@kecan0406/ttheme 1.2.8 → 1.2.10

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/bin/ttheme.js CHANGED
@@ -1,86 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as O1}from"node:module";var k1=Object.create;var{getPrototypeOf:y1,defineProperty:th,getOwnPropertyNames:v1}=Object;var E1=Object.prototype.hasOwnProperty;function S1(t){return this[t]}var M1,I1,Yc=(t,e,n)=>{var r=t!=null&&typeof t==="object";if(r){var i=e?M1??=new WeakMap:I1??=new WeakMap,o=i.get(t);if(o)return o}n=t!=null?k1(y1(t)):{};let s=e||!t||!t.__esModule?th(n,"default",{value:t,enumerable:!0}):n;for(let a of v1(t))if(!E1.call(s,a))th(s,a,{get:S1.bind(t,a),enumerable:!0});if(r)i.set(t,s);return s};var mt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var xt=O1(import.meta.url);var Xc=mt((EH,gh)=>{var Qc={to(t,e){if(!e)return`\x1B[${t+1}G`;return`\x1B[${e+1};${t+1}H`},move(t,e){let n="";if(t<0)n+=`\x1B[${-t}D`;else if(t>0)n+=`\x1B[${t}C`;if(e<0)n+=`\x1B[${-e}A`;else if(e>0)n+=`\x1B[${e}B`;return n},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},_1={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},B1={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let n=0;n<t;n++)e+=this.line+(n<t-1?Qc.up():"");if(t)e+=Qc.left;return e}};gh.exports={cursor:Qc,scroll:_1,erase:B1,beep:"\x07"}});var $u=mt((eF,Yh)=>{var Av=xt("util"),Jh=xt("stream"),we=Yh.exports=function(){Jh.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};Av.inherits(we,Jh);we.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e}),process.nextTick(function(){if(this._process(),this._paused&&this._reads&&this._reads.length>0)this._paused=!1,this.emit("drain")}.bind(this))};we.prototype.write=function(t,e){if(!this.writable)return this.emit("error",Error("Stream not writable")),!1;let n;if(Buffer.isBuffer(t))n=t;else n=Buffer.from(t,e||this._encoding);if(this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&this._reads.length===0)this._paused=!0;return this.writable&&!this._paused};we.prototype.end=function(t,e){if(t)this.write(t,e);if(this.writable=!1,!this._buffers)return;if(this._buffers.length===0)this._end();else this._buffers.push(null),this._process()};we.prototype.destroySoon=we.prototype.end;we.prototype._end=function(){if(this._reads.length>0)this.emit("error",Error("Unexpected end of input"));this.destroy()};we.prototype.destroy=function(){if(!this._buffers)return;this.writable=!1,this._reads=null,this._buffers=null,this.emit("close")};we.prototype._processReadAllowingLess=function(t){this._reads.shift();let e=this._buffers[0];if(e.length>t.length)this._buffered-=t.length,this._buffers[0]=e.slice(t.length),t.func.call(this,e.slice(0,t.length));else this._buffered-=e.length,this._buffers.shift(),t.func.call(this,e)};we.prototype._processRead=function(t){this._reads.shift();let e=0,n=0,r=Buffer.alloc(t.length);while(e<t.length){let i=this._buffers[n++],o=Math.min(i.length,t.length-e);if(i.copy(r,e,0,o),e+=o,o!==i.length)this._buffers[--n]=i.slice(o)}if(n>0)this._buffers.splice(0,n);this._buffered-=t.length,t.func.call(this,r)};we.prototype._process=function(){try{while(this._buffered>0&&this._reads&&this._reads.length>0){let t=this._reads[0];if(t.allowLess)this._processReadAllowingLess(t);else if(this._buffered>=t.length)this._processRead(t);else break}if(this._buffers&&!this.writable)this._end()}catch(t){this.emit("error",t)}}});var ku=mt((Cv)=>{var On=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];Cv.getImagePasses=function(t,e){let n=[],r=t%8,i=e%8,o=(t-r)/8,s=(e-i)/8;for(let a=0;a<On.length;a++){let c=On[a],u=o*c.x.length,l=s*c.y.length;for(let f=0;f<c.x.length;f++)if(c.x[f]<r)u++;else break;for(let f=0;f<c.y.length;f++)if(c.y[f]<i)l++;else break;if(u>0&&l>0)n.push({width:u,height:l,index:a})}return n};Cv.getInterlaceIterator=function(t){return function(e,n,r){let i=e%On[r].x.length,o=(e-i)/On[r].x.length*8+On[r].x[i],s=n%On[r].y.length,a=(n-s)/On[r].y.length*8+On[r].y[s];return o*4+a*t*4}}});var yu=mt((rF,Dh)=>{Dh.exports=function(e,n,r){let i=e+n-r,o=Math.abs(i-e),s=Math.abs(i-n),a=Math.abs(i-r);if(o<=s&&o<=a)return e;if(s<=a)return n;return r}});var vu=mt((iF,Zh)=>{var Uv=ku(),Wv=yu();function Vh(t,e,n){let r=t*e;if(n!==8)r=Math.ceil(r/(8/n));return r}var ri=Zh.exports=function(t,e){let{width:n,height:r,interlace:i,bpp:o,depth:s}=t;if(this.read=e.read,this.write=e.write,this.complete=e.complete,this._imageIndex=0,this._images=[],i){let a=Uv.getImagePasses(n,r);for(let c=0;c<a.length;c++)this._images.push({byteWidth:Vh(a[c].width,o,s),height:a[c].height,lineIndex:0})}else this._images.push({byteWidth:Vh(n,o,s),height:r,lineIndex:0});if(s===8)this._xComparison=o;else if(s===16)this._xComparison=o*2;else this._xComparison=1};ri.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))};ri.prototype._unFilterType1=function(t,e,n){let r=this._xComparison,i=r-1;for(let o=0;o<n;o++){let s=t[1+o],a=o>i?e[o-r]:0;e[o]=s+a}};ri.prototype._unFilterType2=function(t,e,n){let r=this._lastLine;for(let i=0;i<n;i++){let o=t[1+i],s=r?r[i]:0;e[i]=o+s}};ri.prototype._unFilterType3=function(t,e,n){let r=this._xComparison,i=r-1,o=this._lastLine;for(let s=0;s<n;s++){let a=t[1+s],c=o?o[s]:0,u=s>i?e[s-r]:0,l=Math.floor((u+c)/2);e[s]=a+l}};ri.prototype._unFilterType4=function(t,e,n){let r=this._xComparison,i=r-1,o=this._lastLine;for(let s=0;s<n;s++){let a=t[1+s],c=o?o[s]:0,u=s>i?e[s-r]:0,l=s>i&&o?o[s-r]:0,f=Wv(u,c,l);e[s]=a+f}};ri.prototype._reverseFilterLine=function(t){let e=t[0],n,r=this._images[this._imageIndex],i=r.byteWidth;if(e===0)n=t.slice(1,i+1);else switch(n=Buffer.alloc(i),e){case 1:this._unFilterType1(t,n,i);break;case 2:this._unFilterType2(t,n,i);break;case 3:this._unFilterType3(t,n,i);break;case 4:this._unFilterType4(t,n,i);break;default:throw Error("Unrecognised filter type - "+e)}if(this.write(n),r.lineIndex++,r.lineIndex>=r.height)this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex];else this._lastLine=n;if(r)this.read(r.byteWidth+1,this._reverseFilterLine.bind(this));else this._lastLine=null,this.complete()}});var tm=mt((oF,Xh)=>{var _v=xt("util"),Qh=$u(),Bv=vu(),zv=Xh.exports=function(t){Qh.call(this);let e=[],n=this;this._filter=new Bv(t,{read:this.read.bind(this),write:function(r){e.push(r)},complete:function(){n.emit("complete",Buffer.concat(e))}}),this._filter.start()};_v.inherits(zv,Qh)});var ii=mt((sF,em)=>{em.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}});var Mu=mt((aF,nm)=>{var Eu=[];(function(){for(let t=0;t<256;t++){let e=t;for(let n=0;n<8;n++)if(e&1)e=3988292384^e>>>1;else e=e>>>1;Eu[t]=e}})();var Su=nm.exports=function(){this._crc=-1};Su.prototype.write=function(t){for(let e=0;e<t.length;e++)this._crc=Eu[(this._crc^t[e])&255]^this._crc>>>8;return!0};Su.prototype.crc32=function(){return this._crc^-1};Su.crc32=function(t){let e=-1;for(let n=0;n<t.length;n++)e=Eu[(e^t[n])&255]^e>>>8;return e^-1}});var Iu=mt((cF,rm)=>{var St=ii(),Kv=Mu(),Nt=rm.exports=function(t,e){this._options=t,t.checkCRC=t.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[St.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[St.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[St.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[St.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[St.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[St.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=e.read,this.error=e.error,this.metadata=e.metadata,this.gamma=e.gamma,this.transColor=e.transColor,this.palette=e.palette,this.parsed=e.parsed,this.inflateData=e.inflateData,this.finished=e.finished,this.simpleTransparency=e.simpleTransparency,this.headersFinished=e.headersFinished||function(){}};Nt.prototype.start=function(){this.read(St.PNG_SIGNATURE.length,this._parseSignature.bind(this))};Nt.prototype._parseSignature=function(t){let e=St.PNG_SIGNATURE;for(let n=0;n<e.length;n++)if(t[n]!==e[n]){this.error(Error("Invalid file signature"));return}this.read(8,this._parseChunkBegin.bind(this))};Nt.prototype._parseChunkBegin=function(t){let e=t.readUInt32BE(0),n=t.readUInt32BE(4),r="";for(let o=4;o<8;o++)r+=String.fromCharCode(t[o]);let i=Boolean(t[4]&32);if(!this._hasIHDR&&n!==St.TYPE_IHDR){this.error(Error("Expected IHDR on beggining"));return}if(this._crc=new Kv,this._crc.write(Buffer.from(r)),this._chunks[n])return this._chunks[n](e);if(!i){this.error(Error("Unsupported critical chunk type "+r));return}this.read(e+4,this._skipChunk.bind(this))};Nt.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))};Nt.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))};Nt.prototype._parseChunkEnd=function(t){let e=t.readInt32BE(0),n=this._crc.crc32();if(this._options.checkCRC&&n!==e){this.error(Error("Crc error - "+e+" - "+n));return}if(!this._hasIEND)this.read(8,this._parseChunkBegin.bind(this))};Nt.prototype._handleIHDR=function(t){this.read(t,this._parseIHDR.bind(this))};Nt.prototype._parseIHDR=function(t){this._crc.write(t);let e=t.readUInt32BE(0),n=t.readUInt32BE(4),r=t[8],i=t[9],o=t[10],s=t[11],a=t[12];if(r!==8&&r!==4&&r!==2&&r!==1&&r!==16){this.error(Error("Unsupported bit depth "+r));return}if(!(i in St.COLORTYPE_TO_BPP_MAP)){this.error(Error("Unsupported color type"));return}if(o!==0){this.error(Error("Unsupported compression method"));return}if(s!==0){this.error(Error("Unsupported filter method"));return}if(a!==0&&a!==1){this.error(Error("Unsupported interlace method"));return}this._colorType=i;let c=St.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:e,height:n,depth:r,interlace:Boolean(a),palette:Boolean(i&St.COLORTYPE_PALETTE),color:Boolean(i&St.COLORTYPE_COLOR),alpha:Boolean(i&St.COLORTYPE_ALPHA),bpp:c,colorType:i}),this._handleChunkEnd()};Nt.prototype._handlePLTE=function(t){this.read(t,this._parsePLTE.bind(this))};Nt.prototype._parsePLTE=function(t){this._crc.write(t);let e=Math.floor(t.length/3);for(let n=0;n<e;n++)this._palette.push([t[n*3],t[n*3+1],t[n*3+2],255]);this.palette(this._palette),this._handleChunkEnd()};Nt.prototype._handleTRNS=function(t){this.simpleTransparency(),this.read(t,this._parseTRNS.bind(this))};Nt.prototype._parseTRNS=function(t){if(this._crc.write(t),this._colorType===St.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error("Transparency chunk must be after palette"));return}if(t.length>this._palette.length){this.error(Error("More transparent colors than palette size"));return}for(let e=0;e<t.length;e++)this._palette[e][3]=t[e];this.palette(this._palette)}if(this._colorType===St.COLORTYPE_GRAYSCALE)this.transColor([t.readUInt16BE(0)]);if(this._colorType===St.COLORTYPE_COLOR)this.transColor([t.readUInt16BE(0),t.readUInt16BE(2),t.readUInt16BE(4)]);this._handleChunkEnd()};Nt.prototype._handleGAMA=function(t){this.read(t,this._parseGAMA.bind(this))};Nt.prototype._parseGAMA=function(t){this._crc.write(t),this.gamma(t.readUInt32BE(0)/St.GAMMA_DIVISION),this._handleChunkEnd()};Nt.prototype._handleIDAT=function(t){if(!this._emittedHeadersFinished)this._emittedHeadersFinished=!0,this.headersFinished();this.read(-t,this._parseIDAT.bind(this,t))};Nt.prototype._parseIDAT=function(t,e){if(this._crc.write(e),this._colorType===St.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error("Expected palette not found");this.inflateData(e);let n=t-e.length;if(n>0)this._handleIDAT(n);else this._handleChunkEnd()};Nt.prototype._handleIEND=function(t){this.read(t,this._parseIEND.bind(this))};Nt.prototype._parseIEND=function(t){if(this._crc.write(t),this._hasIEND=!0,this._handleChunkEnd(),this.finished)this.finished()}});var Ou=mt((Zv)=>{var im=ku(),qv=[function(){},function(t,e,n,r){if(r===e.length)throw Error("Ran out of data");let i=e[r];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=255},function(t,e,n,r){if(r+1>=e.length)throw Error("Ran out of data");let i=e[r];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=e[r+1]},function(t,e,n,r){if(r+2>=e.length)throw Error("Ran out of data");t[n]=e[r],t[n+1]=e[r+1],t[n+2]=e[r+2],t[n+3]=255},function(t,e,n,r){if(r+3>=e.length)throw Error("Ran out of data");t[n]=e[r],t[n+1]=e[r+1],t[n+2]=e[r+2],t[n+3]=e[r+3]}],Jv=[function(){},function(t,e,n,r){let i=e[0];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=r},function(t,e,n){let r=e[0];t[n]=r,t[n+1]=r,t[n+2]=r,t[n+3]=e[1]},function(t,e,n,r){t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=r},function(t,e,n){t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3]}];function Yv(t,e){let n=[],r=0;function i(){if(r===t.length)throw Error("Ran out of data");let o=t[r];r++;let s,a,c,u,l,f,d,m;switch(e){default:throw Error("unrecognised depth");case 16:d=t[r],r++,n.push((o<<8)+d);break;case 4:d=o&15,m=o>>4,n.push(m,d);break;case 2:l=o&3,f=o>>2&3,d=o>>4&3,m=o>>6&3,n.push(m,d,f,l);break;case 1:s=o&1,a=o>>1&1,c=o>>2&1,u=o>>3&1,l=o>>4&1,f=o>>5&1,d=o>>6&1,m=o>>7&1,n.push(m,d,f,l,u,c,a,s);break}}return{get:function(o){while(n.length<o)i();let s=n.slice(0,o);return n=n.slice(o),s},resetAfterLine:function(){n.length=0},end:function(){if(r!==t.length)throw Error("extra data found")}}}function Dv(t,e,n,r,i,o){let{width:s,height:a,index:c}=t;for(let u=0;u<a;u++)for(let l=0;l<s;l++){let f=n(l,u,c);qv[r](e,i,f,o),o+=r}return o}function Vv(t,e,n,r,i,o){let{width:s,height:a,index:c}=t;for(let u=0;u<a;u++){for(let l=0;l<s;l++){let f=i.get(r),d=n(l,u,c);Jv[r](e,f,d,o)}i.resetAfterLine()}}Zv.dataToBitMap=function(t,e){let{width:n,height:r,depth:i,bpp:o,interlace:s}=e,a;if(i!==8)a=Yv(t,i);let c;if(i<=8)c=Buffer.alloc(n*r*4);else c=new Uint16Array(n*r*4);let u=Math.pow(2,i)-1,l=0,f,d;if(s)f=im.getImagePasses(n,r),d=im.getInterlaceIterator(n,r);else{let m=0;d=function(){let g=m;return m+=4,g},f=[{width:n,height:r}]}for(let m=0;m<f.length;m++)if(i===8)l=Dv(f[m],c,d,o,t,l);else Vv(f[m],c,d,o,a,u);if(i===8){if(l!==t.length)throw Error("extra data found")}else a.end();return c}});var Nu=mt((lF,om)=>{function Xv(t,e,n,r,i){let o=0;for(let s=0;s<r;s++)for(let a=0;a<n;a++){let c=i[t[o]];if(!c)throw Error("index "+t[o]+" not in palette");for(let u=0;u<4;u++)e[o+u]=c[u];o+=4}}function tE(t,e,n,r,i){let o=0;for(let s=0;s<r;s++)for(let a=0;a<n;a++){let c=!1;if(i.length===1){if(i[0]===t[o])c=!0}else if(i[0]===t[o]&&i[1]===t[o+1]&&i[2]===t[o+2])c=!0;if(c)for(let u=0;u<4;u++)e[o+u]=0;o+=4}}function eE(t,e,n,r,i){let o=255,s=Math.pow(2,i)-1,a=0;for(let c=0;c<r;c++)for(let u=0;u<n;u++){for(let l=0;l<4;l++)e[a+l]=Math.floor(t[a+l]*o/s+0.5);a+=4}}om.exports=function(t,e,n=!1){let{depth:r,width:i,height:o,colorType:s,transColor:a,palette:c}=e,u=t;if(s===3)Xv(t,u,i,o,c);else{if(a)tE(t,u,i,o,a);if(r!==8&&!n){if(r===16)u=Buffer.alloc(i*o*4);eE(t,u,i,o,r)}}return u}});var cm=mt((fF,am)=>{var nE=xt("util"),Ru=xt("zlib"),sm=$u(),rE=tm(),iE=Iu(),oE=Ou(),sE=Nu(),Ae=am.exports=function(t){sm.call(this),this._parser=new iE(t,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=t,this.writable=!0,this._parser.start()};nE.inherits(Ae,sm);Ae.prototype._handleError=function(t){if(this.emit("error",t),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy)this._inflate.destroy();if(this._filter)this._filter.destroy(),this._filter.on("error",function(){});this.errord=!0};Ae.prototype._inflateData=function(t){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=Ru.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let n=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,r=Math.max(n,Ru.Z_MIN_CHUNK);this._inflate=Ru.createInflate({chunkSize:r});let i=n,o=this.emit.bind(this,"error");this._inflate.on("error",function(a){if(!i)return;o(a)}),this._filter.on("complete",this._complete.bind(this));let s=this._filter.write.bind(this._filter);this._inflate.on("data",function(a){if(!i)return;if(a.length>i)a=a.slice(0,i);i-=a.length,s(a)}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(t)};Ae.prototype._handleMetaData=function(t){this._metaData=t,this._bitmapInfo=Object.create(t),this._filter=new rE(this._bitmapInfo)};Ae.prototype._handleTransColor=function(t){this._bitmapInfo.transColor=t};Ae.prototype._handlePalette=function(t){this._bitmapInfo.palette=t};Ae.prototype._simpleTransparency=function(){this._metaData.alpha=!0};Ae.prototype._headersFinished=function(){this.emit("metadata",this._metaData)};Ae.prototype._finished=function(){if(this.errord)return;if(!this._inflate)this.emit("error","No Inflate block");else this._inflate.end()};Ae.prototype._complete=function(t){if(this.errord)return;let e;try{let n=oE.dataToBitMap(t,this._bitmapInfo);e=sE(n,this._bitmapInfo,this._options.skipRescale),n=null}catch(n){this._handleError(n);return}this.emit("parsed",e)}});var lm=mt((dF,um)=>{var ce=ii();um.exports=function(t,e,n,r){let i=[ce.COLORTYPE_COLOR_ALPHA,ce.COLORTYPE_ALPHA].indexOf(r.colorType)!==-1;if(r.colorType===r.inputColorType){let g=function(){let $=new ArrayBuffer(2);return new DataView($).setInt16(0,256,!0),new Int16Array($)[0]!==256}();if(r.bitDepth===8||r.bitDepth===16&&g)return t}let o=r.bitDepth!==16?t:new Uint16Array(t.buffer),s=255,a=ce.COLORTYPE_TO_BPP_MAP[r.inputColorType];if(a===4&&!r.inputHasAlpha)a=3;let c=ce.COLORTYPE_TO_BPP_MAP[r.colorType];if(r.bitDepth===16)s=65535,c*=2;let u=Buffer.alloc(e*n*c),l=0,f=0,d=r.bgColor||{};if(d.red===void 0)d.red=s;if(d.green===void 0)d.green=s;if(d.blue===void 0)d.blue=s;function m(){let g,$,w,b=s;switch(r.inputColorType){case ce.COLORTYPE_COLOR_ALPHA:b=o[l+3],g=o[l],$=o[l+1],w=o[l+2];break;case ce.COLORTYPE_COLOR:g=o[l],$=o[l+1],w=o[l+2];break;case ce.COLORTYPE_ALPHA:b=o[l+1],g=o[l],$=g,w=g;break;case ce.COLORTYPE_GRAYSCALE:g=o[l],$=g,w=g;break;default:throw Error("input color type:"+r.inputColorType+" is not supported at present")}if(r.inputHasAlpha){if(!i)b/=s,g=Math.min(Math.max(Math.round((1-b)*d.red+b*g),0),s),$=Math.min(Math.max(Math.round((1-b)*d.green+b*$),0),s),w=Math.min(Math.max(Math.round((1-b)*d.blue+b*w),0),s)}return{red:g,green:$,blue:w,alpha:b}}for(let g=0;g<n;g++)for(let $=0;$<e;$++){let w=m(o,l);switch(r.colorType){case ce.COLORTYPE_COLOR_ALPHA:case ce.COLORTYPE_COLOR:if(r.bitDepth===8){if(u[f]=w.red,u[f+1]=w.green,u[f+2]=w.blue,i)u[f+3]=w.alpha}else if(u.writeUInt16BE(w.red,f),u.writeUInt16BE(w.green,f+2),u.writeUInt16BE(w.blue,f+4),i)u.writeUInt16BE(w.alpha,f+6);break;case ce.COLORTYPE_ALPHA:case ce.COLORTYPE_GRAYSCALE:{let b=(w.red+w.green+w.blue)/3;if(r.bitDepth===8){if(u[f]=b,i)u[f+1]=w.alpha}else if(u.writeUInt16BE(b,f),i)u.writeUInt16BE(w.alpha,f+2);break}default:throw Error("unrecognised color Type "+r.colorType)}l+=a,f+=c}return u}});var hm=mt((hF,dm)=>{var fm=yu();function aE(t,e,n,r,i){for(let o=0;o<n;o++)r[i+o]=t[e+o]}function cE(t,e,n){let r=0,i=e+n;for(let o=e;o<i;o++)r+=Math.abs(t[o]);return r}function uE(t,e,n,r,i,o){for(let s=0;s<n;s++){let a=s>=o?t[e+s-o]:0,c=t[e+s]-a;r[i+s]=c}}function lE(t,e,n,r){let i=0;for(let o=0;o<n;o++){let s=o>=r?t[e+o-r]:0,a=t[e+o]-s;i+=Math.abs(a)}return i}function fE(t,e,n,r,i){for(let o=0;o<n;o++){let s=e>0?t[e+o-n]:0,a=t[e+o]-s;r[i+o]=a}}function dE(t,e,n){let r=0,i=e+n;for(let o=e;o<i;o++){let s=e>0?t[o-n]:0,a=t[o]-s;r+=Math.abs(a)}return r}function hE(t,e,n,r,i,o){for(let s=0;s<n;s++){let a=s>=o?t[e+s-o]:0,c=e>0?t[e+s-n]:0,u=t[e+s]-(a+c>>1);r[i+s]=u}}function mE(t,e,n,r){let i=0;for(let o=0;o<n;o++){let s=o>=r?t[e+o-r]:0,a=e>0?t[e+o-n]:0,c=t[e+o]-(s+a>>1);i+=Math.abs(c)}return i}function gE(t,e,n,r,i,o){for(let s=0;s<n;s++){let a=s>=o?t[e+s-o]:0,c=e>0?t[e+s-n]:0,u=e>0&&s>=o?t[e+s-(n+o)]:0,l=t[e+s]-fm(a,c,u);r[i+s]=l}}function pE(t,e,n,r){let i=0;for(let o=0;o<n;o++){let s=o>=r?t[e+o-r]:0,a=e>0?t[e+o-n]:0,c=e>0&&o>=r?t[e+o-(n+r)]:0,u=t[e+o]-fm(s,a,c);i+=Math.abs(u)}return i}var bE={0:aE,1:uE,2:fE,3:hE,4:gE},wE={0:cE,1:lE,2:dE,3:mE,4:pE};dm.exports=function(t,e,n,r,i){let o;if(!("filterType"in r)||r.filterType===-1)o=[0,1,2,3,4];else if(typeof r.filterType==="number")o=[r.filterType];else throw Error("unrecognised filter types");if(r.bitDepth===16)i*=2;let s=e*i,a=0,c=0,u=Buffer.alloc((s+1)*n),l=o[0];for(let f=0;f<n;f++){if(o.length>1){let d=1/0;for(let m=0;m<o.length;m++){let g=wE[o[m]](t,c,s,i);if(g<d)l=o[m],d=g}}u[a]=l,a++,bE[l](t,c,s,u,a,i),a+=s,c+=s}return u}});var Pu=mt((mF,mm)=>{var Tt=ii(),$E=Mu(),kE=lm(),yE=hm(),vE=xt("zlib"),Nn=mm.exports=function(t){if(this._options=t,t.deflateChunkSize=t.deflateChunkSize||32768,t.deflateLevel=t.deflateLevel!=null?t.deflateLevel:9,t.deflateStrategy=t.deflateStrategy!=null?t.deflateStrategy:3,t.inputHasAlpha=t.inputHasAlpha!=null?t.inputHasAlpha:!0,t.deflateFactory=t.deflateFactory||vE.createDeflate,t.bitDepth=t.bitDepth||8,t.colorType=typeof t.colorType==="number"?t.colorType:Tt.COLORTYPE_COLOR_ALPHA,t.inputColorType=typeof t.inputColorType==="number"?t.inputColorType:Tt.COLORTYPE_COLOR_ALPHA,[Tt.COLORTYPE_GRAYSCALE,Tt.COLORTYPE_COLOR,Tt.COLORTYPE_COLOR_ALPHA,Tt.COLORTYPE_ALPHA].indexOf(t.colorType)===-1)throw Error("option color type:"+t.colorType+" is not supported at present");if([Tt.COLORTYPE_GRAYSCALE,Tt.COLORTYPE_COLOR,Tt.COLORTYPE_COLOR_ALPHA,Tt.COLORTYPE_ALPHA].indexOf(t.inputColorType)===-1)throw Error("option input color type:"+t.inputColorType+" is not supported at present");if(t.bitDepth!==8&&t.bitDepth!==16)throw Error("option bit depth:"+t.bitDepth+" is not supported at present")};Nn.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}};Nn.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())};Nn.prototype.filterData=function(t,e,n){let r=kE(t,e,n,this._options),i=Tt.COLORTYPE_TO_BPP_MAP[this._options.colorType];return yE(r,e,n,this._options,i)};Nn.prototype._packChunk=function(t,e){let n=e?e.length:0,r=Buffer.alloc(n+12);if(r.writeUInt32BE(n,0),r.writeUInt32BE(t,4),e)e.copy(r,8);return r.writeInt32BE($E.crc32(r.slice(4,r.length-4)),r.length-4),r};Nn.prototype.packGAMA=function(t){let e=Buffer.alloc(4);return e.writeUInt32BE(Math.floor(t*Tt.GAMMA_DIVISION),0),this._packChunk(Tt.TYPE_gAMA,e)};Nn.prototype.packIHDR=function(t,e){let n=Buffer.alloc(13);return n.writeUInt32BE(t,0),n.writeUInt32BE(e,4),n[8]=this._options.bitDepth,n[9]=this._options.colorType,n[10]=0,n[11]=0,n[12]=0,this._packChunk(Tt.TYPE_IHDR,n)};Nn.prototype.packIDAT=function(t){return this._packChunk(Tt.TYPE_IDAT,t)};Nn.prototype.packIEND=function(){return this._packChunk(Tt.TYPE_IEND,null)}});var wm=mt((gF,bm)=>{var EE=xt("util"),gm=xt("stream"),SE=ii(),ME=Pu(),pm=bm.exports=function(t){gm.call(this);let e=t||{};this._packer=new ME(e),this._deflate=this._packer.createDeflate(),this.readable=!0};EE.inherits(pm,gm);pm.prototype.pack=function(t,e,n,r){if(this.emit("data",Buffer.from(SE.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(e,n)),r)this.emit("data",this._packer.packGAMA(r));let i=this._packer.filterData(t,e,n);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(o){this.emit("data",this._packer.packIDAT(o))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(i)}});var Sm=mt((to,Em)=>{var $m=xt("assert").ok,oi=xt("zlib"),IE=xt("util"),km=xt("buffer").kMaxLength;function yr(t){if(!(this instanceof yr))return new yr(t);if(t&&t.chunkSize<oi.Z_MIN_CHUNK)t.chunkSize=oi.Z_MIN_CHUNK;if(oi.Inflate.call(this,t),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,t&&t.maxLength!=null)this._maxLength=t.maxLength}function OE(t){return new yr(t)}function ym(t,e){if(e)process.nextTick(e);if(!t._handle)return;t._handle.close(),t._handle=null}yr.prototype._processChunk=function(t,e,n){if(typeof n==="function")return oi.Inflate._processChunk.call(this,t,e,n);let r=this,i=t&&t.length,o=this._chunkSize-this._offset,s=this._maxLength,a=0,c=[],u=0,l;this.on("error",function(g){l=g});function f(g,$){if(r._hadError)return;let w=o-$;if($m(w>=0,"have should not go down"),w>0){let b=r._buffer.slice(r._offset,r._offset+w);if(r._offset+=w,b.length>s)b=b.slice(0,s);if(c.push(b),u+=b.length,s-=b.length,s===0)return!1}if($===0||r._offset>=r._chunkSize)o=r._chunkSize,r._offset=0,r._buffer=Buffer.allocUnsafe(r._chunkSize);if($===0)return a+=i-g,i=g,!0;return!1}$m(this._handle,"zlib binding closed");let d;do d=this._handle.writeSync(e,t,a,i,this._buffer,this._offset,o),d=d||this._writeState;while(!this._hadError&&f(d[0],d[1]));if(this._hadError)throw l;if(u>=km)throw ym(this),RangeError("Cannot create final Buffer. It would be larger than 0x"+km.toString(16)+" bytes");let m=Buffer.concat(c,u);return ym(this),m};IE.inherits(yr,oi.Inflate);function NE(t,e){if(typeof e==="string")e=Buffer.from(e);if(!(e instanceof Buffer))throw TypeError("Not a string or buffer");let n=t._finishFlushFlag;if(n==null)n=oi.Z_FINISH;return t._processChunk(e,n)}function vm(t,e){return NE(new yr(e),t)}Em.exports=to=vm;to.Inflate=yr;to.createInflate=OE;to.inflateSync=vm});var Hu=mt((pF,Im)=>{var Mm=Im.exports=function(t){this._buffer=t,this._reads=[]};Mm.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e})};Mm.prototype.process=function(){while(this._reads.length>0&&this._buffer.length){let t=this._reads[0];if(this._buffer.length&&(this._buffer.length>=t.length||t.allowLess)){this._reads.shift();let e=this._buffer;this._buffer=e.slice(t.length),t.func.call(this,e.slice(0,t.length))}else break}if(this._reads.length>0)throw Error("There are some read requests waitng on finished stream");if(this._buffer.length>0)throw Error("unrecognised content at end of stream")}});var Om=mt((HE)=>{var RE=Hu(),PE=vu();HE.process=function(t,e){let n=[],r=new RE(t);return new PE(e,{read:r.read.bind(r),write:function(o){n.push(o)},complete:function(){}}).start(),r.process(),Buffer.concat(n)}});var Hm=mt((wF,Pm)=>{var Nm=!0,Rm=xt("zlib"),xE=Sm();if(!Rm.deflateSync)Nm=!1;var LE=Hu(),TE=Om(),AE=Iu(),CE=Ou(),jE=Nu();Pm.exports=function(t,e){if(!Nm)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let n;function r(S){n=S}let i;function o(S){i=S}function s(S){i.transColor=S}function a(S){i.palette=S}function c(){i.alpha=!0}let u;function l(S){u=S}let f=[];function d(S){f.push(S)}let m=new LE(t);if(new AE(e,{read:m.read.bind(m),error:r,metadata:o,gamma:l,palette:a,transColor:s,inflateData:d,simpleTransparency:c}).start(),m.process(),n)throw n;let $=Buffer.concat(f);f.length=0;let w;if(i.interlace)w=Rm.inflateSync($);else{let I=((i.width*i.bpp*i.depth+7>>3)+1)*i.height;w=xE($,{chunkSize:I,maxLength:I})}if($=null,!w||!w.length)throw Error("bad png - invalid inflate data response");let b=TE.process(w,i);$=null;let v=CE.dataToBitMap(b,i);b=null;let R=jE(v,i,e.skipRescale);return i.data=R,i.gamma=u||0,i}});var Tm=mt(($F,Lm)=>{var Fm=!0,xm=xt("zlib");if(!xm.deflateSync)Fm=!1;var GE=ii(),UE=Pu();Lm.exports=function(t,e){if(!Fm)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let r=new UE(e||{}),i=[];if(i.push(Buffer.from(GE.PNG_SIGNATURE)),i.push(r.packIHDR(t.width,t.height)),t.gamma)i.push(r.packGAMA(t.gamma));let o=r.filterData(t.data,t.width,t.height),s=xm.deflateSync(o,r.getDeflateOptions());if(o=null,!s||!s.length)throw Error("bad png - invalid compressed data response");return i.push(r.packIDAT(s)),i.push(r.packIEND()),Buffer.concat(i)}});var Am=mt((BE)=>{var WE=Hm(),_E=Tm();BE.read=function(t,e){return WE(t,e||{})};BE.write=function(t,e){return _E(t,e)}});var jm=mt((VE)=>{var qE=xt("util"),Cm=xt("stream"),JE=cm(),YE=wm(),DE=Am(),Gt=VE.PNG=function(t){if(Cm.call(this),t=t||{},this.width=t.width|0,this.height=t.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,t.fill&&this.data)this.data.fill(0);this.gamma=0,this.readable=this.writable=!0,this._parser=new JE(t),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(e){this.data=e,this.emit("parsed",e)}.bind(this)),this._packer=new YE(t),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};qE.inherits(Gt,Cm);Gt.sync=DE;Gt.prototype.pack=function(){if(!this.data||!this.data.length)return this.emit("error","No data provided"),this;return process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this};Gt.prototype.parse=function(t,e){if(e){let n,r;n=function(i){this.removeListener("error",r),this.data=i,e(null,this)}.bind(this),r=function(i){this.removeListener("parsed",n),e(i,null)}.bind(this),this.once("parsed",n),this.once("error",r)}return this.end(t),this};Gt.prototype.write=function(t){return this._parser.write(t),!0};Gt.prototype.end=function(t){this._parser.end(t)};Gt.prototype._metadata=function(t){this.width=t.width,this.height=t.height,this.emit("metadata",t)};Gt.prototype._gamma=function(t){this.gamma=t};Gt.prototype._handleClose=function(){if(!this._parser.writable&&!this._packer.readable)this.emit("close")};Gt.bitblt=function(t,e,n,r,i,o,s,a){if(n|=0,r|=0,i|=0,o|=0,s|=0,a|=0,n>t.width||r>t.height||n+i>t.width||r+o>t.height)throw Error("bitblt reading outside image");if(s>e.width||a>e.height||s+i>e.width||a+o>e.height)throw Error("bitblt writing outside image");for(let c=0;c<o;c++)t.data.copy(e.data,(a+c)*e.width+s<<2,(r+c)*t.width+n<<2,(r+c)*t.width+n+i<<2)};Gt.prototype.bitblt=function(t,e,n,r,i,o,s){return Gt.bitblt(this,t,e,n,r,i,o,s),this};Gt.adjustGamma=function(t){if(t.gamma){for(let e=0;e<t.height;e++)for(let n=0;n<t.width;n++){let r=t.width*e+n<<2;for(let i=0;i<3;i++){let o=t.data[r+i]/255;o=Math.pow(o,0.45454545454545453/t.gamma),t.data[r+i]=Math.round(o*255)}}t.gamma=0}};Gt.prototype.adjustGamma=function(){Gt.adjustGamma(this)}});import{spawnSync as fH}from"node:child_process";import{isMainThread as dH}from"node:worker_threads";import{parseArgs as rH}from"node:util";var Ot={name:"@kecan0406/ttheme",version:"1.2.8",type:"module",bin:{ttheme:"bin/ttheme.js"},files:["bin","dist/manifest.json","shell","!shell/check.zsh"],description:"Character terminal palettes for Ghostty, kitty, Alacritty, WezTerm, iTerm2, Windows Terminal, Warp and Konsole",license:"MIT",author:"kecan0406",repository:{type:"git",url:"git+https://github.com/kecan0406/ttheme.git"},homepage:"https://github.com/kecan0406/ttheme#readme",bugs:"https://github.com/kecan0406/ttheme/issues",keywords:["terminal","theme","ghostty","kitty","alacritty","wezterm","iterm2","konsole"],devDependencies:{"@biomejs/biome":"^2.3.0","@clack/core":"^1.4.3","@clack/prompts":"^1.7.0","@jsquash/jpeg":"^1.6.0","@material/material-color-utilities":"^0.4.0","@types/bun":"^1.3.0","@types/pngjs":"6.0.5","@xterm/headless":"6.0.0","fast-string-width":"^3.0.2",pngjs:"7.0.0","smol-toml":"^1.9.0",typescript:"^5.8.2"},engines:{bun:">=1.3",node:">=20.11"}};import{existsSync as HP,readFileSync as uk}from"node:fs";import{styleText as Ls}from"node:util";import{stdout as wh,stdin as z1}from"node:process";import K1 from"node:readline";var eh=(()=>{let t=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(e)=>{let n=0;t.lastIndex=0;while(t.test(e))n+=1;return e.length-n}})(),nh=(t)=>{return t===12288||t>=65281&&t<=65376||t>=65504&&t<=65510},rh=(t)=>{return t===8987||t===9001||t>=12272&&t<=12287||t>=12289&&t<=12350||t>=12441&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12783&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=65040&&t<=65049||t>=65072&&t<=65106||t>=65108&&t<=65126||t>=65128&&t<=65131||t>=127488&&t<=127490||t>=127504&&t<=127547||t>=127552&&t<=127560||t>=131072&&t<=196605||t>=196608&&t<=262141};var R1=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,P1=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,ih=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,H1=/\t{1,1000}/y,oh=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,F1=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,x1=/\p{M}+/gu,L1={limit:1/0,ellipsis:""},sh=(t,e={},n={})=>{let r=e.limit??1/0,i=e.ellipsis??"",o=e?.ellipsisWidth??(i?sh(i,L1,n).width:0),s=0,a=n.controlWidth??0,c=n.tabWidth??8,u=n.emojiWidth??2,l=2,f=n.regularWidth??1,d=n.wideWidth??2,m=[[F1,f],[R1,0],[P1,a],[H1,c],[oh,u],[ih,d]],g=0,$=0,w=t.length,b=0,v=!1,R=w,S=Math.max(0,r-o),I=0,P=0,O=0,F=0;t:while(!0){if(P>I||$>=w&&$>g){let j=t.slice(I,P)||t.slice(g,$);b=0;for(let W of j.replaceAll(x1,"")){let D=W.codePointAt(0)||0;if(nh(D))F=2;else if(rh(D))F=d;else F=f;if(O+F>S)R=Math.min(R,Math.max(I,g)+b);if(O+F>r){v=!0;break t}b+=W.length,O+=F}I=P=0}if($>=w)break t;for(let j=0,W=m.length;j<W;j++){let[D,_]=m[j];if(D.lastIndex=$,D.test(t)){if(b=D===ih?eh(t.slice($,D.lastIndex)):D===oh?1:D.lastIndex-$,F=b*_,O+F>S)R=Math.min(R,$+Math.floor((S-O)/_));if(O+F>r){v=!0;break t}O+=F,I=g,P=$,$=g=D.lastIndex;continue t}}$+=1}return{width:v?S:O,index:v?R:w,truncated:v,ellipsed:v&&r>=o}},ah=sh;var T1={limit:1/0,ellipsis:"",ellipsisWidth:0},A1=(t,e={})=>{return ah(t,T1,e).width},tt=A1;var Ps="\x1B",dh="›",C1=39,Vc="\x07",hh="[",j1="]",mh="m",Zc=`${j1}8;;`,ch=new RegExp(`(?:\\${hh}(?<code>\\d+)m|\\${Zc}(?<uri>.*)${Vc})`,"y"),uh=(t)=>{if(t>=30&&t<=37)return 39;if(t>=90&&t<=97)return 39;if(t>=40&&t<=47)return 49;if(t>=100&&t<=107)return 49;if(t===1||t===2)return 22;if(t===3)return 23;if(t===4)return 24;if(t===7)return 27;if(t===8)return 28;if(t===9)return 29;if(t===0)return 0;return},lh=(t)=>`${Ps}${hh}${t}${mh}`,fh=(t)=>`${Ps}${Zc}${t}${Vc}`,Dc=(t,e,n)=>{let r=e[Symbol.iterator](),i=!1,o=!1,s=t.at(-1),a=s===void 0?0:tt(s),c=r.next(),u=r.next(),l=0;while(!c.done){let f=c.value,d=tt(f);if(a+d<=n)t[t.length-1]+=f;else t.push(f),a=0;if(f===Ps||f===dh)i=!0,o=e.startsWith(Zc,l+1);if(i){if(o){if(f===Vc)i=!1,o=!1}else if(f===mh)i=!1}else if(a+=d,a===n&&!u.done)t.push(""),a=0;c=u,u=r.next(),l+=f.length}if(s=t.at(-1),!a&&s!==void 0&&s.length&&t.length>1)t[t.length-2]+=t.pop()},G1=(t)=>{let e=t.split(" "),n=e.length;while(n){if(tt(e[n-1]))break;n--}if(n===e.length)return t;return e.slice(0,n).join(" ")+e.slice(n).join("")},U1=(t,e,n={})=>{if(n.trim!==!1&&t.trim()==="")return"";let r="",i,o,s=t.split(" "),a=[""],c=0;for(let f=0;f<s.length;f++){let d=s[f];if(n.trim!==!1){let g=a.at(-1)??"",$=g.trimStart();if(g.length!==$.length)a[a.length-1]=$,c=tt($)}if(f!==0){if(c>=e&&(n.wordWrap===!1||n.trim===!1))a.push(""),c=0;if(c||n.trim===!1)a[a.length-1]+=" ",c++}let m=tt(d);if(n.hard&&m>e){let g=e-c,$=1+Math.floor((m-g-1)/e);if(Math.floor((m-1)/e)<$)a.push("");Dc(a,d,e),c=tt(a.at(-1)??"");continue}if(c+m>e&&c&&m){if(n.wordWrap===!1&&c<e){Dc(a,d,e),c=tt(a.at(-1)??"");continue}a.push(""),c=0}if(c+m>e&&n.wordWrap===!1){Dc(a,d,e),c=tt(a.at(-1)??"");continue}a[a.length-1]+=d,c+=m}if(n.trim!==!1)a=a.map((f)=>G1(f));let u=a.join(`
3
- `),l=!1;for(let f=0;f<u.length;f++){let d=u[f];if(r+=d,!l){if(l=d>="\uD800"&&d<="\uDBFF",l)continue}else l=!1;if(d===Ps||d===dh){ch.lastIndex=f+1;let g=ch.exec(u)?.groups;if(g?.code!==void 0){let $=Number.parseFloat(g.code);i=$===C1?void 0:$}else if(g?.uri!==void 0)o=g.uri.length===0?void 0:g.uri}if(u[f+1]===`
4
- `){if(o)r+=fh("");let m=i?uh(i):void 0;if(i&&m)r+=lh(m)}else if(d===`
5
- `){if(i&&uh(i))r+=lh(i);if(o)r+=fh(o)}}return r},W1=/\r?\n/;function yn(t,e,n){return String(t).normalize().split(W1).map((r)=>U1(r,e,n)).join(`
6
- `)}var Jt=Yc(Xc(),1);function en(t,e,n){if(!n.some((s)=>!s.disabled))return t;let r=t+e,i=Math.max(n.length-1,0),o=r<0?i:r>i?0:r;return n[o]?.disabled?en(o,e<0?-1:1,n):o}function Hs(t,e,n,r){let i=r.split(`
7
- `),o=0,s=t;for(let c of i){if(s<=c.length)break;s-=c.length+1,o++}for(o=Math.max(0,Math.min(i.length-1,o+n)),s=Math.min(s,i[o].length)+e;s<0&&o>0;)o--,s+=i[o].length+1;for(;s>i[o].length&&o<i.length-1;)s-=i[o].length+1,o++;s=Math.max(0,Math.min(i[o].length,s));let a=0;for(let c=0;c<o;c++)a+=i[c].length+1;return a+s}var q1=["up","down","left","right","space","enter","cancel"],J1=["January","February","March","April","May","June","July","August","September","October","November","December"],Pt={actions:new Set(q1),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...J1],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(t,e)=>`There are only ${t} days in ${e}`,afterMin:(t)=>`Date must be on or after ${t.toISOString().slice(0,10)}`,beforeMax:(t)=>`Date must be on or before ${t.toISOString().slice(0,10)}`}}};function $h(t,e){if(typeof t=="string")return Pt.aliases.get(t)===e;for(let n of t)if(n!==void 0&&$h(n,e))return!0;return!1}function Y1(t,e){if(t===e)return;let n=t.split(`
8
- `),r=e.split(`
9
- `),i=Math.max(n.length,r.length),o=[];for(let s=0;s<i;s++)n[s]!==r[s]&&o.push(s);return{lines:o,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}var NH=globalThis.process.platform.startsWith("win"),eu=Symbol("clack:cancel");function Lt(t){return t===eu}function Fs(t,e){let n=t;n.isTTY&&n.setRawMode(e)}var Ts=(t)=>("columns"in t)&&typeof t.columns=="number"?t.columns:80,ru=(t)=>("rows"in t)&&typeof t.rows=="number"?t.rows:20;function vn(t,e,n,r=n,i=n,o){let s=Ts(t??wh);return yn(e,s-n.length,{hard:!0,trim:!1}).split(`
10
- `).map((a,c,u)=>{let l=o?o(a,c):a;return c===0?`${r}${l}`:c===u.length-1?`${i}${l}`:`${n}${l}`}).join(`
11
- `)}function kh(t,e){if("~standard"in t){let n=t["~standard"].validate(e);if(n instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return n.issues?.at(0)?.message}return t(e)}class Yt{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(t,e=!0){let{input:n=z1,output:r=wh,render:i,signal:o,...s}=t;this.opts=s,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=e,this._abortSignal=o,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(t,e){let n=this._subscribers.get(t)??[];n.push(e),this._subscribers.set(t,n)}on(t,e){this.setSubscriber(t,{cb:e})}once(t,e){this.setSubscriber(t,{cb:e,once:!0})}emit(t,...e){let n=this._subscribers.get(t)??[],r=[];for(let i of n)i.cb(...e),i.once&&r.push(()=>n.splice(n.indexOf(i),1));for(let i of r)i()}prompt(){return new Promise((t)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(eu);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=K1.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),Fs(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(Jt.cursor.show),this.output.off("resize",this.render),Fs(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(Jt.cursor.show),this.output.off("resize",this.render),Fs(this.input,!1),t(eu)})})}_isActionKey(t,e){return t==="\t"}_shouldSubmit(t,e){return!0}_setValue(t){this.value=t,this.emit("value",this.value)}_setUserInput(t,e){this.userInput=t??"",this.emit("userInput",this.userInput),e&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(t,e){if(this._track&&e.name!=="return"&&(e.name&&this._isActionKey(t,e)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),e?.name&&(!this._track&&Pt.aliases.has(e.name)&&this.emit("cursor",Pt.aliases.get(e.name)),Pt.actions.has(e.name)&&this.emit("cursor",e.name)),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),this.emit("key",t,e),e?.name==="return"&&this._shouldSubmit(t,e)){if(this.opts.validate){let n=kh(this.opts.validate,this.value);n&&(this.error=n instanceof Error?n.message:n,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}$h([t,e?.name,e?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
12
- `),Fs(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t=yn(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
13
- `).length-1;this.output.write(Jt.cursor.move(-999,t*-1))}render(){let t=yn(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(Jt.cursor.hide);else{let e=Y1(this._prevFrame,t),n=ru(this.output);if(this.restoreCursor(),e){let r=Math.max(0,e.numLinesAfter-n),i=Math.max(0,e.numLinesBefore-n),o=e.lines.find((s)=>s>=r);if(o===void 0){this._prevFrame=t;return}if(e.lines.length===1){this.output.write(Jt.cursor.move(0,o-i)),this.output.write(Jt.erase.lines(1));let s=t.split(`
14
- `);this.output.write(s[o]),this._prevFrame=t,this.output.write(Jt.cursor.move(0,s.length-o-1));return}else if(e.lines.length>1){if(r<i)o=r;else{let a=o-i;a>0&&this.output.write(Jt.cursor.move(0,a))}this.output.write(Jt.erase.down());let s=t.split(`
15
- `).slice(o);this.output.write(s.join(`
16
- `)),this._prevFrame=t;return}}this.output.write(Jt.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}function D1(t,e){if(t===void 0||e.length===0)return 0;let n=e.findIndex((r)=>r.value===t);return n!==-1?n:0}function V1(t,e){return(e.label??String(e.value)).toLowerCase().includes(t.toLowerCase())}function Z1(t,e){if(e)return t?e:e[0]}var Q1=class extends Yt{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#e=0;#n="";#t;#o;#a;get cursor(){return this.#e}get userInputWithCursor(){if(!this.userInput)return Ls(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let e=this.userInput.slice(0,this.cursor),n=this.userInput.slice(this.cursor,this.cursor+1),r=this.userInput.slice(this.cursor+1);return`${e}${Ls("inverse",n)}${r}`}get options(){return typeof this.#o=="function"?this.#o():this.#o}constructor(e){super(e),this.#o=e.options,this.#a=e.placeholder;let n=this.options;this.filteredOptions=[...n],this.multiple=e.multiple===!0,this.#t=typeof e.options=="function"?e.filter:e.filter??V1;let r;if(e.initialValue&&Array.isArray(e.initialValue)?this.multiple?r=e.initialValue:r=e.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(r=[this.options[0]?.value]),r)for(let i of r){let o=n.findIndex((s)=>s.value===i);o!==-1&&(this.toggleSelected(i),this.#e=o)}this.focusedValue=this.options[this.#e]?.value,this.on("key",(i,o)=>this.#r(i,o)),this.on("userInput",(i)=>this.#i(i))}_isActionKey(e,n){return e==="\t"||this.multiple&&this.isNavigating&&n.name==="space"&&e!==void 0&&e!==""}#r(e,n){let r=n.name==="up",i=n.name==="down",o=n.name==="return",s=this.userInput===""||this.userInput==="\t",a=this.#a,c=this.options,u=a!==void 0&&a!==""&&c.some((l)=>!l.disabled&&(this.#t?this.#t(a,l):!0));if(n.name==="tab"&&s&&u){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(a,!0),this.isNavigating=!1;return}r||i?(this.#e=en(this.#e,r?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#e]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):o?this.value=Z1(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(n.name==="tab"||this.isNavigating&&n.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(e){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(e)?this.selectedValues=this.selectedValues.filter((n)=>n!==e):this.selectedValues=[...this.selectedValues,e]:this.selectedValues=[e])}#i(e){if(e!==this.#n){this.#n=e;let n=this.options;e&&this.#t?this.filteredOptions=n.filter((o)=>this.#t?.(e,o)):this.filteredOptions=[...n];let r=D1(this.focusedValue,this.filteredOptions);this.#e=en(r,0,this.filteredOptions);let i=this.filteredOptions[this.#e];i&&!i.disabled?this.focusedValue=i.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};class iu extends Yt{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(e)=>{this.output.write(Jt.cursor.move(0,-1)),this.value=e,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var X1={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};function ph(t){return[...t].map((e)=>X1[e])}function tv(t){let e=new Intl.DateTimeFormat(t,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),n=[],r="/";for(let i of e)i.type==="literal"?r=i.value.trim()||i.value:(i.type==="year"||i.type==="month"||i.type==="day")&&n.push({type:i.type,len:i.type==="year"?4:2});return{segments:n,separator:r}}function tu(t){return Number.parseInt((t||"0").replace(/_/g,"0"),10)||0}function xs(t){return{year:tu(t.year),month:tu(t.month),day:tu(t.day)}}function nu(t,e){return new Date(t||2001,e||1,0).getDate()}function yh(t){let{year:e,month:n,day:r}=xs(t);if(!e||e<0||e>9999||!n||n<1||n>12||!r||r<1)return;let i=new Date(Date.UTC(e,n-1,r));if(!(i.getUTCFullYear()!==e||i.getUTCMonth()!==n-1||i.getUTCDate()!==r))return{year:e,month:n,day:r}}function bh(t){let e=yh(t);return e?new Date(Date.UTC(e.year,e.month-1,e.day)):void 0}function ev(t,e,n,r){let i=n?{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate()}:null,o=r?{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate()}:null;return t==="year"?{min:i?.year??1,max:o?.year??9999}:t==="month"?{min:i&&e.year===i.year?i.month:1,max:o&&e.year===o.year?o.month:12}:{min:i&&e.year===i.year&&e.month===i.month?i.day:1,max:o&&e.year===o.year&&e.month===o.month?o.day:nu(e.year,e.month)}}class vh extends Yt{#e;#n;#t;#o;#a;#r={segmentIndex:0,positionInSegment:0};#i=!0;#s=null;inlineError="";get segmentCursor(){return{...this.#r}}get segmentValues(){return{...this.#t}}get segments(){return this.#e}get separator(){return this.#n}get formattedValue(){return this.#f(this.#t)}#f(t){return this.#e.map((e)=>t[e.type]).join(this.#n)}#c(){this._setUserInput(this.#f(this.#t)),this._setValue(bh(this.#t)??void 0)}constructor(t){let e=t.format?{segments:ph(t.format),separator:t.separator??"/"}:tv(t.locale),n=t.separator??e.separator,r=t.format?ph(t.format):e.segments,i=t.initialValue??t.defaultValue,o=i?{year:String(i.getUTCFullYear()).padStart(4,"0"),month:String(i.getUTCMonth()+1).padStart(2,"0"),day:String(i.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},s=r.map((a)=>o[a.type]).join(n);super({...t,initialUserInput:s},!1),this.#e=r,this.#n=n,this.#t=o,this.#o=t.minDate,this.#a=t.maxDate,this.#c(),this.on("cursor",(a)=>this.#m(a)),this.on("key",(a,c)=>this.#g(a,c)),this.on("finalize",()=>this.#p(t))}#u(){let t=Math.max(0,Math.min(this.#r.segmentIndex,this.#e.length-1)),e=this.#e[t];if(e)return this.#r.positionInSegment=Math.max(0,Math.min(this.#r.positionInSegment,e.len-1)),{segment:e,index:t}}#l(t){this.inlineError="",this.#s=null;let e=this.#u();e&&(this.#r.segmentIndex=Math.max(0,Math.min(this.#e.length-1,e.index+t)),this.#r.positionInSegment=0,this.#i=!0)}#d(t){let e=this.#u();if(!e)return;let{segment:n}=e,r=this.#t[n.type],i=!r||r.replace(/_/g,"")==="",o=Number.parseInt((r||"0").replace(/_/g,"0"),10)||0,s=ev(n.type,xs(this.#t),this.#o,this.#a),a;i?a=t===1?s.min:s.max:a=Math.max(Math.min(s.max,o+t),s.min),this.#t={...this.#t,[n.type]:a.toString().padStart(n.len,"0")},this.#i=!0,this.#s=null,this.#c()}#m(t){if(t)switch(t){case"right":return this.#l(1);case"left":return this.#l(-1);case"up":return this.#d(1);case"down":return this.#d(-1)}}#g(t,e){if(e?.name==="backspace"||e?.sequence===""||e?.sequence==="\b"||t===""||t==="\b"){this.inlineError="";let n=this.#u();if(!n)return;if(!this.#t[n.segment.type].replace(/_/g,"")){this.#l(-1);return}this.#t[n.segment.type]="_".repeat(n.segment.len),this.#i=!0,this.#r.positionInSegment=0,this.#c();return}if(e?.name==="tab"){this.inlineError="";let n=this.#u();if(!n)return;let r=e.shift?-1:1,i=n.index+r;i>=0&&i<this.#e.length&&(this.#r.segmentIndex=i,this.#r.positionInSegment=0,this.#i=!0);return}if(t&&/^[0-9]$/.test(t)){let n=this.#u();if(!n)return;let{segment:r}=n,i=!this.#t[r.type].replace(/_/g,"");if(this.#i&&this.#s!==null&&!i){let d=this.#s+t,m={...this.#t,[r.type]:d},g=this.#h(m,r);if(g){this.inlineError=g,this.#s=null,this.#i=!1;return}this.inlineError="",this.#t[r.type]=d,this.#s=null,this.#i=!1,this.#c(),n.index<this.#e.length-1&&(this.#r.segmentIndex=n.index+1,this.#r.positionInSegment=0,this.#i=!0);return}this.#i&&!i&&(this.#t[r.type]="_".repeat(r.len),this.#r.positionInSegment=0),this.#i=!1,this.#s=null;let o=this.#t[r.type],s=o.indexOf("_"),a=s>=0?s:Math.min(this.#r.positionInSegment,r.len-1);if(a<0||a>=r.len)return;let c=o.slice(0,a)+t+o.slice(a+1),u=!1;if(a===0&&o==="__"&&(r.type==="month"||r.type==="day")){let d=Number.parseInt(t,10);c=`0${t}`,u=d<=(r.type==="month"?1:2)}if(r.type==="year"&&(c=(o.replace(/_/g,"")+t).padStart(r.len,"_")),!c.includes("_")){let d={...this.#t,[r.type]:c},m=this.#h(d,r);if(m){this.inlineError=m;return}}this.inlineError="",this.#t[r.type]=c;let l=c.includes("_")?void 0:yh(this.#t);if(l){let{year:d,month:m}=l,g=nu(d,m);this.#t={year:String(Math.max(0,Math.min(9999,d))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,m))).padStart(2,"0"),day:String(Math.max(1,Math.min(g,l.day))).padStart(2,"0")}}this.#c();let f=c.indexOf("_");u?(this.#i=!0,this.#s=t):f>=0?this.#r.positionInSegment=f:s>=0&&n.index<this.#e.length-1?(this.#r.segmentIndex=n.index+1,this.#r.positionInSegment=0,this.#i=!0):this.#r.positionInSegment=Math.min(a+1,r.len-1)}}#h(t,e){let{month:n,day:r}=xs(t);if(e.type==="month"&&(n<0||n>12))return Pt.date.messages.invalidMonth;if(e.type==="day"&&(r<0||r>31))return Pt.date.messages.invalidDay(31,"any month")}#p(t){let{year:e,month:n,day:r}=xs(this.#t);if(e&&n&&r){let i=nu(e,n);this.#t={...this.#t,day:String(Math.min(r,i)).padStart(2,"0")}}this.value=bh(this.#t)??t.defaultValue??void 0}}var nv=class extends Yt{options;cursor=0;#e;getGroupItems(e){return this.options.filter((n)=>n.group===e)}isGroupSelected(e){let n=this.getGroupItems(e),r=this.value;return r===void 0?!1:n.every((i)=>r.includes(i.value))}toggleValue(){let e=this.options[this.cursor];if(e!==void 0)if(this.value===void 0&&(this.value=[]),e.group===!0){let n=e.value,r=this.getGroupItems(n);this.isGroupSelected(n)?this.value=this.value.filter((i)=>r.findIndex((o)=>o.value===i)===-1):this.value=[...this.value,...r.map((i)=>i.value)],this.value=Array.from(new Set(this.value))}else{let n=this.value.includes(e.value);this.value=n?this.value.filter((r)=>r!==e.value):[...this.value,e.value]}}constructor(e){super(e,!1);let{options:n}=e;this.#e=e.selectableGroups!==!1,this.options=Object.entries(n).flatMap(([r,i])=>[{value:r,group:!0,label:r},...i.map((o)=>({...o,group:r}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:r})=>r===e.cursorAt),this.#e?0:1),this.on("cursor",(r)=>{switch(r){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let i=this.options[this.cursor]?.group===!0;!this.#e&&i&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let i=this.options[this.cursor]?.group===!0;!this.#e&&i&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},rv=new Set(["up","down","left","right"]);class Eh extends Yt{#e=!1;#n;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${t}█`;let e=t.slice(0,this.cursor),n=t.slice(this.cursor,this.cursor+1),r=t.slice(this.cursor+1);return n===`
17
- `?`${e}█
18
- ${r}`:`${e}${Ls("inverse",n)}${r}`}get cursor(){return this._cursor}#t(t){if(this.userInput.length===0){this._setUserInput(t);return}this._setUserInput(this.userInput.slice(0,this.cursor)+t+this.userInput.slice(this.cursor))}#o(t){let e=this.value??"";switch(t){case"up":this._cursor=Hs(this._cursor,0,-1,e);return;case"down":this._cursor=Hs(this._cursor,0,1,e);return;case"left":this._cursor=Hs(this._cursor,-1,0,e);return;case"right":this._cursor=Hs(this._cursor,1,0,e);return}}_shouldSubmit(t,e){if(this.#n)return this.focused==="submit"?!0:(this.#t(`
19
- `),this._cursor++,!1);let n=this.#e;return this.#e=!0,n&&this.cursor===this.userInput.length?(this.userInput[this.cursor-1]===`
20
- `&&(this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--),!0):(this.#t(`
21
- `),this._cursor++,!1)}constructor(t){let e=t.initialUserInput??t.initialValue;super({...t,initialUserInput:e},!1),e!==void 0&&(this._cursor=e.length),this.#n=t.showSubmit??!1,this.on("key",(n,r)=>{if(r?.name&&rv.has(r.name)){this.#e=!1,this.#o(r.name);return}if(n==="\t"&&this.#n){this.focused=this.focused==="editor"?"submit":"editor";return}if(r?.name!=="return"){if(this.#e=!1,r?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(r?.name==="delete"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}n&&(this.#n&&this.focused==="submit"&&(this.focused="editor"),this.#t(n??""),this._cursor++)}}),this.on("userInput",(n)=>{this._setValue(n)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}}class ou extends Yt{options;cursor=0;get _value(){return this.options[this.cursor]?.value}get _enabledOptions(){return this.options.filter((t)=>t.disabled!==!0)}toggleAll(){let t=this._enabledOptions,e=this.value!==void 0&&this.value.length===t.length;this.value=e?[]:t.map((n)=>n.value)}toggleInvert(){let t=this.value;if(!t)return;let e=this._enabledOptions.filter((n)=>!t.includes(n.value));this.value=e.map((n)=>n.value)}toggleValue(){this.value===void 0&&(this.value=[]);let t=this.value.includes(this._value);this.value=t?this.value.filter((e)=>e!==this._value):[...this.value,this._value]}constructor(t){super(t,!1),this.options=t.options,this.value=[...t.initialValues??[]];let e=Math.max(this.options.findIndex(({value:n})=>n===t.cursorAt),0);this.cursor=this.options[e]?.disabled?en(e,1,this.options):e,this.on("key",(n,r)=>{r.name==="a"&&this.toggleAll(),r.name==="i"&&this.toggleInvert()}),this.on("cursor",(n)=>{switch(n){case"left":case"up":this.cursor=en(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=en(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}}var Sh=class extends Yt{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let e=this._selectedValue;this.value=e===void 0?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;let n=this.options.findIndex(({value:i})=>i===e.initialValue),r=n===-1?0:n;this.cursor=this.options[r]?.disabled?en(r,1,this.options):r,this.changeValue(),this.on("cursor",(i)=>{switch(i){case"left":case"up":this.cursor=en(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=en(this.cursor,1,this.options);break}this.changeValue()})}};class su extends Yt{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}█`;let e=t.slice(0,this.cursor),n=t.slice(this.cursor,this.cursor+1),r=t.slice(this.cursor+1);return`${e}${Ls("inverse",n)}${r}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",(e)=>{this._setValue(e)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}}import{styleText as E,stripVTControlCharacters as AH}from"node:util";import ae from"node:process";var Rh=Yc(Xc(),1);function iv(){if(ae.platform!=="win32")return ae.env.TERM!=="linux";return Boolean(ae.env.CI)||Boolean(ae.env.WT_SESSION)||Boolean(ae.env.TERMINUS_SUBLIME)||ae.env.ConEmuTask==="{cmd::Cmder}"||ae.env.TERM_PROGRAM==="Terminus-Sublime"||ae.env.TERM_PROGRAM==="vscode"||ae.env.TERM==="xterm-256color"||ae.env.TERM==="alacritty"||ae.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var ov=iv();var ot=(t,e)=>ov?t:e,sv=ot("◆","*"),av=ot("■","x"),cv=ot("▲","x"),uu=ot("◇","o"),uv=ot("┌","T"),Z=ot("│","|"),nn=ot("└","—"),UH=ot("┐","T"),WH=ot("┘","—"),au=ot("●",">"),Cs=ot("○"," "),lv=ot("◻","[•]"),Mh=ot("◼","[+]"),Ih=ot("◻","[ ]"),_H=ot("▪","•"),Oh=ot("─","-"),fv=ot("╮","+"),dv=ot("├","+"),hv=ot("╯","+"),mv=ot("╰","+"),BH=ot("╭","+"),gv=ot("●","•"),pv=ot("◆","*"),bv=ot("▲","!"),wv=ot("■","x"),js=(t)=>{switch(t){case"initial":case"active":return E("cyan",sv);case"cancel":return E("red",av);case"error":return E("yellow",cv);case"submit":return E("green",uu)}},Ph=(t)=>{switch(t){case"initial":case"active":return E("cyan",Z);case"cancel":return E("red",Z);case"error":return E("yellow",Z);case"submit":return E("green",Z)}};function Hh(t,e){let n=[`${e?`${E("cyan",Z)} `:""}${t.join(" • ")}`];return e&&n.push(E("cyan",nn)),n}var Nh=(t,e,n,r,i,o=!1)=>{let s=e,a=0;if(o)for(let c=r-1;c>=n;c--){let u=t[c];if(u&&(s-=u.length),a++,s<=i)break}else for(let c=n;c<r;c++){let u=t[c];if(u&&(s-=u.length),a++,s<=i)break}return{lineCount:s,removals:a}},cu=({cursor:t,options:e,style:n,output:r=process.stdout,maxItems:i=Number.POSITIVE_INFINITY,columnPadding:o=0,rowPadding:s=4})=>{let a=Ts(r)-o,c=ru(r),u=E("dim","..."),l=Math.max(c-s,0),f=Math.max(Math.min(i,l),5),d=0;t>=f-3&&(d=Math.max(Math.min(t-f+3,e.length-f),0));let m=f<e.length&&d>0,g=f<e.length&&d+f<e.length,$=Math.min(d+f,e.length),w=[],b=0;m&&b++,g&&b++;let v=d+(m?1:0),R=$-(g?1:0);for(let I=v;I<R;I++){let P=e[I],O=P?n(P,I===t):"",F=yn(O,a,{hard:!0,trim:!1}).split(`
22
- `);w.push(F),b+=F.length}if(b>l){let I=0,P=0,O=b,F=t-v,j=l,W=()=>Nh(w,O,0,F,j),D=()=>Nh(w,O,F+1,w.length,j,!0);m?({lineCount:O,removals:I}=W(),O>j&&(g||(j-=1),{lineCount:O,removals:P}=D())):(g||(j-=1),{lineCount:O,removals:P}=D(),O>j&&(j-=1,{lineCount:O,removals:I}=W())),I>0&&(m=!0,w.splice(0,I)),P>0&&(g=!0,w.splice(w.length-P,P))}let S=[];m&&S.push(u);for(let I of w)for(let P of I)S.push(P);return g&&S.push(u),S};var rn=(t)=>{let e=t.active??"Yes",n=t.inactive??"No";return new iu({active:e,inactive:n,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue??!0,render(){let r=t.withGuide??Pt.withGuide,i=`${js(this.state)} `,o=r?`${E("gray",Z)} `:"",s=vn(t.output,t.message,o,i),a=`${r?`${E("gray",Z)}
23
- `:""}${s}
24
- `,c=this.value?e:n;switch(this.state){case"submit":{let u=r?`${E("gray",Z)} `:"";return`${a}${u}${E("dim",c)}`}case"cancel":{let u=r?`${E("gray",Z)} `:"";return`${a}${u}${E(["strikethrough","dim"],c)}${r?`
25
- ${E("gray",Z)}`:""}`}default:{let u=r?`${E("cyan",Z)} `:"",l=r?E("cyan",nn):"";return`${a}${u}${this.value?`${E("green",au)} ${e}`:`${E("dim",Cs)} ${E("dim",e)}`}${t.vertical?r?`
26
- ${E("cyan",Z)} `:`
27
- `:` ${E("dim","/")} `}${this.value?`${E("dim",Cs)} ${E("dim",n)}`:`${E("green",au)} ${n}`}
28
- ${l}
29
- `}}}}).prompt()};var $v=[`${E("dim","↑/↓")} to navigate`,`${E("dim","Space:")} select`,`${E("dim","Enter:")} confirm`],Vi=(t,e)=>t.split(`
30
- `).map((n)=>e(n)).join(`
31
- `),Fh=(t)=>{let e=(i,o)=>{let s=i.label??String(i.value);return o==="disabled"?`${E("gray",Ih)} ${Vi(s,(a)=>E(["strikethrough","gray"],a))}${i.hint?` ${E("dim",`(${i.hint??"disabled"})`)}`:""}`:o==="active"?`${E("cyan",lv)} ${s}${i.hint?` ${E("dim",`(${i.hint})`)}`:""}`:o==="selected"?`${E("green",Mh)} ${Vi(s,(a)=>E("dim",a))}${i.hint?` ${E("dim",`(${i.hint})`)}`:""}`:o==="cancelled"?`${Vi(s,(a)=>E(["strikethrough","dim"],a))}`:o==="active-selected"?`${E("green",Mh)} ${s}${i.hint?` ${E("dim",`(${i.hint})`)}`:""}`:o==="submitted"?`${Vi(s,(a)=>E("dim",a))}`:`${E("dim",Ih)} ${Vi(s,(a)=>E("dim",a))}`},n=t.required??!0,r=t.showInstructions??!0;return new ou({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValues:t.initialValues,required:n,cursorAt:t.cursorAt,validate(i){if(n&&(i===void 0||i.length===0))return`Please select at least one option.
32
- ${E("reset",E("dim",`Press ${E(["gray","bgWhite","inverse"]," space ")} to select, ${E("gray",E("bgWhite",E("inverse"," enter ")))} to submit`))}`},render(){let i=t.withGuide??Pt.withGuide,o=vn(t.output,t.message,i?`${Ph(this.state)} `:"",`${js(this.state)} `),s=`${i?`${E("gray",Z)}
33
- `:""}${o}
34
- `,a=this.value??[],c=(u,l)=>{if(u.disabled)return e(u,"disabled");let f=a.includes(u.value);return l&&f?e(u,"active-selected"):f?e(u,"selected"):e(u,l?"active":"inactive")};switch(this.state){case"submit":{let u=this.options.filter(({value:f})=>a.includes(f)).map((f)=>e(f,"submitted")).join(E("dim",", "))||E("dim","none"),l=vn(t.output,u,i?`${E("gray",Z)} `:"");return`${s}${l}`}case"cancel":{let u=this.options.filter(({value:f})=>a.includes(f)).map((f)=>e(f,"cancelled")).join(E("dim",", "));if(u.trim()==="")return`${s}${E("gray",Z)}`;let l=vn(t.output,u,i?`${E("gray",Z)} `:"");return`${s}${l}${i?`
35
- ${E("gray",Z)}`:""}`}case"error":{let u=i?`${E("yellow",Z)} `:"",l=this.error.split(`
36
- `).map((m,g)=>g===0?`${i?`${E("yellow",nn)} `:""}${E("yellow",m)}`:` ${m}`).join(`
37
- `),f=s.split(`
38
- `).length,d=l.split(`
39
- `).length+1;return`${s}${u}${cu({output:t.output,options:this.options,cursor:this.cursor,maxItems:t.maxItems,columnPadding:u.length,rowPadding:f+d,style:c}).join(`
40
- ${u}`)}
41
- ${l}
42
- `}default:{let u=i?`${E("cyan",Z)} `:"",l=s.split(`
43
- `).length,f=r?Hh($v,i):i?[E("cyan",nn)]:[],d=f.join(`
44
- `),m=f.length+1;return`${s}${u}${cu({output:t.output,options:this.options,cursor:this.cursor,maxItems:t.maxItems,columnPadding:u.length,rowPadding:l+m,style:c}).join(`
45
- ${u}`)}
46
- ${d}
47
- `}}}}).prompt()};var En={message:(t=[],{symbol:e=E("gray",Z),secondarySymbol:n=E("gray",Z),output:r=process.stdout,spacing:i=1,withGuide:o}={})=>{let s=[],a=o??Pt.withGuide,c=a?n:"",u=a?`${e} `:"",l=a?`${n} `:"";for(let d=0;d<i;d++)s.push(c);let f=Array.isArray(t)?t:t.split(`
48
- `);if(f.length>0){let[d,...m]=f;d.length>0?s.push(`${u}${d}`):s.push(a?e:"");for(let g of m)g.length>0?s.push(`${l}${g}`):s.push(a?n:"")}r.write(`${s.join(`
49
- `)}
50
- `)},info:(t,e)=>{En.message(t,{...e,symbol:E("blue",gv)})},success:(t,e)=>{En.message(t,{...e,symbol:E("green",pv)})},step:(t,e)=>{En.message(t,{...e,symbol:E("green",uu)})},warn:(t,e)=>{En.message(t,{...e,symbol:E("yellow",bv)})},warning:(t,e)=>{En.warn(t,e)},error:(t,e)=>{En.message(t,{...e,symbol:E("red",wv)})}},Vr=(t="",e)=>{let n=e?.output??process.stdout,r=e?.withGuide??Pt.withGuide?`${E("gray",nn)} `:"";n.write(`${r}${E("red",t)}
51
-
52
- `)},Gs=(t="",e)=>{let n=e?.output??process.stdout,r=e?.withGuide??Pt.withGuide?`${E("gray",uv)} `:"";n.write(`${r}${t}
53
- `)},lu=(t="",e)=>{let n=e?.output??process.stdout,r=e?.withGuide??Pt.withGuide?`${E("gray",Z)}
54
- ${E("gray",nn)} `:"";n.write(`${r}${t}
55
-
56
- `)};var kv=(t)=>t,yv=(t,e,n)=>{let r={hard:!0,trim:!1},i=yn(t,e,r).split(`
57
- `),o=i.reduce((c,u)=>Math.max(tt(u),c),0),s=i.map(n).reduce((c,u)=>Math.max(tt(u),c),0),a=e-(s-o);return yn(t,a,r)},br=(t="",e="",n)=>{let r=n?.output??ae.stdout,i=n?.withGuide??Pt.withGuide,o=n?.format??kv,s=["",...yv(t,Ts(r)-6,o).split(`
58
- `).map(o),""],a=tt(e),c=Math.max(s.reduce((d,m)=>{let g=tt(m);return g>d?g:d},0),a)+2,u=s.map((d)=>`${E("gray",Z)} ${d}${" ".repeat(c-tt(d))}${E("gray",Z)}`).join(`
59
- `),l=i?`${E("gray",Z)}
60
- `:"",f=i?dv:mv;r.write(`${l}${E("green",uu)} ${E("reset",e)} ${E("gray",Oh.repeat(Math.max(c-a-1,1))+fv)}
61
- ${u}
62
- ${E("gray",f+Oh.repeat(c+2)+hv)}
63
- `)};var zH={light:ot("─","-"),heavy:ot("━","="),block:ot("█","#")};var vv=[`${E("dim","↑/↓")} to navigate`,`${E("dim","Enter:")} confirm`],As=(t,e)=>t.includes(`
64
- `)?t.split(`
65
- `).map((n)=>e(n)).join(`
66
- `):e(t),xh=(t)=>{let e=(r,i)=>{if(r===void 0)return"";let o=r.label??String(r.value);switch(i){case"disabled":return`${E("gray",Cs)} ${As(o,(s)=>E("gray",s))}${r.hint?` ${E("dim",`(${r.hint??"disabled"})`)}`:""}`;case"selected":return`${As(o,(s)=>E("dim",s))}`;case"active":return`${E("green",au)} ${o}${r.hint?` ${E("dim",`(${r.hint})`)}`:""}`;case"cancelled":return`${As(o,(s)=>E(["strikethrough","dim"],s))}`;default:return`${E("dim",Cs)} ${As(o,(s)=>E("dim",s))}`}},n=t.showInstructions??!0;return new Sh({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue,render(){let r=t.withGuide??Pt.withGuide,i=`${js(this.state)} `,o=`${Ph(this.state)} `,s=vn(t.output,t.message,o,i),a=`${r?`${E("gray",Z)}
67
- `:""}${s}
68
- `;switch(this.state){case"submit":{let c=r?`${E("gray",Z)} `:"",u=vn(t.output,e(this.options[this.cursor],"selected"),c);return`${a}${u}`}case"cancel":{let c=r?`${E("gray",Z)} `:"",u=vn(t.output,e(this.options[this.cursor],"cancelled"),c);return`${a}${u}${r?`
69
- ${E("gray",Z)}`:""}`}default:{let c=r?`${E("cyan",Z)} `:"",u=a.split(`
70
- `).length,l=n?Hh(vv,r):r?[E("cyan",nn)]:[],f=l.join(`
71
- `),d=l.length+1;return`${a}${c}${cu({output:t.output,cursor:this.cursor,options:this.options,maxItems:t.maxItems,columnPadding:c.length,rowPadding:u+d,style:(m,g)=>e(m,m.disabled?"disabled":g?"active":"inactive")}).join(`
72
- ${c}`)}
73
- ${f}
74
- `}}}}).prompt()};var KH=`${E("gray",Z)} `;var fu=(t)=>new su({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,output:t.output,signal:t.signal,input:t.input,render(){let e=t?.withGuide??Pt.withGuide,n=`${`${e?`${E("gray",Z)}
75
- `:""}${js(this.state)} `}${t.message}
76
- `,r=t.placeholder&&t.placeholder.length>0?E("inverse",t.placeholder[0])+E("dim",t.placeholder.slice(1)):E(["inverse","hidden"],"_"),i=this.userInput?this.userInputWithCursor:r,o=this.value??"";switch(this.state){case"error":{let s=this.error?` ${E("yellow",this.error)}`:"",a=e?`${E("yellow",Z)} `:"",c=e?E("yellow",nn):"";return`${n.trim()}
77
- ${a}${i}
78
- ${c}${s}
79
- `}case"submit":{let s=o?` ${E("dim",o)}`:"",a=e?E("gray",Z):"";return`${n}${a}${s}`}case"cancel":{let s=o?` ${E(["strikethrough","dim"],o)}`:"",a=e?E("gray",Z):"";return`${n}${a}${s}${o.trim()?`
80
- ${a}`:""}`}default:{let s=e?`${E("cyan",Z)} `:"",a=e?E("cyan",nn):"";return`${n}${s}${i}
81
- ${a}
82
- `}}}}).prompt();function du(t){let e=t.replace("#","");return[e.slice(0,2),e.slice(2,4),e.slice(4,6)].map((n)=>Number.parseInt(n,16)).join(";")}function Fe(t){return`\x1B[38;2;${du(t)}m`}function Us(t,e){return`\x1B[48;2;${du(t)};38;2;${du(e)}m`}function Lh(t,e="\x1B[39m"){return`${t.map((n)=>`${Fe(n)}■`).join(" ")}${e}`}var Zi="⧉";function Ws(t,e){return e?`\x1B]8;;${e}\x1B\\${t}\x1B]8;;\x1B\\`:t}function Ev(t,e){if(t[e]!=="\x1B")return 0;if(t[e+1]==="]"){let r=t.indexOf("\x07",e+2),i=t.indexOf("\x1B\\",e+2),o=r!==-1&&(i===-1||r<i)?r+1:i!==-1?i+2:0;return o?o-e:0}if(t[e+1]!=="[")return 0;let n=e+2;while(n<t.length&&!/[@-~]/.test(t[n]))n++;return n<t.length?n-e+1:0}function Th(t,e){let n="",r=0,i=0;while(i<t.length){let o=Ev(t,i);if(o>0){n+=t.slice(i,i+o),i+=o;continue}let s=String.fromCodePoint(t.codePointAt(i)),a=tt(s);if(r+a>e)break;n+=s,r+=a,i+=s.length}return{head:n,used:r}}function Et(t,e,n=!0){if(e<=0)return"";let r=tt(t);if(r<=e)return n?t+" ".repeat(e-r):t;let{head:i,used:o}=Th(t,e-1);return`${i}${t.includes("\x1B")?"\x1B[0m":""}…${n?" ".repeat(e-1-o):""}`}function pe(t,e,n){let r=n-tt(e)-1;return r<=0?Et(t,n):`${Et(t,r)} ${e}`}function kt(t,e){let n=[],r="";for(let i of t.split(/\s+/).filter(Boolean)){let o=r?`${r} ${i}`:i;if(tt(o)<=e){r=o;continue}if(r)n.push(r);while(tt(i)>e){let{head:s}=Th(i,e),a=Math.max(s.lastIndexOf("/")+1,s.lastIndexOf("#")),c=a>0?a:s.length;n.push(i.slice(0,c)),i=i.slice(c)}r=i}if(r)n.push(r);return n}import{existsSync as Jp,readFileSync as El}from"node:fs";import{join as Yp}from"node:path";var Sv=/^#[0-9a-f]{6}$/;function Bt(t){return Sv.test(t)}function nt(t){let e=Number.parseInt(t.slice(1),16);return[e>>16&255,e>>8&255,e&255]}function Ht(t,e,n){let r=nt(t),i=nt(e);return`#${r.map((o,s)=>Math.round(o+((i[s]??0)-o)*n).toString(16).padStart(2,"0")).join("")}`}function yt(t){let[e,n,r]=nt(t).map((i)=>{let o=i/255;return o<=0.03928?o/12.92:((o+0.055)/1.055)**2.4});return 0.2126*e+0.7152*n+0.0722*r}function gt(t,e){let n=yt(t),r=yt(e);return(Math.max(n,r)+0.05)/(Math.min(n,r)+0.05)}function _s(t,e){return Math.round(gt(t,e)*100)/100}function Mv(t){let e=t/255;return e<=0.04045?e/12.92:((e+0.055)/1.055)**2.4}function ft(t){let[e,n,r]=nt(t).map(Mv),i=Math.cbrt(0.4122214708*e+0.5363325363*n+0.0514459929*r),o=Math.cbrt(0.2119034982*e+0.6806995451*n+0.1073969566*r),s=Math.cbrt(0.0883024619*e+0.2817188376*n+0.6299787005*r),a=1.9779984951*i-2.428592205*o+0.4505937099*s,c=0.0259040371*i+0.7827717662*o-0.808675766*s;return{l:0.2104542553*i+0.793617785*o-0.0040720468*s,c:Math.hypot(a,c),h:(Math.atan2(c,a)*180/Math.PI+360)%360}}var Sn=7,Ah=3,hu=0.15,Ch=1.6,gu=[1,2,3,4,5,6,9,10,11,12,13,14],jh=[7,15],Mn=[1,2,3,4,5,6],sn={1:{name:"red",center:19,width:25},2:{name:"green",center:132,width:35},3:{name:"yellow",center:88,width:35},4:{name:"blue",center:250,width:60},5:{name:"magenta",center:329,width:40},6:{name:"cyan",center:197,width:60}},Xi=0.03,be=25,Xr=15,ti=0.08;function on(t,e){let n=t.ansi[e];if(n===void 0)throw Error(`${t.name}: missing ANSI ${e}`);return n}function mu(t,e,n){let r=t.background;return e.flatMap((i)=>{let o=on(t,i);return gt(o,r)<n?[`ANSI ${i} ${o} on ${r} is ${_s(o,r)}:1, needs ${n}:1`]:[]})}function Gh(t,e){return Math.min(...e.map((n)=>gt(on(t,n),t.background)))}var Uh=[{rule:"foreground",label:"foreground on background",unit:"ratio",min:Sn,measure:({foreground:t,background:e})=>gt(t,e),check:({foreground:t,background:e})=>gt(t,e)<Sn?[`foreground ${t} on ${e} is ${_s(t,e)}:1, needs ${Sn}:1`]:[]},{rule:"accents",label:"weakest accent on background",unit:"ratio",min:Ah,measure:(t)=>Gh(t,gu),check:(t)=>mu(t,gu,Ah)},{rule:"ansi0-dark",label:"ansi0 luminance",unit:"luminance",max:hu,measure:(t)=>yt(on(t,0)),check:(t)=>{let e=on(t,0);return yt(e)>hu?[`ANSI 0 ${e} has luminance ${yt(e).toFixed(3)}, needs <= ${hu}`]:[]}},{rule:"light-ansi",label:"ansi7 and ansi15 on background",unit:"ratio",min:Sn,measure:(t)=>Gh(t,jh),check:(t)=>mu(t,jh,Sn)},{rule:"ansi8-visible",label:"ansi8 on background",unit:"ratio",min:Ch,measure:(t)=>gt(on(t,8),t.background),check:(t)=>mu(t,[8],Ch)},{rule:"selection",label:"foreground on selection",unit:"ratio",min:Sn,measure:({foreground:t,selectionBackground:e})=>e===void 0?Number.NaN:gt(t,e),check:({foreground:t,selectionBackground:e})=>e!==void 0&&gt(t,e)<Sn?[`foreground ${t} on selection ${e} is ${_s(t,e)}:1, needs ${Sn}:1`]:[]}];function xe(t,e){let n=Math.abs(t-e)%360;return Math.min(n,360-n)}var In=(t)=>t>8?t-8:t;function ei(t){let e=t.signatureSlots.filter((n)=>n.startsWith("ansi")).map((n)=>Number(n.slice(4)));return new Set(e.flatMap((n)=>Mn.includes(In(n))?[n,n>8?n-8:n+8]:[n]))}function Qi(t,e){let n=ft(on(t,e));return n.c<Xi?void 0:n}function Qr(t){let e=ei(t);return gu.flatMap((n)=>{let r=Qi(t,n),i=sn[In(n)];if(r===void 0||i===void 0||e.has(n))return[];let o=xe(r.h,i.center)-i.width;return o>0?[{slot:n,hue:r.h,over:o}]:[]})}function wr(t){let e=new Set(t.signatureSlots);return Mn.flatMap((n)=>{let r=Qi(t,n),i=Qi(t,n+8);if(r===void 0||i===void 0||e.has(`ansi${n}`)&&e.has(`ansi${n+8}`))return[];return[{normal:n,gap:xe(r.h,i.h)}]})}function $r(t){let e=ei(t);return[0,8].flatMap((n)=>Mn.flatMap((r)=>Mn.filter((i)=>i>r).flatMap((i)=>{let[o,s]=[n+r,n+i],a=Qi(t,o),c=Qi(t,s);if(a===void 0||c===void 0||e.has(o)&&e.has(s))return[];return xe(a.h,c.h)<Xr&&Math.abs(a.l-c.l)<ti?[[o,s]]:[]})))}var Iv=[{rule:"ansi-role",label:"accent hue outside its ANSI role",unit:"degrees",max:0,measure:(t)=>Math.max(0,...Qr(t).map((e)=>e.over)),check:(t)=>Qr(t).map(({slot:e,hue:n,over:r})=>{let i=sn[In(e)];return`ANSI ${e} ${on(t,e)} has hue ${n.toFixed(0)}°, ${r.toFixed(0)}° outside ${i.name} (${i.center}±${i.width}°)`})},{rule:"bright-follows",label:"widest normal to bright hue gap",unit:"degrees",max:be,measure:(t)=>Math.max(0,...wr(t).map((e)=>e.gap)),check:(t)=>wr(t).filter((e)=>e.gap>be).map(({normal:e,gap:n})=>`ANSI ${e+8} is ${n.toFixed(0)}° from ANSI ${e}, needs <= ${be}°`)},{rule:"distinct",label:"accent pairs that read as one color",unit:"pairs",max:0,measure:(t)=>$r(t).length,check:(t)=>$r(t).map(([e,n])=>`ANSI ${e} ${on(t,e)} and ANSI ${n} ${on(t,n)} are within ${Xr}° hue and ${ti} lightness`)}],Bs=[...Uh,...Iv],pu=Bs.map((t)=>t.rule),Dt=Bs.map(({rule:t,label:e,unit:n,min:r,max:i})=>({rule:t,label:e,unit:n,...r===void 0?{}:{min:r},...i===void 0?{}:{max:i}}));function Le(t){return Bs.map((e)=>Math.round(e.measure(t)*1000)/1000)}function Wh(t,e){return t.filter((n)=>!e.waive.includes(n.rule)).flatMap((n)=>n.check(e).map((r)=>({theme:e.name,rule:n.rule,detail:r})))}function kr(t){return Wh(Bs,t)}function _h(t){return Wh(Uh,t)}function Bh(t){return t.flatMap(kr)}import{chmodSync as Ov,copyFileSync as Nv,existsSync as ni,mkdirSync as Rv,readFileSync as bu,realpathSync as Pv,renameSync as Hv,rmSync as zh,statSync as Fv,writeFileSync as xv}from"node:fs";import{dirname as Lv}from"node:path";function Kh(t){return`${t}.ttheme.bak`}var Tv=/^(?:#|--) ttheme begin$|path = "ttheme-|^DefaultProfile=ttheme-/m;function wu(t){let e=Kh(t);if(ni(t)&&!ni(e)&&!Tv.test(bu(t,"utf8")))Nv(t,e)}function T(t,e){let n=ni(t)?Pv(t):t;Rv(Lv(n),{recursive:!0});let r=`${n}.ttheme-${process.pid}`;if(xv(r,e),ni(n))Ov(r,Fv(n).mode&4095);Hv(r,n)}function Te(t,e){if((ni(t)?bu(t,"utf8"):void 0)===e)return!1;return wu(t),T(t,e),!0}function qh(t,e){let n=Kh(t),r=ni(n)?bu(n,"utf8"):void 0;if(e===""&&r===void 0)return zh(t,{force:!0}),"removed";if(T(t,e),r===void 0||r===e)return zh(n,{force:!0}),"restored";return"kept backup"}import{createHash as rp}from"node:crypto";import{copyFileSync as PM,existsSync as il,mkdirSync as HM,readdirSync as FM,readFileSync as pi,renameSync as ip,rmSync as gi,statSync as xM}from"node:fs";import{basename as op,isAbsolute as LM,join as U}from"node:path";import{createHash as nM}from"node:crypto";import{existsSync as rM,readdirSync as iM,readFileSync as oM,rmSync as sM,statSync as aM,utimesSync as cM}from"node:fs";import{join as di}from"node:path";import{readdirSync as uS,rmSync as lS,statSync as fS}from"node:fs";import{setDefaultAutoSelectFamilyAttemptTimeout as dS}from"node:net";import{homedir as hS}from"node:os";import{join as ao}from"node:path";import{setTimeout as mS}from"node:timers/promises";var _m=Yc(jm(),1);import{constants as tS,deflateSync as eS,inflateSync as nS}from"node:zlib";import{inflateRawSync as QE}from"node:zlib";var ZE=(()=>{var t=import.meta.url;return function(e={}){var n=e,r,i,o=new Promise((h,p)=>{r=h,i=p});let a=globalThis.ServiceWorkerGlobalScope!==void 0&&typeof self<"u"&&globalThis.caches&&globalThis.caches.default!==void 0,c=typeof process==="object"&&process.release&&process.release.name==="node";if(a||c){if(!globalThis.ImageData)globalThis.ImageData=class{constructor(p,k,y){this.data=p,this.width=k,this.height=y}};if(import.meta.url===void 0)import.meta.url="https://localhost";if(typeof self<"u"&&self.location===void 0)self.location={href:""}}var u=Object.assign({},n),l=[],f="./this.program",d=(h,p)=>{throw p},m=typeof window=="object",g=typeof importScripts=="function",$=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",w="";function b(h){if(n.locateFile)return n.locateFile(h,w);return w+h}var v,R,S;if(m||g){if(g)w=self.location.href;else if(typeof document<"u"&&document.currentScript)w=document.currentScript.src;if(t)w=t;if(w.startsWith("blob:"))w="";else w=w.substr(0,w.replace(/[?#].*/,"").lastIndexOf("/")+1);{if(v=(h)=>{var p=new XMLHttpRequest;return p.open("GET",h,!1),p.send(null),p.responseText},g)S=(h)=>{var p=new XMLHttpRequest;return p.open("GET",h,!1),p.responseType="arraybuffer",p.send(null),new Uint8Array(p.response)};R=(h,p,k)=>{var y=new XMLHttpRequest;y.open("GET",h,!0),y.responseType="arraybuffer",y.onload=()=>{if(y.status==200||y.status==0&&y.response){p(y.response);return}k()},y.onerror=k,y.send(null)}}}var I=n.print||console.log.bind(console),P=n.printErr||console.error.bind(console);if(Object.assign(n,u),u=null,n.arguments)l=n.arguments;if(n.thisProgram)f=n.thisProgram;if(n.quit)d=n.quit;var O;if(n.wasmBinary)O=n.wasmBinary;var F,j=!1,W,D,_,me,z,ht,V,kn,Kr;function He(){var h=F.buffer;n.HEAP8=D=new Int8Array(h),n.HEAP16=me=new Int16Array(h),n.HEAPU8=_=new Uint8Array(h),n.HEAPU16=z=new Uint16Array(h),n.HEAP32=ht=new Int32Array(h),n.HEAPU32=V=new Uint32Array(h),n.HEAPF32=kn=new Float32Array(h),n.HEAPF64=Kr=new Float64Array(h)}var fr=[],Ms=[],Is=[],Ok=!1;function Nk(){if(n.preRun){if(typeof n.preRun=="function")n.preRun=[n.preRun];while(n.preRun.length)Hk(n.preRun.shift())}jc(fr)}function Rk(){Ok=!0,jc(Ms)}function Pk(){if(n.postRun){if(typeof n.postRun=="function")n.postRun=[n.postRun];while(n.postRun.length)xk(n.postRun.shift())}jc(Is)}function Hk(h){fr.unshift(h)}function Fk(h){Ms.unshift(h)}function xk(h){Is.unshift(h)}var dr=0,Cc=null,Yi=null;function Lk(h){dr++,n.monitorRunDependencies?.(dr)}function Tk(h){if(dr--,n.monitorRunDependencies?.(dr),dr==0){if(Cc!==null)clearInterval(Cc),Cc=null;if(Yi){var p=Yi;Yi=null,p()}}}function Ld(h){n.onAbort?.(h),h="Aborted("+h+")",P(h),j=!0,W=1,h+=". Build with -sASSERTIONS for more info.";var p=new WebAssembly.RuntimeError(h);throw i(p),p}var Ak="data:application/octet-stream;base64,",Td=(h)=>h.startsWith(Ak),hr;if(n.locateFile){if(hr="mozjpeg_dec.wasm",!Td(hr))hr=b(hr)}else hr=new URL("mozjpeg_dec.wasm",import.meta.url).href;function Ad(h){if(h==hr&&O)return new Uint8Array(O);if(S)return S(h);throw"both async and sync fetching of the wasm failed"}function Ck(h){if(!O&&(m||g)){if(typeof fetch=="function")return fetch(h,{credentials:"same-origin"}).then((p)=>{if(!p.ok)throw`failed to load wasm binary file at '${h}'`;return p.arrayBuffer()}).catch(()=>Ad(h))}return Promise.resolve().then(()=>Ad(h))}function Cd(h,p,k){return Ck(h).then((y)=>WebAssembly.instantiate(y,p)).then(k,(y)=>{P(`failed to asynchronously prepare wasm: ${y}`),Ld(y)})}function jk(h,p,k,y){if(!h&&typeof WebAssembly.instantiateStreaming=="function"&&!Td(p)&&typeof fetch=="function")return fetch(p,{credentials:"same-origin"}).then((M)=>{var N=WebAssembly.instantiateStreaming(M,k);return N.then(y,function(L){return P(`wasm streaming compile failed: ${L}`),P("falling back to ArrayBuffer instantiation"),Cd(p,k,y)})});return Cd(p,k,y)}function Gk(){var h={a:u1};function p(y,M){return Ct=y.exports,F=Ct.A,He(),Kd=Ct.F,Fk(Ct.B),Tk("wasm-instantiate"),Ct}Lk("wasm-instantiate");function k(y){p(y.instance)}if(n.instantiateWasm)try{return n.instantiateWasm(h,p)}catch(y){P(`Module.instantiateWasm callback failed with error: ${y}`),i(y)}return jk(O,hr,h,k).catch(i),{}}function Uk(h){this.name="ExitStatus",this.message=`Program terminated with exit(${h})`,this.status=h}var jc=(h)=>{while(h.length>0)h.shift()(n)},Wk=n.noExitRuntime||!0;class jd{constructor(h){this.excPtr=h,this.ptr=h-24}set_type(h){V[this.ptr+4>>2]=h}get_type(){return V[this.ptr+4>>2]}set_destructor(h){V[this.ptr+8>>2]=h}get_destructor(){return V[this.ptr+8>>2]}set_caught(h){h=h?1:0,D[this.ptr+12]=h}get_caught(){return D[this.ptr+12]!=0}set_rethrown(h){h=h?1:0,D[this.ptr+13]=h}get_rethrown(){return D[this.ptr+13]!=0}init(h,p){this.set_adjusted_ptr(0),this.set_type(h),this.set_destructor(p)}set_adjusted_ptr(h){V[this.ptr+16>>2]=h}get_adjusted_ptr(){return V[this.ptr+16>>2]}get_exception_ptr(){var h=Qd(this.get_type());if(h)return V[this.excPtr>>2];var p=this.get_adjusted_ptr();if(p!==0)return p;return this.excPtr}}var Gd=0,_k=0,Bk=(h,p,k)=>{var y=new jd(h);throw y.init(p,k),Gd=h,_k++,Gd},zk=(h,p,k,y,M)=>{},Kk=()=>{var h=Array(256);for(var p=0;p<256;++p)h[p]=String.fromCharCode(p);Ud=h},Ud,ge=(h)=>{var p="",k=h;while(_[k])p+=Ud[_[k++]];return p},qr={},mr={},Os={},Wd,qt=(h)=>{throw new Wd(h)},_d,Bd=(h)=>{throw new _d(h)},qk=(h,p,k)=>{h.forEach(function(H){Os[H]=p});function y(H){var A=k(H);if(A.length!==h.length)Bd("Mismatched type converter count");for(var K=0;K<h.length;++K)Qe(h[K],A[K])}var M=Array(p.length),N=[],L=0;if(p.forEach((H,A)=>{if(mr.hasOwnProperty(H))M[A]=mr[H];else{if(N.push(H),!qr.hasOwnProperty(H))qr[H]=[];qr[H].push(()=>{if(M[A]=mr[H],++L,L===N.length)y(M)})}}),N.length===0)y(M)};function Jk(h,p,k={}){var y=p.name;if(!h)qt(`type "${y}" must have a positive integer typeid pointer`);if(mr.hasOwnProperty(h))if(k.ignoreDuplicateRegistrations)return;else qt(`Cannot register type '${y}' twice`);if(mr[h]=p,delete Os[h],qr.hasOwnProperty(h)){var M=qr[h];delete qr[h],M.forEach((N)=>N())}}function Qe(h,p,k={}){if(!("argPackAdvance"in p))throw TypeError("registerType registeredInstance requires argPackAdvance");return Jk(h,p,k)}var gr=8,Yk=(h,p,k,y)=>{p=ge(p),Qe(h,{name:p,fromWireType:function(M){return!!M},toWireType:function(M,N){return N?k:y},argPackAdvance:gr,readValueFromPointer:function(M){return this.fromWireType(_[M])},destructorFunction:null})},Gc=[],Xe=[],Uc=(h)=>{if(h>9&&--Xe[h+1]===0)Xe[h]=void 0,Gc.push(h)},Dk=()=>Xe.length/2-5-Gc.length,Vk=()=>{Xe.push(0,1,void 0,1,null,1,!0,1,!1,1),n.count_emval_handles=Dk},pr={toValue:(h)=>{if(!h)qt("Cannot use deleted val. handle = "+h);return Xe[h]},toHandle:(h)=>{switch(h){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let p=Gc.pop()||Xe.length;return Xe[p]=h,Xe[p+1]=1,p}}}};function Wc(h){return this.fromWireType(V[h>>2])}var Zk={name:"emscripten::val",fromWireType:(h)=>{var p=pr.toValue(h);return Uc(h),p},toWireType:(h,p)=>pr.toHandle(p),argPackAdvance:gr,readValueFromPointer:Wc,destructorFunction:null},Qk=(h)=>Qe(h,Zk),Xk=(h,p)=>{switch(p){case 4:return function(k){return this.fromWireType(kn[k>>2])};case 8:return function(k){return this.fromWireType(Kr[k>>3])};default:throw TypeError(`invalid float width (${p}): ${h}`)}},ty=(h,p,k)=>{p=ge(p),Qe(h,{name:p,fromWireType:(y)=>y,toWireType:(y,M)=>M,argPackAdvance:gr,readValueFromPointer:Xk(p,k),destructorFunction:null})},_c=(h,p)=>Object.defineProperty(p,"name",{value:h}),zd=(h)=>{while(h.length){var p=h.pop(),k=h.pop();k(p)}};function ey(h){for(var p=1;p<h.length;++p)if(h[p]!==null&&h[p].destructorFunction===void 0)return!0;return!1}function ny(h,p,k,y,M,N){var L=p.length;if(L<2)qt("argTypes array size mismatch! Must at least get return value and 'this' types!");var H=p[1]!==null&&k!==null,A=ey(p),K=p[0].name!=="void",at=L-2,$t=Array(at),jt=[],se=[],Jr=function(...qc){if(qc.length!==at)qt(`function ${h} called with ${qc.length} arguments, expected ${at}`);se.length=0;var Jc;if(jt.length=H?2:1,jt[0]=M,H)Jc=p[1].toWireType(se,this),jt[1]=Jc;for(var Yr=0;Yr<at;++Yr)$t[Yr]=p[Yr+2].toWireType(se,qc[Yr]),jt.push($t[Yr]);var p1=y(...jt);function b1(w1){if(A)zd(se);else for(var Dr=H?1:2;Dr<p.length;Dr++){var $1=Dr===1?Jc:$t[Dr-2];if(p[Dr].destructorFunction!==null)p[Dr].destructorFunction($1)}if(K)return p[0].fromWireType(w1)}return b1(p1)};return _c(h,Jr)}var ry=(h,p,k)=>{if(h[p].overloadTable===void 0){var y=h[p];h[p]=function(...M){if(!h[p].overloadTable.hasOwnProperty(M.length))qt(`Function '${k}' called with an invalid number of arguments (${M.length}) - expects one of (${h[p].overloadTable})!`);return h[p].overloadTable[M.length].apply(this,M)},h[p].overloadTable=[],h[p].overloadTable[y.argCount]=y}},iy=(h,p,k)=>{if(n.hasOwnProperty(h)){if(k===void 0||n[h].overloadTable!==void 0&&n[h].overloadTable[k]!==void 0)qt(`Cannot register public name '${h}' twice`);if(ry(n,h,h),n.hasOwnProperty(k))qt(`Cannot register multiple overloads of a function with the same number of arguments (${k})!`);n[h].overloadTable[k]=p}else if(n[h]=p,k!==void 0)n[h].numArguments=k},oy=(h,p)=>{var k=[];for(var y=0;y<h;y++)k.push(V[p+y*4>>2]);return k},sy=(h,p,k)=>{if(!n.hasOwnProperty(h))Bd("Replacing nonexistent public symbol");if(n[h].overloadTable!==void 0&&k!==void 0)n[h].overloadTable[k]=p;else n[h]=p,n[h].argCount=k},ay=(h,p,k)=>{h=h.replace(/p/g,"i");var y=n["dynCall_"+h];return y(p,...k)},Ns=[],Kd,qd=(h)=>{var p=Ns[h];if(!p){if(h>=Ns.length)Ns.length=h+1;Ns[h]=p=Kd.get(h)}return p},cy=(h,p,k=[])=>{if(h.includes("j"))return ay(h,p,k);var y=qd(p)(...k);return y},uy=(h,p)=>(...k)=>cy(h,p,k),ly=(h,p)=>{h=ge(h);function k(){if(h.includes("j"))return uy(h,p);return qd(p)}var y=k();if(typeof y!="function")qt(`unknown function pointer with signature ${h}: ${p}`);return y},fy=(h,p)=>{var k=_c(p,function(y){this.name=p,this.message=y;var M=Error(y).stack;if(M!==void 0)this.stack=this.toString()+`
83
- `+M.replace(/^Error(:[^\n]*)?\n/,"")});return k.prototype=Object.create(h.prototype),k.prototype.constructor=k,k.prototype.toString=function(){if(this.message===void 0)return this.name;else return`${this.name}: ${this.message}`},k},Jd,Yd=(h)=>{var p=Zd(h),k=ge(p);return tn(p),k},dy=(h,p)=>{var k=[],y={};function M(N){if(y[N])return;if(mr[N])return;if(Os[N]){Os[N].forEach(M);return}k.push(N),y[N]=!0}throw p.forEach(M),new Jd(`${h}: `+k.map(Yd).join([", "]))},hy=(h)=>{h=h.trim();let p=h.indexOf("(");if(p!==-1)return h.substr(0,p);else return h},my=(h,p,k,y,M,N,L)=>{var H=oy(p,k);h=ge(h),h=hy(h),M=ly(y,M),iy(h,function(){dy(`Cannot call ${h} due to unbound types`,H)},p-1),qk([],H,(A)=>{var K=[A[0],null].concat(A.slice(1));return sy(h,ny(h,K,null,M,N,L),p-1),[]})},gy=(h,p,k)=>{switch(p){case 1:return k?(y)=>D[y]:(y)=>_[y];case 2:return k?(y)=>me[y>>1]:(y)=>z[y>>1];case 4:return k?(y)=>ht[y>>2]:(y)=>V[y>>2];default:throw TypeError(`invalid integer width (${p}): ${h}`)}},py=(h,p,k,y,M)=>{if(p=ge(p),M===-1)M=4294967295;var N=(at)=>at;if(y===0){var L=32-8*k;N=(at)=>at<<L>>>L}var H=p.includes("unsigned"),A=(at,$t)=>{},K;if(H)K=function(at,$t){return A($t,this.name),$t>>>0};else K=function(at,$t){return A($t,this.name),$t};Qe(h,{name:p,fromWireType:N,toWireType:K,argPackAdvance:gr,readValueFromPointer:gy(p,k,y!==0),destructorFunction:null})},by=(h,p,k)=>{var y=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],M=y[p];function N(L){var H=V[L>>2],A=V[L+4>>2];return new M(D.buffer,A,H)}k=ge(k),Qe(h,{name:k,fromWireType:N,argPackAdvance:gr,readValueFromPointer:N},{ignoreDuplicateRegistrations:!0})},wy=(h,p,k,y)=>{if(!(y>0))return 0;var M=k,N=k+y-1;for(var L=0;L<h.length;++L){var H=h.charCodeAt(L);if(H>=55296&&H<=57343){var A=h.charCodeAt(++L);H=65536+((H&1023)<<10)|A&1023}if(H<=127){if(k>=N)break;p[k++]=H}else if(H<=2047){if(k+1>=N)break;p[k++]=192|H>>6,p[k++]=128|H&63}else if(H<=65535){if(k+2>=N)break;p[k++]=224|H>>12,p[k++]=128|H>>6&63,p[k++]=128|H&63}else{if(k+3>=N)break;p[k++]=240|H>>18,p[k++]=128|H>>12&63,p[k++]=128|H>>6&63,p[k++]=128|H&63}}return p[k]=0,k-M},$y=(h,p,k)=>wy(h,_,p,k),ky=(h)=>{var p=0;for(var k=0;k<h.length;++k){var y=h.charCodeAt(k);if(y<=127)p++;else if(y<=2047)p+=2;else if(y>=55296&&y<=57343)p+=4,++k;else p+=3}return p},Dd=(h,p,k)=>{var y=p+k,M="";while(!(p>=y)){var N=h[p++];if(!N)return M;if(!(N&128)){M+=String.fromCharCode(N);continue}var L=h[p++]&63;if((N&224)==192){M+=String.fromCharCode((N&31)<<6|L);continue}var H=h[p++]&63;if((N&240)==224)N=(N&15)<<12|L<<6|H;else N=(N&7)<<18|L<<12|H<<6|h[p++]&63;if(N<65536)M+=String.fromCharCode(N);else{var A=N-65536;M+=String.fromCharCode(55296|A>>10,56320|A&1023)}}return M},yy=(h,p)=>h?Dd(_,h,p):"",vy=(h,p)=>{p=ge(p);var k=p==="std::string";Qe(h,{name:p,fromWireType(y){var M=V[y>>2],N=y+4,L;if(k){var H=N;for(var A=0;A<=M;++A){var K=N+A;if(A==M||_[K]==0){var at=K-H,$t=yy(H,at);if(L===void 0)L=$t;else L+=String.fromCharCode(0),L+=$t;H=K+1}}}else{var jt=Array(M);for(var A=0;A<M;++A)jt[A]=String.fromCharCode(_[N+A]);L=jt.join("")}return tn(y),L},toWireType(y,M){if(M instanceof ArrayBuffer)M=new Uint8Array(M);var N,L=typeof M=="string";if(!(L||M instanceof Uint8Array||M instanceof Uint8ClampedArray||M instanceof Int8Array))qt("Cannot pass non-string to std::string");if(k&&L)N=ky(M);else N=M.length;var H=Kc(4+N+1),A=H+4;if(V[H>>2]=N,k&&L)$y(M,A,N+1);else if(L)for(var K=0;K<N;++K){var at=M.charCodeAt(K);if(at>255)tn(A),qt("String has UTF-16 code units that do not fit in 8 bits");_[A+K]=at}else for(var K=0;K<N;++K)_[A+K]=M[K];if(y!==null)y.push(tn,H);return H},argPackAdvance:gr,readValueFromPointer:Wc,destructorFunction(y){tn(y)}})},Ey=(h,p)=>{var k="";for(var y=0;!(y>=p/2);++y){var M=me[h+y*2>>1];if(M==0)break;k+=String.fromCharCode(M)}return k},Sy=(h,p,k)=>{if(k??=2147483647,k<2)return 0;k-=2;var y=p,M=k<h.length*2?k/2:h.length;for(var N=0;N<M;++N){var L=h.charCodeAt(N);me[p>>1]=L,p+=2}return me[p>>1]=0,p-y},My=(h)=>h.length*2,Iy=(h,p)=>{var k=0,y="";while(!(k>=p/4)){var M=ht[h+k*4>>2];if(M==0)break;if(++k,M>=65536){var N=M-65536;y+=String.fromCharCode(55296|N>>10,56320|N&1023)}else y+=String.fromCharCode(M)}return y},Oy=(h,p,k)=>{if(k??=2147483647,k<4)return 0;var y=p,M=y+k-4;for(var N=0;N<h.length;++N){var L=h.charCodeAt(N);if(L>=55296&&L<=57343){var H=h.charCodeAt(++N);L=65536+((L&1023)<<10)|H&1023}if(ht[p>>2]=L,p+=4,p+4>M)break}return ht[p>>2]=0,p-y},Ny=(h)=>{var p=0;for(var k=0;k<h.length;++k){var y=h.charCodeAt(k);if(y>=55296&&y<=57343)++k;p+=4}return p},Ry=(h,p,k)=>{k=ge(k);var y,M,N,L;if(p===2)y=Ey,M=Sy,L=My,N=(H)=>z[H>>1];else if(p===4)y=Iy,M=Oy,L=Ny,N=(H)=>V[H>>2];Qe(h,{name:k,fromWireType:(H)=>{var A=V[H>>2],K,at=H+4;for(var $t=0;$t<=A;++$t){var jt=H+4+$t*p;if($t==A||N(jt)==0){var se=jt-at,Jr=y(at,se);if(K===void 0)K=Jr;else K+=String.fromCharCode(0),K+=Jr;at=jt+p}}return tn(H),K},toWireType:(H,A)=>{if(typeof A!="string")qt(`Cannot pass non-string to C++ string type ${k}`);var K=L(A),at=Kc(4+K+p);if(V[at>>2]=K/p,M(A,at+4,K+p),H!==null)H.push(tn,at);return at},argPackAdvance:gr,readValueFromPointer:Wc,destructorFunction(H){tn(H)}})},Py=(h,p)=>{p=ge(p),Qe(h,{isVoid:!0,name:p,argPackAdvance:0,fromWireType:()=>{return},toWireType:(k,y)=>{return}})},Hy=(h,p,k)=>_.copyWithin(h,p,p+k),Bc=[],Fy=(h,p,k,y)=>{return h=Bc[h],p=pr.toValue(p),h(null,p,k,y)},xy={},Ly=(h)=>{var p=xy[h];if(p===void 0)return ge(h);return p},Vd=()=>{if(typeof globalThis=="object")return globalThis;function h(p){p.$$$embind_global$$$=p;var k=typeof $$$embind_global$$$=="object"&&p.$$$embind_global$$$==p;if(!k)delete p.$$$embind_global$$$;return k}if(typeof $$$embind_global$$$=="object")return $$$embind_global$$$;if(typeof global=="object"&&h(global))$$$embind_global$$$=global;else if(typeof self=="object"&&h(self))$$$embind_global$$$=self;if(typeof $$$embind_global$$$=="object")return $$$embind_global$$$;throw Error("unable to get global object.")},Ty=(h)=>{if(h===0)return pr.toHandle(Vd());else return h=Ly(h),pr.toHandle(Vd()[h])},Ay=(h)=>{var p=Bc.length;return Bc.push(h),p},Cy=(h,p)=>{var k=mr[h];if(k===void 0)qt(`${p} has unknown type ${Yd(h)}`);return k},jy=(h,p)=>{var k=Array(h);for(var y=0;y<h;++y)k[y]=Cy(V[p+y*4>>2],"parameter "+y);return k},Gy=Reflect.construct,Uy=(h,p,k)=>{var y=[],M=h.toWireType(y,k);if(y.length)V[p>>2]=pr.toHandle(y);return M},Wy=(h,p,k)=>{var y=jy(h,p),M=y.shift();h--;var N=Array(h),L=(A,K,at,$t)=>{var jt=0;for(var se=0;se<h;++se)N[se]=y[se].readValueFromPointer($t+jt),jt+=y[se].argPackAdvance;var Jr=k===1?Gy(K,N):K.apply(A,N);return Uy(M,at,Jr)},H=`methodCaller<(${y.map((A)=>A.name).join(", ")}) => ${M.name}>`;return Ay(_c(H,L))},_y=(h)=>{if(h>9)Xe[h+1]+=1},By=(h)=>{var p=pr.toValue(h);zd(p),Uc(h)},zy=()=>{Ld("")},Ky=()=>2147483648,qy=(h)=>{var p=F.buffer,k=(h-p.byteLength+65535)/65536;try{return F.grow(k),He(),1}catch(y){}},Jy=(h)=>{var p=_.length;h>>>=0;var k=Ky();if(h>k)return!1;var y=(A,K)=>A+(K-A%K)%K;for(var M=1;M<=4;M*=2){var N=p*(1+0.2/M);N=Math.min(N,h+100663296);var L=Math.min(k,y(Math.max(h,N),65536)),H=qy(L);if(H)return!0}return!1},zc={},Yy=()=>f||"./this.program",Di=()=>{if(!Di.strings){var h=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",p={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:h,_:Yy()};for(var k in zc)if(zc[k]===void 0)delete p[k];else p[k]=zc[k];var y=[];for(var k in p)y.push(`${k}=${p[k]}`);Di.strings=y}return Di.strings},Dy=(h,p)=>{for(var k=0;k<h.length;++k)D[p++]=h.charCodeAt(k);D[p]=0},Vy=(h,p)=>{var k=0;return Di().forEach((y,M)=>{var N=p+k;V[h+M*4>>2]=N,Dy(y,N),k+=y.length+1}),0},Zy=(h,p)=>{var k=Di();V[h>>2]=k.length;var y=0;return k.forEach((M)=>y+=M.length+1),V[p>>2]=y,0},Qy=0,Xy=()=>Wk||Qy>0,t1=(h)=>{if(W=h,!Xy())n.onExit?.(h),j=!0;d(h,new Uk(h))},e1=(h,p)=>{W=h,t1(h)},n1=e1,r1=(h)=>52,i1=(h,p)=>p+2097152>>>0<4194305-!!h?(h>>>0)+p*4294967296:NaN;function o1(h,p,k,y,M){var N=i1(p,k);return 70}var s1=[null,[],[]],a1=(h,p)=>{var k=s1[h];if(p===0||p===10)(h===1?I:P)(Dd(k,0)),k.length=0;else k.push(p)},c1=(h,p,k,y)=>{var M=0;for(var N=0;N<k;N++){var L=V[p>>2],H=V[p+4>>2];p+=8;for(var A=0;A<H;A++)a1(h,_[L+A]);M+=H}return V[y>>2]=M,0};Kk(),Wd=n.BindingError=class extends Error{constructor(p){super(p);this.name="BindingError"}},_d=n.InternalError=class extends Error{constructor(p){super(p);this.name="InternalError"}},Vk(),Jd=n.UnboundTypeError=fy(Error,"UnboundTypeError");var u1={o:Bk,q:zk,m:Yk,l:Qk,j:ty,f:my,b:py,a:by,e:vy,c:Ry,n:Py,v:Hy,i:Fy,d:Uc,k:Ty,h:Wy,y:_y,g:By,r:zy,s:Jy,t:Vy,u:Zy,z:n1,w:r1,p:o1,x:c1},Ct=Gk(),l1=()=>(l1=Ct.B)(),Zd=(h)=>(Zd=Ct.C)(h),Kc=(h)=>(Kc=Ct.D)(h),tn=(h)=>(tn=Ct.E)(h),f1=(h)=>(f1=Ct._emscripten_stack_restore)(h),d1=(h)=>(d1=Ct._emscripten_stack_alloc)(h),h1=()=>(h1=Ct.emscripten_stack_get_current)(),m1=(h)=>(m1=Ct.__cxa_increment_exception_refcount)(h),Qd=(h)=>(Qd=Ct.G)(h),g1=n.dynCall_jiji=(h,p,k,y,M)=>(g1=n.dynCall_jiji=Ct.H)(h,p,k,y,M),Rs;Yi=function h(){if(!Rs)Xd();if(!Rs)Yi=h};function Xd(){if(dr>0)return;if(Nk(),dr>0)return;function h(){if(Rs)return;if(Rs=!0,n.calledRun=!0,j)return;if(Rk(),r(n),n.onRuntimeInitialized)n.onRuntimeInitialized();Pk()}if(n.setStatus)n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),h()},1);else h()}if(n.preInit){if(typeof n.preInit=="function")n.preInit=[n.preInit];while(n.preInit.length>0)n.preInit.pop()()}return Xd(),o}})(),Gm=ZE;function xu(t){if(t[0]!==255||t[1]!==216)return null;let e=2;while(e+9<t.length){if(t[e]!==255){e++;continue}let n=t[e+1];if(n===255){e++;continue}let r=t[e+2]<<8|t[e+3];if(n>=192&&n<=207&&n!==196&&n!==200&&n!==204)return{height:t[e+5]<<8|t[e+6],width:t[e+7]<<8|t[e+8]};e+=2+r}return null}var Fu;function XE(){if(Fu)return Fu;let t=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Run:!0,print:()=>{return},printErr:()=>{return},instantiateWasm:(n,r)=>{let i=new WebAssembly.Instance(t,n);return r(i),i.exports}};if(Gm(e),typeof e.decode!=="function")throw Error("the JPEG decoder did not start");return Fu=e,e}function Um(t,e){let n=xu(t);if(n&&n.width*n.height>e)throw Error(`${n.width}×${n.height} is over ${e/1e6} megapixels`);let r=null;try{r=XE().decode(t,!0)}catch{r=null}if(!r)throw Error("not a JPEG image this decoder can read");return{width:r.width,height:r.height,data:new Uint8Array(r.data.buffer,r.data.byteOffset,r.data.length)}}var si=[137,80,78,71,13,10,26,10],Bm=13,zm=3;function vr(t){return t.length>=si.length&&si.every((e,n)=>t[n]===e)}var Km={0:1,2:3,4:2,6:4};function rS(t){if(t.length<33||!vr(t))return;let e=Buffer.from(t.buffer,t.byteOffset,t.byteLength),n=e.readUInt32BE(16),r=e.readUInt32BE(20),i=e[25];if(e[24]!==8||e[28]!==0||Km[i]===void 0)return;let o=[];for(let s=8;s+12<=e.length;){let a=e.readUInt32BE(s),c=e.toString("latin1",s+4,s+8);if(c==="IDAT")o.push(e.subarray(s+8,s+8+a));else if(c==="tRNS"||c==="IEND"){if(c==="tRNS"&&i!==4&&i!==6)return;break}s+=12+a}return o.length>0?{width:n,height:r,type:i,idat:o}:void 0}function iS(t,e,n,r){let i=new Uint8Array(e);for(let o=0;o<n;o++){let s=o*(e+1),a=t[s],c=s+1,u=o>0?t:i,l=o>0?c-e-1:0;if(a===1)for(let f=r;f<e;f++)t[c+f]=t[c+f]+t[c+f-r];else if(a===2)for(let f=0;f<e;f++)t[c+f]=t[c+f]+u[l+f];else if(a===3){for(let f=0;f<r;f++)t[c+f]=t[c+f]+(u[l+f]>>1);for(let f=r;f<e;f++)t[c+f]=t[c+f]+(t[c+f-r]+u[l+f]>>1)}else if(a===4){for(let f=0;f<r;f++)t[c+f]=t[c+f]+u[l+f];for(let f=r;f<e;f++){let d=t[c+f-r],m=u[l+f],g=u[l+f-r],$=Math.abs(m-g),w=Math.abs(d-g),b=Math.abs(d+m-2*g);t[c+f]=t[c+f]+($<=w&&$<=b?d:w<=b?m:g)}}else if(a!==0)throw Error(`bad PNG filter ${a}`)}}function oS(t){let{width:e,height:n,type:r}=t,i=Km[r],o=e*i,s=nS(Buffer.concat(t.idat),{chunkSize:Math.min(268435456,Math.max(65536,n*(o+1)))});if(s.length<n*(o+1))throw Error("truncated PNG");iS(s,o,n,i);let a=new Uint8Array(e*n*4);for(let c=0;c<n;c++){let u=c*(o+1)+1,l=c*e*4;if(r===6)a.set(s.subarray(u,u+o),l);else if(r===2)for(let f=0,d=u,m=l;f<e;f++,d+=3,m+=4)a[m]=s[d],a[m+1]=s[d+1],a[m+2]=s[d+2],a[m+3]=255;else if(r===0)for(let f=0,d=l;f<e;f++,d+=4){let m=s[u+f];a[d]=m,a[d+1]=m,a[d+2]=m,a[d+3]=255}else for(let f=0,d=u,m=l;f<e;f++,d+=2,m+=4){let g=s[d];a[m]=g,a[m+1]=g,a[m+2]=g,a[m+3]=s[d+1]}}return{width:e,height:n,data:a}}function ue(t){let e=rS(t);if(e)return oS(e);let n=_m.PNG.sync.read(Buffer.from(t));return{width:n.width,height:n.height,data:new Uint8Array(n.data)}}function Pn(t,e){if(vr(t)){let n=Hn(t);if(n&&n.width*n.height>e)throw Error(`${n.width}×${n.height} is over ${e/1e6} megapixels`);return ue(t)}if(t[0]===255&&t[1]===216)return Um(t,e);throw Error("not a PNG or JPEG image")}function qm(t,e){let{width:n,height:r,at:i}=e,o=Math.max(0,i.x),s=Math.max(0,i.y),a=Math.min(n,i.x+i.w),c=Math.min(r,i.y+i.h);if(a<=o||c<=s)return;let u={x:o,y:s,w:a-o,h:c-s};if(i.w===t.width&&i.h===t.height)return{part:t,box:u,dx:o-i.x,dy:s-i.y};let l={x:(o-i.x)*t.width/i.w,y:(s-i.y)*t.height/i.h,w:u.w*t.width/i.w,h:u.h*t.height/i.h};return{part:eo(t,l,u.w,u.h),box:u,dx:0,dy:0}}function Jm(t,e){let n=new Uint8Array(e.width*e.height*4),r=qm(t,e);if(r){let{part:i,box:o,dx:s,dy:a}=r;for(let c=0;c<o.h;c++){let u=((c+a)*i.width+s)*4;n.set(i.data.subarray(u,u+o.w*4),((o.y+c)*e.width+o.x)*4)}}return{width:e.width,height:e.height,data:n}}function zs(t,e,n,r={width:t.width,height:t.height,at:{x:0,y:0,w:t.width,h:t.height}}){let i=nt(e),{width:o,height:s}=r,a=new Uint8Array(o*s*3);for(let m=0;m<o*3;m+=3)a.set(i,m);for(let m=1;m<s;m++)a.copyWithin(m*o*3,0,o*3);let c=qm(t,r);if(!c)return{width:o,height:s,data:a};let{part:u,box:l,dx:f,dy:d}=c;for(let m=0;m<l.h;m++)for(let g=0;g<l.w;g++){let $=((m+d)*u.width+g+f)*4,w=((l.y+m)*o+l.x+g)*3,b=u.data[$+3]/255*n;for(let v=0;v<3;v++)a[w+v]=Math.round(i[v]*(1-b)+u.data[$+v]*b)}return{width:o,height:s,data:a}}function Wm(t,e){for(let n=0;n+e.length<=t.length;n++){let r=!0;for(let i=0;i<e.length&&r;i++)r=t[n+i]===e.charCodeAt(i);if(r)return n}return-1}function Hn(t){if(t.length<33||!vr(t))return null;let e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=e.getUint32(16),r=e.getUint32(20);if(t[25]===4||t[25]===6)return{width:n,height:r,alpha:!0};let i=Wm(t,"IDAT");return{width:n,height:r,alpha:Wm(i===-1?t:t.subarray(0,i),"tRNS")!==-1}}function Ym(t,e=Bm){let{width:n,height:r,data:i}=t,o=(l)=>{for(let f=l*n*4+3,d=f+n*4;f<d;f+=4)if(i[f]>=e)return!0;return!1},s=0;while(s<r&&!o(s))s++;if(s===r)return null;let a=r-1;while(!o(a))a--;let c=n,u=-1;for(let l=s;l<=a;l++){let f=l*n*4+3;for(let d=0;d<c;d++)if(i[f+d*4]>=e){c=d;break}for(let d=n-1;d>u;d--)if(i[f+d*4]>=e){u=d;break}}return{x:c,y:s,w:u-c+1,h:a-s+1}}function an(t,e={x:0,y:0,w:t.width,h:t.height}){let n=0;for(let r=e.y;r<e.y+e.h;r++)for(let i=e.x;i<e.x+e.w;i++)if((t.data[(r*t.width+i)*4+3]??0)<Bm)n++;return Math.round(n*100/(e.w*e.h))}function Dm(t,e,n){let r=Math.min(e/t.width,n/t.height),i=Math.max(1,Math.round(t.width*r)),o=Math.max(1,Math.round(t.height*r)),s=eo(t,{x:0,y:0,w:t.width,h:t.height},i,o),a=new Uint8Array(e*n*4),c=Math.floor((e-i)/2),u=Math.floor((n-o)/2);for(let l=0;l<o;l++)a.set(s.data.subarray(l*i*4,(l+1)*i*4),((u+l)*e+c)*4);return{width:e,height:n,data:a}}function sS(t){let e=Math.abs(t);if(e<1)return(7*e*e*e-12*e*e+5.333333333333333)/6;if(e<2)return(-2.3333333333333335*e*e*e+12*e*e-20*e+10.666666666666666)/6;return 0}function Lu(t,e,n,r){if(n===r&&Number.isInteger(e)&&e>=0&&e+r<=t)return{first:Int32Array.from({length:r},(l,f)=>e+f),size:1,weights:new Float32Array(r).fill(1)};let i=n/r,o=Math.max(1,i),s=2*o,a=Math.min(t,Math.ceil(2*s)+2),c=new Int32Array(r),u=new Float32Array(r*a);for(let l=0;l<r;l++){let f=e+(l+0.5)*i,d=Math.floor(f-s-0.5),m=Math.max(0,Math.min(t-a,d));c[l]=m;let g=0;for(let $=d;$<=Math.ceil(f+s-0.5);$++){let w=sS(($+0.5-f)/o),b=l*a+Math.min(t-1,Math.max(0,$))-m;u[b]=(u[b]??0)+w,g+=w}for(let $=l*a;$<(l+1)*a;$++)u[$]=(u[$]??0)/g}return{first:c,size:a,weights:u}}function Vm(t,e,n,r,i,o,s){let a=Lu(t,e.y,e.h,r),c=n*i,u=a.size+1,l=Array.from({length:u},()=>new Float32Array(c)),f=new Int32Array(u).fill(-1),d=new Float32Array(c),m=[],g=[];for(let $=0;$<r;$++){m.length=0,g.length=0;let w=a.first[$];for(let v=0;v<a.size;v++){let R=a.weights[$*a.size+v];if(R===0)continue;let S=w+v,I=S%u,P=l[I];if(f[I]!==S)o(S,P),f[I]=S;m.push(P),g.push(R)}let b=0;while(b<m.length){let v=m[b],R=g[b];if(m.length-b>=4){let S=m[b+1],I=m[b+2],P=m[b+3],O=g[b+1],F=g[b+2],j=g[b+3];if(b===0)for(let W=0;W<c;W++)d[W]=v[W]*R+S[W]*O+I[W]*F+P[W]*j;else for(let W=0;W<c;W++)d[W]=d[W]+(v[W]*R+S[W]*O+I[W]*F+P[W]*j);b+=4}else{if(b===0)for(let S=0;S<c;S++)d[S]=v[S]*R;else for(let S=0;S<c;S++)d[S]=d[S]+v[S]*R;b+=1}}if(m.length===0)d.fill(0);s($,d)}}function Zm(t,e,n,r,i){let o=0,s=n;while(o<s){let c=o+s>>1;if(t[c]+e-1<r)o=c+1;else s=c}let a=o;s=n;while(o<s){let c=o+s>>1;if(t[c]<=i)o=c+1;else s=c}return[a,o]}function eo(t,e,n,r){let i=Lu(t.width,e.x,e.w,n),o=t.data,s=t.width,a=new Float32Array(s*4),c=new Uint8Array(n*r*4);return Vm(t.height,e,n,r,4,(u,l)=>{let f=u*s*4,d=s,m=-1;for(let w=0,b=0;w<s*4;w+=4,b++){let v=o[f+w+3];if(v===0){a[w]=0,a[w+1]=0,a[w+2]=0,a[w+3]=0;continue}if(b<d)d=b;m=b,a[w]=o[f+w]*v,a[w+1]=o[f+w+1]*v,a[w+2]=o[f+w+2]*v,a[w+3]=v}if(l.fill(0),m<0)return;let[g,$]=Zm(i.first,i.size,n,d,m);for(let w=g;w<$;w++){let b=i.first[w]*4,v=w*i.size,R=0,S=0,I=0,P=0;for(let O=0;O<i.size;O++){let F=i.weights[v+O],j=b+O*4;R+=a[j]*F,S+=a[j+1]*F,I+=a[j+2]*F,P+=a[j+3]*F}l[w*4]=R,l[w*4+1]=S,l[w*4+2]=I,l[w*4+3]=P}},(u,l)=>{let f=u*n*4;for(let d=0;d<n;d++){let m=d*4,g=l[m+3];if(g<=0)continue;let $=l[m]/g;c[f+m]=($<0?0:$>255?255:$)+0.5,$=l[m+1]/g,c[f+m+1]=($<0?0:$>255?255:$)+0.5,$=l[m+2]/g,c[f+m+2]=($<0?0:$>255?255:$)+0.5,c[f+m+3]=(g>255?255:g)+0.5}}),{width:n,height:r,data:c}}function Qm(t,e,n,r){let i=Lu(t.width,e.x,e.w,n),o=t.data,s=t.width,a=new Float32Array(n*r);return Vm(t.height,e,n,r,1,(c,u)=>{let l=c*s,f=s,d=-1;for(let $=0;$<s;$++)if(o[l+$]!==0){if($<f)f=$;d=$}if(u.fill(0),d<0)return;let[m,g]=Zm(i.first,i.size,n,f,d);for(let $=m;$<g;$++){let w=l+i.first[$],b=$*i.size,v=0;for(let R=0;R<i.size;R++)v+=o[w+R]*i.weights[b+R];u[$]=v}},(c,u)=>{a.set(u,c*n)}),{width:n,height:r,data:a}}function no(t,e){if(e<=0)return t;let n=Math.max(1,Math.ceil(e*3)),r=Array.from({length:2*n+1},(l,f)=>Math.exp(-((f-n)**2)/(2*e*e))),i=r.reduce((l,f)=>l+f,0),{width:o,height:s,data:a}=t,c=new Float32Array(o*s);for(let l=0;l<s;l++){let f=l*o;for(let d=0;d<o;d++){let m=0;for(let g=-n;g<=n;g++)m+=(a[f+Math.min(o-1,Math.max(0,d+g))]??0)*(r[g+n]??0);c[f+d]=m/i}}let u=new Float32Array(o*s);for(let l=0;l<s;l++){let f=l*o;for(let d=-n;d<=n;d++){let m=(r[d+n]??0)/i,g=Math.min(s-1,Math.max(0,l+d))*o;for(let $=0;$<o;$++)u[f+$]=(u[f+$]??0)+(c[g+$]??0)*m}}return{width:o,height:s,data:u}}function ro(t){let e=new Uint8Array(t.data.length);for(let n=0;n<e.length;n++){let r=t.data[n];e[n]=(r<0?0:r>255?255:r)+0.5}return{width:t.width,height:t.height,data:e}}function io(t){let e=new Uint8Array(t.width*t.height);for(let n=0;n<e.length;n++)e[n]=t.data[n*4+3]??0;return{width:t.width,height:t.height,data:e}}var aS=Array.from({length:256},(t,e)=>{let n=e;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;return n>>>0});function cS(t){let e=4294967295;for(let n of t)e=(aS[(e^n)&255]??0)^e>>>8;return(e^4294967295)>>>0}function Rn(t,e){let n=Buffer.alloc(12+e.length);return n.writeUInt32BE(e.length,0),n.write(t,4,"latin1"),n.set(e,8),n.writeUInt32BE(cS(n.subarray(4,8+e.length)),8+e.length),n}function Xm(t,e,n){let r=new Uint8Array(n*(e+1));r.set(t.subarray(0,e),1);for(let i=1;i<n;i++){let o=i*(e+1),s=i*e,a=s-e;r[o]=2;for(let c=0;c<e;c++)r[o+1+c]=t[s+c]-t[a+c]}return r}function tg(t){return eS(t,{level:1,strategy:tS.Z_RLE})}function eg(t,e,n){let r=Buffer.alloc(13);return r.writeUInt32BE(t.width,0),r.writeUInt32BE(t.height,4),r[8]=8,r[9]=e,Buffer.concat([Buffer.from(si),Rn("IHDR",r),...n,Rn("IDAT",tg(Xm(t.data,t.width,t.height))),Rn("IEND",new Uint8Array)])}function ng(t){let[e,n,r]=nt(t),i=new Uint8Array(768);for(let o=0;o<256;o++)i.set([e,n,r],o*3);return Rn("PLTE",i)}function rg(t,e,n,r,i){let o=Buffer.alloc(13);return o.writeUInt32BE(t,0),o.writeUInt32BE(e,4),o[8]=8,o[9]=n,Buffer.concat([Buffer.from(si),Rn("IHDR",o),Rn("IDAT",tg(Xm(i,t*r,e))),Rn("IEND",new Uint8Array)])}function Ks(t){return rg(t.width,t.height,2,3,t.data)}function Ce(t){return rg(t.width,t.height,6,4,t.data)}function oo(t,e){return eg(t,zm,[ng(e),Rn("tRNS",Uint8Array.from({length:256},(n,r)=>r))])}function Tu(t){return eg(t,0,[])}function ig(t,e){if(!vr(t)||t[25]!==zm)return;let n=Buffer.from(t.buffer,t.byteOffset,t.byteLength),r=[Buffer.from(si)],i=si.length;while(i+8<=n.length){let o=i+12+n.readUInt32BE(i);r.push(n.toString("latin1",i+4,i+8)==="PLTE"?ng(e):n.subarray(i,o)),i=o}return Buffer.concat(r)}var Fn=100,Vt=25000000,gS=536870912,ai=["safe","questionable","explicit"],Er=["nudity","underwear"],Gu=["comic","monochrome","sketch","chibi"],hg=["off","5","10","25","50","100"],mg=["off","720","1080","1440","1800","2560"],gg={nudity:new Set(["nude","naked","topless","bottomless","nipples","naked_towel","undressing"]),underwear:new Set(["underwear","panties","pantsu","bra","lingerie","pantyshot"])},pS={comic:new Set(["comic","4koma"]),monochrome:new Set(["monochrome","greyscale"]),sketch:new Set(["sketch","lineart","line_art"]),chibi:new Set(["chibi"])},bS=/^(?:rating|score|width|height|filetype|dimension):/,so={safe:"s",questionable:"q",explicit:"e"},pg=8191,wS=20000,$S=5000,og=3000,sg=8,kS=8,yS=8000,vS=3000,bg=60000,ag=3,ES=3,SS="https://static.zerochan.net",wg="https://s1.zerochan.net",Uu=`ttheme/${Ot.version} (+${Ot.homepage})`,MS=["orig","tile","thumb","cut"],$g=new Map,IS=BS(process.env.TTHEME_FIND_HOSTS),OS=_S(process.env.TTHEME_FIND_CUTOUTS);dS(vS);var NS=["artist","character","copyright"];function cg(t){try{return uS(t)}catch{return[]}}function ci(t){return t.startsWith("//")?`https:${t}`:t}function Ln(t){return(/\.([a-z0-9]+)(?:\?.*)?$/i.exec(t)?.[1]??"").toLowerCase()}function co(t){let e=t.trim();if(!e)return[];let n=JSON.parse(e);if(Array.isArray(n))return n;let r=n.posts;return Array.isArray(r)?r:[]}function RS(t){let e=t.trim(),r=(e?JSON.parse(e):{}).tags??{};return new Map(Object.entries(r).map(([i,o])=>[i,String(o)]))}function Cu(t,e,n){let r=ci(String(t??""));return{file:r,width:Number(e)||0,height:Number(n)||0,ext:Ln(r)}}function cn(t){return String(t??"").split(/\s+/).filter(Boolean)}function ju(t){let e=typeof t==="number"?new Date(t*1000):typeof t==="string"?new Date(t):void 0;return e&&!Number.isNaN(e.getTime())?e.toISOString().slice(0,10):void 0}function kg(t,e){let n=ci(String(e.preview??""));if(!e.file||!n||!Number(t.id))return[];let r=Number(t.width??t.image_width)||0,i=Number(t.height??t.image_height)||0;return[{id:Number(t.id),width:r,height:i,file:e.file,preview:n,ext:e.ext,owner:String(e.owner??""),score:Number(t.score)||0,rating:String(t.rating??""),md5:String(e.md5??""),source:String(t.source??""),tags:cn(e.tags),named:e.named,...ju(t.created_at)?{posted:ju(t.created_at)}:{},solo:e.solo,family:Number(t.parent_id)||(t.has_children===!0?Number(t.id):0),smaller:e.versions.filter((o)=>o.file&&o.width>0&&o.height>0&&o.width*o.height<r*i)}]}function PS(t){let e=RS(t);return co(t).flatMap((n)=>{let r=ci(String(n.file_url??"")),i=String(n.tags??""),o=(s)=>cn(i).filter((a)=>e.get(a)===s);return kg(n,{preview:n.preview_url,file:r,ext:String(n.file_ext||Ln(r)).toLowerCase(),owner:n.author,md5:n.md5,tags:i,named:{artist:o("artist"),character:o("character"),copyright:o("copyright")},solo:void 0,versions:[Cu(n.jpeg_url,n.jpeg_width,n.jpeg_height),Cu(n.sample_url,n.sample_width,n.sample_height)]})})}function HS(t){return co(t).flatMap((e)=>{let n=ci(String(e.file_url??"")),r=String(e.tag_string??""),i=e.media_asset??{};return kg(e,{preview:i.variants?.find((o)=>o.type==="360x360")?.url??e.preview_file_url,file:n,ext:String(e.file_ext||Ln(n)).toLowerCase(),owner:"",md5:e.md5,tags:r,named:{artist:cn(e.tag_string_artist),character:cn(e.tag_string_character),copyright:cn(e.tag_string_copyright)},solo:r.split(/\s+/).includes("solo"),versions:(i.variants??[]).map((o)=>Cu(o.url,o.width,o.height)).filter((o)=>o.ext==="jpg"||o.ext==="png").sort((o,s)=>s.width*s.height-o.width*o.height)})})}function yg(t){return t.toLowerCase().replace(/\s+/g,"_")}function FS(t){return(Array.isArray(t)?t:[]).map((e)=>yg(String(e)))}function xS(t){return String(t??"").replace(/[^0-9a-z]+/gi,".").replace(/^\.+|\.+$/g,"")||"zerochan"}function LS(t){let e=t.trim(),n=e?JSON.parse(e):{};return(Array.isArray(n.items)?n.items:n.id?[n]:[]).flatMap((i)=>{let o=Number(i.id);if(!o)return[];let s=FS(i.tags),a=ci(String(i.full??""));return[{id:o,width:Number(i.width)||0,height:Number(i.height)||0,file:a,ext:Ln(a),preview:`${wg}/${xS(i.tag??i.primary)}.600.${o}.jpg`,owner:"",score:0,rating:s.some((c)=>gg.nudity.has(c))?"q":"g",md5:String(i.md5??i.hash??""),source:String(i.source??""),tags:s,named:{artist:[],character:[],copyright:[]},solo:s.includes("solo"),family:0,smaller:[]}]})}var TS={mangaka:"artist",studio:"artist",character:"character",series:"copyright",game:"copyright"};function ug(t){return t.replace(/&(?:#(\d+)|amp|quot|apos|lt|gt);/g,(e,n)=>n?String.fromCharCode(Number(n)):{"&amp;":"&","&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"}[e]??e)}function AS(t){let e={artist:[],character:[],copyright:[]};for(let[,r,i]of t.matchAll(/<li class="([a-z]+)[^"]*"[^>]*\bdata-tag="([^"]*)"/g)){let o=TS[r],s=yg(ug(i));if(o&&!e[o].includes(s))e[o].push(s)}let n=ju(/"datePublished":\s*"([^"]+)"/.exec(t)?.[1]);return{named:e,source:"",owner:ug(/\buploader = \{\s*name: '([^']*)'/.exec(t)?.[1]??""),...n?{posted:n}:{}}}function CS(t){return Number(/Zerochan has ([\d,]+) /.exec(t)?.[1]?.replace(/,/g,"")??0)}function jS(t){return co(t).flatMap((e)=>{let n=String(e.value??"");return n?[{value:n,count:Number(e.post_count)||0}]:[]})}function GS(t){return co(t).flatMap((e)=>{let n=String(e.name??"");return n?[{value:n,count:Number(e.count)||0}]:[]})}function US(t){return Number(/count="(\d+)"/.exec(t)?.[1]??0)}function WS(t){let n=(t.trim()?JSON.parse(t):{}).counts?.posts;return n===null?Number.NaN:Number(n)||0}function _S(t){let e=new Map;for(let n of(t??"").split(/\s+/).filter(Boolean)){let r=n.indexOf("=");if(r>0)e.set(n.slice(0,r),n.slice(r+1).split(",").filter(Boolean))}return e}function BS(t){let e=new Map;for(let n of(t??"").split(/[\s,]+/).filter(Boolean)){let r=n.indexOf("="),i=n.slice(0,r);try{let o=new URL(n.slice(r+1));if(i&&o.protocol==="https:")e.set(i,o.origin)}catch{}}return e}function qs(t,e,n,r){let i=(t??"").split(/\s+/);if(r!==void 0&&i.includes(r))return[];let o=e.filter((s)=>i.includes(s));return o.length>0?o:[...n]}function Sr(t){return qs(t,ai,["safe"])}function ui(t){return qs(t,Er,Er,"none")}function Js(t){return qs(t,Gu,[],"none")}function uo(t){let e=q.map((n)=>n.name);return qs(t,e,e)}function Wu(t,e,n){return{score:Number(t)||0,size:Number(e)||0,png:n==="on"}}function lo(t){return[...new Set((t??"").toLowerCase().split(/[\s,]+/).map((e)=>e.replace(/^-+/,"")).filter(Boolean))]}function _u(t,e,n){return{safe:new Set(t),questionable:new Set(e),explicit:new Set(n)}}function Bu(t){let e=IS.get(t.key),n=OS.get(t.key);return{...t,origin:e??t.origin,moved:e!==void 0&&e!==t.origin,cutouts:n??t.cutouts,vouched:t.vouched&&n===void 0}}function vg(t){return t.length<2?t.join(""):t.map((e)=>`~${e}`).join(" ")}function Eg(t){return t>0?[`width:>=${t}`,`height:>=${t}`]:[]}function lg(t){let e=Bu(t),n=(r)=>new URLSearchParams({api_version:"2",include_tags:"1",...r});return{...e,scored:!0,narrow:({score:r,size:i})=>[...r>0?[`score:>=${r}`]:[],...Eg(i)],cutouts:vg(e.cutouts),ratings:_u([so.safe],[so.questionable],[so.explicit]),rate:(r)=>{let[i]=r;if(r.length===1&&i)return`rating:${so[i]}`;let o=ai.filter((a)=>!r.includes(a)),[s]=o;return o.length===1&&s?`-rating:${so[s]}`:""},best:"order:score",tagBudget:Number.POSITIVE_INFINITY,ors:!0,postsUrl:(r,i)=>`${e.origin}/post.json?${n({limit:String(Fn),page:String(i+1),tags:r})}`,countUrl:(r)=>`${e.origin}/post.xml?${new URLSearchParams({limit:"1",tags:r})}`,postUrl:(r)=>`${e.origin}/post.json?${n({tags:`id:${r}`})}`,pageUrl:(r)=>`${e.origin}/post/show/${r}`,parse:PS,count:US,uploadedBy:(r)=>`user:${r}`}}function zS(t){let e=Bu(t),n=_u(["g"],["s","q"],["e"]);return{...e,scored:!0,narrow:({score:r,size:i,png:o})=>[...r>0?[`score:>=${r}`]:[],...Eg(i),...o?["filetype:png"]:[]],cutouts:vg(e.cutouts),ratings:n,rate:(r)=>r.length===ai.length?"":`rating:${r.flatMap((i)=>[...n[i]]).join(",")}`,best:"order:score",tagBudget:2,ors:!0,postsUrl:(r,i)=>`${e.origin}/posts.json?${new URLSearchParams({limit:String(Fn),page:String(i+1),tags:r})}`,countUrl:(r)=>`${e.origin}/counts/posts.json?${new URLSearchParams({tags:r})}`,postUrl:(r)=>`${e.origin}/posts.json?${new URLSearchParams({limit:"1",tags:`id:${r}`})}`,pageUrl:(r)=>`${e.origin}/posts/${r}`,parse:HS,count:WS,uploadedBy:(r)=>`user:${r}`}}function Au(t){return t.split(/\s+/).filter((e)=>e&&!/^(?:order|dimension):/.test(e)).map((e)=>e.split("_").map(encodeURIComponent).join("+")).join(",")}function fg(t){let e=t.split(/\s+/),n=e.find((r)=>r.startsWith("dimension:"))?.slice(10);return{s:e.includes("order:fav")?"fav":"id",...n?{d:n}:{}}}function KS(t){let e=Bu(t);return{...e,scored:!1,narrow:({size:n})=>n>=1800?["dimension:huge"]:n>0?["dimension:large"]:[],cutouts:e.cutouts[0]??"",ratings:_u(["g"],["q"],["e"]),rate:()=>"",best:"order:fav",tagBudget:3,ors:!1,missing:404,postsUrl:(n,r)=>`${e.origin}/${Au(n)}?${new URLSearchParams({json:"",l:String(Fn),p:String(r+1),...fg(n)})}`,countUrl:(n)=>`${e.origin}/${Au(n)}?${new URLSearchParams({xml:"",l:"1"})}`,postUrl:(n)=>`${e.origin}/${n}?json=`,pageUrl:(n)=>`${e.origin}/${n}`,parse:LS,count:CS,credits:AS,counts:(n)=>Au(n).split(",").length===1&&!("d"in fg(n)),guesses:(n)=>(n.tags.includes("transparent_background")?["png","jpg"]:["jpg","png"]).map((r)=>n.preview.replace(wg,SS).replace(/\.600\.(\d+)\.jpg$/,`.full.$1.${r}`))}}function qS(t){let e=dg(`https://${t}`);return q.find((n)=>dg(n.origin)===e)}function zu(t){return t.split(/\s+/).filter((e)=>e&&!bS.test(e)).length}function Ys(t,e){let n=t.trim();if(/^\d+$/.test(n))return{site:e,id:Number(n)};let r=/^([\w.]+):(\d+)$/.exec(n);if(r){let a=q.find((c)=>c.key===r[1]||c.name===r[1]);return a&&{site:a,id:Number(r[2])}}let i;try{i=new URL(n)}catch{return}let o=qS(i.host),s=Number(i.searchParams.get("id")??i.pathname.split("/").filter(Boolean).at(-1));return o&&s>0?{site:o,id:s}:void 0}var q=[zS({key:"danbooru",name:"danbooru",origin:"https://shima.donmai.us",cutouts:["transparent_background"],vouched:!1,ansi:2}),lg({key:"konachan",name:"konachan",origin:"https://konachan.net",cutouts:["transparent","vector"],vouched:!1,ansi:6}),lg({key:"yande",name:"yande.re",origin:"https://yande.re",cutouts:["transparent_png"],vouched:!0,ansi:5}),KS({key:"zerochan",name:"zerochan",origin:"https://www.zerochan.net",cutouts:["transparent_background"],vouched:!1,ansi:3})],Ut=q.find((t)=>t.key==="danbooru"),Tn=134217728;function le(t,e){let n=q.indexOf(t);return(n===-1?q.length:n)*Tn+e}function dg(t){let e;try{e=new URL(t).hostname}catch{return""}return e.split(".").slice(-2).join(".")}function li(t,e,n=e){return e.mirror&&n===e?{site:Ut,url:e.mirror.file}:{site:t,url:n.file}}function Ds(t,e){return e.mirror?{site:Ut,url:e.mirror.preview}:{site:t,url:e.preview}}function Vs(t,e=Er){return t.tags.filter((n)=>e.some((r)=>gg[r].has(n)))}function Sg(t,e){return t.tags.filter((n)=>e.some((r)=>pS[r].has(n)))}function Zs(t,e,n=["safe"]){return n.some((r)=>t.ratings[r].has(e.rating))}function Mg(t,e){return t.rate(["safe"])===""?void 0:ai.find((n)=>t.ratings[n].has(e.rating))}function je(t){return[t,...t.smaller].find((e)=>e.width*e.height<=Vt)}function Ig(t){let e=new Map;for(let[n,r]of[...t].sort(([i],[o])=>i<o?-1:1)){if(r==="")continue;e.set(r,[...e.get(r)??[],n])}return e}function An(){return ao(process.env.XDG_CACHE_HOME??ao(hS(),".cache"),"ttheme")}function Ge(t){return ao(An(),t.key)}function Og(t=gS,e=An()){let n=[],r=0;for(let i of cg(e))for(let o of MS){let s=ao(e,i,o);for(let a of cg(s)){let c=ao(s,a);try{let{size:u,mtimeMs:l}=fS(c);n.push({path:c,size:u,at:l}),r+=u}catch{}}}n.sort((i,o)=>i.at-o.at);for(let i of n){if(r<=t)return;try{lS(i.path,{force:!0}),r-=i.size}catch{}}}function JS(t,e){if(t!==null&&/^\s*\d+\s*$/.test(t))return Number(t)*1000;let n=t===null?Number.NaN:Date.parse(t);return Number.isNaN(n)?bg:Math.max(0,n-e)}function un(t){return $g.get(t.key)??0}function YS(t){for(let e=t;e instanceof Error;e=e.cause)if(e.code==="ECONNRESET")return!0;return!1}function DS(t){return(t.headers.get("server")??"").startsWith("cloudflare")&&t.headers.get("cf-mitigated")==="challenge"}function VS(t,e){let n=new URL(e,t);if(!n.search)n.search=new URL(t).search;return n.href}async function xn(t,e,n,r={},i=wS){let o=e;for(let s=1,a=0;;s++){let c=un(t)-Date.now();if(c>0)await mS(c,void 0,{signal:n});let u;try{u=await fetch(o,{headers:{"User-Agent":Uu,Referer:`${t.origin}/`,...r},redirect:"manual",signal:i?AbortSignal.any([n,AbortSignal.timeout(i)]):n})}catch(f){if(s<ag&&!n.aborted&&YS(f))continue;throw f}let l=u.headers.get("location");if(l&&u.status>=300&&u.status<400&&a<ES){await u.body?.cancel(),o=VS(o,l),a++,s--;continue}if(u.status===429&&s<ag){await u.body?.cancel();let f=JS(u.headers.get("retry-after"),Date.now());if(f>bg)throw Error(`${t.name} asks to wait ${Math.ceil(f/1000)}s`);$g.set(t.key,Math.max(un(t),Date.now()+f));continue}if(!u.ok)throw await u.body?.cancel(),Object.assign(Error(DS(u)?`${t.name} is behind a Cloudflare challenge`:`${t.name} answered ${u.status}`),{status:u.status});return u}}async function Qs(t,e,n){try{return await(await xn(t,e,n)).text()}catch(r){if(t.missing!==void 0&&r.status===t.missing)return"";throw r}}async function Ng(t,e,n,r){return t.parse(await Qs(t,t.postsUrl(e,n),r))}async function Ku(t,e,n){return t.count(await Qs(t,t.countUrl(e),n))}async function fo(t,e,n){let[r]=t.parse(await Qs(t,t.postUrl(e),n));return r}async function Xs(t,e,n){return t.credits?.(await Qs(t,t.pageUrl(e),n))}var ZS=/^https?:\/\/(?:i\.pximg\.net|i\d*\.pixiv\.net|img\d*\.pixiv\.net)\/\S*\/(\d+)(?:_p\d+)?(?:_\w+)?\.\w+(?:[?#]\S*)?$/i,QS=/^https?:\/\/(?:www\.)?pixiv\.net\/member_illust\.php\?\S*\billust_id=(\d+)/i;function ho(t){let e=ZS.exec(t)?.[1]??QS.exec(t)?.[1];return e?`https://www.pixiv.net/artworks/${e}`:t}function ta(t,e){return t.credits!==void 0&&e.named.artist.length===0}function mo(t,e){for(let n of NS){let r=e.named?.[n]??[];if(t.named[n].length===0&&r.length>0)t.named[n]=r}if(t.source||=e.source??"",t.owner||=e.owner??"",!t.posted&&e.posted)t.posted=e.posted}function XS(t){let e=new URLSearchParams({limit:String(2*Fn),only:"md5,tag_string,tag_string_artist,tag_string_character,tag_string_copyright,source,file_url",tags:`md5:${t.join(",")}`});return`${Ut.origin}/posts.json?${e}`}function tM(t){return new Map(co(t).flatMap((e)=>{let n=String(e.md5??"");return n?[[n,{tags:cn(e.tag_string),named:{artist:cn(e.tag_string_artist),character:cn(e.tag_string_character),copyright:cn(e.tag_string_copyright)},source:String(e.source??""),file:ci(String(e.file_url??""))}]]:[]}))}function ea(t,e){for(let n of t){let r=e.get(n.md5);if(!r)continue;if(n.tags=[...new Set([...n.tags,...r.tags])],mo(n,r),n.solo=r.tags.includes("solo"),r.file.includes("/original/")){if(n.mirror={file:r.file,preview:r.file.replace("/original/","/360x360/").replace(/\.[a-z0-9]+$/i,".jpg")},!n.file)n.file=r.file,n.ext=Ln(r.file)}}}async function na(t,e){let n=new Map;if(un(Ut)>Date.now())return n;for(let r=0;r<t.length;r+=Fn){let i=await(await xn(Ut,XS(t.slice(r,r+Fn)),e,{},$S)).text();for(let[o,s]of tM(i))n.set(o,s)}return n}async function ra(t,e,n){if(e.file||!t.guesses)return;for(let r of t.guesses(e))try{let i=await xn(t,r,n,{Range:`bytes=0-${pg}`}),o=Hn(new Uint8Array(await i.arrayBuffer()));return e.file=r,e.ext=Ln(r),o}catch(i){if(n.aborted||i.status!==404)throw i}throw Error(`${t.name} keeps no png or jpg of ${e.id}`)}async function Rg(t,e){if(un(Ut)<=Date.now())try{let i=new URLSearchParams({"search[query]":t,"search[type]":"tag_query",limit:String(sg)}),o=`${Ut.origin}/autocomplete.json?${i}`;return jS(await(await xn(Ut,o,e,{},og)).text())}catch(i){if(e.aborted)throw i}let n=q.find((i)=>i.key==="yande"),r=new URLSearchParams({name:t,order:"count",limit:String(sg)});return GS(await(await xn(n,`${n.origin}/tag.json?${r}`,e,{},og)).text())}function eM(t){try{return(JSON.parse(t).related_tags??[]).flatMap(({tag:n})=>n?.name?[{value:n.name,count:Number(n.post_count)||0}]:[])}catch{return[]}}async function Pg(t,e){if(un(Ut)>Date.now())return[];let n=new URLSearchParams({"search[query]":t,"search[category]":"character",limit:String(kS)});return eM(await(await xn(Ut,`${Ut.origin}/related_tag.json?${n}`,e,{},yS)).text())}function Hg(t,e){return e.slice(0,t.ors?t.tagBudget:1)}async function Fg(t,e,n){let r=await xn(t,e,n,{Range:`bytes=0-${pg}`});return Hn(new Uint8Array(await r.arrayBuffer()))}async function ia(t,e,n,r){let i=await xn(t,e,n,{},0),o=Number(i.headers.get("content-length"))||0,s=i.body?.getReader();if(!s)return new Uint8Array(await i.arrayBuffer());let a=[],c=0;for(;;){let{done:f,value:d}=await s.read();if(f)break;a.push(d),c+=d.length,r?.(c,o)}let u=new Uint8Array(c),l=0;for(let f of a)u.set(f,l),l+=f.length;return u}var uM=12,lM=/^[0-9a-f]{40}$/;function fi(){return di(An(),"drawn")}function xg(t){return nM("sha1").update(JSON.stringify(t)).digest("hex")}function Lg(t){return rM(di(fi(),t))}function Tg(t){let e=di(fi(),t);try{let n=oM(e),r=n.readUInt32BE(0),i=JSON.parse(n.toString("utf8",4,4+r)),o=n.subarray(4+r,4+r+i.figure),s=n.subarray(4+r+i.figure,4+r+i.figure+i.picture);if(o.length!==i.figure||s.length!==i.picture)return;let a=new Date;return cM(e,a,a),{stem:i.stem,fill:i.fill,...i.peak?{peak:i.peak}:{},figure:o,picture:s}}catch{return}}function qu(t,e){let n=Buffer.from(JSON.stringify({stem:e.stem,fill:e.fill,...e.peak?{peak:e.peak}:{},figure:e.figure.length,picture:e.picture.length})),r=Buffer.alloc(4);r.writeUInt32BE(n.length),T(di(fi(),t),Buffer.concat([r,n,e.figure,e.picture])),fM()}function fM(){let t=iM(fi()).filter((e)=>lM.test(e)).flatMap((e)=>{try{return[{name:e,at:aM(di(fi(),e)).mtimeMs}]}catch{return[]}}).sort((e,n)=>n.at-e.at);for(let{name:e}of t.slice(uM))sM(di(fi(),e),{force:!0})}import{readdirSync as wM,readFileSync as zg}from"node:fs";import{basename as $M,join as Kg}from"node:path";/*!
2
+ import{createRequire as tM}from"node:module";var qE=Object.create;var{getPrototypeOf:YE,defineProperty:dp,getOwnPropertyNames:JE}=Object;var VE=Object.prototype.hasOwnProperty;function ZE(t){return this[t]}var QE,XE,Rl=(t,e,n)=>{var r=t!=null&&typeof t==="object";if(r){var i=e?QE??=new WeakMap:XE??=new WeakMap,s=i.get(t);if(s)return s}n=t!=null?qE(YE(t)):{};let o=e||!t||!t.__esModule?dp(n,"default",{value:t,enumerable:!0}):n;for(let a of JE(t))if(!VE.call(o,a))dp(o,a,{get:ZE.bind(t,a),enumerable:!0});if(r)i.set(t,o);return o};var wt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Kt=tM(import.meta.url);var _l=wt((kL,Fp)=>{var kM=Kt("util"),Ap=Kt("stream"),je=Fp.exports=function(){Ap.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};kM.inherits(je,Ap);je.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e}),process.nextTick(function(){if(this._process(),this._paused&&this._reads&&this._reads.length>0)this._paused=!1,this.emit("drain")}.bind(this))};je.prototype.write=function(t,e){if(!this.writable)return this.emit("error",Error("Stream not writable")),!1;let n;if(Buffer.isBuffer(t))n=t;else n=Buffer.from(t,e||this._encoding);if(this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&this._reads.length===0)this._paused=!0;return this.writable&&!this._paused};je.prototype.end=function(t,e){if(t)this.write(t,e);if(this.writable=!1,!this._buffers)return;if(this._buffers.length===0)this._end();else this._buffers.push(null),this._process()};je.prototype.destroySoon=je.prototype.end;je.prototype._end=function(){if(this._reads.length>0)this.emit("error",Error("Unexpected end of input"));this.destroy()};je.prototype.destroy=function(){if(!this._buffers)return;this.writable=!1,this._reads=null,this._buffers=null,this.emit("close")};je.prototype._processReadAllowingLess=function(t){this._reads.shift();let e=this._buffers[0];if(e.length>t.length)this._buffered-=t.length,this._buffers[0]=e.slice(t.length),t.func.call(this,e.slice(0,t.length));else this._buffered-=e.length,this._buffers.shift(),t.func.call(this,e)};je.prototype._processRead=function(t){this._reads.shift();let e=0,n=0,r=Buffer.alloc(t.length);while(e<t.length){let i=this._buffers[n++],s=Math.min(i.length,t.length-e);if(i.copy(r,e,0,s),e+=s,s!==i.length)this._buffers[--n]=i.slice(s)}if(n>0)this._buffers.splice(0,n);this._buffered-=t.length,t.func.call(this,r)};je.prototype._process=function(){try{while(this._buffered>0&&this._reads&&this._reads.length>0){let t=this._reads[0];if(t.allowLess)this._processReadAllowingLess(t);else if(this._buffered>=t.length)this._processRead(t);else break}if(this._buffers&&!this.writable)this._end()}catch(t){this.emit("error",t)}}});var Bl=wt((yM)=>{var Xn=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];yM.getImagePasses=function(t,e){let n=[],r=t%8,i=e%8,s=(t-r)/8,o=(e-i)/8;for(let a=0;a<Xn.length;a++){let c=Xn[a],u=s*c.x.length,l=o*c.y.length;for(let d=0;d<c.x.length;d++)if(c.x[d]<r)u++;else break;for(let d=0;d<c.y.length;d++)if(c.y[d]<i)l++;else break;if(u>0&&l>0)n.push({width:u,height:l,index:a})}return n};yM.getInterlaceIterator=function(t){return function(e,n,r){let i=e%Xn[r].x.length,s=(e-i)/Xn[r].x.length*8+Xn[r].x[i],o=n%Xn[r].y.length,a=(n-o)/Xn[r].y.length*8+Xn[r].y[o];return s*4+a*t*4}}});var Wl=wt((vL,Cp)=>{Cp.exports=function(e,n,r){let i=e+n-r,s=Math.abs(i-e),o=Math.abs(i-n),a=Math.abs(i-r);if(s<=o&&s<=a)return e;if(o<=a)return n;return r}});var Ul=wt((SL,jp)=>{var EM=Bl(),MM=Wl();function Lp(t,e,n){let r=t*e;if(n!==8)r=Math.ceil(r/(8/n));return r}var Zi=jp.exports=function(t,e){let{width:n,height:r,interlace:i,bpp:s,depth:o}=t;if(this.read=e.read,this.write=e.write,this.complete=e.complete,this._imageIndex=0,this._images=[],i){let a=EM.getImagePasses(n,r);for(let c=0;c<a.length;c++)this._images.push({byteWidth:Lp(a[c].width,s,o),height:a[c].height,lineIndex:0})}else this._images.push({byteWidth:Lp(n,s,o),height:r,lineIndex:0});if(o===8)this._xComparison=s;else if(o===16)this._xComparison=s*2;else this._xComparison=1};Zi.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))};Zi.prototype._unFilterType1=function(t,e,n){let r=this._xComparison,i=r-1;for(let s=0;s<n;s++){let o=t[1+s],a=s>i?e[s-r]:0;e[s]=o+a}};Zi.prototype._unFilterType2=function(t,e,n){let r=this._lastLine;for(let i=0;i<n;i++){let s=t[1+i],o=r?r[i]:0;e[i]=s+o}};Zi.prototype._unFilterType3=function(t,e,n){let r=this._xComparison,i=r-1,s=this._lastLine;for(let o=0;o<n;o++){let a=t[1+o],c=s?s[o]:0,u=o>i?e[o-r]:0,l=Math.floor((u+c)/2);e[o]=a+l}};Zi.prototype._unFilterType4=function(t,e,n){let r=this._xComparison,i=r-1,s=this._lastLine;for(let o=0;o<n;o++){let a=t[1+o],c=s?s[o]:0,u=o>i?e[o-r]:0,l=o>i&&s?s[o-r]:0,d=MM(u,c,l);e[o]=a+d}};Zi.prototype._reverseFilterLine=function(t){let e=t[0],n,r=this._images[this._imageIndex],i=r.byteWidth;if(e===0)n=t.slice(1,i+1);else switch(n=Buffer.alloc(i),e){case 1:this._unFilterType1(t,n,i);break;case 2:this._unFilterType2(t,n,i);break;case 3:this._unFilterType3(t,n,i);break;case 4:this._unFilterType4(t,n,i);break;default:throw Error("Unrecognised filter type - "+e)}if(this.write(n),r.lineIndex++,r.lineIndex>=r.height)this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex];else this._lastLine=n;if(r)this.read(r.byteWidth+1,this._reverseFilterLine.bind(this));else this._lastLine=null,this.complete()}});var Bp=wt((EL,_p)=>{var OM=Kt("util"),Gp=_l(),IM=Ul(),xM=_p.exports=function(t){Gp.call(this);let e=[],n=this;this._filter=new IM(t,{read:this.read.bind(this),write:function(r){e.push(r)},complete:function(){n.emit("complete",Buffer.concat(e))}}),this._filter.start()};OM.inherits(xM,Gp)});var Qi=wt((ML,Wp)=>{Wp.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}});var Dl=wt((OL,Up)=>{var Kl=[];(function(){for(let t=0;t<256;t++){let e=t;for(let n=0;n<8;n++)if(e&1)e=3988292384^e>>>1;else e=e>>>1;Kl[t]=e}})();var zl=Up.exports=function(){this._crc=-1};zl.prototype.write=function(t){for(let e=0;e<t.length;e++)this._crc=Kl[(this._crc^t[e])&255]^this._crc>>>8;return!0};zl.prototype.crc32=function(){return this._crc^-1};zl.crc32=function(t){let e=-1;for(let n=0;n<t.length;n++)e=Kl[(e^t[n])&255]^e>>>8;return e^-1}});var ql=wt((IL,Kp)=>{var Nt=Qi(),NM=Dl(),Ht=Kp.exports=function(t,e){this._options=t,t.checkCRC=t.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[Nt.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[Nt.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[Nt.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[Nt.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[Nt.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[Nt.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=e.read,this.error=e.error,this.metadata=e.metadata,this.gamma=e.gamma,this.transColor=e.transColor,this.palette=e.palette,this.parsed=e.parsed,this.inflateData=e.inflateData,this.finished=e.finished,this.simpleTransparency=e.simpleTransparency,this.headersFinished=e.headersFinished||function(){}};Ht.prototype.start=function(){this.read(Nt.PNG_SIGNATURE.length,this._parseSignature.bind(this))};Ht.prototype._parseSignature=function(t){let e=Nt.PNG_SIGNATURE;for(let n=0;n<e.length;n++)if(t[n]!==e[n]){this.error(Error("Invalid file signature"));return}this.read(8,this._parseChunkBegin.bind(this))};Ht.prototype._parseChunkBegin=function(t){let e=t.readUInt32BE(0),n=t.readUInt32BE(4),r="";for(let s=4;s<8;s++)r+=String.fromCharCode(t[s]);let i=Boolean(t[4]&32);if(!this._hasIHDR&&n!==Nt.TYPE_IHDR){this.error(Error("Expected IHDR on beggining"));return}if(this._crc=new NM,this._crc.write(Buffer.from(r)),this._chunks[n])return this._chunks[n](e);if(!i){this.error(Error("Unsupported critical chunk type "+r));return}this.read(e+4,this._skipChunk.bind(this))};Ht.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))};Ht.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))};Ht.prototype._parseChunkEnd=function(t){let e=t.readInt32BE(0),n=this._crc.crc32();if(this._options.checkCRC&&n!==e){this.error(Error("Crc error - "+e+" - "+n));return}if(!this._hasIEND)this.read(8,this._parseChunkBegin.bind(this))};Ht.prototype._handleIHDR=function(t){this.read(t,this._parseIHDR.bind(this))};Ht.prototype._parseIHDR=function(t){this._crc.write(t);let e=t.readUInt32BE(0),n=t.readUInt32BE(4),r=t[8],i=t[9],s=t[10],o=t[11],a=t[12];if(r!==8&&r!==4&&r!==2&&r!==1&&r!==16){this.error(Error("Unsupported bit depth "+r));return}if(!(i in Nt.COLORTYPE_TO_BPP_MAP)){this.error(Error("Unsupported color type"));return}if(s!==0){this.error(Error("Unsupported compression method"));return}if(o!==0){this.error(Error("Unsupported filter method"));return}if(a!==0&&a!==1){this.error(Error("Unsupported interlace method"));return}this._colorType=i;let c=Nt.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:e,height:n,depth:r,interlace:Boolean(a),palette:Boolean(i&Nt.COLORTYPE_PALETTE),color:Boolean(i&Nt.COLORTYPE_COLOR),alpha:Boolean(i&Nt.COLORTYPE_ALPHA),bpp:c,colorType:i}),this._handleChunkEnd()};Ht.prototype._handlePLTE=function(t){this.read(t,this._parsePLTE.bind(this))};Ht.prototype._parsePLTE=function(t){this._crc.write(t);let e=Math.floor(t.length/3);for(let n=0;n<e;n++)this._palette.push([t[n*3],t[n*3+1],t[n*3+2],255]);this.palette(this._palette),this._handleChunkEnd()};Ht.prototype._handleTRNS=function(t){this.simpleTransparency(),this.read(t,this._parseTRNS.bind(this))};Ht.prototype._parseTRNS=function(t){if(this._crc.write(t),this._colorType===Nt.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error("Transparency chunk must be after palette"));return}if(t.length>this._palette.length){this.error(Error("More transparent colors than palette size"));return}for(let e=0;e<t.length;e++)this._palette[e][3]=t[e];this.palette(this._palette)}if(this._colorType===Nt.COLORTYPE_GRAYSCALE)this.transColor([t.readUInt16BE(0)]);if(this._colorType===Nt.COLORTYPE_COLOR)this.transColor([t.readUInt16BE(0),t.readUInt16BE(2),t.readUInt16BE(4)]);this._handleChunkEnd()};Ht.prototype._handleGAMA=function(t){this.read(t,this._parseGAMA.bind(this))};Ht.prototype._parseGAMA=function(t){this._crc.write(t),this.gamma(t.readUInt32BE(0)/Nt.GAMMA_DIVISION),this._handleChunkEnd()};Ht.prototype._handleIDAT=function(t){if(!this._emittedHeadersFinished)this._emittedHeadersFinished=!0,this.headersFinished();this.read(-t,this._parseIDAT.bind(this,t))};Ht.prototype._parseIDAT=function(t,e){if(this._crc.write(e),this._colorType===Nt.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error("Expected palette not found");this.inflateData(e);let n=t-e.length;if(n>0)this._handleIDAT(n);else this._handleChunkEnd()};Ht.prototype._handleIEND=function(t){this.read(t,this._parseIEND.bind(this))};Ht.prototype._parseIEND=function(t){if(this._crc.write(t),this._hasIEND=!0,this._handleChunkEnd(),this.finished)this.finished()}});var Yl=wt((FM)=>{var zp=Bl(),RM=[function(){},function(t,e,n,r){if(r===e.length)throw Error("Ran out of data");let i=e[r];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=255},function(t,e,n,r){if(r+1>=e.length)throw Error("Ran out of data");let i=e[r];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=e[r+1]},function(t,e,n,r){if(r+2>=e.length)throw Error("Ran out of data");t[n]=e[r],t[n+1]=e[r+1],t[n+2]=e[r+2],t[n+3]=255},function(t,e,n,r){if(r+3>=e.length)throw Error("Ran out of data");t[n]=e[r],t[n+1]=e[r+1],t[n+2]=e[r+2],t[n+3]=e[r+3]}],TM=[function(){},function(t,e,n,r){let i=e[0];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=r},function(t,e,n){let r=e[0];t[n]=r,t[n+1]=r,t[n+2]=r,t[n+3]=e[1]},function(t,e,n,r){t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=r},function(t,e,n){t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3]}];function PM(t,e){let n=[],r=0;function i(){if(r===t.length)throw Error("Ran out of data");let s=t[r];r++;let o,a,c,u,l,d,f,h;switch(e){default:throw Error("unrecognised depth");case 16:f=t[r],r++,n.push((s<<8)+f);break;case 4:f=s&15,h=s>>4,n.push(h,f);break;case 2:l=s&3,d=s>>2&3,f=s>>4&3,h=s>>6&3,n.push(h,f,d,l);break;case 1:o=s&1,a=s>>1&1,c=s>>2&1,u=s>>3&1,l=s>>4&1,d=s>>5&1,f=s>>6&1,h=s>>7&1,n.push(h,f,d,l,u,c,a,o);break}}return{get:function(s){while(n.length<s)i();let o=n.slice(0,s);return n=n.slice(s),o},resetAfterLine:function(){n.length=0},end:function(){if(r!==t.length)throw Error("extra data found")}}}function HM(t,e,n,r,i,s){let{width:o,height:a,index:c}=t;for(let u=0;u<a;u++)for(let l=0;l<o;l++){let d=n(l,u,c);RM[r](e,i,d,s),s+=r}return s}function AM(t,e,n,r,i,s){let{width:o,height:a,index:c}=t;for(let u=0;u<a;u++){for(let l=0;l<o;l++){let d=i.get(r),f=n(l,u,c);TM[r](e,d,f,s)}i.resetAfterLine()}}FM.dataToBitMap=function(t,e){let{width:n,height:r,depth:i,bpp:s,interlace:o}=e,a;if(i!==8)a=PM(t,i);let c;if(i<=8)c=Buffer.alloc(n*r*4);else c=new Uint16Array(n*r*4);let u=Math.pow(2,i)-1,l=0,d,f;if(o)d=zp.getImagePasses(n,r),f=zp.getInterlaceIterator(n,r);else{let h=0;f=function(){let p=h;return h+=4,p},d=[{width:n,height:r}]}for(let h=0;h<d.length;h++)if(i===8)l=HM(d[h],c,f,s,t,l);else AM(d[h],c,f,s,a,u);if(i===8){if(l!==t.length)throw Error("extra data found")}else a.end();return c}});var Jl=wt((NL,Dp)=>{function LM(t,e,n,r,i){let s=0;for(let o=0;o<r;o++)for(let a=0;a<n;a++){let c=i[t[s]];if(!c)throw Error("index "+t[s]+" not in palette");for(let u=0;u<4;u++)e[s+u]=c[u];s+=4}}function jM(t,e,n,r,i){let s=0;for(let o=0;o<r;o++)for(let a=0;a<n;a++){let c=!1;if(i.length===1){if(i[0]===t[s])c=!0}else if(i[0]===t[s]&&i[1]===t[s+1]&&i[2]===t[s+2])c=!0;if(c)for(let u=0;u<4;u++)e[s+u]=0;s+=4}}function GM(t,e,n,r,i){let s=255,o=Math.pow(2,i)-1,a=0;for(let c=0;c<r;c++)for(let u=0;u<n;u++){for(let l=0;l<4;l++)e[a+l]=Math.floor(t[a+l]*s/o+0.5);a+=4}}Dp.exports=function(t,e,n=!1){let{depth:r,width:i,height:s,colorType:o,transColor:a,palette:c}=e,u=t;if(o===3)LM(t,u,i,s,c);else{if(a)jM(t,u,i,s,a);if(r!==8&&!n){if(r===16)u=Buffer.alloc(i*s*4);GM(t,u,i,s,r)}}return u}});var Jp=wt((RL,Yp)=>{var _M=Kt("util"),Vl=Kt("zlib"),qp=_l(),BM=Bp(),WM=ql(),UM=Yl(),KM=Jl(),en=Yp.exports=function(t){qp.call(this),this._parser=new WM(t,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=t,this.writable=!0,this._parser.start()};_M.inherits(en,qp);en.prototype._handleError=function(t){if(this.emit("error",t),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy)this._inflate.destroy();if(this._filter)this._filter.destroy(),this._filter.on("error",function(){});this.errord=!0};en.prototype._inflateData=function(t){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=Vl.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let n=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,r=Math.max(n,Vl.Z_MIN_CHUNK);this._inflate=Vl.createInflate({chunkSize:r});let i=n,s=this.emit.bind(this,"error");this._inflate.on("error",function(a){if(!i)return;s(a)}),this._filter.on("complete",this._complete.bind(this));let o=this._filter.write.bind(this._filter);this._inflate.on("data",function(a){if(!i)return;if(a.length>i)a=a.slice(0,i);i-=a.length,o(a)}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(t)};en.prototype._handleMetaData=function(t){this._metaData=t,this._bitmapInfo=Object.create(t),this._filter=new BM(this._bitmapInfo)};en.prototype._handleTransColor=function(t){this._bitmapInfo.transColor=t};en.prototype._handlePalette=function(t){this._bitmapInfo.palette=t};en.prototype._simpleTransparency=function(){this._metaData.alpha=!0};en.prototype._headersFinished=function(){this.emit("metadata",this._metaData)};en.prototype._finished=function(){if(this.errord)return;if(!this._inflate)this.emit("error","No Inflate block");else this._inflate.end()};en.prototype._complete=function(t){if(this.errord)return;let e;try{let n=UM.dataToBitMap(t,this._bitmapInfo);e=KM(n,this._bitmapInfo,this._options.skipRescale),n=null}catch(n){this._handleError(n);return}this.emit("parsed",e)}});var Zp=wt((TL,Vp)=>{var Re=Qi();Vp.exports=function(t,e,n,r){let i=[Re.COLORTYPE_COLOR_ALPHA,Re.COLORTYPE_ALPHA].indexOf(r.colorType)!==-1;if(r.colorType===r.inputColorType){let p=function(){let $=new ArrayBuffer(2);return new DataView($).setInt16(0,256,!0),new Int16Array($)[0]!==256}();if(r.bitDepth===8||r.bitDepth===16&&p)return t}let s=r.bitDepth!==16?t:new Uint16Array(t.buffer),o=255,a=Re.COLORTYPE_TO_BPP_MAP[r.inputColorType];if(a===4&&!r.inputHasAlpha)a=3;let c=Re.COLORTYPE_TO_BPP_MAP[r.colorType];if(r.bitDepth===16)o=65535,c*=2;let u=Buffer.alloc(e*n*c),l=0,d=0,f=r.bgColor||{};if(f.red===void 0)f.red=o;if(f.green===void 0)f.green=o;if(f.blue===void 0)f.blue=o;function h(){let p,$,g,b=o;switch(r.inputColorType){case Re.COLORTYPE_COLOR_ALPHA:b=s[l+3],p=s[l],$=s[l+1],g=s[l+2];break;case Re.COLORTYPE_COLOR:p=s[l],$=s[l+1],g=s[l+2];break;case Re.COLORTYPE_ALPHA:b=s[l+1],p=s[l],$=p,g=p;break;case Re.COLORTYPE_GRAYSCALE:p=s[l],$=p,g=p;break;default:throw Error("input color type:"+r.inputColorType+" is not supported at present")}if(r.inputHasAlpha){if(!i)b/=o,p=Math.min(Math.max(Math.round((1-b)*f.red+b*p),0),o),$=Math.min(Math.max(Math.round((1-b)*f.green+b*$),0),o),g=Math.min(Math.max(Math.round((1-b)*f.blue+b*g),0),o)}return{red:p,green:$,blue:g,alpha:b}}for(let p=0;p<n;p++)for(let $=0;$<e;$++){let g=h(s,l);switch(r.colorType){case Re.COLORTYPE_COLOR_ALPHA:case Re.COLORTYPE_COLOR:if(r.bitDepth===8){if(u[d]=g.red,u[d+1]=g.green,u[d+2]=g.blue,i)u[d+3]=g.alpha}else if(u.writeUInt16BE(g.red,d),u.writeUInt16BE(g.green,d+2),u.writeUInt16BE(g.blue,d+4),i)u.writeUInt16BE(g.alpha,d+6);break;case Re.COLORTYPE_ALPHA:case Re.COLORTYPE_GRAYSCALE:{let b=(g.red+g.green+g.blue)/3;if(r.bitDepth===8){if(u[d]=b,i)u[d+1]=g.alpha}else if(u.writeUInt16BE(b,d),i)u.writeUInt16BE(g.alpha,d+2);break}default:throw Error("unrecognised color Type "+r.colorType)}l+=a,d+=c}return u}});var tg=wt((PL,Xp)=>{var Qp=Wl();function zM(t,e,n,r,i){for(let s=0;s<n;s++)r[i+s]=t[e+s]}function DM(t,e,n){let r=0,i=e+n;for(let s=e;s<i;s++)r+=Math.abs(t[s]);return r}function qM(t,e,n,r,i,s){for(let o=0;o<n;o++){let a=o>=s?t[e+o-s]:0,c=t[e+o]-a;r[i+o]=c}}function YM(t,e,n,r){let i=0;for(let s=0;s<n;s++){let o=s>=r?t[e+s-r]:0,a=t[e+s]-o;i+=Math.abs(a)}return i}function JM(t,e,n,r,i){for(let s=0;s<n;s++){let o=e>0?t[e+s-n]:0,a=t[e+s]-o;r[i+s]=a}}function VM(t,e,n){let r=0,i=e+n;for(let s=e;s<i;s++){let o=e>0?t[s-n]:0,a=t[s]-o;r+=Math.abs(a)}return r}function ZM(t,e,n,r,i,s){for(let o=0;o<n;o++){let a=o>=s?t[e+o-s]:0,c=e>0?t[e+o-n]:0,u=t[e+o]-(a+c>>1);r[i+o]=u}}function QM(t,e,n,r){let i=0;for(let s=0;s<n;s++){let o=s>=r?t[e+s-r]:0,a=e>0?t[e+s-n]:0,c=t[e+s]-(o+a>>1);i+=Math.abs(c)}return i}function XM(t,e,n,r,i,s){for(let o=0;o<n;o++){let a=o>=s?t[e+o-s]:0,c=e>0?t[e+o-n]:0,u=e>0&&o>=s?t[e+o-(n+s)]:0,l=t[e+o]-Qp(a,c,u);r[i+o]=l}}function tO(t,e,n,r){let i=0;for(let s=0;s<n;s++){let o=s>=r?t[e+s-r]:0,a=e>0?t[e+s-n]:0,c=e>0&&s>=r?t[e+s-(n+r)]:0,u=t[e+s]-Qp(o,a,c);i+=Math.abs(u)}return i}var eO={0:zM,1:qM,2:JM,3:ZM,4:XM},nO={0:DM,1:YM,2:VM,3:QM,4:tO};Xp.exports=function(t,e,n,r,i){let s;if(!("filterType"in r)||r.filterType===-1)s=[0,1,2,3,4];else if(typeof r.filterType==="number")s=[r.filterType];else throw Error("unrecognised filter types");if(r.bitDepth===16)i*=2;let o=e*i,a=0,c=0,u=Buffer.alloc((o+1)*n),l=s[0];for(let d=0;d<n;d++){if(s.length>1){let f=1/0;for(let h=0;h<s.length;h++){let p=nO[s[h]](t,c,o,i);if(p<f)l=s[h],f=p}}u[a]=l,a++,eO[l](t,c,o,u,a,i),a+=o,c+=o}return u}});var Zl=wt((HL,eg)=>{var zt=Qi(),rO=Dl(),iO=Zp(),sO=tg(),oO=Kt("zlib"),tr=eg.exports=function(t){if(this._options=t,t.deflateChunkSize=t.deflateChunkSize||32768,t.deflateLevel=t.deflateLevel!=null?t.deflateLevel:9,t.deflateStrategy=t.deflateStrategy!=null?t.deflateStrategy:3,t.inputHasAlpha=t.inputHasAlpha!=null?t.inputHasAlpha:!0,t.deflateFactory=t.deflateFactory||oO.createDeflate,t.bitDepth=t.bitDepth||8,t.colorType=typeof t.colorType==="number"?t.colorType:zt.COLORTYPE_COLOR_ALPHA,t.inputColorType=typeof t.inputColorType==="number"?t.inputColorType:zt.COLORTYPE_COLOR_ALPHA,[zt.COLORTYPE_GRAYSCALE,zt.COLORTYPE_COLOR,zt.COLORTYPE_COLOR_ALPHA,zt.COLORTYPE_ALPHA].indexOf(t.colorType)===-1)throw Error("option color type:"+t.colorType+" is not supported at present");if([zt.COLORTYPE_GRAYSCALE,zt.COLORTYPE_COLOR,zt.COLORTYPE_COLOR_ALPHA,zt.COLORTYPE_ALPHA].indexOf(t.inputColorType)===-1)throw Error("option input color type:"+t.inputColorType+" is not supported at present");if(t.bitDepth!==8&&t.bitDepth!==16)throw Error("option bit depth:"+t.bitDepth+" is not supported at present")};tr.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}};tr.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())};tr.prototype.filterData=function(t,e,n){let r=iO(t,e,n,this._options),i=zt.COLORTYPE_TO_BPP_MAP[this._options.colorType];return sO(r,e,n,this._options,i)};tr.prototype._packChunk=function(t,e){let n=e?e.length:0,r=Buffer.alloc(n+12);if(r.writeUInt32BE(n,0),r.writeUInt32BE(t,4),e)e.copy(r,8);return r.writeInt32BE(rO.crc32(r.slice(4,r.length-4)),r.length-4),r};tr.prototype.packGAMA=function(t){let e=Buffer.alloc(4);return e.writeUInt32BE(Math.floor(t*zt.GAMMA_DIVISION),0),this._packChunk(zt.TYPE_gAMA,e)};tr.prototype.packIHDR=function(t,e){let n=Buffer.alloc(13);return n.writeUInt32BE(t,0),n.writeUInt32BE(e,4),n[8]=this._options.bitDepth,n[9]=this._options.colorType,n[10]=0,n[11]=0,n[12]=0,this._packChunk(zt.TYPE_IHDR,n)};tr.prototype.packIDAT=function(t){return this._packChunk(zt.TYPE_IDAT,t)};tr.prototype.packIEND=function(){return this._packChunk(zt.TYPE_IEND,null)}});var sg=wt((AL,ig)=>{var aO=Kt("util"),ng=Kt("stream"),cO=Qi(),uO=Zl(),rg=ig.exports=function(t){ng.call(this);let e=t||{};this._packer=new uO(e),this._deflate=this._packer.createDeflate(),this.readable=!0};aO.inherits(rg,ng);rg.prototype.pack=function(t,e,n,r){if(this.emit("data",Buffer.from(cO.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(e,n)),r)this.emit("data",this._packer.packGAMA(r));let i=this._packer.filterData(t,e,n);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(s){this.emit("data",this._packer.packIDAT(s))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(i)}});var dg=wt((ao,lg)=>{var og=Kt("assert").ok,Xi=Kt("zlib"),lO=Kt("util"),ag=Kt("buffer").kMaxLength;function ti(t){if(!(this instanceof ti))return new ti(t);if(t&&t.chunkSize<Xi.Z_MIN_CHUNK)t.chunkSize=Xi.Z_MIN_CHUNK;if(Xi.Inflate.call(this,t),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,t&&t.maxLength!=null)this._maxLength=t.maxLength}function dO(t){return new ti(t)}function cg(t,e){if(e)process.nextTick(e);if(!t._handle)return;t._handle.close(),t._handle=null}ti.prototype._processChunk=function(t,e,n){if(typeof n==="function")return Xi.Inflate._processChunk.call(this,t,e,n);let r=this,i=t&&t.length,s=this._chunkSize-this._offset,o=this._maxLength,a=0,c=[],u=0,l;this.on("error",function(p){l=p});function d(p,$){if(r._hadError)return;let g=s-$;if(og(g>=0,"have should not go down"),g>0){let b=r._buffer.slice(r._offset,r._offset+g);if(r._offset+=g,b.length>o)b=b.slice(0,o);if(c.push(b),u+=b.length,o-=b.length,o===0)return!1}if($===0||r._offset>=r._chunkSize)s=r._chunkSize,r._offset=0,r._buffer=Buffer.allocUnsafe(r._chunkSize);if($===0)return a+=i-p,i=p,!0;return!1}og(this._handle,"zlib binding closed");let f;do f=this._handle.writeSync(e,t,a,i,this._buffer,this._offset,s),f=f||this._writeState;while(!this._hadError&&d(f[0],f[1]));if(this._hadError)throw l;if(u>=ag)throw cg(this),RangeError("Cannot create final Buffer. It would be larger than 0x"+ag.toString(16)+" bytes");let h=Buffer.concat(c,u);return cg(this),h};lO.inherits(ti,Xi.Inflate);function fO(t,e){if(typeof e==="string")e=Buffer.from(e);if(!(e instanceof Buffer))throw TypeError("Not a string or buffer");let n=t._finishFlushFlag;if(n==null)n=Xi.Z_FINISH;return t._processChunk(e,n)}function ug(t,e){return fO(new ti(e),t)}lg.exports=ao=ug;ao.Inflate=ti;ao.createInflate=dO;ao.inflateSync=ug});var Ql=wt((FL,hg)=>{var fg=hg.exports=function(t){this._buffer=t,this._reads=[]};fg.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e})};fg.prototype.process=function(){while(this._reads.length>0&&this._buffer.length){let t=this._reads[0];if(this._buffer.length&&(this._buffer.length>=t.length||t.allowLess)){this._reads.shift();let e=this._buffer;this._buffer=e.slice(t.length),t.func.call(this,e.slice(0,t.length))}else break}if(this._reads.length>0)throw Error("There are some read requests waitng on finished stream");if(this._buffer.length>0)throw Error("unrecognised content at end of stream")}});var mg=wt((pO)=>{var hO=Ql(),mO=Ul();pO.process=function(t,e){let n=[],r=new hO(t);return new mO(e,{read:r.read.bind(r),write:function(s){n.push(s)},complete:function(){}}).start(),r.process(),Buffer.concat(n)}});var wg=wt((LL,bg)=>{var pg=!0,gg=Kt("zlib"),bO=dg();if(!gg.deflateSync)pg=!1;var wO=Ql(),$O=mg(),kO=ql(),yO=Yl(),vO=Jl();bg.exports=function(t,e){if(!pg)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let n;function r(E){n=E}let i;function s(E){i=E}function o(E){i.transColor=E}function a(E){i.palette=E}function c(){i.alpha=!0}let u;function l(E){u=E}let d=[];function f(E){d.push(E)}let h=new wO(t);if(new kO(e,{read:h.read.bind(h),error:r,metadata:s,gamma:l,palette:a,transColor:o,inflateData:f,simpleTransparency:c}).start(),h.process(),n)throw n;let $=Buffer.concat(d);d.length=0;let g;if(i.interlace)g=gg.inflateSync($);else{let I=((i.width*i.bpp*i.depth+7>>3)+1)*i.height;g=bO($,{chunkSize:I,maxLength:I})}if($=null,!g||!g.length)throw Error("bad png - invalid inflate data response");let b=$O.process(g,i);$=null;let y=yO.dataToBitMap(b,i);b=null;let S=vO(y,i,e.skipRescale);return i.data=S,i.gamma=u||0,i}});var vg=wt((jL,yg)=>{var $g=!0,kg=Kt("zlib");if(!kg.deflateSync)$g=!1;var SO=Qi(),EO=Zl();yg.exports=function(t,e){if(!$g)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let r=new EO(e||{}),i=[];if(i.push(Buffer.from(SO.PNG_SIGNATURE)),i.push(r.packIHDR(t.width,t.height)),t.gamma)i.push(r.packGAMA(t.gamma));let s=r.filterData(t.data,t.width,t.height),o=kg.deflateSync(s,r.getDeflateOptions());if(s=null,!o||!o.length)throw Error("bad png - invalid compressed data response");return i.push(r.packIDAT(o)),i.push(r.packIEND()),Buffer.concat(i)}});var Sg=wt((IO)=>{var MO=wg(),OO=vg();IO.read=function(t,e){return MO(t,e||{})};IO.write=function(t,e){return OO(t,e)}});var Mg=wt((AO)=>{var RO=Kt("util"),Eg=Kt("stream"),TO=Jp(),PO=sg(),HO=Sg(),Vt=AO.PNG=function(t){if(Eg.call(this),t=t||{},this.width=t.width|0,this.height=t.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,t.fill&&this.data)this.data.fill(0);this.gamma=0,this.readable=this.writable=!0,this._parser=new TO(t),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(e){this.data=e,this.emit("parsed",e)}.bind(this)),this._packer=new PO(t),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};RO.inherits(Vt,Eg);Vt.sync=HO;Vt.prototype.pack=function(){if(!this.data||!this.data.length)return this.emit("error","No data provided"),this;return process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this};Vt.prototype.parse=function(t,e){if(e){let n,r;n=function(i){this.removeListener("error",r),this.data=i,e(null,this)}.bind(this),r=function(i){this.removeListener("parsed",n),e(i,null)}.bind(this),this.once("parsed",n),this.once("error",r)}return this.end(t),this};Vt.prototype.write=function(t){return this._parser.write(t),!0};Vt.prototype.end=function(t){this._parser.end(t)};Vt.prototype._metadata=function(t){this.width=t.width,this.height=t.height,this.emit("metadata",t)};Vt.prototype._gamma=function(t){this.gamma=t};Vt.prototype._handleClose=function(){if(!this._parser.writable&&!this._packer.readable)this.emit("close")};Vt.bitblt=function(t,e,n,r,i,s,o,a){if(n|=0,r|=0,i|=0,s|=0,o|=0,a|=0,n>t.width||r>t.height||n+i>t.width||r+s>t.height)throw Error("bitblt reading outside image");if(o>e.width||a>e.height||o+i>e.width||a+s>e.height)throw Error("bitblt writing outside image");for(let c=0;c<s;c++)t.data.copy(e.data,(a+c)*e.width+o<<2,(r+c)*t.width+n<<2,(r+c)*t.width+n+i<<2)};Vt.prototype.bitblt=function(t,e,n,r,i,s,o){return Vt.bitblt(this,t,e,n,r,i,s,o),this};Vt.adjustGamma=function(t){if(t.gamma){for(let e=0;e<t.height;e++)for(let n=0;n<t.width;n++){let r=t.width*e+n<<2;for(let i=0;i<3;i++){let s=t.data[r+i]/255;s=Math.pow(s,0.45454545454545453/t.gamma),t.data[r+i]=Math.round(s*255)}}t.gamma=0}};Vt.prototype.adjustGamma=function(){Vt.adjustGamma(this)}});var of=wt((Z8,o0)=>{var sf={to(t,e){if(!e)return`\x1B[${t+1}G`;return`\x1B[${e+1};${t+1}H`},move(t,e){let n="";if(t<0)n+=`\x1B[${-t}D`;else if(t>0)n+=`\x1B[${t}C`;if(e<0)n+=`\x1B[${-e}A`;else if(e>0)n+=`\x1B[${e}B`;return n},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},I2={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},x2={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let n=0;n<t;n++)e+=this.line+(n<t-1?sf.up():"");if(t)e+=sf.left;return e}};o0.exports={cursor:sf,scroll:I2,erase:x2,beep:"\x07"}});import{spawnSync as nL}from"node:child_process";import{isMainThread as rL}from"node:worker_threads";import{parseArgs as YC}from"node:util";var Tt={name:"@kecan0406/ttheme",version:"1.2.10",type:"module",bin:{ttheme:"bin/ttheme.js"},files:["bin","dist/manifest.json","shell","!shell/check.zsh"],description:"Character terminal palettes for Ghostty, kitty, Alacritty, WezTerm, iTerm2, Windows Terminal, Warp and Konsole",license:"MIT",author:"kecan0406",repository:{type:"git",url:"git+https://github.com/kecan0406/ttheme.git"},homepage:"https://github.com/kecan0406/ttheme#readme",bugs:"https://github.com/kecan0406/ttheme/issues",keywords:["terminal","theme","ghostty","kitty","alacritty","wezterm","iterm2","konsole"],devDependencies:{"@biomejs/biome":"^2.3.0","@clack/prompts":"^1.7.0","@jsquash/jpeg":"^1.6.0","@material/material-color-utilities":"^0.4.0","@types/bun":"^1.3.0","@types/pngjs":"6.0.5","@xterm/headless":"6.0.0","fast-string-width":"^3.0.2",pngjs:"7.0.0","smol-toml":"^1.9.0",typescript:"^5.8.2"},engines:{bun:">=1.3",node:">=20.11"}};import{existsSync as jF,readFileSync as p1}from"node:fs";var fp=(()=>{let t=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(e)=>{let n=0;t.lastIndex=0;while(t.test(e))n+=1;return e.length-n}})(),hp=(t)=>{return t===12288||t>=65281&&t<=65376||t>=65504&&t<=65510},mp=(t)=>{return t===8987||t===9001||t>=12272&&t<=12287||t>=12289&&t<=12350||t>=12441&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12783&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=65040&&t<=65049||t>=65072&&t<=65106||t>=65108&&t<=65126||t>=65128&&t<=65131||t>=127488&&t<=127490||t>=127504&&t<=127547||t>=127552&&t<=127560||t>=131072&&t<=196605||t>=196608&&t<=262141};var nM=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,rM=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,pp=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,iM=/\t{1,1000}/y,gp=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,sM=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,oM=/\p{M}+/gu,aM={limit:1/0,ellipsis:""},bp=(t,e={},n={})=>{let r=e.limit??1/0,i=e.ellipsis??"",s=e?.ellipsisWidth??(i?bp(i,aM,n).width:0),o=0,a=n.controlWidth??0,c=n.tabWidth??8,u=n.emojiWidth??2,l=2,d=n.regularWidth??1,f=n.wideWidth??2,h=[[sM,d],[nM,0],[rM,a],[iM,c],[gp,u],[pp,f]],p=0,$=0,g=t.length,b=0,y=!1,S=g,E=Math.max(0,r-s),I=0,N=0,R=0,F=0;t:while(!0){if(N>I||$>=g&&$>p){let j=t.slice(I,N)||t.slice(p,$);b=0;for(let B of j.replaceAll(oM,"")){let X=B.codePointAt(0)||0;if(hp(X))F=2;else if(mp(X))F=f;else F=d;if(R+F>E)S=Math.min(S,Math.max(I,p)+b);if(R+F>r){y=!0;break t}b+=B.length,R+=F}I=N=0}if($>=g)break t;for(let j=0,B=h.length;j<B;j++){let[X,U]=h[j];if(X.lastIndex=$,X.test(t)){if(b=X===pp?fp(t.slice($,X.lastIndex)):X===gp?1:X.lastIndex-$,F=b*U,R+F>E)S=Math.min(S,$+Math.floor((E-R)/U));if(R+F>r){y=!0;break t}R+=F,I=p,N=$,$=p=X.lastIndex;continue t}}$+=1}return{width:y?E:R,index:y?S:g,truncated:y,ellipsed:y&&r>=s}},wp=bp;var cM={limit:1/0,ellipsis:"",ellipsisWidth:0},uM=(t,e={})=>{return wp(t,cM,e).width},Q=uM;function Tl(t){let e=t.replace("#","");return[e.slice(0,2),e.slice(2,4),e.slice(4,6)].map((n)=>Number.parseInt(n,16)).join(";")}function Ce(t){return`\x1B[38;2;${Tl(t)}m`}function Fa(t,e){return`\x1B[48;2;${Tl(t)};38;2;${Tl(e)}m`}function $p(t,e="\x1B[39m"){return`${t.map((n)=>`${Ce(n)}■`).join(" ")}${e}`}var Pt="\x1B[0m",at="\x1B[1m",P="\x1B[2m",de="\x1B[22m",Di="\x1B[32m",Jt="\x1B[33m",Ca="\x1B[36m",Sn=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],io="⧉";function La(t,e){return e?`\x1B]8;;${e}\x1B\\${t}\x1B]8;;\x1B\\`:t}function Pl(t,e){if(t[e]!=="\x1B")return 0;if(t[e+1]==="]"){let r=t.indexOf("\x07",e+2),i=t.indexOf("\x1B\\",e+2),s=r!==-1&&(i===-1||r<i)?r+1:i!==-1?i+2:0;return s?s-e:0}if(t[e+1]!=="[")return 0;let n=e+2;while(n<t.length&&!/[@-~]/.test(t[n]))n++;return n<t.length?n-e+1:0}function Hl(t,e){let n="",r=0,i=0;while(i<t.length){let s=Pl(t,i);if(s>0){n+=t.slice(i,i+s),i+=s;continue}let o=String.fromCodePoint(t.codePointAt(i)),a=Q(o);if(r+a>e)break;n+=o,r+=a,i+=o.length}return{head:n,used:r}}function ot(t,e,n=!0){if(e<=0)return"";let r=Q(t);if(r<=e)return n?t+" ".repeat(e-r):t;let{head:i,used:s}=Hl(t,e-1);return`${i}${t.includes("\x1B")?"\x1B[0m":""}…${n?" ".repeat(e-1-s):""}`}function kp(t,e){let{head:n,used:r}=Hl(t,e);return`${n}${t.includes("\x1B")?Pt:""}${" ".repeat(e-r)}`}function jt(t,e,n){let r=n-Q(e)-1;return r<=0?ot(t,n):`${ot(t,r)} ${e}`}function kt(t,e){let n=[],r="";for(let i of t.split(/\s+/).filter(Boolean)){let s=r?`${r} ${i}`:i;if(Q(s)<=e){r=s;continue}if(r)n.push(r);while(Q(i)>e){let{head:o}=Hl(i,e),a=Math.max(o.lastIndexOf("/")+1,o.lastIndexOf("#")),c=a>0?a:o.length;n.push(i.slice(0,c)),i=i.slice(c)}r=i}if(r)n.push(r);return n}import{existsSync as Bw,readFileSync as Vd}from"node:fs";import{join as Ww}from"node:path";var lM=/^#[0-9a-f]{6}$/;function ne(t){return lM.test(t)}function nt(t){let e=Number.parseInt(t.slice(1),16);return[e>>16&255,e>>8&255,e&255]}function Gt(t,e,n){let r=nt(t),i=nt(e);return`#${r.map((s,o)=>Math.round(s+((i[o]??0)-s)*n).toString(16).padStart(2,"0")).join("")}`}function yt(t){let[e,n,r]=nt(t).map((i)=>{let s=i/255;return s<=0.03928?s/12.92:((s+0.055)/1.055)**2.4});return 0.2126*e+0.7152*n+0.0722*r}function bt(t,e){let n=yt(t),r=yt(e);return(Math.max(n,r)+0.05)/(Math.min(n,r)+0.05)}function ja(t,e){return Math.round(bt(t,e)*100)/100}function dM(t){let e=t/255;return e<=0.04045?e/12.92:((e+0.055)/1.055)**2.4}function St(t){let[e,n,r]=nt(t).map(dM),i=Math.cbrt(0.4122214708*e+0.5363325363*n+0.0514459929*r),s=Math.cbrt(0.2119034982*e+0.6806995451*n+0.1073969566*r),o=Math.cbrt(0.0883024619*e+0.2817188376*n+0.6299787005*r),a=1.9779984951*i-2.428592205*s+0.4505937099*o,c=0.0259040371*i+0.7827717662*s-0.808675766*o;return{l:0.2104542553*i+0.793617785*s-0.0040720468*o,c:Math.hypot(a,c),h:(Math.atan2(c,a)*180/Math.PI+360)%360}}var Vn=7,yp=3,Al=0.15,vp=1.6,Cl=[1,2,3,4,5,6,9,10,11,12,13,14],Sp=[7,15],Zn=[1,2,3,4,5,6],fe={1:{name:"red",center:19,width:25},2:{name:"green",center:132,width:35},3:{name:"yellow",center:88,width:35},4:{name:"blue",center:250,width:60},5:{name:"magenta",center:329,width:40},6:{name:"cyan",center:197,width:60}},oo=0.03,Le=25,qi=15,Yi=0.08;function En(t,e){let n=t.ansi[e];if(n===void 0)throw Error(`${t.name}: missing ANSI ${e}`);return n}function Fl(t,e,n){let r=t.background;return e.flatMap((i)=>{let s=En(t,i);return bt(s,r)<n?[`ANSI ${i} ${s} on ${r} is ${ja(s,r)}:1, needs ${n}:1`]:[]})}function Ep(t,e){return Math.min(...e.map((n)=>bt(En(t,n),t.background)))}var Mp=[{rule:"foreground",label:"foreground on background",unit:"ratio",min:Vn,measure:({foreground:t,background:e})=>bt(t,e),check:({foreground:t,background:e})=>bt(t,e)<Vn?[`foreground ${t} on ${e} is ${ja(t,e)}:1, needs ${Vn}:1`]:[]},{rule:"accents",label:"weakest accent on background",unit:"ratio",min:yp,measure:(t)=>Ep(t,Cl),check:(t)=>Fl(t,Cl,yp)},{rule:"ansi0-dark",label:"ansi0 luminance",unit:"luminance",max:Al,measure:(t)=>yt(En(t,0)),check:(t)=>{let e=En(t,0);return yt(e)>Al?[`ANSI 0 ${e} has luminance ${yt(e).toFixed(3)}, needs <= ${Al}`]:[]}},{rule:"light-ansi",label:"ansi7 and ansi15 on background",unit:"ratio",min:Vn,measure:(t)=>Ep(t,Sp),check:(t)=>Fl(t,Sp,Vn)},{rule:"ansi8-visible",label:"ansi8 on background",unit:"ratio",min:vp,measure:(t)=>bt(En(t,8),t.background),check:(t)=>Fl(t,[8],vp)},{rule:"selection",label:"foreground on selection",unit:"ratio",min:Vn,measure:({foreground:t,selectionBackground:e})=>e===void 0?Number.NaN:bt(t,e),check:({foreground:t,selectionBackground:e})=>e!==void 0&&bt(t,e)<Vn?[`foreground ${t} on selection ${e} is ${ja(t,e)}:1, needs ${Vn}:1`]:[]}];function Ne(t,e){let n=Math.abs(t-e)%360;return Math.min(n,360-n)}var Qe=(t)=>t>8?t-8:t;function Ji(t){let e=t.signatureSlots.filter((n)=>n.startsWith("ansi")).map((n)=>Number(n.slice(4)));return new Set(e.flatMap((n)=>Zn.includes(Qe(n))?[n,n>8?n-8:n+8]:[n]))}function so(t,e){let n=St(En(t,e));return n.c<oo?void 0:n}function Qn(t){let e=Ji(t);return Cl.flatMap((n)=>{let r=so(t,n),i=fe[Qe(n)];if(r===void 0||i===void 0||e.has(n))return[];let s=Ne(r.h,i.center)-i.width;return s>0?[{slot:n,hue:r.h,over:s}]:[]})}function Mn(t){let e=new Set(t.signatureSlots);return Zn.flatMap((n)=>{let r=so(t,n),i=so(t,n+8);if(r===void 0||i===void 0||e.has(`ansi${n}`)&&e.has(`ansi${n+8}`))return[];return[{normal:n,gap:Ne(r.h,i.h)}]})}function On(t){let e=Ji(t);return[0,8].flatMap((n)=>Zn.flatMap((r)=>Zn.filter((i)=>i>r).flatMap((i)=>{let[s,o]=[n+r,n+i],a=so(t,s),c=so(t,o);if(a===void 0||c===void 0||e.has(s)&&e.has(o))return[];return Ne(a.h,c.h)<qi&&Math.abs(a.l-c.l)<Yi?[[s,o]]:[]})))}var fM=[{rule:"ansi-role",label:"accent hue outside its ANSI role",unit:"degrees",max:0,measure:(t)=>Math.max(0,...Qn(t).map((e)=>e.over)),check:(t)=>Qn(t).map(({slot:e,hue:n,over:r})=>{let i=fe[Qe(e)];return`ANSI ${e} ${En(t,e)} has hue ${n.toFixed(0)}°, ${r.toFixed(0)}° outside ${i.name} (${i.center}±${i.width}°)`})},{rule:"bright-follows",label:"widest normal to bright hue gap",unit:"degrees",max:Le,measure:(t)=>Math.max(0,...Mn(t).map((e)=>e.gap)),check:(t)=>Mn(t).filter((e)=>e.gap>Le).map(({normal:e,gap:n})=>`ANSI ${e+8} is ${n.toFixed(0)}° from ANSI ${e}, needs <= ${Le}°`)},{rule:"distinct",label:"accent pairs that read as one color",unit:"pairs",max:0,measure:(t)=>On(t).length,check:(t)=>On(t).map(([e,n])=>`ANSI ${e} ${En(t,e)} and ANSI ${n} ${En(t,n)} are within ${qi}° hue and ${Yi} lightness`)}],Ga=[...Mp,...fM],Ll=Ga.map((t)=>t.rule),he=Ga.map(({rule:t,label:e,unit:n,min:r,max:i})=>({rule:t,label:e,unit:n,...r===void 0?{}:{min:r},...i===void 0?{}:{max:i}}));function Xe(t){return Ga.map((e)=>Math.round(e.measure(t)*1000)/1000)}function Op(t,e){return t.filter((n)=>!e.waive.includes(n.rule)).flatMap((n)=>n.check(e).map((r)=>({theme:e.name,rule:n.rule,detail:r})))}function Qr(t){return Op(Ga,t)}function Ip(t){return Op(Mp,t)}function xp(t){return t.flatMap(Qr)}import{chmodSync as hM,copyFileSync as mM,existsSync as Vi,mkdirSync as pM,readFileSync as jl,realpathSync as gM,renameSync as Rp,rmSync as Np,statSync as bM,writeFileSync as Tp}from"node:fs";import{dirname as wM}from"node:path";function Pp(t){return`${t}.ttheme.bak`}var $M=/^(?:#|--) ttheme begin$|path = "ttheme-|^DefaultProfile=ttheme-/m;function Gl(t){let e=Pp(t);if(Vi(t)&&!Vi(e)&&!$M.test(jl(t,"utf8")))mM(t,e)}function H(t,e){let n=Vi(t)?gM(t):t;pM(wM(n),{recursive:!0});let r=`${n}.ttheme-${process.pid}`;if(Tp(r,e),Vi(n))hM(r,bM(n).mode&4095);Rp(r,n)}function Xr(t,e,n){if(Tp(t,n),t!==e)Rp(t,e)}function tn(t,e){if((Vi(t)?jl(t,"utf8"):void 0)===e)return!1;return Gl(t),H(t,e),!0}function Hp(t,e){let n=Pp(t),r=Vi(n)?jl(n,"utf8"):void 0;if(e===""&&r===void 0)return Np(t,{force:!0}),"removed";if(H(t,e),r===void 0||r===e)return Np(n,{force:!0}),"restored";return"kept backup"}import{createHash as Wb}from"node:crypto";import{copyFileSync as mx,existsSync as Md,mkdirSync as px,readdirSync as gx,readFileSync as us,renameSync as Ub,rmSync as cs,statSync as bx}from"node:fs";import{basename as Kb,isAbsolute as wx,join as z}from"node:path";import{createHash as _I}from"node:crypto";import{existsSync as BI,readdirSync as WI,readFileSync as UI,rmSync as KI,statSync as zI,utimesSync as DI}from"node:fs";import{join as os}from"node:path";import{readdirSync as qO,rmSync as YO,statSync as JO}from"node:fs";import{setDefaultAutoSelectFamilyAttemptTimeout as VO}from"node:net";import{homedir as ZO}from"node:os";import{join as ho}from"node:path";import{setTimeout as QO}from"node:timers/promises";var Ng=Rl(Mg(),1);import{constants as jO,deflateSync as GO,inflateSync as _O}from"node:zlib";import{inflateRawSync as CO}from"node:zlib";var FO=(()=>{var t=import.meta.url;return function(e={}){var n=e,r,i,s=new Promise((m,w)=>{r=m,i=w});let a=globalThis.ServiceWorkerGlobalScope!==void 0&&typeof self<"u"&&globalThis.caches&&globalThis.caches.default!==void 0,c=typeof process==="object"&&process.release&&process.release.name==="node";if(a||c){if(!globalThis.ImageData)globalThis.ImageData=class{constructor(w,k,v){this.data=w,this.width=k,this.height=v}};if(import.meta.url===void 0)import.meta.url="https://localhost";if(typeof self<"u"&&self.location===void 0)self.location={href:""}}var u=Object.assign({},n),l=[],d="./this.program",f=(m,w)=>{throw w},h=typeof window=="object",p=typeof importScripts=="function",$=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",g="";function b(m){if(n.locateFile)return n.locateFile(m,g);return g+m}var y,S,E;if(h||p){if(p)g=self.location.href;else if(typeof document<"u"&&document.currentScript)g=document.currentScript.src;if(t)g=t;if(g.startsWith("blob:"))g="";else g=g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1);{if(y=(m)=>{var w=new XMLHttpRequest;return w.open("GET",m,!1),w.send(null),w.responseText},p)E=(m)=>{var w=new XMLHttpRequest;return w.open("GET",m,!1),w.responseType="arraybuffer",w.send(null),new Uint8Array(w.response)};S=(m,w,k)=>{var v=new XMLHttpRequest;v.open("GET",m,!0),v.responseType="arraybuffer",v.onload=()=>{if(v.status==200||v.status==0&&v.response){w(v.response);return}k()},v.onerror=k,v.send(null)}}}var I=n.print||console.log.bind(console),N=n.printErr||console.error.bind(console);if(Object.assign(n,u),u=null,n.arguments)l=n.arguments;if(n.thisProgram)d=n.thisProgram;if(n.quit)f=n.quit;var R;if(n.wasmBinary)R=n.wasmBinary;var F,j=!1,B,X,U,Z,W,$t,tt,Jn,Je;function Ve(){var m=F.buffer;n.HEAP8=X=new Int8Array(m),n.HEAP16=Z=new Int16Array(m),n.HEAPU8=U=new Uint8Array(m),n.HEAPU16=W=new Uint16Array(m),n.HEAP32=$t=new Int32Array(m),n.HEAPU32=tt=new Uint32Array(m),n.HEAPF32=Jn=new Float32Array(m),n.HEAPF64=Je=new Float64Array(m)}var Ze=[],Ta=[],Dr=[],gl=!1;function bl(){if(n.preRun){if(typeof n.preRun=="function")n.preRun=[n.preRun];while(n.preRun.length)iS(n.preRun.shift())}kl(Ze)}function wl(){gl=!0,kl(Ta)}function rS(){if(n.postRun){if(typeof n.postRun=="function")n.postRun=[n.postRun];while(n.postRun.length)oS(n.postRun.shift())}kl(Dr)}function iS(m){Ze.unshift(m)}function sS(m){Ta.unshift(m)}function oS(m){Dr.unshift(m)}var qr=0,$l=null,no=null;function aS(m){qr++,n.monitorRunDependencies?.(qr)}function cS(m){if(qr--,n.monitorRunDependencies?.(qr),qr==0){if($l!==null)clearInterval($l),$l=null;if(no){var w=no;no=null,w()}}}function zm(m){n.onAbort?.(m),m="Aborted("+m+")",N(m),j=!0,B=1,m+=". Build with -sASSERTIONS for more info.";var w=new WebAssembly.RuntimeError(m);throw i(w),w}var uS="data:application/octet-stream;base64,",Dm=(m)=>m.startsWith(uS),Yr;if(n.locateFile){if(Yr="mozjpeg_dec.wasm",!Dm(Yr))Yr=b(Yr)}else Yr=new URL("mozjpeg_dec.wasm",import.meta.url).href;function qm(m){if(m==Yr&&R)return new Uint8Array(R);if(E)return E(m);throw"both async and sync fetching of the wasm failed"}function lS(m){if(!R&&(h||p)){if(typeof fetch=="function")return fetch(m,{credentials:"same-origin"}).then((w)=>{if(!w.ok)throw`failed to load wasm binary file at '${m}'`;return w.arrayBuffer()}).catch(()=>qm(m))}return Promise.resolve().then(()=>qm(m))}function Ym(m,w,k){return lS(m).then((v)=>WebAssembly.instantiate(v,w)).then(k,(v)=>{N(`failed to asynchronously prepare wasm: ${v}`),zm(v)})}function dS(m,w,k,v){if(!m&&typeof WebAssembly.instantiateStreaming=="function"&&!Dm(w)&&typeof fetch=="function")return fetch(w,{credentials:"same-origin"}).then((O)=>{var x=WebAssembly.instantiateStreaming(O,k);return x.then(v,function(C){return N(`wasm streaming compile failed: ${C}`),N("falling back to ArrayBuffer instantiation"),Ym(w,k,v)})});return Ym(w,k,v)}function fS(){var m={a:CE};function w(v,O){return qt=v.exports,F=qt.A,Ve(),np=qt.F,sS(qt.B),cS("wasm-instantiate"),qt}aS("wasm-instantiate");function k(v){w(v.instance)}if(n.instantiateWasm)try{return n.instantiateWasm(m,w)}catch(v){N(`Module.instantiateWasm callback failed with error: ${v}`),i(v)}return dS(R,Yr,m,k).catch(i),{}}function hS(m){this.name="ExitStatus",this.message=`Program terminated with exit(${m})`,this.status=m}var kl=(m)=>{while(m.length>0)m.shift()(n)},mS=n.noExitRuntime||!0;class Jm{constructor(m){this.excPtr=m,this.ptr=m-24}set_type(m){tt[this.ptr+4>>2]=m}get_type(){return tt[this.ptr+4>>2]}set_destructor(m){tt[this.ptr+8>>2]=m}get_destructor(){return tt[this.ptr+8>>2]}set_caught(m){m=m?1:0,X[this.ptr+12]=m}get_caught(){return X[this.ptr+12]!=0}set_rethrown(m){m=m?1:0,X[this.ptr+13]=m}get_rethrown(){return X[this.ptr+13]!=0}init(m,w){this.set_adjusted_ptr(0),this.set_type(m),this.set_destructor(w)}set_adjusted_ptr(m){tt[this.ptr+16>>2]=m}get_adjusted_ptr(){return tt[this.ptr+16>>2]}get_exception_ptr(){var m=up(this.get_type());if(m)return tt[this.excPtr>>2];var w=this.get_adjusted_ptr();if(w!==0)return w;return this.excPtr}}var Vm=0,pS=0,gS=(m,w,k)=>{var v=new Jm(m);throw v.init(w,k),Vm=m,pS++,Vm},bS=(m,w,k,v,O)=>{},wS=()=>{var m=Array(256);for(var w=0;w<256;++w)m[w]=String.fromCharCode(w);Zm=m},Zm,Fe=(m)=>{var w="",k=m;while(U[k])w+=Zm[U[k++]];return w},Wi={},Jr={},Pa={},Qm,le=(m)=>{throw new Qm(m)},Xm,tp=(m)=>{throw new Xm(m)},$S=(m,w,k)=>{m.forEach(function(T){Pa[T]=w});function v(T){var G=k(T);if(G.length!==m.length)tp("Mismatched type converter count");for(var V=0;V<m.length;++V)kn(m[V],G[V])}var O=Array(w.length),x=[],C=0;if(w.forEach((T,G)=>{if(Jr.hasOwnProperty(T))O[G]=Jr[T];else{if(x.push(T),!Wi.hasOwnProperty(T))Wi[T]=[];Wi[T].push(()=>{if(O[G]=Jr[T],++C,C===x.length)v(O)})}}),x.length===0)v(O)};function kS(m,w,k={}){var v=w.name;if(!m)le(`type "${v}" must have a positive integer typeid pointer`);if(Jr.hasOwnProperty(m))if(k.ignoreDuplicateRegistrations)return;else le(`Cannot register type '${v}' twice`);if(Jr[m]=w,delete Pa[m],Wi.hasOwnProperty(m)){var O=Wi[m];delete Wi[m],O.forEach((x)=>x())}}function kn(m,w,k={}){if(!("argPackAdvance"in w))throw TypeError("registerType registeredInstance requires argPackAdvance");return kS(m,w,k)}var Vr=8,yS=(m,w,k,v)=>{w=Fe(w),kn(m,{name:w,fromWireType:function(O){return!!O},toWireType:function(O,x){return x?k:v},argPackAdvance:Vr,readValueFromPointer:function(O){return this.fromWireType(U[O])},destructorFunction:null})},yl=[],yn=[],vl=(m)=>{if(m>9&&--yn[m+1]===0)yn[m]=void 0,yl.push(m)},vS=()=>yn.length/2-5-yl.length,SS=()=>{yn.push(0,1,void 0,1,null,1,!0,1,!1,1),n.count_emval_handles=vS},Zr={toValue:(m)=>{if(!m)le("Cannot use deleted val. handle = "+m);return yn[m]},toHandle:(m)=>{switch(m){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let w=yl.pop()||yn.length;return yn[w]=m,yn[w+1]=1,w}}}};function Sl(m){return this.fromWireType(tt[m>>2])}var ES={name:"emscripten::val",fromWireType:(m)=>{var w=Zr.toValue(m);return vl(m),w},toWireType:(m,w)=>Zr.toHandle(w),argPackAdvance:Vr,readValueFromPointer:Sl,destructorFunction:null},MS=(m)=>kn(m,ES),OS=(m,w)=>{switch(w){case 4:return function(k){return this.fromWireType(Jn[k>>2])};case 8:return function(k){return this.fromWireType(Je[k>>3])};default:throw TypeError(`invalid float width (${w}): ${m}`)}},IS=(m,w,k)=>{w=Fe(w),kn(m,{name:w,fromWireType:(v)=>v,toWireType:(v,O)=>O,argPackAdvance:Vr,readValueFromPointer:OS(w,k),destructorFunction:null})},El=(m,w)=>Object.defineProperty(w,"name",{value:m}),ep=(m)=>{while(m.length){var w=m.pop(),k=m.pop();k(w)}};function xS(m){for(var w=1;w<m.length;++w)if(m[w]!==null&&m[w].destructorFunction===void 0)return!0;return!1}function NS(m,w,k,v,O,x){var C=w.length;if(C<2)le("argTypes array size mismatch! Must at least get return value and 'this' types!");var T=w[1]!==null&&k!==null,G=xS(w),V=w[0].name!=="void",ht=C-2,It=Array(ht),Yt=[],xe=[],Ui=function(...xl){if(xl.length!==ht)le(`function ${m} called with ${xl.length} arguments, expected ${ht}`);xe.length=0;var Nl;if(Yt.length=T?2:1,Yt[0]=O,T)Nl=w[1].toWireType(xe,this),Yt[1]=Nl;for(var Ki=0;Ki<ht;++Ki)It[Ki]=w[Ki+2].toWireType(xe,xl[Ki]),Yt.push(It[Ki]);var UE=v(...Yt);function KE(zE){if(G)ep(xe);else for(var zi=T?1:2;zi<w.length;zi++){var DE=zi===1?Nl:It[zi-2];if(w[zi].destructorFunction!==null)w[zi].destructorFunction(DE)}if(V)return w[0].fromWireType(zE)}return KE(UE)};return El(m,Ui)}var RS=(m,w,k)=>{if(m[w].overloadTable===void 0){var v=m[w];m[w]=function(...O){if(!m[w].overloadTable.hasOwnProperty(O.length))le(`Function '${k}' called with an invalid number of arguments (${O.length}) - expects one of (${m[w].overloadTable})!`);return m[w].overloadTable[O.length].apply(this,O)},m[w].overloadTable=[],m[w].overloadTable[v.argCount]=v}},TS=(m,w,k)=>{if(n.hasOwnProperty(m)){if(k===void 0||n[m].overloadTable!==void 0&&n[m].overloadTable[k]!==void 0)le(`Cannot register public name '${m}' twice`);if(RS(n,m,m),n.hasOwnProperty(k))le(`Cannot register multiple overloads of a function with the same number of arguments (${k})!`);n[m].overloadTable[k]=w}else if(n[m]=w,k!==void 0)n[m].numArguments=k},PS=(m,w)=>{var k=[];for(var v=0;v<m;v++)k.push(tt[w+v*4>>2]);return k},HS=(m,w,k)=>{if(!n.hasOwnProperty(m))tp("Replacing nonexistent public symbol");if(n[m].overloadTable!==void 0&&k!==void 0)n[m].overloadTable[k]=w;else n[m]=w,n[m].argCount=k},AS=(m,w,k)=>{m=m.replace(/p/g,"i");var v=n["dynCall_"+m];return v(w,...k)},Ha=[],np,rp=(m)=>{var w=Ha[m];if(!w){if(m>=Ha.length)Ha.length=m+1;Ha[m]=w=np.get(m)}return w},FS=(m,w,k=[])=>{if(m.includes("j"))return AS(m,w,k);var v=rp(w)(...k);return v},CS=(m,w)=>(...k)=>FS(m,w,k),LS=(m,w)=>{m=Fe(m);function k(){if(m.includes("j"))return CS(m,w);return rp(w)}var v=k();if(typeof v!="function")le(`unknown function pointer with signature ${m}: ${w}`);return v},jS=(m,w)=>{var k=El(w,function(v){this.name=w,this.message=v;var O=Error(v).stack;if(O!==void 0)this.stack=this.toString()+`
3
+ `+O.replace(/^Error(:[^\n]*)?\n/,"")});return k.prototype=Object.create(m.prototype),k.prototype.constructor=k,k.prototype.toString=function(){if(this.message===void 0)return this.name;else return`${this.name}: ${this.message}`},k},ip,sp=(m)=>{var w=cp(m),k=Fe(w);return vn(w),k},GS=(m,w)=>{var k=[],v={};function O(x){if(v[x])return;if(Jr[x])return;if(Pa[x]){Pa[x].forEach(O);return}k.push(x),v[x]=!0}throw w.forEach(O),new ip(`${m}: `+k.map(sp).join([", "]))},_S=(m)=>{m=m.trim();let w=m.indexOf("(");if(w!==-1)return m.substr(0,w);else return m},BS=(m,w,k,v,O,x,C)=>{var T=PS(w,k);m=Fe(m),m=_S(m),O=LS(v,O),TS(m,function(){GS(`Cannot call ${m} due to unbound types`,T)},w-1),$S([],T,(G)=>{var V=[G[0],null].concat(G.slice(1));return HS(m,NS(m,V,null,O,x,C),w-1),[]})},WS=(m,w,k)=>{switch(w){case 1:return k?(v)=>X[v]:(v)=>U[v];case 2:return k?(v)=>Z[v>>1]:(v)=>W[v>>1];case 4:return k?(v)=>$t[v>>2]:(v)=>tt[v>>2];default:throw TypeError(`invalid integer width (${w}): ${m}`)}},US=(m,w,k,v,O)=>{if(w=Fe(w),O===-1)O=4294967295;var x=(ht)=>ht;if(v===0){var C=32-8*k;x=(ht)=>ht<<C>>>C}var T=w.includes("unsigned"),G=(ht,It)=>{},V;if(T)V=function(ht,It){return G(It,this.name),It>>>0};else V=function(ht,It){return G(It,this.name),It};kn(m,{name:w,fromWireType:x,toWireType:V,argPackAdvance:Vr,readValueFromPointer:WS(w,k,v!==0),destructorFunction:null})},KS=(m,w,k)=>{var v=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],O=v[w];function x(C){var T=tt[C>>2],G=tt[C+4>>2];return new O(X.buffer,G,T)}k=Fe(k),kn(m,{name:k,fromWireType:x,argPackAdvance:Vr,readValueFromPointer:x},{ignoreDuplicateRegistrations:!0})},zS=(m,w,k,v)=>{if(!(v>0))return 0;var O=k,x=k+v-1;for(var C=0;C<m.length;++C){var T=m.charCodeAt(C);if(T>=55296&&T<=57343){var G=m.charCodeAt(++C);T=65536+((T&1023)<<10)|G&1023}if(T<=127){if(k>=x)break;w[k++]=T}else if(T<=2047){if(k+1>=x)break;w[k++]=192|T>>6,w[k++]=128|T&63}else if(T<=65535){if(k+2>=x)break;w[k++]=224|T>>12,w[k++]=128|T>>6&63,w[k++]=128|T&63}else{if(k+3>=x)break;w[k++]=240|T>>18,w[k++]=128|T>>12&63,w[k++]=128|T>>6&63,w[k++]=128|T&63}}return w[k]=0,k-O},DS=(m,w,k)=>zS(m,U,w,k),qS=(m)=>{var w=0;for(var k=0;k<m.length;++k){var v=m.charCodeAt(k);if(v<=127)w++;else if(v<=2047)w+=2;else if(v>=55296&&v<=57343)w+=4,++k;else w+=3}return w},op=(m,w,k)=>{var v=w+k,O="";while(!(w>=v)){var x=m[w++];if(!x)return O;if(!(x&128)){O+=String.fromCharCode(x);continue}var C=m[w++]&63;if((x&224)==192){O+=String.fromCharCode((x&31)<<6|C);continue}var T=m[w++]&63;if((x&240)==224)x=(x&15)<<12|C<<6|T;else x=(x&7)<<18|C<<12|T<<6|m[w++]&63;if(x<65536)O+=String.fromCharCode(x);else{var G=x-65536;O+=String.fromCharCode(55296|G>>10,56320|G&1023)}}return O},YS=(m,w)=>m?op(U,m,w):"",JS=(m,w)=>{w=Fe(w);var k=w==="std::string";kn(m,{name:w,fromWireType(v){var O=tt[v>>2],x=v+4,C;if(k){var T=x;for(var G=0;G<=O;++G){var V=x+G;if(G==O||U[V]==0){var ht=V-T,It=YS(T,ht);if(C===void 0)C=It;else C+=String.fromCharCode(0),C+=It;T=V+1}}}else{var Yt=Array(O);for(var G=0;G<O;++G)Yt[G]=String.fromCharCode(U[x+G]);C=Yt.join("")}return vn(v),C},toWireType(v,O){if(O instanceof ArrayBuffer)O=new Uint8Array(O);var x,C=typeof O=="string";if(!(C||O instanceof Uint8Array||O instanceof Uint8ClampedArray||O instanceof Int8Array))le("Cannot pass non-string to std::string");if(k&&C)x=qS(O);else x=O.length;var T=Il(4+x+1),G=T+4;if(tt[T>>2]=x,k&&C)DS(O,G,x+1);else if(C)for(var V=0;V<x;++V){var ht=O.charCodeAt(V);if(ht>255)vn(G),le("String has UTF-16 code units that do not fit in 8 bits");U[G+V]=ht}else for(var V=0;V<x;++V)U[G+V]=O[V];if(v!==null)v.push(vn,T);return T},argPackAdvance:Vr,readValueFromPointer:Sl,destructorFunction(v){vn(v)}})},VS=(m,w)=>{var k="";for(var v=0;!(v>=w/2);++v){var O=Z[m+v*2>>1];if(O==0)break;k+=String.fromCharCode(O)}return k},ZS=(m,w,k)=>{if(k??=2147483647,k<2)return 0;k-=2;var v=w,O=k<m.length*2?k/2:m.length;for(var x=0;x<O;++x){var C=m.charCodeAt(x);Z[w>>1]=C,w+=2}return Z[w>>1]=0,w-v},QS=(m)=>m.length*2,XS=(m,w)=>{var k=0,v="";while(!(k>=w/4)){var O=$t[m+k*4>>2];if(O==0)break;if(++k,O>=65536){var x=O-65536;v+=String.fromCharCode(55296|x>>10,56320|x&1023)}else v+=String.fromCharCode(O)}return v},tE=(m,w,k)=>{if(k??=2147483647,k<4)return 0;var v=w,O=v+k-4;for(var x=0;x<m.length;++x){var C=m.charCodeAt(x);if(C>=55296&&C<=57343){var T=m.charCodeAt(++x);C=65536+((C&1023)<<10)|T&1023}if($t[w>>2]=C,w+=4,w+4>O)break}return $t[w>>2]=0,w-v},eE=(m)=>{var w=0;for(var k=0;k<m.length;++k){var v=m.charCodeAt(k);if(v>=55296&&v<=57343)++k;w+=4}return w},nE=(m,w,k)=>{k=Fe(k);var v,O,x,C;if(w===2)v=VS,O=ZS,C=QS,x=(T)=>W[T>>1];else if(w===4)v=XS,O=tE,C=eE,x=(T)=>tt[T>>2];kn(m,{name:k,fromWireType:(T)=>{var G=tt[T>>2],V,ht=T+4;for(var It=0;It<=G;++It){var Yt=T+4+It*w;if(It==G||x(Yt)==0){var xe=Yt-ht,Ui=v(ht,xe);if(V===void 0)V=Ui;else V+=String.fromCharCode(0),V+=Ui;ht=Yt+w}}return vn(T),V},toWireType:(T,G)=>{if(typeof G!="string")le(`Cannot pass non-string to C++ string type ${k}`);var V=C(G),ht=Il(4+V+w);if(tt[ht>>2]=V/w,O(G,ht+4,V+w),T!==null)T.push(vn,ht);return ht},argPackAdvance:Vr,readValueFromPointer:Sl,destructorFunction(T){vn(T)}})},rE=(m,w)=>{w=Fe(w),kn(m,{isVoid:!0,name:w,argPackAdvance:0,fromWireType:()=>{return},toWireType:(k,v)=>{return}})},iE=(m,w,k)=>U.copyWithin(m,w,w+k),Ml=[],sE=(m,w,k,v)=>{return m=Ml[m],w=Zr.toValue(w),m(null,w,k,v)},oE={},aE=(m)=>{var w=oE[m];if(w===void 0)return Fe(m);return w},ap=()=>{if(typeof globalThis=="object")return globalThis;function m(w){w.$$$embind_global$$$=w;var k=typeof $$$embind_global$$$=="object"&&w.$$$embind_global$$$==w;if(!k)delete w.$$$embind_global$$$;return k}if(typeof $$$embind_global$$$=="object")return $$$embind_global$$$;if(typeof global=="object"&&m(global))$$$embind_global$$$=global;else if(typeof self=="object"&&m(self))$$$embind_global$$$=self;if(typeof $$$embind_global$$$=="object")return $$$embind_global$$$;throw Error("unable to get global object.")},cE=(m)=>{if(m===0)return Zr.toHandle(ap());else return m=aE(m),Zr.toHandle(ap()[m])},uE=(m)=>{var w=Ml.length;return Ml.push(m),w},lE=(m,w)=>{var k=Jr[m];if(k===void 0)le(`${w} has unknown type ${sp(m)}`);return k},dE=(m,w)=>{var k=Array(m);for(var v=0;v<m;++v)k[v]=lE(tt[w+v*4>>2],"parameter "+v);return k},fE=Reflect.construct,hE=(m,w,k)=>{var v=[],O=m.toWireType(v,k);if(v.length)tt[w>>2]=Zr.toHandle(v);return O},mE=(m,w,k)=>{var v=dE(m,w),O=v.shift();m--;var x=Array(m),C=(G,V,ht,It)=>{var Yt=0;for(var xe=0;xe<m;++xe)x[xe]=v[xe].readValueFromPointer(It+Yt),Yt+=v[xe].argPackAdvance;var Ui=k===1?fE(V,x):V.apply(G,x);return hE(O,ht,Ui)},T=`methodCaller<(${v.map((G)=>G.name).join(", ")}) => ${O.name}>`;return uE(El(T,C))},pE=(m)=>{if(m>9)yn[m+1]+=1},gE=(m)=>{var w=Zr.toValue(m);ep(w),vl(m)},bE=()=>{zm("")},wE=()=>2147483648,$E=(m)=>{var w=F.buffer,k=(m-w.byteLength+65535)/65536;try{return F.grow(k),Ve(),1}catch(v){}},kE=(m)=>{var w=U.length;m>>>=0;var k=wE();if(m>k)return!1;var v=(G,V)=>G+(V-G%V)%V;for(var O=1;O<=4;O*=2){var x=w*(1+0.2/O);x=Math.min(x,m+100663296);var C=Math.min(k,v(Math.max(m,x),65536)),T=$E(C);if(T)return!0}return!1},Ol={},yE=()=>d||"./this.program",ro=()=>{if(!ro.strings){var m=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",w={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:m,_:yE()};for(var k in Ol)if(Ol[k]===void 0)delete w[k];else w[k]=Ol[k];var v=[];for(var k in w)v.push(`${k}=${w[k]}`);ro.strings=v}return ro.strings},vE=(m,w)=>{for(var k=0;k<m.length;++k)X[w++]=m.charCodeAt(k);X[w]=0},SE=(m,w)=>{var k=0;return ro().forEach((v,O)=>{var x=w+k;tt[m+O*4>>2]=x,vE(v,x),k+=v.length+1}),0},EE=(m,w)=>{var k=ro();tt[m>>2]=k.length;var v=0;return k.forEach((O)=>v+=O.length+1),tt[w>>2]=v,0},ME=0,OE=()=>mS||ME>0,IE=(m)=>{if(B=m,!OE())n.onExit?.(m),j=!0;f(m,new hS(m))},xE=(m,w)=>{B=m,IE(m)},NE=xE,RE=(m)=>52,TE=(m,w)=>w+2097152>>>0<4194305-!!m?(m>>>0)+w*4294967296:NaN;function PE(m,w,k,v,O){var x=TE(w,k);return 70}var HE=[null,[],[]],AE=(m,w)=>{var k=HE[m];if(w===0||w===10)(m===1?I:N)(op(k,0)),k.length=0;else k.push(w)},FE=(m,w,k,v)=>{var O=0;for(var x=0;x<k;x++){var C=tt[w>>2],T=tt[w+4>>2];w+=8;for(var G=0;G<T;G++)AE(m,U[C+G]);O+=T}return tt[v>>2]=O,0};wS(),Qm=n.BindingError=class extends Error{constructor(w){super(w);this.name="BindingError"}},Xm=n.InternalError=class extends Error{constructor(w){super(w);this.name="InternalError"}},SS(),ip=n.UnboundTypeError=jS(Error,"UnboundTypeError");var CE={o:gS,q:bS,m:yS,l:MS,j:IS,f:BS,b:US,a:KS,e:JS,c:nE,n:rE,v:iE,i:sE,d:vl,k:cE,h:mE,y:pE,g:gE,r:bE,s:kE,t:SE,u:EE,z:NE,w:RE,p:PE,x:FE},qt=fS(),LE=()=>(LE=qt.B)(),cp=(m)=>(cp=qt.C)(m),Il=(m)=>(Il=qt.D)(m),vn=(m)=>(vn=qt.E)(m),jE=(m)=>(jE=qt._emscripten_stack_restore)(m),GE=(m)=>(GE=qt._emscripten_stack_alloc)(m),_E=()=>(_E=qt.emscripten_stack_get_current)(),BE=(m)=>(BE=qt.__cxa_increment_exception_refcount)(m),up=(m)=>(up=qt.G)(m),WE=n.dynCall_jiji=(m,w,k,v,O)=>(WE=n.dynCall_jiji=qt.H)(m,w,k,v,O),Aa;no=function m(){if(!Aa)lp();if(!Aa)no=m};function lp(){if(qr>0)return;if(bl(),qr>0)return;function m(){if(Aa)return;if(Aa=!0,n.calledRun=!0,j)return;if(wl(),r(n),n.onRuntimeInitialized)n.onRuntimeInitialized();rS()}if(n.setStatus)n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),m()},1);else m()}if(n.preInit){if(typeof n.preInit=="function")n.preInit=[n.preInit];while(n.preInit.length>0)n.preInit.pop()()}return lp(),s}})(),Og=FO;function td(t){if(t[0]!==255||t[1]!==216)return null;let e=2;while(e+9<t.length){if(t[e]!==255){e++;continue}let n=t[e+1];if(n===255){e++;continue}let r=t[e+2]<<8|t[e+3];if(n>=192&&n<=207&&n!==196&&n!==200&&n!==204)return{height:t[e+5]<<8|t[e+6],width:t[e+7]<<8|t[e+8]};e+=2+r}return null}var Xl;function LO(){if(Xl)return Xl;let t=new WebAssembly.Module(CO(Buffer.from("7L0NnFzHVSd6q+5H3+7bPdMjjeyRZmTf7ohFITZWg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pEgwRs0A9w8QZJk7/Ey8TTCPSw/NUIrxMfVWkkWEa+T/R2blz56rElx5TZp39peuXeB6eviakhOdMIpdMM1WkiQGa6H/is/8ImFkqcTeeZxAZZlqsIrMYZhb/7+hcvEQm08Rqmo1waIRifVQlbntcmWGHB0s8i8/bo5gwxjFhjGNSGA8K6z0OQj8eFpZ7HBPJONp2HE0xjuYbJ9Yf1R9HtcdRxXHUaxxNNo4Cjs+UZcE4Cj6OThlHb4yjguOYSMYxYYxjQhjHJDAOIj+O8t6Hyeso8j+K/I8i/6PI/yjyP4r8jyL/o8j/KPI/ivyPIv+jyP8p5H8U+R9Fz3wdR9AQP4b4McSP/biazzypX4Wj0R5yqiPe0DijaSYzKPPmv+PU06zmltNPLvy/+Yf6BGqMkB446onyn6uLP/v3Z14+sr3++PHzzyDGIA13DI0ex0x76GqfWrW6Xl1+80Glnns9OFtPvHvh9iC5x946fvyTDx4/jgG8a1dqbCzZn93XCbnIrtJgdngXqZnsggpVgei8WolZ/BpwBO2LeMC74JfjPYc9Om8Egj8C+HvOnAR+hERoE+GPTQp/DuALvEPojkHws8GNxM6StrgOz4/heTXcx2ntBvcJVZXWYsx3A9hESPL2Za46vfRZkv8+xNuG94Nw/fr9LriUfr8XblC/PwCX1O+PwJX0+9NwZf3+LFxWv78EN6Tf34TL6fcAiOSwfo/jfUy/z8f7Af3ehvcB/b60Xfqa3le1V9cT76XsZN3C9dxEEy7q2Vc+p7LHrH/3I+wjeF4L98eKYDo7c4Xd4A9k+5zi3wWY9y8S+GMa/roK/GLZgNURdJ5Pt0va9KO8qa/+xNVX18P9KdwNcDdyOuc4BVea0Ziv8yy3S/xPVsX/FNxNcJ/W8Jfr/KisN+N5CxxGgroV7jNwf6YS1/xYmZHxJbIACoKO4tt3uUrcj2f0CvhdCXfXEhx7owAsIp/5sYfQHnoG3lf9Bw==","base64"))),e={noInitialRun:!0,print:()=>{return},printErr:()=>{return},instantiateWasm:(n,r)=>{let i=new WebAssembly.Instance(t,n);return r(i),i.exports}};if(Og(e),typeof e.decode!=="function")throw Error("the JPEG decoder did not start");return Xl=e,e}function Ig(t,e){let n=td(t);if(n&&n.width*n.height>e)throw Error(`${n.width}×${n.height} is over ${e/1e6} megapixels`);let r=null;try{r=LO().decode(t,!0)}catch{r=null}if(!r)throw Error("not a JPEG image this decoder can read");return{width:r.width,height:r.height,data:new Uint8Array(r.data.buffer,r.data.byteOffset,r.data.length)}}var ts=[137,80,78,71,13,10,26,10],Rg=13,Tg=3;function ei(t){return t.length>=ts.length&&ts.every((e,n)=>t[n]===e)}var Pg={0:1,2:3,4:2,6:4};function BO(t){if(t.length<33||!ei(t))return;let e=Buffer.from(t.buffer,t.byteOffset,t.byteLength),n=e.readUInt32BE(16),r=e.readUInt32BE(20),i=e[25];if(e[24]!==8||e[28]!==0||Pg[i]===void 0)return;let s=[];for(let o=8;o+12<=e.length;){let a=e.readUInt32BE(o),c=e.toString("latin1",o+4,o+8);if(c==="IDAT")s.push(e.subarray(o+8,o+8+a));else if(c==="tRNS"||c==="IEND"){if(c==="tRNS"&&i!==4&&i!==6)return;break}o+=12+a}return s.length>0?{width:n,height:r,type:i,idat:s}:void 0}function WO(t,e,n,r){let i=new Uint8Array(e);for(let s=0;s<n;s++){let o=s*(e+1),a=t[o],c=o+1,u=s>0?t:i,l=s>0?c-e-1:0;if(a===1)for(let d=r;d<e;d++)t[c+d]=t[c+d]+t[c+d-r];else if(a===2)for(let d=0;d<e;d++)t[c+d]=t[c+d]+u[l+d];else if(a===3){for(let d=0;d<r;d++)t[c+d]=t[c+d]+(u[l+d]>>1);for(let d=r;d<e;d++)t[c+d]=t[c+d]+(t[c+d-r]+u[l+d]>>1)}else if(a===4){for(let d=0;d<r;d++)t[c+d]=t[c+d]+u[l+d];for(let d=r;d<e;d++){let f=t[c+d-r],h=u[l+d],p=u[l+d-r],$=Math.abs(h-p),g=Math.abs(f-p),b=Math.abs(f+h-2*p);t[c+d]=t[c+d]+($<=g&&$<=b?f:g<=b?h:p)}}else if(a!==0)throw Error(`bad PNG filter ${a}`)}}function UO(t){let{width:e,height:n,type:r}=t,i=Pg[r],s=e*i,o=_O(Buffer.concat(t.idat),{chunkSize:Math.min(268435456,Math.max(65536,n*(s+1)))});if(o.length<n*(s+1))throw Error("truncated PNG");WO(o,s,n,i);let a=new Uint8Array(e*n*4);for(let c=0;c<n;c++){let u=c*(s+1)+1,l=c*e*4;if(r===6)a.set(o.subarray(u,u+s),l);else if(r===2)for(let d=0,f=u,h=l;d<e;d++,f+=3,h+=4)a[h]=o[f],a[h+1]=o[f+1],a[h+2]=o[f+2],a[h+3]=255;else if(r===0)for(let d=0,f=l;d<e;d++,f+=4){let h=o[u+d];a[f]=h,a[f+1]=h,a[f+2]=h,a[f+3]=255}else for(let d=0,f=u,h=l;d<e;d++,f+=2,h+=4){let p=o[f];a[h]=p,a[h+1]=p,a[h+2]=p,a[h+3]=o[f+1]}}return{width:e,height:n,data:a}}function At(t){let e=BO(t);if(e)return UO(e);let n=Ng.PNG.sync.read(Buffer.from(t));return{width:n.width,height:n.height,data:new Uint8Array(n.data)}}function nr(t,e){if(ei(t)){let n=nn(t);if(n&&n.width*n.height>e)throw Error(`${n.width}×${n.height} is over ${e/1e6} megapixels`);return At(t)}if(t[0]===255&&t[1]===216)return Ig(t,e);throw Error("not a PNG or JPEG image")}function Hg(t,e){let{width:n,height:r,at:i}=e,s=Math.max(0,i.x),o=Math.max(0,i.y),a=Math.min(n,i.x+i.w),c=Math.min(r,i.y+i.h);if(a<=s||c<=o)return;let u={x:s,y:o,w:a-s,h:c-o};if(i.w===t.width&&i.h===t.height)return{part:t,box:u,dx:s-i.x,dy:o-i.y};let l={x:(s-i.x)*t.width/i.w,y:(o-i.y)*t.height/i.h,w:u.w*t.width/i.w,h:u.h*t.height/i.h};return{part:co(t,l,u.w,u.h),box:u,dx:0,dy:0}}function Ag(t,e){let n=new Uint8Array(e.width*e.height*4),r=Hg(t,e);if(r){let{part:i,box:s,dx:o,dy:a}=r;for(let c=0;c<s.h;c++){let u=((c+a)*i.width+o)*4;n.set(i.data.subarray(u,u+s.w*4),((s.y+c)*e.width+s.x)*4)}}return{width:e.width,height:e.height,data:n}}function rr(t,e,n,r={width:t.width,height:t.height,at:{x:0,y:0,w:t.width,h:t.height}}){let i=nt(e),{width:s,height:o}=r,a=new Uint8Array(s*o*3);for(let h=0;h<s*3;h+=3)a.set(i,h);for(let h=1;h<o;h++)a.copyWithin(h*s*3,0,s*3);let c=Hg(t,r);if(!c)return{width:s,height:o,data:a};let{part:u,box:l,dx:d,dy:f}=c;for(let h=0;h<l.h;h++)for(let p=0;p<l.w;p++){let $=((h+f)*u.width+p+d)*4,g=((l.y+h)*s+l.x+p)*3,b=u.data[$+3]/255*n;for(let y=0;y<3;y++)a[g+y]=Math.round(i[y]*(1-b)+u.data[$+y]*b)}return{width:s,height:o,data:a}}function xg(t,e){for(let n=0;n+e.length<=t.length;n++){let r=!0;for(let i=0;i<e.length&&r;i++)r=t[n+i]===e.charCodeAt(i);if(r)return n}return-1}function nn(t){if(t.length<33||!ei(t))return null;let e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=e.getUint32(16),r=e.getUint32(20);if(t[25]===4||t[25]===6)return{width:n,height:r,alpha:!0};let i=xg(t,"IDAT");return{width:n,height:r,alpha:xg(i===-1?t:t.subarray(0,i),"tRNS")!==-1}}function Fg(t,e=Rg){let{width:n,height:r,data:i}=t,s=(l)=>{for(let d=l*n*4+3,f=d+n*4;d<f;d+=4)if(i[d]>=e)return!0;return!1},o=0;while(o<r&&!s(o))o++;if(o===r)return null;let a=r-1;while(!s(a))a--;let c=n,u=-1;for(let l=o;l<=a;l++){let d=l*n*4+3;for(let f=0;f<c;f++)if(i[d+f*4]>=e){c=f;break}for(let f=n-1;f>u;f--)if(i[d+f*4]>=e){u=f;break}}return{x:c,y:o,w:u-c+1,h:a-o+1}}function In(t,e={x:0,y:0,w:t.width,h:t.height}){let n=0;for(let r=e.y;r<e.y+e.h;r++)for(let i=e.x;i<e.x+e.w;i++)if((t.data[(r*t.width+i)*4+3]??0)<Rg)n++;return Math.round(n*100/(e.w*e.h))}function Cg(t,e,n){let r=Math.min(e/t.width,n/t.height),i=Math.max(1,Math.round(t.width*r)),s=Math.max(1,Math.round(t.height*r)),o=co(t,{x:0,y:0,w:t.width,h:t.height},i,s),a=new Uint8Array(e*n*4),c=Math.floor((e-i)/2),u=Math.floor((n-s)/2);for(let l=0;l<s;l++)a.set(o.data.subarray(l*i*4,(l+1)*i*4),((u+l)*e+c)*4);return{width:e,height:n,data:a}}function KO(t){let e=Math.abs(t);if(e<1)return(7*e*e*e-12*e*e+5.333333333333333)/6;if(e<2)return(-2.3333333333333335*e*e*e+12*e*e-20*e+10.666666666666666)/6;return 0}function ed(t,e,n,r){if(n===r&&Number.isInteger(e)&&e>=0&&e+r<=t)return{first:Int32Array.from({length:r},(l,d)=>e+d),size:1,weights:new Float32Array(r).fill(1)};let i=n/r,s=Math.max(1,i),o=2*s,a=Math.min(t,Math.ceil(2*o)+2),c=new Int32Array(r),u=new Float32Array(r*a);for(let l=0;l<r;l++){let d=e+(l+0.5)*i,f=Math.floor(d-o-0.5),h=Math.max(0,Math.min(t-a,f));c[l]=h;let p=0;for(let $=f;$<=Math.ceil(d+o-0.5);$++){let g=KO(($+0.5-d)/s),b=l*a+Math.min(t-1,Math.max(0,$))-h;u[b]=(u[b]??0)+g,p+=g}for(let $=l*a;$<(l+1)*a;$++)u[$]=(u[$]??0)/p}return{first:c,size:a,weights:u}}function Lg(t,e,n,r,i,s,o){let a=ed(t,e.y,e.h,r),c=n*i,u=a.size+1,l=Array.from({length:u},()=>new Float32Array(c)),d=new Int32Array(u).fill(-1),f=new Float32Array(c),h=[],p=[];for(let $=0;$<r;$++){h.length=0,p.length=0;let g=a.first[$];for(let y=0;y<a.size;y++){let S=a.weights[$*a.size+y];if(S===0)continue;let E=g+y,I=E%u,N=l[I];if(d[I]!==E)s(E,N),d[I]=E;h.push(N),p.push(S)}let b=0;while(b<h.length){let y=h[b],S=p[b];if(h.length-b>=4){let E=h[b+1],I=h[b+2],N=h[b+3],R=p[b+1],F=p[b+2],j=p[b+3];if(b===0)for(let B=0;B<c;B++)f[B]=y[B]*S+E[B]*R+I[B]*F+N[B]*j;else for(let B=0;B<c;B++)f[B]=f[B]+(y[B]*S+E[B]*R+I[B]*F+N[B]*j);b+=4}else{if(b===0)for(let E=0;E<c;E++)f[E]=y[E]*S;else for(let E=0;E<c;E++)f[E]=f[E]+y[E]*S;b+=1}}if(h.length===0)f.fill(0);o($,f)}}function jg(t,e,n,r,i){let s=0,o=n;while(s<o){let c=s+o>>1;if(t[c]+e-1<r)s=c+1;else o=c}let a=s;o=n;while(s<o){let c=s+o>>1;if(t[c]<=i)s=c+1;else o=c}return[a,s]}function co(t,e,n,r){let i=ed(t.width,e.x,e.w,n),s=t.data,o=t.width,a=new Float32Array(o*4),c=new Uint8Array(n*r*4);return Lg(t.height,e,n,r,4,(u,l)=>{let d=u*o*4,f=o,h=-1;for(let g=0,b=0;g<o*4;g+=4,b++){let y=s[d+g+3];if(y===0){a[g]=0,a[g+1]=0,a[g+2]=0,a[g+3]=0;continue}if(b<f)f=b;h=b,a[g]=s[d+g]*y,a[g+1]=s[d+g+1]*y,a[g+2]=s[d+g+2]*y,a[g+3]=y}if(l.fill(0),h<0)return;let[p,$]=jg(i.first,i.size,n,f,h);for(let g=p;g<$;g++){let b=i.first[g]*4,y=g*i.size,S=0,E=0,I=0,N=0;for(let R=0;R<i.size;R++){let F=i.weights[y+R],j=b+R*4;S+=a[j]*F,E+=a[j+1]*F,I+=a[j+2]*F,N+=a[j+3]*F}l[g*4]=S,l[g*4+1]=E,l[g*4+2]=I,l[g*4+3]=N}},(u,l)=>{let d=u*n*4;for(let f=0;f<n;f++){let h=f*4,p=l[h+3];if(p<=0)continue;let $=l[h]/p;c[d+h]=($<0?0:$>255?255:$)+0.5,$=l[h+1]/p,c[d+h+1]=($<0?0:$>255?255:$)+0.5,$=l[h+2]/p,c[d+h+2]=($<0?0:$>255?255:$)+0.5,c[d+h+3]=(p>255?255:p)+0.5}}),{width:n,height:r,data:c}}function Gg(t,e,n,r){let i=ed(t.width,e.x,e.w,n),s=t.data,o=t.width,a=new Float32Array(n*r);return Lg(t.height,e,n,r,1,(c,u)=>{let l=c*o,d=o,f=-1;for(let $=0;$<o;$++)if(s[l+$]!==0){if($<d)d=$;f=$}if(u.fill(0),f<0)return;let[h,p]=jg(i.first,i.size,n,d,f);for(let $=h;$<p;$++){let g=l+i.first[$],b=$*i.size,y=0;for(let S=0;S<i.size;S++)y+=s[g+S]*i.weights[b+S];u[$]=y}},(c,u)=>{a.set(u,c*n)}),{width:n,height:r,data:a}}function uo(t,e){if(e<=0)return t;let n=Math.max(1,Math.ceil(e*3)),r=Array.from({length:2*n+1},(l,d)=>Math.exp(-((d-n)**2)/(2*e*e))),i=r.reduce((l,d)=>l+d,0),{width:s,height:o,data:a}=t,c=new Float32Array(s*o);for(let l=0;l<o;l++){let d=l*s;for(let f=0;f<s;f++){let h=0;for(let p=-n;p<=n;p++)h+=(a[d+Math.min(s-1,Math.max(0,f+p))]??0)*(r[p+n]??0);c[d+f]=h/i}}let u=new Float32Array(s*o);for(let l=0;l<o;l++){let d=l*s;for(let f=-n;f<=n;f++){let h=(r[f+n]??0)/i,p=Math.min(o-1,Math.max(0,l+f))*s;for(let $=0;$<s;$++)u[d+$]=(u[d+$]??0)+(c[p+$]??0)*h}}return{width:s,height:o,data:u}}function lo(t){let e=new Uint8Array(t.data.length);for(let n=0;n<e.length;n++){let r=t.data[n];e[n]=(r<0?0:r>255?255:r)+0.5}return{width:t.width,height:t.height,data:e}}function ni(t){let e=new Uint8Array(t.width*t.height);for(let n=0;n<e.length;n++)e[n]=t.data[n*4+3]??0;return{width:t.width,height:t.height,data:e}}var zO=Array.from({length:256},(t,e)=>{let n=e;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;return n>>>0});function DO(t){let e=4294967295;for(let n of t)e=(zO[(e^n)&255]??0)^e>>>8;return(e^4294967295)>>>0}function er(t,e){let n=Buffer.alloc(12+e.length);return n.writeUInt32BE(e.length,0),n.write(t,4,"latin1"),n.set(e,8),n.writeUInt32BE(DO(n.subarray(4,8+e.length)),8+e.length),n}function _g(t,e,n){let r=new Uint8Array(n*(e+1));r.set(t.subarray(0,e),1);for(let i=1;i<n;i++){let s=i*(e+1),o=i*e,a=o-e;r[s]=2;for(let c=0;c<e;c++)r[s+1+c]=t[o+c]-t[a+c]}return r}function Bg(t){return GO(t,{level:1,strategy:jO.Z_RLE})}function Wg(t,e,n){let r=Buffer.alloc(13);return r.writeUInt32BE(t.width,0),r.writeUInt32BE(t.height,4),r[8]=8,r[9]=e,Buffer.concat([Buffer.from(ts),er("IHDR",r),...n,er("IDAT",Bg(_g(t.data,t.width,t.height))),er("IEND",new Uint8Array)])}function Ug(t){let[e,n,r]=nt(t),i=new Uint8Array(768);for(let s=0;s<256;s++)i.set([e,n,r],s*3);return er("PLTE",i)}function Kg(t,e,n,r,i){let s=Buffer.alloc(13);return s.writeUInt32BE(t,0),s.writeUInt32BE(e,4),s[8]=8,s[9]=n,Buffer.concat([Buffer.from(ts),er("IHDR",s),er("IDAT",Bg(_g(i,t*r,e))),er("IEND",new Uint8Array)])}function ir(t){return Kg(t.width,t.height,2,3,t.data)}function rn(t){return Kg(t.width,t.height,6,4,t.data)}function ri(t,e){return Wg(t,Tg,[Ug(e),er("tRNS",Uint8Array.from({length:256},(n,r)=>r))])}function nd(t){return Wg(t,0,[])}function _a(t,e){if(!ei(t)||t[25]!==Tg)return;let n=Buffer.from(t.buffer,t.byteOffset,t.byteLength),r=[Buffer.from(ts)],i=ts.length;while(i+8<=n.length){let s=i+12+n.readUInt32BE(i);r.push(n.toString("latin1",i+4,i+8)==="PLTE"?Ug(e):n.subarray(i,s)),i=s}return Buffer.concat(r)}var sr=100,me=25000000,XO=536870912,es=["safe","questionable","explicit"],ii=["nudity","underwear"],od=["comic","monochrome","sketch","chibi"],Xg=["off","5","10","25","50","100"],tb=["off","720","1080","1440","1800","2560"],eb={nudity:new Set(["nude","naked","topless","bottomless","nipples","naked_towel","undressing"]),underwear:new Set(["underwear","panties","pantsu","bra","lingerie","pantyshot"])},tI={comic:new Set(["comic","4koma"]),monochrome:new Set(["monochrome","greyscale"]),sketch:new Set(["sketch","lineart","line_art"]),chibi:new Set(["chibi"])},eI=/^(?:rating|score|width|height|filetype|dimension):/,fo={safe:"s",questionable:"q",explicit:"e"},nb=8191,nI=20000,rI=5000,zg=3000,Dg=8,iI=8,sI=8000,oI=3000,rb=60000,qg=3,aI=3,cI="https://static.zerochan.net",ib="https://s1.zerochan.net",ad=`ttheme/${Tt.version} (+${Tt.homepage})`,uI=["orig","tile","thumb","cut"],sb=new Map,lI=II(process.env.TTHEME_FIND_HOSTS),dI=OI(process.env.TTHEME_FIND_CUTOUTS);VO(oI);var fI=["artist","character","copyright"];function Yg(t){try{return qO(t)}catch{return[]}}function ns(t){return t.startsWith("//")?`https:${t}`:t}function ar(t){return(/\.([a-z0-9]+)(?:\?.*)?$/i.exec(t)?.[1]??"").toLowerCase()}function mo(t){let e=t.trim();if(!e)return[];let n=JSON.parse(e);if(Array.isArray(n))return n;let r=n.posts;return Array.isArray(r)?r:[]}function hI(t){let e=t.trim(),r=(e?JSON.parse(e):{}).tags??{};return new Map(Object.entries(r).map(([i,s])=>[i,String(s)]))}function id(t,e,n){let r=ns(String(t??""));return{file:r,width:Number(e)||0,height:Number(n)||0,ext:ar(r)}}function xn(t){return String(t??"").split(/\s+/).filter(Boolean)}function sd(t){let e=typeof t==="number"?new Date(t*1000):typeof t==="string"?new Date(t):void 0;return e&&!Number.isNaN(e.getTime())?e.toISOString().slice(0,10):void 0}function ob(t,e){let n=ns(String(e.preview??""));if(!e.file||!n||!Number(t.id))return[];let r=Number(t.width??t.image_width)||0,i=Number(t.height??t.image_height)||0;return[{id:Number(t.id),width:r,height:i,file:e.file,preview:n,ext:e.ext,owner:String(e.owner??""),score:Number(t.score)||0,rating:String(t.rating??""),md5:String(e.md5??""),source:String(t.source??""),tags:xn(e.tags),named:e.named,...sd(t.created_at)?{posted:sd(t.created_at)}:{},solo:e.solo,family:Number(t.parent_id)||(t.has_children===!0?Number(t.id):0),smaller:e.versions.filter((s)=>s.file&&s.width>0&&s.height>0&&s.width*s.height<r*i)}]}function mI(t){let e=hI(t);return mo(t).flatMap((n)=>{let r=ns(String(n.file_url??"")),i=String(n.tags??""),s=(o)=>xn(i).filter((a)=>e.get(a)===o);return ob(n,{preview:n.preview_url,file:r,ext:String(n.file_ext||ar(r)).toLowerCase(),owner:n.author,md5:n.md5,tags:i,named:{artist:s("artist"),character:s("character"),copyright:s("copyright")},solo:void 0,versions:[id(n.jpeg_url,n.jpeg_width,n.jpeg_height),id(n.sample_url,n.sample_width,n.sample_height)]})})}function pI(t){return mo(t).flatMap((e)=>{let n=ns(String(e.file_url??"")),r=String(e.tag_string??""),i=e.media_asset??{};return ob(e,{preview:i.variants?.find((s)=>s.type==="360x360")?.url??e.preview_file_url,file:n,ext:String(e.file_ext||ar(n)).toLowerCase(),owner:"",md5:e.md5,tags:r,named:{artist:xn(e.tag_string_artist),character:xn(e.tag_string_character),copyright:xn(e.tag_string_copyright)},solo:r.split(/\s+/).includes("solo"),versions:(i.variants??[]).map((s)=>id(s.url,s.width,s.height)).filter((s)=>s.ext==="jpg"||s.ext==="png").sort((s,o)=>o.width*o.height-s.width*s.height)})})}function ab(t){return t.toLowerCase().replace(/\s+/g,"_")}function gI(t){return(Array.isArray(t)?t:[]).map((e)=>ab(String(e)))}function bI(t){return String(t??"").replace(/[^0-9a-z]+/gi,".").replace(/^\.+|\.+$/g,"")||"zerochan"}function wI(t){let e=t.trim(),n=e?JSON.parse(e):{};return(Array.isArray(n.items)?n.items:n.id?[n]:[]).flatMap((i)=>{let s=Number(i.id);if(!s)return[];let o=gI(i.tags),a=ns(String(i.full??""));return[{id:s,width:Number(i.width)||0,height:Number(i.height)||0,file:a,ext:ar(a),preview:`${ib}/${bI(i.tag??i.primary)}.600.${s}.jpg`,owner:"",score:0,rating:o.some((c)=>eb.nudity.has(c))?"q":"g",md5:String(i.md5??i.hash??""),source:String(i.source??""),tags:o,named:{artist:[],character:[],copyright:[]},solo:o.includes("solo"),family:0,smaller:[]}]})}var $I={mangaka:"artist",studio:"artist",character:"character",series:"copyright",game:"copyright"};function Jg(t){return t.replace(/&(?:#(\d+)|amp|quot|apos|lt|gt);/g,(e,n)=>n?String.fromCharCode(Number(n)):{"&amp;":"&","&quot;":'"',"&apos;":"'","&lt;":"<","&gt;":">"}[e]??e)}function kI(t){let e={artist:[],character:[],copyright:[]};for(let[,r,i]of t.matchAll(/<li class="([a-z]+)[^"]*"[^>]*\bdata-tag="([^"]*)"/g)){let s=$I[r],o=ab(Jg(i));if(s&&!e[s].includes(o))e[s].push(o)}let n=sd(/"datePublished":\s*"([^"]+)"/.exec(t)?.[1]);return{named:e,source:"",owner:Jg(/\buploader = \{\s*name: '([^']*)'/.exec(t)?.[1]??""),...n?{posted:n}:{}}}function yI(t){return Number(/Zerochan has ([\d,]+) /.exec(t)?.[1]?.replace(/,/g,"")??0)}function vI(t){return mo(t).flatMap((e)=>{let n=String(e.value??"");return n?[{value:n,count:Number(e.post_count)||0}]:[]})}function SI(t){return mo(t).flatMap((e)=>{let n=String(e.name??"");return n?[{value:n,count:Number(e.count)||0}]:[]})}function EI(t){return Number(/count="(\d+)"/.exec(t)?.[1]??0)}function MI(t){let n=(t.trim()?JSON.parse(t):{}).counts?.posts;return n===null?Number.NaN:Number(n)||0}function OI(t){let e=new Map;for(let n of(t??"").split(/\s+/).filter(Boolean)){let r=n.indexOf("=");if(r>0)e.set(n.slice(0,r),n.slice(r+1).split(",").filter(Boolean))}return e}function II(t){let e=new Map;for(let n of(t??"").split(/[\s,]+/).filter(Boolean)){let r=n.indexOf("="),i=n.slice(0,r);try{let s=new URL(n.slice(r+1));if(i&&s.protocol==="https:")e.set(i,s.origin)}catch{}}return e}function Ba(t,e,n,r){let i=(t??"").split(/\s+/);if(r!==void 0&&i.includes(r))return[];let s=e.filter((o)=>i.includes(o));return s.length>0?s:[...n]}function si(t){return Ba(t,es,["safe"])}function rs(t){return Ba(t,ii,ii,"none")}function Wa(t){return Ba(t,od,[],"none")}function po(t){let e=Y.map((n)=>n.name);return Ba(t,e,e)}function cd(t,e,n){return{score:Number(t)||0,size:Number(e)||0,png:n==="on"}}function go(t){return[...new Set((t??"").toLowerCase().split(/[\s,]+/).map((e)=>e.replace(/^-+/,"")).filter(Boolean))]}function ud(t,e,n){return{safe:new Set(t),questionable:new Set(e),explicit:new Set(n)}}function ld(t){let e=lI.get(t.key),n=dI.get(t.key);return{...t,origin:e??t.origin,moved:e!==void 0&&e!==t.origin,cutouts:n??t.cutouts,vouched:t.vouched&&n===void 0}}function cb(t){return t.length<2?t.join(""):t.map((e)=>`~${e}`).join(" ")}function ub(t){return t>0?[`width:>=${t}`,`height:>=${t}`]:[]}function Vg(t){let e=ld(t),n=(r)=>new URLSearchParams({api_version:"2",include_tags:"1",...r});return{...e,scored:!0,narrow:({score:r,size:i})=>[...r>0?[`score:>=${r}`]:[],...ub(i)],cutouts:cb(e.cutouts),ratings:ud([fo.safe],[fo.questionable],[fo.explicit]),rate:(r)=>{let[i]=r;if(r.length===1&&i)return`rating:${fo[i]}`;let s=es.filter((a)=>!r.includes(a)),[o]=s;return s.length===1&&o?`-rating:${fo[o]}`:""},best:"order:score",tagBudget:Number.POSITIVE_INFINITY,ors:!0,postsUrl:(r,i)=>`${e.origin}/post.json?${n({limit:String(sr),page:String(i+1),tags:r})}`,countUrl:(r)=>`${e.origin}/post.xml?${new URLSearchParams({limit:"1",tags:r})}`,postUrl:(r)=>`${e.origin}/post.json?${n({tags:`id:${r}`})}`,pageUrl:(r)=>`${e.origin}/post/show/${r}`,parse:mI,count:EI,uploadedBy:(r)=>`user:${r}`}}function xI(t){let e=ld(t),n=ud(["g"],["s","q"],["e"]);return{...e,scored:!0,narrow:({score:r,size:i,png:s})=>[...r>0?[`score:>=${r}`]:[],...ub(i),...s?["filetype:png"]:[]],cutouts:cb(e.cutouts),ratings:n,rate:(r)=>r.length===es.length?"":`rating:${r.flatMap((i)=>[...n[i]]).join(",")}`,best:"order:score",tagBudget:2,ors:!0,postsUrl:(r,i)=>`${e.origin}/posts.json?${new URLSearchParams({limit:String(sr),page:String(i+1),tags:r})}`,countUrl:(r)=>`${e.origin}/counts/posts.json?${new URLSearchParams({tags:r})}`,postUrl:(r)=>`${e.origin}/posts.json?${new URLSearchParams({limit:"1",tags:`id:${r}`})}`,pageUrl:(r)=>`${e.origin}/posts/${r}`,parse:pI,count:MI,uploadedBy:(r)=>`user:${r}`}}function rd(t){return t.split(/\s+/).filter((e)=>e&&!/^(?:order|dimension):/.test(e)).map((e)=>e.split("_").map(encodeURIComponent).join("+")).join(",")}function Zg(t){let e=t.split(/\s+/),n=e.find((r)=>r.startsWith("dimension:"))?.slice(10);return{s:e.includes("order:fav")?"fav":"id",...n?{d:n}:{}}}function NI(t){let e=ld(t);return{...e,scored:!1,narrow:({size:n})=>n>=1800?["dimension:huge"]:n>0?["dimension:large"]:[],cutouts:e.cutouts[0]??"",ratings:ud(["g"],["q"],["e"]),rate:()=>"",best:"order:fav",tagBudget:3,ors:!1,missing:404,postsUrl:(n,r)=>`${e.origin}/${rd(n)}?${new URLSearchParams({json:"",l:String(sr),p:String(r+1),...Zg(n)})}`,countUrl:(n)=>`${e.origin}/${rd(n)}?${new URLSearchParams({xml:"",l:"1"})}`,postUrl:(n)=>`${e.origin}/${n}?json=`,pageUrl:(n)=>`${e.origin}/${n}`,parse:wI,count:yI,credits:kI,counts:(n)=>rd(n).split(",").length===1&&!("d"in Zg(n)),guesses:(n)=>(n.tags.includes("transparent_background")?["png","jpg"]:["jpg","png"]).map((r)=>n.preview.replace(ib,cI).replace(/\.600\.(\d+)\.jpg$/,`.full.$1.${r}`))}}function RI(t){let e=Qg(`https://${t}`);return Y.find((n)=>Qg(n.origin)===e)}function dd(t){return t.split(/\s+/).filter((e)=>e&&!eI.test(e)).length}function Ua(t,e){let n=t.trim();if(/^\d+$/.test(n))return{site:e,id:Number(n)};let r=/^([\w.]+):(\d+)$/.exec(n);if(r){let a=Y.find((c)=>c.key===r[1]||c.name===r[1]);return a&&{site:a,id:Number(r[2])}}let i;try{i=new URL(n)}catch{return}let s=RI(i.host),o=Number(i.searchParams.get("id")??i.pathname.split("/").filter(Boolean).at(-1));return s&&o>0?{site:s,id:o}:void 0}var Y=[xI({key:"danbooru",name:"danbooru",origin:"https://shima.donmai.us",cutouts:["transparent_background"],vouched:!1,ansi:2}),Vg({key:"konachan",name:"konachan",origin:"https://konachan.net",cutouts:["transparent","vector"],vouched:!1,ansi:6}),Vg({key:"yande",name:"yande.re",origin:"https://yande.re",cutouts:["transparent_png"],vouched:!0,ansi:5}),NI({key:"zerochan",name:"zerochan",origin:"https://www.zerochan.net",cutouts:["transparent_background"],vouched:!1,ansi:3})],Zt=Y.find((t)=>t.key==="danbooru"),cr=134217728;function pe(t,e){let n=Y.indexOf(t);return(n===-1?Y.length:n)*cr+e}function Qg(t){let e;try{e=new URL(t).hostname}catch{return""}return e.split(".").slice(-2).join(".")}function oi(t,e,n=e){return e.mirror&&n===e?{site:Zt,url:e.mirror.file}:{site:t,url:n.file}}function Ka(t,e){return e.mirror?{site:Zt,url:e.mirror.preview}:{site:t,url:e.preview}}function za(t,e=ii){return t.tags.filter((n)=>e.some((r)=>eb[r].has(n)))}function lb(t,e){return t.tags.filter((n)=>e.some((r)=>tI[r].has(n)))}function Da(t,e,n=["safe"]){return n.some((r)=>t.ratings[r].has(e.rating))}function db(t,e){return t.rate(["safe"])===""?void 0:es.find((n)=>t.ratings[n].has(e.rating))}function sn(t){return[t,...t.smaller].find((e)=>e.width*e.height<=me)}function fb(t){let e=new Map;for(let[n,r]of[...t].sort(([i],[s])=>i<s?-1:1)){if(r==="")continue;e.set(r,[...e.get(r)??[],n])}return e}function ur(){return ho(process.env.XDG_CACHE_HOME??ho(ZO(),".cache"),"ttheme")}function Ge(t){return ho(ur(),t.key)}function hb(t=XO,e=ur()){let n=[],r=0;for(let i of Yg(e))for(let s of uI){let o=ho(e,i,s);for(let a of Yg(o)){let c=ho(o,a);try{let{size:u,mtimeMs:l}=JO(c);n.push({path:c,size:u,at:l}),r+=u}catch{}}}n.sort((i,s)=>i.at-s.at);for(let i of n){if(r<=t)return;try{YO(i.path,{force:!0}),r-=i.size}catch{}}}function TI(t,e){if(t!==null&&/^\s*\d+\s*$/.test(t))return Number(t)*1000;let n=t===null?Number.NaN:Date.parse(t);return Number.isNaN(n)?rb:Math.max(0,n-e)}function Nn(t){return sb.get(t.key)??0}function PI(t){for(let e=t;e instanceof Error;e=e.cause)if(e.code==="ECONNRESET")return!0;return!1}function HI(t){return(t.headers.get("server")??"").startsWith("cloudflare")&&t.headers.get("cf-mitigated")==="challenge"}function AI(t,e){let n=new URL(e,t);if(!n.search)n.search=new URL(t).search;return n.href}async function or(t,e,n,r={},i=nI){let s=e;for(let o=1,a=0;;o++){let c=Nn(t)-Date.now();if(c>0)await QO(c,void 0,{signal:n});let u;try{u=await fetch(s,{headers:{"User-Agent":ad,Referer:`${t.origin}/`,...r},redirect:"manual",signal:i?AbortSignal.any([n,AbortSignal.timeout(i)]):n})}catch(d){if(o<qg&&!n.aborted&&PI(d))continue;throw d}let l=u.headers.get("location");if(l&&u.status>=300&&u.status<400&&a<aI){await u.body?.cancel(),s=AI(s,l),a++,o--;continue}if(u.status===429&&o<qg){await u.body?.cancel();let d=TI(u.headers.get("retry-after"),Date.now());if(d>rb)throw Error(`${t.name} asks to wait ${Math.ceil(d/1000)}s`);sb.set(t.key,Math.max(Nn(t),Date.now()+d));continue}if(!u.ok)throw await u.body?.cancel(),Object.assign(Error(HI(u)?`${t.name} is behind a Cloudflare challenge`:`${t.name} answered ${u.status}`),{status:u.status});return u}}async function qa(t,e,n){try{return await(await or(t,e,n)).text()}catch(r){if(t.missing!==void 0&&r.status===t.missing)return"";throw r}}async function mb(t,e,n,r){return t.parse(await qa(t,t.postsUrl(e,n),r))}async function fd(t,e,n){return t.count(await qa(t,t.countUrl(e),n))}async function is(t,e,n){let[r]=t.parse(await qa(t,t.postUrl(e),n));return r}async function Ya(t,e,n){return t.credits?.(await qa(t,t.pageUrl(e),n))}var FI=/^https?:\/\/(?:i\.pximg\.net|i\d*\.pixiv\.net|img\d*\.pixiv\.net)\/\S*\/(\d+)(?:_p\d+)?(?:_\w+)?\.\w+(?:[?#]\S*)?$/i,CI=/^https?:\/\/(?:www\.)?pixiv\.net\/member_illust\.php\?\S*\billust_id=(\d+)/i;function bo(t){let e=FI.exec(t)?.[1]??CI.exec(t)?.[1];return e?`https://www.pixiv.net/artworks/${e}`:t}function Ja(t,e){return t.credits!==void 0&&e.named.artist.length===0}function wo(t,e){for(let n of fI){let r=e.named?.[n]??[];if(t.named[n].length===0&&r.length>0)t.named[n]=r}if(t.source||=e.source??"",t.owner||=e.owner??"",!t.posted&&e.posted)t.posted=e.posted}function LI(t){let e=new URLSearchParams({limit:String(2*sr),only:"md5,tag_string,tag_string_artist,tag_string_character,tag_string_copyright,source,file_url",tags:`md5:${t.join(",")}`});return`${Zt.origin}/posts.json?${e}`}function jI(t){return new Map(mo(t).flatMap((e)=>{let n=String(e.md5??"");return n?[[n,{tags:xn(e.tag_string),named:{artist:xn(e.tag_string_artist),character:xn(e.tag_string_character),copyright:xn(e.tag_string_copyright)},source:String(e.source??""),file:ns(String(e.file_url??""))}]]:[]}))}function Va(t,e){for(let n of t){let r=e.get(n.md5);if(!r)continue;if(n.tags=[...new Set([...n.tags,...r.tags])],wo(n,r),n.solo=r.tags.includes("solo"),r.file.includes("/original/")){if(n.mirror={file:r.file,preview:r.file.replace("/original/","/360x360/").replace(/\.[a-z0-9]+$/i,".jpg")},!n.file)n.file=r.file,n.ext=ar(r.file)}}}async function Za(t,e){let n=new Map;if(Nn(Zt)>Date.now())return n;for(let r=0;r<t.length;r+=sr){let i=await(await or(Zt,LI(t.slice(r,r+sr)),e,{},rI)).text();for(let[s,o]of jI(i))n.set(s,o)}return n}async function $o(t,e,n){if(e.file||!t.guesses)return;for(let r of t.guesses(e))try{let i=await or(t,r,n,{Range:`bytes=0-${nb}`}),s=nn(new Uint8Array(await i.arrayBuffer()));return e.file=r,e.ext=ar(r),s}catch(i){if(n.aborted||i.status!==404)throw i}throw Error(`${t.name} keeps no png or jpg of ${e.id}`)}async function pb(t,e){if(Nn(Zt)<=Date.now())try{let i=new URLSearchParams({"search[query]":t,"search[type]":"tag_query",limit:String(Dg)}),s=`${Zt.origin}/autocomplete.json?${i}`;return vI(await(await or(Zt,s,e,{},zg)).text())}catch(i){if(e.aborted)throw i}let n=Y.find((i)=>i.key==="yande"),r=new URLSearchParams({name:t,order:"count",limit:String(Dg)});return SI(await(await or(n,`${n.origin}/tag.json?${r}`,e,{},zg)).text())}function GI(t){try{return(JSON.parse(t).related_tags??[]).flatMap(({tag:n})=>n?.name?[{value:n.name,count:Number(n.post_count)||0}]:[])}catch{return[]}}async function gb(t,e){if(Nn(Zt)>Date.now())return[];let n=new URLSearchParams({"search[query]":t,"search[category]":"character",limit:String(iI)});return GI(await(await or(Zt,`${Zt.origin}/related_tag.json?${n}`,e,{},sI)).text())}function bb(t,e){return e.slice(0,t.ors?t.tagBudget:1)}async function wb(t,e,n){let r=await or(t,e,n,{Range:`bytes=0-${nb}`});return nn(new Uint8Array(await r.arrayBuffer()))}async function Qa(t,e,n,r){let i=await or(t,e,n,{},0),s=Number(i.headers.get("content-length"))||0,o=i.body?.getReader();if(!o)return new Uint8Array(await i.arrayBuffer());let a=[],c=0;for(;;){let{done:d,value:f}=await o.read();if(d)break;a.push(f),c+=f.length,r?.(c,s)}let u=new Uint8Array(c),l=0;for(let d of a)u.set(d,l),l+=d.length;return u}var qI=12,YI=/^[0-9a-f]{40}$/;function ss(){return os(ur(),"drawn")}function $b(t){return _I("sha1").update(JSON.stringify(t)).digest("hex")}function kb(t){return BI(os(ss(),t))}function yb(t){let e=os(ss(),t);try{let n=UI(e),r=n.readUInt32BE(0),i=JSON.parse(n.toString("utf8",4,4+r)),s=n.subarray(4+r,4+r+i.figure),o=n.subarray(4+r+i.figure,4+r+i.figure+i.picture);if(s.length!==i.figure||o.length!==i.picture)return;let a=new Date;return DI(e,a,a),{stem:i.stem,fill:i.fill,...i.peak?{peak:i.peak}:{},figure:s,picture:o}}catch{return}}function hd(t,e){let n=Buffer.from(JSON.stringify({stem:e.stem,fill:e.fill,...e.peak?{peak:e.peak}:{},figure:e.figure.length,picture:e.picture.length})),r=Buffer.alloc(4);r.writeUInt32BE(n.length),H(os(ss(),t),Buffer.concat([r,n,e.figure,e.picture])),JI()}function JI(){let t=WI(ss()).filter((e)=>YI.test(e)).flatMap((e)=>{try{return[{name:e,at:zI(os(ss(),e)).mtimeMs}]}catch{return[]}}).sort((e,n)=>n.at-e.at);for(let{name:e}of t.slice(qI))KI(os(ss(),e),{force:!0})}import{readdirSync as nx,readFileSync as Rb}from"node:fs";import{basename as rx,join as Tb}from"node:path";/*!
84
4
  * Copyright (c) Squirrel Chat et al., All rights reserved.
85
5
  * SPDX-License-Identifier: BSD-3-Clause
86
6
  *
@@ -106,11 +26,11 @@ ${a}
106
26
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
107
27
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
108
28
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
109
- */function dM(t,e){let n=t.slice(0,e).split(/\r?\n/);return[n.length,n.pop().length+1]}function hM(t,e,n){let r=t.split(/\r?\n/),i="",o=(Math.log10(e+1)|0)+1;for(let s=e-1;s<=e+1;s++){let a=r[s-1];if(!a)continue;if(i+=s.toString().padEnd(o," "),i+=": ",i+=a,i+=`
110
- `,s===e)i+=" ".repeat(o+n+2),i+=`^
111
- `}return i}class G extends Error{line;column;codeblock;constructor(t,e){let[n,r]=dM(e.toml,e.ptr),i=hM(e.toml,n,r);super(`Invalid TOML document: ${t}
29
+ */function VI(t,e){let n=t.slice(0,e).split(/\r?\n/);return[n.length,n.pop().length+1]}function ZI(t,e,n){let r=t.split(/\r?\n/),i="",s=(Math.log10(e+1)|0)+1;for(let o=e-1;o<=e+1;o++){let a=r[o-1];if(!a)continue;if(i+=o.toString().padEnd(s," "),i+=": ",i+=a,i+=`
30
+ `,o===e)i+=" ".repeat(s+n+2),i+=`^
31
+ `}return i}class K extends Error{line;column;codeblock;constructor(t,e){let[n,r]=VI(e.toml,e.ptr),i=ZI(e.toml,n,r);super(`Invalid TOML document: ${t}
112
32
 
113
- ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new G(t,{toml:e.s,ptr:n??e.p})}}/*!
33
+ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new K(t,{toml:e.s,ptr:n??e.p})}}/*!
114
34
  * Copyright (c) Squirrel Chat et al., All rights reserved.
115
35
  * SPDX-License-Identifier: BSD-3-Clause
116
36
  *
@@ -136,8 +56,8 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new G(
136
56
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
137
57
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
138
58
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
139
- */function oa(t){let e=t.p,n=t.s.charCodeAt(t.p++),r=n,i=n===39,o=n===t.s.charCodeAt(t.p)&&n===t.s.charCodeAt(t.p+1);if(o){if((n=t.s.charCodeAt(t.p+=2))===10)t.p++;else if(n===13&&t.s.charCodeAt(t.p+1)===10)t.p+=2}let s="",a=t.p,c=0;for(;t.p<t.s.length;t.p++)if(n=t.s.charCodeAt(t.p),o&&(n===10||n===13&&t.s.charCodeAt(t.p+1)===10))c=c&&3;else if(n<32&&n!==9||n===127)G.x("control characters are not allowed in strings",t);else if((!c||c===3)&&n===r&&(!o||t.s.charCodeAt(t.p+1)===r&&t.s.charCodeAt(t.p+2)===r)){if(o){if(t.s.charCodeAt(t.p+3)===r)t.p++;if(t.s.charCodeAt(t.p+3)===r)t.p++}if(!c){let u=t.s.slice(a,t.p);s=s?s+u:u}return t.p+=o?3:1,s}else if(!c){if(!i&&n===92)s+=t.s.slice(a,a=t.p),c=1}else if(c===1)if(n===120||n===117||n===85){let u=t.p++-1,l=0,f=n===120?2:n===117?4:8;for(let d=0;d<f;d++,t.p++){let m=t.s.charCodeAt(t.p),g=m>=48&&m<=57?m-48:m>=65&&m<=70?m-65+10:m>=97&&m<=102?m-97+10:-1;if(g<0)G.x("invalid non-hex character in unicode escape",t);l=l<<4|g}if(l<0||l>1114111||l>=55296&&l<=57343)G.x("invalid unicode escape",t,u);s+=String.fromCodePoint(l),a=t.p--,c=0}else if(o&&(n===32||n===9))c=2;else{if(n===98)s+="\b";else if(n===116)s+="\t";else if(n===110)s+=`
140
- `;else if(n===102)s+="\f";else if(n===114)s+="\r";else if(n===101)s+="\x1B";else if(n===34)s+='"';else if(n===92)s+="\\";else G.x("unrecognised escape sequence",t);a=t.p+1,c=0}else if(n!==32&&n!==9){if(c===2)G.x("invalid escape: only line-ending whitespace may be escaped",t,a);c=!i&&n===92?1:0,a=t.p}G.x("unfinished string",t,e)}/*!
59
+ */function Xa(t){let e=t.p,n=t.s.charCodeAt(t.p++),r=n,i=n===39,s=n===t.s.charCodeAt(t.p)&&n===t.s.charCodeAt(t.p+1);if(s){if((n=t.s.charCodeAt(t.p+=2))===10)t.p++;else if(n===13&&t.s.charCodeAt(t.p+1)===10)t.p+=2}let o="",a=t.p,c=0;for(;t.p<t.s.length;t.p++)if(n=t.s.charCodeAt(t.p),s&&(n===10||n===13&&t.s.charCodeAt(t.p+1)===10))c=c&&3;else if(n<32&&n!==9||n===127)K.x("control characters are not allowed in strings",t);else if((!c||c===3)&&n===r&&(!s||t.s.charCodeAt(t.p+1)===r&&t.s.charCodeAt(t.p+2)===r)){if(s){if(t.s.charCodeAt(t.p+3)===r)t.p++;if(t.s.charCodeAt(t.p+3)===r)t.p++}if(!c){let u=t.s.slice(a,t.p);o=o?o+u:u}return t.p+=s?3:1,o}else if(!c){if(!i&&n===92)o+=t.s.slice(a,a=t.p),c=1}else if(c===1)if(n===120||n===117||n===85){let u=t.p++-1,l=0,d=n===120?2:n===117?4:8;for(let f=0;f<d;f++,t.p++){let h=t.s.charCodeAt(t.p),p=h>=48&&h<=57?h-48:h>=65&&h<=70?h-65+10:h>=97&&h<=102?h-97+10:-1;if(p<0)K.x("invalid non-hex character in unicode escape",t);l=l<<4|p}if(l<0||l>1114111||l>=55296&&l<=57343)K.x("invalid unicode escape",t,u);o+=String.fromCodePoint(l),a=t.p--,c=0}else if(s&&(n===32||n===9))c=2;else{if(n===98)o+="\b";else if(n===116)o+="\t";else if(n===110)o+=`
60
+ `;else if(n===102)o+="\f";else if(n===114)o+="\r";else if(n===101)o+="\x1B";else if(n===34)o+='"';else if(n===92)o+="\\";else K.x("unrecognised escape sequence",t);a=t.p+1,c=0}else if(n!==32&&n!==9){if(c===2)K.x("invalid escape: only line-ending whitespace may be escaped",t,a);c=!i&&n===92?1:0,a=t.p}K.x("unfinished string",t,e)}/*!
141
61
  * Copyright (c) Squirrel Chat et al., All rights reserved.
142
62
  * SPDX-License-Identifier: BSD-3-Clause
143
63
  *
@@ -163,7 +83,7 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new G(
163
83
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
164
84
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
165
85
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
166
- */var mM=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;class Cn extends Date{#e=!1;#n=!1;#t=null;constructor(t,e,n){let r=!0,i=!0,o="Z",s;if(typeof t==="string")if(e)t:{if(e<3){if(+t.slice(11,13)>23){t="";break t}if(e===2)o=null,t+="Z";else if((s=t.charCodeAt(t.length-1))!==90&&s!==122)o=t.slice(t.length-6);if(n)t=t.slice(0,10)+"T"+t.slice(11)}else if(e===4)t=+t.slice(0,2)>23?"":`0000-01-01T${t}Z`;r=e!==4,i=e!==3}else{let a=t.match(mM);if(a){if(!a[1])r=!1,t=`0000-01-01T${t}`;if(i=!!a[2],i&&t[10]===" "&&(t=t.replace(" ","T")),a[2]&&+a[2]>23)t="";else if(o=a[3]||null,!o&&i)t+="Z"}else t=""}super(t);if(!isNaN(this.getTime()))this.#e=r,this.#n=i,this.#t=o}isDateTime(){return this.#e&&this.#n}isLocal(){return!this.#e||!this.#n||!this.#t}isDate(){return this.#e&&!this.#n}isTime(){return this.#n&&!this.#e}isValid(){return this.#e||this.#n}toISOString(){let t=super.toISOString();if(this.isDate())return t.slice(0,10);if(this.isTime())return t.slice(11,23);if(this.#t===null)return t.slice(0,-1);if(this.#t==="Z"||this.#t==="z")return t;let e=+this.#t.slice(1,3)*60+ +this.#t.slice(4,6);return e=this.#t[0]==="-"?e:-e,new Date(this.getTime()-e*60000).toISOString().slice(0,-1)+this.#t}static wrapAsOffsetDateTime(t,e="Z"){let n=new Cn(t);return n.#t=e,n}static wrapAsLocalDateTime(t){let e=new Cn(t);return e.#t=null,e}static wrapAsLocalDate(t){let e=new Cn(t);return e.#n=!1,e.#t=null,e}static wrapAsLocalTime(t){let e=new Cn(t);return e.#e=!1,e.#t=null,e}}/*!
86
+ */var QI=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;class lr extends Date{#e=!1;#n=!1;#t=null;constructor(t,e,n){let r=!0,i=!0,s="Z",o;if(typeof t==="string")if(e)t:{if(e<3){if(+t.slice(11,13)>23){t="";break t}if(e===2)s=null,t+="Z";else if((o=t.charCodeAt(t.length-1))!==90&&o!==122)s=t.slice(t.length-6);if(n)t=t.slice(0,10)+"T"+t.slice(11)}else if(e===4)t=+t.slice(0,2)>23?"":`0000-01-01T${t}Z`;r=e!==4,i=e!==3}else{let a=t.match(QI);if(a){if(!a[1])r=!1,t=`0000-01-01T${t}`;if(i=!!a[2],i&&t[10]===" "&&(t=t.replace(" ","T")),a[2]&&+a[2]>23)t="";else if(s=a[3]||null,!s&&i)t+="Z"}else t=""}super(t);if(!isNaN(this.getTime()))this.#e=r,this.#n=i,this.#t=s}isDateTime(){return this.#e&&this.#n}isLocal(){return!this.#e||!this.#n||!this.#t}isDate(){return this.#e&&!this.#n}isTime(){return this.#n&&!this.#e}isValid(){return this.#e||this.#n}toISOString(){let t=super.toISOString();if(this.isDate())return t.slice(0,10);if(this.isTime())return t.slice(11,23);if(this.#t===null)return t.slice(0,-1);if(this.#t==="Z"||this.#t==="z")return t;let e=+this.#t.slice(1,3)*60+ +this.#t.slice(4,6);return e=this.#t[0]==="-"?e:-e,new Date(this.getTime()-e*60000).toISOString().slice(0,-1)+this.#t}static wrapAsOffsetDateTime(t,e="Z"){let n=new lr(t);return n.#t=e,n}static wrapAsLocalDateTime(t){let e=new lr(t);return e.#t=null,e}static wrapAsLocalDate(t){let e=new lr(t);return e.#n=!1,e.#t=null,e}static wrapAsLocalTime(t){let e=new lr(t);return e.#e=!1,e.#t=null,e}}/*!
167
87
  * Copyright (c) Squirrel Chat et al., All rights reserved.
168
88
  * SPDX-License-Identifier: BSD-3-Clause
169
89
  *
@@ -189,7 +109,7 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new G(
189
109
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
190
110
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
191
111
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
192
- */function Zt(t,e=10){return e===16?t>47&&t<58||t>64&&t<71||t>96&&t<103:t>47&&t<48+e}function Yu(t,e){return t===32||t===9||t===10||t===13||e&&(t===e||t===44)||t===35}function po(t,e){let n=t.p,r=t.s.charCodeAt(t.p);if(r===91||r===123){t.d--||G.x("document contains excessively nested structures. aborting.",t);let i=r===91?jg(t):Cg(t);return t.d++,i}if(r===34||r===39)return oa(t);if(r===116){if(t.s.charCodeAt(++t.p)!==114||t.s.charCodeAt(++t.p)!==117||t.s.charCodeAt(++t.p)!==101)G.x("invalid value",t,n);return t.p++,!0}if(r===102){if(t.s.charCodeAt(++t.p)!==97||t.s.charCodeAt(++t.p)!==108||t.s.charCodeAt(++t.p)!==115||t.s.charCodeAt(++t.p)!==101)G.x("invalid value",t,n);return t.p++,!1}if(r===43||r===45)return sa(t,t.p,t.s.charCodeAt(++t.p),44-r,e);if(t.s.charCodeAt(t.p+4)===45&&t.s.charCodeAt(t.p+7)===45)return gM(t,r,e);if(t.s.charCodeAt(t.p+2)===58)return pM(t,r,e);return sa(t,t.p,r,0,e)}function sa(t,e,n,r,i){let o=n,s=0,a=!1;if(o===105){if(t.s.charCodeAt(++t.p)!==110||t.s.charCodeAt(++t.p)!==102)G.x("invalid value",t,e);return t.p++,(r||1)/0}if(o===110){if(t.s.charCodeAt(++t.p)!==97||t.s.charCodeAt(++t.p)!==110)G.x("invalid value",t,e);return t.p++,NaN}if(o===48){if(++t.p>=t.s.length||Yu(o=t.s.charCodeAt(t.p),i))return t.bi===!0?0n:0;if(!r){if(o===120)return Ju(t,e,16,i);else if(o===98)return Ju(t,e,2,i);else if(o===111)return Ju(t,e,8,i)}if(o===46)s=2;else if(o===101||o===69)s=4;else G.x("illegal leading zero",t,e)}else if(!Zt(o))G.x("invalid value",t,e);while(++t.p<t.s.length&&(o=t.s.charCodeAt(t.p),!Yu(o,i))){if(!s)s=1;if(o===95){if(!(s&1))G.x("illegal underscore",t);s+=11,a=!0}else if(s===1&&o===46)s=2;else if((s===1||s===3)&&(o===101||o===69))s=4;else if(s===4&&(o===43||o===45));else if(!Zt(o))G.x("illegal character in numeric literal",t);else if(s>9)s-=11;else if(!(s&1))s++}if(!s){let u=(n-48)*(r||1);return t.bi===!0?BigInt(u):u}if(!(s&1))G.x("unfinished numeric value",t,e);let c=t.s.slice(e,t.p);if(a)c=c.replaceAll("_","");return s>1?parseFloat(c):Ag(t,c,10,e)}function Ju(t,e,n,r){let i,o=1;while(++t.p<t.s.length&&(i=t.s.charCodeAt(t.p),!Yu(i,r)))if(i===95){if(o&1)G.x("illegal underscore",t);o=3}else if(!Zt(i,n))G.x("illegal character in numeric literal",t);else if(o&1)o--;if(o&1)G.x("unfinished numeric value",t);let s=t.s.slice(e+2,t.p);if(o)s=s.replaceAll("_","");return Ag(t,s,n,e)}function Ag(t,e,n,r){if(t.bi!==!0)t:{let i=parseInt(e,n);if(!Number.isSafeInteger(i)){if(t.bi)break t;G.x("integer value cannot be represented losslessly",t,r)}return i}return n===10?BigInt(e):BigInt((n===2?"0b":n===8?"0o":"0x")+e)}function gM(t,e,n){let r=t.p++,i;if(!Zt(e)||!Zt(t.s.charCodeAt(t.p++))||!Zt(t.s.charCodeAt(t.p++))||!Zt(t.s.charCodeAt(t.p++)))return sa(t,t.p=r,e,0,n);if(t.p+=5,!Zt(t.s.charCodeAt(t.p++)))G.x("invalid date-time: date part is malformed",t,r);if(t.p>=t.s.length||((e=t.s.charCodeAt(t.p))!==32||(i=!0,!Zt(t.s.charCodeAt(t.p+1))))&&e!==84&&e!==116){let s=t.s.slice(r,t.p);return go(t,s,3,!1,r)}if(t.s.charCodeAt(t.p+=3)!==58)G.x("invalid date-time: time part is malformed",t,r);if(t.s.charCodeAt(t.p+=3)===58)t.p+=3;if(t.s.charCodeAt(t.p)===46)while(Zt(t.s.charCodeAt(++t.p)));if(e=t.s.charCodeAt(t.p)){if(e===90||e===122){let s=t.s.slice(r,++t.p);return go(t,s,1,i,r,"[+00:00]")}if(e===43||e===45){let s=t.s.slice(r,t.p+=6);return go(t,s,1,i,r,!t.ld&&"["+t.s.slice(t.p-6,t.p)+"]")}}let o=t.s.slice(r,t.p);return go(t,o,2,i,r)}function pM(t,e,n){let r=t.p;if(!Zt(e)||!Zt(t.s.charCodeAt(++t.p)))return sa(t,--t.p,e,0,n);if(t.s.charCodeAt(t.p+=4)===58)t.p+=3;if(t.s.charCodeAt(t.p)===46)while(Zt(t.s.charCodeAt(++t.p)));let i=t.s.slice(r,t.p);return go(t,i,4,!1,r)}function go(t,e,n,r,i,o){if(t.ld){let s=new Cn(e,n,r);if(!s.isValid())G.x("invalid date",t,i);return s}try{if(o)e+=o;switch(n){case 1:return Temporal.ZonedDateTime.from(e);case 2:return Temporal.PlainDateTime.from(e);case 3:return Temporal.PlainDate.from(e);case 4:return Temporal.PlainTime.from(e)}}catch(s){G.x(s instanceof Error?s.message:""+s,t,i)}}/*!
112
+ */function ge(t,e=10){return e===16?t>47&&t<58||t>64&&t<71||t>96&&t<103:t>47&&t<48+e}function pd(t,e){return t===32||t===9||t===10||t===13||e&&(t===e||t===44)||t===35}function yo(t,e){let n=t.p,r=t.s.charCodeAt(t.p);if(r===91||r===123){t.d--||K.x("document contains excessively nested structures. aborting.",t);let i=r===91?Eb(t):Sb(t);return t.d++,i}if(r===34||r===39)return Xa(t);if(r===116){if(t.s.charCodeAt(++t.p)!==114||t.s.charCodeAt(++t.p)!==117||t.s.charCodeAt(++t.p)!==101)K.x("invalid value",t,n);return t.p++,!0}if(r===102){if(t.s.charCodeAt(++t.p)!==97||t.s.charCodeAt(++t.p)!==108||t.s.charCodeAt(++t.p)!==115||t.s.charCodeAt(++t.p)!==101)K.x("invalid value",t,n);return t.p++,!1}if(r===43||r===45)return tc(t,t.p,t.s.charCodeAt(++t.p),44-r,e);if(t.s.charCodeAt(t.p+4)===45&&t.s.charCodeAt(t.p+7)===45)return XI(t,r,e);if(t.s.charCodeAt(t.p+2)===58)return tx(t,r,e);return tc(t,t.p,r,0,e)}function tc(t,e,n,r,i){let s=n,o=0,a=!1;if(s===105){if(t.s.charCodeAt(++t.p)!==110||t.s.charCodeAt(++t.p)!==102)K.x("invalid value",t,e);return t.p++,(r||1)/0}if(s===110){if(t.s.charCodeAt(++t.p)!==97||t.s.charCodeAt(++t.p)!==110)K.x("invalid value",t,e);return t.p++,NaN}if(s===48){if(++t.p>=t.s.length||pd(s=t.s.charCodeAt(t.p),i))return t.bi===!0?0n:0;if(!r){if(s===120)return md(t,e,16,i);else if(s===98)return md(t,e,2,i);else if(s===111)return md(t,e,8,i)}if(s===46)o=2;else if(s===101||s===69)o=4;else K.x("illegal leading zero",t,e)}else if(!ge(s))K.x("invalid value",t,e);while(++t.p<t.s.length&&(s=t.s.charCodeAt(t.p),!pd(s,i))){if(!o)o=1;if(s===95){if(!(o&1))K.x("illegal underscore",t);o+=11,a=!0}else if(o===1&&s===46)o=2;else if((o===1||o===3)&&(s===101||s===69))o=4;else if(o===4&&(s===43||s===45));else if(!ge(s))K.x("illegal character in numeric literal",t);else if(o>9)o-=11;else if(!(o&1))o++}if(!o){let u=(n-48)*(r||1);return t.bi===!0?BigInt(u):u}if(!(o&1))K.x("unfinished numeric value",t,e);let c=t.s.slice(e,t.p);if(a)c=c.replaceAll("_","");return o>1?parseFloat(c):vb(t,c,10,e)}function md(t,e,n,r){let i,s=1;while(++t.p<t.s.length&&(i=t.s.charCodeAt(t.p),!pd(i,r)))if(i===95){if(s&1)K.x("illegal underscore",t);s=3}else if(!ge(i,n))K.x("illegal character in numeric literal",t);else if(s&1)s--;if(s&1)K.x("unfinished numeric value",t);let o=t.s.slice(e+2,t.p);if(s)o=o.replaceAll("_","");return vb(t,o,n,e)}function vb(t,e,n,r){if(t.bi!==!0)t:{let i=parseInt(e,n);if(!Number.isSafeInteger(i)){if(t.bi)break t;K.x("integer value cannot be represented losslessly",t,r)}return i}return n===10?BigInt(e):BigInt((n===2?"0b":n===8?"0o":"0x")+e)}function XI(t,e,n){let r=t.p++,i;if(!ge(e)||!ge(t.s.charCodeAt(t.p++))||!ge(t.s.charCodeAt(t.p++))||!ge(t.s.charCodeAt(t.p++)))return tc(t,t.p=r,e,0,n);if(t.p+=5,!ge(t.s.charCodeAt(t.p++)))K.x("invalid date-time: date part is malformed",t,r);if(t.p>=t.s.length||((e=t.s.charCodeAt(t.p))!==32||(i=!0,!ge(t.s.charCodeAt(t.p+1))))&&e!==84&&e!==116){let o=t.s.slice(r,t.p);return ko(t,o,3,!1,r)}if(t.s.charCodeAt(t.p+=3)!==58)K.x("invalid date-time: time part is malformed",t,r);if(t.s.charCodeAt(t.p+=3)===58)t.p+=3;if(t.s.charCodeAt(t.p)===46)while(ge(t.s.charCodeAt(++t.p)));if(e=t.s.charCodeAt(t.p)){if(e===90||e===122){let o=t.s.slice(r,++t.p);return ko(t,o,1,i,r,"[+00:00]")}if(e===43||e===45){let o=t.s.slice(r,t.p+=6);return ko(t,o,1,i,r,!t.ld&&"["+t.s.slice(t.p-6,t.p)+"]")}}let s=t.s.slice(r,t.p);return ko(t,s,2,i,r)}function tx(t,e,n){let r=t.p;if(!ge(e)||!ge(t.s.charCodeAt(++t.p)))return tc(t,--t.p,e,0,n);if(t.s.charCodeAt(t.p+=4)===58)t.p+=3;if(t.s.charCodeAt(t.p)===46)while(ge(t.s.charCodeAt(++t.p)));let i=t.s.slice(r,t.p);return ko(t,i,4,!1,r)}function ko(t,e,n,r,i,s){if(t.ld){let o=new lr(e,n,r);if(!o.isValid())K.x("invalid date",t,i);return o}try{if(s)e+=s;switch(n){case 1:return Temporal.ZonedDateTime.from(e);case 2:return Temporal.PlainDateTime.from(e);case 3:return Temporal.PlainDate.from(e);case 4:return Temporal.PlainTime.from(e)}}catch(o){K.x(o instanceof Error?o.message:""+o,t,i)}}/*!
193
113
  * Copyright (c) Squirrel Chat et al., All rights reserved.
194
114
  * SPDX-License-Identifier: BSD-3-Clause
195
115
  *
@@ -215,7 +135,7 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new G(
215
135
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
216
136
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
217
137
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
218
- */function bM(t){for(;t.p<t.s.length;t.p++){let e=t.s.charCodeAt(t.p);if(e===10)break;if(e===13&&t.s.charCodeAt(t.p+1)===10){t.p++;break}if(e<32&&e!==9||e===127)G.x("control characters are not allowed in comments",t)}}function $e(t,e,n){let r;while(t.p<t.s.length){while(t.p<t.s.length&&((r=t.s.charCodeAt(t.p))===32||r===9||!e&&(r===10||r===13&&t.s.charCodeAt(t.p+1)===10)))t.p++;if(n||r!==35)break;bM(t)}}/*!
138
+ */function ex(t){for(;t.p<t.s.length;t.p++){let e=t.s.charCodeAt(t.p);if(e===10)break;if(e===13&&t.s.charCodeAt(t.p+1)===10){t.p++;break}if(e<32&&e!==9||e===127)K.x("control characters are not allowed in comments",t)}}function _e(t,e,n){let r;while(t.p<t.s.length){while(t.p<t.s.length&&((r=t.s.charCodeAt(t.p))===32||r===9||!e&&(r===10||r===13&&t.s.charCodeAt(t.p+1)===10)))t.p++;if(n||r!==35)break;ex(t)}}/*!
219
139
  * Copyright (c) Squirrel Chat et al., All rights reserved.
220
140
  * SPDX-License-Identifier: BSD-3-Clause
221
141
  *
@@ -241,7 +161,7 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new G(
241
161
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
242
162
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
243
163
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
244
- */function aa(t,e=61){let n,r=0,i=[],o,s=t.s.charCodeAt(n=t.p);do if(s===e){if(!r)G.x("unexpected end of key",t);if(r===1)i.push(t.s.slice(o,t.p));return t.p++,i}else if(s===46){if(!r)G.x("illegal empty bare key",t);if(r===1)i.push(t.s.slice(o,t.p));r=0}else if(!r&&(s===34||s===39)){if(s===t.s.charCodeAt(t.p+1)&&s===t.s.charCodeAt(t.p+2))G.x("illegal quoted key: multiline strings are not allowed",t);i.push(oa(t)),r=2,t.p--}else if(s===32||s===9){if(r===1)i.push(t.s.slice(o,t.p)),r=2}else if(r===2||s<48&&s!==45||s>57&&s<65||s>90&&s<97&&s!==95||s>122)G.x("illegal character in key",t);else if(!r)r=1,o=t.p;while(s=t.s.charCodeAt(++t.p));G.x("incomplete key-value: cannot find end of key",t,n)}function Cg(t){let e=t.p++,n=Object.create(null),r=new Set,i;while(t.p<t.s.length){if($e(t),(i=t.s.charCodeAt(t.p))===125)return t.p++,n;let o,s=n,a=!1,c=t.p,u=aa(t);for(let f=0;f<u.length;f++){if(f)s=a?s[o]:s[o]=Object.create(null);if(o=u[f],(a=Object.hasOwn(s,o))&&(typeof s[o]!=="object"||r.has(s[o])))G.x("trying to redefine an already defined value",t,c);let d=o==="__proto__";if(t.uk&&(d||o==="constructor")){s=t.uk!==1&&G.x("document contains an unsafe property",t,c);break}if(!a&&d)Object.defineProperty(s,o,{enumerable:!0,configurable:!0,writable:!0})}if(a)G.x("trying to redefine an already defined value",t,c);$e(t,!0,!0);let l=po(t,125);if(s&&typeof(s[o]=l)==="object")r.add(l);if($e(t),(i=t.s.charCodeAt(t.p++))===125)return n;if(i!==44)G.x("expected comma or end of structure",t,t.p-1)}G.x("unfinished table",t,e)}function jg(t){let e=t.p++,n=[],r;while(t.p<t.s.length){if($e(t),(r=t.s.charCodeAt(t.p))===93)return t.p++,n;if(n.push(po(t,93)),$e(t),(r=t.s.charCodeAt(t.p++))===93)return n;if(r!==44)G.x("expected comma or end of structure",t,t.p-1)}G.x("unfinished array",t,e)}/*!
164
+ */function ec(t,e=61){let n,r=0,i=[],s,o=t.s.charCodeAt(n=t.p);do if(o===e){if(!r)K.x("unexpected end of key",t);if(r===1)i.push(t.s.slice(s,t.p));return t.p++,i}else if(o===46){if(!r)K.x("illegal empty bare key",t);if(r===1)i.push(t.s.slice(s,t.p));r=0}else if(!r&&(o===34||o===39)){if(o===t.s.charCodeAt(t.p+1)&&o===t.s.charCodeAt(t.p+2))K.x("illegal quoted key: multiline strings are not allowed",t);i.push(Xa(t)),r=2,t.p--}else if(o===32||o===9){if(r===1)i.push(t.s.slice(s,t.p)),r=2}else if(r===2||o<48&&o!==45||o>57&&o<65||o>90&&o<97&&o!==95||o>122)K.x("illegal character in key",t);else if(!r)r=1,s=t.p;while(o=t.s.charCodeAt(++t.p));K.x("incomplete key-value: cannot find end of key",t,n)}function Sb(t){let e=t.p++,n=Object.create(null),r=new Set,i;while(t.p<t.s.length){if(_e(t),(i=t.s.charCodeAt(t.p))===125)return t.p++,n;let s,o=n,a=!1,c=t.p,u=ec(t);for(let d=0;d<u.length;d++){if(d)o=a?o[s]:o[s]=Object.create(null);if(s=u[d],(a=Object.hasOwn(o,s))&&(typeof o[s]!=="object"||r.has(o[s])))K.x("trying to redefine an already defined value",t,c);let f=s==="__proto__";if(t.uk&&(f||s==="constructor")){o=t.uk!==1&&K.x("document contains an unsafe property",t,c);break}if(!a&&f)Object.defineProperty(o,s,{enumerable:!0,configurable:!0,writable:!0})}if(a)K.x("trying to redefine an already defined value",t,c);_e(t,!0,!0);let l=yo(t,125);if(o&&typeof(o[s]=l)==="object")r.add(l);if(_e(t),(i=t.s.charCodeAt(t.p++))===125)return n;if(i!==44)K.x("expected comma or end of structure",t,t.p-1)}K.x("unfinished table",t,e)}function Eb(t){let e=t.p++,n=[],r;while(t.p<t.s.length){if(_e(t),(r=t.s.charCodeAt(t.p))===93)return t.p++,n;if(n.push(yo(t,93)),_e(t),(r=t.s.charCodeAt(t.p++))===93)return n;if(r!==44)K.x("expected comma or end of structure",t,t.p-1)}K.x("unfinished array",t,e)}/*!
245
165
  * Copyright (c) Squirrel Chat et al., All rights reserved.
246
166
  * SPDX-License-Identifier: BSD-3-Clause
247
167
  *
@@ -267,7 +187,7 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new G(
267
187
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
268
188
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
269
189
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
270
- */function Gg(t,e,n,r,i){let o=n,s=r,a,c=!1,u;for(let l=0;l<e.length;l++){if(l){if(o=c?o[a]:o[a]=Object.create(null),s=(u=s[a]).c,i===0&&(u.t===1||u.t===2))return null;if(u.t===2){let f=o.length-1;o=o[f],s=s[f].c}}if(a=e[l],(c=Object.hasOwn(o,a))&&s[a]?.t===0&&s[a]?.d)return null;if(!c){let f=a==="__proto__";if(t.uk&&(f||a==="constructor"))return!1;if(f)Object.defineProperty(o,a,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(s,a,{enumerable:!0,configurable:!0,writable:!0});s[a]={t:l<e.length-1&&i===2?3:i,d:!1,i:0,c:Object.create(null)}}}if(u=s[a],u.t!==i&&!(i===1&&u.t===3))return null;if(i===2){if(!u.d)u.d=!0,o[a]=[];o[a].push(o=Object.create(null)),u.c[u.i++]=u={t:1,d:!1,i:0,c:Object.create(null)}}if(u.d)return null;if(u.d=!0,i===1)o=c?o[a]:o[a]=Object.create(null);else if(i===0&&c)return null;return[a,o,u.c]}function Ug(t,e,n){if(e===null||t.uk===2)G.x(e===null?"trying to redefine an already defined table or value":"document contains an unsafe property",t,n)}function Du(t,e={}){let n={s:t,p:0,d:e.maxDepth??1000,bi:e.integersAsBigInt??!1,ld:e.useLegacyDate??!0,uk:e.unsafeKeyBehaviour==="throw"?2:e.unsafeKeyBehaviour==="drop"?1:0},r=Object.create(null),i=Object.create(null),o,s=!1,a=r,c=i;if(t.charCodeAt(0)===65279)n.p++;$e(n);while(n.p<t.length){if(t.charCodeAt(n.p)===91){let u=t.charCodeAt(++n.p)===91;o=n.p+=+u,s=!1;let l=aa(n,93);if(u){if(t.charCodeAt(n.p)!==93)G.x("expected end of table array declaration",n);n.p++}let f=Gg(n,l,r,i,u?2:1);if(!f)Ug(n,f,o),s=!0;else c=f[2],a=f[1]}else{o=n.p;let u=aa(n),l=Gg(n,u,a,c,0);if(!l&&!s)Ug(n,l,o);$e(n,!0,!0);let f=po(n,void 0);if(l&&!s)l[1][l[0]]=f}if($e(n,!0),n.p<t.length&&(o=t.charCodeAt(n.p))!==10&&(o!==13||t.charCodeAt(n.p+1)!==10))G.x("each key-value declaration must be followed by an end-of-line",n);$e(n)}return r}/*!
190
+ */function Mb(t,e,n,r,i){let s=n,o=r,a,c=!1,u;for(let l=0;l<e.length;l++){if(l){if(s=c?s[a]:s[a]=Object.create(null),o=(u=o[a]).c,i===0&&(u.t===1||u.t===2))return null;if(u.t===2){let d=s.length-1;s=s[d],o=o[d].c}}if(a=e[l],(c=Object.hasOwn(s,a))&&o[a]?.t===0&&o[a]?.d)return null;if(!c){let d=a==="__proto__";if(t.uk&&(d||a==="constructor"))return!1;if(d)Object.defineProperty(s,a,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(o,a,{enumerable:!0,configurable:!0,writable:!0});o[a]={t:l<e.length-1&&i===2?3:i,d:!1,i:0,c:Object.create(null)}}}if(u=o[a],u.t!==i&&!(i===1&&u.t===3))return null;if(i===2){if(!u.d)u.d=!0,s[a]=[];s[a].push(s=Object.create(null)),u.c[u.i++]=u={t:1,d:!1,i:0,c:Object.create(null)}}if(u.d)return null;if(u.d=!0,i===1)s=c?s[a]:s[a]=Object.create(null);else if(i===0&&c)return null;return[a,s,u.c]}function Ob(t,e,n){if(e===null||t.uk===2)K.x(e===null?"trying to redefine an already defined table or value":"document contains an unsafe property",t,n)}function gd(t,e={}){let n={s:t,p:0,d:e.maxDepth??1000,bi:e.integersAsBigInt??!1,ld:e.useLegacyDate??!0,uk:e.unsafeKeyBehaviour==="throw"?2:e.unsafeKeyBehaviour==="drop"?1:0},r=Object.create(null),i=Object.create(null),s,o=!1,a=r,c=i;if(t.charCodeAt(0)===65279)n.p++;_e(n);while(n.p<t.length){if(t.charCodeAt(n.p)===91){let u=t.charCodeAt(++n.p)===91;s=n.p+=+u,o=!1;let l=ec(n,93);if(u){if(t.charCodeAt(n.p)!==93)K.x("expected end of table array declaration",n);n.p++}let d=Mb(n,l,r,i,u?2:1);if(!d)Ob(n,d,s),o=!0;else c=d[2],a=d[1]}else{s=n.p;let u=ec(n),l=Mb(n,u,a,c,0);if(!l&&!o)Ob(n,l,s);_e(n,!0,!0);let d=yo(n,void 0);if(l&&!o)l[1][l[0]]=d}if(_e(n,!0),n.p<t.length&&(s=t.charCodeAt(n.p))!==10&&(s!==13||t.charCodeAt(n.p+1)!==10))K.x("each key-value declaration must be followed by an end-of-line",n);_e(n)}return r}/*!
271
191
  * Copyright (c) Squirrel Chat et al., All rights reserved.
272
192
  * SPDX-License-Identifier: BSD-3-Clause
273
193
  *
@@ -293,7 +213,7 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new G(
293
213
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
294
214
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
295
215
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
296
- */var dx=!!"".isWellFormed;/*!
216
+ */var T3=!!"".isWellFormed;/*!
297
217
  * Copyright (c) Squirrel Chat et al., All rights reserved.
298
218
  * SPDX-License-Identifier: BSD-3-Clause
299
219
  *
@@ -319,93 +239,369 @@ ${i}`,e);this.line=n,this.column=r,this.codeblock=i}static x(t,e,n){throw new G(
319
239
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
320
240
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
321
241
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
322
- */var Qt=["top-left","top-center","top-right","center-left","center","center-right","bottom-left","bottom-center","bottom-right"],bo="Original",kM=1e6,Ue="_groups.toml",Wg=3,_g=8,Vu="[a-z0-9]+(?:-[a-z0-9]+)*",yM=new RegExp(`^(?:(${Vu})@(${Vu})/)?(${Vu})$`),qg=["background","foreground","cursor","selection"];function Q(t,e){throw Error(`${t}: ${e}`)}function Mr(t,e,n){if(typeof n!=="string"||!Bt(n))Q(t,`${e} must be "#rrggbb" (lowercase), got ${JSON.stringify(n)}`);return n}function $o(t,e,n){if(typeof n!=="string"||n.length===0)Q(t,`${e} must be a non-empty string`);return n}function We(t){return t.replace("@","--").replace("/","--")}function x(t){return`ttheme-${We(t)}`}function rt(t){let e=t.indexOf("/");return e<0?void 0:t.slice(0,e)}function mi(t){return t.slice(t.indexOf("/")+1)}function ke(t){let e=yM.exec(t);if(!e)return"takes lowercase letters, digits and single hyphens, as <palette> or <owner>@<market>/<palette>";if((e[1]?.length??0)>39)return"has an owner longer than a GitHub handle can be";return(e[2]?.length??0)>40||(e[3]?.length??0)>40?"is longer than 40 characters":void 0}function ko(t){if(/[\p{Cc}"$`\\]/u.test(t))return"holds a control character, a quote, $, ` or \\";return t.length>80?"is longer than 80 characters":void 0}function wo(t,e,n){let r=$o(t,e,n),i=ko(r);if(i)Q(t,`${e} ${JSON.stringify(r)} ${i}`);return r}function Bg(t,e,n){let r=$o(t,e,n),i=ke(r);if(i)Q(t,`${e} "${r}" ${i}`);return r}function hi(t){return t&&typeof t==="object"?t:{}}function vM(t,e,n){if(e===void 0)return[n.cursor,n.selectionBackground,n.background];let r=Array.isArray(e)?e:[e];if(r.length===0)Q(t,"ghostty.icon_screen must not be empty");return r.map((i,o)=>Mr(t,`ghostty.icon_screen[${o}]`,i))}function EM(t,e,n){let r=hi(e);return{iconGhost:r.icon_ghost===void 0?n.cursor:Mr(t,"ghostty.icon_ghost",r.icon_ghost),iconScreen:vM(t,r.icon_screen,n)}}function SM(t){return new Map([...qg.map((e)=>[e,t[e]]),...t.ansi.map((e,n)=>[`ansi${n}`,e])])}function MM(t,e,n){if(!Array.isArray(e)||e.length!==Wg)Q(t,`meta.signature must name exactly ${Wg} palette slots`);let r=SM(n),i=[],o=[];for(let[s,a]of e.entries()){let c=`meta.signature[${s}]`,u=$o(t,c,a),l=r.get(u);if(l===void 0)Q(t,`${c} ${JSON.stringify(a)} is not a palette slot — use ${qg.join(", ")} or ansi0-ansi15`);i.push(u),o.push(l)}if(new Set(o).size!==o.length)Q(t,"meta.signature slots must resolve to three different colors");return{names:i,colors:o}}function IM(t,e,n){if(e===void 0)return;if(!n)Q(t,"meta.booru_sites renames meta.booru per site, so it needs meta.booru");if(!e||typeof e!=="object"||Array.isArray(e))Q(t,'meta.booru_sites must be a table of site = "tag" or site = ["tag", ...]');let r={};for(let[i,o]of Object.entries(e)){let s=q.find((c)=>c.key===i);if(!s)Q(t,`meta.booru_sites.${i} is not a find site — use ${q.map((c)=>c.key).join(", ")}`);let a=typeof o==="string"?[o]:Array.isArray(o)?o:void 0;if(!a||a.some((c)=>typeof c!=="string"||c===""||/\s/.test(c)))Q(t,`meta.booru_sites.${i} must be one tag or a list of tags, got ${JSON.stringify(o)}`);if(a.length>1&&!s.ors)Q(t,`meta.booru_sites.${i} takes one tag — ${s.name} does not OR tags`);if(a.length>s.tagBudget)Q(t,`meta.booru_sites.${i} takes ${s.tagBudget} tags at most — ${s.name} searches that many at a time`);r[i]=a}return r}function OM(t,e){if(e===void 0)return;if(!Array.isArray(e)||e.length===0||e.length>_g)Q(t,`[[picture]] holds 1 to ${_g} pictures`);return e.map((n,r)=>{let i=hi(n),o=`picture[${r}]`,s=q.find((l)=>l.key===i.site);if(!s)Q(t,`${o}.site must be one of ${q.map((l)=>l.key).join(", ")}`);if(typeof i.id!=="number"||!Number.isSafeInteger(i.id)||i.id<=0)Q(t,`${o}.id must be the post's number on ${s.name}`);let{size:a,position:c,opacity:u}=i;if(a!==void 0&&a!=="fill"&&!(Number.isInteger(a)&&Number(a)>=20&&Number(a)<=999))Q(t,`${o}.size must be "fill" or a percentage from 20 to 999`);if(c!==void 0&&!Qt.includes(c))Q(t,`${o}.position must be one of ${Qt.join(", ")}`);if(u!==void 0&&!(typeof u==="number"&&u>=0&&u<=1))Q(t,`${o}.opacity must be a number from 0 to 1`);return{site:s.key,id:i.id,...a!==void 0?{size:a}:{},...c!==void 0?{position:c}:{},...u!==void 0?{opacity:u}:{}}})}function Jg(t,e){try{return Du(e)}catch(n){Q(t,`is not valid TOML — ${(n instanceof Error?n.message:String(n)).split(`
323
- `)[0]}`)}}function NM(t){let n=Jg(Ue,zg(Kg(t,Ue),"utf8")).group;if(!Array.isArray(n)||n.length===0)Q(Ue,"needs at least one [[group]] table");return n.map((r)=>{let i=hi(r);return{name:wo(Ue,"group.name",i.name),native:i.native===void 0?void 0:wo(Ue,"group.native",i.native),lead:$o(Ue,"group.lead",i.lead)}})}function RM(t,e){if(!Array.isArray(e)||e.length===0)Q(t,'meta.native_names must be a list of names, like ["後藤ひとり"]');return e.map((n,r)=>{let i=wo(t,`meta.native_names[${r}]`,n);if(i.includes("|"))Q(t,`meta.native_names[${r}] ${JSON.stringify(i)} contains |`);return i})}function Zu(t,e,n){let r=Jg(t,e),i=hi(r.meta),o=hi(r.colors),s=hi(r.contrast),a=o.ansi;if(!Array.isArray(a)||a.length!==16)Q(t,`colors.ansi must hold exactly 16 colors, got ${Array.isArray(a)?a.length:typeof a}`);let c=Bg(t,"meta.name",i.name);if(c!==n.name)Q(t,`meta.name "${c}" does not match its file — it lives at ${n.name}`);let u=n.open===!0;for(let W of["order","role"])if(u&&i[W]!==void 0)Q(t,`meta.${W} is for the official palettes — a market palette follows its base`);let l=i.role;if(l!==void 0&&l!=="default")Q(t,`meta.role must be "default", got ${JSON.stringify(l)}`);let f=i.base===void 0?void 0:Bg(t,"meta.base",i.base);if(f!==void 0&&!u)Q(t,"meta.base is for market palettes");let d=f===void 0?void 0:n.bases?.get(f),m=u&&i.group===void 0?d?.group??bo:wo(t,"meta.group",i.group),g=n.groups.get(m);if(!g&&!(u&&(m===bo||n.open)))Q(t,`meta.group "${m}" has no [[group]] table in ${Ue}`);let $=Mr(t,"colors.background",o.background),w=Mr(t,"colors.foreground",o.foreground),b=Mr(t,"colors.cursor",o.cursor),v=Mr(t,"colors.selection_background",o.selection_background),R=a.map((W,D)=>Mr(t,`colors.ansi[${D}]`,W)),S=MM(t,i.signature,{background:$,foreground:w,cursor:b,selection:v,ansi:R}),I=i.booru===void 0?void 0:$o(t,"meta.booru",i.booru);if(I!==void 0&&/[\s\p{Cc}]/u.test(I))Q(t,`meta.booru must be a single booru tag, got ${JSON.stringify(I)}`);let P=IM(t,i.booru_sites,I),O=i.native_names===void 0?void 0:RM(t,i.native_names),F=Array.isArray(s.waive)?s.waive.map(String):[];if(F.length>0&&typeof s.reason!=="string")Q(t,"contrast.waive needs a contrast.reason explaining why");let j=OM(t,r.picture);return{name:c,...f?{base:f}:{},group:m,native:g?.native,...O?{nativeNames:O}:{},lead:!u&&g?.lead===c,order:u?d?.order??kM:Number(i.order),role:l,ansiSource:u&&i.ansi_source===void 0?f??"original":wo(t,"meta.ansi_source",i.ansi_source),...I?{booru:I}:{},...P?{booruSites:P}:{},background:$,foreground:w,cursor:b,selectionBackground:v,ansi:R,signature:S.colors,signatureSlots:S.names,ghostty:EM(t,r.ghostty,{background:$,cursor:b,selectionBackground:v}),waive:F,waiveReason:typeof s.reason==="string"?s.reason:void 0,...j?{pictures:j}:{}}}function Yg(t){let e=NM(t),n=new Map(e.map((o)=>[o.name,o]));if(n.size!==e.length)Q(Ue,"group.name must be unique");let r=wM(t).filter((o)=>o.endsWith(".toml")&&!o.startsWith("_")).map((o)=>Zu(o,zg(Kg(t,o),"utf8"),{name:$M(o,".toml"),groups:n})).sort((o,s)=>o.order-s.order);if(new Set(r.map((o)=>o.order)).size!==r.length)throw Error("themes: meta.order must be unique across all themes");for(let o of e){let s=r.filter((a)=>a.group===o.name);if(s.length===0)Q(Ue,`group "${o.name}" has no themes`);if(!s.some((a)=>a.name===o.lead))Q(Ue,`group "${o.name}" lead "${o.lead}" is not one of its themes`)}return r}function Dg(t){return t.filter((e)=>e.role===void 0)}function Ir(t){let e=(r,i)=>r<i?-1:r>i?1:0,n=(r)=>rt(r.name)?r.name:r.base??r.name;return[...t].sort((r,i)=>Number(rt(r.name)!==void 0)-Number(rt(i.name)!==void 0)||e(r.group.toLowerCase(),i.group.toLowerCase())||Number(r.catalog===void 0)-Number(i.catalog===void 0)||e((r.catalog??"").toLowerCase(),(i.catalog??"").toLowerCase())||e(n(r),n(i))||Number(r.base!==void 0)-Number(i.base!==void 0)||e(r.name,i.name))}var yo={width:2560,height:1550},TM=1,AM=2560,CM=0.1,sp=0.99,jM=2,ln={tall:1.15,reach:0.4,widest:0.95,headroom:0.04,margin:0.03,stands:12},GM=yt(Ht("#19161e","#9b86c8",0.2)),UM="shelf",ua="originals",WM="images.json",Xu=1;function _M(t,e){if(e==="background"||e==="foreground"||e==="cursor")return t[e];if(e==="selection"&&t.selection)return t.selection;let n=/^ansi(\d|1[0-5])$/.exec(e),r=n?t.ansi[Number(n[1])]:void 0;if(!r)throw Error(`${t.name} has no slot ${e}`);return r}function Vg(t){if(t(1))return 1;let e=0,n=1;for(let r=0;r<40;r++){let i=(e+n)/2;if(t(i))e=i;else n=i}return e}function ap(t,e){let r=Vg((o)=>_h({name:t.name,background:Ht(t.background,e,o),foreground:t.foreground,ansi:t.ansi,waive:t.waived??[]}).length===0),i=Vg((o)=>yt(Ht(t.background,e,o))<=GM);return{cap:r,matched:i,opacity:Math.floor(Math.min(r,i)*100)/100}}function Zg(t,e){let n=_M(t,e),{cap:r,matched:i,opacity:o}=ap(t,n),s=nt(t.background),a=Math.hypot(...nt(n).map((c,u)=>(c-(s[u]??0))*o));return{slot:e,color:n,cap:r,matched:i,opacity:o,reach:a}}function la(t,e){return ap(t,e).opacity}function Un(t,e){let n=Zg(t,"cursor");if(n.opacity>=CM)return n;return e.filter((r)=>r!=="cursor"&&r!=="background").map((r)=>Zg(t,r)).reduce((r,i)=>i.reach>r.reach?i:r,n)}function BM(t){return Ym(t)??{x:0,y:0,w:t.width,h:t.height}}function ol(t,e){if(t<=0||e<=0)return yo;let n=Math.min(1,yo.width/Math.max(t,e));return{width:Math.round(t*n),height:Math.round(e*n)}}function cp(t,e,n,r){if(r<ln.stands){let c=t.w*n>t.h*e?{x:t.x+(t.w-t.h*e/n)/2,y:t.y,w:t.h*e/n,h:t.h}:{x:t.x,y:t.y,w:t.w,h:t.w*n/e};return{crop:c,at:{x:0,y:0,w:e,h:n},focus:(c.y-t.y+c.h/2)/t.h}}let i=Math.max(ln.tall*n,ln.reach*e*t.h/t.w),o=i*t.w/t.h;if(o>ln.widest*e)o=ln.widest*e,i=o*t.h/t.w;let s=ln.headroom*n,a=Math.min(1,(n-s)/i);return{crop:{x:t.x,y:t.y,w:t.w,h:t.h*a},at:{x:e*(1-ln.margin)-o,y:s,w:o,h:i*a},focus:Math.min(1,(n/2-s)/i)}}function zM(t,e){return 0.299*(t[e]??0)+0.587*(t[e+1]??0)+0.114*(t[e+2]??0)}function KM(t,e){let n=new Uint32Array(256),r=Math.max(1,Math.floor(e.w*e.h/400000)),i=0;for(let s=0;s<e.w*e.h;s+=r){let a=((e.y+Math.floor(s/e.w))*t.width+e.x+s%e.w)*4;if((t.data[a+3]??0)>=128){let c=Math.round(zM(t.data,a));n[c]=(n[c]??0)+1,i++}}let o=0;for(let s=0;s<256&&i>0;s++)if(o+=n[s]??0,o>=i*sp)return Math.min(jM,Math.max(1,255/Math.max(1,s)));return 1}var Qu=Float64Array.from({length:256},(t,e)=>{let n=e/255;return n<=0.04045?n/12.92:((n+0.055)/1.055)**2.4});function qM(t,e,n){return`#${[t,e,n].map((r)=>Math.round(r).toString(16).padStart(2,"0")).join("")}`}function JM(t,e){let n=new Uint32Array(256),r=new Float64Array(768),i=Math.max(1,Math.floor(e.w*e.h/400000)),o=0;for(let a=0;a<e.w*e.h;a+=i){let c=((e.y+Math.floor(a/e.w))*t.width+e.x+a%e.w)*4;if((t.data[c+3]??0)>=128){let u=t.data[c]??0,l=t.data[c+1]??0,f=t.data[c+2]??0,d=Math.round(255*Math.sqrt(0.2126*(Qu[u]??0)+0.7152*(Qu[l]??0)+0.0722*(Qu[f]??0)));n[d]=(n[d]??0)+1,r[d*3]=(r[d*3]??0)+u,r[d*3+1]=(r[d*3+1]??0)+l,r[d*3+2]=(r[d*3+2]??0)+f,o++}}let s=0;for(let a=0;a<256&&o>0;a++)if(s+=n[a]??0,s>=o*sp){let c=Math.max(1,n[a]??1);return qM((r[a*3]??0)/c,(r[a*3+1]??0)/c,(r[a*3+2]??0)/c)}return"#ffffff"}function YM(t,e){let n=t.data,r=new Uint8Array(t.width*t.height);for(let i=0,o=0;i<r.length;i++,o+=4){let s=n[o+3];if(s===0)continue;let a=(0.299*n[o]+0.587*n[o+1]+0.114*n[o+2])*e;r[i]=(a>255?255:a)*s/255+0.5}return{width:t.width,height:t.height,data:r}}function up(t,e,n){let r=Math.max(0,Math.round(t.at.x)),i=Math.max(0,Math.round(t.at.y)),o=Math.min(e,Math.round(t.at.x+t.at.w)),s=Math.min(n,Math.round(t.at.y+t.at.h));if(o<=r||s<=i)return;let a=t.crop.w/t.at.w,c=t.crop.h/t.at.h;return{x0:r,y0:i,x1:o,y1:s,box:{x:t.crop.x+(r-t.at.x)*a,y:t.crop.y+(i-t.at.y)*c,w:(o-r)*a,h:(s-i)*c}}}function ca(t,e,n,r){let i=new Float32Array(n*r),o=up(e,n,r);if(o){let s=Qm(t,o.box,o.x1-o.x0,o.y1-o.y0);for(let a=o.y0;a<o.y1;a++)i.set(s.data.subarray((a-o.y0)*(o.x1-o.x0),(a-o.y0+1)*(o.x1-o.x0)),a*n+o.x0)}return{width:n,height:r,data:i}}function sl(t,e,n,r){let i=new Uint8Array(n*r*4),o=up(e,n,r);if(o){let s=o.x1-o.x0,a=eo(t,o.box,s,o.y1-o.y0);for(let c=o.y0;c<o.y1;c++)i.set(a.data.subarray((c-o.y0)*s*4,(c-o.y0+1)*s*4),(c*n+o.x0)*4)}return{width:n,height:r,data:i}}function tl(t,e){if(e<=0)return t;let{width:n,height:r}=t,i=[0,1,2,3].map(()=>({width:n,height:r,data:new Float32Array(n*r)}));for(let a=0;a<n*r;a++){let c=t.data[a*4+3]??0;for(let u=0;u<3;u++)i[u].data[a]=(t.data[a*4+u]??0)*c/255;i[3].data[a]=c}let o=i.map((a)=>no(a,e).data),s=new Uint8Array(n*r*4);for(let a=0;a<n*r;a++){let c=o[3]?.[a]??0;if(c<=0)continue;for(let u=0;u<3;u++)s[a*4+u]=Math.min(255,Math.max(0,Math.round((o[u]?.[a]??0)*255/c)));s[a*4+3]=Math.min(255,Math.round(c))}return{width:n,height:r,data:s}}function al(t){let e=BM(t),n,r;return{box:e,clear:an(t,e),get ink(){return n??=YM(t,KM(t,e)),n},image:t,get peak(){return r??=JM(t,e),r}}}function lp(t,e,n,r,i){let o=al(t),{box:s,clear:a,ink:c}=o,u=cp(s,e,n,a),l=Math.min(1,AM/Math.max(s.w,s.h)),f={x:0,y:0,w:Math.round(s.w*l),h:Math.round(s.h*l)},d=r*f.w*u.crop.w/(s.w*u.at.w);if(i==="original")return{coloring:i,figure:tl(eo(t,s,f.w,f.h),d),fill:tl(sl(t,u,e,n),r),focus:u.focus,peak:o.peak};let m=ca(c,{crop:s,at:f,focus:u.focus},f.w,f.h),g=ca(c,u,e,n);return{coloring:i,figure:ro(no(m,d)),fill:ro(no(g,r)),focus:u.focus}}function DM(t,e,n,r){let i=nt(e),o=nt(n),s=new Uint8Array(t.width*t.height*4);for(let a=0;a<t.data.length;a++){let c=(t.data[a]??0)/255*r;for(let u=0;u<3;u++)s[a*4+u]=Math.round((i[u]??0)+((o[u]??0)-(i[u]??0))*c);s[a*4+3]=255}return{width:t.width,height:t.height,data:s}}function VM(t,e,n){let r=nt(e),i=new Uint8Array(t.width*t.height*4);for(let o=0;o<t.width*t.height;o++){let s=(t.data[o*4+3]??0)/255*n;for(let a=0;a<3;a++)i[o*4+a]=Math.round((r[a]??0)+((t.data[o*4+a]??0)-(r[a]??0))*s);i[o*4+3]=255}return{width:t.width,height:t.height,data:i}}function fp(t,e,n,r,i,o,s,a="tone"){let{box:c,clear:u,ink:l}=t,f=cp(c,r,i,u),d=Math.round(100*f.at.w/f.crop.w/Math.min(r/c.w,i/c.h)),m=s?.size??"fill",g=m==="fill"?f:{crop:c,at:wp(c.w,c.h,r,i,m,s?.at??5,!1,m>100?Math.round(f.focus*100):-1),focus:f.focus},$=a==="original"?la(e,t.peak):n.opacity,w=s?.opacity??$;return{image:a==="original"?VM(tl(sl(t.image,g,r,i),o),e.background,w):DM(ro(no(ca(l,g,r,i),o)),e.background,n.color,w),fill:d,opacity:$}}function X(t){return U(t,"ttheme","backgrounds")}function el(t){return U(t,WM)}function Gn(t){try{return pi(t,"utf8")}catch{return}}function jn(t){try{return FM(t)}catch{return[]}}function Rt(t){let e=Gn(el(t));if(e===void 0)return ZM(t);let n=JSON.parse(e);if(n.version!==Xu)throw Error(`${el(t)} is version ${n.version} — this ttheme reads version ${Xu}`);return n}function ye(t){return t.coloring??"tone"}function cl(t){return{name:t.name,background:t.background,foreground:t.foreground,cursor:t.cursor,...t.selection?{selection:t.selection}:{},ansi:t.ansi,...t.waived?{waived:t.waived}:{}}}function bi(t){return{hue:{color:t.backdrop.color,opacity:t.backdrop.opacity},colors:cl(t)}}function wi(t){return t.tone===void 0&&ye(t)==="tone"}function Qg(t){return(t.artist??[]).map((e)=>e.replace(/[\s,]+/g,"_")).join(",")}function dp(t,e){let n=e.pictures.findIndex((i)=>i.key===e.active),r=e.pictures[n];return[...r.artist?.length?[`# by ${Qg(r)}`]:[],...r.from?[`# from ${r.from}`]:[],`# image ${r.key} ${n+1}/${e.pictures.length}`,...e.pictures.map((i)=>[`# picture ${i.key} ${i.stem} ${i.fill} ${i.opacity} ${i.artist?.length?Qg(i):"-"}`,...i.from?[i.from]:[]].join(" ")),...e.pictures.filter((i)=>ye(i)==="original").map((i)=>`# colors ${i.key} original`),`background-image = ${U(t,r.fill)}`,"background-image-fit = cover","background-image-position = top-right",`background-image-opacity = ${r.opacity}`,`config-file = ?${r.stem}.tune.conf`,`config-file = ?${r.stem}.off.conf`,""].join(`
324
- `)}function hp(t){let e=X(t);for(let[n,r]of Object.entries(Rt(e).palettes)){let i=U(e,`${We(n)}.conf`),o=dp(e,r);if(Gn(i)!==o)T(i,o)}}function $i(t,e,n){T(el(t),`${JSON.stringify(e,null,2)}
325
- `);for(let r of n){let i=e.palettes[r],o=U(t,`${We(r)}.conf`);if(i)T(o,dp(t,i));else gi(o,{force:!0})}}function mp(t,e){return jn(t).filter((n)=>n.startsWith(`${e}.`)||n.startsWith(`${e}@`))}function ul(t,e){for(let n of mp(t,e))gi(U(t,n),{force:!0})}function gp(t,e){ul(t,e.stem);for(let n of[e.original,e.cut])if(n)gi(U(t,n),{force:!0})}function Xg(t,e,n,r){let i=op(/^background-image\s*=\s*(.*?)\s*$/m.exec(e??"")?.[1]??"");if(!i.startsWith(`${t}.`)||!/^\.[0-9a-f]{8}@fill-\d+\.png$/.test(i.slice(t.length)))return;let o=i.slice(0,i.indexOf("@")),s=r??/^# image (\S+)$/m.exec(e??"")?.[1]??`picture_${o.slice(t.length+1)}`,a=/^# from (.+)$/m.exec(e??"")?.[1],c=Number(/^background-image-opacity\s*=\s*(\S+)/m.exec(e??"")?.[1]??1),u=n.find((l)=>l.startsWith(`${t}-${s}.`));return{key:s,stem:o,fill:i,opacity:Number.isFinite(c)?c:1,...a?{from:a}:{},...u?{original:U(ua,u)}:{}}}function tp(t,e){if(il(t))ip(t,e)}function ZM(t){let e={version:Xu,palettes:{}};if(!il(t))return e;let n=jn(U(t,ua)),r=jn(t).filter((o)=>o.endsWith(".conf")&&o!=="shown.conf"&&!/\.(tune|off)\.conf$/.test(o)).map((o)=>o.slice(0,-5)),i=U(t,UM);for(let o of new Set([...r,...jn(i)])){let s=[],a=Xg(o,Gn(U(t,`${o}.conf`)),n);if(a)tp(U(t,`${o}.tune.conf`),U(t,`${a.stem}.tune.conf`)),tp(U(t,`${o}.off.conf`),U(t,`${a.stem}.off.conf`)),s.push(a);for(let c of jn(U(i,o))){let u=U(i,o,c),l=Xg(o,Gn(U(u,".conf")),n,c);if(!l)continue;for(let f of jn(u)){let d=f===".tune.conf"||f===".off.conf"?`${l.stem}${f}`:`${o}${f}`;if(f!==".conf")ip(U(u,f),U(t,d))}gi(u,{recursive:!0}),s.push(l)}if(jn(U(i,o)).length===0)gi(U(i,o),{recursive:!0,force:!0});if(s.length>0)s.sort((c,u)=>c.key<u.key?-1:c.key>u.key?1:0),e.palettes[o]={active:(a??s[0]).key,pictures:s}}if(jn(i).length===0)gi(i,{recursive:!0,force:!0});return $i(t,e,Object.keys(e.palettes)),e}function ep(t,e,n){return e.startsWith("~/")?U(n,e.slice(2)):LM(e)?e:U(t,e)}function vo(t,e,n){let r=new Map,i=(a,c)=>{let u=Gn(a);if(u===void 0)return!1;for(let l of u.split(`
326
- `)){let f=/^([a-z-]+)\s*=\s*(.*?)\s*$/.exec(l);if(f?.[1]==="config-file"&&c<4)i(ep(t,f[2].replace(/^\?/,""),n),c+1);else if(f&&/^background-image(?:-fit|-opacity)?$/.test(f[1]))r.set(f[1],f[2])}return!0};if(!i(U(t,`${We(e)}.conf`),0))return;let o=r.get("background-image")??"";if(o==="")return;let s=Number(r.get("background-image-opacity")??1);return{image:ep(t,o,n),opacity:Number.isFinite(s)?s:1,cover:r.get("background-image-fit")==="cover"}}function Wt(t){return`${t.site}_${t.id}`}function fa(t,e,n){let r=X(t),i=Rt(r),o=i.palettes[e];if(!o)throw Error(`${e} has no image`);let s=o.pictures.findIndex((u)=>u.key===(n??o.active));if(s===-1)throw Error(`${e} has no picture ${n}`);let[a]=o.pictures.splice(s,1);gp(r,a);let c=o.pictures[s%Math.max(o.pictures.length,1)];if(!c)delete i.palettes[e];else if(a.key===o.active)o.active=c.key;return $i(r,i,[e]),{key:a.key,left:o.pictures.length}}function pp(t,e,n,r){let i=n.coloring==="original"?Ce(n.figure):oo(n.figure,r),o=n.coloring==="original"?Ce(n.fill):oo(n.fill,r),s=`${We(t)}.${rp("sha1").update(e).update(i).update(o).digest("hex").slice(0,8)}`,a=`${s}@fill-${Math.round(n.focus*100)}.png`;return{stem:s,fill:a,files:[[`${s}.png`,i],[a,o]]}}function bp(t,e,n,r){return n==="original"&&r?{coloring:"original",opacity:la(t,r),peak:r}:{coloring:"tone",opacity:e.opacity,tone:e.color}}function nl(t,e){return U(ua,`${We(t)}-${e}`)}function ll(t,e){return e.map(([n,r])=>{let i=U(t,n);return T(i,r),i})}function da(t,e,n,r,i,o,s,a="tone"){let c=X(t),u=e.name,l=Wt(i),f=Rt(c),d=f.palettes[u]??{active:l,pictures:[]},m=ol(o.width,o.height),g=lp(r,m.width,m.height,s,a),$=pp(u,l,g,n.color),w=nl(u,l),b={key:l,stem:$.stem,fill:$.fill,...bp(e,n,g.coloring,g.coloring==="original"?g.peak:void 0),blur:s,window:m,...i.from?{from:i.from}:{},...i.artist?.length?{artist:i.artist}:{},...i.source?{source:i.source}:{},original:`${w}.${i.ext}`,...i.cut?{cut:`${w}.cut.png`}:{}},v=d.pictures.find((S)=>S.key===l);if(v)gp(c,v);HM(U(c,ua),{recursive:!0});let R=ll(c,[...$.files,[b.original,i.bytes],...b.cut?[[b.cut,Tu(io(r))]]:[]]);return d.pictures=v?d.pictures.map((S)=>S===v?b:S):[...d.pictures,b],d.active=l,f.palettes[u]=d,$i(c,f,[u]),[...R,U(c,`${We(u)}.conf`)]}function ki(t,e,n){let r=X(t),i=Rt(r),o=i.palettes[e],s=o?o.pictures.findIndex((a)=>a.key===n):-1;if(!o||s===-1)throw Error(`${e} has no picture ${n}`);if(o.active!==n)o.active=n,$i(r,i,[e]);return{at:s+1,of:o.pictures.length}}function fe(t,e){let n=Rt(X(t)).palettes[e];if(!n)return[];return[...n.pictures.filter((i)=>i.key===n.active),...n.pictures.filter((i)=>i.key!==n.active)]}var rl="top-right";function wp(t,e,n,r,i,o,s,a=-1){let c=Math.trunc,u=(o-1)%3,l=c((o-1)/3),f=n*e>=r*t!==!s,d=f?c(i*n/100):c(i*r*t/(100*e)),m=f?c(i*n*e/(100*t)):c(i*r/100),g=c(u*(n-d)/2),$=c(l*(r-m)/2);if(a>=0){if(d>n)g=c((n-d)/2);if(m>r)$=Math.max(r-m,Math.min(0,c(r/2)-c(a*m/100)))}return{x:g,y:$,w:d,h:m}}function fl(t,e){let n=Gn(U(t,`${e.stem}.tune.conf`));if(n===void 0)return{};let r=(u)=>new RegExp(`^${u}\\s*=\\s*(.*?)\\s*$`,"m").exec(n)?.[1]??"",i=op(r("background-image")),o=/@(\d+)-/.exec(i)?.[1],s=/@fill-\d+\.png$/.test(i)?"fill":o?Number(o):r("background-image-fit")==="cover"?"fill":100,a=r("background-image-position").replace("center-center","center")||"center",c=Number(r("background-image-opacity")||1);return{...s!=="fill"?{size:s}:{},...a!==rl?{position:a}:{},...Number.isFinite(c)&&c!==e.opacity?{opacity:c}:{}}}function Eo(t,e,n,r,i){let o=n.size??"fill",s=n.position??rl,a=n.opacity??e.opacity;if(o==="fill"&&s===rl&&a===e.opacity)return;let c=Qt.indexOf(s)+1,u=U(t,`${e.stem}.png`),l=U(t,e.fill),f=!0,d=typeof o==="number"&&(o>100||!r&&s!=="center");if(o===100&&!d)l=u,f=!1;else if(typeof o==="number"){if(wi(e))throw Error(`${e.stem} was drawn before pictures kept their tone — init draws it again`);let g=ue(new Uint8Array(pi(u))),{width:$,height:w}=d?yo:g,b=d?Number(/@fill-(\d+)\.png$/.exec(e.fill)?.[1]??50):-1,v=wp(g.width,g.height,$,w,o,c,!1,b);l=U(t,`${e.stem}@${o}-${s}${d?`-${$}x${w}`:""}.png`);let S={crop:{x:0,y:0,w:g.width,h:g.height},at:v,focus:b};T(l,e.tone?oo(ro(ca(io(g),S,$,w)),e.tone):Ce(sl(g,S,$,w))),f=d}let m=U(t,`${e.stem}.tune.conf`);return T(m,[`background-image = ${l.startsWith(`${i}/`)?`~${l.slice(i.length)}`:l}`,`background-image-fit = ${f?"cover":"contain"}`,`background-image-position = ${s}`,`background-image-opacity = ${a}`,""].join(`
327
- `)),m}function $p(t){let e=new Map;for(let[n,r]of Object.entries(Rt(X(t)).palettes)){let[,i,o]=/^([a-z.]+)_(\d+)$/.exec(r.active)??[];if(i&&o)e.set(n,{site:i,id:Number(o)})}return e}function kp(t){try{let e=Hn(new Uint8Array(pi(t)));return e?{width:e.width,height:e.height}:void 0}catch{return}}function yp(t,e,n,r,i,o,s){let a=[n.original,n.cut].map((c)=>{if(!c)return"";try{let{size:u,mtimeMs:l}=xM(U(t,c));return`${c}:${u}:${l}`}catch{return}});if(!n.original||a.includes(void 0))return;return xg([TM,We(e),n.key,...a,r.width,r.height,i,o,o==="tone"?s:""])}function QM(t,e,n){if(!n.window||n.blur===void 0)return;let r=yp(t,e,n,n.window,n.blur,ye(n),n.tone??"");if(!r||Lg(r))return;try{qu(r,{stem:n.stem,fill:n.fill,...n.peak?{peak:n.peak}:{},figure:pi(U(t,`${n.stem}.png`)),picture:pi(U(t,n.fill))})}catch{}}function vp(t,e,n,r,i,o,s,a,c){let u=c?void 0:yp(t,e,n,r,s,a,o.hue.color),l=u?Tg(u):void 0;if(l)return{made:{stem:l.stem,fill:l.fill,files:[[`${l.stem}.png`,l.figure],[l.fill,l.picture]]},peak:l.peak,image:void 0};let f=i();if(!f)return null;let d=lp(f,r.width,r.height,s,a),m=pp(e,n.key,d,o.hue.color),g=d.coloring==="original"?d.peak:void 0;if(u)qu(u,{stem:m.stem,fill:m.fill,...g?{peak:g}:{},figure:m.files[0]?.[1],picture:m.files[1]?.[1]});return{made:m,peak:g,image:f}}function So(t,e,n,r,i,o,s,a,c,u=ye(n)){let l=X(t),f=n.window??kp(U(l,n.fill))??yo,d=vp(l,e,n,f,r,i,o,u,c);if(!d)return null;let{made:m,peak:g,image:$}=d,w={...n,stem:m.stem,fill:m.fill,...bp(i.colors,i.hue,u,g),blur:o,window:f,...c?{cut:`${nl(e,n.key)}.cut.png`}:{}};if(u==="original")delete w.tone;else delete w.peak;if(c&&$)T(U(l,`${nl(e,n.key)}.cut.png`),Tu(io($)));if(m.stem===n.stem)return w;if(ye(n)!==u)QM(l,e,n);ll(l,m.files);let b=fl(l,n);Eo(l,w,ye(n)===u?b:{...b,opacity:void 0},s,a);let v=U(l,`${n.stem}.off.conf`);if(il(v))PM(v,U(l,`${w.stem}.off.conf`));return w}function Ep(t,e,n,r,i,o,s){let a=X(t),c=n.window??kp(U(a,n.fill))??yo;return vp(a,e,n,c,r,i,o,s,!1)!==null}function dl(t,e){let n=X(t),r=Rt(n),i=new Set,o=[];for(let{name:s,picture:a}of e){let c=r.palettes[s],u=c?.pictures.findIndex((f)=>f.key===a.key)??-1,l=c?.pictures[u];if(!c||!l)continue;if(c.pictures[u]=a,i.add(s),l.stem!==a.stem)o.push(l.stem)}if(i.size===0)return;$i(n,r,[...i]);for(let s of o)ul(n,s)}function Sp(t,e,n){return t.replace(/^background-image-opacity = (\S+)$/m,(r,i)=>Number(i)===e?`background-image-opacity = ${n}`:r)}function Mp(t,e,n){let r=U(t,`${e.stem}.tune.conf`),i=Gn(r);if(i!==void 0)T(r,Sp(i,e.opacity,n));return{...e,opacity:n}}function XM(t,e,n,r){if(n.tone===r.color)return Mp(t,n,r.opacity);let i=mp(t,n.stem).filter((a)=>a.endsWith(".png")).map((a)=>{let c=new Uint8Array(pi(U(t,a)));return[a,ig(c,r.color)??oo(io(ue(c)),r.color)]}),o=(a)=>i.find(([c])=>c===a)?.[1]??new Uint8Array,s=`${We(e)}.${rp("sha1").update(n.key).update(o(`${n.stem}.png`)).update(o(n.fill)).digest("hex").slice(0,8)}`;ll(t,i.map(([a,c])=>[s+a.slice(n.stem.length),c]));for(let a of["tune","off"]){let c=Gn(U(t,`${n.stem}.${a}.conf`));if(c!==void 0)T(U(t,`${s}.${a}.conf`),Sp(c.split(n.stem).join(s),n.opacity,r.opacity))}return{...n,stem:s,fill:s+n.fill.slice(n.stem.length),opacity:r.opacity,tone:r.color}}function np(t,e){if(ye(t)==="original")return t.peak!==void 0&&la(e.colors,t.peak)!==t.opacity;return t.tone!==void 0&&(t.tone!==e.hue.color||t.opacity!==e.hue.opacity)}function Ip(t,e){let n=X(t),r=Rt(n),i=[],o=[];for(let[s,a]of Object.entries(r.palettes)){let c=e.get(s);if(!c||!a.pictures.some((u)=>np(u,c)))continue;a.pictures=a.pictures.map((u)=>{if(!np(u,c))return u;let l=ye(u)==="original"?Mp(n,u,la(c.colors,u.peak)):XM(n,s,u,c.hue);if(l.stem!==u.stem)o.push(u.stem);return l}),i.push(s)}if(i.length>0){$i(n,r,i);for(let s of o)ul(n,s)}return i}function ve(t){let{slot:e,color:n,opacity:r}=Un({name:t.name,background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selectionBackground,ansi:t.ansi,waived:t.waive},t.signatureSlots);return{name:t.name,...t.base?{base:t.base}:{},group:t.group,...t.native?{native:t.native}:{},...t.nativeNames?{nativeNames:t.nativeNames}:{},...t.lead?{lead:!0}:{},order:t.order,ansiSource:t.ansiSource,...t.booru?{booru:t.booru}:{},...t.booruSites?{booruSites:t.booruSites}:{},...t.role==="default"?{default:!0}:{},background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selectionBackground,signature:t.signature,signatureSlots:t.signatureSlots,ansi:t.ansi,gate:Le(t),...t.waive.length>0?{waived:t.waive}:{},backdrop:{slot:e,color:n,opacity:r},...t.pictures?{pictures:t.pictures}:{}}}function Ee(t){return{name:t.name,...t.base?{base:t.base}:{},group:t.group,...t.native?{native:t.native}:{},...t.nativeNames?{nativeNames:t.nativeNames}:{},lead:t.lead===!0,order:t.order,...t.default?{role:"default"}:{},ansiSource:t.ansiSource,...t.booru?{booru:t.booru}:{},...t.booruSites?{booruSites:t.booruSites}:{},background:t.background,foreground:t.foreground,cursor:t.cursor,selectionBackground:t.selection,ansi:t.ansi,signature:t.signature,signatureSlots:t.signatureSlots,ghostty:{iconGhost:t.cursor,iconScreen:[t.cursor,t.selection,t.background]},waive:t.waived??[],...t.pictures?{pictures:t.pictures}:{}}}var t2=6,e2=["ansi1","ansi2","ansi4","ansi3","ansi5","ansi6"];function ha(t){let e=(o)=>o.startsWith("ansi")?t.ansi[Number(o.slice(4))]:o==="foreground"?t.foreground:o==="cursor"?t.cursor:o==="selection"?t.selection:void 0,n=(o)=>o.startsWith("ansi")?`ansi${Number(o.slice(4))%8}`:o,r=new Set,i=[];for(let o of["foreground",...t.signatureSlots,...e2]){let s=e(o);if(i.length===t2||!s||r.has(n(o))||i.includes(s))continue;r.add(n(o)),i.push(s)}return i}function Mt(t){return t.filter((e)=>e.default!==!0)}function Mo(){return{version:Ot.version,gate:Dt,placement:ln,palettes:[]}}function n2(t){let[e]=t;if(!e)throw Error("manifest needs at least one theme");return{...Mo(),palettes:t.map(ve)}}var hl={id:"meta",emitShared(t){return[{path:"manifest.json",content:`${JSON.stringify(n2(t),null,2)}
328
- `}]}};import{existsSync as u2,readdirSync as Fp,readFileSync as l2}from"node:fs";import{basename as xp,join as Io}from"node:path";import{existsSync as r2,readFileSync as Op}from"node:fs";import{homedir as Np}from"node:os";import{isAbsolute as Rp,join as Or,resolve as i2}from"node:path";var J="official",_e="ttheme-market.json",yi="ttheme-market",o2=/^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,38}$/i,s2=/^[\w.-]{1,100}$/,a2=/^\w[\w.+/-]{0,199}$/;function _n(t){return Or(t,"ttheme","installed.json")}function Ft(t){return t??[J]}function vi(t){try{let{markets:e}=JSON.parse(Op(_n(t),"utf8"));return Ft(Array.isArray(e)?e.filter((n)=>typeof n==="string"):void 0)}catch{return[J]}}function ut(t){return Rp(t)}function Xt(t){return t!==J&&!ut(t)}function Wn(t){let e=t.indexOf("#");return Xt(t)&&e>=0?t.slice(0,e):t}function ml(t){let e=t.indexOf("#");return Xt(t)&&e>=0?t.slice(e+1):void 0}function Ei(t,e){return Wn(t)===Wn(e)}function Bn(t,e){return!ut(t)&&(e?.[t]??t===J)}function c2(t){return!a2.test(t)||t.includes("..")||t.includes("//")||/(?:[./]|\.lock)$/.test(t)}function zn(t,e=process.cwd()){if(t===J)return J;if(t==="~"||t.startsWith("~/"))return Or(Np(),t.slice(1));if(t.startsWith(".")||Rp(t))return i2(e,t);let[n="",r,...i]=t.split("#"),[o,s,...a]=n.replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,"").split("/");if(!o||!o2.test(o)||!s||!s2.test(s)||a.length>0||i.length>0||r!==void 0&&c2(r))throw Error(`${t} is not a market — give a repository (alice/ttheme-dust, #v1 pins a tag or branch) or a path (./my-market)`);return`${o.toLowerCase()}/${s}${r===void 0?"":`#${r}`}`}function Pp(t){let e=ml(t)?.split("/").map(encodeURIComponent).join("/")??"HEAD";return`https://raw.githubusercontent.com/${Wn(t)}/${e}/${_e}`}function Hp(t){return t.slice(0,t.indexOf("/"))}function gl(t){return Or(t,"ttheme","markets")}function Se(t,e){return Or(gl(t),`${Wn(e).replace("/","--")}.json`)}function ma(t){return Or(t,"ttheme","market")}function pl(t,e){return Or(ma(t),e)}function bl(t,e){if(typeof t!=="string"||typeof e!=="string")return'needs an "owner" (the GitHub handle) and a "name"';return ke(`${t}@${e}/x`)}function te({owner:t,name:e}){return`${t}@${e}`}function Be(t){let e=Or(t,_e);if(!r2(e))throw Error(`${t} has no ${_e} — \`ttheme market init ${t}\` makes one`);let n;try{n=JSON.parse(Op(e,"utf8"))}catch{throw Error(`${e} is not valid JSON`)}let r=bl(n.owner,n.name);if(r)throw Error(`${e} ${r}`);return{owner:n.owner,name:n.name}}function et(t){if(t===J)return"the ttheme catalog";if(!ut(t))return`github.com/${t}`;let e=Np();return t===e||t.startsWith(`${e}/`)?`~${t.slice(e.length)}`:t}var fn="tt1:",Lp=["background","foreground","cursor","selection",...Array.from({length:16},(t,e)=>`ansi${e}`)];function Nr(t,e=!0){return vi(t).filter(ut).flatMap((n)=>{try{let r=Be(n);return[{dir:n,...r,id:te(r)}]}catch(r){if(e)process.stderr.write(`ttheme: skipping the market at ${n} — ${r.message}
329
- `);return[]}})}function ga(t){return Io(t,"palettes")}function Kn(t){let e=ga(t);if(!u2(e))return[];let n=[],r=[];for(let i of Fp(e,{withFileTypes:!0}).sort((o,s)=>o.name<s.name?-1:1)){if(i.name.startsWith("."))continue;if(i.isDirectory()){for(let o of Fp(Io(e,i.name)).sort())if(o.endsWith(".toml"))n.push({path:Io(e,i.name,o),slug:xp(o,".toml"),catalog:i.name})}else if(i.name.endsWith(".toml"))r.push({path:Io(e,i.name),slug:xp(i.name,".toml")})}return[...n,...r]}function Oo(t,e){let n=e.get(t.slug);if(n)return`${t.slug} is also ${n.catalog?`in ${n.catalog}`:"outside a catalog"} — a palette name is used once in a market`;let r=t.catalog===void 0?void 0:ko(t.catalog);return r?`the catalog folder ${JSON.stringify(t.catalog)} ${r}`:void 0}function wl(t,e){let n=rt(e);if(!n)throw Error(`${e} is an official palette — yours are named <you>@<market>/<palette>`);let r=Nr(t,!1).find((o)=>o.id===n);if(!r)throw Error(`${n} is not a local market — \`ttheme market add <dir>\` adds the folder that holds it`);let i=mi(e);return Kn(r.dir).find((o)=>o.slug===i)?.path??Io(ga(r.dir),`${i}.toml`)}function f2(t,e){let n=new Map;for(let i of e)if(i.group!==bo&&!n.has(i.group)){let o=e.find((s)=>s.group===i.group&&s.lead)?.name??"";n.set(i.group,{name:i.group,...i.native?{native:i.native}:{},lead:o})}let r=new Map(e.filter((i)=>!i.default&&!rt(i.name)).map((i)=>[i.name,{group:i.group,order:i.order}]));return{name:t,groups:n,bases:r,open:!0}}function ee(t,e,n){let r=mi(t),{native:i,...o}=Zu(`${r}.toml`,e,f2(r,n)),s=rt(t);return{...o,name:t,...s?{group:s,lead:!1}:{}}}function qn(t,e,n,r=!0){let i=new Map;return Kn(t).flatMap((o)=>{try{let s=Oo(o,i);if(s)throw Error(s);i.set(o.slug,o);let a=ve(ee(`${e}/${o.slug}`,l2(o.path,"utf8"),n));return[o.catalog?{...a,catalog:o.catalog}:a]}catch(s){if(r)process.stderr.write(`ttheme: skipping ${o.path} — ${s.message}
330
- `);return[]}})}function pa(t,e,n=!0){return Nr(t,n).flatMap(({dir:r,id:i})=>qn(r,i,e,n))}function $l(t,e=t.name,n){return{name:e,...t.base?{base:t.base}:{},...t.group!==bo?{group:t.group}:{},ansiSource:t.ansiSource,...t.booru?{booru:t.booru}:{},...t.booruSites?{booruSites:t.booruSites}:{},signature:t.signatureSlots,background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selection,ansi:t.ansi,...t.waived&&t.waived.length>0?{waive:t.waived,reason:n??"kept from the palette"}:{},...t.pictures?{pictures:t.pictures}:{}}}var bt=(t)=>JSON.stringify(t);function Tp(t){return["[[picture]]",`site = ${bt(t.site)}`,`id = ${t.id}`,...t.size===void 0?[]:[`size = ${typeof t.size==="number"?t.size:bt(t.size)}`],...t.position===void 0?[]:[`position = ${bt(t.position)}`],...t.opacity===void 0?[]:[`opacity = ${t.opacity}`]]}function Ap(t,e){return e.length===0?t:`${t.replace(/\n*$/,`
242
+ */var _t=["top-left","top-center","top-right","center-left","center","center-right","bottom-left","bottom-center","bottom-right"],vo="Original",ix=1e6,on="_groups.toml",Ib=3,xb=8,bd="[a-z0-9]+(?:-[a-z0-9]+)*",sx=new RegExp(`^(?:(${bd})@(${bd})/)?(${bd})$`),Pb=["background","foreground","cursor","selection"];function rt(t,e){throw Error(`${t}: ${e}`)}function ai(t,e,n){if(typeof n!=="string"||!ne(n))rt(t,`${e} must be "#rrggbb" (lowercase), got ${JSON.stringify(n)}`);return n}function Eo(t,e,n){if(typeof n!=="string"||n.length===0)rt(t,`${e} must be a non-empty string`);return n}function Qt(t){return t.replace("@","--").replace("/","--")}function A(t){return`ttheme-${Qt(t)}`}function ct(t){let e=t.indexOf("/");return e<0?void 0:t.slice(0,e)}function dr(t){return t.slice(t.indexOf("/")+1)}function Be(t){let e=sx.exec(t);if(!e)return"takes lowercase letters, digits and single hyphens, as <palette> or <owner>@<market>/<palette>";if((e[1]?.length??0)>39)return"has an owner longer than a GitHub handle can be";return(e[2]?.length??0)>40||(e[3]?.length??0)>40?"is longer than 40 characters":void 0}function Mo(t){if(/[\p{Cc}"$`\\]/u.test(t))return"holds a control character, a quote, $, ` or \\";return t.length>80?"is longer than 80 characters":void 0}function So(t,e,n){let r=Eo(t,e,n),i=Mo(r);if(i)rt(t,`${e} ${JSON.stringify(r)} ${i}`);return r}function Nb(t,e,n){let r=Eo(t,e,n),i=Be(r);if(i)rt(t,`${e} "${r}" ${i}`);return r}function as(t){return t&&typeof t==="object"?t:{}}function ox(t,e,n){if(e===void 0)return[n.cursor,n.selectionBackground,n.background];let r=Array.isArray(e)?e:[e];if(r.length===0)rt(t,"ghostty.icon_screen must not be empty");return r.map((i,s)=>ai(t,`ghostty.icon_screen[${s}]`,i))}function ax(t,e,n){let r=as(e);return{iconGhost:r.icon_ghost===void 0?n.cursor:ai(t,"ghostty.icon_ghost",r.icon_ghost),iconScreen:ox(t,r.icon_screen,n)}}function cx(t){return new Map([...Pb.map((e)=>[e,t[e]]),...t.ansi.map((e,n)=>[`ansi${n}`,e])])}function ux(t,e,n){if(!Array.isArray(e)||e.length!==Ib)rt(t,`meta.signature must name exactly ${Ib} palette slots`);let r=cx(n),i=[],s=[];for(let[o,a]of e.entries()){let c=`meta.signature[${o}]`,u=Eo(t,c,a),l=r.get(u);if(l===void 0)rt(t,`${c} ${JSON.stringify(a)} is not a palette slot — use ${Pb.join(", ")} or ansi0-ansi15`);i.push(u),s.push(l)}if(new Set(s).size!==s.length)rt(t,"meta.signature slots must resolve to three different colors");return{names:i,colors:s}}function lx(t,e,n){if(e===void 0)return;if(!n)rt(t,"meta.booru_sites renames meta.booru per site, so it needs meta.booru");if(!e||typeof e!=="object"||Array.isArray(e))rt(t,'meta.booru_sites must be a table of site = "tag" or site = ["tag", ...]');let r={};for(let[i,s]of Object.entries(e)){let o=Y.find((c)=>c.key===i);if(!o)rt(t,`meta.booru_sites.${i} is not a find site — use ${Y.map((c)=>c.key).join(", ")}`);let a=typeof s==="string"?[s]:Array.isArray(s)?s:void 0;if(!a||a.some((c)=>typeof c!=="string"||c===""||/\s/.test(c)))rt(t,`meta.booru_sites.${i} must be one tag or a list of tags, got ${JSON.stringify(s)}`);if(a.length>1&&!o.ors)rt(t,`meta.booru_sites.${i} takes one tag — ${o.name} does not OR tags`);if(a.length>o.tagBudget)rt(t,`meta.booru_sites.${i} takes ${o.tagBudget} tags at most — ${o.name} searches that many at a time`);r[i]=a}return r}function dx(t,e){if(e===void 0)return;if(!Array.isArray(e)||e.length===0||e.length>xb)rt(t,`[[picture]] holds 1 to ${xb} pictures`);return e.map((n,r)=>{let i=as(n),s=`picture[${r}]`,o=Y.find((l)=>l.key===i.site);if(!o)rt(t,`${s}.site must be one of ${Y.map((l)=>l.key).join(", ")}`);if(typeof i.id!=="number"||!Number.isSafeInteger(i.id)||i.id<=0)rt(t,`${s}.id must be the post's number on ${o.name}`);let{size:a,position:c,opacity:u}=i;if(a!==void 0&&a!=="fill"&&!(Number.isInteger(a)&&Number(a)>=20&&Number(a)<=999))rt(t,`${s}.size must be "fill" or a percentage from 20 to 999`);if(c!==void 0&&!_t.includes(c))rt(t,`${s}.position must be one of ${_t.join(", ")}`);if(u!==void 0&&!(typeof u==="number"&&u>=0&&u<=1))rt(t,`${s}.opacity must be a number from 0 to 1`);return{site:o.key,id:i.id,...a!==void 0?{size:a}:{},...c!==void 0?{position:c}:{},...u!==void 0?{opacity:u}:{}}})}function Hb(t,e){try{return gd(e)}catch(n){rt(t,`is not valid TOML — ${(n instanceof Error?n.message:String(n)).split(`
243
+ `)[0]}`)}}function fx(t){let n=Hb(on,Rb(Tb(t,on),"utf8")).group;if(!Array.isArray(n)||n.length===0)rt(on,"needs at least one [[group]] table");return n.map((r)=>{let i=as(r);return{name:So(on,"group.name",i.name),native:i.native===void 0?void 0:So(on,"group.native",i.native),lead:Eo(on,"group.lead",i.lead)}})}function hx(t,e){if(!Array.isArray(e)||e.length===0)rt(t,'meta.native_names must be a list of names, like ["後藤ひとり"]');return e.map((n,r)=>{let i=So(t,`meta.native_names[${r}]`,n);if(i.includes("|"))rt(t,`meta.native_names[${r}] ${JSON.stringify(i)} contains |`);return i})}function wd(t,e,n){let r=Hb(t,e),i=as(r.meta),s=as(r.colors),o=as(r.contrast),a=s.ansi;if(!Array.isArray(a)||a.length!==16)rt(t,`colors.ansi must hold exactly 16 colors, got ${Array.isArray(a)?a.length:typeof a}`);let c=Nb(t,"meta.name",i.name);if(c!==n.name)rt(t,`meta.name "${c}" does not match its file — it lives at ${n.name}`);let u=n.open===!0;for(let B of["order","role"])if(u&&i[B]!==void 0)rt(t,`meta.${B} is for the official palettes — a market palette follows its base`);let l=i.role;if(l!==void 0&&l!=="default")rt(t,`meta.role must be "default", got ${JSON.stringify(l)}`);let d=i.base===void 0?void 0:Nb(t,"meta.base",i.base);if(d!==void 0&&!u)rt(t,"meta.base is for market palettes");let f=d===void 0?void 0:n.bases?.get(d),h=u&&i.group===void 0?f?.group??vo:So(t,"meta.group",i.group),p=n.groups.get(h);if(!p&&!(u&&(h===vo||n.open)))rt(t,`meta.group "${h}" has no [[group]] table in ${on}`);let $=ai(t,"colors.background",s.background),g=ai(t,"colors.foreground",s.foreground),b=ai(t,"colors.cursor",s.cursor),y=ai(t,"colors.selection_background",s.selection_background),S=a.map((B,X)=>ai(t,`colors.ansi[${X}]`,B)),E=ux(t,i.signature,{background:$,foreground:g,cursor:b,selection:y,ansi:S}),I=i.booru===void 0?void 0:Eo(t,"meta.booru",i.booru);if(I!==void 0&&/[\s\p{Cc}]/u.test(I))rt(t,`meta.booru must be a single booru tag, got ${JSON.stringify(I)}`);let N=lx(t,i.booru_sites,I),R=i.native_names===void 0?void 0:hx(t,i.native_names),F=Array.isArray(o.waive)?o.waive.map(String):[];if(F.length>0&&typeof o.reason!=="string")rt(t,"contrast.waive needs a contrast.reason explaining why");let j=dx(t,r.picture);return{name:c,...d?{base:d}:{},group:h,native:p?.native,...R?{nativeNames:R}:{},lead:!u&&p?.lead===c,order:u?f?.order??ix:Number(i.order),role:l,ansiSource:u&&i.ansi_source===void 0?d??"original":So(t,"meta.ansi_source",i.ansi_source),...I?{booru:I}:{},...N?{booruSites:N}:{},background:$,foreground:g,cursor:b,selectionBackground:y,ansi:S,signature:E.colors,signatureSlots:E.names,ghostty:ax(t,r.ghostty,{background:$,cursor:b,selectionBackground:y}),waive:F,waiveReason:typeof o.reason==="string"?o.reason:void 0,...j?{pictures:j}:{}}}function Ab(t){let e=fx(t),n=new Map(e.map((s)=>[s.name,s]));if(n.size!==e.length)rt(on,"group.name must be unique");let r=nx(t).filter((s)=>s.endsWith(".toml")&&!s.startsWith("_")).map((s)=>wd(s,Rb(Tb(t,s),"utf8"),{name:rx(s,".toml"),groups:n})).sort((s,o)=>s.order-o.order);if(new Set(r.map((s)=>s.order)).size!==r.length)throw Error("themes: meta.order must be unique across all themes");for(let s of e){let o=r.filter((a)=>a.group===s.name);if(o.length===0)rt(on,`group "${s.name}" has no themes`);if(!o.some((a)=>a.name===s.lead))rt(on,`group "${s.name}" lead "${s.lead}" is not one of its themes`)}return r}function Fb(t){return t.filter((e)=>e.role===void 0)}function ci(t){let e=(r,i)=>r<i?-1:r>i?1:0,n=(r)=>ct(r.name)?r.name:r.base??r.name;return[...t].sort((r,i)=>Number(ct(r.name)!==void 0)-Number(ct(i.name)!==void 0)||e(r.group.toLowerCase(),i.group.toLowerCase())||Number(r.catalog===void 0)-Number(i.catalog===void 0)||e((r.catalog??"").toLowerCase(),(i.catalog??"").toLowerCase())||e(n(r),n(i))||Number(r.base!==void 0)-Number(i.base!==void 0)||e(r.name,i.name))}var Oo={width:2560,height:1550},$x=1,kx=2560,yx=0.1,zb=0.99,vx=2,Rn={tall:1.15,reach:0.4,widest:0.95,headroom:0.04,margin:0.03,stands:12},Sx=yt(Gt("#19161e","#9b86c8",0.2)),Ex="shelf",ic="originals",Mx="images.json",kd=1;function Ox(t,e){if(e==="background"||e==="foreground"||e==="cursor")return t[e];if(e==="selection"&&t.selection)return t.selection;let n=/^ansi(\d|1[0-5])$/.exec(e),r=n?t.ansi[Number(n[1])]:void 0;if(!r)throw Error(`${t.name} has no slot ${e}`);return r}function Cb(t){if(t(1))return 1;let e=0,n=1;for(let r=0;r<40;r++){let i=(e+n)/2;if(t(i))e=i;else n=i}return e}function Db(t,e){let r=Cb((s)=>Ip({name:t.name,background:Gt(t.background,e,s),foreground:t.foreground,ansi:t.ansi,waive:t.waived??[]}).length===0),i=Cb((s)=>yt(Gt(t.background,e,s))<=Sx);return{cap:r,matched:i,opacity:Math.floor(Math.min(r,i)*100)/100}}function Lb(t,e){let n=Ox(t,e),{cap:r,matched:i,opacity:s}=Db(t,n),o=nt(t.background),a=Math.hypot(...nt(n).map((c,u)=>(c-(o[u]??0))*s));return{slot:e,color:n,cap:r,matched:i,opacity:s,reach:a}}function ls(t,e){return Db(t,e).opacity}function an(t,e){let n=Lb(t,"cursor");if(n.opacity>=yx)return n;return e.filter((r)=>r!=="cursor"&&r!=="background").map((r)=>Lb(t,r)).reduce((r,i)=>i.reach>r.reach?i:r,n)}function Ix(t){return Fg(t)??{x:0,y:0,w:t.width,h:t.height}}function Od(t,e){if(t<=0||e<=0)return Oo;let n=Math.min(1,Oo.width/Math.max(t,e));return{width:Math.round(t*n),height:Math.round(e*n)}}function qb(t,e,n,r){if(r<Rn.stands){let c=t.w*n>t.h*e?{x:t.x+(t.w-t.h*e/n)/2,y:t.y,w:t.h*e/n,h:t.h}:{x:t.x,y:t.y,w:t.w,h:t.w*n/e};return{crop:c,at:{x:0,y:0,w:e,h:n},focus:(c.y-t.y+c.h/2)/t.h}}let i=Math.max(Rn.tall*n,Rn.reach*e*t.h/t.w),s=i*t.w/t.h;if(s>Rn.widest*e)s=Rn.widest*e,i=s*t.h/t.w;let o=Rn.headroom*n,a=Math.min(1,(n-o)/i);return{crop:{x:t.x,y:t.y,w:t.w,h:t.h*a},at:{x:e*(1-Rn.margin)-s,y:o,w:s,h:i*a},focus:Math.min(1,(n/2-o)/i)}}function xx(t,e){return 0.299*(t[e]??0)+0.587*(t[e+1]??0)+0.114*(t[e+2]??0)}function Nx(t,e){let n=new Uint32Array(256),r=Math.max(1,Math.floor(e.w*e.h/400000)),i=0;for(let o=0;o<e.w*e.h;o+=r){let a=((e.y+Math.floor(o/e.w))*t.width+e.x+o%e.w)*4;if((t.data[a+3]??0)>=128){let c=Math.round(xx(t.data,a));n[c]=(n[c]??0)+1,i++}}let s=0;for(let o=0;o<256&&i>0;o++)if(s+=n[o]??0,s>=i*zb)return Math.min(vx,Math.max(1,255/Math.max(1,o)));return 1}var $d=Float64Array.from({length:256},(t,e)=>{let n=e/255;return n<=0.04045?n/12.92:((n+0.055)/1.055)**2.4});function Rx(t,e,n){return`#${[t,e,n].map((r)=>Math.round(r).toString(16).padStart(2,"0")).join("")}`}function Tx(t,e){let n=new Uint32Array(256),r=new Float64Array(768),i=Math.max(1,Math.floor(e.w*e.h/400000)),s=0;for(let a=0;a<e.w*e.h;a+=i){let c=((e.y+Math.floor(a/e.w))*t.width+e.x+a%e.w)*4;if((t.data[c+3]??0)>=128){let u=t.data[c]??0,l=t.data[c+1]??0,d=t.data[c+2]??0,f=Math.round(255*Math.sqrt(0.2126*($d[u]??0)+0.7152*($d[l]??0)+0.0722*($d[d]??0)));n[f]=(n[f]??0)+1,r[f*3]=(r[f*3]??0)+u,r[f*3+1]=(r[f*3+1]??0)+l,r[f*3+2]=(r[f*3+2]??0)+d,s++}}let o=0;for(let a=0;a<256&&s>0;a++)if(o+=n[a]??0,o>=s*zb){let c=Math.max(1,n[a]??1);return Rx((r[a*3]??0)/c,(r[a*3+1]??0)/c,(r[a*3+2]??0)/c)}return"#ffffff"}function Px(t,e){let n=t.data,r=new Uint8Array(t.width*t.height);for(let i=0,s=0;i<r.length;i++,s+=4){let o=n[s+3];if(o===0)continue;let a=(0.299*n[s]+0.587*n[s+1]+0.114*n[s+2])*e;r[i]=(a>255?255:a)*o/255+0.5}return{width:t.width,height:t.height,data:r}}function Yb(t,e,n){let r=Math.max(0,Math.round(t.at.x)),i=Math.max(0,Math.round(t.at.y)),s=Math.min(e,Math.round(t.at.x+t.at.w)),o=Math.min(n,Math.round(t.at.y+t.at.h));if(s<=r||o<=i)return;let a=t.crop.w/t.at.w,c=t.crop.h/t.at.h;return{x0:r,y0:i,x1:s,y1:o,box:{x:t.crop.x+(r-t.at.x)*a,y:t.crop.y+(i-t.at.y)*c,w:(s-r)*a,h:(o-i)*c}}}function nc(t,e,n,r){let i=new Float32Array(n*r),s=Yb(e,n,r);if(s){let o=Gg(t,s.box,s.x1-s.x0,s.y1-s.y0);for(let a=s.y0;a<s.y1;a++)i.set(o.data.subarray((a-s.y0)*(s.x1-s.x0),(a-s.y0+1)*(s.x1-s.x0)),a*n+s.x0)}return{width:n,height:r,data:i}}function Id(t,e,n,r){let i=new Uint8Array(n*r*4),s=Yb(e,n,r);if(s){let o=s.x1-s.x0,a=co(t,s.box,o,s.y1-s.y0);for(let c=s.y0;c<s.y1;c++)i.set(a.data.subarray((c-s.y0)*o*4,(c-s.y0+1)*o*4),(c*n+s.x0)*4)}return{width:n,height:r,data:i}}function yd(t,e){if(e<=0)return t;let{width:n,height:r}=t,i=[0,1,2,3].map(()=>({width:n,height:r,data:new Float32Array(n*r)}));for(let a=0;a<n*r;a++){let c=t.data[a*4+3]??0;for(let u=0;u<3;u++)i[u].data[a]=(t.data[a*4+u]??0)*c/255;i[3].data[a]=c}let s=i.map((a)=>uo(a,e).data),o=new Uint8Array(n*r*4);for(let a=0;a<n*r;a++){let c=s[3]?.[a]??0;if(c<=0)continue;for(let u=0;u<3;u++)o[a*4+u]=Math.min(255,Math.max(0,Math.round((s[u]?.[a]??0)*255/c)));o[a*4+3]=Math.min(255,Math.round(c))}return{width:n,height:r,data:o}}function xd(t){let e=Ix(t),n,r;return{box:e,clear:In(t,e),get ink(){return n??=Px(t,Nx(t,e)),n},image:t,get peak(){return r??=Tx(t,e),r}}}function Jb(t,e,n,r,i){let s=xd(t),{box:o,clear:a,ink:c}=s,u=qb(o,e,n,a),l=Math.min(1,kx/Math.max(o.w,o.h)),d={x:0,y:0,w:Math.round(o.w*l),h:Math.round(o.h*l)},f=r*d.w*u.crop.w/(o.w*u.at.w);if(i==="original")return{coloring:i,figure:yd(co(t,o,d.w,d.h),f),fill:yd(Id(t,u,e,n),r),focus:u.focus,peak:s.peak};let h=nc(c,{crop:o,at:d,focus:u.focus},d.w,d.h),p=nc(c,u,e,n);return{coloring:i,figure:lo(uo(h,f)),fill:lo(uo(p,r)),focus:u.focus}}function Hx(t,e,n,r){let i=nt(e),s=nt(n),o=new Uint8Array(t.width*t.height*4);for(let a=0;a<t.data.length;a++){let c=(t.data[a]??0)/255*r;for(let u=0;u<3;u++)o[a*4+u]=Math.round((i[u]??0)+((s[u]??0)-(i[u]??0))*c);o[a*4+3]=255}return{width:t.width,height:t.height,data:o}}function Ax(t,e,n){let r=nt(e),i=new Uint8Array(t.width*t.height*4);for(let s=0;s<t.width*t.height;s++){let o=(t.data[s*4+3]??0)/255*n;for(let a=0;a<3;a++)i[s*4+a]=Math.round((r[a]??0)+((t.data[s*4+a]??0)-(r[a]??0))*o);i[s*4+3]=255}return{width:t.width,height:t.height,data:i}}function Vb(t,e,n,r,i,s,o,a="tone"){let{box:c,clear:u,ink:l}=t,d=qb(c,r,i,u),f=Math.round(100*d.at.w/d.crop.w/Math.min(r/c.w,i/c.h)),h=o?.size??"fill",p=h==="fill"?d:{crop:c,at:ms(c.w,c.h,r,i,h,o?.at??5,!1,h>100?Math.round(d.focus*100):-1),focus:d.focus},$=a==="original"?ls(e,t.peak):n.opacity,g=o?.opacity??$;return{image:a==="original"?Ax(yd(Id(t.image,p,r,i),s),e.background,g):Hx(lo(uo(nc(l,p,r,i),s)),e.background,n.color,g),fill:f,opacity:$}}function D(t){return z(t,"ttheme","backgrounds")}function vd(t){return z(t,Mx)}function hr(t){try{return us(t,"utf8")}catch{return}}function fr(t){try{return gx(t)}catch{return[]}}function vt(t){let e=hr(vd(t));if(e===void 0)return Fx(t);let n=JSON.parse(e);if(n.version!==kd)throw Error(`${vd(t)} is version ${n.version} — this ttheme reads version ${kd}`);return n}function be(t){return t.coloring??"tone"}function Nd(t){return{name:t.name,background:t.background,foreground:t.foreground,cursor:t.cursor,...t.selection?{selection:t.selection}:{},ansi:t.ansi,...t.waived?{waived:t.waived}:{}}}function mr(t){return{hue:{color:t.backdrop.color,opacity:t.backdrop.opacity},colors:Nd(t)}}function ds(t){return t.tone===void 0&&be(t)==="tone"}function jb(t){return(t.artist??[]).map((e)=>e.replace(/[\s,]+/g,"_")).join(",")}function Zb(t,e){let n=e.pictures.findIndex((i)=>i.key===e.active),r=e.pictures[n];return[...r.artist?.length?[`# by ${jb(r)}`]:[],...r.from?[`# from ${r.from}`]:[],`# image ${r.key} ${n+1}/${e.pictures.length}`,...e.pictures.map((i)=>[`# picture ${i.key} ${i.stem} ${i.fill} ${i.opacity} ${i.artist?.length?jb(i):"-"}`,...i.from?[i.from]:[]].join(" ")),...e.pictures.filter((i)=>be(i)==="original").map((i)=>`# colors ${i.key} original`),`background-image = ${z(t,r.fill)}`,"background-image-fit = cover","background-image-position = top-right",`background-image-opacity = ${r.opacity}`,`config-file = ?${r.stem}.tune.conf`,`config-file = ?${r.stem}.off.conf`,""].join(`
244
+ `)}function Qb(t){let e=D(t);for(let[n,r]of Object.entries(vt(e).palettes)){let i=z(e,`${Qt(n)}.conf`),s=Zb(e,r);if(hr(i)!==s)H(i,s)}}function fs(t,e,n){H(vd(t),`${JSON.stringify(e,null,2)}
245
+ `);for(let r of n){let i=e.palettes[r],s=z(t,`${Qt(r)}.conf`);if(i)H(s,Zb(t,i));else cs(s,{force:!0})}}function Xb(t,e){return fr(t).filter((n)=>n.startsWith(`${e}.`)||n.startsWith(`${e}@`))}function Rd(t,e){for(let n of Xb(t,e))cs(z(t,n),{force:!0})}function tw(t,e){Rd(t,e.stem);for(let n of[e.original,e.cut])if(n)cs(z(t,n),{force:!0})}function Gb(t,e,n,r){let i=Kb(/^background-image\s*=\s*(.*?)\s*$/m.exec(e??"")?.[1]??"");if(!i.startsWith(`${t}.`)||!/^\.[0-9a-f]{8}@fill-\d+\.png$/.test(i.slice(t.length)))return;let s=i.slice(0,i.indexOf("@")),o=r??/^# image (\S+)$/m.exec(e??"")?.[1]??`picture_${s.slice(t.length+1)}`,a=/^# from (.+)$/m.exec(e??"")?.[1],c=Number(/^background-image-opacity\s*=\s*(\S+)/m.exec(e??"")?.[1]??1),u=n.find((l)=>l.startsWith(`${t}-${o}.`));return{key:o,stem:s,fill:i,opacity:Number.isFinite(c)?c:1,...a?{from:a}:{},...u?{original:z(ic,u)}:{}}}function _b(t,e){if(Md(t))Ub(t,e)}function Fx(t){let e={version:kd,palettes:{}};if(!Md(t))return e;let n=fr(z(t,ic)),r=fr(t).filter((s)=>s.endsWith(".conf")&&s!=="shown.conf"&&!/\.(tune|off)\.conf$/.test(s)).map((s)=>s.slice(0,-5)),i=z(t,Ex);for(let s of new Set([...r,...fr(i)])){let o=[],a=Gb(s,hr(z(t,`${s}.conf`)),n);if(a)_b(z(t,`${s}.tune.conf`),z(t,`${a.stem}.tune.conf`)),_b(z(t,`${s}.off.conf`),z(t,`${a.stem}.off.conf`)),o.push(a);for(let c of fr(z(i,s))){let u=z(i,s,c),l=Gb(s,hr(z(u,".conf")),n,c);if(!l)continue;for(let d of fr(u)){let f=d===".tune.conf"||d===".off.conf"?`${l.stem}${d}`:`${s}${d}`;if(d!==".conf")Ub(z(u,d),z(t,f))}cs(u,{recursive:!0}),o.push(l)}if(fr(z(i,s)).length===0)cs(z(i,s),{recursive:!0,force:!0});if(o.length>0)o.sort((c,u)=>c.key<u.key?-1:c.key>u.key?1:0),e.palettes[s]={active:(a??o[0]).key,pictures:o}}if(fr(i).length===0)cs(i,{recursive:!0,force:!0});return fs(t,e,Object.keys(e.palettes)),e}function Bb(t,e,n){return e.startsWith("~/")?z(n,e.slice(2)):wx(e)?e:z(t,e)}function we(t,e,n){let r=new Map,i=(a,c)=>{let u=hr(a);if(u===void 0)return!1;for(let l of u.split(`
246
+ `)){let d=/^([a-z-]+)\s*=\s*(.*?)\s*$/.exec(l);if(d?.[1]==="config-file"&&c<4)i(Bb(t,d[2].replace(/^\?/,""),n),c+1);else if(d&&/^background-image(?:-fit|-opacity|-position)?$/.test(d[1]))r.set(d[1],d[2])}return!0};if(!i(z(t,`${Qt(e)}.conf`),0))return;let s=r.get("background-image")??"";if(s==="")return;let o=Number(r.get("background-image-opacity")??1);return{image:Bb(t,s,n),opacity:Number.isFinite(o)?o:1,cover:r.get("background-image-fit")==="cover",position:r.get("background-image-position")??"center"}}function Xt(t){return`${t.site}_${t.id}`}function sc(t,e,n){let r=D(t),i=vt(r),s=i.palettes[e];if(!s)throw Error(`${e} has no image`);let o=s.pictures.findIndex((u)=>u.key===(n??s.active));if(o===-1)throw Error(`${e} has no picture ${n}`);let[a]=s.pictures.splice(o,1);tw(r,a);let c=s.pictures[o%Math.max(s.pictures.length,1)];if(!c)delete i.palettes[e];else if(a.key===s.active)s.active=c.key;return fs(r,i,[e]),{key:a.key,left:s.pictures.length}}function ew(t,e,n,r){let i=n.coloring==="original"?rn(n.figure):ri(n.figure,r),s=n.coloring==="original"?rn(n.fill):ri(n.fill,r),o=`${Qt(t)}.${Wb("sha1").update(e).update(i).update(s).digest("hex").slice(0,8)}`,a=`${o}@fill-${Math.round(n.focus*100)}.png`;return{stem:o,fill:a,files:[[`${o}.png`,i],[a,s]]}}function nw(t,e,n,r){return n==="original"&&r?{coloring:"original",opacity:ls(t,r),peak:r}:{coloring:"tone",opacity:e.opacity,tone:e.color}}function Sd(t,e){return z(ic,`${Qt(t)}-${e}`)}function Td(t,e){return e.map(([n,r])=>{let i=z(t,n);return H(i,r),i})}function oc(t,e,n,r,i,s,o,a="tone"){let c=D(t),u=e.name,l=Xt(i),d=vt(c),f=d.palettes[u]??{active:l,pictures:[]},h=Od(s.width,s.height),p=Jb(r,h.width,h.height,o,a),$=ew(u,l,p,n.color),g=Sd(u,l),b={key:l,stem:$.stem,fill:$.fill,...nw(e,n,p.coloring,p.coloring==="original"?p.peak:void 0),blur:o,window:h,...i.from?{from:i.from}:{},...i.artist?.length?{artist:i.artist}:{},...i.source?{source:i.source}:{},original:`${g}.${i.ext}`,...i.cut?{cut:`${g}.cut.png`}:{}},y=f.pictures.find((E)=>E.key===l);if(y)tw(c,y);px(z(c,ic),{recursive:!0});let S=Td(c,[...$.files,[b.original,i.bytes],...b.cut?[[b.cut,nd(ni(r))]]:[]]);return f.pictures=y?f.pictures.map((E)=>E===y?b:E):[...f.pictures,b],f.active=l,d.palettes[u]=f,fs(c,d,[u]),[...S,z(c,`${Qt(u)}.conf`)]}function hs(t,e,n){let r=D(t),i=vt(r),s=i.palettes[e],o=s?s.pictures.findIndex((a)=>a.key===n):-1;if(!s||o===-1)throw Error(`${e} has no picture ${n}`);if(s.active!==n)s.active=n,fs(r,i,[e]);return{at:o+1,of:s.pictures.length}}function re(t,e){let n=vt(D(t)).palettes[e];if(!n)return[];return[...n.pictures.filter((i)=>i.key===n.active),...n.pictures.filter((i)=>i.key!==n.active)]}var Ed="top-right";function ms(t,e,n,r,i,s,o,a=-1){let c=Math.trunc,u=(s-1)%3,l=c((s-1)/3),d=n*e>=r*t!==!o,f=d?c(i*n/100):c(i*r*t/(100*e)),h=d?c(i*n*e/(100*t)):c(i*r/100),p=c(u*(n-f)/2),$=c(l*(r-h)/2);if(a>=0){if(f>n)p=c((n-f)/2);if(h>r)$=Math.max(r-h,Math.min(0,c(r/2)-c(a*h/100)))}return{x:p,y:$,w:f,h}}function Pd(t,e){let n=hr(z(t,`${e.stem}.tune.conf`));if(n===void 0)return{};let r=(u)=>new RegExp(`^${u}\\s*=\\s*(.*?)\\s*$`,"m").exec(n)?.[1]??"",i=Kb(r("background-image")),s=/@(\d+)-/.exec(i)?.[1],o=/@fill-\d+\.png$/.test(i)?"fill":s?Number(s):r("background-image-fit")==="cover"?"fill":100,a=r("background-image-position").replace("center-center","center")||"center",c=Number(r("background-image-opacity")||1);return{...o!=="fill"?{size:o}:{},...a!==Ed?{position:a}:{},...Number.isFinite(c)&&c!==e.opacity?{opacity:c}:{}}}function Io(t,e,n,r,i){let s=n.size??"fill",o=n.position??Ed,a=n.opacity??e.opacity;if(s==="fill"&&o===Ed&&a===e.opacity)return;let c=_t.indexOf(o)+1,u=z(t,`${e.stem}.png`),l=z(t,e.fill),d=!0,f=typeof s==="number"&&(s>100||!r&&o!=="center");if(s===100&&!f)l=u,d=!1;else if(typeof s==="number"){if(ds(e))throw Error(`${e.stem} was drawn before pictures kept their tone — init draws it again`);let p=At(new Uint8Array(us(u))),{width:$,height:g}=f?Oo:p,b=f?Number(/@fill-(\d+)\.png$/.exec(e.fill)?.[1]??50):-1,y=ms(p.width,p.height,$,g,s,c,!1,b);l=z(t,`${e.stem}@${s}-${o}${f?`-${$}x${g}`:""}.png`);let E={crop:{x:0,y:0,w:p.width,h:p.height},at:y,focus:b};H(l,e.tone?ri(lo(nc(ni(p),E,$,g)),e.tone):rn(Id(p,E,$,g))),d=f}let h=z(t,`${e.stem}.tune.conf`);return H(h,[`background-image = ${l.startsWith(`${i}/`)?`~${l.slice(i.length)}`:l}`,`background-image-fit = ${d?"cover":"contain"}`,`background-image-position = ${o}`,`background-image-opacity = ${a}`,""].join(`
247
+ `)),h}function rw(t){let e=new Map;for(let[n,r]of Object.entries(vt(D(t)).palettes)){let[,i,s]=/^([a-z.]+)_(\d+)$/.exec(r.active)??[];if(i&&s)e.set(n,{site:i,id:Number(s)})}return e}function iw(t){try{let e=nn(new Uint8Array(us(t)));return e?{width:e.width,height:e.height}:void 0}catch{return}}function sw(t,e,n,r,i,s,o){let a=[n.original,n.cut].map((c)=>{if(!c)return"";try{let{size:u,mtimeMs:l}=bx(z(t,c));return`${c}:${u}:${l}`}catch{return}});if(!n.original||a.includes(void 0))return;return $b([$x,Qt(e),n.key,...a,r.width,r.height,i,s,s==="tone"?o:""])}function Cx(t,e,n){if(!n.window||n.blur===void 0)return;let r=sw(t,e,n,n.window,n.blur,be(n),n.tone??"");if(!r||kb(r))return;try{hd(r,{stem:n.stem,fill:n.fill,...n.peak?{peak:n.peak}:{},figure:us(z(t,`${n.stem}.png`)),picture:us(z(t,n.fill))})}catch{}}function ow(t,e,n,r,i,s,o,a,c){let u=c?void 0:sw(t,e,n,r,o,a,s.hue.color),l=u?yb(u):void 0;if(l)return{made:{stem:l.stem,fill:l.fill,files:[[`${l.stem}.png`,l.figure],[l.fill,l.picture]]},peak:l.peak,image:void 0};let d=i();if(!d)return null;let f=Jb(d,r.width,r.height,o,a),h=ew(e,n.key,f,s.hue.color),p=f.coloring==="original"?f.peak:void 0;if(u)hd(u,{stem:h.stem,fill:h.fill,...p?{peak:p}:{},figure:h.files[0]?.[1],picture:h.files[1]?.[1]});return{made:h,peak:p,image:d}}function xo(t,e,n,r,i,s,o,a,c,u=be(n)){let l=D(t),d=n.window??iw(z(l,n.fill))??Oo,f=ow(l,e,n,d,r,i,s,u,c);if(!f)return null;let{made:h,peak:p,image:$}=f,g={...n,stem:h.stem,fill:h.fill,...nw(i.colors,i.hue,u,p),blur:s,window:d,...c?{cut:`${Sd(e,n.key)}.cut.png`}:{}};if(u==="original")delete g.tone;else delete g.peak;if(c&&$)H(z(l,`${Sd(e,n.key)}.cut.png`),nd(ni($)));if(h.stem===n.stem)return g;if(be(n)!==u)Cx(l,e,n);Td(l,h.files);let b=Pd(l,n);Io(l,g,be(n)===u?b:{...b,opacity:void 0},o,a);let y=z(l,`${n.stem}.off.conf`);if(Md(y))mx(y,z(l,`${g.stem}.off.conf`));return g}function aw(t,e,n,r,i,s,o){let a=D(t),c=n.window??iw(z(a,n.fill))??Oo;return ow(a,e,n,c,r,i,s,o,!1)!==null}function Hd(t,e){let n=D(t),r=vt(n),i=new Set,s=[];for(let{name:o,picture:a}of e){let c=r.palettes[o],u=c?.pictures.findIndex((d)=>d.key===a.key)??-1,l=c?.pictures[u];if(!c||!l)continue;if(c.pictures[u]=a,i.add(o),l.stem!==a.stem)s.push(l.stem)}if(i.size===0)return;fs(n,r,[...i]);for(let o of s)Rd(n,o)}function cw(t,e,n){return t.replace(/^background-image-opacity = (\S+)$/m,(r,i)=>Number(i)===e?`background-image-opacity = ${n}`:r)}function uw(t,e,n){let r=z(t,`${e.stem}.tune.conf`),i=hr(r);if(i!==void 0)H(r,cw(i,e.opacity,n));return{...e,opacity:n}}function Lx(t,e,n,r){if(n.tone===r.color)return uw(t,n,r.opacity);let i=Xb(t,n.stem).filter((a)=>a.endsWith(".png")).map((a)=>{let c=new Uint8Array(us(z(t,a)));return[a,_a(c,r.color)??ri(ni(At(c)),r.color)]}),s=(a)=>i.find(([c])=>c===a)?.[1]??new Uint8Array,o=`${Qt(e)}.${Wb("sha1").update(n.key).update(s(`${n.stem}.png`)).update(s(n.fill)).digest("hex").slice(0,8)}`;Td(t,i.map(([a,c])=>[o+a.slice(n.stem.length),c]));for(let a of["tune","off"]){let c=hr(z(t,`${n.stem}.${a}.conf`));if(c!==void 0)H(z(t,`${o}.${a}.conf`),cw(c.split(n.stem).join(o),n.opacity,r.opacity))}return{...n,stem:o,fill:o+n.fill.slice(n.stem.length),opacity:r.opacity,tone:r.color}}function rc(t,e){if(be(t)==="original")return t.peak!==void 0&&ls(e.colors,t.peak)!==t.opacity;return t.tone!==void 0&&(t.tone!==e.hue.color||t.opacity!==e.hue.opacity)}function lw(t,e){let n=D(t),r=vt(n),i=[],s=[];for(let[o,a]of Object.entries(r.palettes)){let c=e.get(o);if(!c||!a.pictures.some((u)=>rc(u,c)))continue;a.pictures=a.pictures.map((u)=>{if(!rc(u,c))return u;let l=be(u)==="original"?uw(n,u,ls(c.colors,u.peak)):Lx(n,o,u,c.hue);if(l.stem!==u.stem)s.push(u.stem);return l}),i.push(o)}if(i.length>0){fs(n,r,i);for(let o of s)Rd(n,o)}return i}function Te(t){let{slot:e,color:n,opacity:r}=an({name:t.name,background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selectionBackground,ansi:t.ansi,waived:t.waive},t.signatureSlots);return{name:t.name,...t.base?{base:t.base}:{},group:t.group,...t.native?{native:t.native}:{},...t.nativeNames?{nativeNames:t.nativeNames}:{},...t.lead?{lead:!0}:{},order:t.order,ansiSource:t.ansiSource,...t.booru?{booru:t.booru}:{},...t.booruSites?{booruSites:t.booruSites}:{},...t.role==="default"?{default:!0}:{},background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selectionBackground,signature:t.signature,signatureSlots:t.signatureSlots,ansi:t.ansi,gate:Xe(t),...t.waive.length>0?{waived:t.waive}:{},backdrop:{slot:e,color:n,opacity:r},...t.pictures?{pictures:t.pictures}:{}}}function We(t){return{name:t.name,...t.base?{base:t.base}:{},group:t.group,...t.native?{native:t.native}:{},...t.nativeNames?{nativeNames:t.nativeNames}:{},lead:t.lead===!0,order:t.order,...t.default?{role:"default"}:{},ansiSource:t.ansiSource,...t.booru?{booru:t.booru}:{},...t.booruSites?{booruSites:t.booruSites}:{},background:t.background,foreground:t.foreground,cursor:t.cursor,selectionBackground:t.selection,ansi:t.ansi,signature:t.signature,signatureSlots:t.signatureSlots,ghostty:{iconGhost:t.cursor,iconScreen:[t.cursor,t.selection,t.background]},waive:t.waived??[],...t.pictures?{pictures:t.pictures}:{}}}var jx=6,Gx=["ansi1","ansi2","ansi4","ansi3","ansi5","ansi6"];function ac(t){let e=(s)=>s.startsWith("ansi")?t.ansi[Number(s.slice(4))]:s==="foreground"?t.foreground:s==="cursor"?t.cursor:s==="selection"?t.selection:void 0,n=(s)=>s.startsWith("ansi")?`ansi${Number(s.slice(4))%8}`:s,r=new Set,i=[];for(let s of["foreground",...t.signatureSlots,...Gx]){let o=e(s);if(i.length===jx||!o||r.has(n(s))||i.includes(o))continue;r.add(n(s)),i.push(o)}return i}function Et(t){return t.filter((e)=>e.default!==!0)}function ps(){return{version:Tt.version,gate:he,placement:Rn,palettes:[]}}import{existsSync as _x,readFileSync as lc,statSync as dw}from"node:fs";import{homedir as ws}from"node:os";import{join as bs}from"node:path";var Bx=["core","kowiki","unlicensed"],Wx=["ko","ja","en","zh","other"],mw=["keys","keyAt","ownAt","owners","cards","cardAt","ranks","tags","tagAt","tagCard"],pw="TTNI";function pr(t=ws()){return bs(process.env.XDG_CACHE_HOME??bs(t,".cache"),"ttheme","aninames")}var Ux=/[ァ-ヶ]/g,Kx=/[\s\p{P}\p{S}]+/gu;function uc(t){return t.normalize("NFKC").toLowerCase().replace(Ux,(e)=>String.fromCharCode(e.charCodeAt(0)-96)).replace(Kx,"")}function Ld(t){return t.length>=2||/[\p{Script=Han}\p{Script=Hangul}\p{Script=Hiragana}]/u.test(t)}function gw(t){let e=pr(t);return Bx.map((n)=>bs(e,`ttheme-${n}.json`)).filter((n)=>_x(n))}var zx=6;function bw(t){return[`format ${zx}`,...t.map((e)=>`${e}:${dw(e).size}:${dw(e).mtimeMs}`)].join("|")}function Dx(t){try{return JSON.parse(lc(t,"utf8"))}catch{return{}}}function qx(t){let e=new Map;for(let i of t)for(let[s,o]of Object.entries(Dx(i))){let a=e.get(s)??{tags:new Set,names:[],japanese:[],generated:[],rank:0,weight:0,posts:0};a.posts=Math.max(a.posts,o.posts??0),a.generated.push(...o.generated??[]),a.japanese.push(...o.names?.ja??[]),a.tag??=o.tag;for(let c of o.danbooru??[])a.tags.add(c);for(let c of Wx)a.names.push(...o.names?.[c]??[]);if(o.rank!==void 0){let c=o.weight??1;a.rank=(a.rank*a.weight+o.rank*c)/(a.weight+c),a.weight+=c}e.set(s,a)}let n=[],r=Math.log1p([...e.values()].reduce((i,s)=>Math.max(i,s.posts),1));for(let i of e.values()){if(i.tags.size===0)continue;let s=[...i.tags];n.push({tag:i.tag&&i.tags.has(i.tag)?i.tag:s[0],tags:s,names:[...new Set(i.names)],japanese:[...new Set(i.japanese)],generated:[...new Set(i.generated)],rank:i.posts>0?Math.log1p(i.posts)/r:i.rank})}return n}function No(t,e){let n=new t(e.length);return n.set(e),n}function Ad(t){let e=[0];for(let n of t)e.push(e.at(-1)+n.length);return{bytes:Buffer.concat(t),at:No(Uint32Array,e)}}function Yx(t,e){let n=qx(t),r=new Map,i=(S,E,I)=>{let N=r.get(S),R=E*4+I;if(!N)r.set(S,[R]);else if(N.at(-1)>>>2!==E)N.push(R);else if(N.at(-1)<R)N[N.length-1]=R};n.forEach((S,E)=>{let I=[...S.names,...S.tags.map((N)=>N.replaceAll("_"," "))];for(let[N,R]of[[I,1],[S.generated,0]])for(let F of N){let j=uc(F);if(j&&Ld(j))i(j,E,2|R);let B=F.split(/[\s・·_]+/);if(B.length<2)continue;for(let X of B){let U=uc(X);if(U&&Ld(U))i(U,E,R)}}});let s=[...r.keys()].sort(),o=[0],a=[];for(let S of s){for(let E of r.get(S)??[])a.push(E);o.push(a.length)}let c=n.flatMap((S,E)=>S.tags.map((I)=>[I,E])).sort(([S],[E])=>S<E?-1:S>E?1:0),u=Ad(s.map((S)=>Buffer.from(S))),l=Ad(n.map((S)=>Buffer.from(JSON.stringify([S.tag,S.tags,S.names,S.japanese,S.generated])))),d=Ad(c.map(([S])=>Buffer.from(S))),f={keys:u.bytes,keyAt:u.at,ownAt:No(Uint32Array,o),owners:No(Uint32Array,a),cards:l.bytes,cardAt:l.at,ranks:No(Float32Array,n.map((S)=>S.rank)),tags:d.bytes,tagAt:d.at,tagCard:No(Uint32Array,c.map(([,S])=>S))},h=mw.map((S)=>{let E=f[S];return Buffer.from(E.buffer,E.byteOffset,E.byteLength)}),p=0,$=h.map((S)=>{let E=[p,S.length];return p+=Math.ceil(S.length/4)*4,E}),g=Buffer.from(JSON.stringify({stamp:e,sections:$})),b=Math.ceil((8+g.length)/4)*4,y=Buffer.alloc(b+p);y.write(pw,0,"latin1"),y.writeUInt32LE(g.length,4),g.copy(y,8);for(let[S,E]of h.entries())E.copy(y,b+($[S]?.[0]??0));return y}function fw(t,e,n,r){let i=e.byteOffset+n;if(i%4===0)return new t(e.buffer,i,r/4);return new t(e.buffer.slice(i,i+r),0,r/4)}function hw(t,e){if(t.toString("latin1",0,4)!==pw)return;let n=t.readUInt32LE(4),r=JSON.parse(t.toString("utf8",8,8+n));if(r.stamp!==e)return;let i=Math.ceil((8+n)/4)*4,s=(c)=>{let[u,l]=r.sections[mw.indexOf(c)];return[i+u,l]},o=(c)=>{let[u,l]=s(c);return t.subarray(u,u+l)},a=(c)=>fw(Uint32Array,t,...s(c));return{keys:o("keys"),keyAt:a("keyAt"),ownAt:a("ownAt"),owners:a("owners"),cards:o("cards"),cardAt:a("cardAt"),ranks:fw(Float32Array,t,...s("ranks")),tags:o("tags"),tagAt:a("tagAt"),tagCard:a("tagCard")}}var Fd;function jd(t){try{let e=gw(t);if(e.length===0)return;let n=bw(e);if(Fd?.stamp===n)return Fd.index;let r=bs(pr(t),"index.bin"),i;try{i=hw(lc(r),n)}catch{}if(!i){let s=Yx(e,n);try{H(r,s)}catch{}i=hw(s,n)}if(i)Fd={stamp:n,index:i};return i}catch{return}}function ww(t,e){let[n,r,i,s,o]=JSON.parse(t.cards.toString("utf8",t.cardAt[e],t.cardAt[e+1]));return{tag:n,tags:r,names:i,japanese:s,generated:o,rank:t.ranks[e]??0}}function $w(t,e,n,r){let i=0,s=n;while(i<s){let o=i+s>>1;if(t.toString("utf8",e[o],e[o+1])<r)i=o+1;else s=o}return i}function kw(t,e){let n=Buffer.from(e),r=t.tagCard.length,i=$w(t.tags,t.tagAt,r,e);if(i>=r||t.tags.compare(n,0,n.length,t.tagAt[i],t.tagAt[i+1])!==0)return;return t.tagCard[i]}var Cd=/\s*[((][^()()]*[))]$/u,cc={ko:4,en:4,ja:5,zh:3};function Jx(t){if(!t)return[];let e=/\p{Script=Hangul}/u,n=/^[\p{Script=Latin}\p{N}\s.'’-]+$/u,r=new Set([...t.names,...t.generated].filter((d)=>!Cd.test(d))),i=(d)=>!Cd.test(d)||!r.has(d.replace(Cd,"")),s=t.names.filter(i),o=s.filter((d)=>e.test(d)),a=[...o,...t.generated.slice(0,o.length>0?0:2)],c=s.filter((d)=>n.test(d)),u=t.japanese.filter(i),l=s.filter((d)=>!e.test(d)&&!n.test(d)&&!u.includes(d));return[...new Set([...a.slice(0,cc.ko),...c.slice(0,cc.en),...u.slice(0,cc.ja),...l.slice(0,cc.zh)])]}var gs;function dc(t,e=ws()){if(!t)return[];if(!gs)try{gs=JSON.parse(lc(bs(pr(e),"aliases.json"),"utf8")).tags}catch{gs={}}return gs[t]??[]}function Gd(t,e=ws()){try{return Vx(t,e)}catch{return new Map}}function Vx(t,e){let n=new Map,r=gw(e);if(r.length===0||t.length===0)return n;let i=bw(r),s=bs(pr(e),"aliases.json"),o;try{o=JSON.parse(lc(s,"utf8"))}catch{}if(o?.stamp===i&&t.every((l)=>(l in o.tags))){gs=o.tags;for(let l of t)n.set(l,o.tags[l]??[]);return n}let a=jd(e);if(!a)return n;let c=new Set([...t,...o?.stamp===i?Object.keys(o.tags):[]]),u={};for(let l of c){let d=kw(a,l);u[l]=d===void 0?[]:Jx(ww(a,d))}try{H(s,`${JSON.stringify({stamp:i,tags:u})}
248
+ `)}catch{}gs=u;for(let l of t)n.set(l,u[l]??[]);return n}function ui(t,e=ws()){Gd(t.flatMap((n)=>n.booru?[n.booru]:[]),e)}var Zx=0.25,Qx=0.1;function yw(t,e,n=new Set,r=ws()){let i=uc(t);if(!i||!Ld(i))return[];let s=jd(r);if(!s)return[];let o=Buffer.from(i),a=s.ownAt.length-1,c=new Set([...n].flatMap((l)=>kw(s,l)??[])),u=new Map;for(let l=$w(s.keys,s.keyAt,a,i);l<a;l++){let d=s.keyAt[l],f=s.keyAt[l+1]-d;if(f<o.length||s.keys.compare(o,0,o.length,d,d+o.length)!==0)break;let h=f===o.length;for(let p=s.ownAt[l];p<s.ownAt[l+1];p++){let $=s.owners[p],g=$>>>2,b=h?Math.max(0,($&2?2:1)-($&1?0:1)):0,y=(s.ranks[g]??0)+Zx*b+(c.has(g)?Qx:0);if((u.get(g)?.score??-1)<y)u.set(g,{score:y,key:l})}}return[...u].sort(([,l],[,d])=>d.score-l.score).slice(0,e).map(([l,{key:d}])=>{let f=ww(s,l),h=s.keys.toString("utf8",s.keyAt[d],s.keyAt[d+1]);return{tag:f.tags.find((p)=>n.has(p))??f.tag,name:[...f.names,...f.generated].find((p)=>uc(p).includes(h))??f.tag.replaceAll("_"," ")}})}function fc(t=ws()){jd(t)}import{existsSync as s2,readdirSync as Iw,readFileSync as o2}from"node:fs";import{basename as xw,join as Ro}from"node:path";import{existsSync as Xx,readFileSync as vw}from"node:fs";import{homedir as Sw}from"node:os";import{isAbsolute as Ew,join as li,resolve as t2}from"node:path";var q="official",cn="ttheme-market.json",$s="ttheme-market",e2=/^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,38}$/i,n2=/^[\w.-]{1,100}$/,r2=/^\w[\w.+/-]{0,199}$/;function br(t){return li(t,"ttheme","installed.json")}function Bt(t){return t??[q]}function ks(t){try{let{markets:e}=JSON.parse(vw(br(t),"utf8"));return Bt(Array.isArray(e)?e.filter((n)=>typeof n==="string"):void 0)}catch{return[q]}}function ut(t){return Ew(t)}function $e(t){return t!==q&&!ut(t)}function gr(t){let e=t.indexOf("#");return $e(t)&&e>=0?t.slice(0,e):t}function _d(t){let e=t.indexOf("#");return $e(t)&&e>=0?t.slice(e+1):void 0}function ys(t,e){return gr(t)===gr(e)}function wr(t,e){return!ut(t)&&(e?.[t]??t===q)}function i2(t){return!r2.test(t)||t.includes("..")||t.includes("//")||/(?:[./]|\.lock)$/.test(t)}function $r(t,e=process.cwd()){if(t===q)return q;if(t==="~"||t.startsWith("~/"))return li(Sw(),t.slice(1));if(t.startsWith(".")||Ew(t))return t2(e,t);let[n="",r,...i]=t.split("#"),[s,o,...a]=n.replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,"").split("/");if(!s||!e2.test(s)||!o||!n2.test(o)||a.length>0||i.length>0||r!==void 0&&i2(r))throw Error(`${t} is not a market — give a repository (alice/ttheme-dust, #v1 pins a tag or branch) or a path (./my-market)`);return`${s.toLowerCase()}/${o}${r===void 0?"":`#${r}`}`}function Mw(t){let e=_d(t)?.split("/").map(encodeURIComponent).join("/")??"HEAD";return`https://raw.githubusercontent.com/${gr(t)}/${e}/${cn}`}function Ow(t){return t.slice(0,t.indexOf("/"))}function Bd(t){return li(t,"ttheme","markets")}function Ue(t,e){return li(Bd(t),`${gr(e).replace("/","--")}.json`)}function hc(t){return li(t,"ttheme","market")}function Wd(t,e){return li(hc(t),e)}function Ud(t,e){if(typeof t!=="string"||typeof e!=="string")return'needs an "owner" (the GitHub handle) and a "name"';return Be(`${t}@${e}/x`)}function ke({owner:t,name:e}){return`${t}@${e}`}function un(t){let e=li(t,cn);if(!Xx(e))throw Error(`${t} has no ${cn} — \`ttheme market init ${t}\` makes one`);let n;try{n=JSON.parse(vw(e,"utf8"))}catch{throw Error(`${e} is not valid JSON`)}let r=Ud(n.owner,n.name);if(r)throw Error(`${e} ${r}`);return{owner:n.owner,name:n.name}}function st(t){if(t===q)return"the ttheme catalog";if(!ut(t))return`github.com/${t}`;let e=Sw();return t===e||t.startsWith(`${e}/`)?`~${t.slice(e.length)}`:t}var Tn="tt1:",Nw=["background","foreground","cursor","selection",...Array.from({length:16},(t,e)=>`ansi${e}`)];function di(t,e=!0){return ks(t).filter(ut).flatMap((n)=>{try{let r=un(n);return[{dir:n,...r,id:ke(r)}]}catch(r){if(e)process.stderr.write(`ttheme: skipping the market at ${n} — ${r.message}
249
+ `);return[]}})}function mc(t){return Ro(t,"palettes")}function kr(t){let e=mc(t);if(!s2(e))return[];let n=[],r=[];for(let i of Iw(e,{withFileTypes:!0}).sort((s,o)=>s.name<o.name?-1:1)){if(i.name.startsWith("."))continue;if(i.isDirectory()){for(let s of Iw(Ro(e,i.name)).sort())if(s.endsWith(".toml"))n.push({path:Ro(e,i.name,s),slug:xw(s,".toml"),catalog:i.name})}else if(i.name.endsWith(".toml"))r.push({path:Ro(e,i.name),slug:xw(i.name,".toml")})}return[...n,...r]}function To(t,e){let n=e.get(t.slug);if(n)return`${t.slug} is also ${n.catalog?`in ${n.catalog}`:"outside a catalog"} — a palette name is used once in a market`;let r=t.catalog===void 0?void 0:Mo(t.catalog);return r?`the catalog folder ${JSON.stringify(t.catalog)} ${r}`:void 0}function Kd(t,e){let n=ct(e);if(!n)throw Error(`${e} is an official palette — yours are named <you>@<market>/<palette>`);let r=di(t,!1).find((s)=>s.id===n);if(!r)throw Error(`${n} is not a local market — \`ttheme market add <dir>\` adds the folder that holds it`);let i=dr(e);return kr(r.dir).find((s)=>s.slug===i)?.path??Ro(mc(r.dir),`${i}.toml`)}function a2(t,e){let n=new Map;for(let i of e)if(i.group!==vo&&!n.has(i.group)){let s=e.find((o)=>o.group===i.group&&o.lead)?.name??"";n.set(i.group,{name:i.group,...i.native?{native:i.native}:{},lead:s})}let r=new Map(e.filter((i)=>!i.default&&!ct(i.name)).map((i)=>[i.name,{group:i.group,order:i.order}]));return{name:t,groups:n,bases:r,open:!0}}function ye(t,e,n){let r=dr(t),{native:i,...s}=wd(`${r}.toml`,e,a2(r,n)),o=ct(t);return{...s,name:t,...o?{group:o,lead:!1}:{}}}function yr(t,e,n,r=!0){let i=new Map;return kr(t).flatMap((s)=>{try{let o=To(s,i);if(o)throw Error(o);i.set(s.slug,s);let a=Te(ye(`${e}/${s.slug}`,o2(s.path,"utf8"),n));return[s.catalog?{...a,catalog:s.catalog}:a]}catch(o){if(r)process.stderr.write(`ttheme: skipping ${s.path} — ${o.message}
250
+ `);return[]}})}function pc(t,e,n=!0){return di(t,n).flatMap(({dir:r,id:i})=>yr(r,i,e,n))}function zd(t,e=t.name,n){return{name:e,...t.base?{base:t.base}:{},...t.group!==vo?{group:t.group}:{},ansiSource:t.ansiSource,...t.booru?{booru:t.booru}:{},...t.booruSites?{booruSites:t.booruSites}:{},signature:t.signatureSlots,background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selection,ansi:t.ansi,...t.waived&&t.waived.length>0?{waive:t.waived,reason:n??"kept from the palette"}:{},...t.pictures?{pictures:t.pictures}:{}}}var Mt=(t)=>JSON.stringify(t);function Rw(t){return["[[picture]]",`site = ${Mt(t.site)}`,`id = ${t.id}`,...t.size===void 0?[]:[`size = ${typeof t.size==="number"?t.size:Mt(t.size)}`],...t.position===void 0?[]:[`position = ${Mt(t.position)}`],...t.opacity===void 0?[]:[`opacity = ${t.opacity}`]]}function Tw(t,e){return e.length===0?t:`${t.replace(/\n*$/,`
331
251
  `)}${e.map((n)=>`
332
- ${Tp(n).join(`
252
+ ${Rw(n).join(`
253
+ `)}
254
+ `).join("")}`}function Dd(t){let e=["[meta]",`name = ${Mt(dr(t.name))}`,...t.base?[`base = ${Mt(t.base)}`]:[],...t.group?[`group = ${Mt(t.group)}`]:[],...t.ansiSource?[`ansi_source = ${Mt(t.ansiSource)}`]:[],...t.booru?[`booru = ${Mt(t.booru)}`]:[],`signature = [${t.signature.map(Mt).join(", ")}]`,...t.booruSites?["","[meta.booru_sites]",...Object.entries(t.booruSites).map(([n,r])=>`${n} = [${r.map(Mt).join(", ")}]`)]:[],"","[colors]",`background = ${Mt(t.background)}`,`foreground = ${Mt(t.foreground)}`,`cursor = ${Mt(t.cursor)}`,`selection_background = ${Mt(t.selection)}`,"ansi = [",...t.ansi.slice(0,8).map((n)=>` ${Mt(n)},`),"",...t.ansi.slice(8).map((n)=>` ${Mt(n)},`),"]"];if(t.waive&&t.waive.length>0)e.push("","[contrast]",`waive = [${t.waive.map(Mt).join(", ")}]`,`reason = ${Mt(t.reason??"")}`);for(let n of t.pictures??[])e.push("",...Rw(n));return`${e.join(`
333
255
  `)}
334
- `).join("")}`}function kl(t){let e=["[meta]",`name = ${bt(mi(t.name))}`,...t.base?[`base = ${bt(t.base)}`]:[],...t.group?[`group = ${bt(t.group)}`]:[],...t.ansiSource?[`ansi_source = ${bt(t.ansiSource)}`]:[],...t.booru?[`booru = ${bt(t.booru)}`]:[],`signature = [${t.signature.map(bt).join(", ")}]`,...t.booruSites?["","[meta.booru_sites]",...Object.entries(t.booruSites).map(([n,r])=>`${n} = [${r.map(bt).join(", ")}]`)]:[],"","[colors]",`background = ${bt(t.background)}`,`foreground = ${bt(t.foreground)}`,`cursor = ${bt(t.cursor)}`,`selection_background = ${bt(t.selection)}`,"ansi = [",...t.ansi.slice(0,8).map((n)=>` ${bt(n)},`),"",...t.ansi.slice(8).map((n)=>` ${bt(n)},`),"]"];if(t.waive&&t.waive.length>0)e.push("","[contrast]",`waive = [${t.waive.map(bt).join(", ")}]`,`reason = ${bt(t.reason??"")}`);for(let n of t.pictures??[])e.push("",...Tp(n));return`${e.join(`
256
+ `}class Pw{bytes=[];u8(t){this.bytes.push(t&255)}u16(t){this.u8(t>>8),this.u8(t)}u32(t){this.u16(Math.floor(t/65536)),this.u16(t%65536)}str(t=""){let e=new TextEncoder().encode(t);if(e.length>255)throw Error(`"${t}" is too long to share`);this.u8(e.length),this.bytes.push(...e)}color(t){let e=Number.parseInt(t.slice(1),16);this.u8(e>>16),this.u8(e>>8),this.u8(e)}done(){return Buffer.from(this.bytes).toString("base64url")}}class Hw{at=0;bytes;constructor(t){this.bytes=t}u8(){let t=this.bytes[this.at++];if(t===void 0)throw Error("the share code is cut short");return t}u16(){return this.u8()*256+this.u8()}u32(){return this.u16()*65536+this.u16()}str(){let t=this.u8(),e=this.bytes.subarray(this.at,this.at+t);if(e.length!==t)throw Error("the share code is cut short");return this.at+=t,new TextDecoder("utf-8",{fatal:!0}).decode(e)}color(){return`#${[this.u8(),this.u8(),this.u8()].map((t)=>t.toString(16).padStart(2,"0")).join("")}`}end(){if(this.at!==this.bytes.length)throw Error("the share code has bytes left over")}}function Aw(t){let e=new Pw;e.str(t.name);for(let r of[t.background,t.foreground,t.cursor,t.selection,...t.ansi])e.color(r);for(let r of t.signature)e.u8(Nw.indexOf(r));e.str(t.base),e.str(t.group),e.str(t.ansiSource),e.str(t.booru),e.u16((t.waive??[]).reduce((r,i)=>r|1<<Ll.indexOf(i),0)),e.str(t.waive&&t.waive.length>0?t.reason:"");let n=t.pictures??[];e.u8(n.length);for(let r of n)e.u8(Y.findIndex((i)=>i.key===r.site)),e.u32(r.id),e.u16(r.size===void 0?0:r.size==="fill"?1:r.size),e.u8(r.position===void 0?0:_t.indexOf(r.position)+1),e.u16(r.opacity===void 0?0:Math.round(r.opacity*1000)+1);return`${Tn}${e.done()}`}function Fw(t){if(!t.startsWith(Tn))throw Error(`a share code starts with ${Tn}`);let e=t.slice(Tn.length);if(!/^[A-Za-z0-9_-]+$/.test(e))throw Error("the share code holds characters it never uses — was it copied whole?");let n=new Hw(new Uint8Array(Buffer.from(e,"base64url"))),r=n.str(),[i,s,o,a,...c]=Array.from({length:20},()=>n.color()),u=[n.u8(),n.u8(),n.u8()].map((y)=>Nw[y]??`slot${y}`),l=n.str(),d=n.str(),f=n.str(),h=n.str(),p=n.u16(),$=n.str(),g=Ll.filter((y,S)=>p&1<<S),b=Array.from({length:n.u8()},()=>{let y=Y[n.u8()]?.key??"unknown",S=n.u32(),E=n.u16(),I=n.u8(),N=n.u16();return{site:y,id:S,...E===1?{size:"fill"}:E>1?{size:E}:{},...I>0?{position:_t[I-1]??"unknown"}:{},...N>0?{opacity:(N-1)/1000}:{}}});if(n.end(),![i,s,o,a,...c].every(ne))throw Error("the share code holds a color that is not one");return{name:r,...l?{base:l}:{},...d?{group:d}:{},...f?{ansiSource:f}:{},...h?{booru:h}:{},signature:u,background:i,foreground:s,cursor:o,selection:a,ansi:c,...g.length>0?{waive:g,reason:$}:{},...b.length>0?{pictures:b}:{}}}function qd(t){return{background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selectionBackground,ansi:t.ansi}}function Yd(t,e){let n=t.indexOf("ansi = ["),r=t.indexOf("]",n);if(n<0||r<0)throw Error("no ansi = [...] list to rewrite");let i=0,s=t.slice(n,r).replace(/"#[0-9a-fA-F]{6}"/g,()=>Mt(e.ansi[i++]));return[["background",e.background],["foreground",e.foreground],["cursor",e.cursor],["selection_background",e.selection]].reduce((a,[c,u])=>a.replace(new RegExp(`^(${c}\\s*=\\s*)"#[0-9a-fA-F]{6}"`,"m"),(l,d)=>`${d}${Mt(u)}`),t.slice(0,n)+s+t.slice(r))}function Cw(t,e){return t.replace(/^(signature\s*=\s*)\[[^\]]*\]/m,(n,r)=>`${r}[${e.map(Mt).join(", ")}]`)}function Po(t){let e=Xe(We(t)),n=new Set(t.waived??[]),r=Math.max(...he.map((i)=>i.label.length));return he.map((i,s)=>{let o=e[s],a=n.has(i.rule)||Number.isNaN(o)||(i.min===void 0||o>=i.min)&&(i.max===void 0||o<=i.max),c=i.min!==void 0?`≥ ${i.min}`:i.max!==void 0?`≤ ${i.max}`:"",u=Number.isNaN(o)?"—":Number.isInteger(o)?String(o):o.toFixed(2);return` ${a?"✓":"✗"} ${i.label.padEnd(r)} ${u.padStart(6)} ${c}${n.has(i.rule)?" waived":""}`})}import{existsSync as c2,readFileSync as u2,rmSync as l2}from"node:fs";import{join as d2}from"node:path";var bc=["background","foreground","cursor","selection",...Array.from({length:16},(t,e)=>`ansi${e}`)],f2=1;function Lw(t){return d2(t,"ttheme","tone.json")}function jw(t){return bc.includes(t)}function Pn(t){let e=Lw(t);if(!c2(e))return{};let n;try{n=JSON.parse(u2(e,"utf8"))}catch{return{}}let r=n?.palettes;if(typeof r!=="object"||r===null)return{};let i={};for(let[s,o]of Object.entries(r)){if(typeof o!=="object"||o===null)continue;let a={};for(let[c,u]of Object.entries(o))if(jw(c)&&typeof u==="string"&&ne(u.toLowerCase()))a[c]=u.toLowerCase();if(Object.keys(a).length>0)i[s]=a}return i}function Gw(t,e){let n=Lw(t),r=Object.fromEntries(Object.entries(e).filter(([,i])=>Object.keys(i).length>0));if(Object.keys(r).length===0){l2(n,{force:!0});return}H(n,`${JSON.stringify({version:f2,palettes:r},null,2)}
257
+ `)}function gc(t,e){if(e==="background"||e==="foreground"||e==="cursor"||e==="selection")return t[e];return t.ansi[Number(e.slice(4))]}function Jd(t,e){let n={};return bc.forEach((r,i)=>{let s=e[i].toLowerCase();if(s!==gc(t,r).toLowerCase())n[r]=s}),n}function vs(t,e){if(!e)return t;let n=(u)=>e[u]===void 0||e[u]===gc(t,u).toLowerCase();if(bc.every(n))return t;let r=(u)=>e[u]??gc(t,u),i={background:r("background"),foreground:r("foreground"),cursor:r("cursor"),selection:r("selection"),ansi:bc.slice(4).map(r)},s=t.signatureSlots.map((u)=>jw(u)?r(u):gc(i,u)),o={...t,...i,signature:s},a=We(o),c=an({name:o.name,background:i.background,foreground:i.foreground,cursor:i.cursor,selection:i.selection,ansi:i.ansi,waived:a.waive},o.signatureSlots);return{...o,gate:Xe(a),backdrop:c}}function wc(t,e){return Object.keys(e).length===0?t:t.map((n)=>vs(n,e[n.name]))}function _w(t,e,n){let r={...t};if(Object.keys(n).length===0)delete r[e];else r[e]=n;return r}var Uw="https://kecan0406.github.io/ttheme/manifest.json",h2=20000;function ve(t){return Ww(t,"ttheme","catalog.json")}function $c(t,e){H(ve(t),`${JSON.stringify(e,null,2)}
258
+ `)}function lt(t,e=!0){let n=ks(t),r=ve(t),i=ps();if(n.includes(q)){if(!Bw(r))throw Error(`no catalog at ${r} — run \`ttheme init\` first`);i=ln(Vd(r,"utf8"))}let s=n.filter($e).flatMap((o)=>m2(t,o,e));return{...i,palettes:[...i.palettes,...s]}}function vr(t,e){return Zd(Vd(Ue(t,e),"utf8"))}function Ss(t,e){return ke({owner:Ow(t),name:e.name})}function m2(t,e,n){let r=Ue(t,e);if(!Bw(r))return[];try{let i=vr(t,e);return kc(i,Ss(e,i))}catch(i){if(n)process.stderr.write(`ttheme: skipping ${r} — ${i.message}
259
+ `);return[]}}function Zd(t){let e=ln(t),n=Ud(e.owner,e.name);if(n)throw Error(`market index ${n}`);let r=e.palettes.find((i)=>ct(i.name)!==void 0);if(r)throw Error(`market index names ${r.name} with its market — its entries are bare palette names`);return e}function kc(t,e){return t.palettes.map(({lead:n,default:r,native:i,...s})=>({...s,name:`${e}/${s.name}`,group:e}))}function ln(t){let e;try{e=JSON.parse(t)}catch{throw Error("catalog is not valid JSON")}let n=e;if(typeof n?.version!=="string"||!Array.isArray(n.palettes))throw Error("catalog has no version or palettes");for(let r of n.palettes){let i=Kw(r);if(i)throw Error(`catalog entry ${JSON.stringify(r?.name)} ${i}`)}return n}function Kw(t){if(typeof t?.name!=="string"||!Array.isArray(t.ansi)||t.ansi.length!==16)return"is missing name or its 16 ANSI colors";let e=Be(t.name)??(t.base===void 0?void 0:Be(t.base));if(e)return e;if(![t.background,t.foreground,t.cursor,t.selection,...t.ansi].every((n)=>typeof n==="string"&&ne(n)))return'holds a color that is not "#rrggbb"';for(let n of[t.group,t.native??"-",t.catalog??"-",t.ansiSource]){let r=typeof n==="string"?Mo(n):"has a field that is not text";if(r)return r}return}function zw(t){return Ww(t,"ttheme","kept.json")}function yc(t,e){H(zw(t),`${JSON.stringify({palettes:e},null,2)}
260
+ `)}function Hn(t){try{let{palettes:e}=JSON.parse(Vd(zw(t),"utf8"));return Array.isArray(e)?e.filter((n)=>Kw(n)===void 0):[]}catch{return[]}}function fi(t,e,n=!0){let r=[...e.palettes,...pc(t,e.palettes,n)],i=new Set(r.map((s)=>s.name));return{...e,palettes:[...r,...Hn(t).filter((s)=>!i.has(s.name))]}}function Ot(t,e,n=!0){let r=fi(t,e,n);return{...r,palettes:wc(r.palettes,Pn(t))}}function ie(t){return Ot(t,lt(t))}class vc extends Error{}class Sc extends Error{}async function Ho(t,e,n=h2,r){let i;try{let s=AbortSignal.timeout(n);i=await fetch(t,{signal:r?AbortSignal.any([s,r]):s})}catch(s){throw Error(`cannot reach ${t} — ${s instanceof Error?s.message:String(s)}`)}if(i.status===404)throw new vc(`nothing at ${t}`);if(i.status===403||i.status===429)throw new Sc(`${new URL(t).host} is turning requests away for now (${i.status}) — try again in a minute`);if(!i.ok)throw Error(`${t} answered ${i.status}`);return e(await i.text())}function Ao(t){let e=new Set(t.waived??[]),n=t.gate??Xe(We(t));return he.flatMap((r,i)=>{let s=n[i];if(e.has(r.rule)||typeof s!=="number"||Number.isNaN(s))return[];if(r.min!==void 0&&s<r.min)return[`${r.label} ${s} < ${r.min}`];if(r.max!==void 0&&s>r.max)return[`${r.label} ${s} > ${r.max}`];return[]})}function An(t,e){let n=t.find((r)=>r.name===e);if(!n)throw Error(`no palette named ${e} in the catalog — ${Qd(t,[e])}`);return n}function Qd(t,e){let n=e.map((o)=>o.toLowerCase()),r=t.filter((o)=>n.some((a)=>o.name.includes(a))),i=t.filter((o)=>!r.includes(o)&&n.some((a)=>o.group.toLowerCase().includes(a))),s=[...r,...i].map((o)=>o.name).slice(0,3);return s.length>0?`did you mean: ${s.join(", ")}?`:"`ttheme list` shows what is there"}function Dw(t,e){let n=e.toLowerCase();return t.filter((r)=>[r.name,r.group,r.native??"",r.ansiSource,...r.nativeNames??[],...dc(r.booru)].some((i)=>i.toLowerCase().includes(n)))}function qw(t,e,n){let r=n.toLowerCase(),i=(s)=>s.name===e.name?0:s.group===e.group?1:2;return t.filter((s)=>s.booru?.toLowerCase().includes(r)).map((s,o)=>({p:s,at:o})).sort((s,o)=>i(s.p)-i(o.p)||s.at-o.at).map(({p:s})=>s)}function Yw(t,e){return t.booruSites?.[e]??(t.booru?[t.booru]:[])}var p2=9999,Es;function se(t,e){if(!Es||e===""||Es.length>=p2)return e;return`\x1B[?${Es.push(t)}y${e}\x1B[?0y`}function Ec(t){let e=Es,n=[];Es=n;try{return{drawn:t(),targets:n}}finally{Es=e}}function g2(t){let e=t.slice(3,-1);return t.startsWith("\x1B[?")&&t.endsWith("y")&&/^\d{1,4}$/.test(e)?Number(e):void 0}function b2(t){let e=t.slice(2,-1);return t.startsWith("\x1B[")&&t.endsWith("G")&&/^\d*$/.test(e)?Math.max(1,Number(e||1))-1:void 0}function w2(t,e,n){if(!t.includes("\x1B[?"))return{text:t,zones:[]};let r=[],i=[],s="",o=0,a="",c=()=>{let l=i.pop();if(l&&o>l.col)r.push({row:e,col:l.col,width:o-l.col,height:1,target:l.target})},u=0;while(u<t.length){let l=t.indexOf("\x1B",u);if(l!==u){let p=l===-1?t.length:l;a+=t.slice(u,p),s+=t.slice(u,p),u=p;continue}let d=t.slice(u,u+(Pl(t,u)||1));u+=d.length;let f=g2(d),h=f===void 0?b2(d):void 0;if(f===void 0&&h===void 0){s+=d;continue}if(o+=Q(a),a="",h!==void 0)o=h,s+=d;else if(f===0)c();else if(f!==void 0)i.push({target:n[f-1],col:o})}o+=Q(a);while(i.length>0)c();return{text:s,zones:r}}function Mc(t,e){let n=[];return{lines:t.map((i,s)=>{let o=w2(i,s,e);return n.push(...o.zones),o.text}),zones:n}}function Jw(t,e,n){let r=n-t.col,i=e-t.row;return{target:t.target,x:r,y:i,width:t.width,height:t.height,inside:r>=0&&r<t.width&&i>=0&&i<t.height}}function $2(t,e,n){let r;for(let i of t)if(e>=i.row&&e<i.row+i.height&&n>=i.col&&n<i.col+i.width&&(!r||i.width*i.height<=r.width*r.height))r=i;return r}var k2={space:" ",enter:"enter",esc:"esc",tab:"tab",bksp:"backspace","←":"left","→":"right"};function Xd(t){let e=/^(ctrl|alt)\+([a-z])$/.exec(t);if(e)return`${e[1]}-${e[2]}`;return k2[t]??([...t].length===1&&t!==" "?t:void 0)}function dn(t,e){let n=Xd(t);return n?se({kind:"key",key:n},e):e}class Fo{zones=[];held;point(t){if(t.action==="drag"||t.action==="release"){let n=this.held;if(t.action==="release")this.held=void 0;return n&&Jw(n,t.row,t.col)}let e=$2(this.zones,t.row,t.col);if(t.action==="press")this.held=t.button==="left"?e:void 0;return e&&Jw(e,t.row,t.col)}drop(){this.held=void 0}}var Fn=[{name:"preview",title:"Preview"},{name:"browse",title:"Browse"}],Oc=10,Ic=20,y2="\x1B[7;1m\x1B[36m";function Vw(t){return Fn.find((e)=>e.name===t.TTHEME_HUB)?.name}function Zw(t,e){let n=Fn.findIndex((r)=>r.name===t);return Ic+(n+e+Fn.length)%Fn.length+1}function Qw(t){return Ic+Fn.findIndex((e)=>e.name===t)+1}function tf(t,e){let n=Fn.map(({name:i,title:s})=>{let o={kind:"hub",tab:i};if(!e)return se(o,i===t?`[${s}]`:` ${s} `);return i===t?`${y2}${se(o,` ${s} `)}${Pt}`:`${P}${se(o,` ${s} `)}${Pt}`}),r="tab next";return` ${n.join(" ")} ${e?`${P}tab next${Pt}`:"tab next"}`}import{execFileSync as aT}from"node:child_process";import{existsSync as vh,mkdirSync as dk,readdirSync as cT,readFileSync as Eh,rmSync as fk}from"node:fs";import{basename as uT,join as Ii,relative as lT}from"node:path";import{styleText as Pc}from"node:util";import{stdout as u0,stdin as N2}from"node:process";import R2 from"node:readline";var xc="\x1B",r0="›",v2=39,nf="\x07",i0="[",S2="]",s0="m",rf=`${S2}8;;`,Xw=new RegExp(`(?:\\${i0}(?<code>\\d+)m|\\${rf}(?<uri>.*)${nf})`,"y"),t0=(t)=>{if(t>=30&&t<=37)return 39;if(t>=90&&t<=97)return 39;if(t>=40&&t<=47)return 49;if(t>=100&&t<=107)return 49;if(t===1||t===2)return 22;if(t===3)return 23;if(t===4)return 24;if(t===7)return 27;if(t===8)return 28;if(t===9)return 29;if(t===0)return 0;return},e0=(t)=>`${xc}${i0}${t}${s0}`,n0=(t)=>`${xc}${rf}${t}${nf}`,ef=(t,e,n)=>{let r=e[Symbol.iterator](),i=!1,s=!1,o=t.at(-1),a=o===void 0?0:Q(o),c=r.next(),u=r.next(),l=0;while(!c.done){let d=c.value,f=Q(d);if(a+f<=n)t[t.length-1]+=d;else t.push(d),a=0;if(d===xc||d===r0)i=!0,s=e.startsWith(rf,l+1);if(i){if(s){if(d===nf)i=!1,s=!1}else if(d===s0)i=!1}else if(a+=f,a===n&&!u.done)t.push(""),a=0;c=u,u=r.next(),l+=d.length}if(o=t.at(-1),!a&&o!==void 0&&o.length&&t.length>1)t[t.length-2]+=t.pop()},E2=(t)=>{let e=t.split(" "),n=e.length;while(n){if(Q(e[n-1]))break;n--}if(n===e.length)return t;return e.slice(0,n).join(" ")+e.slice(n).join("")},M2=(t,e,n={})=>{if(n.trim!==!1&&t.trim()==="")return"";let r="",i,s,o=t.split(" "),a=[""],c=0;for(let d=0;d<o.length;d++){let f=o[d];if(n.trim!==!1){let p=a.at(-1)??"",$=p.trimStart();if(p.length!==$.length)a[a.length-1]=$,c=Q($)}if(d!==0){if(c>=e&&(n.wordWrap===!1||n.trim===!1))a.push(""),c=0;if(c||n.trim===!1)a[a.length-1]+=" ",c++}let h=Q(f);if(n.hard&&h>e){let p=e-c,$=1+Math.floor((h-p-1)/e);if(Math.floor((h-1)/e)<$)a.push("");ef(a,f,e),c=Q(a.at(-1)??"");continue}if(c+h>e&&c&&h){if(n.wordWrap===!1&&c<e){ef(a,f,e),c=Q(a.at(-1)??"");continue}a.push(""),c=0}if(c+h>e&&n.wordWrap===!1){ef(a,f,e),c=Q(a.at(-1)??"");continue}a[a.length-1]+=f,c+=h}if(n.trim!==!1)a=a.map((d)=>E2(d));let u=a.join(`
261
+ `),l=!1;for(let d=0;d<u.length;d++){let f=u[d];if(r+=f,!l){if(l=f>="\uD800"&&f<="\uDBFF",l)continue}else l=!1;if(f===xc||f===r0){Xw.lastIndex=d+1;let p=Xw.exec(u)?.groups;if(p?.code!==void 0){let $=Number.parseFloat(p.code);i=$===v2?void 0:$}else if(p?.uri!==void 0)s=p.uri.length===0?void 0:p.uri}if(u[d+1]===`
262
+ `){if(s)r+=n0("");let h=i?t0(i):void 0;if(i&&h)r+=e0(h)}else if(f===`
263
+ `){if(i&&t0(i))r+=e0(i);if(s)r+=n0(s)}}return r},O2=/\r?\n/;function Sr(t,e,n){return String(t).normalize().split(O2).map((r)=>M2(r,e,n)).join(`
264
+ `)}var Se=Rl(of(),1);function Cn(t,e,n){if(!n.some((o)=>!o.disabled))return t;let r=t+e,i=Math.max(n.length-1,0),s=r<0?i:r>i?0:r;return n[s]?.disabled?Cn(s,e<0?-1:1,n):s}function Nc(t,e,n,r){let i=r.split(`
265
+ `),s=0,o=t;for(let c of i){if(o<=c.length)break;o-=c.length+1,s++}for(s=Math.max(0,Math.min(i.length-1,s+n)),o=Math.min(o,i[s].length)+e;o<0&&s>0;)s--,o+=i[s].length+1;for(;o>i[s].length&&s<i.length-1;)o-=i[s].length+1,s++;o=Math.max(0,Math.min(i[s].length,o));let a=0;for(let c=0;c<s;c++)a+=i[c].length+1;return a+o}var T2=["up","down","left","right","space","enter","cancel"],P2=["January","February","March","April","May","June","July","August","September","October","November","December"],Wt={actions:new Set(T2),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...P2],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(t,e)=>`There are only ${t} days in ${e}`,afterMin:(t)=>`Date must be on or after ${t.toISOString().slice(0,10)}`,beforeMax:(t)=>`Date must be on or before ${t.toISOString().slice(0,10)}`}}};function l0(t,e){if(typeof t=="string")return Wt.aliases.get(t)===e;for(let n of t)if(n!==void 0&&l0(n,e))return!0;return!1}function H2(t,e){if(t===e)return;let n=t.split(`
266
+ `),r=e.split(`
267
+ `),i=Math.max(n.length,r.length),s=[];for(let o=0;o<i;o++)n[o]!==r[o]&&s.push(o);return{lines:s,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}var n5=globalThis.process.platform.startsWith("win"),cf=Symbol("clack:cancel");function oe(t){return t===cf}function Rc(t,e){let n=t;n.isTTY&&n.setRawMode(e)}var Hc=(t)=>("columns"in t)&&typeof t.columns=="number"?t.columns:80,lf=(t)=>("rows"in t)&&typeof t.rows=="number"?t.rows:20;function Er(t,e,n,r=n,i=n,s){let o=Hc(t??u0);return Sr(e,o-n.length,{hard:!0,trim:!1}).split(`
268
+ `).map((a,c,u)=>{let l=s?s(a,c):a;return c===0?`${r}${l}`:c===u.length-1?`${i}${l}`:`${n}${l}`}).join(`
269
+ `)}function d0(t,e){if("~standard"in t){let n=t["~standard"].validate(e);if(n instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return n.issues?.at(0)?.message}return t(e)}class Ln{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(t,e=!0){let{input:n=N2,output:r=u0,render:i,signal:s,...o}=t;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=e,this._abortSignal=s,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(t,e){let n=this._subscribers.get(t)??[];n.push(e),this._subscribers.set(t,n)}on(t,e){this.setSubscriber(t,{cb:e})}once(t,e){this.setSubscriber(t,{cb:e,once:!0})}emit(t,...e){let n=this._subscribers.get(t)??[],r=[];for(let i of n)i.cb(...e),i.once&&r.push(()=>n.splice(n.indexOf(i),1));for(let i of r)i()}prompt(){return new Promise((t)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(cf);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=R2.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),Rc(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(Se.cursor.show),this.output.off("resize",this.render),Rc(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(Se.cursor.show),this.output.off("resize",this.render),Rc(this.input,!1),t(cf)})})}_isActionKey(t,e){return t==="\t"}_shouldSubmit(t,e){return!0}_setValue(t){this.value=t,this.emit("value",this.value)}_setUserInput(t,e){this.userInput=t??"",this.emit("userInput",this.userInput),e&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(t,e){if(this._track&&e.name!=="return"&&(e.name&&this._isActionKey(t,e)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),e?.name&&(!this._track&&Wt.aliases.has(e.name)&&this.emit("cursor",Wt.aliases.get(e.name)),Wt.actions.has(e.name)&&this.emit("cursor",e.name)),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),this.emit("key",t,e),e?.name==="return"&&this._shouldSubmit(t,e)){if(this.opts.validate){let n=d0(this.opts.validate,this.value);n&&(this.error=n instanceof Error?n.message:n,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}l0([t,e?.name,e?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
270
+ `),Rc(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t=Sr(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
271
+ `).length-1;this.output.write(Se.cursor.move(-999,t*-1))}render(){let t=Sr(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(Se.cursor.hide);else{let e=H2(this._prevFrame,t),n=lf(this.output);if(this.restoreCursor(),e){let r=Math.max(0,e.numLinesAfter-n),i=Math.max(0,e.numLinesBefore-n),s=e.lines.find((o)=>o>=r);if(s===void 0){this._prevFrame=t;return}if(e.lines.length===1){this.output.write(Se.cursor.move(0,s-i)),this.output.write(Se.erase.lines(1));let o=t.split(`
272
+ `);this.output.write(o[s]),this._prevFrame=t,this.output.write(Se.cursor.move(0,o.length-s-1));return}else if(e.lines.length>1){if(r<i)s=r;else{let a=s-i;a>0&&this.output.write(Se.cursor.move(0,a))}this.output.write(Se.erase.down());let o=t.split(`
273
+ `).slice(s);this.output.write(o.join(`
274
+ `)),this._prevFrame=t;return}}this.output.write(Se.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}function A2(t,e){if(t===void 0||e.length===0)return 0;let n=e.findIndex((r)=>r.value===t);return n!==-1?n:0}function F2(t,e){return(e.label??String(e.value)).toLowerCase().includes(t.toLowerCase())}function C2(t,e){if(e)return t?e:e[0]}var L2=class extends Ln{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#e=0;#n="";#t;#s;#a;get cursor(){return this.#e}get userInputWithCursor(){if(!this.userInput)return Pc(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let e=this.userInput.slice(0,this.cursor),n=this.userInput.slice(this.cursor,this.cursor+1),r=this.userInput.slice(this.cursor+1);return`${e}${Pc("inverse",n)}${r}`}get options(){return typeof this.#s=="function"?this.#s():this.#s}constructor(e){super(e),this.#s=e.options,this.#a=e.placeholder;let n=this.options;this.filteredOptions=[...n],this.multiple=e.multiple===!0,this.#t=typeof e.options=="function"?e.filter:e.filter??F2;let r;if(e.initialValue&&Array.isArray(e.initialValue)?this.multiple?r=e.initialValue:r=e.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(r=[this.options[0]?.value]),r)for(let i of r){let s=n.findIndex((o)=>o.value===i);s!==-1&&(this.toggleSelected(i),this.#e=s)}this.focusedValue=this.options[this.#e]?.value,this.on("key",(i,s)=>this.#r(i,s)),this.on("userInput",(i)=>this.#i(i))}_isActionKey(e,n){return e==="\t"||this.multiple&&this.isNavigating&&n.name==="space"&&e!==void 0&&e!==""}#r(e,n){let r=n.name==="up",i=n.name==="down",s=n.name==="return",o=this.userInput===""||this.userInput==="\t",a=this.#a,c=this.options,u=a!==void 0&&a!==""&&c.some((l)=>!l.disabled&&(this.#t?this.#t(a,l):!0));if(n.name==="tab"&&o&&u){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(a,!0),this.isNavigating=!1;return}r||i?(this.#e=Cn(this.#e,r?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#e]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):s?this.value=C2(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(n.name==="tab"||this.isNavigating&&n.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(e){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(e)?this.selectedValues=this.selectedValues.filter((n)=>n!==e):this.selectedValues=[...this.selectedValues,e]:this.selectedValues=[e])}#i(e){if(e!==this.#n){this.#n=e;let n=this.options;e&&this.#t?this.filteredOptions=n.filter((s)=>this.#t?.(e,s)):this.filteredOptions=[...n];let r=A2(this.focusedValue,this.filteredOptions);this.#e=Cn(r,0,this.filteredOptions);let i=this.filteredOptions[this.#e];i&&!i.disabled?this.focusedValue=i.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};class df extends Ln{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(e)=>{this.output.write(Se.cursor.move(0,-1)),this.value=e,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var j2={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};function a0(t){return[...t].map((e)=>j2[e])}function G2(t){let e=new Intl.DateTimeFormat(t,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),n=[],r="/";for(let i of e)i.type==="literal"?r=i.value.trim()||i.value:(i.type==="year"||i.type==="month"||i.type==="day")&&n.push({type:i.type,len:i.type==="year"?4:2});return{segments:n,separator:r}}function af(t){return Number.parseInt((t||"0").replace(/_/g,"0"),10)||0}function Tc(t){return{year:af(t.year),month:af(t.month),day:af(t.day)}}function uf(t,e){return new Date(t||2001,e||1,0).getDate()}function f0(t){let{year:e,month:n,day:r}=Tc(t);if(!e||e<0||e>9999||!n||n<1||n>12||!r||r<1)return;let i=new Date(Date.UTC(e,n-1,r));if(!(i.getUTCFullYear()!==e||i.getUTCMonth()!==n-1||i.getUTCDate()!==r))return{year:e,month:n,day:r}}function c0(t){let e=f0(t);return e?new Date(Date.UTC(e.year,e.month-1,e.day)):void 0}function _2(t,e,n,r){let i=n?{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate()}:null,s=r?{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate()}:null;return t==="year"?{min:i?.year??1,max:s?.year??9999}:t==="month"?{min:i&&e.year===i.year?i.month:1,max:s&&e.year===s.year?s.month:12}:{min:i&&e.year===i.year&&e.month===i.month?i.day:1,max:s&&e.year===s.year&&e.month===s.month?s.day:uf(e.year,e.month)}}class h0 extends Ln{#e;#n;#t;#s;#a;#r={segmentIndex:0,positionInSegment:0};#i=!0;#o=null;inlineError="";get segmentCursor(){return{...this.#r}}get segmentValues(){return{...this.#t}}get segments(){return this.#e}get separator(){return this.#n}get formattedValue(){return this.#d(this.#t)}#d(t){return this.#e.map((e)=>t[e.type]).join(this.#n)}#c(){this._setUserInput(this.#d(this.#t)),this._setValue(c0(this.#t)??void 0)}constructor(t){let e=t.format?{segments:a0(t.format),separator:t.separator??"/"}:G2(t.locale),n=t.separator??e.separator,r=t.format?a0(t.format):e.segments,i=t.initialValue??t.defaultValue,s=i?{year:String(i.getUTCFullYear()).padStart(4,"0"),month:String(i.getUTCMonth()+1).padStart(2,"0"),day:String(i.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},o=r.map((a)=>s[a.type]).join(n);super({...t,initialUserInput:o},!1),this.#e=r,this.#n=n,this.#t=s,this.#s=t.minDate,this.#a=t.maxDate,this.#c(),this.on("cursor",(a)=>this.#m(a)),this.on("key",(a,c)=>this.#p(a,c)),this.on("finalize",()=>this.#g(t))}#u(){let t=Math.max(0,Math.min(this.#r.segmentIndex,this.#e.length-1)),e=this.#e[t];if(e)return this.#r.positionInSegment=Math.max(0,Math.min(this.#r.positionInSegment,e.len-1)),{segment:e,index:t}}#l(t){this.inlineError="",this.#o=null;let e=this.#u();e&&(this.#r.segmentIndex=Math.max(0,Math.min(this.#e.length-1,e.index+t)),this.#r.positionInSegment=0,this.#i=!0)}#f(t){let e=this.#u();if(!e)return;let{segment:n}=e,r=this.#t[n.type],i=!r||r.replace(/_/g,"")==="",s=Number.parseInt((r||"0").replace(/_/g,"0"),10)||0,o=_2(n.type,Tc(this.#t),this.#s,this.#a),a;i?a=t===1?o.min:o.max:a=Math.max(Math.min(o.max,s+t),o.min),this.#t={...this.#t,[n.type]:a.toString().padStart(n.len,"0")},this.#i=!0,this.#o=null,this.#c()}#m(t){if(t)switch(t){case"right":return this.#l(1);case"left":return this.#l(-1);case"up":return this.#f(1);case"down":return this.#f(-1)}}#p(t,e){if(e?.name==="backspace"||e?.sequence===""||e?.sequence==="\b"||t===""||t==="\b"){this.inlineError="";let n=this.#u();if(!n)return;if(!this.#t[n.segment.type].replace(/_/g,"")){this.#l(-1);return}this.#t[n.segment.type]="_".repeat(n.segment.len),this.#i=!0,this.#r.positionInSegment=0,this.#c();return}if(e?.name==="tab"){this.inlineError="";let n=this.#u();if(!n)return;let r=e.shift?-1:1,i=n.index+r;i>=0&&i<this.#e.length&&(this.#r.segmentIndex=i,this.#r.positionInSegment=0,this.#i=!0);return}if(t&&/^[0-9]$/.test(t)){let n=this.#u();if(!n)return;let{segment:r}=n,i=!this.#t[r.type].replace(/_/g,"");if(this.#i&&this.#o!==null&&!i){let f=this.#o+t,h={...this.#t,[r.type]:f},p=this.#h(h,r);if(p){this.inlineError=p,this.#o=null,this.#i=!1;return}this.inlineError="",this.#t[r.type]=f,this.#o=null,this.#i=!1,this.#c(),n.index<this.#e.length-1&&(this.#r.segmentIndex=n.index+1,this.#r.positionInSegment=0,this.#i=!0);return}this.#i&&!i&&(this.#t[r.type]="_".repeat(r.len),this.#r.positionInSegment=0),this.#i=!1,this.#o=null;let s=this.#t[r.type],o=s.indexOf("_"),a=o>=0?o:Math.min(this.#r.positionInSegment,r.len-1);if(a<0||a>=r.len)return;let c=s.slice(0,a)+t+s.slice(a+1),u=!1;if(a===0&&s==="__"&&(r.type==="month"||r.type==="day")){let f=Number.parseInt(t,10);c=`0${t}`,u=f<=(r.type==="month"?1:2)}if(r.type==="year"&&(c=(s.replace(/_/g,"")+t).padStart(r.len,"_")),!c.includes("_")){let f={...this.#t,[r.type]:c},h=this.#h(f,r);if(h){this.inlineError=h;return}}this.inlineError="",this.#t[r.type]=c;let l=c.includes("_")?void 0:f0(this.#t);if(l){let{year:f,month:h}=l,p=uf(f,h);this.#t={year:String(Math.max(0,Math.min(9999,f))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,h))).padStart(2,"0"),day:String(Math.max(1,Math.min(p,l.day))).padStart(2,"0")}}this.#c();let d=c.indexOf("_");u?(this.#i=!0,this.#o=t):d>=0?this.#r.positionInSegment=d:o>=0&&n.index<this.#e.length-1?(this.#r.segmentIndex=n.index+1,this.#r.positionInSegment=0,this.#i=!0):this.#r.positionInSegment=Math.min(a+1,r.len-1)}}#h(t,e){let{month:n,day:r}=Tc(t);if(e.type==="month"&&(n<0||n>12))return Wt.date.messages.invalidMonth;if(e.type==="day"&&(r<0||r>31))return Wt.date.messages.invalidDay(31,"any month")}#g(t){let{year:e,month:n,day:r}=Tc(this.#t);if(e&&n&&r){let i=uf(e,n);this.#t={...this.#t,day:String(Math.min(r,i)).padStart(2,"0")}}this.value=c0(this.#t)??t.defaultValue??void 0}}var B2=class extends Ln{options;cursor=0;#e;getGroupItems(e){return this.options.filter((n)=>n.group===e)}isGroupSelected(e){let n=this.getGroupItems(e),r=this.value;return r===void 0?!1:n.every((i)=>r.includes(i.value))}toggleValue(){let e=this.options[this.cursor];if(e!==void 0)if(this.value===void 0&&(this.value=[]),e.group===!0){let n=e.value,r=this.getGroupItems(n);this.isGroupSelected(n)?this.value=this.value.filter((i)=>r.findIndex((s)=>s.value===i)===-1):this.value=[...this.value,...r.map((i)=>i.value)],this.value=Array.from(new Set(this.value))}else{let n=this.value.includes(e.value);this.value=n?this.value.filter((r)=>r!==e.value):[...this.value,e.value]}}constructor(e){super(e,!1);let{options:n}=e;this.#e=e.selectableGroups!==!1,this.options=Object.entries(n).flatMap(([r,i])=>[{value:r,group:!0,label:r},...i.map((s)=>({...s,group:r}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:r})=>r===e.cursorAt),this.#e?0:1),this.on("cursor",(r)=>{switch(r){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let i=this.options[this.cursor]?.group===!0;!this.#e&&i&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let i=this.options[this.cursor]?.group===!0;!this.#e&&i&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},W2=new Set(["up","down","left","right"]);class m0 extends Ln{#e=!1;#n;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${t}█`;let e=t.slice(0,this.cursor),n=t.slice(this.cursor,this.cursor+1),r=t.slice(this.cursor+1);return n===`
275
+ `?`${e}█
276
+ ${r}`:`${e}${Pc("inverse",n)}${r}`}get cursor(){return this._cursor}#t(t){if(this.userInput.length===0){this._setUserInput(t);return}this._setUserInput(this.userInput.slice(0,this.cursor)+t+this.userInput.slice(this.cursor))}#s(t){let e=this.value??"";switch(t){case"up":this._cursor=Nc(this._cursor,0,-1,e);return;case"down":this._cursor=Nc(this._cursor,0,1,e);return;case"left":this._cursor=Nc(this._cursor,-1,0,e);return;case"right":this._cursor=Nc(this._cursor,1,0,e);return}}_shouldSubmit(t,e){if(this.#n)return this.focused==="submit"?!0:(this.#t(`
277
+ `),this._cursor++,!1);let n=this.#e;return this.#e=!0,n&&this.cursor===this.userInput.length?(this.userInput[this.cursor-1]===`
278
+ `&&(this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--),!0):(this.#t(`
279
+ `),this._cursor++,!1)}constructor(t){let e=t.initialUserInput??t.initialValue;super({...t,initialUserInput:e},!1),e!==void 0&&(this._cursor=e.length),this.#n=t.showSubmit??!1,this.on("key",(n,r)=>{if(r?.name&&W2.has(r.name)){this.#e=!1,this.#s(r.name);return}if(n==="\t"&&this.#n){this.focused=this.focused==="editor"?"submit":"editor";return}if(r?.name!=="return"){if(this.#e=!1,r?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(r?.name==="delete"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}n&&(this.#n&&this.focused==="submit"&&(this.focused="editor"),this.#t(n??""),this._cursor++)}}),this.on("userInput",(n)=>{this._setValue(n)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}}class ff extends Ln{options;cursor=0;get _value(){return this.options[this.cursor]?.value}get _enabledOptions(){return this.options.filter((t)=>t.disabled!==!0)}toggleAll(){let t=this._enabledOptions,e=this.value!==void 0&&this.value.length===t.length;this.value=e?[]:t.map((n)=>n.value)}toggleInvert(){let t=this.value;if(!t)return;let e=this._enabledOptions.filter((n)=>!t.includes(n.value));this.value=e.map((n)=>n.value)}toggleValue(){this.value===void 0&&(this.value=[]);let t=this.value.includes(this._value);this.value=t?this.value.filter((e)=>e!==this._value):[...this.value,this._value]}constructor(t){super(t,!1),this.options=t.options,this.value=[...t.initialValues??[]];let e=Math.max(this.options.findIndex(({value:n})=>n===t.cursorAt),0);this.cursor=this.options[e]?.disabled?Cn(e,1,this.options):e,this.on("key",(n,r)=>{r.name==="a"&&this.toggleAll(),r.name==="i"&&this.toggleInvert()}),this.on("cursor",(n)=>{switch(n){case"left":case"up":this.cursor=Cn(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=Cn(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}}var p0=class extends Ln{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let e=this._selectedValue;this.value=e===void 0?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;let n=this.options.findIndex(({value:i})=>i===e.initialValue),r=n===-1?0:n;this.cursor=this.options[r]?.disabled?Cn(r,1,this.options):r,this.changeValue(),this.on("cursor",(i)=>{switch(i){case"left":case"up":this.cursor=Cn(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=Cn(this.cursor,1,this.options);break}this.changeValue()})}};class hf extends Ln{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}█`;let e=t.slice(0,this.cursor),n=t.slice(this.cursor,this.cursor+1),r=t.slice(this.cursor+1);return`${e}${Pc("inverse",n)}${r}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",(e)=>{this._setValue(e)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}}import{styleText as M,stripVTControlCharacters as l5}from"node:util";import Pe from"node:process";var k0=Rl(of(),1);function U2(){if(Pe.platform!=="win32")return Pe.env.TERM!=="linux";return Boolean(Pe.env.CI)||Boolean(Pe.env.WT_SESSION)||Boolean(Pe.env.TERMINUS_SUBLIME)||Pe.env.ConEmuTask==="{cmd::Cmder}"||Pe.env.TERM_PROGRAM==="Terminus-Sublime"||Pe.env.TERM_PROGRAM==="vscode"||Pe.env.TERM==="xterm-256color"||Pe.env.TERM==="alacritty"||Pe.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var K2=U2();var ft=(t,e)=>K2?t:e,z2=ft("◆","*"),D2=ft("■","x"),q2=ft("▲","x"),gf=ft("◇","o"),Y2=ft("┌","T"),et=ft("│","|"),jn=ft("└","—"),m5=ft("┐","T"),p5=ft("┘","—"),mf=ft("●",">"),Fc=ft("○"," "),J2=ft("◻","[•]"),g0=ft("◼","[+]"),b0=ft("◻","[ ]"),g5=ft("▪","•"),w0=ft("─","-"),V2=ft("╮","+"),Z2=ft("├","+"),Q2=ft("╯","+"),X2=ft("╰","+"),b5=ft("╭","+"),tN=ft("●","•"),eN=ft("◆","*"),nN=ft("▲","!"),rN=ft("■","x"),Cc=(t)=>{switch(t){case"initial":case"active":return M("cyan",z2);case"cancel":return M("red",D2);case"error":return M("yellow",q2);case"submit":return M("green",gf)}},y0=(t)=>{switch(t){case"initial":case"active":return M("cyan",et);case"cancel":return M("red",et);case"error":return M("yellow",et);case"submit":return M("green",et)}};function v0(t,e){let n=[`${e?`${M("cyan",et)} `:""}${t.join(" • ")}`];return e&&n.push(M("cyan",jn)),n}var $0=(t,e,n,r,i,s=!1)=>{let o=e,a=0;if(s)for(let c=r-1;c>=n;c--){let u=t[c];if(u&&(o-=u.length),a++,o<=i)break}else for(let c=n;c<r;c++){let u=t[c];if(u&&(o-=u.length),a++,o<=i)break}return{lineCount:o,removals:a}},pf=({cursor:t,options:e,style:n,output:r=process.stdout,maxItems:i=Number.POSITIVE_INFINITY,columnPadding:s=0,rowPadding:o=4})=>{let a=Hc(r)-s,c=lf(r),u=M("dim","..."),l=Math.max(c-o,0),d=Math.max(Math.min(i,l),5),f=0;t>=d-3&&(f=Math.max(Math.min(t-d+3,e.length-d),0));let h=d<e.length&&f>0,p=d<e.length&&f+d<e.length,$=Math.min(f+d,e.length),g=[],b=0;h&&b++,p&&b++;let y=f+(h?1:0),S=$-(p?1:0);for(let I=y;I<S;I++){let N=e[I],R=N?n(N,I===t):"",F=Sr(R,a,{hard:!0,trim:!1}).split(`
280
+ `);g.push(F),b+=F.length}if(b>l){let I=0,N=0,R=b,F=t-y,j=l,B=()=>$0(g,R,0,F,j),X=()=>$0(g,R,F+1,g.length,j,!0);h?({lineCount:R,removals:I}=B(),R>j&&(p||(j-=1),{lineCount:R,removals:N}=X())):(p||(j-=1),{lineCount:R,removals:N}=X(),R>j&&(j-=1,{lineCount:R,removals:I}=B())),I>0&&(h=!0,g.splice(0,I)),N>0&&(p=!0,g.splice(g.length-N,N))}let E=[];h&&E.push(u);for(let I of g)for(let N of I)E.push(N);return p&&E.push(u),E};var Ke=(t)=>{let e=t.active??"Yes",n=t.inactive??"No";return new df({active:e,inactive:n,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue??!0,render(){let r=t.withGuide??Wt.withGuide,i=`${Cc(this.state)} `,s=r?`${M("gray",et)} `:"",o=Er(t.output,t.message,s,i),a=`${r?`${M("gray",et)}
281
+ `:""}${o}
282
+ `,c=this.value?e:n;switch(this.state){case"submit":{let u=r?`${M("gray",et)} `:"";return`${a}${u}${M("dim",c)}`}case"cancel":{let u=r?`${M("gray",et)} `:"";return`${a}${u}${M(["strikethrough","dim"],c)}${r?`
283
+ ${M("gray",et)}`:""}`}default:{let u=r?`${M("cyan",et)} `:"",l=r?M("cyan",jn):"";return`${a}${u}${this.value?`${M("green",mf)} ${e}`:`${M("dim",Fc)} ${M("dim",e)}`}${t.vertical?r?`
284
+ ${M("cyan",et)} `:`
285
+ `:` ${M("dim","/")} `}${this.value?`${M("dim",Fc)} ${M("dim",n)}`:`${M("green",mf)} ${n}`}
286
+ ${l}
287
+ `}}}}).prompt()};var iN=[`${M("dim","↑/↓")} to navigate`,`${M("dim","Space:")} select`,`${M("dim","Enter:")} confirm`],Co=(t,e)=>t.split(`
288
+ `).map((n)=>e(n)).join(`
289
+ `),S0=(t)=>{let e=(i,s)=>{let o=i.label??String(i.value);return s==="disabled"?`${M("gray",b0)} ${Co(o,(a)=>M(["strikethrough","gray"],a))}${i.hint?` ${M("dim",`(${i.hint??"disabled"})`)}`:""}`:s==="active"?`${M("cyan",J2)} ${o}${i.hint?` ${M("dim",`(${i.hint})`)}`:""}`:s==="selected"?`${M("green",g0)} ${Co(o,(a)=>M("dim",a))}${i.hint?` ${M("dim",`(${i.hint})`)}`:""}`:s==="cancelled"?`${Co(o,(a)=>M(["strikethrough","dim"],a))}`:s==="active-selected"?`${M("green",g0)} ${o}${i.hint?` ${M("dim",`(${i.hint})`)}`:""}`:s==="submitted"?`${Co(o,(a)=>M("dim",a))}`:`${M("dim",b0)} ${Co(o,(a)=>M("dim",a))}`},n=t.required??!0,r=t.showInstructions??!0;return new ff({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValues:t.initialValues,required:n,cursorAt:t.cursorAt,validate(i){if(n&&(i===void 0||i.length===0))return`Please select at least one option.
290
+ ${M("reset",M("dim",`Press ${M(["gray","bgWhite","inverse"]," space ")} to select, ${M("gray",M("bgWhite",M("inverse"," enter ")))} to submit`))}`},render(){let i=t.withGuide??Wt.withGuide,s=Er(t.output,t.message,i?`${y0(this.state)} `:"",`${Cc(this.state)} `),o=`${i?`${M("gray",et)}
291
+ `:""}${s}
292
+ `,a=this.value??[],c=(u,l)=>{if(u.disabled)return e(u,"disabled");let d=a.includes(u.value);return l&&d?e(u,"active-selected"):d?e(u,"selected"):e(u,l?"active":"inactive")};switch(this.state){case"submit":{let u=this.options.filter(({value:d})=>a.includes(d)).map((d)=>e(d,"submitted")).join(M("dim",", "))||M("dim","none"),l=Er(t.output,u,i?`${M("gray",et)} `:"");return`${o}${l}`}case"cancel":{let u=this.options.filter(({value:d})=>a.includes(d)).map((d)=>e(d,"cancelled")).join(M("dim",", "));if(u.trim()==="")return`${o}${M("gray",et)}`;let l=Er(t.output,u,i?`${M("gray",et)} `:"");return`${o}${l}${i?`
293
+ ${M("gray",et)}`:""}`}case"error":{let u=i?`${M("yellow",et)} `:"",l=this.error.split(`
294
+ `).map((h,p)=>p===0?`${i?`${M("yellow",jn)} `:""}${M("yellow",h)}`:` ${h}`).join(`
295
+ `),d=o.split(`
296
+ `).length,f=l.split(`
297
+ `).length+1;return`${o}${u}${pf({output:t.output,options:this.options,cursor:this.cursor,maxItems:t.maxItems,columnPadding:u.length,rowPadding:d+f,style:c}).join(`
298
+ ${u}`)}
299
+ ${l}
300
+ `}default:{let u=i?`${M("cyan",et)} `:"",l=o.split(`
301
+ `).length,d=r?v0(iN,i):i?[M("cyan",jn)]:[],f=d.join(`
302
+ `),h=d.length+1;return`${o}${u}${pf({output:t.output,options:this.options,cursor:this.cursor,maxItems:t.maxItems,columnPadding:u.length,rowPadding:l+h,style:c}).join(`
303
+ ${u}`)}
304
+ ${f}
305
+ `}}}}).prompt()};var Mr={message:(t=[],{symbol:e=M("gray",et),secondarySymbol:n=M("gray",et),output:r=process.stdout,spacing:i=1,withGuide:s}={})=>{let o=[],a=s??Wt.withGuide,c=a?n:"",u=a?`${e} `:"",l=a?`${n} `:"";for(let f=0;f<i;f++)o.push(c);let d=Array.isArray(t)?t:t.split(`
306
+ `);if(d.length>0){let[f,...h]=d;f.length>0?o.push(`${u}${f}`):o.push(a?e:"");for(let p of h)p.length>0?o.push(`${l}${p}`):o.push(a?n:"")}r.write(`${o.join(`
335
307
  `)}
336
- `}class Cp{bytes=[];u8(t){this.bytes.push(t&255)}u16(t){this.u8(t>>8),this.u8(t)}u32(t){this.u16(Math.floor(t/65536)),this.u16(t%65536)}str(t=""){let e=new TextEncoder().encode(t);if(e.length>255)throw Error(`"${t}" is too long to share`);this.u8(e.length),this.bytes.push(...e)}color(t){let e=Number.parseInt(t.slice(1),16);this.u8(e>>16),this.u8(e>>8),this.u8(e)}done(){return Buffer.from(this.bytes).toString("base64url")}}class jp{at=0;bytes;constructor(t){this.bytes=t}u8(){let t=this.bytes[this.at++];if(t===void 0)throw Error("the share code is cut short");return t}u16(){return this.u8()*256+this.u8()}u32(){return this.u16()*65536+this.u16()}str(){let t=this.u8(),e=this.bytes.subarray(this.at,this.at+t);if(e.length!==t)throw Error("the share code is cut short");return this.at+=t,new TextDecoder("utf-8",{fatal:!0}).decode(e)}color(){return`#${[this.u8(),this.u8(),this.u8()].map((t)=>t.toString(16).padStart(2,"0")).join("")}`}end(){if(this.at!==this.bytes.length)throw Error("the share code has bytes left over")}}function Gp(t){let e=new Cp;e.str(t.name);for(let r of[t.background,t.foreground,t.cursor,t.selection,...t.ansi])e.color(r);for(let r of t.signature)e.u8(Lp.indexOf(r));e.str(t.base),e.str(t.group),e.str(t.ansiSource),e.str(t.booru),e.u16((t.waive??[]).reduce((r,i)=>r|1<<pu.indexOf(i),0)),e.str(t.waive&&t.waive.length>0?t.reason:"");let n=t.pictures??[];e.u8(n.length);for(let r of n)e.u8(q.findIndex((i)=>i.key===r.site)),e.u32(r.id),e.u16(r.size===void 0?0:r.size==="fill"?1:r.size),e.u8(r.position===void 0?0:Qt.indexOf(r.position)+1),e.u16(r.opacity===void 0?0:Math.round(r.opacity*1000)+1);return`${fn}${e.done()}`}function Up(t){if(!t.startsWith(fn))throw Error(`a share code starts with ${fn}`);let e=t.slice(fn.length);if(!/^[A-Za-z0-9_-]+$/.test(e))throw Error("the share code holds characters it never uses — was it copied whole?");let n=new jp(new Uint8Array(Buffer.from(e,"base64url"))),r=n.str(),[i,o,s,a,...c]=Array.from({length:20},()=>n.color()),u=[n.u8(),n.u8(),n.u8()].map((v)=>Lp[v]??`slot${v}`),l=n.str(),f=n.str(),d=n.str(),m=n.str(),g=n.u16(),$=n.str(),w=pu.filter((v,R)=>g&1<<R),b=Array.from({length:n.u8()},()=>{let v=q[n.u8()]?.key??"unknown",R=n.u32(),S=n.u16(),I=n.u8(),P=n.u16();return{site:v,id:R,...S===1?{size:"fill"}:S>1?{size:S}:{},...I>0?{position:Qt[I-1]??"unknown"}:{},...P>0?{opacity:(P-1)/1000}:{}}});if(n.end(),![i,o,s,a,...c].every(Bt))throw Error("the share code holds a color that is not one");return{name:r,...l?{base:l}:{},...f?{group:f}:{},...d?{ansiSource:d}:{},...m?{booru:m}:{},signature:u,background:i,foreground:o,cursor:s,selection:a,ansi:c,...w.length>0?{waive:w,reason:$}:{},...b.length>0?{pictures:b}:{}}}function yl(t){return{background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selectionBackground,ansi:t.ansi}}function vl(t,e){let n=t.indexOf("ansi = ["),r=t.indexOf("]",n);if(n<0||r<0)throw Error("no ansi = [...] list to rewrite");let i=0,o=t.slice(n,r).replace(/"#[0-9a-fA-F]{6}"/g,()=>bt(e.ansi[i++]));return[["background",e.background],["foreground",e.foreground],["cursor",e.cursor],["selection_background",e.selection]].reduce((a,[c,u])=>a.replace(new RegExp(`^(${c}\\s*=\\s*)"#[0-9a-fA-F]{6}"`,"m"),(l,f)=>`${f}${bt(u)}`),t.slice(0,n)+o+t.slice(r))}function Wp(t,e){return t.replace(/^(signature\s*=\s*)\[[^\]]*\]/m,(n,r)=>`${r}[${e.map(bt).join(", ")}]`)}function No(t){let e=Le(Ee(t)),n=new Set(t.waived??[]),r=Math.max(...Dt.map((i)=>i.label.length));return Dt.map((i,o)=>{let s=e[o],a=n.has(i.rule)||Number.isNaN(s)||(i.min===void 0||s>=i.min)&&(i.max===void 0||s<=i.max),c=i.min!==void 0?`≥ ${i.min}`:i.max!==void 0?`≤ ${i.max}`:"",u=Number.isNaN(s)?"—":Number.isInteger(s)?String(s):s.toFixed(2);return` ${a?"✓":"✗"} ${i.label.padEnd(r)} ${u.padStart(6)} ${c}${n.has(i.rule)?" waived":""}`})}import{existsSync as d2,readFileSync as h2,rmSync as m2}from"node:fs";import{join as g2}from"node:path";var wa=["background","foreground","cursor","selection",...Array.from({length:16},(t,e)=>`ansi${e}`)],p2=1;function _p(t){return g2(t,"ttheme","tone.json")}function Bp(t){return wa.includes(t)}function dn(t){let e=_p(t);if(!d2(e))return{};let n;try{n=JSON.parse(h2(e,"utf8"))}catch{return{}}let r=n?.palettes;if(typeof r!=="object"||r===null)return{};let i={};for(let[o,s]of Object.entries(r)){if(typeof s!=="object"||s===null)continue;let a={};for(let[c,u]of Object.entries(s))if(Bp(c)&&typeof u==="string"&&Bt(u.toLowerCase()))a[c]=u.toLowerCase();if(Object.keys(a).length>0)i[o]=a}return i}function zp(t,e){let n=_p(t),r=Object.fromEntries(Object.entries(e).filter(([,i])=>Object.keys(i).length>0));if(Object.keys(r).length===0){m2(n,{force:!0});return}T(n,`${JSON.stringify({version:p2,palettes:r},null,2)}
337
- `)}function ba(t,e){if(e==="background"||e==="foreground"||e==="cursor"||e==="selection")return t[e];return t.ansi[Number(e.slice(4))]}function Kp(t,e){let n={};return wa.forEach((r,i)=>{let o=e[i].toLowerCase();if(o!==ba(t,r).toLowerCase())n[r]=o}),n}function Ro(t,e){if(!e)return t;let n=(u)=>e[u]===void 0||e[u]===ba(t,u).toLowerCase();if(wa.every(n))return t;let r=(u)=>e[u]??ba(t,u),i={background:r("background"),foreground:r("foreground"),cursor:r("cursor"),selection:r("selection"),ansi:wa.slice(4).map(r)},o=t.signatureSlots.map((u)=>Bp(u)?r(u):ba(i,u)),s={...t,...i,signature:o},a=Ee(s),c=Un({name:s.name,background:i.background,foreground:i.foreground,cursor:i.cursor,selection:i.selection,ansi:i.ansi,waived:a.waive},s.signatureSlots);return{...s,gate:Le(a),backdrop:c}}function $a(t,e){return Object.keys(e).length===0?t:t.map((n)=>Ro(n,e[n.name]))}function qp(t,e,n){let r={...t};if(Object.keys(n).length===0)delete r[e];else r[e]=n;return r}var Dp="https://kecan0406.github.io/ttheme/manifest.json",b2=20000;function Me(t){return Yp(t,"ttheme","catalog.json")}function ka(t,e){T(Me(t),`${JSON.stringify(e,null,2)}
338
- `)}function ct(t,e=!0){let n=vi(t),r=Me(t),i=Mo();if(n.includes(J)){if(!Jp(r))throw Error(`no catalog at ${r} — run \`ttheme init\` first`);i=ze(El(r,"utf8"))}let o=n.filter(Xt).flatMap((s)=>w2(t,s,e));return{...i,palettes:[...i.palettes,...o]}}function Jn(t,e){return Sl(El(Se(t,e),"utf8"))}function Si(t,e){return te({owner:Hp(t),name:e.name})}function w2(t,e,n){let r=Se(t,e);if(!Jp(r))return[];try{let i=Jn(t,e);return ya(i,Si(e,i))}catch(i){if(n)process.stderr.write(`ttheme: skipping ${r} — ${i.message}
339
- `);return[]}}function Sl(t){let e=ze(t),n=bl(e.owner,e.name);if(n)throw Error(`market index ${n}`);let r=e.palettes.find((i)=>rt(i.name)!==void 0);if(r)throw Error(`market index names ${r.name} with its market — its entries are bare palette names`);return e}function ya(t,e){return t.palettes.map(({lead:n,default:r,native:i,...o})=>({...o,name:`${e}/${o.name}`,group:e}))}function ze(t){let e;try{e=JSON.parse(t)}catch{throw Error("catalog is not valid JSON")}let n=e;if(typeof n?.version!=="string"||!Array.isArray(n.palettes))throw Error("catalog has no version or palettes");for(let r of n.palettes){let i=Vp(r);if(i)throw Error(`catalog entry ${JSON.stringify(r?.name)} ${i}`)}return n}function Vp(t){if(typeof t?.name!=="string"||!Array.isArray(t.ansi)||t.ansi.length!==16)return"is missing name or its 16 ANSI colors";let e=ke(t.name)??(t.base===void 0?void 0:ke(t.base));if(e)return e;if(![t.background,t.foreground,t.cursor,t.selection,...t.ansi].every((n)=>typeof n==="string"&&Bt(n)))return'holds a color that is not "#rrggbb"';for(let n of[t.group,t.native??"-",t.catalog??"-",t.ansiSource]){let r=typeof n==="string"?ko(n):"has a field that is not text";if(r)return r}return}function Zp(t){return Yp(t,"ttheme","kept.json")}function va(t,e){T(Zp(t),`${JSON.stringify({palettes:e},null,2)}
340
- `)}function hn(t){try{let{palettes:e}=JSON.parse(El(Zp(t),"utf8"));return Array.isArray(e)?e.filter((n)=>Vp(n)===void 0):[]}catch{return[]}}function Rr(t,e,n=!0){let r=[...e.palettes,...pa(t,e.palettes,n)],i=new Set(r.map((o)=>o.name));return{...e,palettes:[...r,...hn(t).filter((o)=>!i.has(o.name))]}}function wt(t,e,n=!0){let r=Rr(t,e,n);return{...r,palettes:$a(r.palettes,dn(t))}}function Ie(t){return wt(t,ct(t))}class Ea extends Error{}class Sa extends Error{}async function Po(t,e,n=b2,r){let i;try{let o=AbortSignal.timeout(n);i=await fetch(t,{signal:r?AbortSignal.any([o,r]):o})}catch(o){throw Error(`cannot reach ${t} — ${o instanceof Error?o.message:String(o)}`)}if(i.status===404)throw new Ea(`nothing at ${t}`);if(i.status===403||i.status===429)throw new Sa(`${new URL(t).host} is turning requests away for now (${i.status}) — try again in a minute`);if(!i.ok)throw Error(`${t} answered ${i.status}`);return e(await i.text())}function Ho(t){let e=new Set(t.waived??[]),n=t.gate??Le(Ee(t));return Dt.flatMap((r,i)=>{let o=n[i];if(e.has(r.rule)||typeof o!=="number"||Number.isNaN(o))return[];if(r.min!==void 0&&o<r.min)return[`${r.label} ${o} < ${r.min}`];if(r.max!==void 0&&o>r.max)return[`${r.label} ${o} > ${r.max}`];return[]})}function mn(t,e){let n=t.find((r)=>r.name===e);if(!n)throw Error(`no palette named ${e} in the catalog — ${Ml(t,[e])}`);return n}function Ml(t,e){let n=e.map((s)=>s.toLowerCase()),r=t.filter((s)=>n.some((a)=>s.name.includes(a))),i=t.filter((s)=>!r.includes(s)&&n.some((a)=>s.group.toLowerCase().includes(a))),o=[...r,...i].map((s)=>s.name).slice(0,3);return o.length>0?`did you mean: ${o.join(", ")}?`:"`ttheme list` shows what is there"}function Qp(t,e){let n=e.toLowerCase();return t.filter((r)=>[r.name,r.group,r.native??"",r.ansiSource].some((i)=>i.toLowerCase().includes(n)))}function Xp(t,e,n){let r=n.toLowerCase(),i=(o)=>o.name===e.name?0:o.group===e.group?1:2;return t.filter((o)=>o.booru?.toLowerCase().includes(r)).map((o,s)=>({p:o,at:s})).sort((o,s)=>i(o.p)-i(s.p)||o.at-s.at).map(({p:o})=>o)}function Il(t,e){return t.booruSites?.[e]??(t.booru?[t.booru]:[])}var Yn=[{name:"preview",title:"Preview"},{name:"browse",title:"Browse"}],Ma=10,tb=20;function eb(t){return Yn.find((e)=>e.name===t.TTHEME_HUB)?.name}function nb(t,e){return 20+(Yn.findIndex((r)=>r.name===t)+e+Yn.length)%Yn.length+1}function rb(t,e){let n=Yn.map(({name:i,title:o})=>{if(!e)return i===t?`[${o}]`:` ${o} `;return i===t?`\x1B[7;1m\x1B[36m ${o} \x1B[0m`:`\x1B[2m ${o} \x1B[0m`}),r="tab next";return` ${n.join(" ")} ${e?"\x1B[2mtab next\x1B[0m":"tab next"}`}import{execFileSync as JI}from"node:child_process";import{existsSync as kf,mkdirSync as xw,readdirSync as YI,readFileSync as vf,rmSync as Lw}from"node:fs";import{basename as DI,join as Tr,relative as VI}from"node:path";import{existsSync as ff,readFileSync as dw,rmSync as df}from"node:fs";import{homedir as qe}from"node:os";import{join as Ya}from"node:path";var $2=["black","red","green","yellow","blue","magenta","cyan","white"];function ib(t,e){return[t,...$2.map((n,r)=>`${n} = '${e[r]}'`),""].join(`
341
- `)}var Ol={id:"alacritty",limits:"no runtime color API (OSC only)",emit(t){let e=[...Dn(t),"","[colors.primary]",`background = '${t.background}'`,`foreground = '${t.foreground}'`,"","[colors.cursor]",`cursor = '${t.cursor}'`,`text = '${t.background}'`,"","[colors.selection]",`background = '${t.selectionBackground}'`,`text = '${t.foreground}'`,"",ib("[colors.normal]",t.ansi.slice(0,8)),ib("[colors.bright]",t.ansi.slice(8,16))].join(`
342
- `);return[{path:`alacritty/themes/${x(t.name)}.toml`,content:e}]}};var Nl={id:"ghostty",emit(t){let e=[...Dn(t),`background = ${t.background}`,`foreground = ${t.foreground}`,`cursor-color = ${t.cursor}`,`selection-background = ${t.selectionBackground}`,`selection-foreground = ${t.foreground}`,...t.ansi.map((n,r)=>`palette = ${r}=${n}`),"","macos-icon = custom-style",`macos-icon-ghost-color = ${t.ghostty.iconGhost}`,`macos-icon-screen-color = ${t.ghostty.iconScreen.join(",")}`,"macos-icon-frame = chrome",""].join(`
343
- `);return[{path:`ghostty/themes/${x(t.name)}`,content:e}]}};function Vn(t){let[e,n,r]=nt(t);return{"Alpha Component":1,"Blue Component":r/255,"Color Space":"P3","Green Component":n/255,"Red Component":e/255}}function sb(t){return{...Object.fromEntries(t.ansi.map((e,n)=>[`Ansi ${n} Color`,Vn(e)])),"Background Color":Vn(t.background),"Bold Color":Vn(t.foreground),"Cursor Color":Vn(t.cursor),"Cursor Text Color":Vn(t.background),"Foreground Color":Vn(t.foreground),"Selected Text Color":Vn(t.foreground),"Selection Color":Vn(t.selectionBackground)}}function ob(t){return t?{"Background Image Location":t.image,"Background Image Mode":t.cover?2:3,Blend:t.opacity}:{"Background Image Location":""}}function ab(t,e,n,r,i=!1){let o=(c,u)=>({Name:`ttheme · ${u}`,Guid:x(u),...r?{"Dynamic Profile Parent GUID":r}:{},"Use Separate Colors for Light and Dark Mode":!1,...ob(e.get(c.name)),...sb(c)}),s={Name:"ttheme · default",Guid:x("default"),"Dynamic Profile Parent GUID":r,...ob(void 0)},a=[...n?[o(n,"default")]:i&&r?[s]:[],...t.map((c)=>o(c,c.name))];return`${JSON.stringify({Profiles:a},null,2)}
344
- `}function k2(t,e){return[` <key>${t}</key>`,"\t<dict>",...Object.entries(e).flatMap(([n,r])=>[` <key>${n}</key>`,typeof r==="string"?` <string>${r}</string>`:` <real>${r}</real>`]),"\t</dict>"].join(`
345
- `)}var Rl={id:"iterm2",limits:"colors are Display P3, the space iTerm2 reads OSC colors in",emit(t){let e=['<?xml version="1.0" encoding="UTF-8"?>','<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">','<plist version="1.0">',"<dict>",...Object.entries(sb(t)).map(([n,r])=>k2(n,r)),"</dict>","</plist>",""].join(`
346
- `);return[{path:`iterm2/${x(t.name)}.itermcolors`,content:e}]}};var Pl={id:"kitty",emit(t){let e=[...Dn(t),`background ${t.background}`,`foreground ${t.foreground}`,`cursor ${t.cursor}`,`cursor_text_color ${t.background}`,`selection_background ${t.selectionBackground}`,`selection_foreground ${t.foreground}`,...t.ansi.map((n,r)=>`color${r} ${n}`),""].join(`
347
- `);return[{path:`kitty/themes/${x(t.name)}.conf`,content:e}]}};function cb(t){return["# Generated by ttheme — rewritten on every add, remove and default; do not edit.","import os","",`THEMES = ${JSON.stringify(t.themes)}`,`BACKGROUNDS = ${JSON.stringify(t.backgrounds)}`,"PLACES = {"," 'top-left': 'top-left', 'top-center': 'top', 'top-right': 'top-right',"," 'center-left': 'left', 'center': 'center', 'center-center': 'center', 'center-right': 'right',"," 'bottom-left': 'bottom-left', 'bottom-center': 'bottom', 'bottom-right': 'bottom-right',","}","","shown = {}","faded = {}","worn = {}","","","def locate(path):"," if path.startswith('~/'):"," return os.path.expanduser(path)"," return path if os.path.isabs(path) else os.path.join(BACKGROUNDS, path)","","","def read(path, into):"," try:"," with open(path, encoding='utf-8') as f:"," lines = f.read().splitlines()"," except OSError:"," return False"," for line in lines:"," key, sep, value = line.partition('=')"," key, value = key.strip(), value.strip()"," if not sep or not key or key.startswith('#'):"," continue"," if key == 'config-file':"," read(locate(value.lstrip('?')), into)"," else:"," into[key] = value"," return True","","","def logo(palette):"," c = {}"," if not palette or not read(os.path.join(BACKGROUNDS, palette.replace('@', '--', 1).replace('/', '--', 1) + '.conf'), c):"," return None"," image = c.get('background-image', '')"," try:"," opacity = min(float(c.get('background-image-opacity', '1')), 1.0)"," except ValueError:"," opacity = 1.0"," if not image or opacity <= 0:"," return None"," return locate(image), PLACES.get(c.get('background-image-position', 'center'), 'center'), opacity","","","def fade(path, opacity):"," key = f'{path}#{opacity}'"," if key not in faded:"," from kitty.fast_data_types import load_png_data, png_from_32bit_rgba_data"," with open(path, 'rb') as f:"," rgba, width, height = load_png_data(f.read())"," data = bytearray(rgba)"," data[3::4] = data[3::4].translate(bytes(round(a * opacity) for a in range(256)))"," if len(faded) > 8:"," faded.clear()"," faded[key] = png_from_32bit_rgba_data(bytes(data), width, height)"," return key, faded[key]","","","def show(window):"," want = logo(window.user_vars.get('ttheme_shown') or '')"," if window.id in shown and shown[window.id] == want:"," return"," shown[window.id] = want"," try:"," if want is None:"," window.set_logo('')"," elif want[2] < 1:"," key, png = fade(want[0], want[2])"," window.set_logo(key, want[1], 1, png)"," else:"," window.set_logo(want[0], want[1], 1)"," except Exception:"," shown.pop(window.id, None)","","","def theme(palette):"," path = os.path.join(THEMES, 'ttheme-' + palette.replace('@', '--', 1).replace('/', '--', 1) + '.conf')"," if not palette or not os.path.exists(path):"," return None"," from kitty.colors import parse_colors"," return parse_colors([path])","","","def wear(palette):"," colors = theme(palette) if worn.get('startup') != palette else None"," if colors is None:"," return"," from kitty.colors import patch_colors"," patch_colors(colors[0], colors[1], True, ())"," worn['startup'] = palette","","","def rewear(boss):"," from kitty.colors import patch_colors"," for window in tuple(boss.all_windows):"," colors = theme(window.user_vars.get('ttheme_worn') or '')"," if colors is not None:"," patch_colors(colors[0], colors[1], False, (window,))","","","def on_load(boss, data):"," if getattr(boss, 'ttheme_rewears', False):"," return"," load = boss.load_config_file",""," def reload(*args, **kwargs):"," load(*args, **kwargs)"," worn.pop('startup', None)"," rewear(boss)",""," boss.load_config_file = reload"," boss.ttheme_rewears = True","","","def on_set_user_var(boss, window, data):"," if data['key'] == 'ttheme_shown':"," show(window)"," elif data['key'] == 'ttheme_startup':"," wear(data['value'] or '')","","","def on_focus_change(boss, window, data):"," if data['focused']:"," show(window)","","","def on_close(boss, window, data):"," shown.pop(window.id, None)",""].join(`
348
- `)}function gn(t,e){return[`[${t}]`,`Color=${nt(e).join(",")}`,""]}function y2(t){let e=(n)=>Ht(n,t.background,0.5);return[...Dn(t),"",...gn("Background",t.background),...gn("BackgroundFaint",t.background),...gn("BackgroundIntense",t.background),...t.ansi.slice(0,8).flatMap((n,r)=>[...gn(`Color${r}`,n),...gn(`Color${r}Faint`,e(n)),...gn(`Color${r}Intense`,t.ansi[r+8])]),...gn("Foreground",t.foreground),...gn("ForegroundFaint",e(t.foreground)),...gn("ForegroundIntense",t.foreground),"[General]","Blur=false","ColorRandomization=false",`Description=ttheme · ${t.name}`,"Opacity=1","Wallpaper=",""].join(`
349
- `)}var Hl={id:"konsole",limits:"draws no OSC 4, so a tab repaints by switching color scheme",emit(t){return[{path:`konsole/${x(t.name)}.colorscheme`,content:y2(t)}]}};var ub=44,de=[{name:"Shell",lines:["«B4»~/code/demo«d» on «5»main«2» +2«3» ~1","«2»❯ «»git status -sb","«w»## «2»main«»...«1»origin/main«3» [ahead 1]","«1» M«» src/main.rs","«1»??«» notes.md","","«w»«2»❯ «»ls","«w»«B4»docs«» «B4»src«» «B4»tests«» Cargo.toml README.md","«w»","«2»❯ «»cargo test","«2» ✓«» parses config","«n»«1» ✗«» renders frame","«w»«1» ✗«» renders frame«d» expected «2»3«d», received «1»2","","«2»❯ «»echo «s»selected text«» «c» "]},{name:"Code",lines:["«d» 12 │ «5»import«» { readFile } «5»from «2»'node:fs/promises'","«d» 13 │","«d» 14 │ «8»// Read a palette and check its sixteen colors","«d» 15 │ «5»export async function «4»load«»(path: «6»string«») {","«d» 16 │ «5»const«» text = «5»await «4»readFile«»(path, «2»'utf8'«»)","«b» 17 «d»│ «5»const«» colors = «s»parse(text)«».colors ?? {}","«d» 18 │ «5»if«» (colors.ansi.length !== «3»16«») {","«d» 19 │ «5»throw new «6»Error«»(«2»'needs 16 colors'«»)","«d» 20 │ }","«d» 21 │ «5»return«» { ...colors, ratio: «c»4«3».5«» }","«d» 22 │ }"]},{name:"Diff",lines:["«2»❯ «»git diff --stat","«» src/theme.ts | 3 «2»++«1»-","«2»❯ «»git diff","«b»diff --git a/src/theme.ts b/src/theme.ts","«6»@@ -16,3 +16,4 @@«» export async function load(","«» const text = await readFile(path, 'utf8')","«1»- const colors = parse(text).colors","«2»+ const colors = parse(text).colors ?? {}","«2»+ const ratio = contrast(colors)","«2»❯ «»git log --oneline --graph -4","«3»* 3f2a1c9 («B6»HEAD -> «B2»main«3»)«» Check contrast on load","«3»* 9b04e7d«» Merge branch ansi","«1»|«5»\\","«1»| «5»* «3»51cd0aa«» Add sixteen ANSI colors","«1»|«5»/","«3»* 07be2f1 («B1»origin/main«3», «B3»tag: v1.0«3»)«» Read palette files"]},{name:"Logs",lines:["«2»❯ «»npm run dev","«B2» VITE v6.2.0«d» ready in «b»412«d» ms","«2» ➜ «b»Local«»: «6»http://localhost:5173/","«d»10:42:07 «2»INFO «» GET /api/palettes «2»200«d» 12 ms","«d»10:42:08 «2»INFO «» GET /api/themes/kita «2»200«d» 8 ms","«d»10:42:09 «3»WARN «» slow query: palettes «3»812 ms","«d»10:42:10 «4»DEBUG«» cache hit themes/kita","«d»10:42:11 «B1»ERROR«» POST /api/share «1»500«d» 41 ms","«1» Error«»: read ECONNRESET","«d» at «»TCP.onStreamRead «d»(«6»node:net:216:20«d»)","«d» at «»share «d»(«6»src/share.ts:48:11«d»)","«d»10:42:12 «2»INFO «» retry 1/3 in 200 ms"]},{name:"Monitor",lines:["«6» 1 «b»[«2»|||||||||||||«1»||«» 42.1%«b»]«6» Tasks: «b»128«», 412 thr; «B2»3«» running","«6» 2 «b»[«2»||||||«4»||«» 21.4%«b»]«6» Load average: «b»1.42 «»1.18 0.97","«6» 3 «b»[«2»||||||||||||||«1»|||||«» 71.0%«b»]«6» Uptime: «b»3 days, 04:12:55","«6» 4 «b»[«2»||«» 7.9%«b»]","«6» Mem«b»[«2»||||||||«4»||«3»||«» 6.21G/16.0G«b»]","«6» Swp«b»[«1»|«» 0.10G/2.00G«b»]","","«K2» PID USER CPU% MEM% TIME+ Command ","«s» 4127 kec 38.2 2.1 3:12.44 node dev.js ","«» 2210 kec 12.0 4.8 1:02.10 «b»ghostty","«» 3301 kec 4.4 1.2 0:05.61 «b»zsh","«» 812 «1»root«» 3.1 0.3 0:44.02 «d»kernel_task","«» 167 «1»root«» 0.9 0.1 0:12.80 «d»WindowServer"]}];function Ia(t){let e=de.length;return de[(t%e+e)%e]}function lb(t,e){let n=t.split("«"),r=n[0]?[[n[0],""]]:[];for(let i of n.slice(1)){let o=i.indexOf("»"),s=i.slice(0,o),a=i.slice(o+1);if(s==="w"||s==="n"){if(s==="w"!==e>=44)return}if(a)r.push([a,s==="w"||s==="n"?"":s])}return r}import{openSync as v2,writeSync as E2}from"node:fs";import{ReadStream as S2}from"node:tty";var Mi=["11","10","12","17",...Array.from({length:16},(t,e)=>`4;${e}`)];function zt(t=process.env){return Boolean(t.NO_COLOR)||t.TERM==="dumb"}function Fl(t,e){return`\x1B]${Mi[t]};${e}\x1B\\`}function xl(t,e){return[t.background,t.foreground,t.cursor,t.selection,...t.ansi].map((n,r)=>e&&!e.includes(r)?"":Fl(r,n)).join("")}function M2(t){return`\x1B]${t.startsWith("4;")?`104;${t.slice(2)}`:`1${t}`}\x1B\\`}function I2(t){let e=new Map;for(let n of t.split("\x1B")){let r=n.match(/^\](\d+(?:;\d+)?);(rgba?:[0-9a-fA-F/]+)/),[,i,o]=r??[];if(i&&o)e.set(i,o)}return e}function O2(t){return`#${t.slice(t.indexOf(":")+1).split("/").slice(0,3).map((n)=>n.slice(0,2).padStart(2,"0")).join("")}`}function fb(t,e=[...t.keys()],n=!1){return e.map((r)=>{let i=t.get(r);return i?`\x1B]${r};${n?O2(i):i}\x1B\\`:M2(r)}).join("")}function db(t,e){return`\x1B]50;ColorScheme=${t};UseCustomCursorColor=true;customCursorColor=${e}\x07`}function N2(t=Mi){return`${t.map((e)=>`\x1B]${e};?\x1B\\`).join("")}\x1B[5n`}function R2(t){return t.includes("\x1B[0n")}async function hb(t=Mi){let e,n;try{e=v2("/dev/tty","r+"),n=new S2(e),n.setRawMode(!0)}catch{return new Map}try{E2(e,N2(t));let r="";return await new Promise((i)=>{let o=setTimeout(i,120);n.on("data",(s)=>{if(r+=s.toString(),R2(r))clearTimeout(o),i()})}),I2(r)}finally{n.setRawMode(!1),n.destroy()}}function Ll(t){if(t.NVIM)return"nvim";if(t.VIM_TERMINAL)return"vim";if(t.INSIDE_EMACS)return"emacs";return t.TERM_PROGRAM==="vscode"?"vscode":void 0}function ne(t){if(Ll(t))return"editor";if(t.TERM_PROGRAM==="WarpTerminal")return"warp";if(t.GHOSTTY_RESOURCES_DIR||t.TERM_PROGRAM==="ghostty")return"ghostty";if(t.KITTY_WINDOW_ID)return"kitty";if(t.WEZTERM_PANE)return"wezterm";if(t.ALACRITTY_WINDOW_ID)return"alacritty";if(t.KONSOLE_VERSION)return"konsole";if(t.ITERM_SESSION_ID||t.TERM_PROGRAM==="iTerm.app")return"iterm2";if(t.TERM_PROGRAM==="Apple_Terminal")return"terminal-app";if(t.WT_SESSION&&!t.TERM_PROGRAM)return"windows-terminal";if(t.TERM?.startsWith("foot"))return"foot";return"unknown"}var Oe={ghostty:{links:!0,pictures:!0,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},kitty:{links:!0,pictures:!0,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},iterm2:{links:!0,pictures:!0,bands:!0,files:!0,moves:!0,layers:!0,paints:!0,repaint:[0,1]},wezterm:{links:!0,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},alacritty:{links:!0,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},"windows-terminal":{links:!0,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},konsole:{links:!1,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0,repaint:[0,1],hex:!0,schemes:!0},foot:{links:!0,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},"terminal-app":{links:!1,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},warp:{links:!1,pictures:!0,bands:!0,files:!1,moves:!1,layers:!1,paints:!1},editor:{links:!1,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!1},unknown:{links:!1,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0}};function mb(t){return Oe[ne(t)].links}function gb(t){return Oe[ne(t)].pictures&&!t.TMUX}function pb(t){return Oe[ne(t)].bands}function bb(t){return Oe[ne(t)].files}function wb(t){return Oe[ne(t)].layers}function $b(t){return Oe[ne(t)].moves}var Ii="\x1B[H\x1B[K\x1B[2H\x1B[J\x1B[H";function Zn(t,e){let n=ne(t),r=Oe[n];if(!e||zt(t)||t.TMUX||!r.paints)return;let i=r.repaint??Mi.map((s,a)=>a),o=Mi.filter((s,a)=>i.includes(a));return{slots:i,paint:(s)=>xl(s,i),wear:(s,a)=>!r.schemes?xl(s):a.includes(n)?db(x(s.name),s.cursor):void 0,saved:()=>hb(o),restore:(s)=>fb(s,o,r.hex===!0)}}var re=["ghostty","kitty","alacritty","wezterm","iterm2","windows-terminal","warp","konsole"];var P2=[{section:"tab",title:"This tab"},{section:"startup",title:"New tabs"},{section:"catalog",title:"Palettes"},{section:"own",title:"Your own"},{section:"setup",title:"Setup"},{section:"support",title:"Support"}],xo=[{name:"preview",args:[],about:"Try palettes live — focus repaints, enter edits its tone and picture and applies it, esc restores, ? lists keys",section:"tab",start:"Try every palette live — enter tunes the one you land on and applies it",shell:!0},{name:"use",args:["<palette>"],about:"Paint this tab — a unique prefix works: ttheme use ho",section:"tab",start:"Paint this tab with one — ttheme use homura",shell:!0},{name:"next",args:[],about:"Advance this tab to the next palette",section:"tab",shell:!0},{name:"default",args:["<palette>"],about:"Make a palette the one new tabs open with",section:"startup"},{name:"on",args:[],about:"Wear the default palette in new tabs again",section:"startup"},{name:"off",args:[],about:"Take the palette and picture off every tab — the terminal's own colors until `ttheme on`",section:"startup"},{name:"pin",args:["[directory|ssh:<host>]"],about:"Pick a palette for this directory, everything below it, its repository or an ssh host — cd or ssh in repaints, leaving restores",section:"tab",shell:!0},{name:"unpin",args:["[directory|ssh:<host>]"],about:"Drop a pin — this directory's, every one below it, the one above that paints it, or an ssh host's",section:"tab",shell:!0},{name:"pins",args:[],about:"Map every pinned directory as a tree in its palette's colors, every ssh host, and the pin that covers this one",section:"tab",shell:!0},{name:"config",args:[],about:"Edit settings in $EDITOR — they apply in new tabs",section:"startup",shell:!0},{name:"browse",args:[],about:"Pick palettes and markets in a live picker — shift+←/→ moves between Catalog, Installed, Markets and Errors",section:"catalog",start:"Install or drop palettes, add markets — every change applies at once on enter"},{name:"list",args:["[query]"],about:"Show the catalog, marking what is installed",section:"catalog",flags:{json:{type:"boolean",about:"Print the matches as JSON: name, group, catalog, installed"}}},{name:"add",args:["<palette...>"],about:"Install palettes from the catalog, or from a share code: ttheme add tt1:…",section:"catalog",flags:{market:{type:"string",value:"<source>",about:"Add this market first — a repository, a folder or official — and take bare palette names from it"}}},{name:"remove",args:["<palette...>"],about:"Uninstall palettes",section:"catalog"},{name:"update",args:[],about:"Refresh every market you added now — those with auto-update refresh on their own once a day",section:"catalog"},{name:"market",args:["[action]","[source]"],about:"The markets you added — add, remove and search them; init makes one of your own",actions:[["(none)","List the markets you added: palettes, auto-update and the last update"],["add <source>","Add one: a repository (alice/ttheme-pastel, #v1 pins a tag or branch), a folder, or official — asks whether it updates on its own"],["remove <market>","Drop one by its name (alice@pastel) — the palettes you installed from it keep working"],["search [query]","Repositories on GitHub with the ttheme-market topic"],["init [name]","Make a market of your own, <you>@<name>, in ~/.config/ttheme/market/<name> (or give a folder)"]],section:"catalog"},{name:"new",args:["<name>"],about:"Make a palette of your own, <you>@<market>/<name>, from blank in the palette editor — installed at once",section:"own",flags:{from:{type:"string",value:"<palette>",about:"Open the editor on this palette's colors instead of blank"},in:{type:"string",value:"<market>",about:"The local market to put it in, when you have more than one"}}},{name:"edit",args:["<palette>"],about:"Change one of your palettes in the palette editor — the contrast gate advises, never refuses",section:"own"},{name:"check",args:["<palette>"],about:"Measure a palette against the contrast gate and suggest colors that pass",section:"own",flags:{fix:{type:"boolean",about:"Write the suggested colors into your palette"}}},{name:"share",args:["<palette>"],about:"Print a share code — ttheme add <code> installs it anywhere, pictures included",section:"own",flags:{tone:{type:"string",value:"<tuned|original>",choices:["tuned","original"],about:"Share the palette as you tuned its colors, or as it was — asked when you tuned it and omit this"}}},{name:"init",args:[],about:"Install the shell layer and wire your terminal configs",section:"setup",flags:{yes:{type:"boolean",short:"y",about:"Accept every default without prompting"}}},{name:"uninstall",args:[],about:"Take ttheme out of every terminal config and delete what it wrote",section:"setup",flags:{yes:{type:"boolean",short:"y",about:"Remove without asking"}}},{name:"info",args:[],about:"Print what a bug report needs — version, OS, shell, terminal and the settings you changed",section:"support"},{name:"build",args:[],about:"Emit dist/ for every terminal, plus the zsh palette table — from a checkout",section:"setup",hidden:!0,flags:{only:{type:"string",multiple:!0,value:"<terminal>",choices:re,about:"Rebuild just this terminal — repeat it for more"}}},{name:"find",args:["<palette>"],about:"Pick a booru background for a palette — preview opens this on tab",section:"setup",hidden:!0},{name:"image",args:["<palette>","<action>","[picture]"],about:"Show one of a palette's saved backgrounds, remove one, draw one in its palette's tone or its own colors (or get the other ready before it is asked for), or pass on tuning — preview calls this",section:"setup",hidden:!0},{name:"flatten",args:["<source>","<out>","<background>","<opacity>","[canvas]","[place]"],about:"Lay a picture on a background color at an opacity, placed on a canvas when given one, for Warp, which fades the window instead — preview calls this",section:"setup",hidden:!0},{name:"bake",args:["<source>","<out>","<canvas>","<place>"],about:"Place a picture on a transparent canvas the way sips bakes preview's tuning — preview in Warp calls this",section:"setup",hidden:!0},{name:"tone",args:["<palette>"],about:"Serve a palette's tone editor over stdin and stdout — preview's palette panel runs it",section:"setup",hidden:!0},{name:"redraw",args:[],about:"Draw the background pictures again after TTHEME_BG_BLUR changed — ttheme config and preview call this",section:"setup",hidden:!0}];function Fo(t){let e=Object.entries(t.flags??{}).map(([n,{value:r}])=>`[--${n}${r?` ${r}`:""}]`);return[t.name,...e,...t.args].join(" ")}function Tl(t,e=Math.max(...t.map(([n])=>n.length))){return t.map(([n,r])=>` ${n.padEnd(e)} ${r}`)}var H2=[["npx @kecan0406/ttheme init -y","Wire the terminals found here, no prompts"],["ttheme add homura madoka","Install two palettes"],["ttheme use homura","Paint this tab with one"],["ttheme list --json madoka","The madoka series as JSON"],["ttheme market add alice/ttheme-pastel","alice's market, alice@pastel — ttheme add alice@pastel/dusk"],["ttheme add dusk --market alice/ttheme-pastel","The same in one step"],["ttheme new rei --from rei","Your own rei, <you>@<market>/rei, to edit and share"]];function Lo(t,e=!1){let n=xo.filter((s)=>!s.hidden&&!(e&&s.section==="setup")),r=P2.filter(({section:s})=>n.some((a)=>a.section===s)),i=[...e?["ttheme alone opens preview and browse as tabs — tab and shift+tab move between them"]:[],t?"ttheme help <command> describes one command · ttheme --version prints the version":"ttheme help <command> describes one · ttheme help all lists every command with what it does","https://kecan0406.github.io/ttheme"];if(!t){let s=n.filter((c)=>c.start),a=Math.max(...r.map(({title:c})=>c.length));return["Usage: ttheme <command>","",Ot.description,"","Start here",...Tl(s.map((c)=>[Fo(c),c.start])),"",...r.map(({section:c,title:u})=>`${u.padEnd(a)} ${n.filter((l)=>l.section===c).map((l)=>l.name).join(" · ")}`),"",...i].join(`
350
- `)}let o=Math.max(...n.map((s)=>Fo(s).length));return["Usage: ttheme <command>","",Ot.description,...r.flatMap(({section:s,title:a})=>["",a,...Tl(n.filter((c)=>c.section===s).map((c)=>[Fo(c),c.about]),o)]),"","Examples",...Tl(H2),"",...i].join(`
351
- `)}import{readFileSync as F2}from"node:fs";import{join as x2}from"node:path";var Al="# ttheme begin",Cl="# ttheme end",Oi=/# ttheme begin\n[\s\S]*?# ttheme end\n?/;function Qn(t,e){let n=`${Al}
308
+ `)},info:(t,e)=>{Mr.message(t,{...e,symbol:M("blue",tN)})},success:(t,e)=>{Mr.message(t,{...e,symbol:M("green",eN)})},step:(t,e)=>{Mr.message(t,{...e,symbol:M("green",gf)})},warn:(t,e)=>{Mr.message(t,{...e,symbol:M("yellow",nN)})},warning:(t,e)=>{Mr.warn(t,e)},error:(t,e)=>{Mr.message(t,{...e,symbol:M("red",rN)})}},Or=(t="",e)=>{let n=e?.output??process.stdout,r=e?.withGuide??Wt.withGuide?`${M("gray",jn)} `:"";n.write(`${r}${M("red",t)}
309
+
310
+ `)},Lc=(t="",e)=>{let n=e?.output??process.stdout,r=e?.withGuide??Wt.withGuide?`${M("gray",Y2)} `:"";n.write(`${r}${t}
311
+ `)},Lo=(t="",e)=>{let n=e?.output??process.stdout,r=e?.withGuide??Wt.withGuide?`${M("gray",et)}
312
+ ${M("gray",jn)} `:"";n.write(`${r}${t}
313
+
314
+ `)};var sN=(t)=>t,oN=(t,e,n)=>{let r={hard:!0,trim:!1},i=Sr(t,e,r).split(`
315
+ `),s=i.reduce((c,u)=>Math.max(Q(u),c),0),o=i.map(n).reduce((c,u)=>Math.max(Q(u),c),0),a=e-(o-s);return Sr(t,a,r)},fn=(t="",e="",n)=>{let r=n?.output??Pe.stdout,i=n?.withGuide??Wt.withGuide,s=n?.format??sN,o=["",...oN(t,Hc(r)-6,s).split(`
316
+ `).map(s),""],a=Q(e),c=Math.max(o.reduce((f,h)=>{let p=Q(h);return p>f?p:f},0),a)+2,u=o.map((f)=>`${M("gray",et)} ${f}${" ".repeat(c-Q(f))}${M("gray",et)}`).join(`
317
+ `),l=i?`${M("gray",et)}
318
+ `:"",d=i?Z2:X2;r.write(`${l}${M("green",gf)} ${M("reset",e)} ${M("gray",w0.repeat(Math.max(c-a-1,1))+V2)}
319
+ ${u}
320
+ ${M("gray",d+w0.repeat(c+2)+Q2)}
321
+ `)};var w5={light:ft("─","-"),heavy:ft("━","="),block:ft("█","#")};var aN=[`${M("dim","↑/↓")} to navigate`,`${M("dim","Enter:")} confirm`],Ac=(t,e)=>t.includes(`
322
+ `)?t.split(`
323
+ `).map((n)=>e(n)).join(`
324
+ `):e(t),E0=(t)=>{let e=(r,i)=>{if(r===void 0)return"";let s=r.label??String(r.value);switch(i){case"disabled":return`${M("gray",Fc)} ${Ac(s,(o)=>M("gray",o))}${r.hint?` ${M("dim",`(${r.hint??"disabled"})`)}`:""}`;case"selected":return`${Ac(s,(o)=>M("dim",o))}`;case"active":return`${M("green",mf)} ${s}${r.hint?` ${M("dim",`(${r.hint})`)}`:""}`;case"cancelled":return`${Ac(s,(o)=>M(["strikethrough","dim"],o))}`;default:return`${M("dim",Fc)} ${Ac(s,(o)=>M("dim",o))}`}},n=t.showInstructions??!0;return new p0({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue,render(){let r=t.withGuide??Wt.withGuide,i=`${Cc(this.state)} `,s=`${y0(this.state)} `,o=Er(t.output,t.message,s,i),a=`${r?`${M("gray",et)}
325
+ `:""}${o}
326
+ `;switch(this.state){case"submit":{let c=r?`${M("gray",et)} `:"",u=Er(t.output,e(this.options[this.cursor],"selected"),c);return`${a}${u}`}case"cancel":{let c=r?`${M("gray",et)} `:"",u=Er(t.output,e(this.options[this.cursor],"cancelled"),c);return`${a}${u}${r?`
327
+ ${M("gray",et)}`:""}`}default:{let c=r?`${M("cyan",et)} `:"",u=a.split(`
328
+ `).length,l=n?v0(aN,r):r?[M("cyan",jn)]:[],d=l.join(`
329
+ `),f=l.length+1;return`${a}${c}${pf({output:t.output,cursor:this.cursor,options:this.options,maxItems:t.maxItems,columnPadding:c.length,rowPadding:u+f,style:(h,p)=>e(h,h.disabled?"disabled":p?"active":"inactive")}).join(`
330
+ ${c}`)}
331
+ ${d}
332
+ `}}}}).prompt()};var $5=`${M("gray",et)} `;var bf=(t)=>new hf({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,output:t.output,signal:t.signal,input:t.input,render(){let e=t?.withGuide??Wt.withGuide,n=`${`${e?`${M("gray",et)}
333
+ `:""}${Cc(this.state)} `}${t.message}
334
+ `,r=t.placeholder&&t.placeholder.length>0?M("inverse",t.placeholder[0])+M("dim",t.placeholder.slice(1)):M(["inverse","hidden"],"_"),i=this.userInput?this.userInputWithCursor:r,s=this.value??"";switch(this.state){case"error":{let o=this.error?` ${M("yellow",this.error)}`:"",a=e?`${M("yellow",et)} `:"",c=e?M("yellow",jn):"";return`${n.trim()}
335
+ ${a}${i}
336
+ ${c}${o}
337
+ `}case"submit":{let o=s?` ${M("dim",s)}`:"",a=e?M("gray",et):"";return`${n}${a}${o}`}case"cancel":{let o=s?` ${M(["strikethrough","dim"],s)}`:"",a=e?M("gray",et):"";return`${n}${a}${o}${s.trim()?`
338
+ ${a}`:""}`}default:{let o=e?`${M("cyan",et)} `:"",a=e?M("cyan",jn):"";return`${n}${o}${i}
339
+ ${a}
340
+ `}}}}).prompt();import{existsSync as mu,readFileSync as B$,rmSync as hh}from"node:fs";import{homedir as qe}from"node:os";import{join as Hs}from"node:path";var M0=44,te=[{name:"Shell",lines:["«B4»~/code/demo«d» on «5»main«2» +2«3» ~1","«2»❯ «»git status -sb","«w»## «2»main«»...«1»origin/main«3» [ahead 1]","«1» M«» src/main.rs","«1»??«» notes.md","","«w»«2»❯ «»ls","«w»«B4»docs«» «B4»src«» «B4»tests«» Cargo.toml README.md","«w»","«2»❯ «»cargo test","«2» ✓«» parses config","«n»«1» ✗«» renders frame","«w»«1» ✗«» renders frame«d» expected «2»3«d», received «1»2","","«2»❯ «»echo «s»selected text«» «c» "]},{name:"Code",lines:["«d» 12 │ «5»import«» { readFile } «5»from «2»'node:fs/promises'","«d» 13 │","«d» 14 │ «8»// Read a palette and check its sixteen colors","«d» 15 │ «5»export async function «4»load«»(path: «6»string«») {","«d» 16 │ «5»const«» text = «5»await «4»readFile«»(path, «2»'utf8'«»)","«b» 17 «d»│ «5»const«» colors = «s»parse(text)«».colors ?? {}","«d» 18 │ «5»if«» (colors.ansi.length !== «3»16«») {","«d» 19 │ «5»throw new «6»Error«»(«2»'needs 16 colors'«»)","«d» 20 │ }","«d» 21 │ «5»return«» { ...colors, ratio: «c»4«3».5«» }","«d» 22 │ }"]},{name:"Diff",lines:["«2»❯ «»git diff --stat","«» src/theme.ts | 3 «2»++«1»-","«2»❯ «»git diff","«b»diff --git a/src/theme.ts b/src/theme.ts","«6»@@ -16,3 +16,4 @@«» export async function load(","«» const text = await readFile(path, 'utf8')","«1»- const colors = parse(text).colors","«2»+ const colors = parse(text).colors ?? {}","«2»+ const ratio = contrast(colors)","«2»❯ «»git log --oneline --graph -4","«3»* 3f2a1c9 («B6»HEAD -> «B2»main«3»)«» Check contrast on load","«3»* 9b04e7d«» Merge branch ansi","«1»|«5»\\","«1»| «5»* «3»51cd0aa«» Add sixteen ANSI colors","«1»|«5»/","«3»* 07be2f1 («B1»origin/main«3», «B3»tag: v1.0«3»)«» Read palette files"]},{name:"Logs",lines:["«2»❯ «»npm run dev","«B2» VITE v6.2.0«d» ready in «b»412«d» ms","«2» ➜ «b»Local«»: «6»http://localhost:5173/","«d»10:42:07 «2»INFO «» GET /api/palettes «2»200«d» 12 ms","«d»10:42:08 «2»INFO «» GET /api/themes/kita «2»200«d» 8 ms","«d»10:42:09 «3»WARN «» slow query: palettes «3»812 ms","«d»10:42:10 «4»DEBUG«» cache hit themes/kita","«d»10:42:11 «B1»ERROR«» POST /api/share «1»500«d» 41 ms","«1» Error«»: read ECONNRESET","«d» at «»TCP.onStreamRead «d»(«6»node:net:216:20«d»)","«d» at «»share «d»(«6»src/share.ts:48:11«d»)","«d»10:42:12 «2»INFO «» retry 1/3 in 200 ms"]},{name:"Monitor",lines:["«6» 1 «b»[«2»|||||||||||||«1»||«» 42.1%«b»]«6» Tasks: «b»128«», 412 thr; «B2»3«» running","«6» 2 «b»[«2»||||||«4»||«» 21.4%«b»]«6» Load average: «b»1.42 «»1.18 0.97","«6» 3 «b»[«2»||||||||||||||«1»|||||«» 71.0%«b»]«6» Uptime: «b»3 days, 04:12:55","«6» 4 «b»[«2»||«» 7.9%«b»]","«6» Mem«b»[«2»||||||||«4»||«3»||«» 6.21G/16.0G«b»]","«6» Swp«b»[«1»|«» 0.10G/2.00G«b»]","","«K2» PID USER CPU% MEM% TIME+ Command ","«s» 4127 kec 38.2 2.1 3:12.44 node dev.js ","«» 2210 kec 12.0 4.8 1:02.10 «b»ghostty","«» 3301 kec 4.4 1.2 0:05.61 «b»zsh","«» 812 «1»root«» 3.1 0.3 0:44.02 «d»kernel_task","«» 167 «1»root«» 0.9 0.1 0:12.80 «d»WindowServer"]}];function hi(t){let e=te.length;return te[(t%e+e)%e]}function jc(t,e){let n=t.split("«"),r=n[0]?[[n[0],""]]:[];for(let i of n.slice(1)){let s=i.indexOf("»"),o=i.slice(0,s),a=i.slice(s+1);if(o==="w"||o==="n"){if(o==="w"!==e>=44)return}if(a)r.push([a,o==="w"||o==="n"?"":o])}return r}import{createHash as bN}from"node:crypto";import{existsSync as Bc,readFileSync as Ef,rmSync as I0}from"node:fs";import{homedir as x0}from"node:os";import{join as mi}from"node:path";function Ir(t){return[`# ${t.name} — ${t.group}${t.native?` (${t.native})`:""}`,`# ANSI: ${t.ansiSource}`]}function Gn(t,e){return[`[${t}]`,`Color=${nt(e).join(",")}`,""]}function wf(t,e,n=["Wallpaper="]){let r=(i)=>Gt(i,t.background,0.5);return[...Gn("Background",t.background),...Gn("BackgroundFaint",t.background),...Gn("BackgroundIntense",t.background),...t.ansi.slice(0,8).flatMap((i,s)=>[...Gn(`Color${s}`,i),...Gn(`Color${s}Faint`,r(i)),...Gn(`Color${s}Intense`,t.ansi[s+8])]),...Gn("Foreground",t.foreground),...Gn("ForegroundFaint",r(t.foreground)),...Gn("ForegroundIntense",t.foreground),"[General]","Blur=false","ColorRandomization=false",`Description=${e}`,"Opacity=1",...n,""]}var O0={left:"0",top:"0",center:"0.5",right:"1",bottom:"1"};function cN(t){if(!t||t.opacity<=0)return["Wallpaper="];let[e="center",n="center"]=t.position.split("-");return[`Wallpaper=${t.image}`,`FillStyle=${t.cover?"Crop":"Adapt"}`,`Anchor=${O0[n]??"0.5"},${O0[e]??"0.5"}`,`WallpaperOpacity=${t.opacity}`]}function $f(t,e){return[...Ir(t),"",...wf(t,`ttheme · ${t.name}`,cN(e))].join(`
341
+ `)}var kf={id:"konsole",limits:"draws no OSC 4, so a tab repaints by switching color scheme",emit(t){return[{path:`konsole/${A(t.name)}.colorscheme`,content:$f(t)}]}};import{openSync as uN,writeSync as lN}from"node:fs";import{ReadStream as dN}from"node:tty";var xr=["11","10","12","17",...Array.from({length:16},(t,e)=>`4;${e}`)];function Ft(t=process.env){return Boolean(t.NO_COLOR)||t.TERM==="dumb"}function Go(t,e){return`\x1B]${xr[t]};${e}\x1B\\`}function _n(t,e){return[t.background,t.foreground,t.cursor,t.selection,...t.ansi].map((n,r)=>e&&!e.includes(r)?"":Go(r,n)).join("")}function fN(t){return`\x1B]${t.startsWith("4;")?`104;${t.slice(2)}`:`1${t}`}\x1B\\`}function hN(t){let e=new Map;for(let n of t.split("\x1B")){let r=n.match(/^\](\d+(?:;\d+)?);(rgba?:[0-9a-fA-F/]+)/),[,i,s]=r??[];if(i&&s)e.set(i,s)}return e}function mN(t){return`#${t.slice(t.indexOf(":")+1).split("/").slice(0,3).map((n)=>n.slice(0,2).padStart(2,"0")).join("")}`}function Gc(t,e=[...t.keys()],n=!1){return e.map((r)=>{let i=t.get(r);return i?`\x1B]${r};${n?mN(i):i}\x1B\\`:fN(r)}).join("")}function _c(t,e){return`\x1B]50;ColorScheme=${t};UseCustomCursorColor=true;customCursorColor=${e}\x07`}function pN(t=xr){return`${t.map((e)=>`\x1B]${e};?\x1B\\`).join("")}\x1B[5n`}function gN(t){return t.includes("\x1B[0n")}async function yf(t=xr){let e,n;try{e=uN("/dev/tty","r+"),n=new dN(e),n.setRawMode(!0)}catch{return new Map}try{lN(e,pN(t));let r="";return await new Promise((i)=>{let s=setTimeout(i,120);n.on("data",(o)=>{if(r+=o.toString(),gN(r))clearTimeout(s),i()})}),hN(r)}finally{n.setRawMode(!1),n.destroy()}}function Mf(t){if(t.NVIM)return"nvim";if(t.VIM_TERMINAL)return"vim";if(t.INSIDE_EMACS)return"emacs";return t.TERM_PROGRAM==="vscode"?"vscode":void 0}function Ut(t){if(Mf(t))return"editor";if(t.TERM_PROGRAM==="WarpTerminal")return"warp";if(t.GHOSTTY_RESOURCES_DIR||t.TERM_PROGRAM==="ghostty")return"ghostty";if(t.KITTY_WINDOW_ID)return"kitty";if(t.WEZTERM_PANE)return"wezterm";if(t.ALACRITTY_WINDOW_ID)return"alacritty";if(t.KONSOLE_VERSION)return"konsole";if(t.ITERM_SESSION_ID||t.TERM_PROGRAM==="iTerm.app")return"iterm2";if(t.TERM_PROGRAM==="Apple_Terminal")return"terminal-app";if(t.WT_SESSION&&!t.TERM_PROGRAM)return"windows-terminal";if(t.TERM?.startsWith("foot"))return"foot";return"unknown"}var ae={ghostty:{links:!0,pictures:!0,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},kitty:{links:!0,pictures:!0,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},iterm2:{links:!0,pictures:!0,bands:!0,files:!0,moves:!0,layers:!0,paints:!0,repaint:[0,1]},wezterm:{links:!0,pictures:!0,bands:!1,files:!0,moves:!0,layers:!1,paints:!0,wipes:!0,views:!0},alacritty:{links:!0,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},"windows-terminal":{links:!0,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},konsole:{links:!1,pictures:!0,bands:!1,files:!0,moves:!0,layers:!0,paints:!0,repaint:[0,1],hex:!0,schemes:!0},foot:{links:!0,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},"terminal-app":{links:!1,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0},warp:{links:!0,pictures:!0,bands:!0,files:!1,moves:!1,layers:!1,paints:!1},editor:{links:!1,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!1},unknown:{links:!1,pictures:!1,bands:!1,files:!0,moves:!0,layers:!0,paints:!0}};function vf(t,e,n){let r="";for(let i of t.split(`
342
+ `)){let s=i.trim();if(s.startsWith("[")&&s.endsWith("]"))r=s.slice(1,-1);else if(r===e&&s.startsWith(`${n}=`))return s.slice(n.length+1)}return}function wN(t){let e=t.XDG_CONFIG_HOME??mi(x0(),".config"),n=mi(e,"konsolerc"),r=Bc(n)?vf(Ef(n,"utf8"),"Desktop Entry","DefaultProfile"):void 0;for(let i=0;i<8&&r&&r!=="FALLBACK/";i++){let s=r.endsWith(".profile")?r:`${r}.profile`,o=P0(t).map((u)=>mi(u,s)).find((u)=>Bc(u));if(!o)return!1;let a=Ef(o,"utf8"),c=vf(a,"Interaction Options","AllowEscapedLinks");if(c!==void 0)return c==="true";r=vf(a,"General","Parent")}return!1}function N0(t){let e=Ut(t);return e==="konsole"?wN(t):ae[e].links}function Wc(t,e){let n=Ut(t),r=ae[n];return r.pictures&&!t.TMUX&&(!r.views||e.includes(n))}function Uc(t){return ae[Ut(t)].bands}function Kc(t){return ae[Ut(t)].files}function zc(t){return ae[Ut(t)].layers}function R0(t){return ae[Ut(t)].moves}function T0(t){return ae[Ut(t)].wipes===!0}function pi(t){return ae[Ut(t)].views===!0}function gi(t){return`\x1B]1337;SetUserVar=ttheme_view=${Buffer.from(t).toString("base64")}\x07`}var bi="\x1B[H\x1B[K\x1B[2H\x1B[J\x1B[H",Of=120,Sf=4,$N=40;function kN(t){let e=t.TTHEME_ITERM_SHOWN;return t.TTHEME_ITERM_SWITCH==="1"&&t.TTHEME_ITERM_DYED==="0"&&e?`ttheme · ${e}`:void 0}function yN(t,e){let n=ae.iterm2.repaint??[],r=xr.map((c,u)=>u).filter((c)=>!n.includes(c)),i=new Set(n),s=kN(t),o=[],a=()=>{for(let c of o)clearTimeout(c);o=[]};return{slots:n,paint(c){a();for(let u=0;u<r.length;u+=Sf){let l=r.slice(u,u+Sf),d=setTimeout(()=>{for(let f of l)i.add(f);e(_n(c,l))},Of+u/Sf*$N);d.unref?.(),o.push(d)}return _n(c,n)},wear:(c)=>_n(c),saved:()=>yf(),restore(c){a();let u=xr.filter((l,d)=>i.has(d));return s?`\x1B[?2026h${Gc(new Map,u)}\x1B]1337;SetProfile=${s}\x07\x1B[?2026l`:Gc(c,u)},stop:a}}var vN=3,SN=/^(Wallpaper|FillStyle|Anchor|WallpaperOpacity|WallpaperFlipType)=/;function P0(t){return[t.XDG_DATA_HOME??mi(x0(),".local","share"),...(t.XDG_DATA_DIRS||"/usr/local/share:/usr/share").split(":")].map((e)=>mi(e,"konsole"))}function EN(t,e){let n=/(?:^|;)ColorScheme=([^;]+)/.exec(e)?.[1],r=n&&t.map((c)=>mi(c,`${n}.colorscheme`)).find((c)=>Bc(c));if(!r)return["Wallpaper="];let i=Ef(r,"utf8").split(`
343
+ `),s=i.findIndex((c)=>c.trim()==="[General]"),o=i.findIndex((c,u)=>u>s&&c.trimStart().startsWith("[")),a=s<0?[]:i.slice(s+1,o<0?void 0:o).filter((c)=>SN.test(c));return a.length>0?a:["Wallpaper="]}function MN(t,e,n){let r=P0(t),i=r[0],s=EN(r,e),o=[],a=(u,l,d)=>{let f=wf(l,`ttheme · ${u}`,s).join(`
344
+ `),h=`${A("view")}.${bN("sha1").update(f).digest("hex").slice(0,10)}`,p=mi(i,`${h}.colorscheme`);if(!Bc(p))H(p,f);if(!o.includes(p))o.push(p);for(let $ of o.splice(0,Math.max(0,o.length-vN)))I0($,{force:!0});return _c(h,d)},c=()=>{for(let u of o.splice(0))I0(u,{force:!0})};return{slots:[],paint:(u)=>a(u.name,u,u.cursor),look:(u,l)=>{let[d="",f="",h="",,...p]=l;n(a(u,{background:d,foreground:f,ansi:p},h))},wear:(u,l)=>l.includes("konsole")?_c(A(u.name),u.cursor):void 0,saved:async()=>new Map,restore:()=>{return c(),`\x1B]50;${e}\x07`},stop:c}}function H0(t,e,n=(r)=>{process.stdout.write(r)}){let r=Ut(t),i=ae[r];if(!e||Ft(t)||t.TMUX||!i.paints)return;if(r==="iterm2")return yN(t,n);if(r==="konsole"&&t.TTHEME_KONSOLE_LOOK)return MN(t,t.TTHEME_KONSOLE_LOOK,n);let s=i.repaint??xr.map((a,c)=>c),o=xr.filter((a,c)=>s.includes(c));return{slots:s,paint:(a)=>_n(a,s),wear:(a,c)=>!i.schemes?_n(a):c.includes(r)?_c(A(a.name),a.cursor):void 0,saved:()=>yf(o),restore:(a)=>Gc(a,o,i.hex===!0)}}var Dt=["ghostty","kitty","alacritty","wezterm","iterm2","windows-terminal","warp","konsole","terminal-app"];var ON=[{section:"tab",title:"This tab"},{section:"startup",title:"New tabs"},{section:"catalog",title:"Palettes"},{section:"own",title:"Your own"},{section:"setup",title:"Setup"},{section:"support",title:"Support"}],Bo=[{name:"preview",args:[],about:"Try palettes live — focus repaints, enter edits its tone and picture and applies it, esc restores, ? lists keys",section:"tab",start:"Try every palette live — enter tunes the one you land on and applies it",shell:!0},{name:"use",args:["<palette>"],about:"Paint this tab — a unique prefix works: ttheme use ho",section:"tab",start:"Paint this tab with one — ttheme use homura",shell:!0},{name:"next",args:[],about:"Advance this tab to the next palette",section:"tab",shell:!0},{name:"default",args:["<palette>"],about:"Make a palette the one new tabs open with",section:"startup"},{name:"on",args:[],about:"Wear the default palette in new tabs again",section:"startup"},{name:"off",args:[],about:"Take the palette and picture off every tab — the terminal's own colors until `ttheme on`",section:"startup"},{name:"pin",args:["[directory|ssh:<host>]"],about:"Pick a palette for this directory, everything below it, its repository or an ssh host — cd or ssh in repaints, leaving restores",section:"tab",shell:!0},{name:"unpin",args:["[directory|ssh:<host>]"],about:"Drop a pin — this directory's, every one below it, the one above that paints it, or an ssh host's",section:"tab",shell:!0},{name:"pins",args:[],about:"Map every pinned directory as a tree in its palette's colors, every ssh host, and the pin that covers this one",section:"tab",shell:!0},{name:"config",args:[],about:"Edit settings in $EDITOR — they apply in new tabs",section:"startup",shell:!0},{name:"browse",args:[],about:"Pick palettes and markets in a live picker — shift+←/→ moves between Catalog, Installed, Markets and Errors",section:"catalog",start:"Install or drop palettes, add markets — every change applies at once on enter"},{name:"list",args:["[query]"],about:"Show the catalog, marking what is installed",section:"catalog",flags:{json:{type:"boolean",about:"Print the matches as JSON: name, group, catalog, installed"}}},{name:"add",args:["<palette...>"],about:"Install palettes from the catalog, or from a share code: ttheme add tt1:…",section:"catalog",flags:{market:{type:"string",value:"<source>",about:"Add this market first — a repository, a folder or official — and take bare palette names from it"}}},{name:"remove",args:["<palette...>"],about:"Uninstall palettes",section:"catalog"},{name:"update",args:[],about:"Refresh every market you added now — those with auto-update refresh on their own once a day",section:"catalog"},{name:"market",args:["[action]","[source]"],about:"The markets you added — add, remove and search them; init makes one of your own",actions:[["(none)","List the markets you added: palettes, auto-update and the last update"],["add <source>","Add one: a repository (alice/ttheme-pastel, #v1 pins a tag or branch), a folder, or official — asks whether it updates on its own"],["remove <market>","Drop one by its name (alice@pastel) — the palettes you installed from it keep working"],["search [query]","Repositories on GitHub with the ttheme-market topic"],["init [name]","Make a market of your own, <you>@<name>, in ~/.config/ttheme/market/<name> (or give a folder)"]],section:"catalog"},{name:"new",args:["<name>"],about:"Make a palette of your own, <you>@<market>/<name>, from blank in the palette editor — installed at once",section:"own",flags:{from:{type:"string",value:"<palette>",about:"Open the editor on this palette's colors instead of blank"},in:{type:"string",value:"<market>",about:"The local market to put it in, when you have more than one"}}},{name:"edit",args:["<palette>"],about:"Change one of your palettes in the palette editor — the contrast gate advises, never refuses",section:"own"},{name:"check",args:["<palette>"],about:"Measure a palette against the contrast gate and suggest colors that pass",section:"own",flags:{fix:{type:"boolean",about:"Write the suggested colors into your palette"}}},{name:"share",args:["<palette>"],about:"Print a share code — ttheme add <code> installs it anywhere, pictures included",section:"own",flags:{tone:{type:"string",value:"<tuned|original>",choices:["tuned","original"],about:"Share the palette as you tuned its colors, or as it was — asked when you tuned it and omit this"}}},{name:"init",args:[],about:"Install the shell layer and wire your terminal configs",section:"setup",flags:{yes:{type:"boolean",short:"y",about:"Accept every default without prompting"}}},{name:"uninstall",args:[],about:"Take ttheme out of every terminal config and delete what it wrote",section:"setup",flags:{yes:{type:"boolean",short:"y",about:"Remove without asking"}}},{name:"wire",args:["<terminal>"],about:"Wire one more terminal into this setup, after showing what it edits — the shell offers it in a terminal that paints only through the config init would have wired",section:"setup",hidden:!0},{name:"info",args:[],about:"Print what a bug report needs — version, OS, shell, terminal and the settings you changed",section:"support"},{name:"build",args:[],about:"Emit dist/ for every terminal, plus the zsh palette table — from a checkout",section:"setup",hidden:!0,flags:{only:{type:"string",multiple:!0,value:"<terminal>",choices:Dt,about:"Rebuild just this terminal — repeat it for more"}}},{name:"find",args:["<palette>"],about:"Pick a booru background for a palette — preview opens this on tab",section:"setup",hidden:!0},{name:"image",args:["<palette>","<action>","[picture]"],about:"Show one of a palette's saved backgrounds, remove one, draw one in its palette's tone or its own colors (or get the other ready before it is asked for), or pass on tuning — preview calls this",section:"setup",hidden:!0},{name:"flatten",args:["<source>","<out>","<background>","<opacity>","[canvas]","[place]","[into]"],about:"Lay a picture on a background color at an opacity, placed on a canvas when given one, for Warp, which fades the window instead, and Terminal.app, which takes it written into the file its profile points at and renamed to the out — preview calls this",section:"setup",hidden:!0},{name:"bake",args:["<source>","<out>","<canvas>","<place>"],about:"Place a picture on a transparent canvas the way sips bakes preview's tuning — preview in Warp calls this",section:"setup",hidden:!0},{name:"tone",args:["<palette>"],about:"Serve a palette's tone editor over stdin and stdout — preview's palette panel runs it",section:"setup",hidden:!0},{name:"redraw",args:[],about:"Draw the background pictures again after TTHEME_BG_BLUR changed — ttheme config and preview call this",section:"setup",hidden:!0},{name:"names",args:[],about:"Download aninames' character names when its release changed and index them — any command starts this in the background once a day",section:"setup",hidden:!0}];function _o(t){let e=Object.entries(t.flags??{}).map(([n,{value:r}])=>`[--${n}${r?` ${r}`:""}]`);return[t.name,...e,...t.args].join(" ")}function If(t,e=Math.max(...t.map(([n])=>n.length))){return t.map(([n,r])=>` ${n.padEnd(e)} ${r}`)}var IN=[["npx @kecan0406/ttheme init -y","Wire the terminals found here, no prompts"],["ttheme add homura madoka","Install two palettes"],["ttheme use homura","Paint this tab with one"],["ttheme list --json madoka","The madoka series as JSON"],["ttheme market add alice/ttheme-pastel","alice's market, alice@pastel — ttheme add alice@pastel/dusk"],["ttheme add dusk --market alice/ttheme-pastel","The same in one step"],["ttheme new rei --from rei","Your own rei, <you>@<market>/rei, to edit and share"]];function Wo(t,e=!1){let n=Bo.filter((o)=>!o.hidden&&!(e&&o.section==="setup")),r=ON.filter(({section:o})=>n.some((a)=>a.section===o)),i=[...e?["ttheme alone opens preview and browse as tabs — tab and shift+tab move between them"]:[],t?"ttheme help <command> describes one command · ttheme --version prints the version":"ttheme help <command> describes one · ttheme help all lists every command with what it does","https://kecan0406.github.io/ttheme"];if(!t){let o=n.filter((c)=>c.start),a=Math.max(...r.map(({title:c})=>c.length));return["Usage: ttheme <command>","",Tt.description,"","Start here",...If(o.map((c)=>[_o(c),c.start])),"",...r.map(({section:c,title:u})=>`${u.padEnd(a)} ${n.filter((l)=>l.section===c).map((l)=>l.name).join(" · ")}`),"",...i].join(`
345
+ `)}let s=Math.max(...n.map((o)=>_o(o).length));return["Usage: ttheme <command>","",Tt.description,...r.flatMap(({section:o,title:a})=>["",a,...If(n.filter((c)=>c.section===o).map((c)=>[_o(c),c.about]),s)]),"","Examples",...If(IN),"",...i].join(`
346
+ `)}import{readFileSync as xN}from"node:fs";import{join as NN}from"node:path";var xf="# ttheme begin",Nf="# ttheme end",Ms=/# ttheme begin\n[\s\S]*?# ttheme end\n?/;function Nr(t,e){let n=`${xf}
352
347
  ${e}
353
- ${Cl}
354
- `;if(Oi.test(t))return t.replace(Oi,n);if(t==="")return n;return`${t.replace(/\n*$/,`
348
+ ${Nf}
349
+ `;if(Ms.test(t))return t.replace(Ms,n);if(t==="")return n;return`${t.replace(/\n*$/,`
355
350
  `)}
356
- ${n}`}function Xn(t){let e=t.replace(/\n?# ttheme begin\n[\s\S]*?# ttheme end(?=\n|$)/,"");if(e===t)return t;return e.trim()===""?"":e.replace(/\n*$/,`
357
- `)}function tr(t,e){let n=t.replace(Oi,"");return new RegExp(String.raw`^[ \t]*${e}(?:[ \t]*=|[ \t]+\S)`,"m").test(n)}function kb(t){return`source ${t}/ttheme.zsh`}var L2="# ttheme settings — uncomment a line to change it; exported variables win over this file",Ni={TTHEME_TAB_PALETTE:{doc:"# new tabs: off keeps the configured terminal theme, seq rotates through the palettes (default off)",default:"off"},TTHEME_ANNOUNCE:{doc:'# the palette notice under "Last login:": 1 shows it, 0 silences it (default 1)',default:"1"},TTHEME_FX:{doc:"# search hint animation: typewriter, decode or glitch (default typewriter)",default:"typewriter"},TTHEME_SORT:{doc:"# series and palettes in ttheme and preview: abc sorts them by name, series keeps the order they were added (default abc)",default:"abc"},TTHEME_BG_BLUR:{doc:"# soften the background pictures behind the text: a blur radius in screen pixels, 0 keeps them sharp — changing it draws every picture again (default 0)",default:"0"},TTHEME_BG_COLORS:{doc:"# the colors new background pictures are drawn in: tone tints a picture in one color of its palette, original keeps its own — preview switches each picture later (default tone)",default:"tone"},TTHEME_WARP_FAST:{doc:"# Warp tab switches: on keeps Warp rereading its settings while it is in front with tabs of different palettes, so the tab you switch to shows its palette in about 0.2 s instead of 0.6 s — about 8% CPU meanwhile; off leaves it to Warp (default on)",default:"on"},TTHEME_FIND_RATING:{doc:"# the ratings find lists, any of safe, questionable and explicit, each booru read in its own rating vocabulary (default safe)",default:"safe"},TTHEME_FIND_BLOCK:{doc:'# the posts find drops by tag: nudity, underwear, both, or none to keep them all (default "nudity underwear")',default:"nudity underwear"},TTHEME_FIND_POSTS:{doc:"# what find lists first: all is every post of the character, cutouts are the transparent ones (default all)",default:"all"},TTHEME_FIND_SOLO:{doc:"# on keeps the posts tagged solo, the character alone, by danbooru or zerochan; off lists every post (default on)",default:"on"},TTHEME_FIND_CUTOUTS:{doc:'# the tags find calls a transparent cutout, per site as key=tag,tag pairs — e.g. "konachan=transparent,vector yande=transparent_png" (default the built-in tags)',default:""},TTHEME_FIND_ORDER:{doc:"# the order find lists posts in: fit ranks each page by how well it makes a backdrop, newest or score (default fit)",default:"fit"},TTHEME_FIND_SETS:{doc:"# runs of the same picture at the same size from one uploader: fold shows them as one tile, show lists each (default fold)",default:"fold"},TTHEME_FIND_REMOVE_BG:{doc:"# an opaque picture tried on in find: on cuts the character out with macOS Vision, off leaves it as it is (default on)",default:"on"},TTHEME_FIND_MIN_SCORE:{doc:"# the lowest score find lists: off, or a number such as 5, 10, 25, 50 or 100 — danbooru, konachan and yande.re filter by it, zerochan keeps no score (default off)",default:"off"},TTHEME_FIND_MIN_SIZE:{doc:"# the shortest side a picture find lists must reach, in pixels: off, or a number such as 720, 1080, 1440, 1800 or 2560 (default off)",default:"off"},TTHEME_FIND_SITES:{doc:"# the sites find mixes in its all tab: any of danbooru, konachan, yande.re and zerochan (default all four)",default:"danbooru konachan yande.re zerochan"},TTHEME_FIND_HIDE:{doc:"# the kinds of picture find leaves out by tag: comic, monochrome, sketch, chibi, or none to keep them all (default none)",default:"none"},TTHEME_FIND_HIDE_TAGS:{doc:'# more tags find leaves out, spaced — e.g. "cosplay multiple_girls" (default none)',default:""},TTHEME_FIND_PNG:{doc:"# on lists PNG originals only — a zerochan post counts only where danbooru holds the same file (default off)",default:"off"},TTHEME_FIND_HOSTS:{doc:'# send a find site somewhere else, as key=https://host pairs — e.g. "danbooru=https://danbooru.donmai.us" (default none)',default:""}};function To(t){return Ni[t]?.default}function jl(t,e){let n=`: \${${t}:=${e}}`;return To(t)===e?`# ${n}`:n}function yb(t){return new RegExp(String.raw`^#? ?: \$\{${t}[^\n]*$`,"m")}function T2(t,e){if(yb(e).test(t))return t;let n=Ni[e];return`${t.replace(/\n*$/,`
351
+ ${n}`}function Rr(t){let e=t.replace(/\n?# ttheme begin\n[\s\S]*?# ttheme end(?=\n|$)/,"");if(e===t)return t;return e.trim()===""?"":e.replace(/\n*$/,`
352
+ `)}function Tr(t,e){let n=t.replace(Ms,"");return new RegExp(String.raw`^[ \t]*${e}(?:[ \t]*=|[ \t]+\S)`,"m").test(n)}function A0(t){return`source ${t}/ttheme.zsh`}var RN="# ttheme settings — uncomment a line to change it; exported variables win over this file",Os={TTHEME_TAB_PALETTE:{doc:"# new tabs: off keeps the configured terminal theme, seq rotates through the palettes (default off)",default:"off"},TTHEME_ANNOUNCE:{doc:'# the palette notice under "Last login:": 1 shows it, 0 silences it (default 1)',default:"1"},TTHEME_FX:{doc:"# search hint animation: typewriter, decode or glitch (default typewriter)",default:"typewriter"},TTHEME_SORT:{doc:"# series and palettes in ttheme and preview: abc sorts them by name, series keeps the order they were added (default abc)",default:"abc"},TTHEME_MOUSE:{doc:"# clicks, the wheel and drags in preview, browse, the palette editor and find: on, or off to leave the mouse to the terminal, so a drag selects text again without a modifier (default on)",default:"on"},TTHEME_BG_BLUR:{doc:"# soften the background pictures behind the text: a blur radius in screen pixels, 0 keeps them sharp — changing it draws every picture again (default 0)",default:"0"},TTHEME_BG_COLORS:{doc:"# the colors new background pictures are drawn in: tone tints a picture in one color of its palette, original keeps its own — preview switches each picture later (default tone)",default:"tone"},TTHEME_WARP_FAST:{doc:"# Warp tab switches: on keeps Warp rereading its settings while it is in front with tabs of different palettes, so the tab you switch to shows its palette in about 0.2 s instead of 0.6 s — about 8% CPU meanwhile; off leaves it to Warp (default on)",default:"on"},TTHEME_NAMES:{doc:"# character names in every language for searching palettes and find's search box, from aninames' weekly release: on downloads them (about 7 MB) and checks once a day in the background; off leaves them as they are (default on)",default:"on"},TTHEME_MARKET_LOOKUP:{doc:"# the Markets tab in browse: on looks GitHub up by itself — the markets carrying the ttheme-market topic when the tab opens or you type, and the index of a repository you type or move onto; off waits for space (default on)",default:"on"},TTHEME_FIND_RATING:{doc:"# the ratings find lists, any of safe, questionable and explicit, each booru read in its own rating vocabulary (default safe)",default:"safe"},TTHEME_FIND_BLOCK:{doc:'# the posts find drops by tag: nudity, underwear, both, or none to keep them all (default "nudity underwear")',default:"nudity underwear"},TTHEME_FIND_POSTS:{doc:"# what find lists first: all is every post of the character, cutouts are the transparent ones (default all)",default:"all"},TTHEME_FIND_SOLO:{doc:"# on keeps the posts tagged solo, the character alone, by danbooru or zerochan; off lists every post (default on)",default:"on"},TTHEME_FIND_CUTOUTS:{doc:'# the tags find calls a transparent cutout, per site as key=tag,tag pairs — e.g. "konachan=transparent,vector yande=transparent_png" (default the built-in tags)',default:""},TTHEME_FIND_ORDER:{doc:"# the order find lists posts in: fit ranks each page by how well it makes a backdrop, newest or score (default fit)",default:"fit"},TTHEME_FIND_SETS:{doc:"# runs of the same picture at the same size from one uploader: fold shows them as one tile, show lists each (default fold)",default:"fold"},TTHEME_FIND_REMOVE_BG:{doc:"# an opaque picture tried on in find: on cuts the character out with macOS Vision, off leaves it as it is (default on)",default:"on"},TTHEME_FIND_MIN_SCORE:{doc:"# the lowest score find lists: off, or a number such as 5, 10, 25, 50 or 100 — danbooru, konachan and yande.re filter by it, zerochan keeps no score (default off)",default:"off"},TTHEME_FIND_MIN_SIZE:{doc:"# the shortest side a picture find lists must reach, in pixels: off, or a number such as 720, 1080, 1440, 1800 or 2560 (default off)",default:"off"},TTHEME_FIND_SITES:{doc:"# the sites find mixes in its all tab: any of danbooru, konachan, yande.re and zerochan (default all four)",default:"danbooru konachan yande.re zerochan"},TTHEME_FIND_HIDE:{doc:"# the kinds of picture find leaves out by tag: comic, monochrome, sketch, chibi, or none to keep them all (default none)",default:"none"},TTHEME_FIND_HIDE_TAGS:{doc:'# more tags find leaves out, spaced — e.g. "cosplay multiple_girls" (default none)',default:""},TTHEME_FIND_PNG:{doc:"# on lists PNG originals only — a zerochan post counts only where danbooru holds the same file (default off)",default:"off"},TTHEME_FIND_HOSTS:{doc:'# send a find site somewhere else, as key=https://host pairs — e.g. "danbooru=https://danbooru.donmai.us" (default none)',default:""}};function Uo(t){return Os[t]?.default}function Rf(t,e){let n=`: \${${t}:=${e}}`;return Uo(t)===e?`# ${n}`:n}function F0(t){return new RegExp(String.raw`^#? ?: \$\{${t}[^\n]*$`,"m")}function TN(t,e){if(F0(e).test(t))return t;let n=Os[e];return`${t.replace(/\n*$/,`
358
353
  `)}
359
354
  ${n.doc}
360
- ${jl(e,n.default)}
361
- `}var Oa=Object.keys(Ni),A2=8;function Na(t,e){let n="";try{n=F2(x2(t,"ttheme","config.zsh"),"utf8")}catch{}return(new RegExp(String.raw`^: \$\{${e}:=([^}\n]*)\}`,"m").exec(n)?.[1]??Ni[e].default).replace(/^(["'])(.*)\1$/,"$2")}function er(t){let e=Number(Na(t,"TTHEME_BG_BLUR"));return Number.isFinite(e)?Math.min(A2,Math.max(0,e)):0}function Ra(t){return Na(t,"TTHEME_BG_COLORS")==="original"?"original":"tone"}function Gl(){let t=Object.entries(Ni).map(([e,n])=>`${n.doc}
362
- ${jl(e,n.default)}`);return`${[L2,...t].join(`
355
+ ${Rf(e,n.default)}
356
+ `}var Dc=Object.keys(Os),PN=8;function qc(t,e){let n="";try{n=xN(NN(t,"ttheme","config.zsh"),"utf8")}catch{}return(new RegExp(String.raw`^: \$\{${e}:=([^}\n]*)\}`,"m").exec(n)?.[1]??Os[e].default).replace(/^(["'])(.*)\1$/,"$2")}function Pr(t){let e=Number(qc(t,"TTHEME_BG_BLUR"));return Number.isFinite(e)?Math.min(PN,Math.max(0,e)):0}function Yc(t){return qc(t,"TTHEME_BG_COLORS")==="original"?"original":"tone"}function Tf(){let t=Object.entries(Os).map(([e,n])=>`${n.doc}
357
+ ${Rf(e,n.default)}`);return`${[RN,...t].join(`
363
358
 
364
359
  `)}
365
- `}function Pa(t,e,n){let r=jl(e,n),i=yb(e);if(i.test(t))return t.replace(i,r);return`${t.replace(/\n*$/,`
360
+ `}function Jc(t,e,n){let r=Rf(e,n),i=F0(e);if(i.test(t))return t.replace(i,r);return`${t.replace(/\n*$/,`
366
361
  `)}
367
362
  ${r}
368
- `}function vb(t){if(t==="")return Gl();return Object.keys(Ni).reduce(T2,t)}var Eb=/["$`\\]/;function C2(t){return t.replace(/_\([^)]*\)$/,"").replaceAll("_"," ")}function Ul(t,e,n=[],r={}){for(let l of t)for(let f of[l.name,l.group,l.native??"",...l.nativeNames??[],l.ansiSource])if(Eb.test(f))throw Error(`${l.name}: "${f}" contains a character that breaks zsh quoting`);let i=Math.max(0,...t.map((l)=>l.name.length)),o=(l,f)=>` ${l.name.padEnd(i)} "${f}"`,s=(l)=>l.map((f)=>f.name).join(" "),a=Mt(t),c=(l)=>`'${l.replaceAll("'","'\\''")}'`,u=xo.filter((l)=>l.section!=="setup"&&!l.hidden);return["# Generated by `mise run build` — do not edit.","# Source of truth: themes/*.toml in the ttheme repo.","",`typeset -g TTHEME_VERSION=${Ot.version}`,"",'# the palette new tabs open with, which the iTerm2 "ttheme · default" profile wears',`typeset -g TTHEME_STARTUP=${e??""}`,"","# the terminals ttheme is wired into: a picture change reaches every one of them, from whichever runs the shell",`typeset -ga TTHEME_TERMINALS=(${n.join(" ")})`,...Object.keys(r).length>0?["","# what a wired terminal's adapter needs to know of it (src/terminals/)",...Object.entries(r).map(([l,f])=>`typeset -g ${l}=${c(f)}`)]:[],"","# the commands the shell layer knows (src/verbs.ts): help, completion and argument checks read them",`typeset -ga TTHEME_VERBS=(${u.map((l)=>l.name).join(" ")})`,`typeset -ga TTHEME_TAB_VERBS=(${u.filter((l)=>l.section==="tab").map((l)=>l.name).join(" ")})`,`typeset -ga TTHEME_SHELL_VERBS=(${u.filter((l)=>l.shell).map((l)=>l.name).join(" ")})`,"typeset -gA TTHEME_VERB_ARGS=(",...u.map((l)=>` ${l.name} ${c(l.args.join(" "))}`),")","typeset -gA TTHEME_VERB_ABOUT=(",...u.map((l)=>` ${l.name} ${c(l.about)}`),")",`typeset -g TTHEME_HELP=${c(Lo(!1,!0))}`,`typeset -g TTHEME_HELP_ALL=${c(Lo(!0,!0))}`,"","# the screens the bare ttheme switches between (src/hub.ts): the exit status of a screen run by the CLI says where it went",`typeset -ga TTHEME_HUB_TABS=(${Yn.map((l)=>l.name).join(" ")})`,`typeset -ga TTHEME_HUB_TITLES=(${Yn.map((l)=>l.title).join(" ")})`,`typeset -gi TTHEME_HUB_CLOSED=${Ma} TTHEME_HUB_SWITCH=${tb}`,"","# the settings config.zsh holds, handed to the CLI on every call",`typeset -ga TTHEME_SETTINGS=(${Oa.join(" ")})`,"","# seed for `ttheme config` when no config.zsh exists yet",`typeset -g TTHEME_CONFIG_TEMPLATE='${Gl().trimEnd().replaceAll("'","'\\''")}'`,"","typeset -gA TTHEME_PALETTE=(",...t.map((l)=>o(l,[l.background,l.foreground,l.cursor,l.selection,...l.ansi].join(" "))),")","","# series order: new tabs cycle through it and TTHEME_SORT=series lists it — the default role stays applyable but unlisted",`typeset -ga TTHEME_ORDER=(${s(a)})`,"","# the same palettes by series name, then palette name: TTHEME_SORT=abc lists them this way",`typeset -ga TTHEME_ABC=(${s(Ir(a))})`,"","typeset -gA TTHEME_GROUP=(",...t.map((l)=>o(l,l.group)),")","","# the catalog a market palette sits in — the folder under the market's palettes/, one level below the market in every list","typeset -gA TTHEME_CATALOG=(",...t.filter((l)=>l.catalog).map((l)=>o(l,l.catalog??"")),")","","# original-language title, rendered dim next to the group","typeset -gA TTHEME_NATIVE=(",...t.filter((l)=>l.native).map((l)=>o(l,l.native??"")),")","","# the character's names in its original language, |-separated, and as its booru tag spells it: preview searches both","typeset -gA TTHEME_NATIVE_NAMES=(",...t.filter((l)=>l.nativeNames).map((l)=>o(l,(l.nativeNames??[]).join("|"))),")","typeset -gA TTHEME_CHARACTER=(",...t.filter((l)=>l.booru&&!Eb.test(l.booru)).map((l)=>o(l,C2(l.booru??""))),")","","# the example scenes preview draws beside the list (src/scenes.ts), each line as «role»text runs",`typeset -ga TTHEME_SCENES=(${de.map((l)=>l.name).join(" ")})`,...de.flatMap((l,f)=>[`typeset -ga TTHEME_SCENE_${f+1}=(`,...l.lines.map((d)=>` ${c(d)}`),")"]),"","# each booru's ANSI color, which marks a link to one of its posts",`typeset -gA TTHEME_SITE_ANSI=(${q.map((l)=>`${l.name} ${l.ansi}`).join(" ")})`,"","# the terminals that open OSC 8 links (src/terminal.ts)",`typeset -ga TTHEME_LINKS=(${Object.entries(Oe).flatMap(([l,f])=>f.links?[l]:[]).join(" ")})`,"","# the six colors a list row shows: foreground, the signature, then red and green","typeset -gA TTHEME_SWATCH=(",...t.map((l)=>o(l,ha(l).join(" "))),")","","# where each palette's 16 ANSI colors came from","typeset -gA TTHEME_SRC=(",...t.map((l)=>o(l,l.ansiSource)),")",""].join(`
369
- `)}var Wl={id:"shell",emitShared(t){return[{path:"shell/palettes.zsh",content:Ul(t.map(ve))}]}};import{createHash as j2}from"node:crypto";var G2=["black","red","green","yellow","blue","magenta","cyan","white"];function Sb(t,e){return[` ${t}:`,...G2.map((n,r)=>` ${n}: "${e[r]}"`)]}function U2(t,e,n){let r=j2("sha1");for(let i of e)r.update(i);return`${x(t)}.${r.digest("hex").slice(0,8)}.${n}`}function Mb(t,e,n){let r=2166136261;for(let i of Buffer.from(`${e}
370
- ${n.toLowerCase()}`,"utf8"))r=Math.imul(r^i,16777619)>>>0;return`${x(t)}.${r.toString(16).padStart(8,"0")}.png`}function Ao(t,e){return e?U2(t,[e.image,String(Ib(e))],"yaml"):`${x(t)}.yaml`}function Ib(t){return Math.max(0,Math.min(100,Math.round(t.opacity*100)))}function Co(t,e){return[`name: "${t.name}"`,`background: "${t.background}"`,`foreground: "${t.foreground}"`,`accent: "${t.cursor}"`,`cursor: "${t.cursor}"`,`details: ${yt(t.background)<0.18?"darker":"lighter"}`,...e?["background_image:",` path: "${e.image}"`,` opacity: ${Ib(e)}`]:[],"terminal_colors:",...Sb("normal",t.ansi.slice(0,8)),...Sb("bright",t.ansi.slice(8,16)),""].join(`
371
- `)}var _l={id:"warp",limits:"no selection color, and Warp paints one theme app-wide",emit(t){return[{path:`warp/themes/${Ao(t.name)}`,content:Co(t)}]}};var Ob=(t)=>`[${t.map((e)=>`"${e}"`).join(", ")}]`,Bl={id:"wezterm",limits:"OSC repaints per pane, pictures show per window",emit(t){let e=["[metadata]",`name = "${x(t.name)}"`,`origin_url = "${t.ansiSource}"`,"","[colors]",`foreground = "${t.foreground}"`,`background = "${t.background}"`,`cursor_bg = "${t.cursor}"`,`cursor_border = "${t.cursor}"`,`cursor_fg = "${t.background}"`,`selection_bg = "${t.selectionBackground}"`,`selection_fg = "${t.foreground}"`,"",`ansi = ${Ob(t.ansi.slice(0,8))}`,`brights = ${Ob(t.ansi.slice(8,16))}`,""].join(`
372
- `);return[{path:`wezterm/colors/${x(t.name)}.toml`,content:e}]}},Ri=(t)=>JSON.stringify(t);function Nb(t){return["-- Generated by ttheme — rewritten on every add, remove and default; do not edit.","local wezterm = require 'wezterm'","",`local MODULE = ${Ri(t.path)}`,`local COLORS = ${Ri(t.colors)}`,`local BACKGROUNDS = ${Ri(t.backgrounds)}`,`local STARTUP = ${t.startup?Ri(x(t.startup)):"nil"}`,"local PALETTES = {",...t.palettes.map((e)=>` [${Ri(e.name)}] = ${Ri(e.background)},`),"}","","local X = { left = 'Left', center = 'Center', right = 'Right' }","local Y = { top = 'Top', center = 'Middle', bottom = 'Bottom' }","local SIZE = { cover = 'Cover', contain = 'Contain', stretch = '100%' }","","local function locate(path)"," if path:sub(1, 2) == '~/' then"," return os.getenv('HOME') .. path:sub(2)"," elseif path:sub(1, 1) == '/' or path:match('^%a:[/\\\\]') then"," return path"," end"," return BACKGROUNDS .. '/' .. path","end","","local function read(path, into)"," local f = io.open(path, 'r')"," if not f then"," return false"," end"," for line in f:lines() do"," local key, value = line:match('^%s*([%w%-]+)%s*=%s*(.-)%s*$')"," if key == 'config-file' then"," read(locate((value:gsub('^%?', ''))), into)"," elseif key then"," into[key] = value"," end"," end"," f:close()"," return true","end","","local function layers(palette)"," local color = PALETTES[palette]"," local c = {}"," if not color or not read(BACKGROUNDS .. '/' .. ((palette:gsub('@', '--', 1)):gsub('/', '--', 1)) .. '.conf', c) then"," return nil, 'none'"," end"," local image = c['background-image'] or ''"," local opacity = tonumber(c['background-image-opacity'] or '1') or 1"," if image == '' or opacity <= 0 then"," return nil, 'none'"," end"," local fit = c['background-image-fit'] or 'contain'"," local position = c['background-image-position'] or 'center'"," local y, x = position:match('^(%a+)-(%a+)$')"," local rep = c['background-image-repeat'] == 'true' and 'Repeat' or 'NoRepeat'"," return {"," { source = { Color = color }, width = '100%', height = '100%' },"," {"," source = { File = locate(image) },"," opacity = opacity,"," width = SIZE[fit],"," height = SIZE[fit],"," horizontal_align = X[x or 'center'],"," vertical_align = Y[y or 'center'],"," repeat_x = rep,"," repeat_y = rep,"," },"," }, table.concat({ color, image, opacity, fit, position, rep }, '|')","end","","local function framed(window, view)"," local color, image, opacity, W, H, w, h, x, y, at ="," view:match('^([^|]*)|([^|]*)|([^|]*)|(%d+)|(%d+)|(%-?%d+)|(%-?%d+)|(%-?%d+)|(%-?%d+)|(%d)$')"," if not image or image == '' or tonumber(W) == 0 or tonumber(H) == 0 then"," return nil, 'none'"," end"," local d = window:get_dimensions()"," local k = math.max(d.pixel_width / W, d.pixel_height / H)"," local n = tonumber(at) - 1"," local ax, ay = n % 3, n // 3"," local px = function(n) return string.format('%.2fpx', n) end"," return {"," { source = { Color = color }, width = '100%', height = '100%' },"," {"," source = { File = image },"," opacity = tonumber(opacity) or 1,"," width = px(w * k),"," height = px(h * k),"," horizontal_align = 'Left',"," vertical_align = 'Top',"," horizontal_offset = px(ax * (d.pixel_width - W * k) / 2 + x * k),"," vertical_offset = px(ay * (d.pixel_height - H * k) / 2 + y * k),"," repeat_x = 'NoRepeat',"," repeat_y = 'NoRepeat',"," },"," }, table.concat({ view, d.pixel_width, d.pixel_height }, '|')","end","","local shown = {}","","local function show(window, pane)"," local vars = pane:get_user_vars()"," local id = window:window_id()"," local background, key"," if vars.ttheme_view and vars.ttheme_view ~= '' then"," background, key = framed(window, vars.ttheme_view)"," elseif vars.ttheme_shown and vars.ttheme_shown ~= '' then"," background, key = layers(vars.ttheme_shown)"," elseif shown[id] == nil then"," return"," end"," if shown[id] == key then"," return"," end"," shown[id] = key"," local overrides = window:get_config_overrides() or {}"," overrides.background = background"," window:set_config_overrides(overrides)","end","","wezterm.on('user-var-changed', function(window, pane, name)"," if name == 'ttheme_shown' or name == 'ttheme_view' then"," show(window, pane)"," end","end)","wezterm.on('update-status', show)","","return function(config)"," local dirs = config.color_scheme_dirs or {}"," table.insert(dirs, COLORS)"," config.color_scheme_dirs = dirs"," if STARTUP then"," config.color_scheme = STARTUP"," end"," wezterm.add_to_config_reload_watch_list(MODULE)","end",""].join(`
373
- `)}var Rb=["black","red","green","yellow","blue","purple","cyan","white"];function Pb(t){return{name:x(t.name),background:t.background,foreground:t.foreground,cursorColor:t.cursor,selectionBackground:t.selectionBackground,...Object.fromEntries(Rb.map((e,n)=>[e,t.ansi[n]])),...Object.fromEntries(Rb.map((e,n)=>[`bright${e[0]?.toUpperCase()}${e.slice(1)}`,t.ansi[n+8]]))}}function zl(t,e,n){let r={...e&&n?{profiles:[{updates:e,colorScheme:x(n)}]}:{},schemes:t.map(Pb)};return`${JSON.stringify(r,null,2)}
374
- `}var Kl={id:"windows-terminal",limits:"no kitty graphics, so no pictures; OSC repaints per pane",emit(t){return[{path:`windows-terminal/schemes/${x(t.name)}.json`,content:`${JSON.stringify(Pb(t),null,2)}
375
- `}]},emitShared(t){return[{path:"windows-terminal/ttheme.json",content:zl(t)}]}};function Dn(t){return[`# ${t.name} — ${t.group}${t.native?` (${t.native})`:""}`,`# ANSI: ${t.ansiSource}`]}import{execFileSync as W2}from"node:child_process";import{existsSync as Hb,readdirSync as _2,readFileSync as B2}from"node:fs";import{join as Fb}from"node:path";function it(t){return Hb(t)?B2(t,"utf8"):""}function It(t,e){return t.startsWith(`${e}/`)?`~${t.slice(e.length)}`:t}function Ha(t){return[...new Set(t.split(`
376
- `).map((e)=>e.split(/[ =]/)[0]))].join(", ")}function Ke(t,e){let n=it(t),r=e(n);return r===n?[]:[{file:t,content:r}]}function jo(t){return process.env.XDG_DATA_HOME??Fb(t,".local","share")}function Fa(t){return Hb(t)?_2(t).flatMap((e)=>e.startsWith(x(""))?[Fb(t,e)]:[]):[]}function ql(t,e){if(!t.shelf)return[];let n=`${[t.id,t.shelf.from].filter(Boolean).join("/")}/`;return(t.emitter.emit?.(e)??[]).flatMap((r)=>{let i=r.path.startsWith(n)?r.path.slice(n.length):"";return i!==""&&!i.includes("/")?[{file:i,content:r.content}]:[]})}function Pr(){return{platform:process.platform,env:process.env,run:(t,e)=>{try{return W2(t,[...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5000}).trim()}catch{return}}}}import{existsSync as xb}from"node:fs";import{join as La}from"node:path";function z2(t){let e=t.replace(Oi,"");return/^[ \t]*\[colors[\].]/m.test(e)||/^[ \t]*colors[ \t]*[.=]/m.test(e)}var K2=/^[ \t]*\[general\][ \t]*(?:#.*)?$/m,Lb=/^[ \t]*\[/m,Tb=/^[ \t]*import[ \t]*=/m,q2=/^[ \t]*general[ \t]*[.=]/m;function J2(t){return t?`[general]
377
- import = ["${t}"]`:""}function Jl(t,e){let n=t.replace(Oi,""),r=K2.exec(n);if(!r){let c=n.search(Lb),u=c<0?n:n.slice(0,c);if(q2.test(n)||Tb.test(u))return;return Qn(t,J2(e))}let i=r.index+r[0].length,o=n.slice(i),s=o.search(Lb);if(Tb.test(s<0?o:o.slice(0,s)))return;let a=e?`import = ["${e}"]
363
+ `}function C0(t){if(t==="")return Tf();return Object.keys(Os).reduce(TN,t)}var Vc=/["$`\\]/;function HN(t){return t.replace(/_\([^)]*\)$/,"").replaceAll("_"," ")}function Pf(t,e,n=[],r={}){for(let l of t)for(let d of[l.name,l.group,l.native??"",...l.nativeNames??[],l.ansiSource])if(Vc.test(d))throw Error(`${l.name}: "${d}" contains a character that breaks zsh quoting`);let i=Math.max(0,...t.map((l)=>l.name.length)),s=(l,d)=>` ${l.name.padEnd(i)} "${d}"`,o=(l)=>l.map((d)=>d.name).join(" "),a=Et(t),c=(l)=>`'${l.replaceAll("'","'\\''")}'`,u=Bo.filter((l)=>l.section!=="setup"&&!l.hidden);return["# Generated by `mise run build` — do not edit.","# Source of truth: themes/*.toml in the ttheme repo.","",`typeset -g TTHEME_VERSION=${Tt.version}`,"",'# the palette new tabs open with, which the iTerm2 "ttheme · default" profile wears',`typeset -g TTHEME_STARTUP=${e??""}`,"","# the terminals ttheme is wired into: a picture change reaches every one of them, from whichever runs the shell",`typeset -ga TTHEME_TERMINALS=(${n.join(" ")})`,...Object.keys(r).length>0?["","# what a wired terminal's adapter needs to know of it (src/terminals/)",...Object.entries(r).map(([l,d])=>`typeset -g ${l}=${c(d)}`)]:[],"","# the commands the shell layer knows (src/verbs.ts): help, completion and argument checks read them",`typeset -ga TTHEME_VERBS=(${u.map((l)=>l.name).join(" ")})`,`typeset -ga TTHEME_TAB_VERBS=(${u.filter((l)=>l.section==="tab").map((l)=>l.name).join(" ")})`,`typeset -ga TTHEME_SHELL_VERBS=(${u.filter((l)=>l.shell).map((l)=>l.name).join(" ")})`,"typeset -gA TTHEME_VERB_ARGS=(",...u.map((l)=>` ${l.name} ${c(l.args.join(" "))}`),")","typeset -gA TTHEME_VERB_ABOUT=(",...u.map((l)=>` ${l.name} ${c(l.about)}`),")",`typeset -g TTHEME_HELP=${c(Wo(!1,!0))}`,`typeset -g TTHEME_HELP_ALL=${c(Wo(!0,!0))}`,"","# the screens the bare ttheme switches between (src/hub.ts): the exit status of a screen run by the CLI says where it went",`typeset -ga TTHEME_HUB_TABS=(${Fn.map((l)=>l.name).join(" ")})`,`typeset -ga TTHEME_HUB_TITLES=(${Fn.map((l)=>l.title).join(" ")})`,`typeset -gi TTHEME_HUB_CLOSED=${Oc} TTHEME_HUB_SWITCH=${Ic}`,"","# the settings config.zsh holds, handed to the CLI on every call",`typeset -ga TTHEME_SETTINGS=(${Dc.join(" ")})`,"","# seed for `ttheme config` when no config.zsh exists yet",`typeset -g TTHEME_CONFIG_TEMPLATE='${Tf().trimEnd().replaceAll("'","'\\''")}'`,"","typeset -gA TTHEME_PALETTE=(",...t.map((l)=>s(l,[l.background,l.foreground,l.cursor,l.selection,...l.ansi].join(" "))),")","","# series order: new tabs cycle through it and TTHEME_SORT=series lists it — the default role stays applyable but unlisted",`typeset -ga TTHEME_ORDER=(${o(a)})`,"","# the same palettes by series name, then palette name: TTHEME_SORT=abc lists them this way",`typeset -ga TTHEME_ABC=(${o(ci(a))})`,"","typeset -gA TTHEME_GROUP=(",...t.map((l)=>s(l,l.group)),")","","# the catalog a market palette sits in — the folder under the market's palettes/, one level below the market in every list","typeset -gA TTHEME_CATALOG=(",...t.filter((l)=>l.catalog).map((l)=>s(l,l.catalog??"")),")","","# original-language title, rendered dim next to the group","typeset -gA TTHEME_NATIVE=(",...t.filter((l)=>l.native).map((l)=>s(l,l.native??"")),")","","# the character's names in its original language, |-separated, and as its booru tag spells it: preview searches both","typeset -gA TTHEME_NATIVE_NAMES=(",...t.filter((l)=>l.nativeNames).map((l)=>s(l,(l.nativeNames??[]).join("|"))),")","typeset -gA TTHEME_CHARACTER=(",...t.filter((l)=>l.booru&&!Vc.test(l.booru)).map((l)=>s(l,HN(l.booru??""))),")","","# the example scenes preview draws beside the list (src/scenes.ts), each line as «role»text runs",`typeset -ga TTHEME_SCENES=(${te.map((l)=>l.name).join(" ")})`,...te.flatMap((l,d)=>[`typeset -ga TTHEME_SCENE_${d+1}=(`,...l.lines.map((f)=>` ${c(f)}`),")"]),"","# each booru's ANSI color, which marks a link to one of its posts",`typeset -gA TTHEME_SITE_ANSI=(${Y.map((l)=>`${l.name} ${l.ansi}`).join(" ")})`,"","# the terminals that open OSC 8 links (src/terminal.ts)",`typeset -ga TTHEME_LINKS=(${Object.entries(ae).flatMap(([l,d])=>d.links?[l]:[]).join(" ")})`,"","# the six colors a list row shows: foreground, the signature, then red and green","typeset -gA TTHEME_SWATCH=(",...t.map((l)=>s(l,ac(l).join(" "))),")","","# where each palette's 16 ANSI colors came from","typeset -gA TTHEME_SRC=(",...t.map((l)=>s(l,l.ansiSource)),")",""].join(`
364
+ `)}function L0(t){let e=Object.entries(t).flatMap(([r,i])=>{let s=i.filter((o)=>!Vc.test(o)&&!o.includes("|"));return s.length>0&&!Vc.test(r)?[[r,s.join("|")]]:[]}),n=Math.max(0,...e.map(([r])=>r.length));return["# the character's other names in every language, |-separated, from the aninames index in the cache: preview reads this when it opens and searches them too","typeset -gA TTHEME_ALIASES=(",...e.map(([r,i])=>` ${r.padEnd(n)} "${i}"`),")",""].join(`
365
+ `)}var Hf={id:"shell",emitShared(t){return[{path:"shell/palettes.zsh",content:Pf(t.map(Te))}]}};import{execFileSync as AN}from"node:child_process";import{existsSync as j0,readdirSync as FN,readFileSync as CN}from"node:fs";import{join as G0}from"node:path";function it(t){return j0(t)?CN(t,"utf8"):""}function Rt(t,e){return t.startsWith(`${e}/`)?`~${t.slice(e.length)}`:t}function Zc(t){return[...new Set(t.split(`
366
+ `).map((e)=>e.split(/[ =]/)[0]))].join(", ")}function hn(t,e){let n=it(t),r=e(n);return r===n?[]:[{file:t,content:r}]}function Ko(t){return process.env.XDG_DATA_HOME??G0(t,".local","share")}function Is(t){return j0(t)?FN(t).flatMap((e)=>e.startsWith(A(""))?[G0(t,e)]:[]):[]}function Af(t,e){if(!t.shelf)return[];let n=`${[t.id,t.shelf.from].filter(Boolean).join("/")}/`;return(t.emitter.emit?.(e)??[]).flatMap((r)=>{let i=r.path.startsWith(n)?r.path.slice(n.length):"";return i!==""&&!i.includes("/")?[{file:i,content:r.content}]:[]})}function ze(){return{platform:process.platform,env:process.env,run:(t,e)=>{try{return AN(t,[...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5000}).trim()}catch{return}}}}import{existsSync as Q0}from"node:fs";import{join as Xc}from"node:path";var LN=["black","red","green","yellow","blue","magenta","cyan","white"];function _0(t,e){return[t,...LN.map((n,r)=>`${n} = '${e[r]}'`),""].join(`
367
+ `)}var Ff={id:"alacritty",limits:"no runtime color API (OSC only)",emit(t){let e=[...Ir(t),"","[colors.primary]",`background = '${t.background}'`,`foreground = '${t.foreground}'`,"","[colors.cursor]",`cursor = '${t.cursor}'`,`text = '${t.background}'`,"","[colors.selection]",`background = '${t.selectionBackground}'`,`text = '${t.foreground}'`,"",_0("[colors.normal]",t.ansi.slice(0,8)),_0("[colors.bright]",t.ansi.slice(8,16))].join(`
368
+ `);return[{path:`alacritty/themes/${A(t.name)}.toml`,content:e}]}};var Cf={id:"ghostty",emit(t){let e=[...Ir(t),`background = ${t.background}`,`foreground = ${t.foreground}`,`cursor-color = ${t.cursor}`,`selection-background = ${t.selectionBackground}`,`selection-foreground = ${t.foreground}`,...t.ansi.map((n,r)=>`palette = ${r}=${n}`),"","macos-icon = custom-style",`macos-icon-ghost-color = ${t.ghostty.iconGhost}`,`macos-icon-screen-color = ${t.ghostty.iconScreen.join(",")}`,"macos-icon-frame = chrome",""].join(`
369
+ `);return[{path:`ghostty/themes/${A(t.name)}`,content:e}]}};function Hr(t){let[e,n,r]=nt(t);return{"Alpha Component":1,"Blue Component":r/255,"Color Space":"P3","Green Component":n/255,"Red Component":e/255}}function W0(t){return{...Object.fromEntries(t.ansi.map((e,n)=>[`Ansi ${n} Color`,Hr(e)])),"Background Color":Hr(t.background),"Bold Color":Hr(t.foreground),"Cursor Color":Hr(t.cursor),"Cursor Text Color":Hr(t.background),"Foreground Color":Hr(t.foreground),"Selected Text Color":Hr(t.foreground),"Selection Color":Hr(t.selectionBackground)}}function B0(t){return t?{"Background Image Location":t.image,"Background Image Mode":t.cover?2:3,Blend:t.opacity}:{"Background Image Location":""}}function U0(t,e,n,r,i=!1){let s=(c,u)=>({Name:`ttheme · ${u}`,Guid:A(u),...r?{"Dynamic Profile Parent GUID":r}:{},"Use Separate Colors for Light and Dark Mode":!1,...B0(e.get(c.name)),...W0(c)}),o={Name:"ttheme · default",Guid:A("default"),"Dynamic Profile Parent GUID":r,...B0(void 0)},a=[...n?[s(n,"default")]:i&&r?[o]:[],...t.map((c)=>s(c,c.name))];return`${JSON.stringify({Profiles:a},null,2)}
370
+ `}function jN(t,e){return[` <key>${t}</key>`,"\t<dict>",...Object.entries(e).flatMap(([n,r])=>[` <key>${n}</key>`,typeof r==="string"?` <string>${r}</string>`:` <real>${r}</real>`]),"\t</dict>"].join(`
371
+ `)}var Lf={id:"iterm2",limits:"colors are Display P3, the space iTerm2 reads OSC colors in",emit(t){let e=['<?xml version="1.0" encoding="UTF-8"?>','<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">','<plist version="1.0">',"<dict>",...Object.entries(W0(t)).map(([n,r])=>jN(n,r)),"</dict>","</plist>",""].join(`
372
+ `);return[{path:`iterm2/${A(t.name)}.itermcolors`,content:e}]}};var jf={id:"kitty",emit(t){let e=[...Ir(t),`background ${t.background}`,`foreground ${t.foreground}`,`cursor ${t.cursor}`,`cursor_text_color ${t.background}`,`selection_background ${t.selectionBackground}`,`selection_foreground ${t.foreground}`,...t.ansi.map((n,r)=>`color${r} ${n}`),""].join(`
373
+ `);return[{path:`kitty/themes/${A(t.name)}.conf`,content:e}]}};function K0(t){return["# Generated by ttheme — rewritten on every add, remove and default; do not edit.","import os","",`THEMES = ${JSON.stringify(t.themes)}`,`BACKGROUNDS = ${JSON.stringify(t.backgrounds)}`,"PLACES = {"," 'top-left': 'top-left', 'top-center': 'top', 'top-right': 'top-right',"," 'center-left': 'left', 'center': 'center', 'center-center': 'center', 'center-right': 'right',"," 'bottom-left': 'bottom-left', 'bottom-center': 'bottom', 'bottom-right': 'bottom-right',","}","","shown = {}","faded = {}","worn = {}","","","def locate(path):"," if path.startswith('~/'):"," return os.path.expanduser(path)"," return path if os.path.isabs(path) else os.path.join(BACKGROUNDS, path)","","","def read(path, into):"," try:"," with open(path, encoding='utf-8') as f:"," lines = f.read().splitlines()"," except OSError:"," return False"," for line in lines:"," key, sep, value = line.partition('=')"," key, value = key.strip(), value.strip()"," if not sep or not key or key.startswith('#'):"," continue"," if key == 'config-file':"," read(locate(value.lstrip('?')), into)"," else:"," into[key] = value"," return True","","","def logo(palette):"," c = {}"," if not palette or not read(os.path.join(BACKGROUNDS, palette.replace('@', '--', 1).replace('/', '--', 1) + '.conf'), c):"," return None"," image = c.get('background-image', '')"," try:"," opacity = min(float(c.get('background-image-opacity', '1')), 1.0)"," except ValueError:"," opacity = 1.0"," if not image or opacity <= 0:"," return None"," return locate(image), PLACES.get(c.get('background-image-position', 'center'), 'center'), opacity","","","def fade(path, opacity):"," key = f'{path}#{opacity}'"," if key not in faded:"," from kitty.fast_data_types import load_png_data, png_from_32bit_rgba_data"," with open(path, 'rb') as f:"," rgba, width, height = load_png_data(f.read())"," data = bytearray(rgba)"," data[3::4] = data[3::4].translate(bytes(round(a * opacity) for a in range(256)))"," if len(faded) > 8:"," faded.clear()"," faded[key] = png_from_32bit_rgba_data(bytes(data), width, height)"," return key, faded[key]","","","def show(window):"," want = logo(window.user_vars.get('ttheme_shown') or '')"," if window.id in shown and shown[window.id] == want:"," return"," shown[window.id] = want"," try:"," if want is None:"," window.set_logo('')"," elif want[2] < 1:"," key, png = fade(want[0], want[2])"," window.set_logo(key, want[1], 1, png)"," else:"," window.set_logo(want[0], want[1], 1)"," except Exception:"," shown.pop(window.id, None)","","","def theme(palette):"," path = os.path.join(THEMES, 'ttheme-' + palette.replace('@', '--', 1).replace('/', '--', 1) + '.conf')"," if not palette or not os.path.exists(path):"," return None"," from kitty.colors import parse_colors"," return parse_colors([path])","","","def wear(palette):"," colors = theme(palette) if worn.get('startup') != palette else None"," if colors is None:"," return"," from kitty.colors import patch_colors"," patch_colors(colors[0], colors[1], True, ())"," worn['startup'] = palette","","","def rewear(boss):"," from kitty.colors import patch_colors"," for window in tuple(boss.all_windows):"," colors = theme(window.user_vars.get('ttheme_worn') or '')"," if colors is not None:"," patch_colors(colors[0], colors[1], False, (window,))","","","def on_load(boss, data):"," if getattr(boss, 'ttheme_rewears', False):"," return"," load = boss.load_config_file",""," def reload(*args, **kwargs):"," load(*args, **kwargs)"," worn.pop('startup', None)"," rewear(boss)",""," boss.load_config_file = reload"," boss.ttheme_rewears = True","","","def on_set_user_var(boss, window, data):"," if data['key'] == 'ttheme_shown':"," show(window)"," elif data['key'] == 'ttheme_startup':"," wear(data['value'] or '')","","","def on_focus_change(boss, window, data):"," if data['focused']:"," show(window)","","","def on_close(boss, window, data):"," shown.pop(window.id, None)",""].join(`
374
+ `)}function GN(t){let[e]=t;if(!e)throw Error("manifest needs at least one theme");return{...ps(),palettes:t.map(Te)}}var Gf={id:"meta",emitShared(t){return[{path:"manifest.json",content:`${JSON.stringify(GN(t),null,2)}
375
+ `}]}};var _f={id:"terminal-app",limits:"profiles go into its own settings at init, so the archive carries none"};import{createHash as _N}from"node:crypto";var BN=["black","red","green","yellow","blue","magenta","cyan","white"];function z0(t,e){return[` ${t}:`,...BN.map((n,r)=>` ${n}: "${e[r]}"`)]}function WN(t,e,n){let r=_N("sha1");for(let i of e)r.update(i);return`${A(t)}.${r.digest("hex").slice(0,8)}.${n}`}function D0(t,e,n){let r=2166136261;for(let i of Buffer.from(`${e}
376
+ ${n.toLowerCase()}`,"utf8"))r=Math.imul(r^i,16777619)>>>0;return`${A(t)}.${r.toString(16).padStart(8,"0")}.png`}function zo(t,e){return e?WN(t,[e.image,String(q0(e))],"yaml"):`${A(t)}.yaml`}function q0(t){return Math.max(0,Math.min(100,Math.round(t.opacity*100)))}function Do(t,e){return[`name: "${t.name}"`,`background: "${t.background}"`,`foreground: "${t.foreground}"`,`accent: "${t.cursor}"`,`cursor: "${t.cursor}"`,`details: ${yt(t.background)<0.18?"darker":"lighter"}`,...e?["background_image:",` path: "${e.image}"`,` opacity: ${q0(e)}`]:[],"terminal_colors:",...z0("normal",t.ansi.slice(0,8)),...z0("bright",t.ansi.slice(8,16)),""].join(`
377
+ `)}var Bf={id:"warp",limits:"no selection color, and Warp paints one theme app-wide",emit(t){return[{path:`warp/themes/${zo(t.name)}`,content:Do(t)}]}};var Y0=(t)=>`[${t.map((e)=>`"${e}"`).join(", ")}]`,Wf={id:"wezterm",limits:"OSC repaints per pane, pictures show per window",emit(t){let e=["[metadata]",`name = "${A(t.name)}"`,`origin_url = "${t.ansiSource}"`,"","[colors]",`foreground = "${t.foreground}"`,`background = "${t.background}"`,`cursor_bg = "${t.cursor}"`,`cursor_border = "${t.cursor}"`,`cursor_fg = "${t.background}"`,`selection_bg = "${t.selectionBackground}"`,`selection_fg = "${t.foreground}"`,"",`ansi = ${Y0(t.ansi.slice(0,8))}`,`brights = ${Y0(t.ansi.slice(8,16))}`,""].join(`
378
+ `);return[{path:`wezterm/colors/${A(t.name)}.toml`,content:e}]}},xs=(t)=>JSON.stringify(t);function J0(t){return["-- Generated by ttheme — rewritten on every add, remove and default; do not edit.","local wezterm = require 'wezterm'","",`local MODULE = ${xs(t.path)}`,`local COLORS = ${xs(t.colors)}`,`local BACKGROUNDS = ${xs(t.backgrounds)}`,`local STARTUP = ${t.startup?xs(A(t.startup)):"nil"}`,"local PALETTES = {",...t.palettes.map((e)=>` [${xs(e.name)}] = ${xs(e.background)},`),"}","","local X = { left = 'Left', center = 'Center', right = 'Right' }","local Y = { top = 'Top', center = 'Middle', bottom = 'Bottom' }","local SIZE = { cover = 'Cover', contain = 'Contain', stretch = '100%' }","","local function locate(path)"," if path:sub(1, 2) == '~/' then"," return os.getenv('HOME') .. path:sub(2)"," elseif path:sub(1, 1) == '/' or path:match('^%a:[/\\\\]') then"," return path"," end"," return BACKGROUNDS .. '/' .. path","end","","local function read(path, into)"," local f = io.open(path, 'r')"," if not f then"," return false"," end"," for line in f:lines() do"," local key, value = line:match('^%s*([%w%-]+)%s*=%s*(.-)%s*$')"," if key == 'config-file' then"," read(locate((value:gsub('^%?', ''))), into)"," elseif key then"," into[key] = value"," end"," end"," f:close()"," return true","end","","local function layers(palette)"," local color = PALETTES[palette]"," local c = {}"," if not color or not read(BACKGROUNDS .. '/' .. ((palette:gsub('@', '--', 1)):gsub('/', '--', 1)) .. '.conf', c) then"," return nil, 'none'"," end"," local image = c['background-image'] or ''"," local opacity = tonumber(c['background-image-opacity'] or '1') or 1"," if image == '' or opacity <= 0 then"," return nil, 'none'"," end"," local fit = c['background-image-fit'] or 'contain'"," local position = c['background-image-position'] or 'center'"," local y, x = position:match('^(%a+)-(%a+)$')"," local rep = c['background-image-repeat'] == 'true' and 'Repeat' or 'NoRepeat'"," return {"," { source = { Color = color }, width = '100%', height = '100%' },"," {"," source = { File = locate(image) },"," opacity = opacity,"," width = SIZE[fit],"," height = SIZE[fit],"," horizontal_align = X[x or 'center'],"," vertical_align = Y[y or 'center'],"," repeat_x = rep,"," repeat_y = rep,"," },"," }, table.concat({ color, image, opacity, fit, position, rep }, '|')","end","","local function framed(window, view)"," local color, image, opacity, W, H, w, h, x, y, at ="," view:match('^([^|]*)|([^|]*)|([^|]*)|(%d+)|(%d+)|(%-?%d+)|(%-?%d+)|(%-?%d+)|(%-?%d+)|(%d)$')"," if not image or image == '' or tonumber(W) == 0 or tonumber(H) == 0 then"," return nil, 'none'"," end"," local d = window:get_dimensions()"," local k = math.max(d.pixel_width / W, d.pixel_height / H)"," local n = tonumber(at) - 1"," local ax, ay = n % 3, n // 3"," local px = function(n) return string.format('%.2fpx', n) end"," return {"," { source = { Color = color }, width = '100%', height = '100%' },"," {"," source = { File = image },"," opacity = tonumber(opacity) or 1,"," width = px(w * k),"," height = px(h * k),"," horizontal_align = 'Left',"," vertical_align = 'Top',"," horizontal_offset = px(ax * (d.pixel_width - W * k) / 2 + x * k),"," vertical_offset = px(ay * (d.pixel_height - H * k) / 2 + y * k),"," repeat_x = 'NoRepeat',"," repeat_y = 'NoRepeat',"," },"," }, table.concat({ view, d.pixel_width, d.pixel_height }, '|')","end","","local shown = {}","","local function show(window, pane)"," local vars = pane:get_user_vars()"," local id = window:window_id()"," local background, key"," if vars.ttheme_view and vars.ttheme_view ~= '' then"," background, key = framed(window, vars.ttheme_view)"," elseif vars.ttheme_shown and vars.ttheme_shown ~= '' then"," background, key = layers(vars.ttheme_shown)"," elseif shown[id] == nil then"," return"," end"," if shown[id] == key then"," return"," end"," shown[id] = key"," local overrides = window:get_config_overrides() or {}"," overrides.background = background"," window:set_config_overrides(overrides)","end","","wezterm.on('user-var-changed', function(window, pane, name)"," if name == 'ttheme_shown' or name == 'ttheme_view' then"," show(window, pane)"," end","end)","wezterm.on('update-status', show)","","return function(config)"," local dirs = config.color_scheme_dirs or {}"," table.insert(dirs, COLORS)"," config.color_scheme_dirs = dirs"," if STARTUP then"," config.color_scheme = STARTUP"," end"," wezterm.add_to_config_reload_watch_list(MODULE)","end",""].join(`
379
+ `)}var V0=["black","red","green","yellow","blue","purple","cyan","white"];function Z0(t){return{name:A(t.name),background:t.background,foreground:t.foreground,cursorColor:t.cursor,selectionBackground:t.selectionBackground,...Object.fromEntries(V0.map((e,n)=>[e,t.ansi[n]])),...Object.fromEntries(V0.map((e,n)=>[`bright${e[0]?.toUpperCase()}${e.slice(1)}`,t.ansi[n+8]]))}}function Uf(t,e,n){let r={...e&&n?{profiles:[{updates:e,colorScheme:A(n)}]}:{},schemes:t.map(Z0)};return`${JSON.stringify(r,null,2)}
380
+ `}var Kf={id:"windows-terminal",limits:"a picture belongs to a profile, which a pane cannot change, so none; OSC repaints per pane",emit(t){return[{path:`windows-terminal/schemes/${A(t.name)}.json`,content:`${JSON.stringify(Z0(t),null,2)}
381
+ `}]},emitShared(t){return[{path:"windows-terminal/ttheme.json",content:Uf(t)}]}};function UN(t){let e=t.replace(Ms,"");return/^[ \t]*\[colors[\].]/m.test(e)||/^[ \t]*colors[ \t]*[.=]/m.test(e)}var KN=/^[ \t]*\[general\][ \t]*(?:#.*)?$/m,X0=/^[ \t]*\[/m,t$=/^[ \t]*import[ \t]*=/m,zN=/^[ \t]*general[ \t]*[.=]/m;function DN(t){return t?`[general]
382
+ import = ["${t}"]`:""}function zf(t,e){let n=t.replace(Ms,""),r=KN.exec(n);if(!r){let c=n.search(X0),u=c<0?n:n.slice(0,c);if(zN.test(n)||t$.test(u))return;return Nr(t,DN(e))}let i=r.index+r[0].length,s=n.slice(i),o=s.search(X0);if(t$.test(o<0?s:s.slice(0,o)))return;let a=e?`import = ["${e}"]
378
383
  `:"";return`${n.slice(0,i)}
379
- ${Al}
380
- ${a}${Cl}${o}`}function xa(t){return La(t,"alacritty","alacritty.toml")}function Ab(t){return La(t.configHome,"alacritty","themes")}function Y2(t,e){return e?La(t,"alacritty","themes",`${x(e)}.toml`):void 0}var Yl={id:"alacritty",name:"Alacritty",emitter:Ol,shelf:{from:"themes",dir:Ab},offered:()=>!0,present:(t)=>xb(La(t.configHome,"alacritty")),sync(t,e){e.themes(Yl);let n=xa(t.configHome),r=Jl(it(n),Y2(t.configHome,t.startup));if(r!==void 0)e.wire(n,r)},plan(t){let e=xa(t.configHome);return Jl(it(e),void 0)!==void 0?[`Edit ${It(e,t.home)} — a ttheme block: general.import`]:[]},notes(t){let e=xa(t.configHome),n=it(e);return[...xb(e)&&Jl(n,void 0)===void 0?[`${e} already imports files under [general] — ttheme left it alone; add ${Ab(t)}/<palette>.toml to that import list yourself`]:[],...z2(n)?[`${It(e,t.home)} sets its own colors, which win over an imported palette — remove them to open with ttheme's`]:[]]},next:()=>["Alacritty Reloads its config by itself"],unwire:(t)=>({edits:Ke(xa(t.configHome),Xn),removals:[],touches:[]})};import{existsSync as D2}from"node:fs";import{join as Aa}from"node:path";function V2(t,e,n=""){let r=[];if(!tr(n,"command")){if(r.push(`command = ${t}/launch-tab.zsh`),!tr(n,"shell-integration"))r.push("shell-integration = zsh")}if(e)r.push(`theme = ${x(e)}`);return r.push(`config-file = ?${t}/backgrounds/shown.conf`),r.join(`
381
- `)}function Ta(t){return Aa(t,"ghostty","config")}function Cb(t,e,n){return V2(Aa(t.configHome,"ttheme"),e,n)}var Dl={id:"ghostty",name:"Ghostty",emitter:Nl,shelf:{from:"themes",dir:(t)=>Aa(t.configHome,"ghostty","themes")},offered:()=>!0,present:(t)=>D2(Aa(t.configHome,"ghostty")),sync(t,e){e.themes(Dl);let n=Ta(t.configHome),r=it(n);e.wire(n,Qn(r,Cb(t,t.startup,r)))},plan(t){let e=Ta(t.configHome);return[`Edit ${It(e,t.home)} — a ttheme block: ${Ha(Cb(t,t.startup,it(e)))}`]},notes(t){let e=Ta(t.configHome);return tr(it(e),"command")?[`${It(e,t.home)} sets its own command — ttheme leaves it, so a new tab takes its palette once zsh starts`]:[]},next:()=>["Restart Ghostty New tabs pick up its config"],unwire:(t)=>({edits:Ke(Ta(t.configHome),Xn),removals:[],touches:[]})};import{existsSync as jb}from"node:fs";import{join as Wb}from"node:path";var Vl="ttheme-default";function Go(t){return Wb(t,"Library","Application Support","iTerm2","DynamicProfiles","ttheme.json")}function _b(t){return t.itermBase!==void 0&&t.palettes.length>0}function Gb(t){let e=X(t.configHome),n=new Map;for(let i of t.themes){let o=vo(e,i.name,t.home);if(o)n.set(i.name,o)}let r=new Set(Mt(t.entries).map((i)=>i.name));return ab(t.themes.filter((i)=>r.has(i.name)),n,t.themes.find((i)=>i.name===t.startup),t.state.itermBase,_b(t.state))}function Bb(t){return t.env.TTHEME_ITERM_SUITE??"com.googlecode.iterm2"}function Ub(t){return t.run("defaults",["read",Bb(t),"Default Bookmark Guid"])||void 0}var Z2={key:"itermBase",profile:()=>"ttheme · default",base(t){let e=Ub(t.host);return e&&!e.startsWith("ttheme-")?{...t.state,itermBase:e}:t.state},point(t,e){let n=Ub(t.host),r=t.startup?e||n===Vl?Vl:void 0:n===Vl&&!_b(t.state)?t.state.itermBase:void 0;if(!r||r===n)return;return t.host.run("defaults",["write",Bb(t.host),"Default Bookmark Guid","-string",r]),{restart:Boolean(t.host.run("pgrep",["-x","iTerm2"]))}}},zb={id:"iterm2",name:"iTerm2",emitter:Rl,bakes:!0,offered:(t,e)=>e.platform==="darwin",present:(t)=>jb(Wb(t.home,"Library","Application Support","iTerm2")),sync(t,e){e.write(Go(t.home),Gb(t))},pictures(t,e){e.write(Go(t.home),Gb(t))},plan:(t)=>[`Write ${It(Go(t.home),t.home)} — a "ttheme · <palette>" profile per palette`],notes:()=>[],next(t,e){let n=['iTerm2 profiles A "ttheme · <palette>" per palette in Settings › Profiles'];if(t.startup)n.push(e?.restart?`Restart iTerm2 New tabs open on "ttheme · default", which wears ${t.startup}`:`iTerm2 default "ttheme · default" wears ${t.startup} and follows \`ttheme default\``);return n},unwire:(t)=>({edits:[],removals:jb(Go(t.home))?[Go(t.home)]:[],touches:[]}),defaults:Z2};import{existsSync as Q2}from"node:fs";import{join as ja}from"node:path";function Kb(t,e,n=""){return[...t?[`include themes/${x(t)}.conf`]:[],`watcher ${e}`,...["window_logo_scale 100","window_logo_alpha 1"].filter((r)=>!tr(n,r.split(" ")[0]))].join(`
382
- `)}function Ca(t){return ja(t,"kitty","kitty.conf")}function Zl(t){return ja(t,"ttheme","kitty.py")}function qb(t){return ja(t.configHome,"kitty","themes")}var Ql={id:"kitty",name:"kitty",emitter:Pl,shelf:{from:"themes",dir:qb},offered:()=>!0,present:(t)=>Q2(ja(t.configHome,"kitty")),sync(t,e){e.themes(Ql),e.write(Zl(t.configHome),cb({themes:qb(t),backgrounds:X(t.configHome)}));let n=Ca(t.configHome),r=it(n);e.wire(n,Qn(r,Kb(t.startup,Zl(t.configHome),r)))},plan(t){let e=Ca(t.configHome),n=Kb(t.startup,Zl(t.configHome),it(e));return[`Edit ${It(e,t.home)} — a ttheme block: ${Ha(n)}`]},notes(t){let e=it(Ca(t.configHome));return tr(e,"window_logo_scale")||tr(e,"window_logo_alpha")?["kitty.conf sets its own window_logo_scale or window_logo_alpha — pictures are drawn with them"]:[]},next:()=>["New kitty window Pictures follow it — kitty reloads its colors by itself"],unwire:(t)=>({edits:Ke(Ca(t.configHome),Xn),removals:[],touches:[]})};import{existsSync as Ua}from"node:fs";import{isAbsolute as X2,join as Wo}from"node:path";function Ga(t){return Wo(jo(t),"konsole")}function Uo(t){return Wo(t,"konsolerc")}function Jb(t){return`${x(t)}.profile`}function _o(t){return`ttheme · ${t}`}function Yb(t,e){let n=t.findIndex((i)=>i.trim()===`[${e}]`);if(n<0)return;let r=t.findIndex((i,o)=>o>n&&i.trimStart().startsWith("["));return[n,r<0?t.length:r]}function Xl(t){return new RegExp(String.raw`^\s*${t}\s*=`)}function nr(t,e,n){let r=t.split(`
383
- `),i=Yb(r,e);return(i&&r.slice(i[0]+1,i[1]).find((s)=>Xl(n).test(s)))?.replace(Xl(n),"").trim()}function Db(t,e){let n=t.split(`
384
- `),r=Yb(n,"Desktop Entry"),i=e===void 0?[]:[`DefaultProfile=${e}`];if(!r)return e===void 0?t:`${t===""?"":t.replace(/\n*$/,`
384
+ ${xf}
385
+ ${a}${Nf}${s}`}function Qc(t){return Xc(t,"alacritty","alacritty.toml")}function e$(t){return Xc(t.configHome,"alacritty","themes")}function qN(t,e){return e?Xc(t,"alacritty","themes",`${A(e)}.toml`):void 0}var Df={id:"alacritty",name:"Alacritty",emitter:Ff,shelf:{from:"themes",dir:e$},offered:()=>!0,present:(t)=>Q0(Xc(t.configHome,"alacritty")),sync(t,e){e.themes(Df);let n=Qc(t.configHome),r=zf(it(n),qN(t.configHome,t.startup));if(r!==void 0)e.wire(n,r)},plan(t){let e=Qc(t.configHome);return zf(it(e),void 0)!==void 0?[`Edit ${Rt(e,t.home)} — a ttheme block: general.import`]:[]},notes(t){let e=Qc(t.configHome),n=it(e);return[...Q0(e)&&zf(n,void 0)===void 0?[`${e} already imports files under [general] — ttheme left it alone; add ${e$(t)}/<palette>.toml to that import list yourself`]:[],...UN(n)?[`${Rt(e,t.home)} sets its own colors, which win over an imported palette — remove them to open with ttheme's`]:[]]},next:()=>["Alacritty Reloads its config by itself"],unwire:(t)=>({edits:hn(Qc(t.configHome),Rr),removals:[],touches:[]})};import{existsSync as YN}from"node:fs";import{join as eu}from"node:path";function JN(t,e,n=""){let r=[];if(!Tr(n,"command")){if(r.push(`command = ${t}/launch-tab.zsh`),!Tr(n,"shell-integration"))r.push("shell-integration = zsh")}if(e)r.push(`theme = ${A(e)}`);return r.push(`config-file = ?${t}/backgrounds/shown.conf`),r.join(`
386
+ `)}function tu(t){return eu(t,"ghostty","config")}function n$(t,e,n){return JN(eu(t.configHome,"ttheme"),e,n)}var qf={id:"ghostty",name:"Ghostty",emitter:Cf,shelf:{from:"themes",dir:(t)=>eu(t.configHome,"ghostty","themes")},offered:()=>!0,present:(t)=>YN(eu(t.configHome,"ghostty")),sync(t,e){e.themes(qf);let n=tu(t.configHome),r=it(n);e.wire(n,Nr(r,n$(t,t.startup,r)))},plan(t){let e=tu(t.configHome);return[`Edit ${Rt(e,t.home)} — a ttheme block: ${Zc(n$(t,t.startup,it(e)))}`]},notes(t){let e=tu(t.configHome);return Tr(it(e),"command")?[`${Rt(e,t.home)} sets its own command — ttheme leaves it, so a new tab takes its palette once zsh starts`]:[]},next:()=>["Restart Ghostty New tabs pick up its config"],unwire:(t)=>({edits:hn(tu(t.configHome),Rr),removals:[],touches:[]})};import{existsSync as r$}from"node:fs";import{join as o$}from"node:path";var Yf="ttheme-default";function Ns(t){return o$(t,"Library","Application Support","iTerm2","DynamicProfiles","ttheme.json")}function a$(t){return t.itermBase!==void 0&&t.palettes.length>0}function i$(t){let e=D(t.configHome),n=new Map;for(let i of t.themes){let s=we(e,i.name,t.home);if(s)n.set(i.name,s)}let r=new Set(Et(t.entries).map((i)=>i.name));return U0(t.themes.filter((i)=>r.has(i.name)),n,t.themes.find((i)=>i.name===t.startup),t.state.itermBase,a$(t.state))}function Jf(t){return t.env.TTHEME_ITERM_SUITE??"com.googlecode.iterm2"}function s$(t){return t.run("defaults",["read",Jf(t),"Default Bookmark Guid"])||void 0}function VN(t){return t.run("defaults",["read",Jf(t),"PreventEscapeSequenceFromChangingProfile"])==="0"}var ZN={key:"itermBase",profile:()=>"ttheme · default",base(t){let e=s$(t.host);return e&&!e.startsWith("ttheme-")?{...t.state,itermBase:e}:t.state},point(t,e){let n=s$(t.host),r=t.startup?e||n===Yf?Yf:void 0:n===Yf&&!a$(t.state)?t.state.itermBase:void 0;if(!r||r===n)return;return t.host.run("defaults",["write",Jf(t.host),"Default Bookmark Guid","-string",r]),{restart:Boolean(t.host.run("pgrep",["-x","iTerm2"]))}}},c$={id:"iterm2",name:"iTerm2",emitter:Lf,bakes:!0,offered:(t,e)=>e.platform==="darwin",present:(t)=>r$(o$(t.home,"Library","Application Support","iTerm2")),sync(t,e){e.write(Ns(t.home),i$(t))},pictures(t,e){e.write(Ns(t.home),i$(t))},layer:(t,e)=>({TTHEME_ITERM_SWITCH:VN(e)?"1":"",TTHEME_ITERM_PROFILES:Ns(t.home)}),plan:(t)=>[`Write ${Rt(Ns(t.home),t.home)} — a "ttheme · <palette>" profile per palette`],notes:()=>[],next(t,e){let n=['iTerm2 profiles A "ttheme · <palette>" per palette in Settings › Profiles'];if(t.startup)n.push(e?.restart?`Restart iTerm2 New tabs open on "ttheme · default", which wears ${t.startup}`:`iTerm2 default "ttheme · default" wears ${t.startup} and follows \`ttheme default\``);return n},unwire:(t)=>({edits:[],removals:r$(Ns(t.home))?[Ns(t.home)]:[],touches:[]}),defaults:ZN};import{existsSync as QN}from"node:fs";import{join as ru}from"node:path";function u$(t,e,n=""){return[...t?[`include themes/${A(t)}.conf`]:[],`watcher ${e}`,...["window_logo_scale 100","window_logo_alpha 1"].filter((r)=>!Tr(n,r.split(" ")[0]))].join(`
387
+ `)}function nu(t){return ru(t,"kitty","kitty.conf")}function Vf(t){return ru(t,"ttheme","kitty.py")}function l$(t){return ru(t.configHome,"kitty","themes")}var Zf={id:"kitty",name:"kitty",emitter:jf,shelf:{from:"themes",dir:l$},offered:()=>!0,present:(t)=>QN(ru(t.configHome,"kitty")),sync(t,e){e.themes(Zf),e.write(Vf(t.configHome),K0({themes:l$(t),backgrounds:D(t.configHome)}));let n=nu(t.configHome),r=it(n);e.wire(n,Nr(r,u$(t.startup,Vf(t.configHome),r)))},plan(t){let e=nu(t.configHome),n=u$(t.startup,Vf(t.configHome),it(e));return[`Edit ${Rt(e,t.home)} — a ttheme block: ${Zc(n)}`]},notes(t){let e=it(nu(t.configHome));return Tr(e,"window_logo_scale")||Tr(e,"window_logo_alpha")?["kitty.conf sets its own window_logo_scale or window_logo_alpha — pictures are drawn with them"]:[]},next:()=>["New kitty window Pictures follow it — kitty reloads its colors by itself"],unwire:(t)=>({edits:hn(nu(t.configHome),Rr),removals:[],touches:[]})};import{createHash as XN}from"node:crypto";import{existsSync as iu}from"node:fs";import{basename as f$,isAbsolute as tR,join as wi}from"node:path";function Rs(t){return wi(Ko(t),"konsole")}function qo(t){return wi(t,"konsolerc")}function h$(t){return`${A(t)}.profile`}function Yo(t){return`ttheme · ${t}`}function m$(t,e){let n=t.findIndex((i)=>i.trim()===`[${e}]`);if(n<0)return;let r=t.findIndex((i,s)=>s>n&&i.trimStart().startsWith("["));return[n,r<0?t.length:r]}function Qf(t){return new RegExp(String.raw`^\s*${t}\s*=`)}function Ar(t,e,n){let r=t.split(`
388
+ `),i=m$(r,e);return(i&&r.slice(i[0]+1,i[1]).find((o)=>Qf(n).test(o)))?.replace(Qf(n),"").trim()}function p$(t,e){let n=t.split(`
389
+ `),r=m$(n,"Desktop Entry"),i=e===void 0?[]:[`DefaultProfile=${e}`];if(!r)return e===void 0?t:`${t===""?"":t.replace(/\n*$/,`
385
390
 
386
391
  `)}[Desktop Entry]
387
392
  ${i[0]}
388
- `;let o=n.findIndex((a,c)=>c>r[0]&&c<r[1]&&Xl("DefaultProfile").test(a));if(o>=0)n.splice(o,1,...i);else n.splice(r[0]+1,0,...i);let s=r[1]+i.length-(o>=0?1:0);if(n.slice(r[0]+1,s).every((a)=>a.trim()==="")){let a=r[0]>0&&n[r[0]-1]?.trim()===""?r[0]-1:r[0],c=s===n.length&&n[s-1]===""?s-1:s;n.splice(a,c-a)}return n.join(`
389
- `)}function tI(t){if(t&&Bt(t.toLowerCase()))return t.toLowerCase();let e=t?.split(",").map((n)=>Number(n.trim()));if(!e||e.length<3||e.slice(0,3).some((n)=>!Number.isInteger(n)||n<0||n>255))return;return`#${e.slice(0,3).map((n)=>n.toString(16).padStart(2,"0")).join("")}`}function Vb(t,e){let n=e.endsWith(".profile")?e:`${e}.profile`;if(X2(n))return Ua(n)?n:void 0;let r=n.includes("/")?n:Wo("konsole",n);return[jo(t.home),...(process.env.XDG_DATA_DIRS||"/usr/local/share:/usr/share").split(":")].map((o)=>Wo(o,r)).find((o)=>Ua(o))}function Zb(t,e,n=0){let r=e&&e!=="FALLBACK/"&&n<8?Vb(t,e):void 0;if(!r)return{};let i=it(r),o=Zb(t,nr(i,"General","Parent"),n+1);return{scheme:nr(i,"Appearance","ColorScheme")||o.scheme,use:nr(i,"Cursor Options","UseCustomCursorColor")??o.use,cursor:nr(i,"Cursor Options","CustomCursorColor")??o.cursor}}function eI(t,e){let n=Zb(t,e),r=n.use==="true"?tI(n.cursor):void 0;return[`ColorScheme=${n.scheme??"Breeze"}`,`UseCustomCursorColor=${r?"true":"false"}`,...r?[`customCursorColor=${r}`]:[]].join(";")}function nI(t,e){return["[Appearance]",`ColorScheme=${x(t.name)}`,"","[Cursor Options]",`CustomCursorColor=${nt(t.cursor).join(",")}`,`CustomCursorTextColor=${nt(t.background).join(",")}`,"UseCustomCursorColor=true","","[General]",`Name=${_o(t.name)}`,`Parent=${e}`,""].join(`
390
- `)}function rI(t){let e=new Set(Mt(t.entries).map((n)=>n.name));return t.themes.filter((n)=>e.has(n.name)||n.name===t.startup)}var tf=["--session","--print-reply","--reply-timeout=2000"];function iI(t){return[...(t.run("dbus-send",[...tf,"--dest=org.freedesktop.DBus","/org/freedesktop/DBus","org.freedesktop.DBus.ListNames"])??"").matchAll(/string "(org\.kde\.konsole(?:-\d+)?)"/g)].flatMap(([,n=""])=>{let i=t.run("dbus-send",[...tf,`--dest=${n}`,"/Windows","org.freedesktop.DBus.Introspectable.Introspect"])?.match(/<node name="(\d+)"/)?.[1];return i?[{service:n,window:`/Windows/${i}`}]:[]})}function oI(t,{service:e,window:n},r){let i=(o,...s)=>t.run("dbus-send",[...tf,`--dest=${e}`,n,`org.kde.konsole.Window.${o}`,...s]);return i("setDefaultProfile",`string:${r}`),i("defaultProfile")?.includes(`string "${r}"`)===!0}function sI(t,e){let n=Vb(t,e);return n?nr(it(n),"General","Name"):void 0}function aI(t){return nr(it(Uo(t)),"Desktop Entry","DefaultProfile")}var cI={key:"konsoleBase",profile:_o,base(t){let e=aI(t.configHome);return e&&!e.startsWith(x(""))?{...t.state,konsoleBase:e}:t.state},point(t,e){let n=Uo(t.configHome),r=it(n),i=nr(r,"Desktop Entry","DefaultProfile"),o=i?.startsWith(x(""))===!0,s=t.startup?e||o?Jb(t.startup):void 0:o?t.state.konsoleBase??"":void 0;if(s===void 0||s===(i??"")&&!e)return;if(s!==(i??""))Te(n,Db(r,s||void 0));let a=t.startup?_o(t.startup):s?sI(t,s):void 0,c=iI(t.host),u=a!==void 0&&c.every((l)=>oI(t.host,l,a));return{restart:c.length>0&&!u}}},ef={id:"konsole",name:"Konsole",emitter:Hl,shelf:{from:"",dir:(t)=>Ga(t.home)},offered:(t,e)=>e.platform!=="darwin"&&e.platform!=="win32",present:(t)=>Ua(Ga(t.home))||Ua(Uo(t.configHome)),sync(t,e){e.themes(ef);let n=Ga(t.home),r=t.state.konsoleBase??"FALLBACK/",i=new Set;for(let o of rI(t)){let s=Wo(n,Jb(o.name));i.add(s),e.write(s,nI(o,r))}for(let o of Fa(n))if(o.endsWith(".profile")&&!i.has(o))e.remove(o)},layer:(t)=>({TTHEME_KONSOLE_BASE:eI(t,t.state.konsoleBase)}),plan(t){return[`Write ${It(Ga(t.home),t.home)}/${x("*")}.profile — a "ttheme · <palette>" profile per palette, on top of your own`,...t.startup?[`Edit ${It(Uo(t.configHome),t.home)} — DefaultProfile; \`ttheme off\` puts yours back`]:[]]},notes:()=>[],next(t,e){let n=['Konsole profiles A "ttheme · <palette>" per palette in its profile list'];if(t.startup)n.push(e?.restart?`Restart Konsole New tabs open on "${_o(t.startup)}"`:`Konsole default "${_o(t.startup)}", which follows \`ttheme default\``);return n},unwire(t,e){let n=Uo(t.configHome),r=it(n);return{edits:nr(r,"Desktop Entry","DefaultProfile")?.startsWith(x(""))?[{file:n,content:Db(r,e?.konsoleBase)}]:[],removals:[],touches:[]}},defaults:cI};import{spawn as uI}from"node:child_process";import{existsSync as rr,mkdirSync as lI,readdirSync as nf,readFileSync as rf,realpathSync as fI,rmSync as dI,writeFileSync as hI}from"node:fs";import{dirname as ew,join as ie}from"node:path";function Hr(t){return process.platform==="darwin"?ie(t,".warp","themes"):ie(jo(t),"warp-terminal","themes")}function ir(t,e){return process.platform==="darwin"?ie(t,".warp","settings.toml"):ie(e,"warp-terminal","settings.toml")}var Wa='"dark"';function _a(t){return ie(t,"ttheme","warp.base")}var nw="[appearance.themes]";function rw(t){let e=t.findIndex((r)=>r.trim()===nw);if(e<0)return;let n=t.findIndex((r,i)=>i>e&&r.trimStart().startsWith("["));return[e,n<0?t.length:n]}function or(t){let e=t.split(`
391
- `),n=rw(e);if(!n)return;return e.slice(n[0]+1,n[1]).find((i)=>/^theme\s*=/.test(i))?.replace(/^theme\s*=\s*/,"").trim()}function sf(t,e=`${x(t)}.yaml`){return`{ custom = { name = "${t}", path = "${e}" } }`}function mI(t){return t?.includes(`path = "${x("")}`)===!0?/name = "([^"]+)"/.exec(t)?.[1]:void 0}function Ba(t,e){let n=t.split(`
392
- `),r=rw(n);if(!r)return e===void 0?t:`${t.replace(/\n*$/,`
393
+ `;let s=n.findIndex((a,c)=>c>r[0]&&c<r[1]&&Qf("DefaultProfile").test(a));if(s>=0)n.splice(s,1,...i);else n.splice(r[0]+1,0,...i);let o=r[1]+i.length-(s>=0?1:0);if(n.slice(r[0]+1,o).every((a)=>a.trim()==="")){let a=r[0]>0&&n[r[0]-1]?.trim()===""?r[0]-1:r[0],c=o===n.length&&n[o-1]===""?o-1:o;n.splice(a,c-a)}return n.join(`
394
+ `)}function eR(t){if(t&&ne(t.toLowerCase()))return t.toLowerCase();let e=t?.split(",").map((n)=>Number(n.trim()));if(!e||e.length<3||e.slice(0,3).some((n)=>!Number.isInteger(n)||n<0||n>255))return;return`#${e.slice(0,3).map((n)=>n.toString(16).padStart(2,"0")).join("")}`}function g$(t,e){let n=e.endsWith(".profile")?e:`${e}.profile`;if(tR(n))return iu(n)?n:void 0;let r=n.includes("/")?n:wi("konsole",n);return[Ko(t.home),...(process.env.XDG_DATA_DIRS||"/usr/local/share:/usr/share").split(":")].map((s)=>wi(s,r)).find((s)=>iu(s))}function b$(t,e,n=0){let r=e&&e!=="FALLBACK/"&&n<8?g$(t,e):void 0;if(!r)return{};let i=it(r),s=b$(t,Ar(i,"General","Parent"),n+1);return{scheme:Ar(i,"Appearance","ColorScheme")||s.scheme,use:Ar(i,"Cursor Options","UseCustomCursorColor")??s.use,cursor:Ar(i,"Cursor Options","CustomCursorColor")??s.cursor}}function nR(t,e){let n=b$(t,e),r=n.use==="true"?eR(n.cursor):void 0;return[`ColorScheme=${n.scheme??"Breeze"}`,`UseCustomCursorColor=${r?"true":"false"}`,...r?[`customCursorColor=${r}`]:[]].join(";")}function rR(t,e){return["[Appearance]",`ColorScheme=${A(t.name)}`,"","[Cursor Options]",`CustomCursorColor=${nt(t.cursor).join(",")}`,`CustomCursorTextColor=${nt(t.background).join(",")}`,"UseCustomCursorColor=true","","[General]",`Name=${Yo(t.name)}`,`Parent=${e}`,""].join(`
395
+ `)}var w$=/^ttheme-(.+)\.([0-9a-f]{8})\.colorscheme$/;function iR(t){return XN("sha1").update(t).digest("hex").slice(0,8)}function d$(t,e){let n=Rs(t.home),r=D(t.configHome),i=new Set;for(let s of t.themes){let o=$f(s,we(r,s.name,t.home)),a=wi(n,`${A(s.name)}.${iR(o)}.colorscheme`);i.add(a),e.write(wi(n,`${A(s.name)}.colorscheme`),o),e.write(a,o)}for(let s of Is(n))if(w$.test(f$(s))&&!i.has(s))e.remove(s)}function sR(t){return Is(t).flatMap((e)=>{let[,n,r]=w$.exec(f$(e))??[];return n&&r?[`${n} ${r}`]:[]}).sort().join(" ")}function oR(t){let e=new Set(Et(t.entries).map((n)=>n.name));return t.themes.filter((n)=>e.has(n.name)||n.name===t.startup)}var Xf=["--session","--print-reply","--reply-timeout=2000"];function aR(t){return[...(t.run("dbus-send",[...Xf,"--dest=org.freedesktop.DBus","/org/freedesktop/DBus","org.freedesktop.DBus.ListNames"])??"").matchAll(/string "(org\.kde\.konsole(?:-\d+)?)"/g)].flatMap(([,n=""])=>{let i=t.run("dbus-send",[...Xf,`--dest=${n}`,"/Windows","org.freedesktop.DBus.Introspectable.Introspect"])?.match(/<node name="(\d+)"/)?.[1];return i?[{service:n,window:`/Windows/${i}`}]:[]})}function cR(t,{service:e,window:n},r){let i=(s,...o)=>t.run("dbus-send",[...Xf,`--dest=${e}`,n,`org.kde.konsole.Window.${s}`,...o]);return i("setDefaultProfile",`string:${r}`),i("defaultProfile")?.includes(`string "${r}"`)===!0}function uR(t,e){let n=g$(t,e);return n?Ar(it(n),"General","Name"):void 0}function lR(t){return Ar(it(qo(t)),"Desktop Entry","DefaultProfile")}var dR={key:"konsoleBase",profile:Yo,base(t){let e=lR(t.configHome);return e&&!e.startsWith(A(""))?{...t.state,konsoleBase:e}:t.state},point(t,e){let n=qo(t.configHome),r=it(n),i=Ar(r,"Desktop Entry","DefaultProfile"),s=i?.startsWith(A(""))===!0,o=t.startup?e||s?h$(t.startup):void 0:s?t.state.konsoleBase??"":void 0;if(o===void 0||o===(i??"")&&!e)return;if(o!==(i??""))tn(n,p$(r,o||void 0));let a=t.startup?Yo(t.startup):o?uR(t,o):void 0,c=aR(t.host),u=a!==void 0&&c.every((l)=>cR(t.host,l,a));return{restart:c.length>0&&!u}}},$$={id:"konsole",name:"Konsole",emitter:kf,shelf:{from:"",dir:(t)=>Rs(t.home)},offered:(t,e)=>e.platform!=="darwin"&&e.platform!=="win32",present:(t)=>iu(Rs(t.home))||iu(qo(t.configHome)),sync(t,e){d$(t,e);let n=Rs(t.home),r=t.state.konsoleBase??"FALLBACK/",i=new Set;for(let s of oR(t)){let o=wi(n,h$(s.name));i.add(o),e.write(o,rR(s,r))}for(let s of Is(n))if(s.endsWith(".profile")&&!i.has(s))e.remove(s)},pictures:d$,layer:(t)=>({TTHEME_KONSOLE_BASE:nR(t,t.state.konsoleBase),TTHEME_KONSOLE_SCHEMES:sR(Rs(t.home))}),plan(t){return[`Write ${Rt(Rs(t.home),t.home)}/${A("*")}.profile — a "ttheme · <palette>" profile per palette, on top of your own`,...t.startup?[`Edit ${Rt(qo(t.configHome),t.home)} — DefaultProfile; \`ttheme off\` puts yours back`]:[]]},notes:()=>[],next(t,e){let n=['Konsole profiles A "ttheme · <palette>" per palette in its profile list'];if(t.startup)n.push(e?.restart?`Restart Konsole New tabs open on "${Yo(t.startup)}"`:`Konsole default "${Yo(t.startup)}", which follows \`ttheme default\``);return n},unwire(t,e){let n=qo(t.configHome),r=it(n);return{edits:Ar(r,"Desktop Entry","DefaultProfile")?.startsWith(A(""))?[{file:n,content:p$(r,e?.konsoleBase)}]:[],removals:[],touches:[]}},defaults:dR};import{createHash as fR}from"node:crypto";import{existsSync as v$,readdirSync as hR,readFileSync as mR,rmSync as pR}from"node:fs";import{join as $i}from"node:path";var S$="com.apple.Terminal",Jo="ttheme · ";function De(t){return`${Jo}${t}`}function su(t){return $i(t,"ttheme","terminal-app.js")}function Ts(t){return $i(t,"ttheme","terminal-app")}function gR(t,e){return $i(t.XDG_STATE_HOME??$i(e,".local","state"),"ttheme","terminal-app.window")}var bR=`ObjC.import('AppKit')
396
+
397
+ const OURS = '${Jo}'
398
+ const IMAGE = 'BackgroundImageBookmark'
399
+ const KEYS = ['BackgroundColor', 'TextColor', 'CursorColor', 'SelectionColor', 'ANSIBlackColor', 'ANSIRedColor',
400
+ 'ANSIGreenColor', 'ANSIYellowColor', 'ANSIBlueColor', 'ANSIMagentaColor', 'ANSICyanColor', 'ANSIWhiteColor',
401
+ 'ANSIBrightBlackColor', 'ANSIBrightRedColor', 'ANSIBrightGreenColor', 'ANSIBrightYellowColor', 'ANSIBrightBlueColor',
402
+ 'ANSIBrightMagentaColor', 'ANSIBrightCyanColor', 'ANSIBrightWhiteColor']
403
+
404
+ function color(hex, alpha) {
405
+ const [r, g, b] = [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255)
406
+ const c = $.NSColor.colorWithDeviceRedGreenBlueAlpha(r, g, b, alpha)
407
+ return $.NSKeyedArchiver.archivedDataWithRootObjectRequiringSecureCodingError(c, false, null)
408
+ }
409
+
410
+ function alphaOf(profile) {
411
+ const data = profile.objectForKey('BackgroundColor')
412
+ if (data.isNil()) {
413
+ return 1
414
+ }
415
+ const c = $.NSKeyedUnarchiver.unarchiveObjectWithData(data)
416
+ return c.isNil() ? 1 : c.alphaComponent
417
+ }
418
+
419
+ function ours(ws) {
420
+ return ObjC.deepUnwrap(ws.allKeys).filter((name) => name.startsWith(OURS))
421
+ }
422
+
423
+ function real(path) {
424
+ return $.NSURL.fileURLWithPath(path).URLByResolvingSymlinksInPath.path.js
425
+ }
426
+
427
+ function bookmark(path, was) {
428
+ if (!was.isNil()) {
429
+ const data = $.NSKeyedUnarchiver.unarchiveObjectWithData(was)
430
+ const url = data.isNil() ? data : $.NSURL.URLByResolvingBookmarkDataOptionsRelativeToURLBookmarkDataIsStaleError(data, 768, $(), null, null)
431
+ if (!url.isNil() && url.URLByResolvingSymlinksInPath.path.js === real(path)) {
432
+ return was
433
+ }
434
+ }
435
+ const data = $.NSURL.fileURLWithPath(path).bookmarkDataWithOptionsIncludingResourceValuesForKeysRelativeToURLError(0, $(), $(), $())
436
+ return data.isNil() ? undefined : $.NSKeyedArchiver.archivedDataWithRootObjectRequiringSecureCodingError(data, false, null)
437
+ }
438
+
439
+ function plain(profile) {
440
+ const copy = profile.mutableCopy
441
+ copy.removeObjectForKey(IMAGE)
442
+ return copy
443
+ }
444
+
445
+ function settings() {
446
+ const d = $.NSUserDefaults.alloc.initWithSuiteName('com.apple.Terminal')
447
+ const found = d.dictionaryForKey('Window Settings')
448
+ return { d, ws: found.isNil() ? $.NSMutableDictionary.dictionary : found.mutableCopy }
449
+ }
450
+
451
+ function current(d, ws, name) {
452
+ const profile = ws.objectForKey(name)
453
+ if (profile.isNil()) {
454
+ return false
455
+ }
456
+ const at = profile.objectForKey('TthemeAt')
457
+ const start = d.objectForKey('LastTerminalStartTime')
458
+ return at.isNil() || (!start.isNil() && at.compare(start) < 0)
459
+ }
460
+
461
+ function tabOf(T, tty) {
462
+ for (const w of T.windows()) {
463
+ for (const t of w.tabs()) {
464
+ if (t.tty() === tty) {
465
+ return t
466
+ }
467
+ }
468
+ }
469
+ return null
470
+ }
471
+
472
+ function wear(T, tab, name, fallback) {
473
+ if (tab === null) {
474
+ return 'kept'
475
+ }
476
+ const { d, ws } = settings()
477
+ if (current(d, ws, name) && T.settingsSets.byName(name).exists()) {
478
+ tab.currentSettings = T.settingsSets.byName(name)
479
+ return 'worn'
480
+ }
481
+ if (tab.currentSettings.name().startsWith(OURS) && fallback && T.settingsSets.byName(fallback).exists()) {
482
+ tab.currentSettings = T.settingsSets.byName(fallback)
483
+ return 'base'
484
+ }
485
+ return 'kept'
486
+ }
487
+
488
+ function serve(T) {
489
+ const input = $.NSFileHandle.fileHandleWithStandardInput
490
+ const output = $.NSFileHandle.fileHandleWithStandardOutput
491
+ const tabs = {}
492
+ let buf = ''
493
+ for (;;) {
494
+ const data = input.availableData
495
+ if (+data.length === 0) {
496
+ return ''
497
+ }
498
+ buf += $.NSString.alloc.initWithDataEncoding(data, $.NSUTF8StringEncoding).js
499
+ let at
500
+ while ((at = buf.indexOf('\\n')) >= 0) {
501
+ const [verb, tty, name, fallback] = buf.slice(0, at).split('\\t')
502
+ buf = buf.slice(at + 1)
503
+ let answer = 'kept'
504
+ try {
505
+ if (verb === 'tab') {
506
+ if (!(tty in tabs)) {
507
+ tabs[tty] = tabOf(T, tty)
508
+ }
509
+ answer = wear(T, tabs[tty], name, fallback)
510
+ }
511
+ } catch (e) {
512
+ delete tabs[tty]
513
+ }
514
+ output.writeData($(answer + '\\n').dataUsingEncoding($.NSUTF8StringEncoding))
515
+ }
516
+ }
517
+ }
518
+
519
+ function run(argv) {
520
+ const [verb, ...rest] = argv
521
+ if (verb === 'tab') {
522
+ const T = Application('Terminal')
523
+ return wear(T, tabOf(T, rest[0]), rest[1], rest[2])
524
+ }
525
+ if (verb === 'serve') {
526
+ return serve(Application('Terminal'))
527
+ }
528
+ const { d, ws } = settings()
529
+ if (verb === 'loaded') {
530
+ return current(d, ws, rest[0]) ? '1' : '0'
531
+ }
532
+ let changed = false
533
+ const keep = []
534
+ if (verb === 'write') {
535
+ const named = ws.objectForKey(rest[0])
536
+ const base = named.isNil() ? ws.objectForKey('Basic') : named
537
+ const from = base.isNil() ? $.NSDictionary.dictionary : base
538
+ const alpha = alphaOf(from)
539
+ for (let i = 1; i + 21 < rest.length; i += 22) {
540
+ const name = rest[i]
541
+ const p = from.mutableCopy
542
+ KEYS.forEach((key, k) => p.setObjectForKey(color(rest[i + 1 + k], key === 'BackgroundColor' ? alpha : 1), key))
543
+ p.setObjectForKey(color(rest[i + 2], 1), 'TextBoldColor')
544
+ p.setObjectForKey($(name), 'name')
545
+ p.setObjectForKey($('Window Settings'), 'type')
546
+ p.removeObjectForKey('TthemeAt')
547
+ const was = ws.objectForKey(name)
548
+ if (rest[i + 21] !== '-') {
549
+ const mark = bookmark(rest[i + 21], was.isNil() ? was : was.objectForKey(IMAGE))
550
+ if (mark) {
551
+ p.setObjectForKey(mark, IMAGE)
552
+ }
553
+ }
554
+ keep.push(name)
555
+ const same = was.isNil() ? $.NSMutableDictionary.dictionary : was.mutableCopy
556
+ same.removeObjectForKey('TthemeAt')
557
+ if (!same.isEqualToDictionary(p)) {
558
+ const at = was.isNil() || !plain(same).isEqualToDictionary(plain(p)) ? $.NSDate.date : was.objectForKey('TthemeAt')
559
+ if (!at.isNil()) {
560
+ p.setObjectForKey(at, 'TthemeAt')
561
+ }
562
+ ws.setObjectForKey(p, name)
563
+ changed = true
564
+ }
565
+ }
566
+ }
567
+ if (verb === 'write' || verb === 'drop') {
568
+ for (const name of ours(ws)) {
569
+ if (!keep.includes(name)) {
570
+ ws.removeObjectForKey(name)
571
+ changed = true
572
+ }
573
+ }
574
+ }
575
+ if (changed) {
576
+ d.setObjectForKey(ws, 'Window Settings')
577
+ d.synchronize
578
+ }
579
+ return changed ? 'wrote' : 'same'
580
+ }
581
+ `;function th(t,e,n){return t.run("osascript",["-l","JavaScript",su(e),...n])}function eh(t){return t.run("defaults",["read",S$,"Default Window Settings"])||void 0}function wR(t){return[t.background,t.foreground,t.cursor,t.selectionBackground,...t.ansi]}function E$(t){let e=new Set(Et(t.entries).map((n)=>n.name));return t.themes.filter((n)=>e.has(n.name)||n.name===t.startup)}function nh(t,e){let n=eh(e);return t.terminalBase??(n&&!n.startsWith(Jo)?n:"Basic")}function rh(t,e){let n=/^(\d+)x(\d+)$/.exec(it(gR(t,e)).trim());return n?{width:Number(n[1])*2,height:Number(n[2])*2}:void 0}function ih(t,e,n,r){let i=r?.width??t,s=r?.height??e,o=_t.indexOf(n.position)+1||5,a=ms(t,e,i,s,100,o,n.cover),c=Math.min(1,t/Math.max(1,a.w));return{width:Math.max(1,Math.round(i*c)),height:Math.max(1,Math.round(s*c)),at:{x:Math.round(a.x*c),y:Math.round(a.y*c),w:Math.round(a.w*c),h:Math.round(a.h*c)}}}var M$=/^ttheme-(.+)\.([0-9a-z-]+)\.png$/;function ou(t){let e=new Map;for(let n of v$(t)?hR(t):[]){let[,r]=M$.exec(n)??[];if(r)e.set(r,[...e.get(r)??[],n])}return e}function $R(t){return[...ou(t)].map(([e,n])=>`${e} ${(M$.exec(n[0])??[])[2]}`).sort().join(" ")}function k$(t){let e=Ts(t.configHome),n=ou(e),r=rh(t.host.env,t.home),i=new Map,s=(o)=>{for(let a of o)pR($i(e,a),{force:!0})};for(let o of E$(t)){let a=n.get(Qt(o.name))??[];n.delete(Qt(o.name));let c=we(D(t.configHome),o.name,t.home),u=c&&v$(c.image)?new Uint8Array(mR(c.image)):void 0,l=u&&nn(u);if(!c||!u||!l||c.opacity<=0){s(a);continue}let d=ih(l.width,l.height,c,r),f=fR("sha1").update(u).update(JSON.stringify([o.background.toLowerCase(),c.opacity,d])).digest("hex").slice(0,8),h=`${A(o.name)}.${f}.png`,p=$i(e,h);if(!a.includes(h)){let $;try{$=ir(rr(At(u),o.background,c.opacity,d))}catch{s(a);continue}let[g,...b]=a;if(g)Xr($i(e,g),p,$);else H(p,$);s(b)}else s(a.filter(($)=>$!==h));i.set(o.name,p)}for(let o of n.values())s(o);return i}function y$(t,e){th(t.host,t.configHome,["write",nh(t.state,t.host),...E$(t).flatMap((n)=>[De(n.name),...wR(n),e.get(n.name)??"-"])])}var kR={key:"terminalBase",profile:De,base(t){let e=eh(t.host);return e&&!e.startsWith(Jo)?{...t.state,terminalBase:e}:t.state},point(t,e){let n=eh(t.host),r=n?.startsWith(Jo)===!0;if(t.state.palettes.length===0)th(t.host,t.configHome,["drop"]);let i=t.startup?e||r?De(t.startup):void 0:r?nh(t.state,t.host):void 0;if(i===void 0||i===n&&!e)return;for(let o of["Default Window Settings","Startup Window Settings"])t.host.run("defaults",["write",S$,o,"-string",i]);return{restart:Boolean(t.host.run("pgrep",["-x","Terminal"]))&&th(t.host,t.configHome,["loaded",i])!=="1"}}},O$={id:"terminal-app",name:"Terminal.app",emitter:_f,offered:(t,e)=>e.platform==="darwin",present:()=>!1,sync(t,e){e.write(su(t.configHome),bR),y$(t,k$(t))},pictures(t){y$(t,k$(t))},layer:(t,e)=>({TTHEME_TERMINAL_APP_BASE:nh(t.state,e),TTHEME_TERMINAL_PICTURES:$R(Ts(t.configHome))}),plan:(t)=>[`Add a "${De("<palette>")}" profile per palette to Terminal.app's settings — a copy of your own profile in the palette's colors, with its picture`,...t.startup?[`Make "${De(t.startup)}" Terminal.app's default — \`ttheme off\` puts yours back`]:[]],notes:()=>[],next(t,e){let n=[`Terminal.app A "${De("<palette>")}" profile per palette in Settings › Profiles`];if(t.startup)n.push(e?.restart?`Restart Terminal New windows and tabs open on "${De(t.startup)}"`:`Terminal default "${De(t.startup)}", which follows \`ttheme default\``);return n},unwire:()=>({edits:[],removals:[],touches:[]}),defaults:kR};import{spawn as yR}from"node:child_process";import{existsSync as Fr,mkdirSync as vR,readdirSync as sh,readFileSync as oh,realpathSync as SR,rmSync as ER,writeFileSync as MR}from"node:fs";import{dirname as R$,join as Ee}from"node:path";function ki(t){return process.platform==="darwin"?Ee(t,".warp","themes"):Ee(Ko(t),"warp-terminal","themes")}function Cr(t,e){return process.platform==="darwin"?Ee(t,".warp","settings.toml"):Ee(e,"warp-terminal","settings.toml")}var au='"dark"';function cu(t){return Ee(t,"ttheme","warp.base")}var T$="[appearance.themes]";function P$(t){let e=t.findIndex((r)=>r.trim()===T$);if(e<0)return;let n=t.findIndex((r,i)=>i>e&&r.trimStart().startsWith("["));return[e,n<0?t.length:n]}function Lr(t){let e=t.split(`
582
+ `),n=P$(e);if(!n)return;return e.slice(n[0]+1,n[1]).find((i)=>/^theme\s*=/.test(i))?.replace(/^theme\s*=\s*/,"").trim()}function ch(t,e=`${A(t)}.yaml`){return`{ custom = { name = "${t}", path = "${e}" } }`}function OR(t){return t?.includes(`path = "${A("")}`)===!0?/name = "([^"]+)"/.exec(t)?.[1]:void 0}function uu(t,e){let n=t.split(`
583
+ `),r=P$(n);if(!r)return e===void 0?t:`${t.replace(/\n*$/,`
393
584
  `)}
394
- ${nw}
585
+ ${T$}
395
586
  theme = ${e}
396
- `;let i=n.findIndex((o,s)=>s>r[0]&&s<r[1]&&/^theme\s*=/.test(o));if(i>=0)n.splice(i,1,...e===void 0?[]:[`theme = ${e}`]);else if(e!==void 0)n.splice(r[0]+1,0,`theme = ${e}`);return n.join(`
397
- `)}function of(t){return or(t)?.includes(`path = "${x("")}`)===!0}var gI="setTimeout(() => { const fs = require('node:fs'); const [file, next, seen, theme] = process.argv.slice(-4); if (fs.readFileSync(file, 'utf8') !== seen || !fs.existsSync(theme)) return; const tmp = file + '.ttheme-' + process.pid; fs.writeFileSync(tmp, next); fs.chmodSync(tmp, fs.statSync(file).mode & 0o7777); fs.renameSync(tmp, file) }, 500)";function iw(t,e,n){return{image:ie(t,Mb(e.name,n.image,e.background)),opacity:n.opacity}}function Qb(t){let e=Hr(t.home),n=X(t.configHome),r=new Map,i=new Set;for(let o of t.themes){let s=vo(n,o.name,t.home),a=Ao(o.name,s&&iw(e,o,s));r.set(o.name,a);for(let c of new Set([a,Ao(o.name)]))if(!rr(ie(e,c)))i.add(c)}return{files:r,fresh:i}}function Xb(t,e,n){let r=Hr(t.home),i=X(t.configHome),o=new Set(n.values()),s=or(it(ir(t.home,t.configHome)))??"";for(let u of t.themes){let l=vo(i,u.name,t.home),f=n.get(u.name);if(l&&f){let d=iw(r,u,l);if(!rr(d.image))try{let m=ue(new Uint8Array(rf(l.image)));T(d.image,Ks(zs(m,u.background,1)))}catch{n.set(u.name,Ao(u.name));continue}e.write(ie(r,f),Co(u,d))}}if(!rr(r))return;let a=(u,l)=>u.startsWith(x(""))&&new RegExp(`\\.[0-9a-f]{8}\\.${l}$`).test(u);for(let u of nf(r))if(a(u,"yaml")&&!o.has(u)&&!s.includes(`path = "${u}"`))e.remove(ie(r,u));let c=new Set;for(let u of nf(r)){let l=u.startsWith(x(""))&&u.endsWith(".yaml")?/^ {2}path: "(.+)"$/m.exec(it(ie(r,u)))?.[1]:void 0;if(l)c.add(l)}for(let u of nf(r))if(a(u,"png")&&!c.has(ie(r,u)))e.remove(ie(r,u))}function tw(t,e,n,r=!1){let i=ir(t.home,t.configHome);if(!rr(i))return;let o=_a(t.configHome),s=rf(i,"utf8"),a=r?mI(or(s)):e;if(r&&(a===void 0||!n.files.has(a)))return;let c;if(a){if(!of(s)&&!rr(o))lI(ew(o),{recursive:!0}),hI(o,or(s)??"");c=sf(a,n.files.get(a))}else{if(!of(s))return;c=rr(o)&&rf(o,"utf8")||Wa,dI(o,{force:!0})}let u=Ba(s,c);if(u===s)return;let l=a===void 0?void 0:n.files.get(a)??`${x(a)}.yaml`;if(l!==void 0&&n.fresh.has(l))wu(i),uI(process.execPath,["-e",gI,fI(i),u,s,ie(Hr(t.home),l)],{detached:!0,stdio:"ignore"}).unref();else Te(i,u);return i}var af={id:"warp",name:"Warp",emitter:_l,shelf:{from:"themes",dir:(t)=>Hr(t.home)},bakes:!0,offered:(t,e)=>e.platform!=="win32",present:(t)=>rr(ew(Hr(t.home))),sync(t,e){let n=Qb(t);e.themes(af),Xb(t,e,n.files);let r=tw(t,t.startup,n);if(r)e.note(r)},pictures(t,e){let n=Qb(t);Xb(t,e,n.files),tw(t,void 0,n,!0)},plan(t){let e=ir(t.home,t.configHome);return t.startup&&rr(e)?[`Edit ${It(e,t.home)} — [appearance.themes] theme; \`ttheme off\` puts yours back`]:[]},notes:()=>["Warp wears one theme for the whole app, set through its settings.toml — a tab that takes a palette (`ttheme use`, a pin, preview) switches it, and switching tabs puts on the palette of the tab in front, read from Warp’s session database with sqlite3"],next:()=>[],unwire(t){let e=ir(t.home,t.configHome),n=it(e);return{edits:of(n)?[{file:e,content:Ba(n,it(_a(t.configHome))||Wa)}]:[],removals:[],touches:[]}}};import{existsSync as qa}from"node:fs";import{join as Pi}from"node:path";var ow=/-- ttheme begin\n[\s\S]*?-- ttheme end\n?/,pI=/^return config[ \t]*$/gm;function bI(t){return`dofile(${JSON.stringify(t)})(config)`}var aw=`local wezterm = require 'wezterm'
587
+ `;let i=n.findIndex((s,o)=>o>r[0]&&o<r[1]&&/^theme\s*=/.test(s));if(i>=0)n.splice(i,1,...e===void 0?[]:[`theme = ${e}`]);else if(e!==void 0)n.splice(r[0]+1,0,`theme = ${e}`);return n.join(`
588
+ `)}function ah(t){return Lr(t)?.includes(`path = "${A("")}`)===!0}var IR="setTimeout(() => { const fs = require('node:fs'); const [file, next, seen, theme] = process.argv.slice(-4); if (fs.readFileSync(file, 'utf8') !== seen || !fs.existsSync(theme)) return; const tmp = file + '.ttheme-' + process.pid; fs.writeFileSync(tmp, next); fs.chmodSync(tmp, fs.statSync(file).mode & 0o7777); fs.renameSync(tmp, file) }, 500)";function H$(t,e,n){return{image:Ee(t,D0(e.name,n.image,e.background)),opacity:n.opacity}}function I$(t){let e=ki(t.home),n=D(t.configHome),r=new Map,i=new Set;for(let s of t.themes){let o=we(n,s.name,t.home),a=zo(s.name,o&&H$(e,s,o));r.set(s.name,a);for(let c of new Set([a,zo(s.name)]))if(!Fr(Ee(e,c)))i.add(c)}return{files:r,fresh:i}}function x$(t,e,n){let r=ki(t.home),i=D(t.configHome),s=new Set(n.values()),o=Lr(it(Cr(t.home,t.configHome)))??"";for(let u of t.themes){let l=we(i,u.name,t.home),d=n.get(u.name);if(l&&d){let f=H$(r,u,l);if(!Fr(f.image))try{let h=At(new Uint8Array(oh(l.image)));H(f.image,ir(rr(h,u.background,1)))}catch{n.set(u.name,zo(u.name));continue}e.write(Ee(r,d),Do(u,f))}}if(!Fr(r))return;let a=(u,l)=>u.startsWith(A(""))&&new RegExp(`\\.[0-9a-f]{8}\\.${l}$`).test(u);for(let u of sh(r))if(a(u,"yaml")&&!s.has(u)&&!o.includes(`path = "${u}"`))e.remove(Ee(r,u));let c=new Set;for(let u of sh(r)){let l=u.startsWith(A(""))&&u.endsWith(".yaml")?/^ {2}path: "(.+)"$/m.exec(it(Ee(r,u)))?.[1]:void 0;if(l)c.add(l)}for(let u of sh(r))if(a(u,"png")&&!c.has(Ee(r,u)))e.remove(Ee(r,u))}function xR(t,e){let n=process.env.TTHEME_WARP_WEARS;return t!==void 0&&n!==void 0&&e.files.has(n)?n:t}function N$(t,e,n,r=!1){let i=Cr(t.home,t.configHome);if(!Fr(i))return;let s=cu(t.configHome),o=oh(i,"utf8"),a=r?OR(Lr(o)):e;if(r&&(a===void 0||!n.files.has(a)))return;let c;if(a){if(!ah(o)&&!Fr(s))vR(R$(s),{recursive:!0}),MR(s,Lr(o)??"");c=ch(a,n.files.get(a))}else{if(!ah(o))return;c=Fr(s)&&oh(s,"utf8")||au,ER(s,{force:!0})}let u=uu(o,c);if(u===o)return;let l=a===void 0?void 0:n.files.get(a)??`${A(a)}.yaml`;if(l!==void 0&&n.fresh.has(l))Gl(i),yR(process.execPath,["-e",IR,SR(i),u,o,Ee(ki(t.home),l)],{detached:!0,stdio:"ignore"}).unref();else tn(i,u);return i}var uh={id:"warp",name:"Warp",emitter:Bf,shelf:{from:"themes",dir:(t)=>ki(t.home)},bakes:!0,offered:(t,e)=>e.platform!=="win32",present:(t)=>Fr(R$(ki(t.home))),sync(t,e){let n=I$(t);e.themes(uh),x$(t,e,n.files);let r=N$(t,xR(t.startup,n),n);if(r)e.note(r)},pictures(t,e){let n=I$(t);x$(t,e,n.files),N$(t,void 0,n,!0)},plan(t){let e=Cr(t.home,t.configHome);return t.startup&&Fr(e)?[`Edit ${Rt(e,t.home)} — [appearance.themes] theme; \`ttheme off\` puts yours back`]:[]},notes:()=>["Warp wears one theme for the whole app, set through its settings.toml — a tab that takes a palette (`ttheme use`, a pin, preview) switches it, and switching tabs puts on the palette of the tab in front, read from Warp’s session database with sqlite3"],next:()=>[],unwire(t){let e=Cr(t.home,t.configHome),n=it(e);return{edits:ah(n)?[{file:e,content:uu(n,it(cu(t.configHome))||au)}]:[],removals:[],touches:[]}}};import{existsSync as fu}from"node:fs";import{join as Ps}from"node:path";var A$=/-- ttheme begin\n[\s\S]*?-- ttheme end\n?/,NR=/^return config[ \t]*$/gm;function RR(t){return`dofile(${JSON.stringify(t)})(config)`}var C$=`local wezterm = require 'wezterm'
398
589
  local config = wezterm.config_builder()
399
590
 
400
- `;function wI(t){let e=t.replace(/-- ttheme begin\n[\s\S]*?-- ttheme end\n\n?/,"");return e===`${aw}return config
401
- `?"":e}function cf(t,e){let n=`-- ttheme begin
591
+ `;function TR(t){let e=t.replace(/-- ttheme begin\n[\s\S]*?-- ttheme end\n\n?/,"");return e===`${C$}return config
592
+ `?"":e}function lh(t,e){let n=`-- ttheme begin
402
593
  ${e}
403
594
  -- ttheme end
404
- `;if(ow.test(t))return t.replace(ow,n);if(t==="")return`${aw}${n}
595
+ `;if(A$.test(t))return t.replace(A$,n);if(t==="")return`${C$}${n}
405
596
  return config
406
- `;let r=[...t.matchAll(pI)].at(-1);if(r?.index===void 0)return;return`${t.slice(0,r.index)}${n}
407
- ${t.slice(r.index)}`}function za(t,e){let n=Pi(e,".wezterm.lua");return qa(n)?n:Pi(t,"wezterm","wezterm.lua")}function sw(t){return Pi(t.configHome,"wezterm","colors")}function Ka(t){return Pi(t.configHome,"ttheme","wezterm.lua")}var uf={id:"wezterm",name:"WezTerm",emitter:Bl,shelf:{from:"colors",dir:sw},offered:()=>!0,present:(t)=>qa(Pi(t.configHome,"wezterm"))||qa(Pi(t.home,".wezterm.lua")),sync(t,e){e.themes(uf),e.write(Ka(t),Nb({path:Ka(t),colors:sw(t),backgrounds:X(t.configHome),...t.startup?{startup:t.startup}:{},palettes:t.themes}));let n=za(t.configHome,t.home),r=cf(it(n),bI(Ka(t)));if(r!==void 0)e.wire(n,r)},plan(t){let e=za(t.configHome,t.home);return cf(it(e),"")!==void 0?[`Edit ${It(e,t.home)} — a ttheme block before \`return config\`: color_scheme_dirs, color_scheme, pictures`]:[]},notes(t){let e=za(t.configHome,t.home);return qa(e)&&cf(it(e),"")===void 0?[`${e} has no \`return config\` line — ttheme left it alone; call \`dofile("${Ka(t)}")(config)\` from it yourself`]:[]},next:()=>["WezTerm Reloads its config by itself"],unwire:(t)=>({edits:Ke(za(t.configHome,t.home),wI),removals:[],touches:[]})};import{existsSync as uw,readFileSync as $I,utimesSync as kI}from"node:fs";import{dirname as yI,join as Ja}from"node:path";function lf(t){return Ja(t,"Microsoft","Windows Terminal","Fragments","ttheme","ttheme.json")}function cw(t){return[Ja(t,"Packages","Microsoft.WindowsTerminal_8wekyb3d8bbwe","LocalState","settings.json"),Ja(t,"Packages","Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe","LocalState","settings.json"),Ja(t,"Microsoft","Windows Terminal","settings.json")].filter((e)=>uw(e))}function vI(t){for(let e of t){let n=/"defaultProfile"\s*:\s*"(\{[0-9a-fA-F-]+\})"/.exec($I(e,"utf8"))?.[1];if(n)return n}return}function lw(t){if(t.platform==="win32")return t.env.LOCALAPPDATA;if(!t.env.WSL_DISTRO_NAME)return;let e=t.run("cmd.exe",["/d","/c","echo %LOCALAPPDATA%"]);return e&&t.run("wslpath",["-u",e])||void 0}var fw={id:"windows-terminal",name:"Windows Terminal",emitter:Kl,offered:(t)=>t.wtHome!==void 0,present:(t)=>t.wtHome!==void 0,installs:(t)=>({wtHome:t.wtHome,wtProfile:t.wtProfile}),sync(t,e){let{wtHome:n,wtProfile:r}=t.state;if(!n)return;let i=cw(n);if(e.write(lf(n),zl(t.themes,r??vI(i),t.startup))){let o=new Date;for(let s of i)kI(s,o,o);if(i.length>0)e.repaint()}},plan:(t)=>t.state.wtHome?[`Write ${lf(t.state.wtHome)} — its schemes, and touch settings.json so it reloads`]:[],notes:(t)=>t.state.wtHome?[]:["Windows Terminal: %LOCALAPPDATA% was not found — drop the release fragment into its Fragments folder yourself"],next:()=>["Windows Terminal Reloads its settings by itself"],unwire(t,e){let n=e?.wtHome,r=n?yI(lf(n)):void 0;return{edits:[],removals:r&&uw(r)?[r]:[],touches:n?cw(n):[]}}};var sr={ghostty:Dl,kitty:Ql,alacritty:Yl,wezterm:uf,iterm2:zb,"windows-terminal":fw,warp:af,konsole:ef};function lt(t=re){return t.map((e)=>sr[e])}function Fr(t){return t.startup&&t.palettes.includes(t.startup)?t.startup:t.palettes[0]}function Ne(t){return t.off?void 0:Fr(t)}function Y(){return process.env.XDG_CONFIG_HOME??Ya(qe(),".config")}var Hi=(t)=>typeof t==="string"&&t!==""?t:void 0,EI={author:Hi,startup:Hi,off:(t)=>t?!0:void 0,itermBase:Hi,konsoleBase:Hi,wtHome:Hi,wtProfile:Hi,markets:(t)=>Array.isArray(t)?t.filter((e)=>typeof e==="string"):void 0,updates:(t)=>t&&typeof t==="object"?Object.fromEntries(Object.entries(t).filter((e)=>typeof e[1]==="boolean")):void 0};function B(t){let e=_n(t);if(!ff(e))throw Error(`nothing installed yet at ${e} — run \`ttheme init\` first`);let n=JSON.parse(dw(e,"utf8"));if(!Array.isArray(n?.palettes)||!Array.isArray(n.terminals))throw Error(`${e} has no palettes or terminals`);return{terminals:n.terminals.filter((r)=>re.includes(r)),...Object.fromEntries(Object.entries(EI).flatMap(([r,i])=>{let o=i(n[r]);return o===void 0?[]:[[r,o]]})),palettes:n.palettes}}function Je(t,e){T(_n(t),`${JSON.stringify(e,null,2)}
408
- `)}function hw(t,e){let n=new Map(t.palettes.map((i)=>[i.name,i])),r=e.filter((i)=>!n.has(i));if(r.length>0){let i=[...new Set(r.flatMap((s)=>rt(s)??[]))].filter((s)=>!t.palettes.some((a)=>rt(a.name)===s)),o=i.length>0?`add ${i.join(", ")} first — \`ttheme market search\` finds a market's repository`:Ml(Mt(t.palettes),r);throw Error(`not in any market: ${r.join(", ")} — ${o}`)}return t.palettes.filter((i)=>e.includes(i.name))}function Bo(t,e,n){return{configHome:t,home:n,state:e,startup:Ne(e)}}function mw(t,e,n,r){return{...Bo(t,n,r),entries:e,themes:e.map(Ee)}}function gw(t){let e=[],n={written:e,repainted:!1,write(r,i){if(e.push(r),ff(r)&&dw(r,"utf8")===i)return!1;return T(r,i),!0},wire(r,i){e.push(r),Te(r,i)},note(r){e.push(r)},remove(r){df(r,{force:!0})},themes(r){let i=r.shelf?.dir(t);if(!i)return;for(let o of t.themes)for(let{file:s,content:a}of ql(r,o))n.write(Ya(i,s),a)},repaint(){n.repainted=!0}};return n}function SI(t){return Object.assign({},...lt(t.state.terminals).map((e)=>e.layer?.(t)??{}))}function At(t,e,n,r=qe()){Rt(X(t));let i=hw(Rr(t,e),n.palettes),o=$a(i,dn(t));Ip(t,new Map(o.map((l)=>[l.name,bi(l)]))),hp(t),va(t,i);let s=mw(t,o,n,r),a=gw(s);for(let l of lt(n.terminals))l.sync(s,a);let c=Ya(t,"ttheme","palettes.zsh"),u=Ul(o,s.startup,n.terminals,SI(s));if(a.repainted||it(c)!==u)T(c,u),df(`${c}.zwc`,{force:!0});return a.written.push(c),a.written}function oe(t,e=qe()){let n=B(t),r=lt(n.terminals).filter((s)=>s.pictures);if(r.length===0)return;let i=mw(t,hw(Ie(t),n.palettes),n,e),o=gw(i);for(let s of r)s.pictures?.(i,o)}function xr(t){return!lt(t).some((e)=>e.bakes)}function pw(t,e,n=qe()){let r=Bo(t,e,n);return lt(e.terminals).flatMap((i)=>[...i.shelf?[`Write ${It(i.shelf.dir(r),n)}/${x("*")} — a theme file per palette`]:[],...i.plan(r)])}function bw(t,e,n=qe()){let r=Bo(t,e,n);return lt(e.terminals).flatMap((i)=>i.notes(r))}function ww(t,e,n,r=qe()){let i=Bo(t,e,r);return lt(e.terminals).flatMap((o)=>o.next(i,n.get(o.id)))}function Da(t,e,n,r,i=qe()){let o=[],s=wt(t,e,!1).palettes;for(let a of lt(n)){let c=a.shelf?.dir({configHome:t,home:i});for(let u of c?s.filter((l)=>r.includes(l.name)):[])for(let{file:l}of ql(a,Ee(u))){let f=Ya(c,l);if(ff(f))df(f,{force:!0}),o.push(f)}}return o}function $w(t,e,n,r){return{...Bo(t,e,r),host:n}}function hf(t,e,n,r=qe()){return lt(e.terminals).reduce((i,o)=>o.defaults?.base($w(t,i,n,r))??i,e)}function zo(t,e,n,r,i=qe()){let o=new Map;for(let s of lt(e.terminals)){let a=s.defaults?.point($w(t,e,r,i),n);if(a)o.set(s.id,a)}return o}function Ye(t,e,n,r,i=!1,o=Pr(),s=qe()){let a=i||!Ne(n)&&Ne(r)!==void 0,c=a?hf(t,r,o,s):r;return At(t,e,c,s),Je(t,c),a||Ne(n)!==Ne(r)?zo(t,c,a,o,s):new Map}var MI=300,II=80,kw=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function Va(t){return t>=1e6?`${(t/1e6).toFixed(1)} MB`:`${Math.max(1,Math.round(t/1000))} KB`}function Za(t,e){if(!e)return Va(t);return e>=1e6?`${(t/1e6).toFixed(1)}/${(e/1e6).toFixed(1)} MB`:`${Math.round(t/1000)}/${Math.round(e/1000)} KB`}function ar(t=""){let e=process.stdout;if(!e.isTTY||process.env.TERM==="dumb")return{set(){},say:(u)=>console.log(u),done(){}};let[n,r]=zt()?["",""]:["\x1B[2m","\x1B[22m"],i=0,o=!1,s,a=()=>{e.write(`\r\x1B[2K${n}${Et(`${kw[i%kw.length]} ${t}`,(e.columns||80)-1,!1)}${r}`)},c=setTimeout(()=>{o=!0,a(),s=setInterval(()=>{i++,a()},II),s.unref()},MI);return c.unref(),{set(u){if(t=u,o)a()},say(u){if(o)e.write("\r\x1B[2K");if(console.log(u),o)a()},done(){if(clearTimeout(c),clearInterval(s),o)e.write("\r\x1B[2K"),o=!1}}}import{existsSync as jI,mkdirSync as Rw,readFileSync as Pw,statSync as GI}from"node:fs";import{homedir as UI}from"node:os";import{dirname as WI,join as Ow}from"node:path";import{existsSync as mf,mkdirSync as yw,readFileSync as xi}from"node:fs";import{homedir as FI}from"node:os";import{dirname as vw,join as Lr}from"node:path";import{spawn as OI}from"node:child_process";var NI=30000,RI=3,PI=97,HI=`ObjC.import('Vision')
597
+ `;let r=[...t.matchAll(NR)].at(-1);if(r?.index===void 0)return;return`${t.slice(0,r.index)}${n}
598
+ ${t.slice(r.index)}`}function lu(t,e){let n=Ps(e,".wezterm.lua");return fu(n)?n:Ps(t,"wezterm","wezterm.lua")}function F$(t){return Ps(t.configHome,"wezterm","colors")}function du(t){return Ps(t.configHome,"ttheme","wezterm.lua")}var dh={id:"wezterm",name:"WezTerm",emitter:Wf,shelf:{from:"colors",dir:F$},offered:()=>!0,present:(t)=>fu(Ps(t.configHome,"wezterm"))||fu(Ps(t.home,".wezterm.lua")),sync(t,e){e.themes(dh),e.write(du(t),J0({path:du(t),colors:F$(t),backgrounds:D(t.configHome),...t.startup?{startup:t.startup}:{},palettes:t.themes}));let n=lu(t.configHome,t.home),r=lh(it(n),RR(du(t)));if(r!==void 0)e.wire(n,r)},plan(t){let e=lu(t.configHome,t.home);return lh(it(e),"")!==void 0?[`Edit ${Rt(e,t.home)} — a ttheme block before \`return config\`: color_scheme_dirs, color_scheme, pictures`]:[]},notes(t){let e=lu(t.configHome,t.home);return fu(e)&&lh(it(e),"")===void 0?[`${e} has no \`return config\` line — ttheme left it alone; call \`dofile("${du(t)}")(config)\` from it yourself`]:[]},next:()=>["WezTerm Reloads its config by itself"],unwire:(t)=>({edits:hn(lu(t.configHome,t.home),TR),removals:[],touches:[]})};import{existsSync as j$,readFileSync as PR,utimesSync as HR}from"node:fs";import{dirname as AR,join as hu}from"node:path";function fh(t){return hu(t,"Microsoft","Windows Terminal","Fragments","ttheme","ttheme.json")}function L$(t){return[hu(t,"Packages","Microsoft.WindowsTerminal_8wekyb3d8bbwe","LocalState","settings.json"),hu(t,"Packages","Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe","LocalState","settings.json"),hu(t,"Microsoft","Windows Terminal","settings.json")].filter((e)=>j$(e))}function FR(t){for(let e of t){let n=/"defaultProfile"\s*:\s*"(\{[0-9a-fA-F-]+\})"/.exec(PR(e,"utf8"))?.[1];if(n)return n}return}function G$(t){if(t.platform==="win32")return t.env.LOCALAPPDATA;if(!t.env.WSL_DISTRO_NAME)return;let e=t.run("cmd.exe",["/d","/c","echo %LOCALAPPDATA%"]);return e&&t.run("wslpath",["-u",e])||void 0}var _$={id:"windows-terminal",name:"Windows Terminal",emitter:Kf,offered:(t)=>t.wtHome!==void 0,present:(t)=>t.wtHome!==void 0,installs:(t)=>({wtHome:t.wtHome,wtProfile:t.wtProfile}),sync(t,e){let{wtHome:n,wtProfile:r}=t.state;if(!n)return;let i=L$(n);if(e.write(fh(n),Uf(t.themes,r??FR(i),t.startup))){let s=new Date;for(let o of i)HR(o,s,s);if(i.length>0)e.repaint()}},plan:(t)=>t.state.wtHome?[`Write ${fh(t.state.wtHome)} — its schemes, and touch settings.json so it reloads`]:[],notes:(t)=>t.state.wtHome?[]:["Windows Terminal: %LOCALAPPDATA% was not found — drop the release fragment into its Fragments folder yourself"],next:()=>["Windows Terminal Reloads its settings by itself"],unwire(t,e){let n=e?.wtHome,r=n?AR(fh(n)):void 0;return{edits:[],removals:r&&j$(r)?[r]:[],touches:n?L$(n):[]}}};var mn={ghostty:qf,kitty:Zf,alacritty:Df,wezterm:dh,iterm2:c$,"windows-terminal":_$,warp:uh,konsole:$$,"terminal-app":O$};function pt(t=Dt){return t.map((e)=>mn[e])}function vi(t){return t.startup&&t.palettes.includes(t.startup)?t.startup:t.palettes[0]}function Me(t){return t.off?void 0:vi(t)}function J(){return process.env.XDG_CONFIG_HOME??Hs(qe(),".config")}var yi=(t)=>typeof t==="string"&&t!==""?t:void 0,CR={author:yi,startup:yi,off:(t)=>t?!0:void 0,itermBase:yi,konsoleBase:yi,terminalBase:yi,wtHome:yi,wtProfile:yi,markets:(t)=>Array.isArray(t)?t.filter((e)=>typeof e==="string"):void 0,updates:(t)=>t&&typeof t==="object"?Object.fromEntries(Object.entries(t).filter((e)=>typeof e[1]==="boolean")):void 0};function _(t){let e=br(t);if(!mu(e))throw Error(`nothing installed yet at ${e} — run \`ttheme init\` first`);let n=JSON.parse(B$(e,"utf8"));if(!Array.isArray(n?.palettes)||!Array.isArray(n.terminals))throw Error(`${e} has no palettes or terminals`);return{terminals:n.terminals.filter((r)=>Dt.includes(r)),...Object.fromEntries(Object.entries(CR).flatMap(([r,i])=>{let s=i(n[r]);return s===void 0?[]:[[r,s]]})),palettes:n.palettes}}function He(t,e){H(br(t),`${JSON.stringify(e,null,2)}
599
+ `)}function W$(t,e){let n=new Map(t.palettes.map((i)=>[i.name,i])),r=e.filter((i)=>!n.has(i));if(r.length>0){let i=[...new Set(r.flatMap((o)=>ct(o)??[]))].filter((o)=>!t.palettes.some((a)=>ct(a.name)===o)),s=i.length>0?`add ${i.join(", ")} first — \`ttheme market search\` finds a market's repository`:Qd(Et(t.palettes),r);throw Error(`not in any market: ${r.join(", ")} — ${s}`)}return t.palettes.filter((i)=>e.includes(i.name))}function Vo(t,e,n){return{configHome:t,home:n,state:e,startup:Me(e)}}function U$(t,e,n,r,i){return{...Vo(t,n,r),entries:e,themes:e.map(We),host:i}}function K$(t){let e=[],n={written:e,repainted:!1,write(r,i){if(e.push(r),mu(r)&&B$(r,"utf8")===i)return!1;return H(r,i),!0},wire(r,i){e.push(r),tn(r,i)},note(r){e.push(r)},remove(r){hh(r,{force:!0})},themes(r){let i=r.shelf?.dir(t);if(!i)return;for(let s of t.themes)for(let{file:o,content:a}of Af(r,s))n.write(Hs(i,o),a)},repaint(){n.repainted=!0}};return n}function LR(t,e){return Object.assign({},...pt(t.state.terminals).map((n)=>n.layer?.(t,e)??{}))}function Ct(t,e,n,r=qe(),i=ze()){vt(D(t));let s=W$(fi(t,e),n.palettes),o=wc(s,Pn(t));lw(t,new Map(o.map((u)=>[u.name,mr(u)]))),Qb(t),yc(t,s);let a=U$(t,o,n,r,i),c=K$(a);for(let u of pt(n.terminals))u.sync(a,c);return c.written.push(q$(a,i,c.repainted)),D$(t,o,r),c.written}function z$(t,e=qe()){if(!mu(Hs(t,"ttheme","palettes.zsh")))return;let n=new Set(_(t).palettes);D$(t,ie(t).palettes.filter((r)=>n.has(r.name)),e)}function D$(t,e,n){let r=Hs(t,"ttheme","aliases.zsh"),i=L0(jR(e,n));if(it(r)!==i)H(r,i)}function jR(t,e){let n=t.flatMap((s)=>s.booru?[s.booru]:[]),r=Gd(n,e),i={};for(let s of t){let o=new Set(s.nativeNames??[]),a=(s.booru?r.get(s.booru)??[]:[]).filter((c)=>!o.has(c));if(a.length>0)i[s.name]=a}return i}function q$(t,e,n){let r=Hs(t.configHome,"ttheme","palettes.zsh"),i=Pf(t.entries,t.startup,t.state.terminals,LR(t,e));if(n||it(r)!==i)H(r,i),hh(`${r}.zwc`,{force:!0});return r}function Oe(t,e=qe(),n=ze()){let r=_(t),i=pt(r.terminals).filter((a)=>a.pictures);if(i.length===0)return;let s=U$(t,W$(ie(t),r.palettes),r,e,n),o=K$(s);for(let a of i)a.pictures?.(s,o);q$(s,n,!1)}function Si(t){return!pt(t).some((e)=>e.bakes)}function pu(t,e,n=qe()){let r=Vo(t,e,n);return pt(e.terminals).flatMap((i)=>[...i.shelf?[`Write ${Rt(i.shelf.dir(r),n)}/${A("*")} — a theme file per palette`]:[],...i.plan(r)])}function gu(t,e,n=qe()){let r=Vo(t,e,n);return pt(e.terminals).flatMap((i)=>i.notes(r))}function bu(t,e,n,r=qe()){let i=Vo(t,e,r);return pt(e.terminals).flatMap((s)=>s.next(i,n.get(s.id)))}function wu(t,e,n,r,i=qe()){let s=[],o=Ot(t,e,!1).palettes;for(let a of pt(n)){let c=a.shelf?.dir({configHome:t,home:i});for(let u of c?o.filter((l)=>r.includes(l.name)):[])for(let{file:l}of Af(a,We(u))){let d=Hs(c,l);if(mu(d))hh(d,{force:!0}),s.push(d)}}return s}function Y$(t,e,n,r){return{...Vo(t,e,r),host:n}}function Zo(t,e,n,r=qe()){return pt(e.terminals).reduce((i,s)=>s.defaults?.base(Y$(t,i,n,r))??i,e)}function Ei(t,e,n,r,i=qe()){let s=new Map;for(let o of pt(e.terminals)){let a=o.defaults?.point(Y$(t,e,r,i),n);if(a)s.set(o.id,a)}return s}function pn(t,e,n,r,i=!1,s=ze(),o=qe()){let a=i||!Me(n)&&Me(r)!==void 0,c=a?Zo(t,r,s,o):r;return Ct(t,e,c,o,s),He(t,c),a||Me(n)!==Me(r)?Ei(t,c,a,s,o):new Map}import{performance as J$}from"node:perf_hooks";var GR=16,mh=80,V$="\x1B[?2026h",Z$="\x1B[?2026l";class Mi{shown=[];pointer=new Fo;cursor="";wipe="";immediate;delayed;ticker;last=Number.NEGATIVE_INFINITY;stopped=!1;write;view;beat;constructor(t){this.write=t.write,this.view=t.view,this.beat=t.beat??(()=>{})}request(){if(this.stopped||this.immediate||this.delayed)return;let t=this.last+GR-J$.now();if(t>0)this.delayed=setTimeout(this.paint,t);else this.immediate=setImmediate(this.paint)}soon(){if(this.stopped||this.immediate)return;clearTimeout(this.delayed),this.delayed=void 0,this.immediate=setImmediate(this.paint)}now(){this.cancel(),this.paint()}reset(t=""){this.shown=[],this.cursor="",this.wipe=t}stop(){this.stopped=!0,this.cancel(),clearInterval(this.ticker),this.ticker=void 0}point(t){return this.pointer.point(t)}drop(){this.pointer.drop()}cancel(){clearImmediate(this.immediate),clearTimeout(this.delayed),this.immediate=void 0,this.delayed=void 0}paint=()=>{if(this.immediate=void 0,this.delayed=void 0,this.stopped)return;let{drawn:t,targets:e}=Ec(()=>this.view());if(!t)return;this.last=J$.now();let{lines:n,zones:r}=Mc(t.lines,e);this.pointer.zones=[...t.zones??[],...r];let i=this.wipe;this.wipe="";let s=new Set,o=Math.max(n.length,this.shown.length);for(let l=0;l<o;l++){let d=n[l];if(d!==this.shown[l])i+=`\x1B[${l+1};1H\x1B[0m\x1B[2K${d??""}`,s.add(l)}this.shown=n;let a=t.after?.(s)??"",c=t.cursor??"",u=c!==""&&(i!==""||a!==""||c!==this.cursor);if(this.cursor=c,i||a||u)this.write(`${V$}${i}${a}\x1B[0m${u?c:""}${Z$}`);this.tick(t.ticking===!0)};tick(t){if(t&&!this.ticker)this.ticker=setInterval(()=>{this.beat(),this.request()},mh);else if(!t&&this.ticker)clearInterval(this.ticker),this.ticker=void 0}}class ph{shown=[];write;cols;constructor(t,e){this.write=t,this.cols=e}draw(t){this.put(t,"")}redraw(t){let e=`${this.shown.length>1?`\x1B[${this.shown.length-1}A`:""}${this.shown.length>0?"\r\x1B[J":""}`;this.shown=[],this.put(t,e)}end(t){this.put(t,""),this.write(`
600
+ `),this.shown=[]}put(t,e){let n=t.map((s)=>ot(s,this.cols()-1,!1)),r=0;while(r<n.length&&r<this.shown.length&&n[r]===this.shown[r])r++;if(r===n.length&&n.length===this.shown.length)return;if(r===n.length)r=Math.max(0,n.length-1);let i="";if(this.shown.length===0)i=n.join(`
601
+ `);else if(r>=this.shown.length)i=`
602
+ ${n.slice(r).join(`
603
+ `)}`;else{let s=this.shown.length-1-r;i=`${s>0?`\x1B[${s}A`:""}\r\x1B[J${n.slice(r).join(`
604
+ `)}`}this.shown=n,this.write(`${V$}${e}${i}${Z$}`)}}var _R=300;function $u(t){return t>=1e6?`${(t/1e6).toFixed(1)} MB`:`${Math.max(1,Math.round(t/1000))} KB`}function ku(t,e){if(!e)return $u(t);return e>=1e6?`${(t/1e6).toFixed(1)}/${(e/1e6).toFixed(1)} MB`:`${Math.round(t/1000)}/${Math.round(e/1000)} KB`}var As;async function Q$(t,e){As=t;try{return await e()}finally{As=void 0}}function Bn(t){if(As)As.say(t);else console.log(t)}function jr(t=""){if(As){let u=As;return u.set(t),{set:(l)=>u.set(l),say:(l)=>u.say(l),done:()=>u.set("")}}let e=process.stdout;if(!e.isTTY||process.env.TERM==="dumb")return{set(){},say:(u)=>console.log(u),done(){}};let[n,r]=Ft()?["",""]:[P,de],i=0,s=!1,o,a=()=>{e.write(`\r\x1B[2K${n}${ot(`${Sn[i%Sn.length]} ${t}`,(e.columns||80)-1,!1)}${r}`)},c=setTimeout(()=>{s=!0,a(),o=setInterval(()=>{i++,a()},mh),o.unref()},_R);return c.unref(),{set(u){if(t=u,s)a()},say(u){if(s)e.write("\r\x1B[2K");if(console.log(u),s)a()},done(){if(clearTimeout(c),clearInterval(o),s)e.write("\r\x1B[2K"),s=!1}}}import{existsSync as QR,mkdirSync as ak,readFileSync as ck,statSync as XR}from"node:fs";import{homedir as tT}from"node:os";import{dirname as eT,join as sk}from"node:path";import{existsSync as gh,mkdirSync as X$,readFileSync as Cs}from"node:fs";import{homedir as DR}from"node:os";import{dirname as tk,join as Oi}from"node:path";import{spawn as BR}from"node:child_process";var WR=30000,UR=3,KR=97,zR=`ObjC.import('Vision')
409
605
  ObjC.import('CoreImage')
410
606
  ObjC.import('CoreGraphics')
411
607
  function run(argv) {
@@ -424,11 +620,11 @@ function run(argv) {
424
620
  $.CIImage.imageWithCVPixelBuffer(buffer), $.NSURL.fileURLWithPath(argv[1]), $.kCIFormatRGBA8,
425
621
  $.CGColorSpaceCreateWithName($.kCGColorSpaceSRGB), $({}), error)
426
622
  if (!written) throw new Error('write failed')
427
- }`;function Fi(){return process.platform==="darwin"}function Qa(t){return t>=RI&&t<=PI}function Ko(t,e,n){return new Promise((r,i)=>{let o=OI("osascript",["-l","JavaScript","-e",HI,t,e],{stdio:["ignore","ignore","pipe"],signal:AbortSignal.any([n,AbortSignal.timeout(NI)])}),s="";o.stderr.on("data",(a)=>{s+=a}),o.on("error",i),o.on("close",(a)=>{if(a===0){r();return}i(Error(s.trim().split(`
428
- `).at(-1)||`osascript exited ${a}`))})})}var Ew=90000;function tc(t,e){let n=X(t),r=fe(t,e).flatMap((i)=>{let[,o,s]=/^([a-z.]+)_(\d+)$/.exec(i.key)??[];return o&&s&&q.some((a)=>a.key===o)?[{site:o,id:Number(s),...fl(n,i)}]:[]});return r.length>0?r:void 0}function xI(t,e){let n=new Set(Rt(X(t)).palettes[e.name]?.pictures.map((r)=>r.key));return(e.pictures??[]).filter((r)=>!n.has(Wt(r)))}function Li(t,e){let n=new Set((e??[]).map((r)=>Wt(r)));return{...t,pictures:(t.pictures??[]).filter((r)=>!n.has(Wt(r)))}}async function LI(t,e,n,r,i,o){let s=q.find((w)=>w.key===n.site);if(!s)throw Error(`no site called ${n.site}`);o("Fetching");let a=await fo(s,n.id,i);if(!a)throw Error("the post is gone");if(s!==Ut&&a.md5)try{ea([a],await na([a.md5],i))}catch{}let c=ta(s,a)?Xs(s,a.id,i).then((w)=>{if(w)mo(a,w)},()=>{}):void 0;if(!Zs(s,a,Sr(process.env.TTHEME_FIND_RATING))||Vs(a,ui(process.env.TTHEME_FIND_BLOCK)).length>0)throw Error("outside your find filters — TTHEME_FIND_RATING and TTHEME_FIND_BLOCK");let u=je(a);if(!u)throw Error("too large to use");let l=Lr(Ge(s),"orig",`${n.id}.${u.ext}`),f;if(mf(l))f=new Uint8Array(xi(l));else{o("Downloading");let w=li(s,a,u);f=await ia(w.site,w.url,i,(b,v)=>o("Downloading",Za(b,v))),T(l,f)}let d=Pn(f,Vt),m=!1;if(an(d)===0&&Fi()&&process.env.TTHEME_FIND_REMOVE_BG!=="off"){let w=Lr(Ge(s),"cut",`${n.id}.png`);try{if(!mf(w))o("Cutting out"),yw(vw(w),{recursive:!0}),await Ko(l,w,i);let b=Pn(new Uint8Array(xi(w)),Vt);if(Qa(an(b)))d=b,m=!0}catch{}}await c;let g=cl(e);o("Drawing"),da(t,g,Un(g,e.signatureSlots),d,{site:s.key,id:n.id,ext:u.ext,bytes:f,from:`${s.name} ${n.id} ${s.pageUrl(n.id)}`,artist:a.named.artist,source:ho(a.source),cut:m},{width:0,height:0},er(t),Ra(t));let $=fe(t,e.name).find((w)=>w.key===Wt(n));if($)Eo(X(t),$,n,r,FI())}function TI(t,e){let n=q.find((o)=>o.key===t.site),r=`${n?.name??t.site} ${t.id}`;if(!n||!e)return r;return`${zt()?Zi:`\x1B[${30+n.ansi}m${Zi}\x1B[39m`} ${Ws(r,n.pageUrl(t.id))}`}async function pn(t,e,n){let r=e.flatMap((c)=>xI(t,c).map((u)=>({entry:c,shared:u})));if(r.length===0)return;let i=xr(n),o=process.stdout.isTTY&&mb(process.env),s=new Set,a=ar();for(let[c,{entry:u,shared:l}]of r.entries()){let f=`${u.name} · ${TI(l,o)}`,d=r.length>1?` · ${c+1}/${r.length}`:"",m=(g,$)=>a.set(`${g} ${f}${$?` · ${$}`:""}${d}`);try{await LI(t,u,l,i,AbortSignal.timeout(Ew),m),a.say(` ▣ ${f}`),s.add(u)}catch(g){a.say(` ▢ ${f} — ${g instanceof Error?g.message:String(g)}`)}}a.done();for(let c of s){let u=(c.pictures??[]).find((l)=>fe(t,c.name).some((f)=>f.key===Wt(l)));if(u)ki(t,c.name,Wt(u))}if(s.size>0)oe(t)}function Sw(t,e,n){if(e.width!==t.width||e.height!==t.height)return!1;for(let r=0;r<t.width*t.height;r++)t.data[r*4+3]=e.data[r*4+n]??0;return!0}async function AI(t,e){let[,n,r]=/^(.+)_(\d+)$/.exec(t)??[],i=Lr(An(),n??"local","cut",`${r??t}.png`);if(!mf(i)){if(!Fi())return;yw(vw(i),{recursive:!0}),await Ko(e,i,AbortSignal.timeout(Ew))}return Pn(new Uint8Array(xi(i)),Vt)}function CI(t,e){try{return an(ue(new Uint8Array(xi(Lr(t,`${e.stem}.png`)))))>0}catch{return!1}}function Xa(t,e){return()=>Pn(new Uint8Array(xi(Lr(t,e.original))),Vt)}function Mw(t,e){let n=Xa(t,e);return()=>{let r=n(),i=ue(new Uint8Array(xi(Lr(t,e.cut))));return Sw(r,i,0)?r:null}}async function ec(t,e,n,r,i,o,s,a){let c=X(t),u=Rt(c).palettes[e]?.pictures.find((l)=>l.key===n);if(!u?.original)return null;if(u.cut)return So(t,e,u,Mw(c,u),r,i,o,s,!1,a);if(wi(u)){let l=Xa(c,u)();if(an(l)===0&&CI(c,u)){let f=await AI(n,Lr(c,u.original));if(!f||!Sw(l,f,3))return null;return So(t,e,u,()=>l,r,i,o,s,!0,a)}return So(t,e,u,()=>l,r,i,o,s,!1,a)}return So(t,e,u,Xa(c,u),r,i,o,s,!1,a)}function Iw(t,e,n,r,i,o){let s=X(t),a=Rt(s).palettes[e]?.pictures.find((u)=>u.key===n);if(!a?.original||wi(a))return!1;let c=a.cut?Mw(s,a):Xa(s,a);return Ep(t,e,a,c,r,i,o)}var _I=86400000,BI=3600000,pf=5000;function gf(){return Ow(process.env.XDG_STATE_HOME??Ow(UI(),".local","state"),"ttheme","markets.json")}function bn(){try{let t=JSON.parse(Pw(gf(),"utf8"));return Object.fromEntries(Object.entries(t).filter((e)=>typeof e[1]?.at==="number"&&typeof e[1].error==="string"))}catch{return{}}}function Nw(t,e){let n=bn();if(e===void 0){if(!(t in n))return;delete n[t]}else n[t]={at:Date.now(),error:e};Rw(WI(gf()),{recursive:!0}),T(gf(),`${JSON.stringify(n,null,2)}
429
- `)}function qo(t,e){let n=e===J?Me(t):Xt(e)?Se(t,e):void 0;try{return n?GI(n).mtimeMs:void 0}catch{return}}function zI(t,e,n,r){return t&&(e===void 0||r-e>=_I)&&(n===void 0||r-n>=BI)}function bf(t,e,n=Date.now()){let r=bn();return Ft(e.markets).filter((i)=>zI(Bn(i,e.updates),qo(t,i),r[i]?.at,n))}async function KI(t,e,n){try{return await Po(Pp(t),Sl,e,n)}catch(r){if(r instanceof Ea)throw Error(`${et(t)} has no ${_e} — is the repository public, and has its action run?`);throw r}}async function Jo(t,e,n){if(t===J){let o=await Po(Dp,ze,e,n);return{source:t,id:J,manifest:o,entries:o.palettes}}let r=await KI(t,e,n),i=Si(t,r);return{source:t,id:i,manifest:r,entries:ya(r,i)}}function Ti(t,e){if(e.source===J){ka(t,e.manifest);return}Rw(gl(t),{recursive:!0}),T(Se(t,e.source),`${JSON.stringify(e.manifest,null,2)}
430
- `)}function Ai(t,e){try{if(e===J)return ze(Pw(Me(t),"utf8")).palettes;let n=Jn(t,e);return ya(n,Si(e,n))}catch{return[]}}function qI(t,e){let n=new Map(t.map((i)=>[i.name,JSON.stringify(i)])),r=new Map(e.map((i)=>[i.name,JSON.stringify(i)]));return{added:[...r.keys()].filter((i)=>!n.has(i)),changed:[...r].filter(([i,o])=>n.has(i)&&n.get(i)!==o).map(([i])=>i),gone:[...n.keys()].filter((i)=>!r.has(i))}}async function Yo(t,e,n){let r=Ai(t,e),i;try{i=await Jo(e,n)}catch(o){throw Nw(e,o.message),o}return Ti(t,i),Nw(e,void 0),{source:e,id:i.id,...e===J?{version:i.manifest.version}:{},count:Mt(i.entries).length,change:qI(r,i.entries)}}function _t(t){return`${t} palette${t===1?"":"s"}`}function Do(t,e=Date.now()){let n=Math.floor(Math.max(0,e-t)/60000);if(n<1)return"just now";if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<48?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Hw({added:t,changed:e,gone:n}){return[t.length>0?`${t.length} new`:"",e.length>0?`${e.length} changed`:"",n.length>0?`${n.length} gone`:""].filter(Boolean).join(", ")}function wf(t){let e=Hw(t.change);return`${t.version?`${t.id} ${t.version}`:t.id} — ${_t(t.count)}${e?` (${e})`:""}`}function $f(t){return Hw(t.change)?`Updated ${wf(t)}`:void 0}async function Vo(t,e,n,r){let i=new Set(r.flatMap((u)=>[...u.change.changed,...u.change.gone])),o=e.palettes.filter((u)=>i.has(u));if(o.length===0)return;let s=ct(t,!1);At(t,s,e);let a=new Set(r.flatMap((u)=>u.change.gone));for(let u of o.filter((l)=>a.has(l)))console.log(`${u} left its market — ttheme keeps the copy you have`);let c=new Map(n.map((u)=>[u.name,u.pictures]));await pn(t,wt(t,s,!1).palettes.filter((u)=>o.includes(u.name)&&c.has(u.name)).map((u)=>Li(u,c.get(u.name))),e.terminals)}async function Fw(t=Y()){try{if(!jI(_n(t)))return;let e=B(t),n=bf(t,e);if(n.length===0)return;let r=hn(t),i=ar(`Checking ${n.map(et).join(", ")} for updates`),o=(await Promise.allSettled(n.map((a)=>Yo(t,a,pf)))).flatMap((a)=>a.status==="fulfilled"?[a.value]:[]);i.done();let s=o.flatMap((a)=>$f(a)??[]);if(s.length===0)return;for(let a of s)console.log(a);await Vo(t,e,r,o)}catch{return}}var Cw=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,ZI=["add","remove","search","init"];function Ef(){return process.stdin.isTTY===!0&&process.stdout.isTTY===!0}function QI(){try{let t=JI("gh",["api","user","--jq",".login"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4}).trim().toLowerCase();return Cw.test(t)?t:void 0}catch{return}}async function XI(t,e){if(e.author)return e.author;let n=QI();if(!n){if(!Ef())throw Error("your palettes are named after your GitHub handle — log in with `gh auth login`, or run this in a terminal");let r=await fu({message:"Your GitHub handle — your palettes are named <handle>@<market>/<palette>",validate:(i)=>Cw.test((i??"").toLowerCase())&&(i??"").length<=39?void 0:"that is not a GitHub handle"});if(Lt(r))throw Error("no handle given");n=r.toLowerCase()}return Je(t,{...e,author:n}),console.log(`Your palettes are named ${n}@<market>/<palette>`),n}function Ci(t,e){if(e===J)return J;return ut(e)?te(Be(e)):Si(e,Jn(t,e))}function nc(t,e){try{return Ci(t,e)}catch{return}}function jw(t){return rt(t)??J}function rc(t){return ct(t).palettes.filter((e)=>rt(e.name)===void 0)}function tO(t){let e=Tr(import.meta.dirname,"..","dist","manifest.json");return kf(e)?ze(vf(e,"utf8")).palettes:rc(t)}function Zo(t,e,n){let{updates:r,...i}=t,o=Object.entries(n).filter(([s,a])=>e.includes(s)&&a!==Bn(s,{}));return{...i,markets:e,...o.length>0?{updates:Object.fromEntries(o)}:{}}}function Gw(t,e,n,r){return e.find((i)=>i!==n&&!Ei(i,n)&&nc(t,i)===r)}function yf(t,e,n,r){let i=B(t),o=Ft(i.markets),s=Gw(t,o,e,n);if(s)throw Error(`${n} already names the market at ${et(s)} — \`ttheme market remove ${n}\` first`);let a=r===void 0?{...i.updates}:{...i.updates,[e]:r};Je(t,Zo(i,o.includes(e)?o:[...o,e],a))}async function eO(t){if(!Ef())return!1;let e=await rn({message:`Update ${t} on its own when its author changes it? ttheme checks once a day, when you run it`,initialValue:!1});if(Lt(e))throw Error("no answer given — nothing was added");return e}async function Uw(t){let e=ar(`Fetching ${et(t)}`);try{return await Jo(t)}finally{e.done()}}async function nO(t,e,n){let r=await Uw(n),i=B(t),o=Ft(i.markets),s=Gw(t,o,n,r.id);if(s)throw Error(`${r.id} already names the market at ${et(s)} — \`ttheme market remove ${r.id}\` first`);let{[e]:a,...c}=i.updates??{},u=a===void 0?c:{...c,[n]:a};return Je(t,Zo(i,o.map((l)=>l===e?n:l),u)),Ti(t,r),r}async function Sf(t,e){let n=zn(e),r=Ft(B(t).markets);if(r.includes(n))return console.log(`${et(n)} is already added`),{source:n,id:Ci(t,n),fresh:!1};let i=Xt(n)?r.find((c)=>Xt(c)&&Ei(c,n)):void 0;if(i){let c=await nO(t,i,n);return console.log(`Moved ${c.id} to ${ml(n)??"its default branch"} · ${et(n)} — ${_t(Mt(c.entries).length)}`),{source:n,id:c.id,fresh:!1}}if(ut(n)){let c=te(Be(n));yf(t,n,c);let u=qn(n,c,rc(t)).length;return console.log(`Added ${c} · ${et(n)} — ${_t(u)}, read in place`),{source:n,id:c,fresh:!0}}let o=await Uw(n),s=n===J?void 0:await eO(o.id);yf(t,n,o.id,s),Ti(t,o);let a=_t(Mt(o.entries).length);return console.log(n===J?`Added the ttheme catalog — ${a}`:`Added ${o.id} · ${et(n)} — ${a}${s?", updating on its own":""}`),{source:n,id:o.id,fresh:!0}}async function rO(t){let e=Y(),{source:n,id:r,fresh:i}=await Sf(e,t);if(!i)return;if(ut(n))console.log("\n`ttheme browse` picks them · `ttheme market build` there writes the index others fetch");else if(n===J)console.log("\n`ttheme browse` picks them");else console.log(`
431
- \`ttheme browse\` picks them, or \`ttheme add ${r}/<palette>\``)}function Mf(t,e){if(e===J)Lw(Me(t),{force:!0});else if(Xt(e))Lw(Se(t,e),{force:!0})}function If(t){return`${_t(t.length)} installed from it keep${t.length===1?"s":""} working: ${t.join(", ")} — \`ttheme remove\` drops ${t.length===1?"it":"them"}`}function iO(t){let e=Y(),n=B(e),r=Ft(n.markets),i=r.find((u)=>nc(e,u)===t)??r.find((u)=>u===Ww(t));if(!i)throw Error(`no market named ${t} — \`ttheme market\` lists them`);let o=nc(e,i),s=n.palettes.filter((u)=>jw(u)===o),a=r.filter((u)=>u!==i),c=Zo(n,a,n.updates??{});if(Je(e,c),Mf(e,i),At(e,ct(e),c),console.log(`Removed ${o??t} · ${et(i)}`),s.length>0)console.log(If(s))}function Ww(t){try{return zn(t)}catch{return}}function oO(t,e){try{if(e===J)return Mt(ze(vf(Me(t),"utf8")).palettes).length;if(ut(e))return qn(e,Ci(t,e),rc(t),!1).length;return Jn(t,e).palettes.length}catch{return}}function Of(t,e,n=bn(),r=Date.now()){if(ut(e))return"read in place";let i=n[e],o=qo(t,e);if(i&&(o===void 0||i.at>o))return`update failed ${Do(i.at,r)}`;return o===void 0?"never updated":`updated ${Do(o,r)}`}function sO(){let t=Y(),e=B(t),n=Ft(e.markets);if(n.length===0){console.log("No markets — `ttheme market add official` brings the ttheme catalog back");return}let r=bn(),i=n.map((a)=>{let c=nc(t,a)??"?",u=oO(t,a),l=e.palettes.filter((d)=>jw(d)===c).length,f=ut(a)?[]:[`auto-update ${Bn(a,e.updates)?"on":"off"}`];return{name:c,where:et(a),note:[u===void 0?"Unreadable":_t(u),...l>0?[`${l} installed`]:[],...f,Of(t,a,r)].join(" · ")}}),o=Math.max(...i.map((a)=>a.name.length)),s=Math.max(...i.map((a)=>a.where.length));for(let a of i)console.log(` ${a.name.padEnd(o)} ${a.where.padEnd(s)} ${a.note}`)}function Nf(t){return`${t.owner.login.toLowerCase()}/${t.name}`}async function Rf(t,e){let n=encodeURIComponent(`topic:${yi}${t?` ${t}`:""}`);try{let{items:r}=await Po(`https://api.github.com/search/repositories?q=${n}&sort=stars&per_page=50`,(i)=>JSON.parse(i),void 0,e);return r}catch(r){if(r instanceof Sa)throw Error("GitHub lets a search through about ten times a minute without signing in — try again in a minute");throw r}}async function aO(t){let e=Y(),n=await Rf(t);if(n.length===0){console.log(`No repository carries the ${yi} topic${t?` and matches ${t}`:""} yet`);return}let r=new Set(Ft(B(e).markets).map(Wn)),i=n.map((s)=>{let a=Nf(s);return{arg:a,added:r.has(a),stars:`★${s.stargazers_count}`,about:s.description??""}}),o=Math.max(...i.map((s)=>s.arg.length));for(let s of i)console.log(` ${s.added?"●":"○"} ${s.arg.padEnd(o)} ${s.stars.padStart(5)} ${s.about}`);console.log("\n`ttheme market add <name>` adds one")}var cO=`name: ttheme market
623
+ }`;function Fs(){return process.platform==="darwin"}function yu(t){return t>=UR&&t<=KR}function Qo(t,e,n){return new Promise((r,i)=>{let s=BR("osascript",["-l","JavaScript","-e",zR,t,e],{stdio:["ignore","ignore","pipe"],signal:AbortSignal.any([n,AbortSignal.timeout(WR)])}),o="";s.stderr.on("data",(a)=>{o+=a}),s.on("error",i),s.on("close",(a)=>{if(a===0){r();return}i(Error(o.trim().split(`
624
+ `).at(-1)||`osascript exited ${a}`))})})}var ek=90000;function Su(t,e){let n=D(t),r=re(t,e).flatMap((i)=>{let[,s,o]=/^([a-z.]+)_(\d+)$/.exec(i.key)??[];return s&&o&&Y.some((a)=>a.key===s)?[{site:s,id:Number(o),...Pd(n,i)}]:[]});return r.length>0?r:void 0}function qR(t,e){let n=new Set(vt(D(t)).palettes[e.name]?.pictures.map((r)=>r.key));return(e.pictures??[]).filter((r)=>!n.has(Xt(r)))}function Ls(t,e){let n=new Set((e??[]).map((r)=>Xt(r)));return{...t,pictures:(t.pictures??[]).filter((r)=>!n.has(Xt(r)))}}async function YR(t,e,n,r,i,s){let o=Y.find((g)=>g.key===n.site);if(!o)throw Error(`no site called ${n.site}`);s("Fetching");let a=await is(o,n.id,i);if(!a)throw Error("the post is gone");if(o!==Zt&&a.md5)try{Va([a],await Za([a.md5],i))}catch{}let c=Ja(o,a)?Ya(o,a.id,i).then((g)=>{if(g)wo(a,g)},()=>{}):void 0;if(!Da(o,a,si(process.env.TTHEME_FIND_RATING))||za(a,rs(process.env.TTHEME_FIND_BLOCK)).length>0)throw Error("outside your find filters — TTHEME_FIND_RATING and TTHEME_FIND_BLOCK");let u=sn(a);if(!u)throw Error("too large to use");let l=Oi(Ge(o),"orig",`${n.id}.${u.ext}`),d;if(gh(l))d=new Uint8Array(Cs(l));else{s("Downloading");let g=oi(o,a,u);d=await Qa(g.site,g.url,i,(b,y)=>s("Downloading",ku(b,y))),H(l,d)}let f=nr(d,me),h=!1;if(In(f)===0&&Fs()&&process.env.TTHEME_FIND_REMOVE_BG!=="off"){let g=Oi(Ge(o),"cut",`${n.id}.png`);try{if(!gh(g))s("Cutting out"),X$(tk(g),{recursive:!0}),await Qo(l,g,i);let b=nr(new Uint8Array(Cs(g)),me);if(yu(In(b)))f=b,h=!0}catch{}}await c;let p=Nd(e);s("Drawing"),oc(t,p,an(p,e.signatureSlots),f,{site:o.key,id:n.id,ext:u.ext,bytes:d,from:`${o.name} ${n.id} ${o.pageUrl(n.id)}`,artist:a.named.artist,source:bo(a.source),cut:h},{width:0,height:0},Pr(t),Yc(t));let $=re(t,e.name).find((g)=>g.key===Xt(n));if($)Io(D(t),$,n,r,DR())}function JR(t,e){let n=Y.find((s)=>s.key===t.site),r=`${n?.name??t.site} ${t.id}`;if(!n||!e)return r;return`${Ft()?io:`\x1B[${30+n.ansi}m${io}\x1B[39m`} ${La(r,n.pageUrl(t.id))}`}async function Wn(t,e,n){let r=e.flatMap((c)=>qR(t,c).map((u)=>({entry:c,shared:u})));if(r.length===0)return;let i=Si(n),s=process.stdout.isTTY&&N0(process.env),o=new Set,a=jr();for(let[c,{entry:u,shared:l}]of r.entries()){let d=`${u.name} · ${JR(l,s)}`,f=r.length>1?` · ${c+1}/${r.length}`:"",h=(p,$)=>a.set(`${p} ${d}${$?` · ${$}`:""}${f}`);try{await YR(t,u,l,i,AbortSignal.timeout(ek),h),a.say(` ▣ ${d}`),o.add(u)}catch(p){a.say(` ▢ ${d} — ${p instanceof Error?p.message:String(p)}`)}}a.done();for(let c of o){let u=(c.pictures??[]).find((l)=>re(t,c.name).some((d)=>d.key===Xt(l)));if(u)hs(t,c.name,Xt(u))}if(o.size>0)Oe(t)}function nk(t,e,n){if(e.width!==t.width||e.height!==t.height)return!1;for(let r=0;r<t.width*t.height;r++)t.data[r*4+3]=e.data[r*4+n]??0;return!0}async function VR(t,e){let[,n,r]=/^(.+)_(\d+)$/.exec(t)??[],i=Oi(ur(),n??"local","cut",`${r??t}.png`);if(!gh(i)){if(!Fs())return;X$(tk(i),{recursive:!0}),await Qo(e,i,AbortSignal.timeout(ek))}return nr(new Uint8Array(Cs(i)),me)}function ZR(t,e){try{return In(At(new Uint8Array(Cs(Oi(t,`${e.stem}.png`)))))>0}catch{return!1}}function vu(t,e){return()=>nr(new Uint8Array(Cs(Oi(t,e.original))),me)}function rk(t,e){let n=vu(t,e);return()=>{let r=n(),i=At(new Uint8Array(Cs(Oi(t,e.cut))));return nk(r,i,0)?r:null}}async function Eu(t,e,n,r,i,s,o,a){let c=D(t),u=vt(c).palettes[e]?.pictures.find((l)=>l.key===n);if(!u?.original)return null;if(u.cut)return xo(t,e,u,rk(c,u),r,i,s,o,!1,a);if(ds(u)){let l=vu(c,u)();if(In(l)===0&&ZR(c,u)){let d=await VR(n,Oi(c,u.original));if(!d||!nk(l,d,3))return null;return xo(t,e,u,()=>l,r,i,s,o,!0,a)}return xo(t,e,u,()=>l,r,i,s,o,!1,a)}return xo(t,e,u,vu(c,u),r,i,s,o,!1,a)}function ik(t,e,n,r,i,s){let o=D(t),a=vt(o).palettes[e]?.pictures.find((u)=>u.key===n);if(!a?.original||ds(a))return!1;let c=a.cut?rk(o,a):vu(o,a);return aw(t,e,a,c,r,i,s)}var nT=86400000,rT=3600000,wh=5000;function bh(){return sk(process.env.XDG_STATE_HOME??sk(tT(),".local","state"),"ttheme","markets.json")}function Un(){try{let t=JSON.parse(ck(bh(),"utf8"));return Object.fromEntries(Object.entries(t).filter((e)=>typeof e[1]?.at==="number"&&typeof e[1].error==="string"))}catch{return{}}}function ok(t,e){let n=Un();if(e===void 0){if(!(t in n))return;delete n[t]}else n[t]={at:Date.now(),error:e};ak(eT(bh()),{recursive:!0}),H(bh(),`${JSON.stringify(n,null,2)}
625
+ `)}function Xo(t,e){let n=e===q?ve(t):$e(e)?Ue(t,e):void 0;try{return n?XR(n).mtimeMs:void 0}catch{return}}function iT(t,e,n,r){return t&&(e===void 0||r-e>=nT)&&(n===void 0||r-n>=rT)}function $h(t,e,n=Date.now()){let r=Un();return Bt(e.markets).filter((i)=>iT(wr(i,e.updates),Xo(t,i),r[i]?.at,n))}async function sT(t,e,n){try{return await Ho(Mw(t),Zd,e,n)}catch(r){if(r instanceof vc)throw Error(`${st(t)} has no ${cn} — is the repository public, and has its action run?`);throw r}}async function ta(t,e,n){if(t===q){let s=await Ho(Uw,ln,e,n);return{source:t,id:q,manifest:s,entries:s.palettes}}let r=await sT(t,e,n),i=Ss(t,r);return{source:t,id:i,manifest:r,entries:kc(r,i)}}function js(t,e){if(e.source===q){$c(t,e.manifest);return}ak(Bd(t),{recursive:!0}),H(Ue(t,e.source),`${JSON.stringify(e.manifest,null,2)}
626
+ `)}function Gs(t,e){try{if(e===q)return ln(ck(ve(t),"utf8")).palettes;let n=vr(t,e);return kc(n,Ss(e,n))}catch{return[]}}function oT(t,e){let n=new Map(t.map((i)=>[i.name,JSON.stringify(i)])),r=new Map(e.map((i)=>[i.name,JSON.stringify(i)]));return{added:[...r.keys()].filter((i)=>!n.has(i)),changed:[...r].filter(([i,s])=>n.has(i)&&n.get(i)!==s).map(([i])=>i),gone:[...n.keys()].filter((i)=>!r.has(i))}}async function ea(t,e,n){let r=Gs(t,e),i;try{i=await ta(e,n)}catch(s){throw ok(e,s.message),s}return js(t,i),ok(e,void 0),{source:e,id:i.id,...e===q?{version:i.manifest.version}:{},count:Et(i.entries).length,change:oT(r,i.entries)}}function xt(t){return`${t} palette${t===1?"":"s"}`}function na(t,e=Date.now()){let n=Math.floor(Math.max(0,e-t)/60000);if(n<1)return"just now";if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<48?`${r}h ago`:`${Math.floor(r/24)}d ago`}function uk({added:t,changed:e,gone:n}){return[t.length>0?`${t.length} new`:"",e.length>0?`${e.length} changed`:"",n.length>0?`${n.length} gone`:""].filter(Boolean).join(", ")}function kh(t){let e=uk(t.change);return`${t.version?`${t.id} ${t.version}`:t.id} — ${xt(t.count)}${e?` (${e})`:""}`}function yh(t){return uk(t.change)?`Updated ${kh(t)}`:void 0}async function ra(t,e,n,r){let i=new Set(r.flatMap((u)=>[...u.change.changed,...u.change.gone])),s=e.palettes.filter((u)=>i.has(u));if(s.length===0)return;let o=lt(t,!1);Ct(t,o,e);let a=new Set(r.flatMap((u)=>u.change.gone));for(let u of s.filter((l)=>a.has(l)))Bn(`${u} left its market — ttheme keeps the copy you have`);let c=new Map(n.map((u)=>[u.name,u.pictures]));await Wn(t,Ot(t,o,!1).palettes.filter((u)=>s.includes(u.name)&&c.has(u.name)).map((u)=>Ls(u,c.get(u.name))),e.terminals)}async function lk(t=J()){try{if(!QR(br(t)))return;let e=_(t),n=$h(t,e);if(n.length===0)return;let r=Hn(t),i=jr(`Checking ${n.map(st).join(", ")} for updates`),s=(await Promise.allSettled(n.map((a)=>ea(t,a,wh)))).flatMap((a)=>a.status==="fulfilled"?[a.value]:[]);i.done();let o=s.flatMap((a)=>yh(a)??[]);if(o.length===0)return;for(let a of o)console.log(a);await ra(t,e,r,s)}catch{return}}var pk=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,dT=["add","remove","search","init"];function Mh(){return process.stdin.isTTY===!0&&process.stdout.isTTY===!0}function fT(){try{let t=aT("gh",["api","user","--jq",".login"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4}).trim().toLowerCase();return pk.test(t)?t:void 0}catch{return}}async function hT(t,e){if(e.author)return e.author;let n=fT();if(!n){if(!Mh())throw Error("your palettes are named after your GitHub handle — log in with `gh auth login`, or run this in a terminal");let r=await bf({message:"Your GitHub handle — your palettes are named <handle>@<market>/<palette>",validate:(i)=>pk.test((i??"").toLowerCase())&&(i??"").length<=39?void 0:"that is not a GitHub handle"});if(oe(r))throw Error("no handle given");n=r.toLowerCase()}return He(t,{...e,author:n}),console.log(`Your palettes are named ${n}@<market>/<palette>`),n}function _s(t,e){if(e===q)return q;return ut(e)?ke(un(e)):Ss(e,vr(t,e))}function Mu(t,e){try{return _s(t,e)}catch{return}}function gk(t){return ct(t)??q}function Ou(t){return lt(t).palettes.filter((e)=>ct(e.name)===void 0)}function mT(t){let e=Ii(import.meta.dirname,"..","dist","manifest.json");return vh(e)?ln(Eh(e,"utf8")).palettes:Ou(t)}function ia(t,e,n){let{updates:r,...i}=t,s=Object.entries(n).filter(([o,a])=>e.includes(o)&&a!==wr(o,{}));return{...i,markets:e,...s.length>0?{updates:Object.fromEntries(s)}:{}}}function bk(t,e,n,r){return e.find((i)=>i!==n&&!ys(i,n)&&Mu(t,i)===r)}function Sh(t,e,n,r){let i=_(t),s=Bt(i.markets),o=bk(t,s,e,n);if(o)throw Error(`${n} already names the market at ${st(o)} — \`ttheme market remove ${n}\` first`);let a=r===void 0?{...i.updates}:{...i.updates,[e]:r};He(t,ia(i,s.includes(e)?s:[...s,e],a))}async function pT(t){if(!Mh())return!1;let e=await Ke({message:`Update ${t} on its own when its author changes it? ttheme checks once a day, when you run it`,initialValue:!1});if(oe(e))throw Error("no answer given — nothing was added");return e}async function wk(t){let e=jr(`Fetching ${st(t)}`);try{return await ta(t)}finally{e.done()}}async function gT(t,e,n){let r=await wk(n),i=_(t),s=Bt(i.markets),o=bk(t,s,n,r.id);if(o)throw Error(`${r.id} already names the market at ${st(o)} — \`ttheme market remove ${r.id}\` first`);let{[e]:a,...c}=i.updates??{},u=a===void 0?c:{...c,[n]:a};return He(t,ia(i,s.map((l)=>l===e?n:l),u)),js(t,r),r}async function Oh(t,e){let n=$r(e),r=Bt(_(t).markets);if(r.includes(n))return console.log(`${st(n)} is already added`),{source:n,id:_s(t,n),fresh:!1};let i=$e(n)?r.find((c)=>$e(c)&&ys(c,n)):void 0;if(i){let c=await gT(t,i,n);return console.log(`Moved ${c.id} to ${_d(n)??"its default branch"} · ${st(n)} — ${xt(Et(c.entries).length)}`),{source:n,id:c.id,fresh:!1}}if(ut(n)){let c=ke(un(n));Sh(t,n,c);let u=yr(n,c,Ou(t)).length;return console.log(`Added ${c} · ${st(n)} — ${xt(u)}, read in place`),{source:n,id:c,fresh:!0}}let s=await wk(n),o=n===q?void 0:await pT(s.id);Sh(t,n,s.id,o),js(t,s);let a=xt(Et(s.entries).length);return console.log(n===q?`Added the ttheme catalog — ${a}`:`Added ${s.id} · ${st(n)} — ${a}${o?", updating on its own":""}`),{source:n,id:s.id,fresh:!0}}async function bT(t){let e=J(),{source:n,id:r,fresh:i}=await Oh(e,t);if(!i)return;if(ut(n))console.log("\n`ttheme browse` picks them · `ttheme market build` there writes the index others fetch");else if(n===q)console.log("\n`ttheme browse` picks them");else console.log(`
627
+ \`ttheme browse\` picks them, or \`ttheme add ${r}/<palette>\``)}function Ih(t,e){if(e===q)fk(ve(t),{force:!0});else if($e(e))fk(Ue(t,e),{force:!0})}function xh(t){return`${xt(t.length)} installed from it keep${t.length===1?"s":""} working: ${t.join(", ")} — \`ttheme remove\` drops ${t.length===1?"it":"them"}`}function wT(t){let e=J(),n=_(e),r=Bt(n.markets),i=r.find((u)=>Mu(e,u)===t)??r.find((u)=>u===$k(t));if(!i)throw Error(`no market named ${t} — \`ttheme market\` lists them`);let s=Mu(e,i),o=n.palettes.filter((u)=>gk(u)===s),a=r.filter((u)=>u!==i),c=ia(n,a,n.updates??{});if(He(e,c),Ih(e,i),Ct(e,lt(e),c),console.log(`Removed ${s??t} · ${st(i)}`),o.length>0)console.log(xh(o))}function $k(t){try{return $r(t)}catch{return}}function $T(t,e){try{if(e===q)return Et(ln(Eh(ve(t),"utf8")).palettes).length;if(ut(e))return yr(e,_s(t,e),Ou(t),!1).length;return vr(t,e).palettes.length}catch{return}}function Nh(t,e,n=Un(),r=Date.now()){if(ut(e))return"read in place";let i=n[e],s=Xo(t,e);if(i&&(s===void 0||i.at>s))return`update failed ${na(i.at,r)}`;return s===void 0?"never updated":`updated ${na(s,r)}`}function kT(){let t=J(),e=_(t),n=Bt(e.markets);if(n.length===0){console.log("No markets — `ttheme market add official` brings the ttheme catalog back");return}let r=Un(),i=n.map((a)=>{let c=Mu(t,a)??"?",u=$T(t,a),l=e.palettes.filter((f)=>gk(f)===c).length,d=ut(a)?[]:[`auto-update ${wr(a,e.updates)?"on":"off"}`];return{name:c,where:st(a),note:[u===void 0?"Unreadable":xt(u),...l>0?[`${l} installed`]:[],...d,Nh(t,a,r)].join(" · ")}}),s=Math.max(...i.map((a)=>a.name.length)),o=Math.max(...i.map((a)=>a.where.length));for(let a of i)console.log(` ${a.name.padEnd(s)} ${a.where.padEnd(o)} ${a.note}`)}function Rh(t){return`${t.owner.login.toLowerCase()}/${t.name}`}async function Th(t,e){let n=encodeURIComponent(`topic:${$s}${t?` ${t}`:""}`);try{let{items:r}=await Ho(`https://api.github.com/search/repositories?q=${n}&sort=stars&per_page=50`,(i)=>JSON.parse(i),void 0,e);return r}catch(r){if(r instanceof Sc)throw Error("GitHub lets a search through about ten times a minute without signing in — try again in a minute");throw r}}async function yT(t){let e=J(),n=await Th(t);if(n.length===0){console.log(`No repository carries the ${$s} topic${t?` and matches ${t}`:""} yet`);return}let r=new Set(Bt(_(e).markets).map(gr)),i=n.map((o)=>{let a=Rh(o);return{arg:a,added:r.has(a),stars:`★${o.stargazers_count}`,about:o.description??""}}),s=Math.max(...i.map((o)=>o.arg.length));for(let o of i)console.log(` ${o.added?"●":"○"} ${o.arg.padEnd(s)} ${o.stars.padStart(5)} ${o.about}`);console.log("\n`ttheme market add <name>` adds one")}var vT=`name: ttheme market
432
628
 
433
629
  on:
434
630
  push:
@@ -443,35 +639,36 @@ jobs:
443
639
  runs-on: ubuntu-latest
444
640
  steps:
445
641
  - uses: kecan0406/ttheme/market@v1
446
- `;function _w({name:t}){return`ttheme-${t}`}function uO(t,e){xw(ga(t),{recursive:!0}),xw(Tr(t,".github","workflows"),{recursive:!0}),Bw(t,e,[]),T(Tr(t,".github","workflows","ttheme.yml"),cO),T(Tr(t,"README.md"),`# ${te(e)}
642
+ `;function kk({name:t}){return`ttheme-${t}`}function ST(t,e){dk(mc(t),{recursive:!0}),dk(Ii(t,".github","workflows"),{recursive:!0}),yk(t,e,[]),H(Ii(t,".github","workflows","ttheme.yml"),vT),H(Ii(t,"README.md"),`# ${ke(e)}
447
643
 
448
644
  A [ttheme](https://github.com/kecan0406/ttheme) market:
449
645
 
450
646
  \`\`\`sh
451
- ttheme market add ${e.owner}/${_w(e)}
647
+ ttheme market add ${e.owner}/${kk(e)}
452
648
  ttheme browse
453
649
  \`\`\`
454
- `)}function Bw(t,{owner:e,name:n},r){let{version:i,gate:o,placement:s}=Mo(),a={version:i,gate:o,placement:s,owner:e,name:n,palettes:r};T(Tr(t,_e),`${JSON.stringify(a,null,2)}
455
- `)}function zw(t){return ke(`x@${t}/x`)?"takes lowercase letters, digits and single hyphens":void 0}async function Kw(){if(!Ef())throw Error("name the market: ttheme market init <name>, or --in <name> on new");let t=await fu({message:"Your market's name — its palettes are <you>@<name>/<palette>",validate:(e)=>zw((e??"").toLowerCase())});if(Lt(t))throw Error("no market name given");return t.toLowerCase()}async function qw(t,e){let n=Nr(t);if(e){let s=n.find((a)=>a.name===e||a.id===e||a.dir===Ww(e));if(!s)throw Error(`${e} is not one of your local markets — \`ttheme market init ${e}\` makes it one`);return s}let[r,...i]=n;if(r&&i.length===0)return r;if(r)throw Error(`you have ${n.length} local markets — --in names one: ${n.map((s)=>s.name).join(", ")}`);let o=await Kw();return Jw(t,pl(t,o),o)}async function Jw(t,e,n){let r=!kf(Tr(e,_e)),i;if(r){let s=zw(n);if(s)throw Error(`the market name ${n} ${s}`);if(kf(e)&&YI(e).length>0)throw Error(`${e} is not empty — pick a new folder for the market`);i={owner:await XI(t,B(t)),name:n},uO(e,i)}else i=Be(e);let o=te(i);return yf(t,e,o),console.log(`${r?"Made":"Added"} your market ${o} · ${et(e)}`),{dir:e,...i,id:o}}function Tw(t){return t.startsWith(".")||t.startsWith("/")||t.startsWith("~")}async function lO(t){let e=Y(),n=t&&!Tw(t)?t.toLowerCase():t?DI(zn(t)).toLowerCase():await Kw(),r=t&&Tw(t)?zn(t):pl(e,n),i=await Jw(e,r,n),o=`${i.owner}/${_w(i)}`;console.log(`
650
+ `)}function yk(t,{owner:e,name:n},r){let{version:i,gate:s,placement:o}=ps(),a={version:i,gate:s,placement:o,owner:e,name:n,palettes:r};H(Ii(t,cn),`${JSON.stringify(a,null,2)}
651
+ `)}function vk(t){return Be(`x@${t}/x`)?"takes lowercase letters, digits and single hyphens":void 0}async function Sk(){if(!Mh())throw Error("name the market: ttheme market init <name>, or --in <name> on new");let t=await bf({message:"Your market's name — its palettes are <you>@<name>/<palette>",validate:(e)=>vk((e??"").toLowerCase())});if(oe(t))throw Error("no market name given");return t.toLowerCase()}async function Ek(t,e){let n=di(t);if(e){let o=n.find((a)=>a.name===e||a.id===e||a.dir===$k(e));if(!o)throw Error(`${e} is not one of your local markets — \`ttheme market init ${e}\` makes it one`);return o}let[r,...i]=n;if(r&&i.length===0)return r;if(r)throw Error(`you have ${n.length} local markets — --in names one: ${n.map((o)=>o.name).join(", ")}`);let s=await Sk();return Mk(t,Wd(t,s),s)}async function Mk(t,e,n){let r=!vh(Ii(e,cn)),i;if(r){let o=vk(n);if(o)throw Error(`the market name ${n} ${o}`);if(vh(e)&&cT(e).length>0)throw Error(`${e} is not empty — pick a new folder for the market`);i={owner:await hT(t,_(t)),name:n},ST(e,i)}else i=un(e);let s=ke(i);return Sh(t,e,s),console.log(`${r?"Made":"Added"} your market ${s} · ${st(e)}`),{dir:e,...i,id:s}}function hk(t){return t.startsWith(".")||t.startsWith("/")||t.startsWith("~")}async function ET(t){let e=J(),n=t&&!hk(t)?t.toLowerCase():t?uT($r(t)).toLowerCase():await Sk(),r=t&&hk(t)?$r(t):Wd(e,n),i=await Mk(e,r,n),s=`${i.owner}/${kk(i)}`;console.log(`
456
652
  \`ttheme new <palette> --from <palette>\` puts palettes in it, and a folder under palettes/ shelves them in a catalog — others see them once it is on GitHub:
457
653
 
458
- cd ${et(r)}
654
+ cd ${st(r)}
459
655
  git init -b main && git add -A && git commit -m "${i.id}"
460
- gh repo create ${o} --public --source . --push
461
- gh repo edit ${o} --add-topic ${yi}
656
+ gh repo create ${s} --public --source . --push
657
+ gh repo edit ${s} --add-topic ${$s}
462
658
 
463
- Its action rebuilds ${_e} on every push; then \`ttheme market add ${o}\` works anywhere`)}function fO(t){let e=t?zn(t):process.cwd(),n=Be(e),r=te(n),i=tO(Y()),o=new Map,s=[],a=[];for(let c of Kn(e))try{let u=Oo(c,o);if(u)throw Error(u);o.set(c.slug,c);let l=ee(`${r}/${c.slug}`,vf(c.path,"utf8"),i),f=ve({...l,name:c.slug});s.push(c.catalog?{...f,catalog:c.catalog}:f)}catch(u){a.push(` ${VI(e,c.path)}: ${u.message}`)}if(a.length>0)return console.error(`${a.length} palettes cannot be read — the index was left as it was:
659
+ Its action rebuilds ${cn} on every push; then \`ttheme market add ${s}\` works anywhere`)}function MT(t){let e=t?$r(t):process.cwd(),n=un(e),r=ke(n),i=mT(J()),s=new Map,o=[],a=[];for(let c of kr(e))try{let u=To(c,s);if(u)throw Error(u);s.set(c.slug,c);let l=ye(`${r}/${c.slug}`,Eh(c.path,"utf8"),i),d=Te({...l,name:c.slug});o.push(c.catalog?{...d,catalog:c.catalog}:d)}catch(u){a.push(` ${lT(e,c.path)}: ${u.message}`)}if(a.length>0)return console.error(`${a.length} palettes cannot be read — the index was left as it was:
464
660
  ${a.join(`
465
- `)}`),1;for(let c of s){let l=No(c).filter((d)=>d.startsWith(" ✗")),f=c.catalog?`${c.catalog}/${c.name}`:c.name;console.log(` ${f}${l.length>0?`
661
+ `)}`),1;for(let c of o){let l=Po(c).filter((f)=>f.startsWith(" ✗")),d=c.catalog?`${c.catalog}/${c.name}`:c.name;console.log(` ${d}${l.length>0?`
466
662
  ${l.join(`
467
- `)}`:" passes the gate"}`)}return Bw(e,n,s),console.log(`
468
- ${r} · ${_t(s.length)} → ${Tr(e,_e)}`),0}async function Yw(t,e){switch(t){case void 0:sO();return;case"add":await rO(Aw(t,e));return;case"remove":iO(Aw(t,e));return;case"search":await aO(e);return;case"init":await lO(e);return;case"build":return fO(e);default:throw Error(`unknown market action ${t} — ${ZI.join(", ")}, or none to list them`)}}function Aw(t,e){if(!e)throw Error(t==="add"?"market add takes a repository or a folder: ttheme market add alice/ttheme-dust":"market remove takes a market name — `ttheme market` lists them");return e}function Dw(t,e){let n=Ci(t,e);return`${n} — ${_t(qn(e,n,rc(t),!1).length)}, read in place`}function Xo(t,e){return`${t}/${e}`}function Vw(t){return rt(t.name)?mi(t.name):t.name}function Qo(t){return t.catalog!==void 0&&Qw(t.group)?Xo(t.group,t.catalog):void 0}function Pf(t){if(t?.kind==="palette")return`palette ${t.entry.name}`;if(t?.kind==="group")return`group ${t.name}`;if(t?.kind==="catalog")return`catalog ${Xo(t.group,t.name)}`;return t?.kind??""}function ic(t,e){let n=e.toLowerCase();return[t.name,t.group,t.native??"",t.catalog??""].some((r)=>r.toLowerCase().includes(n))}function Zw(t,e,n){let r=n.trim(),i=[],o=new Set,s=(a)=>({kind:"palette",entry:a});for(let a of t){if(a.default||o.has(a.group))continue;o.add(a.group);let c=t.filter((d)=>!d.default&&d.group===a.group),u=r?c.filter((d)=>ic(d,r)):c;if(r&&u.length===0)continue;let l=r.length>0||e.has(a.group);if(i.push({kind:"group",name:a.group,native:a.native,lead:c.find((d)=>d.lead)??a,expanded:l,count:u.length}),!l)continue;let f=u.filter((d)=>Qo(d)!==void 0);for(let d of new Set(f.map((m)=>m.catalog))){let m=f.filter(($)=>$.catalog===d),g=r.length>0||e.has(Xo(a.group,d));if(i.push({kind:"catalog",group:a.group,name:d,lead:m[0],expanded:g,count:m.length}),g)i.push(...m.map(s))}i.push(...u.filter((d)=>Qo(d)===void 0).map(s))}return i}function dO(t,e){let n=e.trim(),r=new Set(t.filter((i)=>!i.default&&(n===""||ic(i,n))).map((i)=>i.group));return Zw(t,new Set,"").filter((i)=>i.kind==="group"&&r.has(i.name))}function Qw(t){return t.includes("@")}function Hf(t,e,n,r){let i=n-1;if(i<0)return t;let o;if(!Number.isFinite(e))o=e>0?i:0;else if(e>0)o=t>=i?0:Math.min(i,t+e);else o=t<=0?i:Math.max(0,t+e);return r(o)?o+Math.sign(e):o}function Ff(t,e){let n={home:Number.NEGATIVE_INFINITY,end:Number.POSITIVE_INFINITY,pageup:-e,pagedown:e};return t===void 0?void 0:n[t]}function hO(t){let e=t.findIndex((n)=>n.kind==="group"&&Qw(n.name));return e>0&&t.slice(0,e).some((n)=>n.kind==="group")?[...t.slice(0,e),{kind:"rule"},...t.slice(e)]:t}function mO(t){let e=t.findIndex((n)=>n.kind==="palette");return e===-1?0:e}var cr="\x1B[0m",ts="\x1B[2m",es="\x1B[1m",Ar="\x1B[22m",xf="\x1B[36m",Lf="\x1B[33m";function oc(t){return t==="decode"||t==="glitch"?t:"typewriter"}class ns{picked;scope;maxItems;named=[];series=[];color;onFocus;entries=[];seriesPad=0;namePad=0;expanded=new Set;rows=[];cursor=0;top=0;filter="";lastFocused="";constructor(t){this.picked=t.picked,this.scope=t.scope??"palette",this.maxItems=t.maxItems??12,this.color=t.color??!0,this.onFocus=t.onFocus,this.load(t.entries),this.rebuild("first")}load(t){this.entries=t,this.named=t.filter((e)=>!e.default),this.series=[...new Set(this.named.map((e)=>e.group))],this.seriesPad=Math.max(0,...this.series.map((e)=>e.length)),this.namePad=Math.max(0,...this.named.map((e)=>this.indent(e).length+Vw(e).length))}indent(t){return Qo(t)===void 0?" ":" "}setEntries(t){this.load(t),this.rebuild("stay")}setFilter(t){if(t!==this.filter)this.filter=t,this.rebuild("keep")}focusedRow(){return this.rows[this.cursor]}refocus(){this.lastFocused="",this.sync()}members(t,e){let n=this.scope==="palette"?this.filter.trim():"";return this.named.filter((r)=>r.group===t&&(e===void 0||r.catalog===e)&&(n===""||ic(r,n)))}everyone(t){return t.flatMap((e)=>e.kind==="group"?this.members(e.name):[])}pick(){let t=this.rows[this.cursor],e=t?.kind==="palette"?[t.entry.name]:t?.kind==="group"?this.members(t.name).map((r)=>r.name):t?.kind==="catalog"?this.members(t.group,t.name).map((r)=>r.name):t?.kind==="all"?this.everyone(this.rows).map((r)=>r.name):[];if(e.length===0)return;let n=e.some((r)=>!this.picked.has(r));for(let r of e)if(n)this.picked.add(r);else this.picked.delete(r)}pickedIn(t,e){return this.members(t,e).filter((n)=>this.picked.has(n.name)).length}pickedCount(){if(this.scope==="palette")return this.named.filter((t)=>this.picked.has(t.name)).length;return this.series.filter((t)=>this.members(t).every((e)=>this.picked.has(e.name))).length}total(){return this.scope==="series"?this.series.length:this.named.length}matched(){let t=this.filter.trim();if(this.scope==="series")return this.rows.filter((e)=>e.kind==="group").length;return t?this.named.filter((e)=>ic(e,t)).length:this.named.length}sync(){let t=this.rows[this.cursor],e=t?.kind==="palette"?t.entry:t?.kind==="group"&&this.scope==="series"?t.lead:void 0;if(e&&e.name!==this.lastFocused)this.lastFocused=e.name,this.onFocus?.(e)}rebuild(t){let e=this.rows[this.cursor],n=this.scope==="series"?dO(this.entries,this.filter):Zw(this.entries,this.expanded,this.filter);this.rows=n.length>0?hO([{kind:"all",count:this.allCount(n)},...n]):[];let r=n.length>0?this.rows.indexOf(n[mO(n)]):0;if(t==="first")this.cursor=r;else if(t==="keep"||t==="stay"){let i=Pf(e),o=e?.kind==="palette"||t==="stay"?this.rows.findIndex((s)=>Pf(s)===i):-1;this.cursor=o===-1?r:o}else if(this.cursor>=this.rows.length)this.cursor=Math.max(0,this.rows.length-1);this.sync()}allCount(t){return this.scope==="series"?t.length:this.everyone(t).length}move(t){this.cursor=Hf(this.cursor,t,this.rows.length,(e)=>this.rows[e]?.kind==="rule"),this.sync()}toggle(t){if(this.expanded.has(t))this.expanded.delete(t);else this.expanded.add(t);this.rebuild("clamp")}climb(t,e){this.expanded.delete(t),this.rebuild("clamp"),this.cursor=Math.max(0,this.rows.findIndex((n)=>Pf(n)===e)),this.sync()}fold(t){if(this.filter||this.scope==="series")return;let e=this.rows[this.cursor];if(e?.kind==="group"){if(t!==e.expanded)this.toggle(e.name)}else if(e?.kind==="catalog"){if(t!==e.expanded)this.toggle(Xo(e.group,e.name));else if(!t)this.climb(e.group,`group ${e.group}`)}else if(e?.kind==="palette"&&!t&&!e.entry.default){let n=Qo(e.entry);if(n===void 0)this.climb(e.entry.group,`group ${e.entry.group}`);else this.climb(n,`catalog ${n}`)}}window(){if(this.cursor<this.top)this.top=this.cursor;if(this.cursor>=this.top+this.maxItems)this.top=this.cursor-this.maxItems+1;this.top=Math.min(this.top,Math.max(0,this.rows.length-this.maxItems));let t=this.rows.slice(this.top,this.top+this.maxItems);return{lines:t.map((e,n)=>this.renderRow(e,this.top+n===this.cursor)),below:this.rows.length-this.top-t.length}}renderRow(t,e){if(t.kind==="rule")return` ${this.color?`${ts}${"── Markets ──────────"}${cr}`:"── Markets ──────────"}`;let n=t.kind==="palette"?t.entry:t.kind==="all"?void 0:t.lead,r=this.color&&e&&n!==void 0,i=(b)=>this.color?`${ts}${b}${Ar}`:b,o=(b)=>this.color?`${es}${b}${Ar}`:b,s=(b)=>this.color?` ${Lh(ha(b),r?Fe(b.foreground):"\x1B[39m")}`:"",a=e?r?`${Fe(n.cursor)}▌\x1B[39m `:"▌ ":" ",c=(b)=>r?`${a}${Us(n.selection,n.foreground)} ${b} ${cr}`:`${a} ${b}`;if(t.kind==="all"){let b=this.everyone(this.rows).every((v)=>this.picked.has(v.name))?"●":"○";return c(`${b} Select all ${i(`(${t.count})`)}`)}if(t.kind==="group"&&this.scope==="series"){let b=this.pickedIn(t.name)===t.count?"●":"○",v=`(${t.count})${t.native?` ${t.native}`:""}`;return c(`${b} ${o(t.name.padEnd(this.seriesPad))}${s(t.lead)}${this.color?" ":" "}${i(v)}`)}let u=this.rows[this.cursor],l=(b,v)=>this.color&&u?.kind==="palette"&&b?`${es}${Fe(u.entry.cursor)}${v}${Ar}\x1B[39m`:o(v);if(t.kind==="group"){let b=l(u?.kind==="palette"&&u.entry.group===t.name,t.name),v=t.native?` ${i(t.native)}`:"";return c(`${t.expanded?"▾":"▸"} ${b} ${i(`(${this.pickedIn(t.name)}/${t.count})`)}${v}`)}if(t.kind==="catalog"){let b=u?.kind==="palette"&&Qo(u.entry)===Xo(t.group,t.name),v=i(`(${this.pickedIn(t.group,t.name)}/${t.count})`);return c(` ${t.expanded?"▾":"▸"} ${l(b,t.name)} ${v}`)}let f=t.entry,d=this.picked.has(f.name)?"●":"○",m=this.indent(f),g=Vw(f),$=this.color?g.padEnd(this.namePad-m.length):g,w=e?o($):$;return c(`${m}${d} ${w}${s(f)}`)}}function Tf(t){let e=t.named[Math.floor(Math.random()*t.named.length)],n=t.series[Math.floor(Math.random()*t.series.length)];return e&&n?`${e.name} | ${n}`:""}class sc{fx;make;redraw;roller;example="";step=0;seed=0;timer;constructor(t,e,n){this.fx=t,this.make=e,this.redraw=n,this.roll(),this.roller=setInterval(()=>{this.roll(),this.step=8,this.redraw()},3000),this.roller.unref?.()}stop(){clearInterval(this.roller),clearTimeout(this.timer)}roll(){let t=this.make();this.example=t.length>30?`${t.slice(0,29)}…`:t,this.seed=Math.floor(Math.random()*997)}text(){if(this.step===0)return this.example;if(!this.timer)this.timer=setTimeout(()=>{this.timer=void 0,this.step-=1,this.redraw()},60),this.timer.unref?.();let t=Math.floor(this.example.length*(8-this.step)/8);if(this.fx==="typewriter")return`${this.example.slice(0,t)}▏`;let e=this.fx==="decode"?"abcdefghijklmnopqrstuvwxyz":"▓▒░#*+=<>?/-_",n=this.fx==="decode"?(r)=>!/[a-z0-9]/i.test(r):(r)=>r===" ";return[...this.example].map((r,i)=>i+(i*7+this.seed)%3<t||n(r)?r:e[Math.floor(Math.random()*e.length)]??r).join("")}}class Af extends Yt{picked;list;scope;color;hint;lastInput="";constructor(t){super({render:()=>this.draw(),input:t.input,output:t.output,validate:t.required?()=>this.picked.size===0?`Pick at least one ${this.scope}`:void 0:void 0},!0);this.scope=t.scope??"palette",this.picked=new Set(t.installed??[]),this.color=t.color??!0,this.list=new ns({entries:t.entries,picked:this.picked,scope:this.scope,...t.maxItems===void 0?{}:{maxItems:t.maxItems},color:this.color,...t.onFocus?{onFocus:t.onFocus}:{}}),this.hint=new sc(t.fx??"typewriter",()=>Tf(this.list),()=>this.output.emit("resize")),this.once("finalize",()=>this.hint.stop()),this.on("cursor",(e)=>{if(e==="up")this.list.move(-1);else if(e==="down")this.list.move(1);else if(e==="left")this.list.fold(!1);else if(e==="right")this.list.fold(!0)}),this.on("userInput",(e)=>{if(e!==this.lastInput)this.lastInput=e,this.list.setFilter(e)}),this.on("key",(e,n)=>{let r=Ff(n?.name,this.list.maxItems);if(r!==void 0)this.list.move(r);else if(n?.name==="space")this.list.pick()})}_isActionKey(t){return t==="\t"||t===" "}draw(){let t=(m)=>this.color?`${ts}${m}${cr}`:m,e=(m)=>this.color?`${xf}${m}${cr}`:m,n=this.scope==="series"?"Series":"Catalog";if(this.state==="submit")return`${t("◇")} ${n} ${t(`· ${this.list.pickedCount()} picked`)}`;if(this.state==="cancel")return`${t(`◇ ${n} · cancelled`)}`;let r=`${e("◆")} ${n} ${t(`(${this.list.matched()}/${this.list.total()} · ${this.list.pickedCount()} picked)`)}`,i=this.hint.text(),o=`${e("│")} ${this.userInput?`${this.userInput}_`:t(`Search…${i?` e.g. ${i}`:""}`)}`,{lines:s,below:a}=this.list.window(),c=s.length>0?s.map((m)=>`${e("│")} ${m}`):[`${e("│")} ${t(`No ${this.scope==="series"?"series":"palettes"} match '${this.userInput}'`)}`];while(c.length<this.list.maxItems)c.push(e("│"));let u=a>0?`${e("│")} ${t(`↓ ${a} more`)}`:e("│"),l=this.scope==="series"?"":" · ←→ fold",f=this.scope==="series"?"continue":"install",d=this.state==="error"?`${e("└")} ${this.color?`${Lf}${this.error}${cr}`:this.error}`:`${e("└")} ${t(`↑↓ move${l} · space pick · type to filter · enter ${f} · esc cancel`)}`;return[r,o,...c,u,d].join(`
469
- `)}}var rs=[{tab:"catalog",title:"Catalog"},{tab:"installed",title:"Installed"},{tab:"markets",title:"Markets"},{tab:"errors",title:"Errors"}],Cf=34,gO=72,Xw=94,t0=40,e0=10,pO=3,jf={title:"",lines:[],brief:""};function ac(t){let e=t.trim();if(e!==J&&!e.includes("/")&&!e.startsWith("~"))return;try{return zn(e)}catch{return}}function bO(t){return t.charAt(0).toUpperCase()+t.slice(1)}class Gf extends Yt{picked;tab="catalog";filters={catalog:"",installed:"",markets:"",errors:""};cursor={markets:0,errors:0};top={markets:0,errors:0};adds=new Map;removes=new Set;want=new Map;busy=new Map;failed=new Map;refreshed=[];inflight=new Set;markets;problems;kept;installed;startup;io;order;color;hub;maxItems=12;paint;catalog;mine;hint;asking;leaving;shifted=!1;goto;repos;searching=!1;searchError;lastInput="";constructor(t){super({render:()=>this.draw(),input:t.input,output:t.output},!0);Object.assign(this,{render:()=>this.screen()}),this.markets=t.markets,this.problems=t.problems,this.kept=t.kept,this.installed=new Set(t.installed),this.startup=t.startup,this.io=t.io,this.order=t.order??((r)=>r),this.color=t.color??!0,this.hub=t.hub,this.paint=t.onFocus,this.picked=new Set(t.installed);let e=this.entries();this.catalog=new ns({entries:e,picked:this.picked,color:this.color,maxItems:this.maxItems,onFocus:(r)=>this.focus("catalog",r)}),this.mine=new ns({entries:this.mineOf(e),picked:this.picked,color:this.color,maxItems:this.maxItems,onFocus:(r)=>this.focus("installed",r)}),this.hint=new sc(t.fx??"typewriter",()=>Tf(this.tab==="installed"?this.mine:this.catalog),()=>this.redraw());let n=(r,i)=>{this.shifted=i?.shift===!0};this.input.on("keypress",n),this.once("finalize",()=>{this.hint.stop(),this.input.off("keypress",n)}),this.on("cursor",(r)=>{if(this.asking||this.leaving!==void 0||this.shifted)return;if(r==="up"||r==="down")this.move(r==="up"?-1:1);else if(r==="left"||r==="right")this.side(r==="right")}),this.on("userInput",(r)=>{if(r!==this.lastInput)this.lastInput=r,this.filters[this.tab]=r,this.list()?.setFilter(r)}),this.on("key",(r,i)=>this.key(r,i));for(let r of t.due)this.update(r)}_isActionKey(t){return t==="\t"||t===" "||(this.asking!==void 0||this.leaving!==void 0)&&t!==void 0}_shouldSubmit(){return this.asking===void 0&&this.leaving===void 0}next(){return this.goto}async idle(){await Promise.allSettled([...this.inflight])}result(){let t=new Set(this.entries().map((e)=>e.name));return{picked:new Set([...this.picked].filter((e)=>t.has(e))),adds:[...this.adds.values()],removes:[...this.removes],auto:Object.fromEntries(this.want),refreshed:this.refreshed}}key(t,e){if(this.leaving!==void 0){if(e?.name==="escape")this.leaving=void 0,Object.assign(e,{name:"answered",sequence:""});else if(t&&/^[yn]$/i.test(t)){if(t.toLowerCase()==="y")this.state="submit";else this.goto=this.leaving,this.state="cancel";this.leaving=void 0}return}if(this.asking){if(e?.name==="escape")this.asking=void 0,Object.assign(e,{name:"answered",sequence:""});else if(t&&/^[yn]$/i.test(t))this.answer(t.toLowerCase()==="y");return}let n=Ff(e?.name,this.maxItems);if(n!==void 0)this.move(n);else if(e?.name==="tab"){if(this.hub)this.leave(nb(this.hub,e.shift?-1:1))}else if(e?.shift&&(e.name==="left"||e.name==="right"))this.switchTab(e.name==="right"?1:-1);else if(e?.name==="space")this.activate();else if(e?.ctrl&&e.name==="r"){let r=this.tab==="markets"?this.marketRow():void 0;if(r?.kind==="market"&&!this.adds.has(r.market.source))this.update(r.market.source)}}redraw(){if(this.state==="active"||this.state==="error")this.output.emit("resize")}focus(t,e){if(this.tab===t&&this.state!=="submit"&&this.state!=="cancel")this.paint?.(e)}track(t){this.inflight.add(t);let e=()=>this.inflight.delete(t);return t.then(e,e),t}list(){return this.tab==="catalog"?this.catalog:this.tab==="installed"?this.mine:void 0}active(){return[...this.markets.filter((t)=>!this.removes.has(t.source)),...this.adds.values()]}entries(){let t=this.active().flatMap((i)=>i.entries),e=new Set(t.map((i)=>i.name)),n=new Map,r=this.markets.filter((i)=>this.removes.has(i.source)).flatMap((i)=>i.entries);for(let i of[...this.kept,...r])if(this.installed.has(i.name)&&!e.has(i.name))n.set(i.name,i);return this.order([...t,...n.values()])}mineOf(t){return t.filter((e)=>this.installed.has(e.name))}reload(){let t=this.entries();this.catalog.setEntries(t),this.mine.setEntries(this.mineOf(t))}switchTab(t){let e=rs.findIndex((i)=>i.tab===this.tab),n=rs[(e+t+rs.length)%rs.length]?.tab??"catalog",r=this.filters[n];this.tab=n,this._clearUserInput(),this._setUserInput(r,!0),this.lastInput=r,this.list()?.refocus()}move(t){let e=this.list();if(e){e.move(t);return}let n=this.tab==="markets"?"markets":"errors",r=n==="markets"?this.marketRows().map((i)=>i.kind==="rule"):this.problemRows().map(()=>!1);this.cursor[n]=Hf(this.cursor[n],t,r.length,(i)=>r[i]===!0)}side(t){let e=this.list();if(e){e.fold(t);return}let n=this.tab==="markets"?this.marketRow():void 0;if(n?.kind==="market"&&!ut(n.market.source))if(t===n.market.auto)this.want.delete(n.market.source);else this.want.set(n.market.source,t)}activate(){let t=this.list();if(t){t.pick();return}let e=this.tab==="markets"?this.marketRow():void 0;if(e?.kind==="market")this.toggleMarket(e.market);else if(e?.kind==="add")this.fetch(e.source);else if(e?.kind==="repo"){let n=this.known(e.source),r=this.marketRows().findIndex((i)=>i.kind==="market"&&i.market===n);if(n&&r>=0)this.cursor.markets=r;else if(!n)this.fetch(e.source)}else if(e?.kind==="find")this.search()}toggleMarket(t){if(this.adds.has(t.source))this.adds.delete(t.source),this.want.delete(t.source);else if(this.removes.has(t.source))this.removes.delete(t.source);else this.removes.add(t.source);this.reload()}known(t){return[...this.markets,...this.adds.values()].find((e)=>Ei(e.source,t))}fetch(t){if(this.busy.has(t))return;this.failed.delete(t),this.busy.set(t,"Fetching…"),this.track(this.io.fetch(t)).then((e)=>{this.busy.delete(t);let n=this.active().find((r)=>r.id===e.id);if(n)this.failed.set(t,`${e.id} already names the market at ${n.shown}`);else if(ut(t)||t===J)this.stage(e,e.auto);else this.asking=e;this.redraw()},(e)=>{this.busy.delete(t),this.failed.set(t,e.message),this.redraw()})}answer(t){let e=this.asking;if(this.asking=void 0,e)this.stage(e,t)}stage(t,e){if(this.adds.set(t.source,t),e===t.auto)this.want.delete(t.source);else this.want.set(t.source,e);this.reload(),this.cursor.markets=Math.max(0,this.marketRows().findIndex((n)=>n.kind==="market"&&n.market.source===t.source))}update(t){if(this.busy.has(t))return;this.failed.delete(t),this.busy.set(t,"Updating…"),this.track(this.io.refresh(t)).then(({market:e,refreshed:n})=>{this.busy.delete(t),this.markets=this.markets.map((r)=>r.source===t?e:r),this.problems=this.problems.filter((r)=>r.source!==t),this.refreshed.push(n),this.reload(),this.redraw()},(e)=>{this.busy.delete(t),this.failed.set(t,`Update failed: ${e.message}`),this.redraw()})}search(){if(this.searching)return;this.searching=!0,this.searchError=void 0;let t=this.filters.markets.trim();this.track(this.io.search(t&&!ac(t)?t:void 0)).then((e)=>{this.searching=!1,this.repos=e,this.redraw()},(e)=>{this.searching=!1,this.searchError=e.message,this.redraw()})}marketRows(){let t=this.filters.markets.trim().toLowerCase(),e=(...s)=>t===""||s.some((a)=>a.toLowerCase().includes(t)),n=[...this.markets,...this.adds.values()],r=n.filter((s)=>e(s.id,s.shown,s.source)).map((s)=>({kind:"market",market:s})),i=ac(this.filters.markets);if(i&&!n.some((s)=>Ei(s.source,i)))r.push({kind:"add",source:i});r.push({kind:"find"});let o=(this.repos??[]).map((s)=>({repo:s,source:Nf(s)})).filter(({repo:s,source:a})=>e(a,s.description??""));if(o.length>0)r.push({kind:"rule"},...o.map(({repo:s,source:a})=>({kind:"repo",repo:s,source:a})));return r}marketRow(){let t=this.marketRows();return t[Math.min(this.cursor.markets,t.length-1)]}problemList(){let t=new Map([...this.markets,...this.adds.values()].map((e)=>[e.source,e.id]));return[...this.problems.filter((e)=>!(e.update&&e.source&&this.failed.has(e.source))),...[...this.failed].map(([e,n])=>({where:t.get(e)??e,message:n,source:e}))]}problemRows(){let t=this.filters.errors.trim().toLowerCase();return this.problemList().filter((e)=>t===""||`${e.where} ${e.message}`.toLowerCase().includes(t))}windowOf(t,e,n,r=()=>!1){let i=Math.min(this.cursor[e],Math.max(0,t.length-1));if(r(t[i]))i-=1;this.cursor[e]=i;let o=Math.min(this.top[e],i);if(i>=o+this.maxItems)o=i-this.maxItems+1;o=Math.max(0,Math.min(o,t.length-this.maxItems)),this.top[e]=o;let s=t.slice(o,o+this.maxItems);return{lines:s.map((a,c)=>n(a,o+c===i)),below:t.length-o-s.length}}dim(t){return this.color?`${ts}${t}${Ar}`:t}bold(t){return this.color?`${es}${t}${Ar}`:t}warn(t){return this.color?`${Lf}${t}\x1B[39m`:t}lit(t,e,n){if(e&&this.color&&t)return`${Fe(t.cursor)}▌\x1B[39m ${Us(t.selection,t.foreground)} ${n} ${cr}`;return`${e?"▌ ":" "} ${n}`}status(t){return this.adds.has(t.source)?"Will add":this.removes.has(t.source)?"Will remove":this.busy.get(t.source)??(this.failed.has(t.source)||t.status.startsWith("update failed")?"Update failed":"")}marketLine(t,e){if(t.kind==="rule")return` ${this.dim("── On GitHub ──────────")}`;if(t.kind==="market"){let i=t.market,o=this.status(i),s=this.removes.has(i.source)?"○":"●",a=e?this.bold(i.id):i.id;return this.lit(i.entries.find((c)=>!c.default),e,`${s} ${a}${o?` ${this.dim(o)}`:""}`)}if(t.kind==="add"){let i=this.busy.get(t.source);return this.lit(void 0,e,`+ Add ${et(t.source)}${i?` ${this.dim(i)}`:""}`)}if(t.kind==="find"){let i=this.filters.markets.trim(),o=this.searching?"Searching GitHub…":i&&!ac(i)?`Find "${i}" on GitHub`:"Find markets on GitHub";return this.lit(void 0,e,`⌕ ${o}`)}let n=this.busy.get(t.source),r=this.known(t.source)?"●":"○";return this.lit(void 0,e,`${r} ${t.source} ${this.dim(`★${t.repo.stargazers_count}`)}${n?` ${this.dim(n)}`:""}`)}problemLine(t,e){return this.lit(void 0,e,`${this.warn("✗")} ${t.where} ${this.dim(t.message)}`)}body(){let t=this.list();if(t){let n=this.filters[this.tab];return{...t.window(),empty:n?`No palettes match '${n}'`:this.tab==="installed"?"Nothing installed yet":"No palettes"}}if(this.tab==="markets")return{...this.windowOf(this.marketRows(),"markets",(n,r)=>this.marketLine(n,r),(n)=>n?.kind==="rule"),empty:""};let e=this.filters.errors;return{...this.windowOf(this.problemRows(),"errors",(n,r)=>this.problemLine(n,r)),empty:e?`No problems match '${e}'`:"No problems"}}changes(){return this.adds.size+this.removes.size+this.want.size}dirty(){let{picked:t}=this.result();return this.changes()>0||t.size!==this.installed.size||[...t].some((e)=>!this.installed.has(e))}leave(t){if(this.dirty()){this.leaving=t;return}this.goto=t,this.state="cancel"}counts(){let t=[...this.busy.values()].includes("Updating…")?"Updating… · ":"",e=this.list();if(e)return`${t}${e.matched()}/${e.total()} · ${e.pickedCount()} picked`;if(this.tab==="markets"){let n=this.markets.length+this.adds.size,r=this.marketRows().filter((o)=>o.kind==="market").length,i=this.changes();return`${t}${r}/${n} markets${i>0?` · ${i} to apply`:""}`}return`${this.problemRows().length}/${this.problemList().length}`}searchText(){if(this.userInput)return`${this.userInput}_`;if(this.tab==="markets")return this.dim("Search… or add one: owner/repo");let t=this.tab==="errors"?"":this.hint.text();return this.dim(`Search…${t?` e.g. ${t}`:""}`)}tabBar(){return rs.map(({tab:t,title:e})=>{let n=t==="errors"?this.problemList().length:0,r=n>0?`${e} ${n}`:e;if(!this.color)return t===this.tab?`[${r}]`:` ${r} `;return t===this.tab?this.bold(r):this.dim(r)}).join(this.color?" ":" ")}sourceOf(t){let e=this.active().find((n)=>n.entries.some((r)=>r.name===t.name));if(!e)return"In no market you added";return e.source===J?"The ttheme catalog":e.shown}paletteState(t){let e=this.picked.has(t.name),n=this.installed.has(t.name),r=e&&n?"Installed":e?"Will install":n?"Will remove":"Not installed";return this.startup===t.name?`${r} · Default`:r}paletteDetail(t,e){if(!t||t.kind==="rule")return jf;if(t.kind==="all")return{title:this.bold("Select all"),lines:["space picks every palette shown"],brief:""};if(t.kind==="group"){let u=this.entries().filter((d)=>d.group===t.name&&!d.default),l=this.sourceOf(t.lead),f=`${_t(u.length)} · ${u.filter((d)=>this.installed.has(d.name)).length} installed`;return{title:this.bold(t.name),lines:[...t.native?kt(t.native,e).map((d)=>this.dim(d)):[],...kt(l,e),f],brief:`${l} · ${f}`}}if(t.kind==="catalog"){let u=this.entries().filter((d)=>d.group===t.group&&d.catalog===t.name),l=this.sourceOf(t.lead),f=`${_t(u.length)} · ${u.filter((d)=>this.installed.has(d.name)).length} installed`;return{title:this.bold(t.name),lines:[t.group,...kt(l,e),f],brief:`${t.group} · ${f}`}}let n=t.entry,r=this.sourceOf(n),i=Ho(n),o=`Gate ${Dt.length-i.length}/${Dt.length}`,s=n.pictures?.length??0,a=[...s>0?[`${s} picture${s===1?"":"s"}`]:[],...n.base?[`Base ${n.base}`]:[]].join(" · "),c=rt(n.name)?n.catalog?[n.catalog]:[]:[n.group,...n.native?[this.dim(n.native)]:[]];return{title:this.color?`${es}${Fe(n.cursor)}${n.name}${Ar}\x1B[39m`:n.name,lines:[...kt(r,e),...c,this.paletteState(n),"",i.length===0?`${o} · passes`:o,...i.flatMap((u)=>kt(u,e-2).map((l,f)=>`${f===0?this.warn("✗"):" "} ${l}`)),...a?["",a]:[]],brief:[r,o,...a?[a]:[],this.paletteState(n)].join(" · ")}}marketDetail(t,e){if(!t||t.kind==="rule")return jf;if(t.kind==="market"){let i=t.market,o=i.source===J?"The ttheme catalog":i.shown,s=i.entries.filter((m)=>!m.default),a=s.filter((m)=>this.installed.has(m.name)).map((m)=>m.name),c=`${_t(s.length)} · ${a.length} installed`,u=ut(i.source)?"Read in place":`Auto-update ${this.want.get(i.source)??i.auto?"on":"off"}`,l=this.busy.get(i.source)??bO(i.status),f=this.failed.get(i.source),d=this.adds.has(i.source)?["Will add"]:this.removes.has(i.source)?[a.length>0?`Will remove — ${a.join(", ")} stay${a.length===1?"s":""} installed`:"Will remove"]:this.want.has(i.source)?[`Auto-update turns ${this.want.get(i.source)?"on":"off"}`]:[];return{title:this.bold(i.id),lines:[...kt(o,e),c,"",ut(i.source)?u:`${u} ${this.dim("←→")}`,...ut(i.source)?[]:[l],...f?kt(f,e).map((m)=>this.warn(m)):[],...d.length>0?["",...d.flatMap((m)=>kt(m,e))]:[]],brief:[o,u,...d,...ut(i.source)?[]:[l]].join(" · ")}}if(t.kind==="add"){let i=this.busy.get(t.source)??this.failed.get(t.source)??"space fetches its index";return{title:this.bold(et(t.source)),lines:["Not added","",...kt(i,e)],brief:i}}if(t.kind==="find"){let i=this.filters.markets.trim(),o=this.searchError??(this.searching?"Searching…":this.repos?`${this.repos.length} found`:"space searches GitHub");return{title:this.bold("GitHub"),lines:[...kt(`Repositories with the ${yi} topic`,e),...i&&!ac(i)?[`Matching "${i}"`]:[],"",...kt(o,e)],brief:o}}let r=this.known(t.source)?"Added":this.busy.get(t.source)??this.failed.get(t.source)??"space adds it";return{title:this.bold(t.source),lines:[`★ ${t.repo.stargazers_count}`,...kt(t.repo.description??"",e),"",...kt(r,e)],brief:r}}detail(t){let e=this.list();if(e)return this.paletteDetail(e.focusedRow(),t);if(this.tab==="markets")return this.marketDetail(this.marketRow(),t);let n=this.problemRows(),r=n[Math.min(this.cursor.errors,n.length-1)];return r?{title:this.bold(r.where),lines:kt(r.message,t),brief:r.message}:jf}footer(t,e){if(this.leaving!==void 0)return`${t("└")} Apply your changes before you leave? ${this.dim("y apply · n discard · esc stay")}`;if(this.asking)return`${t("└")} Update ${this.asking.id} on its own when its author changes it? ${this.dim("y yes · n no · esc back")}`;let n={catalog:["⇧←→ switch","↑↓ move","←→ fold","space pick",e?"type to filter":""],installed:["⇧←→ switch","↑↓ move","←→ fold","space pick",e?"type to filter":""],markets:["⇧←→ switch","space add/remove","←→ auto-update",e?"ctrl+r update":""],errors:["⇧←→ switch","↑↓ move","type to filter"]}[this.tab];return`${t("└")} ${this.dim([...n.filter(Boolean),"enter apply","esc cancel"].join(" · "))}`}columns(){return this.output.columns??100}rows(){return this.output.rows??24}fitItems(t){let e=Math.max(pO,this.rows()-4-(t>=Xw?0:1)-(this.hub?1:0));this.maxItems=e,this.catalog.maxItems=e,this.mine.maxItems=e}screen(){if(this.state==="submit"||this.state==="cancel")return;let t=this.rows(),e=this.draw().split(`
470
- `),r=`\x1B[?2026h${this.state==="initial"?"\x1B[?25l":""}`;for(let i=0;i<t;i++)r+=`\x1B[${i+1};1H${e[i]??""}\x1B[K`;if(this.output.write(`${r}\x1B[H\x1B[?2026l`),this.state==="initial")this.state="active"}draw(){let t=this.columns();if(t<t0||this.rows()<e0)return`Needs ${t0}×${e0} — now ${t}×${this.rows()}
471
- ${this.dim("esc cancels")}`;let e=(f)=>this.color?`${xf}${f}${cr}`:f,n=t>=Xw,r=n?Math.min(t-Cf-4,gO):t-1;this.fitItems(t);let{lines:i,below:o,empty:s}=this.body(),a=i.length>0?i.map((f)=>`${e("│")} ${f}`):[`${e("│")} ${this.dim(s)}`];while(a.length<this.maxItems)a.push(e("│"));let c=[`${e("◆")} ${this.tabBar()}`,pe(`${e("│")} ${this.searchText()}`,this.dim(this.counts()),r),...a,o>0?`${e("│")} ${this.dim(`↓ ${o} more`)}`:e("│")],u=this.detail(n?Cf:r-2),l=n?c.map((f,d)=>`${Et(f,r)} ${this.dim("│")} ${Et(d===0?u.title:u.lines[d-1]??"",Cf,!1)}`):[...c.map((f)=>Et(f,r,!1)),Et(`${e("│")} ${this.dim(u.brief)}`,r,!1)];return[...this.hub?[Et(rb(this.hub,this.color),t-1,!1)]:[],...l,Et(this.footer(e,n),t-1,!1)].join(`
472
- `)}}import{existsSync as RP}from"node:fs";import{existsSync as Es,mkdirSync as kP,readFileSync as Rd}from"node:fs";import{dirname as yP}from"node:path";import{execFile as wO}from"node:child_process";import{createHash as o0}from"node:crypto";import{existsSync as $O,mkdtempSync as kO,readFileSync as fc,rmSync as yO,statSync as s0,writeFileSync as a0}from"node:fs";import{homedir as vO,tmpdir as EO}from"node:os";import{join as cc}from"node:path";import{fileURLToPath as SO}from"node:url";import{promisify as MO}from"node:util";var De=MO(wO),uc=67108864,IO=4096,_f=["image/png","image/jpeg","image/webp","image/gif","image/tiff","image/heic"],OO=["text/uri-list","text/plain;charset=utf-8","text/plain"],Uf=[..._f,"text/uri-list","text/plain"];function NO(t){try{return s0(t).isFile()}catch{return!1}}function RO(t){let e=[],n="",r="",i=!1;for(let o=0;o<t.length;o++){let s=t[o];if(r==="'")if(s==="'")r="";else n+=s;else if(r==='"')if(s==='"')r="";else if(s==="\\"&&'"\\$`'.includes(t[o+1]??""))n+=t[++o];else n+=s;else if(s==="\\"&&o+1<t.length)n+=t[++o],i=!0;else if(s==="'"||s==='"')r=s,i=!0;else if(/\s/.test(s)){if(i)e.push(n);n="",i=!1}else n+=s,i=!0}if(i)e.push(n);return e}function n0(t){if(/^file:\/\//i.test(t))try{return SO(t)}catch{return}if(t.startsWith("~/"))return cc(vO(),t.slice(2));return t.startsWith("/")?t:void 0}function ji(t,e=NO){let n=[];for(let r of t.replace(/\r\n?/g,`
663
+ `)}`:" passes the gate"}`)}return yk(e,n,o),console.log(`
664
+ ${r} · ${xt(o.length)} → ${Ii(e,cn)}`),0}async function Ok(t,e){switch(t){case void 0:kT();return;case"add":await bT(mk(t,e));return;case"remove":wT(mk(t,e));return;case"search":await yT(e);return;case"init":await ET(e);return;case"build":return MT(e);default:throw Error(`unknown market action ${t} — ${dT.join(", ")}, or none to list them`)}}function mk(t,e){if(!e)throw Error(t==="add"?"market add takes a repository or a folder: ttheme market add alice/ttheme-dust":"market remove takes a market name — `ttheme market` lists them");return e}function Ik(t,e){let n=_s(t,e);return`${n} — ${xt(yr(e,n,Ou(t),!1).length)}, read in place`}var OT=new Intl.Segmenter(void 0,{granularity:"grapheme"});function xk(t){return[...t].length===1&&t>=" "&&t!==""}function IT(t){return[...t.replace(/[\r\n\t]+/g," ")].filter(xk).join("")}function xi(t,e,n=()=>!0){if(e==="backspace")return[...OT.segment(t)].slice(0,-1).map((r)=>r.segment).join("");if(e==="ctrl-u")return"";if(e==="ctrl-w"||e==="alt-backspace")return t.replace(/\S*\s*$/,"");return xk(e)&&n(e)?t+e:void 0}class Gr{value;constructor(t=""){this.value=t}key(t){let e=xi(this.value,t);if(e===void 0)return!1;return this.value=e,!0}paste(t){this.value+=IT(t)}}import{performance as xT}from"node:perf_hooks";import{StringDecoder as NT}from"node:string_decoder";var RT=30,Nk=50,TT=500,PT=5,Rk=Buffer.from("\x1B[M"),xu="\x1B]1337;ReportCellSize\x07\x1B[16t\x1B[14t\x1B[18t",Ck={A:"up",B:"down",C:"right",D:"left",H:"home",F:"end","1~":"home","7~":"home","3~":"delete","4~":"end","8~":"end","5~":"pgup","6~":"pgdn",I:"focus-in",O:"focus-out",Z:"shift-tab","1;2C":"shift-right","1;2D":"shift-left"},HT={"\r":"enter","\n":"enter","\t":"tab","\b":"backspace","":"backspace","\x1B":"esc","\x00":"ctrl-space"},Tk=/\[([0-?]*)([ -/]*)([@-~])/y,AT=/^\[[0-?]*[ -/]*$/,Pk=/\](\d+)/y,FT=/^\]\d*$/,Hk=/\]\d+;/y,CT=/^1337;ReportCellSize=([\d.]+);([\d.]+)(?:;([\d.]+))?$/,Lk="\x1B[200~",Iu="\x1B[201~";function Ph(t){let e=HT[t];if(e)return e;let n=t.codePointAt(0)??0;if(n<27)return`ctrl-${String.fromCharCode(n+96)}`;return n<32?void 0:t}function Bs(t){return{kind:"key",key:t}}function Ws(t){return{events:[Bs("esc")],end:t+1}}function LT(t){let e={};for(let n of t.split(":")){let r=n.indexOf("=");if(r>0)e[n.slice(0,r)]=n.slice(r+1)}return e}var jT=["left","middle","right",void 0];function jk(t,e,n,r){if(!Number.isInteger(t)||t<0||t>=128||!(e>=0)||!(n>=0))return;let i=t&3,s={kind:"mouse",row:n,col:e,shift:(t&4)!==0,alt:(t&8)!==0,ctrl:(t&16)!==0};if(t&64)return{...s,action:"wheel",button:void 0,wheel:i%2===0?-1:1,sideways:i>=2,count:0};let o=jT[i],a=t&32?o?"drag":"move":r||!o?"release":"press";return{...s,action:a,button:o,wheel:0,sideways:!1,count:a==="press"?1:0}}function GT(t,e,n){let r=[],i=e;while(r.length<3&&i<t.length){let u=t.codePointAt(i);r.push(u),i+=u>65535?2:1}if(r.length<3)return n?{events:[],end:t.length}:void 0;let[s=0,o=0,a=0]=r,c=Math.max(s,o,a)<128?jk(s-32,o-33,a-33,!1):void 0;return{events:c?[c]:[],end:i}}function _T(t,e,n){if((n==="M"||n==="m")&&e===""&&t.startsWith("<")){let[i=-1,s=0,o=0]=t.slice(1).split(";").map(Number),a=jk(i,s-1,o-1,n==="m");return a?[a]:[]}if(n==="t"&&e===""){let[i,s=0,o=0]=t.split(";").map(Number),a=i===6?"cell":i===4?"window":i===8?"grid":void 0;return a?[{kind:"size",of:a,h:s,w:o}]:[]}if(n==="y"&&e==="$"&&t.startsWith("?")){let[i=0,s=0]=t.slice(1).split(";").map(Number);return[{kind:"mode",mode:i,value:s}]}if(n==="c"&&t.startsWith("?"))return[{kind:"attributes"}];let r=e===""?Ck[`${t}${n}`]:void 0;return r?[Bs(r)]:[]}function BT(t,e,n){Tk.lastIndex=e+1;let r=Tk.exec(t);if(!r)return!n&&AT.test(t.slice(e+1))?void 0:Ws(e);let[i,s="",o="",a=""]=r,c=e+1+i.length;if(s===""&&o===""&&a==="M")return GT(t,c,n);if(s==="200"&&a==="~"){let u=t.indexOf(Iu,c);if(u===-1)return n?{events:[{kind:"paste",text:t.slice(c)}],end:t.length}:void 0;return{events:[{kind:"paste",text:t.slice(c,u)}],end:u+Iu.length}}return{events:_T(s,o,a),end:c}}function WT(t){let e=CT.exec(t);if(e){let s=Number(e[3]??1);return[{kind:"size",of:"cell",h:Math.round(Number(e[1])*s),w:Math.round(Number(e[2])*s)}]}let[n="",r="",...i]=t.split(";");return[{kind:"osc",code:n,meta:LT(r),payload:i.join(";")}]}function UT(t,e,n){Pk.lastIndex=e+1;let r=Pk.exec(t),i=r?t[e+1+r[0].length]:void 0;if(i!==";"&&i!=="\x07"&&i!=="\x1B")return!n&&FT.test(t.slice(e+1))?void 0:Ws(e);let s=[t.indexOf("\x07",e),t.indexOf("\x1B\\",e+2)].filter((a)=>a!==-1);if(s.length===0)return n?{events:[],end:t.length}:void 0;let o=Math.min(...s);return{events:WT(t.slice(e+2,o)),end:o+(t[o]==="\x07"?1:2)}}function KT(t,e,n){let r=t[e+2];if(r===void 0)return n?Ws(e):void 0;if(!/^[A-Za-z]$/.test(r))return Ws(e);let i=Ck[r];return{events:i?[Bs(i)]:[],end:e+3}}function zT(t,e,n){let r=t[e+1];if(r===void 0)return n?Ws(e):void 0;if(r==="[")return BT(t,e,n);if(r==="]")return UT(t,e,n);if(r==="O")return KT(t,e,n);if(r==="")return{events:[Bs("alt-backspace")],end:e+2};if(/^[a-z]$/.test(r))return{events:[Bs(`alt-${r}`)],end:e+2};return Ws(e)}function Ak(t,e=!1){let n=[],r=0;while(r<t.length){if(t[r]==="\x1B"){let o=zT(t,r,e);if(!o)return{events:n,rest:t.slice(r)};n.push(...o.events),r=o.end;continue}let i=String.fromCodePoint(t.codePointAt(r)),s=Ph(i);if(s)n.push(Bs(s));r+=i.length}return{events:n,rest:""}}function DT(t){let e=t.indexOf(Rk);if(e===-1)return{bytes:t,carry:void 0};let n=[],r=0;while(e!==-1&&e+6<=t.length){n.push(t.subarray(r,e));let[i=0,s=0,o=0]=t.subarray(e+3,e+6);if(s>32&&o>32)n.push(Buffer.from(`\x1B[<${i-32};${s-32};${o-32}M`));r=e+6,e=t.indexOf(Rk,r)}return n.push(t.subarray(r,e===-1?t.length:e)),{bytes:Buffer.concat(n),carry:e===-1?void 0:t.subarray(e)}}function Fk(t){return Hk.lastIndex=1,t.startsWith(Lk)||t.startsWith("\x1B]")&&Hk.test(t)}function qT(t,e){let n=t.slice(-Iu.length)+e;return t.startsWith(Lk)?n.includes(Iu):n.includes("\x07")||n.includes("\x1B\\")}class Hh{held="";timer;carry;pressed;wheeled;utf8=new NT("utf8");burst;take;constructor(t,e=()=>!1){this.burst=e,this.take=(n)=>{let r=this.counted(n);if(r.length>0)t(r)}}counted(t){let e=xT.now();return t.filter((n)=>{if(n.kind!=="mouse")return!0;if(n.action==="wheel"){let s=n.wheel*(n.sideways?2:1),o=this.wheeled;if(o!==void 0&&o.way===s&&e-o.at<PT)return!1;return this.wheeled={at:e,way:s},!0}if(n.action==="release")n.count=this.pressed?.count??0;if(n.action!=="press"||!n.button)return!0;let r=this.pressed,i=r!==void 0&&r.button===n.button&&r.row===n.row&&Math.abs(r.col-n.col)<=1&&e-r.at<=TT;return n.count=i?r.count+1:1,this.pressed={at:e,button:n.button,row:n.row,col:n.col,count:n.count},!0})}feed(t){clearTimeout(this.timer);let e=typeof t==="string"?t:this.bytes(t);if(this.carry)this.wait(Nk);if(!this.held&&!e.includes("\x1B")&&this.burst(e)){this.take([{kind:"paste",text:e}]);return}if(Fk(this.held)&&!qT(this.held,e)){this.held+=e;return}let{events:n,rest:r}=Ak(this.held+e);if(this.held=r,r&&!Fk(r))this.wait(r.length===1?RT:Nk);if(n.length>0)this.take(n)}bytes(t){let{bytes:e,carry:n}=DT(this.carry?Buffer.concat([this.carry,t]):t);return this.carry=n,this.utf8.write(e)}wait(t){clearTimeout(this.timer),this.timer=setTimeout(()=>this.flush(),t)}flush(){clearTimeout(this.timer),this.carry=void 0;let{events:t}=Ak(this.held,!0);if(this.held="",t.length>0)this.take(t)}stop(){clearTimeout(this.timer),this.held="",this.carry=void 0}}class sa{window;grid;see(t){if(t.kind!=="size")return;if(t.of==="cell")return{w:t.w,h:t.h};if(t.of==="window")this.window=t;else this.grid=t;let e=this.window,n=this.grid;return e&&n&&n.h>0&&n.w>0?{h:Math.floor(e.h/n.h),w:Math.floor(e.w/n.w)}:void 0}}var Ru={on:"\x1B[?1049h",off:"\x1B[?1049l"},Kn={on:"\x1B[?25l",off:"\x1B[?25h"},Ni={on:"\x1B[?7l",off:"\x1B[?7h"},_r={on:"\x1B[?2004h",off:"\x1B[?2004l"},Wk={on:"\x1B[?1004h",off:"\x1B[?1004l"},YT={on:"\x1B[?1000h\x1B[?1002h\x1B[?1006h",off:"\x1B[?1006l\x1B[?1002l\x1B[?1000l"};function Ks(t=process.env){return t.TTHEME_MOUSE==="off"?[]:[YT]}var Uk={SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGTERM:15},JT=3000;class aa extends Error{exit;constructor(t){super(t);this.exit=128+Uk[t]}}var gn=[],Us=new Map,oa=new Map;function Gk(t){return gn.findLast((e)=>e.input===t)}var _k;function Kk(t){for(let e of[...gn].reverse())e.abort(t);if(!_k)_k=setTimeout(()=>{zk(),process.exit(t instanceof aa?t.exit:1)},JT).unref()}var VT=Object.fromEntries(Object.keys(Uk).map((t)=>[t,()=>Kk(new aa(t))]));function zk(){for(let t of[...gn].reverse())t.close()}function ZT(){for(let t of gn)t.reassert();gn.at(-1)?.redraw()}function Bk(t){let e=t?"on":"off";for(let[n,r]of Object.entries(VT))process[e](n,r);if(process[e]("uncaughtException",Kk),process[e]("exit",zk),process.platform!=="win32")process[e]("SIGCONT",ZT)}function Nu(){}class Dk{input;output;failed;modes=[];assumed;owned=[];keys;tty;take;resized;queued=[];asking;reject=Nu;open=!0;aborted=!1;constructor(t={}){if(this.input=t.input??process.stdin,this.output=t.output??process.stdout,this.tty=this.output.isTTY===!0&&this.input.isTTY===!0,this.assumed=t.assume??[],this.keys=new Hh((r)=>this.deliver(r),t.burst),this.failed=new Promise((r,i)=>{this.reject=i}),this.failed.catch(Nu),this.tty&&!gn.some((r)=>r.tty))Bk(!0);gn.push(this);let e="";for(let r of this.assumed)if(!Us.has(r))e+=r.on;for(let r of t.modes??[])e+=this.claim(r);this.write(e);let n=oa.get(this.input)??0;if(n===0)this.input.setRawMode?.(!0);oa.set(this.input,n+1),this.input.on("data",this.received),this.input.resume(),this.output.on("resize",this.resizing),this.output.on("error",Nu)}hold(t){this.write(this.claim(t))}get cols(){return this.output.columns||80}get rows(){return this.output.rows||24}write(t){if(t&&this.open)this.output.write(t)}listen(t){this.take=t;let e=this.queued;if(this.queued=[],e.length>0)t(e)}onResize(t){this.resized=t}until(t){return Promise.race([t,this.failed])}loop(t,e=()=>{}){return this.until(new Promise((n)=>{let r=!1;this.listen((i)=>{for(let s of i){let o=r?void 0:t(s);if(o!==void 0)r=!0,n(o)}if(!r)e()})}))}ask(t,e,n,r=!0){return new Promise((i)=>{let s={hold:r,pick:(c)=>{let u=e(c);if(u===void 0)return!1;return o(u),!0}},o=(c)=>{if(clearTimeout(a),this.asking===s)this.asking=void 0;i(c),this.release()},a=setTimeout(()=>o(void 0),n);this.asking=s,this.write(t)})}abort(t){if(this.aborted)return;this.aborted=!0,this.keys.stop(),this.reject(t)}redraw(){this.resized?.()}reassert(){if(this.open)this.input.setRawMode?.(!0),this.write([...this.assumed,...this.owned].map((t)=>t.on).join(""))}close(){if(!this.open)return;this.keys.stop(),this.input.off("data",this.received),this.output.off("resize",this.resizing);let t="";for(let n of[...this.modes].reverse()){let r=(Us.get(n)??1)-1;if(r===0)Us.delete(n),t+=n.off;else Us.set(n,r)}this.write(t),this.open=!1;let e=(oa.get(this.input)??1)-1;if(e===0)oa.delete(this.input),this.input.setRawMode?.(!1),this.input.pause();else oa.set(this.input,e);if(this.output.off("error",Nu),gn.splice(gn.indexOf(this),1),this.tty&&!gn.some((n)=>n.tty))Bk(!1)}received=(t)=>{if(Gk(this.input)===this&&!this.aborted)this.keys.feed(t)};resizing=()=>{if(Gk(this.input)===this)this.resized?.()};claim(t){this.modes.push(t);let e=Us.get(t)??0;if(Us.set(t,e+1),e>0)return"";return this.owned.push(t),t.on}deliver(t){let e=this.asking,n=e?t.filter((r)=>!e.pick(r)):t;if(n.length===0)return;if(!this.take||this.asking?.hold){this.queued.push(...n);return}this.take(n)}release(){if(this.take&&this.queued.length>0){let t=this.queued;this.queued=[],this.take(t)}}}async function Br(t,e){let n=new Dk(t);try{return await e(n)}finally{n.close()}}var QT=3;function ca(t,e){return`${t}/${e}`}function qk(t){return ct(t.name)?dr(t.name):t.name}function zs(t){return t.catalog!==void 0&&Jk(t.group)?ca(t.group,t.catalog):void 0}function Ah(t){if(t?.kind==="palette")return`palette ${t.entry.name}`;if(t?.kind==="group")return`group ${t.name}`;if(t?.kind==="catalog")return`catalog ${ca(t.group,t.name)}`;return t?.kind??""}function Tu(t,e){let n=e.toLowerCase();return[t.name,t.group,t.native??"",t.catalog??"",...t.nativeNames??[],...dc(t.booru)].some((r)=>r.toLowerCase().includes(n))}function Yk(t,e,n){let r=n.trim(),i=[],s=new Set,o=(a)=>({kind:"palette",entry:a});for(let a of t){if(a.default||s.has(a.group))continue;s.add(a.group);let c=t.filter((f)=>!f.default&&f.group===a.group),u=r?c.filter((f)=>Tu(f,r)):c;if(r&&u.length===0)continue;let l=r.length>0||e.has(a.group);if(i.push({kind:"group",name:a.group,native:a.native,lead:c.find((f)=>f.lead)??a,expanded:l,count:u.length}),!l)continue;let d=u.filter((f)=>zs(f)!==void 0);for(let f of new Set(d.map((h)=>h.catalog))){let h=d.filter(($)=>$.catalog===f),p=r.length>0||e.has(ca(a.group,f));if(i.push({kind:"catalog",group:a.group,name:f,lead:h[0],expanded:p,count:h.length}),p)i.push(...h.map(o))}i.push(...u.filter((f)=>zs(f)===void 0).map(o))}return i}function XT(t,e){let n=e.trim(),r=new Set(t.filter((i)=>!i.default&&(n===""||Tu(i,n))).map((i)=>i.group));return Yk(t,new Set,"").filter((i)=>i.kind==="group"&&r.has(i.name))}function Jk(t){return t.includes("@")}function Fh(t,e,n,r,i=!0){let s=n-1;if(s<0)return t;let o;if(!Number.isFinite(e))o=e>0?s:0;else if(e>0)o=t>=s?i?0:s:Math.min(s,t+e);else o=t<=0?i?s:0:Math.max(0,t+e);return r(o)?o+Math.sign(e):o}function Pu(t,e){let n={home:Number.NEGATIVE_INFINITY,end:Number.POSITIVE_INFINITY,pgup:-e,pgdn:e};return t===void 0?void 0:n[t]}function tP(t){let e=t.findIndex((n)=>n.kind==="group"&&Jk(n.name));return e>0&&t.slice(0,e).some((n)=>n.kind==="group")?[...t.slice(0,e),{kind:"rule"},...t.slice(e)]:t}function eP(t){let e=t.findIndex((n)=>n.kind==="palette");return e===-1?0:e}function Hu(t){return t==="decode"||t==="glitch"?t:"typewriter"}function Ds(t,e,n){return se({kind:"row",at:t,part:e},n)}class ua{picked;scope;maxItems;named=[];series=[];color;onFocus;entries=[];seriesPad=0;namePad=0;expanded=new Set;rows=[];cursor=0;top=0;filter="";lastFocused="";constructor(t){this.picked=t.picked,this.scope=t.scope??"palette",this.maxItems=t.maxItems??12,this.color=t.color??!0,this.onFocus=t.onFocus,this.load(t.entries),this.rebuild("first")}load(t){this.entries=t,this.named=t.filter((e)=>!e.default),this.series=[...new Set(this.named.map((e)=>e.group))],this.seriesPad=Math.max(0,...this.series.map((e)=>e.length)),this.namePad=Math.max(0,...this.named.map((e)=>this.indent(e).length+qk(e).length))}indent(t){return zs(t)===void 0?" ":" "}setEntries(t){this.load(t),this.rebuild("stay")}setFilter(t){if(t!==this.filter)this.filter=t,this.rebuild("keep")}clear(){let t=this.rows[this.cursor];if(t?.kind==="palette"&&!t.entry.default){this.expanded.add(t.entry.group);let e=zs(t.entry);if(e!==void 0)this.expanded.add(e)}this.setFilter("")}focusedRow(){return this.rows[this.cursor]}refocus(){this.lastFocused="",this.sync()}members(t,e){let n=this.scope==="palette"?this.filter.trim():"";return this.named.filter((r)=>r.group===t&&(e===void 0||r.catalog===e)&&(n===""||Tu(r,n)))}everyone(t){return t.flatMap((e)=>e.kind==="group"?this.members(e.name):[])}pick(){let t=this.rows[this.cursor],e=t?.kind==="palette"?[t.entry.name]:t?.kind==="group"?this.members(t.name).map((r)=>r.name):t?.kind==="catalog"?this.members(t.group,t.name).map((r)=>r.name):t?.kind==="all"?this.everyone(this.rows).map((r)=>r.name):[];if(e.length===0)return;let n=e.some((r)=>!this.picked.has(r));for(let r of e)if(n)this.picked.add(r);else this.picked.delete(r)}pickedIn(t,e){return this.members(t,e).filter((n)=>this.picked.has(n.name)).length}pickedCount(){if(this.scope==="palette")return this.named.filter((t)=>this.picked.has(t.name)).length;return this.series.filter((t)=>this.members(t).every((e)=>this.picked.has(e.name))).length}total(){return this.scope==="series"?this.series.length:this.named.length}matched(){let t=this.filter.trim();if(this.scope==="series")return this.rows.filter((e)=>e.kind==="group").length;return t?this.named.filter((e)=>Tu(e,t)).length:this.named.length}sync(){let t=this.rows[this.cursor],e=t?.kind==="palette"?t.entry:t?.kind==="group"&&this.scope==="series"?t.lead:void 0;if(e&&e.name!==this.lastFocused)this.lastFocused=e.name,this.onFocus?.(e)}rebuild(t){let e=this.rows[this.cursor],n=this.scope==="series"?XT(this.entries,this.filter):Yk(this.entries,this.expanded,this.filter);this.rows=n.length>0?tP([{kind:"all",count:this.allCount(n)},...n]):[];let r=n.length>0?this.rows.indexOf(n[eP(n)]):0;if(t==="first")this.cursor=r;else if(t==="keep"||t==="stay"){let i=Ah(e),s=e?.kind==="palette"||t==="stay"?this.rows.findIndex((o)=>Ah(o)===i):-1;this.cursor=s===-1?r:s}else if(this.cursor>=this.rows.length)this.cursor=Math.max(0,this.rows.length-1);this.sync()}allCount(t){return this.scope==="series"?t.length:this.everyone(t).length}move(t,e=!0){this.cursor=Fh(this.cursor,t,this.rows.length,(n)=>this.rows[n]?.kind==="rule",e),this.sync()}point(t){let e=this.rows[t];if(!e||e.kind==="rule")return!1;return this.cursor=t,this.sync(),!0}flip(){let t=this.rows[this.cursor];if(t?.kind==="group"||t?.kind==="catalog")this.fold(!t.expanded)}foldable(){let t=this.rows[this.cursor];return(t?.kind==="group"||t?.kind==="catalog")&&this.scope==="palette"&&!this.filter}open(){if(this.foldable())this.flip();else this.pick()}toggle(t){if(this.expanded.has(t))this.expanded.delete(t);else this.expanded.add(t);this.rebuild("clamp")}climb(t,e){this.expanded.delete(t),this.rebuild("clamp"),this.reach(e)}reach(t){this.cursor=Math.max(0,this.rows.findIndex((e)=>Ah(e)===t)),this.sync()}fold(t){if(this.filter||this.scope==="series")return;let e=this.rows[this.cursor];if(e?.kind==="group"){if(t!==e.expanded)this.toggle(e.name)}else if(e?.kind==="catalog"){if(t!==e.expanded)this.toggle(ca(e.group,e.name));else if(!t)this.reach(`group ${e.group}`)}else if(e?.kind==="palette"&&!t&&!e.entry.default){let n=zs(e.entry);if(n===void 0)this.climb(e.entry.group,`group ${e.entry.group}`);else this.climb(n,`catalog ${n}`)}}window(){if(this.cursor<this.top)this.top=this.cursor;if(this.cursor>=this.top+this.maxItems)this.top=this.cursor-this.maxItems+1;this.top=Math.min(this.top,Math.max(0,this.rows.length-this.maxItems));let t=this.rows.slice(this.top,this.top+this.maxItems);return{lines:t.map((e,n)=>this.renderRow(e,this.top+n)),above:this.top,below:this.rows.length-this.top-t.length}}renderRow(t,e){if(t.kind==="rule")return` ${this.color?`${P}${"── Markets ──────────"}${Pt}`:"── Markets ──────────"}`;return Ds(e,"row",this.rowText(t,e))}rowText(t,e){let n=e===this.cursor,r=t.kind==="palette"?t.entry:t.kind==="all"?void 0:t.lead,i=this.color&&n&&r!==void 0,s=(S)=>this.color?`${P}${S}${de}`:S,o=(S)=>this.color?`${at}${S}${de}`:S,a=(S)=>this.color?` ${$p(ac(S),i?Ce(S.foreground):"\x1B[39m")}`:"",c=n?i?`${Ce(r.cursor)}▌\x1B[39m `:"▌ ":" ",u=(S)=>i?`${c}${Fa(r.selection,r.foreground)} ${S} ${Pt}`:`${c} ${S}`,l=(S)=>Ds(e,"box",`${S?"●":"○"} `),d=(S)=>Ds(e,"fold",`${S?"▾":"▸"} `);if(t.kind==="all")return u(`${l(this.everyone(this.rows).every((S)=>this.picked.has(S.name)))}Select all ${s(`(${t.count})`)}`);if(t.kind==="group"&&this.scope==="series"){let S=`(${t.count})${t.native?` ${t.native}`:""}`;return u(`${l(this.pickedIn(t.name)===t.count)}${o(t.name.padEnd(this.seriesPad))}${a(t.lead)}${this.color?" ":" "}${s(S)}`)}let f=this.rows[this.cursor],h=(S,E)=>this.color&&f?.kind==="palette"&&S?`${at}${Ce(f.entry.cursor)}${E}${de}\x1B[39m`:o(E);if(t.kind==="group"){let S=h(f?.kind==="palette"&&f.entry.group===t.name,t.name),E=t.native?` ${s(t.native)}`:"";return u(`${d(t.expanded)}${S} ${s(`(${this.pickedIn(t.name)}/${t.count})`)}${E}`)}if(t.kind==="catalog"){let S=f?.kind==="palette"&&zs(f.entry)===ca(t.group,t.name),E=s(`(${this.pickedIn(t.group,t.name)}/${t.count})`);return u(` ${d(t.expanded)}${h(S,t.name)} ${E}`)}let p=t.entry,$=this.indent(p),g=qk(p),b=this.color?g.padEnd(this.namePad-$.length):g,y=n?o(b):b;return u(`${$}${l(this.picked.has(p.name))}${y}${a(p)}`)}}function Ch(t){let e=t.named[Math.floor(Math.random()*t.named.length)],n=t.series[Math.floor(Math.random()*t.series.length)];return e&&n?`${e.name} | ${n}`:""}class Au{fx;make;redraw;roller;example="";step=0;seed=0;timer;constructor(t,e,n){this.fx=t,this.make=e,this.redraw=n,this.roll(),this.roller=setInterval(()=>{this.roll(),this.step=8,this.redraw()},3000),this.roller.unref?.()}stop(){clearInterval(this.roller),clearTimeout(this.timer)}roll(){let t=this.make();this.example=t.length>30?`${t.slice(0,29)}…`:t,this.seed=Math.floor(Math.random()*997)}text(){if(this.step===0)return this.example;if(!this.timer)this.timer=setTimeout(()=>{this.timer=void 0,this.step-=1,this.redraw()},60),this.timer.unref?.();let t=Math.floor(this.example.length*(8-this.step)/8);if(this.fx==="typewriter")return`${this.example.slice(0,t)}▏`;let e=this.fx==="decode"?"abcdefghijklmnopqrstuvwxyz":"▓▒░#*+=<>?/-_",n=this.fx==="decode"?(r)=>!/[a-z0-9]/i.test(r):(r)=>r===" ";return[...this.example].map((r,i)=>i+(i*7+this.seed)%3<t||n(r)?r:e[Math.floor(Math.random()*e.length)]??r).join("")}}var nP=5;class Lh{picked;list;scope;color;required;most;hint;field=new Gr;input;output;state="active";error="";redraw=()=>{};constructor(t){this.scope=t.scope??"palette",this.picked=new Set(t.installed??[]),this.color=t.color??!0,this.required=t.required??!1,this.most=t.maxItems??12,this.input=t.input,this.output=t.output,this.list=new ua({entries:t.entries,picked:this.picked,scope:this.scope,maxItems:this.most,color:this.color,...t.onFocus?{onFocus:t.onFocus}:{}}),this.hint=new Au(t.fx??"typewriter",()=>Ch(this.list),()=>this.redraw())}prompt(){return Br({input:this.input,output:this.output,modes:[Kn,_r]},async(t)=>{let e=new ph((r)=>t.write(r),()=>t.cols),n=()=>{return this.list.maxItems=Math.max(QT,Math.min(this.most,t.rows-nP)),this.draw()};this.redraw=()=>e.draw(n()),t.onResize(()=>e.redraw(n())),this.redraw();try{let r=await t.loop((i)=>{return this.take(i),this.state==="submit"||this.state==="cancel"?this.state:void 0},()=>this.redraw());return this.redraw=()=>{},e.end(this.draw()),r}finally{this.hint.stop()}})}take(t){if(t.kind==="paste"){this.field.paste(t.text),this.list.setFilter(this.field.value);return}if(t.kind!=="key")return;let e=t.key;if(this.state==="error")this.state="active";let n=Pu(e,this.list.maxItems);if(e==="esc"||e==="ctrl-c")this.state="cancel";else if(e==="enter")if(this.required&&this.picked.size===0)this.error=`Pick at least one ${this.scope}`,this.state="error";else this.state="submit";else if(e==="up"||e==="down")this.list.move(e==="up"?-1:1);else if(e==="left"||e==="right")this.list.fold(e==="right");else if(n!==void 0)this.list.move(n);else if(e===" ")this.list.pick();else if(this.field.key(e))this.list.setFilter(this.field.value)}draw(){let t=(p)=>this.color?`${P}${p}${Pt}`:p,e=(p)=>this.color?`${Ca}${p}${Pt}`:p,n=this.scope==="series"?"Series":"Catalog";if(this.state==="submit")return[`${t("◇")} ${n} ${t(`· ${this.list.pickedCount()} picked`)}`];if(this.state==="cancel")return[`${t(`◇ ${n} · cancelled`)}`];let r=this.field.value,i=`${e("◆")} ${n} ${t(`(${this.list.matched()}/${this.list.total()} · ${this.list.pickedCount()} picked)`)}`,s=this.hint.text(),o=`${e("│")} ${r?`${r}_`:t(`Search…${s?` e.g. ${s}`:""}`)}`,{lines:a,below:c}=this.list.window(),u=a.length>0?a.map((p)=>`${e("│")} ${p}`):[`${e("│")} ${t(`No ${this.scope==="series"?"series":"palettes"} match '${r}'`)}`];while(u.length<this.list.maxItems)u.push(e("│"));let l=c>0?`${e("│")} ${t(`↓ ${c} more`)}`:e("│"),d=this.scope==="series"?"":" · ←→ fold",f=this.scope==="series"?"continue":"install",h=this.state==="error"?`${e("└")} ${this.color?`${Jt}${this.error}${Pt}`:this.error}`:`${e("└")} ${t(`↑↓ move${d} · space pick · type to filter · enter ${f} · esc cancel`)}`;return[i,o,...u,l,h]}}var qs=[{tab:"catalog",title:"Catalog",heading:"Discover palettes"},{tab:"installed",title:"Installed",heading:"Installed palettes"},{tab:"markets",title:"Markets",heading:"Manage markets"},{tab:"errors",title:"Errors",heading:"Problems"}],jh=34,rP=72,iP=94,sP=22,Vk=40,Zk=10,Qk=3,oP=600,aP=500,cP=300,Xk=12,uP="\x1B[7;1m",Gh={title:"",lines:[],brief:""};function la(t){let e=t.trim();if(e!==q&&!e.includes("/")&&!e.startsWith("~"))return;try{return $r(e)}catch{return}}function lP(t){return t.charAt(0).toUpperCase()+t.slice(1)}class _h{picked;tab="catalog";fields={catalog:new Gr,installed:new Gr,markets:new Gr,errors:new Gr};cursor={markets:0,errors:0};top={markets:0,errors:0};adds=new Map;removes=new Set;want=new Map;scope={catalog:void 0,installed:void 0};busy=new Map;failed=new Map;peeked=new Map;peekFailed=new Map;staging=new Set;timers=new Map;refreshed=[];inflight=new Set;markets;problems;kept;installed;startup;io;order;color;hub;owns;input;output;maxItems=12;paint;catalog;mine;hint;screen;state="active";phase="browse";offset=0;started=!1;log=[];working="";stopped;beat=0;asking;leaving;goto;repos;searching=!1;searchError;searched;asked=0;help=!1;worn;live;constructor(t){this.markets=t.markets,this.problems=t.problems,this.kept=t.kept,this.installed=new Set(t.installed),this.startup=t.startup,this.io=t.io,this.order=t.order??((n)=>n),this.color=t.color??!0,this.hub=t.hub,this.owns=t.owns??!1,this.input=t.input,this.output=t.output,this.live=t.lookups??!0,this.paint=t.onFocus,this.picked=new Set(t.installed);let e=this.entries();this.catalog=new ua({entries:e,picked:this.picked,color:this.color,maxItems:this.maxItems,onFocus:(n)=>this.focus("catalog",n)}),this.mine=new ua({entries:this.mineOf(e),picked:this.picked,color:this.color,maxItems:this.maxItems,onFocus:(n)=>this.focus("installed",n)}),this.hint=new Au(t.fx??"typewriter",()=>Ch(this.tab==="installed"?this.mine:this.catalog),()=>this.redraw());for(let n of t.due)this.update(n)}run(){let t=[...this.owns?[Ru,Kn,Ni]:[],_r,...Ks()],e=this.owns?[]:[Kn,Ni];return Br({input:this.input,output:this.output,modes:t,assume:e},async(n)=>{let r=new Mi({write:(i)=>n.write(i),view:()=>this.state==="active"?{lines:this.view(),ticking:this.phase==="applying"}:void 0,beat:()=>{this.beat+=1}});this.screen=r,n.onResize(()=>{r.reset(),r.request()}),r.now();try{return await n.loop((i)=>{if(i.kind==="key")this.key(i.key);else if(i.kind==="paste")this.pasted(i.text);else if(i.kind==="mouse")this.mouse(i,r);return this.state==="active"?void 0:this.state},()=>r.soon())}finally{r.stop(),this.screen=void 0,this.hint.stop();for(let i of this.timers.values())clearTimeout(i);this.timers.clear()}})}applied(){return this.started}lines(){return this.log}failure(){return this.stopped}next(){return this.goto}async idle(){await Promise.allSettled([...this.inflight])}result(){let t=new Set(this.entries().map((e)=>e.name));return{picked:new Set([...this.picked].filter((e)=>t.has(e))),adds:[...this.adds.values()],removes:[...this.removes],auto:Object.fromEntries(this.want),refreshed:this.refreshed}}key(t){if(t==="ctrl-c"){this.state="cancel";return}if(this.help){if(t==="?"||t==="esc")this.help=!1;return}if(this.leaving!==void 0){if(t==="esc")this.leaving=void 0;else if(/^[yn]$/i.test(t)){if(t.toLowerCase()==="y")this.begin();else this.goto=this.leaving,this.state="cancel";this.leaving=void 0}return}if(this.asking){if(t==="esc")this.asking=void 0;else if(/^[yn]$/i.test(t))this.answer(t.toLowerCase()==="y");return}if(this.phase!=="browse"){this.steer(t);return}let e=Pu(t,this.maxItems),n=this.list();if(t==="enter")if(n?.foldable())n.flip();else if(this.dirty())this.phase="review",this.offset=0;else this.state="submit";else if((t==="esc"||t==="ctrl-u")&&this.fields[this.tab].value)this.clear();else if(t==="esc")this.state="cancel";else if(t==="?")this.help=!0;else if(e!==void 0)this.move(e);else if(t==="up"||t==="down")this.move(t==="up"?-1:1);else if(t==="left"||t==="right")this.side(t==="right");else if(t==="tab"||t==="shift-tab"){if(this.hub)this.leave(Zw(this.hub,t==="tab"?1:-1))}else if(t==="shift-left"||t==="shift-right")this.switchTab(t==="shift-right"?1:-1);else if(t===" ")this.activate();else if(t==="ctrl-r"){let r=this.tab==="markets"?this.marketRow():void 0;if(r?.kind==="market"&&!this.adds.has(r.market.source))this.update(r.market.source);else if(r?.kind==="find")this.search()}else if(t==="ctrl-s")this.cycle();else if(this.fields[this.tab].key(t))this.typed()}pasted(t){if(this.phase==="browse"&&!this.help&&!this.asking&&this.leaving===void 0)this.fields[this.tab].paste(t),this.typed()}mouse(t,e){if(this.help){if(t.action==="release")this.help=!1;return}let n=e.point(t),r=n?.target,i=this.phase==="browse"&&this.leaving===void 0&&!this.asking;if(t.action==="wheel"){if(!t.sideways&&(i||this.phase!=="browse"))this.wheel(t.wheel);return}if(!r)return;if(t.action==="press"&&t.button==="left"){if(!i)return;if(r.kind==="tab")this.show(r.tab);else if(r.kind==="chip")this.scopeTo(r.source);else if(r.kind==="row")this.pointRow(r.at)}else if(t.action==="release"&&n?.inside){if(r.kind==="key")this.key(r.key);else if(r.kind==="page"){if(this.phase!=="browse")this.scroll(r.step*this.span());else if(i)this.move(r.step*this.maxItems)}else if(r.kind==="hub"){if(i&&this.hub&&r.tab!==this.hub)this.leave(Qw(r.tab))}else if(r.kind==="row"&&i)this.openRow(r,t.count)}}wheel(t){if(this.phase!=="browse"){this.scroll(t);return}let e=this.list();if(e)e.move(t,!1);else this.move(t,!1)}pointRow(t){let e=this.list();if(e){e.point(t);return}this.cursor[this.tab==="markets"?"markets":"errors"]=t,this.watch()}openRow(t,e){let n=this.list();if(n){if(t.part==="box")n.pick();else if(t.part==="fold")n.flip();else if(e===2)n.open()}else if(t.part==="box"||e===2)this.activate()}typed(){let t=this.fields[this.tab].value;if(this.list()?.setFilter(t),this.tab==="markets")this.later("search",oP,()=>this.lookup()),this.watch()}clear(){this.fields[this.tab].value="";let t=this.list();if(t)t.clear();else this.typed()}redraw(){if(this.state==="active")this.screen?.request()}focus(t,e){if(this.tab===t&&this.state!=="submit"&&this.state!=="cancel")this.worn=e,this.paint?.(e)}track(t){this.inflight.add(t);let e=()=>this.inflight.delete(t);return t.then(e,e),t}list(){return this.tab==="catalog"?this.catalog:this.tab==="installed"?this.mine:void 0}active(){return[...this.markets.filter((t)=>!this.removes.has(t.source)),...this.adds.values()]}entries(){let t=this.active().flatMap((i)=>i.entries),e=new Set(t.map((i)=>i.name)),n=new Map,r=this.markets.filter((i)=>this.removes.has(i.source)).flatMap((i)=>i.entries);for(let i of[...this.kept,...r])if(this.installed.has(i.name)&&!e.has(i.name))n.set(i.name,i);return this.order([...t,...n.values()])}mineOf(t){return t.filter((e)=>this.installed.has(e.name))}scoped(t,e){let n=this.scope[e],r=n===void 0?void 0:this.active().find((s)=>s.source===n);if(!r)return this.scope[e]=void 0,t;let i=new Set(r.entries.map((s)=>s.name));return t.filter((s)=>i.has(s.name))}reload(){let t=this.entries();this.catalog.setEntries(this.scoped(t,"catalog")),this.mine.setEntries(this.scoped(this.mineOf(t),"installed"))}chips(t){let e=t==="catalog"?this.entries():this.mineOf(this.entries()),n=this.active().map((r)=>({source:r.source,label:r.id,count:r.entries.filter((i)=>!i.default&&(t==="catalog"||this.installed.has(i.name))).length})).filter((r)=>t==="catalog"||r.count>0||r.source===this.scope[t]);return[{source:void 0,label:"All",count:e.filter((r)=>!r.default).length},...n]}cycle(){let t=this.tab;if(t!=="catalog"&&t!=="installed"||this.active().length<2)return;let e=this.chips(t),n=Math.max(0,e.findIndex((r)=>r.source===this.scope[t]));this.scopeTo(e[(n+1)%e.length]?.source)}scopeTo(t){let e=this.tab;if(e!=="catalog"&&e!=="installed")return;this.scope[e]=t,this.reload(),this.list()?.refocus()}switchTab(t){let e=qs.findIndex((n)=>n.tab===this.tab);this.show(qs[(e+t+qs.length)%qs.length]?.tab??"catalog")}show(t){if(this.tab=t,this.list()?.refocus(),t==="markets")this.lookup(),this.watch()}move(t,e=!0){let n=this.list();if(n){n.move(t,e);return}let r=this.tab==="markets"?"markets":"errors",i=r==="markets"?this.marketRows().map((s)=>s.kind==="rule"):this.problemRows().map(()=>!1);this.cursor[r]=Fh(this.cursor[r],t,i.length,(s)=>i[s]===!0,e),this.watch()}side(t){let e=this.list();if(e){e.fold(t);return}let n=this.tab==="markets"?this.marketRow():void 0;if(n?.kind==="market"&&!ut(n.market.source))if(t===n.market.auto)this.want.delete(n.market.source);else this.want.set(n.market.source,t)}activate(){let t=this.list();if(t){t.pick();return}let e=this.tab==="markets"?this.marketRow():void 0;if(e?.kind==="market")this.toggleMarket(e.market);else if(e?.kind==="add")this.load(e.source,!0);else if(e?.kind==="repo"){let n=this.known(e.source),r=this.marketRows().findIndex((i)=>i.kind==="market"&&i.market===n);if(n&&r>=0)this.cursor.markets=r;else if(!n)this.load(e.source,!0)}else if(e?.kind==="find")this.search()}toggleMarket(t){if(this.adds.has(t.source))this.adds.delete(t.source),this.want.delete(t.source);else if(this.removes.has(t.source))this.removes.delete(t.source);else this.removes.add(t.source);this.reload()}known(t){return[...this.markets,...this.adds.values()].find((e)=>ys(e.source,t))}load(t,e){let n=this.peeked.get(t);if(n){if(e)this.arrive(t,n);return}if(e)this.staging.add(t);if(this.busy.has(t))return;this.failed.delete(t),this.peekFailed.delete(t),this.busy.set(t,"Fetching…"),this.track(this.io.fetch(t)).then((r)=>{if(this.busy.delete(t),this.peeked.set(t,r),this.staging.delete(t))this.arrive(t,r);this.redraw()},(r)=>{if(this.busy.delete(t),this.staging.delete(t))this.failed.set(t,r.message);else this.peekFailed.set(t,r.message);this.redraw()})}arrive(t,e){let n=this.active().find((r)=>r.id===e.id);if(n)this.failed.set(t,`${e.id} already names the market at ${n.shown}`);else if(ut(t)||t===q)this.stage(e,e.auto);else this.asking=e;this.redraw()}later(t,e,n){this.cancel(t),this.timers.set(t,setTimeout(()=>{if(this.timers.delete(t),this.state!=="submit"&&this.state!=="cancel")n()},e))}cancel(t){clearTimeout(this.timers.get(t)),this.timers.delete(t)}wants(t){return!this.known(t)&&!this.peeked.has(t)&&!this.busy.has(t)&&!this.peekFailed.has(t)}watch(){if(!this.live||this.tab!=="markets")return;let t=la(this.fields.markets.value);if(t&&this.wants(t))this.later("typed",aP,()=>this.load(t,!1));else this.cancel("typed");let e=this.marketRow();if(e?.kind==="repo"&&this.wants(e.source)){let n=e.source;this.later("focus",cP,()=>{let r=this.marketRow();if(this.tab==="markets"&&r?.kind==="repo"&&r.source===n)this.load(n,!1)})}else this.cancel("focus")}answer(t){let e=this.asking;if(this.asking=void 0,e)this.stage(e,t)}stage(t,e){if(this.adds.set(t.source,t),e===t.auto)this.want.delete(t.source);else this.want.set(t.source,e);this.reload(),this.cursor.markets=Math.max(0,this.marketRows().findIndex((n)=>n.kind==="market"&&n.market.source===t.source))}update(t){if(this.busy.has(t))return;this.failed.delete(t),this.busy.set(t,"Updating…"),this.track(this.io.refresh(t)).then(({market:e,refreshed:n})=>{this.busy.delete(t),this.markets=this.markets.map((r)=>r.source===t?e:r),this.problems=this.problems.filter((r)=>r.source!==t),this.refreshed.push(n),this.reload(),this.redraw()},(e)=>{this.busy.delete(t),this.failed.set(t,`Update failed: ${e.message}`),this.redraw()})}wanted(){let t=this.fields.markets.value.trim();return t&&!la(t)?t:""}lookup(){if(this.live&&this.searched!==this.wanted())this.search()}search(){let t=this.wanted(),e=++this.asked;this.searched=t,this.searching=!0,this.searchError=void 0,this.track(this.io.search(t||void 0)).then((n)=>{if(e===this.asked)this.searching=!1,this.repos=n,this.watch(),this.redraw()},(n)=>{if(e===this.asked)this.searching=!1,this.searchError=n.message,this.redraw()})}marketRows(){let t=this.fields.markets.value.trim().toLowerCase(),e=(...o)=>t===""||o.some((a)=>a.toLowerCase().includes(t)),n=[...this.markets,...this.adds.values()],r=n.filter((o)=>e(o.id,o.shown,o.source)).map((o)=>({kind:"market",market:o})),i=la(this.fields.markets.value);if(i&&!n.some((o)=>ys(o.source,i)))r.push({kind:"add",source:i});let s=(this.repos??[]).map((o)=>({repo:o,source:Rh(o)})).filter(({repo:o,source:a})=>e(a,o.description??""));return r.push({kind:"rule"},...s.length>0?s.map(({repo:o,source:a})=>({kind:"repo",repo:o,source:a})):[{kind:"find"}]),r}marketRow(){let t=this.marketRows();return t[this.at(t,"markets",(e)=>e?.kind==="rule")]}problemList(){let t=new Map([...this.markets,...this.adds.values()].map((e)=>[e.source,e.id]));return[...this.problems.filter((e)=>!(e.update&&e.source&&this.failed.has(e.source))),...[...this.failed].map(([e,n])=>({where:t.get(e)??e,message:n,source:e}))]}problemRows(){let t=this.fields.errors.value.trim().toLowerCase();return this.problemList().filter((e)=>t===""||`${e.where} ${e.message}`.toLowerCase().includes(t))}at(t,e,n=()=>!1){let r=Math.min(this.cursor[e],Math.max(0,t.length-1));if(!n(t[r]))return r;return r>0?r-1:r+1}windowOf(t,e,n,r=()=>!1){let i=this.at(t,e,r);this.cursor[e]=i;let s=(l)=>r(t[l])?1:2,o=(l,d)=>{let f=0;for(let h=l;h<=d;h++)f+=s(h);return f},a=Math.min(this.top[e],i);while(a<i&&o(a,i)>this.maxItems)a+=1;while(a>0&&o(a-1,t.length-1)<=this.maxItems)a-=1;this.top[e]=a;let c=[],u=0;for(let l=a;l<t.length&&u+s(l)<=this.maxItems;l++)c.push(l),u+=s(l);return{lines:c.flatMap((l)=>{let d=n(t[l],l===i,l);return r(t[l])?d:d.map((f)=>Ds(l,"row",f))}),above:a,below:t.length-a-c.length}}dim(t){return this.color?`${P}${t}${de}`:t}bold(t){return this.color?`${at}${t}${de}`:t}warn(t){return this.color?`${Jt}${t}\x1B[39m`:t}lit(t,e,n){if(e&&this.color&&t)return`${Ce(t.cursor)}▌\x1B[39m ${Fa(t.selection,t.foreground)} ${n} ${Pt}`;return`${e?"▌ ":" "} ${n}`}status(t){return this.adds.has(t.source)?"Will add":this.removes.has(t.source)?"Will remove":this.busy.get(t.source)??(this.failed.has(t.source)||t.status.startsWith("update failed")?"Update failed":"")}note(t){return` ${this.dim(t)}`}peeking(t){let e=this.peeked.get(t);return e?xt(e.entries.filter((n)=>!n.default).length):""}marketLine(t,e,n){let r=(s)=>Ds(n,"box",`${s} `);if(t.kind==="rule")return[` ${this.dim(`── On GitHub${this.searching?" · searching…":""} ──────────`)}`];if(t.kind==="market"){let s=t.market,o=this.status(s),a=e?this.bold(s.id):s.id,c=s.entries.filter((l)=>!l.default),u=!ut(s.source)&&(this.want.get(s.source)??s.auto)?` ${this.dim("↻ auto-update")}`:"";return[this.lit(s.entries.find((l)=>!l.default),e,`${r(this.removes.has(s.source)?"○":"●")}${a}${u}${o?` ${this.dim(o)}`:""}`),this.note([s.source===q?"The ttheme catalog":ut(s.source)?s.shown:s.source,xt(c.length),`${c.filter((l)=>this.installed.has(l.name)).length} installed`,s.status].join(" · "))]}if(t.kind==="add"){let s=this.busy.get(t.source),o=this.failed.get(t.source)??this.peekFailed.get(t.source),a=this.peeked.get(t.source);return[this.lit(void 0,e,`${r("+")}Add ${st(t.source)}${s?` ${this.dim(s)}`:""}`),o?` ${this.warn(o)}`:this.note(a?`${a.id} · ${this.peeking(t.source)}`:this.live?"Fetching its index…":"space fetches its index")]}if(t.kind==="find"){let s=this.fields.markets.value.trim(),o=s&&!la(s),a=!this.searching&&!this.searchError&&this.repos===void 0,c=this.searching?"Searching GitHub…":this.searchError?"GitHub search failed":a?o?`Find "${s}" on GitHub`:"Find markets on GitHub":o?`No market on GitHub matches "${s}"`:"No market on GitHub yet";return[this.lit(void 0,e,`${r("⌕")}${c}`),this.note(this.searchError??(this.searching?"":a?"space searches GitHub":"space searches again"))]}let i=this.busy.get(t.source);return[this.lit(void 0,e,`${r(this.known(t.source)?"●":"○")}${t.source} ${this.dim(`★${t.repo.stargazers_count}`)}${i?` ${this.dim(i)}`:""}`),this.note([this.peeking(t.source),t.repo.description??""].filter(Boolean).join(" · "))]}problemLine(t,e){return[this.lit(void 0,e,`${this.warn("✗")} ${t.where}`),this.note(t.message)]}body(){let t=this.list();if(t){let n=this.fields[this.tab].value;return{...t.window(),empty:n?`No palettes match '${n}'`:this.tab==="installed"?"Nothing installed yet":"No palettes"}}if(this.tab==="markets")return{...this.windowOf(this.marketRows(),"markets",(n,r,i)=>this.marketLine(n,r,i),(n)=>n?.kind==="rule"),empty:""};let e=this.fields.errors.value;return{...this.windowOf(this.problemRows(),"errors",(n,r)=>this.problemLine(n,r)),empty:e?`No problems match '${e}'`:"No problems"}}changes(){return this.adds.size+this.removes.size+this.want.size}dirty(){let{picked:t}=this.result();return this.changes()>0||t.size!==this.installed.size||[...t].some((e)=>!this.installed.has(e))}leave(t){if(this.dirty()){this.leaving=t;return}this.goto=t,this.state="cancel"}steer(t){if(this.phase==="review"){if(t==="enter")this.begin();else if(t==="esc")this.phase="browse"}else if(this.phase==="done"&&(t==="enter"||t==="esc"))this.state="submit";let e=t==="up"?-1:t==="down"?1:Pu(t,this.span());if(e!==void 0)this.scroll(e)}scroll(t){this.offset=Number.isFinite(t)?Math.max(0,this.offset+t):t>0?Number.MAX_SAFE_INTEGER:0,this.redraw()}span(){return Math.max(Qk,this.rows()-(this.hub?1:0)-4)}begin(){this.phase="applying",this.started=!0,this.offset=0,this.log=[],this.working="";let t={say:(e)=>{this.log.push(...e.split(`
665
+ `)),this.redraw()},status:(e)=>{this.working=e,this.redraw()}};this.track(this.io.apply(this.result(),t)).then(()=>this.ended(),(e)=>this.ended(e))}ended(t){this.working="",this.stopped=t,this.phase="done",this.offset=0,this.redraw()}pending(){let t=this.entries().filter((e)=>!e.default);return{names:t.filter((e)=>this.picked.has(e.name)&&!this.installed.has(e.name)),dropped:t.filter((e)=>this.installed.has(e.name)&&!this.picked.has(e.name))}}marketChanges(){let t=[];for(let e of this.adds.values()){let n=e.source!==q&&(this.want.get(e.source)??e.auto)?"updates on its own":"";t.push(`+ ${e.id} ${this.dim([e.source===q?"The ttheme catalog":e.shown,xt(e.entries.filter((r)=>!r.default).length),n].filter(Boolean).join(" · "))}`)}for(let e of this.removes){let n=this.markets.find((i)=>i.source===e),r=(n?.entries??[]).filter((i)=>!i.default&&this.installed.has(i.name)&&this.picked.has(i.name));t.push(`- ${n?.id??e} ${this.dim([n?.shown??st(e),r.length>0?`its ${xt(r.length)} installed keep working`:""].filter(Boolean).join(" · "))}`)}for(let[e,n]of this.want){let r=this.markets.find((i)=>i.source===e);if(r&&!this.removes.has(e))t.push(`↻ ${r.id} ${this.dim(n?"updates on its own from now":"stops updating on its own")}`)}return t}reviewLines(){let t=this.marketChanges(),{names:e,dropped:n}=this.pending(),r=Math.max(0,...[...e,...n].map((o)=>o.name.length)),i=(o,a)=>` ${o} ${a.name.padEnd(r)} ${this.dim(ct(a.name)?a.catalog??"":a.group)}`,s=[e.length>0?`${e.length} to install`:"",n.length>0?`${n.length} to remove`:""].filter(Boolean);return[...t.length>0?[` ${this.bold("Markets")} ${this.dim(`(${t.length})`)}`,...t.map((o)=>` ${o}`),""]:[],...s.length>0?[` ${this.bold("Palettes")} ${this.dim(`(${s.join(" · ")})`)}`,...e.map((o)=>i("+",o)),...n.map((o)=>i("-",o))]:[]]}summary(){let{names:t,dropped:e}=this.pending(),n=this.adds.size;return[n>0?`${n} market${n===1?"":"s"} added`:"",this.removes.size>0?`${this.removes.size} removed`:"",t.length>0?`${t.length} installed`:"",e.length>0?`${e.length} removed`:""].filter(Boolean).join(" · ")}progressLines(){let t=this.log.map((e)=>` ${e}`);if(this.phase==="applying"){let e=Sn[this.beat%Sn.length];t.push(` ${this.dim(`${e} ${this.working||"Working…"}`)}`)}else if(this.stopped)t.push("",...kt(this.stopped.message,Math.max(20,this.columns()-6)).map((e,n)=>` ${n===0?this.warn("✗"):" "} ${e}`));return t}frame(t,e){let n=t-1,r=this.phase==="review",i=r?this.reviewLines():this.progressLines(),s=this.phase==="review"?`${this.bold("Review changes")}`:this.phase==="applying"?this.bold("Applying changes"):this.stopped?`${this.warn("✗")} ${this.bold("Stopped")}`:`${this.bold("✓ Applied")} ${this.dim(this.summary()?`(${this.summary()})`:"")}`,o=this.span(),a=Math.max(0,i.length-o),c=this.phase==="applying"?a:Math.min(this.offset,a);this.offset=c;let u=i.slice(c,c+o),l=i.length-c-u.length,d=[c>0?` ${this.more(-1,`↑ ${c} more`)}`:"",...u];while(d.length<o+1)d.push("");d.push(l>0?` ${this.more(1,`↓ ${l} more`)}`:"");let f=a>0?[["↑↓","scroll"]]:[],h=r?{badge:"BROWSE (APPLY)",keys:[...f,["enter","apply"]],right:["esc","back"]}:this.phase==="applying"?{badge:"BROWSE (APPLY)",note:"Keys wait until it ends",keys:[]}:{badge:"BROWSE (APPLY)",keys:f,right:["enter","close"]};return[...this.hub?[ot(tf(this.hub,this.color),n,!1)]:[],ot(` ${s}`,n,!1),...d.map((p)=>ot(p,n,!1)),` ${this.keyBar(h,n-1)}`].slice(0,e).join(`
666
+ `)}keyBar(t,e){let n=this.color&&this.worn?Ce(this.worn.cursor):"",r=this.color?`\x1B[7;1m${n} ${t.badge} ${Pt} `:`[${t.badge}] `,i=([c,u])=>dn(c.split(" ")[0]??"",`${this.bold(c)} ${this.dim(u)}`),{note:s,keys:o,right:a}=t;for(;;){let c=`${r}${[t.lead??"",s?this.dim(s):"",...o.map(i)].filter(Boolean).join(" ")}`,u=a?i(a):"";if(Q(c)+(a?3+Q(u):0)<=e)return a?jt(c,u,e):ot(c,e,!1);if(s)s=void 0;else if(o.length>2||!a&&o.length>1){let l=o.length-2;o=o.filter((d,f)=>f!==l)}else if(a)a=void 0;else return ot(c,e,!1)}}more(t,e){return this.dim(se({kind:"page",step:t},e))}counts(){let t=[...this.busy.values()].includes("Updating…")?"Updating… · ":"",e=this.list();if(e)return`${t}${e.matched()}/${e.total()} · ${e.pickedCount()} picked`;if(this.tab==="markets"){let n=this.markets.length+this.adds.size,r=this.marketRows().filter((s)=>s.kind==="market").length,i=this.changes();return`${t}${r}/${n}${i>0?` · ${i} to apply`:""}`}return`${this.problemRows().length}/${this.problemList().length}`}searchText(){let t=this.fields[this.tab].value;if(t)return`${t}_`;if(this.tab==="markets")return this.dim("Search… or add one: owner/repo");let e=this.tab==="errors"?"":this.hint.text();return this.dim(`Search…${e?` e.g. ${e}`:""}`)}tabBar(){return qs.map(({tab:t,title:e})=>{let n=t==="errors"?this.problemList().length:0,r=n>0?`${e} ${n}`:e,i={kind:"tab",tab:t};if(!this.color)return se(i,t===this.tab?`[${r}]`:` ${r} `);return`${t===this.tab?uP:P}${se(i,` ${r} `)}${Pt}`}).join(" ")}heading(){let t=qs.find((e)=>e.tab===this.tab)?.heading??"";return`${this.bold(t)} ${this.dim(`(${this.counts()})`)}`}searchBox(t){let e=(r,i)=>this.dim(`${r}${"─".repeat(t-2)}${i}`),n=this.dim("│");return[e("╭","╮"),`${n} ${ot(`${this.dim("⌕")} ${this.searchText()}`,t-4)} ${n}`,e("╰","╯")]}strip(t){let e=this.tab;if(e!=="catalog"&&e!=="installed"||this.active().length<2)return;let n=this.chips(e),r=Math.max(0,n.findIndex((g)=>g.source===this.scope[e])),i=n.map((g,b)=>b===r&&!this.color?`[${g.label} ${g.count}]`:`${g.label} ${g.count}`),s=" · ",o=(g)=>g>0?`${s}+${g} more`.length:0,a=(g)=>{let b=g>0?2:0,y=0;for(let S=g;S<i.length;S++){let E=b+(y>0?s.length:0)+i[S].length;if(E+o(i.length-S-1)>t)break;b=E,y+=1}return y},c=0;while(c<r&&c+a(c)<=r)c+=1;let u=Math.max(1,a(c)),l=i.slice(c,c+u),d=i.length-c-u,f=l.map((g,b)=>{let y=se({kind:"chip",source:n[c+b]?.source},g);if(c+b===r)return this.color?`${at}${Ca}${y}${Pt}`:y;return this.dim(y)}),h=`${c>0?`${this.dim(dn("ctrl+s","…"))} `:""}${f.join(this.dim(s))}${d>0?this.dim(`${s}${dn("ctrl+s",`+${d} more`)}`):""}`,p=(c>0?2:0)+l.join(s).length+o(d),$="ctrl+s market";return p+2+$.length<=t?`${h} ${this.dim(dn("ctrl+s",$))}`:h}sourceOf(t){let e=this.active().find((n)=>n.entries.some((r)=>r.name===t.name));if(!e)return"In no market you added";return e.source===q?"The ttheme catalog":e.shown}paletteState(t){let e=this.picked.has(t.name),n=this.installed.has(t.name),r=e&&n?"Installed":e?"Will install":n?"Will remove":"Not installed";return this.startup===t.name?`${r} · Default`:r}paletteDetail(t,e){if(!t||t.kind==="rule")return Gh;if(t.kind==="all")return{title:this.bold("Select all"),lines:["space picks every palette shown"],brief:""};if(t.kind==="group"){let u=this.entries().filter((f)=>f.group===t.name&&!f.default),l=this.sourceOf(t.lead),d=`${xt(u.length)} · ${u.filter((f)=>this.installed.has(f.name)).length} installed`;return{title:this.bold(t.name),lines:[...t.native?kt(t.native,e).map((f)=>this.dim(f)):[],...kt(l,e),d],brief:`${l} · ${d}`}}if(t.kind==="catalog"){let u=this.entries().filter((f)=>f.group===t.group&&f.catalog===t.name),l=this.sourceOf(t.lead),d=`${xt(u.length)} · ${u.filter((f)=>this.installed.has(f.name)).length} installed`;return{title:this.bold(t.name),lines:[t.group,...kt(l,e),d],brief:`${t.group} · ${d}`}}let n=t.entry,r=this.sourceOf(n),i=Ao(n),s=`Gate ${he.length-i.length}/${he.length}`,o=n.pictures?.length??0,a=[...o>0?[`${o} picture${o===1?"":"s"}`]:[],...n.base?[`Base ${n.base}`]:[]].join(" · "),c=ct(n.name)?n.catalog?[n.catalog]:[]:[n.group,...n.native?[this.dim(n.native)]:[]];return{title:this.color?`${at}${Ce(n.cursor)}${n.name}${de}\x1B[39m`:n.name,lines:[...kt(r,e),...c,this.paletteState(n),"",i.length===0?`${s} · passes`:s,...i.flatMap((u)=>kt(u,e-2).map((l,d)=>`${d===0?this.warn("✗"):" "} ${l}`)),...a?["",a]:[]],brief:[r,s,...a?[a]:[],this.paletteState(n)].join(" · ")}}marketDetail(t,e){if(!t||t.kind==="rule")return Gh;if(t.kind==="market"){let i=t.market,s=i.source===q?"The ttheme catalog":i.shown,o=i.entries.filter((h)=>!h.default),a=o.filter((h)=>this.installed.has(h.name)).map((h)=>h.name),c=`${xt(o.length)} · ${a.length} installed`,u=ut(i.source)?"Read in place":`Auto-update ${this.want.get(i.source)??i.auto?"on":"off"}`,l=this.busy.get(i.source)??lP(i.status),d=this.failed.get(i.source),f=this.adds.has(i.source)?["Will add"]:this.removes.has(i.source)?[a.length>0?`Will remove — ${a.join(", ")} stay${a.length===1?"s":""} installed`:"Will remove"]:this.want.has(i.source)?[`Auto-update turns ${this.want.get(i.source)?"on":"off"}`]:[];return{title:this.bold(i.id),lines:[...kt(s,e),c,"",ut(i.source)?u:`${u} ${this.dim("←→")}`,...ut(i.source)?[]:[l],...d?kt(d,e).map((h)=>this.warn(h)):[],...f.length>0?["",...f.flatMap((h)=>kt(h,e))]:[]],brief:[s,u,...f,...ut(i.source)?[]:[l]].join(" · ")}}if(t.kind==="add"){let i=this.busy.get(t.source)??this.failed.get(t.source)??this.peekFailed.get(t.source)??(this.peeked.has(t.source)?"space adds it":this.live?"Fetching its index…":"space fetches its index");return{title:this.bold(st(t.source)),lines:["Not added",...this.peekLines(t.source,e),"",...kt(i,e)],brief:[this.peeking(t.source),i].filter(Boolean).join(" · ")}}if(t.kind==="find"){let i=this.fields.markets.value.trim(),s=this.searchError??(this.searching?"Searching…":this.repos?`${this.repos.length} found · space searches again`:"space searches GitHub");return{title:this.bold("GitHub"),lines:[...kt(`Repositories with the ${$s} topic`,e),...i&&!la(i)?[`Matching "${i}"`]:[],"",...kt(s,e)],brief:s}}let r=this.known(t.source)?"Added":this.busy.get(t.source)??this.failed.get(t.source)??this.peekFailed.get(t.source)??"space adds it";return{title:this.bold(t.source),lines:[`★ ${t.repo.stargazers_count}`,...kt(t.repo.description??"",e),...this.peekLines(t.source,e),"",...kt(r,e)],brief:[this.peeking(t.source),r].filter(Boolean).join(" · ")}}peekLines(t,e){let n=this.peeked.get(t);if(!n)return[];let r=n.entries.filter((s)=>!s.default),i=`${r.slice(0,Xk).map((s)=>dr(s.name)).join(", ")}${r.length>Xk?", …":""}`;return["",n.id,xt(r.length),...kt(i,e).map((s)=>this.dim(s))]}detail(t){let e=this.list();if(e)return this.paletteDetail(e.focusedRow(),t);if(this.tab==="markets")return this.marketDetail(this.marketRow(),t);let n=this.problemRows(),r=n[Math.min(this.cursor.errors,n.length-1)];return r?{title:this.bold(r.where),lines:kt(r.message,t),brief:r.message}:Gh}footer(){if(this.help)return{badge:"HELP",keys:[],right:["? esc","close"]};if(this.leaving!==void 0)return{badge:"BROWSE",lead:"Apply your changes before you leave?",keys:[["y","apply"],["n","discard"]],right:["esc","stay"]};if(this.asking)return{badge:"BROWSE",lead:`Update ${this.asking.id} on its own when its author changes it?`,keys:[["y","yes"],["n","no"]],right:["esc","back"]};let t=this.fields[this.tab].value,e=["enter",this.dirty()?"apply":"close"],n=[["⇧←→","tabs"],...t?[["bksp","edit"]]:[],["?","keys"]];return{badge:t?"BROWSE (FILTER)":"BROWSE",keys:[...this.rowKeys(e),...n],right:t?["esc","clear filter"]:["esc","cancel"]}}rowKeys(t){let e=this.list();if(e){let r=e.focusedRow();if(!r)return[t];if(e.foldable())return[(r.kind==="group"||r.kind==="catalog")&&r.expanded?["←","close"]:["→","open"],["space","pick"]];return[["space","pick"],t]}if(this.tab==="errors")return[t];let n=this.marketRow();if(n?.kind==="market"){let r=n.market;return[["space",this.adds.has(r.source)||this.removes.has(r.source)?"undo":"remove"],...ut(r.source)?[]:[["←→","auto-update"]],...this.adds.has(r.source)?[]:[["ctrl+r","update"]],t]}if(n?.kind==="find")return[["space","search"],t];if(n?.kind==="add"||n?.kind==="repo"&&!this.known(n.source))return[["space","add"],t];return[t]}columns(){return(this.output??process.stdout).columns??100}rows(){return(this.output??process.stdout).rows??24}fitItems(t){let e=Math.max(Qk,this.rows()-t);this.maxItems=e,this.catalog.maxItems=e,this.mine.maxItems=e}view(){let t=this.draw().split(`
667
+ `);return Array.from({length:this.rows()},(e,n)=>t[n]??"")}draw(){let t=this.columns(),e=this.rows();if(t<Vk||e<Zk)return`Needs ${Vk}×${Zk} — now ${t}×${e}
668
+ ${this.dim("esc cancels")}`;if(this.phase!=="browse")return this.frame(t,e);let n=t>=iP,r=t-1,i=n?Math.min(t-jh-4,rP):r,s=this.strip(r-1),o=[` ${this.tabBar()}`,...e>=sP?[` ${this.heading()}`,...this.searchBox(t-3).map((g)=>` ${g}`)]:[jt(` ${this.dim("⌕")} ${this.searchText()}`,this.dim(this.counts()),r)],...s?[` ${s}`]:[]];this.fitItems(o.length+3+(n?0:1)+(this.hub?1:0));let{lines:a,above:c,below:u,empty:l}=this.body(),d=a.length>0?a.map((g)=>` ${g}`):[` ${this.dim(l)}`];while(d.length<this.maxItems)d.push("");let f=[c>0?` ${this.more(-1,`↑ ${c} more`)}`:"",...d,u>0?` ${this.more(1,`↓ ${u} more`)}`:""],h=this.detail(n?jh:i-2),p=n?f.map((g,b)=>`${ot(g,i)} ${this.dim("│")} ${ot(b===0?h.title:h.lines[b-1]??"",jh,!1)}`):[...f.map((g)=>ot(g,i,!1)),ot(` ${this.dim(h.brief)}`,i,!1)],$=[...this.hub?[ot(tf(this.hub,this.color),r,!1)]:[],...o.map((g)=>ot(g,r,!1)),...p,` ${this.keyBar(this.footer(),r-1)}`];return(this.help?this.helpBox($,t,e,$.length-p.length-1):$).join(`
669
+ `)}helpRows(){return[["Move","↑↓ home end pgup pgdn"],["Series","←→ · enter on a series"],["Pick","space · a palette, a series, all"],["Filter","Any text · bksp · ctrl-u clears"],["","Each tab keeps its own"],["Tabs","⇧←→ Catalog, Installed, Markets, Errors"],...this.active().length>=2?[["Market","ctrl+s · one market, then all"]]:[],["Markets","space adds or removes · ←→ auto-update"],["","ctrl+r updates it, or searches again"],["Apply","enter reviews and applies · esc cancels"],...this.hub?[["Screens","tab · shift+tab"]]:[],["Close","? esc"]]}helpBox(t,e,n,r){let i=this.helpRows(),s=Math.min(e-2,58),o=Math.floor((e-s)/2),a=`│${" ".repeat(s-2)}│`,c=[`╭─ Help ${"─".repeat(s-9)}╮`,a,...i.map(([l,d])=>`│${ot(` ${this.bold(l.padEnd(10))}${d}`,s-4)} │`),a,`╰${"─".repeat(s-2)}╯`],u=Math.max(0,Math.min(Math.max(r,Math.floor((n-c.length)/2)),n-1-c.length));return t.map((l,d)=>{let f=c[d-u];return f===void 0?l:`${kp(l,o)}${f}`})}}import{existsSync as CF}from"node:fs";import{existsSync as Ia,mkdirSync as IF,readFileSync as Nm}from"node:fs";import{dirname as xF}from"node:path";class Ie extends Error{}import{closeSync as ZH,mkdtempSync as QH,openSync as XH,readSync as tA,rmSync as Qy}from"node:fs";import{homedir as eA,tmpdir as nA}from"node:os";import{join as Xy}from"node:path";import{readFileSync as dP}from"node:fs";var gt={pitch:25,cols:22,rows:9,height:13},Ti={cols:25,rows:21},ue={cols:10,rows:3,pitch:12,top:4},ce=ue.top+ue.rows+1,fP=1073741824,qh=2147483648,hP=-1073741826,mP=1600,pP=56,gP=4,ty=20,bP=50,ey=[["space","unfolds a set of ×N"],["o","opens the post page in a browser"],["c","switches between cutouts and every post"],["a","opens the advanced filters"],["1-9","turn a tag of the tags row on or off"],["ctrl+v","tries on a picture from the clipboard — or drop one on the window"]];function Yh(t){return Math.max(0,Math.floor((t-1)/ue.pitch))}function zn(t,e){let n=e-ce-2;return{perRow:Math.max(1,Math.floor((t-1)/gt.pitch)),rowsVis:Math.max(1,Math.floor(n/gt.height)),height:n}}function ju(t,e=!0){if(e)return`\x1B_Ga=t,t=f,f=100,i=${t.id},q=2;${Buffer.from(t.path).toString("base64")}\x1B\\`;let n;try{n=dP(t.path).toString("base64")}catch{return}let r=n.match(/.{1,4096}/g)??[""];return r.map((i,s)=>{let o=s<r.length-1?1:0;return s===0?`\x1B_Ga=t,f=100,i=${t.id},m=${o},q=2;${i}\x1B\\`:`\x1B_Gm=${o},q=2;${i}\x1B\\`}).join("")}function uy(t,e){let n=t.crop===void 0?"":`,x=0,y=${t.crop*e.h},w=${t.cols*e.w},h=${t.rows*e.h}`;return`\x1B[${t.row+1};${t.col+1}H\x1B_Ga=p,i=${t.id},p=${t.id}${n},c=${t.cols},r=${t.rows},C=1,z=${t.z},q=2\x1B\\`}function Jh(t){return`\x1B_Ga=d,d=i,i=${t},p=${t},q=2\x1B\\`}function pa(t){return`\x1B_Ga=d,d=I,i=${t},q=2\x1B\\`}function Ys(t){return`\x1B[38;2;${nt(t).join(";")}m`}function Lu(t){return`\x1B[48;2;${nt(t).join(";")}m`}var Wh=!1;function Gu(t){return Wh=!0,t.beat}function Js(t){return Sn[Gu(t)%Sn.length]}function dt(t){return Q(t)}function Uh(t,e){if(Q(t)<=e)return t;let n="";for(let r of t){if(Q(n+r)>e)break;n+=r}return n}function Wr(t){return`\x1B[${30+t}m`}function Pi(t,e,n,r){return n?[[`${io} `,r,void 0,{kind:"link",url:n}],[t,e,n]]:[[t,e]]}function Bh(t){let e=Xd(t);return e?{kind:"key",key:e}:void 0}function Kh(t){return t.reduce((e,[n])=>e+dt(n),0)}function wP(t,e){let n=[],r=e;for(let[i,s,o,a]of t){let c=dt(i);if(c<=r){n.push([i,s,o,a]),r-=c;continue}n.push([`${Uh(i,r)}…`,s,o,a]);break}return n}class Cu{parts=[];cols;constructor(t){this.cols=t}put(t,e,n="",r,i){return this.parts.push({col:t,text:e,sgr:n,...r?{link:r}:{},...i?{spot:i}:{}}),t+dt(e)}run(t,e){let n=t;for(let[r,i,s,o]of e)n=this.put(n,r,i,s,o);return n}mark(t,e,n){this.parts.push({col:t,text:" ".repeat(Math.max(0,e)),sgr:"",spot:n,hidden:!0})}zones(t){return this.parts.flatMap(({col:e,text:n,link:r,spot:i})=>{let s=i??(r?{kind:"link",url:r}:void 0),o=e>=0&&e<this.cols?dt(Uh(n,this.cols-e)):0;return s&&o>0?[{row:t,col:e,width:o,height:1,target:s}]:[]})}right(t,e){this.run(t-e.reduce((n,[r])=>n+dt(r),0),e)}center(t,e){this.run(Math.floor((t-e.reduce((n,[r])=>n+dt(r),0))/2),e)}render(){let t="";for(let{col:e,text:n,sgr:r,link:i,hidden:s}of this.parts){if(s||e>=this.cols||e<0)continue;let o=Uh(n,this.cols-e);t+=`\x1B[${e+1}G${r}${La(o,i)}${r?Pt:""}`}return t}}function $P(t){return t.replace(/_\([^)]*\)?$/,"")}function ly(t){return[`${t.reduced?"↓":""}${t.width}×${t.height}`,Math.max(t.width,t.height)<mP?Jt:P]}function ha(t,e,n,r){let i=[...r.keys??[]],s=r.lead,o=r.right,a=()=>{let l=[...s?[Kh(s)]:[],...i.map(([f,h])=>dt(f)+1+dt(h))];return(r.badge?dt(r.badge)+4:0)+l.reduce((f,h)=>f+h,0)+3*Math.max(0,l.length-1)+(o?3+dt(o[0])+1+dt(o[1]):0)};while(a()>e)if(i.length>2)i.splice(-2,1);else if(o)o=void 0;else if(i.length>1)i.splice(-2,1);else break;if(s&&a()>e)s=wP(s,Math.max(0,Kh(s)-(a()-e)-1));let c=0;if(r.badge)c=t.put(0,` ${r.badge} `,`\x1B[7;1m${n}`)+2;if([...s?[s]:[],...i.map(([l,d])=>[[l,at,void 0,Bh(l)],[` ${d}`,P,void 0,Bh(l)]])].forEach((l,d)=>{c=t.run(c+(d?3:0),l)}),o){let l=Bh(o[0].split(" ")[0]??"");t.right(e,[[o[0],at,void 0,l],[` ${o[1]}`,P,void 0,l]])}}function kP(t,e){if(t==="d")return P;if(t==="b")return at;if(t==="s")return Lu(e.colors.selection);if(t==="c")return Lu(e.colors.cursor);let n=/^([BK]?)(\d+)$/.exec(t);if(!n)return"";let r=Number(n[2]),i=(s)=>r<8?s+r:s+52+r;if(n[1]==="K")return`\x1B[30;${i(40)}m`;return`\x1B[${n[1]==="B"?"1;":""}${i(30)}m`}function yP(t,e,n,r,i){let s=te.indexOf(hi(r.scene)),o=te.flatMap((c,u)=>[...u?[[" ",""]]:[],[c.name,u===s?at+i:P,void 0,{kind:"scene",scene:u}]]),a=o.reduce((c,[u])=>c+dt(u),0)<=n;t?.run(e,a?o:[[hi(r.scene).name,at+i],[` ${s+1}/${te.length}`,P]])}function vP(t,e,n,r,i,s,o){let{ansi:a,cursor:c}=s.colors;yP(t[e-2],n,r,s,o);let u=r<M0?3:4;if(r>=56)u=Math.min(7,Math.floor((r+1)/8)-1);let l=n;for(let f=0;f<8;f++)l=(t[e]?.put(l,"▀".repeat(u),Ys(a[f]??c)+Lu(a[f+8]??c))??l)+1;let d=e+2;for(let f of hi(s.scene).lines){let h=jc(f,r);if(!h)continue;if(d>i)return;t[d]?.run(n,h.map(([p,$])=>[p,kP($,s)])),d++}}function SP(t,e,n){let r=[[]];for(let o of t){let a=r[r.length-1];if(a.length===0||dt([...a,o].join(" "))<=e)a.push(o);else if(r.length<n)r.push([o]);else break}let i=r.reduce((o,a)=>o+a.length,0),s=r[r.length-1];while(i<t.length&&s.length>0&&dt([...s,`+${t.length-i}`].join(" "))>e)s.pop(),i--;if(i<t.length)s.push(`+${t.length-i}`);return r.filter((o)=>o.length>0).map((o)=>o.join(" "))}function ny(t){return t.replace(/^https?:\/\/(?:www\.)?/,"")}function EP(t,e,n,r,i){let s=r.info,o=s?.artists??[],a=Wr(r.tiles[r.focus]?.siteAnsi??r.siteAnsi);[["Post",s?.page?Pi(ny(s.page),"",s.page,a):[["—",P]]],["Source",s?.source?Pi(ny(s.source),"",s.link,i):[["—",P]]],["Artist",[o.length>0?[o.join(" "),""]:["—",P]]]].forEach(([u,l],d)=>{t[e+d]?.put(n,u,P),t[e+d]?.run(n+12,l)})}function MP(t,e,n,r,i,s){let o=s.info,a=s.tiles[s.focus];if(!o||!a)return;let c=s.shown?.id===a.key?s.shown:void 0,u=n+12,l=Math.max(12,r-12),d=[`${a.width}×${a.height}${o.ext?` ${o.ext.toUpperCase()}`:""}`,...c?[$u(c.bytes)]:[]].join(" · "),f=[o.rating??"—",a.score>0?`★${a.score}`:"",o.posted??""].filter(Boolean).join(" · "),h=(g,b)=>g.length>0?SP(g,l,b).map((y)=>[[y,""]]):[[["—",P]]],p=[["Characters",h(o.characters,2)],["Series",h(o.series,1)],["Tags",h(o.tags,3)],["Rating",[[[f,f==="—"?P:""]]]],["File",[[[d,""],...c?[[" ",""]]:[],...c?dy(c):[]]]],["Uploader",[[o.uploader?[o.uploader,""]:["—",P]]]]],$=e;for(let[g,b]of p){if($+b.length-1>i)return;t[$]?.put(n,g,P);for(let y of b)t[$]?.run(u,y),$++}}var OP=["Size","Position","Opacity"],IP=[0,3,6];function xP(t,e){let{tune:n,untuned:r}=t;return e===0?n.size!==r.size:e===1?n.at!==r.at:n.opacity!==r.opacity}function NP(t){return t.toFixed(2)}function RP(t,e,n,r,i,s){let o=i.tuning;if(!o)return;let a=i.tiles[i.focus];t[e-3]?.run(n,[[i.palette,at+s],[" Background",P],...a?[[" · ",P],...Pi(`${a.site} ${a.id}`,P,a.page||void 0,Wr(a.siteAnsi))]:[]]);let c=Math.max(8,r-n-21),u=20,l=Math.max(100,o.fill);for(let[d,f]of OP.entries()){let h=e+IP[d],p=o.field===d,$=p?at:P;if(p)t[h]?.put(n,"▶",s,void 0,{kind:"field",field:d});t[h]?.put(n+2,f,$,void 0,{kind:"field",field:d});let g;if(d===1){for(let b=1;b<=9;b++){let y=b===i.tune.at,S=t[e+2+Math.floor((b-1)/3)],E=n+12+(b-1)%3*3;S?.mark(E-1,3,{kind:"place",at:b}),S?.put(E,y?"■":"·",y?at+s:P)}g=_t[i.tune.at-1]??"center"}else{let b;if(d===0){let{size:y}=i.tune;b=y==="fill"?c-1:Math.floor((y-u)*(c-1)/(l-u+1)),g=y==="fill"?"fill":`${y}%`}else b=Math.floor(Math.round(i.tune.opacity*100)*(c-1)/100),g=NP(i.tune.opacity);b=Math.max(0,Math.min(c-1,b)),t[h]?.run(n+12,[["━".repeat(b),s],["●",at],["─".repeat(c-1-b),P]]),t[h]?.mark(n+12,c,{kind:"track",field:d})}if(t[h]?.right(r-2,[[g,$]]),xP(i,d))t[h]?.put(r-1,"↺",p?at+s:P)}}function TP(t,e,n,r,i,s){t[e]?.put(n,`╭${"─".repeat(i-2)}╮`,s);for(let o=e+1;o<e+r-1;o++)t[o]?.put(n,"│",s),t[o]?.put(n+i-1,"│",s);t[e+r-1]?.put(n,`╰${"─".repeat(i-2)}╯`,s)}function zh(t,e=t.site,n=t.siteAnsi){return[` ${e} `,`\x1B[7;${30+n}m`]}function fa(t){return`${Y[Math.floor(t/cr)]?.name??"local"} ${t%cr}`}function da(t,e,n){let r=Y[Math.floor(e/cr)],i=fa(e),s=t.indexOf(i);if(!r||s===-1)return[[t,n]];return[[t.slice(0,s),n],...Pi(i,n,r.pageUrl(e%cr),Wr(r.ansi)),[t.slice(s+i.length),n]].filter(([a])=>a!=="")}function PP(t,e,n){let r=[{name:"all",moved:!1},...Y].flatMap((s,o)=>{let a=`${s.name}${s.moved?"*":""}`,[c,u]=s.name===n.site?zh(n,a):[` ${a} `,P],l=[c,u,void 0,{kind:"site",tab:o}];return o?[[" ",""],l]:[l]}),i=r.reduce((s,[o])=>s+dt(o),0)<=e;t.run(0,i?r:[zh(n)])}function HP(t,e,n,r){if(n.chips.length===0)return;let i=[["tags ",P]],s=dt("tags "),o=n.chips.length;for(let[a,c]of n.chips.entries()){let u=` ${a+1} ${c.name} `;if(s+dt(u)+1>e-2)break;i.push([u,c.on?`\x1B[7m${r}`:P,void 0,{kind:"chip",index:a}],[" ",""]),s+=dt(u)+1,o--}if(o>0)i.push([`+${o}`,P]);t.run(0,i)}function AP(t,e,n,r,i){t[ce-1]?.put(0,"─".repeat(n-1),P);let s=t[ue.top-1],o=Yh(n),a=r.held.length>o?Math.max(0,o-1):r.held.length;for(let[c,u]of r.held.slice(0,a).entries()){let l=c*ue.pitch,d=u.up?at:"";if(s.run(l+1,u.page?Pi(String(u.id),d,u.page,Wr(u.ansi)):[["● ",Wr(u.ansi)],[String(u.id),d]]),u.up)for(let f=0;f<ue.rows;f++)t[ue.top+f]?.put(l,"▌",i);if(u.thumb)e.push({id:fP+c,path:u.thumb,row:ue.top,col:l+1,cols:ue.cols,rows:ue.rows,z:-1})}if(a<r.held.length)s.put(a*ue.pitch+1,`+${r.held.length-a}`,P)}function FP(t,e,n,r){if(n.editing!==void 0){let c=t.run(0,[["⌕ ",r],[n.editing,""],["█",r]]),u=n.suggest?.length?" ↑↓ pick enter searches":" enter searches";t.put(c,n.editing?u:` A tag, a post URL or an id, or drop a picture or ctrl+v — ${n.tag||"esc leaves"}`,P);return}let i=t.run(0,[["⌕ ",r,void 0,{kind:"query"}],[n.tag||"Nothing yet — / searches, ctrl+v pastes a picture",n.tag?"":P,void 0,{kind:"query"}]]),s=ii.filter((c)=>!n.block.includes(c)),o=Y.filter((c)=>!n.enabled.includes(c.name)).map((c)=>c.name),a=[n.preset,...n.solo?["solo"]:[],n.order,...n.rating.join("+")==="safe"?[]:[n.rating.join("+")],...s.length>0?[`allows ${s.join("+")}`]:[],...n.narrow.size>0?[`≥${n.narrow.size}px`]:[],...n.narrow.score>0?[`score≥${n.narrow.score}`]:[],...n.narrow.png?["png"]:[],...n.hide.length+n.hideTags.length>0?[`hides ${[...n.hide,...n.hideTags].join("+")}`]:[],...o.length>0?[`all skips ${o.join("+")}`]:[]];if(t.put(i,` ${a.join(" ")}`,P),n.total>0||!n.searching){let c=[[`${n.tiles.length}/${n.checked}`,""]];if(n.checked<n.total)c.push([` of ${n.total}`,P]);t.right(e,c)}}function dy(t){if(t.cut==="on")return[[`Cut out · ${t.clear}% transparent`,Di]];if(t.cut==="off")return[["Opaque · x cuts out",Jt]];if(t.cut==="failed")return[["Opaque · no cut-out",Jt]];return[t.clear>0?[`${t.clear}% transparent`,Di]:["Opaque",Jt]]}function ry(t){return t.site==="all"?"any site":t.site}function Dh(t,e){if(t.installing!==void 0)return da(`${Js(t)} Installing ${t.palette} ← ${fa(t.installing)}`,t.installing,Jt);if(t.hint)return[[t.hint,Di]];if(t.error)return[[t.error,Jt]];if(t.waiting!==void 0)return[[`${t.slow??t.site} asked to slow down · ${t.waiting}s`,Jt]];if(t.fetching){let{id:n,got:r,size:i}=t.fetching;return da(`${Js(t)} Fetching ${fa(n)} · ${ku(r,i)}`,n,Jt)}if(t.cutting!==void 0)return da(`${Js(t)} Cutting out ${fa(t.cutting)}`,t.cutting,Jt);if(t.preparing!==void 0)return da(`${Js(t)} Preparing ${fa(t.preparing)}`,t.preparing,Jt);if(e)return[e];if(t.saved)return da(t.saved.text,t.saved.key,Di);if(t.note)return[[t.note,P]];return}function fy(t){if(t.ranking)return"Ranking previews by palette colors";if(t.stage==="check")return t.preset==="cutouts"?"Checking PNG headers":"Loading previews";return"Fetching posts"}function hy(t,e){return t.ranking?`${e}${t.ranking.done}/${t.ranking.total}`:""}function CP(t,e,n,r,i){let{background:s,cursor:o,selection:a}=r.colors,{ranking:c}=r,u=c?Math.round(n*c.done/c.total):-1,l=Math.max(6,Math.round(n*0.22)),d=Gu(r)%(ty*2)/ty,f=Math.round((n-l)*(0.5-0.5*Math.cos(Math.PI*(d<1?d:2-d)))),h=Gt(s,o,i),p=Gt(s,Gt(a,s,0.15),i),$=Array.from({length:n},(b,y)=>{let S=(u>=0?y<u:y>=f&&y<f+l)?h:p;return y===0||y===n-1?Gt(S,s,0.55):S}),g=0;for(let b=1;b<=n;b++)if(b===n||$[b]!==$[g])t?.put(e+g," ".repeat(b-g),Lu($[g])),g=b}function LP(t,e,n,r,i){let{background:s,foreground:o}=i.colors,a=i.loaderFrom===void 0?0:Math.min(1,(Gu(i)-i.loaderFrom)/gP),c=e+(n>=5?Math.floor((n-5)/2):0);t[c]?.center(r,[[fy(i),at+Ys(Gt(s,o,a))],[hy(i," "),Ys(Gt(s,Gt(o,s,0.45),a))]]);let u=Math.min(pP,r-8);if(CP(t[c+(n>=3?2:1)],Math.floor((r-u)/2),u,i,a),n<5)return;t[c+4]?.center(r,i.sites.flatMap(({name:l,arrived:d},f)=>[...f?[[" · ",Ys(Gt(s,o,0.25*a))]]:[],[l,Ys(Gt(s,d?Gt(o,s,0.2):o,d?a:0.32*a))]]))}function jP(t,e,n,r,i,s){if(i<=r)return;let o=Math.max(1,Math.round(r*r/i)),a=Math.max(0,Math.min(r-o,Math.round(n.scroll*r/i)));for(let c=0;c<r;c++){let u=c>=a&&c<a+o;t[ce+c]?.put(e-1,u?"┃":"│",u?s:P)}}function GP(t,e,n){if(e)return[`${Js(t)} ${fy(t)}${hy(t," · ")}`,P];let r=n.filter((s)=>!s.missing),i=r.filter((s)=>s.thumb).length;return i<r.length?[`${Js(t)} Loading thumbnails · ${i}/${r.length}`,P]:void 0}function _P(t,e,n,r,i,s,o){let{perRow:a,rowsVis:c,height:u}=zn(r,i);FP(t[0],r,s,o),PP(t[1],r,s),HP(t[2],r,s,o),AP(t,e,r,s,o);let l=t.map((F,j)=>j>=ce&&j<ce+u?F:void 0),d=Math.floor(s.scroll/gt.height),f=Math.floor((s.scroll+u-1)/gt.height),h=[];for(let F=d;F<=f;F++){let j=ce+F*gt.height-s.scroll;for(let B=0;B<a;B++){let X=F*a+B,U=B*gt.pitch,Z=s.tiles[X];if(!Z)continue;h.push(Z);let W=Math.max(j,ce),$t=Math.min(j+gt.height,ce+u);if($t>W)n.push({row:W,col:U,width:gt.pitch-1,height:$t-W,target:{kind:"tile",index:X}});let tt=X===s.focus;if(tt)TP(l,j,U,gt.height,gt.pitch-1,o);let Jn=j+1,Je=Math.max(Jn,ce),Ve=Math.min(Jn+gt.rows,ce+u);if(Z.thumb&&Ve>Je)e.push({id:Z.key,path:Z.thumb,row:Je,col:U+1,cols:gt.cols,rows:Ve-Je,...Ve-Je<gt.rows?{crop:Je-Jn}:{},z:-1});let Ze=[...s.installed.includes(Z.key)?[["✓ ",Di]]:[],...Z.page||s.site!=="all"?Pi(String(Z.id),tt?at:"",Z.page||void 0,Wr(Z.siteAnsi)):[["● ",Wr(Z.siteAnsi)],[String(Z.id),tt?at:""]],[" ",""],ly(Z)],Ta=gt.cols-(Z.mates.length>0?1:0);if(l[j+10]?.run(U+1,Kh(Ze)>Ta?Ze.map(([gl,bl,wl])=>[gl.replace(/^(\S) $/,"$1"),bl,wl]):Ze),Z.mates.length>0)l[j+10]?.put(U+gt.cols,"≈",o);l[j+11]?.put(U+1,Z.artist?$P(Z.artist).slice(0,gt.cols-8):"—",P);let Dr=[];if(Z.score>0)Dr.push([`★${Z.score}`,P]);if(Z.variants>1)Dr.push([` ×${Z.variants}`,o]);if(Dr.length>0)l[j+11]?.right(U+gt.cols+1,Dr)}}let p=Math.ceil(s.tiles.length/a)*gt.height;jP(t,r,s,u,p,o);let $=Math.max(ce,ce+p-s.scroll),g=ce+u-$,b=s.searching&&g>=2;if(b)LP(l,$,g,r-1,s);let y=s.searching&&s.tiles.length===0;if(y&&!s.error){let[F,j]=ey[Math.floor(Gu(s)/bP)%ey.length];t[i-2]?.run(0,[["Tip ",P],[F,at],[` ${j}`,P]])}let S=s.top*a,E=s.tiles.length-(s.top+c)*a,I=[...S>0?[`↑ ${S} above`]:[],...E>0?[`↓ ${E} more`]:[]];if(I.length>0)t[i-2]?.put(0,I.join(" "),P);if(!s.searching&&s.tiles.length===0&&!s.error&&s.tag)t[ce+1]?.put(0,s.preset==="cutouts"?`No transparent cutouts of ${s.tag} on ${ry(s)} — c searches every post, tab tries ${s.nextSite}`:`No posts of ${s.tag} on ${ry(s)} — tab tries ${s.nextSite}`,P);let N=GP(s,b,h),R=Dh(s,N);return ha(t[i-1],r,o,{badge:"IMAGE SEARCH",lead:R,keys:y&&R?.[0]===N?[]:[["←↑↓→","move"],["enter","try on"],["tab","site"],["ctrl+v","picture"],["s","settings"],["/","search"],["?","keys"]],right:["esc","back"]}),b}function BP(t,e,n,r,i,s){let o=i.tiles[i.focus];if(!o)return;let a=i.shown?.id===o.key?i.shown:void 0,c=[zh(i,o.site,o.siteAnsi),[" ",""],...Pi(String(o.id),at,o.page||void 0,Wr(o.siteAnsi)),[" ",""],ly(o)];if(o.score>0)c.push([` · ★${o.score}`,P]);if(a)c.push([` · ${$u(a.bytes)}`,P]);if(a){if(c.push([" ",""],...dy(a)),i.coloring==="original")c.push([" · own colors",P])}if(t[0]?.run(0,c),o.mates.length>0)t[0]?.right(n,[["≈ ",s],[o.mates.join(" "),P]]);if(EP(t,1,2,i,s),i.tuning)RP(t,8,2,2+Math.min(n-4,60),i,s);else if(i.details)MP(t,5,2,Math.min(n-4,Math.max(48,Math.floor(n*0.55))),r-2,i);else vP(t,7,2,n-4,r-2,i,s);if(i.shown)e.push({id:qh+i.shown.id,path:i.shown.path,row:0,col:0,cols:n,rows:r,z:hP});if(i.tuning){ha(t[r-1],n,s,{badge:"IMAGE EDIT",lead:Dh(i),keys:[["↑↓","field"],["←→","step"],["=","reset"],["+","reset all"],i.tuning.field===1?["1-9","place"]:["⇧←→","×10"],["c","colors"],["enter","keep"]],right:["esc","undo"]});return}let u=Dh(i);ha(t[r-1],n,s,{badge:"IMAGE PREVIEW",lead:u,keys:i.installing===void 0?[["←→","browse"],["enter","install"],["t","tune"],["c","colors"],["i","details"],...i.details?[]:[["⇧←→","example"]],...i.shown?.cut==="on"||i.shown?.cut==="off"?[["x","cut out"]]:[],["?","keys"]]:[],right:i.installing===void 0?["esc","grid"]:void 0})}var WP=[["Field","↑↓ size, position, opacity"],["Step","←→ · ⇧←→ ×10"],["Place","1-9 the nine positions"],["Reset","= this field back to its default · + every field"],["Colors","c the palette's tone or its own colors, opacity back to its default"],["Keep","enter back to try, installed with the picture"],["Undo","esc"],["Close","? esc"]],UP={grid:[["Move","←↑↓→ j k home end pgup pgdn"],["Try on","enter"],["Site",`tab shift+tab all, ${Y.map((t)=>t.name).join(", ")}`],["Posts","c cutouts or every post"],["Search","/ a tag, a post URL or an id"],["Tags","1-9 turn a tag of the tags row on or off — the palette's own, then danbooru's related characters"],["Your own","ctrl+v or v a picture from the clipboard · drop one on the window or paste its link"],["Unfold","space a set of ×N"],["Open","o the post page in a browser"],["Settings","s rating, block, posts, solo, order, sets, remove bg"],["Advanced","a or Advanced › in settings min score, min size, sites, hide, hide tags, PNG only"],["Back","esc returns to preview"],["Close","? esc"]],try:[["Browse","←→"],["Install","enter"],["Tune","t size, position and opacity, installed with the picture"],["Colors","c the palette's tone or its own colors, installed with the picture"],["Details","i characters, series, tags, rating and file, under Post, Source and Artist"],["Example",`⇧←→ ${te.map((t)=>t.name.toLowerCase()).join(", ")}`],["Cut out","x the background off or on, on an opaque picture"],["Open","o the post page in a browser"],["Your own","ctrl+v or v a picture from the clipboard · drop one on the window"],["Grid","esc"],["Close","? esc"]]},Vh=6,KP=24;function ma(t){return[...t.settings.flatMap((e,n)=>Boolean(e.advanced)===t.advanced?[n]:[]),t.settings.length]}function zP(t){return t.replace(/^[A-Z](?=[a-z])/,(e)=>e.toLowerCase())}function iy(t){let e=t.settings.filter((n)=>Boolean(n.advanced)!==t.advanced).map((n)=>zP(n.label));return`${t.advanced?"Back to":"More filters:"} ${e.join(", ")} — enter opens the page, or a from any row`}function my(t,e,n){let r=t.indexOf(e);if(r!==-1)return t[(r+n+t.length)%t.length];let i=Number(e)||0;return(n>0?t.find((o)=>(Number(o)||0)>i):[...t].reverse().find((o)=>(Number(o)||0)<i))??t[n>0?0:t.length-1]}function Ri(t,e){let n=[],r="";for(let i of t.split(" "))if(r&&dt(r)+1+dt(i)>e)n.push(r),r=i;else r=r?`${r} ${i}`:i;return r?[...n,r]:n}function DP(t){if(t.entry!=="number"||t.choices.includes(t.value))return t.choices;let e=t.choices.findIndex((n)=>(Number(n)||0)>Number(t.value));return e===-1?[...t.choices,t.value]:[...t.choices.slice(0,e),t.value,...t.choices.slice(e)]}function qP(t,e,n,r){let i=`\x1B[7;${30+r}m`,s=e&&n!==void 0;if(t.entry==="text")return[{text:` ${s?`${n}█`:t.value||"none"} `,sgr:s||e&&t.value?i:t.value?"":P}];let o=s?[]:t.value.split(" "),a=(s?t.choices:DP(t)).map((c,u)=>{let l=o.includes(c),d=t.multi&&e&&u===t.cursor?"4;":"";return{text:t.multi?` ${l?"[x]":"[ ]"} ${c} `:` ${c} `,sgr:l?e?`\x1B[${d}7;${30+r}m`:"":d?`\x1B[4m${P}`:P,choice:c}});return s?[...a,{text:` ${n}█ `,sgr:i}]:a}function sy(t){if(t.entry==="text")return[{text:" ".repeat(KP),sgr:""}];let e=t.choices.map((n)=>({text:t.multi?` [x] ${n} `:` ${n} `,sgr:""}));return t.entry==="number"?[...e,{text:` ${"0".repeat(Vh)}█ `,sgr:""}]:e}function YP(t){return t.reduce((e,n)=>e+dt(n.text)+1,0)-1}function oy(t,e){let n=[[]],r=0;for(let i of t){let s=dt(i.text)>e?{...i,text:` …${Array.from(i.text).slice(-(e-2)).join("")}`}:i;if(r>0&&r+dt(s.text)>e)n.push([]),r=0;n[n.length-1]?.push(s),r+=dt(s.text)+1}return n}function ay(t){if(t.multi&&t.choices.every((e)=>t.default.split(" ").includes(e)))return"Default all";return`Default ${t.default&&t.default!==t.multi?.none?t.default:"none"}`}function cy(t){if(!t.tag)return"";if(!t.counts)return`${t.tag}: counting…`;let e=t.counts.map(({site:n,count:r})=>`${n} ${r===void 0?"no count":r.toLocaleString("en-US")}`);return`${t.tag}: ${e.join(" · ")}`}function JP(t,e){let n=t.advanced?"basic":"advanced";if(!e)return{keys:[["↑↓","setting"],["enter",n],["s","save"]],right:["esc","undo"]};if(t.typing!==void 0)return{keys:[["⌫","erase"],["enter","done"]],right:["esc","cancel"]};if(e.entry)return{keys:[["↑↓","setting"],...e.entry==="number"?[["←→","step"]]:[],["a",n],["enter","type"],["s","save"]],right:["esc","undo"]};return{keys:[["↑↓","setting"],["←→","value"],["a",n],...e.multi?[["space","toggle"]]:[],["enter","save"]],right:["esc","undo"]}}function VP(t,e,n,r,i){let s=r.panel??0,o=r.settings.length,c=6+Math.max(...r.settings.map((W)=>dt(W.label))),u=Math.max(...r.settings.map((W)=>dt(ay(W)))),l=c+Math.max(...r.settings.map((W)=>YP(sy(W))))+u+5,d=Math.min(e-2,Math.max(48,l)),f=d-c-u-5,h=d-7,p=[!1,!0].map((W)=>({advanced:W,rows:ma({settings:r.settings,advanced:W}).slice(0,-1)})),$=r.settings.map((W)=>oy(sy(W),f).length),g=Math.max(...p.map((W)=>W.rows.reduce(($t,tt)=>$t+$[tt],0))),b=Math.max(...p.map((W)=>Ri(iy({settings:r.settings,advanced:W.advanced}),h).length),...r.settings.map((W)=>Ri(W.about,h).length)),y=`${r.tag}: ${Y.map((W)=>`${W.name} 0,000,000`).join(" · ")}`,S=r.tag?Math.max(Ri(y,h).length,Ri(cy(r),h).length):0,E=g+b+S+8,I=Math.floor((e-d)/2),N=Math.max(1,Math.floor((n-1-E)/2)),R=`\x1B[7;${30+r.siteAnsi}m`;t[N]?.put(I,`╭─ Settings ${"─".repeat(Math.max(0,d-13))}╮`);for(let W=N+1;W<N+E-1;W++)t[W]?.put(I,`│${" ".repeat(d-2)}│`);let F=N+2;for(let W of ma(r).slice(0,-1)){let $t=r.settings[W],tt=W===s;if(tt)t[F]?.put(I+2,"▶",i);if(t[F]?.mark(I+2,c-3,{kind:"setting",index:W}),t[F]?.put(I+4,$t.label,tt?at:""),$t.value!==$t.default)t[F]?.right(I+d-3,[[ay($t),P]]);oy(qP($t,tt,r.typing,r.siteAnsi),f).forEach((Jn,Je)=>{let Ve=I+c;for(let Ze of Jn)Ve=t[F+Je].put(Ve,Ze.text,Ze.sgr,void 0,{kind:"choice",index:W,choice:Ze.choice}),Ve+=1}),F+=$[W]}let j=p.find((W)=>W.advanced!==r.advanced)?.rows??[],B=t[N+3+g];if(s===o)B.put(I+2,"▶",i);let X=B.put(I+3,r.advanced?" ‹ Basic ":" Advanced › ",s===o?R:at,void 0,{kind:"setting",index:o});if(j.some((W)=>r.settings[W]?.value!==r.settings[W]?.default))B.put(X+1,"•",P);t[N+5+g]?.put(I+2,"─".repeat(d-4),P),Ri(r.settings[s]?.about??iy(r),h).forEach((W,$t)=>{t[N+6+g+$t]?.put(I+4,W)}),Ri(cy(r),h).forEach((W,$t)=>{t[N+6+g+b+$t]?.put(I+4,W,P)}),t[N+E-1]?.put(I,`╰${"─".repeat(d-2)}╯`);let{keys:U,right:Z}=JP(r,r.settings[s]);ha(t[n-1],e,i,{keys:U,right:Z})}function ZP(t,e,n,r,i){let s=r.tuning?WP:UP[r.mode],o=Math.min(e-2,Math.max(50,...s.map(([,f])=>dt(f)+16))),a=s.map(([f,h])=>({label:f,parts:Ri(h,o-16)})),c=a.reduce((f,{parts:h})=>f+h.length,0)+4,u=Math.floor((e-o)/2),l=Math.max(2,Math.floor((n-c)/2));t[l]?.put(u,`╭─ Help ${"─".repeat(o-9)}╮`);for(let f=l+1;f<l+c-1;f++)t[f]?.put(u,`│${" ".repeat(o-2)}│`);let d=l+2;for(let{label:f,parts:h}of a){t[d]?.put(u+3,f,at);for(let p of h)t[d]?.put(u+13,p),d++}t[l+c-1]?.put(u,`╰${"─".repeat(o-2)}╯`),ha(t[n-1],e,i,{badge:"HELP",right:["? esc","close"]})}function QP(t,e,n){let r=e.suggest??[],i=r.map((a)=>a.alias??(a.count>0?String(a.count):a.palette??"0")),s=Math.max(...r.map((a)=>dt(a.value))),o=Math.max(7,...i.map(dt));r.forEach((a,c)=>{let u=c===e.pick,l=t[1+c];l?.run(0,[[u?"▸ ":" ",n,void 0,{kind:"suggest",index:c}],[a.value,u?at+n:"",void 0,{kind:"suggest",index:c}]]),l?.right(2+s+2+o,[[i[c],P]])})}function Fu(t,e=[]){return[...e,...t.flatMap((n,r)=>n.zones(r))]}function Zh(t,e,n){let r=Array.from({length:n},()=>new Cu(e)),i=[],s=[],o=Ys(t.colors.cursor);if(Wh=!1,e<Ti.cols||n<Ti.rows)return r[0]?.put(0,"ttheme find",at+o),r[1]?.put(0,`Needs ${Ti.cols}×${Ti.rows} — now ${e}×${n}`),r[2]?.put(0,"esc quits",P,void 0,{kind:"key",key:"esc"}),{lines:r.map((c)=>c.render()),images:i,zones:Fu(r),loader:!1,tick:!1};let a=!1;if(t.mode==="try")BP(r,i,e,n,t,o);else a=_P(r,i,s,e,n,t,o);if(t.mode==="grid"&&t.editing!==void 0&&t.suggest?.length){for(let c=1;c<n-1;c++)r[c]=new Cu(e);return QP(r,t,o),{lines:r.map((c)=>c.render()),images:[],zones:Fu(r),loader:!1,tick:!1}}if(t.help||t.panel!==void 0){let c=t.mode==="try"?i:[];for(let u=0;u<n;u++)r[u]=new Cu(e);if(t.help)ZP(r,e,n,t,o);else VP(r,e,n,t,o);return{lines:r.map((u)=>u.render()),images:c,zones:Fu(r),loader:!1,tick:!1}}return{lines:r.map((c)=>c.render()),images:i,zones:Fu(r,s),loader:a,tick:Wh}}import{execFile as XP}from"node:child_process";import{createHash as wy}from"node:crypto";import{existsSync as tH,mkdtempSync as eH,readFileSync as Uu,rmSync as nH,statSync as $y,writeFileSync as ky}from"node:fs";import{homedir as rH,tmpdir as iH}from"node:os";import{join as _u}from"node:path";import{fileURLToPath as sH}from"node:url";import{promisify as oH}from"node:util";var bn=oH(XP),Bu=67108864,aH=4096,tm=["image/png","image/jpeg","image/webp","image/gif","image/tiff","image/heic"],cH=["text/uri-list","text/plain;charset=utf-8","text/plain"],Qh=[...tm,"text/uri-list","text/plain"];function uH(t){try{return $y(t).isFile()}catch{return!1}}function lH(t){let e=[],n="",r="",i=!1;for(let s=0;s<t.length;s++){let o=t[s];if(r==="'")if(o==="'")r="";else n+=o;else if(r==='"')if(o==='"')r="";else if(o==="\\"&&'"\\$`'.includes(t[s+1]??""))n+=t[++s];else n+=o;else if(o==="\\"&&s+1<t.length)n+=t[++s],i=!0;else if(o==="'"||o==='"')r=o,i=!0;else if(/\s/.test(o)){if(i)e.push(n);n="",i=!1}else n+=o,i=!0}if(i)e.push(n);return e}function py(t){if(/^file:\/\//i.test(t))try{return sH(t)}catch{return}if(t.startsWith("~/"))return _u(rH(),t.slice(2));return t.startsWith("/")?t:void 0}function Vs(t,e=uH){let n=[];for(let r of t.replace(/\r\n?/g,`
473
670
  `).split(`
474
- `)){let i=n0(r.trim());if(i&&e(i)){n.push(i);continue}for(let o of RO(r)){if(/^https?:\/\/\S+$/i.test(o)){n.push(o);continue}let s=n0(o);if(s&&e(s))n.push(s)}}return n}function r0(t){let e=vr(t)?Hn(t):xu(t);if(!e)return;return{ext:vr(t)?"png":"jpg",width:e.width,height:e.height}}async function lc(t,e){let n=r0(t);if(n&&n.width*n.height<=Vt)return{bytes:t,...n,source:e};if(process.platform!=="darwin")throw Error(n?`${n.width}×${n.height} is over ${Vt/1e6} megapixels`:"only PNG and JPEG pictures work here");let r=kO(cc(EO(),"ttheme-attach-"));try{let i=cc(r,"in"),o=cc(r,"out.png");a0(i,t);let s=!n||n.width*n.height>Vt?["--resampleHeightWidthMax",String(IO)]:[];await De("sips",["-s","format","png",...s,i,"--out",o]).catch(()=>{throw Error("that is not a picture macOS can read")});let a=new Uint8Array(fc(o)),c=r0(a);if(!c)throw Error("that is not a picture macOS can read");return{bytes:a,...c,source:e}}finally{yO(r,{recursive:!0,force:!0})}}async function Bf(t,e){if(/^https?:\/\//i.test(t)){let n=await fetch(t,{headers:{"User-Agent":Uu},signal:e});if(!n.ok)throw Error(`${new URL(t).host} answered ${n.status}`);if(Number(n.headers.get("content-length")??0)>uc)throw Error("that picture is over 64 MB");let r=new Uint8Array(await n.arrayBuffer());if(/^text\/html/i.test(n.headers.get("content-type")??""))throw Error(`${new URL(t).host} sent a web page, not a picture — copy the image address instead`);return lc(r,t)}if(s0(t).size>uc)throw Error("that picture is over 64 MB");return lc(new Uint8Array(fc(t)),t)}var c0=new Map,Cr={key:"local",name:"local",origin:"file://",moved:!1,cutouts:"",best:"",tagBudget:0,ors:!1,vouched:!0,scored:!1,ansi:7,ratings:{safe:new Set,questionable:new Set,explicit:new Set},rate:()=>"",narrow:()=>[],postsUrl:()=>"",countUrl:()=>"",postUrl:()=>"",pageUrl:(t)=>c0.get(t)??"",parse:()=>[],count:()=>0};function u0(t){if(/^https?:\/\//i.test(t))return"";return t.split("/").pop()??t}function l0(t,e){c0.set(t,e)}function f0(t){return Number.parseInt(o0("sha1").update(t).digest("hex").slice(0,8),16)%Tn}var PO=`ObjC.import('AppKit')
671
+ `)){let i=py(r.trim());if(i&&e(i)){n.push(i);continue}for(let s of lH(r)){if(/^https?:\/\/\S+$/i.test(s)){n.push(s);continue}let o=py(s);if(o&&e(o))n.push(o)}}return n}function gy(t){let e=ei(t)?nn(t):td(t);if(!e)return;return{ext:ei(t)?"png":"jpg",width:e.width,height:e.height}}async function Wu(t,e){let n=gy(t);if(n&&n.width*n.height<=me)return{bytes:t,...n,source:e};if(process.platform!=="darwin")throw Error(n?`${n.width}×${n.height} is over ${me/1e6} megapixels`:"only PNG and JPEG pictures work here");let r=eH(_u(iH(),"ttheme-attach-"));try{let i=_u(r,"in"),s=_u(r,"out.png");ky(i,t);let o=!n||n.width*n.height>me?["--resampleHeightWidthMax",String(aH)]:[];await bn("sips",["-s","format","png",...o,i,"--out",s]).catch(()=>{throw Error("that is not a picture macOS can read")});let a=new Uint8Array(Uu(s)),c=gy(a);if(!c)throw Error("that is not a picture macOS can read");return{bytes:a,...c,source:e}}finally{nH(r,{recursive:!0,force:!0})}}async function em(t,e){if(/^https?:\/\//i.test(t)){let n=await fetch(t,{headers:{"User-Agent":ad},signal:e});if(!n.ok)throw Error(`${new URL(t).host} answered ${n.status}`);if(Number(n.headers.get("content-length")??0)>Bu)throw Error("that picture is over 64 MB");let r=new Uint8Array(await n.arrayBuffer());if(/^text\/html/i.test(n.headers.get("content-type")??""))throw Error(`${new URL(t).host} sent a web page, not a picture — copy the image address instead`);return Wu(r,t)}if($y(t).size>Bu)throw Error("that picture is over 64 MB");return Wu(new Uint8Array(Uu(t)),t)}var yy=new Map,Dn={key:"local",name:"local",origin:"file://",moved:!1,cutouts:"",best:"",tagBudget:0,ors:!1,vouched:!0,scored:!1,ansi:7,ratings:{safe:new Set,questionable:new Set,explicit:new Set},rate:()=>"",narrow:()=>[],postsUrl:()=>"",countUrl:()=>"",postUrl:()=>"",pageUrl:(t)=>yy.get(t)??"",parse:()=>[],count:()=>0};function vy(t){if(/^https?:\/\//i.test(t))return"";return t.split("/").pop()??t}function Sy(t,e){yy.set(t,e)}function Ey(t){return Number.parseInt(wy("sha1").update(t).digest("hex").slice(0,8),16)%cr}var dH=`ObjC.import('AppKit')
475
672
  function run(argv) {
476
673
  const pb = $.NSPasteboard.generalPasteboard
477
674
  const files = pb.readObjectsForClassesOptions($([$.NSURL]), $({ NSPasteboardURLReadingFileURLsOnlyKey: true }))
@@ -496,16 +693,16 @@ function run(argv) {
496
693
  if (web && web.count > 0) return web.objectAtIndex(0).absoluteString.js
497
694
  const text = pb.stringForType('public.utf8-plain-text')
498
695
  return text && !text.isNil() ? text.js : ''
499
- }`,HO=`Add-Type -AssemblyName System.Windows.Forms,System.Drawing
696
+ }`,fH=`Add-Type -AssemblyName System.Windows.Forms,System.Drawing
500
697
  $c = [Windows.Forms.Clipboard]
501
698
  $f = $c::GetFileDropList(); if ($f.Count) { $f; exit }
502
699
  $p = Join-Path $env:TEMP 'ttheme-clipboard.png'
503
700
  $s = $c::GetData('PNG'); if ($s -is [IO.MemoryStream]) { [IO.File]::WriteAllBytes($p, $s.ToArray()); $p; exit }
504
701
  $i = $c::GetImage(); if ($i) { $i.Save($p, [Drawing.Imaging.ImageFormat]::Png); $p; exit }
505
- $c::GetText()`;function d0(){if(process.platform!=="linux")return!1;try{return/microsoft/i.test(fc("/proc/version","utf8"))}catch{return!1}}async function FO(t){let e=Boolean(process.env.WAYLAND_DISPLAY),n=e?["wl-paste",["--list-types"]]:["xclip",["-selection","clipboard","-t","TARGETS","-o"]],r=(await De(n[0],n[1])).stdout.split(`
506
- `).map((s)=>s.trim()),i=(s)=>e?De("wl-paste",["--no-newline","--type",s],{encoding:"buffer",maxBuffer:uc}):De("xclip",["-selection","clipboard","-t",s,"-o"],{encoding:"buffer",maxBuffer:uc});if(r.includes("text/uri-list"))return{text:(await i("text/uri-list")).stdout.toString("utf8")};let o=_f.find((s)=>r.includes(s));if(o)return a0(t,(await i(o)).stdout),{image:t};return{text:r.some((s)=>s.startsWith("text/plain")||s==="UTF8_STRING")?(await i(r.includes("text/plain")?"text/plain":"UTF8_STRING")).stdout.toString("utf8"):""}}function zf(){return Boolean(process.env.SSH_CONNECTION||process.env.SSH_TTY)}async function h0(t){if(process.platform==="darwin"){let e=(await De("osascript",["-l","JavaScript","-e",PO,t])).stdout.trim();return e===t?{image:t}:{text:e}}if(d0()){let e=(await De("powershell.exe",["-NoProfile","-STA","-Command",HO])).stdout.replace(/\r/g,"").trim(),n=await Promise.all(e.split(`
507
- `).map(async(r)=>/^[A-Za-z]:\\/.test(r)?(await De("wslpath",["-u",r])).stdout.trim():r));return n.length===1&&/ttheme-clipboard\.png$/.test(n[0]??"")?{image:n[0]}:{text:n.join(`
508
- `)}}if(process.platform==="linux")return FO(t);throw Error(`reading the clipboard is not supported on ${process.platform}`)}var xO=`ObjC.import('AppKit')
702
+ $c::GetText()`;function My(){if(process.platform!=="linux")return!1;try{return/microsoft/i.test(Uu("/proc/version","utf8"))}catch{return!1}}async function hH(t){let e=Boolean(process.env.WAYLAND_DISPLAY),n=e?["wl-paste",["--list-types"]]:["xclip",["-selection","clipboard","-t","TARGETS","-o"]],r=(await bn(n[0],n[1])).stdout.split(`
703
+ `).map((o)=>o.trim()),i=(o)=>e?bn("wl-paste",["--no-newline","--type",o],{encoding:"buffer",maxBuffer:Bu}):bn("xclip",["-selection","clipboard","-t",o,"-o"],{encoding:"buffer",maxBuffer:Bu});if(r.includes("text/uri-list"))return{text:(await i("text/uri-list")).stdout.toString("utf8")};let s=tm.find((o)=>r.includes(o));if(s)return ky(t,(await i(s)).stdout),{image:t};return{text:r.some((o)=>o.startsWith("text/plain")||o==="UTF8_STRING")?(await i(r.includes("text/plain")?"text/plain":"UTF8_STRING")).stdout.toString("utf8"):""}}function nm(){return Boolean(process.env.SSH_CONNECTION||process.env.SSH_TTY)}async function Oy(t){if(process.platform==="darwin"){let e=(await bn("osascript",["-l","JavaScript","-e",dH,t])).stdout.trim();return e===t?{image:t}:{text:e}}if(My()){let e=(await bn("powershell.exe",["-NoProfile","-STA","-Command",fH])).stdout.replace(/\r/g,"").trim(),n=await Promise.all(e.split(`
704
+ `).map(async(r)=>/^[A-Za-z]:\\/.test(r)?(await bn("wslpath",["-u",r])).stdout.trim():r));return n.length===1&&/ttheme-clipboard\.png$/.test(n[0]??"")?{image:n[0]}:{text:n.join(`
705
+ `)}}if(process.platform==="linux")return hH(t);throw Error(`reading the clipboard is not supported on ${process.platform}`)}var mH=`ObjC.import('AppKit')
509
706
  function run() {
510
707
  const pb = $.NSPasteboard.generalPasteboard
511
708
  const files = pb.readObjectsForClassesOptions($([$.NSURL]), $({ NSPasteboardURLReadingFileURLsOnlyKey: true }))
@@ -517,54 +714,57 @@ function run() {
517
714
  picture = ['public.png', 'public.tiff', 'public.jpeg', 'public.heic'].some((t) => types.includes(t))
518
715
  }
519
716
  return pb.changeCount + '\\t' + (picture ? 'picture' : '')
520
- }`;async function m0(){if(zf())return;if(process.platform==="darwin"){let[t="",e=""]=(await De("osascript",["-l","JavaScript","-e",xO])).stdout.trim().split("\t");return{stamp:t,picture:e==="picture"}}if(process.platform==="linux"&&!d0()){let e=Boolean(process.env.WAYLAND_DISPLAY)?(await De("wl-paste",["--list-types"])).stdout:(await De("xclip",["-selection","clipboard","-t","TARGETS","-o"])).stdout;return{stamp:e,picture:/^image\//m.test(e)}}return}function dc(t){let e=[],n="",r=0;while(r<t.length){if(t[r]!=="\x1B"){n+=t[r],r++;continue}if(t.startsWith("\x1B[200~",r)){let o=t.indexOf("\x1B[201~",r+6);if(o===-1)return{events:e,keys:n,pending:t.slice(r)};e.push({kind:"paste",text:t.slice(r+6,o)}),r=o+6;continue}if(t.startsWith("\x1B]5522;",r)||t.startsWith("\x1B]72;",r)){let o=[t.indexOf("\x1B\\",r),t.indexOf("\x07",r)].filter((f)=>f!==-1);if(o.length===0)return{events:e,keys:n,pending:t.slice(r)};let s=Math.min(...o),a=t.slice(r+2,s),[c="",u="",...l]=a.split(";");e.push({kind:"osc",code:c,meta:LO(u),payload:l.join(";")}),r=s+(t[s]==="\x07"?1:2);continue}let i=/^\[\?([\d;]*)(\$y|c)/.exec(t.slice(r+1,r+64));if(i){if(i[2]==="c")e.push({kind:"attributes"});else{let[o="0",s="0"]=(i[1]??"").split(";");e.push({kind:"mode",mode:Number(o),value:Number(s)})}r+=1+i[0].length;continue}if(/^(?:\[(?:\?[\d;$]*|2|20|200|201)?|\](?:5|55|552|5522|7|72)?)$/.test(t.slice(r+1)))return{events:e,keys:n,pending:t.slice(r)};n+=t[r],r++}return{events:e,keys:n,pending:""}}function LO(t){let e={};for(let n of t.split(":")){let r=n.indexOf("=");if(r>0)e[n.slice(0,r)]=n.slice(r+1)}return e}var is=(t)=>Buffer.from(t).toString("base64"),Wf=(t)=>Buffer.from(t,"base64");function i0(t,e){return e.find((n)=>t.includes(n))}class Kf{clipboard=!1;drops=!1;reading;offered=[];dropping;pw=is(o0("sha1").update(`${process.pid}:${Date.now()}`).digest("hex"));send;deliver;constructor(t,e){this.send=t,this.deliver=e}start(){let t="\x1B[?2004h";if(this.clipboard)t+="\x1B[?5522h";if(this.drops)t+=`\x1B]72;t=a;${Uf.join(" ")}\x1B\\`;this.send(t)}stop(){this.send(`\x1B[?2004l${this.clipboard?"\x1B[?5522l":""}${this.drops?"\x1B]72;t=A\x1B\\":""}`)}ask(){this.reading={mime:".",chunks:[],pw:"",listing:!0},this.send(`\x1B]5522;type=read:name=${is("ttheme")}:pw=${this.pw};${is(".")}\x1B\\`)}take(t){if(t.code==="5522")this.clip(t.meta,t.payload);else if(t.code==="72")this.drop(t.meta,t.payload)}clip(t,e){if(t.type!=="read")return;let n=t.status??"";if(n==="OK"){if(this.reading??={mime:".",chunks:[],pw:t.pw??"",listing:!0},t.pw)this.reading.pw=t.pw;return}let r=this.reading;if(!r)return;if(n==="DATA"){if(r.mime=t.mime?Wf(t.mime).toString("utf8"):r.mime,e)r.chunks.push(Wf(e));return}if(this.reading=void 0,n!=="DONE"){this.deliver({kind:"error",message:n==="EPERM"?"The clipboard read was not allowed":`The terminal answered ${n}`});return}let i=Buffer.concat(r.chunks);if(r.listing){let o=i.toString("utf8").split(/\s+/).filter(Boolean),s=i0(o,[..._f,...OO]);if(!s){this.deliver({kind:"text",text:""});return}let a=r.pw||this.pw,c=r.pw?"Paste event":"ttheme";this.reading={mime:s,chunks:[],pw:a,listing:!1},this.send(`\x1B]5522;type=read:name=${is(c)}:pw=${a};${is(s)}\x1B\\`);return}this.deliver(r.mime.startsWith("image/")?{kind:"bytes",bytes:new Uint8Array(i),source:"clipboard"}:{kind:"text",text:i.toString("utf8")})}drop(t,e){let n=t.t??"";if(n==="m"){if(t.x==="-1"){this.offered=[];return}if(e){this.offered=e.split(" ").filter(Boolean);let a=Uf.filter((c)=>this.offered.includes(c));this.send(`\x1B]72;t=m:o=${a.length>0?1:0};${a.join(" ")}\x1B\\`)}return}if(n==="M"){let a=e?e.split(" ").filter(Boolean):this.offered,c=i0(a,Uf);if(!c){this.send("\x1B]72;t=r:o=0\x1B\\");return}this.dropping={mimes:a,index:a.indexOf(c)+1,chunks:[]},this.send(`\x1B]72;t=r:x=${this.dropping.index}\x1B\\`);return}let r=this.dropping;if(!r)return;if(n==="R"){this.dropping=void 0,this.send("\x1B]72;t=r:o=0\x1B\\"),this.deliver({kind:"error",message:`The drop failed: ${e.split(":")[0]||"unknown error"}`});return}if(n!=="r"&&n!=="")return;if(e)r.chunks.push(Wf(e));if(t.m==="1"||e)return;this.dropping=void 0;let i=Buffer.concat(r.chunks),o=r.mimes[r.index-1]??"",s;if(o.startsWith("image/"))s={kind:"bytes",bytes:new Uint8Array(i),source:"drop"};else{let a=i.toString("utf8"),c=o==="text/uri-list"?ji(a).find((u)=>$O(u)):void 0;s=c?{kind:"bytes",bytes:new Uint8Array(fc(c)),source:c}:{kind:"text",text:a}}this.send("\x1B]72;t=r:o=1\x1B\\"),this.deliver(s)}}import{readFileSync as TO}from"node:fs";var pt={pitch:25,cols:22,rows:9,height:13},Gr={cols:25,rows:16},Re=3,AO=2147483648,CO=-1073741826,jO=1600,g0=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],GO=56,UO=4,p0=20,WO=50,b0=[["space","unfolds a set of ×N"],["o","opens the post page in a browser"],["c","switches between cutouts and every post"],["a","opens the advanced filters"],["1-9","turn a tag of the tags row on or off"],["ctrl+v","tries on a picture from the clipboard — or drop one on the window"]],_O="\x1B[0m",vt="\x1B[1m",C="\x1B[2m",as="\x1B[32m",Ve="\x1B[33m",BO={A:"up",B:"down",C:"right",D:"left",H:"home",F:"end","1~":"home","7~":"home","4~":"end","8~":"end","5~":"pgup","6~":"pgdn",I:"focus-in",O:"focus-out",Z:"shift-tab","1;2C":"shift-right","1;2D":"shift-left"};function gc(t){let e=[],n=0;while(n<t.length){let r=t[n]??"";if(r==="\x1B"){let i=/^(?:\[([0-9;]*)([A-Za-z~])|O([A-Za-z]))/.exec(t.slice(n+1));if(i){e.push(BO[`${i[1]??""}${i[2]??i[3]??""}`]??"nop"),n+=1+i[0].length;continue}let o=t[n+1]??"";if(/^[a-z]$/.test(o)){e.push(`alt-${o}`),n+=2;continue}e.push("esc"),n++;continue}e.push(r==="\r"||r===`
521
- `?"enter":r==="\t"?"tab":r==="\x03"?"ctrl-c":r==="\x16"?"ctrl-v":r===""||r==="\b"?"backspace":r),n++}return e}var O0="\x1B]1337;ReportCellSize\x07\x1B[16t\x1B[14t\x1B[18t",w0="\x1B]1337;ReportCellSize=";function Vf(t){let e=t.indexOf(w0);if(e!==-1){let s=t.slice(e+w0.length),a=[s.indexOf("\x07"),s.indexOf("\x1B\\")].filter((l)=>l!==-1),c=a.length>0?Math.min(...a):-1,u=c===-1?null:/^([\d.]+);([\d.]+);([\d.]+)$/.exec(s.slice(0,c));if(u){let l=Number(u[3]);return{cell:{h:Math.round(Number(u[1])*l),w:Math.round(Number(u[2])*l)},rest:t.slice(0,e)+s.slice(c+(s[c]==="\x07"?1:2))}}}let n=t.indexOf("\x1B[6;"),r=n===-1?null:/^\[6;(\d+);(\d+)t/.exec(t.slice(n+1));if(r)return{cell:{h:Number(r[1]),w:Number(r[2])},rest:t.slice(0,n)+t.slice(n+1+r[0].length)};let i=$0(t,4),o=$0(t,8);if(!i||!o||o.a===0||o.b===0)return null;return{cell:{h:Math.floor(i.a/o.a),w:Math.floor(i.b/o.b)},rest:t.replace(i.text,"").replace(o.text,"")}}function $0(t,e){let n=t.indexOf(`\x1B[${e};`),r=n===-1?null:new RegExp(`^\\[${e};(\\d+);(\\d+)t`).exec(t.slice(n+1));return r?{a:Number(r[1]),b:Number(r[2]),text:`\x1B${r[0]}`}:null}function Ur(t,e){let n=e-Re-2;return{perRow:Math.max(1,Math.floor((t-1)/pt.pitch)),rowsVis:Math.max(1,Math.floor(n/pt.height)),height:n}}function N0(t,e=!0){if(e)return`\x1B_Ga=t,t=f,f=100,i=${t.id},q=2;${Buffer.from(t.path).toString("base64")}\x1B\\`;let n;try{n=TO(t.path).toString("base64")}catch{return}let r=n.match(/.{1,4096}/g)??[""];return r.map((i,o)=>{let s=o<r.length-1?1:0;return o===0?`\x1B_Ga=t,f=100,i=${t.id},m=${s},q=2;${i}\x1B\\`:`\x1B_Gm=${s},q=2;${i}\x1B\\`}).join("")}function R0(t,e){let n=t.crop===void 0?"":`,x=0,y=${t.crop*e.h},w=${t.cols*e.w},h=${t.rows*e.h}`;return`\x1B[${t.row+1};${t.col+1}H\x1B_Ga=p,i=${t.id},p=${t.id}${n},c=${t.cols},r=${t.rows},C=1,z=${t.z},q=2\x1B\\`}function Zf(t){return`\x1B_Ga=d,d=i,i=${t},p=${t},q=2\x1B\\`}function P0(t){return`\x1B_Ga=d,d=I,i=${t},q=2\x1B\\`}function Gi(t){return`\x1B[38;2;${nt(t).join(";")}m`}function mc(t){return`\x1B[48;2;${nt(t).join(";")}m`}var qf=!1;function pc(t){return qf=!0,t.beat}function Ui(t){return g0[pc(t)%g0.length]}function st(t){return tt(t)}function H0(t,e){if(tt(t)<=e)return t;let n="";for(let r of t){if(tt(n+r)>e)break;n+=r}return n}function Wi(t){return`\x1B[${30+t}m`}function _i(t,e,n,r){return n?[[`${Zi} `,r],[t,e,n]]:[[t,e]]}function Jf(t){return t.reduce((e,[n])=>e+st(n),0)}function zO(t,e){let n=[],r=e;for(let[i,o,s]of t){let a=st(i);if(a<=r){n.push([i,o,s]),r-=a;continue}n.push([`${H0(i,r)}…`,o,s]);break}return n}class hc{parts=[];cols;constructor(t){this.cols=t}put(t,e,n="",r){return this.parts.push({col:t,text:e,sgr:n,...r?{link:r}:{}}),t+st(e)}run(t,e){let n=t;for(let[r,i,o]of e)n=this.put(n,r,i,o);return n}right(t,e){this.run(t-e.reduce((n,[r])=>n+st(r),0),e)}center(t,e){this.run(Math.floor((t-e.reduce((n,[r])=>n+st(r),0))/2),e)}render(){let t="";for(let{col:e,text:n,sgr:r,link:i}of this.parts){if(e>=this.cols||e<0)continue;let o=H0(n,this.cols-e);t+=`\x1B[${e+1}G${r}${Ws(o,i)}${r?_O:""}`}return t}}function KO(t){return t.replace(/_\([^)]*\)?$/,"")}function F0(t){return[`${t.reduced?"↓":""}${t.width}×${t.height}`,Math.max(t.width,t.height)<jO?Ve:C]}function cs(t,e,n,r){let i=[...r.keys??[]],o=r.lead,s=r.right,a=()=>{let l=[...o?[Jf(o)]:[],...i.map(([d,m])=>st(d)+1+st(m))];return(r.badge?st(r.badge)+4:0)+l.reduce((d,m)=>d+m,0)+3*Math.max(0,l.length-1)+(s?3+st(s[0])+1+st(s[1]):0)};while(a()>e)if(i.length>2)i.splice(-2,1);else if(s)s=void 0;else if(i.length>1)i.splice(-2,1);else break;if(o&&a()>e)o=zO(o,Math.max(0,Jf(o)-(a()-e)-1));let c=0;if(r.badge)c=t.put(0,` ${r.badge} `,`\x1B[7;1m${n}`)+2;if([...o?[o]:[],...i.map(([l,f])=>[[l,vt],[` ${f}`,C]])].forEach((l,f)=>{c=t.run(c+(f?3:0),l)}),s)t.right(e,[[s[0],vt],[` ${s[1]}`,C]])}function qO(t,e){if(t==="d")return C;if(t==="b")return vt;if(t==="s")return mc(e.colors.selection);if(t==="c")return mc(e.colors.cursor);let n=/^([BK]?)(\d+)$/.exec(t);if(!n)return"";let r=Number(n[2]),i=(o)=>r<8?o+r:o+52+r;if(n[1]==="K")return`\x1B[30;${i(40)}m`;return`\x1B[${n[1]==="B"?"1;":""}${i(30)}m`}function JO(t,e,n,r,i){let o=de.indexOf(Ia(r.scene)),s=de.flatMap((c,u)=>[...u?[[" ",""]]:[],[c.name,u===o?vt+i:C]]),a=s.reduce((c,[u])=>c+st(u),0)<=n;t?.run(e,a?s:[[Ia(r.scene).name,vt+i],[` ${o+1}/${de.length}`,C]])}function YO(t,e,n,r,i,o,s){let{ansi:a,cursor:c}=o.colors;JO(t[e-2],n,r,o,s);let u=r<ub?3:4;if(r>=56)u=Math.min(7,Math.floor((r+1)/8)-1);let l=n;for(let d=0;d<8;d++)l=(t[e]?.put(l,"▀".repeat(u),Gi(a[d]??c)+mc(a[d+8]??c))??l)+1;let f=e+2;for(let d of Ia(o.scene).lines){let m=lb(d,r);if(!m)continue;if(f>i)return;t[f]?.run(n,m.map(([g,$])=>[g,qO($,o)])),f++}}function DO(t,e,n){let r=[[]];for(let s of t){let a=r[r.length-1];if(a.length===0||st([...a,s].join(" "))<=e)a.push(s);else if(r.length<n)r.push([s]);else break}let i=r.reduce((s,a)=>s+a.length,0),o=r[r.length-1];while(i<t.length&&o.length>0&&st([...o,`+${t.length-i}`].join(" "))>e)o.pop(),i--;if(i<t.length)o.push(`+${t.length-i}`);return r.filter((s)=>s.length>0).map((s)=>s.join(" "))}function k0(t){return t.replace(/^https?:\/\/(?:www\.)?/,"")}function VO(t,e,n,r,i){let o=r.info,s=o?.artists??[],a=Wi(r.tiles[r.focus]?.siteAnsi??r.siteAnsi);[["Post",o?.page?_i(k0(o.page),"",o.page,a):[["—",C]]],["Source",o?.source?_i(k0(o.source),"",o.link,i):[["—",C]]],["Artist",[s.length>0?[s.join(" "),""]:["—",C]]]].forEach(([u,l],f)=>{t[e+f]?.put(n,u,C),t[e+f]?.run(n+12,l)})}function ZO(t,e,n,r,i,o){let s=o.info,a=o.tiles[o.focus];if(!s||!a)return;let c=o.shown?.id===a.key?o.shown:void 0,u=n+12,l=Math.max(12,r-12),f=[`${a.width}×${a.height}${s.ext?` ${s.ext.toUpperCase()}`:""}`,...c?[Va(c.bytes)]:[]].join(" · "),d=[s.rating??"—",a.score>0?`★${a.score}`:"",s.posted??""].filter(Boolean).join(" · "),m=(w,b)=>w.length>0?DO(w,l,b).map((v)=>[[v,""]]):[[["—",C]]],g=[["Characters",m(s.characters,2)],["Series",m(s.series,1)],["Tags",m(s.tags,3)],["Rating",[[[d,d==="—"?C:""]]]],["File",[[[f,""],...c?[[" ",""]]:[],...c?x0(c):[]]]],["Uploader",[[s.uploader?[s.uploader,""]:["—",C]]]]],$=e;for(let[w,b]of g){if($+b.length-1>i)return;t[$]?.put(n,w,C);for(let v of b)t[$]?.run(u,v),$++}}var QO=["Size","Position","Opacity"],XO=[0,3,6];function tN(t,e){let{tune:n,untuned:r}=t;return e===0?n.size!==r.size:e===1?n.at!==r.at:n.opacity!==r.opacity}function eN(t){return t.toFixed(2)}function nN(t,e,n,r,i,o){let s=i.tuning;if(!s)return;let a=i.tiles[i.focus];t[e-3]?.run(n,[[i.palette,vt+o],[" Background",C],...a?[[" · ",C],..._i(`${a.site} ${a.id}`,C,a.page||void 0,Wi(a.siteAnsi))]:[]]);let c=Math.max(8,r-n-21),u=20,l=Math.max(100,s.fill);for(let[f,d]of QO.entries()){let m=e+XO[f],g=s.field===f,$=g?vt:C;if(g)t[m]?.put(n,"▶",o);t[m]?.put(n+2,d,$);let w;if(f===1){for(let b=1;b<=9;b++){let v=b===i.tune.at;t[e+2+Math.floor((b-1)/3)]?.put(n+12+(b-1)%3*3,v?"■":"·",v?vt+o:C)}w=Qt[i.tune.at-1]??"center"}else{let b;if(f===0){let{size:v}=i.tune;b=v==="fill"?c-1:Math.floor((v-u)*(c-1)/(l-u+1)),w=v==="fill"?"fill":`${v}%`}else b=Math.floor(Math.round(i.tune.opacity*100)*(c-1)/100),w=eN(i.tune.opacity);b=Math.max(0,Math.min(c-1,b)),t[m]?.run(n+12,[["━".repeat(b),o],["●",vt],["─".repeat(c-1-b),C]])}if(t[m]?.right(r-2,[[w,$]]),tN(i,f))t[m]?.put(r-1,"↺",g?vt+o:C)}}function rN(t,e,n,r,i,o){t[e]?.put(n,`╭${"─".repeat(i-2)}╮`,o);for(let s=e+1;s<e+r-1;s++)t[s]?.put(n,"│",o),t[s]?.put(n+i-1,"│",o);t[e+r-1]?.put(n,`╰${"─".repeat(i-2)}╯`,o)}function Yf(t,e=t.site,n=t.siteAnsi){return[` ${e} `,`\x1B[7;${30+n}m`]}function ss(t){return`${q[Math.floor(t/Tn)]?.name??"local"} ${t%Tn}`}function os(t,e,n){let r=q[Math.floor(e/Tn)],i=ss(e),o=t.indexOf(i);if(!r||o===-1)return[[t,n]];return[[t.slice(0,o),n],..._i(i,n,r.pageUrl(e%Tn),Wi(r.ansi)),[t.slice(o+i.length),n]].filter(([a])=>a!=="")}function iN(t,e,n){let r=[{name:"all",moved:!1},...q].flatMap((o,s)=>{let a=`${o.name}${o.moved?"*":""}`,c=o.name===n.site?Yf(n,a):[` ${a} `,C];return s?[[" ",""],c]:[c]}),i=r.reduce((o,[s])=>o+st(s),0)<=e;t.run(0,i?r:[Yf(n)])}function oN(t,e,n,r){if(n.chips.length===0)return;let i=[["tags ",C]],o=st("tags "),s=n.chips.length;for(let[a,c]of n.chips.entries()){let u=` ${a+1} ${c.name} `;if(o+st(u)+1>e-2)break;i.push([u,c.on?`\x1B[7m${r}`:C],[" ",""]),o+=st(u)+1,s--}if(s>0)i.push([`+${s}`,C]);t.run(0,i)}function sN(t,e,n,r){if(n.editing!==void 0){let c=t.run(0,[["⌕ ",r],[n.editing,""],["█",r]]),u=n.suggest?.length?" ↑↓ pick enter searches":" enter searches";t.put(c,n.editing?u:` A tag, a post URL or an id, or drop a picture or ctrl+v — ${n.tag||"esc leaves"}`,C);return}let i=t.run(0,[["⌕ ",r],[n.tag||"Nothing yet — / searches, ctrl+v pastes a picture",n.tag?"":C]]),o=Er.filter((c)=>!n.block.includes(c)),s=q.filter((c)=>!n.enabled.includes(c.name)).map((c)=>c.name),a=[n.preset,...n.solo?["solo"]:[],n.order,...n.rating.join("+")==="safe"?[]:[n.rating.join("+")],...o.length>0?[`allows ${o.join("+")}`]:[],...n.narrow.size>0?[`≥${n.narrow.size}px`]:[],...n.narrow.score>0?[`score≥${n.narrow.score}`]:[],...n.narrow.png?["png"]:[],...n.hide.length+n.hideTags.length>0?[`hides ${[...n.hide,...n.hideTags].join("+")}`]:[],...s.length>0?[`all skips ${s.join("+")}`]:[]];if(t.put(i,` ${a.join(" ")}`,C),n.total>0||!n.searching){let c=[[`${n.tiles.length}/${n.checked}`,""]];if(n.checked<n.total)c.push([` of ${n.total}`,C]);t.right(e,c)}}function x0(t){if(t.cut==="on")return[[`Cut out · ${t.clear}% transparent`,as]];if(t.cut==="off")return[["Opaque · x cuts out",Ve]];if(t.cut==="failed")return[["Opaque · no cut-out",Ve]];return[t.clear>0?[`${t.clear}% transparent`,as]:["Opaque",Ve]]}function y0(t){return t.site==="all"?"any site":t.site}function Df(t,e){if(t.installing!==void 0)return os(`${Ui(t)} Installing ${t.palette} ← ${ss(t.installing)}`,t.installing,Ve);if(t.hint)return[[t.hint,as]];if(t.error)return[[t.error,Ve]];if(t.waiting!==void 0)return[[`${t.slow??t.site} asked to slow down · ${t.waiting}s`,Ve]];if(t.fetching){let{id:n,got:r,size:i}=t.fetching;return os(`${Ui(t)} Fetching ${ss(n)} · ${Za(r,i)}`,n,Ve)}if(t.cutting!==void 0)return os(`${Ui(t)} Cutting out ${ss(t.cutting)}`,t.cutting,Ve);if(t.preparing!==void 0)return os(`${Ui(t)} Preparing ${ss(t.preparing)}`,t.preparing,Ve);if(e)return[e];if(t.saved)return os(t.saved.text,t.saved.key,as);if(t.note)return[[t.note,C]];return}function L0(t){if(t.ranking)return"Ranking previews by palette colors";if(t.stage==="check")return t.preset==="cutouts"?"Checking PNG headers":"Loading previews";return"Fetching posts"}function T0(t,e){return t.ranking?`${e}${t.ranking.done}/${t.ranking.total}`:""}function aN(t,e,n,r,i){let{background:o,cursor:s,selection:a}=r.colors,{ranking:c}=r,u=c?Math.round(n*c.done/c.total):-1,l=Math.max(6,Math.round(n*0.22)),f=pc(r)%(p0*2)/p0,d=Math.round((n-l)*(0.5-0.5*Math.cos(Math.PI*(f<1?f:2-f)))),m=Ht(o,s,i),g=Ht(o,Ht(a,o,0.15),i),$=Array.from({length:n},(b,v)=>{let R=(u>=0?v<u:v>=d&&v<d+l)?m:g;return v===0||v===n-1?Ht(R,o,0.55):R}),w=0;for(let b=1;b<=n;b++)if(b===n||$[b]!==$[w])t?.put(e+w," ".repeat(b-w),mc($[w])),w=b}function cN(t,e,n,r,i){let{background:o,foreground:s}=i.colors,a=i.loaderFrom===void 0?0:Math.min(1,(pc(i)-i.loaderFrom)/UO),c=e+(n>=5?Math.floor((n-5)/2):0);t[c]?.center(r,[[L0(i),vt+Gi(Ht(o,s,a))],[T0(i," "),Gi(Ht(o,Ht(s,o,0.45),a))]]);let u=Math.min(GO,r-8);if(aN(t[c+(n>=3?2:1)],Math.floor((r-u)/2),u,i,a),n<5)return;t[c+4]?.center(r,i.sites.flatMap(({name:l,arrived:f},d)=>[...d?[[" · ",Gi(Ht(o,s,0.25*a))]]:[],[l,Gi(Ht(o,f?Ht(s,o,0.2):s,f?a:0.32*a))]]))}function uN(t,e,n,r,i,o){if(i<=r)return;let s=Math.max(1,Math.round(r*r/i)),a=Math.max(0,Math.min(r-s,Math.round(n.scroll*r/i)));for(let c=0;c<r;c++){let u=c>=a&&c<a+s;t[Re+c]?.put(e-1,u?"┃":"│",u?o:C)}}function lN(t,e,n){if(e)return[`${Ui(t)} ${L0(t)}${T0(t," · ")}`,C];let r=n.filter((o)=>!o.missing),i=r.filter((o)=>o.thumb).length;return i<r.length?[`${Ui(t)} Loading thumbnails · ${i}/${r.length}`,C]:void 0}function fN(t,e,n,r,i,o){let{perRow:s,rowsVis:a,height:c}=Ur(n,r);sN(t[0],n,i,o),iN(t[1],n,i),oN(t[2],n,i,o);let u=t.map((O,F)=>F>=Re&&F<Re+c?O:void 0),l=Math.floor(i.scroll/pt.height),f=Math.floor((i.scroll+c-1)/pt.height),d=[];for(let O=l;O<=f;O++){let F=Re+O*pt.height-i.scroll;for(let j=0;j<s;j++){let W=O*s+j,D=j*pt.pitch,_=i.tiles[W];if(!_)continue;d.push(_);let me=W===i.focus;if(me)rN(u,F,D,pt.height,pt.pitch-1,o);let z=F+1,ht=Math.max(z,Re),V=Math.min(z+pt.rows,Re+c);if(_.thumb&&V>ht)e.push({id:_.key,path:_.thumb,row:ht,col:D+1,cols:pt.cols,rows:V-ht,...V-ht<pt.rows?{crop:ht-z}:{},z:-1});let kn=[...i.installed.includes(_.key)?[["✓ ",as]]:[],..._.page||i.site!=="all"?_i(String(_.id),me?vt:"",_.page||void 0,Wi(_.siteAnsi)):[["● ",Wi(_.siteAnsi)],[String(_.id),me?vt:""]],[" ",""],F0(_)],Kr=pt.cols-(_.mates.length>0?1:0);if(u[F+10]?.run(D+1,Jf(kn)>Kr?kn.map(([fr,Ms,Is])=>[fr.replace(/^(\S) $/,"$1"),Ms,Is]):kn),_.mates.length>0)u[F+10]?.put(D+pt.cols,"≈",o);u[F+11]?.put(D+1,_.artist?KO(_.artist).slice(0,pt.cols-8):"—",C);let He=[];if(_.score>0)He.push([`★${_.score}`,C]);if(_.variants>1)He.push([` ×${_.variants}`,o]);if(He.length>0)u[F+11]?.right(D+pt.cols+1,He)}}let m=Math.ceil(i.tiles.length/s)*pt.height;uN(t,n,i,c,m,o);let g=Math.max(Re,Re+m-i.scroll),$=Re+c-g,w=i.searching&&$>=2;if(w)cN(u,g,$,n-1,i);let b=i.searching&&i.tiles.length===0;if(b&&!i.error){let[O,F]=b0[Math.floor(pc(i)/WO)%b0.length];t[r-2]?.run(0,[["Tip ",C],[O,vt],[` ${F}`,C]])}let v=i.top*s,R=i.tiles.length-(i.top+a)*s,S=[...v>0?[`↑ ${v} above`]:[],...R>0?[`↓ ${R} more`]:[]];if(S.length>0)t[r-2]?.put(0,S.join(" "),C);if(!i.searching&&i.tiles.length===0&&!i.error&&i.tag)t[Re+1]?.put(0,i.preset==="cutouts"?`No transparent cutouts of ${i.tag} on ${y0(i)} — c searches every post, tab tries ${i.nextSite}`:`No posts of ${i.tag} on ${y0(i)} — tab tries ${i.nextSite}`,C);let I=lN(i,w,d),P=Df(i,I);return cs(t[r-1],n,o,{badge:"IMAGE SEARCH",lead:P,keys:b&&P?.[0]===I?[]:[["←↑↓→","move"],["enter","try on"],["tab","site"],["ctrl+v","picture"],["s","settings"],["/","search"],["?","keys"]],right:["esc","back"]}),w}function dN(t,e,n,r,i,o){let s=i.tiles[i.focus];if(!s)return;let a=i.shown?.id===s.key?i.shown:void 0,c=[Yf(i,s.site,s.siteAnsi),[" ",""],..._i(String(s.id),vt,s.page||void 0,Wi(s.siteAnsi)),[" ",""],F0(s)];if(s.score>0)c.push([` · ★${s.score}`,C]);if(a)c.push([` · ${Va(a.bytes)}`,C]);if(a){if(c.push([" ",""],...x0(a)),i.coloring==="original")c.push([" · own colors",C])}if(t[0]?.run(0,c),s.mates.length>0)t[0]?.right(n,[["≈ ",o],[s.mates.join(" "),C]]);if(VO(t,1,2,i,o),i.tuning)nN(t,8,2,2+Math.min(n-4,60),i,o);else if(i.details)ZO(t,5,2,Math.min(n-4,Math.max(48,Math.floor(n*0.55))),r-2,i);else YO(t,7,2,n-4,r-2,i,o);if(i.shown)e.push({id:AO+i.shown.id,path:i.shown.path,row:0,col:0,cols:n,rows:r,z:CO});if(i.tuning){cs(t[r-1],n,o,{badge:"IMAGE EDIT",lead:Df(i),keys:[["↑↓","field"],["←→","step"],["=","reset"],["+","reset all"],i.tuning.field===1?["1-9","place"]:["⇧←→","×10"],["c","colors"],["enter","keep"]],right:["esc","undo"]});return}let u=Df(i);cs(t[r-1],n,o,{badge:"IMAGE PREVIEW",lead:u,keys:i.installing===void 0?[["←→","browse"],["enter","install"],["t","tune"],["c","colors"],["i","details"],...i.details?[]:[["⇧←→","example"]],...i.shown?.cut==="on"||i.shown?.cut==="off"?[["x","cut out"]]:[],["?","keys"]]:[],right:i.installing===void 0?["esc","grid"]:void 0})}var hN=[["Field","↑↓ size, position, opacity"],["Step","←→ · ⇧←→ ×10"],["Place","1-9 the nine positions"],["Reset","= this field back to its default · + every field"],["Colors","c the palette's tone or its own colors, opacity back to its default"],["Keep","enter back to try, installed with the picture"],["Undo","esc"],["Close","? esc"]],mN={grid:[["Move","←↑↓→ j k home end pgup pgdn"],["Try on","enter"],["Site",`tab shift+tab all, ${q.map((t)=>t.name).join(", ")}`],["Posts","c cutouts or every post"],["Search","/ a tag, a post URL or an id"],["Tags","1-9 turn a tag of the tags row on or off — the palette's own, then danbooru's related characters"],["Your own","ctrl+v or v a picture from the clipboard · drop one on the window or paste its link"],["Unfold","space a set of ×N"],["Open","o the post page in a browser"],["Settings","s rating, block, posts, solo, order, sets, remove bg"],["Advanced","a or Advanced › in settings min score, min size, sites, hide, hide tags, PNG only"],["Back","esc returns to preview"],["Close","? esc"]],try:[["Browse","←→"],["Install","enter"],["Tune","t size, position and opacity, installed with the picture"],["Colors","c the palette's tone or its own colors, installed with the picture"],["Details","i characters, series, tags, rating and file, under Post, Source and Artist"],["Example",`⇧←→ ${de.map((t)=>t.name.toLowerCase()).join(", ")}`],["Cut out","x the background off or on, on an opaque picture"],["Open","o the post page in a browser"],["Your own","ctrl+v or v a picture from the clipboard · drop one on the window"],["Grid","esc"],["Close","? esc"]]},Qf=6,gN=24;function us(t){return[...t.settings.flatMap((e,n)=>Boolean(e.advanced)===t.advanced?[n]:[]),t.settings.length]}function pN(t){return t.replace(/^[A-Z](?=[a-z])/,(e)=>e.toLowerCase())}function v0(t){let e=t.settings.filter((n)=>Boolean(n.advanced)!==t.advanced).map((n)=>pN(n.label));return`${t.advanced?"Back to":"More filters:"} ${e.join(", ")} — enter opens the page, or a from any row`}function A0(t,e,n){let r=t.indexOf(e);if(r!==-1)return t[(r+n+t.length)%t.length];let i=Number(e)||0;return(n>0?t.find((s)=>(Number(s)||0)>i):[...t].reverse().find((s)=>(Number(s)||0)<i))??t[n>0?0:t.length-1]}function jr(t,e){let n=[],r="";for(let i of t.split(" "))if(r&&st(r)+1+st(i)>e)n.push(r),r=i;else r=r?`${r} ${i}`:i;return r?[...n,r]:n}function bN(t){if(t.entry!=="number"||t.choices.includes(t.value))return t.choices;let e=t.choices.findIndex((n)=>(Number(n)||0)>Number(t.value));return e===-1?[...t.choices,t.value]:[...t.choices.slice(0,e),t.value,...t.choices.slice(e)]}function wN(t,e,n,r){let i=`\x1B[7;${30+r}m`,o=e&&n!==void 0;if(t.entry==="text")return[{text:` ${o?`${n}█`:t.value||"none"} `,sgr:o||e&&t.value?i:t.value?"":C}];let s=o?[]:t.value.split(" "),a=(o?t.choices:bN(t)).map((c,u)=>{let l=s.includes(c),f=t.multi&&e&&u===t.cursor?"4;":"";return{text:t.multi?` ${l?"[x]":"[ ]"} ${c} `:` ${c} `,sgr:l?e?`\x1B[${f}7;${30+r}m`:"":f?`\x1B[4m${C}`:C}});return o?[...a,{text:` ${n}█ `,sgr:i}]:a}function E0(t){if(t.entry==="text")return[{text:" ".repeat(gN),sgr:""}];let e=t.choices.map((n)=>({text:t.multi?` [x] ${n} `:` ${n} `,sgr:""}));return t.entry==="number"?[...e,{text:` ${"0".repeat(Qf)}█ `,sgr:""}]:e}function $N(t){return t.reduce((e,n)=>e+st(n.text)+1,0)-1}function S0(t,e){let n=[[]],r=0;for(let i of t){let o=st(i.text)>e?{...i,text:` …${Array.from(i.text).slice(-(e-2)).join("")}`}:i;if(r>0&&r+st(o.text)>e)n.push([]),r=0;n[n.length-1]?.push(o),r+=st(o.text)+1}return n}function M0(t){if(t.multi&&t.choices.every((e)=>t.default.split(" ").includes(e)))return"Default all";return`Default ${t.default&&t.default!==t.multi?.none?t.default:"none"}`}function I0(t){if(!t.tag)return"";if(!t.counts)return`${t.tag}: counting…`;let e=t.counts.map(({site:n,count:r})=>`${n} ${r===void 0?"no count":r.toLocaleString("en-US")}`);return`${t.tag}: ${e.join(" · ")}`}function kN(t,e){let n=t.advanced?"basic":"advanced";if(!e)return{keys:[["↑↓","setting"],["enter",n],["s","save"]],right:["esc","undo"]};if(t.typing!==void 0)return{keys:[["⌫","erase"],["enter","done"]],right:["esc","cancel"]};if(e.entry)return{keys:[["↑↓","setting"],...e.entry==="number"?[["←→","step"]]:[],["a",n],["enter","type"],["s","save"]],right:["esc","undo"]};return{keys:[["↑↓","setting"],["←→","value"],["a",n],...e.multi?[["space","toggle"]]:[],["enter","save"]],right:["esc","undo"]}}function yN(t,e,n,r,i){let o=r.panel??0,s=r.settings.length,c=6+Math.max(...r.settings.map((z)=>st(z.label))),u=Math.max(...r.settings.map((z)=>st(M0(z)))),l=c+Math.max(...r.settings.map((z)=>$N(E0(z))))+u+5,f=Math.min(e-2,Math.max(48,l)),d=f-c-u-5,m=f-7,g=[!1,!0].map((z)=>({advanced:z,rows:us({settings:r.settings,advanced:z}).slice(0,-1)})),$=r.settings.map((z)=>S0(E0(z),d).length),w=Math.max(...g.map((z)=>z.rows.reduce((ht,V)=>ht+$[V],0))),b=Math.max(...g.map((z)=>jr(v0({settings:r.settings,advanced:z.advanced}),m).length),...r.settings.map((z)=>jr(z.about,m).length)),v=`${r.tag}: ${q.map((z)=>`${z.name} 0,000,000`).join(" · ")}`,R=r.tag?Math.max(jr(v,m).length,jr(I0(r),m).length):0,S=w+b+R+8,I=Math.floor((e-f)/2),P=Math.max(1,Math.floor((n-1-S)/2)),O=`\x1B[7;${30+r.siteAnsi}m`;t[P]?.put(I,`╭─ Settings ${"─".repeat(Math.max(0,f-13))}╮`);for(let z=P+1;z<P+S-1;z++)t[z]?.put(I,`│${" ".repeat(f-2)}│`);let F=P+2;for(let z of us(r).slice(0,-1)){let ht=r.settings[z],V=z===o;if(V)t[F]?.put(I+2,"▶",i);if(t[F]?.put(I+4,ht.label,V?vt:""),ht.value!==ht.default)t[F]?.right(I+f-3,[[M0(ht),C]]);S0(wN(ht,V,r.typing,r.siteAnsi),d).forEach((kn,Kr)=>{let He=I+c;for(let fr of kn)He=t[F+Kr].put(He,fr.text,fr.sgr)+1}),F+=$[z]}let j=g.find((z)=>z.advanced!==r.advanced)?.rows??[],W=t[P+3+w];if(o===s)W.put(I+2,"▶",i);let D=W.put(I+3,r.advanced?" ‹ Basic ":" Advanced › ",o===s?O:vt);if(j.some((z)=>r.settings[z]?.value!==r.settings[z]?.default))W.put(D+1,"•",C);t[P+5+w]?.put(I+2,"─".repeat(f-4),C),jr(r.settings[o]?.about??v0(r),m).forEach((z,ht)=>{t[P+6+w+ht]?.put(I+4,z)}),jr(I0(r),m).forEach((z,ht)=>{t[P+6+w+b+ht]?.put(I+4,z,C)}),t[P+S-1]?.put(I,`╰${"─".repeat(f-2)}╯`);let{keys:_,right:me}=kN(r,r.settings[o]);cs(t[n-1],e,i,{keys:_,right:me})}function vN(t,e,n,r,i){let o=r.tuning?hN:mN[r.mode],s=Math.min(e-2,Math.max(50,...o.map(([,d])=>st(d)+16))),a=o.map(([d,m])=>({label:d,parts:jr(m,s-16)})),c=a.reduce((d,{parts:m})=>d+m.length,0)+4,u=Math.floor((e-s)/2),l=Math.max(2,Math.floor((n-c)/2));t[l]?.put(u,`╭─ Help ${"─".repeat(s-9)}╮`);for(let d=l+1;d<l+c-1;d++)t[d]?.put(u,`│${" ".repeat(s-2)}│`);let f=l+2;for(let{label:d,parts:m}of a){t[f]?.put(u+3,d,vt);for(let g of m)t[f]?.put(u+13,g),f++}t[l+c-1]?.put(u,`╰${"─".repeat(s-2)}╯`),cs(t[n-1],e,i,{badge:"HELP",right:["? esc","close"]})}function EN(t,e,n){let r=e.suggest??[],i=r.map((a)=>a.count>0?String(a.count):a.palette??"0"),o=Math.max(...r.map((a)=>st(a.value))),s=Math.max(7,...i.map(st));r.forEach((a,c)=>{let u=c===e.pick,l=t[1+c];l?.run(0,[[u?"▸ ":" ",n],[a.value,u?vt+n:""]]),l?.right(2+o+2+s,[[i[c],C]])})}function Xf(t,e,n){let r=Array.from({length:n},()=>new hc(e)),i=[],o=Gi(t.colors.cursor);if(qf=!1,e<Gr.cols||n<Gr.rows)return r[0]?.put(0,"ttheme find",vt+o),r[1]?.put(0,`Needs ${Gr.cols}×${Gr.rows} — now ${e}×${n}`),r[2]?.put(0,"esc quits",C),{lines:r.map((a)=>a.render()),images:i,loader:!1,tick:!1};let s=!1;if(t.mode==="try")dN(r,i,e,n,t,o);else s=fN(r,i,e,n,t,o);if(t.mode==="grid"&&t.editing!==void 0&&t.suggest?.length){for(let a=1;a<n-1;a++)r[a]=new hc(e);return EN(r,t,o),{lines:r.map((a)=>a.render()),images:[],loader:!1,tick:!1}}if(t.help||t.panel!==void 0){let a=t.mode==="try"?i:[];for(let c=0;c<n;c++)r[c]=new hc(e);if(t.help)vN(r,e,n,t,o);else yN(r,e,n,t,o);return{lines:r.map((c)=>c.render()),images:a,loader:!1,tick:!1}}return{lines:r.map((a)=>a.render()),images:i,loader:s,tick:qf}}var td=5,SN=6,C0=0.05,MN=[1,2,3,4,5,6,9,10,11,12,13,14],j0=(t,e)=>(e-t+360)%360<=180?1:-1;function ls(t,e,n){let r=e*Math.cos(n*Math.PI/180),i=e*Math.sin(n*Math.PI/180),o=[t+0.3963377774*r+0.2158037573*i,t-0.1055613458*r-0.0638541728*i,t-0.0894841775*r-1.291485548*i].map((l)=>l**3),[s,a,c]=o,u=[4.0767416621*s-3.3077115913*a+0.2309699292*c,-1.2684380046*s+2.6097574011*a-0.3413193965*c,-0.0041960863*s-0.7034186147*a+1.707614701*c];if(u.some((l)=>l<-0.0001||l>1.0001))return;return u.map((l)=>{let f=Math.min(1,Math.max(0,l));return Math.round(255*(f<=0.0031308?12.92*f:1.055*f**0.4166666666666667-0.055))})}function he(t,e,n){let r=0,i=e;if(ls(t,e,n)===void 0)for(let s=0;s<24;s++){let a=(r+i)/2;if(ls(t,a,n)===void 0)i=a;else r=a}else r=e;return`#${(ls(t,r,n)??[0,0,0]).map((s)=>s.toString(16).padStart(2,"0")).join("")}`}function IN(t,e){let{l:n,c:r}=ft(t);return he(n,r,(e+360)%360)}function ON(t,e,n){let{l:r,c:i,h:o}=ft(t),s=yt(e)<0.18,a=(l)=>he(s?r+(1-r)*l:r*(1-l),i,o);if(gt(a(1),e)<n+C0)return a(1);let c=0,u=1;for(let l=0;l<30;l++){let f=(c+u)/2;if(gt(a(f),e)>=n+C0)u=f;else c=f}return a(u)}function NN(t,e){let{l:n,c:r,h:i}=ft(t),o=0,s=n;for(let a=0;a<30;a++){let c=(o+s)/2;if(yt(he(c,r,i))<=e-0.005)o=c;else s=c}return he(o,r,i)}function RN(t,e,n){let r=sn[e],[i,o]=[ft(t[e]),ft(t[e+8])],s=(l,f)=>n.has(l)?[f]:Array.from({length:2*r.width+1},(d,m)=>(r.center-r.width+m+360)%360),a=(l,f,d)=>Mn.every((m)=>{let g=(l>8?8:0)+m;if(g===l)return!0;let $=ft(t[g]);return $.c<Xi||xe($.h,f)>=Xr+1||Math.abs($.l-d)>=ti}),c,u=Number.POSITIVE_INFINITY;for(let l of s(e,i.h)){if(!n.has(e)&&!a(e,l,i.l))continue;for(let f of s(e+8,o.h)){if(xe(l,f)>be-td||!n.has(e+8)&&!a(e+8,f,o.l))continue;let d=xe(l,i.h)+xe(f,o.h);if(d<u)u=d,c=[l,f]}}return c}class G0{theme;moves=[];constructor(t){this.theme={...t,ansi:[...t.ansi]}}set(t,e,n){let r=this.get(t);if(n===r)return;if(this.moves.push({slot:t,rule:e,from:r,to:n}),t==="foreground")this.theme.foreground=n;else if(t==="selection")this.theme.selectionBackground=n;else this.theme.ansi[Number(t.slice(4))]=n}get(t){if(t==="foreground")return this.theme.foreground;if(t==="selection")return this.theme.selectionBackground;return this.theme.ansi[Number(t.slice(4))]}rehue(t,e,n){this.set(`ansi${t}`,e,IN(this.theme.ansi[t],n))}roles(){let t=new Set(this.theme.signatureSlots);for(let{slot:n,hue:r}of Qr(this.theme)){let i=sn[In(n)];this.rehue(n,"ansi-role",i.center+j0(i.center,r)*(i.width-td))}for(let{normal:n,gap:r}of wr(this.theme)){if(r<=be)continue;let[i,o]=t.has(`ansi${n+8}`)?[n+8,n]:[n,n+8],s=ft(this.theme.ansi[i]).h,a=ft(this.theme.ansi[o]).h;this.rehue(o,"bright-follows",s+j0(s,a)*(be-td))}let e=ei(this.theme);for(let[n,r]of $r(this.theme)){let i=In(e.has(r)?n:r),o=RN(this.theme.ansi,i,e);if(o===void 0)continue;this.rehue(i,"distinct",o[0]),this.rehue(i+8,"distinct",o[1])}}readability(){let t=new Set(this.theme.waive),{background:e}=this.theme,n=(r,i,o,s=e)=>{if(t.has(r))return;for(let a of i)if(gt(this.get(a),s)<o)this.set(a,r,ON(this.get(a),s,o))};if(n("foreground",["foreground"],7),n("accents",MN.map((r)=>`ansi${r}`),3),n("light-ansi",["ansi7","ansi15"],7),n("ansi8-visible",["ansi8"],1.6),!t.has("ansi0-dark")&&yt(this.get("ansi0"))>0.15)this.set("ansi0","ansi0-dark",NN(this.get("ansi0"),0.15));n("selection",["selection"],7,this.theme.foreground)}net(){return[...new Set(this.moves.map((t)=>t.slot))].flatMap((t)=>{let e=this.moves.filter((i)=>i.slot===t),n=e[0].from,r=this.get(t);return n===r?[]:[{slot:t,rule:[...new Set(e.map((i)=>i.rule))].join(", "),from:n,to:r}]})}}function bc(t){let e=new G0(t);for(let n=0;n<SN;n++)if(e.readability(),e.roles(),kr(e.theme).length===0)break;return{theme:e.theme,moves:e.net(),left:kr(e.theme)}}var fs=[{key:"background",label:"Background",min:0,max:0.5,step:0.01,digits:2},{key:"foreground",label:"Foreground",min:0.5,max:1,step:0.01,digits:2},{key:"hue",label:"Hue",min:0,max:360,step:1,digits:0,wraps:!0},{key:"tint",label:"Tint",min:0,max:0.1,step:0.005,digits:3},{key:"lightness",label:"Accent lightness",min:0.4,max:0.95,step:0.01,digits:2},{key:"chroma",label:"Accent chroma",min:0,max:0.3,step:0.005,digits:3},{key:"brights",label:"Brights",min:-0.2,max:0.2,step:0.01,digits:2}],wc={background:0.21,foreground:0.88,hue:265,tint:0.02,lightness:0.72,chroma:0.12,brights:0.06},U0=(t,e,n)=>Math.min(n,Math.max(e,t));function W0(t,e,n){let r=t[e.key]+e.step*n,i=e.wraps?(r%e.max+e.max)%e.max:U0(r,e.min,e.max);return{...t,[e.key]:Math.round(i*1e4)/1e4}}function Wr(t){let e=(r,i,o)=>he(U0(r,0,1),i,o),n=Array.from({length:16},()=>"#000000");n[0]=e(t.background+0.06,t.tint,t.hue),n[8]=e(t.background+0.25,t.tint,t.hue),n[7]=e(t.foreground-0.06,t.tint/2,t.hue),n[15]=e(t.foreground+0.06,t.tint/2,t.hue);for(let r of Mn){let i=sn[r].center;n[r]=e(t.lightness,t.chroma,i),n[r+8]=e(t.lightness+t.brights,t.chroma,i)}return{background:e(t.background,t.tint,t.hue),foreground:e(t.foreground,t.tint/2,t.hue),cursor:e(t.lightness+t.brights,Math.max(t.chroma,0.08),t.hue),selection:e(t.background+0.1,t.tint*2,t.hue),ansi:n}}var zi=["background","foreground","cursor","selection",...Array.from({length:16},(t,e)=>`ansi${e}`)],Kt=["Background","Foreground","Cursor","Selection"],yc=["Black","Red","Green","Yellow","Blue","Magenta","Cyan","White"],Bi=Kt.length+yc.length,ur=[{key:"l",label:"Lightness",min:0,max:1,step:0.01,digits:2},{key:"c",label:"Chroma",min:0,max:0.37,step:0.005,digits:3},{key:"h",label:"Hue",min:0,max:360,step:1,digits:0,wraps:!0}],_0=5;function PN(t){let e=t.trim();return/^https?:\/\/\S+$/i.test(e)||ji(e).length>0}function ds(t){return[t.background,t.foreground,t.cursor,t.selection,...t.ansi]}function $n(t){let[e,n,r,i,...o]=t;return{background:e,foreground:n,cursor:r,selection:i,ansi:o}}function hs(t){if(t<Kt.length)return{name:Kt[t],about:zi[t]};let e=t-Kt.length,n=yc[e%8];return e<8?{name:n,about:`ansi ${e}`}:{name:`Bright ${n.toLowerCase()}`,about:`ansi ${e}`}}var $c=(t,e,n)=>Math.min(n,Math.max(e,t));function HN(t){return $c(Math.round(t),0,255).toString(16).padStart(2,"0")}function B0(t){let e=t.trim().toLowerCase(),n=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/.exec(e);if(n){let o=n[1];return`#${o.length===3?[...o].map((s)=>s+s).join(""):o}`}let r=/^rgb\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)\s*\)$/.exec(e);if(r)return`#${r.slice(1,4).map((o)=>HN(Number(o))).join("")}`;let i=/^oklch\(\s*([\d.]+)(%?)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:deg|°)?\s*\)$/.exec(e);if(i){let o=Number(i[1])/(i[2]?100:1);return he($c(o,0,1),Number(i[3]),Number(i[4])%360)}return}function kc(t){let e=Dt.find((n)=>n.rule===t);return e?.min??e?.max??0}function ms(t,e,n){let r=$n(t);return{name:"draft",background:r.background,foreground:r.foreground,selectionBackground:r.selection,ansi:r.ansi,waive:n,signatureSlots:e}}function FN(t,e,n){let r=ms(t,e,n),i=(f)=>!n.includes(f),{background:o,foreground:s,selection:a,ansi:c}=$n(t),u=new Set,l=(f,d,m,g)=>{if(i(g)&&gt(d,m)<kc(g))u.add(f)};l(1,s,o,"foreground"),l(3,s,a,"selection");for(let f of[1,2,3,4,5,6,9,10,11,12,13,14])l(4+f,c[f],o,"accents");for(let f of[7,15])l(4+f,c[f],o,"light-ansi");if(l(12,c[8],o,"ansi8-visible"),i("ansi0-dark")&&yt(c[0])>kc("ansi0-dark"))u.add(4);if(i("ansi-role"))for(let{slot:f}of Qr(r))u.add(4+f);if(i("bright-follows")){for(let{normal:f,gap:d}of wr(r))if(d>be)u.add(4+f+8)}if(i("distinct"))for(let[f,d]of $r(r))u.add(4+f).add(4+d);return u}function wn(t,e,n,r,i){let o=gt(t,e),s=kc(n);if(i.includes(n))return{ok:void 0,text:`${r} ${o.toFixed(2)}:1 · waived`};return{ok:o>=s,text:`${r} ${o.toFixed(2)}:1 · ≥ ${s}`}}function ed(t,e,n,r){let i=$n(t),o=ms(t,e,n);if(r===0){let b=[1,2,3,4,5,6,9,10,11,12,13,14].reduce((v,R)=>gt(i.ansi[v],i.background)<=gt(i.ansi[R],i.background)?v:R);return[wn(i.foreground,i.background,"foreground","Foreground on it",n),wn(i.ansi[b],i.background,"accents",`Weakest, ANSI ${b},`,n),wn(i.ansi[8],i.background,"ansi8-visible","ANSI 8 on it",n)]}if(r===1)return[wn(i.foreground,i.background,"foreground","On background",n),wn(i.foreground,i.selection,"selection","On the selection",n)];if(r===2)return[{ok:void 0,text:`On background ${gt(i.cursor,i.background).toFixed(2)}:1`}];if(r===3)return[wn(i.foreground,i.selection,"selection","Foreground on it",n)];let s=r-Kt.length,a=i.ansi[s];if(s===0){let w=yt(a),b=kc("ansi0-dark");return[n.includes("ansi0-dark")?{ok:void 0,text:`Luminance ${w.toFixed(3)} · waived`}:{ok:w<=b,text:`Luminance ${w.toFixed(3)} · ≤ ${b}`}]}if(s===7||s===15)return[wn(a,i.background,"light-ansi","On background",n)];if(s===8)return[wn(a,i.background,"ansi8-visible","On background",n)];let c=[wn(a,i.background,"accents","On background",n)],u=ft(a),l=In(s),f=sn[l],d=`${f.name} ${f.center}±${f.width}°`;if(u.c<Xi)c.push({ok:void 0,text:"Too grey to have a hue"});else if(ei(o).has(s))c.push({ok:void 0,text:`Hue ${u.h.toFixed(0)}° · a signature, free of ${d}`});else if(n.includes("ansi-role"))c.push({ok:void 0,text:`Hue ${u.h.toFixed(0)}° · ${d} waived`});else{let w=xe(u.h,f.center)-f.width;c.push(w>0?{ok:!1,text:`Hue ${u.h.toFixed(0)}° · ${w.toFixed(0)}° outside ${d}`}:{ok:!0,text:`Hue ${u.h.toFixed(0)}° · in ${d}`})}let m=s<8?s+8:s-8,g=wr(o).find((w)=>w.normal===l);if(g)c.push(n.includes("bright-follows")?{ok:void 0,text:`${g.gap.toFixed(0)}° from ANSI ${m} · waived`}:{ok:g.gap<=be,text:`${g.gap.toFixed(0)}° from ANSI ${m} · ≤ ${be}°`});let $=$r(o).flatMap(([w,b])=>w===s?[b]:b===s?[w]:[]);if($.length>0&&!n.includes("distinct"))c.push({ok:!1,text:`Reads as ANSI ${$.join(", ")} · within ${Xr}° and ${ti} lightness`});return c}function z0(t,e,n){let r=Le(ms(t,e,n));return Dt.map((i,o)=>{let s=r[o],a=n.includes(i.rule);return{ok:a||Number.isNaN(s)?void 0:(i.min===void 0||s>=i.min)&&(i.max===void 0||s<=i.max),label:i.label,value:Number.isNaN(s)?"—":Number.isInteger(s)?String(s):s.toFixed(2),bound:a?"waived":i.min!==void 0?`≥ ${i.min}`:i.max!==void 0?`≤ ${i.max}`:""}})}var xN=new Set(["reset","reset-all","hex","paste","fix","open","seeds","tune","sig","follow"]);class gs{mode;seeds=wc;field=0;list;lch;start;signature;row=0;col=0;channel=0;typing;overlay;quitting=!1;compare=!1;notice;filter="";pick=0;result;act;wants;pictures;startPictures;options;fresh;theme;original;startSignature;seeded=!1;seedsBack=!1;tuneFrom;clip;history=[];future=[];lastEdit;constructor(t){this.options=t,this.theme=t.variant==="theme",this.fresh=t.colors===void 0,this.mode=this.fresh?"seeds":"list",this.list=ds(t.colors??Wr(this.seeds)),this.lch=this.list.map(ft),this.start=[...this.list],this.original=t.original?ds(t.original):[...this.list],this.signature=[...t.signature],this.startSignature=[...t.signature],this.pictures=t.pictures??0,this.startPictures=this.pictures}markSaved(){this.start=[...this.list],this.history=[],this.future=[],this.lastEdit=void 0}offDefault(t){return this.list[t]!==this.original[t]}get added(){return Math.max(0,this.pictures-this.startPictures)}found(t){this.pictures=t.count,this.notice=t.note}get waive(){return this.options.waive??[]}get tuned(){return this.tuneFrom?.hex}colors(){return $n(this.list)}edited(){return{colors:this.colors(),signature:[...this.signature]}}shown(){return this.compare?this.start:this.list}slot(){return this.row<Kt.length?this.row:this.row+(this.col===1?8:0)}dirty(){return this.seeded||this.pictures!==this.startPictures||this.list.some((t,e)=>t!==this.start[e])||this.signature.join()!==this.startSignature.join()}misses(){return FN(this.list,this.signature,this.waive)}failing(){return kr(ms(this.list,this.signature,this.waive))}choices(){let t=this.filter.toLowerCase();return(this.options.palettes??[]).filter((e)=>e.name.toLowerCase().includes(t))}paste(t){if(this.notice=void 0,this.overlay==="open"){this.filter+=t.replace(/\s+/g,"").toLowerCase(),this.pick=0;return}if(this.overlay)return;if(t.trim()===""){this.findPictures({clipboard:!0});return}if(PN(t)){this.findPictures({paste:t});return}if(this.mode==="seeds")return;let e=B0(t);if(!e){this.notice="Not a color — #rrggbb, rgb(r g b) or oklch(l c h)";return}if(this.typing=void 0,this.mode==="tune")this.list[this.slot()]=e,this.lch[this.slot()]=ft(e);else this.set(this.slot(),e,"paste")}press(t){if(this.notice=void 0,t==="ctrl-c"){if(this.theme)this.act="cancel";else this.result="cancelled";return}if(this.quitting){if(this.quitting=!1,t==="y"||t==="Y")this.result="cancelled";return}if(this.typing!==void 0){this.type(t);return}if(this.overlay==="keys"){this.overlay=void 0;return}if(this.overlay==="open"){this.openKey(t);return}if(t==="?"){this.overlay="keys";return}if(this.theme&&(t==="ctrl-v"||t==="alt-v"||t==="p"))return;if(t==="ctrl-v"||t==="alt-v"){this.findPictures({clipboard:!0});return}if(t==="p"&&this.mode!=="tune"){this.findPictures();return}if(t===" "&&this.mode!=="seeds"){this.compare=!this.compare;return}if(this.compare&&t==="esc"){this.compare=!1;return}let e=t==="j"?"down":t==="k"?"up":t;if(this.mode==="seeds")this.seedKey(e);else if(this.mode==="tune")this.tuneKey(e);else this.listKey(e)}seedKey(t){let e=fs.length;if(t==="up"||t==="down")this.field=(this.field+(t==="up"?e-1:1))%e;else if(t==="home"||t==="end")this.field=t==="home"?0:e-1;else if(t==="left"||t==="right"||t==="shift-left"||t==="shift-right"){let n=fs[this.field],r=(t.endsWith("left")?-1:1)*(t.startsWith("shift")?n.wraps?10:_0:1);this.seeds=W0(this.seeds,n,r),this.list=ds(Wr(this.seeds)),this.lch=this.list.map(ft)}else if(t==="enter")this.leaveSeeds();else if(t==="o")this.openPalettes();else if(t==="esc")if(this.seedsBack){let n=this.history.pop();if(n)this.restore(n);this.mode="list",this.seedsBack=!1}else this.result="cancelled"}leaveSeeds(){if(this.fresh&&!this.seeded)this.start=[...this.list];this.seeded=!0,this.seedsBack=!1,this.mode="list"}findPictures(t){if(!this.options.find){this.notice="Pictures need Ghostty, iTerm2 or kitty, outside tmux";return}this.wants=t?{start:t}:{}}openPalettes(){if((this.options.palettes??[]).length>0)this.overlay="open",this.pick=0;else this.notice="No other palettes to take colors from"}themeKey(t){if(t==="s"||t==="\x13")this.act="save";else if(t==="enter")this.tune();else if(t==="esc")this.act="cancel";else if(t==="r")this.set(this.slot(),this.original[this.slot()],"reset");else if(t==="R")this.remember("reset-all"),this.list=[...this.original],this.lch=this.list.map(ft);else if(t==="*"||t==="o"||t==="?")return!0;else return!1;return!0}listKey(t){if(this.theme&&this.themeKey(t))return;if(t==="up"||t==="down"){if(this.theme&&this.row===(t==="up"?0:Bi-1))this.act=t==="up"?"above":"below";else this.row=(this.row+(t==="up"?Bi-1:1))%Bi;this.lastEdit=void 0}else if(t==="home"||t==="end")this.row=t==="home"?0:Bi-1;else if(t==="pgup"||t==="pgdn")this.row=t==="pgup"?0:Kt.length;else if(t==="left"||t==="right")this.col=t==="left"?0:1,this.lastEdit=void 0;else if(t==="tab")this.tune();else if(t==="#")this.typing="";else if(t==="c")this.clip=this.list[this.slot()],this.notice=`Copied ${this.clip}`;else if(t==="v")if(this.clip)this.set(this.slot(),this.clip,"paste");else this.notice="Nothing copied yet — c copies a slot";else if(t==="r")this.set(this.slot(),this.start[this.slot()],"reset");else if(t==="=")this.follow();else if(t==="*")this.mark();else if(t==="f")this.fix();else if(t==="s")this.remember("seeds"),this.mode="seeds",this.seedsBack=!0;else if(t==="o")this.openPalettes();else if(t==="u")this.undo();else if(t==="\x12")this.redo();else if(t==="enter"||t==="\x13")this.save();else if(t==="esc")if(this.dirty())this.quitting=!0;else this.result="cancelled"}tune(){let t=this.slot();this.remember("tune"),this.tuneFrom={hex:this.list[t],lch:this.lch[t]},this.mode="tune"}tuneKey(t){let e=ur.length;if(t==="up"||t==="down"||t==="tab"||t==="shift-tab")this.channel=(this.channel+(t==="up"||t==="shift-tab"?e-1:1))%e;else if(t==="left"||t==="right"||t==="shift-left"||t==="shift-right"){let n=ur[this.channel];this.step((t.endsWith("left")?-1:1)*(t.startsWith("shift")?n.wraps?10:_0:1))}else if(/^[0-9]$/.test(t)){let n=ur[this.channel];this.put(n.min+(n.max-n.min)*Number(t)/10)}else if(t==="#")this.typing="";else if(t==="enter"){if(this.tuneFrom&&this.list[this.slot()]===this.tuneFrom.hex)this.history.pop();this.tuneFrom=void 0,this.mode="list"}else if(t==="esc"){let n=this.slot();if(this.tuneFrom)this.list[n]=this.tuneFrom.hex,this.lch[n]=this.tuneFrom.lch,this.history.pop();this.tuneFrom=void 0,this.mode="list"}}step(t){let e=ur[this.channel],n=this.lch[this.slot()][e.key];this.put(n+e.step*t)}put(t){let e=this.slot(),n=ur[this.channel],r=n.wraps?(t%n.max+n.max)%n.max:$c(t,n.min,n.max),i={...this.lch[e],[n.key]:Math.round(r*1e4)/1e4};this.lch[e]=i,this.list[e]=he(i.l,i.c,i.h)}type(t){let e=this.typing??"";if(t==="esc")this.typing=void 0;else if(t==="enter"){let n=B0(e);if(!n){this.notice="Not a color — #rrggbb, rgb(r g b) or oklch(l c h)";return}if(this.typing=void 0,this.mode==="tune")this.list[this.slot()]=n,this.lch[this.slot()]=ft(n);else this.set(this.slot(),n,"hex")}else if(t==="backspace")this.typing=e.slice(0,-1);else if(t==="\x15")this.typing="";else if(t.length===1&&/^[0-9a-z#(),.% ]$/i.test(t)&&e.length<28)this.typing=e+t.toLowerCase()}openKey(t){let e=this.choices();if(t==="esc")this.overlay=void 0,this.filter="";else if(t==="up"||t==="down"){let n=Math.max(1,e.length);this.pick=(this.pick+(t==="up"?n-1:1))%n}else if(t==="home"||t==="end")this.pick=t==="home"?0:Math.max(0,e.length-1);else if(t==="backspace")this.filter=this.filter.slice(0,-1),this.pick=0;else if(t==="\x15")this.filter="",this.pick=0;else if(t==="enter"){let n=e[this.pick];if(!n)return;if(this.remember("open"),this.list=ds(n.colors),this.lch=this.list.map(ft),this.overlay=void 0,this.filter="",this.notice=`Took the colors of ${n.name}`,this.mode==="seeds")this.leaveSeeds()}else if(t.length===1&&/^[a-z0-9@/-]$/i.test(t))this.filter+=t.toLowerCase(),this.pick=0}remember(t){if(t!==this.lastEdit||xN.has(t))this.history.push({list:[...this.list],lch:[...this.lch],signature:[...this.signature]}),this.future=[];this.lastEdit=t}set(t,e,n){if(!Bt(e)||this.list[t]===e)return;this.remember(n),this.list[t]=e,this.lch[t]=ft(e)}follow(){if(this.row<Kt.length){this.notice="= works on an ANSI row — the bright takes its normal";return}let t=this.row,e=this.row+8,n=this.lch[t],r={l:$c(n.l+0.06,0,1),c:n.c,h:n.h};this.remember("follow"),this.lch[e]=r,this.list[e]=he(r.l,r.c,r.h),this.col=1,this.notice=`${hs(e).name} follows ${hs(t).name.toLowerCase()}`}mark(){let t=zi[this.slot()];this.remember("sig"),this.signature=this.signature.includes(t)?this.signature.filter((e)=>e!==t):[...this.signature,t].slice(-3),this.notice=this.signature.length===3?`Signature: ${this.signature.join(", ")}`:`The signature needs three slots — ${this.signature.length} marked`}fix(){let t=ms(this.list,this.signature,this.waive),{theme:e,moves:n,left:r}=bc({...t,selectionBackground:t.selectionBackground,signatureSlots:this.signature});if(n.length===0){this.notice=kr(t).length===0?"Already passes the gate":"No color change fixes it";return}this.remember("fix");let i=ds({...this.colors(),foreground:e.foreground,selection:e.selectionBackground,ansi:e.ansi});this.lch=i.map((o,s)=>o===this.list[s]?this.lch[s]:ft(o)),this.list=i,this.notice=`Moved ${n.length} ${n.length===1?"color":"colors"}${r.length===0?" — passes the gate":" closer to the gate"}`}save(){let t=this.options.check(this.edited());if(t){this.notice=t;return}this.result="saved"}undo(){let t=this.history.pop();if(!t){this.notice="Nothing to undo";return}this.future.push({list:[...this.list],lch:[...this.lch],signature:[...this.signature]}),this.restore(t)}redo(){let t=this.future.pop();if(!t){this.notice="Nothing to redo";return}this.history.push({list:[...this.list],lch:[...this.lch],signature:[...this.signature]}),this.restore(t)}restore(t){this.list=[...t.list],this.lch=[...t.lch],this.signature=[...t.signature],this.lastEdit=void 0}}var rd=80,id=24,ps=48,nd=11;function q0(t){return{color:t,dim:(e)=>t?`\x1B[2m${e}\x1B[22m`:e,bold:(e)=>t?`\x1B[1m${e}\x1B[22m`:e,fg:(e)=>t?Fe(e):"",bg:(e)=>t?`\x1B[48;2;${nt(e).join(";")}m`:""}}function LN(t){return yt(t)>0.35?"#000000":"#ffffff"}function od(t,e,n,r){let i=Math.max(0,Math.min(e.length-1,n));if(!t.color)return e.map((o,s)=>s===i?"●":r?"━":"─").join("");return e.map((o,s)=>{let a=o??"#000000";if(s===i)return`${t.bg(a)}${t.fg(LN(a))}●\x1B[39;49m`;return o?`${t.fg(o)}█`:`${t.fg(r?"#777777":"#555555")}░`}).join("").concat("\x1B[39m")}function J0(t,e,n){return Array.from({length:n},(r,i)=>{let o=e.min+(e.max-e.min)*i/(n-1),s={...t,[e.key]:o};return ls(s.l,s.c,s.h)?he(s.l,s.c,s.h):void 0})}function sd(t,e,n,r){return Math.round((t-e)/(n-e)*(r-1))}var K0={background:(t)=>t.background,foreground:(t)=>t.foreground,hue:(t)=>t.cursor,tint:(t)=>t.background,lightness:(t)=>t.ansi[4],chroma:(t)=>t.ansi[1],brights:(t)=>t.ansi[12]};function ad(t,e){return e===void 0?t.dim("·"):e?t.dim("✓"):t.bold("✗")}function Y0(t,e,n,r=ps){let i=z0(e.list,e.signature,e.waive).sort((c,u)=>Number(c.ok!==!1)-Number(u.ok!==!1)),o=i.filter((c)=>c.ok===!1).length,s=` ${t.dim("Gate")} ${o===0?t.dim("passes"):t.bold(`${o} ${o===1?"miss":"misses"}`)}`,a=r-4;return[s,...i.slice(0,Math.max(0,n-1)).map((c)=>{let u=`${c.value} ${c.bound}`;return` ${ad(t,c.ok)} ${pe(c.ok===!1?c.label:t.dim(c.label),t.dim(u),a-2)}`})]}function D0(t,e,n,r=ps,i=!0){let o=e.misses(),s=$n(e.list),a=i?e.slot():-1,c=(d)=>t.color?`${t.bg(s.selection)}${t.fg(s.foreground)}${d}\x1B[39;49m`:`[${d}]`,u=(d)=>{let m=e.list[d],g=d===a,$=e.signature.includes(zi[d])?"◆":t.color?"■":" ",w=d===0?void 0:d===3?gt(s.foreground,s.selection):gt(m,s.background),b=w===void 0?"":w.toFixed(1),v=o.has(d)?"✗":e.theme&&e.offDefault(d)?"↺":" ",S=`${t.color?`${t.fg(m)}${$}${g?t.fg(s.foreground):"\x1B[39m"} `:`${$} `}${m} ${b.padStart(4)}${v}`;return g?c(` ${S} `):` ${S} `},l=(d)=>d?t.color?`${t.fg(s.cursor)}▌\x1B[39m `:"▌ ":" ",f=[` ${t.dim("Base")}`];for(let d=0;d<Kt.length;d++){let m=i&&d===e.row,g=Kt[d].padEnd(10);f.push(`${l(m)}${m?t.bold(g):g}${u(d)}`)}f.push("",` ${t.dim(`${"ANSI".padEnd(10)} Normal${" ".repeat(11)}Bright`)}`);for(let d=Kt.length;d<Bi;d++){let m=i&&d===e.row,g=yc[d-Kt.length].padEnd(10);f.push(`${l(m)}${m?t.bold(g):g}${u(d)}${u(d+8)}`)}return f.push(""),[...f,...Y0(t,e,n-f.length,r)]}function TN(t,e,n){let r=$n(e.list),i=[` ${t.dim("Seeds")}`];fs.forEach((o,s)=>{let a=s===e.field,c=e.seeds[o.key],u=Array.from({length:nd},($,w)=>{let b=o.min+(o.max-o.min)*w/(nd-1);return K0[o.key](Wr({...e.seeds,[o.key]:b}))}),l=od(t,u,sd(c,o.min,o.max,nd),a),f=`${c.toFixed(o.digits)}${o.wraps?"°":""}`.padStart(6),d=K0[o.key](r),m=a?t.color?`${t.fg(r.cursor)}▌\x1B[39m `:"▌ ":" ",g=o.label.padEnd(17);i.push(`${m}${a?t.bold(g):g}${l} ${f} ${t.color?`${t.fg(d)}■\x1B[39m `:""}${t.dim(d)}`)}),i.push("");for(let o of kt("Seven seeds grow all twenty colors, each accent on the hue its ANSI role reads as — whatever the seeds, they pass the gate. enter moves on to tune each slot.",ps-4))i.push(` ${t.dim(o)}`);return i.push(""),[...i,...Y0(t,e,n-i.length)]}function V0(t,e,n){let r=(f)=>t.fg(e.ansi[f]),i=t.fg(e.foreground),o=`${t.bg(e.background)}${i}`,s=(f)=>t.color?`\x1B[1m${f}\x1B[22m`:f,a=`${r(2)}❯${i} `,c=Math.max(2,Math.min(4,Math.floor((n-9)/8)));return[Array.from({length:8},(f,d)=>`${t.fg(e.ansi[d])}${t.bg(e.ansi[d+8])}${(t.color?"▀":"#").repeat(c)}${o} `).join(""),"",`${s(`${r(4)}~/code/demo`)}${i} on ${r(5)}main${r(2)} +2${r(3)} ~1${i}`,`${a}git status -sb`,`## ${r(2)}main${i}...${r(1)}origin/main${r(3)} [ahead 1]${i}`,`${r(1)} M${i} src/main.rs ${r(1)}??${i} notes.md`,`${a}git diff`,`${r(6)}@@ -12,2 +12,2 @@${i}`,`${r(1)}- let size = 12;${i}`,`${r(2)}+ let size = 14;${i}`,`${a}cargo test`,`${r(2)} ✓${i} parses config`,`${r(1)} ✗${i} renders frame ${r(8)}expected 3, received 2${i}`,`${r(11)} ⚠ 1 warning${i} ${r(12)}ℹ 2 notes${i} ${r(13)}λ${i} ${r(14)}~${i} ${r(9)}✗${i} ${r(10)}✓${i}`,`${a}ls`,`${s(`${r(4)}docs`)} ${s(`${r(4)}src`)} ${r(2)}run.sh${i} ${r(6)}link${i} Cargo.toml`,`${a}echo ${t.bg(e.selection)}selected text${o} ${t.bg(e.cursor)} ${o}`,`${r(7)}ansi 7 text${i} ${r(15)}ansi 15 text${i} ${r(8)}# ansi 8 comment${i}`].map((f)=>`${o} ${Et(f,n-2)} ${t.color?"\x1B[0m":""}`)}function AN(t,e,n,r){let i=e.slot(),o=e.list[i],s=e.lch[i],a=ft(o),c=e.start[i],{name:u,about:l}=hs(i),f=e.signature.includes(zi[i]),d=[pe(`${t.bold(u)} ${t.dim(l)}`,f?t.dim("◆ signature"):"",n),""],m=t.color?`${t.fg(o)}${"█".repeat(8)}\x1B[39m `:"",g=e.typing!==void 0?`${t.bold(`${e.typing}▏`)}`:void 0,[$,w,b]=nt(o),v=g??`${t.bold(o)}${c!==o?t.dim(` was ${t.color?`${t.fg(c)}■\x1B[39m `:""}${c}`):""}`;d.push(`${m}${v}`),d.push(`${m}${t.dim(`rgb ${$} ${w} ${b}`)}`),d.push(`${m}${t.dim(`oklch ${a.l.toFixed(3)} ${a.c.toFixed(3)} ${a.h.toFixed(0)}°`)}`),d.push("");let R=Math.max(8,Math.min(64,n-12));ur.forEach((P,O)=>{let F=e.mode==="tune"&&O===e.channel,j=s[P.key],W=`${j.toFixed(P.digits)}${P.wraps?"°":""}`.padStart(6),D=od(t,J0(s,P,R),sd(j,P.min,P.max,R),F),_=P.key.toUpperCase();d.push(`${F?t.bold(`▸${_}`):t.dim(` ${_}`)} ${D} ${F?t.bold(W):t.dim(W)}`)}),d.push("");let S=ed(e.list,e.signature,e.waive,i);if(a.c<s.c-0.005)S.push({ok:void 0,text:`Chroma held at the sRGB edge — ${a.c.toFixed(3)} of ${s.c.toFixed(3)}`});for(let P of S)kt(P.text,n-2).forEach((O,F)=>{d.push(`${F===0?ad(t,P.ok):" "} ${P.ok===!1?O:t.dim(O)}`)});let I=r-d.length-1;if(I>=3)d.push("",...V0(t,$n(e.shown()),n).slice(0,I));return d}function CN(t,e,n,r){return[pe(`${t.bold("Specimen")} ${t.dim("what the seeds grow")}`,"",n),"",...V0(t,$n(e.list),n).slice(0,r-2)]}var jN=[["Slots","↑↓ slot · ←→ normal or bright · home end · pgup the base colors · pgdn the ANSI ones"],["Tune","tab · ↑↓ lightness, chroma or hue · ←→ step · ⇧←→ ×5, hue ×10 · 0-9 jump · enter keeps · esc undoes"],["Type","# then #rrggbb, rgb(r g b) or oklch(l c h) — a paste works too"],["Slot","c copies · v pastes · r puts it back · = the bright follows its normal · * marks it a signature color"],["Palette","f moves the colors the gate misses · o takes another palette’s colors · s goes back to the seeds"],["History","u undo · ctrl+r redo"],["Pictures","p finds one on the boorus, tried on in these colors · drop a picture on the window, or paste one, its path or its link · ctrl+v takes the clipboard’s"],["Compare","space shows the colors you started from, on the terminal too"],["Save","enter saves · esc cancels, asking first when something changed"]];function GN(t,e,n){let r=[` ${t.bold("Help")}`,""];for(let[i,o]of jN.filter(([s])=>s!=="Pictures"||e.options.find))kt(o,n-16).forEach((s,a)=>{r.push(` ${t.bold((a===0?i:"").padEnd(11))} ${s}`)});return r}function UN(t,e,n,r){let i=e.choices(),o=e.options.palettes?.length??0,s=e.filter?`${t.bold(e.filter)}▏`:t.dim("type to filter"),a=[pe(` ${t.bold("Take colors from")} ${s}`,t.dim(`${i.length}/${o}`),n),""],c=r-2,u=Math.max(0,Math.min(e.pick-Math.floor(c/2),i.length-c)),l=Math.min(40,Math.max(12,...i.map((f)=>tt(f.name))));if(i.slice(u,u+c).forEach((f,d)=>{let m=u+d===e.pick,g=f.colors,$=t.color?`${t.bg(g.background)} ${[...g.ansi].map((v)=>`${t.fg(v)}■`).join("")} ${t.fg(g.foreground)}Aa \x1B[0m`:"",w=m?"▌ ":" ",b=f.name.padEnd(l);a.push(`${w}${m?t.bold(b):b} ${$}`)}),i.length===0)a.push(` ${t.dim(`No palettes match '${e.filter}'`)}`);return a}function WN(t,e,n){let r=t.fg(e.list[2]),i="",o="",s=[],a="";if(e.quitting)i="QUIT",o=e.added>0?`Discard changes and ${e.added} ${e.added===1?"picture":"pictures"}?`:"Discard changes?",s=[["y","discard"],["n","keep editing"]];else if(e.typing!==void 0)i="TYPE",o=t.dim("#rrggbb, rgb(r g b) or oklch(l c h)"),s=[["enter","set"],["ctrl+u","clear"]],a="esc back";else if(e.overlay==="keys")i="HELP",a="any key closes";else if(e.overlay==="open")i="OPEN",s=[["↑↓","palette"],["a-z","filter"],["enter","take its colors"]],a="esc close";else if(e.compare)i="BEFORE",o="The colors you started from",s=[["space","back to yours"]],a="esc back";else if(e.mode==="seeds")i="SEEDS",s=[["↑↓","seed"],["←→","step"],["⇧←→","×5"],["enter","tune slots"],["o","open a palette"],["p","picture"],["?","keys"]],a=e.fresh&&!e.dirty()?"esc cancel":"esc back";else if(e.mode==="tune")i="IMAGE EDIT",s=[["↑↓","L C H"],["←→","step"],["⇧←→","faster"],["0-9","jump"],["#","type"],["enter","keep"]],a="esc undo";else s=[["↑↓","slot"],["←→","normal or bright"],["tab","tune"],["#","type"],["f","fix"],["p","picture"],["u","undo"],["enter","save"],["?","keys"]],a="esc cancel";if(!e.options.find)s=s.filter(([l])=>l!=="p");if(e.notice)o=t.color?`\x1B[33m${e.notice}\x1B[39m`:e.notice,s=[];let c=i?t.color?`\x1B[7;1m${r} ${i} \x1B[0m `:`[${i}] `:"",u=a?`${t.bold(a.split(" ")[0])} ${t.dim(a.split(" ").slice(1).join(" "))}`:"";for(;;){let l=[o,...s.map(([d,m])=>`${t.bold(d)} ${t.dim(m)}`)].filter(Boolean),f=`${c}${l.join(" ")}`;if(tt(f)+tt(a)+3<=n||s.length<=1)return a?pe(f,u,n):Et(f,n);s=[...s.slice(0,-2),...s.slice(-1)]}}var cd=50,ud=22;function Z0(t){let e=t.notice??"";if(t.typing!==void 0)return{mode:"type",keys:[["enter","set"],["ctrl+u","clear"],["esc","back"]],note:e};if(t.compare)return{mode:"compare",keys:[["space","back to yours"],["esc","back"]],note:e};if(t.mode==="tune")return{mode:"tune",keys:[["↑↓","lightness, chroma, hue"],["←→","step"],["⇧←→","×5"],["0-9","jump"],["enter","keep"],["esc","undo"]],note:e};return{mode:"list",keys:[["↑↓←→","slot"],["enter","tune"],["r","reset slot"],["R","reset all"],["#","type a color"],["space","before"]],note:e}}function _N(t,e,n,r){let i=e.slot(),o=e.list[i],s=e.lch[i],a=ft(o),c=e.start[i],u=e.original[i],{name:l,about:f}=hs(i),d=e.signature.includes(zi[i]),m=t.color?`${t.fg(o)}${"█".repeat(4)}\x1B[39m `:"",g=e.typing!==void 0?t.bold(`${e.typing}▏`):void 0,$=[c!==o?`was ${t.color?`${t.fg(c)}■\x1B[39m `:""}${c}`:"",u!==o?`default ${t.color?`${t.fg(u)}■\x1B[39m `:""}${u}`:""].filter(Boolean),w=[pe(`${t.bold(l)} ${t.dim(f)}`,d?t.dim("◆ signature"):"",n),`${m}${g??t.bold(o)} ${t.dim(`oklch ${a.l.toFixed(3)} ${a.c.toFixed(3)} ${a.h.toFixed(0)}°`)}`,...r>=7?[`${m}${t.dim($.length>0?$.join(" "):"as the palette has it")}`]:[]],b=Math.max(8,Math.min(40,n-12));ur.forEach((R,S)=>{let I=e.mode==="tune"&&S===e.channel,P=s[R.key],O=`${P.toFixed(R.digits)}${R.wraps?"°":""}`.padStart(6),F=od(t,J0(s,R,b),sd(P,R.min,R.max,b),I),j=R.key.toUpperCase();w.push(`${I?t.bold(`▸${j}`):t.dim(` ${j}`)} ${F} ${I?t.bold(O):t.dim(O)}`)});let v=ed(e.list,e.signature,e.waive,i);if(a.c<s.c-0.005)v.push({ok:void 0,text:`Chroma held at the sRGB edge — ${a.c.toFixed(3)} of ${s.c.toFixed(3)}`});for(let R of v)for(let[S,I]of kt(R.text,n-2).entries()){if(w.length>=r)return w;w.push(`${S===0?ad(t,R.ok):" "} ${R.ok===!1?I:t.dim(I)}`)}return w}function Q0(t,e,n,r,i){let o=q0(r),s=t.failing().length,a=s===0?"passes the gate":`${s} ${s===1?"miss":"misses"} in the gate`,c=t.list.filter((g,$)=>t.offDefault($)).length,u=pe(`${i?o.bold("Palette"):o.dim("Palette")}${c>0?o.dim(` ${c} off its default`):""}`,o.dim(a),e-2),l=D0(o,t,0,e,i).slice(1,-2),f=[` ${u}`,...l],d=t.row<Kt.length?t.row+2:t.row+4;if(n-f.length>=9)f.push("");let m=n-f.length;if(m>=5){let g=f.length;if(f.push(..._N(o,t,e-2,m).map(($)=>` ${$}`)),t.mode==="tune")d=g+3+(m>=7?1:0)+t.channel;else if(t.typing!==void 0)d=g+2}return{lines:Array.from({length:n},(g,$)=>Et(f[$]??"",e)),at:d}}function BN(t,e,n,r){let i=q0(r);if(e<rd||n<id){let g=[i.bold("ttheme palette editor"),`Needs ${rd}×${id} — now ${e}×${n}`,i.dim("esc cancels")];return Array.from({length:n},($,w)=>Et(g[w]??"",e))}let o=t.failing().length,s=o===0?"✓ Passes the gate":`✗ ${o} ${o===1?"miss":"misses"} in the gate`,a=t.pictures>0?i.dim(`▣ ${t.pictures} ${t.pictures===1?"picture":"pictures"} `):"",c=`${t.dirty()?`${i.color?"\x1B[33m●\x1B[39m":"●"} unsaved `:""}${a}${i.dim(s)}`,l=`${i.fg(t.list[2])}◆${i.color?"\x1B[39m":""} ${i.bold(t.options.title)} ${i.dim(`· ${t.options.name}`)}`,f=n-4,d;if(t.overlay==="keys")d=GN(i,t,e);else if(t.overlay==="open")d=UN(i,t,e,f);else{let g=e-ps-2,$=t.mode==="seeds"?TN(i,t,f):D0(i,t,f),w=t.mode==="seeds"?CN(i,t,g,f):AN(i,t,g,f);d=Array.from({length:f},(b,v)=>`${Et($[v]??"",ps)}${i.dim("│")} ${Et(w[v]??"",g)}`)}let m=[pe(l,c,e),""];for(let g=0;g<f;g++)m.push(Et(d[g]??"",e));return m.push("",WN(i,t,e)),m}async function X0(t,e){let n=new gs(t),{stdin:r,stdout:i}=process,o=i.columns||rd,s=i.rows||id,a=[],c=[],u="",l="",f,d=(S)=>i.write(S),m=()=>{if(f=void 0,e.look){let I=n.shown();if(I.join(" ")!==u)u=I.join(" "),e.look(I);return}let S="";if(n.shown().forEach((I,P)=>{if(c[P]!==I&&e.only?.includes(P))S+=Fl(P,I),c[P]=I}),S)d(S)},g=()=>{let S=BN(n,o,s,e.color),I="";if(S.forEach((P,O)=>{if(a[O]!==P)I+=`\x1B[${O+1};1H\x1B[0m\x1B[2K${P}`}),a=S,I)d(`\x1B[?2026h${I}\x1B[0m\x1B[?2026l`);if(e.only||e.look)f??=setTimeout(m,33)},$,w,b=!1,v=()=>{d(`\x1B[?1049h\x1B[?25l\x1B[?7l\x1B[?2004h${Ii}`),r.setRawMode(!0),r.resume()},R=(S)=>{if($&&w)r[S?"on":"off"]("data",$),i[S?"on":"off"]("resize",w)};v();try{return await new Promise((S)=>{let I=async(P)=>{let O=t.find;if(!O)return;b=!0,R(!1),clearTimeout(f),f=void 0;try{n.found(await O(n.edited(),P))}catch(F){n.notice=F instanceof Error?F.message:String(F)}b=!1,v(),R(!0),o=i.columns||o,s=i.rows||s,a=[],c.length=0,u="",g()};w=()=>{o=i.columns||o,s=i.rows||s,a=[],d(Ii),g()},$=(P)=>{l+=P.toString("utf8");let O=dc(l);l=O.pending;for(let j of O.events)if(j.kind==="paste")n.paste(j.text);if(O.keys.length>8&&/^(?:\/|~\/|file:|https?:)/.test(O.keys)&&n.typing===void 0)n.paste(O.keys);else for(let j of gc(O.keys))if(n.press(j),n.result||n.wants)break;if(n.result){S(n.result==="saved"?n.edited():void 0);return}let F=n.wants;if(F&&!b){n.wants=void 0,I(F.start);return}g()},R(!0),g()})}finally{clearTimeout(f),R(!1),r.setRawMode(!1),r.pause(),d("\x1B[?2004l\x1B[?7h\x1B[?25h\x1B[?1049l")}}import{spawn as cR}from"node:child_process";import{createHash as k$}from"node:crypto";import{existsSync as Ki,mkdirSync as uR,mkdtempSync as lR,readFileSync as y$,rmSync as bs,statSync as fR}from"node:fs";import{homedir as dR,tmpdir as hR}from"node:os";import{dirname as mR,join as Pe}from"node:path";import{pathToFileURL as u$}from"node:url";var zN=new Set(["comic","4koma","monochrome","greyscale","sketch","lineart","speech_bubble"]),KN=new Set(["scenery","landscape","scenic","no_humans","wide_shot","very_wide_shot"]),qN=0.04,JN=0.1,YN=0.05,DN=4096;function VN(t){return new Set(t.cutouts.split(/\s+/).map((e)=>e.replace(/^~/,"")).filter(Boolean))}function ZN(t,e,n,r=0){let{site:i,post:o}=t,s=new Set(o.tags),a=[...VN(i)].some((l)=>s.has(l)),c=Math.min(o.width,o.height),u=o.width>0&&o.height>0?o.width/o.height/(e.w/e.h):1;return(o.solo?2:0)+([...zN].some((l)=>s.has(l))?-3:0)+([...KN].some((l)=>s.has(l))?-1.5:0)+2*Math.min(1,c/e.h)+(a?1.5:-Math.min(1.5,Math.abs(Math.log(u))))+(n>0?1.5*Math.log1p(Math.max(0,o.score))/Math.log1p(n):0)+2*r}function vc(t,e,n=new Map){let r=new Map;for(let{site:i,post:o}of t)r.set(i,Math.max(r.get(i)??0,o.score));return t.map((i,o)=>({pick:i,at:o,score:ZN(i,e,r.get(i.site)??0,n.get(i.post))})).sort((i,o)=>o.score-i.score||i.at-o.at).map(({pick:i})=>i)}function e$(t){let e=new Map;for(let r of t)e.set(r.site,[...e.get(r.site)??[],r]);let n=[];for(let r=0;n.length<t.length;r++)for(let i of e.values()){let o=i[r];if(o)n.push(o)}return n}function ld(t){let e=t/255;return e<=0.04045?e/12.92:((e+0.055)/1.055)**2.4}function t$(t,e,n){let[r,i,o]=[ld(t),ld(e),ld(n)],s=Math.cbrt(0.4122214708*r+0.5363325363*i+0.0514459929*o),a=Math.cbrt(0.2119034982*r+0.6806995451*i+0.1073969566*o),c=Math.cbrt(0.0883024619*r+0.2817188376*i+0.6299787005*o);return[0.2104542553*s+0.793617785*a-0.0040720468*c,1.9779984951*s-2.428592205*a+0.4505937099*c,0.0259040371*s+0.7827717662*a-0.808675766*c]}function n$(t,e){let n=e.map((s)=>t$(...nt(s))).filter(([,s,a])=>Math.hypot(s,a)>=qN);if(n.length===0)return 0;let r=Math.max(1,Math.floor(Math.sqrt(t.width*t.height/DN))),i=n.map(()=>0),o=0;for(let s=0;s<t.height;s+=r)for(let a=0;a<t.width;a+=r){let c=(s*t.width+a)*4;if(t.data[c+3]<128)continue;o++;let[u,l,f]=t$(t.data[c],t.data[c+1],t.data[c+2]);n.forEach(([d,m,g],$)=>{if(Math.hypot(u-d,l-m,f-g)<JN)i[$]=i[$]+1})}if(o===0)return 0;return i.reduce((s,a)=>s+Math.min(1,a/o/YN),0)/n.length}import{mkdirSync as eR,readFileSync as dd,writeFileSync as a$}from"node:fs";import{dirname as nR}from"node:path";import{isMainThread as rR,parentPort as c$,Worker as iR}from"node:worker_threads";var QN=/(?:^|[^0-9a-f])([0-9a-f]{32})(?:[^0-9a-f]|$)/i,XN=[[/yande\.re\/post\/show\/(\d+)/,"yande"],[/konachan\.(?:com|net)\/post\/show\/(\d+)/,"konachan"],[/danbooru\.donmai\.us\/(?:posts|post\/show)\/(\d+)/,"danbooru"],[/zerochan\.net\/(\d+)(?:[?#\s]|$)/,"zerochan"]];function fd(t){let e=/(\d+)_p(\d+)/.exec(t.source);return[...t.md5?[`md5:${t.md5}`]:[],...e&&t.source.includes("pximg")?[`pixiv:${e[1]}_p${e[2]}`]:[]]}function r$(t,e){let n=QN.exec(e.source)?.[1]?.toLowerCase();return[`post:${t.key}:${e.id}`,...e.md5?[`md5:${e.md5}`]:[],...n&&n!==e.md5?[`md5:${n}`]:[],...XN.flatMap(([r,i])=>{let o=r.exec(e.source)?.[1];return o?[`post:${i}:${Number(o)}`]:[]}),...e.family?[`family:${t.key}:${e.family}`]:[]]}function i$(t,e){let n=t.owner||t.named.artist[0]||"";return n!==""&&n===(e.owner||e.named.artist[0]||"")&&t.width===e.width&&t.height===e.height}function o$(t){let r=[];for(let o=0;o<8;o++){let s=Math.floor(o*t.height/8),a=Math.max(s+1,Math.floor((o+1)*t.height/8));for(let c=0;c<9;c++){let u=Math.floor(c*t.width/9),l=Math.max(u+1,Math.floor((c+1)*t.width/9)),f=0;for(let d=s;d<a;d++)for(let m=u;m<l;m++){let g=(d*t.width+m)*4,$=t.data[g+3]/255,w=0.299*t.data[g]+0.587*t.data[g+1]+0.114*t.data[g+2];f+=w*$+255*(1-$)}r.push(f/((l-u)*(a-s)))}}let i=0n;for(let o=0;o<8;o++)for(let s=0;s<8;s++)i=i<<1n|(r[o*9+s]>r[o*9+s+1]?1n:0n);return i.toString(16).padStart(16,"0")}function tR(t,e){let n=BigInt(`0x${t}`)^BigInt(`0x${e}`),r=0;while(n>0n)r+=Number(n&1n),n>>=1n;return r}function s$(t,e){if(t.width<=0||t.height<=0||e.width<=0||e.height<=0)return!1;return Math.abs(Math.log(t.width/t.height/(e.width/e.height)))<0.01&&tR(t.hash,e.hash)<=2}var oR={thumb:"tile",band:"band",match:"tile",show:"view",backdrop:"view",redraw:"view"},Ec;async function sR(t){if(t.job==="redraw")return ec(t.home,t.name,t.key,t.paint,t.blur,t.aligns,t.user);if(t.job==="show"){if(Ec?.from!==t.from){let s=Pn(new Uint8Array(dd(t.from)),Vt);Ec={from:t.from,clear:an(s),inked:al(s)}}let{image:r,fill:i,opacity:o}=fp(Ec.inked,t.colors,t.tone,t.width,t.height,t.blur,t.tune,t.coloring);return eR(nR(t.to),{recursive:!0}),a$(t.to,Ce(r)),{clear:Ec.clear,fill:i,opacity:o}}let e=Pn(new Uint8Array(dd(t.from)),Vt);if(t.job==="backdrop"){da(t.home,t.colors,t.tone,e,{...t.origin,bytes:new Uint8Array(dd(t.source)),cut:t.from!==t.source},t,t.blur,t.coloring);let r=t.tune&&fe(t.home,t.colors.name).find((i)=>i.key===Wt(t.origin));if(t.tune&&r)Eo(X(t.home),r,t.tune,t.aligns??!0,t.user??t.home);return 0}if(t.job==="match")return{match:n$(e,t.colors),hash:o$(e)};if(t.job==="thumb")return T(t.to,Ce(Dm(e,t.width,t.height))),0;let n=e.data.subarray(t.y*e.width*4,(t.y+t.height)*e.width*4);return a$(t.to,Ce({width:e.width,height:t.height,data:n})),0}function aR(t){t.on("message",async(e)=>{try{t.postMessage({id:e.id,value:await sR(e)})}catch(n){t.postMessage({id:e.id,error:n instanceof Error?n.message:String(n)})}})}class hd{worker;next=1;waiting=new Map;send(t){let e=this.next++;return new Promise((n,r)=>{let i=this.open();this.waiting.set(e,{ok:n,no:r}),i.ref(),i.postMessage({...t,id:e})})}close(){this.worker?.terminate(),this.worker=void 0,this.drop(Error("renderer closed"))}open(){if(this.worker)return this.worker;let t=new iR(import.meta.filename);t.unref(),t.on("message",({id:n,value:r,error:i})=>{let o=this.waiting.get(n);if(this.waiting.delete(n),this.waiting.size===0)t.unref();if(i!==void 0)o?.no(Error(i));else o?.ok(r)});let e=(n)=>{if(this.worker===t)this.worker=void 0;this.drop(n instanceof Error?n:Error("renderer stopped"))};return t.on("error",e),t.on("exit",()=>e(void 0)),this.worker=t,t}drop(t){for(let e of this.waiting.values())e.no(t);this.waiting.clear()}}class md{lines=new Map;run(t){let e=oR[t.job],n=this.lines.get(e);if(!n)n=new hd,this.lines.set(e,n);return n.send(t)}close(){for(let t of this.lines.values())t.close();this.lines.clear()}}class gd{lines;constructor(t){this.lines=Array.from({length:Math.max(1,t)},()=>new hd)}async map(t){let e=[],n=0;return await Promise.all(this.lines.map(async(r)=>{while(n<t.length){let i=n++;try{e[i]=await r.send(t[i])}catch(o){e[i]=o instanceof Error?o:Error(String(o))}}})),e}close(){for(let t of this.lines)t.close()}}if(!rR&&c$)aR(c$);var _r=[{name:"TTHEME_FIND_RATING",label:"Rating",about:"The ratings to list, each site read in its own words — space ticks one, and one stays ticked",choices:ai,multi:{read:Sr}},{name:"TTHEME_FIND_BLOCK",label:"Block",about:"Posts tagged with nudity or underwear are left out — space unticks one",choices:Er,multi:{read:ui,none:"none"}},{name:"TTHEME_FIND_POSTS",label:"Posts",about:"Every post of the character, or only the transparent cutouts",choices:["all","cutouts"]},{name:"TTHEME_FIND_SOLO",label:"Solo",about:"When on, only the posts known to show the character alone — checked as posts arrive, so the counts below leave it out",choices:["on","off"]},{name:"TTHEME_FIND_ORDER",label:"Order",about:"How posts are ranked: fit, by how well each makes a backdrop; newest; or score",choices:["fit","newest","score"]},{name:"TTHEME_FIND_SETS",label:"Sets",about:"One picture posted over and over, or held by another site too: fold it into one tile, or show each",choices:["fold","show"]},...Fi()?[{name:"TTHEME_FIND_REMOVE_BG",label:"Remove bg",about:"Cut the character out of an opaque picture you try on, with macOS Vision",choices:["on","off"]}]:[],{name:"TTHEME_FIND_MIN_SCORE",label:"Min score",about:"Posts scored at least this — danbooru, konachan and yande.re; zerochan keeps no score. ←→ steps, or type any number",choices:hg,entry:"number",advanced:!0},{name:"TTHEME_FIND_MIN_SIZE",label:"Min size",about:"The shorter side of a picture, in px — every site filters it. ←→ steps, or type any number",choices:mg,entry:"number",advanced:!0},{name:"TTHEME_FIND_SITES",label:"Sites",about:"The sites the all tab mixes — each keeps its own tab. Space ticks one, and one stays ticked",choices:q.map((t)=>t.name),multi:{read:uo},advanced:!0},{name:"TTHEME_FIND_HIDE",label:"Hide",about:"Comics, monochrome, sketches or chibi, told by tag in every site's spelling — checked as posts arrive",choices:Gu,multi:{read:Js,none:"none"},advanced:!0},{name:"TTHEME_FIND_HIDE_TAGS",label:"Hide tags",about:"Posts with any of these tags are left out, spaced like cosplay multiple_girls — checked as posts arrive",choices:[],entry:"text",advanced:!0},{name:"TTHEME_FIND_PNG",label:"PNG only",about:"PNG originals only — danbooru counts it, the others are told by the file; zerochan only where danbooru holds it",choices:["off","on"],advanced:!0}];function l$(t,e){if(t.multi)return t.multi.read(e).join(" ")||t.multi.none;if(t.entry==="number")return/^\d+$/.test(e??"")&&Number(e)>0?String(Number(e)):"off";if(t.entry==="text")return lo(e).join(" ");return t.choices.find((n)=>n===e)??t.choices[0]}var gR=["fit","newest","score"];function pd(t){return gR.find((e)=>e===t)??"fit"}var pR={left:-1,right:1,"shift-left":-10,"shift-right":10};function bR(t){let e=/^(\d+) (\d+)$/.exec(t??"");return e&&(Number(e[1])>0||Number(e[2])>0)?{x:Number(e[1]),y:Number(e[2])}:void 0}var bd=bR(process.env.TTHEME_BG_MARGIN);function wR(t,e,n){if(e<0){if(t!=="fill")return Math.max(g$,t+e);if(!n)return t;return Math.max(g$,Math.max(100,n)+e+1)}return t==="fill"||t+e>n?"fill":t+e}function v$(t,e){return t.size===e.size&&t.at===e.at&&t.opacity===e.opacity}function $R(t,e){if(v$(t,e))return;return{...t.size!=="fill"?{size:t.size}:{},...t.at!==e.at?{position:Qt[t.at-1]}:{},...t.opacity!==e.opacity?{opacity:t.opacity}:{}}}function kR(t){return t.length>=2&&!/^\d+$/.test(t)&&!t.includes("://")&&!/^[\w.]+:\d+$/.test(t)}var f$=12,yR=4,vR=150,ER=300,d$=12,SR=2,MR=150,IR=30,OR=4000,NR=8000,h$=/\.(png|jpe?g|gif|webp|heic|tiff?|bmp)$/i,RR=process.platform==="win32"?"alt+v":"ctrl+v",m$=process.platform==="darwin"?"ctrl+shift+cmd+4 copies a screenshot":"copy a picture first",PR=1280,HR=16,FR=Qt.indexOf("top-right")+1,g$=20,qi=2147483645,ws=2147483646,p$=-1073741827,xR=-1073741828,b$=2,LR=80,TR=16,AR=0.4,CR=3221225472,jR=256,GR=3,UR=8,WR=9;function Sc(t,e){return{key:t,groups:[],sources:[],queue:[],rounds:0,roundOf:new Map,last:new Map,kin:new Map,kindred:new Map,shapes:[],seen:new Set,same:new Map,checked:0,total:0,focus:0,top:0,searching:e,stage:"fetch",arrived:new Set}}function $s(t){if(!(t instanceof Error))return String(t);if(t instanceof AggregateError&&t.errors[0])return $s(t.errors[0]);if(t.cause)return $s(t.cause);let e=t.code;if(typeof e==="string")return e;let n=(t.message||t.name).split(".")[0]??"";return n.length>56?`${n.slice(0,55)}…`:n}function wd(t,e){return`${t}: ${$s(e)}`}function w$(t){return t.width*t.height}function $$(t,e){return`${t}-${k$("sha1").update(e).digest("hex").slice(0,8)}`}function _R(t){let e=t.lastIndexOf("\x1B");return e!==-1&&/^\[?[0-9;]*$/.test(t.slice(e+1))}function BR(t,e){try{return JSON.parse(y$(Pe(Ge(t),e),"utf8"))}catch{return{}}}function zR(t,e,n){T(Pe(Ge(t),e),`${JSON.stringify(n)}
522
- `)}class $d{view;tone;session=new AbortController;cell={w:0,h:0};cols=process.stdout.columns||80;rows=process.stdout.rows||24;gen=0;pumping=0;boards=new Map;board;posts=new Map;thumbPath=new Map;looking=new Map;looked=new Map;matched=new Map;aheading=!1;pages=new Map;tab=0;values=new Map(_r.map((t)=>[t.name,l$(t,process.env[t.name])]));direction=1;prefetching=0;inflight=new Map;owners=new Map;kept=new Map;related=new Map;pool=[];relating;unsaved=new Set;crediting=new Map;thumbQueue=[];thumbing=0;clarity=new Map;tunedFiles=[];presenting=!1;again=!1;covered="";renders=new md;sent=new Map;placed=new Map;screen=[];ticking;gliding;showing;thumbless=new Set;bands=pb(process.env);files=bb(process.env);moves=$b(process.env);layers=wb(process.env);bandFiles=new Map;nextBand=CR;current;fetch;settle;partial;suggestTimer;suggesting;countTimer;counting;input="";typed="";grabber=new Kf((t)=>this.write(t),(t)=>void this.got(t));featureWait;noticeTimer;peekTimer;peeked;attaching;probeWait;done;dirty=!1;scratch=lR(Pe(hR(),"ttheme-find-"));home;catalog;entry;blurring;start;constructor(t,e,n,r,i){this.start=i,this.home=t,this.catalog=e,this.entry=n,this.tone=Un(n,n.signatureSlots),this.blurring=er(t);let o={size:"fill",at:FR,opacity:this.tone.opacity};this.view={palette:n.name,tag:r,site:this.tabName,siteAnsi:this.tabAnsi,nextSite:this.nextTabName,preset:this.setting("TTHEME_FIND_POSTS")==="all"?"all":"cutouts",order:pd(this.setting("TTHEME_FIND_ORDER")),solo:this.setting("TTHEME_FIND_SOLO")==="on",rating:Sr(this.setting("TTHEME_FIND_RATING")),block:ui(this.setting("TTHEME_FIND_BLOCK")),sets:this.setting("TTHEME_FIND_SETS")==="show"?"show":"fold",narrow:this.narrowed(),enabled:uo(this.setting("TTHEME_FIND_SITES")),hide:Js(this.setting("TTHEME_FIND_HIDE")),hideTags:lo(this.setting("TTHEME_FIND_HIDE_TAGS")),advanced:!1,settings:_r.map((s)=>({label:s.label,choices:[...s.choices],value:this.setting(s.name),default:l$(s,To(s.name)),multi:s.multi&&{none:s.multi.none},about:s.about,entry:s.entry,advanced:s.advanced,cursor:0})),colors:{cursor:n.cursor,selection:n.selection,background:n.background,foreground:n.foreground,ansi:n.ansi},tiles:[],installed:[],checked:0,total:0,searching:r!=="",stage:"fetch",sites:[],focus:0,top:0,scroll:0,beat:0,mode:"grid",help:!1,scene:Math.max(0,de.findIndex((s)=>s.name.toLowerCase()===process.env.TTHEME_SCENE)),details:!1,tune:{...o},untuned:o,coloring:Ra(t),editing:r===""?"":void 0,chips:[]},this.pool=this.selected(this.view),this.syncChips(),this.board=Sc(this.boardKey,r!==""),this.boards.set(this.board.key,this.board)}get signal(){return this.session.signal}get site(){return this.tab===0?void 0:q[this.tab-1]}get sites(){return this.site?[this.site]:q.filter((t)=>this.view.enabled.includes(t.name))}get tabName(){return this.site?.name??"all"}get tabAnsi(){return this.site?.ansi??yR}get nextTabName(){let t=(this.tab+1)%(q.length+1);return t===0?"all":q[t-1].name}frame(){return{w:this.cols*(this.cell.w||10),h:this.rows*(this.cell.h||20)}}setting(t){return this.values.get(t)}narrowed(){return Wu(this.setting("TTHEME_FIND_MIN_SCORE"),this.setting("TTHEME_FIND_MIN_SIZE"),this.setting("TTHEME_FIND_PNG"))}get boardKey(){return`${this.site?.key??"all"}|${this.view.preset}|${this.view.order}`}origPath(t,e,n){return Pe(Ge(t),"orig",`${e}.${n}`)}previewPath(t){let{url:e}=Ds(t.site,t.post);return Pe(Ge(t.site),"thumb",`${$$(t.post.id,e)}.${Ln(e)}`)}tileOf(t,e){let{site:n,post:r}=t,i=le(n,r.id),o=je(r)??r;return{id:r.id,key:i,site:n.name,siteAnsi:n.ansi,width:o.width,height:o.height,reduced:o!==r,page:n===Cr?"":n.pageUrl(r.id),artist:n===Cr?u0(r.source):r.named.artist[0]??"",score:r.score,variants:e,mates:this.owners.get(n.key)?.get(r.owner)??[],thumb:this.thumbPath.get(i),missing:this.thumbless.has(i)}}show(){let t=this.view,e=this.board;if(t.tiles=e.groups.flatMap((n)=>n.open?n.posts.map((r)=>this.tileOf(r,0)):[this.tileOf(n.posts[0],n.posts.length)]),t.checked=e.checked,t.total=e.total,t.searching=e.searching,this.stageOf(e),t.note=e.note,t.focus=Math.max(0,Math.min(e.focus,t.tiles.length-1)),t.top=e.top,this.showing!==e)this.showing=e,this.snap()}stageOf(t){let e=this.view;e.stage=t.stage,e.ranking=t.ranking,e.sites=this.sites.map((n)=>({name:n.name,arrived:t.arrived.has(n.name)}))}syncSite(){let t=this.view;t.site=this.tabName,t.siteAnsi=this.tabAnsi,t.nextSite=this.nextTabName}async run(){let{stdin:t,stdout:e}=process;t.setRawMode(!0),t.resume(),t.on("data",this.onData),e.on("resize",this.onResize),this.write(`\x1B[?25l\x1B[?7l${Ii}`);let n=new Promise((s)=>{this.done=s}),r=setInterval(this.onClock,250),i=await this.probe();if(i){if(this.cell=i,this.view.tag)this.search(),this.relate(this.view.tag)}else this.view.searching=!1,this.view.error="This terminal does not report its cell size — find needs kitty graphics";if(await this.features(),this.grabber.start(),this.write("\x1B[?1004h"),this.start&&"paste"in this.start)this.pasted(this.start.paste);else if(this.start)this.fromClipboard();else this.peek();this.draw();let o=await n;return this.session.abort(),this.grabber.stop(),this.write("\x1B[?1004l"),this.attaching?.abort(),clearTimeout(this.noticeTimer),clearTimeout(this.peekTimer),this.fetch?.abort(),clearTimeout(this.settle),clearTimeout(this.partial),this.quietSuggest(),this.quietCount(),clearInterval(r),clearInterval(this.ticking),clearTimeout(this.gliding),t.off("data",this.onData),e.off("resize",this.onResize),this.write(`\x1B_Ga=d,d=A,q=2\x1B\\${Ii}`),t.setRawMode(!1),t.pause(),this.saveKept(),this.renders.close(),bs(this.scratch,{recursive:!0,force:!0}),Og(),o}write(t){process.stdout.write(t)}get saved(){return this.view.saved?.text}get installs(){return this.view.installed.length}finish(t){this.done?.(t===2&&this.saved?0:t)}probe(){return new Promise((t)=>{let e=setTimeout(()=>{this.probeWait=void 0,t(null)},1000);this.probeWait=(n)=>{clearTimeout(e),this.probeWait=void 0,t(n)},this.write(O0)})}onData=(t)=>{this.input+=t.toString("utf8");for(let n=Vf(this.input);n;n=Vf(this.input))this.input=n.rest,this.probeWait?.(n.cell);if(this.probeWait)return;let e=dc(this.input);if(this.input=e.pending,this.view.editing===void 0&&e.keys.length>8&&/^(?:\/|~\/|file:|https?:)/.test(e.keys))this.pasted(e.keys),e.keys="";this.typed+=e.keys;for(let n of e.events)this.inbound(n);if(clearTimeout(this.partial),_R(this.typed)){this.partial=setTimeout(this.flushKeys,IR);return}this.flushKeys()};flushKeys=()=>{let t=gc(this.typed);this.typed="";for(let e of t)this.key(e)};features(){if(process.env.TMUX)return Promise.resolve();return new Promise((t)=>{let e=setTimeout(()=>{this.featureWait=void 0,t()},500);this.featureWait=()=>{clearTimeout(e),this.featureWait=void 0,t()},this.write("\x1B[?5522$p\x1B]72;t=q\x1B\\\x1B[c")})}inbound(t){if(t.kind==="mode"){if(t.mode===5522)this.grabber.clipboard=t.value!==0&&t.value!==4;return}if(t.kind==="attributes"){this.featureWait?.();return}if(t.kind==="osc"){if(t.code==="72"&&t.meta.t==="q"){this.grabber.drops=!0;return}this.grabber.take(t);return}this.pasted(t.text)}pasted(t){let e=this.view;if(e.editing!==void 0&&t.trim()!==""&&!this.picture(t)){e.editing+=t.replace(/[\r\n]+/g," "),this.suggest(),this.draw();return}if(e.installing!==void 0||e.panel!==void 0||e.help)return;if(t.trim()===""){this.fromClipboard();return}this.attach(t)}picture(t){let e=t.trim();if(/^https?:\/\/\S+$/i.test(e))return!Ys(e,this.site??q[0]);return ji(e).length>0}async got(t){if(t.kind==="error"){this.notice(t.message);return}if(t.kind==="text"){if(t.text.trim()===""){this.notice(`No picture on the clipboard — ${m$}`);return}this.pasted(t.text);return}await this.bring(()=>lc(t.bytes,t.source))}notice(t,e=OR){let n=this.view;n.error=t,clearTimeout(this.noticeTimer),this.noticeTimer=setTimeout(()=>{if(n.error===t)n.error=void 0,this.draw()},e),this.draw()}async peek(){let t=this.view,e;try{e=await m0()}catch{return}if(!e||e.stamp===this.peeked)return;if(this.peeked=e.stamp,!e.picture||t.installing!==void 0)return;t.hint=`Picture on the clipboard · ${RR} uses it`,clearTimeout(this.peekTimer),this.peekTimer=setTimeout(()=>{t.hint=void 0,this.draw()},NR),this.draw()}async fromClipboard(){let t=this.view;if(zf()){if(this.grabber.clipboard){this.grabber.ask();return}this.notice("Over SSH the clipboard is not here — drop the file");return}let e;try{e=await h0(Pe(this.scratch,`clipboard-${Date.now()}.png`))}catch(r){this.notice(`Could not read the clipboard: ${$s(r)}`);return}if(clearTimeout(this.peekTimer),t.hint=void 0,"image"in e){await this.bring(async(r)=>({...await Bf(e.image,r),source:"clipboard"}));return}let n=e.text.trim();if(!n){this.notice(`No picture on the clipboard — ${m$}`);return}if(this.picture(n)){await this.attach(n);return}if(t.editing===void 0)t.editing="";this.pasted(n)}async attach(t){let e=t.trim();if(/^https?:\/\//i.test(e)){let i=Ys(e,this.site??q[0]);if(i){await this.jump(i.site,i.id);return}}let[n,...r]=ji(e).sort((i,o)=>Number(!h$.test(i))-Number(!h$.test(o)));if(!n){this.notice("Nothing to use in that — drop a picture, or paste one or its link");return}await this.bring((i)=>Bf(n,i),r.length)}async bring(t,e=0){let n=this.view;this.attaching?.abort();let r=new AbortController;this.attaching=r,n.error=void 0,n.saved=void 0,n.note="Reading the picture…",this.draw();let i;try{i=await t(AbortSignal.any([r.signal,this.signal]))}catch(d){if(!r.signal.aborted)n.note=void 0,this.notice($s(d),8000);return}if(r.signal.aborted)return;n.note=e>0?`The first picture of ${e+1} — drop one at a time to try the others`:void 0,this.quietSuggest(),n.editing=void 0,n.suggest=void 0,n.pick=void 0;let o=f0(i.bytes);l0(o,i.source);let s=this.origPath(Cr,o,i.ext);T(s,i.bytes);let a=u$(s).href,c={id:o,file:a,width:i.width,height:i.height,ext:i.ext,preview:a,owner:"",score:0,rating:"s",md5:k$("md5").update(i.bytes).digest("hex"),source:i.source,tags:[],named:{artist:[],character:[],copyright:[]},solo:void 0,family:0,smaller:[]},u={site:Cr,post:c},l=this.previewPath(u);T(l,i.bytes),++this.gen,this.current=void 0,n.shown=void 0;let f=Sc(`local|post:${o}`,!1);this.board=f,this.boards.set(f.key,f),this.single(f,u)}single(t,e){t.searching=!1,this.posts.set(le(e.site,e.post.id),e),t.groups=[{posts:[e],open:!1}],t.checked=1,t.total=1,this.thumbQueue.push(e),this.thumbs(),this.view.mode="try",this.show(),this.select(),this.draw()}onClock=()=>{let t=this.sites.reduce((r,i)=>un(i)>un(r)?i:r),e=Math.ceil((un(t)-Date.now())/1000),n=e>0?e:void 0;if(n!==this.view.waiting)this.view.waiting=n,this.view.slow=t.name,this.draw()};onResize=()=>{if(this.cols=process.stdout.columns||this.cols,this.rows=process.stdout.rows||this.rows,this.screen=[],this.scroll(),this.snap(),this.view.mode==="try"&&this.current)this.reveal();this.pump(),this.draw()};key(t){let e=this.view;if(t==="ctrl-c"){this.finish(2);return}if(e.installing!==void 0)return;if(t==="focus-in"){this.peek();return}if(t==="focus-out"||t==="nop")return;if((t==="ctrl-v"||t==="alt-v")&&e.panel===void 0){this.fromClipboard();return}if(e.editing!==void 0){this.editKey(t);return}if(e.panel!==void 0){this.panelKey(t);return}if(e.help){if(t==="?"||t==="esc")e.help=!1,this.draw();return}if(this.cols<Gr.cols||this.rows<Gr.rows){if(t==="esc")this.finish(2);return}if(t==="?"){e.help=!0,this.draw();return}if(e.mode==="try"){this.tryKey(t);return}this.gridKey(t)}gridKey(t){let e=this.view,{perRow:n,rowsVis:r}=Ur(this.cols,this.rows),o={left:-1,right:1,up:-n,down:n,k:-n,j:n,pgup:-n*r,pgdn:n*r,home:-e.focus,end:e.tiles.length}[t];if(o!==void 0){this.focus(e.focus+o);return}if(/^[1-9]$/.test(t)){this.toggle(Number(t)-1);return}if(t==="enter"&&e.tiles[e.focus]){e.mode="try",e.error=void 0,this.select();return}if(t==="v"){this.fromClipboard();return}if(t==="c"){e.preset=e.preset==="cutouts"?"all":"cutouts",this.turn();return}if(t==="tab"||t==="shift-tab"){let s=q.length+1;this.tab=(this.tab+(t==="tab"?1:s-1))%s,this.syncSite(),this.turn();return}if(t==="/"){e.editing="",this.draw();return}if(t===" "){this.unfold();return}if(t==="o"){this.openPage();return}if(t==="s"){e.panel=0,e.advanced=!1,this.recount(),this.draw();return}if(t==="esc")this.finish(2)}panelKey(t){let e=this.view,n=e.panel??0,r=e.settings[n];if(e.typing!==void 0&&r){this.typeKey(r,t);return}let i=us(e);if(t==="up"||t==="down"){let o=i.indexOf(n)+(t==="up"?-1:1);e.panel=i[(o+i.length)%i.length]??n,this.draw();return}if(t==="a"||t==="enter"&&n===e.settings.length){e.advanced=!e.advanced,e.panel=us(e)[0]??0,this.draw();return}if(r?.entry&&(t==="enter"||r.entry==="number"&&/^[0-9]$/.test(t))){e.typing=t==="enter"?r.entry==="text"?r.value:"":t,this.draw();return}if((t==="left"||t==="right")&&r&&r.entry!=="text"){let o=t==="left"?-1:1;if(r.multi)r.cursor=(r.cursor+o+r.choices.length)%r.choices.length;else r.value=A0(r.choices,r.value,o),this.recount();this.draw();return}if(t===" "&&r?.multi){let o=r.value.split(" "),s=r.choices.filter((c,u)=>u===r.cursor?!o.includes(c):o.includes(c)),a=r.multi.none;if(s.length>0||a!==void 0)r.value=s.length>0?s.join(" "):a,this.recount(),this.draw();return}if(t==="esc"){e.settings.forEach((o,s)=>{o.value=this.setting(_r[s]?.name??"")}),e.panel=void 0,e.advanced=!1,this.quietCount(),this.draw();return}if(t==="enter"||t==="s"||t==="alt-c")e.panel=void 0,e.advanced=!1,this.quietCount(),this.adopt()}typeKey(t,e){let n=this.view,r=n.typing??"";if(e==="esc"){n.typing=void 0,this.draw();return}if(e==="enter"||e==="up"||e==="down"){if(t.value=t.entry==="number"?Number(r)>0?String(Number(r)):"off":lo(r).join(" "),n.typing=void 0,this.recount(),e==="enter"){this.draw();return}this.panelKey(e);return}if(e==="backspace"){n.typing=r.slice(0,-1),this.draw();return}if(t.entry==="number"?/^[0-9]$/.test(e)&&r.length<Qf:/^[\x20-\x7e]$/.test(e))n.typing=r+e,this.draw()}quietCount(){clearTimeout(this.countTimer),this.counting?.abort(),this.counting=void 0}recount(){if(this.quietCount(),this.view.counts=void 0,!this.view.tag)return;let t=new AbortController;this.counting=t,this.countTimer=setTimeout(()=>void this.countPending(t),ER)}pending(){let t=(e)=>this.view.settings[_r.findIndex((n)=>n.name===e)]?.value??this.setting(e);return{tag:this.view.tag,chosen:this.view.chosen,preset:t("TTHEME_FIND_POSTS")==="all"?"all":"cutouts",order:pd(t("TTHEME_FIND_ORDER")),rating:Sr(t("TTHEME_FIND_RATING")),narrow:Wu(t("TTHEME_FIND_MIN_SCORE"),t("TTHEME_FIND_MIN_SIZE"),t("TTHEME_FIND_PNG")),enabled:uo(t("TTHEME_FIND_SITES"))}}async countPending(t){let e=this.pending(),n=this.site?[this.site]:q.filter((o)=>e.enabled.includes(o.name)),r=AbortSignal.any([this.signal,t.signal]),i=await Promise.all(n.map(async(o)=>{let s=this.query(o,e);if(!s)return{site:o.name,count:0};if(o.counts&&!o.counts(s.tags))return{site:o.name};try{let a=await Ku(o,s.tags,r);return{site:o.name,...Number.isFinite(a)?{count:a}:{}}}catch{return{site:o.name}}}));if(this.counting===t&&this.view.panel!==void 0)this.view.counts=i,this.draw()}adopt(){let t=this.view,e=_r.map((r)=>this.setting(r.name));t.settings.forEach((r,i)=>{let o=_r[i];if(o)this.values.set(o.name,r.value)});let n=_r.filter((r,i)=>this.setting(r.name)!==e[i]);if(n.length===0){this.draw();return}this.save(n),t.rating=Sr(this.setting("TTHEME_FIND_RATING")),t.block=ui(this.setting("TTHEME_FIND_BLOCK")),t.sets=this.setting("TTHEME_FIND_SETS")==="show"?"show":"fold",t.preset=this.setting("TTHEME_FIND_POSTS")==="all"?"all":"cutouts",t.order=pd(this.setting("TTHEME_FIND_ORDER")),t.solo=this.setting("TTHEME_FIND_SOLO")==="on",t.narrow=this.narrowed(),t.enabled=uo(this.setting("TTHEME_FIND_SITES")),t.hide=Js(this.setting("TTHEME_FIND_HIDE")),t.hideTags=lo(this.setting("TTHEME_FIND_HIDE_TAGS")),this.boards.clear(),this.current=void 0,t.shown=void 0,t.mode="grid",this.search()}save(t){this.store(t.map((e)=>[e.name,this.setting(e.name)]))}store(t){let e=Pe(this.home,"ttheme","config.zsh");try{let n=Ki(e)?y$(e,"utf8"):"";return T(e,t.reduce((r,[i,o])=>Pa(r,i,o),n)),!0}catch(n){return this.view.error=n instanceof Error?n.message:String(n),!1}}editKey(t){let e=this.view,n=e.editing??"",r=e.suggest??[];if((t==="up"||t==="down")&&r.length>0){let o=((e.pick??r.length)+(t==="down"?1:r.length))%(r.length+1);e.pick=o===r.length?void 0:o,this.draw();return}if(t==="esc"||t==="enter")this.quietSuggest();if(t==="esc"){if(e.editing=void 0,e.tag===""){this.finish(2);return}this.draw();return}if(t==="enter"){let i=e.pick===void 0?void 0:r[e.pick],o=i?n.replace(/\S*$/,i.value):n;if(e.editing=void 0,e.suggest=void 0,e.pick=void 0,o.trim()){this.commit(o.trim());return}if(e.tag===""){this.finish(2);return}this.draw();return}if(t==="backspace"){e.editing=n.slice(0,-1),this.suggest(),this.draw();return}if(t.length===1&&t>=" ")e.editing=n+t,this.suggest(),this.draw()}quietSuggest(){clearTimeout(this.suggestTimer),this.suggesting?.abort(),this.suggesting=void 0}suggest(){this.quietSuggest();let t=this.view;t.pick=void 0;let e=/\S*$/.exec(t.editing??"")?.[0]??"";if(!kR(e)){t.suggest=void 0;return}let n=[...new Map(Xp(this.catalog.palettes,this.entry,e).map((i)=>[i.booru,{value:i.booru,count:0,palette:i.name}])).values()].slice(0,GR);t.suggest=n.length>0?n:void 0;let r=new AbortController;this.suggesting=r,this.suggestTimer=setTimeout(async()=>{try{let i=await Rg(e,AbortSignal.any([this.signal,r.signal]));if(this.suggesting===r&&t.editing!==void 0){let o=new Map(i.map((a)=>[a.value,a.count])),s=new Set(n.map((a)=>a.value));t.suggest=[...n.map((a)=>({...a,count:o.get(a.value)??0})),...i.filter((a)=>!s.has(a.value))].slice(0,UR),t.pick=t.pick!==void 0&&t.pick<n.length?t.pick:void 0,this.draw()}}catch{}},vR)}async commit(t){let e=Ys(t,this.site??q[0]);if(e){await this.jump(e.site,e.id);return}if(this.picture(t)){await this.attach(t);return}this.view.tag=t,this.view.chosen=void 0,this.relate(t),this.boards.clear(),await this.search()}async jump(t,e){let n=++this.gen;this.tab=q.indexOf(t)+1,this.syncSite(),this.current=void 0,this.view.shown=void 0,this.view.error=void 0;let r=Sc(`${t.key}|post:${e}`,!0);this.board=r,this.boards.set(r.key,r),this.show(),this.draw();try{let i=await fo(t,e,this.signal);if(n!==this.gen)return;if(!i){r.searching=!1,r.error=`${t.name} has no post ${e}`,this.view.error=r.error,this.show(),this.draw();return}this.single(r,{site:t,post:i})}catch(i){this.fail(n,i,t)}}async turn(){this.fetch?.abort(),this.current=void 0,this.view.shown=void 0;let t=this.boards.get(this.boardKey);if(!t){await this.search();return}this.gen++,this.board=t,this.view.error=t.error,this.show(),this.draw(),await this.pump()}unfold(){let t=this.view,e=0;for(let n of this.board.groups){let r=n.open?n.posts.length:1;if(t.focus<e+r){if(n.posts.length<2)return;n.open=!n.open,this.board.focus=e;for(let i of n.posts)if(!this.thumbPath.has(le(i.site,i.post.id)))this.thumbQueue.push(i);this.thumbs(),this.show(),this.scroll(),this.glide(),this.draw();return}e+=r}}openPage(){let t=this.view.tiles[this.view.focus],e=t&&this.posts.get(t.key);if(!e)return;let n=process.platform==="darwin"?"open":"xdg-open";try{cR(n,[e.site.pageUrl(e.post.id)],{stdio:"ignore",detached:!0}).unref()}catch{}}tryKey(t){let e=this.view;if(e.tuning){this.tuneKey(t);return}if(t==="left"||t==="right"){this.direction=t==="left"?-1:1,this.focus(e.focus+this.direction);return}if(t==="shift-left"||t==="shift-right"){e.scene+=t==="shift-left"?-1:1,e.details=!1,this.draw();return}if(t==="i"){e.details=!e.details,this.inform(),this.draw();return}if(t==="t"){e.tuning={field:0,held:{...e.tune},fill:this.current?.fill??0,coloring:e.coloring},this.draw();return}if(t==="c"){this.recolor();return}if(t==="o"){this.openPage();return}if(t==="x"){this.swap();return}if(t==="v"){this.fromClipboard();return}if(t==="enter"){this.install();return}if(t==="esc")this.fetch?.abort(),clearTimeout(this.settle),e.fetching=void 0,e.mode="grid",e.error=void 0,this.draw()}tuneKey(t){let e=this.view,n=e.tuning,r=e.tune;if(t==="up"||t==="down"){n.field=(n.field+(t==="up"?2:1))%3,this.draw();return}let i=pR[t];if(i!==void 0){if(n.field===0)r.size=wR(r.size,i,n.fill);else if(n.field===1)r.at=(r.at-1+Math.sign(i)+9)%9+1;else r.opacity=Math.max(0,Math.min(100,Math.round(r.opacity*100)+i))/100;this.retune();return}if(/^[1-9]$/.test(t)){n.field=1,r.at=Number(t),this.retune();return}if(t==="="){let o=e.untuned;if(n.field===0)r.size=o.size;else if(n.field===1)r.at=o.at;else r.opacity=o.opacity;this.retune();return}if(t==="+"){e.tune={...e.untuned},this.retune();return}if(t==="enter"){e.tuning=void 0,this.draw();return}if(t==="c"){this.recolor();return}if(t==="esc")e.tune={...n.held,...n.coloring===e.coloring?{}:{opacity:e.untuned.opacity}},e.tuning=void 0,this.retune()}recolor(){let t=this.view;if(!this.current||t.shown?.id!==this.current.key)return;t.coloring=t.coloring==="tone"?"original":"tone",t.tune.opacity=t.untuned.opacity,this.draw(),this.reveal()}retune(){if(this.draw(),this.current&&this.view.shown?.id===this.current.key)this.reveal()}inform(){let t=this.view,e=t.tiles[t.focus],n=e&&this.posts.get(e.key);t.info=n?this.infoOf(n):void 0}infoOf(t){let{site:e,post:n}=t,r=n.named,i=Mg(e,n),o=new Set([...r.artist,...r.character,...r.copyright]),s=ho(n.source),a=/^https?:\/\//i.test(s)?s:e===Cr&&s.startsWith("/")?u$(s).href:void 0;return{page:e===Cr?"":e.pageUrl(n.id),source:s,...a?{link:a}:{},artists:r.artist,characters:r.character,series:r.copyright,tags:n.tags.filter((c)=>!o.has(c)),...i?{rating:i}:{},...n.posted?{posted:n.posted}:{},ext:(je(n)??n).ext,uploader:n.owner}}focus(t){let e=this.view;if(e.tiles.length===0)return;let n=Math.max(0,Math.min(e.tiles.length-1,t));if(n===e.focus)return;if(e.focus=n,this.board.focus=n,this.scroll(),this.glide(),this.pump(),e.mode==="try")this.select();this.draw()}scroll(){let t=this.view,{perRow:e,rowsVis:n}=Ur(this.cols,this.rows),r=Math.floor(t.focus/e);if(r<t.top)t.top=r;if(r>t.top+n-1)t.top=r-n+1;this.board.top=t.top}glide(){if(this.bands)this.prebake();if(this.gliding)return;let t=Ur(this.cols,this.rows).height,e=()=>{let n=this.view,r=n.top*pt.height,i=r-n.scroll;if(i===0||n.mode!=="grid"){n.scroll=r;let o=this.gliding!==void 0;if(this.gliding=void 0,o)this.draw();return}if(Math.abs(i)>2*t)n.scroll=r-Math.sign(i)*t,i=r-n.scroll;n.scroll+=Math.sign(i)*Math.max(1,Math.round(Math.abs(i)*AR)),this.draw(),this.gliding=setTimeout(e,TR)};e()}snap(){clearTimeout(this.gliding),this.gliding=void 0,this.view.scroll=this.view.top*pt.height}prebake(){let t=this.view;for(let e of Xf({...t,scroll:t.top*pt.height},this.cols,this.rows).images)if(e.crop!==void 0)this.band(e.path,e.crop,e.rows)}selected(t){if(t.chosen)return t.chosen;if(!t.tag)return[];return t.tag===this.entry.booru?Il(this.entry,"danbooru"):[t.tag]}syncChips(){let t=this.selected(this.view);this.view.chips=this.pool.slice(0,WR).map((e)=>({name:e,on:t.includes(e)}))}toggle(t){let e=this.view,n=e.chips[t];if(!n)return;let r=this.selected(e),i=n.on?r.filter((o)=>o!==n.name):[...r,n.name];if(i.length===0)return;e.chosen=i,e.tag=i.join(" or "),this.syncChips(),this.boards.clear(),this.search()}async relate(t){this.relating?.abort();let e=this.selected({tag:t,chosen:void 0});if(this.pool=e,this.syncChips(),this.draw(),!t||/\s/.test(t))return;let n=this.related.get(t);if(!n){let r=new AbortController;this.relating=r;try{n=(await Pg(t,AbortSignal.any([this.signal,r.signal]))).map((i)=>i.value)}catch{return}if(this.relating!==r)return;this.related.set(t,n)}this.pool=[...new Set([...e,...n])],this.syncChips(),this.draw()}query(t,e=this.view){let n=e.chosen?Hg(t,e.chosen):e.tag===this.entry.booru?Il(this.entry,t.key):[e.tag];if(n.length===0)return;let r=e.chosen?.slice(n.length)??[],i=n.length>1,o=e.preset==="cutouts"?t.cutouts:"",s=i&&o.includes("~"),a=[i?n.map((l)=>`~${l}`).join(" "):n[0],t.rate(e.rating),...t.narrow(e.narrow),s?"":o,e.order==="score"?t.best:""].filter(Boolean),c=[],u=[];for(let l of a)if(zu([...c,l].join(" "))<=t.tagBudget)c.push(l);else u.push(l);return{tags:c.join(" "),notes:[...u.length>0?[`${t.name} takes ${t.tagBudget} tags — ${u.join(" ")} left out`]:[],...r.length>0?[`${t.name} takes ${n.length} tag${n.length===1?"":"s"} — ${r.join(" ")} left out`]:[],...s?[`${t.name} ORs the names, so cutouts are told by the file`]:[],...e.narrow.score>0&&!t.scored?[`${t.name} keeps no score`]:[],...e.narrow.png&&t.guesses?[`${t.name} names a file type only where danbooru holds the file`]:[]]}}async search(){let t=++this.gen,e=Sc(this.boardKey,!0);this.board=e,this.boards.set(e.key,e),this.view.error=void 0;let n=this.sites.flatMap((o)=>{let s=this.query(o);return s?[{site:o,...s}]:[]}),r=this.sites.filter((o)=>!n.some((s)=>s.site===o)),i=[...n.flatMap(({notes:o})=>o),...r.length>0?[`${this.entry.name} has no tag on ${r.map((o)=>o.name).join(", ")}`]:[]];if(e.note=i.length>0?i.join(" · "):void 0,n.length===0)e.searching=!1;this.show(),this.draw(),this.tally(t,e,n);try{let o=await Promise.all(n.map(async(s)=>({plan:s,owners:await this.mateOwners(s.site)})));if(t!==this.gen)return;e.sources=o.flatMap(({plan:{site:s,tags:a},owners:c})=>{let u=zu(a)+1<=s.tagBudget?s.uploadedBy:void 0;return[...u?[...c.keys()].map((l)=>({site:s,tags:`${a} ${u(l)}`,page:0,done:!1})):[],{site:s,tags:a,page:0,done:!1}]}),this.show(),this.draw(),await this.pump()}catch(o){this.fail(t,o)}}async tally(t,e,n){let r=await Promise.allSettled(n.map(({site:i,tags:o})=>Ku(i,o,this.signal)));if(t===this.gen)e.total=r.reduce((i,o)=>i+(o.status==="fulfilled"&&Number.isFinite(o.value)?o.value:0),0),this.show(),this.draw()}fail(t,e,n=this.site){if(t!==this.gen||this.signal.aborted)return;this.board.error=wd(n?.name??this.tabName,e),this.board.searching=!1,this.view.error=this.board.error,this.show(),this.draw()}drop(t,e,n){for(let r of t.sources)if(r.site===e)r.done=!0;t.note=[t.note,wd(e.name,n)].filter(Boolean).join(" · ")}wants(){let{perRow:t,rowsVis:e}=Ur(this.cols,this.rows);return this.view.tiles.length<(this.board.top+e+b$)*t}need(){let{perRow:t,rowsVis:e}=Ur(this.cols,this.rows);return(e+b$)*t}live(t){return this.boards.get(t.key)===t}page(t,e,n){let r=`${t.key}|${e}|${n}`,i=this.pages.get(r);if(!i)i=Ng(t,e,n,this.signal).then((o)=>this.borrow(t,o)),this.pages.set(r,i),i.catch(()=>this.pages.delete(r));return i}async borrow(t,e){let n=t===Ut?[]:e.filter((r)=>r.md5!=="");if(n.length>0)try{ea(n,await na(n.map((r)=>r.md5),this.signal))}catch{}return e}staged(t){if(t===this.board)this.stageOf(t),this.draw()}async round(t){t.stage="fetch",this.staged(t);let e=q.flatMap((a)=>{let c=t.sources.find((u)=>u.site===a&&!u.done);return c?[c]:[]}),n=await Promise.all(e.map(async(a)=>{try{let c=await this.page(a.site,a.tags,a.page);return t.arrived.add(a.site.name),this.staged(t),{source:a,posts:c}}catch(c){if(t.sources.every((u)=>u.site===a.site)||this.signal.aborted)throw c;return this.drop(t,a.site,c),{source:a,posts:void 0}}}));if(!this.live(t))return;let r=[];for(let{source:a,posts:c}of n){if(!c)continue;a.page++,a.done=c.length<Fn;let u=t.last.get(a);for(let l of c){let f=u&&i$(u.post,l)?u.set:`set:${a.site.key}:${l.id}`;u={post:l,set:f};let d=le(a.site,l.id);if(t.seen.has(d))continue;t.seen.add(d);let m={site:a.site,post:l};if(this.eligible(m))t.kin.set(m,[f,...r$(a.site,l)]),r.push(m);else t.checked++}if(u)t.last.set(a,u)}let i=this.dedupe(t,r),o=++t.rounds,s;if(this.view.order!=="fit")s=e.length>1?e$(i):i;else{let a=vc(i,this.frame(),this.matched),c=a.slice(0,this.need()),u={done:0,total:c.length};if(t.ranking=u,this.staged(t),await this.looks(c,()=>{u.done++,this.staged(t)}),t.ranking=void 0,!this.live(t))return;s=[...vc(c,this.frame(),this.matched),...a.slice(c.length)]}t.stage="check",this.staged(t);for(let a of s)t.roundOf.set(a,o);t.queue.push(...s),this.ahead(t)}ahead(t){if(this.aheading||this.view.order!=="fit"||!this.live(t))return;let e=t.queue.slice(0,this.need()).filter((n)=>!this.looking.has(le(n.site,n.post.id)));if(e.length===0)return;this.aheading=!0,this.looks(e).then(()=>{this.aheading=!1;for(let n of new Set(e.map((r)=>t.roundOf.get(r)??0)))this.resort(t,n);this.ahead(t)})}resort(t,e){let n=t.queue.flatMap((i,o)=>t.roundOf.get(i)===e?[o]:[]),r=vc(n.map((i)=>t.queue[i]),this.frame(),this.matched);n.forEach((i,o)=>{t.queue[i]=r[o]})}dedupe(t,e){let n=[];for(let r of e){let i=fd(r.post),o=i.map((a)=>t.same.get(a)).find(Boolean);if(!o){for(let a of i)t.same.set(a,r);n.push(r);continue}if(t.checked++,w$(r.post)<=w$(o.post))continue;for(let a of[...i,...fd(o.post)])t.same.set(a,r);let s=n.indexOf(o);if(s>=0){n[s]=r;continue}this.replace(t,o,r)}return n}replace(t,e,n){t.roundOf.set(n,t.roundOf.get(e)??0);let r=t.queue.indexOf(e);if(r>=0){t.queue[r]=n;return}for(let i of t.groups){let o=i.posts.indexOf(e);if(o>=0){i.posts[o]=n,this.posts.set(le(n.site,n.post.id),n),this.thumbQueue.push(n),this.thumbs();return}}}async looks(t,e){let n=0;await Promise.all(Array.from({length:d$},async()=>{while(n<t.length)await this.look(t[n++]),e?.()}))}look(t){let e=le(t.site,t.post.id),n=this.looking.get(e);if(!n)n=(async()=>{let r=this.previewPath(t),i=Ds(t.site,t.post);await this.cached(i.site,r,i.url);let o=await this.renders.run({job:"match",from:r,colors:this.entry.signature});return this.looked.set(e,o),this.matched.set(t.post,o.match),o})().catch(()=>{return}),this.looking.set(e,n);return n}async pump(){let t=this.gen,e=this.board;if(this.pumping===t||e.sources.length===0)return;this.pumping=t;let n=[],r;try{e.searching=!0;while(t===this.gen){while(n.length<f$&&e.queue.length>0&&this.wants()){let s=e.queue.shift();n.push({pick:s,passed:this.vet(s)})}if(this.ahead(e),!r&&e.queue.length<f$&&e.sources.some((s)=>!s.done)&&this.wants()){let s=this.round(e).then(()=>{if(r===s)r=void 0});s.catch(()=>{}),r=s}let i=n.shift();if(!i){if(!r)break;await r,this.show(),this.draw();continue}let o=await i.passed;if(t!==this.gen)return;if(e.checked++,o)this.admit(i.pick);this.show(),this.draw()}if(t===this.gen)e.searching=!1,this.show(),this.draw()}catch(i){this.fail(t,i)}finally{if(this.saveKept(),this.pumping===t)this.pumping=0}}eligible({site:t,post:e}){let n=je(e);if(!Zs(t,e,this.view.rating)||Vs(e,this.view.block).length>0||!n)return!1;if(this.view.solo&&e.solo===!1)return!1;let{score:r,size:i,png:o}=this.view.narrow;if(Math.min(e.width,e.height)<i||t.scored&&e.score<r||o&&e.ext!=="png"||Sg(e,this.view.hide).length>0||this.view.hideTags.some((s)=>e.tags.includes(s)))return!1;return this.view.preset==="all"?["png","jpg","jpeg",""].includes(n.ext):["png",""].includes(e.ext)}async vet(t){let[e]=await Promise.all([this.passes(t),this.look(t)]);return e}async passes({site:t,post:e}){return this.view.preset==="all"||t.vouched||this.transparent(t,e)}keep(t,e){let n=`${t.key}/${e}`,r=this.kept.get(n);if(!r)r=BR(t,e),this.kept.set(n,r);return r}async transparent(t,e){let n=this.keep(t,"probes.json"),r=n[e.id];if(r!==void 0)return r;try{let i=await ra(t,e,this.signal),o=li(t,e),s=(i===void 0?await Fg(o.site,o.url,this.signal):i)?.alpha===!0;return n[e.id]=s,this.unsaved.add(`${t.key}/probes.json`),s}catch{return!1}}saveKept(){for(let t of this.unsaved){let[e,n]=t.split("/"),r=q.find((i)=>i.key===e);if(r)zR(r,n,this.keep(r,n))}this.unsaved.clear()}admit(t){let{site:e,post:n}=t,r=this.board,i=le(e,n.id);this.posts.set(i,t);let o=r.kin.get(t)??[],s=this.looked.get(i),a=s&&{hash:s.hash,width:n.width,height:n.height},c=this.view.sets==="fold"?this.kindred(r,o,a):void 0;if(c){if(c.posts.push(t),this.register(r,c,o,a),c.open)this.thumbQueue.push(t),this.thumbs();return}let u={posts:[t],open:!1};r.groups.push(u),this.register(r,u,o,a),this.thumbQueue.push(t),this.thumbs()}kindred(t,e,n){for(let r of e){let i=t.kindred.get(r);if(i)return i}return n&&t.shapes.find((r)=>s$(r.shape,n))?.group}register(t,e,n,r){for(let i of n)if(!t.kindred.has(i))t.kindred.set(i,e);if(r)t.shapes.push({shape:r,group:e})}credit(t,e){let{site:n,post:r}=t;if(!ta(n,r))return Promise.resolve();let i=le(n,r.id),o=this.crediting.get(i);if(!o)o=this.credits(t,e).finally(()=>this.crediting.delete(i)),this.crediting.set(i,o);return o}async credits({site:t,post:e},n){let r=this.keep(t,"credits.json"),i=r[e.id];if(!i){try{i=await Xs(t,e.id,n)}catch{return}if(!i?.owner)return;r[e.id]=i,this.unsaved.add(`${t.key}/credits.json`)}mo(e,i),this.show(),this.inform(),this.draw()}async mateOwners(t){let e=this.owners.get(t.key);if(e)return e;let n=$p(this.home),r=this.keep(t,"owners.json"),i=this.catalog.palettes.flatMap((c)=>{let u=n.get(c.name);return c.group===this.entry.group&&c.name!==this.entry.name&&u?.site===t.key?[{name:c.name,id:u.id}]:[]}),o=await Promise.all(i.map(async(c)=>{let u=r[c.id];if(u!==void 0)return{...c,owner:u};try{return{...c,owner:(await fo(t,c.id,this.signal))?.owner??""}}catch{return}})),s=new Map;for(let c of o)if(c)r[c.id]=c.owner,s.set(c.name,c.owner);this.unsaved.add(`${t.key}/owners.json`);let a=Ig(s);return this.owners.set(t.key,a),a}async cached(t,e,n,r){if(Ki(e))return fR(e).size;let i=this.inflight.get(e);if(i)return i;let o=(async()=>{let s=await ia(t,n,this.signal,r);return T(e,s),s.length})();this.inflight.set(e,o);try{return await o}finally{this.inflight.delete(e)}}thumbs(){while(!this.signal.aborted&&this.thumbing<d$&&this.thumbQueue.length>0){let t=this.thumbQueue.shift();this.thumbing++,this.thumb(t).catch(()=>{this.thumbless.add(le(t.site,t.post.id)),this.show(),this.draw()}).finally(()=>{this.thumbing--,this.thumbs()})}}async thumb(t){let{site:e,post:n}=t,r=pt.cols*this.cell.w,i=pt.rows*this.cell.h,o=Ds(e,n),s=Pe(Ge(e),"tile",`${$$(n.id,o.url)}-${r}x${i}.png`);if(!Ki(s)){let a=this.previewPath(t);if(await this.cached(o.site,a,o.url),this.signal.aborted)return;await this.renders.run({job:"thumb",from:a,to:s,width:r,height:i})}this.thumbPath.set(le(e,n.id),s),this.show(),this.draw()}select(){let t=this.view,e=t.tiles[t.focus];if(this.fetch?.abort(),clearTimeout(this.settle),t.fetching=void 0,this.inform(),!e)return;if(this.current?.key===e.key){this.reveal();return}this.settle=setTimeout(()=>void this.load(e),MR),this.draw()}async load(t){let e=this.view,n=this.posts.get(t.key);if(!n)return;let r=new AbortController;if(this.fetch=r,this.credit(n,r.signal),!je(n.post))return;let{site:i}=n,o=this.board;try{await ra(i,n.post,r.signal);let s=je(n.post),a=this.origPath(i,t.id,s.ext);if(!Ki(a))e.fetching={id:t.key,got:0,size:0},this.draw();let c=li(i,n.post,s),u=await this.cached(c.site,a,c.url,(d,m)=>{if(e.fetching?.id===t.key)e.fetching={id:t.key,got:d,size:m},this.draw()});if(r.signal.aborted)return;if(e.fetching=void 0,o!==this.board)return;let l={site:i,id:t.id,key:t.key,path:a,ext:s.ext,size:u,using:"plain",failed:!1};e.preparing=t.key,this.flush();let f=await this.render(l,"plain");if(r.signal.aborted||o!==this.board)return;if(f.clear===0&&Fi()&&this.setting("TTHEME_FIND_REMOVE_BG")!=="off"){if(e.preparing=void 0,e.cutting=t.key,this.flush(),l.cut=await this.cutOut(i,t.id,a,r.signal),r.signal.aborted||o!==this.board)return;if(e.cutting=void 0,l.cut){e.preparing=t.key,this.flush();let d=await this.render(l,"cut").catch(()=>{return});if(r.signal.aborted||o!==this.board)return;if(d&&Qa(d.clear))l.using="cut";else bs(l.cut,{force:!0}),l.cut=void 0,l.failed=!0}else l.failed=!0}if(this.current=l,e.tiles[e.focus]?.key===t.key)await this.present();this.preload()}catch(s){if(!r.signal.aborted&&!this.signal.aborted)e.error=wd(i.name,s)}finally{if(e.fetching?.id===t.key)e.fetching=void 0;if(e.preparing===t.key)e.preparing=void 0;if(e.cutting===t.key)e.cutting=void 0;this.draw()}}async cutOut(t,e,n,r){let i=Pe(Ge(t),"cut",`${e}.png`);if(Ki(i))return i;try{return uR(mR(i),{recursive:!0}),await Ko(n,i,r),i}catch{bs(i,{force:!0});return}}swap(){let t=this.current;if(!t?.cut||this.view.shown?.id!==t.key)return;t.using=t.using==="cut"?"plain":"cut",this.reveal()}preload(){let t=this.view;if(t.mode!=="try")return;for(let e of[t.focus+this.direction,t.focus-this.direction]){let n=t.tiles[e],r=n&&this.posts.get(n.key);if(r)this.credit(r,this.signal);if(this.prefetching>=SR||!r||!je(r.post))continue;let{site:i,post:o}=r;this.prefetching++,ra(i,o,this.signal).then(async()=>{let s=je(o),a=this.origPath(i,o.id,s.ext),c=li(i,o,s);return await this.cached(c.site,a,c.url),this.render({site:i,id:o.id,key:n.key,path:a,ext:s.ext,size:0,using:"plain",failed:!1},"plain")}).catch(()=>{}).finally(()=>{this.prefetching--})}}async render(t,e){let n=this.cols*this.cell.w,r=this.rows*this.cell.h,i=Math.min(n,PR),o=Math.max(1,Math.round(r*i/n)),s={...this.view.tune},{coloring:a}=this.view,c=!v$(s,this.view.untuned),u=s.opacity!==this.view.untuned.opacity,l=c?`-${s.size}-${s.at}${u?`-${Math.round(s.opacity*100)}`:""}`:"",f=Pe(this.scratch,`${t.site.key}-${t.id}${e==="cut"?"c":""}${a==="original"?"o":""}-${i}x${o}${l}.png`),d=`${t.site.key}:${t.id}:${e}:${a}:${i}x${o}`,m=this.clarity.get(d);if(m&&Ki(f))return t.fill=m.fill,{clear:m.clear,path:f,opacity:m.opacity,touched:u};let g=await this.renders.run({job:"show",from:e==="cut"?t.cut:t.path,to:f,width:i,height:o,colors:this.entry,tone:this.tone,blur:this.blurring*i/ol(n,r).width,coloring:a,...c?{tune:{size:s.size,at:s.at,...u?{opacity:s.opacity}:{}}}:{}});if(this.clarity.set(d,g),t.fill=g.fill,c)this.keepTuned(f);return{clear:g.clear,path:f,opacity:g.opacity,touched:u}}keepTuned(t){this.tunedFiles.push(t);while(this.tunedFiles.length>HR){let e=this.tunedFiles.findIndex((n)=>n!==this.view.shown?.path&&n!==t);if(e===-1)return;bs(this.tunedFiles.splice(e,1)[0],{force:!0})}}async present(){let t=this.current;if(!t)return;let e=t.using,{coloring:n}=this.view,r=this.view.tune.opacity,{clear:i,path:o,opacity:s,touched:a}=await this.render(t,e);if(this.current!==t||t.using!==e||this.view.coloring!==n)return;if(!a&&this.view.tune.opacity===r)this.view.untuned.opacity=s,this.view.tune.opacity=s;if(this.view.tuning&&t.fill)this.view.tuning.fill=t.fill;this.view.shown={id:t.key,clear:i,bytes:t.size,path:o,cut:t.cut?e==="cut"?"on":"off":t.failed?"failed":"none"}}reveal(){let t=this.view;if(this.presenting){this.again=!0;return}this.presenting=!0,t.preparing=this.current?.key,this.flush(),this.present().catch((e)=>{t.error=e instanceof Error?e.message:String(e)}).finally(()=>{if(this.presenting=!1,this.again){this.again=!1,this.reveal();return}if(t.preparing===this.current?.key)t.preparing=void 0;this.draw()})}async install(){let t=this.view,e=t.tiles[t.focus],n=this.current;if(!e||n?.key!==e.key||t.preparing!==void 0||t.shown?.id!==e.key)return;t.installing=e.key,t.error=void 0,this.flush();let r=$R(t.tune,t.untuned),i=this.posts.get(n.key)?.post;try{await this.renders.run({job:"backdrop",from:n.using==="cut"?n.cut:n.path,source:n.path,home:this.home,colors:this.entry,tone:this.tone,origin:{site:n.site.key,id:n.id,ext:n.ext,from:`${n.site.name} ${n.id} ${n.site.pageUrl(n.id)}`,artist:i?.named.artist??[],source:ho(i?.source??"")},width:this.cols*this.cell.w,height:this.rows*this.cell.h,blur:this.blurring,coloring:t.coloring,...r?{tune:r,aligns:xr(B(this.home).terminals),user:dR()}:{}}),this.keep(n.site,"owners.json")[n.id]=i?.owner??"",this.unsaved.add(`${n.site.key}/owners.json`),oe(this.home);let{size:o,at:s,opacity:a}=t.tune,c=r?` · ${o==="fill"?"fill":`${o}%`} · ${Qt[s-1]} · ${a.toFixed(2)}`:"",u=i?.named.artist.length?`${i.named.artist.join(", ")} · `:"";t.saved={text:`Background · ${this.entry.name} ← ${u}${n.site.name} ${n.id}${c}`,key:e.key},t.installed.push(e.key),this.fetch?.abort(),clearTimeout(this.settle),t.fetching=void 0,t.mode="grid"}catch(o){t.error=o instanceof Error?o.message:String(o)}t.installing=void 0,this.draw()}draw(){if(this.dirty||this.signal.aborted)return;this.dirty=!0,setImmediate(()=>{this.dirty=!1,this.flush()})}flush(){if(this.signal.aborted)return;let t=Xf(this.view,this.cols,this.rows);this.view.loaderFrom=t.loader?this.view.loaderFrom??this.view.beat:void 0;let e="";t.lines.forEach((i,o)=>{if(this.screen[o]!==i)e+=`\x1B[${o+1};1H\x1B[K${i}`,this.screen[o]=i});let n=new Set;for(let i of t.images){let o=this.bands?this.banded(i):i;if(!o)continue;if(n.add(o.id),this.sent.get(o.id)!==o.path){let a=N0(o,this.files);if(a===void 0)continue;e+=a,this.sent.set(o.id,o.path),this.placed.delete(o.id)}let s=`${o.row};${o.col};${o.cols};${o.rows};${o.crop};${o.z}`;if(this.placed.get(o.id)!==s){if(!this.moves&&this.placed.has(o.id))e+=Zf(o.id);e+=R0(o,this.cell),this.placed.set(o.id,s)}}for(let i of this.sent.keys())if(!n.has(i))e+=P0(i),this.sent.delete(i),this.placed.delete(i);e+=this.cover();let r=this.view.mode==="grid"&&this.view.editing!==void 0?this.caret():"";if(e||r)this.write(`\x1B[?2026h${e}${r}\x1B[?2026l`);this.pace(t.tick)}cover(){let t=`${this.cols};${this.rows}`;if(!this.layers||this.covered===t)return"";let e="";if(!this.covered){let n=Buffer.from(nt(this.entry.background)).toString("base64");if(e+=`\x1B_Ga=t,f=24,s=1,v=1,i=${qi},q=2;${n}\x1B\\`,bd)e+=`\x1B_Ga=t,f=32,s=1,v=1,i=${ws},q=2;AAAAAA==\x1B\\\x1B[H\x1B_Ga=p,i=${ws},p=${ws},c=1,r=1,C=1,z=${xR},q=2\x1B\\`}else if(!this.moves)e+=Zf(qi);if(this.covered=t,bd){let{x:n,y:r}=bd;return`${e}\x1B_Ga=p,i=${qi},p=${qi},P=${ws},Q=${ws},H=${-n},V=${-r},c=${this.cols+2*n},r=${this.rows+2*r},C=1,z=${p$},q=2\x1B\\`}return`${e}\x1B[H\x1B_Ga=p,i=${qi},p=${qi},c=${this.cols},r=${this.rows},C=1,z=${p$},q=2\x1B\\`}caret(){return`\x1B[1;${Math.min(this.cols,tt(`⌕ ${this.view.editing??""}`)+1)}H`}pace(t){if(t)this.ticking??=setInterval(()=>{this.view.beat++,this.draw()},LR);else if(this.ticking)clearInterval(this.ticking),this.ticking=void 0}banded(t){if(t.crop===void 0)return t;let e=this.band(t.path,t.crop,t.rows,!this.gliding);return e?.ready?{...t,id:e.id,path:e.path,crop:void 0}:void 0}band(t,e,n,r=!0){let i=`${t}|${e}|${n}`,o=this.bandFiles.get(i);if(o||!r)return o;let s=this.nextBand++,a={id:s,path:Pe(this.scratch,`band-${s}.png`),ready:!1};return this.bandFiles.set(i,a),this.renders.run({job:"band",from:t,to:a.path,y:e*this.cell.h,height:n*this.cell.h}).then(()=>{a.ready=!0,this.draw()}).catch(()=>{}),this.trimBands(),a}trimBands(){for(let[t,e]of this.bandFiles){if(this.bandFiles.size<=jR)return;if(e.ready&&!this.sent.has(e.id))this.bandFiles.delete(t),bs(e.path,{force:!0})}}}async function E$(t,e,n){let r=new $d(t,Ie(t),e,e.booru??"",n);return await r.run(),{saved:r.saved,installs:r.installs}}async function S$(t){let e=Y(),n=Ie(e),r=mn(n.palettes,t);if(!process.stdin.isTTY||!process.stdout.isTTY)throw Error("needs a terminal");let i=new $d(e,n,r,r.booru??""),o=await i.run();if(i.saved&&o!==0)return process.stderr.write(`${i.saved}
523
- `),0;return o}import{execFileSync as nP,spawnSync as rP}from"node:child_process";import{chmodSync as iP,copyFileSync as oP,existsSync as Br,mkdirSync as x$,readdirSync as sP,readFileSync as Hc,rmSync as vd}from"node:fs";import{homedir as aP}from"node:os";import{dirname as Ji,join as dt}from"node:path";import{rmSync as M$}from"node:fs";import{basename as KR,join as ks}from"node:path";var I$=ks(import.meta.dirname,".."),qR=ks(I$,"themes"),kd=ks(I$,"dist"),Mc=re.map((t)=>sr[t].emitter),JR=[Wl,hl],U3=Mc.map((t)=>t.id);async function Ic({only:t}={}){if(typeof Bun>"u")throw Error("needs bun — run it from a checkout: bun src/bin.ts build");let e=t&&t.length>0?Mc.filter((o)=>t.includes(o.id)):Mc,n=Yg(qR),r=Bh(n);if(r.length>0){for(let o of r)console.error(` ✗ ${o.theme} [${o.rule}] ${o.detail}`);throw Error(`${r.length} contrast violation(s). Fix the palette, or waive the rule in its [contrast] section with a reason.`)}if(e.length===Mc.length)M$(kd,{recursive:!0,force:!0});else for(let o of e)M$(ks(kd,o.id),{recursive:!0,force:!0});let i=0;for(let o of[...e,...JR]){let s=n.flatMap((u)=>o.emit?.(u)??[]),a=o.emitShared?.(n)??[];for(let u of[...s,...a])await Bun.write(ks(kd,u.path),u.content),i++;let c=s.length>0?`${n.length} themes${o.limits?` (${o.limits})`:""}`:a.map((u)=>KR(u.path)).join(" ");console.log(` ${o.id.padEnd(16)} ${c}`)}console.log(`
524
- ${n.length} themes (${Dg(n).length} in the new-tab rotation) -> ${i} files in dist/`)}import{availableParallelism as YR,homedir as O$}from"node:os";var DR=4;async function Oc(t,e,n=O$()){let r=Rt(X(t)),i=er(t),o=new Map(Ie(t).palettes.map((f)=>[f.name,bi(f)])),s=Object.entries(r.palettes).flatMap(([f,d])=>{let m=o.get(f);return m?d.pictures.filter((g)=>wi(g)||(g.blur??0)!==i).map((g)=>({name:f,key:g.key,paint:m})):[]});if(s.length===0)return 0;e(`Drawing ${s.length} background picture${s.length===1?"":"s"} again${i?` · blur ${i}px`:""}`);let a=xr(B(t).terminals),c=new gd(Math.min(DR,YR()-1)),u=await c.map(s.map(({name:f,key:d,paint:m})=>({job:"redraw",home:t,user:n,name:f,key:d,paint:m,blur:i,aligns:a})));c.close();let l=[];return u.forEach((f,d)=>{let{name:m,key:g}=s[d];if(f instanceof Error||f===null){e(` ▢ ${m} ${g} — ${f instanceof Error?f.message:"no original to draw it from"}, left as it was`);return}l.push({name:m,picture:f})}),dl(t,l),oe(t,n),l.length}async function N$(t,e,n,r,i=O$()){let o=Rt(X(t)).palettes[e],s=o?.pictures.find((l)=>l.key===(r??o.active));if(!o||!s)throw Error(`${e} has no picture ${r??"shown"}`);if(ye(s)===n)return{key:s.key,changed:!1};let a=Ie(t).palettes.find((l)=>l.name===e);if(!a)throw Error(`no palette called ${e}`);let c=xr(B(t).terminals),u=await ec(t,e,s.key,bi(a),er(t),c,i,n);if(!u)throw Error(`${e} ${s.key} has no original to draw it from`);return dl(t,[{name:e,picture:u}]),oe(t,i),{key:s.key,changed:!0}}function R$(t,e,n){let r=Rt(X(t)).palettes[e],i=r?.pictures.find((a)=>a.key===(n??r.active));if(!r||!i)throw Error(`${e} has no picture ${n??"shown"}`);let o=Ie(t).palettes.find((a)=>a.name===e);if(!o)throw Error(`no palette called ${e}`);let s=ye(i)==="original"?"tone":"original";if(!Iw(t,e,i.key,bi(o),er(t),s))throw Error(`${e} ${i.key} has no original to draw it from`);return{key:i.key,coloring:s}}async function P$(){return await Oc(Y(),(t)=>process.stderr.write(`${t}
525
- `)),0}import{existsSync as Rc,readdirSync as VR,readFileSync as yd,rmSync as H$,statSync as F$}from"node:fs";import{homedir as ZR}from"node:os";import{join as ys}from"node:path";var QR=150,XR=260;function Nc(t){return t?.includes(`path = "${x("")}`)===!0}function tP(t){try{return B(t).terminals.includes("warp")}catch{return!1}}function eP(t,e){let n=x(e);if(!Rc(t))return;return VR(t).filter((i)=>i.startsWith(`${n}.`)&&/^[0-9a-f]{8}\.yaml$/.test(i.slice(n.length+1))).map((i)=>({file:i,at:F$(ys(t,i)).mtimeMs})).sort((i,o)=>o.at-i.at)[0]?.file??(Rc(ys(t,`${n}.yaml`))?`${n}.yaml`:void 0)}function lr(t,e,n,r=ZR()){if(!e||zt(t)||t.TMUX||ne(t)!=="warp")return;let i=ir(r,n);if(!Rc(i)||!tP(n))return;let o=Hr(r),s=_a(n),a=[],c,u,l=(g)=>{let $=yd(i,"utf8"),w=or($);if(w===g)return;if(Nc(g)&&!Nc(w)&&!Rc(s))T(s,w??"");if(Te(i,Ba($,g)),!Nc(g))H$(s,{force:!0})},f=(g)=>{for(let $ of a.splice(0))if($===g)a.push($);else H$(ys(o,$),{force:!0})},d=()=>{clearTimeout(c),clearTimeout(u)},m=(g,$)=>{d(),c=setTimeout(()=>{let w=$;if(!w)w=`${x(g.name)}.view-${process.pid}-${a.length+1}.yaml`,T(ys(o,w),Co(g)),a.push(w);let b=w,v=Date.now()-F$(ys(o,b)).mtimeMs;u=setTimeout(()=>{l(sf(g.name,b)),f(b)},Math.max(0,XR-v))},QR)};return{slots:[],paint:(g)=>{return m(g,eP(o,g.name)),""},look:(g,$)=>{let[w="",b="",v="",,...R]=$;m({name:g,background:w,foreground:b,cursor:v,ansi:R})},wear:(g,$)=>$.includes("warp")?"":void 0,saved:async()=>new Map([["theme",or(yd(i,"utf8"))??""]]),restore:(g)=>{d();let $=g.get("theme");if($)l($);else if(Nc(or(yd(i,"utf8"))))l(Wa);return f(),""}}}function cP(t,e,n){for(let r of sP(e))t.push({from:dt(e,r),to:dt(n,r)})}function Od(t){return JSON.parse(Hc(dt(t,"dist","manifest.json"),"utf8"))}function Pc(t,e){let n=dt(e.configHome,"ttheme"),r=[{from:dt(e.root,"bin","ttheme.js"),to:dt(n,"ttheme.js")},{from:dt(e.root,"bin","ttheme.js.map"),to:dt(n,"ttheme.js.map")},{from:dt(e.root,"shell","ttheme.zsh"),to:dt(n,"ttheme.zsh")},{from:dt(e.root,"shell","launch-tab.zsh"),to:dt(n,"launch-tab.zsh"),executable:!0}];cP(r,dt(e.root,"shell","adapters"),dt(n,"adapters"));let i=[{file:dt(e.zdotdir,".zshrc"),block:kb(n)}],o=dt(n,"config.zsh"),s=vb(Br(o)?Hc(o,"utf8"):""),a={file:o,content:t.warpFast===void 0?s:Pa(s,"TTHEME_WARP_FAST",t.warpFast?"on":"off")},c={terminals:t.terminals,palettes:t.palettes,...Object.fromEntries(lt(t.terminals).flatMap((f)=>Object.entries(f.installs?.(e)??{}).filter(([,d])=>d!==void 0))),...t.off?{off:!0}:{}},u=bw(e.configHome,c,e.home),l=e.stateDir?[dt(e.stateDir,"ghostty",".blind")]:[];return{home:e.home,copies:r,edits:i,settings:a,forget:l,catalog:Od(e.root),installed:c,notes:u}}function T$(t){try{return B(t)}catch{return}}function A$(t){try{return wt(t,ct(t),!1).palettes}catch{return[]}}function uP(t,e){let n=Od(e.root),r=Ft(t.markets).includes(J)?n.palettes:[],i=new Set(r.map((s)=>s.name)),o=A$(e.configHome).filter((s)=>!i.has(s.name)&&(rt(s.name)!==void 0||t.palettes.includes(s.name)));return{...n,palettes:[...r,...o]}}function C$(t,e){let n=Fr(t);return n&&e.includes(n)?n:void 0}function lP(t,e,n){let r=Pc(e,n),i=C$(t,e.palettes),o=new Set(["terminals","palettes","off","startup",...re.flatMap((a)=>Object.keys(sr[a].installs?.(n)??{}))]),s=Object.fromEntries(Object.entries(t).filter(([a])=>!o.has(a)));return{...r,installed:{...s,...r.installed,...i?{startup:i}:{}}}}function fP(t,e){let n=Pc({terminals:t.terminals,palettes:t.palettes,off:t.off},e),r=new Set([...n.catalog.palettes,...A$(e.configHome)].map((l)=>l.name)),i=t.palettes.filter((l)=>r.has(l)),o=t.palettes.filter((l)=>!r.has(l)),{startup:s,...a}=t,c={...a,palettes:i,...s&&i.includes(s)?{startup:s}:{}},u=o.length>0?[`Dropped ${o.join(", ")} — no longer in the catalog`,...n.notes]:n.notes;return{...n,installed:c,notes:u}}function dP(t){try{return nP(process.execPath,[dt(t,"ttheme","ttheme.js"),"--version"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()||void 0}catch{return}}function j$(t){let e=Ne(t);return[lt(t.terminals).map((n)=>n.name).join(", "),`${t.palettes.length} palettes`,e?`default ${e}`:"no default — ttheme is off"].join(" · ")}function Ed(t,e=Pr()){for(let s of t.copies)if(x$(Ji(s.to),{recursive:!0}),vd(s.to,{force:!0}),vd(`${s.to}.zwc`,{force:!0}),oP(s.from,s.to),s.executable)iP(s.to,493);T(t.settings.file,t.settings.content);for(let s of t.forget)vd(s,{force:!0});let n=Ji(Ji(t.settings.file)),r=T$(n),i=Object.fromEntries(lt(t.installed.terminals).flatMap((s)=>{let a=s.defaults?.key,c=a?r?.[a]:void 0;return a&&c?[[a,c]]:[]})),o=hf(n,{...t.installed,...i},e,t.home);if(Ft(o.markets).includes(J))ka(n,t.catalog);Je(n,o),At(n,ct(n),o,t.home);for(let s of t.edits){x$(Ji(s.file),{recursive:!0});let a=Br(s.file)?Hc(s.file,"utf8"):"";Te(s.file,Qn(a,s.block))}return zo(n,o,!0,e,t.home)}class Ze extends Error{}function vs(t){if(Lt(t))throw Vr("Nothing changed"),new Ze;return t}function Sd(t,e){return re.filter((n)=>sr[n].offered(t,e))}async function hP(t,e,n,r){return vs(await Fh({message:"Wire which terminals?",options:Sd(n,r).map((i)=>({value:i,label:sr[i].name,hint:i===t?"detected":void 0})),initialValues:e,required:!0}))}async function mP(t){return vs(await rn({message:"Switch Warp to each tab's palette in about 0.2 s instead of 0.6 s?\nAbout 8% CPU while Warp is in front with tabs of different palettes — `ttheme config` changes it",initialValue:Na(t,"TTHEME_WARP_FAST")!=="off"}))}function Md(t){let e=[...t.copies.filter((n)=>!Br(n.to)).map((n)=>n.to),...Br(t.settings.file)?[]:[t.settings.file],...t.edits.filter((n)=>!Hc(n.file,"utf8").includes("# ttheme begin")).map((n)=>n.file)];if(e.length>0)throw Error(`init left gaps:
526
- ${e.join(`
527
- `)}`)}function G$(t,e){return[...new Set(t.palettes.filter((n)=>e.includes(n.name)).map((n)=>n.group))]}function gP(t,e,n){let r=t.palettes.find((s)=>s.name===Ne(e)),i=process.stdout.isTTY===!0,o=r&&(Zn(process.env,i)??lr(process.env,i,n))?.wear(r,e.terminals);if(o===void 0)return!1;return process.stdout.write(o),!0}function pP(t,e){let n=Ne(t);if(!n)return["Default none — new tabs keep the terminal colors",`Turn on \`ttheme on\` wears ${Fr(t)}`];return[`Default ${n}${e?" — this tab wears it already":""}`,"Change it `ttheme preview`, enter on a palette, then default"]}function bP(t){rP("zsh",["-c",'source "$1" && __tt_preview init',"zsh",dt(t,"ttheme","ttheme.zsh")],{stdio:"inherit"})}function wP(t,e,n,r){let i=G$(t.catalog,e.palettes);br([`${i.join(", ")} (${e.palettes.length})`,...pP(t.installed,n)].join(`
528
- `),`Installed ${e.palettes.length} palettes`),br(["exec zsh The ttheme command in this tab",...Nd(t,r)].join(`
529
- `),"Next"),lu("Done")}function Nd(t,e){return[...ww(Ji(Ji(t.settings.file)),t.installed,e,t.home),...t.notes]}function U$(t){return t?(e)=>En.step(e):(e)=>console.log(e)}async function L$(t,e,n,r){let i=fP(t,e),o=Ed(i,n);Md(i),await Oc(e.configHome,U$(r),e.home);let s=["exec zsh Open tabs run the new layer — new tabs already do",...Nd(i,o)],a=`Updated to ${Ot.version} — kept ${j$(i.installed)}`;if(!r){console.log([a,...s].join(`
530
- `));return}br(s.join(`
531
- `),a),lu("Done")}function $P(t,e){let n=[`Placed ${t.copies.length} files`,`Settings in ${t.settings.file} — edit later with \`ttheme config\``,...t.edits.map((r)=>`Wired ${r.file}`),...Nd(t,e),"No palettes yet — open a new shell (`exec zsh`), then `ttheme browse` picks them from the catalog"];console.log(n.join(`
532
- `))}async function W$(t={}){let e=dt(import.meta.dirname,"..");if(!Br(dt(e,"bin","ttheme.js")))throw Error("bin/ttheme.js is missing — run `mise run bin:build` first");if(!Br(dt(e,"dist"))){if(typeof Bun>"u")throw Error("this package is missing dist/ — reinstall @kecan0406/ttheme");await Ic()}let n=aP(),r=Y(),i=process.env.ZDOTDIR??n,o=Pr(),s=lw(o),a=process.env.WT_PROFILE_ID,c={root:e,home:n,configHome:r,zdotdir:i,stateDir:dt(process.env.XDG_STATE_HOME??dt(n,".local","state"),"ttheme"),...s?{wtHome:s}:{},...a?{wtProfile:a}:{}},u=ne(process.env),l=Sd(c,o).filter((O)=>O===u||sr[O].present(c));if(!t.yes&&(process.stdin.isTTY!==!0||process.stdout.isTTY!==!0))throw Error("init asks before it edits your configs — run it in a terminal, or pass --yes to accept the defaults");let f=T$(r);if(t.yes&&f){await L$(f,c,o,!1);return}if(t.yes){if(l.length===0)throw Error(`no supported terminal detected — run this inside ${lt(Sd(c,o)).map((W)=>W.name.toLowerCase()).join(", ").replace(/, ([^,]*)$/," or $1")}`);let F=Pc({terminals:l,palettes:[]},c),j=Ed(F,o);Md(F),$P(F,j);return}if(Gs("ttheme init"),f){let O=dP(r);if(vs(await rn({message:`ttheme${O?` ${O}`:""} is installed — ${j$(f)}
533
- ${O===Ot.version?"Reinstall":"Update to"} ${Ot.version} and keep all of it?`,active:"Yes",inactive:"No, set it up again",initialValue:!0}))){await L$(f,c,o,!0);return}}let d=await hP(u,f?.terminals??l,c,o),m=d.includes("warp")?await mP(r):void 0,g=f?uP(f,c):Od(e),$=f?await Id(g,f.palettes,"palette",!0):await Id(g,[],"series",!0);if(!$)throw Vr("Nothing changed"),new Ze;let w=(f&&C$(f,$))??$[0],b=$.length>1&&(Oe[u].paints||u==="warp"&&d.includes("warp")&&Br(ir(n,r))),v=vs(await rn({message:b?"Pick a default palette in ttheme preview once installed?":`Wear ${w} in every tab?`,initialValue:f?!f.off:!0})),R={terminals:d,palettes:$,off:!v,warpFast:m},S=f?lP(f,R,c):Pc(R,c);if(br([`Install ${$.length} palettes — ${G$(g,$).join(", ")}`,`Copy ${S.copies.length} files under ${r}`,`Write ${S.settings.file}`,...S.edits.map((O)=>`Edit ${O.file} — a ttheme block: source ttheme.zsh`),...pw(r,S.installed,n),"Each config is backed up once to <file>.ttheme.bak before the first edit — `npx @kecan0406/ttheme uninstall` takes it all out",v?b?`Open ttheme preview — every tab wears the palette picked there, ${w} until then`:`Paint every tab with ${w}, this one now`:"Leave the terminal colors as they are — `ttheme on` wears a palette later",...v&&w?lt(d).flatMap((O)=>O.defaults?[`Make "${O.defaults.profile(w)}" the ${O.name} default profile`]:[]):[]].join(`
534
- `),`Wiring ${lt(d).map((O)=>O.name).join(", ")}`),!vs(await rn({message:"Apply these changes?"})))throw Vr("Nothing changed"),new Ze;let I=Ed(S,o);if(Md(S),await Oc(r,U$(!0),n),v&&b)bP(r);let P=B(r);wP({...S,catalog:g,installed:P},R,gP(g,P,r),I)}function Pd(){return process.stdin.isTTY===!0&&process.stdout.isTTY===!0}function _$(t,e){if(t.includes("/"))return t;let n=Nr(e,!1),r=n.filter((o)=>Kn(o.dir).some((s)=>s.slug===t)),[i]=r.length===1?r:n.length===1?n:[];return i?`${i.id}/${t}`:t}function vP(t,e,n){let r=B(t),i=n.filter((o)=>!r.palettes.includes(o));if(i.length>0)Ye(t,e,r,{...r,palettes:[...r.palettes,...i]});else if(n.some((o)=>r.palettes.includes(o)))At(t,e,r);return{state:r,fresh:i}}function EP(t){let e=Math.max(0,...t.map((n)=>n.slot.length));return t.map((n)=>` ${n.slot.padEnd(e)} ${n.from} → ${n.to} ${n.rule}`)}function B$(t,e,n){let r=Up(e),i=ve(ee(r.name,kl(r),n.palettes)),o=wt(t,n,!1).palettes.find((s)=>s.name===i.name);if(o&&JSON.stringify(o)!==JSON.stringify(i))throw Error(`${i.name} is already in ${rt(i.name)??"the ttheme catalog"} and differs — \`ttheme add ${i.name}\` wears that one`);if(!o)va(t,[...hn(t),i]);return i.name}var SP=["background","foreground","cursor"];function z$(t){try{t();return}catch(e){return e.message}}function K$(t,e,n){return wt(t,e,!1).palettes.filter((r)=>r.name!==n).map((r)=>({name:r.name,colors:{background:r.background,foreground:r.foreground,cursor:r.cursor,selection:r.selection,ansi:r.ansi}}))}function q$(t,e){let n=new Set(fe(t,e).map((r)=>r.key));return{count:()=>fe(t,e).length,added:()=>fe(t,e).filter((r)=>!n.has(r.key)).length,fresh:()=>(tc(t,e)??[]).filter((r)=>!n.has(Wt(r))),discard:()=>{let r=fe(t,e).filter((i)=>!n.has(i.key));for(let i of r)ki(t,e,i.key),fa(t,e);if(r.length>0)oe(t)}}}function MP(...t){let e=new Map;for(let n of t.flatMap((r)=>r??[]))e.set(Wt(n),n);return e.size>0?[...e.values()]:void 0}function J$(t,e,n,r){if(!gb(process.env))return;return async(i,o)=>{let s=ve(ee(e,r(i),n.palettes)),{saved:a}=await E$(t,s,o);return{...a?{note:a}:{},count:fe(t,e).length}}}async function Y$(t){let e=process.stdout.isTTY===!0,n=Zn(process.env,e)??lr(process.env,e,Y()),r=n?await n.saved():new Map,i=n?.look?{look:(o)=>n.look?.(t.name,o)}:n?{only:n.slots}:{};try{return await X0(t,{color:!zt(),...i})}finally{if(n)process.stdout.write(n.restore(r))}}async function D$(t,e,n){let r=Y(),i=ct(r),o=await qw(r,n),s=t.includes("/")?t:`${o.id}/${t}`,a=ke(s);if(a)throw Error(`${s} ${a}`);if(rt(s)!==o.id)throw Error(`palettes in ${o.dir} are named ${o.id}/<palette> — ${s} belongs elsewhere`);let c=wl(r,s);if(Es(c))throw Error(`${s} already exists — \`ttheme edit ${s}\` changes it`);let u=e?mn(wt(r,i).palettes,e):void 0;if(!Pd())throw Error("new opens the palette editor — run it in a terminal");let l=u&&(rt(u.name)?u.base:u.default?void 0:u.name),f=u?$l(u,s,`kept from ${u.name}`):void 0,d=u?tc(r,u.name)??u.pictures:void 0,{base:m,ansiSource:g,group:$,...w}=f??{name:s,signature:SP,...Wr(wc)},b=q$(r,s),v=({colors:I,signature:P})=>{let O=MP(d,b.fresh());return kl({...w,...I,signature:P,...l?{base:l}:{},...O?{pictures:O}:{}})},R=await Y$({title:"New palette",name:s,...f?{colors:f}:{},signature:w.signature,...w.waive?{waive:w.waive}:{},palettes:K$(r,i,s),pictures:b.count(),find:J$(r,s,i,v),check:(I)=>z$(()=>ee(s,v(I),i.palettes))});if(!R){b.discard(),console.log("Nothing made");return}kP(yP(c),{recursive:!0}),T(c,v(R));let{state:S}=vP(r,i,[s]);console.log(` + ${s}${u?` from ${u.name}`:""}
535
- ${c}`),await pn(r,wt(r,i).palettes.filter((I)=>I.name===s),S.terminals),console.log(`
536
- \`ttheme use ${s}\` wears it · \`ttheme edit ${s}\` opens it again`)}function IP(t,e,n){let r=ve(ee(t,e,n.palettes));return Ho(r).length>0?No(r).filter((i)=>i.startsWith(" ✗")):[]}async function V$(t){let e=Y(),n=ct(e),r=B(e),i=wt(e,n,!1),o=_$(t,e),s=xc(e,o),a=s&&Es(s)?o:i.palettes.some((b)=>b.name===t)?t:o,c=xc(e,a);if(!c||!Es(c)){let b=i.palettes.some((v)=>v.name===a);throw Error(b?`${a} is not one of yours — \`ttheme new <name> --from ${a}\` makes your own copy`:`no palette of yours called ${a} — \`ttheme new\` makes one`)}if(!Pd())throw Error("edit opens the palette editor — run it in a terminal");let u=Rd(c,"utf8"),l;try{l=ee(a,u,n.palettes)}catch(b){throw Error(`${c} cannot be read — ${b.message}`)}let f=q$(e,a),d=new Set((l.pictures??[]).map((b)=>Wt(b))),m=({colors:b,signature:v})=>Ap(Wp(vl(u,b),v),f.fresh().filter((R)=>!d.has(Wt(R)))),g=await Y$({title:"Edit palette",name:a,colors:yl(l),signature:l.signatureSlots,waive:l.waive,palettes:K$(e,n,a),pictures:f.count(),find:J$(e,a,n,m),check:(b)=>z$(()=>ee(a,m(b),n.palettes))});if(!g){f.discard(),console.log("Nothing changed");return}let $=m(g);if($===u){console.log(f.added()>0?`Kept the pictures you added to ${a}`:"Nothing changed");return}if(T(c,$),r.palettes.includes(a))At(e,n,r);console.log(`Saved ${a}${r.palettes.includes(a)?" — new tabs and `ttheme use` wear it":` — \`ttheme add ${a}\` installs it`}`);let w=IP(a,$,n);if(w.length>0)console.log(`
717
+ }`;async function Iy(){if(nm())return;if(process.platform==="darwin"){let[t="",e=""]=(await bn("osascript",["-l","JavaScript","-e",mH])).stdout.trim().split("\t");return{stamp:t,picture:e==="picture"}}if(process.platform==="linux"&&!My()){let e=Boolean(process.env.WAYLAND_DISPLAY)?(await bn("wl-paste",["--list-types"])).stdout:(await bn("xclip",["-selection","clipboard","-t","TARGETS","-o"])).stdout;return{stamp:e,picture:/^image\//m.test(e)}}return}function Ku(t){return t.length>8&&/^(?:\/|~\/|file:|https?:)/.test(t)}var ga=(t)=>Buffer.from(t).toString("base64"),Xh=(t)=>Buffer.from(t,"base64");function by(t,e){return e.find((n)=>t.includes(n))}class rm{clipboard=!1;drops=!1;reading;offered=[];dropping;pw=ga(wy("sha1").update(`${process.pid}:${Date.now()}`).digest("hex"));send;deliver;constructor(t,e){this.send=t,this.deliver=e}start(){let t="";if(this.clipboard)t+="\x1B[?5522h";if(this.drops)t+=`\x1B]72;t=a;${Qh.join(" ")}\x1B\\`;this.send(t)}stop(){this.send(`${this.clipboard?"\x1B[?5522l":""}${this.drops?"\x1B]72;t=A\x1B\\":""}`)}ask(){this.reading={mime:".",chunks:[],pw:"",listing:!0},this.send(`\x1B]5522;type=read:name=${ga("ttheme")}:pw=${this.pw};${ga(".")}\x1B\\`)}take(t){if(t.code==="5522")this.clip(t.meta,t.payload);else if(t.code==="72")this.drop(t.meta,t.payload)}clip(t,e){if(t.type!=="read")return;let n=t.status??"";if(n==="OK"){if(this.reading??={mime:".",chunks:[],pw:t.pw??"",listing:!0},t.pw)this.reading.pw=t.pw;return}let r=this.reading;if(!r)return;if(n==="DATA"){if(r.mime=t.mime?Xh(t.mime).toString("utf8"):r.mime,e)r.chunks.push(Xh(e));return}if(this.reading=void 0,n!=="DONE"){this.deliver({kind:"error",message:n==="EPERM"?"The clipboard read was not allowed":`The terminal answered ${n}`});return}let i=Buffer.concat(r.chunks);if(r.listing){let s=i.toString("utf8").split(/\s+/).filter(Boolean),o=by(s,[...tm,...cH]);if(!o){this.deliver({kind:"text",text:""});return}let a=r.pw||this.pw,c=r.pw?"Paste event":"ttheme";this.reading={mime:o,chunks:[],pw:a,listing:!1},this.send(`\x1B]5522;type=read:name=${ga(c)}:pw=${a};${ga(o)}\x1B\\`);return}this.deliver(r.mime.startsWith("image/")?{kind:"bytes",bytes:new Uint8Array(i),source:"clipboard"}:{kind:"text",text:i.toString("utf8")})}drop(t,e){let n=t.t??"";if(n==="m"){if(t.x==="-1"){this.offered=[];return}if(e){this.offered=e.split(" ").filter(Boolean);let a=Qh.filter((c)=>this.offered.includes(c));this.send(`\x1B]72;t=m:o=${a.length>0?1:0};${a.join(" ")}\x1B\\`)}return}if(n==="M"){let a=e?e.split(" ").filter(Boolean):this.offered,c=by(a,Qh);if(!c){this.send("\x1B]72;t=r:o=0\x1B\\");return}this.dropping={mimes:a,index:a.indexOf(c)+1,chunks:[]},this.send(`\x1B]72;t=r:x=${this.dropping.index}\x1B\\`);return}let r=this.dropping;if(!r)return;if(n==="R"){this.dropping=void 0,this.send("\x1B]72;t=r:o=0\x1B\\"),this.deliver({kind:"error",message:`The drop failed: ${e.split(":")[0]||"unknown error"}`});return}if(n!=="r"&&n!=="")return;if(e)r.chunks.push(Xh(e));if(t.m==="1"||e)return;this.dropping=void 0;let i=Buffer.concat(r.chunks),s=r.mimes[r.index-1]??"",o;if(s.startsWith("image/"))o={kind:"bytes",bytes:new Uint8Array(i),source:"drop"};else{let a=i.toString("utf8"),c=s==="text/uri-list"?Vs(a).find((u)=>tH(u)):void 0;o=c?{kind:"bytes",bytes:new Uint8Array(Uu(c)),source:c}:{kind:"text",text:a}}this.send("\x1B]72;t=r:o=1\x1B\\"),this.deliver(o)}}var im=5,pH=6,xy=0.05,gH=[1,2,3,4,5,6,9,10,11,12,13,14],Ny=(t,e)=>(e-t+360)%360<=180?1:-1;function ba(t,e,n){let r=e*Math.cos(n*Math.PI/180),i=e*Math.sin(n*Math.PI/180),s=[t+0.3963377774*r+0.2158037573*i,t-0.1055613458*r-0.0638541728*i,t-0.0894841775*r-1.291485548*i].map((l)=>l**3),[o,a,c]=s,u=[4.0767416621*o-3.3077115913*a+0.2309699292*c,-1.2684380046*o+2.6097574011*a-0.3413193965*c,-0.0041960863*o-0.7034186147*a+1.707614701*c];if(u.some((l)=>l<-0.0001||l>1.0001))return;return u.map((l)=>{let d=Math.min(1,Math.max(0,l));return Math.round(255*(d<=0.0031308?12.92*d:1.055*d**0.4166666666666667-0.055))})}function sm(t,e,n){if(ba(t,n,e)!==void 0)return n;let r=0,i=n;for(let s=0;s<24;s++){let o=(r+i)/2;if(ba(t,o,e)===void 0)i=o;else r=o}return r}function Ae(t,e,n){return`#${(ba(t,sm(t,n,e),n)??[0,0,0]).map((i)=>i.toString(16).padStart(2,"0")).join("")}`}function bH(t,e){let{l:n,c:r}=St(t);return Ae(n,r,(e+360)%360)}function wH(t,e,n){let{l:r,c:i,h:s}=St(t),o=yt(e)<0.18,a=(l)=>Ae(o?r+(1-r)*l:r*(1-l),i,s);if(bt(a(1),e)<n+xy)return a(1);let c=0,u=1;for(let l=0;l<30;l++){let d=(c+u)/2;if(bt(a(d),e)>=n+xy)u=d;else c=d}return a(u)}function $H(t,e){let{l:n,c:r,h:i}=St(t),s=0,o=n;for(let a=0;a<30;a++){let c=(s+o)/2;if(yt(Ae(c,r,i))<=e-0.005)s=c;else o=c}return Ae(s,r,i)}function kH(t,e,n){let r=fe[e],[i,s]=[St(t[e]),St(t[e+8])],o=(l,d)=>n.has(l)?[d]:Array.from({length:2*r.width+1},(f,h)=>(r.center-r.width+h+360)%360),a=(l,d,f)=>Zn.every((h)=>{let p=(l>8?8:0)+h;if(p===l)return!0;let $=St(t[p]);return $.c<oo||Ne($.h,d)>=qi+1||Math.abs($.l-f)>=Yi}),c,u=Number.POSITIVE_INFINITY;for(let l of o(e,i.h)){if(!n.has(e)&&!a(e,l,i.l))continue;for(let d of o(e+8,s.h)){if(Ne(l,d)>Le-im||!n.has(e+8)&&!a(e+8,d,s.l))continue;let f=Ne(l,i.h)+Ne(d,s.h);if(f<u)u=f,c=[l,d]}}return c}class Ry{theme;moves=[];constructor(t){this.theme={...t,ansi:[...t.ansi]}}set(t,e,n){let r=this.get(t);if(n===r)return;if(this.moves.push({slot:t,rule:e,from:r,to:n}),t==="foreground")this.theme.foreground=n;else if(t==="selection")this.theme.selectionBackground=n;else this.theme.ansi[Number(t.slice(4))]=n}get(t){if(t==="foreground")return this.theme.foreground;if(t==="selection")return this.theme.selectionBackground;return this.theme.ansi[Number(t.slice(4))]}rehue(t,e,n){this.set(`ansi${t}`,e,bH(this.theme.ansi[t],n))}roles(){let t=new Set(this.theme.signatureSlots);for(let{slot:n,hue:r}of Qn(this.theme)){let i=fe[Qe(n)];this.rehue(n,"ansi-role",i.center+Ny(i.center,r)*(i.width-im))}for(let{normal:n,gap:r}of Mn(this.theme)){if(r<=Le)continue;let[i,s]=t.has(`ansi${n+8}`)?[n+8,n]:[n,n+8],o=St(this.theme.ansi[i]).h,a=St(this.theme.ansi[s]).h;this.rehue(s,"bright-follows",o+Ny(o,a)*(Le-im))}let e=Ji(this.theme);for(let[n,r]of On(this.theme)){let i=Qe(e.has(r)?n:r),s=kH(this.theme.ansi,i,e);if(s===void 0)continue;this.rehue(i,"distinct",s[0]),this.rehue(i+8,"distinct",s[1])}}readability(){let t=new Set(this.theme.waive),{background:e}=this.theme,n=(r,i,s,o=e)=>{if(t.has(r))return;for(let a of i)if(bt(this.get(a),o)<s)this.set(a,r,wH(this.get(a),o,s))};if(n("foreground",["foreground"],7),n("accents",gH.map((r)=>`ansi${r}`),3),n("light-ansi",["ansi7","ansi15"],7),n("ansi8-visible",["ansi8"],1.6),!t.has("ansi0-dark")&&yt(this.get("ansi0"))>0.15)this.set("ansi0","ansi0-dark",$H(this.get("ansi0"),0.15));n("selection",["selection"],7,this.theme.foreground)}net(){return[...new Set(this.moves.map((t)=>t.slot))].flatMap((t)=>{let e=this.moves.filter((i)=>i.slot===t),n=e[0].from,r=this.get(t);return n===r?[]:[{slot:t,rule:[...new Set(e.map((i)=>i.rule))].join(", "),from:n,to:r}]})}}function zu(t){let e=new Ry(t);for(let n=0;n<pH;n++)if(e.readability(),e.roles(),Qr(e.theme).length===0)break;return{theme:e.theme,moves:e.net(),left:Qr(e.theme)}}var Hi=[{key:"background",label:"Background",min:0,max:0.5,step:0.01,digits:2},{key:"foreground",label:"Foreground",min:0.5,max:1,step:0.01,digits:2},{key:"hue",label:"Hue",min:0,max:360,step:1,digits:0,wraps:!0},{key:"tint",label:"Tint",min:0,max:0.1,step:0.005,digits:3},{key:"lightness",label:"Accent lightness",min:0.4,max:0.95,step:0.01,digits:2},{key:"chroma",label:"Accent chroma",min:0,max:0.3,step:0.005,digits:3},{key:"brights",label:"Brights",min:-0.2,max:0.2,step:0.01,digits:2}],wa={background:0.21,foreground:0.88,hue:265,tint:0.02,lightness:0.72,chroma:0.12,brights:0.06},Ty=(t,e,n)=>Math.min(n,Math.max(e,t));function om(t,e,n){let r=t[e.key]+e.step*n,i=e.wraps?(r%e.max+e.max)%e.max:Ty(r,e.min,e.max);return{...t,[e.key]:Math.round(i*1e4)/1e4}}function Ur(t){let e=(r,i,s)=>Ae(Ty(r,0,1),i,s),n=Array.from({length:16},()=>"#000000");n[0]=e(t.background+0.06,t.tint,t.hue),n[8]=e(t.background+0.25,t.tint,t.hue),n[7]=e(t.foreground-0.06,t.tint/2,t.hue),n[15]=e(t.foreground+0.06,t.tint/2,t.hue);for(let r of Zn){let i=fe[r].center;n[r]=e(t.lightness,t.chroma,i),n[r+8]=e(t.lightness+t.brights,t.chroma,i)}return{background:e(t.background,t.tint,t.hue),foreground:e(t.foreground,t.tint/2,t.hue),cursor:e(t.lightness+t.brights,Math.max(t.chroma,0.08),t.hue),selection:e(t.background+0.1,t.tint*2,t.hue),ansi:n}}var Li=["background","foreground","cursor","selection",...Array.from({length:16},(t,e)=>`ansi${e}`)],L=["Background","Foreground","Cursor","Selection"],Du=["Black","Red","Green","Yellow","Blue","Magenta","Cyan","White"],Kr=L.length+Du.length,Ye=[{key:"l",label:"Lightness",min:0,max:1,step:0.01,digits:2},{key:"c",label:"Chroma",min:0,max:0.37,step:0.005,digits:3},{key:"h",label:"Hue",min:0,max:360,step:1,digits:0,wraps:!0}],Py=5,Yn=Ye.length,Qs=["this","pair","normals","brights","accents"],qu=[1,2,3,4,5,6,9,10,11,12,13,14],Hy=qu.filter((t)=>t<8).map((t)=>L.length+t),Ay=qu.filter((t)=>t>8).map((t)=>L.length+t);function am(t,e){let n=e-L.length;if(n<0||t==="this")return[e];if(t==="pair")return[L.length+n%8,L.length+8+n%8];let r=t==="normals"?Hy:t==="brights"?Ay:[...Hy,...Ay];return r.includes(e)?r:[e]}function yH(){return Array.from({length:Kr},(t,e)=>e<L.length?[e]:[e,e+8]).flat()}function vH(t){let e=t.trim();return/^https?:\/\/\S+$/i.test(e)||Vs(e).length>0}function Zs(t){return[t.background,t.foreground,t.cursor,t.selection,...t.ansi]}function ee(t){let[e,n,r,i,...s]=t;return{background:e,foreground:n,cursor:r,selection:i,ansi:s}}function Fi(t){if(t<L.length)return{name:L[t],about:Li[t]};let e=t-L.length,n=Du[e%8];return e<8?{name:n,about:`ansi ${e}`}:{name:`Bright ${n.toLowerCase()}`,about:`ansi ${e}`}}var Xs=(t,e,n)=>Math.min(n,Math.max(e,t));function Fy(t){return t.length===1?t.toLowerCase():t}function SH(t){return Xs(Math.round(t),0,255).toString(16).padStart(2,"0")}function Cy(t){let e=t.trim().toLowerCase(),n=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/.exec(e);if(n){let s=n[1];return`#${s.length===3?[...s].map((o)=>o+o).join(""):s}`}let r=/^rgb\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)\s*\)$/.exec(e);if(r)return`#${r.slice(1,4).map((s)=>SH(Number(s))).join("")}`;let i=/^oklch\(\s*([\d.]+)(%?)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:deg|°)?\s*\)$/.exec(e);if(i){let s=Number(i[1])/(i[2]?100:1);return Ae(Xs(s,0,1),Number(i[3]),Number(i[4])%360)}return}function Ai(t){let e=he.find((n)=>n.rule===t);return e?.min??e?.max??0}function Ci(t,e,n){let r=ee(t);return{name:"draft",background:r.background,foreground:r.foreground,selectionBackground:r.selection,ansi:r.ansi,waive:n,signatureSlots:e}}function EH(t,e){let n=t-L.length,r=t<=1?"foreground":t===3?"selection":n===7||n===15?"light-ansi":n===8?"ansi8-visible":qu.includes(n)?"accents":void 0;return{against:t===0||t===3?1:0,floor:r===void 0||e.includes(r)?void 0:Ai(r)}}function lm(t,e,n,r){let i=Ci(t,e,n),{background:s,foreground:o,selection:a,ansi:c}=ee(t),u=(l,d,f)=>bt(d,f)<Ai(r)?[l]:[];if(r==="foreground")return bt(o,s)<Ai(r)?[1,0]:[];if(r==="selection")return bt(o,a)<Ai(r)?[3,1]:[];if(r==="accents")return qu.flatMap((l)=>u(L.length+l,c[l],s));if(r==="light-ansi")return[7,15].flatMap((l)=>u(L.length+l,c[l],s));if(r==="ansi8-visible")return u(L.length+8,c[8],s);if(r==="ansi0-dark")return yt(c[0])>Ai(r)?[L.length]:[];if(r==="ansi-role")return Qn(i).map(({slot:l})=>L.length+l);if(r==="bright-follows")return Mn(i).filter(({gap:l})=>l>Le).flatMap(({normal:l})=>[L.length+l,L.length+l+8]);if(r==="distinct")return On(i).flatMap(([l,d])=>[L.length+l,L.length+d]);return[]}function MH(t,e,n){return new Set(Li.flatMap((r,i)=>Yu(t,e,n,i).some((s)=>s.ok===!1)?[i]:[]))}function qn(t,e,n,r,i){let s=bt(t,e),o=Ai(n);if(i.includes(n))return{ok:void 0,text:`${r} ${s.toFixed(2)}:1 · waived`};return{ok:s>=o,text:`${r} ${s.toFixed(2)}:1 · ≥ ${o}`}}function Yu(t,e,n,r){let i=ee(t),s=Ci(t,e,n);if(r===0){let b=[1,2,3,4,5,6,9,10,11,12,13,14].reduce((y,S)=>bt(i.ansi[y],i.background)<=bt(i.ansi[S],i.background)?y:S);return[qn(i.foreground,i.background,"foreground","Foreground on it",n),qn(i.ansi[b],i.background,"accents",`Weakest, ANSI ${b},`,n),qn(i.ansi[8],i.background,"ansi8-visible","ANSI 8 on it",n)]}if(r===1)return[qn(i.foreground,i.background,"foreground","On background",n),qn(i.foreground,i.selection,"selection","On the selection",n)];if(r===2)return[{ok:void 0,text:`On background ${bt(i.cursor,i.background).toFixed(2)}:1`}];if(r===3)return[qn(i.foreground,i.selection,"selection","Foreground on it",n)];let o=r-L.length,a=i.ansi[o];if(o===0){let g=yt(a),b=Ai("ansi0-dark");return[n.includes("ansi0-dark")?{ok:void 0,text:`Luminance ${g.toFixed(3)} · waived`}:{ok:g<=b,text:`Luminance ${g.toFixed(3)} · ≤ ${b}`}]}if(o===7||o===15)return[qn(a,i.background,"light-ansi","On background",n)];if(o===8)return[qn(a,i.background,"ansi8-visible","On background",n)];let c=[qn(a,i.background,"accents","On background",n)],u=St(a),l=Qe(o),d=fe[l],f=`${d.name} ${d.center}±${d.width}°`;if(u.c<oo)c.push({ok:void 0,text:"Too grey to have a hue"});else if(Ji(s).has(o))c.push({ok:void 0,text:`Hue ${u.h.toFixed(0)}° · a signature, free of ${f}`});else if(n.includes("ansi-role"))c.push({ok:void 0,text:`Hue ${u.h.toFixed(0)}° · ${f} waived`});else{let g=Ne(u.h,d.center)-d.width;c.push(g>0?{ok:!1,text:`Hue ${u.h.toFixed(0)}° · ${g.toFixed(0)}° outside ${f}`}:{ok:!0,text:`Hue ${u.h.toFixed(0)}° · in ${f}`})}let h=o<8?o+8:o-8,p=Mn(s).find((g)=>g.normal===l);if(p)c.push(n.includes("bright-follows")?{ok:void 0,text:`${p.gap.toFixed(0)}° from ANSI ${h} · waived`}:{ok:p.gap<=Le,text:`${p.gap.toFixed(0)}° from ANSI ${h} · ≤ ${Le}°`});let $=On(s).flatMap(([g,b])=>g===o?[b]:b===o?[g]:[]);if($.length>0&&!n.includes("distinct"))c.push({ok:!1,text:`Reads as ANSI ${$.join(", ")} · within ${qi}° and ${Yi} lightness`});return c}function jy(t,e,n){let r=Xe(Ci(t,e,n));return he.map((i,s)=>{let o=r[s],a=n.includes(i.rule),c=a||Number.isNaN(o)?void 0:(i.min===void 0||o>=i.min)&&(i.max===void 0||o<=i.max);return{ok:c,label:i.label,value:Number.isNaN(o)?"—":Number.isInteger(o)?String(o):o.toFixed(2),bound:a?"waived":i.min!==void 0?`≥ ${i.min}`:i.max!==void 0?`≤ ${i.max}`:"",slots:c===!1?lm(t,e,n,i.rule):[]}})}var OH=new Set(["reset","reset-all","hex","paste","fix","open","tune","sig","follow"]),Gy=Ye[1].max;function cm(t){let[e,n,r]=nt(t);return e===n&&n===r}function um(t,e){return Math.floor(sm(t,e,Gy)*1e4)/1e4}function Ly(t,e){let n=t.wraps?t.max-t.step:t.max;return Math.min(n,Math.round((t.min+(t.max-t.min)*e)/t.step)*t.step)}class $a{mode;seeds=wa;field=0;list;lch;start;original;signature;row=0;col=0;channel=0;scope="this";view="slot";scene=0;typing;overlay;quitting=!1;compare=!1;notice;filter="";pick=0;result;act;wants;pictures;startPictures;options;fresh;theme;startSignature;seeded=!1;tuneFrom;holds=new Map;clip;history=[];future=[];lastEdit;constructor(t){this.options=t,this.theme=t.variant==="theme",this.fresh=t.colors===void 0,this.mode=this.fresh?"seeds":"list",this.list=Zs(t.colors??Ur(this.seeds)),this.lch=this.lchs(),this.start=[...this.list],this.original=t.original?Zs(t.original):[...this.list],this.signature=[...t.signature],this.startSignature=[...t.signature],this.pictures=t.pictures??0,this.startPictures=this.pictures}markSaved(){this.start=[...this.list],this.history=[],this.future=[],this.lastEdit=void 0}offDefault(t){return this.list[t]!==this.original[t]}get added(){return Math.max(0,this.pictures-this.startPictures)}found(t){this.pictures=t.count,this.notice=t.note}get waive(){return this.options.waive??[]}get held(){return this.holds.get(this.slot())}colors(){return ee(this.list)}edited(){return{colors:this.colors(),signature:[...this.signature]}}shown(){return this.compare?this.start:this.list}slot(){return this.row<L.length?this.row:this.row+(this.col===1?8:0)}dirty(){return this.seeded||this.pictures!==this.startPictures||this.list.some((t,e)=>t!==this.start[e])||this.signature.join()!==this.startSignature.join()}misses(){return MH(this.list,this.signature,this.waive)}failing(){return Qr(Ci(this.list,this.signature,this.waive))}choices(){let t=this.filter.toLowerCase();return(this.options.palettes??[]).filter((e)=>e.name.toLowerCase().includes(t))}paste(t){if(this.notice=void 0,this.overlay==="open"){this.filter+=t.replace(/\s+/g,"").toLowerCase(),this.pick=0;return}if(this.overlay)return;if(t.trim()===""){this.findPictures({clipboard:!0});return}if(vH(t)){this.findPictures({paste:t});return}if(this.mode==="seeds")return;let e=Cy(t);if(!e){this.notice="Not a color — #rrggbb, rgb(r g b) or oklch(l c h)";return}this.typing=void 0,this.take(e,"paste")}press(t){if(this.notice=void 0,t==="ctrl-c"){if(this.theme)this.act="cancel";else this.result="cancelled";return}if(this.quitting){if(this.quitting=!1,t==="y"||t==="Y")this.result="cancelled";return}if(this.typing!==void 0){this.type(t);return}if(this.overlay==="keys"){this.overlay=void 0;return}if(this.overlay==="open"){this.openKey(t);return}if(t==="?"){this.overlay="keys";return}if(this.theme&&(t==="ctrl-v"||t==="alt-v"||t==="p"))return;if(t==="ctrl-v"||t==="alt-v"){this.findPictures({clipboard:!0});return}if(t==="p"&&this.mode!=="tune"){this.findPictures();return}if(t===" "&&this.mode!=="seeds"){this.compare=!this.compare;return}if(this.compare&&t==="esc"){this.compare=!1;return}if(t==="g"&&this.mode!=="seeds"){this.view=this.view==="slot"?"relations":"slot";return}let e=t==="j"?"down":t==="k"?"up":t;if(this.mode==="seeds")this.seedKey(e);else if(this.mode==="tune")this.tuneKey(e);else this.listKey(e)}select(t){if(this.mode==="seeds"||this.typing!==void 0||this.overlay||this.quitting)return;if(this.mode==="tune"){if(t===this.slot())return;this.tuneKey("enter")}if(this.notice=void 0,this.row=t<L.length?t:L.length+(t-L.length)%8,t>=L.length)this.col=t-L.length>=8?1:0;this.lastEdit=void 0}grip(t){if(this.mode==="seeds"||this.typing!==void 0||this.overlay||this.quitting)return!1;if(this.notice=void 0,this.mode==="list")this.tune();return this.channel=t,!0}slide(t,e){if(!this.grip(t))return;let n=Math.min(1,Math.max(0,e));if(t===Yn){this.reach(21**n);return}this.put(Ly(Ye[t],n))}sow(t,e){let n=Hi[t];if(this.mode!=="seeds"||this.overlay||this.quitting||!n)return;this.notice=void 0,this.field=t;let r=Math.min(1,Math.max(0,e));this.seeds=om({...this.seeds,[n.key]:Ly(n,r)},n,0),this.list=Zs(Ur(this.seeds)),this.lch=this.lchs()}scroll(t){let e=(n,r)=>Math.min(r,Math.max(0,n+t));if(this.overlay==="open")this.pick=e(this.pick,Math.max(0,this.choices().length-1));else if(this.overlay||this.quitting||this.typing!==void 0)return;else if(this.mode==="seeds")this.field=e(this.field,Hi.length-1);else if(this.mode==="tune")this.channel=e(this.channel,Yn);else this.row=e(this.row,Kr-1),this.lastEdit=void 0}lchOf(t){let e=St(t);return cm(t)?{...e,h:this.neutralHue()}:e}lchs(){return this.list.map((t)=>this.lchOf(t))}neutralHue(){let t=[0,1,3,2].map((e)=>this.list[e]).find((e)=>!cm(e));return t?St(t).h:wa.hue}seedKey(t){let e=Hi.length;if(t==="up"||t==="down")this.field=(this.field+(t==="up"?e-1:1))%e;else if(t==="home"||t==="end")this.field=t==="home"?0:e-1;else if(t==="left"||t==="right"||t==="shift-left"||t==="shift-right"){let n=Hi[this.field],r=(t.endsWith("left")?-1:1)*(t.startsWith("shift")?n.wraps?10:Py:1);this.seeds=om(this.seeds,n,r),this.list=Zs(Ur(this.seeds)),this.lch=this.lchs()}else if(t==="enter")this.leaveSeeds();else if(t==="o")this.openPalettes();else if(t==="esc")this.leave()}leaveSeeds(){this.start=[...this.list],this.original=[...this.list],this.seeded=!0,this.mode="list"}leave(){if(this.theme)this.act="cancel";else if(this.dirty())this.quitting=!0;else this.result="cancelled"}findPictures(t){if(!this.options.find){this.notice="Pictures need Ghostty, iTerm2 or kitty, outside tmux";return}this.wants=t?{start:t}:{}}openPalettes(){if((this.options.palettes??[]).length>0)this.overlay="open",this.pick=0;else this.notice="No other palettes to take colors from"}listKey(t){if(t==="up"||t==="down"){if(this.theme&&this.row===(t==="up"?0:Kr-1))this.act=t==="up"?"above":"below";else this.row=(this.row+(t==="up"?Kr-1:1))%Kr;this.lastEdit=void 0}else if(t==="home"||t==="end")this.row=t==="home"?0:Kr-1;else if(t==="pgup"||t==="pgdn")this.row=t==="pgup"?0:L.length;else if(t==="left"||t==="right"){if(this.row>=L.length)this.col=t==="left"?0:1,this.lastEdit=void 0}else if((t==="shift-left"||t==="shift-right")&&!this.theme)this.scene+=t==="shift-left"?-1:1;else if(t==="n"||t==="N")this.nextMiss(t==="n"?1:-1);else if(t==="enter"||t==="tab")this.tune();else if(t==="#")this.typing="";else if(t==="c")this.clip=this.list[this.slot()],this.notice=`Copied ${this.clip}`;else if(t==="v")if(this.clip)this.set(this.slot(),this.clip,"paste");else this.notice="Nothing copied yet — c copies a slot";else if(t==="r")this.set(this.slot(),this.original[this.slot()],"reset");else if(t==="R")this.remember("reset-all"),this.list=[...this.original],this.lch=this.lchs();else if(t==="=")this.follow();else if(t==="*"&&!this.theme)this.mark();else if(t==="f")this.fix();else if(t==="o"&&!this.theme)this.openPalettes();else if(t==="u")this.undo();else if(t==="ctrl-r")this.redo();else if(t==="s"||t==="ctrl-s")if(this.theme)this.act="save";else this.save();else if(t==="esc")this.leave()}nextMiss(t){let e=yH(),n=this.misses();if(n.size===0){this.notice="The gate passes";return}let r=e.indexOf(this.slot());for(let i=1;i<=e.length;i++){let s=e[((r+t*i)%e.length+e.length)%e.length];if(n.has(s)){if(this.row=s<L.length?s:L.length+(s-L.length)%8,s>=L.length)this.col=s-L.length>=8?1:0;return}}}tune(){this.remember("tune"),this.tuneFrom={list:[...this.list],lch:[...this.lch]},this.holds=new Map,this.hold(),this.mode="tune"}hold(){for(let t of this.scoped())if(!this.holds.has(t))this.holds.set(t,this.lch[t].c)}scoped(){return am(this.scope,this.slot())}tuneKey(t){let e=Ye.length+1,n=this.channel===Yn;if(t==="up"||t==="down"||t==="tab"||t==="shift-tab")this.channel=(this.channel+(t==="up"||t==="shift-tab"?e-1:1))%e;else if(t==="left"||t==="right"||t==="shift-left"||t==="shift-right"){let r=t.endsWith("left")?-1:1;if(n)this.reach(this.ratio()+r*(t.startsWith("shift")?0.5:0.1));else{let i=Ye[this.channel];this.step(r*(t.startsWith("shift")?i.wraps?10:Py:1))}}else if(t==="home"||t==="end")if(n)this.reach(t==="home"?this.partner().floor??1:21);else{let r=Ye[this.channel];this.put(t==="home"?r.min:r.wraps?r.max-r.step:r.max)}else if(/^[0-9]$/.test(t))if(n){if(t!=="0")this.reach(Number(t))}else{let r=Ye[this.channel];this.put(r.min+(r.max-r.min)*Number(t)/10)}else if(t==="a")this.rescope();else if(t==="#")this.typing="";else if(t==="enter"){if(this.tuneFrom&&this.list.every((r,i)=>r===this.tuneFrom?.list[i]))this.history.pop();this.endTune()}else if(t==="esc"){if(this.tuneFrom)this.list=[...this.tuneFrom.list],this.lch=[...this.tuneFrom.lch],this.history.pop();this.endTune()}}rescope(){if(this.slot()<L.length){this.notice="A base color moves alone";return}let t=Qs.indexOf(this.scope);for(let e=1;e<=Qs.length;e++){let n=Qs[(t+e)%Qs.length];if(n==="this"||am(n,this.slot()).length>1){this.scopeTo(n);return}}}scopeTo(t){if(this.mode!=="tune"||this.typing!==void 0||this.quitting||this.slot()<L.length)return;if(t!=="this"&&am(t,this.slot()).length<=1)return;this.scope=t,this.hold();let e=this.scoped().length;this.notice=e>1?`${e} slots move together`:"This slot moves alone"}endTune(){this.tuneFrom=void 0,this.holds=new Map,this.mode="list"}partner(){return EH(this.slot(),this.waive)}ratio(){return bt(this.list[this.slot()],this.list[this.partner().against])}reach(t){let e=this.slot(),n=this.list[this.partner().against],r=this.lch[e],i=this.holds.get(e)??r.c,s=(f)=>Ae(f,Math.min(i,um(f,r.h)),r.h),o=(f)=>bt(s(f),n),a=yt(this.list[e])>=yt(n),c=St(n).l,u=Math.max(1,Math.round(t*100)/100),l=a?1:0,d;if(o(l)<u)d=l,this.notice=`The ratio stops at ${o(l).toFixed(2)}:1 on this side of the color it is read against`;else{let f=c,h=l;for(let p=0;p<24;p++){let $=(f+h)/2;if(o($)>=u)h=$;else f=$}d=h}this.place(e,d,i,r.h);for(let f=0;f<40&&d!==l&&bt(this.list[e],n)<u;f++)d=a?Math.min(1,d+0.001):Math.max(0,d-0.001),this.place(e,d,i,r.h);this.lch[e]={...this.lch[e],l:Math.round(d*1e4)/1e4}}step(t){let e=Ye[this.channel],n=this.lch[this.slot()][e.key];this.put(n+e.step*t)}put(t){let e=this.slot(),n=Ye[this.channel],r=n.wraps?(t%n.max+n.max)%n.max:Xs(t,n.min,n.max),i=Math.round(r*1e4)/1e4,s=this.lch[e],o=this.scoped().filter((u)=>u!==e),a=(u)=>Math.round(u*1e4)/1e4;if(n.key==="c"){let u=um(s.l,s.h);if(i>u)this.notice=`Chroma stops at ${u.toFixed(3)}, the sRGB edge for this lightness and hue`;let l=Math.min(i,u),d=l-s.c;this.holds.set(e,l),this.place(e,s.l,l,s.h);for(let f of o){let h=this.lch[f],p=a(Xs((this.holds.get(f)??h.c)+d,0,Gy));this.holds.set(f,p),this.place(f,h.l,p,h.h)}return}let c=n.key==="h"?((i-s.h)%360+540)%360-180:i-s.l;if(this.place(e,n.key==="l"?i:s.l,this.holds.get(e)??s.c,n.key==="h"?i:s.h),n.key==="h"&&cm(this.list[e]))this.notice="A grey shows no hue — raise its chroma first";for(let u of o){let l=this.lch[u];this.place(u,n.key==="l"?a(Xs(l.l+c,0,1)):l.l,this.holds.get(u)??l.c,n.key==="h"?a(((l.h+c)%360+360)%360):l.h)}}place(t,e,n,r){let i=Math.min(n,um(e,r));this.lch[t]={l:e,c:i,h:r},this.list[t]=Ae(e,i,r)}take(t,e){if(this.mode==="tune")this.list[this.slot()]=t,this.lch[this.slot()]=this.lchOf(t),this.holds.set(this.slot(),this.lch[this.slot()].c);else this.set(this.slot(),t,e)}type(t){let e=this.typing??"";if(t==="esc")this.typing=void 0;else if(t==="enter"){let n=Cy(e);if(!n){this.notice="Not a color — #rrggbb, rgb(r g b) or oklch(l c h)";return}this.typing=void 0,this.take(n,"hex")}else{let n=xi(e,Fy(t),(r)=>/^[0-9a-z#(),.% ]$/.test(r)&&e.length<28);if(n!==void 0)this.typing=n}}openKey(t){let e=this.choices();if(t==="esc")this.overlay=void 0,this.filter="";else if(t==="up"||t==="down"){let n=Math.max(1,e.length);this.pick=(this.pick+(t==="up"?n-1:1))%n}else if(t==="home"||t==="end")this.pick=t==="home"?0:Math.max(0,e.length-1);else if(t==="enter"){let n=e[this.pick];if(!n)return;if(this.remember("open"),this.list=Zs(n.colors),this.lch=this.lchs(),this.overlay=void 0,this.filter="",this.notice=`Took the colors of ${n.name}`,this.mode==="seeds")this.leaveSeeds()}else{let n=xi(this.filter,Fy(t),(r)=>/^[a-z0-9@/-]$/.test(r));if(n!==void 0)this.filter=n,this.pick=0}}remember(t){if(t!==this.lastEdit||OH.has(t))this.history.push({list:[...this.list],lch:[...this.lch],signature:[...this.signature]}),this.future=[];this.lastEdit=t}set(t,e,n){if(!ne(e)||this.list[t]===e)return;this.remember(n),this.list[t]=e,this.lch[t]=this.lchOf(e)}follow(){if(this.row<L.length){this.notice="= works on an ANSI row — the bright takes its normal";return}let t=this.row,e=this.row+8,n=this.lch[t];this.remember("follow"),this.place(e,Xs(n.l+0.06,0,1),n.c,n.h),this.col=1,this.notice=`${Fi(e).name} follows ${Fi(t).name.toLowerCase()}`}mark(){let t=Li[this.slot()];this.remember("sig");let e=this.signature.includes(t)?this.signature.filter((r)=>r!==t):[...this.signature,t],n=e.length>3?e[0]:void 0;this.signature=e.slice(-3),this.notice=this.signature.length===3?`Signature: ${this.signature.join(", ")}${n?` — ${n} dropped`:""}`:`The signature needs three slots — ${this.signature.length} marked`}fix(){let t=Ci(this.list,this.signature,this.waive),{theme:e,moves:n,left:r}=zu({...t,selectionBackground:t.selectionBackground,signatureSlots:this.signature});if(n.length===0){this.notice=Qr(t).length===0?"Already passes the gate":"No color change fixes it";return}this.remember("fix");let i=Zs({...this.colors(),foreground:e.foreground,selection:e.selectionBackground,ansi:e.ansi}),s=this.list;this.list=i,this.lch=i.map((o,a)=>o===s[a]?this.lch[a]:this.lchOf(o)),this.notice=`Moved ${n.length} ${n.length===1?"color":"colors"}${r.length===0?" — passes the gate":" closer to the gate"}`}save(){let t=this.options.check(this.edited());if(t){this.notice=t;return}this.result="saved"}undo(){let t=this.history.pop();if(!t){this.notice="Nothing to undo";return}this.future.push({list:[...this.list],lch:[...this.lch],signature:[...this.signature]}),this.restore(t)}redo(){let t=this.future.pop();if(!t){this.notice="Nothing to redo";return}this.history.push({list:[...this.list],lch:[...this.lch],signature:[...this.signature]}),this.restore(t)}restore(t){this.list=[...t.list],this.lch=[...t.lch],this.signature=[...t.signature],this.lastEdit=void 0}}import{mkdirSync as jH,readFileSync as hm,writeFileSync as qy}from"node:fs";import{dirname as GH}from"node:path";import{isMainThread as _H,parentPort as Yy,Worker as BH}from"node:worker_threads";var IH=new Set(["comic","4koma","monochrome","greyscale","sketch","lineart","speech_bubble"]),xH=new Set(["scenery","landscape","scenic","no_humans","wide_shot","very_wide_shot"]),NH=0.04,RH=0.1,TH=0.05,PH=4096;function HH(t){return new Set(t.cutouts.split(/\s+/).map((e)=>e.replace(/^~/,"")).filter(Boolean))}function AH(t,e,n,r=0){let{site:i,post:s}=t,o=new Set(s.tags),a=[...HH(i)].some((l)=>o.has(l)),c=Math.min(s.width,s.height),u=s.width>0&&s.height>0?s.width/s.height/(e.w/e.h):1;return(s.solo?2:0)+([...IH].some((l)=>o.has(l))?-3:0)+([...xH].some((l)=>o.has(l))?-1.5:0)+2*Math.min(1,c/e.h)+(a?1.5:-Math.min(1.5,Math.abs(Math.log(u))))+(n>0?1.5*Math.log1p(Math.max(0,s.score))/Math.log1p(n):0)+2*r}function Ju(t,e,n=new Map){let r=new Map;for(let{site:i,post:s}of t)r.set(i,Math.max(r.get(i)??0,s.score));return t.map((i,s)=>({pick:i,at:s,score:AH(i,e,r.get(i.site)??0,n.get(i.post))})).sort((i,s)=>s.score-i.score||i.at-s.at).map(({pick:i})=>i)}function By(t){let e=new Map;for(let r of t)e.set(r.site,[...e.get(r.site)??[],r]);let n=[];for(let r=0;n.length<t.length;r++)for(let i of e.values()){let s=i[r];if(s)n.push(s)}return n}function dm(t){let e=t/255;return e<=0.04045?e/12.92:((e+0.055)/1.055)**2.4}function _y(t,e,n){let[r,i,s]=[dm(t),dm(e),dm(n)],o=Math.cbrt(0.4122214708*r+0.5363325363*i+0.0514459929*s),a=Math.cbrt(0.2119034982*r+0.6806995451*i+0.1073969566*s),c=Math.cbrt(0.0883024619*r+0.2817188376*i+0.6299787005*s);return[0.2104542553*o+0.793617785*a-0.0040720468*c,1.9779984951*o-2.428592205*a+0.4505937099*c,0.0259040371*o+0.7827717662*a-0.808675766*c]}function Wy(t,e){let n=e.map((o)=>_y(...nt(o))).filter(([,o,a])=>Math.hypot(o,a)>=NH);if(n.length===0)return 0;let r=Math.max(1,Math.floor(Math.sqrt(t.width*t.height/PH))),i=n.map(()=>0),s=0;for(let o=0;o<t.height;o+=r)for(let a=0;a<t.width;a+=r){let c=(o*t.width+a)*4;if(t.data[c+3]<128)continue;s++;let[u,l,d]=_y(t.data[c],t.data[c+1],t.data[c+2]);n.forEach(([f,h,p],$)=>{if(Math.hypot(u-f,l-h,d-p)<RH)i[$]=i[$]+1})}if(s===0)return 0;return i.reduce((o,a)=>o+Math.min(1,a/s/TH),0)/n.length}var FH=/(?:^|[^0-9a-f])([0-9a-f]{32})(?:[^0-9a-f]|$)/i,CH=[[/yande\.re\/post\/show\/(\d+)/,"yande"],[/konachan\.(?:com|net)\/post\/show\/(\d+)/,"konachan"],[/danbooru\.donmai\.us\/(?:posts|post\/show)\/(\d+)/,"danbooru"],[/zerochan\.net\/(\d+)(?:[?#\s]|$)/,"zerochan"]];function fm(t){let e=/(\d+)_p(\d+)/.exec(t.source);return[...t.md5?[`md5:${t.md5}`]:[],...e&&t.source.includes("pximg")?[`pixiv:${e[1]}_p${e[2]}`]:[]]}function Uy(t,e){let n=FH.exec(e.source)?.[1]?.toLowerCase();return[`post:${t.key}:${e.id}`,...e.md5?[`md5:${e.md5}`]:[],...n&&n!==e.md5?[`md5:${n}`]:[],...CH.flatMap(([r,i])=>{let s=r.exec(e.source)?.[1];return s?[`post:${i}:${Number(s)}`]:[]}),...e.family?[`family:${t.key}:${e.family}`]:[]]}function Ky(t,e){let n=t.owner||t.named.artist[0]||"";return n!==""&&n===(e.owner||e.named.artist[0]||"")&&t.width===e.width&&t.height===e.height}function zy(t){let r=[];for(let s=0;s<8;s++){let o=Math.floor(s*t.height/8),a=Math.max(o+1,Math.floor((s+1)*t.height/8));for(let c=0;c<9;c++){let u=Math.floor(c*t.width/9),l=Math.max(u+1,Math.floor((c+1)*t.width/9)),d=0;for(let f=o;f<a;f++)for(let h=u;h<l;h++){let p=(f*t.width+h)*4,$=t.data[p+3]/255,g=0.299*t.data[p]+0.587*t.data[p+1]+0.114*t.data[p+2];d+=g*$+255*(1-$)}r.push(d/((l-u)*(a-o)))}}let i=0n;for(let s=0;s<8;s++)for(let o=0;o<8;o++)i=i<<1n|(r[s*9+o]>r[s*9+o+1]?1n:0n);return i.toString(16).padStart(16,"0")}function LH(t,e){let n=BigInt(`0x${t}`)^BigInt(`0x${e}`),r=0;while(n>0n)r+=Number(n&1n),n>>=1n;return r}function Dy(t,e){if(t.width<=0||t.height<=0||e.width<=0||e.height<=0)return!1;return Math.abs(Math.log(t.width/t.height/(e.width/e.height)))<0.01&&LH(t.hash,e.hash)<=2}var WH={thumb:"tile",band:"band",match:"tile",show:"view",backdrop:"view",redraw:"view"},Vu;async function UH(t){if(t.job==="redraw")return Eu(t.home,t.name,t.key,t.paint,t.blur,t.aligns,t.user);if(t.job==="show"){if(Vu?.from!==t.from){let o=nr(new Uint8Array(hm(t.from)),me);Vu={from:t.from,clear:In(o),inked:xd(o)}}let{image:r,fill:i,opacity:s}=Vb(Vu.inked,t.colors,t.tone,t.width,t.height,t.blur,t.tune,t.coloring);return jH(GH(t.to),{recursive:!0}),qy(t.to,rn(r)),{clear:Vu.clear,fill:i,opacity:s}}let e=nr(new Uint8Array(hm(t.from)),me);if(t.job==="backdrop"){oc(t.home,t.colors,t.tone,e,{...t.origin,bytes:new Uint8Array(hm(t.source)),cut:t.from!==t.source},t,t.blur,t.coloring);let r=t.tune&&re(t.home,t.colors.name).find((i)=>i.key===Xt(t.origin));if(t.tune&&r)Io(D(t.home),r,t.tune,t.aligns??!0,t.user??t.home);return 0}if(t.job==="match")return{match:Wy(e,t.colors),hash:zy(e)};if(t.job==="thumb")return H(t.to,rn(Cg(e,t.width,t.height))),0;let n=e.data.subarray(t.y*e.width*4,(t.y+t.height)*e.width*4);return qy(t.to,rn({width:e.width,height:t.height,data:n})),0}function KH(t){t.on("message",async(e)=>{try{t.postMessage({id:e.id,value:await UH(e)})}catch(n){t.postMessage({id:e.id,error:n instanceof Error?n.message:String(n)})}})}class mm{worker;next=1;waiting=new Map;send(t){let e=this.next++;return new Promise((n,r)=>{let i=this.open();this.waiting.set(e,{ok:n,no:r}),i.ref(),i.postMessage({...t,id:e})})}close(){this.worker?.terminate(),this.worker=void 0,this.drop(Error("renderer closed"))}open(){if(this.worker)return this.worker;let t=new BH(import.meta.filename);t.unref(),t.on("message",({id:n,value:r,error:i})=>{let s=this.waiting.get(n);if(this.waiting.delete(n),this.waiting.size===0)t.unref();if(i!==void 0)s?.no(Error(i));else s?.ok(r)});let e=(n)=>{if(this.worker===t)this.worker=void 0;this.drop(n instanceof Error?n:Error("renderer stopped"))};return t.on("error",e),t.on("exit",()=>e(void 0)),this.worker=t,t}drop(t){for(let e of this.waiting.values())e.no(t);this.waiting.clear()}}class ka{lines=new Map;run(t){let e=WH[t.job],n=this.lines.get(e);if(!n)n=new mm,this.lines.set(e,n);return n.send(t)}close(){for(let t of this.lines.values())t.close();this.lines.clear()}}class pm{lines;constructor(t){this.lines=Array.from({length:Math.max(1,t)},()=>new mm)}async map(t){let e=[],n=0;return await Promise.all(this.lines.map(async(r)=>{while(n<t.length){let i=n++;try{e[i]=await r.send(t[i])}catch(s){e[i]=s instanceof Error?s:Error(String(s))}}})),e}close(){for(let t of this.lines)t.close()}}if(!_H&&Yy)KH(Yy);import{existsSync as zH,mkdtempSync as DH,readFileSync as qH,rmSync as Jy,writeFileSync as YH}from"node:fs";import{tmpdir as JH}from"node:os";import{basename as Zy,join as Vy}from"node:path";var VH=6;class ya{dir;made=[];of(t,e){this.dir??=DH(Vy(JH(),"ttheme-tint-"));let n=Vy(this.dir,`${Zy(t,".png")}.${e.slice(1).toLowerCase()}.png`);if(!zH(n)){let r=new Uint8Array(qH(t));YH(n,_a(r,e)??ri(ni(At(r)),e)),this.made.push(n);while(this.made.length>VH)Jy(this.made.shift(),{force:!0})}return n}clear(){if(this.dir)Jy(this.dir,{recursive:!0,force:!0});this.dir=void 0,this.made.length=0}}function Zu(t,e,n,r,i){if(be(t)==="original")return{image:e,opacity:t.peak?ls(n,t.peak):t.opacity};let s=an(n,[...r]);return{image:s.color===t.tone?e:i.of(e,s.color),opacity:s.opacity}}function Qu(t,e){let n=Zy(e);return t.find((r)=>n.startsWith(`${r.stem}.`)||n.startsWith(`${r.stem}@`))}var rA=2147483625,tv=2147483626,wn=2147483627,iA=-1073741827,ev=-1073741826,sA=-1073741825,oA=4;function aA(t,e,n,r,i,s){let o=Math.trunc,a=n*i.w,c=r*i.h,u=o((Math.max(s.x,0)+i.w-1)/i.w),l=o(Math.min(s.x+s.w,a)/i.w),d=o((Math.max(s.y,0)+i.h-1)/i.h),f=o(Math.min(s.y+s.h,c)/i.h);if(l<=u||f<=d)return;return{col:u,row:d,cols:l-u,rows:f-d,x:o((u*i.w-s.x)*t/s.w),y:o((d*i.h-s.y)*e/s.h),w:o((l-u)*i.w*t/s.w),h:o((f-d)*i.h*e/s.h)}}function cA(t){try{let e=XH(t,"r"),n=Buffer.alloc(24);return tA(e,n,0,24,0),ZH(e),n.readUInt32BE(0)===2303741511?{width:n.readUInt32BE(16),height:n.readUInt32BE(20)}:void 0}catch{return}}class Xu{ready=()=>{};cell={w:0,h:0};held;tints=new ya;sent=new Map;placed=new Map;viewed="";renders;scratch;made=0;bands=new Map;home;name;views;banded;files;static of(t,e,n,r){if(Ft(t)||!Wc(t,r)||!(zc(t)||pi(t)))return;return new Xu(t,e,n)}constructor(t,e,n){this.home=e,this.name=n,this.views=pi(t),this.banded=Uc(t),this.files=Kc(t)}measured(t){if(this.cell.w===0&&t.w>0&&t.h>0)this.cell=t}load(){let t=D(this.home),e=we(t,this.name,eA()),n=[];try{n=vt(t).palettes[this.name]?.pictures??[]}catch{}let r=e?Qu(n,e.image):void 0;this.held=e&&r?{picture:r,image:e.image,opacity:e.opacity,cover:e.cover,at:_t.indexOf(e.position)+1||5}:void 0}draw(t,e,n,r,i){if(this.cell.w===0)return"";let s=t[0],o=this.look(t,e,n,r,i);if(this.views){let c=r*this.cell.w,u=i*this.cell.h,l=o?`${s}|${o.image}|${o.opacity}|${c}|${u}|${o.box.w}|${o.box.h}|${o.box.x}|${o.box.y}|${this.held?.at??5}`:`${s}||1|${c}|${u}|0|0|0|0|5`;if(l===this.viewed)return"";return this.viewed=l,gi(l)}let a=this.layer(rA,iA,"f=24",Buffer.from(nt(s)),r,i);if(o){let c=Math.max(0,Math.min(255,Math.round((1-o.opacity)*255)));a+=this.picture(o),a+=this.layer(tv,sA,"f=32",Buffer.from([...nt(s),c]),r,i)}else a+=this.drop(wn)+this.drop(tv);return a}resized(){this.sent.clear(),this.placed.clear(),this.viewed=""}clear(){let t=this.views&&this.viewed?gi(""):"";for(let e of this.sent.keys())t+=pa(e);return this.resized(),t}close(){let t=this.clear();if(this.tints.clear(),this.renders?.close(),this.scratch)Qy(this.scratch,{recursive:!0,force:!0});return t}look(t,e,n,r,i){let s=this.held;if(!s)return;let o={name:this.name,...ee([...t]),waived:[...n]},a=Zu(s.picture,s.image,o,e,this.tints),c=cA(a.image);if(!c)return;let u=ms(c.width,c.height,r*this.cell.w,i*this.cell.h,100,s.at,s.cover),l=aA(c.width,c.height,r,i,this.cell,u);if(!l)return;return{image:a.image,opacity:s.opacity===s.picture.opacity?a.opacity:s.opacity,...c,box:u,rect:l}}layer(t,e,n,r,i,s){let o=r.toString("base64"),a=`${o}|${i}|${s}`;if(this.placed.get(t)===a)return"";return this.sent.set(t,a),this.placed.set(t,a),`\x1B_Ga=t,${n},s=1,v=1,i=${t},q=2;${o}\x1B\\\x1B[H\x1B_Ga=p,i=${t},p=${t},c=${i},r=${s},C=1,z=${e},q=2\x1B\\`}picture(t){let{image:e,rect:n}=t;if(this.banded&&(2*n.y+n.h-t.height)**2>1){let s=this.band(t.image,n.y,n.h);if(!s.ready)return"";e=s.path,n={...n,y:0}}let r="";if(this.sent.get(wn)!==e){let s=ju({id:wn,path:e,row:0,col:0,cols:0,rows:0,z:ev},this.files);if(s===void 0)return"";r+=s,this.sent.set(wn,e),this.placed.delete(wn)}let i=`${n.col};${n.row};${n.cols};${n.rows};${n.x};${n.y};${n.w};${n.h}`;if(this.placed.get(wn)!==i)r+=`\x1B[${n.row+1};${n.col+1}H\x1B_Ga=p,i=${wn},p=${wn},x=${n.x},y=${n.y},w=${n.w},h=${n.h},c=${n.cols},r=${n.rows},C=1,z=${ev},q=2\x1B\\`,this.placed.set(wn,i);return r}drop(t){if(!this.sent.has(t))return"";return this.sent.delete(t),this.placed.delete(t),pa(t)}band(t,e,n){let r=`${t}|${e}|${n}`,i=this.bands.get(r);if(i)return i;this.scratch??=QH(Xy(nA(),"ttheme-edit-")),this.renders??=new ka;let s={path:Xy(this.scratch,`band-${++this.made}.png`),ready:!1};this.bands.set(r,s),this.renders.run({job:"band",from:t,to:s.path,y:e,height:n}).then(()=>{s.ready=!0,this.ready()}).catch(()=>{});for(let[o,a]of this.bands){if(this.bands.size<=oA)break;if(a.ready&&a.path!==this.sent.get(wn))this.bands.delete(o),Qy(a.path,{force:!0})}return s}}var nv=80,rv=24,va=50,gm=11;function Lt(t,e){return se(t,e)}function av(t){return{color:t,dim:(e)=>t?`${P}${e}${de}`:e,bold:(e)=>t?`${at}${e}${de}`:e,fg:(e)=>t?Ce(e):"",bg:(e)=>t?`\x1B[48;2;${nt(e).join(";")}m`:""}}function iv(t){return yt(t)>0.35?"#000000":"#ffffff"}function cv(t,e,n,r,i){let s=e.length-1,o=Math.max(0,Math.min(s,n)),a=i===void 0?-1:Math.max(0,Math.min(s,i));if(!t.color)return e.map((c,u)=>u===o?"●":u===a?"○":r?"━":"─").join("");return e.map((c,u)=>{let l=c??"#000000";if(u===o)return`${t.bg(l)}${t.fg(iv(l))}●\x1B[39;49m`;if(u===a)return c?`${t.bg(c)}${t.fg(iv(c))}○\x1B[39;49m`:`${t.fg("#aaaaaa")}○`;return c?`${t.fg(c)}█`:`${t.fg(r?"#777777":"#555555")}░`}).join("").concat("\x1B[39m")}function uA(t,e,n){return Array.from({length:n},(r,i)=>{let s=e.min+(e.max-e.min)*i/(n-1),o={...t,[e.key]:s};return ba(o.l,o.c,o.h)?Ae(o.l,o.c,o.h):void 0})}function bm(t,e,n,r){return Math.round((t-e)/(n-e)*(r-1))}function uv(t,e){return t.held!==void 0&&t.held-e.c>0.0005?t.held:void 0}function lv(t,e,n,r){let i=uv(e,n);return Ye.map((s,o)=>{let a=e.mode==="tune"&&o===e.channel,c=n[s.key],u=`${c.toFixed(s.digits)}${s.wraps?"°":""}`.padStart(6),l=cv(t,uA(n,s,r),bm(c,s.min,s.max,r),a,s.key==="c"&&i!==void 0?bm(i,s.min,s.max,r):void 0),d=s.key.toUpperCase(),f={kind:"channel",channel:o};return`${Lt(f,a?t.bold(`▸${d}`):t.dim(` ${d}`))} ${Lt({kind:"bar",channel:o},l)} ${Lt(f,a?t.bold(u):t.dim(u))}`})}function dv(t,e,n){let r=e.mode==="tune"&&e.channel===Yn,i=e.ratio(),{floor:s}=e.partner(),o=(h)=>Math.round(Math.log(Math.max(1,h))/Math.log(21)*(n-1)),a=o(i),c=s===void 0?-1:o(s),u=r?"━":"─",l=Array.from({length:n},(h,p)=>p===a?t.bold("●"):p===c?"┃":p<c?t.dim(u):u).join(""),d=`${i.toFixed(2)}:1`.padStart(6),f={kind:"channel",channel:Yn};return`${Lt(f,r?t.bold("▸◐"):t.dim(" ◐"))} ${Lt({kind:"bar",channel:Yn},l)} ${Lt(f,r?t.bold(d):t.dim(d))}`}function fv(t,e){if(e.mode!=="tune"||e.slot()<L.length)return[];let n=ee(e.list),r=Qs.map((s)=>Lt({kind:"scope",scope:s},s!==e.scope?t.dim(s):t.color?`${t.bg(n.selection)}${t.fg(n.foreground)} ${s} \x1B[39;49m`:`[${s}]`)),i=e.scoped().length;return[`${t.dim("Scope")} ${r.join(" ")}`,t.dim(i>1?`${i} slots move by the same step, each keeping its own color`:"This slot moves alone · a widens it")]}function lA(t,e){if(!t.misses().has(e))return;if(lm(t.list,t.signature,t.waive,"bright-follows").includes(e))return e-L.length<8?"= makes the bright follow its normal":"= on the normal makes this follow it";return"f moves the colors the gate misses"}function hv(t,e,n){let r=Yu(t.list,t.signature,t.waive,e),i=uv(t,n);if(i!==void 0)r.push({ok:void 0,text:`Chroma ○ ${i.toFixed(3)} is held while you tune — ${n.c.toFixed(3)} fits this lightness and hue`});return r}var sv={background:(t)=>t.background,foreground:(t)=>t.foreground,hue:(t)=>t.cursor,tint:(t)=>t.background,lightness:(t)=>t.ansi[4],chroma:(t)=>t.ansi[1],brights:(t)=>t.ansi[12]};function dA(t){return`oklch ${t.l.toFixed(3)} ${t.c.toFixed(3)} ${t.h.toFixed(0)}°`}function wm(t){return`${t.l.toFixed(2)} ${t.c.toFixed(3)} ${t.h.toFixed(0).padStart(3)}°`}function mv(t,e){return`${t.dim("oklch")} ${t.bold(`${e.l.toFixed(3)} ${e.c.toFixed(3)} ${e.h.toFixed(0)}°`)}`}function tl(t,e){return e===void 0?t.dim("·"):e?t.dim("✓"):t.bold("✗")}function pv(t,e,n,r=va){let i=jy(e.list,e.signature,e.waive).sort((u,l)=>Number(u.ok!==!1)-Number(l.ok!==!1)),s=i.filter((u)=>u.ok===!1).length,o=` ${t.dim("Gate")} ${s===0?t.dim("passes"):t.bold(`${s} ${s===1?"miss":"misses"}`)}`,a=r-4,c=i.flatMap((u)=>{let l=`${u.value} ${u.bound}`,d=` ${tl(t,u.ok)} ${jt(u.ok===!1?u.label:t.dim(u.label),t.dim(l),a-2)}`,f=[...new Set(u.slots)].map(($)=>Fi($).name),h=u.slots[0],p=($)=>h===void 0?$:Lt({kind:"slot",slot:h},$);return f.length>0?[p(d),p(` ${t.dim(ot(f.join(" · "),a-2))}`)]:[p(d)]});return[s===0?o:jt(o,`${t.bold("n")} ${t.dim("next miss")}`,r-2),...c.slice(0,Math.max(0,n-1))]}function gv(t,e,n,r=va,i=!0){let s=e.misses(),o=ee(e.list),a=i?e.slot():-1,c=(d)=>{let f=e.list[d],h=d===a,p=e.signature.includes(Li[d])?"◆":t.color?"■":" ",$=s.has(d)?"✗":e.theme&&e.offDefault(d)?"↺":" ",b=`${t.color?`${t.fg(f)}${p}${h?t.fg(o.foreground):"\x1B[39m"} `:`${p} `}${wm(e.lch[d])}${$}`;if(!h)return Lt({kind:"slot",slot:d},` ${b}`);return Lt({kind:"slot",slot:d},t.color?`${t.bg(o.selection)}${t.fg(o.foreground)} ${b}\x1B[39;49m`:`›${b}`)},u=(d)=>d?t.color?`${t.fg(o.cursor)}▌\x1B[39m `:"▌ ":" ",l=[` ${t.dim("Base")}`];for(let d=0;d<L.length;d++){let f=i&&d===e.row,h=L[d].padEnd(10);l.push(`${Lt({kind:"slot",slot:d},`${u(f)}${f?t.bold(h):h}`)}${c(d)}`)}l.push("",` ${t.dim(`${"ANSI".padEnd(10)} ${"Normal".padEnd(18)} Bright`)}`);for(let d=L.length;d<Kr;d++){let f=i&&d===e.row,h=Du[d-L.length].padEnd(10),p=Lt({kind:"slot",slot:d+(e.col===1?8:0)},`${u(f)}${f?t.bold(h):h}`);l.push(`${p}${c(d)}${c(d+8)}`)}return l.push(""),[...l,...pv(t,e,n-l.length,r)]}function fA(t,e,n){let r=ee(e.list),i=[` ${t.dim("Seeds")}`];Hi.forEach((s,o)=>{let a=o===e.field,c=e.seeds[s.key],u=Array.from({length:gm},(g,b)=>{let y=s.min+(s.max-s.min)*b/(gm-1);return sv[s.key](Ur({...e.seeds,[s.key]:y}))}),l=cv(t,u,bm(c,s.min,s.max,gm),a),d=`${c.toFixed(s.digits)}${s.wraps?"°":""}`.padStart(6),f=sv[s.key](r),h=a?t.color?`${t.fg(r.cursor)}▌\x1B[39m `:"▌ ":" ",p=s.label.padEnd(17),$={kind:"field",field:o};i.push(`${Lt($,`${h}${a?t.bold(p):p}`)}${Lt({kind:"seed",field:o},l)}${Lt($,` ${d} ${t.color?`${t.fg(f)}■\x1B[39m `:""}${t.dim(f)}`)}`)}),i.push("");for(let s of kt("Seven seeds grow all twenty colors, each accent on the hue its ANSI role reads as — whatever the seeds, they pass the gate. enter moves on to tune each slot, and the seeds stay behind.",va-4))i.push(` ${t.dim(s)}`);return i.push(""),[...i,...pv(t,e,n-i.length)]}function hA(t,e){let n=t-L.length;if(n>=0)return e===String(n)||e===`B${n}`||e===`K${n}`;return t===3&&e==="s"||t===2&&e==="c"}function mA(t,e,n,r){let i=r?"\x1B[4m":"";if(n==="d")return`${t.fg(e.foreground)}\x1B[2m${i}`;if(n==="b")return`${t.fg(e.foreground)}\x1B[1m${i}`;if(n==="s")return`${t.bg(e.selection)}${t.fg(e.foreground)}${i}`;if(n==="c")return`${t.bg(e.cursor)}${i}`;let s=/^([BK]?)(\d+)$/.exec(n);if(!s)return`${t.fg(e.foreground)}${i}`;let o=e.ansi[Number(s[2])];if(s[1]==="K")return`${t.fg(e.ansi[0])}${t.bg(o)}${i}`;return`${t.fg(o)}${s[1]==="B"?"\x1B[1m":""}${i}`}function bv(t,e,n,r,i,s){let o=te.indexOf(hi(i)),a=te.map((l,d)=>Lt({kind:"scene",scene:d},d!==o?t.dim(l.name):t.color?`${t.bg(e.selection)}${t.fg(e.foreground)} ${l.name} \x1B[39;49m`:`[${l.name}]`)).join(" "),c=[jt(a,t.dim("⇧←→"),n)],u=`${t.bg(e.background)}${t.fg(e.foreground)}`;for(let l of hi(i).lines){let d=jc(l,n-2);if(!d)continue;if(c.length>=r)break;let f=t.color?d.map(([h,p])=>`${mA(t,e,p,hA(s,p))}${h}\x1B[0m${u}`).join(""):d.map(([h])=>h).join("");c.push(`${u} ${ot(f,n-2)} ${t.color?"\x1B[0m":""}`)}return c}var pA=["Bk","Rd","Gr","Ye","Bl","Ma","Cy","Wh"];function ov(t,e,n,r,i,s,o){let a=(i-s)/(o-1),c=wv(e),u=ee(n),l=(d)=>Math.min(o-1,Math.max(0,Math.round((i-r(St(d)))/a)));return Array.from({length:o},(d,f)=>{let p=`${(f%2===0?(i-a*f).toFixed(i>=1?1:2).replace(/^0(?=\.\d\d)/,""):"").padStart(4)} ${t.dim(f%2===0?"┤":"│")}`;for(let $=0;$<8;$++){let g=[" "," "," "," "," "],b=u.ansi[$],y=u.ansi[$+8],S=l(b)===f,E=l(y)===f,I=(R)=>{if(R===1&&S)return t.color?`${t.fg(b)}●`:"●";if(R===3&&E)return t.color?`${t.fg(y)}○`:"○";return g[R]},N=[0,1,2,3,4].map(I).join("");p+=c.has($)?t.color?`${t.bg(u.selection)}${N}\x1B[39;49m`:N:`${N}${t.color?"\x1B[39m":""}`}return p})}function wv(t){let e=t.mode==="tune"?t.scoped():[t.slot()];return new Set(e.filter((n)=>n>=L.length).map((n)=>(n-L.length)%8))}function gA(t,e){let n=wv(e);return` ${pA.map((r,i)=>n.has(i)?t.bold(` ${r} `):t.dim(` ${r} `)).join("")}`}function bA(t,e){let n=ee(e),r=Array.from({length:40},(s,o)=>{let a=o*9+4.5,c=-1,u=999;for(let[l,d]of Object.entries(fe)){let f=Ne(a,d.center);if(f<=d.width&&f<u)u=f,c=Number(l)}return c<0?" ":t.color?`${t.fg(n.ansi[c])}─`:"─"}).join(""),i=(s,o)=>{let a=Array.from({length:40},()=>" ");for(let c of Object.keys(fe).map(Number)){let u=n.ansi[c+s],l=Math.min(39,Math.round(St(u).h/9));a[l]=t.color?`${t.fg(u)}${o}\x1B[39m`:o}return` ${a.join("")}`};return[`${t.bold("Hue")} ${t.dim("0° 90° 180° 270° 360°")}`,`${t.dim("bands")} ${r}${t.color?"\x1B[39m":""}`,i(0,"●"),i(8,"○")]}function wA(t,e,n){let r=Ci(n,e.signature,e.waive),i=(a)=>Fi(L.length+a).name,s=(a)=>St(n[L.length+a]).h.toFixed(0),o=[...Mn(r).filter(({gap:a})=>a>25).map(({normal:a,gap:c})=>`${i(a)} ${s(a)}° → bright ${s(a+8)}° · ${c.toFixed(0)}° apart · ≤ 25°`),...Qn(r).map(({slot:a,over:c})=>{let u=fe[Qe(a)];return`${i(a)} ${s(a)}° · ${c.toFixed(0)}° outside ${u.name} ${u.center}±${u.width}°`}),...On(r).map(([a,c])=>`${i(a)} and ${i(c).toLowerCase()} read as one color`)];return o.length>0?o.map((a)=>`${t.bold("✗")} ${a}`):[t.dim("✓ Every accent keeps its role and its bright")]}function $m(t,e,n,r,i){let s=e.shown(),o=Math.max(...s.slice(L.length).map((u)=>St(u).c)),a=Math.max(0.2,Math.ceil(o/0.05)*0.05),c=[jt(t.bold("Lightness"),t.dim("● normal ○ bright"),n),...ov(t,e,s,(u)=>u.l,1,0.3,8),gA(t,e)];if(i)c.push("",t.bold("Chroma"),...ov(t,e,s,(u)=>u.c,a,0,5),"",...bA(t,s));return[...c,...wA(t,e,s)].slice(0,r)}function $A(t,e,n){let r=ee(e.list),i=(s,o)=>Lt({kind:"view",view:o},e.view!==o?t.dim(` ${s} `):t.color?`${t.bg(r.selection)}${t.fg(r.foreground)}${t.bold(` ${s} `)}\x1B[39;49m`:`[${s}]`);return jt(`${i("Slot","slot")}${i("Relations","relations")}`,dn("g",`${t.bold("g")} ${t.dim("switch")}`),n)}function kA(t,e,n,r){let i=e.slot(),s=e.list[i],o=e.lch[i],a=e.start[i],{name:c,about:u}=Fi(i),l=e.signature.includes(Li[i]),d=Math.max(8,Math.min(64,n-12));if(e.view==="relations"&&e.mode!=="tune")return[$A(t,e,n),"",...$m(t,e,n,r-2,!0)];let f=i>=L.length?t.dim("Uses underlined below"):l?t.dim("◆ signature"):"",h=[jt(`${t.bold(c)} ${t.dim(u)}`,e.view==="relations"?"":f,n),""],p=t.color?`${t.fg(s)}${"█".repeat(8)}\x1B[39m `:"",$=e.typing!==void 0?`${t.bold(`${e.typing}▏`)}`:void 0,[g,b,y]=nt(s);if(h.push(`${p}${$??mv(t,o)}`),h.push(`${p}${t.dim(`${s} · rgb ${g} ${b} ${y}`)}`),e.view!=="relations"){let N=t.color?`${t.fg(a)}■\x1B[39m `:"";h.push(`${p}${a!==s?t.dim(`was ${N}${dA(e.lchOf(a)).slice(6)} · ${a}`):t.dim("as it opened")}`)}h.push(""),h.push(...lv(t,e,o,d),dv(t,e,d));let S=fv(t,e);if(S.length>0)h.push(...S);if(e.view==="relations")return h.push("",...$m(t,e,n,r-h.length-1,!1)),h;h.push("");for(let N of hv(e,i,o))kt(N.text,n-2).forEach((R,F)=>{h.push(`${F===0?tl(t,N.ok):" "} ${N.ok===!1?R:t.dim(R)}`)});let E=lA(e,i);if(E)h.push(t.dim(` ${E}`));let I=r-h.length-1;if(I>=3)h.push("",...bv(t,ee(e.shown()),n,I,e.scene,i));return h}function yA(t,e,n,r){return[jt(`${t.bold("Sample")} ${t.dim("what the seeds grow")}`,"",n),"",...bv(t,ee(e.list),n,r-2,e.scene,-1)]}var vA=[["Slots","↑↓ slot · ←→ normal or bright · home end · pgup the base colors · pgdn the ANSI ones · n N the next and last miss"],["Tune","enter or tab · ↑↓ lightness, chroma, hue or contrast · ←→ step · ⇧←→ ×5, hue ×10 · home end the ends · 0-9 jump · enter keeps · esc undoes"],["Contrast","◐ moves lightness until the ratio to the color it is read against changes · home the gate’s floor · 1-9 that ratio"],["Chroma","stops at the sRGB edge · what lightness or hue takes away comes back while you tune, where it fits again (○)"],["Scope","a while tuning: this, pair, normals, brights or accents — the slots in it move by the same step, each keeping its own color"],["Relations","g shows the lightness, chroma and hue of every ANSI color at once, and the relations the gate checks"],["Sample","⇧←→ another scene · the slot under the cursor is underlined where it is used"],["Type","# then #rrggbb, rgb(r g b) or oklch(l c h) — a paste works too"],["Slot","c copies · v pastes · r puts it back as it opened, R all of them · = the bright follows its normal · * marks it a signature color"],["Palette","f moves the colors the gate misses · o takes another palette’s colors"],["Gate","✗ marks every slot whose own checks miss, and each miss names its slots"],["History","u undo · ctrl+r redo"],["Pictures","p finds one on the boorus, tried on in these colors · drop a picture on the window, or paste one, its path or its link · ctrl+v takes the clipboard’s"],["Compare","space shows the colors you started from, on the terminal too"],["Save","s saves · esc cancels, asking first when something changed"]];function SA(t,e,n){let r=[` ${t.bold("Help")}`,""];for(let[i,s]of vA.filter(([o])=>o!=="Pictures"||e.options.find))kt(s,n-16).forEach((o,a)=>{r.push(` ${t.bold((a===0?i:"").padEnd(11))} ${o}`)});return r}function EA(t,e,n,r){let i=e.choices(),s=e.options.palettes?.length??0,o=e.filter?`${t.bold(e.filter)}▏`:t.dim("type to filter"),a=[jt(` ${t.bold("Take colors from")} ${o}`,t.dim(`${i.length}/${s}`),n),""],c=r-2,u=Math.max(0,Math.min(e.pick-Math.floor(c/2),i.length-c)),l=Math.min(40,Math.max(12,...i.map((d)=>Q(d.name))));if(i.slice(u,u+c).forEach((d,f)=>{let h=u+f===e.pick,p=d.colors,$=t.color?`${t.bg(p.background)} ${[...p.ansi].map((y)=>`${t.fg(y)}■`).join("")} ${t.fg(p.foreground)}Aa \x1B[0m`:"",g=h?"▌ ":" ",b=d.name.padEnd(l);a.push(Lt({kind:"choice",index:u+f},`${g}${h?t.bold(b):b} ${$}`))}),i.length===0)a.push(` ${t.dim(`No palettes match '${e.filter}'`)}`);return a}var MA=new Set(["enter","s","?","g","a"]);function OA(t,e,n){let r=t.fg(e.list[2]),i="EDIT",s="",o=[],a="";if(e.quitting)i="EDIT (QUIT)",s=e.added>0?`Discard changes and ${e.added} ${e.added===1?"picture":"pictures"}?`:"Discard changes?",o=[["y","discard"],["n","keep editing"]];else if(e.typing!==void 0)i="EDIT (TYPE)",s=t.dim("#rrggbb, rgb(r g b) or oklch(l c h)"),o=[["enter","set"],["ctrl+u","clear"]],a="esc back";else if(e.overlay==="keys")i="HELP",a="any key closes";else if(e.overlay==="open")i="EDIT (OPEN)",o=[["↑↓","palette"],["a-z","filter"],["enter","take its colors"]],a="esc close";else if(e.compare)i="EDIT (BEFORE)",s="The colors you started from",o=[["space","back to yours"]],a="esc back";else if(e.mode==="seeds")i="EDIT (SEEDS)",o=[["↑↓","seed"],["←→","step"],["⇧←→","×5"],["enter","tune the slots"],["o","open a palette"],["p","picture"],["?","keys"]],a="esc cancel";else if(e.mode==="tune")i="EDIT (TUNE)",o=[["↑↓","L C H ◐"],["←→","step"],...e.slot()>=L.length?[["a","scope"]]:[],["⇧←→","faster"],[e.channel===Yn?"1-9":"0-9",e.channel===Yn?"ratio":"jump"],["#","type"],["enter","keep"]],a="esc undo";else o=[["↑↓","slot"],["←→","normal or bright"],["enter","tune"],["g",e.view==="slot"?"relations":"slot"],...e.misses().size>0?[["n","next miss"]]:[],["#","type"],["f","fix"],["p","picture"],["u","undo"],["s","save"],["?","keys"]],a="esc cancel";if(!e.options.find)o=o.filter(([l])=>l!=="p");if(e.notice)s=t.color?`\x1B[33m${e.notice}\x1B[39m`:e.notice,o=[];let c=t.color?`\x1B[7;1m${r} ${i} \x1B[0m `:`[${i}] `,u=a?dn(a.split(" ")[0],`${t.bold(a.split(" ")[0])} ${t.dim(a.split(" ").slice(1).join(" "))}`):"";for(;;){let l=[s,...o.map(([h,p])=>dn(h,`${t.bold(h)} ${t.dim(p)}`))].filter(Boolean),d=`${c}${l.join(" ")}`,f=-1;if(o.forEach(([h],p)=>{if(p>0&&!MA.has(h))f=p}),Q(d)+Q(a)+3<=n||f<0)return a?jt(d,u,n):ot(d,n);o=o.filter((h,p)=>p!==f)}}var km=50,ym=22;function $v(t){let e=t.notice??"";if(t.typing!==void 0)return{mode:"type",keys:[["enter","set"],["ctrl+u","clear"],["esc","back"]],note:e};if(t.compare)return{mode:"compare",keys:[["space","back to yours"],["esc","back"]],note:e};if(t.mode==="tune")return{mode:"tune",keys:[["↑↓","L C H ◐"],["←→","step"],...t.slot()>=L.length?[["a","scope"]]:[],["⇧←→","×5"],["enter","keep"],["esc","undo"]],note:e};return{mode:"list",keys:[["↑↓←→","slot"],["enter","tune"],["g",t.view==="slot"?"relations":"slots"],...t.misses().size>0?[["n","next miss"]]:[],["r","reset slot"],["R","reset all"],["#","type a color"],["space","before"]],note:e}}function IA(t,e,n,r){let i=e.slot(),s=e.list[i],o=e.lch[i],a=e.start[i],c=e.original[i],{name:u,about:l}=Fi(i),d=e.signature.includes(Li[i]),f=t.color?`${t.fg(s)}${"█".repeat(4)}\x1B[39m `:"",h=e.typing!==void 0?t.bold(`${e.typing}▏`):void 0,p=[a!==s?`was ${t.color?`${t.fg(a)}■\x1B[39m `:""}${wm(e.lchOf(a))}`:"",c!==s?`default ${t.color?`${t.fg(c)}■\x1B[39m `:""}${wm(e.lchOf(c))}`:""].filter(Boolean),$=[jt(`${t.bold(u)} ${t.dim(l)}`,d?t.dim("◆ signature"):"",n),`${f}${h??mv(t,o)} ${t.dim(s)}`,...r>=7?[`${f}${t.dim(p.length>0?p.join(" "):"as the palette has it")}`]:[]],g=Math.max(8,Math.min(40,n-12));$.push(...lv(t,e,o,g),dv(t,e,g));for(let b of fv(t,e))if($.length<r)$.push(ot(b,n));for(let b of hv(e,i,o))for(let[y,S]of kt(b.text,n-2).entries()){if($.length>=r)return $;$.push(`${y===0?tl(t,b.ok):" "} ${b.ok===!1?S:t.dim(S)}`)}return $}function kv(t,e,n,r,i){let s=av(r);if(t.view==="relations"&&t.mode==="list"&&t.typing===void 0){let y=i?s.bold("Palette"):s.dim("Palette"),S=$m(s,t,e-2,n-1,!1).map((N)=>` ${N}`),I=[` ${jt(`${y} ${s.dim("Relations")}`,dn("g",`${s.bold("g")} ${s.dim("slots")}`),e-2)}`,...S];return{lines:Array.from({length:n},(N,R)=>ot(I[R]??"",e)),at:2}}let o=gv(s,t,0,e,i).slice(1,-2),a=(t.mode==="tune"||t.typing!==void 0)&&n-1-o.length<6,c=a?[]:[...o],u=t.row<L.length?t.row+2:t.row+4;if(!a&&n-1-c.length>=9)c.push("");let l=n-1-c.length;if(l>=5){let y=c.length+1;if(c.push(...IA(s,t,e-2,l).map((S)=>` ${S}`)),t.mode==="tune")u=y+3+(l>=7?1:0)+t.channel;else if(t.typing!==void 0)u=y+2}let d=i?s.bold("Palette"):s.dim("Palette"),f=i&&l<5?Yu(t.list,t.signature,t.waive,t.slot()).find((y)=>y.ok===!1):void 0,h=t.failing().length,p=h===0?"passes the gate":`${h} ${h===1?"miss":"misses"} in the gate`,$=t.list.filter((y,S)=>t.offDefault(S)).length,b=[` ${f?`${d} ${tl(s,!1)} ${f.text}`:jt(`${d}${$>0?s.dim(` ${$} off its default`):""}`,s.dim(p),e-2)}`,...c];return{lines:Array.from({length:n},(y,S)=>ot(b[S]??"",e)),at:u}}function xA(t,e,n,r){let i=av(r);if(e<nv||n<rv){let p=[i.bold("ttheme palette editor"),`Needs ${nv}×${rv} — now ${e}×${n}`,i.dim("esc cancels")];return Array.from({length:n},($,g)=>ot(p[g]??"",e))}let s=t.failing().length,o=s===0?"✓ Passes the gate":`✗ ${s} ${s===1?"miss":"misses"} in the gate`,a=t.pictures>0?i.dim(`▣ ${t.pictures} ${t.pictures===1?"picture":"pictures"} `):"",c=`${t.dirty()?`${i.color?"\x1B[33m●\x1B[39m":"●"} unsaved `:""}${a}${i.dim(o)}`,l=`${i.fg(t.list[2])}◆${i.color?"\x1B[39m":""} ${i.bold(t.options.title)} ${i.dim(`· ${t.options.name}`)}`,d=n-4,f;if(t.overlay==="keys")f=SA(i,t,e);else if(t.overlay==="open")f=EA(i,t,e,d);else{let p=e-va-2,$=t.mode==="seeds"?fA(i,t,d):gv(i,t,d),g=t.mode==="seeds"?yA(i,t,p,d):kA(i,t,p,d);f=Array.from({length:d},(b,y)=>`${ot($[y]??"",va)}${i.dim("│")} ${ot(g[y]??"",p)}`)}let h=[jt(l,c,e),""];for(let p=0;p<d;p++)h.push(ot(f[p]??"",e));return h.push("",OA(i,t,e)),h}function vm(t,e,n){if(n.action==="wheel"){if(!n.sideways)t.scroll(n.wheel);return}if((n.action==="press"||n.action==="drag")&&n.button!=="left")return;if(n.action==="press"&&t.overlay==="keys"){t.press("esc");return}let r=e?.target;if(!e||!r)return;let i=e.width>1?e.x/(e.width-1):0;if(n.action==="release"){if(!e.inside)return;if(r.kind==="key")t.press(r.key);else if(n.count===2&&r.kind==="slot"&&t.mode==="list")t.press("enter");else if(n.count===2&&r.kind==="choice"&&t.overlay==="open")t.press("enter");return}if(r.kind==="bar")t.slide(r.channel,i);else if(r.kind==="seed")t.sow(r.field,i);else if(n.action!=="press")return;else if(r.kind==="slot")t.select(r.slot);else if(r.kind==="channel")t.grip(r.channel);else if(r.kind==="scope")t.scopeTo(r.scope);else if(r.kind==="choice"){if(t.overlay==="open")t.pick=r.index}else if(t.typing===void 0&&!t.overlay&&!t.quitting){if(r.kind==="field"&&t.mode==="seeds")t.field=r.field;else if(r.kind==="view"&&t.mode!=="seeds")t.view=r.view;else if(r.kind==="scene")t.scene=r.scene}}var NA=[Ru,Kn,Ni,_r],RA=33;async function yv(t,e){let n=new $a(t),r=e.backdrop,i=(s)=>n.typing===void 0&&Ku(s);return Br({modes:[...NA,...Ks()],burst:i},async(s)=>{let o=[],a="",c,u=!1,l=!1,d=()=>{if(c=void 0,e.look){let g=n.shown();if(g.join(" ")!==a)a=g.join(" "),e.look(g);return}let $="";n.shown().forEach((g,b)=>{if(o[b]!==g&&e.only?.includes(b))$+=Go(b,g),o[b]=g}),s.write($)},f=new Mi({write:($)=>s.write($),view:()=>u?void 0:{lines:xA(n,s.cols,s.rows,e.color),after:()=>r?.draw(n.shown(),n.signature,n.waive,s.cols,s.rows)??""}}),h=($=!1)=>{if($)f.soon();else f.request();if(e.only||e.look)c??=setTimeout(d,RA)},p=async($)=>{let g=t.find;if(!g)return;if(u=!0,clearTimeout(c),c=void 0,r)s.write(r.clear());try{n.found(await g(n.edited(),$))}catch(b){n.notice=b instanceof Error?b.message:String(b)}if(l)return;u=!1,r?.load(),o.length=0,a="",f.reset(bi),h()};if(s.write(bi),s.onResize(()=>{r?.resized(),f.reset(bi),f.request()}),r){r.load(),r.ready=()=>f.request();let $=new sa;s.ask(xu,(g)=>$.see(g),1000).then((g)=>{if(g)r.measured(g);f.request()})}h();try{let{edited:$}=await s.loop((g)=>{if(u)return;if(g.kind==="paste")n.paste(g.text);else if(g.kind==="key")n.press(g.key);else if(g.kind==="mouse")vm(n,f.point(g),g);if(n.result)return{edited:n.result==="saved"?n.edited():void 0};let b=n.wants;if(b)n.wants=void 0,p(b.start);return},()=>{if(!u)h(!0)});return $}finally{if(l=!0,clearTimeout(c),f.stop(),r)s.write(r.close())}})}import{spawn as KA}from"node:child_process";import{createHash as Cv}from"node:crypto";import{existsSync as Ea,mkdirSync as zA,mkdtempSync as DA,readFileSync as qA,rmSync as el}from"node:fs";import{homedir as YA,tmpdir as JA}from"node:os";import{basename as VA,dirname as ZA,join as $n}from"node:path";import{pathToFileURL as Ev}from"node:url";import{existsSync as TA,readFileSync as PA,statSync as HA}from"node:fs";import{join as vv}from"node:path";function AA(t,e){try{return JSON.parse(PA(vv(Ge(t),e),"utf8"))}catch{return{}}}function FA(t,e,n){H(vv(Ge(t),e),`${JSON.stringify(n)}
718
+ `)}class Sm{caches=new Map;unsaved=new Set;owners=new Map;crediting=new Map;inflight=new Map;home;catalog;entry;signal;credited;constructor(t){this.home=t.home,this.catalog=t.catalog,this.entry=t.entry,this.signal=t.signal,this.credited=t.credited}matesOf(t,e){return this.owners.get(t.key)?.get(e)??[]}async transparent(t,e){let n=this.keep(t,"probes.json"),r=n[e.id];if(r!==void 0)return r;try{let i=await $o(t,e,this.signal),s=oi(t,e),o=(i===void 0?await wb(s.site,s.url,this.signal):i)?.alpha===!0;return n[e.id]=o,this.unsaved.add(`${t.key}/probes.json`),o}catch{return!1}}save(){for(let t of this.unsaved){let[e,n]=t.split("/"),r=Y.find((i)=>i.key===e);if(r)FA(r,n,this.keep(r,n))}this.unsaved.clear()}owned(t,e,n){this.keep(t,"owners.json")[e]=n,this.unsaved.add(`${t.key}/owners.json`)}credit(t,e){let{site:n,post:r}=t;if(!Ja(n,r))return Promise.resolve();let i=pe(n,r.id),s=this.crediting.get(i);if(!s)s=this.credits(t,e).finally(()=>this.crediting.delete(i)),this.crediting.set(i,s);return s}async mateOwners(t){let e=this.owners.get(t.key);if(e)return e;let n=rw(this.home),r=this.keep(t,"owners.json"),i=this.catalog.palettes.flatMap((c)=>{let u=n.get(c.name);return c.group===this.entry.group&&c.name!==this.entry.name&&u?.site===t.key?[{name:c.name,id:u.id}]:[]}),s=await Promise.all(i.map(async(c)=>{let u=r[c.id];if(u!==void 0)return{...c,owner:u};try{return{...c,owner:(await is(t,c.id,this.signal))?.owner??""}}catch{return}})),o=new Map;for(let c of s)if(c)r[c.id]=c.owner,o.set(c.name,c.owner);this.unsaved.add(`${t.key}/owners.json`);let a=fb(o);return this.owners.set(t.key,a),a}async cached(t,e,n,r){if(TA(e))return HA(e).size;let i=this.inflight.get(e);if(i)return i;let s=(async()=>{let o=await Qa(t,n,this.signal,r);return H(e,o),o.length})();this.inflight.set(e,s);try{return await s}finally{this.inflight.delete(e)}}keep(t,e){let n=`${t.key}/${e}`,r=this.caches.get(n);if(!r)r=AA(t,e),this.caches.set(n,r);return r}async credits({site:t,post:e},n){let r=this.keep(t,"credits.json"),i=r[e.id];if(!i){try{i=await Ya(t,e.id,n)}catch{return}if(!i?.owner)return;r[e.id]=i,this.unsaved.add(`${t.key}/credits.json`)}wo(e,i),this.credited()}}import{rmSync as CA}from"node:fs";import{join as LA}from"node:path";var to=2147483645,Sa=2147483646,Sv=-1073741827,jA=-1073741828,GA=16,_A=0.4,BA=3221225472,WA=256;function UA(t){let e=/^(\d+) (\d+)$/.exec(t??"");return e&&(Number(e[1])>0||Number(e[2])>0)?{x:Number(e[1]),y:Number(e[2])}:void 0}var Em=UA(process.env.TTHEME_BG_MARGIN);class Mm{screen;gliding;sent=new Map;placed=new Map;covered="";viewed="";bands=Uc(process.env);files=Kc(process.env);moves=R0(process.env);layers=zc(process.env);wipes=T0(process.env);views=pi(process.env);bandFiles=new Map;nextBand=BA;view;grid;background;renders;scratch;signal;write;constructor(t){this.view=t.view,this.grid=t.grid,this.background=t.background,this.renders=t.renders,this.scratch=t.scratch,this.signal=t.signal,this.write=t.write,this.screen=new Mi({write:(e)=>this.write(e),view:()=>this.frame(),beat:()=>{this.view.beat++}})}draw(){if(!this.signal.aborted)this.screen.request()}soon(){if(!this.signal.aborted)this.screen.soon()}flush(){if(!this.signal.aborted)this.screen.now()}point(t){return this.screen.point(t)}drop(){this.screen.drop()}frame(){if(this.signal.aborted)return;let{cols:t,rows:e,cell:n}=this.grid(),r=Zh(this.view,t,e);return this.view.loaderFrom=r.loader?this.view.loaderFrom??this.view.beat:void 0,{lines:r.lines,zones:r.zones,after:(i)=>this.images(r.images,i,n),...this.view.mode==="grid"&&this.view.editing!==void 0?{cursor:this.caret()}:{},ticking:r.tick}}images(t,e,n){let r="",i=new Set,s;for(let o of t){if(this.views&&o.id>=qh){s=o;continue}let a=this.bands?this.banded(o):o;if(!a)continue;if(this.wipes&&[...e].some((u)=>u>=a.row&&u<a.row+a.rows))this.placed.delete(a.id);if(i.add(a.id),this.sent.get(a.id)!==a.path){let u=ju(a,this.files);if(u===void 0)continue;r+=u,this.sent.set(a.id,a.path),this.placed.delete(a.id)}let c=`${a.row};${a.col};${a.cols};${a.rows};${a.crop};${a.z}`;if(this.placed.get(a.id)!==c){if(!this.moves&&this.placed.has(a.id))r+=Jh(a.id);r+=uy(a,n),this.placed.set(a.id,c)}}for(let o of this.sent.keys())if(!i.has(o))r+=pa(o),this.sent.delete(o),this.placed.delete(o);return r+(this.views?this.backdrop(s):this.cover())}glide(){if(this.bands)this.prebake();if(this.gliding)return;let{cols:t,rows:e}=this.grid(),n=zn(t,e).height,r=()=>{let i=this.view,s=i.top*gt.height,o=s-i.scroll;if(o===0||i.mode!=="grid"){i.scroll=s;let a=this.gliding!==void 0;if(this.gliding=void 0,a)this.draw();return}if(Math.abs(o)>2*n)i.scroll=s-Math.sign(o)*n,o=s-i.scroll;i.scroll+=Math.sign(o)*Math.max(1,Math.round(Math.abs(o)*_A)),this.draw(),this.gliding=setTimeout(r,GA)};r()}snap(){clearTimeout(this.gliding),this.gliding=void 0,this.view.scroll=this.view.top*gt.height}resized(){this.screen.reset()}stop(){this.screen.stop(),clearTimeout(this.gliding)}prebake(){let t=this.view,{cols:e,rows:n}=this.grid();for(let r of Zh({...t,scroll:t.top*gt.height},e,n).images)if(r.crop!==void 0)this.band(r.path,r.crop,r.rows)}cover(){let{cols:t,rows:e}=this.grid(),n=`${t};${e}`;if(!this.layers||this.covered===n)return"";let r="";if(!this.covered){let i=Buffer.from(nt(this.background)).toString("base64");if(r+=`\x1B_Ga=t,f=24,s=1,v=1,i=${to},q=2;${i}\x1B\\`,Em)r+=`\x1B_Ga=t,f=32,s=1,v=1,i=${Sa},q=2;AAAAAA==\x1B\\\x1B[H\x1B_Ga=p,i=${Sa},p=${Sa},c=1,r=1,C=1,z=${jA},q=2\x1B\\`}else if(!this.moves)r+=Jh(to);if(this.covered=n,Em){let{x:i,y:s}=Em;return`${r}\x1B_Ga=p,i=${to},p=${to},P=${Sa},Q=${Sa},H=${-i},V=${-s},c=${t+2*i},r=${e+2*s},C=1,z=${Sv},q=2\x1B\\`}return`${r}\x1B[H\x1B_Ga=p,i=${to},p=${to},c=${t},r=${e},C=1,z=${Sv},q=2\x1B\\`}backdrop(t){let{cols:e,rows:n,cell:r}=this.grid(),i=e*r.w,s=n*r.h,o=t?`${this.background}|${t.path}|1|${i}|${s}|${i}|${s}|0|0|1`:`${this.background}||1|${i}|${s}|0|0|0|0|5`;if(o===this.viewed)return"";return this.viewed=o,gi(o)}caret(){return`\x1B[1;${Math.min(this.grid().cols,Q(`⌕ ${this.view.editing??""}`)+1)}H`}banded(t){if(t.crop===void 0)return t;let e=this.band(t.path,t.crop,t.rows,!this.gliding);return e?.ready?{...t,id:e.id,path:e.path,crop:void 0}:void 0}band(t,e,n,r=!0){let i=`${t}|${e}|${n}`,s=this.bandFiles.get(i);if(s||!r)return s;let{cell:o}=this.grid(),a=this.nextBand++,c={id:a,path:LA(this.scratch,`band-${a}.png`),ready:!1};return this.bandFiles.set(i,c),this.renders.run({job:"band",from:t,to:c.path,y:e*o.h,height:n*o.h}).then(()=>{c.ready=!0,this.draw()}).catch(()=>{}),this.trimBands(),c}trimBands(){for(let[t,e]of this.bandFiles){if(this.bandFiles.size<=WA)return;if(e.ready&&!this.sent.has(e.id))this.bandFiles.delete(t),CA(e.path,{force:!0})}}}var ji=[{name:"TTHEME_FIND_RATING",label:"Rating",about:"The ratings to list, each site read in its own words — space ticks one, and one stays ticked",choices:es,multi:{read:si}},{name:"TTHEME_FIND_BLOCK",label:"Block",about:"Posts tagged with nudity or underwear are left out — space unticks one",choices:ii,multi:{read:rs,none:"none"}},{name:"TTHEME_FIND_POSTS",label:"Posts",about:"Every post of the character, or only the transparent cutouts",choices:["all","cutouts"]},{name:"TTHEME_FIND_SOLO",label:"Solo",about:"When on, only the posts known to show the character alone — checked as posts arrive, so the counts below leave it out",choices:["on","off"]},{name:"TTHEME_FIND_ORDER",label:"Order",about:"How posts are ranked: fit, by how well each makes a backdrop; newest; or score",choices:["fit","newest","score"]},{name:"TTHEME_FIND_SETS",label:"Sets",about:"One picture posted over and over, or held by another site too: fold it into one tile, or show each",choices:["fold","show"]},...Fs()?[{name:"TTHEME_FIND_REMOVE_BG",label:"Remove bg",about:"Cut the character out of an opaque picture you try on, with macOS Vision",choices:["on","off"]}]:[],{name:"TTHEME_FIND_MIN_SCORE",label:"Min score",about:"Posts scored at least this — danbooru, konachan and yande.re; zerochan keeps no score. ←→ steps, or type any number",choices:Xg,entry:"number",advanced:!0},{name:"TTHEME_FIND_MIN_SIZE",label:"Min size",about:"The shorter side of a picture, in px — every site filters it. ←→ steps, or type any number",choices:tb,entry:"number",advanced:!0},{name:"TTHEME_FIND_SITES",label:"Sites",about:"The sites the all tab mixes — each keeps its own tab. Space ticks one, and one stays ticked",choices:Y.map((t)=>t.name),multi:{read:po},advanced:!0},{name:"TTHEME_FIND_HIDE",label:"Hide",about:"Comics, monochrome, sketches or chibi, told by tag in every site's spelling — checked as posts arrive",choices:od,multi:{read:Wa,none:"none"},advanced:!0},{name:"TTHEME_FIND_HIDE_TAGS",label:"Hide tags",about:"Posts with any of these tags are left out, spaced like cosplay multiple_girls — checked as posts arrive",choices:[],entry:"text",advanced:!0},{name:"TTHEME_FIND_PNG",label:"PNG only",about:"PNG originals only — danbooru counts it, the others are told by the file; zerochan only where danbooru holds it",choices:["off","on"],advanced:!0}];function Mv(t,e){if(t.multi)return t.multi.read(e).join(" ")||t.multi.none;if(t.entry==="number")return/^\d+$/.test(e??"")&&Number(e)>0?String(Number(e)):"off";if(t.entry==="text")return go(e).join(" ");return t.choices.find((n)=>n===e)??t.choices[0]}var QA=["fit","newest","score"];function Om(t){return QA.find((e)=>e===t)??"fit"}var XA={left:-1,right:1,"shift-left":-10,"shift-right":10};function Ov(t){if(process.env.SSH_CONNECTION||!/^(?:https?|file):/i.test(t))return;try{let e=KA(process.platform==="darwin"?"open":"xdg-open",[t],{stdio:"ignore",detached:!0});e.on("error",()=>{}),e.unref()}catch{}}function tF(t,e,n){if(e<0){if(t!=="fill")return Math.max(rl,t+e);if(!n)return t;return Math.max(rl,Math.max(100,n)+e+1)}return t==="fill"||t+e>n?"fill":t+e}function Lv(t,e){return t.size===e.size&&t.at===e.at&&t.opacity===e.opacity}function eF(t,e){if(Lv(t,e))return;return{...t.size!=="fill"?{size:t.size}:{},...t.at!==e.at?{position:_t[t.at-1]}:{},...t.opacity!==e.opacity?{opacity:t.opacity}:{}}}function Iv(t,e){let n=D(t);return re(t,e).flatMap((r,i)=>{let[,s,o]=/^([a-z.]+)_(\d+)$/.exec(r.key)??[],a=[...Y,Dn].find((c)=>c.key===s);if(!a||!o)return[];return[{key:r.key,id:Number(o),ansi:a.ansi,...a===Dn?{}:{page:a.pageUrl(Number(o))},up:i===0,from:$n(n,r.original??r.fill)}]})}function nF(t){return t.length>=2&&!/^\d+$/.test(t)&&!t.includes("://")&&!/^[\w.]+:\d+$/.test(t)}var xv=12,rF=4,iF=150,sF=300,Nv=12,oF=2,aF=150,cF="\x1B[?5522$p\x1B]72;t=q\x1B\\\x1B[c",uF=4000,lF=8000,Rv=/\.(png|jpe?g|gif|webp|heic|tiff?|bmp)$/i,dF=process.platform==="win32"?"alt+v":"ctrl+v",Tv=process.platform==="darwin"?"ctrl+shift+cmd+4 copies a screenshot":"copy a picture first",fF=1280,hF=16,mF=_t.indexOf("top-right")+1,rl=20,Pv=2,Hv=3,pF=/[\p{Script=Hangul}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,gF=8,bF=9;function nl(t,e){return{key:t,groups:[],sources:[],queue:[],rounds:0,roundOf:new Map,last:new Map,kin:new Map,kindred:new Map,shapes:[],seen:new Set,same:new Map,checked:0,total:0,focus:0,top:0,searching:e,stage:"fetch",arrived:new Set}}function Ma(t){if(!(t instanceof Error))return String(t);if(t instanceof AggregateError&&t.errors[0])return Ma(t.errors[0]);if(t.cause)return Ma(t.cause);let e=t.code;if(typeof e==="string")return e;let n=(t.message||t.name).split(".")[0]??"";return n.length>56?`${n.slice(0,55)}…`:n}function Im(t,e){return`${t}: ${Ma(e)}`}function Av(t){return t.width*t.height}function Fv(t,e){return`${t}-${Cv("sha1").update(e).digest("hex").slice(0,8)}`}class xm{view;tone;session=new AbortController;cell={w:0,h:0};cols=process.stdout.columns||80;rows=process.stdout.rows||24;gen=0;pumping=0;boards=new Map;board;posts=new Map;thumbPath=new Map;looking=new Map;looked=new Map;matched=new Map;aheading=!1;pages=new Map;tab=0;values=new Map(ji.map((t)=>[t.name,Mv(t,process.env[t.name])]));direction=1;prefetching=0;related=new Map;pool=[];relating;thumbQueue=[];heldFiles=new Map;heldAsked=new Set;thumbing=0;clarity=new Map;tunedFiles=[];presenting=!1;again=!1;renders=new ka;showing;thumbless=new Set;current;fetch;settle;suggestTimer;suggesting;countTimer;counting;terminal;grabber=new rm((t)=>this.write(t),(t)=>void this.got(t));noticeTimer;peekTimer;peeked;attaching;done;scratch=DA($n(JA(),"ttheme-find-"));home;catalog;entry;tagged;blurring;start;paint;kept;constructor(t,e,n,r,i){this.start=i,this.home=t,this.catalog=e,this.entry=n,this.tagged=new Set(e.palettes.flatMap((o)=>o.booru?[o.booru]:[])),this.tone=an(n,n.signatureSlots),this.blurring=Pr(t);let s={size:"fill",at:mF,opacity:this.tone.opacity};this.view={palette:n.name,tag:r,site:this.tabName,siteAnsi:this.tabAnsi,nextSite:this.nextTabName,preset:this.setting("TTHEME_FIND_POSTS")==="all"?"all":"cutouts",order:Om(this.setting("TTHEME_FIND_ORDER")),solo:this.setting("TTHEME_FIND_SOLO")==="on",rating:si(this.setting("TTHEME_FIND_RATING")),block:rs(this.setting("TTHEME_FIND_BLOCK")),sets:this.setting("TTHEME_FIND_SETS")==="show"?"show":"fold",narrow:this.narrowed(),enabled:po(this.setting("TTHEME_FIND_SITES")),hide:Wa(this.setting("TTHEME_FIND_HIDE")),hideTags:go(this.setting("TTHEME_FIND_HIDE_TAGS")),advanced:!1,settings:ji.map((o)=>({label:o.label,choices:[...o.choices],value:this.setting(o.name),default:Mv(o,Uo(o.name)),multi:o.multi&&{none:o.multi.none},about:o.about,entry:o.entry,advanced:o.advanced,cursor:0})),colors:{cursor:n.cursor,selection:n.selection,background:n.background,foreground:n.foreground,ansi:n.ansi},tiles:[],installed:[],held:Iv(t,n.name),checked:0,total:0,searching:r!=="",stage:"fetch",sites:[],focus:0,top:0,scroll:0,beat:0,mode:"grid",help:!1,scene:Math.max(0,te.findIndex((o)=>o.name.toLowerCase()===process.env.TTHEME_SCENE)),details:!1,tune:{...s},untuned:s,coloring:Yc(t),editing:r===""?"":void 0,chips:[]},this.paint=new Mm({view:this.view,grid:()=>({cols:this.cols,rows:this.rows,cell:this.cell}),background:n.background,renders:this.renders,scratch:this.scratch,signal:this.signal,write:(o)=>this.write(o)}),this.kept=new Sm({home:t,catalog:e,entry:n,signal:this.signal,credited:()=>{this.show(),this.inform(),this.paint.draw()}}),this.pool=this.selected(this.view),this.syncChips(),this.board=nl(this.boardKey,r!==""),this.boards.set(this.board.key,this.board)}get signal(){return this.session.signal}get site(){return this.tab===0?void 0:Y[this.tab-1]}get sites(){return this.site?[this.site]:Y.filter((t)=>this.view.enabled.includes(t.name))}get tabName(){return this.site?.name??"all"}get tabAnsi(){return this.site?.ansi??rF}get nextTabName(){let t=(this.tab+1)%(Y.length+1);return t===0?"all":Y[t-1].name}frame(){return{w:this.cols*(this.cell.w||10),h:this.rows*(this.cell.h||20)}}setting(t){return this.values.get(t)}narrowed(){return cd(this.setting("TTHEME_FIND_MIN_SCORE"),this.setting("TTHEME_FIND_MIN_SIZE"),this.setting("TTHEME_FIND_PNG"))}get boardKey(){return`${this.site?.key??"all"}|${this.view.preset}|${this.view.order}`}origPath(t,e,n){return $n(Ge(t),"orig",`${e}.${n}`)}previewPath(t){let{url:e}=Ka(t.site,t.post);return $n(Ge(t.site),"thumb",`${Fv(t.post.id,e)}.${ar(e)}`)}tileOf(t,e){let{site:n,post:r}=t,i=pe(n,r.id),s=sn(r)??r;return{id:r.id,key:i,site:n.name,siteAnsi:n.ansi,width:s.width,height:s.height,reduced:s!==r,page:n===Dn?"":n.pageUrl(r.id),artist:n===Dn?vy(r.source):r.named.artist[0]??"",score:r.score,variants:e,mates:this.kept.matesOf(n,r.owner),thumb:this.thumbPath.get(i),missing:this.thumbless.has(i)}}show(){let t=this.view,e=this.board;if(t.tiles=e.groups.flatMap((n)=>n.open?n.posts.map((r)=>this.tileOf(r,0)):[this.tileOf(n.posts[0],n.posts.length)]),t.checked=e.checked,t.total=e.total,t.searching=e.searching,this.stageOf(e),t.note=e.note,t.focus=Math.max(0,Math.min(e.focus,t.tiles.length-1)),t.top=e.top,this.showing!==e)this.showing=e,this.paint.snap()}stageOf(t){let e=this.view;e.stage=t.stage,e.ranking=t.ranking,e.sites=this.sites.map((n)=>({name:n.name,arrived:t.arrived.has(n.name)}))}syncSite(){let t=this.view;t.site=this.tabName,t.siteAnsi=this.tabAnsi,t.nextSite=this.nextTabName}run(){let t=(e)=>this.view.editing===void 0&&Ku(e);return Br({modes:[_r,...Ks()],assume:[Kn,Ni],burst:t},async(e)=>{this.terminal=e,e.onResize(this.onResize),e.listen((i)=>{for(let s of i)this.inbound(s);this.paint.soon()}),e.write(bi);let n=new Promise((i)=>{this.done=i}),r=setInterval(this.onClock,250);setTimeout(fc,0);try{let i=new sa,s=await e.ask(xu,(o)=>i.see(o),1000);if(s){if(this.cell=s,this.holdThumbs(),this.view.tag)this.search(),this.relate(this.view.tag)}else this.view.searching=!1,this.view.error="This terminal does not report its cell size — find needs kitty graphics";if(!process.env.TMUX)await e.ask(cF,(o)=>o.kind==="attributes"?!0:void 0,500,!1);if(this.grabber.start(),e.hold(Wk),this.start&&"paste"in this.start)this.pasted(this.start.paste);else if(this.start)this.fromClipboard();else this.peek();return this.paint.draw(),await e.until(n)}finally{this.session.abort(),this.grabber.stop(),this.attaching?.abort(),clearTimeout(this.noticeTimer),clearTimeout(this.peekTimer),this.fetch?.abort(),clearTimeout(this.settle),this.quietSuggest(),this.quietCount(),clearInterval(r),this.paint.stop(),e.write(`\x1B_Ga=d,d=A,q=2\x1B\\${bi}`),this.kept.save(),this.renders.close(),el(this.scratch,{recursive:!0,force:!0}),hb()}})}write(t){this.terminal?.write(t)}get saved(){return this.view.saved?.text}get installs(){return this.view.installed.length}finish(t){this.done?.(t===2&&this.saved?0:t)}inbound(t){if(t.kind==="key")this.key(t.key);else if(t.kind==="mouse")this.pointer(t);else if(t.kind==="paste")this.pasted(t.text);else if(t.kind==="mode"){if(t.mode===5522)this.grabber.clipboard=t.value!==0&&t.value!==4}else if(t.kind==="osc")if(t.code==="72"&&t.meta.t==="q")this.grabber.drops=!0;else this.grabber.take(t)}pasted(t){let e=this.view;if(e.editing!==void 0&&t.trim()!==""&&!this.picture(t)){e.editing+=t.replace(/[\r\n]+/g," "),this.suggest(),this.paint.draw();return}if(e.installing!==void 0||e.panel!==void 0||e.help)return;if(t.trim()===""){this.fromClipboard();return}this.attach(t)}picture(t){let e=t.trim();if(/^https?:\/\/\S+$/i.test(e))return!Ua(e,this.site??Y[0]);return Vs(e).length>0}async got(t){if(t.kind==="error"){this.notice(t.message);return}if(t.kind==="text"){if(t.text.trim()===""){this.notice(`No picture on the clipboard — ${Tv}`);return}this.pasted(t.text);return}await this.bring(()=>Wu(t.bytes,t.source))}notice(t,e=uF){let n=this.view;n.error=t,clearTimeout(this.noticeTimer),this.noticeTimer=setTimeout(()=>{if(n.error===t)n.error=void 0,this.paint.draw()},e),this.paint.draw()}async peek(){let t=this.view,e;try{e=await Iy()}catch{return}if(!e||e.stamp===this.peeked)return;if(this.peeked=e.stamp,!e.picture||t.installing!==void 0)return;t.hint=`Picture on the clipboard · ${dF} uses it`,clearTimeout(this.peekTimer),this.peekTimer=setTimeout(()=>{t.hint=void 0,this.paint.draw()},lF),this.paint.draw()}async fromClipboard(){let t=this.view;if(nm()){if(this.grabber.clipboard){this.grabber.ask();return}this.notice("Over SSH the clipboard is not here — drop the file");return}let e;try{e=await Oy($n(this.scratch,`clipboard-${Date.now()}.png`))}catch(r){this.notice(`Could not read the clipboard: ${Ma(r)}`);return}if(clearTimeout(this.peekTimer),t.hint=void 0,"image"in e){await this.bring(async(r)=>({...await em(e.image,r),source:"clipboard"}));return}let n=e.text.trim();if(!n){this.notice(`No picture on the clipboard — ${Tv}`);return}if(this.picture(n)){await this.attach(n);return}if(t.editing===void 0)t.editing="";this.pasted(n)}async attach(t){let e=t.trim();if(/^https?:\/\//i.test(e)){let i=Ua(e,this.site??Y[0]);if(i){await this.jump(i.site,i.id);return}}let[n,...r]=Vs(e).sort((i,s)=>Number(!Rv.test(i))-Number(!Rv.test(s)));if(!n){this.notice("Nothing to use in that — drop a picture, or paste one or its link");return}await this.bring((i)=>em(n,i),r.length)}async bring(t,e=0){let n=this.view;this.attaching?.abort();let r=new AbortController;this.attaching=r,n.error=void 0,n.saved=void 0,n.note="Reading the picture…",this.paint.draw();let i;try{i=await t(AbortSignal.any([r.signal,this.signal]))}catch(f){if(!r.signal.aborted)n.note=void 0,this.notice(Ma(f),8000);return}if(r.signal.aborted)return;n.note=e>0?`The first picture of ${e+1} — drop one at a time to try the others`:void 0,this.quietSuggest(),n.editing=void 0,n.suggest=void 0,n.pick=void 0;let s=Ey(i.bytes);Sy(s,i.source);let o=this.origPath(Dn,s,i.ext);H(o,i.bytes);let a=Ev(o).href,c={id:s,file:a,width:i.width,height:i.height,ext:i.ext,preview:a,owner:"",score:0,rating:"s",md5:Cv("md5").update(i.bytes).digest("hex"),source:i.source,tags:[],named:{artist:[],character:[],copyright:[]},solo:void 0,family:0,smaller:[]},u={site:Dn,post:c},l=this.previewPath(u);H(l,i.bytes),++this.gen,this.current=void 0,n.shown=void 0;let d=nl(`local|post:${s}`,!1);this.board=d,this.boards.set(d.key,d),this.single(d,u)}single(t,e){t.searching=!1,this.posts.set(pe(e.site,e.post.id),e),t.groups=[{posts:[e],open:!1}],t.checked=1,t.total=1,this.thumbQueue.push(e),this.thumbs(),this.view.mode="try",this.show(),this.select(),this.paint.draw()}onClock=()=>{let t=this.sites.reduce((r,i)=>Nn(i)>Nn(r)?i:r),e=Math.ceil((Nn(t)-Date.now())/1000),n=e>0?e:void 0;if(n!==this.view.waiting)this.view.waiting=n,this.view.slow=t.name,this.paint.draw()};onResize=()=>{if(this.cols=process.stdout.columns||this.cols,this.rows=process.stdout.rows||this.rows,this.paint.resized(),this.holdThumbs(),this.scroll(),this.paint.snap(),this.view.mode==="try"&&this.current)this.reveal();this.pump(),this.paint.draw()};key(t){let e=this.view;if(t==="ctrl-c"){this.finish(2);return}if(e.installing!==void 0)return;if(t==="focus-in"){this.peek();return}if(t==="focus-out")return;if((t==="ctrl-v"||t==="alt-v")&&e.panel===void 0){this.fromClipboard();return}if(e.editing!==void 0){this.editKey(t);return}if(e.panel!==void 0){this.panelKey(t);return}if(e.help){if(t==="?"||t==="esc")e.help=!1,this.paint.draw();return}if(this.cols<Ti.cols||this.rows<Ti.rows){if(t==="esc")this.finish(2);return}if(t==="?"){e.help=!0,this.paint.draw();return}if(e.mode==="try"){this.tryKey(t);return}this.gridKey(t)}pointer(t){let e=this.view,n=this.paint.point(t),r=n?.target;if(e.installing!==void 0)return;if(t.action==="wheel"){if(!t.sideways)this.wheel(t.wheel);return}if((t.action==="press"||t.action==="drag")&&t.button!=="left")return;if(r?.kind==="track"&&n&&t.action!=="release")this.slide(r.field,n);else if(t.action==="press")this.pressed(r);else if(t.action==="release"&&n?.inside)this.released(r,t)}pressed(t){let e=this.view;if(e.help)this.paint.drop(),this.key("esc");else if(e.editing!==void 0||t===void 0)return;else if(e.panel!==void 0){if(t.kind==="setting"&&t.index<e.settings.length&&e.typing===void 0)e.panel=t.index,this.paint.draw()}else if(e.mode==="try")this.tryPoint(t);else if(t.kind==="tile")this.focus(t.index);else if(t.kind==="query")this.gridKey("/");else if(t.kind==="site")this.tab=t.tab,this.syncSite(),this.turn()}released(t,e){let n=this.view;if(t?.kind==="key")this.key(t.key);else if(t?.kind==="link"){if(!e.shift&&!e.alt&&!e.ctrl)Ov(t.url)}else if(n.editing!==void 0){if(t?.kind==="suggest")n.pick=t.index,this.editKey("enter")}else if(n.panel!==void 0)this.panelPoint(t);else if(n.mode==="try"){if(t?.kind==="place"&&n.tuning)this.tuneKey(String(t.at))}else if(t?.kind==="tile"&&e.count===2)this.gridKey("enter");else if(t?.kind==="chip")this.toggle(t.index)}wheel(t){let e=this.view;if(e.help)return;if(e.editing!==void 0){if(e.suggest?.length)this.editKey(t<0?"up":"down")}else if(e.panel!==void 0){if(e.typing===void 0)this.panelKey(t<0?"up":"down")}else if(e.tuning)this.tuneKey(t<0?"up":"down");else if(e.mode==="try")this.tryKey(t<0?"left":"right");else this.focus(e.focus+t*zn(this.cols,this.rows).perRow)}panelPoint(t){let e=this.view;if(t?.kind!=="setting"&&t?.kind!=="choice")return;let n=e.settings[t.index];if(e.typing!==void 0){let r=e.settings[e.panel??0];if(r&&(t.index!==e.panel||t.kind==="setting"))this.typeKey(r,"enter");else return}if(t.kind==="setting"&&t.index===e.settings.length){e.panel=t.index,this.panelKey("enter");return}if(e.panel=t.index,t.kind==="choice"&&n){if(n.entry==="text"||t.choice===void 0){this.panelKey("enter");return}if(n.multi){n.cursor=Math.max(0,n.choices.indexOf(t.choice)),this.panelKey(" ");return}if(n.value!==t.choice)n.value=t.choice,this.recount()}this.paint.draw()}tryPoint(t){let e=this.view;if(t.kind==="scene")e.scene=t.scene,e.details=!1,this.paint.draw();else if(e.tuning&&t.kind==="field")e.tuning.field=t.field,this.paint.draw()}slide(t,e){let n=this.view,r=n.tuning;if(!r)return;let i=Math.min(1,Math.max(0,e.width>1?e.x/(e.width-1):0));if(r.field=t,t===0){let s=Math.max(100,r.fill),o=rl+Math.round(i*(s-rl+1));n.tune.size=i===1||r.fill>0&&o>=r.fill?"fill":Math.min(s,o)}else n.tune.opacity=Math.round(i*100)/100;this.retune()}gridKey(t){let e=this.view,{perRow:n,rowsVis:r}=zn(this.cols,this.rows),s={left:-1,right:1,up:-n,down:n,k:-n,j:n,pgup:-n*r,pgdn:n*r,home:-e.focus,end:e.tiles.length}[t];if(s!==void 0){this.focus(e.focus+s);return}if(/^[1-9]$/.test(t)){this.toggle(Number(t)-1);return}if(t==="enter"&&e.tiles[e.focus]){e.mode="try",e.error=void 0,this.select();return}if(t==="v"){this.fromClipboard();return}if(t==="c"){e.preset=e.preset==="cutouts"?"all":"cutouts",this.turn();return}if(t==="tab"||t==="shift-tab"){let o=Y.length+1;this.tab=(this.tab+(t==="tab"?1:o-1))%o,this.syncSite(),this.turn();return}if(t==="/"){e.editing="",this.paint.draw();return}if(t===" "){this.unfold();return}if(t==="o"){this.openPage();return}if(t==="s"){e.panel=0,e.advanced=!1,this.recount(),this.paint.draw();return}if(t==="esc")this.finish(2)}panelKey(t){let e=this.view,n=e.panel??0,r=e.settings[n];if(e.typing!==void 0&&r){this.typeKey(r,t);return}let i=ma(e);if(t==="up"||t==="down"){let s=i.indexOf(n)+(t==="up"?-1:1);e.panel=i[(s+i.length)%i.length]??n,this.paint.draw();return}if(t==="a"||t==="enter"&&n===e.settings.length){e.advanced=!e.advanced,e.panel=ma(e)[0]??0,this.paint.draw();return}if(r?.entry&&(t==="enter"||r.entry==="number"&&/^[0-9]$/.test(t))){e.typing=t==="enter"?r.entry==="text"?r.value:"":t,this.paint.draw();return}if((t==="left"||t==="right")&&r&&r.entry!=="text"){let s=t==="left"?-1:1;if(r.multi)r.cursor=(r.cursor+s+r.choices.length)%r.choices.length;else r.value=my(r.choices,r.value,s),this.recount();this.paint.draw();return}if(t===" "&&r?.multi){let s=r.value.split(" "),o=r.choices.filter((c,u)=>u===r.cursor?!s.includes(c):s.includes(c)),a=r.multi.none;if(o.length>0||a!==void 0)r.value=o.length>0?o.join(" "):a,this.recount(),this.paint.draw();return}if(t==="esc"){e.settings.forEach((s,o)=>{s.value=this.setting(ji[o]?.name??"")}),e.panel=void 0,e.advanced=!1,this.quietCount(),this.paint.draw();return}if(t==="enter"||t==="s"||t==="alt-c")e.panel=void 0,e.advanced=!1,this.quietCount(),this.adopt()}typeKey(t,e){let n=this.view,r=n.typing??"";if(e==="esc"){n.typing=void 0,this.paint.draw();return}if(e==="enter"||e==="up"||e==="down"){if(t.value=t.entry==="number"?Number(r)>0?String(Number(r)):"off":go(r).join(" "),n.typing=void 0,this.recount(),e==="enter"){this.paint.draw();return}this.panelKey(e);return}let i=xi(r,e,(s)=>t.entry==="number"?/^[0-9]$/.test(s)&&r.length<Vh:/^[\x20-\x7e]$/.test(s));if(i!==void 0)n.typing=i,this.paint.draw()}quietCount(){clearTimeout(this.countTimer),this.counting?.abort(),this.counting=void 0}recount(){if(this.quietCount(),this.view.counts=void 0,!this.view.tag)return;let t=new AbortController;this.counting=t,this.countTimer=setTimeout(()=>void this.countPending(t),sF)}pending(){let t=(e)=>this.view.settings[ji.findIndex((n)=>n.name===e)]?.value??this.setting(e);return{tag:this.view.tag,chosen:this.view.chosen,preset:t("TTHEME_FIND_POSTS")==="all"?"all":"cutouts",order:Om(t("TTHEME_FIND_ORDER")),rating:si(t("TTHEME_FIND_RATING")),narrow:cd(t("TTHEME_FIND_MIN_SCORE"),t("TTHEME_FIND_MIN_SIZE"),t("TTHEME_FIND_PNG")),enabled:po(t("TTHEME_FIND_SITES"))}}async countPending(t){let e=this.pending(),n=this.site?[this.site]:Y.filter((s)=>e.enabled.includes(s.name)),r=AbortSignal.any([this.signal,t.signal]),i=await Promise.all(n.map(async(s)=>{let o=this.query(s,e);if(!o)return{site:s.name,count:0};if(s.counts&&!s.counts(o.tags))return{site:s.name};try{let a=await fd(s,o.tags,r);return{site:s.name,...Number.isFinite(a)?{count:a}:{}}}catch{return{site:s.name}}}));if(this.counting===t&&this.view.panel!==void 0)this.view.counts=i,this.paint.draw()}adopt(){let t=this.view,e=ji.map((r)=>this.setting(r.name));t.settings.forEach((r,i)=>{let s=ji[i];if(s)this.values.set(s.name,r.value)});let n=ji.filter((r,i)=>this.setting(r.name)!==e[i]);if(n.length===0){this.paint.draw();return}this.save(n),t.rating=si(this.setting("TTHEME_FIND_RATING")),t.block=rs(this.setting("TTHEME_FIND_BLOCK")),t.sets=this.setting("TTHEME_FIND_SETS")==="show"?"show":"fold",t.preset=this.setting("TTHEME_FIND_POSTS")==="all"?"all":"cutouts",t.order=Om(this.setting("TTHEME_FIND_ORDER")),t.solo=this.setting("TTHEME_FIND_SOLO")==="on",t.narrow=this.narrowed(),t.enabled=po(this.setting("TTHEME_FIND_SITES")),t.hide=Wa(this.setting("TTHEME_FIND_HIDE")),t.hideTags=go(this.setting("TTHEME_FIND_HIDE_TAGS")),this.boards.clear(),this.current=void 0,t.shown=void 0,t.mode="grid",this.search()}save(t){this.store(t.map((e)=>[e.name,this.setting(e.name)]))}store(t){let e=$n(this.home,"ttheme","config.zsh");try{let n=Ea(e)?qA(e,"utf8"):"";return H(e,t.reduce((r,[i,s])=>Jc(r,i,s),n)),!0}catch(n){return this.view.error=n instanceof Error?n.message:String(n),!1}}editKey(t){let e=this.view,n=e.editing??"",r=e.suggest??[];if((t==="up"||t==="down")&&r.length>0){let o=((e.pick??r.length)+(t==="down"?1:r.length))%(r.length+1);e.pick=o===r.length?void 0:o,this.paint.draw();return}if(t==="esc"||t==="enter")this.quietSuggest();if(t==="esc"){if(e.editing=void 0,e.tag===""){this.finish(2);return}this.paint.draw();return}if(t==="enter"){let s=e.pick===void 0?void 0:r[e.pick],o=s?s.whole?s.value:n.replace(/\S*$/,s.value):n;if(e.editing=void 0,e.suggest=void 0,e.pick=void 0,o.trim()){this.commit(o.trim());return}if(e.tag===""){this.finish(2);return}this.paint.draw();return}let i=xi(n,t);if(i!==void 0)e.editing=i,this.suggest(),this.paint.draw()}quietSuggest(){clearTimeout(this.suggestTimer),this.suggesting?.abort(),this.suggesting=void 0}suggest(){this.quietSuggest();let t=this.view;t.pick=void 0;let e=t.editing??"",n=/\S*$/.exec(e)?.[0]??"",r=nF(n),i=yw(e,Hv,this.tagged).map((c)=>({value:c.tag,count:0,alias:c.name,whole:!0}));if(!r&&i.length===0){t.suggest=void 0;return}let s=r?qw(this.catalog.palettes,this.entry,n).map((c)=>({value:c.booru,count:0,palette:c.name})):[],o=[...new Map([...s.slice(0,Hv),...i].map((c)=>[c.value,c])).values()];if(t.suggest=o.length>0?o:void 0,i.length>0&&pF.test(e))t.pick=o.findIndex((c)=>("whole"in c));if(!r)return;let a=new AbortController;this.suggesting=a,this.suggestTimer=setTimeout(async()=>{try{let c=await pb(n,AbortSignal.any([this.signal,a.signal]));if(this.suggesting===a&&t.editing!==void 0){let u=new Map(c.map((d)=>[d.value,d.count])),l=new Set(o.map((d)=>d.value));t.suggest=[...o.map((d)=>({...d,count:u.get(d.value)??0})),...c.filter((d)=>!l.has(d.value))].slice(0,gF),t.pick=t.pick!==void 0&&t.pick<o.length?t.pick:void 0,this.paint.draw()}}catch{}},iF)}async commit(t){let e=Ua(t,this.site??Y[0]);if(e){await this.jump(e.site,e.id);return}if(this.picture(t)){await this.attach(t);return}this.view.tag=t,this.view.chosen=void 0,this.relate(t),this.boards.clear(),await this.search()}async jump(t,e){let n=++this.gen;this.tab=Y.indexOf(t)+1,this.syncSite(),this.current=void 0,this.view.shown=void 0,this.view.error=void 0;let r=nl(`${t.key}|post:${e}`,!0);this.board=r,this.boards.set(r.key,r),this.show(),this.paint.draw();try{let i=await is(t,e,this.signal);if(n!==this.gen)return;if(!i){r.searching=!1,r.error=`${t.name} has no post ${e}`,this.view.error=r.error,this.show(),this.paint.draw();return}this.single(r,{site:t,post:i})}catch(i){this.fail(n,i,t)}}async turn(){this.fetch?.abort(),this.current=void 0,this.view.shown=void 0;let t=this.boards.get(this.boardKey);if(!t){await this.search();return}this.gen++,this.board=t,this.view.error=t.error,this.show(),this.paint.draw(),await this.pump()}unfold(){let t=this.view,e=0;for(let n of this.board.groups){let r=n.open?n.posts.length:1;if(t.focus<e+r){if(n.posts.length<2)return;n.open=!n.open,this.board.focus=e;for(let i of n.posts)if(!this.thumbPath.has(pe(i.site,i.post.id)))this.thumbQueue.push(i);this.thumbs(),this.show(),this.scroll(),this.paint.glide(),this.paint.draw();return}e+=r}}openPage(){let t=this.view.tiles[this.view.focus],e=t&&this.posts.get(t.key);if(e)Ov(e.site.pageUrl(e.post.id))}tryKey(t){let e=this.view;if(e.tuning){this.tuneKey(t);return}if(t==="left"||t==="right"){this.direction=t==="left"?-1:1,this.focus(e.focus+this.direction);return}if(t==="shift-left"||t==="shift-right"){e.scene+=t==="shift-left"?-1:1,e.details=!1,this.paint.draw();return}if(t==="i"){e.details=!e.details,this.inform(),this.paint.draw();return}if(t==="t"){e.tuning={field:0,held:{...e.tune},fill:this.current?.fill??0,coloring:e.coloring},this.paint.draw();return}if(t==="c"){this.recolor();return}if(t==="o"){this.openPage();return}if(t==="x"){this.swap();return}if(t==="v"){this.fromClipboard();return}if(t==="enter"){this.install();return}if(t==="esc")this.fetch?.abort(),clearTimeout(this.settle),e.fetching=void 0,e.mode="grid",e.error=void 0,this.paint.draw()}tuneKey(t){let e=this.view,n=e.tuning,r=e.tune;if(t==="up"||t==="down"){n.field=(n.field+(t==="up"?2:1))%3,this.paint.draw();return}let i=XA[t];if(i!==void 0){if(n.field===0)r.size=tF(r.size,i,n.fill);else if(n.field===1)r.at=(r.at-1+Math.sign(i)+9)%9+1;else r.opacity=Math.max(0,Math.min(100,Math.round(r.opacity*100)+i))/100;this.retune();return}if(/^[1-9]$/.test(t)){n.field=1,r.at=Number(t),this.retune();return}if(t==="="){let s=e.untuned;if(n.field===0)r.size=s.size;else if(n.field===1)r.at=s.at;else r.opacity=s.opacity;this.retune();return}if(t==="+"){e.tune={...e.untuned},this.retune();return}if(t==="enter"){e.tuning=void 0,this.paint.draw();return}if(t==="c"){this.recolor();return}if(t==="esc")e.tune={...n.held,...n.coloring===e.coloring?{}:{opacity:e.untuned.opacity}},e.tuning=void 0,this.retune()}recolor(){let t=this.view;if(!this.current||t.shown?.id!==this.current.key)return;t.coloring=t.coloring==="tone"?"original":"tone",t.tune.opacity=t.untuned.opacity,this.paint.draw(),this.reveal()}retune(){if(this.paint.draw(),this.current&&this.view.shown?.id===this.current.key)this.reveal()}inform(){let t=this.view,e=t.tiles[t.focus],n=e&&this.posts.get(e.key);t.info=n?this.infoOf(n):void 0}infoOf(t){let{site:e,post:n}=t,r=n.named,i=db(e,n),s=new Set([...r.artist,...r.character,...r.copyright]),o=bo(n.source),a=/^https?:\/\//i.test(o)?o:e===Dn&&o.startsWith("/")?Ev(o).href:void 0;return{page:e===Dn?"":e.pageUrl(n.id),source:o,...a?{link:a}:{},artists:r.artist,characters:r.character,series:r.copyright,tags:n.tags.filter((c)=>!s.has(c)),...i?{rating:i}:{},...n.posted?{posted:n.posted}:{},ext:(sn(n)??n).ext,uploader:n.owner}}focus(t){let e=this.view;if(e.tiles.length===0)return;let n=Math.max(0,Math.min(e.tiles.length-1,t));if(n===e.focus)return;if(e.focus=n,this.board.focus=n,this.scroll(),this.paint.glide(),this.pump(),e.mode==="try")this.select();this.paint.draw()}scroll(){let t=this.view,{perRow:e,rowsVis:n}=zn(this.cols,this.rows),r=Math.floor(t.focus/e);if(r<t.top)t.top=r;if(r>t.top+n-1)t.top=r-n+1;this.board.top=t.top}selected(t){if(t.chosen)return t.chosen;if(!t.tag)return[];return this.namesOf(t.tag,"danbooru")}namesOf(t,e){let n=t===this.entry.booru?this.entry:this.catalog.palettes.find((r)=>r.booru===t);return n?Yw(n,e):[t]}syncChips(){let t=this.selected(this.view);this.view.chips=this.pool.slice(0,bF).map((e)=>({name:e,on:t.includes(e)}))}toggle(t){let e=this.view,n=e.chips[t];if(!n)return;let r=this.selected(e),i=n.on?r.filter((s)=>s!==n.name):[...r,n.name];if(i.length===0)return;e.chosen=i,e.tag=i.join(" or "),this.syncChips(),this.boards.clear(),this.search()}async relate(t){this.relating?.abort();let e=this.selected({tag:t,chosen:void 0});if(this.pool=e,this.syncChips(),this.paint.draw(),!t||/\s/.test(t))return;let n=this.related.get(t);if(!n){let r=new AbortController;this.relating=r;try{n=(await gb(t,AbortSignal.any([this.signal,r.signal]))).map((i)=>i.value)}catch{return}if(this.relating!==r)return;this.related.set(t,n)}this.pool=[...new Set([...e,...n])],this.syncChips(),this.paint.draw()}query(t,e=this.view){let n=e.chosen?bb(t,e.chosen):this.namesOf(e.tag,t.key);if(n.length===0)return;let r=e.chosen?.slice(n.length)??[],i=n.length>1,s=e.preset==="cutouts"?t.cutouts:"",o=i&&s.includes("~"),a=[i?n.map((l)=>`~${l}`).join(" "):n[0],t.rate(e.rating),...t.narrow(e.narrow),o?"":s,e.order==="score"?t.best:""].filter(Boolean),c=[],u=[];for(let l of a)if(dd([...c,l].join(" "))<=t.tagBudget)c.push(l);else u.push(l);return{tags:c.join(" "),notes:[...u.length>0?[`${t.name} takes ${t.tagBudget} tags — ${u.join(" ")} left out`]:[],...r.length>0?[`${t.name} takes ${n.length} tag${n.length===1?"":"s"} — ${r.join(" ")} left out`]:[],...o?[`${t.name} ORs the names, so cutouts are told by the file`]:[],...e.narrow.score>0&&!t.scored?[`${t.name} keeps no score`]:[],...e.narrow.png&&t.guesses?[`${t.name} names a file type only where danbooru holds the file`]:[]]}}async search(){let t=++this.gen,e=nl(this.boardKey,!0);this.board=e,this.boards.set(e.key,e),this.view.error=void 0;let n=this.sites.flatMap((s)=>{let o=this.query(s);return o?[{site:s,...o}]:[]}),r=this.sites.filter((s)=>!n.some((o)=>o.site===s)),i=[...n.flatMap(({notes:s})=>s),...r.length>0?[`${this.entry.name} has no tag on ${r.map((s)=>s.name).join(", ")}`]:[]];if(e.note=i.length>0?i.join(" · "):void 0,n.length===0)e.searching=!1;this.show(),this.paint.draw(),this.tally(t,e,n);try{let s=await Promise.all(n.map(async(o)=>({plan:o,owners:await this.kept.mateOwners(o.site)})));if(t!==this.gen)return;e.sources=s.flatMap(({plan:{site:o,tags:a},owners:c})=>{let u=dd(a)+1<=o.tagBudget?o.uploadedBy:void 0;return[...u?[...c.keys()].map((l)=>({site:o,tags:`${a} ${u(l)}`,page:0,done:!1})):[],{site:o,tags:a,page:0,done:!1}]}),this.show(),this.paint.draw(),await this.pump()}catch(s){this.fail(t,s)}}async tally(t,e,n){let r=await Promise.allSettled(n.map(({site:i,tags:s})=>fd(i,s,this.signal)));if(t===this.gen)e.total=r.reduce((i,s)=>i+(s.status==="fulfilled"&&Number.isFinite(s.value)?s.value:0),0),this.show(),this.paint.draw()}fail(t,e,n=this.site){if(t!==this.gen||this.signal.aborted)return;this.board.error=Im(n?.name??this.tabName,e),this.board.searching=!1,this.view.error=this.board.error,this.show(),this.paint.draw()}drop(t,e,n){for(let r of t.sources)if(r.site===e)r.done=!0;t.note=[t.note,Im(e.name,n)].filter(Boolean).join(" · ")}wants(){let{perRow:t,rowsVis:e}=zn(this.cols,this.rows);return this.view.tiles.length<(this.board.top+e+Pv)*t}need(){let{perRow:t,rowsVis:e}=zn(this.cols,this.rows);return(e+Pv)*t}live(t){return this.boards.get(t.key)===t}page(t,e,n){let r=`${t.key}|${e}|${n}`,i=this.pages.get(r);if(!i)i=mb(t,e,n,this.signal).then((s)=>this.borrow(t,s)),this.pages.set(r,i),i.catch(()=>this.pages.delete(r));return i}async borrow(t,e){let n=t===Zt?[]:e.filter((r)=>r.md5!=="");if(n.length>0)try{Va(n,await Za(n.map((r)=>r.md5),this.signal))}catch{}return e}staged(t){if(t===this.board)this.stageOf(t),this.paint.draw()}async round(t){t.stage="fetch",this.staged(t);let e=Y.flatMap((a)=>{let c=t.sources.find((u)=>u.site===a&&!u.done);return c?[c]:[]}),n=await Promise.all(e.map(async(a)=>{try{let c=await this.page(a.site,a.tags,a.page);return t.arrived.add(a.site.name),this.staged(t),{source:a,posts:c}}catch(c){if(t.sources.every((u)=>u.site===a.site)||this.signal.aborted)throw c;return this.drop(t,a.site,c),{source:a,posts:void 0}}}));if(!this.live(t))return;let r=[];for(let{source:a,posts:c}of n){if(!c)continue;a.page++,a.done=c.length<sr;let u=t.last.get(a);for(let l of c){let d=u&&Ky(u.post,l)?u.set:`set:${a.site.key}:${l.id}`;u={post:l,set:d};let f=pe(a.site,l.id);if(t.seen.has(f))continue;t.seen.add(f);let h={site:a.site,post:l};if(this.eligible(h))t.kin.set(h,[d,...Uy(a.site,l)]),r.push(h);else t.checked++}if(u)t.last.set(a,u)}let i=this.dedupe(t,r),s=++t.rounds,o;if(this.view.order!=="fit")o=e.length>1?By(i):i;else{let a=Ju(i,this.frame(),this.matched),c=a.slice(0,this.need()),u={done:0,total:c.length};if(t.ranking=u,this.staged(t),await this.looks(c,()=>{u.done++,this.staged(t)}),t.ranking=void 0,!this.live(t))return;o=[...Ju(c,this.frame(),this.matched),...a.slice(c.length)]}t.stage="check",this.staged(t);for(let a of o)t.roundOf.set(a,s);t.queue.push(...o),this.ahead(t)}ahead(t){if(this.aheading||this.view.order!=="fit"||!this.live(t))return;let e=t.queue.slice(0,this.need()).filter((n)=>!this.looking.has(pe(n.site,n.post.id)));if(e.length===0)return;this.aheading=!0,this.looks(e).then(()=>{this.aheading=!1;for(let n of new Set(e.map((r)=>t.roundOf.get(r)??0)))this.resort(t,n);this.ahead(t)})}resort(t,e){let n=t.queue.flatMap((i,s)=>t.roundOf.get(i)===e?[s]:[]),r=Ju(n.map((i)=>t.queue[i]),this.frame(),this.matched);n.forEach((i,s)=>{t.queue[i]=r[s]})}dedupe(t,e){let n=[];for(let r of e){let i=fm(r.post),s=i.map((a)=>t.same.get(a)).find(Boolean);if(!s){for(let a of i)t.same.set(a,r);n.push(r);continue}if(t.checked++,Av(r.post)<=Av(s.post))continue;for(let a of[...i,...fm(s.post)])t.same.set(a,r);let o=n.indexOf(s);if(o>=0){n[o]=r;continue}this.replace(t,s,r)}return n}replace(t,e,n){t.roundOf.set(n,t.roundOf.get(e)??0);let r=t.queue.indexOf(e);if(r>=0){t.queue[r]=n;return}for(let i of t.groups){let s=i.posts.indexOf(e);if(s>=0){i.posts[s]=n,this.posts.set(pe(n.site,n.post.id),n),this.thumbQueue.push(n),this.thumbs();return}}}async looks(t,e){let n=0;await Promise.all(Array.from({length:Nv},async()=>{while(n<t.length)await this.look(t[n++]),e?.()}))}look(t){let e=pe(t.site,t.post.id),n=this.looking.get(e);if(!n)n=(async()=>{let r=this.previewPath(t),i=Ka(t.site,t.post);await this.kept.cached(i.site,r,i.url);let s=await this.renders.run({job:"match",from:r,colors:this.entry.signature});return this.looked.set(e,s),this.matched.set(t.post,s.match),s})().catch(()=>{return}),this.looking.set(e,n);return n}async pump(){let t=this.gen,e=this.board;if(this.pumping===t||e.sources.length===0)return;this.pumping=t;let n=[],r;try{e.searching=!0;while(t===this.gen){while(n.length<xv&&e.queue.length>0&&this.wants()){let o=e.queue.shift();n.push({pick:o,passed:this.vet(o)})}if(this.ahead(e),!r&&e.queue.length<xv&&e.sources.some((o)=>!o.done)&&this.wants()){let o=this.round(e).then(()=>{if(r===o)r=void 0});o.catch(()=>{}),r=o}let i=n.shift();if(!i){if(!r)break;await r,this.show(),this.paint.draw();continue}let s=await i.passed;if(t!==this.gen)return;if(e.checked++,s)this.admit(i.pick);this.show(),this.paint.draw()}if(t===this.gen)e.searching=!1,this.show(),this.paint.draw()}catch(i){this.fail(t,i)}finally{if(this.kept.save(),this.pumping===t)this.pumping=0}}eligible({site:t,post:e}){let n=sn(e);if(!Da(t,e,this.view.rating)||za(e,this.view.block).length>0||!n)return!1;if(this.view.solo&&e.solo===!1)return!1;let{score:r,size:i,png:s}=this.view.narrow;if(Math.min(e.width,e.height)<i||t.scored&&e.score<r||s&&e.ext!=="png"||lb(e,this.view.hide).length>0||this.view.hideTags.some((o)=>e.tags.includes(o)))return!1;return this.view.preset==="all"?["png","jpg","jpeg",""].includes(n.ext):["png",""].includes(e.ext)}async vet(t){let[e]=await Promise.all([this.passes(t),this.look(t)]);return e}async passes({site:t,post:e}){return this.view.preset==="all"||t.vouched||this.kept.transparent(t,e)}admit(t){let{site:e,post:n}=t,r=this.board,i=pe(e,n.id);this.posts.set(i,t);let s=r.kin.get(t)??[],o=this.looked.get(i),a=o&&{hash:o.hash,width:n.width,height:n.height},c=this.view.sets==="fold"?this.kindred(r,s,a):void 0;if(c){if(c.posts.push(t),this.register(r,c,s,a),c.open)this.thumbQueue.push(t),this.thumbs();return}let u={posts:[t],open:!1};r.groups.push(u),this.register(r,u,s,a),this.thumbQueue.push(t),this.thumbs()}kindred(t,e,n){for(let r of e){let i=t.kindred.get(r);if(i)return i}return n&&t.shapes.find((r)=>Dy(r.shape,n))?.group}register(t,e,n,r){for(let i of n)if(!t.kindred.has(i))t.kindred.set(i,e);if(r)t.shapes.push({shape:r,group:e})}holds(){this.view.held=Iv(this.home,this.entry.name).map((t)=>{let e=this.heldFiles.get(t.from);return e?{...t,thumb:e}:t}),this.holdThumbs()}holdThumbs(){let t=ue.cols*this.cell.w,e=ue.rows*this.cell.h;if(t===0||e===0)return;for(let n of this.view.held.slice(0,Yh(this.cols))){if(n.thumb||this.heldAsked.has(n.from))continue;this.heldAsked.add(n.from);let r=$n(this.scratch,`held-${VA(n.from)}-${t}x${e}.png`);this.renders.run({job:"thumb",from:n.from,to:r,width:t,height:e}).then(()=>{this.heldFiles.set(n.from,r),this.holds(),this.paint.draw()}).catch(()=>{})}}thumbs(){while(!this.signal.aborted&&this.thumbing<Nv&&this.thumbQueue.length>0){let t=this.thumbQueue.shift();this.thumbing++,this.thumb(t).catch(()=>{this.thumbless.add(pe(t.site,t.post.id)),this.show(),this.paint.draw()}).finally(()=>{this.thumbing--,this.thumbs()})}}async thumb(t){let{site:e,post:n}=t,r=gt.cols*this.cell.w,i=gt.rows*this.cell.h,s=Ka(e,n),o=$n(Ge(e),"tile",`${Fv(n.id,s.url)}-${r}x${i}.png`);if(!Ea(o)){let a=this.previewPath(t);if(await this.kept.cached(s.site,a,s.url),this.signal.aborted)return;await this.renders.run({job:"thumb",from:a,to:o,width:r,height:i})}this.thumbPath.set(pe(e,n.id),o),this.show(),this.paint.draw()}select(){let t=this.view,e=t.tiles[t.focus];if(this.fetch?.abort(),clearTimeout(this.settle),t.fetching=void 0,this.inform(),!e)return;if(this.current?.key===e.key){this.reveal();return}this.settle=setTimeout(()=>void this.load(e),aF),this.paint.draw()}async load(t){let e=this.view,n=this.posts.get(t.key);if(!n)return;let r=new AbortController;if(this.fetch=r,this.kept.credit(n,r.signal),!sn(n.post))return;let{site:i}=n,s=this.board;try{await $o(i,n.post,r.signal);let o=sn(n.post),a=this.origPath(i,t.id,o.ext);if(!Ea(a))e.fetching={id:t.key,got:0,size:0},this.paint.draw();let c=oi(i,n.post,o),u=await this.kept.cached(c.site,a,c.url,(f,h)=>{if(e.fetching?.id===t.key)e.fetching={id:t.key,got:f,size:h},this.paint.draw()});if(r.signal.aborted)return;if(e.fetching=void 0,s!==this.board)return;let l={site:i,id:t.id,key:t.key,path:a,ext:o.ext,size:u,using:"plain",failed:!1};e.preparing=t.key,this.paint.flush();let d=await this.render(l,"plain");if(r.signal.aborted||s!==this.board)return;if(d.clear===0&&Fs()&&this.setting("TTHEME_FIND_REMOVE_BG")!=="off"){if(e.preparing=void 0,e.cutting=t.key,this.paint.flush(),l.cut=await this.cutOut(i,t.id,a,r.signal),r.signal.aborted||s!==this.board)return;if(e.cutting=void 0,l.cut){e.preparing=t.key,this.paint.flush();let f=await this.render(l,"cut").catch(()=>{return});if(r.signal.aborted||s!==this.board)return;if(f&&yu(f.clear))l.using="cut";else el(l.cut,{force:!0}),l.cut=void 0,l.failed=!0}else l.failed=!0}if(this.current=l,e.tiles[e.focus]?.key===t.key)await this.present();this.preload()}catch(o){if(!r.signal.aborted&&!this.signal.aborted)e.error=Im(i.name,o)}finally{if(e.fetching?.id===t.key)e.fetching=void 0;if(e.preparing===t.key)e.preparing=void 0;if(e.cutting===t.key)e.cutting=void 0;this.paint.draw()}}async cutOut(t,e,n,r){let i=$n(Ge(t),"cut",`${e}.png`);if(Ea(i))return i;try{return zA(ZA(i),{recursive:!0}),await Qo(n,i,r),i}catch{el(i,{force:!0});return}}swap(){let t=this.current;if(!t?.cut||this.view.shown?.id!==t.key)return;t.using=t.using==="cut"?"plain":"cut",this.reveal()}preload(){let t=this.view;if(t.mode!=="try")return;for(let e of[t.focus+this.direction,t.focus-this.direction]){let n=t.tiles[e],r=n&&this.posts.get(n.key);if(r)this.kept.credit(r,this.signal);if(this.prefetching>=oF||!r||!sn(r.post))continue;let{site:i,post:s}=r;this.prefetching++,$o(i,s,this.signal).then(async()=>{let o=sn(s),a=this.origPath(i,s.id,o.ext),c=oi(i,s,o);return await this.kept.cached(c.site,a,c.url),this.render({site:i,id:s.id,key:n.key,path:a,ext:o.ext,size:0,using:"plain",failed:!1},"plain")}).catch(()=>{}).finally(()=>{this.prefetching--})}}async render(t,e){let n=this.cols*this.cell.w,r=this.rows*this.cell.h,i=Math.min(n,fF),s=Math.max(1,Math.round(r*i/n)),o={...this.view.tune},{coloring:a}=this.view,c=!Lv(o,this.view.untuned),u=o.opacity!==this.view.untuned.opacity,l=c?`-${o.size}-${o.at}${u?`-${Math.round(o.opacity*100)}`:""}`:"",d=$n(this.scratch,`${t.site.key}-${t.id}${e==="cut"?"c":""}${a==="original"?"o":""}-${i}x${s}${l}.png`),f=`${t.site.key}:${t.id}:${e}:${a}:${i}x${s}`,h=this.clarity.get(f);if(h&&Ea(d))return t.fill=h.fill,{clear:h.clear,path:d,opacity:h.opacity,touched:u};let p=await this.renders.run({job:"show",from:e==="cut"?t.cut:t.path,to:d,width:i,height:s,colors:this.entry,tone:this.tone,blur:this.blurring*i/Od(n,r).width,coloring:a,...c?{tune:{size:o.size,at:o.at,...u?{opacity:o.opacity}:{}}}:{}});if(this.clarity.set(f,p),t.fill=p.fill,c)this.keepTuned(d);return{clear:p.clear,path:d,opacity:p.opacity,touched:u}}keepTuned(t){this.tunedFiles.push(t);while(this.tunedFiles.length>hF){let e=this.tunedFiles.findIndex((n)=>n!==this.view.shown?.path&&n!==t);if(e===-1)return;el(this.tunedFiles.splice(e,1)[0],{force:!0})}}async present(){let t=this.current;if(!t)return;let e=t.using,{coloring:n}=this.view,r=this.view.tune.opacity,{clear:i,path:s,opacity:o,touched:a}=await this.render(t,e);if(this.current!==t||t.using!==e||this.view.coloring!==n)return;if(!a&&this.view.tune.opacity===r)this.view.untuned.opacity=o,this.view.tune.opacity=o;if(this.view.tuning&&t.fill)this.view.tuning.fill=t.fill;this.view.shown={id:t.key,clear:i,bytes:t.size,path:s,cut:t.cut?e==="cut"?"on":"off":t.failed?"failed":"none"}}reveal(){let t=this.view;if(this.presenting){this.again=!0;return}this.presenting=!0,t.preparing=this.current?.key,this.paint.flush(),this.present().catch((e)=>{t.error=e instanceof Error?e.message:String(e)}).finally(()=>{if(this.presenting=!1,this.again){this.again=!1,this.reveal();return}if(t.preparing===this.current?.key)t.preparing=void 0;this.paint.draw()})}async install(){let t=this.view,e=t.tiles[t.focus],n=this.current;if(!e||n?.key!==e.key||t.preparing!==void 0||t.shown?.id!==e.key)return;t.installing=e.key,t.error=void 0,this.paint.flush();let r=eF(t.tune,t.untuned),i=this.posts.get(n.key)?.post;try{await this.renders.run({job:"backdrop",from:n.using==="cut"?n.cut:n.path,source:n.path,home:this.home,colors:this.entry,tone:this.tone,origin:{site:n.site.key,id:n.id,ext:n.ext,from:`${n.site.name} ${n.id} ${n.site.pageUrl(n.id)}`,artist:i?.named.artist??[],source:bo(i?.source??"")},width:this.cols*this.cell.w,height:this.rows*this.cell.h,blur:this.blurring,coloring:t.coloring,...r?{tune:r,aligns:Si(_(this.home).terminals),user:YA()}:{}}),this.kept.owned(n.site,n.id,i?.owner??""),Oe(this.home),this.holds();let{size:s,at:o,opacity:a}=t.tune,c=r?` · ${s==="fill"?"fill":`${s}%`} · ${_t[o-1]} · ${a.toFixed(2)}`:"",u=i?.named.artist.length?`${i.named.artist.join(", ")} · `:"";t.saved={text:`Background · ${this.entry.name} ← ${u}${n.site.name} ${n.id}${c}`,key:e.key},t.installed.push(e.key),this.fetch?.abort(),clearTimeout(this.settle),t.fetching=void 0,t.mode="grid"}catch(s){t.error=s instanceof Error?s.message:String(s)}t.installing=void 0,this.paint.draw()}}async function jv(t,e,n){let r=new xm(t,ie(t),e,e.booru??"",n);if(await r.run(),pi(process.env))process.stdout.write(gi(""));return{saved:r.saved,installs:r.installs}}async function Gv(t){let e=J(),n=ie(e),r=An(n.palettes,t);if(!process.stdin.isTTY||!process.stdout.isTTY)throw Error("needs a terminal");let i=new xm(e,n,r,r.booru??""),s=await i.run();if(i.saved&&s!==0)return process.stderr.write(`${i.saved}
719
+ `),0;return s}import{spawn as wF,spawnSync as _v}from"node:child_process";import{existsSync as $F,readFileSync as Bv}from"node:fs";import{homedir as kF}from"node:os";import{join as Wv}from"node:path";function Uv(t,e,n,r=kF(),i=(s)=>{process.stdout.write(s)}){if(!e||Ft(t)||t.TMUX||Ut(t)!=="terminal-app")return;let[s="",o="-"]=(t.TTHEME_TERMINAL_SHOWN??"").split(" "),a=t.TTHEME_TTY,c=s?we(D(n),s,r):void 0,u=ou(Ts(n)).get(Qt(s))??[],l=u.find((U)=>U===`${A(s)}.${o}.png`)??u[0];if(!a||!c||o==="-"||!l||!$F(c.image))return;let d=Wv(Ts(n),l),f=["-l","JavaScript",su(n),"tab",a,De(s)],h=_(n).terminalBase??"Basic",p=rh(t,r),$=Bv(d),g,b=d,y=0,S,E=!1,I=!1,N,R=(U)=>{E=!0,wF("osascript",[...f,h],{stdio:"ignore"}).on("close",()=>{if(E=!1,I)return;i(U);let Z=N;N=void 0,Z?.()})},F=(U,Z)=>{g??=At(new Uint8Array(Bv(c.image)));let W=Wv(Ts(n),`${A(s)}.h${process.pid}-${++y}.png`);Xr(b,W,ir(rr(g,U,c.opacity,ih(g.width,g.height,c,p)))),b=W,R(Z)},j=()=>{if(b!==d)Xr(b,d,$),b=d},B=(U)=>{clearTimeout(S),S=setTimeout(()=>{if(E)N=U;else U()},Of)},X=()=>{clearTimeout(S),N=void 0};return{slots:[],paint(U){return B(U.name===s?()=>{j(),R("")}:()=>F(U.background,_n(U))),""},look(U,Z){B(()=>F(Z[0]??"",Z.map((W,$t)=>Go($t,W)).join("")))},wear(U){return _v("osascript",[...f.slice(0,-1),De(U.name),h],{encoding:"utf8"}).stdout?.trim()==="worn"?"":_n(U)},saved:async()=>new Map,restore(){return X(),I=!0,j(),_v("osascript",[...f,h],{stdio:"ignore"}),""},stop:X}}import{existsSync as Oa,readdirSync as yF,readFileSync as sl,rmSync as Kv,statSync as Dv}from"node:fs";import{homedir as vF}from"node:os";import{join as Gi}from"node:path";var SF=150,EF=260;function il(t){return t?.includes(`path = "${A("")}`)===!0}function MF(t){try{return _(t).terminals.includes("warp")}catch{return!1}}function zv(t,e){let n=A(e);if(!Oa(t))return;return yF(t).filter((i)=>i.startsWith(`${n}.`)&&/^[0-9a-f]{8}\.yaml$/.test(i.slice(n.length+1))).map((i)=>({file:i,at:Dv(Gi(t,i)).mtimeMs})).sort((i,s)=>s.at-i.at)[0]?.file??(Oa(Gi(t,`${n}.yaml`))?`${n}.yaml`:void 0)}function OF(t,e){if(!e)return;let n;try{n=sl(Gi(t,e),"utf8")}catch{return}let r=/^background_image:\n\s+path:\s*"([^"]*)"\n\s+opacity:\s*(\d+)/m.exec(n);return r?.[1]?{image:r[1],opacity:Number(r[2])/100}:void 0}function qv(t,e,n,r=vF()){if(!e||Ft(t)||t.TMUX||Ut(t)!=="warp")return;let i=Cr(r,n);if(!Oa(i)||!MF(n))return;let s=ki(r),o=cu(n),a=[],c=t.TTHEME_WARP_WEARS??Me(_(n)),u=OF(s,c&&zv(s,c)),l,d,f=(g)=>{let b=sl(i,"utf8"),y=Lr(b);if(y===g)return;if(il(g)&&!il(y)&&!Oa(o))H(o,y??"");if(tn(i,uu(b,g)),!il(g))Kv(o,{force:!0})},h=(g)=>{for(let b of a.splice(0))if(b===g)a.push(b);else Kv(Gi(s,b),{force:!0})},p=()=>{clearTimeout(l),clearTimeout(d)},$=(g,b,y)=>{p(),l=setTimeout(()=>{let S=b;if(!S)S=`${A(g.name)}.view-${process.pid}-${a.length+1}.yaml`,H(Gi(s,S),Do(g,y)),a.push(S);let E=S,I=Date.now()-Dv(Gi(s,E)).mtimeMs;d=setTimeout(()=>{f(ch(g.name,E)),h(E)},Math.max(0,EF-I))},SF)};return{slots:[],paint:(g)=>{if(g.name===c)$(g,zv(s,g.name));else if(u)$(g,void 0,u);else $(g,Oa(Gi(s,`${A(g.name)}.yaml`))?`${A(g.name)}.yaml`:void 0);return""},look:(g,b)=>{let[y="",S="",E="",,...I]=b;$({name:g,background:y,foreground:S,cursor:E,ansi:I},void 0,u)},wear:(g,b)=>b.includes("warp")?"":void 0,saved:async()=>new Map([["theme",Lr(sl(i,"utf8"))??""]]),restore:(g)=>{p();let b=g.get("theme");if(b)f(b);else if(il(Lr(sl(i,"utf8"))))f(au);return h(),""}}}function zr(t,e,n){return Uv(t,e,n)??H0(t,e)??qv(t,e,n)}function Rm(){return process.stdin.isTTY===!0&&process.stdout.isTTY===!0}function Yv(t,e){if(t.includes("/"))return t;let n=di(e,!1),r=n.filter((s)=>kr(s.dir).some((o)=>o.slug===t)),[i]=r.length===1?r:n.length===1?n:[];return i?`${i.id}/${t}`:t}function NF(t,e,n){let r=_(t),i=n.filter((s)=>!r.palettes.includes(s));if(i.length>0)pn(t,e,r,{...r,palettes:[...r.palettes,...i]});else if(n.some((s)=>r.palettes.includes(s)))Ct(t,e,r);return{state:r,fresh:i}}function RF(t){let e=Math.max(0,...t.map((n)=>n.slot.length));return t.map((n)=>` ${n.slot.padEnd(e)} ${n.from} → ${n.to} ${n.rule}`)}function Jv(t,e,n){let r=Fw(e),i=Te(ye(r.name,Dd(r),n.palettes)),s=Ot(t,n,!1).palettes.find((o)=>o.name===i.name);if(s&&JSON.stringify(s)!==JSON.stringify(i))throw Error(`${i.name} is already in ${ct(i.name)??"the ttheme catalog"} and differs — \`ttheme add ${i.name}\` wears that one`);if(!s)yc(t,[...Hn(t),i]);return i.name}var TF=["background","foreground","cursor"];function Vv(t){try{t();return}catch(e){return e.message}}function Zv(t,e,n){return Ot(t,e,!1).palettes.filter((r)=>r.name!==n).map((r)=>({name:r.name,colors:{background:r.background,foreground:r.foreground,cursor:r.cursor,selection:r.selection,ansi:r.ansi}}))}function Qv(t,e){let n=new Set(re(t,e).map((r)=>r.key));return{count:()=>re(t,e).length,added:()=>re(t,e).filter((r)=>!n.has(r.key)).length,fresh:()=>(Su(t,e)??[]).filter((r)=>!n.has(Xt(r))),discard:()=>{let r=re(t,e).filter((i)=>!n.has(i.key));for(let i of r)hs(t,e,i.key),sc(t,e);if(r.length>0)Oe(t)}}}function PF(...t){let e=new Map;for(let n of t.flatMap((r)=>r??[]))e.set(Xt(n),n);return e.size>0?[...e.values()]:void 0}function Xv(t,e,n,r){if(!Wc(process.env,_(t).terminals))return;return async(i,s)=>{let o=Te(ye(e,r(i),n.palettes)),{saved:a}=await jv(t,o,s);return{...a?{note:a}:{},count:re(t,e).length}}}async function t1(t){let e=process.stdout.isTTY===!0,n=J(),r=zr(process.env,e,n),i=r?await r.saved():new Map,s=r?.look?{look:(a)=>r.look?.(t.name,a)}:r?{only:r.slots}:{},o=e?Xu.of(process.env,n,t.name,_(n).terminals):void 0;try{return await yv(t,{color:!Ft(),...s,...o?{backdrop:o}:{}})}finally{if(r)process.stdout.write(r.restore(i))}}async function e1(t,e,n){let r=J(),i=lt(r),s=await Ek(r,n),o=t.includes("/")?t:`${s.id}/${t}`,a=Be(o);if(a)throw Error(`${o} ${a}`);if(ct(o)!==s.id)throw Error(`palettes in ${s.dir} are named ${s.id}/<palette> — ${o} belongs elsewhere`);let c=Kd(r,o);if(Ia(c))throw Error(`${o} already exists — \`ttheme edit ${o}\` changes it`);let u=e?An(Ot(r,i).palettes,e):void 0;if(!Rm())throw Error("new opens the palette editor — run it in a terminal");let l=u&&(ct(u.name)?u.base:u.default?void 0:u.name),d=u?zd(u,o,`kept from ${u.name}`):void 0,f=u?Su(r,u.name)??u.pictures:void 0,{base:h,ansiSource:p,group:$,...g}=d??{name:o,signature:TF,...Ur(wa)},b=Qv(r,o),y=({colors:I,signature:N})=>{let R=PF(f,b.fresh());return Dd({...g,...I,signature:N,...l?{base:l}:{},...R?{pictures:R}:{}})},S=await t1({title:"New palette",name:o,...d?{colors:d}:{},signature:g.signature,...g.waive?{waive:g.waive}:{},palettes:Zv(r,i,o),pictures:b.count(),find:Xv(r,o,i,y),check:(I)=>Vv(()=>ye(o,y(I),i.palettes))});if(!S){b.discard(),console.log("Nothing made");return}IF(xF(c),{recursive:!0}),H(c,y(S));let{state:E}=NF(r,i,[o]);console.log(` + ${o}${u?` from ${u.name}`:""}
720
+ ${c}`),await Wn(r,Ot(r,i).palettes.filter((I)=>I.name===o),E.terminals),console.log(`
721
+ \`ttheme use ${o}\` wears it · \`ttheme edit ${o}\` opens it again`)}function HF(t,e,n){let r=Te(ye(t,e,n.palettes));return Ao(r).length>0?Po(r).filter((i)=>i.startsWith(" ✗")):[]}async function n1(t){let e=J(),n=lt(e),r=_(e),i=Ot(e,n,!1),s=Yv(t,e),o=al(e,s),a=o&&Ia(o)?s:i.palettes.some((b)=>b.name===t)?t:s,c=al(e,a);if(!c||!Ia(c)){let b=i.palettes.some((y)=>y.name===a);throw Error(b?`${a} is not one of yours — \`ttheme new <name> --from ${a}\` makes your own copy`:`no palette of yours called ${a} — \`ttheme new\` makes one`)}if(!Rm())throw Error("edit opens the palette editor — run it in a terminal");let u=Nm(c,"utf8"),l;try{l=ye(a,u,n.palettes)}catch(b){throw Error(`${c} cannot be read — ${b.message}`)}let d=Qv(e,a),f=new Set((l.pictures??[]).map((b)=>Xt(b))),h=({colors:b,signature:y})=>Tw(Cw(Yd(u,b),y),d.fresh().filter((S)=>!f.has(Xt(S)))),p=await t1({title:"Edit palette",name:a,colors:qd(l),signature:l.signatureSlots,waive:l.waive,palettes:Zv(e,n,a),pictures:d.count(),find:Xv(e,a,n,h),check:(b)=>Vv(()=>ye(a,h(b),n.palettes))});if(!p){d.discard(),console.log("Nothing changed");return}let $=h(p);if($===u){console.log(d.added()>0?`Kept the pictures you added to ${a}`:"Nothing changed");return}if(H(c,$),r.palettes.includes(a))Ct(e,n,r);console.log(`Saved ${a}${r.palettes.includes(a)?" — new tabs and `ttheme use` wear it":` — \`ttheme add ${a}\` installs it`}`);let g=HF(a,$,n);if(g.length>0)console.log(`
537
722
  It misses the contrast gate:
538
- ${w.join(`
723
+ ${g.join(`
539
724
  `)}
540
- \`ttheme check --fix ${a}\` suggests colors that pass`)}function Z$(t,e,n){return mn(t.palettes,t.palettes.some((r)=>r.name===e)?e:_$(e,n))}function Q$(t,e=!1){let n=Y(),r=ct(n),i=B(n),o=Z$(wt(n,r),t,n);if(console.log(`${o.name} · ${o.group}
541
- `),console.log(No(o).join(`
542
- `)),Ho(o).length===0)return console.log(`
543
- Passes the gate`),0;let{theme:a,moves:c,left:u}=bc(Ee(o));if(c.length===0)return console.log(`
725
+ \`ttheme check --fix ${a}\` suggests colors that pass`)}function r1(t,e,n){return An(t.palettes,t.palettes.some((r)=>r.name===e)?e:Yv(e,n))}function i1(t,e=!1){let n=J(),r=lt(n),i=_(n),s=r1(Ot(n,r),t,n);if(console.log(`${s.name} · ${s.group}
726
+ `),console.log(Po(s).join(`
727
+ `)),Ao(s).length===0)return console.log(`
728
+ Passes the gate`),0;let{theme:a,moves:c,left:u}=zu(We(s));if(c.length===0)return console.log(`
544
729
  No color change fixes it — waive the rule in [contrast] with a reason, or pick other colors`),1;console.log(`
545
730
  ${u.length===0?"These colors pass":"These colors come closer"}:
546
- ${EP(c).join(`
547
- `)}`);let l=xc(n,o.name);if(!l||!Es(l))return console.log(`
548
- \`ttheme new <name> --from ${o.name}\` makes a copy you can fix`),1;if(!e)return console.log(`
549
- \`ttheme check --fix ${o.name}\` writes them`),1;if(T(l,vl(Rd(l,"utf8"),yl(a))),i.palettes.includes(o.name))At(n,r,i);return console.log(`
550
- Wrote ${l}`),u.length===0?0:1}function xc(t,e){let n=rt(e);return n&&Nr(t,!1).some((r)=>r.id===n)?wl(t,e):void 0}function OP(t,e){let n=xc(t,e.name),r=n&&Es(n)?ee(e.name,Rd(n,"utf8"),[e]).waiveReason:void 0,i=tc(t,e.name)??e.pictures,{pictures:o,...s}=$l(e,e.name,r);return{...s,...i?{pictures:i}:{}}}async function NP(t,e,n){if(t===e)return e;let r=n;if(r===void 0)if(!Pd())r="tuned";else{let i=await xh({message:`Share ${e.name} as…`,options:[{value:"tuned",label:"Your tone",hint:`named ${Fc(e.name)}`},{value:"original",label:"The original"}]});if(Lt(i))throw new Ze;r=i}return r==="original"?e:t}function Fc(t){return`${t}-tuned`}async function X$(t,e){let n=Y(),r=ct(n),i=Z$(Rr(n,r),t,n),o=Ro(i,dn(n)[i.name]),s=await NP(o,i,e),a=OP(n,s),c=s===o&&o!==i;if(c){let u=ke(Fc(s.name));if(u)throw Error(`${Fc(s.name)} ${u} — share the original, or tune a palette with a shorter name`);a.name=Fc(s.name)}if(console.log(Gp(a)),process.stdout.isTTY)console.error(`
551
- Anyone with ttheme wears it with: ttheme add ${fn}…${c?`
552
- It carries your tone, named ${a.name} so it does not clash with ${s.name}`:""}`)}function Lc(t){console.log(`
553
- ${t} palettes installed — open a new tab, or reload your terminal config`)}function PP(t,e){return t.map((n)=>{if(n.startsWith(fn))return n;let r=rt(n);if(r===void 0)return e===J?n:`${e}/${n}`;if(r!==e)throw Error(`${n} is not in ${e} — give its bare name, or leave --market out`);return n})}async function tk(t,e){let n=Y(),r=e?PP(t,(await Sf(n,e)).id):t,i=ct(n),o=[...new Set(r.map((l)=>l.startsWith(fn)?B$(n,l,i):l))],s=B(n),a=o.filter((l)=>s.palettes.includes(l)),c=o.filter((l)=>!s.palettes.includes(l));if(c.length===0){At(n,i,s),console.log(`Already installed: ${a.join(", ")}`);return}let u={...s,palettes:[...s.palettes,...c]};Ye(n,i,s,u);for(let l of c)console.log(` + ${l}`);await pn(n,wt(n,i,!1).palettes.filter((l)=>c.includes(l.name)),u.terminals),Lc(u.palettes.length)}function ek(t){let e=Y(),n=ct(e),r=B(e),i=t.filter((a)=>r.palettes.includes(a)),o=t.filter((a)=>!r.palettes.includes(a));if(i.length===0)throw Error(`not installed: ${o.join(", ")} — \`ttheme list\` marks what is`);let s={...r,palettes:r.palettes.filter((a)=>!i.includes(a))};Ye(e,n,r,s),Da(e,n,r.terminals,i);for(let a of i)console.log(` - ${a}`);if(Lc(s.palettes.length),o.length>0)return console.error(`ttheme remove: not installed: ${o.join(", ")}`),1;return 0}function nk(t){let e=Y(),n=ct(e),r=B(e);if(!r.palettes.includes(t))throw Error(`${t} is not installed — \`ttheme add ${t}\` first`);let{off:i,...o}=r,s=Ye(e,n,r,{...o,startup:t},!0);console.log(ok(t,r.terminals,s).join(`
554
- `))}function rk(){let t=Y(),e=B(t),n=Fr(e);if(!n)throw Error("no palettes installed — `ttheme browse` picks some");if(!e.off){console.log(`Already on · ${n}`);return}let{off:r,...i}=e,o=Ye(t,ct(t),e,i);console.log(ok(n,i.terminals,o).join(`
555
- `))}function ik(){let t=Y(),e=B(t);if(e.off){console.log("Already off");return}let n=Ye(t,ct(t),e,{...e,off:!0}),r=Fr(e);console.log(`Off · new tabs open in the terminal's own colors${r?` — \`ttheme on\` wears ${r} again`:""}`);for(let i of lt(e.terminals))if(n.get(i.id)?.restart)console.log(`${i.name} new tabs open on your own profile once ${i.name} restarts`)}function ok(t,e,n){let r=lt(e).filter((o)=>!o.defaults),i=r.length>0?[`Default ${t} · ${r.map((o)=>o.name).join(", ")} open new tabs with it once their config reloads`]:[];for(let o of lt(e)){let s=o.defaults?.profile(t);if(s)i.push(n.get(o.id)?.restart?`${o.name} new tabs open with it once ${o.name} restarts — "${s}" is now its default profile`:`${o.name} new tabs open with it — "${s}" is its default profile`)}return i.length>0?i:[`Default ${t} · no terminal is wired to open with it — \`ttheme init\` wires one`]}function sk(t,e){let n=new Map(e.palettes.map((r)=>[r.name,"market"]));for(let r of pa(t,e.palettes,!1))n.set(r.name,"mine");return n}function ak(t,e=!1){let n=Y(),r=ct(n),i=new Set(B(n).palettes),o=sk(n,r),s=Mt(wt(n,r).palettes),a=Ir(t?Qp(s,t):s),c=(f)=>o.get(f)??"kept";if(e){let f=a.map((d)=>({name:d.name,group:d.group,...d.catalog?{catalog:d.catalog}:{},installed:i.has(d.name),source:c(d.name)}));console.log(JSON.stringify(f,null,2));return}let u=Math.max(...a.map((f)=>f.name.length),0),l={market:"",mine:" · yours",kept:" · in no market you added"};for(let f of a){let d=f.catalog?`${f.group} / ${f.catalog}`:f.group;console.log(` ${i.has(f.name)?"●":"○"} ${f.name.padEnd(u)} ${d}${l[c(f.name)]}`)}if(process.stdout.isTTY){let f=t?`${a.length} of ${s.length}`:`${s.length}`;console.log(`
556
- ${f} palettes — ${a.filter((d)=>i.has(d.name)).length} installed`)}}async function ck(){let t=Y(),e=vi(t);if(e.length===0)console.log("No markets to update — `ttheme market add official` brings the ttheme catalog back");let n=(d,m)=>`${et(d)}: ${m.message} — kept the copy from the last update`;for(let d of e.filter(ut))try{console.log(` ${Dw(t,d)}`)}catch(m){console.log(` ${n(d,m)}`)}let r=e.filter((d)=>!ut(d)),i=new Set(r),o=ar(),s=()=>o.set(`Updating ${[...i].map(et).join(", ")}${r.length>1?` · ${r.length-i.size}/${r.length}`:""}`);if(s(),await Promise.all(r.map(async(d)=>{let m;try{m=wf(await Yo(t,d))}catch(g){m=n(d,g)}if(i.delete(d),i.size>0)s();else o.done();o.say(` ${m}`)})),o.done(),!RP(_n(t)))return;let a=ct(t),c=B(t),u=sk(t,a),l=c.palettes.filter((d)=>!u.has(d)),f=new Map(hn(t).map((d)=>[d.name,d.pictures]));At(t,a,c);for(let d of l)console.log(` ${d} left its market — ttheme keeps the copy you have`);await pn(t,wt(t,a,!1).palettes.filter((d)=>c.palettes.includes(d.name)&&f.has(d.name)).map((d)=>Li(d,f.get(d.name))),c.terminals)}async function Id(t,e,n,r=!1){let i=process.env.TTHEME_SORT==="series"?t.palettes:Ir(t.palettes),o=process.stdout.isTTY===!0,s=Zn(process.env,o)??lr(process.env,o,Y()),a=s?await s.saved():new Map,c=new Af({entries:i,scope:n,installed:e,required:r,color:!zt(),fx:oc(process.env.TTHEME_FX),onFocus:s?(l)=>process.stdout.write(s.paint(l)):void 0}),u=await c.prompt();if(s)process.stdout.write(s.restore(a));if(Lt(u))return;return t.palettes.filter((l)=>c.picked.has(l.name)).map((l)=>l.name)}function Hd(t,e,n,r){let i;try{i=Ci(t,n)}catch{i=Xt(n)?Wn(n):et(n)}let o=[];if(ut(n))try{o=qn(n,i,Ai(t,J),!1)}catch{o=[]}else o=Ai(t,n);return{source:n,id:i,shown:et(n),entries:o,auto:Bn(n,e.updates),status:Of(t,n,r)}}function Tc(t){return t instanceof Error?t.message:String(t)}function FP(t,e,n,r){let i=new Map(r.map((s)=>[s.source,s.id])),o=[];for(let s of Ft(e.markets)){let a=i.get(s)??et(s),c=n[s],u=qo(t,s);if(c&&(u===void 0||c.at>u))o.push({where:a,source:s,update:!0,message:`Update failed ${Do(c.at)}: ${c.error}`});if(s===J)try{ze(uk(Me(t),"utf8"))}catch(l){o.push({where:a,source:s,message:`${et(Me(t))}: ${Tc(l)}`})}else if(Xt(s))if(!HP(Se(t,s)))o.push({where:a,source:s,message:"No copy of its index yet — `ttheme update` fetches it"});else try{Jn(t,s)}catch(l){o.push({where:a,source:s,message:`${et(Se(t,s))}: ${Tc(l)}`})}else try{let l=te(Be(s)),f=new Map;for(let d of Kn(s))try{let m=Oo(d,f);if(m)throw Error(m);f.set(d.slug,d),ee(`${l}/${d.slug}`,uk(d.path,"utf8"),Ai(t,J))}catch(m){o.push({where:et(d.path),message:Tc(m)})}}catch(l){o.push({where:a,message:Tc(l)})}}return o}function xP(t,e,n,r){return{refresh:async(i)=>{if(ut(i)){let s=Hd(t,e,i,bn());return{market:s,refreshed:{source:i,id:s.id,count:Mt(s.entries).length,change:{added:[],changed:[],gone:[]}}}}let o=await Yo(t,i,pf);return{market:Hd(t,e,i,bn()),refreshed:o}},fetch:async(i)=>{if(ut(i)){let s=te(Be(i));return{source:i,id:s,shown:et(i),entries:qn(i,s,Ai(t,J),!1),auto:!1,status:"read in place"}}let o=await Jo(i,void 0,r);return n.set(i,o),{source:i,id:o.id,shown:et(i),entries:o.entries,auto:Bn(i,{}),status:"not added yet"}},search:(i)=>Rf(i,r)}}function LP(t,e,n){let r=[];for(let i of t.adds){let o=i.source!==J&&(t.auto[i.source]??i.auto);r.push(`Added ${i.id} · ${i.shown} — ${_t(Mt(i.entries).length)}${o?", updating on its own":""}`)}for(let i of t.removes){let o=e.find((a)=>a.source===i)?.id??i;r.push(`Removed ${o} · ${et(i)}`);let s=n.filter((a)=>(rt(a)??J)===o);if(s.length>0)r.push(If(s))}for(let[i,o]of Object.entries(t.auto)){let s=e.find((a)=>a.source===i);if(s&&!t.removes.includes(i))r.push(`${s.id} ${o?"updates on its own now":"no longer updates on its own"}`)}return r}async function TP(t,e,n,r,i){let o=B(t),s=r.adds.length+r.removes.length+Object.keys(r.auto).length>0;for(let b of r.adds){let v=i.get(b.source);if(v)Ti(t,v)}for(let b of r.removes)Mf(t,b);let a=[...Ft(o.markets).filter((b)=>!r.removes.includes(b)),...r.adds.map((b)=>b.source)],c=Zo(o,a,{...o.updates,...r.auto});if(s)Je(t,c);let u=ct(t,!1),l=wt(t,u,!1).palettes.filter((b)=>r.picked.has(b.name)).map((b)=>b.name),f=o.palettes.filter((b)=>!l.includes(b)),d=l.filter((b)=>!o.palettes.includes(b));if(!s&&d.length===0&&f.length===0){await Vo(t,o,e,r.refreshed),console.log("Nothing changed");return}let m={...c,palettes:l};Ye(t,u,o,m),Da(t,u,o.terminals,f);for(let b of LP(r,n,l))console.log(b);for(let b of d)console.log(` + ${b}`);for(let b of f)console.log(` - ${b}`);let g=new Map(e.map((b)=>[b.name,b.pictures])),$=new Set(r.refreshed.flatMap((b)=>[...b.change.changed,...b.change.gone])),w=wt(t,u,!1).palettes;if(await pn(t,[...w.filter((b)=>d.includes(b.name)),...w.filter((b)=>l.includes(b.name)&&!d.includes(b.name)&&$.has(b.name)&&g.has(b.name)).map((b)=>Li(b,g.get(b.name)))],m.terminals),d.length>0||f.length>0)Lc(m.palettes.length)}async function lk(){let t=eb(process.env),e=Y(),n=B(e),r=hn(e),i=bn(),o=Ft(n.markets).map((v)=>Hd(e,n,v,i)),s=new Set(o.flatMap((v)=>v.entries.map((R)=>R.name))),a=r.filter((v)=>n.palettes.includes(v.name)&&!s.has(v.name)),c=new Map,u=new AbortController,l=process.stdout.isTTY===!0,f=Zn(process.env,l)??lr(process.env,l,e),d=f&&!t?await f.saved():new Map,m=Ne(n);if(t)process.stdout.write("\x1B[?2026h");let g=new Gf({markets:o,kept:a,installed:n.palettes,...m?{startup:m}:{},...t?{hub:t}:{},problems:FP(e,n,i,o),due:bf(e,n),io:xP(e,n,c,u.signal),...process.env.TTHEME_SORT==="series"?{}:{order:Ir},color:!zt(),fx:oc(process.env.TTHEME_FX),...f?{onFocus:(v)=>process.stdout.write(f.paint(v))}:{}});if(l&&!t)process.stdout.write("\x1B[?1049h");let $;try{$=await g.prompt()}finally{if(f&&!t)process.stdout.write(f.restore(d));u.abort()}await g.idle();let w=g.result(),b=g.next();if(t&&b!==void 0)return process.stdout.write("\x1B[?25l"),await Vo(e,B(e),r,w.refreshed),b;if(l)process.stdout.write("\x1B[?1049l\x1B[?25h");for(let v of w.refreshed){let R=$f(v);if(R)console.log(R)}if(Lt($))await Vo(e,B(e),r,w.refreshed),console.log("Nothing changed");else await TP(e,r,o,w,c);return t?Ma:0}import{readFileSync as fk}from"node:fs";async function dk(t,e,n){let r=Y();if(mn(Ie(r).palettes,t),e==="show"){if(!n)throw Error("image show needs the picture to show");let{at:i,of:o}=ki(r,t,n);return oe(r),process.stderr.write(`Background · ${t} ${i}/${o} ${n}
557
- `),0}if(e==="drop"){let{key:i,left:o}=fa(r,t,n);return oe(r),process.stderr.write(`Background · ${t} removed ${i} · ${o} left
558
- `),0}if(e==="tone"||e==="original"){let i=await N$(r,t,e,n);return process.stderr.write(`Background · ${t} ${i.key} ${e==="tone"?"tinted":"in its own colors"}
559
- `),0}if(e==="prepare"){let{key:i,coloring:o}=R$(r,t,n);return process.stderr.write(`Background · ${t} ${i} ready in ${o==="tone"?"its tone":"its own colors"}
560
- `),0}if(e==="tuned")return oe(r),0;throw Error(`unknown image action ${e} — show, drop, tone, original, prepare or tuned`)}function hk(t,e){let n=/^(\d+)x(\d+)$/.exec(t),r=/^(\d+)x(\d+)([+-]\d+)([+-]\d+)$/.exec(e);if(!n||!r)throw Error("a canvas is <width>x<height> and a place <width>x<height>+<x>+<y>");let[i,o]=n.slice(1).map(Number),[s,a,c,u]=r.slice(1).map(Number);return{width:i,height:o,at:{x:c,y:u,w:s,h:a}}}function AP(t,e,n){let r=hk(e,n),i=Math.min(1,t.width/r.at.w);if(i===1)return r;return{width:Math.max(1,Math.round(r.width*i)),height:Math.max(1,Math.round(r.height*i)),at:{x:Math.round(r.at.x*i),y:Math.round(r.at.y*i),w:t.width,h:t.height}}}function mk(t,e,n,r){let i=ue(new Uint8Array(fk(t)));return T(e,Ce(Jm(i,hk(n,r)))),0}function gk(t,e,n,r,i,o){let s=Number(r);if(!Bt(n)||!Number.isFinite(s))throw Error("flatten needs a #rrggbb background and an opacity from 0 to 1");let a=ue(new Uint8Array(fk(t))),c=i===void 0?void 0:AP(a,i,o??"");return T(e,Ks(zs(a,n,Math.max(0,Math.min(1,s)),c))),0}import{execFileSync as CP}from"node:child_process";import{readFileSync as jP}from"node:fs";import{arch as GP,platform as Ac,release as Fd}from"node:os";var UP={ghostty:"ghostty",iterm2:"iTerm.app",wezterm:"WezTerm","terminal-app":"Apple_Terminal",warp:"WarpTerminal"};function WP(t,e){if(t==="konsole"){let r=/^(\d{2})(\d{2})(\d{2})$/.exec(e.KONSOLE_VERSION??"");return r?`${r[1]}.${r[2]}.${Number(r[3])}`:e.KONSOLE_VERSION}let n=UP[t];return n!==void 0&&e.TERM_PROGRAM===n?e.TERM_PROGRAM_VERSION:void 0}function _P(t){let e=ne(t),n=t.TERM_PROGRAM&&t.TERM_PROGRAM!=="tmux"?t.TERM_PROGRAM:void 0,r=e==="unknown"?`unknown${n?` (TERM_PROGRAM=${n})`:""}`:e==="editor"?`editor (${Ll(t)})`:`${e} ${WP(e,t)??"(version unknown)"}`,i=t.TERM_PROGRAM==="tmux"?t.TERM_PROGRAM_VERSION:void 0;return[r,t.TMUX?`tmux ${i??"yes"}`:"tmux no",t.SSH_CONNECTION||t.SSH_TTY?"ssh yes":"ssh no"].join(" · ")}function pk(t,e){try{return CP(t,e,{encoding:"utf8",timeout:2000,stdio:["ignore","pipe","ignore"]}).trim()}catch{return}}function BP(){let t=GP();if(Ac()==="darwin")return`macOS ${pk("sw_vers",["-productVersion"])??`(Darwin ${Fd()})`} · ${t}`;if(Ac()==="linux"){let e="";try{e=jP("/etc/os-release","utf8")}catch{}return`${/^PRETTY_NAME="?([^"\n]*)"?$/m.exec(e)?.[1]??"Linux"} · linux ${Fd()} · ${t}`}return`${Ac()==="win32"?"Windows":Ac()} ${Fd()} · ${t}`}function zP(t){if(t.TTHEME_ZSH)return`zsh ${t.TTHEME_ZSH}`;return(t.SHELL?pk(t.SHELL,["--version"])?.split(`
561
- `)[0]:void 0)??t.SHELL??"unknown"}function KP(t){try{let{terminals:e}=B(t);return e.length>0?e.join(", "):"none"}catch{return"installed.json missing or unreadable"}}function qP(t){let e=Oa.flatMap((n)=>{let r=t[n];return r===void 0||r===To(n)?[]:[`${n}=${/\s/.test(r)?JSON.stringify(r):r}`]});return e.length>0?e.join(" "):void 0}function bk(){let t=process.env,n=[["ttheme",Ot.version],["OS",BP()],["Shell",zP(t)],["Terminal",_P(t)],["Wired",KP(Y())],["Settings",qP(t)]].filter((i)=>i[1]!==void 0),r=Math.max(...n.map(([i])=>i.length));for(let[i,o]of n)console.log(`${i.padEnd(r)} ${o}`)}import{createInterface as JP}from"node:readline";var YP="\x1F",wk="\x1E",DP=new Set(["up","down","left","right","home","end","pgup","pgdn","tab","shift-tab","shift-left","shift-right","enter","esc","backspace","ctrl-c"]);function $k(t){return{background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selection,ansi:t.ansi}}class kk{editor;base;cols=cd;rows=ud;focused=!0;home;name;color;constructor(t,e,n){this.home=t,this.name=e,this.color=n,this.base=mn(Rr(t,ct(t),!1).palettes,e);let r=Ro(this.base,dn(t)[e]);this.editor=new gs({title:"Tone",name:e,colors:$k(r),original:$k(this.base),variant:"theme",signature:r.signatureSlots,...r.waived?{waive:r.waived}:{},check:()=>{return}})}save(){try{let t=Kp(this.base,this.editor.list);zp(this.home,qp(dn(this.home),this.name,t)),At(this.home,ct(this.home),B(this.home)),this.editor.markSaved();return}catch(t){return t instanceof Error?t.message:String(t)}}frame(t="ok",e){let n=Z0(this.editor),r=this.editor.act??"-";this.editor.act=void 0;let{lines:i,at:o}=Q0(this.editor,this.cols,this.rows,this.color,this.focused);return[t,r,n.mode,this.editor.dirty()?"1":"0",this.editor.shown().join(" "),n.keys.map(([s])=>s).join(wk),n.keys.map(([,s])=>s).join(wk),e??n.note,String(o),...i].join(YP)}handle(t){let[e="",...n]=t.split(" "),r=n.join(" ");if(e==="quit")return;if(e==="size"){let[i,o]=r.split(" ").map(Number);this.cols=Math.max(30,i??cd),this.rows=Math.max(10,o??ud)}else if(e==="focus")this.focused=r==="1";else if(e==="key"&&DP.has(r))this.editor.press(r);else if(e==="ch"){let i=Number(r);if(Number.isInteger(i)&&i>0)this.editor.press(String.fromCharCode(i))}else if(e==="save"){let i=this.save();return i===void 0?this.frame("saved","Saved"):this.frame("error",i)}return this.frame()}}async function yk(t){let e=new kk(Y(),t,process.env.NO_COLOR===void 0),n=JP({input:process.stdin});for await(let r of n){let i=e.handle(r);if(i===void 0)break;process.stdout.write(`${i}
562
- `)}return n.close(),process.stdin.destroy(),0}import{existsSync as vk,rmSync as VP,utimesSync as ZP}from"node:fs";import{homedir as QP}from"node:os";import{join as Ss}from"node:path";function XP(t){try{return B(t)}catch{return}}function tH(t){let{home:e,configHome:n}=t,r=XP(n),i={configHome:n,home:e},o=lt(re),s=o.map((c)=>c.unwire(i,r)),a=[Ss(n,"ttheme"),t.cacheDir,t.stateDir];return{edits:[...Ke(Ss(t.zdotdir,".zshrc"),Xn),...s.flatMap((c)=>c.edits)],removals:[...o.flatMap((c)=>c.shelf?Fa(c.shelf.dir(i)):[]),...s.flatMap((c)=>c.removals),...a.filter((c)=>vk(c))],touches:s.flatMap((c)=>c.touches),...r?{state:r}:{}}}function eH(t,e,n=Pr()){let r=[];for(let{file:o,content:s}of t.edits){let a=qh(o,s);r.push(a==="removed"?`Removed ${o} — ttheme had created it`:a==="restored"?`Took ttheme out of ${o}`:`Took ttheme out of ${o} — kept ${o}.ttheme.bak, since the file changed after ttheme's first edit`)}if(t.state){let o=zo(e.configHome,{...t.state,off:!0,palettes:[]},!1,n,e.home);for(let s of lt(t.state.terminals))if(o.has(s.id))r.push(`Gave ${s.name} its own default profile back — it takes it at its next start`)}for(let o of t.removals)VP(o,{recursive:!0,force:!0});if(t.removals.length>0)r.push(`Deleted ${t.removals.length} files and folders ttheme wrote`);let i=new Date;for(let o of t.touches)ZP(o,i,i);return r}function nH(){let t=QP();return{home:t,configHome:Y(),zdotdir:process.env.ZDOTDIR??t,cacheDir:An(),stateDir:Ss(process.env.XDG_STATE_HOME??Ss(t,".local","state"),"ttheme")}}async function Ek(t=!1){let e=nH(),n=tH(e);if(n.edits.length===0&&n.removals.length===0){console.log("Nothing of ttheme is installed");return}if(!t){if(process.stdin.isTTY!==!0||process.stdout.isTTY!==!0)throw Error("uninstall asks before it deletes anything — run it in a terminal, or pass --yes");let r=Ss(e.configHome,"ttheme");Gs("ttheme uninstall"),br([...n.edits.map((o)=>`Take ttheme out of ${o.file}`),...n.removals.map((o)=>o===r?`Delete ${o} — settings, pins, every installed picture${vk(ma(e.configHome))?`, and your markets under ${ma(e.configHome)} (push them to GitHub first to keep them)`:""}`:`Delete ${o}`)].join(`
563
- `),"Uninstall");let i=await rn({message:"Remove ttheme?"});if(Lt(i)||!i)throw Vr("Nothing changed"),new Ze}for(let r of eH(n,e))console.log(r);console.log("Open tabs keep their colors until they close — restart your terminal to drop ttheme everywhere")}var iH=new Set(["add","remove","market","default","on","off"]),oH={default:([t])=>nk(t),on:()=>rk(),off:()=>ik(),browse:()=>lk(),list:([t],{json:e})=>ak(t,e),add:(t,{market:e})=>tk(t,e),remove:(t)=>ek(t),update:()=>ck(),market:([t,e])=>Yw(t,e),new:([t],{from:e,in:n})=>D$(t,e,n),edit:([t])=>V$(t),check:([t],{fix:e})=>Q$(t,e),share:([t],{tone:e})=>X$(t,e),init:(t,{yes:e})=>W$({yes:e}),uninstall:(t,{yes:e})=>Ek(e),info:()=>bk(),build:(t,{only:e})=>Ic({only:e}),find:([t])=>S$(t),image:([t,e,n])=>dk(t,e,n),redraw:()=>P$(),tone:([t])=>yk(t),flatten:([t,e,n,r,i,o])=>gk(t,e,n,r,i,o),bake:([t,e,n,r])=>mk(t,e,n,r)},sH=xo.map((t)=>({...t,run:oH[t.name]}));class zr extends Error{verb;constructor(t,e){super(t);this.verb=e}}function Sk(t){let e=sH.find((n)=>n.name===t);if(!e)throw new zr(t.startsWith("-")?`unknown option '${t}'`:`unknown command '${t}'`);return e}function aH(t,e){let n={help:{type:"boolean",short:"h"}};for(let[r,{type:i,short:o,multiple:s}]of Object.entries(t.flags??{}))n[r]={type:i,multiple:s===!0,...o?{short:o}:{}};try{return rH({args:e,options:n,allowPositionals:!0})}catch(r){let[i=""]=(r instanceof Error?r.message:String(r)).split(". ");throw new zr(`${i.charAt(0).toLowerCase()}${i.slice(1)}`,t)}}function cH(t){let[e,...n]=t;if(e===void 0)return{kind:"help",code:1};if(e==="-h"||e==="--help")return{kind:"help",code:0};if(e==="-V"||e==="--version")return{kind:"version"};if(e==="help"){if(n[0]===void 0||n[0]==="all")return{kind:"help",all:n[0]==="all",code:0};return{kind:"help",verb:Sk(n[0]),code:0}}let r=Sk(e),i=aH(r,n);if(i.values.help)return{kind:"help",verb:r,code:0};for(let[l,{choices:f}]of Object.entries(r.flags??{}))for(let d of[i.values[l]??[]].flat())if(f&&!f.includes(String(d)))throw new zr(`--${l} takes ${f.join(", ")} — not ${d}`,r);let o=i.positionals,s=r.args.filter((l)=>l.startsWith("<")).length,a=r.args.some((l)=>l.includes("..."))?Number.POSITIVE_INFINITY:r.args.length;if(o.length<s)throw new zr(`missing ${r.args[o.length]}`,r);if(o.length>a)throw new zr(`too many arguments: ${o.slice(a).join(" ")}`,r);let{help:c,...u}=i.values;return{kind:"run",verb:r,args:o,flags:u}}function Mk(t){let e=Math.max(0,...t.map(([n])=>n.length));return t.map(([n,r])=>` ${n.padEnd(e)} ${r}`)}function xd(t,e=!1){if(!t)return Lo(e);let n=Object.entries(t.flags??{}).map(([r,{short:i,value:o,about:s}])=>[`${i?`-${i}, `:""}--${r}${o?` ${o}`:""}`,s]);return[`Usage: ttheme ${Fo(t)}`,"",t.about,...t.actions?["","Actions:",...Mk(t.actions)]:[],...n.length>0?["","Options:",...Mk(n)]:[]].join(`
564
- `)}var uH=[TypeError,RangeError,ReferenceError,SyntaxError];function lH(t){return uH.some((e)=>t instanceof e)||t instanceof Error&&"code"in t}async function Ik(t){let e;try{let n=cH(t);if(n.kind==="version")return console.log(Ot.version),0;if(n.kind==="help"){if(n.code===0)console.log(xd(n.verb,n.all));else console.error(xd(n.verb,n.all));return n.code}if(e=n.verb,!n.verb.run)throw Error("runs in the shell layer — open a new tab once `ttheme init` has wired it");if(iH.has(n.verb.name))await Fw();let r=await n.verb.run(n.args,n.flags);return typeof r==="number"?r:0}catch(n){if(n instanceof zr)return console.error(n.verb?`ttheme ${n.verb.name}: ${n.message}
731
+ ${RF(c).join(`
732
+ `)}`);let l=al(n,s.name);if(!l||!Ia(l))return console.log(`
733
+ \`ttheme new <name> --from ${s.name}\` makes a copy you can fix`),1;if(!e)return console.log(`
734
+ \`ttheme check --fix ${s.name}\` writes them`),1;if(H(l,Yd(Nm(l,"utf8"),qd(a))),i.palettes.includes(s.name))Ct(n,r,i);return console.log(`
735
+ Wrote ${l}`),u.length===0?0:1}function al(t,e){let n=ct(e);return n&&di(t,!1).some((r)=>r.id===n)?Kd(t,e):void 0}function AF(t,e){let n=al(t,e.name),r=n&&Ia(n)?ye(e.name,Nm(n,"utf8"),[e]).waiveReason:void 0,i=Su(t,e.name)??e.pictures,{pictures:s,...o}=zd(e,e.name,r);return{...o,...i?{pictures:i}:{}}}async function FF(t,e,n){if(t===e)return e;let r=n;if(r===void 0)if(!Rm())r="tuned";else{let i=await E0({message:`Share ${e.name} as…`,options:[{value:"tuned",label:"Your tone",hint:`named ${ol(e.name)}`},{value:"original",label:"The original"}]});if(oe(i))throw new Ie;r=i}return r==="original"?e:t}function ol(t){return`${t}-tuned`}async function s1(t,e){let n=J(),r=lt(n),i=r1(fi(n,r),t,n),s=vs(i,Pn(n)[i.name]),o=await FF(s,i,e),a=AF(n,o),c=o===s&&s!==i;if(c){let u=Be(ol(o.name));if(u)throw Error(`${ol(o.name)} ${u} — share the original, or tune a palette with a shorter name`);a.name=ol(o.name)}if(console.log(Aw(a)),process.stdout.isTTY)console.error(`
736
+ Anyone with ttheme wears it with: ttheme add ${Tn}…${c?`
737
+ It carries your tone, named ${a.name} so it does not clash with ${o.name}`:""}`)}function cl(t){Bn(`
738
+ ${t} palettes installed — open a new tab, or reload your terminal config`)}function LF(t,e){return t.map((n)=>{if(n.startsWith(Tn))return n;let r=ct(n);if(r===void 0)return e===q?n:`${e}/${n}`;if(r!==e)throw Error(`${n} is not in ${e} — give its bare name, or leave --market out`);return n})}async function o1(t,e){let n=J(),r=e?LF(t,(await Oh(n,e)).id):t,i=lt(n),s=[...new Set(r.map((l)=>l.startsWith(Tn)?Jv(n,l,i):l))],o=_(n),a=s.filter((l)=>o.palettes.includes(l)),c=s.filter((l)=>!o.palettes.includes(l));if(c.length===0){Ct(n,i,o),console.log(`Already installed: ${a.join(", ")}`);return}let u={...o,palettes:[...o.palettes,...c]};pn(n,i,o,u);for(let l of c)console.log(` + ${l}`);await Wn(n,Ot(n,i,!1).palettes.filter((l)=>c.includes(l.name)),u.terminals),cl(u.palettes.length)}function a1(t){let e=J(),n=lt(e),r=_(e),i=t.filter((a)=>r.palettes.includes(a)),s=t.filter((a)=>!r.palettes.includes(a));if(i.length===0)throw Error(`not installed: ${s.join(", ")} — \`ttheme list\` marks what is`);let o={...r,palettes:r.palettes.filter((a)=>!i.includes(a))};pn(e,n,r,o),wu(e,n,r.terminals,i);for(let a of i)console.log(` - ${a}`);if(cl(o.palettes.length),s.length>0)return console.error(`ttheme remove: not installed: ${s.join(", ")}`),1;return 0}function c1(t){let e=J(),n=lt(e),r=_(e);if(!r.palettes.includes(t))throw Error(`${t} is not installed — \`ttheme add ${t}\` first`);let{off:i,...s}=r,o=pn(e,n,r,{...s,startup:t},!0);console.log(d1(t,r.terminals,o).join(`
739
+ `))}function u1(){let t=J(),e=_(t),n=vi(e);if(!n)throw Error("no palettes installed — `ttheme browse` picks some");if(!e.off){console.log(`Already on · ${n}`);return}let{off:r,...i}=e,s=pn(t,lt(t),e,i);console.log(d1(n,i.terminals,s).join(`
740
+ `))}function l1(){let t=J(),e=_(t);if(e.off){console.log("Already off");return}let n=pn(t,lt(t),e,{...e,off:!0}),r=vi(e);console.log(`Off · new tabs open in the terminal's own colors${r?` — \`ttheme on\` wears ${r} again`:""}`);for(let i of pt(e.terminals))if(n.get(i.id)?.restart)console.log(`${i.name} new tabs open on your own profile once ${i.name} restarts`)}function d1(t,e,n){let r=pt(e).filter((s)=>!s.defaults),i=r.length>0?[`Default ${t} · ${r.map((s)=>s.name).join(", ")} open new tabs with it once their config reloads`]:[];for(let s of pt(e)){let o=s.defaults?.profile(t);if(o)i.push(n.get(s.id)?.restart?`${s.name} new tabs open with it once ${s.name} restarts — "${o}" is now its default profile`:`${s.name} new tabs open with it — "${o}" is its default profile`)}return i.length>0?i:[`Default ${t} · no terminal is wired to open with it — \`ttheme init\` wires one`]}function f1(t,e){let n=new Map(e.palettes.map((r)=>[r.name,"market"]));for(let r of pc(t,e.palettes,!1))n.set(r.name,"mine");return n}function h1(t,e=!1){let n=J(),r=lt(n),i=new Set(_(n).palettes),s=f1(n,r),o=Et(Ot(n,r).palettes);if(t)ui(o);let a=ci(t?Dw(o,t):o),c=(d)=>s.get(d)??"kept";if(e){let d=a.map((f)=>({name:f.name,group:f.group,...f.catalog?{catalog:f.catalog}:{},installed:i.has(f.name),source:c(f.name)}));console.log(JSON.stringify(d,null,2));return}let u=Math.max(...a.map((d)=>d.name.length),0),l={market:"",mine:" · yours",kept:" · in no market you added"};for(let d of a){let f=d.catalog?`${d.group} / ${d.catalog}`:d.group;console.log(` ${i.has(d.name)?"●":"○"} ${d.name.padEnd(u)} ${f}${l[c(d.name)]}`)}if(process.stdout.isTTY){let d=t?`${a.length} of ${o.length}`:`${o.length}`;console.log(`
741
+ ${d} palettes — ${a.filter((f)=>i.has(f.name)).length} installed`)}}async function m1(){let t=J(),e=ks(t);if(e.length===0)console.log("No markets to update — `ttheme market add official` brings the ttheme catalog back");let n=(f,h)=>`${st(f)}: ${h.message} — kept the copy from the last update`;for(let f of e.filter(ut))try{console.log(` ${Ik(t,f)}`)}catch(h){console.log(` ${n(f,h)}`)}let r=e.filter((f)=>!ut(f)),i=new Set(r),s=jr(),o=()=>s.set(`Updating ${[...i].map(st).join(", ")}${r.length>1?` · ${r.length-i.size}/${r.length}`:""}`);if(o(),await Promise.all(r.map(async(f)=>{let h;try{h=kh(await ea(t,f))}catch(p){h=n(f,p)}if(i.delete(f),i.size>0)o();else s.done();s.say(` ${h}`)})),s.done(),!CF(br(t)))return;let a=lt(t),c=_(t),u=f1(t,a),l=c.palettes.filter((f)=>!u.has(f)),d=new Map(Hn(t).map((f)=>[f.name,f.pictures]));Ct(t,a,c);for(let f of l)console.log(` ${f} left its market — ttheme keeps the copy you have`);await Wn(t,Ot(t,a,!1).palettes.filter((f)=>c.palettes.includes(f.name)&&d.has(f.name)).map((f)=>Ls(f,d.get(f.name))),c.terminals)}async function Tm(t,e,n,r=!1){let i=process.env.TTHEME_SORT==="series"?t.palettes:ci(t.palettes);ui(i);let s=process.stdout.isTTY===!0,o=zr(process.env,s,J()),a=o?await o.saved():new Map,c=new Lh({entries:i,scope:n,installed:e,required:r,color:!Ft(),fx:Hu(process.env.TTHEME_FX),onFocus:o?(l)=>process.stdout.write(o.paint(l)):void 0}),u=await c.prompt();if(o)process.stdout.write(o.restore(a));if(u==="cancel")return;return t.palettes.filter((l)=>c.picked.has(l.name)).map((l)=>l.name)}function Pm(t,e,n,r){let i;try{i=_s(t,n)}catch{i=$e(n)?gr(n):st(n)}let s=[];if(ut(n))try{s=yr(n,i,Gs(t,q),!1)}catch{s=[]}else s=Gs(t,n);return{source:n,id:i,shown:st(n),entries:s,auto:wr(n,e.updates),status:Nh(t,n,r)}}function ul(t){return t instanceof Error?t.message:String(t)}function GF(t,e,n,r){let i=new Map(r.map((o)=>[o.source,o.id])),s=[];for(let o of Bt(e.markets)){let a=i.get(o)??st(o),c=n[o],u=Xo(t,o);if(c&&(u===void 0||c.at>u))s.push({where:a,source:o,update:!0,message:`Update failed ${na(c.at)}: ${c.error}`});if(o===q)try{ln(p1(ve(t),"utf8"))}catch(l){s.push({where:a,source:o,message:`${st(ve(t))}: ${ul(l)}`})}else if($e(o))if(!jF(Ue(t,o)))s.push({where:a,source:o,message:"No copy of its index yet — `ttheme update` fetches it"});else try{vr(t,o)}catch(l){s.push({where:a,source:o,message:`${st(Ue(t,o))}: ${ul(l)}`})}else try{let l=ke(un(o)),d=new Map;for(let f of kr(o))try{let h=To(f,d);if(h)throw Error(h);d.set(f.slug,f),ye(`${l}/${f.slug}`,p1(f.path,"utf8"),Gs(t,q))}catch(h){s.push({where:st(f.path),message:ul(h)})}}catch(l){s.push({where:a,message:ul(l)})}}return s}function _F(t,e,n,r,i){return{refresh:async(s)=>{if(ut(s)){let a=Pm(t,e,s,Un());return{market:a,refreshed:{source:s,id:a.id,count:Et(a.entries).length,change:{added:[],changed:[],gone:[]}}}}let o=await ea(t,s,wh);return{market:Pm(t,e,s,Un()),refreshed:o}},fetch:async(s)=>{if(ut(s)){let a=ke(un(s));return{source:s,id:a,shown:st(s),entries:yr(s,a,Gs(t,q),!1),auto:!1,status:"read in place"}}let o=await ta(s,void 0,r);return n.set(s,o),{source:s,id:o.id,shown:st(s),entries:o.entries,auto:wr(s,{}),status:"not added yet"}},search:(s)=>Th(s,r),apply:i}}function BF(t,e,n){let r=[];for(let i of t.adds){let s=i.source!==q&&(t.auto[i.source]??i.auto);r.push(`Added ${i.id} · ${i.shown} — ${xt(Et(i.entries).length)}${s?", updating on its own":""}`)}for(let i of t.removes){let s=e.find((a)=>a.source===i)?.id??i;r.push(`Removed ${s} · ${st(i)}`);let o=n.filter((a)=>(ct(a)??q)===s);if(o.length>0)r.push(xh(o))}for(let[i,s]of Object.entries(t.auto)){let o=e.find((a)=>a.source===i);if(o&&!t.removes.includes(i))r.push(`${o.id} ${s?"updates on its own now":"no longer updates on its own"}`)}return r}async function WF(t,e,n,r,i){let s=_(t),o=r.adds.length+r.removes.length+Object.keys(r.auto).length>0;for(let b of r.adds){let y=i.get(b.source);if(y)js(t,y)}for(let b of r.removes)Ih(t,b);let a=[...Bt(s.markets).filter((b)=>!r.removes.includes(b)),...r.adds.map((b)=>b.source)],c=ia(s,a,{...s.updates,...r.auto});if(o)He(t,c);let u=lt(t,!1),l=Ot(t,u,!1).palettes.filter((b)=>r.picked.has(b.name)).map((b)=>b.name),d=s.palettes.filter((b)=>!l.includes(b)),f=l.filter((b)=>!s.palettes.includes(b));if(!o&&f.length===0&&d.length===0){await ra(t,s,e,r.refreshed),Bn("Nothing changed");return}let h={...c,palettes:l};pn(t,u,s,h),wu(t,u,s.terminals,d);for(let b of BF(r,n,l))Bn(b);for(let b of f)Bn(` + ${b}`);for(let b of d)Bn(` - ${b}`);let p=new Map(e.map((b)=>[b.name,b.pictures])),$=new Set(r.refreshed.flatMap((b)=>[...b.change.changed,...b.change.gone])),g=Ot(t,u,!1).palettes;if(await Wn(t,[...g.filter((b)=>f.includes(b.name)),...g.filter((b)=>l.includes(b.name)&&!f.includes(b.name)&&$.has(b.name)&&p.has(b.name)).map((b)=>Ls(b,p.get(b.name)))],h.terminals),f.length>0||d.length>0)cl(h.palettes.length)}async function g1(){let t=Vw(process.env),e=J(),n=_(e),r=Hn(e),i=Un(),s=Bt(n.markets).map((b)=>Pm(e,n,b,i)),o=new Set(s.flatMap((b)=>b.entries.map((y)=>y.name))),a=r.filter((b)=>n.palettes.includes(b.name)&&!o.has(b.name));ui([...s.flatMap((b)=>b.entries),...a]);let c=new Map,u=new AbortController,l=process.stdout.isTTY===!0,d=zr(process.env,l,e),f=d&&!t?await d.saved():new Map,h=Me(n);if(t)process.stdout.write("\x1B[?2026h");let p=new _h({markets:s,kept:a,installed:n.palettes,...h?{startup:h}:{},...t?{hub:t}:{},problems:GF(e,n,i,s),due:$h(e,n),io:_F(e,n,c,u.signal,(b,y)=>Q$({say:y.say,set:y.status},()=>WF(e,r,s,b,c))),...process.env.TTHEME_SORT==="series"?{}:{order:ci},color:!Ft(),lookups:process.env.TTHEME_MARKET_LOOKUP!=="off",fx:Hu(process.env.TTHEME_FX),owns:l&&!t,...d?{onFocus:(b)=>process.stdout.write(d.paint(b))}:{}});try{await p.run()}finally{if(d?.stop?.(),d&&!t)process.stdout.write(d.restore(f));u.abort()}await p.idle();let $=p.result(),g=p.next();if(t&&g!==void 0)return await ra(e,_(e),r,$.refreshed),g;if(l&&t)process.stdout.write("\x1B[?1049l\x1B[?25h");for(let b of $.refreshed){let y=yh(b);if(y)console.log(y)}if(p.applied()){for(let y of p.lines())console.log(y);let b=p.failure();if(b)throw b}else await ra(e,_(e),r,$.refreshed),console.log("Nothing changed");return t?Oc:0}import{rmSync as b1}from"node:fs";import{basename as UF,join as xa}from"node:path";var w1=xa(import.meta.dirname,".."),KF=xa(w1,"themes"),Hm=xa(w1,"dist"),ll=Dt.map((t)=>mn[t].emitter),zF=[Hf,Gf],u9=ll.map((t)=>t.id);async function dl({only:t}={}){if(typeof Bun>"u")throw Error("needs bun — run it from a checkout: bun src/bin.ts build");let e=t&&t.length>0?ll.filter((s)=>t.includes(s.id)):ll,n=Ab(KF),r=xp(n);if(r.length>0){for(let s of r)console.error(` ✗ ${s.theme} [${s.rule}] ${s.detail}`);throw Error(`${r.length} contrast violation(s). Fix the palette, or waive the rule in its [contrast] section with a reason.`)}if(e.length===ll.length)b1(Hm,{recursive:!0,force:!0});else for(let s of e)b1(xa(Hm,s.id),{recursive:!0,force:!0});let i=0;for(let s of[...e,...zF]){let o=n.flatMap((u)=>s.emit?.(u)??[]),a=s.emitShared?.(n)??[];for(let u of[...o,...a])await Bun.write(xa(Hm,u.path),u.content),i++;let c=o.length>0?`${n.length} themes${s.limits?` (${s.limits})`:""}`:a.length>0?a.map((u)=>UF(u.path)).join(" "):`no files (${s.limits??"nothing to write"})`;console.log(` ${s.id.padEnd(16)} ${c}`)}console.log(`
742
+ ${n.length} themes (${Fb(n).length} in the new-tab rotation) -> ${i} files in dist/`)}import{existsSync as YF,readFileSync as S1}from"node:fs";import{availableParallelism as DF,homedir as $1}from"node:os";var qF=4;async function fl(t,e,n=$1()){let r=vt(D(t)),i=Pr(t),s=new Map(ie(t).palettes.map((d)=>[d.name,mr(d)])),o=Object.entries(r.palettes).flatMap(([d,f])=>{let h=s.get(d);return h?f.pictures.filter((p)=>ds(p)||(p.blur??0)!==i).map((p)=>({name:d,key:p.key,paint:h})):[]});if(o.length===0)return 0;e(`Drawing ${o.length} background picture${o.length===1?"":"s"} again${i?` · blur ${i}px`:""}`);let a=Si(_(t).terminals),c=new pm(Math.min(qF,DF()-1)),u=await c.map(o.map(({name:d,key:f,paint:h})=>({job:"redraw",home:t,user:n,name:d,key:f,paint:h,blur:i,aligns:a})));c.close();let l=[];return u.forEach((d,f)=>{let{name:h,key:p}=o[f];if(d instanceof Error||d===null){e(` ▢ ${h} ${p} — ${d instanceof Error?d.message:"no original to draw it from"}, left as it was`);return}l.push({name:h,picture:d})}),Hd(t,l),Oe(t,n),l.length}async function k1(t,e,n,r,i=$1()){let s=vt(D(t)).palettes[e],o=s?.pictures.find((l)=>l.key===(r??s.active));if(!s||!o)throw Error(`${e} has no picture ${r??"shown"}`);if(be(o)===n)return{key:o.key,changed:!1};let a=ie(t).palettes.find((l)=>l.name===e);if(!a)throw Error(`no palette called ${e}`);let c=Si(_(t).terminals),u=await Eu(t,e,o.key,mr(a),Pr(t),c,i,n);if(!u)throw Error(`${e} ${o.key} has no original to draw it from`);return Hd(t,[{name:e,picture:u}]),Oe(t,i),{key:o.key,changed:!0}}function y1(t,e,n){let r=vt(D(t)).palettes[e],i=r?.pictures.find((a)=>a.key===(n??r.active));if(!r||!i)throw Error(`${e} has no picture ${n??"shown"}`);let s=ie(t).palettes.find((a)=>a.name===e);if(!s)throw Error(`no palette called ${e}`);let o=be(i)==="original"?"tone":"original";if(!ik(t,e,i.key,mr(s),Pr(t),o))throw Error(`${e} ${i.key} has no original to draw it from`);return{key:i.key,coloring:o}}async function v1(){return await fl(J(),(t)=>process.stderr.write(`${t}
743
+ `)),0}async function E1(t,e,n){let r=J();if(An(ie(r).palettes,t),e==="show"){if(!n)throw Error("image show needs the picture to show");let{at:i,of:s}=hs(r,t,n);return Oe(r),process.stderr.write(`Background · ${t} ${i}/${s} ${n}
744
+ `),0}if(e==="drop"){let{key:i,left:s}=sc(r,t,n);return Oe(r),process.stderr.write(`Background · ${t} removed ${i} · ${s} left
745
+ `),0}if(e==="tone"||e==="original"){let i=await k1(r,t,e,n);return process.stderr.write(`Background · ${t} ${i.key} ${e==="tone"?"tinted":"in its own colors"}
746
+ `),0}if(e==="prepare"){let{key:i,coloring:s}=y1(r,t,n);return process.stderr.write(`Background · ${t} ${i} ready in ${s==="tone"?"its tone":"its own colors"}
747
+ `),0}if(e==="tuned")return Oe(r),0;throw Error(`unknown image action ${e} — show, drop, tone, original, prepare or tuned`)}function M1(t,e){let n=/^(\d+)x(\d+)$/.exec(t),r=/^(\d+)x(\d+)([+-]\d+)([+-]\d+)$/.exec(e);if(!n||!r)throw Error("a canvas is <width>x<height> and a place <width>x<height>+<x>+<y>");let[i,s]=n.slice(1).map(Number),[o,a,c,u]=r.slice(1).map(Number);return{width:i,height:s,at:{x:c,y:u,w:o,h:a}}}function JF(t,e,n){let r=M1(e,n),i=Math.min(1,t.width/r.at.w);if(i===1)return r;return{width:Math.max(1,Math.round(r.width*i)),height:Math.max(1,Math.round(r.height*i)),at:{x:Math.round(r.at.x*i),y:Math.round(r.at.y*i),w:t.width,h:t.height}}}function O1(t,e,n,r){let i=At(new Uint8Array(S1(t)));return H(e,rn(Ag(i,M1(n,r)))),0}function I1(t,e,n,r,i,s,o){let a=Number(r);if(!ne(n)||!Number.isFinite(a))throw Error("flatten needs a #rrggbb background and an opacity from 0 to 1");let c=At(new Uint8Array(S1(t))),u=i?JF(c,i,s??""):void 0,l=ir(rr(c,n,Math.max(0,Math.min(1,a)),u));if(o&&YF(o))Xr(o,e,l);else H(e,l);return 0}import{execFileSync as VF}from"node:child_process";import{readFileSync as ZF}from"node:fs";import{arch as QF,platform as hl,release as Am}from"node:os";var XF={ghostty:"ghostty",iterm2:"iTerm.app",wezterm:"WezTerm","terminal-app":"Apple_Terminal",warp:"WarpTerminal"};function tC(t,e){if(t==="konsole"){let r=/^(\d{2})(\d{2})(\d{2})$/.exec(e.KONSOLE_VERSION??"");return r?`${r[1]}.${r[2]}.${Number(r[3])}`:e.KONSOLE_VERSION}let n=XF[t];return n!==void 0&&e.TERM_PROGRAM===n?e.TERM_PROGRAM_VERSION:void 0}function eC(t){let e=Ut(t),n=t.TERM_PROGRAM&&t.TERM_PROGRAM!=="tmux"?t.TERM_PROGRAM:void 0,r=e==="unknown"?`unknown${n?` (TERM_PROGRAM=${n})`:""}`:e==="editor"?`editor (${Mf(t)})`:`${e} ${tC(e,t)??"(version unknown)"}`,i=t.TERM_PROGRAM==="tmux"?t.TERM_PROGRAM_VERSION:void 0;return[r,t.TMUX?`tmux ${i??"yes"}`:"tmux no",t.SSH_CONNECTION||t.SSH_TTY?"ssh yes":"ssh no"].join(" · ")}function x1(t,e){try{return VF(t,e,{encoding:"utf8",timeout:2000,stdio:["ignore","pipe","ignore"]}).trim()}catch{return}}function nC(){let t=QF();if(hl()==="darwin")return`macOS ${x1("sw_vers",["-productVersion"])??`(Darwin ${Am()})`} · ${t}`;if(hl()==="linux"){let e="";try{e=ZF("/etc/os-release","utf8")}catch{}return`${/^PRETTY_NAME="?([^"\n]*)"?$/m.exec(e)?.[1]??"Linux"} · linux ${Am()} · ${t}`}return`${hl()==="win32"?"Windows":hl()} ${Am()} · ${t}`}function rC(t){if(t.TTHEME_ZSH)return`zsh ${t.TTHEME_ZSH}`;return(t.SHELL?x1(t.SHELL,["--version"])?.split(`
748
+ `)[0]:void 0)??t.SHELL??"unknown"}function iC(t){try{let{terminals:e}=_(t);return e.length>0?e.join(", "):"none"}catch{return"installed.json missing or unreadable"}}function sC(t){let e=Dc.flatMap((n)=>{let r=t[n];return r===void 0||r===Uo(n)?[]:[`${n}=${/\s/.test(r)?JSON.stringify(r):r}`]});return e.length>0?e.join(" "):void 0}function N1(){let t=process.env,n=[["ttheme",Tt.version],["OS",nC()],["Shell",rC(t)],["Terminal",eC(t)],["Wired",iC(J())],["Settings",sC(t)]].filter((i)=>i[1]!==void 0),r=Math.max(...n.map(([i])=>i.length));for(let[i,s]of n)console.log(`${i.padEnd(r)} ${s}`)}import{execFileSync as oC,spawnSync as aC}from"node:child_process";import{chmodSync as cC,copyFileSync as uC,existsSync as _i,mkdirSync as R1,readdirSync as lC,readFileSync as pl,rmSync as Fm}from"node:fs";import{homedir as dC}from"node:os";import{dirname as eo,join as mt}from"node:path";function fC(t,e,n){for(let r of lC(e))t.push({from:mt(e,r),to:mt(n,r)})}function Gm(t){return JSON.parse(pl(mt(t,"dist","manifest.json"),"utf8"))}function ml(t,e){let n=mt(e.configHome,"ttheme"),r=[{from:mt(e.root,"bin","ttheme.js"),to:mt(n,"ttheme.js")},{from:mt(e.root,"bin","ttheme.js.map"),to:mt(n,"ttheme.js.map")},{from:mt(e.root,"shell","ttheme.zsh"),to:mt(n,"ttheme.zsh")},{from:mt(e.root,"shell","preview.zsh"),to:mt(n,"preview.zsh")},{from:mt(e.root,"shell","launch-tab.zsh"),to:mt(n,"launch-tab.zsh"),executable:!0}];fC(r,mt(e.root,"shell","adapters"),mt(n,"adapters"));let i=[{file:mt(e.zdotdir,".zshrc"),block:A0(n)}],s=mt(n,"config.zsh"),o=C0(_i(s)?pl(s,"utf8"):""),a={file:s,content:t.warpFast===void 0?o:Jc(o,"TTHEME_WARP_FAST",t.warpFast?"on":"off")},c={terminals:t.terminals,palettes:t.palettes,...Object.fromEntries(pt(t.terminals).flatMap((d)=>Object.entries(d.installs?.(e)??{}).filter(([,f])=>f!==void 0))),...t.off?{off:!0}:{}},u=gu(e.configHome,c,e.home),l=e.stateDir?[mt(e.stateDir,"ghostty",".blind")]:[];return{home:e.home,copies:r,edits:i,settings:a,forget:l,catalog:Gm(e.root),installed:c,notes:u}}function P1(t){try{return _(t)}catch{return}}function H1(t){try{return Ot(t,lt(t),!1).palettes}catch{return[]}}function hC(t,e){let n=Gm(e.root),r=Bt(t.markets).includes(q)?n.palettes:[],i=new Set(r.map((o)=>o.name)),s=H1(e.configHome).filter((o)=>!i.has(o.name)&&(ct(o.name)!==void 0||t.palettes.includes(o.name)));return{...n,palettes:[...r,...s]}}function A1(t,e){let n=vi(t);return n&&e.includes(n)?n:void 0}function mC(t,e,n){let r=ml(e,n),i=A1(t,e.palettes),s=new Set(["terminals","palettes","off","startup",...Dt.flatMap((a)=>Object.keys(mn[a].installs?.(n)??{}))]),o=Object.fromEntries(Object.entries(t).filter(([a])=>!s.has(a)));return{...r,installed:{...o,...r.installed,...i?{startup:i}:{}}}}function pC(t,e){let n=ml({terminals:t.terminals,palettes:t.palettes,off:t.off},e),r=new Set([...n.catalog.palettes,...H1(e.configHome)].map((l)=>l.name)),i=t.palettes.filter((l)=>r.has(l)),s=t.palettes.filter((l)=>!r.has(l)),{startup:o,...a}=t,c={...a,palettes:i,...o&&i.includes(o)?{startup:o}:{}},u=s.length>0?[`Dropped ${s.join(", ")} — no longer in the catalog`,...n.notes]:n.notes;return{...n,installed:c,notes:u}}function gC(t){try{return oC(process.execPath,[mt(t,"ttheme","ttheme.js"),"--version"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()||void 0}catch{return}}function F1(t){let e=Me(t);return[pt(t.terminals).map((n)=>n.name).join(", "),`${t.palettes.length} palettes`,e?`default ${e}`:"no default — ttheme is off"].join(" · ")}function Cm(t,e=ze()){for(let o of t.copies)if(R1(eo(o.to),{recursive:!0}),Fm(o.to,{force:!0}),Fm(`${o.to}.zwc`,{force:!0}),uC(o.from,o.to),o.executable)cC(o.to,493);H(t.settings.file,t.settings.content);for(let o of t.forget)Fm(o,{force:!0});let n=eo(eo(t.settings.file)),r=P1(n),i=Object.fromEntries(pt(t.installed.terminals).flatMap((o)=>{let a=o.defaults?.key,c=a?r?.[a]:void 0;return a&&c?[[a,c]]:[]})),s=Zo(n,{...t.installed,...i},e,t.home);if(Bt(s.markets).includes(q))$c(n,t.catalog);He(n,s),Ct(n,lt(n),s,t.home,e);for(let o of t.edits){R1(eo(o.file),{recursive:!0});let a=_i(o.file)?pl(o.file,"utf8"):"";tn(o.file,Nr(a,o.block))}return Ei(n,s,!0,e,t.home)}function Na(t){if(oe(t))throw Or("Nothing changed"),new Ie;return t}function Lm(t,e){return Dt.filter((n)=>mn[n].offered(t,e))}async function bC(t,e,n,r){return Na(await S0({message:"Wire which terminals?",options:Lm(n,r).map((i)=>({value:i,label:mn[i].name,hint:i===t?"detected":void 0})),initialValues:e,required:!0}))}async function wC(t){return Na(await Ke({message:"Switch Warp to each tab's palette in about 0.2 s instead of 0.6 s?\nAbout 8% CPU while Warp is in front with tabs of different palettes — `ttheme config` changes it",initialValue:qc(t,"TTHEME_WARP_FAST")!=="off"}))}function jm(t){let e=[...t.copies.filter((n)=>!_i(n.to)).map((n)=>n.to),..._i(t.settings.file)?[]:[t.settings.file],...t.edits.filter((n)=>!pl(n.file,"utf8").includes("# ttheme begin")).map((n)=>n.file)];if(e.length>0)throw Error(`init left gaps:
749
+ ${e.join(`
750
+ `)}`)}function C1(t,e){return[...new Set(t.palettes.filter((n)=>e.includes(n.name)).map((n)=>n.group))]}function $C(t,e,n){let r=t.palettes.find((o)=>o.name===Me(e)),i=process.stdout.isTTY===!0,s=r&&zr(process.env,i,n)?.wear(r,e.terminals);if(s===void 0)return!1;return process.stdout.write(s),!0}function kC(t,e){let n=Me(t);if(!n)return["Default none — new tabs keep the terminal colors",`Turn on \`ttheme on\` wears ${vi(t)}`];return[`Default ${n}${e?" — this tab wears it already":""}`,"Change it `ttheme preview`, enter on a palette, then default"]}function yC(t){aC("zsh",["-c",'source "$1" && __tt_preview init',"zsh",mt(t,"ttheme","ttheme.zsh")],{stdio:"inherit"})}function vC(t,e,n,r){let i=C1(t.catalog,e.palettes);fn([`${i.join(", ")} (${e.palettes.length})`,...kC(t.installed,n)].join(`
751
+ `),`Installed ${e.palettes.length} palettes`),fn(["exec zsh The ttheme command in this tab",..._m(t,r)].join(`
752
+ `),"Next"),Lo("Done")}function _m(t,e){return[...bu(eo(eo(t.settings.file)),t.installed,e,t.home),...t.notes]}function L1(t){return t?(e)=>Mr.step(e):(e)=>console.log(e)}async function T1(t,e,n,r){let i=pC(t,e),s=Cm(i,n);jm(i),await fl(e.configHome,L1(r),e.home);let o=["exec zsh Open tabs run the new layer — new tabs already do",..._m(i,s)],a=`Updated to ${Tt.version} — kept ${F1(i.installed)}`;if(!r){console.log([a,...o].join(`
753
+ `));return}fn(o.join(`
754
+ `),a),Lo("Done")}function SC(t,e){let n=[`Placed ${t.copies.length} files`,`Settings in ${t.settings.file} — edit later with \`ttheme config\``,...t.edits.map((r)=>`Wired ${r.file}`),..._m(t,e),"No palettes yet — open a new shell (`exec zsh`), then `ttheme browse` picks them from the catalog"];console.log(n.join(`
755
+ `))}async function j1(t={}){let e=mt(import.meta.dirname,"..");if(!_i(mt(e,"bin","ttheme.js")))throw Error("bin/ttheme.js is missing — run `mise run bin:build` first");if(!_i(mt(e,"dist"))){if(typeof Bun>"u")throw Error("this package is missing dist/ — reinstall @kecan0406/ttheme");await dl()}let n=dC(),r=J(),i=process.env.ZDOTDIR??n,s=ze(),o=G$(s),a=process.env.WT_PROFILE_ID,c={root:e,home:n,configHome:r,zdotdir:i,stateDir:mt(process.env.XDG_STATE_HOME??mt(n,".local","state"),"ttheme"),...o?{wtHome:o}:{},...a?{wtProfile:a}:{}},u=Ut(process.env),l=Lm(c,s).filter((R)=>R===u||mn[R].present(c));if(!t.yes&&(process.stdin.isTTY!==!0||process.stdout.isTTY!==!0))throw Error("init asks before it edits your configs — run it in a terminal, or pass --yes to accept the defaults");let d=P1(r);if(t.yes&&d){await T1(d,c,s,!1);return}if(t.yes){if(l.length===0)throw Error(`no supported terminal detected — run this inside ${pt(Lm(c,s)).map((B)=>B.name.toLowerCase()).join(", ").replace(/, ([^,]*)$/," or $1")}`);let F=ml({terminals:l,palettes:[]},c),j=Cm(F,s);jm(F),SC(F,j);return}if(Lc("ttheme init"),d){let R=gC(r);if(Na(await Ke({message:`ttheme${R?` ${R}`:""} is installed — ${F1(d)}
756
+ ${R===Tt.version?"Reinstall":"Update to"} ${Tt.version} and keep all of it?`,active:"Yes",inactive:"No, set it up again",initialValue:!0}))){await T1(d,c,s,!0);return}}let f=await bC(u,d?.terminals??l,c,s),h=f.includes("warp")?await wC(r):void 0,p=d?hC(d,c):Gm(e),$=d?await Tm(p,d.palettes,"palette",!0):await Tm(p,[],"series",!0);if(!$)throw Or("Nothing changed"),new Ie;let g=(d&&A1(d,$))??$[0],b=$.length>1&&(ae[u].paints||u==="warp"&&f.includes("warp")&&_i(Cr(n,r))),y=Na(await Ke({message:b?"Pick a default palette in ttheme preview once installed?":`Wear ${g} in every tab?`,initialValue:d?!d.off:!0})),S={terminals:f,palettes:$,off:!y,warpFast:h},E=d?mC(d,S,c):ml(S,c);if(fn([`Install ${$.length} palettes — ${C1(p,$).join(", ")}`,`Copy ${E.copies.length} files under ${r}`,`Write ${E.settings.file}`,...E.edits.map((R)=>`Edit ${R.file} — a ttheme block: source ttheme.zsh`),...pu(r,E.installed,n),"Each config is backed up once to <file>.ttheme.bak before the first edit — `npx @kecan0406/ttheme uninstall` takes it all out",y?b?`Open ttheme preview — every tab wears the palette picked there, ${g} until then`:`Paint every tab with ${g}, this one now`:"Leave the terminal colors as they are — `ttheme on` wears a palette later",...y&&g?pt(f).flatMap((R)=>R.defaults?[`Make "${R.defaults.profile(g)}" the ${R.name} default profile`]:[]):[]].join(`
757
+ `),`Wiring ${pt(f).map((R)=>R.name).join(", ")}`),!Na(await Ke({message:"Apply these changes?"})))throw Or("Nothing changed"),new Ie;let I=Cm(E,s);if(jm(E),await fl(r,L1(!0),n),y&&b)yC(r);let N=_(r);vC({...E,catalog:p,installed:N},S,$C(p,N,r),I)}import{spawn as EC}from"node:child_process";import{createHash as MC}from"node:crypto";import{existsSync as Bm,mkdirSync as OC,readFileSync as IC,statSync as xC,utimesSync as NC,writeFileSync as RC}from"node:fs";import{homedir as W1}from"node:os";import{join as U1}from"node:path";import{gunzipSync as TC}from"node:zlib";var G1="https://github.com/kecan0406/aninames/releases/latest/download",K1=86400000,PC=3600000,HC=120000;function z1(t){return U1(pr(t),".checked")}function AC(t=process.env){return t.TTHEME_NAMES!=="off"}function FC(t){try{return Date.now()-xC(z1(t)).mtimeMs>=K1}catch{return!0}}function Wm(t,e){let n=z1(t);if(OC(pr(t),{recursive:!0}),!Bm(n))RC(n,"");NC(n,e/1000,e/1000)}function D1(t=W1()){if(!AC()||!FC(t))return;try{Wm(t,Date.now()),EC(process.execPath,[process.argv[1],"names"],{detached:!0,stdio:"ignore",env:process.env}).unref()}catch{}}function _1(t){return MC("sha256").update(t).digest("hex")}async function B1(t){let e=await fetch(t,{signal:AbortSignal.timeout(HC)});if(!e.ok)throw Error(`${t} answered ${e.status}`);return new Uint8Array(await e.arrayBuffer())}async function q1(t=W1()){let e=pr(t);try{let r=JSON.parse(new TextDecoder().decode(await B1(`${G1}/ttheme.json`)));for(let[i,{file:s,sha256:o}]of Object.entries(r.layers)){let a=U1(e,`ttheme-${i}.json`);if(Bm(a)&&_1(IC(a))===o)continue;let c=TC(await B1(`${G1}/${s}`));if(_1(c)!==o)throw Error(`${s} does not match its hash`);H(a,c)}Wm(t,Date.now())}catch{return Wm(t,Date.now()-K1+PC),1}fc(t);let n=J();if(Bm(ve(n)))ui(ie(n).palettes,t),z$(n,t);return 0}import{createInterface as CC}from"node:readline";var LC="\x1F",Um="\x1E",jC=new Set(["up","down","left","right","home","end","pgup","pgdn","tab","shift-tab","shift-left","shift-right","enter","esc","backspace","ctrl-c"]);function GC([t="",e="",n="",r=""]){if(t!=="press"&&t!=="drag"&&t!=="release"&&t!=="wheel"||!/^\d+$/.test(e)||!/^\d+$/.test(n)||!/^-?\d+$/.test(r))return;return{kind:"mouse",action:t,button:t==="wheel"?void 0:"left",wheel:t==="wheel"?Number(r)<0?-1:1:0,sideways:!1,row:Number(e),col:Number(n),shift:!1,alt:!1,ctrl:!1,count:t==="press"||t==="release"?Number(r):0}}function Y1(t){return{background:t.background,foreground:t.foreground,cursor:t.cursor,selection:t.selection,ansi:t.ansi}}class J1{editor;base;cols=km;rows=ym;focused=!0;home;name;color;shown="";tints=new ya;pointer=new Fo;drawn={key:"",recolors:!1,look:""};constructor(t,e,n){this.home=t,this.name=e,this.color=n,this.base=An(fi(t,lt(t),!1).palettes,e);let r=vs(this.base,Pn(t)[e]);this.editor=new $a({title:"Tone",name:e,colors:Y1(r),original:Y1(this.base),variant:"theme",signature:r.signatureSlots,...r.waived?{waive:r.waived}:{},check:()=>{return}})}save(){try{let t=Jd(this.base,this.editor.list);Gw(this.home,_w(Pn(this.home),this.name,t)),Ct(this.home,lt(this.home),_(this.home)),this.editor.markSaved();return}catch(t){return t instanceof Error?t.message:String(t)}}close(){this.tints.clear()}pictures(){try{return vt(D(this.home)).palettes[this.name]?.pictures??[]}catch{return[]}}draft(){let t=this.editor.dirty(),e=`${t}
758
+ ${this.shown}
759
+ ${this.editor.list.join(" ")}`;if(e!==this.drawn.key){let n=this.pictures(),r=mr(vs(this.base,Jd(this.base,this.editor.list))),i=this.shown?Qu(n,this.shown):void 0,s={name:this.name,...this.editor.colors(),waived:this.editor.waive},o=i?Zu(i,this.shown,s,this.editor.signature,this.tints):void 0;this.drawn={key:e,recolors:t&&n.some((a)=>rc(a,r)),look:o?`${o.image}${Um}${o.opacity}`:""}}return this.drawn}frame(t="ok",e){let n=$v(this.editor),r=this.editor.act??"-";this.editor.act=void 0;let{drawn:i,targets:s}=Ec(()=>kv(this.editor,this.cols,this.rows,this.color,this.focused)),{lines:o,zones:a}=Mc(i.lines,s);this.pointer.zones=a;let{recolors:c,look:u}=this.draft();return[t,r,n.mode,this.editor.dirty()?"1":"0",this.editor.shown().join(" "),n.keys.map(([l])=>l).join(Um),n.keys.map(([,l])=>l).join(Um),e??n.note,String(i.at),c?"1":"0",u,...o].join(LC)}handle(t){let[e="",...n]=t.split(" "),r=n.join(" ");if(e==="quit")return;if(e==="size"){let[i,s]=r.split(" ").map(Number);this.cols=Math.max(30,i??km),this.rows=Math.max(10,s??ym)}else if(e==="focus")this.focused=r==="1";else if(e==="show")this.shown=r;else if(e==="key"&&jC.has(r))this.editor.press(r);else if(e==="ch"){let i=Number(r),s=Number.isInteger(i)&&i>0&&i<=1114111?Ph(String.fromCodePoint(i)):void 0;if(s)this.editor.press(s)}else if(e==="mouse"){let i=GC(n);if(i)vm(this.editor,this.pointer.point(i),i)}else if(e==="save"){let i=this.save();return i===void 0?this.frame("saved","Saved"):this.frame("error",i)}return this.frame()}}async function V1(t){let e=new J1(J(),t,process.env.NO_COLOR===void 0);process.once("exit",()=>e.close()),process.once("SIGTERM",()=>process.exit(0));let n=CC({input:process.stdin});for await(let r of n){let i=e.handle(r);if(i===void 0)break;process.stdout.write(`${i}
760
+ `)}return n.close(),process.stdin.destroy(),e.close(),0}import{existsSync as Z1,rmSync as _C,utimesSync as BC}from"node:fs";import{homedir as WC}from"node:os";import{join as Ra}from"node:path";function UC(t){try{return _(t)}catch{return}}function KC(t){let{home:e,configHome:n}=t,r=UC(n),i={configHome:n,home:e},s=pt(Dt),o=s.map((c)=>c.unwire(i,r)),a=[Ra(n,"ttheme"),t.cacheDir,t.stateDir];return{edits:[...hn(Ra(t.zdotdir,".zshrc"),Rr),...o.flatMap((c)=>c.edits)],removals:[...s.flatMap((c)=>c.shelf?Is(c.shelf.dir(i)):[]),...o.flatMap((c)=>c.removals),...a.filter((c)=>Z1(c))],touches:o.flatMap((c)=>c.touches),...r?{state:r}:{}}}function zC(t,e,n=ze()){let r=[];for(let{file:s,content:o}of t.edits){let a=Hp(s,o);r.push(a==="removed"?`Removed ${s} — ttheme had created it`:a==="restored"?`Took ttheme out of ${s}`:`Took ttheme out of ${s} — kept ${s}.ttheme.bak, since the file changed after ttheme's first edit`)}if(t.state){let s=Ei(e.configHome,{...t.state,off:!0,palettes:[]},!1,n,e.home);for(let o of pt(t.state.terminals))if(s.has(o.id))r.push(`Gave ${o.name} its own default profile back — it takes it at its next start`)}for(let s of t.removals)_C(s,{recursive:!0,force:!0});if(t.removals.length>0)r.push(`Deleted ${t.removals.length} files and folders ttheme wrote`);let i=new Date;for(let s of t.touches)BC(s,i,i);return r}function DC(){let t=WC();return{home:t,configHome:J(),zdotdir:process.env.ZDOTDIR??t,cacheDir:ur(),stateDir:Ra(process.env.XDG_STATE_HOME??Ra(t,".local","state"),"ttheme")}}async function Q1(t=!1){let e=DC(),n=KC(e);if(n.edits.length===0&&n.removals.length===0){console.log("Nothing of ttheme is installed");return}if(!t){if(process.stdin.isTTY!==!0||process.stdout.isTTY!==!0)throw Error("uninstall asks before it deletes anything — run it in a terminal, or pass --yes");let r=Ra(e.configHome,"ttheme");Lc("ttheme uninstall"),fn([...n.edits.map((s)=>`Take ttheme out of ${s.file}`),...n.removals.map((s)=>s===r?`Delete ${s} — settings, pins, every installed picture${Z1(hc(e.configHome))?`, and your markets under ${hc(e.configHome)} (push them to GitHub first to keep them)`:""}`:`Delete ${s}`)].join(`
761
+ `),"Uninstall");let i=await Ke({message:"Remove ttheme?"});if(oe(i)||!i)throw Or("Nothing changed"),new Ie}for(let r of zC(n,e))console.log(r);console.log("Open tabs keep their colors until they close — restart your terminal to drop ttheme everywhere")}import{homedir as qC}from"node:os";async function X1(t){if(!Dt.includes(t))throw Error(`no terminal ${t} — one of ${Dt.join(", ")}`);let e=t,n=mn[e],r=J(),i=qC(),s=ze(),o=_(r);if(o.terminals.includes(e))return console.log(`${n.name} is wired already`),0;let a={configHome:r,home:i};if(!n.offered(a,s))throw Error(`${n.name} cannot be wired on this system`);if(process.stdin.isTTY!==!0||process.stdout.isTTY!==!0)throw Error("wire asks before it edits your configs — run it in a terminal");let c={...o,...n.installs?.(a)??{},terminals:[e]};fn([...pu(r,c,i),...gu(r,c,i),"Each config is backed up once to <file>.ttheme.bak before the first edit — `npx @kecan0406/ttheme uninstall` takes it all out"].join(`
762
+ `),`Wiring ${n.name}`);let u=await Ke({message:`Wire ${n.name} now?`,initialValue:!1});if(oe(u)||!u)throw Or("Nothing changed"),new Ie;let l=Zo(r,c,s,i),d={...l,terminals:[...o.terminals,e]};He(r,d),Ct(r,lt(r),d,i,s);let f=Ei(r,l,!0,s,i),h=bu(r,l,f,i);if(h.length>0)fn(h.join(`
763
+ `),"Next");return Lo(`Wired ${n.name}`),0}var JC=new Set(["add","remove","market","default","on","off"]),VC={default:([t])=>c1(t),on:()=>u1(),off:()=>l1(),browse:()=>g1(),list:([t],{json:e})=>h1(t,e),add:(t,{market:e})=>o1(t,e),remove:(t)=>a1(t),update:()=>m1(),market:([t,e])=>Ok(t,e),new:([t],{from:e,in:n})=>e1(t,e,n),edit:([t])=>n1(t),check:([t],{fix:e})=>i1(t,e),share:([t],{tone:e})=>s1(t,e),init:(t,{yes:e})=>j1({yes:e}),uninstall:(t,{yes:e})=>Q1(e),wire:([t])=>X1(t),info:()=>N1(),build:(t,{only:e})=>dl({only:e}),find:([t])=>Gv(t),image:([t,e,n])=>E1(t,e,n),redraw:()=>v1(),names:()=>q1(),tone:([t])=>V1(t),flatten:([t,e,n,r,i,s,o])=>I1(t,e,n,r,i,s,o),bake:([t,e,n,r])=>O1(t,e,n,r)},ZC=Bo.map((t)=>({...t,run:VC[t.name]}));class Bi extends Error{verb;constructor(t,e){super(t);this.verb=e}}function tS(t){let e=ZC.find((n)=>n.name===t);if(!e)throw new Bi(t.startsWith("-")?`unknown option '${t}'`:`unknown command '${t}'`);return e}function QC(t,e){let n={help:{type:"boolean",short:"h"}};for(let[r,{type:i,short:s,multiple:o}]of Object.entries(t.flags??{}))n[r]={type:i,multiple:o===!0,...s?{short:s}:{}};try{return YC({args:e,options:n,allowPositionals:!0})}catch(r){let[i=""]=(r instanceof Error?r.message:String(r)).split(". ");throw new Bi(`${i.charAt(0).toLowerCase()}${i.slice(1)}`,t)}}function XC(t){let[e,...n]=t;if(e===void 0)return{kind:"help",code:1};if(e==="-h"||e==="--help")return{kind:"help",code:0};if(e==="-V"||e==="--version")return{kind:"version"};if(e==="help"){if(n[0]===void 0||n[0]==="all")return{kind:"help",all:n[0]==="all",code:0};return{kind:"help",verb:tS(n[0]),code:0}}let r=tS(e),i=QC(r,n);if(i.values.help)return{kind:"help",verb:r,code:0};for(let[l,{choices:d}]of Object.entries(r.flags??{}))for(let f of[i.values[l]??[]].flat())if(d&&!d.includes(String(f)))throw new Bi(`--${l} takes ${d.join(", ")} — not ${f}`,r);let s=i.positionals,o=r.args.filter((l)=>l.startsWith("<")).length,a=r.args.some((l)=>l.includes("..."))?Number.POSITIVE_INFINITY:r.args.length;if(s.length<o)throw new Bi(`missing ${r.args[s.length]}`,r);if(s.length>a)throw new Bi(`too many arguments: ${s.slice(a).join(" ")}`,r);let{help:c,...u}=i.values;return{kind:"run",verb:r,args:s,flags:u}}function eS(t){let e=Math.max(0,...t.map(([n])=>n.length));return t.map(([n,r])=>` ${n.padEnd(e)} ${r}`)}function Km(t,e=!1){if(!t)return Wo(e);let n=Object.entries(t.flags??{}).map(([r,{short:i,value:s,about:o}])=>[`${i?`-${i}, `:""}--${r}${s?` ${s}`:""}`,o]);return[`Usage: ttheme ${_o(t)}`,"",t.about,...t.actions?["","Actions:",...eS(t.actions)]:[],...n.length>0?["","Options:",...eS(n)]:[]].join(`
764
+ `)}var tL=[TypeError,RangeError,ReferenceError,SyntaxError];function eL(t){return tL.some((e)=>t instanceof e)||t instanceof Error&&"code"in t}async function nS(t){let e;try{let n=XC(t);if(n.kind==="version")return console.log(Tt.version),0;if(n.kind==="help"){if(n.code===0)console.log(Km(n.verb,n.all));else console.error(Km(n.verb,n.all));return n.code}if(e=n.verb,!n.verb.run)throw Error("runs in the shell layer — open a new tab once `ttheme init` has wired it");if(JC.has(n.verb.name))await lk();let r=await n.verb.run(n.args,n.flags);if(!n.verb.hidden&&n.verb.name!=="uninstall")D1();return typeof r==="number"?r:0}catch(n){if(n instanceof Bi)return console.error(n.verb?`ttheme ${n.verb.name}: ${n.message}
565
765
 
566
- ${xd(n.verb)}`:`ttheme: ${n.message} — see \`ttheme help\``),1;if(n instanceof Ze)return 1;let r=process.env.TTHEME_DEBUG&&n instanceof Error?n.stack:void 0;return console.error(`
567
- ttheme${e?` ${e.name}`:""}: ${r??(n instanceof Error?n.message:String(n))}${lH(n)?"\nReport a bug with the output of `ttheme info`":""}`),1}}if(dH)if(process.env.TTHEME_DEBUG&&typeof Bun>"u"&&!process.sourceMapsEnabled){let t=fH(process.execPath,["--enable-source-maps",...process.argv.slice(1)],{stdio:"inherit"});process.exitCode=t.status??1}else process.exitCode=await Ik(process.argv.slice(2));
766
+ ${Km(n.verb)}`:`ttheme: ${n.message} — see \`ttheme help\``),1;if(n instanceof Ie)return 1;if(n instanceof aa)return n.exit;let r=process.env.TTHEME_DEBUG&&n instanceof Error?n.stack:void 0;return console.error(`
767
+ ttheme${e?` ${e.name}`:""}: ${r??(n instanceof Error?n.message:String(n))}${eL(n)?"\nReport a bug with the output of `ttheme info`":""}`),1}}if(rL)if(process.env.TTHEME_DEBUG&&typeof Bun>"u"&&!process.sourceMapsEnabled){let t=nL(process.execPath,["--enable-source-maps",...process.argv.slice(1)],{stdio:"inherit"});process.exitCode=t.status??1}else process.exitCode=await nS(process.argv.slice(2));
568
768
 
569
- //# debugId=73A96E40F915C72664756E2164756E21
769
+ //# debugId=B23EC1A0DF290E9464756E2164756E21
570
770
  //# sourceMappingURL=ttheme.js.map