@beechcms/api 0.4.2 → 0.4.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.
@@ -626,4 +626,4 @@ Please report this to https://github.com/markedjs/marked.`,t){let s="<p>An error
626
626
  https://github.com/highlightjs/highlight.js/issues/2277`),Cr=Ge,On=_t),tn===void 0&&(tn=!0);const Wt={code:On,language:Cr};oi("before:highlight",Wt);const Yn=Wt.result?Wt.result:xe(Wt.language,Wt.code,tn);return Yn.code=Wt.code,oi("after:highlight",Yn),Yn}function xe(Ge,_t,tn,On){const Cr=Object.create(null);function Wt(nt,Tt){return nt.keywords[Tt]}function Yn(){if(!Kt.keywords){ys.addText(er);return}let nt=0;Kt.keywordPatternRe.lastIndex=0;let Tt=Kt.keywordPatternRe.exec(er),an="";for(;Tt;){an+=er.substring(nt,Tt.index);const En=Ks.case_insensitive?Tt[0].toLowerCase():Tt[0],Br=Wt(Kt,En);if(Br){const[jo,u0]=Br;if(ys.addText(an),an="",Cr[En]=(Cr[En]||0)+1,Cr[En]<=gt&&(jc+=u0),jo.startsWith("_"))an+=Tt[0];else{const v1=Ks.classNameAliases[jo]||jo;kn(Tt[0],v1)}}else an+=Tt[0];nt=Kt.keywordPatternRe.lastIndex,Tt=Kt.keywordPatternRe.exec(er)}an+=er.substring(nt),ys.addText(an)}function cs(){if(er==="")return;let nt=null;if(typeof Kt.subLanguage=="string"){if(!K[Kt.subLanguage]){ys.addText(er);return}nt=xe(Kt.subLanguage,er,!0,y1[Kt.subLanguage]),y1[Kt.subLanguage]=nt._top}else nt=Xe(er,Kt.subLanguage.length?Kt.subLanguage:null);Kt.relevance>0&&(jc+=nt.relevance),ys.__addSublanguage(nt._emitter,nt.language)}function Dn(){Kt.subLanguage!=null?cs():Yn(),er=""}function kn(nt,Tt){nt!==""&&(ys.startScope(Tt),ys.addText(nt),ys.endScope())}function _l(nt,Tt){let an=1;const En=Tt.length-1;for(;an<=En;){if(!nt._emit[an]){an++;continue}const Br=Ks.classNameAliases[nt[an]]||nt[an],jo=Tt[an];Br?kn(jo,Br):(er=jo,Yn(),er=""),an++}}function Tl(nt,Tt){return nt.scope&&typeof nt.scope=="string"&&ys.openNode(Ks.classNameAliases[nt.scope]||nt.scope),nt.beginScope&&(nt.beginScope._wrap?(kn(er,Ks.classNameAliases[nt.beginScope._wrap]||nt.beginScope._wrap),er=""):nt.beginScope._multi&&(_l(nt.beginScope,Tt),er="")),Kt=Object.create(nt,{parent:{value:Kt}}),Kt}function ud(nt,Tt,an){let En=M(nt.endRe,an);if(En){if(nt["on:end"]){const Br=new t(nt);nt["on:end"](Tt,Br),Br.isMatchIgnored&&(En=!1)}if(En){for(;nt.endsParent&&nt.parent;)nt=nt.parent;return nt}}if(nt.endsWithParent)return ud(nt.parent,Tt,an)}function Ff(nt){return Kt.matcher.regexIndex===0?(er+=nt[0],1):(Ic=!0,0)}function Bw(nt){const Tt=nt[0],an=nt.rule,En=new t(an),Br=[an.__beforeBegin,an["on:begin"]];for(const jo of Br)if(jo&&(jo(nt,En),En.isMatchIgnored))return Ff(Tt);return an.skip?er+=Tt:(an.excludeBegin&&(er+=Tt),Dn(),!an.returnBegin&&!an.excludeBegin&&(er=Tt)),Tl(an,nt),an.returnBegin?0:Tt.length}function Gi(nt){const Tt=nt[0],an=_t.substring(nt.index),En=ud(Kt,nt,an);if(!En)return Bt;const Br=Kt;Kt.endScope&&Kt.endScope._wrap?(Dn(),kn(Tt,Kt.endScope._wrap)):Kt.endScope&&Kt.endScope._multi?(Dn(),_l(Kt.endScope,nt)):Br.skip?er+=Tt:(Br.returnEnd||Br.excludeEnd||(er+=Tt),Dn(),Br.excludeEnd&&(er=Tt));do Kt.scope&&ys.closeNode(),!Kt.skip&&!Kt.subLanguage&&(jc+=Kt.relevance),Kt=Kt.parent;while(Kt!==En.parent);return En.starts&&Tl(En.starts,nt),Br.returnEnd?0:Tt.length}function l0(){const nt=[];for(let Tt=Kt;Tt!==Ks;Tt=Tt.parent)Tt.scope&&nt.unshift(Tt.scope);nt.forEach(Tt=>ys.openNode(Tt))}let dd={};function Bf(nt,Tt){const an=Tt&&Tt[0];if(er+=nt,an==null)return Dn(),0;if(dd.type==="begin"&&Tt.type==="end"&&dd.index===Tt.index&&an===""){if(er+=_t.slice(Tt.index,Tt.index+1),!pt){const En=new Error(`0 width match regex (${Ge})`);throw En.languageName=Ge,En.badRule=dd.rule,En}return 1}if(dd=Tt,Tt.type==="begin")return Bw(Tt);if(Tt.type==="illegal"&&!tn){const En=new Error('Illegal lexeme "'+an+'" for mode "'+(Kt.scope||"<unnamed>")+'"');throw En.mode=Kt,En}else if(Tt.type==="end"){const En=Gi(Tt);if(En!==Bt)return En}if(Tt.type==="illegal"&&an==="")return er+=`
627
627
  `,1;if(c0>1e5&&c0>Tt.index*3)throw new Error("potential infinite loop, way more iterations than matches");return er+=an,an.length}const Ks=Rn(Ge);if(!Ks)throw G(st.replace("{}",Ge)),new Error('Unknown language: "'+Ge+'"');const b1=xn(Ks);let Hf="",Kt=On||b1;const y1={},ys=new it.__emitter(it);l0();let er="",jc=0,Al=0,c0=0,Ic=!1;try{if(Ks.__emitTokens)Ks.__emitTokens(_t,ys);else{for(Kt.matcher.considerAll();;){c0++,Ic?Ic=!1:Kt.matcher.considerAll(),Kt.matcher.lastIndex=Al;const nt=Kt.matcher.exec(_t);if(!nt)break;const Tt=_t.substring(Al,nt.index),an=Bf(Tt,nt);Al=nt.index+an}Bf(_t.substring(Al))}return ys.finalize(),Hf=ys.toHTML(),{language:Ge,value:Hf,relevance:jc,illegal:!1,_emitter:ys,_top:Kt}}catch(nt){if(nt.message&&nt.message.includes("Illegal"))return{language:Ge,value:Sr(_t),illegal:!0,relevance:0,_illegalBy:{message:nt.message,index:Al,context:_t.slice(Al-100,Al+100),mode:nt.mode,resultSoFar:Hf},_emitter:ys};if(pt)return{language:Ge,value:Sr(_t),illegal:!1,relevance:0,errorRaised:nt,_emitter:ys,_top:Kt};throw nt}}function Ue(Ge){const _t={value:Sr(Ge),illegal:!1,relevance:0,_top:Ve,_emitter:new it.__emitter(it)};return _t._emitter.addText(Ge),_t}function Xe(Ge,_t){_t=_t||it.languages||Object.keys(K);const tn=Ue(Ge),On=_t.filter(Rn).filter(wn).map(Dn=>xe(Dn,Ge,!1));On.unshift(tn);const Cr=On.sort((Dn,kn)=>{if(Dn.relevance!==kn.relevance)return kn.relevance-Dn.relevance;if(Dn.language&&kn.language){if(Rn(Dn.language).supersetOf===kn.language)return 1;if(Rn(kn.language).supersetOf===Dn.language)return-1}return 0}),[Wt,Yn]=Cr,cs=Wt;return cs.secondBest=Yn,cs}function vt(Ge,_t,tn){const On=_t&&be[_t]||tn;Ge.classList.add("hljs"),Ge.classList.add(`language-${On}`)}function ot(Ge){let _t=null;const tn=Y(Ge);if(bt(tn))return;if(oi("before:highlightElement",{el:Ge,language:tn}),Ge.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Ge);return}if(Ge.children.length>0&&(it.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(Ge)),it.throwUnescapedHTML))throw new ls("One of your code blocks includes unescaped HTML.",Ge.innerHTML);_t=Ge;const On=_t.textContent,Cr=tn?ce(On,{language:tn,ignoreIllegals:!0}):Xe(On);Ge.innerHTML=Cr.value,Ge.dataset.highlighted="yes",vt(Ge,tn,Cr.language),Ge.result={language:Cr.language,re:Cr.relevance,relevance:Cr.relevance},Cr.secondBest&&(Ge.secondBest={language:Cr.secondBest.language,relevance:Cr.secondBest.relevance}),oi("after:highlightElement",{el:Ge,result:Cr,text:On})}function lt(Ge){it=yt(it,Ge)}const St=()=>{Ct(),ue("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function ht(){Ct(),ue("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let jt=!1;function Ct(){function Ge(){Ct()}if(document.readyState==="loading"){jt||window.addEventListener("DOMContentLoaded",Ge,!1),jt=!0;return}document.querySelectorAll(it.cssSelector).forEach(ot)}function An(Ge,_t){let tn=null;try{tn=_t(P)}catch(On){if(G("Language definition for '{}' could not be registered.".replace("{}",Ge)),pt)G(On);else throw On;tn=Ve}tn.name||(tn.name=Ge),K[Ge]=tn,tn.rawDefinition=_t.bind(null,P),tn.aliases&&Er(tn.aliases,{languageName:Ge})}function pn(Ge){delete K[Ge];for(const _t of Object.keys(be))be[_t]===Ge&&delete be[_t]}function Jn(){return Object.keys(K)}function Rn(Ge){return Ge=(Ge||"").toLowerCase(),K[Ge]||K[be[Ge]]}function Er(Ge,{languageName:_t}){typeof Ge=="string"&&(Ge=[Ge]),Ge.forEach(tn=>{be[tn.toLowerCase()]=_t})}function wn(Ge){const _t=Rn(Ge);return _t&&!_t.disableAutodetect}function Yr(Ge){Ge["before:highlightBlock"]&&!Ge["before:highlightElement"]&&(Ge["before:highlightElement"]=_t=>{Ge["before:highlightBlock"](Object.assign({block:_t.el},_t))}),Ge["after:highlightBlock"]&&!Ge["after:highlightElement"]&&(Ge["after:highlightElement"]=_t=>{Ge["after:highlightBlock"](Object.assign({block:_t.el},_t))})}function cr(Ge){Yr(Ge),Pe.push(Ge)}function Ha(Ge){const _t=Pe.indexOf(Ge);_t!==-1&&Pe.splice(_t,1)}function oi(Ge,_t){const tn=Ge;Pe.forEach(function(On){On[tn]&&On[tn](_t)})}function bs(Ge){return ue("10.7.0","highlightBlock will be removed entirely in v12.0"),ue("10.7.0","Please use highlightElement now."),ot(Ge)}Object.assign(P,{highlight:ce,highlightAuto:Xe,highlightAll:Ct,highlightElement:ot,highlightBlock:bs,configure:lt,initHighlighting:St,initHighlightingOnLoad:ht,registerLanguage:An,unregisterLanguage:pn,listLanguages:Jn,getLanguage:Rn,registerAliases:Er,autoDetection:wn,inherit:yt,addPlugin:cr,removePlugin:Ha}),P.debugMode=function(){pt=!1},P.safeMode=function(){pt=!0},P.versionString=Lt,P.regex={concat:x,lookahead:m,either:C,optional:y,anyNumberOfTimes:b};for(const Ge in Qe)typeof Qe[Ge]=="object"&&e(Qe[Ge]);return Object.assign(P,Qe),P},Re=Pt({});return Re.newInstance=()=>Pt({}),$3=Re,Re.HighlightJS=Re,Re.default=Re,$3}var eze=JIe();const TY=N6(eze);function AY(e,t=[]){return e.flatMap(n=>{const r=[...t,...n.properties?n.properties.className:[]];return n.children?AY(n.children,r):{text:n.value,classes:r}})}function dI(e){return e.value||e.children||[]}function tze(e){return!!TY.getLanguage(e)}function fI({doc:e,name:t,lowlight:n,defaultLanguage:r}){const s=[];return hk(e,i=>i.type.name===t).forEach(i=>{var o;let a=i.pos+1;const l=i.node.attrs.language||r,u=n.listLanguages(),h=l&&(u.includes(l)||tze(l)||(o=n.registered)!=null&&o.call(n,l))?dI(n.highlight(l,i.node.textContent)):dI(n.highlightAuto(i.node.textContent));AY(h).forEach(p=>{const m=a+p.text.length;if(p.classes.length){const b=Bs.inline(a,m,{class:p.classes.join(" ")});s.push(b)}a=m})}),yr.create(e,s)}function nze(e){return typeof e=="function"}function rze({name:e,lowlight:t,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>nze(t[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new Wn({key:new ar("lowlight"),state:{init:(s,{doc:i})=>fI({doc:i,name:e,lowlight:t,defaultLanguage:n}),apply:(s,i,o,a)=>{const l=o.selection.$head.parent.type.name,u=a.selection.$head.parent.type.name,h=hk(o.doc,m=>m.type.name===e),p=hk(a.doc,m=>m.type.name===e);return s.docChanged&&([l,u].includes(e)||p.length!==h.length||s.steps.some(m=>m.from!==void 0&&m.to!==void 0&&h.some(b=>b.pos>=m.from&&b.pos+b.node.nodeSize<=m.to)))?fI({doc:s.doc,name:e,lowlight:t,defaultLanguage:n}):i.map(s.mapping,s.doc)}},props:{decorations(s){return r.getState(s)}}});return r}var sze=bW.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var e;return[...((e=this.parent)==null?void 0:e.call(this))||[],rze({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}});function ize(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",o="(?!struct)("+r+"|"+t.optional(s)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",a={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},h={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},p={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},m={className:"title",begin:t.optional(s)+e.IDENT_RE,relevance:0},b=t.optional(s)+e.IDENT_RE+"\\s*\\(",y=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],x=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],S=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],C=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],_={type:x,keyword:y,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:S},T={className:"function.dispatch",relevance:0,keywords:{_hint:C},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},R=[T,p,a,n,e.C_BLOCK_COMMENT_MODE,h,u],D={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:_,contains:R.concat([{begin:/\(/,end:/\)/,keywords:_,contains:R.concat(["self"]),relevance:0}]),relevance:0},j={className:"function",begin:"("+o+"[\\*&\\s]+)+"+b,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:_,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:_,relevance:0},{begin:b,returnBegin:!0,contains:[m],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[u,h]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:_,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,u,h,a,{begin:/\(/,end:/\)/,keywords:_,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,u,h,a]}]},a,n,e.C_BLOCK_COMMENT_MODE,p]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:_,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(D,j,T,R,[p,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:_,contains:["self",a]},{begin:e.IDENT_RE+"::",keywords:_},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function oze(e){const t={type:["boolean","byte","word","String"],built_in:["KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],_hints:["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],literal:["DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"]},n=ize(e),r=n.keywords;return r.type=[...r.type,...t.type],r.literal=[...r.literal,...t.literal],r.built_in=[...r.built_in,...t.built_in],r._hints=t._hints,n.name="Arduino",n.aliases=["ino"],n.supersetOf="cpp",n}function aze(e){const t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const s={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},i=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},a={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,s]};s.contains.push(a);const l={match:/\\"/},u={className:"string",begin:/'/,end:/'/},h={match:/\\'/},p={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},m=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],b=e.SHEBANG({binary:`(${m.join("|")})`,relevance:10}),y={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},x=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],S=["true","false"],C={match:/(\/[a-z._-]+)+/},N=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],M=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],_=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],T=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:x,literal:S,built_in:[...N,...M,"set","shopt",..._,...T]},contains:[b,e.SHEBANG(),y,p,i,o,C,a,l,u,h,n]}}function lze(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",o="("+r+"|"+t.optional(s)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",a={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},h={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},p={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},m={className:"title",begin:t.optional(s)+e.IDENT_RE,relevance:0},b=t.optional(s)+e.IDENT_RE+"\\s*\\(",S={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},C=[p,a,n,e.C_BLOCK_COMMENT_MODE,h,u],N={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:S,contains:C.concat([{begin:/\(/,end:/\)/,keywords:S,contains:C.concat(["self"]),relevance:0}]),relevance:0},M={begin:"("+o+"[\\*&\\s]+)+"+b,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:S,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:S,relevance:0},{begin:b,returnBegin:!0,contains:[e.inherit(m,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:S,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,u,h,a,{begin:/\(/,end:/\)/,keywords:S,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,u,h,a]}]},a,n,e.C_BLOCK_COMMENT_MODE,p]};return{name:"C",aliases:["h"],keywords:S,disableAutodetect:!0,illegal:"</",contains:[].concat(N,M,C,[p,{begin:e.IDENT_RE+"::",keywords:S},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:p,strings:u,keywords:S}}}function cze(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",o="(?!struct)("+r+"|"+t.optional(s)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",a={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},h={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},p={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},m={className:"title",begin:t.optional(s)+e.IDENT_RE,relevance:0},b=t.optional(s)+e.IDENT_RE+"\\s*\\(",y=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],x=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],S=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],C=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],_={type:x,keyword:y,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:S},T={className:"function.dispatch",relevance:0,keywords:{_hint:C},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},R=[T,p,a,n,e.C_BLOCK_COMMENT_MODE,h,u],D={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:_,contains:R.concat([{begin:/\(/,end:/\)/,keywords:_,contains:R.concat(["self"]),relevance:0}]),relevance:0},j={className:"function",begin:"("+o+"[\\*&\\s]+)+"+b,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:_,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:_,relevance:0},{begin:b,returnBegin:!0,contains:[m],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[u,h]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:_,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,u,h,a,{begin:/\(/,end:/\)/,keywords:_,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,u,h,a]}]},a,n,e.C_BLOCK_COMMENT_MODE,p]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:_,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(D,j,T,R,[p,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:_,contains:["self",a]},{begin:e.IDENT_RE+"::",keywords:_},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function uze(e){const t=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],n=["public","private","protected","static","internal","protected","abstract","async","extern","override","unsafe","virtual","new","sealed","partial"],r=["default","false","null","true"],s=["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"],i=["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"],o={keyword:s.concat(i),built_in:t,literal:r},a=e.inherit(e.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),l={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},u={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},h={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},p=e.inherit(h,{illegal:/\n/}),m={className:"subst",begin:/\{/,end:/\}/,keywords:o},b=e.inherit(m,{illegal:/\n/}),y={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},e.BACKSLASH_ESCAPE,b]},x={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},m]},S=e.inherit(x,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},b]});m.contains=[x,y,h,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,l,e.C_BLOCK_COMMENT_MODE],b.contains=[S,y,p,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,l,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const C={variants:[u,x,y,h,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},N={begin:"<",end:">",contains:[{beginKeywords:"in out"},a]},M=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",_={begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:o,illegal:/::/,contains:[e.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},C,l,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},a,N,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[a,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[a,N,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+M+"\\s+)+"+e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:o,contains:[{beginKeywords:n.join(" "),relevance:0},{begin:e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[e.TITLE_MODE,N],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,relevance:0,contains:[C,l,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},_]}}const dze=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),fze=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],hze=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],pze=[...fze,...hze],mze=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),gze=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),bze=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),yze=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function vze(e){const t=e.regex,n=dze(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",i=/@-?\w[\w]*(-\w+)*/,o="[a-zA-Z-][a-zA-Z0-9_-]*",a=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+o,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+gze.join("|")+")"},{begin:":(:)?("+bze.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+yze.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...a,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...a,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:mze.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...a,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+pze.join("|")+")\\b"}]}}function xze(e){const t=e.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}function wze(e){const i={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:i,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:i,illegal:/["']/}]}]}}function Sze(e){const t=e.regex,n=/[_A-Za-z][_0-9A-Za-z]*/;return{name:"GraphQL",aliases:["gql"],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:["query","mutation","subscription","type","input","schema","directive","interface","union","scalar","fragment","enum","on"],literal:["true","false","null"]},contains:[e.HASH_COMMENT_MODE,e.QUOTE_STRING_MODE,e.NUMBER_MODE,{scope:"punctuation",match:/[.]{3}/,relevance:0},{scope:"punctuation",begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:"variable",begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:"meta",match:/@\w+/,excludeEnd:!0},{scope:"symbol",begin:t.concat(n,t.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}}function Cze(e){const t=e.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},r=e.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const s={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},i={className:"literal",begin:/\bon|off|true|false|yes|no\b/},o={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},a={begin:/\[/,end:/\]/,contains:[r,i,s,o,n,"self"],relevance:0},l=/[A-Za-z0-9_-]+/,u=/"(\\"|[^"])*"/,h=/'[^']*'/,p=t.either(l,u,h),m=t.concat(p,"(\\s*\\.\\s*",p,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:m,className:"attr",starts:{end:/$/,contains:[r,a,i,s,o,n]}}]}}var Vh="[0-9](_*[0-9])*",Ny=`\\.(${Vh})`,My="[0-9a-fA-F](_*[0-9a-fA-F])*",hI={className:"number",variants:[{begin:`(\\b(${Vh})((${Ny})|\\.)?|(${Ny}))[eE][+-]?(${Vh})[fFdD]?\\b`},{begin:`\\b(${Vh})((${Ny})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Ny})[fFdD]?\\b`},{begin:`\\b(${Vh})[fFdD]\\b`},{begin:`\\b0[xX]((${My})\\.?|(${My})?\\.(${My}))[pP][+-]?(${Vh})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${My})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function RY(e,t,n){return n===-1?"":e.replace(t,r=>RY(e,t,n-1))}function kze(e){const t=e.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+RY("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),l={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},u={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},h={className:"params",begin:/\(/,end:/\)/,keywords:l,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:l,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[t.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[h,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:l,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:l,relevance:0,contains:[u,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,hI,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},hI,u]}}const pI="[A-Za-z$_][0-9A-Za-z$_]*",Eze=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],Nze=["true","false","null","undefined","NaN","Infinity"],OY=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],DY=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],jY=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Mze=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],_ze=[].concat(jY,OY,DY);function Tze(e){const t=e.regex,n=(le,{after:W})=>{const Q="</"+le[0].slice(1);return le.input.indexOf(Q,W)!==-1},r=pI,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(le,W)=>{const Q=le[0].length+le.index,H=le.input[Q];if(H==="<"||H===","){W.ignoreMatch();return}H===">"&&(n(le,{after:Q})||W.ignoreMatch());let U;const Z=le.input.substring(Q);if(U=Z.match(/^\s*=/)){W.ignoreMatch();return}if((U=Z.match(/^\s+extends\s+/))&&U.index===0){W.ignoreMatch();return}}},a={$pattern:pI,keyword:Eze,literal:Nze,built_in:_ze,"variable.language":Mze},l="[0-9](_?[0-9])*",u=`\\.(${l})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${h})((${u})|\\.)?|(${u}))[eE][+-]?(${l})\\b`},{begin:`\\b(${h})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},m={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},b={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"css"}},x={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"graphql"}},S={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,m]},N={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},M=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,b,y,x,S,{match:/\$\d+/},p];m.contains=M.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(M)});const _=[].concat(N,m.contains),T=_.concat([{begin:/(\s*)\(/,end:/\)/,keywords:a,contains:["self"].concat(_)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:T},D={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},j={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...OY,...DY]}},L={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},V={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},q={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function X(le){return t.concat("(?!",le.join("|"),")")}const ee={match:t.concat(/\b/,X([...jY,"super","import"].map(le=>`${le}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},re={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},oe={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},F="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",se={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(F)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:T,CLASS_REFERENCE:j},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),L,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,b,y,x,S,N,{match:/\$\d+/},p,j,{scope:"attr",match:r+t.lookahead(":"),relevance:0},se,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,e.REGEXP_MODE,{className:"function",begin:F,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:T}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},V,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[R,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},re,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},ee,q,D,oe,{match:/\$[(.]/}]}}function Aze(e){const t={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],s={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[t,n,e.QUOTE_STRING_MODE,s,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}var qh="[0-9](_*[0-9])*",_y=`\\.(${qh})`,Ty="[0-9a-fA-F](_*[0-9a-fA-F])*",Rze={className:"number",variants:[{begin:`(\\b(${qh})((${_y})|\\.)?|(${_y}))[eE][+-]?(${qh})[fFdD]?\\b`},{begin:`\\b(${qh})((${_y})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${_y})[fFdD]?\\b`},{begin:`\\b(${qh})[fFdD]\\b`},{begin:`\\b0[xX]((${Ty})\\.?|(${Ty})?\\.(${Ty}))[pP][+-]?(${qh})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Ty})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Oze(e){const t={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},n={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},r={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@"},s={className:"subst",begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},i={className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},o={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[i,s]},{begin:"'",end:"'",illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,i,s]}]};s.contains.push(o);const a={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?"},l={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(o,{className:"string"}),"self"]}]},u=Rze,h=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),p={variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},m=p;return m.variants[1].contains=[p],p.variants[1].contains=[m],{name:"Kotlin",aliases:["kt","kts"],keywords:t,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,h,n,r,a,l,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:t,relevance:5,contains:[{begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[p,e.C_LINE_COMMENT_MODE,h],relevance:0},e.C_LINE_COMMENT_MODE,h,a,l,o,e.C_NUMBER_MODE]},h]},{begin:[/class|interface|trait/,/\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},e.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},a,l]},o,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
628
628
  `},u]}}const Dze=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),jze=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],Ize=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],zze=[...jze,...Ize],Lze=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),IY=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),zY=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Pze=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),$ze=IY.concat(zY).sort().reverse();function Fze(e){const t=Dze(e),n=$ze,r="and or not only",s="[\\w-]+",i="("+s+"|@\\{"+s+"\\})",o=[],a=[],l=function(M){return{className:"string",begin:"~?"+M+".*?"+M}},u=function(M,_,T){return{className:M,begin:_,relevance:T}},h={$pattern:/[a-z-]+/,keyword:r,attribute:Lze.join(" ")},p={begin:"\\(",end:"\\)",contains:a,keywords:h,relevance:0};a.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,l("'"),l('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,p,u("variable","@@?"+s,10),u("variable","@\\{"+s+"\\}"),u("built_in","~?`[^`]*?`"),{className:"attribute",begin:s+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const m=a.concat({begin:/\{/,end:/\}/,contains:o}),b={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(a)},y={begin:i+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Pze.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:a}}]},x={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:h,returnEnd:!0,contains:a,relevance:0}},S={className:"variable",variants:[{begin:"@"+s+"\\s*:",relevance:15},{begin:"@"+s}],starts:{end:"[;}]",returnEnd:!0,contains:m}},C={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:i,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,b,u("keyword","all\\b"),u("variable","@\\{"+s+"\\}"),{begin:"\\b("+zze.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,u("selector-tag",i,0),u("selector-id","#"+i),u("selector-class","\\."+i,0),u("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+IY.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+zY.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:m},{begin:"!important"},t.FUNCTION_DISPATCH]},N={begin:s+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[C]};return o.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,x,S,N,y,C,b,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:o}}function Bze(e){const t="\\[=*\\[",n="\\]=*\\]",r={begin:t,end:n,contains:["self"]},s=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:s.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:s}].concat(s)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[r],relevance:5}])}}function Hze(e){const t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},r={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[t,n]},s={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},i={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},o={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[e.HASH_COMMENT_MODE,t,n,r,s,i,o]}}function Uze(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},s={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},i={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},a=/[A-Za-z][A-Za-z0-9+.-]*/,l={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,a,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},u={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},h={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},p=e.inherit(u,{contains:[]}),m=e.inherit(h,{contains:[]});u.contains.push(m),h.contains.push(p);let b=[n,l];return[u,h,p,m].forEach(C=>{C.contains=C.contains.concat(b)}),b=b.concat(u,h),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:b},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:b}]}]},n,i,u,h,{className:"quote",begin:"^>\\s+",contains:b,end:"$"},s,r,l,o,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function Vze(e){const t={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,a={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},l={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:a,illegal:"</",contains:[t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+l.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:l,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}function qze(e){const t=e.regex,n=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],r=/[dualxmsipngr]{0,12}/,s={$pattern:/[\w.]+/,keyword:n.join(" ")},i={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:s},o={begin:/->\{/,end:/\}/},a={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},l={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[a]},u={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},h=[e.BACKSLASH_ESCAPE,i,l],p=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],m=(x,S,C="\\1")=>{const N=C==="\\1"?C:t.concat(C,S);return t.concat(t.concat("(?:",x,")"),S,/(?:\\.|[^\\\/])*?/,N,/(?:\\.|[^\\\/])*?/,C,r)},b=(x,S,C)=>t.concat(t.concat("(?:",x,")"),S,/(?:\\.|[^\\\/])*?/,C,r),y=[l,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),o,{className:"string",contains:h,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},u,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:m("s|tr|y",t.either(...p,{capture:!0}))},{begin:m("s|tr|y","\\(","\\)")},{begin:m("s|tr|y","\\[","\\]")},{begin:m("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:b("(?:m|qr)?",/\//,/\//)},{begin:b("m|qr",t.either(...p,{capture:!0}),/\1/)},{begin:b("m|qr",/\(/,/\)/)},{begin:b("m|qr",/\[/,/\]/)},{begin:b("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,a]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,a,u]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return i.contains=y,o.contains=y,{name:"Perl",aliases:["pl","pm"],keywords:s,contains:y}}function Gze(e){const t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),s=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),i=t.concat(/[A-Z]+/,n),o={scope:"variable",match:"\\$+"+r},a={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},l={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},u=e.inherit(e.APOS_STRING_MODE,{illegal:null}),h=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(l)}),p={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(l),"on:begin":(re,oe)=>{oe.data._beginMatch=re[1]||re[2]},"on:end":(re,oe)=>{oe.data._beginMatch!==re[1]&&oe.ignoreMatch()}},m=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),b=`[
629
- ]`,y={scope:"string",variants:[h,u,p,m]},x={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},S=["false","null","true"],C=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],N=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],_={keyword:C,literal:(re=>{const oe=[];return re.forEach(F=>{oe.push(F),F.toLowerCase()===F?oe.push(F.toUpperCase()):oe.push(F.toLowerCase())}),oe})(S),built_in:N},T=re=>re.map(oe=>oe.replace(/\|\d+$/,"")),R={variants:[{match:[/new/,t.concat(b,"+"),t.concat("(?!",T(N).join("\\b|"),"\\b)"),s],scope:{1:"keyword",4:"title.class"}}]},D=t.concat(r,"\\b(?!\\()"),j={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),D],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[s,t.concat(/::/,t.lookahead(/(?!class\b)/)),D],scope:{1:"title.class",3:"variable.constant"}},{match:[s,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[s,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},L={scope:"attr",match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},V={relevance:0,begin:/\(/,end:/\)/,keywords:_,contains:[L,o,j,e.C_BLOCK_COMMENT_MODE,y,x,R]},q={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",T(C).join("\\b|"),"|",T(N).join("\\b|"),"\\b)"),r,t.concat(b,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[V]};V.contains.push(q);const X=[L,j,e.C_BLOCK_COMMENT_MODE,y,x,R],ee={begin:t.concat(/#\[\s*\\?/,t.either(s,i)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:S,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:S,keyword:["new","array"]},contains:["self",...X]},...X,{scope:"meta",variants:[{match:s},{match:i}]}]};return{case_insensitive:!1,keywords:_,contains:[ee,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},a,{scope:"variable.language",match:/\$this\b/},o,q,j,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},R,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:_,contains:["self",ee,o,j,e.C_BLOCK_COMMENT_MODE,y,x]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},y,x]}}function Wze(e){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function Kze(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function Yze(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],a={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},l={className:"meta",begin:/^(>>>|\.\.\.) /},u={className:"subst",begin:/\{/,end:/\}/,keywords:a,illegal:/#/},h={begin:/\{\{/,relevance:0},p={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,l],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,l],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,l,h,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,l,h,u]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,h,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,h,u]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},m="[0-9](_?[0-9])*",b=`(\\b(${m}))?\\.(${m})|\\b(${m})\\.`,y=`\\b|${r.join("|")}`,x={className:"number",relevance:0,variants:[{begin:`(\\b(${m})|(${b}))[eE][+-]?(${m})[jJ]?(?=${y})`},{begin:`(${b})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${y})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${y})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${y})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${y})`},{begin:`\\b(${m})[jJ](?=${y})`}]},S={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:a,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},C={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:["self",l,x,p,e.HASH_COMMENT_MODE]}]};return u.contains=[p,x,l],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:a,illegal:/(<\/|\?)|=>/,contains:[l,x,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},p,S,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[C]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[x,C,p]}]}}function Zze(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function Xze(e){const t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),s=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,i=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[s,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[i,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:s},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:i},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function Qze(e){const t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),s=t.concat(r,/(::\w+)*/),o={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},a={className:"doctag",begin:"@[A-Za-z]+"},l={begin:"#<",end:">"},u=[e.COMMENT("#","$",{contains:[a]}),e.COMMENT("^=begin","^=end",{contains:[a],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],h={className:"subst",begin:/#\{/,end:/\}/,keywords:o},p={className:"string",contains:[e.BACKSLASH_ESCAPE,h],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,h]})]}]},m="[1-9](_?[0-9])*|0",b="[0-9](_?[0-9])*",y={className:"number",relevance:0,variants:[{begin:`\\b(${m})(\\.(${b}))?([eE][+-]?(${b})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},x={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:o}]},R=[p,{variants:[{match:[/class\s+/,s,/\s+<\s+/,s]},{match:[/\b(class|module)\s+/,s]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:o},{match:[/(include|extend)\s+/,s],scope:{2:"title.class"},keywords:o},{relevance:0,match:[s,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[x]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[p,{begin:n}],relevance:0},y,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:o},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,h],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(l,u),relevance:0}].concat(l,u);h.contains=R,x.contains=R;const V=[{begin:/^\s*=>/,starts:{end:"$",contains:R}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:o,contains:R}}];return u.unshift(l),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:o,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(V).concat(u).concat(R)}}function Jze(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),s=t.concat(n,e.IDENT_RE),i={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,s,t.lookahead(/\s*\(/))},o="([ui](8|16|32|64|128|size)|f(32|64))?",a=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],l=["true","false","Some","None","Ok","Err"],u=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],h=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:h,keyword:a,literal:l,built_in:u},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+o},{begin:"\\b0o([0-7_]+)"+o},{begin:"\\b0x([A-Fa-f0-9_]+)"+o},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+o}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:u,type:h}},{className:"punctuation",begin:"->"},i]}}const eLe=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),tLe=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],nLe=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],rLe=[...tLe,...nLe],sLe=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),iLe=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),oLe=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),aLe=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function lLe(e){const t=eLe(e),n=oLe,r=iLe,s="@[a-z-]+",i="and or not only",a={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+rLe.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+r.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},a,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+aLe.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[t.BLOCK_COMMENT,a,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:s,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:sLe.join(" ")},contains:[{begin:s,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},a,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}function cLe(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function uLe(e){const t=e.regex,n=e.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],o=["double precision","large object","with timezone","without timezone"],a=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],l=["add","asc","collation","desc","final","first","last","view"],u=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],h=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],p=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],m=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],b=h,y=[...u,...l].filter(T=>!h.includes(T)),x={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},S={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},C={match:t.concat(/\b/,t.either(...b),/\s*\(/),relevance:0,keywords:{built_in:b}};function N(T){return t.concat(/\b/,t.either(...T.map(R=>R.replace(/\s+/,"\\s+"))),/\b/)}const M={scope:"keyword",match:N(m),relevance:0};function _(T,{exceptions:R,when:D}={}){const j=D;return R=R||[],T.map(L=>L.match(/\|\d+$/)||R.includes(L)?L:j(L)?`${L}|0`:L)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:_(y,{when:T=>T.length<3}),literal:i,type:a,built_in:p},contains:[{scope:"type",match:N(o)},M,C,x,r,s,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,S]}}function LY(e){return e?typeof e=="string"?e:e.source:null}function gm(e){return hr("(?=",e,")")}function hr(...e){return e.map(n=>LY(n)).join("")}function dLe(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function Mi(...e){return"("+(dLe(e).capture?"":"?:")+e.map(r=>LY(r)).join("|")+")"}const a8=e=>hr(/\b/,e,/\w$/.test(e)?/\b/:/\B/),fLe=["Protocol","Type"].map(a8),mI=["init","self"].map(a8),hLe=["Any","Self"],F3=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],gI=["false","nil","true"],pLe=["assignment","associativity","higherThan","left","lowerThan","none","right"],mLe=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],bI=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],PY=Mi(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),$Y=Mi(PY,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),B3=hr(PY,$Y,"*"),FY=Mi(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),Ix=Mi(FY,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),Ya=hr(FY,Ix,"*"),Ay=hr(/[A-Z]/,Ix,"*"),gLe=["attached","autoclosure",hr(/convention\(/,Mi("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",hr(/objc\(/,Ya,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],bLe=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function yLe(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],s={match:[/\./,Mi(...fLe,...mI)],className:{2:"keyword"}},i={match:hr(/\./,Mi(...F3)),relevance:0},o=F3.filter(xt=>typeof xt=="string").concat(["_|0"]),a=F3.filter(xt=>typeof xt!="string").concat(hLe).map(a8),l={variants:[{className:"keyword",match:Mi(...a,...mI)}]},u={$pattern:Mi(/\b\w+/,/#\w+/),keyword:o.concat(mLe),literal:gI},h=[s,i,l],p={match:hr(/\./,Mi(...bI)),relevance:0},m={className:"built_in",match:hr(/\b/,Mi(...bI),/(?=\()/)},b=[p,m],y={match:/->/,relevance:0},x={className:"operator",relevance:0,variants:[{match:B3},{match:`\\.(\\.|${$Y})+`}]},S=[y,x],C="([0-9]_*)+",N="([0-9a-fA-F]_*)+",M={className:"number",relevance:0,variants:[{match:`\\b(${C})(\\.(${C}))?([eE][+-]?(${C}))?\\b`},{match:`\\b0x(${N})(\\.(${N}))?([pP][+-]?(${C}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},_=(xt="")=>({className:"subst",variants:[{match:hr(/\\/,xt,/[0\\tnr"']/)},{match:hr(/\\/,xt,/u\{[0-9a-fA-F]{1,8}\}/)}]}),T=(xt="")=>({className:"subst",match:hr(/\\/,xt,/[\t ]*(?:[\r\n]|\r\n)/)}),R=(xt="")=>({className:"subst",label:"interpol",begin:hr(/\\/,xt,/\(/),end:/\)/}),D=(xt="")=>({begin:hr(xt,/"""/),end:hr(/"""/,xt),contains:[_(xt),T(xt),R(xt)]}),j=(xt="")=>({begin:hr(xt,/"/),end:hr(/"/,xt),contains:[_(xt),R(xt)]}),L={className:"string",variants:[D(),D("#"),D("##"),D("###"),j(),j("#"),j("##"),j("###")]},V=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],q={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:V},X=xt=>{const Jt=hr(xt,/\//),fn=hr(/\//,xt);return{begin:Jt,end:fn,contains:[...V,{scope:"comment",begin:`#(?!.*${fn})`,end:/$/}]}},ee={scope:"regexp",variants:[X("###"),X("##"),X("#"),q]},re={match:hr(/`/,Ya,/`/)},oe={className:"variable",match:/\$\d+/},F={className:"variable",match:`\\$${Ix}+`},se=[re,oe,F],le={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:bLe,contains:[...S,M,L]}]}},W={scope:"keyword",match:hr(/@/,Mi(...gLe),gm(Mi(/\(/,/\s+/)))},Q={scope:"meta",match:hr(/@/,Ya)},H=[le,W,Q],U={match:gm(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:hr(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,Ix,"+")},{className:"type",match:Ay,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:hr(/\s+&\s+/,gm(Ay)),relevance:0}]},Z={begin:/</,end:/>/,keywords:u,contains:[...r,...h,...H,y,U]};U.contains.push(Z);const he={match:hr(Ya,/\s*:/),keywords:"_|0",relevance:0},fe={begin:/\(/,end:/\)/,relevance:0,keywords:u,contains:["self",he,...r,ee,...h,...b,...S,M,L,...se,...H,U]},ye={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,U]},ge={begin:Mi(gm(hr(Ya,/\s*:/)),gm(hr(Ya,/\s+/,Ya,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:Ya}]},Ee={begin:/\(/,end:/\)/,keywords:u,contains:[ge,...r,...h,...S,M,L,...H,U,fe],endsParent:!0,illegal:/["']/},Ae={match:[/(func|macro)/,/\s+/,Mi(re.match,Ya,B3)],className:{1:"keyword",3:"title.function"},contains:[ye,Ee,t],illegal:[/\[/,/%/]},Qe={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[ye,Ee,t],illegal:/\[|%/},rt={match:[/operator/,/\s+/,B3],className:{1:"keyword",3:"title"}},ct={begin:[/precedencegroup/,/\s+/,Ay],className:{1:"keyword",3:"title"},contains:[U],keywords:[...pLe,...gI],end:/}/},He={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},_e={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},nn={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,Ya,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:u,contains:[ye,...h,{begin:/:/,end:/\{/,keywords:u,contains:[{scope:"title.class.inherited",match:Ay},...h],relevance:0}]};for(const xt of L.variants){const Jt=xt.contains.find(hn=>hn.label==="interpol");Jt.keywords=u;const fn=[...h,...b,...S,M,L,...se];Jt.contains=[...fn,{begin:/\(/,end:/\)/,contains:["self",...fn]}]}return{name:"Swift",keywords:u,contains:[...r,Ae,Qe,He,_e,nn,rt,ct,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},ee,...h,...b,...S,M,L,...se,...H,U,fe]}}const zx="[A-Za-z$_][0-9A-Za-z$_]*",BY=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],HY=["true","false","null","undefined","NaN","Infinity"],UY=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],VY=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],qY=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],GY=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],WY=[].concat(qY,UY,VY);function vLe(e){const t=e.regex,n=(le,{after:W})=>{const Q="</"+le[0].slice(1);return le.input.indexOf(Q,W)!==-1},r=zx,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(le,W)=>{const Q=le[0].length+le.index,H=le.input[Q];if(H==="<"||H===","){W.ignoreMatch();return}H===">"&&(n(le,{after:Q})||W.ignoreMatch());let U;const Z=le.input.substring(Q);if(U=Z.match(/^\s*=/)){W.ignoreMatch();return}if((U=Z.match(/^\s+extends\s+/))&&U.index===0){W.ignoreMatch();return}}},a={$pattern:zx,keyword:BY,literal:HY,built_in:WY,"variable.language":GY},l="[0-9](_?[0-9])*",u=`\\.(${l})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${h})((${u})|\\.)?|(${u}))[eE][+-]?(${l})\\b`},{begin:`\\b(${h})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},m={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},b={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"css"}},x={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"graphql"}},S={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,m]},N={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},M=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,b,y,x,S,{match:/\$\d+/},p];m.contains=M.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(M)});const _=[].concat(N,m.contains),T=_.concat([{begin:/(\s*)\(/,end:/\)/,keywords:a,contains:["self"].concat(_)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:T},D={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},j={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...UY,...VY]}},L={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},V={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},q={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function X(le){return t.concat("(?!",le.join("|"),")")}const ee={match:t.concat(/\b/,X([...qY,"super","import"].map(le=>`${le}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},re={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},oe={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},F="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",se={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(F)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:T,CLASS_REFERENCE:j},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),L,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,b,y,x,S,N,{match:/\$\d+/},p,j,{scope:"attr",match:r+t.lookahead(":"),relevance:0},se,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,e.REGEXP_MODE,{className:"function",begin:F,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:T}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},V,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[R,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},re,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},ee,q,D,oe,{match:/\$[(.]/}]}}function xLe(e){const t=e.regex,n=vLe(e),r=zx,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},o={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},a={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},l=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],u={$pattern:zx,keyword:BY.concat(l),literal:HY,built_in:WY.concat(s),"variable.language":GY},h={className:"meta",begin:"@"+r},p=(x,S,C)=>{const N=x.contains.findIndex(M=>M.label===S);if(N===-1)throw new Error("can not find mode to replace");x.contains.splice(N,1,C)};Object.assign(n.keywords,u),n.exports.PARAMS_CONTAINS.push(h);const m=n.contains.find(x=>x.scope==="attr"),b=Object.assign({},m,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,m,b]),n.contains=n.contains.concat([h,i,o,b]),p(n,"shebang",e.SHEBANG()),p(n,"use_strict",a);const y=n.contains.find(x=>x.label==="func.def");return y.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function wLe(e){const t=e.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},s=/\d{1,2}\/\d{1,2}\/\d{4}/,i=/\d{4}-\d{1,2}-\d{1,2}/,o=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,a=/\d{1,2}(:\d{1,2}){1,2}/,l={className:"literal",variants:[{begin:t.concat(/# */,t.either(i,s),/ *#/)},{begin:t.concat(/# */,a,/ *#/)},{begin:t.concat(/# */,o,/ *#/)},{begin:t.concat(/# */,t.either(i,s),/ +/,t.either(o,a),/ *#/)}]},u={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},h={className:"label",begin:/^\w+:/},p=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),m=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,r,l,u,h,p,m,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[m]}]}}function SLe(e){e.regex;const t=e.COMMENT(/\(;/,/;\)/);t.contains.push("self");const n=e.COMMENT(/;;/,/$/),r=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],s={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},i={className:"variable",begin:/\$[\w_]+/},o={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},a={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},l={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},u={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:r},contains:[n,t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},i,o,s,e.QUOTE_STRING_MODE,l,u,a]}}function CLe(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(i,{begin:/\(/,end:/\)/}),a=e.inherit(e.APOS_STRING_MODE,{className:"string"}),l=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),u={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,l,a,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,o,l,a]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[l]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[u],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[u],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:u}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function kLe(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},s={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},i={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},o={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,s]},a=e.inherit(o,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),m={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},b={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},y={begin:/\{/,end:/\}/,contains:[b],illegal:"\\n",relevance:0},x={begin:"\\[",end:"\\]",contains:[b],illegal:"\\n",relevance:0},S=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},m,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},y,x,i,o],C=[...S];return C.pop(),C.push(a),b.contains=C,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:S}}const ELe={arduino:oze,bash:aze,c:lze,cpp:cze,csharp:uze,css:vze,diff:xze,go:wze,graphql:Sze,ini:Cze,java:kze,javascript:Tze,json:Aze,kotlin:Oze,less:Fze,lua:Bze,makefile:Hze,markdown:Uze,objectivec:Vze,perl:qze,php:Gze,"php-template":Wze,plaintext:Kze,python:Yze,"python-repl":Zze,r:Xze,ruby:Qze,rust:Jze,scss:lLe,shell:cLe,sql:uLe,swift:yLe,typescript:xLe,vbnet:wLe,wasm:SLe,xml:CLe,yaml:kLe},yI={},NLe="hljs-";function MLe(e){const t=TY.newInstance();return e&&i(e),{highlight:n,highlightAuto:r,listLanguages:s,register:i,registerAlias:o,registered:a};function n(l,u,h){const p=h||yI,m=typeof p.prefix=="string"?p.prefix:NLe;if(!t.getLanguage(l))throw new Error("Unknown language: `"+l+"` is not registered");t.configure({__emitter:_Le,classPrefix:m});const b=t.highlight(u,{ignoreIllegals:!0,language:l});if(b.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:b.errorRaised});const y=b._emitter.root,x=y.data;return x.language=b.language,x.relevance=b.relevance,y}function r(l,u){const p=(u||yI).subset||s();let m=-1,b=0,y;for(;++m<p.length;){const x=p[m];if(!t.getLanguage(x))continue;const S=n(x,l,u);S.data&&S.data.relevance!==void 0&&S.data.relevance>b&&(b=S.data.relevance,y=S)}return y||{type:"root",children:[],data:{language:void 0,relevance:b}}}function s(){return t.listLanguages()}function i(l,u){if(typeof l=="string")t.registerLanguage(l,u);else{let h;for(h in l)Object.hasOwn(l,h)&&t.registerLanguage(h,l[h])}}function o(l,u){if(typeof l=="string")t.registerAliases(typeof u=="string"?u:[...u],{languageName:l});else{let h;for(h in l)if(Object.hasOwn(l,h)){const p=l[h];t.registerAliases(typeof p=="string"?p:[...p],{languageName:h})}}}function a(l){return!!t.getLanguage(l)}}class _Le{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],s=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):r.children.push(...s)}openNode(t){const n=this,r=t.split(".").map(function(o,a){return a?o+"_".repeat(a):n.options.classPrefix+o}),s=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};s.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const TLe=sze.extend({addOptions(){return{...this.parent?.(),lowlight:MLe(ELe),defaultLanguage:null,HTMLAttributes:{class:"block-node"},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,enableTabIndentation:!1,tabSize:4}}}),ALe=yY.extend({addProseMirrorPlugins(){return[...this.parent?.()||[],new Wn({props:{handleKeyDown:(e,t)=>(t.key==="Enter"&&this.editor.commands.unsetColor(),!1)}})]}}),RLe=yW.extend({addKeyboardShortcuts(){return{"Mod-Alt--":()=>this.editor.commands.insertContent({type:this.name})}}});function OLe({initialWidth:e,initialHeight:t,contentWidth:n,contentHeight:r,gridInterval:s,minWidth:i,minHeight:o,maxWidth:a,onDimensionsChange:l}){const[u,h]=w.useState({width:Math.max(e??i,i),height:Math.max(t??o,o)}),[p,m]=w.useState(1/0),[b,y]=w.useState(0),[x,S]=w.useState(u),[C,N]=w.useState(),M=w.useCallback((j,L)=>{const V=Math.max(i,Math.min(n??i,s/100*L));return Math.min(L,Math.max(j,V))},[s,n,i]),_=w.useCallback(j=>{j.preventDefault();const L=(C==="left"?b-j.pageX:j.pageX-b)*2,V=s/100*p,q=x.width+L,X=Math.round(q/V)*V,ee=M(X,p),re=r&&n?r/n:1;h({width:Math.max(ee,i),height:Math.max(n?ee*re:r??o,o)})},[M,C,p,b,s,r,n,x.width,i,o]),T=w.useCallback(j=>{j.preventDefault(),j.stopPropagation(),y(0),N(void 0),l?.(u)},[l,u]),R=w.useCallback(j=>{j.key==="Escape"&&(j.preventDefault(),j.stopPropagation(),h({width:Math.max(x.width,i),height:Math.max(x.height,o)}),N(void 0))},[x,i,o]),D=w.useCallback(j=>L=>{L.preventDefault(),L.stopPropagation(),m(a),S({width:Math.max(M(u.width,a),i),height:Math.max(u.height,o)}),y(L.pageX),N(j)},[a,M,u.width,u.height,i,o]);return w.useEffect(()=>{if(C)return document.addEventListener("keydown",R),document.addEventListener("pointermove",_),document.addEventListener("pointerup",T),()=>{document.removeEventListener("keydown",R),document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",T)}},[C,R,_,T]),{initiateResize:D,isResizing:!!C,updateDimensions:h,currentWidth:Math.max(u.width,i),currentHeight:Math.max(u.height,o)}}const c6=({ref:e,className:t,isResizing:n=!1,...r})=>d.jsx("div",{className:ie("absolute top-1/2 h-10 max-h-full w-1.5 -translate-y-1/2 transform cursor-col-resize rounded border border-solid border-[var(--mt-transparent-foreground)] bg-[var(--mt-bg-secondary)] p-px transition-all","opacity-0 [backdrop-filter:saturate(1.8)_blur(20px)]",{"opacity-80":n,"group-hover/node-image:opacity-80":!n},"before:absolute before:inset-y-0 before:-right-1 before:-left-1",t),ref:e,...r});c6.displayName="ResizeHandle";function DLe(){return te.createElement("svg",{"aria-hidden":"true","data-rmiz-btn-unzoom-icon":!0,fill:"currentColor",focusable:"false",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},te.createElement("path",{d:"M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z"}))}function jLe(){return te.createElement("svg",{"aria-hidden":"true","data-rmiz-btn-zoom-icon":!0,fill:"currentColor",focusable:"false",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},te.createElement("path",{d:"M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z"}))}function ILe(e){return typeof Element>"u"?!1:e instanceof Element}const Lx=(e,t)=>ILe(t)&&t.tagName.toUpperCase()===e,l8=e=>Lx("DIV",e)||Lx("SPAN",e),Px=e=>Lx("IMG",e),vI=e=>e.complete&&e.naturalHeight!==0,Qy=e=>Lx("SVG",e),KY=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),zLe=({containerHeight:e,containerWidth:t,offset:n,targetHeight:r,targetWidth:s})=>{const i=KY({height:r,offset:n,width:s}),o=s>r?s/t:r/e;return i>1?o:i*o},sf=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:s,targetWidth:i})=>e===0||t===0?1:!n&&s!==0&&i!==0?zLe({containerHeight:e,containerWidth:t,offset:r,targetHeight:s,targetWidth:i}):KY({height:e,offset:r,width:t}),LLe=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,xI=e=>{if(e!==null){if(Px(e))return e.currentSrc===""?void 0:e.currentSrc;if(l8(e)){const{backgroundImage:t}=window.getComputedStyle(e);if(t!=="")return LLe.exec(t)?.[1]}}},PLe=e=>{if(e!==null)return Px(e)?e.alt:e.getAttribute("aria-label")??void 0},$Le=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:s,offset:i,targetHeight:o,targetWidth:a})=>{const l=sf({containerHeight:e,containerWidth:r,hasScalableSrc:s,offset:i,targetHeight:o,targetWidth:a});return{top:n,left:t,width:r*l,height:e*l,transform:`translate(0,0) scale(${1/l})`}},Yo=({position:e,relativeNum:t})=>{const n=parseFloat(e);return e.endsWith("%")?t*n/100:n},FLe=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:s,objectFit:i,objectPosition:o,offset:a,targetHeight:l,targetWidth:u})=>{let h=i;if(h==="scale-down"&&(u<=r&&l<=e?h="none":h="contain"),h==="cover"||h==="contain"){const p=r/u,m=e/l,b=h==="cover"?Math.max(p,m):Math.min(p,m),[y="50%",x="50%"]=o.split(" "),S=Yo({position:y,relativeNum:r-u*b}),C=Yo({position:x,relativeNum:e-l*b}),N=sf({containerHeight:l*b,containerWidth:u*b,hasScalableSrc:s,offset:a,targetHeight:l,targetWidth:u});return{top:n+C,left:t+S,width:u*b*N,height:l*b*N,transform:`translate(0,0) scale(${1/N})`}}else if(h==="none"){const[p="50%",m="50%"]=o.split(" "),b=Yo({position:p,relativeNum:r-u}),y=Yo({position:m,relativeNum:e-l}),x=sf({containerHeight:l,containerWidth:u,hasScalableSrc:s,offset:a,targetHeight:l,targetWidth:u});return{top:n+y,left:t+b,width:u*x,height:l*x,transform:`translate(0,0) scale(${1/x})`}}else if(h==="fill"){const p=r/u,m=e/l,b=Math.max(p,m),y=sf({containerHeight:l*b,containerWidth:u*b,hasScalableSrc:s,offset:a,targetHeight:l,targetWidth:u});return{width:r*y,height:e*y,transform:`translate(0,0) scale(${1/y})`}}else return{}},BLe=({backgroundPosition:e,backgroundSize:t,containerHeight:n,containerLeft:r,containerTop:s,containerWidth:i,hasScalableSrc:o,offset:a,targetHeight:l,targetWidth:u})=>{if(t==="cover"||t==="contain"){const h=i/u,p=n/l,m=t==="cover"?Math.max(h,p):Math.min(h,p),[b="50%",y="50%"]=e.split(" "),x=Yo({position:b,relativeNum:i-u*m}),S=Yo({position:y,relativeNum:n-l*m}),C=sf({containerHeight:l*m,containerWidth:u*m,hasScalableSrc:o,offset:a,targetHeight:l,targetWidth:u});return{top:s+S,left:r+x,width:u*m*C,height:l*m*C,transform:`translate(0,0) scale(${1/C})`}}else if(t==="auto"){const[h="50%",p="50%"]=e.split(" "),m=Yo({position:h,relativeNum:i-u}),b=Yo({position:p,relativeNum:n-l}),y=sf({containerHeight:l,containerWidth:u,hasScalableSrc:o,offset:a,targetHeight:l,targetWidth:u});return{top:s+b,left:r+m,width:u*y,height:l*y,transform:`translate(0,0) scale(${1/y})`}}else{const[h="50%",p="50%"]=t.split(" "),m=Yo({position:h,relativeNum:i}),b=Yo({position:p,relativeNum:n}),y=m/u,x=b/l,S=Math.min(y,x),[C="50%",N="50%"]=e.split(" "),M=Yo({position:C,relativeNum:i-u*S}),_=Yo({position:N,relativeNum:n-l*S}),T=sf({containerHeight:l*S,containerWidth:u*S,hasScalableSrc:o,offset:a,targetHeight:l,targetWidth:u});return{top:s+_,left:r+M,width:u*S*T,height:l*S*T,transform:`translate(0,0) scale(${1/T})`}}},HLe=/\.svg$/i,ULe=({hasZoomImg:e,imgSrc:t,isSvg:n,isZoomed:r,loadedImgEl:s,offset:i,shouldRefresh:o,targetEl:a})=>{const l=n||t?.slice(0,18)==="data:image/svg+xml"||e||t!==void 0&&HLe.test(t),u=a.getBoundingClientRect(),h=window.getComputedStyle(a),p=s!=null&&l8(a),m=s!=null&&!p,b=s!=null&&s.naturalHeight!==0?s.naturalHeight:u.height,y=s!=null&&s.naturalWidth!==0?s.naturalWidth:u.width,x=$Le({containerHeight:u.height,containerLeft:u.left,containerTop:u.top,containerWidth:u.width,hasScalableSrc:l,offset:i,targetHeight:b,targetWidth:y}),S=m?FLe({containerHeight:u.height,containerLeft:u.left,containerTop:u.top,containerWidth:u.width,hasScalableSrc:l,objectFit:h.objectFit,objectPosition:h.objectPosition,offset:i,targetHeight:b,targetWidth:y}):void 0,C=p?BLe({backgroundPosition:h.backgroundPosition,backgroundSize:h.backgroundSize,containerHeight:u.height,containerLeft:u.left,containerTop:u.top,containerWidth:u.width,hasScalableSrc:l,offset:i,targetHeight:b,targetWidth:y}):void 0,N={...x,...S,...C};if(r){const M=window.innerWidth/2,_=window.innerHeight/2,T=parseFloat(String(N.left??0))+parseFloat(String(N.width??0))/2,R=parseFloat(String(N.top??0))+parseFloat(String(N.height??0))/2,D=M-T,j=_-R;o&&(N.transitionDuration="0.01ms"),N.transform=`translate(${D}px,${j}px) scale(1)`}return N},H3=e=>{if(e==null)return{};if(Qy(e)){const{parentElement:t}=e,n=e.getBoundingClientRect();if(t==null)return{height:n.height,left:n.left,width:n.width,top:n.top};{const r=t.getBoundingClientRect();return{height:n.height,left:r.left-n.left,top:r.top-n.top,width:n.width}}}else return{height:e.offsetHeight,left:e.offsetLeft,width:e.offsetWidth,top:e.offsetTop}},VLe=e=>{const t="-zoom",n=["clip-path","fill","mask","marker-start","marker-mid","marker-end"],r=new Map;if(e.hasAttribute("id")){const{id:s}=e,i=s+t;r.set(s,i);const o=e;o.id=i}e.querySelectorAll("[id]").forEach(s=>{const{id:i}=s,o=i+t;r.set(i,o);const a=s;a.id=o}),r.forEach((s,i)=>{const o=`url(#${i})`,a=`url(#${s})`,l=n.map(u=>`[${u}="${o}"]`).join(", ");e.querySelectorAll(l).forEach(u=>{n.forEach(h=>{u.getAttribute(h)===o&&u.setAttribute(h,a)})})}),e.querySelectorAll("style").forEach(s=>{r.forEach((i,o)=>{const{textContent:a}=s;if(a!==""){const l=s;l.textContent=a.replaceAll(`#${o}`,`#${i}`)}})})},qLe=["img","svg",'[role="img"]',"[data-zoom]"].map(e=>`${e}:not([aria-hidden="true"])`).join(","),wI={overflow:"",width:""};function GLe(){const e=document.querySelector("[data-rmiz-portal]");if(e!=null)return e;const t=document.createElement("div");return t.setAttribute("data-rmiz-portal",""),document.body.appendChild(t),t}function WLe(e){e.preventDefault()}function KLe(e){return te.createElement(YY,{...e})}class YY extends te.Component{constructor(){super(...arguments),this.state={id:"",isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:"UNLOADED",shouldRefresh:!1,styleGhost:{}},this.refContent=te.createRef(),this.refDialog=te.createRef(),this.refModalContent=te.createRef(),this.refModalImg=te.createRef(),this.refWrap=te.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=wI,this.styleModalImg={},this.handleModalStateChange=t=>{const{state:{modalState:n}}=this;t!=="LOADING"&&n==="LOADING"?(this.loadZoomImg(),window.addEventListener("resize",this.handleResize,{passive:!0}),window.addEventListener("touchstart",this.handleTouchStart,{passive:!0}),window.addEventListener("touchmove",this.handleTouchMove,{passive:!0}),window.addEventListener("touchend",this.handleTouchEnd,{passive:!0}),window.addEventListener("touchcancel",this.handleTouchCancel,{passive:!0}),document.addEventListener("keydown",this.handleKeyDown,!0)):t!=="LOADED"&&n==="LOADED"?window.addEventListener("wheel",this.handleWheel,{passive:!0}):t!=="UNLOADING"&&n==="UNLOADING"?(this.ensureImgTransitionEnd(),window.removeEventListener("wheel",this.handleWheel),window.removeEventListener("touchstart",this.handleTouchStart),window.removeEventListener("touchmove",this.handleTouchMove),window.removeEventListener("touchend",this.handleTouchEnd),window.removeEventListener("touchcancel",this.handleTouchCancel),document.removeEventListener("keydown",this.handleKeyDown,!0)):t!=="UNLOADED"&&n==="UNLOADED"&&(this.bodyScrollEnable(),window.removeEventListener("resize",this.handleResize),this.refModalImg.current?.removeEventListener("transitionend",this.handleImgTransitionEnd),this.refDialog.current?.close())},this.setId=()=>{const t=()=>Math.random().toString(16).slice(-4);this.setState({id:t()+t()+t()})},this.setAndTrackImg=()=>{const{refContent:{current:t}}=this;t!=null&&(this.imgEl=t.querySelector(qLe),this.imgEl!==null?(this.contentNotFoundChangeObserver?.disconnect(),this.imgEl.addEventListener("load",this.handleImgLoad),this.imgEl.addEventListener("click",this.handleZoom),this.state.loadedImgEl==null&&this.handleImgLoad(),this.imgElResizeObserver=new ResizeObserver(n=>{const[r]=n;r?.target!==void 0&&(this.imgEl=r.target,this.setState({styleGhost:H3(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver==null&&(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:H3(this.imgEl)})}),this.contentChangeObserver.observe(t,{attributes:!0,childList:!0,subtree:!0}))):this.contentNotFoundChangeObserver==null&&(this.contentNotFoundChangeObserver=new MutationObserver(this.setAndTrackImg),this.contentNotFoundChangeObserver.observe(t,{childList:!0,subtree:!0})))},this.handleIfZoomChanged=t=>{const{props:{isZoomed:n}}=this;!t&&n?this.zoom():t&&!n&&this.unzoom()},this.handleImgLoad=()=>{const t=xI(this.imgEl);if(t==null||t==="")return;const n=new Image,{imgEl:r}=this;if(Px(r)){const{sizes:i,srcset:o,crossOrigin:a}=r;n.sizes=i,n.srcset=o,n.crossOrigin=a}n.src=t;const s=()=>{this.setState({loadedImgEl:n,styleGhost:H3(this.imgEl)})};n.decode().then(s).catch(()=>{if(vI(n)){s();return}n.onload=s})},this.handleZoom=t=>{this.props.isDisabled!==!0&&this.hasImage()&&this.props.onZoomChange?.(!0,{event:t})},this.handleUnzoom=t=>{this.props.isDisabled!==!0&&this.props.onZoomChange?.(!1,{event:t})},this.handleBtnUnzoomClick=t=>{t.preventDefault(),t.stopPropagation(),this.handleUnzoom(t)},this.handleDialogClick=t=>{(t.target===this.refModalContent.current||t.target===this.refModalImg.current)&&(t.stopPropagation(),this.handleUnzoom(t))},this.handleDialogClose=t=>{t.stopPropagation(),this.handleUnzoom(t)},this.handleKeyDown=t=>{t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),this.handleUnzoom(t))},this.handleWheel=t=>{t.ctrlKey||(t.stopPropagation(),queueMicrotask(()=>{this.handleUnzoom(t)}))},this.handleTouchStart=t=>{if(t.touches.length>1){this.isScaling=!0;return}const{changedTouches:n}=t,[r]=n;if(n.length===1&&r!==void 0){const{screenY:s}=r;this.touchYStart=s}},this.handleTouchMove=t=>{const n=window.visualViewport?.scale??1,{changedTouches:r}=t,[s]=r;if(this.props.canSwipeToUnzoom&&!this.isScaling&&n<=1&&this.touchYStart!=null&&s!==void 0){const{screenY:i}=s;this.touchYEnd=i;const o=Math.max(this.touchYStart,this.touchYEnd),a=Math.min(this.touchYStart,this.touchYEnd);Math.abs(o-a)>this.props.swipeToUnzoomThreshold&&(this.touchYStart=void 0,this.touchYEnd=void 0,this.handleUnzoom(t))}},this.handleTouchEnd=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleTouchCancel=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleResize=()=>{this.setState({shouldRefresh:!0})},this.hasImage=()=>this.imgEl!==null&&(this.state.loadedImgEl!==void 0||Qy(this.imgEl))&&window.getComputedStyle(this.imgEl).display!=="none",this.zoom=()=>{this.bodyScrollDisable(),this.refDialog.current?.showModal(),this.refModalImg.current?.addEventListener("transitionend",this.handleImgTransitionEnd),this.setState({modalState:"LOADING"})},this.unzoom=()=>{this.setState({modalState:"UNLOADING"})},this.handleImgTransitionEnd=()=>{clearTimeout(this.timeoutTransitionEnd),this.state.modalState==="LOADING"?this.setState({modalState:"LOADED"}):this.state.modalState==="UNLOADING"&&this.setState({shouldRefresh:!1,modalState:"UNLOADED"})},this.ensureImgTransitionEnd=()=>{if(this.refModalImg.current!==null){const{transitionDuration:t}=window.getComputedStyle(this.refModalImg.current),n=parseFloat(t);if(n!==0&&!Number.isNaN(n)){const r=n*(t.endsWith("ms")?1:1e3)+50;this.timeoutTransitionEnd=setTimeout(this.handleImgTransitionEnd,r)}}},this.bodyScrollDisable=()=>{this.prevBodyAttrs={overflow:document.body.style.overflow,width:document.body.style.width};const{body:{clientWidth:t}}=document;document.body.style.overflow="hidden",document.body.style.width=`${t}px`},this.bodyScrollEnable=()=>{const{prevBodyAttrs:{overflow:t,width:n}}=this;document.body.style.width=n,document.body.style.overflow=t,this.prevBodyAttrs=wI},this.loadZoomImg=()=>{const{props:{zoomImg:t}}=this;if(t==null)return;const{src:n}=t;if(n!==void 0&&n!==""){const r=new Image;r.sizes=t.sizes??"",r.srcset=t.srcSet??"",r.crossOrigin=t.crossOrigin??void 0,r.src=n;const s=()=>{this.setState({isZoomImgLoaded:!0})};r.decode().then(s).catch(()=>{if(vI(r)){s();return}r.onload=s})}},this.UNSAFE_handleSvg=()=>{const{imgEl:t,refModalImg:n,styleModalImg:r}=this;if(Qy(t)){const s=t.cloneNode(!0);VLe(s),s.style.width=`${r.width??0}px`,s.style.height=`${r.height??0}px`,s.addEventListener("click",this.handleUnzoom),n.current?.firstChild?.remove(),n.current?.appendChild(s)}}}render(){const{handleBtnUnzoomClick:t,handleDialogClick:n,handleDialogClose:r,handleUnzoom:s,handleZoom:i,imgEl:o,props:{a11yNameButtonUnzoom:a,a11yNameButtonZoom:l,children:u,classDialog:h,IconUnzoom:p,IconZoom:m,isZoomed:b,wrapElement:y,ZoomContent:x,zoomImg:S,zoomMargin:C},refContent:N,refDialog:M,refModalContent:_,refModalImg:T,refWrap:R,state:{id:D,isZoomImgLoaded:j,loadedImgEl:L,modalState:V,shouldRefresh:q,styleGhost:X}}=this,ee=`rmiz-modal-${D}`,re=`rmiz-modal-img-${D}`,oe=l8(o),F=Px(o),se=Qy(o),le=PLe(o),W=xI(o),Q=F?o.sizes:void 0,H=F?o.srcset:void 0,U=F?o.crossOrigin:void 0,Z=S?.src!==void 0&&S.src!=="",he=this.hasImage(),fe=le!==void 0&&le!==""?`${l}: ${le}`:l,ye=V==="LOADING"||V==="LOADED",ge=he?"found":"not-found",Ee=V==="UNLOADED"||V==="UNLOADING"?"hidden":"visible",Ae={visibility:V==="UNLOADED"?"visible":"hidden"};this.styleModalImg=he&&o!==null?ULe({hasZoomImg:Z,imgSrc:W,isSvg:se,isZoomed:b&&ye,loadedImgEl:L,offset:C,shouldRefresh:q,targetEl:o}):{};let Qe=null;if(he){const rt=F||oe?te.createElement("img",{alt:le,crossOrigin:U,sizes:Q,src:W,srcSet:H,...j&&V==="LOADED"?S:{},"data-rmiz-modal-img":"",height:this.styleModalImg.height??void 0,id:re,ref:T,style:this.styleModalImg,width:this.styleModalImg.width??void 0}):se?te.createElement("div",{"data-rmiz-modal-img":!0,ref:T,style:this.styleModalImg}):null,ct=te.createElement("button",{"aria-label":a,"data-rmiz-btn-unzoom":"",onClick:t,type:"button"},te.createElement(p,null));Qe=x==null?te.createElement(te.Fragment,null,rt,ct):te.createElement(x,{buttonUnzoom:ct,modalState:V,img:rt,isZoomImgLoaded:j,onUnzoom:s})}return te.createElement(y,{"aria-owns":ee,"data-rmiz":"",ref:R},te.createElement(y,{"data-rmiz-content":ge,ref:N,style:Ae},u),he&&te.createElement(y,{"data-rmiz-ghost":"",style:X},te.createElement("button",{"aria-label":fe,"data-rmiz-btn-zoom":"",onClick:i,type:"button"},te.createElement(m,null))),he&&Jx.createPortal(te.createElement("dialog",{"aria-labelledby":re,"aria-modal":"true",className:h,"data-rmiz-modal":"",id:ee,onClick:n,onClose:r,onCancel:WLe,ref:M,role:"dialog"},te.createElement("div",{"data-rmiz-modal-overlay":Ee}),te.createElement("div",{"data-rmiz-modal-content":"",ref:_},Qe)),GLe()))}componentDidMount(){this.setId(),this.setAndTrackImg(),this.handleImgLoad(),this.UNSAFE_handleSvg()}componentWillUnmount(){this.state.modalState!=="UNLOADED"&&this.bodyScrollEnable(),this.contentChangeObserver?.disconnect(),this.contentNotFoundChangeObserver?.disconnect(),this.imgElResizeObserver?.disconnect(),this.imgEl?.removeEventListener("load",this.handleImgLoad),this.imgEl?.removeEventListener("click",this.handleZoom),this.refModalImg.current?.removeEventListener("transitionend",this.handleImgTransitionEnd),window.removeEventListener("wheel",this.handleWheel),window.removeEventListener("touchstart",this.handleTouchStart),window.removeEventListener("touchmove",this.handleTouchMove),window.removeEventListener("touchend",this.handleTouchEnd),window.removeEventListener("touchcancel",this.handleTouchCancel),window.removeEventListener("resize",this.handleResize),document.removeEventListener("keydown",this.handleKeyDown,!0)}componentDidUpdate(t,n){this.handleModalStateChange(n.modalState),this.UNSAFE_handleSvg(),this.handleIfZoomChanged(t.isZoomed)}}YY.defaultProps={a11yNameButtonUnzoom:"Minimize image",a11yNameButtonZoom:"Expand image",canSwipeToUnzoom:!0,IconUnzoom:DLe,IconZoom:jLe,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:"div",zoomMargin:0};const c8=({children:e,className:t,...n})=>d.jsx("div",{className:ie("absolute top-3 right-3 flex flex-row rounded px-0.5 opacity-0 group-hover/node-image:opacity-100","border-[0.5px] bg-[var(--mt-bg-secondary)] [backdrop-filter:saturate(1.8)_blur(20px)]",t),...n,children:e});c8.displayName="ActionWrapper";const $x=({icon:e,tooltip:t,className:n,...r})=>d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",className:ie("text-muted-foreground hover:text-foreground relative flex h-7 w-7 flex-row rounded-none p-0","bg-transparent hover:bg-transparent",n),...r,children:e})}),d.jsx(fa,{side:"bottom",children:t})]});$x.displayName="ActionButton";const YLe=[{key:"onView",icon:d.jsx(BDe,{}),tooltip:"View image"},{key:"onDownload",icon:d.jsx(vDe,{}),tooltip:"Download image"},{key:"onCopy",icon:d.jsx(dDe,{}),tooltip:"Copy image to clipboard"},{key:"onCopyLink",icon:d.jsx(tY,{}),tooltip:"Copy image link",isLink:!0}],ZY=({shouldMerge:e=!1,isLink:t=!1,...n})=>{const[r,s]=w.useState(!1),i=w.useCallback((a,l)=>{a.preventDefault(),a.stopPropagation(),l?.()},[]),o=w.useMemo(()=>YLe.filter(a=>t||!a.isLink),[t]);return d.jsx(c8,{className:ie({"opacity-100":r}),children:e?d.jsxs(Li,{open:r,onOpenChange:s,children:[d.jsx(Pi,{asChild:!0,children:d.jsx($x,{icon:d.jsx(eY,{}),tooltip:"Open menu",onClick:a=>a.preventDefault()})}),d.jsx($i,{className:"w-56",align:"end",children:o.map(({key:a,icon:l,tooltip:u})=>d.jsx(cl,{onClick:h=>i(h,n[a]),children:d.jsxs("div",{className:"flex flex-row items-center gap-2",children:[l,d.jsx("span",{children:u})]})},a))})]}):o.map(({key:a,icon:l,tooltip:u})=>d.jsx($x,{icon:l,tooltip:u,onClick:h=>i(h,n[a])},a))})};ZY.displayName="ImageActions";const ZLe=({editor:e,node:t,src:n,onViewClick:r})=>{const s=r6(n),i=w.useCallback(()=>{r(!0)},[r]),o=w.useCallback(()=>{e.commands.downloadImage({src:t.attrs.src,alt:t.attrs.alt})},[e.commands,t.attrs.alt,t.attrs.src]),a=w.useCallback(()=>{e.commands.copyImage({src:t.attrs.src})},[e.commands,t.attrs.src]),l=w.useCallback(()=>{e.commands.copyLink({src:t.attrs.src})},[e.commands,t.attrs.src]),u=w.useCallback(()=>{e.commands.command(({tr:h,dispatch:p})=>{const{selection:m}=h,b=h.doc.nodeAt(m.from);return b&&b.type.name==="image"&&p?(h.deleteSelection(),!0):!1})},[e.commands]);return{isLink:s,onView:i,onDownload:o,onCopy:a,onCopyLink:l,onRemoveImg:u}},XY=function({className:t,...n}){return d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",className:ie("animate-spin",t),...n,children:[d.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),d.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})};XY.displayName="Spinner";const QY=w.memo(XY),JY=w.memo(()=>d.jsx("div",{className:ie("flex flex-row items-center justify-center","absolute inset-0 rounded bg-[var(--mt-overlay)] opacity-100 transition-opacity"),children:d.jsx(QY,{className:"size-7"})}));JY.displayName="ImageOverlay";const U3=600,XLe=120,SI=120,QLe=e=>({src:typeof e=="string"?e:e.src,id:typeof e=="string"?Ax():e.id}),JLe=({editor:e,node:t,selected:n,updateAttributes:r})=>{const{src:s,width:i,height:o,fileName:a}=t.attrs,l=w.useRef(!1),u=w.useMemo(()=>typeof s=="string"?s:s.src,[s]),[h,p]=w.useState({src:u,isServerUploading:!1,imageLoaded:!1,isZoomed:!1,error:!1,naturalSize:{width:i,height:o}}),m=w.useRef(null),[b,y]=w.useState(null),x=w.useCallback(({width:W,height:Q})=>{r({width:W,height:Q})},[r]),S=h.naturalSize.width/h.naturalSize.height,C=U3*S,N=m.current?parseFloat(getComputedStyle(m.current).getPropertyValue("--editor-width")):1/0,{isLink:M,onView:_,onDownload:T,onCopy:R,onCopyLink:D,onRemoveImg:j}=ZLe({editor:e,node:t,src:h.src,onViewClick:W=>p(Q=>({...Q,isZoomed:W}))}),{currentWidth:L,currentHeight:V,updateDimensions:q,initiateResize:X,isResizing:ee}=OLe({initialWidth:i??h.naturalSize.width,initialHeight:o??h.naturalSize.height,contentWidth:h.naturalSize.width,contentHeight:h.naturalSize.height,gridInterval:.1,onDimensionsChange:x,minWidth:SI,minHeight:XLe,maxWidth:N>0?N:C}),re=w.useMemo(()=>L<=180,[L]),oe=w.useCallback(W=>{const Q=W.target,H={width:Q.naturalWidth,height:Q.naturalHeight};p(U=>({...U,naturalSize:H,imageLoaded:!0})),r({width:Q.width||H.width,height:Q.height||H.height,alt:Q.alt,title:Q.title}),i||q(U=>({...U,width:H.width}))},[i,r,q]),F=w.useCallback(()=>{p(W=>({...W,error:!0,imageLoaded:!0}))},[]),se=w.useCallback(W=>Q=>{y(W),X(W)(Q)},[X]),le=w.useCallback(()=>{y(null)},[]);return w.useEffect(()=>{ee||le()},[ee,le]),w.useEffect(()=>{(async()=>{if(!u.startsWith("blob:")||l.current)return;l.current=!0;const Q=e.options.extensions.find(U=>U.name==="image"),{uploadFn:H}=Q?.options??{};if(!H){try{const U=await JDe(u);p(Z=>({...Z,src:U})),r({src:U})}catch{p(U=>({...U,error:!0}))}return}try{p(ge=>({...ge,isServerUploading:!0}));const Z=await(await fetch(u)).blob(),he=new File([Z],a,{type:Z.type}),fe=await H(he,e),ye=QLe(fe);p(ge=>({...ge,...ye,isServerUploading:!1})),r(ye)}catch{p(U=>({...U,error:!0,isServerUploading:!1}))}})()},[e,a,u,r]),d.jsx(JOe,{ref:m,"data-drag-handle":!0,className:"relative text-center leading-none",children:d.jsx("div",{className:"group/node-image relative mx-auto rounded-md object-contain",style:{maxWidth:`min(${C}px, 100%)`,width:L,maxHeight:U3,aspectRatio:`${h.naturalSize.width} / ${h.naturalSize.height}`},children:d.jsxs("div",{className:ie("relative flex h-full cursor-default flex-col items-center gap-2 rounded",{"outline-primary outline-2 outline-offset-1":n||ee}),children:[d.jsxs("div",{className:"h-full contain-paint",children:[d.jsxs("div",{className:"relative h-full",children:[h.isServerUploading&&!h.error&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:d.jsx(QY,{className:"size-7"})}),h.error&&d.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[d.jsx(TDe,{className:"text-destructive size-8"}),d.jsx("p",{className:"text-muted-foreground mt-2 text-sm",children:"Failed to load image"})]}),d.jsx(KLe,{isZoomed:h.isZoomed,onZoomChange:()=>p(W=>({...W,isZoomed:!1})),children:d.jsx("img",{className:ie("h-auto rounded object-contain transition-shadow",{"opacity-0":!h.imageLoaded||h.error}),style:{maxWidth:`min(100%, ${C}px)`,minWidth:`${SI}px`,maxHeight:U3},width:L,height:V,src:h.src,onError:F,onLoad:oe,alt:t.attrs.alt||"",title:t.attrs.title||"",id:t.attrs.id})})]}),h.isServerUploading&&d.jsx(JY,{}),e.isEditable&&h.imageLoaded&&!h.error&&!h.isServerUploading&&d.jsxs(d.Fragment,{children:[d.jsx(c6,{onPointerDown:se("left"),className:ie("left-1",{hidden:ee&&b==="right"}),isResizing:ee&&b==="left"}),d.jsx(c6,{onPointerDown:se("right"),className:ie("right-1",{hidden:ee&&b==="left"}),isResizing:ee&&b==="right"})]})]}),h.error&&d.jsx(c8,{children:d.jsx($x,{icon:d.jsx(WDe,{}),tooltip:"Remove image",onClick:j})}),!ee&&!h.error&&!h.isServerUploading&&d.jsx(ZY,{shouldMerge:re,isLink:M,onView:_,onDownload:T,onCopy:R,onCopyLink:D})]})})})},u8=(e,t,n)=>{const r=e instanceof Error?e:new Error("Unknown error");n?.(r,t)},ePe=e=>{const[t,n]=e.split(","),r=t.split(":")[1].split(";")[0],s=r.split("/")[1],i=atob(n),o=new Uint8Array(i.length);for(let l=0;l<i.length;l++)o[l]=i.charCodeAt(l);return{blob:new Blob([o],{type:r}),extension:s}},tPe=async e=>{const t=await fetch(e);if(!t.ok)throw new Error("Failed to fetch image");const n=await t.blob(),r=n.type.split(/\/|\+/)[1];return{blob:n,extension:r}},nPe=async e=>e.startsWith("data:")?ePe(e):tPe(e),rPe=async(e,t,n)=>{const r=URL.createObjectURL(e),s=document.createElement("a");s.href=r,s.download=`${t}.${n}`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r)},sPe=async(e,t)=>{const{src:n,alt:r}=e,s=r||"image";try{const{blob:i,extension:o}=await nPe(n);await rPe(i,s,o),t.onActionSuccess?.({...e,action:"download"})}catch(i){u8(i,{...e,action:"download"},t.onActionError)}},iPe=async(e,t)=>{const{src:n}=e;try{const s=await(await fetch(n)).blob();await navigator.clipboard.write([new ClipboardItem({[s.type]:s})]),t.onActionSuccess?.({...e,action:"copyImage"})}catch(r){u8(r,{...e,action:"copyImage"},t.onActionError)}},oPe=async(e,t)=>{const{src:n}=e;try{await navigator.clipboard.writeText(n),t.onActionSuccess?.({...e,action:"copyLink"})}catch(r){u8(r,{...e,action:"copyLink"},t.onActionError)}},aPe=Wq.extend({atom:!0,addOptions(){return{...this.parent?.()||{},inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1,allowedMimeTypes:[],maxFileSize:0,uploadFn:void 0,onToggle:void 0,downloadImage:void 0,copyImage:void 0,copyLink:void 0}},addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},id:{default:null},width:{default:null},height:{default:null},fileName:{default:null}}},addCommands(){return{setImages:e=>({commands:t})=>{const[n,r]=Rx(e,{allowedMimeTypes:this.options.allowedMimeTypes,maxFileSize:this.options.maxFileSize,allowBase64:this.options.allowBase64});return r.length>0&&this.options.onValidationError&&this.options.onValidationError(r),n.length>0?t.insertContent(n.map(s=>{if(s.src instanceof File){const i=URL.createObjectURL(s.src),o=Ax();return{type:this.type.name,attrs:{id:o,src:i,alt:s.alt,title:s.title,fileName:s.src.name}}}else return{type:this.type.name,attrs:{id:Ax(),src:s.src,alt:s.alt,title:s.title,fileName:null}}})):!1},downloadImage:e=>()=>((this.options.downloadImage||sPe)({...e,action:"download"},this.options),!0),copyImage:e=>()=>((this.options.copyImage||iPe)({...e,action:"copyImage"},this.options),!0),copyLink:e=>()=>((this.options.copyLink||oPe)({...e,action:"copyLink"},this.options),!0),toggleImage:()=>({editor:e})=>{const t=document.createElement("input");return t.type="file",t.accept=this.options.allowedMimeTypes.join(","),t.onchange=()=>{const n=t.files;if(!n)return;const[r,s]=Rx(Array.from(n),{allowedMimeTypes:this.options.allowedMimeTypes,maxFileSize:this.options.maxFileSize,allowBase64:this.options.allowBase64});return s.length>0&&this.options.onValidationError?(this.options.onValidationError(s),!1):(r.length===0||this.options.onToggle&&this.options.onToggle(e,r,e.state.selection.from),!1)},t.click(),!0}}},onTransaction({transaction:e}){e.steps.forEach(t=>{t instanceof $s&&t.slice.size===0&&e.before.content.cut(t.from,t.to).forEach(r=>{if(r.type.name==="image"){const s=r.attrs;s.src.startsWith("blob:")&&URL.revokeObjectURL(s.src),this.options.onImageRemoved?.(s)}})})},addNodeView(){return iDe(JLe,{className:"block-node"})}}),lPe=vn.create({addKeyboardShortcuts(){return{"Mod-\\":()=>this.editor.commands.unsetAllMarks()}}}),cPe=vn.create({name:"resetMarksOnEnter",addKeyboardShortcuts(){return{Enter:({editor:e})=>e.isActive("bold")||e.isActive("italic")||e.isActive("strike")||e.isActive("underline")||e.isActive("code")?(e.commands.splitBlock({keepMarks:!1}),!0):!1}}}),uPe=e=>{const{key:t,editor:n,onPaste:r,onDrop:s,onValidationError:i,allowedMimeTypes:o,maxFileSize:a}=e;return new Wn({key:t||new ar("fileHandler"),props:{handleDrop(l,u){const{dataTransfer:h}=u;if(!h?.files.length)return!1;u.preventDefault(),u.stopPropagation();const p=l.posAtCoords({left:u.clientX,top:u.clientY}),[m,b]=Rx(Array.from(h.files),{allowedMimeTypes:o,maxFileSize:a,allowBase64:e.allowBase64});return b.length>0&&i&&i(b),m.length>0&&s&&s(n,m,p?.pos??0),!0},handlePaste(l,u){const{clipboardData:h}=u;if(!h?.files.length)return!1;u.preventDefault(),u.stopPropagation();const[p,m]=Rx(Array.from(h.files),{allowedMimeTypes:o,maxFileSize:a,allowBase64:e.allowBase64}),b=h.getData("text/html");return m.length>0&&i&&i(m),p.length>0&&r&&r(n,p,b),!0}}})},dPe=vn.create({name:"fileHandler",addOptions(){return{allowBase64:!1,allowedMimeTypes:[],maxFileSize:0}},addProseMirrorPlugins(){return[uPe({key:new ar(this.name),editor:this.editor,...this.options})]}});function fPe(e){return/^#{1,6}\s/.test(e)||/\*\*[^*]+\*\*/.test(e)||/\*[^*]+\*/.test(e)||/\[.+\]\(.+\)/.test(e)||/^[-*+]\s/.test(e)||/^\d+\.\s/.test(e)||/^>\s/.test(e)||/`[^`]+`/.test(e)||/^```/.test(e)}const hPe=vn.create({name:"markdownPaste",addProseMirrorPlugins(){const{editor:e}=this;return[new Wn({key:new ar("markdownPaste"),props:{handlePaste:(t,n)=>{const r=n.clipboardData;if(!r||r.getData("text/html"))return!1;const i=r.getData("text/plain");if(!i||!e.markdown||!fPe(i))return!1;try{return e.commands.insertContent(i,{contentType:"markdown"}),n.preventDefault(),!0}catch{return!1}}}})]}});function pPe(e,t){const n=w.useRef(Date.now()),r=w.useRef(null);return w.useCallback((...s)=>{Date.now()-n.current>=t?(e(...s),n.current=Date.now()):(r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{e(...s),n.current=Date.now()},t-(Date.now()-n.current)))},[e,t])}async function mPe(e){return await new Promise(n=>setTimeout(n,3e3)),await s6(e)}const gPe=({placeholder:e,uploader:t,output:n="html"})=>[zW.configure({blockquote:{HTMLAttributes:{class:"block-node"}},bulletList:{HTMLAttributes:{class:"list-node"}},code:{HTMLAttributes:{class:"inline",spellcheck:"false"}},codeBlock:!1,dropcursor:{width:2,class:"ProseMirror-dropcursor border"},heading:{HTMLAttributes:{class:"heading-node"}},horizontalRule:!1,link:{enableClickSelection:!0,openOnClick:!1,HTMLAttributes:{class:"link"}},orderedList:{HTMLAttributes:{class:"list-node"}},paragraph:{HTMLAttributes:{class:"text-node"}}}),aPe.configure({allowedMimeTypes:["image/*"],maxFileSize:5*1024*1024,allowBase64:!0,uploadFn:async r=>t?await t(r):await mPe(r),onToggle(r,s,i){r.commands.insertContentAt(i,s.map(o=>{const a=URL.createObjectURL(o);return{type:"image",attrs:{id:Ax(),src:a,alt:o.name,title:o.name,fileName:o.name}}}))},onImageRemoved({id:r,src:s}){console.log("Image removed",{id:r,src:s})},onValidationError(r){r.forEach(s=>{_n.error("Image validation error",{position:"bottom-right",description:s.reason})})},onActionSuccess({action:r}){const s={copyImage:"Copy Image",copyLink:"Copy Link",download:"Download"};_n.success(s[r],{position:"bottom-right",description:"Image action success"})},onActionError(r,{action:s}){const i={copyImage:"Copy Image",copyLink:"Copy Link",download:"Download"};_n.error(`Failed to ${i[s]}`,{position:"bottom-right",description:r.message})}}),dPe.configure({allowBase64:!0,allowedMimeTypes:["image/*"],maxFileSize:5*1024*1024,onDrop:(r,s,i)=>{s.forEach(async o=>{const a=await s6(o);r.commands.insertContentAt(i,{type:"image",attrs:{src:a}})})},onPaste:(r,s)=>{s.forEach(async i=>{const o=await s6(i);r.commands.insertContent({type:"image",attrs:{src:o}})})},onValidationError:r=>{r.forEach(s=>{_n.error("Image validation error",{position:"bottom-right",description:s.reason})})}}),ALe,bY,BNe,Xje,lPe,RLe,cPe,TLe,FNe.configure({placeholder:()=>e}),...n==="markdown"?[QIe.configure({markedOptions:{gfm:!0}}),AW.configure({HTMLAttributes:{class:"task-list-node"}}),TW.configure({nested:!0}),B6e.configure({table:{resizable:!0,HTMLAttributes:{class:"table-node"}}}),hPe]:[]],bPe=({value:e,output:t="html",placeholder:n="",editorClassName:r,throttleDelay:s=0,onUpdate:i,onBlur:o,uploader:a,...l})=>{const u=pPe(y=>i?.(y),s),h=w.useCallback(y=>u(eI(y,t)),[t,u]),p=w.useCallback(y=>{e&&y.isEmpty&&y.commands.setContent(e,{contentType:t==="markdown"?"markdown":void 0})},[e,t]),m=w.useCallback(y=>o?.(eI(y,t)),[t,o]);return XOe({immediatelyRender:!1,extensions:gPe({placeholder:n,uploader:a,output:t}),editorProps:{attributes:{autocomplete:"off",autocorrect:"off",autocapitalize:"off",class:ie("focus:outline-hidden",r)}},onUpdate:({editor:y})=>h(y),onCreate:({editor:y})=>p(y),onBlur:({editor:y})=>m(y),...l})},yPe={top:0,left:0,bottom:0,right:0,x:0,y:0,width:0,height:0,toJSON:()=>"{}"};function vPe(e){const[t,n]=w.useState(()=>e?.getBoundingClientRect()??yPe),r=w.useCallback(()=>{if(!e)return;const s=e.getBoundingClientRect();n(i=>Math.round(i.width)===Math.round(s.width)&&Math.round(i.height)===Math.round(s.height)&&Math.round(i.x)===Math.round(s.x)&&Math.round(i.y)===Math.round(s.y)?i:s)},[e]);return w.useEffect(()=>{if(!e)return;const s=new ResizeObserver(r);return s.observe(e),window.addEventListener("click",r),window.addEventListener("resize",r),()=>{s.disconnect(),window.removeEventListener("click",r),window.removeEventListener("resize",r)}},[e,r]),t}const eZ=({as:e,name:t,children:n,style:r={},...s})=>{const i=w.useRef(null),o=vPe(i.current),a={[`--${t}-width`]:`${o.width}px`,[`--${t}-height`]:`${o.height}px`};return d.jsx(e,{...s,ref:i,style:{...a,...r},children:n})};eZ.displayName="MeasuredContainer";function xPe(e){const{editor:t}=WN(),n=w.useMemo(()=>e||t,[e,t]);return WK({editor:n,selector(s){return s.editor?{editor:s.editor,editorState:s.editor.state,canCommand:s.editor.can}:{editor:null,editorState:void 0,canCommand:void 0}}})||{editor:null}}const wPe=({editor:e})=>d.jsx("div",{className:"border-border flex h-12 shrink-0 overflow-x-auto border-b p-2",children:d.jsxs("div",{className:"flex w-max items-center gap-px",children:[d.jsx(QK,{editor:e}),d.jsx(Ri,{orientation:"vertical",className:"mx-2"}),d.jsx(rY,{editor:e,activeLevels:[1,2,3,4,5,6]}),d.jsx(Ri,{orientation:"vertical",className:"mx-2"}),d.jsx(sY,{editor:e,activeActions:["bold","italic","underline","strikethrough","code","clearFormatting"],mainActionCount:4}),d.jsx(Ri,{orientation:"vertical",className:"mx-2"}),d.jsx(aY,{editor:e}),d.jsx(Ri,{orientation:"vertical",className:"mx-2"}),d.jsx(lY,{editor:e,activeActions:["orderedList","bulletList"],mainActionCount:0}),d.jsx(Ri,{orientation:"vertical",className:"mx-2"}),d.jsx(cY,{editor:e,activeActions:["codeBlock","blockquote","horizontalRule"],mainActionCount:2})]})}),tZ=({value:e,onChange:t,className:n,editorContentClassName:r,...s})=>{const i=bPe({value:e,onUpdate:t,...s});return i?d.jsx(jw.Provider,{value:{editor:i},children:d.jsx(SPe,{editor:i,className:n,editorContentClassName:r})}):null};tZ.displayName="MinimalTiptapEditor";const SPe=({editor:e,className:t,editorContentClassName:n})=>{const{editor:r}=xPe(e);return r?d.jsxs(eZ,{as:"div",name:"editor",className:ie("border-input min-data-[orientation=vertical]:h-72 flex h-auto w-full min-w-0 flex-col rounded-md border shadow-xs","focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]",t),children:[d.jsx(wPe,{editor:r}),d.jsx(GK,{editor:r,className:ie("minimal-tiptap-editor",n)}),d.jsx(Oje,{editor:r})]}):null};function CPe({value:e,onChange:t,placeholder:n}){const r=w.useRef([]),s=w.useRef(e);w.useEffect(()=>{s.current=e},[e]);const i=async a=>{const l=new FormData;l.append("file",a);const{data:u}=await Gt.post("/upload",l);return r.current.push(u.url),u.url};w.useEffect(()=>()=>{const a=String(s.current||"");r.current.filter(u=>!a.includes(u)).forEach(async u=>{try{const h=u.split("/").pop();h&&await Gt.delete(`/upload/${decodeURIComponent(h)}`)}catch(h){console.error("Session image cleanup failed for:",u,h)}})},[]);const o=e??"";return d.jsx(tZ,{value:o,onChange:a=>{t(typeof a=="string"?a:String(a))},className:"w-full",editorContentClassName:"p-5",output:"html",placeholder:n||"Scrivi qui il tuo contenuto...",autofocus:!1,editable:!0,editorClassName:"focus:outline-none",uploader:i})}function kPe({branch:e,value:t,onChange:n}){return d.jsx(CPe,{value:t,onChange:r=>n(r),placeholder:`Scrivi ${e.label.toLowerCase()}...`})}const CI="image/*",EPe=8e3;function NPe(e){return e.type==="file"&&(e.multiple===!0||e.format==="asset-list")}function nZ(e){try{return new URL(e).protocol==="https:"}catch{return!1}}async function MPe(e){return new Promise(t=>{const n=new Image;let r=!1;const s=()=>{n.onload=null,n.onerror=null},i=a=>{r||(r=!0,s(),t(a))},o=globalThis.setTimeout(()=>i(!1),EPe);n.onload=()=>{globalThis.clearTimeout(o),i(!0)},n.onerror=()=>{globalThis.clearTimeout(o),i(!1)},n.src=e})}function _Pe(e){try{return JSON.parse(e)}catch{return e}}function kI(e){if(typeof e!="string")return null;const t=e.trim();return nZ(t)?t:null}function bm(e){const t=typeof e=="string"?_Pe(e):e,n=Array.isArray(t)?t:[t],r=[];for(const s of n){if(s==null)continue;const i=kI(s);if(i){r.push(i);continue}if(typeof s=="object"&&!Array.isArray(s)){const o=kI(s.url);o&&r.push(o)}}return[...new Set(r)]}function EI(e,t){return e.includes(t)?e:[...e,t]}function TPe(e,t,n){if(n<0||n>=e.length||t===n)return e;const r=[...e],[s]=r.splice(t,1);return r.splice(n,0,s),r}function APe(e,t){return e.isMultiple?e.hasAssets?t("media.manageGallery"):t("media.addImages"):e.hasImage?t("media.replace"):t("media.addImage")}function RPe({branch:e,value:t,onChange:n}){const{t:r}=tt(),s=w.useRef(null),[i,o]=w.useState(!1),[a,l]=w.useState(!1),[u,h]=w.useState(!1),[p,m]=w.useState(!1),[b,y]=w.useState(null),[x,S]=w.useState(""),C=NPe(e),N=w.useMemo(()=>C?bm(t):[],[C,t]),M=typeof t=="string"?t:"",_=M.length>0,T=N.length>0,R=APe({isMultiple:C,hasAssets:T,hasImage:_},r),D=u||p;w.useEffect(()=>{i&&(S(C?"":M),y(null),l(!1))},[i,C,M]);const j=w.useCallback(async W=>{if(!W.type.startsWith("image/")){y(r("media.errorNotImage"));return}y(null),h(!0);try{const Q=new FormData;Q.append("file",W);const{data:H}=await Gt.post("/upload",Q);if(C){const U=bm(t);n(EI(U,H.url))}else n(H.url),o(!1)}catch(Q){y(Q instanceof Error?Q.message:"Error during upload")}finally{h(!1)}},[C,n,t]),L=w.useCallback(async()=>{const W=x.trim();if(!W){y(r("media.errorUrl"));return}if(!nZ(W)){y(r("media.errorHttps"));return}y(null),m(!0);try{if(!await MPe(W)){y(r("media.errorNotRenderable"));return}if(C){const H=bm(t);n(EI(H,W)),S("")}else n(W),o(!1)}finally{m(!1)}},[C,n,x,t]),V=w.useCallback(W=>{W.preventDefault(),l(!1);const Q=W.dataTransfer.files[0];Q&&j(Q)},[j]),q=w.useCallback(W=>{W.preventDefault(),D||l(!0)},[D]),X=w.useCallback(()=>{l(!1)},[]),ee=w.useCallback(W=>{const Q=W.target.files?.[0];Q&&j(Q),W.target.value=""},[j]),re=w.useCallback(()=>{D||s.current?.click()},[D]),oe=w.useCallback(()=>{n("")},[n]),F=w.useCallback(W=>{const Q=bm(t);n(Q.filter((H,U)=>U!==W))},[n,t]),se=w.useCallback((W,Q)=>{const H=bm(t),U=Q==="up"?W-1:W+1;n(TPe(H,W,U))},[n,t]),le=w.useCallback(()=>{n([]),o(!1)},[n]);return C?d.jsx("div",{className:"space-y-3",children:d.jsxs("div",{className:"flex items-start gap-3",children:[T?d.jsx("div",{className:"grid grid-cols-2 gap-1",children:N.slice(0,4).map(W=>d.jsx("div",{className:"relative size-16 overflow-hidden rounded-md border border-input bg-muted",children:d.jsx("img",{src:W,alt:"",className:"size-full object-cover"})},W))}):d.jsx("div",{className:"flex size-16 shrink-0 items-center justify-center rounded-md border border-dashed border-input bg-muted/40",children:d.jsx(xm,{className:"size-5 text-muted-foreground"})}),d.jsx("div",{className:"flex flex-col items-start gap-2",children:d.jsxs(kf,{open:i,onOpenChange:o,children:[d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:"w-fit",onClick:()=>o(!0),children:[d.jsx(xm,{className:"size-4"}),R]}),d.jsxs(Ef,{children:[d.jsxs(Ip,{children:[d.jsx(zp,{children:R}),d.jsx(Nx,{children:r("media.dialogDesc")})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{htmlFor:`${e.alias}-url`,className:"text-sm font-medium",children:r("media.imageLink")}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(Xt,{id:`${e.alias}-url`,type:"url",value:x,onChange:W=>S(W.target.value),placeholder:"https://example.com/image.jpg",disabled:D}),d.jsx(Oe,{type:"button",variant:"secondary",onClick:()=>{L()},disabled:D,children:p?d.jsxs(d.Fragment,{children:[d.jsx(ta,{className:"size-4 animate-spin"}),r("media.verifying")]}):d.jsxs(d.Fragment,{children:[d.jsx(oC,{className:"size-4"}),r("media.add")]})})]})]}),d.jsxs("button",{type:"button",onClick:re,onDrop:V,onDragOver:q,onDragLeave:X,className:ie("w-full rounded-lg border-2 border-dashed p-5 text-center transition-colors","hover:border-primary/50 hover:bg-muted/50",a&&"border-primary bg-muted/50",D&&"pointer-events-none opacity-70"),children:[d.jsx("input",{ref:s,id:`${e.alias}-file`,type:"file",accept:CI,className:"hidden",onChange:ee}),u?d.jsxs("div",{className:"flex flex-col items-center gap-2",children:[d.jsx(ta,{className:"size-8 animate-spin text-muted-foreground"}),d.jsx("span",{className:"text-sm text-muted-foreground",children:r("media.uploading")})]}):d.jsx("p",{className:"text-sm text-muted-foreground",children:r("media.dropOrSelect")})]}),N.length>0?d.jsx("div",{className:"max-h-52 space-y-2 overflow-y-auto rounded-md border border-input p-2",children:N.map((W,Q)=>d.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-input bg-background p-2",children:[d.jsx("img",{src:W,alt:"",className:"size-10 shrink-0 rounded object-cover"}),d.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:W}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",onClick:()=>se(Q,"up"),disabled:Q===0||D,"aria-label":r("media.moveUp"),children:d.jsx(AJ,{className:"size-4"})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",onClick:()=>se(Q,"down"),disabled:Q===N.length-1||D,"aria-label":r("media.moveDown"),children:d.jsx(CJ,{className:"size-4"})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",onClick:()=>F(Q),disabled:D,"aria-label":r("media.removeImage"),children:d.jsx(ro,{className:"size-4"})})]})]},`${W}-${Q}`))}):null,b?d.jsx("p",{className:"text-sm text-destructive",children:b}):null]}),d.jsxs(Ex,{children:[N.length>0?d.jsxs(Oe,{type:"button",variant:"destructive",onClick:le,disabled:D,children:[d.jsx(ro,{className:"size-4"}),r("media.removeAll")]}):null,d.jsx(Oe,{type:"button",variant:"outline",onClick:()=>o(!1),disabled:D,children:r("common.close")})]})]})]})})]})}):d.jsx("div",{className:"space-y-3",children:d.jsxs("div",{className:"flex items-start gap-3",children:[_?d.jsx("div",{className:"relative size-16 shrink-0 overflow-hidden rounded-md border border-input bg-muted",children:d.jsx("img",{src:M,alt:"",className:"size-full object-cover"})}):d.jsx("div",{className:"flex size-16 shrink-0 items-center justify-center rounded-md border border-dashed border-input bg-muted/40",children:d.jsx(xm,{className:"size-5 text-muted-foreground"})}),d.jsx("div",{className:"flex flex-col items-start gap-2",children:d.jsxs(kf,{open:i,onOpenChange:o,children:[d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:"w-fit",onClick:()=>o(!0),children:[d.jsx(xm,{className:"size-4"}),R]}),d.jsxs(Ef,{children:[d.jsxs(Ip,{children:[d.jsxs(zp,{children:[R," image"]}),d.jsx(Nx,{children:r("media.dialogDesc")})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{htmlFor:`${e.alias}-url`,className:"text-sm font-medium",children:r("media.imageLink")}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(Xt,{id:`${e.alias}-url`,type:"url",value:x,onChange:W=>S(W.target.value),placeholder:"https://example.com/image.jpg",disabled:D}),d.jsx(Oe,{type:"button",variant:"secondary",onClick:()=>{L()},disabled:D,children:p?d.jsxs(d.Fragment,{children:[d.jsx(ta,{className:"size-4 animate-spin"}),r("media.verifying")]}):d.jsxs(d.Fragment,{children:[d.jsx(oC,{className:"size-4"}),r("media.useLink")]})})]})]}),d.jsxs("button",{type:"button",onClick:re,onDrop:V,onDragOver:q,onDragLeave:X,className:ie("w-full rounded-lg border-2 border-dashed p-5 text-center transition-colors","hover:border-primary/50 hover:bg-muted/50",a&&"border-primary bg-muted/50",D&&"pointer-events-none opacity-70"),children:[d.jsx("input",{ref:s,id:`${e.alias}-file`,type:"file",accept:CI,className:"hidden",onChange:ee}),u?d.jsxs("div",{className:"flex flex-col items-center gap-2",children:[d.jsx(ta,{className:"size-8 animate-spin text-muted-foreground"}),d.jsx("span",{className:"text-sm text-muted-foreground",children:r("media.uploading")})]}):d.jsx("p",{className:"text-sm text-muted-foreground",children:r("media.dropOrSelect")})]}),b?d.jsx("p",{className:"text-sm text-destructive",children:b}):null]}),d.jsxs(Ex,{children:[_?d.jsxs(Oe,{type:"button",variant:"destructive",onClick:()=>{oe(),o(!1)},disabled:D,children:[d.jsx(ro,{className:"size-4"}),r("media.removeImage")]}):null,d.jsx(Oe,{type:"button",variant:"outline",onClick:()=>o(!1),disabled:D,children:r("common.close")})]})]})]})})]})})}const Ci=new $Me;Ci.registerDisplay("text",qMe);Ci.registerDisplay("number",GMe);Ci.registerDisplay("boolean",WMe);Ci.registerDisplay("date",KMe);Ci.registerDisplay("json",QMe);Ci.registerDisplay("richtext",t_e);Ci.registerDisplay("file",i_e);Ci.registerEdit("text",o_e);Ci.registerEdit("number",a_e);Ci.registerEdit("boolean",l_e);Ci.registerEdit("date",KRe);Ci.registerEdit("json",QRe);Ci.registerEdit("richtext",kPe);Ci.registerEdit("file",RPe);function OPe(e){return Ci.getDisplay(e)??FMe}function DPe(e){return Ci.getEdit(e)??BMe}function rZ(e){const{branch:t}=e,{visibility:n}=Ew(t);if(n==="hidden")return null;const r=OPe(t.type);return n==="masked"?d.jsx(r,{...e,value:"••••••••"}):d.jsx(r,{...e})}function d8(e){const{branch:t}=e,{privacy:n}=Ew(t);if(n==="hash"||n==="encrypt")return d.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-dashed px-3 py-2 text-sm text-muted-foreground",children:[d.jsx("span",{children:"••••••••"}),d.jsx("span",{className:"text-xs",children:"(campo sensibile — non modificabile)"})]});const r=DPe(t.type);return d.jsx(r,{...e})}function jPe({className:e,orientation:t="horizontal",...n}){return d.jsx(Tue,{"data-slot":"tabs","data-orientation":t,orientation:t,className:ie("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...n})}const IPe=Df("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function zPe({className:e,variant:t="default",...n}){return d.jsx(Aue,{"data-slot":"tabs-list","data-variant":t,className:ie(IPe({variant:t}),e),...n})}function NI({className:e,...t}){return d.jsx(Rue,{"data-slot":"tabs-trigger",className:ie("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background dark:data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",e),...t})}function MI({className:e,...t}){return d.jsx(Oue,{"data-slot":"tabs-content",className:ie("flex-1 outline-none",e),...t})}function _I(e){return e.alias.startsWith("meta")}function LPe(e){return e.type==="json"&&e.alias.toLowerCase().includes("tag")}function PPe(e){const t=e.alias.trim().toLowerCase();return t==="title"||t==="name"}function $Pe(e){const t=e.branches.find(LPe)??null,n=e.branches.filter(_I),r=e.branches.filter(s=>!_I(s)&&!PPe(s)&&s.alias!==t?.alias);return{tagsBranch:t,seoBranches:n,mainBranches:r}}function FPe(e){const t=e.find(r=>r.type==="richtext")??null,n=t?e.filter(r=>r.alias!==t.alias):e;return{richtextBranch:t,otherMainBranches:n}}function BPe(e){const t=e.trim().toLowerCase();return t?["error","failed","rejected","archived"].includes(t)?"destructive":["published","active","approved","online"].includes(t)?"default":"outline":"secondary"}function Lw(e){if(typeof e=="string"){const t=e.trim();if(!t)return null;try{const n=JSON.parse(t);if(n&&typeof n=="object")return Lw(n)}catch{}return t}if(e&&typeof e=="object"){const t=e;return[t.url,t.src,t.path].find(r=>typeof r=="string"&&r.trim().length>0)?.trim()??null}return null}function Fx(e){return typeof e=="string"?e.replaceAll(/<[^>]*>/g," ").replaceAll(/\s+/g," ").trim():typeof e=="number"||typeof e=="boolean"?String(e):Array.isArray(e)?e.map(t=>Fx(t)).join(" ").trim():e&&typeof e=="object"?Object.values(e).map(t=>Fx(t)).join(" ").trim():""}function HPe(e,t=50){const n=Fx(e);return n?n.length<=t?n:`${n.slice(0,t).trimEnd()}…`:""}function UPe(e){if(e==null||e==="")return"";const t=new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleDateString("it-IT",{year:"numeric",month:"short",day:"numeric"})}function VPe(e,t){const n=e.status?.trim()||"—",r=t.tagsBranch?Cg(e.data[t.tagsBranch.alias]):[],s=t.coverBranch?Lw(e.data[t.coverBranch.alias]):null,i=t.titleBranch?Fx(e.data[t.titleBranch.alias]):"",o=t.excerptBranch?HPe(e.data[t.excerptBranch.alias],90):"",a=t.dateBranch?UPe(e.data[t.dateBranch.alias]):"",l=i?`Apri dettaglio: ${i}`:`Apri dettaglio entry ${e.id}`;return{entryId:e.id,status:n,tags:r,imageUrl:s,title:i,excerpt:o,dateText:a,ariaLabel:l,statusVariant:BPe(n)}}function qPe(e,t){return t.some(n=>e.includes(n))}function sZ(e){const t=e.branches,n=t.find(a=>{if(a.type!=="file")return!1;const l=a.alias.trim().toLowerCase();return qPe(l,["cover","image","foto","photo"])})??null,r=t.find(a=>{const l=a.alias.trim().toLowerCase();return l==="title"||l==="name"})??null,s=t.find(a=>a.type!=="richtext"&&a.type!=="text"?!1:r?a.alias!==r.alias:!0)??null,i=t.find(a=>a.type==="date")??null,o=t.find(a=>a.type!=="json"?!1:a.alias.toLowerCase().includes("tag"))??null;return{coverBranch:n,titleBranch:r,excerptBranch:s,dateBranch:i,tagsBranch:o}}function GPe(e,t){const n=e.branches.find(r=>{const s=r.alias.toLowerCase();return s==="title"||s==="name"});if(n){const r=t.data[n.alias];if(typeof r=="string"&&r.trim().length>0)return r.trim()}return t.slug?.trim()||t.id}const TI=4;function WPe({tags:e,className:t}){const[n,r]=w.useState(!1);if(e.length===0)return null;const s=e.length>TI;return d.jsxs("div",{className:ie("space-y-1.5",t),children:[d.jsx("p",{className:"text-muted-foreground text-[11px] font-medium tracking-wide uppercase",children:"Tag"}),d.jsx(Mx,{tags:e,maxVisible:TI,expanded:n,onExpandedChange:r,enableToggle:!0,showCollapseBadge:!1,className:"min-w-0 gap-1.5",chipClassName:"min-w-0 max-w-[12rem] truncate font-normal",renderMoreTrigger:(i,o)=>d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:"h-6 rounded-full px-2.5 text-xs",onClick:o,children:["+",i," altri"]})}),s&&n&&d.jsx(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground",onClick:()=>r(!1),children:"Mostra meno"})]})}function KPe(e){return e.replaceAll(/<[^>]*>/g,"").replaceAll(" "," ").trim().length===0}function YPe({value:e,className:t}){const n=LW(e);return KPe(n)?d.jsx("div",{className:"text-muted-foreground text-sm",children:"—"}):d.jsx("div",{className:ie("richtext-content rounded-md bg-transparent text-sm leading-relaxed","[&_table]:w-full [&_table]:border-collapse [&_table]:text-sm","[&_th]:border [&_td]:border [&_th]:border-border [&_td]:border-border [&_th]:bg-muted/40 [&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1","[&_p]:mb-2 [&_a]:text-primary [&_a]:underline",t),dangerouslySetInnerHTML:{__html:n}})}function ZPe(e){const t=e.toLowerCase().trim();return t==="published"?"bg-emerald-50 text-emerald-700 border-emerald-200/80 dark:bg-emerald-500/10 dark:text-emerald-400 dark:border-emerald-800/60":t==="draft"?"bg-amber-50 text-amber-700 border-amber-200/80 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-800/60":["error","failed","rejected","archived"].includes(t)?"bg-red-50 text-red-700 border-red-200/80 dark:bg-red-500/10 dark:text-red-400 dark:border-red-800/60":"bg-neutral-100 text-neutral-600 border-neutral-200/80 dark:bg-neutral-800 dark:text-neutral-400"}function AI({branch:e,entry:t}){const n=e.type==="file"?Lw(t.data[e.alias]):null;return d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e.label}),n?d.jsx("div",{className:"overflow-hidden rounded-xl border bg-muted/20",children:d.jsx("img",{src:n,alt:e.label,className:"h-auto max-h-[60vh] w-full object-contain"})}):d.jsx(rZ,{branch:e,value:t.data[e.alias]})]})}function XPe({seed:e,entry:t,open:n,onClose:r,onEdit:s}){const{tagsBranch:i,seoBranches:o,mainBranches:a}=w.useMemo(()=>$Pe(e),[e]),{richtextBranch:l,otherMainBranches:u}=w.useMemo(()=>FPe(a),[a]),h=w.useMemo(()=>sZ(e),[e]);if(!t)return null;const p=GPe(e,t),m=i?Cg(t.data[i.alias]):[],b=o.length>0,y=a.length===0&&o.length>0?"seo":"content",x=h.coverBranch?Lw(t.data[h.coverBranch.alias]):null,S=!!x,C=S?"h-[min(52vh,520px)] min-h-0":"h-[min(62vh,620px)] min-h-0",N=d.jsx(ml,{className:"h-full px-6 py-4",children:d.jsxs("div",{className:"space-y-5 pr-3",children:[l&&d.jsxs("div",{className:"overflow-hidden rounded-xl border border-neutral-200/80 dark:border-neutral-700/50",children:[d.jsx("div",{className:"border-b border-neutral-200/80 bg-neutral-50/80 px-4 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground dark:border-neutral-700/50 dark:bg-neutral-800/40",children:"Contenuto principale"}),d.jsx("div",{className:"px-4 py-4",children:d.jsx(YPe,{value:t.data[l.alias],className:"border-0 shadow-none"},t.id)})]}),u.length>0&&d.jsxs("div",{className:"space-y-5 px-1",children:[!l&&d.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Contenuto"}),u.map((_,T)=>d.jsxs(w.Fragment,{children:[d.jsx(AI,{branch:_,entry:t}),T<u.length-1&&d.jsx(Ri,{})]},_.alias))]}),!l&&u.length===0&&d.jsx("p",{className:"text-sm text-muted-foreground",children:"Nessun campo contenuto."})]})}),M=d.jsx(ml,{className:"h-full px-6 py-4",children:d.jsx("div",{className:"space-y-4 pr-3",children:d.jsxs("div",{className:"overflow-hidden rounded-xl border border-neutral-200/80 dark:border-neutral-700/50",children:[d.jsx("div",{className:"border-b border-neutral-200/80 bg-neutral-50/80 px-4 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground dark:border-neutral-700/50 dark:bg-neutral-800/40",children:"Metadati / SEO"}),d.jsx("div",{className:"space-y-5 px-4 py-4",children:o.map((_,T)=>d.jsxs(w.Fragment,{children:[d.jsx(AI,{branch:_,entry:t}),T<o.length-1&&d.jsx(Ri,{})]},_.alias))})]})})});return d.jsx(kf,{open:n,onOpenChange:_=>{_||r()},children:d.jsxs(Ef,{showCloseButton:!0,className:"flex max-h-[min(92vh,920px)] w-full max-w-[calc(100%-2rem)] flex-col gap-0 overflow-hidden p-0 sm:max-w-5xl","aria-describedby":void 0,children:[S&&d.jsxs("div",{className:"relative h-[200px] w-full shrink-0 overflow-hidden",children:[d.jsx("img",{src:x,alt:p||"Copertina",className:"h-full w-full object-cover"}),d.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-t from-background/80 via-background/20 to-transparent"})]}),d.jsx(Ip,{className:ie("shrink-0 space-y-0 px-6 pb-4 text-left",S?"pt-3":"pt-6"),children:d.jsxs("div",{className:"flex items-start justify-between gap-3 pr-8",children:[d.jsxs("div",{className:"min-w-0 flex-1 space-y-2.5",children:[d.jsx(zp,{className:"text-left text-xl font-semibold leading-snug",children:p}),d.jsx(WPe,{tags:m}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"font-medium",children:"Stato"}),d.jsx(gi,{variant:"outline",className:ie("text-[11px] font-medium",ZPe(t.status?.trim()||"")),children:t.status?.trim()||"—"})]}),t.slug!=null&&String(t.slug).trim()!==""&&d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":!0,className:"text-border",children:"·"}),d.jsxs("span",{className:"break-all font-mono text-[11px]",children:["/",String(t.slug).trim()]})]})]})]}),d.jsxs(Oe,{type:"button",variant:"default",size:"sm",className:"shrink-0 gap-1.5",onClick:()=>s(t.id),children:[d.jsx(I6,{className:"size-3.5"}),"Modifica"]})]})}),d.jsx(Ri,{}),b?d.jsxs(jPe,{defaultValue:y,className:"flex min-h-0 flex-1 flex-col gap-0",children:[d.jsx("div",{className:"shrink-0 border-b bg-neutral-50/80 px-6 dark:bg-neutral-800/30",children:d.jsxs(zPe,{variant:"line",className:"h-10 w-full justify-start gap-1 bg-transparent p-0",children:[d.jsx(NI,{value:"content",className:"text-sm",children:"Contenuto"}),d.jsx(NI,{value:"seo",className:"text-sm",children:"SEO"})]})}),d.jsx(MI,{value:"content",className:ie("mt-0 overflow-hidden",C),children:N}),d.jsx(MI,{value:"seo",className:ie("mt-0 overflow-hidden",C),children:M})]}):d.jsx("div",{className:ie("overflow-hidden",C),children:N})]})})}const QPe=["gallery-skeleton-1","gallery-skeleton-2","gallery-skeleton-3","gallery-skeleton-4","gallery-skeleton-5","gallery-skeleton-6","gallery-skeleton-7","gallery-skeleton-8"];function JPe(){return d.jsx("div",{className:"grid gap-5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 220px), 420px))",justifyContent:"center"},children:QPe.map(e=>d.jsxs("div",{className:"flex flex-col overflow-hidden rounded-2xl border border-neutral-200/80 bg-card dark:border-neutral-700/50",children:[d.jsxs("div",{className:"relative h-44 w-full shrink-0",children:[d.jsx(kr,{className:"h-full w-full rounded-none"}),d.jsx("div",{className:"absolute left-3 top-3",children:d.jsx(kr,{className:"h-5 w-16 rounded-full"})})]}),d.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[d.jsx(kr,{className:"h-4 w-10/12"}),d.jsx(kr,{className:"h-3 w-7/12"}),d.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-1",children:[d.jsx(Ri,{}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(kr,{className:"h-3 w-20"}),d.jsx(kr,{className:"h-5 w-14 rounded-full"})]})]})]})]},e))})}function e$e(e,t){const[n,r]=w.useState(null),s=w.useMemo(()=>t.find(a=>a.id===n)??null,[t,n]);w.useEffect(()=>{n&&(t.some(a=>a.id===n)||r(null))},[t,n]);const i=w.useMemo(()=>sZ(e),[e]),o=w.useMemo(()=>t.map(a=>VPe(a,i)),[t,i]);return{peekId:n,setPeekId:r,peekEntry:s,cardModels:o}}function t$e({seed:e,data:t,isLoading:n=!1,onEdit:r}){const{setPeekId:s,peekEntry:i,cardModels:o}=e$e(e,t);return n?d.jsx(JPe,{}):t.length===0?d.jsx(VW,{className:"border",children:d.jsxs(qW,{children:[d.jsx(GW,{variant:"icon",children:d.jsx(Tg,{className:"size-5"})}),d.jsx(WW,{children:"Nessun elemento da visualizzare"}),d.jsx(KW,{children:"Non ci sono contenuti disponibili per questa vista galleria."})]})}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"grid gap-5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 220px), 420px))",justifyContent:"center"},children:o.map(a=>d.jsx(PMe,{model:a,onOpen:s},a.entryId))}),d.jsx(XPe,{seed:e,entry:i,open:i!=null,onClose:()=>s(null),onEdit:r})]})}function n$e({open:e,onOpenChange:t,isActive:n,onOpen:r,searchTerm:s,onSearchTermChange:i,visibleFilterColumns:o,activeFiltersCountByColumn:a,onSelectColumn:l}){const{t:u}=tt();return d.jsxs(Li,{open:e,onOpenChange:h=>{t?.(h),h&&r?.(),h||i("")},children:[d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Pi,{asChild:!0,children:d.jsx(Oe,{variant:n?"secondary":"ghost",size:"icon-sm","aria-label":u("toolbar.filter.tooltip"),children:d.jsx(vz,{className:"size-4"})})})}),d.jsx(fa,{side:"top",children:u("toolbar.filter.tooltip")})]}),d.jsxs($i,{align:"end",className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:u("toolbar.filter.label")}),d.jsx(Xt,{placeholder:u("toolbar.filter.searchPlaceholder"),value:s,onChange:h=>i(h.target.value),className:"h-8 text-sm"}),d.jsx(ti,{className:"my-2"}),d.jsx("div",{className:"max-h-56 overflow-y-auto",children:o.length===0?d.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:u("toolbar.filter.noColumns")}):d.jsx("div",{className:"flex flex-col gap-1 py-1",children:o.map(h=>d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-8 justify-between px-2 text-xs",onClick:()=>l(h.columnId),children:[d.jsx("span",{className:"truncate",children:h.label}),a[h.columnId]?d.jsx("span",{className:"text-muted-foreground text-[10px] uppercase",children:a[h.columnId]}):null]},h.columnId))})})]})]})}function r$e({searchTerm:e,onSearchTermChange:t,filteredSortableColumns:n,sortState:r,onToggleDirection:s,onSelectColumn:i,isActive:o,onOpen:a}){const{t:l}=tt();return d.jsxs(Li,{onOpenChange:u=>{u||t(""),u&&a?.()},children:[d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Pi,{asChild:!0,children:d.jsx(Oe,{variant:o?"secondary":"ghost",size:"icon-sm","aria-label":l("toolbar.sort.tooltip"),children:d.jsx(of,{className:"size-4"})})})}),d.jsx(fa,{side:"top",children:l("toolbar.sort.tooltip")})]}),d.jsxs($i,{align:"end",className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:l("toolbar.sort.label")}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Xt,{placeholder:l("toolbar.sort.searchPlaceholder"),value:e,onChange:u=>t(u.target.value),className:"h-8 flex-1 text-sm"}),d.jsx(Oe,{type:"button",variant:"outline",size:"icon-sm",className:"h-8 w-8 shrink-0","aria-label":l("toolbar.sort.invertOrder"),onClick:s,disabled:!r?.columnId,children:d.jsx(of,{className:"size-3.5"})})]}),d.jsx(ti,{className:"my-2"}),d.jsx("div",{className:"max-h-56 overflow-y-auto",children:n.length===0?d.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:l("toolbar.sort.noColumns")}):d.jsx("div",{className:"flex flex-col gap-1 py-1",children:n.map(u=>{const h=r?.columnId===u.alias;return d.jsxs(Oe,{type:"button",variant:h?"secondary":"ghost",size:"sm",className:"h-8 justify-between px-2 text-xs",onClick:()=>i(u.alias),children:[d.jsx("span",{className:"truncate",children:u.label}),h&&d.jsx("span",{className:"text-muted-foreground text-[10px] uppercase",children:r?.desc?"DESC":"ASC"})]},u.alias)})})})]})]})}function iZ({type:e,value:t,onChange:n,selectOptions:r=[],availableTags:s=[],className:i="h-8 flex-1",textClassName:o="text-xs",buttonPlaceholder:a}){const{t:l}=tt(),u=l("toolbar.conditionInput.value"),h=a??l("toolbar.conditionInput.choose");switch(e){case"number":return d.jsx(Xt,{type:"number",value:typeof t=="number"?String(t):"",onChange:p=>{const m=p.target.value;n(m.trim()===""?null:Number(m))},className:`${i} ${o}`.trim(),placeholder:u});case"date":return d.jsx(GN,{id:"toolbar-filter-date",value:t,onChange:n,placeholder:h});case"boolean":{let p="";t===!0?p="true":t===!1&&(p="false");const m=b=>n(b==="true"?!0:b==="false"?!1:null);return d.jsxs(Rr,{value:p,onValueChange:m,children:[d.jsx(Or,{size:"sm",className:`${i} ${o}`.trim(),children:d.jsx(Gr,{placeholder:u})}),d.jsxs(Dr,{children:[d.jsx(or,{value:"true",children:l("toolbar.conditionInput.true")}),d.jsx(or,{value:"false",children:l("toolbar.conditionInput.false")})]})]})}case"select":return d.jsxs(Li,{modal:!1,children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:`${i} justify-between ${o}`.trim(),children:[d.jsx("span",{className:"truncate",children:typeof t=="string"&&t?t:h}),d.jsx(of,{className:"size-3.5 opacity-60"})]})}),d.jsx($i,{align:"end",className:"w-48 p-1",children:r.map(p=>d.jsx(Oe,{type:"button",variant:t===p?"secondary":"ghost",size:"sm",className:"h-8 w-full justify-start px-2 text-xs",onClick:()=>n(p),children:p},p))})]});case"tags":return d.jsxs(Li,{modal:!1,children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:`${i} justify-between ${o}`.trim(),children:[d.jsx("span",{className:"truncate",children:typeof t=="string"&&t?t:l("toolbar.conditionInput.tag")}),d.jsx(of,{className:"size-3.5 opacity-60"})]})}),d.jsx($i,{align:"end",className:"max-h-56 w-56 overflow-y-auto p-1",children:s.map(p=>d.jsx(Oe,{type:"button",variant:t===p?"secondary":"ghost",size:"sm",className:"h-8 w-full justify-start px-2 text-xs",onClick:()=>n(p),children:p},p))})]});default:return d.jsx(Xt,{value:typeof t=="string"?t:"",onChange:p=>n(p.target.value||null),className:`${i} ${o}`.trim(),placeholder:u})}}const s$e=["filter","sort","automation","search","settings","create"],i$e=[{value:"success",label:"Successo"},{value:"warning",label:"Attenzione"},{value:"danger",label:"Critico"},{value:"info",label:"Info"},{value:"neutral",label:"Neutro"}];function o$e(e){return e==="cell"?"cell":"row"}function a$e(e){return Array.isArray(e)?e.filter(t=>t==="bold"||t==="italic"||t==="underline"):[]}function l$e(e){switch(e){case"success":return"bg-emerald-500/70";case"warning":return"bg-amber-500/70";case"danger":return"bg-destructive/70";case"info":return"bg-sky-500/70";default:return"bg-muted-foreground/40"}}function Jy(){return`${Date.now()}_${Math.random().toString(36).slice(2,9)}`}function oZ(e){return e!=="is_empty"&&e!=="is_not_empty"}function aZ(e,t){const n=[{value:"eq",label:t("toolbar.operators.eq")},{value:"is_not_empty",label:t("toolbar.operators.is_not_empty")},{value:"is_empty",label:t("toolbar.operators.is_empty")}];return e==="number"||e==="date"?[{value:"gt",label:t("toolbar.operators.gt")},{value:"lt",label:t("toolbar.operators.lt")},{value:"gte",label:t("toolbar.operators.gte")},{value:"lte",label:t("toolbar.operators.lte")},...n]:e==="tags"?[{value:"contains",label:t("toolbar.operators.contains")},{value:"is_not_empty",label:t("toolbar.operators.is_not_empty")},{value:"is_empty",label:t("toolbar.operators.is_empty")}]:e==="select"?[{value:"eq",label:t("toolbar.operators.eq")},{value:"is_not_empty",label:t("toolbar.operators.is_not_empty")},{value:"is_empty",label:t("toolbar.operators.is_empty")}]:e==="text"||e==="system"?[{value:"contains",label:t("toolbar.operators.contains")},...n]:n}function c$e(e,t=[],n="Stato"){const r=[],s=t.length>0&&t.length<=8?"recommended":"other";r.push({columnId:"status",label:n,section:s});for(const i of e.branches)i.type==="boolean"?r.push({columnId:i.alias,label:i.label,section:"recommended",branchType:"boolean"}):i.type==="date"?r.push({columnId:i.alias,label:i.label,section:"recommended",branchType:"date"}):i.type==="text"&&i.options&&i.options.length>0?r.push({columnId:i.alias,label:i.label,section:"recommended"}):i.type==="text"?r.push({columnId:i.alias,label:i.label,section:"other"}):i.type==="number"&&r.push({columnId:i.alias,label:i.label,section:"other"});return r}function u$e({filters:e,openPillId:t,onOpenPillChange:n,groupBy:r,activeGroupLabel:s,onGroupByChange:i,addConditionToColumn:o,removeColumnFilters:a,updateCondition:l,removeCondition:u,availableTagsByColumnId:h}){const{t:p}=tt();return d.jsxs("div",{className:"mb-2 flex min-h-9 flex-wrap items-center gap-2",children:[r&&d.jsxs(Oe,{variant:"outline",size:"sm",className:"h-8 rounded-full px-3 text-xs",onClick:()=>i?.(null),children:[d.jsx(Ete,{className:"size-3.5"}),p("toolbar.filterPills.groupedBy",{label:s}),d.jsx(ro,{className:"size-3.5 opacity-70"})]}),Object.entries(e).map(([m,b])=>d.jsx(d$e,{group:b,isOpen:t===m,onOpenChange:y=>n(y?m:null),addConditionToColumn:o,removeColumnFilters:a,updateCondition:l,removeCondition:u,availableTagsByColumnId:h},m))]})}function d$e({group:e,isOpen:t,onOpenChange:n,addConditionToColumn:r,removeColumnFilters:s,updateCondition:i,removeCondition:o,availableTagsByColumnId:a}){const{t:l}=tt();return d.jsxs(Li,{open:t,onOpenChange:n,children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-xs","aria-label":l("toolbar.filter.ariaLabel",{label:e.label}),children:[d.jsx("span",{className:"truncate",children:e.label}),d.jsx("span",{className:"opacity-70",children:e.conditions.length})]})}),d.jsxs($i,{align:"start",className:"w-[420px] p-2",children:[d.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[d.jsx(Cs,{className:"px-0 py-0 text-xs font-medium text-muted-foreground",children:l("toolbar.filter.filtersOn",{label:e.label})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"h-7 w-7","aria-label":l("toolbar.filter.removeColumn"),onClick:()=>s(e.columnId),children:d.jsx(La,{className:"size-3.5"})})]}),d.jsxs("div",{className:"space-y-2",children:[e.conditions.map(u=>{const h=aZ(e.type,l),p=oZ(u.op);return d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Rr,{value:u.op,onValueChange:m=>i(e.columnId,u.id,{op:m,value:m==="is_empty"||m==="is_not_empty"?null:u.value}),children:[d.jsx(Or,{size:"sm",className:"h-8 w-40 text-xs",children:d.jsx(Gr,{placeholder:l("toolbar.filter.operator")})}),d.jsx(Dr,{children:h.map(m=>d.jsx(or,{value:m.value,children:m.label},m.value))})]}),p?d.jsx(iZ,{type:e.type,value:u.value,onChange:m=>i(e.columnId,u.id,{value:m}),selectOptions:e.selectOptions,availableTags:a[e.columnId]??[],className:"h-8 flex-1",textClassName:"text-sm"}):d.jsx("div",{className:"h-8 flex-1"}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"h-8 w-8","aria-label":l("toolbar.filter.removeCondition"),onClick:()=>o(e.columnId,u.id),children:d.jsx(ro,{className:"size-3.5"})})]},u.id)}),d.jsx(ti,{}),d.jsx("div",{className:"flex justify-center",children:d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:()=>r(e.columnId),children:[d.jsx(Hi,{className:"size-4"}),l("toolbar.filter.addFilter")]})})]})]})]})}const f$e={table:Nz,gallery:rv,grid:rv,kanban:Ste,chart:pz};function h$e({views:e,activeViewId:t,onChangeView:n,onCreateView:r}){const{t:s}=tt();return d.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[d.jsx(Nw,{type:"single",value:t,onValueChange:i=>i&&n(i),variant:"outline",size:"sm",className:"gap-0",children:e.map(i=>{const o=f$e[i.type];return d.jsxs(rf,{value:i.id,"aria-label":i.label,className:"h-8 gap-1.5 px-2.5",children:[o&&d.jsx(o,{className:"size-4 shrink-0"}),d.jsx("span",{className:"truncate max-w-24",children:i.label})]},i.id)})}),d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"icon-sm",className:"h-8 w-8 shrink-0","aria-label":s("toolbar.viewSwitcher.addView"),onClick:()=>r?.(),children:d.jsx(Hi,{className:"size-4"})})}),d.jsx(fa,{side:"top",children:s("toolbar.viewSwitcher.addView")})]})]})}function p$e({isSearchOpen:e,searchValue:t,searchInputRef:n,handleSearchSubmit:r,onSearchChange:s,handleSearchBlur:i,handleSearchClose:o,handleSearchOpen:a}){const{t:l}=tt();return d.jsx("div",{className:"overflow-hidden rounded-md border border-input bg-transparent transition-[width] duration-200 ease-out",style:{width:e?192:32},children:e?d.jsxs("form",{onSubmit:r,className:"relative flex min-w-[192px] items-center",children:[d.jsx(aC,{className:"text-muted-foreground pointer-events-none absolute left-2.5 size-4 shrink-0"}),d.jsx(Xt,{ref:n,type:"search",placeholder:l("toolbar.search.placeholder"),value:t,onChange:u=>s?.(u.target.value),onBlur:i,className:"h-8 w-full border-0 bg-transparent pl-8 pr-8 focus-visible:ring-0 focus-visible:ring-offset-0","aria-label":l("toolbar.search.ariaLabel")}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"absolute right-1 h-6 w-6 shrink-0","aria-label":l("toolbar.search.close"),onClick:o,children:d.jsx(ro,{className:"size-3.5"})})]}):d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"icon-sm",className:"h-8 w-8 shrink-0","aria-label":l("toolbar.search.ariaLabel"),onClick:a,children:d.jsx(aC,{className:"size-4"})})}),d.jsx(fa,{side:"top",children:l("toolbar.search.open")})]})})}function lZ(e=[]){const t=[];return e.includes("bold")&&t.push("font-bold"),e.includes("italic")&&t.push("italic"),e.includes("underline")&&t.push("underline"),t.join(" ")}function cZ(e,t=[]){const n=lZ(t);switch(e){case"success":return`bg-emerald-500/12 hover:bg-emerald-500/16 ${n}`.trim();case"warning":return`bg-amber-500/12 hover:bg-amber-500/16 ${n}`.trim();case"danger":return`bg-destructive/12 hover:bg-destructive/16 ${n}`.trim();case"info":return`bg-sky-500/12 hover:bg-sky-500/16 ${n}`.trim();default:return`bg-muted/35 hover:bg-muted/45 ${n}`.trim()}}function uZ(e,t=[]){const n=lZ(t),r="[&_[data-slot=badge]]:!text-inherit [&_[data-slot=badge]]:!bg-transparent [&_[data-slot=badge]]:!border-current";switch(e){case"success":return`font-medium text-emerald-700 dark:text-emerald-300 ${n} ${r}`.trim();case"warning":return`font-medium text-amber-800 dark:text-amber-200 ${n} ${r}`.trim();case"danger":return`font-medium text-destructive ${n} ${r}`.trim();case"info":return`font-medium text-sky-800 dark:text-sky-200 ${n} ${r}`.trim();default:return`font-medium ${n} ${r}`.trim()}}function m$e({formattableColumns:e,addConditionalFormatRule:t}){const{t:n}=tt();return d.jsxs("div",{className:"flex min-h-52 flex-col items-center justify-center gap-3 rounded-md border border-dashed",children:[d.jsx("div",{className:"text-sm text-muted-foreground",children:n("toolbar.conditionalFormats.noRules")}),d.jsx(dZ,{columns:e,onSelect:t,compact:!0})]})}function g$e({conditionalFormats:e,setActiveConditionalRuleId:t,setIsConditionalEditorOpen:n}){return d.jsx("div",{className:"space-y-2",children:e.map((r,s)=>d.jsxs("button",{type:"button",className:"flex h-14 w-full overflow-hidden rounded-md border text-left transition-colors hover:bg-muted/40",onClick:()=>{t(r.id),n(!0)},children:[d.jsx("div",{className:`w-1/3 ${l$e(r.tone)}`}),d.jsxs("div",{className:"flex flex-1 items-center justify-between px-3",children:[d.jsx("span",{className:"truncate text-sm",children:r.label||r.group.label}),d.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["#",s+1]})]})]},r.id))})}function b$e({activeConditionalRule:e,conditionalFormats:t,updateConditionalRule:n,moveConditionalRule:r,removeConditionalRule:s,updateConditionalCondition:i,addConditionalCondition:o,removeConditionalCondition:a,updateConditionalTextStyles:l,setIsConditionalEditorOpen:u,availableTagsByColumnId:h}){const{t:p}=tt();return d.jsxs("div",{className:"space-y-2 max-h-[460px] overflow-y-auto pr-1",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>u(!1),children:p("toolbar.conditionalFormats.rulesList")}),d.jsx("span",{className:"text-[11px] text-muted-foreground",children:p("toolbar.conditionalFormats.editRule")})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ZW,{pressed:e.enabled,onPressedChange:m=>n(e.id,{enabled:m}),variant:"outline",size:"sm","aria-label":p("toolbar.conditionalFormats.toggleRule"),className:"h-7 w-7 px-0",children:e.enabled?d.jsx(hp,{className:"size-3.5"}):d.jsx(fp,{className:"size-3.5"})}),d.jsx(Xt,{value:e.label??"",onChange:m=>n(e.id,{label:m.target.value}),className:"h-7 text-xs",placeholder:p("toolbar.conditionalFormats.ruleName")}),d.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"h-7 w-7",onClick:()=>r(e.id,-1),disabled:t.findIndex(m=>m.id===e.id)===0,"aria-label":p("toolbar.conditionalFormats.moveUp"),children:d.jsx(T6,{className:"size-3.5"})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"h-7 w-7",onClick:()=>r(e.id,1),disabled:t.findIndex(m=>m.id===e.id)===t.length-1,"aria-label":p("toolbar.conditionalFormats.moveDown"),children:d.jsx(Nc,{className:"size-3.5"})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"h-7 w-7 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>s(e.id),"aria-label":p("toolbar.conditionalFormats.deleteRule"),children:d.jsx(La,{className:"size-3.5"})})]})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-xs font-medium",children:p("toolbar.conditionalFormats.applyTo")}),d.jsxs("div",{className:"inline-flex rounded-md border p-0.5",children:[d.jsx(Oe,{type:"button",size:"sm",variant:"ghost",className:e.target==="cell"?"h-7 px-3 text-xs bg-black text-white hover:bg-black/90 hover:text-white":"h-7 px-3 text-xs text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>n(e.id,{target:"cell"}),children:p("toolbar.conditionalFormats.cell")}),d.jsx(Oe,{type:"button",size:"sm",variant:"ghost",className:e.target==="row"?"h-7 px-3 text-xs bg-black text-white hover:bg-black/90 hover:text-white":"h-7 px-3 text-xs text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>n(e.id,{target:"row"}),children:p("toolbar.conditionalFormats.row")})]})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-xs font-medium",children:p("toolbar.conditionalFormats.useColorIf")}),d.jsx("div",{className:"h-8 rounded-md border bg-muted/20 px-2 text-xs flex items-center",children:d.jsx("span",{className:"truncate",children:e.group.label})})]}),d.jsx("div",{className:"flex flex-col gap-2",children:e.group.conditions.map(m=>{const b=aZ(e.group.type,p),y=oZ(m.op);return d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Rr,{value:m.op,onValueChange:x=>i(e.id,m.id,{op:x,value:x==="is_empty"||x==="is_not_empty"?null:m.value}),children:[d.jsx(Or,{size:"sm",className:"h-8 w-36 text-xs",children:d.jsx(Gr,{placeholder:p("toolbar.conditionalFormats.operator")})}),d.jsx(Dr,{children:b.map(x=>d.jsx(or,{value:x.value,children:x.label},x.value))})]}),y?d.jsx(iZ,{type:e.group.type,value:m.value,onChange:x=>i(e.id,m.id,{value:x}),selectOptions:e.group.selectOptions??[],availableTags:h[e.columnId]??[],className:"h-8 flex-1",textClassName:"text-xs"}):d.jsx("div",{className:"h-8 flex-1"}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"h-8 w-8","aria-label":p("toolbar.conditionalFormats.removeCondition"),onClick:()=>a(e.id,m.id),children:d.jsx(ro,{className:"size-3.5"})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"h-8 w-8","aria-label":p("toolbar.conditionalFormats.addCondition"),onClick:()=>o(e.id),children:d.jsx(Hi,{className:"size-3.5"})})]},m.id)})}),d.jsxs("div",{className:"space-y-1 pt-1",children:[d.jsx("div",{className:"text-xs font-medium",children:p("toolbar.conditionalFormats.formatStyle")}),d.jsxs("div",{className:"rounded-md border border-dashed p-2",children:[d.jsx("div",{className:`flex min-h-12 items-center rounded-md border px-3 ${e.target==="row"?cZ(e.tone,e.textStyles??[]):""}`,children:d.jsx("span",{className:e.target==="cell"?uZ(e.tone,e.textStyles??[]):"font-medium",children:p("toolbar.conditionalFormats.default")})}),d.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[d.jsxs(Rr,{value:e.tone,onValueChange:m=>n(e.id,{tone:m}),children:[d.jsx(Or,{size:"sm",className:"h-8 w-40 text-xs",children:d.jsx(Gr,{placeholder:p("toolbar.conditionalFormats.colorPreset")})}),d.jsx(Dr,{children:i$e.map(m=>d.jsx(or,{value:m.value,children:m.label},m.value))})]}),d.jsxs(Nw,{variant:"outline",type:"multiple",value:e.textStyles??[],onValueChange:m=>l(e.id,m),children:[d.jsx(rf,{value:"bold","aria-label":p("toolbar.conditionalFormats.bold"),children:d.jsx($J,{className:"size-4"})}),d.jsx(rf,{value:"italic","aria-label":p("toolbar.conditionalFormats.italic"),children:d.jsx(mte,{className:"size-4"})}),d.jsx(rf,{value:"underline","aria-label":p("toolbar.conditionalFormats.underline"),children:d.jsx(tre,{className:"size-4"})})]})]})]})]})]})}function y$e({enabled:e,formattableColumns:t,conditionalFormats:n,activeConditionalRule:r,isConditionalEditorOpen:s,setIsConditionalEditorOpen:i,setActiveConditionalRuleId:o,addConditionalFormatRule:a,updateConditionalRule:l,updateConditionalTextStyles:u,removeConditionalRule:h,moveConditionalRule:p,updateConditionalCondition:m,addConditionalCondition:b,removeConditionalCondition:y,availableTagsByColumnId:x}){const{t:S}=tt();if(!e)return d.jsx("div",{className:"text-sm text-muted-foreground",children:S("toolbar.conditionalFormats.notAvailable")});let C;return s?r?C=d.jsx(b$e,{activeConditionalRule:r,conditionalFormats:n,updateConditionalRule:l,moveConditionalRule:p,removeConditionalRule:h,updateConditionalCondition:m,addConditionalCondition:b,removeConditionalCondition:y,updateConditionalTextStyles:u,setIsConditionalEditorOpen:i,availableTagsByColumnId:x}):C=d.jsx("div",{className:"px-0 py-6 text-center text-sm text-muted-foreground",children:S("toolbar.conditionalFormats.selectRule")}):n.length===0?C=d.jsx(m$e,{formattableColumns:t,addConditionalFormatRule:a}):C=d.jsx(g$e,{conditionalFormats:n,setActiveConditionalRuleId:o,setIsConditionalEditorOpen:i}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx(Cs,{className:"px-0 py-0 text-sm font-semibold text-foreground",children:"Regole dei colori condizionali"}),d.jsx(dZ,{columns:t,onSelect:a})]}),d.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Le regole si applicano dall’alto verso il basso."}),d.jsx(ti,{}),C]})}function dZ({columns:e,onSelect:t,compact:n=!1}){const{t:r}=tt();return d.jsxs(Li,{modal:!1,children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:n?"h-8":"h-8 w-8 px-0","aria-label":r("toolbar.conditionalFormats.addRule"),children:[d.jsx(Hi,{className:"size-4"}),n?r("toolbar.conditionalFormats.add"):null]})}),d.jsxs($i,{align:"end",className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:r("toolbar.conditionalFormats.chooseColumn")}),d.jsx("div",{className:"max-h-56 overflow-y-auto",children:e.length===0?d.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:r("toolbar.conditionalFormats.noColumns")}):d.jsx("div",{className:"flex flex-col gap-1 py-1",children:e.map(s=>d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-8 justify-between px-2 text-xs",onClick:()=>t(s.columnId),children:[d.jsx("span",{className:"truncate",children:s.label}),d.jsx("span",{className:"text-[10px] text-muted-foreground uppercase",children:s.type})]},s.columnId))})})]})]})}function v$e({isSettingsMenuOpenEffective:e,setIsSettingsMenuOpenState:t,onOpenSettings:n,isSettingsOpen:r,commitViewName:s,setColumnSearchTerm:i,viewNameDraft:o,setViewNameDraft:a,setIsConditionalEditorOpen:l,filterColumnSearchTerm:u,setFilterColumnSearchTerm:h,visibleFilterColumns:p,addConditionToColumn:m,setOpenPillId:b,closeSettingsMenu:y,filters:x,sortColumnSearchTerm:S,setSortColumnSearchTerm:C,handleToggleSortDirection:N,sortState:M,filteredSortableColumns:_,handleSortColumnSelect:T,groupBy:R,onGroupByChange:D,recommendedGroupColumns:j,datePrecisionMode:L,applyDatePrecisionMode:V,otherGroupColumns:q,onConditionalFormatsChange:X,formattableColumns:ee,conditionalFormats:re,activeConditionalRule:oe,isConditionalEditorOpen:F,setActiveConditionalRuleId:se,addConditionalFormatRule:le,updateConditionalRule:W,updateConditionalTextStyles:Q,removeConditionalRule:H,moveConditionalRule:U,updateConditionalCondition:Z,addConditionalCondition:he,removeConditionalCondition:fe,availableTagsByColumnId:ye,columnVisibility:ge,onColumnVisibilityChange:Ee,columnSearchTerm:Ae,filteredTableColumns:Qe,pageSize:rt,onPageSizeChange:ct}){const{t:He}=tt();return d.jsxs(Li,{open:e,onOpenChange:_e=>{_e||(s(),i("")),_e&&n?.(),r===void 0&&t(_e)},children:[d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Pi,{asChild:!0,children:d.jsx(Oe,{variant:e?"secondary":"ghost",size:"icon-sm","aria-label":He("toolbar.settings.tooltip"),children:d.jsx(Ag,{className:"size-4"})})})}),d.jsx(fa,{side:"top",children:He("toolbar.settings.tooltip")})]}),d.jsxs($i,{align:"end",className:"w-64",children:[d.jsxs(Em,{children:[d.jsx(Cs,{children:He("toolbar.settings.title")}),d.jsx("div",{className:"px-2 pb-1.5",children:d.jsx(Xt,{value:o,onChange:_e=>a(_e.target.value),onBlur:()=>s(),onKeyDown:_e=>{if(_e.key==="Enter"){_e.preventDefault(),s();return}_e.key.length===1&&!_e.metaKey&&!_e.ctrlKey&&!_e.altKey&&_e.stopPropagation()},className:"h-8 text-sm",placeholder:He("toolbar.settings.viewName")})})]}),d.jsx(ti,{}),d.jsxs(Em,{children:[d.jsx(Cs,{children:He("toolbar.settings.quickActions")}),d.jsxs(Mh,{onOpenChange:_e=>{_e&&l(!1)},children:[d.jsxs(_h,{children:[d.jsx(vz,{className:"size-4"}),He("toolbar.settings.filter")]}),d.jsx(Nh,{children:d.jsxs(Th,{className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:He("toolbar.filter.label")}),d.jsx(Xt,{placeholder:He("toolbar.filter.searchPlaceholder"),value:u,onChange:_e=>h(_e.target.value),className:"h-8 text-sm"}),d.jsx(ti,{className:"my-2"}),d.jsx("div",{className:"max-h-56 overflow-y-auto",children:p.length===0?d.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:He("toolbar.filter.noColumns")}):d.jsx("div",{className:"flex flex-col gap-1 py-1",children:p.map(_e=>d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-8 justify-between px-2 text-xs",onClick:()=>{m(_e.columnId),h(""),b(_e.columnId),y()},children:[d.jsx("span",{className:"truncate",children:_e.label}),x[_e.columnId]?.conditions?.length?d.jsx("span",{className:"text-muted-foreground text-[10px] uppercase",children:x[_e.columnId].conditions.length}):null]},_e.columnId))})})]})})]}),d.jsxs(Mh,{children:[d.jsxs(_h,{children:[d.jsx(of,{className:"size-4"}),He("toolbar.settings.sort")]}),d.jsx(Nh,{children:d.jsxs(Th,{className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:He("toolbar.sort.label")}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Xt,{placeholder:He("toolbar.sort.searchPlaceholder"),value:S,onChange:_e=>C(_e.target.value),className:"h-8 flex-1 text-sm"}),d.jsx(Oe,{type:"button",variant:"outline",size:"icon-sm",className:"h-8 w-8 shrink-0","aria-label":He("toolbar.sort.invertOrder"),onClick:N,disabled:!M?.columnId,children:d.jsx(of,{className:"size-3.5"})})]}),d.jsx(ti,{className:"my-2"}),d.jsx("div",{className:"max-h-56 overflow-y-auto",children:_.length===0?d.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:He("toolbar.sort.noColumns")}):d.jsx("div",{className:"flex flex-col gap-1 py-1",children:_.map(_e=>{const nn=M?.columnId===_e.alias;return d.jsxs(Oe,{type:"button",variant:nn?"secondary":"ghost",size:"sm",className:"h-8 justify-between px-2 text-xs",onClick:()=>T(_e.alias),children:[d.jsx("span",{className:"truncate",children:_e.label}),nn&&d.jsx("span",{className:"text-muted-foreground text-[10px] uppercase",children:M?.desc?"DESC":"ASC"})]},_e.alias)})})})]})})]})]}),d.jsx(ti,{}),d.jsxs(Em,{children:[d.jsx(Cs,{children:He("toolbar.settings.layoutStyle")}),d.jsxs(Mh,{children:[d.jsxs(_h,{children:[d.jsx(wne,{className:"size-4"}),He("toolbar.settings.group"),R?"...":"",R&&d.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground uppercase",children:He("toolbar.settings.active")})]}),d.jsx(Nh,{children:d.jsxs(Th,{className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:He("toolbar.settings.groupBy")}),d.jsxs(Oe,{type:"button",variant:R?"ghost":"secondary",size:"sm",className:"h-8 w-full justify-between px-2 text-xs",onClick:()=>{D?.(null),y()},children:[d.jsx("span",{children:He("toolbar.settings.noGrouping")}),!R&&d.jsx(Pd,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),j.length>0&&d.jsxs(d.Fragment,{children:[d.jsx(ti,{className:"my-2"}),d.jsx(Cs,{className:"px-0 pb-1 pt-0 text-[10px] font-medium text-muted-foreground uppercase tracking-wide",children:He("toolbar.settings.recommended")}),d.jsx("div",{className:"flex flex-col gap-1",children:j.map(_e=>_e.branchType==="date"?d.jsxs(Mh,{children:[d.jsxs(_h,{className:"h-8 w-full rounded-sm px-2 text-xs data-[state=open]:bg-accent",children:[d.jsx("span",{className:"flex-1 truncate text-left",children:_e.label}),R===_e.columnId&&d.jsx(Pd,{className:"mr-2 size-3.5 shrink-0 text-muted-foreground"})]}),d.jsx(Nh,{children:d.jsxs(Th,{className:"w-48 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:He("toolbar.settings.group")}),d.jsxs(abe,{value:L,onValueChange:nn=>{const xt=nn||"monthYear";D?.(_e.columnId),V(xt),y()},children:[d.jsx(CS,{value:"day",children:He("toolbar.settings.day")}),d.jsx(CS,{value:"year",children:He("toolbar.settings.year")}),d.jsx(CS,{value:"monthYear",children:He("toolbar.settings.month")})]})]})})]},_e.columnId):d.jsxs(Oe,{type:"button",variant:R===_e.columnId?"secondary":"ghost",size:"sm",className:"h-8 w-full justify-between px-2 text-xs",onClick:()=>{D?.(R===_e.columnId?null:_e.columnId),y()},children:[d.jsx("span",{className:"truncate",children:_e.label}),R===_e.columnId&&d.jsx(Pd,{className:"size-3.5 shrink-0 text-muted-foreground"})]},_e.columnId))})]}),q.length>0&&d.jsxs(d.Fragment,{children:[d.jsx(ti,{className:"my-2"}),d.jsx(Cs,{className:"px-0 pb-1 pt-0 text-[10px] font-medium text-muted-foreground uppercase tracking-wide",children:He("toolbar.settings.otherFields")}),d.jsx("div",{className:"px-0 pb-1 text-[10px] text-muted-foreground/70",children:He("toolbar.settings.manyGroups")}),d.jsx("div",{className:"flex flex-col gap-1",children:q.map(_e=>d.jsx(Oe,{type:"button",variant:R===_e.columnId?"secondary":"ghost",size:"sm",className:"h-auto min-h-8 w-full flex-col items-start gap-0 px-2 py-1.5 text-xs",onClick:()=>{D?.(R===_e.columnId?null:_e.columnId),y()},children:d.jsxs("div",{className:"flex w-full items-center justify-between",children:[d.jsx("span",{className:"truncate",children:_e.label}),R===_e.columnId&&d.jsx(Pd,{className:"size-3.5 shrink-0 text-muted-foreground"})]})},_e.columnId))})]})]})})]}),d.jsxs(Mh,{children:[d.jsxs(_h,{children:[d.jsx(kz,{className:"size-4"}),He("toolbar.settings.conditionalColors")]}),d.jsx(Nh,{children:d.jsx(Th,{className:"w-[620px] p-3",children:d.jsx(y$e,{enabled:!!X,formattableColumns:ee,conditionalFormats:re,activeConditionalRule:oe,isConditionalEditorOpen:F,setIsConditionalEditorOpen:l,setActiveConditionalRuleId:se,addConditionalFormatRule:le,updateConditionalRule:W,updateConditionalTextStyles:Q,removeConditionalRule:H,moveConditionalRule:U,updateConditionalCondition:Z,addConditionalCondition:he,removeConditionalCondition:fe,availableTagsByColumnId:ye})})})]})]}),d.jsx(ti,{}),d.jsxs(Em,{children:[d.jsx(Cs,{children:He("toolbar.settings.table")}),ge&&Ee&&d.jsxs(Mh,{children:[d.jsxs(_h,{children:[d.jsx(hp,{className:"size-4"}),He("toolbar.settings.visibleColumns")]}),d.jsx(Nh,{children:d.jsxs(Th,{className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:He("toolbar.settings.columnVisibility")}),d.jsx(Xt,{placeholder:He("toolbar.settings.columnSearch"),value:Ae,onChange:_e=>i(_e.target.value),className:"h-8 text-sm"}),d.jsx(ti,{className:"my-2"}),d.jsx("div",{className:"max-h-56 overflow-y-auto",children:Qe.length===0?d.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:He("toolbar.settings.noColumns")}):d.jsx("div",{className:"flex flex-col gap-1 py-1",children:Qe.map(_e=>{const nn=ge[_e.id]??!0;return d.jsxs(Oe,{type:"button",variant:nn?"secondary":"ghost",size:"sm",className:"h-8 justify-between px-2 text-xs",onClick:()=>{const xt={...ge,[_e.id]:!nn};Ee(xt)},children:[d.jsx("span",{className:"truncate",children:_e.label}),nn?d.jsx(hp,{className:"size-3.5 shrink-0 text-muted-foreground"}):d.jsx(fp,{className:"size-3.5 shrink-0 text-muted-foreground/50"})]},_e.id)})})})]})})]}),rt!=null&&ct&&d.jsxs(cl,{onSelect:_e=>_e.preventDefault(),className:"justify-between gap-4 focus:bg-transparent focus:text-inherit data-[highlighted]:bg-transparent data-[highlighted]:text-inherit cursor-default",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(vne,{className:"size-4"}),He("toolbar.settings.rows")]}),d.jsxs("div",{className:"flex h-7 items-stretch",children:[d.jsx(Oe,{type:"button",variant:"outline",size:"icon-xs",className:"h-7 w-7 rounded-r-none border-r-0","aria-label":He("toolbar.settings.decreaseRows"),disabled:rt<=1,onClick:_e=>{_e.stopPropagation(),ct(Math.max(1,rt-1))},children:d.jsx(Vte,{className:"size-3"})}),d.jsx("div",{className:"flex w-9 items-center justify-center border border-input bg-background text-xs tabular-nums",children:rt}),d.jsx(Oe,{type:"button",variant:"outline",size:"icon-xs",className:"h-7 w-7 rounded-l-none border-l-0","aria-label":He("toolbar.settings.increaseRows"),disabled:rt>=100,onClick:_e=>{_e.stopPropagation(),ct(Math.min(100,rt+1))},children:d.jsx(Hi,{className:"size-3"})})]})]})]})]})]})}function x$e({searchValue:e,onSearchChange:t,onSubmitSearch:n}){const[r,s]=w.useState(!1),i=w.useRef(null);w.useEffect(()=>{r&&i.current?.focus()},[r]);const o=()=>s(!0),a=()=>{s(!1),t?.("")};return{isSearchOpen:r,searchInputRef:i,handleSearchOpen:o,handleSearchClose:a,handleSearchSubmit:h=>{h.preventDefault();const p=i.current?.value??e;n?.(p)},handleSearchBlur:()=>{!e&&!i.current?.value&&a()}}}function w$e(){const[e,t]=w.useState(""),[n,r]=w.useState(""),[s,i]=w.useState(""),[o,a]=w.useState(!1),[l,u]=w.useState(null),[h,p]=w.useState(!1);return{sortColumnSearchTerm:e,setSortColumnSearchTerm:t,filterColumnSearchTerm:n,setFilterColumnSearchTerm:r,columnSearchTerm:s,setColumnSearchTerm:i,filterMenuOpen:o,setFilterMenuOpen:a,openPillId:l,setOpenPillId:u,isSettingsMenuOpenState:h,setIsSettingsMenuOpenState:p}}function S$e({activeView:e,onRenameView:t}){const[n,r]=w.useState(e?.label??"");w.useEffect(()=>{r(e?.label??"")},[e?.id,e?.label]);const s=w.useCallback(()=>{if(!e||!t)return;const i=n.trim();!i||i===e.label||t(e.id,i)},[e,t,n]);return{viewNameDraft:n,setViewNameDraft:r,commitViewName:s}}function C$e({seed:e,sortColumnSearchTerm:t,sortState:n,onSortChange:r}){const s=w.useMemo(()=>e.branches.filter(l=>["text","number","date"].includes(l.type)&&Ew(l).sort),[e.branches]),i=w.useMemo(()=>{const l=t.trim().toLowerCase();return l?s.filter(u=>u.label.toLowerCase().includes(l)):s},[t,s]);return{sortableBranches:s,filteredSortableColumns:i,handleToggleSortDirection:()=>{!r||!n?.columnId||r({columnId:n.columnId,desc:!n.desc})},handleSortColumnSelect:l=>{if(!r)return;if(n?.columnId===l){r({columnId:null,desc:!0});return}const h=n?.columnId==null?!0:n.desc;r({columnId:l,desc:h})}}}function k$e({seed:e,availableStatusOptions:t,groupBy:n,dateGroupPrecision:r,onDateGroupPrecisionChange:s}){const{t:i}=tt(),o=w.useMemo(()=>c$e(e,t,i("content.table.status")),[t,e,i]),a=w.useMemo(()=>o.filter(m=>m.section==="recommended"),[o]),l=w.useMemo(()=>o.filter(m=>m.section==="other"),[o]),u=w.useMemo(()=>n?o.find(m=>m.columnId===n)?.label??n:null,[n,o]),h=w.useMemo(()=>r.day?"day":r.year&&r.month?"monthYear":r.year&&!r.month?"year":"monthYear",[r.day,r.month,r.year]),p=w.useCallback(m=>{if(s){if(m==="day"){s({year:!1,month:!1,day:!0});return}if(m==="year"){s({year:!0,month:!1,day:!1});return}s({year:!0,month:!0,day:!1})}},[s]);return{groupableColumns:o,recommendedGroupColumns:a,otherGroupColumns:l,activeGroupLabel:u,datePrecisionMode:h,applyDatePrecisionMode:p}}function E$e({seed:e,filters:t,onFiltersChange:n,availableStatusOptions:r=[]}){const s=w.useMemo(()=>{const h=[{columnId:"slug",label:"Slug",type:"system"},{columnId:"status",label:"Stato",type:"select",selectOptions:r}];for(const p of e.branches){if(!Ew(p).filter)continue;const m=p.alias;p.type==="number"?h.push({columnId:m,label:p.label,type:"number"}):p.type==="date"?h.push({columnId:m,label:p.label,type:"date"}):p.type==="boolean"?h.push({columnId:m,label:p.label,type:"boolean"}):p.type==="json"&&m.toLowerCase().includes("tag")?h.push({columnId:m,label:p.label,type:"tags"}):h.push({columnId:m,label:p.label,type:"text"})}return h},[r,e.branches]),i=w.useMemo(()=>{const h=new Set(["select","number","date","boolean","tags"]);return s.filter(p=>h.has(p.type))},[s]),o=w.useCallback(h=>{const p=s.find(S=>S.columnId===h);if(!p||!n)return;const m=t[h],b=p.type==="tags"?"contains":"eq",y={id:Jy(),op:b,value:null},x={...t,[h]:m?{...m,conditions:[...m.conditions,y]}:{columnId:h,label:p.label,type:p.type,selectOptions:p.selectOptions,conditions:[y]}};n(x)},[s,t,n]),a=w.useCallback(h=>{if(!n||!t[h])return;const p={...t};delete p[h],n(p)},[t,n]),l=w.useCallback((h,p,m)=>{if(!n)return;const b=t[h];if(!b)return;const y=b.conditions.map(x=>x.id===p?{...x,...m}:x);n({...t,[h]:{...b,conditions:y}})},[t,n]),u=w.useCallback((h,p)=>{if(!n)return;const m=t[h];if(!m)return;const b=m.conditions.filter(y=>y.id!==p);if(b.length===0){const y={...t};delete y[h],n(y);return}n({...t,[h]:{...m,conditions:b}})},[t,n]);return{filterableColumns:s,formattableColumns:i,addConditionToColumn:o,removeColumnFilters:a,updateCondition:l,removeCondition:u}}function N$e({viewId:e,conditionalFormatsInput:t,formattableColumns:n,onConditionalFormatsChange:r}){const[s,i]=w.useState(null),[o,a]=w.useState(!1),l=w.useCallback(_=>_.map(T=>({...T,target:o$e(T.target),textStyles:a$e(T.textStyles)})).slice().sort((T,R)=>(T.priority??0)-(R.priority??0)),[]),u=w.useMemo(()=>l(t??[]),[t,l]);w.useEffect(()=>{if(u.length===0){i(null),a(!1);return}(!s||!u.some(_=>_.id===s))&&i(u[0].id)},[s,u]);const h=w.useMemo(()=>s?u.find(_=>_.id===s)??u[0]??null:u[0]??null,[s,u]),p=w.useCallback(_=>{!e||!r||r(e,_)},[r,e]),m=w.useCallback(_=>{const T=n.find(L=>L.columnId===_);if(!T)return;const R=Jy(),D=T.type==="tags"?"contains":"eq",j={id:R,enabled:!0,priority:u.length,label:T.label,columnId:_,group:{columnId:_,label:T.label,type:T.type,selectOptions:T.selectOptions,conditions:[{id:Jy(),op:D,value:null}]},tone:"warning",target:"row",textStyles:[]};p([...u,j]),i(R),a(!0)},[p,u,n]),b=w.useCallback((_,T)=>{const R=u.map(D=>D.id===_?{...D,...T}:D);p(R)},[p,u]),y=w.useCallback((_,T)=>{b(_,{textStyles:T.filter(R=>R==="bold"||R==="italic"||R==="underline")})},[b]),x=w.useCallback(_=>{const T=u.filter(R=>R.id!==_).map((R,D)=>({...R,priority:D}));p(T)},[p,u]),S=w.useCallback((_,T)=>{const R=u.findIndex(V=>V.id===_);if(R<0)return;const D=R+T;if(D<0||D>=u.length)return;const j=u.slice(),[L]=j.splice(R,1);j.splice(D,0,L),p(j.map((V,q)=>({...V,priority:q})))},[p,u]),C=w.useCallback((_,T,R)=>{const D=u.map(j=>{if(j.id!==_)return j;const L=j.group.conditions.map(V=>V.id===T?{...V,...R}:V);return{...j,group:{...j.group,conditions:L}}});p(D)},[p,u]),N=w.useCallback(_=>{const T=u.find(j=>j.id===_);if(!T)return;const R=T.group.type==="tags"?"contains":"eq",D=u.map(j=>j.id===_?{...j,group:{...j.group,conditions:[...j.group.conditions,{id:Jy(),op:R,value:null}]}}:j);p(D)},[p,u]),M=w.useCallback((_,T)=>{const R=u.map(D=>{if(D.id!==_)return D;const j=D.group.conditions.filter(L=>L.id!==T);return{...D,group:{...D.group,conditions:j}}}).filter(D=>D.group.conditions.length>0).map((D,j)=>({...D,priority:j}));p(R)},[p,u]);return{conditionalFormats:u,activeConditionalRule:h,activeConditionalRuleId:s,isConditionalEditorOpen:o,setActiveConditionalRuleId:i,setIsConditionalEditorOpen:a,addConditionalFormatRule:m,updateConditionalRule:b,updateConditionalTextStyles:y,removeConditionalRule:x,moveConditionalRule:S,updateConditionalCondition:C,addConditionalCondition:N,removeConditionalCondition:M}}function M$e({seed:e,views:t,activeViewId:n,onRenameView:r,isFilterActive:s,isSortActive:i,isAutomationActive:o,isSettingsOpen:a,searchValue:l="",onSearchChange:u,onSubmitSearch:h,sortState:p,onSortChange:m,filters:b={},onFiltersChange:y,availableStatusOptions:x=[],groupBy:S=null,dateGroupPrecision:C={year:!0,month:!0,day:!1},onDateGroupPrecisionChange:N,onConditionalFormatsChange:M}){const _=t.find(ue=>ue.id===n),{isSearchOpen:T,searchInputRef:R,handleSearchOpen:D,handleSearchClose:j,handleSearchSubmit:L,handleSearchBlur:V}=x$e({searchValue:l,onSearchChange:u,onSubmitSearch:h}),{sortColumnSearchTerm:q,setSortColumnSearchTerm:X,filterColumnSearchTerm:ee,setFilterColumnSearchTerm:re,columnSearchTerm:oe,setColumnSearchTerm:F,filterMenuOpen:se,setFilterMenuOpen:le,openPillId:W,setOpenPillId:Q,isSettingsMenuOpenState:H,setIsSettingsMenuOpenState:U}=w$e(),{viewNameDraft:Z,setViewNameDraft:he,commitViewName:fe}=S$e({activeView:_,onRenameView:r}),ye=w.useMemo(()=>_?.enabledTools??s$e,[_]),ge=s??Object.values(b).some(ue=>ue.conditions.length>0),Ee=i??!!p?.columnId,Ae=o??!1,Qe=a??H,rt=()=>{a===void 0&&U(!1)},ct=ue=>ye.includes(ue),He=C$e({seed:e,sortColumnSearchTerm:q,sortState:p,onSortChange:m}),{filterableColumns:_e,formattableColumns:nn,addConditionToColumn:xt,removeColumnFilters:Jt,updateCondition:fn,removeCondition:hn}=E$e({seed:e,filters:b,onFiltersChange:y,availableStatusOptions:x}),zn=N$e({viewId:_?.id,conditionalFormatsInput:_?.conditionalFormats,formattableColumns:nn,onConditionalFormatsChange:M}),lr=w.useMemo(()=>[{id:"slug",label:"Slug"},{id:"status",label:"Stato"},...e.branches.map(ue=>({id:ue.alias,label:ue.label}))],[e.branches]),In=w.useMemo(()=>{const ue=ee.trim().toLowerCase();return ue?_e.filter(Fe=>Fe.label.toLowerCase().includes(ue)):_e},[ee,_e]),Fn=w.useMemo(()=>Object.fromEntries(Object.entries(b).map(([ue,Fe])=>[ue,Fe.conditions.length])),[b]),G=w.useMemo(()=>{const ue=oe.trim().toLowerCase();return ue?lr.filter(Fe=>Fe.label.toLowerCase().includes(ue)):lr},[oe,lr]),pe=k$e({seed:e,availableStatusOptions:x,groupBy:S,dateGroupPrecision:C,onDateGroupPrecisionChange:N});return{activeView:_,enabledTools:ye,isFilterActiveEffective:ge,isSortActiveEffective:Ee,isAutomationActiveEffective:Ae,isSettingsMenuOpenEffective:Qe,closeSettingsMenu:rt,isToolEnabled:ct,isSearchOpen:T,searchInputRef:R,handleSearchOpen:D,handleSearchClose:j,handleSearchSubmit:L,handleSearchBlur:V,sortColumnSearchTerm:q,setSortColumnSearchTerm:X,filterColumnSearchTerm:ee,setFilterColumnSearchTerm:re,columnSearchTerm:oe,setColumnSearchTerm:F,filterMenuOpen:se,setFilterMenuOpen:le,openPillId:W,setOpenPillId:Q,isSettingsMenuOpenState:H,setIsSettingsMenuOpenState:U,viewNameDraft:Z,setViewNameDraft:he,commitViewName:fe,...He,filterableColumns:_e,formattableColumns:nn,addConditionToColumn:xt,removeColumnFilters:Jt,updateCondition:fn,removeCondition:hn,visibleFilterColumns:In,activeFiltersCountByColumn:Fn,...zn,tableColumns:lr,filteredTableColumns:G,...pe}}function _$e(e){const{seed:t,views:n,children:r,filters:s={},availableTagsByColumnId:i={}}=e,{t:o}=tt(),a=M$e(e),{activeViewId:l,onChangeView:u,onCreateView:h,onRenameView:p,onCreate:m,onOpenAutomation:b,onOpenFilters:y,onOpenSort:x,onOpenSettings:S,sortState:C,onSortChange:N,onConditionalFormatsChange:M,columnVisibility:_,onColumnVisibilityChange:T,pageSize:R,onPageSizeChange:D,groupBy:j,onGroupByChange:L}=e,{activeView:V,isFilterActiveEffective:q,isSortActiveEffective:X,isAutomationActiveEffective:ee,isSettingsMenuOpenEffective:re,closeSettingsMenu:oe,isToolEnabled:F,isSearchOpen:se,searchInputRef:le,handleSearchOpen:W,handleSearchClose:Q,handleSearchSubmit:H,handleSearchBlur:U,sortColumnSearchTerm:Z,setSortColumnSearchTerm:he,filterColumnSearchTerm:fe,setFilterColumnSearchTerm:ye,columnSearchTerm:ge,setColumnSearchTerm:Ee,filterMenuOpen:Ae,setFilterMenuOpen:Qe,openPillId:rt,setOpenPillId:ct,setIsSettingsMenuOpenState:He,viewNameDraft:_e,setViewNameDraft:nn,commitViewName:xt,filteredSortableColumns:Jt,handleToggleSortDirection:fn,handleSortColumnSelect:hn,addConditionToColumn:zn,removeColumnFilters:lr,updateCondition:In,removeCondition:Fn,visibleFilterColumns:G,activeFiltersCountByColumn:pe,conditionalFormats:ue,activeConditionalRule:Fe,isConditionalEditorOpen:$e,setActiveConditionalRuleId:ze,setIsConditionalEditorOpen:qe,addConditionalFormatRule:Rt,updateConditionalRule:Ot,updateConditionalTextStyles:xn,removeConditionalRule:gn,moveConditionalRule:en,updateConditionalCondition:Lt,addConditionalCondition:ls,removeConditionalCondition:Sr,filteredTableColumns:yt,formattableColumns:Bt,recommendedGroupColumns:gt,otherGroupColumns:Pt,activeGroupLabel:Re,datePrecisionMode:P,applyDatePrecisionMode:K}=a;if(!V)return null;const be=Object.keys(s).length>0||!!Re;return d.jsxs("div",{"data-seed-slug":t.slug,children:[d.jsx("div",{className:"sticky top-(--header-height) z-10 bg-background/95 backdrop-blur-sm border-b",children:d.jsx(Zn,{className:"py-3 border-0 bg-transparent shadow-none rounded-none",children:d.jsxs(Xn,{className:"px-4 py-0",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[d.jsx(h$e,{views:n,activeViewId:l,onChangeView:u,onCreateView:h}),d.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[F("filter")&&d.jsx(n$e,{open:Ae,onOpenChange:Qe,isActive:q,onOpen:y,searchTerm:fe,onSearchTermChange:ye,visibleFilterColumns:G,activeFiltersCountByColumn:pe,onSelectColumn:Pe=>{zn(Pe),Qe(!1),ye(""),ct(Pe)}}),F("sort")&&d.jsx(r$e,{searchTerm:Z,onSearchTermChange:he,filteredSortableColumns:Jt,sortState:C,onToggleDirection:fn,onSelectColumn:hn,isActive:X,onOpen:x}),F("automation")&&d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Oe,{variant:ee?"secondary":"ghost",size:"icon-sm","aria-label":o("toolbar.automation"),onClick:()=>b?.(),children:d.jsx(Rg,{className:"size-4"})})}),d.jsx(fa,{side:"top",children:o("toolbar.automation")})]}),F("search")&&d.jsx(p$e,{isSearchOpen:se,searchValue:e.searchValue??"",searchInputRef:le,handleSearchSubmit:H,onSearchChange:e.onSearchChange,handleSearchBlur:U,handleSearchClose:Q,handleSearchOpen:W}),F("settings")&&d.jsx(v$e,{isSettingsMenuOpenEffective:re,setIsSettingsMenuOpenState:He,onOpenSettings:S,isSettingsOpen:e.isSettingsOpen,commitViewName:xt,setColumnSearchTerm:Ee,viewNameDraft:_e,setViewNameDraft:nn,setIsConditionalEditorOpen:qe,filterColumnSearchTerm:fe,setFilterColumnSearchTerm:ye,visibleFilterColumns:G,addConditionToColumn:zn,setOpenPillId:ct,closeSettingsMenu:oe,filters:s,sortColumnSearchTerm:Z,setSortColumnSearchTerm:he,handleToggleSortDirection:fn,sortState:C,filteredSortableColumns:Jt,handleSortColumnSelect:hn,groupBy:j??null,onGroupByChange:L,recommendedGroupColumns:gt,datePrecisionMode:P,applyDatePrecisionMode:K,otherGroupColumns:Pt,onConditionalFormatsChange:M,formattableColumns:Bt,conditionalFormats:ue,activeConditionalRule:Fe,isConditionalEditorOpen:$e,setActiveConditionalRuleId:ze,addConditionalFormatRule:Rt,updateConditionalRule:Ot,updateConditionalTextStyles:xn,removeConditionalRule:gn,moveConditionalRule:en,updateConditionalCondition:Lt,addConditionalCondition:ls,removeConditionalCondition:Sr,availableTagsByColumnId:i,columnVisibility:_,onColumnVisibilityChange:T,columnSearchTerm:ge,filteredTableColumns:yt,pageSize:R,onPageSizeChange:D}),F("create")&&d.jsxs(Oe,{variant:"default",size:"sm",onClick:m,className:"gap-1.5",children:[d.jsx(Hi,{className:"size-4"}),o("siteHeader.new")]})]})]}),be&&d.jsx("div",{className:"mt-3 pt-3 border-t",children:d.jsx(u$e,{filters:s,openPillId:rt,onOpenPillChange:ct,groupBy:j??null,activeGroupLabel:Re??"",onGroupByChange:L,addConditionToColumn:zn,removeColumnFilters:lr,updateCondition:In,removeCondition:Fn,availableTagsByColumnId:i})})]})})}),r!=null&&d.jsx("div",{className:"mt-4",children:r})]})}const Pp={fetchList:async(e,t)=>(await Gt.get(`/content/${e}`,{params:{...t,filters:t.filters!=null?JSON.stringify(t.filters):void 0}})).data,fetchFacets:async e=>(await Gt.get(`/content/${e}/facets`)).data,fetchById:async(e,t)=>(await Gt.get(`/content/${e}/${t}`)).data,create:async(e,t)=>(await Gt.post(`/content/${e}`,t)).data,update:async(e,t,n)=>(await Gt.put(`/content/${e}/${t}`,n)).data,delete:async(e,t)=>(await Gt.delete(`/content/${e}/${t}`)).data},hc={all:["content"],lists:()=>[...hc.all,"list"],list:(e,t)=>[...hc.lists(),e,t],details:()=>[...hc.all,"detail"],detail:(e,t)=>[...hc.details(),e,t]},f8={all:["facets"],bySlug:e=>[...f8.all,e]};function T$e(e,t){return Ir({queryKey:hc.list(e||"",t),queryFn:()=>{if(!e)throw new Error("Slug is required");return Pp.fetchList(e,t)},enabled:!!e,placeholderData:n=>n,staleTime:10*1e3})}const si={all:["dashboard"],stats:()=>[...si.all,"stats"],cloudflare:()=>[...si.all,"cloudflare"],activity:()=>[...si.all,"activity"],health:()=>[...si.all,"health"],breakdown:()=>[...si.all,"breakdown"],setupChecklist:()=>[...si.all,"setup-checklist"]};function A$e(e){return Ir({queryKey:f8.bySlug(e||""),queryFn:()=>{if(!e)throw new Error("Slug is required");return Pp.fetchFacets(e)},enabled:!!e,staleTime:300*1e3,gcTime:1800*1e3})}function R$e(){const e=wi();return Fs({mutationFn:({slug:t,id:n})=>Pp.delete(t,n),onSuccess:()=>{e.invalidateQueries({queryKey:hc.all}),e.invalidateQueries({queryKey:si.activity()})}})}function O$e(e,t){return Ir({queryKey:hc.detail(e||"",t||""),queryFn:()=>{if(!e||!t)throw new Error("Slug and ID are required");return Pp.fetchById(e,t)},enabled:!!(e&&t),staleTime:10*1e3})}function D$e(){const e=wi();return Fs({mutationFn:async({slug:t,id:n,data:r})=>n?Pp.update(t,n,r):Pp.create(t,r),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:hc.all}),e.invalidateQueries({queryKey:f8.all}),n.id&&e.invalidateQueries({queryKey:hc.detail(n.slug,n.id)}),e.invalidateQueries({queryKey:si.activity()}),e.invalidateQueries({queryKey:si.stats()})}})}const zh="/automations",h1={list:e=>Gt.get(zh,{params:{seed:e}}).then(t=>t.data),get:e=>Gt.get(`${zh}/${e}`).then(t=>t.data),create:e=>Gt.post(zh,e).then(t=>t.data),update:(e,t)=>Gt.put(`${zh}/${e}`,t),toggle:(e,t)=>Gt.patch(`${zh}/${e}/toggle`,{enabled:t}),remove:e=>Gt.delete(`${zh}/${e}`)},fl={all:["automations"],lists:()=>[...fl.all,"list"],list:e=>[...fl.lists(),e],items:()=>[...fl.all,"item"],item:e=>[...fl.items(),e]};function fZ(e){return Ir({queryKey:fl.list(e??""),queryFn:()=>h1.list(e),enabled:!!e,staleTime:1e4})}function j$e(e){const t=wi(),{t:n}=tt();return Fs({mutationFn:({id:r,enabled:s})=>h1.toggle(r,s),onSuccess:()=>{t.invalidateQueries({queryKey:fl.list(e)}),_n.success(n("automations.toast.toggled"))},onError:()=>{_n.error(n("automations.toast.error"))}})}function I$e(e){const t=wi(),{t:n}=tt();return Fs({mutationFn:r=>h1.remove(r),onSuccess:()=>{t.invalidateQueries({queryKey:fl.list(e)}),_n.success(n("automations.toast.deleted"))},onError:()=>{_n.error(n("automations.toast.error"))}})}function z$e({automation:e,onEdit:t,onDelete:n,onToggle:r,isToggling:s}){const{t:i}=tt();return d.jsxs("div",{className:"flex items-center gap-3 py-3 px-1 border-b last:border-0",children:[d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("p",{className:"text-sm font-medium truncate",children:e.name}),d.jsx("p",{className:"text-xs text-muted-foreground",children:e.triggers.map(o=>i(`automations.triggers.${o.event}`)).join(" / ")})]}),d.jsx(f7,{checked:e.enabled,onCheckedChange:r,disabled:s,"aria-label":i("automations.panel.toggleAriaLabel")}),d.jsx(Oe,{variant:"ghost",size:"icon",className:"size-7",onClick:t,"aria-label":i("common.edit"),children:d.jsx(I6,{className:"size-3.5"})}),d.jsx(Oe,{variant:"ghost",size:"icon",className:"size-7 text-destructive hover:text-destructive",onClick:n,"aria-label":i("common.delete"),children:d.jsx(La,{className:"size-3.5"})})]})}function L$e({onNew:e}){const{t}=tt();return d.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[d.jsx("div",{className:"flex size-12 items-center justify-center rounded-full bg-muted mb-4",children:d.jsx(Rg,{className:"size-6 text-muted-foreground"})}),d.jsx("h3",{className:"text-sm font-medium mb-1",children:t("automations.panel.emptyTitle")}),d.jsx("p",{className:"text-xs text-muted-foreground mb-4 max-w-48",children:t("automations.panel.emptyDescription")}),d.jsx(Oe,{size:"sm",onClick:e,children:t("automations.panel.emptyAction")})]})}function P$e(){const[e,t]=w.useState(!1),[n,r]=w.useState(void 0);function s(){r(void 0),t(!0)}function i(a){r(a),t(!0)}function o(){t(!1),r(void 0)}return{editorOpen:e,editingAutomation:n,openNew:s,openEdit:i,closeEditor:o}}var p1=e=>e.type==="checkbox",Kd=e=>e instanceof Date,Ti=e=>e==null;const hZ=e=>typeof e=="object";var rs=e=>!Ti(e)&&!Array.isArray(e)&&hZ(e)&&!Kd(e),$$e=e=>rs(e)&&e.target?p1(e.target)?e.target.checked:e.target.value:e,F$e=(e,t)=>t.split(".").some((n,r,s)=>!isNaN(Number(n))&&e.has(s.slice(0,r).join("."))),B$e=e=>{const t=e.constructor&&e.constructor.prototype;return rs(t)&&t.hasOwnProperty("isPrototypeOf")},h8=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function br(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(h8&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(rs(e)&&B$e(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=br(e[s]));return r}var Pw=e=>/^\w*$/.test(e),pr=e=>e===void 0,$w=e=>Array.isArray(e)?e.filter(Boolean):[],p8=e=>$w(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ut=(e,t,n)=>{if(!t||!rs(e))return n;const s=(Pw(t)?[t]:p8(t)).reduce((i,o)=>Ti(i)?void 0:i[o],e);return pr(s)||s===e?pr(e[t])?n:e[t]:s},el=e=>typeof e=="boolean",Qo=e=>typeof e=="function",rr=(e,t,n)=>{let r=-1;const s=Pw(t)?[t]:p8(t),i=s.length,o=i-1;for(;++r<i;){const a=s[r];let l=n;if(r!==o){const u=e[a];l=rs(u)||Array.isArray(u)?u:isNaN(+s[r+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;e[a]=l,e=e[a]}};const Lh={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},ea={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Sa={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},V3="form",pZ="root",m8=te.createContext(null);m8.displayName="HookFormControlContext";const H$e=()=>te.useContext(m8);var U$e=(e,t,n,r=!0)=>{const s={};for(const i in e)Object.defineProperty(s,i,{get:()=>{const o=i;return t._proxyFormState[o]!==ea.all&&(t._proxyFormState[o]=!r||ea.all),e[o]}});return s};const mZ=typeof window<"u"?te.useLayoutEffect:te.useEffect;var mi=e=>typeof e=="string",V$e=(e,t,n,r,s)=>mi(e)?(r&&t.watch.add(e),ut(n,e,s)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),ut(n,i))):(r&&(t.watchAll=!0),n),u6=e=>Ti(e)||!hZ(e);function tl(e,t,n=new WeakSet){if(e===t)return!0;if(u6(e)||u6(t))return Object.is(e,t);if(Kd(e)&&Kd(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const i of r){const o=e[i];if(!(i in t))return!1;if(i!=="ref"){const a=t[i];if(Kd(o)&&Kd(a)||(rs(o)||Array.isArray(o))&&(rs(a)||Array.isArray(a))?!tl(o,a,n):!Object.is(o,a))return!1}}return!0}const g8=te.createContext(null);g8.displayName="HookFormContext";const Ml=()=>te.useContext(g8),q$e=e=>{const{children:t,watch:n,getValues:r,getFieldState:s,setError:i,clearErrors:o,setValue:a,setValues:l,trigger:u,formState:h,resetField:p,reset:m,handleSubmit:b,unregister:y,control:x,register:S,setFocus:C,subscribe:N}=e,M=te.useMemo(()=>({watch:n,getValues:r,getFieldState:s,setError:i,clearErrors:o,setValue:a,setValues:l,trigger:u,formState:h,resetField:p,reset:m,handleSubmit:b,unregister:y,control:x,register:S,setFocus:C,subscribe:N}),[o,x,h,s,r,b,S,m,p,i,C,a,l,N,u,y,n]);return te.createElement(g8.Provider,{value:M},te.createElement(m8.Provider,{value:M.control},t))};var b8=(e,t,n,r,s)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:s||!0}}:{},no=e=>Array.isArray(e)?e:[e],RI=()=>{let e=[];return{get observers(){return e},next:s=>{for(const i of e)i.next&&i.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(i=>i!==s)}}),unsubscribe:()=>{e=[]}}};function gZ(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const s=e[r],i=t[r];if(s&&rs(s)&&i){const o=gZ(s,i);rs(o)&&(n[r]=o)}else e[r]&&(n[r]=i)}return n}var ei=e=>rs(e)&&!Object.keys(e).length,y8=e=>e.type==="file",Bx=e=>{if(!h8)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},bZ=e=>e.type==="select-multiple",v8=e=>e.type==="radio",G$e=e=>v8(e)||p1(e),q3=e=>Bx(e)&&e.isConnected;function W$e(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;){if(Ti(e)){e=void 0;break}e=e[t[r]],r++}return e}function K$e(e){for(const t in e)if(e.hasOwnProperty(t)&&!pr(e[t]))return!1;return!0}function fs(e,t){if(mi(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const n=Array.isArray(t)?t:Pw(t)?[t]:p8(t),r=n.length===1?e:W$e(e,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(rs(r)&&ei(r)||Array.isArray(r)&&K$e(r))&&fs(e,n.slice(0,-1)),e}var Y$e=e=>{for(const t in e)if(Qo(e[t]))return!0;return!1};function yZ(e){return Array.isArray(e)||rs(e)&&!Y$e(e)}function d6(e,t={}){for(const n in e){const r=e[n];yZ(r)?(t[n]=Array.isArray(r)?[]:{},d6(r,t[n])):pr(r)||(t[n]=!0)}return t}function f6(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(n=>f6(n));return t.some(n=>n!==void 0)?t:void 0}if(rs(e)){const t={};for(const n in e){const r=f6(e[n]);pr(r)||(t[n]=r)}return Object.keys(t).length?t:void 0}}}function zm(e,t,n){n||(n=d6(t));for(const r in e){const s=e[r];if(yZ(s))pr(t)||u6(n[r])?n[r]=d6(s,Array.isArray(s)?[]:{}):zm(s,Ti(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!tl(s,i)}}return f6(n)||{}}const OI={value:!1,isValid:!1},DI={value:!0,isValid:!0};var vZ=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!pr(e[0].attributes.value)?pr(e[0].value)||e[0].value===""?DI:{value:e[0].value,isValid:!0}:DI:OI}return OI},xZ=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>pr(e)?e:t?e===""?NaN:e&&+e:n&&mi(e)?new Date(e):r?r(e):e;const jI={isValid:!1,value:null};var wZ=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,jI):jI;function II(e){const t=e.ref;return y8(t)?t.files:v8(t)?wZ(e.refs).value:bZ(t)?[...t.selectedOptions].map(({value:n})=>n):p1(t)?vZ(e.refs).value:xZ(pr(t.value)?e.ref.value:t.value,e)}var Z$e=(e,t,n,r)=>{const s={};for(const i of e){const o=ut(t,i);o&&rr(s,i,o._f)}return{criteriaMode:n,names:[...e],fields:s,shouldUseNativeValidation:r}},Hx=e=>e instanceof RegExp,ym=e=>pr(e)?e:Hx(e)?e.source:rs(e)?Hx(e.value)?e.value.source:e.value:e,Jh=e=>({isOnSubmit:!e||e===ea.onSubmit,isOnBlur:e===ea.onBlur,isOnChange:e===ea.onChange,isOnAll:e===ea.all,isOnTouch:e===ea.onTouched});const zI="AsyncFunction";var X$e=e=>!!e&&!!e.validate&&!!(Qo(e.validate)&&e.validate.constructor.name===zI||rs(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===zI)),Q$e=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),h6=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const dp=(e,t,n,r)=>{for(const s of n||Object.keys(e)){const i=ut(e,s);if(i){const{_f:o,...a}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],s)&&!r)return!0;if(o.ref&&t(o.ref,o.name)&&!r)return!0;if(dp(a,t))break}else if(rs(a)&&dp(a,t))break}}};function LI(e,t,n){const r=ut(e,n);if(r||Pw(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),o=ut(t,i),a=ut(e,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(a&&a.type)return{name:i,error:a};if(a&&a.root&&a.root.type)return{name:`${i}.root`,error:a.root};s.pop()}return{name:n}}var J$e=(e,t,n,r)=>{n(e);const{name:s,...i}=e;return ei(i)||r&&Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(o=>t[o]===(!r||ea.all))},eFe=(e,t,n)=>!e||!t||e===t||no(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),tFe=(e,t,n,r,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(t||e):(n?r.isOnBlur:s.isOnBlur)?!e:(n?r.isOnChange:s.isOnChange)?e:!0,nFe=(e,t)=>!$w(ut(e,t)).length&&fs(e,t),SZ=(e,t,n)=>{const r=no(ut(e,n));return rr(r,pZ,t[n]),rr(e,n,r),e};function PI(e,t,n="validate"){if(mi(e)||Array.isArray(e)&&e.every(mi)||el(e)&&!e)return{type:n,message:mi(e)?e:"",ref:t}}var Ph=e=>rs(e)&&!Hx(e)?e:{value:e,message:""},p6=async(e,t,n,r,s,i)=>{const{ref:o,refs:a,required:l,maxLength:u,minLength:h,min:p,max:m,pattern:b,validate:y,name:x,valueAsNumber:S,mount:C}=e._f,N=ut(n,x);if(!C||t.has(x))return{};const M=a?a[0]:o,_=X=>{s&&M.reportValidity&&(M.setCustomValidity(el(X)?"":X||""),M.reportValidity())},T={},R=v8(o),D=p1(o),j=R||D,L=(S||y8(o))&&pr(o.value)&&pr(N)||Bx(o)&&o.value===""||N===""||Array.isArray(N)&&!N.length||S&&typeof N=="number"&&isNaN(N),V=b8.bind(null,x,r,T),q=(X,ee,re,oe=Sa.maxLength,F=Sa.minLength)=>{const se=X?ee:re;T[x]={type:X?oe:F,message:se,ref:o,...V(X?oe:F,se)}};if(i?!Array.isArray(N)||!N.length:l&&(!j&&(L||Ti(N))||el(N)&&!N||D&&!vZ(a).isValid||R&&!wZ(a).isValid)){const{value:X,message:ee}=mi(l)?{value:!!l,message:l}:Ph(l);if(X&&(T[x]={type:Sa.required,message:ee,ref:M,...V(Sa.required,ee)},!r))return _(ee),T}if(!L&&(!Ti(p)||!Ti(m))){let X,ee;const re=Ph(m),oe=Ph(p);if(!Ti(N)&&!isNaN(N)){const F=o.valueAsNumber||N&&+N;Ti(re.value)||(X=F>re.value),Ti(oe.value)||(ee=F<oe.value)}else{const F=o.valueAsDate||new Date(N),se=Q=>new Date(new Date().toDateString()+" "+Q),le=o.type=="time",W=o.type=="week";mi(re.value)&&N&&(X=le?se(N)>se(re.value):W?N>re.value:F>new Date(re.value)),mi(oe.value)&&N&&(ee=le?se(N)<se(oe.value):W?N<oe.value:F<new Date(oe.value))}if((X||ee)&&(q(!!X,re.message,oe.message,Sa.max,Sa.min),!r))return _(T[x].message),T}if((u||h)&&!L&&(mi(N)||i&&Array.isArray(N))){const X=Ph(u),ee=Ph(h),re=!Ti(X.value)&&N.length>+X.value,oe=!Ti(ee.value)&&N.length<+ee.value;if((re||oe)&&(q(re,X.message,ee.message),!r))return _(T[x].message),T}if(b&&!L&&mi(N)){const{value:X,message:ee}=Ph(b);if(Hx(X)&&!N.match(X)&&(T[x]={type:Sa.pattern,message:ee,ref:o,...V(Sa.pattern,ee)},!r))return _(ee),T}if(y){if(Qo(y)){const X=await y(N,n),ee=PI(X,M);if(ee&&(T[x]={...ee,...V(Sa.validate,ee.message)},!r))return _(ee.message),T}else if(rs(y)){let X={};for(const ee in y){if(!ei(X)&&!r)break;const re=PI(await y[ee](N,n),M,ee);re&&(X={...re,...V(ee,re.message)},_(re.message),r&&(T[x]=X))}if(!ei(X)&&(T[x]={ref:M,...X},!r))return T}}return _(!0),T};const rFe={mode:ea.onSubmit,reValidateMode:ea.onChange,shouldFocusError:!0},CZ={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function sFe(e={}){let t={...rFe,...e},n={...br(CZ),isLoading:Qo(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},r={},s=rs(t.defaultValues)||rs(t.values)?br(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:br(s),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},l,u=0;const h={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},p={...h};let m={...p};const b={array:RI(),state:RI()},y=t.criteriaMode===ea.all,x=G=>pe=>{clearTimeout(u),u=setTimeout(G,pe)},S=async G=>{if(!o.keepIsValid&&!t.disabled&&(p.isValid||m.isValid||G)){let pe;t.resolver?(pe=ei((await L()).errors),C()):pe=await X({fields:r,onlyCheckValid:!0,eventType:Lh.VALID}),pe!==n.isValid&&b.state.next({isValid:pe})}},C=(G,pe)=>{!t.disabled&&(p.isValidating||p.validatingFields||m.isValidating||m.validatingFields)&&((G||Array.from(a.mount)).forEach(ue=>{ue&&(pe?rr(n.validatingFields,ue,pe):fs(n.validatingFields,ue))}),b.state.next({validatingFields:n.validatingFields,isValidating:!ei(n.validatingFields)}))},N=()=>{n.dirtyFields=zm(s,i)},M=(G,pe=[],ue,Fe,$e=!0,ze=!0)=>{if(Fe&&ue&&!t.disabled){if(o.action=!0,ze&&Array.isArray(ut(r,G))){const qe=ue(ut(r,G),Fe.argA,Fe.argB);$e&&rr(r,G,qe)}if(ze&&Array.isArray(ut(n.errors,G))){const qe=ue(ut(n.errors,G),Fe.argA,Fe.argB);$e&&rr(n.errors,G,qe),nFe(n.errors,G)}if((p.touchedFields||m.touchedFields)&&ze&&Array.isArray(ut(n.touchedFields,G))){const qe=ue(ut(n.touchedFields,G),Fe.argA,Fe.argB);$e&&rr(n.touchedFields,G,qe)}(p.dirtyFields||m.dirtyFields)&&N(),b.state.next({name:G,isDirty:re(G,pe),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else rr(i,G,pe)},_=(G,pe)=>{rr(n.errors,G,pe),b.state.next({errors:n.errors})},T=G=>{n.errors=G,b.state.next({errors:n.errors,isValid:!1})},R=(G,pe,ue,Fe)=>{const $e=ut(r,G);if($e){const ze=pr(ut(i,G)),qe=ut(i,G,pr(ue)?ut(s,G):ue);pr(qe)||Fe&&Fe.defaultChecked||pe?rr(i,G,pe?qe:II($e._f)):se(G,qe),o.mount&&!o.action&&(S(),ze&&n.isDirty&&(p.isDirty||m.isDirty)&&(re()||(n.isDirty=!1,b.state.next({...n}))))}},D=(G,pe,ue,Fe,$e)=>{let ze=!1,qe=!1;const Rt={name:G};if(!t.disabled){if(!ue||Fe){(p.isDirty||m.isDirty)&&(qe=n.isDirty,n.isDirty=Rt.isDirty=re(),ze=qe!==Rt.isDirty);const Ot=tl(ut(s,G),pe);qe=!!ut(n.dirtyFields,G),Ot?fs(n.dirtyFields,G):rr(n.dirtyFields,G,!0),Rt.dirtyFields=n.dirtyFields,ze=ze||(p.dirtyFields||m.dirtyFields)&&qe!==!Ot}if(ue){const Ot=ut(n.touchedFields,G);Ot||(rr(n.touchedFields,G,ue),Rt.touchedFields=n.touchedFields,ze=ze||(p.touchedFields||m.touchedFields)&&Ot!==ue)}ze&&$e&&b.state.next(Rt)}return ze?Rt:{}},j=(G,pe,ue,Fe)=>{const $e=ut(n.errors,G),ze=(p.isValid||m.isValid)&&el(pe)&&n.isValid!==pe;if(t.delayError&&ue?(l=x(()=>_(G,ue)),l(t.delayError)):(clearTimeout(u),l=null,ue?rr(n.errors,G,ue):fs(n.errors,G)),(ue?!tl($e,ue):$e)||!ei(Fe)||ze){const qe={...Fe,...ze&&el(pe)?{isValid:pe}:{},errors:n.errors,name:G};n={...n,...qe},b.state.next(qe)}},L=async G=>(C(G,!0),await t.resolver(i,t.context,Z$e(G||a.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),V=async G=>{const{errors:pe}=await L(G);if(C(G),G)for(const ue of G){const Fe=ut(pe,ue);Fe?rr(n.errors,ue,Fe):fs(n.errors,ue)}else n.errors=pe;return pe},q=async({name:G,eventType:pe})=>{if(e.validate){const ue=await e.validate({formValues:i,formState:n,name:G,eventType:pe});if(rs(ue))for(const Fe in ue)ue[Fe]&&ge(`${V3}.${Fe}`,{message:mi(ue.message)?ue.message:"",type:Sa.validate});else mi(ue)||!ue?ge(V3,{message:ue||"",type:Sa.validate}):ye(V3);return ue}return!0},X=async({fields:G,onlyCheckValid:pe,name:ue,eventType:Fe,context:$e={valid:!0,runRootValidation:!1}})=>{if(e.validate&&($e.runRootValidation=!0,!await q({name:ue,eventType:Fe})&&($e.valid=!1,pe)))return $e.valid;for(const ze in G){const qe=G[ze];if(qe){const{_f:Rt,...Ot}=qe;if(Rt){const xn=a.array.has(Rt.name),gn=qe._f&&X$e(qe._f);gn&&p.validatingFields&&C([Rt.name],!0);const en=await p6(qe,a.disabled,i,y,t.shouldUseNativeValidation&&!pe,xn);if(gn&&p.validatingFields&&C([Rt.name]),en[Rt.name]&&($e.valid=!1,pe)||(!pe&&(ut(en,Rt.name)?xn?SZ(n.errors,en,Rt.name):rr(n.errors,Rt.name,en[Rt.name]):fs(n.errors,Rt.name)),e.shouldUseNativeValidation&&en[Rt.name]))break}!ei(Ot)&&await X({context:$e,onlyCheckValid:pe,fields:Ot,name:ze,eventType:Fe})}}return $e.valid},ee=()=>{for(const G of a.unMount){const pe=ut(r,G);pe&&(pe._f.refs?pe._f.refs.every(ue=>!q3(ue)):!q3(pe._f.ref))&&rt(G)}a.unMount=new Set},re=(G,pe)=>!t.disabled&&(G&&pe&&rr(i,G,pe),!tl(he(),s)),oe=(G,pe,ue)=>V$e(G,a,{...o.mount?i:pr(pe)?s:mi(G)?{[G]:pe}:pe},ue,pe),F=G=>$w(ut(o.mount?i:s,G,t.shouldUnregister?ut(s,G,[]):[])),se=(G,pe,ue={})=>{const Fe=ut(r,G);let $e=pe;if(Fe){const ze=Fe._f;ze&&(!ze.disabled&&rr(i,G,xZ(pe,ze)),$e=Bx(ze.ref)&&Ti(pe)?"":pe,bZ(ze.ref)?[...ze.ref.options].forEach(qe=>qe.selected=$e.includes(qe.value)):ze.refs?p1(ze.ref)?ze.refs.forEach(qe=>{(!qe.defaultChecked||!qe.disabled)&&(Array.isArray($e)?qe.checked=!!$e.find(Rt=>Rt===qe.value):qe.checked=$e===qe.value||!!$e)}):ze.refs.forEach(qe=>qe.checked=qe.value===$e):y8(ze.ref)?ze.ref.value="":(ze.ref.value=$e,ze.ref.type||b.state.next({name:G,values:br(i)})))}(ue.shouldDirty||ue.shouldTouch)&&D(G,$e,ue.shouldTouch,ue.shouldDirty,!0),ue.shouldValidate&&Z(G)},le=(G,pe,ue)=>{for(const Fe in pe){if(!pe.hasOwnProperty(Fe))return;const $e=pe[Fe],ze=G+"."+Fe,qe=ut(r,ze);(a.array.has(G)||rs($e)||qe&&!qe._f)&&!Kd($e)?le(ze,$e,ue):se(ze,$e,ue)}},W=(G,pe,ue={})=>{const Fe=ut(r,G),$e=a.array.has(G),ze=br(pe),qe=ut(i,G),Rt=tl(qe,ze);if(rr(i,G,ze),$e)b.array.next({name:G,values:br(i)}),(p.isDirty||p.dirtyFields||m.isDirty||m.dirtyFields)&&ue.shouldDirty&&(N(),b.state.next({name:G,dirtyFields:n.dirtyFields,isDirty:re(G,ze)}));else{const Ot=Array.isArray(ze)&&!ze.length||ei(ze);!Fe||Fe._f||Ti(ze)||Ot?se(G,ze,ue):le(G,ze,ue)}if(!Rt){const Ot=h6(G,a);b.state.next({...Ot&&n,name:o.mount||Ot?G:void 0,values:br(i)})}},Q=G=>{const pe=Qo(G)?G(i):G;tl(i,pe)||(i={...i,...pe},b.state.next({...n,values:i}))},H=async G=>{o.mount=!0;const pe=G.target;let ue=pe.name,Fe=!0;const $e=ut(r,ue),ze=Ot=>{Fe=Number.isNaN(Ot)||Kd(Ot)&&isNaN(Ot.getTime())||tl(Ot,ut(i,ue,Ot))},qe=Jh(t.mode),Rt=Jh(t.reValidateMode);if($e){let Ot,xn;const gn=pe.type?II($e._f):$$e(G),en=G.type===Lh.BLUR||G.type===Lh.FOCUS_OUT,Lt=!Q$e($e._f)&&!e.validate&&!t.resolver&&!ut(n.errors,ue)&&!$e._f.deps||tFe(en,ut(n.touchedFields,ue),n.isSubmitted,Rt,qe),ls=h6(ue,a,en);rr(i,ue,gn),en?(!pe||!pe.readOnly)&&($e._f.onBlur&&$e._f.onBlur(G),l&&l(0)):$e._f.onChange&&$e._f.onChange(G);const Sr=D(ue,gn,en),yt=!ei(Sr)||ls;if(!en&&b.state.next({name:ue,type:G.type,values:br(i)}),Lt)return(p.isValid||m.isValid)&&(t.mode==="onBlur"?en&&S():en||S()),yt&&b.state.next({name:ue,...ls?{}:Sr});if(!t.resolver&&e.validate&&await q({name:ue,eventType:G.type}),!en&&ls&&b.state.next({...n}),t.resolver){const{errors:Bt}=await L([ue]);if(C([ue]),ze(gn),Fe){const gt=LI(n.errors,r,ue),Pt=LI(Bt,r,gt.name||ue);Ot=Pt.error,ue=Pt.name,xn=ei(Bt)}}else C([ue],!0),Ot=(await p6($e,a.disabled,i,y,t.shouldUseNativeValidation))[ue],C([ue]),ze(gn),Fe&&(Ot?xn=!1:(p.isValid||m.isValid)&&(xn=await X({fields:r,onlyCheckValid:!0,name:ue,eventType:G.type})));Fe&&($e._f.deps&&(!Array.isArray($e._f.deps)||$e._f.deps.length>0)&&Z($e._f.deps),j(ue,xn,Ot,Sr))}},U=(G,pe)=>{if(ut(n.errors,pe)&&G.focus)return G.focus(),1},Z=async(G,pe={})=>{let ue,Fe;const $e=no(G);if(t.resolver){const ze=await V(pr(G)?G:$e);ue=ei(ze),Fe=G?!$e.some(qe=>ut(ze,qe)):ue}else G?(Fe=(await Promise.all($e.map(async ze=>{const qe=ut(r,ze);return await X({fields:qe&&qe._f?{[ze]:qe}:qe,eventType:Lh.TRIGGER})}))).every(Boolean),!(!Fe&&!n.isValid)&&S()):Fe=ue=await X({fields:r,name:G,eventType:Lh.TRIGGER});return b.state.next({...!mi(G)||(p.isValid||m.isValid)&&ue!==n.isValid?{}:{name:G},...t.resolver||!G?{isValid:ue}:{},errors:n.errors}),pe.shouldFocus&&!Fe&&dp(r,U,G?$e:a.mount),Fe},he=(G,pe)=>{let ue={...o.mount?i:s};return pe&&(ue=gZ(pe.dirtyFields?n.dirtyFields:n.touchedFields,ue)),pr(G)?ue:mi(G)?ut(ue,G):G.map(Fe=>ut(ue,Fe))},fe=(G,pe)=>({invalid:!!ut((pe||n).errors,G),isDirty:!!ut((pe||n).dirtyFields,G),error:ut((pe||n).errors,G),isValidating:!!ut(n.validatingFields,G),isTouched:!!ut((pe||n).touchedFields,G)}),ye=G=>{const pe=G?no(G):void 0;pe?.forEach(ue=>fs(n.errors,ue)),pe?pe.forEach(ue=>{b.state.next({name:ue,errors:n.errors})}):b.state.next({errors:{}})},ge=(G,pe,ue)=>{const Fe=(ut(r,G,{_f:{}})._f||{}).ref,$e=ut(n.errors,G)||{},{ref:ze,message:qe,type:Rt,...Ot}=$e;rr(n.errors,G,{...Ot,...pe,ref:Fe}),b.state.next({name:G,errors:n.errors,isValid:!1}),ue&&ue.shouldFocus&&Fe&&Fe.focus&&Fe.focus()},Ee=(G,pe)=>Qo(G)?b.state.subscribe({next:ue=>"values"in ue&&G(ue.values||oe(void 0,pe),ue)}):oe(G,pe,!0),Ae=G=>b.state.subscribe({next:pe=>{if(eFe(G.name,pe.name,G.exact)&&J$e(pe,G.formState||p,lr,G.reRenderRoot)){const ue={...i};G.callback({values:ue,...n,...pe,defaultValues:s})}}}).unsubscribe,Qe=G=>(o.mount=!0,m={...m,...G.formState},Ae({...G,formState:{...h,...G.formState}})),rt=(G,pe={})=>{for(const ue of G?no(G):a.mount)a.mount.delete(ue),a.array.delete(ue),pe.keepValue||(fs(r,ue),fs(i,ue)),!pe.keepError&&fs(n.errors,ue),!pe.keepDirty&&fs(n.dirtyFields,ue),!pe.keepTouched&&fs(n.touchedFields,ue),!pe.keepIsValidating&&fs(n.validatingFields,ue),!t.shouldUnregister&&!pe.keepDefaultValue&&fs(s,ue);b.state.next({values:br(i)}),b.state.next({...n,...pe.keepDirty?{isDirty:re()}:{}}),!pe.keepIsValid&&S()},ct=({disabled:G,name:pe})=>{if(el(G)&&o.mount||G||a.disabled.has(pe)){const $e=a.disabled.has(pe)!==!!G;G?a.disabled.add(pe):a.disabled.delete(pe),$e&&o.mount&&!o.action&&S()}},He=(G,pe={})=>{let ue=ut(r,G);const Fe=el(pe.disabled)||el(t.disabled),$e=!a.registerName.has(G)&&ue&&ue._f&&!ue._f.mount;return rr(r,G,{...ue||{},_f:{...ue&&ue._f?ue._f:{ref:{name:G}},name:G,mount:!0,...pe}}),a.mount.add(G),ue&&!$e?ct({disabled:el(pe.disabled)?pe.disabled:t.disabled,name:G}):R(G,!0,pe.value),{...Fe?{disabled:pe.disabled||t.disabled}:{},...t.progressive?{required:!!pe.required,min:ym(pe.min),max:ym(pe.max),minLength:ym(pe.minLength),maxLength:ym(pe.maxLength),pattern:ym(pe.pattern)}:{},name:G,onChange:H,onBlur:H,ref:ze=>{if(ze){a.registerName.add(G),He(G,pe),a.registerName.delete(G),ue=ut(r,G);const qe=pr(ze.value)&&ze.querySelectorAll&&ze.querySelectorAll("input,select,textarea")[0]||ze,Rt=G$e(qe),Ot=ue._f.refs||[];if(Rt?Ot.find(xn=>xn===qe):qe===ue._f.ref)return;rr(r,G,{_f:{...ue._f,...Rt?{refs:[...Ot.filter(q3),qe,...Array.isArray(ut(s,G))?[{}]:[]],ref:{type:qe.type,name:G}}:{ref:qe}}}),R(G,!1,void 0,qe)}else ue=ut(r,G,{}),ue._f&&(ue._f.mount=!1),(t.shouldUnregister||pe.shouldUnregister)&&!(F$e(a.array,G)&&o.action)&&a.unMount.add(G)}}},_e=()=>t.shouldFocusError&&dp(r,U,a.mount),nn=G=>{el(G)&&(b.state.next({disabled:G}),dp(r,(pe,ue)=>{const Fe=ut(r,ue);Fe&&(pe.disabled=Fe._f.disabled||G,Array.isArray(Fe._f.refs)&&Fe._f.refs.forEach($e=>{$e.disabled=Fe._f.disabled||G}))},0,!1))},xt=(G,pe)=>async ue=>{let Fe;ue&&(ue.preventDefault&&ue.preventDefault(),ue.persist&&ue.persist());let $e=br(i);if(b.state.next({isSubmitting:!0}),t.resolver){const{errors:ze,values:qe}=await L();C(),n.errors=ze,$e=br(qe)}else await X({fields:r,eventType:Lh.SUBMIT});if(a.disabled.size)for(const ze of a.disabled)fs($e,ze);if(fs(n.errors,pZ),ei(n.errors)){b.state.next({errors:{}});try{await G($e,ue)}catch(ze){Fe=ze}}else pe&&await pe({...n.errors},ue),_e(),setTimeout(_e);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ei(n.errors)&&!Fe,submitCount:n.submitCount+1,errors:n.errors}),Fe)throw Fe},Jt=(G,pe={})=>{ut(r,G)&&(pr(pe.defaultValue)?W(G,br(ut(s,G))):(W(G,pe.defaultValue),rr(s,G,br(pe.defaultValue))),pe.keepTouched||fs(n.touchedFields,G),pe.keepDirty||(fs(n.dirtyFields,G),n.isDirty=pe.defaultValue?re(G,br(ut(s,G))):re()),pe.keepError||(fs(n.errors,G),p.isValid&&S()),b.state.next({...n}))},fn=(G,pe={})=>{const ue=G?br(G):s,Fe=br(ue),$e=ei(G),ze=$e?s:Fe;if(pe.keepDefaultValues||(s=ue),!pe.keepValues){if(pe.keepDirtyValues){const qe=new Set([...a.mount,...Object.keys(zm(s,i))]);for(const Rt of Array.from(qe)){const Ot=ut(n.dirtyFields,Rt),xn=ut(i,Rt),gn=ut(ze,Rt);Ot&&!pr(xn)?rr(ze,Rt,xn):!Ot&&!pr(gn)&&W(Rt,gn)}}else{if(h8&&pr(G))for(const qe of a.mount){const Rt=ut(r,qe);if(Rt&&Rt._f){const Ot=Array.isArray(Rt._f.refs)?Rt._f.refs[0]:Rt._f.ref;if(Bx(Ot)){const xn=Ot.closest("form");if(xn){xn.reset();break}}}}if(pe.keepFieldsRef)for(const qe of a.mount)W(qe,ut(ze,qe));else r={}}i=t.shouldUnregister?pe.keepDefaultValues?br(s):{}:br(ze),b.array.next({values:{...ze}}),b.state.next({values:{...ze}})}a={mount:pe.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!p.isValid||!!pe.keepIsValid||!!pe.keepDirtyValues||!t.shouldUnregister&&!ei(ze),o.watch=!!t.shouldUnregister,o.keepIsValid=!!pe.keepIsValid,o.action=!1,pe.keepErrors||(n.errors={}),b.state.next({submitCount:pe.keepSubmitCount?n.submitCount:0,isDirty:$e?!1:pe.keepDirty?n.isDirty:!!(pe.keepDefaultValues&&!tl(G,s)),isSubmitted:pe.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:$e?{}:pe.keepDirtyValues?pe.keepDefaultValues&&i?zm(s,i):n.dirtyFields:pe.keepDefaultValues&&G?zm(s,G):pe.keepDirty?n.dirtyFields:{},touchedFields:pe.keepTouched?n.touchedFields:{},errors:pe.keepErrors?n.errors:{},isSubmitSuccessful:pe.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},hn=(G,pe)=>fn(Qo(G)?G(i):G,{...t.resetOptions,...pe}),zn=(G,pe={})=>{const ue=ut(r,G),Fe=ue&&ue._f;if(Fe){const $e=Fe.refs?Fe.refs[0]:Fe.ref;$e.focus&&setTimeout(()=>{$e.focus(),pe.shouldSelect&&Qo($e.select)&&$e.select()})}},lr=G=>{n={...n,...G}},Fn={control:{register:He,unregister:rt,getFieldState:fe,handleSubmit:xt,setError:ge,_subscribe:Ae,_runSchema:L,_updateIsValidating:C,_focusError:_e,_getWatch:oe,_getDirty:re,_setValid:S,_setFieldArray:M,_setDisabledField:ct,_setErrors:T,_getFieldArray:F,_reset:fn,_resetDefaultValues:()=>Qo(t.defaultValues)&&t.defaultValues().then(G=>{hn(G,t.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:ee,_disableForm:nn,_subjects:b,_proxyFormState:p,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(G){o=G},get _defaultValues(){return s},get _names(){return a},set _names(G){a=G},get _formState(){return n},get _options(){return t},set _options(G){t={...t,...G}}},subscribe:Qe,trigger:Z,register:He,handleSubmit:xt,watch:Ee,setValue:W,setValues:Q,getValues:he,reset:hn,resetField:Jt,clearErrors:ye,unregister:rt,setError:ge,setFocus:zn,getFieldState:fe};return{...Fn,formControl:Fn}}var fu=()=>{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID();const e=typeof performance>"u"?Date.now():performance.now()*1e3;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=(Math.random()*16+e)%16|0;return(t=="x"?n:n&3|8).toString(16)})},G3=(e,t,n={})=>n.shouldFocus||pr(n.shouldFocus)?n.focusName||`${e}.${pr(n.focusIndex)?t:n.focusIndex}.`:"",W3=(e,t)=>[...e,...no(t)],K3=e=>Array.isArray(e)?e.map(()=>{}):void 0;function Y3(e,t,n){return[...e.slice(0,t),...no(n),...e.slice(t)]}var Z3=(e,t,n)=>Array.isArray(e)?(pr(e[n])&&(e[n]=void 0),e.splice(n,0,e.splice(t,1)[0]),e):[],X3=(e,t)=>[...no(t),...no(e)];function iFe(e,t){let n=0;const r=[...e];for(const s of t)r.splice(s-n,1),n++;return $w(r).length?r:[]}var Q3=(e,t)=>pr(t)?[]:iFe(e,no(t).sort((n,r)=>n-r)),J3=(e,t,n)=>{[e[t],e[n]]=[e[n],e[t]]},$I=(e,t,n)=>(e[t]=n,e);function m1(e){const t=H$e(),{control:n=t,name:r,keyName:s="id",shouldUnregister:i,rules:o}=e,[a,l]=te.useState(n._getFieldArray(r)),u=te.useRef(n._getFieldArray(r).map(fu)),h=te.useRef(!1);n._names.array.add(r),te.useMemo(()=>o&&a.length>=0&&n.register(r,o),[n,r,a.length,o]),mZ(()=>n._subjects.array.subscribe({next:({values:_,name:T})=>{if(T===r||!T){const R=ut(_,r);Array.isArray(R)&&(l(R),u.current=R.map(fu))}}}).unsubscribe,[n,r]);const p=te.useCallback(_=>{h.current=!0,n._setFieldArray(r,_)},[n,r]),m=(_,T)=>{const R=no(br(_)),D=W3(n._getFieldArray(r),R);n._names.focus=G3(r,D.length-1,T),u.current=W3(u.current,R.map(fu)),p(D),l(D),n._setFieldArray(r,D,W3,{argA:K3(_)})},b=(_,T)=>{const R=no(br(_)),D=X3(n._getFieldArray(r),R);n._names.focus=G3(r,0,T),u.current=X3(u.current,R.map(fu)),p(D),l(D),n._setFieldArray(r,D,X3,{argA:K3(_)})},y=_=>{const T=Q3(n._getFieldArray(r),_);u.current=Q3(u.current,_),p(T),l(T),!Array.isArray(ut(n._fields,r))&&rr(n._fields,r,void 0),n._setFieldArray(r,T,Q3,{argA:_})},x=(_,T,R)=>{const D=no(br(T)),j=Y3(n._getFieldArray(r),_,D);n._names.focus=G3(r,_,R),u.current=Y3(u.current,_,D.map(fu)),p(j),l(j),n._setFieldArray(r,j,Y3,{argA:_,argB:K3(T)})},S=(_,T)=>{const R=n._getFieldArray(r);J3(R,_,T),J3(u.current,_,T),p(R),l(R),n._setFieldArray(r,R,J3,{argA:_,argB:T},!1)},C=(_,T)=>{const R=n._getFieldArray(r);Z3(R,_,T),Z3(u.current,_,T),p(R),l(R),n._setFieldArray(r,R,Z3,{argA:_,argB:T},!1)},N=(_,T)=>{const R=br(T),D=$I(n._getFieldArray(r),_,R);u.current=[...D].map((j,L)=>!j||L===_?fu():u.current[L]),p(D),l([...D]),n._setFieldArray(r,D,$I,{argA:_,argB:R},!0,!1)},M=_=>{const T=no(br(_));u.current=T.map(fu),p([...T]),l([...T]),n._setFieldArray(r,[...T],R=>R,{},!0,!1)};return te.useEffect(()=>{n._state.action=!1,h6(r,n._names)&&n._subjects.state.next({...n._formState});const _=Jh(n._options.mode);if(h.current&&(!_.isOnSubmit||n._formState.isSubmitted)&&!Jh(n._options.reValidateMode).isOnSubmit&&!_.isOnBlur)if(n._options.resolver)n._runSchema([r]).then(T=>{n._updateIsValidating([r]);const R=ut(T.errors,r),D=ut(n._formState.errors,r);(D?!R&&D.type||R&&(D.type!==R.type||D.message!==R.message):R&&R.type)&&(R?rr(n._formState.errors,r,R):fs(n._formState.errors,r),n._subjects.state.next({errors:n._formState.errors}))});else{const T=ut(n._fields,r);T&&T._f&&!(Jh(n._options.reValidateMode).isOnSubmit&&Jh(n._options.mode).isOnSubmit)&&p6(T,n._names.disabled,n._formValues,n._options.criteriaMode===ea.all,n._options.shouldUseNativeValidation,!0).then(R=>!ei(R)&&n._subjects.state.next({errors:SZ(n._formState.errors,R,r)}))}n._subjects.state.next({name:r,values:br(n._formValues)}),n._names.focus&&dp(n._fields,(T,R)=>{if(n._names.focus&&R.startsWith(n._names.focus)&&T.focus)return T.focus(),1}),n._names.focus="",n._setValid(),h.current=!1},[a,r,n]),te.useEffect(()=>(!ut(n._formValues,r)&&n._setFieldArray(r),()=>{const _=!(n._options.shouldUnregister||i),T=(R,D)=>{const j=ut(n._fields,R);j&&j._f&&(j._f.mount=D)};h.current&&_&&n._subjects.state.next({name:r,values:br(n._formValues)}),_?T(r,!1):n.unregister(r)}),[r,n,s,i]),{swap:te.useCallback(S,[p,r,n]),move:te.useCallback(C,[p,r,n]),prepend:te.useCallback(b,[p,r,n]),append:te.useCallback(m,[p,r,n]),remove:te.useCallback(y,[p,r,n]),insert:te.useCallback(x,[p,r,n]),update:te.useCallback(N,[p,r,n]),replace:te.useCallback(M,[p,r,n]),fields:te.useMemo(()=>a.map((_,T)=>({..._,[s]:u.current[T]||fu()})),[a,s])}}function oFe(e={}){const t=te.useRef(void 0),n=te.useRef(void 0),[r,s]=te.useState(()=>({...br(CZ),isLoading:Qo(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Qo(e.defaultValues)?void 0:e.defaultValues}));if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!Qo(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:o,...a}=sFe(e);t.current={...a,formState:r}}const i=t.current.control;return i._options=e,mZ(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(a=>({...a,isReady:!0})),i._formState.isReady=!0,o},[i]),te.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),te.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),te.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),te.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),te.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==r.isDirty&&i._subjects.state.next({isDirty:o})}},[i,r.isDirty]),te.useEffect(()=>{var o;e.values&&!tl(e.values,n.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((o=i._options.resetOptions)===null||o===void 0)&&o.keepIsValid||i._setValid(),n.current=e.values,s(a=>({...a}))):i._resetDefaultValues()},[i,e.values]),te.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=te.useMemo(()=>U$e(r,i),[i,r]),t.current}const kZ=["eq","neq","contains","gt","lt","isempty","isnotempty"],m6=["create","update","delete","cron"],aFe=["set_variable","webhook","send_mail","edit_field","create_entry"],lFe=Hd({type:Xd(["set_variable","webhook","send_mail","edit_field","create_entry"]),name:es(),fixed_id:es(),column:es(),filters:Du(Hd({field:es(),op:Xd(kZ),value:es()})),url:es(),method:Xd(["POST","GET","PUT"]),headers:Du(Hd({key:es(),value:es()})),body_template:es(),to:es(),subject_template:es(),field:es(),value:es(),seed_slug:es(),field_map:Du(Hd({targetAlias:es(),sourceAlias:es()}))}).superRefine((e,t)=>{e.type==="set_variable"&&((!e.name||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e.name))&&t.addIssue({code:qo.custom,message:"automations.editor.errors.variableNameInvalid",path:["name"]}),e.name&&KNe.has(e.name)&&t.addIssue({code:qo.custom,message:"automations.editor.errors.variableNameReserved",path:["name"]})),e.type==="webhook"&&(e.url?es().url().safeParse(e.url).success||t.addIssue({code:qo.custom,message:"automations.editor.errors.urlInvalid",path:["url"]}):t.addIssue({code:qo.custom,message:"automations.editor.errors.urlRequired",path:["url"]})),e.type==="send_mail"&&(e.to?es().email().safeParse(e.to).success||t.addIssue({code:qo.custom,message:"automations.editor.errors.emailInvalid",path:["to"]}):t.addIssue({code:qo.custom,message:"automations.editor.errors.emailRequired",path:["to"]}),e.subject_template||t.addIssue({code:qo.custom,message:"automations.editor.errors.subjectRequired",path:["subject_template"]}),e.body_template||t.addIssue({code:qo.custom,message:"automations.editor.errors.bodyRequired",path:["body_template"]})),e.type==="edit_field"&&(e.field||t.addIssue({code:qo.custom,message:"automations.editor.errors.fieldRequired",path:["field"]})),e.type==="create_entry"&&(e.seed_slug||t.addIssue({code:qo.custom,message:"automations.editor.errors.seedRequired",path:["seed_slug"]}))}),cFe=Hd({name:es().min(1,"automations.editor.errors.nameRequired").max(100),triggers:Du(Hd({event:w7([XR(""),Xd(["create","update","delete","cron"])]),cron:es()})).min(1,"automations.editor.errors.triggersMin"),trigger_conditions:Hd({kind:XR("group"),op:Xd(["AND","OR"]),negate:awe(),children:Du(cwe())}),actions:Du(lFe).min(1,"automations.editor.errors.actionsMin")}).superRefine((e,t)=>{e.triggers.forEach((n,r)=>{n.event||t.addIssue({code:qo.custom,message:"automations.editor.errors.triggerEventRequired",path:["triggers",r,"event"]}),n.event==="cron"&&!n.cron&&t.addIssue({code:qo.custom,message:"automations.editor.errors.cronRequired",path:["triggers",r,"cron"]})})}),EZ={name:"",fixed_id:"",column:"",filters:[],url:"",method:"POST",headers:[],body_template:"",to:"",subject_template:"",field:"",value:"",seed_slug:"",field_map:[]},Ux={event:"",cron:""},Vx={kind:"group",op:"AND",negate:!1,children:[]},qx={kind:"predicate",left_kind:"ref",left_ref:"",left_literal:"",op:"eq",right_kind:"literal",right_ref:"",right_literal:""};function uFe({value:e,onChange:t,allowedEvents:n}){const{t:r}=tt(),[s,i]=w.useState(""),[o,a]=w.useState(!1),u=(n??m6).filter(h=>r(`automations.triggers.${h}`).toLowerCase().includes(s.toLowerCase()));return d.jsxs(Li,{open:o,onOpenChange:h=>{a(h),h||i("")},children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{variant:"outline",size:"sm",className:"h-8 justify-between w-full text-sm",children:[d.jsx("span",{className:"truncate",children:r(e?`automations.triggers.${e}`:"automations.editor.triggerSelectPlaceholder")}),d.jsx(Nc,{className:"size-3.5 opacity-60 shrink-0"})]})}),d.jsxs($i,{align:"start",className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:r("automations.editor.triggerLabel")}),d.jsx(Xt,{placeholder:r("automations.editor.searchPlaceholder"),value:s,onChange:h=>i(h.target.value),className:"h-8 text-sm mb-1"}),d.jsx(ti,{className:"my-1"}),d.jsx("div",{className:"flex flex-col gap-0.5",children:u.map(h=>d.jsx(Oe,{type:"button",variant:e===h?"secondary":"ghost",size:"sm",className:"h-8 justify-start px-2 text-xs",onClick:()=>{t(h),a(!1)},children:r(`automations.triggers.${h}`)},h))})]})]})}const FI=["eq","neq","contains","startswith","endswith","isempty","isnotempty","matches"],dFe=["eq","neq","in","notin","isempty","isnotempty"],fFe=["eq","neq","gt","gte","lt","lte","isempty","isnotempty"],hFe=["eq","neq","gt","gte","lt","lte","isempty","isnotempty"],pFe=["eq","neq","isempty","isnotempty"],BI=["eq","neq","contains","in","notin","isempty","isnotempty"],mFe=["isempty","isnotempty"],gFe=["eq","neq","gt","gte","lt","lte","contains","startswith","endswith","in","notin","isempty","isnotempty","matches"];function HI(e){if(!e)return gFe;switch(e.type){case"number":return fFe;case"date":return hFe;case"boolean":return pFe;case"tags":return BI;case"json":return BI;case"file":return mFe;case"text":return e.options?.length?dFe:FI;default:return FI}}function ev({branch:e,value:t,onChange:n,className:r="h-7 flex-1 min-w-[60px]"}){const{t:s}=tt(),i=s("automations.when.valuePlaceholder");if(!e)return d.jsx(Xt,{className:`${r} text-xs`,value:t,placeholder:i,onChange:a=>n(a.target.value)});if(e.type==="boolean"){const a=t==="true"?"true":t==="false"?"false":"";return d.jsxs(Rr,{value:a,onValueChange:n,children:[d.jsx(Or,{size:"sm",className:`${r} text-xs`,children:d.jsx(Gr,{placeholder:i})}),d.jsxs(Dr,{children:[d.jsx(or,{value:"true",children:s("automations.when.true")}),d.jsx(or,{value:"false",children:s("automations.when.false")})]})]})}if(e.type==="date")return d.jsx(GN,{id:"automation-value-date",value:t||null,onChange:a=>n(a??""),placeholder:s("automations.when.chooseDate")});if(e.type==="number")return d.jsx(Xt,{type:"number",className:`${r} text-xs`,value:t,placeholder:i,onChange:a=>n(a.target.value)});const o=e.options??[];return e.type==="text"&&o.length>0?d.jsxs(Rr,{value:t,onValueChange:n,children:[d.jsx(Or,{size:"sm",className:`${r} text-xs`,children:d.jsx(Gr,{placeholder:i})}),d.jsx(Dr,{children:o.map(a=>d.jsx(or,{value:a,children:a},a))})]}):(e.type==="tags"||e.type==="json")&&o.length>0?d.jsxs(Li,{modal:!1,children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:`${r} justify-between text-xs`,children:[d.jsx("span",{className:"truncate",children:t||s("automations.when.chooseTag")}),d.jsx(of,{className:"size-3.5 opacity-60 shrink-0"})]})}),d.jsx($i,{align:"end",className:"max-h-56 w-48 overflow-y-auto p-1",children:o.map(a=>d.jsx(Oe,{type:"button",variant:t===a?"secondary":"ghost",size:"sm",className:"h-8 w-full justify-start px-2 text-xs",onClick:()=>n(a),children:a},a))})]}):d.jsx(Xt,{className:`${r} text-xs`,value:t,placeholder:i,onChange:a=>n(a.target.value)})}function bFe({pred:e,onChange:t,onRemove:n,onWrap:r,seedBranches:s}){const{t:i}=tt(),o=e.op==="isempty"||e.op==="isnotempty",a=e.left_kind==="ref"&&e.left_ref.startsWith("this.")?s.find(p=>p.alias===e.left_ref.slice(5)):void 0,l=HI(a);function u(p){const m=p.startsWith("this.")?s.find(x=>x.alias===p.slice(5)):void 0,b=HI(m),y=b.includes(e.op)?e.op:b[0];t({...e,left_ref:p,op:y,right_literal:""})}function h(p){t({...e,op:p,right_literal:""})}return d.jsxs("div",{className:"flex items-start gap-1.5",children:[d.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 min-w-0",children:[e.left_kind==="ref"?d.jsxs(Rr,{value:e.left_ref,onValueChange:u,children:[d.jsx(Or,{size:"sm",className:"h-7 text-xs flex-1 min-w-[80px]",children:d.jsx(Gr,{placeholder:i("automations.when.fieldPlaceholder")})}),d.jsxs(Dr,{children:[s.map(p=>d.jsx(or,{value:`this.${p.alias}`,children:p.label},p.alias)),d.jsx(or,{value:"_custom",children:i("automations.when.customRef")})]})]}):d.jsx(ev,{branch:void 0,value:e.left_literal,onChange:p=>t({...e,left_literal:p})}),d.jsxs(Rr,{value:e.op,onValueChange:p=>h(p),children:[d.jsx(Or,{size:"sm",className:"h-7 text-xs w-28 shrink-0",children:d.jsx(Gr,{})}),d.jsx(Dr,{children:l.map(p=>d.jsx(or,{value:p,children:i(`automations.when.ops.${p}`)},p))})]}),!o&&(e.right_kind==="ref"?d.jsx(ev,{branch:void 0,value:e.right_ref,onChange:p=>t({...e,right_ref:p})}):d.jsx(ev,{branch:a,value:e.right_literal,onChange:p=>t({...e,right_literal:p})}))]}),d.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[r&&d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground/50 hover:text-muted-foreground",onClick:r,children:d.jsx(Qx,{className:"size-3"})})}),d.jsx(fa,{side:"top",className:"text-xs",children:i("automations.when.wrapGroup")})]}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-destructive/60 hover:text-destructive",onClick:n,children:d.jsx(La,{className:"size-3"})})]})]})}function NZ({group:e,onChange:t,onRemove:n,onWrap:r,seedBranches:s,depth:i=0}){const{t:o}=tt(),a=3,l=i===0,u=i<a;function h(S,C){const N=[...e.children];N[S]=C,t({...e,children:N})}function p(S){t({...e,children:e.children.filter((C,N)=>N!==S)})}function m(){t({...e,children:[...e.children,{...qx}]})}function b(){t({...e,op:e.op==="AND"?"OR":"AND"})}function y(){t({...e,negate:!e.negate})}function x(S){if(!u)return;const N={kind:"group",op:"OR",negate:!1,children:[e.children[S],{...qx}]},M=[...e.children];M[S]=N,t({...e,children:M})}return d.jsxs("div",{className:`${l?"":"ml-4 pl-3 border-l border-dashed border-border/60"} flex flex-col gap-1.5`,children:[(!l||e.children.length>1)&&d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx(Oe,{type:"button",variant:"outline",size:"sm",className:"h-6 px-2 text-xs",onClick:b,children:e.op==="AND"?o("automations.when.and"):o("automations.when.or")}),d.jsx(Oe,{type:"button",variant:"ghost",size:"sm",className:`h-6 px-2 text-xs ${e.negate?"text-destructive":"text-muted-foreground"}`,onClick:y,children:o("automations.when.not")}),!l&&d.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[r&&u&&d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:r,children:d.jsx(Qx,{className:"size-3"})})}),d.jsx(fa,{side:"top",className:"text-xs",children:o("automations.when.wrapGroup")})]}),n&&d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-destructive/60 hover:text-destructive",onClick:n,title:o("automations.when.removeGroup"),children:d.jsx(ro,{className:"size-3"})})]})]}),e.children.map((S,C)=>d.jsx("div",{children:S.kind==="predicate"?d.jsx(bFe,{pred:S,onChange:N=>h(C,N),onRemove:()=>p(C),onWrap:u?()=>x(C):void 0,seedBranches:s}):d.jsx(NZ,{group:S,onChange:N=>h(C,N),onRemove:()=>p(C),onWrap:u?()=>x(C):void 0,seedBranches:s,depth:i+1})},C)),d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground self-start",onClick:m,children:[d.jsx(Hi,{className:"size-3 mr-1"}),o("automations.when.addCondition")]})]})}function yFe({seedBranches:e}){const{watch:t,setValue:n}=Ml(),r=t("trigger_conditions");return d.jsx("div",{className:"mt-2",children:d.jsx(NZ,{group:r,onChange:s=>n("trigger_conditions",s,{shouldValidate:!0}),seedBranches:e})})}function UI(e){if(!e||!e.trim())return{preset:"daily",hour:"09",minute:"00",dayOfWeek:"1",dayOfMonth:"1"};const t=e.trim().split(/\s+/);if(t.length!==5)return{preset:"advanced",hour:"09",minute:"00",dayOfWeek:"1",dayOfMonth:"1"};const[n,r,s,i,o]=t;if(n==="0"&&r==="*"&&s==="*"&&i==="*"&&o==="*")return{preset:"hourly",hour:"00",minute:"00",dayOfWeek:"1",dayOfMonth:"1"};const a=/^\d+$/.test(n),l=/^\d+$/.test(r),u=a?n.padStart(2,"0"):"00",h=l?r.padStart(2,"0"):"09";return a&&l&&s==="*"&&i==="*"&&o==="*"?{preset:"daily",hour:h,minute:u,dayOfWeek:"1",dayOfMonth:"1"}:a&&l&&s==="*"&&i==="*"&&/^\d+$/.test(o)?{preset:"weekly",hour:h,minute:u,dayOfWeek:o,dayOfMonth:"1"}:a&&l&&/^\d+$/.test(s)&&i==="*"&&o==="*"?{preset:"monthly",hour:h,minute:u,dayOfWeek:"1",dayOfMonth:s}:{preset:"advanced",hour:h,minute:u,dayOfWeek:"1",dayOfMonth:"1"}}function vFe({triggerIndex:e}){const{t}=tt(),{watch:n,setValue:r,register:s,formState:{errors:i}}=Ml(),o=`triggers.${e}.cron`,a=n(o)??"",l=i.triggers?.[e]?.cron,[u,h]=w.useState(()=>UI(a||""));w.useEffect(()=>{if(a){const C=UI(a);h(N=>!N.preset||N.preset==="advanced"||a.trim()===""?C:N)}},[a]),w.useEffect(()=>{if(u.preset!=="advanced"){let C="";u.preset==="hourly"?C="0 * * * *":u.preset==="daily"?C=`${Number(u.minute)} ${Number(u.hour)} * * *`:u.preset==="weekly"?C=`${Number(u.minute)} ${Number(u.hour)} * * ${u.dayOfWeek}`:u.preset==="monthly"&&(C=`${Number(u.minute)} ${Number(u.hour)} ${u.dayOfMonth} * *`),a!==C&&r(o,C,{shouldValidate:!0})}},[u.preset,u.hour,u.minute,u.dayOfWeek,u.dayOfMonth,r,a,o]);function p(C){h(N=>({...N,...C}))}const m=[{id:"hourly",labelKey:"presetHourly",icon:Id},{id:"daily",labelKey:"presetDaily",icon:z6},{id:"weekly",labelKey:"presetWeekly",icon:JJ},{id:"monthly",labelKey:"presetMonthly",icon:Xx},{id:"advanced",labelKey:"presetAdvanced",icon:Mz}],b=Array.from({length:24},(C,N)=>String(N).padStart(2,"0")),y=["00","05","10","15","20","25","30","35","40","45","50","55"],x=[{value:"1",label:t("automations.editor.cron.days.1")},{value:"2",label:t("automations.editor.cron.days.2")},{value:"3",label:t("automations.editor.cron.days.3")},{value:"4",label:t("automations.editor.cron.days.4")},{value:"5",label:t("automations.editor.cron.days.5")},{value:"6",label:t("automations.editor.cron.days.6")},{value:"0",label:t("automations.editor.cron.days.0")}],S=Array.from({length:31},(C,N)=>String(N+1));return d.jsxs("div",{className:"mt-3",children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:t("automations.editor.cron.title")}),d.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-2",children:m.map(C=>{const N=C.icon,M=u.preset===C.id;return d.jsxs("button",{type:"button",onClick:()=>p({preset:C.id}),className:ie("flex flex-col items-center justify-center p-2.5 rounded-lg border text-xs font-medium transition-all relative overflow-hidden select-none cursor-pointer",M?"bg-primary/10 border-primary text-primary dark:bg-primary/20 shadow-xs":"bg-background hover:bg-muted/50 border-border text-muted-foreground hover:text-foreground"),children:[d.jsx(N,{className:ie("size-4 mb-1.5 transition-transform",M?"scale-110":"")}),d.jsx("span",{className:"text-[11px] text-center leading-tight",children:t(`automations.editor.cron.${C.labelKey}`)})]},C.id)})}),u.preset!=="hourly"&&u.preset!=="advanced"&&d.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-secondary/30 dark:bg-secondary/10 border border-secondary flex flex-wrap items-center gap-4 animate-in fade-in-50 duration-200",children:[d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("label",{className:"text-[11px] font-medium text-muted-foreground",children:t("automations.editor.cron.timeLabel")}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsxs(Rr,{value:u.hour,onValueChange:C=>p({hour:C}),children:[d.jsx(Or,{className:"h-8 w-18 text-xs bg-background",children:d.jsx(Gr,{})}),d.jsx(Dr,{position:"popper",className:"max-h-48",children:b.map(C=>d.jsx(or,{value:C,children:C},C))})]}),d.jsx("span",{className:"text-muted-foreground font-bold",children:":"}),d.jsxs(Rr,{value:u.minute,onValueChange:C=>p({minute:C}),children:[d.jsx(Or,{className:"h-8 w-18 text-xs bg-background",children:d.jsx(Gr,{})}),d.jsx(Dr,{position:"popper",className:"max-h-48",children:y.map(C=>d.jsx(or,{value:C,children:C},C))})]})]})]}),u.preset==="weekly"&&d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("label",{className:"text-[11px] font-medium text-muted-foreground",children:t("automations.editor.cron.dayOfWeekLabel")}),d.jsxs(Rr,{value:u.dayOfWeek,onValueChange:C=>p({dayOfWeek:C}),children:[d.jsx(Or,{className:"h-8 w-32 text-xs bg-background",children:d.jsx(Gr,{})}),d.jsx(Dr,{position:"popper",className:"max-h-48",children:x.map(C=>d.jsx(or,{value:C.value,children:C.label},C.value))})]})]}),u.preset==="monthly"&&d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("label",{className:"text-[11px] font-medium text-muted-foreground",children:t("automations.editor.cron.dayOfMonthLabel")}),d.jsxs(Rr,{value:u.dayOfMonth,onValueChange:C=>p({dayOfMonth:C}),children:[d.jsx(Or,{className:"h-8 w-20 text-xs bg-background",children:d.jsx(Gr,{})}),d.jsx(Dr,{position:"popper",className:"max-h-48",children:S.map(C=>d.jsx(or,{value:C,children:C},C))})]})]})]}),u.preset==="advanced"&&d.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-secondary/30 dark:bg-secondary/10 border border-secondary animate-in fade-in-50 duration-200",children:[d.jsx(Xt,{...s(o),placeholder:"0 9 * * 1",className:"h-8 text-sm font-mono bg-background"}),l&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:t(l.message??"")}),d.jsx("p",{className:"mt-1.5 text-[10px] text-muted-foreground leading-relaxed",children:t("automations.editor.cronHint")})]}),u.preset!=="advanced"&&l&&d.jsx("p",{className:"mt-1.5 text-xs text-destructive px-1",children:t(l.message??"")})]})}function xFe({seedBranches:e}){const{t}=tt(),{watch:n,setValue:r,formState:{errors:s}}=Ml(),{fields:i,append:o,remove:a}=m1({name:"triggers"}),l=n("triggers"),u=l.map(S=>S.event).filter(Boolean),h=m6.filter(S=>!u.includes(S)),p=u.includes("cron"),m=u.some(S=>S!=="cron"),b=u.length>0;function y(){o({...Ux})}function x(S,C){r(`triggers.${S}.event`,C,{shouldValidate:!0}),C!=="cron"&&r(`triggers.${S}.cron`,"",{shouldValidate:!1})}return d.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[d.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[d.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-primary/10",children:d.jsx(Rg,{className:"size-3.5 text-primary"})}),d.jsx("span",{className:"text-sm font-medium",children:t("automations.editor.triggerLabel")})]}),d.jsx("div",{className:"flex flex-col gap-2",children:i.map((S,C)=>{const N=l[C]?.event??"",M=N==="cron",_=u.filter((R,D)=>D!==C),T=m6.filter(R=>!_.includes(R));return d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:"flex-1",children:d.jsx(uFe,{value:N,onChange:R=>x(C,R),allowedEvents:T})}),i.length>1&&d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-destructive/60 hover:text-destructive",onClick:()=>a(C),children:d.jsx(ro,{className:"size-3.5"})})]}),M&&d.jsx(vFe,{triggerIndex:C}),s.triggers?.[C]?.event&&d.jsx("p",{className:"text-xs text-destructive",children:t(s.triggers[C].event.message??"")})]},S.id)})}),h.length>0&&d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"mt-2 h-7 px-2 text-xs text-muted-foreground",onClick:y,children:[d.jsx(Hi,{className:"size-3 mr-1"}),t("automations.editor.addTrigger")]}),s.triggers?.message&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:t(s.triggers.message)}),b&&(m||p)&&d.jsx(yFe,{seedBranches:e})]})}var VI=1,wFe=.9,SFe=.8,CFe=.17,eC=.1,tC=.999,kFe=.9999,EFe=.99,NFe=/[\\\/_+.#"@\[\(\{&]/,MFe=/[\\\/_+.#"@\[\(\{&]/g,_Fe=/[\s-]/,MZ=/[\s-]/g;function g6(e,t,n,r,s,i,o){if(i===t.length)return s===e.length?VI:EFe;var a=`${s},${i}`;if(o[a]!==void 0)return o[a];for(var l=r.charAt(i),u=n.indexOf(l,s),h=0,p,m,b,y;u>=0;)p=g6(e,t,n,r,u+1,i+1,o),p>h&&(u===s?p*=VI:NFe.test(e.charAt(u-1))?(p*=SFe,b=e.slice(s,u-1).match(MFe),b&&s>0&&(p*=Math.pow(tC,b.length))):_Fe.test(e.charAt(u-1))?(p*=wFe,y=e.slice(s,u-1).match(MZ),y&&s>0&&(p*=Math.pow(tC,y.length))):(p*=CFe,s>0&&(p*=Math.pow(tC,u-s))),e.charAt(u)!==t.charAt(i)&&(p*=kFe)),(p<eC&&n.charAt(u-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(u-1)!==r.charAt(i))&&(m=g6(e,t,n,r,u+1,i+2,o),m*eC>p&&(p=m*eC)),p>h&&(h=p),u=n.indexOf(l,u+1);return o[a]=h,h}function qI(e){return e.toLowerCase().replace(MZ," ")}function TFe(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,g6(e,t,qI(e),qI(t),0,0,{})}var vm='[cmdk-group=""]',nC='[cmdk-group-items=""]',AFe='[cmdk-group-heading=""]',_Z='[cmdk-item=""]',GI=`${_Z}:not([aria-disabled="true"])`,b6="cmdk-item-select",Gh="data-value",RFe=(e,t,n)=>TFe(e,t,n),TZ=w.createContext(void 0),g1=()=>w.useContext(TZ),AZ=w.createContext(void 0),x8=()=>w.useContext(AZ),RZ=w.createContext(void 0),OZ=w.forwardRef((e,t)=>{let n=Wh(()=>{var U,Z;return{search:"",value:(Z=(U=e.value)!=null?U:e.defaultValue)!=null?Z:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Wh(()=>new Set),s=Wh(()=>new Map),i=Wh(()=>new Map),o=Wh(()=>new Set),a=DZ(e),{label:l,children:u,value:h,onValueChange:p,filter:m,shouldFilter:b,loop:y,disablePointerSelection:x=!1,vimBindings:S=!0,...C}=e,N=ms(),M=ms(),_=ms(),T=w.useRef(null),R=HFe();_f(()=>{if(h!==void 0){let U=h.trim();n.current.value=U,D.emit()}},[h]),_f(()=>{R(6,ee)},[]);let D=w.useMemo(()=>({subscribe:U=>(o.current.add(U),()=>o.current.delete(U)),snapshot:()=>n.current,setState:(U,Z,he)=>{var fe,ye,ge,Ee;if(!Object.is(n.current[U],Z)){if(n.current[U]=Z,U==="search")X(),V(),R(1,q);else if(U==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Ae=document.getElementById(_);Ae?Ae.focus():(fe=document.getElementById(N))==null||fe.focus()}if(R(7,()=>{var Ae;n.current.selectedItemId=(Ae=re())==null?void 0:Ae.id,D.emit()}),he||R(5,ee),((ye=a.current)==null?void 0:ye.value)!==void 0){let Ae=Z??"";(Ee=(ge=a.current).onValueChange)==null||Ee.call(ge,Ae);return}}D.emit()}},emit:()=>{o.current.forEach(U=>U())}}),[]),j=w.useMemo(()=>({value:(U,Z,he)=>{var fe;Z!==((fe=i.current.get(U))==null?void 0:fe.value)&&(i.current.set(U,{value:Z,keywords:he}),n.current.filtered.items.set(U,L(Z,he)),R(2,()=>{V(),D.emit()}))},item:(U,Z)=>(r.current.add(U),Z&&(s.current.has(Z)?s.current.get(Z).add(U):s.current.set(Z,new Set([U]))),R(3,()=>{X(),V(),n.current.value||q(),D.emit()}),()=>{i.current.delete(U),r.current.delete(U),n.current.filtered.items.delete(U);let he=re();R(4,()=>{X(),he?.getAttribute("id")===U&&q(),D.emit()})}),group:U=>(s.current.has(U)||s.current.set(U,new Set),()=>{i.current.delete(U),s.current.delete(U)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:N,inputId:_,labelId:M,listInnerRef:T}),[]);function L(U,Z){var he,fe;let ye=(fe=(he=a.current)==null?void 0:he.filter)!=null?fe:RFe;return U?ye(U,n.current.search,Z):0}function V(){if(!n.current.search||a.current.shouldFilter===!1)return;let U=n.current.filtered.items,Z=[];n.current.filtered.groups.forEach(fe=>{let ye=s.current.get(fe),ge=0;ye.forEach(Ee=>{let Ae=U.get(Ee);ge=Math.max(Ae,ge)}),Z.push([fe,ge])});let he=T.current;oe().sort((fe,ye)=>{var ge,Ee;let Ae=fe.getAttribute("id"),Qe=ye.getAttribute("id");return((ge=U.get(Qe))!=null?ge:0)-((Ee=U.get(Ae))!=null?Ee:0)}).forEach(fe=>{let ye=fe.closest(nC);ye?ye.appendChild(fe.parentElement===ye?fe:fe.closest(`${nC} > *`)):he.appendChild(fe.parentElement===he?fe:fe.closest(`${nC} > *`))}),Z.sort((fe,ye)=>ye[1]-fe[1]).forEach(fe=>{var ye;let ge=(ye=T.current)==null?void 0:ye.querySelector(`${vm}[${Gh}="${encodeURIComponent(fe[0])}"]`);ge?.parentElement.appendChild(ge)})}function q(){let U=oe().find(he=>he.getAttribute("aria-disabled")!=="true"),Z=U?.getAttribute(Gh);D.setState("value",Z||void 0)}function X(){var U,Z,he,fe;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ye=0;for(let ge of r.current){let Ee=(Z=(U=i.current.get(ge))==null?void 0:U.value)!=null?Z:"",Ae=(fe=(he=i.current.get(ge))==null?void 0:he.keywords)!=null?fe:[],Qe=L(Ee,Ae);n.current.filtered.items.set(ge,Qe),Qe>0&&ye++}for(let[ge,Ee]of s.current)for(let Ae of Ee)if(n.current.filtered.items.get(Ae)>0){n.current.filtered.groups.add(ge);break}n.current.filtered.count=ye}function ee(){var U,Z,he;let fe=re();fe&&(((U=fe.parentElement)==null?void 0:U.firstChild)===fe&&((he=(Z=fe.closest(vm))==null?void 0:Z.querySelector(AFe))==null||he.scrollIntoView({block:"nearest"})),fe.scrollIntoView({block:"nearest"}))}function re(){var U;return(U=T.current)==null?void 0:U.querySelector(`${_Z}[aria-selected="true"]`)}function oe(){var U;return Array.from(((U=T.current)==null?void 0:U.querySelectorAll(GI))||[])}function F(U){let Z=oe()[U];Z&&D.setState("value",Z.getAttribute(Gh))}function se(U){var Z;let he=re(),fe=oe(),ye=fe.findIndex(Ee=>Ee===he),ge=fe[ye+U];(Z=a.current)!=null&&Z.loop&&(ge=ye+U<0?fe[fe.length-1]:ye+U===fe.length?fe[0]:fe[ye+U]),ge&&D.setState("value",ge.getAttribute(Gh))}function le(U){let Z=re(),he=Z?.closest(vm),fe;for(;he&&!fe;)he=U>0?FFe(he,vm):BFe(he,vm),fe=he?.querySelector(GI);fe?D.setState("value",fe.getAttribute(Gh)):se(U)}let W=()=>F(oe().length-1),Q=U=>{U.preventDefault(),U.metaKey?W():U.altKey?le(1):se(1)},H=U=>{U.preventDefault(),U.metaKey?F(0):U.altKey?le(-1):se(-1)};return w.createElement(dt.div,{ref:t,tabIndex:-1,...C,"cmdk-root":"",onKeyDown:U=>{var Z;(Z=C.onKeyDown)==null||Z.call(C,U);let he=U.nativeEvent.isComposing||U.keyCode===229;if(!(U.defaultPrevented||he))switch(U.key){case"n":case"j":{S&&U.ctrlKey&&Q(U);break}case"ArrowDown":{Q(U);break}case"p":case"k":{S&&U.ctrlKey&&H(U);break}case"ArrowUp":{H(U);break}case"Home":{U.preventDefault(),F(0);break}case"End":{U.preventDefault(),W();break}case"Enter":{U.preventDefault();let fe=re();if(fe){let ye=new Event(b6);fe.dispatchEvent(ye)}}}}},w.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:VFe},l),Fw(e,U=>w.createElement(AZ.Provider,{value:D},w.createElement(TZ.Provider,{value:j},U))))}),OFe=w.forwardRef((e,t)=>{var n,r;let s=ms(),i=w.useRef(null),o=w.useContext(RZ),a=g1(),l=DZ(e),u=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:o?.forceMount;_f(()=>{if(!u)return a.item(s,o?.id)},[u]);let h=jZ(s,i,[e.value,e.children,i],e.keywords),p=x8(),m=Ec(R=>R.value&&R.value===h.current),b=Ec(R=>u||a.filter()===!1?!0:R.search?R.filtered.items.get(s)>0:!0);w.useEffect(()=>{let R=i.current;if(!(!R||e.disabled))return R.addEventListener(b6,y),()=>R.removeEventListener(b6,y)},[b,e.onSelect,e.disabled]);function y(){var R,D;x(),(D=(R=l.current).onSelect)==null||D.call(R,h.current)}function x(){p.setState("value",h.current,!0)}if(!b)return null;let{disabled:S,value:C,onSelect:N,forceMount:M,keywords:_,...T}=e;return w.createElement(dt.div,{ref:wc(i,t),...T,id:s,"cmdk-item":"",role:"option","aria-disabled":!!S,"aria-selected":!!m,"data-disabled":!!S,"data-selected":!!m,onPointerMove:S||a.getDisablePointerSelection()?void 0:x,onClick:S?void 0:y},e.children)}),DFe=w.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:s,...i}=e,o=ms(),a=w.useRef(null),l=w.useRef(null),u=ms(),h=g1(),p=Ec(b=>s||h.filter()===!1?!0:b.search?b.filtered.groups.has(o):!0);_f(()=>h.group(o),[]),jZ(o,a,[e.value,e.heading,l]);let m=w.useMemo(()=>({id:o,forceMount:s}),[s]);return w.createElement(dt.div,{ref:wc(a,t),...i,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&w.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:u},n),Fw(e,b=>w.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},w.createElement(RZ.Provider,{value:m},b))))}),jFe=w.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,s=w.useRef(null),i=Ec(o=>!o.search);return!n&&!i?null:w.createElement(dt.div,{ref:wc(s,t),...r,"cmdk-separator":"",role:"separator"})}),IFe=w.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,s=e.value!=null,i=x8(),o=Ec(u=>u.search),a=Ec(u=>u.selectedItemId),l=g1();return w.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),w.createElement(dt.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:s?e.value:o,onChange:u=>{s||i.setState("search",u.target.value),n?.(u.target.value)}})}),zFe=w.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...s}=e,i=w.useRef(null),o=w.useRef(null),a=Ec(u=>u.selectedItemId),l=g1();return w.useEffect(()=>{if(o.current&&i.current){let u=o.current,h=i.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let b=u.offsetHeight;h.style.setProperty("--cmdk-list-height",b.toFixed(1)+"px")})});return m.observe(u),()=>{cancelAnimationFrame(p),m.unobserve(u)}}},[]),w.createElement(dt.div,{ref:wc(i,t),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Fw(e,u=>w.createElement("div",{ref:wc(o,l.listInnerRef),"cmdk-list-sizer":""},u)))}),LFe=w.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:s,contentClassName:i,container:o,...a}=e;return w.createElement(i2,{open:n,onOpenChange:r},w.createElement(o2,{container:o},w.createElement(a2,{"cmdk-overlay":"",className:s}),w.createElement(l2,{"aria-label":e.label,"cmdk-dialog":"",className:i},w.createElement(OZ,{ref:t,...a}))))}),PFe=w.forwardRef((e,t)=>Ec(n=>n.filtered.count===0)?w.createElement(dt.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),$Fe=w.forwardRef((e,t)=>{let{progress:n,children:r,label:s="Loading...",...i}=e;return w.createElement(dt.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},Fw(e,o=>w.createElement("div",{"aria-hidden":!0},o)))}),lo=Object.assign(OZ,{List:zFe,Item:OFe,Input:IFe,Group:DFe,Separator:jFe,Dialog:LFe,Empty:PFe,Loading:$Fe});function FFe(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function BFe(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function DZ(e){let t=w.useRef(e);return _f(()=>{t.current=e}),t}var _f=typeof window>"u"?w.useEffect:w.useLayoutEffect;function Wh(e){let t=w.useRef();return t.current===void 0&&(t.current=e()),t}function Ec(e){let t=x8(),n=()=>e(t.snapshot());return w.useSyncExternalStore(t.subscribe,n,n)}function jZ(e,t,n,r=[]){let s=w.useRef(),i=g1();return _f(()=>{var o;let a=(()=>{var u;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(u=h.current.textContent)==null?void 0:u.trim():s.current}})(),l=r.map(u=>u.trim());i.value(e,a,l),(o=t.current)==null||o.setAttribute(Gh,a),s.current=a}),s}var HFe=()=>{let[e,t]=w.useState(),n=Wh(()=>new Map);return _f(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,s)=>{n.current.set(r,s),t({})}};function UFe(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Fw({asChild:e,children:t},n){return e&&w.isValidElement(t)?w.cloneElement(UFe(t),{ref:t.ref},n(t.props.children)):n(t)}var VFe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const w8=w.forwardRef(({className:e,...t},n)=>d.jsx(lo,{ref:n,className:ie("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));w8.displayName=lo.displayName;const qFe=({children:e,...t})=>d.jsx(kf,{...t,children:d.jsx(Ef,{className:"overflow-hidden p-0",children:d.jsx(w8,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})})}),S8=w.forwardRef(({className:e,...t},n)=>d.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[d.jsx(aC,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),d.jsx(lo.Input,{ref:n,className:ie("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));S8.displayName=lo.Input.displayName;const C8=w.forwardRef(({className:e,...t},n)=>d.jsx(lo.List,{ref:n,className:ie("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));C8.displayName=lo.List.displayName;const k8=w.forwardRef((e,t)=>d.jsx(lo.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));k8.displayName=lo.Empty.displayName;const Yd=w.forwardRef(({className:e,...t},n)=>d.jsx(lo.Group,{ref:n,className:ie("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Yd.displayName=lo.Group.displayName;const tv=w.forwardRef(({className:e,...t},n)=>d.jsx(lo.Separator,{ref:n,className:ie("-mx-1 h-px bg-border",e),...t}));tv.displayName=lo.Separator.displayName;const vo=w.forwardRef(({className:e,...t},n)=>d.jsx(lo.Item,{ref:n,className:ie("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));vo.displayName=lo.Item.displayName;const IZ=({className:e,...t})=>d.jsx("span",{className:ie("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});IZ.displayName="CommandShortcut";function GFe({index:e,triggerSeedSlug:t}){const{t:n}=tt(),{register:r,control:s,watch:i,setValue:o,formState:{errors:a}}=Ml(),{data:l=[]}=n0(),{fields:u,append:h,remove:p}=m1({control:s,name:`actions.${e}.filters`}),[m,b]=w.useState(!1),[y,x]=w.useState(""),S=w.useRef(null),C=i(`actions.${e}.seed_slug`),N=i(`actions.${e}.fixed_id`),M=i(`actions.${e}.column`),_=a.actions?.[e],T=!N,R=l.find(q=>q.slug===(C||t));w.useEffect(()=>{N?x(N):C&&x(C)},[N,C]);function D(q){o(`actions.${e}.seed_slug`,q),o(`actions.${e}.fixed_id`,""),x(q),b(!1)}function j(q){const X=l.find(ee=>ee.slug===q);X?D(X.slug):(o(`actions.${e}.fixed_id`,q),o(`actions.${e}.seed_slug`,""),x(q))}function L(q){x(q),q||(o(`actions.${e}.seed_slug`,""),o(`actions.${e}.fixed_id`,""))}const V=l.find(q=>q.slug===t);return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[n("automations.actions.variableName")," *"]}),d.jsx(Xt,{...r(`actions.${e}.name`),placeholder:"cliente",className:"h-8 text-sm font-mono"}),_?.name&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:n(_.name.message)}),d.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:n("automations.actions.variableNameHint")})]}),d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[n("automations.actions.source")," *"]}),d.jsxs(r0,{open:m,onOpenChange:b,children:[d.jsx(s0,{asChild:!0,children:d.jsxs(Oe,{type:"button",variant:"outline",role:"combobox",className:"h-8 w-full justify-between text-sm font-normal",children:[d.jsx("span",{className:"truncate",children:N?d.jsx("span",{className:"text-muted-foreground",children:n("automations.actions.fixedIdBadge",{id:N})}):C?l.find(q=>q.slug===C)?.label??C:d.jsx("span",{className:"text-muted-foreground",children:n("automations.actions.sourcePlaceholder")})}),d.jsx(Nc,{className:"ml-2 h-3 w-3 shrink-0 opacity-50"})]})}),d.jsx(i0,{className:"w-64 p-0",align:"start",children:d.jsxs(w8,{shouldFilter:!1,children:[d.jsx(S8,{ref:S,placeholder:n("automations.editor.searchPlaceholder"),value:y,onValueChange:L}),d.jsxs(C8,{children:[d.jsx(k8,{children:y?d.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-xs hover:bg-accent",onClick:()=>j(y),children:n("automations.actions.useAsFixedId",{value:y})}):n("commandPalette.noResults")}),V&&d.jsxs(vo,{value:V.slug,onSelect:()=>D(V.slug),className:"text-xs",children:[V.label,d.jsx(gi,{variant:"secondary",className:"ml-2 text-[10px] py-0",children:n("automations.actions.thisSeed")})]}),l.filter(q=>q.slug!==t).filter(q=>!y||q.slug.includes(y)||q.label.toLowerCase().includes(y.toLowerCase())).map(q=>d.jsx(vo,{value:q.slug,onSelect:()=>D(q.slug),className:"text-xs",children:q.label},q.slug)),y&&!l.find(q=>q.slug===y)&&d.jsx(vo,{value:`__fixed__${y}`,onSelect:()=>j(y),className:"text-xs text-muted-foreground",children:n("automations.actions.useAsFixedId",{value:y})})]})]})})]}),N&&d.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[d.jsxs(gi,{variant:"outline",className:"text-[10px] font-mono",children:["ID: ",N]}),d.jsx("button",{type:"button",className:"text-[10px] text-muted-foreground hover:text-foreground",onClick:()=>{o(`actions.${e}.fixed_id`,""),x("")},children:"✕"})]})]}),T&&R&&R.branches.length>0&&d.jsxs("div",{children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:n("automations.actions.column")}),d.jsxs(Rr,{value:M??"",onValueChange:q=>o(`actions.${e}.column`,q==="__all__"?"":q),children:[d.jsx(Or,{size:"sm",className:"h-8 text-sm",children:d.jsx(Gr,{placeholder:n("automations.actions.columnAll")})}),d.jsxs(Dr,{children:[d.jsx(or,{value:"__all__",children:n("automations.actions.columnAll")}),R.branches.map(q=>d.jsx(or,{value:q.alias,children:q.label},q.alias))]})]})]}),T&&d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center justify-between mb-1",children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:n("automations.actions.filters")}),d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>h({field:"",op:"eq",value:""}),children:[d.jsx(Hi,{className:"size-3 mr-1"}),n("automations.editor.addCondition")]})]}),u.map((q,X)=>{const ee=i(`actions.${e}.filters.${X}.field`),re=i(`actions.${e}.filters.${X}.op`),oe=re!=="isempty"&&re!=="isnotempty";return d.jsxs("div",{className:"flex gap-1.5 items-center mb-1.5",children:[d.jsxs(Rr,{value:ee??"",onValueChange:F=>o(`actions.${e}.filters.${X}.field`,F),children:[d.jsx(Or,{size:"sm",className:"h-7 text-xs flex-1",children:d.jsx(Gr,{placeholder:n("automations.editor.conditionField")})}),d.jsx(Dr,{children:(R?.branches??[]).map(F=>d.jsx(or,{value:F.alias,children:F.label},F.alias))})]}),d.jsxs(Rr,{value:re??"eq",onValueChange:F=>o(`actions.${e}.filters.${X}.op`,F),children:[d.jsx(Or,{size:"sm",className:"h-7 text-xs w-28",children:d.jsx(Gr,{})}),d.jsx(Dr,{children:kZ.map(F=>d.jsx(or,{value:F,children:n(`automations.ops.${F}`)},F))})]}),oe&&d.jsx(Xt,{...r(`actions.${e}.filters.${X}.value`),placeholder:"{{this.field}}",className:"h-7 text-xs flex-1 font-mono"}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>p(X),children:d.jsx(La,{className:"size-3"})})]},q.id)}),u.length===0&&d.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("automations.actions.noFilters")}),d.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:n("automations.actions.filterTemplateHint")})]}),d.jsxs("div",{className:"rounded border border-border/50 bg-muted/30 p-2",children:[d.jsx("p",{className:"text-[10px] font-medium text-muted-foreground mb-1",children:n("automations.actions.templateHintTitle")}),N?d.jsx("pre",{className:"text-[10px] text-muted-foreground whitespace-pre-wrap font-mono leading-relaxed",children:n("automations.actions.hintFixed")}):d.jsx("pre",{className:"text-[10px] text-muted-foreground whitespace-pre-wrap font-mono leading-relaxed",children:n("automations.actions.hintCollection")})]})]})}function WFe({index:e}){const{t}=tt(),{register:n,control:r,watch:s,setValue:i,formState:{errors:o}}=Ml(),{fields:a,append:l,remove:u}=m1({control:r,name:`actions.${e}.headers`}),h=s(`actions.${e}.method`),p=o.actions?.[e];return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[t("automations.actions.webhookUrl")," *"]}),d.jsx(Xt,{...n(`actions.${e}.url`),placeholder:"https://example.com/webhook",className:"h-8 text-sm"}),p?.url&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:t(p.url.message)})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:t("automations.actions.webhookMethod")}),d.jsxs(Rr,{value:h??"POST",onValueChange:m=>i(`actions.${e}.method`,m),children:[d.jsx(Or,{size:"sm",className:"h-8 text-sm",children:d.jsx(Gr,{})}),d.jsx(Dr,{children:["POST","GET","PUT"].map(m=>d.jsx(or,{value:m,children:m},m))})]})]}),d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center justify-between mb-1",children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:t("automations.actions.webhookHeaders")}),d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>l({key:"",value:""}),children:[d.jsx(Hi,{className:"size-3 mr-1"}),t("automations.actions.addHeader")]})]}),a.map((m,b)=>d.jsxs("div",{className:"flex gap-2 mb-1",children:[d.jsx(Xt,{...n(`actions.${e}.headers.${b}.key`),placeholder:t("automations.actions.webhookHeaderKeyPlaceholder"),className:"h-7 text-xs"}),d.jsx(Xt,{...n(`actions.${e}.headers.${b}.value`),placeholder:t("automations.actions.webhookHeaderValuePlaceholder"),className:"h-7 text-xs"}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>u(b),children:d.jsx(La,{className:"size-3"})})]},m.id))]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:t("automations.actions.webhookBody")}),d.jsx("textarea",{...n(`actions.${e}.body_template`),rows:3,placeholder:'{"event": "{{trigger_event}}"}',className:"w-full rounded-md border border-input bg-background px-3 py-2 text-xs font-mono resize-none focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),d.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:t("automations.actions.templateHint")})]})]})}function KFe({index:e}){const{t}=tt(),{register:n,formState:{errors:r}}=Ml(),s=r.actions?.[e];return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[t("automations.actions.mailTo")," *"]}),d.jsx(Xt,{...n(`actions.${e}.to`),type:"email",placeholder:t("automations.actions.mailToPlaceholder"),className:"h-8 text-sm"}),s?.to&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:t(s.to.message)})]}),d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[t("automations.actions.mailSubject")," *"]}),d.jsx(Xt,{...n(`actions.${e}.subject_template`),placeholder:t("automations.actions.mailSubjectPlaceholder"),className:"h-8 text-sm"}),s?.subject_template&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:t(s.subject_template.message)}),d.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:t("automations.actions.templateHint")})]}),d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[t("automations.actions.mailBody")," *"]}),d.jsx("textarea",{...n(`actions.${e}.body_template`),rows:4,placeholder:t("automations.actions.mailBodyPlaceholder"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm resize-none focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),s?.body_template&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:t(s.body_template.message)}),d.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:t("automations.actions.templateHint")})]})]})}function YFe({index:e,seedBranches:t}){const{t:n}=tt(),{watch:r,setValue:s,formState:{errors:i}}=Ml(),o=r(`actions.${e}.field`),a=r(`actions.${e}.value`),l=i.actions?.[e],u=t.find(p=>p.alias===o);function h(p){s(`actions.${e}.field`,p),s(`actions.${e}.value`,"")}return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[n("automations.actions.editField")," *"]}),d.jsxs(Rr,{value:o??"",onValueChange:h,children:[d.jsx(Or,{size:"sm",className:"h-8 text-sm",children:d.jsx(Gr,{placeholder:n("automations.actions.editFieldPlaceholder")})}),d.jsx(Dr,{children:t.map(p=>d.jsx(or,{value:p.alias,children:p.label},p.alias))})]}),l?.field&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:n(l.field.message)})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:n("automations.actions.editValue")}),d.jsx(ev,{branch:u,value:a??"",onChange:p=>s(`actions.${e}.value`,p),className:"h-8 flex-1"})]})]})}function ZFe({index:e}){const{t}=tt(),{control:n,watch:r,setValue:s,formState:{errors:i}}=Ml(),{data:o=[]}=n0(),{fields:a,append:l,remove:u}=m1({control:n,name:`actions.${e}.field_map`}),h=r(`actions.${e}.seed_slug`),p=i.actions?.[e],m=o.find(b=>b.slug===h);return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[t("automations.actions.targetSeed")," *"]}),d.jsxs(Rr,{value:h??"",onValueChange:b=>s(`actions.${e}.seed_slug`,b),children:[d.jsx(Or,{size:"sm",className:"h-8 text-sm",children:d.jsx(Gr,{placeholder:t("automations.actions.targetSeedPlaceholder")})}),d.jsx(Dr,{children:o.map(b=>d.jsx(or,{value:b.slug,children:b.label},b.slug))})]}),p?.seed_slug&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:t(p.seed_slug.message)})]}),d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center justify-between mb-1",children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:t("automations.actions.fieldMap")}),d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>l({targetAlias:"",sourceAlias:""}),children:[d.jsx(Hi,{className:"size-3 mr-1"}),t("automations.actions.addFieldMap")]})]}),a.map((b,y)=>d.jsxs("div",{className:"flex gap-2 mb-1 items-center",children:[d.jsxs(Rr,{value:r(`actions.${e}.field_map.${y}.targetAlias`)??"",onValueChange:x=>s(`actions.${e}.field_map.${y}.targetAlias`,x),children:[d.jsx(Or,{size:"sm",className:"h-7 text-xs flex-1",children:d.jsx(Gr,{placeholder:t("automations.actions.fieldMapTarget")})}),d.jsx(Dr,{children:(m?.branches??[]).map(x=>d.jsx(or,{value:x.alias,children:x.label},x.alias))})]}),d.jsx("span",{className:"text-xs text-muted-foreground",children:"←"}),d.jsxs(Rr,{value:r(`actions.${e}.field_map.${y}.sourceAlias`)??"",onValueChange:x=>s(`actions.${e}.field_map.${y}.sourceAlias`,x),children:[d.jsx(Or,{size:"sm",className:"h-7 text-xs flex-1",children:d.jsx(Gr,{placeholder:t("automations.actions.fieldMapSource")})}),d.jsx(Dr,{children:(m?.branches??[]).map(x=>d.jsx(or,{value:x.alias,children:x.label},x.alias))})]}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>u(y),children:d.jsx(La,{className:"size-3"})})]},b.id))]})]})}const XFe={set_variable:"border-l-cyan-500",webhook:"border-l-blue-500",send_mail:"border-l-green-500",edit_field:"border-l-amber-500",create_entry:"border-l-purple-500"};function QFe({index:e,total:t,seedBranches:n,seedSlug:r,onRemove:s,onMoveUp:i,onMoveDown:o}){const{t:a}=tt(),{watch:l}=Ml(),u=l(`actions.${e}.type`);return d.jsxs(Zn,{className:`border-l-4 ${XFe[u]??"border-l-border"}`,children:[d.jsxs(Tr,{className:"flex flex-row items-center justify-between p-3 pb-2",children:[d.jsx("span",{className:"text-sm font-medium",children:a(`automations.actions.${u}`)}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-6",onClick:i,disabled:e===0,"aria-label":"Move up",children:d.jsx(T6,{className:"size-3.5"})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-6",onClick:o,disabled:e===t-1,"aria-label":"Move down",children:d.jsx(Nc,{className:"size-3.5"})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 text-destructive hover:text-destructive",onClick:s,"aria-label":"Remove action",children:d.jsx(ro,{className:"size-3.5"})})]})]}),d.jsxs(Xn,{className:"p-3 pt-0",children:[u==="set_variable"&&d.jsx(GFe,{index:e,triggerSeedSlug:r}),u==="webhook"&&d.jsx(WFe,{index:e}),u==="send_mail"&&d.jsx(KFe,{index:e}),u==="edit_field"&&d.jsx(YFe,{index:e,seedBranches:n}),u==="create_entry"&&d.jsx(ZFe,{index:e})]})]})}function JFe({onAdd:e}){const{t}=tt(),{data:n}=hbe(),[r,s]=w.useState(""),[i,o]=w.useState(!1),l=aFe.filter(h=>!(h==="send_mail"&&n?.features?.email===!1)).filter(h=>t(`automations.actions.${h}`).toLowerCase().includes(r.toLowerCase()));function u(h){e({...EZ,type:h}),o(!1),s("")}return d.jsxs(Li,{open:i,onOpenChange:h=>{o(h),h||s("")},children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{variant:"outline",size:"sm",className:"h-8 w-full text-sm justify-between",children:[d.jsx("span",{children:t("automations.editor.addAction")}),d.jsx(Nc,{className:"size-3.5 opacity-60 shrink-0"})]})}),d.jsxs($i,{align:"start",className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:t("automations.editor.actionsLabel")}),d.jsx(Xt,{placeholder:t("automations.editor.searchPlaceholder"),value:r,onChange:h=>s(h.target.value),className:"h-8 text-sm mb-1"}),d.jsx(ti,{className:"my-1"}),d.jsx("div",{className:"flex flex-col gap-0.5",children:l.map(h=>d.jsx(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-8 justify-start px-2 text-xs",onClick:()=>u(h),children:t(`automations.actions.${h}`)},h))})]})]})}function zZ(){return d.jsx("div",{className:"flex justify-center py-1",children:d.jsx("div",{className:"w-px h-6 bg-border"})})}function eBe({seedBranches:e,seedSlug:t}){const{t:n}=tt(),{control:r,formState:{errors:s}}=Ml(),{fields:i,append:o,remove:a,swap:l}=m1({control:r,name:"actions"});function u(h){o(h)}return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[d.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-primary/10",children:d.jsx(pne,{className:"size-3.5 text-primary"})}),d.jsx("span",{className:"text-sm font-medium",children:n("automations.editor.actionsLabel")})]}),i.length===0&&d.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:n("automations.editor.noActions")}),i.map((h,p)=>d.jsxs("div",{children:[d.jsx(QFe,{index:p,total:i.length,seedBranches:e,seedSlug:t,onRemove:()=>a(p),onMoveUp:()=>l(p,p-1),onMoveDown:()=>l(p,p+1)}),p<i.length-1&&d.jsx(zZ,{})]},h.id)),s.actions?.root?.message&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:n(s.actions.root.message)}),typeof s.actions?.message=="string"&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:n(s.actions.message)}),d.jsx("div",{className:"mt-3",children:d.jsx(JFe,{onAdd:u})})]})}const WI=(e,t,n)=>{if(e&&"reportValidity"in e){const r=ut(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},y6=(e,t)=>{for(const n in t.fields){const r=t.fields[n];r&&r.ref&&"reportValidity"in r.ref?WI(r.ref,n,e):r&&r.refs&&r.refs.forEach(s=>WI(s,n,e))}},KI=(e,t)=>{t.shouldUseNativeValidation&&y6(e,t);const n={};for(const r in e){const s=ut(t.fields,r),i=Object.assign(e[r]||{},{ref:s&&s.ref});if(tBe(t.names||Object.keys(e),r)){const o=Object.assign({},ut(n,r));rr(o,"root",i),rr(n,r,o)}else rr(n,r,i)}return n},tBe=(e,t)=>{const n=YI(t);return e.some(r=>YI(r).match(`^${n}\\.\\d+`))};function YI(e){return e.replace(/\]|\[/g,"")}function ZI(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function nBe(e,t){for(var n={};e.length;){var r=e[0],s=r.code,i=r.message,o=r.path.join(".");if(!n[o])if("unionErrors"in r){var a=r.unionErrors[0].errors[0];n[o]={message:a.message,type:a.code}}else n[o]={message:i,type:s};if("unionErrors"in r&&r.unionErrors.forEach(function(h){return h.errors.forEach(function(p){return e.push(p)})}),t){var l=n[o].types,u=l&&l[r.code];n[o]=b8(o,t,n,s,u?[].concat(u,r.message):r.message)}e.shift()}return n}function rBe(e,t){for(var n={};e.length;){var r=e[0],s=r.code,i=r.message,o=r.path.join(".");if(!n[o])if(r.code==="invalid_union"&&r.errors.length>0){var a=r.errors[0][0];n[o]={message:a.message,type:a.code}}else n[o]={message:i,type:s};if(r.code==="invalid_union"&&r.errors.forEach(function(h){return h.forEach(function(p){return e.push(p)})}),t){var l=n[o].types,u=l&&l[r.code];n[o]=b8(o,t,n,s,u?[].concat(u,r.message):r.message)}e.shift()}return n}function sBe(e,t,n){if(n===void 0&&(n={}),(function(r){return"_def"in r&&typeof r._def=="object"&&"typeName"in r._def})(e))return function(r,s,i){try{return Promise.resolve(ZI(function(){return Promise.resolve(e[n.mode==="sync"?"parse":"parseAsync"](r,t)).then(function(o){return i.shouldUseNativeValidation&&y6({},i),{errors:{},values:n.raw?Object.assign({},r):o}})},function(o){if((function(a){return Array.isArray(a?.issues)})(o))return{values:{},errors:KI(nBe(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if((function(r){return"_zod"in r&&typeof r._zod=="object"})(e))return function(r,s,i){try{return Promise.resolve(ZI(function(){return Promise.resolve((n.mode==="sync"?lye:cye)(e,r,t)).then(function(o){return i.shouldUseNativeValidation&&y6({},i),{errors:{},values:n.raw?Object.assign({},r):o}})},function(o){if((function(a){return a instanceof v7})(o))return{values:{},errors:KI(rBe(o.issues,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}function iBe(e){const t=wi(),{t:n}=tt();return Fs({mutationFn:r=>h1.create(r),onSuccess:()=>{t.invalidateQueries({queryKey:fl.list(e)}),_n.success(n("automations.toast.created"))},onError:()=>{_n.error(n("automations.toast.error"))}})}function oBe(e){const t=wi(),{t:n}=tt();return Fs({mutationFn:({id:r,body:s})=>h1.update(r,s),onSuccess:(r,{id:s})=>{t.invalidateQueries({queryKey:fl.list(e)}),t.invalidateQueries({queryKey:fl.item(s)}),_n.success(n("automations.toast.updated"))},onError:()=>{_n.error(n("automations.toast.error"))}})}function XI(e){return!e||e.length===0?[{...Ux}]:e.map(t=>({event:t.event,cron:t.cron??""}))}function aBe(e){return{...qx,left_kind:e.left.kind,left_ref:e.left.kind==="ref"?e.left.key:"",left_literal:e.left.kind==="literal"?String(e.left.value??""):"",op:e.op,right_kind:e.right?.kind??"literal",right_ref:e.right?.kind==="ref"?e.right.key:"",right_literal:e.right?.kind==="literal"?String(e.right.value??""):""}}function LZ(e){return{kind:"group",op:e.op,negate:e.negate??!1,children:e.children.map(PZ)}}function PZ(e){return e.kind==="predicate"?aBe(e):LZ(e)}function QI(e){return e?Array.isArray(e)?e.length===0?{...Vx}:{kind:"group",op:"AND",negate:!1,children:e.map(t=>({...qx,left_kind:"ref",left_ref:`this.${t.field}`,op:t.op,right_kind:"literal",right_literal:String(t.value??"")}))}:e.kind==="predicate"?{kind:"group",op:"AND",negate:!1,children:[PZ(e)]}:LZ(e):{...Vx}}function lBe(e){const t=e.op==="isempty"||e.op==="isnotempty";return{kind:"predicate",left:e.left_kind==="ref"?{kind:"ref",key:e.left_ref}:{kind:"literal",value:e.left_literal},op:e.op,right:t?void 0:e.right_kind==="ref"?{kind:"ref",key:e.right_ref}:{kind:"literal",value:e.right_literal}}}function $Z(e){return{kind:"group",op:e.op,negate:e.negate||void 0,children:e.children.map(cBe)}}function cBe(e){return e.kind==="predicate"?lBe(e):$Z(e)}function JI(e){const t={...EZ};switch(e.type){case"set_variable":{const n=e.fixed_id??"",r=e.seed_slug??"",s=n?[]:(e.filters??[]).filter(i=>!(i.field==="id"&&i.op==="eq")).map(i=>({field:i.field,op:i.op,value:String(i.value??"")}));return{...t,type:"set_variable",name:e.name,seed_slug:r,fixed_id:n,column:e.column??"",filters:s}}case"webhook":return{...t,type:"webhook",url:e.url,method:e.method??"POST",headers:Object.entries(e.headers??{}).map(([n,r])=>({key:n,value:r})),body_template:e.body_template??""};case"send_mail":return{...t,type:"send_mail",to:e.to,subject_template:e.subject_template,body_template:e.body_template};case"edit_field":return{...t,type:"edit_field",field:e.field,value:String(e.value??"")};case"create_entry":return{...t,type:"create_entry",seed_slug:e.seed_slug,field_map:Object.entries(e.field_map).map(([n,r])=>({targetAlias:n,sourceAlias:r}))}}}function uBe(e,t){const n=$Z(e.trigger_conditions),r=e.trigger_conditions.children.length>0;return{seed_slug:t,name:e.name,triggers:e.triggers.filter(s=>!!s.event).map(s=>({event:s.event,...s.event==="cron"?{cron:s.cron||null}:{}})),trigger_conditions:r?n:null,actions:e.actions.map(s=>{switch(s.type){case"set_variable":return{type:"set_variable",name:s.name,...s.seed_slug?{seed_slug:s.seed_slug}:{},...s.fixed_id?{fixed_id:s.fixed_id}:{},...s.column?{column:s.column}:{},filters:s.filters.map(i=>({field:i.field,op:i.op,value:i.value}))};case"webhook":return{type:"webhook",url:s.url,method:s.method,headers:s.headers.length>0?Object.fromEntries(s.headers.map(i=>[i.key,i.value])):void 0,body_template:s.body_template||void 0};case"send_mail":return{type:"send_mail",to:s.to,subject_template:s.subject_template,body_template:s.body_template};case"edit_field":return{type:"edit_field",field:s.field,value:s.value};case"create_entry":return{type:"create_entry",seed_slug:s.seed_slug,field_map:Object.fromEntries(s.field_map.map(i=>[i.targetAlias,i.sourceAlias]))}}})}}function dBe({seedSlug:e,seedDisplayName:t,automation:n,open:r,onSuccess:s}){const{user:i}=e1(),{t:o}=tt(),a=!!n,l=iBe(e),u=oBe(e),h=o("automations.editor.defaultName",{name:i?.name??i?.email??"Admin"}),p=oFe({resolver:sBe(cFe),mode:"onChange",defaultValues:n?{name:n.name,triggers:XI(n.triggers),trigger_conditions:QI(n.trigger_conditions),actions:n.actions.map(JI)}:{name:h,triggers:[{...Ux}],trigger_conditions:{...Vx},actions:[]}});function m(){n?p.reset({name:n.name,triggers:XI(n.triggers),trigger_conditions:QI(n.trigger_conditions),actions:n.actions.map(JI)}):p.reset({name:h,triggers:[{...Ux}],trigger_conditions:{...Vx},actions:[]})}w.useEffect(()=>{r&&m()},[n?.id,r]);const b=l.isPending||u.isPending;async function y(x){const S=uBe(x,e);a&&n?await u.mutateAsync({id:n.id,body:S}):await l.mutateAsync(S),s()}return{form:p,isEdit:a,isPending:b,resetForm:m,onSubmit:p.handleSubmit(y)}}function fBe({open:e,onOpenChange:t,seedSlug:n,seedDisplayName:r,seedBranches:s,automation:i}){const{t:o}=tt(),{form:a,isEdit:l,isPending:u,resetForm:h,onSubmit:p}=dBe({seedSlug:n,seedDisplayName:r,automation:i,open:e,onSuccess:()=>t(!1)}),{register:m,formState:{errors:b,isValid:y}}=a;return d.jsx(kf,{open:e,onOpenChange:t,children:d.jsx(Ef,{showCloseButton:!1,className:"max-w-2xl p-0 gap-0",children:d.jsx(q$e,{...a,children:d.jsxs("form",{onSubmit:p,children:[d.jsxs(Ip,{className:"px-6 pt-6 pb-4 border-b",children:[d.jsx(zp,{asChild:!0,children:d.jsx(Xt,{...m("name"),className:"text-lg font-semibold border-0 bg-secondary dark:bg-secondary px-3 py-1.5 h-auto transition-colors focus-visible:ring-1 focus-visible:ring-ring shadow-none",placeholder:o("automations.editor.namePlaceholder")})}),b.name&&d.jsx("p",{className:"text-xs text-destructive mt-1",children:o(b.name.message??"")}),d.jsx("p",{className:"text-sm text-muted-foreground",children:o("automations.editor.subtitle",{seed:r})})]}),d.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:d.jsxs("div",{className:"px-6 py-4 flex flex-col gap-0",children:[d.jsx(xFe,{seedBranches:s}),d.jsx(zZ,{}),d.jsx(eBe,{seedBranches:s,seedSlug:n})]})}),d.jsxs(Ex,{className:"px-6 py-4 border-t",children:[d.jsx(Oe,{type:"button",variant:l?"outline":"destructive",onClick:()=>{l||h(),t(!1)},children:o(l?"common.back":"common.cancel")}),d.jsx(Oe,{type:"submit",disabled:!y||u,children:o(u?"common.saving":l?"common.save":"automations.editor.enableButton")})]})]})})})})}function hBe({open:e,onOpenChange:t,seedSlug:n,seedDisplayName:r,seedBranches:s}){const{t:i}=tt(),{data:o=[],isLoading:a}=fZ(e?n:void 0),l=j$e(n),u=I$e(n),{editorOpen:h,editingAutomation:p,openNew:m,openEdit:b,closeEditor:y}=P$e();return d.jsxs(d.Fragment,{children:[d.jsx(XH,{open:e,onOpenChange:t,children:d.jsxs(QH,{side:"right",className:"w-96 p-0 flex flex-col",children:[d.jsxs(JH,{className:"pl-6 pr-12 py-4 border-b flex flex-row items-center justify-between",children:[d.jsx(eU,{children:i("automations.panel.title")}),d.jsxs(Oe,{size:"sm",onClick:m,children:[d.jsx(Hi,{className:"size-4 mr-1"}),i("automations.panel.newButton")]})]}),d.jsx(ml,{className:"flex-1",children:d.jsxs("div",{className:"px-6 py-2",children:[a&&d.jsx("div",{className:"flex flex-col gap-3 py-3",children:[1,2,3].map(x=>d.jsx(kr,{className:"h-12 w-full rounded-lg"},x))}),!a&&o.length===0&&d.jsx(L$e,{onNew:m}),!a&&o.length>0&&d.jsx("div",{children:o.map(x=>d.jsx(z$e,{automation:x,onEdit:()=>b(x),onDelete:()=>u.mutate(x.id),onToggle:S=>l.mutate({id:x.id,enabled:S}),isToggling:l.isPending&&l.variables?.id===x.id},x.id))})]})})]})}),d.jsx(fBe,{open:h,onOpenChange:x=>{x||y()},seedSlug:n,seedDisplayName:r,seedBranches:s,automation:p})]})}function FZ(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.columnId=="string"&&typeof t.label=="string"&&typeof t.type=="string"&&Array.isArray(t.conditions)}function Gx(e){return e==null?!0:typeof e=="string"?e.trim().length===0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function Ng(e){if(e==null)return null;if(typeof e=="string"){const t=e.trim();if(!t)return null;if(/^\d{4}-\d{2}-\d{2}$/.test(t))return t;const n=new Date(t);return Number.isNaN(n.getTime())?null:n.toISOString().slice(0,10)}if(typeof e=="number"){const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString().slice(0,10)}return null}function pBe(e,t,n,r){if(n==="is_empty")return Gx(e);if(n==="is_not_empty")return!Gx(e);switch(t.type){case"tags":return mBe(e,n,r);case"number":return gBe(e,n,r);case"date":return bBe(e,n,r);case"boolean":return yBe(e,n,r);case"select":return vBe(e,n,r);default:return xBe(e,n,r)}}function mBe(e,t,n){const r=DN(e);return t==="contains"||t==="eq"?typeof n!="string"||!n.trim()?!0:r.includes(n):!0}function gBe(e,t,n){let r=null;typeof e=="number"?r=e:typeof e=="string"&&e.trim()!==""&&(r=Number(e));const s=typeof n=="number"?n:null;if(r==null||s==null||Number.isNaN(r)||Number.isNaN(s))return!0;switch(t){case"eq":return r===s;case"gt":return r>s;case"gte":return r>=s;case"lt":return r<s;case"lte":return r<=s;default:return!0}}function bBe(e,t,n){const r=Ng(e),s=typeof n=="string"?Ng(n):null;if(!r||!s)return!0;switch(t){case"eq":return r===s;case"gt":return r>s;case"gte":return r>=s;case"lt":return r<s;case"lte":return r<=s;default:return!0}}function yBe(e,t,n){const r=typeof e=="boolean"?e:null,s=typeof n=="boolean"?n:null;return r==null||s==null?!0:t==="eq"?r===s:!0}function vBe(e,t,n){const r=e==null?"":String(e);if(t!=="eq"||n==null)return!0;const s=String(n);return s.trim()?r.trim().toLowerCase()===s.trim().toLowerCase():!0}function xBe(e,t,n){const r=e==null?"":String(e);if(t==="contains")return typeof n!="string"||!n.trim()?!0:r.toLowerCase().includes(n.toLowerCase());if(t==="eq"){if(n==null)return!0;const s=String(n);return s.trim()?r.trim().toLowerCase()===s.trim().toLowerCase():!0}return!0}function rC(e,t){if(!FZ(t))return!0;for(const n of t.conditions)if(!pBe(e,t,n.op,n.value))return!1;return!0}function wBe(e,t,n){const r=DN(e);return typeof n!="string"||!n.trim()||r.length===0?!1:t==="contains"||t==="eq"?r.includes(n):!1}function SBe(e,t,n){let r=null;typeof e=="number"?r=e:typeof e=="string"&&e.trim()!==""&&(r=Number(e));const s=typeof n=="number"?n:null;if(r==null||s==null||Number.isNaN(r)||Number.isNaN(s))return!1;switch(t){case"eq":return r===s;case"gt":return r>s;case"gte":return r>=s;case"lt":return r<s;case"lte":return r<=s;default:return!1}}function CBe(e,t,n){const r=Ng(e),s=typeof n=="string"?Ng(n):null;if(!r||!s)return!1;switch(t){case"eq":return r===s;case"gt":return r>s;case"gte":return r>=s;case"lt":return r<s;case"lte":return r<=s;default:return!1}}function kBe(e,t,n){const r=typeof e=="boolean"?e:null,s=typeof n=="boolean"?n:null;return r==null||s==null?!1:t==="eq"?r===s:!1}function EBe(e,t,n){const r=e==null?"":String(e);if(t!=="eq"||n==null)return!1;const s=String(n);return!s.trim()||!r.trim()?!1:r.trim().toLowerCase()===s.trim().toLowerCase()}function NBe(e,t,n){const r=e==null?"":String(e);if(t==="contains")return typeof n!="string"||!n.trim()||!r.trim()?!1:r.toLowerCase().includes(n.toLowerCase());if(t==="eq"){if(n==null)return!1;const s=String(n);return!s.trim()||!r.trim()?!1:r.trim().toLowerCase()===s.trim().toLowerCase()}return!1}function MBe(e,t,n,r){if(n==="is_empty")return Gx(e);if(n==="is_not_empty")return!Gx(e);switch(t.type){case"tags":return wBe(e,n,r);case"number":return SBe(e,n,r);case"date":return CBe(e,n,r);case"boolean":return kBe(e,n,r);case"select":return EBe(e,n,r);default:return NBe(e,n,r)}}function ez(e,t){if(!FZ(t))return!1;for(const n of t.conditions)if(!MBe(e,t,n.op,n.value))return!1;return!0}const BZ=20,HZ=60,Wx={year:!0,month:!0,day:!1};function _Be(e,t=Wx){const n=Ng(e);if(!n)return"—";const r=new Date(n+"T00:00:00");if(t.day)return r.toLocaleDateString("en-US",{day:"2-digit",month:"long",year:"numeric"});const s=[];return t.month&&s.push(r.toLocaleDateString("en-US",{month:"long"})),t.year&&s.push(String(r.getFullYear())),s.length?s.join(" "):String(r.getFullYear())}const TBe=(e,t)=>{let n=0,r=0;for(const s of t){const i=s.getValue(e);i===!0?n++:i===!1&&r++}return{trueCount:n,falseCount:r}};function ABe(e){if(e!=null&&typeof e=="object"&&"trueCount"in e&&"falseCount"in e){const{trueCount:t,falseCount:n}=e;return`✓ ${t} / ✗ ${n}`}return""}function RBe(e,t,n){return typeof e=="number"&&!Number.isNaN(e)?`Σ ${e.toLocaleString("en-US")} · ${t} ${n(t===1?"content.table.item":"content.table.items")}`:`${t} ${n(t===1?"content.table.item":"content.table.items")}`}function OBe(e){const t=e.trim().toLowerCase();if(!t)return"secondary";if(["error","failed","rejected","archived"].includes(t))return"destructive";if(["published","active","approved","online"].includes(t))return"default";let n=0;for(let r=0;r<t.length;r++){const s=t.codePointAt(r);s!=null&&(n=n*31+s>>>0,s>65535&&r++)}return n%2===0?"secondary":"outline"}function tz(e,t){let n=0;for(const r of e){const s=r.data[t];if(s==null)continue;const i=String(s).length;i>n&&(n=i)}return Math.min(Math.max(n,BZ),HZ)}function DBe(e,t){if(t.toLowerCase().includes("tag"))return null;let r=0;for(const s of e){const i=s.data[t];if(i==null)continue;let o;if(typeof i=="string")try{o=JSON.stringify(JSON.parse(i))}catch{o=i}else o=JSON.stringify(i);o.length>r&&(r=o.length)}return Math.min(Math.max(r,BZ),HZ)}function jBe(e,t){return e.type==="json"?DBe(t,e.alias):(e.type==="text",tz(t,e.alias))}function IBe(e,t,n){const r={},s=e.slice(0,n);for(const i of t.branches){const o=jBe(i,s);o!=null&&(r[i.alias]=o)}return r}function zBe(e,t,n,r,s=[],i,o=Wx,a=l=>l){const l=[{id:"select",header:({table:p})=>d.jsx(Qk,{checked:p.getIsAllPageRowsSelected()||p.getIsSomePageRowsSelected()&&"indeterminate",onCheckedChange:m=>p.toggleAllPageRowsSelected(!!m),"aria-label":a("common.selectAll")}),cell:({row:p})=>d.jsx(Qk,{checked:p.getIsSelected(),onCheckedChange:m=>p.toggleSelected(!!m),"aria-label":a("common.selectRow")}),enableSorting:!1,enableHiding:!1},{id:"id",accessorFn:p=>p.id,header:"ID",cell:({row:p})=>d.jsx("span",{className:"font-mono text-xs truncate max-w-[8rem] block",title:p.original.id,children:p.original.id}),enableSorting:!1},{id:"slug",accessorFn:p=>p.slug,header:"Slug",filterFn:(p,m,b)=>rC(p.getValue(m),b),cell:({row:p})=>{const m=p.original.slug;return d.jsx("span",{className:"text-muted-foreground text-sm",children:m??"—"})},enableSorting:!1},{id:"status",accessorFn:p=>p.status,header:a("content.table.status"),filterFn:(p,m,b)=>rC(p.getValue(m),b),cell:({row:p})=>{const m=(p.original.status??"").trim()||"—",b=OBe(m);return d.jsx(gi,{variant:b,children:m})},enableSorting:!1}],u=e.branches.map(p=>{const m={accessorFn:y=>y.data[p.alias],id:p.alias,header:()=>d.jsx("div",{className:"font-medium",children:p.label}),filterFn:(y,x,S)=>rC(y.getValue(x),S)};p.type==="date"?(m.getGroupingValue=y=>_Be(y.data[p.alias],o),m.aggregationFn="count",m.aggregatedCell=({getValue:y,row:x})=>{const S=x.subRows?.length??0,C=y();return C?d.jsxs("span",{className:"text-xs text-muted-foreground",children:[C," · ",S," ",a(S===1?"content.table.item":"content.table.items")]}):null}):p.type==="boolean"?(m.aggregationFn=TBe,m.aggregatedCell=({getValue:y})=>{const x=ABe(y());return x?d.jsx("span",{className:"text-xs text-muted-foreground",children:x}):null}):p.type==="number"?(m.aggregationFn="sum",m.aggregatedCell=({getValue:y,row:x})=>{const S=x.subRows?.length??0;return d.jsx("span",{className:"text-xs text-muted-foreground",children:RBe(y(),S,a)})}):(m.aggregationFn="count",m.aggregatedCell=({row:y})=>{const x=y.subRows?.length??0;return d.jsxs("span",{className:"text-xs text-muted-foreground",children:[x," ",a(x===1?"content.table.item":"content.table.items")]})});const b=r?.[p.alias];return{...m,cell:({row:y})=>d.jsx(rZ,{branch:p,value:y.original.data[p.alias],options:typeof b=="number"?{maxLength:b}:void 0})}}),h={id:"actions",enableHiding:!1,cell:({row:p})=>{const m=p.original,b=s.length>1;return d.jsx("div",{className:"text-right",children:d.jsxs(Li,{children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{variant:"ghost",size:"icon-xs",children:[d.jsx("span",{className:"sr-only",children:a("common.openMenu")}),d.jsx(bz,{})]})}),d.jsxs($i,{align:"end",className:"w-40",children:[d.jsx(Cs,{children:a("content.actions.label")}),b?d.jsx(cl,{onClick:()=>i?.(s),className:"text-destructive focus:text-destructive",children:a("common.delete")}):d.jsxs(d.Fragment,{children:[d.jsx(cl,{onClick:()=>{navigator.clipboard.writeText(m.id).then(()=>_n.success(a("common.copied")),()=>_n.error(a("common.copyFailed")))},children:a("content.actions.copyId")}),d.jsx(ti,{}),d.jsx(cl,{onClick:()=>{t(m.id)},children:a("common.edit")}),d.jsx(cl,{onClick:()=>n(m.id),className:"text-destructive focus:text-destructive",children:a("common.delete")})]})]})]})})}};return[...l,...u,h]}function UZ(e,t){const[n,r]=w.useState(e);return w.useEffect(()=>{const s=setTimeout(()=>r(e),t);return()=>clearTimeout(s)},[e,t]),n}function LBe(){const{slug:e}=gH(),t=pa(),{t:n}=tt(),[r,s]=w.useState(0),i=10,[o,a]=w.useState(i),[l,u]=w.useState(""),h=UZ(l,300),[p,m]=w.useState([]),[b]=j2(),y=b.get("status"),[x,S]=w.useState(()=>y?{status:{columnId:"status",label:"Status",type:"select",conditions:[{id:"status-prefilter",op:"eq",value:y}],selectOptions:["draft","published"]}}:{}),[C,N]=w.useState({}),[M,_]=w.useState(!1),[T,R]=w.useState(null),[D,j]=w.useState(!1),[L,V]=w.useState("table"),{seed:q,isLoading:X}=$W(e),[ee,re]=w.useState(null),[oe,F]=w.useState(Wx),{data:se,isLoading:le,error:W}=T$e(e,{page:r+1,limit:o,search:h.trim()||void 0,sortBy:p[0]?.id,sortDir:p[0]?.desc?"desc":"asc",filters:x}),{data:Q}=A$e(e),{mutateAsync:H}=R$e();fZ(e);const U=w.useMemo(()=>se?.items??[],[se]),Z=se?.total??0,he=le,fe=W?W.message:null;w.useEffect(()=>{s(0)},[e,h,p,x,o]),w.useEffect(()=>{if(!ee||!q)return;q.branches.find(P=>P.alias===ee)?.type!=="date"&&F(Wx)},[ee,q]);const[ye,ge]=w.useState(()=>[{id:"table",label:"table",type:"table",enabledTools:["filter","sort","automation","search","settings","create"],conditionalFormats:[]},{id:"gallery",label:"gallery",type:"gallery",enabledTools:["filter","sort","automation","search","create"],conditionalFormats:[]}]),Ee={table:n("content.list.table"),gallery:n("content.list.gallery")},Ae=w.useMemo(()=>ye.map(Re=>({...Re,label:Ee[Re.type]??Re.label})),[ye,n]),Qe=w.useMemo(()=>ye.find(Re=>Re.id===L),[L,ye]),rt=w.useCallback((Re,P)=>{ge(K=>K.map(be=>be.id===Re?{...be,conditionalFormats:P}:be))},[]),ct=w.useCallback((Re,P)=>P==="id"?Re.id:P==="slug"?Re.slug:P==="status"?Re.status:Re.data?.[P],[]),He=w.useRef(new Map);w.useEffect(()=>{He.current.clear()},[e,U]);const _e=w.useCallback((Re,P,K)=>{const be=ct(Re,P);if(K!=="tags")return be;const Pe=`${Re.id}::${P}`;if(He.current.has(Pe))return He.current.get(Pe);let pt=be;if(typeof be=="string")try{pt=JSON.parse(be)}catch{pt=null}return He.current.set(Pe,pt),pt},[ct]),nn=w.useMemo(()=>(Qe?.conditionalFormats??[]).filter(P=>!!P?.enabled).slice().sort((P,K)=>(P.priority??0)-(K.priority??0)),[Qe?.conditionalFormats]),xt=w.useMemo(()=>nn.filter(Re=>{const P=Re.target;return P==="row"||P==="cell+row"}),[nn]),Jt=w.useMemo(()=>{const Re=new Map;for(const P of nn){if(P.target==="row")continue;const be=Re.get(P.columnId)??[];be.push(P),Re.set(P.columnId,be)}return Re},[nn]),fn=w.useCallback(Re=>{let P;const K={};for(const be of xt){const Pe=_e(Re,be.columnId,be.group.type);if(ez(Pe,be.group)){P=cZ(be.tone,be.textStyles??[]);break}}for(const[be,Pe]of Jt.entries())for(const pt of Pe){const st=_e(Re,pt.columnId,pt.group.type);if(ez(st,pt.group)){K[be]=uZ(pt.tone,pt.textStyles??[]);break}}return{rowClassName:P,cellClassNameByColumnId:K}},[Jt,_e,xt]),hn=w.useCallback(Re=>{e&&t(`/content/${e}/${Re}`)},[e,t]),zn=w.useCallback(Re=>{R([Re]),_(!0)},[]),lr=w.useCallback(Re=>{const P=Array.from(new Set(Re)).filter(Boolean);P.length&&(R(P),_(!0))},[]),In=w.useCallback(()=>{e&&t(`/content/${e}/create`)},[e,t]),Fn=w.useCallback(async()=>{if(!e||!T||T.length===0)return;const P=(await Promise.allSettled(T.map(K=>H({slug:e,id:K})))).filter(K=>K.status==="rejected").length;if(P>0)throw new Error(`Partial deletion: ${P} out of ${T.length} failed`);N({})},[e,T,H]),G=w.useMemo(()=>Object.keys(C).filter(Re=>C[Re]),[C]),pe=w.useMemo(()=>Z<=0?1:Math.max(1,Math.ceil(Z/o)),[o,Z]),[ue,Fe]=w.useState(()=>{const Re={};if(Re.id=!1,Re.slug=!1,!q)return Re;const P=q.branches.filter(K=>K.type==="json"&&(K.alias.toLowerCase().includes("metadata")||K.alias.toLowerCase().includes("metadati"))).map(K=>K.alias);for(const K of P)Re[K]=!1;return Re}),$e=w.useMemo(()=>{if(!(!q||U.length===0))return IBe(U,q,o)},[q,U,o]),ze=w.useMemo(()=>q?zBe(q,hn,zn,$e,G,lr,oe,n):[],[q,hn,zn,$e,G,lr,oe,n]),qe=p[0],Rt=w.useMemo(()=>{const Re=new Set;for(const P of U){const K=typeof P.status=="string"?P.status.trim():"";K&&Re.add(K)}return Array.from(Re).sort((P,K)=>P.localeCompare(K,"it"))},[U]),Ot=w.useMemo(()=>{if(!q)return{};const Re=q.branches.filter(K=>K.type==="json"&&K.alias.toLowerCase().includes("tag"));if(Re.length===0)return{};const P={};for(const K of Re){const be=new Set(K.options??[]);for(const Pe of U)for(const pt of DN(Pe.data[K.alias]))be.add(pt);P[K.alias]=Array.from(be).sort((Pe,pt)=>Pe.localeCompare(pt,"it"))}return P},[U,q]),xn=w.useMemo(()=>{const Re=new Set([...Object.keys(Ot),...Object.keys(Q?.tagsByColumnId??{})]),P={};for(const K of Re){const be=new Set([...Ot[K]??[],...Q?.tagsByColumnId?.[K]??[]]);P[K]=Array.from(be).sort((Pe,pt)=>Pe.localeCompare(pt,"it"))}return P},[Ot,Q?.tagsByColumnId]),gn=w.useMemo(()=>Q?.statuses&&Q.statuses.length>0?Q.statuses:Rt,[Q?.statuses,Rt]),en=w.useMemo(()=>ee?[ee]:[],[ee]),Lt=w.useMemo(()=>!q||!ee?!1:q.branches.find(P=>P.alias===ee)?.type==="date",[ee,q]),ls=w.useMemo(()=>{if(Lt&&ee){let Re;return oe.day?Re="day":oe.year&&!oe.month?Re="year":Re="monthYear",`group:${ee}:date:${Re}`}return`group:${ee??"none"}`},[oe.day,oe.month,oe.year,ee,Lt]),Sr=w.useMemo(()=>{const Re=[],P=st=>typeof st=="string"&&st.trim().length>0,K=st=>typeof st=="number"&&!Number.isNaN(st),be=(st,Ve)=>{switch(st){case"boolean":return Ve===!0||Ve===!1;case"number":return K(Ve);default:return P(Ve)}},Pe=(st,Ve)=>{switch(st){case"number":return K(Ve);case"date":return P(Ve);default:return!1}},pt=(st,Ve)=>{switch(Ve.op){case"is_empty":case"is_not_empty":return!0;case"contains":return P(Ve.value);case"eq":return be(st.type,Ve.value);case"gt":case"gte":case"lt":case"lte":return Pe(st.type,Ve.value);default:return!1}};for(const[st,Ve]of Object.entries(x))Ve.conditions.some(bt=>pt(Ve,bt))&&Re.push({id:st,value:Ve});return Re},[x]),yt=w.useCallback(Re=>{if(!Re.length){m([]);return}const[P]=Re;m([{id:P.id,desc:P.desc??!1}])},[]),Bt=w.useCallback(Re=>{if(!Re.columnId){m([]);return}m([{id:Re.columnId,desc:Re.desc}])},[]),gt=w.useCallback((Re,P)=>{ge(K=>K.map(be=>be.id===Re?{...be,label:P}:be))},[]),Pt=w.useMemo(()=>{const Re=["id","slug"];if(!q)return Re;const P=q.branches.filter(K=>K.type==="json"&&(K.alias.toLowerCase().includes("metadata")||K.alias.toLowerCase().includes("metadati"))).map(K=>K.alias);return[...Re,...P]},[q]);return!q&&!X?d.jsx("div",{className:"[--header-height:calc(--spacing(14))]",children:d.jsxs(Ru,{className:"flex flex-col",children:[d.jsx(Pu,{}),d.jsxs("div",{className:"flex flex-1",children:[d.jsx(Lu,{}),d.jsx(Ou,{children:d.jsx("div",{className:"flex flex-1 flex-col gap-4 p-4",children:d.jsx("div",{className:"content-area-inner",children:d.jsxs("div",{className:"rounded-lg border border-destructive bg-destructive/10 p-4",children:[d.jsx("h2",{className:"text-lg font-semibold text-destructive",children:"Error"}),d.jsx("p",{className:"text-sm text-destructive/90",children:fe||`Seed "${e}" not found`})]})})})})]})]})}):X||!q?d.jsx("div",{className:"[--header-height:calc(--spacing(14))]",children:d.jsxs(Ru,{className:"flex flex-col",children:[d.jsx(Pu,{}),d.jsxs("div",{className:"flex flex-1",children:[d.jsx(Lu,{}),d.jsx(Ou,{children:d.jsx("div",{className:"flex flex-1 items-center justify-center py-12",children:d.jsx("div",{className:"text-muted-foreground",children:"Loading configuration..."})})})]})]})}):d.jsxs("div",{className:"[--header-height:calc(--spacing(14))] overflow-x-clip",children:[d.jsxs(Ru,{className:"flex flex-col",children:[d.jsx(Pu,{}),d.jsxs("div",{className:"flex flex-1",children:[d.jsx(Lu,{}),d.jsx(Ou,{className:"min-w-0",children:d.jsx("div",{className:"flex flex-1 flex-col gap-4 p-4 min-w-0",children:d.jsxs("div",{className:"content-area-inner",children:[d.jsxs("div",{className:"mb-6",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:q.labelPlural??q.label}),d.jsxs("p",{className:"text-muted-foreground text-sm",children:['Manage "',q.slug,'" content']})]}),d.jsxs(_$e,{seed:q,views:Ae,activeViewId:L,onChangeView:V,onRenameView:gt,onConditionalFormatsChange:rt,onCreate:In,searchValue:l,onSearchChange:u,sortState:{columnId:qe?.id??null,desc:qe?.desc??!0},onSortChange:Bt,filters:x,onFiltersChange:S,availableTagsByColumnId:xn,availableStatusOptions:gn,pageSize:o,onPageSizeChange:Re=>{a(Re),s(0)},columnVisibility:ue,onColumnVisibilityChange:Fe,groupBy:ee,onGroupByChange:re,dateGroupPrecision:oe,onDateGroupPrecisionChange:F,onOpenAutomation:()=>j(!0),isAutomationActive:D,children:[fe&&d.jsx("div",{className:"rounded-lg border border-destructive bg-destructive/10 p-4",children:d.jsx("p",{className:"text-sm text-destructive",children:fe})}),he&&!fe&&L==="table"&&d.jsx("div",{className:"flex items-center justify-center py-12",children:d.jsx("div",{className:"text-muted-foreground",children:"Loading..."})}),!he&&!fe&&L==="table"&&d.jsx(AMe,{columns:ze,data:U,initialHiddenColumns:Pt,getRowStyles:fn,rowSelection:C,onRowSelectionChange:N,onRowDoubleClick:Re=>hn(Re.id),grouping:en,onGroupingChange:Re=>re(Re[0]??null),renderRowContextMenuContent:Re=>d.jsxs(d.Fragment,{children:[d.jsx(t8e,{children:"Actions"}),G.length>1?d.jsx(Gd,{onSelect:()=>lr(G),className:"text-destructive focus:text-destructive",children:"Delete"}):d.jsxs(d.Fragment,{children:[d.jsx(Gd,{onSelect:()=>{navigator.clipboard.writeText(Re.id).then(()=>_n.success("ID copied"),()=>_n.error("Copy failed"))},children:"Copy ID"}),d.jsx(UW,{}),d.jsx(Gd,{onSelect:()=>hn(Re.id),children:"Edit"}),d.jsx(Gd,{onSelect:()=>zn(Re.id),className:"text-destructive focus:text-destructive",children:"Delete"})]})]}),pageSize:o,onPageSizeChange:Re=>{a(Re),s(0)},pageIndex:r,onPageIndexChange:s,pageCount:pe,totalRows:Z,manualPagination:!0,manualSorting:!0,manualFiltering:!0,columnVisibility:ue,onColumnVisibilityChange:Fe,globalFilter:l,onGlobalFilterChange:u,sorting:p,onSortingChange:yt,columnFilters:Sr},ls),!fe&&L==="gallery"&&d.jsx(t$e,{seed:q,data:U,isLoading:he,onEdit:hn})]})]})})})]})]}),d.jsx(IMe,{open:M,onOpenChange:_,seed:q,entryIds:T,onConfirm:Fn}),d.jsx(hBe,{open:D,onOpenChange:j,seedSlug:q.slug,seedDisplayName:q.label,seedBranches:q.branches})]})}function PBe(e){return PW(e)}function nz(e){return e.alias.startsWith("meta")}function $Be(){return{type:"doc",content:[{type:"paragraph"}]}}function FBe(e){const t={};for(const n of e)n.type==="boolean"?t[n.alias]=!1:n.type==="richtext"?t[n.alias]=$Be():t[n.alias]="";return t}function BBe(e){return typeof e=="string"?e:e!=null?String(e):""}function HBe({branches:e,formData:t,slug:n,status:r}){const s={};for(const i of e){const o=t[i.alias];if(i.type==="json"&&o)if(typeof o=="string")try{s[i.alias]=JSON.parse(o)}catch{s[i.alias]=o}else s[i.alias]=o;else s[i.alias]=o}return{slug:n.trim()||null,status:r.trim()||"draft",...s}}function UBe(e,t){for(const n of e){if(n.type!=="json")continue;const r=t[n.alias];if(!(!r||typeof r!="string"))try{JSON.parse(r)}catch{return{isValid:!1,errorFieldLabel:n.label}}}return{isValid:!0}}function Ry({children:e}){return d.jsx("div",{className:"[--header-height:calc(--spacing(14))]",children:d.jsxs(Ru,{className:"flex flex-col",children:[d.jsx(Pu,{}),d.jsxs("div",{className:"flex flex-1",children:[d.jsx(Lu,{}),d.jsx(Ou,{className:"min-w-0",children:d.jsx("div",{className:"flex flex-1 flex-col gap-4 p-4",children:e})})]})]})})}function VZ({status:e,onStatusChange:t,slug:n,onSlugChange:r,isGrid:s=!1}){const{t:i}=tt(),o=d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(Es,{htmlFor:"entry-status",children:i("content.editor.status")}),d.jsxs(Rr,{value:e,onValueChange:t,children:[d.jsx(Or,{id:"entry-status",className:"w-full",children:d.jsx(Gr,{placeholder:i("content.editor.status")})}),d.jsxs(Dr,{children:[d.jsx(or,{value:"draft",children:i("content.editor.draft")}),d.jsx(or,{value:"published",children:i("content.editor.published")})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Es,{htmlFor:"entry-slug",children:i("content.editor.slug")}),d.jsx(Xt,{id:"entry-slug",value:n,onChange:a=>r(a.target.value),maxLength:15,placeholder:i("content.editor.slugPlaceholder"),className:"font-mono text-sm"})]})]});return s?d.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:o}):d.jsx(d.Fragment,{children:o})}function Kx({branches:e,formData:t,fieldErrors:n,onInputChange:r}){return d.jsx(d.Fragment,{children:e.map(s=>d.jsxs("div",{className:"space-y-2",children:[d.jsx(Es,{htmlFor:s.alias,children:s.label}),d.jsx(d8,{branch:s,value:t[s.alias],onChange:i=>r(s.alias,i)}),n[s.alias]&&d.jsx("p",{className:"text-xs text-destructive",children:n[s.alias]})]},s.alias))})}function VBe({richtextBranch:e,seoBranches:t,contentBranches:n,formData:r,fieldErrors:s,status:i,slug:o,onInputChange:a,onStatusChange:l,onSlugChange:u}){const{t:h}=tt();return d.jsxs("div",{className:"grid flex-1 gap-6 md:grid-cols-[1fr_320px] lg:grid-cols-[1fr_360px] xl:grid-cols-[1fr_400px] md:min-h-0",children:[d.jsxs("div",{className:"min-h-[70vh] flex flex-col rounded-lg border-0",children:[d.jsx(d8,{branch:e,value:r[e.alias],onChange:p=>a(e.alias,p)}),s[e.alias]&&d.jsx("p",{className:"text-xs text-destructive mt-1",children:s[e.alias]})]}),d.jsxs("aside",{className:"flex flex-col gap-4 md:sticky md:top-[calc(var(--header-height)+1rem)] md:self-start",children:[d.jsxs(Zn,{children:[d.jsx(Tr,{children:d.jsx(Wr,{children:h("content.editor.metadataSeo")})}),d.jsxs(Xn,{className:"space-y-4",children:[d.jsx(VZ,{status:i,onStatusChange:l,slug:o,onSlugChange:u}),d.jsx(Kx,{branches:t,formData:r,fieldErrors:s,onInputChange:a})]})]}),d.jsxs(Zn,{children:[d.jsx(Tr,{children:d.jsx(Wr,{children:h("content.editor.content")})}),d.jsx(Xn,{className:"space-y-4",children:d.jsx(Kx,{branches:n,formData:r,fieldErrors:s,onInputChange:a})})]})]})]})}function qBe({seoBranches:e,contentBranches:t,formData:n,fieldErrors:r,status:s,slug:i,onInputChange:o,onStatusChange:a,onSlugChange:l}){const{t:u}=tt();return d.jsxs("div",{className:"mx-auto w-full max-w-2xl lg:max-w-3xl xl:max-w-4xl space-y-6",children:[d.jsxs(Zn,{children:[d.jsx(Tr,{children:d.jsx(Wr,{children:u("content.editor.publication")})}),d.jsx(Xn,{className:"space-y-4",children:d.jsx(VZ,{status:s,onStatusChange:a,slug:i,onSlugChange:l,isGrid:!0})})]}),e.length>0&&d.jsxs(Zn,{children:[d.jsx(Tr,{children:d.jsx(Wr,{children:u("content.editor.metadataSeo")})}),d.jsx(Xn,{className:"space-y-4",children:d.jsx(Kx,{branches:e,formData:n,fieldErrors:r,onInputChange:o})})]}),d.jsxs(Zn,{children:[d.jsx(Tr,{children:d.jsx(Wr,{children:u("content.editor.content")})}),d.jsx(Xn,{className:"space-y-4",children:d.jsx(Kx,{branches:t,formData:n,fieldErrors:r,onInputChange:o})})]})]})}function rz(){const{t:e}=tt(),{slug:t,id:n}=gH(),r=pa(),s=!n,{seed:i,isLoading:o}=$W(t),{data:a,isLoading:l,error:u}=O$e(t,n),{mutateAsync:h,isPending:p}=D$e(),[m,b]=w.useState({}),[y,x]=w.useState("draft"),[S,C]=w.useState(""),[N,M]=w.useState(!1),[_,T]=w.useState(!1),[R,D]=w.useState({}),j=w.useRef(!1),L=B0e(()=>_&&!j.current),V=w.useMemo(()=>i?.branches??[],[i]),q=w.useCallback((ye,ge)=>{b(Ee=>({...Ee,[ye]:ge})),T(!0)},[]),X=w.useCallback(ye=>{x(ye),T(!0)},[]),ee=w.useCallback(ye=>{C(PW(ye)),M(!0),T(!0)},[]);w.useEffect(()=>{a&&(b(a.data??{}),x(a.status??"draft"),C(a.slug??""),T(!1))},[a]);const re=u instanceof Error?u.message:null;w.useEffect(()=>{!i||!s||(b(FBe(V)),x("draft"),C(""),M(!1))},[i,s,V]);const oe=w.useMemo(()=>V.find(ye=>ye.type==="text")?.alias,[V]),F=oe?m[oe]:void 0;w.useEffect(()=>{if(!s||N||oe==null)return;const ye=BBe(F);C(PBe(ye))},[s,N,oe,F]);const se=w.useMemo(()=>V.find(ye=>ye.type==="richtext"),[V]),le=!!se,W=w.useMemo(()=>V.filter(ye=>ye.alias!==se?.alias&&nz(ye)),[V,se]),Q=w.useMemo(()=>V.filter(ye=>ye.alias!==se?.alias&&!nz(ye)),[V,se]),H=async(ye,ge,Ee)=>{await h({slug:ye,id:Ee??void 0,data:ge}),Ee?_n.success(e("content.editor.savedSuccess")):_n.success(e("content.editor.createdSuccess"))},U=async ye=>{if(ye.preventDefault(),!t||!i||!s&&!n)return;const ge=UBe(V,m);if(!ge.isValid){_n.error(e("content.editor.jsonError",{field:ge.errorFieldLabel}));return}D({});try{const Ee=HBe({branches:V,formData:m,slug:S,status:y});await H(t,Ee,s?null:n),T(!1),j.current=!0,r(`/content/${t}`)}catch(Ee){const Ae=Ee;if(Ae.response?.status===409){_n.error(e("content.editor.slugDuplicate"));return}if(Ae.response?.status===400){const Qe=Ae.response.data?.errors;if(Qe&&Qe.length>0){const rt={};Qe.forEach(ct=>{rt[ct.field]=ct.message}),D(rt),_n.error(e("content.editor.validationError",{count:Qe.length}));return}}_n.error(Ee instanceof Error?Ee.message:e("content.editor.saveError"))}},Z=()=>r(t?`/content/${t}`:"/");if(!t)return d.jsx("div",{className:"flex min-h-svh items-center justify-center p-4",children:d.jsx("p",{className:"text-destructive",children:e("content.editor.slugMissing")})});if(!i&&!o)return d.jsx(Ry,{children:d.jsxs("div",{className:"rounded-lg border border-destructive bg-destructive/10 p-4",children:[d.jsx("p",{className:"text-destructive",children:e("content.editor.seedNotFound",{slug:t})}),d.jsx(Oe,{variant:"outline",className:"mt-2",onClick:Z,children:e("content.editor.back")})]})});if(o||!i||n&&l)return d.jsxs(Ry,{children:[d.jsx(kr,{className:"h-10 w-48"}),d.jsxs("div",{className:"grid flex-1 gap-4 md:grid-cols-[1fr_320px] lg:grid-cols-[1fr_360px] xl:grid-cols-[1fr_400px]",children:[d.jsx(kr,{className:"min-h-[70vh] rounded-lg"}),d.jsx(kr,{className:"h-64 rounded-lg"})]})]});if(n&&re)return d.jsx(Ry,{children:d.jsxs("div",{className:"rounded-lg border border-destructive bg-destructive/10 p-4",children:[d.jsx("p",{className:"text-destructive",children:re}),d.jsx(Oe,{variant:"outline",className:"mt-2",onClick:Z,children:"Back"})]})});const he=s?e("content.editor.newEntry",{label:i.label}):e("content.editor.editEntry",{label:i.label}),fe=p?d.jsxs(d.Fragment,{children:[d.jsx(ta,{className:"mr-2 size-4 animate-spin"}),e("content.editor.saving")]}):e("content.editor.save");return d.jsxs(Ry,{children:[d.jsxs("form",{className:"content-area-inner flex flex-1 flex-col",onSubmit:U,children:[d.jsxs("div",{className:"mb-4 flex items-center justify-between gap-4",children:[d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",onClick:Z,children:[d.jsx(EJ,{className:"mr-1 size-4"}),e("content.editor.back")]}),d.jsx("h1",{className:"text-xl font-semibold truncate pb-1",children:he}),d.jsx(Oe,{type:"submit",disabled:p,children:fe})]}),le?d.jsx(VBe,{richtextBranch:se,seoBranches:W,contentBranches:Q,formData:m,fieldErrors:R,status:y,slug:S,onInputChange:q,onStatusChange:X,onSlugChange:ee}):d.jsx(qBe,{seoBranches:W,contentBranches:Q,formData:m,fieldErrors:R,status:y,slug:S,onInputChange:q,onStatusChange:X,onSlugChange:ee})]}),d.jsx(sU,{open:L.state==="blocked",children:d.jsxs(iU,{children:[d.jsxs(oU,{children:[d.jsx(lU,{children:e("content.editor.unsavedTitle")}),d.jsx(cU,{children:e("content.editor.unsavedDesc")})]}),d.jsxs(aU,{children:[d.jsx(dU,{onClick:()=>L.reset?.(),children:e("content.editor.stay")}),d.jsx(uU,{variant:"destructive",onClick:()=>L.proceed?.(),children:e("content.editor.exitWithout")})]})]})})]})}const GBe={alias:"body",label:"Corpo del testo",type:"richtext"};function WBe(){const[e,t]=w.useState("<h2>Titolo di esempio</h2><p>Scrivi qui il tuo contenuto <strong>ricco</strong>.</p><ul><li>Primo punto</li><li>Secondo punto</li></ul>");return d.jsx("div",{className:"[--header-height:calc(--spacing(14))]",children:d.jsxs(Ru,{className:"flex flex-col",children:[d.jsx(Pu,{}),d.jsxs("div",{className:"flex flex-1",children:[d.jsx(Lu,{}),d.jsx(Ou,{children:d.jsxs("div",{className:"mx-auto w-full max-w-screen-2xl p-6 space-y-8",children:[d.jsxs("div",{children:[d.jsx("h1",{className:"text-2xl font-semibold",children:"Field Playground"}),d.jsxs("p",{className:"text-muted-foreground text-sm mt-1",children:["Pagina di test per il campo ",d.jsx("code",{className:"font-mono bg-muted px-1 py-0.5 rounded text-xs",children:"richtext"})]})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h2",{className:"text-base font-medium",children:["Edit — ",d.jsx("span",{className:"text-muted-foreground font-normal",children:'FieldEdit type="richtext"'})]}),d.jsx("div",{className:"max-w-2xl",children:d.jsx(d8,{branch:GBe,value:e,onChange:n=>t(n)})})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h2",{className:"text-base font-medium",children:["Preview — ",d.jsx("span",{className:"text-muted-foreground font-normal",children:"HTML compilato con stili applicati"})]}),d.jsx("div",{className:"richtext-content rounded-md border border-input bg-background px-4 py-3 max-w-2xl",dangerouslySetInnerHTML:{__html:e}})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsx("h2",{className:"text-base font-medium",children:"Output HTML grezzo"}),d.jsx("pre",{className:"rounded-md border border-input bg-muted/30 px-4 py-3 text-xs font-mono whitespace-pre-wrap break-all max-w-2xl max-h-48 overflow-auto",children:e})]})]})})]})]})})}const a0={getTotalStats:async()=>{const{data:e}=await Gt.get("/content/stats/total");return e},getCloudflareStats:async()=>{const{data:e}=await Gt.get("/content/stats/cloudflare");return e},getRecentActivity:async e=>{const{data:t}=await Gt.get("/content/stats/recent-activity",{params:{slug:e}});return t},getSystemHealth:async()=>{const{data:e}=await Gt.get("/content/stats/health");return e},getContentBreakdown:async()=>{const{data:e}=await Gt.get("/content/stats/breakdown");return e},getSetupChecklist:async()=>{const{data:e}=await Gt.get("/content/stats/setup-checklist");return e}};function E8(){return Ir({queryKey:si.stats(),queryFn:a0.getTotalStats,staleTime:300*1e3})}function N8(){return Ir({queryKey:si.cloudflare(),queryFn:a0.getCloudflareStats,staleTime:300*1e3})}function qZ(e){return Ir({queryKey:[...si.activity(),e],queryFn:()=>a0.getRecentActivity(e),refetchInterval:60*1e3,staleTime:60*1e3})}function GZ(){return Ir({queryKey:si.health(),queryFn:a0.getSystemHealth,staleTime:300*1e3})}function KBe(){return Ir({queryKey:si.breakdown(),queryFn:a0.getContentBreakdown,staleTime:300*1e3})}function YBe(){return Ir({queryKey:si.setupChecklist(),queryFn:a0.getSetupChecklist,staleTime:30*1e3,refetchInterval:60*1e3})}class ZBe extends w.Component{state={hasError:!1};static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error(`[BeechCMS] Widget "${this.props.widgetId}" crashed:`,t,n)}render(){return this.state.hasError?d.jsxs("div",{className:"flex h-full min-h-[80px] flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-rose-300/40 bg-rose-500/5 p-4 text-center",children:[d.jsx(P6,{className:"h-5 w-5 text-rose-400"}),d.jsx("p",{className:"text-xs font-medium text-rose-400",children:"Widget non disponibile"}),d.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["ID: ",d.jsx("span",{className:"font-mono",children:this.props.widgetId})]})]}):this.props.children}}const XBe={it:l1,en:Oi};function QBe(){const{data:e=[],isLoading:t}=qZ(),{t:n,i18n:r}=tt(),s=XBe[r.language]??l1;return d.jsxs(Zn,{className:"col-span-2 border-none bg-background/50 backdrop-blur-sm",children:[d.jsx(Tr,{children:d.jsx(Wr,{className:"text-lg font-semibold",children:n("dashboard.recentActivity.title")})}),d.jsx(Xn,{children:d.jsxs("div",{className:"space-y-8",children:[t?d.jsx("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:d.jsx("p",{className:"text-sm text-muted-foreground",children:n("dashboard.recentActivity.loading")})}):e.map(i=>d.jsxs("div",{className:"flex items-center gap-4",children:[d.jsx(mf,{className:"h-9 w-9 border border-primary/10",children:d.jsx(gf,{className:"bg-primary/5 text-primary text-xs",children:(i.user_name||i.user_email).slice(0,2).toUpperCase()})}),d.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[d.jsxs("p",{className:"text-sm leading-none text-muted-foreground",children:[d.jsx("span",{className:"font-bold text-foreground",children:i.user_name||i.user_email})," ",n(`dashboard.recentActivity.actions.${i.action}`,{defaultValue:i.action})," ",d.jsx("span",{className:"font-semibold text-primary",children:i.details?.title||i.details?.name||i.entity_slug||i.entity_id})]}),d.jsx("p",{className:"text-xs text-muted-foreground/70",children:Eg(new Date(i.created_at*1e3),{addSuffix:!0,locale:s})})]})]},i.id)),!t&&e.length===0&&d.jsx("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:d.jsx("p",{className:"text-sm text-muted-foreground",children:n("dashboard.recentActivity.empty")})})]})})]})}function JBe(){const{data:e,isLoading:t}=GZ();if(t||!e)return d.jsxs(Zn,{className:"overflow-hidden border-none bg-white/50 backdrop-blur-xl dark:bg-neutral-900/50",children:[d.jsx(Tr,{children:d.jsx(Wr,{className:"text-sm font-medium",children:"System Health"})}),d.jsx(Xn,{children:d.jsx("div",{className:"h-[120px] w-full animate-pulse rounded-lg bg-neutral-200 dark:bg-neutral-800"})})]});const n=e.status==="warning";return d.jsxs(Zn,{className:"overflow-hidden border-none bg-white/50 backdrop-blur-xl dark:bg-neutral-900/50 shadow-sm transition-all hover:shadow-md",children:[d.jsxs(Tr,{className:"flex flex-row items-center justify-between pb-2 space-y-0",children:[d.jsxs(Wr,{className:"text-sm font-medium flex items-center gap-2",children:[n?d.jsx(Nne,{className:"size-4 text-amber-500"}):d.jsx(_ne,{className:"size-4 text-emerald-500"}),"System Health"]}),d.jsx("div",{className:ie("px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider",n?"bg-amber-100 text-amber-700 dark:bg-amber-500/10 dark:text-amber-400":"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400"),children:e.status})]}),d.jsxs(Xn,{className:"space-y-6",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between text-xs",children:[d.jsxs("div",{className:"flex items-center gap-2 text-neutral-500 dark:text-neutral-400",children:[d.jsx(O6,{className:"size-3"}),d.jsx("span",{children:"D1 Monthly Requests"})]}),d.jsxs("span",{className:"font-medium text-neutral-900 dark:text-neutral-100",children:[e.database.requests30d.toLocaleString()," / ",(e.database.limit/1e6).toFixed(0),"M"]})]}),d.jsx(Sp,{value:e.database.percentage,className:"h-1.5",indicatorClassName:ie(e.database.percentage>80?"bg-amber-500":"bg-emerald-500")})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between text-xs",children:[d.jsxs("div",{className:"flex items-center gap-2 text-neutral-500 dark:text-neutral-400",children:[d.jsx(Mee,{className:"size-3"}),d.jsx("span",{children:"R2 Storage Used"})]}),d.jsxs("span",{className:"font-medium text-neutral-900 dark:text-neutral-100",children:[(e.storage.used/(1024*1024)).toFixed(1)," MB / ",(e.storage.limit/(1024*1024*1024)).toFixed(0)," GB"]})]}),d.jsx(Sp,{value:e.storage.percentage,className:"h-1.5",indicatorClassName:ie(e.storage.percentage>80?"bg-amber-500":"bg-emerald-500")})]}),d.jsxs("p",{className:"text-[10px] text-neutral-400 dark:text-neutral-500 pt-2 border-t border-neutral-100 dark:border-neutral-800",children:["Last check: ",new Date(e.lastUpdate*1e3).toLocaleTimeString()]})]})]})}function eHe(){const{t:e}=tt(),{data:t=[],isLoading:n}=KBe();if(n)return d.jsxs(Zn,{className:"overflow-hidden border-none bg-white/50 backdrop-blur-xl dark:bg-neutral-900/50",children:[d.jsx(Tr,{children:d.jsx(Wr,{className:"text-sm font-medium",children:"Content Pulse"})}),d.jsx(Xn,{children:d.jsx("div",{className:"space-y-4",children:[1,2,3].map(i=>d.jsx("div",{className:"h-10 w-full animate-pulse rounded-lg bg-neutral-200 dark:bg-neutral-800"},i))})})]});const r=[...t].sort((i,o)=>o.count-i.count),s=r.reduce((i,o)=>i+o.count,0);return d.jsxs(Zn,{className:"overflow-hidden border-none bg-white/50 backdrop-blur-xl dark:bg-neutral-900/50 shadow-sm transition-all hover:shadow-md",children:[d.jsxs(Tr,{className:"flex flex-row items-center justify-between pb-4 space-y-0",children:[d.jsxs(Wr,{className:"text-sm font-medium flex items-center gap-2",children:[d.jsx(ic,{className:"size-4 text-emerald-500"}),"Content Pulse"]}),d.jsx(rv,{className:"size-4 text-neutral-400"})]}),d.jsxs(Xn,{className:"",children:[d.jsx(ml,{className:"h-[260px] pr-4",children:d.jsx("div",{className:"space-y-5",children:r.length===0?d.jsx("p",{className:"text-xs text-neutral-500 text-center py-4",children:e("dashboard.contentPulse.noContent")}):r.map(i=>{const o=s>0?i.count/s*100:0;return d.jsxs("div",{className:"group space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between text-xs",children:[d.jsx(Ns,{to:`/content/${i.slug}`,className:"font-medium text-neutral-700 dark:text-neutral-300 hover:text-emerald-600 dark:hover:text-emerald-400 transition-colors",children:i.label}),d.jsxs("span",{className:"text-neutral-500 tabular-nums",children:[i.count," entries"]})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(Sp,{value:o,className:"h-1.5 flex-1",indicatorClassName:"bg-emerald-500/80 dark:bg-emerald-400/80"}),d.jsxs("span",{className:"text-[10px] text-neutral-400 w-8 text-right font-mono",children:[Math.round(o),"%"]})]})]},i.slug)})})}),d.jsxs("div",{className:"mt-6 pt-4 border-t border-neutral-100 dark:border-neutral-800 flex justify-between items-center",children:[d.jsx("span",{className:"text-[10px] text-neutral-400 uppercase tracking-tighter font-bold",children:e("dashboard.contentPulse.totalDistribution")}),d.jsxs("span",{className:"text-[10px] font-mono font-bold text-neutral-500",children:[s," items"]})]})]})]})}function tHe(){return d.jsxs(Zn,{className:"relative overflow-hidden border-none bg-primary/5 text-primary-foreground",children:[d.jsx("div",{className:"absolute -right-8 -top-8 h-32 w-32 rounded-full bg-primary/20 blur-3xl"}),d.jsx(Tr,{className:"relative flex flex-row items-center justify-between pb-2 text-foreground",children:d.jsxs(Wr,{className:"flex items-center gap-2 text-lg font-semibold",children:[d.jsx(Ine,{className:"h-5 w-5 text-primary"}),"Beech AI Insights"]})}),d.jsxs(Xn,{className:"relative space-y-4 text-foreground",children:[d.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Ho notato che hai creato molti contenuti nella categoria ",d.jsx("span",{className:"font-semibold text-foreground",children:'"Blog"'})," ma pochi hanno una meta description ottimizzata per la SEO."]}),d.jsxs("div",{className:"rounded-xl bg-background/50 p-3 text-sm",children:[d.jsx("p",{className:"font-medium",children:"Suggerimento:"}),d.jsx("p",{className:"text-muted-foreground",children:"Posso generare automaticamente delle descrizioni SEO per i tuoi ultimi 5 articoli."})]}),d.jsxs("button",{className:"group flex items-center gap-1 text-sm font-semibold text-primary transition-all hover:gap-2",children:["Ottimizza ora",d.jsx(MJ,{className:"h-4 w-4"})]})]})]})}function nHe({onAction:e}){const t=[{id:"new-entry",label:"Nuovo Contenuto",icon:gee,color:"text-emerald-500"},{id:"media",label:"Carica Media",icon:Tg,color:"text-blue-500"},{id:"collections",label:"Gestisci Collezioni",icon:rv,color:"text-amber-500"},{id:"settings",label:"Configurazione",icon:Ag,color:"text-slate-500"}];return d.jsxs(Zn,{className:"border-none bg-background/50 backdrop-blur-sm",children:[d.jsx(Tr,{children:d.jsx(Wr,{className:"text-lg font-semibold",children:"Azioni Rapide"})}),d.jsx(Xn,{className:"grid grid-cols-2 gap-4",children:t.map(n=>d.jsxs(Oe,{variant:"outline",className:"flex h-24 flex-col items-center justify-center gap-2 border-none bg-background/40 transition-all hover:bg-background/80 hover:scale-105",onClick:()=>e(n.id),children:[d.jsx(n.icon,{className:`h-6 w-6 ${n.color}`}),d.jsx("span",{className:"text-xs font-medium",children:n.label})]},n.id))})]})}const rHe={emerald:{icon:"from-emerald-500/20 to-emerald-400/10 text-emerald-600 dark:text-emerald-400",badge:""},blue:{icon:"from-blue-500/20 to-blue-400/10 text-blue-600 dark:text-blue-400",badge:""},violet:{icon:"from-violet-500/20 to-violet-400/10 text-violet-600 dark:text-violet-400",badge:""},amber:{icon:"from-amber-500/20 to-amber-400/10 text-amber-600 dark:text-amber-400",badge:""},rose:{icon:"from-rose-500/20 to-rose-400/10 text-rose-600 dark:text-rose-400",badge:""}};function sHe({title:e,value:t,icon:n,description:r,trend:s,accent:i="emerald"}){const o=rHe[i];return d.jsx("div",{className:ie("h-full w-full flex flex-col","rounded-2xl border border-neutral-200/80 bg-white/75 backdrop-blur-md p-5","shadow-[0_1px_3px_0_rgb(0,0,0,0.05),0_1px_2px_-1px_rgb(0,0,0,0.04)]","transition-all duration-200 hover:shadow-[0_4px_12px_0_rgb(0,0,0,0.08)]","hover:border-neutral-300/80","dark:border-neutral-700/50 dark:bg-neutral-900/65 dark:hover:border-neutral-600/60"),children:d.jsxs("div",{className:"flex items-start justify-between gap-3",children:[d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:e}),d.jsx("p",{className:"text-2xl font-bold tracking-tight text-foreground tabular-nums",children:t}),r&&d.jsx("p",{className:"mt-1.5 text-xs text-muted-foreground leading-snug",children:r}),s&&d.jsxs("div",{className:ie("mt-2 inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-semibold",s.isPositive?"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-400":"bg-rose-100 text-rose-700 dark:bg-rose-500/15 dark:text-rose-400"),children:[s.isPositive?d.jsx(L6,{className:"size-3"}):d.jsx(Wne,{className:"size-3"}),s.isPositive?"+":"-",s.value,"%"]})]}),d.jsx("div",{className:ie("shrink-0 rounded-xl bg-gradient-to-br p-2.5",o.icon),children:d.jsx(n,{size:20})})]})})}function $p({icon:e,title:t,description:n}){return d.jsxs("div",{className:"flex h-full min-h-[80px] flex-col items-center justify-center gap-2 text-center",children:[d.jsx(e,{className:"size-8 text-muted-foreground/40"}),d.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:t}),n&&d.jsx("p",{className:"text-xs text-muted-foreground/70",children:n})]})}function $f({message:e,onRetry:t}){const{t:n}=tt();return d.jsxs("div",{className:"flex h-full min-h-[80px] flex-col items-center justify-center gap-3 text-center",children:[d.jsx(A6,{className:"size-8 text-destructive/60"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:e??n("dashboard.widgets.error.message")}),t&&d.jsx(Oe,{variant:"outline",size:"sm",onClick:t,children:n("dashboard.widgets.error.retry")})]})}const iHe={it:l1,en:Oi};function sz(e){return e==="published"?"bg-emerald-50 text-emerald-700 border-emerald-200/80 dark:bg-emerald-500/10 dark:text-emerald-400 dark:border-emerald-800/60":e==="draft"?"bg-amber-50 text-amber-700 border-amber-200/80 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-800/60":"bg-neutral-100 text-neutral-600 border-neutral-200/80 dark:bg-neutral-800 dark:text-neutral-400"}function sC(e){const t=e.data;for(const n of Object.keys(t)){const r=t[n];if(typeof r=="string"&&r.trim())return r}return e.id}const oHe=/\.(jpg|jpeg|png|webp|gif|avif|svg)(\?.*)?$/i;function aHe(e){for(const t of Object.values(e.data))if(typeof t=="string"&&(t.startsWith("http")||oHe.test(t)))return t;return null}function v6({seedSlug:e,variant:t="list"}){const{t:n,i18n:r}=tt(),s=iHe[r.language]??Oi;function i(p){return p?Eg(new Date(p*1e3),{addSuffix:!0,locale:s}):"—"}const{data:o,isLoading:a,isError:l,refetch:u}=Ir({queryKey:["widget","recent-content",e],queryFn:async()=>{const m=(await Gt.get(`/content/${e}`,{params:{limit:5,sortBy:"updated_at",sortDir:"desc"}})).data;return Array.isArray(m)?m:m.items},staleTime:180*1e3}),h=d.jsx(Ns,{to:`/content/${e}`,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:n("dashboard.widgets.recentContent.viewAll")});return a?d.jsx(Un,{title:n("dashboard.widgets.recentContent.title"),icon:Id,action:h,children:d.jsx("div",{className:"space-y-3",children:Array.from({length:4}).map((p,m)=>d.jsx(kr,{className:"h-9 w-full rounded-lg animate-pulse"},m))})}):l?d.jsx(Un,{title:n("dashboard.widgets.recentContent.title"),icon:Id,action:h,children:d.jsx($f,{onRetry:()=>u()})}):o?.length?t==="cards"?d.jsx(Un,{title:n("dashboard.widgets.recentContent.title"),icon:Id,action:h,children:d.jsx(ml,{className:"h-full",children:d.jsx("div",{className:"grid grid-cols-2 gap-3 pr-2",children:o.map(p=>{const m=aHe(p);return d.jsxs(Ns,{to:`/content/${e}/${p.id}`,className:"flex flex-col rounded-xl border border-border/60 bg-card overflow-hidden shadow-sm hover:shadow-md transition-shadow",children:[m?d.jsx("img",{src:m,alt:"",className:"h-28 w-full object-cover shrink-0"}):d.jsx("div",{className:"h-28 shrink-0 bg-muted flex items-center justify-center",children:d.jsx(m9,{className:"size-7 text-muted-foreground/30"})}),d.jsxs("div",{className:"flex flex-col flex-1 p-2",children:[d.jsx("p",{className:"text-xs font-medium line-clamp-2 flex-1",children:sC(p)}),d.jsxs("div",{className:"flex items-center justify-between gap-1 mt-auto pt-2",children:[d.jsx("span",{className:ie("text-[10px] px-1.5 py-0.5 rounded-full font-semibold border",sz(p.status)),children:p.status}),d.jsx("span",{className:"text-[10px] text-muted-foreground",children:i(p.updated_at)})]})]})]},p.id)})})})}):d.jsx(Un,{title:n("dashboard.widgets.recentContent.title"),icon:Id,action:h,children:d.jsx("ul",{className:"space-y-0.5",children:o.map(p=>d.jsxs("li",{className:"group rounded-lg px-3 py-2.5 hover:bg-muted/50 transition-colors",children:[d.jsx(Ns,{to:`/content/${e}/${p.id}`,className:"text-sm font-medium truncate block hover:underline decoration-primary/30 mb-1 sm:hidden",children:sC(p)}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Ns,{to:`/content/${e}/${p.id}`,className:"text-sm font-medium truncate flex-1 hover:underline decoration-primary/30 hidden sm:block",children:sC(p)}),d.jsx(gi,{className:ie("shrink-0 text-[10px] border",sz(p.status)),variant:"outline",children:p.status}),d.jsx("span",{className:"text-xs text-muted-foreground shrink-0 tabular-nums ml-auto sm:ml-0",children:i(p.updated_at)})]})]},p.id))})}):d.jsx(Un,{title:n("dashboard.widgets.recentContent.title"),icon:Id,children:d.jsx($p,{icon:m9,title:n("dashboard.widgets.recentContent.noContent"),description:n("dashboard.widgets.recentContent.noContentDesc")})})}function lHe(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")}function x6({seeds:e,variant:t="minimal",title:n,placeholder:r,onCreated:s}){const{t:i}=tt(),[o,a]=w.useState(""),[l,u]=w.useState(e[0]?.slug??""),[h,p]=w.useState(!1),[m,b]=w.useState(null),y=wi(),x=pa(),S=e.find(R=>R.slug===l),C=S?.displayNameAlias??"title",N=i(`dashboard.widgets.quickDraft.fieldLabels.${C}`,{defaultValue:S?.displayNameLabel??C}),{mutate:M,isPending:_}=Fs({mutationFn:async()=>({id:(await Gt.post(`/content/${l}`,{status:"draft",[C]:o})).data.id,seedSlug:l}),onSuccess:({id:R,seedSlug:D})=>{y.invalidateQueries({queryKey:["content",D]}),y.invalidateQueries({queryKey:["widget","recent-content",D]}),y.invalidateQueries({queryKey:["widget","pending-drafts",D]}),y.invalidateQueries({queryKey:si.activity()}),s?.(R,D),p(!0),setTimeout(()=>{x(`/content/${D}/${R}`)},800)},onError:R=>{b(R.message||i("dashboard.widgets.quickDraft.errorCreating"))}});function T(R){R.preventDefault(),b(null),!(!o.trim()||!l)&&M()}return h?d.jsx(Un,{children:d.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-emerald-600 dark:text-emerald-400",children:[d.jsx(_g,{className:"size-5"}),d.jsx("span",{className:"text-sm font-semibold",children:i("dashboard.widgets.quickDraft.draftCreated")})]})}):d.jsx(Un,{icon:Hee,title:t==="minimal"?n||i("dashboard.widgets.quickDraft.title"):void 0,children:d.jsxs("form",{onSubmit:T,className:"space-y-3",children:[t==="expanded"&&d.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:n||i("dashboard.widgets.quickDraft.createDraft")}),d.jsxs("div",{className:ie("flex gap-2",t==="expanded"?"flex-col":"flex-col sm:flex-row sm:items-center"),children:[d.jsxs("div",{className:"flex-1 space-y-1",children:[t==="expanded"&&d.jsx("label",{className:"text-xs text-muted-foreground",children:N}),d.jsx(Xt,{placeholder:r||`${N}…`,value:o,onChange:R=>a(R.target.value),className:"h-8 text-sm"}),t==="expanded"&&o&&d.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:["/",lHe(o)]})]}),d.jsxs("div",{className:ie("flex gap-2",t==="minimal"?"items-center sm:contents":""),children:[d.jsxs("div",{className:ie(t==="expanded"?"w-full space-y-1":"flex-1 min-w-0 sm:w-28 sm:shrink-0 sm:flex-none"),children:[t==="expanded"&&d.jsx("label",{className:"text-xs text-muted-foreground",children:i("dashboard.widgets.quickDraft.type")}),d.jsxs(Rr,{value:l,onValueChange:u,children:[d.jsx(Or,{className:"h-8 text-sm w-full overflow-hidden",children:d.jsx("span",{className:"truncate block",children:e.find(R=>R.slug===l)?.label??i("dashboard.widgets.quickDraft.type")})}),d.jsx(Dr,{children:e.map(R=>d.jsx(or,{value:R.slug,children:R.label},R.slug))})]})]}),t==="minimal"&&d.jsx(Oe,{type:"submit",size:"sm",disabled:_||!o.trim(),className:"shrink-0 h-8",children:_?"…":i("dashboard.widgets.quickDraft.create")})]})]}),t==="expanded"&&d.jsx(Oe,{type:"submit",size:"sm",disabled:_||!o.trim(),className:"w-full h-8",children:i(_?"dashboard.widgets.quickDraft.creating":"dashboard.widgets.quickDraft.createDraft")}),m&&d.jsx("p",{className:"text-xs text-destructive",children:m})]})})}const cHe={it:l1,en:Oi};function uHe(e){for(const t of Object.values(e.data))if(typeof t=="string"&&t.trim())return t;return e.id}function w6({seedSlug:e,variant:t="list",onPublish:n}){const{t:r,i18n:s}=tt(),i=cHe[s.language]??Oi,o=wi(),{data:a,isLoading:l,isError:u,refetch:h}=Ir({queryKey:["widget","pending-drafts",e],queryFn:async()=>{const y=(await Gt.get(`/content/${e}`,{params:{has_pending_draft:1,limit:10}})).data;return Array.isArray(y)?y:y.items},staleTime:180*1e3}),p=Fs({mutationFn:async b=>(await Gt.post(`/content/${e}/${b}/draft/publish`),b),onSuccess:()=>{o.invalidateQueries({queryKey:["widget","pending-drafts",e]}),o.invalidateQueries({queryKey:["widget","recent-content",e]}),o.invalidateQueries({queryKey:si.activity()})}}),m=a?.length?d.jsx(gi,{className:"bg-amber-100 text-amber-700 border-amber-200/80 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-800/60 text-xs tabular-nums",variant:"outline",children:a.length}):null;return l?d.jsx(Un,{title:r("dashboard.widgets.pendingDrafts.title"),icon:yh,children:d.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((b,y)=>d.jsx(kr,{className:"h-10 w-full animate-pulse"},y))})}):u?d.jsx(Un,{title:r("dashboard.widgets.pendingDrafts.title"),icon:yh,children:d.jsx($f,{onRetry:()=>h()})}):t==="counter"?d.jsx(Un,{title:r("dashboard.widgets.pendingDrafts.title"),icon:yh,children:d.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 h-full text-center",children:[d.jsx("span",{className:"text-5xl font-bold tabular-nums",children:a?.length??0}),d.jsx("p",{className:"text-sm text-muted-foreground",children:r("dashboard.widgets.pendingDrafts.pendingCount")}),d.jsx(Ns,{to:`/content/${e}?status=draft`,children:d.jsx(Oe,{variant:"outline",size:"sm",children:r("dashboard.widgets.pendingDrafts.viewAll")})})]})}):a?.length?d.jsx(Un,{title:r("dashboard.widgets.pendingDrafts.title"),icon:yh,action:d.jsxs("div",{className:"flex items-center gap-2",children:[m,d.jsx(Ns,{to:`/content/${e}?status=draft`,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:r("dashboard.widgets.pendingDrafts.viewAll")})]}),children:d.jsx(ml,{className:"h-[260px]",children:d.jsx("ul",{className:"space-y-1 pr-2",children:a.map(b=>d.jsxs("li",{className:"rounded-lg px-2 py-2 hover:bg-muted/40 transition-colors group",children:[d.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d.jsx(Ns,{to:`/content/${e}/${b.id}`,className:"flex-1 text-sm font-medium truncate hover:underline text-foreground decoration-primary/30 min-w-0",children:uHe(b)}),d.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0 tabular-nums hidden sm:inline",children:b.updated_at?Eg(new Date(b.updated_at*1e3),{addSuffix:!0,locale:i}):"—"}),d.jsxs(Oe,{size:"sm",variant:"default",className:"h-6 text-xs px-2 shrink-0 gap-1 opacity-70 group-hover:opacity-100 transition-opacity hidden sm:flex",disabled:p.isPending,onClick:()=>{p.mutate(b.id),n?.(b.id)},children:[d.jsx(b9,{className:"size-3"}),r("dashboard.widgets.pendingDrafts.publish")]})]}),d.jsxs("div",{className:"flex items-center justify-between gap-2 mt-1 sm:hidden",children:[d.jsx("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:b.updated_at?Eg(new Date(b.updated_at*1e3),{addSuffix:!0,locale:i}):"—"}),d.jsxs(Oe,{size:"sm",variant:"default",className:"h-6 text-xs px-2 shrink-0 gap-1",disabled:p.isPending,onClick:()=>{p.mutate(b.id),n?.(b.id)},children:[d.jsx(b9,{className:"size-3"}),r("dashboard.widgets.pendingDrafts.publish")]})]})]},b.id))})})}):d.jsx(Un,{title:r("dashboard.widgets.pendingDrafts.title"),icon:yh,children:d.jsx($p,{icon:yh,title:r("dashboard.widgets.pendingDrafts.noPending")})})}function Yx({variant:e="single"}){const{t}=tt(),{data:n,isLoading:r,isError:s,refetch:i}=E8();if(r)return d.jsx(Un,{children:d.jsx("div",{className:"flex gap-3 h-full",children:Array.from({length:e==="trio"?3:1}).map((p,m)=>d.jsx(kr,{className:"flex-1 h-16 animate-pulse rounded-lg"},m))})});if(s)return d.jsx(Un,{children:d.jsx($f,{onRetry:()=>i()})});const{total:o,today:a,week:l,month:u}=n??{total:0,today:0,week:0,month:0};if(e==="trio"){const p=[{label:t("dashboard.widgets.publicationStats.today"),value:a,color:"text-blue-600 dark:text-blue-400",border:"border-l-blue-400/60",bg:"bg-blue-50/60 dark:bg-blue-500/10"},{label:t("dashboard.widgets.publicationStats.week"),value:l,color:"text-violet-600 dark:text-violet-400",border:"border-l-violet-400/60",bg:"bg-violet-50/60 dark:bg-violet-500/10"},{label:t("dashboard.widgets.publicationStats.month"),value:u,color:"text-emerald-600 dark:text-emerald-400",border:"border-l-emerald-400/60",bg:"bg-emerald-50/60 dark:bg-emerald-500/10"}];return d.jsx(Un,{children:d.jsx("div",{className:"flex gap-2 overflow-x-auto pb-0.5 sm:grid sm:grid-cols-3 sm:overflow-visible h-full",children:p.map(({label:m,value:b,color:y,border:x,bg:S})=>d.jsxs("div",{className:ie("flex flex-col justify-center rounded-lg border-l-2 px-3 py-2 gap-0.5","min-w-[80px] shrink-0 sm:min-w-0 sm:shrink",x,S),children:[d.jsx("span",{className:ie("text-xl font-bold tabular-nums leading-none sm:text-2xl",y),children:b}),d.jsx("span",{className:"text-[10px] font-medium text-muted-foreground whitespace-nowrap",children:m})]},m))})})}const h=a>0;return d.jsx(Un,{children:d.jsxs("div",{className:"flex flex-col justify-center h-full gap-1",children:[d.jsxs("div",{className:"flex items-end gap-2",children:[d.jsx("span",{className:"text-4xl font-bold tabular-nums",children:o.toLocaleString()}),d.jsxs("span",{className:ie("mb-1 flex items-center gap-0.5 text-sm font-semibold",h?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"),children:[d.jsx(L6,{className:ie("size-4",!h&&"opacity-20")}),a]})]}),d.jsx("p",{className:"text-sm text-muted-foreground",children:t("dashboard.widgets.publicationStats.totalContent")})]})})}Yx.displayName="PublicationStatsWidget";function S6({variant:e="badge"}){const{data:t,isLoading:n,isError:r,refetch:s,dataUpdatedAt:i}=GZ(),{data:o}=N8(),{data:a}=E8(),l=t?.status==="healthy"||t?.status==="warning";if(n)return d.jsx(Un,{children:d.jsx(kr,{className:"h-10 w-full animate-pulse"})});if(r)return d.jsx(Un,{children:d.jsx($f,{onRetry:()=>s()})});const u=l??!1,h=i?new Date(i).toLocaleTimeString("it-IT",{hour:"2-digit",minute:"2-digit"}):"—";if(e==="pill-row"){const p=[{label:"API",ok:u},{label:"Storage",ok:!!o},{label:"DB",ok:typeof a?.total=="number"&&a.total>=0}];return d.jsx(Un,{children:d.jsx("div",{className:"flex flex-wrap items-center gap-2 h-full",children:p.map(({label:m,ok:b})=>d.jsxs(gi,{className:ie("text-xs gap-1.5 px-2.5 py-1",b?"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400 border-emerald-200/80 dark:border-emerald-800/60":"bg-red-50 text-red-700 dark:bg-red-500/10 dark:text-red-400 border-red-200/80 dark:border-red-800/60"),variant:"outline",children:[d.jsx("span",{className:ie("size-1.5 rounded-full",b?"bg-emerald-500 shadow-[0_0_4px_rgba(34,197,94,0.6)]":"bg-red-500")}),m]},m))})})}return d.jsx(Un,{children:d.jsxs("div",{className:"flex items-center gap-3 h-full",children:[d.jsxs("div",{className:"relative shrink-0",children:[d.jsx("span",{className:ie("block size-3 rounded-full",u?"bg-emerald-500":"bg-red-500")}),u&&d.jsx("span",{className:"absolute inset-0 rounded-full bg-emerald-500 animate-ping opacity-60"})]}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("p",{className:"text-sm font-semibold",children:u?"Site online":"Error"}),d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Verified at ",h]})]}),u?d.jsx(_z,{className:"size-4 text-emerald-500 shrink-0"}):d.jsx(fre,{className:"size-4 text-red-500 shrink-0"})]})})}const dHe=10*1024*1024*1024;function Oy(e){return(e/1024/1024/1024).toFixed(1)}function fHe(e){return e>85?"#ef4444":e>60?"#eab308":"#22c55e"}function hHe({pct:e,usedLabel:t}){const o=2*Math.PI*38,a=o-e/100*o,l=fHe(e);return d.jsxs("svg",{width:"104",height:"104",viewBox:"0 0 104 104","aria-hidden":!0,children:[d.jsx("circle",{cx:52,cy:52,r:38,fill:"none",stroke:"currentColor",strokeWidth:8,className:"text-muted-foreground/15 dark:text-muted-foreground/30"}),d.jsx("circle",{cx:52,cy:52,r:38,fill:"none",stroke:l,strokeWidth:8,strokeLinecap:"round",strokeDasharray:o,strokeDashoffset:a,transform:"rotate(-90 52 52)",className:"transition-all duration-1000 ease-in-out",style:{filter:`drop-shadow(0 0 4px ${l}60)`}}),d.jsxs("text",{x:52,y:48,textAnchor:"middle",dominantBaseline:"central",fontSize:"15",fontWeight:"700",fill:l,className:"tabular-nums",children:[e,"%"]}),d.jsx("text",{x:52,y:64,textAnchor:"middle",dominantBaseline:"central",fontSize:"9",fontWeight:"500",className:"fill-muted-foreground",fill:"currentColor",style:{color:"var(--muted-foreground)"},children:t})]})}function C6({variant:e="bar",totalBytes:t=dHe}){const{t:n}=tt(),{data:r,isLoading:s,isError:i,refetch:o}=N8();if(s)return d.jsx(Un,{children:d.jsx(kr,{className:"h-12 w-full animate-pulse"})});if(i)return d.jsx(Un,{children:d.jsx($f,{onRetry:()=>o()})});const a=r?r.storage.used*1024*1024:0,l=Math.min(100,Math.round(a/t*100));if(!r)return d.jsx(Un,{children:d.jsx($p,{icon:D6,title:n("dashboard.widgets.storage.noData")})});if(e==="gauge")return d.jsx(Un,{children:d.jsxs("div",{className:"flex flex-col items-center gap-2 h-full w-full xs:flex-row sm:flex-row sm:items-center sm:gap-3",children:[d.jsx("div",{className:"shrink-0",children:d.jsx(hHe,{pct:l,usedLabel:n("dashboard.widgets.storage.used")})}),d.jsxs("div",{className:"flex-1 min-w-0 text-center sm:text-left",children:[d.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:n("dashboard.widgets.storage.title")}),d.jsxs("p",{className:"text-base font-bold text-foreground tabular-nums leading-tight",children:[Oy(a)," ",d.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"GB"})]}),d.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:n("dashboard.widgets.storage.total",{total:Oy(t)})})]})]})});const u=`${Oy(a)} GB di ${Oy(t)} GB`;return d.jsx(Un,{children:d.jsxs("div",{className:"flex flex-col justify-center gap-2 h-full",children:[d.jsxs("div",{className:"flex items-center justify-between text-xs",children:[d.jsx("span",{className:"text-muted-foreground font-medium",children:n("dashboard.widgets.storage.title")}),d.jsxs("span",{className:"font-bold tabular-nums",children:[l,"%"]})]}),d.jsx(Sp,{value:l,className:"h-1.5"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:u})]})})}function pHe(e){for(const t of Object.values(e.data))if(typeof t=="string"&&(t.startsWith("http")||t.startsWith("/")))return t;return null}function mHe(e){for(const t of Object.values(e.data))if(typeof t=="string"&&t.trim()&&!t.startsWith("http")&&!t.startsWith("/"))return t;return e.id}function k6({seedSlug:e="",variant:t="grid",onOpen:n}){const[r,s]=w.useState(t),{t:i}=tt(),o=wi(),a=Ir({queryKey:["widget","media-library"],queryFn:async()=>(await Gt.get("/content/stats/media-library",{params:{limit:12}})).data.items,staleTime:180*1e3,enabled:r==="grid"}),l=Ir({queryKey:["widget","media-gallery",e,"unused"],queryFn:async()=>(await Gt.get("/content/stats/unused-media",{params:{seedSlug:e,limit:12}})).data.items,staleTime:0,enabled:r==="unused"&&!!e}),u=Fs({mutationFn:async y=>{await Gt.delete(`/${encodeURIComponent(y)}`)},onSuccess:()=>{o.invalidateQueries({queryKey:["widget","media-library"]})}}),h=Fs({mutationFn:async y=>{await Gt.delete(`/content/${e}/${y}`)},onSuccess:()=>{o.invalidateQueries({queryKey:["widget","media-gallery",e]})}}),p=r==="grid"?a.isLoading:l.isLoading,m=r==="grid"?a.isError:l.isError,b=r==="grid"?a.refetch:l.refetch;return d.jsxs("div",{className:"h-full w-full flex flex-col rounded-xl border border-neutral-200/60 bg-background/50 backdrop-blur-sm shadow-sm dark:border-neutral-800/60 dark:bg-neutral-900/40 overflow-hidden",children:[d.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border/40 shrink-0",children:[d.jsxs("span",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[d.jsx(em,{className:"size-4 text-muted-foreground"}),i("dashboard.widgets.mediaGallery.title")]}),d.jsxs("div",{className:"flex items-center gap-0.5 bg-muted/50 p-0.5 rounded-md border border-border/50",children:[d.jsx(Oe,{variant:r==="grid"?"secondary":"ghost",size:"sm",className:"h-6 px-2 text-[10px]",onClick:()=>s("grid"),children:i("dashboard.widgets.mediaGallery.all")}),d.jsx(Oe,{variant:r==="unused"?"secondary":"ghost",size:"sm",className:"h-6 px-2 text-[10px]",onClick:()=>s("unused"),children:i("dashboard.widgets.mediaGallery.unused")})]})]}),d.jsx("div",{className:"flex-1 p-3 overflow-y-auto min-h-0",children:p?d.jsx("div",{className:"grid grid-cols-4 gap-2",children:Array.from({length:8}).map((y,x)=>d.jsx(kr,{className:"aspect-square rounded-md animate-pulse"},x))}):m?d.jsx($f,{onRetry:()=>b()}):r==="grid"?a.data?.length?d.jsx("div",{className:"grid grid-cols-4 gap-2",children:a.data.map(y=>{const x=u.isPending&&u.variables===y.key,S=y.mime_type.startsWith("image/");return d.jsxs("div",{className:ie("group relative aspect-square overflow-hidden rounded-lg bg-muted/50 border border-border/50 cursor-pointer transition-all hover:ring-2 hover:ring-primary/20",x&&"opacity-50 grayscale pointer-events-none"),onClick:()=>n?.(y.key),children:[S?d.jsx("img",{src:y.url,alt:y.filename,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-110"}):d.jsx("div",{className:"flex h-full w-full items-center justify-center",children:d.jsx(em,{className:"size-6 text-muted-foreground/30"})}),d.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent p-2 pt-6 opacity-0 group-hover:opacity-100 transition-opacity",children:d.jsx("p",{className:"text-[10px] text-white font-medium truncate",children:y.filename})})]},y.key)})}):d.jsx($p,{icon:em,title:i("dashboard.widgets.mediaGallery.emptyTitle"),description:i("dashboard.widgets.mediaGallery.emptyDesc")}):l.data?.length?d.jsx("div",{className:"grid grid-cols-4 gap-2",children:l.data.map(y=>{const x=pHe(y),S=mHe(y),C=h.isPending&&h.variables===y.id;return d.jsxs("div",{className:ie("group relative aspect-square overflow-hidden rounded-lg bg-muted/50 border border-border/50 cursor-pointer transition-all hover:ring-2 hover:ring-primary/20",C&&"opacity-50 grayscale pointer-events-none"),children:[x?d.jsx("img",{src:x,alt:S,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-110"}):d.jsx("div",{className:"flex h-full w-full items-center justify-center",children:d.jsx(em,{className:"size-6 text-muted-foreground/30"})}),d.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent p-2 pt-6 opacity-0 group-hover:opacity-100 transition-opacity",children:[d.jsx("p",{className:"text-[10px] text-white font-medium truncate mb-1.5",children:S}),d.jsxs(Oe,{variant:"destructive",size:"sm",className:"h-6 w-full text-[10px] gap-1 px-1.5 bg-red-600 hover:bg-red-500 border-none",onClick:N=>{N.stopPropagation(),confirm(`Eliminare definitivamente ${S}?`)&&h.mutate(y.id)},children:[d.jsx(La,{className:"size-3"})," Elimina"]})]})]},y.id)})}):d.jsx($p,{icon:em,title:i("dashboard.widgets.mediaGallery.allInUseTitle"),description:i("dashboard.widgets.mediaGallery.allInUseDesc")})})]})}const gHe={it:l1,en:Oi},bHe={create:Hi,update:I6,delete:La,upload:xm},yHe={create:"bg-emerald-100 text-emerald-600 dark:bg-emerald-500/15 dark:text-emerald-400",update:"bg-blue-100 text-blue-600 dark:bg-blue-500/15 dark:text-blue-400",delete:"bg-red-100 text-red-600 dark:bg-red-500/15 dark:text-red-400",upload:"bg-violet-100 text-violet-600 dark:bg-violet-500/15 dark:text-violet-400"};function iz(e,t,n="User"){return e||t||n}function vHe(e,t){const n=e||t;return n?n.slice(0,2).toUpperCase():"?"}function E6({seedSlug:e,variant:t="feed"}){const{t:n,i18n:r}=tt(),s=gHe[r.language]??Oi;function i(h){return h?Eg(new Date(h*1e3),{addSuffix:!0,locale:s}):"—"}const{data:o,isLoading:a,isError:l,refetch:u}=qZ(e);if(a)return d.jsx(Un,{title:n("dashboard.widgets.activityFeed.title"),icon:ic,children:d.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((h,p)=>d.jsxs("div",{className:"flex gap-3",children:[d.jsx(kr,{className:"size-8 shrink-0 rounded-full animate-pulse"}),d.jsx(kr,{className:"h-8 flex-1 animate-pulse"})]},p))})});if(l)return d.jsx(Un,{title:n("dashboard.widgets.activityFeed.title"),icon:ic,children:d.jsx($f,{onRetry:()=>u()})});if(!o?.length)return d.jsx(Un,{title:n("dashboard.widgets.activityFeed.title"),icon:ic,children:d.jsx($p,{icon:ic,title:n("dashboard.widgets.activityFeed.empty")})});if(t==="compact"){const h=o.slice(0,10);return d.jsx(Un,{title:n("dashboard.widgets.activityFeed.title"),icon:ic,children:d.jsx(ml,{className:"h-full",type:"auto",children:d.jsx("ul",{className:"space-y-1 pr-3",children:h.map(p=>d.jsxs("li",{className:"flex items-center gap-2",children:[d.jsxs("span",{className:"text-xs text-muted-foreground truncate flex-1",children:[d.jsx("span",{className:"font-medium text-foreground",children:iz(p.user_name,p.user_email)})," ",n(`dashboard.recentActivity.actions.${p.action}`,{defaultValue:p.action})," ",d.jsx("span",{className:"font-medium text-foreground",children:p.details?.title||p.details?.name||p.entity_slug||p.entity_id})]}),d.jsx("span",{className:"text-[10px] text-muted-foreground/60 shrink-0",children:i(p.created_at)})]},p.id))})})})}return d.jsx(Un,{title:n("dashboard.widgets.activityFeed.title"),icon:ic,children:d.jsx(ml,{className:"h-[180px]",type:"auto",children:d.jsx("ul",{className:"space-y-3 pr-3",children:o.map(h=>{const p=bHe[h.action]??ic,m=yHe[h.action]??"bg-muted text-muted-foreground";return d.jsxs("li",{className:"flex items-start gap-3 group",children:[d.jsxs("div",{className:"relative shrink-0",children:[d.jsx(mf,{className:"size-8 border border-border/60",children:d.jsx(gf,{className:"text-[10px] bg-primary/5 text-primary font-semibold",children:vHe(h.user_name,h.user_email)})}),d.jsx("span",{className:ie("absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full ring-2 ring-background",m),children:d.jsx(p,{className:"size-2.5"})})]}),d.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[d.jsxs("p",{className:"text-sm leading-snug",children:[d.jsx("span",{className:"font-semibold",children:iz(h.user_name,h.user_email)})," ",d.jsx("span",{className:"text-muted-foreground",children:n(`dashboard.recentActivity.actions.${h.action}`,{defaultValue:h.action})})," ",d.jsx("span",{className:"font-medium",children:h.details?.title||h.details?.name||h.entity_slug||h.entity_id})]}),d.jsx("p",{className:"text-xs text-muted-foreground/70",children:i(h.created_at)})]})]},h.id)})})})})}const oz="beech_setup_checklist_dismissed";function xHe({variant:e="full"}){const{t}=tt(),{data:n,isLoading:r,isError:s}=YBe(),[i,o]=w.useState(()=>localStorage.getItem(oz)==="1");if(r)return d.jsx("div",{className:"rounded-xl border bg-card px-4 py-3",children:d.jsx(kr,{className:"h-5 w-48 animate-pulse"})});if(s||!n)return null;if(n.systemTablesOk&&n.seedsCount>0&&n.contentTablesOk&&n.adminExists&&n.hasContent)return i?null:d.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-emerald-200/80 bg-emerald-50 px-4 py-2.5 dark:border-emerald-800/40 dark:bg-emerald-500/10",children:[d.jsx(_g,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400"}),d.jsx("p",{className:"flex-1 text-sm font-medium text-emerald-800 dark:text-emerald-300",children:t("dashboard.setupChecklist.allDone")}),d.jsx("button",{onClick:()=>{localStorage.setItem(oz,"1"),o(!0)},className:"text-emerald-600 hover:text-emerald-800 dark:text-emerald-400 dark:hover:text-emerald-200","aria-label":"Dismiss",children:d.jsx(ro,{className:"size-4"})})]});const l=[{done:n.systemTablesOk,label:t("dashboard.setupChecklist.systemTables"),hint:t("dashboard.setupChecklist.systemTablesHint")},{done:n.seedsCount>0,label:n.seedsCount>0?t("dashboard.setupChecklist.seeds",{count:n.seedsCount}):t("dashboard.setupChecklist.seedsNone"),action:n.seedsCount===0?{label:t("dashboard.setupChecklist.seedsAction"),href:"https://beechcms.dev/guide"}:void 0},{done:n.contentTablesOk,label:t("dashboard.setupChecklist.contentTables"),action:n.contentTablesOk?void 0:{label:"npx beech seed:load --local",command:"npx beech seed:load --local"}},{done:n.adminExists,label:t("dashboard.setupChecklist.adminAccount"),action:n.adminExists?void 0:{label:t("dashboard.setupChecklist.adminAction"),href:"/setup"}},{done:n.hasContent,label:t("dashboard.setupChecklist.firstContent"),action:!n.hasContent&&n.firstSeedSlug?{label:t("dashboard.setupChecklist.firstContentAction"),href:`/content/${n.firstSeedSlug}/new`}:void 0}],u=l.filter(h=>h.done).length;return d.jsxs("div",{className:"rounded-xl border bg-card px-4 py-3",children:[d.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[d.jsx(A6,{className:"size-4 text-amber-500"}),d.jsx("p",{className:"text-sm font-semibold",children:t("dashboard.setupChecklist.title")}),d.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[u,"/",l.length]})]}),e==="compact"?d.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1.5",children:l.map((h,p)=>d.jsx(wHe,{done:h.done,label:h.label},p))}):d.jsx("ul",{className:"space-y-2",children:l.map((h,p)=>d.jsx(SHe,{...h},p))})]})}function wHe({done:e,label:t}){return d.jsxs("span",{className:ie("flex items-center gap-1.5 text-xs",e?"text-muted-foreground line-through":"text-foreground"),children:[e?d.jsx(_g,{className:"size-3 shrink-0 text-emerald-500"}):d.jsx(R6,{className:"size-3 shrink-0 text-amber-400"}),t]})}function SHe({done:e,label:t,hint:n,action:r}){return d.jsxs("li",{className:"flex items-start gap-2.5",children:[e?d.jsx(_g,{className:"mt-0.5 size-4 shrink-0 text-emerald-500"}):d.jsx(R6,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground/50"}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:ie("text-sm",e?"text-muted-foreground line-through":"text-foreground"),children:t}),!e&&n&&d.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:n}),!e&&r&&(r.command?d.jsx("code",{className:"mt-1 inline-block rounded bg-muted px-2 py-0.5 text-xs font-mono text-foreground",children:r.command}):r.href?.startsWith("http")?d.jsxs("a",{href:r.href,target:"_blank",rel:"noopener noreferrer",className:"mt-0.5 inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[r.label,d.jsx(xc,{className:"size-3"})]}):d.jsxs(Ns,{to:r.href,className:"mt-0.5 inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[r.label,d.jsx(xc,{className:"size-3"})]}))]})]})}function CHe({instance:e,data:t}){return d.jsx(ZBe,{widgetId:e.id,children:d.jsx(kHe,{instance:e,data:t})})}function kHe({instance:e,data:t}){const{type:n,props:r}=e,{t:s}=tt();if(n==="stat"){const i=EHe(r?.statKey,t,s);return d.jsx(sHe,{...i})}return n==="recent-activity"?d.jsx(QBe,{}):n==="system-health"?d.jsx(JBe,{}):n==="content-pulse"?d.jsx(eHe,{}):n==="ai-insights"?d.jsx(tHe,{}):n==="quick-actions"?d.jsx(nHe,{onAction:i=>console.log("[BeechCMS] Quick action:",i)}):n==="recent-content"?d.jsx(v6,{seedSlug:r?.seedSlug??"",variant:r?.variant,onOpen:r?.onOpen}):n==="quick-draft"?d.jsx(x6,{seeds:r?.seeds??[],variant:r?.variant,onCreated:r?.onCreated}):n==="pending-drafts"?d.jsx(w6,{seedSlug:r?.seedSlug??"",variant:r?.variant,onPublish:r?.onPublish,onOpen:r?.onOpen}):n==="publication-stats"?d.jsx(Yx,{variant:r?.variant}):n==="site-status"?d.jsx(S6,{variant:r?.variant}):n==="storage"?d.jsx(C6,{variant:r?.variant,totalBytes:r?.totalBytes}):n==="media-gallery"?d.jsx(k6,{seedSlug:r?.seedSlug??"",variant:r?.variant,onOpen:r?.onOpen}):n==="activity-feed"?d.jsx(E6,{seedSlug:r?.seedSlug??"",variant:r?.variant,limit:r?.limit}):n==="setup-checklist"?d.jsx(xHe,{variant:r?.variant}):d.jsx("div",{className:"flex h-full min-h-[80px] items-center justify-center rounded-xl border-2 border-dashed border-muted p-4",children:d.jsxs("p",{className:"text-sm text-muted-foreground",children:[s("dashboard.widgetRegistry.unknown")," ",d.jsx("span",{className:"font-mono font-semibold",children:n})]})})}function EHe(e,t,n){const{statsData:r,cfData:s,statsLoading:i,cfLoading:o}=t||{};switch(e){case"total":return{title:n("dashboard.widgets.stat.total.title"),value:i?"...":r?.total.toLocaleString()??"0",icon:nv,description:n("dashboard.widgets.stat.total.description"),trend:r?.total?{value:Math.round(r.recent/r.total*100),isPositive:!0}:void 0};case"visitors":return{title:n("dashboard.widgets.stat.visitors.title"),value:o?"...":s?.visitors.value.toLocaleString()??"0",icon:xz,description:n("dashboard.widgets.stat.visitors.description"),trend:s?.visitors.trend?{value:s.visitors.trend,isPositive:s.visitors.isPositive}:void 0};case"traffic":return{title:n("dashboard.widgets.stat.traffic.title"),value:o?"...":`${s?.bandwidth.value} ${s?.bandwidth.unit}`,icon:Rg,description:n("dashboard.widgets.stat.traffic.description"),trend:s?.bandwidth.trend?{value:s.bandwidth.trend,isPositive:s.bandwidth.isPositive}:void 0};case"storage":return{title:n("dashboard.widgets.storage.title"),value:o?"...":`${s?.storage.used} ${s?.storage.unit}`,icon:O6,description:o?n("common.loading"):n("dashboard.widgets.stat.storage.description",{percentage:s?.storage.percentage,total:Math.round((s?.storage.limit??0)/1024)}),trend:s?{value:s.storage.percentage,isPositive:!1}:void 0};default:return{title:"N/A",value:"0",icon:nv}}}function NHe(e){const t=[{id:"setup-checklist",type:"setup-checklist",x:0,y:0,span:{w:8,h:1},props:{variant:"full"}},{id:"site-status",type:"site-status",x:0,y:1,span:{w:2,h:1},props:{variant:"badge"}},{id:"storage-gauge",type:"storage",x:2,y:1,span:{w:2,h:1},props:{variant:"gauge"}},{id:"pub-stats-trio",type:"publication-stats",x:4,y:1,span:{w:2,h:1},props:{variant:"trio"}}];if(e.length>0){const n=e[0],r=e.find(i=>i.slug==="articoli")?.slug??n.slug,s=e.map(i=>{const o=i.branches.find(a=>a.alias===i.displayNameAlias);return{slug:i.slug,label:i.label,displayNameAlias:i.displayNameAlias,displayNameLabel:o?.label??i.displayNameAlias}});t.push({id:"quick-draft-minimal",type:"quick-draft",x:6,y:1,span:{w:2,h:1},props:{variant:"minimal",seeds:s}},{id:"recent-content-list",type:"recent-content",x:0,y:2,span:{w:4,h:2},props:{seedSlug:r,variant:"list"}},{id:"pending-drafts-list",type:"pending-drafts",x:4,y:2,span:{w:4,h:2},props:{seedSlug:r,variant:"list"}},{id:"media-gallery-grid",type:"media-gallery",x:0,y:4,span:{w:4,h:2},props:{seedSlug:r,variant:"grid"}},{id:"activity-feed-full",type:"activity-feed",x:4,y:4,span:{w:4,h:2},props:{seedSlug:r,variant:"feed"}})}return{layout:t}}function MHe(){const{t:e}=tt(),{data:t=[]}=n0(),{data:n,isLoading:r}=E8(),{data:s,isLoading:i}=N8(),{user:o}=e1(),a=new Date().getHours(),l=a>=5&&a<12?e("dashboard.greeting.morning"):a>=12&&a<18?e("dashboard.greeting.afternoon"):a>=18&&a<22?e("dashboard.greeting.evening"):e("dashboard.greeting.night"),u=o?.name||"Admin",h={statsData:n,cfData:s,statsLoading:r,cfLoading:i};return d.jsxs("div",{className:"[--header-height:calc(--spacing(14))] overflow-x-clip min-h-screen bg-neutral-50/50 dark:bg-neutral-950/50 relative",children:[d.jsxs("div",{className:"absolute top-0 left-0 w-full h-full overflow-hidden pointer-events-none z-0",children:[d.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[40%] h-[40%] bg-emerald-500/5 rounded-full blur-[120px]"}),d.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[40%] h-[40%] bg-blue-500/5 rounded-full blur-[120px]"})]}),d.jsxs(Ru,{className:"flex flex-col relative z-10",children:[d.jsx(Pu,{}),d.jsxs("div",{className:"flex flex-1",children:[d.jsx(Lu,{}),d.jsx(Ou,{className:"min-w-0",children:d.jsx("main",{className:"flex flex-1 flex-col gap-8 p-6 md:p-8 lg:p-10",children:d.jsxs("div",{className:"content-area-inner flex flex-col gap-8",children:[d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsxs("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl text-neutral-900 dark:text-neutral-100",children:[l,", ",d.jsx("span",{className:"text-primary",children:u})]}),d.jsx("p",{className:"text-neutral-500 dark:text-neutral-400",children:e("dashboard.greeting.subtitle")})]}),d.jsx("div",{className:"bento-grid grid grid-cols-1 gap-6 md:grid-cols-4 lg:grid-cols-8 auto-rows-min",children:NHe(t).layout.map(p=>{const b=Math.min(Math.max(1,p.span.w),8),y=Math.min(Math.max(1,p.span.h),12),x=Math.max(1,Math.ceil(b/2));return d.jsx("div",{className:"bento-cell flex flex-col",style:{"--col-span-md":x,"--col-span-lg":b,"--row-span":y},children:d.jsx(CHe,{instance:p,data:h})},p.id)})})]})})})]})]})]})}function Un({children:e,className:t,bare:n=!1,title:r,icon:s,action:i,contentClassName:o}){if(n)return d.jsx("div",{className:ie("h-full w-full",t),children:e});const a=!!(r||s||i);return d.jsxs("div",{className:ie("h-full w-full flex flex-col","rounded-2xl border border-neutral-200/80 bg-white/75 backdrop-blur-md overflow-hidden","shadow-[0_1px_3px_0_rgb(0,0,0,0.05),0_1px_2px_-1px_rgb(0,0,0,0.04)]","transition-all duration-200 hover:shadow-[0_4px_12px_0_rgb(0,0,0,0.08),0_2px_4px_-1px_rgb(0,0,0,0.06)]","hover:border-neutral-300/80","dark:border-neutral-700/50 dark:bg-neutral-900/65 dark:hover:border-neutral-600/60","dark:shadow-[0_1px_3px_0_rgb(0,0,0,0.2)] dark:hover:shadow-[0_4px_12px_0_rgb(0,0,0,0.3)]","p-5",t),children:[a&&d.jsxs("div",{className:"flex items-center justify-between mb-4 shrink-0",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[s&&d.jsx(s,{className:"size-4 text-muted-foreground"}),r&&d.jsx("span",{className:"text-sm font-semibold text-foreground",children:r})]}),i&&d.jsx("div",{className:"flex items-center",children:i})]}),d.jsx("div",{className:ie("flex-1 min-h-0",o),children:e})]})}function ec({title:e,description:t,children:n}){return d.jsxs("section",{className:"space-y-4",children:[d.jsxs("div",{children:[d.jsx("h2",{className:"text-base font-semibold text-foreground",children:e}),t&&d.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t})]}),n]})}function tc({children:e,className:t}){return d.jsx("div",{className:ie("grid gap-4",t),children:e})}function zs({label:e,h:t=120,children:n}){return d.jsxs("div",{className:"space-y-2",children:[d.jsx("p",{className:"text-xs font-mono text-muted-foreground/70",children:e}),d.jsx("div",{style:{height:t},children:n})]})}function iC({name:e}){return d.jsx(Un,{children:d.jsx("div",{className:"flex h-full items-center justify-center",children:d.jsx("p",{className:"text-sm font-mono text-muted-foreground/50",children:e})})})}function _He(){const{data:e=[]}=n0(),t=e.map(r=>{const s=r.branches.find(i=>i.alias===r.displayNameAlias);return{slug:r.slug,label:r.label,displayNameAlias:r.displayNameAlias,displayNameLabel:s?.label??r.displayNameAlias}}),n=t[0]?.slug??"";return d.jsx("div",{className:"[--header-height:calc(--spacing(14))]",children:d.jsxs(Ru,{className:"flex flex-col",children:[d.jsx(Pu,{}),d.jsxs("div",{className:"flex flex-1",children:[d.jsx(Lu,{}),d.jsx(Ou,{children:d.jsxs("div",{className:"mx-auto w-full max-w-screen-2xl p-6 space-y-12",children:[d.jsxs("div",{children:[d.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Widget Lab"}),d.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Sandbox per sviluppare e ispezionare i widget prima di portarli in dashboard. Ogni sezione mostra un widget in tutte le sue varianti di dimensione."})]}),d.jsx(ec,{title:"SiteStatusWidget",description:`type="site-status" — mostra lo stato online/offline dell'API`,children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="badge" · span w:2 h:1',children:d.jsx(S6,{variant:"badge"})}),d.jsx(zs,{label:'variant="pill-row" · span w:3 h:1',children:d.jsx(S6,{variant:"pill-row"})})]})}),d.jsx(ec,{title:"StorageWidget",description:'type="storage" — utilizzo storage R2',children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="gauge" · span w:2 h:1',children:d.jsx(C6,{variant:"gauge"})}),d.jsx(zs,{label:'variant="bar" · span w:3 h:1',children:d.jsx(C6,{variant:"bar"})})]})}),d.jsx(ec,{title:"PublicationStatsWidget",description:'type="publication-stats" — contenuti pubblicati oggi / settimana / mese',children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="trio" · span w:2 h:1',children:d.jsx(Yx,{variant:"trio"})}),d.jsx(zs,{label:'variant="single" · span w:2 h:1',children:d.jsx(Yx,{variant:"single"})})]})}),d.jsx(ec,{title:"QuickDraftWidget",description:'type="quick-draft" — crea velocemente una bozza senza navigare',children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="minimal" · span w:2 h:1',children:d.jsx(x6,{variant:"minimal",seeds:t})}),d.jsx(zs,{label:'variant="expanded" · span w:4 h:2',h:200,children:d.jsx(x6,{variant:"expanded",seeds:t})})]})}),d.jsx(ec,{title:"RecentContentWidget",description:'type="recent-content" — lista degli ultimi contenuti modificati',children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="list" · span w:4 h:2',h:280,children:d.jsx(v6,{seedSlug:n,variant:"list"})}),d.jsx(zs,{label:'variant="cards" · span w:4 h:2',h:280,children:d.jsx(v6,{seedSlug:n,variant:"cards"})})]})}),d.jsx(ec,{title:"PendingDraftsWidget",description:'type="pending-drafts" — bozze in attesa di revisione / pubblicazione',children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="counter" · span w:2 h:1',children:d.jsx(w6,{seedSlug:n,variant:"counter"})}),d.jsx(zs,{label:'variant="list" · span w:4 h:2',h:280,children:d.jsx(w6,{seedSlug:n,variant:"list"})})]})}),d.jsx(ec,{title:"MediaGalleryWidget",description:'type="media-gallery" — anteprima griglia dei media caricati',children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="grid" · span w:4 h:2',h:280,children:d.jsx(k6,{seedSlug:n,variant:"grid"})}),d.jsx(zs,{label:'variant="unused" · span w:4 h:2',h:280,children:d.jsx(k6,{seedSlug:n,variant:"unused"})})]})}),d.jsx(ec,{title:"ActivityFeedWidget",description:'type="activity-feed" — log delle ultime azioni nel CMS',children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="compact" · span w:2 h:1',children:d.jsx(E6,{variant:"compact"})}),d.jsx(zs,{label:'variant="feed" · span w:4 h:2',h:280,children:d.jsx(E6,{variant:"feed"})})]})}),d.jsx(ec,{title:"In sviluppo",description:"Nuovi widget in costruzione — aggiungi qui i tuoi componenti prima di registrarli.",children:d.jsxs(tc,{className:"grid-cols-3",children:[d.jsx(zs,{label:"nuovo-widget-1",children:d.jsx(iC,{name:"nuovo-widget-1"})}),d.jsx(zs,{label:"nuovo-widget-2",children:d.jsx(iC,{name:"nuovo-widget-2"})}),d.jsx(zs,{label:"nuovo-widget-3",children:d.jsx(iC,{name:"nuovo-widget-3"})})]})})]})})]})]})})}function THe(){const{t:e}=tt(),t=xH(),n=vp(t);let r=e("errorPage.unknown");n?r=t.statusText||t.data?.message||e("errorPage.unknown"):t instanceof Error&&(r=t.message);const s=n?t.status:null;return d.jsx("div",{className:"flex min-h-svh w-full flex-col items-center justify-center bg-background p-6",children:d.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[s&&d.jsx("span",{className:"text-6xl font-bold text-muted-foreground",children:s}),d.jsx("h1",{className:"text-xl font-semibold",children:e("errorPage.title")}),d.jsx("p",{className:"text-sm text-muted-foreground",children:r}),d.jsx(Ns,{to:"/",className:"rounded-md bg-accent px-4 py-2 text-sm !text-white hover:bg-accent/90",children:e("errorPage.backHome")})]})})}const AHe=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function RHe(){const{t:e,i18n:t}=tt(),[n,r]=w.useState(""),[s,i]=w.useState(null),[o,a]=w.useState(!1),[l,u]=w.useState(!1),h=async p=>{p.preventDefault();const m=n.trim();if(!m){i(e("forgotPassword.emailRequired"));return}if(!AHe.test(m)){i(e("forgotPassword.emailInvalid"));return}i(null),a(!0);try{await $n.post("/auth/forgot-password",{email:m,locale:t.language})}catch{}a(!1),u(!0)};return d.jsx("div",{className:"flex min-h-svh w-full flex-col items-center justify-center bg-background p-4 sm:p-6 md:p-8",children:d.jsx("div",{className:"w-full max-w-sm sm:max-w-md",children:d.jsx(Zn,{className:"overflow-hidden shadow-md",children:d.jsx(Xn,{className:"p-6 md:p-8",children:l?d.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:e("forgotPassword.successTitle")}),d.jsx("p",{className:"text-muted-foreground text-balance text-sm",children:e("forgotPassword.successDesc")}),d.jsx(Ns,{to:"/login",className:"text-sm underline-offset-2 hover:underline",children:e("forgotPassword.backToLogin")})]}):d.jsx("form",{onSubmit:h,noValidate:!0,children:d.jsxs(a7,{children:[d.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:e("forgotPassword.title")}),d.jsx("p",{className:"text-muted-foreground text-balance text-sm",children:e("forgotPassword.desc")})]}),d.jsxs(pc,{children:[d.jsx(wp,{htmlFor:"fp-email",children:"Email"}),d.jsx(Xt,{id:"fp-email",type:"email",inputMode:"email",autoComplete:"email",value:n,className:ie(s?"border-destructive":""),onChange:p=>{r(p.target.value),i(null)}}),s&&d.jsx(l7,{children:s})]}),d.jsx(pc,{children:d.jsx(Oe,{type:"submit",disabled:!n.trim()||o,className:ie("transition-colors duration-200 ease-out disabled:opacity-100",n.trim()&&!o?"bg-accent text-accent-foreground hover:bg-accent/90":"bg-muted text-muted-foreground cursor-not-allowed"),children:e(o?"forgotPassword.sending":"forgotPassword.send")})}),d.jsx("div",{className:"text-center",children:d.jsx(Ns,{to:"/login",className:"text-sm underline-offset-2 hover:underline",children:e("forgotPassword.backToLogin")})})]})})})})})})}const az=8,lz=128;function OHe(){const{t:e,i18n:t}=tt(),n=pa(),[r]=j2(),s=r.get("token"),[i,o]=w.useState(""),[a,l]=w.useState(""),[u,h]=w.useState(!1),[p,m]=w.useState(!1),[b,y]=w.useState(null),[x,S]=w.useState(!1);if(!s)return d.jsx("div",{className:"flex min-h-svh w-full flex-col items-center justify-center bg-background p-4",children:d.jsx("div",{className:"w-full max-w-sm sm:max-w-md",children:d.jsx(Zn,{className:"overflow-hidden shadow-md",children:d.jsx(Xn,{className:"p-6 md:p-8",children:d.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:e("resetPassword.invalidLinkTitle")}),d.jsx("p",{className:"text-muted-foreground text-sm",children:e("resetPassword.invalidLink")}),d.jsx(Ns,{to:"/forgot-password",className:"text-sm underline-offset-2 hover:underline",children:e("resetPassword.requestNew")})]})})})})});const C=i.length>=az&&i.length<=lz&&i===a,N=async M=>{if(M.preventDefault(),i!==a){y(e("resetPassword.mismatch"));return}if(i.length<az){y(e("resetPassword.tooShort"));return}if(i.length>lz){y(e("resetPassword.tooLong"));return}y(null),S(!0);try{await $n.post("/auth/reset-password",{token:s,password:i,locale:t.language}),_n.success(e("resetPassword.success")),n("/login",{replace:!0})}catch(_){$n.isAxiosError(_)&&_.response?.status===400?y(e("resetPassword.invalidToken")):y(e("resetPassword.genericError")),S(!1)}};return d.jsx("div",{className:"flex min-h-svh w-full flex-col items-center justify-center bg-background p-4 sm:p-6 md:p-8",children:d.jsx("div",{className:"w-full max-w-sm sm:max-w-md",children:d.jsx(Zn,{className:"overflow-hidden shadow-md",children:d.jsx(Xn,{className:"p-6 md:p-8",children:d.jsx("form",{onSubmit:N,noValidate:!0,children:d.jsxs(a7,{children:[d.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:e("resetPassword.title")}),d.jsx("p",{className:"text-muted-foreground text-balance text-sm",children:e("resetPassword.desc")})]}),d.jsxs(pc,{children:[d.jsx(wp,{htmlFor:"rp-password",children:e("resetPassword.newPassword")}),d.jsxs("div",{className:"relative",children:[d.jsx(Xt,{id:"rp-password",type:u?"text":"password",autoComplete:"new-password",value:i,className:ie("pr-10",b?"border-destructive":""),onChange:M=>{o(M.target.value),y(null)}}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-sm",className:"absolute right-1 top-1/2 -translate-y-1/2 hover:bg-transparent",onClick:()=>h(M=>!M),"aria-label":e(u?"login.hidePassword":"login.showPassword"),children:d.jsx("span",{className:"inline-flex origin-center animate-[icon-swap_0.15s_ease-out]",children:u?d.jsx(fp,{className:"text-muted-foreground size-4"}):d.jsx(hp,{className:"text-muted-foreground size-4"})})})]})]}),d.jsxs(pc,{children:[d.jsx(wp,{htmlFor:"rp-confirm",children:e("resetPassword.confirmPassword")}),d.jsxs("div",{className:"relative",children:[d.jsx(Xt,{id:"rp-confirm",type:p?"text":"password",autoComplete:"new-password",value:a,className:ie("pr-10",b?"border-destructive":""),onChange:M=>{l(M.target.value),y(null)}}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-sm",className:"absolute right-1 top-1/2 -translate-y-1/2 hover:bg-transparent",onClick:()=>m(M=>!M),"aria-label":e(p?"login.hidePassword":"login.showPassword"),children:d.jsx("span",{className:"inline-flex origin-center animate-[icon-swap_0.15s_ease-out]",children:p?d.jsx(fp,{className:"text-muted-foreground size-4"}):d.jsx(hp,{className:"text-muted-foreground size-4"})})})]}),b&&d.jsx(l7,{children:b})]}),d.jsx(pc,{children:d.jsx(Oe,{type:"submit",disabled:!C||x,className:ie("transition-colors duration-200 ease-out disabled:opacity-100",C&&!x?"bg-accent text-accent-foreground hover:bg-accent/90":"bg-muted text-muted-foreground cursor-not-allowed"),children:e(x?"resetPassword.resetting":"resetPassword.reset")})}),d.jsx("div",{className:"text-center",children:d.jsx(Ns,{to:"/login",className:"text-sm underline-offset-2 hover:underline",children:e("forgotPassword.backToLogin")})})]})})})})})})}function DHe(){const e=pa(),[t,n]=w.useState(""),[r,s]=w.useState(""),[i,o]=w.useState(""),[a,l]=w.useState(""),[u,h]=w.useState(null),[p,m]=w.useState(!1);async function b(y){if(y.preventDefault(),h(null),i!==a){h("Passwords do not match.");return}if(i.length<8){h("Password must be at least 8 characters.");return}m(!0);try{await $n.post("/auth/setup",{email:r,password:i,name:t}),e("/login",{replace:!0})}catch(x){$n.isAxiosError(x)&&x.response?.data?.title?h(x.response.data.title):h("Setup failed. Please try again.")}finally{m(!1)}}return d.jsx("div",{className:"flex min-h-svh w-full items-center justify-center bg-background p-4",children:d.jsxs(Zn,{className:"w-full max-w-md",children:[d.jsxs(Tr,{className:"space-y-1",children:[d.jsx(Wr,{className:"text-2xl font-bold",children:"Welcome to BeechCMS"}),d.jsx(Aa,{children:"Create your admin account to get started. This screen appears only once."})]}),d.jsx(Xn,{children:d.jsxs("form",{onSubmit:b,className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(Es,{htmlFor:"name",children:"Name"}),d.jsx(Xt,{id:"name",placeholder:"Your name",value:t,onChange:y=>n(y.target.value),autoComplete:"name"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Es,{htmlFor:"email",children:"Email"}),d.jsx(Xt,{id:"email",type:"email",placeholder:"admin@example.com",value:r,onChange:y=>s(y.target.value),required:!0,autoComplete:"email"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Es,{htmlFor:"password",children:"Password"}),d.jsx(Xt,{id:"password",type:"password",placeholder:"Min. 8 characters",value:i,onChange:y=>o(y.target.value),required:!0,autoComplete:"new-password"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Es,{htmlFor:"confirm",children:"Confirm password"}),d.jsx(Xt,{id:"confirm",type:"password",placeholder:"Repeat password",value:a,onChange:y=>l(y.target.value),required:!0,autoComplete:"new-password"})]}),u&&d.jsx("p",{className:"text-sm text-destructive",children:u}),d.jsx(Oe,{type:"submit",className:"w-full",disabled:p,children:p?"Creating account…":"Create admin account"})]})})]})})}function jHe(){const[e,t]=w.useState(!1),[n,r]=w.useState(["root"]),[s,i]=w.useState(""),o=n.at(-1)??"root",a=w.useCallback(u=>{r(h=>[...h,u]),i("")},[]),l=w.useCallback(()=>{r(u=>u.length<=1?u:u.slice(0,-1)),i("")},[]);return w.useEffect(()=>{const u=h=>{if(h.key==="k"&&(h.metaKey||h.ctrlKey)){h.preventDefault(),t(p=>!p);return}if(h.key==="n"&&h.altKey&&!h.metaKey&&!h.ctrlKey){h.preventDefault(),t(!0),r(["root","create"]),i("");return}if(e){if(h.key==="Backspace"&&s===""&&n.length>1){h.preventDefault(),l();return}h.key==="Escape"&&n.length>1&&(h.preventDefault(),l())}};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,s,n.length,l]),w.useEffect(()=>{e||(i(""),r(["root"]))},[e]),{open:e,setOpen:t,pages:n,currentPage:o,pushPage:a,popPage:l,search:s,setSearch:i}}function IHe({seeds:e,pushPage:t,navigate:n,setOpen:r,theme:s,toggleTheme:i}){const{t:o}=tt(),a=l=>{n(l),r(!1)};return d.jsxs(d.Fragment,{children:[d.jsxs(Yd,{heading:o("commandPalette.navigate"),forceMount:!0,children:[d.jsxs(vo,{onSelect:()=>a("/"),children:[d.jsx(wz,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsx("span",{children:o("commandPalette.dashboard")})]}),d.jsxs(vo,{onSelect:()=>a("/media"),children:[d.jsx(Tg,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsx("span",{children:o("commandPalette.mediaLibrary")})]}),d.jsxs(vo,{onSelect:()=>a("/settings"),children:[d.jsx(Ag,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsx("span",{children:o("commandPalette.settings")})]})]}),d.jsx(tv,{}),d.jsxs(Yd,{heading:o("commandPalette.contents"),children:[e.slice(0,5).map(l=>{const u=d7(l.dashboard?.icon);return d.jsxs(vo,{onSelect:()=>a(`/content/${l.slug}`),keywords:[l.slug,"contenuto","lista"],children:[d.jsx(u,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsx("span",{children:o("commandPalette.goTo",{label:l.label})})]},l.slug)}),e.length>5&&d.jsxs(vo,{onSelect:()=>t("seeds"),children:[d.jsx(Qx,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsx("span",{children:o("commandPalette.allSeeds")})]})]}),d.jsx(tv,{}),d.jsx(Yd,{heading:o("commandPalette.create"),children:d.jsxs(vo,{onSelect:()=>t("create"),children:[d.jsx(Hi,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsx("span",{children:o("commandPalette.newContent")}),d.jsxs(IZ,{className:"flex items-center gap-0.5",children:[d.jsx("kbd",{className:"text-xs font-mono bg-muted text-muted-foreground px-1 rounded",children:"Alt"}),d.jsx("kbd",{className:"text-xs font-mono bg-muted text-muted-foreground px-1 rounded",children:"N"})]})]})}),d.jsx(tv,{}),d.jsx(Yd,{heading:o("commandPalette.tools"),children:d.jsxs(vo,{onSelect:i,keywords:["dark mode","light mode","tema","theme"],children:[s==="dark"?d.jsx(z6,{className:"size-4 shrink-0 text-muted-foreground"}):d.jsx(Cz,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsx("span",{children:o("commandPalette.changeTheme")})]})})]})}function cz({seeds:e,navigate:t,setOpen:n,mode:r}){const{t:s}=tt(),i=s(r==="create"?"commandPalette.chooseType":"commandPalette.chooseSeed");return d.jsx(Yd,{heading:i,children:e.map(o=>{const a=d7(o.dashboard?.icon);return d.jsxs(vo,{onSelect:()=>{const l=r==="create"?`/content/${o.slug}/create`:`/content/${o.slug}`;t(l),n(!1)},children:[d.jsx(a,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsxs("div",{className:"flex flex-col",children:[d.jsx("span",{children:o.label}),d.jsx("span",{className:"text-[10px] text-muted-foreground",children:o.slug})]})]},o.slug)})})}function zHe(e){const n=e.replace(/<(?!\/?mark\b)[^>]*>/gi,"").split(/(<mark>|<\/mark>)/gi),r=[];let s=!1,i=0;for(const o of n){if(o.toLowerCase()==="<mark>"){s=!0;continue}if(o.toLowerCase()==="</mark>"){s=!1;continue}o&&r.push(s?d.jsx("mark",{children:o},i++):o)}return r}function LHe({search:e,navigate:t,setOpen:n}){const{t:r}=tt(),s=UZ(e,300),{data:i,isLoading:o}=Ir({queryKey:["cmd-search",s],queryFn:async()=>(await Gt.get(`/search?q=${encodeURIComponent(s)}&limit=8`)).data,enabled:s.length>=2,staleTime:3e4}),a=i?.items??[];return e.length<2?null:o?d.jsx("div",{className:"px-4 py-6 text-sm text-center text-muted-foreground",children:r("commandPalette.searching")}):d.jsxs(Yd,{heading:r("commandPalette.searchResults"),children:[a.map(l=>d.jsxs(vo,{onSelect:()=>{t(`/content/${l.schema_slug}/${l.id}`),n(!1)},children:[d.jsx(nv,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsxs("div",{className:"flex flex-col",children:[d.jsx("span",{className:"font-medium",children:l.title}),l.excerpt&&d.jsx("span",{className:"text-xs text-muted-foreground line-clamp-1",children:zHe(l.excerpt)}),d.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/70",children:[l.schema_slug," · ",l.status]})]})]},l.id)),a.length===0&&!o&&d.jsx("div",{className:"px-4 py-6 text-sm text-center text-muted-foreground",children:r("commandPalette.noSearchResults")})]})}function PHe(){const{t:e}=tt(),t=Ec(n=>n.search);return d.jsx(k8,{children:t.length===0?e("commandPalette.noResults"):d.jsxs(d.Fragment,{children:[e("commandPalette.noResults")," ",d.jsxs("span",{className:"font-medium",children:['"',t,'"']})]})})}function $He({pages:e,popPage:t}){return e.length<=1?null:d.jsx("div",{className:"flex items-center gap-2 px-4 pt-4 pb-0 overflow-x-auto",children:e.map((n,r)=>d.jsxs(w.Fragment,{children:[d.jsx(gi,{variant:"secondary",className:ie("cursor-pointer hover:bg-secondary/80 capitalize shrink-0",r===e.length-1&&"opacity-60 pointer-events-none"),onClick:()=>{const s=e.length-1-r;for(let i=0;i<s;i++)t()},children:n}),r<e.length-1&&d.jsx(xc,{className:"size-3 text-muted-foreground shrink-0"})]},n+r))})}function FHe(){const{t:e}=tt(),t=pa(),{resolvedTheme:n,setTheme:r}=Zx(),{open:s,setOpen:i,pages:o,currentPage:a,pushPage:l,popPage:u,search:h,setSearch:p}=jHe(),m=Object.values(h7),b={root:e("commandPalette.placeholderRoot"),seeds:e("commandPalette.placeholderSeeds"),create:e("commandPalette.placeholderCreate"),"search-results":e("commandPalette.placeholderSearch")},y=w.useCallback(()=>{r(n==="dark"?"light":"dark"),i(!1)},[n,r,i]);return d.jsxs(d.Fragment,{children:[d.jsx("style",{children:"[cmdk-list]{height:var(--cmdk-list-height);transition:height 100ms ease}"}),d.jsxs(qFe,{open:s,onOpenChange:i,"aria-label":e("commandPalette.ariaLabel"),children:[d.jsxs("div",{className:"flex flex-col",children:[d.jsx($He,{pages:o,popPage:u}),d.jsx(S8,{placeholder:b[a],value:h,onValueChange:p})]}),d.jsxs(C8,{className:"max-h-[400px]",children:[d.jsx(PHe,{}),a==="root"&&d.jsx(IHe,{seeds:m,pushPage:l,navigate:t,setOpen:i,theme:n,toggleTheme:y}),a==="seeds"&&d.jsx(cz,{seeds:m,navigate:t,setOpen:i,mode:"navigate"}),a==="create"&&d.jsx(cz,{seeds:m,navigate:t,setOpen:i,mode:"create"}),a==="search-results"&&d.jsx(LHe,{search:h,seeds:m,navigate:t,setOpen:i})]}),a!=="root"&&d.jsx("div",{className:"p-3 border-t text-[10px] text-muted-foreground bg-muted/20",children:e("commandPalette.backHint")})]})]})}function BHe(){return d.jsx("div",{className:"flex min-h-svh w-full items-center justify-center bg-background",children:d.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}function HHe(){const e=pa();return w.useEffect(()=>{$n.get("/auth/setup").then(({data:t})=>{t.needsSetup&&e("/setup",{replace:!0})}).catch(()=>{})},[e]),d.jsx("div",{className:"flex min-h-svh w-full flex-col items-center justify-center bg-background p-4 sm:p-6 md:p-8 lg:p-10 xl:p-12",children:d.jsx("div",{className:"w-full max-w-sm sm:max-w-md md:max-w-2xl lg:max-w-4xl xl:max-w-6xl 2xl:max-w-7xl",children:d.jsx(I1e,{})})})}function Dd({children:e}){const{status:t}=e1();return t==="loading"?d.jsx(BHe,{}):t==="unauthenticated"?d.jsx(Q0e,{to:"/login",replace:!0}):d.jsx(d.Fragment,{children:e})}function UHe(){return d.jsxs(d.Fragment,{children:[d.jsx(FHe,{}),d.jsx(J0e,{})]})}const VHe=Eme([{element:d.jsx(UHe,{}),errorElement:d.jsx(THe,{}),children:[{path:"/login",element:d.jsx(HHe,{})},{path:"/setup",element:d.jsx(DHe,{})},{path:"/forgot-password",element:d.jsx(RHe,{})},{path:"/reset-password",element:d.jsx(OHe,{})},{path:"/",element:d.jsx(Dd,{children:d.jsx(MHe,{})})},{path:"/content/:slug/create",element:d.jsx(Dd,{children:d.jsx(rz,{})})},{path:"/content/:slug/:id",element:d.jsx(Dd,{children:d.jsx(rz,{})})},{path:"/content/:slug",element:d.jsx(Dd,{children:d.jsx(LBe,{})})},{path:"/settings",element:d.jsx(Dd,{children:d.jsx(Vbe,{})})},{path:"/test-fields",element:d.jsx(Dd,{children:d.jsx(WBe,{})})},{path:"/widget-lab",element:d.jsx(Dd,{children:d.jsx(_He,{})})}]}],{basename:"/admin"});function qHe(){return d.jsx(O1e,{children:d.jsx(Lme,{router:VHe})})}sJ.createRoot(document.getElementById("root")).render(d.jsx(w.StrictMode,{children:d.jsx(xfe,{client:Ofe,children:d.jsx(lJ,{attribute:"class",defaultTheme:"system",enableSystem:!0,disableTransitionOnChange:!0,enableColorScheme:!0,storageKey:"beech-theme",children:d.jsxs(kB,{children:[d.jsx(qHe,{}),d.jsx(qre,{})]})})})}));
629
+ ]`,y={scope:"string",variants:[h,u,p,m]},x={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},S=["false","null","true"],C=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],N=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],_={keyword:C,literal:(re=>{const oe=[];return re.forEach(F=>{oe.push(F),F.toLowerCase()===F?oe.push(F.toUpperCase()):oe.push(F.toLowerCase())}),oe})(S),built_in:N},T=re=>re.map(oe=>oe.replace(/\|\d+$/,"")),R={variants:[{match:[/new/,t.concat(b,"+"),t.concat("(?!",T(N).join("\\b|"),"\\b)"),s],scope:{1:"keyword",4:"title.class"}}]},D=t.concat(r,"\\b(?!\\()"),j={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),D],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[s,t.concat(/::/,t.lookahead(/(?!class\b)/)),D],scope:{1:"title.class",3:"variable.constant"}},{match:[s,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[s,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},L={scope:"attr",match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},V={relevance:0,begin:/\(/,end:/\)/,keywords:_,contains:[L,o,j,e.C_BLOCK_COMMENT_MODE,y,x,R]},q={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",T(C).join("\\b|"),"|",T(N).join("\\b|"),"\\b)"),r,t.concat(b,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[V]};V.contains.push(q);const X=[L,j,e.C_BLOCK_COMMENT_MODE,y,x,R],ee={begin:t.concat(/#\[\s*\\?/,t.either(s,i)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:S,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:S,keyword:["new","array"]},contains:["self",...X]},...X,{scope:"meta",variants:[{match:s},{match:i}]}]};return{case_insensitive:!1,keywords:_,contains:[ee,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},a,{scope:"variable.language",match:/\$this\b/},o,q,j,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},R,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:_,contains:["self",ee,o,j,e.C_BLOCK_COMMENT_MODE,y,x]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},y,x]}}function Wze(e){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function Kze(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function Yze(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],a={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},l={className:"meta",begin:/^(>>>|\.\.\.) /},u={className:"subst",begin:/\{/,end:/\}/,keywords:a,illegal:/#/},h={begin:/\{\{/,relevance:0},p={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,l],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,l],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,l,h,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,l,h,u]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,h,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,h,u]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},m="[0-9](_?[0-9])*",b=`(\\b(${m}))?\\.(${m})|\\b(${m})\\.`,y=`\\b|${r.join("|")}`,x={className:"number",relevance:0,variants:[{begin:`(\\b(${m})|(${b}))[eE][+-]?(${m})[jJ]?(?=${y})`},{begin:`(${b})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${y})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${y})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${y})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${y})`},{begin:`\\b(${m})[jJ](?=${y})`}]},S={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:a,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},C={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:["self",l,x,p,e.HASH_COMMENT_MODE]}]};return u.contains=[p,x,l],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:a,illegal:/(<\/|\?)|=>/,contains:[l,x,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},p,S,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[C]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[x,C,p]}]}}function Zze(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function Xze(e){const t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),s=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,i=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[s,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[i,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:s},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:i},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function Qze(e){const t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),s=t.concat(r,/(::\w+)*/),o={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},a={className:"doctag",begin:"@[A-Za-z]+"},l={begin:"#<",end:">"},u=[e.COMMENT("#","$",{contains:[a]}),e.COMMENT("^=begin","^=end",{contains:[a],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],h={className:"subst",begin:/#\{/,end:/\}/,keywords:o},p={className:"string",contains:[e.BACKSLASH_ESCAPE,h],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,h]})]}]},m="[1-9](_?[0-9])*|0",b="[0-9](_?[0-9])*",y={className:"number",relevance:0,variants:[{begin:`\\b(${m})(\\.(${b}))?([eE][+-]?(${b})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},x={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:o}]},R=[p,{variants:[{match:[/class\s+/,s,/\s+<\s+/,s]},{match:[/\b(class|module)\s+/,s]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:o},{match:[/(include|extend)\s+/,s],scope:{2:"title.class"},keywords:o},{relevance:0,match:[s,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[x]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[p,{begin:n}],relevance:0},y,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:o},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,h],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(l,u),relevance:0}].concat(l,u);h.contains=R,x.contains=R;const V=[{begin:/^\s*=>/,starts:{end:"$",contains:R}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:o,contains:R}}];return u.unshift(l),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:o,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(V).concat(u).concat(R)}}function Jze(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),s=t.concat(n,e.IDENT_RE),i={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,s,t.lookahead(/\s*\(/))},o="([ui](8|16|32|64|128|size)|f(32|64))?",a=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],l=["true","false","Some","None","Ok","Err"],u=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],h=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:h,keyword:a,literal:l,built_in:u},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+o},{begin:"\\b0o([0-7_]+)"+o},{begin:"\\b0x([A-Fa-f0-9_]+)"+o},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+o}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:u,type:h}},{className:"punctuation",begin:"->"},i]}}const eLe=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),tLe=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],nLe=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],rLe=[...tLe,...nLe],sLe=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),iLe=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),oLe=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),aLe=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function lLe(e){const t=eLe(e),n=oLe,r=iLe,s="@[a-z-]+",i="and or not only",a={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+rLe.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+r.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},a,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+aLe.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[t.BLOCK_COMMENT,a,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:s,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:sLe.join(" ")},contains:[{begin:s,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},a,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}function cLe(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function uLe(e){const t=e.regex,n=e.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],o=["double precision","large object","with timezone","without timezone"],a=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],l=["add","asc","collation","desc","final","first","last","view"],u=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],h=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],p=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],m=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],b=h,y=[...u,...l].filter(T=>!h.includes(T)),x={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},S={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},C={match:t.concat(/\b/,t.either(...b),/\s*\(/),relevance:0,keywords:{built_in:b}};function N(T){return t.concat(/\b/,t.either(...T.map(R=>R.replace(/\s+/,"\\s+"))),/\b/)}const M={scope:"keyword",match:N(m),relevance:0};function _(T,{exceptions:R,when:D}={}){const j=D;return R=R||[],T.map(L=>L.match(/\|\d+$/)||R.includes(L)?L:j(L)?`${L}|0`:L)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:_(y,{when:T=>T.length<3}),literal:i,type:a,built_in:p},contains:[{scope:"type",match:N(o)},M,C,x,r,s,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,S]}}function LY(e){return e?typeof e=="string"?e:e.source:null}function gm(e){return hr("(?=",e,")")}function hr(...e){return e.map(n=>LY(n)).join("")}function dLe(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function Mi(...e){return"("+(dLe(e).capture?"":"?:")+e.map(r=>LY(r)).join("|")+")"}const a8=e=>hr(/\b/,e,/\w$/.test(e)?/\b/:/\B/),fLe=["Protocol","Type"].map(a8),mI=["init","self"].map(a8),hLe=["Any","Self"],F3=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],gI=["false","nil","true"],pLe=["assignment","associativity","higherThan","left","lowerThan","none","right"],mLe=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],bI=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],PY=Mi(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),$Y=Mi(PY,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),B3=hr(PY,$Y,"*"),FY=Mi(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),Ix=Mi(FY,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),Ya=hr(FY,Ix,"*"),Ay=hr(/[A-Z]/,Ix,"*"),gLe=["attached","autoclosure",hr(/convention\(/,Mi("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",hr(/objc\(/,Ya,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],bLe=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function yLe(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],s={match:[/\./,Mi(...fLe,...mI)],className:{2:"keyword"}},i={match:hr(/\./,Mi(...F3)),relevance:0},o=F3.filter(xt=>typeof xt=="string").concat(["_|0"]),a=F3.filter(xt=>typeof xt!="string").concat(hLe).map(a8),l={variants:[{className:"keyword",match:Mi(...a,...mI)}]},u={$pattern:Mi(/\b\w+/,/#\w+/),keyword:o.concat(mLe),literal:gI},h=[s,i,l],p={match:hr(/\./,Mi(...bI)),relevance:0},m={className:"built_in",match:hr(/\b/,Mi(...bI),/(?=\()/)},b=[p,m],y={match:/->/,relevance:0},x={className:"operator",relevance:0,variants:[{match:B3},{match:`\\.(\\.|${$Y})+`}]},S=[y,x],C="([0-9]_*)+",N="([0-9a-fA-F]_*)+",M={className:"number",relevance:0,variants:[{match:`\\b(${C})(\\.(${C}))?([eE][+-]?(${C}))?\\b`},{match:`\\b0x(${N})(\\.(${N}))?([pP][+-]?(${C}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},_=(xt="")=>({className:"subst",variants:[{match:hr(/\\/,xt,/[0\\tnr"']/)},{match:hr(/\\/,xt,/u\{[0-9a-fA-F]{1,8}\}/)}]}),T=(xt="")=>({className:"subst",match:hr(/\\/,xt,/[\t ]*(?:[\r\n]|\r\n)/)}),R=(xt="")=>({className:"subst",label:"interpol",begin:hr(/\\/,xt,/\(/),end:/\)/}),D=(xt="")=>({begin:hr(xt,/"""/),end:hr(/"""/,xt),contains:[_(xt),T(xt),R(xt)]}),j=(xt="")=>({begin:hr(xt,/"/),end:hr(/"/,xt),contains:[_(xt),R(xt)]}),L={className:"string",variants:[D(),D("#"),D("##"),D("###"),j(),j("#"),j("##"),j("###")]},V=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],q={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:V},X=xt=>{const Jt=hr(xt,/\//),fn=hr(/\//,xt);return{begin:Jt,end:fn,contains:[...V,{scope:"comment",begin:`#(?!.*${fn})`,end:/$/}]}},ee={scope:"regexp",variants:[X("###"),X("##"),X("#"),q]},re={match:hr(/`/,Ya,/`/)},oe={className:"variable",match:/\$\d+/},F={className:"variable",match:`\\$${Ix}+`},se=[re,oe,F],le={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:bLe,contains:[...S,M,L]}]}},W={scope:"keyword",match:hr(/@/,Mi(...gLe),gm(Mi(/\(/,/\s+/)))},Q={scope:"meta",match:hr(/@/,Ya)},H=[le,W,Q],U={match:gm(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:hr(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,Ix,"+")},{className:"type",match:Ay,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:hr(/\s+&\s+/,gm(Ay)),relevance:0}]},Z={begin:/</,end:/>/,keywords:u,contains:[...r,...h,...H,y,U]};U.contains.push(Z);const he={match:hr(Ya,/\s*:/),keywords:"_|0",relevance:0},fe={begin:/\(/,end:/\)/,relevance:0,keywords:u,contains:["self",he,...r,ee,...h,...b,...S,M,L,...se,...H,U]},ye={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,U]},ge={begin:Mi(gm(hr(Ya,/\s*:/)),gm(hr(Ya,/\s+/,Ya,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:Ya}]},Ee={begin:/\(/,end:/\)/,keywords:u,contains:[ge,...r,...h,...S,M,L,...H,U,fe],endsParent:!0,illegal:/["']/},Ae={match:[/(func|macro)/,/\s+/,Mi(re.match,Ya,B3)],className:{1:"keyword",3:"title.function"},contains:[ye,Ee,t],illegal:[/\[/,/%/]},Qe={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[ye,Ee,t],illegal:/\[|%/},rt={match:[/operator/,/\s+/,B3],className:{1:"keyword",3:"title"}},ct={begin:[/precedencegroup/,/\s+/,Ay],className:{1:"keyword",3:"title"},contains:[U],keywords:[...pLe,...gI],end:/}/},He={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},_e={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},nn={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,Ya,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:u,contains:[ye,...h,{begin:/:/,end:/\{/,keywords:u,contains:[{scope:"title.class.inherited",match:Ay},...h],relevance:0}]};for(const xt of L.variants){const Jt=xt.contains.find(hn=>hn.label==="interpol");Jt.keywords=u;const fn=[...h,...b,...S,M,L,...se];Jt.contains=[...fn,{begin:/\(/,end:/\)/,contains:["self",...fn]}]}return{name:"Swift",keywords:u,contains:[...r,Ae,Qe,He,_e,nn,rt,ct,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},ee,...h,...b,...S,M,L,...se,...H,U,fe]}}const zx="[A-Za-z$_][0-9A-Za-z$_]*",BY=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],HY=["true","false","null","undefined","NaN","Infinity"],UY=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],VY=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],qY=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],GY=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],WY=[].concat(qY,UY,VY);function vLe(e){const t=e.regex,n=(le,{after:W})=>{const Q="</"+le[0].slice(1);return le.input.indexOf(Q,W)!==-1},r=zx,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(le,W)=>{const Q=le[0].length+le.index,H=le.input[Q];if(H==="<"||H===","){W.ignoreMatch();return}H===">"&&(n(le,{after:Q})||W.ignoreMatch());let U;const Z=le.input.substring(Q);if(U=Z.match(/^\s*=/)){W.ignoreMatch();return}if((U=Z.match(/^\s+extends\s+/))&&U.index===0){W.ignoreMatch();return}}},a={$pattern:zx,keyword:BY,literal:HY,built_in:WY,"variable.language":GY},l="[0-9](_?[0-9])*",u=`\\.(${l})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${h})((${u})|\\.)?|(${u}))[eE][+-]?(${l})\\b`},{begin:`\\b(${h})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},m={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},b={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"css"}},x={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"graphql"}},S={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,m]},N={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},M=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,b,y,x,S,{match:/\$\d+/},p];m.contains=M.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(M)});const _=[].concat(N,m.contains),T=_.concat([{begin:/(\s*)\(/,end:/\)/,keywords:a,contains:["self"].concat(_)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:T},D={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},j={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...UY,...VY]}},L={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},V={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},q={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function X(le){return t.concat("(?!",le.join("|"),")")}const ee={match:t.concat(/\b/,X([...qY,"super","import"].map(le=>`${le}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},re={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},oe={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},F="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",se={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(F)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:T,CLASS_REFERENCE:j},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),L,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,b,y,x,S,N,{match:/\$\d+/},p,j,{scope:"attr",match:r+t.lookahead(":"),relevance:0},se,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,e.REGEXP_MODE,{className:"function",begin:F,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:T}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},V,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[R,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},re,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},ee,q,D,oe,{match:/\$[(.]/}]}}function xLe(e){const t=e.regex,n=vLe(e),r=zx,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},o={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},a={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},l=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],u={$pattern:zx,keyword:BY.concat(l),literal:HY,built_in:WY.concat(s),"variable.language":GY},h={className:"meta",begin:"@"+r},p=(x,S,C)=>{const N=x.contains.findIndex(M=>M.label===S);if(N===-1)throw new Error("can not find mode to replace");x.contains.splice(N,1,C)};Object.assign(n.keywords,u),n.exports.PARAMS_CONTAINS.push(h);const m=n.contains.find(x=>x.scope==="attr"),b=Object.assign({},m,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,m,b]),n.contains=n.contains.concat([h,i,o,b]),p(n,"shebang",e.SHEBANG()),p(n,"use_strict",a);const y=n.contains.find(x=>x.label==="func.def");return y.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function wLe(e){const t=e.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},s=/\d{1,2}\/\d{1,2}\/\d{4}/,i=/\d{4}-\d{1,2}-\d{1,2}/,o=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,a=/\d{1,2}(:\d{1,2}){1,2}/,l={className:"literal",variants:[{begin:t.concat(/# */,t.either(i,s),/ *#/)},{begin:t.concat(/# */,a,/ *#/)},{begin:t.concat(/# */,o,/ *#/)},{begin:t.concat(/# */,t.either(i,s),/ +/,t.either(o,a),/ *#/)}]},u={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},h={className:"label",begin:/^\w+:/},p=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),m=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,r,l,u,h,p,m,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[m]}]}}function SLe(e){e.regex;const t=e.COMMENT(/\(;/,/;\)/);t.contains.push("self");const n=e.COMMENT(/;;/,/$/),r=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],s={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},i={className:"variable",begin:/\$[\w_]+/},o={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},a={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},l={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},u={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:r},contains:[n,t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},i,o,s,e.QUOTE_STRING_MODE,l,u,a]}}function CLe(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(i,{begin:/\(/,end:/\)/}),a=e.inherit(e.APOS_STRING_MODE,{className:"string"}),l=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),u={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,l,a,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,o,l,a]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[l]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[u],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[u],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:u}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function kLe(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},s={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},i={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},o={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,s]},a=e.inherit(o,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),m={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},b={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},y={begin:/\{/,end:/\}/,contains:[b],illegal:"\\n",relevance:0},x={begin:"\\[",end:"\\]",contains:[b],illegal:"\\n",relevance:0},S=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},m,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},y,x,i,o],C=[...S];return C.pop(),C.push(a),b.contains=C,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:S}}const ELe={arduino:oze,bash:aze,c:lze,cpp:cze,csharp:uze,css:vze,diff:xze,go:wze,graphql:Sze,ini:Cze,java:kze,javascript:Tze,json:Aze,kotlin:Oze,less:Fze,lua:Bze,makefile:Hze,markdown:Uze,objectivec:Vze,perl:qze,php:Gze,"php-template":Wze,plaintext:Kze,python:Yze,"python-repl":Zze,r:Xze,ruby:Qze,rust:Jze,scss:lLe,shell:cLe,sql:uLe,swift:yLe,typescript:xLe,vbnet:wLe,wasm:SLe,xml:CLe,yaml:kLe},yI={},NLe="hljs-";function MLe(e){const t=TY.newInstance();return e&&i(e),{highlight:n,highlightAuto:r,listLanguages:s,register:i,registerAlias:o,registered:a};function n(l,u,h){const p=h||yI,m=typeof p.prefix=="string"?p.prefix:NLe;if(!t.getLanguage(l))throw new Error("Unknown language: `"+l+"` is not registered");t.configure({__emitter:_Le,classPrefix:m});const b=t.highlight(u,{ignoreIllegals:!0,language:l});if(b.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:b.errorRaised});const y=b._emitter.root,x=y.data;return x.language=b.language,x.relevance=b.relevance,y}function r(l,u){const p=(u||yI).subset||s();let m=-1,b=0,y;for(;++m<p.length;){const x=p[m];if(!t.getLanguage(x))continue;const S=n(x,l,u);S.data&&S.data.relevance!==void 0&&S.data.relevance>b&&(b=S.data.relevance,y=S)}return y||{type:"root",children:[],data:{language:void 0,relevance:b}}}function s(){return t.listLanguages()}function i(l,u){if(typeof l=="string")t.registerLanguage(l,u);else{let h;for(h in l)Object.hasOwn(l,h)&&t.registerLanguage(h,l[h])}}function o(l,u){if(typeof l=="string")t.registerAliases(typeof u=="string"?u:[...u],{languageName:l});else{let h;for(h in l)if(Object.hasOwn(l,h)){const p=l[h];t.registerAliases(typeof p=="string"?p:[...p],{languageName:h})}}}function a(l){return!!t.getLanguage(l)}}class _Le{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],s=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):r.children.push(...s)}openNode(t){const n=this,r=t.split(".").map(function(o,a){return a?o+"_".repeat(a):n.options.classPrefix+o}),s=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};s.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const TLe=sze.extend({addOptions(){return{...this.parent?.(),lowlight:MLe(ELe),defaultLanguage:null,HTMLAttributes:{class:"block-node"},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,enableTabIndentation:!1,tabSize:4}}}),ALe=yY.extend({addProseMirrorPlugins(){return[...this.parent?.()||[],new Wn({props:{handleKeyDown:(e,t)=>(t.key==="Enter"&&this.editor.commands.unsetColor(),!1)}})]}}),RLe=yW.extend({addKeyboardShortcuts(){return{"Mod-Alt--":()=>this.editor.commands.insertContent({type:this.name})}}});function OLe({initialWidth:e,initialHeight:t,contentWidth:n,contentHeight:r,gridInterval:s,minWidth:i,minHeight:o,maxWidth:a,onDimensionsChange:l}){const[u,h]=w.useState({width:Math.max(e??i,i),height:Math.max(t??o,o)}),[p,m]=w.useState(1/0),[b,y]=w.useState(0),[x,S]=w.useState(u),[C,N]=w.useState(),M=w.useCallback((j,L)=>{const V=Math.max(i,Math.min(n??i,s/100*L));return Math.min(L,Math.max(j,V))},[s,n,i]),_=w.useCallback(j=>{j.preventDefault();const L=(C==="left"?b-j.pageX:j.pageX-b)*2,V=s/100*p,q=x.width+L,X=Math.round(q/V)*V,ee=M(X,p),re=r&&n?r/n:1;h({width:Math.max(ee,i),height:Math.max(n?ee*re:r??o,o)})},[M,C,p,b,s,r,n,x.width,i,o]),T=w.useCallback(j=>{j.preventDefault(),j.stopPropagation(),y(0),N(void 0),l?.(u)},[l,u]),R=w.useCallback(j=>{j.key==="Escape"&&(j.preventDefault(),j.stopPropagation(),h({width:Math.max(x.width,i),height:Math.max(x.height,o)}),N(void 0))},[x,i,o]),D=w.useCallback(j=>L=>{L.preventDefault(),L.stopPropagation(),m(a),S({width:Math.max(M(u.width,a),i),height:Math.max(u.height,o)}),y(L.pageX),N(j)},[a,M,u.width,u.height,i,o]);return w.useEffect(()=>{if(C)return document.addEventListener("keydown",R),document.addEventListener("pointermove",_),document.addEventListener("pointerup",T),()=>{document.removeEventListener("keydown",R),document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",T)}},[C,R,_,T]),{initiateResize:D,isResizing:!!C,updateDimensions:h,currentWidth:Math.max(u.width,i),currentHeight:Math.max(u.height,o)}}const c6=({ref:e,className:t,isResizing:n=!1,...r})=>d.jsx("div",{className:ie("absolute top-1/2 h-10 max-h-full w-1.5 -translate-y-1/2 transform cursor-col-resize rounded border border-solid border-[var(--mt-transparent-foreground)] bg-[var(--mt-bg-secondary)] p-px transition-all","opacity-0 [backdrop-filter:saturate(1.8)_blur(20px)]",{"opacity-80":n,"group-hover/node-image:opacity-80":!n},"before:absolute before:inset-y-0 before:-right-1 before:-left-1",t),ref:e,...r});c6.displayName="ResizeHandle";function DLe(){return te.createElement("svg",{"aria-hidden":"true","data-rmiz-btn-unzoom-icon":!0,fill:"currentColor",focusable:"false",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},te.createElement("path",{d:"M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z"}))}function jLe(){return te.createElement("svg",{"aria-hidden":"true","data-rmiz-btn-zoom-icon":!0,fill:"currentColor",focusable:"false",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},te.createElement("path",{d:"M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z"}))}function ILe(e){return typeof Element>"u"?!1:e instanceof Element}const Lx=(e,t)=>ILe(t)&&t.tagName.toUpperCase()===e,l8=e=>Lx("DIV",e)||Lx("SPAN",e),Px=e=>Lx("IMG",e),vI=e=>e.complete&&e.naturalHeight!==0,Qy=e=>Lx("SVG",e),KY=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),zLe=({containerHeight:e,containerWidth:t,offset:n,targetHeight:r,targetWidth:s})=>{const i=KY({height:r,offset:n,width:s}),o=s>r?s/t:r/e;return i>1?o:i*o},sf=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:s,targetWidth:i})=>e===0||t===0?1:!n&&s!==0&&i!==0?zLe({containerHeight:e,containerWidth:t,offset:r,targetHeight:s,targetWidth:i}):KY({height:e,offset:r,width:t}),LLe=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,xI=e=>{if(e!==null){if(Px(e))return e.currentSrc===""?void 0:e.currentSrc;if(l8(e)){const{backgroundImage:t}=window.getComputedStyle(e);if(t!=="")return LLe.exec(t)?.[1]}}},PLe=e=>{if(e!==null)return Px(e)?e.alt:e.getAttribute("aria-label")??void 0},$Le=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:s,offset:i,targetHeight:o,targetWidth:a})=>{const l=sf({containerHeight:e,containerWidth:r,hasScalableSrc:s,offset:i,targetHeight:o,targetWidth:a});return{top:n,left:t,width:r*l,height:e*l,transform:`translate(0,0) scale(${1/l})`}},Yo=({position:e,relativeNum:t})=>{const n=parseFloat(e);return e.endsWith("%")?t*n/100:n},FLe=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:s,objectFit:i,objectPosition:o,offset:a,targetHeight:l,targetWidth:u})=>{let h=i;if(h==="scale-down"&&(u<=r&&l<=e?h="none":h="contain"),h==="cover"||h==="contain"){const p=r/u,m=e/l,b=h==="cover"?Math.max(p,m):Math.min(p,m),[y="50%",x="50%"]=o.split(" "),S=Yo({position:y,relativeNum:r-u*b}),C=Yo({position:x,relativeNum:e-l*b}),N=sf({containerHeight:l*b,containerWidth:u*b,hasScalableSrc:s,offset:a,targetHeight:l,targetWidth:u});return{top:n+C,left:t+S,width:u*b*N,height:l*b*N,transform:`translate(0,0) scale(${1/N})`}}else if(h==="none"){const[p="50%",m="50%"]=o.split(" "),b=Yo({position:p,relativeNum:r-u}),y=Yo({position:m,relativeNum:e-l}),x=sf({containerHeight:l,containerWidth:u,hasScalableSrc:s,offset:a,targetHeight:l,targetWidth:u});return{top:n+y,left:t+b,width:u*x,height:l*x,transform:`translate(0,0) scale(${1/x})`}}else if(h==="fill"){const p=r/u,m=e/l,b=Math.max(p,m),y=sf({containerHeight:l*b,containerWidth:u*b,hasScalableSrc:s,offset:a,targetHeight:l,targetWidth:u});return{width:r*y,height:e*y,transform:`translate(0,0) scale(${1/y})`}}else return{}},BLe=({backgroundPosition:e,backgroundSize:t,containerHeight:n,containerLeft:r,containerTop:s,containerWidth:i,hasScalableSrc:o,offset:a,targetHeight:l,targetWidth:u})=>{if(t==="cover"||t==="contain"){const h=i/u,p=n/l,m=t==="cover"?Math.max(h,p):Math.min(h,p),[b="50%",y="50%"]=e.split(" "),x=Yo({position:b,relativeNum:i-u*m}),S=Yo({position:y,relativeNum:n-l*m}),C=sf({containerHeight:l*m,containerWidth:u*m,hasScalableSrc:o,offset:a,targetHeight:l,targetWidth:u});return{top:s+S,left:r+x,width:u*m*C,height:l*m*C,transform:`translate(0,0) scale(${1/C})`}}else if(t==="auto"){const[h="50%",p="50%"]=e.split(" "),m=Yo({position:h,relativeNum:i-u}),b=Yo({position:p,relativeNum:n-l}),y=sf({containerHeight:l,containerWidth:u,hasScalableSrc:o,offset:a,targetHeight:l,targetWidth:u});return{top:s+b,left:r+m,width:u*y,height:l*y,transform:`translate(0,0) scale(${1/y})`}}else{const[h="50%",p="50%"]=t.split(" "),m=Yo({position:h,relativeNum:i}),b=Yo({position:p,relativeNum:n}),y=m/u,x=b/l,S=Math.min(y,x),[C="50%",N="50%"]=e.split(" "),M=Yo({position:C,relativeNum:i-u*S}),_=Yo({position:N,relativeNum:n-l*S}),T=sf({containerHeight:l*S,containerWidth:u*S,hasScalableSrc:o,offset:a,targetHeight:l,targetWidth:u});return{top:s+_,left:r+M,width:u*S*T,height:l*S*T,transform:`translate(0,0) scale(${1/T})`}}},HLe=/\.svg$/i,ULe=({hasZoomImg:e,imgSrc:t,isSvg:n,isZoomed:r,loadedImgEl:s,offset:i,shouldRefresh:o,targetEl:a})=>{const l=n||t?.slice(0,18)==="data:image/svg+xml"||e||t!==void 0&&HLe.test(t),u=a.getBoundingClientRect(),h=window.getComputedStyle(a),p=s!=null&&l8(a),m=s!=null&&!p,b=s!=null&&s.naturalHeight!==0?s.naturalHeight:u.height,y=s!=null&&s.naturalWidth!==0?s.naturalWidth:u.width,x=$Le({containerHeight:u.height,containerLeft:u.left,containerTop:u.top,containerWidth:u.width,hasScalableSrc:l,offset:i,targetHeight:b,targetWidth:y}),S=m?FLe({containerHeight:u.height,containerLeft:u.left,containerTop:u.top,containerWidth:u.width,hasScalableSrc:l,objectFit:h.objectFit,objectPosition:h.objectPosition,offset:i,targetHeight:b,targetWidth:y}):void 0,C=p?BLe({backgroundPosition:h.backgroundPosition,backgroundSize:h.backgroundSize,containerHeight:u.height,containerLeft:u.left,containerTop:u.top,containerWidth:u.width,hasScalableSrc:l,offset:i,targetHeight:b,targetWidth:y}):void 0,N={...x,...S,...C};if(r){const M=window.innerWidth/2,_=window.innerHeight/2,T=parseFloat(String(N.left??0))+parseFloat(String(N.width??0))/2,R=parseFloat(String(N.top??0))+parseFloat(String(N.height??0))/2,D=M-T,j=_-R;o&&(N.transitionDuration="0.01ms"),N.transform=`translate(${D}px,${j}px) scale(1)`}return N},H3=e=>{if(e==null)return{};if(Qy(e)){const{parentElement:t}=e,n=e.getBoundingClientRect();if(t==null)return{height:n.height,left:n.left,width:n.width,top:n.top};{const r=t.getBoundingClientRect();return{height:n.height,left:r.left-n.left,top:r.top-n.top,width:n.width}}}else return{height:e.offsetHeight,left:e.offsetLeft,width:e.offsetWidth,top:e.offsetTop}},VLe=e=>{const t="-zoom",n=["clip-path","fill","mask","marker-start","marker-mid","marker-end"],r=new Map;if(e.hasAttribute("id")){const{id:s}=e,i=s+t;r.set(s,i);const o=e;o.id=i}e.querySelectorAll("[id]").forEach(s=>{const{id:i}=s,o=i+t;r.set(i,o);const a=s;a.id=o}),r.forEach((s,i)=>{const o=`url(#${i})`,a=`url(#${s})`,l=n.map(u=>`[${u}="${o}"]`).join(", ");e.querySelectorAll(l).forEach(u=>{n.forEach(h=>{u.getAttribute(h)===o&&u.setAttribute(h,a)})})}),e.querySelectorAll("style").forEach(s=>{r.forEach((i,o)=>{const{textContent:a}=s;if(a!==""){const l=s;l.textContent=a.replaceAll(`#${o}`,`#${i}`)}})})},qLe=["img","svg",'[role="img"]',"[data-zoom]"].map(e=>`${e}:not([aria-hidden="true"])`).join(","),wI={overflow:"",width:""};function GLe(){const e=document.querySelector("[data-rmiz-portal]");if(e!=null)return e;const t=document.createElement("div");return t.setAttribute("data-rmiz-portal",""),document.body.appendChild(t),t}function WLe(e){e.preventDefault()}function KLe(e){return te.createElement(YY,{...e})}class YY extends te.Component{constructor(){super(...arguments),this.state={id:"",isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:"UNLOADED",shouldRefresh:!1,styleGhost:{}},this.refContent=te.createRef(),this.refDialog=te.createRef(),this.refModalContent=te.createRef(),this.refModalImg=te.createRef(),this.refWrap=te.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=wI,this.styleModalImg={},this.handleModalStateChange=t=>{const{state:{modalState:n}}=this;t!=="LOADING"&&n==="LOADING"?(this.loadZoomImg(),window.addEventListener("resize",this.handleResize,{passive:!0}),window.addEventListener("touchstart",this.handleTouchStart,{passive:!0}),window.addEventListener("touchmove",this.handleTouchMove,{passive:!0}),window.addEventListener("touchend",this.handleTouchEnd,{passive:!0}),window.addEventListener("touchcancel",this.handleTouchCancel,{passive:!0}),document.addEventListener("keydown",this.handleKeyDown,!0)):t!=="LOADED"&&n==="LOADED"?window.addEventListener("wheel",this.handleWheel,{passive:!0}):t!=="UNLOADING"&&n==="UNLOADING"?(this.ensureImgTransitionEnd(),window.removeEventListener("wheel",this.handleWheel),window.removeEventListener("touchstart",this.handleTouchStart),window.removeEventListener("touchmove",this.handleTouchMove),window.removeEventListener("touchend",this.handleTouchEnd),window.removeEventListener("touchcancel",this.handleTouchCancel),document.removeEventListener("keydown",this.handleKeyDown,!0)):t!=="UNLOADED"&&n==="UNLOADED"&&(this.bodyScrollEnable(),window.removeEventListener("resize",this.handleResize),this.refModalImg.current?.removeEventListener("transitionend",this.handleImgTransitionEnd),this.refDialog.current?.close())},this.setId=()=>{const t=()=>Math.random().toString(16).slice(-4);this.setState({id:t()+t()+t()})},this.setAndTrackImg=()=>{const{refContent:{current:t}}=this;t!=null&&(this.imgEl=t.querySelector(qLe),this.imgEl!==null?(this.contentNotFoundChangeObserver?.disconnect(),this.imgEl.addEventListener("load",this.handleImgLoad),this.imgEl.addEventListener("click",this.handleZoom),this.state.loadedImgEl==null&&this.handleImgLoad(),this.imgElResizeObserver=new ResizeObserver(n=>{const[r]=n;r?.target!==void 0&&(this.imgEl=r.target,this.setState({styleGhost:H3(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver==null&&(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:H3(this.imgEl)})}),this.contentChangeObserver.observe(t,{attributes:!0,childList:!0,subtree:!0}))):this.contentNotFoundChangeObserver==null&&(this.contentNotFoundChangeObserver=new MutationObserver(this.setAndTrackImg),this.contentNotFoundChangeObserver.observe(t,{childList:!0,subtree:!0})))},this.handleIfZoomChanged=t=>{const{props:{isZoomed:n}}=this;!t&&n?this.zoom():t&&!n&&this.unzoom()},this.handleImgLoad=()=>{const t=xI(this.imgEl);if(t==null||t==="")return;const n=new Image,{imgEl:r}=this;if(Px(r)){const{sizes:i,srcset:o,crossOrigin:a}=r;n.sizes=i,n.srcset=o,n.crossOrigin=a}n.src=t;const s=()=>{this.setState({loadedImgEl:n,styleGhost:H3(this.imgEl)})};n.decode().then(s).catch(()=>{if(vI(n)){s();return}n.onload=s})},this.handleZoom=t=>{this.props.isDisabled!==!0&&this.hasImage()&&this.props.onZoomChange?.(!0,{event:t})},this.handleUnzoom=t=>{this.props.isDisabled!==!0&&this.props.onZoomChange?.(!1,{event:t})},this.handleBtnUnzoomClick=t=>{t.preventDefault(),t.stopPropagation(),this.handleUnzoom(t)},this.handleDialogClick=t=>{(t.target===this.refModalContent.current||t.target===this.refModalImg.current)&&(t.stopPropagation(),this.handleUnzoom(t))},this.handleDialogClose=t=>{t.stopPropagation(),this.handleUnzoom(t)},this.handleKeyDown=t=>{t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),this.handleUnzoom(t))},this.handleWheel=t=>{t.ctrlKey||(t.stopPropagation(),queueMicrotask(()=>{this.handleUnzoom(t)}))},this.handleTouchStart=t=>{if(t.touches.length>1){this.isScaling=!0;return}const{changedTouches:n}=t,[r]=n;if(n.length===1&&r!==void 0){const{screenY:s}=r;this.touchYStart=s}},this.handleTouchMove=t=>{const n=window.visualViewport?.scale??1,{changedTouches:r}=t,[s]=r;if(this.props.canSwipeToUnzoom&&!this.isScaling&&n<=1&&this.touchYStart!=null&&s!==void 0){const{screenY:i}=s;this.touchYEnd=i;const o=Math.max(this.touchYStart,this.touchYEnd),a=Math.min(this.touchYStart,this.touchYEnd);Math.abs(o-a)>this.props.swipeToUnzoomThreshold&&(this.touchYStart=void 0,this.touchYEnd=void 0,this.handleUnzoom(t))}},this.handleTouchEnd=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleTouchCancel=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleResize=()=>{this.setState({shouldRefresh:!0})},this.hasImage=()=>this.imgEl!==null&&(this.state.loadedImgEl!==void 0||Qy(this.imgEl))&&window.getComputedStyle(this.imgEl).display!=="none",this.zoom=()=>{this.bodyScrollDisable(),this.refDialog.current?.showModal(),this.refModalImg.current?.addEventListener("transitionend",this.handleImgTransitionEnd),this.setState({modalState:"LOADING"})},this.unzoom=()=>{this.setState({modalState:"UNLOADING"})},this.handleImgTransitionEnd=()=>{clearTimeout(this.timeoutTransitionEnd),this.state.modalState==="LOADING"?this.setState({modalState:"LOADED"}):this.state.modalState==="UNLOADING"&&this.setState({shouldRefresh:!1,modalState:"UNLOADED"})},this.ensureImgTransitionEnd=()=>{if(this.refModalImg.current!==null){const{transitionDuration:t}=window.getComputedStyle(this.refModalImg.current),n=parseFloat(t);if(n!==0&&!Number.isNaN(n)){const r=n*(t.endsWith("ms")?1:1e3)+50;this.timeoutTransitionEnd=setTimeout(this.handleImgTransitionEnd,r)}}},this.bodyScrollDisable=()=>{this.prevBodyAttrs={overflow:document.body.style.overflow,width:document.body.style.width};const{body:{clientWidth:t}}=document;document.body.style.overflow="hidden",document.body.style.width=`${t}px`},this.bodyScrollEnable=()=>{const{prevBodyAttrs:{overflow:t,width:n}}=this;document.body.style.width=n,document.body.style.overflow=t,this.prevBodyAttrs=wI},this.loadZoomImg=()=>{const{props:{zoomImg:t}}=this;if(t==null)return;const{src:n}=t;if(n!==void 0&&n!==""){const r=new Image;r.sizes=t.sizes??"",r.srcset=t.srcSet??"",r.crossOrigin=t.crossOrigin??void 0,r.src=n;const s=()=>{this.setState({isZoomImgLoaded:!0})};r.decode().then(s).catch(()=>{if(vI(r)){s();return}r.onload=s})}},this.UNSAFE_handleSvg=()=>{const{imgEl:t,refModalImg:n,styleModalImg:r}=this;if(Qy(t)){const s=t.cloneNode(!0);VLe(s),s.style.width=`${r.width??0}px`,s.style.height=`${r.height??0}px`,s.addEventListener("click",this.handleUnzoom),n.current?.firstChild?.remove(),n.current?.appendChild(s)}}}render(){const{handleBtnUnzoomClick:t,handleDialogClick:n,handleDialogClose:r,handleUnzoom:s,handleZoom:i,imgEl:o,props:{a11yNameButtonUnzoom:a,a11yNameButtonZoom:l,children:u,classDialog:h,IconUnzoom:p,IconZoom:m,isZoomed:b,wrapElement:y,ZoomContent:x,zoomImg:S,zoomMargin:C},refContent:N,refDialog:M,refModalContent:_,refModalImg:T,refWrap:R,state:{id:D,isZoomImgLoaded:j,loadedImgEl:L,modalState:V,shouldRefresh:q,styleGhost:X}}=this,ee=`rmiz-modal-${D}`,re=`rmiz-modal-img-${D}`,oe=l8(o),F=Px(o),se=Qy(o),le=PLe(o),W=xI(o),Q=F?o.sizes:void 0,H=F?o.srcset:void 0,U=F?o.crossOrigin:void 0,Z=S?.src!==void 0&&S.src!=="",he=this.hasImage(),fe=le!==void 0&&le!==""?`${l}: ${le}`:l,ye=V==="LOADING"||V==="LOADED",ge=he?"found":"not-found",Ee=V==="UNLOADED"||V==="UNLOADING"?"hidden":"visible",Ae={visibility:V==="UNLOADED"?"visible":"hidden"};this.styleModalImg=he&&o!==null?ULe({hasZoomImg:Z,imgSrc:W,isSvg:se,isZoomed:b&&ye,loadedImgEl:L,offset:C,shouldRefresh:q,targetEl:o}):{};let Qe=null;if(he){const rt=F||oe?te.createElement("img",{alt:le,crossOrigin:U,sizes:Q,src:W,srcSet:H,...j&&V==="LOADED"?S:{},"data-rmiz-modal-img":"",height:this.styleModalImg.height??void 0,id:re,ref:T,style:this.styleModalImg,width:this.styleModalImg.width??void 0}):se?te.createElement("div",{"data-rmiz-modal-img":!0,ref:T,style:this.styleModalImg}):null,ct=te.createElement("button",{"aria-label":a,"data-rmiz-btn-unzoom":"",onClick:t,type:"button"},te.createElement(p,null));Qe=x==null?te.createElement(te.Fragment,null,rt,ct):te.createElement(x,{buttonUnzoom:ct,modalState:V,img:rt,isZoomImgLoaded:j,onUnzoom:s})}return te.createElement(y,{"aria-owns":ee,"data-rmiz":"",ref:R},te.createElement(y,{"data-rmiz-content":ge,ref:N,style:Ae},u),he&&te.createElement(y,{"data-rmiz-ghost":"",style:X},te.createElement("button",{"aria-label":fe,"data-rmiz-btn-zoom":"",onClick:i,type:"button"},te.createElement(m,null))),he&&Jx.createPortal(te.createElement("dialog",{"aria-labelledby":re,"aria-modal":"true",className:h,"data-rmiz-modal":"",id:ee,onClick:n,onClose:r,onCancel:WLe,ref:M,role:"dialog"},te.createElement("div",{"data-rmiz-modal-overlay":Ee}),te.createElement("div",{"data-rmiz-modal-content":"",ref:_},Qe)),GLe()))}componentDidMount(){this.setId(),this.setAndTrackImg(),this.handleImgLoad(),this.UNSAFE_handleSvg()}componentWillUnmount(){this.state.modalState!=="UNLOADED"&&this.bodyScrollEnable(),this.contentChangeObserver?.disconnect(),this.contentNotFoundChangeObserver?.disconnect(),this.imgElResizeObserver?.disconnect(),this.imgEl?.removeEventListener("load",this.handleImgLoad),this.imgEl?.removeEventListener("click",this.handleZoom),this.refModalImg.current?.removeEventListener("transitionend",this.handleImgTransitionEnd),window.removeEventListener("wheel",this.handleWheel),window.removeEventListener("touchstart",this.handleTouchStart),window.removeEventListener("touchmove",this.handleTouchMove),window.removeEventListener("touchend",this.handleTouchEnd),window.removeEventListener("touchcancel",this.handleTouchCancel),window.removeEventListener("resize",this.handleResize),document.removeEventListener("keydown",this.handleKeyDown,!0)}componentDidUpdate(t,n){this.handleModalStateChange(n.modalState),this.UNSAFE_handleSvg(),this.handleIfZoomChanged(t.isZoomed)}}YY.defaultProps={a11yNameButtonUnzoom:"Minimize image",a11yNameButtonZoom:"Expand image",canSwipeToUnzoom:!0,IconUnzoom:DLe,IconZoom:jLe,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:"div",zoomMargin:0};const c8=({children:e,className:t,...n})=>d.jsx("div",{className:ie("absolute top-3 right-3 flex flex-row rounded px-0.5 opacity-0 group-hover/node-image:opacity-100","border-[0.5px] bg-[var(--mt-bg-secondary)] [backdrop-filter:saturate(1.8)_blur(20px)]",t),...n,children:e});c8.displayName="ActionWrapper";const $x=({icon:e,tooltip:t,className:n,...r})=>d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",className:ie("text-muted-foreground hover:text-foreground relative flex h-7 w-7 flex-row rounded-none p-0","bg-transparent hover:bg-transparent",n),...r,children:e})}),d.jsx(fa,{side:"bottom",children:t})]});$x.displayName="ActionButton";const YLe=[{key:"onView",icon:d.jsx(BDe,{}),tooltip:"View image"},{key:"onDownload",icon:d.jsx(vDe,{}),tooltip:"Download image"},{key:"onCopy",icon:d.jsx(dDe,{}),tooltip:"Copy image to clipboard"},{key:"onCopyLink",icon:d.jsx(tY,{}),tooltip:"Copy image link",isLink:!0}],ZY=({shouldMerge:e=!1,isLink:t=!1,...n})=>{const[r,s]=w.useState(!1),i=w.useCallback((a,l)=>{a.preventDefault(),a.stopPropagation(),l?.()},[]),o=w.useMemo(()=>YLe.filter(a=>t||!a.isLink),[t]);return d.jsx(c8,{className:ie({"opacity-100":r}),children:e?d.jsxs(Li,{open:r,onOpenChange:s,children:[d.jsx(Pi,{asChild:!0,children:d.jsx($x,{icon:d.jsx(eY,{}),tooltip:"Open menu",onClick:a=>a.preventDefault()})}),d.jsx($i,{className:"w-56",align:"end",children:o.map(({key:a,icon:l,tooltip:u})=>d.jsx(cl,{onClick:h=>i(h,n[a]),children:d.jsxs("div",{className:"flex flex-row items-center gap-2",children:[l,d.jsx("span",{children:u})]})},a))})]}):o.map(({key:a,icon:l,tooltip:u})=>d.jsx($x,{icon:l,tooltip:u,onClick:h=>i(h,n[a])},a))})};ZY.displayName="ImageActions";const ZLe=({editor:e,node:t,src:n,onViewClick:r})=>{const s=r6(n),i=w.useCallback(()=>{r(!0)},[r]),o=w.useCallback(()=>{e.commands.downloadImage({src:t.attrs.src,alt:t.attrs.alt})},[e.commands,t.attrs.alt,t.attrs.src]),a=w.useCallback(()=>{e.commands.copyImage({src:t.attrs.src})},[e.commands,t.attrs.src]),l=w.useCallback(()=>{e.commands.copyLink({src:t.attrs.src})},[e.commands,t.attrs.src]),u=w.useCallback(()=>{e.commands.command(({tr:h,dispatch:p})=>{const{selection:m}=h,b=h.doc.nodeAt(m.from);return b&&b.type.name==="image"&&p?(h.deleteSelection(),!0):!1})},[e.commands]);return{isLink:s,onView:i,onDownload:o,onCopy:a,onCopyLink:l,onRemoveImg:u}},XY=function({className:t,...n}){return d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",className:ie("animate-spin",t),...n,children:[d.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),d.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})};XY.displayName="Spinner";const QY=w.memo(XY),JY=w.memo(()=>d.jsx("div",{className:ie("flex flex-row items-center justify-center","absolute inset-0 rounded bg-[var(--mt-overlay)] opacity-100 transition-opacity"),children:d.jsx(QY,{className:"size-7"})}));JY.displayName="ImageOverlay";const U3=600,XLe=120,SI=120,QLe=e=>({src:typeof e=="string"?e:e.src,id:typeof e=="string"?Ax():e.id}),JLe=({editor:e,node:t,selected:n,updateAttributes:r})=>{const{src:s,width:i,height:o,fileName:a}=t.attrs,l=w.useRef(!1),u=w.useMemo(()=>typeof s=="string"?s:s.src,[s]),[h,p]=w.useState({src:u,isServerUploading:!1,imageLoaded:!1,isZoomed:!1,error:!1,naturalSize:{width:i,height:o}}),m=w.useRef(null),[b,y]=w.useState(null),x=w.useCallback(({width:W,height:Q})=>{r({width:W,height:Q})},[r]),S=h.naturalSize.width/h.naturalSize.height,C=U3*S,N=m.current?parseFloat(getComputedStyle(m.current).getPropertyValue("--editor-width")):1/0,{isLink:M,onView:_,onDownload:T,onCopy:R,onCopyLink:D,onRemoveImg:j}=ZLe({editor:e,node:t,src:h.src,onViewClick:W=>p(Q=>({...Q,isZoomed:W}))}),{currentWidth:L,currentHeight:V,updateDimensions:q,initiateResize:X,isResizing:ee}=OLe({initialWidth:i??h.naturalSize.width,initialHeight:o??h.naturalSize.height,contentWidth:h.naturalSize.width,contentHeight:h.naturalSize.height,gridInterval:.1,onDimensionsChange:x,minWidth:SI,minHeight:XLe,maxWidth:N>0?N:C}),re=w.useMemo(()=>L<=180,[L]),oe=w.useCallback(W=>{const Q=W.target,H={width:Q.naturalWidth,height:Q.naturalHeight};p(U=>({...U,naturalSize:H,imageLoaded:!0})),r({width:Q.width||H.width,height:Q.height||H.height,alt:Q.alt,title:Q.title}),i||q(U=>({...U,width:H.width}))},[i,r,q]),F=w.useCallback(()=>{p(W=>({...W,error:!0,imageLoaded:!0}))},[]),se=w.useCallback(W=>Q=>{y(W),X(W)(Q)},[X]),le=w.useCallback(()=>{y(null)},[]);return w.useEffect(()=>{ee||le()},[ee,le]),w.useEffect(()=>{(async()=>{if(!u.startsWith("blob:")||l.current)return;l.current=!0;const Q=e.options.extensions.find(U=>U.name==="image"),{uploadFn:H}=Q?.options??{};if(!H){try{const U=await JDe(u);p(Z=>({...Z,src:U})),r({src:U})}catch{p(U=>({...U,error:!0}))}return}try{p(ge=>({...ge,isServerUploading:!0}));const Z=await(await fetch(u)).blob(),he=new File([Z],a,{type:Z.type}),fe=await H(he,e),ye=QLe(fe);p(ge=>({...ge,...ye,isServerUploading:!1})),r(ye)}catch{p(U=>({...U,error:!0,isServerUploading:!1}))}})()},[e,a,u,r]),d.jsx(JOe,{ref:m,"data-drag-handle":!0,className:"relative text-center leading-none",children:d.jsx("div",{className:"group/node-image relative mx-auto rounded-md object-contain",style:{maxWidth:`min(${C}px, 100%)`,width:L,maxHeight:U3,aspectRatio:`${h.naturalSize.width} / ${h.naturalSize.height}`},children:d.jsxs("div",{className:ie("relative flex h-full cursor-default flex-col items-center gap-2 rounded",{"outline-primary outline-2 outline-offset-1":n||ee}),children:[d.jsxs("div",{className:"h-full contain-paint",children:[d.jsxs("div",{className:"relative h-full",children:[h.isServerUploading&&!h.error&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:d.jsx(QY,{className:"size-7"})}),h.error&&d.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[d.jsx(TDe,{className:"text-destructive size-8"}),d.jsx("p",{className:"text-muted-foreground mt-2 text-sm",children:"Failed to load image"})]}),d.jsx(KLe,{isZoomed:h.isZoomed,onZoomChange:()=>p(W=>({...W,isZoomed:!1})),children:d.jsx("img",{className:ie("h-auto rounded object-contain transition-shadow",{"opacity-0":!h.imageLoaded||h.error}),style:{maxWidth:`min(100%, ${C}px)`,minWidth:`${SI}px`,maxHeight:U3},width:L,height:V,src:h.src,onError:F,onLoad:oe,alt:t.attrs.alt||"",title:t.attrs.title||"",id:t.attrs.id})})]}),h.isServerUploading&&d.jsx(JY,{}),e.isEditable&&h.imageLoaded&&!h.error&&!h.isServerUploading&&d.jsxs(d.Fragment,{children:[d.jsx(c6,{onPointerDown:se("left"),className:ie("left-1",{hidden:ee&&b==="right"}),isResizing:ee&&b==="left"}),d.jsx(c6,{onPointerDown:se("right"),className:ie("right-1",{hidden:ee&&b==="left"}),isResizing:ee&&b==="right"})]})]}),h.error&&d.jsx(c8,{children:d.jsx($x,{icon:d.jsx(WDe,{}),tooltip:"Remove image",onClick:j})}),!ee&&!h.error&&!h.isServerUploading&&d.jsx(ZY,{shouldMerge:re,isLink:M,onView:_,onDownload:T,onCopy:R,onCopyLink:D})]})})})},u8=(e,t,n)=>{const r=e instanceof Error?e:new Error("Unknown error");n?.(r,t)},ePe=e=>{const[t,n]=e.split(","),r=t.split(":")[1].split(";")[0],s=r.split("/")[1],i=atob(n),o=new Uint8Array(i.length);for(let l=0;l<i.length;l++)o[l]=i.charCodeAt(l);return{blob:new Blob([o],{type:r}),extension:s}},tPe=async e=>{const t=await fetch(e);if(!t.ok)throw new Error("Failed to fetch image");const n=await t.blob(),r=n.type.split(/\/|\+/)[1];return{blob:n,extension:r}},nPe=async e=>e.startsWith("data:")?ePe(e):tPe(e),rPe=async(e,t,n)=>{const r=URL.createObjectURL(e),s=document.createElement("a");s.href=r,s.download=`${t}.${n}`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r)},sPe=async(e,t)=>{const{src:n,alt:r}=e,s=r||"image";try{const{blob:i,extension:o}=await nPe(n);await rPe(i,s,o),t.onActionSuccess?.({...e,action:"download"})}catch(i){u8(i,{...e,action:"download"},t.onActionError)}},iPe=async(e,t)=>{const{src:n}=e;try{const s=await(await fetch(n)).blob();await navigator.clipboard.write([new ClipboardItem({[s.type]:s})]),t.onActionSuccess?.({...e,action:"copyImage"})}catch(r){u8(r,{...e,action:"copyImage"},t.onActionError)}},oPe=async(e,t)=>{const{src:n}=e;try{await navigator.clipboard.writeText(n),t.onActionSuccess?.({...e,action:"copyLink"})}catch(r){u8(r,{...e,action:"copyLink"},t.onActionError)}},aPe=Wq.extend({atom:!0,addOptions(){return{...this.parent?.()||{},inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1,allowedMimeTypes:[],maxFileSize:0,uploadFn:void 0,onToggle:void 0,downloadImage:void 0,copyImage:void 0,copyLink:void 0}},addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},id:{default:null},width:{default:null},height:{default:null},fileName:{default:null}}},addCommands(){return{setImages:e=>({commands:t})=>{const[n,r]=Rx(e,{allowedMimeTypes:this.options.allowedMimeTypes,maxFileSize:this.options.maxFileSize,allowBase64:this.options.allowBase64});return r.length>0&&this.options.onValidationError&&this.options.onValidationError(r),n.length>0?t.insertContent(n.map(s=>{if(s.src instanceof File){const i=URL.createObjectURL(s.src),o=Ax();return{type:this.type.name,attrs:{id:o,src:i,alt:s.alt,title:s.title,fileName:s.src.name}}}else return{type:this.type.name,attrs:{id:Ax(),src:s.src,alt:s.alt,title:s.title,fileName:null}}})):!1},downloadImage:e=>()=>((this.options.downloadImage||sPe)({...e,action:"download"},this.options),!0),copyImage:e=>()=>((this.options.copyImage||iPe)({...e,action:"copyImage"},this.options),!0),copyLink:e=>()=>((this.options.copyLink||oPe)({...e,action:"copyLink"},this.options),!0),toggleImage:()=>({editor:e})=>{const t=document.createElement("input");return t.type="file",t.accept=this.options.allowedMimeTypes.join(","),t.onchange=()=>{const n=t.files;if(!n)return;const[r,s]=Rx(Array.from(n),{allowedMimeTypes:this.options.allowedMimeTypes,maxFileSize:this.options.maxFileSize,allowBase64:this.options.allowBase64});return s.length>0&&this.options.onValidationError?(this.options.onValidationError(s),!1):(r.length===0||this.options.onToggle&&this.options.onToggle(e,r,e.state.selection.from),!1)},t.click(),!0}}},onTransaction({transaction:e}){e.steps.forEach(t=>{t instanceof $s&&t.slice.size===0&&e.before.content.cut(t.from,t.to).forEach(r=>{if(r.type.name==="image"){const s=r.attrs;s.src.startsWith("blob:")&&URL.revokeObjectURL(s.src),this.options.onImageRemoved?.(s)}})})},addNodeView(){return iDe(JLe,{className:"block-node"})}}),lPe=vn.create({addKeyboardShortcuts(){return{"Mod-\\":()=>this.editor.commands.unsetAllMarks()}}}),cPe=vn.create({name:"resetMarksOnEnter",addKeyboardShortcuts(){return{Enter:({editor:e})=>e.isActive("bold")||e.isActive("italic")||e.isActive("strike")||e.isActive("underline")||e.isActive("code")?(e.commands.splitBlock({keepMarks:!1}),!0):!1}}}),uPe=e=>{const{key:t,editor:n,onPaste:r,onDrop:s,onValidationError:i,allowedMimeTypes:o,maxFileSize:a}=e;return new Wn({key:t||new ar("fileHandler"),props:{handleDrop(l,u){const{dataTransfer:h}=u;if(!h?.files.length)return!1;u.preventDefault(),u.stopPropagation();const p=l.posAtCoords({left:u.clientX,top:u.clientY}),[m,b]=Rx(Array.from(h.files),{allowedMimeTypes:o,maxFileSize:a,allowBase64:e.allowBase64});return b.length>0&&i&&i(b),m.length>0&&s&&s(n,m,p?.pos??0),!0},handlePaste(l,u){const{clipboardData:h}=u;if(!h?.files.length)return!1;u.preventDefault(),u.stopPropagation();const[p,m]=Rx(Array.from(h.files),{allowedMimeTypes:o,maxFileSize:a,allowBase64:e.allowBase64}),b=h.getData("text/html");return m.length>0&&i&&i(m),p.length>0&&r&&r(n,p,b),!0}}})},dPe=vn.create({name:"fileHandler",addOptions(){return{allowBase64:!1,allowedMimeTypes:[],maxFileSize:0}},addProseMirrorPlugins(){return[uPe({key:new ar(this.name),editor:this.editor,...this.options})]}});function fPe(e){return/^#{1,6}\s/.test(e)||/\*\*[^*]+\*\*/.test(e)||/\*[^*]+\*/.test(e)||/\[.+\]\(.+\)/.test(e)||/^[-*+]\s/.test(e)||/^\d+\.\s/.test(e)||/^>\s/.test(e)||/`[^`]+`/.test(e)||/^```/.test(e)}const hPe=vn.create({name:"markdownPaste",addProseMirrorPlugins(){const{editor:e}=this;return[new Wn({key:new ar("markdownPaste"),props:{handlePaste:(t,n)=>{const r=n.clipboardData;if(!r||r.getData("text/html"))return!1;const i=r.getData("text/plain");if(!i||!e.markdown||!fPe(i))return!1;try{return e.commands.insertContent(i,{contentType:"markdown"}),n.preventDefault(),!0}catch{return!1}}}})]}});function pPe(e,t){const n=w.useRef(Date.now()),r=w.useRef(null);return w.useCallback((...s)=>{Date.now()-n.current>=t?(e(...s),n.current=Date.now()):(r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{e(...s),n.current=Date.now()},t-(Date.now()-n.current)))},[e,t])}async function mPe(e){return await new Promise(n=>setTimeout(n,3e3)),await s6(e)}const gPe=({placeholder:e,uploader:t,output:n="html"})=>[zW.configure({blockquote:{HTMLAttributes:{class:"block-node"}},bulletList:{HTMLAttributes:{class:"list-node"}},code:{HTMLAttributes:{class:"inline",spellcheck:"false"}},codeBlock:!1,dropcursor:{width:2,class:"ProseMirror-dropcursor border"},heading:{HTMLAttributes:{class:"heading-node"}},horizontalRule:!1,link:{enableClickSelection:!0,openOnClick:!1,HTMLAttributes:{class:"link"}},orderedList:{HTMLAttributes:{class:"list-node"}},paragraph:{HTMLAttributes:{class:"text-node"}}}),aPe.configure({allowedMimeTypes:["image/*"],maxFileSize:5*1024*1024,allowBase64:!0,uploadFn:async r=>t?await t(r):await mPe(r),onToggle(r,s,i){r.commands.insertContentAt(i,s.map(o=>{const a=URL.createObjectURL(o);return{type:"image",attrs:{id:Ax(),src:a,alt:o.name,title:o.name,fileName:o.name}}}))},onImageRemoved({id:r,src:s}){console.log("Image removed",{id:r,src:s})},onValidationError(r){r.forEach(s=>{_n.error("Image validation error",{position:"bottom-right",description:s.reason})})},onActionSuccess({action:r}){const s={copyImage:"Copy Image",copyLink:"Copy Link",download:"Download"};_n.success(s[r],{position:"bottom-right",description:"Image action success"})},onActionError(r,{action:s}){const i={copyImage:"Copy Image",copyLink:"Copy Link",download:"Download"};_n.error(`Failed to ${i[s]}`,{position:"bottom-right",description:r.message})}}),dPe.configure({allowBase64:!0,allowedMimeTypes:["image/*"],maxFileSize:5*1024*1024,onDrop:(r,s,i)=>{s.forEach(async o=>{const a=await s6(o);r.commands.insertContentAt(i,{type:"image",attrs:{src:a}})})},onPaste:(r,s)=>{s.forEach(async i=>{const o=await s6(i);r.commands.insertContent({type:"image",attrs:{src:o}})})},onValidationError:r=>{r.forEach(s=>{_n.error("Image validation error",{position:"bottom-right",description:s.reason})})}}),ALe,bY,BNe,Xje,lPe,RLe,cPe,TLe,FNe.configure({placeholder:()=>e}),...n==="markdown"?[QIe.configure({markedOptions:{gfm:!0}}),AW.configure({HTMLAttributes:{class:"task-list-node"}}),TW.configure({nested:!0}),B6e.configure({table:{resizable:!0,HTMLAttributes:{class:"table-node"}}}),hPe]:[]],bPe=({value:e,output:t="html",placeholder:n="",editorClassName:r,throttleDelay:s=0,onUpdate:i,onBlur:o,uploader:a,...l})=>{const u=pPe(y=>i?.(y),s),h=w.useCallback(y=>u(eI(y,t)),[t,u]),p=w.useCallback(y=>{e&&y.isEmpty&&y.commands.setContent(e,{contentType:t==="markdown"?"markdown":void 0})},[e,t]),m=w.useCallback(y=>o?.(eI(y,t)),[t,o]);return XOe({immediatelyRender:!1,extensions:gPe({placeholder:n,uploader:a,output:t}),editorProps:{attributes:{autocomplete:"off",autocorrect:"off",autocapitalize:"off",class:ie("focus:outline-hidden",r)}},onUpdate:({editor:y})=>h(y),onCreate:({editor:y})=>p(y),onBlur:({editor:y})=>m(y),...l})},yPe={top:0,left:0,bottom:0,right:0,x:0,y:0,width:0,height:0,toJSON:()=>"{}"};function vPe(e){const[t,n]=w.useState(()=>e?.getBoundingClientRect()??yPe),r=w.useCallback(()=>{if(!e)return;const s=e.getBoundingClientRect();n(i=>Math.round(i.width)===Math.round(s.width)&&Math.round(i.height)===Math.round(s.height)&&Math.round(i.x)===Math.round(s.x)&&Math.round(i.y)===Math.round(s.y)?i:s)},[e]);return w.useEffect(()=>{if(!e)return;const s=new ResizeObserver(r);return s.observe(e),window.addEventListener("click",r),window.addEventListener("resize",r),()=>{s.disconnect(),window.removeEventListener("click",r),window.removeEventListener("resize",r)}},[e,r]),t}const eZ=({as:e,name:t,children:n,style:r={},...s})=>{const i=w.useRef(null),o=vPe(i.current),a={[`--${t}-width`]:`${o.width}px`,[`--${t}-height`]:`${o.height}px`};return d.jsx(e,{...s,ref:i,style:{...a,...r},children:n})};eZ.displayName="MeasuredContainer";function xPe(e){const{editor:t}=WN(),n=w.useMemo(()=>e||t,[e,t]);return WK({editor:n,selector(s){return s.editor?{editor:s.editor,editorState:s.editor.state,canCommand:s.editor.can}:{editor:null,editorState:void 0,canCommand:void 0}}})||{editor:null}}const wPe=({editor:e})=>d.jsx("div",{className:"border-border flex h-12 shrink-0 overflow-x-auto border-b p-2",children:d.jsxs("div",{className:"flex w-max items-center gap-px",children:[d.jsx(QK,{editor:e}),d.jsx(Ri,{orientation:"vertical",className:"mx-2"}),d.jsx(rY,{editor:e,activeLevels:[1,2,3,4,5,6]}),d.jsx(Ri,{orientation:"vertical",className:"mx-2"}),d.jsx(sY,{editor:e,activeActions:["bold","italic","underline","strikethrough","code","clearFormatting"],mainActionCount:4}),d.jsx(Ri,{orientation:"vertical",className:"mx-2"}),d.jsx(aY,{editor:e}),d.jsx(Ri,{orientation:"vertical",className:"mx-2"}),d.jsx(lY,{editor:e,activeActions:["orderedList","bulletList"],mainActionCount:0}),d.jsx(Ri,{orientation:"vertical",className:"mx-2"}),d.jsx(cY,{editor:e,activeActions:["codeBlock","blockquote","horizontalRule"],mainActionCount:2})]})}),tZ=({value:e,onChange:t,className:n,editorContentClassName:r,...s})=>{const i=bPe({value:e,onUpdate:t,...s});return i?d.jsx(jw.Provider,{value:{editor:i},children:d.jsx(SPe,{editor:i,className:n,editorContentClassName:r})}):null};tZ.displayName="MinimalTiptapEditor";const SPe=({editor:e,className:t,editorContentClassName:n})=>{const{editor:r}=xPe(e);return r?d.jsxs(eZ,{as:"div",name:"editor",className:ie("border-input min-data-[orientation=vertical]:h-72 flex h-auto w-full min-w-0 flex-col rounded-md border shadow-xs","focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]",t),children:[d.jsx(wPe,{editor:r}),d.jsx(GK,{editor:r,className:ie("minimal-tiptap-editor",n)}),d.jsx(Oje,{editor:r})]}):null};function CPe({value:e,onChange:t,placeholder:n}){const r=w.useRef([]),s=w.useRef(e);w.useEffect(()=>{s.current=e},[e]);const i=async a=>{const l=new FormData;l.append("file",a);const{data:u}=await Gt.post("/upload",l);return r.current.push(u.url),u.url};w.useEffect(()=>()=>{const a=String(s.current||"");r.current.filter(u=>!a.includes(u)).forEach(async u=>{try{const h=u.split("/").pop();h&&await Gt.delete(`/upload/${decodeURIComponent(h)}`)}catch(h){console.error("Session image cleanup failed for:",u,h)}})},[]);const o=e??"";return d.jsx(tZ,{value:o,onChange:a=>{t(typeof a=="string"?a:String(a))},className:"w-full",editorContentClassName:"p-5",output:"html",placeholder:n||"Scrivi qui il tuo contenuto...",autofocus:!1,editable:!0,editorClassName:"focus:outline-none",uploader:i})}function kPe({branch:e,value:t,onChange:n}){return d.jsx(CPe,{value:t,onChange:r=>n(r),placeholder:`Scrivi ${e.label.toLowerCase()}...`})}const CI="image/*",EPe=8e3;function NPe(e){return e.type==="file"&&(e.multiple===!0||e.format==="asset-list")}function nZ(e){try{return new URL(e).protocol==="https:"}catch{return!1}}async function MPe(e){return new Promise(t=>{const n=new Image;let r=!1;const s=()=>{n.onload=null,n.onerror=null},i=a=>{r||(r=!0,s(),t(a))},o=globalThis.setTimeout(()=>i(!1),EPe);n.onload=()=>{globalThis.clearTimeout(o),i(!0)},n.onerror=()=>{globalThis.clearTimeout(o),i(!1)},n.src=e})}function _Pe(e){try{return JSON.parse(e)}catch{return e}}function kI(e){if(typeof e!="string")return null;const t=e.trim();return nZ(t)?t:null}function bm(e){const t=typeof e=="string"?_Pe(e):e,n=Array.isArray(t)?t:[t],r=[];for(const s of n){if(s==null)continue;const i=kI(s);if(i){r.push(i);continue}if(typeof s=="object"&&!Array.isArray(s)){const o=kI(s.url);o&&r.push(o)}}return[...new Set(r)]}function EI(e,t){return e.includes(t)?e:[...e,t]}function TPe(e,t,n){if(n<0||n>=e.length||t===n)return e;const r=[...e],[s]=r.splice(t,1);return r.splice(n,0,s),r}function APe(e,t){return e.isMultiple?e.hasAssets?t("media.manageGallery"):t("media.addImages"):e.hasImage?t("media.replace"):t("media.addImage")}function RPe({branch:e,value:t,onChange:n}){const{t:r}=tt(),s=w.useRef(null),[i,o]=w.useState(!1),[a,l]=w.useState(!1),[u,h]=w.useState(!1),[p,m]=w.useState(!1),[b,y]=w.useState(null),[x,S]=w.useState(""),C=NPe(e),N=w.useMemo(()=>C?bm(t):[],[C,t]),M=typeof t=="string"?t:"",_=M.length>0,T=N.length>0,R=APe({isMultiple:C,hasAssets:T,hasImage:_},r),D=u||p;w.useEffect(()=>{i&&(S(C?"":M),y(null),l(!1))},[i,C,M]);const j=w.useCallback(async W=>{if(!W.type.startsWith("image/")){y(r("media.errorNotImage"));return}y(null),h(!0);try{const Q=new FormData;Q.append("file",W);const{data:H}=await Gt.post("/upload",Q);if(C){const U=bm(t);n(EI(U,H.url))}else n(H.url),o(!1)}catch(Q){y(Q instanceof Error?Q.message:"Error during upload")}finally{h(!1)}},[C,n,t]),L=w.useCallback(async()=>{const W=x.trim();if(!W){y(r("media.errorUrl"));return}if(!nZ(W)){y(r("media.errorHttps"));return}y(null),m(!0);try{if(!await MPe(W)){y(r("media.errorNotRenderable"));return}if(C){const H=bm(t);n(EI(H,W)),S("")}else n(W),o(!1)}finally{m(!1)}},[C,n,x,t]),V=w.useCallback(W=>{W.preventDefault(),l(!1);const Q=W.dataTransfer.files[0];Q&&j(Q)},[j]),q=w.useCallback(W=>{W.preventDefault(),D||l(!0)},[D]),X=w.useCallback(()=>{l(!1)},[]),ee=w.useCallback(W=>{const Q=W.target.files?.[0];Q&&j(Q),W.target.value=""},[j]),re=w.useCallback(()=>{D||s.current?.click()},[D]),oe=w.useCallback(()=>{n("")},[n]),F=w.useCallback(W=>{const Q=bm(t);n(Q.filter((H,U)=>U!==W))},[n,t]),se=w.useCallback((W,Q)=>{const H=bm(t),U=Q==="up"?W-1:W+1;n(TPe(H,W,U))},[n,t]),le=w.useCallback(()=>{n([]),o(!1)},[n]);return C?d.jsx("div",{className:"space-y-3",children:d.jsxs("div",{className:"flex items-start gap-3",children:[T?d.jsx("div",{className:"grid grid-cols-2 gap-1",children:N.slice(0,4).map(W=>d.jsx("div",{className:"relative size-16 overflow-hidden rounded-md border border-input bg-muted",children:d.jsx("img",{src:W,alt:"",className:"size-full object-cover"})},W))}):d.jsx("div",{className:"flex size-16 shrink-0 items-center justify-center rounded-md border border-dashed border-input bg-muted/40",children:d.jsx(xm,{className:"size-5 text-muted-foreground"})}),d.jsx("div",{className:"flex flex-col items-start gap-2",children:d.jsxs(kf,{open:i,onOpenChange:o,children:[d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:"w-fit",onClick:()=>o(!0),children:[d.jsx(xm,{className:"size-4"}),R]}),d.jsxs(Ef,{children:[d.jsxs(Ip,{children:[d.jsx(zp,{children:R}),d.jsx(Nx,{children:r("media.dialogDesc")})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{htmlFor:`${e.alias}-url`,className:"text-sm font-medium",children:r("media.imageLink")}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(Xt,{id:`${e.alias}-url`,type:"url",value:x,onChange:W=>S(W.target.value),placeholder:"https://example.com/image.jpg",disabled:D}),d.jsx(Oe,{type:"button",variant:"secondary",onClick:()=>{L()},disabled:D,children:p?d.jsxs(d.Fragment,{children:[d.jsx(ta,{className:"size-4 animate-spin"}),r("media.verifying")]}):d.jsxs(d.Fragment,{children:[d.jsx(oC,{className:"size-4"}),r("media.add")]})})]})]}),d.jsxs("button",{type:"button",onClick:re,onDrop:V,onDragOver:q,onDragLeave:X,className:ie("w-full rounded-lg border-2 border-dashed p-5 text-center transition-colors","hover:border-primary/50 hover:bg-muted/50",a&&"border-primary bg-muted/50",D&&"pointer-events-none opacity-70"),children:[d.jsx("input",{ref:s,id:`${e.alias}-file`,type:"file",accept:CI,className:"hidden",onChange:ee}),u?d.jsxs("div",{className:"flex flex-col items-center gap-2",children:[d.jsx(ta,{className:"size-8 animate-spin text-muted-foreground"}),d.jsx("span",{className:"text-sm text-muted-foreground",children:r("media.uploading")})]}):d.jsx("p",{className:"text-sm text-muted-foreground",children:r("media.dropOrSelect")})]}),N.length>0?d.jsx("div",{className:"max-h-52 space-y-2 overflow-y-auto rounded-md border border-input p-2",children:N.map((W,Q)=>d.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-input bg-background p-2",children:[d.jsx("img",{src:W,alt:"",className:"size-10 shrink-0 rounded object-cover"}),d.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:W}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",onClick:()=>se(Q,"up"),disabled:Q===0||D,"aria-label":r("media.moveUp"),children:d.jsx(AJ,{className:"size-4"})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",onClick:()=>se(Q,"down"),disabled:Q===N.length-1||D,"aria-label":r("media.moveDown"),children:d.jsx(CJ,{className:"size-4"})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",onClick:()=>F(Q),disabled:D,"aria-label":r("media.removeImage"),children:d.jsx(ro,{className:"size-4"})})]})]},`${W}-${Q}`))}):null,b?d.jsx("p",{className:"text-sm text-destructive",children:b}):null]}),d.jsxs(Ex,{children:[N.length>0?d.jsxs(Oe,{type:"button",variant:"destructive",onClick:le,disabled:D,children:[d.jsx(ro,{className:"size-4"}),r("media.removeAll")]}):null,d.jsx(Oe,{type:"button",variant:"outline",onClick:()=>o(!1),disabled:D,children:r("common.close")})]})]})]})})]})}):d.jsx("div",{className:"space-y-3",children:d.jsxs("div",{className:"flex items-start gap-3",children:[_?d.jsx("div",{className:"relative size-16 shrink-0 overflow-hidden rounded-md border border-input bg-muted",children:d.jsx("img",{src:M,alt:"",className:"size-full object-cover"})}):d.jsx("div",{className:"flex size-16 shrink-0 items-center justify-center rounded-md border border-dashed border-input bg-muted/40",children:d.jsx(xm,{className:"size-5 text-muted-foreground"})}),d.jsx("div",{className:"flex flex-col items-start gap-2",children:d.jsxs(kf,{open:i,onOpenChange:o,children:[d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:"w-fit",onClick:()=>o(!0),children:[d.jsx(xm,{className:"size-4"}),R]}),d.jsxs(Ef,{children:[d.jsxs(Ip,{children:[d.jsxs(zp,{children:[R," image"]}),d.jsx(Nx,{children:r("media.dialogDesc")})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("label",{htmlFor:`${e.alias}-url`,className:"text-sm font-medium",children:r("media.imageLink")}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(Xt,{id:`${e.alias}-url`,type:"url",value:x,onChange:W=>S(W.target.value),placeholder:"https://example.com/image.jpg",disabled:D}),d.jsx(Oe,{type:"button",variant:"secondary",onClick:()=>{L()},disabled:D,children:p?d.jsxs(d.Fragment,{children:[d.jsx(ta,{className:"size-4 animate-spin"}),r("media.verifying")]}):d.jsxs(d.Fragment,{children:[d.jsx(oC,{className:"size-4"}),r("media.useLink")]})})]})]}),d.jsxs("button",{type:"button",onClick:re,onDrop:V,onDragOver:q,onDragLeave:X,className:ie("w-full rounded-lg border-2 border-dashed p-5 text-center transition-colors","hover:border-primary/50 hover:bg-muted/50",a&&"border-primary bg-muted/50",D&&"pointer-events-none opacity-70"),children:[d.jsx("input",{ref:s,id:`${e.alias}-file`,type:"file",accept:CI,className:"hidden",onChange:ee}),u?d.jsxs("div",{className:"flex flex-col items-center gap-2",children:[d.jsx(ta,{className:"size-8 animate-spin text-muted-foreground"}),d.jsx("span",{className:"text-sm text-muted-foreground",children:r("media.uploading")})]}):d.jsx("p",{className:"text-sm text-muted-foreground",children:r("media.dropOrSelect")})]}),b?d.jsx("p",{className:"text-sm text-destructive",children:b}):null]}),d.jsxs(Ex,{children:[_?d.jsxs(Oe,{type:"button",variant:"destructive",onClick:()=>{oe(),o(!1)},disabled:D,children:[d.jsx(ro,{className:"size-4"}),r("media.removeImage")]}):null,d.jsx(Oe,{type:"button",variant:"outline",onClick:()=>o(!1),disabled:D,children:r("common.close")})]})]})]})})]})})}const Ci=new $Me;Ci.registerDisplay("text",qMe);Ci.registerDisplay("number",GMe);Ci.registerDisplay("boolean",WMe);Ci.registerDisplay("date",KMe);Ci.registerDisplay("json",QMe);Ci.registerDisplay("richtext",t_e);Ci.registerDisplay("file",i_e);Ci.registerEdit("text",o_e);Ci.registerEdit("number",a_e);Ci.registerEdit("boolean",l_e);Ci.registerEdit("date",KRe);Ci.registerEdit("json",QRe);Ci.registerEdit("richtext",kPe);Ci.registerEdit("file",RPe);function OPe(e){return Ci.getDisplay(e)??FMe}function DPe(e){return Ci.getEdit(e)??BMe}function rZ(e){const{branch:t}=e,{visibility:n}=Ew(t);if(n==="hidden")return null;const r=OPe(t.type);return n==="masked"?d.jsx(r,{...e,value:"••••••••"}):d.jsx(r,{...e})}function d8(e){const{branch:t}=e,{privacy:n}=Ew(t);if(n==="hash"||n==="encrypt")return d.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-dashed px-3 py-2 text-sm text-muted-foreground",children:[d.jsx("span",{children:"••••••••"}),d.jsx("span",{className:"text-xs",children:"(campo sensibile — non modificabile)"})]});const r=DPe(t.type);return d.jsx(r,{...e})}function jPe({className:e,orientation:t="horizontal",...n}){return d.jsx(Tue,{"data-slot":"tabs","data-orientation":t,orientation:t,className:ie("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...n})}const IPe=Df("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function zPe({className:e,variant:t="default",...n}){return d.jsx(Aue,{"data-slot":"tabs-list","data-variant":t,className:ie(IPe({variant:t}),e),...n})}function NI({className:e,...t}){return d.jsx(Rue,{"data-slot":"tabs-trigger",className:ie("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background dark:data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",e),...t})}function MI({className:e,...t}){return d.jsx(Oue,{"data-slot":"tabs-content",className:ie("flex-1 outline-none",e),...t})}function _I(e){return e.alias.startsWith("meta")}function LPe(e){return e.type==="json"&&e.alias.toLowerCase().includes("tag")}function PPe(e){const t=e.alias.trim().toLowerCase();return t==="title"||t==="name"}function $Pe(e){const t=e.branches.find(LPe)??null,n=e.branches.filter(_I),r=e.branches.filter(s=>!_I(s)&&!PPe(s)&&s.alias!==t?.alias);return{tagsBranch:t,seoBranches:n,mainBranches:r}}function FPe(e){const t=e.find(r=>r.type==="richtext")??null,n=t?e.filter(r=>r.alias!==t.alias):e;return{richtextBranch:t,otherMainBranches:n}}function BPe(e){const t=e.trim().toLowerCase();return t?["error","failed","rejected","archived"].includes(t)?"destructive":["published","active","approved","online"].includes(t)?"default":"outline":"secondary"}function Lw(e){if(typeof e=="string"){const t=e.trim();if(!t)return null;try{const n=JSON.parse(t);if(n&&typeof n=="object")return Lw(n)}catch{}return t}if(e&&typeof e=="object"){const t=e;return[t.url,t.src,t.path].find(r=>typeof r=="string"&&r.trim().length>0)?.trim()??null}return null}function Fx(e){return typeof e=="string"?e.replaceAll(/<[^>]*>/g," ").replaceAll(/\s+/g," ").trim():typeof e=="number"||typeof e=="boolean"?String(e):Array.isArray(e)?e.map(t=>Fx(t)).join(" ").trim():e&&typeof e=="object"?Object.values(e).map(t=>Fx(t)).join(" ").trim():""}function HPe(e,t=50){const n=Fx(e);return n?n.length<=t?n:`${n.slice(0,t).trimEnd()}…`:""}function UPe(e){if(e==null||e==="")return"";const t=new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleDateString("it-IT",{year:"numeric",month:"short",day:"numeric"})}function VPe(e,t){const n=e.status?.trim()||"—",r=t.tagsBranch?Cg(e.data[t.tagsBranch.alias]):[],s=t.coverBranch?Lw(e.data[t.coverBranch.alias]):null,i=t.titleBranch?Fx(e.data[t.titleBranch.alias]):"",o=t.excerptBranch?HPe(e.data[t.excerptBranch.alias],90):"",a=t.dateBranch?UPe(e.data[t.dateBranch.alias]):"",l=i?`Apri dettaglio: ${i}`:`Apri dettaglio entry ${e.id}`;return{entryId:e.id,status:n,tags:r,imageUrl:s,title:i,excerpt:o,dateText:a,ariaLabel:l,statusVariant:BPe(n)}}function qPe(e,t){return t.some(n=>e.includes(n))}function sZ(e){const t=e.branches,n=t.find(a=>{if(a.type!=="file")return!1;const l=a.alias.trim().toLowerCase();return qPe(l,["cover","image","foto","photo"])})??null,r=t.find(a=>{const l=a.alias.trim().toLowerCase();return l==="title"||l==="name"})??null,s=t.find(a=>a.type!=="richtext"&&a.type!=="text"?!1:r?a.alias!==r.alias:!0)??null,i=t.find(a=>a.type==="date")??null,o=t.find(a=>a.type!=="json"?!1:a.alias.toLowerCase().includes("tag"))??null;return{coverBranch:n,titleBranch:r,excerptBranch:s,dateBranch:i,tagsBranch:o}}function GPe(e,t){const n=e.branches.find(r=>{const s=r.alias.toLowerCase();return s==="title"||s==="name"});if(n){const r=t.data[n.alias];if(typeof r=="string"&&r.trim().length>0)return r.trim()}return t.slug?.trim()||t.id}const TI=4;function WPe({tags:e,className:t}){const[n,r]=w.useState(!1);if(e.length===0)return null;const s=e.length>TI;return d.jsxs("div",{className:ie("space-y-1.5",t),children:[d.jsx("p",{className:"text-muted-foreground text-[11px] font-medium tracking-wide uppercase",children:"Tag"}),d.jsx(Mx,{tags:e,maxVisible:TI,expanded:n,onExpandedChange:r,enableToggle:!0,showCollapseBadge:!1,className:"min-w-0 gap-1.5",chipClassName:"min-w-0 max-w-[12rem] truncate font-normal",renderMoreTrigger:(i,o)=>d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:"h-6 rounded-full px-2.5 text-xs",onClick:o,children:["+",i," altri"]})}),s&&n&&d.jsx(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground",onClick:()=>r(!1),children:"Mostra meno"})]})}function KPe(e){return e.replaceAll(/<[^>]*>/g,"").replaceAll(" "," ").trim().length===0}function YPe({value:e,className:t}){const n=LW(e);return KPe(n)?d.jsx("div",{className:"text-muted-foreground text-sm",children:"—"}):d.jsx("div",{className:ie("richtext-content rounded-md bg-transparent text-sm leading-relaxed","[&_table]:w-full [&_table]:border-collapse [&_table]:text-sm","[&_th]:border [&_td]:border [&_th]:border-border [&_td]:border-border [&_th]:bg-muted/40 [&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1","[&_p]:mb-2 [&_a]:text-primary [&_a]:underline",t),dangerouslySetInnerHTML:{__html:n}})}function ZPe(e){const t=e.toLowerCase().trim();return t==="published"?"bg-emerald-50 text-emerald-700 border-emerald-200/80 dark:bg-emerald-500/10 dark:text-emerald-400 dark:border-emerald-800/60":t==="draft"?"bg-amber-50 text-amber-700 border-amber-200/80 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-800/60":["error","failed","rejected","archived"].includes(t)?"bg-red-50 text-red-700 border-red-200/80 dark:bg-red-500/10 dark:text-red-400 dark:border-red-800/60":"bg-neutral-100 text-neutral-600 border-neutral-200/80 dark:bg-neutral-800 dark:text-neutral-400"}function AI({branch:e,entry:t}){const n=e.type==="file"?Lw(t.data[e.alias]):null;return d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e.label}),n?d.jsx("div",{className:"overflow-hidden rounded-xl border bg-muted/20",children:d.jsx("img",{src:n,alt:e.label,className:"h-auto max-h-[60vh] w-full object-contain"})}):d.jsx(rZ,{branch:e,value:t.data[e.alias]})]})}function XPe({seed:e,entry:t,open:n,onClose:r,onEdit:s}){const{tagsBranch:i,seoBranches:o,mainBranches:a}=w.useMemo(()=>$Pe(e),[e]),{richtextBranch:l,otherMainBranches:u}=w.useMemo(()=>FPe(a),[a]),h=w.useMemo(()=>sZ(e),[e]);if(!t)return null;const p=GPe(e,t),m=i?Cg(t.data[i.alias]):[],b=o.length>0,y=a.length===0&&o.length>0?"seo":"content",x=h.coverBranch?Lw(t.data[h.coverBranch.alias]):null,S=!!x,C=S?"h-[min(52vh,520px)] min-h-0":"h-[min(62vh,620px)] min-h-0",N=d.jsx(ml,{className:"h-full px-6 py-4",children:d.jsxs("div",{className:"space-y-5 pr-3",children:[l&&d.jsxs("div",{className:"overflow-hidden rounded-xl border border-neutral-200/80 dark:border-neutral-700/50",children:[d.jsx("div",{className:"border-b border-neutral-200/80 bg-neutral-50/80 px-4 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground dark:border-neutral-700/50 dark:bg-neutral-800/40",children:"Contenuto principale"}),d.jsx("div",{className:"px-4 py-4",children:d.jsx(YPe,{value:t.data[l.alias],className:"border-0 shadow-none"},t.id)})]}),u.length>0&&d.jsxs("div",{className:"space-y-5 px-1",children:[!l&&d.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Contenuto"}),u.map((_,T)=>d.jsxs(w.Fragment,{children:[d.jsx(AI,{branch:_,entry:t}),T<u.length-1&&d.jsx(Ri,{})]},_.alias))]}),!l&&u.length===0&&d.jsx("p",{className:"text-sm text-muted-foreground",children:"Nessun campo contenuto."})]})}),M=d.jsx(ml,{className:"h-full px-6 py-4",children:d.jsx("div",{className:"space-y-4 pr-3",children:d.jsxs("div",{className:"overflow-hidden rounded-xl border border-neutral-200/80 dark:border-neutral-700/50",children:[d.jsx("div",{className:"border-b border-neutral-200/80 bg-neutral-50/80 px-4 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground dark:border-neutral-700/50 dark:bg-neutral-800/40",children:"Metadati / SEO"}),d.jsx("div",{className:"space-y-5 px-4 py-4",children:o.map((_,T)=>d.jsxs(w.Fragment,{children:[d.jsx(AI,{branch:_,entry:t}),T<o.length-1&&d.jsx(Ri,{})]},_.alias))})]})})});return d.jsx(kf,{open:n,onOpenChange:_=>{_||r()},children:d.jsxs(Ef,{showCloseButton:!0,className:"flex max-h-[min(92vh,920px)] w-full max-w-[calc(100%-2rem)] flex-col gap-0 overflow-hidden p-0 sm:max-w-5xl","aria-describedby":void 0,children:[S&&d.jsxs("div",{className:"relative h-[200px] w-full shrink-0 overflow-hidden",children:[d.jsx("img",{src:x,alt:p||"Copertina",className:"h-full w-full object-cover"}),d.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-t from-background/80 via-background/20 to-transparent"})]}),d.jsx(Ip,{className:ie("shrink-0 space-y-0 px-6 pb-4 text-left",S?"pt-3":"pt-6"),children:d.jsxs("div",{className:"flex items-start justify-between gap-3 pr-8",children:[d.jsxs("div",{className:"min-w-0 flex-1 space-y-2.5",children:[d.jsx(zp,{className:"text-left text-xl font-semibold leading-snug",children:p}),d.jsx(WPe,{tags:m}),d.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"font-medium",children:"Stato"}),d.jsx(gi,{variant:"outline",className:ie("text-[11px] font-medium",ZPe(t.status?.trim()||"")),children:t.status?.trim()||"—"})]}),t.slug!=null&&String(t.slug).trim()!==""&&d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":!0,className:"text-border",children:"·"}),d.jsxs("span",{className:"break-all font-mono text-[11px]",children:["/",String(t.slug).trim()]})]})]})]}),d.jsxs(Oe,{type:"button",variant:"default",size:"sm",className:"shrink-0 gap-1.5",onClick:()=>s(t.id),children:[d.jsx(I6,{className:"size-3.5"}),"Modifica"]})]})}),d.jsx(Ri,{}),b?d.jsxs(jPe,{defaultValue:y,className:"flex min-h-0 flex-1 flex-col gap-0",children:[d.jsx("div",{className:"shrink-0 border-b bg-neutral-50/80 px-6 dark:bg-neutral-800/30",children:d.jsxs(zPe,{variant:"line",className:"h-10 w-full justify-start gap-1 bg-transparent p-0",children:[d.jsx(NI,{value:"content",className:"text-sm",children:"Contenuto"}),d.jsx(NI,{value:"seo",className:"text-sm",children:"SEO"})]})}),d.jsx(MI,{value:"content",className:ie("mt-0 overflow-hidden",C),children:N}),d.jsx(MI,{value:"seo",className:ie("mt-0 overflow-hidden",C),children:M})]}):d.jsx("div",{className:ie("overflow-hidden",C),children:N})]})})}const QPe=["gallery-skeleton-1","gallery-skeleton-2","gallery-skeleton-3","gallery-skeleton-4","gallery-skeleton-5","gallery-skeleton-6","gallery-skeleton-7","gallery-skeleton-8"];function JPe(){return d.jsx("div",{className:"grid gap-5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 220px), 420px))",justifyContent:"center"},children:QPe.map(e=>d.jsxs("div",{className:"flex flex-col overflow-hidden rounded-2xl border border-neutral-200/80 bg-card dark:border-neutral-700/50",children:[d.jsxs("div",{className:"relative h-44 w-full shrink-0",children:[d.jsx(kr,{className:"h-full w-full rounded-none"}),d.jsx("div",{className:"absolute left-3 top-3",children:d.jsx(kr,{className:"h-5 w-16 rounded-full"})})]}),d.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[d.jsx(kr,{className:"h-4 w-10/12"}),d.jsx(kr,{className:"h-3 w-7/12"}),d.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-1",children:[d.jsx(Ri,{}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(kr,{className:"h-3 w-20"}),d.jsx(kr,{className:"h-5 w-14 rounded-full"})]})]})]})]},e))})}function e$e(e,t){const[n,r]=w.useState(null),s=w.useMemo(()=>t.find(a=>a.id===n)??null,[t,n]);w.useEffect(()=>{n&&(t.some(a=>a.id===n)||r(null))},[t,n]);const i=w.useMemo(()=>sZ(e),[e]),o=w.useMemo(()=>t.map(a=>VPe(a,i)),[t,i]);return{peekId:n,setPeekId:r,peekEntry:s,cardModels:o}}function t$e({seed:e,data:t,isLoading:n=!1,onEdit:r}){const{setPeekId:s,peekEntry:i,cardModels:o}=e$e(e,t);return n?d.jsx(JPe,{}):t.length===0?d.jsx(VW,{className:"border",children:d.jsxs(qW,{children:[d.jsx(GW,{variant:"icon",children:d.jsx(Tg,{className:"size-5"})}),d.jsx(WW,{children:"Nessun elemento da visualizzare"}),d.jsx(KW,{children:"Non ci sono contenuti disponibili per questa vista galleria."})]})}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"grid gap-5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 220px), 420px))",justifyContent:"center"},children:o.map(a=>d.jsx(PMe,{model:a,onOpen:s},a.entryId))}),d.jsx(XPe,{seed:e,entry:i,open:i!=null,onClose:()=>s(null),onEdit:r})]})}function n$e({open:e,onOpenChange:t,isActive:n,onOpen:r,searchTerm:s,onSearchTermChange:i,visibleFilterColumns:o,activeFiltersCountByColumn:a,onSelectColumn:l}){const{t:u}=tt();return d.jsxs(Li,{open:e,onOpenChange:h=>{t?.(h),h&&r?.(),h||i("")},children:[d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Pi,{asChild:!0,children:d.jsx(Oe,{variant:n?"secondary":"ghost",size:"icon-sm","aria-label":u("toolbar.filter.tooltip"),children:d.jsx(vz,{className:"size-4"})})})}),d.jsx(fa,{side:"top",children:u("toolbar.filter.tooltip")})]}),d.jsxs($i,{align:"end",className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:u("toolbar.filter.label")}),d.jsx(Xt,{placeholder:u("toolbar.filter.searchPlaceholder"),value:s,onChange:h=>i(h.target.value),className:"h-8 text-sm"}),d.jsx(ti,{className:"my-2"}),d.jsx("div",{className:"max-h-56 overflow-y-auto",children:o.length===0?d.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:u("toolbar.filter.noColumns")}):d.jsx("div",{className:"flex flex-col gap-1 py-1",children:o.map(h=>d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-8 justify-between px-2 text-xs",onClick:()=>l(h.columnId),children:[d.jsx("span",{className:"truncate",children:h.label}),a[h.columnId]?d.jsx("span",{className:"text-muted-foreground text-[10px] uppercase",children:a[h.columnId]}):null]},h.columnId))})})]})]})}function r$e({searchTerm:e,onSearchTermChange:t,filteredSortableColumns:n,sortState:r,onToggleDirection:s,onSelectColumn:i,isActive:o,onOpen:a}){const{t:l}=tt();return d.jsxs(Li,{onOpenChange:u=>{u||t(""),u&&a?.()},children:[d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Pi,{asChild:!0,children:d.jsx(Oe,{variant:o?"secondary":"ghost",size:"icon-sm","aria-label":l("toolbar.sort.tooltip"),children:d.jsx(of,{className:"size-4"})})})}),d.jsx(fa,{side:"top",children:l("toolbar.sort.tooltip")})]}),d.jsxs($i,{align:"end",className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:l("toolbar.sort.label")}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Xt,{placeholder:l("toolbar.sort.searchPlaceholder"),value:e,onChange:u=>t(u.target.value),className:"h-8 flex-1 text-sm"}),d.jsx(Oe,{type:"button",variant:"outline",size:"icon-sm",className:"h-8 w-8 shrink-0","aria-label":l("toolbar.sort.invertOrder"),onClick:s,disabled:!r?.columnId,children:d.jsx(of,{className:"size-3.5"})})]}),d.jsx(ti,{className:"my-2"}),d.jsx("div",{className:"max-h-56 overflow-y-auto",children:n.length===0?d.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:l("toolbar.sort.noColumns")}):d.jsx("div",{className:"flex flex-col gap-1 py-1",children:n.map(u=>{const h=r?.columnId===u.alias;return d.jsxs(Oe,{type:"button",variant:h?"secondary":"ghost",size:"sm",className:"h-8 justify-between px-2 text-xs",onClick:()=>i(u.alias),children:[d.jsx("span",{className:"truncate",children:u.label}),h&&d.jsx("span",{className:"text-muted-foreground text-[10px] uppercase",children:r?.desc?"DESC":"ASC"})]},u.alias)})})})]})]})}function iZ({type:e,value:t,onChange:n,selectOptions:r=[],availableTags:s=[],className:i="h-8 flex-1",textClassName:o="text-xs",buttonPlaceholder:a}){const{t:l}=tt(),u=l("toolbar.conditionInput.value"),h=a??l("toolbar.conditionInput.choose");switch(e){case"number":return d.jsx(Xt,{type:"number",value:typeof t=="number"?String(t):"",onChange:p=>{const m=p.target.value;n(m.trim()===""?null:Number(m))},className:`${i} ${o}`.trim(),placeholder:u});case"date":return d.jsx(GN,{id:"toolbar-filter-date",value:t,onChange:n,placeholder:h});case"boolean":{let p="";t===!0?p="true":t===!1&&(p="false");const m=b=>n(b==="true"?!0:b==="false"?!1:null);return d.jsxs(Rr,{value:p,onValueChange:m,children:[d.jsx(Or,{size:"sm",className:`${i} ${o}`.trim(),children:d.jsx(Gr,{placeholder:u})}),d.jsxs(Dr,{children:[d.jsx(or,{value:"true",children:l("toolbar.conditionInput.true")}),d.jsx(or,{value:"false",children:l("toolbar.conditionInput.false")})]})]})}case"select":return d.jsxs(Li,{modal:!1,children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:`${i} justify-between ${o}`.trim(),children:[d.jsx("span",{className:"truncate",children:typeof t=="string"&&t?t:h}),d.jsx(of,{className:"size-3.5 opacity-60"})]})}),d.jsx($i,{align:"end",className:"w-48 p-1",children:r.map(p=>d.jsx(Oe,{type:"button",variant:t===p?"secondary":"ghost",size:"sm",className:"h-8 w-full justify-start px-2 text-xs",onClick:()=>n(p),children:p},p))})]});case"tags":return d.jsxs(Li,{modal:!1,children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:`${i} justify-between ${o}`.trim(),children:[d.jsx("span",{className:"truncate",children:typeof t=="string"&&t?t:l("toolbar.conditionInput.tag")}),d.jsx(of,{className:"size-3.5 opacity-60"})]})}),d.jsx($i,{align:"end",className:"max-h-56 w-56 overflow-y-auto p-1",children:s.map(p=>d.jsx(Oe,{type:"button",variant:t===p?"secondary":"ghost",size:"sm",className:"h-8 w-full justify-start px-2 text-xs",onClick:()=>n(p),children:p},p))})]});default:return d.jsx(Xt,{value:typeof t=="string"?t:"",onChange:p=>n(p.target.value||null),className:`${i} ${o}`.trim(),placeholder:u})}}const s$e=["filter","sort","automation","search","settings","create"],i$e=[{value:"success",label:"Successo"},{value:"warning",label:"Attenzione"},{value:"danger",label:"Critico"},{value:"info",label:"Info"},{value:"neutral",label:"Neutro"}];function o$e(e){return e==="cell"?"cell":"row"}function a$e(e){return Array.isArray(e)?e.filter(t=>t==="bold"||t==="italic"||t==="underline"):[]}function l$e(e){switch(e){case"success":return"bg-emerald-500/70";case"warning":return"bg-amber-500/70";case"danger":return"bg-destructive/70";case"info":return"bg-sky-500/70";default:return"bg-muted-foreground/40"}}function Jy(){return`${Date.now()}_${Math.random().toString(36).slice(2,9)}`}function oZ(e){return e!=="is_empty"&&e!=="is_not_empty"}function aZ(e,t){const n=[{value:"eq",label:t("toolbar.operators.eq")},{value:"is_not_empty",label:t("toolbar.operators.is_not_empty")},{value:"is_empty",label:t("toolbar.operators.is_empty")}];return e==="number"||e==="date"?[{value:"gt",label:t("toolbar.operators.gt")},{value:"lt",label:t("toolbar.operators.lt")},{value:"gte",label:t("toolbar.operators.gte")},{value:"lte",label:t("toolbar.operators.lte")},...n]:e==="tags"?[{value:"contains",label:t("toolbar.operators.contains")},{value:"is_not_empty",label:t("toolbar.operators.is_not_empty")},{value:"is_empty",label:t("toolbar.operators.is_empty")}]:e==="select"?[{value:"eq",label:t("toolbar.operators.eq")},{value:"is_not_empty",label:t("toolbar.operators.is_not_empty")},{value:"is_empty",label:t("toolbar.operators.is_empty")}]:e==="text"||e==="system"?[{value:"contains",label:t("toolbar.operators.contains")},...n]:n}function c$e(e,t=[],n="Stato"){const r=[],s=t.length>0&&t.length<=8?"recommended":"other";r.push({columnId:"status",label:n,section:s});for(const i of e.branches)i.type==="boolean"?r.push({columnId:i.alias,label:i.label,section:"recommended",branchType:"boolean"}):i.type==="date"?r.push({columnId:i.alias,label:i.label,section:"recommended",branchType:"date"}):i.type==="text"&&i.options&&i.options.length>0?r.push({columnId:i.alias,label:i.label,section:"recommended"}):i.type==="text"?r.push({columnId:i.alias,label:i.label,section:"other"}):i.type==="number"&&r.push({columnId:i.alias,label:i.label,section:"other"});return r}function u$e({filters:e,openPillId:t,onOpenPillChange:n,groupBy:r,activeGroupLabel:s,onGroupByChange:i,addConditionToColumn:o,removeColumnFilters:a,updateCondition:l,removeCondition:u,availableTagsByColumnId:h}){const{t:p}=tt();return d.jsxs("div",{className:"mb-2 flex min-h-9 flex-wrap items-center gap-2",children:[r&&d.jsxs(Oe,{variant:"outline",size:"sm",className:"h-8 rounded-full px-3 text-xs",onClick:()=>i?.(null),children:[d.jsx(Ete,{className:"size-3.5"}),p("toolbar.filterPills.groupedBy",{label:s}),d.jsx(ro,{className:"size-3.5 opacity-70"})]}),Object.entries(e).map(([m,b])=>d.jsx(d$e,{group:b,isOpen:t===m,onOpenChange:y=>n(y?m:null),addConditionToColumn:o,removeColumnFilters:a,updateCondition:l,removeCondition:u,availableTagsByColumnId:h},m))]})}function d$e({group:e,isOpen:t,onOpenChange:n,addConditionToColumn:r,removeColumnFilters:s,updateCondition:i,removeCondition:o,availableTagsByColumnId:a}){const{t:l}=tt();return d.jsxs(Li,{open:t,onOpenChange:n,children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-xs","aria-label":l("toolbar.filter.ariaLabel",{label:e.label}),children:[d.jsx("span",{className:"truncate",children:e.label}),d.jsx("span",{className:"opacity-70",children:e.conditions.length})]})}),d.jsxs($i,{align:"start",className:"w-[420px] p-2",children:[d.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[d.jsx(Cs,{className:"px-0 py-0 text-xs font-medium text-muted-foreground",children:l("toolbar.filter.filtersOn",{label:e.label})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"h-7 w-7","aria-label":l("toolbar.filter.removeColumn"),onClick:()=>s(e.columnId),children:d.jsx(La,{className:"size-3.5"})})]}),d.jsxs("div",{className:"space-y-2",children:[e.conditions.map(u=>{const h=aZ(e.type,l),p=oZ(u.op);return d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Rr,{value:u.op,onValueChange:m=>i(e.columnId,u.id,{op:m,value:m==="is_empty"||m==="is_not_empty"?null:u.value}),children:[d.jsx(Or,{size:"sm",className:"h-8 w-40 text-xs",children:d.jsx(Gr,{placeholder:l("toolbar.filter.operator")})}),d.jsx(Dr,{children:h.map(m=>d.jsx(or,{value:m.value,children:m.label},m.value))})]}),p?d.jsx(iZ,{type:e.type,value:u.value,onChange:m=>i(e.columnId,u.id,{value:m}),selectOptions:e.selectOptions,availableTags:a[e.columnId]??[],className:"h-8 flex-1",textClassName:"text-sm"}):d.jsx("div",{className:"h-8 flex-1"}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"h-8 w-8","aria-label":l("toolbar.filter.removeCondition"),onClick:()=>o(e.columnId,u.id),children:d.jsx(ro,{className:"size-3.5"})})]},u.id)}),d.jsx(ti,{}),d.jsx("div",{className:"flex justify-center",children:d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:()=>r(e.columnId),children:[d.jsx(Hi,{className:"size-4"}),l("toolbar.filter.addFilter")]})})]})]})]})}const f$e={table:Nz,gallery:rv,grid:rv,kanban:Ste,chart:pz};function h$e({views:e,activeViewId:t,onChangeView:n,onCreateView:r}){const{t:s}=tt();return d.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[d.jsx(Nw,{type:"single",value:t,onValueChange:i=>i&&n(i),variant:"outline",size:"sm",className:"gap-0",children:e.map(i=>{const o=f$e[i.type];return d.jsxs(rf,{value:i.id,"aria-label":i.label,className:"h-8 gap-1.5 px-2.5",children:[o&&d.jsx(o,{className:"size-4 shrink-0"}),d.jsx("span",{className:"truncate max-w-24",children:i.label})]},i.id)})}),d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"icon-sm",className:"h-8 w-8 shrink-0","aria-label":s("toolbar.viewSwitcher.addView"),onClick:()=>r?.(),children:d.jsx(Hi,{className:"size-4"})})}),d.jsx(fa,{side:"top",children:s("toolbar.viewSwitcher.addView")})]})]})}function p$e({isSearchOpen:e,searchValue:t,searchInputRef:n,handleSearchSubmit:r,onSearchChange:s,handleSearchBlur:i,handleSearchClose:o,handleSearchOpen:a}){const{t:l}=tt();return d.jsx("div",{className:"overflow-hidden rounded-md bg-transparent transition-[width] duration-200 ease-out",style:{width:e?192:32},children:e?d.jsxs("form",{onSubmit:r,className:"relative flex min-w-[192px] items-center",children:[d.jsx(aC,{className:"text-muted-foreground pointer-events-none absolute left-2.5 size-4 shrink-0"}),d.jsx(Xt,{ref:n,type:"search",placeholder:l("toolbar.search.placeholder"),value:t,onChange:u=>s?.(u.target.value),onBlur:i,className:"h-8 w-full border-0 bg-transparent pl-8 pr-8 focus-visible:ring-0 focus-visible:ring-offset-0","aria-label":l("toolbar.search.ariaLabel")}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"absolute right-1 h-6 w-6 shrink-0","aria-label":l("toolbar.search.close"),onClick:o,children:d.jsx(ro,{className:"size-3.5"})})]}):d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"icon-sm",className:"h-8 w-8 shrink-0","aria-label":l("toolbar.search.ariaLabel"),onClick:a,children:d.jsx(aC,{className:"size-4"})})}),d.jsx(fa,{side:"top",children:l("toolbar.search.open")})]})})}function lZ(e=[]){const t=[];return e.includes("bold")&&t.push("font-bold"),e.includes("italic")&&t.push("italic"),e.includes("underline")&&t.push("underline"),t.join(" ")}function cZ(e,t=[]){const n=lZ(t);switch(e){case"success":return`bg-emerald-500/12 hover:bg-emerald-500/16 ${n}`.trim();case"warning":return`bg-amber-500/12 hover:bg-amber-500/16 ${n}`.trim();case"danger":return`bg-destructive/12 hover:bg-destructive/16 ${n}`.trim();case"info":return`bg-sky-500/12 hover:bg-sky-500/16 ${n}`.trim();default:return`bg-muted/35 hover:bg-muted/45 ${n}`.trim()}}function uZ(e,t=[]){const n=lZ(t),r="[&_[data-slot=badge]]:!text-inherit [&_[data-slot=badge]]:!bg-transparent [&_[data-slot=badge]]:!border-current";switch(e){case"success":return`font-medium text-emerald-700 dark:text-emerald-300 ${n} ${r}`.trim();case"warning":return`font-medium text-amber-800 dark:text-amber-200 ${n} ${r}`.trim();case"danger":return`font-medium text-destructive ${n} ${r}`.trim();case"info":return`font-medium text-sky-800 dark:text-sky-200 ${n} ${r}`.trim();default:return`font-medium ${n} ${r}`.trim()}}function m$e({formattableColumns:e,addConditionalFormatRule:t}){const{t:n}=tt();return d.jsxs("div",{className:"flex min-h-52 flex-col items-center justify-center gap-3 rounded-md border border-dashed",children:[d.jsx("div",{className:"text-sm text-muted-foreground",children:n("toolbar.conditionalFormats.noRules")}),d.jsx(dZ,{columns:e,onSelect:t,compact:!0})]})}function g$e({conditionalFormats:e,setActiveConditionalRuleId:t,setIsConditionalEditorOpen:n}){return d.jsx("div",{className:"space-y-2",children:e.map((r,s)=>d.jsxs("button",{type:"button",className:"flex h-14 w-full overflow-hidden rounded-md border text-left transition-colors hover:bg-muted/40",onClick:()=>{t(r.id),n(!0)},children:[d.jsx("div",{className:`w-1/3 ${l$e(r.tone)}`}),d.jsxs("div",{className:"flex flex-1 items-center justify-between px-3",children:[d.jsx("span",{className:"truncate text-sm",children:r.label||r.group.label}),d.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["#",s+1]})]})]},r.id))})}function b$e({activeConditionalRule:e,conditionalFormats:t,updateConditionalRule:n,moveConditionalRule:r,removeConditionalRule:s,updateConditionalCondition:i,addConditionalCondition:o,removeConditionalCondition:a,updateConditionalTextStyles:l,setIsConditionalEditorOpen:u,availableTagsByColumnId:h}){const{t:p}=tt();return d.jsxs("div",{className:"space-y-2 max-h-[460px] overflow-y-auto pr-1",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>u(!1),children:p("toolbar.conditionalFormats.rulesList")}),d.jsx("span",{className:"text-[11px] text-muted-foreground",children:p("toolbar.conditionalFormats.editRule")})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ZW,{pressed:e.enabled,onPressedChange:m=>n(e.id,{enabled:m}),variant:"outline",size:"sm","aria-label":p("toolbar.conditionalFormats.toggleRule"),className:"h-7 w-7 px-0",children:e.enabled?d.jsx(hp,{className:"size-3.5"}):d.jsx(fp,{className:"size-3.5"})}),d.jsx(Xt,{value:e.label??"",onChange:m=>n(e.id,{label:m.target.value}),className:"h-7 text-xs",placeholder:p("toolbar.conditionalFormats.ruleName")}),d.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"h-7 w-7",onClick:()=>r(e.id,-1),disabled:t.findIndex(m=>m.id===e.id)===0,"aria-label":p("toolbar.conditionalFormats.moveUp"),children:d.jsx(T6,{className:"size-3.5"})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"h-7 w-7",onClick:()=>r(e.id,1),disabled:t.findIndex(m=>m.id===e.id)===t.length-1,"aria-label":p("toolbar.conditionalFormats.moveDown"),children:d.jsx(Nc,{className:"size-3.5"})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"h-7 w-7 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>s(e.id),"aria-label":p("toolbar.conditionalFormats.deleteRule"),children:d.jsx(La,{className:"size-3.5"})})]})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-xs font-medium",children:p("toolbar.conditionalFormats.applyTo")}),d.jsxs("div",{className:"inline-flex rounded-md border p-0.5",children:[d.jsx(Oe,{type:"button",size:"sm",variant:"ghost",className:e.target==="cell"?"h-7 px-3 text-xs bg-black text-white hover:bg-black/90 hover:text-white":"h-7 px-3 text-xs text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>n(e.id,{target:"cell"}),children:p("toolbar.conditionalFormats.cell")}),d.jsx(Oe,{type:"button",size:"sm",variant:"ghost",className:e.target==="row"?"h-7 px-3 text-xs bg-black text-white hover:bg-black/90 hover:text-white":"h-7 px-3 text-xs text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>n(e.id,{target:"row"}),children:p("toolbar.conditionalFormats.row")})]})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-xs font-medium",children:p("toolbar.conditionalFormats.useColorIf")}),d.jsx("div",{className:"h-8 rounded-md border bg-muted/20 px-2 text-xs flex items-center",children:d.jsx("span",{className:"truncate",children:e.group.label})})]}),d.jsx("div",{className:"flex flex-col gap-2",children:e.group.conditions.map(m=>{const b=aZ(e.group.type,p),y=oZ(m.op);return d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Rr,{value:m.op,onValueChange:x=>i(e.id,m.id,{op:x,value:x==="is_empty"||x==="is_not_empty"?null:m.value}),children:[d.jsx(Or,{size:"sm",className:"h-8 w-36 text-xs",children:d.jsx(Gr,{placeholder:p("toolbar.conditionalFormats.operator")})}),d.jsx(Dr,{children:b.map(x=>d.jsx(or,{value:x.value,children:x.label},x.value))})]}),y?d.jsx(iZ,{type:e.group.type,value:m.value,onChange:x=>i(e.id,m.id,{value:x}),selectOptions:e.group.selectOptions??[],availableTags:h[e.columnId]??[],className:"h-8 flex-1",textClassName:"text-xs"}):d.jsx("div",{className:"h-8 flex-1"}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"h-8 w-8","aria-label":p("toolbar.conditionalFormats.removeCondition"),onClick:()=>a(e.id,m.id),children:d.jsx(ro,{className:"size-3.5"})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-xs",className:"h-8 w-8","aria-label":p("toolbar.conditionalFormats.addCondition"),onClick:()=>o(e.id),children:d.jsx(Hi,{className:"size-3.5"})})]},m.id)})}),d.jsxs("div",{className:"space-y-1 pt-1",children:[d.jsx("div",{className:"text-xs font-medium",children:p("toolbar.conditionalFormats.formatStyle")}),d.jsxs("div",{className:"rounded-md border border-dashed p-2",children:[d.jsx("div",{className:`flex min-h-12 items-center rounded-md border px-3 ${e.target==="row"?cZ(e.tone,e.textStyles??[]):""}`,children:d.jsx("span",{className:e.target==="cell"?uZ(e.tone,e.textStyles??[]):"font-medium",children:p("toolbar.conditionalFormats.default")})}),d.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[d.jsxs(Rr,{value:e.tone,onValueChange:m=>n(e.id,{tone:m}),children:[d.jsx(Or,{size:"sm",className:"h-8 w-40 text-xs",children:d.jsx(Gr,{placeholder:p("toolbar.conditionalFormats.colorPreset")})}),d.jsx(Dr,{children:i$e.map(m=>d.jsx(or,{value:m.value,children:m.label},m.value))})]}),d.jsxs(Nw,{variant:"outline",type:"multiple",value:e.textStyles??[],onValueChange:m=>l(e.id,m),children:[d.jsx(rf,{value:"bold","aria-label":p("toolbar.conditionalFormats.bold"),children:d.jsx($J,{className:"size-4"})}),d.jsx(rf,{value:"italic","aria-label":p("toolbar.conditionalFormats.italic"),children:d.jsx(mte,{className:"size-4"})}),d.jsx(rf,{value:"underline","aria-label":p("toolbar.conditionalFormats.underline"),children:d.jsx(tre,{className:"size-4"})})]})]})]})]})]})}function y$e({enabled:e,formattableColumns:t,conditionalFormats:n,activeConditionalRule:r,isConditionalEditorOpen:s,setIsConditionalEditorOpen:i,setActiveConditionalRuleId:o,addConditionalFormatRule:a,updateConditionalRule:l,updateConditionalTextStyles:u,removeConditionalRule:h,moveConditionalRule:p,updateConditionalCondition:m,addConditionalCondition:b,removeConditionalCondition:y,availableTagsByColumnId:x}){const{t:S}=tt();if(!e)return d.jsx("div",{className:"text-sm text-muted-foreground",children:S("toolbar.conditionalFormats.notAvailable")});let C;return s?r?C=d.jsx(b$e,{activeConditionalRule:r,conditionalFormats:n,updateConditionalRule:l,moveConditionalRule:p,removeConditionalRule:h,updateConditionalCondition:m,addConditionalCondition:b,removeConditionalCondition:y,updateConditionalTextStyles:u,setIsConditionalEditorOpen:i,availableTagsByColumnId:x}):C=d.jsx("div",{className:"px-0 py-6 text-center text-sm text-muted-foreground",children:S("toolbar.conditionalFormats.selectRule")}):n.length===0?C=d.jsx(m$e,{formattableColumns:t,addConditionalFormatRule:a}):C=d.jsx(g$e,{conditionalFormats:n,setActiveConditionalRuleId:o,setIsConditionalEditorOpen:i}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx(Cs,{className:"px-0 py-0 text-sm font-semibold text-foreground",children:"Regole dei colori condizionali"}),d.jsx(dZ,{columns:t,onSelect:a})]}),d.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Le regole si applicano dall’alto verso il basso."}),d.jsx(ti,{}),C]})}function dZ({columns:e,onSelect:t,compact:n=!1}){const{t:r}=tt();return d.jsxs(Li,{modal:!1,children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:n?"h-8":"h-8 w-8 px-0","aria-label":r("toolbar.conditionalFormats.addRule"),children:[d.jsx(Hi,{className:"size-4"}),n?r("toolbar.conditionalFormats.add"):null]})}),d.jsxs($i,{align:"end",className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:r("toolbar.conditionalFormats.chooseColumn")}),d.jsx("div",{className:"max-h-56 overflow-y-auto",children:e.length===0?d.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:r("toolbar.conditionalFormats.noColumns")}):d.jsx("div",{className:"flex flex-col gap-1 py-1",children:e.map(s=>d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-8 justify-between px-2 text-xs",onClick:()=>t(s.columnId),children:[d.jsx("span",{className:"truncate",children:s.label}),d.jsx("span",{className:"text-[10px] text-muted-foreground uppercase",children:s.type})]},s.columnId))})})]})]})}function v$e({isSettingsMenuOpenEffective:e,setIsSettingsMenuOpenState:t,onOpenSettings:n,isSettingsOpen:r,commitViewName:s,setColumnSearchTerm:i,viewNameDraft:o,setViewNameDraft:a,setIsConditionalEditorOpen:l,filterColumnSearchTerm:u,setFilterColumnSearchTerm:h,visibleFilterColumns:p,addConditionToColumn:m,setOpenPillId:b,closeSettingsMenu:y,filters:x,sortColumnSearchTerm:S,setSortColumnSearchTerm:C,handleToggleSortDirection:N,sortState:M,filteredSortableColumns:_,handleSortColumnSelect:T,groupBy:R,onGroupByChange:D,recommendedGroupColumns:j,datePrecisionMode:L,applyDatePrecisionMode:V,otherGroupColumns:q,onConditionalFormatsChange:X,formattableColumns:ee,conditionalFormats:re,activeConditionalRule:oe,isConditionalEditorOpen:F,setActiveConditionalRuleId:se,addConditionalFormatRule:le,updateConditionalRule:W,updateConditionalTextStyles:Q,removeConditionalRule:H,moveConditionalRule:U,updateConditionalCondition:Z,addConditionalCondition:he,removeConditionalCondition:fe,availableTagsByColumnId:ye,columnVisibility:ge,onColumnVisibilityChange:Ee,columnSearchTerm:Ae,filteredTableColumns:Qe,pageSize:rt,onPageSizeChange:ct}){const{t:He}=tt();return d.jsxs(Li,{open:e,onOpenChange:_e=>{_e||(s(),i("")),_e&&n?.(),r===void 0&&t(_e)},children:[d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Pi,{asChild:!0,children:d.jsx(Oe,{variant:e?"secondary":"ghost",size:"icon-sm","aria-label":He("toolbar.settings.tooltip"),children:d.jsx(Ag,{className:"size-4"})})})}),d.jsx(fa,{side:"top",children:He("toolbar.settings.tooltip")})]}),d.jsxs($i,{align:"end",className:"w-64",children:[d.jsxs(Em,{children:[d.jsx(Cs,{children:He("toolbar.settings.title")}),d.jsx("div",{className:"px-2 pb-1.5",children:d.jsx(Xt,{value:o,onChange:_e=>a(_e.target.value),onBlur:()=>s(),onKeyDown:_e=>{if(_e.key==="Enter"){_e.preventDefault(),s();return}_e.key.length===1&&!_e.metaKey&&!_e.ctrlKey&&!_e.altKey&&_e.stopPropagation()},className:"h-8 text-sm",placeholder:He("toolbar.settings.viewName")})})]}),d.jsx(ti,{}),d.jsxs(Em,{children:[d.jsx(Cs,{children:He("toolbar.settings.quickActions")}),d.jsxs(Mh,{onOpenChange:_e=>{_e&&l(!1)},children:[d.jsxs(_h,{children:[d.jsx(vz,{className:"size-4"}),He("toolbar.settings.filter")]}),d.jsx(Nh,{children:d.jsxs(Th,{className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:He("toolbar.filter.label")}),d.jsx(Xt,{placeholder:He("toolbar.filter.searchPlaceholder"),value:u,onChange:_e=>h(_e.target.value),className:"h-8 text-sm"}),d.jsx(ti,{className:"my-2"}),d.jsx("div",{className:"max-h-56 overflow-y-auto",children:p.length===0?d.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:He("toolbar.filter.noColumns")}):d.jsx("div",{className:"flex flex-col gap-1 py-1",children:p.map(_e=>d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-8 justify-between px-2 text-xs",onClick:()=>{m(_e.columnId),h(""),b(_e.columnId),y()},children:[d.jsx("span",{className:"truncate",children:_e.label}),x[_e.columnId]?.conditions?.length?d.jsx("span",{className:"text-muted-foreground text-[10px] uppercase",children:x[_e.columnId].conditions.length}):null]},_e.columnId))})})]})})]}),d.jsxs(Mh,{children:[d.jsxs(_h,{children:[d.jsx(of,{className:"size-4"}),He("toolbar.settings.sort")]}),d.jsx(Nh,{children:d.jsxs(Th,{className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:He("toolbar.sort.label")}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Xt,{placeholder:He("toolbar.sort.searchPlaceholder"),value:S,onChange:_e=>C(_e.target.value),className:"h-8 flex-1 text-sm"}),d.jsx(Oe,{type:"button",variant:"outline",size:"icon-sm",className:"h-8 w-8 shrink-0","aria-label":He("toolbar.sort.invertOrder"),onClick:N,disabled:!M?.columnId,children:d.jsx(of,{className:"size-3.5"})})]}),d.jsx(ti,{className:"my-2"}),d.jsx("div",{className:"max-h-56 overflow-y-auto",children:_.length===0?d.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:He("toolbar.sort.noColumns")}):d.jsx("div",{className:"flex flex-col gap-1 py-1",children:_.map(_e=>{const nn=M?.columnId===_e.alias;return d.jsxs(Oe,{type:"button",variant:nn?"secondary":"ghost",size:"sm",className:"h-8 justify-between px-2 text-xs",onClick:()=>T(_e.alias),children:[d.jsx("span",{className:"truncate",children:_e.label}),nn&&d.jsx("span",{className:"text-muted-foreground text-[10px] uppercase",children:M?.desc?"DESC":"ASC"})]},_e.alias)})})})]})})]})]}),d.jsx(ti,{}),d.jsxs(Em,{children:[d.jsx(Cs,{children:He("toolbar.settings.layoutStyle")}),d.jsxs(Mh,{children:[d.jsxs(_h,{children:[d.jsx(wne,{className:"size-4"}),He("toolbar.settings.group"),R?"...":"",R&&d.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground uppercase",children:He("toolbar.settings.active")})]}),d.jsx(Nh,{children:d.jsxs(Th,{className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:He("toolbar.settings.groupBy")}),d.jsxs(Oe,{type:"button",variant:R?"ghost":"secondary",size:"sm",className:"h-8 w-full justify-between px-2 text-xs",onClick:()=>{D?.(null),y()},children:[d.jsx("span",{children:He("toolbar.settings.noGrouping")}),!R&&d.jsx(Pd,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),j.length>0&&d.jsxs(d.Fragment,{children:[d.jsx(ti,{className:"my-2"}),d.jsx(Cs,{className:"px-0 pb-1 pt-0 text-[10px] font-medium text-muted-foreground uppercase tracking-wide",children:He("toolbar.settings.recommended")}),d.jsx("div",{className:"flex flex-col gap-1",children:j.map(_e=>_e.branchType==="date"?d.jsxs(Mh,{children:[d.jsxs(_h,{className:"h-8 w-full rounded-sm px-2 text-xs data-[state=open]:bg-accent",children:[d.jsx("span",{className:"flex-1 truncate text-left",children:_e.label}),R===_e.columnId&&d.jsx(Pd,{className:"mr-2 size-3.5 shrink-0 text-muted-foreground"})]}),d.jsx(Nh,{children:d.jsxs(Th,{className:"w-48 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:He("toolbar.settings.group")}),d.jsxs(abe,{value:L,onValueChange:nn=>{const xt=nn||"monthYear";D?.(_e.columnId),V(xt),y()},children:[d.jsx(CS,{value:"day",children:He("toolbar.settings.day")}),d.jsx(CS,{value:"year",children:He("toolbar.settings.year")}),d.jsx(CS,{value:"monthYear",children:He("toolbar.settings.month")})]})]})})]},_e.columnId):d.jsxs(Oe,{type:"button",variant:R===_e.columnId?"secondary":"ghost",size:"sm",className:"h-8 w-full justify-between px-2 text-xs",onClick:()=>{D?.(R===_e.columnId?null:_e.columnId),y()},children:[d.jsx("span",{className:"truncate",children:_e.label}),R===_e.columnId&&d.jsx(Pd,{className:"size-3.5 shrink-0 text-muted-foreground"})]},_e.columnId))})]}),q.length>0&&d.jsxs(d.Fragment,{children:[d.jsx(ti,{className:"my-2"}),d.jsx(Cs,{className:"px-0 pb-1 pt-0 text-[10px] font-medium text-muted-foreground uppercase tracking-wide",children:He("toolbar.settings.otherFields")}),d.jsx("div",{className:"px-0 pb-1 text-[10px] text-muted-foreground/70",children:He("toolbar.settings.manyGroups")}),d.jsx("div",{className:"flex flex-col gap-1",children:q.map(_e=>d.jsx(Oe,{type:"button",variant:R===_e.columnId?"secondary":"ghost",size:"sm",className:"h-auto min-h-8 w-full flex-col items-start gap-0 px-2 py-1.5 text-xs",onClick:()=>{D?.(R===_e.columnId?null:_e.columnId),y()},children:d.jsxs("div",{className:"flex w-full items-center justify-between",children:[d.jsx("span",{className:"truncate",children:_e.label}),R===_e.columnId&&d.jsx(Pd,{className:"size-3.5 shrink-0 text-muted-foreground"})]})},_e.columnId))})]})]})})]}),d.jsxs(Mh,{children:[d.jsxs(_h,{children:[d.jsx(kz,{className:"size-4"}),He("toolbar.settings.conditionalColors")]}),d.jsx(Nh,{children:d.jsx(Th,{className:"w-[620px] p-3",children:d.jsx(y$e,{enabled:!!X,formattableColumns:ee,conditionalFormats:re,activeConditionalRule:oe,isConditionalEditorOpen:F,setIsConditionalEditorOpen:l,setActiveConditionalRuleId:se,addConditionalFormatRule:le,updateConditionalRule:W,updateConditionalTextStyles:Q,removeConditionalRule:H,moveConditionalRule:U,updateConditionalCondition:Z,addConditionalCondition:he,removeConditionalCondition:fe,availableTagsByColumnId:ye})})})]})]}),d.jsx(ti,{}),d.jsxs(Em,{children:[d.jsx(Cs,{children:He("toolbar.settings.table")}),ge&&Ee&&d.jsxs(Mh,{children:[d.jsxs(_h,{children:[d.jsx(hp,{className:"size-4"}),He("toolbar.settings.visibleColumns")]}),d.jsx(Nh,{children:d.jsxs(Th,{className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:He("toolbar.settings.columnVisibility")}),d.jsx(Xt,{placeholder:He("toolbar.settings.columnSearch"),value:Ae,onChange:_e=>i(_e.target.value),className:"h-8 text-sm"}),d.jsx(ti,{className:"my-2"}),d.jsx("div",{className:"max-h-56 overflow-y-auto",children:Qe.length===0?d.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:He("toolbar.settings.noColumns")}):d.jsx("div",{className:"flex flex-col gap-1 py-1",children:Qe.map(_e=>{const nn=ge[_e.id]??!0;return d.jsxs(Oe,{type:"button",variant:nn?"secondary":"ghost",size:"sm",className:"h-8 justify-between px-2 text-xs",onClick:()=>{const xt={...ge,[_e.id]:!nn};Ee(xt)},children:[d.jsx("span",{className:"truncate",children:_e.label}),nn?d.jsx(hp,{className:"size-3.5 shrink-0 text-muted-foreground"}):d.jsx(fp,{className:"size-3.5 shrink-0 text-muted-foreground/50"})]},_e.id)})})})]})})]}),rt!=null&&ct&&d.jsxs(cl,{onSelect:_e=>_e.preventDefault(),className:"justify-between gap-4 focus:bg-transparent focus:text-inherit data-[highlighted]:bg-transparent data-[highlighted]:text-inherit cursor-default",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(vne,{className:"size-4"}),He("toolbar.settings.rows")]}),d.jsxs("div",{className:"flex h-7 items-stretch",children:[d.jsx(Oe,{type:"button",variant:"outline",size:"icon-xs",className:"h-7 w-7 rounded-r-none border-r-0","aria-label":He("toolbar.settings.decreaseRows"),disabled:rt<=1,onClick:_e=>{_e.stopPropagation(),ct(Math.max(1,rt-1))},children:d.jsx(Vte,{className:"size-3"})}),d.jsx("div",{className:"flex w-9 items-center justify-center border border-input bg-background text-xs tabular-nums",children:rt}),d.jsx(Oe,{type:"button",variant:"outline",size:"icon-xs",className:"h-7 w-7 rounded-l-none border-l-0","aria-label":He("toolbar.settings.increaseRows"),disabled:rt>=100,onClick:_e=>{_e.stopPropagation(),ct(Math.min(100,rt+1))},children:d.jsx(Hi,{className:"size-3"})})]})]})]})]})]})}function x$e({searchValue:e,onSearchChange:t,onSubmitSearch:n}){const[r,s]=w.useState(!1),i=w.useRef(null);w.useEffect(()=>{r&&i.current?.focus()},[r]);const o=()=>s(!0),a=()=>{s(!1),t?.("")};return{isSearchOpen:r,searchInputRef:i,handleSearchOpen:o,handleSearchClose:a,handleSearchSubmit:h=>{h.preventDefault();const p=i.current?.value??e;n?.(p)},handleSearchBlur:()=>{!e&&!i.current?.value&&a()}}}function w$e(){const[e,t]=w.useState(""),[n,r]=w.useState(""),[s,i]=w.useState(""),[o,a]=w.useState(!1),[l,u]=w.useState(null),[h,p]=w.useState(!1);return{sortColumnSearchTerm:e,setSortColumnSearchTerm:t,filterColumnSearchTerm:n,setFilterColumnSearchTerm:r,columnSearchTerm:s,setColumnSearchTerm:i,filterMenuOpen:o,setFilterMenuOpen:a,openPillId:l,setOpenPillId:u,isSettingsMenuOpenState:h,setIsSettingsMenuOpenState:p}}function S$e({activeView:e,onRenameView:t}){const[n,r]=w.useState(e?.label??"");w.useEffect(()=>{r(e?.label??"")},[e?.id,e?.label]);const s=w.useCallback(()=>{if(!e||!t)return;const i=n.trim();!i||i===e.label||t(e.id,i)},[e,t,n]);return{viewNameDraft:n,setViewNameDraft:r,commitViewName:s}}function C$e({seed:e,sortColumnSearchTerm:t,sortState:n,onSortChange:r}){const s=w.useMemo(()=>e.branches.filter(l=>["text","number","date"].includes(l.type)&&Ew(l).sort),[e.branches]),i=w.useMemo(()=>{const l=t.trim().toLowerCase();return l?s.filter(u=>u.label.toLowerCase().includes(l)):s},[t,s]);return{sortableBranches:s,filteredSortableColumns:i,handleToggleSortDirection:()=>{!r||!n?.columnId||r({columnId:n.columnId,desc:!n.desc})},handleSortColumnSelect:l=>{if(!r)return;if(n?.columnId===l){r({columnId:null,desc:!0});return}const h=n?.columnId==null?!0:n.desc;r({columnId:l,desc:h})}}}function k$e({seed:e,availableStatusOptions:t,groupBy:n,dateGroupPrecision:r,onDateGroupPrecisionChange:s}){const{t:i}=tt(),o=w.useMemo(()=>c$e(e,t,i("content.table.status")),[t,e,i]),a=w.useMemo(()=>o.filter(m=>m.section==="recommended"),[o]),l=w.useMemo(()=>o.filter(m=>m.section==="other"),[o]),u=w.useMemo(()=>n?o.find(m=>m.columnId===n)?.label??n:null,[n,o]),h=w.useMemo(()=>r.day?"day":r.year&&r.month?"monthYear":r.year&&!r.month?"year":"monthYear",[r.day,r.month,r.year]),p=w.useCallback(m=>{if(s){if(m==="day"){s({year:!1,month:!1,day:!0});return}if(m==="year"){s({year:!0,month:!1,day:!1});return}s({year:!0,month:!0,day:!1})}},[s]);return{groupableColumns:o,recommendedGroupColumns:a,otherGroupColumns:l,activeGroupLabel:u,datePrecisionMode:h,applyDatePrecisionMode:p}}function E$e({seed:e,filters:t,onFiltersChange:n,availableStatusOptions:r=[]}){const s=w.useMemo(()=>{const h=[{columnId:"slug",label:"Slug",type:"system"},{columnId:"status",label:"Stato",type:"select",selectOptions:r}];for(const p of e.branches){if(!Ew(p).filter)continue;const m=p.alias;p.type==="number"?h.push({columnId:m,label:p.label,type:"number"}):p.type==="date"?h.push({columnId:m,label:p.label,type:"date"}):p.type==="boolean"?h.push({columnId:m,label:p.label,type:"boolean"}):p.type==="json"&&m.toLowerCase().includes("tag")?h.push({columnId:m,label:p.label,type:"tags"}):h.push({columnId:m,label:p.label,type:"text"})}return h},[r,e.branches]),i=w.useMemo(()=>{const h=new Set(["select","number","date","boolean","tags"]);return s.filter(p=>h.has(p.type))},[s]),o=w.useCallback(h=>{const p=s.find(S=>S.columnId===h);if(!p||!n)return;const m=t[h],b=p.type==="tags"?"contains":"eq",y={id:Jy(),op:b,value:null},x={...t,[h]:m?{...m,conditions:[...m.conditions,y]}:{columnId:h,label:p.label,type:p.type,selectOptions:p.selectOptions,conditions:[y]}};n(x)},[s,t,n]),a=w.useCallback(h=>{if(!n||!t[h])return;const p={...t};delete p[h],n(p)},[t,n]),l=w.useCallback((h,p,m)=>{if(!n)return;const b=t[h];if(!b)return;const y=b.conditions.map(x=>x.id===p?{...x,...m}:x);n({...t,[h]:{...b,conditions:y}})},[t,n]),u=w.useCallback((h,p)=>{if(!n)return;const m=t[h];if(!m)return;const b=m.conditions.filter(y=>y.id!==p);if(b.length===0){const y={...t};delete y[h],n(y);return}n({...t,[h]:{...m,conditions:b}})},[t,n]);return{filterableColumns:s,formattableColumns:i,addConditionToColumn:o,removeColumnFilters:a,updateCondition:l,removeCondition:u}}function N$e({viewId:e,conditionalFormatsInput:t,formattableColumns:n,onConditionalFormatsChange:r}){const[s,i]=w.useState(null),[o,a]=w.useState(!1),l=w.useCallback(_=>_.map(T=>({...T,target:o$e(T.target),textStyles:a$e(T.textStyles)})).slice().sort((T,R)=>(T.priority??0)-(R.priority??0)),[]),u=w.useMemo(()=>l(t??[]),[t,l]);w.useEffect(()=>{if(u.length===0){i(null),a(!1);return}(!s||!u.some(_=>_.id===s))&&i(u[0].id)},[s,u]);const h=w.useMemo(()=>s?u.find(_=>_.id===s)??u[0]??null:u[0]??null,[s,u]),p=w.useCallback(_=>{!e||!r||r(e,_)},[r,e]),m=w.useCallback(_=>{const T=n.find(L=>L.columnId===_);if(!T)return;const R=Jy(),D=T.type==="tags"?"contains":"eq",j={id:R,enabled:!0,priority:u.length,label:T.label,columnId:_,group:{columnId:_,label:T.label,type:T.type,selectOptions:T.selectOptions,conditions:[{id:Jy(),op:D,value:null}]},tone:"warning",target:"row",textStyles:[]};p([...u,j]),i(R),a(!0)},[p,u,n]),b=w.useCallback((_,T)=>{const R=u.map(D=>D.id===_?{...D,...T}:D);p(R)},[p,u]),y=w.useCallback((_,T)=>{b(_,{textStyles:T.filter(R=>R==="bold"||R==="italic"||R==="underline")})},[b]),x=w.useCallback(_=>{const T=u.filter(R=>R.id!==_).map((R,D)=>({...R,priority:D}));p(T)},[p,u]),S=w.useCallback((_,T)=>{const R=u.findIndex(V=>V.id===_);if(R<0)return;const D=R+T;if(D<0||D>=u.length)return;const j=u.slice(),[L]=j.splice(R,1);j.splice(D,0,L),p(j.map((V,q)=>({...V,priority:q})))},[p,u]),C=w.useCallback((_,T,R)=>{const D=u.map(j=>{if(j.id!==_)return j;const L=j.group.conditions.map(V=>V.id===T?{...V,...R}:V);return{...j,group:{...j.group,conditions:L}}});p(D)},[p,u]),N=w.useCallback(_=>{const T=u.find(j=>j.id===_);if(!T)return;const R=T.group.type==="tags"?"contains":"eq",D=u.map(j=>j.id===_?{...j,group:{...j.group,conditions:[...j.group.conditions,{id:Jy(),op:R,value:null}]}}:j);p(D)},[p,u]),M=w.useCallback((_,T)=>{const R=u.map(D=>{if(D.id!==_)return D;const j=D.group.conditions.filter(L=>L.id!==T);return{...D,group:{...D.group,conditions:j}}}).filter(D=>D.group.conditions.length>0).map((D,j)=>({...D,priority:j}));p(R)},[p,u]);return{conditionalFormats:u,activeConditionalRule:h,activeConditionalRuleId:s,isConditionalEditorOpen:o,setActiveConditionalRuleId:i,setIsConditionalEditorOpen:a,addConditionalFormatRule:m,updateConditionalRule:b,updateConditionalTextStyles:y,removeConditionalRule:x,moveConditionalRule:S,updateConditionalCondition:C,addConditionalCondition:N,removeConditionalCondition:M}}function M$e({seed:e,views:t,activeViewId:n,onRenameView:r,isFilterActive:s,isSortActive:i,isAutomationActive:o,isSettingsOpen:a,searchValue:l="",onSearchChange:u,onSubmitSearch:h,sortState:p,onSortChange:m,filters:b={},onFiltersChange:y,availableStatusOptions:x=[],groupBy:S=null,dateGroupPrecision:C={year:!0,month:!0,day:!1},onDateGroupPrecisionChange:N,onConditionalFormatsChange:M}){const _=t.find(ue=>ue.id===n),{isSearchOpen:T,searchInputRef:R,handleSearchOpen:D,handleSearchClose:j,handleSearchSubmit:L,handleSearchBlur:V}=x$e({searchValue:l,onSearchChange:u,onSubmitSearch:h}),{sortColumnSearchTerm:q,setSortColumnSearchTerm:X,filterColumnSearchTerm:ee,setFilterColumnSearchTerm:re,columnSearchTerm:oe,setColumnSearchTerm:F,filterMenuOpen:se,setFilterMenuOpen:le,openPillId:W,setOpenPillId:Q,isSettingsMenuOpenState:H,setIsSettingsMenuOpenState:U}=w$e(),{viewNameDraft:Z,setViewNameDraft:he,commitViewName:fe}=S$e({activeView:_,onRenameView:r}),ye=w.useMemo(()=>_?.enabledTools??s$e,[_]),ge=s??Object.values(b).some(ue=>ue.conditions.length>0),Ee=i??!!p?.columnId,Ae=o??!1,Qe=a??H,rt=()=>{a===void 0&&U(!1)},ct=ue=>ye.includes(ue),He=C$e({seed:e,sortColumnSearchTerm:q,sortState:p,onSortChange:m}),{filterableColumns:_e,formattableColumns:nn,addConditionToColumn:xt,removeColumnFilters:Jt,updateCondition:fn,removeCondition:hn}=E$e({seed:e,filters:b,onFiltersChange:y,availableStatusOptions:x}),zn=N$e({viewId:_?.id,conditionalFormatsInput:_?.conditionalFormats,formattableColumns:nn,onConditionalFormatsChange:M}),lr=w.useMemo(()=>[{id:"slug",label:"Slug"},{id:"status",label:"Stato"},...e.branches.map(ue=>({id:ue.alias,label:ue.label}))],[e.branches]),In=w.useMemo(()=>{const ue=ee.trim().toLowerCase();return ue?_e.filter(Fe=>Fe.label.toLowerCase().includes(ue)):_e},[ee,_e]),Fn=w.useMemo(()=>Object.fromEntries(Object.entries(b).map(([ue,Fe])=>[ue,Fe.conditions.length])),[b]),G=w.useMemo(()=>{const ue=oe.trim().toLowerCase();return ue?lr.filter(Fe=>Fe.label.toLowerCase().includes(ue)):lr},[oe,lr]),pe=k$e({seed:e,availableStatusOptions:x,groupBy:S,dateGroupPrecision:C,onDateGroupPrecisionChange:N});return{activeView:_,enabledTools:ye,isFilterActiveEffective:ge,isSortActiveEffective:Ee,isAutomationActiveEffective:Ae,isSettingsMenuOpenEffective:Qe,closeSettingsMenu:rt,isToolEnabled:ct,isSearchOpen:T,searchInputRef:R,handleSearchOpen:D,handleSearchClose:j,handleSearchSubmit:L,handleSearchBlur:V,sortColumnSearchTerm:q,setSortColumnSearchTerm:X,filterColumnSearchTerm:ee,setFilterColumnSearchTerm:re,columnSearchTerm:oe,setColumnSearchTerm:F,filterMenuOpen:se,setFilterMenuOpen:le,openPillId:W,setOpenPillId:Q,isSettingsMenuOpenState:H,setIsSettingsMenuOpenState:U,viewNameDraft:Z,setViewNameDraft:he,commitViewName:fe,...He,filterableColumns:_e,formattableColumns:nn,addConditionToColumn:xt,removeColumnFilters:Jt,updateCondition:fn,removeCondition:hn,visibleFilterColumns:In,activeFiltersCountByColumn:Fn,...zn,tableColumns:lr,filteredTableColumns:G,...pe}}function _$e(e){const{seed:t,views:n,children:r,filters:s={},availableTagsByColumnId:i={}}=e,{t:o}=tt(),a=M$e(e),{activeViewId:l,onChangeView:u,onCreateView:h,onRenameView:p,onCreate:m,onOpenAutomation:b,onOpenFilters:y,onOpenSort:x,onOpenSettings:S,sortState:C,onSortChange:N,onConditionalFormatsChange:M,columnVisibility:_,onColumnVisibilityChange:T,pageSize:R,onPageSizeChange:D,groupBy:j,onGroupByChange:L}=e,{activeView:V,isFilterActiveEffective:q,isSortActiveEffective:X,isAutomationActiveEffective:ee,isSettingsMenuOpenEffective:re,closeSettingsMenu:oe,isToolEnabled:F,isSearchOpen:se,searchInputRef:le,handleSearchOpen:W,handleSearchClose:Q,handleSearchSubmit:H,handleSearchBlur:U,sortColumnSearchTerm:Z,setSortColumnSearchTerm:he,filterColumnSearchTerm:fe,setFilterColumnSearchTerm:ye,columnSearchTerm:ge,setColumnSearchTerm:Ee,filterMenuOpen:Ae,setFilterMenuOpen:Qe,openPillId:rt,setOpenPillId:ct,setIsSettingsMenuOpenState:He,viewNameDraft:_e,setViewNameDraft:nn,commitViewName:xt,filteredSortableColumns:Jt,handleToggleSortDirection:fn,handleSortColumnSelect:hn,addConditionToColumn:zn,removeColumnFilters:lr,updateCondition:In,removeCondition:Fn,visibleFilterColumns:G,activeFiltersCountByColumn:pe,conditionalFormats:ue,activeConditionalRule:Fe,isConditionalEditorOpen:$e,setActiveConditionalRuleId:ze,setIsConditionalEditorOpen:qe,addConditionalFormatRule:Rt,updateConditionalRule:Ot,updateConditionalTextStyles:xn,removeConditionalRule:gn,moveConditionalRule:en,updateConditionalCondition:Lt,addConditionalCondition:ls,removeConditionalCondition:Sr,filteredTableColumns:yt,formattableColumns:Bt,recommendedGroupColumns:gt,otherGroupColumns:Pt,activeGroupLabel:Re,datePrecisionMode:P,applyDatePrecisionMode:K}=a;if(!V)return null;const be=Object.keys(s).length>0||!!Re;return d.jsxs("div",{"data-seed-slug":t.slug,children:[d.jsx("div",{className:"sticky top-(--header-height) z-10 bg-background/95 backdrop-blur-sm border-b",children:d.jsx(Zn,{className:"py-3 border-0 bg-transparent shadow-none rounded-none",children:d.jsxs(Xn,{className:"px-4 py-0",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[d.jsx(h$e,{views:n,activeViewId:l,onChangeView:u,onCreateView:h}),d.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[F("filter")&&d.jsx(n$e,{open:Ae,onOpenChange:Qe,isActive:q,onOpen:y,searchTerm:fe,onSearchTermChange:ye,visibleFilterColumns:G,activeFiltersCountByColumn:pe,onSelectColumn:Pe=>{zn(Pe),Qe(!1),ye(""),ct(Pe)}}),F("sort")&&d.jsx(r$e,{searchTerm:Z,onSearchTermChange:he,filteredSortableColumns:Jt,sortState:C,onToggleDirection:fn,onSelectColumn:hn,isActive:X,onOpen:x}),F("automation")&&d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Oe,{variant:ee?"secondary":"ghost",size:"icon-sm","aria-label":o("toolbar.automation"),onClick:()=>b?.(),children:d.jsx(Rg,{className:"size-4"})})}),d.jsx(fa,{side:"top",children:o("toolbar.automation")})]}),F("search")&&d.jsx(p$e,{isSearchOpen:se,searchValue:e.searchValue??"",searchInputRef:le,handleSearchSubmit:H,onSearchChange:e.onSearchChange,handleSearchBlur:U,handleSearchClose:Q,handleSearchOpen:W}),F("settings")&&d.jsx(v$e,{isSettingsMenuOpenEffective:re,setIsSettingsMenuOpenState:He,onOpenSettings:S,isSettingsOpen:e.isSettingsOpen,commitViewName:xt,setColumnSearchTerm:Ee,viewNameDraft:_e,setViewNameDraft:nn,setIsConditionalEditorOpen:qe,filterColumnSearchTerm:fe,setFilterColumnSearchTerm:ye,visibleFilterColumns:G,addConditionToColumn:zn,setOpenPillId:ct,closeSettingsMenu:oe,filters:s,sortColumnSearchTerm:Z,setSortColumnSearchTerm:he,handleToggleSortDirection:fn,sortState:C,filteredSortableColumns:Jt,handleSortColumnSelect:hn,groupBy:j??null,onGroupByChange:L,recommendedGroupColumns:gt,datePrecisionMode:P,applyDatePrecisionMode:K,otherGroupColumns:Pt,onConditionalFormatsChange:M,formattableColumns:Bt,conditionalFormats:ue,activeConditionalRule:Fe,isConditionalEditorOpen:$e,setActiveConditionalRuleId:ze,addConditionalFormatRule:Rt,updateConditionalRule:Ot,updateConditionalTextStyles:xn,removeConditionalRule:gn,moveConditionalRule:en,updateConditionalCondition:Lt,addConditionalCondition:ls,removeConditionalCondition:Sr,availableTagsByColumnId:i,columnVisibility:_,onColumnVisibilityChange:T,columnSearchTerm:ge,filteredTableColumns:yt,pageSize:R,onPageSizeChange:D}),F("create")&&d.jsxs(Oe,{variant:"default",size:"sm",onClick:m,className:"gap-1.5",children:[d.jsx(Hi,{className:"size-4"}),o("siteHeader.new")]})]})]}),be&&d.jsx("div",{className:"mt-3 pt-3 border-t",children:d.jsx(u$e,{filters:s,openPillId:rt,onOpenPillChange:ct,groupBy:j??null,activeGroupLabel:Re??"",onGroupByChange:L,addConditionToColumn:zn,removeColumnFilters:lr,updateCondition:In,removeCondition:Fn,availableTagsByColumnId:i})})]})})}),r!=null&&d.jsx("div",{className:"mt-4",children:r})]})}const Pp={fetchList:async(e,t)=>(await Gt.get(`/content/${e}`,{params:{...t,filters:t.filters!=null?JSON.stringify(t.filters):void 0}})).data,fetchFacets:async e=>(await Gt.get(`/content/${e}/facets`)).data,fetchById:async(e,t)=>(await Gt.get(`/content/${e}/${t}`)).data,create:async(e,t)=>(await Gt.post(`/content/${e}`,t)).data,update:async(e,t,n)=>(await Gt.put(`/content/${e}/${t}`,n)).data,delete:async(e,t)=>(await Gt.delete(`/content/${e}/${t}`)).data},hc={all:["content"],lists:()=>[...hc.all,"list"],list:(e,t)=>[...hc.lists(),e,t],details:()=>[...hc.all,"detail"],detail:(e,t)=>[...hc.details(),e,t]},f8={all:["facets"],bySlug:e=>[...f8.all,e]};function T$e(e,t){return Ir({queryKey:hc.list(e||"",t),queryFn:()=>{if(!e)throw new Error("Slug is required");return Pp.fetchList(e,t)},enabled:!!e,placeholderData:n=>n,staleTime:10*1e3})}const si={all:["dashboard"],stats:()=>[...si.all,"stats"],cloudflare:()=>[...si.all,"cloudflare"],activity:()=>[...si.all,"activity"],health:()=>[...si.all,"health"],breakdown:()=>[...si.all,"breakdown"],setupChecklist:()=>[...si.all,"setup-checklist"]};function A$e(e){return Ir({queryKey:f8.bySlug(e||""),queryFn:()=>{if(!e)throw new Error("Slug is required");return Pp.fetchFacets(e)},enabled:!!e,staleTime:300*1e3,gcTime:1800*1e3})}function R$e(){const e=wi();return Fs({mutationFn:({slug:t,id:n})=>Pp.delete(t,n),onSuccess:()=>{e.invalidateQueries({queryKey:hc.all}),e.invalidateQueries({queryKey:si.activity()})}})}function O$e(e,t){return Ir({queryKey:hc.detail(e||"",t||""),queryFn:()=>{if(!e||!t)throw new Error("Slug and ID are required");return Pp.fetchById(e,t)},enabled:!!(e&&t),staleTime:10*1e3})}function D$e(){const e=wi();return Fs({mutationFn:async({slug:t,id:n,data:r})=>n?Pp.update(t,n,r):Pp.create(t,r),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:hc.all}),e.invalidateQueries({queryKey:f8.all}),n.id&&e.invalidateQueries({queryKey:hc.detail(n.slug,n.id)}),e.invalidateQueries({queryKey:si.activity()}),e.invalidateQueries({queryKey:si.stats()})}})}const zh="/automations",h1={list:e=>Gt.get(zh,{params:{seed:e}}).then(t=>t.data),get:e=>Gt.get(`${zh}/${e}`).then(t=>t.data),create:e=>Gt.post(zh,e).then(t=>t.data),update:(e,t)=>Gt.put(`${zh}/${e}`,t),toggle:(e,t)=>Gt.patch(`${zh}/${e}/toggle`,{enabled:t}),remove:e=>Gt.delete(`${zh}/${e}`)},fl={all:["automations"],lists:()=>[...fl.all,"list"],list:e=>[...fl.lists(),e],items:()=>[...fl.all,"item"],item:e=>[...fl.items(),e]};function fZ(e){return Ir({queryKey:fl.list(e??""),queryFn:()=>h1.list(e),enabled:!!e,staleTime:1e4})}function j$e(e){const t=wi(),{t:n}=tt();return Fs({mutationFn:({id:r,enabled:s})=>h1.toggle(r,s),onSuccess:()=>{t.invalidateQueries({queryKey:fl.list(e)}),_n.success(n("automations.toast.toggled"))},onError:()=>{_n.error(n("automations.toast.error"))}})}function I$e(e){const t=wi(),{t:n}=tt();return Fs({mutationFn:r=>h1.remove(r),onSuccess:()=>{t.invalidateQueries({queryKey:fl.list(e)}),_n.success(n("automations.toast.deleted"))},onError:()=>{_n.error(n("automations.toast.error"))}})}function z$e({automation:e,onEdit:t,onDelete:n,onToggle:r,isToggling:s}){const{t:i}=tt();return d.jsxs("div",{className:"flex items-center gap-3 py-3 px-1 border-b last:border-0",children:[d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("p",{className:"text-sm font-medium truncate",children:e.name}),d.jsx("p",{className:"text-xs text-muted-foreground",children:e.triggers.map(o=>i(`automations.triggers.${o.event}`)).join(" / ")})]}),d.jsx(f7,{checked:e.enabled,onCheckedChange:r,disabled:s,"aria-label":i("automations.panel.toggleAriaLabel")}),d.jsx(Oe,{variant:"ghost",size:"icon",className:"size-7",onClick:t,"aria-label":i("common.edit"),children:d.jsx(I6,{className:"size-3.5"})}),d.jsx(Oe,{variant:"ghost",size:"icon",className:"size-7 text-destructive hover:text-destructive",onClick:n,"aria-label":i("common.delete"),children:d.jsx(La,{className:"size-3.5"})})]})}function L$e({onNew:e}){const{t}=tt();return d.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[d.jsx("div",{className:"flex size-12 items-center justify-center rounded-full bg-muted mb-4",children:d.jsx(Rg,{className:"size-6 text-muted-foreground"})}),d.jsx("h3",{className:"text-sm font-medium mb-1",children:t("automations.panel.emptyTitle")}),d.jsx("p",{className:"text-xs text-muted-foreground mb-4 max-w-48",children:t("automations.panel.emptyDescription")}),d.jsx(Oe,{size:"sm",onClick:e,children:t("automations.panel.emptyAction")})]})}function P$e(){const[e,t]=w.useState(!1),[n,r]=w.useState(void 0);function s(){r(void 0),t(!0)}function i(a){r(a),t(!0)}function o(){t(!1),r(void 0)}return{editorOpen:e,editingAutomation:n,openNew:s,openEdit:i,closeEditor:o}}var p1=e=>e.type==="checkbox",Kd=e=>e instanceof Date,Ti=e=>e==null;const hZ=e=>typeof e=="object";var rs=e=>!Ti(e)&&!Array.isArray(e)&&hZ(e)&&!Kd(e),$$e=e=>rs(e)&&e.target?p1(e.target)?e.target.checked:e.target.value:e,F$e=(e,t)=>t.split(".").some((n,r,s)=>!isNaN(Number(n))&&e.has(s.slice(0,r).join("."))),B$e=e=>{const t=e.constructor&&e.constructor.prototype;return rs(t)&&t.hasOwnProperty("isPrototypeOf")},h8=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function br(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(h8&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(rs(e)&&B$e(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=br(e[s]));return r}var Pw=e=>/^\w*$/.test(e),pr=e=>e===void 0,$w=e=>Array.isArray(e)?e.filter(Boolean):[],p8=e=>$w(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ut=(e,t,n)=>{if(!t||!rs(e))return n;const s=(Pw(t)?[t]:p8(t)).reduce((i,o)=>Ti(i)?void 0:i[o],e);return pr(s)||s===e?pr(e[t])?n:e[t]:s},el=e=>typeof e=="boolean",Qo=e=>typeof e=="function",rr=(e,t,n)=>{let r=-1;const s=Pw(t)?[t]:p8(t),i=s.length,o=i-1;for(;++r<i;){const a=s[r];let l=n;if(r!==o){const u=e[a];l=rs(u)||Array.isArray(u)?u:isNaN(+s[r+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;e[a]=l,e=e[a]}};const Lh={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},ea={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Sa={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},V3="form",pZ="root",m8=te.createContext(null);m8.displayName="HookFormControlContext";const H$e=()=>te.useContext(m8);var U$e=(e,t,n,r=!0)=>{const s={};for(const i in e)Object.defineProperty(s,i,{get:()=>{const o=i;return t._proxyFormState[o]!==ea.all&&(t._proxyFormState[o]=!r||ea.all),e[o]}});return s};const mZ=typeof window<"u"?te.useLayoutEffect:te.useEffect;var mi=e=>typeof e=="string",V$e=(e,t,n,r,s)=>mi(e)?(r&&t.watch.add(e),ut(n,e,s)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),ut(n,i))):(r&&(t.watchAll=!0),n),u6=e=>Ti(e)||!hZ(e);function tl(e,t,n=new WeakSet){if(e===t)return!0;if(u6(e)||u6(t))return Object.is(e,t);if(Kd(e)&&Kd(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const i of r){const o=e[i];if(!(i in t))return!1;if(i!=="ref"){const a=t[i];if(Kd(o)&&Kd(a)||(rs(o)||Array.isArray(o))&&(rs(a)||Array.isArray(a))?!tl(o,a,n):!Object.is(o,a))return!1}}return!0}const g8=te.createContext(null);g8.displayName="HookFormContext";const Ml=()=>te.useContext(g8),q$e=e=>{const{children:t,watch:n,getValues:r,getFieldState:s,setError:i,clearErrors:o,setValue:a,setValues:l,trigger:u,formState:h,resetField:p,reset:m,handleSubmit:b,unregister:y,control:x,register:S,setFocus:C,subscribe:N}=e,M=te.useMemo(()=>({watch:n,getValues:r,getFieldState:s,setError:i,clearErrors:o,setValue:a,setValues:l,trigger:u,formState:h,resetField:p,reset:m,handleSubmit:b,unregister:y,control:x,register:S,setFocus:C,subscribe:N}),[o,x,h,s,r,b,S,m,p,i,C,a,l,N,u,y,n]);return te.createElement(g8.Provider,{value:M},te.createElement(m8.Provider,{value:M.control},t))};var b8=(e,t,n,r,s)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:s||!0}}:{},no=e=>Array.isArray(e)?e:[e],RI=()=>{let e=[];return{get observers(){return e},next:s=>{for(const i of e)i.next&&i.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(i=>i!==s)}}),unsubscribe:()=>{e=[]}}};function gZ(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const s=e[r],i=t[r];if(s&&rs(s)&&i){const o=gZ(s,i);rs(o)&&(n[r]=o)}else e[r]&&(n[r]=i)}return n}var ei=e=>rs(e)&&!Object.keys(e).length,y8=e=>e.type==="file",Bx=e=>{if(!h8)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},bZ=e=>e.type==="select-multiple",v8=e=>e.type==="radio",G$e=e=>v8(e)||p1(e),q3=e=>Bx(e)&&e.isConnected;function W$e(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;){if(Ti(e)){e=void 0;break}e=e[t[r]],r++}return e}function K$e(e){for(const t in e)if(e.hasOwnProperty(t)&&!pr(e[t]))return!1;return!0}function fs(e,t){if(mi(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const n=Array.isArray(t)?t:Pw(t)?[t]:p8(t),r=n.length===1?e:W$e(e,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(rs(r)&&ei(r)||Array.isArray(r)&&K$e(r))&&fs(e,n.slice(0,-1)),e}var Y$e=e=>{for(const t in e)if(Qo(e[t]))return!0;return!1};function yZ(e){return Array.isArray(e)||rs(e)&&!Y$e(e)}function d6(e,t={}){for(const n in e){const r=e[n];yZ(r)?(t[n]=Array.isArray(r)?[]:{},d6(r,t[n])):pr(r)||(t[n]=!0)}return t}function f6(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(n=>f6(n));return t.some(n=>n!==void 0)?t:void 0}if(rs(e)){const t={};for(const n in e){const r=f6(e[n]);pr(r)||(t[n]=r)}return Object.keys(t).length?t:void 0}}}function zm(e,t,n){n||(n=d6(t));for(const r in e){const s=e[r];if(yZ(s))pr(t)||u6(n[r])?n[r]=d6(s,Array.isArray(s)?[]:{}):zm(s,Ti(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!tl(s,i)}}return f6(n)||{}}const OI={value:!1,isValid:!1},DI={value:!0,isValid:!0};var vZ=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!pr(e[0].attributes.value)?pr(e[0].value)||e[0].value===""?DI:{value:e[0].value,isValid:!0}:DI:OI}return OI},xZ=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>pr(e)?e:t?e===""?NaN:e&&+e:n&&mi(e)?new Date(e):r?r(e):e;const jI={isValid:!1,value:null};var wZ=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,jI):jI;function II(e){const t=e.ref;return y8(t)?t.files:v8(t)?wZ(e.refs).value:bZ(t)?[...t.selectedOptions].map(({value:n})=>n):p1(t)?vZ(e.refs).value:xZ(pr(t.value)?e.ref.value:t.value,e)}var Z$e=(e,t,n,r)=>{const s={};for(const i of e){const o=ut(t,i);o&&rr(s,i,o._f)}return{criteriaMode:n,names:[...e],fields:s,shouldUseNativeValidation:r}},Hx=e=>e instanceof RegExp,ym=e=>pr(e)?e:Hx(e)?e.source:rs(e)?Hx(e.value)?e.value.source:e.value:e,Jh=e=>({isOnSubmit:!e||e===ea.onSubmit,isOnBlur:e===ea.onBlur,isOnChange:e===ea.onChange,isOnAll:e===ea.all,isOnTouch:e===ea.onTouched});const zI="AsyncFunction";var X$e=e=>!!e&&!!e.validate&&!!(Qo(e.validate)&&e.validate.constructor.name===zI||rs(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===zI)),Q$e=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),h6=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const dp=(e,t,n,r)=>{for(const s of n||Object.keys(e)){const i=ut(e,s);if(i){const{_f:o,...a}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],s)&&!r)return!0;if(o.ref&&t(o.ref,o.name)&&!r)return!0;if(dp(a,t))break}else if(rs(a)&&dp(a,t))break}}};function LI(e,t,n){const r=ut(e,n);if(r||Pw(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),o=ut(t,i),a=ut(e,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(a&&a.type)return{name:i,error:a};if(a&&a.root&&a.root.type)return{name:`${i}.root`,error:a.root};s.pop()}return{name:n}}var J$e=(e,t,n,r)=>{n(e);const{name:s,...i}=e;return ei(i)||r&&Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(o=>t[o]===(!r||ea.all))},eFe=(e,t,n)=>!e||!t||e===t||no(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),tFe=(e,t,n,r,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(t||e):(n?r.isOnBlur:s.isOnBlur)?!e:(n?r.isOnChange:s.isOnChange)?e:!0,nFe=(e,t)=>!$w(ut(e,t)).length&&fs(e,t),SZ=(e,t,n)=>{const r=no(ut(e,n));return rr(r,pZ,t[n]),rr(e,n,r),e};function PI(e,t,n="validate"){if(mi(e)||Array.isArray(e)&&e.every(mi)||el(e)&&!e)return{type:n,message:mi(e)?e:"",ref:t}}var Ph=e=>rs(e)&&!Hx(e)?e:{value:e,message:""},p6=async(e,t,n,r,s,i)=>{const{ref:o,refs:a,required:l,maxLength:u,minLength:h,min:p,max:m,pattern:b,validate:y,name:x,valueAsNumber:S,mount:C}=e._f,N=ut(n,x);if(!C||t.has(x))return{};const M=a?a[0]:o,_=X=>{s&&M.reportValidity&&(M.setCustomValidity(el(X)?"":X||""),M.reportValidity())},T={},R=v8(o),D=p1(o),j=R||D,L=(S||y8(o))&&pr(o.value)&&pr(N)||Bx(o)&&o.value===""||N===""||Array.isArray(N)&&!N.length||S&&typeof N=="number"&&isNaN(N),V=b8.bind(null,x,r,T),q=(X,ee,re,oe=Sa.maxLength,F=Sa.minLength)=>{const se=X?ee:re;T[x]={type:X?oe:F,message:se,ref:o,...V(X?oe:F,se)}};if(i?!Array.isArray(N)||!N.length:l&&(!j&&(L||Ti(N))||el(N)&&!N||D&&!vZ(a).isValid||R&&!wZ(a).isValid)){const{value:X,message:ee}=mi(l)?{value:!!l,message:l}:Ph(l);if(X&&(T[x]={type:Sa.required,message:ee,ref:M,...V(Sa.required,ee)},!r))return _(ee),T}if(!L&&(!Ti(p)||!Ti(m))){let X,ee;const re=Ph(m),oe=Ph(p);if(!Ti(N)&&!isNaN(N)){const F=o.valueAsNumber||N&&+N;Ti(re.value)||(X=F>re.value),Ti(oe.value)||(ee=F<oe.value)}else{const F=o.valueAsDate||new Date(N),se=Q=>new Date(new Date().toDateString()+" "+Q),le=o.type=="time",W=o.type=="week";mi(re.value)&&N&&(X=le?se(N)>se(re.value):W?N>re.value:F>new Date(re.value)),mi(oe.value)&&N&&(ee=le?se(N)<se(oe.value):W?N<oe.value:F<new Date(oe.value))}if((X||ee)&&(q(!!X,re.message,oe.message,Sa.max,Sa.min),!r))return _(T[x].message),T}if((u||h)&&!L&&(mi(N)||i&&Array.isArray(N))){const X=Ph(u),ee=Ph(h),re=!Ti(X.value)&&N.length>+X.value,oe=!Ti(ee.value)&&N.length<+ee.value;if((re||oe)&&(q(re,X.message,ee.message),!r))return _(T[x].message),T}if(b&&!L&&mi(N)){const{value:X,message:ee}=Ph(b);if(Hx(X)&&!N.match(X)&&(T[x]={type:Sa.pattern,message:ee,ref:o,...V(Sa.pattern,ee)},!r))return _(ee),T}if(y){if(Qo(y)){const X=await y(N,n),ee=PI(X,M);if(ee&&(T[x]={...ee,...V(Sa.validate,ee.message)},!r))return _(ee.message),T}else if(rs(y)){let X={};for(const ee in y){if(!ei(X)&&!r)break;const re=PI(await y[ee](N,n),M,ee);re&&(X={...re,...V(ee,re.message)},_(re.message),r&&(T[x]=X))}if(!ei(X)&&(T[x]={ref:M,...X},!r))return T}}return _(!0),T};const rFe={mode:ea.onSubmit,reValidateMode:ea.onChange,shouldFocusError:!0},CZ={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function sFe(e={}){let t={...rFe,...e},n={...br(CZ),isLoading:Qo(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},r={},s=rs(t.defaultValues)||rs(t.values)?br(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:br(s),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},l,u=0;const h={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},p={...h};let m={...p};const b={array:RI(),state:RI()},y=t.criteriaMode===ea.all,x=G=>pe=>{clearTimeout(u),u=setTimeout(G,pe)},S=async G=>{if(!o.keepIsValid&&!t.disabled&&(p.isValid||m.isValid||G)){let pe;t.resolver?(pe=ei((await L()).errors),C()):pe=await X({fields:r,onlyCheckValid:!0,eventType:Lh.VALID}),pe!==n.isValid&&b.state.next({isValid:pe})}},C=(G,pe)=>{!t.disabled&&(p.isValidating||p.validatingFields||m.isValidating||m.validatingFields)&&((G||Array.from(a.mount)).forEach(ue=>{ue&&(pe?rr(n.validatingFields,ue,pe):fs(n.validatingFields,ue))}),b.state.next({validatingFields:n.validatingFields,isValidating:!ei(n.validatingFields)}))},N=()=>{n.dirtyFields=zm(s,i)},M=(G,pe=[],ue,Fe,$e=!0,ze=!0)=>{if(Fe&&ue&&!t.disabled){if(o.action=!0,ze&&Array.isArray(ut(r,G))){const qe=ue(ut(r,G),Fe.argA,Fe.argB);$e&&rr(r,G,qe)}if(ze&&Array.isArray(ut(n.errors,G))){const qe=ue(ut(n.errors,G),Fe.argA,Fe.argB);$e&&rr(n.errors,G,qe),nFe(n.errors,G)}if((p.touchedFields||m.touchedFields)&&ze&&Array.isArray(ut(n.touchedFields,G))){const qe=ue(ut(n.touchedFields,G),Fe.argA,Fe.argB);$e&&rr(n.touchedFields,G,qe)}(p.dirtyFields||m.dirtyFields)&&N(),b.state.next({name:G,isDirty:re(G,pe),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else rr(i,G,pe)},_=(G,pe)=>{rr(n.errors,G,pe),b.state.next({errors:n.errors})},T=G=>{n.errors=G,b.state.next({errors:n.errors,isValid:!1})},R=(G,pe,ue,Fe)=>{const $e=ut(r,G);if($e){const ze=pr(ut(i,G)),qe=ut(i,G,pr(ue)?ut(s,G):ue);pr(qe)||Fe&&Fe.defaultChecked||pe?rr(i,G,pe?qe:II($e._f)):se(G,qe),o.mount&&!o.action&&(S(),ze&&n.isDirty&&(p.isDirty||m.isDirty)&&(re()||(n.isDirty=!1,b.state.next({...n}))))}},D=(G,pe,ue,Fe,$e)=>{let ze=!1,qe=!1;const Rt={name:G};if(!t.disabled){if(!ue||Fe){(p.isDirty||m.isDirty)&&(qe=n.isDirty,n.isDirty=Rt.isDirty=re(),ze=qe!==Rt.isDirty);const Ot=tl(ut(s,G),pe);qe=!!ut(n.dirtyFields,G),Ot?fs(n.dirtyFields,G):rr(n.dirtyFields,G,!0),Rt.dirtyFields=n.dirtyFields,ze=ze||(p.dirtyFields||m.dirtyFields)&&qe!==!Ot}if(ue){const Ot=ut(n.touchedFields,G);Ot||(rr(n.touchedFields,G,ue),Rt.touchedFields=n.touchedFields,ze=ze||(p.touchedFields||m.touchedFields)&&Ot!==ue)}ze&&$e&&b.state.next(Rt)}return ze?Rt:{}},j=(G,pe,ue,Fe)=>{const $e=ut(n.errors,G),ze=(p.isValid||m.isValid)&&el(pe)&&n.isValid!==pe;if(t.delayError&&ue?(l=x(()=>_(G,ue)),l(t.delayError)):(clearTimeout(u),l=null,ue?rr(n.errors,G,ue):fs(n.errors,G)),(ue?!tl($e,ue):$e)||!ei(Fe)||ze){const qe={...Fe,...ze&&el(pe)?{isValid:pe}:{},errors:n.errors,name:G};n={...n,...qe},b.state.next(qe)}},L=async G=>(C(G,!0),await t.resolver(i,t.context,Z$e(G||a.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),V=async G=>{const{errors:pe}=await L(G);if(C(G),G)for(const ue of G){const Fe=ut(pe,ue);Fe?rr(n.errors,ue,Fe):fs(n.errors,ue)}else n.errors=pe;return pe},q=async({name:G,eventType:pe})=>{if(e.validate){const ue=await e.validate({formValues:i,formState:n,name:G,eventType:pe});if(rs(ue))for(const Fe in ue)ue[Fe]&&ge(`${V3}.${Fe}`,{message:mi(ue.message)?ue.message:"",type:Sa.validate});else mi(ue)||!ue?ge(V3,{message:ue||"",type:Sa.validate}):ye(V3);return ue}return!0},X=async({fields:G,onlyCheckValid:pe,name:ue,eventType:Fe,context:$e={valid:!0,runRootValidation:!1}})=>{if(e.validate&&($e.runRootValidation=!0,!await q({name:ue,eventType:Fe})&&($e.valid=!1,pe)))return $e.valid;for(const ze in G){const qe=G[ze];if(qe){const{_f:Rt,...Ot}=qe;if(Rt){const xn=a.array.has(Rt.name),gn=qe._f&&X$e(qe._f);gn&&p.validatingFields&&C([Rt.name],!0);const en=await p6(qe,a.disabled,i,y,t.shouldUseNativeValidation&&!pe,xn);if(gn&&p.validatingFields&&C([Rt.name]),en[Rt.name]&&($e.valid=!1,pe)||(!pe&&(ut(en,Rt.name)?xn?SZ(n.errors,en,Rt.name):rr(n.errors,Rt.name,en[Rt.name]):fs(n.errors,Rt.name)),e.shouldUseNativeValidation&&en[Rt.name]))break}!ei(Ot)&&await X({context:$e,onlyCheckValid:pe,fields:Ot,name:ze,eventType:Fe})}}return $e.valid},ee=()=>{for(const G of a.unMount){const pe=ut(r,G);pe&&(pe._f.refs?pe._f.refs.every(ue=>!q3(ue)):!q3(pe._f.ref))&&rt(G)}a.unMount=new Set},re=(G,pe)=>!t.disabled&&(G&&pe&&rr(i,G,pe),!tl(he(),s)),oe=(G,pe,ue)=>V$e(G,a,{...o.mount?i:pr(pe)?s:mi(G)?{[G]:pe}:pe},ue,pe),F=G=>$w(ut(o.mount?i:s,G,t.shouldUnregister?ut(s,G,[]):[])),se=(G,pe,ue={})=>{const Fe=ut(r,G);let $e=pe;if(Fe){const ze=Fe._f;ze&&(!ze.disabled&&rr(i,G,xZ(pe,ze)),$e=Bx(ze.ref)&&Ti(pe)?"":pe,bZ(ze.ref)?[...ze.ref.options].forEach(qe=>qe.selected=$e.includes(qe.value)):ze.refs?p1(ze.ref)?ze.refs.forEach(qe=>{(!qe.defaultChecked||!qe.disabled)&&(Array.isArray($e)?qe.checked=!!$e.find(Rt=>Rt===qe.value):qe.checked=$e===qe.value||!!$e)}):ze.refs.forEach(qe=>qe.checked=qe.value===$e):y8(ze.ref)?ze.ref.value="":(ze.ref.value=$e,ze.ref.type||b.state.next({name:G,values:br(i)})))}(ue.shouldDirty||ue.shouldTouch)&&D(G,$e,ue.shouldTouch,ue.shouldDirty,!0),ue.shouldValidate&&Z(G)},le=(G,pe,ue)=>{for(const Fe in pe){if(!pe.hasOwnProperty(Fe))return;const $e=pe[Fe],ze=G+"."+Fe,qe=ut(r,ze);(a.array.has(G)||rs($e)||qe&&!qe._f)&&!Kd($e)?le(ze,$e,ue):se(ze,$e,ue)}},W=(G,pe,ue={})=>{const Fe=ut(r,G),$e=a.array.has(G),ze=br(pe),qe=ut(i,G),Rt=tl(qe,ze);if(rr(i,G,ze),$e)b.array.next({name:G,values:br(i)}),(p.isDirty||p.dirtyFields||m.isDirty||m.dirtyFields)&&ue.shouldDirty&&(N(),b.state.next({name:G,dirtyFields:n.dirtyFields,isDirty:re(G,ze)}));else{const Ot=Array.isArray(ze)&&!ze.length||ei(ze);!Fe||Fe._f||Ti(ze)||Ot?se(G,ze,ue):le(G,ze,ue)}if(!Rt){const Ot=h6(G,a);b.state.next({...Ot&&n,name:o.mount||Ot?G:void 0,values:br(i)})}},Q=G=>{const pe=Qo(G)?G(i):G;tl(i,pe)||(i={...i,...pe},b.state.next({...n,values:i}))},H=async G=>{o.mount=!0;const pe=G.target;let ue=pe.name,Fe=!0;const $e=ut(r,ue),ze=Ot=>{Fe=Number.isNaN(Ot)||Kd(Ot)&&isNaN(Ot.getTime())||tl(Ot,ut(i,ue,Ot))},qe=Jh(t.mode),Rt=Jh(t.reValidateMode);if($e){let Ot,xn;const gn=pe.type?II($e._f):$$e(G),en=G.type===Lh.BLUR||G.type===Lh.FOCUS_OUT,Lt=!Q$e($e._f)&&!e.validate&&!t.resolver&&!ut(n.errors,ue)&&!$e._f.deps||tFe(en,ut(n.touchedFields,ue),n.isSubmitted,Rt,qe),ls=h6(ue,a,en);rr(i,ue,gn),en?(!pe||!pe.readOnly)&&($e._f.onBlur&&$e._f.onBlur(G),l&&l(0)):$e._f.onChange&&$e._f.onChange(G);const Sr=D(ue,gn,en),yt=!ei(Sr)||ls;if(!en&&b.state.next({name:ue,type:G.type,values:br(i)}),Lt)return(p.isValid||m.isValid)&&(t.mode==="onBlur"?en&&S():en||S()),yt&&b.state.next({name:ue,...ls?{}:Sr});if(!t.resolver&&e.validate&&await q({name:ue,eventType:G.type}),!en&&ls&&b.state.next({...n}),t.resolver){const{errors:Bt}=await L([ue]);if(C([ue]),ze(gn),Fe){const gt=LI(n.errors,r,ue),Pt=LI(Bt,r,gt.name||ue);Ot=Pt.error,ue=Pt.name,xn=ei(Bt)}}else C([ue],!0),Ot=(await p6($e,a.disabled,i,y,t.shouldUseNativeValidation))[ue],C([ue]),ze(gn),Fe&&(Ot?xn=!1:(p.isValid||m.isValid)&&(xn=await X({fields:r,onlyCheckValid:!0,name:ue,eventType:G.type})));Fe&&($e._f.deps&&(!Array.isArray($e._f.deps)||$e._f.deps.length>0)&&Z($e._f.deps),j(ue,xn,Ot,Sr))}},U=(G,pe)=>{if(ut(n.errors,pe)&&G.focus)return G.focus(),1},Z=async(G,pe={})=>{let ue,Fe;const $e=no(G);if(t.resolver){const ze=await V(pr(G)?G:$e);ue=ei(ze),Fe=G?!$e.some(qe=>ut(ze,qe)):ue}else G?(Fe=(await Promise.all($e.map(async ze=>{const qe=ut(r,ze);return await X({fields:qe&&qe._f?{[ze]:qe}:qe,eventType:Lh.TRIGGER})}))).every(Boolean),!(!Fe&&!n.isValid)&&S()):Fe=ue=await X({fields:r,name:G,eventType:Lh.TRIGGER});return b.state.next({...!mi(G)||(p.isValid||m.isValid)&&ue!==n.isValid?{}:{name:G},...t.resolver||!G?{isValid:ue}:{},errors:n.errors}),pe.shouldFocus&&!Fe&&dp(r,U,G?$e:a.mount),Fe},he=(G,pe)=>{let ue={...o.mount?i:s};return pe&&(ue=gZ(pe.dirtyFields?n.dirtyFields:n.touchedFields,ue)),pr(G)?ue:mi(G)?ut(ue,G):G.map(Fe=>ut(ue,Fe))},fe=(G,pe)=>({invalid:!!ut((pe||n).errors,G),isDirty:!!ut((pe||n).dirtyFields,G),error:ut((pe||n).errors,G),isValidating:!!ut(n.validatingFields,G),isTouched:!!ut((pe||n).touchedFields,G)}),ye=G=>{const pe=G?no(G):void 0;pe?.forEach(ue=>fs(n.errors,ue)),pe?pe.forEach(ue=>{b.state.next({name:ue,errors:n.errors})}):b.state.next({errors:{}})},ge=(G,pe,ue)=>{const Fe=(ut(r,G,{_f:{}})._f||{}).ref,$e=ut(n.errors,G)||{},{ref:ze,message:qe,type:Rt,...Ot}=$e;rr(n.errors,G,{...Ot,...pe,ref:Fe}),b.state.next({name:G,errors:n.errors,isValid:!1}),ue&&ue.shouldFocus&&Fe&&Fe.focus&&Fe.focus()},Ee=(G,pe)=>Qo(G)?b.state.subscribe({next:ue=>"values"in ue&&G(ue.values||oe(void 0,pe),ue)}):oe(G,pe,!0),Ae=G=>b.state.subscribe({next:pe=>{if(eFe(G.name,pe.name,G.exact)&&J$e(pe,G.formState||p,lr,G.reRenderRoot)){const ue={...i};G.callback({values:ue,...n,...pe,defaultValues:s})}}}).unsubscribe,Qe=G=>(o.mount=!0,m={...m,...G.formState},Ae({...G,formState:{...h,...G.formState}})),rt=(G,pe={})=>{for(const ue of G?no(G):a.mount)a.mount.delete(ue),a.array.delete(ue),pe.keepValue||(fs(r,ue),fs(i,ue)),!pe.keepError&&fs(n.errors,ue),!pe.keepDirty&&fs(n.dirtyFields,ue),!pe.keepTouched&&fs(n.touchedFields,ue),!pe.keepIsValidating&&fs(n.validatingFields,ue),!t.shouldUnregister&&!pe.keepDefaultValue&&fs(s,ue);b.state.next({values:br(i)}),b.state.next({...n,...pe.keepDirty?{isDirty:re()}:{}}),!pe.keepIsValid&&S()},ct=({disabled:G,name:pe})=>{if(el(G)&&o.mount||G||a.disabled.has(pe)){const $e=a.disabled.has(pe)!==!!G;G?a.disabled.add(pe):a.disabled.delete(pe),$e&&o.mount&&!o.action&&S()}},He=(G,pe={})=>{let ue=ut(r,G);const Fe=el(pe.disabled)||el(t.disabled),$e=!a.registerName.has(G)&&ue&&ue._f&&!ue._f.mount;return rr(r,G,{...ue||{},_f:{...ue&&ue._f?ue._f:{ref:{name:G}},name:G,mount:!0,...pe}}),a.mount.add(G),ue&&!$e?ct({disabled:el(pe.disabled)?pe.disabled:t.disabled,name:G}):R(G,!0,pe.value),{...Fe?{disabled:pe.disabled||t.disabled}:{},...t.progressive?{required:!!pe.required,min:ym(pe.min),max:ym(pe.max),minLength:ym(pe.minLength),maxLength:ym(pe.maxLength),pattern:ym(pe.pattern)}:{},name:G,onChange:H,onBlur:H,ref:ze=>{if(ze){a.registerName.add(G),He(G,pe),a.registerName.delete(G),ue=ut(r,G);const qe=pr(ze.value)&&ze.querySelectorAll&&ze.querySelectorAll("input,select,textarea")[0]||ze,Rt=G$e(qe),Ot=ue._f.refs||[];if(Rt?Ot.find(xn=>xn===qe):qe===ue._f.ref)return;rr(r,G,{_f:{...ue._f,...Rt?{refs:[...Ot.filter(q3),qe,...Array.isArray(ut(s,G))?[{}]:[]],ref:{type:qe.type,name:G}}:{ref:qe}}}),R(G,!1,void 0,qe)}else ue=ut(r,G,{}),ue._f&&(ue._f.mount=!1),(t.shouldUnregister||pe.shouldUnregister)&&!(F$e(a.array,G)&&o.action)&&a.unMount.add(G)}}},_e=()=>t.shouldFocusError&&dp(r,U,a.mount),nn=G=>{el(G)&&(b.state.next({disabled:G}),dp(r,(pe,ue)=>{const Fe=ut(r,ue);Fe&&(pe.disabled=Fe._f.disabled||G,Array.isArray(Fe._f.refs)&&Fe._f.refs.forEach($e=>{$e.disabled=Fe._f.disabled||G}))},0,!1))},xt=(G,pe)=>async ue=>{let Fe;ue&&(ue.preventDefault&&ue.preventDefault(),ue.persist&&ue.persist());let $e=br(i);if(b.state.next({isSubmitting:!0}),t.resolver){const{errors:ze,values:qe}=await L();C(),n.errors=ze,$e=br(qe)}else await X({fields:r,eventType:Lh.SUBMIT});if(a.disabled.size)for(const ze of a.disabled)fs($e,ze);if(fs(n.errors,pZ),ei(n.errors)){b.state.next({errors:{}});try{await G($e,ue)}catch(ze){Fe=ze}}else pe&&await pe({...n.errors},ue),_e(),setTimeout(_e);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ei(n.errors)&&!Fe,submitCount:n.submitCount+1,errors:n.errors}),Fe)throw Fe},Jt=(G,pe={})=>{ut(r,G)&&(pr(pe.defaultValue)?W(G,br(ut(s,G))):(W(G,pe.defaultValue),rr(s,G,br(pe.defaultValue))),pe.keepTouched||fs(n.touchedFields,G),pe.keepDirty||(fs(n.dirtyFields,G),n.isDirty=pe.defaultValue?re(G,br(ut(s,G))):re()),pe.keepError||(fs(n.errors,G),p.isValid&&S()),b.state.next({...n}))},fn=(G,pe={})=>{const ue=G?br(G):s,Fe=br(ue),$e=ei(G),ze=$e?s:Fe;if(pe.keepDefaultValues||(s=ue),!pe.keepValues){if(pe.keepDirtyValues){const qe=new Set([...a.mount,...Object.keys(zm(s,i))]);for(const Rt of Array.from(qe)){const Ot=ut(n.dirtyFields,Rt),xn=ut(i,Rt),gn=ut(ze,Rt);Ot&&!pr(xn)?rr(ze,Rt,xn):!Ot&&!pr(gn)&&W(Rt,gn)}}else{if(h8&&pr(G))for(const qe of a.mount){const Rt=ut(r,qe);if(Rt&&Rt._f){const Ot=Array.isArray(Rt._f.refs)?Rt._f.refs[0]:Rt._f.ref;if(Bx(Ot)){const xn=Ot.closest("form");if(xn){xn.reset();break}}}}if(pe.keepFieldsRef)for(const qe of a.mount)W(qe,ut(ze,qe));else r={}}i=t.shouldUnregister?pe.keepDefaultValues?br(s):{}:br(ze),b.array.next({values:{...ze}}),b.state.next({values:{...ze}})}a={mount:pe.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!p.isValid||!!pe.keepIsValid||!!pe.keepDirtyValues||!t.shouldUnregister&&!ei(ze),o.watch=!!t.shouldUnregister,o.keepIsValid=!!pe.keepIsValid,o.action=!1,pe.keepErrors||(n.errors={}),b.state.next({submitCount:pe.keepSubmitCount?n.submitCount:0,isDirty:$e?!1:pe.keepDirty?n.isDirty:!!(pe.keepDefaultValues&&!tl(G,s)),isSubmitted:pe.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:$e?{}:pe.keepDirtyValues?pe.keepDefaultValues&&i?zm(s,i):n.dirtyFields:pe.keepDefaultValues&&G?zm(s,G):pe.keepDirty?n.dirtyFields:{},touchedFields:pe.keepTouched?n.touchedFields:{},errors:pe.keepErrors?n.errors:{},isSubmitSuccessful:pe.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},hn=(G,pe)=>fn(Qo(G)?G(i):G,{...t.resetOptions,...pe}),zn=(G,pe={})=>{const ue=ut(r,G),Fe=ue&&ue._f;if(Fe){const $e=Fe.refs?Fe.refs[0]:Fe.ref;$e.focus&&setTimeout(()=>{$e.focus(),pe.shouldSelect&&Qo($e.select)&&$e.select()})}},lr=G=>{n={...n,...G}},Fn={control:{register:He,unregister:rt,getFieldState:fe,handleSubmit:xt,setError:ge,_subscribe:Ae,_runSchema:L,_updateIsValidating:C,_focusError:_e,_getWatch:oe,_getDirty:re,_setValid:S,_setFieldArray:M,_setDisabledField:ct,_setErrors:T,_getFieldArray:F,_reset:fn,_resetDefaultValues:()=>Qo(t.defaultValues)&&t.defaultValues().then(G=>{hn(G,t.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:ee,_disableForm:nn,_subjects:b,_proxyFormState:p,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(G){o=G},get _defaultValues(){return s},get _names(){return a},set _names(G){a=G},get _formState(){return n},get _options(){return t},set _options(G){t={...t,...G}}},subscribe:Qe,trigger:Z,register:He,handleSubmit:xt,watch:Ee,setValue:W,setValues:Q,getValues:he,reset:hn,resetField:Jt,clearErrors:ye,unregister:rt,setError:ge,setFocus:zn,getFieldState:fe};return{...Fn,formControl:Fn}}var fu=()=>{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID();const e=typeof performance>"u"?Date.now():performance.now()*1e3;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=(Math.random()*16+e)%16|0;return(t=="x"?n:n&3|8).toString(16)})},G3=(e,t,n={})=>n.shouldFocus||pr(n.shouldFocus)?n.focusName||`${e}.${pr(n.focusIndex)?t:n.focusIndex}.`:"",W3=(e,t)=>[...e,...no(t)],K3=e=>Array.isArray(e)?e.map(()=>{}):void 0;function Y3(e,t,n){return[...e.slice(0,t),...no(n),...e.slice(t)]}var Z3=(e,t,n)=>Array.isArray(e)?(pr(e[n])&&(e[n]=void 0),e.splice(n,0,e.splice(t,1)[0]),e):[],X3=(e,t)=>[...no(t),...no(e)];function iFe(e,t){let n=0;const r=[...e];for(const s of t)r.splice(s-n,1),n++;return $w(r).length?r:[]}var Q3=(e,t)=>pr(t)?[]:iFe(e,no(t).sort((n,r)=>n-r)),J3=(e,t,n)=>{[e[t],e[n]]=[e[n],e[t]]},$I=(e,t,n)=>(e[t]=n,e);function m1(e){const t=H$e(),{control:n=t,name:r,keyName:s="id",shouldUnregister:i,rules:o}=e,[a,l]=te.useState(n._getFieldArray(r)),u=te.useRef(n._getFieldArray(r).map(fu)),h=te.useRef(!1);n._names.array.add(r),te.useMemo(()=>o&&a.length>=0&&n.register(r,o),[n,r,a.length,o]),mZ(()=>n._subjects.array.subscribe({next:({values:_,name:T})=>{if(T===r||!T){const R=ut(_,r);Array.isArray(R)&&(l(R),u.current=R.map(fu))}}}).unsubscribe,[n,r]);const p=te.useCallback(_=>{h.current=!0,n._setFieldArray(r,_)},[n,r]),m=(_,T)=>{const R=no(br(_)),D=W3(n._getFieldArray(r),R);n._names.focus=G3(r,D.length-1,T),u.current=W3(u.current,R.map(fu)),p(D),l(D),n._setFieldArray(r,D,W3,{argA:K3(_)})},b=(_,T)=>{const R=no(br(_)),D=X3(n._getFieldArray(r),R);n._names.focus=G3(r,0,T),u.current=X3(u.current,R.map(fu)),p(D),l(D),n._setFieldArray(r,D,X3,{argA:K3(_)})},y=_=>{const T=Q3(n._getFieldArray(r),_);u.current=Q3(u.current,_),p(T),l(T),!Array.isArray(ut(n._fields,r))&&rr(n._fields,r,void 0),n._setFieldArray(r,T,Q3,{argA:_})},x=(_,T,R)=>{const D=no(br(T)),j=Y3(n._getFieldArray(r),_,D);n._names.focus=G3(r,_,R),u.current=Y3(u.current,_,D.map(fu)),p(j),l(j),n._setFieldArray(r,j,Y3,{argA:_,argB:K3(T)})},S=(_,T)=>{const R=n._getFieldArray(r);J3(R,_,T),J3(u.current,_,T),p(R),l(R),n._setFieldArray(r,R,J3,{argA:_,argB:T},!1)},C=(_,T)=>{const R=n._getFieldArray(r);Z3(R,_,T),Z3(u.current,_,T),p(R),l(R),n._setFieldArray(r,R,Z3,{argA:_,argB:T},!1)},N=(_,T)=>{const R=br(T),D=$I(n._getFieldArray(r),_,R);u.current=[...D].map((j,L)=>!j||L===_?fu():u.current[L]),p(D),l([...D]),n._setFieldArray(r,D,$I,{argA:_,argB:R},!0,!1)},M=_=>{const T=no(br(_));u.current=T.map(fu),p([...T]),l([...T]),n._setFieldArray(r,[...T],R=>R,{},!0,!1)};return te.useEffect(()=>{n._state.action=!1,h6(r,n._names)&&n._subjects.state.next({...n._formState});const _=Jh(n._options.mode);if(h.current&&(!_.isOnSubmit||n._formState.isSubmitted)&&!Jh(n._options.reValidateMode).isOnSubmit&&!_.isOnBlur)if(n._options.resolver)n._runSchema([r]).then(T=>{n._updateIsValidating([r]);const R=ut(T.errors,r),D=ut(n._formState.errors,r);(D?!R&&D.type||R&&(D.type!==R.type||D.message!==R.message):R&&R.type)&&(R?rr(n._formState.errors,r,R):fs(n._formState.errors,r),n._subjects.state.next({errors:n._formState.errors}))});else{const T=ut(n._fields,r);T&&T._f&&!(Jh(n._options.reValidateMode).isOnSubmit&&Jh(n._options.mode).isOnSubmit)&&p6(T,n._names.disabled,n._formValues,n._options.criteriaMode===ea.all,n._options.shouldUseNativeValidation,!0).then(R=>!ei(R)&&n._subjects.state.next({errors:SZ(n._formState.errors,R,r)}))}n._subjects.state.next({name:r,values:br(n._formValues)}),n._names.focus&&dp(n._fields,(T,R)=>{if(n._names.focus&&R.startsWith(n._names.focus)&&T.focus)return T.focus(),1}),n._names.focus="",n._setValid(),h.current=!1},[a,r,n]),te.useEffect(()=>(!ut(n._formValues,r)&&n._setFieldArray(r),()=>{const _=!(n._options.shouldUnregister||i),T=(R,D)=>{const j=ut(n._fields,R);j&&j._f&&(j._f.mount=D)};h.current&&_&&n._subjects.state.next({name:r,values:br(n._formValues)}),_?T(r,!1):n.unregister(r)}),[r,n,s,i]),{swap:te.useCallback(S,[p,r,n]),move:te.useCallback(C,[p,r,n]),prepend:te.useCallback(b,[p,r,n]),append:te.useCallback(m,[p,r,n]),remove:te.useCallback(y,[p,r,n]),insert:te.useCallback(x,[p,r,n]),update:te.useCallback(N,[p,r,n]),replace:te.useCallback(M,[p,r,n]),fields:te.useMemo(()=>a.map((_,T)=>({..._,[s]:u.current[T]||fu()})),[a,s])}}function oFe(e={}){const t=te.useRef(void 0),n=te.useRef(void 0),[r,s]=te.useState(()=>({...br(CZ),isLoading:Qo(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Qo(e.defaultValues)?void 0:e.defaultValues}));if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!Qo(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:o,...a}=sFe(e);t.current={...a,formState:r}}const i=t.current.control;return i._options=e,mZ(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(a=>({...a,isReady:!0})),i._formState.isReady=!0,o},[i]),te.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),te.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),te.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),te.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),te.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==r.isDirty&&i._subjects.state.next({isDirty:o})}},[i,r.isDirty]),te.useEffect(()=>{var o;e.values&&!tl(e.values,n.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((o=i._options.resetOptions)===null||o===void 0)&&o.keepIsValid||i._setValid(),n.current=e.values,s(a=>({...a}))):i._resetDefaultValues()},[i,e.values]),te.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=te.useMemo(()=>U$e(r,i),[i,r]),t.current}const kZ=["eq","neq","contains","gt","lt","isempty","isnotempty"],m6=["create","update","delete","cron"],aFe=["set_variable","webhook","send_mail","edit_field","create_entry"],lFe=Hd({type:Xd(["set_variable","webhook","send_mail","edit_field","create_entry"]),name:es(),fixed_id:es(),column:es(),filters:Du(Hd({field:es(),op:Xd(kZ),value:es()})),url:es(),method:Xd(["POST","GET","PUT"]),headers:Du(Hd({key:es(),value:es()})),body_template:es(),to:es(),subject_template:es(),field:es(),value:es(),seed_slug:es(),field_map:Du(Hd({targetAlias:es(),sourceAlias:es()}))}).superRefine((e,t)=>{e.type==="set_variable"&&((!e.name||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e.name))&&t.addIssue({code:qo.custom,message:"automations.editor.errors.variableNameInvalid",path:["name"]}),e.name&&KNe.has(e.name)&&t.addIssue({code:qo.custom,message:"automations.editor.errors.variableNameReserved",path:["name"]})),e.type==="webhook"&&(e.url?es().url().safeParse(e.url).success||t.addIssue({code:qo.custom,message:"automations.editor.errors.urlInvalid",path:["url"]}):t.addIssue({code:qo.custom,message:"automations.editor.errors.urlRequired",path:["url"]})),e.type==="send_mail"&&(e.to?es().email().safeParse(e.to).success||t.addIssue({code:qo.custom,message:"automations.editor.errors.emailInvalid",path:["to"]}):t.addIssue({code:qo.custom,message:"automations.editor.errors.emailRequired",path:["to"]}),e.subject_template||t.addIssue({code:qo.custom,message:"automations.editor.errors.subjectRequired",path:["subject_template"]}),e.body_template||t.addIssue({code:qo.custom,message:"automations.editor.errors.bodyRequired",path:["body_template"]})),e.type==="edit_field"&&(e.field||t.addIssue({code:qo.custom,message:"automations.editor.errors.fieldRequired",path:["field"]})),e.type==="create_entry"&&(e.seed_slug||t.addIssue({code:qo.custom,message:"automations.editor.errors.seedRequired",path:["seed_slug"]}))}),cFe=Hd({name:es().min(1,"automations.editor.errors.nameRequired").max(100),triggers:Du(Hd({event:w7([XR(""),Xd(["create","update","delete","cron"])]),cron:es()})).min(1,"automations.editor.errors.triggersMin"),trigger_conditions:Hd({kind:XR("group"),op:Xd(["AND","OR"]),negate:awe(),children:Du(cwe())}),actions:Du(lFe).min(1,"automations.editor.errors.actionsMin")}).superRefine((e,t)=>{e.triggers.forEach((n,r)=>{n.event||t.addIssue({code:qo.custom,message:"automations.editor.errors.triggerEventRequired",path:["triggers",r,"event"]}),n.event==="cron"&&!n.cron&&t.addIssue({code:qo.custom,message:"automations.editor.errors.cronRequired",path:["triggers",r,"cron"]})})}),EZ={name:"",fixed_id:"",column:"",filters:[],url:"",method:"POST",headers:[],body_template:"",to:"",subject_template:"",field:"",value:"",seed_slug:"",field_map:[]},Ux={event:"",cron:""},Vx={kind:"group",op:"AND",negate:!1,children:[]},qx={kind:"predicate",left_kind:"ref",left_ref:"",left_literal:"",op:"eq",right_kind:"literal",right_ref:"",right_literal:""};function uFe({value:e,onChange:t,allowedEvents:n}){const{t:r}=tt(),[s,i]=w.useState(""),[o,a]=w.useState(!1),u=(n??m6).filter(h=>r(`automations.triggers.${h}`).toLowerCase().includes(s.toLowerCase()));return d.jsxs(Li,{open:o,onOpenChange:h=>{a(h),h||i("")},children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{variant:"outline",size:"sm",className:"h-8 justify-between w-full text-sm",children:[d.jsx("span",{className:"truncate",children:r(e?`automations.triggers.${e}`:"automations.editor.triggerSelectPlaceholder")}),d.jsx(Nc,{className:"size-3.5 opacity-60 shrink-0"})]})}),d.jsxs($i,{align:"start",className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:r("automations.editor.triggerLabel")}),d.jsx(Xt,{placeholder:r("automations.editor.searchPlaceholder"),value:s,onChange:h=>i(h.target.value),className:"h-8 text-sm mb-1"}),d.jsx(ti,{className:"my-1"}),d.jsx("div",{className:"flex flex-col gap-0.5",children:u.map(h=>d.jsx(Oe,{type:"button",variant:e===h?"secondary":"ghost",size:"sm",className:"h-8 justify-start px-2 text-xs",onClick:()=>{t(h),a(!1)},children:r(`automations.triggers.${h}`)},h))})]})]})}const FI=["eq","neq","contains","startswith","endswith","isempty","isnotempty","matches"],dFe=["eq","neq","in","notin","isempty","isnotempty"],fFe=["eq","neq","gt","gte","lt","lte","isempty","isnotempty"],hFe=["eq","neq","gt","gte","lt","lte","isempty","isnotempty"],pFe=["eq","neq","isempty","isnotempty"],BI=["eq","neq","contains","in","notin","isempty","isnotempty"],mFe=["isempty","isnotempty"],gFe=["eq","neq","gt","gte","lt","lte","contains","startswith","endswith","in","notin","isempty","isnotempty","matches"];function HI(e){if(!e)return gFe;switch(e.type){case"number":return fFe;case"date":return hFe;case"boolean":return pFe;case"tags":return BI;case"json":return BI;case"file":return mFe;case"text":return e.options?.length?dFe:FI;default:return FI}}function ev({branch:e,value:t,onChange:n,className:r="h-7 flex-1 min-w-[60px]"}){const{t:s}=tt(),i=s("automations.when.valuePlaceholder");if(!e)return d.jsx(Xt,{className:`${r} text-xs`,value:t,placeholder:i,onChange:a=>n(a.target.value)});if(e.type==="boolean"){const a=t==="true"?"true":t==="false"?"false":"";return d.jsxs(Rr,{value:a,onValueChange:n,children:[d.jsx(Or,{size:"sm",className:`${r} text-xs`,children:d.jsx(Gr,{placeholder:i})}),d.jsxs(Dr,{children:[d.jsx(or,{value:"true",children:s("automations.when.true")}),d.jsx(or,{value:"false",children:s("automations.when.false")})]})]})}if(e.type==="date")return d.jsx(GN,{id:"automation-value-date",value:t||null,onChange:a=>n(a??""),placeholder:s("automations.when.chooseDate")});if(e.type==="number")return d.jsx(Xt,{type:"number",className:`${r} text-xs`,value:t,placeholder:i,onChange:a=>n(a.target.value)});const o=e.options??[];return e.type==="text"&&o.length>0?d.jsxs(Rr,{value:t,onValueChange:n,children:[d.jsx(Or,{size:"sm",className:`${r} text-xs`,children:d.jsx(Gr,{placeholder:i})}),d.jsx(Dr,{children:o.map(a=>d.jsx(or,{value:a,children:a},a))})]}):(e.type==="tags"||e.type==="json")&&o.length>0?d.jsxs(Li,{modal:!1,children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{type:"button",variant:"outline",size:"sm",className:`${r} justify-between text-xs`,children:[d.jsx("span",{className:"truncate",children:t||s("automations.when.chooseTag")}),d.jsx(of,{className:"size-3.5 opacity-60 shrink-0"})]})}),d.jsx($i,{align:"end",className:"max-h-56 w-48 overflow-y-auto p-1",children:o.map(a=>d.jsx(Oe,{type:"button",variant:t===a?"secondary":"ghost",size:"sm",className:"h-8 w-full justify-start px-2 text-xs",onClick:()=>n(a),children:a},a))})]}):d.jsx(Xt,{className:`${r} text-xs`,value:t,placeholder:i,onChange:a=>n(a.target.value)})}function bFe({pred:e,onChange:t,onRemove:n,onWrap:r,seedBranches:s}){const{t:i}=tt(),o=e.op==="isempty"||e.op==="isnotempty",a=e.left_kind==="ref"&&e.left_ref.startsWith("this.")?s.find(p=>p.alias===e.left_ref.slice(5)):void 0,l=HI(a);function u(p){const m=p.startsWith("this.")?s.find(x=>x.alias===p.slice(5)):void 0,b=HI(m),y=b.includes(e.op)?e.op:b[0];t({...e,left_ref:p,op:y,right_literal:""})}function h(p){t({...e,op:p,right_literal:""})}return d.jsxs("div",{className:"flex items-start gap-1.5",children:[d.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 min-w-0",children:[e.left_kind==="ref"?d.jsxs(Rr,{value:e.left_ref,onValueChange:u,children:[d.jsx(Or,{size:"sm",className:"h-7 text-xs flex-1 min-w-[80px]",children:d.jsx(Gr,{placeholder:i("automations.when.fieldPlaceholder")})}),d.jsxs(Dr,{children:[s.map(p=>d.jsx(or,{value:`this.${p.alias}`,children:p.label},p.alias)),d.jsx(or,{value:"_custom",children:i("automations.when.customRef")})]})]}):d.jsx(ev,{branch:void 0,value:e.left_literal,onChange:p=>t({...e,left_literal:p})}),d.jsxs(Rr,{value:e.op,onValueChange:p=>h(p),children:[d.jsx(Or,{size:"sm",className:"h-7 text-xs w-28 shrink-0",children:d.jsx(Gr,{})}),d.jsx(Dr,{children:l.map(p=>d.jsx(or,{value:p,children:i(`automations.when.ops.${p}`)},p))})]}),!o&&(e.right_kind==="ref"?d.jsx(ev,{branch:void 0,value:e.right_ref,onChange:p=>t({...e,right_ref:p})}):d.jsx(ev,{branch:a,value:e.right_literal,onChange:p=>t({...e,right_literal:p})}))]}),d.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[r&&d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground/50 hover:text-muted-foreground",onClick:r,children:d.jsx(Qx,{className:"size-3"})})}),d.jsx(fa,{side:"top",className:"text-xs",children:i("automations.when.wrapGroup")})]}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-destructive/60 hover:text-destructive",onClick:n,children:d.jsx(La,{className:"size-3"})})]})]})}function NZ({group:e,onChange:t,onRemove:n,onWrap:r,seedBranches:s,depth:i=0}){const{t:o}=tt(),a=3,l=i===0,u=i<a;function h(S,C){const N=[...e.children];N[S]=C,t({...e,children:N})}function p(S){t({...e,children:e.children.filter((C,N)=>N!==S)})}function m(){t({...e,children:[...e.children,{...qx}]})}function b(){t({...e,op:e.op==="AND"?"OR":"AND"})}function y(){t({...e,negate:!e.negate})}function x(S){if(!u)return;const N={kind:"group",op:"OR",negate:!1,children:[e.children[S],{...qx}]},M=[...e.children];M[S]=N,t({...e,children:M})}return d.jsxs("div",{className:`${l?"":"ml-4 pl-3 border-l border-dashed border-border/60"} flex flex-col gap-1.5`,children:[(!l||e.children.length>1)&&d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx(Oe,{type:"button",variant:"outline",size:"sm",className:"h-6 px-2 text-xs",onClick:b,children:e.op==="AND"?o("automations.when.and"):o("automations.when.or")}),d.jsx(Oe,{type:"button",variant:"ghost",size:"sm",className:`h-6 px-2 text-xs ${e.negate?"text-destructive":"text-muted-foreground"}`,onClick:y,children:o("automations.when.not")}),!l&&d.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[r&&u&&d.jsxs(ua,{children:[d.jsx(da,{asChild:!0,children:d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:r,children:d.jsx(Qx,{className:"size-3"})})}),d.jsx(fa,{side:"top",className:"text-xs",children:o("automations.when.wrapGroup")})]}),n&&d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-destructive/60 hover:text-destructive",onClick:n,title:o("automations.when.removeGroup"),children:d.jsx(ro,{className:"size-3"})})]})]}),e.children.map((S,C)=>d.jsx("div",{children:S.kind==="predicate"?d.jsx(bFe,{pred:S,onChange:N=>h(C,N),onRemove:()=>p(C),onWrap:u?()=>x(C):void 0,seedBranches:s}):d.jsx(NZ,{group:S,onChange:N=>h(C,N),onRemove:()=>p(C),onWrap:u?()=>x(C):void 0,seedBranches:s,depth:i+1})},C)),d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground self-start",onClick:m,children:[d.jsx(Hi,{className:"size-3 mr-1"}),o("automations.when.addCondition")]})]})}function yFe({seedBranches:e}){const{watch:t,setValue:n}=Ml(),r=t("trigger_conditions");return d.jsx("div",{className:"mt-2",children:d.jsx(NZ,{group:r,onChange:s=>n("trigger_conditions",s,{shouldValidate:!0}),seedBranches:e})})}function UI(e){if(!e||!e.trim())return{preset:"daily",hour:"09",minute:"00",dayOfWeek:"1",dayOfMonth:"1"};const t=e.trim().split(/\s+/);if(t.length!==5)return{preset:"advanced",hour:"09",minute:"00",dayOfWeek:"1",dayOfMonth:"1"};const[n,r,s,i,o]=t;if(n==="0"&&r==="*"&&s==="*"&&i==="*"&&o==="*")return{preset:"hourly",hour:"00",minute:"00",dayOfWeek:"1",dayOfMonth:"1"};const a=/^\d+$/.test(n),l=/^\d+$/.test(r),u=a?n.padStart(2,"0"):"00",h=l?r.padStart(2,"0"):"09";return a&&l&&s==="*"&&i==="*"&&o==="*"?{preset:"daily",hour:h,minute:u,dayOfWeek:"1",dayOfMonth:"1"}:a&&l&&s==="*"&&i==="*"&&/^\d+$/.test(o)?{preset:"weekly",hour:h,minute:u,dayOfWeek:o,dayOfMonth:"1"}:a&&l&&/^\d+$/.test(s)&&i==="*"&&o==="*"?{preset:"monthly",hour:h,minute:u,dayOfWeek:"1",dayOfMonth:s}:{preset:"advanced",hour:h,minute:u,dayOfWeek:"1",dayOfMonth:"1"}}function vFe({triggerIndex:e}){const{t}=tt(),{watch:n,setValue:r,register:s,formState:{errors:i}}=Ml(),o=`triggers.${e}.cron`,a=n(o)??"",l=i.triggers?.[e]?.cron,[u,h]=w.useState(()=>UI(a||""));w.useEffect(()=>{if(a){const C=UI(a);h(N=>!N.preset||N.preset==="advanced"||a.trim()===""?C:N)}},[a]),w.useEffect(()=>{if(u.preset!=="advanced"){let C="";u.preset==="hourly"?C="0 * * * *":u.preset==="daily"?C=`${Number(u.minute)} ${Number(u.hour)} * * *`:u.preset==="weekly"?C=`${Number(u.minute)} ${Number(u.hour)} * * ${u.dayOfWeek}`:u.preset==="monthly"&&(C=`${Number(u.minute)} ${Number(u.hour)} ${u.dayOfMonth} * *`),a!==C&&r(o,C,{shouldValidate:!0})}},[u.preset,u.hour,u.minute,u.dayOfWeek,u.dayOfMonth,r,a,o]);function p(C){h(N=>({...N,...C}))}const m=[{id:"hourly",labelKey:"presetHourly",icon:Id},{id:"daily",labelKey:"presetDaily",icon:z6},{id:"weekly",labelKey:"presetWeekly",icon:JJ},{id:"monthly",labelKey:"presetMonthly",icon:Xx},{id:"advanced",labelKey:"presetAdvanced",icon:Mz}],b=Array.from({length:24},(C,N)=>String(N).padStart(2,"0")),y=["00","05","10","15","20","25","30","35","40","45","50","55"],x=[{value:"1",label:t("automations.editor.cron.days.1")},{value:"2",label:t("automations.editor.cron.days.2")},{value:"3",label:t("automations.editor.cron.days.3")},{value:"4",label:t("automations.editor.cron.days.4")},{value:"5",label:t("automations.editor.cron.days.5")},{value:"6",label:t("automations.editor.cron.days.6")},{value:"0",label:t("automations.editor.cron.days.0")}],S=Array.from({length:31},(C,N)=>String(N+1));return d.jsxs("div",{className:"mt-3",children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:t("automations.editor.cron.title")}),d.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-2",children:m.map(C=>{const N=C.icon,M=u.preset===C.id;return d.jsxs("button",{type:"button",onClick:()=>p({preset:C.id}),className:ie("flex flex-col items-center justify-center p-2.5 rounded-lg border text-xs font-medium transition-all relative overflow-hidden select-none cursor-pointer",M?"bg-primary/10 border-primary text-primary dark:bg-primary/20 shadow-xs":"bg-background hover:bg-muted/50 border-border text-muted-foreground hover:text-foreground"),children:[d.jsx(N,{className:ie("size-4 mb-1.5 transition-transform",M?"scale-110":"")}),d.jsx("span",{className:"text-[11px] text-center leading-tight",children:t(`automations.editor.cron.${C.labelKey}`)})]},C.id)})}),u.preset!=="hourly"&&u.preset!=="advanced"&&d.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-secondary/30 dark:bg-secondary/10 border border-secondary flex flex-wrap items-center gap-4 animate-in fade-in-50 duration-200",children:[d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("label",{className:"text-[11px] font-medium text-muted-foreground",children:t("automations.editor.cron.timeLabel")}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsxs(Rr,{value:u.hour,onValueChange:C=>p({hour:C}),children:[d.jsx(Or,{className:"h-8 w-18 text-xs bg-background",children:d.jsx(Gr,{})}),d.jsx(Dr,{position:"popper",className:"max-h-48",children:b.map(C=>d.jsx(or,{value:C,children:C},C))})]}),d.jsx("span",{className:"text-muted-foreground font-bold",children:":"}),d.jsxs(Rr,{value:u.minute,onValueChange:C=>p({minute:C}),children:[d.jsx(Or,{className:"h-8 w-18 text-xs bg-background",children:d.jsx(Gr,{})}),d.jsx(Dr,{position:"popper",className:"max-h-48",children:y.map(C=>d.jsx(or,{value:C,children:C},C))})]})]})]}),u.preset==="weekly"&&d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("label",{className:"text-[11px] font-medium text-muted-foreground",children:t("automations.editor.cron.dayOfWeekLabel")}),d.jsxs(Rr,{value:u.dayOfWeek,onValueChange:C=>p({dayOfWeek:C}),children:[d.jsx(Or,{className:"h-8 w-32 text-xs bg-background",children:d.jsx(Gr,{})}),d.jsx(Dr,{position:"popper",className:"max-h-48",children:x.map(C=>d.jsx(or,{value:C.value,children:C.label},C.value))})]})]}),u.preset==="monthly"&&d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("label",{className:"text-[11px] font-medium text-muted-foreground",children:t("automations.editor.cron.dayOfMonthLabel")}),d.jsxs(Rr,{value:u.dayOfMonth,onValueChange:C=>p({dayOfMonth:C}),children:[d.jsx(Or,{className:"h-8 w-20 text-xs bg-background",children:d.jsx(Gr,{})}),d.jsx(Dr,{position:"popper",className:"max-h-48",children:S.map(C=>d.jsx(or,{value:C,children:C},C))})]})]})]}),u.preset==="advanced"&&d.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-secondary/30 dark:bg-secondary/10 border border-secondary animate-in fade-in-50 duration-200",children:[d.jsx(Xt,{...s(o),placeholder:"0 9 * * 1",className:"h-8 text-sm font-mono bg-background"}),l&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:t(l.message??"")}),d.jsx("p",{className:"mt-1.5 text-[10px] text-muted-foreground leading-relaxed",children:t("automations.editor.cronHint")})]}),u.preset!=="advanced"&&l&&d.jsx("p",{className:"mt-1.5 text-xs text-destructive px-1",children:t(l.message??"")})]})}function xFe({seedBranches:e}){const{t}=tt(),{watch:n,setValue:r,formState:{errors:s}}=Ml(),{fields:i,append:o,remove:a}=m1({name:"triggers"}),l=n("triggers"),u=l.map(S=>S.event).filter(Boolean),h=m6.filter(S=>!u.includes(S)),p=u.includes("cron"),m=u.some(S=>S!=="cron"),b=u.length>0;function y(){o({...Ux})}function x(S,C){r(`triggers.${S}.event`,C,{shouldValidate:!0}),C!=="cron"&&r(`triggers.${S}.cron`,"",{shouldValidate:!1})}return d.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[d.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[d.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-primary/10",children:d.jsx(Rg,{className:"size-3.5 text-primary"})}),d.jsx("span",{className:"text-sm font-medium",children:t("automations.editor.triggerLabel")})]}),d.jsx("div",{className:"flex flex-col gap-2",children:i.map((S,C)=>{const N=l[C]?.event??"",M=N==="cron",_=u.filter((R,D)=>D!==C),T=m6.filter(R=>!_.includes(R));return d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:"flex-1",children:d.jsx(uFe,{value:N,onChange:R=>x(C,R),allowedEvents:T})}),i.length>1&&d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-destructive/60 hover:text-destructive",onClick:()=>a(C),children:d.jsx(ro,{className:"size-3.5"})})]}),M&&d.jsx(vFe,{triggerIndex:C}),s.triggers?.[C]?.event&&d.jsx("p",{className:"text-xs text-destructive",children:t(s.triggers[C].event.message??"")})]},S.id)})}),h.length>0&&d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"mt-2 h-7 px-2 text-xs text-muted-foreground",onClick:y,children:[d.jsx(Hi,{className:"size-3 mr-1"}),t("automations.editor.addTrigger")]}),s.triggers?.message&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:t(s.triggers.message)}),b&&(m||p)&&d.jsx(yFe,{seedBranches:e})]})}var VI=1,wFe=.9,SFe=.8,CFe=.17,eC=.1,tC=.999,kFe=.9999,EFe=.99,NFe=/[\\\/_+.#"@\[\(\{&]/,MFe=/[\\\/_+.#"@\[\(\{&]/g,_Fe=/[\s-]/,MZ=/[\s-]/g;function g6(e,t,n,r,s,i,o){if(i===t.length)return s===e.length?VI:EFe;var a=`${s},${i}`;if(o[a]!==void 0)return o[a];for(var l=r.charAt(i),u=n.indexOf(l,s),h=0,p,m,b,y;u>=0;)p=g6(e,t,n,r,u+1,i+1,o),p>h&&(u===s?p*=VI:NFe.test(e.charAt(u-1))?(p*=SFe,b=e.slice(s,u-1).match(MFe),b&&s>0&&(p*=Math.pow(tC,b.length))):_Fe.test(e.charAt(u-1))?(p*=wFe,y=e.slice(s,u-1).match(MZ),y&&s>0&&(p*=Math.pow(tC,y.length))):(p*=CFe,s>0&&(p*=Math.pow(tC,u-s))),e.charAt(u)!==t.charAt(i)&&(p*=kFe)),(p<eC&&n.charAt(u-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(u-1)!==r.charAt(i))&&(m=g6(e,t,n,r,u+1,i+2,o),m*eC>p&&(p=m*eC)),p>h&&(h=p),u=n.indexOf(l,u+1);return o[a]=h,h}function qI(e){return e.toLowerCase().replace(MZ," ")}function TFe(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,g6(e,t,qI(e),qI(t),0,0,{})}var vm='[cmdk-group=""]',nC='[cmdk-group-items=""]',AFe='[cmdk-group-heading=""]',_Z='[cmdk-item=""]',GI=`${_Z}:not([aria-disabled="true"])`,b6="cmdk-item-select",Gh="data-value",RFe=(e,t,n)=>TFe(e,t,n),TZ=w.createContext(void 0),g1=()=>w.useContext(TZ),AZ=w.createContext(void 0),x8=()=>w.useContext(AZ),RZ=w.createContext(void 0),OZ=w.forwardRef((e,t)=>{let n=Wh(()=>{var U,Z;return{search:"",value:(Z=(U=e.value)!=null?U:e.defaultValue)!=null?Z:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Wh(()=>new Set),s=Wh(()=>new Map),i=Wh(()=>new Map),o=Wh(()=>new Set),a=DZ(e),{label:l,children:u,value:h,onValueChange:p,filter:m,shouldFilter:b,loop:y,disablePointerSelection:x=!1,vimBindings:S=!0,...C}=e,N=ms(),M=ms(),_=ms(),T=w.useRef(null),R=HFe();_f(()=>{if(h!==void 0){let U=h.trim();n.current.value=U,D.emit()}},[h]),_f(()=>{R(6,ee)},[]);let D=w.useMemo(()=>({subscribe:U=>(o.current.add(U),()=>o.current.delete(U)),snapshot:()=>n.current,setState:(U,Z,he)=>{var fe,ye,ge,Ee;if(!Object.is(n.current[U],Z)){if(n.current[U]=Z,U==="search")X(),V(),R(1,q);else if(U==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Ae=document.getElementById(_);Ae?Ae.focus():(fe=document.getElementById(N))==null||fe.focus()}if(R(7,()=>{var Ae;n.current.selectedItemId=(Ae=re())==null?void 0:Ae.id,D.emit()}),he||R(5,ee),((ye=a.current)==null?void 0:ye.value)!==void 0){let Ae=Z??"";(Ee=(ge=a.current).onValueChange)==null||Ee.call(ge,Ae);return}}D.emit()}},emit:()=>{o.current.forEach(U=>U())}}),[]),j=w.useMemo(()=>({value:(U,Z,he)=>{var fe;Z!==((fe=i.current.get(U))==null?void 0:fe.value)&&(i.current.set(U,{value:Z,keywords:he}),n.current.filtered.items.set(U,L(Z,he)),R(2,()=>{V(),D.emit()}))},item:(U,Z)=>(r.current.add(U),Z&&(s.current.has(Z)?s.current.get(Z).add(U):s.current.set(Z,new Set([U]))),R(3,()=>{X(),V(),n.current.value||q(),D.emit()}),()=>{i.current.delete(U),r.current.delete(U),n.current.filtered.items.delete(U);let he=re();R(4,()=>{X(),he?.getAttribute("id")===U&&q(),D.emit()})}),group:U=>(s.current.has(U)||s.current.set(U,new Set),()=>{i.current.delete(U),s.current.delete(U)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:N,inputId:_,labelId:M,listInnerRef:T}),[]);function L(U,Z){var he,fe;let ye=(fe=(he=a.current)==null?void 0:he.filter)!=null?fe:RFe;return U?ye(U,n.current.search,Z):0}function V(){if(!n.current.search||a.current.shouldFilter===!1)return;let U=n.current.filtered.items,Z=[];n.current.filtered.groups.forEach(fe=>{let ye=s.current.get(fe),ge=0;ye.forEach(Ee=>{let Ae=U.get(Ee);ge=Math.max(Ae,ge)}),Z.push([fe,ge])});let he=T.current;oe().sort((fe,ye)=>{var ge,Ee;let Ae=fe.getAttribute("id"),Qe=ye.getAttribute("id");return((ge=U.get(Qe))!=null?ge:0)-((Ee=U.get(Ae))!=null?Ee:0)}).forEach(fe=>{let ye=fe.closest(nC);ye?ye.appendChild(fe.parentElement===ye?fe:fe.closest(`${nC} > *`)):he.appendChild(fe.parentElement===he?fe:fe.closest(`${nC} > *`))}),Z.sort((fe,ye)=>ye[1]-fe[1]).forEach(fe=>{var ye;let ge=(ye=T.current)==null?void 0:ye.querySelector(`${vm}[${Gh}="${encodeURIComponent(fe[0])}"]`);ge?.parentElement.appendChild(ge)})}function q(){let U=oe().find(he=>he.getAttribute("aria-disabled")!=="true"),Z=U?.getAttribute(Gh);D.setState("value",Z||void 0)}function X(){var U,Z,he,fe;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ye=0;for(let ge of r.current){let Ee=(Z=(U=i.current.get(ge))==null?void 0:U.value)!=null?Z:"",Ae=(fe=(he=i.current.get(ge))==null?void 0:he.keywords)!=null?fe:[],Qe=L(Ee,Ae);n.current.filtered.items.set(ge,Qe),Qe>0&&ye++}for(let[ge,Ee]of s.current)for(let Ae of Ee)if(n.current.filtered.items.get(Ae)>0){n.current.filtered.groups.add(ge);break}n.current.filtered.count=ye}function ee(){var U,Z,he;let fe=re();fe&&(((U=fe.parentElement)==null?void 0:U.firstChild)===fe&&((he=(Z=fe.closest(vm))==null?void 0:Z.querySelector(AFe))==null||he.scrollIntoView({block:"nearest"})),fe.scrollIntoView({block:"nearest"}))}function re(){var U;return(U=T.current)==null?void 0:U.querySelector(`${_Z}[aria-selected="true"]`)}function oe(){var U;return Array.from(((U=T.current)==null?void 0:U.querySelectorAll(GI))||[])}function F(U){let Z=oe()[U];Z&&D.setState("value",Z.getAttribute(Gh))}function se(U){var Z;let he=re(),fe=oe(),ye=fe.findIndex(Ee=>Ee===he),ge=fe[ye+U];(Z=a.current)!=null&&Z.loop&&(ge=ye+U<0?fe[fe.length-1]:ye+U===fe.length?fe[0]:fe[ye+U]),ge&&D.setState("value",ge.getAttribute(Gh))}function le(U){let Z=re(),he=Z?.closest(vm),fe;for(;he&&!fe;)he=U>0?FFe(he,vm):BFe(he,vm),fe=he?.querySelector(GI);fe?D.setState("value",fe.getAttribute(Gh)):se(U)}let W=()=>F(oe().length-1),Q=U=>{U.preventDefault(),U.metaKey?W():U.altKey?le(1):se(1)},H=U=>{U.preventDefault(),U.metaKey?F(0):U.altKey?le(-1):se(-1)};return w.createElement(dt.div,{ref:t,tabIndex:-1,...C,"cmdk-root":"",onKeyDown:U=>{var Z;(Z=C.onKeyDown)==null||Z.call(C,U);let he=U.nativeEvent.isComposing||U.keyCode===229;if(!(U.defaultPrevented||he))switch(U.key){case"n":case"j":{S&&U.ctrlKey&&Q(U);break}case"ArrowDown":{Q(U);break}case"p":case"k":{S&&U.ctrlKey&&H(U);break}case"ArrowUp":{H(U);break}case"Home":{U.preventDefault(),F(0);break}case"End":{U.preventDefault(),W();break}case"Enter":{U.preventDefault();let fe=re();if(fe){let ye=new Event(b6);fe.dispatchEvent(ye)}}}}},w.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:VFe},l),Fw(e,U=>w.createElement(AZ.Provider,{value:D},w.createElement(TZ.Provider,{value:j},U))))}),OFe=w.forwardRef((e,t)=>{var n,r;let s=ms(),i=w.useRef(null),o=w.useContext(RZ),a=g1(),l=DZ(e),u=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:o?.forceMount;_f(()=>{if(!u)return a.item(s,o?.id)},[u]);let h=jZ(s,i,[e.value,e.children,i],e.keywords),p=x8(),m=Ec(R=>R.value&&R.value===h.current),b=Ec(R=>u||a.filter()===!1?!0:R.search?R.filtered.items.get(s)>0:!0);w.useEffect(()=>{let R=i.current;if(!(!R||e.disabled))return R.addEventListener(b6,y),()=>R.removeEventListener(b6,y)},[b,e.onSelect,e.disabled]);function y(){var R,D;x(),(D=(R=l.current).onSelect)==null||D.call(R,h.current)}function x(){p.setState("value",h.current,!0)}if(!b)return null;let{disabled:S,value:C,onSelect:N,forceMount:M,keywords:_,...T}=e;return w.createElement(dt.div,{ref:wc(i,t),...T,id:s,"cmdk-item":"",role:"option","aria-disabled":!!S,"aria-selected":!!m,"data-disabled":!!S,"data-selected":!!m,onPointerMove:S||a.getDisablePointerSelection()?void 0:x,onClick:S?void 0:y},e.children)}),DFe=w.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:s,...i}=e,o=ms(),a=w.useRef(null),l=w.useRef(null),u=ms(),h=g1(),p=Ec(b=>s||h.filter()===!1?!0:b.search?b.filtered.groups.has(o):!0);_f(()=>h.group(o),[]),jZ(o,a,[e.value,e.heading,l]);let m=w.useMemo(()=>({id:o,forceMount:s}),[s]);return w.createElement(dt.div,{ref:wc(a,t),...i,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&w.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:u},n),Fw(e,b=>w.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},w.createElement(RZ.Provider,{value:m},b))))}),jFe=w.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,s=w.useRef(null),i=Ec(o=>!o.search);return!n&&!i?null:w.createElement(dt.div,{ref:wc(s,t),...r,"cmdk-separator":"",role:"separator"})}),IFe=w.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,s=e.value!=null,i=x8(),o=Ec(u=>u.search),a=Ec(u=>u.selectedItemId),l=g1();return w.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),w.createElement(dt.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:s?e.value:o,onChange:u=>{s||i.setState("search",u.target.value),n?.(u.target.value)}})}),zFe=w.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...s}=e,i=w.useRef(null),o=w.useRef(null),a=Ec(u=>u.selectedItemId),l=g1();return w.useEffect(()=>{if(o.current&&i.current){let u=o.current,h=i.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let b=u.offsetHeight;h.style.setProperty("--cmdk-list-height",b.toFixed(1)+"px")})});return m.observe(u),()=>{cancelAnimationFrame(p),m.unobserve(u)}}},[]),w.createElement(dt.div,{ref:wc(i,t),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Fw(e,u=>w.createElement("div",{ref:wc(o,l.listInnerRef),"cmdk-list-sizer":""},u)))}),LFe=w.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:s,contentClassName:i,container:o,...a}=e;return w.createElement(i2,{open:n,onOpenChange:r},w.createElement(o2,{container:o},w.createElement(a2,{"cmdk-overlay":"",className:s}),w.createElement(l2,{"aria-label":e.label,"cmdk-dialog":"",className:i},w.createElement(OZ,{ref:t,...a}))))}),PFe=w.forwardRef((e,t)=>Ec(n=>n.filtered.count===0)?w.createElement(dt.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),$Fe=w.forwardRef((e,t)=>{let{progress:n,children:r,label:s="Loading...",...i}=e;return w.createElement(dt.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},Fw(e,o=>w.createElement("div",{"aria-hidden":!0},o)))}),lo=Object.assign(OZ,{List:zFe,Item:OFe,Input:IFe,Group:DFe,Separator:jFe,Dialog:LFe,Empty:PFe,Loading:$Fe});function FFe(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function BFe(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function DZ(e){let t=w.useRef(e);return _f(()=>{t.current=e}),t}var _f=typeof window>"u"?w.useEffect:w.useLayoutEffect;function Wh(e){let t=w.useRef();return t.current===void 0&&(t.current=e()),t}function Ec(e){let t=x8(),n=()=>e(t.snapshot());return w.useSyncExternalStore(t.subscribe,n,n)}function jZ(e,t,n,r=[]){let s=w.useRef(),i=g1();return _f(()=>{var o;let a=(()=>{var u;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(u=h.current.textContent)==null?void 0:u.trim():s.current}})(),l=r.map(u=>u.trim());i.value(e,a,l),(o=t.current)==null||o.setAttribute(Gh,a),s.current=a}),s}var HFe=()=>{let[e,t]=w.useState(),n=Wh(()=>new Map);return _f(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,s)=>{n.current.set(r,s),t({})}};function UFe(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Fw({asChild:e,children:t},n){return e&&w.isValidElement(t)?w.cloneElement(UFe(t),{ref:t.ref},n(t.props.children)):n(t)}var VFe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const w8=w.forwardRef(({className:e,...t},n)=>d.jsx(lo,{ref:n,className:ie("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));w8.displayName=lo.displayName;const qFe=({children:e,...t})=>d.jsx(kf,{...t,children:d.jsx(Ef,{className:"overflow-hidden p-0",children:d.jsx(w8,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})})}),S8=w.forwardRef(({className:e,...t},n)=>d.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[d.jsx(aC,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),d.jsx(lo.Input,{ref:n,className:ie("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));S8.displayName=lo.Input.displayName;const C8=w.forwardRef(({className:e,...t},n)=>d.jsx(lo.List,{ref:n,className:ie("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));C8.displayName=lo.List.displayName;const k8=w.forwardRef((e,t)=>d.jsx(lo.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));k8.displayName=lo.Empty.displayName;const Yd=w.forwardRef(({className:e,...t},n)=>d.jsx(lo.Group,{ref:n,className:ie("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Yd.displayName=lo.Group.displayName;const tv=w.forwardRef(({className:e,...t},n)=>d.jsx(lo.Separator,{ref:n,className:ie("-mx-1 h-px bg-border",e),...t}));tv.displayName=lo.Separator.displayName;const vo=w.forwardRef(({className:e,...t},n)=>d.jsx(lo.Item,{ref:n,className:ie("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));vo.displayName=lo.Item.displayName;const IZ=({className:e,...t})=>d.jsx("span",{className:ie("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});IZ.displayName="CommandShortcut";function GFe({index:e,triggerSeedSlug:t}){const{t:n}=tt(),{register:r,control:s,watch:i,setValue:o,formState:{errors:a}}=Ml(),{data:l=[]}=n0(),{fields:u,append:h,remove:p}=m1({control:s,name:`actions.${e}.filters`}),[m,b]=w.useState(!1),[y,x]=w.useState(""),S=w.useRef(null),C=i(`actions.${e}.seed_slug`),N=i(`actions.${e}.fixed_id`),M=i(`actions.${e}.column`),_=a.actions?.[e],T=!N,R=l.find(q=>q.slug===(C||t));w.useEffect(()=>{N?x(N):C&&x(C)},[N,C]);function D(q){o(`actions.${e}.seed_slug`,q),o(`actions.${e}.fixed_id`,""),x(q),b(!1)}function j(q){const X=l.find(ee=>ee.slug===q);X?D(X.slug):(o(`actions.${e}.fixed_id`,q),o(`actions.${e}.seed_slug`,""),x(q))}function L(q){x(q),q||(o(`actions.${e}.seed_slug`,""),o(`actions.${e}.fixed_id`,""))}const V=l.find(q=>q.slug===t);return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[n("automations.actions.variableName")," *"]}),d.jsx(Xt,{...r(`actions.${e}.name`),placeholder:"cliente",className:"h-8 text-sm font-mono"}),_?.name&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:n(_.name.message)}),d.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:n("automations.actions.variableNameHint")})]}),d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[n("automations.actions.source")," *"]}),d.jsxs(r0,{open:m,onOpenChange:b,children:[d.jsx(s0,{asChild:!0,children:d.jsxs(Oe,{type:"button",variant:"outline",role:"combobox",className:"h-8 w-full justify-between text-sm font-normal",children:[d.jsx("span",{className:"truncate",children:N?d.jsx("span",{className:"text-muted-foreground",children:n("automations.actions.fixedIdBadge",{id:N})}):C?l.find(q=>q.slug===C)?.label??C:d.jsx("span",{className:"text-muted-foreground",children:n("automations.actions.sourcePlaceholder")})}),d.jsx(Nc,{className:"ml-2 h-3 w-3 shrink-0 opacity-50"})]})}),d.jsx(i0,{className:"w-64 p-0",align:"start",children:d.jsxs(w8,{shouldFilter:!1,children:[d.jsx(S8,{ref:S,placeholder:n("automations.editor.searchPlaceholder"),value:y,onValueChange:L}),d.jsxs(C8,{children:[d.jsx(k8,{children:y?d.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-xs hover:bg-accent",onClick:()=>j(y),children:n("automations.actions.useAsFixedId",{value:y})}):n("commandPalette.noResults")}),V&&d.jsxs(vo,{value:V.slug,onSelect:()=>D(V.slug),className:"text-xs",children:[V.label,d.jsx(gi,{variant:"secondary",className:"ml-2 text-[10px] py-0",children:n("automations.actions.thisSeed")})]}),l.filter(q=>q.slug!==t).filter(q=>!y||q.slug.includes(y)||q.label.toLowerCase().includes(y.toLowerCase())).map(q=>d.jsx(vo,{value:q.slug,onSelect:()=>D(q.slug),className:"text-xs",children:q.label},q.slug)),y&&!l.find(q=>q.slug===y)&&d.jsx(vo,{value:`__fixed__${y}`,onSelect:()=>j(y),className:"text-xs text-muted-foreground",children:n("automations.actions.useAsFixedId",{value:y})})]})]})})]}),N&&d.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[d.jsxs(gi,{variant:"outline",className:"text-[10px] font-mono",children:["ID: ",N]}),d.jsx("button",{type:"button",className:"text-[10px] text-muted-foreground hover:text-foreground",onClick:()=>{o(`actions.${e}.fixed_id`,""),x("")},children:"✕"})]})]}),T&&R&&R.branches.length>0&&d.jsxs("div",{children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:n("automations.actions.column")}),d.jsxs(Rr,{value:M??"",onValueChange:q=>o(`actions.${e}.column`,q==="__all__"?"":q),children:[d.jsx(Or,{size:"sm",className:"h-8 text-sm",children:d.jsx(Gr,{placeholder:n("automations.actions.columnAll")})}),d.jsxs(Dr,{children:[d.jsx(or,{value:"__all__",children:n("automations.actions.columnAll")}),R.branches.map(q=>d.jsx(or,{value:q.alias,children:q.label},q.alias))]})]})]}),T&&d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center justify-between mb-1",children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:n("automations.actions.filters")}),d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>h({field:"",op:"eq",value:""}),children:[d.jsx(Hi,{className:"size-3 mr-1"}),n("automations.editor.addCondition")]})]}),u.map((q,X)=>{const ee=i(`actions.${e}.filters.${X}.field`),re=i(`actions.${e}.filters.${X}.op`),oe=re!=="isempty"&&re!=="isnotempty";return d.jsxs("div",{className:"flex gap-1.5 items-center mb-1.5",children:[d.jsxs(Rr,{value:ee??"",onValueChange:F=>o(`actions.${e}.filters.${X}.field`,F),children:[d.jsx(Or,{size:"sm",className:"h-7 text-xs flex-1",children:d.jsx(Gr,{placeholder:n("automations.editor.conditionField")})}),d.jsx(Dr,{children:(R?.branches??[]).map(F=>d.jsx(or,{value:F.alias,children:F.label},F.alias))})]}),d.jsxs(Rr,{value:re??"eq",onValueChange:F=>o(`actions.${e}.filters.${X}.op`,F),children:[d.jsx(Or,{size:"sm",className:"h-7 text-xs w-28",children:d.jsx(Gr,{})}),d.jsx(Dr,{children:kZ.map(F=>d.jsx(or,{value:F,children:n(`automations.ops.${F}`)},F))})]}),oe&&d.jsx(Xt,{...r(`actions.${e}.filters.${X}.value`),placeholder:"{{this.field}}",className:"h-7 text-xs flex-1 font-mono"}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>p(X),children:d.jsx(La,{className:"size-3"})})]},q.id)}),u.length===0&&d.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("automations.actions.noFilters")}),d.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:n("automations.actions.filterTemplateHint")})]}),d.jsxs("div",{className:"rounded border border-border/50 bg-muted/30 p-2",children:[d.jsx("p",{className:"text-[10px] font-medium text-muted-foreground mb-1",children:n("automations.actions.templateHintTitle")}),N?d.jsx("pre",{className:"text-[10px] text-muted-foreground whitespace-pre-wrap font-mono leading-relaxed",children:n("automations.actions.hintFixed")}):d.jsx("pre",{className:"text-[10px] text-muted-foreground whitespace-pre-wrap font-mono leading-relaxed",children:n("automations.actions.hintCollection")})]})]})}function WFe({index:e}){const{t}=tt(),{register:n,control:r,watch:s,setValue:i,formState:{errors:o}}=Ml(),{fields:a,append:l,remove:u}=m1({control:r,name:`actions.${e}.headers`}),h=s(`actions.${e}.method`),p=o.actions?.[e];return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[t("automations.actions.webhookUrl")," *"]}),d.jsx(Xt,{...n(`actions.${e}.url`),placeholder:"https://example.com/webhook",className:"h-8 text-sm"}),p?.url&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:t(p.url.message)})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:t("automations.actions.webhookMethod")}),d.jsxs(Rr,{value:h??"POST",onValueChange:m=>i(`actions.${e}.method`,m),children:[d.jsx(Or,{size:"sm",className:"h-8 text-sm",children:d.jsx(Gr,{})}),d.jsx(Dr,{children:["POST","GET","PUT"].map(m=>d.jsx(or,{value:m,children:m},m))})]})]}),d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center justify-between mb-1",children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:t("automations.actions.webhookHeaders")}),d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>l({key:"",value:""}),children:[d.jsx(Hi,{className:"size-3 mr-1"}),t("automations.actions.addHeader")]})]}),a.map((m,b)=>d.jsxs("div",{className:"flex gap-2 mb-1",children:[d.jsx(Xt,{...n(`actions.${e}.headers.${b}.key`),placeholder:t("automations.actions.webhookHeaderKeyPlaceholder"),className:"h-7 text-xs"}),d.jsx(Xt,{...n(`actions.${e}.headers.${b}.value`),placeholder:t("automations.actions.webhookHeaderValuePlaceholder"),className:"h-7 text-xs"}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>u(b),children:d.jsx(La,{className:"size-3"})})]},m.id))]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:t("automations.actions.webhookBody")}),d.jsx("textarea",{...n(`actions.${e}.body_template`),rows:3,placeholder:'{"event": "{{trigger_event}}"}',className:"w-full rounded-md border border-input bg-background px-3 py-2 text-xs font-mono resize-none focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),d.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:t("automations.actions.templateHint")})]})]})}function KFe({index:e}){const{t}=tt(),{register:n,formState:{errors:r}}=Ml(),s=r.actions?.[e];return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[t("automations.actions.mailTo")," *"]}),d.jsx(Xt,{...n(`actions.${e}.to`),type:"email",placeholder:t("automations.actions.mailToPlaceholder"),className:"h-8 text-sm"}),s?.to&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:t(s.to.message)})]}),d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[t("automations.actions.mailSubject")," *"]}),d.jsx(Xt,{...n(`actions.${e}.subject_template`),placeholder:t("automations.actions.mailSubjectPlaceholder"),className:"h-8 text-sm"}),s?.subject_template&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:t(s.subject_template.message)}),d.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:t("automations.actions.templateHint")})]}),d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[t("automations.actions.mailBody")," *"]}),d.jsx("textarea",{...n(`actions.${e}.body_template`),rows:4,placeholder:t("automations.actions.mailBodyPlaceholder"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm resize-none focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"}),s?.body_template&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:t(s.body_template.message)}),d.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:t("automations.actions.templateHint")})]})]})}function YFe({index:e,seedBranches:t}){const{t:n}=tt(),{watch:r,setValue:s,formState:{errors:i}}=Ml(),o=r(`actions.${e}.field`),a=r(`actions.${e}.value`),l=i.actions?.[e],u=t.find(p=>p.alias===o);function h(p){s(`actions.${e}.field`,p),s(`actions.${e}.value`,"")}return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[n("automations.actions.editField")," *"]}),d.jsxs(Rr,{value:o??"",onValueChange:h,children:[d.jsx(Or,{size:"sm",className:"h-8 text-sm",children:d.jsx(Gr,{placeholder:n("automations.actions.editFieldPlaceholder")})}),d.jsx(Dr,{children:t.map(p=>d.jsx(or,{value:p.alias,children:p.label},p.alias))})]}),l?.field&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:n(l.field.message)})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:n("automations.actions.editValue")}),d.jsx(ev,{branch:u,value:a??"",onChange:p=>s(`actions.${e}.value`,p),className:"h-8 flex-1"})]})]})}function ZFe({index:e}){const{t}=tt(),{control:n,watch:r,setValue:s,formState:{errors:i}}=Ml(),{data:o=[]}=n0(),{fields:a,append:l,remove:u}=m1({control:n,name:`actions.${e}.field_map`}),h=r(`actions.${e}.seed_slug`),p=i.actions?.[e],m=o.find(b=>b.slug===h);return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{children:[d.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:[t("automations.actions.targetSeed")," *"]}),d.jsxs(Rr,{value:h??"",onValueChange:b=>s(`actions.${e}.seed_slug`,b),children:[d.jsx(Or,{size:"sm",className:"h-8 text-sm",children:d.jsx(Gr,{placeholder:t("automations.actions.targetSeedPlaceholder")})}),d.jsx(Dr,{children:o.map(b=>d.jsx(or,{value:b.slug,children:b.label},b.slug))})]}),p?.seed_slug&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:t(p.seed_slug.message)})]}),d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center justify-between mb-1",children:[d.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:t("automations.actions.fieldMap")}),d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>l({targetAlias:"",sourceAlias:""}),children:[d.jsx(Hi,{className:"size-3 mr-1"}),t("automations.actions.addFieldMap")]})]}),a.map((b,y)=>d.jsxs("div",{className:"flex gap-2 mb-1 items-center",children:[d.jsxs(Rr,{value:r(`actions.${e}.field_map.${y}.targetAlias`)??"",onValueChange:x=>s(`actions.${e}.field_map.${y}.targetAlias`,x),children:[d.jsx(Or,{size:"sm",className:"h-7 text-xs flex-1",children:d.jsx(Gr,{placeholder:t("automations.actions.fieldMapTarget")})}),d.jsx(Dr,{children:(m?.branches??[]).map(x=>d.jsx(or,{value:x.alias,children:x.label},x.alias))})]}),d.jsx("span",{className:"text-xs text-muted-foreground",children:"←"}),d.jsxs(Rr,{value:r(`actions.${e}.field_map.${y}.sourceAlias`)??"",onValueChange:x=>s(`actions.${e}.field_map.${y}.sourceAlias`,x),children:[d.jsx(Or,{size:"sm",className:"h-7 text-xs flex-1",children:d.jsx(Gr,{placeholder:t("automations.actions.fieldMapSource")})}),d.jsx(Dr,{children:(m?.branches??[]).map(x=>d.jsx(or,{value:x.alias,children:x.label},x.alias))})]}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>u(y),children:d.jsx(La,{className:"size-3"})})]},b.id))]})]})}const XFe={set_variable:"border-l-cyan-500",webhook:"border-l-blue-500",send_mail:"border-l-green-500",edit_field:"border-l-amber-500",create_entry:"border-l-purple-500"};function QFe({index:e,total:t,seedBranches:n,seedSlug:r,onRemove:s,onMoveUp:i,onMoveDown:o}){const{t:a}=tt(),{watch:l}=Ml(),u=l(`actions.${e}.type`);return d.jsxs(Zn,{className:`border-l-4 ${XFe[u]??"border-l-border"}`,children:[d.jsxs(Tr,{className:"flex flex-row items-center justify-between p-3 pb-2",children:[d.jsx("span",{className:"text-sm font-medium",children:a(`automations.actions.${u}`)}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-6",onClick:i,disabled:e===0,"aria-label":"Move up",children:d.jsx(T6,{className:"size-3.5"})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-6",onClick:o,disabled:e===t-1,"aria-label":"Move down",children:d.jsx(Nc,{className:"size-3.5"})}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 text-destructive hover:text-destructive",onClick:s,"aria-label":"Remove action",children:d.jsx(ro,{className:"size-3.5"})})]})]}),d.jsxs(Xn,{className:"p-3 pt-0",children:[u==="set_variable"&&d.jsx(GFe,{index:e,triggerSeedSlug:r}),u==="webhook"&&d.jsx(WFe,{index:e}),u==="send_mail"&&d.jsx(KFe,{index:e}),u==="edit_field"&&d.jsx(YFe,{index:e,seedBranches:n}),u==="create_entry"&&d.jsx(ZFe,{index:e})]})]})}function JFe({onAdd:e}){const{t}=tt(),{data:n}=hbe(),[r,s]=w.useState(""),[i,o]=w.useState(!1),l=aFe.filter(h=>!(h==="send_mail"&&n?.features?.email===!1)).filter(h=>t(`automations.actions.${h}`).toLowerCase().includes(r.toLowerCase()));function u(h){e({...EZ,type:h}),o(!1),s("")}return d.jsxs(Li,{open:i,onOpenChange:h=>{o(h),h||s("")},children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{variant:"outline",size:"sm",className:"h-8 w-full text-sm justify-between",children:[d.jsx("span",{children:t("automations.editor.addAction")}),d.jsx(Nc,{className:"size-3.5 opacity-60 shrink-0"})]})}),d.jsxs($i,{align:"start",className:"w-64 p-2",children:[d.jsx(Cs,{className:"px-0 pb-2 pt-0 text-xs font-medium text-muted-foreground",children:t("automations.editor.actionsLabel")}),d.jsx(Xt,{placeholder:t("automations.editor.searchPlaceholder"),value:r,onChange:h=>s(h.target.value),className:"h-8 text-sm mb-1"}),d.jsx(ti,{className:"my-1"}),d.jsx("div",{className:"flex flex-col gap-0.5",children:l.map(h=>d.jsx(Oe,{type:"button",variant:"ghost",size:"sm",className:"h-8 justify-start px-2 text-xs",onClick:()=>u(h),children:t(`automations.actions.${h}`)},h))})]})]})}function zZ(){return d.jsx("div",{className:"flex justify-center py-1",children:d.jsx("div",{className:"w-px h-6 bg-border"})})}function eBe({seedBranches:e,seedSlug:t}){const{t:n}=tt(),{control:r,formState:{errors:s}}=Ml(),{fields:i,append:o,remove:a,swap:l}=m1({control:r,name:"actions"});function u(h){o(h)}return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[d.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-primary/10",children:d.jsx(pne,{className:"size-3.5 text-primary"})}),d.jsx("span",{className:"text-sm font-medium",children:n("automations.editor.actionsLabel")})]}),i.length===0&&d.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:n("automations.editor.noActions")}),i.map((h,p)=>d.jsxs("div",{children:[d.jsx(QFe,{index:p,total:i.length,seedBranches:e,seedSlug:t,onRemove:()=>a(p),onMoveUp:()=>l(p,p-1),onMoveDown:()=>l(p,p+1)}),p<i.length-1&&d.jsx(zZ,{})]},h.id)),s.actions?.root?.message&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:n(s.actions.root.message)}),typeof s.actions?.message=="string"&&d.jsx("p",{className:"mt-1 text-xs text-destructive",children:n(s.actions.message)}),d.jsx("div",{className:"mt-3",children:d.jsx(JFe,{onAdd:u})})]})}const WI=(e,t,n)=>{if(e&&"reportValidity"in e){const r=ut(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},y6=(e,t)=>{for(const n in t.fields){const r=t.fields[n];r&&r.ref&&"reportValidity"in r.ref?WI(r.ref,n,e):r&&r.refs&&r.refs.forEach(s=>WI(s,n,e))}},KI=(e,t)=>{t.shouldUseNativeValidation&&y6(e,t);const n={};for(const r in e){const s=ut(t.fields,r),i=Object.assign(e[r]||{},{ref:s&&s.ref});if(tBe(t.names||Object.keys(e),r)){const o=Object.assign({},ut(n,r));rr(o,"root",i),rr(n,r,o)}else rr(n,r,i)}return n},tBe=(e,t)=>{const n=YI(t);return e.some(r=>YI(r).match(`^${n}\\.\\d+`))};function YI(e){return e.replace(/\]|\[/g,"")}function ZI(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function nBe(e,t){for(var n={};e.length;){var r=e[0],s=r.code,i=r.message,o=r.path.join(".");if(!n[o])if("unionErrors"in r){var a=r.unionErrors[0].errors[0];n[o]={message:a.message,type:a.code}}else n[o]={message:i,type:s};if("unionErrors"in r&&r.unionErrors.forEach(function(h){return h.errors.forEach(function(p){return e.push(p)})}),t){var l=n[o].types,u=l&&l[r.code];n[o]=b8(o,t,n,s,u?[].concat(u,r.message):r.message)}e.shift()}return n}function rBe(e,t){for(var n={};e.length;){var r=e[0],s=r.code,i=r.message,o=r.path.join(".");if(!n[o])if(r.code==="invalid_union"&&r.errors.length>0){var a=r.errors[0][0];n[o]={message:a.message,type:a.code}}else n[o]={message:i,type:s};if(r.code==="invalid_union"&&r.errors.forEach(function(h){return h.forEach(function(p){return e.push(p)})}),t){var l=n[o].types,u=l&&l[r.code];n[o]=b8(o,t,n,s,u?[].concat(u,r.message):r.message)}e.shift()}return n}function sBe(e,t,n){if(n===void 0&&(n={}),(function(r){return"_def"in r&&typeof r._def=="object"&&"typeName"in r._def})(e))return function(r,s,i){try{return Promise.resolve(ZI(function(){return Promise.resolve(e[n.mode==="sync"?"parse":"parseAsync"](r,t)).then(function(o){return i.shouldUseNativeValidation&&y6({},i),{errors:{},values:n.raw?Object.assign({},r):o}})},function(o){if((function(a){return Array.isArray(a?.issues)})(o))return{values:{},errors:KI(nBe(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if((function(r){return"_zod"in r&&typeof r._zod=="object"})(e))return function(r,s,i){try{return Promise.resolve(ZI(function(){return Promise.resolve((n.mode==="sync"?lye:cye)(e,r,t)).then(function(o){return i.shouldUseNativeValidation&&y6({},i),{errors:{},values:n.raw?Object.assign({},r):o}})},function(o){if((function(a){return a instanceof v7})(o))return{values:{},errors:KI(rBe(o.issues,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}function iBe(e){const t=wi(),{t:n}=tt();return Fs({mutationFn:r=>h1.create(r),onSuccess:()=>{t.invalidateQueries({queryKey:fl.list(e)}),_n.success(n("automations.toast.created"))},onError:()=>{_n.error(n("automations.toast.error"))}})}function oBe(e){const t=wi(),{t:n}=tt();return Fs({mutationFn:({id:r,body:s})=>h1.update(r,s),onSuccess:(r,{id:s})=>{t.invalidateQueries({queryKey:fl.list(e)}),t.invalidateQueries({queryKey:fl.item(s)}),_n.success(n("automations.toast.updated"))},onError:()=>{_n.error(n("automations.toast.error"))}})}function XI(e){return!e||e.length===0?[{...Ux}]:e.map(t=>({event:t.event,cron:t.cron??""}))}function aBe(e){return{...qx,left_kind:e.left.kind,left_ref:e.left.kind==="ref"?e.left.key:"",left_literal:e.left.kind==="literal"?String(e.left.value??""):"",op:e.op,right_kind:e.right?.kind??"literal",right_ref:e.right?.kind==="ref"?e.right.key:"",right_literal:e.right?.kind==="literal"?String(e.right.value??""):""}}function LZ(e){return{kind:"group",op:e.op,negate:e.negate??!1,children:e.children.map(PZ)}}function PZ(e){return e.kind==="predicate"?aBe(e):LZ(e)}function QI(e){return e?Array.isArray(e)?e.length===0?{...Vx}:{kind:"group",op:"AND",negate:!1,children:e.map(t=>({...qx,left_kind:"ref",left_ref:`this.${t.field}`,op:t.op,right_kind:"literal",right_literal:String(t.value??"")}))}:e.kind==="predicate"?{kind:"group",op:"AND",negate:!1,children:[PZ(e)]}:LZ(e):{...Vx}}function lBe(e){const t=e.op==="isempty"||e.op==="isnotempty";return{kind:"predicate",left:e.left_kind==="ref"?{kind:"ref",key:e.left_ref}:{kind:"literal",value:e.left_literal},op:e.op,right:t?void 0:e.right_kind==="ref"?{kind:"ref",key:e.right_ref}:{kind:"literal",value:e.right_literal}}}function $Z(e){return{kind:"group",op:e.op,negate:e.negate||void 0,children:e.children.map(cBe)}}function cBe(e){return e.kind==="predicate"?lBe(e):$Z(e)}function JI(e){const t={...EZ};switch(e.type){case"set_variable":{const n=e.fixed_id??"",r=e.seed_slug??"",s=n?[]:(e.filters??[]).filter(i=>!(i.field==="id"&&i.op==="eq")).map(i=>({field:i.field,op:i.op,value:String(i.value??"")}));return{...t,type:"set_variable",name:e.name,seed_slug:r,fixed_id:n,column:e.column??"",filters:s}}case"webhook":return{...t,type:"webhook",url:e.url,method:e.method??"POST",headers:Object.entries(e.headers??{}).map(([n,r])=>({key:n,value:r})),body_template:e.body_template??""};case"send_mail":return{...t,type:"send_mail",to:e.to,subject_template:e.subject_template,body_template:e.body_template};case"edit_field":return{...t,type:"edit_field",field:e.field,value:String(e.value??"")};case"create_entry":return{...t,type:"create_entry",seed_slug:e.seed_slug,field_map:Object.entries(e.field_map).map(([n,r])=>({targetAlias:n,sourceAlias:r}))}}}function uBe(e,t){const n=$Z(e.trigger_conditions),r=e.trigger_conditions.children.length>0;return{seed_slug:t,name:e.name,triggers:e.triggers.filter(s=>!!s.event).map(s=>({event:s.event,...s.event==="cron"?{cron:s.cron||null}:{}})),trigger_conditions:r?n:null,actions:e.actions.map(s=>{switch(s.type){case"set_variable":return{type:"set_variable",name:s.name,...s.seed_slug?{seed_slug:s.seed_slug}:{},...s.fixed_id?{fixed_id:s.fixed_id}:{},...s.column?{column:s.column}:{},filters:s.filters.map(i=>({field:i.field,op:i.op,value:i.value}))};case"webhook":return{type:"webhook",url:s.url,method:s.method,headers:s.headers.length>0?Object.fromEntries(s.headers.map(i=>[i.key,i.value])):void 0,body_template:s.body_template||void 0};case"send_mail":return{type:"send_mail",to:s.to,subject_template:s.subject_template,body_template:s.body_template};case"edit_field":return{type:"edit_field",field:s.field,value:s.value};case"create_entry":return{type:"create_entry",seed_slug:s.seed_slug,field_map:Object.fromEntries(s.field_map.map(i=>[i.targetAlias,i.sourceAlias]))}}})}}function dBe({seedSlug:e,seedDisplayName:t,automation:n,open:r,onSuccess:s}){const{user:i}=e1(),{t:o}=tt(),a=!!n,l=iBe(e),u=oBe(e),h=o("automations.editor.defaultName",{name:i?.name??i?.email??"Admin"}),p=oFe({resolver:sBe(cFe),mode:"onChange",defaultValues:n?{name:n.name,triggers:XI(n.triggers),trigger_conditions:QI(n.trigger_conditions),actions:n.actions.map(JI)}:{name:h,triggers:[{...Ux}],trigger_conditions:{...Vx},actions:[]}});function m(){n?p.reset({name:n.name,triggers:XI(n.triggers),trigger_conditions:QI(n.trigger_conditions),actions:n.actions.map(JI)}):p.reset({name:h,triggers:[{...Ux}],trigger_conditions:{...Vx},actions:[]})}w.useEffect(()=>{r&&m()},[n?.id,r]);const b=l.isPending||u.isPending;async function y(x){const S=uBe(x,e);a&&n?await u.mutateAsync({id:n.id,body:S}):await l.mutateAsync(S),s()}return{form:p,isEdit:a,isPending:b,resetForm:m,onSubmit:p.handleSubmit(y)}}function fBe({open:e,onOpenChange:t,seedSlug:n,seedDisplayName:r,seedBranches:s,automation:i}){const{t:o}=tt(),{form:a,isEdit:l,isPending:u,resetForm:h,onSubmit:p}=dBe({seedSlug:n,seedDisplayName:r,automation:i,open:e,onSuccess:()=>t(!1)}),{register:m,formState:{errors:b,isValid:y}}=a;return d.jsx(kf,{open:e,onOpenChange:t,children:d.jsx(Ef,{showCloseButton:!1,className:"max-w-2xl p-0 gap-0",children:d.jsx(q$e,{...a,children:d.jsxs("form",{onSubmit:p,children:[d.jsxs(Ip,{className:"px-6 pt-6 pb-4 border-b",children:[d.jsx(zp,{asChild:!0,children:d.jsx(Xt,{...m("name"),className:"text-lg font-semibold border-0 bg-secondary dark:bg-secondary px-3 py-1.5 h-auto transition-colors focus-visible:ring-1 focus-visible:ring-ring shadow-none",placeholder:o("automations.editor.namePlaceholder")})}),b.name&&d.jsx("p",{className:"text-xs text-destructive mt-1",children:o(b.name.message??"")}),d.jsx("p",{className:"text-sm text-muted-foreground",children:o("automations.editor.subtitle",{seed:r})})]}),d.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:d.jsxs("div",{className:"px-6 py-4 flex flex-col gap-0",children:[d.jsx(xFe,{seedBranches:s}),d.jsx(zZ,{}),d.jsx(eBe,{seedBranches:s,seedSlug:n})]})}),d.jsxs(Ex,{className:"px-6 py-4 border-t",children:[d.jsx(Oe,{type:"button",variant:l?"outline":"destructive",onClick:()=>{l||h(),t(!1)},children:o(l?"common.back":"common.cancel")}),d.jsx(Oe,{type:"submit",disabled:!y||u,children:o(u?"common.saving":l?"common.save":"automations.editor.enableButton")})]})]})})})})}function hBe({open:e,onOpenChange:t,seedSlug:n,seedDisplayName:r,seedBranches:s}){const{t:i}=tt(),{data:o=[],isLoading:a}=fZ(e?n:void 0),l=j$e(n),u=I$e(n),{editorOpen:h,editingAutomation:p,openNew:m,openEdit:b,closeEditor:y}=P$e();return d.jsxs(d.Fragment,{children:[d.jsx(XH,{open:e,onOpenChange:t,children:d.jsxs(QH,{side:"right",className:"w-96 p-0 flex flex-col",children:[d.jsxs(JH,{className:"pl-6 pr-12 py-4 border-b flex flex-row items-center justify-between",children:[d.jsx(eU,{children:i("automations.panel.title")}),d.jsxs(Oe,{size:"sm",onClick:m,children:[d.jsx(Hi,{className:"size-4 mr-1"}),i("automations.panel.newButton")]})]}),d.jsx(ml,{className:"flex-1",children:d.jsxs("div",{className:"px-6 py-2",children:[a&&d.jsx("div",{className:"flex flex-col gap-3 py-3",children:[1,2,3].map(x=>d.jsx(kr,{className:"h-12 w-full rounded-lg"},x))}),!a&&o.length===0&&d.jsx(L$e,{onNew:m}),!a&&o.length>0&&d.jsx("div",{children:o.map(x=>d.jsx(z$e,{automation:x,onEdit:()=>b(x),onDelete:()=>u.mutate(x.id),onToggle:S=>l.mutate({id:x.id,enabled:S}),isToggling:l.isPending&&l.variables?.id===x.id},x.id))})]})})]})}),d.jsx(fBe,{open:h,onOpenChange:x=>{x||y()},seedSlug:n,seedDisplayName:r,seedBranches:s,automation:p})]})}function FZ(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.columnId=="string"&&typeof t.label=="string"&&typeof t.type=="string"&&Array.isArray(t.conditions)}function Gx(e){return e==null?!0:typeof e=="string"?e.trim().length===0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function Ng(e){if(e==null)return null;if(typeof e=="string"){const t=e.trim();if(!t)return null;if(/^\d{4}-\d{2}-\d{2}$/.test(t))return t;const n=new Date(t);return Number.isNaN(n.getTime())?null:n.toISOString().slice(0,10)}if(typeof e=="number"){const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString().slice(0,10)}return null}function pBe(e,t,n,r){if(n==="is_empty")return Gx(e);if(n==="is_not_empty")return!Gx(e);switch(t.type){case"tags":return mBe(e,n,r);case"number":return gBe(e,n,r);case"date":return bBe(e,n,r);case"boolean":return yBe(e,n,r);case"select":return vBe(e,n,r);default:return xBe(e,n,r)}}function mBe(e,t,n){const r=DN(e);return t==="contains"||t==="eq"?typeof n!="string"||!n.trim()?!0:r.includes(n):!0}function gBe(e,t,n){let r=null;typeof e=="number"?r=e:typeof e=="string"&&e.trim()!==""&&(r=Number(e));const s=typeof n=="number"?n:null;if(r==null||s==null||Number.isNaN(r)||Number.isNaN(s))return!0;switch(t){case"eq":return r===s;case"gt":return r>s;case"gte":return r>=s;case"lt":return r<s;case"lte":return r<=s;default:return!0}}function bBe(e,t,n){const r=Ng(e),s=typeof n=="string"?Ng(n):null;if(!r||!s)return!0;switch(t){case"eq":return r===s;case"gt":return r>s;case"gte":return r>=s;case"lt":return r<s;case"lte":return r<=s;default:return!0}}function yBe(e,t,n){const r=typeof e=="boolean"?e:null,s=typeof n=="boolean"?n:null;return r==null||s==null?!0:t==="eq"?r===s:!0}function vBe(e,t,n){const r=e==null?"":String(e);if(t!=="eq"||n==null)return!0;const s=String(n);return s.trim()?r.trim().toLowerCase()===s.trim().toLowerCase():!0}function xBe(e,t,n){const r=e==null?"":String(e);if(t==="contains")return typeof n!="string"||!n.trim()?!0:r.toLowerCase().includes(n.toLowerCase());if(t==="eq"){if(n==null)return!0;const s=String(n);return s.trim()?r.trim().toLowerCase()===s.trim().toLowerCase():!0}return!0}function rC(e,t){if(!FZ(t))return!0;for(const n of t.conditions)if(!pBe(e,t,n.op,n.value))return!1;return!0}function wBe(e,t,n){const r=DN(e);return typeof n!="string"||!n.trim()||r.length===0?!1:t==="contains"||t==="eq"?r.includes(n):!1}function SBe(e,t,n){let r=null;typeof e=="number"?r=e:typeof e=="string"&&e.trim()!==""&&(r=Number(e));const s=typeof n=="number"?n:null;if(r==null||s==null||Number.isNaN(r)||Number.isNaN(s))return!1;switch(t){case"eq":return r===s;case"gt":return r>s;case"gte":return r>=s;case"lt":return r<s;case"lte":return r<=s;default:return!1}}function CBe(e,t,n){const r=Ng(e),s=typeof n=="string"?Ng(n):null;if(!r||!s)return!1;switch(t){case"eq":return r===s;case"gt":return r>s;case"gte":return r>=s;case"lt":return r<s;case"lte":return r<=s;default:return!1}}function kBe(e,t,n){const r=typeof e=="boolean"?e:null,s=typeof n=="boolean"?n:null;return r==null||s==null?!1:t==="eq"?r===s:!1}function EBe(e,t,n){const r=e==null?"":String(e);if(t!=="eq"||n==null)return!1;const s=String(n);return!s.trim()||!r.trim()?!1:r.trim().toLowerCase()===s.trim().toLowerCase()}function NBe(e,t,n){const r=e==null?"":String(e);if(t==="contains")return typeof n!="string"||!n.trim()||!r.trim()?!1:r.toLowerCase().includes(n.toLowerCase());if(t==="eq"){if(n==null)return!1;const s=String(n);return!s.trim()||!r.trim()?!1:r.trim().toLowerCase()===s.trim().toLowerCase()}return!1}function MBe(e,t,n,r){if(n==="is_empty")return Gx(e);if(n==="is_not_empty")return!Gx(e);switch(t.type){case"tags":return wBe(e,n,r);case"number":return SBe(e,n,r);case"date":return CBe(e,n,r);case"boolean":return kBe(e,n,r);case"select":return EBe(e,n,r);default:return NBe(e,n,r)}}function ez(e,t){if(!FZ(t))return!1;for(const n of t.conditions)if(!MBe(e,t,n.op,n.value))return!1;return!0}const BZ=20,HZ=60,Wx={year:!0,month:!0,day:!1};function _Be(e,t=Wx){const n=Ng(e);if(!n)return"—";const r=new Date(n+"T00:00:00");if(t.day)return r.toLocaleDateString("en-US",{day:"2-digit",month:"long",year:"numeric"});const s=[];return t.month&&s.push(r.toLocaleDateString("en-US",{month:"long"})),t.year&&s.push(String(r.getFullYear())),s.length?s.join(" "):String(r.getFullYear())}const TBe=(e,t)=>{let n=0,r=0;for(const s of t){const i=s.getValue(e);i===!0?n++:i===!1&&r++}return{trueCount:n,falseCount:r}};function ABe(e){if(e!=null&&typeof e=="object"&&"trueCount"in e&&"falseCount"in e){const{trueCount:t,falseCount:n}=e;return`✓ ${t} / ✗ ${n}`}return""}function RBe(e,t,n){return typeof e=="number"&&!Number.isNaN(e)?`Σ ${e.toLocaleString("en-US")} · ${t} ${n(t===1?"content.table.item":"content.table.items")}`:`${t} ${n(t===1?"content.table.item":"content.table.items")}`}function OBe(e){const t=e.trim().toLowerCase();if(!t)return"secondary";if(["error","failed","rejected","archived"].includes(t))return"destructive";if(["published","active","approved","online"].includes(t))return"default";let n=0;for(let r=0;r<t.length;r++){const s=t.codePointAt(r);s!=null&&(n=n*31+s>>>0,s>65535&&r++)}return n%2===0?"secondary":"outline"}function tz(e,t){let n=0;for(const r of e){const s=r.data[t];if(s==null)continue;const i=String(s).length;i>n&&(n=i)}return Math.min(Math.max(n,BZ),HZ)}function DBe(e,t){if(t.toLowerCase().includes("tag"))return null;let r=0;for(const s of e){const i=s.data[t];if(i==null)continue;let o;if(typeof i=="string")try{o=JSON.stringify(JSON.parse(i))}catch{o=i}else o=JSON.stringify(i);o.length>r&&(r=o.length)}return Math.min(Math.max(r,BZ),HZ)}function jBe(e,t){return e.type==="json"?DBe(t,e.alias):(e.type==="text",tz(t,e.alias))}function IBe(e,t,n){const r={},s=e.slice(0,n);for(const i of t.branches){const o=jBe(i,s);o!=null&&(r[i.alias]=o)}return r}function zBe(e,t,n,r,s=[],i,o=Wx,a=l=>l){const l=[{id:"select",header:({table:p})=>d.jsx(Qk,{checked:p.getIsAllPageRowsSelected()||p.getIsSomePageRowsSelected()&&"indeterminate",onCheckedChange:m=>p.toggleAllPageRowsSelected(!!m),"aria-label":a("common.selectAll")}),cell:({row:p})=>d.jsx(Qk,{checked:p.getIsSelected(),onCheckedChange:m=>p.toggleSelected(!!m),"aria-label":a("common.selectRow")}),enableSorting:!1,enableHiding:!1},{id:"id",accessorFn:p=>p.id,header:"ID",cell:({row:p})=>d.jsx("span",{className:"font-mono text-xs truncate max-w-[8rem] block",title:p.original.id,children:p.original.id}),enableSorting:!1},{id:"slug",accessorFn:p=>p.slug,header:"Slug",filterFn:(p,m,b)=>rC(p.getValue(m),b),cell:({row:p})=>{const m=p.original.slug;return d.jsx("span",{className:"text-muted-foreground text-sm",children:m??"—"})},enableSorting:!1},{id:"status",accessorFn:p=>p.status,header:a("content.table.status"),filterFn:(p,m,b)=>rC(p.getValue(m),b),cell:({row:p})=>{const m=(p.original.status??"").trim()||"—",b=OBe(m);return d.jsx(gi,{variant:b,children:m})},enableSorting:!1}],u=e.branches.map(p=>{const m={accessorFn:y=>y.data[p.alias],id:p.alias,header:()=>d.jsx("div",{className:"font-medium",children:p.label}),filterFn:(y,x,S)=>rC(y.getValue(x),S)};p.type==="date"?(m.getGroupingValue=y=>_Be(y.data[p.alias],o),m.aggregationFn="count",m.aggregatedCell=({getValue:y,row:x})=>{const S=x.subRows?.length??0,C=y();return C?d.jsxs("span",{className:"text-xs text-muted-foreground",children:[C," · ",S," ",a(S===1?"content.table.item":"content.table.items")]}):null}):p.type==="boolean"?(m.aggregationFn=TBe,m.aggregatedCell=({getValue:y})=>{const x=ABe(y());return x?d.jsx("span",{className:"text-xs text-muted-foreground",children:x}):null}):p.type==="number"?(m.aggregationFn="sum",m.aggregatedCell=({getValue:y,row:x})=>{const S=x.subRows?.length??0;return d.jsx("span",{className:"text-xs text-muted-foreground",children:RBe(y(),S,a)})}):(m.aggregationFn="count",m.aggregatedCell=({row:y})=>{const x=y.subRows?.length??0;return d.jsxs("span",{className:"text-xs text-muted-foreground",children:[x," ",a(x===1?"content.table.item":"content.table.items")]})});const b=r?.[p.alias];return{...m,cell:({row:y})=>d.jsx(rZ,{branch:p,value:y.original.data[p.alias],options:typeof b=="number"?{maxLength:b}:void 0})}}),h={id:"actions",enableHiding:!1,cell:({row:p})=>{const m=p.original,b=s.length>1;return d.jsx("div",{className:"text-right",children:d.jsxs(Li,{children:[d.jsx(Pi,{asChild:!0,children:d.jsxs(Oe,{variant:"ghost",size:"icon-xs",children:[d.jsx("span",{className:"sr-only",children:a("common.openMenu")}),d.jsx(bz,{})]})}),d.jsxs($i,{align:"end",className:"w-40",children:[d.jsx(Cs,{children:a("content.actions.label")}),b?d.jsx(cl,{onClick:()=>i?.(s),className:"text-destructive focus:text-destructive",children:a("common.delete")}):d.jsxs(d.Fragment,{children:[d.jsx(cl,{onClick:()=>{navigator.clipboard.writeText(m.id).then(()=>_n.success(a("common.copied")),()=>_n.error(a("common.copyFailed")))},children:a("content.actions.copyId")}),d.jsx(ti,{}),d.jsx(cl,{onClick:()=>{t(m.id)},children:a("common.edit")}),d.jsx(cl,{onClick:()=>n(m.id),className:"text-destructive focus:text-destructive",children:a("common.delete")})]})]})]})})}};return[...l,...u,h]}function UZ(e,t){const[n,r]=w.useState(e);return w.useEffect(()=>{const s=setTimeout(()=>r(e),t);return()=>clearTimeout(s)},[e,t]),n}function LBe(){const{slug:e}=gH(),t=pa(),{t:n}=tt(),[r,s]=w.useState(0),i=10,[o,a]=w.useState(i),[l,u]=w.useState(""),h=UZ(l,300),[p,m]=w.useState([]),[b]=j2(),y=b.get("status"),[x,S]=w.useState(()=>y?{status:{columnId:"status",label:"Status",type:"select",conditions:[{id:"status-prefilter",op:"eq",value:y}],selectOptions:["draft","published"]}}:{}),[C,N]=w.useState({}),[M,_]=w.useState(!1),[T,R]=w.useState(null),[D,j]=w.useState(!1),[L,V]=w.useState("table"),{seed:q,isLoading:X}=$W(e),[ee,re]=w.useState(null),[oe,F]=w.useState(Wx),{data:se,isLoading:le,error:W}=T$e(e,{page:r+1,limit:o,search:h.trim()||void 0,sortBy:p[0]?.id,sortDir:p[0]?.desc?"desc":"asc",filters:x}),{data:Q}=A$e(e),{mutateAsync:H}=R$e();fZ(e);const U=w.useMemo(()=>se?.items??[],[se]),Z=se?.total??0,he=le,fe=W?W.message:null;w.useEffect(()=>{s(0)},[e,h,p,x,o]),w.useEffect(()=>{if(!ee||!q)return;q.branches.find(P=>P.alias===ee)?.type!=="date"&&F(Wx)},[ee,q]);const[ye,ge]=w.useState(()=>[{id:"table",label:"table",type:"table",enabledTools:["filter","sort","automation","search","settings","create"],conditionalFormats:[]},{id:"gallery",label:"gallery",type:"gallery",enabledTools:["filter","sort","automation","search","create"],conditionalFormats:[]}]),Ee={table:n("content.list.table"),gallery:n("content.list.gallery")},Ae=w.useMemo(()=>ye.map(Re=>({...Re,label:Ee[Re.type]??Re.label})),[ye,n]),Qe=w.useMemo(()=>ye.find(Re=>Re.id===L),[L,ye]),rt=w.useCallback((Re,P)=>{ge(K=>K.map(be=>be.id===Re?{...be,conditionalFormats:P}:be))},[]),ct=w.useCallback((Re,P)=>P==="id"?Re.id:P==="slug"?Re.slug:P==="status"?Re.status:Re.data?.[P],[]),He=w.useRef(new Map);w.useEffect(()=>{He.current.clear()},[e,U]);const _e=w.useCallback((Re,P,K)=>{const be=ct(Re,P);if(K!=="tags")return be;const Pe=`${Re.id}::${P}`;if(He.current.has(Pe))return He.current.get(Pe);let pt=be;if(typeof be=="string")try{pt=JSON.parse(be)}catch{pt=null}return He.current.set(Pe,pt),pt},[ct]),nn=w.useMemo(()=>(Qe?.conditionalFormats??[]).filter(P=>!!P?.enabled).slice().sort((P,K)=>(P.priority??0)-(K.priority??0)),[Qe?.conditionalFormats]),xt=w.useMemo(()=>nn.filter(Re=>{const P=Re.target;return P==="row"||P==="cell+row"}),[nn]),Jt=w.useMemo(()=>{const Re=new Map;for(const P of nn){if(P.target==="row")continue;const be=Re.get(P.columnId)??[];be.push(P),Re.set(P.columnId,be)}return Re},[nn]),fn=w.useCallback(Re=>{let P;const K={};for(const be of xt){const Pe=_e(Re,be.columnId,be.group.type);if(ez(Pe,be.group)){P=cZ(be.tone,be.textStyles??[]);break}}for(const[be,Pe]of Jt.entries())for(const pt of Pe){const st=_e(Re,pt.columnId,pt.group.type);if(ez(st,pt.group)){K[be]=uZ(pt.tone,pt.textStyles??[]);break}}return{rowClassName:P,cellClassNameByColumnId:K}},[Jt,_e,xt]),hn=w.useCallback(Re=>{e&&t(`/content/${e}/${Re}`)},[e,t]),zn=w.useCallback(Re=>{R([Re]),_(!0)},[]),lr=w.useCallback(Re=>{const P=Array.from(new Set(Re)).filter(Boolean);P.length&&(R(P),_(!0))},[]),In=w.useCallback(()=>{e&&t(`/content/${e}/create`)},[e,t]),Fn=w.useCallback(async()=>{if(!e||!T||T.length===0)return;const P=(await Promise.allSettled(T.map(K=>H({slug:e,id:K})))).filter(K=>K.status==="rejected").length;if(P>0)throw new Error(`Partial deletion: ${P} out of ${T.length} failed`);N({})},[e,T,H]),G=w.useMemo(()=>Object.keys(C).filter(Re=>C[Re]),[C]),pe=w.useMemo(()=>Z<=0?1:Math.max(1,Math.ceil(Z/o)),[o,Z]),[ue,Fe]=w.useState(()=>{const Re={};if(Re.id=!1,Re.slug=!1,!q)return Re;const P=q.branches.filter(K=>K.type==="json"&&(K.alias.toLowerCase().includes("metadata")||K.alias.toLowerCase().includes("metadati"))).map(K=>K.alias);for(const K of P)Re[K]=!1;return Re}),$e=w.useMemo(()=>{if(!(!q||U.length===0))return IBe(U,q,o)},[q,U,o]),ze=w.useMemo(()=>q?zBe(q,hn,zn,$e,G,lr,oe,n):[],[q,hn,zn,$e,G,lr,oe,n]),qe=p[0],Rt=w.useMemo(()=>{const Re=new Set;for(const P of U){const K=typeof P.status=="string"?P.status.trim():"";K&&Re.add(K)}return Array.from(Re).sort((P,K)=>P.localeCompare(K,"it"))},[U]),Ot=w.useMemo(()=>{if(!q)return{};const Re=q.branches.filter(K=>K.type==="json"&&K.alias.toLowerCase().includes("tag"));if(Re.length===0)return{};const P={};for(const K of Re){const be=new Set(K.options??[]);for(const Pe of U)for(const pt of DN(Pe.data[K.alias]))be.add(pt);P[K.alias]=Array.from(be).sort((Pe,pt)=>Pe.localeCompare(pt,"it"))}return P},[U,q]),xn=w.useMemo(()=>{const Re=new Set([...Object.keys(Ot),...Object.keys(Q?.tagsByColumnId??{})]),P={};for(const K of Re){const be=new Set([...Ot[K]??[],...Q?.tagsByColumnId?.[K]??[]]);P[K]=Array.from(be).sort((Pe,pt)=>Pe.localeCompare(pt,"it"))}return P},[Ot,Q?.tagsByColumnId]),gn=w.useMemo(()=>Q?.statuses&&Q.statuses.length>0?Q.statuses:Rt,[Q?.statuses,Rt]),en=w.useMemo(()=>ee?[ee]:[],[ee]),Lt=w.useMemo(()=>!q||!ee?!1:q.branches.find(P=>P.alias===ee)?.type==="date",[ee,q]),ls=w.useMemo(()=>{if(Lt&&ee){let Re;return oe.day?Re="day":oe.year&&!oe.month?Re="year":Re="monthYear",`group:${ee}:date:${Re}`}return`group:${ee??"none"}`},[oe.day,oe.month,oe.year,ee,Lt]),Sr=w.useMemo(()=>{const Re=[],P=st=>typeof st=="string"&&st.trim().length>0,K=st=>typeof st=="number"&&!Number.isNaN(st),be=(st,Ve)=>{switch(st){case"boolean":return Ve===!0||Ve===!1;case"number":return K(Ve);default:return P(Ve)}},Pe=(st,Ve)=>{switch(st){case"number":return K(Ve);case"date":return P(Ve);default:return!1}},pt=(st,Ve)=>{switch(Ve.op){case"is_empty":case"is_not_empty":return!0;case"contains":return P(Ve.value);case"eq":return be(st.type,Ve.value);case"gt":case"gte":case"lt":case"lte":return Pe(st.type,Ve.value);default:return!1}};for(const[st,Ve]of Object.entries(x))Ve.conditions.some(bt=>pt(Ve,bt))&&Re.push({id:st,value:Ve});return Re},[x]),yt=w.useCallback(Re=>{if(!Re.length){m([]);return}const[P]=Re;m([{id:P.id,desc:P.desc??!1}])},[]),Bt=w.useCallback(Re=>{if(!Re.columnId){m([]);return}m([{id:Re.columnId,desc:Re.desc}])},[]),gt=w.useCallback((Re,P)=>{ge(K=>K.map(be=>be.id===Re?{...be,label:P}:be))},[]),Pt=w.useMemo(()=>{const Re=["id","slug"];if(!q)return Re;const P=q.branches.filter(K=>K.type==="json"&&(K.alias.toLowerCase().includes("metadata")||K.alias.toLowerCase().includes("metadati"))).map(K=>K.alias);return[...Re,...P]},[q]);return!q&&!X?d.jsx("div",{className:"[--header-height:calc(--spacing(14))]",children:d.jsxs(Ru,{className:"flex flex-col",children:[d.jsx(Pu,{}),d.jsxs("div",{className:"flex flex-1",children:[d.jsx(Lu,{}),d.jsx(Ou,{children:d.jsx("div",{className:"flex flex-1 flex-col gap-4 p-4",children:d.jsx("div",{className:"content-area-inner",children:d.jsxs("div",{className:"rounded-lg border border-destructive bg-destructive/10 p-4",children:[d.jsx("h2",{className:"text-lg font-semibold text-destructive",children:"Error"}),d.jsx("p",{className:"text-sm text-destructive/90",children:fe||`Seed "${e}" not found`})]})})})})]})]})}):X||!q?d.jsx("div",{className:"[--header-height:calc(--spacing(14))]",children:d.jsxs(Ru,{className:"flex flex-col",children:[d.jsx(Pu,{}),d.jsxs("div",{className:"flex flex-1",children:[d.jsx(Lu,{}),d.jsx(Ou,{children:d.jsx("div",{className:"flex flex-1 items-center justify-center py-12",children:d.jsx("div",{className:"text-muted-foreground",children:"Loading configuration..."})})})]})]})}):d.jsxs("div",{className:"[--header-height:calc(--spacing(14))] overflow-x-clip",children:[d.jsxs(Ru,{className:"flex flex-col",children:[d.jsx(Pu,{}),d.jsxs("div",{className:"flex flex-1",children:[d.jsx(Lu,{}),d.jsx(Ou,{className:"min-w-0",children:d.jsx("div",{className:"flex flex-1 flex-col gap-4 p-4 min-w-0",children:d.jsxs("div",{className:"content-area-inner",children:[d.jsxs("div",{className:"mb-6",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:q.labelPlural??q.label}),d.jsxs("p",{className:"text-muted-foreground text-sm",children:['Manage "',q.slug,'" content']})]}),d.jsxs(_$e,{seed:q,views:Ae,activeViewId:L,onChangeView:V,onRenameView:gt,onConditionalFormatsChange:rt,onCreate:In,searchValue:l,onSearchChange:u,sortState:{columnId:qe?.id??null,desc:qe?.desc??!0},onSortChange:Bt,filters:x,onFiltersChange:S,availableTagsByColumnId:xn,availableStatusOptions:gn,pageSize:o,onPageSizeChange:Re=>{a(Re),s(0)},columnVisibility:ue,onColumnVisibilityChange:Fe,groupBy:ee,onGroupByChange:re,dateGroupPrecision:oe,onDateGroupPrecisionChange:F,onOpenAutomation:()=>j(!0),isAutomationActive:D,children:[fe&&d.jsx("div",{className:"rounded-lg border border-destructive bg-destructive/10 p-4",children:d.jsx("p",{className:"text-sm text-destructive",children:fe})}),he&&!fe&&L==="table"&&d.jsx("div",{className:"flex items-center justify-center py-12",children:d.jsx("div",{className:"text-muted-foreground",children:"Loading..."})}),!he&&!fe&&L==="table"&&d.jsx(AMe,{columns:ze,data:U,initialHiddenColumns:Pt,getRowStyles:fn,rowSelection:C,onRowSelectionChange:N,onRowDoubleClick:Re=>hn(Re.id),grouping:en,onGroupingChange:Re=>re(Re[0]??null),renderRowContextMenuContent:Re=>d.jsxs(d.Fragment,{children:[d.jsx(t8e,{children:"Actions"}),G.length>1?d.jsx(Gd,{onSelect:()=>lr(G),className:"text-destructive focus:text-destructive",children:"Delete"}):d.jsxs(d.Fragment,{children:[d.jsx(Gd,{onSelect:()=>{navigator.clipboard.writeText(Re.id).then(()=>_n.success("ID copied"),()=>_n.error("Copy failed"))},children:"Copy ID"}),d.jsx(UW,{}),d.jsx(Gd,{onSelect:()=>hn(Re.id),children:"Edit"}),d.jsx(Gd,{onSelect:()=>zn(Re.id),className:"text-destructive focus:text-destructive",children:"Delete"})]})]}),pageSize:o,onPageSizeChange:Re=>{a(Re),s(0)},pageIndex:r,onPageIndexChange:s,pageCount:pe,totalRows:Z,manualPagination:!0,manualSorting:!0,manualFiltering:!0,columnVisibility:ue,onColumnVisibilityChange:Fe,globalFilter:l,onGlobalFilterChange:u,sorting:p,onSortingChange:yt,columnFilters:Sr},ls),!fe&&L==="gallery"&&d.jsx(t$e,{seed:q,data:U,isLoading:he,onEdit:hn})]})]})})})]})]}),d.jsx(IMe,{open:M,onOpenChange:_,seed:q,entryIds:T,onConfirm:Fn}),d.jsx(hBe,{open:D,onOpenChange:j,seedSlug:q.slug,seedDisplayName:q.label,seedBranches:q.branches})]})}function PBe(e){return PW(e)}function nz(e){return e.alias.startsWith("meta")}function $Be(){return{type:"doc",content:[{type:"paragraph"}]}}function FBe(e){const t={};for(const n of e)n.type==="boolean"?t[n.alias]=!1:n.type==="richtext"?t[n.alias]=$Be():t[n.alias]="";return t}function BBe(e){return typeof e=="string"?e:e!=null?String(e):""}function HBe({branches:e,formData:t,slug:n,status:r}){const s={};for(const i of e){const o=t[i.alias];if(i.type==="json"&&o)if(typeof o=="string")try{s[i.alias]=JSON.parse(o)}catch{s[i.alias]=o}else s[i.alias]=o;else s[i.alias]=o}return{slug:n.trim()||null,status:r.trim()||"draft",...s}}function UBe(e,t){for(const n of e){if(n.type!=="json")continue;const r=t[n.alias];if(!(!r||typeof r!="string"))try{JSON.parse(r)}catch{return{isValid:!1,errorFieldLabel:n.label}}}return{isValid:!0}}function Ry({children:e}){return d.jsx("div",{className:"[--header-height:calc(--spacing(14))]",children:d.jsxs(Ru,{className:"flex flex-col",children:[d.jsx(Pu,{}),d.jsxs("div",{className:"flex flex-1",children:[d.jsx(Lu,{}),d.jsx(Ou,{className:"min-w-0",children:d.jsx("div",{className:"flex flex-1 flex-col gap-4 p-4",children:e})})]})]})})}function VZ({status:e,onStatusChange:t,slug:n,onSlugChange:r,isGrid:s=!1}){const{t:i}=tt(),o=d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(Es,{htmlFor:"entry-status",children:i("content.editor.status")}),d.jsxs(Rr,{value:e,onValueChange:t,children:[d.jsx(Or,{id:"entry-status",className:"w-full",children:d.jsx(Gr,{placeholder:i("content.editor.status")})}),d.jsxs(Dr,{children:[d.jsx(or,{value:"draft",children:i("content.editor.draft")}),d.jsx(or,{value:"published",children:i("content.editor.published")})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Es,{htmlFor:"entry-slug",children:i("content.editor.slug")}),d.jsx(Xt,{id:"entry-slug",value:n,onChange:a=>r(a.target.value),maxLength:15,placeholder:i("content.editor.slugPlaceholder"),className:"font-mono text-sm"})]})]});return s?d.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:o}):d.jsx(d.Fragment,{children:o})}function Kx({branches:e,formData:t,fieldErrors:n,onInputChange:r}){return d.jsx(d.Fragment,{children:e.map(s=>d.jsxs("div",{className:"space-y-2",children:[d.jsx(Es,{htmlFor:s.alias,children:s.label}),d.jsx(d8,{branch:s,value:t[s.alias],onChange:i=>r(s.alias,i)}),n[s.alias]&&d.jsx("p",{className:"text-xs text-destructive",children:n[s.alias]})]},s.alias))})}function VBe({richtextBranch:e,seoBranches:t,contentBranches:n,formData:r,fieldErrors:s,status:i,slug:o,onInputChange:a,onStatusChange:l,onSlugChange:u}){const{t:h}=tt();return d.jsxs("div",{className:"grid flex-1 gap-6 md:grid-cols-[1fr_320px] lg:grid-cols-[1fr_360px] xl:grid-cols-[1fr_400px] md:min-h-0",children:[d.jsxs("div",{className:"min-h-[70vh] flex flex-col rounded-lg border-0",children:[d.jsx(d8,{branch:e,value:r[e.alias],onChange:p=>a(e.alias,p)}),s[e.alias]&&d.jsx("p",{className:"text-xs text-destructive mt-1",children:s[e.alias]})]}),d.jsxs("aside",{className:"flex flex-col gap-4 md:sticky md:top-[calc(var(--header-height)+1rem)] md:self-start",children:[d.jsxs(Zn,{children:[d.jsx(Tr,{children:d.jsx(Wr,{children:h("content.editor.metadataSeo")})}),d.jsxs(Xn,{className:"space-y-4",children:[d.jsx(VZ,{status:i,onStatusChange:l,slug:o,onSlugChange:u}),d.jsx(Kx,{branches:t,formData:r,fieldErrors:s,onInputChange:a})]})]}),d.jsxs(Zn,{children:[d.jsx(Tr,{children:d.jsx(Wr,{children:h("content.editor.content")})}),d.jsx(Xn,{className:"space-y-4",children:d.jsx(Kx,{branches:n,formData:r,fieldErrors:s,onInputChange:a})})]})]})]})}function qBe({seoBranches:e,contentBranches:t,formData:n,fieldErrors:r,status:s,slug:i,onInputChange:o,onStatusChange:a,onSlugChange:l}){const{t:u}=tt();return d.jsxs("div",{className:"mx-auto w-full max-w-2xl lg:max-w-3xl xl:max-w-4xl space-y-6",children:[d.jsxs(Zn,{children:[d.jsx(Tr,{children:d.jsx(Wr,{children:u("content.editor.publication")})}),d.jsx(Xn,{className:"space-y-4",children:d.jsx(VZ,{status:s,onStatusChange:a,slug:i,onSlugChange:l,isGrid:!0})})]}),e.length>0&&d.jsxs(Zn,{children:[d.jsx(Tr,{children:d.jsx(Wr,{children:u("content.editor.metadataSeo")})}),d.jsx(Xn,{className:"space-y-4",children:d.jsx(Kx,{branches:e,formData:n,fieldErrors:r,onInputChange:o})})]}),d.jsxs(Zn,{children:[d.jsx(Tr,{children:d.jsx(Wr,{children:u("content.editor.content")})}),d.jsx(Xn,{className:"space-y-4",children:d.jsx(Kx,{branches:t,formData:n,fieldErrors:r,onInputChange:o})})]})]})}function rz(){const{t:e}=tt(),{slug:t,id:n}=gH(),r=pa(),s=!n,{seed:i,isLoading:o}=$W(t),{data:a,isLoading:l,error:u}=O$e(t,n),{mutateAsync:h,isPending:p}=D$e(),[m,b]=w.useState({}),[y,x]=w.useState("draft"),[S,C]=w.useState(""),[N,M]=w.useState(!1),[_,T]=w.useState(!1),[R,D]=w.useState({}),j=w.useRef(!1),L=B0e(()=>_&&!j.current),V=w.useMemo(()=>i?.branches??[],[i]),q=w.useCallback((ye,ge)=>{b(Ee=>({...Ee,[ye]:ge})),T(!0)},[]),X=w.useCallback(ye=>{x(ye),T(!0)},[]),ee=w.useCallback(ye=>{C(PW(ye)),M(!0),T(!0)},[]);w.useEffect(()=>{a&&(b(a.data??{}),x(a.status??"draft"),C(a.slug??""),T(!1))},[a]);const re=u instanceof Error?u.message:null;w.useEffect(()=>{!i||!s||(b(FBe(V)),x("draft"),C(""),M(!1))},[i,s,V]);const oe=w.useMemo(()=>V.find(ye=>ye.type==="text")?.alias,[V]),F=oe?m[oe]:void 0;w.useEffect(()=>{if(!s||N||oe==null)return;const ye=BBe(F);C(PBe(ye))},[s,N,oe,F]);const se=w.useMemo(()=>V.find(ye=>ye.type==="richtext"),[V]),le=!!se,W=w.useMemo(()=>V.filter(ye=>ye.alias!==se?.alias&&nz(ye)),[V,se]),Q=w.useMemo(()=>V.filter(ye=>ye.alias!==se?.alias&&!nz(ye)),[V,se]),H=async(ye,ge,Ee)=>{await h({slug:ye,id:Ee??void 0,data:ge}),Ee?_n.success(e("content.editor.savedSuccess")):_n.success(e("content.editor.createdSuccess"))},U=async ye=>{if(ye.preventDefault(),!t||!i||!s&&!n)return;const ge=UBe(V,m);if(!ge.isValid){_n.error(e("content.editor.jsonError",{field:ge.errorFieldLabel}));return}D({});try{const Ee=HBe({branches:V,formData:m,slug:S,status:y});await H(t,Ee,s?null:n),T(!1),j.current=!0,r(`/content/${t}`)}catch(Ee){const Ae=Ee;if(Ae.response?.status===409){_n.error(e("content.editor.slugDuplicate"));return}if(Ae.response?.status===400){const Qe=Ae.response.data?.errors;if(Qe&&Qe.length>0){const rt={};Qe.forEach(ct=>{rt[ct.field]=ct.message}),D(rt),_n.error(e("content.editor.validationError",{count:Qe.length}));return}}_n.error(Ee instanceof Error?Ee.message:e("content.editor.saveError"))}},Z=()=>r(t?`/content/${t}`:"/");if(!t)return d.jsx("div",{className:"flex min-h-svh items-center justify-center p-4",children:d.jsx("p",{className:"text-destructive",children:e("content.editor.slugMissing")})});if(!i&&!o)return d.jsx(Ry,{children:d.jsxs("div",{className:"rounded-lg border border-destructive bg-destructive/10 p-4",children:[d.jsx("p",{className:"text-destructive",children:e("content.editor.seedNotFound",{slug:t})}),d.jsx(Oe,{variant:"outline",className:"mt-2",onClick:Z,children:e("content.editor.back")})]})});if(o||!i||n&&l)return d.jsxs(Ry,{children:[d.jsx(kr,{className:"h-10 w-48"}),d.jsxs("div",{className:"grid flex-1 gap-4 md:grid-cols-[1fr_320px] lg:grid-cols-[1fr_360px] xl:grid-cols-[1fr_400px]",children:[d.jsx(kr,{className:"min-h-[70vh] rounded-lg"}),d.jsx(kr,{className:"h-64 rounded-lg"})]})]});if(n&&re)return d.jsx(Ry,{children:d.jsxs("div",{className:"rounded-lg border border-destructive bg-destructive/10 p-4",children:[d.jsx("p",{className:"text-destructive",children:re}),d.jsx(Oe,{variant:"outline",className:"mt-2",onClick:Z,children:"Back"})]})});const he=s?e("content.editor.newEntry",{label:i.label}):e("content.editor.editEntry",{label:i.label}),fe=p?d.jsxs(d.Fragment,{children:[d.jsx(ta,{className:"mr-2 size-4 animate-spin"}),e("content.editor.saving")]}):e("content.editor.save");return d.jsxs(Ry,{children:[d.jsxs("form",{className:"content-area-inner flex flex-1 flex-col",onSubmit:U,children:[d.jsxs("div",{className:"mb-4 flex items-center justify-between gap-4",children:[d.jsxs(Oe,{type:"button",variant:"ghost",size:"sm",onClick:Z,children:[d.jsx(EJ,{className:"mr-1 size-4"}),e("content.editor.back")]}),d.jsx("h1",{className:"text-xl font-semibold truncate pb-1",children:he}),d.jsx(Oe,{type:"submit",disabled:p,children:fe})]}),le?d.jsx(VBe,{richtextBranch:se,seoBranches:W,contentBranches:Q,formData:m,fieldErrors:R,status:y,slug:S,onInputChange:q,onStatusChange:X,onSlugChange:ee}):d.jsx(qBe,{seoBranches:W,contentBranches:Q,formData:m,fieldErrors:R,status:y,slug:S,onInputChange:q,onStatusChange:X,onSlugChange:ee})]}),d.jsx(sU,{open:L.state==="blocked",children:d.jsxs(iU,{children:[d.jsxs(oU,{children:[d.jsx(lU,{children:e("content.editor.unsavedTitle")}),d.jsx(cU,{children:e("content.editor.unsavedDesc")})]}),d.jsxs(aU,{children:[d.jsx(dU,{onClick:()=>L.reset?.(),children:e("content.editor.stay")}),d.jsx(uU,{variant:"destructive",onClick:()=>L.proceed?.(),children:e("content.editor.exitWithout")})]})]})})]})}const GBe={alias:"body",label:"Corpo del testo",type:"richtext"};function WBe(){const[e,t]=w.useState("<h2>Titolo di esempio</h2><p>Scrivi qui il tuo contenuto <strong>ricco</strong>.</p><ul><li>Primo punto</li><li>Secondo punto</li></ul>");return d.jsx("div",{className:"[--header-height:calc(--spacing(14))]",children:d.jsxs(Ru,{className:"flex flex-col",children:[d.jsx(Pu,{}),d.jsxs("div",{className:"flex flex-1",children:[d.jsx(Lu,{}),d.jsx(Ou,{children:d.jsxs("div",{className:"mx-auto w-full max-w-screen-2xl p-6 space-y-8",children:[d.jsxs("div",{children:[d.jsx("h1",{className:"text-2xl font-semibold",children:"Field Playground"}),d.jsxs("p",{className:"text-muted-foreground text-sm mt-1",children:["Pagina di test per il campo ",d.jsx("code",{className:"font-mono bg-muted px-1 py-0.5 rounded text-xs",children:"richtext"})]})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h2",{className:"text-base font-medium",children:["Edit — ",d.jsx("span",{className:"text-muted-foreground font-normal",children:'FieldEdit type="richtext"'})]}),d.jsx("div",{className:"max-w-2xl",children:d.jsx(d8,{branch:GBe,value:e,onChange:n=>t(n)})})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h2",{className:"text-base font-medium",children:["Preview — ",d.jsx("span",{className:"text-muted-foreground font-normal",children:"HTML compilato con stili applicati"})]}),d.jsx("div",{className:"richtext-content rounded-md border border-input bg-background px-4 py-3 max-w-2xl",dangerouslySetInnerHTML:{__html:e}})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsx("h2",{className:"text-base font-medium",children:"Output HTML grezzo"}),d.jsx("pre",{className:"rounded-md border border-input bg-muted/30 px-4 py-3 text-xs font-mono whitespace-pre-wrap break-all max-w-2xl max-h-48 overflow-auto",children:e})]})]})})]})]})})}const a0={getTotalStats:async()=>{const{data:e}=await Gt.get("/content/stats/total");return e},getCloudflareStats:async()=>{const{data:e}=await Gt.get("/content/stats/cloudflare");return e},getRecentActivity:async e=>{const{data:t}=await Gt.get("/content/stats/recent-activity",{params:{slug:e}});return t},getSystemHealth:async()=>{const{data:e}=await Gt.get("/content/stats/health");return e},getContentBreakdown:async()=>{const{data:e}=await Gt.get("/content/stats/breakdown");return e},getSetupChecklist:async()=>{const{data:e}=await Gt.get("/content/stats/setup-checklist");return e}};function E8(){return Ir({queryKey:si.stats(),queryFn:a0.getTotalStats,staleTime:300*1e3})}function N8(){return Ir({queryKey:si.cloudflare(),queryFn:a0.getCloudflareStats,staleTime:300*1e3})}function qZ(e){return Ir({queryKey:[...si.activity(),e],queryFn:()=>a0.getRecentActivity(e),refetchInterval:60*1e3,staleTime:60*1e3})}function GZ(){return Ir({queryKey:si.health(),queryFn:a0.getSystemHealth,staleTime:300*1e3})}function KBe(){return Ir({queryKey:si.breakdown(),queryFn:a0.getContentBreakdown,staleTime:300*1e3})}function YBe(){return Ir({queryKey:si.setupChecklist(),queryFn:a0.getSetupChecklist,staleTime:30*1e3,refetchInterval:60*1e3})}class ZBe extends w.Component{state={hasError:!1};static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error(`[BeechCMS] Widget "${this.props.widgetId}" crashed:`,t,n)}render(){return this.state.hasError?d.jsxs("div",{className:"flex h-full min-h-[80px] flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-rose-300/40 bg-rose-500/5 p-4 text-center",children:[d.jsx(P6,{className:"h-5 w-5 text-rose-400"}),d.jsx("p",{className:"text-xs font-medium text-rose-400",children:"Widget non disponibile"}),d.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["ID: ",d.jsx("span",{className:"font-mono",children:this.props.widgetId})]})]}):this.props.children}}const XBe={it:l1,en:Oi};function QBe(){const{data:e=[],isLoading:t}=qZ(),{t:n,i18n:r}=tt(),s=XBe[r.language]??l1;return d.jsxs(Zn,{className:"col-span-2 border-none bg-background/50 backdrop-blur-sm",children:[d.jsx(Tr,{children:d.jsx(Wr,{className:"text-lg font-semibold",children:n("dashboard.recentActivity.title")})}),d.jsx(Xn,{children:d.jsxs("div",{className:"space-y-8",children:[t?d.jsx("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:d.jsx("p",{className:"text-sm text-muted-foreground",children:n("dashboard.recentActivity.loading")})}):e.map(i=>d.jsxs("div",{className:"flex items-center gap-4",children:[d.jsx(mf,{className:"h-9 w-9 border border-primary/10",children:d.jsx(gf,{className:"bg-primary/5 text-primary text-xs",children:(i.user_name||i.user_email).slice(0,2).toUpperCase()})}),d.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[d.jsxs("p",{className:"text-sm leading-none text-muted-foreground",children:[d.jsx("span",{className:"font-bold text-foreground",children:i.user_name||i.user_email})," ",n(`dashboard.recentActivity.actions.${i.action}`,{defaultValue:i.action})," ",d.jsx("span",{className:"font-semibold text-primary",children:i.details?.title||i.details?.name||i.entity_slug||i.entity_id})]}),d.jsx("p",{className:"text-xs text-muted-foreground/70",children:Eg(new Date(i.created_at*1e3),{addSuffix:!0,locale:s})})]})]},i.id)),!t&&e.length===0&&d.jsx("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:d.jsx("p",{className:"text-sm text-muted-foreground",children:n("dashboard.recentActivity.empty")})})]})})]})}function JBe(){const{data:e,isLoading:t}=GZ();if(t||!e)return d.jsxs(Zn,{className:"overflow-hidden border-none bg-white/50 backdrop-blur-xl dark:bg-neutral-900/50",children:[d.jsx(Tr,{children:d.jsx(Wr,{className:"text-sm font-medium",children:"System Health"})}),d.jsx(Xn,{children:d.jsx("div",{className:"h-[120px] w-full animate-pulse rounded-lg bg-neutral-200 dark:bg-neutral-800"})})]});const n=e.status==="warning";return d.jsxs(Zn,{className:"overflow-hidden border-none bg-white/50 backdrop-blur-xl dark:bg-neutral-900/50 shadow-sm transition-all hover:shadow-md",children:[d.jsxs(Tr,{className:"flex flex-row items-center justify-between pb-2 space-y-0",children:[d.jsxs(Wr,{className:"text-sm font-medium flex items-center gap-2",children:[n?d.jsx(Nne,{className:"size-4 text-amber-500"}):d.jsx(_ne,{className:"size-4 text-emerald-500"}),"System Health"]}),d.jsx("div",{className:ie("px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider",n?"bg-amber-100 text-amber-700 dark:bg-amber-500/10 dark:text-amber-400":"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400"),children:e.status})]}),d.jsxs(Xn,{className:"space-y-6",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between text-xs",children:[d.jsxs("div",{className:"flex items-center gap-2 text-neutral-500 dark:text-neutral-400",children:[d.jsx(O6,{className:"size-3"}),d.jsx("span",{children:"D1 Monthly Requests"})]}),d.jsxs("span",{className:"font-medium text-neutral-900 dark:text-neutral-100",children:[e.database.requests30d.toLocaleString()," / ",(e.database.limit/1e6).toFixed(0),"M"]})]}),d.jsx(Sp,{value:e.database.percentage,className:"h-1.5",indicatorClassName:ie(e.database.percentage>80?"bg-amber-500":"bg-emerald-500")})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between text-xs",children:[d.jsxs("div",{className:"flex items-center gap-2 text-neutral-500 dark:text-neutral-400",children:[d.jsx(Mee,{className:"size-3"}),d.jsx("span",{children:"R2 Storage Used"})]}),d.jsxs("span",{className:"font-medium text-neutral-900 dark:text-neutral-100",children:[(e.storage.used/(1024*1024)).toFixed(1)," MB / ",(e.storage.limit/(1024*1024*1024)).toFixed(0)," GB"]})]}),d.jsx(Sp,{value:e.storage.percentage,className:"h-1.5",indicatorClassName:ie(e.storage.percentage>80?"bg-amber-500":"bg-emerald-500")})]}),d.jsxs("p",{className:"text-[10px] text-neutral-400 dark:text-neutral-500 pt-2 border-t border-neutral-100 dark:border-neutral-800",children:["Last check: ",new Date(e.lastUpdate*1e3).toLocaleTimeString()]})]})]})}function eHe(){const{t:e}=tt(),{data:t=[],isLoading:n}=KBe();if(n)return d.jsxs(Zn,{className:"overflow-hidden border-none bg-white/50 backdrop-blur-xl dark:bg-neutral-900/50",children:[d.jsx(Tr,{children:d.jsx(Wr,{className:"text-sm font-medium",children:"Content Pulse"})}),d.jsx(Xn,{children:d.jsx("div",{className:"space-y-4",children:[1,2,3].map(i=>d.jsx("div",{className:"h-10 w-full animate-pulse rounded-lg bg-neutral-200 dark:bg-neutral-800"},i))})})]});const r=[...t].sort((i,o)=>o.count-i.count),s=r.reduce((i,o)=>i+o.count,0);return d.jsxs(Zn,{className:"overflow-hidden border-none bg-white/50 backdrop-blur-xl dark:bg-neutral-900/50 shadow-sm transition-all hover:shadow-md",children:[d.jsxs(Tr,{className:"flex flex-row items-center justify-between pb-4 space-y-0",children:[d.jsxs(Wr,{className:"text-sm font-medium flex items-center gap-2",children:[d.jsx(ic,{className:"size-4 text-emerald-500"}),"Content Pulse"]}),d.jsx(rv,{className:"size-4 text-neutral-400"})]}),d.jsxs(Xn,{className:"",children:[d.jsx(ml,{className:"h-[260px] pr-4",children:d.jsx("div",{className:"space-y-5",children:r.length===0?d.jsx("p",{className:"text-xs text-neutral-500 text-center py-4",children:e("dashboard.contentPulse.noContent")}):r.map(i=>{const o=s>0?i.count/s*100:0;return d.jsxs("div",{className:"group space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between text-xs",children:[d.jsx(Ns,{to:`/content/${i.slug}`,className:"font-medium text-neutral-700 dark:text-neutral-300 hover:text-emerald-600 dark:hover:text-emerald-400 transition-colors",children:i.label}),d.jsxs("span",{className:"text-neutral-500 tabular-nums",children:[i.count," entries"]})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(Sp,{value:o,className:"h-1.5 flex-1",indicatorClassName:"bg-emerald-500/80 dark:bg-emerald-400/80"}),d.jsxs("span",{className:"text-[10px] text-neutral-400 w-8 text-right font-mono",children:[Math.round(o),"%"]})]})]},i.slug)})})}),d.jsxs("div",{className:"mt-6 pt-4 border-t border-neutral-100 dark:border-neutral-800 flex justify-between items-center",children:[d.jsx("span",{className:"text-[10px] text-neutral-400 uppercase tracking-tighter font-bold",children:e("dashboard.contentPulse.totalDistribution")}),d.jsxs("span",{className:"text-[10px] font-mono font-bold text-neutral-500",children:[s," items"]})]})]})]})}function tHe(){return d.jsxs(Zn,{className:"relative overflow-hidden border-none bg-primary/5 text-primary-foreground",children:[d.jsx("div",{className:"absolute -right-8 -top-8 h-32 w-32 rounded-full bg-primary/20 blur-3xl"}),d.jsx(Tr,{className:"relative flex flex-row items-center justify-between pb-2 text-foreground",children:d.jsxs(Wr,{className:"flex items-center gap-2 text-lg font-semibold",children:[d.jsx(Ine,{className:"h-5 w-5 text-primary"}),"Beech AI Insights"]})}),d.jsxs(Xn,{className:"relative space-y-4 text-foreground",children:[d.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Ho notato che hai creato molti contenuti nella categoria ",d.jsx("span",{className:"font-semibold text-foreground",children:'"Blog"'})," ma pochi hanno una meta description ottimizzata per la SEO."]}),d.jsxs("div",{className:"rounded-xl bg-background/50 p-3 text-sm",children:[d.jsx("p",{className:"font-medium",children:"Suggerimento:"}),d.jsx("p",{className:"text-muted-foreground",children:"Posso generare automaticamente delle descrizioni SEO per i tuoi ultimi 5 articoli."})]}),d.jsxs("button",{className:"group flex items-center gap-1 text-sm font-semibold text-primary transition-all hover:gap-2",children:["Ottimizza ora",d.jsx(MJ,{className:"h-4 w-4"})]})]})]})}function nHe({onAction:e}){const t=[{id:"new-entry",label:"Nuovo Contenuto",icon:gee,color:"text-emerald-500"},{id:"media",label:"Carica Media",icon:Tg,color:"text-blue-500"},{id:"collections",label:"Gestisci Collezioni",icon:rv,color:"text-amber-500"},{id:"settings",label:"Configurazione",icon:Ag,color:"text-slate-500"}];return d.jsxs(Zn,{className:"border-none bg-background/50 backdrop-blur-sm",children:[d.jsx(Tr,{children:d.jsx(Wr,{className:"text-lg font-semibold",children:"Azioni Rapide"})}),d.jsx(Xn,{className:"grid grid-cols-2 gap-4",children:t.map(n=>d.jsxs(Oe,{variant:"outline",className:"flex h-24 flex-col items-center justify-center gap-2 border-none bg-background/40 transition-all hover:bg-background/80 hover:scale-105",onClick:()=>e(n.id),children:[d.jsx(n.icon,{className:`h-6 w-6 ${n.color}`}),d.jsx("span",{className:"text-xs font-medium",children:n.label})]},n.id))})]})}const rHe={emerald:{icon:"from-emerald-500/20 to-emerald-400/10 text-emerald-600 dark:text-emerald-400",badge:""},blue:{icon:"from-blue-500/20 to-blue-400/10 text-blue-600 dark:text-blue-400",badge:""},violet:{icon:"from-violet-500/20 to-violet-400/10 text-violet-600 dark:text-violet-400",badge:""},amber:{icon:"from-amber-500/20 to-amber-400/10 text-amber-600 dark:text-amber-400",badge:""},rose:{icon:"from-rose-500/20 to-rose-400/10 text-rose-600 dark:text-rose-400",badge:""}};function sHe({title:e,value:t,icon:n,description:r,trend:s,accent:i="emerald"}){const o=rHe[i];return d.jsx("div",{className:ie("h-full w-full flex flex-col","rounded-2xl border border-neutral-200/80 bg-white/75 backdrop-blur-md p-5","shadow-[0_1px_3px_0_rgb(0,0,0,0.05),0_1px_2px_-1px_rgb(0,0,0,0.04)]","transition-all duration-200 hover:shadow-[0_4px_12px_0_rgb(0,0,0,0.08)]","hover:border-neutral-300/80","dark:border-neutral-700/50 dark:bg-neutral-900/65 dark:hover:border-neutral-600/60"),children:d.jsxs("div",{className:"flex items-start justify-between gap-3",children:[d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:e}),d.jsx("p",{className:"text-2xl font-bold tracking-tight text-foreground tabular-nums",children:t}),r&&d.jsx("p",{className:"mt-1.5 text-xs text-muted-foreground leading-snug",children:r}),s&&d.jsxs("div",{className:ie("mt-2 inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-semibold",s.isPositive?"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-400":"bg-rose-100 text-rose-700 dark:bg-rose-500/15 dark:text-rose-400"),children:[s.isPositive?d.jsx(L6,{className:"size-3"}):d.jsx(Wne,{className:"size-3"}),s.isPositive?"+":"-",s.value,"%"]})]}),d.jsx("div",{className:ie("shrink-0 rounded-xl bg-gradient-to-br p-2.5",o.icon),children:d.jsx(n,{size:20})})]})})}function $p({icon:e,title:t,description:n}){return d.jsxs("div",{className:"flex h-full min-h-[80px] flex-col items-center justify-center gap-2 text-center",children:[d.jsx(e,{className:"size-8 text-muted-foreground/40"}),d.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:t}),n&&d.jsx("p",{className:"text-xs text-muted-foreground/70",children:n})]})}function $f({message:e,onRetry:t}){const{t:n}=tt();return d.jsxs("div",{className:"flex h-full min-h-[80px] flex-col items-center justify-center gap-3 text-center",children:[d.jsx(A6,{className:"size-8 text-destructive/60"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:e??n("dashboard.widgets.error.message")}),t&&d.jsx(Oe,{variant:"outline",size:"sm",onClick:t,children:n("dashboard.widgets.error.retry")})]})}const iHe={it:l1,en:Oi};function sz(e){return e==="published"?"bg-emerald-50 text-emerald-700 border-emerald-200/80 dark:bg-emerald-500/10 dark:text-emerald-400 dark:border-emerald-800/60":e==="draft"?"bg-amber-50 text-amber-700 border-amber-200/80 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-800/60":"bg-neutral-100 text-neutral-600 border-neutral-200/80 dark:bg-neutral-800 dark:text-neutral-400"}function sC(e){const t=e.data;for(const n of Object.keys(t)){const r=t[n];if(typeof r=="string"&&r.trim())return r}return e.id}const oHe=/\.(jpg|jpeg|png|webp|gif|avif|svg)(\?.*)?$/i;function aHe(e){for(const t of Object.values(e.data))if(typeof t=="string"&&(t.startsWith("http")||oHe.test(t)))return t;return null}function v6({seedSlug:e,variant:t="list"}){const{t:n,i18n:r}=tt(),s=iHe[r.language]??Oi;function i(p){return p?Eg(new Date(p*1e3),{addSuffix:!0,locale:s}):"—"}const{data:o,isLoading:a,isError:l,refetch:u}=Ir({queryKey:["widget","recent-content",e],queryFn:async()=>{const m=(await Gt.get(`/content/${e}`,{params:{limit:5,sortBy:"updated_at",sortDir:"desc"}})).data;return Array.isArray(m)?m:m.items},staleTime:180*1e3}),h=d.jsx(Ns,{to:`/content/${e}`,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:n("dashboard.widgets.recentContent.viewAll")});return a?d.jsx(Un,{title:n("dashboard.widgets.recentContent.title"),icon:Id,action:h,children:d.jsx("div",{className:"space-y-3",children:Array.from({length:4}).map((p,m)=>d.jsx(kr,{className:"h-9 w-full rounded-lg animate-pulse"},m))})}):l?d.jsx(Un,{title:n("dashboard.widgets.recentContent.title"),icon:Id,action:h,children:d.jsx($f,{onRetry:()=>u()})}):o?.length?t==="cards"?d.jsx(Un,{title:n("dashboard.widgets.recentContent.title"),icon:Id,action:h,children:d.jsx(ml,{className:"h-full",children:d.jsx("div",{className:"grid grid-cols-2 gap-3 pr-2",children:o.map(p=>{const m=aHe(p);return d.jsxs(Ns,{to:`/content/${e}/${p.id}`,className:"flex flex-col rounded-xl border border-border/60 bg-card overflow-hidden shadow-sm hover:shadow-md transition-shadow",children:[m?d.jsx("img",{src:m,alt:"",className:"h-28 w-full object-cover shrink-0"}):d.jsx("div",{className:"h-28 shrink-0 bg-muted flex items-center justify-center",children:d.jsx(m9,{className:"size-7 text-muted-foreground/30"})}),d.jsxs("div",{className:"flex flex-col flex-1 p-2",children:[d.jsx("p",{className:"text-xs font-medium line-clamp-2 flex-1",children:sC(p)}),d.jsxs("div",{className:"flex items-center justify-between gap-1 mt-auto pt-2",children:[d.jsx("span",{className:ie("text-[10px] px-1.5 py-0.5 rounded-full font-semibold border",sz(p.status)),children:p.status}),d.jsx("span",{className:"text-[10px] text-muted-foreground",children:i(p.updated_at)})]})]})]},p.id)})})})}):d.jsx(Un,{title:n("dashboard.widgets.recentContent.title"),icon:Id,action:h,children:d.jsx("ul",{className:"space-y-0.5",children:o.map(p=>d.jsxs("li",{className:"group rounded-lg px-3 py-2.5 hover:bg-muted/50 transition-colors",children:[d.jsx(Ns,{to:`/content/${e}/${p.id}`,className:"text-sm font-medium truncate block hover:underline decoration-primary/30 mb-1 sm:hidden",children:sC(p)}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Ns,{to:`/content/${e}/${p.id}`,className:"text-sm font-medium truncate flex-1 hover:underline decoration-primary/30 hidden sm:block",children:sC(p)}),d.jsx(gi,{className:ie("shrink-0 text-[10px] border",sz(p.status)),variant:"outline",children:p.status}),d.jsx("span",{className:"text-xs text-muted-foreground shrink-0 tabular-nums ml-auto sm:ml-0",children:i(p.updated_at)})]})]},p.id))})}):d.jsx(Un,{title:n("dashboard.widgets.recentContent.title"),icon:Id,children:d.jsx($p,{icon:m9,title:n("dashboard.widgets.recentContent.noContent"),description:n("dashboard.widgets.recentContent.noContentDesc")})})}function lHe(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")}function x6({seeds:e,variant:t="minimal",title:n,placeholder:r,onCreated:s}){const{t:i}=tt(),[o,a]=w.useState(""),[l,u]=w.useState(e[0]?.slug??""),[h,p]=w.useState(!1),[m,b]=w.useState(null),y=wi(),x=pa(),S=e.find(R=>R.slug===l),C=S?.displayNameAlias??"title",N=i(`dashboard.widgets.quickDraft.fieldLabels.${C}`,{defaultValue:S?.displayNameLabel??C}),{mutate:M,isPending:_}=Fs({mutationFn:async()=>({id:(await Gt.post(`/content/${l}`,{status:"draft",[C]:o})).data.id,seedSlug:l}),onSuccess:({id:R,seedSlug:D})=>{y.invalidateQueries({queryKey:["content",D]}),y.invalidateQueries({queryKey:["widget","recent-content",D]}),y.invalidateQueries({queryKey:["widget","pending-drafts",D]}),y.invalidateQueries({queryKey:si.activity()}),s?.(R,D),p(!0),setTimeout(()=>{x(`/content/${D}/${R}`)},800)},onError:R=>{b(R.message||i("dashboard.widgets.quickDraft.errorCreating"))}});function T(R){R.preventDefault(),b(null),!(!o.trim()||!l)&&M()}return h?d.jsx(Un,{children:d.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-emerald-600 dark:text-emerald-400",children:[d.jsx(_g,{className:"size-5"}),d.jsx("span",{className:"text-sm font-semibold",children:i("dashboard.widgets.quickDraft.draftCreated")})]})}):d.jsx(Un,{icon:Hee,title:t==="minimal"?n||i("dashboard.widgets.quickDraft.title"):void 0,children:d.jsxs("form",{onSubmit:T,className:"space-y-3",children:[t==="expanded"&&d.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:n||i("dashboard.widgets.quickDraft.createDraft")}),d.jsxs("div",{className:ie("flex gap-2",t==="expanded"?"flex-col":"flex-col sm:flex-row sm:items-center"),children:[d.jsxs("div",{className:"flex-1 space-y-1",children:[t==="expanded"&&d.jsx("label",{className:"text-xs text-muted-foreground",children:N}),d.jsx(Xt,{placeholder:r||`${N}…`,value:o,onChange:R=>a(R.target.value),className:"h-8 text-sm"}),t==="expanded"&&o&&d.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:["/",lHe(o)]})]}),d.jsxs("div",{className:ie("flex gap-2",t==="minimal"?"items-center sm:contents":""),children:[d.jsxs("div",{className:ie(t==="expanded"?"w-full space-y-1":"flex-1 min-w-0 sm:w-28 sm:shrink-0 sm:flex-none"),children:[t==="expanded"&&d.jsx("label",{className:"text-xs text-muted-foreground",children:i("dashboard.widgets.quickDraft.type")}),d.jsxs(Rr,{value:l,onValueChange:u,children:[d.jsx(Or,{className:"h-8 text-sm w-full overflow-hidden",children:d.jsx("span",{className:"truncate block",children:e.find(R=>R.slug===l)?.label??i("dashboard.widgets.quickDraft.type")})}),d.jsx(Dr,{children:e.map(R=>d.jsx(or,{value:R.slug,children:R.label},R.slug))})]})]}),t==="minimal"&&d.jsx(Oe,{type:"submit",size:"sm",disabled:_||!o.trim(),className:"shrink-0 h-8",children:_?"…":i("dashboard.widgets.quickDraft.create")})]})]}),t==="expanded"&&d.jsx(Oe,{type:"submit",size:"sm",disabled:_||!o.trim(),className:"w-full h-8",children:i(_?"dashboard.widgets.quickDraft.creating":"dashboard.widgets.quickDraft.createDraft")}),m&&d.jsx("p",{className:"text-xs text-destructive",children:m})]})})}const cHe={it:l1,en:Oi};function uHe(e){for(const t of Object.values(e.data))if(typeof t=="string"&&t.trim())return t;return e.id}function w6({seedSlug:e,variant:t="list",onPublish:n}){const{t:r,i18n:s}=tt(),i=cHe[s.language]??Oi,o=wi(),{data:a,isLoading:l,isError:u,refetch:h}=Ir({queryKey:["widget","pending-drafts",e],queryFn:async()=>{const y=(await Gt.get(`/content/${e}`,{params:{has_pending_draft:1,limit:10}})).data;return Array.isArray(y)?y:y.items},staleTime:180*1e3}),p=Fs({mutationFn:async b=>(await Gt.post(`/content/${e}/${b}/draft/publish`),b),onSuccess:()=>{o.invalidateQueries({queryKey:["widget","pending-drafts",e]}),o.invalidateQueries({queryKey:["widget","recent-content",e]}),o.invalidateQueries({queryKey:si.activity()})}}),m=a?.length?d.jsx(gi,{className:"bg-amber-100 text-amber-700 border-amber-200/80 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-800/60 text-xs tabular-nums",variant:"outline",children:a.length}):null;return l?d.jsx(Un,{title:r("dashboard.widgets.pendingDrafts.title"),icon:yh,children:d.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((b,y)=>d.jsx(kr,{className:"h-10 w-full animate-pulse"},y))})}):u?d.jsx(Un,{title:r("dashboard.widgets.pendingDrafts.title"),icon:yh,children:d.jsx($f,{onRetry:()=>h()})}):t==="counter"?d.jsx(Un,{title:r("dashboard.widgets.pendingDrafts.title"),icon:yh,children:d.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 h-full text-center",children:[d.jsx("span",{className:"text-5xl font-bold tabular-nums",children:a?.length??0}),d.jsx("p",{className:"text-sm text-muted-foreground",children:r("dashboard.widgets.pendingDrafts.pendingCount")}),d.jsx(Ns,{to:`/content/${e}?status=draft`,children:d.jsx(Oe,{variant:"outline",size:"sm",children:r("dashboard.widgets.pendingDrafts.viewAll")})})]})}):a?.length?d.jsx(Un,{title:r("dashboard.widgets.pendingDrafts.title"),icon:yh,action:d.jsxs("div",{className:"flex items-center gap-2",children:[m,d.jsx(Ns,{to:`/content/${e}?status=draft`,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:r("dashboard.widgets.pendingDrafts.viewAll")})]}),children:d.jsx(ml,{className:"h-[260px]",children:d.jsx("ul",{className:"space-y-1 pr-2",children:a.map(b=>d.jsxs("li",{className:"rounded-lg px-2 py-2 hover:bg-muted/40 transition-colors group",children:[d.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d.jsx(Ns,{to:`/content/${e}/${b.id}`,className:"flex-1 text-sm font-medium truncate hover:underline text-foreground decoration-primary/30 min-w-0",children:uHe(b)}),d.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0 tabular-nums hidden sm:inline",children:b.updated_at?Eg(new Date(b.updated_at*1e3),{addSuffix:!0,locale:i}):"—"}),d.jsxs(Oe,{size:"sm",variant:"default",className:"h-6 text-xs px-2 shrink-0 gap-1 opacity-70 group-hover:opacity-100 transition-opacity hidden sm:flex",disabled:p.isPending,onClick:()=>{p.mutate(b.id),n?.(b.id)},children:[d.jsx(b9,{className:"size-3"}),r("dashboard.widgets.pendingDrafts.publish")]})]}),d.jsxs("div",{className:"flex items-center justify-between gap-2 mt-1 sm:hidden",children:[d.jsx("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:b.updated_at?Eg(new Date(b.updated_at*1e3),{addSuffix:!0,locale:i}):"—"}),d.jsxs(Oe,{size:"sm",variant:"default",className:"h-6 text-xs px-2 shrink-0 gap-1",disabled:p.isPending,onClick:()=>{p.mutate(b.id),n?.(b.id)},children:[d.jsx(b9,{className:"size-3"}),r("dashboard.widgets.pendingDrafts.publish")]})]})]},b.id))})})}):d.jsx(Un,{title:r("dashboard.widgets.pendingDrafts.title"),icon:yh,children:d.jsx($p,{icon:yh,title:r("dashboard.widgets.pendingDrafts.noPending")})})}function Yx({variant:e="single"}){const{t}=tt(),{data:n,isLoading:r,isError:s,refetch:i}=E8();if(r)return d.jsx(Un,{children:d.jsx("div",{className:"flex gap-3 h-full",children:Array.from({length:e==="trio"?3:1}).map((p,m)=>d.jsx(kr,{className:"flex-1 h-16 animate-pulse rounded-lg"},m))})});if(s)return d.jsx(Un,{children:d.jsx($f,{onRetry:()=>i()})});const{total:o,today:a,week:l,month:u}=n??{total:0,today:0,week:0,month:0};if(e==="trio"){const p=[{label:t("dashboard.widgets.publicationStats.today"),value:a,color:"text-blue-600 dark:text-blue-400",border:"border-l-blue-400/60",bg:"bg-blue-50/60 dark:bg-blue-500/10"},{label:t("dashboard.widgets.publicationStats.week"),value:l,color:"text-violet-600 dark:text-violet-400",border:"border-l-violet-400/60",bg:"bg-violet-50/60 dark:bg-violet-500/10"},{label:t("dashboard.widgets.publicationStats.month"),value:u,color:"text-emerald-600 dark:text-emerald-400",border:"border-l-emerald-400/60",bg:"bg-emerald-50/60 dark:bg-emerald-500/10"}];return d.jsx(Un,{children:d.jsx("div",{className:"flex gap-2 overflow-x-auto pb-0.5 sm:grid sm:grid-cols-3 sm:overflow-visible h-full",children:p.map(({label:m,value:b,color:y,border:x,bg:S})=>d.jsxs("div",{className:ie("flex flex-col justify-center rounded-lg border-l-2 px-3 py-2 gap-0.5","min-w-[80px] shrink-0 sm:min-w-0 sm:shrink",x,S),children:[d.jsx("span",{className:ie("text-xl font-bold tabular-nums leading-none sm:text-2xl",y),children:b}),d.jsx("span",{className:"text-[10px] font-medium text-muted-foreground whitespace-nowrap",children:m})]},m))})})}const h=a>0;return d.jsx(Un,{children:d.jsxs("div",{className:"flex flex-col justify-center h-full gap-1",children:[d.jsxs("div",{className:"flex items-end gap-2",children:[d.jsx("span",{className:"text-4xl font-bold tabular-nums",children:o.toLocaleString()}),d.jsxs("span",{className:ie("mb-1 flex items-center gap-0.5 text-sm font-semibold",h?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"),children:[d.jsx(L6,{className:ie("size-4",!h&&"opacity-20")}),a]})]}),d.jsx("p",{className:"text-sm text-muted-foreground",children:t("dashboard.widgets.publicationStats.totalContent")})]})})}Yx.displayName="PublicationStatsWidget";function S6({variant:e="badge"}){const{data:t,isLoading:n,isError:r,refetch:s,dataUpdatedAt:i}=GZ(),{data:o}=N8(),{data:a}=E8(),l=t?.status==="healthy"||t?.status==="warning";if(n)return d.jsx(Un,{children:d.jsx(kr,{className:"h-10 w-full animate-pulse"})});if(r)return d.jsx(Un,{children:d.jsx($f,{onRetry:()=>s()})});const u=l??!1,h=i?new Date(i).toLocaleTimeString("it-IT",{hour:"2-digit",minute:"2-digit"}):"—";if(e==="pill-row"){const p=[{label:"API",ok:u},{label:"Storage",ok:!!o},{label:"DB",ok:typeof a?.total=="number"&&a.total>=0}];return d.jsx(Un,{children:d.jsx("div",{className:"flex flex-wrap items-center gap-2 h-full",children:p.map(({label:m,ok:b})=>d.jsxs(gi,{className:ie("text-xs gap-1.5 px-2.5 py-1",b?"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400 border-emerald-200/80 dark:border-emerald-800/60":"bg-red-50 text-red-700 dark:bg-red-500/10 dark:text-red-400 border-red-200/80 dark:border-red-800/60"),variant:"outline",children:[d.jsx("span",{className:ie("size-1.5 rounded-full",b?"bg-emerald-500 shadow-[0_0_4px_rgba(34,197,94,0.6)]":"bg-red-500")}),m]},m))})})}return d.jsx(Un,{children:d.jsxs("div",{className:"flex items-center gap-3 h-full",children:[d.jsxs("div",{className:"relative shrink-0",children:[d.jsx("span",{className:ie("block size-3 rounded-full",u?"bg-emerald-500":"bg-red-500")}),u&&d.jsx("span",{className:"absolute inset-0 rounded-full bg-emerald-500 animate-ping opacity-60"})]}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("p",{className:"text-sm font-semibold",children:u?"Site online":"Error"}),d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Verified at ",h]})]}),u?d.jsx(_z,{className:"size-4 text-emerald-500 shrink-0"}):d.jsx(fre,{className:"size-4 text-red-500 shrink-0"})]})})}const dHe=10*1024*1024*1024;function Oy(e){return(e/1024/1024/1024).toFixed(1)}function fHe(e){return e>85?"#ef4444":e>60?"#eab308":"#22c55e"}function hHe({pct:e,usedLabel:t}){const o=2*Math.PI*38,a=o-e/100*o,l=fHe(e);return d.jsxs("svg",{width:"104",height:"104",viewBox:"0 0 104 104","aria-hidden":!0,children:[d.jsx("circle",{cx:52,cy:52,r:38,fill:"none",stroke:"currentColor",strokeWidth:8,className:"text-muted-foreground/15 dark:text-muted-foreground/30"}),d.jsx("circle",{cx:52,cy:52,r:38,fill:"none",stroke:l,strokeWidth:8,strokeLinecap:"round",strokeDasharray:o,strokeDashoffset:a,transform:"rotate(-90 52 52)",className:"transition-all duration-1000 ease-in-out",style:{filter:`drop-shadow(0 0 4px ${l}60)`}}),d.jsxs("text",{x:52,y:48,textAnchor:"middle",dominantBaseline:"central",fontSize:"15",fontWeight:"700",fill:l,className:"tabular-nums",children:[e,"%"]}),d.jsx("text",{x:52,y:64,textAnchor:"middle",dominantBaseline:"central",fontSize:"9",fontWeight:"500",className:"fill-muted-foreground",fill:"currentColor",style:{color:"var(--muted-foreground)"},children:t})]})}function C6({variant:e="bar",totalBytes:t=dHe}){const{t:n}=tt(),{data:r,isLoading:s,isError:i,refetch:o}=N8();if(s)return d.jsx(Un,{children:d.jsx(kr,{className:"h-12 w-full animate-pulse"})});if(i)return d.jsx(Un,{children:d.jsx($f,{onRetry:()=>o()})});const a=r?r.storage.used*1024*1024:0,l=Math.min(100,Math.round(a/t*100));if(!r)return d.jsx(Un,{children:d.jsx($p,{icon:D6,title:n("dashboard.widgets.storage.noData")})});if(e==="gauge")return d.jsx(Un,{children:d.jsxs("div",{className:"flex flex-col items-center gap-2 h-full w-full xs:flex-row sm:flex-row sm:items-center sm:gap-3",children:[d.jsx("div",{className:"shrink-0",children:d.jsx(hHe,{pct:l,usedLabel:n("dashboard.widgets.storage.used")})}),d.jsxs("div",{className:"flex-1 min-w-0 text-center sm:text-left",children:[d.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:n("dashboard.widgets.storage.title")}),d.jsxs("p",{className:"text-base font-bold text-foreground tabular-nums leading-tight",children:[Oy(a)," ",d.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"GB"})]}),d.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:n("dashboard.widgets.storage.total",{total:Oy(t)})})]})]})});const u=`${Oy(a)} GB di ${Oy(t)} GB`;return d.jsx(Un,{children:d.jsxs("div",{className:"flex flex-col justify-center gap-2 h-full",children:[d.jsxs("div",{className:"flex items-center justify-between text-xs",children:[d.jsx("span",{className:"text-muted-foreground font-medium",children:n("dashboard.widgets.storage.title")}),d.jsxs("span",{className:"font-bold tabular-nums",children:[l,"%"]})]}),d.jsx(Sp,{value:l,className:"h-1.5"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:u})]})})}function pHe(e){for(const t of Object.values(e.data))if(typeof t=="string"&&(t.startsWith("http")||t.startsWith("/")))return t;return null}function mHe(e){for(const t of Object.values(e.data))if(typeof t=="string"&&t.trim()&&!t.startsWith("http")&&!t.startsWith("/"))return t;return e.id}function k6({seedSlug:e="",variant:t="grid",onOpen:n}){const[r,s]=w.useState(t),{t:i}=tt(),o=wi(),a=Ir({queryKey:["widget","media-library"],queryFn:async()=>(await Gt.get("/content/stats/media-library",{params:{limit:12}})).data.items,staleTime:180*1e3,enabled:r==="grid"}),l=Ir({queryKey:["widget","media-gallery",e,"unused"],queryFn:async()=>(await Gt.get("/content/stats/unused-media",{params:{seedSlug:e,limit:12}})).data.items,staleTime:0,enabled:r==="unused"&&!!e}),u=Fs({mutationFn:async y=>{await Gt.delete(`/${encodeURIComponent(y)}`)},onSuccess:()=>{o.invalidateQueries({queryKey:["widget","media-library"]})}}),h=Fs({mutationFn:async y=>{await Gt.delete(`/content/${e}/${y}`)},onSuccess:()=>{o.invalidateQueries({queryKey:["widget","media-gallery",e]})}}),p=r==="grid"?a.isLoading:l.isLoading,m=r==="grid"?a.isError:l.isError,b=r==="grid"?a.refetch:l.refetch;return d.jsxs("div",{className:"h-full w-full flex flex-col rounded-xl border border-neutral-200/60 bg-background/50 backdrop-blur-sm shadow-sm dark:border-neutral-800/60 dark:bg-neutral-900/40 overflow-hidden",children:[d.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border/40 shrink-0",children:[d.jsxs("span",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[d.jsx(em,{className:"size-4 text-muted-foreground"}),i("dashboard.widgets.mediaGallery.title")]}),d.jsxs("div",{className:"flex items-center gap-0.5 bg-muted/50 p-0.5 rounded-md border border-border/50",children:[d.jsx(Oe,{variant:r==="grid"?"secondary":"ghost",size:"sm",className:"h-6 px-2 text-[10px]",onClick:()=>s("grid"),children:i("dashboard.widgets.mediaGallery.all")}),d.jsx(Oe,{variant:r==="unused"?"secondary":"ghost",size:"sm",className:"h-6 px-2 text-[10px]",onClick:()=>s("unused"),children:i("dashboard.widgets.mediaGallery.unused")})]})]}),d.jsx("div",{className:"flex-1 p-3 overflow-y-auto min-h-0",children:p?d.jsx("div",{className:"grid grid-cols-4 gap-2",children:Array.from({length:8}).map((y,x)=>d.jsx(kr,{className:"aspect-square rounded-md animate-pulse"},x))}):m?d.jsx($f,{onRetry:()=>b()}):r==="grid"?a.data?.length?d.jsx("div",{className:"grid grid-cols-4 gap-2",children:a.data.map(y=>{const x=u.isPending&&u.variables===y.key,S=y.mime_type.startsWith("image/");return d.jsxs("div",{className:ie("group relative aspect-square overflow-hidden rounded-lg bg-muted/50 border border-border/50 cursor-pointer transition-all hover:ring-2 hover:ring-primary/20",x&&"opacity-50 grayscale pointer-events-none"),onClick:()=>n?.(y.key),children:[S?d.jsx("img",{src:y.url,alt:y.filename,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-110"}):d.jsx("div",{className:"flex h-full w-full items-center justify-center",children:d.jsx(em,{className:"size-6 text-muted-foreground/30"})}),d.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent p-2 pt-6 opacity-0 group-hover:opacity-100 transition-opacity",children:d.jsx("p",{className:"text-[10px] text-white font-medium truncate",children:y.filename})})]},y.key)})}):d.jsx($p,{icon:em,title:i("dashboard.widgets.mediaGallery.emptyTitle"),description:i("dashboard.widgets.mediaGallery.emptyDesc")}):l.data?.length?d.jsx("div",{className:"grid grid-cols-4 gap-2",children:l.data.map(y=>{const x=pHe(y),S=mHe(y),C=h.isPending&&h.variables===y.id;return d.jsxs("div",{className:ie("group relative aspect-square overflow-hidden rounded-lg bg-muted/50 border border-border/50 cursor-pointer transition-all hover:ring-2 hover:ring-primary/20",C&&"opacity-50 grayscale pointer-events-none"),children:[x?d.jsx("img",{src:x,alt:S,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-110"}):d.jsx("div",{className:"flex h-full w-full items-center justify-center",children:d.jsx(em,{className:"size-6 text-muted-foreground/30"})}),d.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent p-2 pt-6 opacity-0 group-hover:opacity-100 transition-opacity",children:[d.jsx("p",{className:"text-[10px] text-white font-medium truncate mb-1.5",children:S}),d.jsxs(Oe,{variant:"destructive",size:"sm",className:"h-6 w-full text-[10px] gap-1 px-1.5 bg-red-600 hover:bg-red-500 border-none",onClick:N=>{N.stopPropagation(),confirm(`Eliminare definitivamente ${S}?`)&&h.mutate(y.id)},children:[d.jsx(La,{className:"size-3"})," Elimina"]})]})]},y.id)})}):d.jsx($p,{icon:em,title:i("dashboard.widgets.mediaGallery.allInUseTitle"),description:i("dashboard.widgets.mediaGallery.allInUseDesc")})})]})}const gHe={it:l1,en:Oi},bHe={create:Hi,update:I6,delete:La,upload:xm},yHe={create:"bg-emerald-100 text-emerald-600 dark:bg-emerald-500/15 dark:text-emerald-400",update:"bg-blue-100 text-blue-600 dark:bg-blue-500/15 dark:text-blue-400",delete:"bg-red-100 text-red-600 dark:bg-red-500/15 dark:text-red-400",upload:"bg-violet-100 text-violet-600 dark:bg-violet-500/15 dark:text-violet-400"};function iz(e,t,n="User"){return e||t||n}function vHe(e,t){const n=e||t;return n?n.slice(0,2).toUpperCase():"?"}function E6({seedSlug:e,variant:t="feed"}){const{t:n,i18n:r}=tt(),s=gHe[r.language]??Oi;function i(h){return h?Eg(new Date(h*1e3),{addSuffix:!0,locale:s}):"—"}const{data:o,isLoading:a,isError:l,refetch:u}=qZ(e);if(a)return d.jsx(Un,{title:n("dashboard.widgets.activityFeed.title"),icon:ic,children:d.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((h,p)=>d.jsxs("div",{className:"flex gap-3",children:[d.jsx(kr,{className:"size-8 shrink-0 rounded-full animate-pulse"}),d.jsx(kr,{className:"h-8 flex-1 animate-pulse"})]},p))})});if(l)return d.jsx(Un,{title:n("dashboard.widgets.activityFeed.title"),icon:ic,children:d.jsx($f,{onRetry:()=>u()})});if(!o?.length)return d.jsx(Un,{title:n("dashboard.widgets.activityFeed.title"),icon:ic,children:d.jsx($p,{icon:ic,title:n("dashboard.widgets.activityFeed.empty")})});if(t==="compact"){const h=o.slice(0,10);return d.jsx(Un,{title:n("dashboard.widgets.activityFeed.title"),icon:ic,children:d.jsx(ml,{className:"h-full",type:"auto",children:d.jsx("ul",{className:"space-y-1 pr-3",children:h.map(p=>d.jsxs("li",{className:"flex items-center gap-2",children:[d.jsxs("span",{className:"text-xs text-muted-foreground truncate flex-1",children:[d.jsx("span",{className:"font-medium text-foreground",children:iz(p.user_name,p.user_email)})," ",n(`dashboard.recentActivity.actions.${p.action}`,{defaultValue:p.action})," ",d.jsx("span",{className:"font-medium text-foreground",children:p.details?.title||p.details?.name||p.entity_slug||p.entity_id})]}),d.jsx("span",{className:"text-[10px] text-muted-foreground/60 shrink-0",children:i(p.created_at)})]},p.id))})})})}return d.jsx(Un,{title:n("dashboard.widgets.activityFeed.title"),icon:ic,children:d.jsx(ml,{className:"h-[180px]",type:"auto",children:d.jsx("ul",{className:"space-y-3 pr-3",children:o.map(h=>{const p=bHe[h.action]??ic,m=yHe[h.action]??"bg-muted text-muted-foreground";return d.jsxs("li",{className:"flex items-start gap-3 group",children:[d.jsxs("div",{className:"relative shrink-0",children:[d.jsx(mf,{className:"size-8 border border-border/60",children:d.jsx(gf,{className:"text-[10px] bg-primary/5 text-primary font-semibold",children:vHe(h.user_name,h.user_email)})}),d.jsx("span",{className:ie("absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full ring-2 ring-background",m),children:d.jsx(p,{className:"size-2.5"})})]}),d.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[d.jsxs("p",{className:"text-sm leading-snug",children:[d.jsx("span",{className:"font-semibold",children:iz(h.user_name,h.user_email)})," ",d.jsx("span",{className:"text-muted-foreground",children:n(`dashboard.recentActivity.actions.${h.action}`,{defaultValue:h.action})})," ",d.jsx("span",{className:"font-medium",children:h.details?.title||h.details?.name||h.entity_slug||h.entity_id})]}),d.jsx("p",{className:"text-xs text-muted-foreground/70",children:i(h.created_at)})]})]},h.id)})})})})}const oz="beech_setup_checklist_dismissed";function xHe({variant:e="full"}){const{t}=tt(),{data:n,isLoading:r,isError:s}=YBe(),[i,o]=w.useState(()=>localStorage.getItem(oz)==="1");if(r)return d.jsx("div",{className:"rounded-xl border bg-card px-4 py-3",children:d.jsx(kr,{className:"h-5 w-48 animate-pulse"})});if(s||!n)return null;if(n.systemTablesOk&&n.seedsCount>0&&n.contentTablesOk&&n.adminExists&&n.hasContent)return i?null:d.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-emerald-200/80 bg-emerald-50 px-4 py-2.5 dark:border-emerald-800/40 dark:bg-emerald-500/10",children:[d.jsx(_g,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400"}),d.jsx("p",{className:"flex-1 text-sm font-medium text-emerald-800 dark:text-emerald-300",children:t("dashboard.setupChecklist.allDone")}),d.jsx("button",{onClick:()=>{localStorage.setItem(oz,"1"),o(!0)},className:"text-emerald-600 hover:text-emerald-800 dark:text-emerald-400 dark:hover:text-emerald-200","aria-label":"Dismiss",children:d.jsx(ro,{className:"size-4"})})]});const l=[{done:n.systemTablesOk,label:t("dashboard.setupChecklist.systemTables"),hint:t("dashboard.setupChecklist.systemTablesHint")},{done:n.seedsCount>0,label:n.seedsCount>0?t("dashboard.setupChecklist.seeds",{count:n.seedsCount}):t("dashboard.setupChecklist.seedsNone"),action:n.seedsCount===0?{label:t("dashboard.setupChecklist.seedsAction"),href:"https://beechcms.dev/guide"}:void 0},{done:n.contentTablesOk,label:t("dashboard.setupChecklist.contentTables"),action:n.contentTablesOk?void 0:{label:"npx beech seed:load --local",command:"npx beech seed:load --local"}},{done:n.adminExists,label:t("dashboard.setupChecklist.adminAccount"),action:n.adminExists?void 0:{label:t("dashboard.setupChecklist.adminAction"),href:"/setup"}},{done:n.hasContent,label:t("dashboard.setupChecklist.firstContent"),action:!n.hasContent&&n.firstSeedSlug?{label:t("dashboard.setupChecklist.firstContentAction"),href:`/content/${n.firstSeedSlug}/new`}:void 0}],u=l.filter(h=>h.done).length;return d.jsxs("div",{className:"rounded-xl border bg-card px-4 py-3",children:[d.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[d.jsx(A6,{className:"size-4 text-amber-500"}),d.jsx("p",{className:"text-sm font-semibold",children:t("dashboard.setupChecklist.title")}),d.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[u,"/",l.length]})]}),e==="compact"?d.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1.5",children:l.map((h,p)=>d.jsx(wHe,{done:h.done,label:h.label},p))}):d.jsx("ul",{className:"space-y-2",children:l.map((h,p)=>d.jsx(SHe,{...h},p))})]})}function wHe({done:e,label:t}){return d.jsxs("span",{className:ie("flex items-center gap-1.5 text-xs",e?"text-muted-foreground line-through":"text-foreground"),children:[e?d.jsx(_g,{className:"size-3 shrink-0 text-emerald-500"}):d.jsx(R6,{className:"size-3 shrink-0 text-amber-400"}),t]})}function SHe({done:e,label:t,hint:n,action:r}){return d.jsxs("li",{className:"flex items-start gap-2.5",children:[e?d.jsx(_g,{className:"mt-0.5 size-4 shrink-0 text-emerald-500"}):d.jsx(R6,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground/50"}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:ie("text-sm",e?"text-muted-foreground line-through":"text-foreground"),children:t}),!e&&n&&d.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:n}),!e&&r&&(r.command?d.jsx("code",{className:"mt-1 inline-block rounded bg-muted px-2 py-0.5 text-xs font-mono text-foreground",children:r.command}):r.href?.startsWith("http")?d.jsxs("a",{href:r.href,target:"_blank",rel:"noopener noreferrer",className:"mt-0.5 inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[r.label,d.jsx(xc,{className:"size-3"})]}):d.jsxs(Ns,{to:r.href,className:"mt-0.5 inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[r.label,d.jsx(xc,{className:"size-3"})]}))]})]})}function CHe({instance:e,data:t}){return d.jsx(ZBe,{widgetId:e.id,children:d.jsx(kHe,{instance:e,data:t})})}function kHe({instance:e,data:t}){const{type:n,props:r}=e,{t:s}=tt();if(n==="stat"){const i=EHe(r?.statKey,t,s);return d.jsx(sHe,{...i})}return n==="recent-activity"?d.jsx(QBe,{}):n==="system-health"?d.jsx(JBe,{}):n==="content-pulse"?d.jsx(eHe,{}):n==="ai-insights"?d.jsx(tHe,{}):n==="quick-actions"?d.jsx(nHe,{onAction:i=>console.log("[BeechCMS] Quick action:",i)}):n==="recent-content"?d.jsx(v6,{seedSlug:r?.seedSlug??"",variant:r?.variant,onOpen:r?.onOpen}):n==="quick-draft"?d.jsx(x6,{seeds:r?.seeds??[],variant:r?.variant,onCreated:r?.onCreated}):n==="pending-drafts"?d.jsx(w6,{seedSlug:r?.seedSlug??"",variant:r?.variant,onPublish:r?.onPublish,onOpen:r?.onOpen}):n==="publication-stats"?d.jsx(Yx,{variant:r?.variant}):n==="site-status"?d.jsx(S6,{variant:r?.variant}):n==="storage"?d.jsx(C6,{variant:r?.variant,totalBytes:r?.totalBytes}):n==="media-gallery"?d.jsx(k6,{seedSlug:r?.seedSlug??"",variant:r?.variant,onOpen:r?.onOpen}):n==="activity-feed"?d.jsx(E6,{seedSlug:r?.seedSlug??"",variant:r?.variant,limit:r?.limit}):n==="setup-checklist"?d.jsx(xHe,{variant:r?.variant}):d.jsx("div",{className:"flex h-full min-h-[80px] items-center justify-center rounded-xl border-2 border-dashed border-muted p-4",children:d.jsxs("p",{className:"text-sm text-muted-foreground",children:[s("dashboard.widgetRegistry.unknown")," ",d.jsx("span",{className:"font-mono font-semibold",children:n})]})})}function EHe(e,t,n){const{statsData:r,cfData:s,statsLoading:i,cfLoading:o}=t||{};switch(e){case"total":return{title:n("dashboard.widgets.stat.total.title"),value:i?"...":r?.total.toLocaleString()??"0",icon:nv,description:n("dashboard.widgets.stat.total.description"),trend:r?.total?{value:Math.round(r.recent/r.total*100),isPositive:!0}:void 0};case"visitors":return{title:n("dashboard.widgets.stat.visitors.title"),value:o?"...":s?.visitors.value.toLocaleString()??"0",icon:xz,description:n("dashboard.widgets.stat.visitors.description"),trend:s?.visitors.trend?{value:s.visitors.trend,isPositive:s.visitors.isPositive}:void 0};case"traffic":return{title:n("dashboard.widgets.stat.traffic.title"),value:o?"...":`${s?.bandwidth.value} ${s?.bandwidth.unit}`,icon:Rg,description:n("dashboard.widgets.stat.traffic.description"),trend:s?.bandwidth.trend?{value:s.bandwidth.trend,isPositive:s.bandwidth.isPositive}:void 0};case"storage":return{title:n("dashboard.widgets.storage.title"),value:o?"...":`${s?.storage.used} ${s?.storage.unit}`,icon:O6,description:o?n("common.loading"):n("dashboard.widgets.stat.storage.description",{percentage:s?.storage.percentage,total:Math.round((s?.storage.limit??0)/1024)}),trend:s?{value:s.storage.percentage,isPositive:!1}:void 0};default:return{title:"N/A",value:"0",icon:nv}}}function NHe(e){const t=[{id:"setup-checklist",type:"setup-checklist",x:0,y:0,span:{w:8,h:1},props:{variant:"full"}},{id:"site-status",type:"site-status",x:0,y:1,span:{w:2,h:1},props:{variant:"badge"}},{id:"storage-gauge",type:"storage",x:2,y:1,span:{w:2,h:1},props:{variant:"gauge"}},{id:"pub-stats-trio",type:"publication-stats",x:4,y:1,span:{w:2,h:1},props:{variant:"trio"}}];if(e.length>0){const n=e[0],r=e.find(i=>i.slug==="articoli")?.slug??n.slug,s=e.map(i=>{const o=i.branches.find(a=>a.alias===i.displayNameAlias);return{slug:i.slug,label:i.label,displayNameAlias:i.displayNameAlias,displayNameLabel:o?.label??i.displayNameAlias}});t.push({id:"quick-draft-minimal",type:"quick-draft",x:6,y:1,span:{w:2,h:1},props:{variant:"minimal",seeds:s}},{id:"recent-content-list",type:"recent-content",x:0,y:2,span:{w:4,h:2},props:{seedSlug:r,variant:"list"}},{id:"pending-drafts-list",type:"pending-drafts",x:4,y:2,span:{w:4,h:2},props:{seedSlug:r,variant:"list"}},{id:"media-gallery-grid",type:"media-gallery",x:0,y:4,span:{w:4,h:2},props:{seedSlug:r,variant:"grid"}},{id:"activity-feed-full",type:"activity-feed",x:4,y:4,span:{w:4,h:2},props:{seedSlug:r,variant:"feed"}})}return{layout:t}}function MHe(){const{t:e}=tt(),{data:t=[]}=n0(),{data:n,isLoading:r}=E8(),{data:s,isLoading:i}=N8(),{user:o}=e1(),a=new Date().getHours(),l=a>=5&&a<12?e("dashboard.greeting.morning"):a>=12&&a<18?e("dashboard.greeting.afternoon"):a>=18&&a<22?e("dashboard.greeting.evening"):e("dashboard.greeting.night"),u=o?.name||"Admin",h={statsData:n,cfData:s,statsLoading:r,cfLoading:i};return d.jsxs("div",{className:"[--header-height:calc(--spacing(14))] overflow-x-clip min-h-screen bg-neutral-50/50 dark:bg-neutral-950/50 relative",children:[d.jsxs("div",{className:"absolute top-0 left-0 w-full h-full overflow-hidden pointer-events-none z-0",children:[d.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[40%] h-[40%] bg-emerald-500/5 rounded-full blur-[120px]"}),d.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[40%] h-[40%] bg-blue-500/5 rounded-full blur-[120px]"})]}),d.jsxs(Ru,{className:"flex flex-col relative z-10",children:[d.jsx(Pu,{}),d.jsxs("div",{className:"flex flex-1",children:[d.jsx(Lu,{}),d.jsx(Ou,{className:"min-w-0",children:d.jsx("main",{className:"flex flex-1 flex-col gap-8 p-6 md:p-8 lg:p-10",children:d.jsxs("div",{className:"content-area-inner flex flex-col gap-8",children:[d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsxs("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl text-neutral-900 dark:text-neutral-100",children:[l,", ",d.jsx("span",{className:"text-primary",children:u})]}),d.jsx("p",{className:"text-neutral-500 dark:text-neutral-400",children:e("dashboard.greeting.subtitle")})]}),d.jsx("div",{className:"bento-grid grid grid-cols-1 gap-6 md:grid-cols-4 lg:grid-cols-8 auto-rows-min",children:NHe(t).layout.map(p=>{const b=Math.min(Math.max(1,p.span.w),8),y=Math.min(Math.max(1,p.span.h),12),x=Math.max(1,Math.ceil(b/2));return d.jsx("div",{className:"bento-cell flex flex-col",style:{"--col-span-md":x,"--col-span-lg":b,"--row-span":y},children:d.jsx(CHe,{instance:p,data:h})},p.id)})})]})})})]})]})]})}function Un({children:e,className:t,bare:n=!1,title:r,icon:s,action:i,contentClassName:o}){if(n)return d.jsx("div",{className:ie("h-full w-full",t),children:e});const a=!!(r||s||i);return d.jsxs("div",{className:ie("h-full w-full flex flex-col","rounded-2xl border border-neutral-200/80 bg-white/75 backdrop-blur-md overflow-hidden","shadow-[0_1px_3px_0_rgb(0,0,0,0.05),0_1px_2px_-1px_rgb(0,0,0,0.04)]","transition-all duration-200 hover:shadow-[0_4px_12px_0_rgb(0,0,0,0.08),0_2px_4px_-1px_rgb(0,0,0,0.06)]","hover:border-neutral-300/80","dark:border-neutral-700/50 dark:bg-neutral-900/65 dark:hover:border-neutral-600/60","dark:shadow-[0_1px_3px_0_rgb(0,0,0,0.2)] dark:hover:shadow-[0_4px_12px_0_rgb(0,0,0,0.3)]","p-5",t),children:[a&&d.jsxs("div",{className:"flex items-center justify-between mb-4 shrink-0",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[s&&d.jsx(s,{className:"size-4 text-muted-foreground"}),r&&d.jsx("span",{className:"text-sm font-semibold text-foreground",children:r})]}),i&&d.jsx("div",{className:"flex items-center",children:i})]}),d.jsx("div",{className:ie("flex-1 min-h-0",o),children:e})]})}function ec({title:e,description:t,children:n}){return d.jsxs("section",{className:"space-y-4",children:[d.jsxs("div",{children:[d.jsx("h2",{className:"text-base font-semibold text-foreground",children:e}),t&&d.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t})]}),n]})}function tc({children:e,className:t}){return d.jsx("div",{className:ie("grid gap-4",t),children:e})}function zs({label:e,h:t=120,children:n}){return d.jsxs("div",{className:"space-y-2",children:[d.jsx("p",{className:"text-xs font-mono text-muted-foreground/70",children:e}),d.jsx("div",{style:{height:t},children:n})]})}function iC({name:e}){return d.jsx(Un,{children:d.jsx("div",{className:"flex h-full items-center justify-center",children:d.jsx("p",{className:"text-sm font-mono text-muted-foreground/50",children:e})})})}function _He(){const{data:e=[]}=n0(),t=e.map(r=>{const s=r.branches.find(i=>i.alias===r.displayNameAlias);return{slug:r.slug,label:r.label,displayNameAlias:r.displayNameAlias,displayNameLabel:s?.label??r.displayNameAlias}}),n=t[0]?.slug??"";return d.jsx("div",{className:"[--header-height:calc(--spacing(14))]",children:d.jsxs(Ru,{className:"flex flex-col",children:[d.jsx(Pu,{}),d.jsxs("div",{className:"flex flex-1",children:[d.jsx(Lu,{}),d.jsx(Ou,{children:d.jsxs("div",{className:"mx-auto w-full max-w-screen-2xl p-6 space-y-12",children:[d.jsxs("div",{children:[d.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Widget Lab"}),d.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Sandbox per sviluppare e ispezionare i widget prima di portarli in dashboard. Ogni sezione mostra un widget in tutte le sue varianti di dimensione."})]}),d.jsx(ec,{title:"SiteStatusWidget",description:`type="site-status" — mostra lo stato online/offline dell'API`,children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="badge" · span w:2 h:1',children:d.jsx(S6,{variant:"badge"})}),d.jsx(zs,{label:'variant="pill-row" · span w:3 h:1',children:d.jsx(S6,{variant:"pill-row"})})]})}),d.jsx(ec,{title:"StorageWidget",description:'type="storage" — utilizzo storage R2',children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="gauge" · span w:2 h:1',children:d.jsx(C6,{variant:"gauge"})}),d.jsx(zs,{label:'variant="bar" · span w:3 h:1',children:d.jsx(C6,{variant:"bar"})})]})}),d.jsx(ec,{title:"PublicationStatsWidget",description:'type="publication-stats" — contenuti pubblicati oggi / settimana / mese',children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="trio" · span w:2 h:1',children:d.jsx(Yx,{variant:"trio"})}),d.jsx(zs,{label:'variant="single" · span w:2 h:1',children:d.jsx(Yx,{variant:"single"})})]})}),d.jsx(ec,{title:"QuickDraftWidget",description:'type="quick-draft" — crea velocemente una bozza senza navigare',children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="minimal" · span w:2 h:1',children:d.jsx(x6,{variant:"minimal",seeds:t})}),d.jsx(zs,{label:'variant="expanded" · span w:4 h:2',h:200,children:d.jsx(x6,{variant:"expanded",seeds:t})})]})}),d.jsx(ec,{title:"RecentContentWidget",description:'type="recent-content" — lista degli ultimi contenuti modificati',children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="list" · span w:4 h:2',h:280,children:d.jsx(v6,{seedSlug:n,variant:"list"})}),d.jsx(zs,{label:'variant="cards" · span w:4 h:2',h:280,children:d.jsx(v6,{seedSlug:n,variant:"cards"})})]})}),d.jsx(ec,{title:"PendingDraftsWidget",description:'type="pending-drafts" — bozze in attesa di revisione / pubblicazione',children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="counter" · span w:2 h:1',children:d.jsx(w6,{seedSlug:n,variant:"counter"})}),d.jsx(zs,{label:'variant="list" · span w:4 h:2',h:280,children:d.jsx(w6,{seedSlug:n,variant:"list"})})]})}),d.jsx(ec,{title:"MediaGalleryWidget",description:'type="media-gallery" — anteprima griglia dei media caricati',children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="grid" · span w:4 h:2',h:280,children:d.jsx(k6,{seedSlug:n,variant:"grid"})}),d.jsx(zs,{label:'variant="unused" · span w:4 h:2',h:280,children:d.jsx(k6,{seedSlug:n,variant:"unused"})})]})}),d.jsx(ec,{title:"ActivityFeedWidget",description:'type="activity-feed" — log delle ultime azioni nel CMS',children:d.jsxs(tc,{className:"grid-cols-2",children:[d.jsx(zs,{label:'variant="compact" · span w:2 h:1',children:d.jsx(E6,{variant:"compact"})}),d.jsx(zs,{label:'variant="feed" · span w:4 h:2',h:280,children:d.jsx(E6,{variant:"feed"})})]})}),d.jsx(ec,{title:"In sviluppo",description:"Nuovi widget in costruzione — aggiungi qui i tuoi componenti prima di registrarli.",children:d.jsxs(tc,{className:"grid-cols-3",children:[d.jsx(zs,{label:"nuovo-widget-1",children:d.jsx(iC,{name:"nuovo-widget-1"})}),d.jsx(zs,{label:"nuovo-widget-2",children:d.jsx(iC,{name:"nuovo-widget-2"})}),d.jsx(zs,{label:"nuovo-widget-3",children:d.jsx(iC,{name:"nuovo-widget-3"})})]})})]})})]})]})})}function THe(){const{t:e}=tt(),t=xH(),n=vp(t);let r=e("errorPage.unknown");n?r=t.statusText||t.data?.message||e("errorPage.unknown"):t instanceof Error&&(r=t.message);const s=n?t.status:null;return d.jsx("div",{className:"flex min-h-svh w-full flex-col items-center justify-center bg-background p-6",children:d.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[s&&d.jsx("span",{className:"text-6xl font-bold text-muted-foreground",children:s}),d.jsx("h1",{className:"text-xl font-semibold",children:e("errorPage.title")}),d.jsx("p",{className:"text-sm text-muted-foreground",children:r}),d.jsx(Ns,{to:"/",className:"rounded-md bg-accent px-4 py-2 text-sm !text-white hover:bg-accent/90",children:e("errorPage.backHome")})]})})}const AHe=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function RHe(){const{t:e,i18n:t}=tt(),[n,r]=w.useState(""),[s,i]=w.useState(null),[o,a]=w.useState(!1),[l,u]=w.useState(!1),h=async p=>{p.preventDefault();const m=n.trim();if(!m){i(e("forgotPassword.emailRequired"));return}if(!AHe.test(m)){i(e("forgotPassword.emailInvalid"));return}i(null),a(!0);try{await $n.post("/auth/forgot-password",{email:m,locale:t.language})}catch{}a(!1),u(!0)};return d.jsx("div",{className:"flex min-h-svh w-full flex-col items-center justify-center bg-background p-4 sm:p-6 md:p-8",children:d.jsx("div",{className:"w-full max-w-sm sm:max-w-md",children:d.jsx(Zn,{className:"overflow-hidden shadow-md",children:d.jsx(Xn,{className:"p-6 md:p-8",children:l?d.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:e("forgotPassword.successTitle")}),d.jsx("p",{className:"text-muted-foreground text-balance text-sm",children:e("forgotPassword.successDesc")}),d.jsx(Ns,{to:"/login",className:"text-sm underline-offset-2 hover:underline",children:e("forgotPassword.backToLogin")})]}):d.jsx("form",{onSubmit:h,noValidate:!0,children:d.jsxs(a7,{children:[d.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:e("forgotPassword.title")}),d.jsx("p",{className:"text-muted-foreground text-balance text-sm",children:e("forgotPassword.desc")})]}),d.jsxs(pc,{children:[d.jsx(wp,{htmlFor:"fp-email",children:"Email"}),d.jsx(Xt,{id:"fp-email",type:"email",inputMode:"email",autoComplete:"email",value:n,className:ie(s?"border-destructive":""),onChange:p=>{r(p.target.value),i(null)}}),s&&d.jsx(l7,{children:s})]}),d.jsx(pc,{children:d.jsx(Oe,{type:"submit",disabled:!n.trim()||o,className:ie("transition-colors duration-200 ease-out disabled:opacity-100",n.trim()&&!o?"bg-accent text-accent-foreground hover:bg-accent/90":"bg-muted text-muted-foreground cursor-not-allowed"),children:e(o?"forgotPassword.sending":"forgotPassword.send")})}),d.jsx("div",{className:"text-center",children:d.jsx(Ns,{to:"/login",className:"text-sm underline-offset-2 hover:underline",children:e("forgotPassword.backToLogin")})})]})})})})})})}const az=8,lz=128;function OHe(){const{t:e,i18n:t}=tt(),n=pa(),[r]=j2(),s=r.get("token"),[i,o]=w.useState(""),[a,l]=w.useState(""),[u,h]=w.useState(!1),[p,m]=w.useState(!1),[b,y]=w.useState(null),[x,S]=w.useState(!1);if(!s)return d.jsx("div",{className:"flex min-h-svh w-full flex-col items-center justify-center bg-background p-4",children:d.jsx("div",{className:"w-full max-w-sm sm:max-w-md",children:d.jsx(Zn,{className:"overflow-hidden shadow-md",children:d.jsx(Xn,{className:"p-6 md:p-8",children:d.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:e("resetPassword.invalidLinkTitle")}),d.jsx("p",{className:"text-muted-foreground text-sm",children:e("resetPassword.invalidLink")}),d.jsx(Ns,{to:"/forgot-password",className:"text-sm underline-offset-2 hover:underline",children:e("resetPassword.requestNew")})]})})})})});const C=i.length>=az&&i.length<=lz&&i===a,N=async M=>{if(M.preventDefault(),i!==a){y(e("resetPassword.mismatch"));return}if(i.length<az){y(e("resetPassword.tooShort"));return}if(i.length>lz){y(e("resetPassword.tooLong"));return}y(null),S(!0);try{await $n.post("/auth/reset-password",{token:s,password:i,locale:t.language}),_n.success(e("resetPassword.success")),n("/login",{replace:!0})}catch(_){$n.isAxiosError(_)&&_.response?.status===400?y(e("resetPassword.invalidToken")):y(e("resetPassword.genericError")),S(!1)}};return d.jsx("div",{className:"flex min-h-svh w-full flex-col items-center justify-center bg-background p-4 sm:p-6 md:p-8",children:d.jsx("div",{className:"w-full max-w-sm sm:max-w-md",children:d.jsx(Zn,{className:"overflow-hidden shadow-md",children:d.jsx(Xn,{className:"p-6 md:p-8",children:d.jsx("form",{onSubmit:N,noValidate:!0,children:d.jsxs(a7,{children:[d.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:e("resetPassword.title")}),d.jsx("p",{className:"text-muted-foreground text-balance text-sm",children:e("resetPassword.desc")})]}),d.jsxs(pc,{children:[d.jsx(wp,{htmlFor:"rp-password",children:e("resetPassword.newPassword")}),d.jsxs("div",{className:"relative",children:[d.jsx(Xt,{id:"rp-password",type:u?"text":"password",autoComplete:"new-password",value:i,className:ie("pr-10",b?"border-destructive":""),onChange:M=>{o(M.target.value),y(null)}}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-sm",className:"absolute right-1 top-1/2 -translate-y-1/2 hover:bg-transparent",onClick:()=>h(M=>!M),"aria-label":e(u?"login.hidePassword":"login.showPassword"),children:d.jsx("span",{className:"inline-flex origin-center animate-[icon-swap_0.15s_ease-out]",children:u?d.jsx(fp,{className:"text-muted-foreground size-4"}):d.jsx(hp,{className:"text-muted-foreground size-4"})})})]})]}),d.jsxs(pc,{children:[d.jsx(wp,{htmlFor:"rp-confirm",children:e("resetPassword.confirmPassword")}),d.jsxs("div",{className:"relative",children:[d.jsx(Xt,{id:"rp-confirm",type:p?"text":"password",autoComplete:"new-password",value:a,className:ie("pr-10",b?"border-destructive":""),onChange:M=>{l(M.target.value),y(null)}}),d.jsx(Oe,{type:"button",variant:"ghost",size:"icon-sm",className:"absolute right-1 top-1/2 -translate-y-1/2 hover:bg-transparent",onClick:()=>m(M=>!M),"aria-label":e(p?"login.hidePassword":"login.showPassword"),children:d.jsx("span",{className:"inline-flex origin-center animate-[icon-swap_0.15s_ease-out]",children:p?d.jsx(fp,{className:"text-muted-foreground size-4"}):d.jsx(hp,{className:"text-muted-foreground size-4"})})})]}),b&&d.jsx(l7,{children:b})]}),d.jsx(pc,{children:d.jsx(Oe,{type:"submit",disabled:!C||x,className:ie("transition-colors duration-200 ease-out disabled:opacity-100",C&&!x?"bg-accent text-accent-foreground hover:bg-accent/90":"bg-muted text-muted-foreground cursor-not-allowed"),children:e(x?"resetPassword.resetting":"resetPassword.reset")})}),d.jsx("div",{className:"text-center",children:d.jsx(Ns,{to:"/login",className:"text-sm underline-offset-2 hover:underline",children:e("forgotPassword.backToLogin")})})]})})})})})})}function DHe(){const e=pa(),[t,n]=w.useState(""),[r,s]=w.useState(""),[i,o]=w.useState(""),[a,l]=w.useState(""),[u,h]=w.useState(null),[p,m]=w.useState(!1);async function b(y){if(y.preventDefault(),h(null),i!==a){h("Passwords do not match.");return}if(i.length<8){h("Password must be at least 8 characters.");return}m(!0);try{await $n.post("/auth/setup",{email:r,password:i,name:t}),e("/login",{replace:!0})}catch(x){$n.isAxiosError(x)&&x.response?.data?.title?h(x.response.data.title):h("Setup failed. Please try again.")}finally{m(!1)}}return d.jsx("div",{className:"flex min-h-svh w-full items-center justify-center bg-background p-4",children:d.jsxs(Zn,{className:"w-full max-w-md",children:[d.jsxs(Tr,{className:"space-y-1",children:[d.jsx(Wr,{className:"text-2xl font-bold",children:"Welcome to BeechCMS"}),d.jsx(Aa,{children:"Create your admin account to get started. This screen appears only once."})]}),d.jsx(Xn,{children:d.jsxs("form",{onSubmit:b,className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(Es,{htmlFor:"name",children:"Name"}),d.jsx(Xt,{id:"name",placeholder:"Your name",value:t,onChange:y=>n(y.target.value),autoComplete:"name"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Es,{htmlFor:"email",children:"Email"}),d.jsx(Xt,{id:"email",type:"email",placeholder:"admin@example.com",value:r,onChange:y=>s(y.target.value),required:!0,autoComplete:"email"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Es,{htmlFor:"password",children:"Password"}),d.jsx(Xt,{id:"password",type:"password",placeholder:"Min. 8 characters",value:i,onChange:y=>o(y.target.value),required:!0,autoComplete:"new-password"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Es,{htmlFor:"confirm",children:"Confirm password"}),d.jsx(Xt,{id:"confirm",type:"password",placeholder:"Repeat password",value:a,onChange:y=>l(y.target.value),required:!0,autoComplete:"new-password"})]}),u&&d.jsx("p",{className:"text-sm text-destructive",children:u}),d.jsx(Oe,{type:"submit",className:"w-full",disabled:p,children:p?"Creating account…":"Create admin account"})]})})]})})}function jHe(){const[e,t]=w.useState(!1),[n,r]=w.useState(["root"]),[s,i]=w.useState(""),o=n.at(-1)??"root",a=w.useCallback(u=>{r(h=>[...h,u]),i("")},[]),l=w.useCallback(()=>{r(u=>u.length<=1?u:u.slice(0,-1)),i("")},[]);return w.useEffect(()=>{const u=h=>{if(h.key==="k"&&(h.metaKey||h.ctrlKey)){h.preventDefault(),t(p=>!p);return}if(h.key==="n"&&h.altKey&&!h.metaKey&&!h.ctrlKey){h.preventDefault(),t(!0),r(["root","create"]),i("");return}if(e){if(h.key==="Backspace"&&s===""&&n.length>1){h.preventDefault(),l();return}h.key==="Escape"&&n.length>1&&(h.preventDefault(),l())}};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,s,n.length,l]),w.useEffect(()=>{e||(i(""),r(["root"]))},[e]),{open:e,setOpen:t,pages:n,currentPage:o,pushPage:a,popPage:l,search:s,setSearch:i}}function IHe({seeds:e,pushPage:t,navigate:n,setOpen:r,theme:s,toggleTheme:i}){const{t:o}=tt(),a=l=>{n(l),r(!1)};return d.jsxs(d.Fragment,{children:[d.jsxs(Yd,{heading:o("commandPalette.navigate"),forceMount:!0,children:[d.jsxs(vo,{onSelect:()=>a("/"),children:[d.jsx(wz,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsx("span",{children:o("commandPalette.dashboard")})]}),d.jsxs(vo,{onSelect:()=>a("/media"),children:[d.jsx(Tg,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsx("span",{children:o("commandPalette.mediaLibrary")})]}),d.jsxs(vo,{onSelect:()=>a("/settings"),children:[d.jsx(Ag,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsx("span",{children:o("commandPalette.settings")})]})]}),d.jsx(tv,{}),d.jsxs(Yd,{heading:o("commandPalette.contents"),children:[e.slice(0,5).map(l=>{const u=d7(l.dashboard?.icon);return d.jsxs(vo,{onSelect:()=>a(`/content/${l.slug}`),keywords:[l.slug,"contenuto","lista"],children:[d.jsx(u,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsx("span",{children:o("commandPalette.goTo",{label:l.label})})]},l.slug)}),e.length>5&&d.jsxs(vo,{onSelect:()=>t("seeds"),children:[d.jsx(Qx,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsx("span",{children:o("commandPalette.allSeeds")})]})]}),d.jsx(tv,{}),d.jsx(Yd,{heading:o("commandPalette.create"),children:d.jsxs(vo,{onSelect:()=>t("create"),children:[d.jsx(Hi,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsx("span",{children:o("commandPalette.newContent")}),d.jsxs(IZ,{className:"flex items-center gap-0.5",children:[d.jsx("kbd",{className:"text-xs font-mono bg-muted text-muted-foreground px-1 rounded",children:"Alt"}),d.jsx("kbd",{className:"text-xs font-mono bg-muted text-muted-foreground px-1 rounded",children:"N"})]})]})}),d.jsx(tv,{}),d.jsx(Yd,{heading:o("commandPalette.tools"),children:d.jsxs(vo,{onSelect:i,keywords:["dark mode","light mode","tema","theme"],children:[s==="dark"?d.jsx(z6,{className:"size-4 shrink-0 text-muted-foreground"}):d.jsx(Cz,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsx("span",{children:o("commandPalette.changeTheme")})]})})]})}function cz({seeds:e,navigate:t,setOpen:n,mode:r}){const{t:s}=tt(),i=s(r==="create"?"commandPalette.chooseType":"commandPalette.chooseSeed");return d.jsx(Yd,{heading:i,children:e.map(o=>{const a=d7(o.dashboard?.icon);return d.jsxs(vo,{onSelect:()=>{const l=r==="create"?`/content/${o.slug}/create`:`/content/${o.slug}`;t(l),n(!1)},children:[d.jsx(a,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsxs("div",{className:"flex flex-col",children:[d.jsx("span",{children:o.label}),d.jsx("span",{className:"text-[10px] text-muted-foreground",children:o.slug})]})]},o.slug)})})}function zHe(e){const n=e.replace(/<(?!\/?mark\b)[^>]*>/gi,"").split(/(<mark>|<\/mark>)/gi),r=[];let s=!1,i=0;for(const o of n){if(o.toLowerCase()==="<mark>"){s=!0;continue}if(o.toLowerCase()==="</mark>"){s=!1;continue}o&&r.push(s?d.jsx("mark",{children:o},i++):o)}return r}function LHe({search:e,navigate:t,setOpen:n}){const{t:r}=tt(),s=UZ(e,300),{data:i,isLoading:o}=Ir({queryKey:["cmd-search",s],queryFn:async()=>(await Gt.get(`/search?q=${encodeURIComponent(s)}&limit=8`)).data,enabled:s.length>=2,staleTime:3e4}),a=i?.items??[];return e.length<2?null:o?d.jsx("div",{className:"px-4 py-6 text-sm text-center text-muted-foreground",children:r("commandPalette.searching")}):d.jsxs(Yd,{heading:r("commandPalette.searchResults"),children:[a.map(l=>d.jsxs(vo,{onSelect:()=>{t(`/content/${l.schema_slug}/${l.id}`),n(!1)},children:[d.jsx(nv,{className:"size-4 shrink-0 text-muted-foreground"}),d.jsxs("div",{className:"flex flex-col",children:[d.jsx("span",{className:"font-medium",children:l.title}),l.excerpt&&d.jsx("span",{className:"text-xs text-muted-foreground line-clamp-1",children:zHe(l.excerpt)}),d.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/70",children:[l.schema_slug," · ",l.status]})]})]},l.id)),a.length===0&&!o&&d.jsx("div",{className:"px-4 py-6 text-sm text-center text-muted-foreground",children:r("commandPalette.noSearchResults")})]})}function PHe(){const{t:e}=tt(),t=Ec(n=>n.search);return d.jsx(k8,{children:t.length===0?e("commandPalette.noResults"):d.jsxs(d.Fragment,{children:[e("commandPalette.noResults")," ",d.jsxs("span",{className:"font-medium",children:['"',t,'"']})]})})}function $He({pages:e,popPage:t}){return e.length<=1?null:d.jsx("div",{className:"flex items-center gap-2 px-4 pt-4 pb-0 overflow-x-auto",children:e.map((n,r)=>d.jsxs(w.Fragment,{children:[d.jsx(gi,{variant:"secondary",className:ie("cursor-pointer hover:bg-secondary/80 capitalize shrink-0",r===e.length-1&&"opacity-60 pointer-events-none"),onClick:()=>{const s=e.length-1-r;for(let i=0;i<s;i++)t()},children:n}),r<e.length-1&&d.jsx(xc,{className:"size-3 text-muted-foreground shrink-0"})]},n+r))})}function FHe(){const{t:e}=tt(),t=pa(),{resolvedTheme:n,setTheme:r}=Zx(),{open:s,setOpen:i,pages:o,currentPage:a,pushPage:l,popPage:u,search:h,setSearch:p}=jHe(),m=Object.values(h7),b={root:e("commandPalette.placeholderRoot"),seeds:e("commandPalette.placeholderSeeds"),create:e("commandPalette.placeholderCreate"),"search-results":e("commandPalette.placeholderSearch")},y=w.useCallback(()=>{r(n==="dark"?"light":"dark"),i(!1)},[n,r,i]);return d.jsxs(d.Fragment,{children:[d.jsx("style",{children:"[cmdk-list]{height:var(--cmdk-list-height);transition:height 100ms ease}"}),d.jsxs(qFe,{open:s,onOpenChange:i,"aria-label":e("commandPalette.ariaLabel"),children:[d.jsxs("div",{className:"flex flex-col",children:[d.jsx($He,{pages:o,popPage:u}),d.jsx(S8,{placeholder:b[a],value:h,onValueChange:p})]}),d.jsxs(C8,{className:"max-h-[400px]",children:[d.jsx(PHe,{}),a==="root"&&d.jsx(IHe,{seeds:m,pushPage:l,navigate:t,setOpen:i,theme:n,toggleTheme:y}),a==="seeds"&&d.jsx(cz,{seeds:m,navigate:t,setOpen:i,mode:"navigate"}),a==="create"&&d.jsx(cz,{seeds:m,navigate:t,setOpen:i,mode:"create"}),a==="search-results"&&d.jsx(LHe,{search:h,seeds:m,navigate:t,setOpen:i})]}),a!=="root"&&d.jsx("div",{className:"p-3 border-t text-[10px] text-muted-foreground bg-muted/20",children:e("commandPalette.backHint")})]})]})}function BHe(){return d.jsx("div",{className:"flex min-h-svh w-full items-center justify-center bg-background",children:d.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}function HHe(){const e=pa();return w.useEffect(()=>{$n.get("/auth/setup").then(({data:t})=>{t.needsSetup&&e("/setup",{replace:!0})}).catch(()=>{})},[e]),d.jsx("div",{className:"flex min-h-svh w-full flex-col items-center justify-center bg-background p-4 sm:p-6 md:p-8 lg:p-10 xl:p-12",children:d.jsx("div",{className:"w-full max-w-sm sm:max-w-md md:max-w-2xl lg:max-w-4xl xl:max-w-6xl 2xl:max-w-7xl",children:d.jsx(I1e,{})})})}function Dd({children:e}){const{status:t}=e1();return t==="loading"?d.jsx(BHe,{}):t==="unauthenticated"?d.jsx(Q0e,{to:"/login",replace:!0}):d.jsx(d.Fragment,{children:e})}function UHe(){return d.jsxs(d.Fragment,{children:[d.jsx(FHe,{}),d.jsx(J0e,{})]})}const VHe=Eme([{element:d.jsx(UHe,{}),errorElement:d.jsx(THe,{}),children:[{path:"/login",element:d.jsx(HHe,{})},{path:"/setup",element:d.jsx(DHe,{})},{path:"/forgot-password",element:d.jsx(RHe,{})},{path:"/reset-password",element:d.jsx(OHe,{})},{path:"/",element:d.jsx(Dd,{children:d.jsx(MHe,{})})},{path:"/content/:slug/create",element:d.jsx(Dd,{children:d.jsx(rz,{})})},{path:"/content/:slug/:id",element:d.jsx(Dd,{children:d.jsx(rz,{})})},{path:"/content/:slug",element:d.jsx(Dd,{children:d.jsx(LBe,{})})},{path:"/settings",element:d.jsx(Dd,{children:d.jsx(Vbe,{})})},{path:"/test-fields",element:d.jsx(Dd,{children:d.jsx(WBe,{})})},{path:"/widget-lab",element:d.jsx(Dd,{children:d.jsx(_He,{})})}]}],{basename:"/admin"});function qHe(){return d.jsx(O1e,{children:d.jsx(Lme,{router:VHe})})}sJ.createRoot(document.getElementById("root")).render(d.jsx(w.StrictMode,{children:d.jsx(xfe,{client:Ofe,children:d.jsx(lJ,{attribute:"class",defaultTheme:"system",enableSystem:!0,disableTransitionOnChange:!0,enableColorScheme:!0,storageKey:"beech-theme",children:d.jsxs(kB,{children:[d.jsx(qHe,{}),d.jsx(qre,{})]})})})}));