astrocms 0.1.2 → 0.1.3

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.
@@ -186,7 +186,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
186
186
 
187
187
  `)},flush(t){t.enqueue(`data: [DONE]
188
188
 
189
- `)}})}});var dze=QLe(()=>uae(ms([ir({type:wt("text-start"),id:Ge(),providerMetadata:Ut.optional()}),ir({type:wt("text-delta"),id:Ge(),delta:Ge(),providerMetadata:Ut.optional()}),ir({type:wt("text-end"),id:Ge(),providerMetadata:Ut.optional()}),ir({type:wt("error"),errorText:Ge()}),ir({type:wt("tool-input-start"),toolCallId:Ge(),toolName:Ge(),providerExecuted:os().optional(),providerMetadata:Ut.optional(),dynamic:os().optional(),title:Ge().optional()}),ir({type:wt("tool-input-delta"),toolCallId:Ge(),inputTextDelta:Ge()}),ir({type:wt("tool-input-available"),toolCallId:Ge(),toolName:Ge(),input:bl(),providerExecuted:os().optional(),providerMetadata:Ut.optional(),dynamic:os().optional(),title:Ge().optional()}),ir({type:wt("tool-input-error"),toolCallId:Ge(),toolName:Ge(),input:bl(),providerExecuted:os().optional(),providerMetadata:Ut.optional(),dynamic:os().optional(),errorText:Ge(),title:Ge().optional()}),ir({type:wt("tool-approval-request"),approvalId:Ge(),toolCallId:Ge()}),ir({type:wt("tool-output-available"),toolCallId:Ge(),output:bl(),providerExecuted:os().optional(),providerMetadata:Ut.optional(),dynamic:os().optional(),preliminary:os().optional()}),ir({type:wt("tool-output-error"),toolCallId:Ge(),errorText:Ge(),providerExecuted:os().optional(),providerMetadata:Ut.optional(),dynamic:os().optional()}),ir({type:wt("tool-output-denied"),toolCallId:Ge()}),ir({type:wt("reasoning-start"),id:Ge(),providerMetadata:Ut.optional()}),ir({type:wt("reasoning-delta"),id:Ge(),delta:Ge(),providerMetadata:Ut.optional()}),ir({type:wt("reasoning-end"),id:Ge(),providerMetadata:Ut.optional()}),ir({type:wt("source-url"),sourceId:Ge(),url:Ge(),title:Ge().optional(),providerMetadata:Ut.optional()}),ir({type:wt("source-document"),sourceId:Ge(),mediaType:Ge(),title:Ge(),filename:Ge().optional(),providerMetadata:Ut.optional()}),ir({type:wt("file"),url:Ge(),mediaType:Ge(),providerMetadata:Ut.optional()}),ir({type:iae(t=>typeof t=="string"&&t.startsWith("data-"),{message:'Type must start with "data-"'}),id:Ge().optional(),data:bl(),transient:os().optional()}),ir({type:wt("start-step")}),ir({type:wt("finish-step")}),ir({type:wt("start"),messageId:Ge().optional(),messageMetadata:bl().optional()}),ir({type:wt("finish"),finishReason:tae(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:bl().optional()}),ir({type:wt("abort"),reason:Ge().optional()}),ir({type:wt("message-metadata"),messageMetadata:bl()})])));function pze(t){return t.type.startsWith("data-")}function k8(t){return t.type.startsWith("tool-")}function wae(t){return t.type==="dynamic-tool"}function gd(t){return k8(t)||wae(t)}function C8(t){return t.type.split("-").slice(1).join("-")}function mze(t){return wae(t)?t.toolName:C8(t)}function gze({lastMessage:t,messageId:e}){return{message:t?.role==="assistant"?t:{id:e,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function vze({stream:t,messageMetadataSchema:e,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:s,onData:a}){return t.pipeThrough(new TransformStream({async transform(o,l){await r(async({state:c,write:h})=>{var d,m,g,x;function O(_){const A=c.message.parts.filter(gd).find(k=>k.toolCallId===_);if(A==null)throw new Hp({chunkType:"tool-invocation",chunkId:_,message:`No tool invocation found for tool call ID "${_}".`});return A}function w(_){var P;const A=c.message.parts.find($=>k8($)&&$.toolCallId===_.toolCallId),k=_,I=A;if(A!=null){A.state=_.state,I.input=k.input,I.output=k.output,I.errorText=k.errorText,I.rawInput=k.rawInput,I.preliminary=k.preliminary,_.title!==void 0&&(I.title=_.title),I.providerExecuted=(P=k.providerExecuted)!=null?P:A.providerExecuted;const $=k.providerMetadata;if($!=null)if(_.state==="output-available"||_.state==="output-error"){const L=A;L.resultProviderMetadata=$}else A.callProviderMetadata=$}else c.message.parts.push({type:`tool-${_.toolName}`,toolCallId:_.toolCallId,state:_.state,title:_.title,input:k.input,output:k.output,rawInput:k.rawInput,errorText:k.errorText,providerExecuted:k.providerExecuted,preliminary:k.preliminary,...k.providerMetadata!=null&&(_.state==="output-available"||_.state==="output-error")?{resultProviderMetadata:k.providerMetadata}:{},...k.providerMetadata!=null&&!(_.state==="output-available"||_.state==="output-error")?{callProviderMetadata:k.providerMetadata}:{}})}function E(_){var P,A;const k=c.message.parts.find(L=>L.type==="dynamic-tool"&&L.toolCallId===_.toolCallId),I=_,$=k;if(k!=null){k.state=_.state,$.toolName=_.toolName,$.input=I.input,$.output=I.output,$.errorText=I.errorText,$.rawInput=(P=I.rawInput)!=null?P:$.rawInput,$.preliminary=I.preliminary,_.title!==void 0&&($.title=_.title),$.providerExecuted=(A=I.providerExecuted)!=null?A:k.providerExecuted;const L=I.providerMetadata;if(L!=null)if(_.state==="output-available"||_.state==="output-error"){const Q=k;Q.resultProviderMetadata=L}else k.callProviderMetadata=L}else c.message.parts.push({type:"dynamic-tool",toolName:_.toolName,toolCallId:_.toolCallId,state:_.state,input:I.input,output:I.output,errorText:I.errorText,preliminary:I.preliminary,providerExecuted:I.providerExecuted,title:_.title,...I.providerMetadata!=null&&(_.state==="output-available"||_.state==="output-error")?{resultProviderMetadata:I.providerMetadata}:{},...I.providerMetadata!=null&&!(_.state==="output-available"||_.state==="output-error")?{callProviderMetadata:I.providerMetadata}:{}})}async function S(_){if(_!=null){const P=c.message.metadata!=null?bae(c.message.metadata,_):_;e!=null&&await gF({value:P,schema:e,context:{field:"message.metadata",entityId:c.message.id}}),c.message.metadata=P}}switch(o.type){case"text-start":{const _={type:"text",text:"",providerMetadata:o.providerMetadata,state:"streaming"};c.activeTextParts[o.id]=_,c.message.parts.push(_),h();break}case"text-delta":{const _=c.activeTextParts[o.id];if(_==null)throw new Hp({chunkType:"text-delta",chunkId:o.id,message:`Received text-delta for missing text part with ID "${o.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});_.text+=o.delta,_.providerMetadata=(d=o.providerMetadata)!=null?d:_.providerMetadata,h();break}case"text-end":{const _=c.activeTextParts[o.id];if(_==null)throw new Hp({chunkType:"text-end",chunkId:o.id,message:`Received text-end for missing text part with ID "${o.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});_.state="done",_.providerMetadata=(m=o.providerMetadata)!=null?m:_.providerMetadata,delete c.activeTextParts[o.id],h();break}case"reasoning-start":{const _={type:"reasoning",text:"",providerMetadata:o.providerMetadata,state:"streaming"};c.activeReasoningParts[o.id]=_,c.message.parts.push(_),h();break}case"reasoning-delta":{const _=c.activeReasoningParts[o.id];if(_==null)throw new Hp({chunkType:"reasoning-delta",chunkId:o.id,message:`Received reasoning-delta for missing reasoning part with ID "${o.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});_.text+=o.delta,_.providerMetadata=(g=o.providerMetadata)!=null?g:_.providerMetadata,h();break}case"reasoning-end":{const _=c.activeReasoningParts[o.id];if(_==null)throw new Hp({chunkType:"reasoning-end",chunkId:o.id,message:`Received reasoning-end for missing reasoning part with ID "${o.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});_.providerMetadata=(x=o.providerMetadata)!=null?x:_.providerMetadata,_.state="done",delete c.activeReasoningParts[o.id],h();break}case"file":{c.message.parts.push({type:"file",mediaType:o.mediaType,url:o.url,...o.providerMetadata!=null?{providerMetadata:o.providerMetadata}:{}}),h();break}case"source-url":{c.message.parts.push({type:"source-url",sourceId:o.sourceId,url:o.url,title:o.title,providerMetadata:o.providerMetadata}),h();break}case"source-document":{c.message.parts.push({type:"source-document",sourceId:o.sourceId,mediaType:o.mediaType,title:o.title,filename:o.filename,providerMetadata:o.providerMetadata}),h();break}case"tool-input-start":{const _=c.message.parts.filter(k8);c.partialToolCalls[o.toolCallId]={text:"",toolName:o.toolName,index:_.length,dynamic:o.dynamic,title:o.title},o.dynamic?E({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title,providerMetadata:o.providerMetadata}):w({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title,providerMetadata:o.providerMetadata}),h();break}case"tool-input-delta":{const _=c.partialToolCalls[o.toolCallId];if(_==null)throw new Hp({chunkType:"tool-input-delta",chunkId:o.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${o.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});_.text+=o.inputTextDelta;const{value:P}=await iy(_.text);_.dynamic?E({toolCallId:o.toolCallId,toolName:_.toolName,state:"input-streaming",input:P,title:_.title}):w({toolCallId:o.toolCallId,toolName:_.toolName,state:"input-streaming",input:P,title:_.title}),h();break}case"tool-input-available":{o.dynamic?E({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}):w({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}),h(),s&&!o.providerExecuted&&await s({toolCall:o});break}case"tool-input-error":{const _=c.message.parts.filter(gd).find(A=>A.toolCallId===o.toolCallId);(_!=null?_.type==="dynamic-tool":!!o.dynamic)?E({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}):w({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:void 0,rawInput:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}),h();break}case"tool-approval-request":{const _=O(o.toolCallId);_.state="approval-requested",_.approval={id:o.approvalId},h();break}case"tool-output-denied":{const _=O(o.toolCallId);_.state="output-denied",h();break}case"tool-output-available":{const _=O(o.toolCallId);_.type==="dynamic-tool"?E({toolCallId:o.toolCallId,toolName:_.toolName,state:"output-available",input:_.input,output:o.output,preliminary:o.preliminary,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:_.title}):w({toolCallId:o.toolCallId,toolName:C8(_),state:"output-available",input:_.input,output:o.output,providerExecuted:o.providerExecuted,preliminary:o.preliminary,providerMetadata:o.providerMetadata,title:_.title}),h();break}case"tool-output-error":{const _=O(o.toolCallId);_.type==="dynamic-tool"?E({toolCallId:o.toolCallId,toolName:_.toolName,state:"output-error",input:_.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:_.title}):w({toolCallId:o.toolCallId,toolName:C8(_),state:"output-error",input:_.input,rawInput:_.rawInput,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:_.title}),h();break}case"start-step":{c.message.parts.push({type:"step-start"});break}case"finish-step":{c.activeTextParts={},c.activeReasoningParts={};break}case"start":{o.messageId!=null&&(c.message.id=o.messageId),await S(o.messageMetadata),(o.messageId!=null||o.messageMetadata!=null)&&h();break}case"finish":{o.finishReason!=null&&(c.finishReason=o.finishReason),await S(o.messageMetadata),o.messageMetadata!=null&&h();break}case"message-metadata":{await S(o.messageMetadata),o.messageMetadata!=null&&h();break}case"error":{i?.(new Error(o.errorText));break}default:if(pze(o)){if(n?.[o.type]!=null){const A=c.message.parts.findIndex(I=>"id"in I&&"data"in I&&I.id===o.id&&I.type===o.type),k=A>=0?A:c.message.parts.length;await gF({value:o.data,schema:n[o.type],context:{field:`message.parts[${k}].data`,entityName:o.type,entityId:o.id}})}const _=o;if(_.transient){a?.(_);break}const P=_.id!=null?c.message.parts.find(A=>_.type===A.type&&_.id===A.id):void 0;P!=null?P.data=_.data:c.message.parts.push(_),a?.(_),h()}}l.enqueue(o)})}}))}async function yze({stream:t,onError:e}){const n=t.getReader();try{for(;;){const{done:r}=await n.read();if(r)break}}catch(r){e?.(r)}finally{n.releaseLock()}}ry({prefix:"aitxt",size:24});ry({prefix:"aiobj",size:24});var xze=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(t){return new Promise((e,n)=>{this.queue.push(async()=>{try{await t(),e()}catch(r){n(r)}}),this.processQueue()})}};ry({prefix:"aiobj",size:24});async function Oze(t){if(t==null)return[];if(!globalThis.FileList||!(t instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(t).map(async e=>{const{name:n,type:r}=e,i=await new Promise((s,a)=>{const o=new FileReader;o.onload=l=>{var c;s((c=l.target)==null?void 0:c.result)},o.onerror=l=>a(l),o.readAsDataURL(e)});return{type:"file",mediaType:r,filename:n,url:i}}))}var bze=class{constructor({api:t="/api/chat",credentials:e,headers:n,body:r,fetch:i,prepareSendMessagesRequest:s,prepareReconnectToStreamRequest:a}){this.api=t,this.credentials=e,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=s,this.prepareReconnectToStreamRequest=a}async sendMessages({abortSignal:t,...e}){var n,r,i,s,a;const o=await rh(this.body),l=await rh(this.headers),c=await rh(this.credentials),h={...jp(l),...jp(e.headers)},d=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:e.chatId,messages:e.messages,body:{...o,...e.body},headers:h,credentials:c,requestMetadata:e.metadata,trigger:e.trigger,messageId:e.messageId})),m=(r=d?.api)!=null?r:this.api,g=d?.headers!==void 0?jp(d.headers):h,x=d?.body!==void 0?d.body:{...o,...e.body,id:e.chatId,messages:e.messages,trigger:e.trigger,messageId:e.messageId},O=(i=d?.credentials)!=null?i:c,E=await((s=this.fetch)!=null?s:globalThis.fetch)(m,{method:"POST",headers:{"Content-Type":"application/json",...g},body:JSON.stringify(x),credentials:O,signal:t});if(!E.ok)throw new Error((a=await E.text())!=null?a:"Failed to fetch the chat response.");if(!E.body)throw new Error("The response body is empty.");return this.processResponseStream(E.body)}async reconnectToStream(t){var e,n,r,i,s;const a=await rh(this.body),o=await rh(this.headers),l=await rh(this.credentials),c={...jp(o),...jp(t.headers)},h=await((e=this.prepareReconnectToStreamRequest)==null?void 0:e.call(this,{api:this.api,id:t.chatId,body:{...a,...t.body},headers:c,credentials:l,requestMetadata:t.metadata})),d=(n=h?.api)!=null?n:`${this.api}/${t.chatId}/stream`,m=h?.headers!==void 0?jp(h.headers):c,g=(r=h?.credentials)!=null?r:l,O=await((i=this.fetch)!=null?i:globalThis.fetch)(d,{method:"GET",headers:m,credentials:g});if(O.status===204)return null;if(!O.ok)throw new Error((s=await O.text())!=null?s:"Failed to fetch the chat response.");if(!O.body)throw new Error("The response body is empty.");return this.processResponseStream(O.body)}},Sae=class extends bze{constructor(t={}){super(t)}processResponseStream(t){return ZLe({stream:t,schema:dze}).pipeThrough(new TransformStream({async transform(e,n){if(!e.success)throw e.error;n.enqueue(e.value)}}))}},wze=class{constructor({generateId:t=sae,id:e=t(),transport:n=new Sae,messageMetadataSchema:r,dataPartSchemas:i,state:s,onError:a,onToolCall:o,onFinish:l,onData:c,sendAutomaticallyWhen:h}){this.activeResponse=void 0,this.jobExecutor=new xze,this.sendMessage=async(d,m)=>{var g,x,O,w;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(g=this.lastMessage)==null?void 0:g.id,...m});return}let E;if("text"in d||"files"in d?E={parts:[...Array.isArray(d.files)?d.files:await Oze(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:E=d,d.messageId!=null){const S=this.state.messages.findIndex(_=>_.id===d.messageId);if(S===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[S].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,S+1),this.state.replaceMessage(S,{...E,id:d.messageId,role:(x=E.role)!=null?x:"user",metadata:d.metadata})}else this.state.pushMessage({...E,id:(O=E.id)!=null?O:this.generateId(),role:(w=E.role)!=null?w:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...m})},this.regenerate=async({messageId:d,...m}={})=>{const g=d==null?this.state.messages.length-1:this.state.messages.findIndex(x=>x.id===d);if(g===-1)throw new Error(`message ${d} not found`);this.state.messages=this.state.messages.slice(0,this.messages[g].role==="assistant"?g:g+1),await this.makeRequest({trigger:"regenerate-message",messageId:d,...m})},this.resumeStream=async(d={})=>{await this.makeRequest({trigger:"resume-stream",...d})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:d,approved:m,reason:g,options:x})=>this.jobExecutor.run(async()=>{const O=this.state.messages,w=O[O.length-1],E=S=>gd(S)&&S.state==="approval-requested"&&S.approval.id===d?{...S,state:"approval-responded",approval:{id:d,approved:m,reason:g}}:S;this.state.replaceMessage(O.length-1,{...w,parts:w.parts.map(E)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(E)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(S=>{var _;S&&this.makeRequest({trigger:"submit-message",messageId:(_=this.lastMessage)==null?void 0:_.id,...x})})}),this.addToolOutput=async({state:d="output-available",toolCallId:m,output:g,errorText:x,options:O})=>this.jobExecutor.run(async()=>{const w=this.state.messages,E=w[w.length-1],S=_=>gd(_)&&_.toolCallId===m?{..._,state:d,output:g,errorText:x}:_;this.state.replaceMessage(w.length-1,{...E,parts:E.parts.map(S)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(S)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(_=>{var P;_&&this.makeRequest({trigger:"submit-message",messageId:(P=this.lastMessage)==null?void 0:P.id,...O})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.abortController&&this.activeResponse.abortController.abort()},this.id=e,this.transport=n,this.generateId=t,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=s,this.onError=a,this.onToolCall=o,this.onFinish=l,this.onData=c,this.sendAutomaticallyWhen=h}get status(){return this.state.status}setStatus({status:t,error:e}){this.status!==t&&(this.state.status=t,this.state.error=e)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(t){this.state.messages=t}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const t=this.sendAutomaticallyWhen({messages:this.state.messages});return t&&typeof t=="object"&&"then"in t?await t:t}async makeRequest({trigger:t,metadata:e,headers:n,body:r,messageId:i}){var s,a,o;let l;if(t==="resume-stream")try{const g=await this.transport.reconnectToStream({chatId:this.id,metadata:e,headers:n,body:r});if(g==null)return;l=g}catch(g){this.onError&&g instanceof Error&&this.onError(g),this.setStatus({status:"error",error:g});return}this.setStatus({status:"submitted",error:void 0});const c=this.lastMessage;let h=!1,d=!1,m=!1;try{const g={state:gze({lastMessage:this.state.snapshot(c),messageId:this.generateId()}),abortController:new AbortController};g.abortController.signal.addEventListener("abort",()=>{h=!0}),this.activeResponse=g;let x;t==="resume-stream"?x=l:x=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:g.abortController.signal,metadata:e,headers:n,body:r,trigger:t,messageId:i});const O=w=>this.jobExecutor.run(()=>w({state:g.state,write:()=>{var E;this.setStatus({status:"streaming"}),g.state.message.id===((E=this.lastMessage)==null?void 0:E.id)?this.state.replaceMessage(this.state.messages.length-1,g.state.message):this.state.pushMessage(g.state.message)}}));await yze({stream:vze({stream:x,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:O,onError:w=>{throw w}}),onError:w=>{throw w}}),this.setStatus({status:"ready"})}catch(g){if(h||g.name==="AbortError")return h=!0,this.setStatus({status:"ready"}),null;m=!0,g instanceof TypeError&&(g.message.toLowerCase().includes("fetch")||g.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&g instanceof Error&&this.onError(g),this.setStatus({status:"error",error:g})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:h,isDisconnect:d,isError:m,finishReason:(s=this.activeResponse)==null?void 0:s.state.finishReason})}catch(g){console.error(g)}this.activeResponse=void 0}!m&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(o=this.lastMessage)==null?void 0:o.id,metadata:e,headers:n,body:r})}};const vF=(t,e)=>{if(e==null)return[];let n=t.findIndex(r=>r.id===e);if(n===-1)throw new Error("useVercelAIThreadState: Message not found. This is likely an internal bug in assistant-ui.");for(;t[n+1]?.role==="assistant";)n++;return t.slice(0,n+1)},yF=t=>{const n=[...t.content.filter(r=>r.type!=="file"),...t.attachments?.flatMap(r=>r.content.map(i=>({...i,filename:r.name})))??[]].map(r=>{switch(r.type){case"text":return{type:"text",text:r.text};case"image":return{type:"file",url:r.image,...r.filename&&{filename:r.filename},mediaType:"image/png"};case"file":return{type:"file",url:r.data,mediaType:r.mimeType,...r.filename&&{filename:r.filename}};default:throw new Error(`Unsupported part type: ${r.type}`)}});return{role:t.role,parts:n,metadata:t.metadata}},Sze=t=>new Promise((e,n)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=i=>n(i),r.readAsDataURL(t)}),Eze={accept:"*",async add({file:t}){return{id:sae(),type:t.type.startsWith("image/")?"image":"file",name:t.name,file:t,contentType:t.type,content:[],status:{type:"requires-action",reason:"composer-send"}}},async send(t){return{...t,status:{type:"complete"},content:[{type:"file",mimeType:t.contentType??"",filename:t.name,data:await Sze(t.file)}]}},async remove(){}},xF=t=>jc(t);function _ze(t){return t.replace(/[}\]"]+$/,"")}const kze=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),T8=(t,e,n)=>{if(Array.isArray(t))return t.map((r,i)=>T8(r,`${e}[${i}]`,n));if(t&&typeof t=="object"){const r=t,i=Object.keys(r),s=n.get(e)??[],a=new Set(s),o=[...s.filter(l=>kze(r,l)),...i.filter(l=>!a.has(l))];return n.set(e,o),Object.fromEntries(o.map(l=>[l,T8(r[l],`${e}.${l}`,n)]))}return t};function Cze(t,e,n){const r=t?.get(e)??new Map;t?.set(e,r);const i=T8(n,"$",r);return JSON.stringify(i)}function Tze(t,e){return t.state==="approval-requested"&&"approval"in t?{interrupt:{type:"human",payload:t.approval},status:{type:"requires-action",reason:"interrupt"}}:e?.type==="interrupt"?{interrupt:e.payload,status:{type:"requires-action",reason:"interrupt"}}:{}}function Aze(t,e){if(!t.parts||t.parts.length===0)return[];const n=t.parts.filter(i=>i.type!=="step-start"&&(t.role!=="user"||i.type!=="file")).map(i=>{if(i.type==="text")return{type:"text",text:i.text};if(i.type==="reasoning")return{type:"reasoning",text:i.text};if(gd(i)){const s=mze(i),a=i.toolCallId,o=`${t.id}:${a}`,l=i.input||{};let c,h=!1;i.state==="output-available"?c=i.output:i.state==="output-error"?(h=!0,c={error:i.errorText}):i.state==="output-denied"&&(h=!0,c={error:i.approval.reason||"Tool approval denied"});let d=Cze(e.toolArgsKeyOrderCache,o,l);i.state==="input-streaming"?d=_ze(d):e.toolArgsKeyOrderCache?.delete(o);const m=e.toolStatuses?.[a];return{type:"tool-call",toolName:s,toolCallId:a,argsText:d,args:l,result:c,isError:h,...Tze(i,m)}}return i.type==="source-url"?{type:"source",sourceType:"url",id:i.sourceId,url:i.url,title:i.title||""}:i.type==="file"?{type:"file",data:i.url,mimeType:i.mediaType,...i.filename!=null&&{filename:i.filename}}:i.type==="source-document"?(console.warn("Source document parts are not yet supported in conversion"),null):i.type.startsWith("data-")?{type:"data",name:i.type.substring(5),data:i.data}:(console.warn(`Unsupported message part type: ${i.type}`),null)}).filter(Boolean),r=new Set;return n.filter(i=>{if(i.type==="tool-call"&&i.toolCallId!=null){if(r.has(i.toolCallId))return!1;r.add(i.toolCallId)}return!0})}const C6=m6e((t,e)=>{const n=new Date,r=Aze(t,e);switch(t.role){case"user":return{role:"user",id:t.id,createdAt:n,content:r,attachments:t.parts?.filter(i=>i.type==="file").map((i,s)=>({id:s.toString(),type:i.mediaType.startsWith("image/")?"image":"file",name:i.filename??"file",content:[i.mediaType.startsWith("image/")?{type:"image",image:i.url,filename:i.filename}:{type:"file",filename:i.filename,data:i.url,mimeType:i.mediaType}],contentType:i.mediaType??"unknown/unknown",status:{type:"complete"}})),metadata:t.metadata};case"system":case"assistant":{const i=e.messageTiming?.[t.id];return{role:t.role,id:t.id,createdAt:n,content:r,metadata:{...t.metadata,...i&&{timing:i}}}}default:return console.warn(`Unsupported message role: ${t.role}`),[]}}),T6={format:"ai-sdk/v6",encode({message:{id:t,parts:e,...n}}){return{...n,parts:e}},decode(t){return{parentId:t.parent_id,message:{id:t.id,...t.content}}},getId(t){return t.id}},Eae=(t,e)=>({headId:e.headId,messages:e.messages.map(n=>{const r=t([n.message])[0];return{...n,message:r}})}),Pze=(t,e,n,r,i)=>{const s=C.useRef(!1),a=kr(),o=C.useCallback(()=>a.threadListItem.source?a.threadListItem():null,[a]),[l,c]=C.useState(!1),h=C.useRef(new Set),d=C.useRef(i);C.useEffect(()=>{d.current=i}),C.useEffect(()=>{if(!e||s.current)return;const E=async()=>{c(!0);try{const S=await e.withFormat?.(r).load();if(S&&S.messages.length>0){const _=Eae(n,S);t.current.thread.import(_);const P=new lA;P.import(_);const A=P.getMessages();d.current(A.map(jc).flat()),h.current=new Set(_.messages.map(k=>k.message.id))}}catch(S){console.error("Failed to load message history:",S)}finally{c(!1)}};if(s.current=!0,!o()?.getState().remoteId){c(!1);return}E()},[e,r,n,t,o]);const m=C.useRef(null),g=C.useRef(null),x=C.useRef([]),O=C.useRef(!1),w=C.useRef(0);return C.useEffect(()=>{const E=t.current.thread.subscribe(()=>{const{isRunning:S}=t.current.thread.getState(),_=O.current;if(O.current=S,m.current!=null){const P=t.current.thread.getState().messages.at(-1);if(P?.role==="assistant"){const A=P.content.filter(k=>k.type==="tool-call").length;for(;w.current<A;)x.current.push(Date.now()-m.current),w.current++}}if(S){m.current==null&&(m.current=Date.now(),x.current=[],w.current=0),g.current&&(clearTimeout(g.current),g.current=null);return}_&&(m.current!=null&&x.current.push(Date.now()-m.current),g.current&&clearTimeout(g.current),g.current=setTimeout(async()=>{g.current=null;const P=t.current.thread.getState();if(P.isRunning)return;const A=x.current,k=A.length>0?A.at(-1):void 0;if(A.length===1&&k!=null){const F=P.messages.findLast(W=>W.role==="assistant");if(F){const W=F.content.filter(ee=>ee.type==="tool-call").length;if(W>0){const ee=W+1,G=k/ee;A.length=0;for(let re=0;re<ee;re++)A.push(Math.round((re+1)*G))}}}const I=A.length>1?A.map((F,W)=>({start_ms:W===0?0:A[W-1],end_ms:F})):void 0;m.current=null,x.current=[];const $={...k!=null?{durationMs:k}:void 0,...I!=null?{stepTimestamps:I}:void 0},{messages:L}=P;let Q=null;const H=F=>F.length>0?r.getId(F.at(-1)):null,j=F=>F.map((W,ee)=>({parentId:ee===0?Q:r.getId(F[ee-1]),message:W}));for(const F of L){const W=jc(F);if(!(F.status===void 0||F.status.type==="complete"||F.status.type==="incomplete")){Q=H(W)??Q;continue}if(h.current.has(F.id)){if(k!==void 0){const he=e?.withFormat?.(r);let be=Q;for(const q of W){try{await he?.update?.({parentId:be,message:q},r.getId(q))}catch{}be=r.getId(q)}}Q=H(W)??Q;continue}h.current.add(F.id);const G=e?.withFormat?.(r),re=j(W);for(const he of re)await G?.append(he);Q=H(W)??Q,G?.reportTelemetry?.(re,$)}},0))});return()=>{E(),g.current&&(clearTimeout(g.current),g.current=null)}},[e,r,t]),l};function Mze(t){if(!t?.parts)return 0;let e=0;for(const n of t.parts)n.type==="text"&&(e+=n.text.length);return e}function Rze(t){if(!t?.parts)return 0;let e=0;for(const n of t.parts)gd(n)&&e++;return e}const Ize=(t,e)=>{const[n,r]=C.useState({}),i=C.useRef(null);return C.useEffect(()=>{const s=t.findLast(a=>a.role==="assistant");if(e&&s){(!i.current||i.current.messageId!==s.id)&&(i.current={messageId:s.id,startTime:Date.now(),lastContentLength:0,totalChunks:0});const a=i.current,o=Mze(s);o>a.lastContentLength&&(a.firstTokenTime===void 0&&(a.firstTokenTime=Date.now()-a.startTime),a.totalChunks++,a.lastContentLength=o)}else if(!e&&i.current){const a=i.current,o=Date.now()-a.startTime,l=Math.ceil(a.lastContentLength/4),c=Rze(s),h={streamStartTime:a.startTime,totalStreamTime:o,totalChunks:a.totalChunks,toolCallCount:c,...a.firstTokenTime!==void 0&&{firstTokenTime:a.firstTokenTime},...l>0&&{tokenCount:l},...o>0&&l>0&&{tokensPerSecond:l/(o/1e3)}};r(d=>({...d,[a.messageId]:h})),i.current=null}},[t,e]),n},Nze=(t,{adapters:e,toCreateMessage:n,cancelPendingToolCallsOnSend:r=!0}={})=>{const i=Rte(),[s,a]=C.useState({}),o=C.useRef(new Map),l=C.useRef(void 0),c=Object.values(s).some(S=>S?.type==="executing"),h=t.status==="submitted"||t.status==="streaming"||c,d=Ize(t.messages,h),m=C6.useThreadMessages({isRunning:h,messages:t.messages,metadata:C.useMemo(()=>({toolStatuses:s,messageTiming:d,toolArgsKeyOrderCache:o.current,...t.error&&{error:t.error.message}}),[s,d,t.error])}),[g]=C.useState(()=>({get current(){return E}})),x=n6e({state:{messages:m,isRunning:h},getTools:()=>g.current.thread.getModelContext().tools,onResult:S=>{S.type==="add-tool-result"&&t.addToolResult({tool:S.toolName,toolCallId:S.toolCallId,output:S.result,options:{metadata:l.current}})},setToolStatuses:a}),O=Pze(g,e?.history??i?.history,C6.toThreadMessages,T6,S=>{t.setMessages(S)}),w=async()=>{r&&(await x.abort(),t.setMessages(S=>{const _=S.at(-1);if(_?.role!=="assistant")return S;let P=!1;const A=_.parts?.map(k=>!gd(k)||k.state==="output-available"||k.state==="output-error"?k:(P=!0,{...k,state:"output-error",errorText:"User cancelled tool call by sending a new message."}));return P?[...S.slice(0,-1),{..._,parts:A}]:S}))},E=f6e({isRunning:h,messages:m,setMessages:S=>t.setMessages(S.map(xF).filter(Boolean).flat()),onImport:S=>t.setMessages(S.map(xF).filter(Boolean).flat()),onExportExternalState:()=>{const S=g.current.thread.export(),_=[],P=new Map;for(const k of S.messages){const I=jc(k.message);let $=k.parentId!=null?P.get(k.parentId)??k.parentId:null;for(const L of I)_.push({parentId:$,message:L}),$=T6.getId(L);I.length>0&&P.set(k.message.id,T6.getId(I[I.length-1]))}const A={messages:_};return S.headId!=null&&(A.headId=P.get(S.headId)??S.headId),A},onLoadExternalState:S=>{const _=Eae(C6.toThreadMessages,S);g.current.thread.import(_)},onCancel:async()=>{t.stop(),await x.abort()},onNew:async S=>{l.current=S.runConfig,await w();const _=(n??yF)(S);await t.sendMessage(_,{metadata:S.runConfig})},onEdit:async S=>{l.current=S.runConfig;const _=vF(t.messages,S.parentId);t.setMessages(_);const P=(n??yF)(S);await t.sendMessage(P,{metadata:S.runConfig})},onReload:async(S,_)=>{l.current=_.runConfig;const P=vF(t.messages,S);t.setMessages(P),await t.regenerate({metadata:_.runConfig})},onAddToolResult:({toolCallId:S,result:_,isError:P})=>{const A={metadata:l.current};P?t.addToolOutput({state:"output-error",tool:S,toolCallId:S,errorText:typeof _=="string"?_:JSON.stringify(_),options:A}):t.addToolOutput({state:"output-available",tool:S,toolCallId:S,output:_,options:A})},onResumeToolCall:S=>x.resume(S.toolCallId,S.payload),adapters:{attachments:Eze,...i,...e},isLoading:O});return E};var A6,OF;function $ze(){if(OF)return A6;OF=1;function t(e,n){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let r,i=0;return function(...a){clearTimeout(r);const o=Date.now(),l=o-i,c=n-l;c<=0?(i=o,e.apply(this,a)):r=setTimeout(()=>{i=Date.now(),e.apply(this,a)},c)}}return A6=t,A6}var Lze=$ze();const zze=Zh(Lze);var _ae=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},sr=(t,e,n)=>(_ae(t,e,"read from private field"),n?n.call(t):e.get(t)),vl=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},nh=(t,e,n,r)=>(_ae(t,e,"write to private field"),e.set(t,n),n);function Dze(t,e){return e!=null?zze(t,e):t}var La,zO,DO,D0,Q0,F0,Kp,A8,P8,Qze=class{constructor(t=[]){vl(this,La,void 0),vl(this,zO,"ready"),vl(this,DO,void 0),vl(this,D0,new Set),vl(this,Q0,new Set),vl(this,F0,new Set),this.pushMessage=e=>{nh(this,La,sr(this,La).concat(e)),sr(this,Kp).call(this)},this.popMessage=()=>{nh(this,La,sr(this,La).slice(0,-1)),sr(this,Kp).call(this)},this.replaceMessage=(e,n)=>{nh(this,La,[...sr(this,La).slice(0,e),this.snapshot(n),...sr(this,La).slice(e+1)]),sr(this,Kp).call(this)},this.snapshot=e=>structuredClone(e),this["~registerMessagesCallback"]=(e,n)=>{const r=n?Dze(e,n):e;return sr(this,D0).add(r),()=>{sr(this,D0).delete(r)}},this["~registerStatusCallback"]=e=>(sr(this,Q0).add(e),()=>{sr(this,Q0).delete(e)}),this["~registerErrorCallback"]=e=>(sr(this,F0).add(e),()=>{sr(this,F0).delete(e)}),vl(this,Kp,()=>{sr(this,D0).forEach(e=>e())}),vl(this,A8,()=>{sr(this,Q0).forEach(e=>e())}),vl(this,P8,()=>{sr(this,F0).forEach(e=>e())}),nh(this,La,t)}get status(){return sr(this,zO)}set status(t){nh(this,zO,t),sr(this,A8).call(this)}get error(){return sr(this,DO)}set error(t){nh(this,DO,t),sr(this,P8).call(this)}get messages(){return sr(this,La)}set messages(t){nh(this,La,[...t]),sr(this,Kp).call(this)}};La=new WeakMap;zO=new WeakMap;DO=new WeakMap;D0=new WeakMap;Q0=new WeakMap;F0=new WeakMap;Kp=new WeakMap;A8=new WeakMap;P8=new WeakMap;var Jp,bF=class extends wze{constructor({messages:t,...e}){const n=new Qze(t);super({...e,state:n}),vl(this,Jp,void 0),this["~registerMessagesCallback"]=(r,i)=>sr(this,Jp)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>sr(this,Jp)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>sr(this,Jp)["~registerErrorCallback"](r),nh(this,Jp,n)}};Jp=new WeakMap;function Fze({experimental_throttle:t,resume:e=!1,...n}={}){const r=C.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(r.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const i={...n,onToolCall:m=>{var g,x;return(x=(g=r.current).onToolCall)==null?void 0:x.call(g,m)},onData:m=>{var g,x;return(x=(g=r.current).onData)==null?void 0:x.call(g,m)},onFinish:m=>{var g,x;return(x=(g=r.current).onFinish)==null?void 0:x.call(g,m)},onError:m=>{var g,x;return(x=(g=r.current).onError)==null?void 0:x.call(g,m)},sendAutomaticallyWhen:m=>{var g,x,O;return(O=(x=(g=r.current).sendAutomaticallyWhen)==null?void 0:x.call(g,m))!=null?O:!1}},s=C.useRef("chat"in n?n.chat:new bF(i));("chat"in n&&n.chat!==s.current||"id"in n&&s.current.id!==n.id)&&(s.current="chat"in n?n.chat:new bF(i));const o=C.useCallback(m=>s.current["~registerMessagesCallback"](m,t),[t,s.current.id]),l=C.useSyncExternalStore(o,()=>s.current.messages,()=>s.current.messages),c=C.useSyncExternalStore(s.current["~registerStatusCallback"],()=>s.current.status,()=>s.current.status),h=C.useSyncExternalStore(s.current["~registerErrorCallback"],()=>s.current.error,()=>s.current.error),d=C.useCallback(m=>{typeof m=="function"&&(m=m(s.current.messages)),s.current.messages=m},[s]);return C.useEffect(()=>{e&&s.current.resumeStream()},[e,s]),{id:s.current.id,messages:l,setMessages:d,sendMessage:s.current.sendMessage,regenerate:s.current.regenerate,clearError:s.current.clearError,stop:s.current.stop,error:h,resumeStream:s.current.resumeStream,status:c,addToolResult:s.current.addToolOutput,addToolOutput:s.current.addToolOutput,addToolApprovalResponse:s.current.addToolApprovalResponse}}class M8 extends Sae{runtime;constructor(e){super({...e,prepareSendMessagesRequest:async n=>{const r=this.runtime?.thread.getModelContext(),i=(await this.runtime?.threads.mainItem.initialize())?.remoteId??n.id,s={...n,body:{callSettings:r?.callSettings,system:r?.system,config:r?.config,tools:l7e(r?.tools??{}),...n?.body}},a=await e?.prepareSendMessagesRequest?.(s);return{...a,body:a?.body??{...s.body,id:i,messages:n.messages,trigger:n.trigger,messageId:n.messageId,metadata:n.requestMetadata}}}})}setRuntime(e){this.runtime=e}}const Vze=t=>{const e=C.useRef(t);return C.useEffect(()=>{e.current=t}),C.useMemo(()=>new Proxy(e.current,{get(r,i){const s=e.current[i];return typeof s=="function"?s.bind(e.current):s}}),[])},Bze=t=>{const{adapters:e,transport:n,toCreateMessage:r,...i}=t??{},s=Vze(n??new M8),a=Qt(c=>c.threadListItem.id),o=Fze({...i,id:a,transport:s}),l=Nze(o,{adapters:e,...r&&{toCreateMessage:r}});return s instanceof M8&&s.setRuntime(l),l},jze=({cloud:t,...e}={})=>{const n=K6e({cloud:t});return O6e({runtimeHook:function(){return Bze(e)},adapter:n,allowNesting:!0})},R8="cms-agent-session-id";function Hze(){try{return localStorage.getItem(R8)}catch{return null}}function wF(t){try{t===null?localStorage.removeItem(R8):localStorage.setItem(R8,t)}catch{}}const kae=C.createContext(null);function lP(){const t=C.useContext(kae);if(!t)throw new Error("useAgentRuntime must be used inside AgentRuntimeProvider");return t}function Zze({children:t,onRequestOpen:e}){const[n,r]=C.useState(()=>Hze()),[i,s]=C.useState(null),{data:a,isLoading:o,refetch:l}=qo({queryKey:["claude-status"],queryFn:()=>r3e(),retry:!1,staleTime:6e4}),c=a?.authenticated===!0,{data:h=[]}=qo({queryKey:["conversations"],queryFn:()=>a3e(20),enabled:c});C.useEffect(()=>{if(!n||!c||i!==null)return;let O=!1;return Jz(n).then(w=>{O||s(w)}),()=>{O=!0}},[n,c,i]);const d=C.useMemo(()=>new M8({api:n?`/astrocms/api/claude/chat?sessionId=${encodeURIComponent(n)}`:"/astrocms/api/claude/chat"}),[n]),m=jze({transport:d}),g=C.useCallback(()=>{r(null),s(null),wF(null)},[]),x=C.useCallback(async O=>{r(O),wF(O);const w=await Jz(O);s(w)},[]);return M.jsx(REe,{runtime:m,children:M.jsx(Uze,{status:a,statusLoading:o,isAuthenticated:c,refetchStatus:l,sessionId:n,loadedMessages:i,conversations:h,resetSession:g,selectConversation:x,onRequestOpen:e,children:t})})}function Uze({children:t,status:e,statusLoading:n,isAuthenticated:r,refetchStatus:i,sessionId:s,loadedMessages:a,conversations:o,resetSession:l,selectConversation:c,onRequestOpen:h}){const d=kr(),m=Qt(_=>_.thread.isRunning),g=C.useRef(h);g.current=h;const x=C.useCallback(()=>{l(),d.threads().switchToNewThread()},[d,l]),O=C.useCallback(_=>{const P=_.trim();P&&(g.current(),d.thread().append(P))},[d]),w=C.useCallback(async _=>{const P=_.trim();P&&(g.current(),l(),await d.threads().switchToNewThread(),d.thread().append(P))},[d,l]),E=C.useCallback(()=>{g.current()},[]),S=C.useMemo(()=>({status:e,statusLoading:n,isAuthenticated:r,refetchStatus:i,sessionId:s,loadedMessages:a,conversations:o,startNewConversation:x,selectConversation:c,sendPrompt:O,sendInNewConversation:w,requestOpen:E,isRunning:m}),[e,n,r,i,s,a,o,x,c,O,w,E,m]);return M.jsx(kae.Provider,{value:S,children:t})}function qze({open:t}){const{status:e,statusLoading:n,isAuthenticated:r,refetchStatus:i,sessionId:s,loadedMessages:a,conversations:o,startNewConversation:l,selectConversation:c}=lP(),{width:h,handleMouseDown:d}=See({storageKey:"cms-agent-panel-width",defaultWidth:380,minWidth:250,maxWidth:800,side:"left"});return M.jsxs(M.Fragment,{children:[t&&M.jsx(Eee,{side:"left",onMouseDown:d}),M.jsxs("aside",{style:{width:t?h:0},className:`bg-bg-panel flex flex-col shrink-0 overflow-hidden ${t?"":"hidden"}`,"aria-hidden":!t,children:[M.jsxs("div",{className:"px-3 py-2.5 border-b border-border font-semibold text-xs flex items-center justify-between",children:[M.jsx("span",{children:"Agent"}),r&&M.jsx("button",{onClick:l,className:"p-1 rounded hover:bg-bg-hover text-text-muted hover:text-text cursor-pointer","aria-label":"New conversation",tabIndex:0,children:M.jsx(tMe,{size:14})})]}),n?M.jsx("div",{className:"flex-1 flex items-center justify-center text-text-muted text-xs",children:"Connecting to Claude..."}):r?M.jsx(GPe,{loadedMessages:a,conversations:o,onSelectConversation:c},s):M.jsx(rMe,{error:e?.error,onRetry:()=>i()})]})]})}const Cae=C.createContext(null);function Xze({filePath:t,children:e}){return M.jsx(Cae.Provider,{value:t,children:e})}function hw(){return C.useContext(Cae)}function Wze(){const{isAuthenticated:t,sendInNewConversation:e}=lP(),[n,r]=C.useState(""),[i,s]=C.useState(!1),a=C.useRef(null);C.useEffect(()=>{if(!i)return;function l(c){c.key==="Escape"&&a.current?.blur()}return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[i]);const o=C.useCallback(()=>{const l=n.trim();l&&(e(l),r(""),a.current?.blur())},[n,e]);return t?M.jsxs(M.Fragment,{children:[i&&M.jsx("button",{type:"button",tabIndex:-1,"aria-label":"Close prompt",onClick:()=>a.current?.blur(),className:"fixed inset-0 bg-black/20 backdrop-blur-sm z-30 cursor-default"}),M.jsx("div",{className:i?"pointer-events-auto fixed inset-x-0 mx-auto top-16 w-[min(720px,calc(100%-2rem))] z-40 shadow-2xl animate-header-prompt-in":"pointer-events-auto relative w-full max-w-md",children:M.jsxs("div",{className:`rounded-xl border bg-white transition-colors ${i?"border-primary ring-4 ring-primary/15":"border-border hover:border-gray-400"}`,children:[M.jsxs("label",{className:`flex items-start gap-2 cursor-text ${i?"px-4 py-3":"px-3 py-1.5"}`,children:[M.jsx("div",{className:"shrink-0 h-5 flex items-center text-primary",children:M.jsx(qie,{size:i?16:14})}),M.jsx("textarea",{ref:a,value:n,onChange:l=>r(l.target.value),onFocus:()=>s(!0),onBlur:()=>s(!1),onKeyDown:l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),o())},placeholder:i?"Ask AI to help with anything...":"Ask AI...",rows:i?3:1,className:`flex-1 resize-none outline-none bg-transparent text-sm leading-5 placeholder:text-text-muted ${i?"":"h-5 overflow-hidden"}`}),i&&M.jsx("button",{type:"button",onMouseDown:l=>{l.preventDefault(),o()},disabled:!n.trim(),"aria-label":"Send to agent",tabIndex:0,className:"shrink-0 p-2 rounded-lg bg-primary text-white enabled:hover:bg-primary-hover disabled:opacity-40 disabled:cursor-default cursor-pointer",children:M.jsx(nMe,{size:14})})]}),i&&M.jsx("div",{className:"px-4 pb-2 text-[10px] text-text-muted text-center",children:"Enter to send, Shift+Enter for new line, Esc to close"})]})})]}):null}function Tae(){return qo({queryKey:["gitStatus"],queryFn:gW,select:t=>t.files})}function Yze(){const t=ya(),e=C.useRef(void 0),{data:n}=qo({queryKey:["gitStatus"],queryFn:gW,select:r=>r.remote?.lastPulledAt??null});C.useEffect(()=>{e.current!==void 0&&n!==e.current&&(t.invalidateQueries({queryKey:["tree"]}),t.invalidateQueries({queryKey:["file"]}),t.invalidateQueries({queryKey:["folderMeta"]}),t.invalidateQueries({queryKey:["gitDiffs"]})),e.current=n},[n,t])}function Gze(){return qo({queryKey:["gitDiffs"],queryFn:Wxe,select:t=>t.diffs})}function Kze(){return qo({queryKey:["gitRemoteStatus"],queryFn:Jxe})}function z1(){const t=ya();return()=>{t.invalidateQueries({queryKey:["gitStatus"]}),t.invalidateQueries({queryKey:["gitDiffs"]}),t.invalidateQueries({queryKey:["gitRemoteStatus"]})}}function Jze(){const t=z1();return zo({mutationFn:async({message:e,push:n})=>{const r=await Yxe(e,n);if(!r.ok)throw new Error(r.error||"Commit failed");return r},onSuccess:t})}function eDe(){const t=z1(),e=ya();return zo({mutationFn:async()=>{const n=await e3e();if(!n.ok)throw new Error(n.error||"Pull failed");return n},onSuccess:()=>{t(),e.invalidateQueries({queryKey:["tree"]})}})}function tDe(){const t=z1(),e=ya();return zo({mutationFn:n=>n3e(n),onSuccess:()=>{t(),e.invalidateQueries({queryKey:["tree"]})}})}function nDe(){const t=z1(),e=ya();return zo({mutationFn:async({path:n,hunk:r})=>{const i=await t3e(n,r);if(!i.ok)throw new Error(i.error||"Discard hunk failed");return i},onSuccess:()=>{t(),e.invalidateQueries({queryKey:["tree"]})}})}function Aae(){const t=z1();return zo({mutationFn:e=>Gxe(e),onSuccess:t})}function Pae(){const t=z1();return zo({mutationFn:e=>Kxe(e),onSuccess:t})}function rDe(){const[t,e]=C.useState(!1),n=C.useRef(null),r=eDe(),{data:i}=Kze(),s=i?.updateAvailable===!0;C.useEffect(()=>{if(!t)return;function o(c){n.current?.contains(c.target)||e(!1)}function l(c){c.key==="Escape"&&e(!1)}return window.addEventListener("mousedown",o),window.addEventListener("keydown",l),()=>{window.removeEventListener("mousedown",o),window.removeEventListener("keydown",l)}},[t]);function a(){r.mutate(void 0,{onSuccess:()=>e(!1)})}return M.jsxs("div",{ref:n,className:"relative",children:[M.jsxs("button",{type:"button",onClick:()=>e(o=>!o),"aria-label":"More actions","aria-expanded":t,tabIndex:0,className:"relative p-1.5 rounded-md text-text-muted hover:bg-gray-100 hover:text-text cursor-pointer",children:[M.jsx(Rwe,{size:16}),s&&M.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-amber-500","aria-hidden":!0})]}),t&&M.jsxs("div",{role:"menu",className:"absolute right-0 top-full mt-1 w-60 rounded-md border border-border bg-white shadow-lg py-1 z-50",children:[M.jsxs("button",{type:"button",role:"menuitem",onClick:a,disabled:r.isPending,tabIndex:0,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-gray-50 disabled:opacity-50 disabled:cursor-default cursor-pointer",children:[M.jsx(Nwe,{size:13,className:"text-text-muted"}),M.jsx("span",{className:"flex-1",children:r.isPending?"Pulling...":"Pull from remote"}),s&&M.jsxs("span",{className:"text-[10px] text-amber-700 bg-amber-50 border border-amber-200 px-1.5 py-0.5 rounded",children:[i?.behind," new"]})]}),r.error&&M.jsx("div",{className:"px-3 py-2 text-[11px] text-danger",children:r.error.message}),i?.lastCheckedAt&&M.jsxs("div",{className:"px-3 py-1.5 text-[10px] text-text-muted border-t border-border mt-1",children:["Last check: ",new Date(i.lastCheckedAt).toLocaleTimeString()]})]})]})}function iDe({agentOpen:t,onToggleAgent:e,onNavigateGit:n}){const{data:r}=qo({queryKey:["public-config"],queryFn:Zxe,staleTime:1/0}),{data:i=[]}=Tae(),s=i.length;return M.jsxs("header",{className:"h-12 border-b border-border flex items-center gap-4 px-4 bg-white shrink-0 relative z-20",children:[M.jsx("span",{className:"font-semibold text-sm shrink-0",children:"AstroCMS"}),M.jsx("div",{className:"flex-1 flex justify-center",children:M.jsx(Wze,{})}),M.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r?.devServer&&M.jsxs("a",{href:"/",target:"_blank",rel:"noopener noreferrer",className:"px-3 py-1 rounded-md border border-border bg-white text-text no-underline text-xs cursor-pointer hover:bg-gray-100 inline-flex items-center",children:["Preview ",M.jsx(Iwe,{className:"ml-1 align-middle"})]}),M.jsx(rDe,{}),M.jsx(Di,{active:t,onClick:e,children:"Agent"}),s>0&&M.jsx(Di,{variant:"success",onClick:n,children:M.jsxs("span",{className:"inline-flex items-center gap-1.5",children:["Review changes",M.jsx("span",{className:"inline-flex items-center justify-center min-w-4 h-4 px-1 rounded-full bg-white/25 text-white text-[10px] font-semibold",children:s})]})})]})]})}var sDe=Object.defineProperty,aDe=(t,e,n)=>e in t?sDe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ac=(t,e,n)=>aDe(t,typeof e!="symbol"?e+"":e,n);let oDe=class Mae{constructor(e=new Map){this.map=e}clone(){return new Mae(new Map(this.map))}increment(e){const n=this.map.get(e)??0;this.map.set(e,n+1)}decrement(e,n){let r=this.map.get(e);r!==void 0&&(r-=1,this.map.set(e,r),r===0&&n())}},C3=class{constructor(){Ac(this,"map",new Map)}getOrCreate(e){let n=this.map.get(e);return n===void 0&&(n=new Set,this.map.set(e,n)),n}get(e){return this.map.get(e)}use(e,n){const r=this.get(e);r!==void 0&&n(r)}delete(e){return this.map.delete(e)}};function Em(t,e){return e(t),t}function cP(){}const Rae="cell";function SF(t,e){return t===e}const fw=new Map;let lDe=class{constructor(e={}){Ac(this,"subscriptions",new C3),Ac(this,"singletonSubscriptions",new Map),Ac(this,"graph",new C3),Ac(this,"state",new Map),Ac(this,"distinctNodes",new Map),Ac(this,"executionMaps",new Map),Ac(this,"definitionRegistry",new Set),Ac(this,"combinedCells",[]);for(const n of Object.getOwnPropertySymbols(e))this.state.set(n,e[n])}cellInstance(e,n=!0,r=Symbol()){return this.state.has(r)||this.state.set(r,e),n!==!1&&!this.distinctNodes.has(r)&&this.distinctNodes.set(r,n===!0?SF:n),r}signalInstance(e=!0,n=Symbol()){return e!==!1&&this.distinctNodes.set(n,e===!0?SF:e),n}sub(e,n){this.register(e);const r=this.subscriptions.getOrCreate(e);return r.add(n),()=>r.delete(n)}singletonSub(e,n){return this.register(e),n===void 0?this.singletonSubscriptions.delete(e):this.singletonSubscriptions.set(e,n),()=>this.singletonSubscriptions.delete(e)}resetSingletonSubs(){this.singletonSubscriptions.clear()}subMultiple(e,n){const r=this.signalInstance();return this.connect({map:i=>(...s)=>{i(s)},sink:r,sources:e}),this.sub(r,n)}pubIn(e){var n;const r=Reflect.ownKeys(e),i=this.getExecutionMap(r),s=i.refCount.clone(),a=i.participatingNodes.slice(),o=new Map(this.state),l=c=>{this.graph.use(c,h=>{for(const{sources:d,sink:m}of h)d.has(c)&&s.decrement(m,()=>{a.splice(a.indexOf(m),1),l(m)})})};for(;;){const c=a.shift();if(c===void 0)break;const h=c;let d=!1;const m=g=>{const x=this.distinctNodes.get(h);if(x!=null&&x(o.get(h),g)){d=!1;return}d=!0,o.set(h,g),this.state.has(h)&&this.state.set(h,g)};if(Object.prototype.hasOwnProperty.call(e,h)?m(e[h]):i.projections.use(h,g=>{for(const x of g){const O=[...Array.from(x.sources),...Array.from(x.pulls)].map(w=>o.get(w));x.map(m)(...O)}}),d){const g=o.get(h);this.inContext(()=>{this.subscriptions.use(h,x=>{for(const O of x)O(g)})}),(n=this.singletonSubscriptions.get(h))==null||n(g)}else l(h)}}connect({sources:e,pulls:n=[],map:r,sink:i}){const s={map:r,pulls:new Set(n),sink:this.register(i),sources:new Set(e)};for(const a of[...e,...n])this.register(a),this.graph.getOrCreate(a).add(s);this.executionMaps.clear()}pub(e,n){this.pubIn({[e]:n})}pipe(e,...n){return this.combineOperators(...n)(e)}transformer(...e){return n=>Em(this.signalInstance(),r=>(this.link(this.pipe(r,...e),n),r))}link(e,n){this.connect({map:r=>i=>{r(i)},sink:n,sources:[e]})}combine(...e){return Em(this.signalInstance(),n=>{this.connect({map:r=>(...i)=>{r(i)},sink:n,sources:e})})}combineCells(...e){const n=this.combinedCells.find(i=>e.length===i.sources.length&&e.every((s,a)=>s===i.sources[a]));if(n)return n.cell;const r=this.cellInstance(e.map(i=>this.getValue(i)),!0);return this.connect({map:i=>(...s)=>{i(s)},sink:r,sources:e}),this.combinedCells.push({sources:e,cell:r}),r}getValue(e){return this.register(e),this.state.get(e)}getValues(e){return e.map(n=>this.getValue(n))}register(e){const n=fw.get(e);return n===void 0||this.definitionRegistry.has(e)?e:(this.definitionRegistry.add(e),Em(n.type===Rae?this.cellInstance(n.initial,n.distinct,e):this.signalInstance(n.distinct,e),r=>{this.inContext(()=>{n.init(this,r)})}))}inContext(e){return e()}changeWith(e,n,r){this.connect({sources:[n],pulls:[e],sink:e,map:i=>(s,a)=>{i(r(a,s))}})}calculateExecutionMap(e){const n=[],r=new Set,i=new C3,s=new oDe,a=new C3,o=(l,c=0)=>{s.increment(l),!r.has(l)&&(this.register(l),i.use(l,h=>{c=Math.max(...Array.from(h).map(d=>n.indexOf(d)))+1}),this.graph.use(l,h=>{for(const d of h)d.sources.has(l)?(a.getOrCreate(d.sink).add(d),o(d.sink,c)):i.getOrCreate(d.sink).add(l)}),r.add(l),n.splice(c,0,l))};return e.forEach(o),{participatingNodes:n,pendingPulls:i,projections:a,refCount:s}}getExecutionMap(e){let n=e;if(e.length===1){n=e[0];const i=this.executionMaps.get(n);if(i!==void 0)return i}else for(const[i,s]of this.executionMaps.entries())if(Array.isArray(i)&&i.length===e.length&&i.every(a=>e.includes(a)))return s;const r=this.calculateExecutionMap(e);return this.executionMaps.set(n,r),r}combineOperators(...e){return n=>{for(const r of e)n=r(n,this);return n}}};function et(t,e=cP,n=!0){return Em(Symbol(),r=>{fw.set(r,{type:Rae,distinct:n,initial:t,init:e})})}function $r(t=cP,e=!1){return Em(Symbol(),n=>{fw.set(n,{type:"signal",distinct:e,init:t})})}function ef(t=cP){return Em(Symbol(),e=>{fw.set(e,{type:"signal",distinct:!1,init:t})})}const Iae=C.createContext(null);function D1(){const t=C.useContext(Iae);if(t===null)throw new Error("useRealm must be used within a RealmContextProvider");return t}function cr(t){const e=D1();e.register(t);const n=C.useCallback(r=>e.sub(t,r),[e,t]);return C.useSyncExternalStore(n,()=>e.getValue(t),()=>e.getValue(t))}function Ar(...t){const e=D1(),n=C.useMemo(()=>e.combineCells.apply(e,t),[e,...t]);return cr(n)}function Yt(t){const e=D1();return e.register(t),C.useCallback(n=>{e.pub(t,n)},[e,t])}function eu(t){return(e,n)=>{const r=n.signalInstance();return n.connect({map:i=>s=>{i(t(s))},sink:r,sources:[e]}),r}}function Sr(...t){return(e,n)=>{const r=n.signalInstance();return n.connect({map:i=>(...s)=>{i(s)},pulls:t,sink:r,sources:[e]}),r}}function Nae(t){return(e,n)=>{const r=n.signalInstance();return n.connect({map:i=>()=>{i(t)},sink:r,sources:[e]}),r}}function sy(t){return(e,n)=>{const r=n.signalInstance();return n.connect({map:i=>s=>{t(s)&&i(s)},sink:r,sources:[e]}),r}}function $ae(t,e){return(n,r)=>{const i=r.signalInstance();return r.connect({map:s=>a=>{s(e=t(e,a))},sink:i,sources:[n]}),i}}function cDe(t,e){return e(t),t}function wh(){}function Bi(t){return function(e){return{init:n=>{var r;return(r=t.init)==null?void 0:r.call(t,n,e)},postInit:n=>{var r;return(r=t.postInit)==null?void 0:r.call(t,n,e)},update:n=>{var r;return(r=t.update)==null?void 0:r.call(t,n,e)}}}}function uDe({children:t,plugins:e}){const n=p.useMemo(()=>cDe(new lDe,r=>{var i,s;for(const a of e)(i=a.init)==null||i.call(a,r);for(const a of e)(s=a.postInit)==null||s.call(a,r)}),[]);return p.useEffect(()=>{var r;for(const i of e)(r=i.update)==null||r.call(i,n)}),p.createElement(Iae.Provider,{value:n},t)}const Yb=C.createContext(null);function Lae(t,e){let n=null;return t!=null&&(n=t[1]),{getTheme:function(){return e??(n!=null?n.getTheme():null)}}}function Ur(){const t=C.useContext(Yb);return t==null&&(function(e,...n){const r=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",e);for(const s of n)i.append("v",s);throw r.search=i.toString(),Error(`Minified Lexical error #${e}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)})(8),t}function je(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const i of e)r.append("v",i);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const rl=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,hDe=rl&&"documentMode"in document?document.documentMode:null,wl=rl&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),vd=rl&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Gb=!(!rl||!("InputEvent"in window)||hDe)&&"getTargetRanges"in new window.InputEvent("input"),G2=rl&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Km=rl&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,fDe=rl&&/Android/.test(navigator.userAgent),zae=rl&&/^(?=.*Chrome).*/i.test(navigator.userAgent),EF=rl&&fDe&&zae,Kb=rl&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!zae;function Dae(...t){const e=[];for(const n of t)if(n&&typeof n=="string")for(const[r]of n.matchAll(/\S+/g))e.push(r);return e}const dDe=1,pDe=3,mDe=9,gDe=11,yd=0,Qae=1,Jm=2,vDe=0,yDe=1,xDe=2,Jb=4,e5=8,uP=128,ODe=1792|(112|(3|Jb|e5)|uP),hP=1,fP=2,dP=3,pP=4,mP=5,gP=6,dw=G2||Km||Kb?" ":"​",tu=`
189
+ `)}})}});var dze=QLe(()=>uae(ms([ir({type:wt("text-start"),id:Ge(),providerMetadata:Ut.optional()}),ir({type:wt("text-delta"),id:Ge(),delta:Ge(),providerMetadata:Ut.optional()}),ir({type:wt("text-end"),id:Ge(),providerMetadata:Ut.optional()}),ir({type:wt("error"),errorText:Ge()}),ir({type:wt("tool-input-start"),toolCallId:Ge(),toolName:Ge(),providerExecuted:os().optional(),providerMetadata:Ut.optional(),dynamic:os().optional(),title:Ge().optional()}),ir({type:wt("tool-input-delta"),toolCallId:Ge(),inputTextDelta:Ge()}),ir({type:wt("tool-input-available"),toolCallId:Ge(),toolName:Ge(),input:bl(),providerExecuted:os().optional(),providerMetadata:Ut.optional(),dynamic:os().optional(),title:Ge().optional()}),ir({type:wt("tool-input-error"),toolCallId:Ge(),toolName:Ge(),input:bl(),providerExecuted:os().optional(),providerMetadata:Ut.optional(),dynamic:os().optional(),errorText:Ge(),title:Ge().optional()}),ir({type:wt("tool-approval-request"),approvalId:Ge(),toolCallId:Ge()}),ir({type:wt("tool-output-available"),toolCallId:Ge(),output:bl(),providerExecuted:os().optional(),providerMetadata:Ut.optional(),dynamic:os().optional(),preliminary:os().optional()}),ir({type:wt("tool-output-error"),toolCallId:Ge(),errorText:Ge(),providerExecuted:os().optional(),providerMetadata:Ut.optional(),dynamic:os().optional()}),ir({type:wt("tool-output-denied"),toolCallId:Ge()}),ir({type:wt("reasoning-start"),id:Ge(),providerMetadata:Ut.optional()}),ir({type:wt("reasoning-delta"),id:Ge(),delta:Ge(),providerMetadata:Ut.optional()}),ir({type:wt("reasoning-end"),id:Ge(),providerMetadata:Ut.optional()}),ir({type:wt("source-url"),sourceId:Ge(),url:Ge(),title:Ge().optional(),providerMetadata:Ut.optional()}),ir({type:wt("source-document"),sourceId:Ge(),mediaType:Ge(),title:Ge(),filename:Ge().optional(),providerMetadata:Ut.optional()}),ir({type:wt("file"),url:Ge(),mediaType:Ge(),providerMetadata:Ut.optional()}),ir({type:iae(t=>typeof t=="string"&&t.startsWith("data-"),{message:'Type must start with "data-"'}),id:Ge().optional(),data:bl(),transient:os().optional()}),ir({type:wt("start-step")}),ir({type:wt("finish-step")}),ir({type:wt("start"),messageId:Ge().optional(),messageMetadata:bl().optional()}),ir({type:wt("finish"),finishReason:tae(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:bl().optional()}),ir({type:wt("abort"),reason:Ge().optional()}),ir({type:wt("message-metadata"),messageMetadata:bl()})])));function pze(t){return t.type.startsWith("data-")}function k8(t){return t.type.startsWith("tool-")}function wae(t){return t.type==="dynamic-tool"}function gd(t){return k8(t)||wae(t)}function C8(t){return t.type.split("-").slice(1).join("-")}function mze(t){return wae(t)?t.toolName:C8(t)}function gze({lastMessage:t,messageId:e}){return{message:t?.role==="assistant"?t:{id:e,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function vze({stream:t,messageMetadataSchema:e,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:s,onData:a}){return t.pipeThrough(new TransformStream({async transform(o,l){await r(async({state:c,write:h})=>{var d,m,g,x;function O(_){const A=c.message.parts.filter(gd).find(k=>k.toolCallId===_);if(A==null)throw new Hp({chunkType:"tool-invocation",chunkId:_,message:`No tool invocation found for tool call ID "${_}".`});return A}function w(_){var P;const A=c.message.parts.find($=>k8($)&&$.toolCallId===_.toolCallId),k=_,I=A;if(A!=null){A.state=_.state,I.input=k.input,I.output=k.output,I.errorText=k.errorText,I.rawInput=k.rawInput,I.preliminary=k.preliminary,_.title!==void 0&&(I.title=_.title),I.providerExecuted=(P=k.providerExecuted)!=null?P:A.providerExecuted;const $=k.providerMetadata;if($!=null)if(_.state==="output-available"||_.state==="output-error"){const L=A;L.resultProviderMetadata=$}else A.callProviderMetadata=$}else c.message.parts.push({type:`tool-${_.toolName}`,toolCallId:_.toolCallId,state:_.state,title:_.title,input:k.input,output:k.output,rawInput:k.rawInput,errorText:k.errorText,providerExecuted:k.providerExecuted,preliminary:k.preliminary,...k.providerMetadata!=null&&(_.state==="output-available"||_.state==="output-error")?{resultProviderMetadata:k.providerMetadata}:{},...k.providerMetadata!=null&&!(_.state==="output-available"||_.state==="output-error")?{callProviderMetadata:k.providerMetadata}:{}})}function E(_){var P,A;const k=c.message.parts.find(L=>L.type==="dynamic-tool"&&L.toolCallId===_.toolCallId),I=_,$=k;if(k!=null){k.state=_.state,$.toolName=_.toolName,$.input=I.input,$.output=I.output,$.errorText=I.errorText,$.rawInput=(P=I.rawInput)!=null?P:$.rawInput,$.preliminary=I.preliminary,_.title!==void 0&&($.title=_.title),$.providerExecuted=(A=I.providerExecuted)!=null?A:k.providerExecuted;const L=I.providerMetadata;if(L!=null)if(_.state==="output-available"||_.state==="output-error"){const Q=k;Q.resultProviderMetadata=L}else k.callProviderMetadata=L}else c.message.parts.push({type:"dynamic-tool",toolName:_.toolName,toolCallId:_.toolCallId,state:_.state,input:I.input,output:I.output,errorText:I.errorText,preliminary:I.preliminary,providerExecuted:I.providerExecuted,title:_.title,...I.providerMetadata!=null&&(_.state==="output-available"||_.state==="output-error")?{resultProviderMetadata:I.providerMetadata}:{},...I.providerMetadata!=null&&!(_.state==="output-available"||_.state==="output-error")?{callProviderMetadata:I.providerMetadata}:{}})}async function S(_){if(_!=null){const P=c.message.metadata!=null?bae(c.message.metadata,_):_;e!=null&&await gF({value:P,schema:e,context:{field:"message.metadata",entityId:c.message.id}}),c.message.metadata=P}}switch(o.type){case"text-start":{const _={type:"text",text:"",providerMetadata:o.providerMetadata,state:"streaming"};c.activeTextParts[o.id]=_,c.message.parts.push(_),h();break}case"text-delta":{const _=c.activeTextParts[o.id];if(_==null)throw new Hp({chunkType:"text-delta",chunkId:o.id,message:`Received text-delta for missing text part with ID "${o.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});_.text+=o.delta,_.providerMetadata=(d=o.providerMetadata)!=null?d:_.providerMetadata,h();break}case"text-end":{const _=c.activeTextParts[o.id];if(_==null)throw new Hp({chunkType:"text-end",chunkId:o.id,message:`Received text-end for missing text part with ID "${o.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});_.state="done",_.providerMetadata=(m=o.providerMetadata)!=null?m:_.providerMetadata,delete c.activeTextParts[o.id],h();break}case"reasoning-start":{const _={type:"reasoning",text:"",providerMetadata:o.providerMetadata,state:"streaming"};c.activeReasoningParts[o.id]=_,c.message.parts.push(_),h();break}case"reasoning-delta":{const _=c.activeReasoningParts[o.id];if(_==null)throw new Hp({chunkType:"reasoning-delta",chunkId:o.id,message:`Received reasoning-delta for missing reasoning part with ID "${o.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});_.text+=o.delta,_.providerMetadata=(g=o.providerMetadata)!=null?g:_.providerMetadata,h();break}case"reasoning-end":{const _=c.activeReasoningParts[o.id];if(_==null)throw new Hp({chunkType:"reasoning-end",chunkId:o.id,message:`Received reasoning-end for missing reasoning part with ID "${o.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});_.providerMetadata=(x=o.providerMetadata)!=null?x:_.providerMetadata,_.state="done",delete c.activeReasoningParts[o.id],h();break}case"file":{c.message.parts.push({type:"file",mediaType:o.mediaType,url:o.url,...o.providerMetadata!=null?{providerMetadata:o.providerMetadata}:{}}),h();break}case"source-url":{c.message.parts.push({type:"source-url",sourceId:o.sourceId,url:o.url,title:o.title,providerMetadata:o.providerMetadata}),h();break}case"source-document":{c.message.parts.push({type:"source-document",sourceId:o.sourceId,mediaType:o.mediaType,title:o.title,filename:o.filename,providerMetadata:o.providerMetadata}),h();break}case"tool-input-start":{const _=c.message.parts.filter(k8);c.partialToolCalls[o.toolCallId]={text:"",toolName:o.toolName,index:_.length,dynamic:o.dynamic,title:o.title},o.dynamic?E({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title,providerMetadata:o.providerMetadata}):w({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title,providerMetadata:o.providerMetadata}),h();break}case"tool-input-delta":{const _=c.partialToolCalls[o.toolCallId];if(_==null)throw new Hp({chunkType:"tool-input-delta",chunkId:o.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${o.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});_.text+=o.inputTextDelta;const{value:P}=await iy(_.text);_.dynamic?E({toolCallId:o.toolCallId,toolName:_.toolName,state:"input-streaming",input:P,title:_.title}):w({toolCallId:o.toolCallId,toolName:_.toolName,state:"input-streaming",input:P,title:_.title}),h();break}case"tool-input-available":{o.dynamic?E({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}):w({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}),h(),s&&!o.providerExecuted&&await s({toolCall:o});break}case"tool-input-error":{const _=c.message.parts.filter(gd).find(A=>A.toolCallId===o.toolCallId);(_!=null?_.type==="dynamic-tool":!!o.dynamic)?E({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}):w({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:void 0,rawInput:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}),h();break}case"tool-approval-request":{const _=O(o.toolCallId);_.state="approval-requested",_.approval={id:o.approvalId},h();break}case"tool-output-denied":{const _=O(o.toolCallId);_.state="output-denied",h();break}case"tool-output-available":{const _=O(o.toolCallId);_.type==="dynamic-tool"?E({toolCallId:o.toolCallId,toolName:_.toolName,state:"output-available",input:_.input,output:o.output,preliminary:o.preliminary,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:_.title}):w({toolCallId:o.toolCallId,toolName:C8(_),state:"output-available",input:_.input,output:o.output,providerExecuted:o.providerExecuted,preliminary:o.preliminary,providerMetadata:o.providerMetadata,title:_.title}),h();break}case"tool-output-error":{const _=O(o.toolCallId);_.type==="dynamic-tool"?E({toolCallId:o.toolCallId,toolName:_.toolName,state:"output-error",input:_.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:_.title}):w({toolCallId:o.toolCallId,toolName:C8(_),state:"output-error",input:_.input,rawInput:_.rawInput,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:_.title}),h();break}case"start-step":{c.message.parts.push({type:"step-start"});break}case"finish-step":{c.activeTextParts={},c.activeReasoningParts={};break}case"start":{o.messageId!=null&&(c.message.id=o.messageId),await S(o.messageMetadata),(o.messageId!=null||o.messageMetadata!=null)&&h();break}case"finish":{o.finishReason!=null&&(c.finishReason=o.finishReason),await S(o.messageMetadata),o.messageMetadata!=null&&h();break}case"message-metadata":{await S(o.messageMetadata),o.messageMetadata!=null&&h();break}case"error":{i?.(new Error(o.errorText));break}default:if(pze(o)){if(n?.[o.type]!=null){const A=c.message.parts.findIndex(I=>"id"in I&&"data"in I&&I.id===o.id&&I.type===o.type),k=A>=0?A:c.message.parts.length;await gF({value:o.data,schema:n[o.type],context:{field:`message.parts[${k}].data`,entityName:o.type,entityId:o.id}})}const _=o;if(_.transient){a?.(_);break}const P=_.id!=null?c.message.parts.find(A=>_.type===A.type&&_.id===A.id):void 0;P!=null?P.data=_.data:c.message.parts.push(_),a?.(_),h()}}l.enqueue(o)})}}))}async function yze({stream:t,onError:e}){const n=t.getReader();try{for(;;){const{done:r}=await n.read();if(r)break}}catch(r){e?.(r)}finally{n.releaseLock()}}ry({prefix:"aitxt",size:24});ry({prefix:"aiobj",size:24});var xze=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(t){return new Promise((e,n)=>{this.queue.push(async()=>{try{await t(),e()}catch(r){n(r)}}),this.processQueue()})}};ry({prefix:"aiobj",size:24});async function Oze(t){if(t==null)return[];if(!globalThis.FileList||!(t instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(t).map(async e=>{const{name:n,type:r}=e,i=await new Promise((s,a)=>{const o=new FileReader;o.onload=l=>{var c;s((c=l.target)==null?void 0:c.result)},o.onerror=l=>a(l),o.readAsDataURL(e)});return{type:"file",mediaType:r,filename:n,url:i}}))}var bze=class{constructor({api:t="/api/chat",credentials:e,headers:n,body:r,fetch:i,prepareSendMessagesRequest:s,prepareReconnectToStreamRequest:a}){this.api=t,this.credentials=e,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=s,this.prepareReconnectToStreamRequest=a}async sendMessages({abortSignal:t,...e}){var n,r,i,s,a;const o=await rh(this.body),l=await rh(this.headers),c=await rh(this.credentials),h={...jp(l),...jp(e.headers)},d=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:e.chatId,messages:e.messages,body:{...o,...e.body},headers:h,credentials:c,requestMetadata:e.metadata,trigger:e.trigger,messageId:e.messageId})),m=(r=d?.api)!=null?r:this.api,g=d?.headers!==void 0?jp(d.headers):h,x=d?.body!==void 0?d.body:{...o,...e.body,id:e.chatId,messages:e.messages,trigger:e.trigger,messageId:e.messageId},O=(i=d?.credentials)!=null?i:c,E=await((s=this.fetch)!=null?s:globalThis.fetch)(m,{method:"POST",headers:{"Content-Type":"application/json",...g},body:JSON.stringify(x),credentials:O,signal:t});if(!E.ok)throw new Error((a=await E.text())!=null?a:"Failed to fetch the chat response.");if(!E.body)throw new Error("The response body is empty.");return this.processResponseStream(E.body)}async reconnectToStream(t){var e,n,r,i,s;const a=await rh(this.body),o=await rh(this.headers),l=await rh(this.credentials),c={...jp(o),...jp(t.headers)},h=await((e=this.prepareReconnectToStreamRequest)==null?void 0:e.call(this,{api:this.api,id:t.chatId,body:{...a,...t.body},headers:c,credentials:l,requestMetadata:t.metadata})),d=(n=h?.api)!=null?n:`${this.api}/${t.chatId}/stream`,m=h?.headers!==void 0?jp(h.headers):c,g=(r=h?.credentials)!=null?r:l,O=await((i=this.fetch)!=null?i:globalThis.fetch)(d,{method:"GET",headers:m,credentials:g});if(O.status===204)return null;if(!O.ok)throw new Error((s=await O.text())!=null?s:"Failed to fetch the chat response.");if(!O.body)throw new Error("The response body is empty.");return this.processResponseStream(O.body)}},Sae=class extends bze{constructor(t={}){super(t)}processResponseStream(t){return ZLe({stream:t,schema:dze}).pipeThrough(new TransformStream({async transform(e,n){if(!e.success)throw e.error;n.enqueue(e.value)}}))}},wze=class{constructor({generateId:t=sae,id:e=t(),transport:n=new Sae,messageMetadataSchema:r,dataPartSchemas:i,state:s,onError:a,onToolCall:o,onFinish:l,onData:c,sendAutomaticallyWhen:h}){this.activeResponse=void 0,this.jobExecutor=new xze,this.sendMessage=async(d,m)=>{var g,x,O,w;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(g=this.lastMessage)==null?void 0:g.id,...m});return}let E;if("text"in d||"files"in d?E={parts:[...Array.isArray(d.files)?d.files:await Oze(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:E=d,d.messageId!=null){const S=this.state.messages.findIndex(_=>_.id===d.messageId);if(S===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[S].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,S+1),this.state.replaceMessage(S,{...E,id:d.messageId,role:(x=E.role)!=null?x:"user",metadata:d.metadata})}else this.state.pushMessage({...E,id:(O=E.id)!=null?O:this.generateId(),role:(w=E.role)!=null?w:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...m})},this.regenerate=async({messageId:d,...m}={})=>{const g=d==null?this.state.messages.length-1:this.state.messages.findIndex(x=>x.id===d);if(g===-1)throw new Error(`message ${d} not found`);this.state.messages=this.state.messages.slice(0,this.messages[g].role==="assistant"?g:g+1),await this.makeRequest({trigger:"regenerate-message",messageId:d,...m})},this.resumeStream=async(d={})=>{await this.makeRequest({trigger:"resume-stream",...d})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:d,approved:m,reason:g,options:x})=>this.jobExecutor.run(async()=>{const O=this.state.messages,w=O[O.length-1],E=S=>gd(S)&&S.state==="approval-requested"&&S.approval.id===d?{...S,state:"approval-responded",approval:{id:d,approved:m,reason:g}}:S;this.state.replaceMessage(O.length-1,{...w,parts:w.parts.map(E)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(E)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(S=>{var _;S&&this.makeRequest({trigger:"submit-message",messageId:(_=this.lastMessage)==null?void 0:_.id,...x})})}),this.addToolOutput=async({state:d="output-available",toolCallId:m,output:g,errorText:x,options:O})=>this.jobExecutor.run(async()=>{const w=this.state.messages,E=w[w.length-1],S=_=>gd(_)&&_.toolCallId===m?{..._,state:d,output:g,errorText:x}:_;this.state.replaceMessage(w.length-1,{...E,parts:E.parts.map(S)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(S)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(_=>{var P;_&&this.makeRequest({trigger:"submit-message",messageId:(P=this.lastMessage)==null?void 0:P.id,...O})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.abortController&&this.activeResponse.abortController.abort()},this.id=e,this.transport=n,this.generateId=t,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=s,this.onError=a,this.onToolCall=o,this.onFinish=l,this.onData=c,this.sendAutomaticallyWhen=h}get status(){return this.state.status}setStatus({status:t,error:e}){this.status!==t&&(this.state.status=t,this.state.error=e)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(t){this.state.messages=t}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const t=this.sendAutomaticallyWhen({messages:this.state.messages});return t&&typeof t=="object"&&"then"in t?await t:t}async makeRequest({trigger:t,metadata:e,headers:n,body:r,messageId:i}){var s,a,o;let l;if(t==="resume-stream")try{const g=await this.transport.reconnectToStream({chatId:this.id,metadata:e,headers:n,body:r});if(g==null)return;l=g}catch(g){this.onError&&g instanceof Error&&this.onError(g),this.setStatus({status:"error",error:g});return}this.setStatus({status:"submitted",error:void 0});const c=this.lastMessage;let h=!1,d=!1,m=!1;try{const g={state:gze({lastMessage:this.state.snapshot(c),messageId:this.generateId()}),abortController:new AbortController};g.abortController.signal.addEventListener("abort",()=>{h=!0}),this.activeResponse=g;let x;t==="resume-stream"?x=l:x=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:g.abortController.signal,metadata:e,headers:n,body:r,trigger:t,messageId:i});const O=w=>this.jobExecutor.run(()=>w({state:g.state,write:()=>{var E;this.setStatus({status:"streaming"}),g.state.message.id===((E=this.lastMessage)==null?void 0:E.id)?this.state.replaceMessage(this.state.messages.length-1,g.state.message):this.state.pushMessage(g.state.message)}}));await yze({stream:vze({stream:x,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:O,onError:w=>{throw w}}),onError:w=>{throw w}}),this.setStatus({status:"ready"})}catch(g){if(h||g.name==="AbortError")return h=!0,this.setStatus({status:"ready"}),null;m=!0,g instanceof TypeError&&(g.message.toLowerCase().includes("fetch")||g.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&g instanceof Error&&this.onError(g),this.setStatus({status:"error",error:g})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:h,isDisconnect:d,isError:m,finishReason:(s=this.activeResponse)==null?void 0:s.state.finishReason})}catch(g){console.error(g)}this.activeResponse=void 0}!m&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(o=this.lastMessage)==null?void 0:o.id,metadata:e,headers:n,body:r})}};const vF=(t,e)=>{if(e==null)return[];let n=t.findIndex(r=>r.id===e);if(n===-1)throw new Error("useVercelAIThreadState: Message not found. This is likely an internal bug in assistant-ui.");for(;t[n+1]?.role==="assistant";)n++;return t.slice(0,n+1)},yF=t=>{const n=[...t.content.filter(r=>r.type!=="file"),...t.attachments?.flatMap(r=>r.content.map(i=>({...i,filename:r.name})))??[]].map(r=>{switch(r.type){case"text":return{type:"text",text:r.text};case"image":return{type:"file",url:r.image,...r.filename&&{filename:r.filename},mediaType:"image/png"};case"file":return{type:"file",url:r.data,mediaType:r.mimeType,...r.filename&&{filename:r.filename}};default:throw new Error(`Unsupported part type: ${r.type}`)}});return{role:t.role,parts:n,metadata:t.metadata}},Sze=t=>new Promise((e,n)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=i=>n(i),r.readAsDataURL(t)}),Eze={accept:"*",async add({file:t}){return{id:sae(),type:t.type.startsWith("image/")?"image":"file",name:t.name,file:t,contentType:t.type,content:[],status:{type:"requires-action",reason:"composer-send"}}},async send(t){return{...t,status:{type:"complete"},content:[{type:"file",mimeType:t.contentType??"",filename:t.name,data:await Sze(t.file)}]}},async remove(){}},xF=t=>jc(t);function _ze(t){return t.replace(/[}\]"]+$/,"")}const kze=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),T8=(t,e,n)=>{if(Array.isArray(t))return t.map((r,i)=>T8(r,`${e}[${i}]`,n));if(t&&typeof t=="object"){const r=t,i=Object.keys(r),s=n.get(e)??[],a=new Set(s),o=[...s.filter(l=>kze(r,l)),...i.filter(l=>!a.has(l))];return n.set(e,o),Object.fromEntries(o.map(l=>[l,T8(r[l],`${e}.${l}`,n)]))}return t};function Cze(t,e,n){const r=t?.get(e)??new Map;t?.set(e,r);const i=T8(n,"$",r);return JSON.stringify(i)}function Tze(t,e){return t.state==="approval-requested"&&"approval"in t?{interrupt:{type:"human",payload:t.approval},status:{type:"requires-action",reason:"interrupt"}}:e?.type==="interrupt"?{interrupt:e.payload,status:{type:"requires-action",reason:"interrupt"}}:{}}function Aze(t,e){if(!t.parts||t.parts.length===0)return[];const n=t.parts.filter(i=>i.type!=="step-start"&&(t.role!=="user"||i.type!=="file")).map(i=>{if(i.type==="text")return{type:"text",text:i.text};if(i.type==="reasoning")return{type:"reasoning",text:i.text};if(gd(i)){const s=mze(i),a=i.toolCallId,o=`${t.id}:${a}`,l=i.input||{};let c,h=!1;i.state==="output-available"?c=i.output:i.state==="output-error"?(h=!0,c={error:i.errorText}):i.state==="output-denied"&&(h=!0,c={error:i.approval.reason||"Tool approval denied"});let d=Cze(e.toolArgsKeyOrderCache,o,l);i.state==="input-streaming"?d=_ze(d):e.toolArgsKeyOrderCache?.delete(o);const m=e.toolStatuses?.[a];return{type:"tool-call",toolName:s,toolCallId:a,argsText:d,args:l,result:c,isError:h,...Tze(i,m)}}return i.type==="source-url"?{type:"source",sourceType:"url",id:i.sourceId,url:i.url,title:i.title||""}:i.type==="file"?{type:"file",data:i.url,mimeType:i.mediaType,...i.filename!=null&&{filename:i.filename}}:i.type==="source-document"?(console.warn("Source document parts are not yet supported in conversion"),null):i.type.startsWith("data-")?{type:"data",name:i.type.substring(5),data:i.data}:(console.warn(`Unsupported message part type: ${i.type}`),null)}).filter(Boolean),r=new Set;return n.filter(i=>{if(i.type==="tool-call"&&i.toolCallId!=null){if(r.has(i.toolCallId))return!1;r.add(i.toolCallId)}return!0})}const C6=m6e((t,e)=>{const n=new Date,r=Aze(t,e);switch(t.role){case"user":return{role:"user",id:t.id,createdAt:n,content:r,attachments:t.parts?.filter(i=>i.type==="file").map((i,s)=>({id:s.toString(),type:i.mediaType.startsWith("image/")?"image":"file",name:i.filename??"file",content:[i.mediaType.startsWith("image/")?{type:"image",image:i.url,filename:i.filename}:{type:"file",filename:i.filename,data:i.url,mimeType:i.mediaType}],contentType:i.mediaType??"unknown/unknown",status:{type:"complete"}})),metadata:t.metadata};case"system":case"assistant":{const i=e.messageTiming?.[t.id];return{role:t.role,id:t.id,createdAt:n,content:r,metadata:{...t.metadata,...i&&{timing:i}}}}default:return console.warn(`Unsupported message role: ${t.role}`),[]}}),T6={format:"ai-sdk/v6",encode({message:{id:t,parts:e,...n}}){return{...n,parts:e}},decode(t){return{parentId:t.parent_id,message:{id:t.id,...t.content}}},getId(t){return t.id}},Eae=(t,e)=>({headId:e.headId,messages:e.messages.map(n=>{const r=t([n.message])[0];return{...n,message:r}})}),Pze=(t,e,n,r,i)=>{const s=C.useRef(!1),a=kr(),o=C.useCallback(()=>a.threadListItem.source?a.threadListItem():null,[a]),[l,c]=C.useState(!1),h=C.useRef(new Set),d=C.useRef(i);C.useEffect(()=>{d.current=i}),C.useEffect(()=>{if(!e||s.current)return;const E=async()=>{c(!0);try{const S=await e.withFormat?.(r).load();if(S&&S.messages.length>0){const _=Eae(n,S);t.current.thread.import(_);const P=new lA;P.import(_);const A=P.getMessages();d.current(A.map(jc).flat()),h.current=new Set(_.messages.map(k=>k.message.id))}}catch(S){console.error("Failed to load message history:",S)}finally{c(!1)}};if(s.current=!0,!o()?.getState().remoteId){c(!1);return}E()},[e,r,n,t,o]);const m=C.useRef(null),g=C.useRef(null),x=C.useRef([]),O=C.useRef(!1),w=C.useRef(0);return C.useEffect(()=>{const E=t.current.thread.subscribe(()=>{const{isRunning:S}=t.current.thread.getState(),_=O.current;if(O.current=S,m.current!=null){const P=t.current.thread.getState().messages.at(-1);if(P?.role==="assistant"){const A=P.content.filter(k=>k.type==="tool-call").length;for(;w.current<A;)x.current.push(Date.now()-m.current),w.current++}}if(S){m.current==null&&(m.current=Date.now(),x.current=[],w.current=0),g.current&&(clearTimeout(g.current),g.current=null);return}_&&(m.current!=null&&x.current.push(Date.now()-m.current),g.current&&clearTimeout(g.current),g.current=setTimeout(async()=>{g.current=null;const P=t.current.thread.getState();if(P.isRunning)return;const A=x.current,k=A.length>0?A.at(-1):void 0;if(A.length===1&&k!=null){const F=P.messages.findLast(W=>W.role==="assistant");if(F){const W=F.content.filter(ee=>ee.type==="tool-call").length;if(W>0){const ee=W+1,G=k/ee;A.length=0;for(let re=0;re<ee;re++)A.push(Math.round((re+1)*G))}}}const I=A.length>1?A.map((F,W)=>({start_ms:W===0?0:A[W-1],end_ms:F})):void 0;m.current=null,x.current=[];const $={...k!=null?{durationMs:k}:void 0,...I!=null?{stepTimestamps:I}:void 0},{messages:L}=P;let Q=null;const H=F=>F.length>0?r.getId(F.at(-1)):null,j=F=>F.map((W,ee)=>({parentId:ee===0?Q:r.getId(F[ee-1]),message:W}));for(const F of L){const W=jc(F);if(!(F.status===void 0||F.status.type==="complete"||F.status.type==="incomplete")){Q=H(W)??Q;continue}if(h.current.has(F.id)){if(k!==void 0){const he=e?.withFormat?.(r);let be=Q;for(const q of W){try{await he?.update?.({parentId:be,message:q},r.getId(q))}catch{}be=r.getId(q)}}Q=H(W)??Q;continue}h.current.add(F.id);const G=e?.withFormat?.(r),re=j(W);for(const he of re)await G?.append(he);Q=H(W)??Q,G?.reportTelemetry?.(re,$)}},0))});return()=>{E(),g.current&&(clearTimeout(g.current),g.current=null)}},[e,r,t]),l};function Mze(t){if(!t?.parts)return 0;let e=0;for(const n of t.parts)n.type==="text"&&(e+=n.text.length);return e}function Rze(t){if(!t?.parts)return 0;let e=0;for(const n of t.parts)gd(n)&&e++;return e}const Ize=(t,e)=>{const[n,r]=C.useState({}),i=C.useRef(null);return C.useEffect(()=>{const s=t.findLast(a=>a.role==="assistant");if(e&&s){(!i.current||i.current.messageId!==s.id)&&(i.current={messageId:s.id,startTime:Date.now(),lastContentLength:0,totalChunks:0});const a=i.current,o=Mze(s);o>a.lastContentLength&&(a.firstTokenTime===void 0&&(a.firstTokenTime=Date.now()-a.startTime),a.totalChunks++,a.lastContentLength=o)}else if(!e&&i.current){const a=i.current,o=Date.now()-a.startTime,l=Math.ceil(a.lastContentLength/4),c=Rze(s),h={streamStartTime:a.startTime,totalStreamTime:o,totalChunks:a.totalChunks,toolCallCount:c,...a.firstTokenTime!==void 0&&{firstTokenTime:a.firstTokenTime},...l>0&&{tokenCount:l},...o>0&&l>0&&{tokensPerSecond:l/(o/1e3)}};r(d=>({...d,[a.messageId]:h})),i.current=null}},[t,e]),n},Nze=(t,{adapters:e,toCreateMessage:n,cancelPendingToolCallsOnSend:r=!0}={})=>{const i=Rte(),[s,a]=C.useState({}),o=C.useRef(new Map),l=C.useRef(void 0),c=Object.values(s).some(S=>S?.type==="executing"),h=t.status==="submitted"||t.status==="streaming"||c,d=Ize(t.messages,h),m=C6.useThreadMessages({isRunning:h,messages:t.messages,metadata:C.useMemo(()=>({toolStatuses:s,messageTiming:d,toolArgsKeyOrderCache:o.current,...t.error&&{error:t.error.message}}),[s,d,t.error])}),[g]=C.useState(()=>({get current(){return E}})),x=n6e({state:{messages:m,isRunning:h},getTools:()=>g.current.thread.getModelContext().tools,onResult:S=>{S.type==="add-tool-result"&&t.addToolResult({tool:S.toolName,toolCallId:S.toolCallId,output:S.result,options:{metadata:l.current}})},setToolStatuses:a}),O=Pze(g,e?.history??i?.history,C6.toThreadMessages,T6,S=>{t.setMessages(S)}),w=async()=>{r&&(await x.abort(),t.setMessages(S=>{const _=S.at(-1);if(_?.role!=="assistant")return S;let P=!1;const A=_.parts?.map(k=>!gd(k)||k.state==="output-available"||k.state==="output-error"?k:(P=!0,{...k,state:"output-error",errorText:"User cancelled tool call by sending a new message."}));return P?[...S.slice(0,-1),{..._,parts:A}]:S}))},E=f6e({isRunning:h,messages:m,setMessages:S=>t.setMessages(S.map(xF).filter(Boolean).flat()),onImport:S=>t.setMessages(S.map(xF).filter(Boolean).flat()),onExportExternalState:()=>{const S=g.current.thread.export(),_=[],P=new Map;for(const k of S.messages){const I=jc(k.message);let $=k.parentId!=null?P.get(k.parentId)??k.parentId:null;for(const L of I)_.push({parentId:$,message:L}),$=T6.getId(L);I.length>0&&P.set(k.message.id,T6.getId(I[I.length-1]))}const A={messages:_};return S.headId!=null&&(A.headId=P.get(S.headId)??S.headId),A},onLoadExternalState:S=>{const _=Eae(C6.toThreadMessages,S);g.current.thread.import(_)},onCancel:async()=>{t.stop(),await x.abort()},onNew:async S=>{l.current=S.runConfig,await w();const _=(n??yF)(S);await t.sendMessage(_,{metadata:S.runConfig})},onEdit:async S=>{l.current=S.runConfig;const _=vF(t.messages,S.parentId);t.setMessages(_);const P=(n??yF)(S);await t.sendMessage(P,{metadata:S.runConfig})},onReload:async(S,_)=>{l.current=_.runConfig;const P=vF(t.messages,S);t.setMessages(P),await t.regenerate({metadata:_.runConfig})},onAddToolResult:({toolCallId:S,result:_,isError:P})=>{const A={metadata:l.current};P?t.addToolOutput({state:"output-error",tool:S,toolCallId:S,errorText:typeof _=="string"?_:JSON.stringify(_),options:A}):t.addToolOutput({state:"output-available",tool:S,toolCallId:S,output:_,options:A})},onResumeToolCall:S=>x.resume(S.toolCallId,S.payload),adapters:{attachments:Eze,...i,...e},isLoading:O});return E};var A6,OF;function $ze(){if(OF)return A6;OF=1;function t(e,n){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let r,i=0;return function(...a){clearTimeout(r);const o=Date.now(),l=o-i,c=n-l;c<=0?(i=o,e.apply(this,a)):r=setTimeout(()=>{i=Date.now(),e.apply(this,a)},c)}}return A6=t,A6}var Lze=$ze();const zze=Zh(Lze);var _ae=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},sr=(t,e,n)=>(_ae(t,e,"read from private field"),n?n.call(t):e.get(t)),vl=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},nh=(t,e,n,r)=>(_ae(t,e,"write to private field"),e.set(t,n),n);function Dze(t,e){return e!=null?zze(t,e):t}var La,zO,DO,D0,Q0,F0,Kp,A8,P8,Qze=class{constructor(t=[]){vl(this,La,void 0),vl(this,zO,"ready"),vl(this,DO,void 0),vl(this,D0,new Set),vl(this,Q0,new Set),vl(this,F0,new Set),this.pushMessage=e=>{nh(this,La,sr(this,La).concat(e)),sr(this,Kp).call(this)},this.popMessage=()=>{nh(this,La,sr(this,La).slice(0,-1)),sr(this,Kp).call(this)},this.replaceMessage=(e,n)=>{nh(this,La,[...sr(this,La).slice(0,e),this.snapshot(n),...sr(this,La).slice(e+1)]),sr(this,Kp).call(this)},this.snapshot=e=>structuredClone(e),this["~registerMessagesCallback"]=(e,n)=>{const r=n?Dze(e,n):e;return sr(this,D0).add(r),()=>{sr(this,D0).delete(r)}},this["~registerStatusCallback"]=e=>(sr(this,Q0).add(e),()=>{sr(this,Q0).delete(e)}),this["~registerErrorCallback"]=e=>(sr(this,F0).add(e),()=>{sr(this,F0).delete(e)}),vl(this,Kp,()=>{sr(this,D0).forEach(e=>e())}),vl(this,A8,()=>{sr(this,Q0).forEach(e=>e())}),vl(this,P8,()=>{sr(this,F0).forEach(e=>e())}),nh(this,La,t)}get status(){return sr(this,zO)}set status(t){nh(this,zO,t),sr(this,A8).call(this)}get error(){return sr(this,DO)}set error(t){nh(this,DO,t),sr(this,P8).call(this)}get messages(){return sr(this,La)}set messages(t){nh(this,La,[...t]),sr(this,Kp).call(this)}};La=new WeakMap;zO=new WeakMap;DO=new WeakMap;D0=new WeakMap;Q0=new WeakMap;F0=new WeakMap;Kp=new WeakMap;A8=new WeakMap;P8=new WeakMap;var Jp,bF=class extends wze{constructor({messages:t,...e}){const n=new Qze(t);super({...e,state:n}),vl(this,Jp,void 0),this["~registerMessagesCallback"]=(r,i)=>sr(this,Jp)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>sr(this,Jp)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>sr(this,Jp)["~registerErrorCallback"](r),nh(this,Jp,n)}};Jp=new WeakMap;function Fze({experimental_throttle:t,resume:e=!1,...n}={}){const r=C.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(r.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const i={...n,onToolCall:m=>{var g,x;return(x=(g=r.current).onToolCall)==null?void 0:x.call(g,m)},onData:m=>{var g,x;return(x=(g=r.current).onData)==null?void 0:x.call(g,m)},onFinish:m=>{var g,x;return(x=(g=r.current).onFinish)==null?void 0:x.call(g,m)},onError:m=>{var g,x;return(x=(g=r.current).onError)==null?void 0:x.call(g,m)},sendAutomaticallyWhen:m=>{var g,x,O;return(O=(x=(g=r.current).sendAutomaticallyWhen)==null?void 0:x.call(g,m))!=null?O:!1}},s=C.useRef("chat"in n?n.chat:new bF(i));("chat"in n&&n.chat!==s.current||"id"in n&&s.current.id!==n.id)&&(s.current="chat"in n?n.chat:new bF(i));const o=C.useCallback(m=>s.current["~registerMessagesCallback"](m,t),[t,s.current.id]),l=C.useSyncExternalStore(o,()=>s.current.messages,()=>s.current.messages),c=C.useSyncExternalStore(s.current["~registerStatusCallback"],()=>s.current.status,()=>s.current.status),h=C.useSyncExternalStore(s.current["~registerErrorCallback"],()=>s.current.error,()=>s.current.error),d=C.useCallback(m=>{typeof m=="function"&&(m=m(s.current.messages)),s.current.messages=m},[s]);return C.useEffect(()=>{e&&s.current.resumeStream()},[e,s]),{id:s.current.id,messages:l,setMessages:d,sendMessage:s.current.sendMessage,regenerate:s.current.regenerate,clearError:s.current.clearError,stop:s.current.stop,error:h,resumeStream:s.current.resumeStream,status:c,addToolResult:s.current.addToolOutput,addToolOutput:s.current.addToolOutput,addToolApprovalResponse:s.current.addToolApprovalResponse}}class M8 extends Sae{runtime;constructor(e){super({...e,prepareSendMessagesRequest:async n=>{const r=this.runtime?.thread.getModelContext(),i=(await this.runtime?.threads.mainItem.initialize())?.remoteId??n.id,s={...n,body:{callSettings:r?.callSettings,system:r?.system,config:r?.config,tools:l7e(r?.tools??{}),...n?.body}},a=await e?.prepareSendMessagesRequest?.(s);return{...a,body:a?.body??{...s.body,id:i,messages:n.messages,trigger:n.trigger,messageId:n.messageId,metadata:n.requestMetadata}}}})}setRuntime(e){this.runtime=e}}const Vze=t=>{const e=C.useRef(t);return C.useEffect(()=>{e.current=t}),C.useMemo(()=>new Proxy(e.current,{get(r,i){const s=e.current[i];return typeof s=="function"?s.bind(e.current):s}}),[])},Bze=t=>{const{adapters:e,transport:n,toCreateMessage:r,...i}=t??{},s=Vze(n??new M8),a=Qt(c=>c.threadListItem.id),o=Fze({...i,id:a,transport:s}),l=Nze(o,{adapters:e,...r&&{toCreateMessage:r}});return s instanceof M8&&s.setRuntime(l),l},jze=({cloud:t,...e}={})=>{const n=K6e({cloud:t});return O6e({runtimeHook:function(){return Bze(e)},adapter:n,allowNesting:!0})},R8="cms-agent-session-id";function Hze(){try{return localStorage.getItem(R8)}catch{return null}}function wF(t){try{t===null?localStorage.removeItem(R8):localStorage.setItem(R8,t)}catch{}}const kae=C.createContext(null);function lP(){const t=C.useContext(kae);if(!t)throw new Error("useAgentRuntime must be used inside AgentRuntimeProvider");return t}function Zze({children:t,onRequestOpen:e}){const[n,r]=C.useState(()=>Hze()),[i,s]=C.useState(null),{data:a,isLoading:o,refetch:l}=qo({queryKey:["claude-status"],queryFn:()=>r3e(),retry:!1,staleTime:6e4}),c=a?.authenticated===!0,{data:h=[]}=qo({queryKey:["conversations"],queryFn:()=>a3e(20),enabled:c});C.useEffect(()=>{if(!n||!c||i!==null)return;let O=!1;return Jz(n).then(w=>{O||s(w)}),()=>{O=!0}},[n,c,i]);const d=C.useMemo(()=>new M8({api:n?`/astrocms/api/claude/chat?sessionId=${encodeURIComponent(n)}`:"/astrocms/api/claude/chat"}),[n]),m=jze({transport:d}),g=C.useCallback(()=>{r(null),s(null),wF(null)},[]),x=C.useCallback(async O=>{r(O),wF(O);const w=await Jz(O);s(w)},[]);return M.jsx(REe,{runtime:m,children:M.jsx(Uze,{status:a,statusLoading:o,isAuthenticated:c,refetchStatus:l,sessionId:n,loadedMessages:i,conversations:h,resetSession:g,selectConversation:x,onRequestOpen:e,children:t})})}function Uze({children:t,status:e,statusLoading:n,isAuthenticated:r,refetchStatus:i,sessionId:s,loadedMessages:a,conversations:o,resetSession:l,selectConversation:c,onRequestOpen:h}){const d=kr(),m=Qt(_=>_.thread.isRunning),g=C.useRef(h);g.current=h;const x=C.useCallback(()=>{l(),d.threads().switchToNewThread()},[d,l]),O=C.useCallback(_=>{const P=_.trim();P&&(g.current(),d.thread().append(P))},[d]),w=C.useCallback(async _=>{const P=_.trim();P&&(g.current(),l(),await d.threads().switchToNewThread(),d.thread().append(P))},[d,l]),E=C.useCallback(()=>{g.current()},[]),S=C.useMemo(()=>({status:e,statusLoading:n,isAuthenticated:r,refetchStatus:i,sessionId:s,loadedMessages:a,conversations:o,startNewConversation:x,selectConversation:c,sendPrompt:O,sendInNewConversation:w,requestOpen:E,isRunning:m}),[e,n,r,i,s,a,o,x,c,O,w,E,m]);return M.jsx(kae.Provider,{value:S,children:t})}function qze({open:t}){const{status:e,statusLoading:n,isAuthenticated:r,refetchStatus:i,sessionId:s,loadedMessages:a,conversations:o,startNewConversation:l,selectConversation:c}=lP(),{width:h,handleMouseDown:d}=See({storageKey:"cms-agent-panel-width",defaultWidth:380,minWidth:250,maxWidth:800,side:"left"});return M.jsxs(M.Fragment,{children:[t&&M.jsx(Eee,{side:"left",onMouseDown:d}),M.jsxs("aside",{style:{width:t?h:0},className:`bg-bg-panel flex flex-col shrink-0 overflow-hidden ${t?"":"hidden"}`,"aria-hidden":!t,children:[M.jsxs("div",{className:"px-3 py-2.5 border-b border-border font-semibold text-xs flex items-center justify-between",children:[M.jsx("span",{children:"Agent"}),r&&M.jsx("button",{onClick:l,className:"p-1 rounded hover:bg-bg-hover text-text-muted hover:text-text cursor-pointer","aria-label":"New conversation",tabIndex:0,children:M.jsx(tMe,{size:14})})]}),n?M.jsx("div",{className:"flex-1 flex items-center justify-center text-text-muted text-xs",children:"Connecting to Claude..."}):r?M.jsx(GPe,{loadedMessages:a,conversations:o,onSelectConversation:c},s):M.jsx(rMe,{error:e?.error,onRetry:()=>i()})]})]})}const Cae=C.createContext(null);function Xze({filePath:t,children:e}){return M.jsx(Cae.Provider,{value:t,children:e})}function hw(){return C.useContext(Cae)}function Wze(){const{isAuthenticated:t,sendInNewConversation:e}=lP(),[n,r]=C.useState(""),[i,s]=C.useState(!1),a=C.useRef(null);C.useEffect(()=>{if(!i)return;function l(c){c.key==="Escape"&&a.current?.blur()}return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[i]);const o=C.useCallback(()=>{const l=n.trim();l&&(e(l),r(""),a.current?.blur())},[n,e]);return t?M.jsxs(M.Fragment,{children:[i&&M.jsx("button",{type:"button",tabIndex:-1,"aria-label":"Close prompt",onClick:()=>a.current?.blur(),className:"fixed inset-0 bg-black/20 backdrop-blur-sm z-30 cursor-default"}),M.jsx("div",{className:i?"pointer-events-auto fixed inset-x-0 mx-auto top-16 w-[min(720px,calc(100%-2rem))] z-40 shadow-2xl animate-header-prompt-in":"pointer-events-auto relative w-full max-w-md",children:M.jsxs("div",{className:`rounded-xl border bg-white transition-colors ${i?"border-primary ring-4 ring-primary/15":"border-border hover:border-gray-400"}`,children:[M.jsxs("label",{className:`flex items-start gap-2 cursor-text ${i?"px-4 py-3":"px-3 py-1.5"}`,children:[M.jsx("div",{className:"shrink-0 h-5 flex items-center text-primary",children:M.jsx(qie,{size:i?16:14})}),M.jsx("textarea",{ref:a,value:n,onChange:l=>r(l.target.value),onFocus:()=>s(!0),onBlur:()=>s(!1),onKeyDown:l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),o())},placeholder:i?"Ask AI to help with anything...":"Ask AI...",rows:i?3:1,className:`flex-1 resize-none outline-none bg-transparent text-sm leading-5 placeholder:text-text-muted ${i?"":"h-5 overflow-hidden"}`}),i&&M.jsx("button",{type:"button",onMouseDown:l=>{l.preventDefault(),o()},disabled:!n.trim(),"aria-label":"Send to agent",tabIndex:0,className:"shrink-0 p-2 rounded-lg bg-primary text-white enabled:hover:bg-primary-hover disabled:opacity-40 disabled:cursor-default cursor-pointer",children:M.jsx(nMe,{size:14})})]}),i&&M.jsx("div",{className:"px-4 pb-2 text-[10px] text-text-muted text-center",children:"Enter to send, Shift+Enter for new line, Esc to close"})]})})]}):null}function Tae(){return qo({queryKey:["gitStatus"],queryFn:gW,select:t=>t.files})}function Yze(){const t=ya(),e=C.useRef(void 0),{data:n}=qo({queryKey:["gitStatus"],queryFn:gW,select:r=>r.remote?.lastPulledAt??null});C.useEffect(()=>{e.current!==void 0&&n!==e.current&&(t.invalidateQueries({queryKey:["tree"]}),t.invalidateQueries({queryKey:["file"]}),t.invalidateQueries({queryKey:["folderMeta"]}),t.invalidateQueries({queryKey:["gitDiffs"]})),e.current=n},[n,t])}function Gze(){return qo({queryKey:["gitDiffs"],queryFn:Wxe,select:t=>t.diffs})}function Kze(){return qo({queryKey:["gitRemoteStatus"],queryFn:Jxe})}function z1(){const t=ya();return()=>{t.invalidateQueries({queryKey:["gitStatus"]}),t.invalidateQueries({queryKey:["gitDiffs"]}),t.invalidateQueries({queryKey:["gitRemoteStatus"]})}}function Jze(){const t=z1();return zo({mutationFn:async({message:e,push:n})=>{const r=await Yxe(e,n);if(!r.ok)throw new Error(r.error||"Commit failed");return r},onSuccess:t})}function eDe(){const t=z1(),e=ya();return zo({mutationFn:async()=>{const n=await e3e();if(!n.ok)throw new Error(n.error||"Pull failed");return n},onSuccess:()=>{t(),e.invalidateQueries({queryKey:["tree"]})}})}function tDe(){const t=z1(),e=ya();return zo({mutationFn:n=>n3e(n),onSuccess:()=>{t(),e.invalidateQueries({queryKey:["tree"]})}})}function nDe(){const t=z1(),e=ya();return zo({mutationFn:async({path:n,hunk:r})=>{const i=await t3e(n,r);if(!i.ok)throw new Error(i.error||"Discard hunk failed");return i},onSuccess:()=>{t(),e.invalidateQueries({queryKey:["tree"]})}})}function Aae(){const t=z1();return zo({mutationFn:e=>Gxe(e),onSuccess:t})}function Pae(){const t=z1();return zo({mutationFn:e=>Kxe(e),onSuccess:t})}function rDe(){const[t,e]=C.useState(!1),n=C.useRef(null),r=eDe(),{data:i}=Kze(),s=i?.updateAvailable===!0;C.useEffect(()=>{if(!t)return;function o(c){n.current?.contains(c.target)||e(!1)}function l(c){c.key==="Escape"&&e(!1)}return window.addEventListener("mousedown",o),window.addEventListener("keydown",l),()=>{window.removeEventListener("mousedown",o),window.removeEventListener("keydown",l)}},[t]);function a(){r.mutate(void 0,{onSuccess:()=>e(!1)})}return M.jsxs("div",{ref:n,className:"relative",children:[M.jsxs("button",{type:"button",onClick:()=>e(o=>!o),"aria-label":"More actions","aria-expanded":t,tabIndex:0,className:"relative p-1.5 rounded-md text-text-muted hover:bg-gray-100 hover:text-text cursor-pointer",children:[M.jsx(Rwe,{size:16}),s&&M.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-amber-500","aria-hidden":!0})]}),t&&M.jsxs("div",{role:"menu",className:"absolute right-0 top-full mt-1 w-60 rounded-md border border-border bg-white shadow-lg py-1 z-50",children:[M.jsxs("button",{type:"button",role:"menuitem",onClick:a,disabled:r.isPending,tabIndex:0,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-gray-50 disabled:opacity-50 disabled:cursor-default cursor-pointer",children:[M.jsx(Nwe,{size:13,className:"text-text-muted"}),M.jsx("span",{className:"flex-1",children:r.isPending?"Pulling...":"Pull from remote"}),s&&M.jsxs("span",{className:"text-[10px] text-amber-700 bg-amber-50 border border-amber-200 px-1.5 py-0.5 rounded",children:[i?.behind," new"]})]}),r.error&&M.jsx("div",{className:"px-3 py-2 text-[11px] text-danger",children:r.error.message}),i?.lastCheckedAt&&M.jsxs("div",{className:"px-3 py-1.5 text-[10px] text-text-muted border-t border-border mt-1",children:["Last check: ",new Date(i.lastCheckedAt).toLocaleTimeString()]})]})]})}function iDe({agentOpen:t,onToggleAgent:e,onNavigateGit:n}){const{data:r}=qo({queryKey:["public-config"],queryFn:Zxe,staleTime:1/0}),{data:i=[]}=Tae(),s=i.length;return M.jsxs("header",{className:"h-12 border-b border-border flex items-center gap-4 px-4 bg-white shrink-0 relative z-20",children:[M.jsx("span",{className:"font-semibold text-sm shrink-0",children:"AstroCMS"}),M.jsx("div",{className:"flex-1 flex justify-center",children:M.jsx(Wze,{})}),M.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[M.jsx(rDe,{}),M.jsx(Di,{active:t,onClick:e,children:"Agent"}),r?.devServer&&M.jsxs("a",{href:"/",target:"_blank",rel:"noopener noreferrer",className:"px-3 py-1 rounded-md border border-border bg-white text-text no-underline text-xs cursor-pointer hover:bg-gray-100 inline-flex items-center",children:["Preview ",M.jsx(Iwe,{className:"ml-1 align-middle"})]}),s>0&&M.jsx(Di,{variant:"success",onClick:n,children:M.jsxs("span",{className:"inline-flex items-center gap-1.5",children:["Review changes",M.jsx("span",{className:"inline-flex items-center justify-center min-w-4 h-4 px-1 rounded-full bg-white/25 text-white text-[10px] font-semibold",children:s})]})})]})]})}var sDe=Object.defineProperty,aDe=(t,e,n)=>e in t?sDe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ac=(t,e,n)=>aDe(t,typeof e!="symbol"?e+"":e,n);let oDe=class Mae{constructor(e=new Map){this.map=e}clone(){return new Mae(new Map(this.map))}increment(e){const n=this.map.get(e)??0;this.map.set(e,n+1)}decrement(e,n){let r=this.map.get(e);r!==void 0&&(r-=1,this.map.set(e,r),r===0&&n())}},C3=class{constructor(){Ac(this,"map",new Map)}getOrCreate(e){let n=this.map.get(e);return n===void 0&&(n=new Set,this.map.set(e,n)),n}get(e){return this.map.get(e)}use(e,n){const r=this.get(e);r!==void 0&&n(r)}delete(e){return this.map.delete(e)}};function Em(t,e){return e(t),t}function cP(){}const Rae="cell";function SF(t,e){return t===e}const fw=new Map;let lDe=class{constructor(e={}){Ac(this,"subscriptions",new C3),Ac(this,"singletonSubscriptions",new Map),Ac(this,"graph",new C3),Ac(this,"state",new Map),Ac(this,"distinctNodes",new Map),Ac(this,"executionMaps",new Map),Ac(this,"definitionRegistry",new Set),Ac(this,"combinedCells",[]);for(const n of Object.getOwnPropertySymbols(e))this.state.set(n,e[n])}cellInstance(e,n=!0,r=Symbol()){return this.state.has(r)||this.state.set(r,e),n!==!1&&!this.distinctNodes.has(r)&&this.distinctNodes.set(r,n===!0?SF:n),r}signalInstance(e=!0,n=Symbol()){return e!==!1&&this.distinctNodes.set(n,e===!0?SF:e),n}sub(e,n){this.register(e);const r=this.subscriptions.getOrCreate(e);return r.add(n),()=>r.delete(n)}singletonSub(e,n){return this.register(e),n===void 0?this.singletonSubscriptions.delete(e):this.singletonSubscriptions.set(e,n),()=>this.singletonSubscriptions.delete(e)}resetSingletonSubs(){this.singletonSubscriptions.clear()}subMultiple(e,n){const r=this.signalInstance();return this.connect({map:i=>(...s)=>{i(s)},sink:r,sources:e}),this.sub(r,n)}pubIn(e){var n;const r=Reflect.ownKeys(e),i=this.getExecutionMap(r),s=i.refCount.clone(),a=i.participatingNodes.slice(),o=new Map(this.state),l=c=>{this.graph.use(c,h=>{for(const{sources:d,sink:m}of h)d.has(c)&&s.decrement(m,()=>{a.splice(a.indexOf(m),1),l(m)})})};for(;;){const c=a.shift();if(c===void 0)break;const h=c;let d=!1;const m=g=>{const x=this.distinctNodes.get(h);if(x!=null&&x(o.get(h),g)){d=!1;return}d=!0,o.set(h,g),this.state.has(h)&&this.state.set(h,g)};if(Object.prototype.hasOwnProperty.call(e,h)?m(e[h]):i.projections.use(h,g=>{for(const x of g){const O=[...Array.from(x.sources),...Array.from(x.pulls)].map(w=>o.get(w));x.map(m)(...O)}}),d){const g=o.get(h);this.inContext(()=>{this.subscriptions.use(h,x=>{for(const O of x)O(g)})}),(n=this.singletonSubscriptions.get(h))==null||n(g)}else l(h)}}connect({sources:e,pulls:n=[],map:r,sink:i}){const s={map:r,pulls:new Set(n),sink:this.register(i),sources:new Set(e)};for(const a of[...e,...n])this.register(a),this.graph.getOrCreate(a).add(s);this.executionMaps.clear()}pub(e,n){this.pubIn({[e]:n})}pipe(e,...n){return this.combineOperators(...n)(e)}transformer(...e){return n=>Em(this.signalInstance(),r=>(this.link(this.pipe(r,...e),n),r))}link(e,n){this.connect({map:r=>i=>{r(i)},sink:n,sources:[e]})}combine(...e){return Em(this.signalInstance(),n=>{this.connect({map:r=>(...i)=>{r(i)},sink:n,sources:e})})}combineCells(...e){const n=this.combinedCells.find(i=>e.length===i.sources.length&&e.every((s,a)=>s===i.sources[a]));if(n)return n.cell;const r=this.cellInstance(e.map(i=>this.getValue(i)),!0);return this.connect({map:i=>(...s)=>{i(s)},sink:r,sources:e}),this.combinedCells.push({sources:e,cell:r}),r}getValue(e){return this.register(e),this.state.get(e)}getValues(e){return e.map(n=>this.getValue(n))}register(e){const n=fw.get(e);return n===void 0||this.definitionRegistry.has(e)?e:(this.definitionRegistry.add(e),Em(n.type===Rae?this.cellInstance(n.initial,n.distinct,e):this.signalInstance(n.distinct,e),r=>{this.inContext(()=>{n.init(this,r)})}))}inContext(e){return e()}changeWith(e,n,r){this.connect({sources:[n],pulls:[e],sink:e,map:i=>(s,a)=>{i(r(a,s))}})}calculateExecutionMap(e){const n=[],r=new Set,i=new C3,s=new oDe,a=new C3,o=(l,c=0)=>{s.increment(l),!r.has(l)&&(this.register(l),i.use(l,h=>{c=Math.max(...Array.from(h).map(d=>n.indexOf(d)))+1}),this.graph.use(l,h=>{for(const d of h)d.sources.has(l)?(a.getOrCreate(d.sink).add(d),o(d.sink,c)):i.getOrCreate(d.sink).add(l)}),r.add(l),n.splice(c,0,l))};return e.forEach(o),{participatingNodes:n,pendingPulls:i,projections:a,refCount:s}}getExecutionMap(e){let n=e;if(e.length===1){n=e[0];const i=this.executionMaps.get(n);if(i!==void 0)return i}else for(const[i,s]of this.executionMaps.entries())if(Array.isArray(i)&&i.length===e.length&&i.every(a=>e.includes(a)))return s;const r=this.calculateExecutionMap(e);return this.executionMaps.set(n,r),r}combineOperators(...e){return n=>{for(const r of e)n=r(n,this);return n}}};function et(t,e=cP,n=!0){return Em(Symbol(),r=>{fw.set(r,{type:Rae,distinct:n,initial:t,init:e})})}function $r(t=cP,e=!1){return Em(Symbol(),n=>{fw.set(n,{type:"signal",distinct:e,init:t})})}function ef(t=cP){return Em(Symbol(),e=>{fw.set(e,{type:"signal",distinct:!1,init:t})})}const Iae=C.createContext(null);function D1(){const t=C.useContext(Iae);if(t===null)throw new Error("useRealm must be used within a RealmContextProvider");return t}function cr(t){const e=D1();e.register(t);const n=C.useCallback(r=>e.sub(t,r),[e,t]);return C.useSyncExternalStore(n,()=>e.getValue(t),()=>e.getValue(t))}function Ar(...t){const e=D1(),n=C.useMemo(()=>e.combineCells.apply(e,t),[e,...t]);return cr(n)}function Yt(t){const e=D1();return e.register(t),C.useCallback(n=>{e.pub(t,n)},[e,t])}function eu(t){return(e,n)=>{const r=n.signalInstance();return n.connect({map:i=>s=>{i(t(s))},sink:r,sources:[e]}),r}}function Sr(...t){return(e,n)=>{const r=n.signalInstance();return n.connect({map:i=>(...s)=>{i(s)},pulls:t,sink:r,sources:[e]}),r}}function Nae(t){return(e,n)=>{const r=n.signalInstance();return n.connect({map:i=>()=>{i(t)},sink:r,sources:[e]}),r}}function sy(t){return(e,n)=>{const r=n.signalInstance();return n.connect({map:i=>s=>{t(s)&&i(s)},sink:r,sources:[e]}),r}}function $ae(t,e){return(n,r)=>{const i=r.signalInstance();return r.connect({map:s=>a=>{s(e=t(e,a))},sink:i,sources:[n]}),i}}function cDe(t,e){return e(t),t}function wh(){}function Bi(t){return function(e){return{init:n=>{var r;return(r=t.init)==null?void 0:r.call(t,n,e)},postInit:n=>{var r;return(r=t.postInit)==null?void 0:r.call(t,n,e)},update:n=>{var r;return(r=t.update)==null?void 0:r.call(t,n,e)}}}}function uDe({children:t,plugins:e}){const n=p.useMemo(()=>cDe(new lDe,r=>{var i,s;for(const a of e)(i=a.init)==null||i.call(a,r);for(const a of e)(s=a.postInit)==null||s.call(a,r)}),[]);return p.useEffect(()=>{var r;for(const i of e)(r=i.update)==null||r.call(i,n)}),p.createElement(Iae.Provider,{value:n},t)}const Yb=C.createContext(null);function Lae(t,e){let n=null;return t!=null&&(n=t[1]),{getTheme:function(){return e??(n!=null?n.getTheme():null)}}}function Ur(){const t=C.useContext(Yb);return t==null&&(function(e,...n){const r=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",e);for(const s of n)i.append("v",s);throw r.search=i.toString(),Error(`Minified Lexical error #${e}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)})(8),t}function je(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const i of e)r.append("v",i);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const rl=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,hDe=rl&&"documentMode"in document?document.documentMode:null,wl=rl&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),vd=rl&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Gb=!(!rl||!("InputEvent"in window)||hDe)&&"getTargetRanges"in new window.InputEvent("input"),G2=rl&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Km=rl&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,fDe=rl&&/Android/.test(navigator.userAgent),zae=rl&&/^(?=.*Chrome).*/i.test(navigator.userAgent),EF=rl&&fDe&&zae,Kb=rl&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!zae;function Dae(...t){const e=[];for(const n of t)if(n&&typeof n=="string")for(const[r]of n.matchAll(/\S+/g))e.push(r);return e}const dDe=1,pDe=3,mDe=9,gDe=11,yd=0,Qae=1,Jm=2,vDe=0,yDe=1,xDe=2,Jb=4,e5=8,uP=128,ODe=1792|(112|(3|Jb|e5)|uP),hP=1,fP=2,dP=3,pP=4,mP=5,gP=6,dw=G2||Km||Kb?" ":"​",tu=`
190
190
 
191
191
  `,bDe=vd?" ":dw,xd={bold:1,capitalize:1024,code:16,highlight:uP,italic:2,lowercase:256,strikethrough:Jb,subscript:32,superscript:64,underline:e5,uppercase:512},wDe={directionless:1,unmergeable:2},_F={center:fP,end:gP,justify:pP,left:hP,right:dP,start:mP},SDe={[fP]:"center",[gP]:"end",[pP]:"justify",[hP]:"left",[dP]:"right",[mP]:"start"},EDe={normal:0,segmented:2,token:1},_De={[vDe]:"normal",[xDe]:"segmented",[yDe]:"token"},kF="$config";function Fae(t,e,n,r,i,s){let a=t.getFirstChild();for(;a!==null;){const o=a.__key;a.__parent===e&&(Ee(a)&&Fae(a,o,n,r,i,s),n.has(o)||s.delete(o),i.push(o)),a=a.getNextSibling()}}const kDe=100;let I8=!1,vP=0;function CDe(t){vP=t.timeStamp}function P6(t,e,n){const r=t.nodeName==="BR",i=e.__lexicalLineBreak;return i&&(t===i||r&&t.previousSibling===i)||r&&$w(t,n)!==void 0}function TDe(t,e,n){const r=Ja(Ka(n));let i=null,s=null;r!==null&&r.anchorNode===t&&(i=r.anchorOffset,s=r.focusOffset);const a=t.nodeValue;a!==null&&$P(e,a,i,s,!1)}function ADe(t,e,n){if(Ie(t)){const r=t.anchor.getNode();if(r.is(n)&&t.format!==r.getFormat())return!1}return du(e)&&n.isAttached()}function PDe(t,e,n,r){for(let i=t;i&&!yQe(i);i=my(i)){const s=$w(i,e);if(s!==void 0){const a=an(s,n);if(a)return yn(a)||!xr(i)?void 0:[i,a]}else if(i===r)return[r,_oe(n)]}}function Vae(t,e,n){I8=!0;const r=performance.now()-vP>kDe;try{sa(t,(()=>{const i=Qe()||(function(m){return m.getEditorState().read((()=>{const g=Qe();return g!==null?g.clone():null}))})(t),s=new Map,a=t.getRootElement(),o=t._editorState,l=t._blockCursorElement;let c=!1,h="";for(let m=0;m<e.length;m++){const g=e[m],x=g.type,O=g.target,w=PDe(O,t,o,a);if(!w)continue;const[E,S]=w;if(x==="characterData")r&&Ue(S)&&du(O)&&ADe(i,O,S)&&TDe(O,S,t);else if(x==="childList"){c=!0;const _=g.addedNodes;for(let k=0;k<_.length;k++){const I=_[k],$=Soe(I),L=I.parentNode;if(L!=null&&I!==l&&$===null&&!P6(I,L,t)){if(vd){const Q=(xr(I)?I.innerText:null)||I.nodeValue;Q&&(h+=Q)}L.removeChild(I)}}const P=g.removedNodes,A=P.length;if(A>0){let k=0;for(let I=0;I<A;I++){const $=P[I];(P6($,O,t)||l===$)&&(O.appendChild($),k++)}A!==k&&s.set(E,S)}}}if(s.size>0)for(const[m,g]of s)g.reconcileObservedMutation(m,t);const d=n.takeRecords();if(d.length>0){for(let m=0;m<d.length;m++){const g=d[m],x=g.addedNodes,O=g.target;for(let w=0;w<x.length;w++){const E=x[w],S=E.parentNode;S==null||E.nodeName!=="BR"||P6(E,O,t)||S.removeChild(E)}}n.takeRecords()}i!==null&&(c&&yr(i),vd&&Aoe(t)&&i.insertRawText(h))}))}finally{I8=!1}}function Bae(t){const e=t._observer;e!==null&&Vae(t,e.takeRecords(),e)}function jae(t){(function(e){vP===0&&Ka(e).addEventListener("textInput",CDe,!0)})(t),t._observer=new MutationObserver(((e,n)=>{Vae(t,e,n)}))}function N8(t){const e=new Map,n=new Set;for(let r=typeof t=="function"?t:t.replace;r.prototype&&r.prototype.getType!==void 0;r=Object.getPrototypeOf(r)){const{ownNodeConfig:i}=Dw(r);if(i&&i.stateConfigs)for(const s of i.stateConfigs){let a;"stateConfig"in s?(a=s.stateConfig,s.flat&&n.add(a.key)):a=s,e.set(a.key,a)}}return{flatKeys:n,sharedConfigMap:e}}let MDe=class Hae{constructor(e,n,r=void 0,i=new Map,s=void 0){this.node=e,this.sharedNodeState=n,this.unknownState=r,this.knownState=i;const{sharedConfigMap:a}=this.sharedNodeState,o=s!==void 0?s:(function(l,c,h){let d=h.size;if(c)for(const m in c){const g=l.get(m);g&&h.has(g)||d++}return d})(a,r,i);this.size=o}getValue(e){const n=this.knownState.get(e);if(n!==void 0)return n;this.sharedNodeState.sharedConfigMap.set(e.key,e);let r=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){const i=this.unknownState[e.key];i!==void 0&&(r=e.parse(i)),this.updateFromKnown(e,r)}return r}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const e={...this.unknownState},n={};for(const[r,i]of this.knownState)r.isEqual(i,r.defaultValue)?delete e[r.key]:e[r.key]=r.unparse(i);for(const r of this.sharedNodeState.flatKeys)r in e&&(n[r]=e[r],delete e[r]);return CF(e)&&(n.$=e),n}getWritable(e){if(this.node===e)return this;const{sharedNodeState:n,unknownState:r}=this,i=new Map(this.knownState);return new Hae(e,n,(function(s,a,o){let l;if(o)for(const[c,h]of Object.entries(o)){const d=s.get(c);d?a.has(d)||a.set(d,d.parse(h)):(l=l||{},l[c]=h)}return l})(n.sharedConfigMap,i,r),i,this.size)}updateFromKnown(e,n){const r=e.key;this.sharedNodeState.sharedConfigMap.set(r,e);const{knownState:i,unknownState:s}=this;i.has(e)||s&&r in s||(s&&(delete s[r],this.unknownState=CF(s)),this.size++),i.set(e,n)}updateFromUnknown(e,n){const r=this.sharedNodeState.sharedConfigMap.get(e);r?this.updateFromKnown(r,r.parse(n)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=n)}updateFromJSON(e){const{knownState:n}=this;for(const r of n.keys())n.set(r,r.defaultValue);if(this.size=n.size,this.unknownState=void 0,e)for(const[r,i]of Object.entries(e))this.updateFromUnknown(r,i)}};function RDe(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new MDe(e,Zae(e));return e.__state=n,n}function Zae(t){return t.__state?t.__state.sharedNodeState:Ooe(zw(),t.getType()).sharedNodeState}function CF(t){if(t)for(const e in t)return t}function TF(t,e,n){for(const[r,i]of e.knownState){if(t.has(r.key))continue;t.add(r.key);const s=n?n.getValue(r):r.defaultValue;if(s!==i&&!r.isEqual(s,i))return!0}return!1}function AF(t,e,n){const{unknownState:r}=e,i=n?n.unknownState:void 0;if(r){for(const[s,a]of Object.entries(r))if(!t.has(s)&&(t.add(s),a!==(i?i[s]:void 0)))return!0}return!1}function PF(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function MF(t,e){const n=t.__mode,r=t.__format,i=t.__style,s=e.__mode,a=e.__format,o=e.__style,l=t.__state,c=e.__state;return(n===null||n===s)&&(r===null||r===a)&&(i===null||i===o)&&(t.__state===null||l===c||(function(h,d){if(h===d)return!0;if(h&&d&&h.size!==d.size)return!1;const m=new Set;return!(h&&TF(m,h,d)||d&&TF(m,d,h)||h&&AF(m,h,d)||d&&AF(m,d,h))})(l,c))}function RF(t,e){const n=t.mergeWithSibling(e),r=Cr()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function IF(t){let e,n,r=t;if(r.__text!==""||!r.isSimpleText()||r.isUnmergeable()){for(;(e=r.getPreviousSibling())!==null&&Ue(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(MF(e,r)){r=RF(e,r);break}break}e.remove()}for(;(n=r.getNextSibling())!==null&&Ue(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==""){if(MF(r,n)){r=RF(r,n);break}break}n.remove()}}else r.remove()}function Od(t){return NF(t.anchor),NF(t.focus),t}function NF(t){for(;t.type==="element";){const e=t.getNode(),n=t.offset;let r,i;if(n===e.getChildrenSize()?(r=e.getChildAtIndex(n-1),i=!0):(r=e.getChildAtIndex(n),i=!1),Ue(r)){t.set(r.__key,i?r.getTextContentSize():0,"text",!0);break}if(!Ee(r))break;t.set(r.__key,i?r.getChildrenSize():0,"element",!0)}}let bd,Xi,K2,pw,$8,L8,wd,Ho,z8,J2,pi="",xl=null,Ol="",Nc="",em=!1,t5=!1;function n5(t,e){const n=wd.get(t);if(e!==null){const r=V8(t);r.parentNode===e&&e.removeChild(r)}if(Ho.has(t)||Xi._keyToDOMMap.delete(t),Ee(n)){const r=i5(n,wd);D8(r,0,r.length-1,null)}n!==void 0&&LP(J2,K2,pw,n,"destroyed")}function D8(t,e,n,r){let i=e;for(;i<=n;++i){const s=t[i];s!==void 0&&n5(s,r)}}function If(t,e){t.setProperty("text-align",e)}const IDe="40px";function Uae(t,e){const n=bd.theme.indent;if(typeof n=="string"){const i=t.classList.contains(n);e>0&&!i?t.classList.add(n):e<1&&i&&t.classList.remove(n)}const r=getComputedStyle(t).getPropertyValue("--lexical-indent-base-value")||IDe;t.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${r})`)}function qae(t,e){const n=t.style;e===0?If(n,""):e===hP?If(n,"left"):e===fP?If(n,"center"):e===dP?If(n,"right"):e===pP?If(n,"justify"):e===mP?If(n,"start"):e===gP&&If(n,"end")}function Q8(t,e){const n=(function(r){const i=r.__dir;if(i!==null)return i;if(ai(r))return null;const s=r.getParentOrThrow();return ai(s)&&s.__dir===null?"auto":null})(e);n!==null?t.dir=n:t.removeAttribute("dir")}function r5(t,e){const n=Ho.get(t);n===void 0&&je(60);const r=n.createDOM(bd,Xi);if((function(i,s,a){const o=a._keyToDOMMap;(function(l,c,h){const d=`__lexicalKey_${c._key}`;l[d]=h})(s,a,i),o.set(i,s)})(t,r,Xi),Ue(n)?r.setAttribute("data-lexical-text","true"):yn(n)&&r.setAttribute("data-lexical-decorator","true"),Ee(n)){const i=n.__indent,s=n.__size;if(Q8(r,n),i!==0&&Uae(r,i),s!==0){const o=s-1;F8(i5(n,Ho),n,0,o,n.getDOMSlot(r))}const a=n.__format;a!==0&&qae(r,a),n.isInline()||Xae(null,n,r),Lw(n)&&(pi+=tu,Nc+=tu)}else{const i=n.getTextContent();if(yn(n)){const s=n.decorate(Xi,bd);s!==null&&Wae(t,s),r.contentEditable="false"}pi+=i,Nc+=i}return e!==null&&e.insertChild(r),LP(J2,K2,pw,n,"created"),r}function F8(t,e,n,r,i){const s=pi;pi="";let a=n;for(;a<=r;++a){r5(t[a],i);const o=Ho.get(t[a]);o!==null&&Ue(o)&&(xl===null&&(xl=o.getFormat()),Ol===""&&(Ol=o.getStyle()))}Lw(e)&&(pi+=tu),i.element.__lexicalTextContent=pi,pi=s+pi}function $F(t,e){if(t){const n=t.__last;if(n){const r=e.get(n);if(r)return Zo(r)?"line-break":yn(r)&&r.isInline()?"decorator":null}return"empty"}return null}function Xae(t,e,n){const r=$F(t,wd),i=$F(e,Ho);r!==i&&e.getDOMSlot(n).setManagedLineBreak(i)}function NDe(t,e,n){var r;xl=null,Ol="",(function(i,s,a){const o=pi,l=i.__size,c=s.__size;pi="";const h=a.element;if(l===1&&c===1){const d=i.__first,m=s.__first;if(d===m)V0(d,h);else{const x=V8(d),O=r5(m,null);try{h.replaceChild(O,x)}catch(w){if(typeof w=="object"&&w!=null){const E=`${w.toString()} Parent: ${h.tagName}, new child: {tag: ${O.tagName} key: ${m}}, old child: {tag: ${x.tagName}, key: ${d}}.`;throw new Error(E)}throw w}n5(d,null)}const g=Ho.get(m);Ue(g)&&(xl===null&&(xl=g.getFormat()),Ol===""&&(Ol=g.getStyle()))}else{const d=i5(i,wd),m=i5(s,Ho);if(d.length!==l&&je(227),m.length!==c&&je(228),l===0)c!==0&&F8(m,s,0,c-1,a);else if(c===0){if(l!==0){const g=a.after==null&&a.before==null&&a.element.__lexicalLineBreak==null;D8(d,0,l-1,g?null:h),g&&(h.textContent="")}}else(function(g,x,O,w,E,S){const _=w-1,P=E-1;let A,k,I=S.getFirstChild(),$=0,L=0;for(;$<=_&&L<=P;){const j=x[$],F=O[L];if(j===F)I=M6(V0(F,S.element)),$++,L++;else{A===void 0&&(A=new Set(x)),k===void 0&&(k=new Set(O));const ee=k.has(j),G=A.has(F);if(ee)if(G){const re=Sd(Xi,F);re===I?I=M6(V0(F,S.element)):(S.withBefore(I).insertChild(re),V0(F,S.element)),$++,L++}else r5(F,S.withBefore(I)),L++;else I=M6(V8(j)),n5(j,S.element),$++}const W=Ho.get(F);W!==null&&Ue(W)&&(xl===null&&(xl=W.getFormat()),Ol===""&&(Ol=W.getStyle()))}const Q=$>_,H=L>P;if(Q&&!H){const j=O[P+1],F=j===void 0?null:Xi.getElementByKey(j);F8(O,g,L,P,S.withBefore(F))}else H&&!Q&&D8(x,$,_,S.element)})(s,d,m,l,c,a)}Lw(s)&&(pi+=tu),h.__lexicalTextContent=pi,pi=o+pi})(t,e,e.getDOMSlot(n)),r=e,xl==null||xl===r.__textFormat||t5||r.setTextFormat(xl),(function(i){Ol===""||Ol===i.__textStyle||t5||i.setTextStyle(Ol)})(e)}function i5(t,e){const n=[];let r=t.__first;for(;r!==null;){const i=e.get(r);i===void 0&&je(101),n.push(r),r=i.__next}return n}function V0(t,e){const n=wd.get(t);let r=Ho.get(t);n!==void 0&&r!==void 0||je(61);const i=em||L8.has(t)||$8.has(t),s=Sd(Xi,t);if(n===r&&!i){if(Ee(n)){const a=s.__lexicalTextContent;a!==void 0&&(pi+=a,Nc+=a)}else{const a=n.getTextContent();Nc+=a,pi+=a}return s}if(n!==r&&i&&LP(J2,K2,pw,r,"updated"),r.updateDOM(n,s,bd)){const a=r5(t,null);return e===null&&je(62),e.replaceChild(a,s),n5(t,null),a}if(Ee(n)&&Ee(r)){const a=r.__indent;(em||a!==n.__indent)&&Uae(s,a);const o=r.__format;if((em||o!==n.__format)&&qae(s,o),i&&(NDe(n,r,s),ai(r)||r.isInline()||Xae(n,r,s)),Lw(r)&&(pi+=tu,Nc+=tu),(em||r.__dir!==n.__dir)&&(Q8(s,r),ai(r)&&!em))for(const l of r.getChildren())Ee(l)&&Q8(Sd(Xi,l.getKey()),l)}else{const a=r.getTextContent();if(yn(r)){const o=r.decorate(Xi,bd);o!==null&&Wae(t,o)}pi+=a,Nc+=a}if(!t5&&ai(r)&&r.__cachedText!==Nc){const a=r.getWritable();a.__cachedText=Nc,r=a}return s}function Wae(t,e){let n=Xi._pendingDecorators;const r=Xi._decorators;if(n===null){if(r[t]===e)return;n=Eoe(Xi)}n[t]=e}function M6(t){let e=t.nextSibling;return e!==null&&e===Xi._blockCursorElement&&(e=e.nextSibling),e}function $De(t,e,n,r,i,s){pi="",Nc="",em=r===Jm,Xi=n,bd=n._config,K2=n._nodes,pw=Xi._listeners.mutation,$8=i,L8=s,wd=t._nodeMap,Ho=e._nodeMap,t5=e._readOnly,z8=new Map(n._keyToDOMMap);const a=new Map;return J2=a,V0("root",null),Xi=void 0,K2=void 0,$8=void 0,L8=void 0,wd=void 0,Ho=void 0,bd=void 0,z8=void 0,J2=void 0,a}function V8(t){const e=z8.get(t);return e===void 0&&je(75,t),e}function gt(t){return{type:t}}const ay=gt("SELECTION_CHANGE_COMMAND"),LDe=gt("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),mw=gt("CLICK_COMMAND"),td=gt("DELETE_CHARACTER_COMMAND"),_m=gt("INSERT_LINE_BREAK_COMMAND"),ev=gt("INSERT_PARAGRAPH_COMMAND"),km=gt("CONTROLLED_TEXT_INSERTION_COMMAND"),oy=gt("PASTE_COMMAND"),B8=gt("REMOVE_TEXT_COMMAND"),tv=gt("DELETE_WORD_COMMAND"),nv=gt("DELETE_LINE_COMMAND"),Qc=gt("FORMAT_TEXT_COMMAND"),gw=gt("UNDO_COMMAND"),vw=gt("REDO_COMMAND"),yP=gt("KEYDOWN_COMMAND"),Yae=gt("KEY_ARROW_RIGHT_COMMAND"),zDe=gt("MOVE_TO_END"),xP=gt("KEY_ARROW_LEFT_COMMAND"),DDe=gt("MOVE_TO_START"),yw=gt("KEY_ARROW_UP_COMMAND"),xw=gt("KEY_ARROW_DOWN_COMMAND"),Rh=gt("KEY_ENTER_COMMAND"),OP=gt("KEY_SPACE_COMMAND"),Ow=gt("KEY_BACKSPACE_COMMAND"),Q1=gt("KEY_ESCAPE_COMMAND"),bP=gt("KEY_DELETE_COMMAND"),ly=gt("KEY_TAB_COMMAND"),Gae=gt("INSERT_TAB_COMMAND"),s5=gt("INDENT_CONTENT_COMMAND"),j8=gt("OUTDENT_CONTENT_COMMAND"),bw=gt("DROP_COMMAND"),QDe=gt("FORMAT_ELEMENT_COMMAND"),ww=gt("DRAGSTART_COMMAND"),Sw=gt("DRAGOVER_COMMAND"),Kae=gt("DRAGEND_COMMAND"),Ew=gt("COPY_COMMAND"),wP=gt("CUT_COMMAND"),H8=gt("SELECT_ALL_COMMAND"),FDe=gt("CLEAR_EDITOR_COMMAND"),VDe=gt("CLEAR_HISTORY_COMMAND"),B0=gt("CAN_REDO_COMMAND"),j0=gt("CAN_UNDO_COMMAND"),_w=gt("FOCUS_COMMAND"),cy=gt("BLUR_COMMAND"),BDe=gt("KEY_MODIFIER_COMMAND"),_c=Object.freeze({}),Z8=30,U8=[["keydown",function(t,e){if(l2=t.timeStamp,Jae=t.key,!e.isComposing()&&!it(e,yP,t)&&t.key!=null){if(R6&&cV(t))return sa(e,(()=>{T3(e,I6)})),R6=!1,void(I6="");if((function(n){return Mn(n,"ArrowRight",{shiftKey:"any"})})(t))it(e,Yae,t);else if((function(n){return Mn(n,"ArrowRight",Pc)})(t))it(e,zDe,t);else if((function(n){return Mn(n,"ArrowLeft",{shiftKey:"any"})})(t))it(e,xP,t);else if((function(n){return Mn(n,"ArrowLeft",Pc)})(t))it(e,DDe,t);else if((function(n){return Mn(n,"ArrowUp",{altKey:"any",shiftKey:"any"})})(t))it(e,yw,t);else if((function(n){return Mn(n,"ArrowDown",{altKey:"any",shiftKey:"any"})})(t))it(e,xw,t);else if((function(n){return Mn(n,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})})(t))c2=!0,it(e,Rh,t);else if((function(n){return n.key===" "})(t))it(e,OP,t);else if((function(n){return wl&&Mn(n,"o",{ctrlKey:!0})})(t))t.preventDefault(),c2=!0,it(e,_m,!0);else if((function(n){return Mn(n,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})})(t))c2=!1,it(e,Rh,t);else if((function(n){return Mn(n,"Backspace",{shiftKey:"any"})||wl&&Mn(n,"h",{ctrlKey:!0})})(t))cV(t)?it(e,Ow,t):(t.preventDefault(),it(e,td,!0));else if((function(n){return n.key==="Escape"})(t))it(e,Q1,t);else if((function(n){return Mn(n,"Delete",{})||wl&&Mn(n,"d",{ctrlKey:!0})})(t))(function(n){return n.key==="Delete"})(t)?it(e,bP,t):(t.preventDefault(),it(e,td,!1));else if((function(n){return Mn(n,"Backspace",lV)})(t))t.preventDefault(),it(e,tv,!0);else if((function(n){return Mn(n,"Delete",lV)})(t))t.preventDefault(),it(e,tv,!1);else if((function(n){return wl&&Mn(n,"Backspace",{metaKey:!0})})(t))t.preventDefault(),it(e,nv,!0);else if((function(n){return wl&&(Mn(n,"Delete",{metaKey:!0})||Mn(n,"k",{ctrlKey:!0}))})(t))t.preventDefault(),it(e,nv,!1);else if((function(n){return Mn(n,"b",Pc)})(t))t.preventDefault(),it(e,Qc,"bold");else if((function(n){return Mn(n,"u",Pc)})(t))t.preventDefault(),it(e,Qc,"underline");else if((function(n){return Mn(n,"i",Pc)})(t))t.preventDefault(),it(e,Qc,"italic");else if((function(n){return Mn(n,"Tab",{shiftKey:"any"})})(t))it(e,ly,t);else if((function(n){return Mn(n,"z",Pc)})(t))t.preventDefault(),it(e,gw,void 0);else if((function(n){return wl?Mn(n,"z",{metaKey:!0,shiftKey:!0}):Mn(n,"y",{ctrlKey:!0})||Mn(n,"z",{ctrlKey:!0,shiftKey:!0})})(t))t.preventDefault(),it(e,vw,void 0);else{const n=e._editorState._selection;n===null||Ie(n)?uV(t)&&(t.preventDefault(),it(e,H8,t)):(function(r){return Mn(r,"c",Pc)})(t)?(t.preventDefault(),it(e,Ew,t)):(function(r){return Mn(r,"x",Pc)})(t)?(t.preventDefault(),it(e,wP,t)):uV(t)&&(t.preventDefault(),it(e,H8,t))}(function(n){return n.ctrlKey||n.shiftKey||n.altKey||n.metaKey})(t)&&it(e,BDe,t)}}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;Z1(n)&&r!=="touch"&&r!=="pen"&&t.button===0&&sa(e,(()=>{sV(n)||(X8=!0)}))}],["compositionstart",function(t,e){sa(e,(()=>{const n=Qe();if(Ie(n)&&!e.isComposing()){const r=n.anchor,i=n.anchor.getNode();$i(r.key),(t.timeStamp<l2+Z8||r.type==="element"||!n.isCollapsed()||i.getFormat()!==n.format||Ue(i)&&i.getStyle()!==n.style)&&it(e,km,bDe)}}))}],["compositionend",function(t,e){vd?p0=!0:Km||!G2&&!Kb?sa(e,(()=>{T3(e,t.data)})):(R6=!0,I6=t.data)}],["input",function(t,e){t.stopPropagation(),sa(e,(()=>{if(xr(t.target)&&sV(t.target))return;const n=Qe(),r=t.data,i=ioe(t);if(r!=null&&Ie(n)&&noe(n,i,r,t.timeStamp,!1)){p0&&(T3(e,r),p0=!1);const s=n.anchor.getNode(),a=Ja(Ka(e));if(a===null)return;const o=n.isBackward(),l=o?n.anchor.offset:n.focus.offset,c=o?n.focus.offset:n.anchor.offset;Gb&&!n.isCollapsed()&&Ue(s)&&a.anchorNode!==null&&s.getTextContent().slice(0,l)+r+s.getTextContent().slice(l+c)===Toe(a.anchorNode)||it(e,km,r);const h=r.length;vd&&h>1&&t.inputType==="insertCompositionText"&&!e.isComposing()&&(n.anchor.offset-=h),G2||Km||Kb||!e.isComposing()||(l2=0,$i(null))}else NP(!1,e,r!==null?r:void 0),p0&&(T3(e,r||void 0),p0=!1);(function(){Ni();const s=Cr();Bae(s)})()}),{event:t}),tm=null}],["click",function(t,e){sa(e,(()=>{const n=Qe(),r=Ja(Ka(e)),i=Xd();if(r){if(Ie(n)){const s=n.anchor,a=s.getNode();if(s.type==="element"&&s.offset===0&&n.isCollapsed()&&!ai(a)&&on().getChildrenSize()===1&&a.getTopLevelElementOrThrow().isEmpty()&&i!==null&&n.is(i))r.removeAllRanges(),n.dirty=!0;else if(t.detail===3&&!n.isCollapsed()&&a!==n.focus.getNode()){const o=(function(l,c){let h=l;for(;h!==on()&&h!=null;){if(c(h))return h;h=h.getParent()}return null})(a,(l=>Ee(l)&&!l.isInline()));Ee(o)&&o.select(0)}}else if(t.pointerType==="touch"||t.pointerType==="pen"){const s=r.anchorNode;(xr(s)||du(s))&&yr(EP(i,r,e,t))}}it(e,mw,t)}))}],["cut",_c],["copy",_c],["dragstart",_c],["dragover",_c],["dragend",_c],["paste",_c],["focus",_c],["blur",_c],["drop",_c]];Gb&&U8.push(["beforeinput",(t,e)=>(function(n,r){const i=n.inputType,s=ioe(n);i==="deleteCompositionText"||vd&&Aoe(r)||i!=="insertCompositionText"&&sa(r,(()=>{const a=Qe();if(i==="deleteContentBackward"){if(a===null){const g=Xd();if(!Ie(g))return;yr(g.clone())}if(Ie(a)){const g=a.anchor.key===a.focus.key;if(o=n.timeStamp,Jae==="MediaLast"&&o<l2+Z8&&r.isComposing()&&g){if($i(null),l2=0,setTimeout((()=>{sa(r,(()=>{$i(null)}))}),Z8),Ie(a)){const x=a.anchor.getNode();x.markDirty(),Ue(x)||je(142),roe(a,x)}}else{$i(null),n.preventDefault();const x=a.anchor.getNode(),O=x.getTextContent(),w=x.canInsertTextAfter(),E=a.anchor.offset===0&&a.focus.offset===O.length;let S=EF&&g&&!E&&w;if(S&&a.isCollapsed()&&(S=!yn(K8(a.anchor,!0))),!S){it(r,td,!0);const _=Qe();EF&&Ie(_)&&_.isCollapsed()&&(Df=_,setTimeout((()=>Df=null)))}}return}}var o;if(!Ie(a))return;const l=n.data;tm!==null&&NP(!1,r,tm),a.dirty&&tm===null||!a.isCollapsed()||ai(a.anchor.getNode())||s===null||a.applyDOMRange(s),tm=null;const c=a.anchor,h=a.focus,d=c.getNode(),m=h.getNode();if(i!=="insertText"&&i!=="insertTranspose")switch(n.preventDefault(),i){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":it(r,km,n);break;case"insertFromComposition":$i(null),it(r,km,n);break;case"insertLineBreak":$i(null),it(r,_m,!1);break;case"insertParagraph":$i(null),c2&&!Km?(c2=!1,it(r,_m,!1)):it(r,ev,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":it(r,oy,n);break;case"deleteByComposition":(function(g,x){return g!==x||Ee(g)||Ee(x)||!nd(g)||!nd(x)})(d,m)&&it(r,B8,n);break;case"deleteByDrag":case"deleteByCut":it(r,B8,n);break;case"deleteContent":it(r,td,!1);break;case"deleteWordBackward":it(r,tv,!0);break;case"deleteWordForward":it(r,tv,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":it(r,nv,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":it(r,nv,!1);break;case"formatStrikeThrough":it(r,Qc,"strikethrough");break;case"formatBold":it(r,Qc,"bold");break;case"formatItalic":it(r,Qc,"italic");break;case"formatUnderline":it(r,Qc,"underline");break;case"historyUndo":it(r,gw,void 0);break;case"historyRedo":it(r,vw,void 0)}else{if(l===`
192
192
  `)n.preventDefault(),it(r,_m,!1);else if(l===tu)n.preventDefault(),it(r,ev,void 0);else if(l==null&&n.dataTransfer){const g=n.dataTransfer.getData("text/plain");n.preventDefault(),a.insertRawText(g)}else l!=null&&noe(a,s,l,n.timeStamp,!0)?(n.preventDefault(),it(r,km,l)):tm=l;eoe=n.timeStamp}}))})(t,e)]);let l2=0,Jae=null,eoe=0,tm=null;const a5=new WeakMap;let q8=!1,X8=!1,c2=!1,p0=!1,R6=!1,I6="",Df=null,toe=[0,"",0,"root",0];function noe(t,e,n,r,i){const s=t.anchor,a=t.focus,o=s.getNode(),l=Cr(),c=Ja(Ka(l)),h=c!==null?c.anchorNode:null,d=s.key,m=l.getElementByKey(d),g=n.length;return d!==a.key||!Ue(o)||(!i&&(!Gb||eoe<r+50)||o.isDirty()&&g<2||koe(n))&&s.offset!==a.offset&&!o.isComposing()||Rc(o)||o.isDirty()&&g>1||(i||!Gb)&&m!==null&&!o.isComposing()&&h!==t1(m)||c!==null&&e!==null&&(!e.collapsed||e.startContainer!==c.anchorNode||e.startOffset!==c.anchorOffset)||o.getFormat()!==t.format||o.getStyle()!==t.style||(function(x,O){if(O.isSegmented())return!0;if(!x.isCollapsed())return!1;const w=x.anchor.offset,E=O.getParentOrThrow(),S=nd(O);return w===0?!O.canInsertTextBefore()||!E.canInsertTextBefore()&&!O.isComposing()||S||(function(_){const P=_.getPreviousSibling();return(Ue(P)||Ee(P)&&P.isInline())&&!P.canInsertTextAfter()})(O):w===O.getTextContentSize()&&(!O.canInsertTextAfter()||!E.canInsertTextAfter()&&!O.isComposing()||S)})(t,o)}function LF(t,e){return du(t)&&t.nodeValue!==null&&e!==0&&e!==t.nodeValue.length}function zF(t,e,n){const{anchorNode:r,anchorOffset:i,focusNode:s,focusOffset:a}=t;q8&&(q8=!1,LF(r,i)&&LF(s,a)&&!Df)||sa(e,(()=>{if(!n)return void yr(null);if(!py(e,r,s))return;let o=Qe();if(Df&&Ie(o)&&o.isCollapsed()){const l=o.anchor,c=Df.anchor;(l.key===c.key&&l.offset===c.offset+1||l.offset===1&&c.getNode().is(l.getNode().getPreviousSibling()))&&(o=Df.clone(),yr(o))}if(Df=null,Ie(o)){const l=o.anchor,c=l.getNode();if(o.isCollapsed()){t.type==="Range"&&t.anchorNode===t.focusNode&&(o.dirty=!0);const h=Ka(e).event,d=h?h.timeStamp:performance.now(),[m,g,x,O,w]=toe,E=on(),S=e.isComposing()===!1&&E.getTextContent()==="";if(d<w+200&&l.offset===x&&l.key===O)QO(o,m,g);else if(l.type==="text")Ue(c)||je(141),roe(o,c);else if(l.type==="element"&&!S){Ee(c)||je(259);const _=l.getNode();_.isEmpty()?(function(P,A){const k=A.getTextFormat(),I=A.getTextStyle();QO(P,k,I)})(o,_):QO(o,0,"")}}else{const h=l.key,d=o.focus.key,m=o.getNodes(),g=m.length,x=o.isBackward(),O=x?a:i,w=x?i:a,E=x?d:h,S=x?h:d;let _=ODe,P=!1;for(let A=0;A<g;A++){const k=m[A],I=k.getTextContentSize();if(Ue(k)&&I!==0&&!(A===0&&k.__key===E&&O===I||A===g-1&&k.__key===S&&w===0)&&(P=!0,_&=k.getFormat(),_===0))break}o.format=P?_:0}}it(e,ay,void 0)}))}function QO(t,e,n){t.format===e&&t.style===n||(t.format=e,t.style=n,t.dirty=!0)}function roe(t,e){QO(t,e.getFormat(),e.getStyle())}function ioe(t){if(!t.getTargetRanges)return null;const e=t.getTargetRanges();return e.length===0?null:e[0]}function T3(t,e){const n=t._compositionKey;if($i(null),n!==null&&e!=null){if(e===""){const r=an(n),i=t1(t.getElementByKey(n));return void(i!==null&&i.nodeValue!==null&&Ue(r)&&$P(r,i.nodeValue,null,null,!0))}if(e[e.length-1]===`
@@ -302,7 +302,7 @@ Defaulting to 2020, but this will stop working in the future.`)),R.ecmaVersion=1
302
302
  constructor(\${params}) {
303
303
  \${}
304
304
  }
305
- }`,{label:"class",detail:"definition",type:"keyword"}),As('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),As('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],Ape=WR.concat([As("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),As("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),As("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),BZ=new Zfe,Ppe=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function C0(t){return(e,n)=>{let r=e.node.getChild("VariableDefinition");return r&&n(r,t),!0}}const wot=["FunctionDeclaration"],Sot={FunctionDeclaration:C0("function"),ClassDeclaration:C0("class"),ClassExpression:()=>!0,EnumDeclaration:C0("constant"),TypeAliasDeclaration:C0("type"),NamespaceDeclaration:C0("namespace"),VariableDefinition(t,e){t.matchContext(wot)||e(t,"variable")},TypeDefinition(t,e){e(t,"type")},__proto__:null};function Mpe(t,e){let n=BZ.get(e);if(n)return n;let r=[],i=!0;function s(a,o){let l=t.sliceString(a.from,a.to);r.push({label:l,type:o})}return e.cursor(kn.IncludeAnonymous).iterate(a=>{if(i)i=!1;else if(a.name){let o=Sot[a.name];if(o&&o(a,s)||Ppe.has(a.name))return!1}else if(a.to-a.from>8192){for(let o of Mpe(t,a.node))r.push(o);return!1}}),BZ.set(e,r),r}const r4=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,YR=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function Rpe(t){let e=Fn(t.state).resolveInner(t.pos,-1);if(YR.indexOf(e.name)>-1)return null;let n=e.name=="VariableName"||e.to-e.from<20&&r4.test(t.state.sliceDoc(e.from,e.to));if(!n&&!t.explicit)return null;let r=[];for(let i=e;i;i=i.parent)Ppe.has(i.name)&&(r=r.concat(Mpe(t.state.doc,i)));return{options:r,from:n?e.from:t.pos,validFor:r4}}function XE(t,e,n){var r;let i=[];for(;;){let s=e.firstChild,a;if(s?.name=="VariableName")return i.push(t(s)),{path:i.reverse(),name:n};if(s?.name=="MemberExpression"&&((r=a=s.lastChild)===null||r===void 0?void 0:r.name)=="PropertyName")i.push(t(a)),e=s;else return null}}function Ipe(t){let e=r=>t.state.doc.sliceString(r.from,r.to),n=Fn(t.state).resolveInner(t.pos,-1);return n.name=="PropertyName"?XE(e,n.parent,e(n)):(n.name=="."||n.name=="?.")&&n.parent.name=="MemberExpression"?XE(e,n.parent,""):YR.indexOf(n.name)>-1?null:n.name=="VariableName"||n.to-n.from<20&&r4.test(e(n))?{path:[],name:e(n)}:n.name=="MemberExpression"?XE(e,n,""):t.explicit?{path:[],name:""}:null}function Eot(t,e){let n=t,r=[],i=new Set;for(let s=0;;s++){for(let o of(Object.getOwnPropertyNames||Object.keys)(t)){if(!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(o)||i.has(o))continue;i.add(o);let l;try{l=n[o]}catch{continue}r.push({label:o,type:typeof l=="function"?/^[A-Z]/.test(o)?"class":e?"function":"method":e?"variable":"property",boost:-s})}let a=Object.getPrototypeOf(t);if(!a)return r;t=a}}function _ot(t){let e=new Map;return n=>{let r=Ipe(n);if(!r)return null;let i=t;for(let a of r.path)if(i=i[a],!i)return null;let s=e.get(i);return s||e.set(i,s=Eot(i,!r.path.length)),{from:n.pos-r.name.length,options:s,validFor:r4}}}const Ya=$d.define({name:"javascript",parser:bot.configure({props:[ep.add({IfStatement:ob({except:/^\s*({|else\b)/}),TryStatement:ob({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Ant,SwitchBody:t=>{let e=t.textAfter,n=/^\s*\}/.test(e),r=/^\s*(case|default)\b/.test(e);return t.baseIndent+(n?0:r?1:2)*t.unit},Block:Gfe({closing:"}"}),ArrowFunction:t=>t.baseIndent+t.unit,"TemplateString BlockComment":()=>null,"Statement Property":ob({except:/^\s*{/}),JSXElement(t){let e=/^\s*<\//.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},JSXEscape(t){let e=/\s*\}/.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},"JSXOpenTag JSXSelfClosingTag"(t){return t.column(t.node.from)+t.unit}}),tp.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":AR,BlockComment(t){return{from:t.from+2,to:t.to-2}},JSXElement(t){let e=t.firstChild;if(!e||e.name=="JSXSelfClosingTag")return null;let n=t.lastChild;return{from:e.to,to:n.type.isError?t.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(t){var e;let n=(e=t.firstChild)===null||e===void 0?void 0:e.nextSibling,r=t.lastChild;return!n||n.type.isError?null:{from:n.to,to:r.type.isError?t.to:r.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Npe={test:t=>/^JSX/.test(t.name),facet:mS({commentTokens:{block:{open:"{/*",close:"*/}"}}})},GR=Ya.configure({dialect:"ts"},"typescript"),KR=Ya.configure({dialect:"jsx",props:[kR.add(t=>t.isTop?[Npe]:void 0)]}),JR=Ya.configure({dialect:"jsx ts",props:[kR.add(t=>t.isTop?[Npe]:void 0)]},"typescript");let $pe=t=>({label:t,type:"keyword"});const Lpe="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map($pe),kot=Lpe.concat(["declare","implements","private","protected","public"].map($pe));function zpe(t={}){let e=t.jsx?t.typescript?JR:KR:t.typescript?GR:Ya,n=t.typescript?Ape.concat(kot):WR.concat(Lpe);return new zd(e,[Ya.data.of({autocomplete:hrt(YR,xde(n))}),Ya.data.of({autocomplete:Rpe}),t.jsx?Dpe:[]])}function Cot(t){for(;;){if(t.name=="JSXOpenTag"||t.name=="JSXSelfClosingTag"||t.name=="JSXFragmentTag")return t;if(t.name=="JSXEscape"||!t.parent)return null;t=t.parent}}function jZ(t,e,n=t.length){for(let r=e?.firstChild;r;r=r.nextSibling)if(r.name=="JSXIdentifier"||r.name=="JSXBuiltin"||r.name=="JSXNamespacedName"||r.name=="JSXMemberExpression")return t.sliceString(r.from,Math.min(r.to,n));return""}const Tot=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Dpe=Ze.inputHandler.of((t,e,n,r,i)=>{if((Tot?t.composing:t.compositionStarted)||t.state.readOnly||e!=n||r!=">"&&r!="/"||!Ya.isActiveAt(t.state,e,-1))return!1;let s=i(),{state:a}=s,o=a.changeByRange(l=>{var c;let{head:h}=l,d=Fn(a).resolveInner(h-1,-1),m;if(d.name=="JSXStartTag"&&(d=d.parent),!(a.doc.sliceString(h-1,h)!=r||d.name=="JSXAttributeValue"&&d.to>h)){if(r==">"&&d.name=="JSXFragmentTag")return{range:l,changes:{from:h,insert:"</>"}};if(r=="/"&&d.name=="JSXStartCloseTag"){let g=d.parent,x=g.parent;if(x&&g.from==h-2&&((m=jZ(a.doc,x.firstChild,h))||((c=x.firstChild)===null||c===void 0?void 0:c.name)=="JSXFragmentTag")){let O=`${m}>`;return{range:Ce.cursor(h+O.length,-1),changes:{from:h,insert:O}}}}else if(r==">"){let g=Cot(d);if(g&&g.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(a.doc.sliceString(h,h+2))&&(m=jZ(a.doc,g,h)))return{range:l,changes:{from:h,insert:`</${m}>`}}}}return{range:l}});return o.changes.empty?!1:(t.dispatch([s,a.update(o,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});function Aot(t,e){return e||(e={parserOptions:{ecmaVersion:2019,sourceType:"module"},env:{browser:!0,node:!0,es6:!0,es2015:!0,es2017:!0,es2020:!0},rules:{}},t.getRules().forEach((n,r)=>{var i;!((i=n.meta.docs)===null||i===void 0)&&i.recommended&&(e.rules[r]=2)})),n=>{let{state:r}=n,i=[];for(let{from:s,to:a}of Ya.findRegions(r)){let o=r.doc.lineAt(s),l={line:o.number-1,col:s-o.from,pos:s};for(let c of t.verify(r.sliceDoc(s,a),e))i.push(Pot(c,r.doc,l))}return i}}function HZ(t,e,n,r){return n.line(t+r.line).from+e+(t==1?r.col-1:-1)}function Pot(t,e,n){let r=HZ(t.line,t.column,e,n),i={from:r,to:t.endLine!=null&&t.endColumn!=1?HZ(t.endLine,t.endColumn,e,n):r,message:t.message,source:t.ruleId?"eslint:"+t.ruleId:"eslint",severity:t.severity==1?"warning":"error"};if(t.fix){let{range:s,text:a}=t.fix,o=s[0]+n.pos-r,l=s[1]+n.pos-r;i.actions=[{name:"fix",apply(c,h){c.dispatch({changes:{from:h+o,to:h+l,insert:a},scrollIntoView:!0})}}]}return i}const cO=Object.freeze(Object.defineProperty({__proto__:null,autoCloseTags:Dpe,completionPath:Ipe,esLint:Aot,javascript:zpe,javascriptLanguage:Ya,jsxLanguage:KR,localCompletionSource:Rpe,scopeCompletionSource:_ot,snippets:WR,tsxLanguage:JR,typescriptLanguage:GR,typescriptSnippets:Ape},Symbol.toStringTag,{value:"Module"})),T0=["_blank","_self","_top","_parent"],WE=["ascii","utf-8","utf-16","latin1","latin1"],YE=["get","post","put","delete"],GE=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Js=["true","false"],pt={},Mot={a:{attrs:{href:null,ping:null,type:null,media:null,target:T0,hreflang:null}},abbr:pt,address:pt,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:pt,aside:pt,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:pt,base:{attrs:{href:null,target:T0}},bdi:pt,bdo:pt,blockquote:{attrs:{cite:null}},body:pt,br:pt,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:GE,formmethod:YE,formnovalidate:["novalidate"],formtarget:T0,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:pt,center:pt,cite:pt,code:pt,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:pt,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:pt,div:pt,dl:pt,dt:pt,em:pt,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:pt,figure:pt,footer:pt,form:{attrs:{action:null,name:null,"accept-charset":WE,autocomplete:["on","off"],enctype:GE,method:YE,novalidate:["novalidate"],target:T0}},h1:pt,h2:pt,h3:pt,h4:pt,h5:pt,h6:pt,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:pt,hgroup:pt,hr:pt,html:{attrs:{manifest:null}},i:pt,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:GE,formmethod:YE,formnovalidate:["novalidate"],formtarget:T0,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:pt,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:pt,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:pt,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:WE,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:pt,noscript:pt,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:pt,param:{attrs:{name:null,value:null}},pre:pt,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:pt,rt:pt,ruby:pt,samp:pt,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:WE}},section:pt,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:pt,source:{attrs:{src:null,type:null,media:null}},span:pt,strong:pt,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:pt,summary:pt,sup:pt,table:pt,tbody:pt,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:pt,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:pt,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:pt,time:{attrs:{datetime:null}},title:pt,tr:pt,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:pt,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:pt},Qpe={accesskey:null,class:null,contenteditable:Js,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Js,autocorrect:Js,autocapitalize:Js,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Js,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Js,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Js,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Js,"aria-hidden":Js,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Js,"aria-multiselectable":Js,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Js,"aria-relevant":null,"aria-required":Js,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},Fpe="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(t=>"on"+t);for(let t of Fpe)Qpe[t]=null;let Iv=class{constructor(e,n){this.tags={...Mot,...e},this.globalAttrs={...Qpe,...n},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};Iv.default=new Iv;function d1(t,e,n=t.length){if(!e)return"";let r=e.firstChild,i=r&&r.getChild("TagName");return i?t.sliceString(i.from,Math.min(i.to,n)):""}function p1(t,e=!1){for(;t;t=t.parent)if(t.name=="Element")if(e)e=!1;else return t;return null}function Vpe(t,e,n){let r=n.tags[d1(t,p1(e))];return r?.children||n.allTags}function eI(t,e){let n=[];for(let r=p1(e);r&&!r.type.isTop;r=p1(r.parent)){let i=d1(t,r);if(i&&r.lastChild.name=="CloseTag")break;i&&n.indexOf(i)<0&&(e.name=="EndTag"||e.from>=r.firstChild.to)&&n.push(i)}return n}const Bpe=/^[:\-\.\w\u00b7-\uffff]*$/;function ZZ(t,e,n,r,i){let s=/\s*>/.test(t.sliceDoc(i,i+5))?"":">",a=p1(n,n.name=="StartTag"||n.name=="TagName");return{from:r,to:i,options:Vpe(t.doc,a,e).map(o=>({label:o,type:"type"})).concat(eI(t.doc,n).map((o,l)=>({label:"/"+o,apply:"/"+o+s,type:"type",boost:99-l}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function UZ(t,e,n,r){let i=/\s*>/.test(t.sliceDoc(r,r+5))?"":">";return{from:n,to:r,options:eI(t.doc,e).map((s,a)=>({label:s,apply:s+i,type:"type",boost:99-a})),validFor:Bpe}}function Rot(t,e,n,r){let i=[],s=0;for(let a of Vpe(t.doc,n,e))i.push({label:"<"+a,type:"type"});for(let a of eI(t.doc,n))i.push({label:"</"+a+">",type:"type",boost:99-s++});return{from:r,to:r,options:i,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function Iot(t,e,n,r,i){let s=p1(n),a=s?e.tags[d1(t.doc,s)]:null,o=a&&a.attrs?Object.keys(a.attrs):[],l=a&&a.globalAttrs===!1?o:o.length?o.concat(e.globalAttrNames):e.globalAttrNames;return{from:r,to:i,options:l.map(c=>({label:c,type:"property"})),validFor:Bpe}}function Not(t,e,n,r,i){var s;let a=(s=n.parent)===null||s===void 0?void 0:s.getChild("AttributeName"),o=[],l;if(a){let c=t.sliceDoc(a.from,a.to),h=e.globalAttrs[c];if(!h){let d=p1(n),m=d?e.tags[d1(t.doc,d)]:null;h=m?.attrs&&m.attrs[c]}if(h){let d=t.sliceDoc(r,i).toLowerCase(),m='"',g='"';/^['"]/.test(d)?(l=d[0]=='"'?/^[^"]*$/:/^[^']*$/,m="",g=t.sliceDoc(i,i+1)==d[0]?"":d[0],d=d.slice(1),r++):l=/^[^\s<>='"]*$/;for(let x of h)o.push({label:x,apply:m+x+g,type:"constant"})}}return{from:r,to:i,options:o,validFor:l}}function jpe(t,e){let{state:n,pos:r}=e,i=Fn(n).resolveInner(r,-1),s=i.resolve(r);for(let a=r,o;s==i&&(o=i.childBefore(a));){let l=o.lastChild;if(!l||!l.type.isError||l.from<l.to)break;s=i=o,a=l.from}return i.name=="TagName"?i.parent&&/CloseTag$/.test(i.parent.name)?UZ(n,i,i.from,r):ZZ(n,t,i,i.from,r):i.name=="StartTag"||i.name=="IncompleteTag"?ZZ(n,t,i,r,r):i.name=="StartCloseTag"||i.name=="IncompleteCloseTag"?UZ(n,i,r,r):i.name=="OpenTag"||i.name=="SelfClosingTag"||i.name=="AttributeName"?Iot(n,t,i,i.name=="AttributeName"?i.from:r,r):i.name=="Is"||i.name=="AttributeValue"||i.name=="UnquotedAttributeValue"?Not(n,t,i,i.name=="Is"?r:i.from,r):e.explicit&&(s.name=="Element"||s.name=="Text"||s.name=="Document")?Rot(n,t,i,r):null}function Hpe(t){return jpe(Iv.default,t)}function Zpe(t){let{extraTags:e,extraGlobalAttributes:n}=t,r=n||e?new Iv(e,n):Iv.default;return i=>jpe(r,i)}const $ot=Ya.parser.configure({top:"SingleExpression"}),Upe=[{tag:"script",attrs:t=>t.type=="text/typescript"||t.lang=="ts",parser:GR.parser},{tag:"script",attrs:t=>t.type=="text/babel"||t.type=="text/jsx",parser:KR.parser},{tag:"script",attrs:t=>t.type=="text/typescript-jsx",parser:JR.parser},{tag:"script",attrs(t){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(t.type)},parser:$ot},{tag:"script",attrs(t){return!t.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(t.type)},parser:Ya.parser},{tag:"style",attrs(t){return(!t.lang||t.lang=="css")&&(!t.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(t.type))},parser:Rv.parser}],qpe=[{name:"style",parser:Rv.parser.configure({top:"Styles"})}].concat(Fpe.map(t=>({name:t,parser:Ya.parser}))),Xpe=$d.define({name:"html",parser:Hat.configure({props:[ep.add({Element(t){let e=/^(\s*)(<\/)?/.exec(t.textAfter);return t.node.to<=t.pos+e[0].length?t.continue():t.lineIndent(t.node.from)+(e[2]?0:t.unit)},"OpenTag CloseTag SelfClosingTag"(t){return t.column(t.node.from)+t.unit},Document(t){if(t.pos+/\s*/.exec(t.textAfter)[0].length<t.node.to)return t.continue();let e=null,n;for(let r=t.node;;){let i=r.lastChild;if(!i||i.name!="Element"||i.to!=r.to)break;e=r=i}return e&&!((n=e.lastChild)&&(n.name=="CloseTag"||n.name=="SelfClosingTag"))?t.lineIndent(e.from)+t.unit:null}}),tp.add({Element(t){let e=t.firstChild,n=t.lastChild;return!e||e.name!="OpenTag"?null:{from:e.to,to:n.name=="CloseTag"?n.from:t.to}}}),fde.add({"OpenTag CloseTag":t=>t.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),T2=Xpe.configure({wrap:Cpe(Upe,qpe)});function Wpe(t={}){let e="",n;t.matchClosingTags===!1&&(e="noMatch"),t.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(t.nestedLanguages&&t.nestedLanguages.length||t.nestedAttributes&&t.nestedAttributes.length)&&(n=Cpe((t.nestedLanguages||[]).concat(Upe),(t.nestedAttributes||[]).concat(qpe)));let r=n?Xpe.configure({wrap:n,dialect:e}):e?T2.configure({dialect:e}):T2;return new zd(r,[T2.data.of({autocomplete:Zpe(t)}),t.autoCloseTags!==!1?Ype:[],zpe().support,vpe().support])}const qZ=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),Ype=Ze.inputHandler.of((t,e,n,r,i)=>{if(t.composing||t.state.readOnly||e!=n||r!=">"&&r!="/"||!T2.isActiveAt(t.state,e,-1))return!1;let s=i(),{state:a}=s,o=a.changeByRange(l=>{var c,h,d;let m=a.doc.sliceString(l.from-1,l.to)==r,{head:g}=l,x=Fn(a).resolveInner(g,-1),O;if(m&&r==">"&&x.name=="EndTag"){let w=x.parent;if(((h=(c=w.parent)===null||c===void 0?void 0:c.lastChild)===null||h===void 0?void 0:h.name)!="CloseTag"&&(O=d1(a.doc,w.parent,g))&&!qZ.has(O)){let E=g+(a.doc.sliceString(g,g+1)===">"?1:0),S=`</${O}>`;return{range:l,changes:{from:g,to:E,insert:S}}}}else if(m&&r=="/"&&x.name=="IncompleteCloseTag"){let w=x.parent;if(x.from==g-2&&((d=w.lastChild)===null||d===void 0?void 0:d.name)!="CloseTag"&&(O=d1(a.doc,w,g))&&!qZ.has(O)){let E=g+(a.doc.sliceString(g,g+1)===">"?1:0),S=`${O}>`;return{range:Ce.cursor(g+S.length,-1),changes:{from:g,to:E,insert:S}}}}return{range:l}});return o.changes.empty?!1:(t.dispatch([s,a.update(o,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),Lot=Object.freeze(Object.defineProperty({__proto__:null,autoCloseTags:Ype,html:Wpe,htmlCompletionSource:Hpe,htmlCompletionSourceWith:Zpe,htmlLanguage:T2},Symbol.toStringTag,{value:"Module"}));function zot(t,e,n,r){const i=cr(lr),s=Yt(iM),a=p.useRef(null),{lexicalNode:o}=Xk(),l=p.useRef(!1),c=p.useRef(!1),h=p.useCallback(()=>{s({editorType:e,rootNode:o,editorRef:a.current})},[e,o,s]),d=p.useCallback(m=>{var g,x,O,w,E,S;if(m.key==="ArrowDown"){const _=(x=(g=a.current)==null?void 0:g.getCodemirror())==null?void 0:x.state;if(_){const P=_.doc.length,A=_.selection.ranges[0].to;P===A&&(l.current?(i?.update(()=>{var k,I;const $=an(t);$.getNextSibling()?((I=(k=a.current)==null?void 0:k.getCodemirror())==null||I.contentDOM.blur(),$.selectNext()):$.insertAfter(Kt())}),l.current=!1):l.current=!0)}}else if(m.key==="ArrowUp"){const _=(w=(O=a.current)==null?void 0:O.getCodemirror())==null?void 0:w.state;_&&_.selection.ranges[0].from===0&&(c.current?(i?.update(()=>{var A,k;const I=an(t);I.getPreviousSibling()&&((k=(A=a.current)==null?void 0:A.getCodemirror())==null||k.contentDOM.blur(),I.selectPrevious())}),c.current=!1):c.current=!0)}else if(m.key==="Enter")m.stopPropagation();else if(m.key==="Backspace"||m.key==="Delete"){const _=(S=(E=a.current)==null?void 0:E.getCodemirror())==null?void 0:S.state;_?.doc.length===0&&i?.update(()=>{an(t).remove()})}},[i,t]);return p.useEffect(()=>{const m=a.current;return setTimeout(()=>{var g,x;(g=m?.getCodemirror())==null||g.contentDOM.addEventListener("focus",h),(x=m?.getCodemirror())==null||x.contentDOM.addEventListener("keydown",d)},300),()=>{var g,x;(g=m?.getCodemirror())==null||g.contentDOM.removeEventListener("focus",h),(x=m?.getCodemirror())==null||x.contentDOM.removeEventListener("keydown",d)}},[a,h,d,n]),p.useEffect(()=>{r.subscribe(()=>{var m,g;(g=(m=a.current)==null?void 0:m.getCodemirror())==null||g.focus(),h()})},[r,a,t,h]),a}function De(t){return new zd(PR.define(t))}function Ju(t){return _e(()=>import("./index-C_paHaVu.js"),[]).then(e=>e.sql({dialect:e[t]}))}const Gpe=[we.of({name:"C",extensions:["c","h","ino"],load(){return _e(()=>import("./index-D_CH-VK7.js"),[]).then(t=>t.cpp())}}),we.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return _e(()=>import("./index-D_CH-VK7.js"),[]).then(t=>t.cpp())}}),we.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Ju("Cassandra")}}),we.of({name:"CSS",extensions:["css"],load(){return _e(()=>Promise.resolve().then(()=>aat),void 0).then(t=>t.css())}}),we.of({name:"Go",extensions:["go"],load(){return _e(()=>import("./index-09wp6zYx.js"),[]).then(t=>t.go())}}),we.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return _e(()=>Promise.resolve().then(()=>Lot),void 0).then(t=>t.html())}}),we.of({name:"Java",extensions:["java"],load(){return _e(()=>import("./index-QtwSDjQm.js"),[]).then(t=>t.java())}}),we.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return _e(()=>Promise.resolve().then(()=>cO),void 0).then(t=>t.javascript())}}),we.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load(){return _e(()=>import("./index-CfQ-lz7B.js"),[]).then(t=>t.jinja())}}),we.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return _e(()=>import("./index-CGs7A6M0.js"),[]).then(t=>t.json())}}),we.of({name:"JSX",extensions:["jsx"],load(){return _e(()=>Promise.resolve().then(()=>cO),void 0).then(t=>t.javascript({jsx:!0}))}}),we.of({name:"LESS",extensions:["less"],load(){return _e(()=>import("./index-CelDrkwY.js"),[]).then(t=>t.less())}}),we.of({name:"Liquid",extensions:["liquid"],load(){return _e(()=>import("./index-DG4QoCve.js"),[]).then(t=>t.liquid())}}),we.of({name:"MariaDB SQL",load(){return Ju("MariaSQL")}}),we.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return _e(()=>Promise.resolve().then(()=>Kct),void 0).then(t=>t.markdown())}}),we.of({name:"MS SQL",load(){return Ju("MSSQL")}}),we.of({name:"MySQL",load(){return Ju("MySQL")}}),we.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return _e(()=>import("./index-Qu04TL5H.js"),[]).then(t=>t.php())}}),we.of({name:"PLSQL",extensions:["pls"],load(){return Ju("PLSQL")}}),we.of({name:"PostgreSQL",load(){return Ju("PostgreSQL")}}),we.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return _e(()=>import("./index-NEadZbXX.js"),[]).then(t=>t.python())}}),we.of({name:"Rust",extensions:["rs"],load(){return _e(()=>import("./index-BoSz7U0Z.js"),[]).then(t=>t.rust())}}),we.of({name:"Sass",extensions:["sass"],load(){return _e(()=>import("./index-6JDMRjpb.js"),[]).then(t=>t.sass({indented:!0}))}}),we.of({name:"SCSS",extensions:["scss"],load(){return _e(()=>import("./index-6JDMRjpb.js"),[]).then(t=>t.sass())}}),we.of({name:"SQL",extensions:["sql"],load(){return Ju("StandardSQL")}}),we.of({name:"SQLite",load(){return Ju("SQLite")}}),we.of({name:"TSX",extensions:["tsx"],load(){return _e(()=>Promise.resolve().then(()=>cO),void 0).then(t=>t.javascript({jsx:!0,typescript:!0}))}}),we.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return _e(()=>Promise.resolve().then(()=>cO),void 0).then(t=>t.javascript({typescript:!0}))}}),we.of({name:"WebAssembly",extensions:["wat","wast"],load(){return _e(()=>import("./index-D1EUeT6H.js"),[]).then(t=>t.wast())}}),we.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return _e(()=>import("./index-CNodmjTW.js"),[]).then(t=>t.xml())}}),we.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return _e(()=>import("./index-ClAgPazm.js"),[]).then(t=>t.yaml())}}),we.of({name:"APL",extensions:["dyalog","apl"],load(){return _e(()=>import("./apl-B4CMkyY2.js"),[]).then(t=>De(t.apl))}}),we.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return _e(()=>import("./asciiarmor-Df11BRmG.js"),[]).then(t=>De(t.asciiArmor))}}),we.of({name:"ASN.1",extensions:["asn","asn1"],load(){return _e(()=>import("./asn1-EdZsLKOL.js"),[]).then(t=>De(t.asn1({})))}}),we.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return _e(()=>import("./asterisk-B-8jnY81.js"),[]).then(t=>De(t.asterisk))}}),we.of({name:"Brainfuck",extensions:["b","bf"],load(){return _e(()=>import("./brainfuck-C4LP7Hcl.js"),[]).then(t=>De(t.brainfuck))}}),we.of({name:"Cobol",extensions:["cob","cpy"],load(){return _e(()=>import("./cobol-CWcv1MsR.js"),[]).then(t=>De(t.cobol))}}),we.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return _e(()=>import("./clike-B9uivgTg.js"),[]).then(t=>De(t.csharp))}}),we.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return _e(()=>import("./clojure-BMjYHr_A.js"),[]).then(t=>De(t.clojure))}}),we.of({name:"ClojureScript",extensions:["cljs"],load(){return _e(()=>import("./clojure-BMjYHr_A.js"),[]).then(t=>De(t.clojure))}}),we.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return _e(()=>import("./css-BnMrqG3P.js"),[]).then(t=>De(t.gss))}}),we.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return _e(()=>import("./cmake-BQqOBYOt.js"),[]).then(t=>De(t.cmake))}}),we.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return _e(()=>import("./coffeescript-S37ZYGWr.js"),[]).then(t=>De(t.coffeeScript))}}),we.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return _e(()=>import("./commonlisp-DBKNyK5s.js"),[]).then(t=>De(t.commonLisp))}}),we.of({name:"Cypher",extensions:["cyp","cypher"],load(){return _e(()=>import("./cypher-C_CwsFkJ.js"),[]).then(t=>De(t.cypher))}}),we.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return _e(()=>import("./python-BuPzkPfP.js"),[]).then(t=>De(t.cython))}}),we.of({name:"Crystal",extensions:["cr"],load(){return _e(()=>import("./crystal-SjHAIU92.js"),[]).then(t=>De(t.crystal))}}),we.of({name:"D",extensions:["d"],load(){return _e(()=>import("./d-pRatUO7H.js"),[]).then(t=>De(t.d))}}),we.of({name:"Dart",extensions:["dart"],load(){return _e(()=>import("./clike-B9uivgTg.js"),[]).then(t=>De(t.dart))}}),we.of({name:"diff",extensions:["diff","patch"],load(){return _e(()=>import("./diff-DbItnlRl.js"),[]).then(t=>De(t.diff))}}),we.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return _e(()=>import("./dockerfile-BKs6k2Af.js"),__vite__mapDeps([0,1])).then(t=>De(t.dockerFile))}}),we.of({name:"DTD",extensions:["dtd"],load(){return _e(()=>import("./dtd-DF_7sFjM.js"),[]).then(t=>De(t.dtd))}}),we.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return _e(()=>import("./dylan-DwRh75JA.js"),[]).then(t=>De(t.dylan))}}),we.of({name:"EBNF",load(){return _e(()=>import("./ebnf-CDyGwa7X.js"),[]).then(t=>De(t.ebnf))}}),we.of({name:"ECL",extensions:["ecl"],load(){return _e(()=>import("./ecl-Cabwm37j.js"),[]).then(t=>De(t.ecl))}}),we.of({name:"edn",extensions:["edn"],load(){return _e(()=>import("./clojure-BMjYHr_A.js"),[]).then(t=>De(t.clojure))}}),we.of({name:"Eiffel",extensions:["e"],load(){return _e(()=>import("./eiffel-CnydiIhH.js"),[]).then(t=>De(t.eiffel))}}),we.of({name:"Elm",extensions:["elm"],load(){return _e(()=>import("./elm-vLlmbW-K.js"),[]).then(t=>De(t.elm))}}),we.of({name:"Erlang",extensions:["erl"],load(){return _e(()=>import("./erlang-BNw1qcRV.js"),[]).then(t=>De(t.erlang))}}),we.of({name:"Esper",load(){return _e(()=>import("./sql-D0XecflT.js"),[]).then(t=>De(t.esper))}}),we.of({name:"Factor",extensions:["factor"],load(){return _e(()=>import("./factor-kuTfRLto.js"),__vite__mapDeps([2,1])).then(t=>De(t.factor))}}),we.of({name:"FCL",load(){return _e(()=>import("./fcl-Kvtd6kyn.js"),[]).then(t=>De(t.fcl))}}),we.of({name:"Forth",extensions:["forth","fth","4th"],load(){return _e(()=>import("./forth-Ffai-XNe.js"),[]).then(t=>De(t.forth))}}),we.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return _e(()=>import("./fortran-DYz_wnZ1.js"),[]).then(t=>De(t.fortran))}}),we.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return _e(()=>import("./mllike-CXdrOF99.js"),[]).then(t=>De(t.fSharp))}}),we.of({name:"Gas",extensions:["s"],load(){return _e(()=>import("./gas-Bneqetm1.js"),[]).then(t=>De(t.gas))}}),we.of({name:"Gherkin",extensions:["feature"],load(){return _e(()=>import("./gherkin-heZmZLOM.js"),[]).then(t=>De(t.gherkin))}}),we.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return _e(()=>import("./groovy-D9Dt4D0W.js"),[]).then(t=>De(t.groovy))}}),we.of({name:"Haskell",extensions:["hs"],load(){return _e(()=>import("./haskell-Cw1EW3IL.js"),[]).then(t=>De(t.haskell))}}),we.of({name:"Haxe",extensions:["hx"],load(){return _e(()=>import("./haxe-H-WmDvRZ.js"),[]).then(t=>De(t.haxe))}}),we.of({name:"HXML",extensions:["hxml"],load(){return _e(()=>import("./haxe-H-WmDvRZ.js"),[]).then(t=>De(t.hxml))}}),we.of({name:"HTTP",load(){return _e(()=>import("./http-DBlCnlav.js"),[]).then(t=>De(t.http))}}),we.of({name:"IDL",extensions:["pro"],load(){return _e(()=>import("./idl-BEugSyMb.js"),[]).then(t=>De(t.idl))}}),we.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return _e(()=>import("./javascript-iXu5QeM3.js"),[]).then(t=>De(t.jsonld))}}),we.of({name:"Julia",extensions:["jl"],load(){return _e(()=>import("./julia-DuME0IfC.js"),[]).then(t=>De(t.julia))}}),we.of({name:"Kotlin",extensions:["kt","kts"],load(){return _e(()=>import("./clike-B9uivgTg.js"),[]).then(t=>De(t.kotlin))}}),we.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return _e(()=>import("./livescript-BwQOo05w.js"),[]).then(t=>De(t.liveScript))}}),we.of({name:"Lua",extensions:["lua"],load(){return _e(()=>import("./lua-BgMRiT3U.js"),[]).then(t=>De(t.lua))}}),we.of({name:"mIRC",extensions:["mrc"],load(){return _e(()=>import("./mirc-CjQqDB4T.js"),[]).then(t=>De(t.mirc))}}),we.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return _e(()=>import("./mathematica-DTrFuWx2.js"),[]).then(t=>De(t.mathematica))}}),we.of({name:"Modelica",extensions:["mo"],load(){return _e(()=>import("./modelica-Dc1JOy9r.js"),[]).then(t=>De(t.modelica))}}),we.of({name:"MUMPS",extensions:["mps"],load(){return _e(()=>import("./mumps-BT43cFF4.js"),[]).then(t=>De(t.mumps))}}),we.of({name:"Mbox",extensions:["mbox"],load(){return _e(()=>import("./mbox-CNhZ1qSd.js"),[]).then(t=>De(t.mbox))}}),we.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return _e(()=>import("./nginx-DdIZxoE0.js"),[]).then(t=>De(t.nginx))}}),we.of({name:"NSIS",extensions:["nsh","nsi"],load(){return _e(()=>import("./nsis-LdVXkNf5.js"),__vite__mapDeps([3,1])).then(t=>De(t.nsis))}}),we.of({name:"NTriples",extensions:["nt","nq"],load(){return _e(()=>import("./ntriples-BfvgReVJ.js"),[]).then(t=>De(t.ntriples))}}),we.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return _e(()=>import("./clike-B9uivgTg.js"),[]).then(t=>De(t.objectiveC))}}),we.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return _e(()=>import("./clike-B9uivgTg.js"),[]).then(t=>De(t.objectiveCpp))}}),we.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return _e(()=>import("./mllike-CXdrOF99.js"),[]).then(t=>De(t.oCaml))}}),we.of({name:"Octave",extensions:["m"],load(){return _e(()=>import("./octave-Ck1zUtKM.js"),[]).then(t=>De(t.octave))}}),we.of({name:"Oz",extensions:["oz"],load(){return _e(()=>import("./oz-BzwKVEFT.js"),[]).then(t=>De(t.oz))}}),we.of({name:"Pascal",extensions:["p","pas"],load(){return _e(()=>import("./pascal--L3eBynH.js"),[]).then(t=>De(t.pascal))}}),we.of({name:"Perl",extensions:["pl","pm"],load(){return _e(()=>import("./perl-CdXCOZ3F.js"),[]).then(t=>De(t.perl))}}),we.of({name:"Pig",extensions:["pig"],load(){return _e(()=>import("./pig-CevX1Tat.js"),[]).then(t=>De(t.pig))}}),we.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return _e(()=>import("./powershell-CFHJl5sT.js"),[]).then(t=>De(t.powerShell))}}),we.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return _e(()=>import("./properties-C78fOPTZ.js"),[]).then(t=>De(t.properties))}}),we.of({name:"ProtoBuf",extensions:["proto"],load(){return _e(()=>import("./protobuf-ChK-085T.js"),[]).then(t=>De(t.protobuf))}}),we.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return _e(()=>import("./pug-DeIclll2.js"),__vite__mapDeps([4,5])).then(t=>De(t.pug))}}),we.of({name:"Puppet",extensions:["pp"],load(){return _e(()=>import("./puppet-DMA9R1ak.js"),[]).then(t=>De(t.puppet))}}),we.of({name:"Q",extensions:["q"],load(){return _e(()=>import("./q-pXgVlZs6.js"),[]).then(t=>De(t.q))}}),we.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return _e(()=>import("./r-B6wPVr8A.js"),[]).then(t=>De(t.r))}}),we.of({name:"RPM Changes",load(){return _e(()=>import("./rpm-CTu-6PCP.js"),[]).then(t=>De(t.rpmChanges))}}),we.of({name:"RPM Spec",extensions:["spec"],load(){return _e(()=>import("./rpm-CTu-6PCP.js"),[]).then(t=>De(t.rpmSpec))}}),we.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return _e(()=>import("./ruby-B2Rjki9n.js"),[]).then(t=>De(t.ruby))}}),we.of({name:"SAS",extensions:["sas"],load(){return _e(()=>import("./sas-B4kiWyti.js"),[]).then(t=>De(t.sas))}}),we.of({name:"Scala",extensions:["scala"],load(){return _e(()=>import("./clike-B9uivgTg.js"),[]).then(t=>De(t.scala))}}),we.of({name:"Scheme",extensions:["scm","ss"],load(){return _e(()=>import("./scheme-C41bIUwD.js"),[]).then(t=>De(t.scheme))}}),we.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return _e(()=>import("./shell-CjFT_Tl9.js"),[]).then(t=>De(t.shell))}}),we.of({name:"Sieve",extensions:["siv","sieve"],load(){return _e(()=>import("./sieve-C3Gn_uJK.js"),[]).then(t=>De(t.sieve))}}),we.of({name:"Smalltalk",extensions:["st"],load(){return _e(()=>import("./smalltalk-CnHTOXQT.js"),[]).then(t=>De(t.smalltalk))}}),we.of({name:"Solr",load(){return _e(()=>import("./solr-DehyRSwq.js"),[]).then(t=>De(t.solr))}}),we.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return _e(()=>import("./mllike-CXdrOF99.js"),[]).then(t=>De(t.sml))}}),we.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return _e(()=>import("./sparql-DkYu6x3z.js"),[]).then(t=>De(t.sparql))}}),we.of({name:"Spreadsheet",alias:["excel","formula"],load(){return _e(()=>import("./spreadsheet-BCZA_wO0.js"),[]).then(t=>De(t.spreadsheet))}}),we.of({name:"Squirrel",extensions:["nut"],load(){return _e(()=>import("./clike-B9uivgTg.js"),[]).then(t=>De(t.squirrel))}}),we.of({name:"Stylus",extensions:["styl"],load(){return _e(()=>import("./stylus-B533Al4x.js"),[]).then(t=>De(t.stylus))}}),we.of({name:"Swift",extensions:["swift"],load(){return _e(()=>import("./swift-BzpIVaGY.js"),[]).then(t=>De(t.swift))}}),we.of({name:"sTeX",load(){return _e(()=>import("./stex-C3f8Ysf7.js"),[]).then(t=>De(t.stex))}}),we.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return _e(()=>import("./stex-C3f8Ysf7.js"),[]).then(t=>De(t.stex))}}),we.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return _e(()=>import("./verilog-C6RDOZhf.js"),[]).then(t=>De(t.verilog))}}),we.of({name:"Tcl",extensions:["tcl"],load(){return _e(()=>import("./tcl-DVfN8rqt.js"),[]).then(t=>De(t.tcl))}}),we.of({name:"Textile",extensions:["textile"],load(){return _e(()=>import("./textile-CnDTJFAw.js"),[]).then(t=>De(t.textile))}}),we.of({name:"TiddlyWiki",load(){return _e(()=>import("./tiddlywiki-DO-Gjzrf.js"),[]).then(t=>De(t.tiddlyWiki))}}),we.of({name:"Tiki wiki",load(){return _e(()=>import("./tiki-DGYXhP31.js"),[]).then(t=>De(t.tiki))}}),we.of({name:"TOML",extensions:["toml"],load(){return _e(()=>import("./toml-Bm5Em-hy.js"),[]).then(t=>De(t.toml))}}),we.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return _e(()=>import("./troff-wAsdV37c.js"),[]).then(t=>De(t.troff))}}),we.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return _e(()=>import("./ttcn-CfJYG6tj.js"),[]).then(t=>De(t.ttcn))}}),we.of({name:"TTCN_CFG",extensions:["cfg"],load(){return _e(()=>import("./ttcn-cfg-B9xdYoR4.js"),[]).then(t=>De(t.ttcnCfg))}}),we.of({name:"Turtle",extensions:["ttl"],load(){return _e(()=>import("./turtle-B1tBg_DP.js"),[]).then(t=>De(t.turtle))}}),we.of({name:"Web IDL",extensions:["webidl"],load(){return _e(()=>import("./webidl-ZXfAyPTL.js"),[]).then(t=>De(t.webIDL))}}),we.of({name:"VB.NET",extensions:["vb"],load(){return _e(()=>import("./vb-CmGdzxic.js"),[]).then(t=>De(t.vb))}}),we.of({name:"VBScript",extensions:["vbs"],load(){return _e(()=>import("./vbscript-BuJXcnF6.js"),[]).then(t=>De(t.vbScript))}}),we.of({name:"Velocity",extensions:["vtl"],load(){return _e(()=>import("./velocity-D8B20fx6.js"),[]).then(t=>De(t.velocity))}}),we.of({name:"Verilog",extensions:["v"],load(){return _e(()=>import("./verilog-C6RDOZhf.js"),[]).then(t=>De(t.verilog))}}),we.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return _e(()=>import("./vhdl-lSbBsy5d.js"),[]).then(t=>De(t.vhdl))}}),we.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load(){return _e(()=>import("./xquery-DzFWVndE.js"),[]).then(t=>De(t.xQuery))}}),we.of({name:"Yacas",extensions:["ys"],load(){return _e(()=>import("./yacas-BJ4BC0dw.js"),[]).then(t=>De(t.yacas))}}),we.of({name:"Z80",extensions:["z80"],load(){return _e(()=>import("./z80-Hz9HOZM7.js"),[]).then(t=>De(t.z80))}}),we.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return _e(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(t=>De(t.mscgen))}}),we.of({name:"Xù",extensions:["xu"],load(){return _e(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(t=>De(t.xu))}}),we.of({name:"MsGenny",extensions:["msgenny"],load(){return _e(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(t=>De(t.msgenny))}}),we.of({name:"Vue",extensions:["vue"],load(){return _e(()=>import("./index-CFkco-F_.js"),[]).then(t=>t.vue())}}),we.of({name:"Angular Template",load(){return _e(()=>import("./index-BLbwxB-T.js"),[]).then(t=>t.angular())}})],XZ="#2e3440",tI="#3b4252",WZ="#434c5e",uO="#4c566a",YZ="#e5e9f0",ZC="#eceff4",KE="#8fbcbb",GZ="#88c0d0",Dot="#81a1c1",So="#5e81ac",Qot="#bf616a",Wp="#d08770",JE="#ebcb8b",KZ="#a3be8c",Fot="#b48ead",JZ="#d30102",nI=ZC,e_=nI,Vot="#ffffff",t_=tI,Bot=nI,eU=tI,jot=Ze.theme({"&":{color:XZ,backgroundColor:Vot},".cm-content":{caretColor:eU},".cm-cursor, .cm-dropCursor":{borderLeftColor:eU},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Bot},".cm-panels":{backgroundColor:nI,color:uO},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:`1px solid ${uO}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:YZ},".cm-activeLine":{backgroundColor:e_},".cm-selectionMatch":{backgroundColor:YZ},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${uO}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:ZC},".cm-gutters":{backgroundColor:ZC,color:XZ,border:"none"},".cm-activeLineGutter":{backgroundColor:e_},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:t_},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:t_,borderBottomColor:t_},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:e_,color:uO}}},{dark:!1}),Hot=zy.define([{tag:Y.keyword,color:So},{tag:[Y.name,Y.deleted,Y.character,Y.propertyName,Y.macroName],color:Wp},{tag:[Y.variableName],color:Wp},{tag:[Y.function(Y.variableName)],color:So},{tag:[Y.labelName],color:Dot},{tag:[Y.color,Y.constant(Y.name),Y.standard(Y.name)],color:So},{tag:[Y.definition(Y.name),Y.separator],color:KZ},{tag:[Y.brace],color:KE},{tag:[Y.annotation],color:JZ},{tag:[Y.number,Y.changed,Y.annotation,Y.modifier,Y.self,Y.namespace],color:GZ},{tag:[Y.typeName,Y.className],color:JE},{tag:[Y.operator,Y.operatorKeyword],color:KZ},{tag:[Y.tagName],color:Fot},{tag:[Y.squareBracket],color:Qot},{tag:[Y.angleBracket],color:Wp},{tag:[Y.attributeName],color:JE},{tag:[Y.regexp],color:So},{tag:[Y.quote],color:tI},{tag:[Y.string],color:Wp},{tag:Y.link,color:KE,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[Y.url,Y.escape,Y.special(Y.string)],color:Wp},{tag:[Y.meta],color:GZ},{tag:[Y.comment],color:WZ,fontStyle:"italic"},{tag:Y.strong,fontWeight:"bold",color:So},{tag:Y.emphasis,fontStyle:"italic",color:So},{tag:Y.strikethrough,textDecoration:"line-through"},{tag:Y.heading,fontWeight:"bold",color:So},{tag:Y.special(Y.heading1),fontWeight:"bold",color:So},{tag:Y.heading1,fontWeight:"bold",color:So},{tag:[Y.heading2,Y.heading3,Y.heading4],fontWeight:"bold",color:So},{tag:[Y.heading5,Y.heading6],color:So},{tag:[Y.atom,Y.bool,Y.special(Y.variableName)],color:Wp},{tag:[Y.processingInstruction,Y.inserted],color:KE},{tag:[Y.contentSeparator],color:JE},{tag:Y.invalid,color:WZ,borderBottom:`1px dotted ${JZ}`}]),Kpe=[jot,lde(Hot)],tU=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class m1{constructor(e,n,r=0,i=e.length,s,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(r,i),this.bufferStart=r,this.normalize=s?o=>s(tU(o)):tU,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Rs(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let n=iR(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=_l(e);let i=this.normalize(n);if(i.length)for(let s=0,a=r;;s++){let o=i.charCodeAt(s),l=this.match(o,a,this.bufferPos+this.bufferStart);if(s==i.length-1){if(l)return this.value=l,this;break}a==r&&s<n.length&&n.charCodeAt(s)==o&&a++}}}match(e,n,r){let i=null;for(let s=0;s<this.matches.length;s+=2){let a=this.matches[s],o=!1;this.query.charCodeAt(a)==e&&(a==this.query.length-1?i={from:this.matches[s+1],to:r}:(this.matches[s]++,o=!0)),o||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:n,to:r}:this.matches.push(1,n)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}typeof Symbol<"u"&&(m1.prototype[Symbol.iterator]=function(){return this});const Jpe={from:-1,to:-1,match:/.*/.exec("")},rI="gm"+(/x/.unicode==null?"":"u");class eme{constructor(e,n,r,i=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=Jpe,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new tme(e,n,r,i,s);this.re=new RegExp(n,rI+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=e.iter();let a=e.lineAt(i);this.curLineStart=a.from,this.matchPos=i4(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,i=r+n[0].length;if(this.matchPos=i4(this.text,i+(r==i?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<i||r>this.value.to)&&(!this.test||this.test(r,i,n)))return this.value={from:r,to:i,match:n},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const n_=new WeakMap;class zm{constructor(e,n){this.from=e,this.text=n}get to(){return this.from+this.text.length}static get(e,n,r){let i=n_.get(e);if(!i||i.from>=r||i.to<=n){let o=new zm(n,e.sliceString(n,r));return n_.set(e,o),o}if(i.from==n&&i.to==r)return i;let{text:s,from:a}=i;return a>n&&(s=e.sliceString(n,a)+s,a=n),i.to<r&&(s+=e.sliceString(i.to,r)),n_.set(e,new zm(a,s)),new zm(n,s.slice(n-a,r-a))}}class tme{constructor(e,n,r,i,s){this.text=e,this.to=s,this.done=!1,this.value=Jpe,this.matchPos=i4(e,i),this.re=new RegExp(n,rI+(r?.ignoreCase?"i":"")),this.test=r?.test,this.flat=zm.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==e&&(this.re.lastIndex=e+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,i=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,i,n)))return this.value={from:r,to:i,match:n},this.matchPos=i4(this.text,i+(r==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=zm.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(eme.prototype[Symbol.iterator]=tme.prototype[Symbol.iterator]=function(){return this});function Zot(t){try{return new RegExp(t,rI),!0}catch{return!1}}function i4(t,e){if(e>=t.length)return e;let n=t.lineAt(e),r;for(;e<n.to&&(r=n.text.charCodeAt(e-n.from))>=56320&&r<57344;)e++;return e}const Uot=t=>{let{state:e}=t,n=String(e.doc.lineAt(t.state.selection.main.head).number),{close:r,result:i}=Ftt(t,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:e.phrase("go")});return i.then(s=>{let a=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!a){t.dispatch({effects:r});return}let o=e.doc.lineAt(e.selection.main.head),[,l,c,h,d]=a,m=h?+h.slice(1):0,g=c?+c:o.number;if(c&&d){let w=g/100;l&&(w=w*(l=="-"?-1:1)+o.number/e.doc.lines),g=Math.round(e.doc.lines*w)}else c&&l&&(g=g*(l=="-"?-1:1)+o.number);let x=e.doc.line(Math.max(1,Math.min(e.doc.lines,g))),O=Ce.cursor(x.from+Math.max(0,Math.min(m,x.length)));t.dispatch({effects:[r,Ze.scrollIntoView(O.from,{y:"center"})],selection:O})}),!0},qot={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Xot=tt.define({combine(t){return rc(t,qot,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function Wot(t){return[elt,Jot]}const Yot=lt.mark({class:"cm-selectionMatch"}),Got=lt.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function nU(t,e,n,r){return(n==0||t(e.sliceDoc(n-1,n))!=vr.Word)&&(r==e.doc.length||t(e.sliceDoc(r,r+1))!=vr.Word)}function Kot(t,e,n,r){return t(e.sliceDoc(n,n+1))==vr.Word&&t(e.sliceDoc(r-1,r))==vr.Word}const Jot=Nr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(Xot),{state:n}=t,r=n.selection;if(r.ranges.length>1)return lt.none;let i=r.main,s,a=null;if(i.empty){if(!e.highlightWordAroundCursor)return lt.none;let l=n.wordAt(i.head);if(!l)return lt.none;a=n.charCategorizer(i.head),s=n.sliceDoc(l.from,l.to)}else{let l=i.to-i.from;if(l<e.minSelectionLength||l>200)return lt.none;if(e.wholeWords){if(s=n.sliceDoc(i.from,i.to),a=n.charCategorizer(i.head),!(nU(a,n,i.from,i.to)&&Kot(a,n,i.from,i.to)))return lt.none}else if(s=n.sliceDoc(i.from,i.to),!s)return lt.none}let o=[];for(let l of t.visibleRanges){let c=new m1(n.doc,s,l.from,l.to);for(;!c.next().done;){let{from:h,to:d}=c.value;if((!a||nU(a,n,h,d))&&(i.empty&&h<=i.from&&d>=i.to?o.push(Got.range(h,d)):(h>=i.to||d<=i.from)&&o.push(Yot.range(h,d)),o.length>e.maxMatches))return lt.none}}return lt.set(o)}},{decorations:t=>t.decorations}),elt=Ze.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),tlt=({state:t,dispatch:e})=>{let{selection:n}=t,r=Ce.create(n.ranges.map(i=>t.wordAt(i.head)||Ce.cursor(i.head)),n.mainIndex);return r.eq(n)?!1:(e(t.update({selection:r})),!0)};function nlt(t,e){let{main:n,ranges:r}=t.selection,i=t.wordAt(n.head),s=i&&i.from==n.from&&i.to==n.to;for(let a=!1,o=new m1(t.doc,e,r[r.length-1].to);;)if(o.next(),o.done){if(a)return null;o=new m1(t.doc,e,0,Math.max(0,r[r.length-1].from-1)),a=!0}else{if(a&&r.some(l=>l.from==o.value.from))continue;if(s){let l=t.wordAt(o.value.from);if(!l||l.from!=o.value.from||l.to!=o.value.to)continue}return o.value}}const rlt=({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(s=>s.from===s.to))return tlt({state:t,dispatch:e});let r=t.sliceDoc(n[0].from,n[0].to);if(t.selection.ranges.some(s=>t.sliceDoc(s.from,s.to)!=r))return!1;let i=nlt(t,r);return i?(e(t.update({selection:t.selection.addRange(Ce.range(i.from,i.to),!1),effects:Ze.scrollIntoView(i.to)})),!0):!1},og=tt.define({combine(t){return rc(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new vlt(e),scrollToMatch:e=>Ze.scrollIntoView(e)})}});class nme{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Zot(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(n,r)=>r=="n"?`
305
+ }`,{label:"class",detail:"definition",type:"keyword"}),As('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),As('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],Ape=WR.concat([As("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),As("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),As("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),BZ=new Zfe,Ppe=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function C0(t){return(e,n)=>{let r=e.node.getChild("VariableDefinition");return r&&n(r,t),!0}}const wot=["FunctionDeclaration"],Sot={FunctionDeclaration:C0("function"),ClassDeclaration:C0("class"),ClassExpression:()=>!0,EnumDeclaration:C0("constant"),TypeAliasDeclaration:C0("type"),NamespaceDeclaration:C0("namespace"),VariableDefinition(t,e){t.matchContext(wot)||e(t,"variable")},TypeDefinition(t,e){e(t,"type")},__proto__:null};function Mpe(t,e){let n=BZ.get(e);if(n)return n;let r=[],i=!0;function s(a,o){let l=t.sliceString(a.from,a.to);r.push({label:l,type:o})}return e.cursor(kn.IncludeAnonymous).iterate(a=>{if(i)i=!1;else if(a.name){let o=Sot[a.name];if(o&&o(a,s)||Ppe.has(a.name))return!1}else if(a.to-a.from>8192){for(let o of Mpe(t,a.node))r.push(o);return!1}}),BZ.set(e,r),r}const r4=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,YR=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function Rpe(t){let e=Fn(t.state).resolveInner(t.pos,-1);if(YR.indexOf(e.name)>-1)return null;let n=e.name=="VariableName"||e.to-e.from<20&&r4.test(t.state.sliceDoc(e.from,e.to));if(!n&&!t.explicit)return null;let r=[];for(let i=e;i;i=i.parent)Ppe.has(i.name)&&(r=r.concat(Mpe(t.state.doc,i)));return{options:r,from:n?e.from:t.pos,validFor:r4}}function XE(t,e,n){var r;let i=[];for(;;){let s=e.firstChild,a;if(s?.name=="VariableName")return i.push(t(s)),{path:i.reverse(),name:n};if(s?.name=="MemberExpression"&&((r=a=s.lastChild)===null||r===void 0?void 0:r.name)=="PropertyName")i.push(t(a)),e=s;else return null}}function Ipe(t){let e=r=>t.state.doc.sliceString(r.from,r.to),n=Fn(t.state).resolveInner(t.pos,-1);return n.name=="PropertyName"?XE(e,n.parent,e(n)):(n.name=="."||n.name=="?.")&&n.parent.name=="MemberExpression"?XE(e,n.parent,""):YR.indexOf(n.name)>-1?null:n.name=="VariableName"||n.to-n.from<20&&r4.test(e(n))?{path:[],name:e(n)}:n.name=="MemberExpression"?XE(e,n,""):t.explicit?{path:[],name:""}:null}function Eot(t,e){let n=t,r=[],i=new Set;for(let s=0;;s++){for(let o of(Object.getOwnPropertyNames||Object.keys)(t)){if(!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(o)||i.has(o))continue;i.add(o);let l;try{l=n[o]}catch{continue}r.push({label:o,type:typeof l=="function"?/^[A-Z]/.test(o)?"class":e?"function":"method":e?"variable":"property",boost:-s})}let a=Object.getPrototypeOf(t);if(!a)return r;t=a}}function _ot(t){let e=new Map;return n=>{let r=Ipe(n);if(!r)return null;let i=t;for(let a of r.path)if(i=i[a],!i)return null;let s=e.get(i);return s||e.set(i,s=Eot(i,!r.path.length)),{from:n.pos-r.name.length,options:s,validFor:r4}}}const Ya=$d.define({name:"javascript",parser:bot.configure({props:[ep.add({IfStatement:ob({except:/^\s*({|else\b)/}),TryStatement:ob({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Ant,SwitchBody:t=>{let e=t.textAfter,n=/^\s*\}/.test(e),r=/^\s*(case|default)\b/.test(e);return t.baseIndent+(n?0:r?1:2)*t.unit},Block:Gfe({closing:"}"}),ArrowFunction:t=>t.baseIndent+t.unit,"TemplateString BlockComment":()=>null,"Statement Property":ob({except:/^\s*{/}),JSXElement(t){let e=/^\s*<\//.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},JSXEscape(t){let e=/\s*\}/.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},"JSXOpenTag JSXSelfClosingTag"(t){return t.column(t.node.from)+t.unit}}),tp.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":AR,BlockComment(t){return{from:t.from+2,to:t.to-2}},JSXElement(t){let e=t.firstChild;if(!e||e.name=="JSXSelfClosingTag")return null;let n=t.lastChild;return{from:e.to,to:n.type.isError?t.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(t){var e;let n=(e=t.firstChild)===null||e===void 0?void 0:e.nextSibling,r=t.lastChild;return!n||n.type.isError?null:{from:n.to,to:r.type.isError?t.to:r.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Npe={test:t=>/^JSX/.test(t.name),facet:mS({commentTokens:{block:{open:"{/*",close:"*/}"}}})},GR=Ya.configure({dialect:"ts"},"typescript"),KR=Ya.configure({dialect:"jsx",props:[kR.add(t=>t.isTop?[Npe]:void 0)]}),JR=Ya.configure({dialect:"jsx ts",props:[kR.add(t=>t.isTop?[Npe]:void 0)]},"typescript");let $pe=t=>({label:t,type:"keyword"});const Lpe="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map($pe),kot=Lpe.concat(["declare","implements","private","protected","public"].map($pe));function zpe(t={}){let e=t.jsx?t.typescript?JR:KR:t.typescript?GR:Ya,n=t.typescript?Ape.concat(kot):WR.concat(Lpe);return new zd(e,[Ya.data.of({autocomplete:hrt(YR,xde(n))}),Ya.data.of({autocomplete:Rpe}),t.jsx?Dpe:[]])}function Cot(t){for(;;){if(t.name=="JSXOpenTag"||t.name=="JSXSelfClosingTag"||t.name=="JSXFragmentTag")return t;if(t.name=="JSXEscape"||!t.parent)return null;t=t.parent}}function jZ(t,e,n=t.length){for(let r=e?.firstChild;r;r=r.nextSibling)if(r.name=="JSXIdentifier"||r.name=="JSXBuiltin"||r.name=="JSXNamespacedName"||r.name=="JSXMemberExpression")return t.sliceString(r.from,Math.min(r.to,n));return""}const Tot=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Dpe=Ze.inputHandler.of((t,e,n,r,i)=>{if((Tot?t.composing:t.compositionStarted)||t.state.readOnly||e!=n||r!=">"&&r!="/"||!Ya.isActiveAt(t.state,e,-1))return!1;let s=i(),{state:a}=s,o=a.changeByRange(l=>{var c;let{head:h}=l,d=Fn(a).resolveInner(h-1,-1),m;if(d.name=="JSXStartTag"&&(d=d.parent),!(a.doc.sliceString(h-1,h)!=r||d.name=="JSXAttributeValue"&&d.to>h)){if(r==">"&&d.name=="JSXFragmentTag")return{range:l,changes:{from:h,insert:"</>"}};if(r=="/"&&d.name=="JSXStartCloseTag"){let g=d.parent,x=g.parent;if(x&&g.from==h-2&&((m=jZ(a.doc,x.firstChild,h))||((c=x.firstChild)===null||c===void 0?void 0:c.name)=="JSXFragmentTag")){let O=`${m}>`;return{range:Ce.cursor(h+O.length,-1),changes:{from:h,insert:O}}}}else if(r==">"){let g=Cot(d);if(g&&g.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(a.doc.sliceString(h,h+2))&&(m=jZ(a.doc,g,h)))return{range:l,changes:{from:h,insert:`</${m}>`}}}}return{range:l}});return o.changes.empty?!1:(t.dispatch([s,a.update(o,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});function Aot(t,e){return e||(e={parserOptions:{ecmaVersion:2019,sourceType:"module"},env:{browser:!0,node:!0,es6:!0,es2015:!0,es2017:!0,es2020:!0},rules:{}},t.getRules().forEach((n,r)=>{var i;!((i=n.meta.docs)===null||i===void 0)&&i.recommended&&(e.rules[r]=2)})),n=>{let{state:r}=n,i=[];for(let{from:s,to:a}of Ya.findRegions(r)){let o=r.doc.lineAt(s),l={line:o.number-1,col:s-o.from,pos:s};for(let c of t.verify(r.sliceDoc(s,a),e))i.push(Pot(c,r.doc,l))}return i}}function HZ(t,e,n,r){return n.line(t+r.line).from+e+(t==1?r.col-1:-1)}function Pot(t,e,n){let r=HZ(t.line,t.column,e,n),i={from:r,to:t.endLine!=null&&t.endColumn!=1?HZ(t.endLine,t.endColumn,e,n):r,message:t.message,source:t.ruleId?"eslint:"+t.ruleId:"eslint",severity:t.severity==1?"warning":"error"};if(t.fix){let{range:s,text:a}=t.fix,o=s[0]+n.pos-r,l=s[1]+n.pos-r;i.actions=[{name:"fix",apply(c,h){c.dispatch({changes:{from:h+o,to:h+l,insert:a},scrollIntoView:!0})}}]}return i}const cO=Object.freeze(Object.defineProperty({__proto__:null,autoCloseTags:Dpe,completionPath:Ipe,esLint:Aot,javascript:zpe,javascriptLanguage:Ya,jsxLanguage:KR,localCompletionSource:Rpe,scopeCompletionSource:_ot,snippets:WR,tsxLanguage:JR,typescriptLanguage:GR,typescriptSnippets:Ape},Symbol.toStringTag,{value:"Module"})),T0=["_blank","_self","_top","_parent"],WE=["ascii","utf-8","utf-16","latin1","latin1"],YE=["get","post","put","delete"],GE=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Js=["true","false"],pt={},Mot={a:{attrs:{href:null,ping:null,type:null,media:null,target:T0,hreflang:null}},abbr:pt,address:pt,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:pt,aside:pt,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:pt,base:{attrs:{href:null,target:T0}},bdi:pt,bdo:pt,blockquote:{attrs:{cite:null}},body:pt,br:pt,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:GE,formmethod:YE,formnovalidate:["novalidate"],formtarget:T0,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:pt,center:pt,cite:pt,code:pt,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:pt,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:pt,div:pt,dl:pt,dt:pt,em:pt,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:pt,figure:pt,footer:pt,form:{attrs:{action:null,name:null,"accept-charset":WE,autocomplete:["on","off"],enctype:GE,method:YE,novalidate:["novalidate"],target:T0}},h1:pt,h2:pt,h3:pt,h4:pt,h5:pt,h6:pt,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:pt,hgroup:pt,hr:pt,html:{attrs:{manifest:null}},i:pt,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:GE,formmethod:YE,formnovalidate:["novalidate"],formtarget:T0,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:pt,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:pt,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:pt,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:WE,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:pt,noscript:pt,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:pt,param:{attrs:{name:null,value:null}},pre:pt,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:pt,rt:pt,ruby:pt,samp:pt,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:WE}},section:pt,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:pt,source:{attrs:{src:null,type:null,media:null}},span:pt,strong:pt,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:pt,summary:pt,sup:pt,table:pt,tbody:pt,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:pt,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:pt,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:pt,time:{attrs:{datetime:null}},title:pt,tr:pt,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:pt,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:pt},Qpe={accesskey:null,class:null,contenteditable:Js,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Js,autocorrect:Js,autocapitalize:Js,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Js,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Js,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Js,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Js,"aria-hidden":Js,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Js,"aria-multiselectable":Js,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Js,"aria-relevant":null,"aria-required":Js,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},Fpe="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(t=>"on"+t);for(let t of Fpe)Qpe[t]=null;let Iv=class{constructor(e,n){this.tags={...Mot,...e},this.globalAttrs={...Qpe,...n},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};Iv.default=new Iv;function d1(t,e,n=t.length){if(!e)return"";let r=e.firstChild,i=r&&r.getChild("TagName");return i?t.sliceString(i.from,Math.min(i.to,n)):""}function p1(t,e=!1){for(;t;t=t.parent)if(t.name=="Element")if(e)e=!1;else return t;return null}function Vpe(t,e,n){let r=n.tags[d1(t,p1(e))];return r?.children||n.allTags}function eI(t,e){let n=[];for(let r=p1(e);r&&!r.type.isTop;r=p1(r.parent)){let i=d1(t,r);if(i&&r.lastChild.name=="CloseTag")break;i&&n.indexOf(i)<0&&(e.name=="EndTag"||e.from>=r.firstChild.to)&&n.push(i)}return n}const Bpe=/^[:\-\.\w\u00b7-\uffff]*$/;function ZZ(t,e,n,r,i){let s=/\s*>/.test(t.sliceDoc(i,i+5))?"":">",a=p1(n,n.name=="StartTag"||n.name=="TagName");return{from:r,to:i,options:Vpe(t.doc,a,e).map(o=>({label:o,type:"type"})).concat(eI(t.doc,n).map((o,l)=>({label:"/"+o,apply:"/"+o+s,type:"type",boost:99-l}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function UZ(t,e,n,r){let i=/\s*>/.test(t.sliceDoc(r,r+5))?"":">";return{from:n,to:r,options:eI(t.doc,e).map((s,a)=>({label:s,apply:s+i,type:"type",boost:99-a})),validFor:Bpe}}function Rot(t,e,n,r){let i=[],s=0;for(let a of Vpe(t.doc,n,e))i.push({label:"<"+a,type:"type"});for(let a of eI(t.doc,n))i.push({label:"</"+a+">",type:"type",boost:99-s++});return{from:r,to:r,options:i,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function Iot(t,e,n,r,i){let s=p1(n),a=s?e.tags[d1(t.doc,s)]:null,o=a&&a.attrs?Object.keys(a.attrs):[],l=a&&a.globalAttrs===!1?o:o.length?o.concat(e.globalAttrNames):e.globalAttrNames;return{from:r,to:i,options:l.map(c=>({label:c,type:"property"})),validFor:Bpe}}function Not(t,e,n,r,i){var s;let a=(s=n.parent)===null||s===void 0?void 0:s.getChild("AttributeName"),o=[],l;if(a){let c=t.sliceDoc(a.from,a.to),h=e.globalAttrs[c];if(!h){let d=p1(n),m=d?e.tags[d1(t.doc,d)]:null;h=m?.attrs&&m.attrs[c]}if(h){let d=t.sliceDoc(r,i).toLowerCase(),m='"',g='"';/^['"]/.test(d)?(l=d[0]=='"'?/^[^"]*$/:/^[^']*$/,m="",g=t.sliceDoc(i,i+1)==d[0]?"":d[0],d=d.slice(1),r++):l=/^[^\s<>='"]*$/;for(let x of h)o.push({label:x,apply:m+x+g,type:"constant"})}}return{from:r,to:i,options:o,validFor:l}}function jpe(t,e){let{state:n,pos:r}=e,i=Fn(n).resolveInner(r,-1),s=i.resolve(r);for(let a=r,o;s==i&&(o=i.childBefore(a));){let l=o.lastChild;if(!l||!l.type.isError||l.from<l.to)break;s=i=o,a=l.from}return i.name=="TagName"?i.parent&&/CloseTag$/.test(i.parent.name)?UZ(n,i,i.from,r):ZZ(n,t,i,i.from,r):i.name=="StartTag"||i.name=="IncompleteTag"?ZZ(n,t,i,r,r):i.name=="StartCloseTag"||i.name=="IncompleteCloseTag"?UZ(n,i,r,r):i.name=="OpenTag"||i.name=="SelfClosingTag"||i.name=="AttributeName"?Iot(n,t,i,i.name=="AttributeName"?i.from:r,r):i.name=="Is"||i.name=="AttributeValue"||i.name=="UnquotedAttributeValue"?Not(n,t,i,i.name=="Is"?r:i.from,r):e.explicit&&(s.name=="Element"||s.name=="Text"||s.name=="Document")?Rot(n,t,i,r):null}function Hpe(t){return jpe(Iv.default,t)}function Zpe(t){let{extraTags:e,extraGlobalAttributes:n}=t,r=n||e?new Iv(e,n):Iv.default;return i=>jpe(r,i)}const $ot=Ya.parser.configure({top:"SingleExpression"}),Upe=[{tag:"script",attrs:t=>t.type=="text/typescript"||t.lang=="ts",parser:GR.parser},{tag:"script",attrs:t=>t.type=="text/babel"||t.type=="text/jsx",parser:KR.parser},{tag:"script",attrs:t=>t.type=="text/typescript-jsx",parser:JR.parser},{tag:"script",attrs(t){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(t.type)},parser:$ot},{tag:"script",attrs(t){return!t.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(t.type)},parser:Ya.parser},{tag:"style",attrs(t){return(!t.lang||t.lang=="css")&&(!t.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(t.type))},parser:Rv.parser}],qpe=[{name:"style",parser:Rv.parser.configure({top:"Styles"})}].concat(Fpe.map(t=>({name:t,parser:Ya.parser}))),Xpe=$d.define({name:"html",parser:Hat.configure({props:[ep.add({Element(t){let e=/^(\s*)(<\/)?/.exec(t.textAfter);return t.node.to<=t.pos+e[0].length?t.continue():t.lineIndent(t.node.from)+(e[2]?0:t.unit)},"OpenTag CloseTag SelfClosingTag"(t){return t.column(t.node.from)+t.unit},Document(t){if(t.pos+/\s*/.exec(t.textAfter)[0].length<t.node.to)return t.continue();let e=null,n;for(let r=t.node;;){let i=r.lastChild;if(!i||i.name!="Element"||i.to!=r.to)break;e=r=i}return e&&!((n=e.lastChild)&&(n.name=="CloseTag"||n.name=="SelfClosingTag"))?t.lineIndent(e.from)+t.unit:null}}),tp.add({Element(t){let e=t.firstChild,n=t.lastChild;return!e||e.name!="OpenTag"?null:{from:e.to,to:n.name=="CloseTag"?n.from:t.to}}}),fde.add({"OpenTag CloseTag":t=>t.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),T2=Xpe.configure({wrap:Cpe(Upe,qpe)});function Wpe(t={}){let e="",n;t.matchClosingTags===!1&&(e="noMatch"),t.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(t.nestedLanguages&&t.nestedLanguages.length||t.nestedAttributes&&t.nestedAttributes.length)&&(n=Cpe((t.nestedLanguages||[]).concat(Upe),(t.nestedAttributes||[]).concat(qpe)));let r=n?Xpe.configure({wrap:n,dialect:e}):e?T2.configure({dialect:e}):T2;return new zd(r,[T2.data.of({autocomplete:Zpe(t)}),t.autoCloseTags!==!1?Ype:[],zpe().support,vpe().support])}const qZ=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),Ype=Ze.inputHandler.of((t,e,n,r,i)=>{if(t.composing||t.state.readOnly||e!=n||r!=">"&&r!="/"||!T2.isActiveAt(t.state,e,-1))return!1;let s=i(),{state:a}=s,o=a.changeByRange(l=>{var c,h,d;let m=a.doc.sliceString(l.from-1,l.to)==r,{head:g}=l,x=Fn(a).resolveInner(g,-1),O;if(m&&r==">"&&x.name=="EndTag"){let w=x.parent;if(((h=(c=w.parent)===null||c===void 0?void 0:c.lastChild)===null||h===void 0?void 0:h.name)!="CloseTag"&&(O=d1(a.doc,w.parent,g))&&!qZ.has(O)){let E=g+(a.doc.sliceString(g,g+1)===">"?1:0),S=`</${O}>`;return{range:l,changes:{from:g,to:E,insert:S}}}}else if(m&&r=="/"&&x.name=="IncompleteCloseTag"){let w=x.parent;if(x.from==g-2&&((d=w.lastChild)===null||d===void 0?void 0:d.name)!="CloseTag"&&(O=d1(a.doc,w,g))&&!qZ.has(O)){let E=g+(a.doc.sliceString(g,g+1)===">"?1:0),S=`${O}>`;return{range:Ce.cursor(g+S.length,-1),changes:{from:g,to:E,insert:S}}}}return{range:l}});return o.changes.empty?!1:(t.dispatch([s,a.update(o,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),Lot=Object.freeze(Object.defineProperty({__proto__:null,autoCloseTags:Ype,html:Wpe,htmlCompletionSource:Hpe,htmlCompletionSourceWith:Zpe,htmlLanguage:T2},Symbol.toStringTag,{value:"Module"}));function zot(t,e,n,r){const i=cr(lr),s=Yt(iM),a=p.useRef(null),{lexicalNode:o}=Xk(),l=p.useRef(!1),c=p.useRef(!1),h=p.useCallback(()=>{s({editorType:e,rootNode:o,editorRef:a.current})},[e,o,s]),d=p.useCallback(m=>{var g,x,O,w,E,S;if(m.key==="ArrowDown"){const _=(x=(g=a.current)==null?void 0:g.getCodemirror())==null?void 0:x.state;if(_){const P=_.doc.length,A=_.selection.ranges[0].to;P===A&&(l.current?(i?.update(()=>{var k,I;const $=an(t);$.getNextSibling()?((I=(k=a.current)==null?void 0:k.getCodemirror())==null||I.contentDOM.blur(),$.selectNext()):$.insertAfter(Kt())}),l.current=!1):l.current=!0)}}else if(m.key==="ArrowUp"){const _=(w=(O=a.current)==null?void 0:O.getCodemirror())==null?void 0:w.state;_&&_.selection.ranges[0].from===0&&(c.current?(i?.update(()=>{var A,k;const I=an(t);I.getPreviousSibling()&&((k=(A=a.current)==null?void 0:A.getCodemirror())==null||k.contentDOM.blur(),I.selectPrevious())}),c.current=!1):c.current=!0)}else if(m.key==="Enter")m.stopPropagation();else if(m.key==="Backspace"||m.key==="Delete"){const _=(S=(E=a.current)==null?void 0:E.getCodemirror())==null?void 0:S.state;_?.doc.length===0&&i?.update(()=>{an(t).remove()})}},[i,t]);return p.useEffect(()=>{const m=a.current;return setTimeout(()=>{var g,x;(g=m?.getCodemirror())==null||g.contentDOM.addEventListener("focus",h),(x=m?.getCodemirror())==null||x.contentDOM.addEventListener("keydown",d)},300),()=>{var g,x;(g=m?.getCodemirror())==null||g.contentDOM.removeEventListener("focus",h),(x=m?.getCodemirror())==null||x.contentDOM.removeEventListener("keydown",d)}},[a,h,d,n]),p.useEffect(()=>{r.subscribe(()=>{var m,g;(g=(m=a.current)==null?void 0:m.getCodemirror())==null||g.focus(),h()})},[r,a,t,h]),a}function De(t){return new zd(PR.define(t))}function Ju(t){return _e(()=>import("./index-DizxtYKi.js"),[]).then(e=>e.sql({dialect:e[t]}))}const Gpe=[we.of({name:"C",extensions:["c","h","ino"],load(){return _e(()=>import("./index-CYE1F8io.js"),[]).then(t=>t.cpp())}}),we.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return _e(()=>import("./index-CYE1F8io.js"),[]).then(t=>t.cpp())}}),we.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Ju("Cassandra")}}),we.of({name:"CSS",extensions:["css"],load(){return _e(()=>Promise.resolve().then(()=>aat),void 0).then(t=>t.css())}}),we.of({name:"Go",extensions:["go"],load(){return _e(()=>import("./index-_dNFOYm2.js"),[]).then(t=>t.go())}}),we.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return _e(()=>Promise.resolve().then(()=>Lot),void 0).then(t=>t.html())}}),we.of({name:"Java",extensions:["java"],load(){return _e(()=>import("./index-QanI40bh.js"),[]).then(t=>t.java())}}),we.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return _e(()=>Promise.resolve().then(()=>cO),void 0).then(t=>t.javascript())}}),we.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load(){return _e(()=>import("./index-DOj3riRn.js"),[]).then(t=>t.jinja())}}),we.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return _e(()=>import("./index-q0t8g2gT.js"),[]).then(t=>t.json())}}),we.of({name:"JSX",extensions:["jsx"],load(){return _e(()=>Promise.resolve().then(()=>cO),void 0).then(t=>t.javascript({jsx:!0}))}}),we.of({name:"LESS",extensions:["less"],load(){return _e(()=>import("./index-q9XyrmEJ.js"),[]).then(t=>t.less())}}),we.of({name:"Liquid",extensions:["liquid"],load(){return _e(()=>import("./index-BkfBVCds.js"),[]).then(t=>t.liquid())}}),we.of({name:"MariaDB SQL",load(){return Ju("MariaSQL")}}),we.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return _e(()=>Promise.resolve().then(()=>Kct),void 0).then(t=>t.markdown())}}),we.of({name:"MS SQL",load(){return Ju("MSSQL")}}),we.of({name:"MySQL",load(){return Ju("MySQL")}}),we.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return _e(()=>import("./index-C-FkFQiR.js"),[]).then(t=>t.php())}}),we.of({name:"PLSQL",extensions:["pls"],load(){return Ju("PLSQL")}}),we.of({name:"PostgreSQL",load(){return Ju("PostgreSQL")}}),we.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return _e(()=>import("./index-AcL57xZ_.js"),[]).then(t=>t.python())}}),we.of({name:"Rust",extensions:["rs"],load(){return _e(()=>import("./index-Cc1XfOk5.js"),[]).then(t=>t.rust())}}),we.of({name:"Sass",extensions:["sass"],load(){return _e(()=>import("./index-DYLQOWH5.js"),[]).then(t=>t.sass({indented:!0}))}}),we.of({name:"SCSS",extensions:["scss"],load(){return _e(()=>import("./index-DYLQOWH5.js"),[]).then(t=>t.sass())}}),we.of({name:"SQL",extensions:["sql"],load(){return Ju("StandardSQL")}}),we.of({name:"SQLite",load(){return Ju("SQLite")}}),we.of({name:"TSX",extensions:["tsx"],load(){return _e(()=>Promise.resolve().then(()=>cO),void 0).then(t=>t.javascript({jsx:!0,typescript:!0}))}}),we.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return _e(()=>Promise.resolve().then(()=>cO),void 0).then(t=>t.javascript({typescript:!0}))}}),we.of({name:"WebAssembly",extensions:["wat","wast"],load(){return _e(()=>import("./index-xUvntAv0.js"),[]).then(t=>t.wast())}}),we.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return _e(()=>import("./index-T_P_b0mL.js"),[]).then(t=>t.xml())}}),we.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return _e(()=>import("./index-UyGAnl2N.js"),[]).then(t=>t.yaml())}}),we.of({name:"APL",extensions:["dyalog","apl"],load(){return _e(()=>import("./apl-B4CMkyY2.js"),[]).then(t=>De(t.apl))}}),we.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return _e(()=>import("./asciiarmor-Df11BRmG.js"),[]).then(t=>De(t.asciiArmor))}}),we.of({name:"ASN.1",extensions:["asn","asn1"],load(){return _e(()=>import("./asn1-EdZsLKOL.js"),[]).then(t=>De(t.asn1({})))}}),we.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return _e(()=>import("./asterisk-B-8jnY81.js"),[]).then(t=>De(t.asterisk))}}),we.of({name:"Brainfuck",extensions:["b","bf"],load(){return _e(()=>import("./brainfuck-C4LP7Hcl.js"),[]).then(t=>De(t.brainfuck))}}),we.of({name:"Cobol",extensions:["cob","cpy"],load(){return _e(()=>import("./cobol-CWcv1MsR.js"),[]).then(t=>De(t.cobol))}}),we.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return _e(()=>import("./clike-B9uivgTg.js"),[]).then(t=>De(t.csharp))}}),we.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return _e(()=>import("./clojure-BMjYHr_A.js"),[]).then(t=>De(t.clojure))}}),we.of({name:"ClojureScript",extensions:["cljs"],load(){return _e(()=>import("./clojure-BMjYHr_A.js"),[]).then(t=>De(t.clojure))}}),we.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return _e(()=>import("./css-BnMrqG3P.js"),[]).then(t=>De(t.gss))}}),we.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return _e(()=>import("./cmake-BQqOBYOt.js"),[]).then(t=>De(t.cmake))}}),we.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return _e(()=>import("./coffeescript-S37ZYGWr.js"),[]).then(t=>De(t.coffeeScript))}}),we.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return _e(()=>import("./commonlisp-DBKNyK5s.js"),[]).then(t=>De(t.commonLisp))}}),we.of({name:"Cypher",extensions:["cyp","cypher"],load(){return _e(()=>import("./cypher-C_CwsFkJ.js"),[]).then(t=>De(t.cypher))}}),we.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return _e(()=>import("./python-BuPzkPfP.js"),[]).then(t=>De(t.cython))}}),we.of({name:"Crystal",extensions:["cr"],load(){return _e(()=>import("./crystal-SjHAIU92.js"),[]).then(t=>De(t.crystal))}}),we.of({name:"D",extensions:["d"],load(){return _e(()=>import("./d-pRatUO7H.js"),[]).then(t=>De(t.d))}}),we.of({name:"Dart",extensions:["dart"],load(){return _e(()=>import("./clike-B9uivgTg.js"),[]).then(t=>De(t.dart))}}),we.of({name:"diff",extensions:["diff","patch"],load(){return _e(()=>import("./diff-DbItnlRl.js"),[]).then(t=>De(t.diff))}}),we.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return _e(()=>import("./dockerfile-BKs6k2Af.js"),__vite__mapDeps([0,1])).then(t=>De(t.dockerFile))}}),we.of({name:"DTD",extensions:["dtd"],load(){return _e(()=>import("./dtd-DF_7sFjM.js"),[]).then(t=>De(t.dtd))}}),we.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return _e(()=>import("./dylan-DwRh75JA.js"),[]).then(t=>De(t.dylan))}}),we.of({name:"EBNF",load(){return _e(()=>import("./ebnf-CDyGwa7X.js"),[]).then(t=>De(t.ebnf))}}),we.of({name:"ECL",extensions:["ecl"],load(){return _e(()=>import("./ecl-Cabwm37j.js"),[]).then(t=>De(t.ecl))}}),we.of({name:"edn",extensions:["edn"],load(){return _e(()=>import("./clojure-BMjYHr_A.js"),[]).then(t=>De(t.clojure))}}),we.of({name:"Eiffel",extensions:["e"],load(){return _e(()=>import("./eiffel-CnydiIhH.js"),[]).then(t=>De(t.eiffel))}}),we.of({name:"Elm",extensions:["elm"],load(){return _e(()=>import("./elm-vLlmbW-K.js"),[]).then(t=>De(t.elm))}}),we.of({name:"Erlang",extensions:["erl"],load(){return _e(()=>import("./erlang-BNw1qcRV.js"),[]).then(t=>De(t.erlang))}}),we.of({name:"Esper",load(){return _e(()=>import("./sql-D0XecflT.js"),[]).then(t=>De(t.esper))}}),we.of({name:"Factor",extensions:["factor"],load(){return _e(()=>import("./factor-kuTfRLto.js"),__vite__mapDeps([2,1])).then(t=>De(t.factor))}}),we.of({name:"FCL",load(){return _e(()=>import("./fcl-Kvtd6kyn.js"),[]).then(t=>De(t.fcl))}}),we.of({name:"Forth",extensions:["forth","fth","4th"],load(){return _e(()=>import("./forth-Ffai-XNe.js"),[]).then(t=>De(t.forth))}}),we.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return _e(()=>import("./fortran-DYz_wnZ1.js"),[]).then(t=>De(t.fortran))}}),we.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return _e(()=>import("./mllike-CXdrOF99.js"),[]).then(t=>De(t.fSharp))}}),we.of({name:"Gas",extensions:["s"],load(){return _e(()=>import("./gas-Bneqetm1.js"),[]).then(t=>De(t.gas))}}),we.of({name:"Gherkin",extensions:["feature"],load(){return _e(()=>import("./gherkin-heZmZLOM.js"),[]).then(t=>De(t.gherkin))}}),we.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return _e(()=>import("./groovy-D9Dt4D0W.js"),[]).then(t=>De(t.groovy))}}),we.of({name:"Haskell",extensions:["hs"],load(){return _e(()=>import("./haskell-Cw1EW3IL.js"),[]).then(t=>De(t.haskell))}}),we.of({name:"Haxe",extensions:["hx"],load(){return _e(()=>import("./haxe-H-WmDvRZ.js"),[]).then(t=>De(t.haxe))}}),we.of({name:"HXML",extensions:["hxml"],load(){return _e(()=>import("./haxe-H-WmDvRZ.js"),[]).then(t=>De(t.hxml))}}),we.of({name:"HTTP",load(){return _e(()=>import("./http-DBlCnlav.js"),[]).then(t=>De(t.http))}}),we.of({name:"IDL",extensions:["pro"],load(){return _e(()=>import("./idl-BEugSyMb.js"),[]).then(t=>De(t.idl))}}),we.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return _e(()=>import("./javascript-iXu5QeM3.js"),[]).then(t=>De(t.jsonld))}}),we.of({name:"Julia",extensions:["jl"],load(){return _e(()=>import("./julia-DuME0IfC.js"),[]).then(t=>De(t.julia))}}),we.of({name:"Kotlin",extensions:["kt","kts"],load(){return _e(()=>import("./clike-B9uivgTg.js"),[]).then(t=>De(t.kotlin))}}),we.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return _e(()=>import("./livescript-BwQOo05w.js"),[]).then(t=>De(t.liveScript))}}),we.of({name:"Lua",extensions:["lua"],load(){return _e(()=>import("./lua-BgMRiT3U.js"),[]).then(t=>De(t.lua))}}),we.of({name:"mIRC",extensions:["mrc"],load(){return _e(()=>import("./mirc-CjQqDB4T.js"),[]).then(t=>De(t.mirc))}}),we.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return _e(()=>import("./mathematica-DTrFuWx2.js"),[]).then(t=>De(t.mathematica))}}),we.of({name:"Modelica",extensions:["mo"],load(){return _e(()=>import("./modelica-Dc1JOy9r.js"),[]).then(t=>De(t.modelica))}}),we.of({name:"MUMPS",extensions:["mps"],load(){return _e(()=>import("./mumps-BT43cFF4.js"),[]).then(t=>De(t.mumps))}}),we.of({name:"Mbox",extensions:["mbox"],load(){return _e(()=>import("./mbox-CNhZ1qSd.js"),[]).then(t=>De(t.mbox))}}),we.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return _e(()=>import("./nginx-DdIZxoE0.js"),[]).then(t=>De(t.nginx))}}),we.of({name:"NSIS",extensions:["nsh","nsi"],load(){return _e(()=>import("./nsis-LdVXkNf5.js"),__vite__mapDeps([3,1])).then(t=>De(t.nsis))}}),we.of({name:"NTriples",extensions:["nt","nq"],load(){return _e(()=>import("./ntriples-BfvgReVJ.js"),[]).then(t=>De(t.ntriples))}}),we.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return _e(()=>import("./clike-B9uivgTg.js"),[]).then(t=>De(t.objectiveC))}}),we.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return _e(()=>import("./clike-B9uivgTg.js"),[]).then(t=>De(t.objectiveCpp))}}),we.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return _e(()=>import("./mllike-CXdrOF99.js"),[]).then(t=>De(t.oCaml))}}),we.of({name:"Octave",extensions:["m"],load(){return _e(()=>import("./octave-Ck1zUtKM.js"),[]).then(t=>De(t.octave))}}),we.of({name:"Oz",extensions:["oz"],load(){return _e(()=>import("./oz-BzwKVEFT.js"),[]).then(t=>De(t.oz))}}),we.of({name:"Pascal",extensions:["p","pas"],load(){return _e(()=>import("./pascal--L3eBynH.js"),[]).then(t=>De(t.pascal))}}),we.of({name:"Perl",extensions:["pl","pm"],load(){return _e(()=>import("./perl-CdXCOZ3F.js"),[]).then(t=>De(t.perl))}}),we.of({name:"Pig",extensions:["pig"],load(){return _e(()=>import("./pig-CevX1Tat.js"),[]).then(t=>De(t.pig))}}),we.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return _e(()=>import("./powershell-CFHJl5sT.js"),[]).then(t=>De(t.powerShell))}}),we.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return _e(()=>import("./properties-C78fOPTZ.js"),[]).then(t=>De(t.properties))}}),we.of({name:"ProtoBuf",extensions:["proto"],load(){return _e(()=>import("./protobuf-ChK-085T.js"),[]).then(t=>De(t.protobuf))}}),we.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return _e(()=>import("./pug-DeIclll2.js"),__vite__mapDeps([4,5])).then(t=>De(t.pug))}}),we.of({name:"Puppet",extensions:["pp"],load(){return _e(()=>import("./puppet-DMA9R1ak.js"),[]).then(t=>De(t.puppet))}}),we.of({name:"Q",extensions:["q"],load(){return _e(()=>import("./q-pXgVlZs6.js"),[]).then(t=>De(t.q))}}),we.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return _e(()=>import("./r-B6wPVr8A.js"),[]).then(t=>De(t.r))}}),we.of({name:"RPM Changes",load(){return _e(()=>import("./rpm-CTu-6PCP.js"),[]).then(t=>De(t.rpmChanges))}}),we.of({name:"RPM Spec",extensions:["spec"],load(){return _e(()=>import("./rpm-CTu-6PCP.js"),[]).then(t=>De(t.rpmSpec))}}),we.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return _e(()=>import("./ruby-B2Rjki9n.js"),[]).then(t=>De(t.ruby))}}),we.of({name:"SAS",extensions:["sas"],load(){return _e(()=>import("./sas-B4kiWyti.js"),[]).then(t=>De(t.sas))}}),we.of({name:"Scala",extensions:["scala"],load(){return _e(()=>import("./clike-B9uivgTg.js"),[]).then(t=>De(t.scala))}}),we.of({name:"Scheme",extensions:["scm","ss"],load(){return _e(()=>import("./scheme-C41bIUwD.js"),[]).then(t=>De(t.scheme))}}),we.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return _e(()=>import("./shell-CjFT_Tl9.js"),[]).then(t=>De(t.shell))}}),we.of({name:"Sieve",extensions:["siv","sieve"],load(){return _e(()=>import("./sieve-C3Gn_uJK.js"),[]).then(t=>De(t.sieve))}}),we.of({name:"Smalltalk",extensions:["st"],load(){return _e(()=>import("./smalltalk-CnHTOXQT.js"),[]).then(t=>De(t.smalltalk))}}),we.of({name:"Solr",load(){return _e(()=>import("./solr-DehyRSwq.js"),[]).then(t=>De(t.solr))}}),we.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return _e(()=>import("./mllike-CXdrOF99.js"),[]).then(t=>De(t.sml))}}),we.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return _e(()=>import("./sparql-DkYu6x3z.js"),[]).then(t=>De(t.sparql))}}),we.of({name:"Spreadsheet",alias:["excel","formula"],load(){return _e(()=>import("./spreadsheet-BCZA_wO0.js"),[]).then(t=>De(t.spreadsheet))}}),we.of({name:"Squirrel",extensions:["nut"],load(){return _e(()=>import("./clike-B9uivgTg.js"),[]).then(t=>De(t.squirrel))}}),we.of({name:"Stylus",extensions:["styl"],load(){return _e(()=>import("./stylus-B533Al4x.js"),[]).then(t=>De(t.stylus))}}),we.of({name:"Swift",extensions:["swift"],load(){return _e(()=>import("./swift-BzpIVaGY.js"),[]).then(t=>De(t.swift))}}),we.of({name:"sTeX",load(){return _e(()=>import("./stex-C3f8Ysf7.js"),[]).then(t=>De(t.stex))}}),we.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return _e(()=>import("./stex-C3f8Ysf7.js"),[]).then(t=>De(t.stex))}}),we.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return _e(()=>import("./verilog-C6RDOZhf.js"),[]).then(t=>De(t.verilog))}}),we.of({name:"Tcl",extensions:["tcl"],load(){return _e(()=>import("./tcl-DVfN8rqt.js"),[]).then(t=>De(t.tcl))}}),we.of({name:"Textile",extensions:["textile"],load(){return _e(()=>import("./textile-CnDTJFAw.js"),[]).then(t=>De(t.textile))}}),we.of({name:"TiddlyWiki",load(){return _e(()=>import("./tiddlywiki-DO-Gjzrf.js"),[]).then(t=>De(t.tiddlyWiki))}}),we.of({name:"Tiki wiki",load(){return _e(()=>import("./tiki-DGYXhP31.js"),[]).then(t=>De(t.tiki))}}),we.of({name:"TOML",extensions:["toml"],load(){return _e(()=>import("./toml-Bm5Em-hy.js"),[]).then(t=>De(t.toml))}}),we.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return _e(()=>import("./troff-wAsdV37c.js"),[]).then(t=>De(t.troff))}}),we.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return _e(()=>import("./ttcn-CfJYG6tj.js"),[]).then(t=>De(t.ttcn))}}),we.of({name:"TTCN_CFG",extensions:["cfg"],load(){return _e(()=>import("./ttcn-cfg-B9xdYoR4.js"),[]).then(t=>De(t.ttcnCfg))}}),we.of({name:"Turtle",extensions:["ttl"],load(){return _e(()=>import("./turtle-B1tBg_DP.js"),[]).then(t=>De(t.turtle))}}),we.of({name:"Web IDL",extensions:["webidl"],load(){return _e(()=>import("./webidl-ZXfAyPTL.js"),[]).then(t=>De(t.webIDL))}}),we.of({name:"VB.NET",extensions:["vb"],load(){return _e(()=>import("./vb-CmGdzxic.js"),[]).then(t=>De(t.vb))}}),we.of({name:"VBScript",extensions:["vbs"],load(){return _e(()=>import("./vbscript-BuJXcnF6.js"),[]).then(t=>De(t.vbScript))}}),we.of({name:"Velocity",extensions:["vtl"],load(){return _e(()=>import("./velocity-D8B20fx6.js"),[]).then(t=>De(t.velocity))}}),we.of({name:"Verilog",extensions:["v"],load(){return _e(()=>import("./verilog-C6RDOZhf.js"),[]).then(t=>De(t.verilog))}}),we.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return _e(()=>import("./vhdl-lSbBsy5d.js"),[]).then(t=>De(t.vhdl))}}),we.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load(){return _e(()=>import("./xquery-DzFWVndE.js"),[]).then(t=>De(t.xQuery))}}),we.of({name:"Yacas",extensions:["ys"],load(){return _e(()=>import("./yacas-BJ4BC0dw.js"),[]).then(t=>De(t.yacas))}}),we.of({name:"Z80",extensions:["z80"],load(){return _e(()=>import("./z80-Hz9HOZM7.js"),[]).then(t=>De(t.z80))}}),we.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return _e(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(t=>De(t.mscgen))}}),we.of({name:"Xù",extensions:["xu"],load(){return _e(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(t=>De(t.xu))}}),we.of({name:"MsGenny",extensions:["msgenny"],load(){return _e(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(t=>De(t.msgenny))}}),we.of({name:"Vue",extensions:["vue"],load(){return _e(()=>import("./index-CzHG20cy.js"),[]).then(t=>t.vue())}}),we.of({name:"Angular Template",load(){return _e(()=>import("./index-ZE3ch6VY.js"),[]).then(t=>t.angular())}})],XZ="#2e3440",tI="#3b4252",WZ="#434c5e",uO="#4c566a",YZ="#e5e9f0",ZC="#eceff4",KE="#8fbcbb",GZ="#88c0d0",Dot="#81a1c1",So="#5e81ac",Qot="#bf616a",Wp="#d08770",JE="#ebcb8b",KZ="#a3be8c",Fot="#b48ead",JZ="#d30102",nI=ZC,e_=nI,Vot="#ffffff",t_=tI,Bot=nI,eU=tI,jot=Ze.theme({"&":{color:XZ,backgroundColor:Vot},".cm-content":{caretColor:eU},".cm-cursor, .cm-dropCursor":{borderLeftColor:eU},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Bot},".cm-panels":{backgroundColor:nI,color:uO},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:`1px solid ${uO}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:YZ},".cm-activeLine":{backgroundColor:e_},".cm-selectionMatch":{backgroundColor:YZ},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${uO}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:ZC},".cm-gutters":{backgroundColor:ZC,color:XZ,border:"none"},".cm-activeLineGutter":{backgroundColor:e_},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:t_},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:t_,borderBottomColor:t_},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:e_,color:uO}}},{dark:!1}),Hot=zy.define([{tag:Y.keyword,color:So},{tag:[Y.name,Y.deleted,Y.character,Y.propertyName,Y.macroName],color:Wp},{tag:[Y.variableName],color:Wp},{tag:[Y.function(Y.variableName)],color:So},{tag:[Y.labelName],color:Dot},{tag:[Y.color,Y.constant(Y.name),Y.standard(Y.name)],color:So},{tag:[Y.definition(Y.name),Y.separator],color:KZ},{tag:[Y.brace],color:KE},{tag:[Y.annotation],color:JZ},{tag:[Y.number,Y.changed,Y.annotation,Y.modifier,Y.self,Y.namespace],color:GZ},{tag:[Y.typeName,Y.className],color:JE},{tag:[Y.operator,Y.operatorKeyword],color:KZ},{tag:[Y.tagName],color:Fot},{tag:[Y.squareBracket],color:Qot},{tag:[Y.angleBracket],color:Wp},{tag:[Y.attributeName],color:JE},{tag:[Y.regexp],color:So},{tag:[Y.quote],color:tI},{tag:[Y.string],color:Wp},{tag:Y.link,color:KE,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[Y.url,Y.escape,Y.special(Y.string)],color:Wp},{tag:[Y.meta],color:GZ},{tag:[Y.comment],color:WZ,fontStyle:"italic"},{tag:Y.strong,fontWeight:"bold",color:So},{tag:Y.emphasis,fontStyle:"italic",color:So},{tag:Y.strikethrough,textDecoration:"line-through"},{tag:Y.heading,fontWeight:"bold",color:So},{tag:Y.special(Y.heading1),fontWeight:"bold",color:So},{tag:Y.heading1,fontWeight:"bold",color:So},{tag:[Y.heading2,Y.heading3,Y.heading4],fontWeight:"bold",color:So},{tag:[Y.heading5,Y.heading6],color:So},{tag:[Y.atom,Y.bool,Y.special(Y.variableName)],color:Wp},{tag:[Y.processingInstruction,Y.inserted],color:KE},{tag:[Y.contentSeparator],color:JE},{tag:Y.invalid,color:WZ,borderBottom:`1px dotted ${JZ}`}]),Kpe=[jot,lde(Hot)],tU=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class m1{constructor(e,n,r=0,i=e.length,s,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(r,i),this.bufferStart=r,this.normalize=s?o=>s(tU(o)):tU,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Rs(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let n=iR(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=_l(e);let i=this.normalize(n);if(i.length)for(let s=0,a=r;;s++){let o=i.charCodeAt(s),l=this.match(o,a,this.bufferPos+this.bufferStart);if(s==i.length-1){if(l)return this.value=l,this;break}a==r&&s<n.length&&n.charCodeAt(s)==o&&a++}}}match(e,n,r){let i=null;for(let s=0;s<this.matches.length;s+=2){let a=this.matches[s],o=!1;this.query.charCodeAt(a)==e&&(a==this.query.length-1?i={from:this.matches[s+1],to:r}:(this.matches[s]++,o=!0)),o||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:n,to:r}:this.matches.push(1,n)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}typeof Symbol<"u"&&(m1.prototype[Symbol.iterator]=function(){return this});const Jpe={from:-1,to:-1,match:/.*/.exec("")},rI="gm"+(/x/.unicode==null?"":"u");class eme{constructor(e,n,r,i=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=Jpe,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new tme(e,n,r,i,s);this.re=new RegExp(n,rI+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=e.iter();let a=e.lineAt(i);this.curLineStart=a.from,this.matchPos=i4(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,i=r+n[0].length;if(this.matchPos=i4(this.text,i+(r==i?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<i||r>this.value.to)&&(!this.test||this.test(r,i,n)))return this.value={from:r,to:i,match:n},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const n_=new WeakMap;class zm{constructor(e,n){this.from=e,this.text=n}get to(){return this.from+this.text.length}static get(e,n,r){let i=n_.get(e);if(!i||i.from>=r||i.to<=n){let o=new zm(n,e.sliceString(n,r));return n_.set(e,o),o}if(i.from==n&&i.to==r)return i;let{text:s,from:a}=i;return a>n&&(s=e.sliceString(n,a)+s,a=n),i.to<r&&(s+=e.sliceString(i.to,r)),n_.set(e,new zm(a,s)),new zm(n,s.slice(n-a,r-a))}}class tme{constructor(e,n,r,i,s){this.text=e,this.to=s,this.done=!1,this.value=Jpe,this.matchPos=i4(e,i),this.re=new RegExp(n,rI+(r?.ignoreCase?"i":"")),this.test=r?.test,this.flat=zm.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==e&&(this.re.lastIndex=e+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,i=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,i,n)))return this.value={from:r,to:i,match:n},this.matchPos=i4(this.text,i+(r==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=zm.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(eme.prototype[Symbol.iterator]=tme.prototype[Symbol.iterator]=function(){return this});function Zot(t){try{return new RegExp(t,rI),!0}catch{return!1}}function i4(t,e){if(e>=t.length)return e;let n=t.lineAt(e),r;for(;e<n.to&&(r=n.text.charCodeAt(e-n.from))>=56320&&r<57344;)e++;return e}const Uot=t=>{let{state:e}=t,n=String(e.doc.lineAt(t.state.selection.main.head).number),{close:r,result:i}=Ftt(t,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:e.phrase("go")});return i.then(s=>{let a=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!a){t.dispatch({effects:r});return}let o=e.doc.lineAt(e.selection.main.head),[,l,c,h,d]=a,m=h?+h.slice(1):0,g=c?+c:o.number;if(c&&d){let w=g/100;l&&(w=w*(l=="-"?-1:1)+o.number/e.doc.lines),g=Math.round(e.doc.lines*w)}else c&&l&&(g=g*(l=="-"?-1:1)+o.number);let x=e.doc.line(Math.max(1,Math.min(e.doc.lines,g))),O=Ce.cursor(x.from+Math.max(0,Math.min(m,x.length)));t.dispatch({effects:[r,Ze.scrollIntoView(O.from,{y:"center"})],selection:O})}),!0},qot={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Xot=tt.define({combine(t){return rc(t,qot,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function Wot(t){return[elt,Jot]}const Yot=lt.mark({class:"cm-selectionMatch"}),Got=lt.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function nU(t,e,n,r){return(n==0||t(e.sliceDoc(n-1,n))!=vr.Word)&&(r==e.doc.length||t(e.sliceDoc(r,r+1))!=vr.Word)}function Kot(t,e,n,r){return t(e.sliceDoc(n,n+1))==vr.Word&&t(e.sliceDoc(r-1,r))==vr.Word}const Jot=Nr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(Xot),{state:n}=t,r=n.selection;if(r.ranges.length>1)return lt.none;let i=r.main,s,a=null;if(i.empty){if(!e.highlightWordAroundCursor)return lt.none;let l=n.wordAt(i.head);if(!l)return lt.none;a=n.charCategorizer(i.head),s=n.sliceDoc(l.from,l.to)}else{let l=i.to-i.from;if(l<e.minSelectionLength||l>200)return lt.none;if(e.wholeWords){if(s=n.sliceDoc(i.from,i.to),a=n.charCategorizer(i.head),!(nU(a,n,i.from,i.to)&&Kot(a,n,i.from,i.to)))return lt.none}else if(s=n.sliceDoc(i.from,i.to),!s)return lt.none}let o=[];for(let l of t.visibleRanges){let c=new m1(n.doc,s,l.from,l.to);for(;!c.next().done;){let{from:h,to:d}=c.value;if((!a||nU(a,n,h,d))&&(i.empty&&h<=i.from&&d>=i.to?o.push(Got.range(h,d)):(h>=i.to||d<=i.from)&&o.push(Yot.range(h,d)),o.length>e.maxMatches))return lt.none}}return lt.set(o)}},{decorations:t=>t.decorations}),elt=Ze.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),tlt=({state:t,dispatch:e})=>{let{selection:n}=t,r=Ce.create(n.ranges.map(i=>t.wordAt(i.head)||Ce.cursor(i.head)),n.mainIndex);return r.eq(n)?!1:(e(t.update({selection:r})),!0)};function nlt(t,e){let{main:n,ranges:r}=t.selection,i=t.wordAt(n.head),s=i&&i.from==n.from&&i.to==n.to;for(let a=!1,o=new m1(t.doc,e,r[r.length-1].to);;)if(o.next(),o.done){if(a)return null;o=new m1(t.doc,e,0,Math.max(0,r[r.length-1].from-1)),a=!0}else{if(a&&r.some(l=>l.from==o.value.from))continue;if(s){let l=t.wordAt(o.value.from);if(!l||l.from!=o.value.from||l.to!=o.value.to)continue}return o.value}}const rlt=({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(s=>s.from===s.to))return tlt({state:t,dispatch:e});let r=t.sliceDoc(n[0].from,n[0].to);if(t.selection.ranges.some(s=>t.sliceDoc(s.from,s.to)!=r))return!1;let i=nlt(t,r);return i?(e(t.update({selection:t.selection.addRange(Ce.range(i.from,i.to),!1),effects:Ze.scrollIntoView(i.to)})),!0):!1},og=tt.define({combine(t){return rc(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new vlt(e),scrollToMatch:e=>Ze.scrollIntoView(e)})}});class nme{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Zot(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(n,r)=>r=="n"?`
306
306
  `:r=="r"?"\r":r=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new clt(this):new alt(this)}getCursor(e,n=0,r){let i=e.doc?e:Dt.create({doc:e});return r==null&&(r=i.doc.length),this.regexp?am(this,i,n,r):sm(this,i,n,r)}}class rme{constructor(e){this.spec=e}}function ilt(t,e,n){return(r,i,s,a)=>{if(n&&!n(r,i,s,a))return!1;let o=r>=a&&i<=a+s.length?s.slice(r-a,i-a):e.doc.sliceString(r,i);return t(o,e,r,i)}}function sm(t,e,n,r){let i;return t.wholeWord&&(i=slt(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(i=ilt(t.test,e,i)),new m1(e.doc,t.unquoted,n,r,t.caseSensitive?void 0:s=>s.toLowerCase(),i)}function slt(t,e){return(n,r,i,s)=>((s>n||s+i.length<r)&&(s=Math.max(0,n-2),i=t.sliceString(s,Math.min(t.length,r+2))),(e(s4(i,n-s))!=vr.Word||e(a4(i,n-s))!=vr.Word)&&(e(a4(i,r-s))!=vr.Word||e(s4(i,r-s))!=vr.Word))}class alt extends rme{constructor(e){super(e)}nextMatch(e,n,r){let i=sm(this.spec,e,r,e.doc.length).nextOverlapping();if(i.done){let s=Math.min(e.doc.length,n+this.spec.unquoted.length);i=sm(this.spec,e,0,s).nextOverlapping()}return i.done||i.value.from==n&&i.value.to==r?null:i.value}prevMatchInRange(e,n,r){for(let i=r;;){let s=Math.max(n,i-1e4-this.spec.unquoted.length),a=sm(this.spec,e,s,i),o=null;for(;!a.nextOverlapping().done;)o=a.value;if(o)return o;if(s==n)return null;i-=1e4}}prevMatch(e,n,r){let i=this.prevMatchInRange(e,0,n);return i||(i=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=n||i.to!=r)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let r=sm(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=n)return null;i.push(r.value)}return i}highlight(e,n,r,i){let s=sm(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}function olt(t,e,n){return(r,i,s)=>(!n||n(r,i,s))&&t(s[0],e,r,i)}function am(t,e,n,r){let i;return t.wholeWord&&(i=llt(e.charCategorizer(e.selection.main.head))),t.test&&(i=olt(t.test,e,i)),new eme(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:i},n,r)}function s4(t,e){return t.slice(Ei(t,e,!1),e)}function a4(t,e){return t.slice(e,Ei(t,e))}function llt(t){return(e,n,r)=>!r[0].length||(t(s4(r.input,r.index))!=vr.Word||t(a4(r.input,r.index))!=vr.Word)&&(t(a4(r.input,r.index+r[0].length))!=vr.Word||t(s4(r.input,r.index+r[0].length))!=vr.Word)}class clt extends rme{nextMatch(e,n,r){let i=am(this.spec,e,r,e.doc.length).next();return i.done&&(i=am(this.spec,e,0,n).next()),i.done?null:i.value}prevMatchInRange(e,n,r){for(let i=1;;i++){let s=Math.max(n,r-i*1e4),a=am(this.spec,e,s,r),o=null;for(;!a.next().done;)o=a.value;if(o&&(s==n||o.from>s+10))return o;if(s==n)return null}}prevMatch(e,n,r){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return e.match[0];if(r=="$")return"$";for(let i=r.length;i>0;i--){let s=+r.slice(0,i);if(s>0&&s<e.match.length)return e.match[s]+r.slice(i)}return n})}matchAll(e,n){let r=am(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=n)return null;i.push(r.value)}return i}highlight(e,n,r,i){let s=am(this.spec,e,Math.max(0,n-250),Math.min(r+250,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}const Nv=Et.define(),iI=Et.define(),Eh=hi.define({create(t){return new r_(UC(t).create(),null)},update(t,e){for(let n of e.effects)n.is(Nv)?t=new r_(n.value.create(),t.panel):n.is(iI)&&(t=new r_(t.query,n.value?sI:null));return t},provide:t=>Sv.from(t,e=>e.panel)});class r_{constructor(e,n){this.query=e,this.panel=n}}const ult=lt.mark({class:"cm-searchMatch"}),hlt=lt.mark({class:"cm-searchMatch cm-searchMatch-selected"}),flt=Nr.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Eh))}update(t){let e=t.state.field(Eh);(e!=t.startState.field(Eh)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return lt.none;let{view:n}=this,r=new Vs;for(let i=0,s=n.visibleRanges,a=s.length;i<a;i++){let{from:o,to:l}=s[i];for(;i<a-1&&l>s[i+1].from-500;)l=s[++i].to;t.highlight(n.state,o,l,(c,h)=>{let d=n.state.selection.ranges.some(m=>m.from==c&&m.to==h);r.add(c,h,d?hlt:ult)})}return r.finish()}},{decorations:t=>t.decorations});function Fy(t){return e=>{let n=e.state.field(Eh,!1);return n&&n.query.spec.valid?t(e,n):ame(e)}}const o4=Fy((t,{query:e})=>{let{to:n}=t.state.selection.main,r=e.nextMatch(t.state,n,n);if(!r)return!1;let i=Ce.single(r.from,r.to),s=t.state.facet(og);return t.dispatch({selection:i,effects:[aI(t,r),s.scrollToMatch(i.main,t)],userEvent:"select.search"}),sme(t),!0}),l4=Fy((t,{query:e})=>{let{state:n}=t,{from:r}=n.selection.main,i=e.prevMatch(n,r,r);if(!i)return!1;let s=Ce.single(i.from,i.to),a=t.state.facet(og);return t.dispatch({selection:s,effects:[aI(t,i),a.scrollToMatch(s.main,t)],userEvent:"select.search"}),sme(t),!0}),dlt=Fy((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:Ce.create(n.map(r=>Ce.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),plt=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,s=[],a=0;for(let o=new m1(t.doc,t.sliceDoc(r,i));!o.next().done;){if(s.length>1e3)return!1;o.value.from==r&&(a=s.length),s.push(Ce.range(o.value.from,o.value.to))}return e(t.update({selection:Ce.create(s,a),userEvent:"select.search.matches"})),!0},rU=Fy((t,{query:e})=>{let{state:n}=t,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let s=e.nextMatch(n,r,r);if(!s)return!1;let a=s,o=[],l,c,h=[];a.from==r&&a.to==i&&(c=n.toText(e.getReplacement(a)),o.push({from:a.from,to:a.to,insert:c}),a=e.nextMatch(n,a.from,a.to),h.push(Ze.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+".")));let d=t.state.changes(o);return a&&(l=Ce.single(a.from,a.to).map(d),h.push(aI(t,a)),h.push(n.facet(og).scrollToMatch(l.main,t))),t.dispatch({changes:d,selection:l,effects:h,userEvent:"input.replace"}),!0}),mlt=Fy((t,{query:e})=>{if(t.state.readOnly)return!1;let n=e.matchAll(t.state,1e9).map(i=>{let{from:s,to:a}=i;return{from:s,to:a,insert:e.getReplacement(i)}});if(!n.length)return!1;let r=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:Ze.announce.of(r),userEvent:"input.replace.all"}),!0});function sI(t){return t.state.facet(og).createPanel(t)}function UC(t,e){var n,r,i,s,a;let o=t.selection.main,l=o.empty||o.to>o.from+100?"":t.sliceDoc(o.from,o.to);if(e&&!l)return e;let c=t.facet(og);return new nme({search:((n=e?.literal)!==null&&n!==void 0?n:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(r=e?.caseSensitive)!==null&&r!==void 0?r:c.caseSensitive,literal:(i=e?.literal)!==null&&i!==void 0?i:c.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:c.regexp,wholeWord:(a=e?.wholeWord)!==null&&a!==void 0?a:c.wholeWord})}function ime(t){let e=bR(t,sI);return e&&e.dom.querySelector("[main-field]")}function sme(t){let e=ime(t);e&&e==t.root.activeElement&&e.select()}const ame=t=>{let e=t.state.field(Eh,!1);if(e&&e.panel){let n=ime(t);if(n&&n!=t.root.activeElement){let r=UC(t.state,e.query.spec);r.valid&&t.dispatch({effects:Nv.of(r)}),n.focus(),n.select()}}else t.dispatch({effects:[iI.of(!0),e?Nv.of(UC(t.state,e.query.spec)):Et.appendConfig.of(xlt)]});return!0},ome=t=>{let e=t.state.field(Eh,!1);if(!e||!e.panel)return!1;let n=bR(t,sI);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:iI.of(!1)}),!0},glt=[{key:"Mod-f",run:ame,scope:"editor search-panel"},{key:"F3",run:o4,shift:l4,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:o4,shift:l4,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ome,scope:"editor search-panel"},{key:"Mod-Shift-l",run:plt},{key:"Mod-Alt-g",run:Uot},{key:"Mod-d",run:rlt,preventDefault:!0}];class vlt{constructor(e){this.view=e;let n=this.query=e.state.field(Eh).query.spec;this.commit=this.commit.bind(this),this.searchField=Dn("input",{value:n.search,placeholder:ea(e,"Find"),"aria-label":ea(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Dn("input",{value:n.replace,placeholder:ea(e,"Replace"),"aria-label":ea(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Dn("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=Dn("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=Dn("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(i,s,a){return Dn("button",{class:"cm-button",name:i,onclick:s,type:"button"},a)}this.dom=Dn("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,r("next",()=>o4(e),[ea(e,"next")]),r("prev",()=>l4(e),[ea(e,"previous")]),r("select",()=>dlt(e),[ea(e,"all")]),Dn("label",null,[this.caseField,ea(e,"match case")]),Dn("label",null,[this.reField,ea(e,"regexp")]),Dn("label",null,[this.wordField,ea(e,"by word")]),...e.state.readOnly?[]:[Dn("br"),this.replaceField,r("replace",()=>rU(e),[ea(e,"replace")]),r("replaceAll",()=>mlt(e),[ea(e,"replace all")])],Dn("button",{name:"close",onclick:()=>ome(e),"aria-label":ea(e,"close"),type:"button"},["×"])])}commit(){let e=new nme({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Nv.of(e)}))}keydown(e){Ket(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?l4:o4)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),rU(this.view))}update(e){for(let n of e.transactions)for(let r of n.effects)r.is(Nv)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(og).top}}function ea(t,e){return t.state.phrase(e)}const hO=30,fO=/[\s\.,:;?!]/;function aI(t,{from:e,to:n}){let r=t.state.doc.lineAt(e),i=t.state.doc.lineAt(n).to,s=Math.max(r.from,e-hO),a=Math.min(i,n+hO),o=t.state.sliceDoc(s,a);if(s!=r.from){for(let l=0;l<hO;l++)if(!fO.test(o[l+1])&&fO.test(o[l])){o=o.slice(l);break}}if(a!=i){for(let l=o.length-1;l>o.length-hO;l--)if(!fO.test(o[l-1])&&fO.test(o[l])){o=o.slice(0,l);break}}return Ze.announce.of(`${t.state.phrase("current match")}. ${o} ${t.state.phrase("on line")} ${r.number}.`)}const ylt=Ze.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),xlt=[Eh,il.low(flt),ylt];class iU{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class Ff{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=r.facet($v).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((g,x)=>g.from-x.from||g.to-x.to),a=new Vs,o=[],l=0,c=r.doc.iter(),h=0,d=r.doc.length;for(let g=0;;){let x=g==s.length?null:s[g];if(!x&&!o.length)break;let O,w;if(o.length)O=l,w=o.reduce((_,P)=>Math.min(_,P.to),x&&x.from>O?x.from:1e8);else{if(O=x.from,O>d)break;w=x.to,o.push(x),g++}for(;g<s.length;){let _=s[g];if(_.from==O&&(_.to>_.from||_.to==O))o.push(_),g++,w=Math.min(_.to,w);else{w=Math.min(_.from,w);break}}w=Math.min(w,d);let E=!1;if(o.some(_=>_.from==O&&(_.to==w||w==d))&&(E=O==w,!E&&w-O<10)){let _=O-(h+c.value.length);_>0&&(c.next(_),h=O);for(let P=O;;){if(P>=w){E=!0;break}if(!c.lineBreak&&h+c.value.length>P)break;P=h+c.value.length,h+=c.value.length,c.next()}}let S=Rlt(o);if(E)a.add(O,O,lt.widget({widget:new Tlt(S),diagnostics:o.slice()}));else{let _=o.reduce((P,A)=>A.markClass?P+" "+A.markClass:P,"");a.add(O,w,lt.mark({class:"cm-lintRange cm-lintRange-"+S+_,diagnostics:o.slice(),inclusiveEnd:o.some(P=>P.to>w)}))}if(l=w,l==d)break;for(let _=0;_<o.length;_++)o[_].to<=l&&o.splice(_--,1)}let m=a.finish();return new Ff(m,n,jh(m))}}function jh(t,e=null,n=0){let r=null;return t.between(n,1e9,(i,s,{spec:a})=>{if(!(e&&a.diagnostics.indexOf(e)<0))if(!r)r=new iU(i,s,e||a.diagnostics[0]);else{if(a.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new iU(r.from,s,r.diagnostic)}}),r}function Olt(t,e){let n=e.pos,r=e.end||n,i=t.state.facet($v).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(a=>a.is(lme))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function blt(t,e){return t.field(fa,!1)?e:e.concat(Et.appendConfig.of(Ilt))}const lme=Et.define(),oI=Et.define(),cme=Et.define(),fa=hi.define({create(){return new Ff(lt.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,i=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);r=jh(n,t.selected.diagnostic,s)||jh(n,null,s)}!n.size&&i&&e.state.facet($v).autoPanel&&(i=null),t=new Ff(n,i,r)}for(let n of e.effects)if(n.is(lme)){let r=e.state.facet($v).autoPanel?n.value.length?Lv.open:null:t.panel;t=Ff.init(n.value,r,e.state)}else n.is(oI)?t=new Ff(t.diagnostics,n.value?Lv.open:null,t.selected):n.is(cme)&&(t=new Ff(t.diagnostics,t.panel,n.value));return t},provide:t=>[Sv.from(t,e=>e.panel),Ze.decorations.from(t,e=>e.diagnostics)]}),wlt=lt.mark({class:"cm-lintRange cm-lintRange-active"});function Slt(t,e,n){let{diagnostics:r}=t.state.field(fa),i,s=-1,a=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(l,c,{spec:h})=>{if(e>=l&&e<=c&&(l==c||(e>l||n>0)&&(e<c||n<0)))return i=h.diagnostics,s=l,a=c,!1});let o=t.state.facet($v).tooltipFilter;return i&&o&&(i=o(i,t.state)),i?{pos:s,end:a,above:t.state.doc.lineAt(s).to<a,create(){return{dom:Elt(t,i)}}}:null}function Elt(t,e){return Dn("ul",{class:"cm-tooltip-lint"},e.map(n=>hme(t,n,!1)))}const _lt=t=>{let e=t.state.field(fa,!1);(!e||!e.panel)&&t.dispatch({effects:blt(t.state,[oI.of(!0)])});let n=bR(t,Lv.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},sU=t=>{let e=t.state.field(fa,!1);return!e||!e.panel?!1:(t.dispatch({effects:oI.of(!1)}),!0)},klt=t=>{let e=t.state.field(fa,!1);if(!e)return!1;let n=t.state.selection.main,r=jh(e.diagnostics,null,n.to+1);return!r&&(r=jh(e.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(t.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},Clt=[{key:"Mod-Shift-m",run:_lt,preventDefault:!0},{key:"F8",run:klt}],$v=tt.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...rc(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:aU,tooltipFilter:aU,needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n,hideOn:(e,n)=>e?n?(r,i,s)=>e(r,i,s)||n(r,i,s):e:n,autoPanel:(e,n)=>e||n})}}});function aU(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function ume(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;r<n.length;r++){let i=n[r];if(/[a-zA-Z]/.test(i)&&!e.some(s=>s.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function hme(t,e,n){var r;let i=n?ume(e.actions):[];return Dn("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Dn("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,a)=>{let o=!1,l=g=>{if(g.preventDefault(),o)return;o=!0;let x=jh(t.state.field(fa).diagnostics,e);x&&s.apply(t,x.from,x.to)},{name:c}=s,h=i[a]?c.indexOf(i[a]):-1,d=h<0?c:[c.slice(0,h),Dn("u",c.slice(h,h+1)),c.slice(h+1)],m=s.markClass?" "+s.markClass:"";return Dn("button",{type:"button",class:"cm-diagnosticAction"+m,onclick:l,onmousedown:l,"aria-label":` Action: ${c}${h<0?"":` (access key "${i[a]})"`}.`},d)}),e.source&&Dn("div",{class:"cm-diagnosticSource"},e.source))}class Tlt extends oo{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Dn("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class oU{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=hme(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Lv{constructor(e){this.view=e,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)sU(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],a=ume(s.actions);for(let o=0;o<a.length;o++)if(a[o].toUpperCase().charCodeAt(0)==i.keyCode){let l=jh(this.view.state.field(fa).diagnostics,s);l&&s.actions[o].apply(e,l.from,l.to)}}else return;i.preventDefault()}},r=i=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(i.target)&&this.moveSelection(s)};this.list=Dn("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=Dn("div",{class:"cm-panel-lint"},this.list,Dn("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>sU(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(fa).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(fa),r=0,i=!1,s=null,a=new Set;for(e.between(0,this.view.state.doc.length,(o,l,{spec:c})=>{for(let h of c.diagnostics){if(a.has(h))continue;a.add(h);let d=-1,m;for(let g=r;g<this.items.length;g++)if(this.items[g].diagnostic==h){d=g;break}d<0?(m=new oU(this.view,h),this.items.splice(r,0,m),i=!0):(m=this.items[d],d>r&&(this.items.splice(r,d-r),i=!0)),n&&m.diagnostic==n.diagnostic?m.dom.hasAttribute("aria-selected")||(m.dom.setAttribute("aria-selected","true"),s=m):m.dom.hasAttribute("aria-selected")&&m.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new oU(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let c=l.height/this.list.offsetHeight;o.top<l.top?this.list.scrollTop-=(l.top-o.top)/c:o.bottom>l.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(fa),r=jh(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:cme.of(r)})}static open(e){return new Lv(e)}}function Alt(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function dO(t){return Alt(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Plt=Ze.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:dO("#d11")},".cm-lintRange-warning":{backgroundImage:dO("orange")},".cm-lintRange-info":{backgroundImage:dO("#999")},".cm-lintRange-hint":{backgroundImage:dO("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Mlt(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function Rlt(t){let e="hint",n=1;for(let r of t){let i=Mlt(r.severity);i>n&&(n=i,e=r.severity)}return e}const Ilt=[fa,Ze.decorations.compute([fa],t=>{let{selected:e,panel:n}=t.field(fa);return!e||!n||e.from==e.to?lt.none:lt.set([wlt.range(e.from,e.to)])}),Dtt(Slt,{hideOn:Olt}),Plt],fme=[wR(),Ktt(),mtt(),mit(),jnt(),itt(),ctt(),Dt.allowMultipleSelections.of(!0),Mnt(),lde(qnt,{fallback:!0}),ert(),qrt(),iit(),Ctt(),Ptt(),btt(),Wot(),rg.of([...Grt,...vst,...glt,...Eit,...Qnt,...Tde,...Clt])],lg=p.forwardRef(({title:t,children:e},n)=>{const r=cr(sf);return p.createElement(yie,{delayDuration:100},p.createElement(xie,null,p.createElement(Oie,{ref:n,asChild:!0},p.createElement("span",{className:ke.tooltipTrigger},e)),p.createElement(bie,{container:r?.current},p.createElement(wie,{className:sn(ke.tooltipContent),sideOffset:10},t))))}),dme=p.forwardRef(({children:t,className:e,...n},r)=>p.createElement(cTe,{...n,ref:r,className:sn(e,ke.selectItem)},p.createElement(uTe,null,t))),Nlt=({title:t,placeholder:e,className:n})=>{const[r,i]=Ar(Vi,Lr);return p.createElement(lg,{title:t},p.createElement(Bre,{"aria-label":e,className:sn(ke.selectTrigger,n),"data-toolbar-item":!0,disabled:r},p.createElement(sTe,{placeholder:e}),p.createElement(jre,{className:ke.selectDropdownArrow},i("arrow_drop_down"))))},pme=({children:t,className:e=ke.selectContainer})=>{const n=cr(sf);return p.createElement(aTe,{container:n?.current},p.createElement(oTe,{className:sn(e,"mdxeditor-select-content"),onCloseAutoFocus:r=>{r.preventDefault()},position:"popper"},p.createElement(lTe,{"data-editor-dropdown":!0,style:{maxHeight:"var(--radix-select-content-available-height)"}},t)))},$lt=({children:t,title:e,className:n})=>{const[r,i]=Ar(Vi,Lr);return p.createElement(lg,{title:e},p.createElement(Bre,{"aria-label":e,className:sn(ke.toolbarButtonSelectTrigger,n),disabled:r},t,p.createElement(jre,{className:ke.selectDropdownArrow},i("arrow_drop_down"))))},mme=t=>p.createElement(Vre,{value:t.value||"",onValueChange:t.onChange,disabled:t.disabled},p.createElement(Nlt,{title:t.triggerTitle,placeholder:t.placeholder}),p.createElement(pme,null,t.items.map((e,n)=>e==="separator"?p.createElement(hTe,{key:n}):p.createElement(dme,{key:n,value:e.value},e.label)))),Llt=({language:t,nodeKey:e,code:n,focusEmitter:r})=>{const i=qr(),{parentEditor:s,lexicalNode:a}=Xk(),[o,l,c,h,d]=Ar(Vi,WC,YC,Lr,XC),m=zot(e,"codeblock",t,r),{setCode:g}=Xk(),x=p.useRef(null),O=p.useRef(null),{value:w,items:E}=p.useMemo(()=>zlt(d,t),[d,t]),S=p.useRef(g);return S.current=g,m.current={getCodemirror:()=>x.current},p.useEffect(()=>{const _=O.current;return(async()=>{const P=[...l,fme,Kpe,wR(),rg.of([yst]),Ze.lineWrapping,Ze.updateListener.of(({state:A})=>{S.current(A.doc.toString())}),Ze.domEventHandlers({focus:()=>{s.update(()=>{yr(null)})}})];if(o&&P.push(Dt.readOnly.of(!0)),t!==""){const A=d.keyMap[t]??t,k=d.supportMap[A];if(k)P.push(k.extension);else if(c){const I=Gpe.find($=>$.name===t||$.alias.includes(t)||$.extensions.includes(t));if(I)try{const $=await I.load();P.push($.extension)}catch{console.warn("failed to load language support for",t)}}}_.innerHTML="",x.current=new Ze({parent:_,state:Dt.create({doc:n,extensions:P})}),_.addEventListener("keydown",lU)})(),()=>{var P;(P=x.current)==null||P.destroy(),x.current=null,_.removeEventListener("keydown",lU)}},[o,t,...l]),p.createElement("div",{className:ke.codeMirrorWrapper},p.createElement("div",{className:ke.codeMirrorToolbar},p.createElement(mme,{disabled:o,value:w,onChange:_=>{s.update(()=>{a.setLanguage(_===ub?"":_),setTimeout(()=>{s.update(()=>{a.getLatest().select()})})})},triggerTitle:i("codeBlock.selectLanguage","Select code block language"),placeholder:i("codeBlock.inlineLanguage","Language"),items:E}),p.createElement("button",{className:ke.iconButton,type:"button",disabled:o,title:i("codeblock.delete","Delete code block"),onClick:_=>{_.preventDefault(),s.update(()=>{a.remove()})}},h("delete_small"))),p.createElement("div",{ref:O}))};function lU(t){t.stopPropagation()}const ub="__EMPTY_VALUE__";function qC(t){var e;const n=[],r={},i={};if(Array.isArray(t))for(const s of t){const a=((e=s.alias)==null?void 0:e[0])??s.name.toLowerCase(),o=a||ub;if(n.push({value:o,label:s.name}),r[a]=o,s.alias)for(const l of s.alias)r[l]=o;if(s.extensions)for(const l of s.extensions)r[l]=o;r[s.name.toLowerCase()]=o,s.support&&(i[o]=s.support)}else{const s={};for(const[a,o]of Object.entries(t))o in s||(s[o]=a,n.push({value:a||ub,label:o})),r[a]=s[o]||ub}return{items:n,keyMap:r,supportMap:i}}function zlt(t,e){const n=t.keyMap[e]??e;return!n||t.items.some(r=>r.value===n)?{value:n,items:t.items}:{value:n,items:[...t.items,{value:n,label:e}]}}const XC=et(qC({js:"JavaScript",ts:"TypeScript",tsx:"TypeScript (React)",jsx:"JavaScript (React)",css:"CSS"})),Dlt=$r(t=>{t.link(t.pipe(Dlt,eu(({language:e,code:n})=>({code:n,language:e,meta:""}))),oS)}),WC=et([]),YC=et(!0),Qlt=Bi({update(t,e){t.pubIn({[XC]:qC(e?.codeBlockLanguages??{}),[WC]:e?.codeMirrorExtensions??[],[YC]:e?.autoLoadLanguageSupport??!0})},init(t,e){const n=qC(e?.codeBlockLanguages??{});t.pubIn({[XC]:n,[WC]:e?.codeMirrorExtensions??[],[FKe]:Flt(),[YC]:e?.autoLoadLanguageSupport??!0})}});function Flt(t){return{match(e,n){return!n},priority:1,Editor:Llt}}function Vlt({url:t,title:e,text:n,onSubmit:r,onCancel:i,linkAutocompleteSuggestions:s,showLinkTitleField:a,showAnchorTextField:o}){const{register:l,handleSubmit:c,control:h,setValue:d,reset:m}=CM({values:{url:t,title:e,text:n}}),g=qr();return p.createElement("form",{onSubmit:x=>{c(r)(x),x.stopPropagation(),x.preventDefault()},onReset:x=>{x.stopPropagation(),i()},onKeyDown:x=>{x.key==="Escape"&&(x.stopPropagation(),i())},className:sn(ke.multiFieldForm,ke.linkDialogEditForm)},p.createElement("div",{className:ke.formField},p.createElement("label",{htmlFor:"link-url"},g("createLink.url","URL")),p.createElement(wue,{register:l,initialInputValue:t,inputName:"url",suggestions:s,setValue:d,control:h,placeholder:g("createLink.urlPlaceholder","Select or paste an URL"),autofocus:!0})),o?p.createElement("div",{className:ke.formField},p.createElement("label",{htmlFor:"link-text",title:g("createLink.textTooltip","The text to be displayed for the link")},g("createLink.text","Anchor text")),p.createElement("input",{id:"link-text",className:ke.textInput,size:40,...l("text")})):null,a?p.createElement("div",{className:ke.formField},p.createElement("label",{htmlFor:"link-title",title:g("createLink.titleTooltip","The link's title attribute, shown on hover")},g("createLink.title","Link title")),p.createElement("input",{id:"link-title",className:ke.textInput,size:40,...l("title")})):null,p.createElement("div",{style:{display:"flex",justifyContent:"flex-end",gap:"var(--spacing-2)"}},p.createElement("button",{type:"submit",title:g("createLink.saveTooltip","Set URL"),"aria-label":g("createLink.saveTooltip","Set URL"),className:sn(ke.primaryButton)},g("dialogControls.save","Save")),p.createElement("button",{type:"reset",title:g("createLink.cancelTooltip","Cancel change"),"aria-label":g("createLink.cancelTooltip","Cancel change"),className:sn(ke.secondaryButton)},g("dialogControls.cancel","Cancel"))))}const Blt=()=>{const[t,e,n,r,i,s,a]=Ar(sf,lr,Lr,Ts,bme,wme,Eme),o=Yt(gme),l=Yt(vme),c=Yt(yme),h=Yt(xme),d=Yt(Ome);p.useEffect(()=>{const E=()=>{e?.getEditorState().read(()=>{o(!0)})};return window.addEventListener("resize",E),window.addEventListener("scroll",E),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E)}},[e,o]);const[m,g]=p.useState(!1),x=qr();if(r.type==="inactive")return null;const O=r.rectangle,w=r.type==="preview"&&r.url.startsWith("http");return p.createElement(W4,{open:!0},p.createElement(ACe,{"data-visible":r.type==="edit",className:ke.linkDialogAnchor,style:{top:`${O.top}px`,left:`${O.left}px`,width:`${O.width}px`,height:`${O.height}px`}}),p.createElement(Y4,{container:t?.current},p.createElement(gre,{className:sn(ke.linkDialogPopoverContent),sideOffset:5,onOpenAutoFocus:E=>{E.preventDefault()},key:r.linkNodeKey},r.type==="edit"&&p.createElement(Vlt,{url:r.url,title:r.title,text:r.text,onSubmit:l,onCancel:c.bind(null),linkAutocompleteSuggestions:i,showLinkTitleField:a,showAnchorTextField:r.withAnchorText}),r.type==="preview"&&p.createElement(p.Fragment,null,p.createElement("a",{className:ke.linkDialogPreviewAnchor,href:r.url,...w?{target:"_blank",rel:"noreferrer"}:{},onClick:E=>{s!==null&&(E.preventDefault(),s(r.url))},title:w?x("linkPreview.open","Open {{url}} in new window",{url:r.url}):r.url},p.createElement("span",null,r.url),w&&n("open_in_new")),p.createElement(i_,{onClick:()=>{h()},title:x("linkPreview.edit","Edit link URL"),"aria-label":x("linkPreview.edit","Edit link URL")},n("edit")),p.createElement(yie,null,p.createElement(xie,{open:m},p.createElement(Oie,{asChild:!0},p.createElement(i_,{title:x("linkPreview.copyToClipboard","Copy to clipboard"),"aria-label":x("linkPreview.copyToClipboard","Copy to clipboard"),onClick:()=>{window.navigator.clipboard.writeText(r.url).then(()=>{g(!0),setTimeout(()=>{g(!1)},1e3)})}},n(m?"check":"content_copy"))),p.createElement(bie,{container:t?.current},p.createElement(wie,{className:sn(ke.tooltipContent),sideOffset:5},x("linkPreview.copied","Copied!"),p.createElement(rAe,null))))),p.createElement(i_,{title:x("linkPreview.remove","Remove link"),"aria-label":x("linkPreview.remove","Remove link"),onClick:()=>{d()}},n("link_off"))),p.createElement(G4,{className:ke.popoverArrow}))))},i_=p.forwardRef(({className:t,...e},n)=>p.createElement("button",{className:sn(ke.actionButton,t),ref:n,...e}));function GC(t){if(!t)return null;const e=Lqe(t);if(e===null)return null;const n=e.getParent();return Ms(n)?n:Ms(e)?e:null}const gme=$r(),Ts=et({type:"inactive"},t=>{t.pub(hv,e=>e.registerCommand(Q1,()=>t.getValue(Ts).type==="preview"?(t.pub(Ts,{type:"inactive"}),!0):!1,On)),t.sub(t.pipe(iu),e=>{e!=="rich-text"&&t.pub(Ts,{type:"inactive"})}),t.pub(hv,e=>e.registerCommand(yP,n=>{if(n.key==="k"&&(S5?n.metaKey:n.ctrlKey)&&!t.getValue(Vi)){const r=Qe();return Ie(r)?(t.pub(lI),n.stopPropagation(),n.preventDefault(),!0):!1}return!1},e1)),t.sub(t.pipe(xme,Sr(Ts,lr)),([,e,n])=>{if(e.type==="preview")setTimeout(()=>{n?.getEditorState().read(()=>{const r=an(e.linkNodeKey),i=Ms(r)?r.getTextContent().length>0&&r.getChildrenSize()<=1:!1,s=i&&r?r.getTextContent():"";t.pub(Ts,{type:"edit",initialUrl:e.url,url:e.url,title:e.title,text:s,withAnchorText:i,linkNodeKey:e.linkNodeKey,rectangle:e.rectangle})})});else throw new Error("Cannot switch to edit mode when not in preview mode")}),t.sub(t.pipe(vme,Sr(lr,Ts,i1)),([e,n,r,i])=>{var s,a,o;const l=((s=e.text)==null?void 0:s.trim())??"",c=((a=e.url)==null?void 0:a.trim())??"",h=((o=e.title)==null?void 0:o.trim())??"";if(c!==""){if(i?.isCollapsed()){const d=l||h||c;n?.update(()=>{const m=GC(i);if(m)if(Io(m)){const g=su(c,{title:h});g.append(qn(l)),m.replace(g),g.select()}else m.setURL(c),m.setTitle(h),cU(m.getFirstChild(),l);else{const g=su(c,{title:h});g.append(qn(d)),j1([g]),g.select()}},{discrete:!0})}else n?.update(()=>{cU(i?.anchor.getNode(),l)}),n?.dispatchCommand(s1,{url:c,title:h});t.pub(Ts,{type:"preview",linkNodeKey:r.linkNodeKey,rectangle:r.rectangle,title:h,url:c})}else r.type==="edit"&&r.initialUrl!==""&&n?.dispatchCommand(s1,null),t.pub(Ts,{type:"inactive"})}),t.link(t.pipe(yme,Sr(Ts,lr),eu(([,e,n])=>{if(e.type==="edit")return n?.focus(),e.initialUrl===""?{type:"inactive"}:{type:"preview",url:e.initialUrl,linkNodeKey:e.linkNodeKey,rectangle:e.rectangle};throw new Error("Cannot cancel edit when not in edit mode")})),Ts),t.link(t.pipe(t.combine(i1,gme),Sr(lr,Ts,Vi),eu(([[e],n,r,i])=>{if(Ie(e)&&n&&!i){const s=GC(e);if(!e.isCollapsed())return{type:"inactive"};if(s){const a=Rce(n);return a?{type:"preview",url:s.getURL(),linkNodeKey:s.getKey(),title:s.getTitle(),rectangle:a}:{type:"inactive"}}else return{type:"inactive"}}else return{type:"inactive"}})),Ts)}),vme=$r(),yme=ef();ef();const xme=ef(),Ome=ef(t=>{t.sub(t.pipe(Ome,Sr(lr)),([,e])=>{e?.dispatchCommand(s1,null)})}),lI=ef(t=>{t.sub(t.pipe(lI,Sr(i1,lr),sy(([,e])=>Ie(e))),([,e,n])=>{n?.focus(()=>{setTimeout(()=>{n.getEditorState().read(()=>{const r=GC(e),i=Rce(n),s=r?.getURL()??"",a=r?.getURL()??"",o=r?.getTitle()??"",l=r?.getKey()??"",c=r?r.getTextContent().length>0&&r.getChildrenSize()<=1:!!e?.isCollapsed(),h=c&&r?r.getTextContent():"";t.pub(Ts,{type:"edit",initialUrl:s,url:a,title:o,text:h,withAnchorText:c,linkNodeKey:l,rectangle:i})})})})})}),bme=et([]),wme=et(null),Sme=et(null,t=>{t.pub(hv,e=>{function n(r){const[i,s]=t.getValues([Vi,Sme]);!i||s===null||e.update(()=>{const a=Zl(r.target);if(a!==null){const o=Uo(a,l=>l instanceof mu);o!==null&&s(r,o,o.getURL())}})}return e.registerRootListener((r,i)=>{r&&r.addEventListener("click",n),i&&i.removeEventListener("click",n)})})});function cU(t,e){Ue(t)&&e&&(t.setTextContent(e),t.selectStart())}const Eme=et(!0),jlt=Bi({init(t,e){t.pub(pu,e?.LinkDialog??Blt),t.pub(wme,e?.onClickLinkCallback??null),t.pub(Sme,e?.onReadOnlyClickLinkCallback??null),t.pub(Eme,e?.showLinkTitleField??!0)},update(t,e={}){t.pub(bme,e.linkAutocompleteSuggestions??[])}});function cI(t,e){return p.forwardRef((n,r)=>{const i=sn(e.className,n.className);return p.createElement(t,{...e,...n,className:i,ref:r})})}function Hlt(t){return({title:e,children:n,...r})=>p.createElement(t,{"aria-label":e,...r},p.createElement(lg,{title:e},n))}const Zlt=({readOnly:t,children:e,className:n})=>p.createElement(NA,{className:sn("mdxeditor-toolbar",ke.toolbarRoot,{[ke.readOnlyToolbarRoot]:t},n),...t?{tabIndex:-1}:{}},e),Ult=cI(Oh,{className:ke.toolbarButton,"data-toolbar-item":!0}),Vy=Hlt(Ult),_me=cI(LO,{className:ke.toolbarToggleItem,"data-toolbar-item":!0});cI(tw,{type:"single",className:ke.toolbarToggleSingleGroup});const kme=p.forwardRef(({on:t,title:e,children:n,disabled:r,...i},s)=>p.createElement(tw,{type:"single",className:ke.toolbarToggleSingleGroup,...i,value:t?"on":"off",ref:s},p.createElement(_me,{"aria-label":e,value:"on",disabled:r},p.createElement(lg,{title:e},n)))),Cme=({items:t})=>p.createElement("div",{className:ke.toolbarGroupOfGroups},t.map((e,n)=>p.createElement(kme,{key:n,title:e.title,on:e.active,onValueChange:r=>{e.onChange(r==="on")},disabled:e.disabled},e.contents))),Tme=({value:t,onChange:e,className:n,ggClassName:r,items:i,disabled:s})=>{const a=qr();return p.createElement("div",{className:sn(ke.toolbarGroupOfGroups,r)},p.createElement(tw,{"aria-label":a("toolbar.toggleGroup","toggle group"),type:"single",className:sn(ke.toolbarToggleSingleGroup,n),onValueChange:e,value:t||"",disabled:s,onFocus:o=>{o.preventDefault()}},i.map((o,l)=>p.createElement(_me,{key:l,"aria-label":o.title,value:o.value},p.createElement(lg,{title:o.title},o.contents)))))},qlt=t=>{const e=cr(Vi);return p.createElement(p.Fragment,null,t.items.length===1?p.createElement(Vy,{title:t.title,onClick:()=>{t.onChoose("")},disabled:e},t.children):p.createElement(Vre,{value:"",onValueChange:t.onChoose},p.createElement($lt,{title:t.title},t.children),p.createElement(pme,{className:ke.toolbarButtonDropdownContainer},t.items.map((n,r)=>p.createElement(dme,{key:r,value:n.value},n.label)))))},A0=lie,s_=et(()=>null),a_=et(""),uU=()=>"This is an empty toolbar. Pass `{toolbarContents: () => { return <>toolbar components</> }}` to the toolbarPlugin to customize it.",Xlt=Bi({init(t,e){const n=e?.toolbarPosition==="bottom"?kZe:_Ze;t.pubIn({[s_]:e?.toolbarContents??uU,[a_]:e?.toolbarClassName??"",[n]:()=>{const[r,i,s]=Ar(s_,Vi,a_);return p.createElement(Zlt,{className:s,readOnly:i},r())}})},update(t,e){t.pub(s_,e?.toolbarContents??uU),t.pub(a_,e?.toolbarClassName??"")}});class si{constructor(e,n,r,i){this.fromA=e,this.toA=n,this.fromB=r,this.toB=i}offset(e,n=e){return new si(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function Vd(t,e,n,r,i,s){if(t==r)return[];let a=hI(t,e,n,r,i,s),o=fI(t,e+a,n,r,i+a,s);e+=a,n-=o,i+=a,s-=o;let l=n-e,c=s-i;if(!l||!c)return[new si(e,n,i,s)];if(l>c){let d=t.slice(e,n).indexOf(r.slice(i,s));if(d>-1)return[new si(e,e+d,i,i),new si(e+d+c,n,s,s)]}else if(c>l){let d=r.slice(i,s).indexOf(t.slice(e,n));if(d>-1)return[new si(e,e,i,i+d),new si(n,n,i+d+l,s)]}if(l==1||c==1)return[new si(e,n,i,s)];let h=Mme(t,e,n,r,i,s);if(h){let[d,m,g]=h;return Vd(t,e,d,r,i,m).concat(Vd(t,d+g,n,r,m+g,s))}return Wlt(t,e,n,r,i,s)}let Y0=1e9,G0=0,uI=!1;function Wlt(t,e,n,r,i,s){let a=n-e,o=s-i;if(Y0<1e9&&Math.min(a,o)>Y0*16||G0>0&&Date.now()>G0)return Math.min(a,o)>Y0*64?[new si(e,n,i,s)]:hU(t,e,n,r,i,s);let l=Math.ceil((a+o)/2);o_.reset(l),l_.reset(l);let c=(g,x)=>t.charCodeAt(e+g)==r.charCodeAt(i+x),h=(g,x)=>t.charCodeAt(n-g-1)==r.charCodeAt(s-x-1),d=(a-o)%2!=0?l_:null,m=d?null:o_;for(let g=0;g<l;g++){if(g>Y0||G0>0&&!(g&63)&&Date.now()>G0)return hU(t,e,n,r,i,s);let x=o_.advance(g,a,o,l,d,!1,c)||l_.advance(g,a,o,l,m,!0,h);if(x)return Ylt(t,e,n,e+x[0],r,i,s,i+x[1])}return[new si(e,n,i,s)]}class Ame{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,n,r,i,s,a,o){for(let l=-e+this.start;l<=e-this.end;l+=2){let c=i+l,h=l==-e||l!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,d=h-l;for(;h<n&&d<r&&o(h,d);)h++,d++;if(this.vec[c]=h,h>n)this.end+=2;else if(d>r)this.start+=2;else if(s){let m=i+(n-r)-l;if(m>=0&&m<this.len&&s.vec[m]!=-1)if(a){let g=s.vec[m];if(g>=n-h)return[g,i+g-m]}else{let g=n-s.vec[m];if(h>=g)return[h,d]}}}return null}}const o_=new Ame,l_=new Ame;function Ylt(t,e,n,r,i,s,a,o){let l=!1;return!g1(t,r)&&++r==n&&(l=!0),!g1(i,o)&&++o==a&&(l=!0),l?[new si(e,n,s,a)]:Vd(t,e,r,i,s,o).concat(Vd(t,r,n,i,o,a))}function Pme(t,e){let n=1,r=Math.min(t,e);for(;n<r;)n=n<<1;return n}function hI(t,e,n,r,i,s){if(e==n||e==s||t.charCodeAt(e)!=r.charCodeAt(i))return 0;let a=Pme(n-e,s-i);for(let o=e,l=i;;){let c=o+a,h=l+a;if(c>n||h>s||t.slice(o,c)!=r.slice(l,h)){if(a==1)return o-e-(g1(t,o)?0:1);a=a>>1}else{if(c==n||h==s)return c-e;o=c,l=h}}}function fI(t,e,n,r,i,s){if(e==n||i==s||t.charCodeAt(n-1)!=r.charCodeAt(s-1))return 0;let a=Pme(n-e,s-i);for(let o=n,l=s;;){let c=o-a,h=l-a;if(c<e||h<i||t.slice(c,o)!=r.slice(h,l)){if(a==1)return n-o-(g1(t,o)?0:1);a=a>>1}else{if(c==e||h==i)return n-c;o=c,l=h}}}function KC(t,e,n,r,i,s,a,o){let l=r.slice(i,s),c=null;for(;;){if(c||a<o)return c;for(let h=e+a;;){g1(t,h)||h++;let d=h+a;if(g1(t,d)||(d+=d==h+1?1:-1),d>=n)break;let m=t.slice(h,d),g=-1;for(;(g=l.indexOf(m,g+1))!=-1;){let x=hI(t,d,n,r,i+g+m.length,s),O=fI(t,e,h,r,i,i+g),w=m.length+x+O;(!c||c[2]<w)&&(c=[h-O,i+g-O,w])}h=d}if(o<0)return c;a=a>>1}}function Mme(t,e,n,r,i,s){let a=n-e,o=s-i;if(a<o){let l=Mme(r,i,s,t,e,n);return l&&[l[1],l[0],l[2]]}return a<4||o*2<a?null:KC(t,e,n,r,i,s,Math.floor(a/4),-1)}function hU(t,e,n,r,i,s){uI=!0;let a=n-e,o=s-i,l;if(a<o){let m=KC(r,i,s,t,e,n,Math.floor(a/6),50);l=m&&[m[1],m[0],m[2]]}else l=KC(t,e,n,r,i,s,Math.floor(o/6),50);if(!l)return[new si(e,n,i,s)];let[c,h,d]=l;return Vd(t,e,c,r,i,h).concat(Vd(t,c+d,n,r,h+d,s))}function Rme(t,e){for(let n=1;n<t.length;n++){let r=t[n-1],i=t[n];r.toA>i.fromA-e&&r.toB>i.fromB-e&&(t[n-1]=new si(r.fromA,i.toA,r.fromB,i.toB),t.splice(n--,1))}}function Glt(t,e,n){for(;;){Rme(n,1);let r=!1;for(let i=0;i<n.length;i++){let s=n[i],a,o;(a=hI(t,s.fromA,s.toA,e,s.fromB,s.toB))&&(s=n[i]=new si(s.fromA+a,s.toA,s.fromB+a,s.toB)),(o=fI(t,s.fromA,s.toA,e,s.fromB,s.toB))&&(s=n[i]=new si(s.fromA,s.toA-o,s.fromB,s.toB-o));let l=s.toA-s.fromA,c=s.toB-s.fromB;if(l&&c)continue;let h=s.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:t.length)-s.toA;if(!h||!d)continue;let m=l?t.slice(s.fromA,s.toA):e.slice(s.fromB,s.toB);h<=m.length&&t.slice(s.fromA-h,s.fromA)==m.slice(m.length-h)?(n[i]=new si(s.fromA-h,s.toA-h,s.fromB-h,s.toB-h),r=!0):d<=m.length&&t.slice(s.toA,s.toA+d)==m.slice(0,d)&&(n[i]=new si(s.fromA+d,s.toA+d,s.fromB+d,s.toB+d),r=!0)}if(!r)break}return n}function Klt(t,e,n){for(let r=0,i=0;i<t.length;i++){let s=t[i],a=s.toA-s.fromA,o=s.toB-s.fromB;if(a&&o||a>3||o>3){let l=i==t.length-1?e.length:t[i+1].fromA,c=s.fromA-r,h=l-s.toA,d=dU(e,s.fromA,c),m=fU(e,s.toA,h),g=s.fromA-d,x=m-s.toA;if((!a||!o)&&g&&x){let O=Math.max(a,o),[w,E,S]=a?[e,s.fromA,s.toA]:[n,s.fromB,s.toB];O>g&&e.slice(d,s.fromA)==w.slice(S-g,S)?(s=t[i]=new si(d,d+a,s.fromB-g,s.toB-g),d=s.fromA,m=fU(e,s.toA,l-s.toA)):O>x&&e.slice(s.toA,m)==w.slice(E,E+x)&&(s=t[i]=new si(m-a,m,s.fromB+x,s.toB+x),m=s.toA,d=dU(e,s.fromA,s.fromA-r)),g=s.fromA-d,x=m-s.toA}if(g||x)s=t[i]=new si(s.fromA-g,s.toA+x,s.fromB-g,s.toB+x);else if(a){if(!o){let O=mU(e,s.fromA,s.toA),w,E=O<0?-1:pU(e,s.toA,s.fromA);O>-1&&(w=O-s.fromA)<=h&&e.slice(s.fromA,O)==e.slice(s.toA,s.toA+w)?s=t[i]=s.offset(w):E>-1&&(w=s.toA-E)<=c&&e.slice(s.fromA-w,s.fromA)==e.slice(E,s.toA)&&(s=t[i]=s.offset(-w))}}else{let O=mU(n,s.fromB,s.toB),w,E=O<0?-1:pU(n,s.toB,s.fromB);O>-1&&(w=O-s.fromB)<=h&&n.slice(s.fromB,O)==n.slice(s.toB,s.toB+w)?s=t[i]=s.offset(w):E>-1&&(w=s.toB-E)<=c&&n.slice(s.fromB-w,s.fromB)==n.slice(E,s.toB)&&(s=t[i]=s.offset(-w))}}r=s.toA}return Rme(t,3),t}let ad;try{ad=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function Ime(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function Nme(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?Ime(n)?1:0:ad?!zme(n)||e==t.length-1?ad.test(String.fromCharCode(n))?1:0:ad.test(t.slice(e,e+2))?2:0:0}function $me(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?Ime(n)?1:0:ad?!Dme(n)||e==1?ad.test(String.fromCharCode(n))?1:0:ad.test(t.slice(e-2,e))?2:0:0}const Lme=8;function fU(t,e,n){if(e==t.length||!$me(t,e))return e;for(let r=e,i=e+n,s=0;s<Lme;s++){let a=Nme(t,r);if(!a||r+a>i)return r;r+=a}return e}function dU(t,e,n){if(!e||!Nme(t,e))return e;for(let r=e,i=e-n,s=0;s<Lme;s++){let a=$me(t,r);if(!a||r-a<i)return r;r-=a}return e}function pU(t,e,n){for(;e!=n;e--)if(t.charCodeAt(e-1)==10)return e;return-1}function mU(t,e,n){for(;e!=n;e++)if(t.charCodeAt(e)==10)return e;return-1}const zme=t=>t>=55296&&t<=56319,Dme=t=>t>=56320&&t<=57343;function g1(t,e){return!e||e==t.length||!zme(t.charCodeAt(e-1))||!Dme(t.charCodeAt(e))}function Jlt(t,e,n){var r;let i=n?.override;return i?i(t,e):(Y0=((r=n?.scanLimit)!==null&&r!==void 0?r:1e9)>>1,G0=n?.timeout?Date.now()+n.timeout:0,uI=!1,Glt(t,e,Vd(t,0,t.length,e,0,e.length)))}function Qme(){return!uI}function Fme(t,e,n){return Klt(Jlt(t,e,n),t,e)}const Cl=tt.define({combine:t=>t[0]}),JC=Et.define(),ect=tt.define(),v1=hi.define({create(t){return null},update(t,e){for(let n of e.effects)n.is(JC)&&(t=n.value);for(let n of e.state.facet(ect))t=n(t,e);return t}});class Dm{constructor(e,n,r,i,s,a=!0){this.changes=e,this.fromA=n,this.toA=r,this.fromB=i,this.toB=s,this.precise=a}offset(e,n){return e||n?new Dm(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,r){let i=Fme(e.toString(),n.toString(),r);return Vme(i,e,n,0,0,Qme())}static updateA(e,n,r,i,s){return OU(xU(e,i,!0,r.length),e,n,r,s)}static updateB(e,n,r,i,s){return OU(xU(e,i,!1,n.length),e,n,r,s)}}function gU(t,e,n,r){let i=n.lineAt(t),s=r.lineAt(e);return i.to==t&&s.to==e&&t<n.length&&e<r.length?[t+1,e+1]:[i.from,s.from]}function vU(t,e,n,r){let i=n.lineAt(t),s=r.lineAt(e);return i.from==t&&s.from==e?[t,e]:[i.to+1,s.to+1]}function Vme(t,e,n,r,i,s){let a=[];for(let o=0;o<t.length;o++){let l=t[o],[c,h]=gU(l.fromA+r,l.fromB+i,e,n),[d,m]=vU(l.toA+r,l.toB+i,e,n),g=[l.offset(-c+r,-h+i)];for(;o<t.length-1;){let x=t[o+1],[O,w]=gU(x.fromA+r,x.fromB+i,e,n);if(O>d+1&&w>m+1)break;g.push(x.offset(-c+r,-h+i)),[d,m]=vU(x.toA+r,x.toB+i,e,n),o++}a.push(new Dm(g,c,Math.max(c,d),h,Math.max(h,m),s))}return a}const pO=1e3;function yU(t,e,n,r){let i=0,s=t.length;for(;;){if(i==s){let h=0,d=0;i&&({toA:h,toB:d}=t[i-1]);let m=e-(n?h:d);return[h+m,d+m]}let a=i+s>>1,o=t[a],[l,c]=n?[o.fromA,o.toA]:[o.fromB,o.toB];if(l>e)s=a;else if(c<=e)i=a+1;else return r?[o.fromA,o.fromB]:[o.toA,o.toB]}}function xU(t,e,n,r){let i=[];return e.iterChangedRanges((s,a,o,l)=>{let c=0,h=n?e.length:r,d=0,m=n?r:e.length;s>pO&&([c,d]=yU(t,s-pO,n,!0)),a<e.length-pO&&([h,m]=yU(t,a+pO,n,!1));let g=l-o-(a-s),x,[O,w]=n?[g,0]:[0,g];i.length&&(x=i[i.length-1]).toA>=c?i[i.length-1]={fromA:x.fromA,fromB:x.fromB,toA:h,toB:m,diffA:x.diffA+O,diffB:x.diffB+w}:i.push({fromA:c,toA:h,fromB:d,toB:m,diffA:O,diffB:w})}),i}function OU(t,e,n,r,i){if(!t.length)return e;let s=[];for(let a=0,o=0,l=0,c=0;;a++){let h=a==t.length?null:t[a],d=h?h.fromA+o:n.length,m=h?h.fromB+l:r.length;for(;c<e.length;){let w=e[c];if(h&&(w.toA+o>d||w.toB+l>m))break;s.push(w.offset(o,l)),c++}if(!h)break;let g=h.toA+o+h.diffA,x=h.toB+l+h.diffB,O=Fme(n.sliceString(d,g),r.sliceString(m,x),i);for(let w of Vme(O,n,r,d,m,Qme()))s.push(w);for(o+=h.diffA,l+=h.diffB;c<e.length;){let w=e[c];if(w.fromA+o>g&&w.fromB+l>x)break;c++}}return s}const tct={scanLimit:500},Bme=Nr.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=SU(t))}update(t){(t.docChanged||t.viewportChanged||nct(t.startState,t.state)||rct(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=SU(t.view))}},{decorations:t=>t.deco}),mO=il.low(Dfe({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(Bme))===null||e===void 0?void 0:e.gutter)||Bt.empty}}));function nct(t,e){return t.field(v1,!1)!=e.field(v1,!1)}function rct(t,e){return t.facet(Cl)!=e.facet(Cl)}const bU=lt.line({class:"cm-changedLine"}),ict=lt.mark({class:"cm-changedText"}),sct=lt.mark({tagName:"ins",class:"cm-insertedLine"}),act=lt.mark({tagName:"del",class:"cm-deletedLine"}),wU=new class extends Wl{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function oct(t,e,n,r,i,s){let a=n?t.fromA:t.fromB,o=n?t.toA:t.toB,l=0;if(a!=o){i.add(a,a,bU),i.add(a,o,n?act:sct),s&&s.add(a,a,wU);for(let c=e.iterRange(a,o-1),h=a;!c.next().done;){if(c.lineBreak){h++,i.add(h,h,bU),s&&s.add(h,h,wU);continue}let d=h+c.value.length;if(r)for(;l<t.changes.length;){let m=t.changes[l],g=a+(n?m.fromA:m.fromB),x=a+(n?m.toA:m.toB),O=Math.max(h,g),w=Math.min(d,x);if(O<w&&i.add(O,w,ict),x<d)l++;else break}h=d}}}function SU(t){let e=t.state.field(v1),{side:n,highlightChanges:r,markGutter:i,overrideChunk:s}=t.state.facet(Cl),a=n=="a",o=new Vs,l=i?new Vs:null,{from:c,to:h}=t.viewport;for(let d of e){if((a?d.fromA:d.fromB)>=h)break;(a?d.toA:d.toB)>c&&(!s||!s(t.state,d,o,l))&&oct(d,t.state.doc,a,r,o,l)}return{deco:o.finish(),gutter:l&&l.finish()}}class gO extends oo{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}const c4=Et.define({map:(t,e)=>t.map(e)}),K0=hi.define({create:()=>lt.none,update:(t,e)=>{for(let n of e.effects)if(n.is(c4))return n.value;return t.map(e.changes)},provide:t=>Ze.decorations.from(t)}),vO=.01;function EU(t,e){if(t.size!=e.size)return!1;let n=t.iter(),r=e.iter();for(;n.value;){if(n.from!=r.from||Math.abs(n.value.spec.widget.height-r.value.spec.widget.height)>1)return!1;n.next(),r.next()}return!0}function lct(t,e,n){let r=new Vs,i=new Vs,s=t.state.field(K0).iter(),a=e.state.field(K0).iter(),o=0,l=0,c=0,h=0,d=t.viewport,m=e.viewport;for(let w=0;;w++){let E=w<n.length?n[w]:null,S=E?E.fromA:t.state.doc.length,_=E?E.fromB:e.state.doc.length;if(o<S){let P=t.lineBlockAt(o).top+c,A=e.lineBlockAt(l).top+h,k=P-A;k<-vO?(c-=k,r.add(o,o,lt.widget({widget:new gO(-k),block:!0,side:-1}))):k>vO&&(h+=k,i.add(l,l,lt.widget({widget:new gO(k),block:!0,side:-1})))}if(S>o+1e3&&o<d.from&&S>d.from&&l<m.from&&_>m.from){let P=Math.min(d.from-o,m.from-l);o+=P,l+=P,w--}else if(E)o=E.toA,l=E.toB;else break;for(;s.value&&s.from<o;)c-=s.value.spec.widget.height,s.next();for(;a.value&&a.from<l;)h-=a.value.spec.widget.height,a.next()}for(;s.value;)c-=s.value.spec.widget.height,s.next();for(;a.value;)h-=a.value.spec.widget.height,a.next();let g=t.contentHeight+c-(e.contentHeight+h);g<vO?r.add(t.state.doc.length,t.state.doc.length,lt.widget({widget:new gO(-g),block:!0,side:1})):g>vO&&i.add(e.state.doc.length,e.state.doc.length,lt.widget({widget:new gO(g),block:!0,side:1}));let x=r.finish(),O=i.finish();EU(x,t.state.field(K0))||t.dispatch({effects:c4.of(x)}),EU(O,e.state.field(K0))||e.dispatch({effects:c4.of(O)})}const eT=Et.define({map:(t,e)=>e.mapPos(t)});class cct extends oo{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=e.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",r=>{let i=e.posAtDOM(r.target);e.dispatch({effects:eT.of(i)});let{side:s,sibling:a}=e.state.facet(Cl);a&&a().dispatch({effects:eT.of(uct(i,e.state.field(v1),s=="a"))})}),n}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function uct(t,e,n){let r=0,i=0;for(let s=0;;s++){let a=s<e.length?e[s]:null;if(!a||(n?a.fromA:a.fromB)>=t)return i+(t-r);[r,i]=n?[a.toA,a.toB]:[a.toB,a.toA]}}const hct=hi.define({create(t){return lt.none},update(t,e){t=t.map(e.changes);for(let n of e.effects)n.is(eT)&&(t=t.update({filter:r=>r!=n.value}));return t},provide:t=>Ze.decorations.from(t)});function _U({margin:t=3,minSize:e=4}){return hct.init(n=>fct(n,t,e))}function fct(t,e,n){let r=new Vs,i=t.facet(Cl).side=="a",s=t.field(v1),a=1;for(let o=0;;o++){let l=o<s.length?s[o]:null,c=o?a+e:1,h=l?t.doc.lineAt(i?l.fromA:l.fromB).number-1-e:t.doc.lines,d=h-c+1;if(d>=n&&r.add(t.doc.line(c).from,t.doc.line(h).to,lt.replace({widget:new cct(d),block:!0})),!l)break;a=t.doc.lineAt(Math.min(t.doc.length,i?l.toA:l.toB)).number}return r.finish()}const dct=Ze.styleModule.of(new lu({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),pct=Ze.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),kU=new ng,yO=new ng;class mct{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||tct;let n=[il.low(Bme),pct,dct,K0,Ze.updateListener.of(d=>{this.measuring<0&&(d.heightChanged||d.viewportChanged)&&!d.transactions.some(m=>m.effects.some(g=>g.is(c4)))&&this.measure()})],r=[Cl.of({side:"a",sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&r.push(mO);let i=Dt.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],Ze.editorAttributes.of({class:"cm-merge-a"}),yO.of(r),n]}),s=[Cl.of({side:"b",sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&s.push(mO);let a=Dt.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],Ze.editorAttributes.of({class:"cm-merge-b"}),yO.of(s),n]});this.chunks=Dm.build(i.doc,a.doc,this.diffConf);let o=[v1.init(()=>this.chunks),kU.of(e.collapseUnchanged?_U(e.collapseUnchanged):[])];i=i.update({effects:Et.appendConfig.of(o)}).state,a=a.update({effects:Et.appendConfig.of(o)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let l=e.orientation||"a-b",c=document.createElement("div");c.className="cm-mergeViewEditor";let h=document.createElement("div");h.className="cm-mergeViewEditor",this.editorDOM.appendChild(l=="a-b"?c:h),this.editorDOM.appendChild(l=="a-b"?h:c),this.a=new Ze({state:i,parent:c,root:e.root,dispatchTransactions:d=>this.dispatch(d,this.a)}),this.b=new Ze({state:a,parent:h,root:e.root,dispatchTransactions:d=>this.dispatch(d,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls=="b-to-a",e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,n){if(e.some(r=>r.docChanged)){let r=e[e.length-1],i=e.reduce((a,o)=>a.compose(o.changes),ii.empty(e[0].startState.doc.length));this.chunks=n==this.a?Dm.updateA(this.chunks,r.newDoc,this.b.state.doc,i,this.diffConf):Dm.updateB(this.chunks,this.a.state.doc,r.newDoc,i,this.diffConf),n.update([...e,r.state.update({effects:JC.of(this.chunks)})]);let s=n==this.a?this.b:this.a;s.update([s.state.update({effects:JC.of(this.chunks)})]),this.scheduleMeasure()}else n.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let s=e.orientation!="b-a";if(s!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let a=this.a.dom.parentNode,o=this.b.dom.parentNode;a.remove(),o.remove(),this.editorDOM.insertBefore(s?a:o,this.editorDOM.firstChild),this.editorDOM.appendChild(s?o:a),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let s=!!this.revertDOM,a=this.revertToA,o=this.renderRevert;"revertControls"in e&&(s=!!e.revertControls,a=e.revertControls=="b-to-a"),"renderRevertControl"in e&&(o=e.renderRevertControl),this.setupRevertControls(s,a,o)}let n="highlightChanges"in e,r="gutter"in e,i="collapseUnchanged"in e;if(n||r||i){let s=[],a=[];if(n||r){let o=this.a.state.facet(Cl),l=r?e.gutter!==!1:o.markGutter,c=n?e.highlightChanges!==!1:o.highlightChanges;s.push(yO.reconfigure([Cl.of({side:"a",sibling:()=>this.b,highlightChanges:c,markGutter:l}),l?mO:[]])),a.push(yO.reconfigure([Cl.of({side:"b",sibling:()=>this.a,highlightChanges:c,markGutter:l}),l?mO:[]]))}if(i){let o=kU.reconfigure(e.collapseUnchanged?_U(e.collapseUnchanged):[]);s.push(o),a.push(o)}this.a.dispatch({effects:s}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,n,r){this.revertToA=n,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=r,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",i=>this.revertClicked(i)),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame(()=>{this.measuring=-1,this.measure()})}}measure(){lct(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,n=e.firstChild,r=this.a.viewport,i=this.b.viewport;for(let s=0;s<this.chunks.length;s++){let a=this.chunks[s];if(a.fromA>r.to||a.fromB>i.to)break;if(a.fromA<r.from||a.fromB<i.from)continue;let o=this.a.lineBlockAt(a.fromA).top+"px";for(;n&&+n.dataset.chunk<s;)n=CU(n);n&&n.dataset.chunk==String(s)?(n.style.top!=o&&(n.style.top=o),n=n.nextSibling):e.insertBefore(this.renderRevertButton(o,s),n)}for(;n;)n=CU(n)}renderRevertButton(e,n){let r;if(this.renderRevert)r=this.renderRevert();else{r=document.createElement("button");let i=this.a.state.phrase("Revert this chunk");r.setAttribute("aria-label",i),r.setAttribute("title",i),r.textContent=this.revertToLeft?"⇜":"⇝"}return r.style.top=e,r.setAttribute("data-chunk",String(n)),r}revertClicked(e){let n=e.target,r;for(;n&&n.parentNode!=this.revertDOM;)n=n.parentNode;if(n&&(r=this.chunks[n.dataset.chunk])){let[i,s,a,o,l,c]=this.revertToA?[this.b,this.a,r.fromB,r.toB,r.fromA,r.toA]:[this.a,this.b,r.fromA,r.toA,r.fromB,r.toB],h=i.state.sliceDoc(a,Math.max(a,o-1));a!=o&&c<=s.state.doc.length&&(h+=i.state.lineBreak),s.dispatch({changes:{from:l,to:Math.min(s.state.doc.length,c),insert:h},userEvent:"revert"}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}}function CU(t){let e=t.nextSibling;return t.remove(),e}class u4{static create(e,n,r,i,s){let a=i+(i<<8)+e+(n<<4)|0;return new u4(e,n,r,a,s,[],[])}constructor(e,n,r,i,s,a,o){this.type=e,this.value=n,this.from=r,this.hash=i,this.end=s,this.children=a,this.positions=o,this.hashProp=[[kt.contextHash,i]]}addChild(e,n){e.prop(kt.contextHash)!=this.hash&&(e=new jt(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(n)}toTree(e,n=this.end){let r=this.children.length-1;return r>=0&&(n=Math.max(n,this.positions[r]+this.children[r].length+this.from)),new jt(e.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,s,a)=>new jt(ui.none,i,s,a,this.hashProp)})}}var Xe;(function(t){t[t.Document=1]="Document",t[t.CodeBlock=2]="CodeBlock",t[t.FencedCode=3]="FencedCode",t[t.Blockquote=4]="Blockquote",t[t.HorizontalRule=5]="HorizontalRule",t[t.BulletList=6]="BulletList",t[t.OrderedList=7]="OrderedList",t[t.ListItem=8]="ListItem",t[t.ATXHeading1=9]="ATXHeading1",t[t.ATXHeading2=10]="ATXHeading2",t[t.ATXHeading3=11]="ATXHeading3",t[t.ATXHeading4=12]="ATXHeading4",t[t.ATXHeading5=13]="ATXHeading5",t[t.ATXHeading6=14]="ATXHeading6",t[t.SetextHeading1=15]="SetextHeading1",t[t.SetextHeading2=16]="SetextHeading2",t[t.HTMLBlock=17]="HTMLBlock",t[t.LinkReference=18]="LinkReference",t[t.Paragraph=19]="Paragraph",t[t.CommentBlock=20]="CommentBlock",t[t.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",t[t.Escape=22]="Escape",t[t.Entity=23]="Entity",t[t.HardBreak=24]="HardBreak",t[t.Emphasis=25]="Emphasis",t[t.StrongEmphasis=26]="StrongEmphasis",t[t.Link=27]="Link",t[t.Image=28]="Image",t[t.InlineCode=29]="InlineCode",t[t.HTMLTag=30]="HTMLTag",t[t.Comment=31]="Comment",t[t.ProcessingInstruction=32]="ProcessingInstruction",t[t.Autolink=33]="Autolink",t[t.HeaderMark=34]="HeaderMark",t[t.QuoteMark=35]="QuoteMark",t[t.ListMark=36]="ListMark",t[t.LinkMark=37]="LinkMark",t[t.EmphasisMark=38]="EmphasisMark",t[t.CodeMark=39]="CodeMark",t[t.CodeText=40]="CodeText",t[t.CodeInfo=41]="CodeInfo",t[t.LinkTitle=42]="LinkTitle",t[t.LinkLabel=43]="LinkLabel",t[t.URL=44]="URL"})(Xe||(Xe={}));class gct{constructor(e,n){this.start=e,this.content=n,this.marks=[],this.parsers=[]}}class vct{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return A2(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,n=0,r=0){for(let i=n;i<e;i++)r+=this.text.charCodeAt(i)==9?4-r%4:1;return r}findColumn(e){let n=0;for(let r=0;n<this.text.length&&r<e;n++)r+=this.text.charCodeAt(n)==9?4-r%4:1;return n}scrub(){if(!this.baseIndent)return this.text;let e="";for(let n=0;n<this.basePos;n++)e+=" ";return e+this.text.slice(this.basePos)}}function TU(t,e,n){if(n.pos==n.text.length||t!=e.block&&n.indent>=e.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(t.type==Xe.OrderedList?mI:pI)(n,e,!1);return r>0&&(t.type!=Xe.BulletList||dI(n,e,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==t.value}const jme={[Xe.Blockquote](t,e,n){return n.next!=62?!1:(n.markers.push(rn(Xe.QuoteMark,e.lineStart+n.pos,e.lineStart+n.pos+1)),n.moveBase(n.pos+(co(n.text.charCodeAt(n.pos+1))?2:1)),t.end=e.lineStart+n.text.length,!0)},[Xe.ListItem](t,e,n){return n.indent<n.baseIndent+t.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+t.value),!0)},[Xe.OrderedList]:TU,[Xe.BulletList]:TU,[Xe.Document](){return!0}};function co(t){return t==32||t==9||t==10||t==13}function A2(t,e=0){for(;e<t.length&&co(t.charCodeAt(e));)e++;return e}function AU(t,e,n){for(;e>n&&co(t.charCodeAt(e-1));)e--;return e}function Hme(t){if(t.next!=96&&t.next!=126)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==t.next;)e++;if(e<t.pos+3)return-1;if(t.next==96){for(let n=e;n<t.text.length;n++)if(t.text.charCodeAt(n)==96)return-1}return e}function Zme(t){return t.next!=62?-1:t.text.charCodeAt(t.pos+1)==32?2:1}function dI(t,e,n){if(t.next!=42&&t.next!=45&&t.next!=95)return-1;let r=1;for(let i=t.pos+1;i<t.text.length;i++){let s=t.text.charCodeAt(i);if(s==t.next)r++;else if(!co(s))return-1}return n&&t.next==45&&Xme(t)>-1&&t.depth==e.stack.length&&e.parser.leafBlockParsers.indexOf(Kme.SetextHeading)>-1||r<3?-1:1}function Ume(t,e){for(let n=t.stack.length-1;n>=0;n--)if(t.stack[n].type==e)return!0;return!1}function pI(t,e,n){return(t.next==45||t.next==43||t.next==42)&&(t.pos==t.text.length-1||co(t.text.charCodeAt(t.pos+1)))&&(!n||Ume(e,Xe.BulletList)||t.skipSpace(t.pos+2)<t.text.length)?1:-1}function mI(t,e,n){let r=t.pos,i=t.next;for(;i>=48&&i<=57;){r++;if(r==t.text.length)return-1;i=t.text.charCodeAt(r)}return r==t.pos||r>t.pos+9||i!=46&&i!=41||r<t.text.length-1&&!co(t.text.charCodeAt(r+1))||n&&!Ume(e,Xe.OrderedList)&&(t.skipSpace(r+1)==t.text.length||r>t.pos+1||t.next!=49)?-1:r+1-t.pos}function qme(t){if(t.next!=35)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==35;)e++;if(e<t.text.length&&t.text.charCodeAt(e)!=32)return-1;let n=e-t.pos;return n>6?-1:n}function Xme(t){if(t.next!=45&&t.next!=61||t.indent>=t.baseIndent+4)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==t.next;)e++;let n=e;for(;e<t.text.length&&co(t.text.charCodeAt(e));)e++;return e==t.text.length?n:-1}const tT=/^[ \t]*$/,Wme=/-->/,Yme=/\?>/,nT=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Wme],[/^\s*<\?/,Yme],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,tT],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,tT]];function Gme(t,e,n){if(t.next!=60)return-1;let r=t.text.slice(t.pos);for(let i=0,s=nT.length-(n?1:0);i<s;i++)if(nT[i][0].test(r))return i;return-1}function PU(t,e){let n=t.countIndent(e,t.pos,t.indent),r=t.countIndent(t.skipSpace(e),e,n);return r>=n+5?n+1:r}function eh(t,e,n){let r=t.length-1;r>=0&&t[r].to==e&&t[r].type==Xe.CodeText?t[r].to=n:t.push(rn(Xe.CodeText,e,n))}const xO={LinkReference:void 0,IndentedCode(t,e){let n=e.baseIndent+4;if(e.indent<n)return!1;let r=e.findColumn(n),i=t.lineStart+r,s=t.lineStart+e.text.length,a=[],o=[];for(eh(a,i,s);t.nextLine()&&e.depth>=t.stack.length;)if(e.pos==e.text.length){eh(o,t.lineStart-1,t.lineStart);for(let l of e.markers)o.push(l)}else{if(e.indent<n)break;{if(o.length){for(let c of o)c.type==Xe.CodeText?eh(a,c.from,c.to):a.push(c);o=[]}eh(a,t.lineStart-1,t.lineStart);for(let c of e.markers)a.push(c);s=t.lineStart+e.text.length;let l=t.lineStart+e.findColumn(e.baseIndent+4);l<s&&eh(a,l,s)}}return o.length&&(o=o.filter(l=>l.type!=Xe.CodeText),o.length&&(e.markers=o.concat(e.markers))),t.addNode(t.buffer.writeElements(a,-i).finish(Xe.CodeBlock,s-i),i),!0},FencedCode(t,e){let n=Hme(e);if(n<0)return!1;let r=t.lineStart+e.pos,i=e.next,s=n-e.pos,a=e.skipSpace(n),o=AU(e.text,e.text.length,a),l=[rn(Xe.CodeMark,r,r+s)];a<o&&l.push(rn(Xe.CodeInfo,t.lineStart+a,t.lineStart+o));for(let c=!0,h=!0,d=!1;t.nextLine()&&e.depth>=t.stack.length;c=!1){let m=e.pos;if(e.indent-e.baseIndent<4)for(;m<e.text.length&&e.text.charCodeAt(m)==i;)m++;if(m-e.pos>=s&&e.skipSpace(m)==e.text.length){for(let g of e.markers)l.push(g);h&&d&&eh(l,t.lineStart-1,t.lineStart),l.push(rn(Xe.CodeMark,t.lineStart+e.pos,t.lineStart+m)),t.nextLine();break}else{d=!0,c||(eh(l,t.lineStart-1,t.lineStart),h=!1);for(let O of e.markers)l.push(O);let g=t.lineStart+e.basePos,x=t.lineStart+e.text.length;g<x&&(eh(l,g,x),h=!1)}}return t.addNode(t.buffer.writeElements(l,-r).finish(Xe.FencedCode,t.prevLineEnd()-r),r),!0},Blockquote(t,e){let n=Zme(e);return n<0?!1:(t.startContext(Xe.Blockquote,e.pos),t.addNode(Xe.QuoteMark,t.lineStart+e.pos,t.lineStart+e.pos+1),e.moveBase(e.pos+n),null)},HorizontalRule(t,e){if(dI(e,t,!1)<0)return!1;let n=t.lineStart+e.pos;return t.nextLine(),t.addNode(Xe.HorizontalRule,n),!0},BulletList(t,e){let n=pI(e,t,!1);if(n<0)return!1;t.block.type!=Xe.BulletList&&t.startContext(Xe.BulletList,e.basePos,e.next);let r=PU(e,e.pos+1);return t.startContext(Xe.ListItem,e.basePos,r-e.baseIndent),t.addNode(Xe.ListMark,t.lineStart+e.pos,t.lineStart+e.pos+n),e.moveBaseColumn(r),null},OrderedList(t,e){let n=mI(e,t,!1);if(n<0)return!1;t.block.type!=Xe.OrderedList&&t.startContext(Xe.OrderedList,e.basePos,e.text.charCodeAt(e.pos+n-1));let r=PU(e,e.pos+n);return t.startContext(Xe.ListItem,e.basePos,r-e.baseIndent),t.addNode(Xe.ListMark,t.lineStart+e.pos,t.lineStart+e.pos+n),e.moveBaseColumn(r),null},ATXHeading(t,e){let n=qme(e);if(n<0)return!1;let r=e.pos,i=t.lineStart+r,s=AU(e.text,e.text.length,r),a=s;for(;a>r&&e.text.charCodeAt(a-1)==e.next;)a--;(a==s||a==r||!co(e.text.charCodeAt(a-1)))&&(a=e.text.length);let o=t.buffer.write(Xe.HeaderMark,0,n).writeElements(t.parser.parseInline(e.text.slice(r+n+1,a),i+n+1),-i);a<e.text.length&&o.write(Xe.HeaderMark,a-r,s-r);let l=o.finish(Xe.ATXHeading1-1+n,e.text.length-r);return t.nextLine(),t.addNode(l,i),!0},HTMLBlock(t,e){let n=Gme(e,t,!1);if(n<0)return!1;let r=t.lineStart+e.pos,i=nT[n][1],s=[],a=i!=tT;for(;!i.test(e.text)&&t.nextLine();){if(e.depth<t.stack.length){a=!1;break}for(let c of e.markers)s.push(c)}a&&t.nextLine();let o=i==Wme?Xe.CommentBlock:i==Yme?Xe.ProcessingInstructionBlock:Xe.HTMLBlock,l=t.prevLineEnd();return t.addNode(t.buffer.writeElements(s,-r).finish(o,l-r),r),!0},SetextHeading:void 0};class yct{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,n,r){if(this.stage==-1)return!1;let i=r.content+`
307
307
  `+n.scrub(),s=this.advance(i);return s>-1&&s<i.length?this.complete(e,r,s):!1}finish(e,n){return(this.stage==2||this.stage==3)&&A2(n.content,this.pos)==n.content.length?this.complete(e,n,n.content.length):!1}complete(e,n,r){return e.addLeafElement(n,rn(Xe.LinkReference,this.start,this.start+r,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(o1e(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(rn(Xe.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(s1e(e,A2(e,this.pos),this.start)))return-1}else if(this.stage==2){let n=A2(e,this.pos),r=0;if(n>this.pos){let i=a1e(e,n,this.start);if(i){let s=c_(e,i.to-this.start);s>0&&(this.nextStage(i),r=s)}}return r||(r=c_(e,this.pos)),r>0&&r<e.length?r:-1}else return c_(e,this.pos)}}}function c_(t,e){for(;e<t.length;e++){let n=t.charCodeAt(e);if(n==10)break;if(!co(n))return-1}return e}class xct{nextLine(e,n,r){let i=n.depth<e.stack.length?-1:Xme(n),s=n.next;if(i<0)return!1;let a=rn(Xe.HeaderMark,e.lineStart+n.pos,e.lineStart+i);return e.nextLine(),e.addLeafElement(r,rn(s==61?Xe.SetextHeading1:Xe.SetextHeading2,r.start,e.prevLineEnd(),[...e.parser.parseInline(r.content,r.start),a])),!0}finish(){return!1}}const Kme={LinkReference(t,e){return e.content.charCodeAt(0)==91?new yct(e):null},SetextHeading(){return new xct}},Oct=[(t,e)=>qme(e)>=0,(t,e)=>Hme(e)>=0,(t,e)=>Zme(e)>=0,(t,e)=>pI(e,t,!0)>=0,(t,e)=>mI(e,t,!0)>=0,(t,e)=>dI(e,t,!0)>=0,(t,e)=>Gme(e,t,!0)>=0],bct={text:"",end:0};class wct{constructor(e,n,r,i){this.parser=e,this.input=n,this.ranges=i,this.line=new vct,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=i[i.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=i[0].from,this.block=u4.create(Xe.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new _ct(r,n):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let r=0;;){let i=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;r<e.markers.length&&(!i||e.markers[r].from<i.end);){let s=e.markers[r++];this.addNode(s.type,s.from,s.to)}if(!i)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;e:for(;;){for(let r of this.parser.blockParsers)if(r){let i=r(this,e);if(i!=!1){if(i==!0)return null;e.forward();continue e}}break}let n=new gct(this.lineStart+e.pos,e.text.slice(e.pos));for(let r of this.parser.leafBlockParsers)if(r){let i=r(this,n);i&&n.parsers.push(i)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let r of this.parser.endLeafBlock)if(r(this,e,n))break e}for(let r of n.parsers)if(r.nextLine(this,e,n))return null;n.content+=`
308
308
  `+e.scrub();for(let r of e.markers)n.marks.push(r)}return this.finishLeaf(n),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let n=this.fragments.takeNodes(this);return n?(this.absoluteLineStart+=n,this.lineStart=l1e(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let n=bct;if(n.end=e,e>=this.to)n.text="";else if(n.text=this.lineChunkAt(e),n.end+=n.text.length,this.ranges.length>1){let r=this.absoluteLineStart,i=this.rangeI;for(;this.ranges[i].to<n.end;){i++;let s=this.ranges[i].from,a=this.lineChunkAt(s);n.end=s+a.length,n.text=n.text.slice(0,this.ranges[i-1].to-r)+a,r=n.end-n.text.length}}return n}readLine(){let{line:e}=this,{text:n,end:r}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=r,e.reset(n);e.depth<this.stack.length;e.depth++){let i=this.stack[e.depth],s=this.parser.skipContextMarkup[i.type];if(!s)throw new Error("Unhandled block context "+Xe[i.type]);let a=this.line.markers.length;if(!s(i,this,e)){this.line.markers.length>a&&(i.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let n=this.input.chunk(e),r;if(this.input.lineChunks)r=n==`
@@ -505,4 +505,4 @@ ${a}`:s||a}function Pdt(t,{maxDepth:e=1e3,numbersAsFloat:n=!1}={}){if(Uy(t)!=="o
505
505
  `;default:return""}}function Zge(t){return Object.entries(t).map(([e,n])=>Ldt(n)?{name:e,type:"object",required:!1,children:Zge(n)}:{name:e,type:zdt(n),required:!1})}function Ldt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&!(t instanceof Date)}function zdt(t){return typeof t=="number"?"number":typeof t=="boolean"?"boolean":t instanceof Date?"date":Array.isArray(t)?t.every(e=>typeof e=="string")?"string-array":"json":typeof t=="object"&&t!==null?"json":"string"}const Ddt=3e3;function Qdt({onSelectFile:t}){const e=hw(),{tree:n,invalidateTree:r}=jd(),i=C.useMemo(()=>Rdt(e),[e]),s=Idt(i),a=C.useMemo(()=>Mee(n,e),[n,e]),{data:o,isLoading:l,error:c}=fht(e),h=dht(),{jsxDescriptors:d,componentMeta:m}=hht(),[g,x]=C.useState({}),[O,w]=C.useState({}),[E,S]=C.useState(""),[_,P]=C.useState(""),[A,k]=C.useState(!1),I=C.useRef(null),$=C.useRef(""),L=C.useRef({}),Q=C.useRef(""),{data:H}=qT(),j=H?.collections??{},F=H?.error,W=C.useMemo(()=>Bwe(e,j),[e,j]),ee=WT(),G=XT(),re=C.useMemo(()=>cdt(e,j,ee,G),[e,j,ee,G]),he=C.useMemo(()=>W&&W.length>0?W:s?Zge(g):W,[W,s,g]);C.useEffect(()=>{if(o!==void 0){if(s){const Te=Ndt(o.content,i);x(Te),w(Te),L.current=Te,Q.current="",S(""),P(""),$.current=""}else{const Te=tdt(o.content),me=Te?rdt(Te):{},Ne=ndt(o.content),{esm:Le,content:Ve}=Bht(Ne);x(me),w(me),L.current=me,Q.current=Le,S(Ve),P(Ve),$.current=Ve}k(!0)}},[o,s,i]);const be=E!==_||JSON.stringify(g)!==JSON.stringify(O),q=C.useRef(0),J=C.useCallback(async()=>{const Te=L.current,me=$.current,Ne=O;let Le;if(s)Le=$dt(Te,i);else{const Ve=jht(Q.current,me);Le=sdt(Te,Ve)}await h.mutateAsync({path:e,content:Le}),q.current=Date.now(),P(me),w(Te),re.length>0&&udt(re,Ne,Te)&&r()},[e,h,s,i,O,re,r]);C.useEffect(()=>{function Te(me){if((me.metaKey||me.ctrlKey)&&me.key==="s"){me.preventDefault();const Ne=JSON.stringify(L.current)!==JSON.stringify(O),Le=$.current!==_;(Ne||Le)&&J()}}return window.addEventListener("keydown",Te),()=>window.removeEventListener("keydown",Te)},[O,_,J]),C.useEffect(()=>{if(!A||!be||h.isPending)return;const Te=Math.max(0,Ddt-(Date.now()-q.current)),me=setTimeout(()=>{J()},Te);return()=>clearTimeout(me)},[A,be,h.isPending,E,g,J]);const ce=C.useCallback(Te=>{S(Te),$.current=Te},[]),X=C.useCallback(Te=>{x(Te),L.current=Te},[]),Me=C.useMemo(()=>d?Fht({filePath:e,jsxDescriptors:d,originalContent:_}):void 0,[e,d,A]),Be=s?l||!A:l||!A||!Me;return M.jsxs("div",{className:"flex flex-col h-full",children:[M.jsx(ldt,{isDirty:be,isSaving:h.isPending,localeSiblings:a,onSelectFile:t}),F&&M.jsxs("div",{className:"mb-2 px-3 py-2 rounded-md border border-yellow-400 bg-yellow-50 text-sm text-yellow-900",children:[M.jsx("span",{className:"font-semibold",children:"Schema parsing failed:"})," ",F]}),M.jsx("div",{className:"flex-1 flex flex-col border border-border rounded-md overflow-auto bg-bg -mt-px",children:c?M.jsxs("div",{className:"p-5 text-red-500",children:["File not found: ",e]}):Be?M.jsx("div",{className:"p-5 text-text-muted",children:"Loading..."}):M.jsxs(M.Fragment,{children:[he&&he.length>0&&M.jsx(Zht,{schema:he,frontmatter:g,onChange:X}),!s&&M.jsx(_S.Provider,{value:m,children:M.jsx(Xqe,{ref:I,markdown:_,onChange:ce,contentEditableClassName:"mdxeditor-rich-text",plugins:Me,className:"flex-1 bg-white"})})]})})]})}function $X({children:t,content:e,side:n="top",className:r}){const[i,s]=C.useState(!1);return M.jsxs("span",{className:`relative inline-flex ${r??""}`,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),onFocus:()=>s(!0),onBlur:()=>s(!1),children:[t,i&&M.jsx("span",{role:"tooltip",className:`absolute left-1/2 -translate-x-1/2 px-2 py-1 rounded bg-text text-white text-[11px] font-normal whitespace-nowrap pointer-events-none z-50 ${n==="top"?"bottom-full mb-2":"top-full mt-2"}`,children:e})]})}function Fdt(t){const e=[];let n=null;for(const r of t.split(`
506
506
  `))if(!(r.startsWith("diff --git")||r.startsWith("index ")||r.startsWith("--- ")||r.startsWith("+++ ")||r.startsWith("new file mode")||r.startsWith("deleted file mode")||r.startsWith("old mode")||r.startsWith("new mode")||r.startsWith("similarity index")||r.startsWith("rename from")||r.startsWith("rename to")||r.startsWith("copy from")||r.startsWith("copy to"))){if(r.startsWith("@@")){n&&e.push(n),n={header:r,lines:[],raw:r+`
507
507
  `};continue}n&&(n.raw+=r+`
508
- `,r.startsWith("+")?n.lines.push({kind:"add",text:r.slice(1)}):r.startsWith("-")?n.lines.push({kind:"remove",text:r.slice(1)}):r.startsWith(" ")?n.lines.push({kind:"context",text:r.slice(1)}):r.startsWith("\\")&&n.lines.push({kind:"nonewline",text:r}))}return n&&e.push(n),e}function Vdt({path:t,diff:e}){const n=C.useMemo(()=>Fdt(e),[e]),r=nDe(),[i,s]=C.useState(null),[a,o]=C.useState(null);if(n.length===0)return M.jsx("div",{className:"px-4 py-6 text-xs text-text-muted text-center",children:"No changes to display."});function l(c,h){if(a!==c){o(c);return}s(c),r.mutate({path:t,hunk:h.raw},{onSettled:()=>{s(null),o(null)}})}return M.jsxs("div",{className:"divide-y divide-border",children:[n.map((c,h)=>{const d=i===h,m=a===h;return M.jsxs("div",{children:[M.jsxs("div",{className:"flex items-center gap-3 px-4 py-1 bg-blue-50 border-y border-blue-100",children:[M.jsx("code",{className:"text-[11px] text-blue-700 flex-1 font-mono truncate",children:c.header}),m?M.jsxs("div",{className:"flex items-center gap-1",children:[M.jsx("button",{type:"button",onClick:()=>l(h,c),disabled:d,"aria-label":"Confirm discard hunk",tabIndex:0,className:"text-[11px] font-semibold text-danger border border-danger rounded px-2 py-0.5 hover:bg-red-50 disabled:opacity-50 cursor-pointer",children:d?"...":"Confirm discard"}),M.jsx("button",{type:"button",onClick:()=>o(null),"aria-label":"Cancel",tabIndex:0,className:"text-[11px] text-text-muted border border-border rounded px-2 py-0.5 hover:bg-gray-100 cursor-pointer",children:"Cancel"})]}):M.jsxs("button",{type:"button",onClick:()=>l(h,c),"aria-label":"Discard this hunk",tabIndex:0,className:"inline-flex items-center gap-1 text-[11px] text-text-muted hover:text-danger rounded px-1.5 py-0.5 cursor-pointer",children:[M.jsx(yee,{size:11}),"Discard"]})]}),M.jsx("pre",{className:"font-mono text-xs leading-5",children:c.lines.map((g,x)=>{if(g.kind==="nonewline")return M.jsx("div",{className:"px-4 py-0.5 text-text-muted",children:g.text},x);const O=g.kind==="add"?"bg-green-50":g.kind==="remove"?"bg-red-50":"",w=g.kind==="add"?"+":g.kind==="remove"?"-":" ",E=g.kind==="add"?"text-green-700":g.kind==="remove"?"text-red-700":"text-text-muted";return M.jsxs("div",{className:`flex px-4 ${O}`,children:[M.jsx("span",{className:`inline-block w-4 shrink-0 select-none ${E}`,children:w}),M.jsx("span",{className:"whitespace-pre",children:g.text||" "})]},x)})})]},h)}),r.error&&M.jsx("div",{className:"px-4 py-2 text-xs text-danger",children:r.error.message})]})}const Bdt={M:"Modified",A:"Added",D:"Deleted",R:"Renamed","?":"Untracked",U:"Unmerged"};function jdt(t){return t==="D"?"bg-red-100 text-red-700":t==="A"||t==="?"?"bg-green-100 text-green-700":"bg-blue-100 text-blue-700"}function Hdt({file:t,diff:e}){const n=Aae(),r=Pae(),i=tDe(),[s,a]=C.useState(!1);function o(h){h?n.mutate([t.path]):r.mutate([t.path])}function l(h){h.target.closest("button, input")||o(!t.staged)}function c(h){h.stopPropagation(),s?(i.mutate(t.path),a(!1)):a(!0)}return M.jsxs("section",{id:`file-${t.path}`,className:"rounded-lg border border-border bg-white overflow-hidden",children:[M.jsxs("header",{onClick:l,className:"flex items-center gap-3 px-4 py-2.5 border-b border-border bg-gray-50 sticky top-0 z-10 cursor-pointer select-none hover:bg-gray-100",children:[M.jsx("input",{type:"checkbox",checked:t.staged,onChange:h=>o(h.target.checked),onClick:h=>h.stopPropagation(),className:"accent-primary w-4 h-4 cursor-pointer","aria-label":`Include ${t.path}`}),M.jsx("span",{className:`inline-block text-[10px] font-semibold px-2 py-0.5 rounded-full ${jdt(t.status)}`,children:Bdt[t.status]||t.status}),M.jsx("span",{className:"font-mono text-xs flex-1 truncate",title:t.path,children:t.path}),s?M.jsxs("div",{className:"flex gap-1",children:[M.jsx(Di,{size:"sm",className:"border-danger! text-danger! hover:bg-red-50!",onClick:c,children:"Confirm discard file"}),M.jsx(Di,{size:"sm",onClick:h=>{h.stopPropagation(),a(!1)},children:"Cancel"})]}):M.jsxs("button",{type:"button",onClick:c,className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-danger px-2 py-1 rounded cursor-pointer","aria-label":`Discard all changes for ${t.path}`,tabIndex:0,children:[M.jsx(yee,{size:12}),"Discard file"]})]}),M.jsx(Vdt,{path:t.path,diff:e})]})}function Zdt(){const t=ya(),{data:e=[],isLoading:n}=Tae(),{data:r={}}=Gze(),i=Jze(),s=Aae(),a=Pae(),{isAuthenticated:o,sendInNewConversation:l,isRunning:c}=lP(),[h,d]=C.useState(""),g=e.filter(P=>P.staged).length,x=h.trim().length>0&&g>0,O=e.length>0&&e.every(P=>P.staged);function w(){if(O)a.mutate(e.map(P=>P.path));else{const P=e.filter(A=>!A.staged).map(A=>A.path);P.length&&s.mutate(P)}}function E(){t.invalidateQueries({queryKey:["gitStatus"]}),t.invalidateQueries({queryKey:["gitDiffs"]})}async function S(P){if(x)try{await i.mutateAsync({message:h.trim(),push:P}),d("")}catch{}}function _(){if(c)return;l("Commit the staged files with a concise conventional commit message that explains WHY, then push.")}return M.jsxs("div",{className:"flex flex-col h-full relative",children:[M.jsxs("div",{className:"flex-1 overflow-auto px-6 pt-6 pb-40",children:[M.jsxs("div",{className:"pb-3 flex items-center gap-3",children:[M.jsx("h1",{className:"text-lg font-semibold",children:"Review changes"}),M.jsxs("span",{className:"text-xs text-text-muted",children:[e.length," file",e.length===1?"":"s"," changed",g>0&&` · ${g} staged`]}),M.jsx("div",{className:"flex-1"}),M.jsx("button",{type:"button",onClick:E,className:"p-1.5 rounded text-text-muted hover:text-text hover:bg-gray-100 cursor-pointer","aria-label":"Refresh",tabIndex:0,children:M.jsx(Mwe,{size:14})})]}),e.length>0&&M.jsx("div",{className:"pb-4",children:M.jsxs("label",{className:"flex items-center gap-2.5 text-sm font-medium cursor-pointer select-none",children:[M.jsx("input",{type:"checkbox",checked:O,onChange:w,className:"accent-primary w-4 h-4"}),"Include all"]})}),n?M.jsx("div",{className:"text-xs text-text-muted py-10 text-center",children:"Loading..."}):e.length===0?M.jsxs("div",{className:"text-sm text-text-muted py-16 text-center",children:["Working tree is clean.",M.jsx("br",{}),"Nothing to commit."]}):M.jsx("div",{className:"flex flex-col gap-4",children:e.map(P=>M.jsx(Hdt,{file:P,diff:r[P.path]??""},P.path))})]}),e.length>0&&M.jsx("div",{className:"absolute left-0 right-0 bottom-0 z-20 border-t border-border bg-white px-6 py-3 shadow-[0_-4px_12px_-4px_rgba(0,0,0,0.08)]",children:M.jsxs("div",{className:"flex flex-col gap-3 max-w-5xl mx-auto",children:[o&&g>0&&M.jsx($X,{content:"Agent will generate a commit message and push",children:M.jsxs("button",{type:"button",onClick:_,disabled:c,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-gradient-to-r from-indigo-600 to-primary text-white shadow-md enabled:hover:opacity-95 enabled:cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed",tabIndex:0,children:[M.jsx(qie,{size:16}),M.jsx("span",{className:"font-semibold text-sm",children:c?"AI is working...":`Publish (${g})`})]})}),M.jsxs("div",{className:"flex gap-2",children:[M.jsx("input",{value:h,onChange:P=>d(P.target.value),onKeyDown:P=>{P.key==="Enter"&&!P.shiftKey&&x&&(P.preventDefault(),S(!0))},placeholder:o&&g>0?"or enter manual commit message...":"Enter commit message...",className:"flex-1 px-3 py-2 border border-border rounded-md text-sm outline-none focus:border-primary"}),M.jsx($X,{content:"Commit & push",children:M.jsx(Di,{variant:"success",onClick:()=>S(!0),disabled:!x||i.isPending,children:i.isPending?"...":`Publish (${g})`})})]}),i.error&&M.jsx("div",{className:"text-xs text-danger",children:i.error.message})]})})]})}function Udt(){return M.jsx("div",{className:"text-text-muted p-10 text-center",children:"Select a file from the sidebar to edit"})}function qdt({filePath:t,onSelectFile:e}){return M.jsxs(rye,{children:[M.jsx(CO,{path:"/",element:M.jsx(Udt,{})}),M.jsx(CO,{path:"/git",element:M.jsx(Zdt,{})}),M.jsx(CO,{path:"/edit/*",element:M.jsx(Qdt,{onSelectFile:e},t)})]})}function Xdt(t,e=!1){const[n,r]=C.useState(()=>{const i=localStorage.getItem(t);return i!==null?i==="true":e});return C.useEffect(()=>{localStorage.setItem(t,String(n))},[t,n]),[n,r]}function Wdt(){const[t,e]=Xdt("cms-agent-panel-open");function n(){e(!t)}return{agentOpen:t,setAgentOpen:e,toggleAgent:n}}function Ydt(){const t=ro();return t.pathname.startsWith("/edit/")&&decodeURIComponent(t.pathname.slice(6))||null}function Gdt(){const t=E4(),e=ro(),n=Ydt(),{agentOpen:r,setAgentOpen:i,toggleAgent:s}=Wdt();Yze();const a=C.useCallback(()=>i(!0),[i]);function o(h){t(`/edit/${h}`)}const c=e.pathname.startsWith("/git")?"flex-1 overflow-hidden bg-bg-main flex flex-col":"flex-1 overflow-auto p-4 bg-bg-main";return M.jsx(Zze,{onRequestOpen:a,children:M.jsx(iSe,{filePath:n,children:M.jsxs(Xze,{filePath:n,children:[M.jsx(iDe,{agentOpen:r,onToggleAgent:s,onNavigateGit:()=>t("/git")}),M.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[M.jsx(fSe,{onSelectFile:o}),M.jsx("main",{className:c,children:M.jsx(qdt,{filePath:n,onSelectFile:o})}),M.jsx(qze,{open:r})]})]})})})}function Kdt({children:t}){const[e,n]=C.useState("loading"),[r,i]=C.useState(""),[s,a]=C.useState(null),[o,l]=C.useState(!1);C.useEffect(()=>{let h=!1;return jxe().then(d=>{h||n(!d.required||d.authenticated?"ok":"gated")}).catch(()=>{h||n("gated")}),()=>{h=!0}},[]),C.useEffect(()=>Bxe(()=>n("gated")),[]);async function c(h){if(h.preventDefault(),!r)return;l(!0),a(null);const d=await Hxe(r);l(!1),d.ok?(i(""),n("ok")):a(d.error??"Invalid password")}return e==="loading"?M.jsx("div",{className:"flex h-screen items-center justify-center text-text-muted",children:"Chargement…"}):e==="gated"?M.jsx("div",{className:"flex h-screen items-center justify-center bg-bg-main",children:M.jsxs("form",{onSubmit:c,className:"flex w-80 flex-col gap-3 rounded-md border border-border bg-white p-6 shadow-sm",children:[M.jsx("h1",{className:"text-lg font-semibold",children:"AstroCMS"}),M.jsx("label",{htmlFor:"astrocms-password",className:"text-sm text-text-muted",children:"Mot de passe"}),M.jsx("input",{id:"astrocms-password",type:"password",value:r,onChange:h=>i(h.target.value),autoFocus:!0,autoComplete:"current-password",className:"rounded-md border border-border bg-white px-2 py-1 text-sm outline-none focus:border-primary"}),s&&M.jsx("p",{className:"text-sm text-danger",children:s}),M.jsx(Di,{type:"submit",variant:"primary",disabled:o||!r,children:o?"…":"Se connecter"})]})}):M.jsx(M.Fragment,{children:t})}function Jdt(){return M.jsx(Kdt,{children:M.jsx(Awe,{children:M.jsx($we,{children:M.jsx(Gdt,{})})})})}window.Prism=J2e;const ept=new oxe;ave.createRoot(document.getElementById("root")).render(M.jsx(p.StrictMode,{children:M.jsx(lxe,{client:ept,children:M.jsx(Cye,{basename:"/astrocms",children:M.jsx(Jdt,{})})})}));export{cpe as C,Oa as E,kn as I,$d as L,Zfe as N,zd as a,hrt as b,ob as c,xde as d,Fd as e,tp as f,Fn as g,t4 as h,ep as i,Ant as j,Gfe as k,AR as l,As as m,Ze as n,Ce as o,Wpe as p,Ufe as q,mpe as r,Jd as s,Y as t,fde as u,Ya as v};
508
+ `,r.startsWith("+")?n.lines.push({kind:"add",text:r.slice(1)}):r.startsWith("-")?n.lines.push({kind:"remove",text:r.slice(1)}):r.startsWith(" ")?n.lines.push({kind:"context",text:r.slice(1)}):r.startsWith("\\")&&n.lines.push({kind:"nonewline",text:r}))}return n&&e.push(n),e}function Vdt({path:t,diff:e}){const n=C.useMemo(()=>Fdt(e),[e]),r=nDe(),[i,s]=C.useState(null),[a,o]=C.useState(null);if(n.length===0)return M.jsx("div",{className:"px-4 py-6 text-xs text-text-muted text-center",children:"No changes to display."});function l(c,h){if(a!==c){o(c);return}s(c),r.mutate({path:t,hunk:h.raw},{onSettled:()=>{s(null),o(null)}})}return M.jsxs("div",{className:"divide-y divide-border",children:[n.map((c,h)=>{const d=i===h,m=a===h;return M.jsxs("div",{children:[M.jsxs("div",{className:"flex items-center gap-3 px-4 py-1 bg-blue-50 border-y border-blue-100",children:[M.jsx("code",{className:"text-[11px] text-blue-700 flex-1 font-mono truncate",children:c.header}),m?M.jsxs("div",{className:"flex items-center gap-1",children:[M.jsx("button",{type:"button",onClick:()=>l(h,c),disabled:d,"aria-label":"Confirm discard hunk",tabIndex:0,className:"text-[11px] font-semibold text-danger border border-danger rounded px-2 py-0.5 hover:bg-red-50 disabled:opacity-50 cursor-pointer",children:d?"...":"Confirm discard"}),M.jsx("button",{type:"button",onClick:()=>o(null),"aria-label":"Cancel",tabIndex:0,className:"text-[11px] text-text-muted border border-border rounded px-2 py-0.5 hover:bg-gray-100 cursor-pointer",children:"Cancel"})]}):M.jsxs("button",{type:"button",onClick:()=>l(h,c),"aria-label":"Discard this hunk",tabIndex:0,className:"inline-flex items-center gap-1 text-[11px] text-text-muted hover:text-danger rounded px-1.5 py-0.5 cursor-pointer",children:[M.jsx(yee,{size:11}),"Discard"]})]}),M.jsx("pre",{className:"font-mono text-xs leading-5",children:c.lines.map((g,x)=>{if(g.kind==="nonewline")return M.jsx("div",{className:"px-4 py-0.5 text-text-muted",children:g.text},x);const O=g.kind==="add"?"bg-green-50":g.kind==="remove"?"bg-red-50":"",w=g.kind==="add"?"+":g.kind==="remove"?"-":" ",E=g.kind==="add"?"text-green-700":g.kind==="remove"?"text-red-700":"text-text-muted";return M.jsxs("div",{className:`flex px-4 ${O}`,children:[M.jsx("span",{className:`inline-block w-4 shrink-0 select-none ${E}`,children:w}),M.jsx("span",{className:"whitespace-pre-wrap break-all min-w-0 flex-1",children:g.text||" "})]},x)})})]},h)}),r.error&&M.jsx("div",{className:"px-4 py-2 text-xs text-danger",children:r.error.message})]})}const Bdt={M:"Modified",A:"Added",D:"Deleted",R:"Renamed","?":"Untracked",U:"Unmerged"};function jdt(t){return t==="D"?"bg-red-100 text-red-700":t==="A"||t==="?"?"bg-green-100 text-green-700":"bg-blue-100 text-blue-700"}function Hdt({file:t,diff:e}){const n=Aae(),r=Pae(),i=tDe(),[s,a]=C.useState(!1);function o(h){h?n.mutate([t.path]):r.mutate([t.path])}function l(h){h.target.closest("button, input")||o(!t.staged)}function c(h){h.stopPropagation(),s?(i.mutate(t.path),a(!1)):a(!0)}return M.jsxs("section",{id:`file-${t.path}`,className:"rounded-lg border border-border bg-white overflow-hidden",children:[M.jsxs("header",{onClick:l,className:"flex items-center gap-3 px-4 py-2.5 border-b border-border bg-gray-50 sticky top-0 z-10 cursor-pointer select-none hover:bg-gray-100",children:[M.jsx("input",{type:"checkbox",checked:t.staged,onChange:h=>o(h.target.checked),onClick:h=>h.stopPropagation(),className:"accent-primary w-4 h-4 cursor-pointer","aria-label":`Include ${t.path}`}),M.jsx("span",{className:`inline-block text-[10px] font-semibold px-2 py-0.5 rounded-full ${jdt(t.status)}`,children:Bdt[t.status]||t.status}),M.jsx("span",{className:"font-mono text-xs flex-1 truncate",title:t.path,children:t.path}),s?M.jsxs("div",{className:"flex gap-1",children:[M.jsx(Di,{size:"sm",className:"border-danger! text-danger! hover:bg-red-50!",onClick:c,children:"Confirm discard file"}),M.jsx(Di,{size:"sm",onClick:h=>{h.stopPropagation(),a(!1)},children:"Cancel"})]}):M.jsxs("button",{type:"button",onClick:c,className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-danger px-2 py-1 rounded cursor-pointer","aria-label":`Discard all changes for ${t.path}`,tabIndex:0,children:[M.jsx(yee,{size:12}),"Discard file"]})]}),M.jsx(Vdt,{path:t.path,diff:e})]})}function Zdt(){const t=ya(),{data:e=[],isLoading:n}=Tae(),{data:r={}}=Gze(),i=Jze(),s=Aae(),a=Pae(),{isAuthenticated:o,sendInNewConversation:l,isRunning:c}=lP(),[h,d]=C.useState(""),g=e.filter(P=>P.staged).length,x=h.trim().length>0&&g>0,O=e.length>0&&e.every(P=>P.staged);function w(){if(O)a.mutate(e.map(P=>P.path));else{const P=e.filter(A=>!A.staged).map(A=>A.path);P.length&&s.mutate(P)}}function E(){t.invalidateQueries({queryKey:["gitStatus"]}),t.invalidateQueries({queryKey:["gitDiffs"]})}async function S(P){if(x)try{await i.mutateAsync({message:h.trim(),push:P}),d("")}catch{}}function _(){if(c)return;l("Commit the staged files with a concise conventional commit message that explains WHY, then push.")}return M.jsxs("div",{className:"flex flex-col h-full relative",children:[M.jsxs("div",{className:"flex-1 overflow-auto px-6 pt-6 pb-40",children:[M.jsxs("div",{className:"pb-3 flex items-center gap-3",children:[M.jsx("h1",{className:"text-lg font-semibold",children:"Review changes"}),M.jsxs("span",{className:"text-xs text-text-muted",children:[e.length," file",e.length===1?"":"s"," changed",g>0&&` · ${g} staged`]}),M.jsx("div",{className:"flex-1"}),M.jsx("button",{type:"button",onClick:E,className:"p-1.5 rounded text-text-muted hover:text-text hover:bg-gray-100 cursor-pointer","aria-label":"Refresh",tabIndex:0,children:M.jsx(Mwe,{size:14})})]}),e.length>0&&M.jsx("div",{className:"pb-4",children:M.jsxs("label",{className:"flex items-center gap-2.5 text-sm font-medium cursor-pointer select-none",children:[M.jsx("input",{type:"checkbox",checked:O,onChange:w,className:"accent-primary w-4 h-4"}),"Include all"]})}),n?M.jsx("div",{className:"text-xs text-text-muted py-10 text-center",children:"Loading..."}):e.length===0?M.jsxs("div",{className:"text-sm text-text-muted py-16 text-center",children:["Working tree is clean.",M.jsx("br",{}),"Nothing to commit."]}):M.jsx("div",{className:"flex flex-col gap-4",children:e.map(P=>M.jsx(Hdt,{file:P,diff:r[P.path]??""},P.path))})]}),e.length>0&&M.jsx("div",{className:"absolute left-0 right-0 bottom-0 z-20 border-t border-border bg-white px-6 py-3 shadow-[0_-4px_12px_-4px_rgba(0,0,0,0.08)]",children:M.jsxs("div",{className:"flex flex-col gap-3 max-w-5xl mx-auto",children:[o&&g>0&&M.jsx($X,{content:"Agent will generate a commit message and push",children:M.jsxs("button",{type:"button",onClick:_,disabled:c,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-gradient-to-r from-indigo-600 to-primary text-white shadow-md enabled:hover:opacity-95 enabled:cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed",tabIndex:0,children:[M.jsx(qie,{size:16}),M.jsx("span",{className:"font-semibold text-sm",children:c?"AI is working...":`Publish (${g})`})]})}),M.jsxs("div",{className:"flex gap-2",children:[M.jsx("input",{value:h,onChange:P=>d(P.target.value),onKeyDown:P=>{P.key==="Enter"&&!P.shiftKey&&x&&(P.preventDefault(),S(!0))},placeholder:o&&g>0?"or enter manual commit message...":"Enter commit message...",className:"flex-1 px-3 py-2 border border-border rounded-md text-sm outline-none focus:border-primary"}),M.jsx($X,{content:"Commit & push",children:M.jsx(Di,{variant:"success",onClick:()=>S(!0),disabled:!x||i.isPending,children:i.isPending?"...":`Publish (${g})`})})]}),i.error&&M.jsx("div",{className:"text-xs text-danger",children:i.error.message})]})})]})}function Udt(){return M.jsx("div",{className:"text-text-muted p-10 text-center",children:"Select a file from the sidebar to edit"})}function qdt({filePath:t,onSelectFile:e}){return M.jsxs(rye,{children:[M.jsx(CO,{path:"/",element:M.jsx(Udt,{})}),M.jsx(CO,{path:"/git",element:M.jsx(Zdt,{})}),M.jsx(CO,{path:"/edit/*",element:M.jsx(Qdt,{onSelectFile:e},t)})]})}function Xdt(t,e=!1){const[n,r]=C.useState(()=>{const i=localStorage.getItem(t);return i!==null?i==="true":e});return C.useEffect(()=>{localStorage.setItem(t,String(n))},[t,n]),[n,r]}function Wdt(){const[t,e]=Xdt("cms-agent-panel-open");function n(){e(!t)}return{agentOpen:t,setAgentOpen:e,toggleAgent:n}}function Ydt(){const t=ro();return t.pathname.startsWith("/edit/")&&decodeURIComponent(t.pathname.slice(6))||null}function Gdt(){const t=E4(),e=ro(),n=Ydt(),{agentOpen:r,setAgentOpen:i,toggleAgent:s}=Wdt();Yze();const a=C.useCallback(()=>i(!0),[i]);function o(h){t(`/edit/${h}`)}const c=e.pathname.startsWith("/git")?"flex-1 overflow-hidden bg-bg-main flex flex-col":"flex-1 overflow-auto p-4 bg-bg-main";return M.jsx(Zze,{onRequestOpen:a,children:M.jsx(iSe,{filePath:n,children:M.jsxs(Xze,{filePath:n,children:[M.jsx(iDe,{agentOpen:r,onToggleAgent:s,onNavigateGit:()=>t("/git")}),M.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[M.jsx(fSe,{onSelectFile:o}),M.jsx("main",{className:c,children:M.jsx(qdt,{filePath:n,onSelectFile:o})}),M.jsx(qze,{open:r})]})]})})})}function Kdt({children:t}){const[e,n]=C.useState("loading"),[r,i]=C.useState(""),[s,a]=C.useState(null),[o,l]=C.useState(!1);C.useEffect(()=>{let h=!1;return jxe().then(d=>{h||n(!d.required||d.authenticated?"ok":"gated")}).catch(()=>{h||n("gated")}),()=>{h=!0}},[]),C.useEffect(()=>Bxe(()=>n("gated")),[]);async function c(h){if(h.preventDefault(),!r)return;l(!0),a(null);const d=await Hxe(r);l(!1),d.ok?(i(""),n("ok")):a(d.error??"Invalid password")}return e==="loading"?M.jsx("div",{className:"flex h-screen items-center justify-center text-text-muted",children:"Chargement…"}):e==="gated"?M.jsx("div",{className:"flex h-screen items-center justify-center bg-bg-main",children:M.jsxs("form",{onSubmit:c,className:"flex w-80 flex-col gap-3 rounded-md border border-border bg-white p-6 shadow-sm",children:[M.jsx("h1",{className:"text-lg font-semibold",children:"AstroCMS"}),M.jsx("label",{htmlFor:"astrocms-password",className:"text-sm text-text-muted",children:"Mot de passe"}),M.jsx("input",{id:"astrocms-password",type:"password",value:r,onChange:h=>i(h.target.value),autoFocus:!0,autoComplete:"current-password",className:"rounded-md border border-border bg-white px-2 py-1 text-sm outline-none focus:border-primary"}),s&&M.jsx("p",{className:"text-sm text-danger",children:s}),M.jsx(Di,{type:"submit",variant:"primary",disabled:o||!r,children:o?"…":"Se connecter"})]})}):M.jsx(M.Fragment,{children:t})}function Jdt(){return M.jsx(Kdt,{children:M.jsx(Awe,{children:M.jsx($we,{children:M.jsx(Gdt,{})})})})}window.Prism=J2e;const ept=new oxe;ave.createRoot(document.getElementById("root")).render(M.jsx(p.StrictMode,{children:M.jsx(lxe,{client:ept,children:M.jsx(Cye,{basename:"/astrocms",children:M.jsx(Jdt,{})})})}));export{cpe as C,Oa as E,kn as I,$d as L,Zfe as N,zd as a,hrt as b,ob as c,xde as d,Fd as e,tp as f,Fn as g,t4 as h,ep as i,Ant as j,Gfe as k,AR as l,As as m,Ze as n,Ce as o,Wpe as p,Ufe as q,mpe as r,Jd as s,Y as t,fde as u,Ya as v};