MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / L$K

Function L$K

package/cli.js:3002–3002  ·  view source on GitHub ↗
(q)

Source from the content-addressed store, hash-verified

3000`;if(!q.lang)return[[Hu8(_),z]];let Y;try{Y=Ws1().highlight(z,{language:q.lang,ignoreIllegals:!0})}catch{return[[Hu8(_),z]]}if(!zaz(Y.emitter)){if(!j$K)j$K=!0,H6(Error(`color-diff: hljs emitter shape mismatch (keys: ${Object.keys(Y.emitter).join(",")}). Syntax highlighting disabled.`));return[[Hu8(_),z]]}let $=[];return D$K(Y.emitter.rootNode,_,void 0,$),$}function H$K(q){let K=[],_=0;while(_<q.length){let z=q[_];if(/[\p{L}\p{N}_]/u.test(z)){let Y=_+1;while(Y<q.length&&/[\p{L}\p{N}_]/u.test(q[Y]))Y++;K.push(q.slice(_,Y)),_=Y}else if(/\s/.test(z)){let Y=_+1;while(Y<q.length&&/\s/.test(q[Y]))Y++;K.push(q.slice(_,Y)),_=Y}else{let $=q.codePointAt(_)>65535?2:1;K.push(q.slice(_,_+$)),_+=$}}return K}function $az(q){let K=[],_=0;while(_<q.length)if(q[_]==="-"){let z=_,Y=_;while(Y<q.length&&q[Y]==="-")Y++;let $=Y;while($<q.length&&q[$]==="+")$++;let A=Y-z,O=$-Y;if(A>0&&O>0){let w=Math.min(A,O);for(let j=0;j<w;j++)K.push([z+j,Y+j]);_=$}else _=Y}else _++;return K}function Aaz(q,K){let _=H$K(q),z=H$K(K),Y=px1(_,z),$=q.length+K.length,A=0,O=[],w=[],j=0,H=0;for(let J of Y){let M=J.value.reduce((X,P)=>X+P.length,0);if(J.removed)A+=M,O.push({start:j,end:j+M}),j+=M;else if(J.added)A+=M,w.push({start:H,end:H+M}),H+=M;else j+=M,H+=M}if($>0&&A/$>Yaz)return[[],[]];return[O,w]}function Z$K(q){q.lines=q.lines.map((K)=>K.flatMap(([_,z])=>z.split(`
3001`).filter((Y)=>Y.length>0).map((Y)=>[_,Y])))}function Oaz(q){return O1(q)}function G$K(q,K,_){let z=[];for(let Y of q.lines){let $=Y.slice(),A=[],O=0;while($.length>0){let[w,j]=$.shift(),H=O1(j);if(O+H<=K)A.push([w,j]),O+=H;else{let J=K-O,M=0,X=0;for(let P of j){let W=Oaz(P);if(X+W>J)break;X+=W,M+=P.length}if(M===0)if(O===0)M=j.codePointAt(0)>65535?2:1;else{z.push(A),$.unshift([w,j]),A=[],O=0;continue}A.push([w,j.slice(0,M)]),z.push(A),$.unshift([w,j.slice(M)]),A=[],O=0}}z.push(A)}if(q.lines=z,q.marker&&q.marker!==" "){let Y=Ju8(q.marker,_),$={foreground:_.foreground,background:Y};for(let A of q.lines){let O=A.reduce((w,[,j])=>w+O1(j),0);if(O<K)A.push([$," ".repeat(K-O)])}}}function T$K(q,K,_,z){let Y={foreground:q.marker?P$K(q.marker,K):K.foreground,background:q.marker?Ju8(q.marker,K):K.background},$=q.marker===null||q.marker===" ";for(let A=0;A<q.lines.length;A++){let O=A===0?` ${String(q.lineNumber).padStart(_)} `:" ".repeat(_+2),w=$&&!z?`${Ds1}${O}${J$K}`:O;q.lines[A].unshift([Y,w])}}function waz(q,K){if(!q.marker)return;let _={foreground:P$K(q.marker,K),background:Ju8(q.marker,K)};for(let z of q.lines)z.unshift([_,q.marker])}function jaz(q){for(let K of q.lines)if(K.length>0){K[0][1]=Ds1+K[0][1];let _=K.length-1;K[_][1]=K[_][1]+J$K}}function Haz(q,K,_){if(!q.marker)return;let z=Ju8(q.marker,K),Y=Kaz(q.marker,K),$=0,A=0;for(let O=0;O<q.lines.length;O++){let w=[];for(let[j,H]of q.lines[O]){let J=A,M=A+H.length;while($<_.length&&_[$].end<=J)$++;if($>=_.length){w.push([{...j,background:z},H]),A=M;continue}let X=H,P=J;while(X.length>0&&$<_.length){let W=_[$],D=P>=W.start&&P<W.end,f;if(D)f=Math.min(W.end,M);else if(W.start>P&&W.start<M)f=W.start;else f=M;let G=f-P,Z=X.slice(0,G);if(w.push([{...j,background:D?Y:z},Z]),X=X.slice(G),P=f,P>=W.end)$++}if(X.length>0)w.push([{...j,background:z},X]);A=M}q.lines[O]=w}}function v$K(q,K,_,z){return q.lines.map((Y)=>soz(Y,z,_,K))}function Jaz(q){let K=Math.max(0,q.oldStart+q.oldLines-1),_=Math.max(0,q.newStart+q.newLines-1);return Math.max(K,_)}function Maz(q){return q==="+"||q==="-"?q:" "}class fs1{hunk;filePath;firstLine;prefixContent;constructor(q,K,_,z){this.hunk=q,this.filePath=_,this.firstLine=K,this.prefixContent=z??null}render(q,K,_){let z=M$K(q),Y=X$K(q,z),A={lang:W$K(this.filePath,this.firstLine),stack:null};this.prefixContent;let O=String(Jaz(this.hunk)).length,w=this.hunk.oldStart,j=this.hunk.newStart,H=Math.max(1,K-O-2-1),J=this.hunk.lines.map((P)=>{let W=Maz(P.slice(0,1)),D=P.slice(1),f;switch(W){case"+":f=j++;break;case"-":f=w++;break;case" ":f=j,w++,j++;break}return{lineNumber:f,marker:W,code:D}}),M=J.map(()=>[]);if(!_){let P=J.map((W)=>W.marker);for(let[W,D]of $az(P)){let[f,G]=Aaz(J[W].code,J[D].code);M[W]=f,M[D]=G}}let X=[];for(let P=0;P<J.length;P++){let{lineNumber:W,marker:D,code:f}=J[P],G=D==="-"?[[Hu8(Y),f]]:f$K(A,f,Y),Z={marker:D,lineNumber:W,lines:[G]};if(Z$K(Z),Haz(Z,Y,M[P]),G$K(Z,H,Y),z==="ansi"&&D==="-")jaz(Z);waz(Z,Y),T$K(Z,Y,O,_),X.push(...v$K(Z,_,!1,z))}return X}}class Zs1{code;filePath;constructor(q,K){this.code=q,this.filePath=K}render(q,K,_){let z=M$K(q),Y=X$K(q,z),$=this.code.split(`
3002`);if($.length>0&&$[$.length-1]==="")$.pop();let A=$[0]??null,w={lang:W$K(this.filePath,A),stack:null},j=String($.length).length,H=Math.max(1,K-j-2),J=[];for(let M=0;M<$.length;M++){let X=f$K(w,$[M],Y),P={marker:null,lineNumber:M+1,lines:[X]};Z$K(P),G$K(P,H,Y),T$K(P,Y,j,_),J.push(...v$K(P,_,!0,z))}return J}}function k$K(q){let K=process.env.CLAUDE_CODE_SYNTAX_HIGHLIGHT??process.env.BAT_THEME;return{theme:toz(q),source:null}}var ju8=null,Xs1="\x1B[0m",Ds1="\x1B[2m",J$K="\x1B[22m",Ta,Ps1,A$K,O$K,eoz,qaz,w$K,j$K=!1,Yaz=0.4;var V$K=y(()=>{RO6();Q5();E8();Ta={r:0,g:0,b:0,a:1};Ps1=[0,95,135,175,215,255];A$K={keyword:a4(249,38,114),_storage:a4(102,217,239),built_in:a4(166,226,46),type:a4(166,226,46),literal:a4(190,132,255),number:a4(190,132,255),string:a4(230,219,116),title:a4(166,226,46),"title.function":a4(166,226,46),"title.class":a4(166,226,46),"title.class.inherited":a4(166,226,46),params:a4(253,151,31),comment:a4(117,113,94),meta:a4(117,113,94),attr:a4(166,226,46),attribute:a4(166,226,46),variable:a4(255,255,255),"variable.language":a4(255,255,255),property:a4(255,255,255),operator:a4(249,38,114),punctuation:a4(248,248,242),symbol:a4(190,132,255),regexp:a4(230,219,116),subst:a4(248,248,242)},O$K={keyword:a4(167,29,93),_storage:a4(167,29,93),built_in:a4(0,134,179),type:a4(0,134,179),literal:a4(0,134,179),number:a4(0,134,179),string:a4(24,54,145),title:a4(121,93,163),"title.function":a4(121,93,163),"title.class":a4(0,0,0),"title.class.inherited":a4(0,0,0),params:a4(0,134,179),comment:a4(150,152,150),meta:a4(150,152,150),attr:a4(0,134,179),attribute:a4(0,134,179),variable:a4(0,134,179),"variable.language":a4(0,134,179),property:a4(0,134,179),operator:a4(167,29,93),punctuation:a4(51,51,51),symbol:a4(0,134,179),regexp:a4(24,54,145),subst:a4(51,51,51)},eoz=new Set(["const","let","var","function","class","type","interface","enum","namespace","module","def","fn","func","struct","trait","impl"]),qaz={keyword:iP(13),_storage:iP(14),built_in:iP(14),type:iP(14),literal:iP(12),number:iP(12),string:iP(10),title:iP(11),"title.function":iP(11),"title.class":iP(11),comment:iP(8),meta:iP(8)};w$K={Dockerfile:"dockerfile",Makefile:"makefile",Rakefile:"ruby",Gemfile:"ruby",CMakeLists:"cmake"}});function e68(){if(k_(process.env.CLAUDE_CODE_SYNTAX_HIGHLIGHT))return"env";return null}function N$K(){return e68()===null?fs1:null}function y$K(){return e68()===null?Zs1:null}function E$K(q){return e68()===null?k$K(q):null}var Mu8=y(()=>{V$K();m8()});function Paz(q){let K=z6(13),{line:_,gutterWidth:z}=q,Y;if(K[0]!==z||K[1]!==_)Y=of(_,0,z),K[0]=z,K[1]=_,K[2]=Y;else Y=K[2];let $=Y,A;if(K[3]!==z||K[4]!==_)A=of(_,z),K[3]=z,K[4]=_,K[5]=A;else A=K[5];let O=A,w;if(K[6]!==$)w=d2.createElement(LP,{fromLeftEdge:!0},d2.createElement(k,null,d2.createElement(B5,null,$))),K[6]=$,K[7]=w;else w=K[7];let j;if(K[8]!==O)j=d2.createElement(k,null,d2.createElement(B5,null,O)),K[8]=O,K[9]=j;else j=K[9];let H;if(K[10]!==w||K[11]!==j)H=d2.createElement(u,{flexDirection:"row"},w,j),K[10]=w,K[11]=j,K[12]=H;else H=K[12];return H}var d2,NK6,Xaz=80,zy;var gj6=y(()=>{q8();tC();s6();_M();$A6();Y$K();Mu8();d2=O6(D6(),1),NK6=O6(D6(),1),zy=NK6.memo(function(K){let _=z6(21),{code:z,filePath:Y,width:$,dim:A}=K,O=A===void 0?!1:A,w=NK6.useRef(null),[j,H]=NK6.useState($||Xaz),[J]=Aq(),X=Bj().syntaxHighlightingDisabled??!1,P;q:{if(X){P=null;break q}let E;if(_[0]===Symbol.for("react.memo_cache_sentinel"))E=y$K(),_[0]=E;else E=_[0];let S=E;if(!S){P=null;break q}let R;if(_[1]!==z||_[2]!==Y)R=new S(z,Y),_[1]=z,_[2]=Y,_[3]=R;else R=_[3];P=R}let W=P,D,f;if(_[4]!==$)D=()=>{if(!$&&w.current){let{width:E}=nT6(w.current);if(E>0)H(E-2)}},f=[$],_[4]=$,_[5]=D,_[6]=f;else D=_[5],f=_[6];NK6.useEffect(D,f);let G;q:{if(W===null){G=null;break q}let E;if(_[7]!==W||_[8]!==O||_[9]!==j||_[10]!==J)E=W.render(J,j,O),_[7]=W,_[8]=O,_[9]=j,_[10]=J,_[11]=E;else E=_[11];G=E}let Z=G,T;q:{if(!p4()){T=0;break q}let E=G$(z,`
3003`)+1,S;if(_[12]!==E)S=E.toString(),_[12]=E,_[13]=S;else S=_[13];T=S.length+2}let v=T,V;if(_[14]!==z||_[15]!==O||_[16]!==Y||_[17]!==v||_[18]!==Z||_[19]!==X)V=d2.createElement(u,{ref:w},Z?d2.createElement(u,{flexDirection:"column"},Z.map((E,S)=>v>0?d2.createElement(Paz,{key:S,line:E,gutterWidth:v}):d2.createElement(k,{key:S},d2.createElement(B5,null,E)))):d2.createElement(z$K,{code:z,filePath:Y,dim:O,skipColoring:X})),_[14]=z,_[15]=O,_[16]=Y,_[17]=v,_[18]=Z,_[19]=X,_[20]=V;else V=_[20];return V})});function L$K(q){let K=z6(10),{patch:_,dim:z,width:Y}=q,[$]=Aq(),A;if(K[0]!==z||K[1]!==_.lines||K[2]!==_.oldStart||K[3]!==$||K[4]!==Y)A=vaz(_.lines,_.oldStart,Y,z,$),K[0]=z,K[1]=_.lines,K[2]=_.oldStart,K[3]=$,K[4]=Y,K[5]=A;else A=K[5];let O=A,w;if(K[6]!==O)w=O.map(Daz),K[6]=O,K[7]=w;else w=K[7];let j;if(K[8]!==w)j=FH.createElement(u,{flexDirection:"column",flexGrow:1},w),K[8]=w,K[9]=j;else j=K[9];return j}function Daz(q,K){return FH.createElement(u,{key:K},q)}function faz(q){return q.map((K)=>{if(K.startsWith("+"))return{code:K.slice(1),i:0,type:"add",originalCode:K.slice(1)};if(K.startsWith("-"))return{code:K.slice(1),i:0,type:"remove",originalCode:K.slice(1)};return{code:K.slice(1),i:0,type:"nochange",originalCode:K.slice(1)}})}function Zaz(q){let K=[],_=0;while(_<q.length){let z=q[_];if(!z){_++;continue}if(z.type==="remove"){let Y=[z],$=_+1;while($<q.length&&q[$]?.type==="remove"){let O=q[$];if(O)Y.push(O);$++}let A=[];while($<q.length&&q[$]?.type==="add"){let O=q[$];if(O)A.push(O);$++}if(Y.length>0&&A.length>0){let O=Math.min(Y.length,A.length);for(let w=0;w<O;w++){let j=Y[w],H=A[w];if(j&&H)j.wordDiff=!0,H.wordDiff=!0,j.matchedLine=H,H.matchedLine=j}K.push(...Y.filter(Boolean)),K.push(...A.filter(Boolean)),_=$}else K.push(z),_++}else K.push(z),_++}return K}function Gaz(q,K){return ux1(q,K,{ignoreCase:!1})}function Taz(q,K,_,z,Y){let{type:$,i:A,wordDiff:O,matchedLine:w,originalCode:j}=q;if(!O||!w)return null;let H=$==="remove"?j:w.originalCode,J=$==="remove"?w.originalCode:j,M=Gaz(H,J),X=H.length+J.length;if(M.filter((V)=>V.added||V.removed).reduce((V,E)=>V+E.value.length,0)/X>Waz||z)return null;let D=$==="add"?"+":"-",f=D.length,G=Math.max(1,K-_-1-f),Z=[],T=[],v=0;if(M.forEach((V,E)=>{let S=!1,R;if($==="add"){if(V.added)S=!0,R="diffAddedWord";else if(!V.removed)S=!0}else if($==="remove"){if(V.removed)S=!0,R="diffRemovedWord";else if(!V.added)S=!0}if(!S)return;nS(V.value,G,"wrap").split(`
3004`).forEach((B,p)=>{if(!B)return;if(p>0||v+O1(B)>G){if(T.length>0)Z.push({content:[...T],contentWidth:v}),T=[],v=0}T.push(FH.createElement(k,{key:`part-${E}-${p}`,backgroundColor:R},B)),v+=O1(B)})}),T.length>0)Z.push({content:T,contentWidth:v});return Z.map(({content:V,contentWidth:E},S)=>{let R=`${$}-${A}-${S}`,x=$==="add"?z?"diffAddedDimmed":"diffAdded":z?"diffRemovedDimmed":"diffRemoved",I=S===0?A:void 0,B=(I!==void 0?I.toString().padStart(_):" ".repeat(_))+" ",p=B.length+f+E,C=Math.max(0,K-p);return FH.createElement(u,{key:R,flexDirection:"row"},FH.createElement(LP,{fromLeftEdge:!0},FH.createElement(k,{color:Y?"text":void 0,backgroundColor:x,dimColor:z},B,D)),FH.createElement(k,{color:Y?"text":void 0,backgroundColor:x,dimColor:z},V," ".repeat(C)))})}function vaz(q,K,_,z,Y){let $=Math.max(1,Math.floor(_)),A=faz(q),O=Zaz(A),w=kaz(O,K),j=Math.max(...w.map(({i:J})=>J),0),H=Math.max(j.toString().length+1,0);return w.flatMap((J)=>{let{type:M,code:X,i:P,wordDiff:W,matchedLine:D}=J;if(W&&D){let v=Taz(J,$,H,z,Y);if(v!==null)return v}let f=2,G=Math.max(1,$-H-1-f);return nS(X,G,"wrap").split(`
3005`).map((v,V)=>{let E=`${M}-${P}-${V}`,S=V===0?P:void 0,R=(S!==void 0?S.toString().padStart(H):" ".repeat(H))+" ",x=M==="add"?"+":M==="remove"?"-":" ",I=R.length+1+O1(v),B=Math.max(0,$-I),p=M==="add"?z?"diffAddedDimmed":"diffAdded":M==="remove"?z?"diffRemovedDimmed":"diffRemoved":void 0;return FH.createElement(u,{key:E,flexDirection:"row"},FH.createElement(LP,{fromLeftEdge:!0},FH.createElement(k,{color:Y?"text":void 0,backgroundColor:p,dimColor:z||M==="nochange"},R,x)),FH.createElement(k,{color:Y?"text":void 0,backgroundColor:p,dimColor:z},v," ".repeat(B)))})})}function kaz(q,K){let _=K,z=[],Y=[...q];while(Y.length>0){let $=Y.shift(),{code:A,type:O,originalCode:w,wordDiff:j,matchedLine:H}=$,J={code:A,type:O,i:_,originalCode:w,wordDiff:j,matchedLine:H};switch(O){case"nochange":_++,z.push(J);break;case"add":_++,z.push(J);break;case"remove":{z.push(J);let M=0;while(Y[0]?.type==="remove"){_++;let X=Y.shift(),{code:P,type:W,originalCode:D,wordDiff:f,matchedLine:G}=X,Z={code:P,type:W,i:_,originalCode:D,wordDiff:f,matchedLine:G};z.push(Z),M++}_-=M;break}}}return z}var FH,Waz=0.4;var R$K=y(()=>{q8();RO6();Q5();s6();FH=O6(D6(),1)});function Vaz(q){return Math.max(q.oldStart+q.oldLines-1,q.newStart+q.newLines-1,1).toString().length+3}function Naz(q,K,_,z,Y,$,A,O){let w=N$K();if(!w)return null;let j=O?Vaz(q):0,H=j>0&&j<$?j:0,J=`${Y}|${$}|${A?1:0}|${H}|${K??""}|${_}`,M=h$K.get(q),X=M?.get(J);if(X)return X;let P=new w(q,K,_,z).render(Y,$,A);if(P===null)return null;let W=null,D=null;if(H>0)W=P.map((G)=>of(G,0,H)),D=P.map((G)=>of(G,H));let f={lines:P,gutterWidth:H,gutters:W,contents:D};if(!M)M=new Map,h$K.set(q,M);if(M.size>=4)M.clear();return M.set(J,f),f}var B0,S$K,h$K,gQ;var cL6=y(()=>{q8();tC();s6();_M();$A6();Mu8();R$K();B0=O6(D6(),1),S$K=O6(D6(),1),h$K=new WeakMap;gQ=S$K.memo(function(K){let _=z6(26),{patch:z,dim:Y,filePath:$,firstLine:A,fileContent:O,width:w,skipHighlighting:j}=K,H=j===void 0?!1:j,[J]=Aq(),X=Bj().syntaxHighlightingDisabled??!1,P=Math.max(1,Math.floor(w)),W;if(_[0]!==Y||_[1]!==O||_[2]!==$||_[3]!==A||_[4]!==z||_[5]!==P||_[6]!==H||_[7]!==X||_[8]!==J){let V=p4();W=H||X?null:Naz(z,A,$,O??null,J,P,Y,V),_[0]=Y,_[1]=O,_[2]=$,_[3]=A,_[4]=z,_[5]=P,_[6]=H,_[7]=X,_[8]=J,_[9]=W}else W=_[9];let D=W;if(!D){let V;if(_[10]!==Y||_[11]!==z||_[12]!==w)V=B0.createElement(u,null,B0.createElement(L$K,{patch:z,dim:Y,width:w})),_[10]=Y,_[11]=z,_[12]=w,_[13]=V;else V=_[13];return V}let{lines:f,gutterWidth:G,gutters:Z,contents:T}=D;if(G>0&&Z&&T){let V;if(_[14]!==G||_[15]!==Z)V=B0.createElement(LP,{fromLeftEdge:!0},B0.createElement(FT6,{lines:Z,width:G})),_[14]=G,_[15]=Z,_[16]=V;else V=_[16];let E=P-G,S;if(_[17]!==T||_[18]!==E)S=B0.createElement(FT6,{lines:T,width:E}),_[17]=T,_[18]=E,_[19]=S;else S=_[19];let R;if(_[20]!==V||_[21]!==S)R=B0.createElement(u,{flexDirection:"row"},V,S),_[20]=V,_[21]=S,_[22]=R;else R=_[22];return R}let v;if(_[23]!==f||_[24]!==P)v=B0.createElement(u,null,B0.createElement(FT6,{lines:f,width:P})),_[23]=f,_[24]=P,_[25]=v;else v=_[25];return v})});function lL6({hunks:q,dim:K,width:_,filePath:z,firstLine:Y,fileContent:$}){return be(q.map((A)=>va.createElement(u,{flexDirection:"column",key:A.newStart},va.createElement(gQ,{patch:A,dim:K,width:_,filePath:z,firstLine:Y,fileContent:$}))),(A)=>va.createElement(LP,{fromLeftEdge:!0,key:`ellipsis-${A}`},va.createElement(k,{dimColor:!0},"...")))}var va;var Xu8=y(()=>{s6();cL6();va=O6(D6(),1)});import{relative as yaz}from"path";function yK6(q){let K=z6(38),{file_path:_,operation:z,patch:Y,firstLine:$,fileContent:A,content:O,style:w,verbose:j}=q,{columns:H}=t1(),J;if(K[0]!==z)J=c2.createElement(k,{color:"subtle"},"User rejected ",z," to "),K[0]=z,K[1]=J;else J=K[1];let M;if(K[2]!==_||K[3]!==j)M=j?_:yaz(Z8(),_),K[2]=_,K[3]=j,K[4]=M;else M=K[4];let X;if(K[5]!==M)X=c2.createElement(k,{bold:!0,color:"subtle"},M),K[5]=M,K[6]=X;else X=K[6];let P;if(K[7]!==J||K[8]!==X)P=c2.createElement(u,{flexDirection:"row"},J,X),K[7]=J,K[8]=X,K[9]=P;else P=K[9];let W=P;if(w==="condensed"&&!j){let Z;if(K[10]!==W)Z=c2.createElement(s8,null,W),K[10]=W,K[11]=Z;else Z=K[11];return Z}if(z==="write"&&O!==void 0){let Z,T;if(K[12]!==O||K[13]!==j){let I=O.split(`

Callers

nothing calls this directly

Calls 4

z6Function · 0.85
AqFunction · 0.85
vazFunction · 0.85
createElementMethod · 0.80

Tested by

no test coverage detected