import{parser as l}from"@lezer/php";import{parseMixed as i}from"@lezer/common";import{html as p}from"@codemirror/lang-html";import{LRLanguage as u,indentNodeProp as d,continuedIndent as r,delimitedIndent as m,foldNodeProp as f,foldInside as c,LanguageSupport as g}from"@codemirror/language";const a=u.define({name:"php",parser:l.configure({props:[d.add({IfStatement:r({except:/^\s*({|else\b|elseif\b|endif\b)/}),TryStatement:r({except:/^\s*({|catch\b|finally\b)/}),SwitchBody:e=>{let o=e.textAfter,t=/^\s*\}/.test(o),n=/^\s*(case|default)\b/.test(o);return e.baseIndent+(t?0:n?1:2)*e.unit},ColonBlock:e=>e.baseIndent+e.unit,"Block EnumBody DeclarationList":m({closing:"}"}),ArrowFunction:e=>e.baseIndent+e.unit,"String BlockComment":()=>null,Statement:r({except:/^({|end(for|foreach|switch|while)\b)/})}),f.add({"Block EnumBody DeclarationList SwitchBody ArrayExpression ValueList":c,ColonBlock(e){return{from:e.from+1,to:e.to}},BlockComment(e){return{from:e.from+2,to:e.to-2}}})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"},line:"//"},indentOnInput:/^\s*(?:case |default:|end(?:if|for(?:each)?|switch|while)|else(?:if)?|\{|\})$/,wordChars:"$",closeBrackets:{stringPrefixes:["b","B"]}}});function h(e={}){let o=[],t;if(e.baseLanguage!==null)if(e.baseLanguage)t=e.baseLanguage;else{let n=p({matchClosingTags:!1});o.push(n.support),t=n.language}return new g(a.configure({wrap:t&&i(n=>n.type.isTop?{parser:t.parser,overlay:s=>s.name=="Text"}:null),top:e.plain?"Program":"Template"}),o)}export{h as php,a as phpLanguage};
