@openchamber/web 1.4.8 → 1.5.0
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/README.md +9 -1
- package/bin/cli.js +35 -0
- package/dist/assets/{ToolOutputDialog-Dn1Yyik_.js → ToolOutputDialog-D8JjsNSh.js} +2 -2
- package/dist/assets/index-B5OwFsqC.js +2 -0
- package/dist/assets/index-DXflA-iU.css +1 -0
- package/dist/assets/main-SJbJIOue.js +156 -0
- package/dist/assets/{vendor-.bun-94fMDU1C.js → vendor-.bun-CqCnPJev.js} +353 -352
- package/dist/assets/{worker-NULm4lOi.js → worker-C7rwD-e5.js} +1 -1
- package/dist/index.html +3 -3
- package/package.json +2 -2
- package/server/index.js +146 -13
- package/server/lib/git-service.js +12 -0
- package/dist/assets/index-CyM2ZMJa.js +0 -2
- package/dist/assets/index-RdQawb7R.css +0 -1
- package/dist/assets/main-hUJJZcBf.js +0 -128
|
@@ -150,4 +150,4 @@ XID_Start XIDS`.split(/\s/).map(t=>[it(t),t])),vo=new Map([["s",R(383)],[R(383),
|
|
|
150
150
|
\f\r "&'<=>\``.split(""),`\0
|
|
151
151
|
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Vi(t,e,n,r){const s=r.schema,o=s.space==="svg"?!1:r.settings.omitOptionalTags;let a=s.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(t.tagName.toLowerCase());const i=[];let l;s.space==="html"&&t.tagName==="svg"&&(r.schema=rs);const c=Xi(r,t.properties),u=r.all(s.space==="html"&&t.tagName==="template"?t.content:t);return r.schema=s,u&&(a=!1),(c||!o||!ji(t,e,n))&&(i.push("<",t.tagName,c?" "+c:""),a&&(s.space==="svg"||r.settings.closeSelfClosing)&&(l=c.charAt(c.length-1),(!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&i.push(" "),i.push("/")),i.push(">")),i.push(u),!a&&(!o||!on(t,e,n))&&i.push("</"+t.tagName+">"),i.join("")}function Xi(t,e){const n=[];let r=-1,s;if(e){for(s in e)if(e[s]!==null&&e[s]!==void 0){const o=Ki(t,s,e[s]);o&&n.push(o)}}for(;++r<n.length;){const o=t.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&o!=='"'&&o!=="'"&&(n[r]+=" ")}return n.join("")}function Ki(t,e,n){const r=Ya(t.schema,e),s=t.settings.allowParseErrors&&t.schema.space==="html"?0:1,o=t.settings.allowDangerousCharacters?0:1;let a=t.quote,i;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const l=pe(r.attribute,Object.assign({},t.settings.characterReferences,{subset:ze.name[s][o]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?vi:xi)(n,{padLeft:!t.settings.tightCommaSeparatedLists}):String(n),t.settings.collapseEmptyAttributes&&!n)?l:(t.settings.preferUnquoted&&(i=pe(n,Object.assign({},t.settings.characterReferences,{attribute:!0,subset:ze.unquoted[s][o]}))),i!==n&&(t.settings.quoteSmart&&Hn(n,a)>Hn(n,t.alternative)&&(a=t.alternative),i=a+pe(n,Object.assign({},t.settings.characterReferences,{subset:(a==="'"?ze.single:ze.double)[s][o],attribute:!0}))+a),l+(i&&"="+i))}const Zi=["<","&"];function ls(t,e,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?t.value:pe(t.value,Object.assign({},r.settings.characterReferences,{subset:Zi}))}function Qi(t,e,n,r){return r.settings.allowDangerousHtml?t.value:ls(t,e,n,r)}function Yi(t,e,n,r){return r.all(t)}const Ji=ni("type",{invalid:el,unknown:tl,handlers:{comment:Si,doctype:ki,element:Vi,raw:Qi,root:Yi,text:ls}});function el(t){throw new Error("Expected node, not `"+t+"`")}function tl(t){const e=t;throw new Error("Cannot compile unknown node `"+e.type+"`")}const nl={},rl={},sl=[];function ol(t,e){const n=e||nl,r=n.quote||'"',s=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:al,all:il,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Ha,characterReferences:n.characterReferences||rl,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?rs:ti,quote:r,alternative:s}.one(Array.isArray(t)?{type:"root",children:t}:t,void 0,void 0)}function al(t,e,n){return Ji(t,e,n,this)}function il(t){const e=[],n=t&&t.children||sl;let r=-1;for(;++r<n.length;)e[r]=this.one(n[r],r,t);return e.join("")}function et(t,e){const n=typeof t=="string"?{}:{...t.colorReplacements},r=typeof t=="string"?t:t.name;for(const[s,o]of Object.entries(e?.colorReplacements||{}))typeof o=="string"?n[s]=o:s===r&&Object.assign(n,o);return n}function J(t,e){return t&&(e?.[t?.toLowerCase()]||t)}function ll(t){return Array.isArray(t)?t:[t]}async function cs(t){return Promise.resolve(typeof t=="function"?t():t).then(e=>e.default||e)}function an(t){return!t||["plaintext","txt","text","plain"].includes(t)}function cl(t){return t==="ansi"||an(t)}function ln(t){return t==="none"}function ul(t){return ln(t)}function us(t,e){if(!e)return t;t.properties||={},t.properties.class||=[],typeof t.properties.class=="string"&&(t.properties.class=t.properties.class.split(/\s+/g)),Array.isArray(t.properties.class)||(t.properties.class=[]);const n=Array.isArray(e)?e:e.split(/\s+/g);for(const r of n)r&&!t.properties.class.includes(r)&&t.properties.class.push(r);return t}function ct(t,e=!1){if(t.length===0)return[["",0]];const n=t.split(/(\r?\n)/g);let r=0;const s=[];for(let o=0;o<n.length;o+=2){const a=e?n[o]+(n[o+1]||""):n[o];s.push([a,r]),r+=n[o].length,r+=n[o+1]?.length||0}return s}function hl(t){const e=ct(t,!0).map(([s])=>s);function n(s){if(s===t.length)return{line:e.length-1,character:e[e.length-1].length};let o=s,a=0;for(const i of e){if(o<i.length)break;o-=i.length,a++}return{line:a,character:o}}function r(s,o){let a=0;for(let i=0;i<s;i++)a+=e[i].length;return a+=o,a}return{lines:e,indexToPos:n,posToIndex:r}}const cn="light-dark()",fl=["color","background-color"];function dl(t,e){let n=0;const r=[];for(const s of e)s>n&&r.push({...t,content:t.content.slice(n,s),offset:t.offset+n}),n=s;return n<t.content.length&&r.push({...t,content:t.content.slice(n),offset:t.offset+n}),r}function pl(t,e){const n=Array.from(e instanceof Set?e:new Set(e)).sort((r,s)=>r-s);return n.length?t.map(r=>r.flatMap(s=>{const o=n.filter(a=>s.offset<a&&a<s.offset+s.content.length).map(a=>a-s.offset).sort((a,i)=>a-i);return o.length?dl(s,o):s})):t}function gl(t,e,n,r,s="css-vars"){const o={content:t.content,explanation:t.explanation,offset:t.offset},a=e.map(u=>tt(t.variants[u])),i=new Set(a.flatMap(u=>Object.keys(u))),l={},c=(u,h)=>{const f=h==="color"?"":h==="background-color"?"-bg":`-${h}`;return n+e[u]+(h==="color"?"":f)};return a.forEach((u,h)=>{for(const f of i){const d=u[f]||"inherit";if(h===0&&r&&fl.includes(f))if(r===cn&&a.length>1){const p=e.findIndex(y=>y==="light"),w=e.findIndex(y=>y==="dark");if(p===-1||w===-1)throw new $('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const C=a[p][f]||"inherit",g=a[w][f]||"inherit";l[f]=`light-dark(${C}, ${g})`,s==="css-vars"&&(l[c(h,f)]=d)}else l[f]=d;else s==="css-vars"&&(l[c(h,f)]=d)}}),o.htmlStyle=l,o}function tt(t){const e={};if(t.color&&(e.color=t.color),t.bgColor&&(e["background-color"]=t.bgColor),t.fontStyle){t.fontStyle&M.Italic&&(e["font-style"]="italic"),t.fontStyle&M.Bold&&(e["font-weight"]="bold");const n=[];t.fontStyle&M.Underline&&n.push("underline"),t.fontStyle&M.Strikethrough&&n.push("line-through"),n.length&&(e["text-decoration"]=n.join(" "))}return e}function Xt(t){return typeof t=="string"?t:Object.entries(t).map(([e,n])=>`${e}:${n}`).join(";")}const hs=new WeakMap;function ut(t,e){hs.set(t,e)}function $e(t){return hs.get(t)}class Ce{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(e,n){return new Ce(Object.fromEntries(ll(n).map(r=>[r,zt])),e)}constructor(...e){if(e.length===2){const[n,r]=e;this.lang=r,this._stacks=n}else{const[n,r,s]=e;this.lang=r,this._stacks={[s]:n}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return ml(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function ml(t){const e=[],n=new Set;function r(s){if(n.has(s))return;n.add(s);const o=s?.nameScopesList?.scopeName;o&&e.push(o),s.parent&&r(s.parent)}return r(t),e}function yl(t,e){if(!(t instanceof Ce))throw new $("Invalid grammar state");return t.getInternalStack(e)}function bl(){const t=new WeakMap;function e(n){if(!t.has(n.meta)){let r=function(a){if(typeof a=="number"){if(a<0||a>n.source.length)throw new $(`Invalid decoration offset: ${a}. Code length: ${n.source.length}`);return{...s.indexToPos(a),offset:a}}else{const i=s.lines[a.line];if(i===void 0)throw new $(`Invalid decoration position ${JSON.stringify(a)}. Lines length: ${s.lines.length}`);let l=a.character;if(l<0&&(l=i.length+l),l<0||l>i.length)throw new $(`Invalid decoration position ${JSON.stringify(a)}. Line ${a.line} length: ${i.length}`);return{...a,character:l,offset:s.posToIndex(a.line,l)}}};const s=hl(n.source),o=(n.options.decorations||[]).map(a=>({...a,start:r(a.start),end:r(a.end)}));wl(o),t.set(n.meta,{decorations:o,converter:s,source:n.source})}return t.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(!this.options.decorations?.length)return;const s=e(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]);return pl(n,s)},code(n){if(!this.options.decorations?.length)return;const r=e(this),s=Array.from(n.children).filter(u=>u.type==="element"&&u.tagName==="span");if(s.length!==r.converter.lines.length)throw new $(`Number of lines in code element (${s.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function o(u,h,f,d){const p=s[u];let w="",C=-1,g=-1;if(h===0&&(C=0),f===0&&(g=0),f===Number.POSITIVE_INFINITY&&(g=p.children.length),C===-1||g===-1)for(let m=0;m<p.children.length;m++)w+=fs(p.children[m]),C===-1&&w.length===h&&(C=m+1),g===-1&&w.length===f&&(g=m+1);if(C===-1)throw new $(`Failed to find start index for decoration ${JSON.stringify(d.start)}`);if(g===-1)throw new $(`Failed to find end index for decoration ${JSON.stringify(d.end)}`);const y=p.children.slice(C,g);if(!d.alwaysWrap&&y.length===p.children.length)i(p,d,"line");else if(!d.alwaysWrap&&y.length===1&&y[0].type==="element")i(y[0],d,"token");else{const m={type:"element",tagName:"span",properties:{},children:y};i(m,d,"wrapper"),p.children.splice(C,y.length,m)}}function a(u,h){s[u]=i(s[u],h,"line")}function i(u,h,f){const d=h.properties||{},p=h.transform||(w=>w);return u.tagName=h.tagName||"span",u.properties={...u.properties,...d,class:u.properties.class},h.properties?.class&&us(u,h.properties.class),u=p(u,f)||u,u}const l=[],c=r.decorations.sort((u,h)=>h.start.offset-u.start.offset||u.end.offset-h.end.offset);for(const u of c){const{start:h,end:f}=u;if(h.line===f.line)o(h.line,h.character,f.character,u);else if(h.line<f.line){o(h.line,h.character,Number.POSITIVE_INFINITY,u);for(let d=h.line+1;d<f.line;d++)l.unshift(()=>a(d,u));o(f.line,0,f.character,u)}}l.forEach(u=>u())}}}function wl(t){for(let e=0;e<t.length;e++){const n=t[e];if(n.start.offset>n.end.offset)throw new $(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=e+1;r<t.length;r++){const s=t[r],o=n.start.offset<=s.start.offset&&s.start.offset<n.end.offset,a=n.start.offset<s.end.offset&&s.end.offset<=n.end.offset,i=s.start.offset<=n.start.offset&&n.start.offset<s.end.offset,l=s.start.offset<n.end.offset&&n.end.offset<=s.end.offset;if(o||a||i||l){if(o&&a||i&&l||i&&n.start.offset===n.end.offset||a&&s.start.offset===s.end.offset)continue;throw new $(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(s.start)} intersect.`)}}}}function fs(t){return t.type==="text"?t.value:t.type==="element"?t.children.map(fs).join(""):""}const Cl=[bl()];function nt(t){const e=_l(t.transformers||[]);return[...e.pre,...e.normal,...e.post,...Cl]}function _l(t){const e=[],n=[],r=[];for(const s of t)switch(s.enforce){case"pre":e.push(s);break;case"post":n.push(s);break;default:r.push(s)}return{pre:e,post:n,normal:r}}var se=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],At={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Sl(t,e){const n=t.indexOf("\x1B",e);if(n!==-1&&t[n+1]==="["){const r=t.indexOf("m",n);if(r!==-1)return{sequence:t.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:t.length}}function Zn(t){const e=t.shift();if(e==="2"){const n=t.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(e==="5"){const n=t.shift();if(n)return{type:"table",index:Number(n)}}}function kl(t){const e=[];for(;t.length>0;){const n=t.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)e.push({type:"resetAll"});else if(r<=9)At[r]&&e.push({type:"setDecoration",value:At[r]});else if(r<=29){const s=At[r-20];s&&(e.push({type:"resetDecoration",value:s}),s==="dim"&&e.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)e.push({type:"setForegroundColor",value:{type:"named",name:se[r-30]}});else if(r===38){const s=Zn(t);s&&e.push({type:"setForegroundColor",value:s})}else if(r===39)e.push({type:"resetForegroundColor"});else if(r<=47)e.push({type:"setBackgroundColor",value:{type:"named",name:se[r-40]}});else if(r===48){const s=Zn(t);s&&e.push({type:"setBackgroundColor",value:s})}else r===49?e.push({type:"resetBackgroundColor"}):r===53?e.push({type:"setDecoration",value:"overline"}):r===55?e.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?e.push({type:"setForegroundColor",value:{type:"named",name:se[r-90+8]}}):r>=100&&r<=107&&e.push({type:"setBackgroundColor",value:{type:"named",name:se[r-100+8]}})}return e}function vl(){let t=null,e=null,n=new Set;return{parse(r){const s=[];let o=0;do{const a=Sl(r,o),i=a.sequence?r.substring(o,a.startPosition):r.substring(o);if(i.length>0&&s.push({value:i,foreground:t,background:e,decorations:new Set(n)}),a.sequence){const l=kl(a.sequence);for(const c of l)c.type==="resetAll"?(t=null,e=null,n.clear()):c.type==="resetForegroundColor"?t=null:c.type==="resetBackgroundColor"?e=null:c.type==="resetDecoration"&&n.delete(c.value);for(const c of l)c.type==="setForegroundColor"?t=c.value:c.type==="setBackgroundColor"?e=c.value:c.type==="setDecoration"&&n.add(c.value)}o=a.position}while(o<r.length);return s}}}var xl={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function El(t=xl){function e(i){return t[i]}function n(i){return`#${i.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function s(){if(r)return r;r=[];for(let c=0;c<se.length;c++)r.push(e(se[c]));let i=[0,95,135,175,215,255];for(let c=0;c<6;c++)for(let u=0;u<6;u++)for(let h=0;h<6;h++)r.push(n([i[c],i[u],i[h]]));let l=8;for(let c=0;c<24;c++,l+=10)r.push(n([l,l,l]));return r}function o(i){return s()[i]}function a(i){switch(i.type){case"named":return e(i.name);case"rgb":return n(i.rgb);case"table":return o(i.index)}}return{value:a}}const Al={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function Il(t,e,n){const r=et(t,n),s=ct(e),o=Object.fromEntries(se.map(l=>{const c=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`,u=t.colors?.[c];return[l,u||Al[l]]})),a=El(o),i=vl();return s.map(l=>i.parse(l[0]).map(c=>{let u,h;c.decorations.has("reverse")?(u=c.background?a.value(c.background):t.bg,h=c.foreground?a.value(c.foreground):t.fg):(u=c.foreground?a.value(c.foreground):t.fg,h=c.background?a.value(c.background):void 0),u=J(u,r),h=J(h,r),c.decorations.has("dim")&&(u=Rl(u));let f=M.None;return c.decorations.has("bold")&&(f|=M.Bold),c.decorations.has("italic")&&(f|=M.Italic),c.decorations.has("underline")&&(f|=M.Underline),c.decorations.has("strikethrough")&&(f|=M.Strikethrough),{content:c.value,offset:l[1],color:u,bgColor:h,fontStyle:f}}))}function Rl(t){const e=t.match(/#([0-9a-f]{3,8})/i);if(e){const r=e[1];if(r.length===8){const s=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${s}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const s=r[0],o=r[1],a=r[2],i=r[3],l=Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0");return`#${s}${s}${o}${o}${a}${a}${l}`}else if(r.length===3){const s=r[0],o=r[1],a=r[2];return`#${s}${s}${o}${o}${a}${a}80`}}}const n=t.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:t}function un(t,e,n={}){const{theme:r=t.getLoadedThemes()[0]}=n,s=t.resolveLangAlias(n.lang||"text");if(an(s)||ln(r))return ct(e).map(l=>[{content:l[0],offset:l[1]}]);const{theme:o,colorMap:a}=t.setTheme(r);if(s==="ansi")return Il(o,e,n);const i=t.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==i.name)throw new $(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${i.name}"`);if(!n.grammarState.themes.includes(o.name))throw new $(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${o.name}"`)}return $l(e,i,o,a,n)}function Nl(...t){if(t.length===2)return $e(t[1]);const[e,n,r={}]=t,{lang:s="text",theme:o=e.getLoadedThemes()[0]}=r;if(an(s)||ln(o))throw new $("Plain language does not have grammar state");if(s==="ansi")throw new $("ANSI language does not have grammar state");const{theme:a,colorMap:i}=e.setTheme(o),l=e.getLanguage(s);return new Ce(rt(n,l,a,i,r).stateStack,l.name,a.name)}function $l(t,e,n,r,s){const o=rt(t,e,n,r,s),a=new Ce(rt(t,e,n,r,s).stateStack,e.name,n.name);return ut(o.tokens,a),o.tokens}function rt(t,e,n,r,s){const o=et(n,s),{tokenizeMaxLineLength:a=0,tokenizeTimeLimit:i=500}=s,l=ct(t);let c=s.grammarState?yl(s.grammarState,n.name)??zt:s.grammarContextCode!=null?rt(s.grammarContextCode,e,n,r,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:zt,u=[];const h=[];for(let f=0,d=l.length;f<d;f++){const[p,w]=l[f];if(p===""){u=[],h.push([]);continue}if(a>0&&p.length>=a){u=[],h.push([{content:p,offset:w,color:"",fontStyle:0}]);continue}let C,g,y;s.includeExplanation&&(C=e.tokenizeLine(p,c,i),g=C.tokens,y=0);const m=e.tokenizeLine2(p,c,i),_=m.tokens.length/2;for(let S=0;S<_;S++){const E=m.tokens[2*S],L=S+1<_?m.tokens[2*S+2]:p.length;if(E===L)continue;const B=m.tokens[2*S+1],Ge=J(r[ge.getForeground(B)],o),ft=ge.getFontStyle(B),_e={content:p.substring(E,L),offset:w+E,color:Ge,fontStyle:ft};if(s.includeExplanation){const Z=[];if(s.includeExplanation!=="scopeName")for(const q of n.settings){let ie;switch(typeof q.scope){case"string":ie=q.scope.split(/,/).map(dt=>dt.trim());break;case"object":ie=q.scope;break;default:continue}Z.push({settings:q,selectors:ie.map(dt=>dt.split(/ /))})}_e.explanation=[];let dn=0;for(;E+dn<L;){const q=g[y],ie=p.substring(q.startIndex,q.endIndex);dn+=ie.length,_e.explanation.push({content:ie,scopes:s.includeExplanation==="scopeName"?Pl(q.scopes):Ll(Z,q.scopes)}),y+=1}}u.push(_e)}h.push(u),u=[],c=m.ruleStack}return{tokens:h,stateStack:c}}function Pl(t){return t.map(e=>({scopeName:e}))}function Ll(t,e){const n=[];for(let r=0,s=e.length;r<s;r++){const o=e[r];n[r]={scopeName:o,themeMatches:Ml(t,o,e.slice(0,r))}}return n}function Qn(t,e){return t===e||e.substring(0,t.length)===t&&e[t.length]==="."}function Tl(t,e,n){if(!Qn(t[t.length-1],e))return!1;let r=t.length-2,s=n.length-1;for(;r>=0&&s>=0;)Qn(t[r],n[s])&&(r-=1),s-=1;return r===-1}function Ml(t,e,n){const r=[];for(const{selectors:s,settings:o}of t)for(const a of s)if(Tl(a,e,n)){r.push(o);break}return r}function ds(t,e,n){const r=Object.entries(n.themes).filter(l=>l[1]).map(l=>({color:l[0],theme:l[1]})),s=r.map(l=>{const c=un(t,e,{...n,theme:l.theme}),u=$e(c),h=typeof l.theme=="string"?l.theme:l.theme.name;return{tokens:c,state:u,theme:h}}),o=Ol(...s.map(l=>l.tokens)),a=o[0].map((l,c)=>l.map((u,h)=>{const f={content:u.content,variants:{},offset:u.offset};return"includeExplanation"in n&&n.includeExplanation&&(f.explanation=u.explanation),o.forEach((d,p)=>{const{content:w,explanation:C,offset:g,...y}=d[c][h];f.variants[r[p].color]=y}),f})),i=s[0].state?new Ce(Object.fromEntries(s.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),s[0].state.lang):void 0;return i&&ut(a,i),a}function Ol(...t){const e=t.map(()=>[]),n=t.length;for(let r=0;r<t[0].length;r++){const s=t.map(l=>l[r]),o=e.map(()=>[]);e.forEach((l,c)=>l.push(o[c]));const a=s.map(()=>0),i=s.map(l=>l[0]);for(;i.every(l=>l);){const l=Math.min(...i.map(c=>c.content.length));for(let c=0;c<n;c++){const u=i[c];u.content.length===l?(o[c].push(u),a[c]+=1,i[c]=s[c][a[c]]):(o[c].push({...u,content:u.content.slice(0,l)}),i[c]={...u,content:u.content.slice(l),offset:u.offset+l})}}}return e}function st(t,e,n){let r,s,o,a,i,l;if("themes"in n){const{defaultColor:c="light",cssVariablePrefix:u="--shiki-",colorsRendering:h="css-vars"}=n,f=Object.entries(n.themes).filter(g=>g[1]).map(g=>({color:g[0],theme:g[1]})).sort((g,y)=>g.color===c?-1:y.color===c?1:0);if(f.length===0)throw new $("`themes` option must not be empty");const d=ds(t,e,n);if(l=$e(d),c&&cn!==c&&!f.find(g=>g.color===c))throw new $(`\`themes\` option must contain the defaultColor key \`${c}\``);const p=f.map(g=>t.getTheme(g.theme)),w=f.map(g=>g.color);o=d.map(g=>g.map(y=>gl(y,w,u,c,h))),l&&ut(o,l);const C=f.map(g=>et(g.theme,n));s=Yn(f,p,C,u,c,"fg",h),r=Yn(f,p,C,u,c,"bg",h),a=`shiki-themes ${p.map(g=>g.name).join(" ")}`,i=c?void 0:[s,r].join(";")}else if("theme"in n){const c=et(n.theme,n);o=un(t,e,n);const u=t.getTheme(n.theme);r=J(u.bg,c),s=J(u.fg,c),a=u.name,l=$e(o)}else throw new $("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:s,bg:r,themeName:a,rootStyle:i,grammarState:l}}function Yn(t,e,n,r,s,o,a){return t.map((i,l)=>{const c=J(e[l][o],n[l])||"inherit",u=`${r+i.color}${o==="bg"?"-bg":""}:${c}`;if(l===0&&s){if(s===cn&&t.length>1){const h=t.findIndex(w=>w.color==="light"),f=t.findIndex(w=>w.color==="dark");if(h===-1||f===-1)throw new $('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const d=J(e[h][o],n[h])||"inherit",p=J(e[f][o],n[f])||"inherit";return`light-dark(${d}, ${p});${u}`}return c}return a==="css-vars"?u:null}).filter(i=>!!i).join(";")}function ot(t,e,n,r={meta:{},options:n,codeToHast:(s,o)=>ot(t,s,o),codeToTokens:(s,o)=>st(t,s,o)}){let s=e;for(const p of nt(n))s=p.preprocess?.call(r,s,n)||s;let{tokens:o,fg:a,bg:i,themeName:l,rootStyle:c,grammarState:u}=st(t,s,n);const{mergeWhitespaces:h=!0,mergeSameStyleTokens:f=!1}=n;h===!0?o=Dl(o):h==="never"&&(o=Bl(o)),f&&(o=Fl(o));const d={...r,get source(){return s}};for(const p of nt(n))o=p.tokens?.call(d,o)||o;return Gl(o,{...n,fg:a,bg:i,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??c},d,u)}function Gl(t,e,n,r=$e(t)){const s=nt(e),o=[],a={type:"root",children:[]},{structure:i="classic",tabindex:l="0"}=e,c={class:`shiki ${e.themeName||""}`};e.rootStyle!==!1&&(e.rootStyle!=null?c.style=e.rootStyle:c.style=`background-color:${e.bg};color:${e.fg}`),l!==!1&&l!=null&&(c.tabindex=l.toString());for(const[w,C]of Object.entries(e.meta||{}))w.startsWith("_")||(c[w]=C);let u={type:"element",tagName:"pre",properties:c,children:[]},h={type:"element",tagName:"code",properties:{},children:o};const f=[],d={...n,structure:i,addClassToHast:us,get source(){return n.source},get tokens(){return t},get options(){return e},get root(){return a},get pre(){return u},get code(){return h},get lines(){return f}};if(t.forEach((w,C)=>{C&&(i==="inline"?a.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&o.push({type:"text",value:`
|
|
152
152
|
`}));let g={type:"element",tagName:"span",properties:{class:"line"},children:[]},y=0;for(const m of w){let _={type:"element",tagName:"span",properties:{...m.htmlAttrs},children:[{type:"text",value:m.content}]};const S=Xt(m.htmlStyle||tt(m));S&&(_.properties.style=S);for(const E of s)_=E?.span?.call(d,_,C+1,y,g,m)||_;i==="inline"?a.children.push(_):i==="classic"&&g.children.push(_),y+=m.content.length}if(i==="classic"){for(const m of s)g=m?.line?.call(d,g,C+1)||g;f.push(g),o.push(g)}else i==="inline"&&f.push(g)}),i==="classic"){for(const w of s)h=w?.code?.call(d,h)||h;u.children.push(h);for(const w of s)u=w?.pre?.call(d,u)||u;a.children.push(u)}else if(i==="inline"){const w=[];let C={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const m of a.children)m.type==="element"&&m.tagName==="br"?(w.push(C),C={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(m.type==="element"||m.type==="text")&&C.children.push(m);w.push(C);let y={type:"element",tagName:"code",properties:{},children:w};for(const m of s)y=m?.code?.call(d,y)||y;a.children=[];for(let m=0;m<y.children.length;m++){m>0&&a.children.push({type:"element",tagName:"br",properties:{},children:[]});const _=y.children[m];_.type==="element"&&a.children.push(..._.children)}}let p=a;for(const w of s)p=w?.root?.call(d,p)||p;return r&&ut(p,r),p}function Dl(t){return t.map(e=>{const n=[];let r="",s;return e.forEach((o,a)=>{const l=!(o.fontStyle&&(o.fontStyle&M.Underline||o.fontStyle&M.Strikethrough));l&&o.content.match(/^\s+$/)&&e[a+1]?(s===void 0&&(s=o.offset),r+=o.content):r?(l?n.push({...o,offset:s,content:r+o.content}):n.push({content:r,offset:s},o),s=void 0,r=""):n.push(o)}),n})}function Bl(t){return t.map(e=>e.flatMap(n=>{if(n.content.match(/^\s+$/))return n;const r=n.content.match(/^(\s*)(.*?)(\s*)$/);if(!r)return n;const[,s,o,a]=r;if(!s&&!a)return n;const i=[{...n,offset:n.offset+s.length,content:o}];return s&&i.unshift({content:s,offset:n.offset}),a&&i.push({content:a,offset:n.offset+s.length+o.length}),i}))}function Fl(t){return t.map(e=>{const n=[];for(const r of e){if(n.length===0){n.push({...r});continue}const s=n[n.length-1],o=Xt(s.htmlStyle||tt(s)),a=Xt(r.htmlStyle||tt(r)),i=s.fontStyle&&(s.fontStyle&M.Underline||s.fontStyle&M.Strikethrough),l=r.fontStyle&&(r.fontStyle&M.Underline||r.fontStyle&M.Strikethrough);!i&&!l&&o===a?s.content+=r.content:n.push({...r})}return n})}const jl=ol;function Ul(t,e,n){const r={meta:{},options:n,codeToHast:(o,a)=>ot(t,o,a),codeToTokens:(o,a)=>st(t,o,a)};let s=jl(ot(t,e,n,r));for(const o of nt(n))s=o.postprocess?.call(r,s,n)||s;return s}const Jn={light:"#333333",dark:"#bbbbbb"},er={light:"#fffffe",dark:"#1e1e1e"},tr="__shiki_resolved";function hn(t){if(t?.[tr])return t;const e={...t};e.tokenColors&&!e.settings&&(e.settings=e.tokenColors,delete e.tokenColors),e.type||="dark",e.colorReplacements={...e.colorReplacements},e.settings||=[];let{bg:n,fg:r}=e;if(!n||!r){const i=e.settings?e.settings.find(l=>!l.name&&!l.scope):void 0;i?.settings?.foreground&&(r=i.settings.foreground),i?.settings?.background&&(n=i.settings.background),!r&&e?.colors?.["editor.foreground"]&&(r=e.colors["editor.foreground"]),!n&&e?.colors?.["editor.background"]&&(n=e.colors["editor.background"]),r||(r=e.type==="light"?Jn.light:Jn.dark),n||(n=e.type==="light"?er.light:er.dark),e.fg=r,e.bg=n}e.settings[0]&&e.settings[0].settings&&!e.settings[0].scope||e.settings.unshift({settings:{foreground:e.fg,background:e.bg}});let s=0;const o=new Map;function a(i){if(o.has(i))return o.get(i);s+=1;const l=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;return e.colorReplacements?.[`#${l}`]?a(i):(o.set(i,l),l)}e.settings=e.settings.map(i=>{const l=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),c=i.settings?.background&&!i.settings.background.startsWith("#");if(!l&&!c)return i;const u={...i,settings:{...i.settings}};if(l){const h=a(i.settings.foreground);e.colorReplacements[h]=i.settings.foreground,u.settings.foreground=h}if(c){const h=a(i.settings.background);e.colorReplacements[h]=i.settings.background,u.settings.background=h}return u});for(const i of Object.keys(e.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!e.colors[i]?.startsWith("#")){const l=a(e.colors[i]);e.colorReplacements[l]=e.colors[i],e.colors[i]=l}return Object.defineProperty(e,tr,{enumerable:!1,writable:!1,value:!0}),e}async function zl(t){return Array.from(new Set((await Promise.all(t.filter(e=>!cl(e)).map(async e=>await cs(e).then(n=>Array.isArray(n)?n:[n])))).flat()))}async function Wl(t){return(await Promise.all(t.map(async n=>ul(n)?null:hn(await cs(n))))).filter(n=>!!n)}class fe extends Error{constructor(e){super(e),this.name="ShikiError"}}function ps(t,e){if(!e)return t;if(e[t]){const n=new Set([t]);for(;e[t];){if(t=e[t],n.has(t))throw new fe(`Circular alias \`${Array.from(n).join(" -> ")} -> ${t}\``);n.add(t)}}return t}class ql extends qa{constructor(e,n,r,s={}){super(e),this._resolver=e,this._themes=n,this._langs=r,this._alias=s,this._themes.map(o=>this.loadTheme(o)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const n=hn(e);return n.name&&(this._resolvedThemes.set(n.name,n),this._loadedThemesCache=null),n}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let n=this._textmateThemeCache.get(e);n||(n=Ke.createFromRawTheme(e),this._textmateThemeCache.set(e,n)),this._syncRegistry.setTheme(n)}getGrammar(e){return e=ps(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const n=new Set([...this._langMap.values()].filter(o=>o.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const r={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const s=this.loadGrammarWithConfiguration(e.scopeName,1,r);if(s.name=e.name,this._resolvedGrammars.set(e.name,s),e.aliases&&e.aliases.forEach(o=>{this._alias[o]=e.name}),this._loadedLanguagesCache=null,n.size)for(const o of n)this._resolvedGrammars.delete(o.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(o.scopeName),this._syncRegistry?._grammars?.delete(o.scopeName),this.loadLanguage(this._langMap.get(o.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const s of e)this.resolveEmbeddedLanguages(s);const n=Array.from(this._langGraph.entries()),r=n.filter(([s,o])=>!o);if(r.length){const s=n.filter(([o,a])=>a?(a.embeddedLanguages||a.embeddedLangs)?.some(l=>r.map(([c])=>c).includes(l)):!1).filter(o=>!r.includes(o));throw new fe(`Missing languages ${r.map(([o])=>`\`${o}\``).join(", ")}, required by ${s.map(([o])=>`\`${o}\``).join(", ")}`)}for(const[s,o]of n)this._resolver.addLanguage(o);for(const[s,o]of n)this.loadLanguage(o)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);const n=e.embeddedLanguages??e.embeddedLangs;if(n)for(const r of n)this._langGraph.set(r,this._langMap.get(r))}}class Hl{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,n){this._onigLib={createOnigScanner:r=>e.createScanner(r),createOnigString:r=>e.createString(r)},n.forEach(r=>this.addLanguage(r))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(n=>{this._langs.set(n,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(n=>{this._injections.get(n)||this._injections.set(n,[]),this._injections.get(n).push(e.scopeName)})}getInjections(e){const n=e.split(".");let r=[];for(let s=1;s<=n.length;s++){const o=n.slice(0,s).join(".");r=[...r,...this._injections.get(o)||[]]}return r}}let Se=0;function Vl(t){Se+=1,t.warnings!==!1&&Se>=10&&Se%10===0&&console.warn(`[Shiki] ${Se} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let e=!1;if(!t.engine)throw new fe("`engine` option is required for synchronous mode");const n=(t.langs||[]).flat(1),r=(t.themes||[]).flat(1).map(hn),s=new Hl(t.engine,n),o=new ql(s,r,n,t.langAlias);let a;function i(m){return ps(m,t.langAlias)}function l(m){g();const _=o.getGrammar(typeof m=="string"?m:m.name);if(!_)throw new fe(`Language \`${m}\` not found, you may need to load it first`);return _}function c(m){if(m==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};g();const _=o.getTheme(m);if(!_)throw new fe(`Theme \`${m}\` not found, you may need to load it first`);return _}function u(m){g();const _=c(m);a!==m&&(o.setTheme(_),a=m);const S=o.getColorMap();return{theme:_,colorMap:S}}function h(){return g(),o.getLoadedThemes()}function f(){return g(),o.getLoadedLanguages()}function d(...m){g(),o.loadLanguages(m.flat(1))}async function p(...m){return d(await zl(m))}function w(...m){g();for(const _ of m.flat(1))o.loadTheme(_)}async function C(...m){return g(),w(await Wl(m))}function g(){if(e)throw new fe("Shiki instance has been disposed")}function y(){e||(e=!0,o.dispose(),Se-=1)}return{setTheme:u,getTheme:c,getLanguage:l,getLoadedThemes:h,getLoadedLanguages:f,resolveLangAlias:i,loadLanguage:p,loadLanguageSync:d,loadTheme:C,loadThemeSync:w,dispose:y,[Symbol.dispose]:y}}function Xl(t){const e=Vl(t);return{getLastGrammarState:(...n)=>Nl(e,...n),codeToTokensBase:(n,r)=>un(e,n,r),codeToTokensWithThemes:(n,r)=>ds(e,n,r),codeToTokens:(n,r)=>st(e,n,r),codeToHast:(n,r)=>ot(e,n,r),codeToHtml:(n,r)=>Ul(e,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...e,getInternalContext:()=>e}}class gs{diff(e,n,r={}){let s;typeof r=="function"?(s=r,r={}):"callback"in r&&(s=r.callback);const o=this.castInput(e,r),a=this.castInput(n,r),i=this.removeEmpty(this.tokenize(o,r)),l=this.removeEmpty(this.tokenize(a,r));return this.diffWithOptionsObj(i,l,r,s)}diffWithOptionsObj(e,n,r,s){var o;const a=y=>{if(y=this.postProcess(y,r),s){setTimeout(function(){s(y)},0);return}else return y},i=n.length,l=e.length;let c=1,u=i+l;r.maxEditLength!=null&&(u=Math.min(u,r.maxEditLength));const h=(o=r.timeout)!==null&&o!==void 0?o:1/0,f=Date.now()+h,d=[{oldPos:-1,lastComponent:void 0}];let p=this.extractCommon(d[0],n,e,0,r);if(d[0].oldPos+1>=l&&p+1>=i)return a(this.buildValues(d[0].lastComponent,n,e));let w=-1/0,C=1/0;const g=()=>{for(let y=Math.max(w,-c);y<=Math.min(C,c);y+=2){let m;const _=d[y-1],S=d[y+1];_&&(d[y-1]=void 0);let E=!1;if(S){const B=S.oldPos-y;E=S&&0<=B&&B<i}const L=_&&_.oldPos+1<l;if(!E&&!L){d[y]=void 0;continue}if(!L||E&&_.oldPos<S.oldPos?m=this.addToPath(S,!0,!1,0,r):m=this.addToPath(_,!1,!0,1,r),p=this.extractCommon(m,n,e,y,r),m.oldPos+1>=l&&p+1>=i)return a(this.buildValues(m.lastComponent,n,e))||!0;d[y]=m,m.oldPos+1>=l&&(C=Math.min(C,y-1)),p+1>=i&&(w=Math.max(w,y+1))}c++};if(s)(function y(){setTimeout(function(){if(c>u||Date.now()>f)return s(void 0);g()||y()},0)})();else for(;c<=u&&Date.now()<=f;){const y=g();if(y)return y}}addToPath(e,n,r,s,o){const a=e.lastComponent;return a&&!o.oneChangePerToken&&a.added===n&&a.removed===r?{oldPos:e.oldPos+s,lastComponent:{count:a.count+1,added:n,removed:r,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+s,lastComponent:{count:1,added:n,removed:r,previousComponent:a}}}extractCommon(e,n,r,s,o){const a=n.length,i=r.length;let l=e.oldPos,c=l-s,u=0;for(;c+1<a&&l+1<i&&this.equals(r[l+1],n[c+1],o);)c++,l++,u++,o.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return u&&!o.oneChangePerToken&&(e.lastComponent={count:u,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=l,c}equals(e,n,r){return r.comparator?r.comparator(e,n):e===n||!!r.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let r=0;r<e.length;r++)e[r]&&n.push(e[r]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,r){const s=[];let o;for(;e;)s.push(e),o=e.previousComponent,delete e.previousComponent,e=o;s.reverse();const a=s.length;let i=0,l=0,c=0;for(;i<a;i++){const u=s[i];if(u.removed)u.value=this.join(r.slice(c,c+u.count)),c+=u.count;else{if(!u.added&&this.useLongestToken){let h=n.slice(l,l+u.count);h=h.map(function(f,d){const p=r[c+d];return p.length>f.length?p:f}),u.value=this.join(h)}else u.value=this.join(n.slice(l,l+u.count));l+=u.count,u.added||(c+=u.count)}}return s}}class Kl extends gs{}const Zl=new Kl;function Ql(t,e,n){return Zl.diff(t,e,n)}const nr="a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";class Yl extends gs{tokenize(e){const n=new RegExp(`(\\r?\\n)|[${nr}]+|[^\\S\\n\\r]+|[^${nr}]`,"ug");return e.match(n)||[]}}const Jl=new Yl;function ec(t,e,n){return Jl.diff(t,e,n)}function tc(t={}){const{classPrefix:e="__shiki_",classSuffix:n="",classReplacer:r=i=>i}=t,s=new Map;function o(i){return Object.entries(i).map(([l,c])=>`${l}:${c}`).join(";")}function a(i){const l=typeof i=="string"?i:o(i);let c=e+nc(l)+n;return c=r(c),s.has(c)||s.set(c,typeof i=="string"?i:{...i}),c}return{name:"@shikijs/transformers:style-to-class",pre(i){if(!i.properties.style)return;const l=a(i.properties.style);delete i.properties.style,this.addClassToHast(i,l)},tokens(i){for(const l of i)for(const c of l){if(!c.htmlStyle)continue;const u=a(c.htmlStyle);c.htmlStyle={},c.htmlAttrs||={},c.htmlAttrs.class?c.htmlAttrs.class+=` ${u}`:c.htmlAttrs.class=u}},getClassRegistry(){return s},getCSS(){let i="";for(const[l,c]of s.entries())i+=`.${l}{${typeof c=="string"?c:o(c)}}`;return i},clearRegistry(){s.clear()}}}function nc(t,e=0){let n=3735928559^e,r=1103547991^e;for(let s=0,o;s<t.length;s++)o=t.charCodeAt(s),n=Math.imul(n^o,2654435761),r=Math.imul(r^o,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&r)+(n>>>0)).toString(36).slice(0,6)}const Oe={dark:"pierre-dark",light:"pierre-light"},rr=new Map,sr=new Set;function fn(t,e){t=Array.isArray(t)?t:[t];for(const n of t){if(sr.has(n.name))continue;let r=rr.get(n.name);r==null&&(r=n,rr.set(n.name,r)),sr.add(r.name),e.loadLanguageSync(r.data)}}const It=new Map,or=new Set;function ms(t,e){t=Array.isArray(t)?t:[t];for(let n of t){let r;if(typeof n=="string"){if(r=It.get(n),r==null)throw new Error(`loadResolvedThemes: ${n} is not resolved, you must resolve it before calling loadResolvedThemes`)}else r=n,n=n.name,It.has(n)||It.set(n,r);or.has(n)||(or.add(n),e.loadThemeSync(r))}}function Pe(t){return t.replace(/\n$|\r\n$/,"")}function rc(t){return{type:"text",value:t}}function Rt({tagName:t,children:e=[],properties:n={}}){return{type:"element",tagName:t,properties:n,children:e}}function sc(t){let e=t.children[0];for(;e!=null;){if(e.type==="element"&&e.tagName==="code")return e;"children"in e?e=e.children[0]:e=null}}function oc(t,e,n){const r=typeof n.lineInfo=="function"?n.lineInfo(e):n.lineInfo[e];if(r==null)throw console.error({node:t,line:e,state:n}),new Error(`processLine: line ${e}, contains no state.lineInfo`);return t.tagName="span",t.properties["data-column-content"]="",t.children.length===0&&t.children.push(rc(`
|
|
153
|
-
`)),Rt({tagName:"div",children:[Rt({tagName:"span",children:[Rt({tagName:"span",children:[{type:"text",value:`${r.lineNumber}`}],properties:{"data-line-number-content":""}})],properties:{"data-column-number":""}}),t],properties:{"data-line":r.lineNumber,"data-alt-line":r.altLineNumber,"data-line-type":r.type,"data-line-index":r.lineIndex}})}function ys(t=!1){const e={lineInfo:{}},n=[{line(r){return delete r.properties.class,r},pre(r){const s=sc(r),o=[];if(s!=null){let a=1;for(const i of s.children)i.type==="element"&&(o.push(oc(i,a,e)),a++);s.children=o}return r}}];return t&&n.push(ac,ar),{state:e,transformers:n,toClass:ar}}const ar=tc({classPrefix:"hl-"}),ac={name:"token-style-normalizer",tokens(t){for(const e of t)for(const n of e){if(n.htmlStyle!=null)continue;const r={};n.color!=null&&(r.color=n.color),n.bgColor!=null&&(r["background-color"]=n.bgColor),n.fontStyle!=null&&n.fontStyle!==0&&((n.fontStyle&1)!==0&&(r["font-style"]="italic"),(n.fontStyle&2)!==0&&(r["font-weight"]="bold"),(n.fontStyle&4)!==0&&(r["text-decoration"]="underline")),Object.keys(r).length>0&&(n.htmlStyle=r)}}};function D(t="diffs"){return`--${t}-`}const ke={"1c":"1c",abap:"abap",as:"actionscript-3",ada:"ada",adb:"ada",ads:"ada",adoc:"asciidoc",asciidoc:"asciidoc","component.html":"angular-html","component.ts":"angular-ts",conf:"nginx",htaccess:"apache",cls:"tex",trigger:"apex",apl:"apl",applescript:"applescript",scpt:"applescript",ara:"ara",asm:"asm",s:"riscv",astro:"astro",awk:"awk",bal:"ballerina",sh:"zsh",bash:"zsh",bat:"cmd",cmd:"cmd",be:"berry",beancount:"beancount",bib:"bibtex",bicep:"bicep","blade.php":"blade",bsl:"bsl",c:"c",h:"objective-cpp",cs:"csharp",cpp:"cpp",hpp:"cpp",cc:"cpp",cxx:"cpp",hh:"cpp",cdc:"cdc",cairo:"cairo",clar:"clarity",clj:"clojure",cljs:"clojure",cljc:"clojure",soy:"soy",cmake:"cmake","CMakeLists.txt":"cmake",cob:"cobol",cbl:"cobol",cobol:"cobol",CODEOWNERS:"codeowners",ql:"ql",coffee:"coffeescript",lisp:"lisp",cl:"lisp",lsp:"lisp",log:"log",v:"verilog",cql:"cql",cr:"crystal",css:"css",csv:"csv",cue:"cue",cypher:"cypher",cyp:"cypher",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",patch:"diff",Dockerfile:"dockerfile",dockerfile:"dockerfile",env:"dotenv",dm:"dream-maker",edge:"edge",el:"emacs-lisp",ex:"elixir",exs:"elixir",elm:"elm",erb:"erb",erl:"erlang",hrl:"erlang",f:"fortran-fixed-form",for:"fortran-fixed-form",fs:"fsharp",fsi:"fsharp",fsx:"fsharp",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"fortran-free-form",f95:"fortran-free-form",fnl:"fennel",fish:"fish",ftl:"ftl",tres:"gdresource",res:"gdresource",gd:"gdscript",gdshader:"gdshader",gs:"genie",feature:"gherkin",COMMIT_EDITMSG:"git-commit","git-rebase-todo":"git-rebase",gjs:"glimmer-js",gleam:"gleam",gts:"glimmer-ts",glsl:"glsl",vert:"glsl",frag:"glsl",shader:"shaderlab",gp:"gnuplot",plt:"gnuplot",gnuplot:"gnuplot",go:"go",graphql:"graphql",gql:"graphql",groovy:"groovy",gvy:"groovy",hack:"hack",haml:"haml",hbs:"handlebars",handlebars:"handlebars",hs:"haskell",lhs:"haskell",hx:"haxe",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",fx:"hlsl",html:"html",htm:"html",http:"http",rest:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",cfg:"ini",jade:"pug",pug:"pug",java:"java",js:"javascript",mjs:"javascript",cjs:"javascript",jinja:"jinja",jinja2:"jinja",j2:"jinja",jison:"jison",jl:"julia",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",libsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",kt:"kotlin",kts:"kts",kql:"kusto",tex:"tex",ltx:"tex",lean:"lean4",less:"less",liquid:"liquid",lit:"lit",ll:"llvm",logo:"logo",lua:"lua",luau:"luau",Makefile:"makefile",mk:"makefile",makefile:"makefile",md:"markdown",markdown:"markdown",marko:"marko",m:"wolfram",mat:"matlab",mdc:"mdc",mdx:"mdx",wiki:"wikitext",mediawiki:"wikitext",mmd:"mermaid",mermaid:"mermaid",mips:"mipsasm",mojo:"mojo","🔥":"mojo",move:"move",nar:"narrat",nf:"nextflow",nim:"nim",nims:"nim",nimble:"nim",nix:"nix",nu:"nushell",mm:"objective-cpp",ml:"ocaml",mli:"ocaml",mll:"ocaml",mly:"ocaml",pas:"pascal",p:"pascal",pl:"prolog",pm:"perl",t:"perl",raku:"raku",p6:"raku",pl6:"raku",php:"php",phtml:"php",pls:"plsql",sql:"sql",po:"po",polar:"polar",pcss:"postcss",pot:"pot",potx:"potx",pq:"powerquery",pqm:"powerquery",ps1:"powershell",psm1:"powershell",psd1:"powershell",prisma:"prisma",pro:"prolog",P:"prolog",properties:"properties",proto:"protobuf",pp:"puppet",purs:"purescript",py:"python",pyw:"python",pyi:"python",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",R:"r",rkt:"racket",rktl:"racket",razor:"razor",cshtml:"razor",rb:"ruby",rbw:"ruby",reg:"reg",regex:"regexp",rel:"rel",rs:"rust",rst:"rst",rake:"ruby",gemspec:"ruby",sas:"sas",sass:"sass",scala:"scala",sc:"scala",scm:"scheme",ss:"scheme",sld:"scheme",scss:"scss",sdbl:"sdbl",shadergraph:"shader",st:"smalltalk",sol:"solidity",sparql:"sparql",rq:"sparql",spl:"splunk",config:"ssh-config",do:"stata",ado:"stata",dta:"stata",styl:"stylus",stylus:"stylus",svelte:"svelte",swift:"swift",sv:"system-verilog",svh:"system-verilog",service:"systemd",socket:"systemd",device:"systemd",timer:"systemd",talon:"talonscript",tasl:"tasl",tcl:"tcl",templ:"templ",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"typescript",tsp:"typespec",tsv:"tsv",tsx:"tsx",ttl:"turtle",twig:"twig",typ:"typst",vv:"v",vala:"vala",vapi:"vala",vb:"vb",vbs:"vb",bas:"vb",vh:"verilog",vhd:"vhdl",vhdl:"vhdl",vim:"vimscript",vue:"vue","vine.ts":"vue-vine",vy:"vyper",wasm:"wasm",wat:"wasm",wy:"文言",wgsl:"wgsl",wit:"wit",wl:"wolfram",nb:"wolfram",xml:"xml",xsl:"xsl",xslt:"xsl",yaml:"yaml",yml:"yml",zs:"zenscript",zig:"zig",zsh:"zsh",sty:"tex"};function Kt(t){if(ke[t]!=null)return ke[t];const e=t.match(/\.([^/\\]+\.[^/\\]+)$/);return e!=null&&ke[e[1]]!=null?ke[e[1]]??"text":ke[t.match(/\.([^.]+)$/)?.[1]??""]??"text"}function bs({theme:t=Oe,highlighter:e,prefix:n}){let r="";if(typeof t=="string"){const s=e.getTheme(t);r+=`color:${s.fg};`,r+=`background-color:${s.bg};`,r+=`${D(n)}fg:${s.fg};`,r+=`${D(n)}bg:${s.bg};`,r+=Nt(s,n)}else{let s=e.getTheme(t.dark);r+=`${D(n)}dark:${s.fg};`,r+=`${D(n)}dark-bg:${s.bg};`,r+=Nt(s,n,"dark"),s=e.getTheme(t.light),r+=`${D(n)}light:${s.fg};`,r+=`${D(n)}light-bg:${s.bg};`,r+=Nt(s,n,"light")}return r}function Nt(t,e,n){n=n!=null?`${n}-`:"";let r="";const s=t.colors?.["gitDecoration.addedResourceForeground"]??t.colors?.["terminal.ansiGreen"];s!=null&&(r+=`${D(e)}${n}addition-color:${s};`);const o=t.colors?.["gitDecoration.deletedResourceForeground"]??t.colors?.["terminal.ansiRed"];o!=null&&(r+=`${D(e)}${n}deletion-color:${o};`);const a=t.colors?.["gitDecoration.modifiedResourceForeground"]??t.colors?.["terminal.ansiBlue"];return a!=null&&(r+=`${D(e)}${n}modified-color:${a};`),r}function Zt(t){let e=t.children[0];for(;e!=null;){if(e.type==="element"&&e.tagName==="code")return e.children;"children"in e?e=e.children[0]:e=null}throw console.error(t),new Error("getLineNodes: Unable to find children")}function ir({line:t,spanStart:e,spanLength:n}){return{start:{line:t,character:e},end:{line:t,character:e+n},properties:{"data-diff-span":""},alwaysWrap:!0}}function We({item:t,arr:e,enableJoin:n,isNeutral:r=!1,isLastItem:s=!1}){const o=e[e.length-1];if(o==null||s||!n){e.push([r?0:1,t.value]);return}const a=o[0]===0;if(r===a||r&&t.value.length===1&&!a){o[1]+=t.value;return}e.push([r?0:1,t.value])}function ic(t,e,n,r=!1){const s=(()=>{const c=n.theme??Oe;if(typeof c=="string")return e.getTheme(c).type})(),o=bs({theme:n.theme,highlighter:e});if(t.newLines!=null&&t.oldLines!=null){const{oldContent:c,newContent:u,oldInfo:h,newInfo:f,oldDecorations:d,newDecorations:p}=lr({hunks:t.hunks,oldLines:t.oldLines,newLines:t.newLines,lineDiffType:n.lineDiffType});return{code:cr({oldFile:{name:t.prevName??t.name,contents:c},oldInfo:h,oldDecorations:d,newFile:{name:t.name,contents:u},newInfo:f,newDecorations:p,highlighter:e,options:n,languageOverride:r?"text":t.lang}),themeStyles:o,baseThemeType:s}}const a=[];let i=0,l=0;for(const c of t.hunks){const{oldContent:u,newContent:h,oldInfo:f,newInfo:d,oldDecorations:p,newDecorations:w,splitLineIndex:C,unifiedLineIndex:g}=lr({hunks:[c],splitLineIndex:i,unifiedLineIndex:l,lineDiffType:n.lineDiffType}),y={name:t.prevName??t.name,contents:u},m={name:t.name,contents:h};a.push(cr({oldFile:y,oldInfo:f,oldDecorations:p,newFile:m,newInfo:d,newDecorations:w,highlighter:e,options:n,languageOverride:r?"text":t.lang})),i=C,l=g}return{code:(()=>{if(a.length<=1){const c=a[0]??{oldLines:[],newLines:[]};if(c.newLines.length===0||c.oldLines.length===0)return c}return{hunks:a}})(),themeStyles:o,baseThemeType:s}}function lc({oldLine:t,newLine:e,oldLineIndex:n,newLineIndex:r,oldDecorations:s,newDecorations:o,lineDiffType:a}){if(t==null||e==null||a==="none")return;t=Pe(t),e=Pe(e);const i=a==="char"?Ql(t,e):ec(t,e),l=[],c=[],u=a==="word-alt";for(const f of i){const d=f===i[i.length-1];!f.added&&!f.removed?(We({item:f,arr:l,enableJoin:u,isNeutral:!0,isLastItem:d}),We({item:f,arr:c,enableJoin:u,isNeutral:!0,isLastItem:d})):f.removed?We({item:f,arr:l,enableJoin:u,isLastItem:d}):We({item:f,arr:c,enableJoin:u,isLastItem:d})}let h=0;for(const f of l)f[0]===1&&s.push(ir({line:n-1,spanStart:h,spanLength:f[1].length})),h+=f[1].length;h=0;for(const f of c)f[0]===1&&o.push(ir({line:r-1,spanStart:h,spanLength:f[1].length})),h+=f[1].length}function lr({hunks:t,oldLines:e,newLines:n,splitLineIndex:r=0,unifiedLineIndex:s=0,lineDiffType:o}){const a={},i={},l=[],c=[];let u=1,h=1,f=1,d=1,p="",w="";for(const C of t){for(;e!=null&&n!=null&&u<C.additionStart&&h<C.deletionStart;)a[h]={type:"context-expanded",lineNumber:d,altLineNumber:f,lineIndex:`${s},${r}`},i[u]={type:"context-expanded",lineNumber:f,altLineNumber:d,lineIndex:`${s},${r}`},p+=e[h-1],w+=n[u-1],h++,u++,d++,f++,r++,s++;d=C.deletionStart,f=C.additionStart;for(const g of C.hunkContent)if(g.type==="context")for(const y of g.lines)a[h]={type:"context",lineNumber:d,altLineNumber:f,lineIndex:`${s},${r}`},i[u]={type:"context",lineNumber:f,altLineNumber:d,lineIndex:`${s},${r}`},p+=y,w+=y,h++,u++,f++,d++,r++,s++;else{const y=Math.max(g.additions.length,g.deletions.length);let m=0,_=s;for(;m<y;){const S=g.deletions[m],E=g.additions[m];lc({newLine:E,oldLine:S,oldLineIndex:h,newLineIndex:u,oldDecorations:l,newDecorations:c,lineDiffType:o}),S!=null&&(a[h]={type:"change-deletion",lineNumber:d,lineIndex:`${_},${r}`},p+=S,h++,d++),E!=null&&(i[u]={type:"change-addition",lineNumber:f,lineIndex:`${_+g.deletions.length},${r}`},w+=E,u++,f++),r++,_++,m++}s+=g.additions.length+g.deletions.length}if(!(e==null||n==null||C!==t[t.length-1]))for(;h<=e.length||u<=e.length;){const g=e[h-1],y=n[u-1];if(g==null&&y==null)break;g!=null&&(a[h]={type:"context-expanded",lineNumber:d,altLineNumber:f,lineIndex:`${s},${r}`},p+=g,h++,d++),y!=null&&(i[u]={type:"context-expanded",lineNumber:f,altLineNumber:d,lineIndex:`${s},${r}`},w+=y,u++,f++),r++,s++}}return{oldContent:Pe(p),newContent:Pe(w),oldInfo:a,newInfo:i,oldDecorations:l,newDecorations:c,splitLineIndex:r,unifiedLineIndex:s}}function cr({oldFile:t,newFile:e,oldInfo:n,newInfo:r,highlighter:s,oldDecorations:o,newDecorations:a,languageOverride:i,options:{theme:l=Oe,...c}}){const u=i??Kt(t.name),h=i??Kt(e.name),{state:f,transformers:d}=ys(),p=typeof l=="string"?{...c,lang:"text",theme:l,transformers:d,decorations:void 0,defaultColor:!1,cssVariablePrefix:D()}:{...c,lang:"text",themes:l,transformers:d,decorations:void 0,defaultColor:!1,cssVariablePrefix:D()};return{oldLines:t.contents===""?[]:(p.lang=u,f.lineInfo=n,p.decorations=o,Zt(s.codeToHast(t.contents,p))),newLines:e.contents===""?[]:(p.lang=h,p.decorations=a,f.lineInfo=r,Zt(s.codeToHast(e.contents,p)))}}function cc(t,e,{theme:n=Oe,tokenizeMaxLineLength:r},s=!1){const{state:o,transformers:a}=ys(),i=s?"text":t.lang??Kt(t.name),l=(()=>{if(typeof n=="string")return e.getTheme(n).type})(),c=bs({theme:n,highlighter:e});o.lineInfo=h=>({type:"context",lineIndex:h-1,lineNumber:h});const u=typeof n=="string"?{lang:i,theme:n,transformers:a,defaultColor:!1,cssVariablePrefix:D(),tokenizeMaxLineLength:r}:{lang:i,themes:n,transformers:a,defaultColor:!1,cssVariablePrefix:D(),tokenizeMaxLineLength:r};return{code:Zt(e.codeToHast(Pe(t.contents),u)),themeStyles:c,baseThemeType:l}}let ur,me={theme:Oe,tokenizeMaxLineLength:1e3,lineDiffType:"word-alt"};self.addEventListener("error",t=>{console.error("[Shiki Worker] Unhandled error:",t.error)});self.addEventListener("message",t=>{const e=t.data;try{switch(e.type){case"initialize":uc(e);break;case"set-render-options":hc(e);break;case"file":fc(e);break;case"diff":dc(e);break;default:throw new Error(`Unknown request type: ${e.type}`)}}catch(n){console.error("Worker error:",n),mc(e.id,n)}});function uc({id:t,renderOptions:e,resolvedThemes:n,resolvedLanguages:r}){const s=ht();ms(n,s),r!=null&&fn(r,s),me=e,postMessage({type:"success",id:t,requestType:"initialize",sentAt:Date.now()})}function hc({id:t,renderOptions:e,resolvedThemes:n}){ms(n,ht()),me=e,postMessage({type:"success",id:t,requestType:"set-render-options",sentAt:Date.now()})}function fc({id:t,file:e,resolvedLanguages:n}){const r=ht();n!=null&&fn(n,r);const s={theme:me.theme,tokenizeMaxLineLength:me.tokenizeMaxLineLength};pc(t,cc(e,r,s),s)}function dc({id:t,diff:e,resolvedLanguages:n}){const r=ht();n!=null&&fn(n,r),gc(t,ic(e,r,me),me)}function ht(){return ur??=Xl({themes:[],langs:[],engine:oa()}),ur}function pc(t,e,n){postMessage({type:"success",requestType:"file",id:t,result:e,options:n,sentAt:Date.now()})}function gc(t,e,n){postMessage({type:"success",requestType:"diff",id:t,result:e,options:n,sentAt:Date.now()})}function mc(t,e){const n={type:"error",id:t,error:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0};postMessage(n)}
|
|
153
|
+
`)),Rt({tagName:"div",children:[Rt({tagName:"span",children:[Rt({tagName:"span",children:[{type:"text",value:`${r.lineNumber}`}],properties:{"data-line-number-content":""}})],properties:{"data-column-number":""}}),t],properties:{"data-line":r.lineNumber,"data-alt-line":r.altLineNumber,"data-line-type":r.type,"data-line-index":r.lineIndex}})}function ys(t=!1){const e={lineInfo:{}},n=[{line(r){return delete r.properties.class,r},pre(r){const s=sc(r),o=[];if(s!=null){let a=1;for(const i of s.children)i.type==="element"&&(o.push(oc(i,a,e)),a++);s.children=o}return r}}];return t&&n.push(ac,ar),{state:e,transformers:n,toClass:ar}}const ar=tc({classPrefix:"hl-"}),ac={name:"token-style-normalizer",tokens(t){for(const e of t)for(const n of e){if(n.htmlStyle!=null)continue;const r={};n.color!=null&&(r.color=n.color),n.bgColor!=null&&(r["background-color"]=n.bgColor),n.fontStyle!=null&&n.fontStyle!==0&&((n.fontStyle&1)!==0&&(r["font-style"]="italic"),(n.fontStyle&2)!==0&&(r["font-weight"]="bold"),(n.fontStyle&4)!==0&&(r["text-decoration"]="underline")),Object.keys(r).length>0&&(n.htmlStyle=r)}}};function D(t="diffs"){return`--${t}-`}const ke={"1c":"1c",abap:"abap",as:"actionscript-3",ada:"ada",adb:"ada",ads:"ada",adoc:"asciidoc",asciidoc:"asciidoc","component.html":"angular-html","component.ts":"angular-ts",conf:"nginx",htaccess:"apache",cls:"tex",trigger:"apex",apl:"apl",applescript:"applescript",scpt:"applescript",ara:"ara",asm:"asm",s:"riscv",astro:"astro",awk:"awk",bal:"ballerina",sh:"zsh",bash:"zsh",bat:"cmd",cmd:"cmd",be:"berry",beancount:"beancount",bib:"bibtex",bicep:"bicep","blade.php":"blade",bsl:"bsl",c:"c",h:"objective-cpp",cs:"csharp",cpp:"cpp",hpp:"cpp",cc:"cpp",cxx:"cpp",hh:"cpp",cdc:"cdc",cairo:"cairo",clar:"clarity",clj:"clojure",cljs:"clojure",cljc:"clojure",soy:"soy",cmake:"cmake","CMakeLists.txt":"cmake",cob:"cobol",cbl:"cobol",cobol:"cobol",CODEOWNERS:"codeowners",ql:"ql",coffee:"coffeescript",lisp:"lisp",cl:"lisp",lsp:"lisp",log:"log",v:"verilog",cql:"cql",cr:"crystal",css:"css",csv:"csv",cue:"cue",cypher:"cypher",cyp:"cypher",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",patch:"diff",Dockerfile:"dockerfile",dockerfile:"dockerfile",env:"dotenv",dm:"dream-maker",edge:"edge",el:"emacs-lisp",ex:"elixir",exs:"elixir",elm:"elm",erb:"erb",erl:"erlang",hrl:"erlang",f:"fortran-fixed-form",for:"fortran-fixed-form",fs:"fsharp",fsi:"fsharp",fsx:"fsharp",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"fortran-free-form",f95:"fortran-free-form",fnl:"fennel",fish:"fish",ftl:"ftl",tres:"gdresource",res:"gdresource",gd:"gdscript",gdshader:"gdshader",gs:"genie",feature:"gherkin",COMMIT_EDITMSG:"git-commit","git-rebase-todo":"git-rebase",gjs:"glimmer-js",gleam:"gleam",gts:"glimmer-ts",glsl:"glsl",vert:"glsl",frag:"glsl",shader:"shaderlab",gp:"gnuplot",plt:"gnuplot",gnuplot:"gnuplot",go:"go",graphql:"graphql",gql:"graphql",groovy:"groovy",gvy:"groovy",hack:"hack",haml:"haml",hbs:"handlebars",handlebars:"handlebars",hs:"haskell",lhs:"haskell",hx:"haxe",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",fx:"hlsl",html:"html",htm:"html",http:"http",rest:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",cfg:"ini",jade:"pug",pug:"pug",java:"java",js:"javascript",mjs:"javascript",cjs:"javascript",jinja:"jinja",jinja2:"jinja",j2:"jinja",jison:"jison",jl:"julia",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",libsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",kt:"kotlin",kts:"kts",kql:"kusto",tex:"tex",ltx:"tex",lean:"lean4",less:"less",liquid:"liquid",lit:"lit",ll:"llvm",logo:"logo",lua:"lua",luau:"luau",Makefile:"makefile",mk:"makefile",makefile:"makefile",md:"markdown",markdown:"markdown",marko:"marko",m:"wolfram",mat:"matlab",mdc:"mdc",mdx:"mdx",wiki:"wikitext",mediawiki:"wikitext",mmd:"mermaid",mermaid:"mermaid",mips:"mipsasm",mojo:"mojo","🔥":"mojo",move:"move",nar:"narrat",nf:"nextflow",nim:"nim",nims:"nim",nimble:"nim",nix:"nix",nu:"nushell",mm:"objective-cpp",ml:"ocaml",mli:"ocaml",mll:"ocaml",mly:"ocaml",pas:"pascal",p:"pascal",pl:"prolog",pm:"perl",t:"perl",raku:"raku",p6:"raku",pl6:"raku",php:"php",phtml:"php",pls:"plsql",sql:"sql",po:"po",polar:"polar",pcss:"postcss",pot:"pot",potx:"potx",pq:"powerquery",pqm:"powerquery",ps1:"powershell",psm1:"powershell",psd1:"powershell",prisma:"prisma",pro:"prolog",P:"prolog",properties:"properties",proto:"protobuf",pp:"puppet",purs:"purescript",py:"python",pyw:"python",pyi:"python",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",R:"r",rkt:"racket",rktl:"racket",razor:"razor",cshtml:"razor",rb:"ruby",rbw:"ruby",reg:"reg",regex:"regexp",rel:"rel",rs:"rust",rst:"rst",rake:"ruby",gemspec:"ruby",sas:"sas",sass:"sass",scala:"scala",sc:"scala",scm:"scheme",ss:"scheme",sld:"scheme",scss:"scss",sdbl:"sdbl",shadergraph:"shader",st:"smalltalk",sol:"solidity",sparql:"sparql",rq:"sparql",spl:"splunk",config:"ssh-config",do:"stata",ado:"stata",dta:"stata",styl:"stylus",stylus:"stylus",svelte:"svelte",swift:"swift",sv:"system-verilog",svh:"system-verilog",service:"systemd",socket:"systemd",device:"systemd",timer:"systemd",talon:"talonscript",tasl:"tasl",tcl:"tcl",templ:"templ",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"typescript",tsp:"typespec",tsv:"tsv",tsx:"tsx",ttl:"turtle",twig:"twig",typ:"typst",vv:"v",vala:"vala",vapi:"vala",vb:"vb",vbs:"vb",bas:"vb",vh:"verilog",vhd:"vhdl",vhdl:"vhdl",vim:"vimscript",vue:"vue","vine.ts":"vue-vine",vy:"vyper",wasm:"wasm",wat:"wasm",wy:"文言",wgsl:"wgsl",wit:"wit",wl:"wolfram",nb:"wolfram",xml:"xml",xsl:"xsl",xslt:"xsl",yaml:"yaml",yml:"yml",zs:"zenscript",zig:"zig",zsh:"zsh",sty:"tex"};function Kt(t){if(ke[t]!=null)return ke[t];const e=t.match(/\.([^/\\]+\.[^/\\]+)$/);return e!=null&&ke[e[1]]!=null?ke[e[1]]??"text":ke[t.match(/\.([^.]+)$/)?.[1]??""]??"text"}function bs({theme:t=Oe,highlighter:e,prefix:n}){let r="";if(typeof t=="string"){const s=e.getTheme(t);r+=`color:${s.fg};`,r+=`background-color:${s.bg};`,r+=`${D(n)}fg:${s.fg};`,r+=`${D(n)}bg:${s.bg};`,r+=Nt(s,n)}else{let s=e.getTheme(t.dark);r+=`${D(n)}dark:${s.fg};`,r+=`${D(n)}dark-bg:${s.bg};`,r+=Nt(s,n,"dark"),s=e.getTheme(t.light),r+=`${D(n)}light:${s.fg};`,r+=`${D(n)}light-bg:${s.bg};`,r+=Nt(s,n,"light")}return r}function Nt(t,e,n){n=n!=null?`${n}-`:"";let r="";const s=t.colors?.["gitDecoration.addedResourceForeground"]??t.colors?.["terminal.ansiGreen"];s!=null&&(r+=`${D(e)}${n}addition-color:${s};`);const o=t.colors?.["gitDecoration.deletedResourceForeground"]??t.colors?.["terminal.ansiRed"];o!=null&&(r+=`${D(e)}${n}deletion-color:${o};`);const a=t.colors?.["gitDecoration.modifiedResourceForeground"]??t.colors?.["terminal.ansiBlue"];return a!=null&&(r+=`${D(e)}${n}modified-color:${a};`),r}function Zt(t){let e=t.children[0];for(;e!=null;){if(e.type==="element"&&e.tagName==="code")return e.children;"children"in e?e=e.children[0]:e=null}throw console.error(t),new Error("getLineNodes: Unable to find children")}function ir({line:t,spanStart:e,spanLength:n}){return{start:{line:t,character:e},end:{line:t,character:e+n},properties:{"data-diff-span":""},alwaysWrap:!0}}function We({item:t,arr:e,enableJoin:n,isNeutral:r=!1,isLastItem:s=!1}){const o=e[e.length-1];if(o==null||s||!n){e.push([r?0:1,t.value]);return}const a=o[0]===0;if(r===a||r&&t.value.length===1&&!a){o[1]+=t.value;return}e.push([r?0:1,t.value])}function ic(t,e,n,r=!1){const s=(()=>{const c=n.theme??Oe;if(typeof c=="string")return e.getTheme(c).type})(),o=bs({theme:n.theme,highlighter:e});if(t.newLines!=null&&t.oldLines!=null){const{oldContent:c,newContent:u,oldInfo:h,newInfo:f,oldDecorations:d,newDecorations:p}=lr({hunks:t.hunks,oldLines:t.oldLines,newLines:t.newLines,lineDiffType:n.lineDiffType});return{code:cr({oldFile:{name:t.prevName??t.name,contents:c},oldInfo:h,oldDecorations:d,newFile:{name:t.name,contents:u},newInfo:f,newDecorations:p,highlighter:e,options:n,languageOverride:r?"text":t.lang}),themeStyles:o,baseThemeType:s}}const a=[];let i=0,l=0;for(const c of t.hunks){const{oldContent:u,newContent:h,oldInfo:f,newInfo:d,oldDecorations:p,newDecorations:w,splitLineIndex:C,unifiedLineIndex:g}=lr({hunks:[c],splitLineIndex:i,unifiedLineIndex:l,lineDiffType:n.lineDiffType}),y={name:t.prevName??t.name,contents:u},m={name:t.name,contents:h};a.push(cr({oldFile:y,oldInfo:f,oldDecorations:p,newFile:m,newInfo:d,newDecorations:w,highlighter:e,options:n,languageOverride:r?"text":t.lang})),i=C,l=g}return{code:(()=>{if(a.length<=1){const c=a[0]??{oldLines:[],newLines:[]};if(c.newLines.length===0||c.oldLines.length===0)return c}return{hunks:a}})(),themeStyles:o,baseThemeType:s}}function lc({oldLine:t,newLine:e,oldLineIndex:n,newLineIndex:r,oldDecorations:s,newDecorations:o,lineDiffType:a}){if(t==null||e==null||a==="none")return;t=Pe(t),e=Pe(e);const i=a==="char"?Ql(t,e):ec(t,e),l=[],c=[],u=a==="word-alt";for(const f of i){const d=f===i[i.length-1];!f.added&&!f.removed?(We({item:f,arr:l,enableJoin:u,isNeutral:!0,isLastItem:d}),We({item:f,arr:c,enableJoin:u,isNeutral:!0,isLastItem:d})):f.removed?We({item:f,arr:l,enableJoin:u,isLastItem:d}):We({item:f,arr:c,enableJoin:u,isLastItem:d})}let h=0;for(const f of l)f[0]===1&&s.push(ir({line:n-1,spanStart:h,spanLength:f[1].length})),h+=f[1].length;h=0;for(const f of c)f[0]===1&&o.push(ir({line:r-1,spanStart:h,spanLength:f[1].length})),h+=f[1].length}function lr({hunks:t,oldLines:e,newLines:n,splitLineIndex:r=0,unifiedLineIndex:s=0,lineDiffType:o}){const a={},i={},l=[],c=[];let u=1,h=1,f=1,d=1,p="",w="";for(const C of t){for(;e!=null&&n!=null&&u<C.additionStart&&h<C.deletionStart;)a[h]={type:"context-expanded",lineNumber:d,altLineNumber:f,lineIndex:`${s},${r}`},i[u]={type:"context-expanded",lineNumber:f,altLineNumber:d,lineIndex:`${s},${r}`},p+=e[h-1],w+=n[u-1],h++,u++,d++,f++,r++,s++;d=C.deletionStart,f=C.additionStart;for(const g of C.hunkContent)if(g.type==="context")for(const y of g.lines)a[h]={type:"context",lineNumber:d,altLineNumber:f,lineIndex:`${s},${r}`},i[u]={type:"context",lineNumber:f,altLineNumber:d,lineIndex:`${s},${r}`},p+=y,w+=y,h++,u++,f++,d++,r++,s++;else{const y=Math.max(g.additions.length,g.deletions.length);let m=0,_=s;for(;m<y;){const S=g.deletions[m],E=g.additions[m];lc({newLine:E,oldLine:S,oldLineIndex:h,newLineIndex:u,oldDecorations:l,newDecorations:c,lineDiffType:o}),S!=null&&(a[h]={type:"change-deletion",lineNumber:d,lineIndex:`${_},${r}`},p+=S,h++,d++),E!=null&&(i[u]={type:"change-addition",lineNumber:f,lineIndex:`${_+g.deletions.length},${r}`},w+=E,u++,f++),r++,_++,m++}s+=g.additions.length+g.deletions.length}if(!(e==null||n==null||C!==t[t.length-1]))for(;h<=e.length||u<=e.length;){const g=e[h-1],y=n[u-1];if(g==null&&y==null)break;g!=null&&(a[h]={type:"context-expanded",lineNumber:d,altLineNumber:f,lineIndex:`${s},${r}`},p+=g,h++,d++),y!=null&&(i[u]={type:"context-expanded",lineNumber:f,altLineNumber:d,lineIndex:`${s},${r}`},w+=y,u++,f++),r++,s++}}return{oldContent:p,newContent:w,oldInfo:a,newInfo:i,oldDecorations:l,newDecorations:c,splitLineIndex:r,unifiedLineIndex:s}}function cr({oldFile:t,newFile:e,oldInfo:n,newInfo:r,highlighter:s,oldDecorations:o,newDecorations:a,languageOverride:i,options:{theme:l=Oe,...c}}){const u=i??Kt(t.name),h=i??Kt(e.name),{state:f,transformers:d}=ys(),p=typeof l=="string"?{...c,lang:"text",theme:l,transformers:d,decorations:void 0,defaultColor:!1,cssVariablePrefix:D()}:{...c,lang:"text",themes:l,transformers:d,decorations:void 0,defaultColor:!1,cssVariablePrefix:D()};return{oldLines:t.contents===""?[]:(p.lang=u,f.lineInfo=n,p.decorations=o,Zt(s.codeToHast(Pe(t.contents),p))),newLines:e.contents===""?[]:(p.lang=h,p.decorations=a,f.lineInfo=r,Zt(s.codeToHast(Pe(e.contents),p)))}}function cc(t,e,{theme:n=Oe,tokenizeMaxLineLength:r},s=!1){const{state:o,transformers:a}=ys(),i=s?"text":t.lang??Kt(t.name),l=(()=>{if(typeof n=="string")return e.getTheme(n).type})(),c=bs({theme:n,highlighter:e});o.lineInfo=h=>({type:"context",lineIndex:h-1,lineNumber:h});const u=typeof n=="string"?{lang:i,theme:n,transformers:a,defaultColor:!1,cssVariablePrefix:D(),tokenizeMaxLineLength:r}:{lang:i,themes:n,transformers:a,defaultColor:!1,cssVariablePrefix:D(),tokenizeMaxLineLength:r};return{code:Zt(e.codeToHast(Pe(t.contents),u)),themeStyles:c,baseThemeType:l}}let ur,me={theme:Oe,tokenizeMaxLineLength:1e3,lineDiffType:"word-alt"};self.addEventListener("error",t=>{console.error("[Shiki Worker] Unhandled error:",t.error)});self.addEventListener("message",t=>{const e=t.data;try{switch(e.type){case"initialize":uc(e);break;case"set-render-options":hc(e);break;case"file":fc(e);break;case"diff":dc(e);break;default:throw new Error(`Unknown request type: ${e.type}`)}}catch(n){console.error("Worker error:",n),mc(e.id,n)}});function uc({id:t,renderOptions:e,resolvedThemes:n,resolvedLanguages:r}){const s=ht();ms(n,s),r!=null&&fn(r,s),me=e,postMessage({type:"success",id:t,requestType:"initialize",sentAt:Date.now()})}function hc({id:t,renderOptions:e,resolvedThemes:n}){ms(n,ht()),me=e,postMessage({type:"success",id:t,requestType:"set-render-options",sentAt:Date.now()})}function fc({id:t,file:e,resolvedLanguages:n}){const r=ht();n!=null&&fn(n,r);const s={theme:me.theme,tokenizeMaxLineLength:me.tokenizeMaxLineLength};pc(t,cc(e,r,s),s)}function dc({id:t,diff:e,resolvedLanguages:n}){const r=ht();n!=null&&fn(n,r),gc(t,ic(e,r,me),me)}function ht(){return ur??=Xl({themes:[],langs:[],engine:oa()}),ur}function pc(t,e,n){postMessage({type:"success",requestType:"file",id:t,result:e,options:n,sentAt:Date.now()})}function gc(t,e,n){postMessage({type:"success",requestType:"diff",id:t,result:e,options:n,sentAt:Date.now()})}function mc(t,e){const n={type:"error",id:t,error:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0};postMessage(n)}
|
package/dist/index.html
CHANGED
|
@@ -191,10 +191,10 @@
|
|
|
191
191
|
pointer-events: none;
|
|
192
192
|
}
|
|
193
193
|
</style>
|
|
194
|
-
<script type="module" crossorigin src="/assets/index-
|
|
195
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-
|
|
194
|
+
<script type="module" crossorigin src="/assets/index-B5OwFsqC.js"></script>
|
|
195
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-CqCnPJev.js">
|
|
196
196
|
<link rel="stylesheet" crossorigin href="/assets/vendor--Jn2c0Clh.css">
|
|
197
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
197
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DXflA-iU.css">
|
|
198
198
|
</head>
|
|
199
199
|
<body class="h-full bg-background text-foreground">
|
|
200
200
|
<div id="root" class="h-full">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openchamber/web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./server/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@fontsource/ibm-plex-mono": "^5.2.7",
|
|
26
26
|
"@fontsource/ibm-plex-sans": "^5.1.1",
|
|
27
27
|
"@ibm/plex": "^6.4.1",
|
|
28
|
-
"@opencode-ai/sdk": "^1.1.
|
|
28
|
+
"@opencode-ai/sdk": "^1.1.19",
|
|
29
29
|
"@radix-ui/react-collapsible": "^1.1.12",
|
|
30
30
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
31
31
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
package/server/index.js
CHANGED
|
@@ -15,7 +15,7 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
15
15
|
const __dirname = path.dirname(__filename);
|
|
16
16
|
|
|
17
17
|
const DEFAULT_PORT = 3000;
|
|
18
|
-
const HEALTH_CHECK_INTERVAL =
|
|
18
|
+
const HEALTH_CHECK_INTERVAL = 15000;
|
|
19
19
|
const SHUTDOWN_TIMEOUT = 10000;
|
|
20
20
|
const MODELS_DEV_API_URL = 'https://models.dev/api.json';
|
|
21
21
|
const MODELS_METADATA_CACHE_TTL = 5 * 60 * 1000;
|
|
@@ -605,6 +605,10 @@ const sanitizeSettingsUpdate = (payload) => {
|
|
|
605
605
|
const trimmed = candidate.defaultAgent.trim();
|
|
606
606
|
result.defaultAgent = trimmed.length > 0 ? trimmed : undefined;
|
|
607
607
|
}
|
|
608
|
+
if (typeof candidate.defaultGitIdentityId === 'string') {
|
|
609
|
+
const trimmed = candidate.defaultGitIdentityId.trim();
|
|
610
|
+
result.defaultGitIdentityId = trimmed.length > 0 ? trimmed : undefined;
|
|
611
|
+
}
|
|
608
612
|
if (typeof candidate.queueModeEnabled === 'boolean') {
|
|
609
613
|
result.queueModeEnabled = candidate.queueModeEnabled;
|
|
610
614
|
}
|
|
@@ -1425,6 +1429,20 @@ function parseArgs(argv = process.argv.slice(2)) {
|
|
|
1425
1429
|
return options;
|
|
1426
1430
|
}
|
|
1427
1431
|
|
|
1432
|
+
function killProcessOnPort(port) {
|
|
1433
|
+
if (!port) return;
|
|
1434
|
+
try {
|
|
1435
|
+
// SDK's proc.kill() only kills the Node wrapper, not the actual opencode binary.
|
|
1436
|
+
// Kill any process listening on our port to clean up orphaned children.
|
|
1437
|
+
spawnSync('sh', ['-c', `lsof -ti:${port} | xargs kill -9 2>/dev/null || true`], {
|
|
1438
|
+
stdio: 'ignore',
|
|
1439
|
+
timeout: 5000
|
|
1440
|
+
});
|
|
1441
|
+
} catch {
|
|
1442
|
+
// Ignore - process may already be dead
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1428
1446
|
async function startOpenCode() {
|
|
1429
1447
|
const desiredPort = ENV_CONFIGURED_OPENCODE_PORT ?? 0;
|
|
1430
1448
|
console.log(
|
|
@@ -1492,6 +1510,8 @@ async function restartOpenCode() {
|
|
|
1492
1510
|
openCodeNotReadySince = Date.now();
|
|
1493
1511
|
console.log('Restarting OpenCode process...');
|
|
1494
1512
|
|
|
1513
|
+
const portToKill = openCodePort;
|
|
1514
|
+
|
|
1495
1515
|
if (openCodeProcess) {
|
|
1496
1516
|
console.log('Stopping existing OpenCode process...');
|
|
1497
1517
|
try {
|
|
@@ -1501,11 +1521,13 @@ async function restartOpenCode() {
|
|
|
1501
1521
|
}
|
|
1502
1522
|
openCodeProcess = null;
|
|
1503
1523
|
syncToHmrState();
|
|
1504
|
-
|
|
1505
|
-
// Brief delay to allow port release
|
|
1506
|
-
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
1507
1524
|
}
|
|
1508
1525
|
|
|
1526
|
+
killProcessOnPort(portToKill);
|
|
1527
|
+
|
|
1528
|
+
// Brief delay to allow port release
|
|
1529
|
+
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
1530
|
+
|
|
1509
1531
|
if (ENV_CONFIGURED_OPENCODE_PORT) {
|
|
1510
1532
|
console.log(`Using OpenCode port from environment: ${ENV_CONFIGURED_OPENCODE_PORT}`);
|
|
1511
1533
|
setOpenCodePort(ENV_CONFIGURED_OPENCODE_PORT);
|
|
@@ -1851,6 +1873,7 @@ function setupProxy(app) {
|
|
|
1851
1873
|
},
|
|
1852
1874
|
onProxyReq: (proxyReq, req, res) => {
|
|
1853
1875
|
console.log(`Proxying ${req.method} ${req.path} to OpenCode`);
|
|
1876
|
+
|
|
1854
1877
|
if (req.headers.accept && req.headers.accept.includes('text/event-stream')) {
|
|
1855
1878
|
console.log(`[SSE] Setting up SSE proxy for ${req.method} ${req.path}`);
|
|
1856
1879
|
proxyReq.setHeader('Accept', 'text/event-stream');
|
|
@@ -1912,6 +1935,8 @@ async function gracefulShutdown(options = {}) {
|
|
|
1912
1935
|
clearInterval(healthCheckInterval);
|
|
1913
1936
|
}
|
|
1914
1937
|
|
|
1938
|
+
const portToKill = openCodePort;
|
|
1939
|
+
|
|
1915
1940
|
if (openCodeProcess) {
|
|
1916
1941
|
console.log('Stopping OpenCode process...');
|
|
1917
1942
|
try {
|
|
@@ -1922,6 +1947,8 @@ async function gracefulShutdown(options = {}) {
|
|
|
1922
1947
|
openCodeProcess = null;
|
|
1923
1948
|
}
|
|
1924
1949
|
|
|
1950
|
+
killProcessOnPort(portToKill);
|
|
1951
|
+
|
|
1925
1952
|
if (server) {
|
|
1926
1953
|
await Promise.race([
|
|
1927
1954
|
new Promise((resolve) => {
|
|
@@ -1997,16 +2024,16 @@ async function main(options = {}) {
|
|
|
1997
2024
|
req.path.startsWith('/api/opencode')
|
|
1998
2025
|
) {
|
|
1999
2026
|
|
|
2000
|
-
express.json()(req, res, next);
|
|
2027
|
+
express.json({ limit: '50mb' })(req, res, next);
|
|
2001
2028
|
} else if (req.path.startsWith('/api')) {
|
|
2002
2029
|
|
|
2003
2030
|
next();
|
|
2004
2031
|
} else {
|
|
2005
2032
|
|
|
2006
|
-
express.json()(req, res, next);
|
|
2033
|
+
express.json({ limit: '50mb' })(req, res, next);
|
|
2007
2034
|
}
|
|
2008
2035
|
});
|
|
2009
|
-
app.use(express.urlencoded({ extended: true }));
|
|
2036
|
+
app.use(express.urlencoded({ extended: true, limit: '50mb' }));
|
|
2010
2037
|
|
|
2011
2038
|
app.use((req, res, next) => {
|
|
2012
2039
|
console.log(`${new Date().toISOString()} - ${req.method} ${req.path}`);
|
|
@@ -2239,7 +2266,7 @@ async function main(options = {}) {
|
|
|
2239
2266
|
|
|
2240
2267
|
const heartbeatInterval = setInterval(() => {
|
|
2241
2268
|
writeSseEvent(res, { type: 'openchamber:heartbeat', timestamp: Date.now() });
|
|
2242
|
-
},
|
|
2269
|
+
}, 15000);
|
|
2243
2270
|
|
|
2244
2271
|
const decoder = new TextDecoder();
|
|
2245
2272
|
const reader = upstream.body.getReader();
|
|
@@ -2365,7 +2392,7 @@ async function main(options = {}) {
|
|
|
2365
2392
|
|
|
2366
2393
|
const heartbeatInterval = setInterval(() => {
|
|
2367
2394
|
writeSseEvent(res, { type: 'openchamber:heartbeat', timestamp: Date.now() });
|
|
2368
|
-
},
|
|
2395
|
+
}, 15000);
|
|
2369
2396
|
|
|
2370
2397
|
const decoder = new TextDecoder();
|
|
2371
2398
|
const reader = upstream.body.getReader();
|
|
@@ -3365,6 +3392,22 @@ async function main(options = {}) {
|
|
|
3365
3392
|
}
|
|
3366
3393
|
});
|
|
3367
3394
|
|
|
3395
|
+
app.get('/api/git/has-local-identity', async (req, res) => {
|
|
3396
|
+
const { hasLocalIdentity } = await getGitLibraries();
|
|
3397
|
+
try {
|
|
3398
|
+
const directory = req.query.directory;
|
|
3399
|
+
if (!directory) {
|
|
3400
|
+
return res.status(400).json({ error: 'directory parameter is required' });
|
|
3401
|
+
}
|
|
3402
|
+
|
|
3403
|
+
const hasLocal = await hasLocalIdentity(directory);
|
|
3404
|
+
res.json({ hasLocalIdentity: hasLocal });
|
|
3405
|
+
} catch (error) {
|
|
3406
|
+
console.error('Failed to check local git identity:', error);
|
|
3407
|
+
res.status(500).json({ error: 'Failed to check local git identity' });
|
|
3408
|
+
}
|
|
3409
|
+
});
|
|
3410
|
+
|
|
3368
3411
|
app.post('/api/git/set-identity', async (req, res) => {
|
|
3369
3412
|
const { getProfile, setLocalIdentity, getGlobalIdentity } = await getGitLibraries();
|
|
3370
3413
|
try {
|
|
@@ -4000,6 +4043,54 @@ async function main(options = {}) {
|
|
|
4000
4043
|
}
|
|
4001
4044
|
});
|
|
4002
4045
|
|
|
4046
|
+
// Read file as raw bytes (images, etc.)
|
|
4047
|
+
app.get('/api/fs/raw', async (req, res) => {
|
|
4048
|
+
const filePath = typeof req.query.path === 'string' ? req.query.path.trim() : '';
|
|
4049
|
+
if (!filePath) {
|
|
4050
|
+
return res.status(400).json({ error: 'Path is required' });
|
|
4051
|
+
}
|
|
4052
|
+
|
|
4053
|
+
try {
|
|
4054
|
+
const resolvedPath = path.resolve(normalizeDirectoryPath(filePath));
|
|
4055
|
+
if (resolvedPath.includes('..')) {
|
|
4056
|
+
return res.status(400).json({ error: 'Invalid path: path traversal not allowed' });
|
|
4057
|
+
}
|
|
4058
|
+
|
|
4059
|
+
const stats = await fsPromises.stat(resolvedPath);
|
|
4060
|
+
if (!stats.isFile()) {
|
|
4061
|
+
return res.status(400).json({ error: 'Specified path is not a file' });
|
|
4062
|
+
}
|
|
4063
|
+
|
|
4064
|
+
const ext = path.extname(resolvedPath).toLowerCase();
|
|
4065
|
+
const mimeMap = {
|
|
4066
|
+
'.png': 'image/png',
|
|
4067
|
+
'.jpg': 'image/jpeg',
|
|
4068
|
+
'.jpeg': 'image/jpeg',
|
|
4069
|
+
'.gif': 'image/gif',
|
|
4070
|
+
'.svg': 'image/svg+xml',
|
|
4071
|
+
'.webp': 'image/webp',
|
|
4072
|
+
'.ico': 'image/x-icon',
|
|
4073
|
+
'.bmp': 'image/bmp',
|
|
4074
|
+
'.avif': 'image/avif',
|
|
4075
|
+
};
|
|
4076
|
+
const mimeType = mimeMap[ext] || 'application/octet-stream';
|
|
4077
|
+
|
|
4078
|
+
const content = await fsPromises.readFile(resolvedPath);
|
|
4079
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
4080
|
+
res.type(mimeType).send(content);
|
|
4081
|
+
} catch (error) {
|
|
4082
|
+
const err = error;
|
|
4083
|
+
if (err && typeof err === 'object' && err.code === 'ENOENT') {
|
|
4084
|
+
return res.status(404).json({ error: 'File not found' });
|
|
4085
|
+
}
|
|
4086
|
+
if (err && typeof err === 'object' && err.code === 'EACCES') {
|
|
4087
|
+
return res.status(403).json({ error: 'Access to file denied' });
|
|
4088
|
+
}
|
|
4089
|
+
console.error('Failed to read raw file:', error);
|
|
4090
|
+
res.status(500).json({ error: (error && error.message) || 'Failed to read file' });
|
|
4091
|
+
}
|
|
4092
|
+
});
|
|
4093
|
+
|
|
4003
4094
|
// Write file contents
|
|
4004
4095
|
app.post('/api/fs/write', async (req, res) => {
|
|
4005
4096
|
const { path: filePath, content } = req.body || {};
|
|
@@ -4306,6 +4397,7 @@ async function main(options = {}) {
|
|
|
4306
4397
|
const rawPath = typeof req.query.path === 'string' && req.query.path.trim().length > 0
|
|
4307
4398
|
? req.query.path.trim()
|
|
4308
4399
|
: os.homedir();
|
|
4400
|
+
const respectGitignore = req.query.respectGitignore === 'true';
|
|
4309
4401
|
|
|
4310
4402
|
try {
|
|
4311
4403
|
const resolvedPath = path.resolve(normalizeDirectoryPath(rawPath));
|
|
@@ -4316,16 +4408,57 @@ async function main(options = {}) {
|
|
|
4316
4408
|
}
|
|
4317
4409
|
|
|
4318
4410
|
const dirents = await fsPromises.readdir(resolvedPath, { withFileTypes: true });
|
|
4411
|
+
|
|
4412
|
+
// Get gitignored paths if requested
|
|
4413
|
+
let ignoredPaths = new Set();
|
|
4414
|
+
if (respectGitignore) {
|
|
4415
|
+
try {
|
|
4416
|
+
// Get all entry paths to check (relative to resolvedPath for git check-ignore)
|
|
4417
|
+
const pathsToCheck = dirents.map((d) => d.name);
|
|
4418
|
+
|
|
4419
|
+
if (pathsToCheck.length > 0) {
|
|
4420
|
+
try {
|
|
4421
|
+
// Use git check-ignore with paths as arguments
|
|
4422
|
+
// Pass paths directly as arguments (works for reasonable directory sizes)
|
|
4423
|
+
const result = await new Promise((resolve) => {
|
|
4424
|
+
const child = spawn('git', ['check-ignore', '--', ...pathsToCheck], {
|
|
4425
|
+
cwd: resolvedPath,
|
|
4426
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
4427
|
+
});
|
|
4428
|
+
|
|
4429
|
+
let stdout = '';
|
|
4430
|
+
child.stdout.on('data', (data) => { stdout += data.toString(); });
|
|
4431
|
+
child.on('close', () => resolve(stdout));
|
|
4432
|
+
child.on('error', () => resolve(''));
|
|
4433
|
+
});
|
|
4434
|
+
|
|
4435
|
+
result.split('\n').filter(Boolean).forEach((name) => {
|
|
4436
|
+
const fullPath = path.join(resolvedPath, name.trim());
|
|
4437
|
+
ignoredPaths.add(fullPath);
|
|
4438
|
+
});
|
|
4439
|
+
} catch {
|
|
4440
|
+
// git check-ignore fails if not a git repo, continue without filtering
|
|
4441
|
+
}
|
|
4442
|
+
}
|
|
4443
|
+
} catch {
|
|
4444
|
+
// If git is not available, continue without gitignore filtering
|
|
4445
|
+
}
|
|
4446
|
+
}
|
|
4447
|
+
|
|
4319
4448
|
const entries = await Promise.all(
|
|
4320
4449
|
dirents.map(async (dirent) => {
|
|
4321
4450
|
const entryPath = path.join(resolvedPath, dirent.name);
|
|
4451
|
+
|
|
4452
|
+
// Skip gitignored entries
|
|
4453
|
+
if (respectGitignore && ignoredPaths.has(entryPath)) {
|
|
4454
|
+
return null;
|
|
4455
|
+
}
|
|
4456
|
+
|
|
4322
4457
|
let isDirectory = dirent.isDirectory();
|
|
4323
4458
|
const isSymbolicLink = dirent.isSymbolicLink();
|
|
4324
4459
|
|
|
4325
4460
|
if (!isDirectory && isSymbolicLink) {
|
|
4326
|
-
|
|
4327
|
-
try {
|
|
4328
|
-
|
|
4461
|
+
try {
|
|
4329
4462
|
const linkStats = await fsPromises.stat(entryPath);
|
|
4330
4463
|
isDirectory = linkStats.isDirectory();
|
|
4331
4464
|
} catch {
|
|
@@ -4345,7 +4478,7 @@ async function main(options = {}) {
|
|
|
4345
4478
|
|
|
4346
4479
|
res.json({
|
|
4347
4480
|
path: resolvedPath,
|
|
4348
|
-
entries
|
|
4481
|
+
entries: entries.filter(Boolean)
|
|
4349
4482
|
});
|
|
4350
4483
|
} catch (error) {
|
|
4351
4484
|
console.error('Failed to list directory:', error);
|
|
@@ -160,6 +160,18 @@ export async function getCurrentIdentity(directory) {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
export async function hasLocalIdentity(directory) {
|
|
164
|
+
const git = simpleGit(normalizeDirectoryPath(directory));
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
const localName = await git.getConfig('user.name', 'local').catch(() => null);
|
|
168
|
+
const localEmail = await git.getConfig('user.email', 'local').catch(() => null);
|
|
169
|
+
return Boolean(localName?.value || localEmail?.value);
|
|
170
|
+
} catch {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
163
175
|
export async function setLocalIdentity(directory, profile) {
|
|
164
176
|
const git = simpleGit(normalizeDirectoryPath(directory));
|
|
165
177
|
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-hUJJZcBf.js","assets/vendor-.bun-94fMDU1C.js","assets/vendor--Jn2c0Clh.css","assets/main-C1GggQif.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as P}from"./vendor-.bun-94fMDU1C.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const a of n)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&o(l)}).observe(document,{childList:!0,subtree:!0});function r(n){const a={};return n.integrity&&(a.integrity=n.integrity),n.referrerPolicy&&(a.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?a.credentials="include":n.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(n){if(n.ep)return;n.ep=!0;const a=r(n);fetch(n.href,a)}})();async function $(t){const e=await fetch("/api/terminal/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t.cwd,cols:t.cols||80,rows:t.rows||24})});if(!e.ok){const r=await e.json().catch(()=>({error:"Failed to create terminal"}));throw new Error(r.error||"Failed to create terminal session")}return e.json()}function x(t,e,r,o={}){const{maxRetries:n=3,initialRetryDelay:a=1e3,maxRetryDelay:l=8e3,connectionTimeout:F=1e4}=o;let c=null,f=0,p=null,y=null,m=!1,g=!1,u=!1;const T=()=>{p&&(clearTimeout(p),p=null),y&&(clearTimeout(y),y=null)},E=()=>{m=!0,T(),c&&(c.close(),c=null)},j=()=>{if(!(m||u)){if(c&&c.readyState!==EventSource.CLOSED){console.warn("Attempted to create duplicate EventSource, skipping");return}g=!1,c=new EventSource(`/api/terminal/${t}/stream`),y=setTimeout(()=>{!g&&c?.readyState!==EventSource.OPEN&&(console.error("Terminal connection timeout"),c?.close(),b(new Error("Connection timeout"),!1))},F),c.onopen=()=>{g||(g=!0,f=0,T(),e({type:"connected"}))},c.onmessage=h=>{try{const d=JSON.parse(h.data);d.type==="exit"&&(u=!0,E()),e(d)}catch(d){console.error("Failed to parse terminal event:",d),r?.(d,!1)}},c.onerror=h=>{console.error("Terminal stream error:",h,"readyState:",c?.readyState),T();const d=u||c?.readyState===EventSource.CLOSED;c?.close(),c=null,u||b(new Error("Terminal stream connection error"),d)}}},b=(h,d)=>{if(!(m||u))if(f<n&&!d){f++;const k=Math.min(a*Math.pow(2,f-1),l);console.log(`Reconnecting to terminal stream (attempt ${f}/${n}) in ${k}ms`),e({type:"reconnecting",attempt:f,maxAttempts:n}),p=setTimeout(()=>{!m&&!u&&j()},k)}else console.error(`Terminal connection failed after ${f} attempts`),r?.(h,!0),E()};return j(),E}async function C(t,e){const r=await fetch(`/api/terminal/${t}/input`,{method:"POST",headers:{"Content-Type":"text/plain"},body:e});if(!r.ok){const o=await r.json().catch(()=>({error:"Failed to send input"}));throw new Error(o.error||"Failed to send terminal input")}}async function N(t,e,r){const o=await fetch(`/api/terminal/${t}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cols:e,rows:r})});if(!o.ok){const n=await o.json().catch(()=>({error:"Failed to resize terminal"}));throw new Error(n.error||"Failed to resize terminal")}}async function G(t){const e=await fetch(`/api/terminal/${t}`,{method:"DELETE"});if(!e.ok){const r=await e.json().catch(()=>({error:"Failed to close terminal"}));throw new Error(r.error||"Failed to close terminal")}}async function v(t,e){const r=await fetch(`/api/terminal/${t}/restart`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e.cwd,cols:e.cols??80,rows:e.rows??24})});if(!r.ok){const o=await r.json().catch(()=>({error:"Failed to restart terminal"}));throw new Error(o.error||"Failed to restart terminal")}return r.json()}async function I(t){const e=await fetch("/api/terminal/force-kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok){const r=await e.json().catch(()=>({error:"Failed to force kill terminal"}));throw new Error(r.error||"Failed to force kill terminal")}}const A=t=>{const e=t?.retry;return{maxRetries:e?.maxRetries??3,initialRetryDelay:e?.initialDelayMs??1e3,maxRetryDelay:e?.maxDelayMs??8e3,connectionTimeout:t?.connectionTimeoutMs??1e4}},D=()=>({async createSession(t){return $(t)},connect(t,e,r){const o=x(t,e.onEvent,e.onError,A(r));return{close:()=>o()}},async sendInput(t,e){await C(t,e)},async resize(t){await N(t.sessionId,t.cols,t.rows)},async close(t){await G(t)},async restartSession(t,e){return v(t,{cwd:e.cwd??"",cols:e.cols,rows:e.rows})},async forceKill(t){await I(t)}}),J=()=>{if(typeof window>"u")return"";const t=window.__OPENCHAMBER_DESKTOP_SERVER__?.origin;return t||window.location.origin},s="/api/git";function i(t,e,r){const o=new URL(t,J());if(e&&o.searchParams.set("directory",e),r)for(const[n,a]of Object.entries(r))a!==void 0&&o.searchParams.set(n,String(a));return o.toString()}async function R(t){const e=await fetch(i(`${s}/check`,t));if(!e.ok)throw new Error(`Failed to check git repository: ${e.statusText}`);return(await e.json()).isGitRepository}async function _(t){const e=await fetch(i(`${s}/status`,t));if(!e.ok)throw new Error(`Failed to get git status: ${e.statusText}`);return e.json()}async function L(t,e){const{path:r,staged:o,contextLines:n}=e;if(!r)throw new Error("path is required to fetch git diff");const a=await fetch(i(`${s}/diff`,t,{path:r,staged:o?"true":void 0,context:n}));if(!a.ok)throw new Error(`Failed to get git diff: ${a.statusText}`);return a.json()}async function B(t,e){const{path:r,staged:o}=e;if(!r)throw new Error("path is required to fetch git file diff");const n=await fetch(i(`${s}/file-diff`,t,{path:r,staged:o?"true":void 0}));if(!n.ok)throw new Error(`Failed to get git file diff: ${n.statusText}`);return n.json()}async function W(t,e){if(!e)throw new Error("path is required to revert git changes");const r=await fetch(i(`${s}/revert`,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to revert git changes")}}async function q(t){if(!t)return!1;const e=await fetch(i(`${s}/worktree-type`,t));if(!e.ok)throw new Error(`Failed to detect worktree type: ${e.statusText}`);return!!(await e.json()).linked}async function M(t){const e=await fetch(i(`${s}/branches`,t));if(!e.ok)throw new Error(`Failed to get branches: ${e.statusText}`);return e.json()}async function z(t,e){if(!e?.branch)throw new Error("branch is required to delete a branch");const r=await fetch(i(`${s}/branches`,t),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete branch")}return r.json()}async function U(t,e){if(!e?.branch)throw new Error("branch is required to delete remote branch");const r=await fetch(i(`${s}/remote-branches`,t),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete remote branch")}return r.json()}async function K(t,e){if(!Array.isArray(e)||e.length===0)throw new Error("No files provided to generate commit message");const r=await fetch(i(`${s}/commit-message`,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:e})});if(!r.ok){const l=await r.json().catch(()=>({error:r.statusText}));throw new Error(l.error||"Failed to generate commit message")}const o=await r.json();if(!o?.message||typeof o.message!="object")throw new Error("Malformed commit generation response");const n=typeof o.message.subject=="string"&&o.message.subject.trim().length>0?o.message.subject.trim():"",a=Array.isArray(o.message.highlights)?o.message.highlights.filter(l=>typeof l=="string"&&l.trim().length>0).map(l=>l.trim()):[];return{message:{subject:n,highlights:a}}}async function V(t){const e=await fetch(i(`${s}/worktrees`,t));if(!e.ok){const r=await e.json().catch(()=>({error:e.statusText}));throw new Error(r.error||"Failed to list worktrees")}return e.json()}async function H(t,e){if(!e?.path||!e?.branch)throw new Error("path and branch are required to add a worktree");const r=await fetch(i(`${s}/worktrees`,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to add worktree")}return r.json()}async function Q(t,e){if(!e?.path)throw new Error("path is required to remove a worktree");const r=await fetch(i(`${s}/worktrees`,t),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to remove worktree")}return r.json()}async function X(t){const e=await fetch(i(`${s}/ignore-openchamber`,t),{method:"POST"});if(!e.ok){const r=await e.json().catch(()=>({error:e.statusText}));throw new Error(r.error||"Failed to update git ignore")}}async function Y(t,e,r={}){const o=await fetch(i(`${s}/commit`,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e,addAll:r.addAll??!1,files:r.files})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to create commit")}return o.json()}async function Z(t,e={}){const r=await fetch(i(`${s}/push`,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to push")}return r.json()}async function ee(t,e={}){const r=await fetch(i(`${s}/pull`,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to pull")}return r.json()}async function te(t,e={}){const r=await fetch(i(`${s}/fetch`,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to fetch")}return r.json()}async function re(t,e){const r=await fetch(i(`${s}/checkout`,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:e})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to checkout branch")}return r.json()}async function oe(t,e,r){const o=await fetch(i(`${s}/branches`,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,startPoint:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to create branch")}return o.json()}async function ne(t,e,r){const o=await fetch(i(`${s}/branches/rename`,t),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:e,newName:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to rename branch")}return o.json()}async function se(t,e={}){const r=await fetch(i(`${s}/log`,t,{maxCount:e.maxCount,from:e.from,to:e.to,file:e.file}));if(!r.ok)throw new Error(`Failed to get git log: ${r.statusText}`);return r.json()}async function ie(t,e){const r=await fetch(i(`${s}/commit-files`,t,{hash:e}));if(!r.ok)throw new Error(`Failed to get commit files: ${r.statusText}`);return r.json()}async function ae(){const t=await fetch(i(`${s}/identities`,void 0));if(!t.ok)throw new Error(`Failed to get git identities: ${t.statusText}`);return t.json()}async function ce(t){const e=await fetch(i(`${s}/identities`,void 0),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok){const r=await e.json().catch(()=>({error:e.statusText}));throw new Error(r.error||"Failed to create git identity")}return e.json()}async function le(t,e){const r=await fetch(i(`${s}/identities/${t}`,void 0),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to update git identity")}return r.json()}async function de(t){const e=await fetch(i(`${s}/identities/${t}`,void 0),{method:"DELETE"});if(!e.ok){const r=await e.json().catch(()=>({error:e.statusText}));throw new Error(r.error||"Failed to delete git identity")}}async function fe(t){if(!t)return null;const e=await fetch(i(`${s}/current-identity`,t));if(!e.ok)throw new Error(`Failed to get current git identity: ${e.statusText}`);const r=await e.json();return r?{userName:r.userName??null,userEmail:r.userEmail??null,sshCommand:r.sshCommand??null}:null}async function ke(){const t=await fetch(i(`${s}/global-identity`,void 0));if(!t.ok)throw new Error(`Failed to get global git identity: ${t.statusText}`);const e=await t.json();return!e||!e.userName&&!e.userEmail?null:{userName:e.userName??null,userEmail:e.userEmail??null,sshCommand:e.sshCommand??null}}async function ue(t,e){const r=await fetch(i(`${s}/set-identity`,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:e})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to set git identity")}return r.json()}async function Se(){const t=await fetch(i(`${s}/discover-credentials`,void 0));if(!t.ok)throw new Error(`Failed to discover git credentials: ${t.statusText}`);return t.json()}const he=()=>({checkIsGitRepository:R,getGitStatus:_,getGitDiff:L,getGitFileDiff:B,revertGitFile:W,isLinkedWorktree:q,getGitBranches:M,deleteGitBranch:z,deleteRemoteBranch:U,generateCommitMessage:K,listGitWorktrees:V,addGitWorktree:H,removeGitWorktree:Q,ensureOpenChamberIgnored:X,createGitCommit(t,e,r){return Y(t,e,r)},gitPush:Z,gitPull:ee,gitFetch:te,checkoutBranch:re,createBranch:oe,renameBranch:ne,getGitLog(t,e){return se(t,e)},getCommitFiles:ie,getCurrentGitIdentity:fe,setGitIdentity:ue,getGitIdentities:ae,createGitIdentity:ce,updateGitIdentity:le,deleteGitIdentity:de}),w=t=>t.replace(/\\/g,"/"),we=()=>({async listDirectory(t){const e=w(t),r=await fetch("/api/fs/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to list directory")}return r.json()},async search(t){const e=await fetch("/api/fs/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:w(t.directory),query:t.query,maxResults:t.maxResults})});if(!e.ok){const o=await e.json().catch(()=>({error:e.statusText}));throw new Error(o.error||"Failed to search files")}const r=await e.json();return Array.isArray(r)?r.filter(o=>!!o&&typeof o=="object"&&typeof o.path=="string").map(o=>({path:w(o.path),score:o.score,preview:o.preview})):[]},async createDirectory(t){const e=w(t),r=await fetch("/api/fs/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to create directory")}const o=await r.json();return{success:!!o?.success,path:typeof o?.path=="string"?w(o.path):e}}}),S="/api/config/settings",pe="/api/config/reload",O=t=>!t||typeof t!="object"?{}:t,ye=()=>({async load(){const t=await fetch(S,{method:"GET",headers:{Accept:"application/json"}});if(!t.ok)throw new Error(`Failed to load settings: ${t.statusText}`);return{settings:O(await t.json().catch(()=>({}))),source:"web"}},async save(t){const e=await fetch(S,{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t)});if(!e.ok){const o=await e.json().catch(()=>({error:e.statusText}));throw new Error(o.error||"Failed to save settings")}return O(await e.json().catch(()=>({})))},async restartOpenCode(){const t=await fetch(pe,{method:"POST"});if(!t.ok){const e=await t.json().catch(()=>({error:t.statusText}));throw new Error(e.error||"Failed to restart OpenCode")}return{restarted:!0}}}),me=()=>({async requestDirectoryAccess(t){return{success:!0,path:t.path}},async startAccessingDirectory(t){return{success:!0}},async stopAccessingDirectory(t){return{success:!0}}}),ge=async t=>{if(typeof Notification>"u")return console.info("Notifications not supported in this environment",t),!1;if(await Notification.requestPermission()!=="granted")return console.warn("Notification permission not granted"),!1;try{return new Notification(t?.title??"OpenChamber",{body:t?.body,tag:t?.tag}),!0}catch(r){return console.warn("Failed to send notification",r),!1}},Te=()=>({async notifyAgentCompletion(t){return ge(t)},canNotify:()=>typeof Notification<"u"?Notification.permission==="granted":!1}),Ee=()=>({async getAvailableTools(){const t=await fetch("/api/experimental/tool/ids");if(!t.ok)throw new Error(`Tools API returned ${t.status} ${t.statusText}`);const e=await t.json();if(!Array.isArray(e))throw new Error("Tools API returned invalid data format");return e.filter(r=>typeof r=="string"&&r!=="invalid").sort()}}),je=()=>({runtime:{platform:"web",isDesktop:!1,isVSCode:!1,label:"web"},terminal:D(),git:he(),files:we(),settings:ye(),permissions:me(),notifications:Te(),tools:Ee()});window.__OPENCHAMBER_RUNTIME_APIS__=je();P(()=>import("./main-hUJJZcBf.js").then(t=>t.m),__vite__mapDeps([0,1,2,3]));export{U as a,H as b,R as c,z as d,de as e,ce as f,_ as g,Se as h,ke as i,ae as j,X as k,V as l,M as m,Q as r,le as u};
|