@decido/shell 4.0.2 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CenterComposite-V3LL23PG.mjs +64 -0
- package/dist/DebugPanel-NFXQOZQ6.mjs +1 -0
- package/dist/MorphShell-4JGDAN46.mjs +1 -0
- package/dist/PlaygroundAppSidebar-QI73PNRI.mjs +1 -0
- package/dist/PlaygroundChat-CBIIQMWU.mjs +1 -0
- package/dist/PlaygroundTerminal-MVZKXTYW.mjs +1 -0
- package/dist/PluginSandbox-MUNBFWGH.mjs +1 -0
- package/dist/ReactFlowEditor-2ALQWCHQ.mjs +6 -0
- package/dist/ReactFlowEditor-ROZ6RF3K.css +1 -0
- package/dist/TimelineEditor-UPRRXXVM.mjs +3 -0
- package/dist/WidgetSlotPanel-YX2VBQAP.mjs +1 -0
- package/dist/chunk-3YEFIKFH.mjs +1 -0
- package/dist/chunk-53FADIUX.mjs +1 -0
- package/dist/chunk-5FWJFDER.mjs +285 -0
- package/dist/chunk-6K3AFDP5.mjs +1 -0
- package/dist/chunk-AGAAZ2MU.mjs +1 -0
- package/dist/chunk-BCP43BRV.mjs +2 -0
- package/dist/chunk-BSJBW64M.mjs +1 -0
- package/dist/chunk-C5FD536O.mjs +1 -0
- package/dist/chunk-DTH34ILQ.mjs +1 -0
- package/dist/chunk-DWP77YZU.mjs +1 -0
- package/dist/chunk-O3OWL3Q2.mjs +1 -0
- package/dist/chunk-POBZMHZ5.mjs +7 -0
- package/dist/chunk-S3AQ4QDD.mjs +42 -0
- package/dist/chunk-XDA6ZRIQ.mjs +1 -0
- package/dist/chunk-XTDMHHMW.mjs +5 -0
- package/dist/chunk-YAYNNUEX.mjs +12 -0
- package/dist/chunk-YEKQJ4YC.mjs +1 -0
- package/dist/chunk-YHFKY5MB.mjs +1 -0
- package/dist/chunk-ZKD74U4X.mjs +1 -0
- package/dist/index.css +1 -0
- package/dist/index.js +506 -0
- package/dist/index.mjs +89 -0
- package/dist/useIntentLens-OCAUBNOQ.mjs +1 -0
- package/dist/useSuggestionsStore-Q4KVPU7L.mjs +1 -0
- package/dist/wasm-A4BTVJWV.mjs +1 -0
- package/package.json +18 -19
package/dist/index.js
ADDED
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
"use strict";var Tz=Object.create;var ih=Object.defineProperty;var Iz=Object.getOwnPropertyDescriptor;var Az=Object.getOwnPropertyNames;var Mz=Object.getPrototypeOf,Pz=Object.prototype.hasOwnProperty;var U=(t,e)=>()=>(t&&(e=t(t=0)),e);var aN=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Mo=(t,e)=>{for(var r in e)ih(t,r,{get:e[r],enumerable:!0})},sh=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Az(e))!Pz.call(t,o)&&o!==r&&ih(t,o,{get:()=>e[o],enumerable:!(n=Iz(e,o))||n.enumerable});return t},de=(t,e,r)=>(sh(t,e,"default"),r&&sh(r,e,"default")),Re=(t,e,r)=>(r=t!=null?Tz(Mz(t)):{},sh(e||!t||!t.__esModule?ih(r,"default",{value:t,enumerable:!0}):r,t)),Rz=t=>sh(ih({},"__esModule",{value:!0}),t);var Uo,dN,Bu,lN,cN,ed,B0,Dl,Ol=U(()=>{"use strict";Uo=require("react"),dN=require("react/jsx-runtime"),Bu=typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0,lN=()=>import("@tauri-apps/api/event"),cN=(0,Uo.createContext)({socket:null,isConnected:!1,isNativeOS:!1,emitEvent:()=>{},onEvent:()=>{},offEvent:()=>{}}),ed=()=>(0,Uo.useContext)(cN),B0=(t,e)=>{let{onEvent:r,offEvent:n}=ed();(0,Uo.useEffect)(()=>(r(t,e),()=>n(t,e)),[t,e,r,n])},Dl=({children:t,socketInstance:e=null,isConnected:r=!1})=>{let n=(0,Uo.useRef)(new Map),o=(0,Uo.useRef)(new Map),s=(0,Uo.useCallback)(async(c,d)=>{if(Bu){try{let{emit:u}=await lN();await u(c,d)}catch(u){console.error(`[Tauri IPC] Error emitiendo ${c}:`,u)}return}if(!e){console.warn(`[NetworkProvider] Emit '${c}' ignorado: No hay red disponible.`);return}typeof e.emit=="function"?e.emit(c,d):typeof e.send=="function"&&e.send(JSON.stringify({event:c,payload:d}))},[e]),i=(0,Uo.useCallback)((c,d)=>{if(Bu){let u=lN().then(({listen:f})=>f(c,p=>{d(p.payload)}));o.current.has(c)||o.current.set(c,[]),o.current.get(c)?.push({originalCallback:d,unlistenPromise:u});return}if(e){if(typeof e.on=="function")e.on(c,d);else if(typeof e.addEventListener=="function"){let u=f=>{try{let p=JSON.parse(f.data);p.event===c&&d(p.payload)}catch{}};e.addEventListener("message",u),n.current.has(c)||n.current.set(c,[]),n.current.get(c)?.push({originalCallback:d,wrappedCallback:u})}}},[e]),a=(0,Uo.useCallback)((c,d)=>{if(Bu){let u=o.current.get(c)||[],f=u.findIndex(p=>p.originalCallback===d);f>-1&&(u[f].unlistenPromise.then(p=>p()),u.splice(f,1));return}if(e){if(typeof e.off=="function")e.off(c,d);else if(typeof e.removeEventListener=="function"){let u=n.current.get(c)||[],f=u.findIndex(p=>p.originalCallback===d);if(f>-1){let{wrappedCallback:p}=u[f];e.removeEventListener("message",p),u.splice(f,1)}}}},[e]),l=Bu?!0:r;return(0,dN.jsx)(cN.Provider,{value:{socket:e,isConnected:l,isNativeOS:Bu,emitEvent:s,onEvent:i,offEvent:a},children:t})}});function $N(t,e){let r=document.documentElement;Object.entries(t).forEach(([n,o])=>{r.style.setProperty(`--ds-${n}`,o)}),Object.entries(e).forEach(([n,o])=>{r.style.setProperty(`--ds-${n}`,o)})}var FN,HN,ad,Y0,VN,jN,WN,UN,GN,$u,mi,Fu=U(()=>{"use strict";FN=require("zustand"),HN=require("zustand/middleware"),ad={"radius-xs":"4px","radius-sm":"6px","radius-md":"10px","radius-lg":"16px","radius-xl":"24px","blur-xs":"4px","blur-sm":"8px","blur-md":"16px","blur-lg":"24px","blur-xl":"40px","font-sans":"'Inter', 'system-ui', sans-serif","font-mono":"'JetBrains Mono', 'Fira Code', monospace"},Y0={id:"decido-dark",name:"Decido Dark",description:"Tema por defecto \u2014 oscuro con acentos p\xFArpura y cyan",preview:{bg:"#0a0a0f",accent:"#a855f7",text:"#e8e8f0"},tokens:{"surface-primary":"#0a0a0f","surface-secondary":"#12121a","surface-tertiary":"#1a1a26","surface-elevated":"#22222e","surface-glass":"rgba(255, 255, 255, 0.03)","surface-overlay":"rgba(0, 0, 0, 0.6)","text-primary":"#e8e8f0","text-secondary":"#9898b0","text-muted":"#5a5a72","text-inverse":"#0a0a0f","accent-blue":"#4a9eff","accent-purple":"#a855f7","accent-green":"#34d399","accent-red":"#f87171","accent-amber":"#fbbf24","accent-cyan":"#22d3ee","border-subtle":"rgba(255, 255, 255, 0.06)","border-default":"rgba(255, 255, 255, 0.1)","border-strong":"rgba(255, 255, 255, 0.2)","border-glow":"rgba(168, 85, 247, 0.5)","status-ok":"#34d399","status-warn":"#fbbf24","status-error":"#f87171","status-info":"#4a9eff"},meta:ad},VN={id:"midnight-blue",name:"Midnight Blue",description:"Azul profundo con tonos slate",preview:{bg:"#0b1120",accent:"#3b82f6",text:"#f1f5f9"},tokens:{"surface-primary":"#0b1120","surface-secondary":"#111827","surface-tertiary":"#1e293b","surface-elevated":"#273548","surface-glass":"rgba(30, 41, 59, 0.5)","surface-overlay":"rgba(11, 17, 32, 0.7)","text-primary":"#f1f5f9","text-secondary":"#94a3b8","text-muted":"#64748b","text-inverse":"#0b1120","accent-blue":"#3b82f6","accent-purple":"#8b5cf6","accent-green":"#22c55e","accent-red":"#ef4444","accent-amber":"#f59e0b","accent-cyan":"#06b6d4","border-subtle":"rgba(148, 163, 184, 0.06)","border-default":"rgba(148, 163, 184, 0.12)","border-strong":"rgba(148, 163, 184, 0.25)","border-glow":"rgba(59, 130, 246, 0.5)","status-ok":"#22c55e","status-warn":"#f59e0b","status-error":"#ef4444","status-info":"#3b82f6"},meta:ad},jN={id:"emerald-noir",name:"Emerald Noir",description:"Oscuro con acentos esmeralda",preview:{bg:"#0a0f0d",accent:"#34d399",text:"#ecfdf5"},tokens:{"surface-primary":"#0a0f0d","surface-secondary":"#0f1a15","surface-tertiary":"#162620","surface-elevated":"#1e332b","surface-glass":"rgba(22, 38, 32, 0.5)","surface-overlay":"rgba(10, 15, 13, 0.7)","text-primary":"#ecfdf5","text-secondary":"#a7f3d0","text-muted":"#6ee7b7","text-inverse":"#0a0f0d","accent-blue":"#2dd4bf","accent-purple":"#a78bfa","accent-green":"#34d399","accent-red":"#fb7185","accent-amber":"#fbbf24","accent-cyan":"#2dd4bf","border-subtle":"rgba(167, 243, 208, 0.06)","border-default":"rgba(167, 243, 208, 0.12)","border-strong":"rgba(167, 243, 208, 0.25)","border-glow":"rgba(52, 211, 153, 0.5)","status-ok":"#34d399","status-warn":"#fbbf24","status-error":"#fb7185","status-info":"#2dd4bf"},meta:ad},WN={id:"rose-gold",name:"Rose Gold",description:"Elegante con tonos rosa y dorado",preview:{bg:"#120a0d",accent:"#f472b6",text:"#fdf2f8"},tokens:{"surface-primary":"#120a0d","surface-secondary":"#1a1015","surface-tertiary":"#26161e","surface-elevated":"#331c28","surface-glass":"rgba(38, 22, 30, 0.5)","surface-overlay":"rgba(18, 10, 13, 0.7)","text-primary":"#fdf2f8","text-secondary":"#f9a8d4","text-muted":"#f472b6","text-inverse":"#120a0d","accent-blue":"#e879f9","accent-purple":"#f472b6","accent-green":"#34d399","accent-red":"#fb7185","accent-amber":"#fcd34d","accent-cyan":"#e879f9","border-subtle":"rgba(249, 168, 212, 0.06)","border-default":"rgba(249, 168, 212, 0.12)","border-strong":"rgba(249, 168, 212, 0.25)","border-glow":"rgba(244, 114, 182, 0.5)","status-ok":"#34d399","status-warn":"#fcd34d","status-error":"#fb7185","status-info":"#e879f9"},meta:ad},UN={id:"oled-pure",name:"OLED Pure",description:"Negro absoluto para pantallas OLED",preview:{bg:"#000000",accent:"#a855f7",text:"#ffffff"},tokens:{"surface-primary":"#000000","surface-secondary":"#0a0a0a","surface-tertiary":"#141414","surface-elevated":"#1e1e1e","surface-glass":"rgba(255, 255, 255, 0.02)","surface-overlay":"rgba(0, 0, 0, 0.8)","text-primary":"#ffffff","text-secondary":"#a0a0a0","text-muted":"#666666","text-inverse":"#000000","accent-blue":"#4a9eff","accent-purple":"#a855f7","accent-green":"#34d399","accent-red":"#f87171","accent-amber":"#fbbf24","accent-cyan":"#22d3ee","border-subtle":"rgba(255, 255, 255, 0.04)","border-default":"rgba(255, 255, 255, 0.08)","border-strong":"rgba(255, 255, 255, 0.15)","border-glow":"rgba(168, 85, 247, 0.5)","status-ok":"#4ade80","status-warn":"#fbbf24","status-error":"#f87171","status-info":"#4a9eff"},meta:ad},GN={id:"decido-light",name:"Decido Light",description:"Tema claro premium \u2014 ideal para trabajo diurno",preview:{bg:"#f8f9fb",accent:"#6366f1",text:"#1a1a2e"},tokens:{"surface-primary":"#f8f9fb","surface-secondary":"#ffffff","surface-tertiary":"#eef0f4","surface-elevated":"#ffffff","surface-glass":"rgba(0, 0, 0, 0.03)","surface-overlay":"rgba(0, 0, 0, 0.4)","text-primary":"#1a1a2e","text-secondary":"#64648c","text-muted":"#9898b0","text-inverse":"#ffffff","accent-blue":"#3b82f6","accent-purple":"#6366f1","accent-green":"#10b981","accent-red":"#ef4444","accent-amber":"#f59e0b","accent-cyan":"#06b6d4","border-subtle":"rgba(0, 0, 0, 0.06)","border-default":"rgba(0, 0, 0, 0.12)","border-strong":"rgba(0, 0, 0, 0.2)","border-glow":"rgba(99, 102, 241, 0.4)","status-ok":"#10b981","status-warn":"#f59e0b","status-error":"#ef4444","status-info":"#3b82f6"},meta:ad},$u=[Y0,GN,VN,jN,WN,UN];mi=(0,FN.create)()((0,HN.persist)((t,e)=>({currentThemeId:"decido-dark",customPresets:[],setTheme:r=>{t({currentThemeId:r});let n=e().getCurrentPreset();$N(n.tokens,n.meta)},setToken:(r,n)=>{document.documentElement.style.setProperty(`--ds-${r}`,n)},addPreset:r=>{t(n=>({customPresets:[...n.customPresets.filter(o=>o.id!==r.id),r]}))},inject:()=>{let r=e().getCurrentPreset();$N(r.tokens,r.meta)},exportCSS:()=>{let r=e().getCurrentPreset(),n=[":root {"];return Object.entries(r.tokens).forEach(([o,s])=>{n.push(` --ds-${o}: ${s};`)}),Object.entries(r.meta).forEach(([o,s])=>{n.push(` --ds-${o}: ${s};`)}),n.push("}"),n.join(`
|
|
2
|
+
`)},getCurrentPreset:()=>{let{currentThemeId:r,customPresets:n}=e();return[...$u,...n].find(o=>o.id===r)??Y0},getAllPresets:()=>[...$u,...e().customPresets]}),{name:"decido-aura-theme",onRehydrateStorage:()=>t=>{t&&setTimeout(()=>t.inject(),0)}}))});var Qz,e$,t$,r$,Ki,X0=U(()=>{"use strict";Qz={R1:"workspace-chat",R2:null,R3:"graph-editor",R4:"debug",R5:null,R6:null},e$={R1:"workspace-chat",R2:null,R3:null,R4:null,R5:null,R6:null},t$={R1:null,R2:null,R3:null,R4:null,R5:null,R6:null},r$={R1:"app-sidebar",R2:null,R3:"graph-editor",R4:"terminal",R5:null,R6:null},Ki={creator:Qz,player:e$,minimal:t$,studio:r$}});var JN,XN,n$,Ut,Us=U(()=>{"use strict";JN=require("zustand"),XN=500,n$=0,Ut=(0,JN.create)((t,e)=>({isOpen:!1,activeTab:"logs",logEntries:[],logFilters:{levels:new Set(["info","warn","error","debug"]),categories:new Set},allCategories:new Set,errorCount:0,togglePanel:()=>t(r=>({isOpen:!r.isOpen})),setOpen:r=>t({isOpen:r}),setActiveTab:r=>t({activeTab:r}),addLogEntry:r=>{let n=++n$,o={...r,id:n};t(s=>{let i=[...s.logEntries,o];i.length>XN&&i.splice(0,i.length-XN);let a=new Set(s.allCategories);return r.categories.forEach(l=>a.add(l)),{logEntries:i,allCategories:a,errorCount:r.level==="error"?s.errorCount+1:s.errorCount}})},clearLogs:()=>t({logEntries:[],errorCount:0}),toggleLevel:r=>t(n=>{let o=new Set(n.logFilters.levels);return o.has(r)?o.delete(r):o.add(r),{logFilters:{...n.logFilters,levels:o}}}),toggleCategory:r=>t(n=>{let o=new Set(n.logFilters.categories);return o.has(r)?o.delete(r):o.add(r),{logFilters:{...n.logFilters,categories:o}}}),resetFilters:()=>t({logFilters:{levels:new Set(["info","warn","error","debug"]),categories:new Set}})}))});var QN,ZN,o$,gi,fh=U(()=>{"use strict";QN=require("zustand"),ZN=200,o$=0,gi=(0,QN.create)((t,e)=>({events:[],isPaused:!1,filter:"",addEvent:r=>{if(e().isPaused)return;let n=++o$;t(o=>{let s=[...o.events,{...r,id:n}];return{events:s.length>ZN?s.slice(-ZN):s}})},clear:()=>t({events:[]}),togglePause:()=>t(r=>({isPaused:!r.isPaused})),setFilter:r=>t({filter:r})}))});function i$(){let t=new Date;return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}.${String(t.getMilliseconds()).padStart(3,"0")}`}function Hu(t,e,r,n){if(J0>=s$)return;J0++,Z0||(Z0=setTimeout(()=>{J0=0,Z0=null},1e3));let o=i$();Ut.getState().addLogEntry({timestamp:o,level:t,categories:e,message:r,data:n});let s=e[0]||"system",i=r.split(" ")[0]||r;gi.getState().addEvent({timestamp:o,storeName:s,actionName:i,data:n,level:t==="debug"?"info":t})}function qi(t){return(e,r,n="info")=>{Hu(n,[t],e,r)}}var J0,Z0,s$,fn,Vu=U(()=>{"use strict";Us();fh();J0=0,Z0=null,s$=50;fn={morph:qi("morph"),chat:qi("chat"),gemini:qi("gemini"),network:qi("network"),shell:qi("shell"),engine:qi("engine"),layout:qi("layout"),store:qi("store"),system:qi("system"),info:(t,e,r)=>Hu("info",[t],e,r),warn:(t,e,r)=>Hu("warn",[t],e,r),error:(t,e,r)=>Hu("error",[t],e,r),debug:(t,e,r)=>Hu("debug",[t],e,r)}});var eC,ph,ld,a$,ke,Qn=U(()=>{"use strict";eC=require("zustand"),ph=require("zustand/middleware"),ld=require("idb-keyval");X0();Vu();X0();a$={getItem:async t=>await(0,ld.get)(t)||null,setItem:async(t,e)=>{await(0,ld.set)(t,e)},removeItem:async t=>{await(0,ld.del)(t)}},ke=(0,eC.create)()((0,ph.persist)((t,e)=>({slots:{...Ki.player},setSlot:(r,n)=>t(o=>({slots:{...o.slots,[r]:n}})),swapSlots:(r,n)=>t(o=>({slots:{...o.slots,[r]:o.slots[n],[n]:o.slots[r]}})),resetLayout:r=>{let n=Ki[r];n&&t({slots:{...n}})},isCreatorMode:!1,setIsCreatorMode:r=>{t({isCreatorMode:r});let n=r?Ki.creator:Ki.player;t({slots:{...n}})},showCanvas:!1,setShowCanvas:r=>t({showCanvas:r}),showChat:!0,setShowChat:r=>t({showChat:r}),isSidebarOpen:!1,setIsSidebarOpen:r=>t({isSidebarOpen:r}),isImmersive:!1,setIsImmersive:r=>t({isImmersive:r}),activeStage:null,stageHistory:[],setStage:r=>{fn.layout(`setStage \u2192 ${r?.type||"null"}`,r),t({activeStage:r})},pushStage:r=>{let{activeStage:n,stageHistory:o}=e();fn.layout(`pushStage \u2192 ${r.type}${r.label?` (${r.label})`:""} | depth: ${o.length+1}`,{stage:r,previousStage:n?.type});let s=n?[...o,n]:o;t({activeStage:r,stageHistory:s})},popStage:()=>{let{stageHistory:r,activeStage:n}=e();if(r.length===0){fn.layout("popStage \u2192 null (history empty)",{poppedStage:n?.type},"warn"),t({activeStage:null});return}let o=r[r.length-1];fn.layout(`popStage \u2192 ${o.type}${o.label?` (${o.label})`:""} | depth: ${r.length-1}`,{poppedStage:n?.type,restoredStage:o.type}),t({activeStage:o,stageHistory:r.slice(0,-1)})},clearStages:()=>{fn.layout("clearStages \u2192 all cleared",{previousDepth:e().stageHistory.length}),t({activeStage:null,stageHistory:[]})},tabs:[],activeTabId:null,addTab:r=>{let{tabs:n}=e();if(n.some(o=>o.id===r.id)){t({activeTabId:r.id});return}t({tabs:[...n,r],activeTabId:r.id})},removeTab:r=>{let{tabs:n,activeTabId:o}=e(),s=n.filter(a=>a.id!==r),i=o===r?s.length>0?s[s.length-1].id:null:o;t({tabs:s,activeTabId:i})},setActiveTab:r=>t({activeTabId:r}),savedPresets:[],savePreset:r=>{let{slots:n,savedPresets:o}=e(),s={id:Date.now().toString(36),name:r,slots:{...n},createdAt:Date.now()};t({savedPresets:[...o,s]})},loadPreset:r=>{let{savedPresets:n}=e(),o=n.find(s=>s.id===r);o&&t({slots:{...o.slots}})},deletePreset:r=>{t(n=>({savedPresets:n.savedPresets.filter(o=>o.id!==r)}))}}),{name:"decido-layout-v4",storage:(0,ph.createJSONStorage)(()=>a$),partialize:t=>({slots:t.slots,isCreatorMode:t.isCreatorMode,isSidebarOpen:t.isSidebarOpen,showCanvas:t.showCanvas,showChat:t.showChat,tabs:t.tabs,activeTabId:t.activeTabId,savedPresets:t.savedPresets})}))});var rC,mh,dd,l$,X,ot=U(()=>{"use strict";rC=require("zustand"),mh=require("zustand/middleware"),dd=require("idb-keyval"),l$={getItem:async t=>await(0,dd.get)(t)||null,setItem:async(t,e)=>{await(0,dd.set)(t,e)},removeItem:async t=>{await(0,dd.del)(t)}},X=(0,rC.create)()((0,mh.persist)(t=>({isBooting:!0,setIsBooting:e=>t({isBooting:e}),step:"chat",setStep:e=>t({step:e}),selectedProfile:null,setSelectedProfile:e=>t({selectedProfile:e}),prototypeBrand:"decido",setPrototypeBrand:e=>t(r=>({prototypeBrand:typeof e=="function"?e(r.prototypeBrand):e})),activeArtifactData:null,setActiveArtifactData:e=>t({activeArtifactData:e}),demoState:"idle",setDemoState:e=>t({demoState:e}),showCanvas:!1,setShowCanvas:e=>t({showCanvas:e}),showChat:!0,setShowChat:e=>t({showChat:e}),isMuted:!1,setIsMuted:e=>t(r=>({isMuted:typeof e=="function"?e(r.isMuted):e})),selectedVoice:"Kore",setSelectedVoice:e=>t({selectedVoice:e}),isFullscreen:!1,setIsFullscreen:e=>t({isFullscreen:e}),isVoiceActive:!1,setIsVoiceActive:e=>t({isVoiceActive:e}),isSidebarOpen:!1,setIsSidebarOpen:e=>t({isSidebarOpen:e}),isTerminalOpen:!1,setIsTerminalOpen:e=>t({isTerminalOpen:e}),inputValue:"",setInputValue:e=>t({inputValue:e}),isCreatorMode:!1,setIsCreatorMode:e=>t({isCreatorMode:e}),creatorViewMode:"graph",setCreatorViewMode:e=>t({creatorViewMode:e}),logs:[],addLog:(e,r="info")=>t(n=>({logs:[...n.logs.slice(-49),{time:new Date().toLocaleTimeString([],{hour12:!1}),msg:e,type:r}]})),setLogs:e=>t(r=>({logs:typeof e=="function"?e(r.logs):e})),savedSequences:[],addSavedSequence:e=>t(r=>({savedSequences:[...r.savedSequences,e]})),removeSavedSequence:e=>t(r=>({savedSequences:r.savedSequences.filter(n=>n.id!==e)})),chatMessagesByInstance:{},addChatMessage:e=>t(r=>{let n=r.activeChatId||"_default",o=r.chatMessagesByInstance[n]||[],s={...e,id:Math.random().toString(36).substring(2,9),timestamp:Date.now()},i={...r.chatMessagesByInstance,[n]:[...o,s]},a=r.chatInstances.map(l=>{if(l.id===n){let c=e.sender==="user"?e.text.slice(0,60):l.preview,d=l.title==="Nueva conversaci\xF3n"&&e.sender==="user"?e.text.slice(0,40):l.title;return{...l,preview:c,title:d,messageCount:(l.messageCount||0)+1,updatedAt:Date.now()}}return l});return{chatMessagesByInstance:i,chatInstances:a}}),upsertChatMessage:(e,r)=>t(n=>{let o=n.activeChatId||"_default",s=n.chatMessagesByInstance[o]||[],i=s.findIndex(l=>l.id===e),a;return i>=0?(a=[...s],a[i]={...a[i],...r}):a=[...s,r],{chatMessagesByInstance:{...n.chatMessagesByInstance,[o]:a}}}),clearChatMessages:()=>t(e=>{let r=e.activeChatId||"_default";return{chatMessagesByInstance:{...e.chatMessagesByInstance,[r]:[]}}}),getChatMessages:()=>{let e=X.getState(),r=e.activeChatId||"_default";return e.chatMessagesByInstance[r]||[]},chatInstances:[],activeChatId:null,addChatInstance:e=>{let r=Date.now().toString(36)+Math.random().toString(36).substring(2,7),n=Date.now(),o=localStorage.getItem("decido_gemini_model")||void 0,s=localStorage.getItem("decido_selected_shell")||void 0;return t(i=>({chatInstances:[{id:r,title:e||"Nueva conversaci\xF3n",createdAt:n,updatedAt:n,model:o,shellType:s},...i.chatInstances],activeChatId:r})),r},removeChatInstance:e=>t(r=>{let{[e]:n,...o}=r.chatMessagesByInstance;return{chatInstances:r.chatInstances.filter(s=>s.id!==e),activeChatId:r.activeChatId===e?r.chatInstances.find(s=>s.id!==e)?.id??null:r.activeChatId,chatMessagesByInstance:o}}),renameChatInstance:(e,r)=>t(n=>({chatInstances:n.chatInstances.map(o=>o.id===e?{...o,title:r,updatedAt:Date.now()}:o)})),setActiveChatId:e=>t({activeChatId:e})}),{name:"playground-storage",storage:(0,mh.createJSONStorage)(()=>l$),partialize:t=>({showChat:t.showChat,logs:t.logs,inputValue:t.inputValue,prototypeBrand:t.prototypeBrand,isCreatorMode:t.isCreatorMode,isMuted:t.isMuted,selectedVoice:t.selectedVoice,isTerminalOpen:t.isTerminalOpen,isSidebarOpen:t.isSidebarOpen,step:t.step,selectedProfile:t.selectedProfile,savedSequences:t.savedSequences,chatMessagesByInstance:t.chatMessagesByInstance,chatInstances:t.chatInstances,activeChatId:t.activeChatId})}))});var cC={};Mo(cC,{useSuggestionsStore:()=>Yi});var aC,lC,Yi,gh=U(()=>{"use strict";aC=require("zustand"),lC=require("zustand/middleware"),Yi=(0,aC.create)()((0,lC.persist)((t,e)=>({seeds:["Expl\xEDcame c\xF3mo funciona este flujo","Crea un grafo de onboarding","Analiza el rendimiento del sistema"],generated:[],pluginSuggestions:{},addSeed:r=>t(n=>({seeds:[...n.seeds,r]})),removeSeed:r=>t(n=>({seeds:n.seeds.filter((o,s)=>s!==r)})),updateSeed:(r,n)=>t(o=>({seeds:o.seeds.map((s,i)=>i===r?n:s)})),setGenerated:r=>t({generated:r}),registerPluginSuggestions:(r,n)=>t(o=>({pluginSuggestions:{...o.pluginSuggestions,[r]:n}})),unregisterPluginSuggestions:r=>t(n=>{let o={...n.pluginSuggestions};return delete o[r],{pluginSuggestions:o}}),getAllSuggestions:()=>{let r=e(),n=Object.values(r.pluginSuggestions).flat();return[...r.generated,...r.seeds,...n]}}),{name:"decido-suggestions-store"}))});var ho,Wu,An,Be,u$,dC,uC=U(()=>{"use strict";ho=Re(require("react")),Wu=require("motion/react"),An=require("lucide-react");gh();Be=require("react/jsx-runtime"),u$=[{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",type:"Ultra-Fast"},{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro",type:"Deep-Reasoning"},{id:"gemini-3.1-flash-lite-preview",name:"Gemini 3.1 Flash Lite",type:"Cutting-Edge"}],dC=ho.default.memo(function({isOpen:e,onClose:r}){let{seeds:n,generated:o,addSeed:s,removeSeed:i,updateSeed:a,setGenerated:l}=Yi(),[c,d]=(0,ho.useState)(""),[u,f]=(0,ho.useState)(5),[p,h]=(0,ho.useState)(!1),[b,g]=(0,ho.useState)(null),[x,y]=(0,ho.useState)(()=>localStorage.getItem("google_gemini_api_key")||""),[m,v]=(0,ho.useState)(!1),[S,w]=(0,ho.useState)(()=>localStorage.getItem("decido_gemini_model")||"gemini-3-flash-preview"),C=(0,ho.useCallback)(T=>{w(T),localStorage.setItem("decido_gemini_model",T),fetch("http://localhost:3100/api/models/active",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model_id:T})}).catch(()=>console.warn("Orquestador local no expone /api/models/active a\xFAn."))},[]),A=(0,ho.useCallback)(()=>{c.trim()&&(s(c.trim()),d(""))},[c,s]),k=(0,ho.useCallback)(async()=>{if(n.length!==0){h(!0);try{let T=localStorage.getItem("google_gemini_api_key")||window.__DECIDO__?._apiKey||"",E=localStorage.getItem("decido_gemini_model")||"gemini-3-flash-preview";if(!T){console.warn("\u274C No API key for suggestions"),h(!1);return}let P=`Bas\xE1ndote en estas frases semilla, genera exactamente ${u} sugerencias similares para un chat de IA de productividad. Solo devuelve las sugerencias, una por l\xEDnea, sin numeraci\xF3n ni bullets:
|
|
3
|
+
|
|
4
|
+
${n.join(`
|
|
5
|
+
`)}`,O=((await(await fetch(`https://generativelanguage.googleapis.com/v1beta/models/${E}:generateContent?key=${T}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contents:[{parts:[{text:P}]}]})})).json())?.candidates?.[0]?.content?.parts?.[0]?.text||"").split(`
|
|
6
|
+
`).map(B=>B.trim()).filter(B=>B.length>3);l(O.slice(0,u))}catch(T){console.error("Error generating suggestions:",T)}finally{h(!1)}}},[n,u,l]),M=(0,ho.useCallback)(()=>{x.trim()?localStorage.setItem("google_gemini_api_key",x.trim()):localStorage.removeItem("google_gemini_api_key")},[x]);return(0,Be.jsx)(Wu.AnimatePresence,{children:e&&(0,Be.jsxs)(Be.Fragment,{children:[(0,Be.jsx)(Wu.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-surface-overlay backdrop-blur-xs z-200",style:{position:"fixed",inset:0,zIndex:200}}),(0,Be.jsxs)(Wu.motion.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",damping:30,stiffness:300},className:"fixed inset-y-0 left-0 w-full sm:w-[360px] bg-surface-secondary border-r border-border-default z-201 flex flex-col shadow-2xl",style:{position:"fixed",top:0,bottom:0,left:0,zIndex:201},children:[(0,Be.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-subtle",children:[(0,Be.jsx)("h2",{className:"text-sm font-bold text-text-primary",children:"\u2699\uFE0F Configuraci\xF3n"}),(0,Be.jsx)("button",{onClick:r,className:"w-7 h-7 rounded-full bg-surface-glass hover:bg-surface-glass flex items-center justify-center text-text-secondary hover:text-text-primary transition-colors",children:(0,Be.jsx)(An.X,{size:14})})]}),(0,Be.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-6",style:{scrollbarWidth:"thin",scrollbarColor:"rgba(255,255,255,0.15) transparent"},children:[(0,Be.jsxs)("section",{children:[(0,Be.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,Be.jsx)(An.Key,{size:14,className:"text-amber-400"}),(0,Be.jsx)("h3",{className:"text-xs font-semibold text-text-secondary uppercase tracking-wider",children:"API Key"})]}),(0,Be.jsxs)("div",{className:"flex gap-2",children:[(0,Be.jsx)("input",{type:m?"text":"password",value:x,onChange:T=>y(T.target.value),onBlur:M,placeholder:"AIzaSy...",className:"flex-1 bg-surface-glass border border-border-default rounded-lg px-3 py-2 text-xs text-text-primary placeholder-zinc-600 outline-hidden focus:border-border-strong font-mono"}),(0,Be.jsx)("button",{onClick:()=>v(!m),className:"px-2 rounded-lg text-[10px] text-text-muted hover:text-text-primary bg-surface-glass hover:bg-surface-glass border border-border-default transition-colors",children:m?"\u{1F648}":"\u{1F441}\uFE0F"})]})]}),(0,Be.jsxs)("section",{children:[(0,Be.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,Be.jsx)(An.BrainCircuit,{size:14,className:"text-emerald-400"}),(0,Be.jsx)("h3",{className:"text-xs font-semibold text-text-secondary uppercase tracking-wider",children:"Brain Router (Enjambre)"})]}),(0,Be.jsx)("div",{className:"flex flex-col gap-2",children:u$.map(T=>(0,Be.jsxs)("button",{onClick:()=>C(T.id),className:`flex items-center justify-between px-3 py-2 rounded-xl transition-all border ${S===T.id?"bg-emerald-500/10 border-emerald-500/30 shadow-[0_0_10px_rgba(16,185,129,0.2)]":"bg-surface-glass border-border-default hover:border-border-strong"}`,children:[(0,Be.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,Be.jsx)("span",{className:`text-xs font-bold ${S===T.id?"text-emerald-400":"text-text-primary"}`,children:T.name}),(0,Be.jsx)("span",{className:"text-[9px] font-mono text-text-muted uppercase tracking-wider",children:T.id})]}),(0,Be.jsx)("span",{className:`text-[9px] px-2 py-0.5 rounded-full font-bold uppercase tracking-widest ${S===T.id?"bg-emerald-500/20 text-emerald-300":"bg-surface-tertiary text-text-secondary"}`,children:T.type})]},T.id))})]}),(0,Be.jsxs)("section",{children:[(0,Be.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,Be.jsx)(An.Sparkles,{size:14,className:"text-cyan-400"}),(0,Be.jsx)("h3",{className:"text-xs font-semibold text-text-secondary uppercase tracking-wider",children:"Frases Semilla"}),(0,Be.jsx)("span",{className:"text-[10px] text-text-muted font-mono ml-auto",children:n.length})]}),(0,Be.jsx)("div",{className:"space-y-1.5 mb-3",children:n.map((T,E)=>(0,Be.jsxs)("div",{className:"flex items-center gap-1.5 group",children:[b===E?(0,Be.jsx)("input",{autoFocus:!0,value:T,onChange:P=>a(E,P.target.value),onBlur:()=>g(null),onKeyDown:P=>P.key==="Enter"&&g(null),className:"flex-1 bg-surface-glass border border-cyan-500/30 rounded-lg px-2.5 py-1.5 text-xs text-text-primary outline-hidden font-mono"}):(0,Be.jsx)("button",{onClick:()=>g(E),className:"flex-1 text-left px-2.5 py-1.5 rounded-lg text-xs text-text-secondary hover:text-text-primary hover:bg-surface-glass transition-colors font-mono truncate",children:T}),(0,Be.jsx)("button",{onClick:()=>i(E),className:"w-6 h-6 rounded-md text-text-muted hover:text-red-400 hover:bg-red-500/10 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-all shrink-0",children:(0,Be.jsx)(An.Trash2,{size:12})})]},E))}),(0,Be.jsxs)("div",{className:"flex gap-1.5",children:[(0,Be.jsx)("input",{value:c,onChange:T=>d(T.target.value),onKeyDown:T=>T.key==="Enter"&&A(),placeholder:"Nueva frase semilla...",className:"flex-1 bg-surface-glass border border-border-default rounded-lg px-2.5 py-1.5 text-xs text-text-primary placeholder-zinc-600 outline-hidden focus:border-border-strong font-mono"}),(0,Be.jsx)("button",{onClick:A,className:"w-8 h-8 rounded-lg bg-cyan-500/10 border border-cyan-500/20 text-cyan-400 hover:bg-cyan-500/20 flex items-center justify-center transition-colors",children:(0,Be.jsx)(An.Plus,{size:14})})]})]}),(0,Be.jsxs)("section",{children:[(0,Be.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,Be.jsx)(An.Sparkles,{size:14,className:"text-purple-400"}),(0,Be.jsx)("h3",{className:"text-xs font-semibold text-text-secondary uppercase tracking-wider",children:"Generar con AI"})]}),(0,Be.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,Be.jsx)("label",{className:"text-[10px] text-text-muted font-mono",children:"Cantidad:"}),(0,Be.jsx)("input",{type:"number",min:1,max:20,value:u,onChange:T=>f(Math.max(1,Math.min(20,parseInt(T.target.value)||5))),className:"w-14 bg-surface-glass border border-border-default rounded-lg px-2 py-1 text-xs text-text-primary outline-hidden text-center font-mono"}),(0,Be.jsxs)("button",{onClick:k,disabled:p||n.length===0,className:"flex-1 flex items-center justify-center gap-2 px-3 py-1.5 rounded-lg bg-purple-500/15 border border-purple-500/20 text-purple-300 hover:bg-purple-500/25 disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-xs font-semibold",children:[p?(0,Be.jsx)(An.Loader2,{size:14,className:"animate-spin"}):(0,Be.jsx)(An.Sparkles,{size:14}),p?"Generando...":"Generar Sugerencias"]})]}),o.length>0&&(0,Be.jsxs)("div",{className:"space-y-1 bg-surface-glass rounded-lg p-2 border border-border-subtle",children:[(0,Be.jsxs)("div",{className:"text-[9px] text-text-muted font-mono uppercase mb-1",children:["Generadas (",o.length,")"]}),o.map((T,E)=>(0,Be.jsx)("div",{className:"text-xs text-text-secondary font-mono px-2 py-1 rounded hover:bg-surface-glass transition-colors",children:T},E))]})]}),Object.keys(Yi.getState().pluginSuggestions).length>0&&(0,Be.jsxs)("section",{children:[(0,Be.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,Be.jsx)(An.Box,{size:14,className:"text-emerald-400"}),(0,Be.jsx)("h3",{className:"text-xs font-semibold text-text-secondary uppercase tracking-wider",children:"Plugins"})]}),Object.entries(Yi.getState().pluginSuggestions).map(([T,E])=>(0,Be.jsxs)("div",{className:"mb-2",children:[(0,Be.jsxs)("div",{className:"text-[10px] text-text-muted font-mono mb-1",children:[T," (",E.length,")"]}),E.map((P,N)=>(0,Be.jsx)("div",{className:"text-xs text-text-secondary font-mono px-2 py-1",children:P},N))]},T))]})]})]})]})})})});var pC={};Mo(pC,{PlaygroundAppSidebar:()=>bh});var Fl,Xi,en,fC,$e,f$,bh,ex=U(()=>{"use strict";Fl=Re(require("react")),Xi=require("motion/react"),en=require("lucide-react");ot();fC=require("@decido/chat");uC();$e=require("react/jsx-runtime"),f$=()=>{let[t,e]=(0,Fl.useState)(!1);return(0,$e.jsxs)("div",{className:"relative",onMouseLeave:()=>e(!1),children:[(0,$e.jsx)("button",{onClick:()=>e(!t),className:`w-8 h-8 rounded-lg flex items-center justify-center transition-colors shrink-0 ${t?"bg-surface-elevated text-text-primary":"text-text-muted hover:text-text-primary hover:bg-surface-glass"}`,title:"Herramientas de Desarrollador",children:(0,$e.jsx)(en.Wrench,{size:16})}),(0,$e.jsx)(Xi.AnimatePresence,{children:t&&(0,$e.jsxs)(Xi.motion.div,{initial:{opacity:0,scale:.9,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:10},transition:{type:"spring",stiffness:400,damping:25},className:"absolute bottom-full right-0 mb-2 flex flex-col gap-2 p-2 rounded-2xl bg-surface-elevated border border-border-default shadow-2xl origin-bottom z-50",children:[(0,$e.jsx)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("DECIDO_OPEN_SWARM_WIZARD")),className:"w-10 h-10 rounded-full bg-surface-secondary border border-border-default hover:border-cyan-400/50 flex items-center justify-center text-text-secondary hover:text-cyan-400 transition-all hover:shadow-[0_0_15px_rgba(6,182,212,0.3)]",title:"Configuraci\xF3n del Enjambre",children:(0,$e.jsx)("i",{className:"fas fa-cog text-sm"})}),(0,$e.jsx)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("DECIDO_TOGGLE_TOPOLOGY")),className:"w-10 h-10 rounded-full bg-surface-secondary border border-border-default hover:border-emerald-400/50 flex items-center justify-center text-text-secondary hover:text-emerald-400 transition-all hover:shadow-[0_0_15px_rgba(16,185,129,0.3)]",title:"Live Topology",children:(0,$e.jsx)(en.Network,{size:16})}),(0,$e.jsx)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("DECIDO_OPEN_MARKETPLACE")),className:"w-10 h-10 rounded-full bg-surface-secondary border border-border-default hover:border-indigo-400/50 flex items-center justify-center text-text-secondary hover:text-indigo-400 transition-all hover:shadow-[0_0_15px_rgba(99,102,241,0.3)]",title:"Plugin Marketplace",children:(0,$e.jsx)(en.PackageOpen,{size:16})}),(0,$e.jsx)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("DECIDO_TOGGLE_TW_EDITOR")),className:"w-10 h-10 rounded-full bg-surface-secondary border border-border-default hover:border-purple-400/50 flex items-center justify-center text-text-secondary hover:text-purple-400 transition-all hover:shadow-[0_0_15px_rgba(139,92,246,0.3)]",title:"Tailwind Editor",children:(0,$e.jsx)(en.Paintbrush,{size:16})})]})})]})},bh=Fl.default.memo(function({isOpen:e,onClose:r,menuSections:n=[],onSettings:o,onProfile:s,profileName:i="Usuario",profileAvatar:a}){let[l,c]=(0,Fl.useState)(""),[d,u]=(0,Fl.useState)(new Set),[f,p]=(0,Fl.useState)(!1),h=X(C=>C.chatInstances),b=X(C=>C.activeChatId),g=X(C=>C.addChatInstance),x=X(C=>C.removeChatInstance),y=X(C=>C.renameChatInstance),m=X(C=>C.setActiveChatId),v=C=>{u(A=>{let k=new Set(A);return k.has(C)?k.delete(C):k.add(C),k})},S=(C=!1)=>(0,$e.jsxs)("div",{className:"flex flex-col h-full bg-surface-secondary text-text-primary",children:[(0,$e.jsxs)("div",{className:"flex-none p-3 pt-4 space-y-2",children:[C&&(0,$e.jsx)("div",{className:"flex justify-end mb-1",children:(0,$e.jsx)("button",{onClick:r,className:"w-7 h-7 rounded-full bg-surface-glass hover:bg-surface-elevated flex items-center justify-center text-text-secondary hover:text-text-primary transition-colors",children:(0,$e.jsx)(en.X,{size:14})})}),(0,$e.jsxs)("div",{className:"relative",children:[(0,$e.jsx)(en.Search,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-text-muted"}),(0,$e.jsx)("input",{value:l,onChange:A=>c(A.target.value),placeholder:"Buscar conversaciones...",className:"w-full bg-surface-glass border border-border-subtle rounded-lg pl-8 pr-3 py-2 text-sm text-text-primary placeholder-text-muted outline-hidden focus:border-border-strong focus:bg-surface-glass transition-colors"}),l&&(0,$e.jsx)("button",{onClick:()=>c(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary",children:(0,$e.jsx)(en.X,{size:12})})]}),(0,$e.jsxs)("button",{onClick:()=>g(),className:"w-full flex items-center gap-2 px-3 py-2 rounded-lg bg-surface-glass border border-border-subtle hover:bg-surface-glass hover:border-border-default transition-colors text-sm text-text-primary hover:text-text-primary",children:[(0,$e.jsx)(en.Plus,{size:16}),(0,$e.jsx)("span",{children:"Nueva conversaci\xF3n"})]})]}),(0,$e.jsxs)("div",{className:"flex-1 overflow-y-auto px-3 pb-2 space-y-1",style:{scrollbarWidth:"thin",scrollbarColor:"rgba(255,255,255,0.15) transparent"},children:[(0,$e.jsx)(fC.ChatHistoryList,{chatInstances:h,activeChatId:b||"",searchQuery:l,setActiveChatId:m,renameChatInstance:y,removeChatInstance:x}),n.length>0&&(0,$e.jsx)("div",{className:"mt-4 pt-3 border-t border-border-subtle",children:n.map(A=>(0,$e.jsxs)("div",{className:"mb-3",children:[(0,$e.jsxs)("button",{onClick:()=>A.collapsible&&v(A.id),className:"flex items-center gap-1.5 px-2 py-1.5 text-[11px] font-semibold text-text-muted uppercase tracking-wider w-full hover:text-text-primary transition-colors",children:[A.icon,(0,$e.jsx)("span",{className:"flex-1 text-left",children:A.title}),A.collapsible&&(0,$e.jsx)(en.ChevronDown,{size:12,className:`transition-transform ${d.has(A.id)?"-rotate-90":""}`})]}),(0,$e.jsx)(Xi.AnimatePresence,{children:!d.has(A.id)&&(0,$e.jsx)(Xi.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:A.items.map(k=>(0,$e.jsxs)("button",{onClick:k.onClick,className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-sm transition-colors ${k.active?"bg-surface-glass text-text-primary":"text-text-secondary hover:bg-surface-glass hover:text-text-primary"}`,children:[k.icon,(0,$e.jsx)("span",{className:"flex-1 text-left truncate",children:k.label}),k.badge!==void 0&&(0,$e.jsx)("span",{className:"px-1.5 py-0.5 rounded-full bg-cyan-500/15 text-cyan-400 text-[10px] font-bold",children:k.badge})]},k.id))})})]},A.id))})]}),(0,$e.jsx)("div",{className:"flex-none border-t border-border-subtle px-3 py-2",children:(0,$e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,$e.jsxs)("button",{onClick:s,className:"flex-1 flex items-center gap-2 px-2 py-2 rounded-lg hover:bg-surface-glass transition-colors group",children:[(0,$e.jsx)("div",{className:"w-7 h-7 rounded-full bg-linear-to-br from-cyan-500 to-purple-600 flex items-center justify-center text-text-primary text-xs font-bold shrink-0",children:a||i.charAt(0).toUpperCase()}),(0,$e.jsx)("span",{className:"text-sm text-text-primary group-hover:text-text-primary truncate",children:i})]}),(0,$e.jsx)(f$,{}),(0,$e.jsx)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("DECIDO_OPEN_MCP_MODAL")),className:"w-8 h-8 rounded-lg text-text-muted hover:text-text-primary hover:bg-surface-glass flex items-center justify-center transition-colors shrink-0",title:"Configuraci\xF3n MCP",children:(0,$e.jsx)(en.Plug,{size:16})}),(0,$e.jsx)("button",{onClick:()=>p(!0),className:"w-8 h-8 rounded-lg text-text-muted hover:text-text-primary hover:bg-surface-glass flex items-center justify-center transition-colors shrink-0",title:"Configuraci\xF3n",children:(0,$e.jsx)(en.Settings,{size:16})})]})}),(0,$e.jsx)(dC,{isOpen:f,onClose:()=>p(!1)})]}),w=(0,$e.jsx)(Xi.AnimatePresence,{children:e&&(0,$e.jsxs)($e.Fragment,{children:[(0,$e.jsx)(Xi.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:r,className:"md:hidden fixed inset-0 bg-surface-overlay backdrop-blur-xs z-40"}),(0,$e.jsx)(Xi.motion.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",damping:30,stiffness:300},className:"md:hidden fixed inset-y-0 left-0 w-[380px] z-50 shadow-2xl",children:S(!0)})]})});return(0,$e.jsxs)($e.Fragment,{children:[w,e&&(0,$e.jsx)("div",{className:"hidden md:flex h-full w-full min-h-0",children:S(!1)})]})})});function xh(t){return p$[t]||Se.Command}function yh(t){return hC[t]||"text-white"}function mC(t){return{text:hC[t]||"text-white",bg:`bg-${t}-500/10`,border:`border-${t}-500/20`}}var Se,p$,hC,tx=U(()=>{"use strict";Se=require("lucide-react"),p$={Search:Se.Search,MessageSquare:Se.MessageSquare,BrainCircuit:Se.BrainCircuit,Sparkles:Se.Sparkles,Command:Se.Command,Terminal:Se.Terminal,Workflow:Se.Workflow,Zap:Se.Zap,Rocket:Se.Rocket,Network:Se.Network,FileText:Se.FileText,FolderOpen:Se.FolderOpen,Code:Se.Code,Database:Se.Database,ShoppingCart:Se.ShoppingCart,Building2:Se.Building2,Users:Se.Users,Activity:Se.Activity,Thermometer:Se.Thermometer,AlertTriangle:Se.AlertTriangle,TrendingUp:Se.TrendingUp,BarChart3:Se.BarChart3,PieChart:Se.PieChart,Gauge:Se.Gauge,Bell:Se.Bell,Cpu:Se.Cpu,HardDrive:Se.HardDrive,Server:Se.Server,Cloud:Se.Cloud,Wifi:Se.Wifi,PackageCheck:Se.PackageCheck,Lock:Se.Lock,Shield:Se.Shield,Settings:Se.Settings,Globe:Se.Globe,Mail:Se.Mail,Home:Se.Home,Layers:Se.Layers,Box:Se.Box};hC={emerald:"text-emerald-400",cyan:"text-cyan-400",purple:"text-purple-400",orange:"text-orange-400",yellow:"text-yellow-400",rose:"text-rose-400",red:"text-red-400",blue:"text-blue-400",indigo:"text-indigo-400",pink:"text-pink-400",amber:"text-amber-400",teal:"text-teal-400",lime:"text-lime-400",sky:"text-sky-400",violet:"text-violet-400",fuchsia:"text-fuchsia-400",white:"text-white"}});var gC,bi,bC,xC=U(()=>{"use strict";gC=Re(require("react"));tx();bi=require("react/jsx-runtime"),bC=gC.default.memo(function({suggestions:e,onSelect:r}){return(0,bi.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2.5 sm:gap-3 w-full min-w-0 max-w-full mt-3 sm:mt-4",children:e.map((n,o)=>{let s=xh(n.icon),i=yh(n.color);return(0,bi.jsx)("div",{className:"group relative flex flex-col p-3 sm:p-4 bg-surface-tertiary hover:bg-surface-elevated border border-border-subtle hover:border-border-default rounded-xl sm:rounded-2xl text-left transition-all overflow-hidden h-auto min-h-[6rem] sm:h-32 min-w-0",children:(0,bi.jsxs)("div",{className:"flex-1 cursor-pointer flex flex-col min-w-0",onClick:()=>r(n.command),children:[(0,bi.jsxs)("div",{className:"flex items-center gap-2 mb-1.5 sm:mb-2",children:[(0,bi.jsx)("div",{className:`p-1 sm:p-1.5 rounded-full bg-surface-glass shrink-0 ${i}`,children:(0,bi.jsx)(s,{size:12,className:"sm:w-3.5 sm:h-3.5"})}),(0,bi.jsx)("span",{className:`text-[11px] sm:text-xs font-bold truncate ${i}`,children:n.title})]}),(0,bi.jsxs)("p",{className:"text-xs sm:text-sm text-text-secondary flex-1 leading-snug line-clamp-2 sm:line-clamp-3 overflow-hidden break-words",children:['"',n.command,'"']})]})},o)})})})});var yC,vC,Ue,mo=U(()=>{"use strict";yC=require("zustand"),vC=require("zustand/middleware");Vu();Ue=(0,yC.create)()((0,vC.persist)((t,e)=>({instances:new Map,activeInstanceId:null,historyByInstance:new Map,upsertInstance:r=>{fn.store(`upsertInstance: ${r.id} (${r.shellType})`,{id:r.id,shellType:r.shellType,label:r.label}),t(n=>{let o=new Map(n.instances),s=o.get(r.id),i=new Map(n.historyByInstance);if(s?.data){let a=i.get(r.id)||{stack:[],index:-1},l=a.stack.slice(0,a.index+1);l.push({...s.data}),l.length>20&&l.shift(),i.set(r.id,{stack:l,index:l.length-1})}return o.set(r.id,{artifacts:[],activeArtifactIndex:0,createdAt:Date.now(),...s,...r}),{instances:o,activeInstanceId:r.id,historyByInstance:i}})},removeInstance:r=>{t(n=>{let o=new Map(n.instances);o.delete(r);let s=n.activeInstanceId===r?o.size>0?o.keys().next().value??null:null:n.activeInstanceId;return{instances:o,activeInstanceId:s}})},setActiveInstance:r=>t({activeInstanceId:r}),pushArtifact:(r,n)=>{t(o=>{let s=new Map(o.instances),i=s.get(r);if(!i)return o;let a={...n,updatedAt:Date.now()},l=[...i.artifacts,a];return s.set(r,{...i,artifacts:l,activeArtifactIndex:l.length-1}),{instances:s}})},updateArtifact:(r,n,o)=>{t(s=>{let i=new Map(s.instances),a=i.get(r);if(!a)return s;let l=a.artifacts.map(c=>c.id===n?{...c,data:{...c.data,...o},updatedAt:Date.now()}:c);return i.set(r,{...a,artifacts:l}),{instances:i}})},setActiveArtifact:(r,n)=>{t(o=>{let s=new Map(o.instances),i=s.get(r);return i?(s.set(r,{...i,activeArtifactIndex:Math.max(0,Math.min(n,i.artifacts.length-1))}),{instances:s}):o})},removeArtifact:(r,n)=>{t(o=>{let s=new Map(o.instances),i=s.get(r);if(!i)return o;let a=i.artifacts.filter(l=>l.id!==n);return s.set(r,{...i,artifacts:a,activeArtifactIndex:Math.min(i.activeArtifactIndex,Math.max(0,a.length-1))}),{instances:s}})},getInstance:r=>e().instances.get(r),getInstances:()=>Array.from(e().instances.values()),getActiveInstance:()=>{let{instances:r,activeInstanceId:n}=e();return n?r.get(n):void 0},undo:r=>{let n=r||e().activeInstanceId;n&&t(o=>{let s=o.historyByInstance.get(n);if(!s||s.index<0)return o;let i=new Map(o.instances),a=i.get(n);if(!a)return o;let l=new Map(o.historyByInstance),c=s.stack[s.index];return fn.store(`undo: ${n} \u2192 version ${s.index}/${s.stack.length}`,{instanceId:n}),i.set(n,{...a,data:{...c}}),l.set(n,{...s,index:s.index-1}),{instances:i,historyByInstance:l}})},redo:r=>{let n=r||e().activeInstanceId;n&&t(o=>{let s=o.historyByInstance.get(n);if(!s||s.index>=s.stack.length-1)return o;let i=new Map(o.instances),a=i.get(n);if(!a)return o;let l=new Map(o.historyByInstance),c=s.index+1,d=s.stack[c];return fn.store(`redo: ${n} \u2192 version ${c+1}/${s.stack.length}`,{instanceId:n}),i.set(n,{...a,data:{...d}}),l.set(n,{...s,index:c}),{instances:i,historyByInstance:l}})},canUndo:r=>{let n=r||e().activeInstanceId;if(!n)return!1;let o=e().historyByInstance.get(n);return!!o&&o.index>=0},canRedo:r=>{let n=r||e().activeInstanceId;if(!n)return!1;let o=e().historyByInstance.get(n);return!!o&&o.index<o.stack.length-1},getHistoryInfo:r=>{let n=r||e().activeInstanceId;if(!n)return{current:0,total:0};let o=e().historyByInstance.get(n);return o?{current:o.index+2,total:o.stack.length+1}:{current:0,total:0}}}),{name:"decido-morph-instances",storage:{getItem:t=>{let e=localStorage.getItem(t);if(!e)return null;let r=JSON.parse(e);return r.state?.instances&&(r.state.instances=new Map(r.state.instances)),r},setItem:(t,e)=>{let r={...e,state:{...e.state,instances:Array.from(e.state.instances.entries())}};localStorage.setItem(t,JSON.stringify(r))},removeItem:t=>localStorage.removeItem(t)},partialize:t=>({instances:t.instances,activeInstanceId:t.activeInstanceId})}))});var wC,SC,h$,Mn,xi=U(()=>{"use strict";wC=require("zustand"),SC=require("zustand/middleware"),h$=[{id:"builtin_status_card",name:"Status Card",category:"card",schema:{type:"div",props:{className:"bg-zinc-900/80 border border-border-default rounded-xl p-4 backdrop-blur-xs"},children:[{type:"div",props:{className:"flex items-center gap-2 mb-2"},children:[{type:"span",props:{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}},{type:"span",props:{className:"text-xs font-mono text-text-secondary uppercase tracking-wider"},children:"{{title}}"}]},{type:"h3",props:{className:"text-2xl font-bold text-white"},children:"{{value}}"},{type:"p",props:{className:"text-xs text-text-muted mt-1"},children:"{{subtitle}}"}]},dataContract:{inputs:{title:{type:"string",description:"Card title"},value:{type:"string",description:"Main value"},subtitle:{type:"string",description:"Description"}},outputs:{}},tags:["status","metric","dashboard"],source:"built-in",createdAt:Date.now(),updatedAt:Date.now()},{id:"builtin_alert_banner",name:"Alert Banner",category:"alert",schema:{type:"div",props:{className:"flex items-center gap-3 p-3 rounded-lg border border-amber-500/20 bg-amber-500/5"},children:[{type:"span",props:{className:"text-amber-400 text-lg"},children:"\u26A0\uFE0F"},{type:"div",children:[{type:"p",props:{className:"text-sm font-semibold text-amber-200"},children:"{{title}}"},{type:"p",props:{className:"text-xs text-amber-300/70"},children:"{{message}}"}]}]},dataContract:{inputs:{title:{type:"string",description:"Alert title"},message:{type:"string",description:"Alert message"}},outputs:{}},tags:["alert","warning","notification"],source:"built-in",createdAt:Date.now(),updatedAt:Date.now()},{id:"builtin_input_form",name:"Text Input Form",category:"form",schema:{type:"div",props:{className:"bg-zinc-900/80 border border-border-default rounded-xl p-4 space-y-3"},children:[{type:"label",props:{className:"text-sm text-text-primary font-medium"},children:"{{label}}"},{type:"input",props:{className:"w-full bg-zinc-800 border border-border-default rounded-lg px-3 py-2 text-white text-sm focus:border-purple-500/50 outline-hidden transition-colors",placeholder:"{{placeholder}}"},onAction:{command:"engine:setVariable",payload:{target:"{{variableKey}}"}}},{type:"button",props:{className:"w-full py-2 bg-purple-500 hover:bg-purple-400 text-white text-sm font-medium rounded-lg transition-colors"},children:"{{buttonText}}",onAction:{command:"engine:completeNode",payload:{handle:"success"}}}]},dataContract:{inputs:{label:{type:"string",description:"Input label"},placeholder:{type:"string",description:"Placeholder text"},variableKey:{type:"string",description:"Target variable key"},buttonText:{type:"string",description:"Submit button text"}},outputs:{value:{type:"string"}}},tags:["form","input","interactive"],source:"built-in",createdAt:Date.now(),updatedAt:Date.now()},{id:"builtin_data_table",name:"Data Table",category:"table",schema:{type:"div",props:{className:"bg-zinc-900/80 border border-border-default rounded-xl overflow-hidden"},children:[{type:"div",props:{className:"px-4 py-3 border-b border-border-subtle"},children:[{type:"h4",props:{className:"text-sm font-semibold text-white"},children:"{{title}}"}]},{type:"table",props:{className:"w-full"},children:[{type:"thead",children:[{type:"tr",props:{className:"text-xs text-text-muted uppercase"},children:"{{headers}}"}]},{type:"tbody",props:{className:"text-sm text-text-primary"},children:"{{rows}}"}]}]},dataContract:{inputs:{title:{type:"string",description:"Table title"},headers:{type:"string",description:"Column headers"},rows:{type:"string",description:"Table rows data"}},outputs:{}},tags:["table","data","list"],source:"built-in",createdAt:Date.now(),updatedAt:Date.now()}],Mn=(0,wC.create)()((0,SC.persist)((t,e)=>({components:Object.fromEntries(h$.map(r=>[r.id,r])),addComponent:r=>t(n=>({components:{...n.components,[r.id]:r}})),removeComponent:r=>t(n=>{let{[r]:o,...s}=n.components;return{components:s}}),updateComponent:(r,n)=>t(o=>{let s=o.components[r];return s?{components:{...o.components,[r]:{...s,...n,updatedAt:Date.now()}}}:o}),getByCategory:r=>Object.values(e().components).filter(n=>n.category===r),getBySource:r=>Object.values(e().components).filter(n=>n.source===r)}),{name:"decido-ui-components"}))});function yi(t,e,r){fd.set(t,e),r?rx.set(t,r):NC[t]&&rx.set(t,NC[t])}function Pa(t){return fd.get(t)}function kC(t){return fd.has(t)}function pd(){return Array.from(fd.keys())}function Hl(t){return rx.get(t)||{icon:"\u{1F4E6}",color:"#71717a",label:t}}function EC(t,e){let r=n=>CC.default.createElement(e,{...n.data||{},...n});fd.set(t,r)}function TC(t){return fd.get(t)}var CC,rx,NC,fd,Vl=U(()=>{"use strict";CC=Re(require("react")),rx=new Map,NC={markdown:{icon:"\u{1F4DD}",color:"#10b981",label:"Markdown"},iframe:{icon:"\u{1F5A5}\uFE0F",color:"#6b7280",label:"iFrame"},"nexusai-preview":{icon:"\u{1F310}",color:"#3b82f6",label:"Web Preview"},"shell-vscode":{icon:"\u{1F4BB}",color:"#007acc",label:"VS Code"},"shell-canvas":{icon:"\u{1F5BC}\uFE0F",color:"#f59e0b",label:"Canvas"},"shell-theme-editor":{icon:"\u{1F3A8}",color:"#a855f7",label:"Theme Editor"}},fd=new Map});var ox={};Mo(ox,{INTENT_PATTERNS:()=>vh,getIntentPatterns:()=>nx,registerIntentPattern:()=>m$,useIntentLens:()=>Uu});function m$(t){AC.push(t)}function nx(){return[...vh,...AC]}function g$(t){if(!t.trim())return[];let e=[];for(let{type:o,pattern:s,color:i}of vh){let a=new RegExp(s.source,s.flags),l;for(;(l=a.exec(t))!==null;)e.push({start:l.index,end:l.index+l[0].length,intent:o,color:i})}e.sort((o,s)=>o.start-s.start);let r=[],n=0;for(let o of e)o.start<n||(o.start>n&&r.push({text:t.slice(n,o.start),intent:"NONE",color:null,isMatch:!1}),r.push({text:t.slice(o.start,o.end),intent:o.intent,color:o.color,isMatch:!0}),n=o.end);return n<t.length&&r.push({text:t.slice(n),intent:"NONE",color:null,isMatch:!1}),r}function Uu(t){return(0,IC.useMemo)(()=>{let r=g$(t),n=new Map;for(let o of r)if(o.isMatch&&o.intent!=="NONE"){let s=n.get(o.intent);if(s)s.matchedPhrases.push(o.text);else{let i=vh.find(a=>a.type===o.intent);n.set(o.intent,{type:o.intent,label:i.label,color:i.color,icon:i.icon,matchedPhrases:[o.text]})}}return{tokens:r,detectedIntents:Array.from(n.values()),hasIntents:n.size>0,primaryIntent:n.size>0?Array.from(n.values())[0]:null}},[t])}var IC,vh,AC,hd=U(()=>{"use strict";IC=require("react"),vh=[{type:"EDIT_GRAPH",pattern:/\b(agrega|suma|añade|conecta|modifica|cambia|elimina|borra|parchea|actualiza|inserta|mueve)\b/gi,label:"Editar Grafo",icon:"\u270F\uFE0F",color:"#f59e0b",examples:["Agrega un nodo de validaci\xF3n despu\xE9s de login","Conecta el nodo de pago con el de confirmaci\xF3n","Elimina el paso de verificaci\xF3n duplicado"]},{type:"CREATE_GRAPH",pattern:/\b(grafo|flujo|nodos|blueprint|escenario|onboarding|proceso|workflow|pipeline|trigger|subflujo|orquest)\b|\b(crea|diseña|genera|construye)\s+(un|una|el|la|los|las)\b/gi,label:"Crear Grafo",icon:"\u{1F517}",color:"#10b981",examples:["Crea un flujo de onboarding para nuevos usuarios","Dise\xF1a un pipeline de procesamiento de datos","Genera un blueprint con 5 nodos de decisi\xF3n"]},{type:"UI_ACTION",pattern:/\b(shell|tema|theme|sidebar|panel|activity\s*bar|status\s*bar|top\s*bar|notificaci[oó]n|shortcut|atajo|layout)\b|\b(configura)\s+(el|la|los|las)\b/gi,label:"Acci\xF3n UI",icon:"\u{1F3A8}",color:"#3b82f6",examples:["Abre el panel de sidebar","Configura el tema oscuro","Cambia el layout a pantalla completa"]},{type:"MCP_ACTION",pattern:/\b(ejecuta|invoca|llama|herramienta|tool|api|endpoint)\b/gi,label:"Acci\xF3n MCP",icon:"\u26A1",color:"#a855f7",examples:["Ejecuta la herramienta de an\xE1lisis de c\xF3digo","Invoca el endpoint de validaci\xF3n","Llama al API de b\xFAsqueda sem\xE1ntica"]},{type:"NAVIGATE",pattern:/\b(landing|página\s*web|web\s*page|website|diseño\s*web|sitio|homepage|portfolio|dashboard\s*ui|ui\s*design|mockup|prototipo\s*web)\b/gi,label:"Web Preview",icon:"\u{1F310}",color:"#06b6d4",examples:["Crea una landing page para un SaaS de IA","Dise\xF1a un portfolio moderno con tema oscuro","Genera un dashboard UI para m\xE9tricas de ventas","Crea una p\xE1gina de pricing con 3 planes"]}],AC=[]});function RC(){let[t,e]=(0,vi.useState)(()=>localStorage.getItem(MC)||"gemini-3-flash-preview"),[r,n]=(0,vi.useState)({});(0,vi.useEffect)(()=>{let a=!0,l=async()=>{try{let d=await(0,PC.getProviderStatuses)();if(!a)return;let u={};for(let[f,p]of Object.entries(d))u[f]=p==="available"?"online":"offline";n(u)}catch{}};l();let c=setInterval(l,3e4);return()=>{a=!1,clearInterval(c)}},[]);let o=(0,vi.useMemo)(()=>Object.entries(b$).map(([a,l])=>{let c=x$[a]||{label:a,icon:"\u{1F916}",color:"#888",isLocal:!1};return{provider:a,label:c.label,icon:c.icon,color:c.color,isLocal:c.isLocal,models:l,status:r[a]||"unknown"}}),[r]),s=(0,vi.useMemo)(()=>{for(let a of o){let l=a.models.find(c=>c.id===t);if(l)return{model:l,group:a}}return{model:{id:t,label:t,provider:"unknown",tag:"",isLocal:!1},group:o[0]||null}},[t,o]),i=(0,vi.useCallback)(a=>{e(a),localStorage.setItem(MC,a),typeof window<"u"&&window.__DECIDO__&&(window.__DECIDO__.selectedModel=a)},[]);return{selectedModelId:t,selectedModel:s.model,selectedProvider:s.group,providerGroups:o,selectModel:i,providerStatuses:r}}var vi,PC,b$,x$,MC,DC=U(()=>{"use strict";vi=require("react"),PC=require("@decido/kernel-bridge"),b$={ollama:[{id:"qwen2.5:7b",label:"Qwen 2.5 7B",provider:"ollama",tag:"local",isLocal:!0},{id:"llama3.1:8b",label:"Llama 3.1 8B",provider:"ollama",tag:"local",isLocal:!0},{id:"codellama:7b",label:"CodeLlama 7B",provider:"ollama",tag:"code",isLocal:!0},{id:"mistral:7b",label:"Mistral 7B",provider:"ollama",tag:"local",isLocal:!0}],gemini:[{id:"gemini-3-flash-preview",label:"3.0 Flash",provider:"gemini",tag:"fast",isLocal:!1},{id:"gemini-3.1-pro-preview",label:"3.1 Pro",provider:"gemini",tag:"smart",isLocal:!1},{id:"gemini-3.1-flash-lite-preview",label:"3.1 Flash Lite",provider:"gemini",tag:"stable",isLocal:!1}],anthropic:[{id:"claude-sonnet-4-20250514",label:"Sonnet 4",provider:"anthropic",tag:"balanced",isLocal:!1},{id:"claude-3-5-haiku-20241022",label:"3.5 Haiku",provider:"anthropic",tag:"fast",isLocal:!1}],openai:[{id:"gpt-4o",label:"GPT-4o",provider:"openai",tag:"smart",isLocal:!1},{id:"gpt-4o-mini",label:"GPT-4o Mini",provider:"openai",tag:"fast",isLocal:!1}]},x$={ollama:{label:"Ollama",icon:"\u{1F999}",color:"#10b981",isLocal:!0},gemini:{label:"Gemini",icon:"\u2728",color:"#3b82f6",isLocal:!1},anthropic:{label:"Claude",icon:"\u{1F9E0}",color:"#a855f7",isLocal:!1},openai:{label:"OpenAI",icon:"\u26A1",color:"#06b6d4",isLocal:!1},mlx:{label:"MLX",icon:"\u{1F34E}",color:"#f59e0b",isLocal:!0}},MC="decido_ai_model"});var wh,Sh,Nh,tn,OC,_C=U(()=>{"use strict";wh=Re(require("react")),Sh=require("motion/react"),Nh=require("lucide-react");hd();tn=require("react/jsx-runtime"),OC=wh.default.memo(function({onSelect:e}){let r=nx(),[n,o]=(0,wh.useState)(null);return(0,tn.jsxs)("div",{className:"w-full bg-surface-tertiary border border-border-default rounded-xl overflow-hidden shadow-2xl",children:[(0,tn.jsxs)("div",{className:"px-3 py-2 flex items-center gap-2 border-b border-border-subtle",children:[(0,tn.jsx)(Nh.Zap,{size:12,className:"text-cyan-400"}),(0,tn.jsx)("span",{className:"text-[10px] text-text-muted font-mono uppercase tracking-wider",children:"Intenciones Disponibles"})]}),(0,tn.jsxs)("div",{className:"max-h-[240px] overflow-y-auto custom-scrollbar",children:[r.map(s=>(0,tn.jsxs)("div",{className:"border-b border-border-subtle last:border-0",children:[(0,tn.jsxs)("button",{onClick:()=>o(n===s.type?null:s.type),className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-surface-glass transition-colors",children:[(0,tn.jsx)("span",{className:"text-base leading-none",children:s.icon}),(0,tn.jsx)("span",{className:"font-semibold text-text-primary flex-1 text-left",children:s.label}),(0,tn.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:s.color}}),(0,tn.jsx)(Nh.ChevronDown,{size:12,className:`text-text-muted transition-transform ${n===s.type?"rotate-180":""}`})]}),(0,tn.jsx)(Sh.AnimatePresence,{children:n===s.type&&(0,tn.jsx)(Sh.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:(0,tn.jsx)("div",{className:"px-3 pb-2 space-y-1",children:s.examples.map((i,a)=>(0,tn.jsxs)("button",{onClick:()=>e(i),className:"w-full text-left px-2.5 py-1.5 rounded-lg text-[11px] text-text-secondary hover:text-text-primary hover:bg-surface-glass transition-colors font-mono leading-snug flex items-center gap-2 group",children:[(0,tn.jsx)("span",{className:"w-1 h-1 rounded-full shrink-0 opacity-40 group-hover:opacity-100 transition-opacity",style:{background:s.color}}),(0,tn.jsx)("span",{className:"flex-1",children:i}),(0,tn.jsx)("span",{className:"text-[9px] text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"\u21B5"})]},a))})})})]},s.type)),r.length===0&&(0,tn.jsx)("div",{className:"px-3 py-4 text-xs text-text-muted italic text-center",children:"Sin intenciones registradas"})]})]})})});function LC({group:t,selectedModelId:e,onSelect:r}){return(0,gr.jsxs)("div",{children:[(0,gr.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 text-[10px] font-semibold text-text-secondary",children:[(0,gr.jsx)("span",{children:t.icon}),(0,gr.jsx)("span",{children:t.label}),(0,gr.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ml-auto ${v$[t.status]}`})]}),t.models.map(n=>(0,gr.jsxs)("button",{type:"button",onClick:o=>{o.stopPropagation(),r(n.id)},className:`w-full text-left px-3 py-2 text-xs flex items-center justify-between transition-colors
|
|
7
|
+
${e===n.id?"text-text-primary":"text-text-secondary hover:bg-surface-glass hover:text-text-primary"}`,style:e===n.id?{background:`${t.color}20`}:void 0,children:[(0,gr.jsx)("span",{className:"font-mono truncate",children:n.label}),n.tag&&(0,gr.jsx)("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full font-semibold shrink-0 ${y$[n.tag]||"bg-surface-glass text-text-muted"}`,children:n.tag})]},n.id))]})}var Ra,Ch,gr,y$,v$,BC,zC=U(()=>{"use strict";Ra=Re(require("react")),Ch=require("lucide-react"),gr=require("react/jsx-runtime"),y$={fast:"bg-cyan-500/20 text-cyan-400",smart:"bg-purple-500/20 text-purple-400",stable:"bg-emerald-500/20 text-emerald-400",new:"bg-emerald-500/20 text-emerald-400",code:"bg-amber-500/20 text-amber-400",local:"bg-emerald-500/15 text-emerald-400",balanced:"bg-purple-500/15 text-purple-400",vision:"bg-pink-500/20 text-pink-400",audio:"bg-amber-500/20 text-amber-400",lite:"bg-surface-glass text-text-secondary"},v$={online:"bg-emerald-400 shadow-[0_0_6px_rgba(52,211,153,0.5)]",offline:"bg-red-400/60",unknown:"bg-surface-tertiary"},BC=Ra.default.memo(function({selectedModelId:e,selectedModel:r,providerGroups:n,onSelect:o}){let[s,i]=(0,Ra.useState)(!1),a=(0,Ra.useRef)(null);(0,Ra.useEffect)(()=>{if(!s)return;let d=u=>{a.current&&!a.current.contains(u.target)&&i(!1)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[s]);let l=n.filter(d=>d.isLocal),c=n.filter(d=>!d.isLocal);return(0,gr.jsxs)("div",{ref:a,className:"relative",children:[(0,gr.jsxs)("button",{type:"button",onClick:d=>{d.stopPropagation(),i(!s)},className:`flex items-center gap-1.5 px-2 py-1.5 rounded-xl text-text-muted
|
|
8
|
+
hover:text-text-primary hover:bg-surface-glass transition-all text-[10px] font-mono`,title:`Modelo AI: ${r.label}`,children:[(0,gr.jsx)(Ch.Cpu,{size:14}),(0,gr.jsx)(Ch.ChevronDown,{size:10})]}),s&&(0,gr.jsxs)("div",{className:`absolute left-0 w-64 bg-white/90 dark:bg-surface-tertiary border border-black/[0.06] dark:border-border-default
|
|
9
|
+
rounded-xl shadow-xl dark:shadow-2xl z-50 max-h-[360px] overflow-y-auto custom-scrollbar`,style:{bottom:"100%",marginBottom:"0.5rem"},children:[l.length>0&&(0,gr.jsxs)(gr.Fragment,{children:[(0,gr.jsxs)("div",{className:`px-3 py-1.5 text-[9px] text-text-muted font-mono uppercase tracking-wider
|
|
10
|
+
border-b border-border-subtle flex items-center gap-1.5`,children:[(0,gr.jsx)("span",{className:"text-emerald-400",children:"\u25CF"})," Local"]}),l.map(d=>(0,gr.jsx)(LC,{group:d,selectedModelId:e,onSelect:u=>{o(u),i(!1)}},d.provider))]}),c.length>0&&(0,gr.jsxs)(gr.Fragment,{children:[(0,gr.jsxs)("div",{className:`px-3 py-1.5 text-[9px] text-text-muted font-mono uppercase tracking-wider
|
|
11
|
+
border-b border-border-subtle flex items-center gap-1.5`,children:[(0,gr.jsx)("span",{className:"text-cyan-400",children:"\u2601"})," Cloud (BYOK)"]}),c.map(d=>(0,gr.jsx)(LC,{group:d,selectedModelId:e,onSelect:u=>{o(u),i(!1)}},d.provider))]})]})]})})});var Ko,gs,et,$C,FC=U(()=>{"use strict";Ko=Re(require("react")),gs=require("lucide-react");Vl();zC();et=require("react/jsx-runtime"),$C=Ko.default.memo(function({selectedModelId:e,selectedModel:r,providerGroups:n,onModelSelect:o,selectedShell:s,onShellSelect:i,showCanvas:a,setShowCanvas:l,prototypeBrand:c="decido",setPrototypeBrand:d,intentEnabled:u,onIntentToggle:f,showIntentPanel:p,onIntentPanelToggle:h}){let[b,g]=(0,Ko.useState)(!1),[x,y]=(0,Ko.useState)(!1),m=(0,Ko.useRef)(null),v=(0,Ko.useRef)(null),S=(0,Ko.useMemo)(()=>{try{return pd()}catch{return[]}},[]),w=()=>{if(!d)return;let k=["startup_demo","enterprise_demo","industrial_demo"];d(k[(k.indexOf(c)+1)%k.length])};(0,Ko.useEffect)(()=>{if(!b)return;let k=M=>{m.current&&!m.current.contains(M.target)&&g(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[b]),(0,Ko.useEffect)(()=>{if(!x)return;let k=M=>{v.current&&!v.current.contains(M.target)&&y(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[x]);let C=s?Hl(s):null,A=a||u||p;return(0,et.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-0.5 sm:gap-1 xl:gap-2 relative flex-1 min-w-0",children:[(0,et.jsx)(BC,{selectedModelId:e,selectedModel:r,providerGroups:n,onSelect:o}),(0,et.jsx)("div",{className:"w-px h-4 bg-surface-glass/80 mx-1"}),(0,et.jsxs)("div",{ref:v,className:"relative",children:[(0,et.jsxs)("button",{type:"button",onClick:k=>{k.stopPropagation(),y(!x),g(!1)},className:`flex items-center gap-1 px-2 py-1.5 rounded-xl hover:bg-surface-glass transition-all text-[10px] font-mono
|
|
12
|
+
${s?"":"text-text-muted hover:text-cyan-400"}`,style:s&&C?{color:C.color}:void 0,title:`Destino de salida: ${C?.label||s||"Ninguna (chat)"}`,children:[(0,et.jsx)("span",{className:"text-sm",children:C?.icon||"\u{1F4AC}"}),(0,et.jsx)(gs.ChevronDown,{size:10})]}),x&&(0,et.jsxs)("div",{className:`absolute left-1/2 -translate-x-1/2 sm:left-auto sm:translate-x-0 w-[220px] bg-white/95 dark:bg-surface-tertiary border border-black/[0.06] dark:border-border-default
|
|
13
|
+
rounded-2xl shadow-xl dark:shadow-2xl z-[100] max-h-[300px] overflow-y-auto custom-scrollbar flex flex-col backdrop-blur-xl`,style:{bottom:"100%",marginBottom:"0.6rem"},children:[(0,et.jsx)("div",{className:"px-3 py-2 text-[10px] text-text-muted font-mono uppercase tracking-wider bg-surface-base/50",children:"Destino de Salida"}),(0,et.jsxs)("div",{className:"p-1 pb-2",children:[(0,et.jsxs)("button",{type:"button",onClick:k=>{k.stopPropagation(),i(null),y(!1)},className:`w-full text-left px-3 py-2.5 rounded-xl text-xs transition-colors font-mono flex items-center gap-2.5
|
|
14
|
+
${s?"text-text-secondary hover:bg-surface-glass hover:text-text-primary":"bg-cyan-500/10 text-cyan-400 font-semibold"}`,children:[(0,et.jsx)("span",{className:"text-base leading-none w-4 text-center",children:"\u{1F4AC}"}),(0,et.jsx)("span",{children:"Ninguna (Chat)"})]}),(0,et.jsx)("div",{className:"h-px bg-border-subtle my-1 mx-1"}),S.map(k=>{let M=Hl(k);return(0,et.jsxs)("button",{type:"button",onClick:T=>{T.stopPropagation(),i(k),y(!1)},className:`w-full text-left px-3 py-2.5 mt-0.5 rounded-xl text-xs transition-colors font-mono flex items-center gap-2.5
|
|
15
|
+
${s===k?"text-text-primary font-semibold":"text-text-secondary hover:bg-surface-glass hover:text-text-primary"}`,style:s===k?{background:`${M.color}20`}:void 0,children:[(0,et.jsx)("span",{className:"text-base leading-none w-4 text-center",children:M.icon}),(0,et.jsx)("span",{className:"flex-1 truncate",children:M.label}),(0,et.jsx)("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:M.color}})]},k)})]})]})]}),(0,et.jsx)("div",{className:"w-px h-4 bg-surface-glass/80 mx-1"}),(0,et.jsxs)("div",{ref:m,className:"relative",children:[(0,et.jsxs)("button",{type:"button",onClick:k=>{k.stopPropagation(),g(!b),y(!1)},className:`w-8 h-8 rounded-xl flex items-center justify-center transition-all relative
|
|
16
|
+
${b||A?"text-text-primary bg-surface-glass":"text-text-secondary hover:text-text-primary hover:bg-surface-glass"}`,title:"Opciones del Agente",children:[(0,et.jsx)(gs.Settings2,{size:16}),A&&(0,et.jsx)("div",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 rounded-full bg-cyan-400"})]}),b&&(0,et.jsxs)("div",{className:`absolute left-1/2 -translate-x-1/2 sm:left-auto sm:translate-x-0 sm:-right-2 w-[240px] sm:w-[260px] bg-white/95 dark:bg-surface-tertiary border border-black/[0.06] dark:border-border-default
|
|
17
|
+
rounded-2xl shadow-xl dark:shadow-2xl z-[100] max-h-[380px] overflow-y-auto custom-scrollbar flex flex-col backdrop-blur-xl`,style:{bottom:"100%",marginBottom:"0.6rem"},children:[(0,et.jsx)("div",{className:"px-3 py-2 text-[10px] text-text-muted font-mono uppercase tracking-wider bg-surface-base/50",children:"Agente y Contexto"}),(0,et.jsxs)("div",{className:"p-1",children:[(0,et.jsxs)("button",{type:"button",onClick:k=>{k.stopPropagation(),f()},className:`w-full text-left px-3 py-2.5 rounded-xl text-xs transition-colors font-mono flex items-center justify-between group
|
|
18
|
+
${u?"text-emerald-500 bg-emerald-500/10":"text-text-secondary hover:bg-surface-glass hover:text-text-primary"}`,children:[(0,et.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,et.jsx)(gs.Brain,{size:15}),(0,et.jsx)("span",{children:"Interpretar intenciones"})]}),(0,et.jsx)("div",{className:`w-7 h-4 rounded-full flex items-center p-0.5 transition-colors border ${u?"bg-emerald-500 border-emerald-500/0":"bg-surface-glass border-border-default group-hover:bg-border-subtle"}`,children:(0,et.jsx)("div",{className:`w-3 h-3 rounded-full bg-white transition-transform ${u?"translate-x-[12px]":"translate-x-0"}`})})]}),(0,et.jsxs)("button",{type:"button",onClick:k=>{k.stopPropagation(),h(),g(!1)},className:"w-full text-left px-3 py-2.5 mt-0.5 rounded-xl text-xs text-text-secondary hover:bg-surface-glass hover:text-cyan-500 transition-colors font-mono flex items-center gap-2.5",children:[(0,et.jsx)(gs.Zap,{size:15}),(0,et.jsx)("span",{children:"Explorar cat\xE1logo"})]})]}),(0,et.jsx)("div",{className:"h-px bg-border-subtle"}),(0,et.jsx)("div",{className:"px-3 py-2 text-[10px] text-text-muted font-mono uppercase tracking-wider bg-surface-base/50",children:"Entorno Visual"}),(0,et.jsxs)("div",{className:"p-1 pb-2",children:[l&&(0,et.jsxs)("button",{type:"button",onClick:k=>{k.stopPropagation(),l(!a),g(!1)},className:`w-full text-left px-3 py-2.5 rounded-xl text-xs transition-colors font-mono flex items-center justify-between
|
|
19
|
+
${a?"text-primary bg-primary/10":"text-text-secondary hover:bg-surface-glass hover:text-text-primary"}`,children:[(0,et.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,et.jsx)(gs.MonitorPlay,{size:15}),(0,et.jsx)("span",{children:"Lienzo (Canvas)"})]}),a&&(0,et.jsx)("div",{className:"w-2 h-2 rounded-full bg-primary"})]}),d&&(0,et.jsx)("button",{type:"button",onClick:k=>{k.stopPropagation(),w()},className:"w-full mt-0.5 text-left px-3 py-2.5 rounded-xl text-xs text-amber-500 hover:bg-surface-glass transition-colors font-mono flex items-center justify-between",children:(0,et.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,et.jsx)(gs.Code2,{size:15}),(0,et.jsxs)("span",{children:["UI: ",c]})]})})]})]})]})]})})});var HC,Da,qo,VC,jC=U(()=>{"use strict";HC=Re(require("react")),Da=require("lucide-react"),qo=require("react/jsx-runtime"),VC=HC.default.memo(function({inputHasText:e,isGenerating:r,isTranscribing:n,onToggleTranscribing:o,onSend:s,setIsVoiceActive:i}){return r?(0,qo.jsx)("div",{className:"flex items-center gap-2 min-w-[100px] justify-end",children:(0,qo.jsx)("button",{type:"button",onClick:a=>a.stopPropagation(),className:`w-12 h-12 rounded-full text-text-primary bg-red-500/80 hover:bg-red-500 flex items-center justify-center
|
|
20
|
+
transition-colors shadow-[0_0_15px_rgba(239,68,68,0.3)]`,title:"Detener generaci\xF3n",children:(0,qo.jsx)(Da.Square,{size:18})})}):(0,qo.jsxs)("div",{className:"flex items-center gap-2 min-w-[100px] justify-end",children:[(0,qo.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),o()},className:`w-10 h-10 rounded-full flex items-center justify-center transition-all
|
|
21
|
+
${n?"text-red-400 bg-red-400/10 animate-pulse":"text-text-secondary hover:text-text-primary hover:bg-surface-glass"}`,title:"Reconocimiento de voz (STT)",children:(0,qo.jsx)(Da.Mic,{size:20})}),e?(0,qo.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),s()},className:`w-12 h-12 rounded-full text-text-inverse bg-cyan-400 hover:bg-cyan-300 flex items-center justify-center
|
|
22
|
+
transition-colors shadow-[0_0_15px_rgba(34,211,238,0.3)]`,title:"Enviar",children:(0,qo.jsx)(Da.Send,{size:20,className:"ml-1"})}):i?(0,qo.jsxs)("button",{type:"button",onClick:a=>{a.stopPropagation(),i(!0)},className:`w-12 h-12 rounded-full text-cyan-400 bg-cyan-500/10 hover:bg-cyan-500/20 flex items-center justify-center
|
|
23
|
+
border border-cyan-500/20 transition-all shadow-[0_0_15px_rgba(6,182,212,0.15)]
|
|
24
|
+
hover:shadow-[0_0_20px_rgba(6,182,212,0.3)] group relative overflow-hidden`,title:"Hablar con la IA (Live)",children:[(0,qo.jsx)(Da.Sparkles,{size:22,className:"relative z-10 transition-transform group-hover:scale-110"}),(0,qo.jsx)("div",{className:"absolute inset-0 bg-linear-to-r from-cyan-400 to-purple-500 rounded-full opacity-0 group-hover:opacity-20 transition-opacity"})]}):null]})})});var Yo,Ji,go,WC,Je,w$,S$,UC,GC=U(()=>{"use strict";Yo=Re(require("react")),Ji=require("motion/react"),go=require("lucide-react"),WC=require("zustand/react/shallow");mo();Qn();Je=require("react/jsx-runtime"),w$=[{id:"landing-saas",title:"Landing SaaS",category:"Marketing",emoji:"\u{1F680}",color:"#7c3aed",description:"Hero, CTA, features",html:'<section class="min-h-screen bg-linear-to-br from-violet-950 via-indigo-950 to-black text-white flex items-center justify-center"><h1 class="text-5xl font-bold">Landing SaaS</h1></section>'},{id:"dashboard",title:"Dashboard",category:"App",emoji:"\u{1F4CA}",color:"#06b6d4",description:"M\xE9tricas, sidebar, cards",html:'<div class="min-h-screen bg-gray-950 text-white flex items-center justify-center"><h1 class="text-5xl font-bold">Dashboard</h1></div>'},{id:"portfolio",title:"Portfolio",category:"Personal",emoji:"\u{1F3A8}",color:"#ec4899",description:"Bio, proyectos, contacto",html:'<div class="min-h-screen bg-gray-950 text-white flex items-center justify-center"><h1 class="text-5xl font-bold">Portfolio</h1></div>'},{id:"pricing",title:"Pricing",category:"Marketing",emoji:"\u{1F4B3}",color:"#10b981",description:"3 planes, toggle anual",html:'<section class="min-h-screen bg-gray-950 text-white flex items-center justify-center"><h1 class="text-5xl font-bold">Pricing</h1></section>'},{id:"login",title:"Login",category:"Auth",emoji:"\u{1F510}",color:"#f59e0b",description:"Form, social, glassmorphism",html:'<div class="min-h-screen bg-gray-950 text-white flex items-center justify-center"><h1 class="text-5xl font-bold">Login</h1></div>'},{id:"blog",title:"Blog",category:"Content",emoji:"\u{1F4DD}",color:"#3b82f6",description:"Lista de art\xEDculos",html:'<div class="min-h-screen bg-gray-950 text-white flex items-center justify-center"><h1 class="text-5xl font-bold">Blog</h1></div>'}],S$=["All","Marketing","App","Personal","Auth","Content","Generated"],UC=Yo.default.memo(function({isOpen:e,onClose:r,onLoadTemplate:n,onOpenInstance:o}){let[s,i]=(0,Yo.useState)("creations"),[a,l]=(0,Yo.useState)(""),[c,d]=(0,Yo.useState)("All"),u=Ue((0,WC.useShallow)(v=>Array.from(v.instances.values()))),f=Ue(v=>v.setActiveInstance),p=Ue(v=>v.removeInstance),h=(0,Yo.useMemo)(()=>u.filter(v=>v.data?.html||v.shellType==="iframe").sort((v,S)=>S.createdAt-v.createdAt),[u]),b=(0,Yo.useMemo)(()=>w$.filter(v=>{let S=!a||v.title.toLowerCase().includes(a.toLowerCase())||v.description.toLowerCase().includes(a.toLowerCase()),w=c==="All"||v.category===c;return S&&w}),[a,c]),g=(0,Yo.useMemo)(()=>{if(!a)return h;let v=a.toLowerCase();return h.filter(S=>S.label.toLowerCase().includes(v)||S.shellType.toLowerCase().includes(v))},[h,a]),x=(0,Yo.useCallback)(v=>{f(v.id),ke.getState().setActiveTab(`morph-${v.id}`),o(v.id),r()},[f,o,r]),y=(0,Yo.useCallback)(v=>{n(v.html),r()},[n,r]),m=v=>{let S=Date.now()-v,w=Math.floor(S/6e4);if(w<1)return"ahora";if(w<60)return`${w}m`;let C=Math.floor(w/60);return C<24?`${C}h`:`${Math.floor(C/24)}d`};return(0,Je.jsx)(Ji.AnimatePresence,{children:e&&(0,Je.jsx)(Ji.motion.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},className:"absolute bottom-full left-0 right-0 z-50 mb-2",children:(0,Je.jsxs)("div",{className:`bg-white/95 dark:bg-[#1a1a2e] border border-black/[0.08] dark:border-border-default
|
|
25
|
+
rounded-2xl shadow-xl dark:shadow-2xl overflow-hidden max-h-[420px] flex flex-col backdrop-blur-xl`,children:[(0,Je.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-black/[0.06] dark:border-border-subtle shrink-0",children:[(0,Je.jsxs)("div",{className:"flex items-center gap-3",children:[(0,Je.jsx)("h3",{className:"text-sm font-bold text-text-primary",children:"Librer\xEDa"}),(0,Je.jsxs)("div",{className:"flex bg-black/[0.04] dark:bg-surface-glass rounded-lg p-0.5",children:[(0,Je.jsxs)("button",{onClick:()=>i("creations"),className:`px-3 py-1.5 text-[11px] font-semibold rounded-md transition-all flex items-center gap-1.5
|
|
26
|
+
${s==="creations"?"bg-white dark:bg-surface-tertiary text-text-primary shadow-sm":"text-text-muted hover:text-text-secondary"}`,children:[(0,Je.jsx)(go.FolderOpen,{size:12})," Mis Creaciones",h.length>0&&(0,Je.jsx)("span",{className:"text-[9px] bg-cyan-500/20 text-cyan-600 dark:text-cyan-400 px-1.5 py-0.5 rounded-full font-bold",children:h.length})]}),(0,Je.jsxs)("button",{onClick:()=>i("templates"),className:`px-3 py-1.5 text-[11px] font-semibold rounded-md transition-all flex items-center gap-1.5
|
|
27
|
+
${s==="templates"?"bg-white dark:bg-surface-tertiary text-text-primary shadow-sm":"text-text-muted hover:text-text-secondary"}`,children:[(0,Je.jsx)(go.Palette,{size:12})," Templates"]})]})]}),(0,Je.jsx)("button",{onClick:r,className:"w-7 h-7 rounded-lg text-text-muted hover:text-text-primary hover:bg-black/[0.04] dark:hover:bg-surface-glass flex items-center justify-center transition-colors",children:(0,Je.jsx)(go.X,{size:14})})]}),(0,Je.jsxs)("div",{className:"px-4 py-2 border-b border-black/[0.04] dark:border-border-subtle shrink-0 flex items-center gap-2",children:[(0,Je.jsxs)("div",{className:"flex-1 relative",children:[(0,Je.jsx)(go.Search,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-text-muted"}),(0,Je.jsx)("input",{type:"text",placeholder:"Buscar...",value:a,onChange:v=>l(v.target.value),className:`w-full pl-8 pr-3 py-1.5 bg-black/[0.03] dark:bg-surface-glass border border-transparent focus:border-cyan-500/30
|
|
28
|
+
rounded-lg text-xs text-text-primary placeholder-text-muted outline-hidden transition`})]}),s==="templates"&&(0,Je.jsx)("div",{className:"flex gap-1 overflow-x-auto no-scrollbar",children:S$.filter(v=>v!=="Generated").map(v=>(0,Je.jsx)("button",{onClick:()=>d(v),className:`px-2 py-1 text-[10px] font-semibold rounded-md whitespace-nowrap transition-all
|
|
29
|
+
${c===v?"bg-cyan-500/15 text-cyan-600 dark:text-cyan-400":"text-text-muted hover:text-text-secondary hover:bg-black/[0.04] dark:hover:bg-surface-glass"}`,children:v},v))})]}),(0,Je.jsx)("div",{className:"flex-1 overflow-y-auto px-3 py-3 custom-scrollbar",children:(0,Je.jsx)(Ji.AnimatePresence,{mode:"wait",children:s==="creations"?(0,Je.jsx)(Ji.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:g.length===0?(0,Je.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,Je.jsx)(go.FolderOpen,{size:32,className:"text-text-muted/30 mb-3"}),(0,Je.jsx)("p",{className:"text-sm text-text-muted",children:"Sin creaciones a\xFAn"}),(0,Je.jsx)("p",{className:"text-[10px] text-text-muted/60 mt-1",children:"Genera una p\xE1gina desde el chat para verla aqu\xED"})]}):(0,Je.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:g.map((v,S)=>(0,Je.jsxs)(Ji.motion.button,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{delay:S*.03},onClick:()=>x(v),className:`group relative bg-black/[0.02] dark:bg-surface-glass border border-black/[0.06] dark:border-border-subtle
|
|
30
|
+
hover:border-cyan-500/30 rounded-xl p-3 text-left transition-all hover:shadow-md overflow-hidden`,children:[(0,Je.jsx)("div",{className:`h-16 rounded-lg bg-gradient-to-br from-cyan-500/10 to-purple-500/10 dark:from-cyan-500/5 dark:to-purple-500/5
|
|
31
|
+
mb-2 flex items-center justify-center overflow-hidden border border-black/[0.04] dark:border-border-subtle`,children:(0,Je.jsx)("span",{className:"text-lg opacity-50",children:"\u{1F310}"})}),(0,Je.jsx)("h4",{className:"text-[11px] font-semibold text-text-primary truncate",children:v.label}),(0,Je.jsxs)("div",{className:"flex items-center gap-1.5 mt-1",children:[(0,Je.jsxs)("span",{className:"flex items-center gap-1 text-[9px] text-text-muted",children:[(0,Je.jsx)(go.Clock,{size:9})," ",m(v.createdAt)]}),(0,Je.jsxs)("span",{className:"flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded bg-cyan-500/10 text-cyan-600 dark:text-cyan-400 font-semibold",children:[(0,Je.jsx)(go.Tag,{size:8})," ",v.shellType]})]}),(0,Je.jsx)("div",{className:"absolute top-1.5 right-1.5 opacity-0 group-hover:opacity-100 transition-opacity flex gap-1",children:(0,Je.jsx)("button",{onClick:w=>{w.stopPropagation(),p(v.id)},className:"w-5 h-5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-400 flex items-center justify-center",title:"Eliminar",children:(0,Je.jsx)(go.Trash2,{size:10})})})]},v.id))})},"creations"):(0,Je.jsx)(Ji.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:(0,Je.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:b.map((v,S)=>(0,Je.jsxs)(Ji.motion.button,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{delay:S*.03},onClick:()=>y(v),className:`group bg-black/[0.02] dark:bg-surface-glass border border-black/[0.06] dark:border-border-subtle
|
|
32
|
+
hover:border-opacity-50 rounded-xl p-3 text-left transition-all hover:shadow-md overflow-hidden`,style:{"--hover-color":v.color},children:[(0,Je.jsx)("div",{className:"h-14 rounded-lg mb-2 flex items-center justify-center transition-all group-hover:scale-[1.02]",style:{background:`linear-gradient(135deg, ${v.color}20, ${v.color}08)`},children:(0,Je.jsx)("span",{className:"text-2xl",children:v.emoji})}),(0,Je.jsx)("h4",{className:"text-[11px] font-semibold text-text-primary",children:v.title}),(0,Je.jsx)("p",{className:"text-[9px] text-text-muted mt-0.5",children:v.description}),(0,Je.jsx)("span",{className:"inline-block mt-1.5 text-[9px] font-semibold px-1.5 py-0.5 rounded",style:{background:`${v.color}15`,color:v.color},children:v.category})]},v.id))})},"templates")})})]})})})})});var br,jl,kh,sx,Eh,ur,Th,ix=U(()=>{"use strict";br=require("react"),jl=require("motion/react"),kh=require("lucide-react"),sx=require("@decido/engine");xi();ot();Vl();Eh=require("@decido/chat");hd();DC();_C();gh();mo();FC();jC();GC();ur=require("react/jsx-runtime"),Th=({onSend:t,isGenerating:e,isVoiceActive:r=!1,setIsVoiceActive:n,VoiceWidget:o,dynamicPersona:s,setSuggestions:i,selectedVoice:a,showCanvas:l,setShowCanvas:c,prototypeBrand:d="decido",setPrototypeBrand:u})=>{let[f,p]=(0,br.useState)(""),[h,b]=(0,br.useState)(!1),[g,x]=(0,br.useState)(!1),[y,m]=(0,br.useState)(0),[v,S]=(0,br.useState)(!1),[w,C]=(0,br.useState)(!1),[A,k]=(0,br.useState)(!0),[M,T]=(0,br.useState)(()=>localStorage.getItem("decido_selected_shell")),E=(0,br.useRef)(null),{selectedModelId:P,selectedModel:N,providerGroups:D,selectModel:R}=RC();(0,br.useEffect)(()=>{typeof window<"u"&&window.__DECIDO__&&(window.__DECIDO__.intentEnabled=A)},[A]);let O=X(K=>K.activeChatId);(0,br.useEffect)(()=>{O&&X.setState(K=>({chatInstances:K.chatInstances.map(he=>he.id===O?{...he,model:P}:he)}))},[P,O]),(0,br.useEffect)(()=>{if(M?localStorage.setItem("decido_selected_shell",M):localStorage.removeItem("decido_selected_shell"),typeof window<"u"&&window.__DECIDO__&&(window.__DECIDO__.selectedShell=M),!!O)if(X.setState(K=>({chatInstances:K.chatInstances.map(he=>he.id===O?{...he,shellType:M||void 0}:he)})),M){let K=Hl(M);Ue.getState().upsertInstance({id:O,sourceChatId:O,shellType:M,label:K.label||M,data:{}})}else Ue.getState().removeInstance(O)},[M,O]);let B=X(K=>K.chatInstances.find(he=>he.id===K.activeChatId));(0,br.useEffect)(()=>{if(!B)return;B.model&&B.model!==P&&R(B.model);let K=B.shellType||null;K!==M&&T(K)},[O]);let{primaryIntent:L}=Uu(A?f:""),H=Yi(K=>K.seeds),j=Yi(K=>K.generated),$=Yi(K=>K.pluginSuggestions),q=(0,br.useMemo)(()=>{let K=Object.values($).flat();return[...j,...H,...K]},[j,H,$]),[F,_]=(0,br.useState)(0);(0,br.useEffect)(()=>{if(q.length<=1)return;let K=setInterval(()=>_(he=>(he+1)%q.length),4e3);return()=>clearInterval(K)},[q.length]);let W=q.length>0?q[F%q.length]:"Escribe / para comandos... (Shift+Enter nueva l\xEDnea)";(0,br.useEffect)(()=>{let K=E.current;K&&(K.style.height="auto",K.style.height=`${Math.min(K.scrollHeight,200)}px`)},[f]);let V=(0,sx.useTimelineStore)(K=>K.timelines),z=(0,sx.useTimelineStore)(K=>K.blueprintLibrary),G=Mn(K=>K.components),Y=(0,br.useMemo)(()=>{let K=Object.keys(V).map(He=>({id:He,label:He,description:V[He]?.name||He})),he=Object.entries(z).map(([He,nt])=>({id:He,label:nt.name||He,description:`v${nt.metadata?.version||"?"} \xB7 ${nt.metadata?.tags?.join(", ")||""}`})),lt=Object.values(G).map(He=>({id:He.id,label:He.name,description:He.category}));return[{command:"/run",label:"Run Flow",description:"Ejecutar un flujo",icon:"\u25B6",subCommands:K},{command:"/flows",label:"List Flows",description:"Ver todos los flujos",icon:"\u{1F4CB}"},{command:"/blueprints",label:"Blueprints",description:"Subflujos disponibles",icon:"\u{1F517}",subCommands:he},{command:"/ui",label:"UI Components",description:"Biblioteca de componentes",icon:"\u{1F3A8}",subCommands:lt},{command:"/reset",label:"Reset Engine",description:"Reiniciar el motor",icon:"\u{1F504}"},{command:"/tts",label:"Voice Synthesis",description:"Generar audio TTS con Kokoro",icon:"\u{1F399}\uFE0F"}]},[V,z,G]),Z=(0,br.useMemo)(()=>{if(!f.startsWith("/"))return[];let K=f.split(" "),he=K[0].toLowerCase(),lt=K.slice(1).join(" ").toLowerCase(),He=Y.find(nt=>nt.command===he);return He?.subCommands?He.subCommands.filter(nt=>!lt||nt.id.toLowerCase().includes(lt)||nt.label.toLowerCase().includes(lt)).map(nt=>({...nt,type:"sub",parentCommand:he})):Y.filter(nt=>nt.command.startsWith(he)).map(nt=>({id:nt.command,label:nt.label,description:nt.description,icon:nt.icon,type:"command",subCommands:nt.subCommands}))},[f,Y]);(0,br.useEffect)(()=>{x(f.startsWith("/")&&Z.length>0),m(0)},[f,Z.length]);let se=K=>{K.type==="command"?K.subCommands?(p(K.id+" "),E.current?.focus()):(t(K.id),p(""),x(!1)):K.type==="sub"&&(t(`${K.parentCommand} ${K.id}`),p(""),x(!1))},we=K=>{if(g){K.key==="ArrowDown"?(K.preventDefault(),m(he=>Math.min(he+1,Z.length-1))):K.key==="ArrowUp"?(K.preventDefault(),m(he=>Math.max(he-1,0))):K.key==="Enter"&&Z[y]?(K.preventDefault(),se(Z[y])):K.key==="Escape"&&x(!1);return}K.key==="Enter"&&!K.shiftKey&&(K.preventDefault(),f.trim()&&!e&&(t(f.trim()),p("")))},_e=K=>{K.preventDefault(),f.trim()&&!e&&(t(f.trim()),p(""))},Pe=(0,br.useCallback)(()=>{f.trim()&&!e&&(t(f.trim()),p(""))},[f,e,t]);return(0,ur.jsxs)(jl.motion.div,{layout:!0,className:`w-full relative ${r?"h-64":""}`,children:[(0,ur.jsx)(Eh.SlashCommandMenu,{isOpen:g,items:Z,activeIndex:y,onSelect:se,onHover:m}),(0,ur.jsx)(jl.AnimatePresence,{children:v&&(0,ur.jsx)(jl.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:(0,ur.jsx)(OC,{onSelect:K=>{p(K),S(!1),E.current?.focus()}})})}),(0,ur.jsx)(UC,{isOpen:w,onClose:()=>C(!1),onLoadTemplate:K=>{t(`/template ${K.slice(0,100)}`)},onOpenInstance:K=>{Ue.getState().setActiveInstance(K),c&&c(!0)}}),(0,ur.jsx)("div",{className:`bg-white/80 dark:bg-surface-tertiary border border-black/[0.08] dark:border-border-default rounded-4xl flex flex-col p-2 shadow-sm dark:shadow-2xl transition-all duration-300
|
|
33
|
+
${r?"h-full border-cyan-500/30":"focus-within:border-black/[0.12] dark:focus-within:border-border-strong focus-within:shadow-md dark:focus-within:shadow-lg"}`,children:(0,ur.jsx)(jl.AnimatePresence,{mode:"wait",children:r?(0,ur.jsx)(Eh.VoiceLiveMode,{VoiceWidget:o,dynamicPersona:s,setSuggestions:i,selectedVoice:a,onClose:()=>n?.(!1)}):(0,ur.jsxs)(jl.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex flex-col w-full h-full cursor-text",onClick:K=>{let he=K.currentTarget.querySelector("textarea");he&&K.target===K.currentTarget&&he.focus()},children:[(0,ur.jsxs)("form",{onSubmit:_e,className:"relative flex items-center px-3 sm:px-4 py-2 sm:py-3 min-h-[48px] sm:min-h-[60px]",children:[(0,ur.jsx)("textarea",{ref:E,placeholder:h?"Escuchando...":W,value:f,onChange:K=>p(K.target.value),onKeyDown:we,rows:1,className:"w-full bg-transparent text-text-primary placeholder-text-muted outline-hidden text-sm sm:text-[15px] leading-relaxed resize-none",disabled:e,style:{maxHeight:"200px"}}),L&&!g&&(0,ur.jsxs)("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 flex items-center gap-1 px-2 py-1 rounded-full text-[10px] font-semibold border",style:{background:`${L.color}15`,borderColor:`${L.color}30`,color:L.color},children:[(0,ur.jsx)("span",{children:L.icon}),(0,ur.jsx)("span",{children:L.label})]})]}),(0,ur.jsxs)("div",{className:"flex flex-wrap items-center justify-between px-2 pb-1 relative z-10 w-full gap-y-2",children:[(0,ur.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,ur.jsx)("button",{type:"button",onClick:()=>{C(!w),S(!1)},className:`w-10 h-10 rounded-full flex items-center justify-center transition-colors
|
|
34
|
+
${w?"text-cyan-400 bg-cyan-500/10":"text-text-secondary hover:text-text-primary hover:bg-surface-glass"}`,title:"Librer\xEDa de recursos",children:(0,ur.jsx)(kh.FolderOpen,{size:20})}),(0,ur.jsx)("button",{type:"button",className:"w-10 h-10 rounded-full text-text-secondary hover:text-text-primary hover:bg-surface-glass flex items-center justify-center transition-colors",title:"Adjuntar",children:(0,ur.jsx)(kh.Paperclip,{size:20})})]}),(0,ur.jsx)($C,{selectedModelId:P,selectedModel:N,providerGroups:D,onModelSelect:R,selectedShell:M,onShellSelect:T,showCanvas:l,setShowCanvas:c,prototypeBrand:d,setPrototypeBrand:u,intentEnabled:A,onIntentToggle:()=>k(!A),showIntentPanel:v,onIntentPanelToggle:()=>S(!v)}),(0,ur.jsx)(VC,{inputHasText:!!f.trim(),isGenerating:e,isTranscribing:h,onToggleTranscribing:()=>b(!h),onSend:Pe,setIsVoiceActive:n})]})]},"text-mode")})}),(0,ur.jsx)("div",{className:"text-center mt-3",children:(0,ur.jsx)("p",{className:"text-[10px] md:text-[11px] text-text-muted font-medium tracking-wide",children:"Decido puede equivocarse. Considera revisar la informaci\xF3n importante."})})]})}});function KC(t,e){if(!t.startsWith("/"))return!1;let r=t.split(" "),n=r[0].toLowerCase(),o=r.slice(1).join(" ");switch(n){case"/run":return o?(Ih.useTimelineStore.getState().timelines[o]?(e.setPrototypeBrand(o),Ah.useEngineStore.getState().resetEngine(),e.addChatMessage({type:"text",sender:"system",text:`\u25B6\uFE0F Ejecutando flujo: **${o}**`,actorId:"system"}),setTimeout(()=>{Ah.useEngineStore.getState().dispatchEvent({type:"SYSTEM_START"})},100)):e.addChatMessage({type:"alert",sender:"system",text:`Flujo "${o}" no encontrado. Usa /flows para ver los disponibles.`,actorId:"system"}),!0):!1;case"/flows":{let s=Object.keys(Ih.useTimelineStore.getState().timelines);return e.addChatMessage({type:"text",sender:"system",text:`\u{1F4CB} Flujos disponibles:
|
|
35
|
+
${s.map(i=>`\u2022 ${i}`).join(`
|
|
36
|
+
`)}
|
|
37
|
+
|
|
38
|
+
Usa /run [nombre] para ejecutar.`,actorId:"system"}),!0}case"/blueprints":{let s=Object.entries(Ih.useTimelineStore.getState().blueprintLibrary);return e.addChatMessage({type:"text",sender:"system",text:`\u{1F4E6} Blueprints:
|
|
39
|
+
${s.map(([i,a])=>`\u2022 ${i} \u2014 ${a.name||"?"}`).join(`
|
|
40
|
+
`)||"Ninguno registrado."}`,actorId:"system"}),!0}case"/ui":{if(o){let s=Mn.getState().components[o];s?e.addChatMessage({type:"ui-artifact",sender:"agent",text:`\u{1F3A8} ${s.name}`,actorId:"system",uiSchema:JSON.stringify(s.schema)}):e.addChatMessage({type:"alert",sender:"system",text:`Componente "${o}" no encontrado.`,actorId:"system"})}else{let s=Object.values(Mn.getState().components);e.addChatMessage({type:"text",sender:"system",text:`\u{1F3A8} UI Components:
|
|
41
|
+
${s.map(i=>`\u2022 ${i.name} (${i.category}) \u2014 ${i.source}`).join(`
|
|
42
|
+
`)||"Ninguno."}
|
|
43
|
+
|
|
44
|
+
Usa /ui [id] para renderizar.`,actorId:"system"})}return!0}case"/tts":return o?(e.addChatMessage({type:"text",sender:"system",text:`\u{1F399}\uFE0F Generando audio neuronal para:
|
|
45
|
+
"${o}"...`,actorId:"system"}),import("@decido/kernel-bridge").then(({kernel:s})=>{s.execute("call_mcp_tool",{server_name:"Kokoro TTS",tool_name:"generate_tts",arguments:{text:o,voice:"em_alex",speed:1,lang:"es",return_base64:!0}}).then(i=>{let a=typeof i=="string"?i:JSON.stringify(i);if(a.includes("DATA_URI:")){let l=a.split("DATA_URI:")[1].trim();e.addChatMessage({type:"audio",sender:"system",text:"\u2705 Emisi\xF3n de voz generada con \xE9xito",audioSrc:l,actorId:"system"})}else e.addChatMessage({type:"alert",sender:"system",text:`La respuesta no incluy\xF3 un URI v\xE1lido:
|
|
46
|
+
${a}`,actorId:"system"})}).catch(i=>{e.addChatMessage({type:"alert",sender:"system",text:`\u274C Error de TTS: ${String(i)}`,actorId:"system"})})}),!0):(e.addChatMessage({type:"alert",sender:"system",text:`Debes indicar el texto a leer. Ejemplo:
|
|
47
|
+
/tts Hola mundo`,actorId:"system"}),!0);case"/reset":return Ah.useEngineStore.getState().resetEngine(),e.addChatMessage({type:"text",sender:"system",text:"\u23F9 Motor reiniciado.",actorId:"system"}),!0;default:return e.addChatMessage({type:"alert",sender:"system",text:`Comando desconocido: ${n}`,actorId:"system"}),!0}}var Ih,Ah,qC=U(()=>{"use strict";Ih=require("@decido/engine"),Ah=require("@decido/engine");xi()});var YC={};Mo(YC,{PlaygroundChat:()=>Gu});var Oa,Zi,_a,md,qe,Gu,Mh=U(()=>{"use strict";Oa=Re(require("react")),Zi=require("motion/react"),_a=require("lucide-react");xC();ot();mo();Qn();ix();md=require("@decido/chat");qC();qe=require("react/jsx-runtime"),Gu=Oa.default.memo(function({step:e,selectedProfile:r,authAvailableLicenses:n,handleProfileSelect:o,activeConfig:s,demoState:i,suggestions:a,setInputValue:l,isGenerating:c,config:d,handleGeneratePlayground:u,isCreatorMode:f=!0,isVoiceActive:p=!1,setIsVoiceActive:h,VoiceWidget:b,dynamicPersona:g,setSuggestions:x,selectedVoice:y,showCanvas:m,setShowCanvas:v}){let S=X($=>$.activeChatId),w=X($=>$.chatMessagesByInstance[$.activeChatId||"_default"]||[]),C=X($=>$.addChatMessage),A=X($=>$.prototypeBrand),k=X($=>$.setPrototypeBrand),M=Oa.default.useRef(null),[T,E]=Oa.default.useState(!0),[P,N]=Oa.default.useState(!1),D=Oa.default.useRef(!0),R=()=>{if(!M.current)return;let{scrollTop:$,scrollHeight:q,clientHeight:F}=M.current,_=q-$-F<100;E(_),D.current=_},O=w[w.length-1],B=`${w.length}-${O?.text?.length||0}`;Oa.default.useEffect(()=>{D.current&&M.current&&M.current.scrollTo({top:M.current.scrollHeight,behavior:"smooth"})},[B]);let L=()=>{let $=0,q=setInterval(()=>{if($>200){clearInterval(q);return}C({type:$%3===0?"alert":$%5===0?"card":"text",sender:$%2===0?"agent":"system",text:`Stresstesting message ${$} para medir rendimiento en el sistema.`}),$++},10)},H=()=>{let $=s&&typeof s=="object"&&d?.environments?Object.keys(d.environments):["brand-a","brand-b","brand-c"],q=($.indexOf(A)+1)%$.length;k($[q])},j=Oa.default.useMemo(()=>({activeConfig:s,onMorphInstanceSelect:$=>{Ue.getState().setActiveInstance($),ke.getState().setActiveTab(`morph-${$}`),v&&v(!0)},extensions:{getPreviewHTML:()=>Ue.getState().getActiveInstance?.()?.data?.html||null,onSendMessage:$=>C({type:"text",sender:"user",text:$}),renderMessageActions:$=>null}}),[s,v,C]);return(0,qe.jsx)(Zi.AnimatePresence,{mode:"wait",children:e==="action"?(0,qe.jsxs)(Zi.motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"flex flex-col items-center justify-center h-full text-center",children:[(0,qe.jsx)("div",{className:"w-24 h-24 mx-auto rounded-full border-[3px] border-cyan-500/30 border-t-cyan-400 animate-spin mb-8 shadow-[0_0_30px_rgba(34,211,238,0.2)]"}),(0,qe.jsx)("h2",{className:"text-3xl font-bold text-text-primary mb-4",children:"Reestructurando el OS..."}),(0,qe.jsxs)("p",{className:"text-cyan-400 font-mono text-sm tracking-widest uppercase bg-cyan-500/10 py-2 px-6 rounded-full inline-block border border-cyan-500/20",children:["Cargando m\xF3dulos para: ",r]})]},"action-step"):e==="profile"?(0,qe.jsxs)(Zi.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"flex flex-col items-center justify-center h-full w-full max-w-4xl mx-auto pb-20",children:[(0,qe.jsx)("h2",{className:"text-2xl md:text-3xl font-bold text-text-primary text-center mb-8",children:"Selecciona tu Perfil"}),(0,qe.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 w-full",children:n.map($=>(0,qe.jsx)("button",{onClick:()=>o($),className:`group relative p-6 rounded-3xl bg-surface-tertiary border border-border-subtle transition-all text-left overflow-hidden ${$.type==="enterprise"?"hover:border-emerald-500/50":"hover:border-cyan-500/50"}`,children:(0,qe.jsxs)("div",{className:"flex items-center gap-4 mb-4",children:[(0,qe.jsx)("div",{className:`w-12 h-12 rounded-full flex items-center justify-center shadow-inner ${$.type==="enterprise"?"bg-emerald-500/10 text-emerald-400":"bg-cyan-500/10 text-cyan-400"}`,children:$.type==="enterprise"?(0,qe.jsx)(_a.Building2,{size:24}):(0,qe.jsx)(_a.BrainCircuit,{size:24})}),(0,qe.jsx)("h3",{className:"text-xl font-bold text-text-primary",children:$.name})]})},$.id))})]},"profile-step"):(0,qe.jsxs)(Zi.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0},className:"flex flex-col h-full overflow-hidden w-full max-w-full lg:max-w-4xl mx-auto pb-4 px-3 sm:px-6 md:px-8 lg:px-4 min-w-0 min-h-0 box-border",children:[(0,qe.jsxs)("div",{ref:M,onScroll:R,className:`flex-1 overflow-y-auto overflow-x-hidden custom-scrollbar scroll-smooth flex flex-col gap-6 md:gap-8 min-w-0 min-h-0 ${f?"pb-48 md:pb-64":"justify-end pb-6"}`,children:[(0,qe.jsxs)("div",{className:"flex flex-col gap-3 md:gap-4 transition-all mt-4 sm:mt-6 md:mt-8",children:[(0,qe.jsxs)("h1",{className:"text-2xl sm:text-3xl md:text-5xl font-semibold leading-tight text-text-primary/50",children:[(0,qe.jsx)("span",{className:`bg-linear-to-r ${s.gradient} text-transparent bg-clip-text transition-all duration-700`,children:s.greetingText}),(0,qe.jsx)("br",{}),s.greetingPrompt||"\xBFEn qu\xE9 puedo ayudarte hoy?"]}),(0,qe.jsxs)("div",{className:"flex items-center gap-4 flex-wrap mt-2",children:[(0,qe.jsx)("p",{className:"text-sm text-text-muted font-mono transition-all duration-700",children:s.subtitle}),(0,qe.jsxs)("div",{className:"hidden md:flex gap-2 items-center",children:[(0,qe.jsxs)("button",{onClick:H,className:"text-[10px] text-text-secondary hover:text-text-primary uppercase tracking-wider transition-colors bg-surface-glass hover:bg-surface-glass px-3 py-1.5 rounded-full border border-border-default flex items-center gap-2",children:[(0,qe.jsx)("span",{className:`w-2 h-2 rounded-full ${A==="brand-b"?"bg-emerald-400":A==="brand-c"?"bg-purple-400":"bg-cyan-400"}`}),"Tema: ",A]}),(0,qe.jsxs)("button",{onClick:L,className:"text-[10px] text-text-secondary hover:text-orange-400 uppercase tracking-wider transition-colors bg-orange-500/5 hover:bg-orange-500/10 px-3 py-1.5 rounded-full border border-orange-500/20 border-dashed flex items-center gap-2",children:[(0,qe.jsx)("span",{className:"text-orange-500 font-bold",children:"\u26A0"})," Estr\xE9s (200 msgs)"]}),(0,qe.jsxs)("div",{className:"relative",children:[(0,qe.jsxs)("button",{onClick:()=>N(!P),className:"text-[10px] text-text-secondary hover:text-cyan-400 uppercase tracking-wider transition-colors bg-surface-glass hover:bg-surface-glass px-3 py-1.5 rounded-full border border-border-default flex items-center gap-2",children:[(0,qe.jsx)(_a.Download,{size:10})," Export"]}),(0,qe.jsx)(md.ChatExportMenu,{isOpen:P,onClose:()=>N(!1)})]})]})]})]}),(0,qe.jsx)(md.ChatProvider,{value:j,children:(w.length>0||c)&&(0,qe.jsxs)("div",{className:"flex flex-col gap-6 mt-6 max-w-full md:max-w-3xl min-w-0",children:[w.map($=>(0,qe.jsx)(md.ChatMessageRow,{msg:$},$.id)),(0,qe.jsx)(Zi.AnimatePresence,{children:c&&(0,qe.jsxs)(Zi.motion.div,{initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.95},className:"flex gap-4",children:[(0,qe.jsx)("div",{className:"w-10 h-10 rounded-full flex items-center justify-center shadow-lg border shrink-0 bg-transparent border-border-strong text-text-primary",children:(0,qe.jsx)(_a.Sparkles,{size:18,className:"text-text-muted animate-pulse"})}),(0,qe.jsx)("div",{className:"flex-1 space-y-2 flex flex-col items-start justify-center",children:(0,qe.jsxs)("div",{className:"bg-surface-tertiary border border-border-subtle rounded-2xl p-4 shadow-xl inline-flex gap-1.5 items-center justify-center",children:[(0,qe.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-surface-elevated animate-bounce",style:{animationDelay:"0ms"}}),(0,qe.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-surface-elevated animate-bounce",style:{animationDelay:"150ms"}}),(0,qe.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-surface-elevated animate-bounce",style:{animationDelay:"300ms"}})]})})]})})]})}),!w.length&&i!=="idle"&&(0,qe.jsx)("div",{className:"flex flex-col gap-6 mt-6 max-w-full md:max-w-3xl opacity-50 min-w-0",children:(0,qe.jsx)("p",{className:"text-sm text-text-muted italic",children:"Ejecutando secuencia en el simulador sin salida de chat..."})}),!w.length&&i==="idle"&&(0,qe.jsx)(bC,{suggestions:a,onSelect:l})]}),!T&&w.length>5&&(0,qe.jsx)(Zi.motion.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},onClick:()=>M.current?.scrollTo({top:M.current.scrollHeight,behavior:"smooth"}),className:`absolute ${f?"bottom-[100px]":"bottom-20"} left-1/2 transform -translate-x-1/2 bg-cyan-500 text-text-primary rounded-full px-4 py-2 text-xs font-bold shadow-[0_0_15px_rgba(34,211,238,0.5)] border border-cyan-400 flex items-center gap-2 z-50 hover:bg-cyan-400`,children:"\u2B07 Nuevos Mensajes"}),!f&&(0,qe.jsx)("div",{className:"shrink-0 w-full max-w-full lg:max-w-3xl mx-auto pb-2",children:(0,qe.jsx)(Th,{isGenerating:c,onSend:$=>{KC($,{prototypeBrand:A,setPrototypeBrand:k,addChatMessage:C})||(l($),u?u($):window.__DECIDO__?.geminiStream&&window.__DECIDO__.geminiStream($))},isVoiceActive:p,setIsVoiceActive:h,VoiceWidget:b,dynamicPersona:g,setSuggestions:x,selectedVoice:y,showCanvas:m,setShowCanvas:v,prototypeBrand:A,setPrototypeBrand:k})})]},"chat-greeting")})})});var JC={};Mo(JC,{PlaygroundTerminal:()=>ax});var XC,Ph,gd,Pn,ax,lx=U(()=>{"use strict";XC=Re(require("react")),Ph=require("motion/react"),gd=require("lucide-react"),Pn=require("react/jsx-runtime"),ax=XC.default.memo(function({isOpen:e,setIsOpen:r,logs:n,setLogs:o,logsEndRef:s}){return(0,Pn.jsx)(Ph.AnimatePresence,{children:e&&(0,Pn.jsxs)(Ph.motion.div,{initial:{opacity:0,y:50},animate:{opacity:1,y:0},exit:{opacity:0,y:50},className:"absolute right-6 bottom-40 w-80 h-64 bg-surface-overlay backdrop-blur-md border border-border-default rounded-xl flex flex-col overflow-hidden z-30 shadow-2xl",children:[(0,Pn.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border-default bg-surface-glass",children:[(0,Pn.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Pn.jsx)(gd.Terminal,{size:14,className:"text-text-secondary"}),(0,Pn.jsx)("span",{className:"text-xs font-mono text-text-secondary",children:"System Log"})]}),(0,Pn.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Pn.jsx)("button",{onClick:()=>o([]),className:"text-text-muted hover:text-red-400 transition-colors",title:"Limpiar logs",children:(0,Pn.jsx)(gd.Trash2,{size:14})}),(0,Pn.jsx)("button",{onClick:()=>r(!1),className:"text-text-muted hover:text-text-primary transition-colors",children:(0,Pn.jsx)(gd.X,{size:14})})]})]}),(0,Pn.jsxs)("div",{className:"flex-1 overflow-y-auto p-3 font-mono text-[10px] space-y-1 custom-scrollbar",children:[n.map((i,a)=>(0,Pn.jsxs)("div",{className:`flex gap-2 ${i.type==="error"?"text-red-400":i.type==="success"?"text-emerald-400":i.type==="system"?"text-purple-400":"text-text-secondary"}`,children:[(0,Pn.jsxs)("span",{className:"opacity-50 shrink-0",children:["[",i.time,"]"]}),(0,Pn.jsx)("span",{className:"wrap-break-word",children:i.msg})]},a)),(0,Pn.jsx)("div",{ref:s})]})]})})})});var Rh,Dh,bs,Lr,cx,ZC=U(()=>{"use strict";Rh=require("react"),Dh=require("motion/react"),bs=require("lucide-react"),Lr=require("react/jsx-runtime"),cx=({id:t,name:e,nodeCount:r,isActive:n,isSubflow:o,onSelect:s,onRename:i,onDuplicate:a,onDelete:l})=>{let[c,d]=(0,Rh.useState)(!1),[u,f]=(0,Rh.useState)(e),[p,h]=(0,Rh.useState)(!1),b=()=>{let y=u.trim();y&&y!==e&&i(y),d(!1)},g=o?"violet":"cyan",x=o?bs.Network:bs.FileText;return(0,Lr.jsxs)("div",{className:`group relative flex items-center gap-2 px-3 py-2 rounded-xl cursor-pointer transition-all mb-0.5 ${n?`bg-${g}-500/15 border border-${g}-500/30`:"hover:bg-surface-glass border border-transparent"}`,onClick:()=>!c&&s(),children:[(0,Lr.jsx)(x,{size:14,className:n?`text-${g}-400`:o?"text-violet-400/60":"text-text-muted"}),c?(0,Lr.jsx)("div",{className:"flex-1 flex items-center gap-1",children:(0,Lr.jsx)("input",{autoFocus:!0,value:u,onChange:y=>f(y.target.value),onKeyDown:y=>{y.key==="Enter"&&b(),y.key==="Escape"&&d(!1)},onBlur:b,className:"flex-1 bg-surface-glass border border-cyan-500/30 rounded px-2 py-0.5 text-xs text-text-primary focus:outline-hidden font-mono",onClick:y=>y.stopPropagation()})}):(0,Lr.jsxs)(Lr.Fragment,{children:[(0,Lr.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Lr.jsx)("div",{className:`text-xs font-medium truncate ${n?"text-text-primary":o?"text-text-secondary":"text-text-primary"}`,children:e||t}),(0,Lr.jsxs)("div",{className:"text-[10px] text-text-muted font-mono",children:[r," nodos"]})]}),o&&(0,Lr.jsx)("span",{className:"text-[9px] bg-violet-500/10 text-violet-400 px-1.5 py-0.5 rounded-full font-mono",children:"sub"}),(0,Lr.jsx)("button",{onClick:y=>{y.stopPropagation(),h(!p)},className:"opacity-0 group-hover:opacity-100 p-1 rounded hover:bg-surface-glass text-text-muted transition-all",children:(0,Lr.jsx)(bs.MoreVertical,{size:14})})]}),(0,Lr.jsx)(Dh.AnimatePresence,{children:p&&(0,Lr.jsxs)(Dh.motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},className:"absolute right-0 top-full z-50 bg-surface-tertiary border border-border-default rounded-xl shadow-2xl overflow-hidden mt-1 min-w-[140px]",onClick:y=>y.stopPropagation(),children:[(0,Lr.jsxs)("button",{onClick:()=>{f(e||t),d(!0),h(!1)},className:"flex items-center gap-2 w-full px-3 py-2 text-xs text-text-primary hover:bg-surface-glass transition-colors",children:[(0,Lr.jsx)(bs.Edit3,{size:12})," Renombrar"]}),(0,Lr.jsxs)("button",{onClick:()=>{a(),h(!1)},className:"flex items-center gap-2 w-full px-3 py-2 text-xs text-text-primary hover:bg-surface-glass transition-colors",children:[(0,Lr.jsx)(bs.Copy,{size:12})," Duplicar"]}),l&&(0,Lr.jsxs)("button",{onClick:()=>{l(),h(!1)},className:"flex items-center gap-2 w-full px-3 py-2 text-xs text-red-400 hover:bg-red-500/10 transition-colors border-t border-border-subtle",children:[(0,Lr.jsx)(bs.Trash2,{size:12})," Eliminar"]})]})})]})}});var Xo,Qi,Ro,wi,QC,it,ek,tk=U(()=>{"use strict";Xo=require("react"),Qi=require("motion/react"),Ro=require("lucide-react"),wi=require("@decido/engine");ot();QC=require("@decido/engine");ZC();it=require("react/jsx-runtime"),ek=({isOpen:t,onClose:e})=>{let r=(0,wi.useTimelineStore)(E=>E.timelines),n=(0,wi.useTimelineStore)(E=>E.blueprintLibrary),o=X(E=>E.prototypeBrand),s=X(E=>E.setPrototypeBrand),i=(0,QC.useBlueprintNavigation)(E=>E.resetNavigation),a=(0,wi.useTimelineStore)(E=>E.createTimeline),l=(0,wi.useTimelineStore)(E=>E.addKeyframe),c=(0,wi.useTimelineStore)(E=>E.addBlueprint),d=(0,wi.useTimelineStore)(E=>E.duplicateTimeline),u=(0,wi.useTimelineStore)(E=>E.renameTimeline),f=(0,wi.useTimelineStore)(E=>E.deleteTimeline),[p,h]=(0,Xo.useState)(!1),[b,g]=(0,Xo.useState)("blueprint"),[x,y]=(0,Xo.useState)(""),[m,v]=(0,Xo.useState)(!1),S=(0,Xo.useRef)(null);(0,Xo.useEffect)(()=>{let E=P=>{S.current&&!S.current.contains(P.target)&&v(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);let w=(0,Xo.useCallback)(()=>{if(x.trim()){if(b==="subflow"){let E=`subflow_${x.trim().toLowerCase().replace(/\s+/g,"_")}`,P=a(x.trim(),E);l(P,{t:0,track:"entry",label:"Entrada",position:{x:300,y:50}}),l(P,{t:5,track:"return",label:"Retorno",handle:"success",position:{x:300,y:300}});let N=`bp_${x.trim().toLowerCase().replace(/\s+/g,"_")}`,D=wi.useTimelineStore.getState().timelines[P];D&&c({...D,id:N,isSubflow:!0,signature:{inputs:{},outputs:{}},metadata:{author:"user",version:"1.0.0",tags:["custom"],description:x.trim(),isPublic:!1,createdAt:Date.now(),updatedAt:Date.now()}}),s(P)}else s(a(x.trim()));y(""),h(!1)}},[x,b,a,l,c,s]),C=(0,Xo.useCallback)(E=>{i(),s(E)},[s,i]),A=(0,Xo.useCallback)(E=>{if(f(E)&&o===E){let N=Object.keys(r).filter(D=>D!==E);N.length>0&&s(N[0])}},[f,o,r,s]),k=Object.entries(r),M=Object.entries(n),T={};for(let[E]of Object.entries(r))E.startsWith("subflow_")&&(T[`bp_${E.replace("subflow_","")}`]=E);return(0,it.jsx)(Qi.AnimatePresence,{children:t&&(0,it.jsxs)(it.Fragment,{children:[(0,it.jsx)(Qi.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-surface-overlay z-40",onClick:e}),(0,it.jsxs)(Qi.motion.div,{initial:{opacity:0,x:-20,scale:.95},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:-20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:"fixed left-4 bottom-20 z-50 w-80 max-h-[60vh] bg-surface-primary border border-border-default rounded-2xl shadow-2xl overflow-hidden flex flex-col",style:{backdropFilter:"blur(20px)"},onClick:E=>E.stopPropagation(),children:[(0,it.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-glass",children:[(0,it.jsxs)("div",{className:"flex items-center gap-2",children:[(0,it.jsx)(Ro.FolderOpen,{size:16,className:"text-cyan-400"}),(0,it.jsx)("span",{className:"text-sm font-bold text-text-primary tracking-wide",children:"Blueprints"}),(0,it.jsx)("span",{className:"text-[10px] bg-surface-glass text-text-secondary px-1.5 py-0.5 rounded-full font-mono",children:k.length})]}),(0,it.jsxs)("div",{className:"relative",ref:S,children:[(0,it.jsx)("button",{onClick:()=>v(!m),className:"p-1.5 rounded-lg hover:bg-cyan-500/20 text-cyan-400 transition-colors",title:"Crear nuevo",children:(0,it.jsx)(Ro.Plus,{size:16})}),(0,it.jsx)(Qi.AnimatePresence,{children:m&&(0,it.jsxs)(Qi.motion.div,{initial:{opacity:0,scale:.9,y:-5},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:-5},className:"absolute right-0 top-full mt-1 z-50 bg-surface-tertiary border border-border-default rounded-xl shadow-2xl overflow-hidden min-w-[180px]",children:[(0,it.jsxs)("button",{onClick:()=>{g("blueprint"),h(!0),v(!1)},className:"flex items-center gap-2 w-full px-3 py-2.5 text-xs text-text-primary hover:bg-surface-glass transition-colors",children:[(0,it.jsx)(Ro.FileText,{size:13,className:"text-cyan-400"}),(0,it.jsxs)("div",{className:"text-left",children:[(0,it.jsx)("div",{className:"font-medium",children:"Nuevo Blueprint"}),(0,it.jsx)("div",{className:"text-[10px] text-text-muted",children:"Flujo principal"})]})]}),(0,it.jsxs)("button",{onClick:()=>{g("subflow"),h(!0),v(!1)},className:"flex items-center gap-2 w-full px-3 py-2.5 text-xs text-text-primary hover:bg-surface-glass transition-colors border-t border-border-subtle",children:[(0,it.jsx)(Ro.Network,{size:13,className:"text-violet-400"}),(0,it.jsxs)("div",{className:"text-left",children:[(0,it.jsx)("div",{className:"font-medium",children:"Nuevo SubFlow"}),(0,it.jsx)("div",{className:"text-[10px] text-text-muted",children:"Con Entry + Return"})]})]})]})})]})]}),(0,it.jsx)(Qi.AnimatePresence,{children:p&&(0,it.jsx)(Qi.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden border-b border-border-default",children:(0,it.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3",children:[b==="subflow"?(0,it.jsx)(Ro.Network,{size:14,className:"text-violet-400 shrink-0"}):(0,it.jsx)(Ro.FileText,{size:14,className:"text-cyan-400 shrink-0"}),(0,it.jsx)("input",{autoFocus:!0,value:x,onChange:E=>y(E.target.value),onKeyDown:E=>{E.key==="Enter"&&w(),E.key==="Escape"&&h(!1)},placeholder:b==="subflow"?"Nombre del subflow...":"Nombre del blueprint...",className:"flex-1 bg-surface-glass border border-border-default rounded-lg px-3 py-1.5 text-xs text-text-primary focus:outline-hidden focus:border-cyan-500/50 font-mono"}),(0,it.jsx)("button",{onClick:w,className:"p-1.5 rounded-lg bg-cyan-500/20 text-cyan-400 hover:bg-cyan-500/30",children:(0,it.jsx)(Ro.Check,{size:14})}),(0,it.jsx)("button",{onClick:()=>h(!1),className:"p-1.5 rounded-lg hover:bg-surface-glass text-text-muted",children:(0,it.jsx)(Ro.X,{size:14})})]})})}),(0,it.jsxs)("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:[(0,it.jsxs)("div",{className:"px-2 py-1",children:[(0,it.jsx)("div",{className:"px-2 py-1.5 text-[9px] font-bold text-text-muted uppercase tracking-widest",children:"Blueprints Principales"}),k.map(([E,P])=>(0,it.jsx)(cx,{id:E,name:P.name||E,nodeCount:P.keyframes?.length||0,isActive:E===o,onSelect:()=>C(E),onRename:N=>u(E,N),onDuplicate:()=>{s(d(E))},onDelete:k.length>1?()=>A(E):void 0},E))]}),M.length>0&&(0,it.jsxs)("div",{className:"px-2 py-1 border-t border-border-subtle",children:[(0,it.jsx)("div",{className:"px-2 py-1.5 text-[9px] font-bold text-text-muted uppercase tracking-widest",children:"Subflujos"}),M.map(([E,P])=>{let N=T[E]||"";return(0,it.jsx)(cx,{id:E,name:P.name||E,nodeCount:P.keyframes?.length||0,isActive:N===o,isSubflow:!0,onSelect:()=>N&&C(N),onRename:D=>N&&u(N,D),onDuplicate:()=>N&&s(d(N)),onDelete:()=>N&&A(N)},E)})]})]})]})]})})}});var rk,xs,Hn,Oh,nk=U(()=>{"use strict";rk=require("react"),xs=require("lucide-react"),Hn=require("react/jsx-runtime"),Oh=({node:t,activeId:e,onNavigate:r})=>{let[n,o]=(0,rk.useState)(t.depth<2),s=t.children.length>0,i=t.id===e,a=t.type==="trigger"?(0,Hn.jsx)(xs.Zap,{size:13,className:"text-amber-400"}):t.type==="subflow"?(0,Hn.jsx)(xs.Network,{size:13,className:t.isCyclic?"text-red-400":"text-violet-400"}):t.type==="orphan"?(0,Hn.jsx)(xs.AlertTriangle,{size:13,className:"text-text-muted"}):(0,Hn.jsx)(xs.FileText,{size:13,className:"text-cyan-400"});return(0,Hn.jsxs)("div",{children:[(0,Hn.jsxs)("div",{className:`flex items-center gap-1.5 px-2 py-1.5 rounded-lg cursor-pointer transition-all mb-0.5 ${i?"bg-cyan-500/15 border border-cyan-500/30":t.isCyclic?"bg-red-500/5 border border-red-500/20 hover:bg-red-500/10":"hover:bg-surface-glass border border-transparent"}`,style:{paddingLeft:`${8+t.depth*16}px`},onClick:()=>r(t.id),children:[s?(0,Hn.jsx)("button",{onClick:l=>{l.stopPropagation(),o(!n)},className:"p-0.5 rounded hover:bg-surface-glass text-text-muted shrink-0",children:n?(0,Hn.jsx)(xs.ChevronDown,{size:12}):(0,Hn.jsx)(xs.ChevronRight,{size:12})}):(0,Hn.jsx)("span",{className:"w-5 shrink-0"}),a,(0,Hn.jsx)("span",{className:`text-xs truncate flex-1 ${i?"text-text-primary font-medium":t.isCyclic?"text-red-300":"text-text-secondary"}`,children:t.name}),t.isCyclic&&(0,Hn.jsx)("span",{className:"text-[8px] bg-red-500/20 text-red-400 px-1 py-0.5 rounded font-mono",children:"CICLO"}),t.type==="trigger"&&(0,Hn.jsx)("span",{className:"text-[8px] bg-amber-500/10 text-amber-400 px-1 py-0.5 rounded font-mono",children:"\u26A1"})]}),s&&n&&(0,Hn.jsx)("div",{children:t.children.map(l=>(0,Hn.jsx)(Oh,{node:l,activeId:e,onNavigate:r},l.id))})]})}});var ok,Ku,bd,dx,sk,Hr,ik,ak=U(()=>{"use strict";ok=require("react"),Ku=require("motion/react"),bd=require("lucide-react"),dx=require("@decido/engine");ot();sk=require("@decido/engine");nk();Hr=require("react/jsx-runtime"),ik=({isOpen:t,onClose:e})=>{let r=(0,dx.useTimelineStore)(u=>u.timelines),n=(0,dx.useTimelineStore)(u=>u.blueprintLibrary),o=X(u=>u.setPrototypeBrand),s=(0,sk.useBlueprintNavigation)(u=>u.resetNavigation),i=X(u=>u.prototypeBrand),{roots:a,orphans:l,cycleWarnings:c}=(0,ok.useMemo)(()=>{let u={},f=new Set;for(let[S,w]of Object.entries(r)){let C=(w.keyframes||[]).filter(A=>A.track==="subflow"&&A.targetBlueprintId);C.length>0&&(u[S]=C.map(A=>A.targetBlueprintId),C.forEach(A=>f.add(A.targetBlueprintId)))}let p={};for(let S of Object.keys(r))if(S.startsWith("subflow_")){let w=`bp_${S.replace("subflow_","")}`;p[w]=S}let h=new Set([...f].map(S=>p[S]).filter(Boolean)),b=[],g=(S,w,C)=>{let A=r[S],k=A?.name||S,M=S.startsWith("subflow_"),T=(A?.keyframes||[]).some(D=>D.track==="trigger");if(w.has(S))return b.push(`Ciclo: ${[...w].join(" \u2192 ")} \u2192 ${S}`),{id:S,name:k,type:"subflow",children:[],isCyclic:!0,depth:C};let E=new Set(w);E.add(S);let N=(u[S]||[]).map(D=>{let R=p[D];return R?g(R,E,C+1):{id:D,name:D,type:"orphan",children:[],depth:C+1}});return{id:S,name:k,type:T?"trigger":M?"subflow":"blueprint",children:N,depth:C}},x=Object.keys(u).filter(S=>!h.has(S)),y=x.map(S=>g(S,new Set,0)),v=Object.keys(n).filter(S=>{let w=p[S];return w?!f.has(S)&&!x.includes(w):!1}).map(S=>({id:p[S]||S,name:n[S]?.name||S,type:"subflow",children:[],depth:0}));return{roots:y,orphans:v,cycleWarnings:b}},[r,n]),d=u=>{s(),o(u)};return(0,Hr.jsx)(Ku.AnimatePresence,{children:t&&(0,Hr.jsxs)(Hr.Fragment,{children:[(0,Hr.jsx)(Ku.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-surface-overlay z-40",onClick:e}),(0,Hr.jsxs)(Ku.motion.div,{initial:{opacity:0,x:-20,scale:.95},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:-20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:"fixed left-4 bottom-20 z-50 w-96 max-h-[60vh] bg-surface-primary border border-border-default rounded-2xl shadow-2xl overflow-hidden flex flex-col",style:{backdropFilter:"blur(20px)"},onClick:u=>u.stopPropagation(),children:[(0,Hr.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-glass",children:[(0,Hr.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Hr.jsx)(bd.TreePine,{size:16,className:"text-emerald-400"}),(0,Hr.jsx)("span",{className:"text-sm font-bold text-text-primary tracking-wide",children:"Jerarqu\xEDa"}),c.length>0&&(0,Hr.jsxs)("span",{className:"text-[10px] bg-red-500/20 text-red-400 px-1.5 py-0.5 rounded-full font-mono flex items-center gap-1",children:[(0,Hr.jsx)(bd.AlertTriangle,{size:10})," ",c.length," ciclo(s)"]})]}),(0,Hr.jsx)("button",{onClick:e,className:"p-1.5 rounded-lg hover:bg-surface-glass text-text-muted transition-colors",children:(0,Hr.jsx)(bd.X,{size:14})})]}),(0,Hr.jsxs)("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-2",children:[a.length===0&&l.length===0&&(0,Hr.jsx)("div",{className:"text-center text-text-muted text-xs py-8",children:"No hay flujos con subflows referenciados"}),a.map(u=>(0,Hr.jsx)(Oh,{node:u,activeId:i,onNavigate:d},u.id)),l.length>0&&(0,Hr.jsxs)("div",{className:"mt-3 pt-3 border-t border-border-subtle",children:[(0,Hr.jsx)("div",{className:"px-2 py-1 text-[9px] font-bold text-text-muted uppercase tracking-widest",children:"Sin Referencia"}),l.map(u=>(0,Hr.jsx)(Oh,{node:u,activeId:i,onNavigate:d},u.id))]})]})]})]})})}});var lk,xd,Vn,ck,dk=U(()=>{"use strict";lk=Re(require("react")),xd=require("lucide-react"),Vn=require("react/jsx-runtime"),ck=lk.default.memo(function({currentTime:e,seekTime:r,playbackSpeed:n,setPlaybackSpeed:o,isPlaying:s,setIsPlaying:i,handleResetPlayground:a,currentTimeline:l}){return(0,Vn.jsxs)("div",{className:"flex items-center gap-3 w-full bg-surface-overlay p-2 rounded-xl border border-border-subtle",children:[(0,Vn.jsxs)("span",{className:"text-xs font-mono text-text-secondary w-10 text-right",children:[e.toFixed(1),"s"]}),(0,Vn.jsxs)("div",{className:"relative flex-1 h-6 flex items-center group cursor-pointer",children:[(0,Vn.jsx)("div",{className:"absolute w-full h-1.5 bg-surface-glass rounded-full overflow-hidden group-hover:bg-surface-glass transition-colors",children:(0,Vn.jsx)("div",{className:"h-full bg-purple-500/50 group-hover:bg-purple-400 transition-colors",style:{width:`${e/Math.max(l.duration,1)*100}%`}})}),(0,Vn.jsx)("input",{type:"range",min:"0",max:l.duration,step:"0.1",value:e,onChange:c=>r(parseFloat(c.target.value)),className:"absolute w-full h-full opacity-0 cursor-pointer z-20"}),l.keyframes.map((c,d)=>(0,Vn.jsx)("div",{className:"absolute top-1/2 -translate-y-1/2 w-2 h-2 rounded-full border border-[#1e1e1f] z-10 pointer-events-none transition-all group-hover:scale-125",style:{left:`calc(${c.t/l.duration*100}% - 4px)`,backgroundColor:e>=c.t?"#a855f7":"#52525b"}},d))]}),(0,Vn.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10",children:[l.duration.toFixed(1),"s"]}),(0,Vn.jsxs)("div",{className:"flex gap-1 border-l border-border-default pl-2 ml-1",children:[(0,Vn.jsx)("button",{onClick:()=>i(!s),className:"w-8 h-8 rounded-lg bg-surface-glass hover:bg-purple-500/20 text-text-primary flex items-center justify-center transition-colors",children:s?(0,Vn.jsx)(xd.Pause,{size:14}):(0,Vn.jsx)(xd.Play,{size:14,className:"ml-0.5"})}),(0,Vn.jsxs)("button",{onClick:()=>o(n===1?2:1),className:"w-8 h-8 rounded-lg hover:bg-surface-glass text-text-secondary flex items-center justify-center transition-colors text-[10px] font-bold",children:[n,"x"]}),(0,Vn.jsx)("button",{onClick:a,className:"w-8 h-8 rounded-lg hover:bg-surface-glass text-text-secondary flex items-center justify-center transition-colors",title:"Rewind & Reset Engine",children:(0,Vn.jsx)(xd.RotateCcw,{size:14})})]})]})})});var Jo,_h,Vr,yd,ir,uk,fk,pk=U(()=>{"use strict";Jo=Re(require("react")),_h=require("motion/react"),Vr=require("lucide-react"),yd=require("@decido/engine");ot();xi();ir=require("react/jsx-runtime"),uk=[{cmd:"/add",args:"<type> [label]",desc:"Agregar nodo",icon:(0,ir.jsx)(Vr.MessageCircle,{size:14,className:"text-blue-400"})},{cmd:"/shell",args:"<action> [label]",desc:"Nodo Shell",icon:(0,ir.jsx)(Vr.Terminal,{size:14,className:"text-teal-400"})},{cmd:"/connect",args:"<nodeA> <nodeB>",desc:"Conectar nodos",icon:(0,ir.jsx)(Vr.Network,{size:14,className:"text-violet-400"})},{cmd:"/var",args:"<name> <value>",desc:"Definir variable",icon:(0,ir.jsx)(Vr.Variable,{size:14,className:"text-emerald-400"})},{cmd:"/export",args:"",desc:"Exportar DSD",icon:(0,ir.jsx)(Vr.Download,{size:14,className:"text-cyan-400"})},{cmd:"/ui",args:"[componentId]",desc:"UI Components",icon:(0,ir.jsx)(Vr.Layout,{size:14,className:"text-pink-400"})},{cmd:"/clear",args:"",desc:"Limpiar nodos",icon:(0,ir.jsx)(Vr.Trash2,{size:14,className:"text-red-400"})},{cmd:"/help",args:"",desc:"Ayuda",icon:(0,ir.jsx)(Vr.HelpCircle,{size:14,className:"text-text-secondary"})}],fk=Jo.default.memo(function({inputValue:e="",setInputValue:r,isGenerating:n=!1,handleGeneratePlayground:o,setIsVoiceActive:s,prototypeBrand:i="",handleExport:a}){let[l,c]=(0,Jo.useState)(!1),[d,u]=(0,Jo.useState)(0),f=(0,Jo.useMemo)(()=>{if(!e.startsWith("/"))return[];let g=e.split(" ")[0].toLowerCase();return uk.filter(x=>x.cmd.startsWith(g))},[e]);(0,Jo.useEffect)(()=>{c(e.startsWith("/")&&f.length>0),u(0)},[e,f.length]);let p=(0,Jo.useCallback)(()=>{let g=e.trim().split(/\s+/),x=g[0]?.toLowerCase();if(x==="/add"||x==="/shell"){let y=g[1]||(x==="/shell"?"config":"dialogue"),m=g.slice(2).join(" ")||y,v={dialogue:"dialogue",logic:"logic",ui:"ui",render:"render",subflow:"subflow",entry:"entry",return:"return",trigger:"trigger",condition:"condition",set:"set",registerButton:"shell:registerButton",activitybar:"shell:registerButton",registerTab:"shell:registerTab",tab:"shell:registerTab",registerPanel:"shell:registerPanel",panel:"shell:registerPanel",registerSidebar:"shell:registerSidebar",sidebar:"shell:registerSidebar",registerStatusBar:"shell:registerStatusBar",statusbar:"shell:registerStatusBar",registerTopBar:"shell:registerTopBar",topbar:"shell:registerTopBar",registerAction:"shell:registerAction",command:"shell:registerAction",toggleSidebar:"shell:toggleSidebar",togglePanel:"shell:togglePanel",splitPane:"shell:splitPane",focusTab:"shell:focusTab",closeTab:"shell:closeTab",setTheme:"shell:setTheme",theme:"shell:setTheme",applyPalette:"shell:applyPalette",palette:"shell:applyPalette",updateToken:"shell:updateToken",token:"shell:updateToken",notification:"shell:notification",notify:"shell:notification",modal:"shell:modal",execCommand:"shell:execCommand",exec:"shell:execCommand",shortcut:"shell:shortcut",emitEvent:"shell:emitEvent",emit:"shell:emitEvent",config:"shell:config",shellConfig:"shell:config"},S={"shell:registerButton":"registerActivityBarItem","shell:registerTab":"openTab","shell:registerPanel":"registerPanelView","shell:registerSidebar":"registerSidebarView","shell:registerStatusBar":"registerStatusBarItem","shell:registerTopBar":"registerTopBarItem","shell:registerAction":"registerCommand","shell:toggleSidebar":"toggleSidebar","shell:togglePanel":"togglePanel","shell:splitPane":"splitPane","shell:focusTab":"focusTab","shell:closeTab":"closeTab","shell:setTheme":"setTheme","shell:applyPalette":"applyPalette","shell:updateToken":"updateToken","shell:notification":"showNotification","shell:modal":"showModal","shell:execCommand":"executeCommand","shell:shortcut":"registerShortcut","shell:emitEvent":"emitEvent","shell:config":"shellConfig"},w=y;x==="/shell"&&!y.startsWith("shell:")?w=v[y]||`shell:${y}`:w=v[y]||y;let C={t:Date.now(),track:w,position:{x:200+Math.random()*600,y:100+Math.random()*400},label:m,state:m};w==="dialogue"?(C.speech=m,C.actorId="assistant"):w==="subflow"&&(C.targetBlueprintId=""),w.startsWith("shell:")&&(C.track="shell",C.type=w,C.shellAction=S[w]||w.replace("shell:","")),yd.useTimelineStore.getState().addKeyframe(i,C),X.getState().addLog(`\u2705 Nodo "${m}" (${w}) agregado al canvas`,"success")}else if(x==="/var"){let y=g[1],m=g.slice(2).join(" ");y&&(yd.useEngineStore.getState().setVariable(y,m||""),X.getState().addLog(`\u{1F4CA} Variable "${y}" = "${m}"`,"info"))}else if(x==="/export")a();else if(x==="/ui"){let y=Object.values(Mn.getState().components);if(g[1]){let m=y.find(v=>v.id===g[1]||v.name.toLowerCase().includes(g[1].toLowerCase()));m&&(yd.useTimelineStore.getState().addKeyframe(i,{t:Date.now(),track:"render",position:{x:200+Math.random()*600,y:100+Math.random()*400},label:m.name,state:m.name,uiSchema:m.schema,autoComplete:!1}),X.getState().addLog(`\u{1F5BC}\uFE0F UI Component "${m.name}" agregado`,"success"))}else X.getState().addLog(`\u{1F3A8} UI Components:
|
|
48
|
+
${y.map(m=>`\u2022 ${m.name} (${m.source})`).join(`
|
|
49
|
+
`)||"Ninguno disponible"}`,"info")}else if(x==="/clear")yd.useTimelineStore.getState().setDynamicTimelines(y=>({...y,[i]:{...y[i],keyframes:[],edges:[]}})),X.getState().addLog("\u{1F5D1}\uFE0F Canvas limpiado","warning");else if(x==="/help")X.getState().addLog(`\u{1F4CB} Comandos Creator:
|
|
50
|
+
${uk.map(y=>`${y.cmd} ${y.args} \u2014 ${y.desc}`).join(`
|
|
51
|
+
`)}`,"info");else return!1;return r(""),!0},[e,i,a,r]),h=(0,Jo.useCallback)(()=>{e.startsWith("/")?p():o()},[e,p,o]),b=(0,Jo.useCallback)(g=>{if(l){if(g.key==="ArrowDown")g.preventDefault(),u(x=>Math.min(x+1,f.length-1));else if(g.key==="ArrowUp")g.preventDefault(),u(x=>Math.max(x-1,0));else if(g.key==="Enter"&&f[d]){g.preventDefault(),r(f[d].cmd+" "),c(!1);return}else if(g.key==="Escape"){c(!1);return}}g.key==="Enter"&&!l&&!n&&h()},[l,d,f,n,h,r]);return(0,ir.jsxs)("div",{className:"relative",children:[(0,ir.jsx)(_h.AnimatePresence,{children:l&&(0,ir.jsxs)(_h.motion.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},className:"absolute bottom-full left-0 mb-2 w-full bg-surface-secondary/95 backdrop-blur-xl border border-border-default rounded-xl shadow-2xl shadow-black/50 overflow-hidden z-50",children:[(0,ir.jsx)("div",{className:"px-3 py-1.5 border-b border-border-subtle",children:(0,ir.jsx)("span",{className:"text-[9px] font-bold text-text-muted uppercase tracking-widest",children:"/ Comandos Creator"})}),(0,ir.jsx)("div",{className:"max-h-[200px] overflow-y-auto py-1",children:f.map((g,x)=>(0,ir.jsxs)("button",{onClick:()=>{r(g.cmd+" "),c(!1)},className:`w-full flex items-center gap-2.5 px-3 py-2 text-xs transition-colors ${x===d?"bg-purple-500/15 text-text-primary":"text-text-secondary hover:text-text-primary hover:bg-surface-glass"}`,children:[g.icon,(0,ir.jsx)("span",{className:"font-mono font-bold text-purple-300",children:g.cmd}),(0,ir.jsx)("span",{className:"text-text-muted font-mono",children:g.args}),(0,ir.jsx)("span",{className:"ml-auto text-[10px] text-text-muted truncate max-w-[150px]",children:g.desc})]},g.cmd))})]})}),(0,ir.jsxs)("div",{className:"flex items-center gap-2 sm:gap-3 w-full bg-surface-overlay p-1.5 sm:p-2 rounded-xl border border-border-subtle focus-within:border-cyan-500/30 transition-colors mt-2",children:[(0,ir.jsx)(Vr.Wand2,{size:20,className:"text-purple-400 ml-2"}),(0,ir.jsx)("input",{type:"text",placeholder:"Escribe / para comandos, o un prompt AI...",value:e,onChange:g=>r(g.target.value),onKeyDown:b,className:"w-full bg-transparent text-text-primary placeholder-text-muted outline-hidden text-sm h-10"}),(0,ir.jsx)("button",{onClick:h,disabled:n,className:"px-3 sm:px-4 py-2 rounded-lg font-bold text-xs sm:text-sm transition-colors disabled:opacity-50 min-w-[70px] sm:min-w-[100px] flex justify-center items-center bg-purple-500/20 text-purple-400 hover:bg-purple-500/30",children:n?(0,ir.jsx)(Vr.Clock,{size:16,className:"animate-spin"}):"Enviar"}),(0,ir.jsx)("div",{className:"w-px h-6 bg-surface-glass mx-1"}),(0,ir.jsx)("button",{onClick:()=>s(!0),className:"w-10 h-10 rounded-full flex items-center justify-center border transition-all shadow-[0_0_15px_rgba(6,182,212,0.15)] text-purple-400 bg-purple-500/10 border-purple-500/20 hover:bg-purple-500/20",children:(0,ir.jsx)(Vr.Mic,{size:18})})]})]})})});var hk,Rn,mk,Pt,gk,bk=U(()=>{"use strict";hk=Re(require("react")),Rn=require("lucide-react"),mk=require("@decido/engine");ot();Pt=require("react/jsx-runtime"),gk=hk.default.memo(function({dynamicTimelines:e,prototypeBrand:r,showCanvas:n,setShowCanvas:o,isTerminalOpen:s,setIsTerminalOpen:i,isMuted:a,setIsMuted:l,selectedVoice:c,setSelectedVoice:d,isFullscreen:u,toggleFullscreen:f,handleExport:p,config:h,isBlueprintManagerOpen:b,setIsBlueprintManagerOpen:g,isTreeOpen:x,setIsTreeOpen:y}){return(0,Pt.jsxs)("div",{className:"flex w-full overflow-x-auto custom-scrollbar pb-2 sm:pb-3 pt-1 mt-1 items-center justify-between gap-2 sm:gap-4",children:[(0,Pt.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-2 min-w-max",children:[(0,Pt.jsxs)("button",{onClick:()=>g(!b),className:"bg-surface-secondary hover:bg-surface-tertiary border border-border-default rounded-lg text-xs font-medium text-text-primary px-3 py-2 outline-hidden cursor-pointer hover:border-cyan-400/50 transition-colors flex items-center gap-2",children:[(0,Pt.jsx)(Rn.FolderOpen,{size:14,className:"text-cyan-400"}),(0,Pt.jsx)("span",{className:"max-w-[120px] truncate",children:e[r]?.name||r}),(0,Pt.jsx)("span",{className:"text-[10px] text-text-muted font-mono",children:e[r]?.keyframes?.length||0})]}),(0,Pt.jsx)("button",{onClick:()=>y(!x),className:"bg-surface-secondary hover:bg-surface-tertiary border border-border-default rounded-lg text-xs font-medium text-text-primary px-2.5 py-2 outline-hidden cursor-pointer hover:border-emerald-400/50 transition-colors flex items-center gap-1.5",title:"Jerarqu\xEDa de dependencias",children:(0,Pt.jsx)(Rn.TreePine,{size:14,className:"text-emerald-400"})}),(0,Pt.jsx)("div",{className:"w-px h-6 bg-surface-glass mx-1"}),(0,Pt.jsxs)("button",{onClick:()=>o(!n),className:`px-3 py-2 rounded-lg transition-all text-xs font-medium flex items-center gap-2 shrink-0 ${n?"text-text-primary bg-surface-glass":"text-text-secondary hover:text-cyan-400 hover:bg-surface-glass border border-transparent"}`,title:"Panel 3D / Diagrama",children:[(0,Pt.jsx)(Rn.Layers,{size:14})," ",(0,Pt.jsx)("span",{className:"hidden sm:inline",children:"Visualizador"})]}),(0,Pt.jsxs)("button",{onClick:()=>i(!s),className:`px-3 py-2 rounded-lg transition-all text-xs font-medium flex items-center gap-2 shrink-0 ${s?"text-text-primary bg-surface-glass":"text-text-secondary hover:text-purple-400 hover:bg-surface-glass border border-transparent"}`,title:"Panel de Logs",children:[(0,Pt.jsx)(Rn.Terminal,{size:14})," ",(0,Pt.jsx)("span",{className:"hidden sm:inline",children:"Logs OS"})]}),(0,Pt.jsx)("div",{className:"w-px h-6 bg-surface-glass mx-1"}),(0,Pt.jsx)("button",{onClick:()=>l(!a),className:`px-3 py-2 rounded-lg transition-all text-xs font-medium flex items-center justify-center shrink-0 ${a?"text-text-muted hover:text-red-400 hover:bg-surface-glass border border-transparent":"text-text-primary bg-surface-glass"}`,title:a?"Activar Audio":"Silenciar",children:a?(0,Pt.jsx)(Rn.VolumeX,{size:16}):(0,Pt.jsx)(Rn.Volume2,{size:16})}),(0,Pt.jsx)("select",{value:c,onChange:m=>d(m.target.value),className:"bg-surface-secondary hover:bg-surface-tertiary border border-border-default rounded-lg text-xs font-medium text-text-primary px-3 py-2 outline-hidden cursor-pointer focus:border-cyan-400 transition-colors",children:h?.voices?.map(m=>(0,Pt.jsxs)("option",{value:m,children:["Voz: ",m]},m))}),(0,Pt.jsx)("button",{onClick:f,className:"px-3 py-2 rounded-lg transition-all text-xs font-medium flex items-center justify-center shrink-0 text-text-muted hover:text-text-primary hover:bg-surface-glass border border-transparent",title:"Pantalla Completa",children:u?(0,Pt.jsx)(Rn.Minimize,{size:16}):(0,Pt.jsx)(Rn.Maximize,{size:16})})]}),(0,Pt.jsxs)("div",{className:"flex items-center gap-2 sm:gap-3 shrink-0 pr-1",children:[(0,Pt.jsxs)("label",{className:"flex items-center gap-2 shrink-0 px-4 py-2 rounded-xl font-medium text-sm transition-colors border bg-cyan-500/10 text-cyan-500 hover:bg-cyan-500/20 border-transparent cursor-pointer",title:"Importar DSD",children:[(0,Pt.jsx)(Rn.Layers,{size:16})," ",(0,Pt.jsx)("span",{className:"hidden sm:inline",children:"Importar DSD"}),(0,Pt.jsx)("input",{type:"file",accept:".dsd,.json",className:"hidden",onChange:m=>{let v=m.target.files?.[0];if(!v)return;let S=new FileReader;S.onload=w=>{try{let C=JSON.parse(w.target?.result);C.format==="decido-standard-document"&&C.blueprint?(mk.useTimelineStore.getState().setDynamicTimelines(A=>({...A,[C.brand||r]:C.blueprint})),X.getState().addLog(`Se ha importado el blueprint de ${C.brand} (${C.blueprint.keyframes.length} nodos)`,"success")):X.getState().addLog("El archivo no es un DSD v\xE1lido.","error")}catch{X.getState().addLog("Error al parsear archivo DSD.","error")}},S.readAsText(v),m.target.value=""}})]}),(0,Pt.jsxs)("button",{onClick:p,className:"flex items-center gap-2 shrink-0 px-4 py-2 rounded-xl font-medium text-sm transition-colors border bg-purple-500/10 text-purple-400 hover:bg-purple-500/20 border-transparent",title:"Exportar DSD",children:[(0,Pt.jsx)(Rn.Layers,{size:16})," ",(0,Pt.jsx)("span",{className:"hidden sm:inline",children:"Exportar DSD"})]})]})]})})});var qu,xk,yk,Br,vk,wk=U(()=>{"use strict";qu=Re(require("react")),xk=require("motion/react"),yk=require("lucide-react");tk();ak();dk();pk();bk();Br=require("react/jsx-runtime"),vk=qu.default.memo(function({step:e,isVoiceActive:r,setIsVoiceActive:n,currentTime:o,seekTime:s,playbackSpeed:i,setPlaybackSpeed:a,isPlaying:l,setIsPlaying:c,handleResetPlayground:d,dynamicTimelines:u,prototypeBrand:f,setPrototypeBrand:p,inputValue:h,setInputValue:b,isGenerating:g,handleGeneratePlayground:x,showCanvas:y,setShowCanvas:m,isTerminalOpen:v,setIsTerminalOpen:S,isMuted:w,setIsMuted:C,selectedVoice:A,setSelectedVoice:k,isFullscreen:M,toggleFullscreen:T,handleExport:E,dynamicPersona:P,setSuggestions:N,isCreatorMode:D,VoiceWidget:R,config:O}){if(e==="action"||e==="profile"||!D&&!r)return null;let[B,L]=(0,qu.useState)(!1),[H,j]=(0,qu.useState)(!1),$=u[f]||{duration:10,keyframes:[]};return(0,Br.jsxs)(Br.Fragment,{children:[(0,Br.jsx)("div",{className:"absolute bottom-0 left-0 w-full p-3 sm:p-4 md:p-6 bg-linear-to-t from-surface-primary via-surface-primary to-transparent z-40 flex flex-col items-center",children:(0,Br.jsx)(xk.motion.div,{layout:!0,className:`w-full max-w-4xl relative ${r?"h-64":""}`,children:r?(0,Br.jsxs)("div",{className:"flex flex-col w-full h-full relative p-2 bg-surface-tertiary border border-cyan-500/30 rounded-4xl shadow-lg",children:[(0,Br.jsxs)("div",{className:"flex w-full items-center justify-between mb-2",children:[(0,Br.jsx)("span",{className:"text-cyan-400 font-medium px-4 bg-linear-to-r from-cyan-400 via-purple-400 to-indigo-400 text-transparent bg-clip-text animate-pulse",children:"Capturando Audio de IA..."}),(0,Br.jsx)("button",{onClick:()=>n(!1),className:"w-8 h-8 rounded-full bg-surface-glass hover:bg-surface-glass flex items-center justify-center text-text-secondary hover:text-text-primary transition-colors",children:(0,Br.jsx)(yk.X,{size:16})})]}),(0,Br.jsx)("div",{className:"flex-1 w-full rounded-2xl overflow-hidden relative",children:R?(0,Br.jsx)(R,{isCompact:!0,persona:P,onSuggestionsUpdate:N,selectedVoice:A,controls:{setPrototypeBrand:p,setShowCanvas:m,setIsPlaying:c,handleExport:E,setInputValue:b,handleGeneratePlayground:x}}):(0,Br.jsx)("div",{className:"p-4 flex flex-col items-center justify-center h-full text-text-muted font-mono text-sm border border-border-subtle rounded-xl bg-surface-glass",children:"M\xF3dulo de Voz no proporcionado."})})]}):(0,Br.jsxs)("div",{className:`bg-surface-tertiary/90 border border-border-default rounded-xl sm:rounded-2xl shadow-xl backdrop-blur-md p-3 sm:p-4 md:p-5 flex flex-col gap-3 sm:gap-4 transition-all ${D?"border-purple-500/30":""}`,children:[D&&(0,Br.jsx)(ck,{currentTime:o,seekTime:s,playbackSpeed:i,setPlaybackSpeed:a,isPlaying:l,setIsPlaying:c,handleResetPlayground:d,currentTimeline:$}),D&&(0,Br.jsxs)(Br.Fragment,{children:[(0,Br.jsx)(fk,{inputValue:h,setInputValue:b,isGenerating:g,handleGeneratePlayground:x,setIsVoiceActive:n,prototypeBrand:f,handleExport:E}),(0,Br.jsx)(gk,{dynamicTimelines:u,prototypeBrand:f,showCanvas:y,setShowCanvas:m,isTerminalOpen:v,setIsTerminalOpen:S,isMuted:w,setIsMuted:C,selectedVoice:A,setSelectedVoice:k,isFullscreen:M,toggleFullscreen:T,handleExport:E,config:O,isBlueprintManagerOpen:B,setIsBlueprintManagerOpen:L,isTreeOpen:H,setIsTreeOpen:j})]})]})})}),(0,Br.jsx)(ek,{isOpen:B,onClose:()=>L(!1)}),(0,Br.jsx)(ik,{isOpen:H,onClose:()=>j(!1)})]})})});var Sk,Lh,La,Ba,ux=U(()=>{"use strict";Sk=require("react"),Lh=require("lucide-react"),La=require("react/jsx-runtime"),Ba=class extends Sk.Component{state={hasError:!1,error:null};static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,r){console.error(`[PlaygroundErrorBoundary] Error capturado en ${this.props.fallbackName||"componente"}:`,e,r)}handleReset=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?(0,La.jsxs)("div",{className:"flex flex-col items-center justify-center w-full h-full min-h-[150px] bg-red-500/10 border border-red-500/20 rounded-xl p-4 text-center backdrop-blur-xs",children:[(0,La.jsx)(Lh.AlertTriangle,{className:"text-red-400 mb-3",size:32}),(0,La.jsxs)("h3",{className:"text-red-400 font-bold mb-1",children:["Fallo en ",this.props.fallbackName||"M\xF3dulo"]}),(0,La.jsx)("p",{className:"text-xs text-red-300/80 mb-4 max-w-xs truncate",title:this.state.error?.message,children:this.state.error?.message||"Excepci\xF3n desconocida en el renderizado."}),(0,La.jsxs)("button",{onClick:this.handleReset,className:"flex items-center gap-2 px-3 py-1.5 bg-red-500/20 hover:bg-red-500/30 text-red-300 rounded-lg text-xs transition-colors border border-red-500/20",children:[(0,La.jsx)(Lh.RefreshCw,{size:12}),"Reiniciar M\xF3dulo"]})]}):this.props.children}}});var Nk,xr,Si,Yu,Bh,Ck,zh=U(()=>{"use strict";Nk=Re(require("react")),xr=require("lucide-react"),Si=require("react/jsx-runtime"),Yu={info:{icon:xr.Info,color:"text-blue-400",bg:"bg-blue-500/10",label:"INFO"},warn:{icon:xr.AlertTriangle,color:"text-amber-400",bg:"bg-amber-500/10",label:"WARN"},error:{icon:xr.AlertCircle,color:"text-red-400",bg:"bg-red-500/10",label:"ERROR"},debug:{icon:xr.Bug,color:"text-purple-400",bg:"bg-purple-500/10",label:"DEBUG"}},Bh={trigger:{icon:xr.Zap,color:"text-yellow-400",label:"Trigger"},dialogue:{icon:xr.MessageSquare,color:"text-blue-400",label:"Di\xE1logo"},logic:{icon:xr.Settings,color:"text-orange-400",label:"L\xF3gica"},ui:{icon:xr.Map,color:"text-green-400",label:"UI"},render:{icon:xr.Map,color:"text-pink-400",label:"Render"},condition:{icon:xr.GitBranch,color:"text-amber-400",label:"Condici\xF3n"},subflow:{icon:xr.ArrowRight,color:"text-purple-400",label:"Subflow"},entry:{icon:xr.Circle,color:"text-emerald-400",label:"Entry"},return:{icon:xr.ArrowRight,color:"text-red-400",label:"Return"},set:{icon:xr.Settings,color:"text-cyan-400",label:"Variable"},morph:{icon:xr.Map,color:"text-violet-400",label:"Morph"}},Ck=Nk.default.memo(function({entry:e}){let r=Yu[e.level],n=r.icon;return(0,Si.jsxs)("div",{className:`flex items-start gap-2 px-3 py-1 hover:bg-surface-glass font-mono text-[11px] leading-relaxed border-b border-border-subtle ${r.bg}`,children:[(0,Si.jsx)("span",{className:"text-text-muted shrink-0 w-[70px] pt-0.5",children:e.timestamp}),(0,Si.jsx)(n,{size:12,className:`${r.color} shrink-0 mt-0.5`}),(0,Si.jsx)("span",{className:`font-bold shrink-0 w-[38px] ${r.color}`,children:r.label}),e.categories.length>0&&(0,Si.jsx)("span",{className:"shrink-0 flex gap-1",children:e.categories.map((o,s)=>(0,Si.jsx)("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold bg-surface-glass text-text-secondary uppercase tracking-widest",children:o},s))}),(0,Si.jsx)("span",{className:"text-text-primary flex-1 break-all",children:e.message}),e.data!==void 0&&(0,Si.jsx)("span",{className:"text-text-muted shrink-0 truncate max-w-[200px]",children:typeof e.data=="object"?JSON.stringify(e.data):String(e.data)})]})})});function kk(){let t=Ut(p=>p.logEntries),e=Ut(p=>p.logFilters),r=Ut(p=>p.allCategories),n=Ut(p=>p.clearLogs),o=Ut(p=>p.toggleLevel),s=Ut(p=>p.toggleCategory),[i,a]=(0,Ni.useState)(!1),[l,c]=(0,Ni.useState)(!1),d=(0,Ni.useRef)(null);(0,Ni.useEffect)(()=>{d.current&&(d.current.scrollTop=d.current.scrollHeight)},[t.length]);let u=(0,Ni.useMemo)(()=>t.filter(p=>!(!e.levels.has(p.level)||e.categories.size>0&&!p.categories.some(h=>e.categories.has(h)))),[t,e]),f=(0,Ni.useMemo)(()=>Array.from(r).sort(),[r]);return(0,zr.jsxs)("div",{className:"flex flex-col h-full",children:[(0,zr.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border-subtle shrink-0 bg-surface-primary/50",children:[(0,zr.jsx)("div",{className:"flex gap-1",children:Object.keys(Yu).map(p=>{let h=Yu[p],b=e.levels.has(p),g=t.filter(x=>x.level===p).length;return(0,zr.jsxs)("button",{onClick:()=>o(p),className:`flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold transition-all border ${b?`${h.bg} ${h.color} border-current/20`:"bg-transparent text-text-muted border-transparent hover:text-text-secondary"}`,children:[h.label,g>0&&(0,zr.jsx)("span",{className:"text-[9px] opacity-60",children:g})]},p)})}),(0,zr.jsx)("div",{className:"flex-1"}),f.length>0&&(0,zr.jsx)("button",{onClick:()=>a(!i),className:`p-1 rounded transition-colors ${i?"bg-cyan-500/20 text-cyan-400":"text-text-muted hover:text-text-primary hover:bg-surface-glass"}`,title:"Filtrar categor\xEDas",children:(0,zr.jsx)(za.Filter,{size:12})}),(0,zr.jsxs)("span",{className:"text-[10px] text-text-muted font-mono",children:[u.length,"/",t.length]}),(0,zr.jsx)("button",{onClick:()=>{let p=u.map(h=>{let b=h.categories.length>0?` [${h.categories.join(",")}]`:"",g=h.data!==void 0?` | ${typeof h.data=="object"?JSON.stringify(h.data):String(h.data)}`:"";return`[${h.timestamp}] ${Yu[h.level].label}${b} ${h.message}${g}`}).join(`
|
|
52
|
+
`);navigator.clipboard.writeText(p).then(()=>{c(!0),setTimeout(()=>c(!1),1500)})},className:`p-1 rounded transition-colors ${l?"text-green-400 bg-green-500/10":"text-text-muted hover:text-cyan-400 hover:bg-cyan-500/10"}`,title:"Copiar logs visibles",children:l?(0,zr.jsx)(za.Check,{size:12}):(0,zr.jsx)(za.Copy,{size:12})}),(0,zr.jsx)("button",{onClick:n,className:"p-1 rounded text-text-muted hover:text-red-400 hover:bg-red-500/10 transition-colors",title:"Limpiar logs",children:(0,zr.jsx)(za.Trash2,{size:12})})]}),(0,zr.jsx)($h.AnimatePresence,{children:i&&f.length>0&&(0,zr.jsx)($h.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden border-b border-border-subtle",children:(0,zr.jsx)("div",{className:"flex flex-wrap gap-1 px-3 py-2 bg-surface-primary/80",children:f.map(p=>{let h=e.categories.size===0||e.categories.has(p);return(0,zr.jsx)("button",{onClick:()=>s(p),className:`px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider transition-all border ${h?"bg-cyan-500/10 text-cyan-400 border-cyan-500/20":"bg-transparent text-text-muted border-transparent hover:text-text-secondary"}`,children:p},p)})})})}),(0,zr.jsx)("div",{ref:d,className:"flex-1 overflow-y-auto custom-scrollbar",children:u.length===0?(0,zr.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted text-xs font-mono",children:"Sin entradas de log"}):u.map(p=>(0,zr.jsx)(Ck,{entry:p},p.id))})]})}var Ni,$h,za,zr,Ek=U(()=>{"use strict";Ni=require("react"),$h=require("motion/react"),za=require("lucide-react");Us();zh();zr=require("react/jsx-runtime")});function Ak(){let t=X(i=>i.prototypeBrand),r=(0,Ik.useTimelineStore)(i=>i.timelines)[t],n=(0,Tk.useMemo)(()=>{if(!r)return null;let i=r.keyframes||[],a=r.edges||[],l=new Set(i.map(y=>y.id)),c={};i.forEach(y=>{let m=y.track||"unknown";c[m]=(c[m]||0)+1});let d=new Set(a.map(y=>y.target)),u=new Set(a.map(y=>y.source)),f=i.filter(y=>y.track==="trigger"||y.track==="entry"?!1:!d.has(y.id)&&a.length>0),p=i.filter(y=>d.has(y.id)&&!u.has(y.id)&&y.track!=="return"),h=a.filter(y=>!l.has(y.target)||!l.has(y.source)),b=i.filter(y=>!y.label&&!y.state&&y.track!=="trigger"),g=f.length+h.length+b.length,x=Math.max(0,Math.min(100,100-g*10));return{kfs:i,edges:a,trackCounts:c,orphans:f,terminals:p,deadEdges:h,unlabeled:b,score:x,issues:g}},[r]);if(!r||!n)return(0,Tt.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted text-xs font-mono",children:"Sin blueprint activo"});let o=n.score>=80?"text-green-400":n.score>=50?"text-amber-400":"text-red-400",s=n.score>=80?"bg-green-500/10":n.score>=50?"bg-amber-500/10":"bg-red-500/10";return(0,Tt.jsxs)("div",{className:"h-full overflow-y-auto custom-scrollbar p-4 space-y-4",children:[(0,Tt.jsxs)("div",{className:`flex items-center gap-4 p-4 rounded-xl ${s} border border-border-subtle`,children:[(0,Tt.jsx)("div",{className:`text-4xl font-black ${o} font-mono`,children:n.score}),(0,Tt.jsxs)("div",{children:[(0,Tt.jsx)("div",{className:`text-sm font-bold ${o}`,children:n.score>=80?"\u2705 Saludable":n.score>=50?"\u26A0\uFE0F Revisar":"\u{1F534} Problemas detectados"}),(0,Tt.jsxs)("div",{className:"text-[11px] text-text-muted",children:[n.kfs.length," nodos \xB7 ",n.edges.length," conexiones \xB7 ",n.issues," problemas"]})]})]}),(0,Tt.jsxs)("div",{className:"space-y-2",children:[(0,Tt.jsx)("div",{className:"text-[11px] font-bold text-text-secondary uppercase tracking-widest",children:"Distribuci\xF3n por Track"}),(0,Tt.jsx)("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-2",children:Object.entries(n.trackCounts).map(([i,a])=>{let l=Bh[i]||{icon:Ci.Circle,color:"text-text-secondary",label:i},c=l.icon;return(0,Tt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-surface-glass border border-border-subtle",children:[(0,Tt.jsx)(c,{size:14,className:l.color}),(0,Tt.jsx)("span",{className:"text-[11px] text-text-primary font-semibold",children:l.label}),(0,Tt.jsx)("span",{className:"ml-auto text-[11px] font-mono text-text-muted",children:a})]},i)})})]}),n.orphans.length>0&&(0,Tt.jsxs)("div",{className:"space-y-1",children:[(0,Tt.jsxs)("div",{className:"text-[11px] font-bold text-amber-400 flex items-center gap-1",children:[(0,Tt.jsx)(Ci.AlertTriangle,{size:12})," Nodos Hu\xE9rfanos (",n.orphans.length,")"]}),n.orphans.map(i=>(0,Tt.jsxs)("div",{className:"pl-5 text-[11px] text-text-muted font-mono",children:["\xB7 ",i.label||i.id," ",(0,Tt.jsxs)("span",{className:"text-text-muted",children:["(",i.track,")"]})]},i.id))]}),n.deadEdges.length>0&&(0,Tt.jsxs)("div",{className:"space-y-1",children:[(0,Tt.jsxs)("div",{className:"text-[11px] font-bold text-red-400 flex items-center gap-1",children:[(0,Tt.jsx)(Ci.XCircle,{size:12})," Conexiones Rotas (",n.deadEdges.length,")"]}),n.deadEdges.map((i,a)=>(0,Tt.jsxs)("div",{className:"pl-5 text-[11px] text-text-muted font-mono",children:["\xB7 ",i.source," \u2192 ",i.target]},a))]}),n.unlabeled.length>0&&(0,Tt.jsxs)("div",{className:"space-y-1",children:[(0,Tt.jsxs)("div",{className:"text-[11px] font-bold text-text-muted flex items-center gap-1",children:[(0,Tt.jsx)(Ci.Info,{size:12})," Sin Etiqueta (",n.unlabeled.length,")"]}),n.unlabeled.slice(0,5).map(i=>(0,Tt.jsxs)("div",{className:"pl-5 text-[11px] text-text-muted font-mono",children:["\xB7 ",i.id," ",(0,Tt.jsxs)("span",{className:"text-text-muted",children:["(",i.track,")"]})]},i.id))]}),n.terminals.length>0&&(0,Tt.jsxs)("div",{className:"space-y-1",children:[(0,Tt.jsxs)("div",{className:"text-[11px] font-bold text-text-secondary flex items-center gap-1",children:[(0,Tt.jsx)(Ci.CheckCircle,{size:12})," Nodos Terminales (",n.terminals.length,")"]}),n.terminals.map(i=>(0,Tt.jsxs)("div",{className:"pl-5 text-[11px] text-text-muted font-mono",children:["\xB7 ",i.label||i.id," ",(0,Tt.jsxs)("span",{className:"text-text-muted",children:["(",i.track,")"]})]},i.id))]})]})}var Tk,Ci,Ik,Tt,Mk=U(()=>{"use strict";Tk=require("react"),Ci=require("lucide-react");ot();Ik=require("@decido/engine");zh();Tt=require("react/jsx-runtime")});function Dk(){let t=X(a=>a.prototypeBrand),e=(0,Pk.useTimelineStore)(a=>a.timelines),r=(0,Rk.useEngineStore)(a=>a.activeNodeIds),n=e[t];if(!n)return(0,eo.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted text-xs font-mono",children:"Sin blueprint activo"});let o=n.keyframes||[],s=n.edges||[],i=new Set(r);return(0,eo.jsxs)("div",{className:"h-full overflow-y-auto custom-scrollbar p-3",children:[(0,eo.jsxs)("div",{className:"text-[10px] font-bold text-text-muted uppercase tracking-widest mb-3",children:["Grafo: ",n.name||t," \xB7 ",o.length," nodos \xB7 ",s.length," aristas"]}),(0,eo.jsx)("div",{className:"space-y-1",children:o.map(a=>{let l=Bh[a.track]||{icon:Fh.Circle,color:"text-text-secondary",label:a.track},c=l.icon,d=i.has(a.id),u=s.filter(f=>f.source===a.id);return(0,eo.jsxs)("div",{className:`group rounded-lg border transition-all ${d?"bg-cyan-500/10 border-cyan-500/30 ring-1 ring-cyan-500/20":"bg-surface-glass border-border-subtle hover:bg-surface-glass"}`,children:[(0,eo.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2",children:[(0,eo.jsx)(c,{size:13,className:l.color}),(0,eo.jsx)("span",{className:`text-[11px] font-semibold flex-1 ${d?"text-cyan-300":"text-text-primary"}`,children:a.label||a.state||a.id}),(0,eo.jsx)("span",{className:"text-[9px] text-text-muted font-mono",children:a.track}),d&&(0,eo.jsx)("span",{className:"w-2 h-2 rounded-full bg-cyan-400 animate-pulse"})]}),u.length>0&&(0,eo.jsx)("div",{className:"px-3 pb-2 flex flex-wrap gap-1",children:u.map((f,p)=>{let h=o.find(b=>b.id===f.target);return(0,eo.jsxs)("span",{className:"inline-flex items-center gap-1 text-[9px] text-text-muted bg-surface-glass rounded px-1.5 py-0.5",children:[(0,eo.jsx)(Fh.ArrowRight,{size:8,className:"text-text-muted"}),h?.label||h?.state||f.target,f.sourceHandle&&f.sourceHandle!=="success"&&(0,eo.jsxs)("span",{className:"text-amber-500/70",children:["(",f.sourceHandle,")"]})]},p)})})]},a.id)})})]})}var Fh,Pk,Rk,eo,Ok=U(()=>{"use strict";Fh=require("lucide-react");ot();Pk=require("@decido/engine"),Rk=require("@decido/engine");zh();eo=require("react/jsx-runtime")});function Lk(){let t=Ut(i=>i.logEntries),e=(0,_k.useEngineStore)(i=>i.activeNodeIds),[r,n]=(0,Hh.useState)(-1),o=(0,Hh.useMemo)(()=>t.filter(i=>i.categories.some(a=>["ENGINE","PLUGIN:DIALOGUE","PLUGIN:LOGIC","PLUGIN:SUBFLOW","PLUGIN:RETURN","PLUGIN:UI","PLUGIN:UIRENDER"].includes(a.toUpperCase()))||i.message.includes("\u{1F680}")||i.message.includes("\u{1F500}")||i.message.includes("\u{1F5E3}")||i.message.includes("\u26A1")||i.message.includes("\u{1F3C1}")),[t]),s=r>=0?o[r]:null;return(0,Nr.jsxs)("div",{className:"h-full flex flex-col",children:[(0,Nr.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border-subtle shrink-0 bg-surface-primary/50",children:[(0,Nr.jsx)("button",{onClick:()=>n(Math.max(0,r-1)),disabled:r<=0,className:"p-1 rounded text-text-muted hover:text-text-primary hover:bg-surface-glass disabled:opacity-30 transition-colors",children:(0,Nr.jsx)(Vh.SkipBack,{size:14})}),(0,Nr.jsx)("span",{className:"text-[10px] text-text-muted font-mono w-16 text-center",children:r>=0?`${r+1}/${o.length}`:`\u2014/${o.length}`}),(0,Nr.jsx)("button",{onClick:()=>n(Math.min(o.length-1,r+1)),disabled:r>=o.length-1,className:"p-1 rounded text-text-muted hover:text-text-primary hover:bg-surface-glass disabled:opacity-30 transition-colors",children:(0,Nr.jsx)(Vh.SkipForward,{size:14})}),(0,Nr.jsx)("div",{className:"flex-1"}),(0,Nr.jsx)("span",{className:"text-[10px] text-text-muted",children:e.length>0&&`Nodo activo: ${e[0]?.substring(0,12)}...`})]}),(0,Nr.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:o.length===0?(0,Nr.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted text-xs font-mono",children:"Ejecuta un flujo para ver el replay"}):(0,Nr.jsx)("div",{className:"py-1",children:o.map((i,a)=>{let l=a===r,c=a<r;return(0,Nr.jsxs)("button",{onClick:()=>n(a),className:`w-full flex items-start gap-2 px-3 py-1.5 text-left transition-all border-l-2 ${l?"bg-amber-500/10 border-amber-400 text-amber-300":c?"border-border-default text-text-muted hover:bg-surface-glass":"border-transparent text-text-secondary hover:bg-surface-glass"}`,children:[(0,Nr.jsx)("span",{className:`shrink-0 w-5 h-5 rounded-full flex items-center justify-center text-[9px] font-bold mt-0.5 ${l?"bg-amber-500/20 text-amber-400":"bg-surface-glass text-text-muted"}`,children:a+1}),(0,Nr.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Nr.jsx)("div",{className:"text-[11px] font-mono truncate",children:i.message}),(0,Nr.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[(0,Nr.jsx)("span",{className:"text-[9px] text-text-muted",children:i.timestamp}),i.categories.map((d,u)=>(0,Nr.jsx)("span",{className:"text-[8px] px-1 py-0.5 rounded bg-surface-glass text-text-muted uppercase tracking-widest",children:d},u))]})]})]},i.id)})})}),s&&(0,Nr.jsxs)("div",{className:"border-t border-border-subtle px-3 py-2 bg-surface-primary/80 shrink-0",children:[(0,Nr.jsxs)("div",{className:"text-[10px] font-bold text-text-secondary mb-1",children:["Detalle del paso ",r+1]}),(0,Nr.jsx)("div",{className:"text-[11px] text-text-primary font-mono break-all",children:s.message}),s.data&&(0,Nr.jsx)("pre",{className:"text-[10px] text-text-muted font-mono mt-1 max-h-20 overflow-y-auto",children:typeof s.data=="object"?JSON.stringify(s.data,null,2):String(s.data)})]})]})}var Hh,Vh,_k,Nr,Bk=U(()=>{"use strict";Hh=require("react"),Vh=require("lucide-react");Us();_k=require("@decido/engine"),Nr=require("react/jsx-runtime")});function N$(t,e){fx.set(t,e)}function vd(t){return fx.get(t)}function px(){return Array.from(fx.keys())}var zk,fx,_t,ys=U(()=>{"use strict";zk=require("zustand");Vu();fx=new Map,_t=(0,zk.create)((t,e)=>({activeStage:null,stageHistory:[],setStage:r=>{fn.morph(`setStage \u2192 ${r?.type||"null"}${r?.label?` (${r.label})`:""}`,r),t({activeStage:r})},pushStage:r=>{let{activeStage:n,stageHistory:o}=e();fn.morph(`pushStage \u2192 ${r.type}${r.label?` (${r.label})`:""} | depth: ${o.length+1}`,{stage:r,previousStage:n?.type});let s=n?[...o,n]:o;t({activeStage:r,stageHistory:s})},popStage:()=>{let{stageHistory:r,activeStage:n}=e();if(r.length===0){fn.morph("popStage \u2192 null (history empty)",{poppedStage:n?.type},"warn"),t({activeStage:null});return}let o=r[r.length-1];fn.morph(`popStage \u2192 ${o.type}${o.label?` (${o.label})`:""} | depth: ${r.length-1}`,{poppedStage:n?.type,restoredStage:o.type}),t({activeStage:o,stageHistory:r.slice(0,-1)})},clearStages:()=>{fn.morph("clearStages \u2192 all stages cleared",{previousDepth:e().stageHistory.length}),t({activeStage:null,stageHistory:[]})}}))});function C$(){return jh||(jh=globalThis.__DECIDO_SHELL_STORES__||[],jh)}function Xu({value:t,path:e,onUpdate:r,depth:n=0}){let[o,s]=(0,to.useState)(n>1);if(t==null)return(0,xe.jsx)("span",{className:"text-text-muted italic text-[10px] font-mono",children:String(t)});if(typeof t=="function")return null;if(typeof t=="boolean")return(0,xe.jsxs)("button",{onClick:()=>r(e,!t),className:`flex items-center gap-1 text-[10px] font-mono transition-colors ${t?"text-emerald-400":"text-text-muted"}`,children:[t?(0,xe.jsx)(Mr.ToggleRight,{size:14}):(0,xe.jsx)(Mr.ToggleLeft,{size:14}),String(t)]});if(typeof t=="number")return(0,xe.jsx)("input",{type:"number",value:t,onChange:a=>r(e,Number(a.target.value)),className:"bg-surface-tertiary border border-border-default rounded px-1.5 py-0.5 text-[10px] font-mono text-cyan-300 w-24 outline-hidden focus:border-cyan-500/50"});if(typeof t=="string")return(0,xe.jsx)("input",{type:"text",value:t,onChange:a=>r(e,a.target.value),className:"bg-surface-tertiary border border-border-default rounded px-1.5 py-0.5 text-[10px] font-mono text-amber-300 flex-1 min-w-[80px] max-w-[300px] outline-hidden focus:border-amber-500/50"});let i=Object.prototype.toString.call(t);if(i==="[object Map]"){let a=Array.from(t.entries());return(0,xe.jsxs)("div",{className:"pl-3 border-l border-border-subtle",children:[(0,xe.jsxs)("button",{onClick:()=>s(!o),className:"flex items-center gap-1 text-[10px] text-text-muted hover:text-text-primary",children:[o?(0,xe.jsx)(Mr.ChevronRight,{size:10}):(0,xe.jsx)(Mr.ChevronDown,{size:10}),(0,xe.jsx)("span",{className:"text-violet-400",children:"Map"}),"(",a.length,")"]}),!o&&a.map((l,c)=>(0,xe.jsxs)("div",{className:"flex items-start gap-2 py-0.5 pl-2",children:[(0,xe.jsxs)("span",{className:"text-[10px] text-text-muted font-mono shrink-0",children:[String(l[0]),":"]}),(0,xe.jsx)(Xu,{value:l[1],path:`${e}.${String(l[0])}`,onUpdate:()=>{},depth:n+1})]},c))]})}if(i==="[object Set]"){let a=Array.from(t);return(0,xe.jsxs)("div",{className:"pl-3 border-l border-border-subtle",children:[(0,xe.jsxs)("button",{onClick:()=>s(!o),className:"flex items-center gap-1 text-[10px] text-text-muted hover:text-text-primary",children:[o?(0,xe.jsx)(Mr.ChevronRight,{size:10}):(0,xe.jsx)(Mr.ChevronDown,{size:10}),(0,xe.jsx)("span",{className:"text-violet-400",children:"Set"}),"(",a.length,")"]}),!o&&a.map((l,c)=>(0,xe.jsx)("div",{className:"pl-2 py-0.5",children:(0,xe.jsx)(Xu,{value:l,path:`${e}[${c}]`,onUpdate:()=>{},depth:n+1})},c))]})}if(Array.isArray(t))return(0,xe.jsxs)("div",{className:"pl-3 border-l border-border-subtle",children:[(0,xe.jsxs)("button",{onClick:()=>s(!o),className:"flex items-center gap-1 text-[10px] text-text-muted hover:text-text-primary",children:[o?(0,xe.jsx)(Mr.ChevronRight,{size:10}):(0,xe.jsx)(Mr.ChevronDown,{size:10}),(0,xe.jsx)("span",{className:"text-blue-400",children:"Array"}),(0,xe.jsxs)("span",{className:"text-text-muted",children:["[",t.length,"]"]})]}),!o&&t.slice(0,50).map((a,l)=>(0,xe.jsxs)("div",{className:"flex items-start gap-2 py-0.5 pl-2",children:[(0,xe.jsx)("span",{className:"text-[9px] text-text-muted font-mono shrink-0 w-4 text-right",children:l}),(0,xe.jsx)(Xu,{value:a,path:`${e}[${l}]`,onUpdate:r,depth:n+1})]},l)),t.length>50&&(0,xe.jsxs)("span",{className:"text-[9px] text-text-muted pl-2",children:["... +",t.length-50," m\xE1s"]})]});if(typeof t=="object"){let a=Object.entries(t).filter(([,l])=>typeof l!="function");return(0,xe.jsxs)("div",{className:"pl-3 border-l border-border-subtle",children:[(0,xe.jsxs)("button",{onClick:()=>s(!o),className:"flex items-center gap-1 text-[10px] text-text-muted hover:text-text-primary",children:[o?(0,xe.jsx)(Mr.ChevronRight,{size:10}):(0,xe.jsx)(Mr.ChevronDown,{size:10}),(0,xe.jsx)("span",{className:"text-orange-400",children:`{${a.length}}`})]}),!o&&a.map(([l,c])=>(0,xe.jsxs)("div",{className:"flex items-start gap-2 py-0.5 pl-2",children:[(0,xe.jsxs)("span",{className:"text-[10px] text-text-secondary font-mono shrink-0",children:[l,":"]}),(0,xe.jsx)(Xu,{value:c,path:`${e}.${l}`,onUpdate:r,depth:n+1})]},l))]})}return(0,xe.jsx)("span",{className:"text-text-muted text-[10px] font-mono",children:String(t)})}function $k(){let t=(0,to.useMemo)(()=>[...C$(),...k$],[]),[e,r]=(0,to.useState)(t[0]?.name||""),n=(0,to.useMemo)(()=>t.find(h=>h.name===e),[t,e]),o=(0,to.useSyncExternalStore)((0,to.useCallback)(h=>n?.store?.subscribe?.(h)||(()=>{}),[n]),(0,to.useCallback)(()=>n?.store?.getState?.()??{},[n])),{stateEntries:s,actionEntries:i}=(0,to.useMemo)(()=>{let h=[],b=[];for(let[g,x]of Object.entries(o))typeof x=="function"?b.push([g,x]):h.push([g,x]);return{stateEntries:h,actionEntries:b}},[o]),a=(0,to.useCallback)((h,b)=>{if(!n)return;let g=h.split("."),x=g[1];if(x)if(g.length===2)n.store.setState({[x]:b});else{let y=n.store.getState()[x];try{let m=JSON.parse(JSON.stringify(y)),v=m;for(let w=2;w<g.length-1;w++)v=v[g[w].replace(/\[(\d+)\]/,".$1")];let S=g[g.length-1].replace(/\[(\d+)\]/,"$1");v[S]=b,n.store.setState({[x]:m})}catch{n.store.setState({[x]:b})}}},[n]),[l,c]=(0,to.useState)(null),[d,u]=(0,to.useState)([]),[f,p]=(0,to.useState)(null);return(0,xe.jsxs)("div",{className:"flex h-full",children:[(0,xe.jsx)("div",{className:"w-32 shrink-0 border-r border-border-subtle overflow-y-auto bg-surface-primary/50",children:["shell","studio"].map(h=>{let b=t.filter(g=>g.group===h);return b.length===0?null:(0,xe.jsxs)("div",{children:[(0,xe.jsx)("div",{className:"px-2 py-1 text-[8px] font-bold text-text-muted uppercase tracking-widest",children:h}),b.map(g=>(0,xe.jsx)("button",{onClick:()=>r(g.name),className:`w-full text-left px-2 py-1.5 text-[10px] font-semibold transition-all ${e===g.name?"bg-emerald-500/10 text-emerald-400 border-r-2 border-emerald-400":"text-text-muted hover:text-text-primary hover:bg-surface-glass"}`,children:g.name},g.name))]},h)})}),(0,xe.jsxs)("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-3 space-y-3",children:[(0,xe.jsxs)("div",{children:[(0,xe.jsxs)("div",{className:"text-[10px] font-bold text-text-secondary uppercase tracking-widest mb-2 flex items-center gap-1",children:[(0,xe.jsx)(Mr.Database,{size:10})," Estado (",s.length,")"]}),(0,xe.jsx)("div",{className:"space-y-1",children:s.map(([h,b])=>(0,xe.jsxs)("div",{className:"flex items-start gap-2 py-0.5",children:[(0,xe.jsx)("span",{className:"text-[10px] text-text-primary font-mono font-semibold shrink-0 min-w-[100px]",children:h}),(0,xe.jsx)(Xu,{value:b,path:`root.${h}`,onUpdate:a,depth:0})]},h))})]}),i.length>0&&(0,xe.jsxs)("div",{children:[(0,xe.jsxs)("div",{className:"text-[10px] font-bold text-text-secondary uppercase tracking-widest mb-2 flex items-center gap-1",children:[(0,xe.jsx)(Mr.Zap,{size:10})," Acciones (",i.length,")"]}),(0,xe.jsx)("div",{className:"flex flex-wrap gap-1",children:i.map(([h,b])=>(0,xe.jsxs)("button",{onClick:()=>{try{let g=b();g instanceof Promise&&g.catch(x=>c(`\u274C ${h}: ${x.message}`)),c(`\u2705 ${h}()`)}catch(g){c(`\u274C ${h}: ${g.message}`)}setTimeout(()=>c(null),2e3)},className:"px-2 py-1 rounded text-[9px] font-mono font-bold bg-surface-glass text-text-secondary hover:text-emerald-400 hover:bg-emerald-500/10 border border-border-subtle hover:border-emerald-500/20 transition-all",title:`Ejecutar ${h}()`,children:["\u25B6 ",h]},h))}),l&&(0,xe.jsx)("div",{className:"mt-2 text-[10px] font-mono text-text-secondary animate-pulse",children:l})]}),(0,xe.jsxs)("div",{className:"border-t border-border-subtle pt-3 mt-3",children:[(0,xe.jsxs)("div",{className:"text-[10px] font-bold text-text-secondary uppercase tracking-widest mb-2 flex items-center gap-1",children:[(0,xe.jsx)(Mr.Camera,{size:10})," Snapshots"]}),(0,xe.jsxs)("div",{className:"flex flex-wrap gap-1 mb-2",children:[(0,xe.jsx)("button",{onClick:()=>{if(!n)return;let h=n.store.getState(),b={};for(let[g,x]of Object.entries(h))typeof x!="function"&&(b[g]=x);u(g=>[...g,{id:Date.now(),label:`${e} @ ${new Date().toLocaleTimeString()}`,data:JSON.parse(JSON.stringify(b,(x,y)=>y instanceof Map?Object.fromEntries(y):y instanceof Set?Array.from(y):y))}])},className:"px-2 py-1 rounded text-[9px] font-mono font-bold bg-violet-500/10 text-violet-400 hover:bg-violet-500/20 border border-violet-500/20",children:"\u{1F4F8} Snapshot"}),d.length>0&&f===null&&(0,xe.jsxs)("button",{onClick:()=>p(d[d.length-1].id),className:"px-2 py-1 rounded text-[9px] font-mono font-bold bg-cyan-500/10 text-cyan-400 hover:bg-cyan-500/20 border border-cyan-500/20",children:[(0,xe.jsx)(Mr.ArrowLeftRight,{size:10,className:"inline mr-1"}),"Diff vs \xFAltimo"]}),f!==null&&(0,xe.jsx)("button",{onClick:()=>p(null),className:"px-2 py-1 rounded text-[9px] font-mono bg-surface-tertiary text-text-secondary hover:bg-surface-tertiary",children:"Cerrar diff"}),d.length>0&&(0,xe.jsxs)("button",{onClick:()=>{let h=new Blob([JSON.stringify(d,null,2)],{type:"application/json"}),b=URL.createObjectURL(h),g=document.createElement("a");g.href=b,g.download=`snapshots-${e}.json`,g.click(),URL.revokeObjectURL(b)},className:"px-2 py-1 rounded text-[9px] font-mono text-text-muted hover:text-text-primary hover:bg-surface-glass",children:[(0,xe.jsx)(Mr.Download,{size:10,className:"inline mr-1"}),"Export"]})]}),d.map((h,b)=>(0,xe.jsxs)("div",{className:"flex items-center gap-2 py-0.5 text-[9px]",children:[(0,xe.jsx)("span",{className:"text-text-muted font-mono",children:h.label}),(0,xe.jsx)("button",{onClick:()=>p(f===h.id?null:h.id),className:`px-1.5 py-0.5 rounded font-bold ${f===h.id?"bg-cyan-500/20 text-cyan-400":"text-text-muted hover:text-cyan-400"}`,children:"diff"}),(0,xe.jsx)("button",{onClick:()=>u(g=>g.filter(x=>x.id!==h.id)),className:"text-text-muted hover:text-red-400",children:"\xD7"})]},h.id)),f!==null&&(()=>{let h=d.find(x=>x.id===f);if(!h)return null;let b={};for(let[x,y]of s)b[x]=y;let g=new Set([...Object.keys(h.data),...Object.keys(b)]);return(0,xe.jsxs)("div",{className:"mt-2 bg-surface-primary rounded border border-border-subtle p-2 max-h-[200px] overflow-y-auto custom-scrollbar",children:[(0,xe.jsxs)("div",{className:"text-[8px] text-text-muted mb-1",children:["Diff: ",h.label," \u2192 actual"]}),Array.from(g).map(x=>{let y=JSON.stringify(h.data[x]),m=JSON.stringify(b[x],(v,S)=>S instanceof Map?Object.fromEntries(S):S instanceof Set?Array.from(S):S);return y===m?null:(0,xe.jsxs)("div",{className:"py-0.5 font-mono text-[9px]",children:[(0,xe.jsxs)("span",{className:"text-text-secondary font-semibold",children:[x,":"]}),y!==void 0&&(0,xe.jsxs)("div",{className:"text-red-400/70 pl-3",children:["- ",y?.slice(0,100)]}),m!==void 0&&(0,xe.jsxs)("div",{className:"text-emerald-400/70 pl-3",children:["+ ",m?.slice(0,100)]})]},x)})]})})()]})]})]})}var to,Mr,wd,xe,jh,k$,Fk=U(()=>{"use strict";to=require("react"),Mr=require("lucide-react");ot();wd=require("@decido/engine");ys();xi();xe=require("react/jsx-runtime"),jh=null;k$=[{name:"Playground",group:"studio",store:X},{name:"Engine",group:"studio",store:wd.useEngineStore},{name:"Timeline",group:"studio",store:wd.useTimelineStore},{name:"Morphology",group:"studio",store:_t},{name:"UserState",group:"studio",store:wd.useUserStateStore},{name:"UIComponents",group:"studio",store:Mn}]});function T$(){let t=new Date;return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}function Wk(){let t=_t(d=>d.activeStage),e=_t(d=>d.stageHistory),r=ke(d=>d.activeStage),n=ke(d=>d.stageHistory),[o,s]=(0,ea.useState)([]),i=(0,ea.useRef)(null),a=(0,ea.useMemo)(()=>{let d=t?.type||null,u=r?.type||null;return d!==u},[t,r]),l=e.length,c=l>5;return(0,ea.useEffect)(()=>{let d=_t.getState().activeStage,u=_t.getState().stageHistory.length;return _t.subscribe(p=>{let h=p.activeStage,b=p.stageHistory.length;if(h!==d||b!==u){let g="change",x="info";b>u?g="\u2B07\uFE0F pushStage":b<u&&h?g="\u2B06\uFE0F popStage":!h&&d?(g="\u{1F5D1}\uFE0F clearStages",x="warn"):h&&!d?g="\u{1F4CC} setStage":g="\u{1F504} setStage",s(y=>{let m=[...y,{id:++E$,timestamp:T$(),action:g,stageType:h?.type||null,label:h?.label||h?.type||"null",data:{depth:b,sourceNodeId:h?.sourceNodeId},level:x}];return m.length>Hk?m.slice(-Hk):m}),d=h,u=b}})},[]),(0,ea.useEffect)(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[o]),(0,Ze.jsxs)("div",{className:"flex h-full text-[10px]",children:[(0,Ze.jsxs)("div",{className:"w-48 shrink-0 border-r border-border-subtle p-3 space-y-2 overflow-y-auto",children:[(0,Ze.jsxs)("div",{className:"text-[9px] font-bold text-text-muted uppercase tracking-widest mb-2 flex items-center gap-1",children:[(0,Ze.jsx)(Gs.Layers,{size:10})," Stack (",l+(t?1:0),")"]}),a&&(0,Ze.jsxs)("div",{className:"px-2 py-1.5 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-[9px] font-bold flex items-center gap-1 animate-pulse",children:[(0,Ze.jsx)(Gs.AlertTriangle,{size:10})," Stores desincronizados"]}),c&&(0,Ze.jsxs)("div",{className:"px-2 py-1.5 rounded-lg bg-amber-500/10 border border-amber-500/30 text-amber-400 text-[9px] font-bold flex items-center gap-1",children:[(0,Ze.jsx)(Gs.AlertTriangle,{size:10})," Stack depth: ",l," (posible leak)"]}),t?(0,Ze.jsxs)("div",{className:`px-3 py-2 rounded-xl border-2 ${jk[t.type]||"border-border-default bg-surface-glass"} relative`,children:[(0,Ze.jsx)("div",{className:"absolute -top-2 right-2 px-1.5 py-0.5 rounded text-[7px] font-bold bg-cyan-500 text-text-inverse uppercase",children:"Activo"}),(0,Ze.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,Ze.jsx)("span",{className:"text-lg",children:Vk[t.type]||"\u2753"}),(0,Ze.jsxs)("div",{children:[(0,Ze.jsx)("div",{className:"font-bold text-text-primary text-[11px]",children:t.type.toUpperCase()}),t.label&&(0,Ze.jsx)("div",{className:"text-text-secondary text-[9px]",children:t.label})]})]}),t.sourceNodeId&&(0,Ze.jsxs)("div",{className:"mt-1 text-[8px] text-text-muted font-mono truncate",children:["src: ",t.sourceNodeId]})]}):(0,Ze.jsx)("div",{className:"px-3 py-2 rounded-xl border border-dashed border-border-default text-text-muted text-center italic",children:"Sin stage activo"}),e.length>0&&(0,Ze.jsx)("div",{className:"flex justify-center text-text-muted",children:(0,Ze.jsx)(Gs.ArrowUp,{size:12})}),[...e].reverse().map((d,u)=>(0,Ze.jsx)("div",{className:`px-3 py-1.5 rounded-lg border ${jk[d.type]||"border-border-default bg-surface-tertiary/50"} opacity-50 hover:opacity-80 cursor-pointer transition-all`,onClick:()=>{let f=u+1,p=_t.getState(),h=ke.getState();for(let b=0;b<f;b++)p.popStage(),h.popStage()},title:`Click para volver a: ${d.label||d.type}`,children:(0,Ze.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,Ze.jsx)("span",{children:Vk[d.type]||"\u2753"}),(0,Ze.jsx)("span",{className:"font-semibold text-text-primary",children:d.type}),d.label&&(0,Ze.jsxs)("span",{className:"text-text-muted truncate max-w-[80px]",children:[" \xB7 ",d.label]})]})},u))]}),(0,Ze.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,Ze.jsxs)("div",{className:"px-3 py-1.5 border-b border-border-subtle flex items-center justify-between",children:[(0,Ze.jsxs)("div",{className:"text-[9px] font-bold text-text-muted uppercase tracking-widest flex items-center gap-1",children:[(0,Ze.jsx)(Gs.Clock,{size:10})," Eventos (",o.length,")"]}),(0,Ze.jsx)("button",{onClick:()=>s([]),className:"p-0.5 rounded hover:bg-surface-glass text-text-muted hover:text-text-secondary",title:"Limpiar eventos",children:(0,Ze.jsx)(Gs.RotateCcw,{size:10})})]}),(0,Ze.jsx)("div",{ref:i,className:"flex-1 overflow-y-auto custom-scrollbar",children:o.length===0?(0,Ze.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted italic",children:"Esperando eventos morph..."}):o.map(d=>(0,Ze.jsxs)("div",{className:`flex items-start gap-2 px-3 py-1 border-b border-border-subtle hover:bg-surface-glass ${d.level==="warn"?"bg-amber-500/5":d.level==="error"?"bg-red-500/5":""}`,children:[(0,Ze.jsx)("span",{className:"text-text-muted shrink-0 font-mono w-[50px]",children:d.timestamp}),(0,Ze.jsx)("span",{className:"shrink-0 w-[90px] font-semibold text-text-secondary",children:d.action}),(0,Ze.jsx)("span",{className:`font-mono ${d.stageType?"text-cyan-400":"text-text-muted"}`,children:d.label}),d.data?.depth!==void 0&&(0,Ze.jsxs)("span",{className:"text-text-muted ml-auto shrink-0",children:["depth: ",d.data.depth]})]},d.id))}),a&&(0,Ze.jsxs)("div",{className:"px-3 py-2 border-t border-red-500/20 bg-red-500/5",children:[(0,Ze.jsx)("div",{className:"text-[9px] font-bold text-red-400 mb-1",children:"\u26A0\uFE0F Store Desync Detectado"}),(0,Ze.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-[9px] font-mono",children:[(0,Ze.jsxs)("div",{children:[(0,Ze.jsx)("span",{className:"text-text-muted",children:"morph:"})," ",(0,Ze.jsx)("span",{className:"text-violet-400",children:t?.type||"null"}),(0,Ze.jsxs)("span",{className:"text-text-muted",children:[" (depth: ",e.length,")"]})]}),(0,Ze.jsxs)("div",{children:[(0,Ze.jsx)("span",{className:"text-text-muted",children:"layout:"})," ",(0,Ze.jsx)("span",{className:"text-emerald-400",children:r?.type||"null"}),(0,Ze.jsxs)("span",{className:"text-text-muted",children:[" (depth: ",n.length,")"]})]})]})]})]})]})}var ea,Gs,Ze,E$,Hk,Vk,jk,Uk=U(()=>{"use strict";ea=require("react");ys();Qn();Gs=require("lucide-react"),Ze=require("react/jsx-runtime"),E$=0,Hk=100,Vk={"2d":"\u{1F4CA}","3d":"\u{1F9CA}",workbench:"\u{1F527}",liquid:"\u{1F4A7}",artifact:"\u{1F4C4}",custom:"\u2699\uFE0F"},jk={"2d":"border-cyan-500 bg-cyan-500/10","3d":"border-violet-500 bg-violet-500/10",workbench:"border-amber-500 bg-amber-500/10",liquid:"border-blue-500 bg-blue-500/10",artifact:"border-emerald-500 bg-emerald-500/10",custom:"border-border-default bg-surface-glass"}});function Gk(){let t=new Date;return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}function Kk(t){Ju.push(t),Ju.length>A$&&Ju.shift(),Wh.forEach(e=>e())}function Zu(){return Ju}function Yk(){Ju.length=0,Wh.forEach(t=>t())}function Xk(t){return Wh.add(t),()=>Wh.delete(t)}function Jk(){if(qk)return;qk=!0;let t=window.fetch;window.fetch=async function(e,r){let n=r?.method?.toUpperCase()||"GET",o=typeof e=="string"?e:e instanceof URL?e.toString():e.url,s=++I$,i=performance.now(),a;try{r?.body&&(a=typeof r.body=="string"?r.body.slice(0,2048):"[binary]")}catch{}try{let l=await t.call(window,e,r),c=Math.round(performance.now()-i),d,u=0;try{let p=await l.clone().text();u=p.length,d=p.slice(0,2048)}catch{}return Kk({id:s,timestamp:Gk(),method:n,url:o,status:l.status,duration:c,requestBody:a,responseBody:d,size:u}),l}catch(l){let c=Math.round(performance.now()-i);throw Kk({id:s,timestamp:Gk(),method:n,url:o,status:0,duration:c,requestBody:a,size:0,error:l.message}),l}}}var I$,A$,Ju,Wh,qk,hx=U(()=>{"use strict";I$=0,A$=200,Ju=[],Wh=new Set;qk=!1});function P$(t){return M$[String(t).charAt(0)]||"text-text-secondary"}function R$(t){try{let e=new URL(t),r=e.pathname+e.search;return r.length>60?r.slice(0,57)+"...":r}catch{return t.length>60?t.slice(0,57)+"...":t}}function Zk(t){try{return new URL(t).hostname}catch{return""}}function D$(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/(1024*1024)).toFixed(1)}MB`}function O$({entry:t,isExpanded:e,onToggle:r}){return(0,tt.jsxs)(tt.Fragment,{children:[(0,tt.jsxs)("div",{onClick:r,className:`flex items-center gap-2 px-3 py-1 text-[10px] font-mono cursor-pointer hover:bg-surface-glass border-b border-border-subtle ${t.error?"bg-red-500/5":""}`,children:[e?(0,tt.jsx)($a.ChevronDown,{size:10,className:"text-text-muted"}):(0,tt.jsx)($a.ChevronRight,{size:10,className:"text-text-muted"}),(0,tt.jsx)("span",{className:"text-text-muted w-[50px] shrink-0",children:t.timestamp}),(0,tt.jsx)("span",{className:`w-[40px] shrink-0 font-bold ${t.method==="POST"?"text-amber-400":"text-cyan-400"}`,children:t.method}),(0,tt.jsx)("span",{className:`w-[30px] shrink-0 font-bold ${P$(t.status)}`,children:t.status||"ERR"}),(0,tt.jsx)("span",{className:"flex-1 text-text-primary truncate",title:t.url,children:R$(t.url)}),(0,tt.jsxs)("span",{className:"text-text-muted w-[50px] shrink-0 text-right",children:[t.duration,"ms"]}),(0,tt.jsx)("span",{className:"text-text-muted w-[40px] shrink-0 text-right",children:D$(t.size)})]}),e&&(0,tt.jsxs)("div",{className:"px-6 py-2 bg-surface-primary/80 border-b border-border-subtle text-[9px] font-mono space-y-2",children:[(0,tt.jsxs)("div",{children:[(0,tt.jsx)("span",{className:"text-text-muted",children:"URL:"})," ",(0,tt.jsx)("span",{className:"text-text-primary break-all",children:t.url})]}),t.error&&(0,tt.jsxs)("div",{className:"text-red-400",children:["Error: ",t.error]}),t.requestBody&&(0,tt.jsxs)("div",{children:[(0,tt.jsx)("div",{className:"text-text-muted mb-0.5",children:"Request Body:"}),(0,tt.jsx)("pre",{className:"bg-surface-secondary rounded p-2 text-text-secondary overflow-x-auto max-h-[150px] overflow-y-auto whitespace-pre-wrap",children:(()=>{try{return JSON.stringify(JSON.parse(t.requestBody),null,2)}catch{return t.requestBody}})()})]}),t.responseBody&&(0,tt.jsxs)("div",{children:[(0,tt.jsx)("div",{className:"text-text-muted mb-0.5",children:"Response Body:"}),(0,tt.jsx)("pre",{className:"bg-surface-secondary rounded p-2 text-text-secondary overflow-x-auto max-h-[150px] overflow-y-auto whitespace-pre-wrap",children:(()=>{try{return JSON.stringify(JSON.parse(t.responseBody),null,2)}catch{return t.responseBody}})()})]})]})]})}function Qk(){let t=(0,Zo.useSyncExternalStore)((0,Zo.useCallback)(c=>Xk(c),[]),(0,Zo.useCallback)(()=>Zu(),[])),[e,r]=(0,Zo.useState)(new Set),[n,o]=(0,Zo.useState)(""),s=(0,Zo.useMemo)(()=>{let c=new Set;return t.forEach(d=>{let u=Zk(d.url);u&&c.add(u)}),Array.from(c).sort()},[t]),i=(0,Zo.useMemo)(()=>n?t.filter(c=>Zk(c.url).includes(n)):t,[t,n]),a=(0,Zo.useCallback)(c=>{r(d=>{let u=new Set(d);return u.has(c)?u.delete(c):u.add(c),u})},[]),l=(0,Zo.useMemo)(()=>t.filter(c=>c.status>=400||c.error).length,[t]);return(0,tt.jsxs)("div",{className:"flex flex-col h-full",children:[(0,tt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border-subtle shrink-0",children:[(0,tt.jsx)($a.Globe,{size:12,className:"text-cyan-400"}),(0,tt.jsx)("span",{className:"text-[10px] font-bold text-text-secondary uppercase tracking-widest",children:"Network"}),(0,tt.jsxs)("span",{className:"text-[9px] text-text-muted font-mono",children:[i.length,"/",t.length]}),l>0&&(0,tt.jsxs)("span",{className:"px-1.5 py-0.5 rounded-full text-[8px] font-bold bg-red-500/20 text-red-400",children:[l," err"]}),(0,tt.jsx)("div",{className:"flex-1"}),s.length>0&&(0,tt.jsxs)("select",{value:n,onChange:c=>o(c.target.value),className:"bg-surface-secondary border border-border-default rounded px-1.5 py-0.5 text-[9px] text-text-secondary outline-hidden",children:[(0,tt.jsx)("option",{value:"",children:"All domains"}),s.map(c=>(0,tt.jsx)("option",{value:c,children:c},c))]}),(0,tt.jsx)("button",{onClick:Yk,className:"p-0.5 rounded hover:bg-surface-glass text-text-muted hover:text-text-secondary",title:"Limpiar",children:(0,tt.jsx)($a.RotateCcw,{size:10})})]}),(0,tt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-0.5 text-[8px] font-bold text-text-muted uppercase tracking-widest border-b border-border-subtle shrink-0",children:[(0,tt.jsx)("span",{className:"w-[14px]"}),(0,tt.jsx)("span",{className:"w-[50px]",children:"Time"}),(0,tt.jsx)("span",{className:"w-[40px]",children:"Method"}),(0,tt.jsx)("span",{className:"w-[30px]",children:"Status"}),(0,tt.jsx)("span",{className:"flex-1",children:"URL"}),(0,tt.jsx)("span",{className:"w-[50px] text-right",children:"Duration"}),(0,tt.jsx)("span",{className:"w-[40px] text-right",children:"Size"})]}),(0,tt.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:i.length===0?(0,tt.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted text-[10px] italic",children:"Sin peticiones de red capturadas"}):i.map(c=>(0,tt.jsx)(O$,{entry:c,isExpanded:e.has(c.id),onToggle:()=>a(c.id)},c.id))})]})}var Zo,$a,tt,M$,e2=U(()=>{"use strict";Zo=require("react"),$a=require("lucide-react");hx();tt=require("react/jsx-runtime");Jk();M$={2:"text-emerald-400",3:"text-amber-400",4:"text-red-400",5:"text-red-500",0:"text-text-muted"}});var t2,r2,Fa,mx=U(()=>{"use strict";t2=require("zustand"),r2=require("zustand/middleware"),Fa=(0,t2.create)()((0,r2.persist)((t,e)=>({profiles:[],activeProfileId:null,createProfile:r=>{let n={id:Date.now().toString(36),name:r,watchList:[],pinnedActions:[],logCategories:[],logLevels:["info","warn","error","debug"],notes:"",createdAt:Date.now()};t(o=>({profiles:[...o.profiles,n],activeProfileId:n.id}))},updateProfile:(r,n)=>{t(o=>({profiles:o.profiles.map(s=>s.id===r?{...s,...n}:s)}))},deleteProfile:r=>{t(n=>({profiles:n.profiles.filter(o=>o.id!==r),activeProfileId:n.activeProfileId===r?null:n.activeProfileId}))},activateProfile:r=>t({activeProfileId:r}),getActiveProfile:()=>{let{profiles:r,activeProfileId:n}=e();return r.find(o=>o.id===n)},addWatch:(r,n)=>{t(o=>({profiles:o.profiles.map(s=>s.id===r?{...s,watchList:[...s.watchList,n]}:s)}))},removeWatch:(r,n)=>{t(o=>({profiles:o.profiles.map(s=>s.id===r?{...s,watchList:s.watchList.filter((i,a)=>a!==n)}:s)}))},addPinnedAction:(r,n)=>{t(o=>({profiles:o.profiles.map(s=>s.id===r?{...s,pinnedActions:[...s.pinnedActions,n]}:s)}))},removePinnedAction:(r,n)=>{t(o=>({profiles:o.profiles.map(s=>s.id===r?{...s,pinnedActions:s.pinnedActions.filter((i,a)=>a!==n)}:s)}))}}),{name:"decido-debug-profiles-v1"}))});function _$(t,e){let r=e.split("."),n=t;for(let o of r){if(n==null)return;n=n[o]}return n}function L$(t){if(t==null)return String(t);if(typeof t=="function")return"[fn]";if(typeof t=="object"){let e=Object.prototype.toString.call(t);if(e==="[object Map]")return`Map(${t.size})`;if(e==="[object Set]")return`Set(${t.size})`;if(Array.isArray(t))return`Array(${t.length})`;try{return JSON.stringify(t).slice(0,100)}catch{return"[object]"}}return String(t)}function B$({storeName:t,path:e}){let r=Ha[t],n=(0,bo.useSyncExternalStore)((0,bo.useCallback)(a=>r?.subscribe?.(a)||(()=>{}),[r]),(0,bo.useCallback)(()=>r?.getState?.()??{},[r])),o=_$(n,e),s=L$(o),i=typeof o=="number"?"text-cyan-300":typeof o=="string"?"text-amber-300":typeof o=="boolean"?o?"text-emerald-400":"text-text-muted":o==null?"text-text-muted italic":"text-text-secondary";return(0,ze.jsx)("span",{className:`font-mono text-[9px] ${i} max-w-[200px] truncate`,title:s,children:s})}function z$({profile:t}){let{updateProfile:e,addWatch:r,removeWatch:n,addPinnedAction:o,removePinnedAction:s,deleteProfile:i}=Fa(),[a,l]=(0,bo.useState)(Object.keys(Ha)[0]),[c,d]=(0,bo.useState)(""),[u,f]=(0,bo.useState)(Object.keys(Ha)[0]),[p,h]=(0,bo.useState)(""),b=(0,bo.useMemo)(()=>{let x=Ha[a];if(!x)return[];let y=x.getState();return Object.entries(y).filter(([,m])=>typeof m!="function").map(([m])=>m)},[a]),g=(0,bo.useMemo)(()=>{let x=Ha[u];if(!x)return[];let y=x.getState();return Object.entries(y).filter(([,m])=>typeof m=="function").map(([m])=>m)},[u]);return(0,ze.jsxs)("div",{className:"space-y-3 p-3",children:[(0,ze.jsxs)("div",{children:[(0,ze.jsxs)("div",{className:"text-[9px] font-bold text-text-secondary uppercase tracking-widest mb-1.5 flex items-center gap-1",children:[(0,ze.jsx)(xn.Eye,{size:10})," Watch List (",t.watchList.length,")"]}),t.watchList.map((x,y)=>(0,ze.jsxs)("div",{className:"flex items-center gap-2 py-0.5 group",children:[(0,ze.jsx)("span",{className:"text-[8px] text-text-muted font-bold uppercase",children:x.storeName}),(0,ze.jsx)("span",{className:"text-[9px] text-text-secondary font-mono",children:x.path}),(0,ze.jsx)("span",{className:"text-text-muted",children:"="}),(0,ze.jsx)(B$,{storeName:x.storeName,path:x.path}),(0,ze.jsx)("button",{onClick:()=>n(t.id,y),className:"opacity-0 group-hover:opacity-100 text-text-muted hover:text-red-400 transition-all ml-auto",children:(0,ze.jsx)(xn.X,{size:10})})]},y)),(0,ze.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,ze.jsx)("select",{value:a,onChange:x=>l(x.target.value),className:"bg-surface-secondary border border-border-default rounded px-1 py-0.5 text-[8px] text-text-secondary",children:Object.keys(Ha).map(x=>(0,ze.jsx)("option",{value:x,children:x},x))}),(0,ze.jsxs)("select",{value:c,onChange:x=>d(x.target.value),className:"bg-surface-secondary border border-border-default rounded px-1 py-0.5 text-[8px] text-text-secondary flex-1",children:[(0,ze.jsx)("option",{value:"",children:"Select property..."}),b.map(x=>(0,ze.jsx)("option",{value:x,children:x},x))]}),(0,ze.jsx)("button",{onClick:()=>{c&&(r(t.id,{storeName:a,path:c}),d(""))},disabled:!c,className:"px-1.5 py-0.5 rounded text-[8px] font-bold bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20 border border-emerald-500/20 disabled:opacity-30",children:(0,ze.jsx)(xn.Plus,{size:10})})]})]}),(0,ze.jsxs)("div",{children:[(0,ze.jsxs)("div",{className:"text-[9px] font-bold text-text-secondary uppercase tracking-widest mb-1.5 flex items-center gap-1",children:[(0,ze.jsx)(xn.Zap,{size:10})," Quick Actions (",t.pinnedActions.length,")"]}),(0,ze.jsx)("div",{className:"flex flex-wrap gap-1 mb-1",children:t.pinnedActions.map((x,y)=>(0,ze.jsxs)("button",{onClick:()=>{let m=Ha[x.storeName];if(m){let v=m.getState()[x.actionName];typeof v=="function"&&v()}},className:"group px-2 py-0.5 rounded text-[8px] font-mono bg-surface-glass text-text-secondary hover:text-amber-400 hover:bg-amber-500/10 border border-border-subtle hover:border-amber-500/20 flex items-center gap-1",children:["\u25B6 ",x.storeName,".",x.actionName,(0,ze.jsx)("span",{onClick:m=>{m.stopPropagation(),s(t.id,y)},className:"opacity-0 group-hover:opacity-100 text-text-muted hover:text-red-400",children:(0,ze.jsx)(xn.X,{size:8})})]},y))}),(0,ze.jsxs)("div",{className:"flex items-center gap-1",children:[(0,ze.jsx)("select",{value:u,onChange:x=>f(x.target.value),className:"bg-surface-secondary border border-border-default rounded px-1 py-0.5 text-[8px] text-text-secondary",children:Object.keys(Ha).map(x=>(0,ze.jsx)("option",{value:x,children:x},x))}),(0,ze.jsxs)("select",{value:p,onChange:x=>h(x.target.value),className:"bg-surface-secondary border border-border-default rounded px-1 py-0.5 text-[8px] text-text-secondary flex-1",children:[(0,ze.jsx)("option",{value:"",children:"Select action..."}),g.map(x=>(0,ze.jsx)("option",{value:x,children:x},x))]}),(0,ze.jsx)("button",{onClick:()=>{p&&(o(t.id,{storeName:u,actionName:p}),h(""))},disabled:!p,className:"px-1.5 py-0.5 rounded text-[8px] font-bold bg-amber-500/10 text-amber-400 hover:bg-amber-500/20 border border-amber-500/20 disabled:opacity-30",children:(0,ze.jsx)(xn.Plus,{size:10})})]})]}),(0,ze.jsxs)("div",{children:[(0,ze.jsxs)("div",{className:"text-[9px] font-bold text-text-secondary uppercase tracking-widest mb-1 flex items-center gap-1",children:[(0,ze.jsx)(xn.StickyNote,{size:10})," Notas"]}),(0,ze.jsx)("textarea",{value:t.notes,onChange:x=>e(t.id,{notes:x.target.value}),placeholder:"Hip\xF3tesis de debugging, observaciones...",className:"w-full bg-surface-secondary border border-border-default rounded px-2 py-1.5 text-[9px] text-text-primary font-mono outline-hidden focus:border-violet-500/50 resize-y min-h-[40px] max-h-[120px]"})]}),(0,ze.jsxs)("button",{onClick:()=>i(t.id),className:"flex items-center gap-1 px-2 py-1 rounded text-[9px] text-red-400/60 hover:text-red-400 hover:bg-red-500/10 transition-all",children:[(0,ze.jsx)(xn.Trash2,{size:10})," Eliminar perfil"]})]})}function n2(){let t=Fa(a=>a.profiles),e=Fa(a=>a.activeProfileId),{createProfile:r,activateProfile:n}=Fa(),[o,s]=(0,bo.useState)(""),i=(0,bo.useMemo)(()=>t.find(a=>a.id===e),[t,e]);return(0,ze.jsxs)("div",{className:"flex h-full",children:[(0,ze.jsxs)("div",{className:"w-40 shrink-0 border-r border-border-subtle overflow-y-auto bg-surface-primary/50 flex flex-col",children:[(0,ze.jsxs)("div",{className:"p-2",children:[(0,ze.jsx)("div",{className:"text-[8px] font-bold text-text-muted uppercase tracking-widest mb-1",children:"Perfiles"}),t.map(a=>(0,ze.jsxs)("button",{onClick:()=>n(a.id),className:`w-full text-left px-2 py-1.5 text-[10px] font-semibold transition-all rounded mb-0.5 flex items-center gap-1.5 ${e===a.id?"bg-violet-500/10 text-violet-400 border-r-2 border-violet-400":"text-text-muted hover:text-text-primary hover:bg-surface-glass"}`,children:[e===a.id?(0,ze.jsx)(xn.Star,{size:10}):(0,ze.jsx)(xn.StarOff,{size:10,className:"opacity-30"}),(0,ze.jsx)("span",{className:"truncate",children:a.name}),(0,ze.jsx)("span",{className:"ml-auto text-[8px] text-text-muted",children:a.watchList.length})]},a.id))]}),(0,ze.jsx)("div",{className:"mt-auto p-2 border-t border-border-subtle",children:(0,ze.jsxs)("div",{className:"flex items-center gap-1",children:[(0,ze.jsx)("input",{value:o,onChange:a=>s(a.target.value),onKeyDown:a=>{a.key==="Enter"&&o.trim()&&(r(o.trim()),s(""))},placeholder:"Nuevo perfil...",className:"flex-1 bg-surface-secondary border border-border-default rounded px-1.5 py-0.5 text-[9px] text-text-primary outline-hidden focus:border-violet-500/50"}),(0,ze.jsx)("button",{onClick:()=>{o.trim()&&(r(o.trim()),s(""))},disabled:!o.trim(),className:"p-1 rounded bg-violet-500/10 text-violet-400 hover:bg-violet-500/20 disabled:opacity-30",children:(0,ze.jsx)(xn.Plus,{size:12})})]})})]}),(0,ze.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:i?(0,ze.jsx)(z$,{profile:i}):(0,ze.jsxs)("div",{className:"flex items-center justify-center h-full text-text-muted text-[10px] italic flex-col gap-2",children:[(0,ze.jsx)("span",{children:"Selecciona o crea un perfil de debug"}),(0,ze.jsx)("span",{className:"text-[8px] text-text-muted",children:"Los perfiles te permiten monitorear variables espec\xEDficas, ejecutar acciones, y tomar notas"})]})})]})}var bo,xn,Sd,ze,Ha,o2=U(()=>{"use strict";bo=require("react"),xn=require("lucide-react");mx();ot();Sd=require("@decido/engine");ys();xi();mo();ze=require("react/jsx-runtime"),Ha={Playground:X,Engine:Sd.useEngineStore,Timeline:Sd.useTimelineStore,Morphology:_t,UserState:Sd.useUserStateStore,UIComponents:Mn,MorphInstance:Ue}});function H$({event:t}){let e=$$[t.storeName]||"border-l-text-muted bg-surface-glass",r=F$[t.storeName]||"bg-surface-glass text-text-secondary";return(0,ar.jsxs)("div",{className:`border-l-2 ${e} px-3 py-1.5 hover:bg-surface-glass transition-colors`,children:[(0,ar.jsxs)("div",{className:"flex items-center gap-2 text-[10px]",children:[(0,ar.jsx)("span",{className:"text-text-muted font-mono shrink-0 w-[65px]",children:t.timestamp}),(0,ar.jsx)("span",{className:`px-1.5 py-0.5 rounded text-[8px] font-bold uppercase tracking-wider ${r}`,children:t.storeName}),(0,ar.jsx)("span",{className:"font-semibold text-text-primary truncate",children:t.actionName}),t.level==="warn"&&(0,ar.jsx)("span",{className:"text-[8px] text-amber-400",children:"\u26A0"}),t.level==="error"&&(0,ar.jsx)("span",{className:"text-[8px] text-red-400",children:"\u2715"})]}),t.data&&(0,ar.jsx)("div",{className:"mt-0.5 text-[9px] text-text-muted font-mono truncate max-w-full",children:typeof t.data=="object"?JSON.stringify(t.data):String(t.data)})]})}function s2(){let t=gi(l=>l.events),e=gi(l=>l.isPaused),r=gi(l=>l.filter),{clear:n,togglePause:o,setFilter:s}=gi(),i=(0,Nd.useRef)(null),a=(0,Nd.useMemo)(()=>{if(!r)return t;let l=r.toLowerCase();return t.filter(c=>c.storeName.includes(l)||c.actionName.toLowerCase().includes(l))},[t,r]);return(0,Nd.useEffect)(()=>{!e&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[a,e]),(0,ar.jsxs)("div",{className:"flex flex-col h-full",children:[(0,ar.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border-subtle shrink-0",children:[(0,ar.jsx)(ki.Clock,{size:12,className:"text-amber-400"}),(0,ar.jsx)("span",{className:"text-[10px] font-bold text-text-secondary uppercase tracking-widest",children:"Timeline"}),(0,ar.jsxs)("span",{className:"text-[9px] text-text-muted font-mono",children:[a.length,"/",t.length]}),e&&(0,ar.jsx)("span",{className:"px-1.5 py-0.5 rounded text-[8px] font-bold bg-amber-500/20 text-amber-400 animate-pulse",children:"PAUSADO"}),(0,ar.jsx)("div",{className:"flex-1"}),(0,ar.jsxs)("div",{className:"flex items-center bg-surface-secondary border border-border-default rounded px-1.5 gap-1",children:[(0,ar.jsx)(ki.Search,{size:10,className:"text-text-muted"}),(0,ar.jsx)("input",{value:r,onChange:l=>s(l.target.value),placeholder:"Filtrar...",className:"bg-transparent text-[9px] text-text-primary outline-hidden w-24 py-0.5"})]}),(0,ar.jsx)("button",{onClick:o,className:`p-1 rounded transition-colors ${e?"bg-amber-500/10 text-amber-400":"text-text-muted hover:text-text-secondary hover:bg-surface-glass"}`,title:e?"Reanudar":"Pausar",children:e?(0,ar.jsx)(ki.Play,{size:10}):(0,ar.jsx)(ki.Pause,{size:10})}),(0,ar.jsx)("button",{onClick:n,className:"p-0.5 rounded hover:bg-surface-glass text-text-muted hover:text-text-secondary",title:"Limpiar",children:(0,ar.jsx)(ki.RotateCcw,{size:10})})]}),(0,ar.jsx)("div",{ref:i,className:"flex-1 overflow-y-auto custom-scrollbar",children:a.length===0?(0,ar.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted text-[10px] italic",children:t.length===0?"Esperando acciones...":"Sin resultados para el filtro"}):a.map(l=>(0,ar.jsx)(H$,{event:l},l.id))})]})}var Nd,ki,ar,$$,F$,i2=U(()=>{"use strict";Nd=require("react"),ki=require("lucide-react");fh();ar=require("react/jsx-runtime"),$$={morph:"border-l-violet-500 bg-violet-500/5",layout:"border-l-emerald-500 bg-emerald-500/5",gemini:"border-l-blue-500 bg-blue-500/5",chat:"border-l-cyan-500 bg-cyan-500/5",store:"border-l-amber-500 bg-amber-500/5",engine:"border-l-orange-500 bg-orange-500/5",network:"border-l-teal-500 bg-teal-500/5",shell:"border-l-pink-500 bg-pink-500/5",system:"border-l-text-muted bg-surface-glass"},F$={morph:"bg-violet-500/20 text-violet-400",layout:"bg-emerald-500/20 text-emerald-400",gemini:"bg-blue-500/20 text-blue-400",chat:"bg-cyan-500/20 text-cyan-400",store:"bg-amber-500/20 text-amber-400",engine:"bg-orange-500/20 text-orange-400",network:"bg-teal-500/20 text-teal-400",shell:"bg-pink-500/20 text-pink-400",system:"bg-surface-glass text-text-secondary"}});function V$(t=1e3){let[e,r]=(0,Ei.useState)({fps:0,memory:null,domNodes:0}),n=(0,Ei.useRef)(0),o=(0,Ei.useRef)(performance.now());return(0,Ei.useEffect)(()=>{let s,i=()=>{n.current++,s=requestAnimationFrame(i)};s=requestAnimationFrame(i);let a=setInterval(()=>{let l=performance.now(),c=(l-o.current)/1e3,d=Math.round(n.current/c);n.current=0,o.current=l;let u=null,f=performance.memory;if(f){let h=Math.round(f.usedJSHeapSize/1024/1024),b=Math.round(f.jsHeapSizeLimit/1024/1024);u={usedMB:h,totalMB:b,percent:Math.round(h/b*100)}}let p=document.querySelectorAll("*").length;r({fps:d,memory:u,domNodes:p})},t);return()=>{cancelAnimationFrame(s),clearInterval(a)}},[t]),e}function a2({data:t,color:e,height:r=24,width:n=80}){if(t.length<2)return null;let o=Math.max(...t,1),s=Math.min(...t,0),i=o-s||1,a=t.map((l,c)=>{let d=c/(t.length-1)*n,u=r-(l-s)/i*r;return`${d},${u}`}).join(" ");return(0,dt.jsx)("svg",{width:n,height:r,className:"shrink-0",children:(0,dt.jsx)("polyline",{points:a,fill:"none",stroke:e,strokeWidth:"1.5",strokeLinejoin:"round"})})}function j$({fps:t}){let e=t>=50?"text-emerald-400":t>=30?"text-amber-400":"text-red-400",r=t>=50?"bg-emerald-500/10":t>=30?"bg-amber-500/10":"bg-red-500/10",n=Math.min(t/60,1);return(0,dt.jsxs)("div",{className:`rounded-xl ${r} px-4 py-3 flex items-center gap-3`,children:[(0,dt.jsxs)("div",{className:"relative w-12 h-12",children:[(0,dt.jsxs)("svg",{className:"w-12 h-12 -rotate-90",viewBox:"0 0 48 48",children:[(0,dt.jsx)("circle",{cx:"24",cy:"24",r:"20",fill:"none",stroke:"currentColor",className:"text-text-muted",strokeWidth:"3"}),(0,dt.jsx)("circle",{cx:"24",cy:"24",r:"20",fill:"none",stroke:"currentColor",className:e,strokeWidth:"3",strokeDasharray:`${n*125.6} 125.6`,strokeLinecap:"round"})]}),(0,dt.jsx)("span",{className:`absolute inset-0 flex items-center justify-center text-[11px] font-bold ${e}`,children:t})]}),(0,dt.jsxs)("div",{children:[(0,dt.jsx)("div",{className:"text-[10px] font-bold text-text-primary",children:"FPS"}),(0,dt.jsx)("div",{className:`text-[9px] ${e}`,children:t>=50?"\u2705 Excelente":t>=30?"\u26A0\uFE0F Aceptable":"\u{1F534} Bajo"})]})]})}function l2(){let t=V$(500),[e,r]=(0,Ei.useState)([]),[n,o]=(0,Ei.useState)([]);return(0,Ei.useEffect)(()=>{r(s=>{let i=[...s,t.fps];return i.length>60?i.slice(-60):i}),t.memory&&o(s=>{let i=[...s,t.memory.usedMB];return i.length>60?i.slice(-60):i})},[t.fps,t.memory?.usedMB]),(0,dt.jsxs)("div",{className:"p-3 space-y-3 overflow-y-auto h-full custom-scrollbar",children:[(0,dt.jsxs)("div",{className:"text-[9px] font-bold text-text-muted uppercase tracking-widest flex items-center gap-1",children:[(0,dt.jsx)(Cd.BarChart3,{size:10})," Performance Dashboard"]}),(0,dt.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,dt.jsx)(j$,{fps:t.fps}),(0,dt.jsxs)("div",{className:"rounded-xl bg-blue-500/10 px-4 py-3",children:[(0,dt.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,dt.jsx)(Cd.HardDrive,{size:12,className:"text-blue-400"}),(0,dt.jsx)("span",{className:"text-[10px] font-bold text-text-primary",children:"Memoria"})]}),t.memory?(0,dt.jsxs)(dt.Fragment,{children:[(0,dt.jsxs)("div",{className:"text-[14px] font-bold text-blue-400",children:[t.memory.usedMB,"MB"]}),(0,dt.jsxs)("div",{className:"text-[9px] text-text-muted",children:[t.memory.percent,"% de ",t.memory.totalMB,"MB"]}),(0,dt.jsx)("div",{className:"mt-1 h-1.5 bg-surface-tertiary rounded-full overflow-hidden",children:(0,dt.jsx)("div",{className:`h-full rounded-full transition-all ${t.memory.percent>80?"bg-red-500":t.memory.percent>50?"bg-amber-500":"bg-blue-500"}`,style:{width:`${t.memory.percent}%`}})})]}):(0,dt.jsx)("div",{className:"text-[9px] text-text-muted italic",children:"No disponible"})]}),(0,dt.jsxs)("div",{className:"rounded-xl bg-violet-500/10 px-4 py-3",children:[(0,dt.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,dt.jsx)(Cd.Cpu,{size:12,className:"text-violet-400"}),(0,dt.jsx)("span",{className:"text-[10px] font-bold text-text-primary",children:"DOM"})]}),(0,dt.jsx)("div",{className:"text-[14px] font-bold text-violet-400",children:t.domNodes.toLocaleString()}),(0,dt.jsx)("div",{className:"text-[9px] text-text-muted",children:t.domNodes>5e3?"\u26A0\uFE0F Alto":t.domNodes>2e3?"Normal":"\u2705 Ligero"})]})]}),(0,dt.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,dt.jsxs)("div",{className:"rounded-xl bg-surface-secondary/50 border border-border-subtle px-3 py-2",children:[(0,dt.jsx)("div",{className:"text-[9px] text-text-muted mb-1",children:"FPS (\xFAltimos 30s)"}),(0,dt.jsx)(a2,{data:e,color:"#34d399",width:200,height:30})]}),t.memory&&(0,dt.jsxs)("div",{className:"rounded-xl bg-surface-secondary/50 border border-border-subtle px-3 py-2",children:[(0,dt.jsx)("div",{className:"text-[9px] text-text-muted mb-1",children:"Memoria (\xFAltimos 30s)"}),(0,dt.jsx)(a2,{data:n,color:"#60a5fa",width:200,height:30})]})]})]})}var Ei,Cd,dt,c2=U(()=>{"use strict";Ei=require("react"),Cd=require("lucide-react"),dt=require("react/jsx-runtime")});function f2(){return{meta:{exportedAt:new Date().toISOString(),userAgent:navigator.userAgent,url:window.location.href,screenSize:`${window.innerWidth}x${window.innerHeight}`},logs:Ut.getState().logEntries.slice(-100),timeline:gi.getState().events,network:Zu(),morphology:{activeStage:_t.getState().activeStage,stageHistory:_t.getState().stageHistory},layout:{activeStage:ke.getState().activeStage,stageHistory:ke.getState().stageHistory,slots:ke.getState().slots},instances:(()=>{let e=Ue.getState().instances,r=[];return e.forEach((n,o)=>r.push({instanceId:o,...n})),r})(),profiles:Fa.getState().profiles}}function d2(){let t=f2(),e=[],r=new Date().toLocaleString();e.push(`# Debug Report \u2014 ${r}
|
|
53
|
+
`),e.push("## Meta"),e.push(`- **Screen**: ${t.meta.screenSize}`),e.push(`- **URL**: ${t.meta.url}`),e.push(`- **UA**: ${t.meta.userAgent}
|
|
54
|
+
`),e.push("## Morphology State"),e.push(`- **Active Stage**: ${t.morphology.activeStage?.type||"null"} (${t.morphology.activeStage?.label||"\u2013"})`),e.push(`- **History Depth**: ${t.morphology.stageHistory.length}`);let n=t.morphology.activeStage?.type===t.layout.activeStage?.type?"\u2705 Sincronizado":"\u26A0\uFE0F DESINCRONIZADO";e.push(`- **Layout Sync**: ${n}
|
|
55
|
+
`);let o={info:0,warn:0,error:0,debug:0};t.logs.forEach(i=>{o[i.level]++}),e.push(`## Logs Summary (${t.logs.length})`),e.push(`| Level | Count |
|
|
56
|
+
|-------|-------|
|
|
57
|
+
| info | ${o.info} |
|
|
58
|
+
| warn | ${o.warn} |
|
|
59
|
+
| error | ${o.error} |
|
|
60
|
+
| debug | ${o.debug} |
|
|
61
|
+
`);let s=t.network.filter(i=>i.status>=400||i.error).length;return e.push(`## Network (${t.network.length} requests, ${s} errors)`),t.network.length>0&&(e.push("| Time | Method | Status | URL | Duration |"),e.push("|------|--------|--------|-----|----------|"),t.network.slice(-20).forEach(i=>{let a=i.url.length>50?i.url.slice(0,47)+"...":i.url;e.push(`| ${i.timestamp} | ${i.method} | ${i.status||"ERR"} | ${a} | ${i.duration}ms |`)})),e.push(""),e.push(`## Timeline Events (${t.timeline.length})`),t.timeline.slice(-30).forEach(i=>{e.push(`- \`${i.timestamp}\` **${i.storeName}**.${i.actionName} ${i.level!=="info"?`(${i.level})`:""}`)}),e.join(`
|
|
62
|
+
`)}function u2(t,e,r){let n=new Blob([t],{type:r}),o=URL.createObjectURL(n),s=document.createElement("a");s.href=o,s.download=e,s.click(),URL.revokeObjectURL(o)}function p2(){let[t,e]=(0,Wl.useState)(!1),[r,n]=(0,Wl.useState)(null),o=(0,Wl.useCallback)(()=>{let c=f2(),d=new Date().toISOString().replace(/[:.]/g,"-");u2(JSON.stringify(c,null,2),`debug-report-${d}.json`,"application/json"),n("\u{1F4E6} JSON exportado"),setTimeout(()=>n(null),2e3)},[]),s=(0,Wl.useCallback)(()=>{let c=d2(),d=new Date().toISOString().replace(/[:.]/g,"-");u2(c,`debug-report-${d}.md`,"text/markdown"),n("\u{1F4DD} Markdown exportado"),setTimeout(()=>n(null),2e3)},[]),i=(0,Wl.useCallback)(async()=>{let c=d2();await navigator.clipboard.writeText(c),e(!0),n("\u{1F4CB} Copiado al portapapeles"),setTimeout(()=>{e(!1),n(null)},2e3)},[]),a=Ut(c=>c.logEntries.length),l=gi(c=>c.events.length);return(0,It.jsxs)("div",{className:"p-4 space-y-4 overflow-y-auto h-full custom-scrollbar",children:[(0,It.jsxs)("div",{className:"text-[10px] font-bold text-text-secondary uppercase tracking-widest flex items-center gap-1",children:[(0,It.jsx)(Ti.Download,{size:10})," Exportar Sesi\xF3n de Debug"]}),(0,It.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,It.jsxs)("button",{onClick:o,className:"rounded-xl bg-blue-500/10 border border-blue-500/20 p-4 hover:bg-blue-500/15 transition-all group",children:[(0,It.jsx)(Ti.FileJson,{size:24,className:"text-blue-400 mb-2 group-hover:scale-110 transition-transform"}),(0,It.jsx)("div",{className:"text-[11px] font-bold text-text-primary",children:"JSON Completo"}),(0,It.jsx)("div",{className:"text-[9px] text-text-muted mt-1",children:"Logs, timeline, network, morph state, profiles"})]}),(0,It.jsxs)("button",{onClick:s,className:"rounded-xl bg-violet-500/10 border border-violet-500/20 p-4 hover:bg-violet-500/15 transition-all group",children:[(0,It.jsx)(Ti.FileText,{size:24,className:"text-violet-400 mb-2 group-hover:scale-110 transition-transform"}),(0,It.jsx)("div",{className:"text-[11px] font-bold text-text-primary",children:"Markdown Report"}),(0,It.jsx)("div",{className:"text-[9px] text-text-muted mt-1",children:"Resumen legible con tablas y m\xE9tricas"})]}),(0,It.jsxs)("button",{onClick:i,className:"rounded-xl bg-emerald-500/10 border border-emerald-500/20 p-4 hover:bg-emerald-500/15 transition-all group",children:[t?(0,It.jsx)(Ti.Check,{size:24,className:"text-emerald-400 mb-2"}):(0,It.jsx)(Ti.Copy,{size:24,className:"text-emerald-400 mb-2 group-hover:scale-110 transition-transform"}),(0,It.jsx)("div",{className:"text-[11px] font-bold text-text-primary",children:"Copiar al Clipboard"}),(0,It.jsx)("div",{className:"text-[9px] text-text-muted mt-1",children:"Pegar en chat, issue, o documento"})]})]}),(0,It.jsxs)("div",{className:"rounded-xl bg-surface-secondary/50 border border-border-subtle p-3",children:[(0,It.jsx)("div",{className:"text-[9px] font-bold text-text-muted uppercase tracking-widest mb-2",children:"Datos a exportar"}),(0,It.jsxs)("div",{className:"grid grid-cols-4 gap-3 text-center",children:[(0,It.jsxs)("div",{children:[(0,It.jsx)("div",{className:"text-[14px] font-bold text-green-400",children:a}),(0,It.jsx)("div",{className:"text-[8px] text-text-muted",children:"Logs"})]}),(0,It.jsxs)("div",{children:[(0,It.jsx)("div",{className:"text-[14px] font-bold text-amber-400",children:l}),(0,It.jsx)("div",{className:"text-[8px] text-text-muted",children:"Timeline"})]}),(0,It.jsxs)("div",{children:[(0,It.jsx)("div",{className:"text-[14px] font-bold text-cyan-400",children:Zu().length}),(0,It.jsx)("div",{className:"text-[8px] text-text-muted",children:"Network"})]}),(0,It.jsxs)("div",{children:[(0,It.jsx)("div",{className:"text-[14px] font-bold text-violet-400",children:Fa.getState().profiles.length}),(0,It.jsx)("div",{className:"text-[8px] text-text-muted",children:"Profiles"})]})]})]}),r&&(0,It.jsx)("div",{className:"text-[10px] text-emerald-400 font-mono animate-pulse text-center",children:r})]})}var Wl,Ti,It,h2=U(()=>{"use strict";Wl=require("react"),Ti=require("lucide-react");Us();fh();hx();ys();Qn();mo();mx();It=require("react/jsx-runtime")});function U$(t){return t?/^#[0-9a-f]{3,8}$/i.test(t)||/^rgb/i.test(t):!1}function G$(t){let e=getComputedStyle(t),r=getComputedStyle(document.documentElement),n=[],o=["surface-primary","surface-secondary","surface-tertiary","surface-elevated","surface-glass","text-primary","text-secondary","text-muted","accent-blue","accent-purple","accent-green","accent-red","accent-amber","accent-cyan","border-subtle","border-default","border-strong","border-glow"],s=e.backgroundColor,i=e.color,a=e.borderColor;for(let l of o){let c=r.getPropertyValue(`--ds-${l}`).trim();c&&(s===c||i===c||a===c)&&n.push({token:`--ds-${l}`,value:c})}return n}var rn,$r,ge,m2,W$,K$,g2,b2=U(()=>{"use strict";rn=require("react"),$r=require("lucide-react");Fu();ge=require("react/jsx-runtime"),m2=({target:t,color:e="#3b82f6"})=>{let[r,n]=(0,rn.useState)(null);return(0,rn.useEffect)(()=>{if(!t){n(null);return}let o=()=>n(t.getBoundingClientRect());o();let s=new ResizeObserver(o);return s.observe(t),window.addEventListener("scroll",o,!0),()=>{s.disconnect(),window.removeEventListener("scroll",o,!0)}},[t]),r?(0,ge.jsx)("div",{className:"fixed pointer-events-none z-99999",style:{left:r.left-2,top:r.top-2,width:r.width+4,height:r.height+4,border:`2px solid ${e}`,borderRadius:4,background:`${e}11`,transition:"all 0.15s ease"},children:(0,ge.jsxs)("span",{className:"absolute -top-5 left-0 text-[9px] font-mono px-1.5 py-0.5 rounded",style:{background:e,color:"#fff"},children:[t?.tagName.toLowerCase(),t?.id?`#${t.id}`:"",t?.classList.length?`.${Array.from(t.classList).slice(0,2).join(".")}`:""]})}):null},W$=["display","position","z-index","opacity","width","height","max-width","max-height","margin","padding","gap","flex","flex-direction","align-items","justify-content","background-color","color","font-size","font-weight","border","border-radius","box-shadow","backdrop-filter","overflow","transform","pointer-events"];K$=({el:t})=>{let e=getComputedStyle(t),r={t:e.marginTop,r:e.marginRight,b:e.marginBottom,l:e.marginLeft},n={t:e.paddingTop,r:e.paddingRight,b:e.paddingBottom,l:e.paddingLeft},o=t.offsetWidth,s=t.offsetHeight;return(0,ge.jsx)("div",{className:"flex justify-center py-3",children:(0,ge.jsx)("div",{className:"relative text-[8px] font-mono select-none",children:(0,ge.jsxs)("div",{className:"border border-dashed border-accent-amber/40 bg-accent-amber/5 px-6 py-4 rounded",children:[(0,ge.jsx)("span",{className:"absolute top-0.5 left-1 text-accent-amber/60",children:"margin"}),(0,ge.jsx)("span",{className:"absolute top-1 left-1/2 -translate-x-1/2 text-accent-amber",children:r.t}),(0,ge.jsx)("span",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 text-accent-amber",children:r.b}),(0,ge.jsx)("span",{className:"absolute left-1 top-1/2 -translate-y-1/2 text-accent-amber",children:r.l}),(0,ge.jsx)("span",{className:"absolute right-1 top-1/2 -translate-y-1/2 text-accent-amber",children:r.r}),(0,ge.jsxs)("div",{className:"border border-dashed border-accent-green/40 bg-accent-green/5 px-6 py-4 rounded relative",children:[(0,ge.jsx)("span",{className:"absolute top-0.5 left-1 text-accent-green/60",children:"padding"}),(0,ge.jsx)("span",{className:"absolute top-1 left-1/2 -translate-x-1/2 text-accent-green",children:n.t}),(0,ge.jsx)("span",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 text-accent-green",children:n.b}),(0,ge.jsx)("span",{className:"absolute left-1 top-1/2 -translate-y-1/2 text-accent-green",children:n.l}),(0,ge.jsx)("span",{className:"absolute right-1 top-1/2 -translate-y-1/2 text-accent-green",children:n.r}),(0,ge.jsxs)("div",{className:"bg-accent-blue/10 border border-accent-blue/30 rounded px-4 py-2 text-center text-accent-blue",children:[o," \xD7 ",s]})]})]})})})},g2=()=>{let[t,e]=(0,rn.useState)(null),[r,n]=(0,rn.useState)(null),[o,s]=(0,rn.useState)(!1),[i,a]=(0,rn.useState)("classes"),[l,c]=(0,rn.useState)(""),[d,u]=(0,rn.useState)(!1),[f,p]=(0,rn.useState)(""),[h,b]=(0,rn.useState)([]),g=mi(k=>k.setTheme),x=mi(k=>k.currentThemeId);(0,rn.useEffect)(()=>{if(!o)return;let k=T=>{T.preventDefault(),T.stopPropagation();let E=T.target;E.closest("[data-debug-panel]")||(e(E),s(!1))},M=T=>{let E=T.target;E.closest("[data-debug-panel]")||n(E)};return document.addEventListener("click",k,!0),document.addEventListener("mousemove",M,!0),document.body.style.cursor="crosshair",()=>{document.removeEventListener("click",k,!0),document.removeEventListener("mousemove",M,!0),document.body.style.cursor=""}},[o]);let y=(0,rn.useMemo)(()=>t?Array.from(t.classList).filter(k=>!l||k.includes(l)):[],[t,l]),m=(0,rn.useMemo)(()=>{if(!t)return[];let k=getComputedStyle(t);return(d?Array.from({length:k.length},(T,E)=>k[E]):W$).map(T=>({prop:T,value:k.getPropertyValue(T)})).filter(T=>T.value&&T.value!=="none"&&T.value!=="normal"&&T.value!=="auto"&&T.value!=="0px").filter(T=>!l||T.prop.includes(l)||T.value.includes(l))},[t,l,d]),v=(0,rn.useMemo)(()=>t?G$(t):[],[t]),S=(0,rn.useCallback)(k=>{t&&(t.classList.toggle(k),e(t),c(M=>M))},[t]),w=(0,rn.useCallback)(()=>{!t||!f.trim()||(t.classList.add(...f.trim().split(/\s+/)),p(""),c(k=>k))},[t,f]),C=(0,rn.useCallback)(()=>{let k=document.getElementById("root");if(!k)return;let M=[];k.querySelectorAll("*").forEach(T=>{if(!(T instanceof HTMLElement))return;let E=getComputedStyle(T),P=E.backgroundColor,N=E.color;P&&P!=="rgba(0, 0, 0, 0)"&&P!=="transparent"&&!Array.from(T.classList).some(R=>R.startsWith("bg-surface-")||R.startsWith("bg-accent-"))&&U$(P)&&M.push(T)}),b(M)},[]),A=[{id:"classes",label:"Classes",icon:$r.Layers},{id:"computed",label:"CSS",icon:$r.Box},{id:"tokens",label:"Tokens",icon:$r.Palette},{id:"box",label:"Box",icon:$r.Box}];return(0,ge.jsxs)("div",{className:"flex flex-col h-full text-text-primary","data-debug-panel":!0,children:[(0,ge.jsx)(m2,{target:o?r:t,color:o?"#f59e0b":"#3b82f6"}),r&&!o&&r!==t&&(0,ge.jsx)(m2,{target:r,color:"#22d3ee44"}),(0,ge.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border-subtle bg-surface-secondary/50 shrink-0",children:[(0,ge.jsxs)("button",{onClick:()=>s(!o),className:`flex items-center gap-1 px-2 py-1 rounded text-[10px] font-semibold transition-all ${o?"bg-accent-amber/20 text-accent-amber ring-1 ring-accent-amber/40":"text-text-muted hover:text-text-primary hover:bg-surface-glass"}`,title:"Pick Element",children:[o?(0,ge.jsx)($r.Eye,{size:11}):(0,ge.jsx)($r.EyeOff,{size:11}),"Pick"]}),(0,ge.jsx)("div",{className:"w-px h-4 bg-border-subtle mx-1"}),(0,ge.jsx)("select",{value:x,onChange:k=>g(k.target.value),className:"bg-surface-tertiary text-text-primary text-[10px] font-mono rounded px-1.5 py-1 border border-border-subtle outline-none cursor-pointer",children:$u.map(k=>(0,ge.jsx)("option",{value:k.id,children:k.name},k.id))}),(0,ge.jsx)("div",{className:"w-px h-4 bg-border-subtle mx-1"}),(0,ge.jsxs)("button",{onClick:C,className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] font-semibold text-text-muted hover:text-accent-red hover:bg-accent-red/10 transition-all",title:"Find elements with hardcoded colors",children:[(0,ge.jsx)($r.AlertTriangle,{size:10}),"Audit",h.length>0&&(0,ge.jsx)("span",{className:"text-[8px] bg-accent-red/20 text-accent-red px-1 rounded-full",children:h.length})]}),t&&(0,ge.jsxs)("div",{className:"ml-auto text-[9px] font-mono text-text-muted truncate max-w-[180px]",children:["<",t.tagName.toLowerCase(),t.id?`#${t.id}`:"",">",(0,ge.jsxs)("span",{className:"text-text-muted/50 ml-1",children:[t.offsetWidth,"\xD7",t.offsetHeight]})]})]}),t?(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsxs)("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-border-subtle shrink-0",children:[A.map(k=>(0,ge.jsx)("button",{onClick:()=>a(k.id),className:`px-2 py-0.5 rounded text-[10px] font-semibold transition-all ${i===k.id?"bg-surface-glass text-text-primary":"text-text-muted hover:text-text-primary"}`,children:k.label},k.id)),(0,ge.jsxs)("div",{className:"ml-auto flex items-center gap-1 bg-surface-tertiary rounded px-1.5 py-0.5 border border-border-subtle",children:[(0,ge.jsx)($r.Search,{size:9,className:"text-text-muted"}),(0,ge.jsx)("input",{value:l,onChange:k=>c(k.target.value),placeholder:"Filter...",className:"bg-transparent text-text-primary text-[10px] font-mono outline-none w-20"})]})]}),(0,ge.jsxs)("div",{className:"flex-1 overflow-auto scrollbar-thin",children:[i==="classes"&&(0,ge.jsxs)("div",{className:"p-2",children:[(0,ge.jsxs)("div",{className:"flex items-center gap-1 mb-2",children:[(0,ge.jsx)("input",{value:f,onChange:k=>p(k.target.value),onKeyDown:k=>k.key==="Enter"&&w(),placeholder:"Add TW class...",className:"flex-1 bg-surface-tertiary text-text-primary text-[10px] font-mono px-2 py-1 rounded border border-border-subtle outline-none focus:border-accent-blue/50"}),(0,ge.jsx)("button",{onClick:w,className:"p-1 rounded text-text-muted hover:text-accent-green hover:bg-accent-green/10",children:(0,ge.jsx)($r.Plus,{size:11})})]}),(0,ge.jsxs)("div",{className:"flex flex-wrap gap-1",children:[y.map(k=>(0,ge.jsxs)("button",{onClick:()=>S(k),className:"group flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[9px] font-mono bg-surface-glass border border-border-subtle text-text-secondary hover:text-text-primary hover:border-accent-blue/40 transition-all",children:[k,(0,ge.jsx)($r.X,{size:8,className:"opacity-0 group-hover:opacity-100 text-accent-red"})]},k)),y.length===0&&(0,ge.jsx)("span",{className:"text-[10px] text-text-muted italic",children:"No classes match filter"})]}),(0,ge.jsxs)("button",{onClick:()=>t&&navigator.clipboard.writeText(Array.from(t.classList).join(" ")),className:"mt-2 flex items-center gap-1 text-[9px] text-text-muted hover:text-accent-cyan transition-colors",children:[(0,ge.jsx)($r.Copy,{size:9})," Copy all classes"]})]}),i==="computed"&&(0,ge.jsxs)("div",{children:[(0,ge.jsx)("div",{className:"px-2 py-1 flex justify-end",children:(0,ge.jsx)("button",{onClick:()=>u(!d),className:`text-[9px] font-mono px-1.5 py-0.5 rounded ${d?"bg-accent-purple/20 text-accent-purple":"text-text-muted hover:text-text-primary"}`,children:d?"ALL":"KEY"})}),m.map(({prop:k,value:M})=>(0,ge.jsxs)("div",{className:"flex items-center gap-1 px-2 py-0.5 text-[10px] font-mono hover:bg-surface-glass group",children:[(0,ge.jsxs)("span",{className:"text-accent-purple shrink-0 w-[110px] truncate",children:[k,":"]}),(0,ge.jsx)("span",{className:"flex-1 text-text-secondary truncate",children:M}),(k.includes("color")||k==="background-color")&&M!=="transparent"&&M!=="rgba(0, 0, 0, 0)"&&(0,ge.jsx)("span",{className:"w-3 h-3 rounded-sm border border-border-subtle shrink-0",style:{backgroundColor:M}}),(0,ge.jsx)("button",{onClick:()=>navigator.clipboard.writeText(`${k}: ${M}`),className:"opacity-0 group-hover:opacity-100 text-text-muted hover:text-accent-cyan",children:(0,ge.jsx)($r.Copy,{size:9})})]},k))]}),i==="tokens"&&(0,ge.jsxs)("div",{className:"p-2",children:[(0,ge.jsx)("div",{className:"text-[9px] font-mono text-text-muted uppercase tracking-wider mb-2",children:"Active Design Tokens"}),v.length>0?v.map(({token:k,value:M})=>(0,ge.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 rounded hover:bg-surface-glass text-[10px] font-mono",children:[(0,ge.jsx)("span",{className:"w-4 h-4 rounded border border-border-subtle shrink-0",style:{backgroundColor:M}}),(0,ge.jsx)("span",{className:"text-accent-cyan",children:k}),(0,ge.jsx)("span",{className:"text-text-muted ml-auto",children:M})]},k)):(0,ge.jsxs)("div",{className:"text-text-muted text-[10px] italic",children:["No `--ds-*` tokens detected on this element.",(0,ge.jsx)("br",{}),"This might use hardcoded colors."]}),t?.style.cssText&&(0,ge.jsxs)("div",{className:"mt-3",children:[(0,ge.jsx)("div",{className:"text-[9px] font-mono text-text-muted uppercase tracking-wider mb-1",children:"Inline Styles"}),(0,ge.jsx)("div",{className:"text-[10px] font-mono text-accent-amber bg-surface-glass rounded p-2 break-all",children:t.style.cssText})]})]}),i==="box"&&t&&(0,ge.jsx)(K$,{el:t})]})]}):(0,ge.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-text-muted text-xs gap-2 py-8",children:[(0,ge.jsx)($r.Eye,{size:24,className:"opacity-30"}),(0,ge.jsxs)("span",{children:["Click ",(0,ge.jsx)("strong",{children:'"Pick"'})," to select an element"]}),(0,ge.jsxs)("span",{className:"text-[9px]",children:["or use ",(0,ge.jsx)("strong",{children:'"Audit"'})," to find hardcoded colors"]})]}),h.length>0&&(0,ge.jsxs)("div",{className:"shrink-0 border-t border-border-subtle px-2 py-1 bg-accent-red/5",children:[(0,ge.jsxs)("div",{className:"text-[9px] font-mono text-accent-red mb-1",children:["\u26A0 ",h.length," elements with potential hardcoded colors"]}),(0,ge.jsx)("div",{className:"flex flex-wrap gap-1 max-h-12 overflow-auto",children:h.slice(0,20).map((k,M)=>(0,ge.jsxs)("button",{onClick:()=>{e(k),a("computed")},className:"text-[8px] font-mono text-text-muted hover:text-accent-red bg-surface-glass rounded px-1 py-0.5",children:[k.tagName.toLowerCase(),k.className&&typeof k.className=="string"?`.${k.className.split(" ")[0]}`:""]},M))})]})]})}});var y2={};Mo(y2,{DebugPanel:()=>Qu});var x2,Uh,yr,xo,q$,Y$,Qu,Gh=U(()=>{"use strict";x2=Re(require("react")),Uh=require("motion/react"),yr=require("lucide-react");Us();Ek();Mk();Ok();Bk();Fk();Uk();e2();o2();i2();c2();h2();b2();xo=require("react/jsx-runtime"),q$=[{id:"logs",label:"Logs",icon:yr.Bug,color:"text-green-400"},{id:"flow-health",label:"Health",icon:yr.Activity,color:"text-cyan-400"},{id:"topology",label:"Topology",icon:yr.Map,color:"text-purple-400"},{id:"replay",label:"Replay",icon:yr.PlayCircle,color:"text-amber-400"},{id:"stores",label:"Stores",icon:yr.Database,color:"text-emerald-400"},{id:"morph-stack",label:"Morph",icon:yr.Layers,color:"text-violet-400"},{id:"network",label:"Network",icon:yr.Globe,color:"text-cyan-400"},{id:"profiles",label:"Profiles",icon:yr.UserCog,color:"text-rose-400"},{id:"timeline",label:"Timeline",icon:yr.Clock,color:"text-amber-400"},{id:"performance",label:"Perf",icon:yr.Gauge,color:"text-lime-400"},{id:"export",label:"Export",icon:yr.Download,color:"text-text-secondary"},{id:"css-inspector",label:"CSS",icon:yr.Palette,color:"text-indigo-400"}],Y$={logs:kk,"flow-health":Ak,topology:Dk,replay:Lk,stores:$k,"morph-stack":Wk,network:Qk,profiles:n2,timeline:s2,performance:l2,export:p2,"css-inspector":g2},Qu=x2.default.memo(function({className:e}){let r=Ut(l=>l.isOpen),n=Ut(l=>l.activeTab),o=Ut(l=>l.setActiveTab),s=Ut(l=>l.togglePanel),i=Ut(l=>l.errorCount);if(!r)return null;let a=Y$[n];return(0,xo.jsx)(Uh.AnimatePresence,{children:(0,xo.jsxs)(Uh.motion.div,{initial:{height:0,opacity:0},animate:{height:"100%",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15,ease:"easeOut"},className:`flex flex-col bg-surface-primary border-t border-border-default overflow-hidden ${e||""}`,children:[(0,xo.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 border-b border-border-subtle shrink-0 bg-surface-primary/80",children:[(0,xo.jsx)("div",{className:"flex items-center gap-0.5 overflow-x-auto flex-1 min-w-0",style:{scrollbarWidth:"none"},children:q$.map(l=>{let c=l.icon,d=n===l.id;return(0,xo.jsxs)("button",{onClick:()=>o(l.id),className:`flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-semibold transition-all whitespace-nowrap shrink-0 ${d?"bg-surface-glass text-text-primary shadow-xs":"text-text-muted hover:text-text-primary hover:bg-surface-glass"}`,children:[(0,xo.jsx)(c,{size:11,className:d?l.color:""}),l.label,l.id==="logs"&&i>0&&(0,xo.jsx)("span",{className:"ml-0.5 px-1 py-0.5 rounded-full text-[8px] font-bold bg-red-500/20 text-red-400",children:i})]},l.id)})}),(0,xo.jsxs)("div",{className:"flex items-center gap-1 shrink-0 ml-1",children:[(0,xo.jsx)("span",{className:"text-[9px] text-text-muted font-mono mr-1",children:"\u2303\u21E7D"}),(0,xo.jsx)("button",{onClick:s,className:"p-1 rounded text-text-muted hover:text-text-primary hover:bg-surface-glass transition-colors",title:"Cerrar panel",children:(0,xo.jsx)(yr.X,{size:14})})]})]}),(0,xo.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,xo.jsx)(a,{})})]})})})});function Ul(t){let{chatId:e,shellType:r,label:n,data:o={},artifact:s}=t;Ue.getState().upsertInstance({id:e,sourceChatId:e,shellType:r,label:n,data:o}),s&&Ue.getState().pushArtifact(e,{id:s.id,name:s.name,shellType:s.shellType||r,version:s.version||1,data:s.data}),X.getState().setShowCanvas(!0),console.log(`[MorphBridge] \u{1F300} ${r} instance "${n}" \u2192 tab ${e}`)}function v2(t){return typeof t=="string"?/<html|<div|<body|<script/i.test(t)?"iframe":(/^#{1,6}\s|^\*\*|^\- \[/m.test(t),"markdown"):t.artifact||t.schema?"iframe":t.keyframes||t.nodes?"shell-canvas":"markdown"}var gx=U(()=>{"use strict";mo();ot()});var kd,S2,Kh,N2,C2,k2,w2,E2,T2=U(()=>{"use strict";kd=require("react");ot();S2=require("@decido/engine"),Kh=require("@decido/engine");xi();N2=require("@decido/engine"),C2=require("@decido/engine");Ol();k2=require("@decido/engine");gx();mo();Vu();w2={},E2=t=>{let e=X(y=>y.prototypeBrand),r=X(y=>y.setInputValue),n=X(y=>y.addLog),o=X(y=>y.addChatMessage),s=(0,S2.useTimelineStore)(y=>y.timelines),{semanticMatch:i,isThinking:a}=(0,N2.useReactiveEngine)(t),{generateKeyframeOnTheFly:l,generateTimeline:c,isGenerating:d}=(0,C2.useAIDirector)(t),{emitEvent:u,isConnected:f}=ed(),p=s[e],h=(0,Kh.useEngineStore)(y=>y.lastEvent);(0,kd.useEffect)(()=>{let y=v=>{let S=v.detail?.html;if(S){let w=`web-${Date.now()}`;Ul({chatId:w,shellType:"nexusai-preview",label:"Reporte en Vivo",data:{html:S,css:"",javascript:""}}),X.getState().setIsSidebarOpen(!1)}},m=v=>{v.detail?.query&&X.getState().setIsSidebarOpen(!1)};return window.addEventListener("studio:render-preview",y),window.addEventListener("studio:search-order",m),()=>{window.removeEventListener("studio:render-preview",y),window.removeEventListener("studio:search-order",m)}},[]);let b=(0,kd.useCallback)(y=>{if(!p)return;let m=p.keyframes.find(v=>v.id===y);m&&(n(`Reaccionando a Nodo: ${m.state||m.id}`,"system"),Kh.useEngineStore.getState().dispatchEvent({type:"USER_INTENT_MATCHED",targetNodeId:y,routeHandle:"success"}))},[p,n]),g=(0,kd.useCallback)(async y=>{if(!y||!y.trim())return;n(`Analizando intenci\xF3n: "${y}"`,"system"),k2.AudioController.stop(),o({type:"text",sender:"user",text:y});let m=localStorage.getItem("decido_selected_shell");if(m==="nexusai-preview"||m==="iframe"){n("\u{1F310} Web Preview mode \u2014 generando HTML directo...","system"),o({type:"text",sender:"system",text:"\u{1F310} Generando dise\xF1o web..."});let A=localStorage.getItem("google_gemini_api_key")||window.__DECIDO__?._apiKey||w2.env?.VITE_GEMINI_API_KEY||"",k=localStorage.getItem("decido_gemini_model")||"gemini-3-flash-preview";if(!A){o({type:"error",sender:"system",text:"\u26A0\uFE0F No se encontr\xF3 API key de Gemini."});return}let M=Ue.getState().getActiveInstance(),T=M?.data?.html||"",E=M?.data?.css||"",P=M?.data?.javascript||"",N=!!T.trim(),D=window.__DECIDO__?.selectedElementSelector||null,R=D?`
|
|
63
|
+
|
|
64
|
+
IMPORTANT: The user has SELECTED a specific element: \`${D}\`. Focus your changes ONLY on this element and its children. Do not modify other parts of the page.`:"",O=N?`You are an expert web developer. The user has an EXISTING web page and wants to MODIFY it.${R}
|
|
65
|
+
|
|
66
|
+
CURRENT HTML:
|
|
67
|
+
\`\`\`html
|
|
68
|
+
${T}
|
|
69
|
+
\`\`\`
|
|
70
|
+
|
|
71
|
+
CURRENT CSS:
|
|
72
|
+
\`\`\`css
|
|
73
|
+
${E}
|
|
74
|
+
\`\`\`
|
|
75
|
+
|
|
76
|
+
CURRENT JavaScript:
|
|
77
|
+
\`\`\`javascript
|
|
78
|
+
${P}
|
|
79
|
+
\`\`\`
|
|
80
|
+
|
|
81
|
+
Apply the user's requested changes to the EXISTING code above. Keep everything else intact.
|
|
82
|
+
IMPORTANT: DO NOT USE JSON. Instead, strictly format your response using these XML-like tags:
|
|
83
|
+
<decido-html>
|
|
84
|
+
<!-- your html here without <html> or <body> tags -->
|
|
85
|
+
</decido-html>
|
|
86
|
+
<decido-css>
|
|
87
|
+
/* your tailwind/custom css here */
|
|
88
|
+
</decido-css>
|
|
89
|
+
<decido-js>
|
|
90
|
+
// your javascript here
|
|
91
|
+
</decido-js>
|
|
92
|
+
Use Tailwind CSS classes. Do not include explanatory text outside the tags.`:`You are an expert web developer. Generate HTML, CSS, and JavaScript for the user's request.
|
|
93
|
+
IMPORTANT: DO NOT USE JSON. Instead, strictly format your response using these XML-like tags:
|
|
94
|
+
<decido-html>
|
|
95
|
+
<!-- your html here without <html> or <body> tags -->
|
|
96
|
+
</decido-html>
|
|
97
|
+
<decido-css>
|
|
98
|
+
/* your tailwind/custom css here */
|
|
99
|
+
</decido-css>
|
|
100
|
+
<decido-js>
|
|
101
|
+
// your javascript here
|
|
102
|
+
</decido-js>
|
|
103
|
+
Use Tailwind CSS classes for styling (it will be auto-loaded). Write modern, responsive, visually stunning code.
|
|
104
|
+
Use vibrant gradients, dark backgrounds (#0a0a0a, #1a1a2e), neon accent colors, smooth animations, and premium typography.
|
|
105
|
+
Do not include any explanatory text outside the tags.`;try{let B=X.getState().activeChatId||"_default",H=(X.getState().chatMessagesByInstance[B]||[]).filter(Pe=>(Pe.sender==="user"||Pe.sender==="agent")&&Pe.type==="text"&&Pe.text?.trim()).slice(-10),j=[];for(let Pe of H){let K=Pe.sender==="user"?"user":"model";j.length>0&&j[j.length-1].role===K?j[j.length-1].parts[0].text+=`
|
|
106
|
+
`+(Pe.text||""):j.push({role:K,parts:[{text:Pe.text||""}]})}(j.length===0||j[j.length-1].role!=="user")&&j.push({role:"user",parts:[{text:y}]});let $=`https://generativelanguage.googleapis.com/v1beta/models/${k}:generateContent?key=${A}`;fn.gemini(`POST ${k} | ${j.length} turns | prompt: ${O.length} chars`,{model:k,turnsCount:j.length});let q=performance.now(),F=await fetch($,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contents:j,systemInstruction:{parts:[{text:O}]},generationConfig:{temperature:.7,maxOutputTokens:16384}})}),_=Math.round(performance.now()-q),W=await F.json(),V=W?.candidates?.[0]?.content?.parts?.[0]?.text||"",z=W?.usageMetadata?.totalTokenCount||0;fn.gemini(`Response ${F.status} | ${_}ms | ${z} tokens | ${V.length} chars`,{status:F.status,duration:_,tokens:z});let G={html:"",css:"",javascript:""},Y=/<decido-html>([\s\S]*?)<\/decido-html>/i.exec(V),Z=/<decido-css>([\s\S]*?)<\/decido-css>/i.exec(V),se=/<decido-js>([\s\S]*?)<\/decido-js>/i.exec(V);if(Y||Z||se)G.html=Y?Y[1].trim():"",G.css=Z?Z[1].trim():"",G.javascript=se?se[1].trim():"";else{let Pe=V.trim(),K=/```(?:json)?\s*([\s\S]*?)```/i.exec(V);K?Pe=K[1].trim():Pe=Pe.replace(/^```json\s*/i,"").replace(/\s*```$/i,"").trim();try{G=JSON.parse(Pe)}catch(he){console.error("Web Preview Parse Error:",he,V),G.html=`
|
|
107
|
+
<div class="fixed inset-0 flex flex-col items-center justify-center bg-gray-900 text-white p-6 text-center font-sans z-[9999]">
|
|
108
|
+
<div class="bg-red-500/10 border border-red-500 text-red-400 p-4 rounded-xl max-w-lg shadow-2xl">
|
|
109
|
+
<h3 class="font-bold text-lg mb-2">Error de Generaci\xF3n AI</h3>
|
|
110
|
+
<p class="text-sm opacity-80 mb-4">El modelo gener\xF3 c\xF3digo que no cumple con el formato XML o JSON estricto.</p>
|
|
111
|
+
<div class="text-xs text-left bg-black/50 p-2 rounded overflow-auto max-h-48 text-gray-300">
|
|
112
|
+
${he.message}
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
</div>`}}let we;N&&M?(we=M.id,Ue.getState().upsertInstance({id:we,sourceChatId:M.sourceChatId,shellType:"nexusai-preview",label:M.label,data:{html:G.html,css:G.css,javascript:G.javascript}})):(we=`web-${Date.now()}`,Ul({chatId:we,shellType:"nexusai-preview",label:y.slice(0,40),data:{html:G.html,css:G.css,javascript:G.javascript}})),o({type:"text",sender:"agent",text:`${N?"\u{1F504} Dise\xF1o actualizado":"\u2705 Dise\xF1o web generado"}. Revisa el panel derecho.`,morphInstanceId:we}),n(`\u{1F310} HTML ${N?"actualizado":"generado"} en Web Preview`,"success")}catch(B){fn.gemini(`ERROR: ${B.message}`,{error:B.message},"error"),o({type:"error",sender:"system",text:`Error generando HTML: ${B.message}`})}return}else if(m==="dataway-studio"){n("Dataway Studio \u2014 generando M-Script...","system");let A=localStorage.getItem("dataway_active_resource"),k=localStorage.getItem("dataway_active_connector")||"google_sheets";if(!A){o({type:"error",sender:"system",text:"Debes seleccionar una tabla en el panel Recursos de Dataway primero."});return}let M=`loading-${Date.now()}`;o({id:M,type:"text",sender:"system",text:"Analizando esquema y generando M-Script..."});try{let T=w2.env?.VITE_API_BASE_URL||"http://localhost:3001",E=await fetch(`${T}/api/dataway/copilot`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:y,connectorId:k,resource:A})});if(!E.ok){let N=await E.json().catch(()=>({error:`HTTP ${E.status}`}));throw new Error(N.error||`Error del servidor HTTP ${E.status}`)}let P=await E.json();if(P.script){let N=P.explanation?`**An\xE1lisis de la IA:** ${P.explanation}
|
|
116
|
+
|
|
117
|
+
`:"";o({type:"text",sender:"agent",text:`${N}Pipeline actualizado. Revisa el resultado:
|
|
118
|
+
|
|
119
|
+
\`\`\`dataway
|
|
120
|
+
${P.script}
|
|
121
|
+
\`\`\``}),window.dispatchEvent(new CustomEvent("intent:dataway-generate-script",{detail:{script:P.script,resource:P.targetResource}}))}else o({type:"error",sender:"system",text:"El agente no retorn\xF3 c\xF3digo."})}catch(T){o({type:"error",sender:"system",text:`Error de IA: ${T.message}`})}return}if(!p){n("No hay blueprint activo para evaluar.","error");return}let v=typeof window<"u"&&window.__DECIDO__?.intentEnabled!==!1,S=v&&/agrega|suma|añade|conecta|modifica|cambia|elimina|borra|parchea|actualiza|inserta|mueve/i.test(y);if(v&&/grafo|flujo|nodos|complejo|historia|blueprint|escenario|onboarding|proceso|workflow|pipeline|crea\s+(un|una|el|la|los|las)\s|diseña|genera\s+(un|una)|construye|orquest|trigger|subflujo|set\s+variable|marque\s+user\.|shell|tema|theme|sidebar|panel|activity\s*bar|status\s*bar|top\s*bar|notificaci[oó]n|shortcut|atajo|layout|configura\s+(el|la|los|las)\s/i.test(y)||S){n(`Intenci\xF3n compleja detectada. ${S?"Editando Grafo...":"Construyendo Nuevo Grafo..."}`,"system");let A=await c(y,e,15,S,p);A===!0?o({type:"text",sender:"system",text:"Se ha modificado el grafo contextualmente seg\xFAn tus instrucciones."}):A&&A.keyframes&&A.keyframes.length>0?(b(A.keyframes[0].id),o({type:"text",sender:"system",text:"Se ha creado un nuevo grafo."})):n("Fallo al generar el Blueprint con IA.","error");return}let C=v?await i(y,p):null;if(C&&C!=="GENERATE"&&typeof C=="string")b(C);else if(C&&typeof C=="object"&&C.intent==="UI_ACTION"){n(`\u{1F3A8} UI_ACTION detectada. Montando artefacto: ${C.artifact}`,"system"),X.getState().setActiveArtifactData({artifact:C.artifact,...C.payload});let A=`ui-${C.artifact}-${Date.now()}`;Ul({chatId:A,shellType:"nexusai-preview",label:C.artifact||"Visualizaci\xF3n",data:{artifact:C.artifact,...C.payload}}),o({type:"text",sender:"agent",text:"He preparado la visualizaci\xF3n solicitada en el panel derecho.",morphInstanceId:A})}else if(C&&typeof C=="object"&&C.intent==="MCP_ACTION")n(`Manejando intenci\xF3n MCP_ACTION: ${C.tool}`,"system"),Kh.useEngineStore.getState().dispatchEvent({type:"MCP_EXECUTION_REQUESTED",payload:{tool:C.tool,parameters:C.parameters}}),o({type:"text",sender:"system",text:`Ejecutando herramienta externa: ${C.tool}`});else if(C&&typeof C=="object"&&C.intent==="UI_COMPONENT"){n(`\u{1F3A8} UI_COMPONENT generado por IA: ${C.name}`,"system");let A=`ai_${Date.now()}`;Mn.getState().addComponent({id:A,name:C.name||"AI Component",category:C.category||"custom",schema:C.schema,dataContract:{inputs:{},outputs:{}},tags:C.tags||["ai-generated"],source:"ai-generated",createdAt:Date.now(),updatedAt:Date.now()}),Ul({chatId:`comp-${A}`,shellType:"nexusai-preview",label:C.name||"AI Component",data:{html:C.schema,schema:C.schema},artifact:{id:A,name:C.name||"AI Component",data:{html:C.schema,schema:C.schema}}}),o({type:"ui-artifact",sender:"agent",text:`\u{1F3A8} ${C.name}`,actorId:"system",uiSchema:JSON.stringify(C.schema),morphInstanceId:`comp-${A}`}),o({type:"text",sender:"system",text:`Componente "${C.name}" guardado en la biblioteca UI. Accede con /ui.`,morphInstanceId:`comp-${A}`})}else{n("Intenci\xF3n reactiva detectada. Inventando nodo en vivo...","system");let A=await l(y,e,p);A?b(A.id):n("Fallo al generar morfolog\xEDa reactiva.","error")}},[p,e,i,l,c,b,n,o,u,f]),x=(0,kd.useCallback)(async y=>{let m=typeof y=="string"?y:void 0;y&&typeof y.preventDefault=="function"&&y.preventDefault();let v=X.getState().inputValue,S=m||v;!S||typeof S!="string"||!S.trim()||(await g(S),r(""))},[g,r]);return{handleUserCommand:g,handleGeneratePlayground:x,isGenerating:d||a}}});var ef,bx=U(()=>{"use strict";ef=(t,e=!1)=>{if(!e)try{let r=new(window.AudioContext||window.webkitAudioContext),n=r.createOscillator(),o=r.createGain();n.connect(o),o.connect(r.destination),t==="beep"?(n.frequency.setValueAtTime(600,r.currentTime),o.gain.setValueAtTime(.1,r.currentTime),o.gain.exponentialRampToValueAtTime(.01,r.currentTime+.1),n.start(r.currentTime),n.stop(r.currentTime+.1)):t==="success"?(n.frequency.setValueAtTime(400,r.currentTime),n.frequency.exponentialRampToValueAtTime(800,r.currentTime+.2),o.gain.setValueAtTime(.1,r.currentTime),o.gain.exponentialRampToValueAtTime(.01,r.currentTime+.3),n.start(r.currentTime),n.stop(r.currentTime+.3)):t==="alert"&&(n.type="square",n.frequency.setValueAtTime(300,r.currentTime),n.frequency.setValueAtTime(400,r.currentTime+.1),o.gain.setValueAtTime(.1,r.currentTime),o.gain.exponentialRampToValueAtTime(.01,r.currentTime+.3),n.start(r.currentTime),n.stop(r.currentTime+.3))}catch{console.error("Audio not supported")}}});var tf,I2,A2,Ed,qh=U(()=>{"use strict";tf=require("react");ot();I2=require("@decido/engine"),A2=require("@decido/engine");bx();Ed=()=>{let t=X(u=>u.prototypeBrand),e=(0,I2.useTimelineStore)(u=>u.timelines),r=(0,A2.useEngineStore)(u=>u.activeNodeIds),{addLog:n,addChatMessage:o,isMuted:s,demoState:i,setDemoState:a,showCanvas:l,setShowCanvas:c}=X(),d=(0,tf.useRef)(new Set);return(0,tf.useEffect)(()=>{r.length===0&&(d.current.clear(),a("idle"))},[r,a]),(0,tf.useEffect)(()=>{let u=e[t]?.blueprint||{nodes:e[t]?.keyframes||[]};if(!u||r.length===0)return;u.nodes.filter(p=>r.includes(p.id)&&p.track==="ui").forEach(p=>{if(!d.current.has(p.id)){d.current.add(p.id);let h=p.state||"idle";a(h),p.canvas!==void 0&&c(p.canvas),n(`\u{1F500} System Authored Transition: UI Context [${h}]`,"system"),h.includes("whatsapp")&&!h.includes("resolved")&&!h.includes("idle")?o({type:"alert",sender:"system",text:"Alerta de SLA Cr\xEDtico detectada v\xEDa integraci\xF3n."}):h.includes("analyzing")&&o({type:"workflow",sender:"system",text:"Analizando informaci\xF3n contextual..."}),h.includes("alert")?ef("alert",s):ef("beep",s)}})},[r,t,e,s,n,o,a,c]),{demoState:i,setDemoState:a,showCanvas:l,setShowCanvas:c}}});function M2(){let[t,e]=(0,Va.useState)(!1),[r,n]=(0,Va.useState)(null),o=(0,Va.useRef)(null),s=(0,Va.useCallback)(async()=>{try{let a=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser",frameRate:{ideal:60}},audio:!0}),c=[{mimeType:"video/webm;codecs=vp9,opus",videoBitsPerSecond:8e6},{mimeType:"video/webm;codecs=h264,opus",videoBitsPerSecond:8e6},{mimeType:"video/webm;codecs=vp8,opus",videoBitsPerSecond:5e6},{mimeType:"video/webm",videoBitsPerSecond:25e5}].find(f=>MediaRecorder.isTypeSupported(f.mimeType));c||(c={mimeType:"",videoBitsPerSecond:25e5});let d=new MediaRecorder(a,c),u=[];return d.ondataavailable=f=>{f.data.size>0&&u.push(f.data)},d.onstop=()=>{let f=new Blob(u,{type:"video/webm"}),p=URL.createObjectURL(f),h=document.createElement("a");h.style.display="none",h.href=p,h.download=`decido-demo-${new Date().getTime()}.webm`,document.body.appendChild(h),h.click(),URL.revokeObjectURL(p),e(!1)},o.current=d,new Promise(f=>{let p=3;n(p);let h=setInterval(()=>{p-=1,p>0?n(p):(clearInterval(h),n(null),d.start(),e(!0),a.getVideoTracks()[0].onended=()=>{d.state!=="inactive"&&d.stop()},f(!0))},1e3)})}catch(a){return console.error("Error starting recording:",a),e(!1),n(null),!1}},[]),i=(0,Va.useCallback)(()=>{o.current&&o.current.state!=="inactive"&&o.current.stop()},[]);return{isRecording:t,countdown:r,startRecording:s,stopRecording:i}}var Va,P2=U(()=>{"use strict";Va=require("react")});function O2(t){let e=(0,R2.useMemo)(()=>({id:`tape-${t}`,events:[{t:.1,event:{type:"SYSTEM_START"},description:"Arranque Autom\xE1tico"}]}),[t]);return(0,D2.usePlaybackSimulator)(e)}var R2,D2,_2=U(()=>{"use strict";R2=require("react"),D2=require("@decido/engine")});var Yh,L2=U(()=>{"use strict";Yh=Object.assign(t=>{let e={availableLicenses:[{id:"1",name:"Decido Personal",type:"personal"},{id:"2",name:"K\xFAspide Corp",type:"enterprise"},{id:"3",name:"Madefront Ind",type:"enterprise"}]};return t?t(e):e},{getState:()=>({availableLicenses:[{id:"1",name:"Decido Personal",type:"personal"},{id:"2",name:"K\xFAspide Corp",type:"enterprise"},{id:"3",name:"Madefront Ind",type:"enterprise"}],login:(t,e,r)=>{},setActiveContext:t=>{}})})});function Xh(t,e){let r=t||{environments:{},voices:[]},n=(0,ta.useMemo)(()=>r.environments[e]||Object.values(r.environments)[0]||{gradient:"from-gray-400 to-gray-600",greetingText:"Console",subtitle:"Sin configuraci\xF3n",borderColor:"border-border-strong",glowColor:"shadow-none",buttonColor:"bg-surface-glass",buttonGlow:"shadow-none",suggestions:[],widgets:[]},[r,e]),[o,s]=(0,ta.useState)([]);(0,ta.useEffect)(()=>{s(u=>{let f=n.suggestions||[];return JSON.stringify(u)===JSON.stringify(f)?u:f})},[n.suggestions]);let i=Yh(u=>u.availableLicenses),a=i?.find(u=>u.type==="enterprise"),l=a?a.name:"Empresa Local",c=(0,ta.useMemo)(()=>({id:t?.persona?.id||"agent-core",name:t?.persona?.name||"Agent",voiceName:t?.persona?.voiceName||"Zephyr",systemInstruction:t?.persona?.systemInstruction||"Eres un agente inteligente del Marco de Trabajo Decido OS. Est\xE1s dise\xF1ado para proporcionar asistencia r\xE1pida, ejecutar comandos del sistema de forma segura, y ayudar al usuario en el uso de la interfaz."}),[t]),d=(0,ta.useCallback)(u=>{let{setSelectedProfile:f,setStep:p,addLog:h}=X.getState();f(u.name),p("action"),setTimeout(()=>{Yh.getState().login("admin",`${u.name} Context`,i),Yh.getState().setActiveContext(u.id),p("chat"),h(`Perfil cargado: ${u.name}`,"success")},2500)},[i]);return{safeConfig:r,activeConfig:n,suggestions:o,setSuggestions:s,dynamicPersona:c,authAvailableLicenses:i,handleProfileSelect:d}}var ta,xx=U(()=>{"use strict";ta=require("react");L2();ot()});function z2(){let{prototypeBrand:t,addLog:e}=X(),r=(0,B2.useTimelineStore)(o=>o.timelines[t]);return{handleExport:async()=>{if(!r){e("No hay un blueprint activo para exportar.","error");return}try{let o={format:"decido-standard-document",version:"1.0",exportedAt:new Date().toISOString(),brand:t,blueprint:r},s=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),i=URL.createObjectURL(s),a=document.createElement("a");a.href=i,a.download=`${t}-demo.dsd`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i),e(`Grafo exportado exitosamente como ${t}-demo.dsd`,"success")}catch(o){e(`Error exportando DSD: ${o}`,"error"),console.error(o)}}}}var B2,$2=U(()=>{"use strict";ot();B2=require("@decido/engine")});function F2(){let t=X(n=>n.isFullscreen),e=X(n=>n.setIsFullscreen),r=(0,Jh.useCallback)(()=>{document.fullscreenElement?document.exitFullscreen&&document.exitFullscreen():document.documentElement.requestFullscreen().catch(n=>console.error(`Fullscreen err: ${n.message}`))},[]);return(0,Jh.useEffect)(()=>{let n=()=>e(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",n),()=>document.removeEventListener("fullscreenchange",n)},[e]),{isFullscreen:t,toggleFullscreen:r}}var Jh,H2=U(()=>{"use strict";Jh=require("react");ot()});var j2={};Mo(j2,{CenterComposite:()=>X$});function X$({aiProvider:t,VoiceWidget:e,config:r}){let n=X(),{step:o,selectedProfile:s,prototypeBrand:i,setPrototypeBrand:a,isMuted:l,setIsMuted:c,selectedVoice:d,setSelectedVoice:u,isVoiceActive:f,setIsVoiceActive:p,isTerminalOpen:h,setIsTerminalOpen:b,isCreatorMode:g,setIsCreatorMode:x,inputValue:y,setInputValue:m,logs:v,setLogs:S}=n,w=(0,Zh.useRef)(null);(0,Zh.useEffect)(()=>{w.current&&w.current.scrollIntoView({behavior:"smooth"})},[v]);let C=(0,V2.useTimelineStore)(se=>se.timelines),{handleGeneratePlayground:A,isGenerating:k}=E2(t),{demoState:M,showCanvas:T,setShowCanvas:E}=Ed(),{currentTime:P,isPlaying:N,setIsPlaying:D,playbackSpeed:R,setPlaybackSpeed:O,seekTime:B,resetSimulation:L}=O2(i),{safeConfig:H,activeConfig:j,suggestions:$,setSuggestions:q,dynamicPersona:F,authAvailableLicenses:_,handleProfileSelect:W}=Xh(r,i),{handleExport:V}=z2(),{isFullscreen:z,toggleFullscreen:G}=F2(),{isRecording:Y}=M2(),Z=Ut(se=>se.isOpen);return(0,Dn.jsx)("div",{className:"flex flex-col h-full relative min-w-0 min-h-0",children:(0,Dn.jsxs)(Gl.Group,{orientation:"vertical",className:"flex-1 min-h-0 min-w-0",children:[(0,Dn.jsxs)(Gl.Panel,{id:"chat-area",defaultSize:Z?65:100,className:"flex flex-col relative min-h-0 min-w-0",children:[(0,Dn.jsx)("div",{className:`flex-1 z-10 flex flex-col relative min-h-0 min-w-0 ${g?"overflow-y-auto p-4 md:p-6 pb-48 justify-end":"overflow-hidden"}`,children:(0,Dn.jsx)(Ba,{fallbackName:"Motor de Chat",children:(0,Dn.jsx)(Gu,{step:o,selectedProfile:s,authAvailableLicenses:_,handleProfileSelect:W,activeConfig:j,demoState:M,suggestions:$,setInputValue:m,isGenerating:k,config:H,isCreatorMode:g,handleGeneratePlayground:A,isVoiceActive:f,setIsVoiceActive:p,VoiceWidget:e,dynamicPersona:F,setSuggestions:q,selectedVoice:d,showCanvas:T,setShowCanvas:E})})}),g&&(0,Dn.jsx)(Ba,{fallbackName:"Terminal de Logs",children:(0,Dn.jsx)(ax,{isOpen:h,setIsOpen:b,logs:v,setLogs:S,logsEndRef:w})}),(0,Dn.jsx)(vk,{step:o,isVoiceActive:f,setIsVoiceActive:p,currentTime:P,seekTime:B,playbackSpeed:R,setPlaybackSpeed:O,dynamicTimelines:C,prototypeBrand:i,setPrototypeBrand:a,inputValue:y,setInputValue:m,isGenerating:k,handleGeneratePlayground:A,isPlaying:N,setIsPlaying:D,handleResetPlayground:L,showCanvas:T,setShowCanvas:E,isTerminalOpen:h,setIsTerminalOpen:b,isMuted:l,setIsMuted:c,selectedVoice:d,setSelectedVoice:u,isFullscreen:z,toggleFullscreen:G,demoState:M,isRecording:Y,handleExport:V,dynamicPersona:F,setSuggestions:q,isCreatorMode:g,setIsCreatorMode:x,VoiceWidget:e,config:H})]}),Z&&(0,Dn.jsxs)(Dn.Fragment,{children:[(0,Dn.jsx)(Gl.Separator,{className:"h-2 hover:bg-cyan-500/20 active:bg-cyan-500/30 transition-colors cursor-row-resize z-40 relative group flex items-center justify-center",children:(0,Dn.jsx)("div",{className:"h-[2px] w-12 bg-surface-glass rounded-full group-hover:bg-cyan-500 transition-colors"})}),(0,Dn.jsx)(Gl.Panel,{id:"debug-panel",defaultSize:35,minSize:15,children:(0,Dn.jsx)(Qu,{})})]})]})})}var Zh,Gl,V2,Dn,W2=U(()=>{"use strict";Zh=require("react"),Gl=require("react-resizable-panels");Mh();lx();wk();ux();Gh();ot();Us();V2=require("@decido/engine");T2();qh();P2();_2();xx();$2();H2();Dn=require("react/jsx-runtime")});function U2(t){let{renderingType:e,activeStage:r,activeArtifactData:n,activeConfig:o,activeState:s,prototypeBrand:i,chartData:a,dragConstraintsRef:l,defaultViewMode:c,instanceId:d}=t,u=Pa(e);if(u)return(0,at.jsx)(u,{instanceId:d||r?.sourceNodeId||"default",data:r?.data||{},artifacts:[],activeArtifactIndex:0});if(e==="workbench"){let f=vd("AdminWorkbench")||vd("Workbench");return f?(0,at.jsx)(f,{...r?.data||{}}):(0,at.jsx)("div",{className:"w-full h-full flex items-center justify-center text-text-muted font-mono text-sm",children:(0,at.jsxs)("div",{className:"text-center",children:[(0,at.jsx)(yx.Code2,{size:48,className:"mx-auto mb-4 text-text-muted"}),(0,at.jsx)("p",{children:"AdminWorkbench no registrado"}),(0,at.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Usa registerShell('shell-vscode', Component)"})]})})}if(e==="liquid"){let f=vd("SafeLiquidUI");return f&&r?.data?(0,at.jsx)("div",{className:"w-full h-full p-6 overflow-auto",children:(0,at.jsx)(f,{uiSchema:r.data.code||r.data,tenantId:"system"})}):(0,at.jsx)("div",{className:"w-full h-full p-6 overflow-auto",children:(0,at.jsx)("pre",{className:"text-xs text-text-secondary font-mono bg-surface-glass rounded-xl p-4 border border-border-subtle",children:JSON.stringify(r?.data||{},null,2)})})}if(e==="custom"&&r?.componentId){let f=vd(r.componentId);return f?(0,at.jsx)(f,{...r?.data||{}}):(0,at.jsxs)("div",{className:"w-full h-full flex items-center justify-center text-text-muted font-mono text-sm",children:["Componente '",r.componentId,"' no registrado"]})}if(e==="artifact"&&(n||r?.data)){let f=r?.data||n;return f.artifact==="graph-visualizer"?(0,at.jsx)("div",{className:"flex-1 flex items-center justify-center p-6 text-text-muted font-mono",children:"Graph Visualizer temporalmente deshabilitado por conflictos CSS."}):f.artifact==="data-table"?(0,at.jsx)("div",{className:"flex-1 w-full h-full p-6 py-2",children:(0,at.jsx)(Z$,{columns:f.columns,rows:f.rows})}):f.artifact==="markdown"?(0,at.jsx)("div",{className:"flex-1 w-full h-full p-6 py-2",children:(0,at.jsx)(Q$,{content:f.content})}):(0,at.jsxs)("div",{className:"flex-1 flex items-center justify-center p-6 text-text-muted font-mono",children:["Componente ",f.artifact," desconocido."]})}return(0,at.jsxs)("div",{ref:l,className:"flex-1 h-full rounded-2xl bg-surface-overlay flex items-center justify-center relative overflow-hidden group border border-border-subtle m-6 mt-2",children:[(0,at.jsx)("svg",{className:"absolute inset-0 pointer-events-none z-0 w-full h-full opacity-30",children:(0,at.jsx)("path",{d:"M 150 75 C 250 150, 350 50, 400 100",stroke:"cyan",strokeWidth:2,fill:"none",strokeDasharray:"10, 10"})}),o?.widgets?.map(f=>{let p=f.icon;return(0,at.jsxs)("div",{className:`absolute cursor-grab rounded-2xl border ${f.bg} ${f.border} p-4 shadow-xl backdrop-blur-md flex flex-col justify-between`,style:{width:f.w,height:f.h,left:f.x,top:f.y},children:[(0,at.jsxs)("div",{className:"flex justify-between items-start pointer-events-none z-10",children:[(0,at.jsx)("span",{className:"text-sm font-semibold text-text-primary/80",children:f.title}),(0,at.jsx)("div",{className:`p-1.5 rounded-lg bg-surface-glass ${f.color}`,children:(0,at.jsx)(p,{size:16})})]}),(0,at.jsx)("div",{className:`text-2xl font-bold mt-2 ${f.color} pointer-events-none z-10`,children:f.value}),f.chart&&(0,at.jsx)("div",{className:"absolute bottom-0 left-0 w-full h-16 opacity-30 pointer-events-none rounded-b-2xl overflow-hidden",children:(0,at.jsx)(Qh.Suspense,{fallback:null,children:(0,at.jsx)(J$,{chartData:a,color:f.color})})})]},`${i}-${f.id}`)})]})}var Qh,yx,at,J$,Z$,Q$,G2=U(()=>{"use strict";Qh=Re(require("react")),yx=require("lucide-react");Vl();ys();at=require("react/jsx-runtime"),J$=Qh.default.lazy(()=>import("recharts").then(t=>({default:({chartData:e,color:r})=>(0,at.jsx)(t.ResponsiveContainer,{width:"100%",height:"100%",children:(0,at.jsx)(t.AreaChart,{data:e,children:(0,at.jsx)(t.Area,{type:"monotone",dataKey:"val",stroke:"currentColor",fill:"currentColor",strokeWidth:2,className:r})})})}))),Z$=({columns:t,rows:e})=>(0,at.jsx)("div",{className:"w-full h-full overflow-auto bg-surface-primary border border-border-default rounded-2xl shadow-xl p-4 custom-scrollbar",children:(0,at.jsxs)("table",{className:"w-full text-left text-sm text-text-primary",children:[(0,at.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-surface-glass",children:(0,at.jsx)("tr",{children:t?.map((r,n)=>(0,at.jsx)("th",{className:"px-6 py-3",children:r},n))})}),(0,at.jsx)("tbody",{children:e?.map((r,n)=>(0,at.jsx)("tr",{className:"border-b border-border-subtle hover:bg-surface-glass transition-colors",children:r?.map((o,s)=>(0,at.jsx)("td",{className:"px-6 py-4",children:o},s))},n))})]})}),Q$=({content:t})=>(0,at.jsx)("div",{className:"w-full h-full overflow-auto bg-surface-primary border border-border-default rounded-2xl shadow-xl p-8 whitespace-pre-wrap text-text-primary font-sans leading-relaxed text-sm custom-scrollbar",children:t})});var em,Td,vs,lr,K2,tm,vx=U(()=>{"use strict";em=Re(require("react")),Td=require("motion/react"),vs=require("lucide-react");ot();ys();G2();lr=require("react/jsx-runtime"),K2={workbench:{icon:vs.Code2,label:"Workbench",color:"text-purple-400"},liquid:{icon:vs.Droplets,label:"UI Din\xE1mica",color:"text-amber-400"},artifact:{icon:vs.MonitorPlay,label:"Artefacto",color:"text-emerald-400"},custom:{icon:vs.Layers,label:"Custom",color:"text-violet-400"}},tm=em.default.memo(function({showCanvas:e,setShowCanvas:r,activeConfig:n,prototypeBrand:o,activeState:s,chartData:i,dragConstraintsRef:a}){if(!e)return null;let l=_t(S=>S.activeStage),c=_t(S=>S.stageHistory),d=_t(S=>S.popStage),u=_t(S=>S.clearStages),f=X(S=>S.activeArtifactData),[p,h]=em.default.useState("3d"),b=l||(f?{type:"artifact",data:f}:null),g=b?.type||p,x=K2[g]||K2.custom,y=x.icon,m=()=>{u(),X.getState().setActiveArtifactData(null),r(!1)},v=()=>{c.length>0?d():u()};return(0,lr.jsx)(Td.AnimatePresence,{children:(0,lr.jsxs)(Td.motion.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"w-full h-full bg-surface-secondary flex flex-col overflow-hidden relative border-l border-border-subtle",children:[(0,lr.jsxs)("div",{className:"flex justify-between items-center pl-2 z-10 p-4 pb-0 shrink-0",children:[(0,lr.jsxs)("div",{className:"flex items-center gap-2",children:[(l||f)&&(0,lr.jsx)("button",{onClick:v,className:"p-1.5 rounded-lg hover:bg-surface-glass text-text-muted hover:text-text-primary transition-colors",title:"Volver",children:(0,lr.jsx)(vs.ArrowLeft,{size:16})}),(0,lr.jsxs)("h2",{className:"text-lg font-bold flex items-center gap-2 text-text-primary",children:[(0,lr.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center bg-surface-glass",children:(0,lr.jsx)(y,{size:14,className:x.color})}),(0,lr.jsx)("span",{className:"truncate max-w-[200px]",children:l?.label||(f?"Artefacto":"Lienzo de Trabajo")}),(0,lr.jsx)("span",{className:"text-text-muted font-mono text-[10px] ml-1",children:g.toUpperCase()})]})]}),(0,lr.jsxs)("div",{className:"flex items-center gap-3",children:[c.length>0&&(0,lr.jsxs)("div",{className:"hidden md:flex items-center gap-1 text-[10px] text-text-muted font-mono",children:[c.map((S,w)=>(0,lr.jsxs)(em.default.Fragment,{children:[(0,lr.jsx)("span",{className:"hover:text-text-secondary cursor-pointer",onClick:()=>{let C=_t.getState();for(let A=0;A<c.length-w;A++)C.popStage()},children:S.label||S.type}),(0,lr.jsx)("span",{children:"\u203A"})]},w)),(0,lr.jsx)("span",{className:"text-text-secondary",children:l?.label||g})]}),!b&&(0,lr.jsxs)("div",{className:"flex bg-surface-glass border border-border-default rounded-full p-1",children:[(0,lr.jsx)("button",{onClick:()=>h("2d"),className:`px-3 py-1 text-[10px] font-bold tracking-wider rounded-full transition-all ${p==="2d"?"bg-surface-glass text-text-primary shadow-xs":"text-text-muted hover:text-text-primary"}`,children:"2D DATA"}),(0,lr.jsx)("button",{onClick:()=>h("3d"),className:`px-3 py-1 text-[10px] font-bold tracking-wider rounded-full transition-all ${p==="3d"?"bg-cyan-500/20 text-cyan-400 shadow-[0_0_10px_rgba(6,182,212,0.3)]":"text-text-muted hover:text-text-primary"}`,children:"3D SCENE"})]}),(0,lr.jsx)("button",{onClick:m,className:"p-2 bg-surface-glass hover:bg-red-500/20 text-text-secondary hover:text-red-400 rounded-full transition-colors",children:(0,lr.jsx)(vs.X,{size:16})})]})]}),(0,lr.jsx)("div",{className:"flex-1 relative overflow-hidden",children:(0,lr.jsx)(Td.AnimatePresence,{mode:"wait",children:(0,lr.jsx)(Td.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},className:"w-full h-full",children:(0,lr.jsx)(U2,{renderingType:g,activeStage:l,activeArtifactData:f,activeConfig:n,activeState:s,prototypeBrand:o,chartData:i,dragConstraintsRef:a,defaultViewMode:p})},g+(l?.componentId||""))})})]})})})});function t8(t){return e8[t]||Qo.FileCode}function rm({instanceId:t,className:e=""}){let r=Ue(s=>s.getInstance(t)),n=Ue(s=>s.setActiveArtifact),o=Ue(s=>s.removeArtifact);return!r||r.artifacts.length<=1?null:(0,Ks.jsx)("div",{className:`flex items-center gap-0.5 px-2 py-1 bg-surface-primary border-b border-border-subtle overflow-x-auto scrollbar-hide ${e}`,children:(0,Ks.jsx)(rf.AnimatePresence,{mode:"popLayout",children:r.artifacts.map((s,i)=>{let a=i===r.activeArtifactIndex,l=t8(s.shellType);return(0,Ks.jsxs)(rf.motion.button,{layout:!0,initial:{opacity:0,scale:.9,width:0},animate:{opacity:1,scale:1,width:"auto"},exit:{opacity:0,scale:.9,width:0},onClick:()=>n(t,i),className:`
|
|
122
|
+
flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[10px] font-medium
|
|
123
|
+
transition-colors whitespace-nowrap group relative shrink-0
|
|
124
|
+
${a?"bg-surface-glass text-text-primary border border-border-default":"text-text-muted hover:text-text-primary hover:bg-surface-glass border border-transparent"}
|
|
125
|
+
`,children:[(0,Ks.jsx)(l,{size:10,className:a?"text-cyan-400":"text-text-muted"}),(0,Ks.jsx)("span",{className:"truncate max-w-[100px]",children:s.name}),s.version>1&&(0,Ks.jsxs)("span",{className:"text-[8px] text-text-muted font-mono",children:["v",s.version]}),r.artifacts.length>1&&(0,Ks.jsx)("span",{onClick:c=>{c.stopPropagation(),o(t,s.id)},className:`w-3.5 h-3.5 rounded flex items-center justify-center
|
|
126
|
+
opacity-0 group-hover:opacity-100 hover:bg-surface-glass hover:text-red-400
|
|
127
|
+
transition-all ml-0.5`,children:(0,Ks.jsx)(Qo.X,{size:8})}),a&&(0,Ks.jsx)(rf.motion.div,{layoutId:"artifact-indicator",className:"absolute bottom-0 left-1 right-1 h-[1.5px] bg-cyan-500/50 rounded-full"})]},s.id)})})})}var rf,Qo,Ks,e8,wx=U(()=>{"use strict";rf=require("motion/react"),Qo=require("lucide-react");mo();Ks=require("react/jsx-runtime"),e8={markdown:Qo.FileText,iframe:Qo.Globe,"shell-vscode":Qo.FileCode,"shell-canvas":Qo.Layers,"shell-omnichannel":Qo.MessageSquare}});var ws,Sx,q2=U(()=>{"use strict";ws=require("lucide-react"),Sx={"3d":{icon:ws.Box,color:"text-cyan-400"},"2d":{icon:ws.LayoutDashboard,color:"text-emerald-400"},workbench:{icon:ws.CodeXml,color:"text-purple-400"},liquid:{icon:ws.Droplets,color:"text-blue-400"},custom:{icon:ws.Puzzle,color:"text-orange-400"},artifact:{icon:ws.FileBox,color:"text-yellow-400"}}});function n8({iframeRef:t,isOpen:e,onClose:r}){let[n,o]=(0,jr.useState)(null),[s,i]=(0,jr.useState)(!0),[a,l]=(0,jr.useState)(""),[c,d]=(0,jr.useState)("layout"),[u,f]=(0,jr.useState)("");(0,jr.useEffect)(()=>{if(!e)return;let m=v=>{v.data?.type==="tw-bridge:select"&&o({selector:v.data.selector,tagName:v.data.tagName,classes:v.data.classes||[],originalClasses:v.data.originalClasses||v.data.classes||[],rect:v.data.rect||{width:0,height:0}})};return window.addEventListener("message",m),()=>window.removeEventListener("message",m)},[e]),(0,jr.useEffect)(()=>{e&&t.current?.contentWindow?.postMessage({type:"tw-bridge:toggle",enabled:s},"*")},[s,e,t]),(0,jr.useEffect)(()=>{e?(i(!0),t.current?.contentWindow?.postMessage({type:"tw-bridge:toggle",enabled:!0},"*")):t.current?.contentWindow?.postMessage({type:"tw-bridge:toggle",enabled:!1},"*")},[e,t]);let p=(0,jr.useCallback)(m=>{n&&(o(v=>v?{...v,classes:m}:null),t.current?.contentWindow?.postMessage({type:"tw-bridge:apply",selector:n.selector,classes:m},"*"))},[n,t]),h=(0,jr.useCallback)(m=>{n&&p(n.classes.filter(v=>v!==m))},[n,p]),b=(0,jr.useCallback)(m=>{if(!n)return;let v=m.trim();!v||n.classes.includes(v)||(p([...n.classes,v]),l(""))},[n,p]),g=(0,jr.useCallback)(()=>{n&&p([...n.originalClasses])},[n,p]),x=(0,jr.useCallback)(()=>{n&&navigator.clipboard.writeText(n.classes.join(" "))},[n]),y=n&&JSON.stringify(n.classes)!==JSON.stringify(n.originalClasses);return e?(0,Me.jsxs)("div",{className:"w-[280px] shrink-0 flex flex-col bg-surface-primary border-l border-border-subtle h-full text-text-primary",children:[(0,Me.jsxs)("div",{className:"px-3 py-2 border-b border-border-subtle shrink-0",children:[(0,Me.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,Me.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,Me.jsx)(Wr.Paintbrush,{size:12,className:"text-accent-purple"}),(0,Me.jsx)("span",{className:"text-[11px] font-bold",children:"TW Editor"}),(0,Me.jsx)("span",{className:"text-[7px] px-1 py-0.5 rounded-full bg-accent-purple/15 text-accent-purple font-mono font-bold",children:"LIVE"})]}),(0,Me.jsx)("button",{onClick:r,className:"text-text-muted hover:text-text-primary transition-colors",children:(0,Me.jsx)(Wr.X,{size:12})})]}),(0,Me.jsxs)("button",{onClick:()=>i(!s),className:`w-full flex items-center gap-1.5 px-2 py-1 rounded text-[10px] font-medium transition-all cursor-pointer ${s?"bg-accent-purple/15 text-accent-purple border border-accent-purple/30":"bg-surface-glass text-text-muted border border-border-subtle"}`,children:[(0,Me.jsx)(Wr.MousePointer,{size:10}),s?"Click un elemento":"Inspector off",(0,Me.jsx)("span",{className:`ml-auto w-1.5 h-1.5 rounded-full ${s?"bg-accent-green animate-pulse":"bg-text-muted/30"}`})]})]}),n?(0,Me.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,Me.jsx)("div",{className:"px-3 py-1.5 border-b border-border-subtle/50 shrink-0",children:(0,Me.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,Me.jsxs)("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-surface-glass text-text-muted",children:["<",n.tagName.toLowerCase(),">"]}),(0,Me.jsxs)("span",{className:"text-[8px] font-mono text-text-muted/40 ml-auto",children:[Math.round(n.rect.width),"\xD7",Math.round(n.rect.height)]})]})}),(0,Me.jsxs)("div",{className:"px-3 py-1.5 border-b border-border-subtle/50 shrink-0",children:[(0,Me.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,Me.jsxs)("span",{className:"text-[8px] font-mono text-text-muted/60 uppercase tracking-wider",children:["Clases (",n.classes.length,")"]}),(0,Me.jsxs)("div",{className:"flex gap-1",children:[y&&(0,Me.jsxs)("button",{onClick:g,className:"text-[7px] text-accent-amber flex items-center gap-0.5 cursor-pointer",children:[(0,Me.jsx)(Wr.RotateCcw,{size:7})," Undo"]}),(0,Me.jsxs)("button",{onClick:x,className:"text-[7px] text-text-muted/40 hover:text-accent-cyan flex items-center gap-0.5 cursor-pointer",children:[(0,Me.jsx)(Wr.Copy,{size:7})," Copy"]})]})]}),(0,Me.jsx)("div",{className:"flex flex-wrap gap-0.5 max-h-[100px] overflow-y-auto custom-scrollbar",children:n.classes.map(m=>{let v=!n.originalClasses.includes(m);return(0,Me.jsxs)("span",{className:`group inline-flex items-center gap-0.5 px-1 py-0.5 rounded text-[8px] font-mono transition-all ${v?"bg-accent-green/15 text-accent-green border border-accent-green/30":"bg-surface-glass text-text-secondary border border-border-subtle"}`,children:[m,(0,Me.jsx)("button",{onClick:()=>h(m),className:"opacity-0 group-hover:opacity-100 text-red-400 cursor-pointer",children:(0,Me.jsx)(Wr.X,{size:7})})]},m)})}),y&&(0,Me.jsx)("div",{className:"mt-1 flex flex-wrap gap-0.5",children:n.originalClasses.filter(m=>!n.classes.includes(m)).map(m=>(0,Me.jsx)("button",{onClick:()=>b(m),className:"px-1 py-0.5 rounded text-[8px] font-mono bg-red-500/10 text-red-400/60 border border-red-500/20 line-through hover:no-underline cursor-pointer",children:m},`rm-${m}`))})]}),(0,Me.jsxs)("div",{className:"px-3 py-1.5 border-b border-border-subtle/50 shrink-0 flex gap-1",children:[(0,Me.jsxs)("div",{className:"flex-1 relative",children:[(0,Me.jsx)(Wr.Plus,{size:9,className:"absolute left-1.5 top-1/2 -translate-y-1/2 text-text-muted/40"}),(0,Me.jsx)("input",{type:"text",value:a,onChange:m=>l(m.target.value),onKeyDown:m=>{m.key==="Enter"&&a.trim()&&b(a)},placeholder:"Agregar clase...",className:"w-full pl-5 pr-1 py-1 text-[10px] font-mono bg-surface-glass border border-border-subtle rounded text-text-primary placeholder:text-text-muted/30 focus:outline-none focus:border-accent-purple/40"})]}),(0,Me.jsx)("button",{onClick:()=>b(a),disabled:!a.trim(),className:"px-2 py-1 rounded bg-accent-purple/15 text-accent-purple text-[9px] font-bold disabled:opacity-30 cursor-pointer",children:"+"})]}),(0,Me.jsxs)("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:[(0,Me.jsx)("div",{className:"px-3 py-1 border-b border-border-subtle/30 sticky top-0 bg-surface-primary z-10",children:(0,Me.jsxs)("div",{className:"relative",children:[(0,Me.jsx)(Wr.Search,{size:9,className:"absolute left-1.5 top-1/2 -translate-y-1/2 text-text-muted/30"}),(0,Me.jsx)("input",{type:"text",value:u,onChange:m=>f(m.target.value),placeholder:"Filtrar...",className:"w-full pl-5 pr-1 py-0.5 text-[9px] font-mono bg-surface-glass border border-border-subtle/50 rounded text-text-primary placeholder:text-text-muted/20 focus:outline-none"})]})}),r8.map(m=>{let v=u?m.classes.filter(w=>w.includes(u.toLowerCase())):m.classes;if(v.length===0)return null;let S=c===m.id;return(0,Me.jsxs)("div",{className:"border-b border-border-subtle/20",children:[(0,Me.jsxs)("button",{onClick:()=>d(S?null:m.id),className:"w-full flex items-center gap-1.5 px-3 py-1 hover:bg-surface-glass text-left cursor-pointer",children:[S?(0,Me.jsx)(Wr.ChevronDown,{size:8}):(0,Me.jsx)(Wr.ChevronRight,{size:8}),(0,Me.jsx)("span",{className:"text-[9px] font-semibold text-text-primary flex-1",children:m.label}),(0,Me.jsx)("span",{className:"text-[7px] font-mono text-text-muted/40",children:v.length})]}),S&&(0,Me.jsx)("div",{className:"px-3 pb-1.5 flex flex-wrap gap-0.5",children:v.map(w=>{let C=n.classes.includes(w);return(0,Me.jsxs)("button",{onClick:()=>C?h(w):b(w),className:`px-1 py-0.5 rounded text-[8px] font-mono cursor-pointer transition-all ${C?"bg-accent-green/15 text-accent-green border border-accent-green/30":"bg-surface-glass text-text-muted border border-border-subtle/50 hover:border-accent-purple/30"}`,children:[C?"\u2713 ":"",w]},w)})})]},m.id)})]}),y&&(0,Me.jsxs)("div",{className:"px-3 py-1.5 border-t border-border-subtle bg-surface-secondary/50 shrink-0",children:[(0,Me.jsxs)("div",{className:"flex items-center justify-between mb-0.5",children:[(0,Me.jsx)("span",{className:"text-[7px] font-mono text-accent-green/60 uppercase",children:"className"}),(0,Me.jsxs)("button",{onClick:x,className:"text-[7px] text-text-muted/40 hover:text-accent-cyan flex items-center gap-0.5 cursor-pointer",children:[(0,Me.jsx)(Wr.Copy,{size:7})," Copy"]})]}),(0,Me.jsx)("div",{className:"text-[8px] font-mono text-text-secondary bg-surface-primary p-1.5 rounded border border-border-subtle max-h-[48px] overflow-y-auto break-all",children:n.classes.join(" ")})]})]}):(0,Me.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center p-4 text-center",children:[(0,Me.jsx)(Wr.MousePointer,{size:20,className:"text-accent-purple/30 mb-2"}),(0,Me.jsx)("p",{className:"text-[10px] text-text-muted",children:"Click un elemento del preview"}),(0,Me.jsx)("p",{className:"text-[8px] text-text-muted/40 mt-0.5",children:"para editar sus clases Tailwind"})]})]}):null}var jr,Wr,Me,Y2,Nx,r8,X2,J2=U(()=>{"use strict";jr=require("react"),Wr=require("lucide-react"),Me=require("react/jsx-runtime"),Y2=({data:t})=>{let e=t?.content||t?.markdown||"";return(0,Me.jsx)("div",{className:"w-full h-full overflow-auto bg-surface-primary p-8 custom-scrollbar",children:(0,Me.jsx)("div",{className:"max-w-3xl mx-auto prose prose-invert prose-sm prose-zinc",children:(0,Me.jsx)("div",{className:"whitespace-pre-wrap text-text-primary font-sans leading-relaxed text-sm",children:e})})})},Nx=`
|
|
128
|
+
<script>
|
|
129
|
+
(function() {
|
|
130
|
+
var inspectorActive = false;
|
|
131
|
+
var selectedEl = null;
|
|
132
|
+
var hoveredEl = null;
|
|
133
|
+
|
|
134
|
+
function generateSelector(el) {
|
|
135
|
+
var parts = [];
|
|
136
|
+
var cur = el;
|
|
137
|
+
while (cur && cur !== document.body && cur !== document.documentElement) {
|
|
138
|
+
var part = cur.tagName.toLowerCase();
|
|
139
|
+
if (cur.id) { parts.unshift('#' + cur.id); break; }
|
|
140
|
+
var parent = cur.parentElement;
|
|
141
|
+
if (parent) {
|
|
142
|
+
var sibs = Array.from(parent.children).filter(function(c) { return c.tagName === cur.tagName; });
|
|
143
|
+
if (sibs.length > 1) {
|
|
144
|
+
part += ':nth-of-type(' + (sibs.indexOf(cur) + 1) + ')';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
parts.unshift(part);
|
|
148
|
+
cur = cur.parentElement;
|
|
149
|
+
}
|
|
150
|
+
return parts.join(' > ');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
window.addEventListener('message', function(e) {
|
|
154
|
+
if (e.data && e.data.type === 'tw-bridge:toggle') {
|
|
155
|
+
inspectorActive = !!e.data.enabled;
|
|
156
|
+
document.body.style.cursor = inspectorActive ? 'crosshair' : '';
|
|
157
|
+
if (!inspectorActive) {
|
|
158
|
+
if (hoveredEl) { hoveredEl.style.outline = ''; hoveredEl.style.outlineOffset = ''; hoveredEl = null; }
|
|
159
|
+
if (selectedEl) { selectedEl.style.outline = ''; selectedEl.style.outlineOffset = ''; selectedEl = null; }
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (e.data && e.data.type === 'tw-bridge:apply') {
|
|
163
|
+
var el = document.querySelector(e.data.selector);
|
|
164
|
+
if (el) el.className = e.data.classes.join(' ');
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
document.addEventListener('mouseover', function(e) {
|
|
169
|
+
if (!inspectorActive) return;
|
|
170
|
+
var t = e.target;
|
|
171
|
+
if (hoveredEl && hoveredEl !== selectedEl) {
|
|
172
|
+
hoveredEl.style.outline = '';
|
|
173
|
+
hoveredEl.style.outlineOffset = '';
|
|
174
|
+
}
|
|
175
|
+
t.style.outline = '2px dashed rgba(139, 92, 246, 0.6)';
|
|
176
|
+
t.style.outlineOffset = '2px';
|
|
177
|
+
hoveredEl = t;
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
document.addEventListener('mouseout', function(e) {
|
|
181
|
+
if (!inspectorActive) return;
|
|
182
|
+
if (e.target !== selectedEl) {
|
|
183
|
+
e.target.style.outline = '';
|
|
184
|
+
e.target.style.outlineOffset = '';
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
document.addEventListener('click', function(e) {
|
|
189
|
+
if (!inspectorActive) return;
|
|
190
|
+
e.preventDefault();
|
|
191
|
+
e.stopPropagation();
|
|
192
|
+
var t = e.target;
|
|
193
|
+
if (selectedEl) { selectedEl.style.outline = ''; selectedEl.style.outlineOffset = ''; }
|
|
194
|
+
t.style.outline = '2px solid rgba(139, 92, 246, 0.9)';
|
|
195
|
+
t.style.outlineOffset = '2px';
|
|
196
|
+
selectedEl = t;
|
|
197
|
+
var classes = t.className ? t.className.split(/\\s+/).filter(Boolean) : [];
|
|
198
|
+
var rect = t.getBoundingClientRect();
|
|
199
|
+
window.parent.postMessage({
|
|
200
|
+
type: 'tw-bridge:select',
|
|
201
|
+
selector: generateSelector(t),
|
|
202
|
+
tagName: t.tagName,
|
|
203
|
+
classes: classes,
|
|
204
|
+
originalClasses: classes,
|
|
205
|
+
rect: { width: rect.width, height: rect.height }
|
|
206
|
+
}, '*');
|
|
207
|
+
}, true);
|
|
208
|
+
})();
|
|
209
|
+
</script>`,r8=[{id:"layout",label:"Layout",classes:["flex","inline-flex","grid","block","hidden","flex-row","flex-col","items-center","items-start","items-end","justify-center","justify-between","justify-start","justify-end","relative","absolute","fixed","overflow-hidden","overflow-auto"]},{id:"spacing",label:"Spacing",classes:["p-0","p-1","p-2","p-3","p-4","p-6","p-8","px-2","px-4","px-6","py-1","py-2","py-3","py-4","m-0","m-1","m-2","m-4","mx-auto","my-2","my-4","gap-1","gap-2","gap-3","gap-4","gap-6"]},{id:"sizing",label:"Sizing",classes:["w-full","w-auto","w-1/2","w-1/3","h-full","h-auto","h-screen","min-w-0","max-w-sm","max-w-md","max-w-lg"]},{id:"typography",label:"Type",classes:["text-xs","text-sm","text-base","text-lg","text-xl","text-2xl","font-light","font-normal","font-medium","font-semibold","font-bold","text-left","text-center","text-right","truncate"]},{id:"colors",label:"Colors",classes:["text-white","text-black","text-gray-500","bg-white","bg-black","bg-transparent","bg-gray-100","bg-gray-800","bg-gray-900","bg-blue-500","bg-green-500","bg-red-500","bg-purple-500","bg-cyan-500"]},{id:"borders",label:"Borders",classes:["border","border-0","border-2","rounded-none","rounded-sm","rounded","rounded-md","rounded-lg","rounded-xl","rounded-2xl","rounded-full"]},{id:"effects",label:"Effects",classes:["shadow-sm","shadow","shadow-md","shadow-lg","shadow-xl","opacity-0","opacity-50","opacity-100","transition-all","transition-colors","cursor-pointer"]}];X2=({data:t,instanceId:e})=>{let r=(0,jr.useRef)(null),n=t?.content||t?.html||"",o=t?.url||"",[s,i]=(0,jr.useState)(!1),a=(0,jr.useMemo)(()=>{if(o)return o;if(!n)return"about:blank";let l='<script src="https://cdn.tailwindcss.com"></script>',c=n;c.includes("</body>")?c=c.replace("</body>",`${l}${Nx}</body>`):c.includes("</html>")?c=c.replace("</html>",`${l}${Nx}</html>`):c+=`${l}${Nx}`;let d=new Blob([c],{type:"text/html"});return URL.createObjectURL(d)},[n,o]);return(0,jr.useEffect)(()=>()=>{!o&&a!=="about:blank"&&URL.revokeObjectURL(a)},[a,o]),(0,Me.jsxs)("div",{className:"w-full h-full bg-surface-secondary rounded-lg overflow-hidden flex",children:[(0,Me.jsxs)("div",{className:"flex-1 relative",children:[(0,Me.jsx)("iframe",{ref:r,src:a,title:`sandbox-${e}`,sandbox:"allow-scripts allow-same-origin allow-forms",className:"w-full h-full border-none"}),(0,Me.jsxs)("button",{onClick:()=>i(!s),className:`absolute top-2 right-2 z-10 flex items-center gap-1 px-2 py-1 rounded-lg text-[10px] font-semibold transition-all shadow-lg cursor-pointer ${s?"bg-accent-purple text-white":"bg-black/60 text-white/80 hover:bg-accent-purple/80 hover:text-white backdrop-blur-sm"}`,title:"Tailwind Editor",children:[(0,Me.jsx)(Wr.Paintbrush,{size:11})," TW"]})]}),(0,Me.jsx)(n8,{iframeRef:r,isOpen:s,onClose:()=>i(!1)})]})}});function s8({tokenKey:t,label:e}){let{getCurrentPreset:r,setToken:n}=mi(),s=r().tokens[t];return(0,le.jsxs)("div",{className:"flex items-center gap-2 py-1.5 px-2 rounded-lg bg-surface-glass hover:bg-surface-elevated/50 transition-colors group",children:[(0,le.jsxs)("div",{className:"relative w-6 h-6 shrink-0",children:[(0,le.jsx)("div",{className:"w-6 h-6 rounded-md border border-border-default",style:{background:s}}),(0,le.jsx)("input",{type:"color",value:s.startsWith("#")?s:"#888888",onChange:i=>n(t,i.target.value),className:"absolute inset-0 opacity-0 w-full h-full cursor-pointer"})]}),(0,le.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,le.jsx)("div",{className:"text-[11px] font-semibold text-text-primary truncate",children:e}),(0,le.jsxs)("div",{className:"text-[9px] text-text-muted font-mono",children:["--ds-",t]})]}),(0,le.jsx)("span",{className:"text-[10px] text-text-muted font-mono opacity-0 group-hover:opacity-100 transition-opacity",children:s.slice(0,9)})]})}function i8({preset:t,isActive:e,onSelect:r}){return(0,le.jsxs)("button",{onClick:r,className:`flex flex-col items-center gap-2 p-3 rounded-xl border transition-all duration-200 cursor-pointer ${e?"border-accent-purple bg-accent-purple/10 shadow-glow-sm":"border-border-subtle bg-surface-glass hover:border-border-default hover:bg-surface-elevated/30"}`,children:[(0,le.jsx)("div",{className:"flex gap-1",children:[t.preview.bg,t.preview.accent,t.preview.text].map((n,o)=>(0,le.jsx)("div",{className:"w-3 h-3 rounded-full border border-border-subtle",style:{background:n}},o))}),(0,le.jsx)("span",{className:"text-[10px] font-medium text-text-secondary",children:t.name})]})}function a8(){return(0,le.jsxs)("div",{className:"flex flex-col gap-4 p-3",children:[(0,le.jsx)(ja,{title:"Buttons",children:(0,le.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,le.jsx)("button",{className:"px-4 py-2 bg-accent-purple text-text-inverse rounded-lg text-xs font-semibold hover:opacity-90 transition-opacity",children:"Primary"}),(0,le.jsx)("button",{className:"px-4 py-2 bg-surface-glass border border-border-default text-text-primary rounded-lg text-xs font-semibold hover:bg-surface-elevated transition-colors",children:"Secondary"}),(0,le.jsx)("button",{className:"px-4 py-2 bg-accent-red/10 text-accent-red border border-accent-red/20 rounded-lg text-xs font-semibold hover:bg-accent-red/20 transition-colors",children:"Destructive"}),(0,le.jsx)("button",{className:"px-3 py-1.5 text-text-secondary text-xs hover:text-text-primary transition-colors",children:"Ghost"})]})}),(0,le.jsxs)(ja,{title:"Cards",children:[(0,le.jsxs)("div",{className:"surface-card p-4",children:[(0,le.jsx)("div",{className:"text-sm font-semibold text-text-primary mb-1",children:"Glass Card"}),(0,le.jsx)("div",{className:"text-xs text-text-secondary",children:"Surface secondary con border subtle y hover."})]}),(0,le.jsxs)("div",{className:"glass-panel rounded-xl p-4 mt-2",children:[(0,le.jsx)("div",{className:"text-sm font-semibold text-text-primary mb-1",children:"Glass Panel"}),(0,le.jsx)("div",{className:"text-xs text-text-secondary",children:"Overlay + backdrop blur + border default."})]})]}),(0,le.jsxs)(ja,{title:"Inputs",children:[(0,le.jsx)("input",{type:"text",placeholder:"Escribe algo...",className:"w-full px-3 py-2 bg-surface-primary border border-border-default rounded-lg text-sm text-text-primary placeholder:text-text-muted focus:border-accent-purple focus:ring-1 focus:ring-accent-purple/30 outline-hidden transition-all"}),(0,le.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,le.jsx)("input",{type:"text",value:"Readonly",readOnly:!0,className:"flex-1 px-3 py-2 bg-surface-glass border border-border-subtle rounded-lg text-sm text-text-secondary"}),(0,le.jsxs)("select",{className:"px-3 py-2 bg-surface-primary border border-border-default rounded-lg text-sm text-text-primary outline-hidden",children:[(0,le.jsx)("option",{children:"Opci\xF3n A"}),(0,le.jsx)("option",{children:"Opci\xF3n B"})]})]})]}),(0,le.jsx)(ja,{title:"Badges & Status",children:(0,le.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,le.jsx)("span",{className:"px-2 py-0.5 bg-status-ok/10 text-status-ok border border-status-ok/20 rounded-full text-[10px] font-semibold",children:"Active"}),(0,le.jsx)("span",{className:"px-2 py-0.5 bg-status-warn/10 text-status-warn border border-status-warn/20 rounded-full text-[10px] font-semibold",children:"Pending"}),(0,le.jsx)("span",{className:"px-2 py-0.5 bg-status-error/10 text-status-error border border-status-error/20 rounded-full text-[10px] font-semibold",children:"Error"}),(0,le.jsx)("span",{className:"px-2 py-0.5 bg-status-info/10 text-status-info border border-status-info/20 rounded-full text-[10px] font-semibold",children:"Info"}),(0,le.jsx)("span",{className:"px-2 py-0.5 bg-accent-purple/10 text-accent-purple border border-accent-purple/20 rounded-full text-[10px] font-semibold",children:"Plugin"})]})}),(0,le.jsx)(ja,{title:"Chat Bubbles",children:(0,le.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,le.jsx)("div",{className:"self-end max-w-[80%] px-3 py-2 bg-accent-purple/10 border border-accent-purple/20 rounded-2xl rounded-br-sm",children:(0,le.jsx)("div",{className:"text-xs text-text-primary",children:"Hola, \xBFc\xF3mo puedo ayudarte hoy?"})}),(0,le.jsx)("div",{className:"self-start max-w-[80%] px-3 py-2 bg-surface-glass border border-border-subtle rounded-2xl rounded-bl-sm",children:(0,le.jsx)("div",{className:"text-xs text-text-primary",children:"Muestra el dashboard de ventas"})}),(0,le.jsx)("div",{className:"self-end max-w-[80%] px-3 py-2 bg-accent-blue/10 border border-accent-blue/20 rounded-2xl rounded-br-sm",children:(0,le.jsx)("span",{className:"inline-flex items-center gap-1 text-xs text-accent-blue font-medium",children:"\u25CF Generando dise\xF1o web..."})})]})}),(0,le.jsxs)(ja,{title:"Typography",children:[(0,le.jsx)("h1",{className:"text-xl font-bold text-text-primary",children:"Heading Primary"}),(0,le.jsx)("h2",{className:"text-base font-semibold text-text-secondary",children:"Heading Secondary"}),(0,le.jsx)("p",{className:"text-sm text-text-secondary mt-1",children:"Body text con color secundario para contenido descriptivo."}),(0,le.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Caption text en muted para metadata y timestamps."}),(0,le.jsx)("p",{className:"text-sm text-gradient font-bold mt-2",children:"\u2726 Gradient text premium"})]}),(0,le.jsx)(ja,{title:"Accent Palette",children:(0,le.jsx)("div",{className:"grid grid-cols-6 gap-1",children:["accent-blue","accent-purple","accent-green","accent-red","accent-amber","accent-cyan"].map(t=>(0,le.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,le.jsx)("div",{className:`w-8 h-8 rounded-lg bg-${t}`}),(0,le.jsx)("span",{className:"text-[8px] text-text-muted",children:t.split("-")[1]})]},t))})}),(0,le.jsx)(ja,{title:"Graph Nodes",children:(0,le.jsx)("div",{className:"flex gap-2",children:[{name:"Dialogue",border:"border-accent-purple/30",header:"bg-accent-purple/10"},{name:"Logic",border:"border-accent-amber/30",header:"bg-accent-amber/10"},{name:"State",border:"border-accent-cyan/30",header:"bg-accent-cyan/10"}].map(t=>(0,le.jsxs)("div",{className:`flex-1 bg-surface-tertiary ${t.border} border rounded-lg overflow-hidden`,children:[(0,le.jsx)("div",{className:`${t.header} px-2 py-1 text-[10px] font-semibold text-text-primary`,children:t.name}),(0,le.jsx)("div",{className:"px-2 py-2 text-[9px] text-text-muted",children:"Node content"})]},t.name))})})]})}function ja({title:t,children:e}){return(0,le.jsxs)("div",{children:[(0,le.jsx)("div",{className:"text-[10px] font-bold uppercase tracking-wider text-text-muted mb-2",children:t}),e]})}function Z2(){let[t,e]=(0,nm.useState)("themes"),{currentThemeId:r,setTheme:n,exportCSS:o,getAllPresets:s,getCurrentPreset:i}=mi(),a=(0,nm.useCallback)(()=>{let c=o();navigator.clipboard.writeText(c)},[o]),l=[{id:"themes",icon:"\u{1F3A8}",label:"Temas"},{id:"tokens",icon:"\u{1F527}",label:"Tokens"},{id:"showroom",icon:"\u{1F3DB}\uFE0F",label:"Showroom"}];return(0,le.jsxs)("div",{className:"flex flex-col h-full bg-surface-primary text-text-primary font-sans overflow-hidden",children:[(0,le.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-border-subtle bg-surface-glass",children:[(0,le.jsx)("span",{className:"text-sm",children:"\u{1F3A8}"}),(0,le.jsx)("span",{className:"text-xs font-bold flex-1",children:"Design System"}),(0,le.jsx)("span",{className:"text-[9px] px-1.5 py-0.5 bg-accent-purple/10 text-accent-purple rounded font-mono",children:i().name}),(0,le.jsx)("button",{onClick:a,className:"px-2.5 py-1 border border-border-default rounded-md bg-accent-purple hover:bg-accent-purple/80 text-[10px] text-text-primary font-medium cursor-pointer transition-colors",children:"Export CSS"})]}),(0,le.jsx)("div",{className:"flex border-b border-border-subtle",children:l.map(c=>(0,le.jsxs)("button",{onClick:()=>e(c.id),className:`flex-1 flex items-center justify-center gap-1.5 py-2 text-[10px] font-semibold transition-all cursor-pointer ${t===c.id?"text-accent-purple border-b-2 border-accent-purple bg-accent-purple/5":"text-text-muted hover:text-text-secondary hover:bg-surface-glass"}`,children:[(0,le.jsx)("span",{children:c.icon}),(0,le.jsx)("span",{children:c.label})]},c.id))}),(0,le.jsxs)("div",{className:"flex-1 overflow-auto custom-scrollbar",children:[t==="themes"&&(0,le.jsxs)("div",{className:"p-3 flex flex-col gap-3",children:[(0,le.jsx)("div",{className:"text-[10px] font-bold uppercase tracking-wider text-text-muted",children:"Presets"}),(0,le.jsx)("div",{className:"grid grid-cols-2 gap-2",children:s().map(c=>(0,le.jsx)(i8,{preset:c,isActive:r===c.id,onSelect:()=>n(c.id)},c.id))}),(0,le.jsxs)("div",{className:"mt-2",children:[(0,le.jsx)("div",{className:"text-[10px] font-bold uppercase tracking-wider text-text-muted mb-2",children:"Vista R\xE1pida"}),(0,le.jsxs)("div",{className:"surface-card p-3 flex flex-col gap-2",children:[(0,le.jsxs)("div",{className:"flex items-center gap-2",children:[(0,le.jsx)("div",{className:"w-8 h-8 rounded-full bg-accent-purple flex items-center justify-center text-text-inverse text-[10px] font-bold",children:"Z"}),(0,le.jsxs)("div",{children:[(0,le.jsx)("div",{className:"text-xs font-semibold text-text-primary",children:"Zephyr AI"}),(0,le.jsx)("div",{className:"text-[10px] text-text-muted",children:"Agente activo \u2022 ahora"})]})]}),(0,le.jsx)("div",{className:"px-3 py-2 bg-surface-glass rounded-xl text-xs text-text-secondary",children:"\xBFEn qu\xE9 puedo ayudarte hoy?"}),(0,le.jsxs)("div",{className:"flex gap-1.5",children:[(0,le.jsx)("span",{className:"px-2 py-0.5 bg-status-ok/10 text-status-ok rounded-full text-[9px] font-medium",children:"Online"}),(0,le.jsx)("span",{className:"px-2 py-0.5 bg-accent-blue/10 text-accent-blue rounded-full text-[9px] font-medium",children:"GPT-4"})]})]})]})]}),t==="tokens"&&(0,le.jsx)("div",{className:"p-3 flex flex-col gap-3",children:o8.map(c=>(0,le.jsxs)("div",{children:[(0,le.jsxs)("div",{className:"text-[10px] font-bold uppercase tracking-wider text-text-muted mb-1.5 flex items-center gap-1",children:[(0,le.jsx)("span",{children:c.icon})," ",c.title]}),(0,le.jsx)("div",{className:"flex flex-col gap-1",children:c.tokens.map(d=>(0,le.jsx)(s8,{tokenKey:d.key,label:d.label},d.key))})]},c.title))}),t==="showroom"&&(0,le.jsx)(a8,{})]})]})}var nm,le,o8,Q2=U(()=>{"use strict";nm=require("react");Fu();le=require("react/jsx-runtime"),o8=[{title:"Surfaces",icon:"\u25FB\uFE0F",tokens:[{key:"surface-primary",label:"Primary"},{key:"surface-secondary",label:"Secondary"},{key:"surface-tertiary",label:"Tertiary"},{key:"surface-elevated",label:"Elevated"}]},{title:"Text",icon:"\u270F\uFE0F",tokens:[{key:"text-primary",label:"Primary"},{key:"text-secondary",label:"Secondary"},{key:"text-muted",label:"Muted"}]},{title:"Accents",icon:"\u{1F48E}",tokens:[{key:"accent-blue",label:"Blue"},{key:"accent-purple",label:"Purple"},{key:"accent-green",label:"Green"},{key:"accent-red",label:"Red"},{key:"accent-amber",label:"Amber"},{key:"accent-cyan",label:"Cyan"}]},{title:"Borders",icon:"\u25AC",tokens:[{key:"border-subtle",label:"Subtle"},{key:"border-default",label:"Default"},{key:"border-strong",label:"Strong"},{key:"border-glow",label:"Glow"}]},{title:"Status",icon:"\u25CF",tokens:[{key:"status-ok",label:"Success"},{key:"status-warn",label:"Warning"},{key:"status-error",label:"Error"},{key:"status-info",label:"Info"}]}]});var eE,tE,Wa,rE,nE=U(()=>{"use strict";eE=require("react"),tE=require("lucide-react"),Wa=require("react/jsx-runtime"),rE=({artifacts:t,activeArtifactIndex:e})=>{let r=t?.[e];if((0,eE.useEffect)(()=>{if(!r)return;let o="";typeof r.content=="string"?o=r.content:r.data&&typeof r.data.content=="string"&&(o=r.data.content),o&&(o=o.replace(/```[a-zA-Z-]*\n/gi,"").replace(/```/g,"").trim(),window.dispatchEvent(new CustomEvent("intent:dataway-generate-script",{detail:{script:o}})))},[r]),!r)return null;let n=typeof r.content=="string"?r.content:r.data?.content||"";return n=n.replace(/```[a-zA-Z-]*\n/gi,"").replace(/```/g,"").trim(),(0,Wa.jsxs)("div",{className:"w-full flex tracking-tight flex-col border border-teal-500/20 bg-teal-500/5 rounded-xl overflow-hidden mt-2",children:[(0,Wa.jsxs)("div",{className:"bg-teal-500/10 px-3 py-2 flex items-center gap-2 border-b border-teal-500/10",children:[(0,Wa.jsx)(tE.Database,{className:"w-4 h-4 text-teal-600 dark:text-teal-400"}),(0,Wa.jsx)("span",{className:"text-[11px] font-bold text-teal-800 dark:text-teal-300 uppercase tracking-widest",children:"M-Script Aplicado"})]}),(0,Wa.jsx)("div",{className:"p-3",children:(0,Wa.jsx)("pre",{className:"text-[13px] font-mono text-teal-900/80 dark:text-teal-100/80 whitespace-pre-wrap break-all",children:n})})]})}});function Cx(t,e,r){return`<!DOCTYPE html>
|
|
210
|
+
<html lang="es">
|
|
211
|
+
<head>
|
|
212
|
+
<meta charset="UTF-8">
|
|
213
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
214
|
+
<title>Decido Preview</title>
|
|
215
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
216
|
+
<style>
|
|
217
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
218
|
+
body {
|
|
219
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
|
|
220
|
+
margin: 0;
|
|
221
|
+
background: #fff;
|
|
222
|
+
min-height: 100vh;
|
|
223
|
+
}
|
|
224
|
+
${e}
|
|
225
|
+
</style>
|
|
226
|
+
</head>
|
|
227
|
+
<body>
|
|
228
|
+
${t}
|
|
229
|
+
<script>try { ${r} } catch(e) { console.error(e); }</script>
|
|
230
|
+
</body>
|
|
231
|
+
</html>`}function oE(){let[t,e]=(0,Id.useState)({status:"idle",url:null,error:null,progress:0}),r=(0,Id.useCallback)(async()=>{let s=Ue.getState().getActiveInstance();if(!s?.data?.html){e({status:"error",url:null,error:"No hay contenido para desplegar",progress:0});return}let{html:i,css:a,javascript:l}=s.data;e({status:"deploying",url:null,error:null,progress:10});let c=localStorage.getItem("nexusai_api_key");if(c)try{e(x=>({...x,progress:30}));let d="@nexusai/sdk",{NexusAI:u}=await import(d),f=new u({apiKey:c}),p=Cx(i,a||"",l||""),{jobId:h}=await f.pipeline.deploy({componentName:`preview-${Date.now()}`,componentCode:p});e(x=>({...x,progress:60}));let b=await f.pipeline.waitForDeploy(h,{timeoutMs:6e4,onProgress:x=>e(y=>({...y,progress:60+Math.round((x.progress||0)*.4)}))}),g=b.result?.deploymentUrl||b.result?.url||"";e({status:"success",url:g,error:null,progress:100})}catch(d){let u=Cx(i,a||"",l||""),f=new Blob([u],{type:"text/html"}),p=URL.createObjectURL(f);e({status:"success",url:p,error:`SDK fall\xF3 (${d.message}). Preview local generado.`,progress:100})}else{await new Promise(p=>setTimeout(p,500)),e(p=>({...p,progress:50}));let d=Cx(i,a||"",l||""),u=new Blob([d],{type:"text/html"}),f=URL.createObjectURL(u);e({status:"success",url:f,error:null,progress:100})}},[]),n=(0,Id.useCallback)(()=>{e({status:"idle",url:null,error:null,progress:0})},[]),o=(0,Id.useCallback)(()=>{t.url&&navigator.clipboard.writeText(t.url)},[t.url]);return{...t,deploy:r,reset:n,copyUrl:o}}var Id,sE=U(()=>{"use strict";Id=require("react");mo()});var qs,Ss,iE,aE,lE=U(()=>{"use strict";qs=Re(require("react")),Ss=require("react/jsx-runtime"),iE={html:{label:"HTML",color:"#e44d26"},css:{label:"CSS",color:"#2965f1"},js:{label:"JS",color:"#f7df1e"}},aE=qs.default.memo(function({code:e={html:"",css:"",js:""},onCodeChange:r}){let[n,o]=(0,qs.useState)("html"),s=(0,qs.useRef)(null),[i,a]=(0,qs.useState)(e);(0,qs.useEffect)(()=>{a(e)},[e]);let l=(0,qs.useCallback)(u=>{let f={...i,[n]:u};a(f),r(f)},[n,i,r]),c=n==="html"?i.html:n==="css"?i.css:i.js,d=(c||"").split(`
|
|
232
|
+
`).length;return(0,Ss.jsxs)("div",{className:"flex flex-col h-full bg-surface-tertiary border-l border-border-subtle overflow-hidden",style:{minWidth:280},children:[(0,Ss.jsxs)("div",{className:"flex items-center gap-0.5 px-2 py-1.5 bg-surface-secondary border-b border-border-subtle shrink-0",children:[["html","css","js"].map(u=>(0,Ss.jsxs)("button",{onClick:()=>o(u),className:`px-3 py-1 rounded text-[10px] font-mono uppercase tracking-wider transition-colors ${n===u?"bg-surface-glass text-text-primary":"text-text-muted hover:text-text-primary hover:bg-surface-glass"}`,children:[(0,Ss.jsx)("span",{className:"inline-block w-2 h-2 rounded-full mr-1.5",style:{background:iE[u].color}}),iE[u].label]},u)),(0,Ss.jsxs)("span",{className:"ml-auto text-[9px] text-text-muted font-mono",children:[d," l\xEDneas"]})]}),(0,Ss.jsx)("div",{className:"flex-1 overflow-auto relative",style:{fontFamily:'ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace'},children:(0,Ss.jsxs)("div",{className:"flex min-h-full",children:[(0,Ss.jsx)("div",{className:"select-none text-right pr-3 pl-3 py-3 text-[11px] text-text-muted leading-normal shrink-0 bg-surface-tertiary border-r border-border-subtle",children:Array.from({length:d},(u,f)=>(0,Ss.jsx)("div",{children:f+1},f))}),(0,Ss.jsx)("textarea",{ref:s,value:c,onChange:u=>l(u.target.value),spellCheck:!1,className:"flex-1 resize-none bg-transparent text-text-primary text-[11px] leading-normal p-3 outline-hidden min-h-full",style:{tabSize:2}})]})})]})})});var cE,dE,Do,l8,uE,fE=U(()=>{"use strict";cE=Re(require("react")),dE=require("motion/react"),Do=require("react/jsx-runtime"),l8=[{id:"landing-saas",title:"Landing SaaS",category:"Marketing",emoji:"\u{1F680}",gradient:"from-violet-600 to-indigo-600",description:"Hero con CTA, features, testimonios",html:`<section class="min-h-screen bg-linear-to-br from-violet-950 via-indigo-950 to-black text-text-primary">
|
|
233
|
+
<nav class="flex items-center justify-between px-8 py-6">
|
|
234
|
+
<span class="text-xl font-bold bg-linear-to-r from-violet-400 to-indigo-400 bg-clip-text text-transparent">NexusAI</span>
|
|
235
|
+
<div class="flex gap-6 text-sm text-text-secondary"><a href="#" class="hover:text-text-primary">Features</a><a href="#" class="hover:text-text-primary">Pricing</a><a href="#" class="hover:text-text-primary">Docs</a></div>
|
|
236
|
+
<button class="px-5 py-2 bg-violet-600 hover:bg-violet-500 rounded-full text-sm font-medium transition">Get Started</button>
|
|
237
|
+
</nav>
|
|
238
|
+
<div class="flex flex-col items-center text-center pt-24 px-6">
|
|
239
|
+
<span class="px-4 py-1.5 bg-violet-500/10 border border-violet-500/20 rounded-full text-xs text-violet-300 mb-6">\u2728 Now in Beta</span>
|
|
240
|
+
<h1 class="text-5xl md:text-7xl font-bold leading-tight max-w-4xl">Build faster with <span class="bg-linear-to-r from-violet-400 to-cyan-400 bg-clip-text text-transparent">AI-powered</span> tools</h1>
|
|
241
|
+
<p class="text-lg text-text-secondary mt-6 max-w-2xl">Ship products 10x faster. Our AI understands your codebase and generates production-ready code in seconds.</p>
|
|
242
|
+
<div class="flex gap-4 mt-10"><button class="px-8 py-3 bg-violet-600 hover:bg-violet-500 rounded-full font-medium transition">Start Free Trial</button><button class="px-8 py-3 bg-surface-glass hover:bg-surface-glass border border-border-default rounded-full font-medium transition">Watch Demo \u2192</button></div>
|
|
243
|
+
</div>
|
|
244
|
+
</section>`,css:"",js:""},{id:"dashboard",title:"Dashboard",category:"App",emoji:"\u{1F4CA}",gradient:"from-cyan-600 to-blue-600",description:"M\xE9tricas, gr\xE1ficos, sidebar",html:`<div class="flex h-screen bg-surface-primary text-text-primary">
|
|
245
|
+
<aside class="w-56 bg-surface-secondary border-r border-border-subtle p-4 flex flex-col gap-2">
|
|
246
|
+
<span class="text-lg font-bold text-cyan-400 mb-4">\u{1F4CA} Dashboard</span>
|
|
247
|
+
<a class="px-3 py-2 rounded-lg bg-cyan-500/10 text-cyan-300 text-sm">Overview</a>
|
|
248
|
+
<a class="px-3 py-2 rounded-lg text-text-muted hover:text-text-primary text-sm">Analytics</a>
|
|
249
|
+
<a class="px-3 py-2 rounded-lg text-text-muted hover:text-text-primary text-sm">Reports</a>
|
|
250
|
+
<a class="px-3 py-2 rounded-lg text-text-muted hover:text-text-primary text-sm">Settings</a>
|
|
251
|
+
</aside>
|
|
252
|
+
<main class="flex-1 p-8 overflow-auto">
|
|
253
|
+
<h2 class="text-2xl font-bold mb-6">Good morning \u{1F44B}</h2>
|
|
254
|
+
<div class="grid grid-cols-3 gap-4 mb-8">
|
|
255
|
+
<div class="bg-surface-secondary border border-border-subtle rounded-2xl p-5"><p class="text-xs text-text-muted mb-1">Revenue</p><p class="text-3xl font-bold text-emerald-400">$48,352</p><p class="text-xs text-emerald-500 mt-1">\u2191 12.5%</p></div>
|
|
256
|
+
<div class="bg-surface-secondary border border-border-subtle rounded-2xl p-5"><p class="text-xs text-text-muted mb-1">Users</p><p class="text-3xl font-bold text-cyan-400">2,847</p><p class="text-xs text-cyan-500 mt-1">\u2191 8.3%</p></div>
|
|
257
|
+
<div class="bg-surface-secondary border border-border-subtle rounded-2xl p-5"><p class="text-xs text-text-muted mb-1">Conversion</p><p class="text-3xl font-bold text-violet-400">3.24%</p><p class="text-xs text-violet-500 mt-1">\u2191 2.1%</p></div>
|
|
258
|
+
</div>
|
|
259
|
+
<div class="bg-surface-secondary border border-border-subtle rounded-2xl p-6"><h3 class="text-sm font-medium text-text-secondary mb-4">Recent Activity</h3><div class="space-y-3"><div class="flex items-center gap-3 text-sm"><span class="w-8 h-8 rounded-full bg-emerald-500/10 flex items-center justify-center text-emerald-400">$</span><span class="text-text-primary">New subscription \u2014 Pro Plan</span><span class="ml-auto text-text-muted">2m ago</span></div><div class="flex items-center gap-3 text-sm"><span class="w-8 h-8 rounded-full bg-cyan-500/10 flex items-center justify-center text-cyan-400">\u{1F464}</span><span class="text-text-primary">New user registered</span><span class="ml-auto text-text-muted">15m ago</span></div></div></div>
|
|
260
|
+
</main>
|
|
261
|
+
</div>`,css:"",js:""},{id:"portfolio",title:"Portfolio",category:"Personal",emoji:"\u{1F3A8}",gradient:"from-pink-600 to-rose-600",description:"Bio, proyectos, contacto",html:`<div class="min-h-screen bg-surface-primary text-text-primary px-6 py-16 flex flex-col items-center">
|
|
262
|
+
<div class="max-w-2xl w-full">
|
|
263
|
+
<div class="flex items-center gap-4 mb-8"><div class="w-16 h-16 rounded-full bg-linear-to-br from-pink-500 to-rose-500 flex items-center justify-center text-2xl">JR</div><div><h1 class="text-2xl font-bold">Maria Garcia</h1><p class="text-text-muted">Full-Stack Designer & Developer</p></div></div>
|
|
264
|
+
<p class="text-text-secondary leading-relaxed mb-12">I craft beautiful digital experiences that bridge the gap between design and engineering. 5+ years building products for startups and enterprises.</p>
|
|
265
|
+
<h2 class="text-sm font-bold text-text-muted uppercase tracking-wider mb-4">Selected Work</h2>
|
|
266
|
+
<div class="grid grid-cols-2 gap-4 mb-12">
|
|
267
|
+
<div class="group bg-surface-tertiary rounded-2xl overflow-hidden border border-border-subtle hover:border-pink-500/30 transition"><div class="h-32 bg-linear-to-br from-pink-500/20 to-purple-500/20"></div><div class="p-4"><h3 class="font-medium">E-Commerce Platform</h3><p class="text-xs text-text-muted mt-1">React, Node.js, Stripe</p></div></div>
|
|
268
|
+
<div class="group bg-surface-tertiary rounded-2xl overflow-hidden border border-border-subtle hover:border-cyan-500/30 transition"><div class="h-32 bg-linear-to-br from-cyan-500/20 to-blue-500/20"></div><div class="p-4"><h3 class="font-medium">AI Dashboard</h3><p class="text-xs text-text-muted mt-1">Vue, Python, TensorFlow</p></div></div>
|
|
269
|
+
</div>
|
|
270
|
+
<div class="flex gap-4 text-sm text-text-muted"><a href="#" class="hover:text-text-primary">GitHub</a><a href="#" class="hover:text-text-primary">LinkedIn</a><a href="#" class="hover:text-text-primary">Twitter</a><a href="#" class="hover:text-text-primary">Email</a></div>
|
|
271
|
+
</div>
|
|
272
|
+
</div>`,css:"",js:""},{id:"pricing",title:"Pricing",category:"Marketing",emoji:"\u{1F4B3}",gradient:"from-emerald-600 to-teal-600",description:"3 planes con toggle mensual/anual",html:`<section class="min-h-screen bg-surface-primary text-text-primary py-20 px-6">
|
|
273
|
+
<div class="max-w-5xl mx-auto text-center">
|
|
274
|
+
<h2 class="text-4xl font-bold mb-4">Simple, transparent pricing</h2>
|
|
275
|
+
<p class="text-text-muted mb-12">No hidden fees. Cancel anytime.</p>
|
|
276
|
+
<div class="grid md:grid-cols-3 gap-6">
|
|
277
|
+
<div class="bg-surface-tertiary border border-border-subtle rounded-2xl p-8 text-left"><p class="text-sm text-text-muted mb-2">Starter</p><p class="text-4xl font-bold mb-1">$9<span class="text-lg text-text-muted">/mo</span></p><p class="text-xs text-text-muted mb-6">Perfect for getting started</p><ul class="space-y-2 text-sm text-text-secondary mb-8"><li>\u2713 5 projects</li><li>\u2713 Basic analytics</li><li>\u2713 Email support</li></ul><button class="w-full py-2.5 bg-surface-glass hover:bg-surface-glass border border-border-default rounded-xl text-sm transition">Get Started</button></div>
|
|
278
|
+
<div class="bg-surface-tertiary border-2 border-emerald-500/50 rounded-2xl p-8 text-left relative"><span class="absolute -top-3 left-1/2 -translate-x-1/2 px-3 py-0.5 bg-emerald-500 rounded-full text-xs font-medium">Popular</span><p class="text-sm text-text-muted mb-2">Pro</p><p class="text-4xl font-bold mb-1">$29<span class="text-lg text-text-muted">/mo</span></p><p class="text-xs text-text-muted mb-6">For growing teams</p><ul class="space-y-2 text-sm text-text-secondary mb-8"><li>\u2713 Unlimited projects</li><li>\u2713 Advanced analytics</li><li>\u2713 Priority support</li><li>\u2713 Custom domains</li></ul><button class="w-full py-2.5 bg-emerald-600 hover:bg-emerald-500 rounded-xl text-sm font-medium transition">Get Started</button></div>
|
|
279
|
+
<div class="bg-surface-tertiary border border-border-subtle rounded-2xl p-8 text-left"><p class="text-sm text-text-muted mb-2">Enterprise</p><p class="text-4xl font-bold mb-1">$99<span class="text-lg text-text-muted">/mo</span></p><p class="text-xs text-text-muted mb-6">For large organizations</p><ul class="space-y-2 text-sm text-text-secondary mb-8"><li>\u2713 Everything in Pro</li><li>\u2713 SSO & SAML</li><li>\u2713 Dedicated support</li><li>\u2713 SLA guarantee</li></ul><button class="w-full py-2.5 bg-surface-glass hover:bg-surface-glass border border-border-default rounded-xl text-sm transition">Contact Sales</button></div>
|
|
280
|
+
</div>
|
|
281
|
+
</div>
|
|
282
|
+
</section>`,css:"",js:""},{id:"login",title:"Login",category:"Auth",emoji:"\u{1F510}",gradient:"from-amber-600 to-orange-600",description:"Form con social login y glassmorphism",html:`<div class="min-h-screen bg-surface-primary flex items-center justify-center p-6">
|
|
283
|
+
<div class="w-full max-w-sm bg-surface-glass backdrop-blur-xl border border-border-default rounded-3xl p-8 text-text-primary">
|
|
284
|
+
<div class="text-center mb-8"><span class="text-4xl">\u{1F510}</span><h2 class="text-2xl font-bold mt-3">Welcome back</h2><p class="text-sm text-text-muted mt-1">Sign in to your account</p></div>
|
|
285
|
+
<div class="space-y-4">
|
|
286
|
+
<div><label class="text-xs text-text-muted mb-1 block">Email</label><input type="email" placeholder="you@email.com" class="w-full px-4 py-3 bg-surface-glass border border-border-default rounded-xl text-sm outline-hidden focus:border-amber-500/50 transition"/></div>
|
|
287
|
+
<div><label class="text-xs text-text-muted mb-1 block">Password</label><input type="password" placeholder="\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" class="w-full px-4 py-3 bg-surface-glass border border-border-default rounded-xl text-sm outline-hidden focus:border-amber-500/50 transition"/></div>
|
|
288
|
+
<button class="w-full py-3 bg-linear-to-r from-amber-500 to-orange-500 hover:from-amber-400 hover:to-orange-400 rounded-xl text-sm font-medium transition">Sign In</button>
|
|
289
|
+
<div class="flex items-center gap-3 my-2"><div class="flex-1 h-px bg-surface-glass"></div><span class="text-xs text-text-muted">or</span><div class="flex-1 h-px bg-surface-glass"></div></div>
|
|
290
|
+
<button class="w-full py-3 bg-surface-glass hover:bg-surface-glass border border-border-default rounded-xl text-sm transition flex items-center justify-center gap-2">\u{1F310} Continue with Google</button>
|
|
291
|
+
</div>
|
|
292
|
+
<p class="text-xs text-text-muted text-center mt-6">Don't have an account? <a href="#" class="text-amber-400 hover:underline">Sign up</a></p>
|
|
293
|
+
</div>
|
|
294
|
+
</div>`,css:"",js:""},{id:"blog",title:"Blog",category:"Content",emoji:"\u{1F4DD}",gradient:"from-sky-600 to-blue-600",description:"Lista de art\xEDculos con cards",html:`<div class="min-h-screen bg-surface-primary text-text-primary py-16 px-6">
|
|
295
|
+
<div class="max-w-3xl mx-auto">
|
|
296
|
+
<h1 class="text-4xl font-bold mb-2">Blog</h1>
|
|
297
|
+
<p class="text-text-muted mb-12">Thoughts on design, technology, and building products.</p>
|
|
298
|
+
<div class="space-y-6">
|
|
299
|
+
<article class="group bg-surface-tertiary border border-border-subtle rounded-2xl p-6 hover:border-sky-500/30 transition cursor-pointer"><div class="flex items-center gap-2 text-xs text-text-muted mb-3"><span class="px-2 py-0.5 bg-sky-500/10 text-sky-400 rounded">Design</span><span>Mar 15, 2026</span><span>\xB7 5 min read</span></div><h2 class="text-xl font-bold group-hover:text-sky-400 transition">The Future of AI-Powered Design Tools</h2><p class="text-sm text-text-muted mt-2 leading-relaxed">How generative AI is transforming the way we build user interfaces and what it means for designers.</p></article>
|
|
300
|
+
<article class="group bg-surface-tertiary border border-border-subtle rounded-2xl p-6 hover:border-violet-500/30 transition cursor-pointer"><div class="flex items-center gap-2 text-xs text-text-muted mb-3"><span class="px-2 py-0.5 bg-violet-500/10 text-violet-400 rounded">Engineering</span><span>Mar 10, 2026</span><span>\xB7 8 min read</span></div><h2 class="text-xl font-bold group-hover:text-violet-400 transition">Building a Real-Time Collaboration Engine</h2><p class="text-sm text-text-muted mt-2 leading-relaxed">A deep dive into the architecture behind our multi-user editing system using CRDTs and WebSockets.</p></article>
|
|
301
|
+
<article class="group bg-surface-tertiary border border-border-subtle rounded-2xl p-6 hover:border-emerald-500/30 transition cursor-pointer"><div class="flex items-center gap-2 text-xs text-text-muted mb-3"><span class="px-2 py-0.5 bg-emerald-500/10 text-emerald-400 rounded">Product</span><span>Mar 5, 2026</span><span>\xB7 3 min read</span></div><h2 class="text-xl font-bold group-hover:text-emerald-400 transition">Shipping Faster with Component Libraries</h2><p class="text-sm text-text-muted mt-2 leading-relaxed">How we reduced our time-to-market by 60% by investing in a robust design system.</p></article>
|
|
302
|
+
</div>
|
|
303
|
+
</div>
|
|
304
|
+
</div>`,css:"",js:""}],uE=cE.default.memo(function({onSelect:e}){return(0,Do.jsxs)("div",{className:"flex flex-col items-center justify-center h-full p-6 overflow-auto",children:[(0,Do.jsxs)("div",{className:"text-center mb-8",children:[(0,Do.jsx)("span",{className:"text-4xl",children:"\u{1F3A8}"}),(0,Do.jsx)("h2",{className:"text-xl font-bold text-text-primary mt-3",children:"Elige un template"}),(0,Do.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Click para cargar \u2014 luego refina con IA"})]}),(0,Do.jsx)("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-3 max-w-3xl w-full",children:l8.map((r,n)=>(0,Do.jsxs)(dE.motion.button,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:n*.05},onClick:()=>e({html:r.html,css:r.css,js:r.js}),className:"group bg-surface-tertiary border border-border-subtle hover:border-border-strong rounded-2xl p-4 text-left transition-all hover:scale-[1.02] hover:shadow-xl overflow-hidden",children:[(0,Do.jsx)("div",{className:`h-20 rounded-xl bg-linear-to-br ${r.gradient} opacity-30 group-hover:opacity-50 transition mb-3 flex items-center justify-center`,children:(0,Do.jsx)("span",{className:"text-3xl opacity-70",children:r.emoji})}),(0,Do.jsx)("h3",{className:"text-sm font-bold text-text-primary",children:r.title}),(0,Do.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:r.category}),(0,Do.jsx)("p",{className:"text-[10px] text-text-muted mt-1",children:r.description})]},r.id))})]})})});var Ur,Lt,Ee,pE,c8,hE,mE=U(()=>{"use strict";Ur=require("react"),Lt=require("lucide-react");sE();mo();lE();fE();Ee=require("react/jsx-runtime"),pE={desktop:{w:"100%",h:"100%",label:"Desktop"},tablet:{w:"768px",h:"1024px",label:"Tablet"},mobile:{w:"375px",h:"667px",label:"Mobile"}},c8={desktop:Lt.Monitor,tablet:Lt.Tablet,mobile:Lt.Smartphone},hE=({artifacts:t,activeArtifactIndex:e,data:r})=>{let n=(0,Ur.useRef)(null),[o,s]=(0,Ur.useState)("desktop"),[i,a]=(0,Ur.useState)(Date.now()),[l,c]=(0,Ur.useState)(!1),[d,u]=(0,Ur.useState)(!1),[f,p]=(0,Ur.useState)(null),[h,b]=(0,Ur.useState)(!1),[g,x]=(0,Ur.useState)(!1),y=oE(),m=(0,Ur.useMemo)(()=>{let E=r||t?.[e??0]?.data||{},P=E.html||E.content||"",N=E.css||E.styles||"",D=E.javascript||E.js||"";return{html:P,css:N,js:D}},[r,t,e]);(0,Ur.useEffect)(()=>{let E=P=>{P.data?.type==="DECIDO_ELEMENT_SELECTED"&&(p(P.data.selector||null),window.__DECIDO__&&(window.__DECIDO__.selectedElementSelector=P.data.selector||null))};return window.addEventListener("message",E),()=>window.removeEventListener("message",E)},[]);let[v,S]=(0,Ur.useState)(!1);(0,Ur.useEffect)(()=>{let E=P=>{if(!(P.target instanceof HTMLInputElement||P.target instanceof HTMLTextAreaElement||!(P.metaKey||P.ctrlKey))){if(P.code==="KeyI"&&!P.shiftKey){P.preventDefault(),u(D=>!D);return}if(P.code==="KeyE"&&!P.shiftKey){P.preventDefault(),x(D=>!D);return}if(P.code==="KeyD"&&!P.shiftKey){P.preventDefault(),y.deploy();return}if(P.key==="/"){P.preventDefault(),S(D=>!D);return}}};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[y]),(0,Ur.useEffect)(()=>{n.current?.contentWindow&&n.current.contentWindow.postMessage({type:"DECIDO_SET_INSPECT",enabled:d},"*")},[d,i]);let w=(0,Ur.useMemo)(()=>{let E=(m.js||"").replace(/<\/script/gi,"<\\/script");return`
|
|
305
|
+
<!DOCTYPE html>
|
|
306
|
+
<html lang="es">
|
|
307
|
+
<head>
|
|
308
|
+
<meta charset="UTF-8">
|
|
309
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
310
|
+
<base target="_blank">
|
|
311
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
312
|
+
<style>
|
|
313
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
314
|
+
body {
|
|
315
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
|
|
316
|
+
margin: 0;
|
|
317
|
+
background: #fff;
|
|
318
|
+
min-height: 100vh;
|
|
319
|
+
color: #1a1a1a;
|
|
320
|
+
}
|
|
321
|
+
html, body { width: 100%; height: 100%; }
|
|
322
|
+
.__decido-hover { outline: 2px dashed #06b6d4 !important; outline-offset: 2px; cursor: crosshair !important; }
|
|
323
|
+
.__decido-selected { outline: 2px solid #06b6d4 !important; outline-offset: 2px; box-shadow: 0 0 0 4px rgba(6,182,212,0.15) !important; }
|
|
324
|
+
${m.css}
|
|
325
|
+
</style>
|
|
326
|
+
</head>
|
|
327
|
+
<body>
|
|
328
|
+
${m.html}
|
|
329
|
+
<script>
|
|
330
|
+
try { ${E} } catch(e) { console.error('[Preview]', e); }
|
|
331
|
+
</script>
|
|
332
|
+
<script>
|
|
333
|
+
// Link interceptor
|
|
334
|
+
document.addEventListener('click', function(e) {
|
|
335
|
+
var a = e.target.closest('a');
|
|
336
|
+
if (!a) return;
|
|
337
|
+
var href = a.getAttribute('href') || '';
|
|
338
|
+
if (href.startsWith('#')) return;
|
|
339
|
+
if (href.startsWith('javascript:')) { e.preventDefault(); return; }
|
|
340
|
+
e.preventDefault();
|
|
341
|
+
if (href && href !== '#') window.open(href, '_blank', 'noopener,noreferrer');
|
|
342
|
+
}, true);
|
|
343
|
+
|
|
344
|
+
// Element Inspector
|
|
345
|
+
var _inspectEnabled = false;
|
|
346
|
+
var _hoveredEl = null;
|
|
347
|
+
var _selectedEl = null;
|
|
348
|
+
|
|
349
|
+
function _getSelector(el) {
|
|
350
|
+
if (el.id) return '#' + el.id;
|
|
351
|
+
var path = [];
|
|
352
|
+
while (el && el !== document.body && el !== document.documentElement) {
|
|
353
|
+
var tag = el.tagName.toLowerCase();
|
|
354
|
+
if (el.className && typeof el.className === 'string') {
|
|
355
|
+
var cls = el.className.split(/s+/).filter(function(c) { return !c.startsWith('__decido'); }).slice(0, 2).join('.');
|
|
356
|
+
if (cls) tag += '.' + cls;
|
|
357
|
+
}
|
|
358
|
+
var parent = el.parentElement;
|
|
359
|
+
if (parent) {
|
|
360
|
+
var siblings = Array.from(parent.children).filter(function(c) { return c.tagName === el.tagName; });
|
|
361
|
+
if (siblings.length > 1) tag += ':nth-child(' + (Array.from(parent.children).indexOf(el) + 1) + ')';
|
|
362
|
+
}
|
|
363
|
+
path.unshift(tag);
|
|
364
|
+
el = parent;
|
|
365
|
+
if (path.length >= 3) break;
|
|
366
|
+
}
|
|
367
|
+
return path.join(' > ');
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
document.addEventListener('mouseover', function(e) {
|
|
371
|
+
if (!_inspectEnabled) return;
|
|
372
|
+
if (_hoveredEl) _hoveredEl.classList.remove('__decido-hover');
|
|
373
|
+
_hoveredEl = e.target;
|
|
374
|
+
if (_hoveredEl !== _selectedEl) _hoveredEl.classList.add('__decido-hover');
|
|
375
|
+
});
|
|
376
|
+
document.addEventListener('mouseout', function(e) {
|
|
377
|
+
if (_hoveredEl) _hoveredEl.classList.remove('__decido-hover');
|
|
378
|
+
});
|
|
379
|
+
document.addEventListener('click', function(e) {
|
|
380
|
+
if (!_inspectEnabled) return;
|
|
381
|
+
e.preventDefault();
|
|
382
|
+
e.stopPropagation();
|
|
383
|
+
if (_selectedEl) _selectedEl.classList.remove('__decido-selected');
|
|
384
|
+
_selectedEl = e.target;
|
|
385
|
+
_selectedEl.classList.add('__decido-selected');
|
|
386
|
+
_hoveredEl = null;
|
|
387
|
+
var sel = _getSelector(_selectedEl);
|
|
388
|
+
window.parent.postMessage({ type: 'DECIDO_ELEMENT_SELECTED', selector: sel, tagName: _selectedEl.tagName }, '*');
|
|
389
|
+
}, true);
|
|
390
|
+
|
|
391
|
+
window.addEventListener('message', function(e) {
|
|
392
|
+
if (e.data && e.data.type === 'DECIDO_SET_INSPECT') {
|
|
393
|
+
_inspectEnabled = e.data.enabled;
|
|
394
|
+
if (!_inspectEnabled) {
|
|
395
|
+
if (_hoveredEl) _hoveredEl.classList.remove('__decido-hover');
|
|
396
|
+
if (_selectedEl) _selectedEl.classList.remove('__decido-selected');
|
|
397
|
+
_hoveredEl = null; _selectedEl = null;
|
|
398
|
+
}
|
|
399
|
+
document.body.style.cursor = _inspectEnabled ? 'crosshair' : '';
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
</script>
|
|
403
|
+
</body>
|
|
404
|
+
</html>`},[m]),C=(0,Ur.useCallback)(()=>a(Date.now()),[]),A=(0,Ur.useCallback)(()=>{let E=window.open();E&&(E.document.write(w),E.document.close())},[w]),k=(0,Ur.useCallback)(()=>{let E=!d;u(E),E||p(null)},[d]),M=pE[o],T=!!m.html?.trim();return(0,Ee.jsxs)("div",{className:`w-full h-full flex flex-col bg-surface-primary overflow-hidden ${l?"fixed inset-0 z-9999":""}`,children:[(0,Ee.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 bg-surface-secondary border-b border-border-subtle text-[10px] text-text-muted select-none shrink-0",children:[(0,Ee.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,Ee.jsxs)("div",{className:"flex gap-1 px-1",children:[(0,Ee.jsx)("span",{className:"w-2.5 h-2.5 rounded-full bg-red-500/80"}),(0,Ee.jsx)("span",{className:"w-2.5 h-2.5 rounded-full bg-yellow-500/80"}),(0,Ee.jsx)("span",{className:"w-2.5 h-2.5 rounded-full bg-green-500/80"})]}),(0,Ee.jsx)("button",{onClick:C,className:"p-1 rounded hover:bg-surface-glass transition-colors",title:"Recargar",children:(0,Ee.jsx)(Lt.RotateCcw,{size:12})}),(0,Ee.jsx)("button",{onClick:()=>Ue.getState().undo(),disabled:!Ue.getState().canUndo(),className:`p-1 rounded transition-colors ${Ue.getState().canUndo()?"hover:bg-surface-glass text-text-secondary":"text-text-muted cursor-not-allowed"}`,title:"Deshacer",children:(0,Ee.jsx)(Lt.Undo2,{size:12})}),(0,Ee.jsx)("button",{onClick:()=>Ue.getState().redo(),disabled:!Ue.getState().canRedo(),className:`p-1 rounded transition-colors ${Ue.getState().canRedo()?"hover:bg-surface-glass text-text-secondary":"text-text-muted cursor-not-allowed"}`,title:"Rehacer",children:(0,Ee.jsx)(Lt.Redo2,{size:12})}),(0,Ee.jsxs)("span",{className:"px-2 py-0.5 bg-surface-overlay rounded text-[9px] font-mono",children:[M.w==="100%"?"Adaptable":M.w," \xD7 ",M.h==="100%"?"100%":M.h]})]}),(0,Ee.jsx)("div",{className:"flex items-center gap-0.5",children:["desktop","tablet","mobile"].map(E=>{let P=c8[E];return(0,Ee.jsx)("button",{onClick:()=>s(E),className:`p-1.5 rounded transition-colors ${o===E?"bg-surface-glass text-text-primary":"hover:bg-surface-glass text-text-muted hover:text-text-primary"}`,title:pE[E].label,children:(0,Ee.jsx)(P,{size:13})},E)})}),(0,Ee.jsxs)("div",{className:"flex items-center gap-1",children:[(0,Ee.jsx)("button",{onClick:k,className:`p-1 rounded transition-colors ${d?"bg-cyan-500/20 text-cyan-400":"hover:bg-surface-glass text-text-muted"}`,title:d?"Desactivar inspector":"Seleccionar elemento",children:(0,Ee.jsx)(Lt.MousePointer2,{size:12})}),(0,Ee.jsx)("button",{onClick:()=>x(!g),className:`p-1 rounded transition-colors ${g?"bg-violet-500/20 text-violet-400":"hover:bg-surface-glass text-text-muted"}`,title:g?"Ocultar c\xF3digo":"Ver / editar c\xF3digo",children:(0,Ee.jsx)(Lt.Code2,{size:12})}),(0,Ee.jsx)("button",{onClick:()=>{y.deploy()},disabled:!T||y.status==="deploying",className:`p-1 rounded transition-colors ${y.status==="deploying"?"text-amber-400 animate-pulse":T?"hover:bg-emerald-500/10 text-text-muted hover:text-emerald-400":"text-text-muted cursor-not-allowed"}`,title:"Desplegar preview",children:y.status==="deploying"?(0,Ee.jsx)(Lt.Loader2,{size:12,className:"animate-spin"}):(0,Ee.jsx)(Lt.Rocket,{size:12})}),(0,Ee.jsx)("button",{onClick:()=>c(!l),className:"p-1 rounded hover:bg-surface-glass transition-colors",title:l?"Salir fullscreen":"Fullscreen",children:l?(0,Ee.jsx)(Lt.Minimize2,{size:12}):(0,Ee.jsx)(Lt.Maximize2,{size:12})}),(0,Ee.jsx)("button",{onClick:A,className:"p-1 rounded hover:bg-surface-glass transition-colors",title:"Abrir en nueva pesta\xF1a",children:(0,Ee.jsx)(Lt.ExternalLink,{size:12})})]})]}),y.status!=="idle"&&(0,Ee.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border-subtle text-[10px] shrink-0",style:{background:y.status==="success"?"rgba(16,185,129,0.08)":y.status==="error"?"rgba(239,68,68,0.08)":"rgba(245,158,11,0.08)"},children:[y.status==="deploying"&&(0,Ee.jsxs)(Ee.Fragment,{children:[(0,Ee.jsx)(Lt.Loader2,{size:10,className:"text-amber-400 animate-spin"}),(0,Ee.jsxs)("span",{className:"text-amber-300 font-mono",children:["Desplegando... ",y.progress,"%"]}),(0,Ee.jsx)("div",{className:"flex-1 h-1 bg-surface-glass rounded-full overflow-hidden",children:(0,Ee.jsx)("div",{className:"h-full bg-amber-400 transition-all duration-300 rounded-full",style:{width:`${y.progress}%`}})})]}),y.status==="success"&&y.url&&(0,Ee.jsxs)(Ee.Fragment,{children:[(0,Ee.jsx)(Lt.Check,{size:10,className:"text-emerald-400"}),(0,Ee.jsx)("a",{href:y.url,target:"_blank",rel:"noopener noreferrer",className:"text-emerald-300 font-mono flex-1 truncate hover:underline",children:y.url.length>60?y.url.slice(0,60)+"...":y.url}),(0,Ee.jsx)("button",{onClick:()=>{y.copyUrl(),b(!0),setTimeout(()=>b(!1),1500)},className:"text-text-secondary hover:text-text-primary transition-colors",title:"Copiar URL",children:h?(0,Ee.jsx)(Lt.Check,{size:10,className:"text-emerald-400"}):(0,Ee.jsx)(Lt.Copy,{size:10})}),(0,Ee.jsx)("button",{onClick:y.reset,className:"text-text-muted hover:text-text-primary",children:"\u2715"})]}),y.status==="error"&&(0,Ee.jsxs)(Ee.Fragment,{children:[(0,Ee.jsx)("span",{className:"text-red-400",children:"\u26A0"}),(0,Ee.jsx)("span",{className:"text-red-300 font-mono flex-1",children:y.error}),(0,Ee.jsx)("button",{onClick:y.reset,className:"text-text-muted hover:text-text-primary",children:"\u2715"})]})]}),f&&(0,Ee.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-cyan-500/10 border-b border-cyan-500/20 text-[10px] shrink-0",children:[(0,Ee.jsx)(Lt.MousePointer2,{size:10,className:"text-cyan-400"}),(0,Ee.jsx)("code",{className:"text-cyan-300 font-mono flex-1 truncate",children:f}),(0,Ee.jsx)("span",{className:"text-text-muted",children:"Escribe en el chat para modificar este elemento"}),(0,Ee.jsx)("button",{onClick:()=>{p(null),u(!1)},className:"text-text-muted hover:text-text-primary",children:"\u2715"})]}),(0,Ee.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,Ee.jsx)("div",{className:`flex items-center justify-center overflow-auto p-2 ${g?"w-1/2":"flex-1"}`,style:{background:"repeating-conic-gradient(#1a1a1b 0% 25%, #141415 0% 50%) 0 0 / 20px 20px"},children:T?(0,Ee.jsx)("div",{className:"bg-white shadow-2xl transition-all duration-300 overflow-hidden w-full h-full",style:{maxWidth:g?"100%":M.w,maxHeight:g?"100%":M.h,border:o!=="desktop"?"6px solid #333":"1px solid #2a2a2a",borderRadius:o!=="desktop"?"1.5rem":"4px"},children:(0,Ee.jsx)("iframe",{ref:n,srcDoc:w,title:"NexusAI Preview",sandbox:"allow-scripts allow-same-origin allow-forms allow-modals",className:"w-full h-full border-0"},i)}):(0,Ee.jsx)(uE,{onSelect:E=>{let P=Ue.getState().getActiveInstance();if(P)Ue.getState().upsertInstance({...P,data:{...P.data,html:E.html,css:E.css,javascript:E.js}});else{let N="tpl-"+Date.now();Ue.getState().upsertInstance({id:N,shellType:"nexusai-preview",sourceChatId:"_default",label:"Template",data:{html:E.html,css:E.css,javascript:E.js}}),Ue.getState().setActiveInstance(N)}}})}),g&&(0,Ee.jsx)("div",{className:"w-1/2 shrink-0",children:(0,Ee.jsx)(aE,{code:m,onCodeChange:E=>{let P=Ue.getState().getActiveInstance();P&&Ue.getState().upsertInstance({...P,data:{...P.data,html:E.html,css:E.css,javascript:E.js}})}})})]}),v&&(0,Ee.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-surface-overlay backdrop-blur-xs",onClick:()=>S(!1),children:(0,Ee.jsxs)("div",{className:"bg-surface-tertiary border border-border-default rounded-2xl p-6 max-w-xs w-full shadow-2xl",onClick:E=>E.stopPropagation(),children:[(0,Ee.jsx)("h3",{className:"text-sm font-bold text-text-primary mb-4 flex items-center gap-2",children:"\u2328\uFE0F Atajos de Teclado"}),(0,Ee.jsx)("div",{className:"space-y-2 text-[11px]",children:[["\u2318 I","Inspector de elementos"],["\u2318 E","Editor de c\xF3digo"],["\u2318 D","Desplegar preview"],["\u2318 Z","Deshacer (topolog\xEDa)"],["\u2318 \u21E7 Z","Rehacer (topolog\xEDa)"],["\u2318 /","Esta ayuda"],["\u2318 B","Toggle sidebar"],["\u2318 \u21E7 C","Toggle modo Creator"],["\u2318 \u21E7 V","Toggle canvas"]].map(([E,P])=>(0,Ee.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Ee.jsx)("span",{className:"text-text-secondary",children:P}),(0,Ee.jsx)("kbd",{className:"px-2 py-0.5 bg-surface-glass border border-border-default rounded text-text-primary font-mono text-[10px]",children:E})]},E))}),(0,Ee.jsx)("button",{onClick:()=>S(!1),className:"w-full mt-4 py-2 bg-surface-glass hover:bg-surface-glass rounded-xl text-xs text-text-secondary transition",children:"Cerrar"})]})})]})}});function bE(){gE||(gE=!0,yi("markdown",Y2),yi("iframe",X2),yi("shell-theme-editor",Z2),yi("nexusai-preview",hE,{icon:"\u{1F310}",color:"#3b82f6",label:"Web Preview"}),yi("dataway-studio",rE,{icon:"\u0192",color:"#14b8a6",label:"Dataway M-Script Studio"}))}var gE,xE=U(()=>{"use strict";Vl();J2();Q2();nE();mE();gE=!1});function om(){(0,yE.useEffect)(()=>{let t=e=>{if(!(e.metaKey||e.ctrlKey))return;let n=Ue.getState();if(e.key==="w"&&n.activeInstanceId&&(e.preventDefault(),n.removeInstance(n.activeInstanceId)),e.key>="1"&&e.key<="9"){let o=parseInt(e.key)-1,s=n.getInstances();o<s.length&&(e.preventDefault(),n.setActiveInstance(s[o].id))}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[])}var yE,kx=U(()=>{"use strict";yE=require("react");mo()});var vE={};Mo(vE,{MorphShell:()=>nf});async function d8(t,e){let r=e||localStorage.getItem("decido_gemini_model")||"gemini-3-flash-preview",n=localStorage.getItem("google_gemini_api_key")||window.__DECIDO__?._apiKey||u8.env?.VITE_GEMINI_API_KEY||"";if(!n){console.error('\u274C No Gemini API key. Set localStorage "google_gemini_api_key" or VITE_GEMINI_API_KEY'),X.getState().addChatMessage({type:"error",sender:"system",text:"\u26A0\uFE0F No se encontr\xF3 API key de Gemini."});return}X.getState().addChatMessage({type:"text",sender:"user",text:t});let s=new AbortController;Ex=s;let i=[{type:"thinking",label:"Processing",startTime:Date.now()}];try{let a=`https://generativelanguage.googleapis.com/v1beta/models/${r}:streamGenerateContent?alt=sse&key=${n}`,l=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contents:[{role:"user",parts:[{text:t}]}],systemInstruction:{parts:[{text:"Eres Decido AI, un asistente del sistema operativo Decido OS. Responde en espa\xF1ol, s\xE9 conciso y \xFAtil."}]},generationConfig:{temperature:.7,maxOutputTokens:4096}}),signal:s.signal});if(!l.ok)throw new Error(`Gemini API ${l.status}: ${(await l.text()).slice(0,200)}`);i[0].endTime=Date.now(),i.push({type:"text_delta",label:"Streaming",startTime:Date.now()});let c=l.body?.getReader();if(!c)throw new Error("No reader");let d=new TextDecoder,u="",f=`gemini-${Date.now()}`,p="";for(;;){let{done:h,value:b}=await c.read();if(h)break;p+=d.decode(b,{stream:!0});let g=p.split(`
|
|
405
|
+
`);p=g.pop()||"";for(let x of g){let y=x.trim();if(!y.startsWith("data: "))continue;let m=y.slice(6);if(!(!m||m==="[DONE]"))try{let S=JSON.parse(m)?.candidates?.[0]?.content?.parts?.[0]?.text;S&&(u+=S,X.getState().upsertChatMessage(f,{id:f,type:"text",sender:"agent",text:u,timestamp:Date.now(),executionSteps:[...i]}))}catch(v){console.warn("[SSE] JSON parse failed:",m.slice(0,100),v)}}}if(p.trim().startsWith("data: "))try{let h=JSON.parse(p.trim().slice(6))?.candidates?.[0]?.content?.parts?.[0]?.text;h&&(u+=h)}catch{}i[1].endTime=Date.now(),i.push({type:"text_complete",label:"Complete",startTime:Date.now(),endTime:Date.now()}),X.getState().upsertChatMessage(f,{id:f,type:"text",sender:"agent",text:u,timestamp:Date.now(),executionSteps:i}),console.log("\u2705 Streaming complete:",u.length,"chars")}catch(a){a.name==="AbortError"?X.getState().addChatMessage({type:"alert",sender:"system",text:"\u23F9\uFE0F Generaci\xF3n cancelada."}):(console.error("\u274C",a.message),X.getState().addChatMessage({type:"error",sender:"system",text:`\u274C ${a.message}`}))}finally{Ex=null}}function nf({showCanvas:t=!0,setShowCanvas:e,activeConfig:r,prototypeBrand:n="",activeState:o,chartData:s=[],dragConstraintsRef:i}){om();let a=Ue(P=>P.getActiveInstance()),l=Ue(P=>P.removeInstance),c=ke(P=>P.activeStage),d=ke(P=>P.stageHistory),u=_t(P=>P.activeStage),f=_t(P=>P.stageHistory),p=ke(P=>P.isImmersive),h=ke(P=>P.setIsImmersive),b=c||u,g=c?d:f,x=X(P=>P.activeArtifactData),y=b||(x?{type:"artifact",data:x}:null),m=y?.type||"3d",v=Sx[m]||Sx.custom,S=v.icon,w=ke(P=>P.addTab);Ua.default.useEffect(()=>{if(!(!y&&!a)){if(a)w({id:`morph-${a.id}`,label:a.label,componentId:`morph:${a.shellType}`,closeable:!0,data:a});else if(y){let P=`morph-${m}-${y.label||"stage"}`;w({id:P,label:y.label||m.toUpperCase(),componentId:`morph:${m}`,closeable:!0,data:y})}}},[y?.type,y?.label,a?.id,a?.shellType]);let C=(0,Ua.useCallback)(()=>{a&&l(a.id),ke.getState().clearStages(),_t.getState().clearStages(),X.getState().setActiveArtifactData(null),e?.(!1)},[e,a,l]),A=(0,Ua.useCallback)(()=>{if(a){let P=Array.from(Ue.getState().instances.keys()),N=P.indexOf(a.id);if(ke.getState().removeTab(`morph-${a.id}`),l(a.id),P.length>1){let D=N>0?N-1:P.length-2,R=P.filter(O=>O!==a.id)[Math.min(D,P.length-2)];if(R){Ue.getState().setActiveInstance(R);let O=Ue.getState().instances.get(R);O?.sourceChatId&&X.getState().setActiveChatId(O.sourceChatId)}}else C()}else g.length>0?(ke.getState().popStage(),_t.getState().popStage()):C()},[a,g.length,C,l]),k=(0,Ua.useCallback)(()=>{h(!p)},[p,h]);if(!t)return null;let M=a&&Pa(a.shellType),T=a?.label||b?.label||(x?"Artefacto":"Lienzo"),E=a?.shellType||m;return(0,fr.jsx)(sm.AnimatePresence,{children:(0,fr.jsxs)(sm.motion.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"w-full h-full bg-surface-secondary flex flex-col overflow-hidden relative border-l border-border-subtle",children:[(0,fr.jsxs)("div",{className:"flex justify-between items-center pl-2 z-10 p-3 pb-0 shrink-0",children:[(0,fr.jsxs)("div",{className:"flex items-center gap-2",children:[(b||x||a)&&(0,fr.jsx)("button",{onClick:A,className:"p-1.5 rounded-lg hover:bg-surface-glass text-text-muted hover:text-text-primary transition-colors",title:"Volver",children:(0,fr.jsx)(Ga.ArrowLeft,{size:16})}),(0,fr.jsxs)("h2",{className:"text-sm font-bold flex items-center gap-2 text-text-primary",children:[(0,fr.jsx)("div",{className:"w-6 h-6 rounded-lg flex items-center justify-center bg-surface-glass",children:(0,fr.jsx)(S,{size:12,className:v.color})}),(0,fr.jsx)("span",{className:"truncate max-w-[180px]",children:T}),(0,fr.jsx)("span",{className:"text-text-muted font-mono text-[9px] ml-1",children:String(E).toUpperCase()})]})]}),(0,fr.jsxs)("div",{className:"flex items-center gap-2",children:[g.length>0&&(0,fr.jsxs)("div",{className:"hidden md:flex items-center gap-1 text-[9px] text-text-muted font-mono",children:[g.map((P,N)=>(0,fr.jsxs)(Ua.default.Fragment,{children:[(0,fr.jsx)("span",{className:"hover:text-text-secondary cursor-pointer",onClick:()=>{let D=g.length-N;for(let R=0;R<D;R++)ke.getState().popStage(),_t.getState().popStage()},children:P.label||P.type}),(0,fr.jsx)("span",{children:"\u203A"})]},N)),(0,fr.jsx)("span",{className:"text-text-secondary",children:T})]}),(0,fr.jsx)("button",{onClick:k,className:"p-1.5 rounded-lg hover:bg-surface-glass text-text-muted hover:text-text-primary transition-colors",title:p?"Salir de inmersivo":"Modo inmersivo",children:p?(0,fr.jsx)(Ga.Minimize2,{size:14}):(0,fr.jsx)(Ga.Maximize2,{size:14})}),(0,fr.jsx)("button",{onClick:C,className:"p-1.5 bg-surface-glass hover:bg-red-500/20 text-text-secondary hover:text-red-400 rounded-full transition-colors",children:(0,fr.jsx)(Ga.X,{size:14})})]})]}),a&&(0,fr.jsx)(rm,{instanceId:a.id}),(0,fr.jsx)("div",{className:"flex-1 relative overflow-hidden",children:M?Ua.default.createElement(Pa(a.shellType),{instanceId:a.id,data:a.data,artifacts:a.artifacts,activeArtifactIndex:a.activeArtifactIndex}):(0,fr.jsx)(tm,{showCanvas:!0,setShowCanvas:e||(()=>{}),activeConfig:r,prototypeBrand:n,activeState:o,chartData:s,dragConstraintsRef:i||void 0})})]})})}var Ua,sm,Ga,fr,u8,Ex,im=U(()=>{"use strict";Ua=Re(require("react")),sm=require("motion/react"),Ga=require("lucide-react");Qn();ys();ot();mo();Vl();vx();wx();q2();xE();kx();fr=require("react/jsx-runtime"),u8={};bE();Ex=null;typeof window<"u"&&(window.__DECIDO__={...window.__DECIDO__,useMorphInstanceStore:Ue,useLayoutStore:ke,useMorphologyStore:_t,usePlaygroundStore:X,registerShell:yi,resolveShell:Pa,getRegisteredShellTypes:pd,geminiStream:d8,geminiAbort:()=>Ex?.abort(),registerSuggestions:(t,e)=>{Promise.resolve().then(()=>(gh(),cC)).then(r=>r.useSuggestionsStore.getState().registerPluginSuggestions(t,e))},registerIntent:t=>{Promise.resolve().then(()=>(hd(),ox)).then(e=>e.registerIntentPattern(t))},getIntentPatterns:()=>Promise.resolve().then(()=>(hd(),ox)).then(t=>t.getIntentPatterns())})});function Gr(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let r=0,n;r<t.length;r++)(n=Gr(t[r]))!==""&&(e+=(e&&" ")+n);else for(let r in t)t[r]&&(e+=(e&&" ")+r);return e}var wE=U(()=>{"use strict"});function NE(){for(var t=0,e=arguments.length,r={},n;t<e;++t){if(!(n=arguments[t]+"")||n in r||/[\s.]/.test(n))throw new Error("illegal type: "+n);r[n]=[]}return new am(r)}function am(t){this._=t}function p8(t,e){return t.trim().split(/^|\s+/).map(function(r){var n="",o=r.indexOf(".");if(o>=0&&(n=r.slice(o+1),r=r.slice(0,o)),r&&!e.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:n}})}function h8(t,e){for(var r=0,n=t.length,o;r<n;++r)if((o=t[r]).name===e)return o.value}function SE(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=f8,t=t.slice(0,n).concat(t.slice(n+1));break}return r!=null&&t.push({name:e,value:r}),t}var f8,Kl,CE=U(()=>{"use strict";f8={value:()=>{}};am.prototype=NE.prototype={constructor:am,on:function(t,e){var r=this._,n=p8(t+"",r),o,s=-1,i=n.length;if(arguments.length<2){for(;++s<i;)if((o=(t=n[s]).type)&&(o=h8(r[o],t.name)))return o;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<i;)if(o=(t=n[s]).type)r[o]=SE(r[o],t.name,e);else if(e==null)for(o in r)r[o]=SE(r[o],t.name,null);return this},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new am(t)},call:function(t,e){if((o=arguments.length-2)>0)for(var r=new Array(o),n=0,o,s;n<o;++n)r[n]=arguments[n+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(s=this._[t],n=0,o=s.length;n<o;++n)s[n].value.apply(e,r)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],o=0,s=n.length;o<s;++o)n[o].value.apply(e,r)}};Kl=NE});var lm=U(()=>{"use strict";CE()});var cm,Tx,Ix=U(()=>{"use strict";cm="http://www.w3.org/1999/xhtml",Tx={svg:"http://www.w3.org/2000/svg",xhtml:cm,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"}});function ra(t){var e=t+="",r=e.indexOf(":");return r>=0&&(e=t.slice(0,r))!=="xmlns"&&(t=t.slice(r+1)),Tx.hasOwnProperty(e)?{space:Tx[e],local:t}:t}var dm=U(()=>{"use strict";Ix()});function m8(t){return function(){var e=this.ownerDocument,r=this.namespaceURI;return r===cm&&e.documentElement.namespaceURI===cm?e.createElement(t):e.createElementNS(r,t)}}function g8(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function um(t){var e=ra(t);return(e.local?g8:m8)(e)}var Ax=U(()=>{"use strict";dm();Ix()});function b8(){}function ql(t){return t==null?b8:function(){return this.querySelector(t)}}var fm=U(()=>{"use strict"});function kE(t){typeof t!="function"&&(t=ql(t));for(var e=this._groups,r=e.length,n=new Array(r),o=0;o<r;++o)for(var s=e[o],i=s.length,a=n[o]=new Array(i),l,c,d=0;d<i;++d)(l=s[d])&&(c=t.call(l,l.__data__,d,s))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new Kr(n,this._parents)}var EE=U(()=>{"use strict";Ys();fm()});function Mx(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}var TE=U(()=>{"use strict"});function x8(){return[]}function of(t){return t==null?x8:function(){return this.querySelectorAll(t)}}var Px=U(()=>{"use strict"});function y8(t){return function(){return Mx(t.apply(this,arguments))}}function IE(t){typeof t=="function"?t=y8(t):t=of(t);for(var e=this._groups,r=e.length,n=[],o=[],s=0;s<r;++s)for(var i=e[s],a=i.length,l,c=0;c<a;++c)(l=i[c])&&(n.push(t.call(l,l.__data__,c,i)),o.push(l));return new Kr(n,o)}var AE=U(()=>{"use strict";Ys();TE();Px()});function sf(t){return function(){return this.matches(t)}}function pm(t){return function(e){return e.matches(t)}}var af=U(()=>{"use strict"});function w8(t){return function(){return v8.call(this.children,t)}}function S8(){return this.firstElementChild}function ME(t){return this.select(t==null?S8:w8(typeof t=="function"?t:pm(t)))}var v8,PE=U(()=>{"use strict";af();v8=Array.prototype.find});function C8(){return Array.from(this.children)}function k8(t){return function(){return N8.call(this.children,t)}}function RE(t){return this.selectAll(t==null?C8:k8(typeof t=="function"?t:pm(t)))}var N8,DE=U(()=>{"use strict";af();N8=Array.prototype.filter});function OE(t){typeof t!="function"&&(t=sf(t));for(var e=this._groups,r=e.length,n=new Array(r),o=0;o<r;++o)for(var s=e[o],i=s.length,a=n[o]=[],l,c=0;c<i;++c)(l=s[c])&&t.call(l,l.__data__,c,s)&&a.push(l);return new Kr(n,this._parents)}var _E=U(()=>{"use strict";Ys();af()});function hm(t){return new Array(t.length)}var Rx=U(()=>{"use strict"});function LE(){return new Kr(this._enter||this._groups.map(hm),this._parents)}function lf(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}var Dx=U(()=>{"use strict";Rx();Ys();lf.prototype={constructor:lf,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}}});function BE(t){return function(){return t}}var zE=U(()=>{"use strict"});function E8(t,e,r,n,o,s){for(var i=0,a,l=e.length,c=s.length;i<c;++i)(a=e[i])?(a.__data__=s[i],n[i]=a):r[i]=new lf(t,s[i]);for(;i<l;++i)(a=e[i])&&(o[i]=a)}function T8(t,e,r,n,o,s,i){var a,l,c=new Map,d=e.length,u=s.length,f=new Array(d),p;for(a=0;a<d;++a)(l=e[a])&&(f[a]=p=i.call(l,l.__data__,a,e)+"",c.has(p)?o[a]=l:c.set(p,l));for(a=0;a<u;++a)p=i.call(t,s[a],a,s)+"",(l=c.get(p))?(n[a]=l,l.__data__=s[a],c.delete(p)):r[a]=new lf(t,s[a]);for(a=0;a<d;++a)(l=e[a])&&c.get(f[a])===l&&(o[a]=l)}function I8(t){return t.__data__}function $E(t,e){if(!arguments.length)return Array.from(this,I8);var r=e?T8:E8,n=this._parents,o=this._groups;typeof t!="function"&&(t=BE(t));for(var s=o.length,i=new Array(s),a=new Array(s),l=new Array(s),c=0;c<s;++c){var d=n[c],u=o[c],f=u.length,p=A8(t.call(d,d&&d.__data__,c,n)),h=p.length,b=a[c]=new Array(h),g=i[c]=new Array(h),x=l[c]=new Array(f);r(d,u,b,g,x,p,e);for(var y=0,m=0,v,S;y<h;++y)if(v=b[y]){for(y>=m&&(m=y+1);!(S=g[m])&&++m<h;);v._next=S||null}}return i=new Kr(i,n),i._enter=a,i._exit=l,i}function A8(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}var FE=U(()=>{"use strict";Ys();Dx();zE()});function HE(){return new Kr(this._exit||this._groups.map(hm),this._parents)}var VE=U(()=>{"use strict";Rx();Ys()});function jE(t,e,r){var n=this.enter(),o=this,s=this.exit();return typeof t=="function"?(n=t(n),n&&(n=n.selection())):n=n.append(t+""),e!=null&&(o=e(o),o&&(o=o.selection())),r==null?s.remove():r(s),n&&o?n.merge(o).order():o}var WE=U(()=>{"use strict"});function UE(t){for(var e=t.selection?t.selection():t,r=this._groups,n=e._groups,o=r.length,s=n.length,i=Math.min(o,s),a=new Array(o),l=0;l<i;++l)for(var c=r[l],d=n[l],u=c.length,f=a[l]=new Array(u),p,h=0;h<u;++h)(p=c[h]||d[h])&&(f[h]=p);for(;l<o;++l)a[l]=r[l];return new Kr(a,this._parents)}var GE=U(()=>{"use strict";Ys()});function KE(){for(var t=this._groups,e=-1,r=t.length;++e<r;)for(var n=t[e],o=n.length-1,s=n[o],i;--o>=0;)(i=n[o])&&(s&&i.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(i,s),s=i);return this}var qE=U(()=>{"use strict"});function YE(t){t||(t=M8);function e(u,f){return u&&f?t(u.__data__,f.__data__):!u-!f}for(var r=this._groups,n=r.length,o=new Array(n),s=0;s<n;++s){for(var i=r[s],a=i.length,l=o[s]=new Array(a),c,d=0;d<a;++d)(c=i[d])&&(l[d]=c);l.sort(e)}return new Kr(o,this._parents).order()}function M8(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}var XE=U(()=>{"use strict";Ys()});function JE(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}var ZE=U(()=>{"use strict"});function QE(){return Array.from(this)}var eT=U(()=>{"use strict"});function tT(){for(var t=this._groups,e=0,r=t.length;e<r;++e)for(var n=t[e],o=0,s=n.length;o<s;++o){var i=n[o];if(i)return i}return null}var rT=U(()=>{"use strict"});function nT(){let t=0;for(let e of this)++t;return t}var oT=U(()=>{"use strict"});function sT(){return!this.node()}var iT=U(()=>{"use strict"});function aT(t){for(var e=this._groups,r=0,n=e.length;r<n;++r)for(var o=e[r],s=0,i=o.length,a;s<i;++s)(a=o[s])&&t.call(a,a.__data__,s,o);return this}var lT=U(()=>{"use strict"});function P8(t){return function(){this.removeAttribute(t)}}function R8(t){return function(){this.removeAttributeNS(t.space,t.local)}}function D8(t,e){return function(){this.setAttribute(t,e)}}function O8(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function _8(t,e){return function(){var r=e.apply(this,arguments);r==null?this.removeAttribute(t):this.setAttribute(t,r)}}function L8(t,e){return function(){var r=e.apply(this,arguments);r==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,r)}}function cT(t,e){var r=ra(t);if(arguments.length<2){var n=this.node();return r.local?n.getAttributeNS(r.space,r.local):n.getAttribute(r)}return this.each((e==null?r.local?R8:P8:typeof e=="function"?r.local?L8:_8:r.local?O8:D8)(r,e))}var dT=U(()=>{"use strict";dm()});function mm(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}var Ox=U(()=>{"use strict"});function B8(t){return function(){this.style.removeProperty(t)}}function z8(t,e,r){return function(){this.style.setProperty(t,e,r)}}function $8(t,e,r){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(t):this.style.setProperty(t,n,r)}}function uT(t,e,r){return arguments.length>1?this.each((e==null?B8:typeof e=="function"?$8:z8)(t,e,r??"")):Ka(this.node(),t)}function Ka(t,e){return t.style.getPropertyValue(e)||mm(t).getComputedStyle(t,null).getPropertyValue(e)}var _x=U(()=>{"use strict";Ox()});function F8(t){return function(){delete this[t]}}function H8(t,e){return function(){this[t]=e}}function V8(t,e){return function(){var r=e.apply(this,arguments);r==null?delete this[t]:this[t]=r}}function fT(t,e){return arguments.length>1?this.each((e==null?F8:typeof e=="function"?V8:H8)(t,e)):this.node()[t]}var pT=U(()=>{"use strict"});function hT(t){return t.trim().split(/^|\s+/)}function Lx(t){return t.classList||new mT(t)}function mT(t){this._node=t,this._names=hT(t.getAttribute("class")||"")}function gT(t,e){for(var r=Lx(t),n=-1,o=e.length;++n<o;)r.add(e[n])}function bT(t,e){for(var r=Lx(t),n=-1,o=e.length;++n<o;)r.remove(e[n])}function j8(t){return function(){gT(this,t)}}function W8(t){return function(){bT(this,t)}}function U8(t,e){return function(){(e.apply(this,arguments)?gT:bT)(this,t)}}function xT(t,e){var r=hT(t+"");if(arguments.length<2){for(var n=Lx(this.node()),o=-1,s=r.length;++o<s;)if(!n.contains(r[o]))return!1;return!0}return this.each((typeof e=="function"?U8:e?j8:W8)(r,e))}var yT=U(()=>{"use strict";mT.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}}});function G8(){this.textContent=""}function K8(t){return function(){this.textContent=t}}function q8(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function vT(t){return arguments.length?this.each(t==null?G8:(typeof t=="function"?q8:K8)(t)):this.node().textContent}var wT=U(()=>{"use strict"});function Y8(){this.innerHTML=""}function X8(t){return function(){this.innerHTML=t}}function J8(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function ST(t){return arguments.length?this.each(t==null?Y8:(typeof t=="function"?J8:X8)(t)):this.node().innerHTML}var NT=U(()=>{"use strict"});function Z8(){this.nextSibling&&this.parentNode.appendChild(this)}function CT(){return this.each(Z8)}var kT=U(()=>{"use strict"});function Q8(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ET(){return this.each(Q8)}var TT=U(()=>{"use strict"});function IT(t){var e=typeof t=="function"?t:um(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}var AT=U(()=>{"use strict";Ax()});function eF(){return null}function MT(t,e){var r=typeof t=="function"?t:um(t),n=e==null?eF:typeof e=="function"?e:ql(e);return this.select(function(){return this.insertBefore(r.apply(this,arguments),n.apply(this,arguments)||null)})}var PT=U(()=>{"use strict";Ax();fm()});function tF(){var t=this.parentNode;t&&t.removeChild(this)}function RT(){return this.each(tF)}var DT=U(()=>{"use strict"});function rF(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function nF(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function OT(t){return this.select(t?nF:rF)}var _T=U(()=>{"use strict"});function LT(t){return arguments.length?this.property("__data__",t):this.node().__data__}var BT=U(()=>{"use strict"});function oF(t){return function(e){t.call(this,e,this.__data__)}}function sF(t){return t.trim().split(/^|\s+/).map(function(e){var r="",n=e.indexOf(".");return n>=0&&(r=e.slice(n+1),e=e.slice(0,n)),{type:e,name:r}})}function iF(t){return function(){var e=this.__on;if(e){for(var r=0,n=-1,o=e.length,s;r<o;++r)s=e[r],(!t.type||s.type===t.type)&&s.name===t.name?this.removeEventListener(s.type,s.listener,s.options):e[++n]=s;++n?e.length=n:delete this.__on}}}function aF(t,e,r){return function(){var n=this.__on,o,s=oF(e);if(n){for(var i=0,a=n.length;i<a;++i)if((o=n[i]).type===t.type&&o.name===t.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=s,o.options=r),o.value=e;return}}this.addEventListener(t.type,s,r),o={type:t.type,name:t.name,value:e,listener:s,options:r},n?n.push(o):this.__on=[o]}}function zT(t,e,r){var n=sF(t+""),o,s=n.length,i;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(o=0,d=a[l];o<s;++o)if((i=n[o]).type===d.type&&i.name===d.name)return d.value}return}for(a=e?aF:iF,o=0;o<s;++o)this.each(a(n[o],e,r));return this}var $T=U(()=>{"use strict"});function FT(t,e,r){var n=mm(t),o=n.CustomEvent;typeof o=="function"?o=new o(e,r):(o=n.document.createEvent("Event"),r?(o.initEvent(e,r.bubbles,r.cancelable),o.detail=r.detail):o.initEvent(e,!1,!1)),t.dispatchEvent(o)}function lF(t,e){return function(){return FT(this,t,e)}}function cF(t,e){return function(){return FT(this,t,e.apply(this,arguments))}}function HT(t,e){return this.each((typeof e=="function"?cF:lF)(t,e))}var VT=U(()=>{"use strict";Ox()});function*jT(){for(var t=this._groups,e=0,r=t.length;e<r;++e)for(var n=t[e],o=0,s=n.length,i;o<s;++o)(i=n[o])&&(yield i)}var WT=U(()=>{"use strict"});function Kr(t,e){this._groups=t,this._parents=e}function UT(){return new Kr([[document.documentElement]],Bx)}function dF(){return this}var Bx,na,Ys=U(()=>{"use strict";EE();AE();PE();DE();_E();FE();Dx();VE();WE();GE();qE();XE();ZE();eT();rT();oT();iT();lT();dT();_x();pT();yT();wT();NT();kT();TT();AT();PT();DT();_T();BT();$T();VT();WT();Bx=[null];Kr.prototype=UT.prototype={constructor:Kr,select:kE,selectAll:IE,selectChild:ME,selectChildren:RE,filter:OE,data:$E,enter:LE,exit:HE,join:jE,merge:UE,selection:dF,order:KE,sort:YE,call:JE,nodes:QE,node:tT,size:nT,empty:sT,each:aT,attr:cT,style:uT,property:fT,classed:xT,text:vT,html:ST,raise:CT,lower:ET,append:IT,insert:MT,remove:RT,clone:OT,datum:LT,on:zT,dispatch:HT,[Symbol.iterator]:jT};na=UT});function On(t){return typeof t=="string"?new Kr([[document.querySelector(t)]],[document.documentElement]):new Kr([[t]],Bx)}var GT=U(()=>{"use strict";Ys()});function KT(t){let e;for(;e=t.sourceEvent;)t=e;return t}var qT=U(()=>{"use strict"});function yo(t,e){if(t=KT(t),e===void 0&&(e=t.currentTarget),e){var r=e.ownerSVGElement||e;if(r.createSVGPoint){var n=r.createSVGPoint();return n.x=t.clientX,n.y=t.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var o=e.getBoundingClientRect();return[t.clientX-o.left-e.clientLeft,t.clientY-o.top-e.clientTop]}}return[t.pageX,t.pageY]}var YT=U(()=>{"use strict";qT()});var Oo=U(()=>{"use strict";af();dm();YT();GT();Ys();fm();Px();_x()});function gm(t){t.stopImmediatePropagation()}function qa(t){t.preventDefault(),t.stopImmediatePropagation()}var XT,Yl,zx=U(()=>{"use strict";XT={passive:!1},Yl={capture:!0,passive:!1}});function cf(t){var e=t.document.documentElement,r=On(t).on("dragstart.drag",qa,Yl);"onselectstart"in e?r.on("selectstart.drag",qa,Yl):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function df(t,e){var r=t.document.documentElement,n=On(t).on("dragstart.drag",null);e&&(n.on("click.drag",qa,Yl),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in r?n.on("selectstart.drag",null):(r.style.MozUserSelect=r.__noselect,delete r.__noselect)}var $x=U(()=>{"use strict";Oo();zx()});var uf,JT=U(()=>{"use strict";uf=t=>()=>t});function ff(t,{sourceEvent:e,subject:r,target:n,identifier:o,active:s,x:i,y:a,dx:l,dy:c,dispatch:d}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:d}})}var ZT=U(()=>{"use strict";ff.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t}});function uF(t){return!t.ctrlKey&&!t.button}function fF(){return this.parentNode}function pF(t,e){return e??{x:t.x,y:t.y}}function hF(){return navigator.maxTouchPoints||"ontouchstart"in this}function bm(){var t=uF,e=fF,r=pF,n=hF,o={},s=Kl("start","drag","end"),i=0,a,l,c,d,u=0;function f(v){v.on("mousedown.drag",p).filter(n).on("touchstart.drag",g).on("touchmove.drag",x,XT).on("touchend.drag touchcancel.drag",y).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(v,S){if(!(d||!t.call(this,v,S))){var w=m(this,e.call(this,v,S),v,S,"mouse");w&&(On(v.view).on("mousemove.drag",h,Yl).on("mouseup.drag",b,Yl),cf(v.view),gm(v),c=!1,a=v.clientX,l=v.clientY,w("start",v))}}function h(v){if(qa(v),!c){var S=v.clientX-a,w=v.clientY-l;c=S*S+w*w>u}o.mouse("drag",v)}function b(v){On(v.view).on("mousemove.drag mouseup.drag",null),df(v.view,c),qa(v),o.mouse("end",v)}function g(v,S){if(t.call(this,v,S)){var w=v.changedTouches,C=e.call(this,v,S),A=w.length,k,M;for(k=0;k<A;++k)(M=m(this,C,v,S,w[k].identifier,w[k]))&&(gm(v),M("start",v,w[k]))}}function x(v){var S=v.changedTouches,w=S.length,C,A;for(C=0;C<w;++C)(A=o[S[C].identifier])&&(qa(v),A("drag",v,S[C]))}function y(v){var S=v.changedTouches,w=S.length,C,A;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),C=0;C<w;++C)(A=o[S[C].identifier])&&(gm(v),A("end",v,S[C]))}function m(v,S,w,C,A,k){var M=s.copy(),T=yo(k||w,S),E,P,N;if((N=r.call(v,new ff("beforestart",{sourceEvent:w,target:f,identifier:A,active:i,x:T[0],y:T[1],dx:0,dy:0,dispatch:M}),C))!=null)return E=N.x-T[0]||0,P=N.y-T[1]||0,function D(R,O,B){var L=T,H;switch(R){case"start":o[A]=D,H=i++;break;case"end":delete o[A],--i;case"drag":T=yo(B||O,S),H=i;break}M.call(R,v,new ff(R,{sourceEvent:O,subject:N,target:f,identifier:A,active:H,x:T[0]+E,y:T[1]+P,dx:T[0]-L[0],dy:T[1]-L[1],dispatch:M}),C)}}return f.filter=function(v){return arguments.length?(t=typeof v=="function"?v:uf(!!v),f):t},f.container=function(v){return arguments.length?(e=typeof v=="function"?v:uf(v),f):e},f.subject=function(v){return arguments.length?(r=typeof v=="function"?v:uf(v),f):r},f.touchable=function(v){return arguments.length?(n=typeof v=="function"?v:uf(!!v),f):n},f.on=function(){var v=s.on.apply(s,arguments);return v===s?f:v},f.clickDistance=function(v){return arguments.length?(u=(v=+v)*v,f):Math.sqrt(u)},f}var QT=U(()=>{"use strict";lm();Oo();$x();zx();JT();ZT()});var Fx=U(()=>{"use strict";QT();$x()});function xm(t,e,r){t.prototype=e.prototype=r,r.constructor=t}function Hx(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}var e5=U(()=>{"use strict"});function mf(){}function r5(){return this.rgb().formatHex()}function SF(){return this.rgb().formatHex8()}function NF(){return c5(this).formatHsl()}function n5(){return this.rgb().formatRgb()}function Js(t){var e,r;return t=(t+"").trim().toLowerCase(),(e=mF.exec(t))?(r=e[1].length,e=parseInt(e[1],16),r===6?o5(e):r===3?new _o(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):r===8?ym(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):r===4?ym(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=gF.exec(t))?new _o(e[1],e[2],e[3],1):(e=bF.exec(t))?new _o(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=xF.exec(t))?ym(e[1],e[2],e[3],e[4]):(e=yF.exec(t))?ym(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=vF.exec(t))?a5(e[1],e[2]/100,e[3]/100,1):(e=wF.exec(t))?a5(e[1],e[2]/100,e[3]/100,e[4]):t5.hasOwnProperty(t)?o5(t5[t]):t==="transparent"?new _o(NaN,NaN,NaN,0):null}function o5(t){return new _o(t>>16&255,t>>8&255,t&255,1)}function ym(t,e,r,n){return n<=0&&(t=e=r=NaN),new _o(t,e,r,n)}function CF(t){return t instanceof mf||(t=Js(t)),t?(t=t.rgb(),new _o(t.r,t.g,t.b,t.opacity)):new _o}function Md(t,e,r,n){return arguments.length===1?CF(t):new _o(t,e,r,n??1)}function _o(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}function s5(){return`#${Xl(this.r)}${Xl(this.g)}${Xl(this.b)}`}function kF(){return`#${Xl(this.r)}${Xl(this.g)}${Xl(this.b)}${Xl((isNaN(this.opacity)?1:this.opacity)*255)}`}function i5(){let t=Sm(this.opacity);return`${t===1?"rgb(":"rgba("}${Jl(this.r)}, ${Jl(this.g)}, ${Jl(this.b)}${t===1?")":`, ${t})`}`}function Sm(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Jl(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Xl(t){return t=Jl(t),(t<16?"0":"")+t.toString(16)}function a5(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new Xs(t,e,r,n)}function c5(t){if(t instanceof Xs)return new Xs(t.h,t.s,t.l,t.opacity);if(t instanceof mf||(t=Js(t)),!t)return new Xs;if(t instanceof Xs)return t;t=t.rgb();var e=t.r/255,r=t.g/255,n=t.b/255,o=Math.min(e,r,n),s=Math.max(e,r,n),i=NaN,a=s-o,l=(s+o)/2;return a?(e===s?i=(r-n)/a+(r<n)*6:r===s?i=(n-e)/a+2:i=(e-r)/a+4,a/=l<.5?s+o:2-s-o,i*=60):a=l>0&&l<1?0:i,new Xs(i,a,l,t.opacity)}function d5(t,e,r,n){return arguments.length===1?c5(t):new Xs(t,e,r,n??1)}function Xs(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}function l5(t){return t=(t||0)%360,t<0?t+360:t}function vm(t){return Math.max(0,Math.min(1,t||0))}function Vx(t,e,r){return(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)*255}var pf,wm,Ad,hf,Ii,mF,gF,bF,xF,yF,vF,wF,t5,u5=U(()=>{"use strict";e5();pf=.7,wm=1/pf,Ad="\\s*([+-]?\\d+)\\s*",hf="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ii="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",mF=/^#([0-9a-f]{3,8})$/,gF=new RegExp(`^rgb\\(${Ad},${Ad},${Ad}\\)$`),bF=new RegExp(`^rgb\\(${Ii},${Ii},${Ii}\\)$`),xF=new RegExp(`^rgba\\(${Ad},${Ad},${Ad},${hf}\\)$`),yF=new RegExp(`^rgba\\(${Ii},${Ii},${Ii},${hf}\\)$`),vF=new RegExp(`^hsl\\(${hf},${Ii},${Ii}\\)$`),wF=new RegExp(`^hsla\\(${hf},${Ii},${Ii},${hf}\\)$`),t5={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};xm(mf,Js,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:r5,formatHex:r5,formatHex8:SF,formatHsl:NF,formatRgb:n5,toString:n5});xm(_o,Md,Hx(mf,{brighter(t){return t=t==null?wm:Math.pow(wm,t),new _o(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?pf:Math.pow(pf,t),new _o(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new _o(Jl(this.r),Jl(this.g),Jl(this.b),Sm(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:s5,formatHex:s5,formatHex8:kF,formatRgb:i5,toString:i5}));xm(Xs,d5,Hx(mf,{brighter(t){return t=t==null?wm:Math.pow(wm,t),new Xs(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?pf:Math.pow(pf,t),new Xs(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,o=2*r-n;return new _o(Vx(t>=240?t-240:t+120,o,n),Vx(t,o,n),Vx(t<120?t+240:t-120,o,n),this.opacity)},clamp(){return new Xs(l5(this.h),vm(this.s),vm(this.l),Sm(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let t=Sm(this.opacity);return`${t===1?"hsl(":"hsla("}${l5(this.h)}, ${vm(this.s)*100}%, ${vm(this.l)*100}%${t===1?")":`, ${t})`}`}}))});var Nm=U(()=>{"use strict";u5()});function jx(t,e,r,n,o){var s=t*t,i=s*t;return((1-3*t+3*s-i)*e+(4-6*s+3*i)*r+(1+3*t+3*s-3*i)*n+i*o)/6}function f5(t){var e=t.length-1;return function(r){var n=r<=0?r=0:r>=1?(r=1,e-1):Math.floor(r*e),o=t[n],s=t[n+1],i=n>0?t[n-1]:2*o-s,a=n<e-1?t[n+2]:2*s-o;return jx((r-n/e)*e,i,o,s,a)}}var Wx=U(()=>{"use strict"});function p5(t){var e=t.length;return function(r){var n=Math.floor(((r%=1)<0?++r:r)*e),o=t[(n+e-1)%e],s=t[n%e],i=t[(n+1)%e],a=t[(n+2)%e];return jx((r-n/e)*e,o,s,i,a)}}var h5=U(()=>{"use strict";Wx()});var gf,Ux=U(()=>{"use strict";gf=t=>()=>t});function EF(t,e){return function(r){return t+r*e}}function TF(t,e,r){return t=Math.pow(t,r),e=Math.pow(e,r)-t,r=1/r,function(n){return Math.pow(t+n*e,r)}}function m5(t){return(t=+t)==1?Cm:function(e,r){return r-e?TF(e,r,t):gf(isNaN(e)?r:e)}}function Cm(t,e){var r=e-t;return r?EF(t,r):gf(isNaN(t)?e:t)}var g5=U(()=>{"use strict";Ux()});function b5(t){return function(e){var r=e.length,n=new Array(r),o=new Array(r),s=new Array(r),i,a;for(i=0;i<r;++i)a=Md(e[i]),n[i]=a.r||0,o[i]=a.g||0,s[i]=a.b||0;return n=t(n),o=t(o),s=t(s),a.opacity=1,function(l){return a.r=n(l),a.g=o(l),a.b=s(l),a+""}}}var Zl,IF,AF,Gx=U(()=>{"use strict";Nm();Wx();h5();g5();Zl=(function t(e){var r=m5(e);function n(o,s){var i=r((o=Md(o)).r,(s=Md(s)).r),a=r(o.g,s.g),l=r(o.b,s.b),c=Cm(o.opacity,s.opacity);return function(d){return o.r=i(d),o.g=a(d),o.b=l(d),o.opacity=c(d),o+""}}return n.gamma=t,n})(1);IF=b5(f5),AF=b5(p5)});function x5(t,e){e||(e=[]);var r=t?Math.min(e.length,t.length):0,n=e.slice(),o;return function(s){for(o=0;o<r;++o)n[o]=t[o]*(1-s)+e[o]*s;return n}}function y5(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}var v5=U(()=>{"use strict"});function w5(t,e){var r=e?e.length:0,n=t?Math.min(r,t.length):0,o=new Array(n),s=new Array(r),i;for(i=0;i<n;++i)o[i]=oa(t[i],e[i]);for(;i<r;++i)s[i]=e[i];return function(a){for(i=0;i<n;++i)s[i]=o[i](a);return s}}var S5=U(()=>{"use strict";km()});function N5(t,e){var r=new Date;return t=+t,e=+e,function(n){return r.setTime(t*(1-n)+e*n),r}}var C5=U(()=>{"use strict"});function vo(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}var bf=U(()=>{"use strict"});function k5(t,e){var r={},n={},o;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(o in e)o in t?r[o]=oa(t[o],e[o]):n[o]=e[o];return function(s){for(o in r)n[o]=r[o](s);return n}}var E5=U(()=>{"use strict";km()});function MF(t){return function(){return t}}function PF(t){return function(e){return t(e)+""}}function xf(t,e){var r=qx.lastIndex=Kx.lastIndex=0,n,o,s,i=-1,a=[],l=[];for(t=t+"",e=e+"";(n=qx.exec(t))&&(o=Kx.exec(e));)(s=o.index)>r&&(s=e.slice(r,s),a[i]?a[i]+=s:a[++i]=s),(n=n[0])===(o=o[0])?a[i]?a[i]+=o:a[++i]=o:(a[++i]=null,l.push({i,x:vo(n,o)})),r=Kx.lastIndex;return r<e.length&&(s=e.slice(r),a[i]?a[i]+=s:a[++i]=s),a.length<2?l[0]?PF(l[0].x):MF(e):(e=l.length,function(c){for(var d=0,u;d<e;++d)a[(u=l[d]).i]=u.x(c);return a.join("")})}var qx,Kx,Yx=U(()=>{"use strict";bf();qx=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Kx=new RegExp(qx.source,"g")});function oa(t,e){var r=typeof e,n;return e==null||r==="boolean"?gf(e):(r==="number"?vo:r==="string"?(n=Js(e))?(e=n,Zl):xf:e instanceof Js?Zl:e instanceof Date?N5:y5(e)?x5:Array.isArray(e)?w5:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?k5:vo)(t,e)}var km=U(()=>{"use strict";Nm();Gx();S5();C5();bf();E5();Yx();Ux();v5()});function Xx(t,e,r,n,o,s){var i,a,l;return(i=Math.sqrt(t*t+e*e))&&(t/=i,e/=i),(l=t*r+e*n)&&(r-=t*l,n-=e*l),(a=Math.sqrt(r*r+n*n))&&(r/=a,n/=a,l/=a),t*n<e*r&&(t=-t,e=-e,l=-l,i=-i),{translateX:o,translateY:s,rotate:Math.atan2(e,t)*T5,skewX:Math.atan(l)*T5,scaleX:i,scaleY:a}}var T5,Em,I5=U(()=>{"use strict";T5=180/Math.PI,Em={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1}});function A5(t){let e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Em:Xx(e.a,e.b,e.c,e.d,e.e,e.f)}function M5(t){return t==null?Em:(Tm||(Tm=document.createElementNS("http://www.w3.org/2000/svg","g")),Tm.setAttribute("transform",t),(t=Tm.transform.baseVal.consolidate())?(t=t.matrix,Xx(t.a,t.b,t.c,t.d,t.e,t.f)):Em)}var Tm,P5=U(()=>{"use strict";I5()});function R5(t,e,r,n){function o(c){return c.length?c.pop()+" ":""}function s(c,d,u,f,p,h){if(c!==u||d!==f){var b=p.push("translate(",null,e,null,r);h.push({i:b-4,x:vo(c,u)},{i:b-2,x:vo(d,f)})}else(u||f)&&p.push("translate("+u+e+f+r)}function i(c,d,u,f){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),f.push({i:u.push(o(u)+"rotate(",null,n)-2,x:vo(c,d)})):d&&u.push(o(u)+"rotate("+d+n)}function a(c,d,u,f){c!==d?f.push({i:u.push(o(u)+"skewX(",null,n)-2,x:vo(c,d)}):d&&u.push(o(u)+"skewX("+d+n)}function l(c,d,u,f,p,h){if(c!==u||d!==f){var b=p.push(o(p)+"scale(",null,",",null,")");h.push({i:b-4,x:vo(c,u)},{i:b-2,x:vo(d,f)})}else(u!==1||f!==1)&&p.push(o(p)+"scale("+u+","+f+")")}return function(c,d){var u=[],f=[];return c=t(c),d=t(d),s(c.translateX,c.translateY,d.translateX,d.translateY,u,f),i(c.rotate,d.rotate,u,f),a(c.skewX,d.skewX,u,f),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,f),c=d=null,function(p){for(var h=-1,b=f.length,g;++h<b;)u[(g=f[h]).i]=g.x(p);return u.join("")}}}var Jx,Zx,D5=U(()=>{"use strict";bf();P5();Jx=R5(A5,"px, ","px)","deg)"),Zx=R5(M5,", ",")",")")});function O5(t){return((t=Math.exp(t))+1/t)/2}function DF(t){return((t=Math.exp(t))-1/t)/2}function OF(t){return((t=Math.exp(2*t))-1)/(t+1)}var RF,Ql,_5=U(()=>{"use strict";RF=1e-12;Ql=(function t(e,r,n){function o(s,i){var a=s[0],l=s[1],c=s[2],d=i[0],u=i[1],f=i[2],p=d-a,h=u-l,b=p*p+h*h,g,x;if(b<RF)x=Math.log(f/c)/e,g=function(C){return[a+C*p,l+C*h,c*Math.exp(e*C*x)]};else{var y=Math.sqrt(b),m=(f*f-c*c+n*b)/(2*c*r*y),v=(f*f-c*c-n*b)/(2*f*r*y),S=Math.log(Math.sqrt(m*m+1)-m),w=Math.log(Math.sqrt(v*v+1)-v);x=(w-S)/e,g=function(C){var A=C*x,k=O5(S),M=c/(r*y)*(k*OF(e*A+S)-DF(S));return[a+M*p,l+M*h,c*k/O5(e*A+S)]}}return g.duration=x*1e3*e/Math.SQRT2,g}return o.rho=function(s){var i=Math.max(.001,+s),a=i*i,l=a*a;return t(i,a,l)},o})(Math.SQRT2,2,4)});var Pd=U(()=>{"use strict";km();bf();Yx();D5();_5();Gx()});function Cf(){return ec||(z5(_F),ec=Sf.now()+Mm)}function _F(){ec=0}function Nf(){this._call=this._time=this._next=null}function Pm(t,e,r){var n=new Nf;return n.restart(t,e,r),n}function $5(){Cf(),++Rd;for(var t=Im,e;t;)(e=ec-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Rd}function L5(){ec=(Am=Sf.now())+Mm,Rd=vf=0;try{$5()}finally{Rd=0,BF(),ec=0}}function LF(){var t=Sf.now(),e=t-Am;e>B5&&(Mm-=e,Am=t)}function BF(){for(var t,e=Im,r,n=1/0;e;)e._call?(n>e._time&&(n=e._time),t=e,e=e._next):(r=e._next,e._next=null,e=t?t._next=r:Im=r);wf=t,Qx(n)}function Qx(t){if(!Rd){vf&&(vf=clearTimeout(vf));var e=t-ec;e>24?(t<1/0&&(vf=setTimeout(L5,t-Sf.now()-Mm)),yf&&(yf=clearInterval(yf))):(yf||(Am=Sf.now(),yf=setInterval(LF,B5)),Rd=1,z5(L5))}}var Rd,vf,yf,B5,Im,wf,Am,ec,Mm,Sf,z5,ey=U(()=>{"use strict";Rd=0,vf=0,yf=0,B5=1e3,Am=0,ec=0,Mm=0,Sf=typeof performance=="object"&&performance.now?performance:Date,z5=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};Nf.prototype=Pm.prototype={constructor:Nf,restart:function(t,e,r){if(typeof t!="function")throw new TypeError("callback is not a function");r=(r==null?Cf():+r)+(e==null?0:+e),!this._next&&wf!==this&&(wf?wf._next=this:Im=this,wf=this),this._call=t,this._time=r,Qx()},stop:function(){this._call&&(this._call=null,this._time=1/0,Qx())}}});function Rm(t,e,r){var n=new Nf;return e=e==null?0:+e,n.restart(o=>{n.stop(),t(o+e)},e,r),n}var F5=U(()=>{"use strict";ey()});var ty=U(()=>{"use strict";ey();F5()});function Ya(t,e,r,n,o,s){var i=t.__transition;if(!i)t.__transition={};else if(r in i)return;FF(t,r,{name:e,index:n,group:o,on:zF,tween:$F,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:j5})}function Ef(t,e){var r=yn(t,e);if(r.state>j5)throw new Error("too late; already scheduled");return r}function jn(t,e){var r=yn(t,e);if(r.state>Dm)throw new Error("too late; already running");return r}function yn(t,e){var r=t.__transition;if(!r||!(r=r[e]))throw new Error("transition not found");return r}function FF(t,e,r){var n=t.__transition,o;n[e]=r,r.timer=Pm(s,0,r.time);function s(c){r.state=H5,r.timer.restart(i,r.delay,r.time),r.delay<=c&&i(c-r.delay)}function i(c){var d,u,f,p;if(r.state!==H5)return l();for(d in n)if(p=n[d],p.name===r.name){if(p.state===Dm)return Rm(i);p.state===V5?(p.state=kf,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete n[d]):+d<e&&(p.state=kf,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete n[d])}if(Rm(function(){r.state===Dm&&(r.state=V5,r.timer.restart(a,r.delay,r.time),a(c))}),r.state=Om,r.on.call("start",t,t.__data__,r.index,r.group),r.state===Om){for(r.state=Dm,o=new Array(f=r.tween.length),d=0,u=-1;d<f;++d)(p=r.tween[d].value.call(t,t.__data__,r.index,r.group))&&(o[++u]=p);o.length=u+1}}function a(c){for(var d=c<r.duration?r.ease.call(null,c/r.duration):(r.timer.restart(l),r.state=_m,1),u=-1,f=o.length;++u<f;)o[u].call(t,d);r.state===_m&&(r.on.call("end",t,t.__data__,r.index,r.group),l())}function l(){r.state=kf,r.timer.stop(),delete n[e];for(var c in n)return;delete t.__transition}}var zF,$F,j5,H5,Om,Dm,V5,_m,kf,Lo=U(()=>{"use strict";lm();ty();zF=Kl("start","end","cancel","interrupt"),$F=[],j5=0,H5=1,Om=2,Dm=3,V5=4,_m=5,kf=6});function tc(t,e){var r=t.__transition,n,o,s=!0,i;if(r){e=e==null?null:e+"";for(i in r){if((n=r[i]).name!==e){s=!1;continue}o=n.state>Om&&n.state<_m,n.state=kf,n.timer.stop(),n.on.call(o?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete r[i]}s&&delete t.__transition}}var ry=U(()=>{"use strict";Lo()});function W5(t){return this.each(function(){tc(this,t)})}var U5=U(()=>{"use strict";ry()});function HF(t,e){var r,n;return function(){var o=jn(this,t),s=o.tween;if(s!==r){n=r=s;for(var i=0,a=n.length;i<a;++i)if(n[i].name===e){n=n.slice(),n.splice(i,1);break}}o.tween=n}}function VF(t,e,r){var n,o;if(typeof r!="function")throw new Error;return function(){var s=jn(this,t),i=s.tween;if(i!==n){o=(n=i).slice();for(var a={name:e,value:r},l=0,c=o.length;l<c;++l)if(o[l].name===e){o[l]=a;break}l===c&&o.push(a)}s.tween=o}}function G5(t,e){var r=this._id;if(t+="",arguments.length<2){for(var n=yn(this.node(),r).tween,o=0,s=n.length,i;o<s;++o)if((i=n[o]).name===t)return i.value;return null}return this.each((e==null?HF:VF)(r,t,e))}function Dd(t,e,r){var n=t._id;return t.each(function(){var o=jn(this,n);(o.value||(o.value={}))[e]=r.apply(this,arguments)}),function(o){return yn(o,n).value[e]}}var Tf=U(()=>{"use strict";Lo()});function Lm(t,e){var r;return(typeof e=="number"?vo:e instanceof Js?Zl:(r=Js(e))?(e=r,Zl):xf)(t,e)}var ny=U(()=>{"use strict";Nm();Pd()});function jF(t){return function(){this.removeAttribute(t)}}function WF(t){return function(){this.removeAttributeNS(t.space,t.local)}}function UF(t,e,r){var n,o=r+"",s;return function(){var i=this.getAttribute(t);return i===o?null:i===n?s:s=e(n=i,r)}}function GF(t,e,r){var n,o=r+"",s;return function(){var i=this.getAttributeNS(t.space,t.local);return i===o?null:i===n?s:s=e(n=i,r)}}function KF(t,e,r){var n,o,s;return function(){var i,a=r(this),l;return a==null?void this.removeAttribute(t):(i=this.getAttribute(t),l=a+"",i===l?null:i===n&&l===o?s:(o=l,s=e(n=i,a)))}}function qF(t,e,r){var n,o,s;return function(){var i,a=r(this),l;return a==null?void this.removeAttributeNS(t.space,t.local):(i=this.getAttributeNS(t.space,t.local),l=a+"",i===l?null:i===n&&l===o?s:(o=l,s=e(n=i,a)))}}function K5(t,e){var r=ra(t),n=r==="transform"?Zx:Lm;return this.attrTween(t,typeof e=="function"?(r.local?qF:KF)(r,n,Dd(this,"attr."+t,e)):e==null?(r.local?WF:jF)(r):(r.local?GF:UF)(r,n,e))}var q5=U(()=>{"use strict";Pd();Oo();Tf();ny()});function YF(t,e){return function(r){this.setAttribute(t,e.call(this,r))}}function XF(t,e){return function(r){this.setAttributeNS(t.space,t.local,e.call(this,r))}}function JF(t,e){var r,n;function o(){var s=e.apply(this,arguments);return s!==n&&(r=(n=s)&&XF(t,s)),r}return o._value=e,o}function ZF(t,e){var r,n;function o(){var s=e.apply(this,arguments);return s!==n&&(r=(n=s)&&YF(t,s)),r}return o._value=e,o}function Y5(t,e){var r="attr."+t;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;var n=ra(t);return this.tween(r,(n.local?JF:ZF)(n,e))}var X5=U(()=>{"use strict";Oo()});function QF(t,e){return function(){Ef(this,t).delay=+e.apply(this,arguments)}}function e6(t,e){return e=+e,function(){Ef(this,t).delay=e}}function J5(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?QF:e6)(e,t)):yn(this.node(),e).delay}var Z5=U(()=>{"use strict";Lo()});function t6(t,e){return function(){jn(this,t).duration=+e.apply(this,arguments)}}function r6(t,e){return e=+e,function(){jn(this,t).duration=e}}function Q5(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?t6:r6)(e,t)):yn(this.node(),e).duration}var eI=U(()=>{"use strict";Lo()});function n6(t,e){if(typeof e!="function")throw new Error;return function(){jn(this,t).ease=e}}function tI(t){var e=this._id;return arguments.length?this.each(n6(e,t)):yn(this.node(),e).ease}var rI=U(()=>{"use strict";Lo()});function o6(t,e){return function(){var r=e.apply(this,arguments);if(typeof r!="function")throw new Error;jn(this,t).ease=r}}function nI(t){if(typeof t!="function")throw new Error;return this.each(o6(this._id,t))}var oI=U(()=>{"use strict";Lo()});function sI(t){typeof t!="function"&&(t=sf(t));for(var e=this._groups,r=e.length,n=new Array(r),o=0;o<r;++o)for(var s=e[o],i=s.length,a=n[o]=[],l,c=0;c<i;++c)(l=s[c])&&t.call(l,l.__data__,c,s)&&a.push(l);return new wo(n,this._parents,this._name,this._id)}var iI=U(()=>{"use strict";Oo();rc()});function aI(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,r=t._groups,n=e.length,o=r.length,s=Math.min(n,o),i=new Array(n),a=0;a<s;++a)for(var l=e[a],c=r[a],d=l.length,u=i[a]=new Array(d),f,p=0;p<d;++p)(f=l[p]||c[p])&&(u[p]=f);for(;a<n;++a)i[a]=e[a];return new wo(i,this._parents,this._name,this._id)}var lI=U(()=>{"use strict";rc()});function s6(t){return(t+"").trim().split(/^|\s+/).every(function(e){var r=e.indexOf(".");return r>=0&&(e=e.slice(0,r)),!e||e==="start"})}function i6(t,e,r){var n,o,s=s6(e)?Ef:jn;return function(){var i=s(this,t),a=i.on;a!==n&&(o=(n=a).copy()).on(e,r),i.on=o}}function cI(t,e){var r=this._id;return arguments.length<2?yn(this.node(),r).on.on(t):this.each(i6(r,t,e))}var dI=U(()=>{"use strict";Lo()});function a6(t){return function(){var e=this.parentNode;for(var r in this.__transition)if(+r!==t)return;e&&e.removeChild(this)}}function uI(){return this.on("end.remove",a6(this._id))}var fI=U(()=>{"use strict"});function pI(t){var e=this._name,r=this._id;typeof t!="function"&&(t=ql(t));for(var n=this._groups,o=n.length,s=new Array(o),i=0;i<o;++i)for(var a=n[i],l=a.length,c=s[i]=new Array(l),d,u,f=0;f<l;++f)(d=a[f])&&(u=t.call(d,d.__data__,f,a))&&("__data__"in d&&(u.__data__=d.__data__),c[f]=u,Ya(c[f],e,r,f,c,yn(d,r)));return new wo(s,this._parents,e,r)}var hI=U(()=>{"use strict";Oo();rc();Lo()});function mI(t){var e=this._name,r=this._id;typeof t!="function"&&(t=of(t));for(var n=this._groups,o=n.length,s=[],i=[],a=0;a<o;++a)for(var l=n[a],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var f=t.call(d,d.__data__,u,l),p,h=yn(d,r),b=0,g=f.length;b<g;++b)(p=f[b])&&Ya(p,e,r,b,f,h);s.push(f),i.push(d)}return new wo(s,i,e,r)}var gI=U(()=>{"use strict";Oo();rc();Lo()});function bI(){return new l6(this._groups,this._parents)}var l6,xI=U(()=>{"use strict";Oo();l6=na.prototype.constructor});function c6(t,e){var r,n,o;return function(){var s=Ka(this,t),i=(this.style.removeProperty(t),Ka(this,t));return s===i?null:s===r&&i===n?o:o=e(r=s,n=i)}}function yI(t){return function(){this.style.removeProperty(t)}}function d6(t,e,r){var n,o=r+"",s;return function(){var i=Ka(this,t);return i===o?null:i===n?s:s=e(n=i,r)}}function u6(t,e,r){var n,o,s;return function(){var i=Ka(this,t),a=r(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(t),Ka(this,t))),i===l?null:i===n&&l===o?s:(o=l,s=e(n=i,a))}}function f6(t,e){var r,n,o,s="style."+e,i="end."+s,a;return function(){var l=jn(this,t),c=l.on,d=l.value[s]==null?a||(a=yI(e)):void 0;(c!==r||o!==d)&&(n=(r=c).copy()).on(i,o=d),l.on=n}}function vI(t,e,r){var n=(t+="")=="transform"?Jx:Lm;return e==null?this.styleTween(t,c6(t,n)).on("end.style."+t,yI(t)):typeof e=="function"?this.styleTween(t,u6(t,n,Dd(this,"style."+t,e))).each(f6(this._id,t)):this.styleTween(t,d6(t,n,e),r).on("end.style."+t,null)}var wI=U(()=>{"use strict";Pd();Oo();Lo();Tf();ny()});function p6(t,e,r){return function(n){this.style.setProperty(t,e.call(this,n),r)}}function h6(t,e,r){var n,o;function s(){var i=e.apply(this,arguments);return i!==o&&(n=(o=i)&&p6(t,i,r)),n}return s._value=e,s}function SI(t,e,r){var n="style."+(t+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,h6(t,e,r??""))}var NI=U(()=>{"use strict"});function m6(t){return function(){this.textContent=t}}function g6(t){return function(){var e=t(this);this.textContent=e??""}}function CI(t){return this.tween("text",typeof t=="function"?g6(Dd(this,"text",t)):m6(t==null?"":t+""))}var kI=U(()=>{"use strict";Tf()});function b6(t){return function(e){this.textContent=t.call(this,e)}}function x6(t){var e,r;function n(){var o=t.apply(this,arguments);return o!==r&&(e=(r=o)&&b6(o)),e}return n._value=t,n}function EI(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,x6(t))}var TI=U(()=>{"use strict"});function II(){for(var t=this._name,e=this._id,r=Bm(),n=this._groups,o=n.length,s=0;s<o;++s)for(var i=n[s],a=i.length,l,c=0;c<a;++c)if(l=i[c]){var d=yn(l,e);Ya(l,t,r,c,i,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new wo(n,this._parents,t,r)}var AI=U(()=>{"use strict";rc();Lo()});function MI(){var t,e,r=this,n=r._id,o=r.size();return new Promise(function(s,i){var a={value:i},l={value:function(){--o===0&&s()}};r.each(function(){var c=jn(this,n),d=c.on;d!==t&&(e=(t=d).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),c.on=e}),o===0&&s()})}var PI=U(()=>{"use strict";Lo()});function wo(t,e,r,n){this._groups=t,this._parents=e,this._name=r,this._id=n}function RI(t){return na().transition(t)}function Bm(){return++y6}var y6,sa,rc=U(()=>{"use strict";Oo();q5();X5();Z5();eI();rI();oI();iI();lI();dI();fI();hI();gI();xI();wI();NI();kI();TI();AI();Tf();PI();y6=0;sa=na.prototype;wo.prototype=RI.prototype={constructor:wo,select:pI,selectAll:mI,selectChild:sa.selectChild,selectChildren:sa.selectChildren,filter:sI,merge:aI,selection:bI,transition:II,call:sa.call,nodes:sa.nodes,node:sa.node,size:sa.size,empty:sa.empty,each:sa.each,on:cI,attr:K5,attrTween:Y5,style:vI,styleTween:SI,text:CI,textTween:EI,remove:uI,tween:G5,delay:J5,duration:Q5,ease:tI,easeVarying:nI,end:MI,[Symbol.iterator]:sa[Symbol.iterator]}});function zm(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var DI=U(()=>{"use strict"});var OI=U(()=>{"use strict";DI()});function w6(t,e){for(var r;!(r=t.__transition)||!(r=r[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return r}function _I(t){var e,r;t instanceof wo?(e=t._id,t=t._name):(e=Bm(),(r=v6).time=Cf(),t=t==null?null:t+"");for(var n=this._groups,o=n.length,s=0;s<o;++s)for(var i=n[s],a=i.length,l,c=0;c<a;++c)(l=i[c])&&Ya(l,t,e,c,i,r||w6(l,e));return new wo(n,this._parents,t,e)}var v6,LI=U(()=>{"use strict";rc();Lo();OI();ty();v6={time:null,delay:0,duration:250,ease:zm}});var BI=U(()=>{"use strict";Oo();U5();LI();na.prototype.interrupt=W5;na.prototype.transition=_I});var zI=U(()=>{"use strict";BI();ry()});var If,$I=U(()=>{"use strict";If=t=>()=>t});function oy(t,{sourceEvent:e,target:r,transform:n,dispatch:o}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:o}})}var FI=U(()=>{"use strict"});function Zs(t,e,r){this.k=t,this.x=e,this.y=r}function Af(t){for(;!t.__zoom;)if(!(t=t.parentNode))return nc;return t.__zoom}var nc,sy=U(()=>{"use strict";Zs.prototype={constructor:Zs,scale:function(t){return t===1?this:new Zs(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new Zs(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};nc=new Zs(1,0,0);Af.prototype=Zs.prototype});function $m(t){t.stopImmediatePropagation()}function Od(t){t.preventDefault(),t.stopImmediatePropagation()}var HI=U(()=>{"use strict"});function S6(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function N6(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function VI(){return this.__zoom||nc}function C6(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function k6(){return navigator.maxTouchPoints||"ontouchstart"in this}function E6(t,e,r){var n=t.invertX(e[0][0])-r[0][0],o=t.invertX(e[1][0])-r[1][0],s=t.invertY(e[0][1])-r[0][1],i=t.invertY(e[1][1])-r[1][1];return t.translate(o>n?(n+o)/2:Math.min(0,n)||Math.max(0,o),i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i))}function Fm(){var t=S6,e=N6,r=E6,n=C6,o=k6,s=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],a=250,l=Ql,c=Kl("start","zoom","end"),d,u,f,p=500,h=150,b=0,g=10;function x(N){N.property("__zoom",VI).on("wheel.zoom",A,{passive:!1}).on("mousedown.zoom",k).on("dblclick.zoom",M).filter(o).on("touchstart.zoom",T).on("touchmove.zoom",E).on("touchend.zoom touchcancel.zoom",P).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(N,D,R,O){var B=N.selection?N.selection():N;B.property("__zoom",VI),N!==B?S(N,D,R,O):B.interrupt().each(function(){w(this,arguments).event(O).start().zoom(null,typeof D=="function"?D.apply(this,arguments):D).end()})},x.scaleBy=function(N,D,R,O){x.scaleTo(N,function(){var B=this.__zoom.k,L=typeof D=="function"?D.apply(this,arguments):D;return B*L},R,O)},x.scaleTo=function(N,D,R,O){x.transform(N,function(){var B=e.apply(this,arguments),L=this.__zoom,H=R==null?v(B):typeof R=="function"?R.apply(this,arguments):R,j=L.invert(H),$=typeof D=="function"?D.apply(this,arguments):D;return r(m(y(L,$),H,j),B,i)},R,O)},x.translateBy=function(N,D,R,O){x.transform(N,function(){return r(this.__zoom.translate(typeof D=="function"?D.apply(this,arguments):D,typeof R=="function"?R.apply(this,arguments):R),e.apply(this,arguments),i)},null,O)},x.translateTo=function(N,D,R,O,B){x.transform(N,function(){var L=e.apply(this,arguments),H=this.__zoom,j=O==null?v(L):typeof O=="function"?O.apply(this,arguments):O;return r(nc.translate(j[0],j[1]).scale(H.k).translate(typeof D=="function"?-D.apply(this,arguments):-D,typeof R=="function"?-R.apply(this,arguments):-R),L,i)},O,B)};function y(N,D){return D=Math.max(s[0],Math.min(s[1],D)),D===N.k?N:new Zs(D,N.x,N.y)}function m(N,D,R){var O=D[0]-R[0]*N.k,B=D[1]-R[1]*N.k;return O===N.x&&B===N.y?N:new Zs(N.k,O,B)}function v(N){return[(+N[0][0]+ +N[1][0])/2,(+N[0][1]+ +N[1][1])/2]}function S(N,D,R,O){N.on("start.zoom",function(){w(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){w(this,arguments).event(O).end()}).tween("zoom",function(){var B=this,L=arguments,H=w(B,L).event(O),j=e.apply(B,L),$=R==null?v(j):typeof R=="function"?R.apply(B,L):R,q=Math.max(j[1][0]-j[0][0],j[1][1]-j[0][1]),F=B.__zoom,_=typeof D=="function"?D.apply(B,L):D,W=l(F.invert($).concat(q/F.k),_.invert($).concat(q/_.k));return function(V){if(V===1)V=_;else{var z=W(V),G=q/z[2];V=new Zs(G,$[0]-z[0]*G,$[1]-z[1]*G)}H.zoom(null,V)}})}function w(N,D,R){return!R&&N.__zooming||new C(N,D)}function C(N,D){this.that=N,this.args=D,this.active=0,this.sourceEvent=null,this.extent=e.apply(N,D),this.taps=0}C.prototype={event:function(N){return N&&(this.sourceEvent=N),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(N,D){return this.mouse&&N!=="mouse"&&(this.mouse[1]=D.invert(this.mouse[0])),this.touch0&&N!=="touch"&&(this.touch0[1]=D.invert(this.touch0[0])),this.touch1&&N!=="touch"&&(this.touch1[1]=D.invert(this.touch1[0])),this.that.__zoom=D,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(N){var D=On(this.that).datum();c.call(N,this.that,new oy(N,{sourceEvent:this.sourceEvent,target:x,type:N,transform:this.that.__zoom,dispatch:c}),D)}};function A(N,...D){if(!t.apply(this,arguments))return;var R=w(this,D).event(N),O=this.__zoom,B=Math.max(s[0],Math.min(s[1],O.k*Math.pow(2,n.apply(this,arguments)))),L=yo(N);if(R.wheel)(R.mouse[0][0]!==L[0]||R.mouse[0][1]!==L[1])&&(R.mouse[1]=O.invert(R.mouse[0]=L)),clearTimeout(R.wheel);else{if(O.k===B)return;R.mouse=[L,O.invert(L)],tc(this),R.start()}Od(N),R.wheel=setTimeout(H,h),R.zoom("mouse",r(m(y(O,B),R.mouse[0],R.mouse[1]),R.extent,i));function H(){R.wheel=null,R.end()}}function k(N,...D){if(f||!t.apply(this,arguments))return;var R=N.currentTarget,O=w(this,D,!0).event(N),B=On(N.view).on("mousemove.zoom",$,!0).on("mouseup.zoom",q,!0),L=yo(N,R),H=N.clientX,j=N.clientY;cf(N.view),$m(N),O.mouse=[L,this.__zoom.invert(L)],tc(this),O.start();function $(F){if(Od(F),!O.moved){var _=F.clientX-H,W=F.clientY-j;O.moved=_*_+W*W>b}O.event(F).zoom("mouse",r(m(O.that.__zoom,O.mouse[0]=yo(F,R),O.mouse[1]),O.extent,i))}function q(F){B.on("mousemove.zoom mouseup.zoom",null),df(F.view,O.moved),Od(F),O.event(F).end()}}function M(N,...D){if(t.apply(this,arguments)){var R=this.__zoom,O=yo(N.changedTouches?N.changedTouches[0]:N,this),B=R.invert(O),L=R.k*(N.shiftKey?.5:2),H=r(m(y(R,L),O,B),e.apply(this,D),i);Od(N),a>0?On(this).transition().duration(a).call(S,H,O,N):On(this).call(x.transform,H,O,N)}}function T(N,...D){if(t.apply(this,arguments)){var R=N.touches,O=R.length,B=w(this,D,N.changedTouches.length===O).event(N),L,H,j,$;for($m(N),H=0;H<O;++H)j=R[H],$=yo(j,this),$=[$,this.__zoom.invert($),j.identifier],B.touch0?!B.touch1&&B.touch0[2]!==$[2]&&(B.touch1=$,B.taps=0):(B.touch0=$,L=!0,B.taps=1+!!d);d&&(d=clearTimeout(d)),L&&(B.taps<2&&(u=$[0],d=setTimeout(function(){d=null},p)),tc(this),B.start())}}function E(N,...D){if(this.__zooming){var R=w(this,D).event(N),O=N.changedTouches,B=O.length,L,H,j,$;for(Od(N),L=0;L<B;++L)H=O[L],j=yo(H,this),R.touch0&&R.touch0[2]===H.identifier?R.touch0[0]=j:R.touch1&&R.touch1[2]===H.identifier&&(R.touch1[0]=j);if(H=R.that.__zoom,R.touch1){var q=R.touch0[0],F=R.touch0[1],_=R.touch1[0],W=R.touch1[1],V=(V=_[0]-q[0])*V+(V=_[1]-q[1])*V,z=(z=W[0]-F[0])*z+(z=W[1]-F[1])*z;H=y(H,Math.sqrt(V/z)),j=[(q[0]+_[0])/2,(q[1]+_[1])/2],$=[(F[0]+W[0])/2,(F[1]+W[1])/2]}else if(R.touch0)j=R.touch0[0],$=R.touch0[1];else return;R.zoom("touch",r(m(H,j,$),R.extent,i))}}function P(N,...D){if(this.__zooming){var R=w(this,D).event(N),O=N.changedTouches,B=O.length,L,H;for($m(N),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),L=0;L<B;++L)H=O[L],R.touch0&&R.touch0[2]===H.identifier?delete R.touch0:R.touch1&&R.touch1[2]===H.identifier&&delete R.touch1;if(R.touch1&&!R.touch0&&(R.touch0=R.touch1,delete R.touch1),R.touch0)R.touch0[1]=this.__zoom.invert(R.touch0[0]);else if(R.end(),R.taps===2&&(H=yo(H,this),Math.hypot(u[0]-H[0],u[1]-H[1])<g)){var j=On(this).on("dblclick.zoom");j&&j.apply(this,arguments)}}}return x.wheelDelta=function(N){return arguments.length?(n=typeof N=="function"?N:If(+N),x):n},x.filter=function(N){return arguments.length?(t=typeof N=="function"?N:If(!!N),x):t},x.touchable=function(N){return arguments.length?(o=typeof N=="function"?N:If(!!N),x):o},x.extent=function(N){return arguments.length?(e=typeof N=="function"?N:If([[+N[0][0],+N[0][1]],[+N[1][0],+N[1][1]]]),x):e},x.scaleExtent=function(N){return arguments.length?(s[0]=+N[0],s[1]=+N[1],x):[s[0],s[1]]},x.translateExtent=function(N){return arguments.length?(i[0][0]=+N[0][0],i[1][0]=+N[1][0],i[0][1]=+N[0][1],i[1][1]=+N[1][1],x):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},x.constrain=function(N){return arguments.length?(r=N,x):r},x.duration=function(N){return arguments.length?(a=+N,x):a},x.interpolate=function(N){return arguments.length?(l=N,x):l},x.on=function(){var N=c.on.apply(c,arguments);return N===c?x:N},x.clickDistance=function(N){return arguments.length?(b=(N=+N)*N,x):Math.sqrt(b)},x.tapDistance=function(N){return arguments.length?(g=+N,x):g},x}var jI=U(()=>{"use strict";lm();Fx();Pd();Oo();zI();$I();FI();sy();HI()});var WI=U(()=>{"use strict";jI();sy()});function py(t){return t===null?null:t?"valid":"invalid"}function T6(t,e){let r=new Map,n=e?.nodes?new Set(e.nodes.map(o=>o.id)):null;return t.forEach(o=>{o.measured.width&&o.measured.height&&(e?.includeHiddenNodes||!o.hidden)&&(!n||n.has(o.id))&&r.set(o.id,o)}),r}async function iA({nodes:t,width:e,height:r,panZoom:n,minZoom:o,maxZoom:s},i){if(t.size===0)return Promise.resolve(!0);let a=T6(t,i),l=Fd(a),c=Df(l,e,r,i?.minZoom??o,i?.maxZoom??s,i?.padding??.1);return await n.setViewport(c,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),Promise.resolve(!0)}function by({nodeId:t,nextPosition:e,nodeLookup:r,nodeOrigin:n=[0,0],nodeExtent:o,onError:s}){let i=r.get(t),a=i.parentId?r.get(i.parentId):void 0,{x:l,y:c}=a?a.internals.positionAbsolute:{x:0,y:0},d=i.origin??n,u=i.extent||o;if(i.extent==="parent"&&!i.expandParent)if(!a)s?.("005",So.error005());else{let p=a.measured.width,h=a.measured.height;p&&h&&(u=[[l,c],[l+p,c+h]])}else a&&zd(i.extent)&&(u=[[i.extent[0][0]+l,i.extent[0][1]+c],[i.extent[1][0]+l,i.extent[1][1]+c]]);let f=zd(u)?oc(e,u,i.measured):e;return(i.measured.width===void 0||i.measured.height===void 0)&&s?.("015",So.error015()),{position:{x:f.x-l+(i.measured.width??0)*d[0],y:f.y-c+(i.measured.height??0)*d[1]},positionAbsolute:f}}async function aA({nodesToRemove:t=[],edgesToRemove:e=[],nodes:r,edges:n,onBeforeDelete:o}){let s=new Set(t.map(f=>f.id)),i=[];for(let f of r){if(f.deletable===!1)continue;let p=s.has(f.id),h=!p&&f.parentId&&i.find(b=>b.id===f.parentId);(p||h)&&i.push(f)}let a=new Set(e.map(f=>f.id)),l=n.filter(f=>f.deletable!==!1),d=sA(i,l);for(let f of l)a.has(f.id)&&!d.find(h=>h.id===f.id)&&d.push(f);if(!o)return{edges:d,nodes:i};let u=await o({nodes:i,edges:d});return typeof u=="boolean"?u?{edges:d,nodes:i}:{edges:[],nodes:[]}:u}function lA(t,e,r){let{width:n,height:o}=Mi(r),{x:s,y:i}=r.internals.positionAbsolute;return oc(t,[[s,i],[s+n,i+o]],e)}function _d(t,e){if(typeof t=="number")return Math.floor((e-e/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){let r=parseFloat(t);if(!Number.isNaN(r))return Math.floor(r)}if(typeof t=="string"&&t.endsWith("%")){let r=parseFloat(t);if(!Number.isNaN(r))return Math.floor(e*r*.01)}return console.error(`[React Flow] The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function I6(t,e,r){if(typeof t=="string"||typeof t=="number"){let n=_d(t,r),o=_d(t,e);return{top:n,right:o,bottom:n,left:o,x:o*2,y:n*2}}if(typeof t=="object"){let n=_d(t.top??t.y??0,r),o=_d(t.bottom??t.y??0,r),s=_d(t.left??t.x??0,e),i=_d(t.right??t.x??0,e);return{top:n,right:i,bottom:o,left:s,x:s+i,y:n+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function A6(t,e,r,n,o,s){let{x:i,y:a}=Pf(t,[e,r,n]),{x:l,y:c}=Pf({x:t.x+t.width,y:t.y+t.height},[e,r,n]),d=o-l,u=s-c;return{left:Math.floor(i),top:Math.floor(a),right:Math.floor(d),bottom:Math.floor(u)}}function zd(t){return t!=null&&t!=="parent"}function Mi(t){return{width:t.measured?.width??t.width??t.initialWidth??0,height:t.measured?.height??t.height??t.initialHeight??0}}function wy(t){return(t.measured?.width??t.width??t.initialWidth)!==void 0&&(t.measured?.height??t.height??t.initialHeight)!==void 0}function Sy(t,e={width:0,height:0},r,n,o){let s={...t},i=n.get(r);if(i){let a=i.origin||o;s.x+=i.internals.positionAbsolute.x-(e.width??0)*a[0],s.y+=i.internals.positionAbsolute.y-(e.height??0)*a[1]}return s}function Ny(t,e){if(t.size!==e.size)return!1;for(let r of t)if(!e.has(r))return!1;return!0}function dA(){let t,e;return{promise:new Promise((n,o)=>{t=n,e=o}),resolve:t,reject:e}}function uA(t){return{...uy,...t||{}}}function Mf(t,{snapGrid:e=[0,0],snapToGrid:r=!1,transform:n,containerBounds:o}){let{x:s,y:i}=Cs(t),a=jd({x:s-(o?.left??0),y:i-(o?.top??0)},n),{x:l,y:c}=r?Vd(a,e):a;return{xSnapped:l,ySnapped:c,...a}}function ky(t){let e=t.composedPath?.()?.[0]||t.target;return e?.nodeType!==1?!1:M6.includes(e.nodeName)||e.hasAttribute("contenteditable")||!!e.closest(".nokey")}function qm({sourceX:t,sourceY:e,targetX:r,targetY:n,sourceControlX:o,sourceControlY:s,targetControlX:i,targetControlY:a}){let l=t*.125+o*.375+i*.375+r*.125,c=e*.125+s*.375+a*.375+n*.125,d=Math.abs(l-t),u=Math.abs(c-e);return[l,c,d,u]}function Hm(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function qI({pos:t,x1:e,y1:r,x2:n,y2:o,c:s}){switch(t){case Te.Left:return[e-Hm(e-n,s),r];case Te.Right:return[e+Hm(n-e,s),r];case Te.Top:return[e,r-Hm(r-o,s)];case Te.Bottom:return[e,r+Hm(o-r,s)]}}function Ym({sourceX:t,sourceY:e,sourcePosition:r=Te.Bottom,targetX:n,targetY:o,targetPosition:s=Te.Top,curvature:i=.25}){let[a,l]=qI({pos:r,x1:t,y1:e,x2:n,y2:o,c:i}),[c,d]=qI({pos:s,x1:n,y1:o,x2:t,y2:e,c:i}),[u,f,p,h]=qm({sourceX:t,sourceY:e,targetX:n,targetY:o,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${t},${e} C${a},${l} ${c},${d} ${n},${o}`,u,f,p,h]}function Ty({sourceX:t,sourceY:e,targetX:r,targetY:n}){let o=Math.abs(r-t)/2,s=r<t?r+o:r-o,i=Math.abs(n-e)/2,a=n<e?n+i:n-i;return[s,a,o,i]}function fA({sourceNode:t,targetNode:e,selected:r=!1,zIndex:n=0,elevateOnSelect:o=!1,zIndexMode:s="basic"}){if(s==="manual")return n;let i=o&&r?n+1e3:n,a=Math.max(t.parentId||o&&t.selected?t.internals.z:0,e.parentId||o&&e.selected?e.internals.z:0);return i+a}function pA({sourceNode:t,targetNode:e,width:r,height:n,transform:o}){let s=Um(jm(t),jm(e));s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1);let i={x:-o[0]/o[2],y:-o[1]/o[2],width:r/o[2],height:n/o[2]};return Hd(i,Gm(s))>0}function Xm({sourceX:t,sourceY:e,targetX:r,targetY:n}){let[o,s,i,a]=Ty({sourceX:t,sourceY:e,targetX:r,targetY:n});return[`M ${t},${e}L ${r},${n}`,o,s,i,a]}function O6({source:t,sourcePosition:e=Te.Bottom,target:r,targetPosition:n=Te.Top,center:o,offset:s,stepPosition:i}){let a=YI[e],l=YI[n],c={x:t.x+a.x*s,y:t.y+a.y*s},d={x:r.x+l.x*s,y:r.y+l.y*s},u=D6({source:c,sourcePosition:e,target:d}),f=u.x!==0?"x":"y",p=u[f],h=[],b,g,x={x:0,y:0},y={x:0,y:0},[,,m,v]=Ty({sourceX:t.x,sourceY:t.y,targetX:r.x,targetY:r.y});if(a[f]*l[f]===-1){f==="x"?(b=o.x??c.x+(d.x-c.x)*i,g=o.y??(c.y+d.y)/2):(b=o.x??(c.x+d.x)/2,g=o.y??c.y+(d.y-c.y)*i);let w=[{x:b,y:c.y},{x:b,y:d.y}],C=[{x:c.x,y:g},{x:d.x,y:g}];a[f]===p?h=f==="x"?w:C:h=f==="x"?C:w}else{let w=[{x:c.x,y:d.y}],C=[{x:d.x,y:c.y}];if(f==="x"?h=a.x===p?C:w:h=a.y===p?w:C,e===n){let E=Math.abs(t[f]-r[f]);if(E<=s){let P=Math.min(s-1,s-E);a[f]===p?x[f]=(c[f]>t[f]?-1:1)*P:y[f]=(d[f]>r[f]?-1:1)*P}}if(e!==n){let E=f==="x"?"y":"x",P=a[f]===l[E],N=c[E]>d[E],D=c[E]<d[E];(a[f]===1&&(!P&&N||P&&D)||a[f]!==1&&(!P&&D||P&&N))&&(h=f==="x"?w:C)}let A={x:c.x+x.x,y:c.y+x.y},k={x:d.x+y.x,y:d.y+y.y},M=Math.max(Math.abs(A.x-h[0].x),Math.abs(k.x-h[0].x)),T=Math.max(Math.abs(A.y-h[0].y),Math.abs(k.y-h[0].y));M>=T?(b=(A.x+k.x)/2,g=h[0].y):(b=h[0].x,g=(A.y+k.y)/2)}return[[t,{x:c.x+x.x,y:c.y+x.y},...h,{x:d.x+y.x,y:d.y+y.y},r],b,g,m,v]}function _6(t,e,r,n){let o=Math.min(XI(t,e)/2,XI(e,r)/2,n),{x:s,y:i}=e;if(t.x===s&&s===r.x||t.y===i&&i===r.y)return`L${s} ${i}`;if(t.y===i){let c=t.x<r.x?-1:1,d=t.y<r.y?1:-1;return`L ${s+o*c},${i}Q ${s},${i} ${s},${i+o*d}`}let a=t.x<r.x?1:-1,l=t.y<r.y?-1:1;return`L ${s},${i+o*l}Q ${s},${i} ${s+o*a},${i}`}function Of({sourceX:t,sourceY:e,sourcePosition:r=Te.Bottom,targetX:n,targetY:o,targetPosition:s=Te.Top,borderRadius:i=5,centerX:a,centerY:l,offset:c=20,stepPosition:d=.5}){let[u,f,p,h,b]=O6({source:{x:t,y:e},sourcePosition:r,target:{x:n,y:o},targetPosition:s,center:{x:a,y:l},offset:c,stepPosition:d});return[u.reduce((x,y,m)=>{let v="";return m>0&&m<u.length-1?v=_6(u[m-1],y,u[m+1],i):v=`${m===0?"M":"L"}${y.x} ${y.y}`,x+=v,x},""),f,p,h,b]}function JI(t){return t&&!!(t.internals.handleBounds||t.handles?.length)&&!!(t.measured.width||t.width||t.initialWidth)}function hA(t){let{sourceNode:e,targetNode:r}=t;if(!JI(e)||!JI(r))return null;let n=e.internals.handleBounds||ZI(e.handles),o=r.internals.handleBounds||ZI(r.handles),s=QI(n?.source??[],t.sourceHandle),i=QI(t.connectionMode===Za.Strict?o?.target??[]:(o?.target??[]).concat(o?.source??[]),t.targetHandle);if(!s||!i)return t.onError?.("008",So.error008(s?"target":"source",{id:t.id,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle})),null;let a=s?.position||Te.Bottom,l=i?.position||Te.Top,c=Qa(e,s,a),d=Qa(r,i,l);return{sourceX:c.x,sourceY:c.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:l}}function ZI(t){if(!t)return null;let e=[],r=[];for(let n of t)n.width=n.width??1,n.height=n.height??1,n.type==="source"?e.push(n):n.type==="target"&&r.push(n);return{source:e,target:r}}function Qa(t,e,r=Te.Left,n=!1){let o=(e?.x??0)+t.internals.positionAbsolute.x,s=(e?.y??0)+t.internals.positionAbsolute.y,{width:i,height:a}=e??Mi(t);if(n)return{x:o+i/2,y:s+a/2};switch(e?.position??r){case Te.Top:return{x:o+i/2,y:s};case Te.Right:return{x:o+i,y:s+a/2};case Te.Bottom:return{x:o+i/2,y:s+a};case Te.Left:return{x:o,y:s+a/2}}}function QI(t,e){return t&&(e?t.find(r=>r.id===e):t[0])||null}function Jm(t,e){return t?typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(n=>`${n}=${t[n]}`).join("&")}`:""}function mA(t,{id:e,defaultColor:r,defaultMarkerStart:n,defaultMarkerEnd:o}){let s=new Set;return t.reduce((i,a)=>([a.markerStart||n,a.markerEnd||o].forEach(l=>{if(l&&typeof l=="object"){let c=Jm(l,e);s.has(c)||(i.push({id:c,color:l.color||r,...l}),s.add(c))}}),i),[]).sort((i,a)=>i.id.localeCompare(a.id))}function Ay(t,e){let r={...t};for(let n in e)e[n]!==void 0&&(r[n]=e[n]);return r}function bA(t,e,r){let n=Ay(Iy,r);for(let o of t.values())if(o.parentId)Py(o,t,e,n);else{let s=Rf(o,n.nodeOrigin),i=zd(o.extent)?o.extent:n.nodeExtent,a=oc(s,i,Mi(o));o.internals.positionAbsolute=a}}function z6(t,e){if(!t.handles)return t.measured?e?.internals.handleBounds:void 0;let r=[],n=[];for(let o of t.handles){let s={id:o.id,width:o.width??1,height:o.height??1,nodeId:t.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?r.push(s):o.type==="target"&&n.push(s)}return{source:r,target:n}}function My(t){return t==="manual"}function Zm(t,e,r,n={}){let o=Ay(B6,n),s={i:0},i=new Map(e),a=o?.elevateNodesOnSelect&&!My(o.zIndexMode)?gA:0,l=t.length>0;e.clear(),r.clear();for(let c of t){let d=i.get(c.id);if(o.checkEquality&&c===d?.internals.userNode)e.set(c.id,d);else{let u=Rf(c,o.nodeOrigin),f=zd(c.extent)?c.extent:o.nodeExtent,p=oc(u,f,Mi(c));d={...o.defaults,...c,measured:{width:c.measured?.width,height:c.measured?.height},internals:{positionAbsolute:p,handleBounds:z6(c,d),z:xA(c,a,o.zIndexMode),userNode:c}},e.set(c.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(l=!1),c.parentId&&Py(d,e,r,n,s)}return l}function $6(t,e){if(!t.parentId)return;let r=e.get(t.parentId);r?r.set(t.id,t):e.set(t.parentId,new Map([[t.id,t]]))}function Py(t,e,r,n,o){let{elevateNodesOnSelect:s,nodeOrigin:i,nodeExtent:a,zIndexMode:l}=Ay(Iy,n),c=t.parentId,d=e.get(c);if(!d){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}$6(t,r),o&&!d.parentId&&d.internals.rootParentIndex===void 0&&l==="auto"&&(d.internals.rootParentIndex=++o.i,d.internals.z=d.internals.z+o.i*L6),o&&d.internals.rootParentIndex!==void 0&&(o.i=d.internals.rootParentIndex);let u=s&&!My(l)?gA:0,{x:f,y:p,z:h}=F6(t,d,i,a,u,l),{positionAbsolute:b}=t.internals,g=f!==b.x||p!==b.y;(g||h!==t.internals.z)&&e.set(t.id,{...t,internals:{...t.internals,positionAbsolute:g?{x:f,y:p}:b,z:h}})}function xA(t,e,r){let n=Ns(t.zIndex)?t.zIndex:0;return My(r)?n:n+(t.selected?e:0)}function F6(t,e,r,n,o,s){let{x:i,y:a}=e.internals.positionAbsolute,l=Mi(t),c=Rf(t,r),d=zd(t.extent)?oc(c,t.extent,l):c,u=oc({x:i+d.x,y:a+d.y},n,l);t.extent==="parent"&&(u=lA(u,l,e));let f=xA(t,o,s),p=e.internals.z??0;return{x:u.x,y:u.y,z:p>=f?p+1:f}}function Qm(t,e,r,n=[0,0]){let o=[],s=new Map;for(let i of t){let a=e.get(i.parentId);if(!a)continue;let l=s.get(i.parentId)?.expandedRect??sc(a),c=xy(l,i.rect);s.set(i.parentId,{expandedRect:c,parent:a})}return s.size>0&&s.forEach(({expandedRect:i,parent:a},l)=>{let c=a.internals.positionAbsolute,d=Mi(a),u=a.origin??n,f=i.x<c.x?Math.round(Math.abs(c.x-i.x)):0,p=i.y<c.y?Math.round(Math.abs(c.y-i.y)):0,h=Math.max(d.width,Math.round(i.width)),b=Math.max(d.height,Math.round(i.height)),g=(h-d.width)*u[0],x=(b-d.height)*u[1];(f>0||p>0||g||x)&&(o.push({id:l,type:"position",position:{x:a.position.x-f+g,y:a.position.y-p+x}}),r.get(l)?.forEach(y=>{t.some(m=>m.id===y.id)||o.push({id:y.id,type:"position",position:{x:y.position.x+f,y:y.position.y+p}})})),(d.width<i.width||d.height<i.height||f||p)&&o.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:h+(f?u[0]*f-g:0),height:b+(p?u[1]*p-x:0)}})}),o}function yA(t,e,r,n,o,s,i){let a=n?.querySelector(".xyflow__viewport"),l=!1;if(!a)return{changes:[],updatedInternals:l};let c=[],d=window.getComputedStyle(a),{m22:u}=new window.DOMMatrixReadOnly(d.transform),f=[];for(let p of t.values()){let h=e.get(p.id);if(!h)continue;if(h.hidden){e.set(h.id,{...h,internals:{...h.internals,handleBounds:void 0}}),l=!0;continue}let b=Km(p.nodeElement),g=h.measured.width!==b.width||h.measured.height!==b.height;if(!!(b.width&&b.height&&(g||!h.internals.handleBounds||p.force))){let y=p.nodeElement.getBoundingClientRect(),m=zd(h.extent)?h.extent:s,{positionAbsolute:v}=h.internals;h.parentId&&h.extent==="parent"?v=lA(v,b,e.get(h.parentId)):m&&(v=oc(v,m,b));let S={...h,measured:b,internals:{...h.internals,positionAbsolute:v,handleBounds:{source:KI("source",p.nodeElement,y,u,h.id),target:KI("target",p.nodeElement,y,u,h.id)}}};e.set(h.id,S),h.parentId&&Py(S,e,r,{nodeOrigin:o,zIndexMode:i}),l=!0,g&&(c.push({id:h.id,type:"dimensions",dimensions:b}),h.expandParent&&h.parentId&&f.push({id:h.id,parentId:h.parentId,rect:sc(S,o)}))}}if(f.length>0){let p=Qm(f,e,r,o);c.push(...p)}return{changes:c,updatedInternals:l}}async function vA({delta:t,panZoom:e,transform:r,translateExtent:n,width:o,height:s}){if(!e||!t.x&&!t.y)return Promise.resolve(!1);let i=await e.setViewportConstrained({x:r[0]+t.x,y:r[1]+t.y,zoom:r[2]},[[0,0],[o,s]],n),a=!!i&&(i.x!==r[0]||i.y!==r[1]||i.k!==r[2]);return Promise.resolve(a)}function eA(t,e,r,n,o,s){let i=o,a=n.get(i)||new Map;n.set(i,a.set(r,e)),i=`${o}-${t}`;let l=n.get(i)||new Map;if(n.set(i,l.set(r,e)),s){i=`${o}-${t}-${s}`;let c=n.get(i)||new Map;n.set(i,c.set(r,e))}}function Ry(t,e,r){t.clear(),e.clear();for(let n of r){let{source:o,target:s,sourceHandle:i=null,targetHandle:a=null}=n,l={edgeId:n.id,source:o,target:s,sourceHandle:i,targetHandle:a},c=`${o}-${i}--${s}-${a}`,d=`${s}-${a}--${o}-${i}`;eA("source",l,d,t,o,i),eA("target",l,c,t,s,a),e.set(n.id,n)}}function wA(t,e){if(!t.parentId)return!1;let r=e.get(t.parentId);return r?r.selected?!0:wA(r,e):!1}function tA(t,e,r){let n=t;do{if(n?.matches?.(e))return!0;if(n===r)return!1;n=n?.parentElement}while(n);return!1}function H6(t,e,r,n){let o=new Map;for(let[s,i]of t)if((i.selected||i.id===n)&&(!i.parentId||!wA(i,t))&&(i.draggable||e&&typeof i.draggable>"u")){let a=t.get(s);a&&o.set(s,{id:s,position:a.position||{x:0,y:0},distance:{x:r.x-a.internals.positionAbsolute.x,y:r.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return o}function iy({nodeId:t,dragItems:e,nodeLookup:r,dragging:n=!0}){let o=[];for(let[i,a]of e){let l=r.get(i)?.internals.userNode;l&&o.push({...l,position:a.position,dragging:n})}if(!t)return[o[0],o];let s=r.get(t)?.internals.userNode;return[s?{...s,position:e.get(t)?.position||s.position,dragging:n}:o[0],o]}function V6({dragItems:t,snapGrid:e,x:r,y:n}){let o=t.values().next().value;if(!o)return null;let s={x:r-o.distance.x,y:n-o.distance.y},i=Vd(s,e);return{x:i.x-s.x,y:i.y-s.y}}function SA({onNodeMouseDown:t,getStoreItems:e,onDragStart:r,onDrag:n,onDragStop:o}){let s={x:null,y:null},i=0,a=new Map,l=!1,c={x:0,y:0},d=null,u=!1,f=null,p=!1,h=!1,b=null;function g({noDragClassName:y,handleSelector:m,domNode:v,isSelectable:S,nodeId:w,nodeClickDistance:C=0}){f=On(v);function A({x:E,y:P}){let{nodeLookup:N,nodeExtent:D,snapGrid:R,snapToGrid:O,nodeOrigin:B,onNodeDrag:L,onSelectionDrag:H,onError:j,updateNodePositions:$}=e();s={x:E,y:P};let q=!1,F=a.size>1,_=F&&D?cy(Fd(a)):null,W=F&&O?V6({dragItems:a,snapGrid:R,x:E,y:P}):null;for(let[V,z]of a){if(!N.has(V))continue;let G={x:E-z.distance.x,y:P-z.distance.y};O&&(G=W?{x:Math.round(G.x+W.x),y:Math.round(G.y+W.y)}:Vd(G,R));let Y=null;if(F&&D&&!z.extent&&_){let{positionAbsolute:we}=z.internals,_e=we.x-_.x+D[0][0],Pe=we.x+z.measured.width-_.x2+D[1][0],K=we.y-_.y+D[0][1],he=we.y+z.measured.height-_.y2+D[1][1];Y=[[_e,K],[Pe,he]]}let{position:Z,positionAbsolute:se}=by({nodeId:V,nextPosition:G,nodeLookup:N,nodeExtent:Y||D,nodeOrigin:B,onError:j});q=q||z.position.x!==Z.x||z.position.y!==Z.y,z.position=Z,z.internals.positionAbsolute=se}if(h=h||q,!!q&&($(a,!0),b&&(n||L||!w&&H))){let[V,z]=iy({nodeId:w,dragItems:a,nodeLookup:N});n?.(b,a,V,z),L?.(b,V,z),w||H?.(b,z)}}async function k(){if(!d)return;let{transform:E,panBy:P,autoPanSpeed:N,autoPanOnNodeDrag:D}=e();if(!D){l=!1,cancelAnimationFrame(i);return}let[R,O]=cA(c,d,N);(R!==0||O!==0)&&(s.x=(s.x??0)-R/E[2],s.y=(s.y??0)-O/E[2],await P({x:R,y:O})&&A(s)),i=requestAnimationFrame(k)}function M(E){let{nodeLookup:P,multiSelectionActive:N,nodesDraggable:D,transform:R,snapGrid:O,snapToGrid:B,selectNodesOnDrag:L,onNodeDragStart:H,onSelectionDragStart:j,unselectNodesAndEdges:$}=e();u=!0,(!L||!S)&&!N&&w&&(P.get(w)?.selected||$()),S&&L&&w&&t?.(w);let q=Mf(E.sourceEvent,{transform:R,snapGrid:O,snapToGrid:B,containerBounds:d});if(s=q,a=H6(P,D,q,w),a.size>0&&(r||H||!w&&j)){let[F,_]=iy({nodeId:w,dragItems:a,nodeLookup:P});r?.(E.sourceEvent,a,F,_),H?.(E.sourceEvent,F,_),w||j?.(E.sourceEvent,_)}}let T=bm().clickDistance(C).on("start",E=>{let{domNode:P,nodeDragThreshold:N,transform:D,snapGrid:R,snapToGrid:O}=e();d=P?.getBoundingClientRect()||null,p=!1,h=!1,b=E.sourceEvent,N===0&&M(E),s=Mf(E.sourceEvent,{transform:D,snapGrid:R,snapToGrid:O,containerBounds:d}),c=Cs(E.sourceEvent,d)}).on("drag",E=>{let{autoPanOnNodeDrag:P,transform:N,snapGrid:D,snapToGrid:R,nodeDragThreshold:O,nodeLookup:B}=e(),L=Mf(E.sourceEvent,{transform:N,snapGrid:D,snapToGrid:R,containerBounds:d});if(b=E.sourceEvent,(E.sourceEvent.type==="touchmove"&&E.sourceEvent.touches.length>1||w&&!B.has(w))&&(p=!0),!p){if(!l&&P&&u&&(l=!0,k()),!u){let H=Cs(E.sourceEvent,d),j=H.x-c.x,$=H.y-c.y;Math.sqrt(j*j+$*$)>O&&M(E)}(s.x!==L.xSnapped||s.y!==L.ySnapped)&&a&&u&&(c=Cs(E.sourceEvent,d),A(L))}}).on("end",E=>{if(!(!u||p)&&(l=!1,u=!1,cancelAnimationFrame(i),a.size>0)){let{nodeLookup:P,updateNodePositions:N,onNodeDragStop:D,onSelectionDragStop:R}=e();if(h&&(N(a,!1),h=!1),o||D||!w&&R){let[O,B]=iy({nodeId:w,dragItems:a,nodeLookup:P,dragging:!1});o?.(E.sourceEvent,a,O,B),D?.(E.sourceEvent,O,B),w||R?.(E.sourceEvent,B)}}}).filter(E=>{let P=E.target;return!E.button&&(!y||!tA(P,`.${y}`,v))&&(!m||tA(P,m,v))});f.call(T)}function x(){f?.on(".drag",null)}return{update:g,destroy:x}}function j6(t,e,r){let n=[],o={x:t.x-r,y:t.y-r,width:r*2,height:r*2};for(let s of e.values())Hd(o,sc(s))>0&&n.push(s);return n}function U6(t,e,r,n){let o=[],s=1/0,i=j6(t,r,e+W6);for(let a of i){let l=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(let c of l){if(n.nodeId===c.nodeId&&n.type===c.type&&n.id===c.id)continue;let{x:d,y:u}=Qa(a,c,c.position,!0),f=Math.sqrt(Math.pow(d-t.x,2)+Math.pow(u-t.y,2));f>e||(f<s?(o=[{...c,x:d,y:u}],s=f):f===s&&o.push({...c,x:d,y:u}))}}if(!o.length)return null;if(o.length>1){let a=n.type==="source"?"target":"source";return o.find(l=>l.type===a)??o[0]}return o[0]}function NA(t,e,r,n,o,s=!1){let i=n.get(t);if(!i)return null;let a=o==="strict"?i.internals.handleBounds?.[e]:[...i.internals.handleBounds?.source??[],...i.internals.handleBounds?.target??[]],l=(r?a?.find(c=>c.id===r):a?.[0])??null;return l&&s?{...l,...Qa(i,l,l.position,!0)}:l}function CA(t,e){return t||(e?.classList.contains("target")?"target":e?.classList.contains("source")?"source":null)}function G6(t,e){let r=null;return e?r=!0:t&&!e&&(r=!1),r}function K6(t,{connectionMode:e,connectionRadius:r,handleId:n,nodeId:o,edgeUpdaterType:s,isTarget:i,domNode:a,nodeLookup:l,lib:c,autoPanOnConnect:d,flowId:u,panBy:f,cancelConnection:p,onConnectStart:h,onConnect:b,onConnectEnd:g,isValidConnection:x=kA,onReconnectEnd:y,updateConnection:m,getTransform:v,getFromHandle:S,autoPanSpeed:w,dragThreshold:C=1,handleDomNode:A}){let k=Cy(t.target),M=0,T,{x:E,y:P}=Cs(t),N=CA(s,A),D=a?.getBoundingClientRect(),R=!1;if(!D||!N)return;let O=NA(o,N,n,l,e);if(!O)return;let B=Cs(t,D),L=!1,H=null,j=!1,$=null;function q(){if(!d||!D)return;let[Z,se]=cA(B,D,w);f({x:Z,y:se}),M=requestAnimationFrame(q)}let F={...O,nodeId:o,type:N,position:O.position},_=l.get(o),V={inProgress:!0,isValid:null,from:Qa(_,F,Te.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:_,to:B,toHandle:null,toPosition:UI[F.position],toNode:null,pointer:B};function z(){R=!0,m(V),h?.(t,{nodeId:o,handleId:n,handleType:N})}C===0&&z();function G(Z){if(!R){let{x:he,y:lt}=Cs(Z),He=he-E,nt=lt-P;if(!(He*He+nt*nt>C*C))return;z()}if(!S()||!F){Y(Z);return}let se=v();B=Cs(Z,D),T=U6(jd(B,se,!1,[1,1]),r,l,F),L||(q(),L=!0);let we=EA(Z,{handle:T,connectionMode:e,fromNodeId:o,fromHandleId:n,fromType:i?"target":"source",isValidConnection:x,doc:k,lib:c,flowId:u,nodeLookup:l});$=we.handleDomNode,H=we.connection,j=G6(!!T,we.isValid);let _e=l.get(o),Pe=_e?Qa(_e,F,Te.Left,!0):V.from,K={...V,from:Pe,isValid:j,to:we.toHandle&&j?Pf({x:we.toHandle.x,y:we.toHandle.y},se):B,toHandle:we.toHandle,toPosition:j&&we.toHandle?we.toHandle.position:UI[F.position],toNode:we.toHandle?l.get(we.toHandle.nodeId):null,pointer:B};m(K),V=K}function Y(Z){if(!("touches"in Z&&Z.touches.length>0)){if(R){(T||$)&&H&&j&&b?.(H);let{inProgress:se,...we}=V,_e={...we,toPosition:V.toHandle?V.toPosition:null};g?.(Z,_e),s&&y?.(Z,_e)}p(),cancelAnimationFrame(M),L=!1,j=!1,H=null,$=null,k.removeEventListener("mousemove",G),k.removeEventListener("mouseup",Y),k.removeEventListener("touchmove",G),k.removeEventListener("touchend",Y)}}k.addEventListener("mousemove",G),k.addEventListener("mouseup",Y),k.addEventListener("touchmove",G),k.addEventListener("touchend",Y)}function EA(t,{handle:e,connectionMode:r,fromNodeId:n,fromHandleId:o,fromType:s,doc:i,lib:a,flowId:l,isValidConnection:c=kA,nodeLookup:d}){let u=s==="target",f=e?i.querySelector(`.${a}-flow__handle[data-id="${l}-${e?.nodeId}-${e?.id}-${e?.type}"]`):null,{x:p,y:h}=Cs(t),b=i.elementFromPoint(p,h),g=b?.classList.contains(`${a}-flow__handle`)?b:f,x={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let y=CA(void 0,g),m=g.getAttribute("data-nodeid"),v=g.getAttribute("data-handleid"),S=g.classList.contains("connectable"),w=g.classList.contains("connectableend");if(!m||!y)return x;let C={source:u?m:n,sourceHandle:u?v:o,target:u?n:m,targetHandle:u?o:v};x.connection=C;let k=S&&w&&(r===Za.Strict?u&&y==="source"||!u&&y==="target":m!==n||v!==o);x.isValid=k&&c(C),x.toHandle=NA(m,y,v,d,r,!0)}return x}function TA({domNode:t,panZoom:e,getTransform:r,getViewScale:n}){let o=On(t);function s({translateExtent:a,width:l,height:c,zoomStep:d=1,pannable:u=!0,zoomable:f=!0,inversePan:p=!1}){let h=m=>{if(m.sourceEvent.type!=="wheel"||!e)return;let v=r(),S=m.sourceEvent.ctrlKey&&Wd()?10:1,w=-m.sourceEvent.deltaY*(m.sourceEvent.deltaMode===1?.05:m.sourceEvent.deltaMode?1:.002)*d,C=v[2]*Math.pow(2,w*S);e.scaleTo(C)},b=[0,0],g=m=>{(m.sourceEvent.type==="mousedown"||m.sourceEvent.type==="touchstart")&&(b=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY])},x=m=>{let v=r();if(m.sourceEvent.type!=="mousemove"&&m.sourceEvent.type!=="touchmove"||!e)return;let S=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY],w=[S[0]-b[0],S[1]-b[1]];b=S;let C=n()*Math.max(v[2],Math.log(v[2]))*(p?-1:1),A={x:v[0]-w[0]*C,y:v[1]-w[1]*C},k=[[0,0],[l,c]];e.setViewportConstrained({x:A.x,y:A.y,zoom:v[2]},k,a)},y=Fm().on("start",g).on("zoom",u?x:null).on("zoom.wheel",f?h:null);o.call(y,{})}function i(){o.on("zoom",null)}return{update:s,destroy:i,pointer:yo}}function Y6({zoomPanValues:t,noWheelClassName:e,d3Selection:r,d3Zoom:n,panOnScrollMode:o,panOnScrollSpeed:s,zoomOnPinch:i,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:c}){return d=>{if(Ld(d,e))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();let u=r.property("__zoom").k||1;if(d.ctrlKey&&i){let g=yo(d),x=AA(d),y=u*Math.pow(2,x);n.scaleTo(r,y,g,d);return}let f=d.deltaMode===1?20:1,p=o===ia.Vertical?0:d.deltaX*f,h=o===ia.Horizontal?0:d.deltaY*f;!Wd()&&d.shiftKey&&o!==ia.Vertical&&(p=d.deltaY*f,h=0),n.translateBy(r,-(p/u)*s,-(h/u)*s,{internal:!0});let b=tg(r.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?(l?.(d,b),t.panScrollTimeout=setTimeout(()=>{c?.(d,b),t.isPanScrolling=!1},150)):(t.isPanScrolling=!0,a?.(d,b))}}function X6({noWheelClassName:t,preventScrolling:e,d3ZoomHandler:r}){return function(n,o){let s=n.type==="wheel",i=!e&&s&&!n.ctrlKey,a=Ld(n,t);if(n.ctrlKey&&s&&a&&n.preventDefault(),i||a)return null;n.preventDefault(),r.call(this,n,o)}}function J6({zoomPanValues:t,onDraggingChange:e,onPanZoomStart:r}){return n=>{if(n.sourceEvent?.internal)return;let o=tg(n.transform);t.mouseButton=n.sourceEvent?.button||0,t.isZoomingOrPanning=!0,t.prevViewport=o,n.sourceEvent?.type==="mousedown"&&e(!0),r&&r?.(n.sourceEvent,o)}}function Z6({zoomPanValues:t,panOnDrag:e,onPaneContextMenu:r,onTransformChange:n,onPanZoom:o}){return s=>{t.usedRightMouseButton=!!(r&&IA(e,t.mouseButton??0)),s.sourceEvent?.sync||n([s.transform.x,s.transform.y,s.transform.k]),o&&!s.sourceEvent?.internal&&o?.(s.sourceEvent,tg(s.transform))}}function Q6({zoomPanValues:t,panOnDrag:e,panOnScroll:r,onDraggingChange:n,onPanZoomEnd:o,onPaneContextMenu:s}){return i=>{if(!i.sourceEvent?.internal&&(t.isZoomingOrPanning=!1,s&&IA(e,t.mouseButton??0)&&!t.usedRightMouseButton&&i.sourceEvent&&s(i.sourceEvent),t.usedRightMouseButton=!1,n(!1),o)){let a=tg(i.transform);t.prevViewport=a,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{o?.(i.sourceEvent,a)},r?150:0)}}}function e9({zoomActivationKeyPressed:t,zoomOnScroll:e,zoomOnPinch:r,panOnDrag:n,panOnScroll:o,zoomOnDoubleClick:s,userSelectionActive:i,noWheelClassName:a,noPanClassName:l,lib:c,connectionInProgress:d}){return u=>{let f=t||e,p=r&&u.ctrlKey,h=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(Ld(u,`${c}-flow__node`)||Ld(u,`${c}-flow__edge`)))return!0;if(!n&&!f&&!o&&!s&&!r||i||d&&!h||Ld(u,a)&&h||Ld(u,l)&&(!h||o&&h&&!t)||!r&&u.ctrlKey&&h)return!1;if(!r&&u.type==="touchstart"&&u.touches?.length>1)return u.preventDefault(),!1;if(!f&&!o&&!p&&h||!n&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(n)&&!n.includes(u.button)&&u.type==="mousedown")return!1;let b=Array.isArray(n)&&n.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||h)&&b}}function MA({domNode:t,minZoom:e,maxZoom:r,translateExtent:n,viewport:o,onPanZoom:s,onPanZoomStart:i,onPanZoomEnd:a,onDraggingChange:l}){let c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=t.getBoundingClientRect(),u=Fm().scaleExtent([e,r]).translateExtent(n),f=On(t).call(u);y({x:o.x,y:o.y,zoom:Bd(o.zoom,e,r)},[[0,0],[d.width,d.height]],n);let p=f.on("wheel.zoom"),h=f.on("dblclick.zoom");u.wheelDelta(AA);function b(T,E){return f?new Promise(P=>{u?.interpolate(E?.interpolate==="linear"?oa:Ql).transform(ly(f,E?.duration,E?.ease,()=>P(!0)),T)}):Promise.resolve(!1)}function g({noWheelClassName:T,noPanClassName:E,onPaneContextMenu:P,userSelectionActive:N,panOnScroll:D,panOnDrag:R,panOnScrollMode:O,panOnScrollSpeed:B,preventScrolling:L,zoomOnPinch:H,zoomOnScroll:j,zoomOnDoubleClick:$,zoomActivationKeyPressed:q,lib:F,onTransformChange:_,connectionInProgress:W,paneClickDistance:V,selectionOnDrag:z}){N&&!c.isZoomingOrPanning&&x();let G=D&&!q&&!N;u.clickDistance(z?1/0:!Ns(V)||V<0?0:V);let Y=G?Y6({zoomPanValues:c,noWheelClassName:T,d3Selection:f,d3Zoom:u,panOnScrollMode:O,panOnScrollSpeed:B,zoomOnPinch:H,onPanZoomStart:i,onPanZoom:s,onPanZoomEnd:a}):X6({noWheelClassName:T,preventScrolling:L,d3ZoomHandler:p});if(f.on("wheel.zoom",Y,{passive:!1}),!N){let se=J6({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:i});u.on("start",se);let we=Z6({zoomPanValues:c,panOnDrag:R,onPaneContextMenu:!!P,onPanZoom:s,onTransformChange:_});u.on("zoom",we);let _e=Q6({zoomPanValues:c,panOnDrag:R,panOnScroll:D,onPaneContextMenu:P,onPanZoomEnd:a,onDraggingChange:l});u.on("end",_e)}let Z=e9({zoomActivationKeyPressed:q,panOnDrag:R,zoomOnScroll:j,panOnScroll:D,zoomOnDoubleClick:$,zoomOnPinch:H,userSelectionActive:N,noPanClassName:E,noWheelClassName:T,lib:F,connectionInProgress:W});u.filter(Z),$?f.on("dblclick.zoom",h):f.on("dblclick.zoom",null)}function x(){u.on("zoom",null)}async function y(T,E,P){let N=ay(T),D=u?.constrain()(N,E,P);return D&&await b(D),new Promise(R=>R(D))}async function m(T,E){let P=ay(T);return await b(P,E),new Promise(N=>N(P))}function v(T){if(f){let E=ay(T),P=f.property("__zoom");(P.k!==T.zoom||P.x!==T.x||P.y!==T.y)&&u?.transform(f,E,null,{sync:!0})}}function S(){let T=f?Af(f.node()):{x:0,y:0,k:1};return{x:T.x,y:T.y,zoom:T.k}}function w(T,E){return f?new Promise(P=>{u?.interpolate(E?.interpolate==="linear"?oa:Ql).scaleTo(ly(f,E?.duration,E?.ease,()=>P(!0)),T)}):Promise.resolve(!1)}function C(T,E){return f?new Promise(P=>{u?.interpolate(E?.interpolate==="linear"?oa:Ql).scaleBy(ly(f,E?.duration,E?.ease,()=>P(!0)),T)}):Promise.resolve(!1)}function A(T){u?.scaleExtent(T)}function k(T){u?.translateExtent(T)}function M(T){let E=!Ns(T)||T<0?0:T;u?.clickDistance(E)}return{update:g,destroy:x,setViewport:m,setViewportConstrained:y,getViewport:S,scaleTo:w,scaleBy:C,setScaleExtent:A,setTranslateExtent:k,syncViewport:v,setClickDistance:M}}function t9({width:t,prevWidth:e,height:r,prevHeight:n,affectsX:o,affectsY:s}){let i=t-e,a=r-n,l=[i>0?1:i<0?-1:0,a>0?1:a<0?-1:0];return i&&o&&(l[0]=l[0]*-1),a&&s&&(l[1]=l[1]*-1),l}function rA(t){let e=t.includes("right")||t.includes("left"),r=t.includes("bottom")||t.includes("top"),n=t.includes("left"),o=t.includes("top");return{isHorizontal:e,isVertical:r,affectsX:n,affectsY:o}}function Xa(t,e){return Math.max(0,e-t)}function Ja(t,e){return Math.max(0,t-e)}function Vm(t,e,r){return Math.max(0,e-t,t-r)}function nA(t,e){return t?!e:e}function r9(t,e,r,n,o,s,i,a){let{affectsX:l,affectsY:c}=e,{isHorizontal:d,isVertical:u}=e,f=d&&u,{xSnapped:p,ySnapped:h}=r,{minWidth:b,maxWidth:g,minHeight:x,maxHeight:y}=n,{x:m,y:v,width:S,height:w,aspectRatio:C}=t,A=Math.floor(d?p-t.pointerX:0),k=Math.floor(u?h-t.pointerY:0),M=S+(l?-A:A),T=w+(c?-k:k),E=-s[0]*S,P=-s[1]*w,N=Vm(M,b,g),D=Vm(T,x,y);if(i){let B=0,L=0;l&&A<0?B=Xa(m+A+E,i[0][0]):!l&&A>0&&(B=Ja(m+M+E,i[1][0])),c&&k<0?L=Xa(v+k+P,i[0][1]):!c&&k>0&&(L=Ja(v+T+P,i[1][1])),N=Math.max(N,B),D=Math.max(D,L)}if(a){let B=0,L=0;l&&A>0?B=Ja(m+A,a[0][0]):!l&&A<0&&(B=Xa(m+M,a[1][0])),c&&k>0?L=Ja(v+k,a[0][1]):!c&&k<0&&(L=Xa(v+T,a[1][1])),N=Math.max(N,B),D=Math.max(D,L)}if(o){if(d){let B=Vm(M/C,x,y)*C;if(N=Math.max(N,B),i){let L=0;!l&&!c||l&&!c&&f?L=Ja(v+P+M/C,i[1][1])*C:L=Xa(v+P+(l?A:-A)/C,i[0][1])*C,N=Math.max(N,L)}if(a){let L=0;!l&&!c||l&&!c&&f?L=Xa(v+M/C,a[1][1])*C:L=Ja(v+(l?A:-A)/C,a[0][1])*C,N=Math.max(N,L)}}if(u){let B=Vm(T*C,b,g)/C;if(D=Math.max(D,B),i){let L=0;!l&&!c||c&&!l&&f?L=Ja(m+T*C+E,i[1][0])/C:L=Xa(m+(c?k:-k)*C+E,i[0][0])/C,D=Math.max(D,L)}if(a){let L=0;!l&&!c||c&&!l&&f?L=Xa(m+T*C,a[1][0])/C:L=Ja(m+(c?k:-k)*C,a[0][0])/C,D=Math.max(D,L)}}}k=k+(k<0?D:-D),A=A+(A<0?N:-N),o&&(f?M>T*C?k=(nA(l,c)?-A:A)/C:A=(nA(l,c)?-k:k)*C:d?(k=A/C,c=l):(A=k*C,l=c));let R=l?m+A:m,O=c?v+k:v;return{width:S+(l?-A:A),height:w+(c?-k:k),x:s[0]*A*(l?-1:1)+R,y:s[1]*k*(c?-1:1)+O}}function o9(t){return[[0,0],[t.measured.width,t.measured.height]]}function s9(t,e,r){let n=e.position.x+t.position.x,o=e.position.y+t.position.y,s=t.measured.width??0,i=t.measured.height??0,a=r[0]*s,l=r[1]*i;return[[n-a,o-l],[n+s-a,o+i-l]]}function OA({domNode:t,nodeId:e,getStoreItems:r,onChange:n,onEnd:o}){let s=On(t),i={controlDirection:rA("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:c,boundaries:d,keepAspectRatio:u,resizeDirection:f,onResizeStart:p,onResize:h,onResizeEnd:b,shouldResize:g}){let x={...DA},y={...n9};i={boundaries:d,resizeDirection:f,keepAspectRatio:u,controlDirection:rA(c)};let m,v=null,S=[],w,C,A,k=!1,M=bm().on("start",T=>{let{nodeLookup:E,transform:P,snapGrid:N,snapToGrid:D,nodeOrigin:R,paneDomNode:O}=r();if(m=E.get(e),!m)return;v=O?.getBoundingClientRect()??null;let{xSnapped:B,ySnapped:L}=Mf(T.sourceEvent,{transform:P,snapGrid:N,snapToGrid:D,containerBounds:v});x={width:m.measured.width??0,height:m.measured.height??0,x:m.position.x??0,y:m.position.y??0},y={...x,pointerX:B,pointerY:L,aspectRatio:x.width/x.height},w=void 0,m.parentId&&(m.extent==="parent"||m.expandParent)&&(w=E.get(m.parentId),C=w&&m.extent==="parent"?o9(w):void 0),S=[],A=void 0;for(let[H,j]of E)if(j.parentId===e&&(S.push({id:H,position:{...j.position},extent:j.extent}),j.extent==="parent"||j.expandParent)){let $=s9(j,m,j.origin??R);A?A=[[Math.min($[0][0],A[0][0]),Math.min($[0][1],A[0][1])],[Math.max($[1][0],A[1][0]),Math.max($[1][1],A[1][1])]]:A=$}p?.(T,{...x})}).on("drag",T=>{let{transform:E,snapGrid:P,snapToGrid:N,nodeOrigin:D}=r(),R=Mf(T.sourceEvent,{transform:E,snapGrid:P,snapToGrid:N,containerBounds:v}),O=[];if(!m)return;let{x:B,y:L,width:H,height:j}=x,$={},q=m.origin??D,{width:F,height:_,x:W,y:V}=r9(y,i.controlDirection,R,i.boundaries,i.keepAspectRatio,q,C,A),z=F!==H,G=_!==j,Y=W!==B&&z,Z=V!==L&&G;if(!Y&&!Z&&!z&&!G)return;if((Y||Z||q[0]===1||q[1]===1)&&($.x=Y?W:x.x,$.y=Z?V:x.y,x.x=$.x,x.y=$.y,S.length>0)){let Pe=W-B,K=V-L;for(let he of S)he.position={x:he.position.x-Pe+q[0]*(F-H),y:he.position.y-K+q[1]*(_-j)},O.push(he)}if((z||G)&&($.width=z&&(!i.resizeDirection||i.resizeDirection==="horizontal")?F:x.width,$.height=G&&(!i.resizeDirection||i.resizeDirection==="vertical")?_:x.height,x.width=$.width,x.height=$.height),w&&m.expandParent){let Pe=q[0]*($.width??0);$.x&&$.x<Pe&&(x.x=Pe,y.x=y.x-($.x-Pe));let K=q[1]*($.height??0);$.y&&$.y<K&&(x.y=K,y.y=y.y-($.y-K))}let se=t9({width:x.width,prevWidth:H,height:x.height,prevHeight:j,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),we={...x,direction:se};g?.(T,we)!==!1&&(k=!0,h?.(T,we),n($,O))}).on("end",T=>{k&&(b?.(T,{...x}),o?.({...x}),k=!1)});s.call(M)}function l(){s.on(".drag",null)}return{update:a,destroy:l}}var So,$d,dy,uy,Za,ia,aa,fy,Ai,pn,Te,UI,hy,oA,my,Rf,gy,Fd,Wm,sA,Bd,oc,GI,cA,Um,cy,Gm,sc,jm,xy,Hd,yy,Ns,vy,Vd,jd,Pf,Df,Wd,Km,Cy,M6,Ey,Cs,KI,P6,R6,ic,YI,D6,XI,gA,L6,Iy,B6,W6,kA,eg,tg,ay,Ld,IA,q6,ly,AA,la,PA,RA,DA,n9,Dy=U(()=>{"use strict";Fx();Oo();WI();Pd();So={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:e,sourceHandle:r,targetHandle:n})=>`Couldn't create edge for ${t} handle id: "${t==="source"?r:n}", edge id: ${e}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},$d=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],dy=["Enter"," ","Escape"],uy={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:e,y:r})=>`Moved selected node ${t}. New position, x: ${e}, y: ${r}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};(function(t){t.Strict="strict",t.Loose="loose"})(Za||(Za={}));(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(ia||(ia={}));(function(t){t.Partial="partial",t.Full="full"})(aa||(aa={}));fy={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Ai||(Ai={}));(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(pn||(pn={}));(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Te||(Te={}));UI={[Te.Left]:Te.Right,[Te.Right]:Te.Left,[Te.Top]:Te.Bottom,[Te.Bottom]:Te.Top};hy=t=>"id"in t&&"source"in t&&"target"in t,oA=t=>"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),my=t=>"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),Rf=(t,e=[0,0])=>{let{width:r,height:n}=Mi(t),o=t.origin??e,s=r*o[0],i=n*o[1];return{x:t.position.x-s,y:t.position.y-i}},gy=(t,e={nodeOrigin:[0,0]})=>{if(process.env.NODE_ENV==="development"&&!e.nodeLookup&&console.warn("Please use `getNodesBounds` from `useReactFlow`/`useSvelteFlow` hook to ensure correct values for sub flows. If not possible, you have to provide a nodeLookup to support sub flows."),t.length===0)return{x:0,y:0,width:0,height:0};let r=t.reduce((n,o)=>{let s=typeof o=="string",i=!e.nodeLookup&&!s?o:void 0;e.nodeLookup&&(i=s?e.nodeLookup.get(o):my(o)?o:e.nodeLookup.get(o.id));let a=i?jm(i,e.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Um(n,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Gm(r)},Fd=(t,e={})=>{let r={x:1/0,y:1/0,x2:-1/0,y2:-1/0},n=!1;return t.forEach(o=>{(e.filter===void 0||e.filter(o))&&(r=Um(r,jm(o)),n=!0)}),n?Gm(r):{x:0,y:0,width:0,height:0}},Wm=(t,e,[r,n,o]=[0,0,1],s=!1,i=!1)=>{let a={...jd(e,[r,n,o]),width:e.width/o,height:e.height/o},l=[];for(let c of t.values()){let{measured:d,selectable:u=!0,hidden:f=!1}=c;if(i&&!u||f)continue;let p=d.width??c.width??c.initialWidth??null,h=d.height??c.height??c.initialHeight??null,b=Hd(a,sc(c)),g=(p??0)*(h??0),x=s&&b>0;(!c.internals.handleBounds||x||b>=g||c.dragging)&&l.push(c)}return l},sA=(t,e)=>{let r=new Set;return t.forEach(n=>{r.add(n.id)}),e.filter(n=>r.has(n.source)||r.has(n.target))};Bd=(t,e=0,r=1)=>Math.min(Math.max(t,e),r),oc=(t={x:0,y:0},e,r)=>({x:Bd(t.x,e[0][0],e[1][0]-(r?.width??0)),y:Bd(t.y,e[0][1],e[1][1]-(r?.height??0))});GI=(t,e,r)=>t<e?Bd(Math.abs(t-e),1,e)/e:t>r?-Bd(Math.abs(t-r),1,e)/e:0,cA=(t,e,r=15,n=40)=>{let o=GI(t.x,n,e.width-n)*r,s=GI(t.y,n,e.height-n)*r;return[o,s]},Um=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),cy=({x:t,y:e,width:r,height:n})=>({x:t,y:e,x2:t+r,y2:e+n}),Gm=({x:t,y:e,x2:r,y2:n})=>({x:t,y:e,width:r-t,height:n-e}),sc=(t,e=[0,0])=>{let{x:r,y:n}=my(t)?t.internals.positionAbsolute:Rf(t,e);return{x:r,y:n,width:t.measured?.width??t.width??t.initialWidth??0,height:t.measured?.height??t.height??t.initialHeight??0}},jm=(t,e=[0,0])=>{let{x:r,y:n}=my(t)?t.internals.positionAbsolute:Rf(t,e);return{x:r,y:n,x2:r+(t.measured?.width??t.width??t.initialWidth??0),y2:n+(t.measured?.height??t.height??t.initialHeight??0)}},xy=(t,e)=>Gm(Um(cy(t),cy(e))),Hd=(t,e)=>{let r=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),n=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(r*n)},yy=t=>Ns(t.width)&&Ns(t.height)&&Ns(t.x)&&Ns(t.y),Ns=t=>!isNaN(t)&&isFinite(t),vy=(t,e)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${e} Help: https://reactflow.dev/error#${t}`)},Vd=(t,e=[1,1])=>({x:e[0]*Math.round(t.x/e[0]),y:e[1]*Math.round(t.y/e[1])}),jd=({x:t,y:e},[r,n,o],s=!1,i=[1,1])=>{let a={x:(t-r)/o,y:(e-n)/o};return s?Vd(a,i):a},Pf=({x:t,y:e},[r,n,o])=>({x:t*o+r,y:e*o+n});Df=(t,e,r,n,o,s)=>{let i=I6(s,e,r),a=(e-i.x)/t.width,l=(r-i.y)/t.height,c=Math.min(a,l),d=Bd(c,n,o),u=t.x+t.width/2,f=t.y+t.height/2,p=e/2-u*d,h=r/2-f*d,b=A6(t,p,h,d,e,r),g={left:Math.min(b.left-i.left,0),top:Math.min(b.top-i.top,0),right:Math.min(b.right-i.right,0),bottom:Math.min(b.bottom-i.bottom,0)};return{x:p-g.left+g.right,y:h-g.top+g.bottom,zoom:d}},Wd=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;Km=t=>({width:t.offsetWidth,height:t.offsetHeight}),Cy=t=>t?.getRootNode?.()||window?.document,M6=["INPUT","SELECT","TEXTAREA"];Ey=t=>"clientX"in t,Cs=(t,e)=>{let r=Ey(t),n=r?t.clientX:t.touches?.[0].clientX,o=r?t.clientY:t.touches?.[0].clientY;return{x:n-(e?.left??0),y:o-(e?.top??0)}},KI=(t,e,r,n,o)=>{let s=e.querySelectorAll(`.${t}`);return!s||!s.length?null:Array.from(s).map(i=>{let a=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:t,nodeId:o,position:i.getAttribute("data-handlepos"),x:(a.left-r.left)/n,y:(a.top-r.top)/n,...Km(i)}})};P6=({source:t,sourceHandle:e,target:r,targetHandle:n})=>`xy-edge__${t}${e||""}-${r}${n||""}`,R6=(t,e)=>e.some(r=>r.source===t.source&&r.target===t.target&&(r.sourceHandle===t.sourceHandle||!r.sourceHandle&&!t.sourceHandle)&&(r.targetHandle===t.targetHandle||!r.targetHandle&&!t.targetHandle)),ic=(t,e,r={})=>{if(!t.source||!t.target)return vy("006",So.error006()),e;let n=r.getEdgeId||P6,o;return hy(t)?o={...t}:o={...t,id:n(t)},R6(o,e)?e:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,e.concat(o))};YI={[Te.Left]:{x:-1,y:0},[Te.Right]:{x:1,y:0},[Te.Top]:{x:0,y:-1},[Te.Bottom]:{x:0,y:1}},D6=({source:t,sourcePosition:e=Te.Bottom,target:r})=>e===Te.Left||e===Te.Right?t.x<r.x?{x:1,y:0}:{x:-1,y:0}:t.y<r.y?{x:0,y:1}:{x:0,y:-1},XI=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));gA=1e3,L6=10,Iy={nodeOrigin:[0,0],nodeExtent:$d,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},B6={...Iy,checkEquality:!0};W6=250;kA=()=>!0;eg={onPointerDown:K6,isValid:EA};tg=t=>({x:t.x,y:t.y,zoom:t.k}),ay=({x:t,y:e,zoom:r})=>nc.translate(t,e).scale(r),Ld=(t,e)=>t.target.closest(`.${e}`),IA=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),q6=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,ly=(t,e=0,r=q6,n=()=>{})=>{let o=typeof e=="number"&&e>0;return o||n(),o?t.transition().duration(e).ease(r).on("end",n):t},AA=t=>{let e=t.ctrlKey&&Wd()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e};(function(t){t.Line="line",t.Handle="handle"})(la||(la={}));PA=["top-left","top-right","bottom-left","bottom-right"],RA=["top","right","bottom","left"];DA={width:0,height:0,x:0,y:0},n9={...DA,pointerX:0,pointerY:0,aspectRatio:1}});function Rt(t,e){let r=(0,te.useContext)(ig);if(r===null)throw new Error(sM);return(0,sg.useStoreWithEqualityFn)(r,t,e)}function Pr(){let t=(0,te.useContext)(ig);if(t===null)throw new Error(sM);return(0,te.useMemo)(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}function f9({rfId:t}){let e=Rt(d9);return(0,Q.jsx)("div",{id:`${c9}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:l9,children:e})}function p9({rfId:t,disableKeyboardA11y:e}){let r=Rt(u9);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("div",{id:`${iM}-${t}`,style:_A,children:e?r["node.a11yDescription.default"]:r["node.a11yDescription.keyboardDisabled"]}),(0,Q.jsx)("div",{id:`${aM}-${t}`,style:_A,children:r["edge.a11yDescription.default"]}),!e&&(0,Q.jsx)(f9,{rfId:t})]})}function h9({proOptions:t,position:e="bottom-right"}){return t?.hideAttribution?null:(0,Q.jsx)(Gd,{position:e,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:(0,Q.jsx)("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}function g9(t,e){return(0,Cr.shallow)(t.selectedNodes.map(rg),e.selectedNodes.map(rg))&&(0,Cr.shallow)(t.selectedEdges.map(rg),e.selectedEdges.map(rg))}function b9({onSelectionChange:t}){let e=Pr(),{selectedNodes:r,selectedEdges:n}=Rt(m9,g9);return(0,te.useEffect)(()=>{let o={nodes:r,edges:n};t?.(o),e.getState().onSelectionChangeHandlers.forEach(s=>s(o))},[r,n,t]),null}function y9({onSelectionChange:t}){let e=Rt(x9);return t||e?(0,Q.jsx)(b9,{onSelectionChange:t}):null}function N9(t){let{setNodes:e,setEdges:r,setMinZoom:n,setMaxZoom:o,setTranslateExtent:s,setNodeExtent:i,reset:a,setDefaultNodesAndEdges:l}=Rt(S9,Cr.shallow),c=Pr();(0,te.useEffect)(()=>(l(t.defaultNodes,t.defaultEdges),()=>{d.current=BA,a()}),[]);let d=(0,te.useRef)(BA);return(0,te.useEffect)(()=>{for(let u of LA){let f=t[u],p=d.current[u];f!==p&&(typeof t[u]>"u"||(u==="nodes"?e(f):u==="edges"?r(f):u==="minZoom"?n(f):u==="maxZoom"?o(f):u==="translateExtent"?s(f):u==="nodeExtent"?i(f):u==="ariaLabelConfig"?c.setState({ariaLabelConfig:uA(f)}):u==="fitView"?c.setState({fitViewQueued:f}):u==="fitViewOptions"?c.setState({fitViewOptions:f}):c.setState({[u]:f})))}d.current=t},LA.map(u=>t[u])),null}function zA(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function C9(t){let[e,r]=(0,te.useState)(t==="system"?null:t);return(0,te.useEffect)(()=>{if(t!=="system"){r(t);return}let n=zA(),o=()=>r(n?.matches?"dark":"light");return o(),n?.addEventListener("change",o),()=>{n?.removeEventListener("change",o)}},[t]),e!==null?e:zA()?.matches?"dark":"light"}function _f(t=null,e={target:$A,actInsideInputWithModifier:!0}){let[r,n]=(0,te.useState)(!1),o=(0,te.useRef)(!1),s=(0,te.useRef)(new Set([])),[i,a]=(0,te.useMemo)(()=>{if(t!==null){let c=(Array.isArray(t)?t:[t]).filter(u=>typeof u=="string").map(u=>u.replace("+",`
|
|
406
|
+
`).replace(`
|
|
407
|
+
|
|
408
|
+
`,`
|
|
409
|
+
+`).split(`
|
|
410
|
+
`)),d=c.reduce((u,f)=>u.concat(...f),[]);return[c,d]}return[[],[]]},[t]);return(0,te.useEffect)(()=>{let l=e?.target??$A,c=e?.actInsideInputWithModifier??!0;if(t!==null){let d=p=>{if(o.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!o.current||o.current&&!c)&&ky(p))return!1;let b=HA(p.code,a);if(s.current.add(p[b]),FA(i,s.current,!1)){let g=p.composedPath?.()?.[0]||p.target,x=g?.nodeName==="BUTTON"||g?.nodeName==="A";e.preventDefault!==!1&&(o.current||!x)&&p.preventDefault(),n(!0)}},u=p=>{let h=HA(p.code,a);FA(i,s.current,!0)?(n(!1),s.current.clear()):s.current.delete(p[h]),p.key==="Meta"&&s.current.clear(),o.current=!1},f=()=>{s.current.clear(),n(!1)};return l?.addEventListener("keydown",d),l?.addEventListener("keyup",u),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{l?.removeEventListener("keydown",d),l?.removeEventListener("keyup",u),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[t,n]),r}function FA(t,e,r){return t.filter(n=>r||n.length===e.size).some(n=>n.every(o=>e.has(o)))}function HA(t,e){return e.includes(t)?"code":"key"}function cM(t,e){let r=[],n=new Map,o=[];for(let s of t)if(s.type==="add"){o.push(s);continue}else if(s.type==="remove"||s.type==="replace")n.set(s.id,[s]);else{let i=n.get(s.id);i?i.push(s):n.set(s.id,[s])}for(let s of e){let i=n.get(s.id);if(!i){r.push(s);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){r.push({...i[0].item});continue}let a={...s};for(let l of i)E9(l,a);r.push(a)}return o.length&&o.forEach(s=>{s.index!==void 0?r.splice(s.index,0,{...s.item}):r.push({...s.item})}),r}function E9(t,e){switch(t.type){case"select":{e.selected=t.selected;break}case"position":{typeof t.position<"u"&&(e.position=t.position),typeof t.dragging<"u"&&(e.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(e.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(e.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(e.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(e.resizing=t.resizing);break}}}function ag(t,e){return cM(t,e)}function lg(t,e){return cM(t,e)}function ac(t,e){return{id:t,type:"select",selected:e}}function Ud(t,e=new Set,r=!1){let n=[];for(let[o,s]of t){let i=e.has(o);!(s.selected===void 0&&!i)&&s.selected!==i&&(r&&(s.selected=i),n.push(ac(s.id,i)))}return n}function VA({items:t=[],lookup:e}){let r=[],n=new Map(t.map(o=>[o.id,o]));for(let[o,s]of t.entries()){let i=e.get(s.id),a=i?.internals?.userNode??i;a!==void 0&&a!==s&&r.push({id:s.id,item:s,type:"replace"}),a===void 0&&r.push({item:s,type:"add",index:o})}for(let[o]of e)n.get(o)===void 0&&r.push({id:o,type:"remove"});return r}function jA(t){return{id:t.id,type:"remove"}}function dM(t){return(0,te.forwardRef)(t)}function UA(t){let[e,r]=(0,te.useState)(BigInt(0)),[n]=(0,te.useState)(()=>A9(()=>r(o=>o+BigInt(1))));return I9(()=>{let o=n.get();o.length&&(t(o),n.reset())},[e]),n}function A9(t){let e=[];return{get:()=>e,reset:()=>{e=[]},push:r=>{e.push(r),t()}}}function M9({children:t}){let e=Pr(),r=(0,te.useCallback)(a=>{let{nodes:l=[],setNodes:c,hasDefaultNodes:d,onNodesChange:u,nodeLookup:f,fitViewQueued:p,onNodesChangeMiddlewareMap:h}=e.getState(),b=l;for(let x of a)b=typeof x=="function"?x(b):x;let g=VA({items:b,lookup:f});for(let x of h.values())g=x(g);d&&c(b),g.length>0?u?.(g):p&&window.requestAnimationFrame(()=>{let{fitViewQueued:x,nodes:y,setNodes:m}=e.getState();x&&m(y)})},[]),n=UA(r),o=(0,te.useCallback)(a=>{let{edges:l=[],setEdges:c,hasDefaultEdges:d,onEdgesChange:u,edgeLookup:f}=e.getState(),p=l;for(let h of a)p=typeof h=="function"?h(p):h;d?c(p):u&&u(VA({items:p,lookup:f}))},[]),s=UA(o),i=(0,te.useMemo)(()=>({nodeQueue:n,edgeQueue:s}),[]);return(0,Q.jsx)(uM.Provider,{value:i,children:t})}function P9(){let t=(0,te.useContext)(uM);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}function Lf(){let t=k9(),e=Pr(),r=P9(),n=Rt(R9),o=(0,te.useMemo)(()=>{let s=u=>e.getState().nodeLookup.get(u),i=u=>{r.nodeQueue.push(u)},a=u=>{r.edgeQueue.push(u)},l=u=>{let{nodeLookup:f,nodeOrigin:p}=e.getState(),h=WA(u)?u:f.get(u.id),b=h.parentId?Sy(h.position,h.measured,h.parentId,f,p):h.position,g={...h,position:b,width:h.measured?.width??h.width,height:h.measured?.height??h.height};return sc(g)},c=(u,f,p={replace:!1})=>{i(h=>h.map(b=>{if(b.id===u){let g=typeof f=="function"?f(b):f;return p.replace&&WA(g)?g:{...b,...g}}return b}))},d=(u,f,p={replace:!1})=>{a(h=>h.map(b=>{if(b.id===u){let g=typeof f=="function"?f(b):f;return p.replace&&T9(g)?g:{...b,...g}}return b}))};return{getNodes:()=>e.getState().nodes.map(u=>({...u})),getNode:u=>s(u)?.internals.userNode,getInternalNode:s,getEdges:()=>{let{edges:u=[]}=e.getState();return u.map(f=>({...f}))},getEdge:u=>e.getState().edgeLookup.get(u),setNodes:i,setEdges:a,addNodes:u=>{let f=Array.isArray(u)?u:[u];r.nodeQueue.push(p=>[...p,...f])},addEdges:u=>{let f=Array.isArray(u)?u:[u];r.edgeQueue.push(p=>[...p,...f])},toObject:()=>{let{nodes:u=[],edges:f=[],transform:p}=e.getState(),[h,b,g]=p;return{nodes:u.map(x=>({...x})),edges:f.map(x=>({...x})),viewport:{x:h,y:b,zoom:g}}},deleteElements:async({nodes:u=[],edges:f=[]})=>{let{nodes:p,edges:h,onNodesDelete:b,onEdgesDelete:g,triggerNodeChanges:x,triggerEdgeChanges:y,onDelete:m,onBeforeDelete:v}=e.getState(),{nodes:S,edges:w}=await aA({nodesToRemove:u,edgesToRemove:f,nodes:p,edges:h,onBeforeDelete:v}),C=w.length>0,A=S.length>0;if(C){let k=w.map(jA);g?.(w),y(k)}if(A){let k=S.map(jA);b?.(S),x(k)}return(A||C)&&m?.({nodes:S,edges:w}),{deletedNodes:S,deletedEdges:w}},getIntersectingNodes:(u,f=!0,p)=>{let h=yy(u),b=h?u:l(u),g=p!==void 0;return b?(p||e.getState().nodes).filter(x=>{let y=e.getState().nodeLookup.get(x.id);if(y&&!h&&(x.id===u.id||!y.internals.positionAbsolute))return!1;let m=sc(g?x:y),v=Hd(m,b);return f&&v>0||v>=m.width*m.height||v>=b.width*b.height}):[]},isNodeIntersecting:(u,f,p=!0)=>{let b=yy(u)?u:l(u);if(!b)return!1;let g=Hd(b,f);return p&&g>0||g>=f.width*f.height||g>=b.width*b.height},updateNode:c,updateNodeData:(u,f,p={replace:!1})=>{c(u,h=>{let b=typeof f=="function"?f(h):f;return p.replace?{...h,data:b}:{...h,data:{...h.data,...b}}},p)},updateEdge:d,updateEdgeData:(u,f,p={replace:!1})=>{d(u,h=>{let b=typeof f=="function"?f(h):f;return p.replace?{...h,data:b}:{...h,data:{...h.data,...b}}},p)},getNodesBounds:u=>{let{nodeLookup:f,nodeOrigin:p}=e.getState();return gy(u,{nodeLookup:f,nodeOrigin:p})},getHandleConnections:({type:u,id:f,nodeId:p})=>Array.from(e.getState().connectionLookup.get(`${p}-${u}${f?`-${f}`:""}`)?.values()??[]),getNodeConnections:({type:u,handleId:f,nodeId:p})=>Array.from(e.getState().connectionLookup.get(`${p}${u?f?`-${u}-${f}`:`-${u}`:""}`)?.values()??[]),fitView:async u=>{let f=e.getState().fitViewResolver??dA();return e.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:f}),r.nodeQueue.push(p=>[...p]),f.promise}}},[]);return(0,te.useMemo)(()=>({...o,...t,viewportInitialized:n}),[n])}function O9({deleteKeyCode:t,multiSelectionKeyCode:e}){let r=Pr(),{deleteElements:n}=Lf(),o=_f(t,{actInsideInputWithModifier:!1}),s=_f(e,{target:D9});(0,te.useEffect)(()=>{if(o){let{edges:i,nodes:a}=r.getState();n({nodes:a.filter(GA),edges:i.filter(GA)}),r.setState({nodesSelectionActive:!1})}},[o]),(0,te.useEffect)(()=>{r.setState({multiSelectionActive:s})},[s])}function _9(t){let e=Pr();(0,te.useEffect)(()=>{let r=()=>{if(!t.current||!(t.current.checkVisibility?.()??!0))return!1;let n=Km(t.current);(n.height===0||n.width===0)&&e.getState().onError?.("004",So.error004()),e.setState({width:n.width||500,height:n.height||500})};if(t.current){r(),window.addEventListener("resize",r);let n=new ResizeObserver(()=>r());return n.observe(t.current),()=>{window.removeEventListener("resize",r),n&&t.current&&n.unobserve(t.current)}}},[])}function B9({onPaneContextMenu:t,zoomOnScroll:e=!0,zoomOnPinch:r=!0,panOnScroll:n=!1,panOnScrollSpeed:o=.5,panOnScrollMode:s=ia.Free,zoomOnDoubleClick:i=!0,panOnDrag:a=!0,defaultViewport:l,translateExtent:c,minZoom:d,maxZoom:u,zoomActivationKeyCode:f,preventScrolling:p=!0,children:h,noWheelClassName:b,noPanClassName:g,onViewportChange:x,isControlledViewport:y,paneClickDistance:m,selectionOnDrag:v}){let S=Pr(),w=(0,te.useRef)(null),{userSelectionActive:C,lib:A,connectionInProgress:k}=Rt(L9,Cr.shallow),M=_f(f),T=(0,te.useRef)();_9(w);let E=(0,te.useCallback)(P=>{x?.({x:P[0],y:P[1],zoom:P[2]}),y||S.setState({transform:P})},[x,y]);return(0,te.useEffect)(()=>{if(w.current){T.current=MA({domNode:w.current,minZoom:d,maxZoom:u,translateExtent:c,viewport:l,onDraggingChange:R=>S.setState(O=>O.paneDragging===R?O:{paneDragging:R}),onPanZoomStart:(R,O)=>{let{onViewportChangeStart:B,onMoveStart:L}=S.getState();L?.(R,O),B?.(O)},onPanZoom:(R,O)=>{let{onViewportChange:B,onMove:L}=S.getState();L?.(R,O),B?.(O)},onPanZoomEnd:(R,O)=>{let{onViewportChangeEnd:B,onMoveEnd:L}=S.getState();L?.(R,O),B?.(O)}});let{x:P,y:N,zoom:D}=T.current.getViewport();return S.setState({panZoom:T.current,transform:[P,N,D],domNode:w.current.closest(".react-flow")}),()=>{T.current?.destroy()}}},[]),(0,te.useEffect)(()=>{T.current?.update({onPaneContextMenu:t,zoomOnScroll:e,zoomOnPinch:r,panOnScroll:n,panOnScrollSpeed:o,panOnScrollMode:s,zoomOnDoubleClick:i,panOnDrag:a,zoomActivationKeyPressed:M,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:b,lib:A,onTransformChange:E,connectionInProgress:k,selectionOnDrag:v,paneClickDistance:m})},[t,e,r,n,o,s,i,a,M,p,g,C,b,A,E,k,v,m]),(0,Q.jsx)("div",{className:"react-flow__renderer",ref:w,style:cg,children:h})}function $9(){let{userSelectionActive:t,userSelectionRect:e}=Rt(z9,Cr.shallow);return t&&e?(0,Q.jsx)("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}function H9({isSelecting:t,selectionKeyPressed:e,selectionMode:r=aa.Full,panOnDrag:n,paneClickDistance:o,selectionOnDrag:s,onSelectionStart:i,onSelectionEnd:a,onPaneClick:l,onPaneContextMenu:c,onPaneScroll:d,onPaneMouseEnter:u,onPaneMouseMove:f,onPaneMouseLeave:p,children:h}){let b=Pr(),{userSelectionActive:g,elementsSelectable:x,dragging:y,connectionInProgress:m}=Rt(F9,Cr.shallow),v=x&&(t||g),S=(0,te.useRef)(null),w=(0,te.useRef)(),C=(0,te.useRef)(new Set),A=(0,te.useRef)(new Set),k=(0,te.useRef)(!1),M=B=>{if(k.current||m){k.current=!1;return}l?.(B),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},T=B=>{if(Array.isArray(n)&&n?.includes(2)){B.preventDefault();return}c?.(B)},E=d?B=>d(B):void 0,P=B=>{k.current&&(B.stopPropagation(),k.current=!1)},N=B=>{let{domNode:L}=b.getState();if(w.current=L?.getBoundingClientRect(),!w.current)return;let H=B.target===S.current;if(!H&&!!B.target.closest(".nokey")||!t||!(s&&H||e)||B.button!==0||!B.isPrimary)return;B.target?.setPointerCapture?.(B.pointerId),k.current=!1;let{x:q,y:F}=Cs(B.nativeEvent,w.current);b.setState({userSelectionRect:{width:0,height:0,startX:q,startY:F,x:q,y:F}}),H||(B.stopPropagation(),B.preventDefault())},D=B=>{let{userSelectionRect:L,transform:H,nodeLookup:j,edgeLookup:$,connectionLookup:q,triggerNodeChanges:F,triggerEdgeChanges:_,defaultEdgeOptions:W,resetSelectedElements:V}=b.getState();if(!w.current||!L)return;let{x:z,y:G}=Cs(B.nativeEvent,w.current),{startX:Y,startY:Z}=L;if(!k.current){let K=e?0:o;if(Math.hypot(z-Y,G-Z)<=K)return;V(),i?.(B)}k.current=!0;let se={startX:Y,startY:Z,x:z<Y?z:Y,y:G<Z?G:Z,width:Math.abs(z-Y),height:Math.abs(G-Z)},we=C.current,_e=A.current;C.current=new Set(Wm(j,se,H,r===aa.Partial,!0).map(K=>K.id)),A.current=new Set;let Pe=W?.selectable??!0;for(let K of C.current){let he=q.get(K);if(he)for(let{edgeId:lt}of he.values()){let He=$.get(lt);He&&(He.selectable??Pe)&&A.current.add(lt)}}if(!Ny(we,C.current)){let K=Ud(j,C.current,!0);F(K)}if(!Ny(_e,A.current)){let K=Ud($,A.current);_(K)}b.setState({userSelectionRect:se,userSelectionActive:!0,nodesSelectionActive:!1})},R=B=>{B.button===0&&(B.target?.releasePointerCapture?.(B.pointerId),!g&&B.target===S.current&&b.getState().userSelectionRect&&M?.(B),b.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(a?.(B),b.setState({nodesSelectionActive:C.current.size>0})))},O=n===!0||Array.isArray(n)&&n.includes(0);return(0,Q.jsxs)("div",{className:Gr(["react-flow__pane",{draggable:O,dragging:y,selection:t}]),onClick:v?void 0:Oy(M,S),onContextMenu:Oy(T,S),onWheel:Oy(E,S),onPointerEnter:v?void 0:u,onPointerMove:v?D:f,onPointerUp:v?R:void 0,onPointerDownCapture:v?N:void 0,onClickCapture:v?P:void 0,onPointerLeave:p,ref:S,style:cg,children:[h,(0,Q.jsx)($9,{})]})}function Ly({id:t,store:e,unselect:r=!1,nodeRef:n}){let{addSelectedNodes:o,unselectNodesAndEdges:s,multiSelectionActive:i,nodeLookup:a,onError:l}=e.getState(),c=a.get(t);if(!c){l?.("012",So.error012(t));return}e.setState({nodesSelectionActive:!1}),c.selected?(r||c.selected&&i)&&(s({nodes:[c],edges:[]}),requestAnimationFrame(()=>n?.current?.blur())):o([t])}function fM({nodeRef:t,disabled:e=!1,noDragClassName:r,handleSelector:n,nodeId:o,isSelectable:s,nodeClickDistance:i}){let a=Pr(),[l,c]=(0,te.useState)(!1),d=(0,te.useRef)();return(0,te.useEffect)(()=>{d.current=SA({getStoreItems:()=>a.getState(),onNodeMouseDown:u=>{Ly({id:u,store:a,nodeRef:t})},onDragStart:()=>{c(!0)},onDragStop:()=>{c(!1)}})},[]),(0,te.useEffect)(()=>{if(!(e||!t.current||!d.current))return d.current.update({noDragClassName:r,handleSelector:n,domNode:t.current,isSelectable:s,nodeId:o,nodeClickDistance:i}),()=>{d.current?.destroy()}},[r,n,e,s,t,o,i]),l}function pM(){let t=Pr();return(0,te.useCallback)(r=>{let{nodeExtent:n,snapToGrid:o,snapGrid:s,nodesDraggable:i,onError:a,updateNodePositions:l,nodeLookup:c,nodeOrigin:d}=t.getState(),u=new Map,f=V9(i),p=o?s[0]:5,h=o?s[1]:5,b=r.direction.x*p*r.factor,g=r.direction.y*h*r.factor;for(let[,x]of c){if(!f(x))continue;let y={x:x.internals.positionAbsolute.x+b,y:x.internals.positionAbsolute.y+g};o&&(y=Vd(y,s));let{position:m,positionAbsolute:v}=by({nodeId:x.id,nextPosition:y,nodeLookup:c,nodeExtent:n,nodeOrigin:d,onError:a});x.position=m,x.internals.positionAbsolute=v,u.set(x.id,x)}l(u)},[])}function G9({type:t="source",position:e=Te.Top,isValidConnection:r,isConnectable:n=!0,isConnectableStart:o=!0,isConnectableEnd:s=!0,id:i,onConnect:a,children:l,className:c,onMouseDown:d,onTouchStart:u,...f},p){let h=i||null,b=t==="target",g=Pr(),x=hM(),{connectOnClick:y,noPanClassName:m,rfId:v}=Rt(W9,Cr.shallow),{connectingFrom:S,connectingTo:w,clickConnecting:C,isPossibleEndHandle:A,connectionInProcess:k,clickConnectionInProcess:M,valid:T}=Rt(U9(x,h,t),Cr.shallow);x||g.getState().onError?.("010",So.error010());let E=D=>{let{defaultEdgeOptions:R,onConnect:O,hasDefaultEdges:B}=g.getState(),L={...R,...D};if(B){let{edges:H,setEdges:j}=g.getState();j(ic(L,H))}O?.(L),a?.(L)},P=D=>{if(!x)return;let R=Ey(D.nativeEvent);if(o&&(R&&D.button===0||!R)){let O=g.getState();eg.onPointerDown(D.nativeEvent,{handleDomNode:D.currentTarget,autoPanOnConnect:O.autoPanOnConnect,connectionMode:O.connectionMode,connectionRadius:O.connectionRadius,domNode:O.domNode,nodeLookup:O.nodeLookup,lib:O.lib,isTarget:b,handleId:h,nodeId:x,flowId:O.rfId,panBy:O.panBy,cancelConnection:O.cancelConnection,onConnectStart:O.onConnectStart,onConnectEnd:(...B)=>g.getState().onConnectEnd?.(...B),updateConnection:O.updateConnection,onConnect:E,isValidConnection:r||((...B)=>g.getState().isValidConnection?.(...B)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:O.autoPanSpeed,dragThreshold:O.connectionDragThreshold})}R?d?.(D):u?.(D)},N=D=>{let{onClickConnectStart:R,onClickConnectEnd:O,connectionClickStartHandle:B,connectionMode:L,isValidConnection:H,lib:j,rfId:$,nodeLookup:q,connection:F}=g.getState();if(!x||!B&&!o)return;if(!B){R?.(D.nativeEvent,{nodeId:x,handleId:h,handleType:t}),g.setState({connectionClickStartHandle:{nodeId:x,type:t,id:h}});return}let _=Cy(D.target),W=r||H,{connection:V,isValid:z}=eg.isValid(D.nativeEvent,{handle:{nodeId:x,id:h,type:t},connectionMode:L,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:W,flowId:$,doc:_,lib:j,nodeLookup:q});z&&V&&E(V);let G=structuredClone(F);delete G.inProgress,G.toPosition=G.toHandle?G.toHandle.position:null,O?.(D,G),g.setState({connectionClickStartHandle:null})};return(0,Q.jsx)("div",{"data-handleid":h,"data-nodeid":x,"data-handlepos":e,"data-id":`${v}-${x}-${h}-${t}`,className:Gr(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",m,c,{source:!b,target:b,connectable:n,connectablestart:o,connectableend:s,clickconnecting:C,connectingfrom:S,connectingto:w,valid:T,connectionindicator:n&&(!k||A)&&(k||M?s:o)}]),onMouseDown:P,onTouchStart:P,onClick:y?N:void 0,ref:p,...f,children:l})}function K9({data:t,isConnectable:e,sourcePosition:r=Te.Bottom}){return(0,Q.jsxs)(Q.Fragment,{children:[t?.label,(0,Q.jsx)(qr,{type:"source",position:r,isConnectable:e})]})}function q9({data:t,isConnectable:e,targetPosition:r=Te.Top,sourcePosition:n=Te.Bottom}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qr,{type:"target",position:r,isConnectable:e}),t?.label,(0,Q.jsx)(qr,{type:"source",position:n,isConnectable:e})]})}function Y9(){return null}function X9({data:t,isConnectable:e,targetPosition:r=Te.Top}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qr,{type:"target",position:r,isConnectable:e}),t?.label]})}function J9(t){return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??t.style?.width,height:t.height??t.initialHeight??t.style?.height}:{width:t.width??t.style?.width,height:t.height??t.style?.height}}function Q9({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:r}){let n=Pr(),{width:o,height:s,transformString:i,userSelectionActive:a}=Rt(Z9,Cr.shallow),l=pM(),c=(0,te.useRef)(null);(0,te.useEffect)(()=>{r||c.current?.focus({preventScroll:!0})},[r]);let d=!a&&o!==null&&s!==null;if(fM({nodeRef:c,disabled:!d}),!d)return null;let u=t?p=>{let h=n.getState().nodes.filter(b=>b.selected);t(p,h)}:void 0,f=p=>{Object.prototype.hasOwnProperty.call(og,p.key)&&(p.preventDefault(),l({direction:og[p.key],factor:p.shiftKey?4:1}))};return(0,Q.jsx)("div",{className:Gr(["react-flow__nodesselection","react-flow__container",e]),style:{transform:i},children:(0,Q.jsx)("div",{ref:c,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:r?void 0:-1,onKeyDown:r?void 0:f,style:{width:o,height:s}})})}function mM({children:t,onPaneClick:e,onPaneMouseEnter:r,onPaneMouseMove:n,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,paneClickDistance:a,deleteKeyCode:l,selectionKeyCode:c,selectionOnDrag:d,selectionMode:u,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:h,panActivationKeyCode:b,zoomActivationKeyCode:g,elementsSelectable:x,zoomOnScroll:y,zoomOnPinch:m,panOnScroll:v,panOnScrollSpeed:S,panOnScrollMode:w,zoomOnDoubleClick:C,panOnDrag:A,defaultViewport:k,translateExtent:M,minZoom:T,maxZoom:E,preventScrolling:P,onSelectionContextMenu:N,noWheelClassName:D,noPanClassName:R,disableKeyboardA11y:O,onViewportChange:B,isControlledViewport:L}){let{nodesSelectionActive:H,userSelectionActive:j}=Rt(eH,Cr.shallow),$=_f(c,{target:qA}),q=_f(b,{target:qA}),F=q||A,_=q||v,W=d&&F!==!0,V=$||j||W;return O9({deleteKeyCode:l,multiSelectionKeyCode:h}),(0,Q.jsx)(B9,{onPaneContextMenu:s,elementsSelectable:x,zoomOnScroll:y,zoomOnPinch:m,panOnScroll:_,panOnScrollSpeed:S,panOnScrollMode:w,zoomOnDoubleClick:C,panOnDrag:!$&&F,defaultViewport:k,translateExtent:M,minZoom:T,maxZoom:E,zoomActivationKeyCode:g,preventScrolling:P,noWheelClassName:D,noPanClassName:R,onViewportChange:B,isControlledViewport:L,paneClickDistance:a,selectionOnDrag:W,children:(0,Q.jsxs)(H9,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:e,onPaneMouseEnter:r,onPaneMouseMove:n,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:F,isSelecting:!!V,selectionMode:u,selectionKeyPressed:$,paneClickDistance:a,selectionOnDrag:W,children:[t,H&&(0,Q.jsx)(Q9,{onSelectionContextMenu:N,noPanClassName:R,disableKeyboardA11y:O})]})})}function nH(t){return Rt((0,te.useCallback)(rH(t),[t]),Cr.shallow)}function sH(){let t=Rt(oH),[e]=(0,te.useState)(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(r=>{let n=new Map;r.forEach(o=>{let s=o.target.getAttribute("data-id");n.set(s,{id:s,nodeElement:o.target,force:!0})}),t(n)}));return(0,te.useEffect)(()=>()=>{e?.disconnect()},[e]),e}function iH({node:t,nodeType:e,hasDimensions:r,resizeObserver:n}){let o=Pr(),s=(0,te.useRef)(null),i=(0,te.useRef)(null),a=(0,te.useRef)(t.sourcePosition),l=(0,te.useRef)(t.targetPosition),c=(0,te.useRef)(e),d=r&&!!t.internals.handleBounds;return(0,te.useEffect)(()=>{s.current&&!t.hidden&&(!d||i.current!==s.current)&&(i.current&&n?.unobserve(i.current),n?.observe(s.current),i.current=s.current)},[d,t.hidden]),(0,te.useEffect)(()=>()=>{i.current&&(n?.unobserve(i.current),i.current=null)},[]),(0,te.useEffect)(()=>{if(s.current){let u=c.current!==e,f=a.current!==t.sourcePosition,p=l.current!==t.targetPosition;(u||f||p)&&(c.current=e,a.current=t.sourcePosition,l.current=t.targetPosition,o.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:s.current,force:!0}]])))}},[t.id,e,t.sourcePosition,t.targetPosition]),s}function aH({id:t,onClick:e,onMouseEnter:r,onMouseMove:n,onMouseLeave:o,onContextMenu:s,onDoubleClick:i,nodesDraggable:a,elementsSelectable:l,nodesConnectable:c,nodesFocusable:d,resizeObserver:u,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:h,rfId:b,nodeTypes:g,nodeClickDistance:x,onError:y}){let{node:m,internals:v,isParent:S}=Rt(z=>{let G=z.nodeLookup.get(t),Y=z.parentLookup.has(t);return{node:G,internals:G.internals,isParent:Y}},Cr.shallow),w=m.type||"default",C=g?.[w]||KA[w];C===void 0&&(y?.("003",So.error003(w)),w="default",C=g?.default||KA.default);let A=!!(m.draggable||a&&typeof m.draggable>"u"),k=!!(m.selectable||l&&typeof m.selectable>"u"),M=!!(m.connectable||c&&typeof m.connectable>"u"),T=!!(m.focusable||d&&typeof m.focusable>"u"),E=Pr(),P=wy(m),N=iH({node:m,nodeType:w,hasDimensions:P,resizeObserver:u}),D=fM({nodeRef:N,disabled:m.hidden||!A,noDragClassName:f,handleSelector:m.dragHandle,nodeId:t,isSelectable:k,nodeClickDistance:x}),R=pM();if(m.hidden)return null;let O=Mi(m),B=J9(m),L=k||A||e||r||n||o,H=r?z=>r(z,{...v.userNode}):void 0,j=n?z=>n(z,{...v.userNode}):void 0,$=o?z=>o(z,{...v.userNode}):void 0,q=s?z=>s(z,{...v.userNode}):void 0,F=i?z=>i(z,{...v.userNode}):void 0,_=z=>{let{selectNodesOnDrag:G,nodeDragThreshold:Y}=E.getState();k&&(!G||!A||Y>0)&&Ly({id:t,store:E,nodeRef:N}),e&&e(z,{...v.userNode})},W=z=>{if(!(ky(z.nativeEvent)||h)){if(dy.includes(z.key)&&k){let G=z.key==="Escape";Ly({id:t,store:E,unselect:G,nodeRef:N})}else if(A&&m.selected&&Object.prototype.hasOwnProperty.call(og,z.key)){z.preventDefault();let{ariaLabelConfig:G}=E.getState();E.setState({ariaLiveMessage:G["node.a11yDescription.ariaLiveMessage"]({direction:z.key.replace("Arrow","").toLowerCase(),x:~~v.positionAbsolute.x,y:~~v.positionAbsolute.y})}),R({direction:og[z.key],factor:z.shiftKey?4:1})}}},V=()=>{if(h||!N.current?.matches(":focus-visible"))return;let{transform:z,width:G,height:Y,autoPanOnNodeFocus:Z,setCenter:se}=E.getState();if(!Z)return;Wm(new Map([[t,m]]),{x:0,y:0,width:G,height:Y},z,!0).length>0||se(m.position.x+O.width/2,m.position.y+O.height/2,{zoom:z[2]})};return(0,Q.jsx)("div",{className:Gr(["react-flow__node",`react-flow__node-${w}`,{[p]:A},m.className,{selected:m.selected,selectable:k,parent:S,draggable:A,dragging:D}]),ref:N,style:{zIndex:v.z,transform:`translate(${v.positionAbsolute.x}px,${v.positionAbsolute.y}px)`,pointerEvents:L?"all":"none",visibility:P?"visible":"hidden",...m.style,...B},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:j,onMouseLeave:$,onContextMenu:q,onClick:_,onDoubleClick:F,onKeyDown:T?W:void 0,tabIndex:T?0:void 0,onFocus:T?V:void 0,role:m.ariaRole??(T?"group":void 0),"aria-roledescription":"node","aria-describedby":h?void 0:`${iM}-${b}`,"aria-label":m.ariaLabel,...m.domAttributes,children:(0,Q.jsx)(j9,{value:t,children:(0,Q.jsx)(C,{id:t,data:m.data,type:w,positionAbsoluteX:v.positionAbsolute.x,positionAbsoluteY:v.positionAbsolute.y,selected:m.selected??!1,selectable:k,draggable:A,deletable:m.deletable??!0,isConnectable:M,sourcePosition:m.sourcePosition,targetPosition:m.targetPosition,dragging:D,dragHandle:m.dragHandle,zIndex:v.z,parentId:m.parentId,...O})})})}function gM(t){let{nodesDraggable:e,nodesConnectable:r,nodesFocusable:n,elementsSelectable:o,onError:s}=Rt(cH,Cr.shallow),i=nH(t.onlyRenderVisibleElements),a=sH();return(0,Q.jsx)("div",{className:"react-flow__nodes",style:cg,children:i.map(l=>(0,Q.jsx)(lH,{id:l,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:a,nodesDraggable:e,nodesConnectable:r,nodesFocusable:n,elementsSelectable:o,nodeClickDistance:t.nodeClickDistance,onError:s},l))})}function uH(t){return Rt((0,te.useCallback)(r=>{if(!t)return r.edges.map(o=>o.id);let n=[];if(r.width&&r.height)for(let o of r.edges){let s=r.nodeLookup.get(o.source),i=r.nodeLookup.get(o.target);s&&i&&pA({sourceNode:s,targetNode:i,width:r.width,height:r.height,transform:r.transform})&&n.push(o.id)}return n},[t]),Cr.shallow)}function hH(t){let e=Pr();return(0,te.useMemo)(()=>Object.prototype.hasOwnProperty.call(YA,t)?YA[t]:(e.getState().onError?.("009",So.error009(t)),null),[t])}function xM({x:t,y:e,label:r,labelStyle:n,labelShowBg:o=!0,labelBgStyle:s,labelBgPadding:i=[2,4],labelBgBorderRadius:a=2,children:l,className:c,...d}){let[u,f]=(0,te.useState)({x:1,y:0,width:0,height:0}),p=Gr(["react-flow__edge-textwrapper",c]),h=(0,te.useRef)(null);return(0,te.useEffect)(()=>{if(h.current){let b=h.current.getBBox();f({x:b.x,y:b.y,width:b.width,height:b.height})}},[r]),r?(0,Q.jsxs)("g",{transform:`translate(${t-u.width/2} ${e-u.height/2})`,className:p,visibility:u.width?"visible":"hidden",...d,children:[o&&(0,Q.jsx)("rect",{width:u.width+2*i[0],x:-i[0],y:-i[1],height:u.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:a,ry:a}),(0,Q.jsx)("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:h,style:n,children:r}),l]}):null}function dg({path:t,labelX:e,labelY:r,label:n,labelStyle:o,labelShowBg:s,labelBgStyle:i,labelBgPadding:a,labelBgBorderRadius:l,interactionWidth:c=20,...d}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("path",{...d,d:t,fill:"none",className:Gr(["react-flow__edge-path",d.className])}),c?(0,Q.jsx)("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:c,className:"react-flow__edge-interaction"}):null,n&&Ns(e)&&Ns(r)?(0,Q.jsx)(bH,{x:e,y:r,label:n,labelStyle:o,labelShowBg:s,labelBgStyle:i,labelBgPadding:a,labelBgBorderRadius:l}):null]})}function XA({pos:t,x1:e,y1:r,x2:n,y2:o}){return t===Te.Left||t===Te.Right?[.5*(e+n),r]:[e,.5*(r+o)]}function yM({sourceX:t,sourceY:e,sourcePosition:r=Te.Bottom,targetX:n,targetY:o,targetPosition:s=Te.Top}){let[i,a]=XA({pos:r,x1:t,y1:e,x2:n,y2:o}),[l,c]=XA({pos:s,x1:n,y1:o,x2:t,y2:e}),[d,u,f,p]=qm({sourceX:t,sourceY:e,targetX:n,targetY:o,sourceControlX:i,sourceControlY:a,targetControlX:l,targetControlY:c});return[`M${t},${e} C${i},${a} ${l},${c} ${n},${o}`,d,u,f,p]}function vM(t){return(0,te.memo)(({id:e,sourceX:r,sourceY:n,targetX:o,targetY:s,sourcePosition:i,targetPosition:a,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:b,markerStart:g,interactionWidth:x})=>{let[y,m,v]=yM({sourceX:r,sourceY:n,sourcePosition:i,targetX:o,targetY:s,targetPosition:a}),S=t.isInternal?void 0:e;return(0,Q.jsx)(dg,{id:S,path:y,labelX:m,labelY:v,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:b,markerStart:g,interactionWidth:x})})}function SM(t){return(0,te.memo)(({id:e,sourceX:r,sourceY:n,targetX:o,targetY:s,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:f,sourcePosition:p=Te.Bottom,targetPosition:h=Te.Top,markerEnd:b,markerStart:g,pathOptions:x,interactionWidth:y})=>{let[m,v,S]=Of({sourceX:r,sourceY:n,sourcePosition:p,targetX:o,targetY:s,targetPosition:h,borderRadius:x?.borderRadius,offset:x?.offset,stepPosition:x?.stepPosition}),w=t.isInternal?void 0:e;return(0,Q.jsx)(dg,{id:w,path:m,labelX:v,labelY:S,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:b,markerStart:g,interactionWidth:y})})}function kM(t){return(0,te.memo)(({id:e,...r})=>{let n=t.isInternal?void 0:e;return(0,Q.jsx)(NM,{...r,id:n,pathOptions:(0,te.useMemo)(()=>({borderRadius:0,offset:r.pathOptions?.offset}),[r.pathOptions?.offset])})})}function TM(t){return(0,te.memo)(({id:e,sourceX:r,sourceY:n,targetX:o,targetY:s,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:p,markerStart:h,interactionWidth:b})=>{let[g,x,y]=Xm({sourceX:r,sourceY:n,targetX:o,targetY:s}),m=t.isInternal?void 0:e;return(0,Q.jsx)(dg,{id:m,path:g,labelX:x,labelY:y,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:p,markerStart:h,interactionWidth:b})})}function AM(t){return(0,te.memo)(({id:e,sourceX:r,sourceY:n,targetX:o,targetY:s,sourcePosition:i=Te.Bottom,targetPosition:a=Te.Top,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:b,markerStart:g,pathOptions:x,interactionWidth:y})=>{let[m,v,S]=Ym({sourceX:r,sourceY:n,sourcePosition:i,targetX:o,targetY:s,targetPosition:a,curvature:x?.curvature}),w=t.isInternal?void 0:e;return(0,Q.jsx)(dg,{id:w,path:m,labelX:v,labelY:S,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:b,markerStart:g,interactionWidth:y})})}function eM({position:t,centerX:e,centerY:r,radius:n=10,onMouseDown:o,onMouseEnter:s,onMouseOut:i,type:a}){return(0,Q.jsx)("circle",{onMouseDown:o,onMouseEnter:s,onMouseOut:i,className:Gr([QA,`${QA}-${a}`]),cx:SH(e,n,t),cy:NH(r,n,t),r:n,stroke:"transparent",fill:"transparent"})}function CH({isReconnectable:t,reconnectRadius:e,edge:r,sourceX:n,sourceY:o,targetX:s,targetY:i,sourcePosition:a,targetPosition:l,onReconnect:c,onReconnectStart:d,onReconnectEnd:u,setReconnecting:f,setUpdateHover:p}){let h=Pr(),b=(v,S)=>{if(v.button!==0)return;let{autoPanOnConnect:w,domNode:C,connectionMode:A,connectionRadius:k,lib:M,onConnectStart:T,cancelConnection:E,nodeLookup:P,rfId:N,panBy:D,updateConnection:R}=h.getState(),O=S.type==="target",B=(j,$)=>{f(!1),u?.(j,r,S.type,$)},L=j=>c?.(r,j),H=(j,$)=>{f(!0),d?.(v,r,S.type),T?.(j,$)};eg.onPointerDown(v.nativeEvent,{autoPanOnConnect:w,connectionMode:A,connectionRadius:k,domNode:C,handleId:S.id,nodeId:S.nodeId,nodeLookup:P,isTarget:O,edgeUpdaterType:S.type,lib:M,flowId:N,cancelConnection:E,panBy:D,isValidConnection:(...j)=>h.getState().isValidConnection?.(...j)??!0,onConnect:L,onConnectStart:H,onConnectEnd:(...j)=>h.getState().onConnectEnd?.(...j),onReconnectEnd:B,updateConnection:R,getTransform:()=>h.getState().transform,getFromHandle:()=>h.getState().connection.fromHandle,dragThreshold:h.getState().connectionDragThreshold,handleDomNode:v.currentTarget})},g=v=>b(v,{nodeId:r.target,id:r.targetHandle??null,type:"target"}),x=v=>b(v,{nodeId:r.source,id:r.sourceHandle??null,type:"source"}),y=()=>p(!0),m=()=>p(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(t===!0||t==="source")&&(0,Q.jsx)(eM,{position:a,centerX:n,centerY:o,radius:e,onMouseDown:g,onMouseEnter:y,onMouseOut:m,type:"source"}),(t===!0||t==="target")&&(0,Q.jsx)(eM,{position:l,centerX:s,centerY:i,radius:e,onMouseDown:x,onMouseEnter:y,onMouseOut:m,type:"target"})]})}function kH({id:t,edgesFocusable:e,edgesReconnectable:r,elementsSelectable:n,onClick:o,onDoubleClick:s,onContextMenu:i,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,reconnectRadius:d,onReconnect:u,onReconnectStart:f,onReconnectEnd:p,rfId:h,edgeTypes:b,noPanClassName:g,onError:x,disableKeyboardA11y:y}){let m=Rt(se=>se.edgeLookup.get(t)),v=Rt(se=>se.defaultEdgeOptions);m=v?{...v,...m}:m;let S=m.type||"default",w=b?.[S]||JA[S];w===void 0&&(x?.("011",So.error011(S)),S="default",w=b?.default||JA.default);let C=!!(m.focusable||e&&typeof m.focusable>"u"),A=typeof u<"u"&&(m.reconnectable||r&&typeof m.reconnectable>"u"),k=!!(m.selectable||n&&typeof m.selectable>"u"),M=(0,te.useRef)(null),[T,E]=(0,te.useState)(!1),[P,N]=(0,te.useState)(!1),D=Pr(),{zIndex:R,sourceX:O,sourceY:B,targetX:L,targetY:H,sourcePosition:j,targetPosition:$}=Rt((0,te.useCallback)(se=>{let we=se.nodeLookup.get(m.source),_e=se.nodeLookup.get(m.target);if(!we||!_e)return{zIndex:m.zIndex,...ZA};let Pe=hA({id:t,sourceNode:we,targetNode:_e,sourceHandle:m.sourceHandle||null,targetHandle:m.targetHandle||null,connectionMode:se.connectionMode,onError:x});return{zIndex:fA({selected:m.selected,zIndex:m.zIndex,sourceNode:we,targetNode:_e,elevateOnSelect:se.elevateEdgesOnSelect,zIndexMode:se.zIndexMode}),...Pe||ZA}},[m.source,m.target,m.sourceHandle,m.targetHandle,m.selected,m.zIndex]),Cr.shallow),q=(0,te.useMemo)(()=>m.markerStart?`url('#${Jm(m.markerStart,h)}')`:void 0,[m.markerStart,h]),F=(0,te.useMemo)(()=>m.markerEnd?`url('#${Jm(m.markerEnd,h)}')`:void 0,[m.markerEnd,h]);if(m.hidden||O===null||B===null||L===null||H===null)return null;let _=se=>{let{addSelectedEdges:we,unselectNodesAndEdges:_e,multiSelectionActive:Pe}=D.getState();k&&(D.setState({nodesSelectionActive:!1}),m.selected&&Pe?(_e({nodes:[],edges:[m]}),M.current?.blur()):we([t])),o&&o(se,m)},W=s?se=>{s(se,{...m})}:void 0,V=i?se=>{i(se,{...m})}:void 0,z=a?se=>{a(se,{...m})}:void 0,G=l?se=>{l(se,{...m})}:void 0,Y=c?se=>{c(se,{...m})}:void 0,Z=se=>{if(!y&&dy.includes(se.key)&&k){let{unselectNodesAndEdges:we,addSelectedEdges:_e}=D.getState();se.key==="Escape"?(M.current?.blur(),we({edges:[m]})):_e([t])}};return(0,Q.jsx)("svg",{style:{zIndex:R},children:(0,Q.jsxs)("g",{className:Gr(["react-flow__edge",`react-flow__edge-${S}`,m.className,g,{selected:m.selected,animated:m.animated,inactive:!k&&!o,updating:T,selectable:k}]),onClick:_,onDoubleClick:W,onContextMenu:V,onMouseEnter:z,onMouseMove:G,onMouseLeave:Y,onKeyDown:C?Z:void 0,tabIndex:C?0:void 0,role:m.ariaRole??(C?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":m.ariaLabel===null?void 0:m.ariaLabel||`Edge from ${m.source} to ${m.target}`,"aria-describedby":C?`${aM}-${h}`:void 0,ref:M,...m.domAttributes,children:[!P&&(0,Q.jsx)(w,{id:t,source:m.source,target:m.target,type:m.type,selected:m.selected,animated:m.animated,selectable:k,deletable:m.deletable??!0,label:m.label,labelStyle:m.labelStyle,labelShowBg:m.labelShowBg,labelBgStyle:m.labelBgStyle,labelBgPadding:m.labelBgPadding,labelBgBorderRadius:m.labelBgBorderRadius,sourceX:O,sourceY:B,targetX:L,targetY:H,sourcePosition:j,targetPosition:$,data:m.data,style:m.style,sourceHandleId:m.sourceHandle,targetHandleId:m.targetHandle,markerStart:q,markerEnd:F,pathOptions:"pathOptions"in m?m.pathOptions:void 0,interactionWidth:m.interactionWidth}),A&&(0,Q.jsx)(CH,{edge:m,isReconnectable:A,reconnectRadius:d,onReconnect:u,onReconnectStart:f,onReconnectEnd:p,sourceX:O,sourceY:B,targetX:L,targetY:H,sourcePosition:j,targetPosition:$,setUpdateHover:E,setReconnecting:N})]})})}function PM({defaultMarkerColor:t,onlyRenderVisibleElements:e,rfId:r,edgeTypes:n,noPanClassName:o,onReconnect:s,onEdgeContextMenu:i,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:d,reconnectRadius:u,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:h,disableKeyboardA11y:b}){let{edgesFocusable:g,edgesReconnectable:x,elementsSelectable:y,onError:m}=Rt(TH,Cr.shallow),v=uH(e);return(0,Q.jsxs)("div",{className:"react-flow__edges",children:[(0,Q.jsx)(gH,{defaultColor:t,rfId:r}),v.map(S=>(0,Q.jsx)(EH,{id:S,edgesFocusable:g,edgesReconnectable:x,elementsSelectable:y,noPanClassName:o,onReconnect:s,onContextMenu:i,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,onClick:d,reconnectRadius:u,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:h,rfId:r,onError:m,edgeTypes:n,disableKeyboardA11y:b},S))]})}function MH({children:t}){let e=Rt(AH);return(0,Q.jsx)("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:e},children:t})}function PH(t){let e=Lf(),r=(0,te.useRef)(!1);(0,te.useEffect)(()=>{!r.current&&e.viewportInitialized&&t&&(setTimeout(()=>t(e),1),r.current=!0)},[t,e.viewportInitialized])}function DH(t){let e=Rt(RH),r=Pr();return(0,te.useEffect)(()=>{t&&(e?.(t),r.setState({transform:[t.x,t.y,t.zoom]}))},[t,e]),null}function tM(t){return t.connection.inProgress?{...t.connection,to:jd(t.connection.to,t.transform)}:{...t.connection}}function OH(t){return t?r=>{let n=tM(r);return t(n)}:tM}function _H(t){let e=OH(t);return Rt(e,Cr.shallow)}function BH({containerStyle:t,style:e,type:r,component:n}){let{nodesConnectable:o,width:s,height:i,isValid:a,inProgress:l}=Rt(LH,Cr.shallow);return!(s&&o&&l)?null:(0,Q.jsx)("svg",{style:t,width:s,height:i,className:"react-flow__connectionline react-flow__container",children:(0,Q.jsx)("g",{className:Gr(["react-flow__connection",py(a)]),children:(0,Q.jsx)(RM,{style:e,type:r,CustomComponent:n,isValid:a})})})}function rM(t=zH){let e=(0,te.useRef)(t),r=Pr();(0,te.useEffect)(()=>{if(process.env.NODE_ENV==="development"){let n=new Set([...Object.keys(e.current),...Object.keys(t)]);for(let o of n)if(e.current[o]!==t[o]){r.getState().onError?.("002",So.error002());break}e.current=t}},[t])}function $H(){let t=Pr(),e=(0,te.useRef)(!1);(0,te.useEffect)(()=>{if(process.env.NODE_ENV==="development"&&!e.current){let r=document.querySelector(".react-flow__pane");r&&window.getComputedStyle(r).zIndex!=="1"&&t.getState().onError?.("013",So.error013("react")),e.current=!0}},[])}function DM({nodeTypes:t,edgeTypes:e,onInit:r,onNodeClick:n,onEdgeClick:o,onNodeDoubleClick:s,onEdgeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:c,onNodeContextMenu:d,onSelectionContextMenu:u,onSelectionStart:f,onSelectionEnd:p,connectionLineType:h,connectionLineStyle:b,connectionLineComponent:g,connectionLineContainerStyle:x,selectionKeyCode:y,selectionOnDrag:m,selectionMode:v,multiSelectionKeyCode:S,panActivationKeyCode:w,zoomActivationKeyCode:C,deleteKeyCode:A,onlyRenderVisibleElements:k,elementsSelectable:M,defaultViewport:T,translateExtent:E,minZoom:P,maxZoom:N,preventScrolling:D,defaultMarkerColor:R,zoomOnScroll:O,zoomOnPinch:B,panOnScroll:L,panOnScrollSpeed:H,panOnScrollMode:j,zoomOnDoubleClick:$,panOnDrag:q,onPaneClick:F,onPaneMouseEnter:_,onPaneMouseMove:W,onPaneMouseLeave:V,onPaneScroll:z,onPaneContextMenu:G,paneClickDistance:Y,nodeClickDistance:Z,onEdgeContextMenu:se,onEdgeMouseEnter:we,onEdgeMouseMove:_e,onEdgeMouseLeave:Pe,reconnectRadius:K,onReconnect:he,onReconnectStart:lt,onReconnectEnd:He,noDragClassName:nt,noWheelClassName:dr,noPanClassName:ln,disableKeyboardA11y:Tr,nodeExtent:bn,rfId:St,viewport:mt,onViewportChange:je}){return rM(t),rM(e),$H(),PH(r),DH(mt),(0,Q.jsx)(tH,{onPaneClick:F,onPaneMouseEnter:_,onPaneMouseMove:W,onPaneMouseLeave:V,onPaneContextMenu:G,onPaneScroll:z,paneClickDistance:Y,deleteKeyCode:A,selectionKeyCode:y,selectionOnDrag:m,selectionMode:v,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:S,panActivationKeyCode:w,zoomActivationKeyCode:C,elementsSelectable:M,zoomOnScroll:O,zoomOnPinch:B,zoomOnDoubleClick:$,panOnScroll:L,panOnScrollSpeed:H,panOnScrollMode:j,panOnDrag:q,defaultViewport:T,translateExtent:E,minZoom:P,maxZoom:N,onSelectionContextMenu:u,preventScrolling:D,noDragClassName:nt,noWheelClassName:dr,noPanClassName:ln,disableKeyboardA11y:Tr,onViewportChange:je,isControlledViewport:!!mt,children:(0,Q.jsxs)(MH,{children:[(0,Q.jsx)(IH,{edgeTypes:e,onEdgeClick:o,onEdgeDoubleClick:i,onReconnect:he,onReconnectStart:lt,onReconnectEnd:He,onlyRenderVisibleElements:k,onEdgeContextMenu:se,onEdgeMouseEnter:we,onEdgeMouseMove:_e,onEdgeMouseLeave:Pe,reconnectRadius:K,defaultMarkerColor:R,noPanClassName:ln,disableKeyboardA11y:Tr,rfId:St}),(0,Q.jsx)(BH,{style:b,type:h,component:g,containerStyle:x}),(0,Q.jsx)("div",{className:"react-flow__edgelabel-renderer"}),(0,Q.jsx)(dH,{nodeTypes:t,onNodeClick:n,onNodeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:c,onNodeContextMenu:d,nodeClickDistance:Z,onlyRenderVisibleElements:k,noPanClassName:ln,noDragClassName:nt,disableKeyboardA11y:Tr,nodeExtent:bn,rfId:St}),(0,Q.jsx)("div",{className:"react-flow__viewport-portal"})]})})}function Bf({initialNodes:t,initialEdges:e,defaultNodes:r,defaultEdges:n,initialWidth:o,initialHeight:s,initialMinZoom:i,initialMaxZoom:a,initialFitViewOptions:l,fitView:c,nodeOrigin:d,nodeExtent:u,zIndexMode:f,children:p}){let[h]=(0,te.useState)(()=>HH({nodes:t,edges:e,defaultNodes:r,defaultEdges:n,width:o,height:s,fitView:c,minZoom:i,maxZoom:a,fitViewOptions:l,nodeOrigin:d,nodeExtent:u,zIndexMode:f}));return(0,Q.jsx)(a9,{value:h,children:(0,Q.jsx)(M9,{children:p})})}function VH({children:t,nodes:e,edges:r,defaultNodes:n,defaultEdges:o,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:u,nodeExtent:f,zIndexMode:p}){return(0,te.useContext)(ig)?(0,Q.jsx)(Q.Fragment,{children:t}):(0,Q.jsx)(Bf,{initialNodes:e,initialEdges:r,defaultNodes:n,defaultEdges:o,initialWidth:s,initialHeight:i,fitView:a,initialFitViewOptions:l,initialMinZoom:c,initialMaxZoom:d,nodeOrigin:u,nodeExtent:f,zIndexMode:p,children:t})}function WH({nodes:t,edges:e,defaultNodes:r,defaultEdges:n,className:o,nodeTypes:s,edgeTypes:i,onNodeClick:a,onEdgeClick:l,onInit:c,onMove:d,onMoveStart:u,onMoveEnd:f,onConnect:p,onConnectStart:h,onConnectEnd:b,onClickConnectStart:g,onClickConnectEnd:x,onNodeMouseEnter:y,onNodeMouseMove:m,onNodeMouseLeave:v,onNodeContextMenu:S,onNodeDoubleClick:w,onNodeDragStart:C,onNodeDrag:A,onNodeDragStop:k,onNodesDelete:M,onEdgesDelete:T,onDelete:E,onSelectionChange:P,onSelectionDragStart:N,onSelectionDrag:D,onSelectionDragStop:R,onSelectionContextMenu:O,onSelectionStart:B,onSelectionEnd:L,onBeforeDelete:H,connectionMode:j,connectionLineType:$=Ai.Bezier,connectionLineStyle:q,connectionLineComponent:F,connectionLineContainerStyle:_,deleteKeyCode:W="Backspace",selectionKeyCode:V="Shift",selectionOnDrag:z=!1,selectionMode:G=aa.Full,panActivationKeyCode:Y="Space",multiSelectionKeyCode:Z=Wd()?"Meta":"Control",zoomActivationKeyCode:se=Wd()?"Meta":"Control",snapToGrid:we,snapGrid:_e,onlyRenderVisibleElements:Pe=!1,selectNodesOnDrag:K,nodesDraggable:he,autoPanOnNodeFocus:lt,nodesConnectable:He,nodesFocusable:nt,nodeOrigin:dr=lM,edgesFocusable:ln,edgesReconnectable:Tr,elementsSelectable:bn=!0,defaultViewport:St=v9,minZoom:mt=.5,maxZoom:je=2,translateExtent:or=$d,preventScrolling:fo=!0,nodeExtent:Jn,defaultMarkerColor:Ao="#b1b1b7",zoomOnScroll:pi=!0,zoomOnPinch:ps=!0,panOnScroll:cn=!1,panOnScrollSpeed:ne=.5,panOnScrollMode:be=ia.Free,zoomOnDoubleClick:me=!0,panOnDrag:ue=!0,onPaneClick:ht,onPaneMouseEnter:Zt,onPaneMouseMove:Wo,onPaneMouseLeave:Qt,onPaneScroll:Gt,onPaneContextMenu:$n,paneClickDistance:We=1,nodeClickDistance:ct=0,children:xt,onReconnect:Ir,onReconnectStart:dn,onReconnectEnd:sr,onEdgeContextMenu:Tn,onEdgeDoubleClick:Ar,onEdgeMouseEnter:un,onEdgeMouseMove:Ml,onEdgeMouseLeave:Pl,reconnectRadius:hi=10,onNodesChange:Rl,onEdgesChange:Lu,noDragClassName:QB="nodrag",noWheelClassName:ez="nowheel",noPanClassName:QS="nopan",fitView:eN,fitViewOptions:tN,connectOnClick:tz,attributionPosition:rz,proOptions:nz,defaultEdgeOptions:oz,elevateNodesOnSelect:sz=!0,elevateEdgesOnSelect:iz=!1,disableKeyboardA11y:rN=!1,autoPanOnConnect:az,autoPanOnNodeDrag:lz,autoPanSpeed:cz,connectionRadius:dz,isValidConnection:uz,onError:fz,style:pz,id:nN,nodeDragThreshold:hz,connectionDragThreshold:mz,viewport:gz,onViewportChange:bz,width:xz,height:yz,colorMode:vz="light",debug:wz,onScroll:oN,ariaLabelConfig:Sz,zIndexMode:sN="basic",...Nz},Cz){let L0=nN||"1",kz=C9(vz),Ez=(0,te.useCallback)(iN=>{iN.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),oN?.(iN)},[oN]);return(0,Q.jsx)("div",{"data-testid":"rf__wrapper",...Nz,onScroll:Ez,style:{...pz,...jH},ref:Cz,className:Gr(["react-flow",o,kz]),id:nN,role:"application",children:(0,Q.jsxs)(VH,{nodes:t,edges:e,width:xz,height:yz,fitView:eN,fitViewOptions:tN,minZoom:mt,maxZoom:je,nodeOrigin:dr,nodeExtent:Jn,zIndexMode:sN,children:[(0,Q.jsx)(FH,{onInit:c,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:y,onNodeMouseMove:m,onNodeMouseLeave:v,onNodeContextMenu:S,onNodeDoubleClick:w,nodeTypes:s,edgeTypes:i,connectionLineType:$,connectionLineStyle:q,connectionLineComponent:F,connectionLineContainerStyle:_,selectionKeyCode:V,selectionOnDrag:z,selectionMode:G,deleteKeyCode:W,multiSelectionKeyCode:Z,panActivationKeyCode:Y,zoomActivationKeyCode:se,onlyRenderVisibleElements:Pe,defaultViewport:St,translateExtent:or,minZoom:mt,maxZoom:je,preventScrolling:fo,zoomOnScroll:pi,zoomOnPinch:ps,zoomOnDoubleClick:me,panOnScroll:cn,panOnScrollSpeed:ne,panOnScrollMode:be,panOnDrag:ue,onPaneClick:ht,onPaneMouseEnter:Zt,onPaneMouseMove:Wo,onPaneMouseLeave:Qt,onPaneScroll:Gt,onPaneContextMenu:$n,paneClickDistance:We,nodeClickDistance:ct,onSelectionContextMenu:O,onSelectionStart:B,onSelectionEnd:L,onReconnect:Ir,onReconnectStart:dn,onReconnectEnd:sr,onEdgeContextMenu:Tn,onEdgeDoubleClick:Ar,onEdgeMouseEnter:un,onEdgeMouseMove:Ml,onEdgeMouseLeave:Pl,reconnectRadius:hi,defaultMarkerColor:Ao,noDragClassName:QB,noWheelClassName:ez,noPanClassName:QS,rfId:L0,disableKeyboardA11y:rN,nodeExtent:Jn,viewport:gz,onViewportChange:bz}),(0,Q.jsx)(N9,{nodes:t,edges:e,defaultNodes:r,defaultEdges:n,onConnect:p,onConnectStart:h,onConnectEnd:b,onClickConnectStart:g,onClickConnectEnd:x,nodesDraggable:he,autoPanOnNodeFocus:lt,nodesConnectable:He,nodesFocusable:nt,edgesFocusable:ln,edgesReconnectable:Tr,elementsSelectable:bn,elevateNodesOnSelect:sz,elevateEdgesOnSelect:iz,minZoom:mt,maxZoom:je,nodeExtent:Jn,onNodesChange:Rl,onEdgesChange:Lu,snapToGrid:we,snapGrid:_e,connectionMode:j,translateExtent:or,connectOnClick:tz,defaultEdgeOptions:oz,fitView:eN,fitViewOptions:tN,onNodesDelete:M,onEdgesDelete:T,onDelete:E,onNodeDragStart:C,onNodeDrag:A,onNodeDragStop:k,onSelectionDrag:D,onSelectionDragStart:N,onSelectionDragStop:R,onMove:d,onMoveStart:u,onMoveEnd:f,noPanClassName:QS,nodeOrigin:dr,rfId:L0,autoPanOnConnect:az,autoPanOnNodeDrag:lz,autoPanSpeed:cz,onError:fz,connectionRadius:dz,isValidConnection:uz,selectNodesOnDrag:K,nodeDragThreshold:hz,connectionDragThreshold:mz,onBeforeDelete:H,debug:wz,ariaLabelConfig:Sz,zIndexMode:sN}),(0,Q.jsx)(y9,{onSelectionChange:P}),xt,(0,Q.jsx)(h9,{proOptions:nz,position:rz}),(0,Q.jsx)(p9,{rfId:L0,disableKeyboardA11y:rN})]})})}function Kd(t){let[e,r]=(0,te.useState)(t),n=(0,te.useCallback)(o=>r(s=>ag(o,s)),[]);return[e,r,n]}function qd(t){let[e,r]=(0,te.useState)(t),n=(0,te.useCallback)(o=>r(s=>lg(o,s)),[]);return[e,r,n]}function UH({dimensions:t,lineWidth:e,variant:r,className:n}){return(0,Q.jsx)("path",{strokeWidth:e,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:Gr(["react-flow__background-pattern",r,n])})}function GH({radius:t,className:e}){return(0,Q.jsx)("circle",{cx:t,cy:t,r:t,className:Gr(["react-flow__background-pattern","dots",e])})}function OM({id:t,variant:e=Pi.Dots,gap:r=20,size:n,lineWidth:o=1,offset:s=0,color:i,bgColor:a,style:l,className:c,patternClassName:d}){let u=(0,te.useRef)(null),{transform:f,patternId:p}=Rt(qH,Cr.shallow),h=n||KH[e],b=e===Pi.Dots,g=e===Pi.Cross,x=Array.isArray(r)?r:[r,r],y=[x[0]*f[2]||1,x[1]*f[2]||1],m=h*f[2],v=Array.isArray(s)?s:[s,s],S=g?[m,m]:y,w=[v[0]*f[2]||1+S[0]/2,v[1]*f[2]||1+S[1]/2],C=`${p}${t||""}`;return(0,Q.jsxs)("svg",{className:Gr(["react-flow__background",c]),style:{...l,...cg,"--xy-background-color-props":a,"--xy-background-pattern-color-props":i},ref:u,"data-testid":"rf__background",children:[(0,Q.jsx)("pattern",{id:C,x:f[0]%y[0],y:f[1]%y[1],width:y[0],height:y[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${w[0]},-${w[1]})`,children:b?(0,Q.jsx)(GH,{radius:m/2,className:d}):(0,Q.jsx)(UH,{dimensions:S,lineWidth:o,variant:e,className:d})}),(0,Q.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${C})`})]})}function YH(){return(0,Q.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:(0,Q.jsx)("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function XH(){return(0,Q.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:(0,Q.jsx)("path",{d:"M0 0h32v4.2H0z"})})}function JH(){return(0,Q.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:(0,Q.jsx)("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function ZH(){return(0,Q.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,Q.jsx)("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function QH(){return(0,Q.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,Q.jsx)("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function ng({children:t,className:e,...r}){return(0,Q.jsx)("button",{type:"button",className:Gr(["react-flow__controls-button",e]),...r,children:t})}function _M({style:t,showZoom:e=!0,showFitView:r=!0,showInteractive:n=!0,fitViewOptions:o,onZoomIn:s,onZoomOut:i,onFitView:a,onInteractiveChange:l,className:c,children:d,position:u="bottom-left",orientation:f="vertical","aria-label":p}){let h=Pr(),{isInteractive:b,minZoomReached:g,maxZoomReached:x,ariaLabelConfig:y}=Rt(eV,Cr.shallow),{zoomIn:m,zoomOut:v,fitView:S}=Lf(),w=()=>{m(),s?.()},C=()=>{v(),i?.()},A=()=>{S(o),a?.()},k=()=>{h.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),l?.(!b)};return(0,Q.jsxs)(Gd,{className:Gr(["react-flow__controls",f==="horizontal"?"horizontal":"vertical",c]),position:u,style:t,"data-testid":"rf__controls","aria-label":p??y["controls.ariaLabel"],children:[e&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ng,{onClick:w,className:"react-flow__controls-zoomin",title:y["controls.zoomIn.ariaLabel"],"aria-label":y["controls.zoomIn.ariaLabel"],disabled:x,children:(0,Q.jsx)(YH,{})}),(0,Q.jsx)(ng,{onClick:C,className:"react-flow__controls-zoomout",title:y["controls.zoomOut.ariaLabel"],"aria-label":y["controls.zoomOut.ariaLabel"],disabled:g,children:(0,Q.jsx)(XH,{})})]}),r&&(0,Q.jsx)(ng,{className:"react-flow__controls-fitview",onClick:A,title:y["controls.fitView.ariaLabel"],"aria-label":y["controls.fitView.ariaLabel"],children:(0,Q.jsx)(JH,{})}),n&&(0,Q.jsx)(ng,{className:"react-flow__controls-interactive",onClick:k,title:y["controls.interactive.ariaLabel"],"aria-label":y["controls.interactive.ariaLabel"],children:b?(0,Q.jsx)(QH,{}):(0,Q.jsx)(ZH,{})}),d]})}function tV({id:t,x:e,y:r,width:n,height:o,style:s,color:i,strokeColor:a,strokeWidth:l,className:c,borderRadius:d,shapeRendering:u,selected:f,onClick:p}){let{background:h,backgroundColor:b}=s||{},g=i||h||b;return(0,Q.jsx)("rect",{className:Gr(["react-flow__minimap-node",{selected:f},c]),x:e,y:r,rx:d,ry:d,width:n,height:o,style:{fill:g,stroke:a,strokeWidth:l},shapeRendering:u,onClick:p?x=>p(x,t):void 0})}function oV({nodeStrokeColor:t,nodeColor:e,nodeClassName:r="",nodeBorderRadius:n=5,nodeStrokeWidth:o,nodeComponent:s=rV,onClick:i}){let a=Rt(nV,Cr.shallow),l=_y(e),c=_y(t),d=_y(r),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return(0,Q.jsx)(Q.Fragment,{children:a.map(f=>(0,Q.jsx)(iV,{id:f,nodeColorFunc:l,nodeStrokeColorFunc:c,nodeClassNameFunc:d,nodeBorderRadius:n,nodeStrokeWidth:o,NodeComponent:s,onClick:i,shapeRendering:u},f))})}function sV({id:t,nodeColorFunc:e,nodeStrokeColorFunc:r,nodeClassNameFunc:n,nodeBorderRadius:o,nodeStrokeWidth:s,shapeRendering:i,NodeComponent:a,onClick:l}){let{node:c,x:d,y:u,width:f,height:p}=Rt(h=>{let b=h.nodeLookup.get(t);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};let g=b.internals.userNode,{x,y}=b.internals.positionAbsolute,{width:m,height:v}=Mi(g);return{node:g,x,y,width:m,height:v}},Cr.shallow);return!c||c.hidden||!wy(c)?null:(0,Q.jsx)(a,{x:d,y:u,width:f,height:p,style:c.style,selected:!!c.selected,className:n(c),color:e(c),borderRadius:o,strokeColor:r(c),strokeWidth:s,shapeRendering:i,onClick:l,id:c.id})}function LM({style:t,className:e,nodeStrokeColor:r,nodeColor:n,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:i,nodeComponent:a,bgColor:l,maskColor:c,maskStrokeColor:d,maskStrokeWidth:u,position:f="bottom-right",onClick:p,onNodeClick:h,pannable:b=!1,zoomable:g=!1,ariaLabel:x,inversePan:y,zoomStep:m=1,offsetScale:v=5}){let S=Pr(),w=(0,te.useRef)(null),{boundingRect:C,viewBB:A,rfId:k,panZoom:M,translateExtent:T,flowWidth:E,flowHeight:P,ariaLabelConfig:N}=Rt(uV,Cr.shallow),D=t?.width??lV,R=t?.height??cV,O=C.width/D,B=C.height/R,L=Math.max(O,B),H=L*D,j=L*R,$=v*L,q=C.x-(H-C.width)/2-$,F=C.y-(j-C.height)/2-$,_=H+$*2,W=j+$*2,V=`${fV}-${k}`,z=(0,te.useRef)(0),G=(0,te.useRef)();z.current=L,(0,te.useEffect)(()=>{if(w.current&&M)return G.current=TA({domNode:w.current,panZoom:M,getTransform:()=>S.getState().transform,getViewScale:()=>z.current}),()=>{G.current?.destroy()}},[M]),(0,te.useEffect)(()=>{G.current?.update({translateExtent:T,width:E,height:P,inversePan:y,pannable:b,zoomStep:m,zoomable:g})},[b,g,y,m,T,E,P]);let Y=p?we=>{let[_e,Pe]=G.current?.pointer(we)||[0,0];p(we,{x:_e,y:Pe})}:void 0,Z=h?(0,te.useCallback)((we,_e)=>{let Pe=S.getState().nodeLookup.get(_e).internals.userNode;h(we,Pe)},[]):void 0,se=x??N["minimap.ariaLabel"];return(0,Q.jsx)(Gd,{position:f,style:{...t,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*L:void 0,"--xy-minimap-node-background-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:Gr(["react-flow__minimap",e]),"data-testid":"rf__minimap",children:(0,Q.jsxs)("svg",{width:D,height:R,viewBox:`${q} ${F} ${_} ${W}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":V,ref:w,onClick:Y,children:[se&&(0,Q.jsx)("title",{id:V,children:se}),(0,Q.jsx)(aV,{onClick:Z,nodeColor:n,nodeStrokeColor:r,nodeBorderRadius:s,nodeClassName:o,nodeStrokeWidth:i,nodeComponent:a}),(0,Q.jsx)("path",{className:"react-flow__minimap-mask",d:`M${q-$},${F-$}h${_+$*2}v${W+$*2}h${-_-$*2}z
|
|
411
|
+
M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}function mV({nodeId:t,position:e,variant:r=la.Handle,className:n,style:o=void 0,children:s,color:i,minWidth:a=10,minHeight:l=10,maxWidth:c=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:f,autoScale:p=!0,shouldResize:h,onResizeStart:b,onResize:g,onResizeEnd:x}){let y=hM(),m=typeof t=="string"?t:y,v=Pr(),S=(0,te.useRef)(null),w=r===la.Handle,C=Rt((0,te.useCallback)(pV(w&&p),[w,p]),Cr.shallow),A=(0,te.useRef)(null),k=e??hV[r];(0,te.useEffect)(()=>{if(!(!S.current||!m))return A.current||(A.current=OA({domNode:S.current,nodeId:m,getStoreItems:()=>{let{nodeLookup:T,transform:E,snapGrid:P,snapToGrid:N,nodeOrigin:D,domNode:R}=v.getState();return{nodeLookup:T,transform:E,snapGrid:P,snapToGrid:N,nodeOrigin:D,paneDomNode:R}},onChange:(T,E)=>{let{triggerNodeChanges:P,nodeLookup:N,parentLookup:D,nodeOrigin:R}=v.getState(),O=[],B={x:T.x,y:T.y},L=N.get(m);if(L&&L.expandParent&&L.parentId){let H=L.origin??R,j=T.width??L.measured.width??0,$=T.height??L.measured.height??0,q={id:L.id,parentId:L.parentId,rect:{width:j,height:$,...Sy({x:T.x??L.position.x,y:T.y??L.position.y},{width:j,height:$},L.parentId,N,H)}},F=Qm([q],N,D,R);O.push(...F),B.x=T.x?Math.max(H[0]*j,T.x):void 0,B.y=T.y?Math.max(H[1]*$,T.y):void 0}if(B.x!==void 0&&B.y!==void 0){let H={id:m,type:"position",position:{...B}};O.push(H)}if(T.width!==void 0&&T.height!==void 0){let j={id:m,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:T.width,height:T.height}};O.push(j)}for(let H of E){let j={...H,type:"position"};O.push(j)}P(O)},onEnd:({width:T,height:E})=>{let P={id:m,type:"dimensions",resizing:!1,dimensions:{width:T,height:E}};v.getState().triggerNodeChanges([P])}})),A.current.update({controlPosition:k,boundaries:{minWidth:a,minHeight:l,maxWidth:c,maxHeight:d},keepAspectRatio:u,resizeDirection:f,onResizeStart:b,onResize:g,onResizeEnd:x,shouldResize:h}),()=>{A.current?.destroy()}},[k,a,l,c,d,u,b,g,x,h]);let M=k.split("-");return(0,Q.jsx)("div",{className:Gr(["react-flow__resize-control","nodrag",...M,r,n]),ref:S,style:{...o,scale:C,...i&&{[w?"backgroundColor":"borderColor"]:i}},children:s})}function BM({nodeId:t,isVisible:e=!0,handleClassName:r,handleStyle:n,lineClassName:o,lineStyle:s,color:i,minWidth:a=10,minHeight:l=10,maxWidth:c=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:u=!1,autoScale:f=!0,shouldResize:p,onResizeStart:h,onResize:b,onResizeEnd:g}){return e?(0,Q.jsxs)(Q.Fragment,{children:[RA.map(x=>(0,Q.jsx)(oM,{className:o,style:s,nodeId:t,position:x,variant:la.Line,color:i,minWidth:a,minHeight:l,maxWidth:c,maxHeight:d,onResizeStart:h,keepAspectRatio:u,autoScale:f,shouldResize:p,onResize:b,onResizeEnd:g},x)),PA.map(x=>(0,Q.jsx)(oM,{className:r,style:n,nodeId:t,position:x,color:i,minWidth:a,minHeight:l,maxWidth:c,maxHeight:d,onResizeStart:h,keepAspectRatio:u,autoScale:f,shouldResize:p,onResize:b,onResizeEnd:g},x))]}):null}var Q,te,sg,Cr,i9,ig,a9,sM,_A,l9,iM,aM,c9,d9,u9,Gd,m9,rg,x9,lM,v9,w9,LA,S9,BA,$A,k9,WA,T9,I9,uM,R9,GA,D9,cg,L9,z9,Oy,F9,V9,By,j9,hM,W9,U9,qr,og,KA,Z9,qA,eH,tH,rH,oH,lH,cH,dH,fH,pH,YA,mH,bM,gH,bH,xH,wM,NM,CM,yH,EM,vH,IM,wH,MM,JA,ZA,SH,NH,QA,EH,TH,IH,AH,RH,LH,RM,zH,FH,nM,HH,jH,el,Hce,Pi,KH,qH,tl,eV,rl,rV,nV,_y,iV,aV,lV,cV,dV,uV,fV,nl,pV,hV,oM,Ri=U(()=>{"use strict";"use client";Q=require("react/jsx-runtime"),te=require("react");wE();Dy();Dy();sg=require("zustand/traditional"),Cr=require("zustand/shallow"),i9=require("react-dom"),ig=(0,te.createContext)(null),a9=ig.Provider,sM=So.error001();_A={display:"none"},l9={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},iM="react-flow__node-desc",aM="react-flow__edge-desc",c9="react-flow__aria-live",d9=t=>t.ariaLiveMessage,u9=t=>t.ariaLabelConfig;Gd=(0,te.forwardRef)(({position:t="top-left",children:e,className:r,style:n,...o},s)=>{let i=`${t}`.split("-");return(0,Q.jsx)("div",{className:Gr(["react-flow__panel",r,...i]),style:n,ref:s,...o,children:e})});Gd.displayName="Panel";m9=t=>{let e=[],r=[];for(let[,n]of t.nodeLookup)n.selected&&e.push(n.internals.userNode);for(let[,n]of t.edgeLookup)n.selected&&r.push(n);return{selectedNodes:e,selectedEdges:r}},rg=t=>t.id;x9=t=>!!t.onSelectionChangeHandlers;lM=[0,0],v9={x:0,y:0,zoom:1},w9=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],LA=[...w9,"rfId"],S9=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),BA={translateExtent:$d,nodeOrigin:lM,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};$A=typeof document<"u"?document:null;k9=()=>{let t=Pr();return(0,te.useMemo)(()=>({zoomIn:e=>{let{panZoom:r}=t.getState();return r?r.scaleBy(1.2,{duration:e?.duration}):Promise.resolve(!1)},zoomOut:e=>{let{panZoom:r}=t.getState();return r?r.scaleBy(1/1.2,{duration:e?.duration}):Promise.resolve(!1)},zoomTo:(e,r)=>{let{panZoom:n}=t.getState();return n?n.scaleTo(e,{duration:r?.duration}):Promise.resolve(!1)},getZoom:()=>t.getState().transform[2],setViewport:async(e,r)=>{let{transform:[n,o,s],panZoom:i}=t.getState();return i?(await i.setViewport({x:e.x??n,y:e.y??o,zoom:e.zoom??s},r),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{let[e,r,n]=t.getState().transform;return{x:e,y:r,zoom:n}},setCenter:async(e,r,n)=>t.getState().setCenter(e,r,n),fitBounds:async(e,r)=>{let{width:n,height:o,minZoom:s,maxZoom:i,panZoom:a}=t.getState(),l=Df(e,n,o,s,i,r?.padding??.1);return a?(await a.setViewport(l,{duration:r?.duration,ease:r?.ease,interpolate:r?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(e,r={})=>{let{transform:n,snapGrid:o,snapToGrid:s,domNode:i}=t.getState();if(!i)return e;let{x:a,y:l}=i.getBoundingClientRect(),c={x:e.x-a,y:e.y-l},d=r.snapGrid??o,u=r.snapToGrid??s;return jd(c,n,u,d)},flowToScreenPosition:e=>{let{transform:r,domNode:n}=t.getState();if(!n)return e;let{x:o,y:s}=n.getBoundingClientRect(),i=Pf(e,r);return{x:i.x+o,y:i.y+s}}}),[])};WA=t=>oA(t),T9=t=>hy(t);I9=typeof window<"u"?te.useLayoutEffect:te.useEffect;uM=(0,te.createContext)(null);R9=t=>!!t.panZoom;GA=t=>t.selected,D9=typeof window<"u"?window:void 0;cg={position:"absolute",width:"100%",height:"100%",top:0,left:0},L9=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});z9=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});Oy=(t,e)=>r=>{r.target===e.current&&t?.(r)},F9=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,connectionInProgress:t.connection.inProgress,dragging:t.paneDragging});V9=t=>e=>e.selected&&(e.draggable||t&&typeof e.draggable>"u");By=(0,te.createContext)(null),j9=By.Provider;By.Consumer;hM=()=>(0,te.useContext)(By),W9=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),U9=(t,e,r)=>n=>{let{connectionClickStartHandle:o,connectionMode:s,connection:i}=n,{fromHandle:a,toHandle:l,isValid:c}=i,d=l?.nodeId===t&&l?.id===e&&l?.type===r;return{connectingFrom:a?.nodeId===t&&a?.id===e&&a?.type===r,connectingTo:d,clickConnecting:o?.nodeId===t&&o?.id===e&&o?.type===r,isPossibleEndHandle:s===Za.Strict?a?.type!==r:t!==a?.nodeId||e!==a?.id,connectionInProcess:!!a,clickConnectionInProcess:!!o,valid:d&&c}};qr=(0,te.memo)(dM(G9));og={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},KA={input:K9,default:q9,output:X9,group:Y9};Z9=t=>{let{width:e,height:r,x:n,y:o}=Fd(t.nodeLookup,{filter:s=>!!s.selected});return{width:Ns(e)?e:null,height:Ns(r)?r:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${n}px,${o}px)`}};qA=typeof window<"u"?window:void 0,eH=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});mM.displayName="FlowRenderer";tH=(0,te.memo)(mM),rH=t=>e=>t?Wm(e.nodeLookup,{x:0,y:0,width:e.width,height:e.height},e.transform,!0).map(r=>r.id):Array.from(e.nodeLookup.keys());oH=t=>t.updateNodeInternals;lH=(0,te.memo)(aH),cH=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});gM.displayName="NodeRenderer";dH=(0,te.memo)(gM);fH=({color:t="none",strokeWidth:e=1})=>{let r={strokeWidth:e,...t&&{stroke:t}};return(0,Q.jsx)("polyline",{className:"arrow",style:r,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},pH=({color:t="none",strokeWidth:e=1})=>{let r={strokeWidth:e,...t&&{stroke:t,fill:t}};return(0,Q.jsx)("polyline",{className:"arrowclosed",style:r,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},YA={[pn.Arrow]:fH,[pn.ArrowClosed]:pH};mH=({id:t,type:e,color:r,width:n=12.5,height:o=12.5,markerUnits:s="strokeWidth",strokeWidth:i,orient:a="auto-start-reverse"})=>{let l=hH(e);return l?(0,Q.jsx)("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${n}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:a,refX:"0",refY:"0",children:(0,Q.jsx)(l,{color:r,strokeWidth:i})}):null},bM=({defaultColor:t,rfId:e})=>{let r=Rt(s=>s.edges),n=Rt(s=>s.defaultEdgeOptions),o=(0,te.useMemo)(()=>mA(r,{id:e,defaultColor:t,defaultMarkerStart:n?.markerStart,defaultMarkerEnd:n?.markerEnd}),[r,n,e,t]);return o.length?(0,Q.jsx)("svg",{className:"react-flow__marker","aria-hidden":"true",children:(0,Q.jsx)("defs",{children:o.map(s=>(0,Q.jsx)(mH,{id:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient},s.id))})}):null};bM.displayName="MarkerDefinitions";gH=(0,te.memo)(bM);xM.displayName="EdgeText";bH=(0,te.memo)(xM);xH=vM({isInternal:!1}),wM=vM({isInternal:!0});xH.displayName="SimpleBezierEdge";wM.displayName="SimpleBezierEdgeInternal";NM=SM({isInternal:!1}),CM=SM({isInternal:!0});NM.displayName="SmoothStepEdge";CM.displayName="SmoothStepEdgeInternal";yH=kM({isInternal:!1}),EM=kM({isInternal:!0});yH.displayName="StepEdge";EM.displayName="StepEdgeInternal";vH=TM({isInternal:!1}),IM=TM({isInternal:!0});vH.displayName="StraightEdge";IM.displayName="StraightEdgeInternal";wH=AM({isInternal:!1}),MM=AM({isInternal:!0});wH.displayName="BezierEdge";MM.displayName="BezierEdgeInternal";JA={default:MM,straight:IM,step:EM,smoothstep:CM,simplebezier:wM},ZA={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},SH=(t,e,r)=>r===Te.Left?t-e:r===Te.Right?t+e:t,NH=(t,e,r)=>r===Te.Top?t-e:r===Te.Bottom?t+e:t,QA="react-flow__edgeupdater";EH=(0,te.memo)(kH),TH=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});PM.displayName="EdgeRenderer";IH=(0,te.memo)(PM),AH=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;RH=t=>t.panZoom?.syncViewport;LH=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});RM=({style:t,type:e=Ai.Bezier,CustomComponent:r,isValid:n})=>{let{inProgress:o,from:s,fromNode:i,fromHandle:a,fromPosition:l,to:c,toNode:d,toHandle:u,toPosition:f,pointer:p}=_H();if(!o)return;if(r)return(0,Q.jsx)(r,{connectionLineType:e,connectionLineStyle:t,fromNode:i,fromHandle:a,fromX:s.x,fromY:s.y,toX:c.x,toY:c.y,fromPosition:l,toPosition:f,connectionStatus:py(n),toNode:d,toHandle:u,pointer:p});let h="",b={sourceX:s.x,sourceY:s.y,sourcePosition:l,targetX:c.x,targetY:c.y,targetPosition:f};switch(e){case Ai.Bezier:[h]=Ym(b);break;case Ai.SimpleBezier:[h]=yM(b);break;case Ai.Step:[h]=Of({...b,borderRadius:0});break;case Ai.SmoothStep:[h]=Of(b);break;default:[h]=Xm(b)}return(0,Q.jsx)("path",{d:h,fill:"none",className:"react-flow__connection-path",style:t})};RM.displayName="ConnectionLine";zH={};DM.displayName="GraphView";FH=(0,te.memo)(DM),nM=({nodes:t,edges:e,defaultNodes:r,defaultEdges:n,width:o,height:s,fitView:i,fitViewOptions:a,minZoom:l=.5,maxZoom:c=2,nodeOrigin:d,nodeExtent:u,zIndexMode:f="basic"}={})=>{let p=new Map,h=new Map,b=new Map,g=new Map,x=n??e??[],y=r??t??[],m=d??[0,0],v=u??$d;Ry(b,g,x);let S=Zm(y,p,h,{nodeOrigin:m,nodeExtent:v,zIndexMode:f}),w=[0,0,1];if(i&&o&&s){let C=Fd(p,{filter:T=>!!((T.width||T.initialWidth)&&(T.height||T.initialHeight))}),{x:A,y:k,zoom:M}=Df(C,o,s,l,c,a?.padding??.1);w=[A,k,M]}return{rfId:"1",width:o??0,height:s??0,transform:w,nodes:y,nodesInitialized:S,nodeLookup:p,parentLookup:h,edges:x,edgeLookup:g,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:r!==void 0,hasDefaultEdges:n!==void 0,panZoom:null,minZoom:l,maxZoom:c,translateExtent:$d,nodeExtent:v,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Za.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:m,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:i??!1,fitViewOptions:a,fitViewResolver:null,connection:{...fy},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:vy,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:uy,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},HH=({nodes:t,edges:e,defaultNodes:r,defaultEdges:n,width:o,height:s,fitView:i,fitViewOptions:a,minZoom:l,maxZoom:c,nodeOrigin:d,nodeExtent:u,zIndexMode:f})=>(0,sg.createWithEqualityFn)((p,h)=>{async function b(){let{nodeLookup:g,panZoom:x,fitViewOptions:y,fitViewResolver:m,width:v,height:S,minZoom:w,maxZoom:C}=h();x&&(await iA({nodes:g,width:v,height:S,panZoom:x,minZoom:w,maxZoom:C},y),m?.resolve(!0),p({fitViewResolver:null}))}return{...nM({nodes:t,edges:e,width:o,height:s,fitView:i,fitViewOptions:a,minZoom:l,maxZoom:c,nodeOrigin:d,nodeExtent:u,defaultNodes:r,defaultEdges:n,zIndexMode:f}),setNodes:g=>{let{nodeLookup:x,parentLookup:y,nodeOrigin:m,elevateNodesOnSelect:v,fitViewQueued:S,zIndexMode:w}=h(),C=Zm(g,x,y,{nodeOrigin:m,nodeExtent:u,elevateNodesOnSelect:v,checkEquality:!0,zIndexMode:w});S&&C?(b(),p({nodes:g,nodesInitialized:C,fitViewQueued:!1,fitViewOptions:void 0})):p({nodes:g,nodesInitialized:C})},setEdges:g=>{let{connectionLookup:x,edgeLookup:y}=h();Ry(x,y,g),p({edges:g})},setDefaultNodesAndEdges:(g,x)=>{if(g){let{setNodes:y}=h();y(g),p({hasDefaultNodes:!0})}if(x){let{setEdges:y}=h();y(x),p({hasDefaultEdges:!0})}},updateNodeInternals:g=>{let{triggerNodeChanges:x,nodeLookup:y,parentLookup:m,domNode:v,nodeOrigin:S,nodeExtent:w,debug:C,fitViewQueued:A,zIndexMode:k}=h(),{changes:M,updatedInternals:T}=yA(g,y,m,v,S,w,k);T&&(bA(y,m,{nodeOrigin:S,nodeExtent:w,zIndexMode:k}),A?(b(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),M?.length>0&&(C&&console.log("React Flow: trigger node changes",M),x?.(M)))},updateNodePositions:(g,x=!1)=>{let y=[],m=[],{nodeLookup:v,triggerNodeChanges:S,connection:w,updateConnection:C,onNodesChangeMiddlewareMap:A}=h();for(let[k,M]of g){let T=v.get(k),E=!!(T?.expandParent&&T?.parentId&&M?.position),P={id:k,type:"position",position:E?{x:Math.max(0,M.position.x),y:Math.max(0,M.position.y)}:M.position,dragging:x};if(T&&w.inProgress&&w.fromNode.id===T.id){let N=Qa(T,w.fromHandle,Te.Left,!0);C({...w,from:N})}E&&T.parentId&&y.push({id:k,parentId:T.parentId,rect:{...M.internals.positionAbsolute,width:M.measured.width??0,height:M.measured.height??0}}),m.push(P)}if(y.length>0){let{parentLookup:k,nodeOrigin:M}=h(),T=Qm(y,v,k,M);m.push(...T)}for(let k of A.values())m=k(m);S(m)},triggerNodeChanges:g=>{let{onNodesChange:x,setNodes:y,nodes:m,hasDefaultNodes:v,debug:S}=h();if(g?.length){if(v){let w=ag(g,m);y(w)}S&&console.log("React Flow: trigger node changes",g),x?.(g)}},triggerEdgeChanges:g=>{let{onEdgesChange:x,setEdges:y,edges:m,hasDefaultEdges:v,debug:S}=h();if(g?.length){if(v){let w=lg(g,m);y(w)}S&&console.log("React Flow: trigger edge changes",g),x?.(g)}},addSelectedNodes:g=>{let{multiSelectionActive:x,edgeLookup:y,nodeLookup:m,triggerNodeChanges:v,triggerEdgeChanges:S}=h();if(x){let w=g.map(C=>ac(C,!0));v(w);return}v(Ud(m,new Set([...g]),!0)),S(Ud(y))},addSelectedEdges:g=>{let{multiSelectionActive:x,edgeLookup:y,nodeLookup:m,triggerNodeChanges:v,triggerEdgeChanges:S}=h();if(x){let w=g.map(C=>ac(C,!0));S(w);return}S(Ud(y,new Set([...g]))),v(Ud(m,new Set,!0))},unselectNodesAndEdges:({nodes:g,edges:x}={})=>{let{edges:y,nodes:m,nodeLookup:v,triggerNodeChanges:S,triggerEdgeChanges:w}=h(),C=g||m,A=x||y,k=[];for(let T of C){if(!T.selected)continue;let E=v.get(T.id);E&&(E.selected=!1),k.push(ac(T.id,!1))}let M=[];for(let T of A)T.selected&&M.push(ac(T.id,!1));S(k),w(M)},setMinZoom:g=>{let{panZoom:x,maxZoom:y}=h();x?.setScaleExtent([g,y]),p({minZoom:g})},setMaxZoom:g=>{let{panZoom:x,minZoom:y}=h();x?.setScaleExtent([y,g]),p({maxZoom:g})},setTranslateExtent:g=>{h().panZoom?.setTranslateExtent(g),p({translateExtent:g})},resetSelectedElements:()=>{let{edges:g,nodes:x,triggerNodeChanges:y,triggerEdgeChanges:m,elementsSelectable:v}=h();if(!v)return;let S=x.reduce((C,A)=>A.selected?[...C,ac(A.id,!1)]:C,[]),w=g.reduce((C,A)=>A.selected?[...C,ac(A.id,!1)]:C,[]);y(S),m(w)},setNodeExtent:g=>{let{nodes:x,nodeLookup:y,parentLookup:m,nodeOrigin:v,elevateNodesOnSelect:S,nodeExtent:w,zIndexMode:C}=h();g[0][0]===w[0][0]&&g[0][1]===w[0][1]&&g[1][0]===w[1][0]&&g[1][1]===w[1][1]||(Zm(x,y,m,{nodeOrigin:v,nodeExtent:g,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:C}),p({nodeExtent:g}))},panBy:g=>{let{transform:x,width:y,height:m,panZoom:v,translateExtent:S}=h();return vA({delta:g,panZoom:v,transform:x,translateExtent:S,width:y,height:m})},setCenter:async(g,x,y)=>{let{width:m,height:v,maxZoom:S,panZoom:w}=h();if(!w)return Promise.resolve(!1);let C=typeof y?.zoom<"u"?y.zoom:S;return await w.setViewport({x:m/2-g*C,y:v/2-x*C,zoom:C},{duration:y?.duration,ease:y?.ease,interpolate:y?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...fy}})},updateConnection:g=>{p({connection:g})},reset:()=>p({...nM()})}},Object.is);jH={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};el=dM(WH);Hce=So.error014();(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Pi||(Pi={}));KH={[Pi.Dots]:1,[Pi.Lines]:1,[Pi.Cross]:6},qH=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});OM.displayName="Background";tl=(0,te.memo)(OM);eV=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});_M.displayName="Controls";rl=(0,te.memo)(_M);rV=(0,te.memo)(tV),nV=t=>t.nodes.map(e=>e.id),_y=t=>t instanceof Function?t:()=>t;iV=(0,te.memo)(sV),aV=(0,te.memo)(oV),lV=200,cV=150,dV=t=>!t.hidden,uV=t=>{let e={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:e,boundingRect:t.nodeLookup.size>0?xy(Fd(t.nodeLookup,{filter:dV}),e):e,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},fV="react-flow__minimap-desc";LM.displayName="MiniMap";nl=(0,te.memo)(LM),pV=t=>e=>t?`${Math.max(1/e.transform[2],1)}`:void 0,hV={[la.Line]:"right",[la.Handle]:"bottom-right"};oM=(0,te.memo)(mV)});var zf=U(()=>{});var rr,Qs,gV,bV,hn,xV,yV,ug,zM,vV,wV,SV,NV,CV,kV,EV,TV,IV,AV,MV,PV,RV,DV,OV,_V,LV,BV,zV,$V,FV,zy,$M=U(()=>{"use strict";rr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Qs=rr((t,e)=>{var r=Object.defineProperty,n=(P,N,D)=>N in P?r(P,N,{enumerable:!0,configurable:!0,writable:!0,value:D}):P[N]=D,o=(P,N)=>()=>(N||P((N={exports:{}}).exports,N),N.exports),s=(P,N,D)=>n(P,typeof N!="symbol"?N+"":N,D),i=o((P,N)=>{"use strict";var D="\0",R="\0",O="",B=class{constructor(F){s(this,"_isDirected",!0),s(this,"_isMultigraph",!1),s(this,"_isCompound",!1),s(this,"_label"),s(this,"_defaultNodeLabelFn",()=>{}),s(this,"_defaultEdgeLabelFn",()=>{}),s(this,"_nodes",{}),s(this,"_in",{}),s(this,"_preds",{}),s(this,"_out",{}),s(this,"_sucs",{}),s(this,"_edgeObjs",{}),s(this,"_edgeLabels",{}),s(this,"_nodeCount",0),s(this,"_edgeCount",0),s(this,"_parent"),s(this,"_children"),F&&(this._isDirected=Object.hasOwn(F,"directed")?F.directed:!0,this._isMultigraph=Object.hasOwn(F,"multigraph")?F.multigraph:!1,this._isCompound=Object.hasOwn(F,"compound")?F.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[R]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(F){return this._label=F,this}graph(){return this._label}setDefaultNodeLabel(F){return this._defaultNodeLabelFn=F,typeof F!="function"&&(this._defaultNodeLabelFn=()=>F),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var F=this;return this.nodes().filter(_=>Object.keys(F._in[_]).length===0)}sinks(){var F=this;return this.nodes().filter(_=>Object.keys(F._out[_]).length===0)}setNodes(F,_){var W=arguments,V=this;return F.forEach(function(z){W.length>1?V.setNode(z,_):V.setNode(z)}),this}setNode(F,_){return Object.hasOwn(this._nodes,F)?(arguments.length>1&&(this._nodes[F]=_),this):(this._nodes[F]=arguments.length>1?_:this._defaultNodeLabelFn(F),this._isCompound&&(this._parent[F]=R,this._children[F]={},this._children[R][F]=!0),this._in[F]={},this._preds[F]={},this._out[F]={},this._sucs[F]={},++this._nodeCount,this)}node(F){return this._nodes[F]}hasNode(F){return Object.hasOwn(this._nodes,F)}removeNode(F){var _=this;if(Object.hasOwn(this._nodes,F)){var W=V=>_.removeEdge(_._edgeObjs[V]);delete this._nodes[F],this._isCompound&&(this._removeFromParentsChildList(F),delete this._parent[F],this.children(F).forEach(function(V){_.setParent(V)}),delete this._children[F]),Object.keys(this._in[F]).forEach(W),delete this._in[F],delete this._preds[F],Object.keys(this._out[F]).forEach(W),delete this._out[F],delete this._sucs[F],--this._nodeCount}return this}setParent(F,_){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(_===void 0)_=R;else{_+="";for(var W=_;W!==void 0;W=this.parent(W))if(W===F)throw new Error("Setting "+_+" as parent of "+F+" would create a cycle");this.setNode(_)}return this.setNode(F),this._removeFromParentsChildList(F),this._parent[F]=_,this._children[_][F]=!0,this}_removeFromParentsChildList(F){delete this._children[this._parent[F]][F]}parent(F){if(this._isCompound){var _=this._parent[F];if(_!==R)return _}}children(F=R){if(this._isCompound){var _=this._children[F];if(_)return Object.keys(_)}else{if(F===R)return this.nodes();if(this.hasNode(F))return[]}}predecessors(F){var _=this._preds[F];if(_)return Object.keys(_)}successors(F){var _=this._sucs[F];if(_)return Object.keys(_)}neighbors(F){var _=this.predecessors(F);if(_){let V=new Set(_);for(var W of this.successors(F))V.add(W);return Array.from(V.values())}}isLeaf(F){var _;return this.isDirected()?_=this.successors(F):_=this.neighbors(F),_.length===0}filterNodes(F){var _=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});_.setGraph(this.graph());var W=this;Object.entries(this._nodes).forEach(function([G,Y]){F(G)&&_.setNode(G,Y)}),Object.values(this._edgeObjs).forEach(function(G){_.hasNode(G.v)&&_.hasNode(G.w)&&_.setEdge(G,W.edge(G))});var V={};function z(G){var Y=W.parent(G);return Y===void 0||_.hasNode(Y)?(V[G]=Y,Y):Y in V?V[Y]:z(Y)}return this._isCompound&&_.nodes().forEach(G=>_.setParent(G,z(G))),_}setDefaultEdgeLabel(F){return this._defaultEdgeLabelFn=F,typeof F!="function"&&(this._defaultEdgeLabelFn=()=>F),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(F,_){var W=this,V=arguments;return F.reduce(function(z,G){return V.length>1?W.setEdge(z,G,_):W.setEdge(z,G),G}),this}setEdge(){var F,_,W,V,z=!1,G=arguments[0];typeof G=="object"&&G!==null&&"v"in G?(F=G.v,_=G.w,W=G.name,arguments.length===2&&(V=arguments[1],z=!0)):(F=G,_=arguments[1],W=arguments[3],arguments.length>2&&(V=arguments[2],z=!0)),F=""+F,_=""+_,W!==void 0&&(W=""+W);var Y=j(this._isDirected,F,_,W);if(Object.hasOwn(this._edgeLabels,Y))return z&&(this._edgeLabels[Y]=V),this;if(W!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(F),this.setNode(_),this._edgeLabels[Y]=z?V:this._defaultEdgeLabelFn(F,_,W);var Z=$(this._isDirected,F,_,W);return F=Z.v,_=Z.w,Object.freeze(Z),this._edgeObjs[Y]=Z,L(this._preds[_],F),L(this._sucs[F],_),this._in[_][Y]=Z,this._out[F][Y]=Z,this._edgeCount++,this}edge(F,_,W){var V=arguments.length===1?q(this._isDirected,arguments[0]):j(this._isDirected,F,_,W);return this._edgeLabels[V]}edgeAsObj(){let F=this.edge(...arguments);return typeof F!="object"?{label:F}:F}hasEdge(F,_,W){var V=arguments.length===1?q(this._isDirected,arguments[0]):j(this._isDirected,F,_,W);return Object.hasOwn(this._edgeLabels,V)}removeEdge(F,_,W){var V=arguments.length===1?q(this._isDirected,arguments[0]):j(this._isDirected,F,_,W),z=this._edgeObjs[V];return z&&(F=z.v,_=z.w,delete this._edgeLabels[V],delete this._edgeObjs[V],H(this._preds[_],F),H(this._sucs[F],_),delete this._in[_][V],delete this._out[F][V],this._edgeCount--),this}inEdges(F,_){return this.isDirected()?this.filterEdges(this._in[F],F,_):this.nodeEdges(F,_)}outEdges(F,_){return this.isDirected()?this.filterEdges(this._out[F],F,_):this.nodeEdges(F,_)}nodeEdges(F,_){if(F in this._nodes)return this.filterEdges({...this._in[F],...this._out[F]},F,_)}filterEdges(F,_,W){if(F){var V=Object.values(F);return W?V.filter(function(z){return z.v===_&&z.w===W||z.v===W&&z.w===_}):V}}};function L(F,_){F[_]?F[_]++:F[_]=1}function H(F,_){--F[_]||delete F[_]}function j(F,_,W,V){var z=""+_,G=""+W;if(!F&&z>G){var Y=z;z=G,G=Y}return z+O+G+O+(V===void 0?D:V)}function $(F,_,W,V){var z=""+_,G=""+W;if(!F&&z>G){var Y=z;z=G,G=Y}var Z={v:z,w:G};return V&&(Z.name=V),Z}function q(F,_){return j(F,_.v,_.w,_.name)}N.exports=B}),a=o((P,N)=>{N.exports="3.0.2"}),l=o((P,N)=>{N.exports={Graph:i(),version:a()}}),c=o((P,N)=>{var D=i();N.exports={write:R,read:L};function R(H){var j={options:{directed:H.isDirected(),multigraph:H.isMultigraph(),compound:H.isCompound()},nodes:O(H),edges:B(H)};return H.graph()!==void 0&&(j.value=structuredClone(H.graph())),j}function O(H){return H.nodes().map(function(j){var $=H.node(j),q=H.parent(j),F={v:j};return $!==void 0&&(F.value=$),q!==void 0&&(F.parent=q),F})}function B(H){return H.edges().map(function(j){var $=H.edge(j),q={v:j.v,w:j.w};return j.name!==void 0&&(q.name=j.name),$!==void 0&&(q.value=$),q})}function L(H){var j=new D(H.options).setGraph(H.value);return H.nodes.forEach(function($){j.setNode($.v,$.value),$.parent&&j.setParent($.v,$.parent)}),H.edges.forEach(function($){j.setEdge({v:$.v,w:$.w,name:$.name},$.value)}),j}}),d=o((P,N)=>{N.exports=R;var D=()=>1;function R(B,L,H,j){return O(B,String(L),H||D,j||function($){return B.outEdges($)})}function O(B,L,H,j){var $={},q=!0,F=0,_=B.nodes(),W=function(Y){var Z=H(Y);$[Y.v].distance+Z<$[Y.w].distance&&($[Y.w]={distance:$[Y.v].distance+Z,predecessor:Y.v},q=!0)},V=function(){_.forEach(function(Y){j(Y).forEach(function(Z){var se=Z.v===Y?Z.v:Z.w,we=se===Z.v?Z.w:Z.v;W({v:se,w:we})})})};_.forEach(function(Y){var Z=Y===L?0:Number.POSITIVE_INFINITY;$[Y]={distance:Z}});for(var z=_.length,G=1;G<z&&(q=!1,F++,V(),!!q);G++);if(F===z-1&&(q=!1,V(),q))throw new Error("The graph contains a negative weight cycle");return $}}),u=o((P,N)=>{N.exports=D;function D(R){var O={},B=[],L;function H(j){Object.hasOwn(O,j)||(O[j]=!0,L.push(j),R.successors(j).forEach(H),R.predecessors(j).forEach(H))}return R.nodes().forEach(function(j){L=[],H(j),L.length&&B.push(L)}),B}}),f=o((P,N)=>{var D=class{constructor(){s(this,"_arr",[]),s(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(R){return R.key})}has(R){return Object.hasOwn(this._keyIndices,R)}priority(R){var O=this._keyIndices[R];if(O!==void 0)return this._arr[O].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(R,O){var B=this._keyIndices;if(R=String(R),!Object.hasOwn(B,R)){var L=this._arr,H=L.length;return B[R]=H,L.push({key:R,priority:O}),this._decrease(H),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var R=this._arr.pop();return delete this._keyIndices[R.key],this._heapify(0),R.key}decrease(R,O){var B=this._keyIndices[R];if(O>this._arr[B].priority)throw new Error("New priority is greater than current priority. Key: "+R+" Old: "+this._arr[B].priority+" New: "+O);this._arr[B].priority=O,this._decrease(B)}_heapify(R){var O=this._arr,B=2*R,L=B+1,H=R;B<O.length&&(H=O[B].priority<O[H].priority?B:H,L<O.length&&(H=O[L].priority<O[H].priority?L:H),H!==R&&(this._swap(R,H),this._heapify(H)))}_decrease(R){for(var O=this._arr,B=O[R].priority,L;R!==0&&(L=R>>1,!(O[L].priority<B));)this._swap(R,L),R=L}_swap(R,O){var B=this._arr,L=this._keyIndices,H=B[R],j=B[O];B[R]=j,B[O]=H,L[j.key]=R,L[H.key]=O}};N.exports=D}),p=o((P,N)=>{var D=f();N.exports=O;var R=()=>1;function O(L,H,j,$){var q=function(F){return L.outEdges(F)};return B(L,String(H),j||R,$||q)}function B(L,H,j,$){var q={},F=new D,_,W,V=function(z){var G=z.v!==_?z.v:z.w,Y=q[G],Z=j(z),se=W.distance+Z;if(Z<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+z+" Weight: "+Z);se<Y.distance&&(Y.distance=se,Y.predecessor=_,F.decrease(G,se))};for(L.nodes().forEach(function(z){var G=z===H?0:Number.POSITIVE_INFINITY;q[z]={distance:G},F.add(z,G)});F.size()>0&&(_=F.removeMin(),W=q[_],W.distance!==Number.POSITIVE_INFINITY);)$(_).forEach(V);return q}}),h=o((P,N)=>{var D=p();N.exports=R;function R(O,B,L){return O.nodes().reduce(function(H,j){return H[j]=D(O,j,B,L),H},{})}}),b=o((P,N)=>{N.exports=D;function D(O,B,L){if(O[B].predecessor!==void 0)throw new Error("Invalid source vertex");if(O[L].predecessor===void 0&&L!==B)throw new Error("Invalid destination vertex");return{weight:O[L].distance,path:R(O,B,L)}}function R(O,B,L){for(var H=[],j=L;j!==B;)H.push(j),j=O[j].predecessor;return H.push(B),H.reverse()}}),g=o((P,N)=>{N.exports=D;function D(R){var O=0,B=[],L={},H=[];function j($){var q=L[$]={onStack:!0,lowlink:O,index:O++};if(B.push($),R.successors($).forEach(function(W){Object.hasOwn(L,W)?L[W].onStack&&(q.lowlink=Math.min(q.lowlink,L[W].index)):(j(W),q.lowlink=Math.min(q.lowlink,L[W].lowlink))}),q.lowlink===q.index){var F=[],_;do _=B.pop(),L[_].onStack=!1,F.push(_);while($!==_);H.push(F)}}return R.nodes().forEach(function($){Object.hasOwn(L,$)||j($)}),H}}),x=o((P,N)=>{var D=g();N.exports=R;function R(O){return D(O).filter(function(B){return B.length>1||B.length===1&&O.hasEdge(B[0],B[0])})}}),y=o((P,N)=>{N.exports=R;var D=()=>1;function R(B,L,H){return O(B,L||D,H||function(j){return B.outEdges(j)})}function O(B,L,H){var j={},$=B.nodes();return $.forEach(function(q){j[q]={},j[q][q]={distance:0},$.forEach(function(F){q!==F&&(j[q][F]={distance:Number.POSITIVE_INFINITY})}),H(q).forEach(function(F){var _=F.v===q?F.w:F.v,W=L(F);j[q][_]={distance:W,predecessor:q}})}),$.forEach(function(q){var F=j[q];$.forEach(function(_){var W=j[_];$.forEach(function(V){var z=W[q],G=F[V],Y=W[V],Z=z.distance+G.distance;Z<Y.distance&&(Y.distance=Z,Y.predecessor=G.predecessor)})})}),j}}),m=o((P,N)=>{function D(O){var B={},L={},H=[];function j($){if(Object.hasOwn(L,$))throw new R;Object.hasOwn(B,$)||(L[$]=!0,B[$]=!0,O.predecessors($).forEach(j),delete L[$],H.push($))}if(O.sinks().forEach(j),Object.keys(B).length!==O.nodeCount())throw new R;return H}var R=class extends Error{constructor(){super(...arguments)}};N.exports=D,D.CycleException=R}),v=o((P,N)=>{var D=m();N.exports=R;function R(O){try{D(O)}catch(B){if(B instanceof D.CycleException)return!1;throw B}return!0}}),S=o((P,N)=>{N.exports=D;function D(O,B,L,H,j){Array.isArray(B)||(B=[B]);var $=(O.isDirected()?O.successors:O.neighbors).bind(O),q={};return B.forEach(function(F){if(!O.hasNode(F))throw new Error("Graph does not have node: "+F);j=R(O,F,L==="post",q,$,H,j)}),j}function R(O,B,L,H,j,$,q){return Object.hasOwn(H,B)||(H[B]=!0,L||(q=$(q,B)),j(B).forEach(function(F){q=R(O,F,L,H,j,$,q)}),L&&(q=$(q,B))),q}}),w=o((P,N)=>{var D=S();N.exports=R;function R(O,B,L){return D(O,B,L,function(H,j){return H.push(j),H},[])}}),C=o((P,N)=>{var D=w();N.exports=R;function R(O,B){return D(O,B,"post")}}),A=o((P,N)=>{var D=w();N.exports=R;function R(O,B){return D(O,B,"pre")}}),k=o((P,N)=>{var D=i(),R=f();N.exports=O;function O(B,L){var H=new D,j={},$=new R,q;function F(W){var V=W.v===q?W.w:W.v,z=$.priority(V);if(z!==void 0){var G=L(W);G<z&&(j[V]=q,$.decrease(V,G))}}if(B.nodeCount()===0)return H;B.nodes().forEach(function(W){$.add(W,Number.POSITIVE_INFINITY),H.setNode(W)}),$.decrease(B.nodes()[0],0);for(var _=!1;$.size()>0;){if(q=$.removeMin(),Object.hasOwn(j,q))H.setEdge(q,j[q]);else{if(_)throw new Error("Input graph is not connected: "+B);_=!0}B.nodeEdges(q).forEach(F)}return H}}),M=o((P,N)=>{var D=p(),R=d();N.exports=O;function O(L,H,j,$){return B(L,H,j,$||function(q){return L.outEdges(q)})}function B(L,H,j,$){if(j===void 0)return D(L,H,j,$);for(var q=!1,F=L.nodes(),_=0;_<F.length;_++){for(var W=$(F[_]),V=0;V<W.length;V++){var z=W[V],G=z.v===F[_]?z.v:z.w,Y=G===z.v?z.w:z.v;j({v:G,w:Y})<0&&(q=!0)}if(q)return R(L,H,j,$)}return D(L,H,j,$)}}),T=o((P,N)=>{N.exports={bellmanFord:d(),components:u(),dijkstra:p(),dijkstraAll:h(),extractPath:b(),findCycles:x(),floydWarshall:y(),isAcyclic:v(),postorder:C(),preorder:A(),prim:k(),shortestPaths:M(),reduce:S(),tarjan:g(),topsort:m()}}),E=l();e.exports={Graph:E.Graph,json:c(),alg:T(),version:E.version}}),gV=rr((t,e)=>{var r=class{constructor(){let s={};s._next=s._prev=s,this._sentinel=s}dequeue(){let s=this._sentinel,i=s._prev;if(i!==s)return n(i),i}enqueue(s){let i=this._sentinel;s._prev&&s._next&&n(s),s._next=i._next,i._next._prev=s,i._next=s,s._prev=i}toString(){let s=[],i=this._sentinel,a=i._prev;for(;a!==i;)s.push(JSON.stringify(a,o)),a=a._prev;return"["+s.join(", ")+"]"}};function n(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function o(s,i){if(s!=="_next"&&s!=="_prev")return i}e.exports=r}),bV=rr((t,e)=>{var r=Qs().Graph,n=gV();e.exports=s;var o=()=>1;function s(u,f){if(u.nodeCount()<=1)return[];let p=l(u,f||o);return i(p.graph,p.buckets,p.zeroIdx).flatMap(h=>u.outEdges(h.v,h.w))}function i(u,f,p){let h=[],b=f[f.length-1],g=f[0],x;for(;u.nodeCount();){for(;x=g.dequeue();)a(u,f,p,x);for(;x=b.dequeue();)a(u,f,p,x);if(u.nodeCount()){for(let y=f.length-2;y>0;--y)if(x=f[y].dequeue(),x){h=h.concat(a(u,f,p,x,!0));break}}}return h}function a(u,f,p,h,b){let g=b?[]:void 0;return u.inEdges(h.v).forEach(x=>{let y=u.edge(x),m=u.node(x.v);b&&g.push({v:x.v,w:x.w}),m.out-=y,c(f,p,m)}),u.outEdges(h.v).forEach(x=>{let y=u.edge(x),m=x.w,v=u.node(m);v.in-=y,c(f,p,v)}),u.removeNode(h.v),g}function l(u,f){let p=new r,h=0,b=0;u.nodes().forEach(y=>{p.setNode(y,{v:y,in:0,out:0})}),u.edges().forEach(y=>{let m=p.edge(y.v,y.w)||0,v=f(y),S=m+v;p.setEdge(y.v,y.w,S),b=Math.max(b,p.node(y.v).out+=v),h=Math.max(h,p.node(y.w).in+=v)});let g=d(b+h+3).map(()=>new n),x=h+1;return p.nodes().forEach(y=>{c(g,x,p.node(y))}),{graph:p,buckets:g,zeroIdx:x}}function c(u,f,p){p.out?p.in?u[p.out-p.in+f].enqueue(p):u[u.length-1].enqueue(p):u[0].enqueue(p)}function d(u){let f=[];for(let p=0;p<u;p++)f.push(p);return f}}),hn=rr((t,e)=>{"use strict";var r=Qs().Graph;e.exports={addBorderNode:f,addDummyNode:n,applyWithChunking:b,asNonCompoundGraph:s,buildLayerMatrix:c,intersectRect:l,mapValues:A,maxRank:g,normalizeRanks:d,notime:m,partition:x,pick:C,predecessorWeights:a,range:w,removeEmptyRanks:u,simplify:o,successorWeights:i,time:y,uniqueId:S,zipObject:k};function n(M,T,E,P){for(var N=P;M.hasNode(N);)N=S(P);return E.dummy=T,M.setNode(N,E),N}function o(M){let T=new r().setGraph(M.graph());return M.nodes().forEach(E=>T.setNode(E,M.node(E))),M.edges().forEach(E=>{let P=T.edge(E.v,E.w)||{weight:0,minlen:1},N=M.edge(E);T.setEdge(E.v,E.w,{weight:P.weight+N.weight,minlen:Math.max(P.minlen,N.minlen)})}),T}function s(M){let T=new r({multigraph:M.isMultigraph()}).setGraph(M.graph());return M.nodes().forEach(E=>{M.children(E).length||T.setNode(E,M.node(E))}),M.edges().forEach(E=>{T.setEdge(E,M.edge(E))}),T}function i(M){let T=M.nodes().map(E=>{let P={};return M.outEdges(E).forEach(N=>{P[N.w]=(P[N.w]||0)+M.edge(N).weight}),P});return k(M.nodes(),T)}function a(M){let T=M.nodes().map(E=>{let P={};return M.inEdges(E).forEach(N=>{P[N.v]=(P[N.v]||0)+M.edge(N).weight}),P});return k(M.nodes(),T)}function l(M,T){let E=M.x,P=M.y,N=T.x-E,D=T.y-P,R=M.width/2,O=M.height/2;if(!N&&!D)throw new Error("Not possible to find intersection inside of the rectangle");let B,L;return Math.abs(D)*R>Math.abs(N)*O?(D<0&&(O=-O),B=O*N/D,L=O):(N<0&&(R=-R),B=R,L=R*D/N),{x:E+B,y:P+L}}function c(M){let T=w(g(M)+1).map(()=>[]);return M.nodes().forEach(E=>{let P=M.node(E),N=P.rank;N!==void 0&&(T[N][P.order]=E)}),T}function d(M){let T=M.nodes().map(P=>{let N=M.node(P).rank;return N===void 0?Number.MAX_VALUE:N}),E=b(Math.min,T);M.nodes().forEach(P=>{let N=M.node(P);Object.hasOwn(N,"rank")&&(N.rank-=E)})}function u(M){let T=M.nodes().map(R=>M.node(R).rank).filter(R=>R!==void 0),E=b(Math.min,T),P=[];M.nodes().forEach(R=>{let O=M.node(R).rank-E;P[O]||(P[O]=[]),P[O].push(R)});let N=0,D=M.graph().nodeRankFactor;Array.from(P).forEach((R,O)=>{R===void 0&&O%D!==0?--N:R!==void 0&&N&&R.forEach(B=>M.node(B).rank+=N)})}function f(M,T,E,P){let N={width:0,height:0};return arguments.length>=4&&(N.rank=E,N.order=P),n(M,"border",N,T)}function p(M,T=h){let E=[];for(let P=0;P<M.length;P+=T){let N=M.slice(P,P+T);E.push(N)}return E}var h=65535;function b(M,T){if(T.length>h){let E=p(T);return M.apply(null,E.map(P=>M.apply(null,P)))}else return M.apply(null,T)}function g(M){let T=M.nodes().map(E=>{let P=M.node(E).rank;return P===void 0?Number.MIN_VALUE:P});return b(Math.max,T)}function x(M,T){let E={lhs:[],rhs:[]};return M.forEach(P=>{T(P)?E.lhs.push(P):E.rhs.push(P)}),E}function y(M,T){let E=Date.now();try{return T()}finally{console.log(M+" time: "+(Date.now()-E)+"ms")}}function m(M,T){return T()}var v=0;function S(M){var T=++v;return M+(""+T)}function w(M,T,E=1){T==null&&(T=M,M=0);let P=D=>D<T;E<0&&(P=D=>T<D);let N=[];for(let D=M;P(D);D+=E)N.push(D);return N}function C(M,T){let E={};for(let P of T)M[P]!==void 0&&(E[P]=M[P]);return E}function A(M,T){let E=T;return typeof T=="string"&&(E=P=>P[T]),Object.entries(M).reduce((P,[N,D])=>(P[N]=E(D,N),P),{})}function k(M,T){return M.reduce((E,P,N)=>(E[P]=T[N],E),{})}}),xV=rr((t,e)=>{"use strict";var r=bV(),n=hn().uniqueId;e.exports={run:o,undo:i};function o(a){(a.graph().acyclicer==="greedy"?r(a,l(a)):s(a)).forEach(c=>{let d=a.edge(c);a.removeEdge(c),d.forwardName=c.name,d.reversed=!0,a.setEdge(c.w,c.v,d,n("rev"))});function l(c){return d=>c.edge(d).weight}}function s(a){let l=[],c={},d={};function u(f){Object.hasOwn(d,f)||(d[f]=!0,c[f]=!0,a.outEdges(f).forEach(p=>{Object.hasOwn(c,p.w)?l.push(p):u(p.w)}),delete c[f])}return a.nodes().forEach(u),l}function i(a){a.edges().forEach(l=>{let c=a.edge(l);if(c.reversed){a.removeEdge(l);let d=c.forwardName;delete c.reversed,delete c.forwardName,a.setEdge(l.w,l.v,c,d)}})}}),yV=rr((t,e)=>{"use strict";var r=hn();e.exports={run:n,undo:s};function n(i){i.graph().dummyChains=[],i.edges().forEach(a=>o(i,a))}function o(i,a){let l=a.v,c=i.node(l).rank,d=a.w,u=i.node(d).rank,f=a.name,p=i.edge(a),h=p.labelRank;if(u===c+1)return;i.removeEdge(a);let b,g,x;for(x=0,++c;c<u;++x,++c)p.points=[],g={width:0,height:0,edgeLabel:p,edgeObj:a,rank:c},b=r.addDummyNode(i,"edge",g,"_d"),c===h&&(g.width=p.width,g.height=p.height,g.dummy="edge-label",g.labelpos=p.labelpos),i.setEdge(l,b,{weight:p.weight},f),x===0&&i.graph().dummyChains.push(b),l=b;i.setEdge(l,d,{weight:p.weight},f)}function s(i){i.graph().dummyChains.forEach(a=>{let l=i.node(a),c=l.edgeLabel,d;for(i.setEdge(l.edgeObj,c);l.dummy;)d=i.successors(a)[0],i.removeNode(a),c.points.push({x:l.x,y:l.y}),l.dummy==="edge-label"&&(c.x=l.x,c.y=l.y,c.width=l.width,c.height=l.height),a=d,l=i.node(a)})}}),ug=rr((t,e)=>{"use strict";var{applyWithChunking:r}=hn();e.exports={longestPath:n,slack:o};function n(s){var i={};function a(l){var c=s.node(l);if(Object.hasOwn(i,l))return c.rank;i[l]=!0;let d=s.outEdges(l).map(f=>f==null?Number.POSITIVE_INFINITY:a(f.w)-s.edge(f).minlen);var u=r(Math.min,d);return u===Number.POSITIVE_INFINITY&&(u=0),c.rank=u}s.sources().forEach(a)}function o(s,i){return s.node(i.w).rank-s.node(i.v).rank-s.edge(i).minlen}}),zM=rr((t,e)=>{"use strict";var r=Qs().Graph,n=ug().slack;e.exports=o;function o(l){var c=new r({directed:!1}),d=l.nodes()[0],u=l.nodeCount();c.setNode(d,{});for(var f,p;s(c,l)<u;)f=i(c,l),p=c.hasNode(f.v)?n(l,f):-n(l,f),a(c,l,p);return c}function s(l,c){function d(u){c.nodeEdges(u).forEach(f=>{var p=f.v,h=u===p?f.w:p;!l.hasNode(h)&&!n(c,f)&&(l.setNode(h,{}),l.setEdge(u,h,{}),d(h))})}return l.nodes().forEach(d),l.nodeCount()}function i(l,c){return c.edges().reduce((d,u)=>{let f=Number.POSITIVE_INFINITY;return l.hasNode(u.v)!==l.hasNode(u.w)&&(f=n(c,u)),f<d[0]?[f,u]:d},[Number.POSITIVE_INFINITY,null])[1]}function a(l,c,d){l.nodes().forEach(u=>c.node(u).rank+=d)}}),vV=rr((t,e)=>{"use strict";var r=zM(),n=ug().slack,o=ug().longestPath,s=Qs().alg.preorder,i=Qs().alg.postorder,a=hn().simplify;e.exports=l,l.initLowLimValues=f,l.initCutValues=c,l.calcCutValue=u,l.leaveEdge=h,l.enterEdge=b,l.exchangeEdges=g;function l(v){v=a(v),o(v);var S=r(v);f(S),c(S,v);for(var w,C;w=h(S);)C=b(S,v,w),g(S,v,w,C)}function c(v,S){var w=i(v,v.nodes());w=w.slice(0,w.length-1),w.forEach(C=>d(v,S,C))}function d(v,S,w){var C=v.node(w),A=C.parent;v.edge(w,A).cutvalue=u(v,S,w)}function u(v,S,w){var C=v.node(w),A=C.parent,k=!0,M=S.edge(w,A),T=0;return M||(k=!1,M=S.edge(A,w)),T=M.weight,S.nodeEdges(w).forEach(E=>{var P=E.v===w,N=P?E.w:E.v;if(N!==A){var D=P===k,R=S.edge(E).weight;if(T+=D?R:-R,y(v,w,N)){var O=v.edge(w,N).cutvalue;T+=D?-O:O}}}),T}function f(v,S){arguments.length<2&&(S=v.nodes()[0]),p(v,{},1,S)}function p(v,S,w,C,A){var k=w,M=v.node(C);return S[C]=!0,v.neighbors(C).forEach(T=>{Object.hasOwn(S,T)||(w=p(v,S,w,T,C))}),M.low=k,M.lim=w++,A?M.parent=A:delete M.parent,w}function h(v){return v.edges().find(S=>v.edge(S).cutvalue<0)}function b(v,S,w){var C=w.v,A=w.w;S.hasEdge(C,A)||(C=w.w,A=w.v);var k=v.node(C),M=v.node(A),T=k,E=!1;k.lim>M.lim&&(T=M,E=!0);var P=S.edges().filter(N=>E===m(v,v.node(N.v),T)&&E!==m(v,v.node(N.w),T));return P.reduce((N,D)=>n(S,D)<n(S,N)?D:N)}function g(v,S,w,C){var A=w.v,k=w.w;v.removeEdge(A,k),v.setEdge(C.v,C.w,{}),f(v),c(v,S),x(v,S)}function x(v,S){var w=v.nodes().find(A=>!S.node(A).parent),C=s(v,w);C=C.slice(1),C.forEach(A=>{var k=v.node(A).parent,M=S.edge(A,k),T=!1;M||(M=S.edge(k,A),T=!0),S.node(A).rank=S.node(k).rank+(T?M.minlen:-M.minlen)})}function y(v,S,w){return v.hasEdge(S,w)}function m(v,S,w){return w.low<=S.lim&&S.lim<=w.lim}}),wV=rr((t,e)=>{"use strict";var r=ug(),n=r.longestPath,o=zM(),s=vV();e.exports=i;function i(d){var u=d.graph().ranker;if(u instanceof Function)return u(d);switch(d.graph().ranker){case"network-simplex":c(d);break;case"tight-tree":l(d);break;case"longest-path":a(d);break;case"none":break;default:c(d)}}var a=n;function l(d){n(d),o(d)}function c(d){s(d)}}),SV=rr((t,e)=>{e.exports=r;function r(s){let i=o(s);s.graph().dummyChains.forEach(a=>{let l=s.node(a),c=l.edgeObj,d=n(s,i,c.v,c.w),u=d.path,f=d.lca,p=0,h=u[p],b=!0;for(;a!==c.w;){if(l=s.node(a),b){for(;(h=u[p])!==f&&s.node(h).maxRank<l.rank;)p++;h===f&&(b=!1)}if(!b){for(;p<u.length-1&&s.node(h=u[p+1]).minRank<=l.rank;)p++;h=u[p]}s.setParent(a,h),a=s.successors(a)[0]}})}function n(s,i,a,l){let c=[],d=[],u=Math.min(i[a].low,i[l].low),f=Math.max(i[a].lim,i[l].lim),p,h;p=a;do p=s.parent(p),c.push(p);while(p&&(i[p].low>u||f>i[p].lim));for(h=p,p=l;(p=s.parent(p))!==h;)d.push(p);return{path:c.concat(d.reverse()),lca:h}}function o(s){let i={},a=0;function l(c){let d=a;s.children(c).forEach(l),i[c]={low:d,lim:a++}}return s.children().forEach(l),i}}),NV=rr((t,e)=>{var r=hn();e.exports={run:n,cleanup:a};function n(l){let c=r.addDummyNode(l,"root",{},"_root"),d=s(l),u=Object.values(d),f=r.applyWithChunking(Math.max,u)-1,p=2*f+1;l.graph().nestingRoot=c,l.edges().forEach(b=>l.edge(b).minlen*=p);let h=i(l)+1;l.children().forEach(b=>o(l,c,p,h,f,d,b)),l.graph().nodeRankFactor=p}function o(l,c,d,u,f,p,h){let b=l.children(h);if(!b.length){h!==c&&l.setEdge(c,h,{weight:0,minlen:d});return}let g=r.addBorderNode(l,"_bt"),x=r.addBorderNode(l,"_bb"),y=l.node(h);l.setParent(g,h),y.borderTop=g,l.setParent(x,h),y.borderBottom=x,b.forEach(m=>{o(l,c,d,u,f,p,m);let v=l.node(m),S=v.borderTop?v.borderTop:m,w=v.borderBottom?v.borderBottom:m,C=v.borderTop?u:2*u,A=S!==w?1:f-p[h]+1;l.setEdge(g,S,{weight:C,minlen:A,nestingEdge:!0}),l.setEdge(w,x,{weight:C,minlen:A,nestingEdge:!0})}),l.parent(h)||l.setEdge(c,g,{weight:0,minlen:f+p[h]})}function s(l){var c={};function d(u,f){var p=l.children(u);p&&p.length&&p.forEach(h=>d(h,f+1)),c[u]=f}return l.children().forEach(u=>d(u,1)),c}function i(l){return l.edges().reduce((c,d)=>c+l.edge(d).weight,0)}function a(l){var c=l.graph();l.removeNode(c.nestingRoot),delete c.nestingRoot,l.edges().forEach(d=>{var u=l.edge(d);u.nestingEdge&&l.removeEdge(d)})}}),CV=rr((t,e)=>{var r=hn();e.exports=n;function n(s){function i(a){let l=s.children(a),c=s.node(a);if(l.length&&l.forEach(i),Object.hasOwn(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(let d=c.minRank,u=c.maxRank+1;d<u;++d)o(s,"borderLeft","_bl",a,c,d),o(s,"borderRight","_br",a,c,d)}}s.children().forEach(i)}function o(s,i,a,l,c,d){let u={width:0,height:0,rank:d,borderType:i},f=c[i][d-1],p=r.addDummyNode(s,"border",u,a);c[i][d]=p,s.setParent(p,l),f&&s.setEdge(f,p,{weight:1})}}),kV=rr((t,e)=>{"use strict";e.exports={adjust:r,undo:n};function r(d){let u=d.graph().rankdir.toLowerCase();(u==="lr"||u==="rl")&&o(d)}function n(d){let u=d.graph().rankdir.toLowerCase();(u==="bt"||u==="rl")&&i(d),(u==="lr"||u==="rl")&&(l(d),o(d))}function o(d){d.nodes().forEach(u=>s(d.node(u))),d.edges().forEach(u=>s(d.edge(u)))}function s(d){let u=d.width;d.width=d.height,d.height=u}function i(d){d.nodes().forEach(u=>a(d.node(u))),d.edges().forEach(u=>{let f=d.edge(u);f.points.forEach(a),Object.hasOwn(f,"y")&&a(f)})}function a(d){d.y=-d.y}function l(d){d.nodes().forEach(u=>c(d.node(u))),d.edges().forEach(u=>{let f=d.edge(u);f.points.forEach(c),Object.hasOwn(f,"x")&&c(f)})}function c(d){let u=d.x;d.x=d.y,d.y=u}}),EV=rr((t,e)=>{"use strict";var r=hn();e.exports=n;function n(o){let s={},i=o.nodes().filter(u=>!o.children(u).length),a=i.map(u=>o.node(u).rank),l=r.applyWithChunking(Math.max,a),c=r.range(l+1).map(()=>[]);function d(u){if(s[u])return;s[u]=!0;let f=o.node(u);c[f.rank].push(u),o.successors(u).forEach(d)}return i.sort((u,f)=>o.node(u).rank-o.node(f).rank).forEach(d),c}}),TV=rr((t,e)=>{"use strict";var r=hn().zipObject;e.exports=n;function n(s,i){let a=0;for(let l=1;l<i.length;++l)a+=o(s,i[l-1],i[l]);return a}function o(s,i,a){let l=r(a,a.map((h,b)=>b)),c=i.flatMap(h=>s.outEdges(h).map(b=>({pos:l[b.w],weight:s.edge(b).weight})).sort((b,g)=>b.pos-g.pos)),d=1;for(;d<a.length;)d<<=1;let u=2*d-1;d-=1;let f=new Array(u).fill(0),p=0;return c.forEach(h=>{let b=h.pos+d;f[b]+=h.weight;let g=0;for(;b>0;)b%2&&(g+=f[b+1]),b=b-1>>1,f[b]+=h.weight;p+=h.weight*g}),p}}),IV=rr((t,e)=>{e.exports=r;function r(n,o=[]){return o.map(s=>{let i=n.inEdges(s);if(i.length){let a=i.reduce((l,c)=>{let d=n.edge(c),u=n.node(c.v);return{sum:l.sum+d.weight*u.order,weight:l.weight+d.weight}},{sum:0,weight:0});return{v:s,barycenter:a.sum/a.weight,weight:a.weight}}else return{v:s}})}}),AV=rr((t,e)=>{"use strict";var r=hn();e.exports=n;function n(i,a){let l={};i.forEach((d,u)=>{let f=l[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:u};d.barycenter!==void 0&&(f.barycenter=d.barycenter,f.weight=d.weight)}),a.edges().forEach(d=>{let u=l[d.v],f=l[d.w];u!==void 0&&f!==void 0&&(f.indegree++,u.out.push(l[d.w]))});let c=Object.values(l).filter(d=>!d.indegree);return o(c)}function o(i){let a=[];function l(d){return u=>{u.merged||(u.barycenter===void 0||d.barycenter===void 0||u.barycenter>=d.barycenter)&&s(d,u)}}function c(d){return u=>{u.in.push(d),--u.indegree===0&&i.push(u)}}for(;i.length;){let d=i.pop();a.push(d),d.in.reverse().forEach(l(d)),d.out.forEach(c(d))}return a.filter(d=>!d.merged).map(d=>r.pick(d,["vs","i","barycenter","weight"]))}function s(i,a){let l=0,c=0;i.weight&&(l+=i.barycenter*i.weight,c+=i.weight),a.weight&&(l+=a.barycenter*a.weight,c+=a.weight),i.vs=a.vs.concat(i.vs),i.barycenter=l/c,i.weight=c,i.i=Math.min(a.i,i.i),a.merged=!0}}),MV=rr((t,e)=>{var r=hn();e.exports=n;function n(i,a){let l=r.partition(i,g=>Object.hasOwn(g,"barycenter")),c=l.lhs,d=l.rhs.sort((g,x)=>x.i-g.i),u=[],f=0,p=0,h=0;c.sort(s(!!a)),h=o(u,d,h),c.forEach(g=>{h+=g.vs.length,u.push(g.vs),f+=g.barycenter*g.weight,p+=g.weight,h=o(u,d,h)});let b={vs:u.flat(!0)};return p&&(b.barycenter=f/p,b.weight=p),b}function o(i,a,l){let c;for(;a.length&&(c=a[a.length-1]).i<=l;)a.pop(),i.push(c.vs),l++;return l}function s(i){return(a,l)=>a.barycenter<l.barycenter?-1:a.barycenter>l.barycenter?1:i?l.i-a.i:a.i-l.i}}),PV=rr((t,e)=>{var r=IV(),n=AV(),o=MV();e.exports=s;function s(l,c,d,u){let f=l.children(c),p=l.node(c),h=p?p.borderLeft:void 0,b=p?p.borderRight:void 0,g={};h&&(f=f.filter(v=>v!==h&&v!==b));let x=r(l,f);x.forEach(v=>{if(l.children(v.v).length){let S=s(l,v.v,d,u);g[v.v]=S,Object.hasOwn(S,"barycenter")&&a(v,S)}});let y=n(x,d);i(y,g);let m=o(y,u);if(h&&(m.vs=[h,m.vs,b].flat(!0),l.predecessors(h).length)){let v=l.node(l.predecessors(h)[0]),S=l.node(l.predecessors(b)[0]);Object.hasOwn(m,"barycenter")||(m.barycenter=0,m.weight=0),m.barycenter=(m.barycenter*m.weight+v.order+S.order)/(m.weight+2),m.weight+=2}return m}function i(l,c){l.forEach(d=>{d.vs=d.vs.flatMap(u=>c[u]?c[u].vs:u)})}function a(l,c){l.barycenter!==void 0?(l.barycenter=(l.barycenter*l.weight+c.barycenter*c.weight)/(l.weight+c.weight),l.weight+=c.weight):(l.barycenter=c.barycenter,l.weight=c.weight)}}),RV=rr((t,e)=>{var r=Qs().Graph,n=hn();e.exports=o;function o(i,a,l,c){c||(c=i.nodes());let d=s(i),u=new r({compound:!0}).setGraph({root:d}).setDefaultNodeLabel(f=>i.node(f));return c.forEach(f=>{let p=i.node(f),h=i.parent(f);(p.rank===a||p.minRank<=a&&a<=p.maxRank)&&(u.setNode(f),u.setParent(f,h||d),i[l](f).forEach(b=>{let g=b.v===f?b.w:b.v,x=u.edge(g,f),y=x!==void 0?x.weight:0;u.setEdge(g,f,{weight:i.edge(b).weight+y})}),Object.hasOwn(p,"minRank")&&u.setNode(f,{borderLeft:p.borderLeft[a],borderRight:p.borderRight[a]}))}),u}function s(i){for(var a;i.hasNode(a=n.uniqueId("_root")););return a}}),DV=rr((t,e)=>{e.exports=r;function r(n,o,s){let i={},a;s.forEach(l=>{let c=n.parent(l),d,u;for(;c;){if(d=n.parent(c),d?(u=i[d],i[d]=c):(u=a,a=c),u&&u!==c){o.setEdge(u,c);return}c=d}})}}),OV=rr((t,e)=>{"use strict";var r=EV(),n=TV(),o=PV(),s=RV(),i=DV(),a=Qs().Graph,l=hn();e.exports=c;function c(p,h={}){if(typeof h.customOrder=="function"){h.customOrder(p,c);return}let b=l.maxRank(p),g=d(p,l.range(1,b+1),"inEdges"),x=d(p,l.range(b-1,-1,-1),"outEdges"),y=r(p);if(f(p,y),h.disableOptimalOrderHeuristic)return;let m=Number.POSITIVE_INFINITY,v,S=h.constraints||[];for(let w=0,C=0;C<4;++w,++C){u(w%2?g:x,w%4>=2,S),y=l.buildLayerMatrix(p);let A=n(p,y);A<m?(C=0,v=Object.assign({},y),m=A):A===m&&(v=structuredClone(y))}f(p,v)}function d(p,h,b){let g=new Map,x=(y,m)=>{g.has(y)||g.set(y,[]),g.get(y).push(m)};for(let y of p.nodes()){let m=p.node(y);if(typeof m.rank=="number"&&x(m.rank,y),typeof m.minRank=="number"&&typeof m.maxRank=="number")for(let v=m.minRank;v<=m.maxRank;v++)v!==m.rank&&x(v,y)}return h.map(function(y){return s(p,y,b,g.get(y)||[])})}function u(p,h,b){let g=new a;p.forEach(function(x){b.forEach(v=>g.setEdge(v.left,v.right));let y=x.graph().root,m=o(x,y,g,h);m.vs.forEach((v,S)=>x.node(v).order=S),i(x,g,m.vs)})}function f(p,h){Object.values(h).forEach(b=>b.forEach((g,x)=>p.node(g).order=x))}}),_V=rr((t,e)=>{"use strict";var r=Qs().Graph,n=hn();e.exports={positionX:b,findType1Conflicts:o,findType2Conflicts:s,addConflict:a,hasConflict:l,verticalAlignment:c,horizontalCompaction:d,alignCoordinates:p,findSmallestWidthAlignment:f,balance:h};function o(y,m){let v={};function S(w,C){let A=0,k=0,M=w.length,T=C[C.length-1];return C.forEach((E,P)=>{let N=i(y,E),D=N?y.node(N).order:M;(N||E===T)&&(C.slice(k,P+1).forEach(R=>{y.predecessors(R).forEach(O=>{let B=y.node(O),L=B.order;(L<A||D<L)&&!(B.dummy&&y.node(R).dummy)&&a(v,O,R)})}),k=P+1,A=D)}),C}return m.length&&m.reduce(S),v}function s(y,m){let v={};function S(C,A,k,M,T){let E;n.range(A,k).forEach(P=>{E=C[P],y.node(E).dummy&&y.predecessors(E).forEach(N=>{let D=y.node(N);D.dummy&&(D.order<M||D.order>T)&&a(v,N,E)})})}function w(C,A){let k=-1,M,T=0;return A.forEach((E,P)=>{if(y.node(E).dummy==="border"){let N=y.predecessors(E);N.length&&(M=y.node(N[0]).order,S(A,T,P,k,M),T=P,k=M)}S(A,T,A.length,M,C.length)}),A}return m.length&&m.reduce(w),v}function i(y,m){if(y.node(m).dummy)return y.predecessors(m).find(v=>y.node(v).dummy)}function a(y,m,v){if(m>v){let w=m;m=v,v=w}let S=y[m];S||(y[m]=S={}),S[v]=!0}function l(y,m,v){if(m>v){let S=m;m=v,v=S}return!!y[m]&&Object.hasOwn(y[m],v)}function c(y,m,v,S){let w={},C={},A={};return m.forEach(k=>{k.forEach((M,T)=>{w[M]=M,C[M]=M,A[M]=T})}),m.forEach(k=>{let M=-1;k.forEach(T=>{let E=S(T);if(E.length){E=E.sort((N,D)=>A[N]-A[D]);let P=(E.length-1)/2;for(let N=Math.floor(P),D=Math.ceil(P);N<=D;++N){let R=E[N];C[T]===T&&M<A[R]&&!l(v,T,R)&&(C[R]=T,C[T]=w[T]=w[R],M=A[R])}}})}),{root:w,align:C}}function d(y,m,v,S,w){let C={},A=u(y,m,v,w),k=w?"borderLeft":"borderRight";function M(P,N){let D=A.nodes().slice(),R={},O=D.pop();for(;O;){if(R[O])P(O);else{R[O]=!0,D.push(O);for(let B of N(O))D.push(B)}O=D.pop()}}function T(P){C[P]=A.inEdges(P).reduce((N,D)=>Math.max(N,C[D.v]+A.edge(D)),0)}function E(P){let N=A.outEdges(P).reduce((R,O)=>Math.min(R,C[O.w]-A.edge(O)),Number.POSITIVE_INFINITY),D=y.node(P);N!==Number.POSITIVE_INFINITY&&D.borderType!==k&&(C[P]=Math.max(C[P],N))}return M(T,A.predecessors.bind(A)),M(E,A.successors.bind(A)),Object.keys(S).forEach(P=>C[P]=C[v[P]]),C}function u(y,m,v,S){let w=new r,C=y.graph(),A=g(C.nodesep,C.edgesep,S);return m.forEach(k=>{let M;k.forEach(T=>{let E=v[T];if(w.setNode(E),M){var P=v[M],N=w.edge(P,E);w.setEdge(P,E,Math.max(A(y,T,M),N||0))}M=T})}),w}function f(y,m){return Object.values(m).reduce((v,S)=>{let w=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;Object.entries(S).forEach(([k,M])=>{let T=x(y,k)/2;w=Math.max(M+T,w),C=Math.min(M-T,C)});let A=w-C;return A<v[0]&&(v=[A,S]),v},[Number.POSITIVE_INFINITY,null])[1]}function p(y,m){let v=Object.values(m),S=n.applyWithChunking(Math.min,v),w=n.applyWithChunking(Math.max,v);["u","d"].forEach(C=>{["l","r"].forEach(A=>{let k=C+A,M=y[k];if(M===m)return;let T=Object.values(M),E=S-n.applyWithChunking(Math.min,T);A!=="l"&&(E=w-n.applyWithChunking(Math.max,T)),E&&(y[k]=n.mapValues(M,P=>P+E))})})}function h(y,m){return n.mapValues(y.ul,(v,S)=>{if(m)return y[m.toLowerCase()][S];{let w=Object.values(y).map(C=>C[S]).sort((C,A)=>C-A);return(w[1]+w[2])/2}})}function b(y){let m=n.buildLayerMatrix(y),v=Object.assign(o(y,m),s(y,m)),S={},w;["u","d"].forEach(A=>{w=A==="u"?m:Object.values(m).reverse(),["l","r"].forEach(k=>{k==="r"&&(w=w.map(P=>Object.values(P).reverse()));let M=(A==="u"?y.predecessors:y.successors).bind(y),T=c(y,w,v,M),E=d(y,w,T.root,T.align,k==="r");k==="r"&&(E=n.mapValues(E,P=>-P)),S[A+k]=E})});let C=f(y,S);return p(S,C),h(S,y.graph().align)}function g(y,m,v){return(S,w,C)=>{let A=S.node(w),k=S.node(C),M=0,T;if(M+=A.width/2,Object.hasOwn(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":T=-A.width/2;break;case"r":T=A.width/2;break}if(T&&(M+=v?T:-T),T=0,M+=(A.dummy?m:y)/2,M+=(k.dummy?m:y)/2,M+=k.width/2,Object.hasOwn(k,"labelpos"))switch(k.labelpos.toLowerCase()){case"l":T=k.width/2;break;case"r":T=-k.width/2;break}return T&&(M+=v?T:-T),T=0,M}}function x(y,m){return y.node(m).width}}),LV=rr((t,e)=>{"use strict";var r=hn(),n=_V().positionX;e.exports=o;function o(i){i=r.asNonCompoundGraph(i),s(i),Object.entries(n(i)).forEach(([a,l])=>i.node(a).x=l)}function s(i){let a=r.buildLayerMatrix(i),l=i.graph().ranksep,c=i.graph().rankalign,d=0;a.forEach(u=>{let f=u.reduce((p,h)=>{let b=i.node(h).height;return p>b?p:b},0);u.forEach(p=>{let h=i.node(p);c==="top"?h.y=d+h.height/2:c==="bottom"?h.y=d+f-h.height/2:h.y=d+f/2}),d+=f+l})}}),BV=rr((t,e)=>{"use strict";var r=xV(),n=yV(),o=wV(),s=hn().normalizeRanks,i=SV(),a=hn().removeEmptyRanks,l=NV(),c=CV(),d=kV(),u=OV(),f=LV(),p=hn(),h=Qs().Graph;e.exports=b;function b(_,W={}){let V=W.debugTiming?p.time:p.notime;return V("layout",()=>{let z=V(" buildLayoutGraph",()=>M(_));return V(" runLayout",()=>g(z,V,W)),V(" updateInputGraph",()=>x(_,z)),z})}function g(_,W,V){W(" makeSpaceForEdgeLabels",()=>T(_)),W(" removeSelfEdges",()=>H(_)),W(" acyclic",()=>r.run(_)),W(" nestingGraph.run",()=>l.run(_)),W(" rank",()=>o(p.asNonCompoundGraph(_))),W(" injectEdgeLabelProxies",()=>E(_)),W(" removeEmptyRanks",()=>a(_)),W(" nestingGraph.cleanup",()=>l.cleanup(_)),W(" normalizeRanks",()=>s(_)),W(" assignRankMinMax",()=>P(_)),W(" removeEdgeLabelProxies",()=>N(_)),W(" normalize.run",()=>n.run(_)),W(" parentDummyChains",()=>i(_)),W(" addBorderSegments",()=>c(_)),W(" order",()=>u(_,V)),W(" insertSelfEdges",()=>j(_)),W(" adjustCoordinateSystem",()=>d.adjust(_)),W(" position",()=>f(_)),W(" positionSelfEdges",()=>$(_)),W(" removeBorderNodes",()=>L(_)),W(" normalize.undo",()=>n.undo(_)),W(" fixupEdgeLabelCoords",()=>O(_)),W(" undoCoordinateSystem",()=>d.undo(_)),W(" translateGraph",()=>D(_)),W(" assignNodeIntersects",()=>R(_)),W(" reversePoints",()=>B(_)),W(" acyclic.undo",()=>r.undo(_))}function x(_,W){_.nodes().forEach(V=>{let z=_.node(V),G=W.node(V);z&&(z.x=G.x,z.y=G.y,z.order=G.order,z.rank=G.rank,W.children(V).length&&(z.width=G.width,z.height=G.height))}),_.edges().forEach(V=>{let z=_.edge(V),G=W.edge(V);z.points=G.points,Object.hasOwn(G,"x")&&(z.x=G.x,z.y=G.y)}),_.graph().width=W.graph().width,_.graph().height=W.graph().height}var y=["nodesep","edgesep","ranksep","marginx","marginy"],m={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb",rankalign:"center"},v=["acyclicer","ranker","rankdir","align","rankalign"],S=["width","height","rank"],w={width:0,height:0},C=["minlen","weight","width","height","labeloffset"],A={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},k=["labelpos"];function M(_){let W=new h({multigraph:!0,compound:!0}),V=F(_.graph());return W.setGraph(Object.assign({},m,q(V,y),p.pick(V,v))),_.nodes().forEach(z=>{let G=F(_.node(z)),Y=q(G,S);Object.keys(w).forEach(Z=>{Y[Z]===void 0&&(Y[Z]=w[Z])}),W.setNode(z,Y),W.setParent(z,_.parent(z))}),_.edges().forEach(z=>{let G=F(_.edge(z));W.setEdge(z,Object.assign({},A,q(G,C),p.pick(G,k)))}),W}function T(_){let W=_.graph();W.ranksep/=2,_.edges().forEach(V=>{let z=_.edge(V);z.minlen*=2,z.labelpos.toLowerCase()!=="c"&&(W.rankdir==="TB"||W.rankdir==="BT"?z.width+=z.labeloffset:z.height+=z.labeloffset)})}function E(_){_.edges().forEach(W=>{let V=_.edge(W);if(V.width&&V.height){let z=_.node(W.v),G={rank:(_.node(W.w).rank-z.rank)/2+z.rank,e:W};p.addDummyNode(_,"edge-proxy",G,"_ep")}})}function P(_){let W=0;_.nodes().forEach(V=>{let z=_.node(V);z.borderTop&&(z.minRank=_.node(z.borderTop).rank,z.maxRank=_.node(z.borderBottom).rank,W=Math.max(W,z.maxRank))}),_.graph().maxRank=W}function N(_){_.nodes().forEach(W=>{let V=_.node(W);V.dummy==="edge-proxy"&&(_.edge(V.e).labelRank=V.rank,_.removeNode(W))})}function D(_){let W=Number.POSITIVE_INFINITY,V=0,z=Number.POSITIVE_INFINITY,G=0,Y=_.graph(),Z=Y.marginx||0,se=Y.marginy||0;function we(_e){let Pe=_e.x,K=_e.y,he=_e.width,lt=_e.height;W=Math.min(W,Pe-he/2),V=Math.max(V,Pe+he/2),z=Math.min(z,K-lt/2),G=Math.max(G,K+lt/2)}_.nodes().forEach(_e=>we(_.node(_e))),_.edges().forEach(_e=>{let Pe=_.edge(_e);Object.hasOwn(Pe,"x")&&we(Pe)}),W-=Z,z-=se,_.nodes().forEach(_e=>{let Pe=_.node(_e);Pe.x-=W,Pe.y-=z}),_.edges().forEach(_e=>{let Pe=_.edge(_e);Pe.points.forEach(K=>{K.x-=W,K.y-=z}),Object.hasOwn(Pe,"x")&&(Pe.x-=W),Object.hasOwn(Pe,"y")&&(Pe.y-=z)}),Y.width=V-W+Z,Y.height=G-z+se}function R(_){_.edges().forEach(W=>{let V=_.edge(W),z=_.node(W.v),G=_.node(W.w),Y,Z;V.points?(Y=V.points[0],Z=V.points[V.points.length-1]):(V.points=[],Y=G,Z=z),V.points.unshift(p.intersectRect(z,Y)),V.points.push(p.intersectRect(G,Z))})}function O(_){_.edges().forEach(W=>{let V=_.edge(W);if(Object.hasOwn(V,"x"))switch((V.labelpos==="l"||V.labelpos==="r")&&(V.width-=V.labeloffset),V.labelpos){case"l":V.x-=V.width/2+V.labeloffset;break;case"r":V.x+=V.width/2+V.labeloffset;break}})}function B(_){_.edges().forEach(W=>{let V=_.edge(W);V.reversed&&V.points.reverse()})}function L(_){_.nodes().forEach(W=>{if(_.children(W).length){let V=_.node(W),z=_.node(V.borderTop),G=_.node(V.borderBottom),Y=_.node(V.borderLeft[V.borderLeft.length-1]),Z=_.node(V.borderRight[V.borderRight.length-1]);V.width=Math.abs(Z.x-Y.x),V.height=Math.abs(G.y-z.y),V.x=Y.x+V.width/2,V.y=z.y+V.height/2}}),_.nodes().forEach(W=>{_.node(W).dummy==="border"&&_.removeNode(W)})}function H(_){_.edges().forEach(W=>{if(W.v===W.w){var V=_.node(W.v);V.selfEdges||(V.selfEdges=[]),V.selfEdges.push({e:W,label:_.edge(W)}),_.removeEdge(W)}})}function j(_){var W=p.buildLayerMatrix(_);W.forEach(V=>{var z=0;V.forEach((G,Y)=>{var Z=_.node(G);Z.order=Y+z,(Z.selfEdges||[]).forEach(se=>{p.addDummyNode(_,"selfedge",{width:se.label.width,height:se.label.height,rank:Z.rank,order:Y+ ++z,e:se.e,label:se.label},"_se")}),delete Z.selfEdges})})}function $(_){_.nodes().forEach(W=>{var V=_.node(W);if(V.dummy==="selfedge"){var z=_.node(V.e.v),G=z.x+z.width/2,Y=z.y,Z=V.x-G,se=z.height/2;_.setEdge(V.e,V.label),_.removeNode(W),V.label.points=[{x:G+2*Z/3,y:Y-se},{x:G+5*Z/6,y:Y-se},{x:G+Z,y:Y},{x:G+5*Z/6,y:Y+se},{x:G+2*Z/3,y:Y+se}],V.label.x=V.x,V.label.y=V.y}})}function q(_,W){return p.mapValues(p.pick(_,W),Number)}function F(_){var W={};return _&&Object.entries(_).forEach(([V,z])=>{typeof V=="string"&&(V=V.toLowerCase()),W[V]=z}),W}}),zV=rr((t,e)=>{var r=hn(),n=Qs().Graph;e.exports={debugOrdering:o};function o(s){let i=r.buildLayerMatrix(s),a=new n({compound:!0,multigraph:!0}).setGraph({});return s.nodes().forEach(l=>{a.setNode(l,{label:l}),a.setParent(l,"layer"+s.node(l).rank)}),s.edges().forEach(l=>a.setEdge(l.v,l.w,{},l.name)),i.forEach((l,c)=>{let d="layer"+c;a.setNode(d,{rank:"same"}),l.reduce((u,f)=>(a.setEdge(u,f,{style:"invis"}),f))}),a}}),$V=rr((t,e)=>{e.exports="2.0.4"}),FV=rr((t,e)=>{e.exports={graphlib:Qs(),layout:BV(),debug:zV(),util:{time:hn().time,notime:hn().notime},version:$V()}}),zy=FV();});function fg(t,e,r={}){let{direction:n="TB",nodeWidth:o=260,nodeHeight:s=180,rankSep:i=100,nodeSep:a=80}=r,l=new zy.graphlib.Graph().setDefaultEdgeLabel(()=>({}));return l.setGraph({rankdir:n,ranksep:i,nodesep:a,marginx:50,marginy:50}),t.forEach(d=>{let u=d.measured?.width||o,f=d.measured?.height||s;l.setNode(d.id,{width:u,height:f})}),e.forEach(d=>{l.setEdge(d.source,d.target)}),zy.layout(l),{nodes:t.map(d=>{let u=l.node(d.id),f=d.measured?.width||o,p=d.measured?.height||s;return{...d,position:{x:u.x-f/2,y:u.y-p/2}}}),edges:e}}var $y=U(()=>{"use strict";$M()});var HM,_n,FM,$t,Oe,ks=U(()=>{"use strict";Ri();HM=require("lucide-react"),_n=require("react/jsx-runtime"),FM={teal:{border:"border-teal-500/30",bg:"from-teal-500/15 to-cyan-500/10",text:"text-teal-400",ring:"ring-teal-400",glow:"rgba(20,184,166,0.6)"},cyan:{border:"border-cyan-500/30",bg:"from-cyan-500/15 to-sky-500/10",text:"text-cyan-400",ring:"ring-cyan-400",glow:"rgba(6,182,212,0.6)"},sky:{border:"border-sky-500/30",bg:"from-sky-500/15 to-blue-500/10",text:"text-sky-400",ring:"ring-sky-400",glow:"rgba(14,165,233,0.6)"},indigo:{border:"border-indigo-500/30",bg:"from-indigo-500/15 to-violet-500/10",text:"text-indigo-400",ring:"ring-indigo-400",glow:"rgba(99,102,241,0.6)"},rose:{border:"border-rose-500/30",bg:"from-rose-500/15 to-pink-500/10",text:"text-rose-400",ring:"ring-rose-400",glow:"rgba(244,63,94,0.6)"},amber:{border:"border-amber-500/30",bg:"from-amber-500/15 to-orange-500/10",text:"text-amber-400",ring:"ring-amber-400",glow:"rgba(245,158,11,0.6)"},emerald:{border:"border-emerald-500/30",bg:"from-emerald-500/15 to-green-500/10",text:"text-emerald-400",ring:"ring-emerald-400",glow:"rgba(16,185,129,0.6)"},violet:{border:"border-violet-500/30",bg:"from-violet-500/15 to-purple-500/10",text:"text-violet-400",ring:"ring-violet-400",glow:"rgba(139,92,246,0.6)"},pink:{border:"border-pink-500/30",bg:"from-pink-500/15 to-rose-500/10",text:"text-pink-400",ring:"ring-pink-400",glow:"rgba(236,72,153,0.6)"},orange:{border:"border-orange-500/30",bg:"from-orange-500/15 to-amber-500/10",text:"text-orange-400",ring:"ring-orange-400",glow:"rgba(249,115,22,0.6)"}},$t=({label:t,icon:e,accentColor:r,isExecuting:n,children:o,extraHandles:s})=>{let i=FM[r]||FM.teal,a=n?`ring-2 ${i.ring} shadow-[0_0_20px_${i.glow}] scale-105 z-50`:"";return(0,_n.jsxs)("div",{className:`bg-surface-tertiary ${i.border} border rounded-xl shadow-2xl w-[240px] overflow-hidden group hover:${i.border.replace("/30","/60")} transition-all duration-300 ${a}`,children:[(0,_n.jsxs)("div",{className:`bg-linear-to-r ${i.bg} px-3 py-2 border-b ${i.border.replace("/30","/20")} flex items-center justify-between`,children:[(0,_n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_n.jsx)("span",{className:i.text,children:e}),(0,_n.jsx)("span",{className:`text-xs font-bold ${i.text} uppercase tracking-widest`,children:t})]}),(0,_n.jsx)("div",{className:`${i.text} opacity-30 cursor-grab active:cursor-grabbing hover:opacity-80 transition-colors custom-drag-handle`,children:(0,_n.jsx)(HM.GripVertical,{size:14})})]}),(0,_n.jsx)("div",{className:"p-3 flex flex-col gap-3",children:o}),(0,_n.jsx)(qr,{type:"target",position:Te.Top,className:"w-3! h-3! bg-teal-500! border-teal-400/50! -top-1.5!"}),(0,_n.jsx)(qr,{type:"source",id:"success",position:Te.Bottom,className:"w-3! h-3! bg-emerald-500! border-emerald-400/50! -bottom-1.5!"}),s?.map(l=>(0,_n.jsx)(qr,{type:"source",id:l.id,position:l.position,className:l.className},l.id))]})},Oe=({label:t,value:e,onChange:r,placeholder:n,type:o="text",options:s})=>(0,_n.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,_n.jsx)("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:t}),o==="select"&&s?(0,_n.jsx)("select",{value:e,onChange:i=>r(i.target.value),className:"bg-surface-tertiary/50 border border-border-subtle rounded-lg px-2 py-1.5 text-xs text-text-primary w-full focus:outline-hidden focus:border-teal-500/50 transition-colors appearance-none cursor-pointer",children:s.map(i=>(0,_n.jsx)("option",{value:i.value,children:i.label},i.value))}):(0,_n.jsx)("input",{type:o,value:e,onChange:i=>r(i.target.value),className:"bg-surface-tertiary/50 border border-border-subtle rounded-lg px-2 py-1.5 text-xs text-text-primary w-full focus:outline-hidden focus:border-teal-500/50 transition-colors font-mono",placeholder:n})]})});var VM,jM,ca,Fy,WM=U(()=>{"use strict";VM=require("lucide-react");ks();jM=require("@decido/engine");ot();ca=require("react/jsx-runtime"),Fy=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,jM.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,ca.jsxs)($t,{id:t,label:"Activity Bar",icon:(0,ca.jsx)(VM.PanelLeft,{size:14}),accentColor:"teal",isExecuting:e.isExecuting,children:[(0,ca.jsx)(Oe,{label:"ID",value:e.shellItemId||"",onChange:s=>o("shellItemId",s),placeholder:"btn-explorer"}),(0,ca.jsx)(Oe,{label:"T\xEDtulo",value:e.shellTitle||"",onChange:s=>o("shellTitle",s),placeholder:"Explorador"}),(0,ca.jsx)(Oe,{label:"\xCDcono",value:e.shellIcon||"",onChange:s=>o("shellIcon",s),placeholder:"fas fa-folder"}),(0,ca.jsx)(Oe,{label:"View ID",value:e.shellViewId||"",onChange:s=>o("shellViewId",s),placeholder:"explorer-view"}),(0,ca.jsx)(Oe,{label:"Orden",value:String(e.shellOrder||0),onChange:s=>o("shellOrder",parseInt(s)||0),type:"number"})]})}});var UM,GM,ol,Hy,KM=U(()=>{"use strict";UM=require("lucide-react");ks();GM=require("@decido/engine");ot();ol=require("react/jsx-runtime"),Hy=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,GM.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,ol.jsxs)($t,{id:t,label:"Open Tab",icon:(0,ol.jsx)(UM.FileText,{size:14}),accentColor:"cyan",isExecuting:e.isExecuting,children:[(0,ol.jsx)(Oe,{label:"Tab ID",value:e.shellTabId||"",onChange:s=>o("shellTabId",s),placeholder:"settings-tab"}),(0,ol.jsx)(Oe,{label:"T\xEDtulo",value:e.shellTabTitle||"",onChange:s=>o("shellTabTitle",s),placeholder:"Configuraci\xF3n"}),(0,ol.jsx)(Oe,{label:"Componente",value:e.shellTabComponent||"",onChange:s=>o("shellTabComponent",s),placeholder:"settings-view"}),(0,ol.jsx)(Oe,{label:"\xCDcono",value:e.shellIcon||"",onChange:s=>o("shellIcon",s),placeholder:"fas fa-cog"})]})}});var qM,YM,Yd,Vy,XM=U(()=>{"use strict";qM=require("lucide-react");ks();YM=require("@decido/engine");ot();Yd=require("react/jsx-runtime"),Vy=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,YM.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,Yd.jsxs)($t,{id:t,label:"Panel View",icon:(0,Yd.jsx)(qM.PanelBottom,{size:14}),accentColor:"indigo",isExecuting:e.isExecuting,children:[(0,Yd.jsx)(Oe,{label:"Panel ID",value:e.shellPanelId||"",onChange:s=>o("shellPanelId",s),placeholder:"output-panel"}),(0,Yd.jsx)(Oe,{label:"T\xEDtulo",value:e.shellPanelTitle||"",onChange:s=>o("shellPanelTitle",s),placeholder:"Output"})]})}});var JM,ZM,Xd,jy,QM=U(()=>{"use strict";JM=require("lucide-react");ks();ZM=require("@decido/engine");ot();Xd=require("react/jsx-runtime"),jy=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,ZM.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,Xd.jsxs)($t,{id:t,label:"Sidebar View",icon:(0,Xd.jsx)(JM.Sidebar,{size:14}),accentColor:"sky",isExecuting:e.isExecuting,children:[(0,Xd.jsx)(Oe,{label:"View ID",value:e.shellSidebarId||"",onChange:s=>o("shellSidebarId",s),placeholder:"file-explorer"}),(0,Xd.jsx)(Oe,{label:"T\xEDtulo",value:e.shellSidebarTitle||"",onChange:s=>o("shellSidebarTitle",s),placeholder:"Archivos"})]})}});var eP,tP,sl,Wy,rP=U(()=>{"use strict";eP=require("lucide-react");ks();tP=require("@decido/engine");ot();sl=require("react/jsx-runtime"),Wy=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,tP.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,sl.jsxs)($t,{id:t,label:"Status Bar",icon:(0,sl.jsx)(eP.Minus,{size:14}),accentColor:"emerald",isExecuting:e.isExecuting,children:[(0,sl.jsx)(Oe,{label:"Item ID",value:e.shellStatusId||"",onChange:s=>o("shellStatusId",s),placeholder:"git-branch"}),(0,sl.jsx)(Oe,{label:"Texto",value:e.shellStatusText||"",onChange:s=>o("shellStatusText",s),placeholder:"main \u2713"}),(0,sl.jsx)(Oe,{label:"Alineaci\xF3n",value:e.shellStatusAlign||"left",onChange:s=>o("shellStatusAlign",s),type:"select",options:[{value:"left",label:"\u2190 Izquierda"},{value:"right",label:"\u2192 Derecha"}]}),(0,sl.jsx)(Oe,{label:"Orden",value:String(e.shellOrder||0),onChange:s=>o("shellOrder",parseInt(s)||0),type:"number"})]})}});var nP,oP,da,Uy,sP=U(()=>{"use strict";nP=require("lucide-react");ks();oP=require("@decido/engine");ot();da=require("react/jsx-runtime"),Uy=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,oP.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,da.jsxs)($t,{id:t,label:"Top Bar",icon:(0,da.jsx)(nP.ArrowUpFromDot,{size:14}),accentColor:"violet",isExecuting:e.isExecuting,children:[(0,da.jsx)(Oe,{label:"Item ID",value:e.shellTopBarId||"",onChange:s=>o("shellTopBarId",s),placeholder:"toggle-sidebar"}),(0,da.jsx)(Oe,{label:"T\xEDtulo",value:e.shellTitle||"",onChange:s=>o("shellTitle",s),placeholder:"Panel Izquierdo"}),(0,da.jsx)(Oe,{label:"\xCDcono",value:e.shellIcon||"",onChange:s=>o("shellIcon",s),placeholder:"fas fa-bars"}),(0,da.jsx)(Oe,{label:"Command ID",value:e.shellCommandId||"",onChange:s=>o("shellCommandId",s),placeholder:"layout.toggleSidebar"}),(0,da.jsx)(Oe,{label:"Orden",value:String(e.shellOrder||0),onChange:s=>o("shellOrder",parseInt(s)||0),type:"number"})]})}});var iP,aP,lc,Gy,lP=U(()=>{"use strict";iP=require("lucide-react");ks();aP=require("@decido/engine");ot();lc=require("react/jsx-runtime"),Gy=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,aP.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,lc.jsxs)($t,{id:t,label:"Register Cmd",icon:(0,lc.jsx)(iP.Terminal,{size:14}),accentColor:"amber",isExecuting:e.isExecuting,children:[(0,lc.jsx)(Oe,{label:"Command ID",value:e.shellCommandId||"",onChange:s=>o("shellCommandId",s),placeholder:"myModule.doSomething"}),(0,lc.jsx)(Oe,{label:"T\xEDtulo",value:e.shellTitle||"",onChange:s=>o("shellTitle",s),placeholder:"Hacer algo"}),(0,lc.jsx)(Oe,{label:"Categor\xEDa",value:e.shellCategory||"",onChange:s=>o("shellCategory",s),placeholder:"General"})]})}});var Di,$f,vn,Ky,qy,Yy,Xy,Jy,cP=U(()=>{"use strict";Di=require("lucide-react");ks();$f=require("@decido/engine");ot();vn=require("react/jsx-runtime"),Ky=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,$f.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,vn.jsx)($t,{id:t,label:"Toggle Sidebar",icon:(0,vn.jsx)(Di.PanelLeftClose,{size:14}),accentColor:"sky",isExecuting:e.isExecuting,children:(0,vn.jsx)(Oe,{label:"Estado",value:e.shellVisible||"toggle",onChange:s=>o("shellVisible",s),type:"select",options:[{value:"toggle",label:"\u2194 Toggle"},{value:"true",label:"\u{1F441} Mostrar"},{value:"false",label:"\u{1F6AB} Ocultar"}]})})},qy=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,$f.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,vn.jsx)($t,{id:t,label:"Toggle Panel",icon:(0,vn.jsx)(Di.PanelBottomClose,{size:14}),accentColor:"indigo",isExecuting:e.isExecuting,children:(0,vn.jsx)(Oe,{label:"Estado",value:e.shellVisible||"toggle",onChange:s=>o("shellVisible",s),type:"select",options:[{value:"toggle",label:"\u2194 Toggle"},{value:"true",label:"\u{1F441} Mostrar"},{value:"false",label:"\u{1F6AB} Ocultar"}]})})},Yy=({id:t,data:e})=>(0,vn.jsx)($t,{id:t,label:"Split Pane",icon:(0,vn.jsx)(Di.Columns2,{size:14}),accentColor:"violet",isExecuting:e.isExecuting,children:(0,vn.jsx)("div",{className:"text-[10px] text-text-muted italic",children:"Divide el editor en un nuevo panel"})}),Xy=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,$f.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,vn.jsxs)($t,{id:t,label:"Focus Tab",icon:(0,vn.jsx)(Di.Focus,{size:14}),accentColor:"cyan",isExecuting:e.isExecuting,children:[(0,vn.jsx)(Oe,{label:"Pane ID",value:e.shellPaneId||"",onChange:s=>o("shellPaneId",s),placeholder:"pane-main"}),(0,vn.jsx)(Oe,{label:"Tab ID",value:e.shellTabId||"",onChange:s=>o("shellTabId",s),placeholder:"settings-tab"})]})},Jy=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,$f.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,vn.jsxs)($t,{id:t,label:"Close Tab",icon:(0,vn.jsx)(Di.X,{size:14}),accentColor:"rose",isExecuting:e.isExecuting,children:[(0,vn.jsx)(Oe,{label:"Pane ID",value:e.shellPaneId||"",onChange:s=>o("shellPaneId",s),placeholder:"pane-main"}),(0,vn.jsx)(Oe,{label:"Tab ID",value:e.shellTabId||"",onChange:s=>o("shellTabId",s),placeholder:"settings-tab"})]})}});var Jd,pg,ro,Zy,Qy,ev,dP=U(()=>{"use strict";Jd=require("lucide-react");ks();pg=require("@decido/engine");ot();ro=require("react/jsx-runtime"),Zy=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,pg.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,ro.jsx)($t,{id:t,label:"Set Theme",icon:(0,ro.jsx)(Jd.Palette,{size:14}),accentColor:"amber",isExecuting:e.isExecuting,children:(0,ro.jsx)(Oe,{label:"Tema",value:e.shellTheme||"dark",onChange:s=>o("shellTheme",s),type:"select",options:[{value:"dark",label:"\u{1F319} Dark"},{value:"light",label:"\u2600\uFE0F Light"}]})})},Qy=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,pg.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,ro.jsxs)($t,{id:t,label:"Apply Palette",icon:(0,ro.jsx)(Jd.Paintbrush,{size:14}),accentColor:"pink",isExecuting:e.isExecuting,children:[(0,ro.jsx)(Oe,{label:"Primary",value:e.shellPrimary||"",onChange:s=>o("shellPrimary",s),placeholder:"#6366f1"}),(0,ro.jsx)(Oe,{label:"Secondary",value:e.shellSecondary||"",onChange:s=>o("shellSecondary",s),placeholder:"#8b5cf6"}),(0,ro.jsx)(Oe,{label:"Accent",value:e.shellAccent||"",onChange:s=>o("shellAccent",s),placeholder:"#f59e0b"}),(0,ro.jsx)(Oe,{label:"BG Main",value:e.shellBgMain||"",onChange:s=>o("shellBgMain",s),placeholder:"#070720"}),(0,ro.jsx)(Oe,{label:"BG Content",value:e.shellBgContent||"",onChange:s=>o("shellBgContent",s),placeholder:"#0F0F23"})]})},ev=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,pg.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,ro.jsxs)($t,{id:t,label:"CSS Token",icon:(0,ro.jsx)(Jd.Pipette,{size:14}),accentColor:"orange",isExecuting:e.isExecuting,children:[(0,ro.jsx)(Oe,{label:"Token",value:e.shellToken||"",onChange:s=>o("shellToken",s),placeholder:"--color-primary"}),(0,ro.jsx)(Oe,{label:"Valor",value:e.shellTokenValue||"",onChange:s=>o("shellTokenValue",s),placeholder:"#6366f1"})]})}});var Oi,Zd,Rr,tv,rv,nv,ov,sv,uP=U(()=>{"use strict";Oi=require("lucide-react");ks();Zd=require("@decido/engine");ot();Rr=require("react/jsx-runtime"),tv=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,Zd.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,Rr.jsxs)($t,{id:t,label:"Notification",icon:(0,Rr.jsx)(Oi.Bell,{size:14}),accentColor:"emerald",isExecuting:e.isExecuting,children:[(0,Rr.jsx)(Oe,{label:"Tipo",value:e.shellNotifType||"info",onChange:s=>o("shellNotifType",s),type:"select",options:[{value:"info",label:"\u2139\uFE0F Info"},{value:"success",label:"\u2705 Success"},{value:"warning",label:"\u26A0\uFE0F Warning"},{value:"error",label:"\u274C Error"}]}),(0,Rr.jsx)(Oe,{label:"T\xEDtulo",value:e.shellNotifTitle||"",onChange:s=>o("shellNotifTitle",s),placeholder:"Operaci\xF3n exitosa"}),(0,Rr.jsx)(Oe,{label:"Mensaje",value:e.shellNotifMessage||"",onChange:s=>o("shellNotifMessage",s),placeholder:"Los cambios se guardaron"})]})},rv=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,Zd.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,Rr.jsxs)($t,{id:t,label:"Show Modal",icon:(0,Rr.jsx)(Oi.SquareStack,{size:14}),accentColor:"violet",isExecuting:e.isExecuting,children:[(0,Rr.jsx)(Oe,{label:"T\xEDtulo",value:e.shellModalTitle||"",onChange:s=>o("shellModalTitle",s),placeholder:"Confirmaci\xF3n"}),(0,Rr.jsx)(Oe,{label:"Contenido HTML",value:e.shellModalContent||"",onChange:s=>o("shellModalContent",s),placeholder:"<p>\xBFEst\xE1s seguro?</p>"})]})},nv=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,Zd.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,Rr.jsxs)($t,{id:t,label:"Exec Command",icon:(0,Rr.jsx)(Oi.Play,{size:14}),accentColor:"teal",isExecuting:e.isExecuting,children:[(0,Rr.jsx)(Oe,{label:"Command ID",value:e.shellCommandId||"",onChange:s=>o("shellCommandId",s),placeholder:"palette.toggle"}),(0,Rr.jsx)(Oe,{label:"Argumento (JSON)",value:e.shellCommandArg||"",onChange:s=>o("shellCommandArg",s),placeholder:'{"key": "value"}'})]})},ov=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,Zd.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,Rr.jsxs)($t,{id:t,label:"Shortcut",icon:(0,Rr.jsx)(Oi.Keyboard,{size:14}),accentColor:"amber",isExecuting:e.isExecuting,children:[(0,Rr.jsx)(Oe,{label:"Keys",value:e.shellKeys||"",onChange:s=>o("shellKeys",s),placeholder:"Control+Shift+P"}),(0,Rr.jsx)(Oe,{label:"Command ID",value:e.shellCommandId||"",onChange:s=>o("shellCommandId",s),placeholder:"palette.toggle"}),(0,Rr.jsx)(Oe,{label:"Descripci\xF3n",value:e.shellShortcutDesc||"",onChange:s=>o("shellShortcutDesc",s),placeholder:"Abrir paleta"})]})},sv=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,Zd.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,Rr.jsxs)($t,{id:t,label:"Emit Event",icon:(0,Rr.jsx)(Oi.Radio,{size:14}),accentColor:"rose",isExecuting:e.isExecuting,children:[(0,Rr.jsx)(Oe,{label:"Evento",value:e.shellEventName||"",onChange:s=>o("shellEventName",s),placeholder:"app:customEvent"}),(0,Rr.jsx)(Oe,{label:"Data (JSON)",value:e.shellEventData||"",onChange:s=>o("shellEventData",s),placeholder:'{"msg": "hello"}'})]})}});var iv,fP,No,av,pP=U(()=>{"use strict";iv=require("lucide-react");ks();fP=require("@decido/engine");ot();No=require("react/jsx-runtime"),av=({id:t,data:e})=>{let r=X(s=>s.prototypeBrand),n=(0,fP.useTimelineStore)(s=>s.updateKeyframe),o=(s,i)=>n(r,t,{[s]:i});return(0,No.jsxs)($t,{id:t,label:"Shell Config",icon:(0,No.jsx)(iv.Settings2,{size:14}),accentColor:"teal",isExecuting:e.isExecuting,children:[(0,No.jsx)(Oe,{label:"Tema",value:e.shellTheme||"",onChange:s=>o("shellTheme",s),type:"select",options:[{value:"",label:"\u2014 Sin cambio \u2014"},{value:"dark",label:"\u{1F319} Dark"},{value:"light",label:"\u2600\uFE0F Light"}]}),(0,No.jsx)(Oe,{label:"Primary",value:e.shellPrimary||"",onChange:s=>o("shellPrimary",s),placeholder:"#6366f1"}),(0,No.jsx)(Oe,{label:"Accent",value:e.shellAccent||"",onChange:s=>o("shellAccent",s),placeholder:"#f59e0b"}),(0,No.jsx)(Oe,{label:"Sidebar",value:e.shellSidebarState||"",onChange:s=>o("shellSidebarState",s),type:"select",options:[{value:"",label:"\u2014 Sin cambio \u2014"},{value:"true",label:"\u{1F441} Visible"},{value:"false",label:"\u{1F6AB} Oculto"}]}),(0,No.jsx)(Oe,{label:"Panel",value:e.shellPanelState||"",onChange:s=>o("shellPanelState",s),type:"select",options:[{value:"",label:"\u2014 Sin cambio \u2014"},{value:"true",label:"\u{1F441} Visible"},{value:"false",label:"\u{1F6AB} Oculto"}]}),(0,No.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,No.jsx)("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Config Extra (JSON)"}),(0,No.jsx)("textarea",{value:e.shellConfigJson||"",onChange:s=>o("shellConfigJson",s.target.value),className:"bg-surface-tertiary/50 border border-border-subtle rounded-lg px-2 py-1.5 text-xs text-text-primary w-full focus:outline-hidden focus:border-teal-500/50 transition-colors font-mono resize-y min-h-[40px]",placeholder:'{"shortcuts": [{"id": "s1", "keys": "Ctrl+K", "commandId": "palette.toggle"}]}',rows:2})]}),(0,No.jsxs)("div",{className:"flex items-center gap-2 pt-1 border-t border-border-subtle",children:[(0,No.jsx)(iv.Settings2,{size:12,className:"text-teal-400"}),(0,No.jsx)("span",{className:"text-[10px] font-mono text-teal-400",children:"Full Shell Configuration"})]})]})}});var hP=U(()=>{"use strict";WM();KM();XM();QM();rP();sP();lP();cP();dP();uP();pP()});function xP(t){let e={...t.payload},r=t.type;return r==="core:subflow"&&(e.label=t.payload.label),(r==="ui:render"||r==="render")&&(e.label=t.payload.label||t.payload.state||"UI Component",e.state=t.payload.state||t.payload.label||"UI Component",e.uiSchema=t.payload.uiSchema||t.payload.schema),r==="event:trigger"&&Object.assign(e,{triggerType:t.payload.triggerType||"SYSTEM_START",cronExpression:t.payload.cronExpression,webhookPath:t.payload.webhookPath,eventChannel:t.payload.eventChannel,guardExpression:t.payload.guardExpression,priority:t.payload.priority}),r==="logic:condition"&&(e.conditionExpression=t.payload.conditionExpression||""),(r==="morph"||r==="ui:morph")&&Object.assign(e,{morphType:t.payload.morphType||"workbench",morphData:t.payload.morphData||null,componentId:t.payload.componentId||"",suspendOnMorph:t.payload.suspendOnMorph||!1}),r.startsWith("shell:")&&Object.keys(t.payload).forEach(n=>{n.startsWith("shell")&&(e[n]=t.payload[n])}),e}function lv(t,e,r,n){let o={t:Date.now(),track:t,position:r,label:e,state:e};return t==="dialogue"?(o.speech="Nuevo di\xE1logo...",o.actorId="assistant"):t==="render"&&n?.uiSchema?(o.uiSchema=n.uiSchema,o.autoComplete=!1):t==="subflow"?o.targetBlueprintId="":t==="morph"?o.morphType="workbench":t==="set"?(o.target="",o.value=""):t==="condition"&&(o.conditionExpression="true"),t.startsWith("shell:")&&(o.track="shell",o.shellAction=n?.shellAction||t.replace("shell:","")),o}var qt,mP,gP,bP,yP=U(()=>{"use strict";qt=require("@decido/canvas-core");hP();mP={dialogue:qt.DialogueNode,"ai:dialogue":qt.DialogueNode,logic:qt.LogicNode,"mcp:execute":qt.LogicNode,ui:qt.StateNode,"ui:state":qt.StateNode,"core:subflow":qt.SubflowNode,"core:entry":qt.EntryNode,"core:return":qt.ReturnNode,"ui:render":qt.RenderNode,render:qt.RenderNode,trigger:qt.TriggerNode,"event:trigger":qt.TriggerNode,condition:qt.ConditionalNode,"logic:condition":qt.ConditionalNode,set:qt.SetVariableNode,"state:set":qt.SetVariableNode,morph:qt.MorphNode,"ui:morph":qt.MorphNode,"shell:registerButton":Fy,"shell:registerTab":Hy,"shell:registerPanel":Vy,"shell:registerSidebar":jy,"shell:registerStatusBar":Wy,"shell:registerTopBar":Uy,"shell:registerAction":Gy,"shell:toggleSidebar":Ky,"shell:togglePanel":qy,"shell:splitPane":Yy,"shell:focusTab":Xy,"shell:closeTab":Jy,"shell:setTheme":Zy,"shell:applyPalette":Qy,"shell:updateToken":ev,"shell:notification":tv,"shell:modal":rv,"shell:execCommand":nv,"shell:shortcut":ov,"shell:emitEvent":sv,"shell:config":av},gP={"ai:dialogue":100,"ui:state":450,"mcp:execute":800,"core:subflow":1100,"core:entry":300,"core:return":300,"ui:render":1400,render:1400,"event:trigger":-200,"logic:condition":600,"state:set":1e3,set:1e3,morph:1400,"ui:morph":1400,"shell:registerButton":1700,"shell:registerTab":1700,"shell:registerPanel":1700,"shell:registerSidebar":1700,"shell:registerStatusBar":1700,"shell:registerTopBar":1700,"shell:registerAction":1700,"shell:toggleSidebar":2e3,"shell:togglePanel":2e3,"shell:splitPane":2e3,"shell:focusTab":2e3,"shell:closeTab":2e3,"shell:setTheme":2300,"shell:applyPalette":2300,"shell:updateToken":2300,"shell:notification":2600,"shell:modal":2600,"shell:execCommand":2600,"shell:shortcut":2600,"shell:emitEvent":2600,"shell:config":2900},bP={dialogue:"dialogue","ai:dialogue":"dialogue",logic:"logic","mcp:execute":"logic",ui:"ui","ui:state":"ui","core:subflow":"subflow","core:entry":"entry","core:return":"return","ui:render":"render",render:"render",trigger:"trigger","event:trigger":"trigger",condition:"condition","logic:condition":"condition",set:"set","state:set":"set"}});function vP(t,e,r){return t.map(n=>{let o=n.sourceHandle||"success",s=HV.has(o)?o:"success",i=VV[s]||"#a855f7",a=e.includes(n.source),l=r.includes(n.id),c=l?"#22d3ee":i,d=l?`drop-shadow(0 0 10px ${c})`:a?"drop-shadow(0 0 5px rgba(255,255,255,0.8))":"none";return{id:n.id,source:n.source,target:n.target,sourceHandle:s,targetHandle:n.targetHandle,animated:a||l,style:{stroke:c,strokeWidth:l?5:a?4:3,filter:d},markerEnd:{type:pn.ArrowClosed,color:c}}})}var HV,VV,wP=U(()=>{"use strict";Ri();HV=new Set(["success","error","true","false","fallback","cancel"]),VV={success:"#22c55e",error:"#ef4444",true:"#22c55e",false:"#ef4444",fallback:"#f97316",cancel:"#a855f7"}});var gt,rt,jV,SP,NP=U(()=>{"use strict";gt=require("lucide-react");xi();rt=require("react/jsx-runtime"),jV=[{section:"Di\xE1logo"},{track:"dialogue",label:"Dialogue Node",icon:(0,rt.jsx)(gt.MessageCircle,{size:14,className:"text-blue-400"}),color:"hover:bg-blue-500/10"},{section:"L\xF3gica"},{track:"logic",label:"Logic Gate",icon:(0,rt.jsx)(gt.Cpu,{size:14,className:"text-amber-400"}),color:"hover:bg-amber-500/10"},{section:"Estado UI"},{track:"ui",label:"State Change",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-purple-400"}),color:"hover:bg-purple-500/10"},{section:"HSM / Subflujos"},{track:"subflow",label:"Subflow",icon:(0,rt.jsx)(gt.Network,{size:14,className:"text-violet-400"}),color:"hover:bg-violet-500/10"},{track:"entry",label:"Entry",icon:(0,rt.jsx)(gt.LogIn,{size:14,className:"text-emerald-400"}),color:"hover:bg-emerald-500/10"},{track:"return",label:"Return",icon:(0,rt.jsx)(gt.LogOut,{size:14,className:"text-rose-400"}),color:"hover:bg-rose-500/10"},{section:"Triggers / Branching"},{track:"trigger",label:"Event Trigger",icon:(0,rt.jsx)(gt.Zap,{size:14,className:"text-yellow-400"}),color:"hover:bg-yellow-500/10"},{track:"condition",label:"Condici\xF3n",icon:(0,rt.jsx)(gt.GitBranch,{size:14,className:"text-amber-400"}),color:"hover:bg-amber-500/10"},{track:"set",label:"Set Variable",icon:(0,rt.jsx)(gt.Layout,{size:14,className:"text-violet-400"}),color:"hover:bg-violet-500/10"},{section:"Morfolog\xEDa"},{track:"morph",label:"Morph Stage",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-purple-400"}),color:"hover:bg-purple-500/10"},{section:"\u{1F5A5}\uFE0F Shell: Registro"},{track:"shell:registerButton",label:"Activity Bar",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-teal-400"}),color:"hover:bg-teal-500/10",extra:{shellAction:"registerActivityBarItem"}},{track:"shell:registerTab",label:"Open Tab",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-cyan-400"}),color:"hover:bg-cyan-500/10",extra:{shellAction:"openTab"}},{track:"shell:registerPanel",label:"Panel View",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-indigo-400"}),color:"hover:bg-indigo-500/10",extra:{shellAction:"registerPanelView"}},{track:"shell:registerSidebar",label:"Sidebar View",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-sky-400"}),color:"hover:bg-sky-500/10",extra:{shellAction:"registerSidebarView"}},{track:"shell:registerStatusBar",label:"Status Bar",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-emerald-400"}),color:"hover:bg-emerald-500/10",extra:{shellAction:"registerStatusBarItem"}},{track:"shell:registerTopBar",label:"Top Bar",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-violet-400"}),color:"hover:bg-violet-500/10",extra:{shellAction:"registerTopBarItem"}},{track:"shell:registerAction",label:"Register Cmd",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-amber-400"}),color:"hover:bg-amber-500/10",extra:{shellAction:"registerCommand"}},{section:"\u{1F5A5}\uFE0F Shell: Layout"},{track:"shell:toggleSidebar",label:"Toggle Sidebar",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-sky-400"}),color:"hover:bg-sky-500/10",extra:{shellAction:"toggleSidebar"}},{track:"shell:togglePanel",label:"Toggle Panel",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-indigo-400"}),color:"hover:bg-indigo-500/10",extra:{shellAction:"togglePanel"}},{track:"shell:splitPane",label:"Split Pane",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-violet-400"}),color:"hover:bg-violet-500/10",extra:{shellAction:"splitPane"}},{track:"shell:focusTab",label:"Focus Tab",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-cyan-400"}),color:"hover:bg-cyan-500/10",extra:{shellAction:"focusTab"}},{track:"shell:closeTab",label:"Close Tab",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-rose-400"}),color:"hover:bg-rose-500/10",extra:{shellAction:"closeTab"}},{section:"\u{1F5A5}\uFE0F Shell: Tema"},{track:"shell:setTheme",label:"Set Theme",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-amber-400"}),color:"hover:bg-amber-500/10",extra:{shellAction:"setTheme"}},{track:"shell:applyPalette",label:"Apply Palette",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-pink-400"}),color:"hover:bg-pink-500/10",extra:{shellAction:"applyPalette"}},{track:"shell:updateToken",label:"CSS Token",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-orange-400"}),color:"hover:bg-orange-500/10",extra:{shellAction:"updateToken"}},{section:"\u{1F5A5}\uFE0F Shell: Interacci\xF3n"},{track:"shell:notification",label:"Notification",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-emerald-400"}),color:"hover:bg-emerald-500/10",extra:{shellAction:"showNotification"}},{track:"shell:modal",label:"Show Modal",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-violet-400"}),color:"hover:bg-violet-500/10",extra:{shellAction:"showModal"}},{track:"shell:execCommand",label:"Exec Command",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-teal-400"}),color:"hover:bg-teal-500/10",extra:{shellAction:"executeCommand"}},{track:"shell:shortcut",label:"Shortcut",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-amber-400"}),color:"hover:bg-amber-500/10",extra:{shellAction:"registerShortcut"}},{track:"shell:emitEvent",label:"Emit Event",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-rose-400"}),color:"hover:bg-rose-500/10",extra:{shellAction:"emitEvent"}},{section:"\u{1F5A5}\uFE0F Shell: Config"},{track:"shell:config",label:"Shell Config",icon:(0,rt.jsx)(gt.Monitor,{size:14,className:"text-teal-400"}),color:"hover:bg-teal-500/10",extra:{shellAction:"shellConfig"}}],SP=({x:t,y:e,onAdd:r,onClose:n})=>{let o=Mn(a=>a.components),s=Object.values(o),i={position:"fixed",left:Math.min(t,window.innerWidth-240),top:Math.min(e,window.innerHeight-600),zIndex:999};return(0,rt.jsxs)("div",{style:i,className:"w-56 bg-surface-secondary/95 backdrop-blur-xl border border-border-default rounded-xl shadow-2xl shadow-black/50 overflow-hidden",children:[(0,rt.jsx)("div",{className:"px-3 py-2 border-b border-border-subtle",children:(0,rt.jsx)("span",{className:"text-[10px] font-bold text-text-muted uppercase tracking-widest",children:"\u2795 Agregar Nodo"})}),(0,rt.jsxs)("div",{className:"max-h-[480px] overflow-y-auto py-1",children:[jV.map((a,l)=>a.section?(0,rt.jsx)("div",{className:"px-3 pt-2 pb-1 text-[9px] font-bold text-text-muted uppercase tracking-widest",children:a.section},`s-${l}`):(0,rt.jsxs)("button",{onClick:()=>r(a.track,a.label,a.extra),className:`w-full flex items-center gap-2.5 px-3 py-1.5 text-xs text-text-primary hover:text-text-primary transition-colors ${a.color}`,children:[a.icon,(0,rt.jsx)("span",{children:a.label})]},`i-${l}`)),s.length>0&&(0,rt.jsxs)(rt.Fragment,{children:[(0,rt.jsx)("div",{className:"px-3 pt-2 pb-1 text-[9px] font-bold text-text-muted uppercase tracking-widest",children:"UI Components"}),s.map(a=>(0,rt.jsxs)("button",{onClick:()=>r("render",a.name,{uiSchema:a.schema}),className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-xs text-text-primary hover:text-text-primary hover:bg-pink-500/10 transition-colors",children:[(0,rt.jsx)(gt.Layout,{size:14,className:a.source==="ai-generated"?"text-pink-400":"text-cyan-400"}),(0,rt.jsx)("span",{children:a.name}),(0,rt.jsx)("span",{className:"ml-auto text-[9px] text-text-muted",children:a.source==="ai-generated"?"AI":"built-in"})]},a.id))]})]})]})}});var CP,Es,nn,kP,EP=U(()=>{"use strict";CP=Re(require("react")),Es=require("lucide-react");$y();nn=require("react/jsx-runtime"),kP=CP.default.memo(function({canUndo:e,canRedo:r,undoCount:n,redoCount:o,undo:s,redo:i,nodes:a,edges:l,setNodes:c,updateKeyframePosition:d,removeKeyframe:u,activeTimelineId:f,currentBlueprintId:p,fitView:h,setSelectedNodeId:b}){return(0,nn.jsxs)("div",{className:"absolute top-3 right-3 z-20 flex items-center gap-1 bg-surface-secondary/90 backdrop-blur-xs border border-border-default rounded-lg p-1",children:[(0,nn.jsxs)("button",{onClick:s,disabled:!e,className:"flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors disabled:opacity-30 disabled:cursor-not-allowed hover:bg-surface-glass text-text-primary",title:"Deshacer (\u2318Z)",children:[(0,nn.jsx)(Es.Undo2,{size:14}),e&&(0,nn.jsx)("span",{className:"text-[9px] text-emerald-400 font-mono",children:n})]}),(0,nn.jsx)("div",{className:"w-px h-4 bg-surface-glass"}),(0,nn.jsxs)("button",{onClick:i,disabled:!r,className:"flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors disabled:opacity-30 disabled:cursor-not-allowed hover:bg-surface-glass text-text-primary",title:"Rehacer (\u2318\u21E7Z)",children:[(0,nn.jsx)(Es.Redo2,{size:14}),r&&(0,nn.jsx)("span",{className:"text-[9px] text-blue-400 font-mono",children:o})]}),(0,nn.jsx)("div",{className:"w-px h-4 bg-surface-glass"}),(0,nn.jsx)("button",{onClick:()=>{let{nodes:v}=fg(a,l,{direction:"TB"});c(v),v.forEach(S=>d(f,S.id,S.position)),setTimeout(()=>h({padding:.2,duration:600}),50)},className:"flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors hover:bg-surface-glass text-text-primary",title:"Organizar Nodos (Dagre Layout)",children:(0,nn.jsx)(Es.LayoutGrid,{size:14})}),(0,nn.jsx)("div",{className:"w-px h-4 bg-surface-glass"}),(0,nn.jsx)("button",{onClick:()=>{let v=a.filter(w=>w.selected);if(v.length<2)return;let S=v.reduce((w,C)=>w+C.position.y,0)/v.length;c(w=>w.map(C=>C.selected?{...C,position:{...C.position,y:S}}:C)),v.forEach(w=>d(f,w.id,{...w.position,y:S}))},className:"flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors hover:bg-surface-glass text-text-primary",title:"Alinear Horizontalmente",children:(0,nn.jsx)(Es.AlignHorizontalDistributeCenter,{size:14})}),(0,nn.jsx)("button",{onClick:()=>{let v=a.filter(w=>w.selected);if(v.length<2)return;let S=v.reduce((w,C)=>w+C.position.x,0)/v.length;c(w=>w.map(C=>C.selected?{...C,position:{...C.position,x:S}}:C)),v.forEach(w=>d(f,w.id,{...w.position,x:S}))},className:"flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors hover:bg-surface-glass text-text-primary",title:"Alinear Verticalmente",children:(0,nn.jsx)(Es.AlignVerticalDistributeCenter,{size:14})}),(0,nn.jsx)("div",{className:"w-px h-4 bg-surface-glass"}),(0,nn.jsx)("button",{onClick:()=>{let v=a.filter(w=>w.selected);if(v.length===0)return;let S=p||f;v.forEach(w=>u(S,w.id)),b(null)},className:"flex items-center gap-1 px-2 py-1.5 rounded-md text-xs transition-colors hover:bg-red-500/20 text-red-400",title:"Eliminar Seleccionados",children:(0,nn.jsx)(Es.Trash2,{size:14})})]})})});function TP(t){return e=>{let r=e.metaKey||e.ctrlKey,n=e.target;if(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.tagName==="SELECT")return;let o=t.getNodes(),s=t.getEdges(),i=t.currentBlueprintId||t.activeTimelineId;if(r&&e.key==="a"&&(e.preventDefault(),t.setNodes(a=>a.map(l=>({...l,selected:!0}))),t.setEdges(a=>a.map(l=>({...l,selected:!0})))),r&&e.key==="c"){let a=o.filter(c=>c.selected);if(!a.length)return;let l=new Set(a.map(c=>c.id));t.clipboard.current={nodes:a,edges:s.filter(c=>l.has(c.source)&&l.has(c.target))}}if(r&&e.key==="v"){let{nodes:a,edges:l}=t.clipboard.current;if(!a.length)return;e.preventDefault();let c={};t.setNodes(d=>d.map(u=>({...u,selected:!1}))),a.forEach(d=>{let u=`${d.id}_copy_${Date.now()}_${Math.random().toString(36).substring(7)}`;c[d.id]=u,t.addKeyframe(i,{id:u,t:Date.now(),track:t.NODE_TYPE_TO_TRACK[d.type||""]||d.type||"dialogue",label:`${d.data.label||d.data.state||"Copy"} (copia)`,state:`${d.data.state||d.data.label||"Copy"} (copia)`,position:{x:d.position.x+50,y:d.position.y+50},speech:d.data.speech,actorId:d.data.actorId,intent:d.data.intent,uiSchema:d.data.uiSchema||d.data.schema,autoComplete:d.data.autoComplete,triggerType:d.data.triggerType,guardExpression:d.data.guardExpression,priority:d.data.priority,conditionExpression:d.data.conditionExpression,variableTarget:d.data.variableTarget,variableValue:d.data.variableValue,targetBlueprintId:d.data.targetBlueprintId,handle:d.data.handle})}),l.forEach(d=>{let u=c[d.source],f=c[d.target];u&&f&&t.addTimelineEdge(i,{id:`edge-${u}-${f}-${Date.now()}`,source:u,target:f,sourceHandle:d.sourceHandle||null,targetHandle:d.targetHandle||null})})}if(e.key==="Delete"||e.key==="Backspace"){let a=o.filter(c=>c.selected),l=s.filter(c=>c.selected);if(!a.length&&!l.length)return;e.preventDefault(),a.forEach(c=>t.removeKeyframe(i,c.id)),l.forEach(c=>t.removeTimelineEdge(i,c.id)),t.setSelectedNodeId(null)}}}var IP=U(()=>{"use strict"});function AP(t){return WV[t]||{icon:Ts.Zap,label:t,color:"text-orange-400",bg:"bg-orange-500/10",border:"border-orange-500/20"}}var Ts,De,WV,MP,PP,RP,DP,OP,_P,LP=U(()=>{"use strict";Ts=require("lucide-react"),De=require("react/jsx-runtime"),WV={dialogue:{icon:Ts.Mic2,label:"Di\xE1logo",color:"text-purple-400",bg:"bg-purple-500/10",border:"border-purple-500/20"},ui:{icon:Ts.Monitor,label:"Estado UI",color:"text-cyan-400",bg:"bg-cyan-500/10",border:"border-cyan-500/20"},logic:{icon:Ts.Zap,label:"L\xF3gica MCP",color:"text-orange-400",bg:"bg-orange-500/10",border:"border-orange-500/20"},render:{icon:Ts.Image,label:"UI Render",color:"text-pink-400",bg:"bg-pink-500/10",border:"border-pink-500/20"},trigger:{icon:Ts.Zap,label:"Trigger",color:"text-yellow-400",bg:"bg-yellow-500/10",border:"border-yellow-500/20"},set:{icon:Ts.PenSquare,label:"Set Variable",color:"text-violet-400",bg:"bg-violet-500/10",border:"border-violet-500/20"}};MP=({keyframe:t,onUpdate:e})=>(0,De.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,De.jsx)("h4",{className:"text-[10px] font-bold text-purple-400/40 uppercase tracking-widest border-b border-purple-500/20 pb-1",children:"Configuraci\xF3n Di\xE1logo"}),(0,De.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,De.jsx)("label",{className:"text-[10px] text-text-muted",children:"Actor ID"}),(0,De.jsxs)("select",{value:t.actorId||"system",onChange:r=>e({actorId:r.target.value}),className:"bg-surface-overlay border border-border-default rounded px-2 py-1.5 text-xs text-purple-300 focus:outline-hidden focus:border-purple-500/50",children:[(0,De.jsx)("option",{value:"system",children:"\u{1F680} System"}),(0,De.jsx)("option",{value:"user",children:"\u{1F464} User"}),(0,De.jsx)("option",{value:"client",children:"\u{1F4BC} Client"}),(0,De.jsx)("option",{value:"inventory_agent",children:"\u{1F4E6} Inventory Agent"})]})]}),(0,De.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,De.jsxs)("label",{className:"text-[10px] text-text-muted flex justify-between",children:[(0,De.jsx)("span",{children:"Texto (TTS)"}),(0,De.jsxs)("span",{className:"text-purple-400/50",children:[t.speech?.length||0," chars"]})]}),(0,De.jsx)("textarea",{value:t.speech||"",onChange:r=>e({speech:r.target.value}),className:"bg-surface-overlay border border-border-default rounded px-2 py-2 text-xs text-text-primary focus:outline-hidden focus:border-purple-500/50 min-h-[120px] resize-y",placeholder:"Escribe el di\xE1logo aqu\xED..."})]})]}),PP=({keyframe:t,onUpdate:e})=>(0,De.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,De.jsx)("h4",{className:"text-[10px] font-bold text-cyan-400/40 uppercase tracking-widest border-b border-cyan-500/20 pb-1",children:"Eventos Interfaz"}),(0,De.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,De.jsx)("label",{className:"text-[10px] text-text-muted",children:"App State Trigger"}),(0,De.jsx)("input",{type:"text",value:t.state||"",onChange:r=>e({state:r.target.value}),className:"bg-surface-overlay border border-border-default rounded px-2 py-1.5 text-xs text-cyan-300 font-mono focus:outline-hidden focus:border-cyan-500/50",placeholder:"e.g., loading_screen"})]}),(0,De.jsx)("div",{className:"mt-1 bg-surface-glass rounded-lg border border-border-default p-3",children:(0,De.jsxs)("label",{className:"flex items-start gap-3 cursor-pointer",children:[(0,De.jsx)("input",{type:"checkbox",checked:t.canvas||!1,onChange:r=>e({canvas:r.target.checked}),className:"mt-0.5 rounded border-border-strong bg-surface-glass text-cyan-500 w-4 h-4 cursor-pointer"}),(0,De.jsxs)("div",{className:"flex flex-col",children:[(0,De.jsx)("span",{className:"text-xs font-bold text-cyan-300",children:"Embeber Lienzo 3D"}),(0,De.jsx)("span",{className:"text-[10px] text-text-muted mt-1",children:"Al pasar por este nodo, mostrar\xE1 el motor SpatialCanvas3D."})]})]})})]}),RP=({keyframe:t,onUpdate:e})=>(0,De.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,De.jsx)("h4",{className:"text-[10px] font-bold text-pink-400/40 uppercase tracking-widest border-b border-pink-500/20 pb-1",children:"UI Component"}),(0,De.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,De.jsx)("label",{className:"text-[10px] text-text-muted",children:"Nombre"}),(0,De.jsx)("input",{type:"text",value:t.label||t.state||"",onChange:r=>e({label:r.target.value,state:r.target.value}),className:"bg-surface-overlay border border-border-default rounded px-2 py-1.5 text-xs text-pink-300 font-mono focus:outline-hidden focus:border-pink-500/50",placeholder:"e.g., Formulario Contacto"})]}),(0,De.jsx)("div",{className:"bg-surface-glass rounded-lg border border-border-default p-3",children:(0,De.jsxs)("label",{className:"flex items-start gap-3 cursor-pointer",children:[(0,De.jsx)("input",{type:"checkbox",checked:t.autoComplete??!0,onChange:r=>e({autoComplete:r.target.checked}),className:"mt-0.5 rounded border-border-strong bg-surface-glass text-pink-500 w-4 h-4 cursor-pointer"}),(0,De.jsxs)("div",{className:"flex flex-col",children:[(0,De.jsx)("span",{className:"text-xs font-bold text-pink-300",children:"Auto-Complete"}),(0,De.jsx)("span",{className:"text-[10px] text-text-muted mt-1",children:"Si activo, el nodo se completa al mostrarse. Si no, espera interacci\xF3n."})]})]})}),(0,De.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,De.jsx)("label",{className:"text-[10px] text-text-muted",children:"UI Schema (JSON)"}),(0,De.jsx)("textarea",{value:typeof t.uiSchema=="object"?JSON.stringify(t.uiSchema,null,2):t.uiSchema||"",onChange:r=>{try{e({uiSchema:JSON.parse(r.target.value)})}catch{}},className:"bg-surface-overlay border border-border-default rounded px-2 py-2 text-[10px] text-pink-200 font-mono focus:outline-hidden focus:border-pink-500/50 min-h-[80px] resize-y",placeholder:'{"type":"div","children":...}'})]})]}),DP=({keyframe:t,onUpdate:e})=>(0,De.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,De.jsx)("h4",{className:"text-[10px] font-bold text-orange-400/40 uppercase tracking-widest border-b border-orange-500/20 pb-1",children:"Motor de L\xF3gica"}),(0,De.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,De.jsx)("label",{className:"text-[10px] text-text-muted",children:"T\xF3pico / Intenci\xF3n"}),(0,De.jsx)("input",{type:"text",value:t.intent||"",onChange:r=>e({intent:r.target.value}),className:"bg-surface-overlay border border-border-default rounded px-2 py-1.5 text-xs text-orange-300 font-mono focus:outline-hidden focus:border-orange-500/50",placeholder:"e.g., process_payment"})]}),(0,De.jsx)("div",{className:"p-3 bg-orange-500/10 border border-orange-500/20 rounded",children:(0,De.jsx)("p",{className:"text-[10px] text-orange-300/80 leading-relaxed",children:"Este nodo disparar\xE1 eventos hacia el Event Mesh para orquestar servicios remotos."})})]}),OP=({keyframe:t,onUpdate:e})=>(0,De.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,De.jsx)("h4",{className:"text-[10px] font-bold text-yellow-400/40 uppercase tracking-widest border-b border-yellow-500/20 pb-1",children:"Activaci\xF3n Autom\xE1tica"}),(0,De.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,De.jsx)("label",{className:"text-[10px] text-text-muted",children:"Guard Expression"}),(0,De.jsx)("input",{type:"text",value:t.guardExpression||"",onChange:r=>e({guardExpression:r.target.value}),className:"bg-surface-overlay border border-border-default rounded px-2 py-1.5 text-xs text-yellow-300 font-mono focus:outline-hidden focus:border-yellow-500/50",placeholder:"!user.onboardingComplete"}),(0,De.jsx)("span",{className:"text-[9px] text-text-muted",children:"Si true, el flujo se auto-activa al cargar la app."})]}),(0,De.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,De.jsx)("label",{className:"text-[10px] text-text-muted",children:"Prioridad"}),(0,De.jsx)("input",{type:"number",value:t.priority||0,onChange:r=>e({priority:parseInt(r.target.value)||0}),className:"bg-surface-overlay border border-border-default rounded px-2 py-1.5 text-xs text-yellow-300 font-mono focus:outline-hidden focus:border-yellow-500/50 w-20",placeholder:"0"}),(0,De.jsx)("span",{className:"text-[9px] text-text-muted",children:"Mayor = se eval\xFAa primero."})]})]}),_P=({keyframe:t,onUpdate:e})=>(0,De.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,De.jsx)("h4",{className:"text-[10px] font-bold text-violet-400/40 uppercase tracking-widest border-b border-violet-500/20 pb-1",children:"Escritura de Variable"}),(0,De.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,De.jsx)("label",{className:"text-[10px] text-text-muted",children:"Variable Target"}),(0,De.jsx)("input",{type:"text",value:t.variableTarget||"",onChange:r=>e({variableTarget:r.target.value}),className:"bg-surface-overlay border border-border-default rounded px-2 py-1.5 text-xs text-violet-300 font-mono focus:outline-hidden focus:border-violet-500/50",placeholder:"e.g., user.onboardingComplete"}),(0,De.jsx)("span",{className:"text-[9px] text-text-muted",children:'Prefijo "user." = persistente. Sin prefijo = sesi\xF3n.'})]}),(0,De.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,De.jsx)("label",{className:"text-[10px] text-text-muted",children:"Valor"}),(0,De.jsx)("input",{type:"text",value:t.variableValue??"",onChange:r=>e({variableValue:r.target.value}),className:"bg-surface-overlay border border-border-default rounded px-2 py-1.5 text-xs text-emerald-300 font-mono focus:outline-hidden focus:border-violet-500/50",placeholder:"e.g., true, 50, user.xp + 10"}),(0,De.jsx)("span",{className:"text-[9px] text-text-muted",children:"Puede ser literal o expresi\xF3n JS."})]})]})});var BP,hg,mg,Ff,vt,zP,$P=U(()=>{"use strict";BP=Re(require("react")),hg=require("lucide-react"),mg=require("motion/react");ot();Ff=require("@decido/engine");LP();vt=require("react/jsx-runtime"),zP=({selectedNodeId:t,onClose:e})=>{let r=X(f=>f.prototypeBrand),n=(0,Ff.useTimelineStore)(f=>f.timelines),o=(0,Ff.useTimelineStore)(f=>f.updateKeyframe),s=(0,Ff.useEngineStore)(f=>f.variables),i=n[r]?.keyframes.find(f=>f.id===t),a=i?.track||"",l=BP.default.useMemo(()=>{if(!i)return[];let p=((i.speech||"")+(i.state||"")).match(/\{\{([^}]+)\}\}/g)||[];return[...new Set(p.map(h=>h.replace(/\{\{|\}\}/g,"").trim()))]},[i?.speech,i?.state,i]);if(!i)return null;let c=AP(a),d=c.icon,u=f=>o(r,i.id,f);return(0,vt.jsx)(mg.AnimatePresence,{children:(0,vt.jsxs)(mg.motion.div,{initial:{x:300,opacity:0},animate:{x:0,opacity:1},exit:{x:300,opacity:0},transition:{type:"spring",bounce:0,duration:.3},className:"absolute right-0 top-0 bottom-0 w-[300px] bg-surface-primary border-l border-border-default z-50 shadow-2xl flex flex-col",children:[(0,vt.jsxs)("div",{className:`p-4 border-b border-border-default flex items-center justify-between ${c.bg}`,children:[(0,vt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,vt.jsx)(d,{size:16,className:c.color}),(0,vt.jsx)("h3",{className:`text-sm font-bold uppercase tracking-widest ${c.color}`,children:c.label})]}),(0,vt.jsx)("button",{onClick:e,className:"p-1 rounded-md hover:bg-surface-glass text-text-primary/50 hover:text-text-primary transition-colors",children:(0,vt.jsx)(hg.X,{size:16})})]}),(0,vt.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 custom-scrollbar flex flex-col gap-5",children:[(0,vt.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,vt.jsx)("h4",{className:"text-[10px] font-bold text-text-primary/40 uppercase tracking-widest border-b border-border-default pb-1",children:"Metadatos Base"}),(0,vt.jsxs)("div",{className:"grid grid-cols-2 gap-2 mt-1",children:[(0,vt.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,vt.jsx)("label",{className:"text-[10px] text-text-muted",children:"Node ID"}),(0,vt.jsx)("input",{type:"text",value:i.id,readOnly:!0,className:"bg-surface-overlay border border-border-subtle rounded px-2 py-1 text-xs text-text-secondary font-mono outline-hidden"})]}),(0,vt.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,vt.jsx)("label",{className:"text-[10px] text-text-muted",children:"Tiempo (t)"}),(0,vt.jsxs)("div",{className:"flex items-center border border-border-default rounded overflow-hidden",children:[(0,vt.jsx)("input",{type:"number",step:"0.1",value:i.t,onChange:f=>u({t:parseFloat(f.target.value)||0}),className:"bg-surface-glass px-2 py-1 text-xs text-text-primary outline-hidden w-full font-mono"}),(0,vt.jsx)("span",{className:"bg-surface-glass px-2 py-1 text-xs text-text-muted border-l border-border-default",children:"s"})]})]})]})]}),a==="dialogue"&&(0,vt.jsx)(MP,{keyframe:i,onUpdate:u}),a==="ui"&&(0,vt.jsx)(PP,{keyframe:i,onUpdate:u}),a==="render"&&(0,vt.jsx)(RP,{keyframe:i,onUpdate:u}),a==="logic"&&(0,vt.jsx)(DP,{keyframe:i,onUpdate:u}),a==="trigger"&&(0,vt.jsx)(OP,{keyframe:i,onUpdate:u}),a==="set"&&(0,vt.jsx)(_P,{keyframe:i,onUpdate:u}),(0,vt.jsxs)("div",{className:"flex flex-col gap-3 mt-2",children:[(0,vt.jsxs)("h4",{className:"text-[10px] font-bold text-emerald-400/40 uppercase tracking-widest border-b border-emerald-500/20 pb-1 flex items-center gap-1.5",children:[(0,vt.jsx)(hg.Variable,{size:10}),"Data Bindings"]}),l.length>0&&(0,vt.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,vt.jsx)("span",{className:"text-[9px] text-text-muted uppercase",children:"Variables Referenciadas"}),(0,vt.jsx)("div",{className:"flex flex-wrap gap-1",children:l.map(f=>(0,vt.jsxs)("span",{className:`text-[10px] font-mono px-1.5 py-0.5 rounded border ${s[f]!==void 0?"bg-emerald-500/10 border-emerald-500/20 text-emerald-400":"bg-red-500/10 border-red-500/20 text-red-400"}`,children:[`{{${f}}}`," ",s[f]!==void 0?`= ${s[f]}`:"\u26A0 undefined"]},f))})]}),(0,vt.jsxs)("div",{className:"p-2 bg-emerald-500/5 border border-emerald-500/10 rounded text-[10px] text-text-muted",children:["Usa ",(0,vt.jsx)("code",{className:"text-emerald-400 bg-surface-glass px-1 rounded",children:"{{variable}}"})," en el texto para interpolar valores del Motor."]})]})]})]})})}});var Ae,ut,FP,HP,VP=U(()=>{"use strict";Ae=require("lucide-react"),ut=require("react/jsx-runtime"),FP="application/decido-node",HP=[{id:"dialogue",label:"Di\xE1logo",icon:(0,ut.jsx)(Ae.MessageCircle,{size:14}),items:[{type:"dialogue",label:"Dialogue",icon:(0,ut.jsx)(Ae.MessageCircle,{size:16}),color:"border-blue-500/40",description:"Nodo de di\xE1logo AI"}]},{id:"logic",label:"L\xF3gica / MCP",icon:(0,ut.jsx)(Ae.Cpu,{size:14}),items:[{type:"logic",label:"Logic Gate",icon:(0,ut.jsx)(Ae.Cpu,{size:16}),color:"border-amber-500/40",description:"Evaluaci\xF3n condicional"}]},{id:"ui",label:"Estado UI",icon:(0,ut.jsx)(Ae.Monitor,{size:14}),items:[{type:"ui",label:"State Change",icon:(0,ut.jsx)(Ae.Monitor,{size:16}),color:"border-purple-500/40",description:"Cambio de estado visual"}]},{id:"hsm",label:"HSM / Subflujos",icon:(0,ut.jsx)(Ae.Network,{size:14}),items:[{type:"core:subflow",label:"Subflow",icon:(0,ut.jsx)(Ae.Network,{size:16}),color:"border-violet-500/40",description:"Subflujo jer\xE1rquico"},{type:"core:entry",label:"Entry",icon:(0,ut.jsx)(Ae.LogIn,{size:16}),color:"border-emerald-500/40",description:"Punto de entrada"},{type:"core:return",label:"Return",icon:(0,ut.jsx)(Ae.LogOut,{size:16}),color:"border-rose-500/40",description:"Punto de retorno"}]},{id:"triggers",label:"Triggers / Branching",icon:(0,ut.jsx)(Ae.Zap,{size:14}),items:[{type:"trigger",label:"Event Trigger",icon:(0,ut.jsx)(Ae.Zap,{size:16}),color:"border-yellow-500/40",description:"Disparador de evento"},{type:"condition",label:"Condici\xF3n",icon:(0,ut.jsx)(Ae.GitBranch,{size:16}),color:"border-amber-500/40",description:"Bifurcaci\xF3n condicional"},{type:"set",label:"Set Variable",icon:(0,ut.jsx)(Ae.PenSquare,{size:16}),color:"border-violet-500/40",description:"Escribir variable (UserState o sesi\xF3n)"}]},{id:"morphology",label:"Morfolog\xEDa",icon:(0,ut.jsx)(Ae.Layout,{size:14}),items:[{type:"morph",label:"Morph Stage",icon:(0,ut.jsx)(Ae.Monitor,{size:16}),color:"border-purple-500/40",description:"Controlar \xE1rea de renderizado"}]},{id:"shell-register",label:"\u{1F5A5}\uFE0F Shell: Registro",icon:(0,ut.jsx)(Ae.Terminal,{size:14}),items:[{type:"shell:registerButton",label:"Activity Bar",icon:(0,ut.jsx)(Ae.PanelLeft,{size:16}),color:"border-teal-500/40",description:"Registrar bot\xF3n en Activity Bar",meta:{shellAction:"registerActivityBarItem"}},{type:"shell:registerTab",label:"Open Tab",icon:(0,ut.jsx)(Ae.FileText,{size:16}),color:"border-cyan-500/40",description:"Abrir tab en el editor",meta:{shellAction:"openTab"}},{type:"shell:registerPanel",label:"Panel View",icon:(0,ut.jsx)(Ae.PanelBottom,{size:16}),color:"border-indigo-500/40",description:"Registrar vista en panel inferior",meta:{shellAction:"registerPanelView"}},{type:"shell:registerSidebar",label:"Sidebar View",icon:(0,ut.jsx)(Ae.Sidebar,{size:16}),color:"border-sky-500/40",description:"Registrar vista en sidebar",meta:{shellAction:"registerSidebarView"}},{type:"shell:registerStatusBar",label:"Status Bar",icon:(0,ut.jsx)(Ae.Minus,{size:16}),color:"border-emerald-500/40",description:"A\xF1adir item al status bar",meta:{shellAction:"registerStatusBarItem"}},{type:"shell:registerTopBar",label:"Top Bar",icon:(0,ut.jsx)(Ae.ArrowUpFromDot,{size:16}),color:"border-violet-500/40",description:"A\xF1adir bot\xF3n al top bar",meta:{shellAction:"registerTopBarItem"}},{type:"shell:registerAction",label:"Register Cmd",icon:(0,ut.jsx)(Ae.Terminal,{size:16}),color:"border-amber-500/40",description:"Registrar un comando",meta:{shellAction:"registerCommand"}}]},{id:"shell-layout",label:"\u{1F5A5}\uFE0F Shell: Layout",icon:(0,ut.jsx)(Ae.Columns2,{size:14}),items:[{type:"shell:toggleSidebar",label:"Toggle Sidebar",icon:(0,ut.jsx)(Ae.PanelLeft,{size:16}),color:"border-sky-500/40",description:"Mostrar/ocultar sidebar",meta:{shellAction:"toggleSidebar"}},{type:"shell:togglePanel",label:"Toggle Panel",icon:(0,ut.jsx)(Ae.PanelBottom,{size:16}),color:"border-indigo-500/40",description:"Mostrar/ocultar panel",meta:{shellAction:"togglePanel"}},{type:"shell:splitPane",label:"Split Pane",icon:(0,ut.jsx)(Ae.Columns2,{size:16}),color:"border-violet-500/40",description:"Dividir editor",meta:{shellAction:"splitPane"}},{type:"shell:focusTab",label:"Focus Tab",icon:(0,ut.jsx)(Ae.Focus,{size:16}),color:"border-cyan-500/40",description:"Enfocar un tab",meta:{shellAction:"focusTab"}},{type:"shell:closeTab",label:"Close Tab",icon:(0,ut.jsx)(Ae.X,{size:16}),color:"border-rose-500/40",description:"Cerrar un tab",meta:{shellAction:"closeTab"}}]},{id:"shell-theme",label:"\u{1F5A5}\uFE0F Shell: Tema",icon:(0,ut.jsx)(Ae.Palette,{size:14}),items:[{type:"shell:setTheme",label:"Set Theme",icon:(0,ut.jsx)(Ae.Palette,{size:16}),color:"border-amber-500/40",description:"Cambiar dark/light",meta:{shellAction:"setTheme"}},{type:"shell:applyPalette",label:"Apply Palette",icon:(0,ut.jsx)(Ae.Paintbrush,{size:16}),color:"border-pink-500/40",description:"Aplicar paleta de colores",meta:{shellAction:"applyPalette"}},{type:"shell:updateToken",label:"CSS Token",icon:(0,ut.jsx)(Ae.Pipette,{size:16}),color:"border-orange-500/40",description:"Modificar token CSS",meta:{shellAction:"updateToken"}}]},{id:"shell-interaction",label:"\u{1F5A5}\uFE0F Shell: Interacci\xF3n",icon:(0,ut.jsx)(Ae.Bell,{size:14}),items:[{type:"shell:notification",label:"Notification",icon:(0,ut.jsx)(Ae.Bell,{size:16}),color:"border-emerald-500/40",description:"Mostrar toast",meta:{shellAction:"showNotification"}},{type:"shell:modal",label:"Show Modal",icon:(0,ut.jsx)(Ae.SquareStack,{size:16}),color:"border-violet-500/40",description:"Abrir modal",meta:{shellAction:"showModal"}},{type:"shell:execCommand",label:"Exec Command",icon:(0,ut.jsx)(Ae.Play,{size:16}),color:"border-teal-500/40",description:"Ejecutar comando",meta:{shellAction:"executeCommand"}},{type:"shell:shortcut",label:"Shortcut",icon:(0,ut.jsx)(Ae.Keyboard,{size:16}),color:"border-amber-500/40",description:"Registrar atajo",meta:{shellAction:"registerShortcut"}},{type:"shell:emitEvent",label:"Emit Event",icon:(0,ut.jsx)(Ae.Radio,{size:16}),color:"border-rose-500/40",description:"Emitir evento",meta:{shellAction:"emitEvent"}}]},{id:"shell-config",label:"\u{1F5A5}\uFE0F Shell: Config",icon:(0,ut.jsx)(Ae.Settings2,{size:14}),items:[{type:"shell:config",label:"Shell Config",icon:(0,ut.jsx)(Ae.Settings2,{size:16}),color:"border-teal-500/40",description:"Configuraci\xF3n completa del shell",meta:{shellAction:"shellConfig"}}]}]});var cc,Hf,no,Ft,jP,WP=U(()=>{"use strict";cc=require("react"),Hf=require("motion/react"),no=require("lucide-react");xi();VP();Ft=require("react/jsx-runtime"),jP=({className:t})=>{let[e,r]=(0,cc.useState)(!1),[n,o]=(0,cc.useState)({dialogue:!0,logic:!0,ui:!0,render:!0,hsm:!1,triggers:!1,morphology:!1,"shell-register":!0,"shell-layout":!0,"shell-theme":!0,"shell-interaction":!0,"shell-config":!0}),[s,i]=(0,cc.useState)(""),a=Mn(u=>u.components),l=(0,cc.useMemo)(()=>{let u=Object.values(a).map(p=>({type:"render",label:p.name,icon:(0,Ft.jsx)(no.Layout,{size:16}),color:p.source==="ai-generated"?"border-pink-500/40":"border-cyan-500/40",description:`${p.category} \xB7 ${p.source}`,meta:{uiSchema:p.schema,componentId:p.id}})),f=[...HP];return f.splice(3,0,{id:"render",label:"UI Render",icon:(0,Ft.jsx)(no.Image,{size:14}),items:u}),f},[a]),c=(0,cc.useMemo)(()=>{if(!s.trim())return l;let u=s.toLowerCase();return l.map(f=>({...f,items:f.items.filter(p=>p.label.toLowerCase().includes(u)||p.type.toLowerCase().includes(u)||(p.description||"").toLowerCase().includes(u))})).filter(f=>f.items.length>0)},[l,s]),d=(u,f)=>{u.dataTransfer.setData(FP,JSON.stringify({type:f.type,label:f.label,meta:f.meta||{}})),u.dataTransfer.effectAllowed="move"};return e?(0,Ft.jsx)("div",{className:`flex flex-col items-center py-3 px-1 bg-surface-primary/80 border-r border-border-subtle ${t||""}`,children:(0,Ft.jsx)("button",{onClick:()=>r(!1),className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-surface-glass transition-colors",title:"Abrir Palette",children:(0,Ft.jsx)(no.PanelLeft,{size:18})})}):(0,Ft.jsxs)(Hf.motion.div,{initial:{width:0,opacity:0},animate:{width:220,opacity:1},exit:{width:0,opacity:0},transition:{duration:.2},className:`flex flex-col bg-surface-primary/90 border-r border-border-subtle overflow-hidden select-none ${t||""}`,style:{width:220},children:[(0,Ft.jsxs)("div",{className:"flex items-center justify-between px-3 py-2.5 border-b border-border-subtle",children:[(0,Ft.jsx)("span",{className:"text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Nodos"}),(0,Ft.jsx)("button",{onClick:()=>r(!0),className:"p-1 rounded text-text-muted hover:text-text-primary hover:bg-surface-glass transition-colors",children:(0,Ft.jsx)(no.PanelLeftClose,{size:14})})]}),(0,Ft.jsx)("div",{className:"px-2 py-2 border-b border-border-subtle",children:(0,Ft.jsxs)("div",{className:"flex items-center gap-2 bg-surface-glass rounded-lg px-2.5 py-1.5",children:[(0,Ft.jsx)(no.Search,{size:12,className:"text-text-muted shrink-0"}),(0,Ft.jsx)("input",{type:"text",placeholder:"Buscar nodos...",value:s,onChange:u=>i(u.target.value),className:"bg-transparent text-xs text-text-primary placeholder-zinc-600 outline-hidden w-full"})]})}),(0,Ft.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:c.map(u=>(0,Ft.jsxs)("div",{children:[(0,Ft.jsxs)("button",{onClick:()=>o(f=>({...f,[u.id]:!f[u.id]})),className:"w-full flex items-center gap-2 px-3 py-2 text-xs font-semibold text-text-secondary hover:text-text-primary hover:bg-surface-glass transition-colors",children:[n[u.id]?(0,Ft.jsx)(no.ChevronDown,{size:12}):(0,Ft.jsx)(no.ChevronRight,{size:12}),(0,Ft.jsx)("span",{className:"text-text-muted",children:u.icon}),(0,Ft.jsx)("span",{children:u.label}),(0,Ft.jsx)("span",{className:"ml-auto text-[10px] text-text-muted bg-surface-glass px-1.5 py-0.5 rounded",children:u.items.length})]}),(0,Ft.jsx)(Hf.AnimatePresence,{children:n[u.id]&&(0,Ft.jsx)(Hf.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:u.items.map(f=>(0,Ft.jsxs)("div",{draggable:!0,onDragStart:p=>d(p,f),className:`flex items-center gap-2 px-3 py-2 mx-2 mb-1 rounded-lg border bg-surface-secondary/60 hover:bg-surface-glass cursor-grab active:cursor-grabbing transition-all group ${f.color}`,children:[(0,Ft.jsx)(no.GripVertical,{size:12,className:"text-text-muted group-hover:text-text-secondary shrink-0"}),(0,Ft.jsx)("div",{className:"text-text-secondary group-hover:text-text-primary shrink-0",children:f.icon}),(0,Ft.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Ft.jsx)("div",{className:"text-[11px] font-medium text-text-primary group-hover:text-text-primary truncate",children:f.label}),f.description&&(0,Ft.jsx)("div",{className:"text-[9px] text-text-muted truncate",children:f.description})]})]},`${u.id}-${f.type}-${f.label}`))})})]},u.id))})]})}});var ua,gg,Is,Vf,Ht,UP,GP=U(()=>{"use strict";ua=require("react"),gg=require("motion/react"),Is=require("lucide-react"),Vf=require("@decido/engine"),Ht=require("react/jsx-runtime"),UP=({isOpen:t,onToggle:e})=>{let r=(0,Vf.useEngineStore)(y=>y.variables),n=(0,Vf.useEngineStore)(y=>y.setVariable),[o,s]=(0,ua.useState)(""),[i,a]=(0,ua.useState)(""),[l,c]=(0,ua.useState)(""),[d,u]=(0,ua.useState)(null),f=Object.entries(r).filter(([y])=>!l||y.toLowerCase().includes(l.toLowerCase())),p=(0,ua.useCallback)(()=>{if(!o.trim())return;let y=i;if(i==="true")y=!0;else if(i==="false")y=!1;else if(!isNaN(Number(i))&&i.trim())y=Number(i);else try{y=JSON.parse(i)}catch{}n(o.trim(),y),s(""),a("")},[o,i,n]),h=(0,ua.useCallback)(y=>{let v={...Vf.useEngineStore.getState().variables};delete v[y],Vf.useEngineStore.setState({variables:v})},[]),b=(0,ua.useCallback)((y,m)=>{let v=m;if(m==="true")v=!0;else if(m==="false")v=!1;else if(!isNaN(Number(m))&&m.trim())v=Number(m);else try{v=JSON.parse(m)}catch{}n(y,v),u(null)},[n]),g=y=>typeof y=="boolean"?"text-amber-400":typeof y=="number"?"text-blue-400":typeof y=="object"?"text-violet-400":"text-emerald-400",x=y=>typeof y=="boolean"?"bool":typeof y=="number"?"num":typeof y=="object"?"obj":"str";return(0,Ht.jsxs)("div",{className:"absolute bottom-0 left-0 right-0 z-30",children:[(0,Ht.jsxs)("button",{onClick:e,className:"flex items-center gap-2 px-3 py-1.5 bg-surface-secondary/90 backdrop-blur-xs border-t border-x border-border-default rounded-t-lg text-xs text-text-secondary hover:text-emerald-400 transition-colors ml-4",children:[(0,Ht.jsx)(Is.Variable,{size:12}),(0,Ht.jsx)("span",{className:"font-bold uppercase tracking-wider text-[9px]",children:"Variables"}),(0,Ht.jsx)("span",{className:"ml-1 bg-emerald-500/20 text-emerald-400 text-[9px] px-1.5 py-0.5 rounded-full font-mono",children:Object.keys(r).length}),t?(0,Ht.jsx)(Is.ChevronDown,{size:10}):(0,Ht.jsx)(Is.ChevronRight,{size:10})]}),(0,Ht.jsx)(gg.AnimatePresence,{children:t&&(0,Ht.jsx)(gg.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"bg-surface-secondary/95 backdrop-blur-xl border-t border-border-default overflow-hidden",children:(0,Ht.jsxs)("div",{className:"max-h-[220px] overflow-y-auto custom-scrollbar",children:[(0,Ht.jsx)("div",{className:"flex items-center gap-2 p-2 border-b border-border-subtle",children:(0,Ht.jsxs)("div",{className:"flex items-center gap-1 flex-1 bg-surface-overlay rounded-lg px-2 border border-border-subtle",children:[(0,Ht.jsx)(Is.Search,{size:12,className:"text-text-muted"}),(0,Ht.jsx)("input",{type:"text",placeholder:"Buscar...",value:l,onChange:y=>c(y.target.value),className:"bg-transparent text-xs text-text-primary outline-hidden py-1.5 w-full placeholder-zinc-600"})]})}),(0,Ht.jsxs)("div",{className:"divide-y divide-white/5",children:[f.length===0&&(0,Ht.jsx)("div",{className:"text-center text-text-muted text-[10px] py-4",children:l?"Sin resultados":"No hay variables definidas"}),f.map(([y,m])=>(0,Ht.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-surface-glass group transition-colors",children:[(0,Ht.jsx)("span",{className:`text-[9px] font-bold uppercase ${g(m)} bg-surface-glass px-1 py-0.5 rounded`,children:x(m)}),(0,Ht.jsx)("span",{className:"text-xs text-text-primary font-mono truncate min-w-[100px]",children:y}),(0,Ht.jsx)("span",{className:"text-text-muted text-[10px]",children:"="}),d===y?(0,Ht.jsx)("input",{autoFocus:!0,defaultValue:typeof m=="object"?JSON.stringify(m):String(m),onBlur:v=>b(y,v.target.value),onKeyDown:v=>{v.key==="Enter"&&b(y,v.target.value),v.key==="Escape"&&u(null)},className:"flex-1 bg-surface-overlay border border-emerald-500/30 rounded px-1.5 py-0.5 text-xs text-text-primary outline-hidden font-mono"}):(0,Ht.jsx)("span",{onClick:()=>u(y),className:`flex-1 text-xs font-mono truncate cursor-pointer hover:text-text-primary transition-colors ${g(m)}`,children:typeof m=="object"?JSON.stringify(m):String(m)}),(0,Ht.jsx)("button",{onClick:()=>h(y),className:"opacity-0 group-hover:opacity-100 text-text-muted hover:text-red-400 transition-all p-0.5",children:(0,Ht.jsx)(Is.Trash2,{size:10})})]},y))]}),(0,Ht.jsxs)("div",{className:"flex items-center gap-2 p-2 border-t border-border-subtle bg-surface-glass",children:[(0,Ht.jsx)(Is.Plus,{size:12,className:"text-emerald-500"}),(0,Ht.jsx)("input",{type:"text",placeholder:"nombre",value:o,onChange:y=>s(y.target.value),onKeyDown:y=>{y.key==="Enter"&&p()},className:"bg-surface-overlay border border-border-subtle rounded px-2 py-1 text-xs text-emerald-300 font-mono outline-hidden w-[120px] focus:border-emerald-500/30"}),(0,Ht.jsx)("span",{className:"text-text-muted text-[10px]",children:"="}),(0,Ht.jsx)("input",{type:"text",placeholder:"valor",value:i,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Enter"&&p()},className:"bg-surface-overlay border border-border-subtle rounded px-2 py-1 text-xs text-text-primary font-mono outline-hidden flex-1 focus:border-emerald-500/30"}),(0,Ht.jsx)("button",{onClick:p,disabled:!o.trim(),className:"px-2 py-1 text-[10px] bg-emerald-500/10 text-emerald-400 rounded font-bold hover:bg-emerald-500/20 disabled:opacity-30 transition-colors",children:"Agregar"})]})]})})})]})}});var qP={};Mo(qP,{ReactFlowEditor:()=>GV});var Yr,wn,KP,jf,bg,vr,UV,GV,YP=U(()=>{"use strict";Yr=Re(require("react"));Ri();zf();ot();wn=require("@decido/engine"),KP=require("@decido/core"),jf=require("@decido/engine");$y();bg=require("lucide-react");ys();yP();wP();NP();EP();IP();$P();WP();GP();vr=require("react/jsx-runtime"),UV=({className:t,style:e,id:r})=>{let{fitView:n,getIntersectingNodes:o,screenToFlowPosition:s}=Lf(),[i,a,l]=Kd([]),[c,d,u]=qd([]),[f,p]=(0,Yr.useState)(null),[h,b]=(0,Yr.useState)(!1),g=(0,Yr.useRef)(null),x=(0,Yr.useRef)({nodes:[],edges:[]}),[y,m]=(0,Yr.useState)(null),v=X(K=>K.prototypeBrand),S=(0,wn.useEngineStore)(K=>K.activeNodeIds),w=(0,wn.useEngineStore)(K=>K.activeEdgeIds),C=(0,wn.useTimelineStore)(K=>K.timelines),A=(0,wn.useTimelineStore)(K=>K.blueprintLibrary),k=(0,wn.useTimelineStore)(K=>K.updateKeyframePosition),M=(0,wn.useTimelineStore)(K=>K.updateKeyframe),T=(0,wn.useTimelineStore)(K=>K.addEdge),E=(0,wn.useTimelineStore)(K=>K.removeEdge),P=(0,wn.useTimelineStore)(K=>K.addKeyframe),N=(0,wn.useTimelineStore)(K=>K.removeKeyframe),D=(0,wn.useTimelineStore)(K=>K.undo),R=(0,wn.useTimelineStore)(K=>K.redo),O=(0,wn.useTimelineStore)(K=>K.setActiveTimeline),B=(0,wn.useTimelineStore)(K=>K.pastTimelines),L=(0,wn.useTimelineStore)(K=>K.futureTimelines);(0,Yr.useEffect)(()=>{O(v)},[v,O]),(0,Yr.useEffect)(()=>{let K=he=>{(he.metaKey||he.ctrlKey)&&he.key==="z"&&!he.shiftKey?(he.preventDefault(),D()):(he.metaKey||he.ctrlKey)&&(he.key==="Z"||he.key==="y")&&(he.preventDefault(),R())};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[D,R]);let H=(B[v]?.length||0)>0,j=(L[v]?.length||0)>0,$=(0,jf.useBlueprintNavigation)(K=>K.currentBlueprintId),q=(0,jf.useBlueprintNavigation)(K=>K.pushNavigation),F=$?A[$]:null,_=F||C[v];(0,Yr.useEffect)(()=>{if(!_)return;let K=F?$:v,he=(0,KP.convertLegacyTimelineToBlueprint)(K,_.keyframes||[],_.edges||[]),lt=Object.values(he.nodes),He={};lt.forEach(St=>{St.visual?.x!==void 0&&St.visual?.y!==void 0&&(St.visual.y!==0||St.visual.x!==0)&&(He[St.id]={x:St.visual.x,y:St.visual.y})});let nt=150,dr=lt.filter(St=>!He[St.id]),ln=!0;for(;dr.length>0&&ln;)ln=!1,dr=dr.filter(St=>{let mt=he.edges.find(je=>je.target===St.id&&He[je.source]);if(mt){let je=He[mt.source],or={x:je.x,y:je.y+nt},fo=!0;for(;fo;)fo=Object.values(He).some(Jn=>Math.abs(Jn.x-or.x)<50&&Math.abs(Jn.y-or.y)<50),fo&&(or.x+=250);return He[St.id]=or,ln=!0,!1}return!0});dr.forEach((St,mt)=>{He[St.id]={x:gP[St.type]||0,y:mt*100}});let Tr=lt.map(St=>({id:St.id,type:St.type,position:He[St.id],parentId:St.visual?.parentId,extent:St.visual?.parentId?"parent":void 0,data:{keyframeId:St.id,isInteractive:!0,isExecuting:S.includes(St.id),onUpdateNodeData:(mt,je)=>M(K,mt,je),variables:wn.useEngineStore.getState().variables,isSpeaking:wn.useEngineStore.getState().isSpeaking,registeredMorphComponents:px(),onDrillDown:(mt,je)=>q({blueprintId:mt,label:je}),...xP(St)}})),bn=_.edges?vP(_.edges,S,w):[];if(a(Tr),d(bn),g.current!==K){if(g.current=K,(Tr.every(mt=>mt.position.x===0&&mt.position.y===0)||Tr.filter(mt=>mt.position.x===0&&mt.position.y===0).length>Tr.length*.5)&&Tr.length>1){let{nodes:mt}=fg(Tr,bn,{direction:"TB"});a(mt),mt.forEach(je=>k(v,je.id,je.position))}setTimeout(()=>n({padding:.2,duration:800}),50)}},[_,S,F,a,d,n]);let W=(0,Yr.useCallback)(K=>{d(he=>ic(K,he)),T(v,{id:`edge-${K.source}-${K.target}-${Date.now()}`,source:K.source,target:K.target,sourceHandle:K.sourceHandle||null,targetHandle:K.targetHandle||null})},[v,T,d]),V=(0,Yr.useCallback)(K=>{K.forEach(he=>E(v,he.id))},[v,E]),z=(0,Yr.useCallback)((K,he,lt)=>{(lt.length>1?lt:[he]).forEach(He=>{if(k(v,He.id,He.position),He.id===he.id){let nt=o(He).filter(dr=>dr.type==="group");He.type!=="group"&&M(v,He.id,{parentId:nt[0]?.id||void 0})}})},[v,k,M,o]),G=(0,Yr.useCallback)((K,he)=>p(he.id),[]),Y=(0,Yr.useCallback)(()=>{p(null),m(null)},[]),Z=(0,Yr.useCallback)(K=>{K.preventDefault();let he=s({x:K.clientX,y:K.clientY});m({x:K.clientX,y:K.clientY,flowPos:he})},[s]),se=(0,Yr.useCallback)((K,he,lt)=>{if(!y)return;P($||v,lv(K,he,y.flowPos,lt)),m(null)},[y,v,$,P]);(0,Yr.useEffect)(()=>{let K=TP({getNodes:()=>i,getEdges:()=>c,setNodes:a,setEdges:d,clipboard:x,activeTimelineId:v,currentBlueprintId:$,addKeyframe:P,addTimelineEdge:T,removeKeyframe:N,removeTimelineEdge:E,setSelectedNodeId:p,NODE_TYPE_TO_TRACK:bP});return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[i,c,v,$,a,d,P,T,N,E]);let we=(0,jf.useBlueprintNavigation)(K=>K.navigationStack),_e=(0,jf.useBlueprintNavigation)(K=>K.navigateToLevel),Pe=we.length>1;return(0,vr.jsxs)("div",{style:e,className:`relative flex flex-col overflow-hidden w-full h-full ${t||""}`,id:r,children:[Pe&&(0,vr.jsxs)("div",{className:"flex-none flex items-center gap-1 px-3 py-2 bg-surface-overlay border-b border-border-default backdrop-blur-xs z-10",children:[(0,vr.jsxs)("button",{onClick:()=>_e(0),className:"flex items-center gap-1 text-xs text-text-secondary hover:text-text-primary transition-colors px-1.5 py-0.5 rounded hover:bg-surface-glass",children:[(0,vr.jsx)(bg.Home,{size:12}),(0,vr.jsx)("span",{children:"Root"})]}),we.slice(1).map((K,he)=>(0,vr.jsxs)(Yr.default.Fragment,{children:[(0,vr.jsx)(bg.ChevronRight,{size:12,className:"text-text-muted"}),(0,vr.jsxs)("button",{onClick:()=>_e(he+1),className:`text-xs px-1.5 py-0.5 rounded transition-colors ${he+1===we.length-1?"text-purple-300 bg-purple-500/10 border border-purple-500/20":"text-text-secondary hover:text-text-primary hover:bg-surface-glass"}`,children:["\u{1F4E6} ",K.label]})]},he+1))]}),(0,vr.jsxs)("div",{className:"flex-1 relative flex overflow-hidden",onDragOver:K=>{K.preventDefault(),K.dataTransfer.dropEffect="move"},onDrop:K=>{K.preventDefault();let he=K.dataTransfer.getData("application/decido-node");if(he)try{let{type:lt,label:He,meta:nt}=JSON.parse(he),dr=s({x:K.clientX,y:K.clientY});P($||v,lv(lt,He,dr,nt))}catch(lt){console.error("[ReactFlowEditor] Drop failed:",lt)}},children:[(0,vr.jsx)(jP,{}),(0,vr.jsxs)(el,{nodes:i,edges:c,nodeTypes:mP,onNodesChange:l,onEdgesChange:u,onEdgesDelete:V,onConnect:W,onNodeDragStop:z,onNodeClick:G,onPaneClick:Y,onPaneContextMenu:Z,colorMode:"dark",fitView:!0,fitViewOptions:{padding:.2},minZoom:.1,selectionOnDrag:!0,panOnDrag:[1],selectionMode:aa.Partial,multiSelectionKeyCode:"Meta",deleteKeyCode:null,children:[(0,vr.jsx)(rl,{className:"fill-white"}),(0,vr.jsx)(kP,{canUndo:H,canRedo:j,undoCount:B[v]?.length||0,redoCount:L[v]?.length||0,undo:D,redo:R,nodes:i,edges:c,setNodes:a,updateKeyframePosition:k,removeKeyframe:N,activeTimelineId:v,currentBlueprintId:$,fitView:n,setSelectedNodeId:p}),(0,vr.jsx)(nl,{nodeStrokeColor:()=>"#ffffff",nodeColor:()=>"#333333",maskColor:"rgba(0, 0, 0, 0.7)"}),(0,vr.jsx)(tl,{color:"#555",gap:20})]}),y&&(0,vr.jsxs)(vr.Fragment,{children:[(0,vr.jsx)("div",{className:"fixed inset-0 z-998",onClick:()=>m(null)}),(0,vr.jsx)(SP,{x:y.x,y:y.y,onAdd:se,onClose:()=>m(null)})]})]}),f&&(0,vr.jsx)(zP,{selectedNodeId:f,onClose:()=>p(null)}),(0,vr.jsx)(UP,{isOpen:h,onToggle:()=>b(K=>!K)})]})},GV=t=>(0,vr.jsx)(Bf,{children:(0,vr.jsx)(UV,{...t})})});var XP,xg,JP,kr,KV,ZP,QP=U(()=>{"use strict";XP=Re(require("react")),xg=require("lucide-react"),JP=require("motion/react"),kr=require("react/jsx-runtime"),KV={dialogue:{clock:"text-purple-400/70",input:"focus:border-purple-500/50",text:"text-purple-300",label:"text-purple-400/70"},ui:{clock:"text-cyan-400/70",input:"focus:border-cyan-500/50",text:"text-text-primary",label:"text-cyan-400/70"},logic:{clock:"text-orange-400/70",input:"focus:border-orange-500/50",text:"text-text-primary",label:"text-orange-400/70"}},ZP=XP.default.memo(function({kf:e,track:r,activeTimelineId:n,updateKeyframe:o,removeKeyframe:s}){let i=KV[r];return(0,kr.jsxs)(JP.motion.div,{layout:!0,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2},style:{left:`${e.t*100}px`,width:"260px"},className:"absolute top-2 bottom-2 bg-surface-secondary border border-border-default rounded-xl p-3 flex flex-col gap-2 group hover:border-border-subtle0 shadow-[0_8px_30px_rgb(0,0,0,0.5)] hover:shadow-[0_8px_30px_rgb(0,0,0,0.8)] transition-all z-10",children:[(0,kr.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b border-border-subtle pb-1.5",children:[(0,kr.jsxs)("div",{className:"flex items-center gap-1 bg-surface-overlay px-1.5 py-0.5 rounded border border-border-default transition-colors",children:[(0,kr.jsx)(xg.Clock,{size:10,className:i.clock}),(0,kr.jsx)("input",{type:"number",step:"0.1",className:"bg-transparent w-10 text-xs text-text-primary font-mono focus:outline-hidden text-center",value:e.t,onChange:a=>o(n,e.id,{t:parseFloat(a.target.value)||0})})]}),(0,kr.jsx)("button",{onClick:()=>s(n,e.id),className:"p-1 text-text-muted hover:text-red-400 hover:bg-red-500/10 rounded transition-colors opacity-0 group-hover:opacity-100",title:"Eliminar Keyframe",children:(0,kr.jsx)(xg.Trash2,{size:12})})]}),r==="dialogue"&&(0,kr.jsxs)("div",{className:"flex flex-col gap-2 flex-1",children:[(0,kr.jsxs)("div",{className:"flex items-center gap-2",children:[(0,kr.jsx)("span",{className:`text-[9px] uppercase tracking-wider ${i.label} w-10`,children:"Actor"}),(0,kr.jsx)("input",{type:"text",className:`flex-1 bg-surface-glass border border-border-subtle rounded px-2 py-1 text-xs ${i.text} focus:outline-hidden ${i.input}`,value:e.actorId||"",placeholder:"system",onChange:a=>o(n,e.id,{actorId:a.target.value})})]}),(0,kr.jsx)("textarea",{className:`w-full bg-surface-glass border border-border-subtle rounded px-2 py-1.5 text-xs text-text-primary focus:outline-hidden ${i.input} resize-none flex-1 min-h-0`,placeholder:"Texto a sintetizar...",value:e.speech||"",onChange:a=>o(n,e.id,{speech:a.target.value})})]}),r==="ui"&&(0,kr.jsxs)("div",{className:"flex flex-col gap-2 flex-1 justify-center",children:[(0,kr.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,kr.jsx)("span",{className:`text-[9px] uppercase tracking-wider ${i.label}`,children:"App State"}),(0,kr.jsx)("input",{type:"text",className:`w-full bg-surface-glass border border-border-subtle rounded px-2 py-1.5 text-xs text-text-primary focus:outline-hidden ${i.input}`,value:e.state||"",placeholder:"idle",onChange:a=>o(n,e.id,{state:a.target.value})})]}),(0,kr.jsxs)("label",{className:"flex items-center gap-2 p-1.5 mt-1 rounded hover:bg-surface-glass cursor-pointer border border-transparent hover:border-border-subtle transition-colors",children:[(0,kr.jsx)("input",{type:"checkbox",checked:e.canvas||!1,onChange:a=>o(n,e.id,{canvas:a.target.checked}),className:"rounded border-border-strong bg-surface-glass text-cyan-500 w-3.5 h-3.5"}),(0,kr.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-cyan-300",children:"Mostrar Lienzo 3D"})]})]}),r==="logic"&&(0,kr.jsxs)("div",{className:"flex flex-col gap-1 flex-1 justify-center",children:[(0,kr.jsx)("span",{className:`text-[9px] uppercase tracking-wider ${i.label}`,children:"Intent / Action"}),(0,kr.jsx)("input",{type:"text",className:`w-full bg-surface-glass border border-border-subtle rounded px-2 py-1.5 text-xs text-text-primary focus:outline-hidden ${i.input} font-mono mt-1`,value:e.intent||"",placeholder:"action_name",onChange:a=>o(n,e.id,{intent:a.target.value})}),(0,kr.jsx)("span",{className:"text-[9px] text-text-muted leading-tight mt-2 px-1",children:"Dispara un trigger local o llamada MCP."})]})]})})});var tR={};Mo(tR,{TimelineEditor:()=>qV});var Qd,yg,eR,nr,qV,rR=U(()=>{"use strict";Qd=require("@decido/engine");ot();yg=require("lucide-react"),eR=require("motion/react");QP();nr=require("react/jsx-runtime"),qV=()=>{let t=X(c=>c.prototypeBrand),e=(0,Qd.useTimelineStore)(c=>c.timelines),r=(0,Qd.useTimelineStore)(c=>c.addKeyframe),n=(0,Qd.useTimelineStore)(c=>c.updateKeyframe),o=(0,Qd.useTimelineStore)(c=>c.removeKeyframe),s=(0,Qd.useTimelineStore)(c=>c.updateDuration),i=e[t];if(!i)return null;let a=c=>{r(t,{t:i.duration,track:c,...c==="dialogue"?{speech:"",actorId:"system"}:{},...c==="ui"?{state:"new_state",canvas:!1}:{},...c==="logic"?{intent:""}:{}})},l=["dialogue","ui","logic"];return(0,nr.jsxs)("div",{className:"flex flex-col h-full bg-surface-secondary text-text-primary border-l border-border-default w-full shadow-2xl z-40 overflow-hidden relative",children:[(0,nr.jsx)("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E')] opacity-[0.10] mix-blend-overlay pointer-events-none z-0"}),(0,nr.jsxs)("div",{className:"p-4 border-b border-border-default relative z-10 flex justify-between items-center bg-surface-glass",children:[(0,nr.jsxs)("div",{children:[(0,nr.jsxs)("h2",{className:"text-lg font-bold text-text-primary flex items-center gap-2",children:[(0,nr.jsx)(yg.MonitorPlay,{size:18,className:"text-purple-400"}),"Multi-Track Sequence"]}),(0,nr.jsxs)("p",{className:"text-xs text-text-secondary mt-1 font-mono uppercase tracking-wider",children:["Editando: ",i.name]})]}),(0,nr.jsxs)("div",{className:"text-right flex flex-col items-end gap-1",children:[(0,nr.jsx)("span",{className:"text-xs text-text-muted font-mono",children:"Duraci\xF3n Global (s)"}),(0,nr.jsx)("input",{type:"number",className:"bg-surface-glass border border-border-strong rounded px-2 py-1 w-20 text-text-primary text-right text-sm focus:outline-hidden focus:border-purple-400",value:i.duration,onChange:c=>s(t,parseFloat(c.target.value)||0)})]})]}),(0,nr.jsxs)("div",{className:"flex-1 flex overflow-hidden w-full relative z-10",children:[(0,nr.jsxs)("div",{className:"w-[220px] shrink-0 flex flex-col border-r border-border-default bg-surface-primary z-20",children:[(0,nr.jsx)("div",{className:"h-8 border-b border-border-default shrink-0 bg-surface-secondary"}),l.map(c=>(0,nr.jsxs)("div",{className:`h-[170px] flex flex-col justify-center p-4 border-b border-border-subtle relative
|
|
412
|
+
${c==="dialogue"?"bg-purple-500/5":c==="ui"?"bg-cyan-500/5":"bg-orange-500/5"}`,children:[(0,nr.jsx)("div",{className:`text-[10px] font-bold uppercase tracking-widest
|
|
413
|
+
${c==="dialogue"?"text-purple-400":c==="ui"?"text-cyan-400":"text-orange-400"}`,children:c==="dialogue"?"Track 1: Di\xE1logo & Audio":c==="ui"?"Track 2: UI & Canvas":"Track 3: L\xF3gica & MCP"}),(0,nr.jsxs)("button",{onClick:()=>a(c),className:"mt-3 w-fit py-1.5 px-3 rounded text-xs transition-colors flex items-center gap-1 border border-border-default hover:bg-surface-glass text-text-primary/70 hover:text-text-primary",children:[(0,nr.jsx)(yg.Plus,{size:12})," Add Node"]})]},c))]}),(0,nr.jsx)("div",{className:"flex-1 overflow-x-auto overflow-y-hidden custom-scrollbar bg-surface-secondary relative",children:(0,nr.jsxs)("div",{className:"h-full relative min-w-max pb-10",style:{width:`${Math.max(i.duration,15)*100+400}px`},children:[(0,nr.jsx)("div",{className:"h-8 border-b border-border-default sticky top-0 bg-surface-secondary z-20 flex items-end",children:Array.from({length:Math.ceil(Math.max(i.duration,15))+5}).map((c,d)=>(0,nr.jsxs)("div",{className:"absolute h-3 border-l border-border-strong",style:{left:`${d*100}px`},children:[(0,nr.jsxs)("span",{className:"absolute -top-5 -left-1.5 text-[10px] text-text-primary/30 font-mono tracking-tighter",children:[d,"s"]}),(0,nr.jsx)("div",{className:"absolute left-[50px] -bottom-3 h-1.5 border-l border-border-default"})]},d))}),(0,nr.jsx)("div",{className:"flex flex-col w-full relative",children:l.map(c=>(0,nr.jsx)("div",{className:"h-[170px] border-b border-border-subtle relative hover:bg-surface-glass transition-colors group/lane",children:(0,nr.jsx)(eR.AnimatePresence,{children:i.keyframes.filter(d=>d.track===c).map(d=>(0,nr.jsx)(ZP,{kf:d,track:c,activeTimelineId:t,updateKeyframe:n,removeKeyframe:o},d.id))})},c))})]})})]})]})}});var oR={};Mo(oR,{checkWasmPermission:()=>XV,getWasmManifest:()=>JV,onWasmPluginEvent:()=>nR,runWasmPlugin:()=>YV,useWasmPluginEvents:()=>ZV});async function dv(){if(!cv)try{cv=(await import("@tauri-apps/api/core")).invoke}catch{throw new Error("[WASM Bridge] @tauri-apps/api not available. WASM plugins are only supported in the desktop app.")}return cv}async function YV(t,e="run"){return(await dv())("run_wasm_plugin",{name:t,function:e})}async function XV(t,e){return(await dv())("check_plugin_permission",{pluginName:t,permission:e})}async function JV(t){return(await dv())("get_wasm_manifest",{name:t})}async function nR(t){try{let{listen:e}=await import("@tauri-apps/api/event");return await e("wasm-plugin-event",n=>{t(n.payload)})}catch{return console.warn("[WASM Bridge] Event listener not available outside Tauri desktop."),()=>{}}}function ZV(t=50){let[e,r]=(0,fa.useState)([]),[n,o]=(0,fa.useState)(null),s=(0,fa.useRef)(null);(0,fa.useEffect)(()=>{let a=!1;return nR(l=>{a||(o(l),r(c=>[...c.slice(-(t-1)),l]))}).then(l=>{a?l():s.current=l}),()=>{a=!0,s.current?.()}},[t]);let i=(0,fa.useCallback)(()=>{r([]),o(null)},[]);return{events:e,lastEvent:n,clear:i}}var fa,cv,sR=U(()=>{"use strict";fa=require("react"),cv=null});var iR={};Mo(iR,{PluginSandbox:()=>uv});var eu,QV,uv,aR=U(()=>{"use strict";eu=require("@decido/logger"),QV={},uv=class{worker=null;config;pendingRequests=new Map;isReady=!1;readyPromise;readyResolve;onRpcRequest;onWidgetRegister;onLog;onError;constructor(e){this.config=e,this.readyPromise=new Promise(r=>{this.readyResolve=r})}async start(){let e=(0,eu.probeStart)("sandbox.start",{context:{module:"sdk",component:"PluginSandbox"}});if(this.config.trusted){this.isReady=!0,this.readyResolve(),e({pluginId:this.config.pluginId,trusted:!0});return}let r=new URL("./sandbox-worker.js",QV.url);this.worker=new Worker(r,{type:"module",name:`plugin-${this.config.pluginId}`}),this.worker.onmessage=o=>{this.handleWorkerMessage(o.data)},this.worker.onerror=o=>{(0,eu.probe)("sandbox.error",{pluginId:this.config.pluginId,error:o.message},{level:"error",context:{module:"sdk",component:"PluginSandbox"}}),console.error(`[Sandbox:${this.config.pluginId}] Worker error:`,o.message),this.onError&&this.onError(o.message)},this.sendToWorker({type:"SANDBOX_INIT",pluginId:this.config.pluginId,payload:{pluginUrl:this.config.pluginUrl,tenantId:this.config.tenantId,permissions:this.config.permissions||[]}});let n=this.config.timeout||1e4;await Promise.race([this.readyPromise,new Promise((o,s)=>setTimeout(()=>s(new Error(`Plugin "${this.config.pluginId}" sandbox init timed out after ${n}ms`)),n))]),e({pluginId:this.config.pluginId,trusted:!1})}async mount(){this.config.trusted||this.sendToWorker({type:"SANDBOX_MOUNT",pluginId:this.config.pluginId})}async unmount(){this.config.trusted||this.sendToWorker({type:"SANDBOX_UNMOUNT",pluginId:this.config.pluginId})}broadcastEvent(e,r){this.worker&&this.sendToWorker({type:"SANDBOX_EVENT_BROADCAST",pluginId:this.config.pluginId,payload:{topic:e,data:r}})}destroy(){(0,eu.probe)("sandbox.destroy",{pluginId:this.config.pluginId,pendingRequests:this.pendingRequests.size},{context:{module:"sdk",component:"PluginSandbox"}}),this.worker&&(this.sendToWorker({type:"SANDBOX_DESTROY",pluginId:this.config.pluginId}),setTimeout(()=>{this.worker?.terminate(),this.worker=null},500));for(let[,e]of this.pendingRequests)clearTimeout(e.timer),e.reject(new Error("Sandbox destroyed"));this.pendingRequests.clear()}sendToWorker(e){this.worker?.postMessage(e)}handleWorkerMessage(e){switch(e.type){case"SANDBOX_READY":this.isReady=!0,this.readyResolve();break;case"SANDBOX_RPC_REQUEST":(0,eu.probe)("sandbox.rpc.request",{pluginId:e.pluginId,action:e.payload?.action},{context:{module:"sdk",component:"PluginSandbox"},security:{tier:1}}),this.handleRpcFromPlugin(e);break;case"SANDBOX_RPC_RESPONSE":this.handleRpcResponse(e);break;case"SANDBOX_EVENT_EMIT":break;case"SANDBOX_WIDGET_REGISTER":this.onWidgetRegister&&this.onWidgetRegister(e.payload);break;case"SANDBOX_LOG":if(this.onLog)this.onLog(e.payload?.level||"log",e.payload?.args||[]);else{let r=e.payload?.level||"log",n=`[Sandbox:${e.pluginId}]`;console[r]?.(n,...e.payload?.args||[])}break;case"SANDBOX_ERROR":console.error(`[Sandbox:${e.pluginId}] Error:`,e.error),this.onError&&this.onError(e.error||"Unknown error");break;default:console.warn(`[Sandbox:${e.pluginId}] Unknown message type: ${e.type}`)}}async handleRpcFromPlugin(e){if(!e.requestId||!this.onRpcRequest){this.sendToWorker({type:"SANDBOX_RPC_RESPONSE",pluginId:e.pluginId,requestId:e.requestId,error:"No RPC handler available"});return}try{let r=await this.onRpcRequest(e.payload?.action,e.payload?.data);this.sendToWorker({type:"SANDBOX_RPC_RESPONSE",pluginId:e.pluginId,requestId:e.requestId,payload:r})}catch(r){this.sendToWorker({type:"SANDBOX_RPC_RESPONSE",pluginId:e.pluginId,requestId:e.requestId,error:r.message})}}handleRpcResponse(e){let r=e.requestId;if(!r)return;let n=this.pendingRequests.get(r);n&&(clearTimeout(n.timer),this.pendingRequests.delete(r),e.error?n.reject(new Error(e.error)):n.resolve(e.payload))}}});function lR({widget:t,onClose:e,className:r=""}){return(0,oe.jsx)(hv,{widgetId:t.id,children:t.url?(0,oe.jsx)(rj,{widget:t,onClose:e,className:r}):t.schema?(0,oe.jsx)(nj,{widget:t,onClose:e,className:r}):t.scriptUrl?(0,oe.jsx)(tj,{widget:t,onClose:e,className:r}):t.component?(0,oe.jsx)(ej,{widget:t,onClose:e,className:r}):(0,oe.jsx)("div",{className:`w-full h-full flex items-center justify-center text-text-muted ${r}`,children:(0,oe.jsxs)("p",{className:"text-xs",children:['Widget "',t.title,'" has no schema, URL, scriptUrl, or component']})})})}function ej({widget:t,onClose:e,className:r=""}){let n=t.component;return(0,oe.jsxs)("div",{className:`w-full h-full flex flex-col bg-surface-primary ${r} min-w-0 min-h-0`,children:[(0,oe.jsx)(Uf,{label:"OPTION D \xB7 NATIVE",color:"emerald",title:t.title,onClose:e,children:(0,oe.jsx)("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-emerald-500/10 border border-emerald-500/20",children:(0,oe.jsx)("span",{className:"text-[9px] text-emerald-400 font-mono",children:"REACT"})})}),(0,oe.jsx)("div",{className:"flex-1 min-h-0 min-w-0 overflow-y-auto overflow-x-auto bg-surface-primary rr-block relative","data-rr-block":!0,children:(0,oe.jsx)(Xr.default.Suspense,{fallback:(0,oe.jsx)(cR,{title:t.title,color:"emerald"}),children:(0,oe.jsx)(n,{})})})]})}function tj({widget:t,onClose:e,className:r=""}){let[n,o]=Xr.default.useState("idle"),[s,i]=Xr.default.useState(0),[a,l]=Xr.default.useState(null),c=Xr.default.useRef(null);Xr.default.useEffect(()=>()=>{c.current&&(c.current.destroy(),c.current=null)},[]);let d=Xr.default.useCallback(async()=>{try{o("running"),l(null);let p=t.scriptUrl||"";if(p.startsWith("wasm://")){let g=p.replace("wasm://","").split("/"),x=g[0],y=g[1]||"run",{runWasmPlugin:m}=await Promise.resolve().then(()=>(sR(),oR)),v=await m(x,y);console.log(`[WASM] Plugin "${x}.${y}" result:`,v),i(S=>S+1),o("stopped");return}let{PluginSandbox:h}=await Promise.resolve().then(()=>(aR(),iR)),b=new h({pluginId:t.pluginId,pluginUrl:p,tenantId:"default",permissions:t.permissions||[]});b.onRpcRequest=async(g,x)=>new Promise((y,m)=>{let v=`headless-${Date.now()}-${Math.random().toString(36).slice(2)}`,S=w=>{w.data?.reqId===v&&(window.removeEventListener("message",S),w.data.error?m(new Error(w.data.error)):y(w.data.result))};window.addEventListener("message",S),window.postMessage({type:"DECIDO_RPC",reqId:v,action:g,pluginId:t.pluginId,payload:x},window.location.origin)}),b.onError=g=>{l(g),o("error")},c.current=b,await b.start(),i(g=>g+1)}catch(p){o("error"),l(typeof p=="string"?p:p?.message||String(p)),console.error("[HeadlessWidget] Error:",p)}},[t]),u=Xr.default.useCallback(()=>{c.current&&(c.current.destroy(),c.current=null),o("stopped")},[]),f={idle:"bg-gray-500/20 text-gray-400",running:"bg-emerald-500/20 text-emerald-400",stopped:"bg-amber-500/20 text-amber-400",error:"bg-red-500/20 text-red-400"};return(0,oe.jsxs)("div",{className:`flex flex-col h-full ${r}`,children:[(0,oe.jsx)(Uf,{title:t.title,label:"WORKER",color:"violet",onClose:e,children:(0,oe.jsx)("div",{className:`flex items-center gap-1 px-1.5 py-0.5 rounded ${f[n]}`,children:(0,oe.jsx)("span",{className:"text-[9px] font-mono uppercase",children:n})})}),(0,oe.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,oe.jsxs)("div",{className:"text-center",children:[(0,oe.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Worker Sandbox Plugin"}),(0,oe.jsx)("p",{className:"text-[10px] text-text-disabled font-mono",children:t.scriptUrl})]}),(0,oe.jsxs)("div",{className:"flex gap-2",children:[(0,oe.jsx)("button",{onClick:d,disabled:n==="running",className:"px-3 py-1.5 text-xs rounded bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/30 disabled:opacity-50 transition-colors",children:"\u25B6 Start"}),(0,oe.jsx)("button",{onClick:u,disabled:n!=="running",className:"px-3 py-1.5 text-xs rounded bg-red-500/20 text-red-400 hover:bg-red-500/30 disabled:opacity-50 transition-colors",children:"\u25A0 Stop"})]}),s>0&&(0,oe.jsxs)("p",{className:"text-[10px] text-text-disabled",children:["Runs: ",s]}),a&&(0,oe.jsx)("p",{className:"text-[10px] text-red-400 max-w-[200px] text-center",children:a})]})]})}function rj({widget:t,onClose:e,className:r=""}){let n=Xr.default.useRef(null),o=Xr.default.useRef(new pv),[s,i]=Xr.default.useState(!0),[a,l]=Xr.default.useState(!1),[c,d]=Xr.default.useState(!0);Xr.default.useEffect(()=>{if(!t.url)return;let p=new AbortController;return fetch(t.url,{mode:"no-cors",signal:p.signal}).then(()=>d(!0)).catch(()=>d(!1)),()=>p.abort()},[t.url]),Xr.default.useEffect(()=>{let p=o.current;return p.onRequest("getTheme",()=>document.documentElement.classList.contains("dark")?"dark":"light"),p.onRequest("getData",h=>Wf.resolve(h.path)),p.onRequest("navigate",h=>{console.log("[Bridge] Plugin requested navigation:",h.route)}),p.onRequest("requestAction",h=>(console.log("[Bridge] Action from plugin:",h.command),window.dispatchEvent(new CustomEvent("sdui:action",{detail:{command:h.command,payload:h.payload}})),{dispatched:!0})),p.onRequest("getWidgets",()=>{let h=window.__pluginWidgetStore;return h?{widgets:h.getVisible().map(b=>({id:b.id,title:b.title,pluginId:b.pluginId}))}:{widgets:[]}}),p.onRequest("openExternal",h=>(window.open(h.url,"_blank","noopener,noreferrer"),{opened:!0})),()=>p.detach()},[]),Xr.default.useEffect(()=>{i(!0),l(!1)},[t.url]);let u=()=>{i(!1),l(!1),n.current&&o.current.attach(n.current)},f=()=>{n.current&&(i(!0),l(!1),n.current.src=n.current.src)};return c?(0,oe.jsxs)("div",{className:`w-full h-full flex flex-col bg-surface-primary ${r}`,children:[(0,oe.jsx)(Uf,{label:"OPTION B \xB7 IFRAME",color:"blue",title:t.title,onClose:e,onRefresh:f,children:(0,oe.jsxs)("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-blue-500/10 border border-blue-500/20",children:[(0,oe.jsx)(ei.Wifi,{className:"w-2.5 h-2.5 text-blue-400"}),(0,oe.jsx)("span",{className:"text-[9px] text-blue-400 font-mono",children:"BRIDGE"})]})}),(0,oe.jsxs)("div",{className:"flex-1 relative rr-block","data-rr-block":!0,children:[s&&(0,oe.jsx)(cR,{title:t.title,color:"blue"}),a&&(0,oe.jsx)(oj,{url:t.url||"",onRetry:f}),(0,oe.jsx)("iframe",{ref:n,src:t.url,className:"w-full h-full border-0 rr-block",onLoad:u,onError:()=>{i(!1),l(!0)},sandbox:"allow-scripts allow-same-origin allow-popups allow-forms allow-modals","data-rr-block":!0,title:t.title})]})]}):(0,oe.jsxs)("div",{className:`w-full h-full flex flex-col bg-surface-primary ${r}`,children:[(0,oe.jsx)(Uf,{label:"OPTION B \xB7 IFRAME",color:"blue",title:t.title,onClose:e,onRefresh:()=>d(!0)}),(0,oe.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3",children:[(0,oe.jsx)("div",{className:"w-14 h-14 rounded-2xl bg-amber-500/10 border border-amber-500/20 flex items-center justify-center",children:(0,oe.jsx)(ei.WifiOff,{className:"w-7 h-7 text-amber-400"})}),(0,oe.jsx)("p",{className:"text-sm font-semibold text-text-primary",children:"Plugin Offline"}),(0,oe.jsxs)("p",{className:"text-xs text-text-muted",children:[t.url," no responde"]}),(0,oe.jsx)("button",{onClick:()=>{d(!0)},className:"px-3 py-1.5 rounded-lg text-xs font-medium bg-surface-glass hover:bg-surface-elevated transition-colors",children:"Reintentar"})]})]})}function nj({widget:t,onClose:e,className:r=""}){let[,n]=Xr.default.useReducer(o=>o+1,0);return Xr.default.useEffect(()=>Wf.subscribe(n),[]),(0,oe.jsxs)("div",{className:`w-full h-full flex flex-col bg-surface-primary overflow-hidden ${r}`,children:[(0,oe.jsx)(Uf,{label:"OPTION A \xB7 SDUI",color:"emerald",title:t.title,onClose:e,children:(0,oe.jsx)("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-emerald-500/10 border border-emerald-500/20",children:(0,oe.jsx)("span",{className:"text-[9px] text-emerald-400 font-mono",children:"REACTIVE"})})}),(0,oe.jsx)("div",{className:"flex-1 overflow-auto",children:t.schema&&(0,oe.jsx)(dR,{node:t.schema})})]})}function Uf({label:t,color:e,title:r,onClose:n,onRefresh:o,children:s}){let i={blue:"text-blue-400 bg-blue-400",emerald:"text-emerald-400 bg-emerald-400"},a=i[e]?.split(" ")[0]||"text-cyan-400",l=i[e]?.split(" ")[1]||"bg-cyan-400";return(0,oe.jsxs)("div",{className:"flex-none flex items-center justify-between px-3 py-1.5 bg-surface-secondary/80 backdrop-blur-sm border-b border-border-subtle",children:[(0,oe.jsxs)("div",{className:"flex items-center gap-2",children:[(0,oe.jsx)("div",{className:`w-2 h-2 rounded-full ${l} animate-pulse`}),(0,oe.jsx)("span",{className:`text-[10px] font-bold ${a} tracking-wider uppercase`,children:t}),(0,oe.jsx)("span",{className:"text-xs font-medium text-text-primary",children:r}),s]}),(0,oe.jsxs)("div",{className:"flex items-center gap-1",children:[o&&(0,oe.jsx)("button",{onClick:o,className:"p-1 rounded text-text-muted hover:text-text-primary hover:bg-surface-glass transition-colors",title:"Refresh",children:(0,oe.jsx)(ei.RefreshCw,{className:"w-3 h-3"})}),n&&(0,oe.jsx)("button",{onClick:n,className:"p-1 rounded text-text-muted hover:text-red-400 hover:bg-red-500/10 transition-colors",title:"Close",children:(0,oe.jsx)(ei.X,{className:"w-3 h-3"})})]})]})}function cR({title:t,color:e}){return(0,oe.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-surface-primary z-10",children:(0,oe.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,oe.jsx)("div",{className:`w-6 h-6 border-2 ${e==="blue"?"border-blue-500/20":"border-emerald-500/20"} rounded-full relative`,children:(0,oe.jsx)("div",{className:`absolute inset-0 w-6 h-6 border-2 border-transparent border-t-current ${e==="blue"?"border-blue-400":"border-emerald-400"} rounded-full animate-spin`})}),(0,oe.jsxs)("p",{className:"text-[10px] text-text-muted",children:["Loading ",t,"..."]})]})})}function oj({url:t,onRetry:e}){return(0,oe.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-surface-primary z-10",children:(0,oe.jsxs)("div",{className:"text-center space-y-2",children:[(0,oe.jsx)(ei.X,{className:"w-8 h-8 text-red-400 mx-auto"}),(0,oe.jsxs)("p",{className:"text-xs text-text-muted",children:["Failed to load ",t]}),(0,oe.jsx)("button",{onClick:e,className:"text-[10px] px-2 py-1 rounded bg-surface-glass hover:bg-surface-elevated transition-colors",children:"Retry"})]})})}function dR({node:t}){if(typeof t=="string")return(0,oe.jsx)(oe.Fragment,{children:t});if(!t||!t.type||t.conditional&&!Wf.resolve(t.conditional))return null;let e={...t.props};if(t.dataSource){let o=Wf.resolve(t.dataSource);if(o!==void 0){if(typeof o=="string"||typeof o=="number")return Xr.default.createElement(t.type,e,String(o));e={...e,data:o}}}if(t.onAction){let o=t.onAction;e.onClick=()=>{console.log(`[SDUI Action] ${o.command}`,o.payload),window.dispatchEvent(new CustomEvent("sdui:action",{detail:{command:o.command,payload:o.payload}}))},e.style={...e.style,cursor:"pointer"}}let r=ij[t.type];if(r)return(0,oe.jsx)(r,{...e});if(!sj.has(t.type))return(0,oe.jsxs)("div",{className:"p-2 border border-amber-500/20 rounded bg-amber-500/5 text-xs text-amber-400",children:["Unknown: ",t.type]});let n=t.children?.map((o,s)=>(0,oe.jsx)(dR,{node:o},s));return Xr.default.createElement(t.type,e,n)}function aj({label:t,value:e,unit:r,color:n="cyan",trend:o}){let s={cyan:"bg-cyan-900/30 border-cyan-500/20 text-cyan-400",emerald:"bg-emerald-900/30 border-emerald-500/20 text-emerald-400",amber:"bg-amber-900/30 border-amber-500/20 text-amber-400",red:"bg-red-900/30 border-red-500/20 text-red-400",blue:"bg-blue-900/30 border-blue-500/20 text-blue-400"},i={up:"\u2191",down:"\u2193",stable:"\u2192"},a={up:"text-emerald-400",down:"text-red-400",stable:"text-zinc-500"};return(0,oe.jsxs)("div",{className:`p-3 rounded-lg border text-center ${s[n]||s.cyan}`,children:[(0,oe.jsxs)("div",{className:"text-2xl font-bold flex items-center justify-center gap-1",children:[e,r&&(0,oe.jsx)("span",{className:"text-sm opacity-60",children:r}),o&&(0,oe.jsx)("span",{className:`text-sm ${a[o]}`,children:i[o]})]}),(0,oe.jsx)("div",{className:"text-[10px] text-zinc-400 uppercase tracking-wider mt-1",children:t})]})}function lj({value:t,max:e=100,label:r,color:n="cyan"}){let o=Math.min(100,t/e*100),s={cyan:"bg-cyan-500",emerald:"bg-emerald-500",amber:"bg-amber-500",red:"bg-red-500"};return(0,oe.jsxs)("div",{className:"space-y-1",children:[r&&(0,oe.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,oe.jsx)("span",{className:"text-zinc-400",children:r}),(0,oe.jsxs)("span",{className:"text-zinc-300 font-mono",children:[o.toFixed(0),"%"]})]}),(0,oe.jsx)("div",{className:"h-2 rounded-full bg-zinc-800 overflow-hidden",children:(0,oe.jsx)("div",{className:`h-full rounded-full transition-all duration-700 ${s[n]||s.cyan}`,style:{width:`${o}%`}})})]})}function cj({status:t,label:e}){let r={online:"bg-emerald-500/10 border-emerald-500/20 text-emerald-400",offline:"bg-zinc-500/10 border-zinc-500/20 text-zinc-400",warning:"bg-amber-500/10 border-amber-500/20 text-amber-400",error:"bg-red-500/10 border-red-500/20 text-red-400"},n={online:"bg-emerald-400",offline:"bg-zinc-500",warning:"bg-amber-400",error:"bg-red-400"};return(0,oe.jsxs)("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full border text-[10px] font-semibold uppercase tracking-wider ${r[t]}`,children:[(0,oe.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${n[t]} ${t==="online"?"animate-pulse":""}`}),e||t]})}function dj({data:t,maxItems:e=6}){let r=Array.isArray(t)?t.slice(0,e):[];if(r.length===0)return(0,oe.jsx)("p",{className:"text-xs text-zinc-500 italic",children:"No events"});let n={pageload:"text-cyan-400",api:"text-blue-400",click:"text-emerald-400",session:"text-purple-400",error:"text-red-400"};return(0,oe.jsx)("div",{className:"space-y-0.5",children:r.map((o,s)=>(0,oe.jsxs)("div",{className:"flex items-center gap-2 text-xs py-1.5 px-2 rounded hover:bg-white/[0.02] transition-colors",children:[(0,oe.jsx)("span",{className:"text-zinc-600 font-mono text-[10px] w-16 shrink-0",children:o.time}),(0,oe.jsx)("span",{className:`text-[10px] font-bold uppercase tracking-wider w-16 shrink-0 ${n[o.type]||"text-zinc-500"}`,children:o.type}),(0,oe.jsx)("span",{className:"text-zinc-400 truncate",children:o.path}),o.duration>0&&(0,oe.jsxs)("span",{className:"ml-auto text-zinc-600 font-mono text-[10px] shrink-0",children:[o.duration,"ms"]})]},s))})}function uj({data:t}){let e=Array.isArray(t)?t:[];return e.length===0?(0,oe.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-emerald-900/10 rounded-lg border border-emerald-500/10",children:[(0,oe.jsx)("span",{className:"text-emerald-400 text-sm",children:"\u2713"}),(0,oe.jsx)("span",{className:"text-xs text-emerald-400",children:"No errors detected"})]}):(0,oe.jsx)("div",{className:"space-y-2",children:e.map((r,n)=>{let o=r.severity==="error";return(0,oe.jsxs)("div",{className:`p-3 rounded-lg border space-y-1 ${o?"bg-red-900/10 border-red-500/20":"bg-amber-900/10 border-amber-500/20"}`,children:[(0,oe.jsxs)("div",{className:"flex items-center justify-between",children:[(0,oe.jsx)("span",{className:`text-sm font-medium ${o?"text-red-400":"text-amber-400"}`,children:r.message}),(0,oe.jsx)("span",{className:"text-[10px] text-zinc-500",children:r.ago})]}),(0,oe.jsx)("div",{className:"text-xs text-zinc-500 font-mono",children:r.source})]},n)})})}function fj({data:t,color:e="cyan",height:r=32}){let n=Array.isArray(t)?t:[30,45,28,60,42,75,55,90,65,80],o=Math.max(...n),s=Math.min(...n),i=o-s||1,a=120,l=n.map((d,u)=>{let f=u/(n.length-1)*a,p=r-(d-s)/i*(r-4)-2;return`${f},${p}`}).join(" "),c={cyan:"#22d3ee",emerald:"#34d399",amber:"#fbbf24",red:"#f87171",blue:"#60a5fa"};return(0,oe.jsx)("svg",{width:a,height:r,className:"inline-block align-middle",children:(0,oe.jsx)("polyline",{points:l,fill:"none",stroke:c[e]||c.cyan,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}var Xr,ei,oe,fv,Wf,pv,hv,sj,ij,uR=U(()=>{"use strict";Xr=Re(require("react")),ei=require("lucide-react"),oe=require("react/jsx-runtime"),fv=class{data={};listeners=new Set;set(e,r){this.data[e]=r,this.listeners.forEach(n=>n())}resolve(e){let r=e.split("."),n=this.data;for(let o of r){if(n==null)return;n=n[o]}return n}merge(e){Object.assign(this.data,e),this.listeners.forEach(r=>r())}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}},Wf=new fv;Wf.merge({sentinel:{metrics:{eventsPerMin:1247,avgLatency:23,uptime:99.7,errorCount:2},events:[{time:"10:23:01",type:"pageload",path:"/dashboard",duration:142},{time:"10:22:58",type:"api",path:"/api/nodes",duration:89},{time:"10:22:45",type:"click",path:"sidebar",duration:3},{time:"10:22:30",type:"session",path:"user:admin",duration:0}],errors:[{message:"TypeError: Cannot read properties of undefined",source:"IssueList.tsx:11:39",ago:"3 min",severity:"error"},{message:"Warning: defaultProps deprecated",source:"recharts.js:28626",ago:"15 min",severity:"warning"}],sessions:{today:3,recording:!0}}});pv=class{iframe=null;handlers=new Map;themeObserver=null;attach(e){this.iframe=e,window.addEventListener("message",this.onMessage),this.themeObserver=new MutationObserver(()=>{let r=document.documentElement.classList.contains("dark");this.emit("theme:changed",r?"dark":"light")}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})}detach(){window.removeEventListener("message",this.onMessage),this.themeObserver?.disconnect(),this.themeObserver=null,this.iframe=null}onRequest(e,r){this.handlers.set(e,r)}emit(e,r){this.iframe?.contentWindow?.postMessage({type:"DECIDO_HOST_EVENT",topic:e,payload:r},"*")}onMessage=e=>{if(!this.iframe||e.source!==this.iframe.contentWindow)return;let r=e.data;if(r?.type==="DECIDO_PLUGIN_REQUEST"&&r.action){let n=this.handlers.get(r.action);if(n)try{let o=n(r.payload);o instanceof Promise?o.then(s=>this.respond(r.requestId,s)).catch(s=>this.respond(r.requestId,{error:String(s)})):this.respond(r.requestId,o)}catch(o){console.error("[Bridge] Handler error:",o),this.respond(r.requestId,{error:String(o)})}else console.warn(`[Bridge] No handler for action: ${r.action}`)}};respond(e,r){e&&this.iframe?.contentWindow?.postMessage({type:"DECIDO_PLUGIN_RESPONSE",requestId:e,payload:r},"*")}},hv=class extends Xr.default.Component{state={hasError:!1};static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,r){console.error(`[Widget:${this.props.widgetId}] Crash:`,e,r)}render(){return this.state.hasError?(0,oe.jsxs)("div",{className:"w-full h-full flex flex-col items-center justify-center bg-surface-primary gap-3 p-6",children:[(0,oe.jsx)("div",{className:"w-14 h-14 rounded-2xl bg-red-500/10 border border-red-500/20 flex items-center justify-center",children:(0,oe.jsx)(ei.AlertTriangle,{className:"w-7 h-7 text-red-400"})}),(0,oe.jsx)("p",{className:"text-sm font-semibold text-text-primary",children:"Widget Crashed"}),(0,oe.jsx)("p",{className:"text-xs text-text-muted text-center max-w-[280px] font-mono bg-surface-glass px-3 py-2 rounded-lg",children:this.state.error?.message||"Unknown error"}),(0,oe.jsx)("button",{onClick:()=>{this.setState({hasError:!1,error:void 0}),this.props.onReset?.()},className:"px-4 py-1.5 rounded-lg text-xs font-medium bg-surface-glass hover:bg-surface-elevated border border-border-subtle transition-colors",children:"Retry"})]}):this.props.children}};sj=new Set(["div","span","p","h1","h2","h3","h4","h5","h6","button","a","img","ul","ol","li","table","thead","tbody","tr","th","td","form","input","textarea","select","option","label","section","article","nav","header","footer","main","aside"]),ij={MetricCard:aj,ProgressBar:lj,StatusBadge:cj,EventList:dj,ErrorList:uj,Sparkline:fj}});var pR={};Mo(pR,{WidgetSlotPanel:()=>hj,pluginWidgetStore:()=>mn});function pj(){let[,t]=Gf.default.useReducer(e=>e+1,0);return Gf.default.useEffect(()=>mn.subscribe(t),[]),{widgets:mn.getVisible(),activeId:mn.activeId}}function hj(){let{widgets:t,activeId:e}=pj(),r=e&&t.find(s=>s.id===e)||t[0],n=Gf.default.useCallback(s=>{mn.remove(s),mn.size===0&&ke.getState().setSlot("R3",null)},[]),o=Gf.default.useCallback(()=>{mn.clear(),ke.getState().setSlot("R3",null)},[]);return t.length===0?(0,Bo.jsxs)("div",{className:"w-full h-full flex flex-col items-center justify-center text-text-muted gap-3 bg-surface-primary",children:[(0,Bo.jsx)("div",{className:"w-12 h-12 rounded-xl bg-cyan-500/5 border border-cyan-500/10 flex items-center justify-center",children:(0,Bo.jsx)("span",{className:"text-xl",children:"\u{1F9E9}"})}),(0,Bo.jsx)("p",{className:"text-sm font-medium",children:"No widgets activos"}),(0,Bo.jsx)("p",{className:"text-xs opacity-60 max-w-[200px] text-center",children:"Selecciona un plugin del sidebar para ver widgets aqu\xED"})]}):(0,Bo.jsxs)("div",{className:"w-full h-full flex flex-col bg-surface-primary overflow-hidden",children:[(0,Bo.jsxs)("div",{className:"flex-none flex items-center gap-1 px-2 py-1 bg-surface-secondary border-b border-border-subtle overflow-x-auto",children:[t.map(s=>(0,Bo.jsxs)("button",{onClick:()=>mn.setActive(s.id),className:`px-2.5 py-1 rounded-md text-[10px] font-medium transition-all whitespace-nowrap ${r?.id===s.id?"bg-surface-glass text-text-primary border border-border-default":"text-text-muted hover:text-text-secondary hover:bg-surface-glass/50"}`,children:[s.icon&&(0,Bo.jsx)("span",{className:"mr-1",children:s.icon}),s.title]},s.id)),t.length>1&&(0,Bo.jsx)("button",{onClick:o,className:"ml-auto px-2 py-1 rounded-md text-[10px] text-text-muted hover:text-red-400 hover:bg-red-500/10 transition-all",title:"Close all widgets",children:"\u2715 All"})]}),r&&(0,Bo.jsx)("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden",children:(0,Bo.jsx)(lR,{widget:r,onClose:()=>n(r.id)})})]})}var Gf,Bo,fR,mv,mn,gv=U(()=>{"use strict";Gf=Re(require("react"));uR();Qn();Bo=require("react/jsx-runtime"),fR="decido:activeWidgets",mv=class{widgets=new Map;listeners=new Set;_activeId=null;persistTimer=null;register(e){this.widgets.set(e.id,{...e,visible:e.visible??!0}),this.notify(),this.persist()}remove(e){this.widgets.delete(e),this._activeId===e&&(this._activeId=null),this.notify(),this.persist()}clear(){this.widgets.clear(),this._activeId=null,this.notify(),this.persist()}setActive(e){this._activeId=e,this.notify(),this.persist()}get activeId(){return this._activeId}get size(){return this.widgets.size}getVisible(){return Array.from(this.widgets.values()).filter(e=>e.visible!==!1).sort((e,r)=>(e.order??100)-(r.order??100))}restoreFromPersistence(e){try{let r=localStorage.getItem(fR);if(!r)return!1;let n=JSON.parse(r);if(!n?.widgets?.length)return!1;for(let o of n.widgets){let s=e(o.id);this.widgets.set(o.id,{...o,visible:!0,schema:s})}return this._activeId=n.activeId,this.notify(),console.log(`[WidgetStore] Restored ${n.widgets.length} widgets from persistence`),!0}catch(r){return console.warn("[WidgetStore] Restore failed:",r),!1}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.listeners.forEach(e=>e())}persist(){this.persistTimer&&clearTimeout(this.persistTimer),this.persistTimer=setTimeout(()=>{try{let e={widgets:Array.from(this.widgets.values()).map(r=>({id:r.id,pluginId:r.pluginId,title:r.title,icon:r.icon,slot:r.slot,url:r.url,order:r.order})),activeId:this._activeId};localStorage.setItem(fR,JSON.stringify(e))}catch{}},300)}},mn=new mv;window.__pluginWidgetStore=mn});var M4=aN((cme,xa)=>{"use strict";function tw(){return xa.exports=tw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},xa.exports.__esModule=!0,xa.exports.default=xa.exports,tw.apply(null,arguments)}xa.exports=tw,xa.exports.__esModule=!0,xa.exports.default=xa.exports});var P4=aN((dme,sp)=>{"use strict";function SU(t,e){if(t==null)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.indexOf(n)!==-1)continue;r[n]=t[n]}return r}sp.exports=SU,sp.exports.__esModule=!0,sp.exports.default=sp.exports});var ce={};Mo(ce,{AIDirector:()=>W0,AgentPlayer:()=>XS,AppHeader:()=>ju,AppShell:()=>ZB,ArtifactBar:()=>rm,BUILT_IN_PRESETS:()=>Ki,DebugPanel:()=>Qu,DecidoPlayer:()=>YS,DecidoShell:()=>th,EventBus:()=>_z,GlobalOverlays:()=>_0,LayoutConfigurator:()=>hh,LayoutGrid:()=>wg,MarketplaceWidget:()=>Gz,McpToolsWidget:()=>Zz,MorphShell:()=>nf,NetworkProvider:()=>Dl,OpsDashboard:()=>Jz,PanelSplitter:()=>SN,PluginErrorBoundary:()=>_l,SafeLiquidUI:()=>$z,ShellPluginProvider:()=>V0,SlotRenderer:()=>ti,THEME_DECIDO_DARK:()=>Y0,THEME_DECIDO_LIGHT:()=>GN,THEME_EMERALD_NOIR:()=>jN,THEME_MIDNIGHT_BLUE:()=>VN,THEME_OLED_PURE:()=>UN,THEME_PRESETS:()=>$u,THEME_ROSE_GOLD:()=>WN,TabBar:()=>vg,TransientLayer:()=>Lz,bridgeToMorph:()=>Ul,detectShellType:()=>v2,getAvailableSlotComponents:()=>mR,getMorphComponent:()=>vd,getMorphComponentCompat:()=>TC,getRegisteredMorphComponents:()=>px,getRegisteredShellTypes:()=>pd,getShellMeta:()=>Hl,initBridgeAgent:()=>ON,isShellRegistered:()=>kC,registerMorphComponent:()=>N$,registerMorphComponentCompat:()=>EC,registerShell:()=>yi,registerSlotComponent:()=>hR,registerStore:()=>q0,resolveColor:()=>yh,resolveColorClasses:()=>mC,resolveIcon:()=>xh,resolveShell:()=>Pa,useAutoUpdater:()=>Uz,useDebugPanelStore:()=>Ut,useGeminiStream:()=>WB,useIntentLens:()=>Uu,useKeyboardShortcuts:()=>Fz,useLayoutStore:()=>ke,useMcpStore:()=>$0,useMorphInstanceStore:()=>Ue,useMorphologyStore:()=>_t,useNetwork:()=>ed,useNetworkEvent:()=>B0,usePlaygroundStore:()=>X,usePluginContext:()=>xN,usePluginEngine:()=>Hz,usePluginState:()=>Oz,useShellKeyboard:()=>om,useShellStore:()=>_r,useSystemBoot:()=>jz,useTheme:()=>mi,useUIComponentStore:()=>Mn,useUpdaterStore:()=>F0});module.exports=Rz(ce);Ol();var uN=require("zustand"),z0=require("@decido/kernel-bridge"),fN=require("@decido/sentinel-browser"),_r=(0,uN.create)()((0,fN.sentinelMiddleware)("shell_store",t=>({plugins:new Map,widgets:new Map,activeShellMode:"workbench",setShellMode:e=>t({activeShellMode:e}),rootLayout:null,activeWidgetId:null,workspaces:[],activeWorkspaceId:null,transientOverlays:[],isCommandPaletteOpen:!1,isForgeTerminalOpen:!1,isGodModePanelOpen:!1,isMarketplaceOpen:!1,isShortcutSettingsOpen:!1,savedScenes:{},widgetDataBus:{},setWidgetData:(e,r)=>t(n=>({widgetDataBus:{...n.widgetDataBus,[e]:r}})),isThinClient:!1,initializeEnvironment:async()=>{try{if(!(typeof window<"u"&&"__TAURI_INTERNALS__"in window)){console.log("[OS] Web Environment Detected (No Tauri). Running in standard browser mode."),t({isThinClient:!1});return}let n=await(await import("@tauri-apps/plugin-os")).type(),o=n==="android"||n==="ios";t({isThinClient:o}),console.log(`[OS] Entorno detectado: ${o?"M\xF3vil (Thin Client)":"Desktop (Node)"}`),o&&z0.kernel.execute("broadcast_message",{intent:"node_announcement",payload:JSON.stringify({tier:"Satellite",capabilities:["voice","display"]})}),z0.kernel.onEvent(async s=>{if(s.event_type==="broadcast_event"&&s.data?.intent==="push_notification"){let{title:i,body:a,urgency:l}=s.data.payload;try{let c=await import("@tauri-apps/plugin-notification"),d=await c.isPermissionGranted();d||(d=await c.requestPermission()==="granted"),d&&(c.sendNotification({title:i,body:a,icon:"notification_icon",sound:l==="critical"?"alarm":"default"}),console.log(`[Satellite] \u{1F514} Alerta recibida de ${s.agent_id}: ${i}`))}catch(c){console.warn("Failed to send tauri notification",c)}}})}catch(e){console.warn("[OS] No se pudo detectar el entorno Tauri, asumiendo Desktop",e)}},registerPlugin:e=>t(r=>{let n=e.id||e.manifest?.id;if(!n)return r;let o=new Map(r.plugins);o.set(n,e);let s=new Map(r.widgets);if((e.widgets||e.manifest?.widgets||[]).forEach(a=>{let l={...a,pluginId:n};s.set(l.id,l)}),e.onRegister)try{Promise.resolve(e.onRegister()).catch(a=>console.error(`[OS] Failed to async-register plugin ${n}:`,a))}catch(a){console.error(`[OS] Failed to sync-register plugin ${n}:`,a)}if(e.mount&&e.manifest&&typeof window<"u")try{e.mount({})}catch(a){console.error(`[OS] Failed to mount plugin ${n}`,a)}return{plugins:o,widgets:s}}),unregisterPlugin:e=>t(r=>{let n=new Map(r.plugins),o=n.get(e);if(o){let s=new Map(r.widgets);if((o.widgets||o.manifest?.widgets||[]).forEach(a=>s.delete(a.id)),o.onUnregister)try{Promise.resolve(o.onUnregister()).catch(a=>console.error(`[OS] Failed to async-unregister plugin ${e}:`,a))}catch(a){console.error(`[OS] Failed to sync-unregister plugin ${e}:`,a)}return n.delete(e),{plugins:n,widgets:s}}return r}),openTransientOverlay:e=>{let r=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Date.now().toString()+Math.random().toString(36).substring(2);return t(n=>({transientOverlays:[...n.transientOverlays,{...e,id:r}]})),r},closeTransientOverlay:e=>{t(r=>({transientOverlays:r.transientOverlays.filter(n=>n.id!==e)}))},setCommandPaletteOpen:e=>{t({isCommandPaletteOpen:e})},setForgeTerminalOpen:e=>{t({isForgeTerminalOpen:e})},setGodModePanelOpen:e=>{t({isGodModePanelOpen:e})},setMarketplaceOpen:e=>{t({isMarketplaceOpen:e})},setShortcutSettingsOpen:e=>{t({isShortcutSettingsOpen:e})},setLayout:e=>{if(typeof document<"u"&&"startViewTransition"in document){let r=document.startViewTransition(()=>{t({rootLayout:e})});r.ready&&r.ready.catch(()=>{}),r.finished&&r.finished.catch(()=>{}),r.updateCallbackDone&&r.updateCallbackDone.catch(()=>{})}else t({rootLayout:e})},addWorkspace:e=>{t(r=>r.workspaces.find(o=>o.id===e.id)?r:{workspaces:[...r.workspaces,e]})},setActiveWorkspace:e=>{t(r=>{let n=r.workspaces.find(o=>o.id===e);if(!n)return r;if(typeof document<"u"&&"startViewTransition"in document){let o=document.startViewTransition(()=>{t({rootLayout:n.layout,activeWorkspaceId:e})});return o.ready&&o.ready.catch(()=>{}),o.finished&&o.finished.catch(()=>{}),o.updateCallbackDone&&o.updateCallbackDone.catch(()=>{}),r}else return{rootLayout:n.layout,activeWorkspaceId:e}})},saveScene:e=>{t(r=>{if(!r.rootLayout)return r;let n=JSON.parse(JSON.stringify(r.rootLayout));return{savedScenes:{...r.savedScenes,[e]:n}}})},loadScene:e=>{t(r=>{let n=r.savedScenes[e];if(!n)return r;if(typeof document<"u"&&"startViewTransition"in document){let o=document.startViewTransition(()=>{t({rootLayout:JSON.parse(JSON.stringify(n))})});return o.ready&&o.ready.catch(()=>{}),o.finished&&o.finished.catch(()=>{}),o.updateCallbackDone&&o.updateCallbackDone.catch(()=>{}),r}else return{rootLayout:JSON.parse(JSON.stringify(n))}})},requestCapability:e=>{let r=[];return _r.getState().widgets.forEach(n=>{n.capabilities?.includes(e)&&r.push(n)}),r},openWidgetByCapability:(e,r)=>{let n=_r.getState(),o=n.requestCapability(e);if(o.length===0)return!1;let s=o[0],i=s.layoutConfig?.preferredZone||"overlay";return i==="overlay"?(n.openTransientOverlay({widgetId:s.id,position:{x:typeof window<"u"?window.innerWidth/2-200:100,y:typeof window<"u"?window.innerHeight/2-150:100,width:s.layoutConfig?.initialSize?.w||400,height:s.layoutConfig?.initialSize?.h||300},props:{context:{renderMode:r?.renderMode||"expanded",data:r?.data}}}),!0):(console.warn(`[Shell OS] Morphological view requested for capability ${e} in zone ${i}, but only 'overlay' is currently implemented for Intent-Based Registry.`),!1)}})));de(ce,require("@decido/shell-auth"),module.exports);de(ce,require("@decido/plugin-engine"),module.exports);var hN=require("zustand"),mN="macia_mcp_servers",Dz=()=>{try{let t=localStorage.getItem(mN);if(t){let e=JSON.parse(t);if(Array.isArray(e))return e}}catch(t){console.error("[McpStore] Failed to parse persisted MCP servers",t)}return[]},pN=t=>{try{localStorage.setItem(mN,JSON.stringify(t))}catch(e){console.error("[McpStore] Failed to persist MCP servers",e)}},$0=(0,hN.create)()(t=>({mcpServers:Dz(),addMcpServer:e=>t(r=>{let n=[...r.mcpServers.filter(o=>o.name!==e.name),{...e,isConnected:!1}];return pN(n),{mcpServers:n}}),removeMcpServer:e=>t(r=>{let n=r.mcpServers.filter(o=>o.name!==e||o.isDefault);return pN(n),{mcpServers:n}}),setMcpServerStatus:(e,r)=>t(n=>({mcpServers:n.mcpServers.map(o=>o.name===e?{...o,isConnected:r}:o)}))}));var gN=require("zustand"),F0=(0,gN.create)((t,e)=>({isUpdating:!1,status:"idle",progress:0,downloadedBytes:0,totalBytes:0,version:null,error:null,setChecking:()=>t({status:"checking",error:null}),setDownloading:(r,n)=>t({isUpdating:!0,status:"downloading",version:r,totalBytes:n,downloadedBytes:0,progress:0}),updateProgress:r=>{let n=e().totalBytes,o=e().downloadedBytes+r,s=n>0?Math.min(Math.round(o/n*100),100):0;t({downloadedBytes:o,progress:s})},setInstalling:()=>t({status:"installing",progress:100}),setRebooting:()=>t({status:"rebooting"}),setError:r=>t({status:"error",error:r,isUpdating:!1}),reset:()=>t({isUpdating:!1,status:"idle",progress:0,downloadedBytes:0,totalBytes:0,version:null,error:null})}));var td=require("react");var yN=require("react/jsx-runtime"),H0=class{state={};listeners=new Set;set(e,r){this.state={...this.state,[e]:r},this.listeners.forEach(n=>n())}get(e,r){return e in this.state?this.state[e]:r}getSnapshot(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}},ah=new Map,bN=(0,td.createContext)(null);function V0({pluginId:t,children:e}){let r=_r(d=>d.plugins),n=_r(d=>d.openTransientOverlay),o=_r(d=>d.closeTransientOverlay);ah.has(t)||ah.set(t,new H0);let s=ah.get(t),i=(d,u)=>{s.set(d,u)},a=(d,u)=>s.get(d,u),l=(d,u)=>{n({widgetId:d,position:u})},c={pluginId:t,pluginDetails:r.get(t),setContextState:i,getContextState:a,openOverlay:l,closeOverlay:o};return(0,yN.jsx)(bN.Provider,{value:c,children:e})}function xN(){let t=(0,td.useContext)(bN);if(!t)throw new Error("usePluginContext must be used within a ShellPluginProvider. Only call this inside MaciaWidgets components.");return t}function Oz(t,e){let r=xN(),n=ah.get(r.pluginId);if(!n)throw new Error("Plugin store not initialized");let o=(0,td.useSyncExternalStore)(a=>n.subscribe(a),()=>n.getSnapshot()),s=t in o?o[t]:e;return[s,a=>{if(typeof a=="function"){let l=a;r.setContextState(t,l(s))}else r.setContextState(t,a)}]}var j0=require("@decido/logger"),_z={listeners:new Map,emit(t,e){let r=this.listeners.get(t)?.size??0;(0,j0.probe)("eventbus.emit",{event:t,listenerCount:r},{level:"debug",context:{module:"shell",component:"EventBus"}}),this.listeners.get(t)?.forEach(n=>n(e))},subscribe(t,e){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e),(0,j0.probe)("eventbus.subscribe",{event:t,totalListeners:this.listeners.get(t).size},{level:"debug",context:{module:"shell",component:"EventBus"}}),()=>{let r=this.listeners.get(t);r&&r.delete(e)}}};var W0=class{static async processQuery(e){let{plugins:r}=_r.getState(),n=[];r.forEach(o=>{o.intents&&n.push(...o.intents)});for(let o of n){let s=e.match(o.match.pattern);if(s){console.log(`[AIDirector] Intent Matched: ${o.name}`);try{return await o.handler(s),!0}catch(i){throw console.error(`[AIDirector] Error handling intent ${o.name}:`,i),i}}}return console.log(`[AIDirector] No specific intent matched for: "${e}". Delegating to general AI layer.`),await this.delegateToGeneralAI(e),!1}static getSuggestedIntents(){let{plugins:e}=_r.getState(),r=[];return e.forEach(n=>{n.intents&&n.intents.forEach(o=>{r.push({pluginName:n.name||n.manifest?.name||"Unknown Plugin",intentName:o.name,description:o.match.description,examples:o.match.examples||[]})})}),r}static async delegateToGeneralAI(e){console.log(`[AIDirector Fallback] Processing general request: ${e}`)}};var wN=Re(require("react"));var vN=Re(require("react")),lh=require("lucide-react"),hs=require("react/jsx-runtime"),_l=class extends vN.default.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,r){console.error(`\u{1F6A8} [Plugin Error Boundary] Plugin ${this.props.pluginName||this.props.pluginId||"Unknown"} crashed:`,e,r)}resetBoundary=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?(0,hs.jsxs)("div",{className:"w-full h-full flex flex-col items-center justify-center p-6 bg-red-950/10 border border-red-500/20 rounded-xl m-2 backdrop-blur-xs relative overflow-hidden",children:[(0,hs.jsx)("div",{className:"absolute top-0 left-0 w-full h-1 bg-linear-to-r from-red-500/50 to-orange-500/50"}),(0,hs.jsx)(lh.AlertTriangle,{className:"w-12 h-12 text-red-400 mb-4 opacity-80"}),(0,hs.jsx)("h3",{className:"text-lg font-bold text-red-200 mb-2 text-center text-balance",children:"Plugin Crashed"}),(0,hs.jsxs)("p",{className:"text-sm text-red-300/70 text-center mb-6 max-w-sm",children:["The plugin ",(0,hs.jsx)("span",{className:"text-red-200 font-mono bg-red-900/40 px-1 py-0.5 rounded",children:this.props.pluginName||this.props.pluginId||"unknown"})," encountered an unexpected runtime error. The core OS remains stable."]}),this.state.error&&(0,hs.jsx)("div",{className:"w-full bg-surface-overlay p-3 rounded-lg border border-red-900/30 mb-6 overflow-auto max-h-24",children:(0,hs.jsx)("code",{className:"text-xs text-red-400 font-mono whitespace-pre-wrap break-all",children:this.state.error.toString()})}),(0,hs.jsxs)("button",{onClick:this.resetBoundary,className:"flex items-center gap-2 px-4 py-2 bg-red-500/10 hover:bg-red-500/20 active:bg-red-500/30 text-red-300 border border-red-500/30 rounded-lg transition-colors text-sm font-medium",children:[(0,hs.jsx)(lh.RefreshCw,{className:"w-4 h-4"}),"Reload Plugin"]})]}):this.props.children}};var Fn=require("react/jsx-runtime"),SN=({node:t,isRoot:e=!1})=>{let r=_r(i=>i.rootLayout),n=_r(i=>i.widgets),o=t||(e?r:void 0);if(!o)return(0,Fn.jsx)("div",{className:"flex-1 flex items-center justify-center text-text-primary/30 text-sm italic h-full w-full",children:"No active layout topology"});if(o.type==="widget"&&o.widgetId){let i=n.get(o.widgetId);if(!i)return(0,Fn.jsxs)("div",{className:"text-red-500 p-4 bg-surface-glass",children:["Widget '",o.widgetId,"' not found."]});let a=i.component;return(0,Fn.jsxs)("div",{className:"w-full h-full relative overflow-hidden bg-surface-overlay backdrop-blur-md border border-border-subtle rounded-2xl shadow-xl flex flex-col",children:[(0,Fn.jsx)("div",{className:"flex-none px-4 py-2 border-b border-border-default bg-linear-to-r from-white/5 to-transparent",children:(0,Fn.jsx)("span",{className:"text-xs font-semibold text-text-primary/70 uppercase tracking-wider",children:i.name})}),(0,Fn.jsx)("div",{className:"flex-1 overflow-auto relative",children:(0,Fn.jsx)(V0,{pluginId:i.pluginId,children:a?(0,Fn.jsx)(_l,{pluginName:i.name,pluginId:i.pluginId,children:(0,Fn.jsx)(wN.default.Suspense,{fallback:(0,Fn.jsx)("div",{className:"text-text-primary/50 p-4 text-center",children:"Loading Remote Plugin..."}),children:(0,Fn.jsx)(a,{...i.defaultProps||{}})})}):(0,Fn.jsx)("div",{className:"text-text-primary/50 p-4 text-center",children:"Component Not Renderable"})})})]})}let s=o.type==="split-vertical";return(0,Fn.jsx)("div",{className:`flex w-full h-full gap-4 ${s?"flex-col":"flex-row"}`,children:o.children?.map((i,a)=>(0,Fn.jsx)("div",{className:"shrink grow",style:{flexBasis:i.size?`${i.size}%`:"auto"},children:(0,Fn.jsx)(SN,{node:i})},i.id||a))})};var NN=Re(require("react"));var Go=require("react/jsx-runtime"),Lz=()=>{let t=_r(n=>n.transientOverlays),e=_r(n=>n.widgets),r=_r(n=>n.closeTransientOverlay);return t.length===0?null:(0,Go.jsx)("div",{className:"fixed inset-0 z-100 pointer-events-none",children:t.map(n=>{let o=e.get(n.widgetId);if(!o)return null;let s=o.component,i=16,a=72,l=n.position.width||400,c=n.position.height||300,d=n.position.x,u=n.position.y;if(typeof window<"u"){let f=window.innerWidth-a-i,p=window.innerHeight-i*2;l>f&&(l=f),c>p&&(c=p);let h=window.innerWidth-l-i,b=window.innerHeight-c-i;d<a&&(d=a),d>h&&(d=h),u<i&&(u=i),u>b&&(u=b)}return(0,Go.jsxs)("div",{className:"absolute shadow-2xl rounded-2xl overflow-hidden glass-panel border border-border-default pointer-events-auto animate-in fade-in zoom-in-95 duration-200",style:{left:d,top:u,width:l,height:c},children:[(0,Go.jsxs)("div",{className:"flex justify-between items-center px-4 py-2 bg-surface-overlay border-b border-border-subtle backdrop-blur-md",children:[(0,Go.jsx)("span",{className:"text-xs font-semibold text-text-primary/70",children:o.name}),(0,Go.jsx)("button",{onClick:()=>r(n.id),className:"w-4 h-4 rounded-full bg-red-500/80 hover:bg-red-500 flex items-center justify-center transition-colors"})]}),(0,Go.jsx)("div",{className:"p-4 bg-surface-overlay backdrop-blur-xl h-full w-full",children:s?(0,Go.jsx)(_l,{pluginName:o.name,pluginId:o.pluginId,children:(0,Go.jsx)(NN.default.Suspense,{fallback:(0,Go.jsx)("div",{className:"text-text-primary/50 p-4 text-center",children:"Loading Floating Plugin..."}),children:(0,Go.jsx)(s,{...o.defaultProps||{},...n.props||{}})})}):(0,Go.jsx)("div",{className:"text-text-primary/50 text-center w-full h-full flex items-center justify-center",children:"No Component"})})]},n.id)})})};var ch=Re(require("react")),U0=require("@decido/kernel-bridge"),CN=Re(require("clsx")),kN=require("tailwind-merge"),G0=require("react/jsx-runtime"),Bz=["div","span","p","button","input","h1","h2","h3","h4","h5","h6","img","a","ul","ol","li","section","article","aside","header","footer","nav","main","figure","figcaption","blockquote","hr","br","b","i","u","s","em","strong","small","sub","sup","mark","del","ins","kbd","samp","var","code","pre","q","cite","dfn","abbr","time","address","ruby","rt","rp","bdi","bdo","wbr","table","caption","colgroup","col","tbody","thead","tfoot","tr","td","th"],zz=(...t)=>(0,kN.twMerge)((0,CN.default)(t)),$z=({uiSchema:t,missionData:e,tenantId:r})=>{let n=(0,ch.useMemo)(()=>{if(!t)return null;if(typeof t=="object")return t;try{return JSON.parse(t)}catch(i){return console.error("[Server-Driven UI] Failed to parse schema:",i),null}},[t]),o=async(i,a)=>{try{await U0.kernel.execute(r,i,{...a,__missionContext:e})}catch(l){console.error("[Server-Driven UI] RPC Execution Failed:",l),U0.kernel.injectEvent({type:"system_alert",source:"SafeLiquidUI",payload:{level:"error",title:"Action Failed",message:String(l)}})}},s=(i,a)=>{if(typeof i=="string")return i;if(!i||!i.type)return null;let l=Bz.includes(i.type)?i.type:"div",c={...i.props,key:a};if(c.className&&(c.className=zz(c.className)),i.onAction&&i.onAction.command){let u=l==="input"?"onChange":"onClick";c[u]=f=>{f&&typeof f.preventDefault=="function"&&(f.preventDefault(),f.stopPropagation());let p=f?.target?.value,h=p!==void 0?{...i.onAction?.payload,value:p}:i.onAction?.payload;o(i.onAction.command,h)}}let d=null;return Array.isArray(i.children)?d=i.children.map((u,f)=>s(u,f)):typeof i.children=="string"&&(d=i.children.replace(/\{\{\s*([a-zA-Z0-9_.]+)\s*\}\}/g,(u,f)=>{let p=f.split("."),h={missionData:e};for(let b of p)if(h&&typeof h=="object"&&b in h)h=h[b];else return u;return String(h)})),ch.default.createElement(l,c,d)};return n?(0,G0.jsx)("div",{className:"w-full h-full overflow-y-auto custom-scrollbar",children:s(n)}):(0,G0.jsx)("div",{className:"w-full h-full flex items-center justify-center bg-surface-primary/50 backdrop-blur border border-border-subtle rounded-xl p-8 text-text-muted font-mono text-xs",children:"Waiting for Server-Driven UI Schema..."})};var EN=require("react");var dh=require("@decido/commands"),Fz=()=>{let t=(0,dh.useCommandRegistry)(r=>r.registerCommand),e=(0,dh.useShortcutManager)(r=>r.registerDefaultShortcut);(0,EN.useEffect)(()=>{t({id:"shell.toggleCommandPalette",title:"Toggle Command Palette",category:"Shell",handler:()=>{let r=_r.getState();r.setCommandPaletteOpen(!r.isCommandPaletteOpen)}}),e("shell.toggleCommandPalette","$mod+k"),t({id:"shell.openShortcutSettings",title:"Configurar Atajos",category:"Shell",handler:()=>{let r=_r.getState();r.setShortcutSettingsOpen(!r.isShortcutSettingsOpen)}}),e("shell.openShortcutSettings","$mod+Shift+K"),t({id:"shell.toggleForgeTerminal",title:"Toggle Forge Terminal",category:"Shell",handler:()=>{let r=_r.getState();r.setForgeTerminalOpen(!r.isForgeTerminalOpen)}}),e("shell.toggleForgeTerminal","$mod+j"),t({id:"shell.toggleGodMode",title:"Toggle God Mode",category:"Shell",handler:()=>{let r=_r.getState();r.setGodModePanelOpen(!r.isGodModePanelOpen)}}),e("shell.toggleGodMode","$mod+Shift+D"),t({id:"shell.closePanels",title:"Close Active Panels",category:"Shell",handler:()=>{let r=_r.getState();r.isCommandPaletteOpen&&r.setCommandPaletteOpen(!1),r.isForgeTerminalOpen&&r.setForgeTerminalOpen(!1),r.isGodModePanelOpen&&r.setGodModePanelOpen(!1)}}),e("shell.closePanels","Escape")},[t,e])};var TN=require("react"),IN=require("@noble/curves/ed25519.js"),Hz=({setRemote:t,getRemote:e,registry:r,publicKeyB64:n,onPluginLoaded:o,onMCPServerDiscovered:s,onSecurityAlert:i,onSidebarItemsRegistered:a})=>{(0,TN.useEffect)(()=>{let l=async(c,d,u,f)=>{try{if(f&&f!=="offline_or_invalid_signature"){console.info(`\u{1F512} [Security] Verifying Cryptographic Signature for ${c}...`);try{let g=await fetch(d);if(!g.ok)throw new Error("Could not fetch remote bundle for verification");let x=await g.text();if(!n){console.error(`\u{1F6A8} [Security Breach] No public key provided to verify ${c}. Halting execution.`),i&&i(c,"El host no provey\xF3 una llave p\xFAblica para verificar la firma criptogr\xE1fica.");return}let y=Uint8Array.from(atob(n),w=>w.charCodeAt(0)).slice(12),m=Uint8Array.from(atob(f),w=>w.charCodeAt(0)),v=new TextEncoder().encode(x);if(!IN.ed25519.verify(m,v,y)){console.error(`\u{1F6A8} [Security Breach] Invalid signature for ${c}. Halting execution.`),i&&i(c,"El plugin ha sido modificado en tr\xE1nsito o no tiene firma v\xE1lida.");return}console.info(`\u2705 [Security] Signature verified for ${c}. Secure to execute.`)}catch(g){console.error(`\u{1F6A8} [Security] Failed to verify signature for ${c}:`,g),i&&i(c,"Fallo al verificar firma criptogr\xE1fica.");return}}else console.debug(`[Security] Loaded ${c} without a cryptographic signature (Local Dev Mode).`);t(c,{url:()=>Promise.resolve(`${d}?t=${Date.now()}`),format:"esm",from:"vite"});let p=async g=>g&&typeof g=="object"&&"default"in g?g.default:g,h=(g,x)=>{g&&g.widgets?(console.info(`\u{1F525} [Federation Marketplace] Registering Cortex: ${x} with ${g.widgets.length} widgets`),g.widgets=g.widgets.map(y=>{let m=y.component;if(m&&typeof m=="object"&&!m.$$typeof)try{let v=Object.keys(m);v.length>0&&typeof m[v[0]]=="function"?m=m[v[0]]:m.default&&(m=m.default)}catch(v){console.warn(`[Federation Marketplace] TDZ / Getter Exception unpacking component for ${y.name}:`,v)}return{...y,component:m}}),o(g,x),g.mcp_servers&&Array.isArray(g.mcp_servers)&&(console.info(`\u{1F50C} [Dynamic MCP] Discovered ${g.mcp_servers.length} MCP Servers in ${x}.`),s&&g.mcp_servers.forEach(y=>{s(y)})),g.sidebarItems&&Array.isArray(g.sidebarItems)&&a&&(console.info(`\u{1F4CC} [Sidebar] ${x} registered ${g.sidebarItems.length} sidebar items`),a(g.id||x,g.sidebarItems))):console.warn(`\u26A0\uFE0F [Federation Marketplace] Manifest ${x} is invalid or has no widgets`,g)},b=async g=>{try{let x=await e(c,u),y=await p(x);y.id&&y.widgets?(console.log(`[Plugin Injector] Setup Root Cortex: ${y.name}`),h(y,y.name)):y.default&&y.default.id&&y.default.widgets?(console.log(`[Plugin Injector] Setup Default Cortex: ${y.default.name}`),h(y.default,y.default.name)):(console.warn("[Plugin Injector] No raw CORTEX structure found at root, checking legacy namespaces..."),y.PlantaErpPlugin&&h(y.PlantaErpPlugin,"PlantaErpPlugin"),y.FrubealaUiPlugin&&h(y.FrubealaUiPlugin,"FrubealaUiPlugin"),y.ForgeCortex&&h(y.ForgeCortex,"ForgeCortex"),y.CommanderCortex&&h(y.CommanderCortex,"CommanderCortex"),y.BridgeCortex&&h(y.BridgeCortex,"BridgeCortex"))}catch(x){x instanceof ReferenceError&&g>0?(console.warn(`\u23F3 [Plugin Engine] TDZ ReferenceError dynamically loading ${c}, waiting 100ms... (${g} left)`),await new Promise(y=>setTimeout(y,100)),await b(g-1)):console.error(`\u274C [Federation Marketplace] Could not load Remote ${c} from ${d}:`,x)}};await b(10)}catch(p){console.error(`\u274C [Federation Marketplace] execution error resolving Remote ${c} from ${d}:`,p)}};for(let c of r)c.enabled&&c.url&&c.exposedModule&&l(c.name,c.url,c.exposedModule,c.signature)},[r,t,e,n,o,s,i,a])};var rd=require("react"),nd=require("@decido/kernel-bridge"),PN=require("@decido/plugin-engine");var AN=require("react"),K0=require("@decido/kernel-bridge"),Vz={},MN=()=>{(0,AN.useEffect)(()=>{if(Vz.env?.VITE_DECIDO_SAFE_MODE==="1"){console.log("\u{1F6E1}\uFE0F [Telemetry] Performance tracking disabled in Safe Mode");return}try{if("PerformanceObserver"in window){let t=new PerformanceObserver(r=>{for(let n of r.getEntries())n.duration>250&&(console.warn(`\u26A0\uFE0F [Telemetry] Long task detected! UI blocked for ${n.duration.toFixed(0)}ms`,n),K0.kernel.injectEvent({type:"system_alert",source:"telemetry_engine",payload:{level:"warning",title:"Performance Degradation",message:`A plugin or core component blocked the main thread for ${n.duration.toFixed(0)}ms.`,duration:n.duration}}))});t.observe({entryTypes:["longtask"]});let e=setInterval(()=>{let r=performance.memory;r&&r.usedJSHeapSize>r.jsHeapSizeLimit*.9&&(console.error("\u{1F6A8} [Telemetry] Critical Memory Warning! Heap > 90%"),K0.kernel.injectEvent({type:"system_alert",source:"telemetry_engine",payload:{level:"error",title:"Critical Memory Exhaustion",message:`V8 JS Heap is critically high (${(r.usedJSHeapSize/1024/1024).toFixed(0)}MB). The application might crash soon. Consider restarting plugins.`}}))},3e4);return()=>{t.disconnect(),clearInterval(e)}}}catch(t){console.warn("[Telemetry] PerformanceObserver not fully supported on this platform",t)}},[])};var Wz={},jz=({availableInstances:t=[],onAutoConnect:e})=>{let[r,n]=(0,rd.useState)(!1),[o,s]=(0,rd.useState)(!1),[i,a]=(0,rd.useState)(null);return MN(),(0,rd.useEffect)(()=>{let l=(0,PN.initPluginSecurityManager)();return(async()=>{try{let d=await nd.kernel.execute("get_settings").catch(()=>({})),u=Wz.env?.VITE_APP_VERSION||"1.0.0",f=localStorage.getItem("decido_app_version");if(f!==u&&(console.warn(`[Boot] Version mismatch detected (${f} -> ${u}). Purgando cach\xE9 para UI Refresh.`),await nd.kernel.execute("save_settings",{config:{gemini_api_key:d?.gemini_api_key||"",qdrant_url:d?.qdrant_url||"http://localhost:6334",qdrant_api_key:d?.qdrant_api_key||"",swarm_key:d?.swarm_key||null,setup_completed:!1,selected_instance_id:null}}),localStorage.setItem("decido_app_version",u),d.setup_completed=!1,d.selected_instance_id=null),d.setup_completed&&d.swarm_key&&await nd.StateRehydrationManager.rehydrate(d.swarm_key),d.setup_completed&&d.selected_instance_id){let p=t.find(h=>h.id===d.selected_instance_id);p&&(a(p),s(!0),e?e(p):nd.kernel.execute("connect_to_swarm",{redisUrl:p.ip}).catch(h=>{console.error("[Boot] Failed to auto-reconnect swarm:",h)}))}}catch(d){console.error("[Boot] Error during rehydration:",d)}finally{n(!0)}})(),()=>{l()}},[t,e]),{isRehydrated:r,setupComplete:o,setSetupComplete:s,selectedInstance:i,setSelectedInstance:a}};var RN=require("react"),DN=require("@decido/kernel-bridge");var Uz=({appName:t="Decido OS",onUpdateAvailable:e,onUpdateFinished:r,delayMs:n=4e3}={})=>{let o=F0();(0,RN.useEffect)(()=>{setTimeout(async()=>{if(!("__TAURI_INTERNALS__"in window)){console.info("[Updater] Ejecuci\xF3n en navegador detectada. Saltando buscar OTA de Tauri.");return}try{o.setChecking();let a=await(await import("@tauri-apps/plugin-updater")).check();if(a){console.info(`[Updater] Nueva versi\xF3n encontrada: ${a.version} (${a.date})`),e?e(a.version,a.date):DN.kernel.notify("\u{1F680} Actualizaci\xF3n Disponible",`Descargando silenci\xF3samente la versi\xF3n ${a.version}...`);let l=0,c=0;await a.downloadAndInstall(d=>{switch(d.event){case"Started":c=d.data.contentLength,o.setDownloading(a.version,c);break;case"Progress":o.updateProgress(d.data.chunkLength);break;case"Finished":console.info("[Updater] Descarga completada. Preparando reinicio."),o.setInstalling();break}}),r?r():(o.setRebooting(),setTimeout(async()=>{(await import("@tauri-apps/plugin-process")).relaunch()},3e3))}else o.reset()}catch(i){let a=i?.toString()||"";a.includes("url")||a.includes("404")||a.includes("offline")||a.includes("Could not fetch")||a.includes("fetch")||a.includes("network")||a.includes("ECONNREFUSED")?(console.info("[Updater] OTA no disponible \u2014 modo local/offline."),o.reset()):(console.error("[Updater] Fall\xF3 el escaneo de actualizaciones:",i),o.setError(a))}},n)},[t,e,r,n])};var Ll=[];function q0(t,e){Ll.find(r=>r.name===t)||Ll.push({name:t,store:e}),typeof window<"u"&&(window.__ZUSTAND_STORES__=window.__ZUSTAND_STORES__||{},window.__ZUSTAND_STORES__[t]=e)}function ON(){if(typeof window>"u"||window.__BRIDGE_AGENT__)return;console.log("[BridgeAgent] Initializing postMessage bridge v1.0...");let t=(l,c,d,u)=>{if(!(!c||!l))try{l.postMessage({jsonrpc:"2.0",id:c,result:d,error:u||null},"*")}catch{}},e=(l,c,d)=>{try{l.postMessage({jsonrpc:"2.0",method:c,params:d},"*")}catch{}},r=(l,c=0)=>{if(c>4)return"[max depth]";if(l==null)return l;if(typeof l=="function")return"[Function]";if(typeof l!="object")return l;if(Array.isArray(l))return l.slice(0,50).map(u=>r(u,c+1));if(l instanceof Map)return Object.fromEntries(Array.from(l.entries()).slice(0,50).map(([u,f])=>[String(u),r(f,c+1)]));if(l instanceof Set)return Array.from(l).slice(0,50).map(u=>r(u,c+1));let d={};for(let u of Object.keys(l).slice(0,100))d[u]=r(l[u],c+1);return d},n=l=>{if(l.id)return`#${l.id}`;let c=[],d=l;for(;d&&d!==document.body;){let u=d.tagName.toLowerCase();if(d.id){c.unshift(`#${d.id}`);break}if(d.className&&typeof d.className=="string"){let p=d.className.trim().split(/\s+/).filter(h=>!h.includes("/")).slice(0,2).join(".");p&&(u+=`.${p}`)}let f=d.parentElement;if(f){let p=Array.from(f.children).filter(h=>h.tagName===d.tagName);p.length>1&&(u+=`:nth-of-type(${p.indexOf(d)+1})`)}c.unshift(u),d=d.parentElement}return c.join(" > ")},o=!1,s=null,i=null,a=async l=>{let c=l.data;if(!c||c.jsonrpc!=="2.0"||!c.method)return;let{method:d,params:u,id:f}=c,p=l.source;try{switch(d){case"PING":case"HANDSHAKE":{t(p,f,{success:!0,version:"1.0.0",stores:Ll.map(h=>h.name),url:window.location.href,title:document.title});break}case"CLICK":{let h=document.querySelector(u.selector);if(!h)throw new Error(`Element not found: ${u.selector}`);h.click(),h.focus?.(),t(p,f,{success:!0});break}case"DBLCLICK":{let h=document.querySelector(u.selector);if(!h)throw new Error(`Element not found: ${u.selector}`);h.dispatchEvent(new MouseEvent("dblclick",{bubbles:!0})),t(p,f,{success:!0});break}case"TYPE":{let h=document.querySelector(u.selector);if(!h)throw new Error(`Element not found: ${u.selector}`);h.focus();let b=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set||Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set;b?b.call(h,u.value||""):h.value=u.value||"",h.dispatchEvent(new Event("input",{bubbles:!0})),h.dispatchEvent(new Event("change",{bubbles:!0})),t(p,f,{success:!0});break}case"CLEAR":{let h=document.querySelector(u.selector);if(!h)throw new Error(`Element not found: ${u.selector}`);h.value="",h.dispatchEvent(new Event("input",{bubbles:!0})),t(p,f,{success:!0});break}case"SELECT":{let h=document.querySelector(u.selector);if(!h)throw new Error(`Element not found: ${u.selector}`);h.value=u.value||"",h.dispatchEvent(new Event("change",{bubbles:!0})),t(p,f,{success:!0});break}case"HOVER":{let h=document.querySelector(u.selector);if(!h)throw new Error(`Element not found: ${u.selector}`);h.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0})),h.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0})),t(p,f,{success:!0});break}case"FOCUS":{let h=document.querySelector(u.selector);if(!h)throw new Error(`Element not found: ${u.selector}`);h.focus(),t(p,f,{success:!0});break}case"SCROLL":{u.selector?document.querySelector(u.selector)?.scrollIntoView({behavior:"smooth",block:"center"}):window.scrollTo({top:u.y||0,left:u.x||0,behavior:"smooth"}),t(p,f,{success:!0});break}case"KEYDOWN":case"KEYUP":case"KEYPRESS":{(u.selector?document.querySelector(u.selector):document.activeElement||document.body)?.dispatchEvent(new KeyboardEvent(d.toLowerCase(),{key:u.key,bubbles:!0})),t(p,f,{success:!0});break}case"NAVIGATE":{window.location.href=u.url||u.value||"/",t(p,f,{success:!0});break}case"RELOAD":{window.location.reload(),t(p,f,{success:!0});break}case"BACK":{window.history.back(),t(p,f,{success:!0});break}case"WAIT_FOR":{let h=u.timeout||5e3,b=Date.now(),g=()=>{document.querySelector(u.selector)?t(p,f,{success:!0}):Date.now()-b>h?t(p,f,null,{code:408,message:`Timeout waiting for: ${u.selector}`}):setTimeout(g,100)};g();break}case"ASSERT_EXISTS":{if(!document.querySelector(u.selector))throw new Error(`Assert failed: ${u.selector} not found`);t(p,f,{success:!0});break}case"ASSERT_TEXT":{let h=document.querySelector(u.selector);if(!h)throw new Error(`Assert failed: ${u.selector} not found`);let b=h.textContent?.trim();if(b!==u.expected&&b!==u.value)throw new Error(`Assert failed: expected "${u.expected||u.value}", got "${b}"`);t(p,f,{success:!0,text:b});break}case"ASSERT_VISIBLE":{let h=document.querySelector(u.selector);if(!h)throw new Error(`Assert failed: ${u.selector} not found`);let b=window.getComputedStyle(h);if(b.display==="none"||b.visibility==="hidden"||b.opacity==="0")throw new Error(`Assert failed: ${u.selector} not visible`);t(p,f,{success:!0});break}case"STORE_LIST":{let h=Ll.map(b=>{let g=b.store.getState(),x=Object.keys(g).filter(y=>typeof g[y]=="function");return{name:b.name,keys:Object.keys(g).length,methods:x.length}});t(p,f,{success:!0,stores:h});break}case"STORE_READ":{let h=Ll.find(y=>y.name===u.store||y.name===u.storeName);if(!h)throw new Error(`Store not found: ${u.store||u.storeName}`);let b=h.store.getState(),g=Object.keys(b).filter(y=>typeof b[y]=="function"),x=b;u.path&&(x=u.path.split(".").reduce((y,m)=>y?.[m],b)),t(p,f,{success:!0,name:h.name,state:r(b),methods:g,value:u.path?r(x):void 0});break}case"STORE_WRITE":{let h=Ll.find(g=>g.name===u.store||g.name===u.storeName);if(!h)throw new Error(`Store not found: ${u.store||u.storeName}`);let b=(u.path||"").split(".").filter(Boolean);if(b.length===0)throw new Error("Store path required");if(b.length===1)h.store.setState({[b[0]]:JSON.parse(u.value)});else{let g={...h.store.getState()},x=g;for(let y=0;y<b.length-1;y++)x=x[b[y]];x[b[b.length-1]]=JSON.parse(u.value),h.store.setState(g)}t(p,f,{success:!0});break}case"GET_HTML":{let h=document.querySelector(u.selector);t(p,f,{success:!0,html:h?.outerHTML||""});break}case"GET_COMPUTED_STYLE":{let h=document.querySelector(u.selector);if(!h)throw new Error(`Element not found: ${u.selector}`);let b=window.getComputedStyle(h),g=u.property||u.key?b.getPropertyValue(u.property||u.key):void 0;t(p,f,{success:!0,value:g});break}case"GET_INFO":{t(p,f,{success:!0,title:document.title,url:window.location.href,buttons:document.querySelectorAll("button").length,inputs:document.querySelectorAll("input").length,links:document.querySelectorAll("a").length});break}case"EVAL":{let h=window.eval(u.code);t(p,f,{success:!0,result:r(h)});break}case"RECORD_START":{if(o){t(p,f,{success:!1,error:"Already recording"});break}o=!0,i=p;let h=y=>{let m=y.target;m&&e(i,"bridge.recorded",{type:"click",selector:n(m),tagName:m.tagName,id:m.id,textContent:(m.textContent||"").slice(0,50),timestamp:Date.now()})},b=y=>{let m=y.target;!m||!["INPUT","TEXTAREA","SELECT"].includes(m.tagName)||e(i,"bridge.recorded",{type:m.tagName==="SELECT"?"select":"type",selector:n(m),value:m.value,tagName:m.tagName,timestamp:Date.now()})},g,x=()=>{clearTimeout(g),g=setTimeout(()=>{e(i,"bridge.recorded",{type:"scroll",x:window.scrollX,y:window.scrollY,timestamp:Date.now()})},300)};document.addEventListener("click",h,!0),document.addEventListener("input",b,!0),document.addEventListener("change",b,!0),window.addEventListener("scroll",x,!0),s=()=>{document.removeEventListener("click",h,!0),document.removeEventListener("input",b,!0),document.removeEventListener("change",b,!0),window.removeEventListener("scroll",x,!0)},t(p,f,{success:!0});break}case"RECORD_STOP":{s&&s(),o=!1,s=null,i=null,t(p,f,{success:!0});break}default:t(p,f,null,{code:-32601,message:`Unknown method: ${d}`})}}catch(h){t(p,f,null,{code:500,message:h.message||String(h)})}};window.addEventListener("message",a),window.__BRIDGE_AGENT__={version:"1.0.0",storeRegistry:Ll,registerStore:q0,destroy:()=>window.removeEventListener("message",a)},console.log("[BridgeAgent] Ready \u2014 listening for postMessage commands")}var Ma=require("react"),od=require("@decido/plugin-engine"),mr=require("lucide-react"),fe=require("react/jsx-runtime"),Kz={},Gz=()=>{let t=(0,od.usePluginStore)(x=>x.registry),e=(0,od.usePluginStore)(x=>x.availablePlugins),r=(0,od.usePluginStore)(x=>x.addRegistryEntry),n=(0,od.usePluginStore)(x=>x.removeRegistryEntry),o=(0,od.usePluginStore)(x=>x.toggleRegistryEntry),[s,i]=(0,Ma.useState)([]),[a,l]=(0,Ma.useState)(!0),[c,d]=(0,Ma.useState)(null),[u,f]=(0,Ma.useState)(!1),[p,h]=(0,Ma.useState)(null);(0,Ma.useEffect)(()=>{(async()=>{try{l(!0);let y=Kz.env?.VITE_MARKETPLACE_URL||"http://localhost:5010/api/marketplace",m=await fetch(`${y}/catalog`);if(!m.ok)throw new Error("Catalog request failed");let v=await m.json();i(v),d(null)}catch(y){d(y.message||"Failed to connect to Decido Hub")}finally{l(!1)}})()},[]);let b=x=>{r({name:x.name,url:x.url,exposedModule:x.exposedModule,signature:x.signature})},g=x=>t.some(y=>y.name===x);return(0,fe.jsxs)("div",{className:"w-full h-full flex flex-col bg-surface-primary text-text-primary font-sans overflow-hidden border-r border-border-subtle",children:[(0,fe.jsxs)("div",{className:"p-4 border-b border-border-subtle bg-surface-secondary/50 flex justify-between items-center shrink-0",children:[(0,fe.jsxs)("div",{className:"flex items-center gap-2",children:[(0,fe.jsx)(mr.Puzzle,{className:"w-5 h-5 text-cyan-400"}),(0,fe.jsx)("h2",{className:"font-bold text-sm tracking-wide",children:"Decido Hub"})]}),(0,fe.jsxs)("div",{className:"flex bg-surface-primary p-1 rounded-lg border border-border-subtle",children:[(0,fe.jsx)("button",{onClick:()=>{f(!1),h(null)},className:`px-3 py-1 text-xs rounded-md transition-colors ${u?"text-text-muted hover:text-text-primary":"bg-cyan-500/20 text-cyan-400"}`,children:"Installed"}),(0,fe.jsxs)("button",{onClick:()=>{f(!0),h(null)},className:`px-3 py-1 flex items-center gap-1 text-xs rounded-md transition-colors ${u?"bg-cyan-500/20 text-cyan-400":"text-text-muted hover:text-text-primary"}`,children:[(0,fe.jsx)(mr.DownloadCloud,{className:"w-3 h-3"})," Catalog"]})]})]}),(0,fe.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[!p&&!u&&(0,fe.jsxs)("div",{className:"bg-cyan-500/10 border border-cyan-500/20 p-3 rounded-lg flex items-start gap-3",children:[(0,fe.jsx)(mr.RefreshCcw,{className:"w-4 h-4 text-cyan-400 shrink-0 mt-0.5"}),(0,fe.jsx)("p",{className:"text-xs text-cyan-200/70 leading-relaxed",children:"Changes to the Federation Registry require a hard reload to apply securely to the OS Kernel context. (cmd+R)"})]}),p&&(0,fe.jsxs)("div",{className:"space-y-4 animate-in fade-in slide-in-from-right-4 duration-300",children:[(0,fe.jsxs)("button",{onClick:()=>h(null),className:"flex items-center gap-1 text-xs text-text-secondary hover:text-text-primary transition-colors mb-2",children:[(0,fe.jsx)(mr.ChevronLeft,{className:"w-4 h-4"})," Volver"]}),(0,fe.jsxs)("div",{className:"flex items-start gap-4 pb-4 border-b border-border-subtle",children:[(0,fe.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-linear-to-br from-cyan-500/20 to-blue-500/20 border border-cyan-500/30 flex items-center justify-center shrink-0",children:(0,fe.jsx)(mr.Box,{className:"w-8 h-8 text-cyan-400"})}),(0,fe.jsxs)("div",{className:"flex-1",children:[(0,fe.jsx)("h2",{className:"text-xl font-bold text-text-primary mb-1",children:p.title||p.name}),(0,fe.jsxs)("p",{className:"text-sm text-cyan-400 font-mono mb-2",children:[p.author||"Decido Publisher"," \u2022 v",p.version||"1.0.0"]}),g(p.name)?(0,fe.jsxs)("div",{className:"flex items-center gap-2",children:[(0,fe.jsxs)("span",{className:"bg-emerald-500/10 text-emerald-400 text-xs px-3 py-1.5 rounded-full font-medium flex items-center gap-1",children:[(0,fe.jsx)("div",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),"Installed"]}),(0,fe.jsx)("button",{onClick:()=>n(p.name),className:"bg-surface-tertiary hover:bg-red-500/20 hover:text-red-400 text-text-primary text-xs px-3 py-1.5 rounded transition-colors",children:"Uninstall"})]}):(0,fe.jsx)("button",{onClick:()=>b(p),className:"bg-cyan-600 hover:bg-cyan-500 text-text-primary text-sm px-6 py-2 rounded-lg transition-colors shadow-lg shadow-cyan-500/20 font-medium",children:"Install Plugin"})]})]}),(0,fe.jsxs)("div",{className:"space-y-6 pt-2",children:[(0,fe.jsxs)("div",{children:[(0,fe.jsxs)("h3",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center gap-2",children:[(0,fe.jsx)(mr.Info,{className:"w-4 h-4 text-text-muted"})," General Description"]}),(0,fe.jsx)("p",{className:"text-sm text-text-secondary leading-relaxed bg-surface-glass p-4 rounded-xl border border-border-subtle/50",children:p.description||"No README.md currently available for this plugin. This is a technical expansion module for Decido OS."})]}),(()=>{let x=e.find(y=>y.id===p.name||y.name===p.name);return x?(0,fe.jsxs)("div",{className:"space-y-4",children:[x.widgets&&x.widgets.length>0&&(0,fe.jsxs)("div",{children:[(0,fe.jsxs)("h3",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center gap-2",children:[(0,fe.jsx)(mr.LayoutDashboard,{className:"w-4 h-4 text-cyan-400"})," Provisioned Widgets"]}),(0,fe.jsx)("div",{className:"grid gap-2",children:x.widgets.map(y=>(0,fe.jsxs)("div",{className:"bg-surface-secondary border border-border-subtle p-3 rounded-lg flex items-center justify-between",children:[(0,fe.jsxs)("div",{className:"flex flex-col",children:[(0,fe.jsx)("span",{className:"text-sm font-medium text-text-primary",children:y.name}),(0,fe.jsxs)("span",{className:"text-xs text-text-muted font-mono",children:["ID: ",y.id]})]}),(0,fe.jsxs)("span",{className:"text-xs bg-surface-primary text-emerald-400/80 border border-emerald-500/20 px-2 py-1 rounded",children:["Zone: ",y.defaultZone]})]},y.id))})]}),x.intents&&x.intents.length>0&&(0,fe.jsxs)("div",{children:[(0,fe.jsxs)("h3",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center gap-2",children:[(0,fe.jsx)(mr.Code,{className:"w-4 h-4 text-purple-400"})," Registered AI Intents"]}),(0,fe.jsx)("div",{className:"bg-surface-secondary border border-border-subtle rounded-lg p-3 flex flex-wrap gap-2",children:x.intents.map(y=>(0,fe.jsxs)("span",{className:"bg-surface-primary text-purple-400/90 text-xs px-2 py-1 rounded border border-purple-500/20 font-mono",children:['"',y,'"']},y))})]})]}):(0,fe.jsx)("div",{className:"text-xs text-text-muted italic bg-surface-glass p-4 rounded-xl border border-border-subtle/30 text-center",children:"Install and activate this plugin to view its provided Architecture bounds (Widgets & Intents)."})})()]})]}),!p&&u&&(0,fe.jsxs)("div",{className:"space-y-4",children:[a&&(0,fe.jsx)("div",{className:"text-xs text-text-muted text-center py-8 animate-pulse",children:"Connecting to Decido Hub..."}),c&&(0,fe.jsxs)("div",{className:"bg-red-500/10 border border-red-500/20 p-4 rounded-xl flex items-center gap-3 text-red-400 text-xs",children:[(0,fe.jsx)(mr.AlertCircle,{className:"w-4 h-4"})," ",c]}),!a&&!c&&s.map(x=>{let y=g(x.name);return(0,fe.jsxs)("div",{onClick:()=>h(x),className:"bg-surface-secondary border border-border-subtle hover:border-cyan-500/30 focus:border-cyan-500/30 cursor-pointer p-4 rounded-xl flex flex-col gap-3 transition-colors group",children:[(0,fe.jsxs)("div",{className:"flex justify-between items-start",children:[(0,fe.jsxs)("div",{className:"flex gap-3 items-center",children:[(0,fe.jsx)("div",{className:"w-10 h-10 rounded-lg bg-surface-primary border border-border-subtle flex items-center justify-center group-hover:border-cyan-500/30 transition-colors",children:(0,fe.jsx)(mr.Box,{className:"w-5 h-5 text-text-muted group-hover:text-cyan-400 transition-colors"})}),(0,fe.jsxs)("div",{children:[(0,fe.jsx)("h3",{className:"font-bold text-sm text-text-primary group-hover:text-cyan-300 transition-colors",children:x.title}),(0,fe.jsxs)("p",{className:"text-xs text-text-muted font-mono mt-0.5",children:[x.author," \u2022 v",x.version]})]})]}),y&&(0,fe.jsx)("span",{className:"bg-emerald-500/10 text-emerald-400 text-[10px] px-2 py-1 rounded-full uppercase font-bold tracking-wider",children:"Installed"})]}),(0,fe.jsx)("p",{className:"text-xs text-text-secondary leading-relaxed border-l-2 border-border-subtle pl-2 line-clamp-2",children:x.description}),(0,fe.jsxs)("div",{className:"flex gap-2 mt-1",children:[(0,fe.jsx)("button",{className:"text-[10px] text-text-secondary hover:text-text-primary bg-surface-glass px-2 py-1 rounded uppercase font-bold tracking-wide",children:"Details"}),x.tags?.map(m=>(0,fe.jsx)("span",{className:"text-[10px] bg-surface-primary text-text-muted px-2 py-1 rounded-full border border-border-subtle",children:m},m))]})]},x.id)})]}),!p&&!u&&(0,fe.jsxs)("div",{className:"space-y-3",children:[t.map(x=>(0,fe.jsxs)("div",{onClick:()=>h(x),className:`bg-surface-secondary border ${x.enabled?"border-border-default/50":"border-border-subtle opacity-60"} hover:border-cyan-500/30 cursor-pointer p-4 rounded-xl transition-all group`,children:[(0,fe.jsxs)("div",{className:"flex justify-between items-start mb-2",children:[(0,fe.jsxs)("div",{className:"flex items-center gap-3",children:[(0,fe.jsx)("div",{className:"w-10 h-10 rounded-lg bg-surface-primary border border-border-subtle flex items-center justify-center group-hover:border-cyan-500/30 transition-colors",children:(0,fe.jsx)(mr.Box,{className:"w-5 h-5 text-text-muted group-hover:text-cyan-400 transition-colors"})}),(0,fe.jsxs)("div",{children:[(0,fe.jsxs)("div",{className:"flex items-center gap-2",children:[(0,fe.jsx)("div",{className:`w-2 h-2 rounded-full ${x.enabled?"bg-emerald-400 shadow-[0_0_8px_rgba(52,211,153,0.5)]":"bg-surface-elevated"}`}),(0,fe.jsx)("h3",{className:"font-bold text-sm tracking-wide text-text-primary group-hover:text-cyan-300 transition-colors",children:x.name})]}),(0,fe.jsxs)("div",{className:"text-xs font-mono text-text-muted mt-1",children:["module: ",(0,fe.jsx)("span",{className:"text-cyan-300/80",children:x.exposedModule})]})]})]}),(0,fe.jsxs)("div",{className:"flex items-center gap-1",onClick:y=>y.stopPropagation(),children:[(0,fe.jsx)("button",{onClick:()=>o(x.name),className:`w-7 h-7 flex items-center justify-center rounded transition-colors ${x.enabled?"text-emerald-400 hover:bg-emerald-400/10":"text-text-muted hover:bg-surface-tertiary"}`,title:x.enabled?"Disable Plugin":"Enable Plugin",children:(0,fe.jsx)(mr.Power,{className:"w-4 h-4"})}),(0,fe.jsx)("button",{onClick:()=>n(x.name),className:"w-7 h-7 flex items-center justify-center rounded transition-colors text-text-muted hover:bg-red-500/20 hover:text-red-400",title:"Uninstall Plugin",children:(0,fe.jsx)(mr.Trash2,{className:"w-4 h-4"})})]})]}),(0,fe.jsxs)("div",{className:"bg-surface-glass p-2 border border-border-subtle/50 rounded flex gap-2 items-center mt-3",children:[(0,fe.jsx)(mr.Code,{className:"w-3.5 h-3.5 text-text-muted shrink-0"}),(0,fe.jsx)("span",{className:"font-mono text-[10px] text-text-secondary truncate",title:x.url,children:x.url})]})]},x.name)),t.length===0&&(0,fe.jsxs)("div",{className:"text-center py-12 text-text-muted text-sm",children:[(0,fe.jsx)(mr.Puzzle,{className:"w-8 h-8 mx-auto text-text-muted mb-3"}),"No local modules installed.",(0,fe.jsx)("br",{}),(0,fe.jsx)("button",{onClick:()=>f(!0),className:"mt-3 text-cyan-400 hover:text-cyan-300 underline underline-offset-4 decoration-zinc-800",children:"Browse Decido Hub"})]})]})]})]})};var zu=require("react"),uh=require("lucide-react"),er=require("react/jsx-runtime"),qz={},_N=()=>{let[t,e]=(0,zu.useState)(""),[r,n]=(0,zu.useState)("INFO"),[o,s]=(0,zu.useState)("NONE"),[i,a]=(0,zu.useState)(!1);return(0,er.jsxs)("div",{className:"bg-surface-tertiary rounded-xl border border-border-default p-6 shadow-lg",children:[(0,er.jsxs)("h3",{className:"text-lg font-bold text-text-primary mb-4 flex items-center gap-2",children:[(0,er.jsx)(uh.Megaphone,{size:20,className:"text-purple-400"})," Broadcast Center"]}),(0,er.jsxs)("div",{className:"space-y-4",children:[(0,er.jsxs)("div",{children:[(0,er.jsx)("label",{className:"block text-xs font-bold text-text-secondary mb-1",children:"Message"}),(0,er.jsx)("input",{type:"text",value:t,onChange:c=>e(c.target.value),placeholder:"e.g. System maintenance in 5 minutes",className:"w-full bg-surface-secondary border border-border-default rounded-lg p-3 text-text-primary focus:border-purple-500 outline-hidden"})]}),(0,er.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,er.jsxs)("div",{children:[(0,er.jsx)("label",{className:"block text-xs font-bold text-text-secondary mb-1",children:"Alert Type"}),(0,er.jsxs)("select",{value:r,onChange:c=>n(c.target.value),className:"w-full bg-surface-secondary border border-border-default rounded-lg p-3 text-text-primary outline-hidden",children:[(0,er.jsx)("option",{value:"INFO",children:"Info (Blue)"}),(0,er.jsx)("option",{value:"WARNING",children:"Warning (Orange)"}),(0,er.jsx)("option",{value:"CRITICAL",children:"Critical (Red)"}),(0,er.jsx)("option",{value:"SUCCESS",children:"Success (Green)"})]})]}),(0,er.jsxs)("div",{children:[(0,er.jsx)("label",{className:"block text-xs font-bold text-text-secondary mb-1",children:"Forced Action"}),(0,er.jsxs)("select",{value:o,onChange:c=>s(c.target.value),className:"w-full bg-surface-secondary border border-border-default rounded-lg p-3 text-text-primary outline-hidden",children:[(0,er.jsx)("option",{value:"NONE",children:"None"}),(0,er.jsx)("option",{value:"RELOAD",children:"Force Reload"}),(0,er.jsx)("option",{value:"LINK",children:"Open Link"})]})]})]}),(0,er.jsx)("div",{className:"pt-2",children:(0,er.jsx)("button",{onClick:async()=>{if(t){a(!0);try{let c=qz.env?.VITE_API_URL||"http://localhost:3001/api";await fetch(`${c}/admin/broadcast`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t,type:r,action:o==="NONE"?void 0:o})}),alert("Broadcast Sent!"),e("")}catch(c){console.error(c),alert("Error sending broadcast")}finally{a(!1)}}},disabled:i||!t,className:"w-full py-3 bg-purple-600 hover:bg-purple-500 disabled:opacity-50 disabled:bg-surface-elevated text-text-primary font-bold rounded-lg transition-colors flex items-center justify-center gap-2",children:i?"Sending...":(0,er.jsxs)(er.Fragment,{children:[(0,er.jsx)(uh.Send,{size:18})," Broadcast Now"]})})})]})]})};var sd=require("lucide-react"),ms=require("react/jsx-runtime"),Yz={},LN=()=>{let t=async e=>{if(confirm("Are you sure you want to execute this global action?"))try{let r=Yz.env?.VITE_API_URL||"http://localhost:3001/api";e==="FORCE_RELOAD"?await fetch(`${r}/admin/broadcast`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:"System Integrity Check: Reloading...",type:"WARNING",action:"RELOAD"})}):e==="CLEAR_ALERTS"&&await fetch(`${r}/admin/broadcast`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:"System Normal",type:"SUCCESS"})})}catch{alert("Action Failed")}};return(0,ms.jsxs)("div",{className:"bg-surface-tertiary rounded-xl border border-border-default p-6 shadow-lg",children:[(0,ms.jsxs)("h3",{className:"text-lg font-bold text-text-primary mb-4 flex items-center gap-2",children:[(0,ms.jsx)(sd.ShieldAlert,{size:20,className:"text-red-400"})," Panic Room"]}),(0,ms.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,ms.jsxs)("button",{onClick:()=>t("FORCE_RELOAD"),className:"flex flex-col items-center justify-center p-4 bg-red-900/20 hover:bg-red-900/40 border border-red-800/50 rounded-lg transition-colors group",children:[(0,ms.jsx)(sd.RefreshCw,{size:24,className:"text-red-500 mb-2 group-hover:rotate-180 transition-transform duration-500"}),(0,ms.jsx)("span",{className:"text-xs font-bold text-red-400",children:"Force Reload All"})]}),(0,ms.jsxs)("button",{onClick:()=>t("CLEAR_ALERTS"),className:"flex flex-col items-center justify-center p-4 bg-emerald-900/20 hover:bg-emerald-900/40 border border-emerald-800/50 rounded-lg transition-colors",children:[(0,ms.jsx)(sd.Zap,{size:24,className:"text-emerald-500 mb-2"}),(0,ms.jsx)("span",{className:"text-xs font-bold text-emerald-400",children:"System Normal"})]})]})]})};var Bl=require("react"),Zn=require("recharts"),BN=require("lucide-react"),Qr=require("react/jsx-runtime"),Xz={},zN=()=>{let[t,e]=(0,Bl.useState)([]),[r,n]=(0,Bl.useState)(!0),[o,s]=(0,Bl.useState)(null),[i,a]=(0,Bl.useState)(!1),l=5e4;(0,Bl.useEffect)(()=>{(async()=>{try{n(!0);let f=Xz.env?.VITE_API_URL||"http://localhost:3001/api",p=await fetch(`${f}/billing/usage`);if(!p.ok)throw new Error("Failed to fetch billing usage");let h=await p.json();e(h);let b=0;h.forEach(g=>{Object.keys(g).forEach(x=>{x!=="date"&&(b+=Number(g[x]))})}),b>=l*.8&&a(!0)}catch(f){console.error("Failed to fetch billing usage:",f),s(f.message||"Failed to load usage data")}finally{n(!1)}})()},[]);let c=()=>{let u=new Set;return t.forEach(f=>{Object.keys(f).forEach(p=>{p!=="date"&&u.add(p)})}),Array.from(u)},d=["#8884d8","#82ca9d","#ffc658","#ff8042","#00C49F"];return(0,Qr.jsxs)("div",{className:"w-full flex-1 bg-surface-overlay border border-border-default rounded-xl backdrop-blur-xl overflow-hidden shadow-2xl",children:[(0,Qr.jsx)("div",{className:"p-4 border-b border-border-subtle",children:(0,Qr.jsx)("h3",{className:"text-emerald-400 font-semibold flex items-center gap-2",children:"Portal del Cliente - Consumo de IA (Gas)"})}),(0,Qr.jsxs)("div",{className:"p-4",children:[i&&(0,Qr.jsxs)("div",{className:"mb-4 flex items-center gap-2 text-rose-400 bg-rose-500/10 p-3 rounded-lg border border-rose-500/20",children:[(0,Qr.jsx)(BN.AlertCircle,{className:"w-5 h-5"}),(0,Qr.jsxs)("span",{children:["Atenci\xF3n: Has superado el 80% de tu cuota mensual (",l," Gas)."]})]}),r?(0,Qr.jsx)("div",{className:"h-64 flex items-center justify-center text-text-primary/50",children:"Cargando consumo..."}):o?(0,Qr.jsx)("div",{className:"h-64 flex items-center justify-center text-rose-400",children:o}):t.length===0?(0,Qr.jsx)("div",{className:"h-64 flex items-center justify-center text-text-primary/50",children:"No hay datos de consumo registrados a\xFAn."}):(0,Qr.jsx)("div",{className:"h-64 w-full",children:(0,Qr.jsx)(Zn.ResponsiveContainer,{width:"100%",height:"100%",children:(0,Qr.jsxs)(Zn.BarChart,{data:t,children:[(0,Qr.jsx)(Zn.CartesianGrid,{strokeDasharray:"3 3",stroke:"#ffffff10",vertical:!1}),(0,Qr.jsx)(Zn.XAxis,{dataKey:"date",stroke:"#ffffff50",tickFormatter:u=>new Date(u).toLocaleDateString()}),(0,Qr.jsx)(Zn.YAxis,{stroke:"#ffffff50"}),(0,Qr.jsx)(Zn.Tooltip,{contentStyle:{backgroundColor:"#1a1a1a",border:"1px solid #333"},itemStyle:{color:"#fff"}}),(0,Qr.jsx)(Zn.Legend,{}),c().map((u,f)=>(0,Qr.jsx)(Zn.Bar,{dataKey:u,stackId:"a",fill:d[f%d.length]},u))]})})})]})]})};var id=require("lucide-react"),Mt=require("react/jsx-runtime"),Jz=()=>(0,Mt.jsxs)("div",{className:"min-h-screen bg-surface-primary p-8 text-text-primary",children:[(0,Mt.jsxs)("header",{className:"mb-8 flex items-center justify-between",children:[(0,Mt.jsxs)("div",{children:[(0,Mt.jsx)("h1",{className:"text-3xl font-black text-transparent bg-clip-text bg-linear-to-r from-purple-400 to-pink-600",children:"MISSION CONTROL"}),(0,Mt.jsx)("p",{className:"text-text-muted font-mono text-sm mt-1",children:"System Operations & Real-time Command"})]}),(0,Mt.jsxs)("div",{className:"flex gap-4",children:[(0,Mt.jsxs)("div",{className:"bg-surface-secondary px-4 py-2 rounded-lg border border-border-subtle flex items-center gap-3",children:[(0,Mt.jsx)(id.Users,{size:16,className:"text-blue-400"}),(0,Mt.jsx)("span",{className:"font-mono font-bold",children:"12 Active"})]}),(0,Mt.jsxs)("div",{className:"bg-surface-secondary px-4 py-2 rounded-lg border border-border-subtle flex items-center gap-3",children:[(0,Mt.jsx)(id.Server,{size:16,className:"text-emerald-400"}),(0,Mt.jsx)("span",{className:"font-mono font-bold",children:"Healthy"}),(0,Mt.jsx)("div",{className:"w-2 h-2 rounded-full bg-emerald-500 animate-pulse"})]})]})]}),(0,Mt.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,Mt.jsx)("div",{className:"space-y-6",children:(0,Mt.jsx)(_N,{})}),(0,Mt.jsxs)("div",{className:"space-y-6",children:[(0,Mt.jsx)(LN,{}),(0,Mt.jsx)(zN,{})]}),(0,Mt.jsxs)("div",{className:"bg-surface-secondary rounded-xl border border-border-subtle p-6 font-mono text-xs h-[500px] flex flex-col",children:[(0,Mt.jsxs)("h3",{className:"font-bold text-text-secondary mb-4 flex items-center gap-2",children:[(0,Mt.jsx)(id.Activity,{size:16})," Live Event Stream"]}),(0,Mt.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-2 text-text-muted",children:[(0,Mt.jsxs)("p",{children:[(0,Mt.jsx)("span",{className:"text-emerald-500",children:"[10:00:01]"})," System Init"]}),(0,Mt.jsxs)("p",{children:[(0,Mt.jsx)("span",{className:"text-blue-500",children:"[10:05:23]"})," User 'Julio' connected"]}),(0,Mt.jsxs)("p",{children:[(0,Mt.jsx)("span",{className:"text-yellow-500",children:"[10:12:45]"})," AI Graph Analysis triggered"]}),(0,Mt.jsxs)("p",{children:[(0,Mt.jsx)("span",{className:"text-purple-500",children:"[10:15:00]"})," Order #1234 staged to PRODUCTION"]}),(0,Mt.jsx)("div",{className:"opacity-30 italic mt-4",children:"Listening for events..."})]})]})]})]});var Gi=require("react"),Ui=require("@decido/kernel-bridge");var Kt=require("react/jsx-runtime"),Zz=()=>{let{mcpServers:t,setMcpServerStatus:e}=$0(),[r,n]=(0,Gi.useState)([]),[o,s]=(0,Gi.useState)(null),[i,a]=(0,Gi.useState)(null),[l,c]=(0,Gi.useState)("{}"),[d,u]=(0,Gi.useState)(null),[f,p]=(0,Gi.useState)(!1),h=async()=>{try{let m=await Ui.kernel.execute("list_mcp_tools");n(m||[])}catch(m){console.error("Failed to fetch MCP tools",m)}};(0,Gi.useEffect)(()=>{h();let m=setInterval(h,1e4);return()=>clearInterval(m)},[]);let b=async(m,v,S)=>{s(m);try{let w=S.split(" ").filter(C=>C.trim()!=="");await Ui.kernel.execute("connect_mcp_server",{name:m,command:v,args:w}),Ui.kernel.notify("MCP Connected",`Server ${m} connected successfully.`),e(m,!0),await h()}catch(w){Ui.kernel.notify("MCP Connection Failed",w.toString())}finally{s(null)}},g=async m=>{s(m);try{await Ui.kernel.execute("disconnect_mcp_server",{name:m}),Ui.kernel.notify("MCP Disconnected",`Server ${m} disconnected.`),e(m,!1),await h()}catch(v){Ui.kernel.notify("Disconnect Failed",v.toString())}finally{s(null)}},x=m=>{if(i===m.name){a(null);return}a(m.name),u(null);let v={};m.inputSchema?.properties&&Object.keys(m.inputSchema.properties).forEach(S=>{let w=m.inputSchema.properties[S];w.type==="string"?v[S]="":w.type==="number"?v[S]=0:w.type==="boolean"?v[S]=!1:w.type==="object"?v[S]={}:w.type==="array"&&(v[S]=[])}),c(JSON.stringify(v,null,2))},y=async m=>{p(!0),u(null);try{let v={};try{let k=l.replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"');v=JSON.parse(k)}catch{u("Invalid JSON format in arguments."),p(!1);return}let S=m.split(":"),w="",C=m;S.length>=3&&S[0]==="mcp"?(w=S[1],C=S.slice(2).join(":")):S.length===2&&S[0]!=="mcp"?(w=S[0],C=S[1]):w=S[0]||"frubeala-mcp";let A=await Ui.kernel.execute("call_mcp_tool",{serverName:w,toolName:C,arguments:v});if(A&&A.content){let k=A.content.filter(M=>M.type==="text").map(M=>M.text).join("\\n");u(k)}else u(JSON.stringify(A,null,2))}catch(v){u(`Error: ${v.toString()}`)}finally{p(!1)}};return(0,Kt.jsxs)("div",{className:"space-y-4",children:[(0,Kt.jsxs)("div",{className:"space-y-2",children:[(0,Kt.jsx)("h4",{className:"text-xs font-bold text-text-secondary uppercase tracking-widest mb-3",children:"Conexiones Activas"}),t.length===0&&(0,Kt.jsx)("div",{className:"text-text-muted text-xs text-center py-4 bg-surface-glass rounded-xl border border-border-subtle",children:"Sin servidores conectados."}),t.map((m,v)=>(0,Kt.jsxs)("div",{className:"flex flex-col p-3 bg-surface-glass rounded-xl border border-border-subtle",children:[(0,Kt.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Kt.jsx)("span",{className:"text-sm font-medium text-text-primary",children:m.name}),m.isConnected?(0,Kt.jsx)("button",{onClick:()=>g(m.name),disabled:o===m.name,className:"px-2 py-1 bg-red-900/30 hover:bg-red-900/60 text-red-400 border border-red-500/30 rounded text-xs transition-colors",children:o===m.name?"Disconnecting...":"Disconnect"}):(0,Kt.jsx)("button",{onClick:()=>b(m.name,m.command,m.args),disabled:o===m.name,className:"px-2 py-1 bg-emerald-900/30 hover:bg-emerald-900/60 text-emerald-400 border border-emerald-500/30 rounded text-xs transition-colors",children:o===m.name?"Connecting...":"Connect"})]}),(0,Kt.jsxs)("div",{className:"text-[10px] text-text-muted font-mono mt-1",children:[m.command," ",m.args]})]},v))]}),(0,Kt.jsxs)("div",{className:"space-y-2 mt-6",children:[(0,Kt.jsx)("h4",{className:"text-xs font-bold text-text-secondary uppercase tracking-widest mb-3 border-t border-border-subtle pt-4",children:"Tools Playground"}),r.length===0&&(0,Kt.jsx)("div",{className:"text-text-muted text-xs text-center py-4 bg-surface-glass rounded-xl border border-border-subtle",children:"No hay herramientas disponibles. Aseg\xFArate de que un servidor MCP est\xE9 online."}),(0,Kt.jsx)("div",{className:"space-y-2 pb-10",children:r.map(m=>(0,Kt.jsxs)("div",{className:"bg-surface-overlay border border-border-subtle rounded-xl p-3 overflow-hidden",children:[(0,Kt.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Kt.jsxs)("div",{children:[(0,Kt.jsx)("h4",{className:"text-cyan-400 font-bold text-sm",children:m.name.split(":").pop()||m.name}),(0,Kt.jsx)("p",{className:"text-xs text-text-muted line-clamp-1",children:m.description})]}),(0,Kt.jsx)("button",{onClick:()=>x(m),className:"px-3 py-1 bg-cyan-900/30 hover:bg-cyan-900/60 text-cyan-400 border border-cyan-500/30 rounded text-xs transition-colors",children:"Test"})]}),i===m.name&&(0,Kt.jsxs)("div",{className:"mt-4 border-t border-border-default pt-4 flex flex-col gap-3 animate-in slide-in-from-top-4 duration-200",children:[(0,Kt.jsxs)("div",{children:[(0,Kt.jsx)("label",{className:"text-[10px] text-text-muted font-bold uppercase tracking-wider mb-1 block",children:"Arguments (JSON)"}),(0,Kt.jsx)("textarea",{value:l,onChange:v=>c(v.target.value),className:"w-full h-24 bg-surface-overlay border border-border-default rounded p-2 text-cyan-300 font-mono text-xs focus:border-cyan-400 outline-hidden resize-none"})]}),(0,Kt.jsx)("button",{onClick:()=>y(m.name),disabled:f,className:"w-full py-2 bg-linear-to-r from-cyan-600 to-indigo-600 text-text-primary rounded font-bold text-xs hover:from-cyan-500 hover:to-indigo-500 transition-all shadow-[0_0_15px_rgba(6,182,212,0.3)] disabled:opacity-50",children:f?"Executing...":"Execute Tool"}),d&&(0,Kt.jsxs)("div",{className:"mt-2",children:[(0,Kt.jsx)("label",{className:"text-[10px] text-text-muted font-bold uppercase tracking-wider mb-1 block",children:"Output"}),(0,Kt.jsx)("div",{className:"w-full max-h-48 overflow-y-auto bg-surface-primary border border-border-default rounded p-2 text-emerald-400 font-mono text-xs whitespace-pre-wrap",children:d})]})]})]},m.name))})]})]})};var us=Re(require("react"));var nC=Re(require("react")),In=require("lucide-react");Fu();var KN=Re(require("react")),zl=require("motion/react"),qN=require("lucide-react"),Po=require("react/jsx-runtime"),YN=KN.default.memo(function({isSpeaking:e,isCreatorMode:r,creatorViewMode:n,modelLabel:o,onModelClick:s,onSyncCreatorMode:i,onSetCreatorViewMode:a}){return(0,Po.jsxs)("div",{"data-tauri-drag-region":!0,className:"flex-1 flex items-center justify-center gap-2 min-w-0",children:[(0,Po.jsx)(zl.AnimatePresence,{children:e&&(0,Po.jsx)(zl.motion.div,{initial:{opacity:0,width:0},animate:{opacity:1,width:"auto"},exit:{opacity:0,width:0},className:"flex items-center gap-0.5 mr-2 overflow-hidden",children:[1,2,3,4,5].map(l=>(0,Po.jsx)(zl.motion.div,{animate:{height:[6,Math.random()*16+8,6]},transition:{repeat:1/0,duration:.5,delay:l*.08},className:"w-1 bg-accent-cyan rounded-full"},l))})}),(0,Po.jsxs)("div",{className:"flex bg-surface-tertiary border border-border-default rounded-lg p-0.5 shadow-sm",children:[(0,Po.jsx)("button",{onClick:()=>{r&&i(!1)},className:`px-3 py-1 text-[11px] font-semibold rounded-md transition-all duration-200 ${r?"text-text-muted hover:text-text-secondary border border-transparent":"bg-surface-elevated text-text-primary shadow-sm border border-border-default"}`,children:"Player"}),(0,Po.jsx)("button",{onClick:()=>{r||i(!0)},className:`px-3 py-1 text-[11px] font-semibold rounded-md transition-all duration-200 flex items-center gap-1 ${r?"bg-surface-elevated text-accent-purple shadow-sm border border-accent-purple":"text-text-muted hover:text-text-secondary border border-transparent"}`,children:"Creator"})]}),(0,Po.jsx)(zl.AnimatePresence,{children:r&&(0,Po.jsxs)(zl.motion.div,{initial:{opacity:0,scale:.9,width:0},animate:{opacity:1,scale:1,width:"auto"},exit:{opacity:0,scale:.9,width:0},className:"hidden lg:flex bg-surface-tertiary border border-border-default rounded-lg p-0.5 overflow-hidden shadow-sm",children:[(0,Po.jsx)("button",{onClick:()=>a("timeline"),className:`px-2.5 py-1 text-[10px] font-bold tracking-wider rounded-md transition-all duration-200 ${n==="timeline"?"bg-surface-elevated text-text-primary shadow-sm border border-border-default":"text-text-muted hover:text-text-secondary border border-transparent"}`,children:"TIMELINE"}),(0,Po.jsxs)("button",{onClick:()=>a("graph"),className:`px-2.5 py-1 text-[10px] font-bold tracking-wider rounded-md transition-all duration-200 flex items-center gap-1 ${n==="graph"?"bg-surface-elevated text-text-primary shadow-sm border border-border-default":"text-text-muted hover:text-text-secondary border border-transparent"}`,children:[(0,Po.jsx)(qN.Network,{size:10})," GRAPH"]})]})})]})});var cd=require("react"),$l=require("motion/react"),po=require("lucide-react");Qn();var Q0={R1:"Left Top",R2:"Left Bottom",R3:"Right Top",R4:"Right Bottom",R5:"Top Edge",R6:"Status Bar"};var tC=[{id:null,label:"\u2014 Vac\xEDo \u2014"},{id:"chat",label:"Chat"},{id:"debug",label:"Debug Panel"},{id:"terminal",label:"Terminal"},{id:"canvas",label:"Canvas / MorphShell"},{id:"graph-editor",label:"Graph Editor"},{id:"timeline-editor",label:"Timeline Editor"},{id:"app-sidebar",label:"App Sidebar"}];var Xe=require("react/jsx-runtime");function hh(){let[t,e]=(0,cd.useState)(!1),[r,n]=(0,cd.useState)(!1),[o,s]=(0,cd.useState)(""),i=ke(h=>h.slots),a=ke(h=>h.setSlot),l=ke(h=>h.resetLayout),c=ke(h=>h.savedPresets),d=ke(h=>h.savePreset),u=ke(h=>h.loadPreset),f=ke(h=>h.deletePreset),p=(0,cd.useCallback)(()=>{o.trim()&&(d(o.trim()),s(""))},[o,d]);return(0,Xe.jsxs)("div",{className:"relative",children:[(0,Xe.jsx)("button",{onClick:()=>e(!t),className:`p-2 rounded-lg transition-all ${t?"bg-cyan-500/20 text-cyan-400 shadow-[0_0_10px_rgba(6,182,212,0.2)]":"text-text-muted hover:text-text-primary hover:bg-surface-glass"}`,title:"Layout Configurator",children:(0,Xe.jsx)(po.Grid3X3,{size:16})}),(0,Xe.jsx)($l.AnimatePresence,{children:t&&(0,Xe.jsxs)(Xe.Fragment,{children:[(0,Xe.jsx)("div",{className:"fixed inset-0 z-800",style:{position:"fixed",inset:0,zIndex:800},onClick:()=>e(!1)}),(0,Xe.jsxs)($l.motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`absolute top-full right-0 mt-2 w-[calc(100vw-2rem)] sm:w-[380px] z-801
|
|
414
|
+
bg-surface-tertiary border border-border-default rounded-xl sm:rounded-2xl shadow-2xl overflow-hidden`,children:[(0,Xe.jsxs)("div",{className:"px-4 py-3 border-b border-border-subtle flex items-center justify-between",children:[(0,Xe.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xe.jsx)(po.Settings,{size:14,className:"text-cyan-400"}),(0,Xe.jsx)("h3",{className:"text-sm font-bold text-text-primary",children:"Layout Configurator"})]}),(0,Xe.jsx)("div",{className:"flex items-center gap-1",children:Object.keys(Ki).map(h=>(0,Xe.jsx)("button",{onClick:()=>l(h),className:`px-2.5 py-1 text-[10px] font-bold uppercase tracking-wider
|
|
415
|
+
rounded-full bg-surface-glass text-text-muted hover:text-text-primary hover:bg-surface-glass
|
|
416
|
+
transition-colors border border-border-subtle`,children:h},h))})]}),(0,Xe.jsxs)("div",{children:[(0,Xe.jsxs)("button",{onClick:()=>n(!r),className:"w-full px-4 py-2.5 flex items-center justify-between hover:bg-surface-glass transition-colors group",children:[(0,Xe.jsxs)("div",{className:"flex items-center gap-2 text-xs font-medium text-text-secondary group-hover:text-text-primary",children:[(0,Xe.jsx)(po.SlidersHorizontal,{size:14,className:"text-cyan-500/50"}),(0,Xe.jsx)("span",{children:"Configuraci\xF3n de Slots"}),(0,Xe.jsx)("span",{className:"text-[9px] px-1.5 rounded-full bg-cyan-500/10 text-cyan-400",children:"6 REGIONES"})]}),(0,Xe.jsx)($l.motion.div,{animate:{rotate:r?180:0},children:(0,Xe.jsx)(po.ChevronDown,{size:14,className:"text-text-muted"})})]}),(0,Xe.jsx)($l.AnimatePresence,{initial:!1,children:r&&(0,Xe.jsx)($l.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},className:"overflow-hidden",children:(0,Xe.jsx)("div",{className:"px-4 pb-4 pt-1 space-y-2 bg-black/10",children:Object.keys(Q0).map(h=>(0,Xe.jsxs)("div",{className:"flex items-center gap-3",children:[(0,Xe.jsxs)("div",{className:"w-20 flex items-center gap-1.5",children:[(0,Xe.jsx)("span",{className:`w-5 h-5 rounded bg-surface-glass flex items-center justify-center
|
|
417
|
+
text-[9px] font-bold font-mono text-cyan-400/60 shadow-inner`,children:h}),(0,Xe.jsx)("span",{className:"text-[10px] text-text-muted truncate",children:Q0[h]})]}),(0,Xe.jsxs)("div",{className:"flex-1 relative",children:[(0,Xe.jsx)("select",{value:i[h]||"",onChange:b=>a(h,b.target.value||null),className:`w-full bg-surface-secondary border border-border-default rounded-lg px-3 py-1.5
|
|
418
|
+
text-xs text-text-primary appearance-none cursor-pointer
|
|
419
|
+
hover:border-border-strong transition-colors
|
|
420
|
+
focus:outline-hidden focus:border-cyan-500/40`,children:tC.map(b=>(0,Xe.jsx)("option",{value:b.id||"",children:b.label},b.id||"null"))}),(0,Xe.jsx)(po.ChevronDown,{size:12,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-muted pointer-events-none"})]})]},h))})})})]}),(0,Xe.jsxs)("div",{className:"px-4 pb-3 border-t border-border-subtle pt-3",children:[(0,Xe.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,Xe.jsx)("input",{value:o,onChange:h=>s(h.target.value),onKeyDown:h=>h.key==="Enter"&&p(),placeholder:"Nombre del preset...",className:`flex-1 bg-surface-glass border border-border-default rounded-lg px-3 py-1.5
|
|
421
|
+
text-xs text-text-primary placeholder:text-text-muted outline-hidden
|
|
422
|
+
focus:border-cyan-500/40`}),(0,Xe.jsx)("button",{onClick:p,disabled:!o.trim(),className:`p-1.5 rounded-lg bg-cyan-500/10 text-cyan-400 hover:bg-cyan-500/20
|
|
423
|
+
disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,title:"Guardar Preset",children:(0,Xe.jsx)(po.Save,{size:14})})]}),c.length>0&&(0,Xe.jsx)("div",{className:"space-y-1 max-h-[120px] overflow-y-auto",children:c.map(h=>(0,Xe.jsxs)("div",{className:"flex items-center gap-2 group",children:[(0,Xe.jsx)("button",{onClick:()=>u(h.id),className:`flex-1 text-left px-2 py-1 text-[11px] text-text-secondary
|
|
424
|
+
hover:text-text-primary hover:bg-surface-glass rounded-lg transition-colors`,children:h.name}),(0,Xe.jsx)("button",{onClick:()=>f(h.id),className:`p-1 rounded text-text-muted hover:text-red-400
|
|
425
|
+
opacity-0 group-hover:opacity-100 transition-all`,children:(0,Xe.jsx)(po.Trash2,{size:12})})]},h.id))})]}),(0,Xe.jsxs)("div",{className:"px-4 py-2 border-t border-border-subtle flex items-center justify-between text-[10px] text-text-muted",children:[(0,Xe.jsx)("span",{children:"\u2318K \u2192 buscar slots"}),(0,Xe.jsxs)("button",{onClick:()=>l("player"),className:"flex items-center gap-1 hover:text-text-secondary transition-colors",children:[(0,Xe.jsx)(po.RotateCcw,{size:10}),"Reset"]})]})]})]})})]})}ot();var oC=require("@decido/engine");Us();Qn();var tr=require("react/jsx-runtime");function c$(){let t=mi(n=>n.currentThemeId),e=mi(n=>n.setTheme),r=t!=="decido-light";return(0,tr.jsx)("button",{onClick:()=>e(r?"decido-light":"decido-dark"),className:"w-8 h-8 rounded-lg flex items-center justify-center transition-all duration-200 border text-text-secondary hover:text-text-primary hover:bg-surface-glass border-transparent",title:r?"Cambiar a Decido Light":"Cambiar a Decido Dark","aria-label":r?"Cambiar a tema claro":"Cambiar a tema oscuro",children:(0,tr.jsxs)("div",{className:"relative w-4 h-4",children:[(0,tr.jsx)(In.Sun,{size:16,className:"absolute inset-0 transition-all duration-300",style:{opacity:r?0:1,transform:r?"rotate(-90deg) scale(0.5)":"rotate(0deg) scale(1)",color:r?void 0:"#f59e0b"}}),(0,tr.jsx)(In.Moon,{size:16,className:"absolute inset-0 transition-all duration-300",style:{opacity:r?1:0,transform:r?"rotate(0deg) scale(1)":"rotate(90deg) scale(0.5)",color:r?"#a78bfa":void 0}})]})})}var ju=nC.default.memo(function({extraActions:e=[],modelLabel:r,onModelClick:n}){let o=X(k=>k.isSidebarOpen),s=X(k=>k.setIsSidebarOpen),i=X(k=>k.prototypeBrand),a=X(k=>k.isCreatorMode),l=X(k=>k.setIsCreatorMode),c=X(k=>k.creatorViewMode),d=X(k=>k.setCreatorViewMode),u=X(k=>k.isVoiceActive),{isSpeaking:f}=(0,oC.useEngineStore)(),p=Ut(k=>k.isOpen),h=Ut(k=>k.errorCount),b=Ut(k=>k.togglePanel),g=ke(k=>k.showChat),x=ke(k=>k.setShowChat),y=X(k=>k.setShowChat),m=()=>{let k=!g;x(k),y(k)},v=k=>{l(k),ke.getState().setIsCreatorMode(k)},C=[...[{id:"toggle-chat",icon:g?(0,tr.jsx)(In.MessageSquareOff,{size:16}):(0,tr.jsx)(In.MessageSquare,{size:16}),label:g?"Ocultar chat":"Mostrar chat",onClick:m,variant:g?"ghost":"outline",visibleIn:"both",className:g?"text-text-secondary":"text-accent-cyan bg-surface-glass border-accent-cyan/30"},{id:"debug-panel",icon:(0,tr.jsx)(In.Bug,{size:16}),onClick:b,variant:p?"accent":"ghost",showIndicator:h>0,indicatorColor:"bg-status-error",visibleIn:"both"}],...e].filter(k=>!k.visibleIn||k.visibleIn==="both"||k.visibleIn==="creator"&&a||k.visibleIn==="player"&&!a),A=(k="ghost")=>{switch(k){case"accent":return"bg-surface-glass text-accent-cyan hover:bg-surface-elevated border border-accent-cyan";case"outline":return"bg-transparent text-text-primary hover:bg-surface-glass border-border-default";default:return"bg-transparent text-text-secondary hover:text-text-primary hover:bg-surface-glass border-transparent"}};return(0,tr.jsxs)("header",{"data-tauri-drag-region":!0,className:"flex-none h-12 px-3 flex items-center justify-between bg-surface-secondary backdrop-blur-md border-b border-border-default shadow-[0_1px_3px_0_rgba(0,0,0,0.08)] z-30 select-none",children:[(0,tr.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,tr.jsx)("button",{onClick:()=>s(!o),className:"w-8 h-8 rounded-lg text-text-secondary hover:text-text-primary hover:bg-surface-glass flex items-center justify-center transition-all duration-150 shrink-0",title:o?"Cerrar panel":"Abrir panel",children:o?(0,tr.jsx)(In.PanelLeftClose,{size:18}):(0,tr.jsx)(In.PanelLeftOpen,{size:18})}),(0,tr.jsx)("button",{className:"w-8 h-8 rounded-lg text-text-secondary hover:text-text-primary hover:bg-surface-glass flex items-center justify-center transition-all duration-150 shrink-0",title:"Nueva Conversaci\xF3n",children:(0,tr.jsx)(In.Plus,{size:18})}),(0,tr.jsx)("div",{className:"h-4 w-px bg-border-subtle mx-1 hidden sm:block"}),(0,tr.jsx)("div",{"data-tauri-drag-region":!0,className:"flex items-center gap-2 min-w-0 cursor-default",children:(0,tr.jsx)("span",{className:"text-sm font-semibold text-text-primary/80 tracking-tight truncate hidden sm:inline",children:(0,tr.jsxs)("span",{className:"text-accent-cyan capitalize",children:[i||"Decido"," OS"]})})})]}),(0,tr.jsx)(YN,{isSpeaking:!!f,isCreatorMode:a,creatorViewMode:c,modelLabel:r,onModelClick:n,onSyncCreatorMode:v,onSetCreatorViewMode:d}),(0,tr.jsxs)("div",{className:"flex items-center gap-1",children:[C.map(k=>(0,tr.jsxs)("button",{onClick:k.onClick,className:`relative h-8 rounded-lg flex items-center justify-center transition-all duration-150 border text-xs font-medium ${k.className||""} ${A(k.variant)} ${k.label?"px-3 gap-1.5":"w-8"}`,title:k.label,children:[k.icon,k.label&&(0,tr.jsx)("span",{className:"hidden sm:inline",children:k.label}),k.showIndicator&&(0,tr.jsx)("span",{className:`absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full ${k.indicatorColor||"bg-accent-cyan"} shadow-[0_0_6px] animate-pulse`})]},k.id)),(0,tr.jsx)(c$,{}),(0,tr.jsx)(hh,{}),(0,tr.jsx)("button",{className:"w-8 h-8 rounded-lg text-text-secondary hover:text-text-primary hover:bg-surface-glass flex items-center justify-center transition-all duration-150",title:"Compartir",children:(0,tr.jsx)(In.Share2,{size:16})})]})]})});var zB=require("@decido/engine");var sC=require("react"),ud=require("@decido/engine");ot();Ol();var d$=()=>{let{isConnected:t,isNativeOS:e,emitEvent:r}=ed(),n=(0,ud.useEngineStore)(s=>s.lastEvent),o=X(s=>s.addLog);(0,sC.useEffect)(()=>{if(n?.type==="MCP_EXECUTION_REQUESTED"){let{intent:s,tool:i,context:a,parameters:l}=n.payload||{},c=n.targetNodeId,d=s||i;if(e||t){o(`\u{1F980} [OS Kernel] Solicitando ejecuci\xF3n nativa: ${d}`,"system"),fetch("http://localhost:3101/api/explorer/execute_tool",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool_name:d,args:a||l})}).then(u=>u.json()).then(u=>{if(u.success||u.result)o(`\u2705 [Daemon REST] Herramienta completada: ${d}`,"success"),ud.useEngineStore.getState().dispatchEvent({type:"NODE_COMPLETED",targetNodeId:c,routeHandle:"success",variables:{result:u.result,...u}});else throw new Error(u.error||"Server error")}).catch(u=>{o(`\u274C [Daemon REST] Error en la herramienta ${d}: ${u.message}`,"error"),ud.useEngineStore.getState().dispatchEvent({type:"NODE_COMPLETED",targetNodeId:c,routeHandle:"error",variables:{error:u.message,mcp_error:u.message}})});return}else{o(`[Local Mock] Simulando callback resolutivo para: ${d}`,"system");let u=setTimeout(()=>{ud.useEngineStore.getState().dispatchEvent({type:"NODE_COMPLETED",targetNodeId:c,routeHandle:"success",variables:{mockValue:Math.floor(Math.random()*100),mocked_intent:d}})},1500);return()=>clearTimeout(u)}}},[n,t,e,r,o]),B0("mcp:response",s=>{let{targetNodeId:i,status:a,data:l,error:c}=s;if(!i){o(`\u26A0\uFE0F [OS Kernel] Respuesta hu\xE9rfana (sin targetNodeId): ${a}`,"error");return}o(`\u2705 [OS Kernel] Respuesta recibida para nodo ${i}: ${a}`,a==="success"?"success":"error");let d=a==="success"?"success":"error";ud.useEngineStore.getState().dispatchEvent({type:"NODE_COMPLETED",targetNodeId:i,routeHandle:d,variables:{...l,mcp_error:c}})})},iC=()=>(d$(),null);ex();ot();var Wn=require("react-resizable-panels");Qn();var As=Re(require("react")),pa=require("react/jsx-runtime"),mj=As.default.lazy(()=>Promise.resolve().then(()=>(W2(),j2)).then(t=>({default:t.CenterComposite}))),gj=As.default.lazy(()=>Promise.resolve().then(()=>(Mh(),YC)).then(t=>({default:t.PlaygroundChat}))),bj=As.default.lazy(()=>Promise.resolve().then(()=>(Gh(),y2)).then(t=>({default:t.DebugPanel}))),xj=As.default.lazy(()=>Promise.resolve().then(()=>(lx(),JC)).then(t=>({default:t.PlaygroundTerminal}))),yj=As.default.lazy(()=>Promise.resolve().then(()=>(im(),vE)).then(t=>({default:t.MorphShell}))),vj=As.default.lazy(()=>Promise.resolve().then(()=>(YP(),qP)).then(t=>({default:t.ReactFlowEditor}))),wj=As.default.lazy(()=>Promise.resolve().then(()=>(rR(),tR)).then(t=>({default:t.TimelineEditor}))),Sj=As.default.lazy(()=>Promise.resolve().then(()=>(ex(),pC)).then(t=>({default:t.PlaygroundAppSidebar}))),Nj=As.default.lazy(()=>Promise.resolve().then(()=>(gv(),pR)).then(t=>({default:t.WidgetSlotPanel}))),Cj=()=>(0,pa.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,pa.jsx)("div",{className:"w-6 h-6 border-2 border-cyan-500 border-t-transparent rounded-full animate-spin"})}),bv={"workspace-chat":mj,chat:gj,debug:bj,terminal:xj,canvas:yj,"graph-editor":vj,"timeline-editor":wj,"app-sidebar":Sj,"widget-panel":Nj},ti=As.default.memo(function({componentId:e,slotProps:r={},className:n=""}){if(!e)return null;let o=bv[e];return o?(0,pa.jsx)(As.default.Suspense,{fallback:(0,pa.jsx)(Cj,{}),children:(0,pa.jsx)("div",{className:`w-full h-full overflow-hidden ${n}`,children:(0,pa.jsx)(o,{...r})})}):(0,pa.jsxs)("div",{className:`w-full h-full flex items-center justify-center text-text-muted text-xs font-mono ${n}`,children:["Unknown slot: ",e]})});function hR(t,e){bv[t]=e}function mR(){return Object.keys(bv)}var gR=Re(require("react")),Kf=require("motion/react"),bR=require("lucide-react");Qn();mo();ot();var ha=require("react/jsx-runtime");function vg({className:t=""}){let e=ke(i=>i.tabs),r=ke(i=>i.activeTabId),n=ke(i=>i.setActiveTab),o=ke(i=>i.removeTab),s=gR.default.useCallback(i=>{if(n(i),i.startsWith("morph-")){let a=i.replace("morph-","");Ue.getState().setActiveInstance(a);let l=Ue.getState().instances.get(a);l?.sourceChatId&&X.getState().setActiveChatId(l.sourceChatId)}},[n]);return e.length===0?null:(0,ha.jsx)("div",{className:`flex items-center gap-0.5 px-2 py-1 bg-surface-primary border-b border-border-subtle overflow-x-auto scrollbar-hide ${t}`,children:(0,ha.jsx)(Kf.AnimatePresence,{mode:"popLayout",children:e.map(i=>(0,ha.jsxs)(Kf.motion.button,{layout:!0,initial:{opacity:0,scale:.9,width:0},animate:{opacity:1,scale:1,width:"auto"},exit:{opacity:0,scale:.9,width:0},onClick:()=>s(i.id),className:`
|
|
426
|
+
flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-medium
|
|
427
|
+
transition-colors whitespace-nowrap group relative shrink-0
|
|
428
|
+
${r===i.id?"bg-surface-glass text-text-primary shadow-xs border border-border-default":"text-text-muted hover:text-text-primary hover:bg-surface-glass border border-transparent"}
|
|
429
|
+
`,children:[(0,ha.jsx)("span",{className:"truncate max-w-[120px]",children:i.label}),i.closeable!==!1&&(0,ha.jsx)("span",{onClick:a=>{a.stopPropagation(),o(i.id)},className:`w-4 h-4 rounded-md flex items-center justify-center
|
|
430
|
+
opacity-0 group-hover:opacity-100 hover:bg-surface-glass hover:text-red-400
|
|
431
|
+
transition-all ml-0.5`,children:(0,ha.jsx)(bR.X,{size:10})}),r===i.id&&(0,ha.jsx)(Kf.motion.div,{layoutId:"tab-indicator",className:"absolute bottom-0 left-1 right-1 h-[2px] bg-cyan-500/60 rounded-full"})]},i.id))})})}var wt=require("react/jsx-runtime"),xR="w-1.5 hover:bg-cyan-500/20 active:bg-cyan-500/30 transition-colors cursor-col-resize z-40 relative group flex items-center justify-center",yR=(0,wt.jsx)("div",{className:"w-[2px] h-10 bg-white/5 rounded-full group-hover:bg-cyan-500/60 transition-colors"}),vR="h-1.5 hover:bg-cyan-500/20 active:bg-cyan-500/30 transition-colors cursor-row-resize z-40 relative group flex items-center justify-center",wR=(0,wt.jsx)("div",{className:"h-[2px] w-10 bg-white/5 rounded-full group-hover:bg-cyan-500/60 transition-colors"}),xv="h-full overflow-hidden flex flex-col min-w-0 min-h-0 bg-surface-secondary border-r border-border-subtle shadow-[inset_-6px_0_20px_rgba(0,0,0,0.15)]",yv="h-full overflow-hidden flex flex-col min-w-0 min-h-0 bg-surface-secondary border-l border-border-subtle shadow-[inset_6px_0_20px_rgba(0,0,0,0.15)]";function wg({children:t,slotProps:e={}}){let r=ke(x=>x.slots),n=ke(x=>x.tabs),o=ke(x=>x.showCanvas),i=ke(x=>x.showChat)?r.R1:null,a=!!(i||r.R2),l=!!(r.R3||r.R4),c=!!r.R6,d=n.length>0,u=`${a?"L":""}${o?"C":""}${l?"R":""}`,f=o?l?20:25:l?50:100,p=o?35:l?70:100,h=o?a?25:40:a?50:100,b=o?60:a?70:100,g=a&&l?40:a?60:l?50:100;return(0,wt.jsxs)("div",{className:"flex-1 flex flex-col h-full overflow-hidden min-w-0 min-h-0",children:[r.R5&&(0,wt.jsx)("div",{className:"flex-none",children:(0,wt.jsx)(ti,{componentId:r.R5,slotProps:e})}),d&&(0,wt.jsx)(vg,{}),(0,wt.jsxs)(Wn.Group,{orientation:"horizontal",className:"flex-1 min-w-0 min-h-0",children:[a&&(0,wt.jsx)(Wn.Panel,{id:"left-column",defaultSize:f,minSize:15,className:"h-full overflow-hidden flex flex-col min-w-0 min-h-0",children:i&&r.R2?(0,wt.jsxs)(Wn.Group,{orientation:"vertical",className:"h-full min-w-0 min-h-0",children:[(0,wt.jsx)(Wn.Panel,{id:"R1",defaultSize:65,minSize:20,className:"flex flex-col min-w-0 min-h-0",children:(0,wt.jsx)("div",{className:xv,children:(0,wt.jsx)(ti,{componentId:i,slotProps:e})})}),(0,wt.jsx)(Wn.Separator,{className:vR,children:wR}),(0,wt.jsx)(Wn.Panel,{id:"R2",defaultSize:35,minSize:15,className:"flex flex-col min-w-0 min-h-0",children:(0,wt.jsx)("div",{className:xv,children:(0,wt.jsx)(ti,{componentId:r.R2,slotProps:e})})})]}):(0,wt.jsx)("div",{className:xv,children:(0,wt.jsx)(ti,{componentId:i||r.R2,slotProps:e})})}),a&&o&&(0,wt.jsx)(Wn.Separator,{id:"h-left",className:xR,children:yR}),o&&(0,wt.jsx)(Wn.Panel,{id:"center",defaultSize:g,minSize:20,className:"h-full overflow-hidden flex flex-col min-w-0 min-h-0",children:(0,wt.jsx)("div",{className:"h-full flex flex-col overflow-hidden bg-surface-secondary min-w-0 min-h-0",children:t})}),l&&(o||a)&&(0,wt.jsx)(Wn.Separator,{id:"h-right",className:xR,children:yR}),l&&(0,wt.jsx)(Wn.Panel,{id:"right-column",defaultSize:h,minSize:15,className:"h-full overflow-hidden flex flex-col min-w-0 min-h-0",children:r.R3&&r.R4?(0,wt.jsxs)(Wn.Group,{orientation:"vertical",className:"h-full min-w-0 min-h-0",children:[(0,wt.jsx)(Wn.Panel,{id:"R3",defaultSize:65,minSize:20,className:"flex flex-col min-w-0 min-h-0",children:(0,wt.jsx)("div",{className:yv,children:(0,wt.jsx)(ti,{componentId:r.R3,slotProps:e})})}),(0,wt.jsx)(Wn.Separator,{className:vR,children:wR}),(0,wt.jsx)(Wn.Panel,{id:"R4",defaultSize:35,minSize:15,className:"flex flex-col min-w-0 min-h-0",children:(0,wt.jsx)("div",{className:yv,children:(0,wt.jsx)(ti,{componentId:r.R4,slotProps:e})})})]}):(0,wt.jsx)("div",{className:yv,children:(0,wt.jsx)(ti,{componentId:r.R3||r.R4,slotProps:e})})})]},u),c&&(0,wt.jsx)("div",{className:"flex-none border-t border-border-subtle",children:(0,wt.jsx)(ti,{componentId:r.R6,slotProps:e})})]})}Qn();var Sg=require("motion/react"),il=require("react/jsx-runtime");function SR(){return(0,il.jsxs)("div",{className:"h-dvh w-full bg-surface-primary flex flex-col items-center justify-center font-mono text-cyan-400 relative overflow-hidden",children:[(0,il.jsx)("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E')] opacity-[0.15] mix-blend-overlay pointer-events-none z-0"}),(0,il.jsxs)(Sg.motion.div,{initial:{opacity:0},animate:{opacity:1},className:"z-10 flex flex-col items-center",children:[(0,il.jsx)("div",{className:"w-16 h-16 rounded-full border-[3px] border-cyan-500/30 border-t-cyan-400 animate-spin mb-6 shadow-[0_0_30px_rgba(34,211,238,0.2)]"}),(0,il.jsx)(Sg.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.5},className:"text-sm tracking-widest uppercase mb-2 font-bold",children:"Inicializando yo.decido"}),(0,il.jsx)(Sg.motion.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1},className:"text-xs text-text-muted",children:"Cargando m\xF3dulos de IA y telemetr\xEDa..."})]})]})}var NR=require("react"),CR=require("@decido/logger");ot();Us();function kR(){let t=X(r=>r.addLog),e=Ut(r=>r.addLogEntry);(0,NR.useEffect)(()=>{let r=CR.logger.subscribe(n=>{let o=n.categories.length>0?`[${n.categories.join(",")}] `:"";t(`${o}${n.message}`,n.level),e({timestamp:n.timestamp,level:n.level,categories:n.categories,message:n.message,data:n.data,source:n.source})});return()=>r()},[t,e])}var ER=require("react");ot();bx();function TR(){let t=X(r=>r.setIsBooting),e=X(r=>r.isMuted);(0,ER.useEffect)(()=>{let r=setTimeout(()=>{t(!1),ef("success",e)},2500);return()=>clearTimeout(r)},[e,t])}im();xx();qh();var Ng=require("react"),IR=require("socket.io-client");ot();var Ej={},kj=Ej.env?.VITE_API_BASE_URL||"http://localhost:3001",AR=()=>{let{addChatMessage:t,isMuted:e}=X(),r=(0,Ng.useRef)(new Set);(0,Ng.useEffect)(()=>{let n=(0,IR.io)(kj,{reconnectionAttempts:5,reconnectionDelay:2e3}),o=s=>{if(s){let{wamid:i,from:a,type:l,timestamp:c,name:d,content:u}=s;if(i&&r.current.has(i))return;i&&r.current.add(i);let f=parseInt(c),p=new Date(f>1e10?f:f*1e3),h={type:"div",props:{className:"w-full outline-hidden bg-transparent flex flex-col p-4 gap-3 border-l-4 border-l-[#25D366]"},children:[{type:"div",props:{className:"flex items-center gap-3 border-b border-white/5 pb-3"},children:[{type:"div",props:{className:"flex items-center justify-center p-2 bg-[#25D366]/20 rounded-full text-[#25D366] w-8 h-8 font-bold text-xs"},children:"WA"},{type:"div",props:{className:"flex flex-col"},children:[{type:"span",props:{className:"font-semibold text-text-primary text-xs"},children:d?`${d}`:`${a}`},{type:"span",props:{className:"text-[#25D366] text-[10px] uppercase font-mono tracking-wider"},children:`Recibido a las ${p.toLocaleTimeString()}`}]}]},{type:"p",props:{className:"text-text-secondary leading-relaxed bg-black/20 p-3 rounded-lg border border-white/5"},children:u||"Mensaje interactivo o multimedia (Abrir WhatsApp Studio para ver)"},{type:"button",props:{className:"mt-2 w-full py-2 bg-[#25D366]/20 hover:bg-[#25D366]/30 text-[#25D366] rounded-lg transition-colors text-xs font-bold border border-[#25D366]/20 flex items-center justify-center gap-2"},children:"Abrir WhatsApp Studio",onAction:{command:"studio:openPlugin",payload:{pluginId:"chameleon",view:"discovery_admin"}}},{type:"button",props:{className:"mt-1 w-full py-2 bg-surface-secondary hover:bg-surface-tertiary text-text-secondary rounded-lg transition-colors text-xs font-medium border border-border-default flex items-center justify-center gap-2"},children:"Ver Kanban de Pedidos",onAction:{command:"studio:openPlugin",payload:{pluginId:"chameleon",view:"enterprise_kanban"}}}]};t({type:"ui-artifact",sender:"agent",text:`Nuevo mensaje de WhatsApp de ${d||a}`,actorId:"whatsapp",actorName:"WhatsApp Gateway",uiSchema:JSON.stringify(h)})}};return n.on("wa:message_received",o),n.on("connect",()=>{console.log("[WhatsApp Listener] Conectado al backend para mensajes globales:",n.id)}),()=>{n.off("wa:message_received",o),n.disconnect()}},[t,e])};gv();var Al=require("@decido/plugin-engine");var vv="http://localhost:3333",MR={id:"sentinel-ui",name:"Sentinel AI",description:"Observability suite: telemetry, error tracking, and session replay for Decido OS",author:"Decido Engineering",version:"2.0.0",icon:"Shield",color:"#3b82f6",engines:{},permissions:["events:read","sessions:read","errors:read"],intents:["sentinel:openTelemetry","sentinel:openErrors","sentinel:openReplays"],widgets:[{id:"sentinel-telemetry",name:"Telemetry Dashboard",icon:"Activity",defaultZone:"main-canvas",schema:{type:"div",props:{className:"p-4 space-y-5 bg-zinc-950 min-h-full"},children:[{type:"div",props:{className:"flex items-center justify-between"},children:[{type:"h2",props:{className:"text-lg font-bold text-white flex items-center gap-2"},children:["\u{1F6E1}\uFE0F Sentinel \u2014 Telemetry"]},{type:"StatusBadge",props:{status:"online",label:"Live"}}]},{type:"div",props:{className:"grid grid-cols-3 gap-3"},children:[{type:"MetricCard",props:{label:"Events/min",value:1247,color:"emerald",trend:"up"}},{type:"MetricCard",props:{label:"Avg Latency",value:"23ms",color:"amber",trend:"down"}},{type:"MetricCard",props:{label:"Uptime",value:"99.7%",color:"cyan",trend:"stable"}}]},{type:"div",props:{className:"grid grid-cols-2 gap-3"},children:[{type:"div",props:{className:"p-3 bg-zinc-900/50 rounded-lg border border-white/5 space-y-2"},children:[{type:"div",props:{className:"flex items-center justify-between"},children:[{type:"span",props:{className:"text-[10px] text-zinc-500 uppercase tracking-wider"},children:["Event Rate (60s)"]},{type:"Sparkline",props:{color:"cyan",height:28}}]}]},{type:"div",props:{className:"p-3 bg-zinc-900/50 rounded-lg border border-white/5 space-y-2"},children:[{type:"ProgressBar",props:{label:"Memory",value:67,color:"emerald"}},{type:"ProgressBar",props:{label:"CPU",value:34,color:"cyan"}}]}]},{type:"div",props:{className:"p-3 bg-zinc-900/50 rounded-lg border border-white/5 space-y-2"},children:[{type:"h3",props:{className:"text-xs font-semibold text-zinc-400 uppercase tracking-wider"},children:["Recent Events"]},{type:"EventList",dataSource:"sentinel.events",props:{maxItems:5}}]}]}},{id:"sentinel-errors",name:"Error Tracking",icon:"AlertTriangle",defaultZone:"main-canvas",schema:{type:"div",props:{className:"p-4 space-y-4 bg-zinc-950 min-h-full"},children:[{type:"div",props:{className:"flex items-center justify-between"},children:[{type:"h2",props:{className:"text-lg font-bold text-white flex items-center gap-2"},children:["\u{1F534} Error Tracking"]},{type:"MetricCard",props:{label:"Total Errors",value:2,color:"red"}}]},{type:"ErrorList",dataSource:"sentinel.errors",props:{}},{type:"button",props:{className:"w-full px-4 py-2.5 bg-red-600/20 hover:bg-red-600/30 text-red-400 text-sm rounded-lg font-medium transition-colors border border-red-500/20"},children:["\u{1F5D1}\uFE0F Clear All Errors"],onAction:{command:"sentinel:clearErrors"}}]}},{id:"sentinel-replays",name:"Session Replay",icon:"Film",defaultZone:"main-canvas",schema:{type:"div",props:{className:"p-4 space-y-4 bg-zinc-950 min-h-full"},children:[{type:"div",props:{className:"flex items-center justify-between"},children:[{type:"h2",props:{className:"text-lg font-bold text-white flex items-center gap-2"},children:["\u{1F3AC} Session Replay"]},{type:"StatusBadge",props:{status:"online",label:"Recording"}}]},{type:"div",props:{className:"grid grid-cols-2 gap-3"},children:[{type:"MetricCard",props:{label:"Sessions Today",value:3,color:"blue"}},{type:"MetricCard",props:{label:"Avg Duration",value:"4:30",color:"cyan"}}]},{type:"div",props:{className:"p-4 bg-zinc-900/50 rounded-lg border border-white/5 text-center space-y-3"},children:[{type:"div",props:{className:"text-4xl"},children:["\u{1F4F9}"]},{type:"p",props:{className:"text-sm text-zinc-300"},children:["Latest session: 4 min 32s"]},{type:"ProgressBar",props:{label:"Playback",value:72,color:"blue"}},{type:"button",props:{className:"px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm rounded-lg font-medium transition-colors"},children:["\u25B6 Play Latest Session"],onAction:{command:"sentinel:openReplay",payload:{sessionId:"latest"}}}]}]}}],sidebarItems:[{id:"telemetry",label:"Telemetry Dashboard",icon:"Activity",section:"sentinel",sectionTitle:"\u{1F6E1}\uFE0F Sentinel AI",targetWidget:"sentinel-telemetry"},{id:"errors",label:"Error Tracking",icon:"AlertTriangle",section:"sentinel",sectionTitle:"\u{1F6E1}\uFE0F Sentinel AI",targetWidget:"sentinel-errors"},{id:"replays",label:"Session Replay",icon:"Film",section:"sentinel",sectionTitle:"\u{1F6E1}\uFE0F Sentinel AI",targetWidget:"sentinel-replays"}]},PR={"sentinel-telemetry":`${vv}/`,"sentinel-errors":`${vv}/errors`,"sentinel-replays":`${vv}/replays`};var LB=require("@decido/sdk");var jg=require("react");var FR=require("zustand"),HR=require("zustand/middleware");var RR=t=>t<5?24:72,DR=(t,e)=>{let r=t.toLowerCase();return r.includes("perforacion")||r.includes("dise\xF1o")||r.includes("cnc")?"HOMAG":e>10||r.includes("grueso")||r.includes("18mm")?"GABBIANI":"SIGMA"},OR=t=>{let e=t.replace(/\D/g,"");return e.startsWith("57")?`+${e}`:`+57 ${e}`};var Tj={DISE\u00D1O:["OPTIMIZACION","CAJA"],OPTIMIZACION:["CAJA","PRODUCCION"],CAJA:["PRODUCCION"],PRODUCCION:["DESPACHO"],DESPACHO:["ENTREGADO"],ENTREGADO:[]},_R=(t,e)=>{let r=t.status;return(Tj[r]||[]).includes(e)?e==="PRODUCCION"&&!t.isPaid?{allowed:!1,reason:"Bloqueo de Caja: El pedido debe estar pagado para entrar a Planta."}:e==="DESPACHO"&&t.status!=="PRODUCCION"?{allowed:!1,reason:"El pedido debe salir de producci\xF3n antes de despacharse."}:{allowed:!0}:{allowed:!1,reason:`Flujo inv\xE1lido: No se puede pasar de ${r} a ${e}.`}};var Le=Re(require("react"),1),zR=Re(require("react-dom"),1),Co=Re(require("react"),1),wv=Re(require("react"),1),$R=Re(require("react"),1),Ij=t=>{switch(t){case"success":return Pj;case"info":return Dj;case"warning":return Rj;case"error":return Oj;default:return null}},Aj=Array(12).fill(0),Mj=({visible:t,className:e})=>Co.default.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},Co.default.createElement("div",{className:"sonner-spinner"},Aj.map((r,n)=>Co.default.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),Pj=Co.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Co.default.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),Rj=Co.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Co.default.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Dj=Co.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Co.default.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Oj=Co.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Co.default.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),_j=Co.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},Co.default.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Co.default.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Lj=()=>{let[t,e]=wv.default.useState(document.hidden);return wv.default.useEffect(()=>{let r=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},Sv=1,Bj=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let e=this.subscribers.indexOf(t);this.subscribers.splice(e,1)}),this.publish=t=>{this.subscribers.forEach(e=>e(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var e;let{message:r,...n}=t,o=typeof t?.id=="number"||((e=t.id)==null?void 0:e.length)>0?t.id:Sv++,s=this.toasts.find(a=>a.id===o),i=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...t,id:o,title:r}),{...a,...t,id:o,dismissible:i,title:r}):a):this.addToast({title:r,...n,dismissible:i,id:o}),o},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(e=>{this.subscribers.forEach(r=>r({id:e.id,dismiss:!0}))}),this.subscribers.forEach(e=>e({id:t,dismiss:!0})),t),this.message=(t,e)=>this.create({...e,message:t}),this.error=(t,e)=>this.create({...e,message:t,type:"error"}),this.success=(t,e)=>this.create({...e,type:"success",message:t}),this.info=(t,e)=>this.create({...e,type:"info",message:t}),this.warning=(t,e)=>this.create({...e,type:"warning",message:t}),this.loading=(t,e)=>this.create({...e,type:"loading",message:t}),this.promise=(t,e)=>{if(!e)return;let r;e.loading!==void 0&&(r=this.create({...e,promise:t,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));let n=t instanceof Promise?t:t(),o=r!==void 0,s,i=n.then(async l=>{if(s=["resolve",l],$R.default.isValidElement(l))o=!1,this.create({id:r,type:"default",message:l});else if($j(l)&&!l.ok){o=!1;let c=typeof e.error=="function"?await e.error(`HTTP error! status: ${l.status}`):e.error,d=typeof e.description=="function"?await e.description(`HTTP error! status: ${l.status}`):e.description;this.create({id:r,type:"error",message:c,description:d})}else if(e.success!==void 0){o=!1;let c=typeof e.success=="function"?await e.success(l):e.success,d=typeof e.description=="function"?await e.description(l):e.description;this.create({id:r,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],e.error!==void 0){o=!1;let c=typeof e.error=="function"?await e.error(l):e.error,d=typeof e.description=="function"?await e.description(l):e.description;this.create({id:r,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(r),r=void 0),(l=e.finally)==null||l.call(e)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof r!="string"&&typeof r!="number"?{unwrap:a}:Object.assign(r,{unwrap:a})},this.custom=(t,e)=>{let r=e?.id||Sv++;return this.create({jsx:t(r),id:r,...e}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},zo=new Bj,zj=(t,e)=>{let r=e?.id||Sv++;return zo.addToast({title:t,...e,id:r}),r},$j=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",Fj=zj,Hj=()=>zo.toasts,Vj=()=>zo.getActiveToasts(),Bt=Object.assign(Fj,{success:zo.success,info:zo.info,warning:zo.warning,error:zo.error,custom:zo.custom,message:zo.message,promise:zo.promise,dismiss:zo.dismiss,loading:zo.loading},{getHistory:Hj,getToasts:Vj});function jj(t,{insertAt:e}={}){if(!t||typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e==="top"&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}jj(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
432
|
+
`);function Cg(t){return t.label!==void 0}var Wj=3,Uj="32px",Gj="16px",LR=4e3,Kj=356,qj=14,Yj=20,Xj=200;function ri(...t){return t.filter(Boolean).join(" ")}function Jj(t){let[e,r]=t.split("-"),n=[];return e&&n.push(e),r&&n.push(r),n}var Zj=t=>{var e,r,n,o,s,i,a,l,c,d,u;let{invert:f,toast:p,unstyled:h,interacting:b,setHeights:g,visibleToasts:x,heights:y,index:m,toasts:v,expanded:S,removeToast:w,defaultRichColors:C,closeButton:A,style:k,cancelButtonStyle:M,actionButtonStyle:T,className:E="",descriptionClassName:P="",duration:N,position:D,gap:R,loadingIcon:O,expandByDefault:B,classNames:L,icons:H,closeButtonAriaLabel:j="Close toast",pauseWhenPageIsHidden:$}=t,[q,F]=Le.default.useState(null),[_,W]=Le.default.useState(null),[V,z]=Le.default.useState(!1),[G,Y]=Le.default.useState(!1),[Z,se]=Le.default.useState(!1),[we,_e]=Le.default.useState(!1),[Pe,K]=Le.default.useState(!1),[he,lt]=Le.default.useState(0),[He,nt]=Le.default.useState(0),dr=Le.default.useRef(p.duration||N||LR),ln=Le.default.useRef(null),Tr=Le.default.useRef(null),bn=m===0,St=m+1<=x,mt=p.type,je=p.dismissible!==!1,or=p.className||"",fo=p.descriptionClassName||"",Jn=Le.default.useMemo(()=>y.findIndex(We=>We.toastId===p.id)||0,[y,p.id]),Ao=Le.default.useMemo(()=>{var We;return(We=p.closeButton)!=null?We:A},[p.closeButton,A]),pi=Le.default.useMemo(()=>p.duration||N||LR,[p.duration,N]),ps=Le.default.useRef(0),cn=Le.default.useRef(0),ne=Le.default.useRef(0),be=Le.default.useRef(null),[me,ue]=D.split("-"),ht=Le.default.useMemo(()=>y.reduce((We,ct,xt)=>xt>=Jn?We:We+ct.height,0),[y,Jn]),Zt=Lj(),Wo=p.invert||f,Qt=mt==="loading";cn.current=Le.default.useMemo(()=>Jn*R+ht,[Jn,ht]),Le.default.useEffect(()=>{dr.current=pi},[pi]),Le.default.useEffect(()=>{z(!0)},[]),Le.default.useEffect(()=>{let We=Tr.current;if(We){let ct=We.getBoundingClientRect().height;return nt(ct),g(xt=>[{toastId:p.id,height:ct,position:p.position},...xt]),()=>g(xt=>xt.filter(Ir=>Ir.toastId!==p.id))}},[g,p.id]),Le.default.useLayoutEffect(()=>{if(!V)return;let We=Tr.current,ct=We.style.height;We.style.height="auto";let xt=We.getBoundingClientRect().height;We.style.height=ct,nt(xt),g(Ir=>Ir.find(dn=>dn.toastId===p.id)?Ir.map(dn=>dn.toastId===p.id?{...dn,height:xt}:dn):[{toastId:p.id,height:xt,position:p.position},...Ir])},[V,p.title,p.description,g,p.id]);let Gt=Le.default.useCallback(()=>{Y(!0),lt(cn.current),g(We=>We.filter(ct=>ct.toastId!==p.id)),setTimeout(()=>{w(p)},Xj)},[p,w,g,cn]);Le.default.useEffect(()=>{if(p.promise&&mt==="loading"||p.duration===1/0||p.type==="loading")return;let We;return S||b||$&&Zt?(()=>{if(ne.current<ps.current){let ct=new Date().getTime()-ps.current;dr.current=dr.current-ct}ne.current=new Date().getTime()})():dr.current!==1/0&&(ps.current=new Date().getTime(),We=setTimeout(()=>{var ct;(ct=p.onAutoClose)==null||ct.call(p,p),Gt()},dr.current)),()=>clearTimeout(We)},[S,b,p,mt,$,Zt,Gt]),Le.default.useEffect(()=>{p.delete&&Gt()},[Gt,p.delete]);function $n(){var We,ct,xt;return H!=null&&H.loading?Le.default.createElement("div",{className:ri(L?.loader,(We=p?.classNames)==null?void 0:We.loader,"sonner-loader"),"data-visible":mt==="loading"},H.loading):O?Le.default.createElement("div",{className:ri(L?.loader,(ct=p?.classNames)==null?void 0:ct.loader,"sonner-loader"),"data-visible":mt==="loading"},O):Le.default.createElement(Mj,{className:ri(L?.loader,(xt=p?.classNames)==null?void 0:xt.loader),visible:mt==="loading"})}return Le.default.createElement("li",{tabIndex:0,ref:Tr,className:ri(E,or,L?.toast,(e=p?.classNames)==null?void 0:e.toast,L?.default,L?.[mt],(r=p?.classNames)==null?void 0:r[mt]),"data-sonner-toast":"","data-rich-colors":(n=p.richColors)!=null?n:C,"data-styled":!(p.jsx||p.unstyled||h),"data-mounted":V,"data-promise":!!p.promise,"data-swiped":Pe,"data-removed":G,"data-visible":St,"data-y-position":me,"data-x-position":ue,"data-index":m,"data-front":bn,"data-swiping":Z,"data-dismissible":je,"data-type":mt,"data-invert":Wo,"data-swipe-out":we,"data-swipe-direction":_,"data-expanded":!!(S||B&&V),style:{"--index":m,"--toasts-before":m,"--z-index":v.length-m,"--offset":`${G?he:cn.current}px`,"--initial-height":B?"auto":`${He}px`,...k,...p.style},onDragEnd:()=>{se(!1),F(null),be.current=null},onPointerDown:We=>{Qt||!je||(ln.current=new Date,lt(cn.current),We.target.setPointerCapture(We.pointerId),We.target.tagName!=="BUTTON"&&(se(!0),be.current={x:We.clientX,y:We.clientY}))},onPointerUp:()=>{var We,ct,xt,Ir;if(we||!je)return;be.current=null;let dn=Number(((We=Tr.current)==null?void 0:We.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),sr=Number(((ct=Tr.current)==null?void 0:ct.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Tn=new Date().getTime()-((xt=ln.current)==null?void 0:xt.getTime()),Ar=q==="x"?dn:sr,un=Math.abs(Ar)/Tn;if(Math.abs(Ar)>=Yj||un>.11){lt(cn.current),(Ir=p.onDismiss)==null||Ir.call(p,p),W(q==="x"?dn>0?"right":"left":sr>0?"down":"up"),Gt(),_e(!0),K(!1);return}se(!1),F(null)},onPointerMove:We=>{var ct,xt,Ir,dn;if(!be.current||!je||((ct=window.getSelection())==null?void 0:ct.toString().length)>0)return;let sr=We.clientY-be.current.y,Tn=We.clientX-be.current.x,Ar=(xt=t.swipeDirections)!=null?xt:Jj(D);!q&&(Math.abs(Tn)>1||Math.abs(sr)>1)&&F(Math.abs(Tn)>Math.abs(sr)?"x":"y");let un={x:0,y:0};q==="y"?(Ar.includes("top")||Ar.includes("bottom"))&&(Ar.includes("top")&&sr<0||Ar.includes("bottom")&&sr>0)&&(un.y=sr):q==="x"&&(Ar.includes("left")||Ar.includes("right"))&&(Ar.includes("left")&&Tn<0||Ar.includes("right")&&Tn>0)&&(un.x=Tn),(Math.abs(un.x)>0||Math.abs(un.y)>0)&&K(!0),(Ir=Tr.current)==null||Ir.style.setProperty("--swipe-amount-x",`${un.x}px`),(dn=Tr.current)==null||dn.style.setProperty("--swipe-amount-y",`${un.y}px`)}},Ao&&!p.jsx?Le.default.createElement("button",{"aria-label":j,"data-disabled":Qt,"data-close-button":!0,onClick:Qt||!je?()=>{}:()=>{var We;Gt(),(We=p.onDismiss)==null||We.call(p,p)},className:ri(L?.closeButton,(o=p?.classNames)==null?void 0:o.closeButton)},(s=H?.close)!=null?s:_j):null,p.jsx||(0,Le.isValidElement)(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:Le.default.createElement(Le.default.Fragment,null,mt||p.icon||p.promise?Le.default.createElement("div",{"data-icon":"",className:ri(L?.icon,(i=p?.classNames)==null?void 0:i.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||$n():null,p.type!=="loading"?p.icon||H?.[mt]||Ij(mt):null):null,Le.default.createElement("div",{"data-content":"",className:ri(L?.content,(a=p?.classNames)==null?void 0:a.content)},Le.default.createElement("div",{"data-title":"",className:ri(L?.title,(l=p?.classNames)==null?void 0:l.title)},typeof p.title=="function"?p.title():p.title),p.description?Le.default.createElement("div",{"data-description":"",className:ri(P,fo,L?.description,(c=p?.classNames)==null?void 0:c.description)},typeof p.description=="function"?p.description():p.description):null),(0,Le.isValidElement)(p.cancel)?p.cancel:p.cancel&&Cg(p.cancel)?Le.default.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||M,onClick:We=>{var ct,xt;Cg(p.cancel)&&je&&((xt=(ct=p.cancel).onClick)==null||xt.call(ct,We),Gt())},className:ri(L?.cancelButton,(d=p?.classNames)==null?void 0:d.cancelButton)},p.cancel.label):null,(0,Le.isValidElement)(p.action)?p.action:p.action&&Cg(p.action)?Le.default.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||T,onClick:We=>{var ct,xt;Cg(p.action)&&((xt=(ct=p.action).onClick)==null||xt.call(ct,We),!We.defaultPrevented&&Gt())},className:ri(L?.actionButton,(u=p?.classNames)==null?void 0:u.actionButton)},p.action.label):null))};function BR(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function Qj(t,e){let r={};return[t,e].forEach((n,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?Gj:Uj;function l(c){["top","right","bottom","left"].forEach(d=>{r[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof n=="number"||typeof n=="string"?l(n):typeof n=="object"?["top","right","bottom","left"].forEach(c=>{n[c]===void 0?r[`${i}-${c}`]=a:r[`${i}-${c}`]=typeof n[c]=="number"?`${n[c]}px`:n[c]}):l(a)}),r}var ffe=(0,Le.forwardRef)(function(t,e){let{invert:r,position:n="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:u,duration:f,style:p,visibleToasts:h=Wj,toastOptions:b,dir:g=BR(),gap:x=qj,loadingIcon:y,icons:m,containerAriaLabel:v="Notifications",pauseWhenPageIsHidden:S}=t,[w,C]=Le.default.useState([]),A=Le.default.useMemo(()=>Array.from(new Set([n].concat(w.filter($=>$.position).map($=>$.position)))),[w,n]),[k,M]=Le.default.useState([]),[T,E]=Le.default.useState(!1),[P,N]=Le.default.useState(!1),[D,R]=Le.default.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),O=Le.default.useRef(null),B=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),L=Le.default.useRef(null),H=Le.default.useRef(!1),j=Le.default.useCallback($=>{C(q=>{var F;return(F=q.find(_=>_.id===$.id))!=null&&F.delete||zo.dismiss($.id),q.filter(({id:_})=>_!==$.id)})},[]);return Le.default.useEffect(()=>zo.subscribe($=>{if($.dismiss){C(q=>q.map(F=>F.id===$.id?{...F,delete:!0}:F));return}setTimeout(()=>{zR.default.flushSync(()=>{C(q=>{let F=q.findIndex(_=>_.id===$.id);return F!==-1?[...q.slice(0,F),{...q[F],...$},...q.slice(F+1)]:[$,...q]})})})}),[]),Le.default.useEffect(()=>{if(d!=="system"){R(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?R("dark"):R("light")),typeof window>"u")return;let $=window.matchMedia("(prefers-color-scheme: dark)");try{$.addEventListener("change",({matches:q})=>{R(q?"dark":"light")})}catch{$.addListener(({matches:F})=>{try{R(F?"dark":"light")}catch(_){console.error(_)}})}},[d]),Le.default.useEffect(()=>{w.length<=1&&E(!1)},[w]),Le.default.useEffect(()=>{let $=q=>{var F,_;o.every(W=>q[W]||q.code===W)&&(E(!0),(F=O.current)==null||F.focus()),q.code==="Escape"&&(document.activeElement===O.current||(_=O.current)!=null&&_.contains(document.activeElement))&&E(!1)};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[o]),Le.default.useEffect(()=>{if(O.current)return()=>{L.current&&(L.current.focus({preventScroll:!0}),L.current=null,H.current=!1)}},[O.current]),Le.default.createElement("section",{ref:e,"aria-label":`${v} ${B}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map(($,q)=>{var F;let[_,W]=$.split("-");return w.length?Le.default.createElement("ol",{key:$,dir:g==="auto"?BR():g,tabIndex:-1,ref:O,className:a,"data-sonner-toaster":!0,"data-theme":D,"data-y-position":_,"data-lifted":T&&w.length>1&&!s,"data-x-position":W,style:{"--front-toast-height":`${((F=k[0])==null?void 0:F.height)||0}px`,"--width":`${Kj}px`,"--gap":`${x}px`,...p,...Qj(l,c)},onBlur:V=>{H.current&&!V.currentTarget.contains(V.relatedTarget)&&(H.current=!1,L.current&&(L.current.focus({preventScroll:!0}),L.current=null))},onFocus:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||H.current||(H.current=!0,L.current=V.relatedTarget)},onMouseEnter:()=>E(!0),onMouseMove:()=>E(!0),onMouseLeave:()=>{P||E(!1)},onDragEnd:()=>E(!1),onPointerDown:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||N(!0)},onPointerUp:()=>N(!1)},w.filter(V=>!V.position&&q===0||V.position===$).map((V,z)=>{var G,Y;return Le.default.createElement(Zj,{key:V.id,icons:m,index:z,toast:V,defaultRichColors:u,duration:(G=b?.duration)!=null?G:f,className:b?.className,descriptionClassName:b?.descriptionClassName,invert:r,visibleToasts:h,closeButton:(Y=b?.closeButton)!=null?Y:i,interacting:P,position:$,style:b?.style,unstyled:b?.unstyled,classNames:b?.classNames,cancelButtonStyle:b?.cancelButtonStyle,actionButtonStyle:b?.actionButtonStyle,removeToast:j,toasts:w.filter(Z=>Z.position==V.position),heights:k.filter(Z=>Z.position==V.position),setHeights:M,expandByDefault:s,gap:x,loadingIcon:y,expanded:T,pauseWhenPageIsHidden:S,swipeDirections:t.swipeDirections})})):null}))});var qf=require("@decido/kernel-bridge"),VR=Re(require("yjs")),jR=require("y-websocket"),kg={},Nv=new VR.Doc,$o=Nv.getMap("orders"),eW=()=>(kg.env?.VITE_API_BASE_URL||"http://localhost:3001").replace(/^https?/,e=>e==="https"?"wss":"ws")+"/api/collaboration",xfe=new jR.WebsocketProvider(eW(),"madefront-kanban-room",Nv,{connect:!0});qf.kernel.onEvent(t=>{t&&(t.type==="MadefrontOrderUpdated"||t.event_type==="MadefrontOrderUpdated"||t.message?.includes("MadefrontOrderUpdated"))&&es.getState().fetchOrders()});var es=(0,FR.create)()((0,HR.persist)((t,e)=>($o.observe(()=>{t({orders:Array.from($o.values())})}),{orders:Array.from($o.values()),setOrders:r=>t({orders:r}),fetchOrders:async()=>{try{let r=kg.env?.VITE_API_BASE_URL||"http://localhost:3001",n=await fetch(`${r}/api/orders`,{headers:{"x-api-key":"dev_ak_chameleon_studio_99x"}});if(!n.ok)throw new Error(`Error HTTP: ${n.status}`);let o=await n.json();if(o.error)throw new Error(o.error);let s=i=>{switch(i?.toUpperCase()){case"NEW":case"DESIGN":return"DISE\xD1O";case"OPTIMIZATION":case"IN_CUTTING":case"IN_EDGEBANDING":case"IN_ASSEMBLY":return"OPTIMIZACION";case"AUTHORIZED_FOR_PRODUCTION":return"CAJA";case"PRODUCTION":return"PRODUCCION";case"DISPATCH":case"IN_DISPATCH":case"READY_FOR_DISPATCH":return"DESPACHO";case"COMPLETED":case"DELIVERED":return"ENTREGADO";default:return"DISE\xD1O"}};Nv.transact(()=>{let i=new Set(o.map(a=>a.legacyId||a.id));Array.from($o.keys()).forEach(a=>{i.has(a)||$o.delete(a)}),o.forEach(a=>{let l=a.legacyId||a.id,c=s(a.stage);$o.set(l,{id:l,client:a.clientName||a.clientId||"Desconocido",whatsapp:a.clientPhone?String(a.clientPhone):a.whatsapp?String(a.whatsapp):"+57 000 000 0000",material:a.salesObservation||a.material||a.items?.[0]?.woodType||"Desconocido",measurements:a.items?.[0]?.dimensions||"Ver O.T.",sheets:a.items?.[0]?.quantity||1,status:c,rawStage:a.stage,machine:a.machine||"Sin Asignar",slaHours:a.is24Hours?24:72,isUrgent:a.isUrgent||!1,isPaid:a.isPaid||!1,createdAt:new Date(a.createdAt).toLocaleDateString(),logs:$o.get(l)?.logs||[]})})})}catch(r){console.error("[Chameleon Store] Error fetching orders:",r),Bt.error(`SysError: ${r.message}`)}},createOrder:r=>{let n=RR(r.sheets),o=DR(r.material,r.sheets),s=OR(r.whatsapp),i=`MF-${Math.floor(1e3+Math.random()*9e3)}`,a={id:i,client:r.client,whatsapp:s,material:r.material,measurements:r.measurements,sheets:parseInt(r.sheets),status:"DISE\xD1O",machine:o,slaHours:n,isPaid:!1,createdAt:new Date().toISOString(),logs:[`Pedido creado. SLA calculado: ${n}h. M\xE1quina sugerida: ${o}`]};$o.set(i,a),qf.kernel.execute("broadcast_message",{message:JSON.stringify({type:"ORDER_CREATED",payload:a})}).catch(l=>console.error("Sync Error",l))},updateStatus:async(r,n)=>{let o=$o.get(r);if(!o)return;let s=_R(o,n);if(!s.allowed){console.warn(`[Workflow Engine] Bloqueo: ${s.reason}`),setTimeout(()=>Bt.error("Transici\xF3n Bloqueada",{description:s.reason}),0);return}let i="DESIGN";switch(n){case"CAJA":i="AUTHORIZED_FOR_PRODUCTION";break;case"PRODUCCION":i="PRODUCTION";break;case"DESPACHO":i="DISPATCH";break;case"ENTREGADO":i="DELIVERED";break;case"OPTIMIZACION":i="IN_CUTTING";break}try{let a=kg.env?.VITE_API_BASE_URL||"http://localhost:3001",l=await fetch(`${a}/api/orders/${o.id}/dynamic-move`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":"dev_ak_chameleon_studio_99x"},body:JSON.stringify({newStage:i})});if(!l.ok){let u=await l.json().catch(()=>({}));throw new Error(u.error||`Error HTTP: ${l.status}`)}let c=`[${new Date().toLocaleTimeString()}] Movido a ${n}`,d={...o,status:n,logs:[...o.logs,c]};$o.set(r,d),await qf.kernel.execute("broadcast_message",{message:JSON.stringify({type:"MadefrontOrderUpdated",data:d})})}catch(a){Bt.error(`Error persistiendo estado: ${a.message}`)}},updateOrder:r=>{$o.has(r.id)&&$o.set(r.id,r)},approvePayment:async r=>{let n=$o.get(r);if(!n)return;let o={...n,isPaid:!0,status:"PRODUCCION",logs:[...n.logs,"\u{1F4B0} Pago Aprobado por Caja -> Enviado a Planta"]};$o.set(r,o);try{let s=kg.env?.VITE_API_BASE_URL||"http://localhost:3001";await fetch(`${s}/api/orders/${n.id}/dynamic-move`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":"dev_ak_chameleon_studio_99x"},body:JSON.stringify({newStage:"PRODUCTION"})}),await qf.kernel.execute("broadcast_message",{message:JSON.stringify({type:"MadefrontOrderUpdated",data:o})})}catch{}},getOrdersByStage:r=>e().orders.filter(n=>n.status===r),getPendingPayments:()=>e().orders.filter(r=>r.status==="CAJA"&&!r.isPaid)}),{name:"madefront-db-v2"}));var WR=require("zustand"),al=(0,WR.create)(t=>({currentRole:"NONE",currentUser:"",activeContext:void 0,setRole:(e,r,n)=>t({currentRole:e,currentUser:r,activeContext:n}),logout:()=>t({currentRole:"NONE",currentUser:"",activeContext:void 0})}));var UR=require("zustand"),Eg=(0,UR.create)(t=>({currentView:"login",searchTerm:"",setCurrentView:e=>t({currentView:e}),setSearchTerm:e=>t({searchTerm:e})}));var dl=require("lucide-react");var vc=require("react");var ae=Re(require("react")),gc=require("react-dom");var on=require("react");function KR(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return(0,on.useMemo)(()=>n=>{e.forEach(o=>o(n))},e)}var Yf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function dc(t){let e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Tg(t){return"nodeType"in t}function ko(t){var e,r;return t?dc(t)?t:Tg(t)&&(e=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?e:window:window}function Ig(t){let{Document:e}=ko(t);return t instanceof e}function tu(t){return dc(t)?!1:t instanceof ko(t).HTMLElement}function kv(t){return t instanceof ko(t).SVGElement}function uc(t){return t?dc(t)?t.document:Tg(t)?Ig(t)?t:tu(t)||kv(t)?t.ownerDocument:document:document:document}var Ms=Yf?on.useLayoutEffect:on.useEffect;function Ag(t){let e=(0,on.useRef)(t);return Ms(()=>{e.current=t}),(0,on.useCallback)(function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return e.current==null?void 0:e.current(...n)},[])}function qR(){let t=(0,on.useRef)(null),e=(0,on.useCallback)((n,o)=>{t.current=setInterval(n,o)},[]),r=(0,on.useCallback)(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,r]}function ru(t,e){e===void 0&&(e=[t]);let r=(0,on.useRef)(t);return Ms(()=>{r.current!==t&&(r.current=t)},e),r}function nu(t,e){let r=(0,on.useRef)();return(0,on.useMemo)(()=>{let n=t(r.current);return r.current=n,n},[...e])}function Xf(t){let e=Ag(t),r=(0,on.useRef)(null),n=(0,on.useCallback)(o=>{o!==r.current&&e?.(o,r.current),r.current=o},[]);return[r,n]}function Mg(t){let e=(0,on.useRef)();return(0,on.useEffect)(()=>{e.current=t},[t]),e.current}var Cv={};function fc(t,e){return(0,on.useMemo)(()=>{if(e)return e;let r=Cv[t]==null?0:Cv[t]+1;return Cv[t]=r,t+"-"+r},[t,e])}function YR(t){return function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return n.reduce((s,i)=>{let a=Object.entries(i);for(let[l,c]of a){let d=s[l];d!=null&&(s[l]=d+t*c)}return s},{...e})}}var pc=YR(1),hc=YR(-1);function tW(t){return"clientX"in t&&"clientY"in t}function Jf(t){if(!t)return!1;let{KeyboardEvent:e}=ko(t.target);return e&&t instanceof e}function rW(t){if(!t)return!1;let{TouchEvent:e}=ko(t.target);return e&&t instanceof e}function Pg(t){if(rW(t)){if(t.touches&&t.touches.length){let{clientX:e,clientY:r}=t.touches[0];return{x:e,y:r}}else if(t.changedTouches&&t.changedTouches.length){let{clientX:e,clientY:r}=t.changedTouches[0];return{x:e,y:r}}}return tW(t)?{x:t.clientX,y:t.clientY}:null}var ll=Object.freeze({Translate:{toString(t){if(!t)return;let{x:e,y:r}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;let{scaleX:e,scaleY:r}=t;return"scaleX("+e+") scaleY("+r+")"}},Transform:{toString(t){if(t)return[ll.Translate.toString(t),ll.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:r,easing:n}=t;return e+" "+r+"ms "+n}}}),GR="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function XR(t){return t.matches(GR)?t:t.querySelector(GR)}var mc=Re(require("react")),nW={display:"none"};function JR(t){let{id:e,value:r}=t;return mc.default.createElement("div",{id:e,style:nW},r)}function ZR(t){let{id:e,announcement:r,ariaLiveType:n="assertive"}=t,o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return mc.default.createElement("div",{id:e,style:o,role:"status","aria-live":n,"aria-atomic":!0},r)}function QR(){let[t,e]=(0,mc.useState)("");return{announce:(0,mc.useCallback)(n=>{n!=null&&e(n)},[]),announcement:t}}var fD=(0,ae.createContext)(null);function oW(t){let e=(0,ae.useContext)(fD);(0,ae.useEffect)(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function sW(){let[t]=(0,ae.useState)(()=>new Set),e=(0,ae.useCallback)(n=>(t.add(n),()=>t.delete(n)),[t]);return[(0,ae.useCallback)(n=>{let{type:o,event:s}=n;t.forEach(i=>{var a;return(a=i[o])==null?void 0:a.call(i,s)})},[t]),e]}var iW={draggable:`
|
|
433
|
+
To pick up a draggable item, press the space bar.
|
|
434
|
+
While dragging, use the arrow keys to move the item.
|
|
435
|
+
Press space again to drop the item in its new position, or press escape to cancel.
|
|
436
|
+
`},aW={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:r}=t;return r?"Draggable item "+e.id+" was moved over droppable area "+r.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:r}=t;return r?"Draggable item "+e.id+" was dropped over droppable area "+r.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function lW(t){let{announcements:e=aW,container:r,hiddenTextDescribedById:n,screenReaderInstructions:o=iW}=t,{announce:s,announcement:i}=QR(),a=fc("DndLiveRegion"),[l,c]=(0,ae.useState)(!1);if((0,ae.useEffect)(()=>{c(!0)},[]),oW((0,ae.useMemo)(()=>({onDragStart(u){let{active:f}=u;s(e.onDragStart({active:f}))},onDragMove(u){let{active:f,over:p}=u;e.onDragMove&&s(e.onDragMove({active:f,over:p}))},onDragOver(u){let{active:f,over:p}=u;s(e.onDragOver({active:f,over:p}))},onDragEnd(u){let{active:f,over:p}=u;s(e.onDragEnd({active:f,over:p}))},onDragCancel(u){let{active:f,over:p}=u;s(e.onDragCancel({active:f,over:p}))}}),[s,e])),!l)return null;let d=ae.default.createElement(ae.default.Fragment,null,ae.default.createElement(JR,{id:n,value:o.draggable}),ae.default.createElement(ZR,{id:a,announcement:i}));return r?(0,gc.createPortal)(d,r):d}var Sn;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Sn||(Sn={}));function Dg(){}function Ov(t,e){return(0,ae.useMemo)(()=>({sensor:t,options:e??{}}),[t,e])}function pD(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return(0,ae.useMemo)(()=>[...e].filter(n=>n!=null),[...e])}var ni=Object.freeze({x:0,y:0});function hD(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function mD(t,e){let{data:{value:r}}=t,{data:{value:n}}=e;return r-n}function cW(t,e){let{data:{value:r}}=t,{data:{value:n}}=e;return n-r}function eD(t){let{left:e,top:r,height:n,width:o}=t;return[{x:e,y:r},{x:e+o,y:r},{x:e,y:r+n},{x:e+o,y:r+n}]}function _v(t,e){if(!t||t.length===0)return null;let[r]=t;return e?r[e]:r}function tD(t,e,r){return e===void 0&&(e=t.left),r===void 0&&(r=t.top),{x:e+t.width*.5,y:r+t.height*.5}}var gD=t=>{let{collisionRect:e,droppableRects:r,droppableContainers:n}=t,o=tD(e,e.left,e.top),s=[];for(let i of n){let{id:a}=i,l=r.get(a);if(l){let c=hD(tD(l),o);s.push({id:a,data:{droppableContainer:i,value:c}})}}return s.sort(mD)},bD=t=>{let{collisionRect:e,droppableRects:r,droppableContainers:n}=t,o=eD(e),s=[];for(let i of n){let{id:a}=i,l=r.get(a);if(l){let c=eD(l),d=o.reduce((f,p,h)=>f+hD(c[h],p),0),u=Number((d/4).toFixed(4));s.push({id:a,data:{droppableContainer:i,value:u}})}}return s.sort(mD)};function dW(t,e){let r=Math.max(e.top,t.top),n=Math.max(e.left,t.left),o=Math.min(e.left+e.width,t.left+t.width),s=Math.min(e.top+e.height,t.top+t.height),i=o-n,a=s-r;if(n<o&&r<s){let l=e.width*e.height,c=t.width*t.height,d=i*a,u=d/(l+c-d);return Number(u.toFixed(4))}return 0}var uW=t=>{let{collisionRect:e,droppableRects:r,droppableContainers:n}=t,o=[];for(let s of n){let{id:i}=s,a=r.get(i);if(a){let l=dW(a,e);l>0&&o.push({id:i,data:{droppableContainer:s,value:l}})}}return o.sort(cW)};function fW(t,e,r){return{...t,scaleX:e&&r?e.width/r.width:1,scaleY:e&&r?e.height/r.height:1}}function xD(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:ni}function pW(t){return function(r){for(var n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];return o.reduce((i,a)=>({...i,top:i.top+t*a.y,bottom:i.bottom+t*a.y,left:i.left+t*a.x,right:i.right+t*a.x}),{...r})}}var hW=pW(1);function mW(t){if(t.startsWith("matrix3d(")){let e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){let e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function gW(t,e,r){let n=mW(e);if(!n)return t;let{scaleX:o,scaleY:s,x:i,y:a}=n,l=t.left-i-(1-o)*parseFloat(r),c=t.top-a-(1-s)*parseFloat(r.slice(r.indexOf(" ")+1)),d=o?t.width/o:t.width,u=s?t.height/s:t.height;return{width:d,height:u,top:c,right:l+d,bottom:c+u,left:l}}var bW={ignoreTransform:!1};function yc(t,e){e===void 0&&(e=bW);let r=t.getBoundingClientRect();if(e.ignoreTransform){let{transform:c,transformOrigin:d}=ko(t).getComputedStyle(t);c&&(r=gW(r,c,d))}let{top:n,left:o,width:s,height:i,bottom:a,right:l}=r;return{top:n,left:o,width:s,height:i,bottom:a,right:l}}function rD(t){return yc(t,{ignoreTransform:!0})}function xW(t){let e=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:e,bottom:r,width:e,height:r}}function yW(t,e){return e===void 0&&(e=ko(t).getComputedStyle(t)),e.position==="fixed"}function vW(t,e){e===void 0&&(e=ko(t).getComputedStyle(t));let r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{let s=e[o];return typeof s=="string"?r.test(s):!1})}function rp(t,e){let r=[];function n(o){if(e!=null&&r.length>=e||!o)return r;if(Ig(o)&&o.scrollingElement!=null&&!r.includes(o.scrollingElement))return r.push(o.scrollingElement),r;if(!tu(o)||kv(o)||r.includes(o))return r;let s=ko(t).getComputedStyle(o);return o!==t&&vW(o,s)&&r.push(o),yW(o,s)?r:n(o.parentNode)}return t?n(t):r}function yD(t){let[e]=rp(t,1);return e??null}function Ev(t){return!Yf||!t?null:dc(t)?t:Tg(t)?Ig(t)||t===uc(t).scrollingElement?window:tu(t)?t:null:null}function vD(t){return dc(t)?t.scrollX:t.scrollLeft}function wD(t){return dc(t)?t.scrollY:t.scrollTop}function Av(t){return{x:vD(t),y:wD(t)}}var Ln;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Ln||(Ln={}));function SD(t){return!Yf||!t?!1:t===document.scrollingElement}function ND(t){let e={x:0,y:0},r=SD(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},n={x:t.scrollWidth-r.width,y:t.scrollHeight-r.height},o=t.scrollTop<=e.y,s=t.scrollLeft<=e.x,i=t.scrollTop>=n.y,a=t.scrollLeft>=n.x;return{isTop:o,isLeft:s,isBottom:i,isRight:a,maxScroll:n,minScroll:e}}var wW={x:.2,y:.2};function SW(t,e,r,n,o){let{top:s,left:i,right:a,bottom:l}=r;n===void 0&&(n=10),o===void 0&&(o=wW);let{isTop:c,isBottom:d,isLeft:u,isRight:f}=ND(t),p={x:0,y:0},h={x:0,y:0},b={height:e.height*o.y,width:e.width*o.x};return!c&&s<=e.top+b.height?(p.y=Ln.Backward,h.y=n*Math.abs((e.top+b.height-s)/b.height)):!d&&l>=e.bottom-b.height&&(p.y=Ln.Forward,h.y=n*Math.abs((e.bottom-b.height-l)/b.height)),!f&&a>=e.right-b.width?(p.x=Ln.Forward,h.x=n*Math.abs((e.right-b.width-a)/b.width)):!u&&i<=e.left+b.width&&(p.x=Ln.Backward,h.x=n*Math.abs((e.left+b.width-i)/b.width)),{direction:p,speed:h}}function NW(t){if(t===document.scrollingElement){let{innerWidth:s,innerHeight:i}=window;return{top:0,left:0,right:s,bottom:i,width:s,height:i}}let{top:e,left:r,right:n,bottom:o}=t.getBoundingClientRect();return{top:e,left:r,right:n,bottom:o,width:t.clientWidth,height:t.clientHeight}}function CD(t){return t.reduce((e,r)=>pc(e,Av(r)),ni)}function CW(t){return t.reduce((e,r)=>e+vD(r),0)}function kW(t){return t.reduce((e,r)=>e+wD(r),0)}function EW(t,e){if(e===void 0&&(e=yc),!t)return;let{top:r,left:n,bottom:o,right:s}=e(t);yD(t)&&(o<=0||s<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}var TW=[["x",["left","right"],CW],["y",["top","bottom"],kW]],Qf=class{constructor(e,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=rp(r),o=CD(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[s,i,a]of TW)for(let l of i)Object.defineProperty(this,l,{get:()=>{let c=a(n),d=o[s]-c;return this.rect[l]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},bc=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=e}add(e,r,n){var o;(o=this.target)==null||o.addEventListener(e,r,n),this.listeners.push([e,r,n])}};function IW(t){let{EventTarget:e}=ko(t);return t instanceof e?t:uc(t)}function Tv(t,e){let r=Math.abs(t.x),n=Math.abs(t.y);return typeof e=="number"?Math.sqrt(r**2+n**2)>e:"x"in e&&"y"in e?r>e.x&&n>e.y:"x"in e?r>e.x:"y"in e?n>e.y:!1}var Ps;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Ps||(Ps={}));function nD(t){t.preventDefault()}function AW(t){t.stopPropagation()}var Nt;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Nt||(Nt={}));var kD={start:[Nt.Space,Nt.Enter],cancel:[Nt.Esc],end:[Nt.Space,Nt.Enter,Nt.Tab]},MW=(t,e)=>{let{currentCoordinates:r}=e;switch(t.code){case Nt.Right:return{...r,x:r.x+25};case Nt.Left:return{...r,x:r.x-25};case Nt.Down:return{...r,y:r.y+25};case Nt.Up:return{...r,y:r.y-25}}},ou=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:r}}=e;this.props=e,this.listeners=new bc(uc(r)),this.windowListeners=new bc(ko(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Ps.Resize,this.handleCancel),this.windowListeners.add(Ps.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Ps.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:r}=this.props,n=e.node.current;n&&EW(n),r(ni)}handleKeyDown(e){if(Jf(e)){let{active:r,context:n,options:o}=this.props,{keyboardCodes:s=kD,coordinateGetter:i=MW,scrollBehavior:a="smooth"}=o,{code:l}=e;if(s.end.includes(l)){this.handleEnd(e);return}if(s.cancel.includes(l)){this.handleCancel(e);return}let{collisionRect:c}=n.current,d=c?{x:c.left,y:c.top}:ni;this.referenceCoordinates||(this.referenceCoordinates=d);let u=i(e,{active:r,context:n.current,currentCoordinates:d});if(u){let f=hc(u,d),p={x:0,y:0},{scrollableAncestors:h}=n.current;for(let b of h){let g=e.code,{isTop:x,isRight:y,isLeft:m,isBottom:v,maxScroll:S,minScroll:w}=ND(b),C=NW(b),A={x:Math.min(g===Nt.Right?C.right-C.width/2:C.right,Math.max(g===Nt.Right?C.left:C.left+C.width/2,u.x)),y:Math.min(g===Nt.Down?C.bottom-C.height/2:C.bottom,Math.max(g===Nt.Down?C.top:C.top+C.height/2,u.y))},k=g===Nt.Right&&!y||g===Nt.Left&&!m,M=g===Nt.Down&&!v||g===Nt.Up&&!x;if(k&&A.x!==u.x){let T=b.scrollLeft+f.x,E=g===Nt.Right&&T<=S.x||g===Nt.Left&&T>=w.x;if(E&&!f.y){b.scrollTo({left:T,behavior:a});return}E?p.x=b.scrollLeft-T:p.x=g===Nt.Right?b.scrollLeft-S.x:b.scrollLeft-w.x,p.x&&b.scrollBy({left:-p.x,behavior:a});break}else if(M&&A.y!==u.y){let T=b.scrollTop+f.y,E=g===Nt.Down&&T<=S.y||g===Nt.Up&&T>=w.y;if(E&&!f.x){b.scrollTo({top:T,behavior:a});return}E?p.y=b.scrollTop-T:p.y=g===Nt.Down?b.scrollTop-S.y:b.scrollTop-w.y,p.y&&b.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(e,pc(hc(u,this.referenceCoordinates),p))}}}handleMove(e,r){let{onMove:n}=this.props;e.preventDefault(),n(r)}handleEnd(e){let{onEnd:r}=this.props;e.preventDefault(),this.detach(),r()}handleCancel(e){let{onCancel:r}=this.props;e.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};ou.activators=[{eventName:"onKeyDown",handler:(t,e,r)=>{let{keyboardCodes:n=kD,onActivation:o}=e,{active:s}=r,{code:i}=t.nativeEvent;if(n.start.includes(i)){let a=s.activatorNode.current;return a&&t.target!==a?!1:(t.preventDefault(),o?.({event:t.nativeEvent}),!0)}return!1}}];function oD(t){return!!(t&&"distance"in t)}function sD(t){return!!(t&&"delay"in t)}var ep=class{constructor(e,r,n){var o;n===void 0&&(n=IW(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=r;let{event:s}=e,{target:i}=s;this.props=e,this.events=r,this.document=uc(i),this.documentListeners=new bc(this.document),this.listeners=new bc(n),this.windowListeners=new bc(ko(i)),this.initialCoordinates=(o=Pg(s))!=null?o:ni,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Ps.Resize,this.handleCancel),this.windowListeners.add(Ps.DragStart,nD),this.windowListeners.add(Ps.VisibilityChange,this.handleCancel),this.windowListeners.add(Ps.ContextMenu,nD),this.documentListeners.add(Ps.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(sD(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(oD(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,r){let{active:n,onPending:o}=this.props;o(n,e,this.initialCoordinates,r)}handleStart(){let{initialCoordinates:e}=this,{onStart:r}=this.props;e&&(this.activated=!0,this.documentListeners.add(Ps.Click,AW,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Ps.SelectionChange,this.removeTextSelection),r(e))}handleMove(e){var r;let{activated:n,initialCoordinates:o,props:s}=this,{onMove:i,options:{activationConstraint:a}}=s;if(!o)return;let l=(r=Pg(e))!=null?r:ni,c=hc(o,l);if(!n&&a){if(oD(a)){if(a.tolerance!=null&&Tv(c,a.tolerance))return this.handleCancel();if(Tv(c,a.distance))return this.handleStart()}if(sD(a)&&Tv(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}e.cancelable&&e.preventDefault(),i(l)}handleEnd(){let{onAbort:e,onEnd:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleCancel(){let{onAbort:e,onCancel:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleKeydown(e){e.code===Nt.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},PW={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}},su=class extends ep{constructor(e){let{event:r}=e,n=uc(r.target);super(e,PW,n)}};su.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:r}=t,{onActivation:n}=e;return!r.isPrimary||r.button!==0?!1:(n?.({event:r}),!0)}}];var RW={move:{name:"mousemove"},end:{name:"mouseup"}},Mv;(function(t){t[t.RightClick=2]="RightClick"})(Mv||(Mv={}));var Pv=class extends ep{constructor(e){super(e,RW,uc(e.event.target))}};Pv.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:r}=t,{onActivation:n}=e;return r.button===Mv.RightClick?!1:(n?.({event:r}),!0)}}];var Iv={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}},Rv=class extends ep{constructor(e){super(e,Iv)}static setup(){return window.addEventListener(Iv.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Iv.move.name,e)};function e(){}}};Rv.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:r}=t,{onActivation:n}=e,{touches:o}=r;return o.length>1?!1:(n?.({event:r}),!0)}}];var Zf;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Zf||(Zf={}));var Og;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Og||(Og={}));function DW(t){let{acceleration:e,activator:r=Zf.Pointer,canScroll:n,draggingRect:o,enabled:s,interval:i=5,order:a=Og.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:d,delta:u,threshold:f}=t,p=_W({delta:u,disabled:!s}),[h,b]=qR(),g=(0,ae.useRef)({x:0,y:0}),x=(0,ae.useRef)({x:0,y:0}),y=(0,ae.useMemo)(()=>{switch(r){case Zf.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Zf.DraggableRect:return o}},[r,o,l]),m=(0,ae.useRef)(null),v=(0,ae.useCallback)(()=>{let w=m.current;if(!w)return;let C=g.current.x*x.current.x,A=g.current.y*x.current.y;w.scrollBy(C,A)},[]),S=(0,ae.useMemo)(()=>a===Og.TreeOrder?[...c].reverse():c,[a,c]);(0,ae.useEffect)(()=>{if(!s||!c.length||!y){b();return}for(let w of S){if(n?.(w)===!1)continue;let C=c.indexOf(w),A=d[C];if(!A)continue;let{direction:k,speed:M}=SW(w,A,y,e,f);for(let T of["x","y"])p[T][k[T]]||(M[T]=0,k[T]=0);if(M.x>0||M.y>0){b(),m.current=w,h(v,i),g.current=M,x.current=k;return}}g.current={x:0,y:0},x.current={x:0,y:0},b()},[e,v,n,b,s,i,JSON.stringify(y),JSON.stringify(p),h,c,S,d,JSON.stringify(f)])}var OW={x:{[Ln.Backward]:!1,[Ln.Forward]:!1},y:{[Ln.Backward]:!1,[Ln.Forward]:!1}};function _W(t){let{delta:e,disabled:r}=t,n=Mg(e);return nu(o=>{if(r||!n||!o)return OW;let s={x:Math.sign(e.x-n.x),y:Math.sign(e.y-n.y)};return{x:{[Ln.Backward]:o.x[Ln.Backward]||s.x===-1,[Ln.Forward]:o.x[Ln.Forward]||s.x===1},y:{[Ln.Backward]:o.y[Ln.Backward]||s.y===-1,[Ln.Forward]:o.y[Ln.Forward]||s.y===1}}},[r,e,n])}function LW(t,e){let r=e!=null?t.get(e):void 0,n=r?r.node.current:null;return nu(o=>{var s;return e==null?null:(s=n??o)!=null?s:null},[n,e])}function BW(t,e){return(0,ae.useMemo)(()=>t.reduce((r,n)=>{let{sensor:o}=n,s=o.activators.map(i=>({eventName:i.eventName,handler:e(i.handler,n)}));return[...r,...s]},[]),[t,e])}var tp;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(tp||(tp={}));var Dv;(function(t){t.Optimized="optimized"})(Dv||(Dv={}));var iD=new Map;function zW(t,e){let{dragging:r,dependencies:n,config:o}=e,[s,i]=(0,ae.useState)(null),{frequency:a,measure:l,strategy:c}=o,d=(0,ae.useRef)(t),u=g(),f=ru(u),p=(0,ae.useCallback)(function(x){x===void 0&&(x=[]),!f.current&&i(y=>y===null?x:y.concat(x.filter(m=>!y.includes(m))))},[f]),h=(0,ae.useRef)(null),b=nu(x=>{if(u&&!r)return iD;if(!x||x===iD||d.current!==t||s!=null){let y=new Map;for(let m of t){if(!m)continue;if(s&&s.length>0&&!s.includes(m.id)&&m.rect.current){y.set(m.id,m.rect.current);continue}let v=m.node.current,S=v?new Qf(l(v),v):null;m.rect.current=S,S&&y.set(m.id,S)}return y}return x},[t,s,r,u,l]);return(0,ae.useEffect)(()=>{d.current=t},[t]),(0,ae.useEffect)(()=>{u||p()},[r,u]),(0,ae.useEffect)(()=>{s&&s.length>0&&i(null)},[JSON.stringify(s)]),(0,ae.useEffect)(()=>{u||typeof a!="number"||h.current!==null||(h.current=setTimeout(()=>{p(),h.current=null},a))},[a,u,p,...n]),{droppableRects:b,measureDroppableContainers:p,measuringScheduled:s!=null};function g(){switch(c){case tp.Always:return!1;case tp.BeforeDragging:return r;default:return!r}}}function ED(t,e){return nu(r=>t?r||(typeof e=="function"?e(t):t):null,[e,t])}function $W(t,e){return ED(t,e)}function FW(t){let{callback:e,disabled:r}=t,n=Ag(e),o=(0,ae.useMemo)(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;let{MutationObserver:s}=window;return new s(n)},[n,r]);return(0,ae.useEffect)(()=>()=>o?.disconnect(),[o]),o}function _g(t){let{callback:e,disabled:r}=t,n=Ag(e),o=(0,ae.useMemo)(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;let{ResizeObserver:s}=window;return new s(n)},[r]);return(0,ae.useEffect)(()=>()=>o?.disconnect(),[o]),o}function HW(t){return new Qf(yc(t),t)}function aD(t,e,r){e===void 0&&(e=HW);let[n,o]=(0,ae.useState)(null);function s(){o(l=>{if(!t)return null;if(t.isConnected===!1){var c;return(c=l??r)!=null?c:null}let d=e(t);return JSON.stringify(l)===JSON.stringify(d)?l:d})}let i=FW({callback(l){if(t)for(let c of l){let{type:d,target:u}=c;if(d==="childList"&&u instanceof HTMLElement&&u.contains(t)){s();break}}}}),a=_g({callback:s});return Ms(()=>{s(),t?(a?.observe(t),i?.observe(document.body,{childList:!0,subtree:!0})):(a?.disconnect(),i?.disconnect())},[t]),n}function VW(t){let e=ED(t);return xD(t,e)}var lD=[];function jW(t){let e=(0,ae.useRef)(t),r=nu(n=>t?n&&n!==lD&&t&&e.current&&t.parentNode===e.current.parentNode?n:rp(t):lD,[t]);return(0,ae.useEffect)(()=>{e.current=t},[t]),r}function WW(t){let[e,r]=(0,ae.useState)(null),n=(0,ae.useRef)(t),o=(0,ae.useCallback)(s=>{let i=Ev(s.target);i&&r(a=>a?(a.set(i,Av(i)),new Map(a)):null)},[]);return(0,ae.useEffect)(()=>{let s=n.current;if(t!==s){i(s);let a=t.map(l=>{let c=Ev(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,Av(c)]):null}).filter(l=>l!=null);r(a.length?new Map(a):null),n.current=t}return()=>{i(t),i(s)};function i(a){a.forEach(l=>{let c=Ev(l);c?.removeEventListener("scroll",o)})}},[o,t]),(0,ae.useMemo)(()=>t.length?e?Array.from(e.values()).reduce((s,i)=>pc(s,i),ni):CD(t):ni,[t,e])}function cD(t,e){e===void 0&&(e=[]);let r=(0,ae.useRef)(null);return(0,ae.useEffect)(()=>{r.current=null},e),(0,ae.useEffect)(()=>{let n=t!==ni;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?hc(t,r.current):ni}function UW(t){(0,ae.useEffect)(()=>{if(!Yf)return;let e=t.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(let r of e)r?.()}},t.map(e=>{let{sensor:r}=e;return r}))}function GW(t,e){return(0,ae.useMemo)(()=>t.reduce((r,n)=>{let{eventName:o,handler:s}=n;return r[o]=i=>{s(i,e)},r},{}),[t,e])}function TD(t){return(0,ae.useMemo)(()=>t?xW(t):null,[t])}var dD=[];function KW(t,e){e===void 0&&(e=yc);let[r]=t,n=TD(r?ko(r):null),[o,s]=(0,ae.useState)(dD);function i(){s(()=>t.length?t.map(l=>SD(l)?n:new Qf(e(l),l)):dD)}let a=_g({callback:i});return Ms(()=>{a?.disconnect(),i(),t.forEach(l=>a?.observe(l))},[t]),o}function qW(t){if(!t)return null;if(t.children.length>1)return t;let e=t.children[0];return tu(e)?e:t}function YW(t){let{measure:e}=t,[r,n]=(0,ae.useState)(null),o=(0,ae.useCallback)(c=>{for(let{target:d}of c)if(tu(d)){n(u=>{let f=e(d);return u?{...u,width:f.width,height:f.height}:f});break}},[e]),s=_g({callback:o}),i=(0,ae.useCallback)(c=>{let d=qW(c);s?.disconnect(),d&&s?.observe(d),n(d?e(d):null)},[e,s]),[a,l]=Xf(i);return(0,ae.useMemo)(()=>({nodeRef:a,rect:r,setRef:l}),[r,a,l])}var XW=[{sensor:su,options:{}},{sensor:ou,options:{}}],JW={current:{}},Rg={draggable:{measure:rD},droppable:{measure:rD,strategy:tp.WhileDragging,frequency:Dv.Optimized},dragOverlay:{measure:yc}},xc=class extends Map{get(e){var r;return e!=null&&(r=super.get(e))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:r}=e;return!r})}getNodeFor(e){var r,n;return(r=(n=this.get(e))==null?void 0:n.node.current)!=null?r:void 0}},ZW={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new xc,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Dg},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Rg,measureDroppableContainers:Dg,windowRect:null,measuringScheduled:!1},QW={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Dg,draggableNodes:new Map,over:null,measureDroppableContainers:Dg},Lg=(0,ae.createContext)(QW),ID=(0,ae.createContext)(ZW);function e7(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new xc}}}function t7(t,e){switch(e.type){case Sn.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Sn.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case Sn.DragEnd:case Sn.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Sn.RegisterDroppable:{let{element:r}=e,{id:n}=r,o=new xc(t.droppable.containers);return o.set(n,r),{...t,droppable:{...t.droppable,containers:o}}}case Sn.SetDroppableDisabled:{let{id:r,key:n,disabled:o}=e,s=t.droppable.containers.get(r);if(!s||n!==s.key)return t;let i=new xc(t.droppable.containers);return i.set(r,{...s,disabled:o}),{...t,droppable:{...t.droppable,containers:i}}}case Sn.UnregisterDroppable:{let{id:r,key:n}=e,o=t.droppable.containers.get(r);if(!o||n!==o.key)return t;let s=new xc(t.droppable.containers);return s.delete(r),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function r7(t){let{disabled:e}=t,{active:r,activatorEvent:n,draggableNodes:o}=(0,ae.useContext)(Lg),s=Mg(n),i=Mg(r?.id);return(0,ae.useEffect)(()=>{if(!e&&!n&&s&&i!=null){if(!Jf(s)||document.activeElement===s.target)return;let a=o.get(i);if(!a)return;let{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(let d of[l.current,c.current]){if(!d)continue;let u=XR(d);if(u){u.focus();break}}})}},[n,e,o,i,s]),null}function n7(t,e){let{transform:r,...n}=e;return t!=null&&t.length?t.reduce((o,s)=>s({transform:o,...n}),r):r}function o7(t){return(0,ae.useMemo)(()=>({draggable:{...Rg.draggable,...t?.draggable},droppable:{...Rg.droppable,...t?.droppable},dragOverlay:{...Rg.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function s7(t){let{activeNode:e,measure:r,initialRect:n,config:o=!0}=t,s=(0,ae.useRef)(!1),{x:i,y:a}=typeof o=="boolean"?{x:o,y:o}:o;Ms(()=>{if(!i&&!a||!e){s.current=!1;return}if(s.current||!n)return;let c=e?.node.current;if(!c||c.isConnected===!1)return;let d=r(c),u=xD(d,n);if(i||(u.x=0),a||(u.y=0),s.current=!0,Math.abs(u.x)>0||Math.abs(u.y)>0){let f=yD(c);f&&f.scrollBy({top:u.y,left:u.x})}},[e,i,a,n,r])}var AD=(0,ae.createContext)({...ni,scaleX:1,scaleY:1}),cl;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(cl||(cl={}));var MD=(0,ae.memo)(function(e){var r,n,o,s;let{id:i,accessibility:a,autoScroll:l=!0,children:c,sensors:d=XW,collisionDetection:u=uW,measuring:f,modifiers:p,...h}=e,b=(0,ae.useReducer)(t7,void 0,e7),[g,x]=b,[y,m]=sW(),[v,S]=(0,ae.useState)(cl.Uninitialized),w=v===cl.Initialized,{draggable:{active:C,nodes:A,translate:k},droppable:{containers:M}}=g,T=C!=null?A.get(C):null,E=(0,ae.useRef)({initial:null,translated:null}),P=(0,ae.useMemo)(()=>{var Qt;return C!=null?{id:C,data:(Qt=T?.data)!=null?Qt:JW,rect:E}:null},[C,T]),N=(0,ae.useRef)(null),[D,R]=(0,ae.useState)(null),[O,B]=(0,ae.useState)(null),L=ru(h,Object.values(h)),H=fc("DndDescribedBy",i),j=(0,ae.useMemo)(()=>M.getEnabled(),[M]),$=o7(f),{droppableRects:q,measureDroppableContainers:F,measuringScheduled:_}=zW(j,{dragging:w,dependencies:[k.x,k.y],config:$.droppable}),W=LW(A,C),V=(0,ae.useMemo)(()=>O?Pg(O):null,[O]),z=Wo(),G=$W(W,$.draggable.measure);s7({activeNode:C!=null?A.get(C):null,config:z.layoutShiftCompensation,initialRect:G,measure:$.draggable.measure});let Y=aD(W,$.draggable.measure,G),Z=aD(W?W.parentElement:null),se=(0,ae.useRef)({activatorEvent:null,active:null,activeNode:W,collisionRect:null,collisions:null,droppableRects:q,draggableNodes:A,draggingNode:null,draggingNodeRect:null,droppableContainers:M,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),we=M.getNodeFor((r=se.current.over)==null?void 0:r.id),_e=YW({measure:$.dragOverlay.measure}),Pe=(n=_e.nodeRef.current)!=null?n:W,K=w?(o=_e.rect)!=null?o:Y:null,he=!!(_e.nodeRef.current&&_e.rect),lt=VW(he?null:Y),He=TD(Pe?ko(Pe):null),nt=jW(w?we??W:null),dr=KW(nt),ln=n7(p,{transform:{x:k.x-lt.x,y:k.y-lt.y,scaleX:1,scaleY:1},activatorEvent:O,active:P,activeNodeRect:Y,containerNodeRect:Z,draggingNodeRect:K,over:se.current.over,overlayNodeRect:_e.rect,scrollableAncestors:nt,scrollableAncestorRects:dr,windowRect:He}),Tr=V?pc(V,k):null,bn=WW(nt),St=cD(bn),mt=cD(bn,[Y]),je=pc(ln,St),or=K?hW(K,ln):null,fo=P&&or?u({active:P,collisionRect:or,droppableRects:q,droppableContainers:j,pointerCoordinates:Tr}):null,Jn=_v(fo,"id"),[Ao,pi]=(0,ae.useState)(null),ps=he?ln:pc(ln,mt),cn=fW(ps,(s=Ao?.rect)!=null?s:null,Y),ne=(0,ae.useRef)(null),be=(0,ae.useCallback)((Qt,Gt)=>{let{sensor:$n,options:We}=Gt;if(N.current==null)return;let ct=A.get(N.current);if(!ct)return;let xt=Qt.nativeEvent,Ir=new $n({active:N.current,activeNode:ct,event:xt,options:We,context:se,onAbort(sr){if(!A.get(sr))return;let{onDragAbort:Ar}=L.current,un={id:sr};Ar?.(un),y({type:"onDragAbort",event:un})},onPending(sr,Tn,Ar,un){if(!A.get(sr))return;let{onDragPending:Pl}=L.current,hi={id:sr,constraint:Tn,initialCoordinates:Ar,offset:un};Pl?.(hi),y({type:"onDragPending",event:hi})},onStart(sr){let Tn=N.current;if(Tn==null)return;let Ar=A.get(Tn);if(!Ar)return;let{onDragStart:un}=L.current,Ml={activatorEvent:xt,active:{id:Tn,data:Ar.data,rect:E}};(0,gc.unstable_batchedUpdates)(()=>{un?.(Ml),S(cl.Initializing),x({type:Sn.DragStart,initialCoordinates:sr,active:Tn}),y({type:"onDragStart",event:Ml}),R(ne.current),B(xt)})},onMove(sr){x({type:Sn.DragMove,coordinates:sr})},onEnd:dn(Sn.DragEnd),onCancel:dn(Sn.DragCancel)});ne.current=Ir;function dn(sr){return async function(){let{active:Ar,collisions:un,over:Ml,scrollAdjustedTranslate:Pl}=se.current,hi=null;if(Ar&&Pl){let{cancelDrop:Rl}=L.current;hi={activatorEvent:xt,active:Ar,collisions:un,delta:Pl,over:Ml},sr===Sn.DragEnd&&typeof Rl=="function"&&await Promise.resolve(Rl(hi))&&(sr=Sn.DragCancel)}N.current=null,(0,gc.unstable_batchedUpdates)(()=>{x({type:sr}),S(cl.Uninitialized),pi(null),R(null),B(null),ne.current=null;let Rl=sr===Sn.DragEnd?"onDragEnd":"onDragCancel";if(hi){let Lu=L.current[Rl];Lu?.(hi),y({type:Rl,event:hi})}})}}},[A]),me=(0,ae.useCallback)((Qt,Gt)=>($n,We)=>{let ct=$n.nativeEvent,xt=A.get(We);if(N.current!==null||!xt||ct.dndKit||ct.defaultPrevented)return;let Ir={active:xt};Qt($n,Gt.options,Ir)===!0&&(ct.dndKit={capturedBy:Gt.sensor},N.current=We,be($n,Gt))},[A,be]),ue=BW(d,me);UW(d),Ms(()=>{Y&&v===cl.Initializing&&S(cl.Initialized)},[Y,v]),(0,ae.useEffect)(()=>{let{onDragMove:Qt}=L.current,{active:Gt,activatorEvent:$n,collisions:We,over:ct}=se.current;if(!Gt||!$n)return;let xt={active:Gt,activatorEvent:$n,collisions:We,delta:{x:je.x,y:je.y},over:ct};(0,gc.unstable_batchedUpdates)(()=>{Qt?.(xt),y({type:"onDragMove",event:xt})})},[je.x,je.y]),(0,ae.useEffect)(()=>{let{active:Qt,activatorEvent:Gt,collisions:$n,droppableContainers:We,scrollAdjustedTranslate:ct}=se.current;if(!Qt||N.current==null||!Gt||!ct)return;let{onDragOver:xt}=L.current,Ir=We.get(Jn),dn=Ir&&Ir.rect.current?{id:Ir.id,rect:Ir.rect.current,data:Ir.data,disabled:Ir.disabled}:null,sr={active:Qt,activatorEvent:Gt,collisions:$n,delta:{x:ct.x,y:ct.y},over:dn};(0,gc.unstable_batchedUpdates)(()=>{pi(dn),xt?.(sr),y({type:"onDragOver",event:sr})})},[Jn]),Ms(()=>{se.current={activatorEvent:O,active:P,activeNode:W,collisionRect:or,collisions:fo,droppableRects:q,draggableNodes:A,draggingNode:Pe,draggingNodeRect:K,droppableContainers:M,over:Ao,scrollableAncestors:nt,scrollAdjustedTranslate:je},E.current={initial:K,translated:or}},[P,W,fo,or,A,Pe,K,q,M,Ao,nt,je]),DW({...z,delta:k,draggingRect:or,pointerCoordinates:Tr,scrollableAncestors:nt,scrollableAncestorRects:dr});let ht=(0,ae.useMemo)(()=>({active:P,activeNode:W,activeNodeRect:Y,activatorEvent:O,collisions:fo,containerNodeRect:Z,dragOverlay:_e,draggableNodes:A,droppableContainers:M,droppableRects:q,over:Ao,measureDroppableContainers:F,scrollableAncestors:nt,scrollableAncestorRects:dr,measuringConfiguration:$,measuringScheduled:_,windowRect:He}),[P,W,Y,O,fo,Z,_e,A,M,q,Ao,F,nt,dr,$,_,He]),Zt=(0,ae.useMemo)(()=>({activatorEvent:O,activators:ue,active:P,activeNodeRect:Y,ariaDescribedById:{draggable:H},dispatch:x,draggableNodes:A,over:Ao,measureDroppableContainers:F}),[O,ue,P,Y,x,H,A,Ao,F]);return ae.default.createElement(fD.Provider,{value:m},ae.default.createElement(Lg.Provider,{value:Zt},ae.default.createElement(ID.Provider,{value:ht},ae.default.createElement(AD.Provider,{value:cn},c)),ae.default.createElement(r7,{disabled:a?.restoreFocus===!1})),ae.default.createElement(lW,{...a,hiddenTextDescribedById:H}));function Wo(){let Qt=D?.autoScrollEnabled===!1,Gt=typeof l=="object"?l.enabled===!1:l===!1,$n=w&&!Qt&&!Gt;return typeof l=="object"?{...l,enabled:$n}:{enabled:$n}}}),i7=(0,ae.createContext)(null),uD="button",a7="Draggable";function PD(t){let{id:e,data:r,disabled:n=!1,attributes:o}=t,s=fc(a7),{activators:i,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:d,draggableNodes:u,over:f}=(0,ae.useContext)(Lg),{role:p=uD,roleDescription:h="draggable",tabIndex:b=0}=o??{},g=l?.id===e,x=(0,ae.useContext)(g?AD:i7),[y,m]=Xf(),[v,S]=Xf(),w=GW(i,e),C=ru(r);Ms(()=>(u.set(e,{id:e,key:s,node:y,activatorNode:v,data:C}),()=>{let k=u.get(e);k&&k.key===s&&u.delete(e)}),[u,e]);let A=(0,ae.useMemo)(()=>({role:p,tabIndex:b,"aria-disabled":n,"aria-pressed":g&&p===uD?!0:void 0,"aria-roledescription":h,"aria-describedby":d.draggable}),[n,p,b,g,h,d.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:A,isDragging:g,listeners:n?void 0:w,node:y,over:f,setNodeRef:m,setActivatorNodeRef:S,transform:x}}function RD(){return(0,ae.useContext)(ID)}var l7="Droppable",c7={timeout:25};function DD(t){let{data:e,disabled:r=!1,id:n,resizeObserverConfig:o}=t,s=fc(l7),{active:i,dispatch:a,over:l,measureDroppableContainers:c}=(0,ae.useContext)(Lg),d=(0,ae.useRef)({disabled:r}),u=(0,ae.useRef)(!1),f=(0,ae.useRef)(null),p=(0,ae.useRef)(null),{disabled:h,updateMeasurementsFor:b,timeout:g}={...c7,...o},x=ru(b??n),y=(0,ae.useCallback)(()=>{if(!u.current){u.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{c(Array.isArray(x.current)?x.current:[x.current]),p.current=null},g)},[g]),m=_g({callback:y,disabled:h||!i}),v=(0,ae.useCallback)((A,k)=>{m&&(k&&(m.unobserve(k),u.current=!1),A&&m.observe(A))},[m]),[S,w]=Xf(v),C=ru(e);return(0,ae.useEffect)(()=>{!m||!S.current||(m.disconnect(),u.current=!1,m.observe(S.current))},[S,m]),(0,ae.useEffect)(()=>(a({type:Sn.RegisterDroppable,element:{id:n,key:s,disabled:r,node:S,rect:f,data:C}}),()=>a({type:Sn.UnregisterDroppable,key:s,id:n})),[n]),(0,ae.useEffect)(()=>{r!==d.current.disabled&&(a({type:Sn.SetDroppableDisabled,id:n,key:s,disabled:r}),d.current.disabled=r)},[n,s,r,a]),{active:i,rect:f,isOver:l?.id===n,node:S,over:l,setNodeRef:w}}var sn=Re(require("react"));function OD(t,e,r){let n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(e,1)[0]),n}function d7(t,e){return t.reduce((r,n,o)=>{let s=e.get(n);return s&&(r[o]=s),r},Array(t.length))}function Bg(t){return t!==null&&t>=0}function u7(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function f7(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}var _D=t=>{let{rects:e,activeIndex:r,overIndex:n,index:o}=t,s=OD(e,n,r),i=e[o],a=s[o];return!a||!i?null:{x:a.left-i.left,y:a.top-i.top,scaleX:a.width/i.width,scaleY:a.height/i.height}};var zg={scaleX:1,scaleY:1},LD=t=>{var e;let{activeIndex:r,activeNodeRect:n,index:o,rects:s,overIndex:i}=t,a=(e=s[r])!=null?e:n;if(!a)return null;if(o===r){let c=s[i];return c?{x:0,y:r<i?c.top+c.height-(a.top+a.height):c.top-a.top,...zg}:null}let l=p7(s,o,r);return o>r&&o<=i?{x:0,y:-a.height-l,...zg}:o<r&&o>=i?{x:0,y:a.height+l,...zg}:{x:0,y:0,...zg}};function p7(t,e,r){let n=t[e],o=t[e-1],s=t[e+1];return n?r<e?o?n.top-(o.top+o.height):s?s.top-(n.top+n.height):0:s?s.top-(n.top+n.height):o?n.top-(o.top+o.height):0:0}var BD="Sortable",zD=sn.default.createContext({activeIndex:-1,containerId:BD,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:_D,disabled:{draggable:!1,droppable:!1}});function $D(t){let{children:e,id:r,items:n,strategy:o=_D,disabled:s=!1}=t,{active:i,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:d}=RD(),u=fc(BD,r),f=a.rect!==null,p=(0,sn.useMemo)(()=>n.map(w=>typeof w=="object"&&"id"in w?w.id:w),[n]),h=i!=null,b=i?p.indexOf(i.id):-1,g=c?p.indexOf(c.id):-1,x=(0,sn.useRef)(p),y=!u7(p,x.current),m=g!==-1&&b===-1||y,v=f7(s);Ms(()=>{y&&h&&d(p)},[y,p,h,d]),(0,sn.useEffect)(()=>{x.current=p},[p]);let S=(0,sn.useMemo)(()=>({activeIndex:b,containerId:u,disabled:v,disableTransforms:m,items:p,overIndex:g,useDragOverlay:f,sortedRects:d7(p,l),strategy:o}),[b,u,v.draggable,v.droppable,m,p,g,l,f,o]);return sn.default.createElement(zD.Provider,{value:S},e)}var h7=t=>{let{id:e,items:r,activeIndex:n,overIndex:o}=t;return OD(r,n,o).indexOf(e)},m7=t=>{let{containerId:e,isSorting:r,wasDragging:n,index:o,items:s,newIndex:i,previousItems:a,previousContainerId:l,transition:c}=t;return!c||!n||a!==s&&o===i?!1:r?!0:i!==o&&e===l},g7={duration:200,easing:"ease"},FD="transform",b7=ll.Transition.toString({property:FD,duration:0,easing:"linear"}),x7={roleDescription:"sortable"};function y7(t){let{disabled:e,index:r,node:n,rect:o}=t,[s,i]=(0,sn.useState)(null),a=(0,sn.useRef)(r);return Ms(()=>{if(!e&&r!==a.current&&n.current){let l=o.current;if(l){let c=yc(n.current,{ignoreTransform:!0}),d={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(d.x||d.y)&&i(d)}}r!==a.current&&(a.current=r)},[e,r,n,o]),(0,sn.useEffect)(()=>{s&&i(null)},[s]),s}function HD(t){let{animateLayoutChanges:e=m7,attributes:r,disabled:n,data:o,getNewIndex:s=h7,id:i,strategy:a,resizeObserverConfig:l,transition:c=g7}=t,{items:d,containerId:u,activeIndex:f,disabled:p,disableTransforms:h,sortedRects:b,overIndex:g,useDragOverlay:x,strategy:y}=(0,sn.useContext)(zD),m=v7(n,p),v=d.indexOf(i),S=(0,sn.useMemo)(()=>({sortable:{containerId:u,index:v,items:d},...o}),[u,o,v,d]),w=(0,sn.useMemo)(()=>d.slice(d.indexOf(i)),[d,i]),{rect:C,node:A,isOver:k,setNodeRef:M}=DD({id:i,data:S,disabled:m.droppable,resizeObserverConfig:{updateMeasurementsFor:w,...l}}),{active:T,activatorEvent:E,activeNodeRect:P,attributes:N,setNodeRef:D,listeners:R,isDragging:O,over:B,setActivatorNodeRef:L,transform:H}=PD({id:i,data:S,attributes:{...x7,...r},disabled:m.draggable}),j=KR(M,D),$=!!T,q=$&&!h&&Bg(f)&&Bg(g),F=!x&&O,_=F&&q?H:null,V=q?_??(a??y)({rects:b,activeNodeRect:P,activeIndex:f,overIndex:g,index:v}):null,z=Bg(f)&&Bg(g)?s({id:i,items:d,activeIndex:f,overIndex:g}):v,G=T?.id,Y=(0,sn.useRef)({activeId:G,items:d,newIndex:z,containerId:u}),Z=d!==Y.current.items,se=e({active:T,containerId:u,isDragging:O,isSorting:$,id:i,index:v,items:d,newIndex:Y.current.newIndex,previousItems:Y.current.items,previousContainerId:Y.current.containerId,transition:c,wasDragging:Y.current.activeId!=null}),we=y7({disabled:!se,index:v,node:A,rect:C});return(0,sn.useEffect)(()=>{$&&Y.current.newIndex!==z&&(Y.current.newIndex=z),u!==Y.current.containerId&&(Y.current.containerId=u),d!==Y.current.items&&(Y.current.items=d)},[$,z,u,d]),(0,sn.useEffect)(()=>{if(G===Y.current.activeId)return;if(G&&!Y.current.activeId){Y.current.activeId=G;return}let Pe=setTimeout(()=>{Y.current.activeId=G},50);return()=>clearTimeout(Pe)},[G]),{active:T,activeIndex:f,attributes:N,data:S,rect:C,index:v,newIndex:z,items:d,isOver:k,isSorting:$,isDragging:O,listeners:R,node:A,overIndex:g,over:B,setNodeRef:j,setActivatorNodeRef:L,setDroppableNodeRef:M,setDraggableNodeRef:D,transform:we??V,transition:_e()};function _e(){if(we||Z&&Y.current.newIndex===v)return b7;if(!(F&&!Jf(E)||!c)&&($||se))return ll.Transition.toString({...c,property:FD})}}function v7(t,e){var r,n;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(r=t?.draggable)!=null?r:e.draggable,droppable:(n=t?.droppable)!=null?n:e.droppable}}function $g(t){if(!t)return!1;let e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}var w7=[Nt.Down,Nt.Right,Nt.Up,Nt.Left],VD=(t,e)=>{let{context:{active:r,collisionRect:n,droppableRects:o,droppableContainers:s,over:i,scrollableAncestors:a}}=e;if(w7.includes(t.code)){if(t.preventDefault(),!r||!n)return;let l=[];s.getEnabled().forEach(u=>{if(!u||u!=null&&u.disabled)return;let f=o.get(u.id);if(f)switch(t.code){case Nt.Down:n.top<f.top&&l.push(u);break;case Nt.Up:n.top>f.top&&l.push(u);break;case Nt.Left:n.left>f.left&&l.push(u);break;case Nt.Right:n.left<f.left&&l.push(u);break}});let c=bD({active:r,collisionRect:n,droppableRects:o,droppableContainers:l,pointerCoordinates:null}),d=_v(c,"id");if(d===i?.id&&c.length>1&&(d=c[1].id),d!=null){let u=s.get(r.id),f=s.get(d),p=f?o.get(f.id):null,h=f?.node.current;if(h&&p&&u&&f){let g=rp(h).some((w,C)=>a[C]!==w),x=jD(u,f),y=S7(u,f),m=g||!x?{x:0,y:0}:{x:y?n.width-p.width:0,y:y?n.height-p.height:0},v={x:p.left,y:p.top};return m.x&&m.y?v:hc(v,m)}}}};function jD(t,e){return!$g(t)||!$g(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function S7(t,e){return!$g(t)||!$g(e)||!jD(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}var ma=require("lucide-react");var Ye=require("react/jsx-runtime"),Lv=[{id:"DISE\xD1O",title:"Dise\xF1o",color:"bg-blue-500/10 border-blue-500/20 text-blue-700 dark:text-blue-400",coordinator:"Paola"},{id:"OPTIMIZACION",title:"Optimizaci\xF3n y Fact.",color:"bg-purple-500/10 border-purple-500/20 text-purple-700 dark:text-purple-400",coordinator:"Diego"},{id:"CAJA",title:"Caja",color:"bg-yellow-500/10 border-yellow-500/20 text-yellow-700 dark:text-yellow-400",coordinator:"Gloria"},{id:"PRODUCCION",title:"Producci\xF3n",color:"bg-orange-500/10 border-orange-500/20 text-orange-700 dark:text-orange-400",coordinator:"Gabriel, Diego"},{id:"DESPACHO",title:"Despacho",color:"bg-green-500/10 border-green-500/20 text-green-700 dark:text-green-400",coordinator:"Manuel"},{id:"ENTREGADO",title:"Entregado",color:"bg-teal-500/10 border-teal-500/20 text-teal-700 dark:text-teal-400",coordinator:"Local"}];function N7({order:t}){let{attributes:e,listeners:r,setNodeRef:n,transform:o,transition:s,isDragging:i}=HD({id:t.id}),a={transform:ll.Transform.toString(o),transition:s,zIndex:i?10:1,opacity:i?.5:1};return(0,Ye.jsxs)("div",{ref:n,style:a,...e,...r,className:"bg-surface-secondary p-3 rounded-xl shadow-sm lg:shadow border border-border-default mb-3 cursor-grab active:cursor-grabbing hover:border-border-hover hover:shadow-md transition-all group",children:[(0,Ye.jsxs)("div",{className:"flex justify-between items-start mb-2",children:[(0,Ye.jsxs)("div",{className:"flex flex-col",children:[(0,Ye.jsx)("span",{className:"font-bold text-text-primary text-sm",children:t.id}),t.rawStage&&(0,Ye.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-text-tertiary mt-0.5 font-bold",children:t.rawStage.replace(/_/g," ")})]}),(0,Ye.jsxs)("span",{className:"text-[10px] font-medium px-2 py-0.5 bg-surface-tertiary rounded-full text-text-secondary border border-border-default",children:[t.material.substring(0,15),"..."]})]}),(0,Ye.jsxs)("div",{className:"space-y-1.5 text-xs text-text-secondary",children:[(0,Ye.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Ye.jsx)(ma.User,{size:13,className:"text-text-tertiary"}),(0,Ye.jsx)("span",{className:"truncate",children:t.client})]}),(0,Ye.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Ye.jsx)(ma.Ruler,{size:13,className:"text-text-tertiary"}),(0,Ye.jsx)("span",{children:t.measurements})]}),(0,Ye.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Ye.jsx)(ma.Calendar,{size:13,className:"text-text-tertiary"}),(0,Ye.jsx)("span",{children:t.createdAt})]}),(0,Ye.jsxs)("div",{className:"flex items-center gap-2 cursor-pointer hover:bg-surface-tertiary p-1 -ml-1 rounded transition-colors group/phone mt-1",onClick:l=>{l.stopPropagation(),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:open-plugin",{detail:{pluginId:"chameleon"}}))},title:"Abrir WhatsApp Studio",children:[(0,Ye.jsx)(ma.Phone,{size:13,className:"text-green-500 group-hover/phone:animate-pulse"}),(0,Ye.jsx)("span",{className:"text-green-600 dark:text-green-400 font-medium group-hover/phone:underline",children:t.whatsapp})]})]})]})}function Fg(){let{orders:t,updateStatus:e}=es(),[r,n]=(0,vc.useState)(!1),[o,s]=(0,vc.useState)(""),i=["DISE\xD1O","OPTIMIZACION","CAJA","PRODUCCION","DESPACHO"],[a,l]=(0,vc.useState)(()=>{if(typeof window<"u"){let f=localStorage.getItem("mf_kanban_cols");if(f)return JSON.parse(f)}return i});(0,vc.useEffect)(()=>{localStorage.setItem("mf_kanban_cols",JSON.stringify(a))},[a]),(0,vc.useEffect)(()=>{let f=p=>{p.detail?.query&&(s(p.detail.query),window.dispatchEvent(new CustomEvent("studio:open-plugin",{detail:{pluginId:"chameleon",viewId:"chameleon-kanban-view"}})))};return window.addEventListener("studio:search-order",f),()=>window.removeEventListener("studio:search-order",f)},[]);let c=f=>{l(p=>p.includes(f)?p.filter(h=>h!==f):[...p,f])},d=pD(Ov(su,{activationConstraint:{distance:5}}),Ov(ou,{coordinateGetter:VD})),u=async f=>{let{active:p,over:h}=f;if(!h)return;let b=p.id,g=h.id,x=t.find(v=>v.id===b);if(!x)return;let y=null,m=Lv.find(v=>v.id===g);if(m)y=m.id;else{let v=t.find(S=>S.id===g);v&&(y=v.status)}y&&x.status!==y&&e(x.id,y)};return(0,Ye.jsxs)("div",{className:"h-full w-full bg-transparent p-4 flex flex-col overflow-hidden min-h-0 relative",children:[(0,Ye.jsxs)("div",{className:"flex justify-between items-center mb-4 shrink-0",children:[(0,Ye.jsxs)("h2",{className:"text-lg font-bold text-text-primary flex items-center gap-2",children:["Kanban de Pedidos",(0,Ye.jsxs)("span",{className:"text-xs bg-brand-primary/10 text-brand-primary px-2 py-0.5 rounded-full border border-brand-primary/20",children:[t.length," Totales"]})]}),(0,Ye.jsxs)("div",{className:"flex items-center gap-3 relative",children:[(0,Ye.jsxs)("div",{className:"relative flex items-center",children:[(0,Ye.jsx)("input",{type:"text",placeholder:"Buscar pedido, cliente...",value:o,onChange:f=>s(f.target.value),className:"pl-3 pr-8 py-1.5 w-64 bg-surface-secondary border border-border-default rounded-lg text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-brand-primary/50 transition-colors"}),o&&(0,Ye.jsx)("button",{onClick:()=>s(""),className:"absolute right-2 text-text-muted hover:text-text-primary",children:"\u2715"})]}),(0,Ye.jsxs)("button",{onClick:()=>n(!r),className:"flex items-center gap-2 px-3 py-1.5 bg-surface-secondary border border-border-default rounded-lg text-sm font-medium text-text-secondary hover:text-text-primary transition-colors",children:["Filtros ",(0,Ye.jsx)("span",{className:"opacity-50",children:"\u25BE"})]}),r&&(0,Ye.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-56 bg-surface-elevated border border-border-default shadow-xl rounded-xl p-3 z-50",children:[(0,Ye.jsx)("h3",{className:"text-xs font-bold text-text-secondary uppercase mb-2",children:"Columnas Visibles"}),(0,Ye.jsx)("div",{className:"flex flex-col gap-1.5",children:Lv.map(f=>(0,Ye.jsxs)("label",{className:"flex items-center gap-2 text-sm text-text-primary cursor-pointer hover:bg-surface-tertiary p-1.5 rounded-md transition-colors",children:[(0,Ye.jsx)("input",{type:"checkbox",className:"rounded border-border-default bg-surface-secondary text-brand-primary focus:ring-brand-primary/50",checked:a.includes(f.id),onChange:()=>c(f.id)}),f.title]},f.id))})]})]})]}),(0,Ye.jsx)(MD,{sensors:d,collisionDetection:gD,onDragEnd:u,children:(0,Ye.jsx)("div",{className:"flex-1 min-h-0 flex gap-6 overflow-x-auto pb-4 pr-4 scrollbar-thin",children:Lv.filter(f=>a.includes(f.id)).map(f=>{let p=t.filter(g=>{if(g.status!==f.id)return!1;if(o){let x=o.toLowerCase();return g.id.toLowerCase().includes(x)||g.client.toLowerCase().includes(x)||g.whatsapp.toLowerCase().includes(x)||g.material.toLowerCase().includes(x)}return!0}),h=100,b=p.slice(0,h);return(0,Ye.jsxs)("div",{className:"flex flex-col shrink-0 w-[280px] bg-surface-primary/30 rounded-2xl border border-border-default overflow-hidden",children:[(0,Ye.jsxs)("div",{className:`p-3 border-b border-border-default ${f.color}`,children:[(0,Ye.jsx)("h2",{className:"font-bold text-base",children:f.title}),(0,Ye.jsxs)("p",{className:"text-[10px] opacity-80 mt-0.5 flex items-center gap-1 uppercase tracking-wider font-semibold",children:[(0,Ye.jsx)(ma.User,{size:10})," ",f.coordinator]}),(0,Ye.jsxs)("div",{className:"mt-2 text-xs font-medium bg-black/5 dark:bg-white/10 px-2 py-0.5 rounded-md inline-block",children:[p.length," pedidos"]})]}),(0,Ye.jsx)("div",{className:"flex-1 p-4 overflow-y-auto min-h-0",children:(0,Ye.jsx)($D,{id:f.id,items:b.map(g=>g.id),strategy:LD,children:(0,Ye.jsxs)("div",{className:"min-h-[100px] h-full flex flex-col gap-0 pb-10",children:[b.map(g=>(0,Ye.jsx)(N7,{order:g},g.id)),p.length>h&&(0,Ye.jsxs)("div",{className:"p-3 mt-2 text-center text-xs font-medium text-text-tertiary bg-surface-tertiary/50 rounded-xl border border-border-subtle border-dashed",children:["+ ",p.length-h," pedidos ocultos",(0,Ye.jsx)("br",{}),(0,Ye.jsx)("span",{className:"text-[10px] text-brand-primary opacity-80 mt-1 inline-block",children:"Usa el buscador para filtrar"})]})]})})})]},f.id)})})})]})}var Hg=require("lucide-react");var ts=require("react/jsx-runtime"),C7={};function Vg(){let{orders:t}=es(),{searchTerm:e,setSearchTerm:r}=Eg(),n=a=>a.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),o=n(e),s=t.filter(a=>n(a.id).includes(o)||n(a.client).includes(o)||n(a.status).includes(o));return(0,ts.jsxs)("div",{className:"h-full w-full bg-white p-8 flex flex-col",children:[(0,ts.jsxs)("div",{className:"flex items-center justify-between mb-8",children:[(0,ts.jsxs)("div",{children:[(0,ts.jsxs)("h1",{className:"text-3xl font-bold text-gray-800 flex items-center gap-3",children:[(0,ts.jsx)(Hg.FileSpreadsheet,{className:"text-green-600",size:32}),"Historial de Pedidos"]}),(0,ts.jsx)("p",{className:"text-gray-500 mt-2",children:"Registro completo de operaciones Madefront."})]}),(0,ts.jsx)("div",{className:"flex items-center gap-4",children:(0,ts.jsxs)("button",{onClick:()=>{if(t.length===0)return;let a=["N\xBA Pedido","Urgente","Cliente","WhatsApp","Material","L\xE1minas","M\xE1quina","Estado","Pagado","SLA (Horas)","Fecha Creaci\xF3n"],l=t.map(p=>[p.id,p.isUrgent?"SI":"NO",`"${p.client}"`,p.whatsapp,`"${p.material}"`,p.sheets.toString(),p.machine,p.status,p.isPaid?"SI":"NO",p.slaHours.toString(),p.createdAt]),c=[a.join(","),...l.map(p=>p.join(","))].join(`
|
|
437
|
+
`),d=new Blob([c],{type:"text/csv;charset=utf-8;"}),u=URL.createObjectURL(d),f=document.createElement("a");f.setAttribute("href",u),f.setAttribute("download",`Madefront_Historial_${new Date().toISOString().split("T")[0]}.csv`),document.body.appendChild(f),f.click(),document.body.removeChild(f)},className:"flex items-center gap-2 px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 font-medium transition-colors shadow-sm active:scale-95",children:[(0,ts.jsx)(Hg.Download,{size:18}),"Descargar CSV"]})})]}),(0,ts.jsx)("div",{className:"flex-1 bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden flex flex-col",children:(0,ts.jsx)("iframe",{src:`https://docs.google.com/spreadsheets/d/${C7.env?.VITE_GOOGLE_SHEETS_ID||"1tu_YDOYiYeyWlw5_xqC5DHIsVB2bQdu1vCV3tCNoAYI"}/edit?rm=minimal`,className:"w-full h-full border-0",title:"Google Sheets Viewer",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]})}var Vt=require("react/jsx-runtime"),WD=()=>{let{createOrder:t}=es(),{logout:e}=al(),{currentView:r,setCurrentView:n}=Eg(),[o,s]=(0,jg.useState)({client:"",whatsapp:"",material:"",sheets:"1",measurements:"Adjunto"});(0,jg.useEffect)(()=>{r!=="madefront_kanban"&&r!=="madefront_excel"&&n("madefront_kanban")},[r,n]);let i=a=>{a.preventDefault(),t(o),Bt.success("Pedido Creado",{description:`El pedido para ${o.client} fue enviado a Dise\xF1o/Caja.`}),s({client:"",whatsapp:"",material:"",sheets:"1",measurements:"Adjunto"})};return(0,Vt.jsxs)("div",{className:"h-screen w-full bg-blue-50/50 font-sans text-slate-800 flex flex-col",children:[(0,Vt.jsxs)("header",{className:"bg-white px-8 py-4 border-b border-blue-100 flex justify-between items-center z-10 shadow-sm shrink-0",children:[(0,Vt.jsxs)("h1",{className:"text-xl font-bold text-blue-900 flex items-center gap-2",children:[(0,Vt.jsx)(dl.Package,{className:"text-blue-500"})," Gerencia & Ventas"]}),(0,Vt.jsxs)("div",{className:"flex bg-slate-100 p-1 rounded-xl",children:[(0,Vt.jsx)("button",{onClick:()=>n("madefront_kanban"),className:`px-4 py-2 rounded-lg text-sm font-bold transition-all ${r==="madefront_kanban"?"bg-white shadow-sm text-blue-600":"text-slate-500 hover:text-slate-700"}`,children:"Kanban Operativo"}),(0,Vt.jsxs)("button",{onClick:()=>n("madefront_excel"),className:`px-4 py-2 rounded-lg text-sm font-bold transition-all flex items-center gap-2 ${r==="madefront_excel"?"bg-white shadow-sm text-green-600":"text-slate-500 hover:text-slate-700"}`,children:[(0,Vt.jsx)(dl.FileSpreadsheet,{size:16})," Datos"]})]}),(0,Vt.jsxs)("button",{onClick:e,className:"text-sm text-slate-500 hover:text-blue-600 flex items-center gap-2 bg-slate-100 px-4 py-2 rounded-lg",children:[(0,Vt.jsx)(dl.LogOut,{size:16})," Salir"]})]}),(0,Vt.jsx)("main",{className:"flex-1 overflow-hidden flex flex-col w-full relative",children:r==="madefront_kanban"?(0,Vt.jsxs)("div",{className:"flex-1 flex flex-col p-4 md:p-6 overflow-hidden",children:[(0,Vt.jsxs)("div",{className:"mb-4 bg-white p-4 rounded-2xl shadow-sm border border-blue-100 flex gap-4 items-end shrink-0 overflow-x-auto",children:[(0,Vt.jsxs)("div",{className:"flex-1 min-w-[200px]",children:[(0,Vt.jsx)("label",{className:"text-[10px] font-bold text-slate-400 uppercase",children:"Cliente Nuevo"}),(0,Vt.jsx)("input",{className:"w-full bg-slate-50 border border-slate-200 rounded-lg px-3 py-2 text-sm",value:o.client,onChange:a=>s({...o,client:a.target.value}),placeholder:"Ej: Arq. Juan..."})]}),(0,Vt.jsxs)("div",{className:"w-40 shrink-0",children:[(0,Vt.jsx)("label",{className:"text-[10px] font-bold text-slate-400 uppercase",children:"Tel\xE9fono"}),(0,Vt.jsx)("input",{className:"w-full bg-slate-50 border border-slate-200 rounded-lg px-3 py-2 text-sm",value:o.whatsapp,onChange:a=>s({...o,whatsapp:a.target.value}),placeholder:"300..."})]}),(0,Vt.jsxs)("div",{className:"w-24 shrink-0",children:[(0,Vt.jsx)("label",{className:"text-[10px] font-bold text-slate-400 uppercase",children:"L\xE1minas"}),(0,Vt.jsx)("input",{type:"number",className:"w-full bg-slate-50 border border-slate-200 rounded-lg px-3 py-2 text-sm",value:o.sheets,onChange:a=>s({...o,sheets:a.target.value})})]}),(0,Vt.jsxs)("div",{className:"w-48 shrink-0",children:[(0,Vt.jsx)("label",{className:"text-[10px] font-bold text-slate-400 uppercase",children:"Material"}),(0,Vt.jsx)("input",{className:"w-full bg-slate-50 border border-slate-200 rounded-lg px-3 py-2 text-sm",value:o.material,onChange:a=>s({...o,material:a.target.value}),placeholder:"Ej: RH 15mm"})]}),(0,Vt.jsxs)("button",{onClick:i,className:"bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-6 rounded-lg shadow-md transition-all flex items-center gap-2 shrink-0 h-[38px]",children:[(0,Vt.jsx)(dl.Plus,{size:16})," Crear"]})]}),(0,Vt.jsx)("div",{className:"flex-1 min-h-0 border border-slate-200 rounded-2xl overflow-hidden shadow-xl bg-white flex flex-col",children:(0,Vt.jsx)(Fg,{})})]}):(0,Vt.jsx)(Vg,{})})]})};var wc=require("lucide-react"),At=require("react/jsx-runtime"),UD=()=>{let{getPendingPayments:t,approvePayment:e}=es(),{logout:r,currentUser:n}=al(),o=t();return(0,At.jsxs)("div",{className:"min-h-screen bg-slate-50 text-slate-900 font-sans",children:[(0,At.jsxs)("header",{className:"bg-white border-b border-emerald-100 px-8 py-4 flex justify-between items-center sticky top-0 z-10",children:[(0,At.jsxs)("div",{className:"flex items-center gap-3",children:[(0,At.jsx)("div",{className:"p-2 bg-emerald-100 text-emerald-600 rounded-lg",children:(0,At.jsx)(wc.DollarSign,{size:24})}),(0,At.jsxs)("div",{children:[(0,At.jsx)("h1",{className:"text-xl font-bold text-emerald-950",children:"Terminal de Caja"}),(0,At.jsxs)("p",{className:"text-xs text-emerald-600 font-medium uppercase tracking-wider",children:["Operador: ",n]})]})]}),(0,At.jsxs)("button",{onClick:r,className:"text-sm text-slate-400 hover:text-red-500 flex items-center gap-2 font-medium",children:[(0,At.jsx)(wc.LogOut,{size:16})," Salir"]})]}),(0,At.jsxs)("main",{className:"p-8 max-w-5xl mx-auto",children:[(0,At.jsxs)("div",{className:"flex justify-between items-end mb-6",children:[(0,At.jsx)("h2",{className:"text-2xl font-bold text-slate-800",children:"Pendientes de Aprobaci\xF3n"}),(0,At.jsxs)("span",{className:"text-sm bg-slate-200 px-3 py-1 rounded-full text-slate-600 font-bold",children:[o.length," PEDIDOS"]})]}),(0,At.jsxs)("div",{className:"grid gap-4",children:[o.map(s=>(0,At.jsxs)("div",{className:"bg-white p-6 rounded-2xl shadow-sm border border-slate-100 flex justify-between items-center hover:shadow-md transition-shadow",children:[(0,At.jsxs)("div",{children:[(0,At.jsxs)("div",{className:"flex items-center gap-3 mb-1",children:[(0,At.jsx)("span",{className:"text-lg font-black text-slate-800",children:s.id}),(0,At.jsx)("span",{className:"px-2 py-0.5 bg-blue-50 text-blue-600 text-xs font-bold rounded uppercase",children:s.client})]}),(0,At.jsxs)("div",{className:"text-sm text-slate-500 flex gap-4",children:[(0,At.jsxs)("span",{children:["\u{1F4C5} SLA: ",s.slaHours,"h"]}),(0,At.jsxs)("span",{children:["\u{1FAB5} ",s.material]}),(0,At.jsxs)("span",{children:["\u{1F4CF} ",s.sheets," L\xE1minas"]})]})]}),(0,At.jsxs)("div",{className:"flex items-center gap-6",children:[(0,At.jsxs)("div",{className:"text-right",children:[(0,At.jsx)("p",{className:"text-xs text-slate-400 uppercase font-bold",children:"Total a Pagar"}),(0,At.jsxs)("p",{className:"text-xl font-bold text-slate-900",children:["$ ",(s.sheets*25e4+5e4).toLocaleString()]})]}),(0,At.jsxs)("button",{onClick:()=>e(s.id),className:"bg-emerald-500 hover:bg-emerald-600 text-white px-6 py-3 rounded-xl font-bold flex items-center gap-2 shadow-lg shadow-emerald-200 transition-all active:scale-95",children:[(0,At.jsx)(wc.CheckCircle,{size:20}),"CONFIRMAR PAGO"]})]})]},s.id)),o.length===0&&(0,At.jsxs)("div",{className:"text-center py-20 bg-white rounded-3xl border border-dashed border-slate-200",children:[(0,At.jsx)(wc.CheckCircle,{size:48,className:"mx-auto text-slate-200 mb-4"}),(0,At.jsx)("p",{className:"text-slate-400",children:"Todo al d\xEDa. No hay pagos pendientes."})]})]})]})]})};var ul=require("lucide-react");var Yt=require("react/jsx-runtime"),GD=()=>{let{getOrdersByStage:t,updateStatus:e}=es(),{logout:r}=al(),n=t("PRODUCCION"),o=s=>{e(s,"DESPACHO"),Bt.success(`Enviando WhatsApp a +57...: El pedido ${s} pas\xF3 a Despacho`,{description:"Notificaci\xF3n de Producci\xF3n",icon:"\u{1F4F1}"})};return(0,Yt.jsxs)("div",{className:"min-h-screen bg-neutral-900 text-white font-sans selection:bg-orange-500 selection:text-white",children:[(0,Yt.jsxs)("header",{className:"bg-black border-b border-orange-600/30 px-6 py-4 flex justify-between items-center",children:[(0,Yt.jsxs)("div",{className:"flex items-center gap-4",children:[(0,Yt.jsx)("div",{className:"w-3 h-3 rounded-full bg-green-500 animate-pulse shadow-[0_0_10px_#22c55e]"}),(0,Yt.jsx)("h1",{className:"text-2xl font-black tracking-tighter text-orange-500",children:"KIOSCO DE PLANTA"})]}),(0,Yt.jsx)("button",{onClick:r,className:"bg-neutral-800 p-3 rounded-lg hover:bg-neutral-700",children:(0,Yt.jsx)(ul.LogOut,{size:24})})]}),(0,Yt.jsx)("main",{className:"p-6",children:n.length===0?(0,Yt.jsxs)("div",{className:"h-[60vh] flex flex-col items-center justify-center text-neutral-600",children:[(0,Yt.jsx)(ul.Hammer,{size:80,className:"mb-6 opacity-20"}),(0,Yt.jsx)("h2",{className:"text-3xl font-black uppercase",children:"M\xE1quinas Libres"}),(0,Yt.jsx)("p",{className:"mt-2",children:"Esperando asignaci\xF3n desde Caja..."})]}):(0,Yt.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:n.map(s=>(0,Yt.jsxs)("div",{className:"bg-neutral-800 border-l-8 border-orange-500 rounded-r-2xl p-6 relative overflow-hidden group",children:[(0,Yt.jsxs)("div",{className:"absolute top-0 right-0 bg-neutral-700 px-4 py-2 rounded-bl-xl text-xs font-bold text-neutral-400",children:["MAQUINA: ",(0,Yt.jsx)("span",{className:"text-orange-400 text-base",children:s.machine})]}),(0,Yt.jsxs)("div",{className:"mb-6 mt-2",children:[(0,Yt.jsx)("h2",{className:"text-5xl font-black text-white mb-2",children:s.id}),(0,Yt.jsx)("p",{className:"text-xl text-neutral-300 font-medium truncate",children:s.material}),(0,Yt.jsxs)("div",{className:"mt-4 flex gap-2",children:[(0,Yt.jsxs)("span",{className:"px-3 py-1 bg-neutral-700 rounded text-sm font-mono text-orange-200",children:[s.sheets," L\xC1MINAS"]}),(0,Yt.jsx)("span",{className:"px-3 py-1 bg-neutral-700 rounded text-sm font-mono text-orange-200",children:s.measurements})]})]}),(0,Yt.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,Yt.jsxs)("button",{className:"bg-neutral-700 hover:bg-neutral-600 text-neutral-300 py-4 rounded-xl font-bold flex flex-col items-center justify-center gap-1",children:[(0,Yt.jsx)(ul.AlertTriangle,{size:24}),(0,Yt.jsx)("span",{className:"text-xs",children:"REPORTAR"})]}),(0,Yt.jsxs)("button",{onClick:()=>o(s.id),className:"bg-orange-600 hover:bg-orange-500 text-white py-4 rounded-xl font-black text-lg flex flex-col items-center justify-center gap-1 shadow-[0_0_20px_rgba(234,88,12,0.3)] active:scale-95 transition-all",children:[(0,Yt.jsx)(ul.CheckSquare,{size:28}),"TERMINADO"]})]})]},s.id))})})]})};var ga=require("lucide-react");var ft=require("react/jsx-runtime"),KD=()=>{let{getOrdersByStage:t,updateStatus:e}=es(),{logout:r,currentUser:n}=al(),o=t("DESPACHO"),s=(i,a)=>{e(i,"ENTREGADO"),Bt.success(`Mensaje enviado a ${a}`,{description:`\u{1F4E6} \xA1Tu pedido ${i} ha sido entregado exitosamente!`,icon:"\u2705"})};return(0,ft.jsxs)("div",{className:"min-h-screen bg-slate-900 text-slate-100 font-sans",children:[(0,ft.jsxs)("header",{className:"bg-slate-950 border-b border-purple-500/30 px-6 py-4 flex justify-between items-center sticky top-0 z-10 shadow-lg shadow-purple-500/10",children:[(0,ft.jsxs)("div",{className:"flex items-center gap-3",children:[(0,ft.jsx)("div",{className:"p-2 bg-purple-500/20 text-purple-400 rounded-lg",children:(0,ft.jsx)(ga.Truck,{size:24})}),(0,ft.jsxs)("div",{children:[(0,ft.jsx)("h1",{className:"text-xl font-bold text-white",children:"Log\xEDstica & Despacho"}),(0,ft.jsxs)("p",{className:"text-xs text-purple-400 font-medium uppercase tracking-wider",children:["Operador: ",n]})]})]}),(0,ft.jsxs)("button",{onClick:r,className:"text-sm text-slate-400 hover:text-red-400 flex items-center gap-2 font-medium bg-slate-800 px-4 py-2 rounded-lg transition-colors",children:[(0,ft.jsx)(ga.LogOut,{size:16})," Salir"]})]}),(0,ft.jsxs)("main",{className:"p-8 max-w-6xl mx-auto",children:[(0,ft.jsxs)("div",{className:"flex justify-between items-end mb-8",children:[(0,ft.jsxs)("div",{children:[(0,ft.jsx)("h2",{className:"text-3xl font-bold text-white mb-2",children:"Pedidos Listos para Entrega"}),(0,ft.jsx)("p",{className:"text-slate-400",children:"Verifica la identidad antes de entregar el paquete."})]}),(0,ft.jsxs)("span",{className:"text-sm bg-purple-500/20 border border-purple-500/30 px-4 py-2 rounded-full text-purple-300 font-bold tracking-widest",children:[o.length," PAQUETES"]})]}),(0,ft.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.map(i=>(0,ft.jsxs)("div",{className:"bg-slate-800 border border-slate-700/50 rounded-2xl p-6 relative group overflow-hidden hover:border-purple-500/30 transition-colors",children:[(0,ft.jsx)("div",{className:"flex justify-between items-start mb-6",children:(0,ft.jsxs)("div",{children:[(0,ft.jsxs)("h3",{className:"text-2xl font-black text-white mb-1 flex items-center gap-2",children:[i.id,(0,ft.jsx)("span",{className:"bg-green-500/20 text-green-400 text-[10px] px-2 py-1 rounded-full uppercase tracking-widest font-bold",children:"PAGADO"})]}),(0,ft.jsxs)("p",{className:"text-slate-400 flex items-center gap-2",children:[(0,ft.jsx)(ga.Navigation,{size:14,className:"text-purple-400"}),"Destino: ",(0,ft.jsx)("strong",{className:"text-white",children:i.client})]})]})}),(0,ft.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-6 text-sm bg-slate-900/50 p-4 rounded-xl",children:[(0,ft.jsxs)("div",{children:[(0,ft.jsx)("span",{className:"block text-slate-500 text-xs mb-1 uppercase font-bold tracking-wider",children:"Material"}),(0,ft.jsx)("span",{className:"font-medium text-slate-200",children:i.material})]}),(0,ft.jsxs)("div",{children:[(0,ft.jsx)("span",{className:"block text-slate-500 text-xs mb-1 uppercase font-bold tracking-wider",children:"L\xE1minas (Volumen)"}),(0,ft.jsxs)("span",{className:"font-medium text-slate-200",children:[i.sheets," unid."]})]}),(0,ft.jsxs)("div",{className:"col-span-2 border-t border-slate-700/50 pt-3 mt-1",children:[(0,ft.jsx)("span",{className:"block text-slate-500 text-xs mb-1 uppercase font-bold tracking-wider",children:"Contacto WhatsApp"}),(0,ft.jsx)("span",{className:"font-mono text-purple-300",children:i.whatsapp})]})]}),(0,ft.jsxs)("button",{onClick:()=>s(i.id,i.whatsapp),className:"w-full bg-purple-600 hover:bg-purple-500 text-white py-4 rounded-xl font-bold flex items-center justify-center gap-2 shadow-lg shadow-purple-900/50 transition-all active:scale-95",children:[(0,ft.jsx)(ga.CheckCircle,{size:20}),"CONFIRMAR ENTREGA"]})]},i.id)),o.length===0&&(0,ft.jsxs)("div",{className:"col-span-full h-[40vh] flex flex-col items-center justify-center text-slate-500 border-2 border-dashed border-slate-700 rounded-3xl",children:[(0,ft.jsx)(ga.Truck,{size:64,className:"mb-4 opacity-20"}),(0,ft.jsx)("p",{className:"text-lg font-medium",children:"Bandeja de salida vac\xEDa"}),(0,ft.jsx)("p",{className:"text-sm",children:"Todo ha sido despachado a los clientes."})]})]})]})]})};var op=require("react"),m4=require("socket.io-client");var ye=Re(require("react"),1),Zv=require("socket.io-client"),I=require("react/jsx-runtime"),Jv=require("@decido/kernel-bridge");Ri();var Bv=class t{static instance;templates=new Map;constructor(){}static getInstance(){return t.instance||(t.instance=new t),t.instance}register(e){this.templates.set(e.id,e)}get(e){return this.templates.get(e)}getAll(){return Array.from(this.templates.values())}},zv=Bv.getInstance();var $v=`
|
|
438
|
+
You are an AI Graph Architect for react-flow.
|
|
439
|
+
Your goal is to parse natural language requests and return a JSON schema of operations to modify the graph.
|
|
440
|
+
|
|
441
|
+
# Output Format
|
|
442
|
+
Return ONLY a JSON object with this structure:
|
|
443
|
+
{
|
|
444
|
+
"operations": [
|
|
445
|
+
{ "type": "addNode", "id": "generated-id", "position": { "x": 0, "y": 0 }, "data": { "label": "Node Label", "type": "default" } },
|
|
446
|
+
{ "type": "addEdge", "source": "source-id", "target": "target-id", "animated": true }
|
|
447
|
+
],
|
|
448
|
+
"thought": "Brief explanation of your architectural decision."
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
# Rules
|
|
452
|
+
1. Assign unique IDs to new nodes (e.g., "node-timestamp-random").
|
|
453
|
+
2. Prefer "default" or "input/output" types unless specified.
|
|
454
|
+
3. Space nodes out reasonably (x+=200).
|
|
455
|
+
`;var Fv=class t{static instance;constructor(){this.registerPrompts()}static getInstance(){return t.instance||(t.instance=new t),t.instance}registerPrompts(){zv.register({id:"flow-generation",description:"Generate Flow Graph",system:$v,user:"Request: {{input}}",requiredContext:["activeView"]})}executor=null;setExecutor(e){this.executor=e}async generateGraphOps(e){if(console.log("[FlowOrchestrator] Generating ops for:",e),this.executor)try{let r=`${$v}
|
|
456
|
+
|
|
457
|
+
User Prompt: ${e}`,n=await this.executor(r);return this.parseResponse(n)}catch(r){return console.error("[FlowOrchestrator] AI Execution Failed:",r),{operations:[],thought:"Failed to generate flow via AI."}}return e.toLowerCase().includes("server")?{thought:"Adding a server node as requested.",operations:[{type:"addNode",id:`server-${Date.now()}`,position:{x:Math.random()*500,y:Math.random()*500},data:{label:"Server Node",type:"default"}}]}:{operations:[],thought:"No relevant graph operations found (Mock)."}}parseResponse(e){try{let r=e.replace(/```json/g,"").replace(/```/g,"").trim();return JSON.parse(r)}catch{return console.error("[FlowOrchestrator] Failed to parse JSON:",e),{operations:[],thought:"Invalid JSON response from AI."}}}},fpe=Fv.getInstance();var jv=Re(require("react"));var Sc=require("lucide-react");var iu=Re(require("react"),1),E7=Re(require("react-dom"),1);function k7(t){if(!t||typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",e.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}var hpe=Array(12).fill(0);var Hv=1,Vv=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let r=this.subscribers.indexOf(e);this.subscribers.splice(r,1)}),this.publish=e=>{this.subscribers.forEach(r=>r(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var r;let{message:n,...o}=e,s=typeof e?.id=="number"||((r=e.id)==null?void 0:r.length)>0?e.id:Hv++,i=this.toasts.find(l=>l.id===s),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),i?this.toasts=this.toasts.map(l=>l.id===s?(this.publish({...l,...e,id:s,title:n}),{...l,...e,id:s,dismissible:a,title:n}):l):this.addToast({title:n,...o,dismissible:a,id:s}),s},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(r=>r({id:e,dismiss:!0})))):this.toasts.forEach(r=>{this.subscribers.forEach(n=>n({id:r.id,dismiss:!0}))}),e),this.message=(e,r)=>this.create({...r,message:e}),this.error=(e,r)=>this.create({...r,message:e,type:"error"}),this.success=(e,r)=>this.create({...r,type:"success",message:e}),this.info=(e,r)=>this.create({...r,type:"info",message:e}),this.warning=(e,r)=>this.create({...r,type:"warning",message:e}),this.loading=(e,r)=>this.create({...r,type:"loading",message:e}),this.promise=(e,r)=>{if(!r)return;let n;r.loading!==void 0&&(n=this.create({...r,promise:e,type:"loading",message:r.loading,description:typeof r.description!="function"?r.description:void 0}));let o=Promise.resolve(e instanceof Function?e():e),s=n!==void 0,i,a=o.then(async c=>{if(i=["resolve",c],iu.default.isValidElement(c))s=!1,this.create({id:n,type:"default",message:c});else if(I7(c)&&!c.ok){s=!1;let u=typeof r.error=="function"?await r.error(`HTTP error! status: ${c.status}`):r.error,f=typeof r.description=="function"?await r.description(`HTTP error! status: ${c.status}`):r.description,h=typeof u=="object"&&!iu.default.isValidElement(u)?u:{message:u};this.create({id:n,type:"error",description:f,...h})}else if(c instanceof Error){s=!1;let u=typeof r.error=="function"?await r.error(c):r.error,f=typeof r.description=="function"?await r.description(c):r.description,h=typeof u=="object"&&!iu.default.isValidElement(u)?u:{message:u};this.create({id:n,type:"error",description:f,...h})}else if(r.success!==void 0){s=!1;let u=typeof r.success=="function"?await r.success(c):r.success,f=typeof r.description=="function"?await r.description(c):r.description,h=typeof u=="object"&&!iu.default.isValidElement(u)?u:{message:u};this.create({id:n,type:"success",description:f,...h})}}).catch(async c=>{if(i=["reject",c],r.error!==void 0){s=!1;let d=typeof r.error=="function"?await r.error(c):r.error,u=typeof r.description=="function"?await r.description(c):r.description,p=typeof d=="object"&&!iu.default.isValidElement(d)?d:{message:d};this.create({id:n,type:"error",description:u,...p})}}).finally(()=>{s&&(this.dismiss(n),n=void 0),r.finally==null||r.finally.call(r)}),l=()=>new Promise((c,d)=>a.then(()=>i[0]==="reject"?d(i[1]):c(i[1])).catch(d));return typeof n!="string"&&typeof n!="number"?{unwrap:l}:Object.assign(n,{unwrap:l})},this.custom=(e,r)=>{let n=r?.id||Hv++;return this.create({jsx:e(n),id:n,...r}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Rs=new Vv,T7=(t,e)=>{let r=e?.id||Hv++;return Rs.addToast({title:t,...e,id:r}),r},I7=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",A7=T7,M7=()=>Rs.toasts,P7=()=>Rs.getActiveToasts(),_i=Object.assign(A7,{success:Rs.success,info:Rs.info,warning:Rs.warning,error:Rs.error,custom:Rs.custom,message:Rs.message,promise:Rs.promise,dismiss:Rs.dismiss,loading:Rs.loading},{getHistory:M7,getToasts:P7});k7("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");var qD=require("react/jsx-runtime");var Nc=require("react"),au=require("lucide-react"),Nn=require("react/jsx-runtime"),ype=(0,Nc.memo)(({data:t})=>{let e=t.label||"UNKNOWN_SKILL",[r,n]=(0,Nc.useState)(!1),[o,s]=(0,Nc.useState)(["> READY_TO_EXECUTE"]),[i,a]=(0,Nc.useState)("idle"),[l,c]=(0,Nc.useState)(t.config||{target:"127.0.0.1"});return(0,Nn.jsxs)("div",{className:"h-full bg-slate-900 border border-slate-700 rounded-lg overflow-hidden flex flex-col shadow-lg",style:{minWidth:200,minHeight:180},children:[(0,Nn.jsxs)("div",{className:"flex items-center justify-between p-2 bg-slate-800 border-b border-slate-700",children:[(0,Nn.jsx)("div",{className:`p-1 rounded ${i==="running"?"bg-amber-500 text-white animate-pulse":"text-slate-500"}`,children:(0,Nn.jsx)(au.Terminal,{size:14})}),(0,Nn.jsx)("span",{className:"text-[9px] font-bold text-slate-400 uppercase tracking-wider",children:i}),(0,Nn.jsxs)("button",{onClick:()=>{n(!0),a("running"),s(u=>[...u,`> EXECUTING: ${e}`,"> INITIATING_PROCESS..."]),setTimeout(()=>{s(u=>[...u,`> TARGET_ACQUIRED: ${l.target||"LOCALHOST"}`,"> RUNNING_DIAGNOSTICS..."])},800),setTimeout(()=>{s(u=>[...u,"> PROCESS_COMPLETE","> EXIT_CODE: 0"]),n(!1),a("success")},2200)},disabled:r,className:`flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold transition-all
|
|
458
|
+
${r?"text-slate-500 cursor-not-allowed":"bg-emerald-600 hover:bg-emerald-500 text-white shadow-lg shadow-emerald-900/50"}
|
|
459
|
+
`,children:[r?(0,Nn.jsx)(au.Activity,{size:10,className:"animate-spin"}):(0,Nn.jsx)(au.Play,{size:10}),"RUN"]})]}),(0,Nn.jsxs)("div",{className:"px-3 py-2 bg-slate-900 border-b border-slate-800 flex items-center gap-2",children:[(0,Nn.jsx)("span",{className:"text-[9px] font-bold text-slate-500 uppercase",children:"Target"}),(0,Nn.jsx)("input",{type:"text",value:l.target,onChange:u=>c({...l,target:u.target.value}),className:"flex-1 bg-transparent border-none text-[11px] text-blue-400 font-mono outline-none placeholder-slate-700",placeholder:"ENTER_TARGET"})]}),(0,Nn.jsxs)("div",{className:"flex-1 p-2 bg-black/40 font-mono text-[9px] overflow-y-auto custom-scrollbar",children:[o.map((u,f)=>(0,Nn.jsx)("div",{className:"text-emerald-500/80 mb-0.5 whitespace-pre-wrap break-all border-l-2 border-transparent pl-1 hover:border-emerald-500/30",children:u},f)),r&&(0,Nn.jsx)("div",{className:"text-emerald-500 animate-pulse",children:"_"})]}),(0,Nn.jsxs)("div",{className:"flex justify-between px-2 py-1 bg-slate-950 text-[8px] text-slate-600 font-mono",children:[(0,Nn.jsxs)("span",{children:["PID: ",Math.floor(Math.random()*9999)]}),(0,Nn.jsx)("span",{children:"MEM: 14MB"})]})]})});var Ds=require("react");Ri();var Os=require("lucide-react");var Ve=require("react/jsx-runtime"),YD=({value:t,label:e,onChange:r,depth:n=0})=>{let[o,s]=(0,Ds.useState)(!1),[i,a]=(0,Ds.useState)(10),l=Array.isArray(t)?"array":t===null?"null":typeof t;if(t===null)return(0,Ve.jsx)("div",{style:{color:"var(--text-dim)",fontStyle:"italic"},children:"null"});if(l==="boolean")return(0,Ve.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e&&(0,Ve.jsxs)("span",{style:{color:"var(--accent-primary)",fontWeight:700,marginRight:"8px"},children:[e,":"]}),(0,Ve.jsx)("button",{onClick:()=>r(!t),style:{width:32,height:16,borderRadius:"8px",position:"relative",background:t?"var(--accent-primary)":"var(--border-light)",border:"none",cursor:"pointer",transition:"background 0.15s"},children:(0,Ve.jsx)("div",{style:{position:"absolute",top:2,width:12,height:12,background:"white",borderRadius:"50%",left:t?18:2,transition:"left 0.15s"}})}),(0,Ve.jsx)("span",{style:{color:"var(--text-dim)",fontSize:"9px"},children:t?"TRUE":"FALSE"})]});let c={flex:1,background:"var(--node-bg)",border:"1px solid var(--border-light)",borderRadius:"var(--radius-sm)",padding:"2px 8px",fontSize:"10px",outline:"none",fontFamily:"var(--font-mono)",minWidth:0};if(l==="string")return(0,Ve.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"},children:[e&&(0,Ve.jsxs)("span",{style:{color:"var(--accent-primary)",fontWeight:700,whiteSpace:"nowrap"},children:[e,":"]}),(0,Ve.jsx)("input",{style:{...c,color:"var(--status-ok)"},value:t,onChange:d=>r(d.target.value)})]});if(l==="number")return(0,Ve.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"},children:[e&&(0,Ve.jsxs)("span",{style:{color:"var(--accent-primary)",fontWeight:700,whiteSpace:"nowrap"},children:[e,":"]}),(0,Ve.jsx)("input",{type:"number",style:{...c,color:"var(--accent-primary)"},value:t,onChange:d=>r(Number(d.target.value))})]});if(l==="array"||l==="object"){let d=Object.keys(t),u=d.length,f=u===0;return(0,Ve.jsxs)("div",{style:{width:"100%"},children:[(0,Ve.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[(0,Ve.jsx)("button",{onClick:()=>s(!o),disabled:f,style:{background:"none",border:"none",color:"var(--text-dim)",cursor:f?"default":"pointer",opacity:f?.3:1,padding:0},children:o?(0,Ve.jsx)(Os.ChevronDown,{size:12}):(0,Ve.jsx)(Os.ChevronRight,{size:12})}),e&&(0,Ve.jsxs)("span",{style:{color:"var(--accent-primary)",fontWeight:700},children:[e,":"]}),(0,Ve.jsx)("span",{style:{fontSize:"9px",color:"var(--text-dim)",textTransform:"uppercase"},children:l==="array"?`Array(${u})`:"Object"}),!o&&!f&&(0,Ve.jsxs)("span",{style:{fontSize:"9px",color:"var(--text-dim)",maxWidth:150,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",opacity:.5},children:[JSON.stringify(t).slice(0,30),"..."]})]}),o&&(0,Ve.jsxs)("div",{style:{paddingLeft:"16px",marginLeft:"4px",borderLeft:"1px solid var(--border-light)",display:"flex",flexDirection:"column",gap:"4px",marginTop:"4px"},children:[d.slice(0,i).map(p=>{let h=t[p],b=g=>{let x;Array.isArray(t)?(x=[...t],x[Number(p)]=g):x={...t,[p]:g},r(x)};return(0,Ve.jsx)("div",{style:{paddingTop:"2px",paddingBottom:"2px"},children:(0,Ve.jsx)(YD,{label:Array.isArray(t)?`${p}`:p,value:h,onChange:b,depth:n+1})},p)}),u>i&&(0,Ve.jsxs)("button",{onClick:()=>a(p=>p+20),className:"text-[9px] text-blue-400 hover:text-blue-300 w-full text-center py-1 bg-slate-800/50 rounded",children:["Show ",u-i," more..."]})]})]})}return(0,Ve.jsx)("div",{style:{color:"var(--status-crit)"},children:"Unknown Type"})},R7=({data:t,selected:e})=>{let[r,n]=(0,Ds.useState)("mission"),[o,s]=(0,Ds.useState)(""),[i,a]=(0,Ds.useState)(""),[l,c]=(0,Ds.useState)(!1),[d,u]=(0,Ds.useState)({});(0,Ds.useEffect)(()=>{t.getDebugState&&u(t.getDebugState(r))},[r,t.getDebugState]);let f=d,p=t.availableActions||[],h=async x=>{try{if(t.onRunAction){let y=t.onRunAction(x);y instanceof Promise?_i.promise(y,{loading:`Running ${x}...`,success:`${x} completed`,error:`${x} failed`}):_i.success(`Executed: ${x}`)}else _i.warning("No action runner provided")}catch(y){_i.error(`Error executing ${x}`),console.error(y)}},b=()=>{try{t.onInjectState?(t.onInjectState(i),_i.success("State injected into Core"),c(!1)):_i.error("Injection not supported")}catch{_i.error("Invalid JSON")}},g={mission:"var(--accent-primary, #3b82f6)",ui:"var(--status-warn, #f59e0b)",system:"var(--status-ok, #10b981)"};return(0,Ve.jsxs)("div",{className:`bg-slate-900 border-2 rounded-xl overflow-hidden flex flex-col font-mono text-[10px] ${e?"border-blue-500 shadow-xl":"border-slate-800"}`,style:{width:"100%",height:"100%",minWidth:"350px",minHeight:"500px"},children:[(0,Ve.jsx)(BM,{minWidth:350,minHeight:500,isVisible:e,color:"var(--accent-primary)"}),(0,Ve.jsxs)("div",{className:"h-8 flex items-center px-2 border-b border-red-500/30 bg-linear-to-r from-red-900/20 to-blue-900/20 drag-handle",children:[(0,Ve.jsxs)("div",{className:"flex items-center gap-2 text-red-500 font-bold uppercase tracking-widest text-[10px]",children:[(0,Ve.jsx)(Os.ShieldAlert,{size:14}),(0,Ve.jsx)("span",{children:"GOD_MODE // KERNEL"})]}),(0,Ve.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,Ve.jsx)("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),(0,Ve.jsx)("span",{className:"text-slate-500",children:"v2.0"})]})]}),(0,Ve.jsx)("div",{className:"flex border-b border-slate-700 bg-slate-900",children:["mission","ui","system"].map(x=>(0,Ve.jsx)("button",{onClick:()=>n(x),className:`flex-1 py-2 text-[10px] uppercase font-bold transition-colors border-b-2 ${r===x?"text-"+x+" border-"+x:"text-slate-500 border-transparent hover:text-slate-300"}`,style:{color:r===x?g[x]:void 0,borderColor:r===x?g[x]:void 0},children:x},x))}),(0,Ve.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden bg-slate-950",children:[(0,Ve.jsxs)("div",{className:"p-2 border-b border-slate-800 bg-slate-900 flex items-center gap-2",children:[(0,Ve.jsxs)("div",{className:"flex items-center bg-slate-950 rounded border border-slate-800 flex-1 px-2 h-7 gap-2",children:[(0,Ve.jsx)(Os.Search,{size:12,className:"text-slate-500"}),(0,Ve.jsx)("input",{className:"bg-transparent border-none text-slate-200 w-full outline-none font-mono text-[10px]",placeholder:"Filter keys...",value:o,onChange:x=>s(x.target.value)})]}),(0,Ve.jsx)("button",{onClick:()=>c(!l),className:`p-1.5 rounded border ${l?"border-blue-500 bg-blue-500/10 text-blue-500":"border-slate-800 bg-transparent text-slate-500"}`,title:"Inject State",children:(0,Ve.jsx)(Os.Terminal,{size:14})})]}),(0,Ve.jsx)("div",{className:"flex-1 overflow-y-auto p-2 custom-scrollbar",children:l?(0,Ve.jsxs)("div",{className:"h-full flex flex-col gap-2",children:[(0,Ve.jsx)("textarea",{className:"flex-1 bg-slate-900 border border-slate-700 rounded p-2 text-green-400 font-mono text-[10px] outline-none resize-none",placeholder:"// Paste JSON State here to hydrate...",value:i,onChange:x=>a(x.target.value)}),(0,Ve.jsx)("button",{onClick:b,className:"w-full py-2 bg-blue-600 hover:bg-blue-500 text-white rounded font-bold uppercase tracking-wider text-[10px]",children:"HYDRATE REALITY"})]}):(0,Ve.jsx)("div",{className:"flex flex-col gap-1 pb-10",children:(0,Ve.jsx)(YD,{value:f,onChange:x=>{_i.info("Visual editing is read-only for deep structures. Use Injection for major changes.")}})})}),(0,Ve.jsxs)("div",{className:"h-[150px] border-t border-slate-800 bg-slate-900 p-2 overflow-y-auto custom-scrollbar",children:[(0,Ve.jsxs)("div",{className:"text-[9px] text-slate-500 uppercase font-bold mb-2 flex items-center gap-2",children:[(0,Ve.jsx)(Os.Zap,{size:10})," OVERRIDE COMMANDS"]}),(0,Ve.jsx)("div",{className:"grid grid-cols-2 gap-1",children:p.filter(x=>x.toLowerCase().includes(o.toLowerCase())).slice(0,10).map(x=>(0,Ve.jsxs)("button",{onClick:()=>h(x),className:"text-left px-2 py-1 bg-slate-800 hover:bg-slate-700 text-slate-400 hover:text-white rounded text-[9px] truncate transition-colors",title:x,children:[x,"()"]},x))})]})]})]})},Ope=(0,Ds.memo)(R7);var _7=require("react"),Wv=require("lucide-react");var Wg=Re(require("react")),D7=require("react/jsx-runtime"),Bpe=(0,Wg.createContext)(null);var XD=require("react/jsx-runtime");var L7=require("react");var Uv=new Date,Upe=[`[${Uv.toLocaleTimeString()}] System initialized.`,`[${Uv.toLocaleTimeString()}] Connected to Cortex Telemetry.`,`[${Uv.toLocaleTimeString()}] Monitoring active nodes...`];var B7=require("react");var $7=require("react");var Li=require("@decido/logger");var Gv=class{tools=new Map;modules=new Map;register(e){this.tools.has(e.name)&&Li.logger.warn(`[ToolRegistry] Overwriting tool: ${e.name}`),this.tools.set(e.name,e),Li.logger.info(`[ToolRegistry] Registered tool: ${e.name}`)}unregister(e){this.tools.delete(e),Li.logger.info(`[ToolRegistry] Unregistered tool: ${e}`)}registerModule(e){this.modules.has(e.id)&&(Li.logger.warn(`[ToolRegistry] Module already registered: ${e.id}, updating...`),this.modules.get(e.id).tools.forEach(n=>this.tools.delete(n.name))),this.modules.set(e.id,e),e.tools.forEach(r=>this.register(r)),Li.logger.info(`[ToolRegistry] \u{1F4E6} Module registered: ${e.name} (${e.tools.length} tools)`)}unregisterModule(e){let r=this.modules.get(e);r&&(r.tools.forEach(n=>this.tools.delete(n.name)),this.modules.delete(e),Li.logger.info(`[ToolRegistry] \u{1F4E6} Module unregistered: ${r.name}`))}getModule(e){return this.modules.get(e)}getAllModules(){return Array.from(this.modules.values())}get(e){return this.tools.get(e)}getAll(){return Array.from(this.tools.values())}async execute(e,r){let n=this.tools.get(e);if(!n)throw new Error(`Tool not found: ${e}`);try{return Li.logger.info(`[ToolRegistry] Executing ${e}`,r),await n.handler(r)}catch(o){throw Li.logger.error(`[ToolRegistry] Execution failed for ${e}`,o),o}}},z7=new Gv;var JD=require("react");var Kv=class{channels=new Map;lastValues=new Map;subscribe(e,r){if(this.channels.has(e)||this.channels.set(e,new Set),this.channels.get(e).add(r),this.lastValues.has(e))try{r(this.lastValues.get(e))}catch(n){console.error(`[Synapse] Error in callback for ${e}:`,n)}return()=>this.unsubscribe(e,r)}unsubscribe(e,r){this.channels.get(e)?.delete(r),this.channels.get(e)?.size===0&&this.channels.delete(e)}broadcast(e,r){this.lastValues.set(e,r);let n=this.channels.get(e);n&&n.forEach(o=>{try{o(r)}catch(s){console.error(`[Synapse] Broadcast failed for listener on ${e}`,s)}})}getValue(e){return this.lastValues.get(e)}getActiveChannels(){return Array.from(this.channels.keys())}},F7=new Kv;var ba=require("lucide-react"),qv=class{definitions=new Map;constructor(){this.registerDefaults()}register(e){this.definitions.set(e.id,e)}get(e){return this.definitions.get(e)}getAll(){return Array.from(this.definitions.values())}getByType(e){return this.getAll().filter(r=>r.type===e)}registerDefaults(){this.register({id:"cron",label:"Interval Timer",type:"trigger",icon:ba.Timer,description:"Dispara un evento repetidamente.",fields:[{key:"interval",label:"Intervalo (ms)",type:"number",defaultValue:5e3},{key:"emitTimestamp",label:"Incluir Timestamp",type:"boolean",defaultValue:!0}],execute:async()=>({}),setup:(e,{trigger:r})=>{let n=Number(e.interval)||5e3,o=setInterval(()=>{r({timestamp:Date.now(),type:"cron"})},n);return()=>clearInterval(o)}}),this.register({id:"event",label:"Event Listener",type:"trigger",icon:ba.Zap,description:"Escucha eventos globales (window.postMessage).",fields:[{key:"eventName",label:"Nombre del Evento",type:"text",placeholder:"mindframe.event"}],execute:async()=>({}),setup:(e,{trigger:r})=>{if(!e.eventName)return;let n=o=>{(o.data?.type===e.eventName||o.data?.name===e.eventName)&&r(o.data)};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)}}),this.register({id:"bridge",label:"Broadcast Message",type:"action",icon:ba.Zap,description:"Env\xEDa un mensaje global a la ventana.",fields:[{key:"method",label:"Method / Event Name",type:"text",defaultValue:"custom_event"},{key:"payload",label:"Payload (JSON)",type:"json"}],execute:async(e,r)=>{let n=e.payload?JSON.parse(e.payload):r;return window.postMessage({type:e.method,payload:n,timestamp:Date.now()},"*"),{sent:!0,method:e.method}}}),this.register({id:"http",label:"HTTP Request",type:"action",icon:ba.Globe,description:"Realiza una petici\xF3n API externa.",fields:[{key:"url",label:"URL",type:"text",placeholder:"https://api.xyz"},{key:"method",label:"M\xE9todo",type:"select",defaultValue:"GET",options:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"}]},{key:"body",label:"Body (JSON)",type:"json"}],execute:async(e,r)=>await(await fetch(e.url,{method:e.method,headers:{"Content-Type":"application/json"},body:e.method!=="GET"?e.body||JSON.stringify(r):void 0})).json()}),this.register({id:"check_value",label:"Check Value",type:"condition",icon:ba.Split,description:"Compara un valor del payload.",fields:[{key:"field",label:"Campo (ej: data.id)",type:"text"},{key:"operator",label:"Operador",type:"select",defaultValue:"equals",options:[{label:"Igual a (==)",value:"equals"},{label:"Contiene",value:"contains"},{label:"Mayor que (>)",value:"gt"}]},{key:"value",label:"Valor a comparar",type:"text"}],execute:async(e,r)=>{let o=((i,a)=>a.split(".").reduce((l,c)=>l?.[c],i))(r,e.field),s=e.value;return e.operator==="equals"?String(o)===String(s):e.operator==="contains"?String(o).includes(String(s)):e.operator==="gt"?Number(o)>Number(s):!1}})}},lhe=new qv;var ZD=require("@decido/logger");var QD=require("zustand");Ri();var e4=(t=[],e=[])=>(0,QD.create)((r,n)=>({nodes:t,edges:e,onNodesChange:o=>{r({nodes:ag(o,n().nodes)})},onEdgesChange:o=>{r({edges:lg(o,n().edges)})},onConnect:o=>{r({edges:ic(o,n().edges)})},setNodes:o=>{r({nodes:o})},setEdges:o=>{r({edges:o})},addNode:o=>{r({nodes:[...n().nodes,o]})},updateNodeConfig:(o,s)=>{r({nodes:n().nodes.map(i=>i.id===o?{...i,data:{...i.data,config:s}}:i)})}}));var lu=Re(require("react"));Ri();zf();var t4=Re(require("yjs")),r4=require("y-websocket"),Cn=require("react/jsx-runtime"),W7={},Ug=null,fl=null;function H7(t){if(!Ug){Ug=new t4.Doc;let e=W7.env?.VITE_WS_URL||"ws://localhost:3001";fl=new r4.WebsocketProvider(`${e}/api/collaboration`,t,Ug),fl.awareness.setLocalStateField("user",{name:`Usuario ${Math.floor(Math.random()*1e3)}`,color:`hsl(${Math.floor(Math.random()*360)}, 70%, 50%)`})}return{ydoc:Ug,wsProvider:fl}}function V7(){let[t,e]=lu.default.useState(new Map);lu.default.useEffect(()=>{if(!fl)return;let n=fl.awareness,o=()=>{e(new Map(n.getStates()))};return n.on("change",o),o(),()=>n.off("change",o)},[]);let r=Array.from(t.entries()).filter(([n,o])=>n!==fl?.awareness.clientID&&o.cursor).map(([n,o])=>(0,Cn.jsxs)("div",{style:{position:"absolute",left:o.cursor.x,top:o.cursor.y,pointerEvents:"none",zIndex:9999},className:"flex flex-col items-start transition-all duration-75 ease-out",children:[(0,Cn.jsx)("svg",{width:"24",height:"36",viewBox:"0 0 24 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"absolute -left-1 -top-1",style:{transform:"rotate(-25deg)"},children:(0,Cn.jsx)("path",{d:"M5.65376 2.15376C5.40821 1.66266 4.70732 1.63738 4.43265 2.1098L0.165287 9.44917C-0.0827293 9.87574 0.224673 10.4285 0.730302 10.4285H10.1506C10.7437 10.4285 11.0182 9.69176 10.5513 9.303L5.65376 2.15376Z",fill:o.user?.color||"red"})}),(0,Cn.jsx)("span",{style:{backgroundColor:o.user?.color||"red"},className:"text-[10px] font-bold text-white px-2 py-0.5 rounded-md whitespace-nowrap shadow-sm mt-3 ml-2",children:o.user?.name||"Anon"})]},n));return(0,Cn.jsx)(Cn.Fragment,{children:r})}var j7=({initialNodes:t=[],initialEdges:e=[],nodes:r,edges:n,onNodesChange:o,onEdgesChange:s,onConnect:i,nodeTypes:a,edgeTypes:l,onSave:c,readOnly:d=!1,onNodeClick:u,onEdgeClick:f,onPaneClick:p,flowId:h="default-flow"})=>{lu.default.useEffect(()=>{H7(`madefront-flow-${h}`)},[h]);let b=(0,lu.useMemo)(()=>e4(t,e),[]),g=b(M=>M.nodes),x=b(M=>M.edges),y=b(M=>M.onNodesChange),m=b(M=>M.onEdgesChange),v=b(M=>M.onConnect),S=r!==void 0?r:g,w=n!==void 0?n:x;return(0,Cn.jsx)("div",{className:"w-full h-full min-h-[500px] border border-white/10 rounded-xl overflow-hidden bg-macia-bg relative",children:(0,Cn.jsxs)(el,{nodes:S,edges:w,onNodesChange:d?void 0:o!==void 0?o:y,onEdgesChange:d?void 0:s!==void 0?s:m,onConnect:d?void 0:i!==void 0?i:v,nodeTypes:a,edgeTypes:l,fitView:!0,proOptions:{hideAttribution:!0},className:"bg-transparent",nodesDraggable:!d,nodesConnectable:!d,elementsSelectable:!0,onNodeClick:u,onEdgeClick:f,onPaneClick:p,onPointerMove:M=>{let T=M.currentTarget.getBoundingClientRect();fl?.awareness.setLocalStateField("cursor",{x:M.clientX-T.left,y:M.clientY-T.top})},onPointerLeave:()=>{fl?.awareness.setLocalStateField("cursor",null)},children:[(0,Cn.jsx)(V7,{}),(0,Cn.jsx)(tl,{variant:Pi.Dots,gap:24,size:2,color:"rgba(255,255,255,0.05)"}),(0,Cn.jsx)(rl,{className:"bg-macia-bg border border-white/10 fill-white text-white"}),(0,Cn.jsx)(nl,{nodeColor:"rgba(6, 182, 212, 0.5)",maskColor:"rgba(0, 0, 0, 0.7)",className:"bg-macia-bg border border-white/10"}),c&&!d&&(0,Cn.jsx)(Gd,{position:"top-right",className:"m-4",children:(0,Cn.jsx)("button",{onClick:()=>c(S,w),className:"px-4 py-2 bg-emerald-500/20 hover:bg-emerald-500/30 text-emerald-400 border border-emerald-500/50 rounded-lg text-sm font-bold transition-colors shadow-[0_0_15px_rgba(16,185,129,0.2)]",children:"Guardar Pipeline"})})]})})},n4=t=>(0,Cn.jsx)(Bf,{children:(0,Cn.jsx)(j7,{...t})});var o4=require("react"),s4=require("react/jsx-runtime");var Qv=require("@decido/macia-core"),oo=require("lucide-react"),Cc={},i4=Cc.env?.VITE_API_BASE_URL||"http://localhost:3001",a4=[{id:"t1",label:"Confirmaci\xF3n Pedido",icon:"fas fa-check-circle"},{id:"t2",label:"Estado de Env\xEDo",icon:"fas fa-truck"},{id:"t3",label:"Cotizaci\xF3n",icon:"fas fa-file-invoice"},{id:"t4",label:"Bienvenida",icon:"fas fa-hand-wave"}],l4=[{id:"a1",label:"Auto-respuesta horario",active:!0},{id:"a2",label:"Crear pedido autom\xE1tico",active:!0},{id:"a3",label:"Escalamiento a asesor",active:!1},{id:"a4",label:"Encuesta satisfacci\xF3n",active:!0}],Yv=({title:t,icon:e,count:r,defaultOpen:n=!0,children:o})=>{let[s,i]=(0,ye.useState)(n);return(0,I.jsxs)("div",{className:"border-b",style:{borderColor:"var(--border-color)"},children:[(0,I.jsxs)("button",{onClick:()=>i(a=>!a),className:"w-full flex items-center gap-2 px-3 py-2 text-[10px] font-black uppercase tracking-widest transition-all hover:bg-white/5",style:{color:"var(--text-secondary)"},children:[(0,I.jsx)("i",{className:`fas fa-chevron-${s?"down":"right"} text-[8px] w-3`}),(0,I.jsx)("i",{className:`${e} text-[10px]`}),(0,I.jsx)("span",{className:"flex-1 text-left",children:t}),r!==void 0&&(0,I.jsx)("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold",style:{background:"var(--bg-muted)",color:"var(--text-secondary)"},children:r})]}),s&&(0,I.jsx)("div",{className:"pb-1",children:o})]})},U7=({selectedContact:t,onSelectContact:e})=>{let[r,n]=(0,ye.useState)(""),[o,s]=(0,ye.useState)([]);(0,ye.useEffect)(()=>{let a=async()=>{try{let c=await(await fetch(`${i4}/api/whatsapp/conversations`)).json();s(c.map(d=>({...d,last_activity:new Date(d.last_activity)})))}catch{}};a();let l=(0,Zv.io)(i4,{transports:["websocket","polling"]});return l.on("wa:message_received",a),l.on("wa:message_sent",a),()=>{l.disconnect()}},[]);let i=o.filter(a=>a.phone.includes(r));return(0,I.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,I.jsx)("div",{className:"p-2 shrink-0",children:(0,I.jsxs)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-xs",style:{background:"var(--bg-muted)",border:"1px solid var(--border-color)"},children:[(0,I.jsx)("i",{className:"fas fa-search text-[10px]",style:{color:"var(--text-secondary)"}}),(0,I.jsx)("input",{type:"text",placeholder:"Filtrar...",className:"flex-1 bg-transparent outline-none text-xs",style:{color:"var(--text-primary)"},value:r,onChange:a=>n(a.target.value)})]})}),(0,I.jsxs)("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:[(0,I.jsxs)(Yv,{title:"Conversaciones",icon:"fas fa-comments",count:i.length,children:[i.map(a=>(0,I.jsxs)("button",{onClick:()=>e(a.phone),className:"w-full flex items-start gap-2.5 px-3 py-2 text-left transition-all rounded-md mx-1",style:{background:t===a.phone?"var(--bg-muted)":"transparent",width:"calc(100% - 8px)"},onMouseEnter:l=>{t!==a.phone&&(l.currentTarget.style.background="var(--bg-muted)")},onMouseLeave:l=>{t!==a.phone&&(l.currentTarget.style.background="transparent")},children:[(0,I.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0 text-white text-[10px] font-bold",style:{background:"var(--brand-primary)"},children:(0,I.jsx)("i",{className:"fab fa-whatsapp text-sm"})}),(0,I.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,I.jsxs)("div",{className:"flex items-center justify-between",children:[(0,I.jsx)("span",{className:"text-xs font-bold truncate",style:{color:"var(--text-primary)"},children:a.profile_name||"+"+a.phone}),(0,I.jsx)("span",{className:"text-[9px] shrink-0 ml-1",style:{color:"var(--text-secondary)"},children:a.last_activity.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),(0,I.jsx)("p",{className:"text-[10px] truncate mt-0.5",style:{color:"var(--text-secondary)"},children:a.last_message||"Media"})]})]},a.phone)),i.length===0&&(0,I.jsxs)("div",{className:"px-4 py-3 pb-4 text-center",children:[(0,I.jsx)("i",{className:"fab fa-whatsapp text-2xl mb-2",style:{color:"#25D366"}}),(0,I.jsx)("p",{className:"text-xs",style:{color:"var(--text-secondary)"},children:"No hay chats activos. Manda un WhatsApp al n\xFAmero Business para empezar."})]})]}),(0,I.jsx)(Yv,{title:"Plantillas",icon:"fas fa-file-alt",count:a4.length,defaultOpen:!1,children:a4.map(a=>(0,I.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 mx-1 rounded-md cursor-pointer transition-all",style:{width:"calc(100% - 8px)"},onMouseEnter:l=>l.currentTarget.style.background="var(--bg-muted)",onMouseLeave:l=>l.currentTarget.style.background="transparent",children:[(0,I.jsx)("i",{className:`${a.icon} text-[10px]`,style:{color:"var(--brand-primary)"}}),(0,I.jsx)("span",{className:"text-xs",style:{color:"var(--text-primary)"},children:a.label})]},a.id))}),(0,I.jsx)(Yv,{title:"Automatizaciones",icon:"fas fa-robot",count:l4.filter(a=>a.active).length,defaultOpen:!1,children:l4.map(a=>(0,I.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 mx-1 rounded-md",style:{width:"calc(100% - 8px)"},children:[(0,I.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${a.active?"bg-green-500":"bg-slate-400"}`}),(0,I.jsx)("span",{className:"text-xs flex-1",style:{color:"var(--text-primary)"},children:a.label}),(0,I.jsx)("span",{className:"text-[9px] font-bold",style:{color:a.active?"#22c55e":"var(--text-secondary)"},children:a.active?"ON":"OFF"})]},a.id))})]})]})},G7={c1:{name:"Mar\xEDa Garc\xEDa",phone:"+57 301 234 5678",email:"maria@gmail.com",city:"Bogot\xE1",totalOrders:8,totalSpent:"$4,250,000",lastOrder:"PED-1847",sentiment:"neutral",tags:["VIP","Frecuente","Muebler\xEDa"],timeline:[{time:"2m",event:"Pregunt\xF3 por estado de pedido",icon:"fas fa-comment"},{time:"1d",event:"Pedido PED-1847 en PRODUCTION",icon:"fas fa-industry"},{time:"3d",event:"Transici\xF3n a IN_CUTTING (Control)",icon:"fas fa-check-circle"},{time:"1w",event:"Tracking Link Generado",icon:"fas fa-link"}]},c2:{name:"Carlos Ruiz",phone:"+57 310 987 6543",email:"cruiz@empresa.co",city:"Medell\xEDn",totalOrders:3,totalSpent:"$1,890,000",lastOrder:"PED-1832",sentiment:"positive",tags:["Empresa","Nuevo"],timeline:[{time:"15m",event:"Solicit\xF3 cotizaci\xF3n de mesa",icon:"fas fa-comment"},{time:"2d",event:"RuleEngine Trigger: NEW Order",icon:"fas fa-bolt"}]}},K7={positive:{icon:"fas fa-smile",color:"#22c55e",label:"Positivo"},neutral:{icon:"fas fa-meh",color:"#f59e0b",label:"Neutral"},negative:{icon:"fas fa-frown",color:"#ef4444",label:"Negativo"}},np=({label:t,value:e})=>(0,I.jsxs)("div",{className:"flex justify-between items-center py-1.5",children:[(0,I.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--text-secondary)"},children:t}),(0,I.jsx)("span",{className:"text-xs font-semibold",style:{color:"var(--text-primary)"},children:e})]}),q7=({selectedContact:t})=>{let e=t?G7[t]:null;if(!e)return(0,I.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-6",children:[(0,I.jsx)("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"var(--bg-muted)"},children:(0,I.jsx)("i",{className:"fas fa-user-slash text-xl",style:{color:"var(--text-secondary)"}})}),(0,I.jsxs)("p",{className:"text-xs text-center font-medium",style:{color:"var(--text-secondary)"},children:["Selecciona un contacto",(0,I.jsx)("br",{}),"para ver detalles"]})]});let r=K7[e.sentiment];return(0,I.jsxs)("div",{className:"flex flex-col h-full overflow-y-auto scrollbar-thin",children:[(0,I.jsxs)("div",{className:"p-4 text-center border-b",style:{borderColor:"var(--border-color)"},children:[(0,I.jsx)("div",{className:"w-14 h-14 rounded-full mx-auto flex items-center justify-center text-white font-bold text-lg mb-3",style:{background:"var(--brand-primary)"},children:e.name.split(" ").map(n=>n[0]).join("")}),(0,I.jsx)("h3",{className:"font-bold text-sm",style:{color:"var(--text-primary)"},children:e.name}),(0,I.jsx)("p",{className:"text-[10px] mt-0.5",style:{color:"var(--text-secondary)"},children:e.phone}),(0,I.jsx)("div",{className:"flex flex-wrap justify-center gap-1 mt-3",children:e.tags.map(n=>(0,I.jsx)("span",{className:"px-2 py-0.5 rounded-full text-[9px] font-bold",style:{background:"var(--bg-muted)",color:"var(--brand-primary)",border:"1px solid var(--border-color)"},children:n},n))})]}),(0,I.jsxs)("div",{className:"px-4 py-3 border-b",style:{borderColor:"var(--border-color)"},children:[(0,I.jsx)("div",{className:"text-[10px] font-black uppercase tracking-widest mb-2",style:{color:"var(--text-secondary)"},children:"Sentimiento IA"}),(0,I.jsxs)("div",{className:"flex items-center gap-2 p-2 rounded-lg",style:{background:"var(--bg-muted)"},children:[(0,I.jsx)("i",{className:`${r.icon} text-lg`,style:{color:r.color}}),(0,I.jsxs)("div",{children:[(0,I.jsx)("span",{className:"text-xs font-bold",style:{color:r.color},children:r.label}),(0,I.jsx)("div",{className:"w-full h-1.5 rounded-full mt-1",style:{background:"var(--border-color)"},children:(0,I.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:e.sentiment==="positive"?"80%":e.sentiment==="neutral"?"50%":"25%",background:r.color}})})]})]})]}),(0,I.jsxs)("div",{className:"px-4 py-3 border-b",style:{borderColor:"var(--border-color)"},children:[(0,I.jsx)("div",{className:"text-[10px] font-black uppercase tracking-widest mb-2",style:{color:"var(--text-secondary)"},children:"Resumen Cliente"}),(0,I.jsx)(np,{label:"Pedidos",value:String(e.totalOrders)}),(0,I.jsx)(np,{label:"Total",value:e.totalSpent}),(0,I.jsx)(np,{label:"\xDAltimo",value:e.lastOrder}),(0,I.jsx)(np,{label:"Ciudad",value:e.city}),(0,I.jsx)(np,{label:"Email",value:e.email})]}),(0,I.jsxs)("div",{className:"px-4 py-3",children:[(0,I.jsx)("div",{className:"text-[10px] font-black uppercase tracking-widest mb-3",style:{color:"var(--text-secondary)"},children:"Actividad Reciente"}),(0,I.jsx)("div",{className:"space-y-0",children:e.timeline.map((n,o)=>(0,I.jsxs)("div",{className:"flex gap-3 relative",children:[o<e.timeline.length-1&&(0,I.jsx)("div",{className:"absolute left-[9px] top-5 w-px h-full",style:{background:"var(--border-color)"}}),(0,I.jsx)("div",{className:"w-5 h-5 rounded-full flex items-center justify-center shrink-0 z-10",style:{background:"var(--bg-muted)",border:"1px solid var(--border-color)"},children:(0,I.jsx)("i",{className:`${n.icon} text-[8px]`,style:{color:"var(--brand-primary)"}})}),(0,I.jsxs)("div",{className:"pb-4 min-w-0",children:[(0,I.jsx)("p",{className:"text-[11px] font-medium leading-tight",style:{color:"var(--text-primary)"},children:n.event}),(0,I.jsxs)("span",{className:"text-[9px]",style:{color:"var(--text-secondary)"},children:["Hace ",n.time]})]})]},o))})]})]})},Y7=()=>{let[t,e]=(0,ye.useState)([{id:"1",text:"Soy tu Agente Vocal asignado. \xBFEn qu\xE9 te ayudo con tus flujos?",type:"system"}]),[r,n]=(0,ye.useState)(""),[o,s]=(0,ye.useState)(!1),i=(0,ye.useRef)(null);(0,ye.useEffect)(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[t]),(0,ye.useEffect)(()=>{let l=Jv.kernel.onEvent(d=>{d.event_type==="message_sent"&&d.data?.target==="vocal_domain_agent"||d.event_type==="message_sent"&&d.data?.intent==="vocal_response"&&(e(u=>[...u,{id:Date.now().toString(),text:d.data.payload,type:"agent"}]),s(!1))}),c=null;try{c=new EventSource("http://localhost:3001/api/events"),c.addEventListener("whatsapp:message_received",d=>{try{let u=JSON.parse(d.data);e(f=>[...f,{id:Date.now().toString(),text:`\u{1F4F1} [WA] ${u.profileName||u.from}: ${u.text||"Archivo Adjunto"}`,type:"user"}]),s(!0),setTimeout(()=>{e(f=>[...f,{id:Date.now().toString(),text:"Regla disparada: Mensaje recibido. Evaluando intenci\xF3n...",type:"system"}]),s(!1)},1e3)}catch{}}),c.addEventListener("whatsapp:status_update",d=>{try{let u=JSON.parse(d.data);e(f=>[...f,{id:Date.now().toString(),text:`\u2714\uFE0F [Estado WA] ${u.status} a ${u.recipient_id}`,type:"system"}])}catch{}}),c.onerror=()=>{c?.close()}}catch{console.log("SSE Error, falling back to local kernel")}return()=>{l(),c&&c.close()}},[]);let a=async()=>{if(!r.trim())return;let l=r;n(""),e(c=>[...c,{id:Date.now().toString(),text:l,type:"user"}]),s(!0);try{await Jv.kernel.execute("spawn_task",{target_id:"vocal_domain_agent",role:"vocal_domain",intent:"user_prompt",payload:l}),setTimeout(()=>{s(!1),e(c=>c.some(d=>d.type==="agent"&&parseInt(d.id)>Date.now()-2e3)?c:[...c,{id:Date.now().toString(),text:"Evaluando el dise\xF1o de tu flujo actual... Parece \xF3ptimo para WhatsApp Business.",type:"agent"}])},1500)}catch(c){console.error("Error contacting agent:",c),s(!1)}};return(0,I.jsxs)("div",{className:"h-full flex flex-col font-sans",style:{background:"var(--bg-elevated)",color:"var(--text-primary)"},children:[(0,I.jsxs)("div",{className:"h-11 shrink-0 flex items-center px-3 border-b gap-2",style:{borderColor:"var(--border-color)"},children:[(0,I.jsx)("div",{className:"w-6 h-6 rounded-full bg-emerald-500/20 flex items-center justify-center border border-emerald-500/50",children:(0,I.jsx)("i",{className:"fas fa-robot text-emerald-400 text-xs text-brand animate-pulse"})}),(0,I.jsx)("span",{className:"font-bold text-xs",children:"Agente Decido"}),(0,I.jsx)("span",{className:"ml-auto px-1.5 py-0.5 rounded text-[9px] font-bold bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",children:"VOCAL DOMAIN"})]}),(0,I.jsxs)("div",{ref:i,className:"flex-1 min-h-0 overflow-y-auto p-3 space-y-3",children:[t.map(l=>(0,I.jsxs)("div",{className:`flex flex-col max-w-[90%] ${l.type==="user"?"ml-auto items-end":"mr-auto items-start"}`,children:[l.type==="system"&&(0,I.jsx)("div",{className:"text-[10px] text-center w-full my-2 italic",style:{color:"var(--text-secondary)"},children:l.text}),l.type!=="system"&&(0,I.jsx)("div",{className:`text-xs px-3 py-2 rounded-xl leading-relaxed ${l.type==="user"?"bg-brand text-white rounded-br-sm":"bg-white/5 border border-white/10 rounded-bl-sm"}`,children:l.text})]},l.id)),o&&(0,I.jsxs)("div",{className:"flex items-center gap-1.5 p-2 bg-white/5 w-fit rounded-lg border border-white/10 rounded-bl-sm",children:[(0,I.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500/50 animate-bounce",style:{animationDelay:"0ms"}}),(0,I.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500/50 animate-bounce",style:{animationDelay:"150ms"}}),(0,I.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500/50 animate-bounce",style:{animationDelay:"300ms"}})]})]}),(0,I.jsx)("div",{className:"p-2 shrink-0 border-t",style:{borderColor:"var(--border-color)"},children:(0,I.jsxs)("div",{className:"flex items-end gap-2 bg-white/5 border border-white/10 rounded-lg p-1.5 focus-within:border-emerald-500/50 transition-colors",children:[(0,I.jsx)("textarea",{value:r,onChange:l=>n(l.target.value),onKeyDown:l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),a())},placeholder:"Preg\xFAntale al Agente...",className:"flex-1 bg-transparent resize-none text-xs outline-none p-1.5 min-h-[32px] max-h-[100px]",rows:r.split(`
|
|
460
|
+
`).length>1?Math.min(r.split(`
|
|
461
|
+
`).length,4):1}),(0,I.jsx)("button",{onClick:a,disabled:!r.trim()||o,className:"w-8 h-8 shrink-0 rounded-md bg-white/10 hover:bg-white/20 text-emerald-400 flex items-center justify-center transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:(0,I.jsx)("i",{className:"fas fa-paper-plane text-xs"})})]})})]})},Xv=Cc.env?.VITE_API_BASE_URL||"http://localhost:3001",X7=({selectedContact:t})=>{let[e,r]=(0,ye.useState)([]),[n,o]=(0,ye.useState)(""),[s,i]=(0,ye.useState)("COPILOT"),[a,l]=(0,ye.useState)(null),c=(0,ye.useRef)(null),d=(0,ye.useCallback)(async()=>{if(!t){r([]);return}try{let f=(await(await fetch(`${Xv}/api/whatsapp/messages?phone=${t}&limit=50`)).json()).reverse().map(p=>({id:p.id.toString(),text:p.body||(p.message_type==="image"?"\u{1F4F8} [Imagen]":"\u{1F4CE} [Archivo]"),sender:p.direction==="INBOUND"?"user":"bot",timestamp:new Date(p.created_at),isIncoming:p.direction==="INBOUND",status:p.direction==="OUTBOUND"?"sent":void 0}));r(f)}catch(f){console.error("Failed to fetch messages:",f)}},[t]);(0,ye.useEffect)(()=>{d();let f=(0,Zv.io)(Xv,{transports:["websocket","polling"]});return f.on("connect",()=>console.log("[ChatTab] Connected to WebSocket")),f.on("wa:message_received",p=>{t&&p.from===t&&d()}),f.on("wa:message_sent",p=>{t&&p.to===t&&d()}),f.on("wa:status_update",p=>{t&&d()}),l(f),()=>{f.disconnect()}},[t,d]),(0,ye.useEffect)(()=>{c.current?.scrollIntoView({behavior:"smooth"})},[e]);let u=async()=>{if(!n.trim()||!t)return;let f=n;o("");let p={id:`temp-${Date.now()}`,text:f,sender:"bot",timestamp:new Date,isIncoming:!1,status:"sent"};r(h=>[...h,p]);try{await fetch(`${Xv}/api/whatsapp/send-chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({to:t,text:f})})}catch(h){console.error("Send failed:",h)}};return(0,I.jsxs)("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden relative",children:[(0,I.jsxs)("div",{className:"h-12 shrink-0 flex items-center justify-between px-4 border-b",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)"},children:[(0,I.jsxs)("div",{className:"flex items-center gap-3",children:[(0,I.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-[10px] font-bold",style:{background:"#25D366"},children:(0,I.jsx)("i",{className:"fab fa-whatsapp text-sm"})}),(0,I.jsxs)("div",{children:[(0,I.jsx)("span",{className:"text-xs font-bold",style:{color:"var(--text-primary)"},children:t?"+"+t:"Seleccionar contacto"}),(0,I.jsx)("span",{className:"text-[10px] block",style:{color:"var(--text-secondary)"},children:t?"en l\xEDnea":"\u2014"})]})]}),(0,I.jsx)("div",{className:"flex items-center gap-1 p-0.5 rounded-lg",style:{background:"var(--bg-muted)"},children:["MANUAL","COPILOT","AUTO"].map(f=>(0,I.jsxs)("button",{onClick:()=>i(f),className:"px-2.5 py-1 rounded-md text-[9px] font-black tracking-wide transition-all",style:{background:s===f?"var(--brand-primary)":"transparent",color:s===f?"white":"var(--text-secondary)"},children:[f==="COPILOT"&&(0,I.jsx)("i",{className:"fas fa-wand-sparkles mr-1 text-[8px]"}),f]},f))})]}),(0,I.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 scrollbar-thin",style:{background:"var(--bg-primary)"},children:[(0,I.jsx)("div",{className:"absolute inset-0 opacity-[0.02] pointer-events-none",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23888' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`}}),(0,I.jsxs)("div",{className:"relative z-10 space-y-3",children:[e.map(f=>(0,I.jsx)("div",{className:`flex ${f.sender==="system"?"justify-center":f.isIncoming?"justify-start":"justify-end"}`,children:f.sender==="system"?(0,I.jsxs)("span",{className:"px-3 py-1 rounded-full text-[9px] font-bold uppercase tracking-widest",style:{background:"var(--bg-muted)",color:"var(--text-secondary)",border:"1px solid var(--border-color)"},children:[(0,I.jsx)("i",{className:"fas fa-info-circle mr-1"}),f.text]}):f.sender==="copilot"?(0,I.jsxs)("div",{className:"max-w-[75%] p-3 rounded-xl rounded-bl-none shadow-lg border",style:{background:"linear-gradient(135deg, rgba(99,102,241,0.15), rgba(168,85,247,0.15))",borderColor:"rgba(139,92,246,0.3)"},children:[(0,I.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5",children:[(0,I.jsx)("i",{className:"fas fa-wand-sparkles text-[10px]",style:{color:"#a855f7"}}),(0,I.jsx)("span",{className:"text-[9px] font-black uppercase tracking-wide",style:{color:"#a855f7"},children:"CoPilot IA"})]}),(0,I.jsx)("p",{className:"text-xs italic leading-relaxed",style:{color:"var(--text-primary)"},children:f.text}),(0,I.jsxs)("div",{className:"mt-2 flex gap-1.5",children:[(0,I.jsx)("button",{className:"flex-1 px-2 py-1 rounded-md text-[9px] font-bold transition-all",style:{background:"var(--bg-muted)",color:"var(--text-secondary)",border:"1px solid var(--border-color)"},children:"Ignorar"}),(0,I.jsx)("button",{className:"flex-1 px-2 py-1 rounded-md text-[9px] font-bold transition-all text-white",style:{background:"#8b5cf6"},children:"Aplicar"})]})]}):(0,I.jsxs)("div",{className:`max-w-[70%] p-3 rounded-xl shadow-sm text-xs leading-relaxed ${f.isIncoming?"rounded-tl-none":"rounded-tr-none"}`,style:{background:f.isIncoming?"var(--bg-elevated)":"rgba(37,211,102,0.15)",color:"var(--text-primary)",border:f.isIncoming?"1px solid var(--border-color)":"1px solid rgba(37,211,102,0.2)"},children:[(0,I.jsx)("p",{className:"whitespace-pre-wrap",children:f.text}),(0,I.jsxs)("div",{className:"flex items-center justify-end gap-1 mt-1.5",children:[(0,I.jsx)("span",{className:"text-[9px]",style:{color:"var(--text-secondary)"},children:f.timestamp.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),!f.isIncoming&&f.status&&(0,I.jsx)("i",{className:`fas fa-check-double text-[9px] ${f.status==="read"?"text-blue-400":""}`,style:{color:f.status==="read"?"#38bdf8":"var(--text-secondary)"}})]})]})},f.id)),(0,I.jsx)("div",{ref:c})]})]}),(0,I.jsxs)("div",{className:"shrink-0 p-3 border-t",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)"},children:[(0,I.jsxs)("div",{className:"flex items-center gap-2",children:[(0,I.jsx)("button",{className:"w-8 h-8 rounded-lg flex items-center justify-center transition-all",style:{color:"var(--text-secondary)"},onMouseEnter:f=>f.currentTarget.style.background="var(--bg-muted)",onMouseLeave:f=>f.currentTarget.style.background="transparent",children:(0,I.jsx)("i",{className:"fas fa-paperclip text-sm"})}),(0,I.jsxs)("div",{className:"flex-1 flex items-center gap-2 px-3 py-2 rounded-xl",style:{background:"var(--bg-muted)",border:"1px solid var(--border-color)"},children:[(0,I.jsx)("input",{type:"text",placeholder:"Escribe un mensaje...",className:"flex-1 bg-transparent outline-none text-xs",style:{color:"var(--text-primary)"},value:n,onChange:f=>o(f.target.value),onKeyDown:f=>f.key==="Enter"&&u()}),(0,I.jsx)("button",{className:"text-xs",style:{color:"var(--text-secondary)"},children:(0,I.jsx)("i",{className:"fas fa-face-smile"})})]}),(0,I.jsx)("button",{onClick:u,className:"w-9 h-9 rounded-xl flex items-center justify-center text-white transition-all shadow-md",style:{background:"#25D366"},children:(0,I.jsx)("i",{className:`fas ${n.trim()?"fa-paper-plane":"fa-microphone"} text-sm`})})]}),s==="COPILOT"&&(0,I.jsxs)("div",{className:"flex items-center gap-2 mt-2 px-2",children:[(0,I.jsx)("i",{className:"fas fa-wand-sparkles text-[9px]",style:{color:"#a855f7"}}),(0,I.jsx)("span",{className:"text-[9px]",style:{color:"var(--text-secondary)"},children:"CoPilot activo \u2014 sugerencias autom\xE1ticas"})]})]})]})},c4={incoming:{icon:(0,I.jsx)(oo.MessageCircle,{size:14}),colorClass:"text-emerald-400",bgClass:"from-emerald-500/10 to-transparent"},outgoing:{icon:(0,I.jsx)(oo.Reply,{size:14}),colorClass:"text-blue-400",bgClass:"from-blue-500/10 to-transparent"},system:{icon:(0,I.jsx)(oo.Info,{size:14}),colorClass:"text-purple-400",bgClass:"from-purple-500/10 to-transparent"}},f4=(0,ye.memo)(({id:t,data:e,selected:r})=>{let n=e||{},o=c4[n.type]||c4.incoming,s=(0,I.jsxs)("div",{className:"flex justify-between items-center w-full min-w-[140px]",children:[(0,I.jsxs)("div",{className:"flex items-center gap-2",children:[(0,I.jsx)("span",{className:o.colorClass,children:o.icon}),(0,I.jsx)("span",{children:n.label})]}),n.time&&(0,I.jsx)("span",{className:"text-[9px] text-zinc-500 font-mono tracking-wider ml-4",children:n.time})]});return(0,I.jsxs)(Qv.BaseNode,{id:t,selected:r,title:s,className:`border border-white/5 bg-linear-to-br ${o.bgClass} backdrop-blur-md`,children:[(0,I.jsx)(qr,{type:"target",position:Te.Left,className:"!w-2 !h-2 !bg-zinc-800 !border-[1.5px] !border-zinc-400"}),(0,I.jsx)("div",{className:"p-3 text-xs leading-relaxed text-zinc-300 font-light break-words max-w-[240px]",children:n.text}),(0,I.jsx)(qr,{type:"source",position:Te.Right,className:`!w-2 !h-2 !bg-zinc-800 !border-[1.5px] ${o.colorClass.replace("text-","border-")}`})]})});f4.displayName="MessageNode";var d4={reply:{icon:(0,I.jsx)(oo.Bot,{size:14}),colorClass:"text-emerald-400",bgClass:"from-emerald-500/10 to-transparent"},create_order:{icon:(0,I.jsx)(oo.ShoppingCart,{size:14}),colorClass:"text-amber-400",bgClass:"from-amber-500/10 to-transparent"},escalate:{icon:(0,I.jsx)(oo.Headphones,{size:14}),colorClass:"text-rose-400",bgClass:"from-rose-500/10 to-transparent"},analyze:{icon:(0,I.jsx)(oo.Brain,{size:14}),colorClass:"text-violet-400",bgClass:"from-violet-500/10 to-transparent"},decision:{icon:(0,I.jsx)(oo.GitBranch,{size:14}),colorClass:"text-cyan-400",bgClass:"from-cyan-500/10 to-transparent"}},p4=(0,ye.memo)(({id:t,data:e,selected:r})=>{let n=e||{},o=d4[n?.actionType]||d4.reply,s=(0,I.jsxs)("div",{className:"flex items-center gap-2",children:[(0,I.jsx)("span",{className:o.colorClass,children:o.icon}),(0,I.jsx)("span",{children:n?.label||"Action"})]});return(0,I.jsxs)(Qv.BaseNode,{id:t,selected:r,title:s,hideTarget:!0,hideSource:!0,className:`min-w-[200px] border border-white/5 bg-linear-to-br ${o.bgClass} backdrop-blur-md`,children:[(0,I.jsx)(qr,{type:"target",position:Te.Left,className:"!w-2 !h-2 !bg-zinc-800 !border-[1.5px] !border-zinc-400"}),n.description&&(0,I.jsx)("div",{className:"px-3 py-2 text-xs text-zinc-400 font-light leading-relaxed",children:n.description}),(0,I.jsx)(qr,{type:"source",position:Te.Right,className:`!w-2 !h-2 !bg-zinc-800 !border-[1.5px] ${o.colorClass.replace("text-","border-")}`}),n.actionType==="decision"&&(0,I.jsx)(qr,{type:"source",position:Te.Bottom,id:"no",className:"!w-2 !h-2 !bg-zinc-800 !border-[1.5px] border-rose-500"})]})});p4.displayName="BotActionNode";var J7=({token:t="demo-token-123",onClose:e})=>{let r=`http://localhost:3001/track/${t}`,[n,o]=(0,ye.useState)(!0);return(0,I.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 animate-in fade-in",children:(0,I.jsxs)("div",{className:"w-full max-w-[400px] bg-[#0E1525] rounded-[24px] overflow-hidden border border-white/10 shadow-2xl flex flex-col h-[700px] max-h-[90vh] relative animate-in zoom-in-95",children:[(0,I.jsxs)("div",{className:"absolute top-4 right-4 z-10 flex gap-2",children:[(0,I.jsx)("button",{onClick:()=>window.open(r,"_blank"),className:"w-8 h-8 rounded-full bg-white/10 backdrop-blur-md flex items-center justify-center text-white/70 hover:text-white hover:bg-white/20 transition-colors",title:"Abrir en nueva pesta\xF1a",children:(0,I.jsx)("i",{className:"fas fa-external-link-alt text-xs"})}),(0,I.jsx)("button",{onClick:e,className:"w-8 h-8 rounded-full bg-white/10 backdrop-blur-md flex items-center justify-center text-white/70 hover:text-white hover:bg-white/20 transition-colors",title:"Cerrar vista previa",children:(0,I.jsx)("i",{className:"fas fa-times text-xs"})})]}),(0,I.jsx)("div",{className:"h-7 w-full bg-black flex justify-center items-start shrink-0",children:(0,I.jsx)("div",{className:"w-[120px] h-5 bg-black rounded-b-xl"})}),(0,I.jsx)("div",{className:"px-4 py-2 bg-black/50 border-b border-white/5 flex items-center justify-center shrink-0",children:(0,I.jsxs)("div",{className:"bg-white/5 rounded-lg px-3 py-1 flex items-center gap-2 text-[10px] text-white/40 w-fit",children:[(0,I.jsx)("i",{className:"fas fa-lock text-[8px]"}),(0,I.jsxs)("span",{children:["decido.com/track/",t]})]})}),(0,I.jsxs)("div",{className:"flex-1 relative bg-black",children:[n&&(0,I.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-[#0E1525] text-white/50",children:[(0,I.jsx)("i",{className:"fas fa-circle-notch fa-spin text-2xl text-emerald-500 mb-3"}),(0,I.jsx)("span",{className:"text-xs font-medium",children:"Cargando vista m\xF3vil..."})]}),(0,I.jsx)("iframe",{src:r,className:`w-full h-full border-none transition-opacity duration-300 ${n?"opacity-0":"opacity-100"}`,onLoad:()=>o(!1),title:"Tracking Portal Preview"})]}),(0,I.jsx)("div",{className:"h-6 w-full bg-black flex justify-center items-center shrink-0",children:(0,I.jsx)("div",{className:"w-[120px] h-1 bg-white/20 rounded-full"})})]})})},Z7={messageNode:f4,botAction:p4},Q7=[{id:"trigger",type:"messageNode",position:{x:50,y:300},data:{label:"Mensaje Entrante de WhatsApp",type:"incoming",text:"Hola, \xBFc\xF3mo va mi pedido XJ-901?",time:"10:05 AM"}},{id:"ai-intent",type:"botAction",position:{x:400,y:280},data:{label:"Reconocimiento Intenci\xF3n IA",actionType:"analyze",description:'Detectar Intenci\xF3n: "Estado de Pedido"'}},{id:"db-check",type:"botAction",position:{x:750,y:150},data:{label:"Acci\xF3n Ejecutada",actionType:"decision",description:"Action: GENERATE_TRACKING_LINK"}},{id:"escalate-human",type:"botAction",position:{x:750,y:400},data:{label:"Evaluar Sentimiento (Frustrado)",actionType:"escalate",description:"Ruteo Inmediato a Humano"}},{id:"reply-status",type:"messageNode",position:{x:1050,y:150},data:{label:"Regla: SEND_WA_TEMPLATE",type:"outgoing",text:`Template: pedido_produccion
|
|
462
|
+
Par\xE1metros: [legacyId, trackUrl]`,time:"10:06 AM"}},{id:"assign-agent",type:"messageNode",position:{x:1050,y:400},data:{label:"Soporte Asignado",type:"system",text:"Asignando Chat #3421 (Humano en la ruta)"}}],eU=[{id:"e1",source:"trigger",target:"ai-intent",animated:!0,style:{stroke:"#22c55e"},markerEnd:{type:pn.ArrowClosed,color:"#22c55e"}},{id:"e2",source:"ai-intent",target:"db-check",label:"Intent: Query Order",animated:!0,style:{stroke:"#3b82f6"},markerEnd:{type:pn.ArrowClosed,color:"#3b82f6"}},{id:"e3",source:"db-check",target:"reply-status",label:"Pedido Encontrado",style:{stroke:"#22c55e"},markerEnd:{type:pn.ArrowClosed,color:"#22c55e"}},{id:"e4",source:"ai-intent",target:"escalate-human",label:"Intent: Queja/Reclamo",style:{stroke:"#ef4444"},markerEnd:{type:pn.ArrowClosed,color:"#ef4444"}},{id:"e5",source:"db-check",sourceHandle:"no",target:"escalate-human",label:"Pedido No Encontrado",style:{stroke:"#ef4444",strokeDasharray:"5 5"},markerEnd:{type:pn.ArrowClosed,color:"#ef4444"}},{id:"e6",source:"escalate-human",target:"assign-agent",style:{stroke:"#f59e0b"},markerEnd:{type:pn.ArrowClosed,color:"#f59e0b"}}],tU=()=>{let[t,e]=(0,ye.useState)(Q7),[r,n]=(0,ye.useState)(eU),[o,s]=(0,ye.useState)(!1),i=(0,ye.useCallback)(d=>{},[]),a=(0,ye.useCallback)(d=>{},[]),l=(0,ye.useCallback)(d=>{n(u=>[...u,{...d,id:`e-${Date.now()}`,animated:!0}])},[n]),c=(0,ye.useCallback)((d,u)=>{(u.data?.description?.includes("GENERATE_TRACKING_LINK")||u.data?.text?.includes("trackUrl"))&&s(!0)},[]);return(0,I.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[(0,I.jsxs)("div",{className:"h-9 shrink-0 flex items-center gap-2 px-3 border-b",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)"},children:[(0,I.jsxs)("span",{className:"text-[10px] font-black uppercase tracking-widest",style:{color:"var(--text-secondary)"},children:[(0,I.jsx)("i",{className:"fas fa-project-diagram mr-1.5"}),"Flujo de Conversaci\xF3n"]}),(0,I.jsx)("div",{className:"flex-1"}),(0,I.jsx)("div",{className:"flex items-center gap-1",children:[{icon:"fas fa-comment-dots",label:"Mensaje",color:"#25D366"},{icon:"fas fa-brain",label:"IA",color:"#8b5cf6"},{icon:"fas fa-code-branch",label:"Decisi\xF3n",color:"#06b6d4"},{icon:"fas fa-cart-plus",label:"Pedido",color:"#f59e0b"}].map(d=>(0,I.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 rounded-md text-[9px] font-bold cursor-grab transition-all",style:{border:"1px dashed var(--border-color)",color:d.color},title:`Arrastra para agregar: ${d.label}`,children:[(0,I.jsx)("i",{className:d.icon}),(0,I.jsx)("span",{children:d.label})]},d.label))}),(0,I.jsx)("div",{className:"h-5 w-px mx-1",style:{background:"var(--border-color)"}}),(0,I.jsx)("button",{className:"px-2 py-1 rounded-md text-[9px] font-bold transition-all",style:{color:"var(--text-secondary)"},title:"Fit view",children:(0,I.jsx)("i",{className:"fas fa-compress-arrows-alt"})})]}),(0,I.jsx)("div",{className:"flex-1 min-h-0 relative",children:(0,I.jsx)(n4,{nodes:t,edges:r,onNodesChange:i,onEdgesChange:a,onConnect:l,onNodeClick:c,nodeTypes:Z7})}),o&&(0,I.jsx)(J7,{onClose:()=>s(!1)})]})},rU=[{hour:"6AM",sent:2,received:5},{hour:"7AM",sent:8,received:12},{hour:"8AM",sent:15,received:22},{hour:"9AM",sent:28,received:35},{hour:"10AM",sent:42,received:48},{hour:"11AM",sent:38,received:41},{hour:"12PM",sent:20,received:25},{hour:"1PM",sent:15,received:18},{hour:"2PM",sent:30,received:33},{hour:"3PM",sent:45,received:52},{hour:"4PM",sent:35,received:40},{hour:"5PM",sent:22,received:28},{hour:"6PM",sent:10,received:15}],nU=[{label:"Mensajes Hoy",value:"347",change:"+12%",icon:"fas fa-paper-plane",color:"#22c55e",positive:!0},{label:"Tiempo Respuesta",value:"2.4s",change:"-18%",icon:"fas fa-clock",color:"#3b82f6",positive:!0},{label:"Tasa Conversi\xF3n",value:"24.5%",change:"+3.2%",icon:"fas fa-funnel-dollar",color:"#f59e0b",positive:!0},{label:"Chats Activos",value:"12",change:"+2",icon:"fas fa-comments",color:"#8b5cf6",positive:!0},{label:"Pedidos v\xEDa WA",value:"8",change:"+1",icon:"fas fa-cart-plus",color:"#06b6d4",positive:!0},{label:"Escalamientos",value:"3",change:"+1",icon:"fas fa-exclamation-triangle",color:"#ef4444",positive:!1}],u4=[{intent:"Estado de Pedido",count:156,pct:45},{intent:"Cotizaci\xF3n",count:89,pct:26},{intent:"Cat\xE1logo",count:52,pct:15},{intent:"Reclamo",count:28,pct:8},{intent:"Otro",count:22,pct:6}],oU=["#22c55e","#3b82f6","#f59e0b","#ef4444","#6b7280"],sU=({data:t})=>{let e=Math.max(...t.map(r=>Math.max(r.sent,r.received)));return(0,I.jsx)("div",{className:"flex items-end gap-1 h-32",children:t.map((r,n)=>(0,I.jsxs)("div",{className:"flex-1 flex flex-col items-center gap-0.5",children:[(0,I.jsxs)("div",{className:"w-full flex items-end gap-px",style:{height:"100px"},children:[(0,I.jsx)("div",{className:"flex-1 rounded-t-sm transition-all duration-500",style:{height:`${r.received/e*100}%`,background:"rgba(37,211,102,0.6)"},title:`Recibidos: ${r.received}`}),(0,I.jsx)("div",{className:"flex-1 rounded-t-sm transition-all duration-500",style:{height:`${r.sent/e*100}%`,background:"rgba(59,130,246,0.6)"},title:`Enviados: ${r.sent}`})]}),(0,I.jsx)("span",{className:"text-[7px] font-bold",style:{color:"var(--text-secondary)"},children:r.hour})]},n))})},iU=()=>{let[t,e]=(0,ye.useState)({});return(0,ye.useEffect)(()=>{let r=setTimeout(()=>{let n={};u4.forEach(o=>{n[o.intent]=o.pct}),e(n)},200);return()=>clearTimeout(r)},[]),(0,I.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scrollbar-thin",style:{background:"var(--bg-primary)"},children:[(0,I.jsx)("div",{className:"grid grid-cols-3 gap-3",children:nU.map((r,n)=>(0,I.jsxs)("div",{className:"p-3 rounded-xl border transition-all hover:shadow-lg",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)",animationDelay:`${n*80}ms`},children:[(0,I.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,I.jsx)("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:`${r.color}15`},children:(0,I.jsx)("i",{className:`${r.icon} text-xs`,style:{color:r.color}})}),(0,I.jsx)("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded ${r.positive?"text-green-500":"text-red-500"}`,style:{background:r.positive?"rgba(34,197,94,0.1)":"rgba(239,68,68,0.1)"},children:r.change})]}),(0,I.jsx)("div",{className:"text-xl font-black",style:{color:"var(--text-primary)"},children:r.value}),(0,I.jsx)("div",{className:"text-[10px] font-medium mt-0.5",style:{color:"var(--text-secondary)"},children:r.label})]},r.label))}),(0,I.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,I.jsxs)("div",{className:"p-4 rounded-xl border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)"},children:[(0,I.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,I.jsxs)("h3",{className:"text-xs font-bold",style:{color:"var(--text-primary)"},children:[(0,I.jsx)("i",{className:"fas fa-chart-bar mr-2",style:{color:"var(--brand-primary)"}}),"Actividad por Hora"]}),(0,I.jsxs)("div",{className:"flex items-center gap-3 text-[9px]",children:[(0,I.jsxs)("span",{className:"flex items-center gap-1",children:[(0,I.jsx)("span",{className:"w-2 h-2 rounded-sm",style:{background:"rgba(37,211,102,0.6)"}}),(0,I.jsx)("span",{style:{color:"var(--text-secondary)"},children:"Recibidos"})]}),(0,I.jsxs)("span",{className:"flex items-center gap-1",children:[(0,I.jsx)("span",{className:"w-2 h-2 rounded-sm",style:{background:"rgba(59,130,246,0.6)"}}),(0,I.jsx)("span",{style:{color:"var(--text-secondary)"},children:"Enviados"})]})]})]}),(0,I.jsx)(sU,{data:rU})]}),(0,I.jsxs)("div",{className:"p-4 rounded-xl border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)"},children:[(0,I.jsxs)("h3",{className:"text-xs font-bold mb-4",style:{color:"var(--text-primary)"},children:[(0,I.jsx)("i",{className:"fas fa-brain mr-2",style:{color:"var(--brand-primary)"}}),"Intenciones Detectadas"]}),(0,I.jsx)("div",{className:"space-y-3",children:u4.map((r,n)=>(0,I.jsxs)("div",{children:[(0,I.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,I.jsx)("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:r.intent}),(0,I.jsxs)("span",{className:"text-[10px] font-bold",style:{color:"var(--text-secondary)"},children:[r.count," (",r.pct,"%)"]})]}),(0,I.jsx)("div",{className:"h-2 rounded-full overflow-hidden",style:{background:"var(--bg-muted)"},children:(0,I.jsx)("div",{className:"h-full rounded-full transition-all duration-1000 ease-out",style:{width:`${t[r.intent]||0}%`,background:oU[n]}})})]},r.intent))})]})]}),(0,I.jsxs)("div",{className:"p-4 rounded-xl border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)"},children:[(0,I.jsxs)("h3",{className:"text-xs font-bold mb-4",style:{color:"var(--text-primary)"},children:[(0,I.jsx)("i",{className:"fas fa-fire-alt mr-2",style:{color:"var(--brand-primary)"}}),"Heatmap Semanal"]}),(0,I.jsxs)("div",{className:"grid gap-1",style:{gridTemplateColumns:"auto repeat(24, 1fr)"},children:[(0,I.jsx)("div",{}),Array.from({length:24},(r,n)=>(0,I.jsx)("div",{className:"text-[7px] text-center font-bold",style:{color:"var(--text-secondary)"},children:n},n)),["Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b","Dom"].map((r,n)=>(0,I.jsxs)(ye.default.Fragment,{children:[(0,I.jsx)("div",{className:"text-[9px] font-bold pr-2 flex items-center",style:{color:"var(--text-secondary)"},children:r}),Array.from({length:24},(o,s)=>{let i=Math.random(),a=n>=5,l=s>=7&&s<=18,c=(a?.3:1)*(l?1:.4)*i;return(0,I.jsx)("div",{className:"aspect-square rounded-sm transition-all hover:ring-1 hover:ring-white/30 cursor-pointer",style:{background:c>.6?"#22c55e":c>.3?"rgba(34,197,94,0.4)":c>.1?"rgba(34,197,94,0.15)":"var(--bg-muted)"},title:`${r} ${s}:00 \u2014 ${Math.floor(c*50)} mensajes`},s)})]},r))]})]})]})},aU=()=>{let[t,e]=(0,ye.useState)(""),[r,n]=(0,ye.useState)("text"),[o,s]=(0,ye.useState)("Hola desde Decido OS \u{1F680}"),[i,a]=(0,ye.useState)("hello_world"),[l,c]=(0,ye.useState)("en_US"),[d,u]=(0,ye.useState)(!1),[f,p]=(0,ye.useState)(null),[h,b]=(0,ye.useState)([]),[g,x]=(0,ye.useState)(""),[y,m]=(0,ye.useState)(!1),[v,S]=(0,ye.useState)([]),[w,C]=(0,ye.useState)([]),[A,k]=(0,ye.useState)(!1);ye.default.useEffect(()=>{let N=localStorage.getItem("wa_api_tester_phones");if(N)try{b(JSON.parse(N))}catch{}M()},[]),ye.default.useEffect(()=>{let N=w.find(D=>D.name===i&&D.language===l);if(N){let D=N.components?.find(R=>R.type==="BODY"||R.type==="body");if(D&&D.text){let R=D.text.match(/\{\{\d+\}\}/g);if(R){let O=Math.max(...R.map(B=>parseInt(B.replace(/\{|\}/g,""))));S(B=>{let L=[...B];for(;L.length<O;)L.push("");return L.slice(0,O)});return}}}S([])},[i,l,w]);let M=async()=>{k(!0);try{let N=Cc.env?.VITE_API_BASE_URL||"http://localhost:3001",D=await fetch(`${N}/api/whatsapp/templates`);if(D.ok){let R=await D.json();!R.error&&Array.isArray(R)&&(C(R),R.length>0&&(a(R[0].name),c(R[0].language)))}}catch(N){console.error("Failed to fetch templates",N)}finally{k(!1)}},T=()=>{if(!t||!g)return;let N=[...h,{name:g,number:t}];b(N),localStorage.setItem("wa_api_tester_phones",JSON.stringify(N)),x(""),m(!1)},E=N=>{let D=h.filter(R=>R.number!==N);b(D),localStorage.setItem("wa_api_tester_phones",JSON.stringify(D)),t===N&&e("")},P=async()=>{if(!t){p({error:"Ingresa un n\xFAmero de tel\xE9fono v\xE1lido (ej. 52155...)"});return}u(!0),p(null);try{let N={};r==="text"?N.text=o:r==="template"?(N.templateName=i,N.language=l,N.components=[],v.length>0&&N.components.push({type:"body",parameters:v.map(O=>({type:"text",text:O||"n/a"}))})):r==="interactive"&&(N.bodyText=o,N.buttons=[{id:"opt_1",title:"S\xED, me interesa"},{id:"opt_2",title:"No, gracias"}]);let D=Cc.env?.VITE_API_BASE_URL||"http://localhost:3001",R=await(await fetch(`${D}/api/whatsapp/send-test`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({to:t,type:r,payload:N})})).json();p(R)}catch(N){p({error:N.message})}finally{u(!1)}};return(0,I.jsx)("div",{className:"flex-1 flex flex-col min-h-0 overflow-y-auto p-6",style:{background:"var(--bg-primary)",color:"var(--text-primary)"},children:(0,I.jsxs)("div",{className:"max-w-2xl mx-auto w-full space-y-6",children:[(0,I.jsxs)("div",{children:[(0,I.jsx)("h2",{className:"text-xl font-bold mb-1",children:"WhatsApp API Tester"}),(0,I.jsx)("p",{className:"text-sm",style:{color:"var(--text-secondary)"},children:"Prueba el env\xEDo de diferentes formatos soportados por Meta Cloud API directamente."})]}),(0,I.jsxs)("div",{className:"p-5 rounded-xl border space-y-4",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)"},children:[(0,I.jsxs)("div",{children:[(0,I.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,I.jsx)("label",{className:"block text-xs font-bold uppercase tracking-wider",style:{color:"var(--text-secondary)"},children:"Tel\xE9fono Destino (Sandbox)"}),t&&!h.find(N=>N.number===t)&&(0,I.jsx)("button",{onClick:()=>m(!y),className:"text-[10px] font-bold text-indigo-400 hover:text-indigo-300 transition-colors",children:"+ Guardar N\xFAmero"})]}),y&&(0,I.jsxs)("div",{className:"flex gap-2 mb-2 p-2 rounded-lg bg-indigo-500/10 border border-indigo-500/30",children:[(0,I.jsx)("input",{type:"text",placeholder:"Nombre (ej. Mi Celular)",className:"flex-1 px-3 py-1.5 text-xs rounded border outline-none bg-black/20 text-white border-transparent focus:border-indigo-500",value:g,onChange:N=>x(N.target.value)}),(0,I.jsx)("button",{onClick:T,className:"px-3 py-1.5 bg-indigo-500 text-white rounded text-xs font-bold hover:bg-indigo-600",children:"Guardar"}),(0,I.jsx)("button",{onClick:()=>m(!1),className:"px-3 py-1.5 bg-white/10 text-white rounded text-xs hover:bg-white/20",children:"Cancelar"})]}),(0,I.jsxs)("div",{className:"flex flex-col gap-2",children:[h.length>0&&(0,I.jsx)("div",{className:"flex flex-wrap gap-2 mb-1",children:h.map((N,D)=>(0,I.jsxs)("div",{className:`flex items-center gap-2 px-3 py-1.5 rounded-full border border-indigo-500/30 text-xs cursor-pointer transition-colors ${t===N.number?"bg-indigo-500 text-white":"bg-transparent text-indigo-300 hover:bg-indigo-500/10"}`,onClick:()=>e(N.number),children:[(0,I.jsx)("i",{className:"fas fa-user-circle"}),(0,I.jsx)("span",{className:"font-bold",children:N.name}),(0,I.jsx)("button",{onClick:R=>{R.stopPropagation(),E(N.number)},className:"w-4 h-4 rounded-full flex items-center justify-center hover:bg-red-500/50 hover:text-white text-indigo-300 transition-colors",children:(0,I.jsx)("i",{className:"fas fa-times text-[8px]"})})]},D))}),(0,I.jsx)("input",{type:"text",placeholder:"Ej. 52155... (Incluye c\xF3digo de pa\xEDs)",className:"w-full px-4 py-2 text-sm rounded-lg border outline-none transition-all focus:border-indigo-500 font-mono",style:{background:"var(--bg-primary)",borderColor:"var(--border-color)",color:"var(--text-primary)"},value:t,onChange:N=>e(N.target.value)}),(0,I.jsxs)("p",{className:"text-[10px] mt-1 text-amber-500/80",children:[(0,I.jsx)("i",{className:"fas fa-exclamation-triangle mr-1"}),"Aseg\xFArate de que este n\xFAmero est\xE9 registrado en Meta for Developers si tu app est\xE1 en modo desarrollo."]})]})]}),(0,I.jsxs)("div",{children:[(0,I.jsx)("label",{className:"block text-xs font-bold uppercase tracking-wider mb-2",style:{color:"var(--text-secondary)"},children:"Tipo de Mensaje"}),(0,I.jsx)("div",{className:"flex gap-2",children:["text","template","interactive"].map(N=>(0,I.jsx)("button",{onClick:()=>n(N),className:`px-4 py-2 text-sm font-medium rounded-lg transition-all capitalize border ${r===N?"border-indigo-500 bg-indigo-500/10 text-indigo-400":"hover:bg-white/5 opacity-70"}`,style:{borderColor:r===N?"":"var(--border-color)"},children:N},N))})]}),(0,I.jsxs)("div",{className:"pt-2",children:[r==="text"&&(0,I.jsxs)("div",{children:[(0,I.jsx)("label",{className:"block text-xs font-bold uppercase tracking-wider mb-2",style:{color:"var(--text-secondary)"},children:"Mensaje de Texto"}),(0,I.jsx)("textarea",{className:"w-full px-4 py-2 text-sm rounded-lg border outline-none min-h-[100px]",style:{background:"var(--bg-primary)",borderColor:"var(--border-color)",color:"var(--text-primary)"},value:o,onChange:N=>s(N.target.value)})]}),r==="template"&&(0,I.jsxs)("div",{children:[(0,I.jsx)("label",{className:"block text-xs font-bold uppercase tracking-wider mb-2",style:{color:"var(--text-secondary)"},children:"Seleccionar Template (Aprobado)"}),A?(0,I.jsx)("div",{className:"text-xs p-2 text-indigo-400",children:"Cargando plantillas de Meta..."}):w.length>0?(0,I.jsx)("select",{className:"w-full px-4 py-2 text-sm rounded-lg border outline-none font-mono",style:{background:"var(--bg-primary)",borderColor:"var(--border-color)",color:"var(--text-primary)"},value:`${i}::${l}`,onChange:N=>{let[D,R]=N.target.value.split("::");a(D),c(R)},children:w.filter(N=>N.status==="APPROVED").map(N=>(0,I.jsxs)("option",{value:`${N.name}::${N.language}`,children:[N.name," (",N.language,") [",N.category,"]"]},`${N.id||N.name}_${N.language}`))}):(0,I.jsx)("input",{type:"text",placeholder:"No se pudieron cargar, ingresa el nombre manual (ej. hello_world)",className:"w-full px-4 py-2 text-sm rounded-lg border outline-none",style:{background:"var(--bg-primary)",borderColor:"var(--border-color)",color:"var(--text-primary)"},value:i,onChange:N=>a(N.target.value)}),v.length>0&&(0,I.jsxs)("div",{className:"mt-4 p-3 rounded bg-black/20 border border-white/5 space-y-3",children:[(0,I.jsx)("label",{className:"block text-xs font-bold text-indigo-300",children:"Variables Requeridas (Cuerpo)"}),v.map((N,D)=>(0,I.jsxs)("div",{className:"flex items-center gap-2",children:[(0,I.jsx)("span",{className:"text-xs font-mono text-white/50 w-8",children:`{{${D+1}}}`}),(0,I.jsx)("input",{type:"text",placeholder:"Valor para la variable (opcional)",className:"flex-1 px-3 py-1.5 text-xs rounded border outline-none bg-black/40 text-white border-transparent focus:border-indigo-500",value:N,onChange:R=>{let O=[...v];O[D]=R.target.value,S(O)}})]},D))]}),(0,I.jsx)("p",{className:"text-[10px] mt-2",style:{color:"var(--text-secondary)"},children:"Si la plantilla usa variables din\xE1micas en encabezados o links, la API intentar\xE1 autocompletarlos si no se incluyen aqu\xED."})]}),r==="interactive"&&(0,I.jsxs)("div",{children:[(0,I.jsx)("label",{className:"block text-xs font-bold uppercase tracking-wider mb-2",style:{color:"var(--text-secondary)"},children:"Texto Principal (Con Botones)"}),(0,I.jsx)("textarea",{className:"w-full px-4 py-2 text-sm rounded-lg border outline-none min-h-[80px]",style:{background:"var(--bg-primary)",borderColor:"var(--border-color)",color:"var(--text-primary)"},value:o,onChange:N=>s(N.target.value)}),(0,I.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,I.jsx)("div",{className:"px-3 py-1.5 rounded bg-indigo-500/20 text-indigo-400 text-xs font-bold border border-indigo-500/30",children:"Bot\xF3n: S\xED, me interesa"}),(0,I.jsx)("div",{className:"px-3 py-1.5 rounded bg-indigo-500/20 text-indigo-400 text-xs font-bold border border-indigo-500/30",children:"Bot\xF3n: No, gracias"})]})]})]}),(0,I.jsx)("div",{className:"pt-4 border-t flex justify-end",style:{borderColor:"var(--border-color)"},children:(0,I.jsxs)("button",{onClick:P,disabled:d,className:`px-6 py-2 rounded-lg font-bold text-sm text-white flex items-center gap-2 ${d?"opacity-50 cursor-not-allowed":"hover:bg-indigo-600"} bg-indigo-500 transition-colors`,children:[d?(0,I.jsx)("i",{className:"fas fa-spinner fa-spin"}):(0,I.jsx)("i",{className:"fab fa-whatsapp"}),d?"Enviando...":"Enviar Prueba"]})})]}),f&&(0,I.jsxs)("div",{className:`p-4 rounded-xl border ${f.error||!f.success?"bg-red-500/10 border-red-500/30":"bg-green-500/10 border-green-500/30"}`,children:[(0,I.jsx)("h3",{className:`text-sm font-bold mb-2 ${f.error||!f.success?"text-red-400":"text-green-400"}`,children:f.error||!f.success?"Error en el env\xEDo":"\xA1Mensaje enviado con \xE9xito!"}),(0,I.jsx)("pre",{className:"text-[10px] overflow-x-auto p-3 rounded bg-black/50 text-slate-300",children:JSON.stringify(f,null,2)})]})]})})},lU=()=>{let[t,e]=(0,ye.useState)([]),[r,n]=(0,ye.useState)(!0),[o,s]=(0,ye.useState)(null),[i,a]=(0,ye.useState)(!1),[l,c]=(0,ye.useState)(""),[d,u]=(0,ye.useState)("UTILITY"),[f,p]=(0,ye.useState)("es"),[h,b]=(0,ye.useState)(""),[g,x]=(0,ye.useState)("Hola {{1}}, tu pedido est\xE1 listo."),[y,m]=(0,ye.useState)(""),[v,S]=(0,ye.useState)([]);(0,ye.useEffect)(()=>{w()},[]);let w=async()=>{n(!0),s(null);try{let k=Cc.env?.VITE_API_BASE_URL||"http://localhost:3001",M=await fetch(`${k}/api/whatsapp/templates`);if(!M.ok)throw new Error(`HTTP ${M.status}`);let T=await M.json();if(T.error)throw new Error(T.error);e(T||[])}catch(k){s(k.message)}finally{n(!1)}},C=async()=>{if(!l||!g){s("Por favor completa el nombre y el texto.");return}n(!0);try{let k=Cc.env?.VITE_API_BASE_URL||"http://localhost:3001",M=[];h.trim()&&M.push({type:"HEADER",format:"TEXT",text:h});let T=g.match(/\{\{\d+\}\}/g),E;T&&T.length>0&&(E={body_text:[T.map((R,O)=>`Variable${O+1}`)]}),M.push({type:"BODY",text:g,...E?{example:E}:{}}),y.trim()&&M.push({type:"FOOTER",text:y}),v.length>0&&M.push({type:"BUTTONS",buttons:v.map(R=>R.type==="URL"?{type:"URL",text:R.text,url:R.url}:{type:"QUICK_REPLY",text:R.text})});let P={name:l.toLowerCase().replace(/[^a-z0-9_]/g,"_"),language:f,category:d,components:M},N=await fetch(`${k}/api/whatsapp/templates`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)}),D=await N.json();if(!N.ok||D.error)throw new Error(D.error||"Error al crear la plantilla");a(!1),c(""),b(""),m(""),S([]),x("Hola {{1}}, tu pedido est\xE1 listo."),await w()}catch(k){s(k.message),n(!1)}},A=async k=>{if(window.confirm(`\xBFSeguro que deseas eliminar la plantilla '${k}' permanentemente de Meta?`)){n(!0);try{let M=Cc.env?.VITE_API_BASE_URL||"http://localhost:3001",T=await fetch(`${M}/api/whatsapp/templates/${k}`,{method:"DELETE"}),E=await T.json();if(!T.ok||E.error)throw new Error(E.error||"Error al eliminar");await w()}catch(M){s(M.message),n(!1)}}};return(0,I.jsx)("div",{className:"flex-1 flex flex-col min-h-0 overflow-y-auto p-6",style:{background:"var(--bg-primary)",color:"var(--text-primary)"},children:(0,I.jsxs)("div",{className:"max-w-4xl mx-auto w-full space-y-6",children:[(0,I.jsxs)("div",{className:"flex items-center justify-between",children:[(0,I.jsxs)("div",{children:[(0,I.jsx)("h2",{className:"text-xl font-bold mb-1",children:"Gestor de Plantillas (Meta)"}),(0,I.jsx)("p",{className:"text-sm",style:{color:"var(--text-secondary)"},children:"Crea y administra tus plantillas oficiales de WhatsApp sin salir de Decido OS."})]}),(0,I.jsx)("button",{onClick:()=>a(!i),className:"px-4 py-2 bg-indigo-500 hover:bg-indigo-600 text-white text-sm font-bold rounded-lg transition-colors",children:i?"Ver Lista":"+ Nueva Plantilla"})]}),o&&(0,I.jsxs)("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/30 text-red-400 text-sm font-medium",children:[(0,I.jsx)("i",{className:"fas fa-exclamation-triangle mr-2"})," ",o]}),i?(0,I.jsxs)("div",{className:"p-6 rounded-xl border space-y-4",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)"},children:[(0,I.jsx)("h3",{className:"font-bold text-lg border-b pb-2 mb-4",style:{borderColor:"var(--border-color)"},children:"Crear Nueva Plantilla"}),(0,I.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,I.jsxs)("div",{children:[(0,I.jsx)("label",{className:"block text-xs font-bold uppercase tracking-wider mb-2",style:{color:"var(--text-secondary)"},children:"Nombre de la Plantilla"}),(0,I.jsx)("input",{type:"text",placeholder:"ej. welcome_message_01",className:"w-full px-4 py-2 text-sm rounded-lg border outline-none font-mono",style:{background:"var(--bg-primary)",borderColor:"var(--border-color)",color:"var(--text-primary)"},value:l,onChange:k=>c(k.target.value.toLowerCase().replace(/[^a-z0-9_]/g,"_"))}),(0,I.jsx)("p",{className:"text-[10px] mt-1",style:{color:"var(--text-secondary)"},children:"Solo min\xFAsculas y guiones bajos (_)"})]}),(0,I.jsxs)("div",{children:[(0,I.jsx)("label",{className:"block text-xs font-bold uppercase tracking-wider mb-2",style:{color:"var(--text-secondary)"},children:"Categor\xEDa"}),(0,I.jsxs)("select",{className:"w-full px-4 py-2 text-sm rounded-lg border outline-none",style:{background:"var(--bg-primary)",borderColor:"var(--border-color)",color:"var(--text-primary)"},value:d,onChange:k=>u(k.target.value),children:[(0,I.jsx)("option",{value:"UTILITY",children:"Utilidad (Avisos, tracking, alertas)"}),(0,I.jsx)("option",{value:"MARKETING",children:"Marketing (Promociones, ventas)"}),(0,I.jsx)("option",{value:"AUTHENTICATION",children:"Autenticaci\xF3n (OTPs)"})]})]})]}),(0,I.jsxs)("div",{children:[(0,I.jsx)("label",{className:"block text-xs font-bold uppercase tracking-wider mb-2",style:{color:"var(--text-secondary)"},children:"Idioma (Locale)"}),(0,I.jsxs)("select",{className:"w-full px-4 py-2 text-sm rounded-lg border outline-none max-w-xs",style:{background:"var(--bg-primary)",borderColor:"var(--border-color)",color:"var(--text-primary)"},value:f,onChange:k=>p(k.target.value),children:[(0,I.jsx)("option",{value:"es",children:"Espa\xF1ol (es)"}),(0,I.jsx)("option",{value:"es_LA",children:"Espa\xF1ol Latino (es_LA)"}),(0,I.jsx)("option",{value:"en_US",children:"Ingl\xE9s (en_US)"})]})]}),(0,I.jsxs)("div",{className:"pt-4 border-t space-y-4",style:{borderColor:"var(--border-color)"},children:[(0,I.jsx)("h4",{className:"text-xs font-bold uppercase tracking-wider",style:{color:"var(--text-secondary)"},children:"Estructura del Mensaje"}),(0,I.jsxs)("div",{children:[(0,I.jsx)("label",{className:"block text-xs font-bold mb-2",children:"Encabezado (Opcional)"}),(0,I.jsx)("input",{type:"text",placeholder:"Ej. \xA1Alerta de Promoci\xF3n!",className:"w-full px-4 py-2 text-sm rounded-lg border outline-none",style:{background:"var(--bg-primary)",borderColor:"var(--border-color)",color:"var(--text-primary)"},value:h,onChange:k=>b(k.target.value)})]}),(0,I.jsxs)("div",{children:[(0,I.jsx)("label",{className:"block text-xs font-bold mb-2",children:"Cuerpo (Obligatorio)"}),(0,I.jsx)("textarea",{className:"w-full px-4 py-2 text-sm rounded-lg border outline-none min-h-[100px]",style:{background:"var(--bg-primary)",borderColor:"var(--border-color)",color:"var(--text-primary)"},value:g,onChange:k=>x(k.target.value)}),(0,I.jsxs)("p",{className:"text-[10px] mt-1",style:{color:"var(--text-secondary)"},children:["Usa ","{{","1","}}",", ","{{","2","}}"," para variables que se llenar\xE1n din\xE1micamente."]})]}),(0,I.jsxs)("div",{children:[(0,I.jsx)("label",{className:"block text-xs font-bold mb-2",children:"Pie de p\xE1gina (Opcional)"}),(0,I.jsx)("input",{type:"text",placeholder:"Ej. Responde STOP para cancelar",className:"w-full px-4 py-2 text-sm rounded-lg border outline-none",style:{background:"var(--bg-primary)",borderColor:"var(--border-color)",color:"var(--text-primary)"},value:y,onChange:k=>m(k.target.value)})]}),(0,I.jsxs)("div",{children:[(0,I.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,I.jsx)("label",{className:"block text-xs font-bold",children:"Botones (M\xE1x 3)"}),(0,I.jsxs)("div",{className:"flex gap-2",children:[(0,I.jsx)("button",{onClick:()=>{v.length<3&&S([...v,{type:"QUICK_REPLY",text:"Nuevo Bot\xF3n"}])},className:"px-2 py-1 text-[10px] bg-white/10 hover:bg-white/20 rounded font-bold transition-colors",disabled:v.length>=3,children:"+ Respuesta R\xE1pida"}),(0,I.jsx)("button",{onClick:()=>{v.length<3&&S([...v,{type:"URL",text:"Saber M\xE1s",url:"https://"}])},className:"px-2 py-1 text-[10px] bg-white/10 hover:bg-white/20 rounded font-bold transition-colors",disabled:v.length>=3,children:"+ Enlace Web (URL)"})]})]}),v.length>0&&(0,I.jsx)("div",{className:"space-y-2",children:v.map((k,M)=>(0,I.jsxs)("div",{className:"flex gap-2 items-start bg-black/20 p-2 rounded-lg border",style:{borderColor:"var(--border-color)"},children:[(0,I.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,I.jsxs)("div",{className:"flex items-center gap-2",children:[(0,I.jsx)("span",{className:"text-[10px] font-bold px-2 py-1 bg-white/10 rounded",children:k.type==="URL"?"\u{1F310} URL":"\u21AA\uFE0F RESPUESTA"}),(0,I.jsx)("input",{type:"text",placeholder:"Texto del bot\xF3n (ej. Comprar)",className:"flex-1 px-3 py-1.5 text-xs rounded border outline-none",style:{background:"var(--bg-primary)",borderColor:"var(--border-color)",color:"var(--text-primary)"},value:k.text,onChange:T=>{let E=[...v];E[M].text=T.target.value,S(E)}})]}),k.type==="URL"&&(0,I.jsx)("input",{type:"text",placeholder:"https://tulink.com",className:"w-full px-3 py-1.5 text-xs rounded border outline-none",style:{background:"var(--bg-primary)",borderColor:"var(--border-color)",color:"var(--text-primary)"},value:k.url||"",onChange:T=>{let E=[...v];E[M].url=T.target.value,S(E)}})]}),(0,I.jsx)("button",{onClick:()=>S(v.filter((T,E)=>E!==M)),className:"w-8 h-8 flex items-center justify-center text-red-400 hover:bg-red-500/20 rounded",children:(0,I.jsx)("i",{className:"fas fa-times"})})]},M))})]})]}),(0,I.jsx)("div",{className:"pt-4 border-t flex justify-end",style:{borderColor:"var(--border-color)"},children:(0,I.jsxs)("button",{onClick:C,disabled:r||!l||!g,className:`px-6 py-2 rounded-lg font-bold text-sm text-white flex items-center gap-2 ${r?"opacity-50 cursor-not-allowed":"hover:bg-green-600"} bg-green-500 transition-colors`,children:[r?(0,I.jsx)("i",{className:"fas fa-spinner fa-spin"}):(0,I.jsx)("i",{className:"fas fa-paper-plane"}),"Enviar a Meta para Aprobaci\xF3n"]})})]}):(0,I.jsxs)("div",{className:"rounded-xl border overflow-hidden",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)"},children:[(0,I.jsxs)("div",{className:"flex bg-black/20 p-4 border-b text-xs font-bold uppercase tracking-wider",style:{borderColor:"var(--border-color)",color:"var(--text-secondary)"},children:[(0,I.jsx)("div",{className:"flex-[2]",children:"Nombre"}),(0,I.jsx)("div",{className:"flex-1",children:"Categor\xEDa"}),(0,I.jsx)("div",{className:"flex-1",children:"Idioma"}),(0,I.jsx)("div",{className:"flex-1",children:"Estado"}),(0,I.jsx)("div",{className:"flex-1 text-right",children:"Acci\xF3n"})]}),r?(0,I.jsxs)("div",{className:"p-8 text-center text-sm",style:{color:"var(--text-secondary)"},children:[(0,I.jsx)("i",{className:"fas fa-spinner fa-spin mr-2"})," Cargando plantillas desde Meta..."]}):t.length===0?(0,I.jsx)("div",{className:"p-8 text-center text-sm",style:{color:"var(--text-secondary)"},children:"No hay plantillas creadas en esta WABA (WhatsApp Business Account)."}):(0,I.jsx)("div",{className:"divide-y",style:{borderColor:"var(--border-color)"},children:t.map(k=>(0,I.jsxs)("div",{className:"flex items-center p-4 hover:bg-white/5 transition-colors text-sm",children:[(0,I.jsx)("div",{className:"flex-[2] font-mono font-bold",children:k.name}),(0,I.jsx)("div",{className:"flex-1 text-[11px] font-bold",children:(0,I.jsx)("span",{className:"px-2 py-1 rounded-md bg-white/5",children:k.category})}),(0,I.jsx)("div",{className:"flex-1",children:k.language}),(0,I.jsxs)("div",{className:"flex-1 flex items-center gap-2",children:[k.status==="APPROVED"&&(0,I.jsx)("span",{className:"w-2 h-2 rounded-full bg-green-500"}),k.status==="PENDING"&&(0,I.jsx)("span",{className:"w-2 h-2 rounded-full bg-amber-500"}),k.status==="REJECTED"&&(0,I.jsx)("span",{className:"w-2 h-2 rounded-full bg-red-500"}),(0,I.jsx)("span",{className:"text-xs font-bold",children:k.status})]}),(0,I.jsx)("div",{className:"flex-1 text-right",children:(0,I.jsx)("button",{onClick:()=>A(k.name),className:"w-8 h-8 rounded-full hover:bg-red-500/20 text-red-400 transition-colors",title:"Eliminar Plantilla",children:(0,I.jsx)("i",{className:"fas fa-trash"})})})]},k.id))})]})]})})},cU=[{icon:"fas fa-comment-dots",color:"text-indigo-400",bg:"bg-indigo-500/10",text:"Saluda al cliente cuando se cree un pedido"},{icon:"fas fa-camera",color:"text-amber-400",bg:"bg-amber-500/10",text:"Detecta pagos en fotos de comprobante"},{icon:"fas fa-industry",color:"text-emerald-400",bg:"bg-emerald-500/10",text:"Avisa por WhatsApp al pasar a Producci\xF3n"},{icon:"fas fa-truck",color:"text-cyan-400",bg:"bg-cyan-500/10",text:"Pedido listo: avisa si >$1M"}],dU=()=>{let[t,e]=(0,ye.useState)(""),[r,n]=(0,ye.useState)(!1),[o,s]=(0,ye.useState)(null),[i,a]=(0,ye.useState)(null),l=async c=>{let d=c||t;if(d.trim()){n(!0),a(null),s(null);try{let u=await fetch("http://localhost:3001/api/whatsapp/rules/generate",{method:"POST",headers:{"Content-Type":"application/json","x-tenant-id":"dev-tenant"},body:JSON.stringify({prompt:d})});if(!u.ok)throw new Error("Error al generar regla IA");let f=await u.json();s(JSON.stringify(f.rule||f,null,2))}catch(u){a(u.message||"Error de conexi\xF3n con el AI Service")}finally{n(!1)}}};return(0,I.jsx)("div",{className:"flex-1 h-full flex flex-col items-center justify-center p-8 bg-black/20 overflow-y-auto",children:(0,I.jsxs)("div",{className:"w-full max-w-3xl",children:[(0,I.jsxs)("div",{className:"text-center mb-10 text-white",children:[(0,I.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-indigo-500/20 text-indigo-400 mb-6 border border-indigo-500/30 shadow-[0_0_30px_rgba(99,102,241,0.2)]",children:(0,I.jsx)("i",{className:"fas fa-wand-magic-sparkles text-2xl"})}),(0,I.jsx)("h2",{className:"text-3xl font-black tracking-tight mb-3",children:"Workflow Architect"}),(0,I.jsx)("p",{className:"text-zinc-400 max-w-lg mx-auto leading-relaxed",children:"Escribe una instrucci\xF3n en lenguaje natural y Sentinal AI generar\xE1 la regla JSON requerida para la automatizaci\xF3n de WhatsApp."})]}),(0,I.jsx)("div",{className:"grid grid-cols-2 gap-3 mb-8",children:cU.map((c,d)=>(0,I.jsxs)("button",{onClick:()=>{e(c.text),l(c.text)},className:"flex items-center gap-3 p-4 text-left rounded-xl transition-all border border-white/5 bg-zinc-900/50 hover:bg-zinc-800/80 hover:border-white/10 group",children:[(0,I.jsx)("div",{className:`w-8 h-8 shrink-0 flex items-center justify-center rounded-lg ${c.bg} ${c.color}`,children:(0,I.jsx)("i",{className:c.icon})}),(0,I.jsx)("span",{className:"text-sm font-medium text-zinc-300 group-hover:text-white leading-tight",children:c.text})]},d))}),(0,I.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,I.jsxs)("div",{className:"relative group",children:[(0,I.jsx)("div",{className:"absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none",children:(0,I.jsx)("i",{className:"fas fa-terminal text-zinc-500"})}),(0,I.jsx)("input",{type:"text",value:t,onChange:c=>e(c.target.value),onKeyDown:c=>c.key==="Enter"&&l(),placeholder:"Ej: Cuando un pedido pase de Producci\xF3n a Dispatch, env\xEDa una plantilla...",className:"block w-full pl-11 pr-32 py-4 bg-zinc-950/80 border-2 border-zinc-800 rounded-xl text-sm outline-none text-zinc-200 placeholder-zinc-600 focus:border-indigo-500/50 focus:bg-zinc-950 transition-all shadow-inner"}),(0,I.jsx)("button",{onClick:()=>l(),disabled:r||!t.trim(),className:"absolute right-2 top-2 bottom-2 px-6 bg-indigo-600 hover:bg-indigo-500 disabled:bg-zinc-800 disabled:text-zinc-600 text-white font-bold rounded-lg text-sm transition-all shadow-lg active:scale-95 flex items-center gap-2",children:r?(0,I.jsx)("i",{className:"fas fa-circle-notch fa-spin"}):"Generar"})]}),i&&(0,I.jsxs)("div",{className:"p-4 rounded-xl bg-rose-500/10 border border-rose-500/20 text-rose-400 text-sm flex items-start gap-3 animate-in fade-in slide-in-from-top-2",children:[(0,I.jsx)("i",{className:"fas fa-exclamation-circle mt-0.5"}),(0,I.jsx)("div",{children:i})]}),o&&(0,I.jsxs)("div",{className:"rounded-xl overflow-hidden border border-zinc-800 bg-[#0d1117] relative animate-in zoom-in-95 fade-in duration-300 shadow-2xl",children:[(0,I.jsxs)("div",{className:"px-4 py-2 border-b border-zinc-800 bg-[#161b22] flex items-center gap-2",children:[(0,I.jsx)("i",{className:"fab fa-js text-yellow-400/80 text-xs"}),(0,I.jsx)("span",{className:"text-xs font-mono text-zinc-400",children:"generated_rule.json"}),(0,I.jsx)("div",{className:"flex-1"}),(0,I.jsx)("span",{className:"text-[10px] uppercase font-bold text-emerald-400 bg-emerald-500/10 px-2 py-0.5 rounded",children:"V\xE1lido"})]}),(0,I.jsx)("pre",{className:"p-5 text-xs font-mono leading-relaxed text-[#c9d1d9] overflow-x-auto whitespace-pre-wrap max-h-[300px] overflow-y-auto custom-scrollbar",children:o})]})]})]})})},uU=()=>{let[t,e]=(0,ye.useState)({activeChats:12,avgResponse:"2.4s",todayMessages:347,botUptime:"99.8%",queuedMessages:3});return(0,ye.useEffect)(()=>{let r=setInterval(()=>{e(n=>({...n,activeChats:n.activeChats+Math.floor(Math.random()*3)-1,todayMessages:n.todayMessages+Math.floor(Math.random()*5),queuedMessages:Math.max(0,n.queuedMessages+Math.floor(Math.random()*3)-1)}))},8e3);return()=>clearInterval(r)},[]),t},fU=ye.default.memo(()=>{let t=uU();return(0,I.jsxs)("div",{className:"h-6 shrink-0 flex items-center justify-between px-3 text-[10px] font-medium border-t",style:{background:"var(--brand-primary)",borderColor:"transparent",color:"white"},children:[(0,I.jsxs)("div",{className:"flex items-center gap-4",children:[(0,I.jsxs)("span",{className:"flex items-center gap-1",children:[(0,I.jsx)("i",{className:"fas fa-comments"})," ",t.activeChats," chats activos"]}),(0,I.jsxs)("span",{className:"flex items-center gap-1",children:[(0,I.jsx)("i",{className:"fas fa-clock"})," Resp: ",t.avgResponse]}),(0,I.jsxs)("span",{className:"flex items-center gap-1",children:[(0,I.jsx)("i",{className:"fas fa-paper-plane"})," ",t.todayMessages," hoy"]})]}),(0,I.jsxs)("div",{className:"flex items-center gap-4",children:[(0,I.jsxs)("span",{className:"flex items-center gap-1",children:[(0,I.jsx)("i",{className:"fas fa-inbox"})," ",t.queuedMessages," en cola"]}),(0,I.jsxs)("span",{className:"flex items-center gap-1",children:[(0,I.jsx)("i",{className:"fas fa-robot"})," Uptime: ",t.botUptime]}),(0,I.jsx)("span",{className:"opacity-70",children:"WhatsApp Business API"})]})]})}),pU=[{id:"chat",label:"Live Chat",icon:"fas fa-comments"},{id:"flow",label:"Flow Canvas",icon:"fas fa-project-diagram"},{id:"architect",label:"Workflow Architect",icon:"fas fa-wand-magic-sparkles"},{id:"analytics",label:"Analytics",icon:"fas fa-chart-bar"},{id:"api_tester",label:"API Tester",icon:"fas fa-vial"},{id:"templates",label:"Templates",icon:"fas fa-layer-group"}],h4=({gatewayStatus:t="connected",activeProvider:e="Meta Cloud API"})=>{let[r,n]=(0,ye.useState)("chat"),[o,s]=(0,ye.useState)(!0),[i,a]=(0,ye.useState)(!1),[l,c]=(0,ye.useState)(!0),[d,u]=(0,ye.useState)(null),[f,p]=(0,ye.useState)(!1),[h,b]=(0,ye.useState)(""),g=(0,ye.useRef)(null);(0,ye.useEffect)(()=>{let m=v=>{(v.metaKey||v.ctrlKey)&&v.key==="k"&&(v.preventDefault(),p(S=>!S),b("")),v.key==="Escape"&&p(!1)};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[]),(0,ye.useEffect)(()=>{f&&g.current&&g.current.focus()},[f]);let x=[{id:"chat",label:"Abrir Chat en Vivo",icon:"fas fa-comments",action:()=>n("chat")},{id:"flow",label:"Abrir Flow Canvas",icon:"fas fa-project-diagram",action:()=>n("flow")},{id:"architect",label:"Abrir Workflow Architect (IA)",icon:"fas fa-wand-magic-sparkles",action:()=>n("architect")},{id:"analytics",label:"Abrir Analytics",icon:"fas fa-chart-bar",action:()=>n("analytics")},{id:"explorer",label:o?"Cerrar Explorer":"Abrir Explorer",icon:"fas fa-folder-tree",action:()=>s(m=>!m)},{id:"inspector",label:i?"Cerrar Inspector":"Abrir Inspector",icon:"fas fa-info-circle",action:()=>a(m=>!m)},{id:"agent",label:l?"Ocultar Copiloto":"Mostrar Copiloto",icon:"fas fa-robot",action:()=>c(m=>!m)},{id:"demo",label:"Activar Modo Demo",icon:"fas fa-play-circle",action:()=>{}}].filter(m=>m.label.toLowerCase().includes(h.toLowerCase())),y=m=>{m.action(),p(!1)};return(0,I.jsxs)("div",{className:"h-full w-full flex flex-col overflow-hidden relative font-sans",style:{background:"var(--bg-primary)"},children:[(0,I.jsxs)("div",{className:"h-11 shrink-0 flex items-center justify-between px-3 gap-2 border-b",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)"},children:[(0,I.jsxs)("div",{className:"flex items-center gap-2",children:[(0,I.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 rounded-lg",style:{background:"var(--bg-muted)"},children:[(0,I.jsx)("i",{className:"fab fa-whatsapp text-green-500 text-lg"}),(0,I.jsx)("span",{className:"font-black text-xs uppercase tracking-widest",style:{color:"var(--text-primary)"},children:"Discovery Studio"})]}),(0,I.jsx)("div",{className:"h-5 w-px mx-1",style:{background:"var(--border-color)"}}),(0,I.jsx)("button",{onClick:()=>s(m=>!m),className:`w-7 h-7 rounded-md flex items-center justify-center text-xs transition-all ${o?"text-brand":""}`,style:{background:o?"var(--bg-muted)":"transparent",color:o?"var(--brand-primary)":"var(--text-secondary)"},title:"Toggle Explorer",children:(0,I.jsx)("i",{className:"fas fa-folder-tree"})}),(0,I.jsx)("button",{onClick:()=>a(m=>!m),className:"w-7 h-7 rounded-md flex items-center justify-center text-xs transition-all",style:{background:i?"var(--bg-muted)":"transparent",color:i?"var(--text-primary)":"var(--text-secondary)"},title:"Toggle Inspector",children:(0,I.jsx)("i",{className:"fas fa-columns"})}),(0,I.jsx)("button",{onClick:()=>c(m=>!m),className:"w-7 h-7 rounded-md flex items-center justify-center text-xs transition-all border border-emerald-500/20",style:{background:l?"rgba(16, 185, 129, 0.1)":"transparent",color:l?"#10b981":"var(--text-secondary)"},title:"Toggle Agent Copilot",children:(0,I.jsx)("i",{className:"fas fa-robot"})})]}),(0,I.jsxs)("button",{onClick:()=>p(!0),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all hover:border-brand-primary",style:{background:"var(--bg-muted)",border:"1px solid var(--border-color)",color:"var(--text-secondary)"},children:[(0,I.jsx)("i",{className:"fas fa-search text-[10px]"}),(0,I.jsx)("span",{children:"Buscar comandos..."}),(0,I.jsx)("kbd",{className:"ml-4 px-1.5 py-0.5 rounded text-[9px] font-mono font-bold",style:{background:"var(--bg-elevated)",border:"1px solid var(--border-color)"},children:"\u2318K"})]}),(0,I.jsxs)("div",{className:"flex items-center gap-2",children:[(0,I.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-lg text-[10px] font-bold",style:{background:t==="connected"?"rgba(34,197,94,0.1)":"rgba(239,68,68,0.1)",color:t==="connected"?"#22c55e":"#ef4444"},children:[(0,I.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${t==="connected"?"bg-green-500 animate-pulse":"bg-red-500"}`}),t==="connected"?`CONNECTED: ${e}`:"DISCONNECTED"]}),(0,I.jsx)("button",{className:"w-7 h-7 rounded-md flex items-center justify-center text-xs transition-all",style:{color:"var(--text-secondary)"},title:"Settings",children:(0,I.jsx)("i",{className:"fas fa-cog"})})]})]}),(0,I.jsxs)("div",{className:"h-9 shrink-0 flex items-end px-1 gap-px border-b",style:{background:"var(--bg-muted)",borderColor:"var(--border-color)"},children:[pU.map(m=>(0,I.jsxs)("button",{onClick:()=>n(m.id),className:`flex items-center gap-2 px-4 py-1.5 text-xs font-semibold rounded-t-lg transition-all relative ${r===m.id?"font-bold":"opacity-60 hover:opacity-80"}`,style:{background:r===m.id?"var(--bg-primary)":"transparent",color:r===m.id?"var(--text-primary)":"var(--text-secondary)",borderBottom:r===m.id?"2px solid var(--brand-primary)":"2px solid transparent"},children:[(0,I.jsx)("i",{className:`${m.icon} text-[10px]`}),m.label]},m.id)),(0,I.jsx)("div",{className:"flex-1"}),(0,I.jsx)("div",{className:"flex items-center gap-1 px-2 pb-1",children:(0,I.jsx)("button",{className:"w-6 h-6 rounded flex items-center justify-center text-[10px] transition-all hover:bg-white/10",style:{color:"var(--text-secondary)"},title:"Split view",children:(0,I.jsx)("i",{className:"fas fa-columns"})})})]}),(0,I.jsxs)("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[o&&(0,I.jsx)("div",{className:"w-60 shrink-0 flex flex-col border-r overflow-hidden animate-fade-in",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)"},children:(0,I.jsx)(U7,{selectedContact:d,onSelectContact:u})}),(0,I.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[r==="chat"&&(0,I.jsx)(X7,{selectedContact:d}),r==="flow"&&(0,I.jsx)(tU,{}),r==="architect"&&(0,I.jsx)(dU,{}),r==="analytics"&&(0,I.jsx)(iU,{}),r==="api_tester"&&(0,I.jsx)(aU,{}),r==="templates"&&(0,I.jsx)(lU,{})]}),i&&(0,I.jsx)("div",{className:"w-72 shrink-0 flex flex-col border-l overflow-hidden animate-fade-in",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)"},children:(0,I.jsx)(q7,{selectedContact:d})}),l&&(0,I.jsx)("div",{className:"w-80 shrink-0 flex flex-col border-l overflow-hidden animate-fade-in relative shadow-[-10px_0_30px_rgba(0,0,0,0.1)]",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)"},children:(0,I.jsx)(Y7,{})})]}),(0,I.jsx)(fU,{}),f&&(0,I.jsxs)("div",{className:"absolute inset-0 z-50 flex items-start justify-center pt-[15%]",onClick:()=>p(!1),children:[(0,I.jsx)("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),(0,I.jsxs)("div",{className:"relative w-[520px] max-h-[400px] rounded-xl overflow-hidden shadow-2xl border animate-scale-up",style:{background:"var(--bg-elevated)",borderColor:"var(--border-color)"},onClick:m=>m.stopPropagation(),children:[(0,I.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b",style:{borderColor:"var(--border-color)"},children:[(0,I.jsx)("i",{className:"fas fa-search text-xs",style:{color:"var(--text-secondary)"}}),(0,I.jsx)("input",{ref:g,type:"text",placeholder:"Escribe un comando...",className:"flex-1 bg-transparent outline-none text-sm font-medium",style:{color:"var(--text-primary)"},value:h,onChange:m=>b(m.target.value)}),(0,I.jsx)("kbd",{className:"px-1.5 py-0.5 rounded text-[9px] font-mono",style:{background:"var(--bg-muted)",color:"var(--text-secondary)"},children:"ESC"})]}),(0,I.jsxs)("div",{className:"max-h-[320px] overflow-y-auto p-1",children:[x.map((m,v)=>(0,I.jsxs)("button",{onClick:()=>y(m),className:"w-full flex items-center gap-3 px-4 py-2.5 rounded-lg text-sm transition-all text-left",style:{color:"var(--text-primary)"},onMouseEnter:S=>S.currentTarget.style.background="var(--bg-muted)",onMouseLeave:S=>S.currentTarget.style.background="transparent",children:[(0,I.jsx)("i",{className:`${m.icon} w-5 text-center text-xs`,style:{color:"var(--brand-primary)"}}),(0,I.jsx)("span",{className:"font-medium",children:m.label})]},m.id)),x.length===0&&(0,I.jsxs)("div",{className:"py-8 text-center text-xs",style:{color:"var(--text-secondary)"},children:[(0,I.jsx)("i",{className:"fas fa-search-minus text-lg mb-2 block opacity-30"}),"No se encontraron comandos"]})]})]})]})]})};var Gg=require("react/jsx-runtime"),mU={},hU=mU.env?.VITE_API_BASE_URL||"http://localhost:3001",g4=()=>{let[t,e]=(0,op.useState)("disconnected"),[r,n]=(0,op.useState)("Meta Cloud API");return(0,op.useEffect)(()=>{let o=(0,m4.io)(hU,{reconnectionDelay:2e3,reconnectionAttempts:1/0});return o.on("connect",()=>{console.log("[Discovery Admin] Conectado al backend de monitoreo:",o.id),e("connected")}),o.on("disconnect",()=>{console.warn("[Discovery Admin] Desconectado del backend"),e("disconnected")}),o.on("wa:status_update",s=>{console.log("[Discovery Admin] Estado del WA Gateway actualizado:",s),s?.status}),()=>{o.disconnect()}},[]),(0,Gg.jsx)("div",{className:"w-full h-full flex flex-col transition-colors",style:{"--bg-primary":"var(--ds-surface-primary, #ffffff)","--bg-elevated":"var(--ds-surface-secondary, #f8fafc)","--bg-muted":"var(--ds-surface-tertiary, #f1f5f9)","--border-color":"var(--ds-border-default, #e2e8f0)","--text-primary":"var(--ds-text-primary, #0f172a)","--text-secondary":"var(--ds-text-secondary, #64748b)","--brand-primary":"var(--ds-accent-blue, #3b82f6)"},children:(0,Gg.jsx)("div",{className:"flex-1 w-full h-full min-h-0 relative",children:(0,Gg.jsx)(h4,{gatewayStatus:t,activeProvider:r})})})};var Fr=require("react"),kc=require("framer-motion");var Ct=require("lucide-react"),ee=require("react/jsx-runtime"),gU={},cu=gU.env?.VITE_API_BASE_URL||"http://localhost:3001",b4=()=>{let[t]=(0,Fr.useState)([{id:"postgres",name:"PostgreSQL Core"},{id:"google_sheets",name:"Google Sheets MCP"}]),[e,r]=(0,Fr.useState)("postgres"),[n,o]=(0,Fr.useState)([]),[s,i]=(0,Fr.useState)(null),[a,l]=(0,Fr.useState)(!0),[c,d]=(0,Fr.useState)(!1),[u,f]=(0,Fr.useState)([]),[p,h]=(0,Fr.useState)(""),[b,g]=(0,Fr.useState)(null),[x,y]=(0,Fr.useState)(null),[m,v]=(0,Fr.useState)("data"),[S,w]=(0,Fr.useState)([]),[C,A]=(0,Fr.useState)(!1),[k,M]=(0,Fr.useState)(!1),[T,E]=(0,Fr.useState)(null),[P,N]=(0,Fr.useState)(!1),[D,R]=(0,Fr.useState)(!1),O=async()=>{l(!0),y(null);try{let z=await fetch(`${cu}/api/dataway/resources?connectorId=${e}`,{headers:{"x-api-key":"dev_ak_chameleon_studio_99x"}});if(!z.ok)throw new Error("API Endpoint /api/dataway/resources no disponible");let G=await z.json(),Y=Array.isArray(G.resources)?G.resources:[];o(Y),Y.length>0?i(Y[0]):i(null)}catch(z){console.error("[DB Admin] Failed to load schema:",z),y(z.message)}finally{l(!1)}};(0,Fr.useEffect)(()=>{O()},[e]);let B=async(z,G=!1)=>{G||d(!0),h(""),g(null);try{let Y=await fetch(`${cu}/api/dataway/query`,{method:"POST",headers:{"x-api-key":"dev_ak_chameleon_studio_99x","Content-Type":"application/json"},body:JSON.stringify({connectorId:e,resource:z,type:e==="postgres"?"table":"range"})});if(!Y.ok)throw new Error(`El backend Dataway rechaz\xF3 la lectura de la tabla ${z}`);let Z=await Y.json();f(Array.isArray(Z.data)?Z.data:[])}catch(Y){Bt.error(`Acceso Denegado a ${z}`,{description:Y.message}),f([])}finally{d(!1)}},L=async z=>{A(!0);try{let G=await fetch(`${cu}/api/dataway/schema?connectorId=${e}&resource=${z}`,{headers:{"x-api-key":"dev_ak_chameleon_studio_99x"}});if(!G.ok)throw new Error(`El Dataway backend rechaz\xF3 el esquema de ${z}`);let Y=await G.json();w(Y.schema||[])}catch(G){Bt.error("Error de Esquema Dataway",{description:G.message}),w([])}finally{A(!1)}};(0,Fr.useEffect)(()=>{s&&(B(s),L(s),v("data"))},[s]);let H=z=>{let G="asc";b&&b.key===z&&b.direction==="asc"&&(G="desc"),g({key:z,direction:G})},j=(0,Fr.useMemo)(()=>{let z=[...u];if(p){let G=p.toLowerCase();z=z.filter(Y=>Object.keys(Y).some(Z=>String(Y[Z]).toLowerCase().includes(G)))}return b!==null&&z.sort((G,Y)=>{let Z=G[b.key],se=Y[b.key];return Z<se?b.direction==="asc"?-1:1:Z>se?b.direction==="asc"?1:-1:0}),z},[u,p,b]),$=u.length>0?Object.keys(u[0]):[],q=async z=>{if(!s)return;R(!0);let G=P,Y=G?"POST":"PUT",Z=G?`${cu}/api/db/${s}`:`${cu}/api/db/${s}/${z.id}`;try{let se={...z};G&&delete se.id;let we=await fetch(Z,{method:Y,headers:{"Content-Type":"application/json","x-api-key":"dev_ak_chameleon_studio_99x"},body:JSON.stringify(se)});if(!we.ok){let _e=await we.json().catch(()=>({}));throw new Error(_e.message||_e.error||"Error desconocido al guardar en base de datos")}Bt.success(`Registro ${G?"creado":"actualizado"} en la tabla ${s}`),M(!1),B(s,!0)}catch(se){Bt.error("Error de Integridad",{description:se.message})}finally{R(!1)}},F=async z=>{if(s&&confirm("\xBFAtenci\xF3n: Esta acci\xF3n es destructiva y permanente. \xBFConfirmar eliminaci\xF3n?"))try{if(!(await fetch(`${cu}/api/db/${s}/${z}`,{method:"DELETE",headers:{"x-api-key":"dev_ak_chameleon_studio_99x"}})).ok)throw new Error("No se pudo eliminar el registro (violaci\xF3n de Foreign Key o ruta no implementada)");Bt.success("Registro eliminado exitosamente"),f(Y=>Y.filter(Z=>Z.id!==z))}catch(G){Bt.error("Fallo al Eliminar",{description:G.message})}},_=z=>{E({...z}),N(!1),M(!0)},W=()=>{let z={};$.length>0&&$.forEach(G=>{G!=="id"&&G!=="created_at"&&G!=="updated_at"&&(z[G]="")}),E(z),N(!0),M(!0)},V=z=>typeof z=="boolean"?"checkbox":typeof z=="number"?"number":"text";return(0,ee.jsxs)("div",{className:"w-full h-full flex flex-row overflow-hidden",style:{"--bg-primary":"var(--ds-surface-primary, #ffffff)","--bg-elevated":"var(--ds-surface-secondary, #f8fafc)","--bg-surface":"var(--ds-surface-tertiary, #f1f5f9)","--border-color":"var(--ds-border-default, #e2e8f0)","--text-primary":"var(--ds-text-primary, #0f172a)","--text-secondary":"var(--ds-text-secondary, #64748b)","--brand-primary":"var(--ds-accent-blue, #3b82f6)","--brand-primary-hover":"var(--ds-accent-blue-hover, #2563eb)"},children:[(0,ee.jsxs)("div",{className:"w-72 border-r border-[var(--border-color)] bg-[var(--bg-elevated)] flex flex-col h-full z-10 shadow-[2px_0_10px_rgba(0,0,0,0.02)]",children:[(0,ee.jsxs)("div",{className:"p-6 border-b border-[var(--border-color)] flex flex-col gap-4 bg-[var(--bg-primary)]",children:[(0,ee.jsxs)("div",{className:"flex items-center gap-3",children:[(0,ee.jsx)("div",{className:"p-2 bg-[var(--brand-primary)]/10 rounded-xl",children:(0,ee.jsx)(Ct.DatabaseZap,{className:"w-6 h-6 text-[var(--brand-primary)]"})}),(0,ee.jsxs)("div",{children:[(0,ee.jsx)("h2",{className:"font-extrabold text-[var(--text-primary)] tracking-tight text-lg leading-none",children:"Data Studio"}),(0,ee.jsx)("p",{className:"text-[11px] font-medium text-[var(--text-secondary)] uppercase tracking-wider mt-1",children:"Dataway Core"})]})]}),(0,ee.jsx)("select",{value:e,onChange:z=>r(z.target.value),className:"w-full bg-[var(--bg-surface)] border border-[var(--border-color)] text-[var(--text-primary)] text-sm font-bold rounded-lg px-3 py-2 outline-none cursor-pointer hover:border-[var(--brand-primary)]/50 focus:border-[var(--brand-primary)] focus:ring-2 focus:ring-[var(--brand-primary)]/20 transition-all shadow-sm",children:t.map(z=>(0,ee.jsx)("option",{value:z.id,children:z.name},z.id))})]}),(0,ee.jsxs)("div",{className:"p-4 flex-1 overflow-y-auto w-full space-y-1.5 custom-scrollbar",children:[(0,ee.jsxs)("h3",{className:"text-xs font-bold text-[var(--text-secondary)] tracking-wider uppercase mb-3 px-2 flex items-center justify-between",children:["Esquema P\xFAbico",(0,ee.jsx)("button",{onClick:O,className:"hover:text-[var(--text-primary)] transition-colors p-1 rounded-md hover:bg-[var(--bg-surface)]",children:(0,ee.jsx)(Ct.RefreshCw,{className:"w-3 h-3"})})]}),a?(0,ee.jsx)("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(z=>(0,ee.jsx)("div",{className:"h-10 bg-[var(--bg-surface)] rounded-lg animate-pulse w-full"},z))}):x?(0,ee.jsxs)("div",{className:"p-4 mx-2 bg-red-50 text-red-600 rounded-xl border border-red-100 flex flex-col items-center text-center gap-2",children:[(0,ee.jsx)(Ct.ServerCrash,{className:"w-6 h-6"}),(0,ee.jsx)("p",{className:"text-sm font-semibold",children:"Backend Offline"}),(0,ee.jsx)("p",{className:"text-xs opacity-80",children:x})]}):n.length===0?(0,ee.jsx)("div",{className:"p-4 text-center text-[var(--text-secondary)] text-sm",children:"No se descubrieron tablas v\xEDa /api/db/tables."}):n.map(z=>(0,ee.jsxs)("button",{onClick:()=>i(z),className:`w-full flex items-center justify-between px-3 py-2.5 rounded-xl text-sm font-semibold transition-all duration-200 group ${s===z?"bg-gradient-to-r from-[var(--brand-primary)] to-[var(--brand-primary-hover)] text-white shadow-md shadow-blue-500/20":"text-[var(--text-secondary)] hover:bg-[var(--bg-surface)] hover:text-[var(--text-primary)]"}`,children:[(0,ee.jsxs)("div",{className:"flex items-center gap-3",children:[(0,ee.jsx)(Ct.TableProperties,{className:`w-4 h-4 ${s===z?"text-blue-100":"text-slate-400 group-hover:text-slate-600"}`}),(0,ee.jsx)("span",{className:"capitalize",children:z})]}),s===z&&(0,ee.jsx)(Ct.ChevronRight,{className:"w-4 h-4 opacity-70"})]},z))]})]}),(0,ee.jsxs)("div",{className:"flex-1 bg-[var(--bg-surface)] flex flex-col h-full min-w-0 relative",children:[(0,ee.jsxs)("header",{className:"px-8 py-6 bg-[var(--bg-primary)] border-b border-[var(--border-color)] flex items-center justify-between sticky top-0 z-20 shadow-sm",children:[(0,ee.jsxs)("div",{className:"flex flex-col",children:[(0,ee.jsxs)("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] text-xs font-bold uppercase tracking-wider mb-1",children:[(0,ee.jsx)(Ct.Server,{className:"w-3.5 h-3.5"}),(0,ee.jsxs)("span",{children:[t.find(z=>z.id===e)?.name," / ",s||"..."]})]}),(0,ee.jsxs)("h1",{className:"text-3xl font-extrabold text-[var(--text-primary)] capitalize tracking-tight flex items-center gap-3",children:[s||"Selecciona un Recurso",c&&(0,ee.jsx)(Ct.Loader2,{className:"w-5 h-5 animate-spin text-[var(--brand-primary)]"})]})]}),s&&(0,ee.jsxs)("div",{className:"flex gap-4 items-center",children:[(0,ee.jsxs)("div",{className:"flex bg-[var(--bg-elevated)] border border-[var(--border-color)] rounded-lg p-1 shadow-sm h-[42px] items-center mr-2",children:[(0,ee.jsx)("button",{onClick:()=>v("data"),className:`px-4 py-1.5 text-xs font-bold rounded-md transition-all duration-200 ${m==="data"?"bg-[var(--bg-primary)] text-[var(--text-primary)] shadow-sm border border-[var(--border-color)]":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] border border-transparent"}`,children:"Registros"}),(0,ee.jsx)("button",{onClick:()=>v("schema"),className:`px-4 py-1.5 text-xs font-bold rounded-md transition-all duration-200 ${m==="schema"?"bg-[var(--bg-primary)] text-[var(--brand-primary)] shadow-sm border border-[var(--brand-primary)]/30":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] border border-transparent"}`,children:"Estructura"})]}),(0,ee.jsxs)("div",{className:"relative group",children:[(0,ee.jsx)(Ct.Search,{className:"w-4 h-4 text-[var(--text-secondary)] absolute left-3.5 top-1/2 -translate-y-1/2 group-focus-within:text-[var(--brand-primary)] transition-colors"}),(0,ee.jsx)("input",{type:"text",placeholder:`Buscar en ${s}...`,value:p,onChange:z=>h(z.target.value),className:"pl-10 pr-4 py-2.5 rounded-xl border border-[var(--border-color)] bg-[var(--bg-elevated)] text-[var(--text-primary)] text-sm font-medium outline-none focus:ring-2 focus:ring-[var(--brand-primary)]/20 focus:border-[var(--brand-primary)] transition-all w-72 shadow-inner"})]}),(0,ee.jsx)("div",{className:"h-8 w-px bg-[var(--border-color)] mx-2"}),(0,ee.jsx)("button",{onClick:()=>B(s),disabled:c,className:"p-2.5 text-[var(--text-secondary)] hover:bg-[var(--bg-surface)] hover:text-[var(--text-primary)] rounded-xl transition-all disabled:opacity-50 border border-transparent hover:border-[var(--border-color)]",title:"Recargar Data",children:(0,ee.jsx)(Ct.RefreshCw,{className:`w-[18px] h-[18px] ${c?"animate-spin":""}`})}),(0,ee.jsxs)("button",{onClick:W,disabled:n.length===0,className:"flex items-center gap-2 bg-[var(--brand-primary)] hover:bg-[var(--brand-primary-hover)] text-white px-5 py-2.5 rounded-xl font-bold text-sm shadow-lg shadow-[var(--brand-primary)]/25 transition-all active:scale-95 disabled:opacity-50 disabled:grayscale",children:[(0,ee.jsx)(Ct.Plus,{className:"w-[18px] h-[18px]"}),"Insertar Fila"]})]})]}),(0,ee.jsx)("div",{className:"flex-1 overflow-hidden p-6 relative flex flex-col",children:s?(0,ee.jsxs)("div",{className:"flex-1 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-2xl shadow-sm overflow-hidden flex flex-col relative",children:[(0,ee.jsx)("div",{className:"overflow-auto flex-1 custom-scrollbar",children:m==="schema"?(0,ee.jsxs)("table",{className:"w-full text-left text-sm whitespace-nowrap",children:[(0,ee.jsx)("thead",{className:"bg-[var(--bg-elevated)] sticky top-0 z-10 shadow-[0_1px_2px_rgba(0,0,0,0.05)]",children:(0,ee.jsxs)("tr",{children:[(0,ee.jsx)("th",{className:"px-6 py-4 text-xs font-bold text-[var(--text-secondary)] uppercase tracking-wider",children:"Columna"}),(0,ee.jsx)("th",{className:"px-6 py-4 text-xs font-bold text-[var(--text-secondary)] uppercase tracking-wider",children:"Tipo de Dato"}),(0,ee.jsx)("th",{className:"px-6 py-4 text-xs font-bold text-[var(--text-secondary)] uppercase tracking-wider",children:"Nulabilidad"}),(0,ee.jsx)("th",{className:"px-6 py-4 text-xs font-bold text-[var(--text-secondary)] uppercase tracking-wider",children:"Valor por Defecto"})]})}),(0,ee.jsx)("tbody",{className:"divide-y divide-[var(--border-color)] text-[var(--text-primary)] font-medium",children:C?(0,ee.jsx)("tr",{children:(0,ee.jsx)("td",{colSpan:4,className:"h-48 text-center text-[var(--text-secondary)]",children:(0,ee.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,ee.jsx)(Ct.Loader2,{className:"w-8 h-8 animate-spin text-[var(--brand-primary)]"}),(0,ee.jsx)("span",{children:"Cargando esquema estructural..."})]})})}):S.map(z=>(0,ee.jsxs)(kc.motion.tr,{initial:{opacity:0},animate:{opacity:1},className:"hover:bg-[var(--bg-surface)]/70 transition-colors",children:[(0,ee.jsx)("td",{className:"px-6 py-3",children:(0,ee.jsx)("span",{className:"font-bold text-[var(--text-primary)]",children:z.name})}),(0,ee.jsx)("td",{className:"px-6 py-3",children:(0,ee.jsx)("span",{className:"font-mono text-[11px] text-blue-600 bg-blue-50 px-2 py-1 rounded-md",children:z.type})}),(0,ee.jsx)("td",{className:"px-6 py-3",children:z.is_nullable==="YES"?(0,ee.jsx)("span",{className:"opacity-60 text-[11px] font-bold uppercase",children:"Nullable"}):(0,ee.jsx)("span",{className:"text-red-600 bg-red-50 px-2 py-0.5 rounded text-[10px] font-bold uppercase",children:"Not Null"})}),(0,ee.jsx)("td",{className:"px-6 py-3",children:z.default_value?(0,ee.jsx)("span",{className:"font-mono text-[11px] text-purple-600 bg-purple-50 px-2 py-1 rounded-md",children:z.default_value}):(0,ee.jsx)("span",{className:"text-gray-400 italic",children:"None"})})]},z.name))})]}):(0,ee.jsxs)("table",{className:"w-full text-left text-sm whitespace-nowrap",children:[(0,ee.jsx)("thead",{className:"bg-[var(--bg-elevated)] sticky top-0 z-10 shadow-[0_1px_2px_rgba(0,0,0,0.05)]",children:(0,ee.jsxs)("tr",{children:[$.map(z=>(0,ee.jsx)("th",{onClick:()=>H(z),className:"px-6 py-4 cursor-pointer hover:bg-[var(--bg-surface)] transition-colors group select-none",children:(0,ee.jsxs)("div",{className:"flex items-center gap-2 text-xs font-bold text-[var(--text-secondary)] uppercase tracking-wider",children:[z,(0,ee.jsx)(Ct.ArrowUpDown,{className:`w-3.5 h-3.5 ${b?.key===z?"text-[var(--brand-primary)]":"opacity-0 group-hover:opacity-50 transition-opacity"}`})]})},z)),(0,ee.jsx)("th",{className:"px-6 py-4 w-24 sticky right-0 bg-[var(--bg-elevated)] backdrop-blur-md shadow-[-4px_0_10px_rgba(0,0,0,0.02)]",children:(0,ee.jsx)("span",{className:"sr-only",children:"Actions"})})]})}),(0,ee.jsx)("tbody",{className:"divide-y divide-[var(--border-color)] text-[var(--text-primary)] font-medium",children:j.length===0?(0,ee.jsx)("tr",{children:(0,ee.jsx)("td",{colSpan:$.length+1,className:"h-48 text-center text-[var(--text-secondary)]",children:c?(0,ee.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,ee.jsx)(Ct.Loader2,{className:"w-8 h-8 animate-spin text-[var(--brand-primary)]"}),(0,ee.jsxs)("span",{children:["Consultando ",s,"..."]})]}):(0,ee.jsxs)("div",{className:"flex flex-col items-center gap-3 opacity-60",children:[(0,ee.jsx)(Ct.Database,{className:"w-10 h-10"}),(0,ee.jsx)("span",{children:"La consulta retorn\xF3 0 filas."})]})})}):j.map((z,G)=>(0,ee.jsxs)(kc.motion.tr,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:Math.min(G*.02,.5)},className:"hover:bg-[var(--bg-surface)]/70 transition-colors group",children:[$.map(Y=>{let Z=z[Y];return(0,ee.jsx)("td",{className:"px-6 py-3 max-w-[250px] truncate text-ellipsis",children:typeof Z=="boolean"?(0,ee.jsx)("span",{className:`px-2 py-1 rounded-md text-[10px] font-bold uppercase tracking-wider ${Z?"bg-green-100 text-green-700":"bg-red-100 text-red-700"}`,children:Z?"TRUE":"FALSE"}):typeof Z=="object"&&Z!==null?(0,ee.jsx)("span",{className:"font-mono text-[11px] text-emerald-600 bg-emerald-50 px-2 py-1 rounded-md",children:JSON.stringify(Z)}):(0,ee.jsx)("span",{title:String(Z),children:Z!=null?String(Z):(0,ee.jsx)("span",{className:"text-gray-400 italic",children:"null"})})},Y)}),(0,ee.jsx)("td",{className:"px-6 py-3 text-right sticky right-0 bg-[var(--bg-primary)] group-hover:bg-[#f8fafc] transition-colors shadow-[-4px_0_10px_rgba(0,0,0,0.02)] border-l border-transparent group-hover:border-[var(--border-color)]",children:(0,ee.jsxs)("div",{className:"flex items-center justify-end gap-1 opacity-10 md:opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,ee.jsx)("button",{onClick:()=>_(z),className:"p-1.5 hover:bg-blue-100 text-blue-600 rounded-md transition-colors tooltip-trigger",title:"Editar Registro",children:(0,ee.jsx)(Ct.Edit2,{className:"w-4 h-4"})}),(0,ee.jsx)("button",{onClick:()=>F(z.id),className:"p-1.5 hover:bg-red-100 text-red-600 rounded-md transition-colors tooltip-trigger",title:"Eliminar Permanente",children:(0,ee.jsx)(Ct.Trash2,{className:"w-4 h-4"})})]})})]},z.id||G))})]})}),(0,ee.jsxs)("div",{className:"px-6 py-3 border-t border-[var(--border-color)] bg-[var(--bg-elevated)] text-xs font-semibold text-[var(--text-secondary)] flex justify-between items-center z-10",children:[(0,ee.jsxs)("span",{children:["Total Records: ",j.length]}),(0,ee.jsx)("span",{className:"uppercase tracking-wider",children:"Macia Platform v2.0 - Core Gateway"})]})]}):(0,ee.jsxs)("div",{className:"m-auto flex flex-col items-center justify-center opacity-40",children:[(0,ee.jsx)(Ct.LayoutGrid,{className:"w-16 h-16 mb-4"}),(0,ee.jsx)("h2",{className:"text-xl font-bold",children:"Sin Datos Activos"}),(0,ee.jsx)("p",{className:"text-sm",children:"Selecciona una tabla en el panel lateral."})]})})]}),(0,ee.jsx)(kc.AnimatePresence,{children:k&&(0,ee.jsx)(kc.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-[var(--text-primary)]/40 backdrop-blur-md",children:(0,ee.jsxs)(kc.motion.div,{initial:{scale:.95,opacity:0,y:20},animate:{scale:1,opacity:1,y:0},exit:{scale:.95,opacity:0,y:-20},transition:{type:"spring",bounce:0,duration:.3},className:"bg-[var(--bg-primary)] border border-white/20 rounded-3xl shadow-[0_20px_60px_-10px_rgba(0,0,0,0.3)] w-full max-w-2xl overflow-hidden flex flex-col relative",children:[(0,ee.jsx)("div",{className:"absolute top-0 left-0 w-full h-32 bg-gradient-to-br from-blue-500/10 to-purple-500/5 pointer-events-none"}),(0,ee.jsxs)("div",{className:"px-8 py-5 border-b border-[var(--border-color)] flex justify-between items-center relative z-10 bg-[var(--bg-primary)]/80 backdrop-blur-lg",children:[(0,ee.jsxs)("div",{children:[(0,ee.jsx)("h3",{className:"font-extrabold text-xl text-[var(--text-primary)] tracking-tight",children:P?"Insertar Documento":"Modificar Documento"}),(0,ee.jsxs)("p",{className:"text-xs text-[var(--text-secondary)] font-medium mt-0.5",children:["Tabla destino: ",(0,ee.jsx)("span",{className:"uppercase tracking-wider bg-[var(--bg-surface)] px-1.5 py-0.5 rounded text-[var(--brand-primary)]",children:s})]})]}),(0,ee.jsx)("button",{onClick:()=>M(!1),className:"p-2 bg-[var(--bg-surface)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--border-color)] rounded-xl transition-all",children:(0,ee.jsx)(Ct.X,{className:"w-5 h-5"})})]}),(0,ee.jsx)("div",{className:"p-8 space-y-5 max-h-[65vh] overflow-y-auto custom-scrollbar relative z-10",children:T&&Object.keys(T).map(z=>{let G=!P&&z==="id"||z==="created_at"||z==="updated_at",Y=T[z],Z=V(Y);return(0,ee.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,ee.jsxs)("label",{className:"text-[11px] font-bold text-[var(--text-secondary)] uppercase tracking-wider pl-1 flex justify-between",children:[z,G&&(0,ee.jsx)("span",{className:"opacity-50 font-mono lowercase",children:"auto-generated"})]}),G?(0,ee.jsx)("input",{disabled:!0,value:Y||"Depende del Motor DB",className:"w-full px-4 py-3 rounded-xl border border-[var(--border-color)] bg-[var(--bg-surface)] text-[var(--text-secondary)] font-mono text-xs cursor-not-allowed opacity-70"}):typeof Y=="boolean"?(0,ee.jsxs)("select",{value:String(Y),onChange:se=>E({...T,[z]:se.target.value==="true"}),className:"w-full px-4 py-3 rounded-xl border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:ring-2 focus:ring-[var(--brand-primary)]/20 focus:border-[var(--brand-primary)] text-sm font-medium outline-none transition-all cursor-pointer shadow-sm",children:[(0,ee.jsx)("option",{value:"true",children:"Verdadero (TRUE)"}),(0,ee.jsx)("option",{value:"false",children:"Falso (FALSE)"})]}):typeof Y=="object"&&Y!==null?(0,ee.jsx)("textarea",{rows:4,value:JSON.stringify(Y,null,2),onChange:se=>{try{let we=JSON.parse(se.target.value);E({...T,[z]:we})}catch{E({...T,[z]:se.target.value})}},className:"w-full px-4 py-3 rounded-xl border border-[var(--border-color)] bg-[var(--bg-primary)] font-mono text-xs focus:ring-2 focus:ring-[var(--brand-primary)]/20 focus:border-[var(--brand-primary)] outline-none transition-all shadow-sm"}):(0,ee.jsx)("input",{type:Z,value:Y!==null?Y:"",onChange:se=>E({...T,[z]:Z==="number"?Number(se.target.value):se.target.value}),className:"w-full px-4 py-3 rounded-xl border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:ring-2 focus:ring-[var(--brand-primary)]/20 focus:border-[var(--brand-primary)] text-sm font-medium outline-none transition-all shadow-sm",placeholder:`Ingresar ${z}...`})]},z)})}),(0,ee.jsxs)("div",{className:"px-8 py-5 border-t border-[var(--border-color)] bg-[var(--bg-surface)] flex justify-end gap-3 rounded-b-3xl relative z-10",children:[(0,ee.jsx)("button",{onClick:()=>M(!1),className:"px-5 py-2.5 rounded-xl text-sm font-bold text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--border-color)] transition-all",children:"Descartar"}),(0,ee.jsxs)("button",{onClick:()=>q(T),disabled:D,className:"flex items-center gap-2 px-6 py-2.5 rounded-xl text-sm font-extrabold text-white bg-gradient-to-r from-[var(--brand-primary)] to-[var(--brand-primary-hover)] shadow-lg shadow-[var(--brand-primary)]/30 transition-all active:scale-95 disabled:opacity-70",children:[D?(0,ee.jsx)(Ct.Loader2,{className:"w-[18px] h-[18px] animate-spin"}):(0,ee.jsx)(Ct.Check,{className:"w-[18px] h-[18px]"}),D?"Sincronizando...":"Confirmar Cambios"]})]})]})})}),(0,ee.jsx)("style",{children:`
|
|
463
|
+
.custom-scrollbar::-webkit-scrollbar {
|
|
464
|
+
width: 6px;
|
|
465
|
+
height: 6px;
|
|
466
|
+
}
|
|
467
|
+
.custom-scrollbar::-webkit-scrollbar-track {
|
|
468
|
+
background: transparent;
|
|
469
|
+
}
|
|
470
|
+
.custom-scrollbar::-webkit-scrollbar-thumb {
|
|
471
|
+
background: var(--border-color);
|
|
472
|
+
border-radius: 10px;
|
|
473
|
+
}
|
|
474
|
+
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
|
|
475
|
+
background: var(--text-secondary);
|
|
476
|
+
}
|
|
477
|
+
`})]})};var Et=require("react"),_u=require("framer-motion");var pl=Re(require("react"),1),I4=require("react-dom");function Ec(t,e,r){let n=r.initialDeps??[],o,s=!0;function i(){var a,l,c;let d;r.key&&((a=r.debug)!=null&&a.call(r))&&(d=Date.now());let u=t();if(!(u.length!==n.length||u.some((h,b)=>n[b]!==h)))return o;n=u;let p;if(r.key&&((l=r.debug)!=null&&l.call(r))&&(p=Date.now()),o=e(...u),r.key&&((c=r.debug)!=null&&c.call(r))){let h=Math.round((Date.now()-d)*100)/100,b=Math.round((Date.now()-p)*100)/100,g=b/16,x=(y,m)=>{for(y=String(y);y.length<m;)y=" "+y;return y};console.info(`%c\u23F1 ${x(b,5)} /${x(h,5)} ms`,`
|
|
478
|
+
font-size: .6rem;
|
|
479
|
+
font-weight: bold;
|
|
480
|
+
color: hsl(${Math.max(0,Math.min(120-120*g,120))}deg 100% 31%);`,r?.key)}return r?.onChange&&!(s&&r.skipInitialOnChange)&&r.onChange(o),s=!1,o}return i.updateDeps=a=>{n=a},i}function ew(t,e){if(t===void 0)throw new Error(`Unexpected undefined${e?`: ${e}`:""}`);return t}var x4=(t,e)=>Math.abs(t-e)<1.01,y4=(t,e,r)=>{let n;return function(...o){t.clearTimeout(n),n=t.setTimeout(()=>e.apply(this,o),r)}};var v4=t=>{let{offsetWidth:e,offsetHeight:r}=t;return{width:e,height:r}},bU=t=>t,xU=t=>{let e=Math.max(t.startIndex-t.overscan,0),r=Math.min(t.endIndex+t.overscan,t.count-1),n=[];for(let o=e;o<=r;o++)n.push(o);return n},N4=(t,e)=>{let r=t.scrollElement;if(!r)return;let n=t.targetWindow;if(!n)return;let o=i=>{let{width:a,height:l}=i;e({width:Math.round(a),height:Math.round(l)})};if(o(v4(r)),!n.ResizeObserver)return()=>{};let s=new n.ResizeObserver(i=>{let a=()=>{let l=i[0];if(l?.borderBoxSize){let c=l.borderBoxSize[0];if(c){o({width:c.inlineSize,height:c.blockSize});return}}o(v4(r))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return s.observe(r,{box:"border-box"}),()=>{s.unobserve(r)}},w4={passive:!0};var S4=typeof window>"u"?!0:"onscrollend"in window,C4=(t,e)=>{let r=t.scrollElement;if(!r)return;let n=t.targetWindow;if(!n)return;let o=0,s=t.options.useScrollendEvent&&S4?()=>{}:y4(n,()=>{e(o,!1)},t.options.isScrollingResetDelay),i=d=>()=>{let{horizontal:u,isRtl:f}=t.options;o=u?r.scrollLeft*(f&&-1||1):r.scrollTop,s(),e(o,d)},a=i(!0),l=i(!1);r.addEventListener("scroll",a,w4);let c=t.options.useScrollendEvent&&S4;return c&&r.addEventListener("scrollend",l,w4),()=>{r.removeEventListener("scroll",a),c&&r.removeEventListener("scrollend",l)}};var yU=(t,e,r)=>{if(e?.borderBoxSize){let n=e.borderBoxSize[0];if(n)return Math.round(n[r.options.horizontal?"inlineSize":"blockSize"])}return t[r.options.horizontal?"offsetWidth":"offsetHeight"]};var k4=(t,{adjustments:e=0,behavior:r},n)=>{var o,s;let i=t+e;(s=(o=n.scrollElement)==null?void 0:o.scrollTo)==null||s.call(o,{[n.options.horizontal?"left":"top"]:i,behavior:r})},Kg=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var r,n,o;return((o=(n=(r=this.targetWindow)==null?void 0:r.performance)==null?void 0:n.now)==null?void 0:o.call(n))??Date.now()},this.observer=(()=>{let r=null,n=()=>r||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:r=new this.targetWindow.ResizeObserver(o=>{o.forEach(s=>{let i=()=>{let a=s.target,l=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(a,s,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var o;(o=n())==null||o.disconnect(),r=null},observe:o=>{var s;return(s=n())==null?void 0:s.observe(o,{box:"border-box"})},unobserve:o=>{var s;return(s=n())==null?void 0:s.unobserve(o)}}})(),this.range=null,this.setOptions=r=>{Object.entries(r).forEach(([n,o])=>{typeof o>"u"&&delete r[n]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:bU,rangeExtractor:xU,onChange:()=>{},measureElement:yU,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...r}},this.notify=r=>{var n,o;(o=(n=this.options).onChange)==null||o.call(n,this,r)},this.maybeNotify=Ec(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),r=>{this.notify(r)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(r=>r()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var r;let n=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==n){if(this.cleanup(),!n){this.maybeNotify();return}this.scrollElement=n,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((r=this.scrollElement)==null?void 0:r.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,s)=>{this.scrollAdjustments=0,this.scrollDirection=s?this.getScrollOffset()<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=s,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(r,n)=>{let o=new Map,s=new Map;for(let i=n-1;i>=0;i--){let a=r[i];if(o.has(a.lane))continue;let l=s.get(a.lane);if(l==null||a.end>l.end?s.set(a.lane,a):a.end<l.end&&o.set(a.lane,!0),o.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((i,a)=>i.end===a.end?i.index-a.index:i.end-a.end)[0]:void 0},this.getMeasurementOptions=Ec(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(r,n,o,s,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:r,paddingStart:n,scrollMargin:o,getItemKey:s,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=Ec(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:r,paddingStart:n,scrollMargin:o,getItemKey:s,enabled:i,lanes:a},l)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>r)for(let f of this.laneAssignments.keys())f>=r&&this.laneAssignments.delete(f);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(f=>{this.itemSizeCache.set(f.key,f.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===r&&(this.lanesSettling=!1);let d=this.measurementsCache.slice(0,c),u=new Array(a).fill(void 0);for(let f=0;f<c;f++){let p=d[f];p&&(u[p.lane]=f)}for(let f=c;f<r;f++){let p=s(f),h=this.laneAssignments.get(f),b,g;if(h!==void 0&&this.options.lanes>1){b=h;let v=u[b],S=v!==void 0?d[v]:void 0;g=S?S.end+this.options.gap:n+o}else{let v=this.options.lanes===1?d[f-1]:this.getFurthestMeasurement(d,f);g=v?v.end+this.options.gap:n+o,b=v?v.lane:f%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(f,b)}let x=l.get(p),y=typeof x=="number"?x:this.options.estimateSize(f),m=g+y;d[f]={index:f,start:g,size:y,end:m,key:p,lane:b},u[b]=f}return this.measurementsCache=d,d},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=Ec(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(r,n,o,s)=>this.range=r.length>0&&n>0?vU({measurements:r,outerSize:n,scrollOffset:o,lanes:s}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=Ec(()=>{let r=null,n=null,o=this.calculateRange();return o&&(r=o.startIndex,n=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,r,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,r,n]},(r,n,o,s,i)=>s===null||i===null?[]:r({startIndex:s,endIndex:i,overscan:n,count:o}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=r=>{let n=this.options.indexAttribute,o=r.getAttribute(n);return o?parseInt(o,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=r=>{var n;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;let o=this.scrollState.index??((n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index);if(o!==void 0&&this.range){let s=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,o-s),a=Math.min(this.options.count-1,o+s);return r>=i&&r<=a}return!0},this.measureElement=r=>{if(!r){this.elementsCache.forEach((i,a)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(a))});return}let n=this.indexFromElement(r),o=this.options.getItemKey(n),s=this.elementsCache.get(o);s!==r&&(s&&this.observer.unobserve(s),this.observer.observe(r),this.elementsCache.set(o,r)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(r,void 0,this))},this.resizeItem=(r,n)=>{var o;let s=this.measurementsCache[r];if(!s)return;let i=this.itemSizeCache.get(s.key)??s.size,a=n-i;a!==0&&(((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(s,a,this):s.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",a),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=a,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(s.index),this.itemSizeCache=new Map(this.itemSizeCache.set(s.key,n)),this.notify(!1))},this.getVirtualItems=Ec(()=>[this.getVirtualIndexes(),this.getMeasurements()],(r,n)=>{let o=[];for(let s=0,i=r.length;s<i;s++){let a=r[s],l=n[a];o.push(l)}return o},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=r=>{let n=this.getMeasurements();if(n.length!==0)return ew(n[E4(0,n.length-1,o=>ew(n[o]).start,r)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let r=this.scrollElement.document.documentElement;return this.options.horizontal?r.scrollWidth-this.scrollElement.innerWidth:r.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(r,n,o=0)=>{if(!this.scrollElement)return 0;let s=this.getSize(),i=this.getScrollOffset();n==="auto"&&(n=r>=i+s?"end":"start"),n==="center"?r+=(o-s)/2:n==="end"&&(r-=s);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,r),0)},this.getOffsetForIndex=(r,n="auto")=>{r=Math.max(0,Math.min(r,this.options.count-1));let o=this.getSize(),s=this.getScrollOffset(),i=this.measurementsCache[r];if(!i)return;if(n==="auto")if(i.end>=s+o-this.options.scrollPaddingEnd)n="end";else if(i.start<=s+this.options.scrollPaddingStart)n="start";else return[s,n];if(n==="end"&&r===this.options.count-1)return[this.getMaxScrollOffset(),n];let a=n==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,n,i.size),n]},this.scrollToOffset=(r,{align:n="start",behavior:o="auto"}={})=>{let s=this.getOffsetForAlignment(r,n),i=this.now();this.scrollState={index:null,align:n,behavior:o,startedAt:i,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(r,{align:n="auto",behavior:o="auto"}={})=>{r=Math.max(0,Math.min(r,this.options.count-1));let s=this.getOffsetForIndex(r,n);if(!s)return;let[i,a]=s,l=this.now();this.scrollState={index:r,align:a,behavior:o,startedAt:l,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(r,{behavior:n="auto"}={})=>{let o=this.getScrollOffset()+r,s=this.now();this.scrollState={index:null,align:"start",behavior:n,startedAt:s,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var r;let n=this.getMeasurements(),o;if(n.length===0)o=this.options.paddingStart;else if(this.options.lanes===1)o=((r=n[n.length-1])==null?void 0:r.end)??0;else{let s=Array(this.options.lanes).fill(null),i=n.length-1;for(;i>=0&&s.some(a=>a===null);){let a=n[i];s[a.lane]===null&&(s[a.lane]=a.end),i--}o=Math.max(...s.filter(a=>a!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(r,{adjustments:n,behavior:o})=>{this.options.scrollToFn(r,{behavior:o,adjustments:n},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let n=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=n?n[0]:this.scrollState.lastTargetOffset,s=1,i=o!==this.scrollState.lastTargetOffset;if(!i&&x4(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=s){this.scrollState=null;return}}else this.scrollState.stableFrames=0,i&&(this.scrollState.lastTargetOffset=o,this.scrollState.behavior="auto",this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}},E4=(t,e,r,n)=>{for(;t<=e;){let o=(t+e)/2|0,s=r(o);if(s<n)t=o+1;else if(s>n)e=o-1;else return o}return t>0?t-1:0};function vU({measurements:t,outerSize:e,scrollOffset:r,lanes:n}){let o=t.length-1,s=l=>t[l].start;if(t.length<=n)return{startIndex:0,endIndex:o};let i=E4(0,o,s,r),a=i;if(n===1)for(;a<o&&t[a].end<r+e;)a++;else if(n>1){let l=Array(n).fill(0);for(;a<o&&l.some(d=>d<r+e);){let d=t[a];l[d.lane]=d.end,a++}let c=Array(n).fill(r+e);for(;i>=0&&c.some(d=>d>=r);){let d=t[i];c[d.lane]=d.start,i--}i=Math.max(0,i-i%n),a=Math.min(o,a+(n-1-a%n))}return{startIndex:i,endIndex:a}}var T4=typeof document<"u"?pl.useLayoutEffect:pl.useEffect;function wU({useFlushSync:t=!0,...e}){let r=pl.useReducer(()=>({}),{})[1],n={...e,onChange:(s,i)=>{var a;t&&i?(0,I4.flushSync)(r):r(),(a=e.onChange)==null||a.call(e,s,i)}},[o]=pl.useState(()=>new Kg(n));return o.setOptions(n),T4(()=>o._didMount(),[]),T4(()=>o._willUpdate()),o}function A4(t){return wU({observeElementRect:N4,observeElementOffset:C4,scrollToFn:k4,...t})}var Ke=require("lucide-react");var Il=require("react"),ds=require("lucide-react");var vB=Re(M4(),1),wB=Re(P4(),1),Tl=require("react");var jo=require("react");var nw=[],_4=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,r=0;e<t.length;e++)(e%2?_4:nw).push(r=r+t[e])})();function NU(t){if(t<768)return!1;for(let e=0,r=nw.length;;){let n=e+r>>1;if(t<nw[n])r=n;else if(t>=_4[n])e=n+1;else return!0;if(e==r)return!1}}function R4(t){return t>=127462&&t<=127487}var D4=8205;function L4(t,e,r=!0,n=!0){return(r?B4:CU)(t,e,n)}function B4(t,e,r){if(e==t.length)return e;e&&z4(t.charCodeAt(e))&&$4(t.charCodeAt(e-1))&&e--;let n=rw(t,e);for(e+=O4(n);e<t.length;){let o=rw(t,e);if(n==D4||o==D4||r&&NU(o))e+=O4(o),n=o;else if(R4(o)){let s=0,i=e-2;for(;i>=0&&R4(rw(t,i));)s++,i-=2;if(s%2==0)break;e+=2}else break}return e}function CU(t,e,r){for(;e>0;){let n=B4(t,e-2,r);if(n<e)return n;e--}return 0}function rw(t,e){let r=t.charCodeAt(e);if(!$4(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return z4(n)?(r-55296<<10)+(n-56320)+65536:r}function z4(t){return t>=56320&&t<57344}function $4(t){return t>=55296&&t<56320}function O4(t){return t<65536?1:2}var kt=class t{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,r,n){[e,r]=hu(this,e,r);let o=[];return this.decompose(0,e,o,2),n.length&&n.decompose(0,n.length,o,3),this.decompose(r,this.length,o,1),uu.from(o,this.length-(r-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,r=this.length){[e,r]=hu(this,e,r);let n=[];return this.decompose(e,r,n,0),uu.from(n,r-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let r=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),o=new Ac(this),s=new Ac(e);for(let i=r,a=r;;){if(o.next(i),s.next(i),i=0,o.lineBreak!=s.lineBreak||o.done!=s.done||o.value!=s.value)return!1;if(a+=o.value.length,o.done||a>=n)return!0}}iter(e=1){return new Ac(this,e)}iterRange(e,r=this.length){return new Zg(this,e,r)}iterLines(e,r){let n;if(e==null)n=this.iter();else{r==null&&(r=this.lines+1);let o=this.line(e).from;n=this.iterRange(o,Math.max(o,r==this.lines+1?this.length:r<=1?0:this.line(r-1).to))}return new Qg(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?t.empty:e.length<=32?new rs(e):uu.from(rs.split(e,[]))}},rs=class t extends kt{constructor(e,r=kU(e)){super(),this.text=e,this.length=r}get lines(){return this.text.length}get children(){return null}lineInner(e,r,n,o){for(let s=0;;s++){let i=this.text[s],a=o+i.length;if((r?n:a)>=e)return new sw(o,a,n,i);o=a+1,n++}}decompose(e,r,n,o){let s=e<=0&&r>=this.length?this:new t(F4(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(o&1){let i=n.pop(),a=Jg(s.text,i.text.slice(),0,s.length);if(a.length<=32)n.push(new t(a,i.length+s.length));else{let l=a.length>>1;n.push(new t(a.slice(0,l)),new t(a.slice(l)))}}else n.push(s)}replace(e,r,n){if(!(n instanceof t))return super.replace(e,r,n);[e,r]=hu(this,e,r);let o=Jg(this.text,Jg(n.text,F4(this.text,0,e)),r),s=this.length+n.length-(r-e);return o.length<=32?new t(o,s):uu.from(t.split(o,[]),s)}sliceString(e,r=this.length,n=`
|
|
481
|
+
`){[e,r]=hu(this,e,r);let o="";for(let s=0,i=0;s<=r&&i<this.text.length;i++){let a=this.text[i],l=s+a.length;s>e&&i&&(o+=n),e<l&&r>s&&(o+=a.slice(Math.max(0,e-s),r-s)),s=l+1}return o}flatten(e){for(let r of this.text)e.push(r)}scanIdentical(){return 0}static split(e,r){let n=[],o=-1;for(let s of e)n.push(s),o+=s.length+1,n.length==32&&(r.push(new t(n,o)),n=[],o=-1);return o>-1&&r.push(new t(n,o)),r}},uu=class t extends kt{constructor(e,r){super(),this.children=e,this.length=r,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,r,n,o){for(let s=0;;s++){let i=this.children[s],a=o+i.length,l=n+i.lines-1;if((r?l:a)>=e)return i.lineInner(e,r,n,o);o=a+1,n=l+1}}decompose(e,r,n,o){for(let s=0,i=0;i<=r&&s<this.children.length;s++){let a=this.children[s],l=i+a.length;if(e<=l&&r>=i){let c=o&((i<=e?1:0)|(l>=r?2:0));i>=e&&l<=r&&!c?n.push(a):a.decompose(e-i,r-i,n,c)}i=l+1}}replace(e,r,n){if([e,r]=hu(this,e,r),n.lines<this.lines)for(let o=0,s=0;o<this.children.length;o++){let i=this.children[o],a=s+i.length;if(e>=s&&r<=a){let l=i.replace(e-s,r-s,n),c=this.lines-i.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let d=this.children.slice();return d[o]=l,new t(d,this.length-(r-e)+n.length)}return super.replace(s,a,l)}s=a+1}return super.replace(e,r,n)}sliceString(e,r=this.length,n=`
|
|
482
|
+
`){[e,r]=hu(this,e,r);let o="";for(let s=0,i=0;s<this.children.length&&i<=r;s++){let a=this.children[s],l=i+a.length;i>e&&s&&(o+=n),e<l&&r>i&&(o+=a.sliceString(e-i,r-i,n)),i=l+1}return o}flatten(e){for(let r of this.children)r.flatten(e)}scanIdentical(e,r){if(!(e instanceof t))return 0;let n=0,[o,s,i,a]=r>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;o+=r,s+=r){if(o==i||s==a)return n;let l=this.children[o],c=e.children[s];if(l!=c)return n+l.scanIdentical(c,r);n+=l.length+1}}static from(e,r=e.reduce((n,o)=>n+o.length+1,-1)){let n=0;for(let p of e)n+=p.lines;if(n<32){let p=[];for(let h of e)h.flatten(p);return new rs(p,r)}let o=Math.max(32,n>>5),s=o<<1,i=o>>1,a=[],l=0,c=-1,d=[];function u(p){let h;if(p.lines>s&&p instanceof t)for(let b of p.children)u(b);else p.lines>i&&(l>i||!l)?(f(),a.push(p)):p instanceof rs&&l&&(h=d[d.length-1])instanceof rs&&p.lines+h.lines<=32?(l+=p.lines,c+=p.length+1,d[d.length-1]=new rs(h.text.concat(p.text),h.length+1+p.length)):(l+p.lines>o&&f(),l+=p.lines,c+=p.length+1,d.push(p))}function f(){l!=0&&(a.push(d.length==1?d[0]:t.from(d,c)),c=-1,l=d.length=0)}for(let p of e)u(p);return f(),a.length==1?a[0]:new t(a,r)}};kt.empty=new rs([""],0);function kU(t){let e=-1;for(let r of t)e+=r.length+1;return e}function Jg(t,e,r=0,n=1e9){for(let o=0,s=0,i=!0;s<t.length&&o<=n;s++){let a=t[s],l=o+a.length;l>=r&&(l>n&&(a=a.slice(0,n-o)),o<r&&(a=a.slice(r-o)),i?(e[e.length-1]+=a,i=!1):e.push(a)),o=l+1}return e}function F4(t,e,r){return Jg(t,[""],e,r)}var Ac=class{constructor(e,r=1){this.dir=r,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[r>0?1:(e instanceof rs?e.text.length:e.children.length)<<1]}nextInner(e,r){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,o=this.nodes[n],s=this.offsets[n],i=s>>1,a=o instanceof rs?o.text.length:o.children.length;if(i==(r>0?a:0)){if(n==0)return this.done=!0,this.value="",this;r>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(r>0?0:1)){if(this.offsets[n]+=r,e==0)return this.lineBreak=!0,this.value=`
|
|
483
|
+
`,this;e--}else if(o instanceof rs){let l=o.text[i+(r<0?-1:0)];if(this.offsets[n]+=r,l.length>Math.max(0,e))return this.value=e==0?l:r>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=o.children[i+(r<0?-1:0)];e>l.length?(e-=l.length,this.offsets[n]+=r):(r<0&&this.offsets[n]--,this.nodes.push(l),this.offsets.push(r>0?1:(l instanceof rs?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Zg=class{constructor(e,r,n){this.value="",this.done=!1,this.cursor=new Ac(e,r>n?-1:1),this.pos=r>n?e.length:0,this.from=Math.min(r,n),this.to=Math.max(r,n)}nextInner(e,r){if(r<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,r<0?this.pos-this.to:this.from-this.pos);let n=r<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:o}=this.cursor.next(e);return this.pos+=(o.length+e)*r,this.value=o.length<=n?o:r<0?o.slice(o.length-n):o.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Qg=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:r,lineBreak:n,value:o}=this.inner.next(e);return r&&this.afterBreak?(this.value="",this.afterBreak=!1):r?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=o,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(kt.prototype[Symbol.iterator]=function(){return this.iter()},Ac.prototype[Symbol.iterator]=Zg.prototype[Symbol.iterator]=Qg.prototype[Symbol.iterator]=function(){return this});var sw=class{constructor(e,r,n,o){this.from=e,this.to=r,this.number=n,this.text=o}get length(){return this.to-this.from}};function hu(t,e,r){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,r))]}function an(t,e,r=!0,n=!0){return L4(t,e,r,n)}function EU(t){return t>=56320&&t<57344}function TU(t){return t>=55296&&t<56320}function Gn(t,e){let r=t.charCodeAt(e);if(!TU(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return EU(n)?(r-55296<<10)+(n-56320)+65536:r}function up(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function os(t){return t<65536?1:2}var iw=/\r\n?|\n/,Un=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Un||(Un={})),ya=class t{constructor(e){this.sections=e}get length(){let e=0;for(let r=0;r<this.sections.length;r+=2)e+=this.sections[r];return e}get newLength(){let e=0;for(let r=0;r<this.sections.length;r+=2){let n=this.sections[r+1];e+=n<0?this.sections[r]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let r=0,n=0,o=0;r<this.sections.length;){let s=this.sections[r++],i=this.sections[r++];i<0?(e(n,o,s),o+=s):o+=i,n+=s}}iterChangedRanges(e,r=!1){aw(this,e,r)}get invertedDesc(){let e=[];for(let r=0;r<this.sections.length;){let n=this.sections[r++],o=this.sections[r++];o<0?e.push(n,o):e.push(o,n)}return new t(e)}composeDesc(e){return this.empty?e:e.empty?this:U4(this,e)}mapDesc(e,r=!1){return e.empty?this:lw(this,e,r)}mapPos(e,r=-1,n=Un.Simple){let o=0,s=0;for(let i=0;i<this.sections.length;){let a=this.sections[i++],l=this.sections[i++],c=o+a;if(l<0){if(c>e)return s+(e-o);s+=a}else{if(n!=Un.Simple&&c>=e&&(n==Un.TrackDel&&o<e&&c>e||n==Un.TrackBefore&&o<e||n==Un.TrackAfter&&c>e))return null;if(c>e||c==e&&r<0&&!a)return e==o||r<0?s:s+l;s+=l}o=c}if(e>o)throw new RangeError(`Position ${e} is out of range for changeset of length ${o}`);return s}touchesRange(e,r=e){for(let n=0,o=0;n<this.sections.length&&o<=r;){let s=this.sections[n++],i=this.sections[n++],a=o+s;if(i>=0&&o<=r&&a>=e)return o<e&&a>r?"cover":!0;o=a}return!1}toString(){let e="";for(let r=0;r<this.sections.length;){let n=this.sections[r++],o=this.sections[r++];e+=(e?" ":"")+n+(o>=0?":"+o:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(r=>typeof r!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new t(e)}static create(e){return new t(e)}},Eo=class t extends ya{constructor(e,r){super(e),this.inserted=r}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return aw(this,(r,n,o,s,i)=>e=e.replace(o,o+(n-r),i),!1),e}mapDesc(e,r=!1){return lw(this,e,r,!0)}invert(e){let r=this.sections.slice(),n=[];for(let o=0,s=0;o<r.length;o+=2){let i=r[o],a=r[o+1];if(a>=0){r[o]=a,r[o+1]=i;let l=o>>1;for(;n.length<l;)n.push(kt.empty);n.push(i?e.slice(s,s+i):kt.empty)}s+=i}return new t(r,n)}compose(e){return this.empty?e:e.empty?this:U4(this,e,!0)}map(e,r=!1){return e.empty?this:lw(this,e,r,!0)}iterChanges(e,r=!1){aw(this,e,r)}get desc(){return ya.create(this.sections)}filter(e){let r=[],n=[],o=[],s=new Mc(this);e:for(let i=0,a=0;;){let l=i==e.length?1e9:e[i++];for(;a<l||a==l&&s.len==0;){if(s.done)break e;let d=Math.min(s.len,l-a);so(o,d,-1);let u=s.ins==-1?-1:s.off==0?s.ins:0;so(r,d,u),u>0&&hl(n,r,s.text),s.forward(d),a+=d}let c=e[i++];for(;a<c;){if(s.done)break e;let d=Math.min(s.len,c-a);so(r,d,-1),so(o,d,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(d),a+=d}}return{changes:new t(r,n),filtered:ya.create(o)}}toJSON(){let e=[];for(let r=0;r<this.sections.length;r+=2){let n=this.sections[r],o=this.sections[r+1];o<0?e.push(n):o==0?e.push([n]):e.push([n].concat(this.inserted[r>>1].toJSON()))}return e}static of(e,r,n){let o=[],s=[],i=0,a=null;function l(d=!1){if(!d&&!o.length)return;i<r&&so(o,r-i,-1);let u=new t(o,s);a=a?a.compose(u.map(a)):u,o=[],s=[],i=0}function c(d){if(Array.isArray(d))for(let u of d)c(u);else if(d instanceof t){if(d.length!=r)throw new RangeError(`Mismatched change set length (got ${d.length}, expected ${r})`);l(),a=a?a.compose(d.map(a)):d}else{let{from:u,to:f=u,insert:p}=d;if(u>f||u<0||f>r)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${r})`);let h=p?typeof p=="string"?kt.of(p.split(n||iw)):p:kt.empty,b=h.length;if(u==f&&b==0)return;u<i&&l(),u>i&&so(o,u-i,-1),so(o,f-u,b),hl(s,o,h),i=f}}return c(e),l(!a),a}static empty(e){return new t(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let r=[],n=[];for(let o=0;o<e.length;o++){let s=e[o];if(typeof s=="number")r.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((i,a)=>a&&typeof i!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)r.push(s[0],0);else{for(;n.length<o;)n.push(kt.empty);n[o]=kt.of(s.slice(1)),r.push(s[0],n[o].length)}}}return new t(r,n)}static createSet(e,r){return new t(e,r)}};function so(t,e,r,n=!1){if(e==0&&r<=0)return;let o=t.length-2;o>=0&&r<=0&&r==t[o+1]?t[o]+=e:o>=0&&e==0&&t[o]==0?t[o+1]+=r:n?(t[o]+=e,t[o+1]+=r):t.push(e,r)}function hl(t,e,r){if(r.length==0)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(r);else{for(;t.length<n;)t.push(kt.empty);t.push(r)}}function aw(t,e,r){let n=t.inserted;for(let o=0,s=0,i=0;i<t.sections.length;){let a=t.sections[i++],l=t.sections[i++];if(l<0)o+=a,s+=a;else{let c=o,d=s,u=kt.empty;for(;c+=a,d+=l,l&&n&&(u=u.append(n[i-2>>1])),!(r||i==t.sections.length||t.sections[i+1]<0);)a=t.sections[i++],l=t.sections[i++];e(o,c,s,d,u),o=c,s=d}}}function lw(t,e,r,n=!1){let o=[],s=n?[]:null,i=new Mc(t),a=new Mc(e);for(let l=-1;;){if(i.done&&a.len||a.done&&i.len)throw new Error("Mismatched change set lengths");if(i.ins==-1&&a.ins==-1){let c=Math.min(i.len,a.len);so(o,c,-1),i.forward(c),a.forward(c)}else if(a.ins>=0&&(i.ins<0||l==i.i||i.off==0&&(a.len<i.len||a.len==i.len&&!r))){let c=a.len;for(so(o,a.ins,-1);c;){let d=Math.min(i.len,c);i.ins>=0&&l<i.i&&i.len<=d&&(so(o,0,i.ins),s&&hl(s,o,i.text),l=i.i),i.forward(d),c-=d}a.next()}else if(i.ins>=0){let c=0,d=i.len;for(;d;)if(a.ins==-1){let u=Math.min(d,a.len);c+=u,d-=u,a.forward(u)}else if(a.ins==0&&a.len<d)d-=a.len,a.next();else break;so(o,c,l<i.i?i.ins:0),s&&l<i.i&&hl(s,o,i.text),l=i.i,i.forward(i.len-d)}else{if(i.done&&a.done)return s?Eo.createSet(o,s):ya.create(o);throw new Error("Mismatched change set lengths")}}}function U4(t,e,r=!1){let n=[],o=r?[]:null,s=new Mc(t),i=new Mc(e);for(let a=!1;;){if(s.done&&i.done)return o?Eo.createSet(n,o):ya.create(n);if(s.ins==0)so(n,s.len,0,a),s.next();else if(i.len==0&&!i.done)so(n,0,i.ins,a),o&&hl(o,n,i.text),i.next();else{if(s.done||i.done)throw new Error("Mismatched change set lengths");{let l=Math.min(s.len2,i.len),c=n.length;if(s.ins==-1){let d=i.ins==-1?-1:i.off?0:i.ins;so(n,l,d,a),o&&d&&hl(o,n,i.text)}else i.ins==-1?(so(n,s.off?0:s.len,l,a),o&&hl(o,n,s.textBit(l))):(so(n,s.off?0:s.len,i.off?0:i.ins,a),o&&!i.off&&hl(o,n,i.text));a=(s.ins>l||i.ins>=0&&i.len>l)&&(a||n.length>c),s.forward2(l),i.forward(l)}}}}var Mc=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,r=this.i-2>>1;return r>=e.length?kt.empty:e[r]}textBit(e){let{inserted:r}=this.set,n=this.i-2>>1;return n>=r.length&&!e?kt.empty:r[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},du=class t{constructor(e,r,n){this.from=e,this.to=r,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,r=-1){let n,o;return this.empty?n=o=e.mapPos(this.from,r):(n=e.mapPos(this.from,1),o=e.mapPos(this.to,-1)),n==this.from&&o==this.to?this:new t(n,o,this.flags)}extend(e,r=e,n=0){if(e<=this.anchor&&r>=this.anchor)return ie.range(e,r,void 0,void 0,n);let o=Math.abs(e-this.anchor)>Math.abs(r-this.anchor)?e:r;return ie.range(this.anchor,o,void 0,void 0,n)}eq(e,r=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!r||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ie.range(e.anchor,e.head)}static create(e,r,n){return new t(e,r,n)}},ie=class t{constructor(e,r){this.ranges=e,this.mainIndex=r}map(e,r=-1){return e.empty?this:t.create(this.ranges.map(n=>n.map(e,r)),this.mainIndex)}eq(e,r=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],r))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new t([this.main],0)}addRange(e,r=!0){return t.create([e].concat(this.ranges),r?0:this.mainIndex+1)}replaceRange(e,r=this.mainIndex){let n=this.ranges.slice();return n[r]=e,t.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new t(e.ranges.map(r=>du.fromJSON(r)),e.main)}static single(e,r=e){return new t([t.range(e,r)],0)}static create(e,r=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,o=0;o<e.length;o++){let s=e[o];if(s.empty?s.from<=n:s.from<n)return t.normalized(e.slice(),r);n=s.to}return new t(e,r)}static cursor(e,r=0,n,o){return du.create(e,e,(r==0?0:r<0?8:16)|(n==null?7:Math.min(6,n))|(o??16777215)<<6)}static range(e,r,n,o,s){let i=(n??16777215)<<6|(o==null?7:Math.min(6,o));return!s&&e!=r&&(s=r<e?1:-1),r<e?du.create(r,e,48|i):du.create(e,r,(s?s<0?8:16:0)|i)}static normalized(e,r=0){let n=e[r];e.sort((o,s)=>o.from-s.from),r=e.indexOf(n);for(let o=1;o<e.length;o++){let s=e[o],i=e[o-1];if(s.empty?s.from<=i.to:s.from<i.to){let a=i.from,l=Math.max(s.to,i.to);o<=r&&r--,e.splice(--o,2,s.anchor>s.head?t.range(l,a):t.range(a,l))}}return new t(e,r)}};function G4(t,e){for(let r of t.ranges)if(r.to>e)throw new RangeError("Selection points outside of document")}var xw=0,Ce=class t{constructor(e,r,n,o,s){this.combine=e,this.compareInput=r,this.compare=n,this.isStatic=o,this.id=xw++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new t(e.combine||(r=>r),e.compareInput||((r,n)=>r===n),e.compare||(e.combine?(r,n)=>r===n:yw),!!e.static,e.enables)}of(e){return new fu([],this,0,e)}compute(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new fu(e,this,1,r)}computeN(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new fu(e,this,2,r)}from(e,r){return r||(r=n=>n),this.compute([e],n=>r(n.field(e)))}};function yw(t,e){return t==e||t.length==e.length&&t.every((r,n)=>r===e[n])}var fu=class{constructor(e,r,n,o){this.dependencies=e,this.facet=r,this.type=n,this.value=o,this.id=xw++}dynamicSlot(e){var r;let n=this.value,o=this.facet.compareInput,s=this.id,i=e[s]>>1,a=this.type==2,l=!1,c=!1,d=[];for(let u of this.dependencies)u=="doc"?l=!0:u=="selection"?c=!0:(((r=e[u.id])!==null&&r!==void 0?r:1)&1)==0&&d.push(e[u.id]);return{create(u){return u.values[i]=n(u),1},update(u,f){if(l&&f.docChanged||c&&(f.docChanged||f.selection)||cw(u,d)){let p=n(u);if(a?!H4(p,u.values[i],o):!o(p,u.values[i]))return u.values[i]=p,1}return 0},reconfigure:(u,f)=>{let p,h=f.config.address[s];if(h!=null){let b=nb(f,h);if(this.dependencies.every(g=>g instanceof Ce?f.facet(g)===u.facet(g):g instanceof Jr?f.field(g,!1)==u.field(g,!1):!0)||(a?H4(p=n(u),b,o):o(p=n(u),b)))return u.values[i]=b,0}else p=n(u);return u.values[i]=p,1}}}};function H4(t,e,r){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!r(t[n],e[n]))return!1;return!0}function cw(t,e){let r=!1;for(let n of e)ap(t,n)&1&&(r=!0);return r}function IU(t,e,r){let n=r.map(l=>t[l.id]),o=r.map(l=>l.type),s=n.filter(l=>!(l&1)),i=t[e.id]>>1;function a(l){let c=[];for(let d=0;d<n.length;d++){let u=nb(l,n[d]);if(o[d]==2)for(let f of u)c.push(f);else c.push(u)}return e.combine(c)}return{create(l){for(let c of n)ap(l,c);return l.values[i]=a(l),1},update(l,c){if(!cw(l,s))return 0;let d=a(l);return e.compare(d,l.values[i])?0:(l.values[i]=d,1)},reconfigure(l,c){let d=cw(l,n),u=c.config.facets[e.id],f=c.facet(e);if(u&&!d&&yw(r,u))return l.values[i]=f,0;let p=a(l);return e.compare(p,f)?(l.values[i]=f,0):(l.values[i]=p,1)}}}var qg=Ce.define({static:!0}),Jr=class t{constructor(e,r,n,o,s){this.id=e,this.createF=r,this.updateF=n,this.compareF=o,this.spec=s,this.provides=void 0}static define(e){let r=new t(xw++,e.create,e.update,e.compare||((n,o)=>n===o),e);return e.provide&&(r.provides=e.provide(r)),r}create(e){let r=e.facet(qg).find(n=>n.field==this);return(r?.create||this.createF)(e)}slot(e){let r=e[this.id]>>1;return{create:n=>(n.values[r]=this.create(n),1),update:(n,o)=>{let s=n.values[r],i=this.updateF(s,o);return this.compareF(s,i)?0:(n.values[r]=i,1)},reconfigure:(n,o)=>{let s=n.facet(qg),i=o.facet(qg),a;return(a=s.find(l=>l.field==this))&&a!=i.find(l=>l.field==this)?(n.values[r]=a.create(n),1):o.config.address[this.id]!=null?(n.values[r]=o.field(this),0):(n.values[r]=this.create(n),1)}}}init(e){return[this,qg.of({field:this,create:e})]}get extension(){return this}},Tc={lowest:4,low:3,default:2,high:1,highest:0};function ip(t){return e=>new eb(e,t)}var oi={highest:ip(Tc.highest),high:ip(Tc.high),default:ip(Tc.default),low:ip(Tc.low),lowest:ip(Tc.lowest)},eb=class{constructor(e,r){this.inner=e,this.prec=r}},tb=class t{of(e){return new lp(this,e)}reconfigure(e){return t.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},lp=class{constructor(e,r){this.compartment=e,this.inner=r}},rb=class t{constructor(e,r,n,o,s,i){for(this.base=e,this.compartments=r,this.dynamicSlots=n,this.address=o,this.staticValues=s,this.facets=i,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let r=this.address[e.id];return r==null?e.default:this.staticValues[r>>1]}static resolve(e,r,n){let o=[],s=Object.create(null),i=new Map;for(let f of AU(e,r,i))f instanceof Jr?o.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let a=Object.create(null),l=[],c=[];for(let f of o)a[f.id]=c.length<<1,c.push(p=>f.slot(p));let d=n?.config.facets;for(let f in s){let p=s[f],h=p[0].facet,b=d&&d[f]||[];if(p.every(g=>g.type==0))if(a[h.id]=l.length<<1|1,yw(b,p))l.push(n.facet(h));else{let g=h.combine(p.map(x=>x.value));l.push(n&&h.compare(g,n.facet(h))?n.facet(h):g)}else{for(let g of p)g.type==0?(a[g.id]=l.length<<1|1,l.push(g.value)):(a[g.id]=c.length<<1,c.push(x=>g.dynamicSlot(x)));a[h.id]=c.length<<1,c.push(g=>IU(g,h,p))}}let u=c.map(f=>f(a));return new t(e,i,u,a,l,s)}};function AU(t,e,r){let n=[[],[],[],[],[]],o=new Map;function s(i,a){let l=o.get(i);if(l!=null){if(l<=a)return;let c=n[l].indexOf(i);c>-1&&n[l].splice(c,1),i instanceof lp&&r.delete(i.compartment)}if(o.set(i,a),Array.isArray(i))for(let c of i)s(c,a);else if(i instanceof lp){if(r.has(i.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(i.compartment)||i.inner;r.set(i.compartment,c),s(c,a)}else if(i instanceof eb)s(i.inner,i.prec);else if(i instanceof Jr)n[a].push(i),i.provides&&s(i.provides,a);else if(i instanceof fu)n[a].push(i),i.facet.extensions&&s(i.facet.extensions,Tc.default);else{let c=i.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${i}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(c,a)}}return s(t,Tc.default),n.reduce((i,a)=>i.concat(a))}function ap(t,e){if(e&1)return 2;let r=e>>1,n=t.status[r];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;t.status[r]=4;let o=t.computeSlot(t,t.config.dynamicSlots[r]);return t.status[r]=2|o}function nb(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}var K4=Ce.define(),dw=Ce.define({combine:t=>t.some(e=>e),static:!0}),q4=Ce.define({combine:t=>t.length?t[0]:void 0,static:!0}),Y4=Ce.define(),X4=Ce.define(),J4=Ce.define(),Z4=Ce.define({combine:t=>t.length?t[0]:!1}),io=class{constructor(e,r){this.type=e,this.value=r}static define(){return new uw}},uw=class{of(e){return new io(this,e)}},fw=class{constructor(e){this.map=e}of(e){return new Qe(this,e)}},Qe=class t{constructor(e,r){this.type=e,this.value=r}map(e){let r=this.type.map(this.value,e);return r===void 0?void 0:r==this.value?this:new t(this.type,r)}is(e){return this.type==e}static define(e={}){return new fw(e.map||(r=>r))}static mapEffects(e,r){if(!e.length)return e;let n=[];for(let o of e){let s=o.map(r);s&&n.push(s)}return n}};Qe.reconfigure=Qe.define();Qe.appendConfig=Qe.define();var kn=class t{constructor(e,r,n,o,s,i){this.startState=e,this.changes=r,this.selection=n,this.effects=o,this.annotations=s,this.scrollIntoView=i,this._doc=null,this._state=null,n&&G4(n,r.newLength),s.some(a=>a.type==t.time)||(this.annotations=s.concat(t.time.of(Date.now())))}static create(e,r,n,o,s,i){return new t(e,r,n,o,s,i)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let r of this.annotations)if(r.type==e)return r.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let r=this.annotation(t.userEvent);return!!(r&&(r==e||r.length>e.length&&r.slice(0,e.length)==e&&r[e.length]=="."))}};kn.time=io.define();kn.userEvent=io.define();kn.addToHistory=io.define();kn.remote=io.define();function MU(t,e){let r=[];for(let n=0,o=0;;){let s,i;if(n<t.length&&(o==e.length||e[o]>=t[n]))s=t[n++],i=t[n++];else if(o<e.length)s=e[o++],i=e[o++];else return r;!r.length||r[r.length-1]<s?r.push(s,i):r[r.length-1]<i&&(r[r.length-1]=i)}}function Q4(t,e,r){var n;let o,s,i;return r?(o=e.changes,s=Eo.empty(e.changes.length),i=t.changes.compose(e.changes)):(o=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),i=t.changes.compose(o)),{changes:i,selection:e.selection?e.selection.map(s):(n=t.selection)===null||n===void 0?void 0:n.map(o),effects:Qe.mapEffects(t.effects,o).concat(Qe.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function pw(t,e,r){let n=e.selection,o=pu(e.annotations);return e.userEvent&&(o=o.concat(kn.userEvent.of(e.userEvent))),{changes:e.changes instanceof Eo?e.changes:Eo.of(e.changes||[],r,t.facet(q4)),selection:n&&(n instanceof ie?n:ie.single(n.anchor,n.head)),effects:pu(e.effects),annotations:o,scrollIntoView:!!e.scrollIntoView}}function eO(t,e,r){let n=pw(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(r=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(r=!1);let i=!!e[s].sequential;n=Q4(n,pw(t,e[s],i?n.changes.newLength:t.doc.length),i)}let o=kn.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return RU(r?PU(o):o)}function PU(t){let e=t.startState,r=!0;for(let o of e.facet(Y4)){let s=o(t);if(s===!1){r=!1;break}Array.isArray(s)&&(r=r===!0?s:MU(r,s))}if(r!==!0){let o,s;if(r===!1)s=t.changes.invertedDesc,o=Eo.empty(e.doc.length);else{let i=t.changes.filter(r);o=i.changes,s=i.filtered.mapDesc(i.changes).invertedDesc}t=kn.create(e,o,t.selection&&t.selection.map(s),Qe.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(X4);for(let o=n.length-1;o>=0;o--){let s=n[o](t);s instanceof kn?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof kn?t=s[0]:t=eO(e,pu(s),!1)}return t}function RU(t){let e=t.startState,r=e.facet(J4),n=t;for(let o=r.length-1;o>=0;o--){let s=r[o](t);s&&Object.keys(s).length&&(n=Q4(n,pw(e,s,t.changes.newLength),!0))}return n==t?t:kn.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}var DU=[];function pu(t){return t==null?DU:Array.isArray(t)?t:[t]}var cr=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(cr||(cr={})),OU=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,hw;try{hw=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function _U(t){if(hw)return hw.test(t);for(let e=0;e<t.length;e++){let r=t[e];if(/\w/.test(r)||r>"\x80"&&(r.toUpperCase()!=r.toLowerCase()||OU.test(r)))return!0}return!1}function LU(t){return e=>{if(!/\S/.test(e))return cr.Space;if(_U(e))return cr.Word;for(let r=0;r<t.length;r++)if(e.indexOf(t[r])>-1)return cr.Word;return cr.Other}}var jt=class t{constructor(e,r,n,o,s,i){this.config=e,this.doc=r,this.selection=n,this.values=o,this.status=e.statusTemplate.slice(),this.computeSlot=s,i&&(i._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)ap(this,a<<1);this.computeSlot=null}field(e,r=!0){let n=this.config.address[e.id];if(n==null){if(r)throw new RangeError("Field is not present in this state");return}return ap(this,n),nb(this,n)}update(...e){return eO(this,e,!0)}applyTransaction(e){let r=this.config,{base:n,compartments:o}=r;for(let a of e.effects)a.is(tb.reconfigure)?(r&&(o=new Map,r.compartments.forEach((l,c)=>o.set(c,l)),r=null),o.set(a.value.compartment,a.value.extension)):a.is(Qe.reconfigure)?(r=null,n=a.value):a.is(Qe.appendConfig)&&(r=null,n=pu(n).concat(a.value));let s;r?s=e.startState.values.slice():(r=rb.resolve(n,o,this),s=new t(r,this.doc,this.selection,r.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let i=e.startState.facet(dw)?e.newSelection:e.newSelection.asSingle();new t(r,e.newDoc,i,s,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:e},range:ie.cursor(r.from+e.length)}))}changeByRange(e){let r=this.selection,n=e(r.ranges[0]),o=this.changes(n.changes),s=[n.range],i=pu(n.effects);for(let a=1;a<r.ranges.length;a++){let l=e(r.ranges[a]),c=this.changes(l.changes),d=c.map(o);for(let f=0;f<a;f++)s[f]=s[f].map(d);let u=o.mapDesc(c,!0);s.push(l.range.map(u)),o=o.compose(d),i=Qe.mapEffects(i,d).concat(Qe.mapEffects(pu(l.effects),u))}return{changes:o,selection:ie.create(s,r.mainIndex),effects:i}}changes(e=[]){return e instanceof Eo?e:Eo.of(e,this.doc.length,this.facet(t.lineSeparator))}toText(e){return kt.of(e.split(this.facet(t.lineSeparator)||iw))}sliceDoc(e=0,r=this.doc.length){return this.doc.sliceString(e,r,this.lineBreak)}facet(e){let r=this.config.address[e.id];return r==null?e.default:(ap(this,r),nb(this,r))}toJSON(e){let r={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let o=e[n];o instanceof Jr&&this.config.address[o.id]!=null&&(r[n]=o.spec.toJSON(this.field(e[n]),this))}return r}static fromJSON(e,r={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let o=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(e,s)){let i=n[s],a=e[s];o.push(i.init(l=>i.spec.fromJSON(a,l)))}}return t.create({doc:e.doc,selection:ie.fromJSON(e.selection),extensions:r.extensions?o.concat([r.extensions]):o})}static create(e={}){let r=rb.resolve(e.extensions||[],new Map),n=e.doc instanceof kt?e.doc:kt.of((e.doc||"").split(r.staticFacet(t.lineSeparator)||iw)),o=e.selection?e.selection instanceof ie?e.selection:ie.single(e.selection.anchor,e.selection.head):ie.single(0);return G4(o,n.length),r.staticFacet(dw)||(o=o.asSingle()),new t(r,n,o,r.dynamicSlots.map(()=>null),(s,i)=>i.create(s),null)}get tabSize(){return this.facet(t.tabSize)}get lineBreak(){return this.facet(t.lineSeparator)||`
|
|
484
|
+
`}get readOnly(){return this.facet(Z4)}phrase(e,...r){for(let n of this.facet(t.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return r.length&&(e=e.replace(/\$(\$|\d*)/g,(n,o)=>{if(o=="$")return"$";let s=+(o||1);return!s||s>r.length?n:r[s-1]})),e}languageDataAt(e,r,n=-1){let o=[];for(let s of this.facet(K4))for(let i of s(this,r,n))Object.prototype.hasOwnProperty.call(i,e)&&o.push(i[e]);return o}charCategorizer(e){let r=this.languageDataAt("wordChars",e);return LU(r.length?r[0]:"")}wordAt(e){let{text:r,from:n,length:o}=this.doc.lineAt(e),s=this.charCategorizer(e),i=e-n,a=e-n;for(;i>0;){let l=an(r,i,!1);if(s(r.slice(l,i))!=cr.Word)break;i=l}for(;a<o;){let l=an(r,a);if(s(r.slice(a,l))!=cr.Word)break;a=l}return i==a?null:ie.range(i+n,a+n)}};jt.allowMultipleSelections=dw;jt.tabSize=Ce.define({combine:t=>t.length?t[0]:4});jt.lineSeparator=q4;jt.readOnly=Z4;jt.phrases=Ce.define({compare(t,e){let r=Object.keys(t),n=Object.keys(e);return r.length==n.length&&r.every(o=>t[o]==e[o])}});jt.languageData=K4;jt.changeFilter=Y4;jt.transactionFilter=X4;jt.transactionExtender=J4;tb.reconfigure=Qe.define();function ao(t,e,r={}){let n={};for(let o of t)for(let s of Object.keys(o)){let i=o[s],a=n[s];if(a===void 0)n[s]=i;else if(!(a===i||i===void 0))if(Object.hasOwnProperty.call(r,s))n[s]=r[s](a,i);else throw new Error("Config merge conflict for field "+s)}for(let o in e)n[o]===void 0&&(n[o]=e[o]);return n}var _s=class{eq(e){return this==e}range(e,r=e){return cp.create(e,r,this)}};_s.prototype.startSide=_s.prototype.endSide=0;_s.prototype.point=!1;_s.prototype.mapMode=Un.TrackDel;function vw(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}var cp=class t{constructor(e,r,n){this.from=e,this.to=r,this.value=n}static create(e,r,n){return new t(e,r,n)}};function mw(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}var gw=class t{constructor(e,r,n,o){this.from=e,this.to=r,this.value=n,this.maxPoint=o}get length(){return this.to[this.to.length-1]}findIndex(e,r,n,o=0){let s=n?this.to:this.from;for(let i=o,a=s.length;;){if(i==a)return i;let l=i+a>>1,c=s[l]-e||(n?this.value[l].endSide:this.value[l].startSide)-r;if(l==i)return c>=0?i:a;c>=0?a=l:i=l+1}}between(e,r,n,o){for(let s=this.findIndex(r,-1e9,!0),i=this.findIndex(n,1e9,!1,s);s<i;s++)if(o(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,r){let n=[],o=[],s=[],i=-1,a=-1;for(let l=0;l<this.value.length;l++){let c=this.value[l],d=this.from[l]+e,u=this.to[l]+e,f,p;if(d==u){let h=r.mapPos(d,c.startSide,c.mapMode);if(h==null||(f=p=h,c.startSide!=c.endSide&&(p=r.mapPos(d,c.endSide),p<f)))continue}else if(f=r.mapPos(d,c.startSide),p=r.mapPos(u,c.endSide),f>p||f==p&&c.startSide>0&&c.endSide<=0)continue;(p-f||c.endSide-c.startSide)<0||(i<0&&(i=f),c.point&&(a=Math.max(a,p-f)),n.push(c),o.push(f-i),s.push(p-i))}return{mapped:n.length?new t(o,s,n,a):null,pos:i}}},Dt=class t{constructor(e,r,n,o){this.chunkPos=e,this.chunk=r,this.nextLayer=n,this.maxPoint=o}static create(e,r,n,o){return new t(e,r,n,o)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let r of this.chunk)e+=r.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:r=[],sort:n=!1,filterFrom:o=0,filterTo:s=this.length}=e,i=e.filter;if(r.length==0&&!i)return this;if(n&&(r=r.slice().sort(mw)),this.isEmpty)return r.length?t.of(r):this;let a=new ob(this,null,-1).goto(0),l=0,c=[],d=new ns;for(;a.value||l<r.length;)if(l<r.length&&(a.from-r[l].from||a.startSide-r[l].value.startSide)>=0){let u=r[l++];d.addInner(u.from,u.to,u.value)||c.push(u)}else a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(l==r.length||this.chunkEnd(a.chunkIndex)<r[l].from)&&(!i||o>this.chunkEnd(a.chunkIndex)||s<this.chunkPos[a.chunkIndex])&&d.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!i||o>a.to||s<a.from||i(a.from,a.to,a.value))&&(d.addInner(a.from,a.to,a.value)||c.push(cp.create(a.from,a.to,a.value))),a.next());return d.finishInner(this.nextLayer.isEmpty&&!c.length?t.empty:this.nextLayer.update({add:c,filter:i,filterFrom:o,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let r=[],n=[],o=-1;for(let i=0;i<this.chunk.length;i++){let a=this.chunkPos[i],l=this.chunk[i],c=e.touchesRange(a,a+l.length);if(c===!1)o=Math.max(o,l.maxPoint),r.push(l),n.push(e.mapPos(a));else if(c===!0){let{mapped:d,pos:u}=l.map(a,e);d&&(o=Math.max(o,d.maxPoint),r.push(d),n.push(u))}}let s=this.nextLayer.map(e);return r.length==0?s:new t(n,r,s||t.empty,o)}between(e,r,n){if(!this.isEmpty){for(let o=0;o<this.chunk.length;o++){let s=this.chunkPos[o],i=this.chunk[o];if(r>=s&&e<=s+i.length&&i.between(s,e-s,r-s,n)===!1)return}this.nextLayer.between(e,r,n)}}iter(e=0){return dp.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,r=0){return dp.from(e).goto(r)}static compare(e,r,n,o,s=-1){let i=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),a=r.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),l=V4(i,a,n),c=new Ic(i,l,s),d=new Ic(a,l,s);n.iterGaps((u,f,p)=>j4(c,u,d,f,p,o)),n.empty&&n.length==0&&j4(c,0,d,0,0,o)}static eq(e,r,n=0,o){o==null&&(o=999999999);let s=e.filter(d=>!d.isEmpty&&r.indexOf(d)<0),i=r.filter(d=>!d.isEmpty&&e.indexOf(d)<0);if(s.length!=i.length)return!1;if(!s.length)return!0;let a=V4(s,i),l=new Ic(s,a,0).goto(n),c=new Ic(i,a,0).goto(n);for(;;){if(l.to!=c.to||!bw(l.active,c.active)||l.point&&(!c.point||!vw(l.point,c.point)))return!1;if(l.to>o)return!0;l.next(),c.next()}}static spans(e,r,n,o,s=-1){let i=new Ic(e,null,s).goto(r),a=r,l=i.openStart;for(;;){let c=Math.min(i.to,n);if(i.point){let d=i.activeForPoint(i.to),u=i.pointFrom<r?d.length+1:i.point.startSide<0?d.length:Math.min(d.length,l);o.point(a,c,i.point,d,u,i.pointRank),l=Math.min(i.openEnd(c),d.length)}else c>a&&(o.span(a,c,i.active,l),l=i.openEnd(c));if(i.to>n)return l+(i.point&&i.to>n?1:0);a=i.to,i.next()}}static of(e,r=!1){let n=new ns;for(let o of e instanceof cp?[e]:r?BU(e):e)n.add(o.from,o.to,o.value);return n.finish()}static join(e){if(!e.length)return t.empty;let r=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let o=e[n];o!=t.empty;o=o.nextLayer)r=new t(o.chunkPos,o.chunk,r,Math.max(o.maxPoint,r.maxPoint));return r}};Dt.empty=new Dt([],[],null,-1);function BU(t){if(t.length>1)for(let e=t[0],r=1;r<t.length;r++){let n=t[r];if(mw(e,n)>0)return t.slice().sort(mw);e=n}return t}Dt.empty.nextLayer=Dt.empty;var ns=class t{finishChunk(e){this.chunks.push(new gw(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,r,n){this.addInner(e,r,n)||(this.nextLayer||(this.nextLayer=new t)).add(e,r,n)}addInner(e,r,n){let o=e-this.lastTo||n.startSide-this.last.endSide;if(o<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(r-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=r,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,r-e)),!0)}addChunk(e,r){if((e-this.lastTo||r.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,r.maxPoint),this.chunks.push(r),this.chunkPos.push(e);let n=r.value.length-1;return this.last=r.value[n],this.lastFrom=r.from[n]+e,this.lastTo=r.to[n]+e,!0}finish(){return this.finishInner(Dt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let r=Dt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,r}};function V4(t,e,r){let n=new Map;for(let s of t)for(let i=0;i<s.chunk.length;i++)s.chunk[i].maxPoint<=0&&n.set(s.chunk[i],s.chunkPos[i]);let o=new Set;for(let s of e)for(let i=0;i<s.chunk.length;i++){let a=n.get(s.chunk[i]);a!=null&&(r?r.mapPos(a):a)==s.chunkPos[i]&&!r?.touchesRange(a,a+s.chunk[i].length)&&o.add(s.chunk[i])}return o}var ob=class{constructor(e,r,n,o=0){this.layer=e,this.skip=r,this.minPoint=n,this.rank=o}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,r=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,r,!1),this}gotoInner(e,r,n){for(;this.chunkIndex<this.layer.chunk.length;){let o=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(o)||this.layer.chunkEnd(this.chunkIndex)<e||o.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let o=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],r,!0);(!n||this.rangeIndex<o)&&this.setRangeIndex(o)}this.next()}forward(e,r){(this.to-e||this.endSide-r)<0&&this.gotoInner(e,r,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],r=this.layer.chunk[this.chunkIndex],n=e+r.from[this.rangeIndex];if(this.from=n,this.to=e+r.to[this.rangeIndex],this.value=r.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},dp=class t{constructor(e){this.heap=e}static from(e,r=null,n=-1){let o=[];for(let s=0;s<e.length;s++)for(let i=e[s];!i.isEmpty;i=i.nextLayer)i.maxPoint>=n&&o.push(new ob(i,r,n,s));return o.length==1?o[0]:new t(o)}get startSide(){return this.value?this.value.startSide:0}goto(e,r=-1e9){for(let n of this.heap)n.goto(e,r);for(let n=this.heap.length>>1;n>=0;n--)ow(this.heap,n);return this.next(),this}forward(e,r){for(let n of this.heap)n.forward(e,r);for(let n=this.heap.length>>1;n>=0;n--)ow(this.heap,n);(this.to-e||this.value.endSide-r)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),ow(this.heap,0)}}};function ow(t,e){for(let r=t[e];;){let n=(e<<1)+1;if(n>=t.length)break;let o=t[n];if(n+1<t.length&&o.compare(t[n+1])>=0&&(o=t[n+1],n++),r.compare(o)<0)break;t[n]=r,t[e]=o,e=n}}var Ic=class{constructor(e,r,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=dp.from(e,r,n)}goto(e,r=-1e9){return this.cursor.goto(e,r),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=r,this.openStart=-1,this.next(),this}forward(e,r){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-r)<0;)this.removeActive(this.minActive);this.cursor.forward(e,r)}removeActive(e){Yg(this.active,e),Yg(this.activeTo,e),Yg(this.activeRank,e),this.minActive=W4(this.active,this.activeTo)}addActive(e){let r=0,{value:n,to:o,rank:s}=this.cursor;for(;r<this.activeRank.length&&(s-this.activeRank[r]||o-this.activeTo[r])>0;)r++;Xg(this.active,r,n),Xg(this.activeTo,r,o),Xg(this.activeRank,r,s),e&&Xg(e,r,this.cursor.from),this.minActive=W4(this.active,this.activeTo)}next(){let e=this.to,r=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let o=this.minActive;if(o>-1&&(this.activeTo[o]-this.cursor.from||this.active[o].endSide-this.cursor.startSide)<0){if(this.activeTo[o]>e){this.to=this.activeTo[o],this.endSide=this.active[o].endSide;break}this.removeActive(o),n&&Yg(n,o)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(n),this.cursor.next();else if(r&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let o=n.length-1;o>=0&&n[o]<e;o--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let r=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&r.push(this.active[n]);return r.reverse()}openEnd(e){let r=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)r++;return r}};function j4(t,e,r,n,o,s){t.goto(e),r.goto(n);let i=n+o,a=n,l=n-e,c=!!s.boundChange;for(let d=!1;;){let u=t.to+l-r.to,f=u||t.endSide-r.endSide,p=f<0?t.to+l:r.to,h=Math.min(p,i);if(t.point||r.point?(t.point&&r.point&&vw(t.point,r.point)&&bw(t.activeForPoint(t.to),r.activeForPoint(r.to))||s.comparePoint(a,h,t.point,r.point),d=!1):(d&&s.boundChange(a),h>a&&!bw(t.active,r.active)&&s.compareRange(a,h,t.active,r.active),c&&h<i&&(u||t.openEnd(p)!=r.openEnd(p))&&(d=!0)),p>i)break;a=p,f<=0&&t.next(),f>=0&&r.next()}}function bw(t,e){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!=e[r]&&!vw(t[r],e[r]))return!1;return!0}function Yg(t,e){for(let r=e,n=t.length-1;r<n;r++)t[r]=t[r+1];t.pop()}function Xg(t,e,r){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=r}function W4(t,e){let r=-1,n=1e9;for(let o=0;o<e.length;o++)(e[o]-n||t[o].endSide-t[r].endSide)<0&&(r=o,n=e[o]);return r}function va(t,e,r=t.length){let n=0;for(let o=0;o<r&&o<t.length;)t.charCodeAt(o)==9?(n+=e-n%e,o++):(n++,o=an(t,o));return n}function sb(t,e,r,n){for(let o=0,s=0;;){if(s>=e)return o;if(o==t.length)break;s+=t.charCodeAt(o)==9?r-s%r:1,o=an(t,o)}return n===!0?-1:t.length}var tO=typeof Symbol>"u"?"__\u037C":Symbol.for("\u037C"),ww=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),rO=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Ls=class{constructor(e,r){this.rules=[];let{finish:n}=r||{};function o(i){return/^@/.test(i)?[i]:i.split(/,\s*/)}function s(i,a,l,c){let d=[],u=/^@(\w+)\b/.exec(i[0]),f=u&&u[1]=="keyframes";if(u&&a==null)return l.push(i[0]+";");for(let p in a){let h=a[p];if(/&/.test(p))s(p.split(/,\s*/).map(b=>i.map(g=>b.replace(/&/,g))).reduce((b,g)=>b.concat(g)),h,l);else if(h&&typeof h=="object"){if(!u)throw new RangeError("The value of a property ("+p+") should be a primitive value.");s(o(p),h,d,f)}else h!=null&&d.push(p.replace(/_.*/,"").replace(/[A-Z]/g,b=>"-"+b.toLowerCase())+": "+h+";")}(d.length||f)&&l.push((n&&!u&&!c?i.map(n):i).join(", ")+" {"+d.join(" ")+"}")}for(let i in e)s(o(i),e[i],this.rules)}getRules(){return this.rules.join(`
|
|
485
|
+
`)}static newName(){let e=rO[tO]||1;return rO[tO]=e+1,"\u037C"+e.toString(36)}static mount(e,r,n){let o=e[ww],s=n&&n.nonce;o?s&&o.setNonce(s):o=new Sw(e,s),o.mount(Array.isArray(r)?r:[r],e)}},nO=new Map,Sw=class{constructor(e,r){let n=e.ownerDocument||e,o=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&o.CSSStyleSheet){let s=nO.get(n);if(s)return e[ww]=s;this.sheet=new o.CSSStyleSheet,nO.set(n,this)}else this.styleTag=n.createElement("style"),r&&this.styleTag.setAttribute("nonce",r);this.modules=[],e[ww]=this}mount(e,r){let n=this.sheet,o=0,s=0;for(let i=0;i<e.length;i++){let a=e[i],l=this.modules.indexOf(a);if(l<s&&l>-1&&(this.modules.splice(l,1),s--,l=-1),l==-1){if(this.modules.splice(s++,0,a),n)for(let c=0;c<a.rules.length;c++)n.insertRule(a.rules[c],o++)}else{for(;s<l;)o+=this.modules[s++].rules.length;o+=a.rules.length,s++}}if(n)r.adoptedStyleSheets.indexOf(this.sheet)<0&&(r.adoptedStyleSheets=[this.sheet,...r.adoptedStyleSheets]);else{let i="";for(let l=0;l<this.modules.length;l++)i+=this.modules[l].getRules()+`
|
|
486
|
+
`;this.styleTag.textContent=i;let a=r.head||r;this.styleTag.parentNode!=a&&a.insertBefore(this.styleTag,a.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var wa={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},mu={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},zU=typeof navigator<"u"&&/Mac/.test(navigator.platform),$U=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(gn=0;gn<10;gn++)wa[48+gn]=wa[96+gn]=String(gn);var gn;for(gn=1;gn<=24;gn++)wa[gn+111]="F"+gn;var gn;for(gn=65;gn<=90;gn++)wa[gn]=String.fromCharCode(gn+32),mu[gn]=String.fromCharCode(gn);var gn;for(ib in wa)mu.hasOwnProperty(ib)||(mu[ib]=wa[ib]);var ib;function oO(t){var e=zU&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||$U&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!e&&t.key||(t.shiftKey?mu:wa)[t.keyCode]||t.key||"Unidentified";return r=="Esc"&&(r="Escape"),r=="Del"&&(r="Delete"),r=="Left"&&(r="ArrowLeft"),r=="Up"&&(r="ArrowUp"),r=="Right"&&(r="ArrowRight"),r=="Down"&&(r="ArrowDown"),r}function Wt(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,r=arguments[1];if(r&&typeof r=="object"&&r.nodeType==null&&!Array.isArray(r)){for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n)){var o=r[n];typeof o=="string"?t.setAttribute(n,o):o!=null&&(t[n]=o)}e++}for(;e<arguments.length;e++)sO(t,arguments[e]);return t}function sO(t,e){if(typeof e=="string")t.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)t.appendChild(e);else if(Array.isArray(e))for(var r=0;r<e.length;r++)sO(t,e[r]);else throw new RangeError("Unsupported child node: "+e)}var To=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Rw=typeof document<"u"?document:{documentElement:{style:{}}},Dw=/Edge\/(\d+)/.exec(To.userAgent),WO=/MSIE \d/.test(To.userAgent),Ow=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(To.userAgent),Bb=!!(WO||Ow||Dw),iO=!Bb&&/gecko\/(\d+)/i.test(To.userAgent),Nw=!Bb&&/Chrome\/(\d+)/.exec(To.userAgent),aO="webkitFontSmoothing"in Rw.documentElement.style,_w=!Bb&&/Apple Computer/.test(To.vendor),lO=_w&&(/Mobile\/\w+/.test(To.userAgent)||To.maxTouchPoints>2),Ie={mac:lO||/Mac/.test(To.platform),windows:/Win/.test(To.platform),linux:/Linux|X11/.test(To.platform),ie:Bb,ie_version:WO?Rw.documentMode||6:Ow?+Ow[1]:Dw?+Dw[1]:0,gecko:iO,gecko_version:iO?+(/Firefox\/(\d+)/.exec(To.userAgent)||[0,0])[1]:0,chrome:!!Nw,chrome_version:Nw?+Nw[1]:0,ios:lO,android:/Android\b/.test(To.userAgent),webkit:aO,webkit_version:aO?+(/\bAppleWebKit\/(\d+)/.exec(To.userAgent)||[0,0])[1]:0,safari:_w,safari_version:_w?+(/\bVersion\/(\d+(\.\d+)?)/.exec(To.userAgent)||[0,0])[1]:0,tabSize:Rw.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function I1(t,e){for(let r in t)r=="class"&&e.class?e.class+=" "+t.class:r=="style"&&e.style?e.style+=";"+t.style:e[r]=t[r];return e}var vb=Object.create(null);function A1(t,e,r){if(t==e)return!0;t||(t=vb),e||(e=vb);let n=Object.keys(t),o=Object.keys(e);if(n.length-(r&&n.indexOf(r)>-1?1:0)!=o.length-(r&&o.indexOf(r)>-1?1:0))return!1;for(let s of n)if(s!=r&&(o.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function FU(t,e){for(let r=t.attributes.length-1;r>=0;r--){let n=t.attributes[r].name;e[n]==null&&t.removeAttribute(n)}for(let r in e){let n=e[r];r=="style"?t.style.cssText=n:t.getAttribute(r)!=n&&t.setAttribute(r,n)}}function cO(t,e,r){let n=!1;if(e)for(let o in e)r&&o in r||(n=!0,o=="style"?t.style.cssText="":t.removeAttribute(o));if(r)for(let o in r)e&&e[o]==r[o]||(n=!0,o=="style"?t.style.cssText=r[o]:t.setAttribute(o,r[o]));return n}function HU(t){let e=Object.create(null);for(let r=0;r<t.attributes.length;r++){let n=t.attributes[r];e[n.name]=n.value}return e}var Io=class{eq(e){return!1}updateDOM(e,r,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,r,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},qn=(function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t})(qn||(qn={})),Fe=class extends _s{constructor(e,r,n,o){super(),this.startSide=e,this.endSide=r,this.widget=n,this.spec=o}get heightRelevant(){return!1}static mark(e){return new kp(e)}static widget(e){let r=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return r+=n&&!e.inlineOrder?r>0?3e8:-4e8:r>0?1e8:-1e8,new Oc(e,r,r,n,e.widget||null,!1)}static replace(e){let r=!!e.block,n,o;if(e.isBlockGap)n=-5e8,o=4e8;else{let{start:s,end:i}=UO(e,r);n=(s?r?-3e8:-1:5e8)-1,o=(i?r?2e8:1:-6e8)+1}return new Oc(e,n,o,r,e.widget||null,!0)}static line(e){return new Ep(e)}static set(e,r=!1){return Dt.of(e,r)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Fe.none=Dt.empty;var kp=class t extends Fe{constructor(e){let{start:r,end:n}=UO(e);super(r?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?I1(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||vb}eq(e){return this==e||e instanceof t&&this.tagName==e.tagName&&A1(this.attrs,e.attrs)}range(e,r=e){if(e>=r)throw new RangeError("Mark decorations may not be empty");return super.range(e,r)}};kp.prototype.point=!1;var Ep=class t extends Fe{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof t&&this.spec.class==e.spec.class&&A1(this.spec.attributes,e.spec.attributes)}range(e,r=e){if(r!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,r)}};Ep.prototype.mapMode=Un.TrackBefore;Ep.prototype.point=!0;var Oc=class t extends Fe{constructor(e,r,n,o,s,i){super(r,n,s,e),this.block=o,this.isReplace=i,this.mapMode=o?r<=0?Un.TrackBefore:Un.TrackAfter:Un.TrackDel}get type(){return this.startSide!=this.endSide?qn.WidgetRange:this.startSide<=0?qn.WidgetBefore:qn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof t&&VU(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,r=e){if(this.isReplace&&(e>r||e==r&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&r!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,r)}};Oc.prototype.point=!0;function UO(t,e=!1){let{inclusiveStart:r,inclusiveEnd:n}=t;return r==null&&(r=t.inclusive),n==null&&(n=t.inclusive),{start:r??e,end:n??e}}function VU(t,e){return t==e||!!(t&&e&&t.compare(e))}function wu(t,e,r,n=0){let o=r.length-1;o>=0&&r[o]+n>=t?r[o]=Math.max(r[o],e):r.push(t,e)}var wb=class t extends _s{constructor(e,r){super(),this.tagName=e,this.attributes=r}eq(e){return e==this||e instanceof t&&this.tagName==e.tagName&&A1(this.attributes,e.attributes)}static create(e){return new t(e.tagName,e.attributes||vb)}static set(e,r=!1){return Dt.of(e,r)}};wb.prototype.startSide=wb.prototype.endSide=-1;function Tp(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Lw(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function mp(t,e){if(!e.anchorNode)return!1;try{return Lw(t,e.anchorNode)}catch{return!1}}function gp(t){return t.nodeType==3?Ap(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function bp(t,e,r,n){return r?dO(t,e,r,n,-1)||dO(t,e,r,n,1):!1}function bl(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Sb(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function dO(t,e,r,n,o){for(;;){if(t==r&&e==n)return!0;if(e==(o<0?0:Ca(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=bl(t)+(o<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(o<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=o<0?Ca(t):0}else return!1}}function Ca(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ip(t,e){let r=e?t.left:t.right;return{left:r,right:r,top:t.top,bottom:t.bottom}}function jU(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function GO(t,e){let r=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.width-t.offsetWidth)<1)&&(r=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:r,scaleY:n}}function WU(t,e,r,n,o,s,i,a){let l=t.ownerDocument,c=l.defaultView||window;for(let d=t,u=!1;d&&!u;)if(d.nodeType==1){let f,p=d==l.body,h=1,b=1;if(p)f=jU(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(d).position)&&(u=!0),d.scrollHeight<=d.clientHeight&&d.scrollWidth<=d.clientWidth){d=d.assignedSlot||d.parentNode;continue}let y=d.getBoundingClientRect();({scaleX:h,scaleY:b}=GO(d,y)),f={left:y.left,right:y.left+d.clientWidth*h,top:y.top,bottom:y.top+d.clientHeight*b}}let g=0,x=0;if(o=="nearest")e.top<f.top?(x=e.top-(f.top+i),r>0&&e.bottom>f.bottom+x&&(x=e.bottom-f.bottom+i)):e.bottom>f.bottom&&(x=e.bottom-f.bottom+i,r<0&&e.top-x<f.top&&(x=e.top-(f.top+i)));else{let y=e.bottom-e.top,m=f.bottom-f.top;x=(o=="center"&&y<=m?e.top+y/2-m/2:o=="start"||o=="center"&&r<0?e.top-i:e.bottom-m+i)-f.top}if(n=="nearest"?e.left<f.left?(g=e.left-(f.left+s),r>0&&e.right>f.right+g&&(g=e.right-f.right+s)):e.right>f.right&&(g=e.right-f.right+s,r<0&&e.left<f.left+g&&(g=e.left-(f.left+s))):g=(n=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:n=="start"==a?e.left-s:e.right-(f.right-f.left)+s)-f.left,g||x)if(p)c.scrollBy(g,x);else{let y=0,m=0;if(x){let v=d.scrollTop;d.scrollTop+=x/b,m=(d.scrollTop-v)*b}if(g){let v=d.scrollLeft;d.scrollLeft+=g/h,y=(d.scrollLeft-v)*h}e={left:e.left-y,top:e.top-m,right:e.right-y,bottom:e.bottom-m},y&&Math.abs(y-g)<1&&(n="nearest"),m&&Math.abs(m-x)<1&&(o="nearest")}if(p)break;(e.top<f.top||e.bottom>f.bottom||e.left<f.left||e.right>f.right)&&(e={left:Math.max(e.left,f.left),right:Math.min(e.right,f.right),top:Math.max(e.top,f.top),bottom:Math.min(e.bottom,f.bottom)}),d=d.assignedSlot||d.parentNode}else if(d.nodeType==11)d=d.host;else break}function KO(t,e=!0){let r=t.ownerDocument,n=null,o=null;for(let s=t.parentNode;s&&!(s==r.body||(!e||n)&&o);)if(s.nodeType==1)!o&&s.scrollHeight>s.clientHeight&&(o=s),e&&!n&&s.scrollWidth>s.clientWidth&&(n=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:n,y:o}}var Bw=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:r,focusNode:n}=e;this.set(r,Math.min(e.anchorOffset,r?Ca(r):0),n,Math.min(e.focusOffset,n?Ca(n):0))}set(e,r,n,o){this.anchorNode=e,this.anchorOffset=r,this.focusNode=n,this.focusOffset=o}},Pc=null;Ie.safari&&Ie.safari_version>=26&&(Pc=!1);function qO(t){if(t.setActive)return t.setActive();if(Pc)return t.focus(Pc);let e=[];for(let r=t;r&&(e.push(r,r.scrollTop,r.scrollLeft),r!=r.ownerDocument);r=r.parentNode);if(t.focus(Pc==null?{get preventScroll(){return Pc={preventScroll:!0},!0}}:void 0),!Pc){Pc=!1;for(let r=0;r<e.length;){let n=e[r++],o=e[r++],s=e[r++];n.scrollTop!=o&&(n.scrollTop=o),n.scrollLeft!=s&&(n.scrollLeft=s)}}}var uO;function Ap(t,e,r=e){let n=uO||(uO=document.createRange());return n.setEnd(t,r),n.setStart(t,e),n}function Su(t,e,r,n){let o={key:e,code:e,keyCode:r,which:r,cancelable:!0};n&&({altKey:o.altKey,ctrlKey:o.ctrlKey,shiftKey:o.shiftKey,metaKey:o.metaKey}=n);let s=new KeyboardEvent("keydown",o);s.synthetic=!0,t.dispatchEvent(s);let i=new KeyboardEvent("keyup",o);return i.synthetic=!0,t.dispatchEvent(i),s.defaultPrevented||i.defaultPrevented}function UU(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function GU(t,e){let r=e.focusNode,n=e.focusOffset;if(!r||e.anchorNode!=r||e.anchorOffset!=n)return!1;for(n=Math.min(n,Ca(r));;)if(n){if(r.nodeType!=1)return!1;let o=r.childNodes[n-1];o.contentEditable=="false"?n--:(r=o,n=Ca(r))}else{if(r==t)return!0;n=bl(r),r=r.parentNode}}function YO(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function XO(t,e){for(let r=t,n=e;;){if(r.nodeType==3&&n>0)return{node:r,offset:n};if(r.nodeType==1&&n>0){if(r.contentEditable=="false")return null;r=r.childNodes[n-1],n=Ca(r)}else if(r.parentNode&&!Sb(r))n=bl(r),r=r.parentNode;else return null}}function JO(t,e){for(let r=t,n=e;;){if(r.nodeType==3&&n<r.nodeValue.length)return{node:r,offset:n};if(r.nodeType==1&&n<r.childNodes.length){if(r.contentEditable=="false")return null;r=r.childNodes[n],n=0}else if(r.parentNode&&!Sb(r))n=bl(r)+1,r=r.parentNode;else return null}}var zi=class t{constructor(e,r,n=!0){this.node=e,this.offset=r,this.precise=n}static before(e,r){return new t(e.parentNode,bl(e),r)}static after(e,r){return new t(e.parentNode,bl(e)+1,r)}},Xt=(function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t})(Xt||(Xt={})),_c=Xt.LTR,M1=Xt.RTL;function ZO(t){let e=[];for(let r=0;r<t.length;r++)e.push(1<<+t[r]);return e}var KU=ZO("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),qU=ZO("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),zw=Object.create(null),Bi=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),r=t.charCodeAt(1);zw[e]=r,zw[r]=-e}function QO(t){return t<=247?KU[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?qU[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}var YU=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,$s=class{get dir(){return this.level%2?M1:_c}constructor(e,r,n){this.from=e,this.to=r,this.level=n}side(e,r){return this.dir==r==e?this.to:this.from}forward(e,r){return e==(this.dir==r)}static find(e,r,n,o){let s=-1;for(let i=0;i<e.length;i++){let a=e[i];if(a.from<=r&&a.to>=r){if(a.level==n)return i;(s<0||(o!=0?o<0?a.from<r:a.to>r:e[s].level>a.level))&&(s=i)}}if(s<0)throw new RangeError("Index out of range");return s}};function e_(t,e){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++){let n=t[r],o=e[r];if(n.from!=o.from||n.to!=o.to||n.direction!=o.direction||!e_(n.inner,o.inner))return!1}return!0}var pr=[];function XU(t,e,r,n,o){for(let s=0;s<=n.length;s++){let i=s?n[s-1].to:e,a=s<n.length?n[s].from:r,l=s?256:o;for(let c=i,d=l,u=l;c<a;c++){let f=QO(t.charCodeAt(c));f==512?f=d:f==8&&u==4&&(f=16),pr[c]=f==4?2:f,f&7&&(u=f),d=f}for(let c=i,d=l,u=l;c<a;c++){let f=pr[c];if(f==128)c<a-1&&d==pr[c+1]&&d&24?f=pr[c]=d:pr[c]=256;else if(f==64){let p=c+1;for(;p<a&&pr[p]==64;)p++;let h=c&&d==8||p<r&&pr[p]==8?u==1?1:8:256;for(let b=c;b<p;b++)pr[b]=h;c=p-1}else f==8&&u==1&&(pr[c]=1);d=f,f&7&&(u=f)}}}function JU(t,e,r,n,o){let s=o==1?2:1;for(let i=0,a=0,l=0;i<=n.length;i++){let c=i?n[i-1].to:e,d=i<n.length?n[i].from:r;for(let u=c,f,p,h;u<d;u++)if(p=zw[f=t.charCodeAt(u)])if(p<0){for(let b=a-3;b>=0;b-=3)if(Bi[b+1]==-p){let g=Bi[b+2],x=g&2?o:g&4?g&1?s:o:0;x&&(pr[u]=pr[Bi[b]]=x),a=b;break}}else{if(Bi.length==189)break;Bi[a++]=u,Bi[a++]=f,Bi[a++]=l}else if((h=pr[u])==2||h==1){let b=h==o;l=b?0:1;for(let g=a-3;g>=0;g-=3){let x=Bi[g+2];if(x&2)break;if(b)Bi[g+2]|=2;else{if(x&4)break;Bi[g+2]|=4}}}}}function ZU(t,e,r,n){for(let o=0,s=n;o<=r.length;o++){let i=o?r[o-1].to:t,a=o<r.length?r[o].from:e;for(let l=i;l<a;){let c=pr[l];if(c==256){let d=l+1;for(;;)if(d==a){if(o==r.length)break;d=r[o++].to,a=o<r.length?r[o].from:e}else if(pr[d]==256)d++;else break;let u=s==1,f=(d<e?pr[d]:n)==1,p=u==f?u?1:2:n;for(let h=d,b=o,g=b?r[b-1].to:t;h>l;)h==g&&(h=r[--b].from,g=b?r[b-1].to:t),pr[--h]=p;l=d}else s=c,l++}}}function $w(t,e,r,n,o,s,i){let a=n%2?2:1;if(n%2==o%2)for(let l=e,c=0;l<r;){let d=!0,u=!1;if(c==s.length||l<s[c].from){let b=pr[l];b!=a&&(d=!1,u=b==16)}let f=!d&&a==1?[]:null,p=d?n:n+1,h=l;e:for(;;)if(c<s.length&&h==s[c].from){if(u)break e;let b=s[c];if(!d)for(let g=b.to,x=c+1;;){if(g==r)break e;if(x<s.length&&s[x].from==g)g=s[x++].to;else{if(pr[g]==a)break e;break}}if(c++,f)f.push(b);else{b.from>l&&i.push(new $s(l,b.from,p));let g=b.direction==_c!=!(p%2);Fw(t,g?n+1:n,o,b.inner,b.from,b.to,i),l=b.to}h=b.to}else{if(h==r||(d?pr[h]!=a:pr[h]==a))break;h++}f?$w(t,l,h,n+1,o,f,i):l<h&&i.push(new $s(l,h,p)),l=h}else for(let l=r,c=s.length;l>e;){let d=!0,u=!1;if(!c||l>s[c-1].to){let b=pr[l-1];b!=a&&(d=!1,u=b==16)}let f=!d&&a==1?[]:null,p=d?n:n+1,h=l;e:for(;;)if(c&&h==s[c-1].to){if(u)break e;let b=s[--c];if(!d)for(let g=b.from,x=c;;){if(g==e)break e;if(x&&s[x-1].to==g)g=s[--x].from;else{if(pr[g-1]==a)break e;break}}if(f)f.push(b);else{b.to<l&&i.push(new $s(b.to,l,p));let g=b.direction==_c!=!(p%2);Fw(t,g?n+1:n,o,b.inner,b.from,b.to,i),l=b.from}h=b.from}else{if(h==e||(d?pr[h-1]!=a:pr[h-1]==a))break;h--}f?$w(t,h,l,n+1,o,f,i):h<l&&i.push(new $s(h,l,p)),l=h}}function Fw(t,e,r,n,o,s,i){let a=e%2?2:1;XU(t,o,s,n,a),JU(t,o,s,n,a),ZU(o,s,n,a),$w(t,o,s,e,r,n,i)}function QU(t,e,r){if(!t)return[new $s(0,0,e==M1?1:0)];if(e==_c&&!r.length&&!YU.test(t))return t_(t.length);if(r.length)for(;t.length>pr.length;)pr[pr.length]=256;let n=[],o=e==_c?0:1;return Fw(t,o,o,r,0,t.length,n),n}function t_(t){return[new $s(0,t,0)]}var r_="";function eG(t,e,r,n,o){var s;let i=n.head-t.from,a=$s.find(e,i,(s=n.bidiLevel)!==null&&s!==void 0?s:-1,n.assoc),l=e[a],c=l.side(o,r);if(i==c){let f=a+=o?1:-1;if(f<0||f>=e.length)return null;l=e[a=f],i=l.side(!o,r),c=l.side(o,r)}let d=an(t.text,i,l.forward(o,r));(d<l.from||d>l.to)&&(d=c),r_=t.text.slice(Math.min(i,d),Math.max(i,d));let u=a==(o?e.length-1:0)?null:e[a+(o?1:-1)];return u&&d==c&&u.level+(o?0:1)<l.level?ie.cursor(u.side(!o,r)+t.from,u.forward(o,r)?1:-1,u.level):ie.cursor(d+t.from,l.forward(o,r)?-1:1,l.level)}function tG(t,e,r){for(let n=e;n<r;n++){let o=QO(t.charCodeAt(n));if(o==1)return _c;if(o==2||o==4)return M1}return _c}var n_=Ce.define(),o_=Ce.define(),s_=Ce.define(),i_=Ce.define(),Hw=Ce.define(),a_=Ce.define(),l_=Ce.define(),P1=Ce.define(),R1=Ce.define(),c_=Ce.define({combine:t=>t.some(e=>e)}),d_=Ce.define({combine:t=>t.some(e=>e)}),u_=Ce.define(),xp=class t{constructor(e,r="nearest",n="nearest",o=5,s=5,i=!1){this.range=e,this.y=r,this.x=n,this.yMargin=o,this.xMargin=s,this.isSnapshot=i}map(e){return e.empty?this:new t(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new t(ie.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},ab=Qe.define({map:(t,e)=>t.map(e)}),f_=Qe.define();function Kn(t,e,r){let n=t.facet(i_);n.length?n[0](e):window.onerror&&window.onerror(String(e),r,void 0,void 0,e)||(r?console.error(r+":",e):console.error(e))}var Sa=Ce.define({combine:t=>t.length?t[0]:!0}),rG=0,bu=Ce.define({combine(t){return t.filter((e,r)=>{for(let n=0;n<r;n++)if(t[n].plugin==e.plugin)return!1;return!0})}}),Er=class t{constructor(e,r,n,o,s){this.id=e,this.create=r,this.domEventHandlers=n,this.domEventObservers=o,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(bu.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(bu.of({plugin:this,arg:e}))}static define(e,r){let{eventHandlers:n,eventObservers:o,provide:s,decorations:i}=r||{};return new t(rG++,e,n,o,a=>{let l=[];return i&&l.push(zb.of(c=>{let d=c.plugin(a);return d?i(d):Fe.none})),s&&l.push(s(a)),l})}static fromClass(e,r){return t.define((n,o)=>new e(n,o),r)}},yp=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let r=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(r)}catch(n){if(Kn(r.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(r){Kn(e.state,r,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var r;if(!((r=this.value)===null||r===void 0)&&r.destroy)try{this.value.destroy()}catch(n){Kn(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},p_=Ce.define(),D1=Ce.define(),zb=Ce.define(),h_=Ce.define(),O1=Ce.define(),Mp=Ce.define(),m_=Ce.define();function fO(t,e){let r=t.state.facet(m_);if(!r.length)return r;let n=r.map(s=>s instanceof Function?s(t):s),o=[];return Dt.spans(n,e.from,e.to,{point(){},span(s,i,a,l){let c=s-e.from,d=i-e.from,u=o;for(let f=a.length-1;f>=0;f--,l--){let p=a[f].spec.bidiIsolate,h;if(p==null&&(p=tG(e.text,c,d)),l>0&&u.length&&(h=u[u.length-1]).to==c&&h.direction==p)h.to=d,u=h.inner;else{let b={from:c,to:d,direction:p,inner:[]};u.push(b),u=b.inner}}}}),o}var g_=Ce.define();function _1(t){let e=0,r=0,n=0,o=0;for(let s of t.state.facet(g_)){let i=s(t);i&&(i.left!=null&&(e=Math.max(e,i.left)),i.right!=null&&(r=Math.max(r,i.right)),i.top!=null&&(n=Math.max(n,i.top)),i.bottom!=null&&(o=Math.max(o,i.bottom)))}return{left:e,right:r,top:n,bottom:o}}var fp=Ce.define(),ii=class t{constructor(e,r,n,o){this.fromA=e,this.toA=r,this.fromB=n,this.toB=o}join(e){return new t(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let r=e.length,n=this;for(;r>0;r--){let o=e[r-1];if(!(o.fromA>n.toA)){if(o.toA<n.fromA)break;n=n.join(o),e.splice(r-1,1)}}return e.splice(r,0,n),e}static extendWithRanges(e,r){if(r.length==0)return e;let n=[];for(let o=0,s=0,i=0;;){let a=o<e.length?e[o].fromB:1e9,l=s<r.length?r[s]:1e9,c=Math.min(a,l);if(c==1e9)break;let d=c+i,u=c,f=d;for(;;)if(s<r.length&&r[s]<=u){let p=r[s+1];s+=2,u=Math.max(u,p);for(let h=o;h<e.length&&e[h].fromB<=u;h++)i=e[h].toA-e[h].toB;f=Math.max(f,p+i)}else if(o<e.length&&e[o].fromB<=u){let p=e[o++];u=Math.max(u,p.toB),f=Math.max(f,p.toA),i=p.toA-p.toB}else break;n.push(new t(d,f,c,u))}return n}},Nb=class t{constructor(e,r,n){this.view=e,this.state=r,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=Eo.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let o=[];this.changes.iterChangedRanges((s,i,a,l)=>o.push(new ii(s,i,a,l))),this.changedRanges=o}static create(e,r,n){return new t(e,r,n)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},nG=[],Dr=class{constructor(e,r,n=0){this.dom=e,this.length=r,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return nG}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let r=this.domAttrs;r&&FU(this.dom,r)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,r=this.posAtStart){let n=r;for(let o of this.children){if(o==e)return n;n+=o.length+o.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,r){return null}domPosFor(e,r){let n=bl(this.dom),o=this.length?e>0:r>0;return new zi(this.parent.dom,n+(o?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Cu)return e;return null}static get(e){return e.cmTile}},Nu=class extends Dr{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let r=this.dom,n=null,o,s=e?.node==r?e:null,i=0;for(let a of this.children){if(a.sync(e),i+=a.length+a.breakAfter,o=n?n.nextSibling:r.firstChild,s&&o!=a.dom&&(s.written=!0),a.dom.parentNode==r)for(;o&&o!=a.dom;)o=pO(o);else r.insertBefore(a.dom,o);n=a.dom}for(o=n?n.nextSibling:r.firstChild,s&&o&&(s.written=!0);o;)o=pO(o);this.length=i}};function pO(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}var Cu=class extends Nu{constructor(e,r){super(r),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let r=Dr.get(e);if(r&&this.owns(r))return r;e=e.parentNode}}blockTiles(e){for(let r=[],n=this,o=0,s=0;;)if(o==n.children.length){if(!r.length)return;n=n.parent,n.breakAfter&&s++,o=r.pop()}else{let i=n.children[o++];if(i instanceof Na)r.push(o),n=i,o=0;else{let a=s+i.length,l=e(i,s);if(l!==void 0)return l;s=a+i.breakAfter}}}resolveBlock(e,r){let n,o=-1,s,i=-1;if(this.blockTiles((a,l)=>{let c=l+a.length;if(e>=l&&e<=c){if(a.isWidget()&&r>=-1&&r<=1){if(a.flags&32)return!0;a.flags&16&&(n=void 0)}(l<e||e==c&&(r<-1?a.length:a.covers(1)))&&(!n||!a.isWidget()&&n.isWidget())&&(n=a,o=e-l),(c>e||e==l&&(r>1?a.length:a.covers(-1)))&&(!s||!a.isWidget()&&s.isWidget())&&(s=a,i=e-l)}}),!n&&!s)throw new Error("No tile at position "+e);return n&&r<0||!s?{tile:n,offset:o}:{tile:s,offset:i}}},Na=class t extends Nu{constructor(e,r){super(e),this.wrapper=r}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,r){let n=new t(r||document.createElement(e.tagName),e);return r||(n.flags|=4),n}},ku=class t extends Nu{constructor(e,r){super(e),this.attrs=r}isLine(){return!0}static start(e,r,n){let o=new t(r||document.createElement("div"),e);return(!r||!n)&&(o.flags|=4),o}get domAttrs(){return this.attrs}resolveInline(e,r,n){let o=null,s=-1,i=null,a=-1;function l(d,u){for(let f=0,p=0;f<d.children.length&&p<=u;f++){let h=d.children[f],b=p+h.length;b>=u&&(h.isComposite()?l(h,u-p):(!i||i.isHidden&&(r>0||n&&sG(i,h)))&&(b>u||h.flags&32)?(i=h,a=u-p):(p<u||h.flags&16&&!h.isHidden)&&(o=h,s=u-p)),p=b}}l(this,e);let c=(r<0?o:i)||o||i;return c?{tile:c,offset:c==o?s:a}:null}coordsIn(e,r){let n=this.resolveInline(e,r,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),r):oG(this)}domIn(e,r){let n=this.resolveInline(e,r);if(n){let{tile:o,offset:s}=n;if(this.dom.contains(o.dom))return o.isText()?new zi(o.dom,Math.min(o.dom.nodeValue.length,s)):o.domPosFor(s,o.flags&16?1:o.flags&32?-1:r);let i=n.tile.parent,a=!1;for(let l of i.children){if(a)return new zi(l.dom,0);l==n.tile&&(a=!0)}}return new zi(this.dom,0)}};function oG(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let r=gp(e);return r[r.length-1]||null}function sG(t,e){let r=t.coordsIn(0,1),n=e.coordsIn(0,1);return r&&n&&n.top<r.bottom}var Fo=class t extends Nu{constructor(e,r){super(e),this.mark=r}get domAttrs(){return this.mark.attrs}static of(e,r){let n=new t(r||document.createElement(e.tagName),e);return r||(n.flags|=4),n}},Rc=class t extends Dr{constructor(e,r){super(e,r.length),this.text=r}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,r){let n=this.dom.nodeValue.length;e>n&&(e=n);let o=e,s=e,i=0;e==0&&r<0||e==n&&r>=0?Ie.chrome||Ie.gecko||(e?(o--,i=1):s<n&&(s++,i=-1)):r<0?o--:s<n&&s++;let a=Ap(this.dom,o,s).getClientRects();if(!a.length)return null;let l=a[(i?i<0:r>=0)?0:a.length-1];return Ie.safari&&!i&&l.width==0&&(l=Array.prototype.find.call(a,c=>c.width)||l),i?Ip(l,i<0):l||null}static of(e,r){let n=new t(r||document.createTextNode(e),e);return r||(n.flags|=2),n}},Lc=class t extends Dr{constructor(e,r,n,o){super(e,r,o),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,r){return this.coordsInWidget(e,r,!1)}coordsInWidget(e,r,n){let o=this.widget.coordsAt(this.dom,e,r);if(o)return o;if(n)return Ip(this.dom.getBoundingClientRect(),this.length?e==0:r<=0);{let s=this.dom.getClientRects(),i=null;if(!s.length)return null;let a=this.flags&16?!0:this.flags&32?!1:e>0;for(let l=a?s.length-1:0;i=s[l],!(e>0?l==0:l==s.length-1||i.top<i.bottom);l+=a?-1:1);return Ip(i,!a)}}get overrideDOMText(){if(!this.length)return kt.empty;let{root:e}=this;if(!e)return kt.empty;let r=this.posAtStart;return e.view.state.doc.slice(r,r+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,r,n,o,s){return s||(s=e.toDOM(r),e.editable||(s.contentEditable="false")),new t(s,n,e,o)}},Eu=class extends Dr{constructor(e){let r=document.createElement("img");r.className="cm-widgetBuffer",r.setAttribute("aria-hidden","true"),super(r,0,e)}get isHidden(){return!0}get overrideDOMText(){return kt.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},Vw=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,r,n){let{tile:o,index:s,beforeBreak:i,parents:a}=this;for(;e||r>0;)if(o.isComposite())if(i){if(!e)break;n&&n.break(),e--,i=!1}else if(s==o.children.length){if(!e&&!a.length)break;n&&n.leave(o),i=!!o.breakAfter,{tile:o,index:s}=a.pop(),s++}else{let l=o.children[s],c=l.breakAfter;(r>0?l.length<=e:l.length<e)&&(!n||n.skip(l,0,l.length)!==!1||!l.isComposite)?(i=!!c,s++,e-=l.length):(a.push({tile:o,index:s}),o=l,s=0,n&&l.isComposite()&&n.enter(l))}else if(s==o.length)i=!!o.breakAfter,{tile:o,index:s}=a.pop(),s++;else if(e){let l=Math.min(e,o.length-s);n&&n.skip(o,s,s+l),e-=l,s+=l}else break;return this.tile=o,this.index=s,this.beforeBreak=i,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},jw=class{constructor(e,r,n,o){this.from=e,this.to=r,this.wrapper=n,this.rank=o}},Ww=class{constructor(e,r,n){this.cache=e,this.root=r,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,r,n,o){var s;this.flushBuffer();let i=this.ensureMarks(r,n),a=i.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let l=i.children[i.children.length-1]=new Rc(a.dom,a.text+e);l.parent=i}else i.append(o||Rc.of(e,(s=this.cache.find(Rc))===null||s===void 0?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,r){let n=this.curLine;n.dom!=r.line.dom&&(n.setDOM(this.cache.reused.has(r.line)?Cw(r.line.dom):r.line.dom),this.cache.reused.set(r.line,2));let o=n;for(let a=r.marks.length-1;a>=0;a--){let l=r.marks[a],c=o.lastChild;if(c instanceof Fo&&c.mark.eq(l.mark))c.dom!=l.dom&&c.setDOM(Cw(l.dom)),o=c;else{if(this.cache.reused.get(l)){let u=Dr.get(l.dom);u&&u.setDOM(Cw(l.dom))}let d=Fo.of(l.mark,l.dom);o.append(d),o=d}this.cache.reused.set(l,2)}let s=Dr.get(e.text);s&&this.cache.reused.set(s,2);let i=new Rc(e.text,e.text.nodeValue);i.flags|=8,o.append(i)}addInlineWidget(e,r,n){let o=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);o||this.flushBuffer();let s=this.ensureMarks(r,n);!o&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,r,n){this.flushBuffer(),this.ensureMarks(r,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let r=this.afterWidget||this.lastBlock;r.length+=e,this.pos+=e}addLineStart(e,r){var n;e||(e=b_);let o=ku.start(e,r||((n=this.cache.find(ku))===null||n===void 0?void 0:n.dom),!!r);this.getBlockPos().append(this.lastBlock=this.curLine=o)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,r){var n;let o=this.curLine;for(let s=e.length-1;s>=0;s--){let i=e[s],a;if(r>0&&(a=o.lastChild)&&a instanceof Fo&&a.mark.eq(i))o=a,r--;else{let l=Fo.of(i,(n=this.cache.find(Fo,c=>c.mark.eq(i)))===null||n===void 0?void 0:n.dom);o.append(l),o=l,r=0}}return o}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!hO(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Ie.ios&&hO(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(kw,0,32)||new Lc(kw.toDOM(),0,kw,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let r=new jw(e.from,e.to,e.value,e.rank),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-r.rank||this.wrappers[n-1].to-r.to)<0;)n--;this.wrappers.splice(n,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let r=this.root;for(let n of this.wrappers){let o=r.lastChild;if(n.from<this.pos&&o instanceof Na&&o.wrapper.eq(n.wrapper))r=o;else{let s=Na.of(n.wrapper,(e=this.cache.find(Na,i=>i.wrapper.eq(n.wrapper)))===null||e===void 0?void 0:e.dom);r.append(s),r=s}}return r}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let r=2|(e<0?16:32),n=this.cache.find(Eu,void 0,1);return n&&(n.flags=r),n||new Eu(r)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},Uw=class{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:o,lineBreak:s,done:i}=this.cursor.next(this.skipCount);if(this.skipCount=0,i)throw new Error("Ran out of text content when drawing inline views");this.text=o;let a=this.textOff=Math.min(e,o.length);return s?null:o.slice(0,a)}let r=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,r);return this.textOff=r,n}},Cb=[Lc,ku,Rc,Fo,Eu,Na,Cu];for(let t=0;t<Cb.length;t++)Cb[t].bucket=t;var Gw=class{constructor(e){this.view=e,this.buckets=Cb.map(()=>[]),this.index=Cb.map(()=>0),this.reused=new Map}add(e){let r=e.constructor.bucket,n=this.buckets[r];n.length<6?n.push(e):n[this.index[r]=(this.index[r]+1)%6]=e}find(e,r,n=2){let o=e.bucket,s=this.buckets[o],i=this.index[o];for(let a=s.length-1;a>=0;a--){let l=(a+i)%s.length,c=s[l];if((!r||r(c))&&!this.reused.has(c))return s.splice(l,1),l<i&&this.index[o]--,this.reused.set(c,n),c}return null}findWidget(e,r,n){let o=this.buckets[0];if(o.length)for(let s=0,i=0;;s++){if(s==o.length){if(i)return null;i=1,s=0}let a=o[s];if(!this.reused.has(a)&&(i==0?a.widget.compare(e):a.widget.constructor==e.constructor&&e.updateDOM(a.dom,this.view,a.widget)))return o.splice(s,1),s<this.index[0]&&this.index[0]--,a.widget==e&&a.length==r&&(a.flags&497)==n?(this.reused.set(a,1),a):(this.reused.set(a,2),new Lc(a.dom,r,e,a.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,r=2){if(!this.reused.has(e))return this.reused.set(e,r),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},Kw=class{constructor(e,r,n,o,s){this.view=e,this.decorations=o,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new Gw(e),this.text=new Uw(e.state.doc),this.builder=new Ww(this.cache,new Cu(e,e.contentDOM),Dt.iter(n)),this.cache.reused.set(r,2),this.old=new Vw(r),this.reuseWalker={skip:(i,a,l)=>{if(this.cache.add(i),i.isComposite())return!1},enter:i=>this.cache.add(i),leave:()=>{},break:()=>{}}}run(e,r){let n=r&&this.getCompositionContext(r.text);for(let o=0,s=0,i=0;;){let a=i<e.length?e[i++]:null,l=a?a.fromA:this.old.root.length;if(l>o){let c=l-o;this.preserve(c,!i,!a),o=l,s+=c}if(!a)break;r&&a.fromA<=r.range.fromA&&a.toA>=r.range.toA?(this.forward(a.fromA,r.range.fromA,r.range.fromA<r.range.toA?1:-1),this.emit(s,r.range.fromB),this.cache.clear(),this.builder.addComposition(r,n),this.text.skip(r.range.toB-r.range.fromB),this.forward(r.range.fromA,a.toA),this.emit(r.range.toB,a.toB)):(this.forward(a.fromA,a.toA),this.emit(s,a.toB)),s=a.toB,o=a.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,r,n){let o=lG(this.old),s=this.openMarks;this.old.advance(e,n?1:-1,{skip:(i,a,l)=>{if(i.isWidget())if(this.openWidget)this.builder.continueWidget(l-a);else{let c=l>0||a<i.length?Lc.of(i.widget,this.view,l-a,i.flags&496,this.cache.maybeReuse(i)):this.cache.reuse(i);c.flags&256?(c.flags&=-2,this.builder.addBlockWidget(c)):(this.builder.ensureLine(null),this.builder.addInlineWidget(c,o,s),s=o.length)}else if(i.isText())this.builder.ensureLine(null),!a&&l==i.length&&!this.cache.reused.has(i)?this.builder.addText(i.text,o,s,this.cache.reuse(i)):(this.cache.add(i),this.builder.addText(i.text.slice(a,l),o,s)),s=o.length;else if(i.isLine())i.flags&=-2,this.cache.reused.set(i,1),this.builder.addLine(i);else if(i instanceof Eu)this.cache.add(i);else if(i instanceof Fo)this.builder.ensureLine(null),this.builder.addMark(i,o,s),this.cache.reused.set(i,1),s=o.length;else return!1;this.openWidget=!1},enter:i=>{i.isLine()?this.builder.addLineStart(i.attrs,this.cache.maybeReuse(i)):(this.cache.add(i),i instanceof Fo&&o.unshift(i.mark)),this.openWidget=!1},leave:i=>{i.isLine()?o.length&&(o.length=s=0):i instanceof Fo&&(o.shift(),s=Math.min(s,o.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,r){let n=null,o=this.builder,s=0,i=Dt.spans(this.decorations,e,r,{point:(a,l,c,d,u,f)=>{if(c instanceof Oc){if(this.disallowBlockEffectsFor[f]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(l>this.view.state.doc.lineAt(a).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=d.length,u>d.length)o.continueWidget(l-a);else{let p=c.widget||(c.block?xl.block:xl.inline),h=iG(c),b=this.cache.findWidget(p,l-a,h)||Lc.of(p,this.view,l-a,h);c.block?(c.startSide>0&&o.addLineStartIfNotCovered(n),o.addBlockWidget(b)):(o.ensureLine(n),o.addInlineWidget(b,d,u))}n=null}else n=aG(n,c);l>a&&this.text.skip(l-a)},span:(a,l,c,d)=>{for(let u=a;u<l;){let f=this.text.next(Math.min(512,l-u));f==null?(o.addLineStartIfNotCovered(n),o.addBreak(),u++):(o.ensureLine(n),o.addText(f,c,u==a?d:c.length),u+=f.length),n=null}}});o.addLineStartIfNotCovered(n),this.openWidget=i>s,this.openMarks=i}forward(e,r,n=1){r-e<=10?this.old.advance(r-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(r-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let r=[],n=null;for(let o=e.parentNode;;o=o.parentNode){let s=Dr.get(o);if(o==this.view.contentDOM)break;s instanceof Fo?r.push(s):s?.isLine()?n=s:s instanceof Na||(o.nodeName=="DIV"&&!n&&o!=this.view.contentDOM?n=new ku(o,b_):n||r.push(Fo.of(new kp({tagName:o.nodeName.toLowerCase(),attributes:HU(o)}),o)))}return{line:n,marks:r}}};function hO(t,e){let r=n=>{for(let o of n.children)if((e?o.isText():o.length)||r(o))return!0;return!1};return r(t)}function iG(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}var b_={class:"cm-line"};function aG(t,e){let r=e.spec.attributes,n=e.spec.class;return!r&&!n||(t||(t={class:"cm-line"}),r&&I1(r,t),n&&(t.class+=" "+n)),t}function lG(t){let e=[];for(let r=t.parents.length;r>1;r--){let n=r==t.parents.length?t.tile:t.parents[r].tile;n instanceof Fo&&e.push(n.mark)}return e}function Cw(t){let e=Dr.get(t);return e&&e.setDOM(t.cloneNode()),t}var xl=class extends Io{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};xl.inline=new xl("span");xl.block=new xl("div");var kw=new class extends Io{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},kb=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Fe.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Cu(e,e.contentDOM),this.updateInner([new ii(0,0,0,e.state.doc.length)],null)}update(e){var r;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:d,toA:u})=>u<this.minWidthFrom||d>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let o=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((r=this.domChanged)===null||r===void 0)&&r.newSel?o=this.domChanged.newSel.head:!gG(e.changes,this.hasComposition)&&!e.selectionSet&&(o=e.state.selection.main.head));let s=o>-1?dG(this.view,e.changes,o):null;if(this.domChanged=null,this.hasComposition){let{from:d,to:u}=this.hasComposition;n=new ii(d,u,e.changes.mapPos(d,-1),e.changes.mapPos(u,1)).addToSet(n.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Ie.ie||Ie.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,a=this.blockWrappers;this.updateDeco();let l=pG(i,this.decorations,e.changes);l.length&&(n=ii.extendWithRanges(n,l));let c=hG(a,this.blockWrappers,e.changes);return c.length&&(n=ii.extendWithRanges(n,c)),s&&!n.some(d=>d.fromA<=s.range.fromA&&d.toA>=s.range.toA)&&(n=s.range.addToSet(n.slice())),this.tile.flags&2&&n.length==0?!1:(this.updateInner(n,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,r){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(r||e.length){let i=this.tile,a=new Kw(this.view,i,this.blockWrappers,this.decorations,this.dynamicDecorationMap);r&&Dr.get(r.text)&&a.cache.reused.set(Dr.get(r.text),2),this.tile=a.run(e,r),qw(i,a.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=Ie.chrome||Ie.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||n.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let o=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.tile.children)s.isWidget()&&s.widget instanceof vp&&o.push(s.dom);n.updateGaps(o)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let r of e.transactions)for(let n of r.effects)n.is(f_)&&(this.editContextFormatting=n.value)}updateSelection(e=!1,r=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,o=this.view.root.activeElement,s=o==n,i=!s&&!(this.view.state.facet(Sa)||n.tabIndex>-1)&&mp(n,this.view.observer.selectionRange)&&!(o&&n.contains(o));if(!(s||r||i))return;let a=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,c,d;if(l.empty?d=c=this.inlineDOMNearPos(l.anchor,l.assoc||1):(d=this.inlineDOMNearPos(l.head,l.head==l.from?1:-1),c=this.inlineDOMNearPos(l.anchor,l.anchor==l.from?1:-1)),Ie.gecko&&l.empty&&!this.hasComposition&&cG(c)){let f=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(f,c.node.childNodes[c.offset]||null)),c=d=new zi(f,0),a=!0}let u=this.view.observer.selectionRange;(a||!u.focusNode||(!bp(c.node,c.offset,u.anchorNode,u.anchorOffset)||!bp(d.node,d.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,l))&&(this.view.observer.ignore(()=>{Ie.android&&Ie.chrome&&n.contains(u.focusNode)&&mG(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let f=Tp(this.view.root);if(f)if(l.empty){if(Ie.gecko){let p=uG(c.node,c.offset);if(p&&p!=3){let h=(p==1?XO:JO)(c.node,c.offset);h&&(c=new zi(h.node,h.offset))}}f.collapse(c.node,c.offset),l.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=l.bidiLevel)}else if(f.extend){f.collapse(c.node,c.offset);try{f.extend(d.node,d.offset)}catch{}}else{let p=document.createRange();l.anchor>l.head&&([c,d]=[d,c]),p.setEnd(d.node,d.offset),p.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(p)}i&&this.view.root.activeElement==n&&(n.blur(),o&&o.focus())}),this.view.observer.setSelectionRange(c,d)),this.impreciseAnchor=c.precise?null:new zi(u.anchorNode,u.anchorOffset),this.impreciseHead=d.precise?null:new zi(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,r){return this.hasComposition&&r.empty&&bp(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==r.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,r=e.state.selection.main,n=Tp(e.root),{anchorNode:o,anchorOffset:s}=e.observer.selectionRange;if(!n||!r.empty||!r.assoc||!n.modify)return;let i=this.lineAt(r.head,r.assoc);if(!i)return;let a=i.posAtStart;if(r.head==a||r.head==a+i.length)return;let l=this.coordsAt(r.head,-1),c=this.coordsAt(r.head,1);if(!l||!c||l.bottom>c.top)return;let d=this.domAtPos(r.head+r.assoc,r.assoc);n.collapse(d.node,d.offset),n.modify("move",r.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=r.from&&n.collapse(o,s)}posFromDOM(e,r){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let o=n.posAtStart;if(n.isComposite()){let s;if(e==n.dom)s=n.dom.childNodes[r];else{let i=Ca(e)==0?0:r==0?-1:1;for(;;){let a=e.parentNode;if(a==n.dom)break;i==0&&a.firstChild!=a.lastChild&&(e==a.firstChild?i=-1:i=1),e=a}i<0?s=e:s=e.nextSibling}if(s==n.dom.firstChild)return o;for(;s&&!Dr.get(s);)s=s.nextSibling;if(!s)return o+n.length;for(let i=0,a=o;;i++){let l=n.children[i];if(l.dom==s)return a;a+=l.length+l.breakAfter}}else return n.isText()?e==n.dom?o+r:o+(r?n.length:0):o}domAtPos(e,r){let{tile:n,offset:o}=this.tile.resolveBlock(e,r);return n.isWidget()?n.domPosFor(e,r):n.domIn(o,r)}inlineDOMNearPos(e,r){let n,o=-1,s=!1,i,a=-1,l=!1;return this.tile.blockTiles((c,d)=>{if(c.isWidget()){if(c.flags&32&&d>=e)return!0;c.flags&16&&(s=!0)}else{let u=d+c.length;if(d<=e&&(n=c,o=e-d,s=u<e),u>=e&&!i&&(i=c,a=e-d,l=d>e),d>e&&i)return!0}}),!n&&!i?this.domAtPos(e,r):(s&&i?n=null:l&&n&&(i=null),n&&r<0||!i?n.domIn(o,r):i.domIn(a,r))}coordsAt(e,r){let{tile:n,offset:o}=this.tile.resolveBlock(e,r);return n.isWidget()?n.widget instanceof vp?null:n.coordsInWidget(o,r,!0):n.coordsIn(o,r)}lineAt(e,r){let{tile:n}=this.tile.resolveBlock(e,r);return n.isLine()?n:null}coordsForChar(e){let{tile:r,offset:n}=this.tile.resolveBlock(e,1);if(!r.isLine())return null;function o(s,i){if(s.isComposite())for(let a of s.children){if(a.length>=i){let l=o(a,i);if(l)return l}if(i-=a.length,i<0)break}else if(s.isText()&&i<s.length){let a=an(s.text,i);if(a==i)return null;let l=Ap(s.dom,i,a).getClientRects();for(let c=0;c<l.length;c++){let d=l[c];if(c==l.length-1||d.top<d.bottom&&d.left<d.right)return d}}return null}return o(r,n)}measureVisibleLineHeights(e){let r=[],{from:n,to:o}=e,s=this.view.contentDOM.clientWidth,i=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==Xt.LTR,c=0,d=(u,f,p)=>{for(let h=0;h<u.children.length&&!(f>o);h++){let b=u.children[h],g=f+b.length,x=b.dom.getBoundingClientRect(),{height:y}=x;if(p&&!h&&(c+=x.top-p.top),b instanceof Na)g>n&&d(b,f,x);else if(f>=n&&(c>0&&r.push(-c),r.push(y+c),c=0,i)){let m=b.dom.lastChild,v=m?gp(m):[];if(v.length){let S=v[v.length-1],w=l?S.right-x.left:x.right-S.left;w>a&&(a=w,this.minWidth=s,this.minWidthFrom=f,this.minWidthTo=g)}}p&&h==u.children.length-1&&(c+=p.bottom-x.bottom),f=g+b.breakAfter}};return d(this.tile,0,null),r}textDirectionAt(e){let{tile:r}=this.tile.resolveBlock(e,1);return getComputedStyle(r.dom).direction=="rtl"?Xt.RTL:Xt.LTR}measureTextSize(){let e=this.tile.blockTiles(i=>{if(i.isLine()&&i.children.length&&i.length<=20){let a=0,l;for(let c of i.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let d=gp(c.dom);if(d.length!=1)return;a+=d[0].width,l=d[0].height}if(a)return{lineHeight:i.dom.getBoundingClientRect().height,charWidth:a/i.length,textHeight:l}}});if(e)return e;let r=document.createElement("div"),n,o,s;return r.className="cm-line",r.style.width="99999px",r.style.position="absolute",r.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(r);let i=gp(r.firstChild)[0];n=r.getBoundingClientRect().height,o=i&&i.width?i.width/27:7,s=i&&i.height?i.height:n,r.remove()}),{lineHeight:n,charWidth:o,textHeight:s}}computeBlockGapDeco(){let e=[],r=this.view.viewState;for(let n=0,o=0;;o++){let s=o==r.viewports.length?null:r.viewports[o],i=s?s.from-1:this.view.state.doc.length;if(i>n){let a=(r.lineBlockAt(i).bottom-r.lineBlockAt(n).top)/this.view.scaleY;e.push(Fe.replace({widget:new vp(a),block:!0,inclusive:!0,isBlockGap:!0}).range(n,i))}if(!s)break;n=s.to+1}return Fe.set(e)}updateDeco(){let e=1,r=this.view.state.facet(zb).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),n=!1,o=this.view.state.facet(O1).map((s,i)=>{let a=typeof s=="function";return a&&(n=!0),a?s(this.view):s});for(o.length&&(this.dynamicDecorationMap[e++]=n,r.push(Dt.join(o))),this.decorations=[this.editContextFormatting,...r,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(h_).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(e){var r;if(e.isSnapshot){let d=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=d.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let d of this.view.state.facet(u_))try{if(d(this.view,e.range,e))return!0}catch(u){Kn(this.view.state,u,"scroll handler")}let{range:n}=e,o=this.coordsAt(n.head,(r=n.assoc)!==null&&r!==void 0?r:n.empty?0:n.head>n.anchor?-1:1),s;if(!o)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(o={left:Math.min(o.left,s.left),top:Math.min(o.top,s.top),right:Math.max(o.right,s.right),bottom:Math.max(o.bottom,s.bottom)});let i=_1(this.view),a={left:o.left-i.left,top:o.top-i.top,right:o.right+i.right,bottom:o.bottom+i.bottom},{offsetWidth:l,offsetHeight:c}=this.view.scrollDOM;if(WU(this.view.scrollDOM,a,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,c),-c),this.view.textDirection==Xt.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(o.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||o.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let d=this.view.docView.lineAt(n.head,1);d&&d.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let r=n=>n.isWidget()||n.children.some(r);return r(this.tile.resolveBlock(e,1).tile)}destroy(){qw(this.tile)}};function qw(t,e){let r=e?.get(t);if(r!=1){r==null&&t.destroy();for(let n of t.children)qw(n,e)}}function cG(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function x_(t,e){let r=t.observer.selectionRange;if(!r.focusNode)return null;let n=XO(r.focusNode,r.focusOffset),o=JO(r.focusNode,r.focusOffset),s=n||o;if(o&&n&&o.node!=n.node){let a=Dr.get(o.node);if(!a||a.isText()&&a.text!=o.node.nodeValue)s=o;else if(t.docView.lastCompositionAfterCursor){let l=Dr.get(n.node);!l||l.isText()&&l.text!=n.node.nodeValue||(s=o)}}if(t.docView.lastCompositionAfterCursor=s!=n,!s)return null;let i=e-s.offset;return{from:i,to:i+s.node.nodeValue.length,node:s.node}}function dG(t,e,r){let n=x_(t,r);if(!n)return null;let{node:o,from:s,to:i}=n,a=o.nodeValue;if(/[\n\r]/.test(a)||t.state.doc.sliceString(n.from,n.to)!=a)return null;let l=e.invertedDesc;return{range:new ii(l.mapPos(s),l.mapPos(i),s,i),text:o}}function uG(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e<t.childNodes.length&&t.childNodes[e].contentEditable=="false"?2:0)}var fG=class{constructor(){this.changes=[]}compareRange(e,r){wu(e,r,this.changes)}comparePoint(e,r){wu(e,r,this.changes)}boundChange(e){wu(e,e,this.changes)}};function pG(t,e,r){let n=new fG;return Dt.compare(t,e,r,n),n.changes}var Yw=class{constructor(){this.changes=[]}compareRange(e,r){wu(e,r,this.changes)}comparePoint(){}boundChange(e){wu(e,e,this.changes)}};function hG(t,e,r){let n=new Yw;return Dt.compare(t,e,r,n),n.changes}function mG(t,e){for(let r=t;r&&r!=e;r=r.assignedSlot||r.parentNode)if(r.nodeType==1&&r.contentEditable=="false")return!0;return!1}function gG(t,e){let r=!1;return e&&t.iterChangedRanges((n,o)=>{n<e.to&&o>e.from&&(r=!0)}),r}var vp=class extends Io{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function bG(t,e,r=1){let n=t.charCategorizer(e),o=t.doc.lineAt(e),s=e-o.from;if(o.length==0)return ie.cursor(e);s==0?r=1:s==o.length&&(r=-1);let i=s,a=s;r<0?i=an(o.text,s,!1):a=an(o.text,s);let l=n(o.text.slice(i,a));for(;i>0;){let c=an(o.text,i,!1);if(n(o.text.slice(c,i))!=l)break;i=c}for(;a<o.length;){let c=an(o.text,a);if(n(o.text.slice(a,c))!=l)break;a=c}return ie.range(i+o.from,a+o.from)}function xG(t,e,r,n,o){let s=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&r.height>t.defaultLineHeight*1.5){let a=t.viewState.heightOracle.textHeight,l=Math.floor((o-r.top-(t.defaultLineHeight-a)*.5)/a);s+=l*t.viewState.heightOracle.lineLength}let i=t.state.sliceDoc(r.from,r.to);return r.from+sb(i,s,t.state.tabSize)}function Xw(t,e,r){let n=t.lineBlockAt(e);if(Array.isArray(n.type)){let o;for(let s of n.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!o||s.type==qn.Text&&(o.type!=s.type||(r<0?s.from<e:s.to>e)))&&(o=s)}}return o||n}return n}function yG(t,e,r,n){let o=Xw(t,e.head,e.assoc||-1),s=!n||o.type!=qn.Text||!(t.lineWrapping||o.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>o.from?e.head-1:e.head);if(s){let i=t.dom.getBoundingClientRect(),a=t.textDirectionAt(o.from),l=t.posAtCoords({x:r==(a==Xt.LTR)?i.right-1:i.left+1,y:(s.top+s.bottom)/2});if(l!=null)return ie.cursor(l,r?-1:1)}return ie.cursor(r?o.to:o.from,r?-1:1)}function mO(t,e,r,n){let o=t.state.doc.lineAt(e.head),s=t.bidiSpans(o),i=t.textDirectionAt(o.from);for(let a=e,l=null;;){let c=eG(o,s,i,a,r),d=r_;if(!c){if(o.number==(r?t.state.doc.lines:1))return a;d=`
|
|
487
|
+
`,o=t.state.doc.line(o.number+(r?1:-1)),s=t.bidiSpans(o),c=t.visualLineSide(o,!r)}if(l){if(!l(d))return a}else{if(!n)return c;l=n(d)}a=c}}function vG(t,e,r){let n=t.state.charCategorizer(e),o=n(r);return s=>{let i=n(s);return o==cr.Space&&(o=i),o==i}}function wG(t,e,r,n){let o=e.head,s=r?1:-1;if(o==(r?t.state.doc.length:0))return ie.cursor(o,e.assoc);let i=e.goalColumn,a,l=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(o,e.assoc||((e.empty?r:e.head==e.from)?1:-1)),d=t.documentTop;if(c)i==null&&(i=c.left-l.left),a=s<0?c.top:c.bottom;else{let h=t.viewState.lineBlockAt(o);i==null&&(i=Math.min(l.right-l.left,t.defaultCharacterWidth*(o-h.from))),a=(s<0?h.top:h.bottom)+d}let u=l.left+i,f=t.viewState.heightOracle.textHeight>>1,p=n??f;for(let h=0;;h+=f){let b=a+(p+h)*s,g=Jw(t,{x:u,y:b},!1,s);if(r?b>l.bottom:b<l.top)return ie.cursor(g.pos,g.assoc);let x=t.coordsAtPos(g.pos,g.assoc),y=x?(x.top+x.bottom)/2:0;if(!x||(r?y>a:y<a))return ie.cursor(g.pos,g.assoc,void 0,i)}}function wp(t,e,r){for(;;){let n=0;for(let o of t)o.between(e-1,e+1,(s,i,a)=>{if(e>s&&e<i){let l=n||r||(e-s<i-e?-1:1);e=l<0?s:i,n=l}});if(!n)return e}}function y_(t,e){let r=null;for(let n=0;n<e.ranges.length;n++){let o=e.ranges[n],s=null;if(o.empty){let i=wp(t,o.from,0);i!=o.from&&(s=ie.cursor(i,-1))}else{let i=wp(t,o.from,-1),a=wp(t,o.to,1);(i!=o.from||a!=o.to)&&(s=ie.range(o.from==o.anchor?i:a,o.from==o.head?i:a))}s&&(r||(r=e.ranges.slice()),r[n]=s)}return r?ie.create(r,e.mainIndex):e}function Ew(t,e,r){let n=wp(t.state.facet(Mp).map(o=>o(t)),r.from,e.head>r.from?-1:1);return n==r.from?r:ie.cursor(n,n<r.from?1:-1)}var zs=class{constructor(e,r){this.pos=e,this.assoc=r}};function Jw(t,e,r,n){let o=t.contentDOM.getBoundingClientRect(),s=o.top+t.viewState.paddingTop,{x:i,y:a}=e,l=a-s,c;for(;;){if(l<0)return new zs(0,1);if(l>t.viewState.docHeight)return new zs(t.state.doc.length,-1);if(c=t.elementAtHeight(l),n==null)break;if(c.type==qn.Text){if(n<0?c.to<t.viewport.from:c.from>t.viewport.to)break;let f=t.docView.coordsAt(n<0?c.from:c.to,n>0?-1:1);if(f&&(n<0?f.top<=l+s:f.bottom>=l+s))break}let u=t.viewState.heightOracle.textHeight/2;l=n>0?c.bottom+u:c.top-u}if(t.viewport.from>=c.to||t.viewport.to<=c.from){if(r)return null;if(c.type==qn.Text){let u=xG(t,o,c,i,a);return new zs(u,u==c.from?1:-1)}}if(c.type!=qn.Text)return l<(c.top+c.bottom)/2?new zs(c.from,1):new zs(c.to,-1);let d=t.docView.lineAt(c.from,2);return(!d||d.length!=c.length)&&(d=t.docView.lineAt(c.from,-2)),new Zw(t,i,a,t.textDirectionAt(c.from)).scanTile(d,c.from)}var Zw=class{constructor(e,r,n,o){this.view=e,this.x=r,this.y=n,this.baseDir=o,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,r){let{line:n,spans:o}=this.bidiSpansAt(e);return o[$s.find(o,e-n.from,-1,r)].level==this.baseDir}dirAt(e,r){let{line:n,spans:o}=this.bidiSpansAt(e);return o[$s.find(o,e-n.from,-1,r)].dir}bidiIn(e,r){let{spans:n,line:o}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+o.from<r)}scan(e,r){let n=0,o=e.length-1,s=new Set,i=this.bidiIn(e[0],e[o]),a,l,c=-1,d=1e9,u;e:for(;n<o;){let p=o-n,h=n+o>>1;t:if(s.has(h)){let g=n+Math.floor(Math.random()*p);for(let x=0;x<p;x++){if(!s.has(g)){h=g;break t}g++,g==o&&(g=n)}break e}s.add(h);let b=r(h);if(b)for(let g=0;g<b.length;g++){let x=b[g],y=0;if(!(x.width==0&&b.length>1)){if(x.bottom<this.y)(!a||a.bottom<x.bottom)&&(a=x),y=1;else if(x.top>this.y)(!l||l.top>x.top)&&(l=x),y=-1;else{let m=x.left>this.x?this.x-x.left:x.right<this.x?this.x-x.right:0,v=Math.abs(m);v<d&&(c=h,d=v,u=x),m&&(y=m<0==(this.baseDir==Xt.LTR)?-1:1)}y==-1&&(!i||this.baseDirAt(e[h],1))?o=h:y==1&&(!i||this.baseDirAt(e[h+1],-1))&&(n=h+1)}}}if(!u){let p=a&&(!l||this.y-a.bottom<l.top-this.y)?a:l;return this.y=(p.top+p.bottom)/2,this.scan(e,r)}let f=(i?this.dirAt(e[c],1):this.baseDir)==Xt.LTR;return{i:c,after:this.x>(u.left+u.right)/2==f}}scanText(e,r){let n=[];for(let s=0;s<e.length;s=an(e.text,s))n.push(r+s);n.push(r+e.length);let o=this.scan(n,s=>{let i=n[s]-r,a=n[s+1]-r;return Ap(e.dom,i,a).getClientRects()});return o.after?new zs(n[o.i+1],-1):new zs(n[o.i],1)}scanTile(e,r){if(!e.length)return new zs(r,1);if(e.children.length==1){let a=e.children[0];if(a.isText())return this.scanText(a,r);if(a.isComposite())return this.scanTile(a,r)}let n=[r];for(let a=0,l=r;a<e.children.length;a++)n.push(l+=e.children[a].length);let o=this.scan(n,a=>{let l=e.children[a];return l.flags&48?null:(l.dom.nodeType==1?l.dom:Ap(l.dom,0,l.length)).getClientRects()}),s=e.children[o.i],i=n[o.i];return s.isText()?this.scanText(s,i):s.isComposite()?this.scanTile(s,i):o.after?new zs(n[o.i+1],-1):new zs(i,1)}},gu="\uFFFF",Qw=class{constructor(e,r){this.points=e,this.view=r,this.text="",this.lineSeparator=r.state.facet(jt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=gu}readRange(e,r){if(!e)return this;let n=e.parentNode;for(let o=e;;){this.findPointBefore(n,o);let s=this.text.length;this.readNode(o);let i=Dr.get(o),a=o.nextSibling;if(a==r){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let l=Dr.get(a);(i&&l?i.breakAfter:(i?i.breakAfter:Sb(o))||Sb(a)&&(o.nodeName!="BR"||i?.isWidget())&&this.text.length>s)&&!NG(a,r)&&this.lineBreak(),o=a}return this.findPointBefore(n,r),this}readTextNode(e){let r=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,r.length));for(let n=0,o=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,i=1,a;if(this.lineSeparator?(s=r.indexOf(this.lineSeparator,n),i=this.lineSeparator.length):(a=o.exec(r))&&(s=a.index,i=a[0].length),this.append(r.slice(n,s<0?r.length:s)),s<0)break;if(this.lineBreak(),i>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=i-1);n=s+i}}readNode(e){let r=Dr.get(e),n=r&&r.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let o=n.iter();!o.next().done;)o.lineBreak?this.lineBreak():this.append(o.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,r){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==r&&(n.pos=this.text.length)}findPointInside(e,r){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(SG(e,n.node,n.offset)?r:0))}};function SG(t,e,r){for(;;){if(!e||r<Ca(e))return!1;if(e==t)return!0;r=bl(e)+1,e=e.parentNode}}function NG(t,e){let r;for(;!(t==e||!t);t=t.nextSibling){let n=Dr.get(t);if(!n?.isWidget())return!1;n&&(r||(r=[])).push(n)}if(r)for(let n of r){let o=n.overrideDOMText;if(o?.length)return!1}return!0}var Eb=class{constructor(e,r){this.node=e,this.offset=r,this.pos=-1}},e1=class{constructor(e,r,n,o){this.typeOver=o,this.bounds=null,this.text="",this.domChanged=r>-1;let{impreciseHead:s,impreciseAnchor:i}=e.docView,a=e.state.selection;if(e.state.readOnly&&r>-1)this.newSel=null;else if(r>-1&&(this.bounds=v_(e.docView.tile,r,n,0))){let l=s||i?[]:kG(e),c=new Qw(l,e);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=EG(l,this.bounds.from)}else{let l=e.observer.selectionRange,c=s&&s.node==l.focusNode&&s.offset==l.focusOffset||!Lw(e.contentDOM,l.focusNode)?a.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),d=i&&i.node==l.anchorNode&&i.offset==l.anchorOffset||!Lw(e.contentDOM,l.anchorNode)?a.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),u=e.viewport;if((Ie.ios||Ie.chrome)&&a.main.empty&&c!=d&&(u.from>0||u.to<e.state.doc.length)){let f=Math.min(c,d),p=Math.max(c,d),h=u.from-f,b=u.to-p;(h==0||h==1||f==0)&&(b==0||b==-1||p==e.state.doc.length)&&(c=0,d=e.state.doc.length)}if(e.inputState.composing>-1&&a.ranges.length>1)this.newSel=a.replaceRange(ie.range(d,c));else if(e.lineWrapping&&d==c&&!(a.main.empty&&a.main.head==c)&&e.inputState.lastTouchTime>Date.now()-100){let f=e.coordsAtPos(c,-1),p=0;f&&(p=e.inputState.lastTouchY<=f.bottom?-1:1),this.newSel=ie.create([ie.cursor(c,p)])}else this.newSel=ie.single(d,c)}}};function v_(t,e,r,n){if(t.isComposite()){let o=-1,s=-1,i=-1,a=-1;for(let l=0,c=n,d=n;l<t.children.length;l++){let u=t.children[l],f=c+u.length;if(c<e&&f>r)return v_(u,e,r,c);if(f>=e&&o==-1&&(o=l,s=c),c>r&&u.dom.parentNode==t.dom){i=l,a=d;break}d=f,c=f+u.breakAfter}return{from:s,to:a<0?n+t.length:a,startDOM:(o?t.children[o-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:i<t.children.length&&i>=0?t.children[i].dom:null}}else return t.isText()?{from:n,to:n+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function w_(t,e){let r,{newSel:n}=e,{state:o}=t,s=o.selection.main,i=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:a,to:l}=e.bounds,c=s.from,d=null;(i===8||Ie.android&&e.text.length<l-a)&&(c=s.to,d="end");let u=o.doc.sliceString(a,l,gu),f,p;!s.empty&&s.from>=a&&s.to<=l&&(e.typeOver||u!=e.text)&&u.slice(0,s.from-a)==e.text.slice(0,s.from-a)&&u.slice(s.to-a)==e.text.slice(f=e.text.length-(u.length-(s.to-a)))?r={from:s.from,to:s.to,insert:kt.of(e.text.slice(s.from-a,f).split(gu))}:(p=S_(u,e.text,c-a,d))&&(Ie.chrome&&i==13&&p.toB==p.from+2&&e.text.slice(p.from,p.toB)==gu+gu&&p.toB--,r={from:a+p.from,to:a+p.toA,insert:kt.of(e.text.slice(p.from,p.toB).split(gu))})}else n&&(!t.hasFocus&&o.facet(Sa)||Tb(n,s))&&(n=null);if(!r&&!n)return!1;if((Ie.mac||Ie.android)&&r&&r.from==r.to&&r.from==s.head-1&&/^\. ?$/.test(r.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(n&&r.insert.length==2&&(n=ie.single(n.main.anchor-1,n.main.head-1)),r={from:r.from,to:r.to,insert:kt.of([r.insert.toString().replace("."," ")])}):o.doc.lineAt(s.from).to<s.to&&t.docView.lineHasWidget(s.to)&&t.inputState.insertingTextAt>Date.now()-50?r={from:s.from,to:s.to,insert:o.toText(t.inputState.insertingText)}:Ie.chrome&&r&&r.from==r.to&&r.from==s.head&&r.insert.toString()==`
|
|
488
|
+
`&&t.lineWrapping&&(n&&(n=ie.single(n.main.anchor-1,n.main.head-1)),r={from:s.from,to:s.to,insert:kt.of([" "])}),r)return L1(t,r,n,i);if(n&&!Tb(n,s)){let a=!1,l="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(a=!0),l=t.inputState.lastSelectionOrigin,l=="select.pointer"&&(n=y_(o.facet(Mp).map(c=>c(t)),n))),t.dispatch({selection:n,scrollIntoView:a,userEvent:l}),!0}else return!1}function L1(t,e,r,n=-1){if(Ie.ios&&t.inputState.flushIOSKey(e))return!0;let o=t.state.selection.main;if(Ie.android&&(e.to==o.to&&(e.from==o.from||e.from==o.from-1&&t.state.sliceDoc(e.from,o.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Su(t.contentDOM,"Enter",13)||(e.from==o.from-1&&e.to==o.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>o.head)&&Su(t.contentDOM,"Backspace",8)||e.from==o.from&&e.to==o.to+1&&e.insert.length==0&&Su(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let i,a=()=>i||(i=CG(t,e,r));return t.state.facet(a_).some(l=>l(t,e.from,e.to,s,a))||t.dispatch(a()),!0}function CG(t,e,r){let n,o=t.state,s=o.selection.main,i=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let l=e.from<s.from?-1:1,c=l<0?s.from:s.to,d=wp(o.facet(Mp).map(u=>u(t)),c,l);e.from==d&&(i=d)}if(i>-1)n={changes:e,selection:ie.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!r||r.main.empty&&r.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let l=s.from<e.from?o.sliceDoc(s.from,e.from):"",c=s.to>e.to?o.sliceDoc(e.to,s.to):"";n=o.replaceSelection(t.state.toText(l+e.insert.sliceString(0,void 0,t.state.lineBreak)+c))}else{let l=o.changes(e),c=r&&r.main.to<=l.newLength?r.main:void 0;if(o.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let d=t.state.sliceDoc(e.from,e.to),u,f=r&&x_(t,r.main.head);if(f){let h=e.insert.length-(e.to-e.from);u={from:f.from,to:f.to-h}}else u=t.state.doc.lineAt(s.head);let p=s.to-e.to;n=o.changeByRange(h=>{if(h.from==s.from&&h.to==s.to)return{changes:l,range:c||h.map(l)};let b=h.to-p,g=b-d.length;if(t.state.sliceDoc(g,b)!=d||b>=u.from&&g<=u.to)return{range:h};let x=o.changes({from:g,to:b,insert:e.insert}),y=h.to-s.to;return{changes:x,range:c?ie.range(Math.max(0,c.anchor+y),Math.max(0,c.head+y)):h.map(x)}})}else n={changes:l,selection:c&&o.selection.replaceRange(c)}}let a="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,a+=".compose",t.inputState.compositionFirstChange&&(a+=".start",t.inputState.compositionFirstChange=!1)),o.update(n,{userEvent:a,scrollIntoView:!0})}function S_(t,e,r,n){let o=Math.min(t.length,e.length),s=0;for(;s<o&&t.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==o&&t.length==e.length)return null;let i=t.length,a=e.length;for(;i>0&&a>0&&t.charCodeAt(i-1)==e.charCodeAt(a-1);)i--,a--;if(n=="end"){let l=Math.max(0,s-Math.min(i,a));r-=i+l-s}if(i<s&&t.length<e.length){let l=r<=s&&r>=i?s-r:0;s-=l,a=s+(a-i),i=s}else if(a<s){let l=r<=s&&r>=a?s-r:0;s-=l,i=s+(i-a),a=s}return{from:s,toA:i,toB:a}}function kG(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:r,anchorOffset:n,focusNode:o,focusOffset:s}=t.observer.selectionRange;return r&&(e.push(new Eb(r,n)),(o!=r||s!=n)&&e.push(new Eb(o,s))),e}function EG(t,e){if(t.length==0)return null;let r=t[0].pos,n=t.length==2?t[1].pos:r;return r>-1&&n>-1?ie.single(r+e,n+e):null}function Tb(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}var t1=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Ie.safari&&e.contentDOM.addEventListener("input",()=>null),Ie.gecko&&FG(e.contentDOM.ownerDocument)}handleEvent(e){!DG(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,r){let n=this.handlers[e];if(n){for(let o of n.observers)o(this.view,r);for(let o of n.handlers){if(r.defaultPrevented)break;if(o(this.view,r)){r.preventDefault();break}}}}ensureHandlers(e){let r=TG(e),n=this.handlers,o=this.view.contentDOM;for(let s in r)if(s!="scroll"){let i=!r[s].handlers.length,a=n[s];a&&i!=!a.handlers.length&&(o.removeEventListener(s,this.handleEvent),a=null),a||o.addEventListener(s,this.handleEvent,{passive:i})}for(let s in n)s!="scroll"&&!r[s]&&o.removeEventListener(s,this.handleEvent);this.handlers=r}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&C_.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Ie.android&&Ie.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let r;return Ie.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((r=N_.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||IG.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=r||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let r=this.pendingIOSKey;return!r||r.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Su(this.view.contentDOM,r.key,r.keyCode,r instanceof KeyboardEvent?r:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:Ie.safari&&!Ie.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function gO(t,e){return(r,n)=>{try{return e.call(t,n,r)}catch(o){Kn(r.state,o)}}}function TG(t){let e=Object.create(null);function r(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of t){let o=n.spec,s=o&&o.plugin.domEventHandlers,i=o&&o.plugin.domEventObservers;if(s)for(let a in s){let l=s[a];l&&r(a).handlers.push(gO(n.value,l))}if(i)for(let a in i){let l=i[a];l&&r(a).observers.push(gO(n.value,l))}}for(let n in ai)r(n).handlers.push(ai[n]);for(let n in Ho)r(n).observers.push(Ho[n]);return e}var N_=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],IG="dthko",C_=[16,17,18,20,91,92,224,225],lb=6;function cb(t){return Math.max(0,t)*.7+8}function AG(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}var r1=class{constructor(e,r,n,o){this.view=e,this.startEvent=r,this.style=n,this.mustSelect=o,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=r,this.scrollParents=KO(e.contentDOM),this.atoms=e.state.facet(Mp).map(i=>i(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=r.shiftKey,this.multiple=e.state.facet(jt.allowMultipleSelections)&&MG(e,r),this.dragging=RG(e,r)&&T_(r)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&AG(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let r=0,n=0,o=0,s=0,i=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:i}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=_1(this.view);e.clientX-l.left<=o+lb?r=-cb(o-e.clientX):e.clientX+l.right>=i-lb&&(r=cb(e.clientX-i)),e.clientY-l.top<=s+lb?n=-cb(s-e.clientY):e.clientY+l.bottom>=a-lb&&(n=cb(e.clientY-a)),this.setScrollSpeed(r,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,r){this.scrollSpeed={x:e,y:r},e||r?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:r}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),r&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=r,r=0),(e||r)&&this.view.win.scrollBy(e,r),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:r}=this,n=y_(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(r.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(r=>r.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function MG(t,e){let r=t.state.facet(n_);return r.length?r[0](e):Ie.mac?e.metaKey:e.ctrlKey}function PG(t,e){let r=t.state.facet(o_);return r.length?r[0](e):Ie.mac?!e.altKey:!e.ctrlKey}function RG(t,e){let{main:r}=t.state.selection;if(r.empty)return!1;let n=Tp(t.root);if(!n||n.rangeCount==0)return!0;let o=n.getRangeAt(0).getClientRects();for(let s=0;s<o.length;s++){let i=o[s];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}function DG(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let r=e.target,n;r!=t.contentDOM;r=r.parentNode)if(!r||r.nodeType==11||(n=Dr.get(r))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(e))return!1;return!0}var ai=Object.create(null),Ho=Object.create(null),k_=Ie.ie&&Ie.ie_version<15||Ie.ios&&Ie.webkit_version<604;function OG(t){let e=t.dom.parentNode;if(!e)return;let r=e.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout(()=>{t.focus(),r.remove(),E_(t,r.value)},50)}function $b(t,e,r){for(let n of t.facet(e))r=n(r,t);return r}function E_(t,e){e=$b(t.state,P1,e);let{state:r}=t,n,o=1,s=r.toText(e),i=s.lines==r.selection.ranges.length;if(n1!=null&&r.selection.ranges.every(l=>l.empty)&&n1==s.toString()){let l=-1;n=r.changeByRange(c=>{let d=r.doc.lineAt(c.from);if(d.from==l)return{range:c};l=d.from;let u=r.toText((i?s.line(o++).text:e)+r.lineBreak);return{changes:{from:d.from,insert:u},range:ie.cursor(c.from+u.length)}})}else i?n=r.changeByRange(l=>{let c=s.line(o++);return{changes:{from:l.from,to:l.to,insert:c.text},range:ie.cursor(l.from+c.length)}}):n=r.replaceSelection(s);t.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}Ho.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft};Ho.wheel=Ho.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};ai.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);Ho.touchstart=(t,e)=>{let r=t.inputState,n=e.targetTouches[0];r.lastTouchTime=Date.now(),n&&(r.lastTouchX=n.clientX,r.lastTouchY=n.clientY),r.setSelectionOrigin("select.pointer")};Ho.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};ai.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let r=null;for(let n of t.state.facet(s_))if(r=n(t,e),r)break;if(!r&&e.button==0&&(r=LG(t,e)),r){let n=!t.hasFocus;t.inputState.startMouseSelection(new r1(t,e,r,n)),n&&t.observer.ignore(()=>{qO(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let o=t.inputState.mouseSelection;if(o)return o.start(e),o.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function bO(t,e,r,n){if(n==1)return ie.cursor(e,r);if(n==2)return bG(t.state,e,r);{let o=t.docView.lineAt(e,r),s=t.state.doc.lineAt(o?o.posAtEnd:e),i=o?o.posAtStart:s.from,a=o?o.posAtEnd:s.to;return a<t.state.doc.length&&a==s.to&&a++,ie.range(i,a)}}var _G=Ie.ie&&Ie.ie_version<=11,xO=null,yO=0,vO=0;function T_(t){if(!_G)return t.detail;let e=xO,r=vO;return xO=t,vO=Date.now(),yO=!e||r>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(yO+1)%3:1}function LG(t,e){let r=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),n=T_(e),o=t.state.selection;return{update(s){s.docChanged&&(r.pos=s.changes.mapPos(r.pos),o=o.map(s.changes))},get(s,i,a){let l=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),c,d=bO(t,l.pos,l.assoc,n);if(r.pos!=l.pos&&!i){let u=bO(t,r.pos,r.assoc,n),f=Math.min(u.from,d.from),p=Math.max(u.to,d.to);d=f<d.from?ie.range(f,p,d.assoc):ie.range(p,f,d.assoc)}return i?o.replaceRange(o.main.extend(d.from,d.to,d.assoc)):a&&n==1&&o.ranges.length>1&&(c=BG(o,l.pos))?c:a?o.addRange(d):ie.create([d])}}}function BG(t,e){for(let r=0;r<t.ranges.length;r++){let{from:n,to:o}=t.ranges[r];if(n<=e&&o>=e)return ie.create(t.ranges.slice(0,r).concat(t.ranges.slice(r+1)),t.mainIndex==r?0:t.mainIndex-(t.mainIndex>r?1:0))}return null}ai.dragstart=(t,e)=>{let{selection:{main:r}}=t.state;if(e.target.draggable){let o=t.docView.tile.nearest(e.target);if(o&&o.isWidget()){let s=o.posAtStart,i=s+o.length;(s>=r.to||i<=r.from)&&(r=ie.range(s,i))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=r,e.dataTransfer&&(e.dataTransfer.setData("Text",$b(t.state,R1,t.state.sliceDoc(r.from,r.to))),e.dataTransfer.effectAllowed="copyMove"),!1};ai.dragend=t=>(t.inputState.draggedContent=null,!1);function wO(t,e,r,n){if(r=$b(t.state,P1,r),!r)return;let o=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,i=n&&s&&PG(t,e)?{from:s.from,to:s.to}:null,a={from:o,insert:r},l=t.state.changes(i?[i,a]:a);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(o,-1),head:l.mapPos(o,1)},userEvent:i?"move.drop":"input.drop"}),t.inputState.draggedContent=null}ai.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let r=e.dataTransfer.files;if(r&&r.length){let n=Array(r.length),o=0,s=()=>{++o==r.length&&wO(t,e,n.filter(i=>i!=null).join(t.state.lineBreak),!1)};for(let i=0;i<r.length;i++){let a=new FileReader;a.onerror=s,a.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(n[i]=a.result),s()},a.readAsText(r[i])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return wO(t,e,n,!0),!0}return!1};ai.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let r=k_?null:e.clipboardData;return r?(E_(t,r.getData("text/plain")||r.getData("text/uri-list")),!0):(OG(t),!1)};function zG(t,e){let r=t.dom.parentNode;if(!r)return;let n=r.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),t.focus()},50)}function $G(t){let e=[],r=[],n=!1;for(let o of t.selection.ranges)o.empty||(e.push(t.sliceDoc(o.from,o.to)),r.push(o));if(!e.length){let o=-1;for(let{from:s}of t.selection.ranges){let i=t.doc.lineAt(s);i.number>o&&(e.push(i.text),r.push({from:i.from,to:Math.min(t.doc.length,i.to+1)})),o=i.number}n=!0}return{text:$b(t,R1,e.join(t.lineBreak)),ranges:r,linewise:n}}var n1=null;ai.copy=ai.cut=(t,e)=>{if(!mp(t.contentDOM,t.observer.selectionRange))return!1;let{text:r,ranges:n,linewise:o}=$G(t.state);if(!r&&!o)return!1;n1=o?r:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=k_?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",r),!0):(zG(t,r),!1)};var I_=io.define();function A_(t,e){let r=[];for(let n of t.facet(l_)){let o=n(t,e);o&&r.push(o)}return r.length?t.update({effects:r,annotations:I_.of(!0)}):null}function M_(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let r=A_(t.state,e);r?t.dispatch(r):t.update([])}},10)}Ho.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),M_(t)};Ho.blur=t=>{t.observer.clearSelectionRange(),M_(t)};Ho.compositionstart=Ho.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};Ho.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Ie.chrome&&Ie.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};Ho.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};ai.beforeinput=(t,e)=>{var r,n;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(r=e.dataTransfer)===null||r===void 0?void 0:r.getData("text/plain"),i=e.getTargetRanges();if(s&&i.length){let a=i[0],l=t.posAtDOM(a.startContainer,a.startOffset),c=t.posAtDOM(a.endContainer,a.endOffset);return L1(t,{from:l,to:c,insert:t.state.toText(s)},null),!0}}let o;if(Ie.chrome&&Ie.android&&(o=N_.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(o.key,o.keyCode),o.key=="Backspace"||o.key=="Delete")){let s=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var i;(((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Ie.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Ie.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>Ho.compositionend(t,e),20),!1};var SO=new Set;function FG(t){SO.has(t)||(SO.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}var NO=["pre-wrap","normal","pre-line","break-spaces"],Tu=!1;function CO(){Tu=!1}var o1=class{constructor(e){this.lineWrapping=e,this.doc=kt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,r){let n=this.doc.lineAt(r).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((r-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return NO.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let r=!1;for(let n=0;n<e.length;n++){let o=e[n];o<0?n++:this.heightSamples[Math.floor(o*10)]||(r=!0,this.heightSamples[Math.floor(o*10)]=!0)}return r}refresh(e,r,n,o,s,i){let a=NO.indexOf(e)>-1,l=Math.abs(r-this.lineHeight)>.3||this.lineWrapping!=a||Math.abs(n-this.charWidth)>.1;if(this.lineWrapping=a,this.lineHeight=r,this.charWidth=n,this.textHeight=o,this.lineLength=s,l){this.heightSamples={};for(let c=0;c<i.length;c++){let d=i[c];d<0?c++:this.heightSamples[Math.floor(d*10)]=!0}}return l}},s1=class{constructor(e,r){this.from=e,this.heights=r,this.index=0}get more(){return this.index<this.heights.length}},si=class t{constructor(e,r,n,o,s){this.from=e,this.length=r,this.top=n,this.height=o,this._content=s}get type(){return typeof this._content=="number"?qn.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Oc?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let r=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new t(this.from,this.length+e.length,this.top,this.height+e.height,r)}},wr=(function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t})(wr||(wr={})),gb=.001,ss=class t{constructor(e,r,n=2){this.length=e,this.height=r,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>gb&&(Tu=!0),this.height=e)}replace(e,r,n){return t.of(n)}decomposeLeft(e,r){r.push(this)}decomposeRight(e,r){r.push(this)}applyChanges(e,r,n,o){let s=this,i=n.doc;for(let a=o.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:d,toB:u}=o[a],f=s.lineAt(l,wr.ByPosNoHeight,n.setDoc(r),0,0),p=f.to>=c?f:s.lineAt(c,wr.ByPosNoHeight,n,0,0);for(u+=p.to-c,c=p.to;a>0&&f.from<=o[a-1].toA;)l=o[a-1].fromA,d=o[a-1].fromB,a--,l<f.from&&(f=s.lineAt(l,wr.ByPosNoHeight,n,0,0));d+=f.from-l,l=f.from;let h=a1.build(n.setDoc(i),e,d,u);s=Ib(s,s.replace(l,c,h))}return s.updateHeight(n,0)}static empty(){return new Bs(0,0,0)}static of(e){if(e.length==1)return e[0];let r=0,n=e.length,o=0,s=0;for(;;)if(r==n)if(o>s*2){let a=e[r-1];a.break?e.splice(--r,1,a.left,null,a.right):e.splice(--r,1,a.left,a.right),n+=1+a.break,o-=a.size}else if(s>o*2){let a=e[n];a.break?e.splice(n,1,a.left,null,a.right):e.splice(n,1,a.left,a.right),n+=2+a.break,s-=a.size}else break;else if(o<s){let a=e[r++];a&&(o+=a.size)}else{let a=e[--n];a&&(s+=a.size)}let i=0;return e[r-1]==null?(i=1,r--):e[r]==null&&(i=1,n++),new i1(t.of(e.slice(0,r)),i,t.of(e.slice(n)))}};function Ib(t,e){return t==e?t:(t.constructor!=e.constructor&&(Tu=!0),e)}ss.prototype.size=1;var HG=Fe.replace({}),Ab=class extends ss{constructor(e,r,n){super(e,r),this.deco=n,this.spaceAbove=0}mainBlock(e,r){return new si(r,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,r,n,o){return this.spaceAbove&&e<n+this.spaceAbove?new si(o,0,n,this.spaceAbove,HG):this.mainBlock(n,o)}lineAt(e,r,n,o,s){let i=this.mainBlock(o,s);return this.spaceAbove?this.blockAt(0,n,o,s).join(i):i}forEachLine(e,r,n,o,s,i){e<=s+this.length&&r>=s&&i(this.lineAt(0,wr.ByPos,n,o,s))}setMeasuredHeight(e){let r=e.heights[e.index++];r<0?(this.spaceAbove=-r,r=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(r)}updateHeight(e,r=0,n=!1,o){return o&&o.from<=r&&o.more&&this.setMeasuredHeight(o),this.outdated=!1,this}toString(){return`block(${this.length})`}},Bs=class t extends Ab{constructor(e,r,n){super(e,r,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,r){return new si(r,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,r,n){let o=n[0];return n.length==1&&(o instanceof t||o instanceof gl&&o.flags&4)&&Math.abs(this.length-o.length)<10?(o instanceof gl?o=new t(o.length,this.height,this.spaceAbove):o.height=this.height,this.outdated||(o.outdated=!1),o):ss.of(n)}updateHeight(e,r=0,n=!1,o){return o&&o.from<=r&&o.more?this.setMeasuredHeight(o):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},gl=class t extends ss{constructor(e){super(e,0)}heightMetrics(e,r){let n=e.doc.lineAt(r).number,o=e.doc.lineAt(r+this.length).number,s=o-n+1,i,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*s);i=l/s,this.length>s+1&&(a=(this.height-l)/(this.length-s-1))}else i=this.height/s;return{firstLine:n,lastLine:o,perLine:i,perChar:a}}blockAt(e,r,n,o){let{firstLine:s,lastLine:i,perLine:a,perChar:l}=this.heightMetrics(r,o);if(r.lineWrapping){let c=o+(e<r.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),d=r.doc.lineAt(c),u=a+d.length*l,f=Math.max(n,e-u/2);return new si(d.from,d.length,f,u,0)}else{let c=Math.max(0,Math.min(i-s,Math.floor((e-n)/a))),{from:d,length:u}=r.doc.line(s+c);return new si(d,u,n+a*c,a,0)}}lineAt(e,r,n,o,s){if(r==wr.ByHeight)return this.blockAt(e,n,o,s);if(r==wr.ByPosNoHeight){let{from:p,to:h}=n.doc.lineAt(e);return new si(p,h-p,0,0,0)}let{firstLine:i,perLine:a,perChar:l}=this.heightMetrics(n,s),c=n.doc.lineAt(e),d=a+c.length*l,u=c.number-i,f=o+a*u+l*(c.from-s-u);return new si(c.from,c.length,Math.max(o,Math.min(f,o+this.height-d)),d,0)}forEachLine(e,r,n,o,s,i){e=Math.max(e,s),r=Math.min(r,s+this.length);let{firstLine:a,perLine:l,perChar:c}=this.heightMetrics(n,s);for(let d=e,u=o;d<=r;){let f=n.doc.lineAt(d);if(d==e){let h=f.number-a;u+=l*h+c*(e-s-h)}let p=l+c*f.length;i(new si(f.from,f.length,u,p,0)),u+=p,d=f.to+1}}replace(e,r,n){let o=this.length-r;if(o>0){let s=n[n.length-1];s instanceof t?n[n.length-1]=new t(s.length+o):n.push(null,new t(o-1))}if(e>0){let s=n[0];s instanceof t?n[0]=new t(e+s.length):n.unshift(new t(e-1),null)}return ss.of(n)}decomposeLeft(e,r){r.push(new t(e-1),null)}decomposeRight(e,r){r.push(null,new t(this.length-e-1))}updateHeight(e,r=0,n=!1,o){let s=r+this.length;if(o&&o.from<=r+this.length&&o.more){let i=[],a=Math.max(r,o.from),l=-1;for(o.from>r&&i.push(new t(o.from-r-1).updateHeight(e,r));a<=s&&o.more;){let d=e.doc.lineAt(a).length;i.length&&i.push(null);let u=o.heights[o.index++],f=0;u<0&&(f=-u,u=o.heights[o.index++]),l==-1?l=u:Math.abs(u-l)>=gb&&(l=-2);let p=new Bs(d,u,f);p.outdated=!1,i.push(p),a+=d+1}a<=s&&i.push(null,new t(s-a).updateHeight(e,a));let c=ss.of(i);return(l<0||Math.abs(c.height-this.height)>=gb||Math.abs(l-this.heightMetrics(e,r).perLine)>=gb)&&(Tu=!0),Ib(this,c)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(r,r+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},i1=class extends ss{constructor(e,r,n){super(e.length+r+n.length,e.height+n.height,r|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,r,n,o){let s=n+this.left.height;return e<s?this.left.blockAt(e,r,n,o):this.right.blockAt(e,r,s,o+this.left.length+this.break)}lineAt(e,r,n,o,s){let i=o+this.left.height,a=s+this.left.length+this.break,l=r==wr.ByHeight?e<i:e<a,c=l?this.left.lineAt(e,r,n,o,s):this.right.lineAt(e,r,n,i,a);if(this.break||(l?c.to<a:c.from>a))return c;let d=r==wr.ByPosNoHeight?wr.ByPosNoHeight:wr.ByPos;return l?c.join(this.right.lineAt(a,d,n,i,a)):this.left.lineAt(a,d,n,o,s).join(c)}forEachLine(e,r,n,o,s,i){let a=o+this.left.height,l=s+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,r,n,o,s,i),r>=l&&this.right.forEachLine(e,r,n,a,l,i);else{let c=this.lineAt(l,wr.ByPos,n,o,s);e<c.from&&this.left.forEachLine(e,c.from-1,n,o,s,i),c.to>=e&&c.from<=r&&i(c),r>c.to&&this.right.forEachLine(c.to+1,r,n,a,l,i)}}replace(e,r,n){let o=this.left.length+this.break;if(r<o)return this.balanced(this.left.replace(e,r,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-o,r-o,n));let s=[];e>0&&this.decomposeLeft(e,s);let i=s.length;for(let a of n)s.push(a);if(e>0&&kO(s,i-1),r<this.length){let a=s.length;this.decomposeRight(r,s),kO(s,a)}return ss.of(s)}decomposeLeft(e,r){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,r);r.push(this.left),this.break&&(n++,e>=n&&r.push(null)),e>n&&this.right.decomposeLeft(e-n,r)}decomposeRight(e,r){let n=this.left.length,o=n+this.break;if(e>=o)return this.right.decomposeRight(e-o,r);e<n&&this.left.decomposeRight(e,r),this.break&&e<o&&r.push(null),r.push(this.right)}balanced(e,r){return e.size>2*r.size||r.size>2*e.size?ss.of(this.break?[e,null,r]:[e,r]):(this.left=Ib(this.left,e),this.right=Ib(this.right,r),this.setHeight(e.height+r.height),this.outdated=e.outdated||r.outdated,this.size=e.size+r.size,this.length=e.length+this.break+r.length,this)}updateHeight(e,r=0,n=!1,o){let{left:s,right:i}=this,a=r+s.length+this.break,l=null;return o&&o.from<=r+s.length&&o.more?l=s=s.updateHeight(e,r,n,o):s.updateHeight(e,r,n),o&&o.from<=a+i.length&&o.more?l=i=i.updateHeight(e,a,n,o):i.updateHeight(e,a,n),l?this.balanced(s,i):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function kO(t,e){let r,n;t[e]==null&&(r=t[e-1])instanceof gl&&(n=t[e+1])instanceof gl&&t.splice(e-1,3,new gl(r.length+1+n.length))}var VG=5,a1=class t{constructor(e,r){this.pos=e,this.oracle=r,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,r){if(this.lineStart>-1){let n=Math.min(r,this.lineEnd),o=this.nodes[this.nodes.length-1];o instanceof Bs?o.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Bs(n-this.pos,-1,0)),this.writtenTo=n,r>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=r}point(e,r,n){if(e<r||n.heightRelevant){let o=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;o<0&&(o=this.oracle.lineHeight);let i=r-e;n.block?this.addBlock(new Ab(i,o,n)):(i||s||o>=VG)&&this.addLineDeco(o,s,i)}else r>e&&this.span(e,r);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:r}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=r,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Bs(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,r){let n=new gl(r-e);return this.oracle.doc.lineAt(e).to==r&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Bs)return e;let r=new Bs(0,-1,0);return this.nodes.push(r),r}addBlock(e){this.enterLine();let r=e.deco;r&&r.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,r&&r.endSide>0&&(this.covering=e)}addLineDeco(e,r,n){let o=this.ensureLine();o.length+=n,o.collapsed+=n,o.widgetHeight=Math.max(o.widgetHeight,e),o.breaks+=r,this.writtenTo=this.pos=this.pos+n}finish(e){let r=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(r instanceof Bs)&&!this.isCovered?this.nodes.push(new Bs(0,-1,0)):(this.writtenTo<this.pos||r==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let o of this.nodes)o instanceof Bs&&o.updateHeight(this.oracle,n),n+=o?o.length:1;return this.nodes}static build(e,r,n,o){let s=new t(n,e);return Dt.spans(r,n,o,s,0),s.finish(n)}};function jG(t,e,r){let n=new l1;return Dt.compare(t,e,r,n,0),n.changes}var l1=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,r,n,o){(e<r||n&&n.heightRelevant||o&&o.heightRelevant)&&wu(e,r,this.changes,5)}};function WG(t,e){let r=t.getBoundingClientRect(),n=t.ownerDocument,o=n.defaultView||window,s=Math.max(0,r.left),i=Math.min(o.innerWidth,r.right),a=Math.max(0,r.top),l=Math.min(o.innerHeight,r.bottom);for(let c=t.parentNode;c&&c!=n.body;)if(c.nodeType==1){let d=c,u=window.getComputedStyle(d);if((d.scrollHeight>d.clientHeight||d.scrollWidth>d.clientWidth)&&u.overflow!="visible"){let f=d.getBoundingClientRect();s=Math.max(s,f.left),i=Math.min(i,f.right),a=Math.max(a,f.top),l=Math.min(c==t.parentNode?o.innerHeight:l,f.bottom)}c=u.position=="absolute"||u.position=="fixed"?d.offsetParent:d.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-r.left,right:Math.max(s,i)-r.left,top:a-(r.top+e),bottom:Math.max(a,l)-(r.top+e)}}function UG(t){let e=t.getBoundingClientRect(),r=t.ownerDocument.defaultView||window;return e.left<r.innerWidth&&e.right>0&&e.top<r.innerHeight&&e.bottom>0}function GG(t,e){let r=t.getBoundingClientRect();return{left:0,right:r.right-r.left,top:e,bottom:r.bottom-(r.top+e)}}var Sp=class{constructor(e,r,n,o){this.from=e,this.to=r,this.size=n,this.displaySize=o}static same(e,r){if(e.length!=r.length)return!1;for(let n=0;n<e.length;n++){let o=e[n],s=r[n];if(o.from!=s.from||o.to!=s.to||o.size!=s.size)return!1}return!0}draw(e,r){return Fe.replace({widget:new c1(this.displaySize*(r?e.scaleY:e.scaleX),r)}).range(this.from,this.to)}},c1=class extends Io{constructor(e,r){super(),this.size=e,this.vertical=r}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},Mb=class{constructor(e,r){this.view=e,this.state=r,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=EO,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Xt.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=r.facet(D1).some(o=>typeof o!="function"&&o.class=="cm-lineWrapping");this.heightOracle=new o1(n),this.stateDeco=TO(r),this.heightMap=ss.empty().applyChanges(this.stateDeco,kt.empty,this.heightOracle.setDoc(r.doc),[new ii(0,0,0,r.doc.length)]);for(let o=0;o<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());o++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Fe.set(this.lineGaps.map(o=>o.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:r}=this.state.selection;for(let n=0;n<=1;n++){let o=n?r.head:r.anchor;if(!e.some(({from:s,to:i})=>o>=s&&o<=i)){let{from:s,to:i}=this.lineBlockAt(o);e.push(new xu(s,i))}}return this.viewports=e.sort((n,o)=>n.from-o.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?EO:new d1(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(pp(e,this.scaler))})}update(e,r=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=TO(this.state);let o=e.changedRanges,s=ii.extendWithRanges(o,jG(n,this.stateDeco,e?e.changes:Eo.empty(this.state.doc.length))),i=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);CO(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=i||Tu)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=i);let l=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(r&&(r.range.head<l.from||r.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,r));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),r&&(this.scrollTarget=r),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(d_)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,r=e.contentDOM,n=window.getComputedStyle(r),o=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?Xt.RTL:Xt.LTR;let i=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",a=r.getBoundingClientRect(),l=i||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,d=0;if(a.width&&a.height){let{scaleX:S,scaleY:w}=GO(r,a);(S>.005&&Math.abs(this.scaleX-S)>.005||w>.005&&Math.abs(this.scaleY-w)>.005)&&(this.scaleX=S,this.scaleY=w,c|=16,i=l=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,f=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=f)&&(this.paddingTop=u,this.paddingBottom=f,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(o.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let p=KO(this.view.contentDOM,!1).y;p!=this.scrollParent&&(this.scrollParent=p,this.scrollAnchorHeight=-1,this.scrollOffset=0);let h=this.getScrollOffset();this.scrollOffset!=h&&(this.scrollAnchorHeight=-1,this.scrollOffset=h),this.scrolledToBottom=YO(this.scrollParent||e.win);let b=(this.printing?GG:WG)(r,this.paddingTop),g=b.top-this.pixelViewport.top,x=b.bottom-this.pixelViewport.bottom;this.pixelViewport=b;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(l=!0)),!this.inView&&!this.scrollTarget&&!UG(e.dom))return 0;let m=a.width;if((this.contentDOMWidth!=m||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let S=e.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(S)&&(i=!0),i||o.lineWrapping&&Math.abs(m-this.contentDOMWidth)>o.charWidth){let{lineHeight:w,charWidth:C,textHeight:A}=e.docView.measureTextSize();i=w>0&&o.refresh(s,w,C,A,Math.max(5,m/C),S),i&&(e.docView.minWidth=0,c|=16)}g>0&&x>0?d=Math.max(g,x):g<0&&x<0&&(d=Math.min(g,x)),CO();for(let w of this.viewports){let C=w.from==this.viewport.from?S:e.docView.measureVisibleLineHeights(w);this.heightMap=(i?ss.empty().applyChanges(this.stateDeco,kt.empty,this.heightOracle,[new ii(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(o,0,i,new s1(w.from,C))}Tu&&(c|=2)}let v=!this.viewportIsAppropriate(this.viewport,d)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(d,this.scrollTarget),c|=this.updateForViewport()),(c&2||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(i?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,r){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),o=this.heightMap,s=this.heightOracle,{visibleTop:i,visibleBottom:a}=this,l=new xu(o.lineAt(i-n*1e3,wr.ByHeight,s,0,0).from,o.lineAt(a+(1-n)*1e3,wr.ByHeight,s,0,0).to);if(r){let{head:c}=r.range;if(c<l.from||c>l.to){let d=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=o.lineAt(c,wr.ByPos,s,0,0),f;r.y=="center"?f=(u.top+u.bottom)/2-d/2:r.y=="start"||r.y=="nearest"&&c<l.from?f=u.top:f=u.bottom-d,l=new xu(o.lineAt(f-1e3/2,wr.ByHeight,s,0,0).from,o.lineAt(f+d+1e3/2,wr.ByHeight,s,0,0).to)}}return l}mapViewport(e,r){let n=r.mapPos(e.from,-1),o=r.mapPos(e.to,1);return new xu(this.heightMap.lineAt(n,wr.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(o,wr.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:r},n=0){if(!this.inView)return!0;let{top:o}=this.heightMap.lineAt(e,wr.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(r,wr.ByPos,this.heightOracle,0,0),{visibleTop:i,visibleBottom:a}=this;return(e==0||o<=i-Math.max(10,Math.min(-n,250)))&&(r==this.state.doc.length||s>=a+Math.max(10,Math.min(n,250)))&&o>i-2*1e3&&s<a+2*1e3}mapLineGaps(e,r){if(!e.length||r.empty)return e;let n=[];for(let o of e)r.touchesRange(o.from,o.to)||n.push(new Sp(r.mapPos(o.from),r.mapPos(o.to),o.size,o.displaySize));return n}ensureLineGaps(e,r){let n=this.heightOracle.lineWrapping,o=n?1e4:2e3,s=o>>1,i=o<<1;if(this.defaultTextDirection!=Xt.LTR&&!n)return[];let a=[],l=(d,u,f,p)=>{if(u-d<s)return;let h=this.state.selection.main,b=[h.from];h.empty||b.push(h.to);for(let x of b)if(x>d&&x<u){l(d,x-10,f,p),l(x+10,u,f,p);return}let g=qG(e,x=>x.from>=f.from&&x.to<=f.to&&Math.abs(x.from-d)<s&&Math.abs(x.to-u)<s&&!b.some(y=>x.from<y&&x.to>y));if(!g){if(u<f.to&&r&&n&&r.visibleRanges.some(m=>m.from<=u&&m.to>=u)){let m=r.moveToLineBoundary(ie.cursor(u),!1,!0).head;m>d&&(u=m)}let x=this.gapSize(f,d,u,p),y=n||x<2e6?x:2e6;g=new Sp(d,u,x,y)}a.push(g)},c=d=>{if(d.length<i||d.type!=qn.Text)return;let u=KG(d.from,d.to,this.stateDeco);if(u.total<i)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,p,h;if(n){let b=o/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,x;if(f!=null){let y=ub(u,f),m=((this.visibleBottom-this.visibleTop)/2+b)/d.height;g=y-m,x=y+m}else g=(this.visibleTop-d.top-b)/d.height,x=(this.visibleBottom-d.top+b)/d.height;p=db(u,g),h=db(u,x)}else{let b=u.total*this.heightOracle.charWidth,g=o*this.heightOracle.charWidth,x=0;if(b>2e6)for(let w of e)w.from>=d.from&&w.from<d.to&&w.size!=w.displaySize&&w.from*this.heightOracle.charWidth+x<this.pixelViewport.left&&(x=w.size-w.displaySize);let y=this.pixelViewport.left+x,m=this.pixelViewport.right+x,v,S;if(f!=null){let w=ub(u,f),C=((m-y)/2+g)/b;v=w-C,S=w+C}else v=(y-g)/b,S=(m+g)/b;p=db(u,v),h=db(u,S)}p>d.from&&l(d.from,p,d,u),h<d.to&&l(h,d.to,d,u)};for(let d of this.viewportLines)Array.isArray(d.type)?d.type.forEach(c):c(d);return a}gapSize(e,r,n,o){let s=ub(o,n)-ub(o,r);return this.heightOracle.lineWrapping?e.height*s:o.total*this.heightOracle.charWidth*s}updateLineGaps(e){Sp.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Fe.set(e.map(r=>r.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let r=this.stateDeco;this.lineGaps.length&&(r=r.concat(this.lineGapDeco));let n=[];Dt.spans(r,this.viewport.from,this.viewport.to,{span(s,i){n.push({from:s,to:i})},point(){}},20);let o=0;if(n.length!=this.visibleRanges.length)o=12;else for(let s=0;s<n.length&&!(o&8);s++){let i=this.visibleRanges[s],a=n[s];(i.from!=a.from||i.to!=a.to)&&(o|=4,e&&e.mapPos(i.from,-1)==a.from&&e.mapPos(i.to,1)==a.to||(o|=8))}return this.visibleRanges=n,o}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(r=>r.from<=e&&r.to>=e)||pp(this.heightMap.lineAt(e,wr.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(r=>r.top<=e&&r.bottom>=e)||pp(this.heightMap.lineAt(this.scaler.fromDOM(e),wr.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let r=this.lineBlockAtHeight(e+8);return r.from>=this.viewport.from||this.viewportLines[0].top-e>200?r:this.viewportLines[0]}elementAtHeight(e){return pp(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},xu=class{constructor(e,r){this.from=e,this.to=r}};function KG(t,e,r){let n=[],o=t,s=0;return Dt.spans(r,t,e,{span(){},point(i,a){i>o&&(n.push({from:o,to:i}),s+=i-o),o=a}},20),o<e&&(n.push({from:o,to:e}),s+=e-o),{total:s,ranges:n}}function db({total:t,ranges:e},r){if(r<=0)return e[0].from;if(r>=1)return e[e.length-1].to;let n=Math.floor(t*r);for(let o=0;;o++){let{from:s,to:i}=e[o],a=i-s;if(n<=a)return s+n;n-=a}}function ub(t,e){let r=0;for(let{from:n,to:o}of t.ranges){if(e<=o){r+=e-n;break}r+=o-n}return r/t.total}function qG(t,e){for(let r of t)if(e(r))return r}var EO={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function TO(t){let e=t.facet(zb).filter(n=>typeof n!="function"),r=t.facet(O1).filter(n=>typeof n!="function");return r.length&&e.push(Dt.join(r)),e}var d1=class t{constructor(e,r,n){let o=0,s=0,i=0;this.viewports=n.map(({from:a,to:l})=>{let c=r.lineAt(a,wr.ByPos,e,0,0).top,d=r.lineAt(l,wr.ByPos,e,0,0).bottom;return o+=d-c,{from:a,to:l,top:c,bottom:d,domTop:0,domBottom:0}}),this.scale=(7e6-o)/(r.height-o);for(let a of this.viewports)a.domTop=i+(a.top-s)*this.scale,i=a.domBottom=a.domTop+(a.bottom-a.top),s=a.bottom}toDOM(e){for(let r=0,n=0,o=0;;r++){let s=r<this.viewports.length?this.viewports[r]:null;if(!s||e<s.top)return o+(e-n)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);n=s.bottom,o=s.domBottom}}fromDOM(e){for(let r=0,n=0,o=0;;r++){let s=r<this.viewports.length?this.viewports[r]:null;if(!s||e<s.domTop)return n+(e-o)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);n=s.bottom,o=s.domBottom}}eq(e){return e instanceof t?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((r,n)=>r.from==e.viewports[n].from&&r.to==e.viewports[n].to):!1}};function pp(t,e){if(e.scale==1)return t;let r=e.toDOM(t.top),n=e.toDOM(t.bottom);return new si(t.from,t.length,r,n-r,Array.isArray(t._content)?t._content.map(o=>pp(o,e)):t._content)}var fb=Ce.define({combine:t=>t.join(" ")}),u1=Ce.define({combine:t=>t.indexOf(!0)>-1}),f1=Ls.newName(),P_=Ls.newName(),R_=Ls.newName(),D_={"&light":"."+P_,"&dark":"."+R_};function p1(t,e,r){return new Ls(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,o=>{if(o=="&")return t;if(!r||!r[o])throw new RangeError(`Unsupported selector: ${o}`);return r[o]}):t+" "+n}})}var YG=p1("."+f1,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},D_),XG={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Tw=Ie.ie&&Ie.ie_version<=11,h1=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Bw,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(r=>{for(let n of r)this.queue.push(n);(Ie.ie&&Ie.ie_version<=11||Ie.ios&&e.composing)&&r.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Ie.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Ie.chrome&&Ie.chrome_version<126)&&(this.editContext=new m1(e),e.state.facet(Sa)&&(e.contentDOM.editContext=this.editContext.editContext)),Tw&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var r;((r=this.view.docView)===null||r===void 0?void 0:r.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(r=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),r.length>0&&r[r.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(r=>{r.length>0&&r[r.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((r,n)=>r!=e[n]))){this.gapIntersection.disconnect();for(let r of e)this.gapIntersection.observe(r);this.gaps=e}}onSelectionChange(e){let r=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,o=this.selectionRange;if(n.state.facet(Sa)?n.root.activeElement!=this.dom:!mp(this.dom,o))return;let s=o.anchorNode&&n.docView.tile.nearest(o.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){r||(this.selectionChanged=!1);return}(Ie.ie&&Ie.ie_version<=11||Ie.android&&Ie.chrome)&&!n.state.selection.main.empty&&o.focusNode&&bp(o.focusNode,o.focusOffset,o.anchorNode,o.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,r=Tp(e.root);if(!r)return!1;let n=Ie.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&JG(this.view,r)||r;if(!n||this.selectionRange.eq(n))return!1;let o=mp(this.dom,n);return o&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&GU(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),o&&(this.selectionChanged=!0),!0)}setSelectionRange(e,r){this.selectionRange.set(e.node,e.offset,r.node,r.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,r=null;for(let n=this.dom;n;)if(n.nodeType==1)!r&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:r||(r=this.scrollTargets.slice(0,e)),r&&r.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!r&&(r=this.scrollTargets.slice(0,e)),r){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=r)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,XG),Tw&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Tw&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,r){var n;if(!this.delayedAndroidKey){let o=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Su(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(o)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:r,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let r=-1,n=-1,o=!1;for(let s of e){let i=this.readMutation(s);i&&(i.typeOver&&(o=!0),r==-1?{from:r,to:n}=i:(r=Math.min(i.from,r),n=Math.max(i.to,n)))}return{from:r,to:n,typeOver:o}}readChange(){let{from:e,to:r,typeOver:n}=this.processRecords(),o=this.selectionChanged&&mp(this.dom,this.selectionRange);if(e<0&&!o)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new e1(this.view,e,r,n);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let r=this.readChange();if(!r)return this.view.requestMeasure(),!1;let n=this.view.state,o=w_(this.view,r);return this.view.state==n&&(r.domChanged||r.newSel&&!Tb(this.view.state.selection,r.newSel.main))&&this.view.update([]),o}readMutation(e){let r=this.view.docView.tile.nearest(e.target);if(!r||r.isWidget())return null;if(r.markDirty(e.type=="attributes"),e.type=="childList"){let n=IO(r,e.previousSibling||e.target.previousSibling,-1),o=IO(r,e.nextSibling||e.target.nextSibling,1);return{from:n?r.posAfter(n):r.posAtStart,to:o?r.posBefore(o):r.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Sa)!=e.state.facet(Sa)&&(e.view.contentDOM.editContext=e.state.facet(Sa)?this.editContext.editContext:null))}destroy(){var e,r,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(r=this.gapIntersection)===null||r===void 0||r.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let o of this.scrollTargets)o.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function IO(t,e,r){for(;e;){let n=Dr.get(e);if(n&&n.parent==t)return n;let o=e.parentNode;e=o!=t.dom?o:r>0?e.nextSibling:e.previousSibling}return null}function AO(t,e){let r=e.startContainer,n=e.startOffset,o=e.endContainer,s=e.endOffset,i=t.docView.domAtPos(t.state.selection.main.anchor,1);return bp(i.node,i.offset,o,s)&&([r,n,o,s]=[o,s,r,n]),{anchorNode:r,anchorOffset:n,focusNode:o,focusOffset:s}}function JG(t,e){if(e.getComposedRanges){let o=e.getComposedRanges(t.root)[0];if(o)return AO(t,o)}let r=null;function n(o){o.preventDefault(),o.stopImmediatePropagation(),r=o.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",n,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),r?AO(t,r):null}var m1=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let r=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let o=e.state.selection.main,{anchor:s,head:i}=o,a=this.toEditorPos(n.updateRangeStart),l=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:a,drifted:!1});let c=l-a>n.text.length;a==this.from&&s<this.from?a=s:l==this.to&&s>this.to&&(l=s);let d=S_(e.state.sliceDoc(a,l),n.text,(c?o.from:o.to)-a,c?"end":null);if(!d){let f=ie.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));Tb(f,o)||e.dispatch({selection:f,userEvent:"select"});return}let u={from:d.from+a,to:d.toA+a,insert:kt.of(n.text.slice(d.from,d.toB).split(`
|
|
489
|
+
`))};if((Ie.mac||Ie.android)&&u.from==i-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:a,to:l,insert:kt.of([n.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let f=this.to-this.from+(u.to-u.from+u.insert.length);L1(e,u,ie.single(this.toEditorPos(n.selectionStart,f),this.toEditorPos(n.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(r.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(r.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let o=[],s=null;for(let i=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);i<a;i++){let l=e.coordsForChar(i);s=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||s||new DOMRect,o.push(s)}r.updateCharacterBounds(n.rangeStart,o)},this.handlers.textformatupdate=n=>{let o=[];for(let s of n.getTextFormats()){let i=s.underlineStyle,a=s.underlineThickness;if(!/none/i.test(i)&&!/none/i.test(a)){let l=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);if(l<c){let d=`text-decoration: underline ${/^[a-z]/.test(i)?i+" ":i=="Dashed"?"dashed ":i=="Squiggle"?"wavy ":""}${/thin/i.test(a)?1:2}px`;o.push(Fe.mark({attributes:{style:d}}).range(l,c))}}}e.dispatch({effects:f_.of(Fe.set(o))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(e.state)}};for(let n in this.handlers)r.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let o=Tp(n.root);o&&o.rangeCount&&this.editContext.updateSelectionBounds(o.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let r=0,n=!1,o=this.pendingContextChange;return e.changes.iterChanges((s,i,a,l,c)=>{if(n)return;let d=c.length-(i-s);if(o&&i>=o.to)if(o.from==s&&o.to==i&&o.insert.eq(c)){o=this.pendingContextChange=null,r+=d,this.to+=d;return}else o=null,this.revertPending(e.state);if(s+=r,i+=r,i<=this.from)this.from+=d,this.to+=d;else if(s<this.to){if(s<this.from||i>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(i),c.toString()),this.to+=d}r+=d}),o&&!n&&this.revertPending(e.state),!n}update(e){let r=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(o=>!o.isUserEvent("input.type")&&o.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||r)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:r}=e.selection.main;this.from=Math.max(0,r-1e4),this.to=Math.min(e.doc.length,r+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let r=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(r.from),this.toContextPos(r.from+r.insert.length),e.doc.sliceString(r.from,r.to))}setSelection(e){let{main:r}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,r.anchor))),o=this.toContextPos(r.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=o)&&this.editContext.updateSelection(n,o)}rangeIsValid(e){let{head:r}=e.selection.main;return!(this.from>0&&r-this.from<500||this.to<e.doc.length&&this.to-r<500||this.to-this.from>1e4*3)}toEditorPos(e,r=this.to-this.from){e=Math.min(e,r);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let r=this.composing;return r&&r.drifted?r.contextBase+(e-r.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},ve=class t{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var r;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(o=>o.forEach(s=>n(s,this)))||(o=>this.update(o)),this.dispatch=this.dispatch.bind(this),this._root=e.root||UU(e.parent)||document,this.viewState=new Mb(this,e.state||jt.create(e)),e.scrollTo&&e.scrollTo.is(ab)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(bu).map(o=>new yp(o));for(let o of this.plugins)o.update(this);this.observer=new h1(this),this.inputState=new t1(this),this.inputState.ensureHandlers(this.plugins),this.docView=new kb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((r=document.fonts)===null||r===void 0)&&r.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let r=e.length==1&&e[0]instanceof kn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(r,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let r=!1,n=!1,o,s=this.state;for(let f of e){if(f.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=f.state}if(this.destroyed){this.viewState.state=s;return}let i=this.hasFocus,a=0,l=null;e.some(f=>f.annotation(I_))?(this.inputState.notifiedFocused=i,a=1):i!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=i,l=A_(s,i),l||(a=1));let c=this.observer.delayedAndroidKey,d=null;if(c?(this.observer.clearDelayedAndroidKey(),d=this.observer.readChange(),(d&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(d=null)):this.observer.clear(),s.facet(jt.phrases)!=this.state.facet(jt.phrases))return this.setState(s);o=Nb.create(this,s,e),o.flags|=a;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(u&&(u=u.map(f.changes)),f.scrollIntoView){let{main:p}=f.state.selection;u=new xp(p.empty?p:ie.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of f.effects)p.is(ab)&&(u=p.value.clip(this.state))}this.viewState.update(o,u),this.bidiCache=Pb.update(this.bidiCache,o.changes),o.empty||(this.updatePlugins(o),this.inputState.update(o)),r=this.docView.update(o),this.state.facet(fp)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(r,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(o.startState.facet(fb)!=o.state.facet(fb)&&(this.viewState.mustMeasureContent=!0),(r||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),r&&this.docViewUpdate(),!o.empty)for(let f of this.state.facet(Hw))try{f(o)}catch(p){Kn(this.state,p,"update listener")}(l||d)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),d&&!w_(this,d)&&c.force&&Su(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let r=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new Mb(this,e),this.plugins=e.facet(bu).map(n=>new yp(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new kb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}r&&this.focus(),this.requestMeasure()}updatePlugins(e){let r=e.startState.facet(bu),n=e.state.facet(bu);if(r!=n){let o=[];for(let s of n){let i=r.indexOf(s);if(i<0)o.push(new yp(s));else{let a=this.plugins[i];a.mustUpdate=e,o.push(a)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=o,this.pluginMap.clear()}else for(let o of this.plugins)o.mustUpdate=e;for(let o=0;o<this.plugins.length;o++)this.plugins[o].update(this);r!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let r=e.value;if(r&&r.docViewUpdate)try{r.docViewUpdate(this)}catch(n){Kn(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let r=null,n=this.viewState.scrollParent,o=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:i}=this.viewState;Math.abs(o-this.viewState.scrollOffset)>1&&(i=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(i<0)if(YO(n||this.win))s=-1,i=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(o);s=p.from,i=p.top}this.updateState=1;let l=this.viewState.measure();if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let d=c.map(p=>{try{return p.read(this)}catch(h){return Kn(this.state,h),MO}}),u=Nb.create(this,this.state,[]),f=!1;u.flags|=l,r?r.flags|=l:r=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),f=this.docView.update(u),f&&this.docViewUpdate());for(let p=0;p<c.length;p++)if(d[p]!=MO)try{let h=c[p];h.write&&h.write(d[p],this)}catch(h){Kn(this.state,h)}if(f&&this.docView.updateSelection(!0),!u.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,i=-1;continue}else{let h=((s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-i)/this.scaleY;if((h>1||h<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){o=o+h,n?n.scrollTop+=h:this.win.scrollBy(0,h),i=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(r&&!r.empty)for(let a of this.state.facet(Hw))a(r)}get themeClasses(){return f1+" "+(this.state.facet(u1)?R_:P_)+" "+this.state.facet(fb)}updateAttrs(){let e=PO(this,p_,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),r={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Sa)?"true":"false",class:"cm-content",style:`${Ie.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(r["aria-readonly"]="true"),PO(this,D1,r);let n=this.observer.ignore(()=>{let o=cO(this.contentDOM,this.contentAttrs,r),s=cO(this.dom,this.editorAttrs,e);return o||s});return this.editorAttrs=e,this.contentAttrs=r,n}showAnnouncements(e){let r=!0;for(let n of e)for(let o of n.effects)if(o.is(t.announce)){r&&(this.announceDOM.textContent=""),r=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=o.value}}mountStyles(){this.styleModules=this.state.facet(fp);let e=this.state.facet(t.cspNonce);Ls.mount(this.root,this.styleModules.concat(YG).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let r=0;r<this.measureRequests.length;r++)if(this.measureRequests[r].key===e.key){this.measureRequests[r]=e;return}}this.measureRequests.push(e)}}plugin(e){let r=this.pluginMap.get(e);return(r===void 0||r&&r.plugin!=e)&&this.pluginMap.set(e,r=this.plugins.find(n=>n.plugin==e)||null),r&&r.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,r,n){return Ew(this,e,mO(this,e,r,n))}moveByGroup(e,r){return Ew(this,e,mO(this,e,r,n=>vG(this,e.head,n)))}visualLineSide(e,r){let n=this.bidiSpans(e),o=this.textDirectionAt(e.from),s=n[r?n.length-1:0];return ie.cursor(s.side(r,o)+e.from,s.forward(!r,o)?1:-1)}moveToLineBoundary(e,r,n=!0){return yG(this,e,r,n)}moveVertically(e,r,n){return Ew(this,e,wG(this,e,r,n))}domAtPos(e,r=1){return this.docView.domAtPos(e,r)}posAtDOM(e,r=0){return this.docView.posFromDOM(e,r)}posAtCoords(e,r=!0){this.readMeasured();let n=Jw(this,e,r);return n&&n.pos}posAndSideAtCoords(e,r=!0){return this.readMeasured(),Jw(this,e,r)}coordsAtPos(e,r=1){this.readMeasured();let n=this.docView.coordsAt(e,r);if(!n||n.left==n.right)return n;let o=this.state.doc.lineAt(e),s=this.bidiSpans(o),i=s[$s.find(s,e-o.from,-1,r)];return Ip(n,i.dir==Xt.LTR==r>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(c_)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>ZG)return t_(e.length);let r=this.textDirectionAt(e.from),n;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==r&&(s.fresh||e_(s.isolates,n=fO(this,e))))return s.order;n||(n=fO(this,e));let o=QU(e.text,r,n);return this.bidiCache.push(new Pb(e.from,e.to,r,n,!0,o)),o}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Ie.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{qO(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,r={}){return ab.of(new xp(typeof e=="number"?ie.cursor(e):e,r.y,r.x,r.yMargin,r.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:r}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return ab.of(new xp(ie.cursor(n.from),"start","start",n.top-e,r,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Er.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Er.define(()=>({}),{eventObservers:e})}static theme(e,r){let n=Ls.newName(),o=[fb.of(n),fp.of(p1(`.${n}`,e))];return r&&r.dark&&o.push(u1.of(!0)),o}static baseTheme(e){return oi.lowest(fp.of(p1("."+f1,e,D_)))}static findFromDOM(e){var r;let n=e.querySelector(".cm-content"),o=n&&Dr.get(n)||Dr.get(e);return((r=o?.root)===null||r===void 0?void 0:r.view)||null}};ve.styleModule=fp;ve.inputHandler=a_;ve.clipboardInputFilter=P1;ve.clipboardOutputFilter=R1;ve.scrollHandler=u_;ve.focusChangeEffect=l_;ve.perLineTextDirection=c_;ve.exceptionSink=i_;ve.updateListener=Hw;ve.editable=Sa;ve.mouseSelectionStyle=s_;ve.dragMovesSelection=o_;ve.clickAddsSelectionRange=n_;ve.decorations=zb;ve.blockWrappers=h_;ve.outerDecorations=O1;ve.atomicRanges=Mp;ve.bidiIsolatedRanges=m_;ve.scrollMargins=g_;ve.darkTheme=u1;ve.cspNonce=Ce.define({combine:t=>t.length?t[0]:""});ve.contentAttributes=D1;ve.editorAttributes=p_;ve.lineWrapping=ve.contentAttributes.of({class:"cm-lineWrapping"});ve.announce=Qe.define();var ZG=4096,MO={},Pb=class t{constructor(e,r,n,o,s,i){this.from=e,this.to=r,this.dir=n,this.isolates=o,this.fresh=s,this.order=i}static update(e,r){if(r.empty&&!e.some(s=>s.fresh))return e;let n=[],o=e.length?e[e.length-1].dir:Xt.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let i=e[s];i.dir==o&&!r.touchesRange(i.from,i.to)&&n.push(new t(r.mapPos(i.from,1),r.mapPos(i.to,-1),i.dir,i.isolates,!1,i.order))}return n}};function PO(t,e,r){for(let n=t.state.facet(e),o=n.length-1;o>=0;o--){let s=n[o],i=typeof s=="function"?s(t):s;i&&I1(i,r)}return r}var QG=Ie.mac?"mac":Ie.windows?"win":Ie.linux?"linux":"key";function eK(t,e){let r=t.split(/-(?!$)/),n=r[r.length-1];n=="Space"&&(n=" ");let o,s,i,a;for(let l=0;l<r.length-1;++l){let c=r[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))e=="mac"?a=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(n="Alt-"+n),s&&(n="Ctrl-"+n),a&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function pb(t,e,r){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),r!==!1&&e.shiftKey&&(t="Shift-"+t),t}var tK=oi.default(ve.domEventHandlers({keydown(t,e){return L_(O_(e.state),t,e,"editor")}})),ka=Ce.define({enables:tK}),RO=new WeakMap;function O_(t){let e=t.facet(ka),r=RO.get(e);return r||RO.set(e,r=nK(e.reduce((n,o)=>n.concat(o),[]))),r}function __(t,e,r){return L_(O_(t.state),e,t,r)}var ml=null,rK=4e3;function nK(t,e=QG){let r=Object.create(null),n=Object.create(null),o=(i,a)=>{let l=n[i];if(l==null)n[i]=a;else if(l!=a)throw new Error("Key binding "+i+" is used both as a regular binding and as a multi-stroke prefix")},s=(i,a,l,c,d)=>{var u,f;let p=r[i]||(r[i]=Object.create(null)),h=a.split(/ (?!$)/).map(x=>eK(x,e));for(let x=1;x<h.length;x++){let y=h.slice(0,x).join(" ");o(y,!0),p[y]||(p[y]={preventDefault:!0,stopPropagation:!1,run:[m=>{let v=ml={view:m,prefix:y,scope:i};return setTimeout(()=>{ml==v&&(ml=null)},rK),!0}]})}let b=h.join(" ");o(b,!1);let g=p[b]||(p[b]={preventDefault:!1,stopPropagation:!1,run:((f=(u=p._any)===null||u===void 0?void 0:u.run)===null||f===void 0?void 0:f.slice())||[]});l&&g.run.push(l),c&&(g.preventDefault=!0),d&&(g.stopPropagation=!0)};for(let i of t){let a=i.scope?i.scope.split(" "):["editor"];if(i.any)for(let c of a){let d=r[c]||(r[c]=Object.create(null));d._any||(d._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=i;for(let f in d)d[f].run.push(p=>u(p,g1))}let l=i[e]||i.key;if(l)for(let c of a)s(c,l,i.run,i.preventDefault,i.stopPropagation),i.shift&&s(c,"Shift-"+l,i.shift,i.preventDefault,i.stopPropagation)}return r}var g1=null;function L_(t,e,r,n){g1=e;let o=oO(e),s=Gn(o,0),i=os(s)==o.length&&o!=" ",a="",l=!1,c=!1,d=!1;ml&&ml.view==r&&ml.scope==n&&(a=ml.prefix+" ",C_.indexOf(e.keyCode)<0&&(c=!0,ml=null));let u=new Set,f=g=>{if(g){for(let x of g.run)if(!u.has(x)&&(u.add(x),x(r)))return g.stopPropagation&&(d=!0),!0;g.preventDefault&&(g.stopPropagation&&(d=!0),c=!0)}return!1},p=t[n],h,b;return p&&(f(p[a+pb(o,e,!i)])?l=!0:i&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Ie.windows&&e.ctrlKey&&e.altKey)&&!(Ie.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(h=wa[e.keyCode])&&h!=o?(f(p[a+pb(h,e,!0)])||e.shiftKey&&(b=mu[e.keyCode])!=o&&b!=h&&f(p[a+pb(b,e,!1)]))&&(l=!0):i&&e.shiftKey&&f(p[a+pb(o,e,!0)])&&(l=!0),!l&&f(p._any)&&(l=!0)),c&&(l=!0),l&&d&&e.stopPropagation(),g1=null,l}var Dc=class t{constructor(e,r,n,o,s){this.className=e,this.left=r,this.top=n,this.width=o,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,r){return r.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,r,n){if(n.empty){let o=e.coordsAtPos(n.head,n.assoc||1);if(!o)return[];let s=B_(e);return[new t(r,o.left-s.left,o.top-s.top,null,o.bottom-o.top)]}else return oK(e,r,n)}};function B_(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Xt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function DO(t,e,r,n){let o=t.coordsAtPos(e,r*2);if(!o)return n;let s=t.dom.getBoundingClientRect(),i=(o.top+o.bottom)/2,a=t.posAtCoords({x:s.left+1,y:i}),l=t.posAtCoords({x:s.right-1,y:i});return a==null||l==null?n:{from:Math.max(n.from,Math.min(a,l)),to:Math.min(n.to,Math.max(a,l))}}function oK(t,e,r){if(r.to<=t.viewport.from||r.from>=t.viewport.to)return[];let n=Math.max(r.from,t.viewport.from),o=Math.min(r.to,t.viewport.to),s=t.textDirection==Xt.LTR,i=t.contentDOM,a=i.getBoundingClientRect(),l=B_(t),c=i.querySelector(".cm-line"),d=c&&window.getComputedStyle(c),u=a.left+(d?parseInt(d.paddingLeft)+Math.min(0,parseInt(d.textIndent)):0),f=a.right-(d?parseInt(d.paddingRight):0),p=Xw(t,n,1),h=Xw(t,o,-1),b=p.type==qn.Text?p:null,g=h.type==qn.Text?h:null;if(b&&(t.lineWrapping||p.widgetLineBreaks)&&(b=DO(t,n,1,b)),g&&(t.lineWrapping||h.widgetLineBreaks)&&(g=DO(t,o,-1,g)),b&&g&&b.from==g.from&&b.to==g.to)return y(m(r.from,r.to,b));{let S=b?m(r.from,null,b):v(p,!1),w=g?m(null,r.to,g):v(h,!0),C=[];return(b||p).to<(g||h).from-(b&&g?1:0)||p.widgetLineBreaks>1&&S.bottom+t.defaultLineHeight/2<w.top?C.push(x(u,S.bottom,f,w.top)):S.bottom<w.top&&t.elementAtHeight((S.bottom+w.top)/2).type==qn.Text&&(S.bottom=w.top=(S.bottom+w.top)/2),y(S).concat(C).concat(y(w))}function x(S,w,C,A){return new Dc(e,S-l.left,w-l.top,Math.max(0,C-S),A-w)}function y({top:S,bottom:w,horizontal:C}){let A=[];for(let k=0;k<C.length;k+=2)A.push(x(C[k],S,C[k+1],w));return A}function m(S,w,C){let A=1e9,k=-1e9,M=[];function T(N,D,R,O,B){let L=t.coordsAtPos(N,N==C.to?-2:2),H=t.coordsAtPos(R,R==C.from?2:-2);!L||!H||(A=Math.min(L.top,H.top,A),k=Math.max(L.bottom,H.bottom,k),B==Xt.LTR?M.push(s&&D?u:L.left,s&&O?f:H.right):M.push(!s&&O?u:H.left,!s&&D?f:L.right))}let E=S??C.from,P=w??C.to;for(let N of t.visibleRanges)if(N.to>E&&N.from<P)for(let D=Math.max(N.from,E),R=Math.min(N.to,P);;){let O=t.state.doc.lineAt(D);for(let B of t.bidiSpans(O)){let L=B.from+O.from,H=B.to+O.from;if(L>=R)break;H>D&&T(Math.max(L,D),S==null&&L<=E,Math.min(H,R),w==null&&H>=P,B.dir)}if(D=O.to+1,D>=R)break}return M.length==0&&T(E,S==null,P,w==null,t.textDirection),{top:A,bottom:k,horizontal:M}}function v(S,w){let C=a.top+(w?S.top:S.bottom);return{top:C,bottom:C,horizontal:[]}}}function sK(t,e){return t.constructor==e.constructor&&t.eq(e)}var b1=class{constructor(e,r){this.view=e,this.layer=r,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),r.above&&this.dom.classList.add("cm-layer-above"),r.class&&this.dom.classList.add(r.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),r.mount&&r.mount(this.dom,e)}update(e){e.startState.facet(bb)!=e.state.facet(bb)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let r=0,n=e.facet(bb);for(;r<n.length&&n[r]!=this.layer;)r++;this.dom.style.zIndex=String((this.layer.above?150:-1)-r)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:r}=this.view;(e!=this.scaleX||r!=this.scaleY)&&(this.scaleX=e,this.scaleY=r,this.dom.style.transform=`scale(${1/e}, ${1/r})`)}draw(e){if(e.length!=this.drawn.length||e.some((r,n)=>!sK(r,this.drawn[n]))){let r=this.dom.firstChild,n=0;for(let o of e)o.update&&r&&o.constructor&&this.drawn[n].constructor&&o.update(r,this.drawn[n])?(r=r.nextSibling,n++):this.dom.insertBefore(o.draw(),r);for(;r;){let o=r.nextSibling;r.remove(),r=o}this.drawn=e,Ie.safari&&Ie.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},bb=Ce.define();function z_(t){return[Er.define(e=>new b1(e,t)),bb.of(t)]}var Iu=Ce.define({combine(t){return ao(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,r)=>Math.min(e,r),drawRangeCursor:(e,r)=>e||r})}});function $_(t={}){return[Iu.of(t),iK,aK,lK,d_.of(!0)]}function F_(t){return t.startState.facet(Iu)!=t.state.facet(Iu)}var iK=z_({above:!0,markers(t){let{state:e}=t,r=e.facet(Iu),n=[];for(let o of e.selection.ranges){let s=o==e.selection.main;if(o.empty||r.drawRangeCursor&&!(s&&Ie.ios&&r.iosSelectionHandles)){let i=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=o.empty?o:ie.cursor(o.head,o.assoc);for(let l of Dc.forRange(t,i,a))n.push(l)}}return n},update(t,e){t.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let r=F_(t);return r&&OO(t.state,e),t.docChanged||t.selectionSet||r},mount(t,e){OO(e.state,t)},class:"cm-cursorLayer"});function OO(t,e){e.style.animationDuration=t.facet(Iu).cursorBlinkRate+"ms"}var aK=z_({above:!1,markers(t){let e=[],{main:r,ranges:n}=t.state.selection;for(let o of n)if(!o.empty)for(let s of Dc.forRange(t,"cm-selectionBackground",o))e.push(s);if(Ie.ios&&!r.empty&&t.state.facet(Iu).iosSelectionHandles){for(let o of Dc.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ie.cursor(r.from,1)))e.push(o);for(let o of Dc.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ie.cursor(r.to,1)))e.push(o)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||F_(t)},class:"cm-selectionLayer"}),lK=oi.highest(ve.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),H_=Qe.define({map(t,e){return t==null?null:e.mapPos(t)}}),hp=Jr.define({create(){return null},update(t,e){return t!=null&&(t=e.changes.mapPos(t)),e.effects.reduce((r,n)=>n.is(H_)?n.value:r,t)}}),cK=Er.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let r=t.state.field(hp);r==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(hp)!=r||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:t}=this,e=t.state.field(hp),r=e!=null&&t.coordsAtPos(e);if(!r)return null;let n=t.scrollDOM.getBoundingClientRect();return{left:r.left-n.left+t.scrollDOM.scrollLeft*t.scaleX,top:r.top-n.top+t.scrollDOM.scrollTop*t.scaleY,height:r.bottom-r.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:r}=this.view;t?(this.cursor.style.left=t.left/e+"px",this.cursor.style.top=t.top/r+"px",this.cursor.style.height=t.height/r+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(hp)!=t&&this.view.dispatch({effects:H_.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){(t.target==this.view.contentDOM||!this.view.contentDOM.contains(t.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function V_(){return[hp,cK]}function _O(t,e,r,n,o){e.lastIndex=0;for(let s=t.iterRange(r,n),i=r,a;!s.next().done;i+=s.value.length)if(!s.lineBreak)for(;a=e.exec(s.value);)o(i+a.index,a)}function dK(t,e){let r=t.visibleRanges;if(r.length==1&&r[0].from==t.viewport.from&&r[0].to==t.viewport.to)return r;let n=[];for(let{from:o,to:s}of r)o=Math.max(t.state.doc.lineAt(o).from,o-e),s=Math.min(t.state.doc.lineAt(s).to,s+e),n.length&&n[n.length-1].to>=o?n[n.length-1].to=s:n.push({from:o,to:s});return n}var x1=class{constructor(e){let{regexp:r,decoration:n,decorate:o,boundary:s,maxLength:i=1e3}=e;if(!r.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=r,o)this.addMatch=(a,l,c,d)=>o(d,c,c+a[0].length,a,l);else if(typeof n=="function")this.addMatch=(a,l,c,d)=>{let u=n(a,l,c);u&&d(c,c+a[0].length,u)};else if(n)this.addMatch=(a,l,c,d)=>d(c,c+a[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=i}createDeco(e){let r=new ns,n=r.add.bind(r);for(let{from:o,to:s}of dK(e,this.maxLength))_O(e.state.doc,this.regexp,o,s,(i,a)=>this.addMatch(a,e,i,n));return r.finish()}updateDeco(e,r){let n=1e9,o=-1;return e.docChanged&&e.changes.iterChanges((s,i,a,l)=>{l>=e.view.viewport.from&&a<=e.view.viewport.to&&(n=Math.min(a,n),o=Math.max(l,o))}),e.viewportMoved||o-n>1e3?this.createDeco(e.view):o>-1?this.updateRange(e.view,r.map(e.changes),n,o):r}updateRange(e,r,n,o){for(let s of e.visibleRanges){let i=Math.max(s.from,n),a=Math.min(s.to,o);if(a>=i){let l=e.state.doc.lineAt(i),c=l.to<a?e.state.doc.lineAt(a):l,d=Math.max(s.from,l.from),u=Math.min(s.to,c.to);if(this.boundary){for(;i>l.from;i--)if(this.boundary.test(l.text[i-1-l.from])){d=i;break}for(;a<c.to;a++)if(this.boundary.test(c.text[a-c.from])){u=a;break}}let f=[],p,h=(b,g,x)=>f.push(x.range(b,g));if(l==c)for(this.regexp.lastIndex=d-l.from;(p=this.regexp.exec(l.text))&&p.index<u-l.from;)this.addMatch(p,e,p.index+l.from,h);else _O(e.state.doc,this.regexp,d,u,(b,g)=>this.addMatch(g,e,b,h));r=r.update({filterFrom:d,filterTo:u,filter:(b,g)=>b<d||g>u,add:f})}}return r}},y1=/x/.unicode!=null?"gu":"g",uK=new RegExp(`[\0-\b
|
|
490
|
+
-\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,y1),fK={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},Iw=null;function pK(){var t;if(Iw==null&&typeof document<"u"&&document.body){let e=document.body.style;Iw=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return Iw||!1}var xb=Ce.define({combine(t){let e=ao(t,{render:null,specialChars:uK,addSpecialChars:null});return(e.replaceTabs=!pK())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,y1)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,y1)),e}});function j_(t={}){return[xb.of(t),hK()]}var LO=null;function hK(){return LO||(LO=Er.fromClass(class{constructor(t){this.view=t,this.decorations=Fe.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(xb)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new x1({regexp:t.specialChars,decoration:(e,r,n)=>{let{doc:o}=r.state,s=Gn(e[0],0);if(s==9){let i=o.lineAt(n),a=r.state.tabSize,l=va(i.text,a,n-i.from);return Fe.replace({widget:new w1((a-l%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=Fe.replace({widget:new v1(t,s)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(xb);t.startState.facet(xb)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}var mK="\u2022";function gK(t){return t>=32?mK:t==10?"\u2424":String.fromCharCode(9216+t)}var v1=class extends Io{constructor(e,r){super(),this.options=e,this.code=r}eq(e){return e.code==this.code}toDOM(e){let r=gK(this.code),n=e.state.phrase("Control character")+" "+(fK[this.code]||"0x"+this.code.toString(16)),o=this.options.render&&this.options.render(this.code,n,r);if(o)return o;let s=document.createElement("span");return s.textContent=r,s.title=n,s.setAttribute("aria-label",n),s.className="cm-specialChar",s}ignoreEvent(){return!1}},w1=class extends Io{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}};function W_(){return xK}var bK=Fe.line({class:"cm-activeLine"}),xK=Er.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,r=[];for(let n of t.state.selection.ranges){let o=t.lineBlockAt(n.head);o.from>e&&(r.push(bK.range(o.from)),e=o.from)}return Fe.set(r)}},{decorations:t=>t.decorations}),S1=class extends Io{constructor(e){super(),this.content=e}toDOM(e){let r=document.createElement("span");return r.className="cm-placeholder",r.style.pointerEvents="none",r.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),r.setAttribute("aria-hidden","true"),r}coordsAt(e){let r=e.firstChild?gp(e.firstChild):[];if(!r.length)return null;let n=window.getComputedStyle(e.parentNode),o=Ip(r[0],n.direction!="rtl"),s=parseInt(n.lineHeight);return o.bottom-o.top>s*1.5?{left:o.left,right:o.right,top:o.top,bottom:o.top+s}:o}ignoreEvent(){return!1}};function U_(t){let e=Er.fromClass(class{constructor(r){this.view=r,this.placeholder=t?Fe.set([Fe.widget({widget:new S1(t),side:1}).range(0)]):Fe.none}get decorations(){return this.view.state.doc.length?Fe.none:this.placeholder}},{decorations:r=>r.decorations});return typeof t=="string"?[e,ve.contentAttributes.of({"aria-placeholder":t})]:e}var N1=2e3;function yK(t,e,r){let n=Math.min(e.line,r.line),o=Math.max(e.line,r.line),s=[];if(e.off>N1||r.off>N1||e.col<0||r.col<0){let i=Math.min(e.off,r.off),a=Math.max(e.off,r.off);for(let l=n;l<=o;l++){let c=t.doc.line(l);c.length<=a&&s.push(ie.range(c.from+i,c.to+a))}}else{let i=Math.min(e.col,r.col),a=Math.max(e.col,r.col);for(let l=n;l<=o;l++){let c=t.doc.line(l),d=sb(c.text,i,t.tabSize,!0);if(d<0)s.push(ie.cursor(c.to));else{let u=sb(c.text,a,t.tabSize);s.push(ie.range(c.from+d,c.from+u))}}}return s}function vK(t,e){let r=t.coordsAtPos(t.viewport.from);return r?Math.round(Math.abs((r.left-e)/t.defaultCharacterWidth)):-1}function BO(t,e){let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(r),o=r-n.from,s=o>N1?-1:o==n.length?vK(t,e.clientX):va(n.text,t.state.tabSize,r-n.from);return{line:n.number,col:s,off:o}}function wK(t,e){let r=BO(t,e),n=t.state.selection;return r?{update(o){if(o.docChanged){let s=o.changes.mapPos(o.startState.doc.line(r.line).from),i=o.state.doc.lineAt(s);r={line:i.number,col:r.col,off:Math.min(r.off,i.length)},n=n.map(o.changes)}},get(o,s,i){let a=BO(t,o);if(!a)return n;let l=yK(t.state,r,a);return l.length?i?ie.create(l.concat(n.ranges)):ie.create(l):n}}:null}function G_(t){let e=t?.eventFilter||(r=>r.altKey&&r.button==0);return ve.mouseSelectionStyle.of((r,n)=>e(n)?wK(r,n):null)}var SK={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},NK={style:"cursor: crosshair"};function K_(t={}){let[e,r]=SK[t.key||"Alt"],n=Er.fromClass(class{constructor(o){this.view=o,this.isDown=!1}set(o){this.isDown!=o&&(this.isDown=o,this.view.update([]))}},{eventObservers:{keydown(o){this.set(o.keyCode==e||r(o))},keyup(o){(o.keyCode==e||!r(o))&&this.set(!1)},mousemove(o){this.set(r(o))}}});return[n,ve.contentAttributes.of(o=>{var s;return!((s=o.plugin(n))===null||s===void 0)&&s.isDown?NK:null})]}var hb="-10000px",Rb=class{constructor(e,r,n,o){this.facet=r,this.createTooltipView=n,this.removeTooltipView=o,this.input=e.state.facet(r),this.tooltips=this.input.filter(i=>i);let s=null;this.tooltipViews=this.tooltips.map(i=>s=n(i,s))}update(e,r){var n;let o=e.state.facet(this.facet),s=o.filter(l=>l);if(o===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let i=[],a=r?[]:null;for(let l=0;l<s.length;l++){let c=s[l],d=-1;if(c){for(let u=0;u<this.tooltips.length;u++){let f=this.tooltips[u];f&&f.create==c.create&&(d=u)}if(d<0)i[l]=this.createTooltipView(c,l?i[l-1]:null),a&&(a[l]=!!c.above);else{let u=i[l]=this.tooltipViews[d];a&&(a[l]=r[d]),u.update&&u.update(e)}}}for(let l of this.tooltipViews)i.indexOf(l)<0&&(this.removeTooltipView(l),(n=l.destroy)===null||n===void 0||n.call(l));return r&&(a.forEach((l,c)=>r[c]=l),r.length=a.length),this.input=o,this.tooltips=s,this.tooltipViews=i,!0}};function CK(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}var Aw=Ce.define({combine:t=>{var e,r,n;return{position:Ie.ios?"absolute":((e=t.find(o=>o.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((r=t.find(o=>o.parent))===null||r===void 0?void 0:r.parent)||null,tooltipSpace:((n=t.find(o=>o.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||CK}}}),zO=new WeakMap,B1=Er.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(Aw);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Rb(t,Pp,(r,n)=>this.createTooltip(r,n),r=>{this.resizeObserver&&this.resizeObserver.unobserve(r.dom),r.dom.remove()}),this.above=this.manager.tooltips.map(r=>!!r.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(r=>{Date.now()>this.lastTransaction-50&&r.length>0&&r[r.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let r=e||t.geometryChanged,n=t.state.facet(Aw);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let o of this.manager.tooltipViews)o.dom.style.position=this.position;r=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let o of this.manager.tooltipViews)this.container.appendChild(o.dom);r=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);r&&this.maybeMeasure()}createTooltip(t,e){let r=t.create(this.view),n=e?e.dom:null;if(r.dom.classList.add("cm-tooltip"),t.arrow&&!r.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let o=document.createElement("div");o.className="cm-tooltip-arrow",r.dom.appendChild(o)}return r.dom.style.position=this.position,r.dom.style.top=hb,r.dom.style.left="0px",this.container.insertBefore(r.dom,n),r.mount&&r.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(r.dom),r}destroy(){var t,e,r;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(t=n.destroy)===null||t===void 0||t.call(n);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(r=this.intersectionObserver)===null||r===void 0||r.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,r=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Ie.safari){let i=s.getBoundingClientRect();r=Math.abs(i.top+1e4)>1||Math.abs(i.left)>1}else r=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(r||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),o=_1(this.view);return{visible:{left:n.left+o.left,top:n.top+o.top,right:n.right-o.right,bottom:n.bottom-o.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,i)=>{let a=this.manager.tooltipViews[i];return a.getCoords?a.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Aw).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:r}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:r,space:n,scaleX:o,scaleY:s}=t,i=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:d}=c,u=t.pos[a],f=t.size[a];if(!u||l.clip!==!1&&(u.bottom<=Math.max(r.top,n.top)||u.top>=Math.min(r.bottom,n.bottom)||u.right<Math.max(r.left,n.left)-.1||u.left>Math.min(r.right,n.right)+.1)){d.style.top=hb;continue}let p=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,h=p?7:0,b=f.right-f.left,g=(e=zO.get(c))!==null&&e!==void 0?e:f.bottom-f.top,x=c.offset||EK,y=this.view.textDirection==Xt.LTR,m=f.width>n.right-n.left?y?n.left:n.right-f.width:y?Math.max(n.left,Math.min(u.left-(p?14:0)+x.x,n.right-b)):Math.min(Math.max(n.left,u.left-b+(p?14:0)-x.x),n.right-b),v=this.above[a];!l.strictSide&&(v?u.top-g-h-x.y<n.top:u.bottom+g+h+x.y>n.bottom)&&v==n.bottom-u.bottom>u.top-n.top&&(v=this.above[a]=!v);let S=(v?u.top-n.top:n.bottom-u.bottom)-h;if(S<g&&c.resize!==!1){if(S<this.view.defaultLineHeight){d.style.top=hb;continue}zO.set(c,g),d.style.height=(g=S)/s+"px"}else d.style.height&&(d.style.height="");let w=v?u.top-g-h-x.y:u.bottom+h+x.y,C=m+b;if(c.overlap!==!0)for(let A of i)A.left<C&&A.right>m&&A.top<w+g&&A.bottom>w&&(w=v?A.top-g-2-h:A.bottom+h+2);if(this.position=="absolute"?(d.style.top=(w-t.parent.top)/s+"px",$O(d,(m-t.parent.left)/o)):(d.style.top=w/s+"px",$O(d,m/o)),p){let A=u.left+(y?x.x:-x.x)-(m+14-7);p.style.left=A/o+"px"}c.overlap!==!0&&i.push({left:m,top:w,right:C,bottom:w+g}),d.classList.toggle("cm-tooltip-above",v),d.classList.toggle("cm-tooltip-below",!v),c.positioned&&c.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=hb}},{eventObservers:{scroll(){this.maybeMeasure()}}});function $O(t,e){let r=parseInt(t.style.left,10);(isNaN(r)||Math.abs(e-r)>1)&&(t.style.left=e+"px")}var kK=ve.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),EK={x:0,y:0},Pp=Ce.define({enables:[B1,kK]}),Db=Ce.define({combine:t=>t.reduce((e,r)=>e.concat(r),[])}),Ob=class t{static create(e){return new t(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Rb(e,Db,(r,n)=>this.createHostedView(r,n),r=>r.dom.remove())}createHostedView(e,r){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,r?r.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let r of this.manager.tooltipViews)r.mount&&r.mount(e);this.mounted=!0}positioned(e){for(let r of this.manager.tooltipViews)r.positioned&&r.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let r of this.manager.tooltipViews)(e=r.destroy)===null||e===void 0||e.call(r)}passProp(e){let r;for(let n of this.manager.tooltipViews){let o=n[e];if(o!==void 0){if(r===void 0)r=o;else if(r!==o)return}}return r}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},TK=Pp.compute([Db],t=>{let e=t.facet(Db);return e.length===0?null:{pos:Math.min(...e.map(r=>r.pos)),end:Math.max(...e.map(r=>{var n;return(n=r.end)!==null&&n!==void 0?n:r.pos})),create:Ob.create,above:e[0].above,arrow:e.some(r=>r.arrow)}}),C1=class{constructor(e,r,n,o,s){this.view=e,this.source=r,this.field=n,this.setHover=o,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:r}=this,n=e.docView.tile.nearest(r.target);if(!n)return;let o,s=1;if(n.isWidget())o=n.posAtStart;else{if(o=e.posAtCoords(r),o==null)return;let a=e.coordsAtPos(o);if(!a||r.y<a.top||r.y>a.bottom||r.x<a.left-e.defaultCharacterWidth||r.x>a.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(o)).find(d=>d.from<=o&&d.to>=o),c=l&&l.dir==Xt.RTL?-1:1;s=r.x<a.left?-c:c}let i=this.source(e,o,s);if(i?.then){let a=this.pending={pos:o};i.then(l=>{this.pending==a&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Kn(e.state,l,"hover tooltip"))}else i&&!(Array.isArray(i)&&!i.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(i)?i:[i])})}get tooltip(){let e=this.view.plugin(B1),r=e?e.manager.tooltips.findIndex(n=>n.create==Ob.create):-1;return r>-1?e.manager.tooltipViews[r]:null}mousemove(e){var r,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:o,tooltip:s}=this;if(o.length&&s&&!IK(s.dom,e)||this.pending){let{pos:i}=o[0]||this.pending,a=(n=(r=o[0])===null||r===void 0?void 0:r.end)!==null&&n!==void 0?n:i;(i==a?this.view.posAtCoords(this.lastMove)!=i:!AK(this.view,i,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:r}=this;if(r.length){let{tooltip:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let r=n=>{e.removeEventListener("mouseleave",r),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",r)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},mb=4;function IK(t,e){let{left:r,right:n,top:o,bottom:s}=t.getBoundingClientRect(),i;if(i=t.querySelector(".cm-tooltip-arrow")){let a=i.getBoundingClientRect();o=Math.min(a.top,o),s=Math.max(a.bottom,s)}return e.clientX>=r-mb&&e.clientX<=n+mb&&e.clientY>=o-mb&&e.clientY<=s+mb}function AK(t,e,r,n,o,s){let i=t.scrollDOM.getBoundingClientRect(),a=t.documentTop+t.documentPadding.top+t.contentHeight;if(i.left>n||i.right<n||i.top>o||Math.min(i.bottom,a)<o)return!1;let l=t.posAtCoords({x:n,y:o},!1);return l>=e&&l<=r}function q_(t,e={}){let r=Qe.define(),n=Jr.define({create(){return[]},update(o,s){if(o.length&&(e.hideOnChange&&(s.docChanged||s.selection)?o=[]:e.hideOn&&(o=o.filter(i=>!e.hideOn(s,i))),s.docChanged)){let i=[];for(let a of o){let l=s.changes.mapPos(a.pos,-1,Un.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),a);c.pos=l,c.end!=null&&(c.end=s.changes.mapPos(c.end)),i.push(c)}}o=i}for(let i of s.effects)i.is(r)&&(o=i.value),i.is(MK)&&(o=[]);return o},provide:o=>Db.from(o)});return{active:n,extension:[n,Er.define(o=>new C1(o,t,n,r,e.hoverTime||300)),TK]}}function z1(t,e){let r=t.plugin(B1);if(!r)return null;let n=r.manager.tooltips.indexOf(e);return n<0?null:r.manager.tooltipViews[n]}var MK=Qe.define();var FO=Ce.define({combine(t){let e,r;for(let n of t)e=e||n.topContainer,r=r||n.bottomContainer;return{topContainer:e,bottomContainer:r}}});function Rp(t,e){let r=t.plugin(Y_),n=r?r.specs.indexOf(e):-1;return n>-1?r.panels[n]:null}var Y_=Er.fromClass(class{constructor(t){this.input=t.state.facet(Bc),this.specs=this.input.filter(r=>r),this.panels=this.specs.map(r=>r(t));let e=t.state.facet(FO);this.top=new yu(t,!0,e.topContainer),this.bottom=new yu(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(r=>r.top)),this.bottom.sync(this.panels.filter(r=>!r.top));for(let r of this.panels)r.dom.classList.add("cm-panel"),r.mount&&r.mount()}update(t){let e=t.state.facet(FO);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new yu(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new yu(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let r=t.state.facet(Bc);if(r!=this.input){let n=r.filter(l=>l),o=[],s=[],i=[],a=[];for(let l of n){let c=this.specs.indexOf(l),d;c<0?(d=l(t.view),a.push(d)):(d=this.panels[c],d.update&&d.update(t)),o.push(d),(d.top?s:i).push(d)}this.specs=n,this.panels=o,this.top.sync(s),this.bottom.sync(i);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let n of this.panels)n.update&&n.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>ve.scrollMargins.of(e=>{let r=e.plugin(t);return r&&{top:r.top.scrollMargin(),bottom:r.bottom.scrollMargin()}})}),yu=class{constructor(e,r,n){this.view=e,this.top=r,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let r of this.panels)r.destroy&&e.indexOf(r)<0&&r.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let r=this.container||this.view.dom;r.insertBefore(this.dom,this.top?r.firstChild:null)}let e=this.dom.firstChild;for(let r of this.panels)if(r.dom.parentNode==this.dom){for(;e!=r.dom;)e=HO(e);e=e.nextSibling}else this.dom.insertBefore(r.dom,e);for(;e;)e=HO(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function HO(t){let e=t.nextSibling;return t.remove(),e}var Bc=Ce.define({enables:Y_});function X_(t,e){let r,n=new Promise(i=>r=i),o=i=>PK(i,e,r);t.state.field(Mw,!1)?t.dispatch({effects:J_.of(o)}):t.dispatch({effects:Qe.appendConfig.of(Mw.init(()=>[o]))});let s=Z_.of(o);return{close:s,result:n.then(i=>((t.win.queueMicrotask||(l=>t.win.setTimeout(l,10)))(()=>{t.state.field(Mw).indexOf(o)>-1&&t.dispatch({effects:s})}),i))}}var Mw=Jr.define({create(){return[]},update(t,e){for(let r of e.effects)r.is(J_)?t=[r.value].concat(t):r.is(Z_)&&(t=t.filter(n=>n!=r.value));return t},provide:t=>Bc.computeN([t],e=>e.field(t))}),J_=Qe.define(),Z_=Qe.define();function PK(t,e,r){let n=e.content?e.content(t,()=>i(null)):null;if(!n){if(n=Wt("form"),e.input){let a=Wt("input",e.input);/^(text|password|number|email|tel|url)$/.test(a.type)&&a.classList.add("cm-textfield"),a.name||(a.name="input"),n.appendChild(Wt("label",(e.label||"")+": ",a))}else n.appendChild(document.createTextNode(e.label||""));n.appendChild(document.createTextNode(" ")),n.appendChild(Wt("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let o=n.nodeName=="FORM"?[n]:n.querySelectorAll("form");for(let a=0;a<o.length;a++){let l=o[a];l.addEventListener("keydown",c=>{c.keyCode==27?(c.preventDefault(),i(null)):c.keyCode==13&&(c.preventDefault(),i(l))}),l.addEventListener("submit",c=>{c.preventDefault(),i(l)})}let s=Wt("div",n,Wt("button",{onclick:()=>i(null),"aria-label":t.state.phrase("close"),class:"cm-dialog-close",type:"button"},["\xD7"]));e.class&&(s.className=e.class),s.classList.add("cm-dialog");function i(a){s.contains(s.ownerDocument.activeElement)&&t.focus(),r(a)}return{dom:s,top:e.top,mount:()=>{if(e.focus){let a;typeof e.focus=="string"?a=n.querySelector(e.focus):a=n.querySelector("input")||n.querySelector("button"),a&&"select"in a?a.select():a&&"focus"in a&&a.focus()}}}}var is=class extends _s{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};is.prototype.elementClass="";is.prototype.toDOM=void 0;is.prototype.mapMode=Un.TrackBefore;is.prototype.startSide=is.prototype.endSide=-1;is.prototype.point=!0;var yb=Ce.define(),RK=Ce.define(),DK={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Dt.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Np=Ce.define();function $1(t){return[Q_(),Np.of({...DK,...t})]}var k1=Ce.define({combine:t=>t.some(e=>e)});function Q_(t){let e=[OK];return t&&t.fixed===!1&&e.push(k1.of(!0)),e}var OK=Er.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Np).map(e=>new _b(t,e)),this.fixed=!t.state.facet(k1);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,r=t.view.viewport,n=Math.min(e.to,r.to)-Math.max(e.from,r.from);this.syncGutters(n<(r.to-r.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(k1)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let r=Dt.iter(this.view.state.facet(yb),this.view.viewport.from),n=[],o=this.gutters.map(s=>new T1(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(s.type)){let i=!0;for(let a of s.type)if(a.type==qn.Text&&i){E1(r,n,a.from);for(let l of o)l.line(this.view,a,n);i=!1}else if(a.widget)for(let l of o)l.widget(this.view,a)}else if(s.type==qn.Text){E1(r,n,s.from);for(let i of o)i.line(this.view,s,n)}else if(s.widget)for(let i of o)i.widget(this.view,s);for(let s of o)s.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Np),r=t.state.facet(Np),n=t.docChanged||t.heightChanged||t.viewportChanged||!Dt.eq(t.startState.facet(yb),t.state.facet(yb),t.view.viewport.from,t.view.viewport.to);if(e==r)for(let o of this.gutters)o.update(t)&&(n=!0);else{n=!0;let o=[];for(let s of r){let i=e.indexOf(s);i<0?o.push(new _b(this.view,s)):(this.gutters[i].update(t),o.push(this.gutters[i]))}for(let s of this.gutters)s.dom.remove(),o.indexOf(s)<0&&s.destroy();for(let s of o)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=o}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>ve.scrollMargins.of(e=>{let r=e.plugin(t);if(!r||r.gutters.length==0||!r.fixed)return null;let n=r.dom.offsetWidth*e.scaleX,o=r.domAfter?r.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Xt.LTR?{left:n,right:o}:{right:n,left:o}})});function VO(t){return Array.isArray(t)?t:[t]}function E1(t,e,r){for(;t.value&&t.from<=r;)t.from==r&&e.push(t.value),t.next()}var T1=class{constructor(e,r,n){this.gutter=e,this.height=n,this.i=0,this.cursor=Dt.iter(e.markers,r.from)}addElement(e,r,n){let{gutter:o}=this,s=(r.top-this.height)/e.scaleY,i=r.height/e.scaleY;if(this.i==o.elements.length){let a=new Lb(e,i,s,n);o.elements.push(a),o.dom.appendChild(a.dom)}else o.elements[this.i].update(e,i,s,n);this.height=r.bottom,this.i++}line(e,r,n){let o=[];E1(this.cursor,o,r.from),n.length&&(o=o.concat(n));let s=this.gutter.config.lineMarker(e,r,o);s&&o.unshift(s);let i=this.gutter;o.length==0&&!i.config.renderEmptyElements||this.addElement(e,r,o)}widget(e,r){let n=this.gutter.config.widgetMarker(e,r.widget,r),o=n?[n]:null;for(let s of e.state.facet(RK)){let i=s(e,r.widget,r);i&&(o||(o=[])).push(i)}o&&this.addElement(e,r,o)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let r=e.elements.pop();e.dom.removeChild(r.dom),r.destroy()}}},_b=class{constructor(e,r){this.view=e,this.config=r,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in r.domEventHandlers)this.dom.addEventListener(n,o=>{let s=o.target,i;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let l=s.getBoundingClientRect();i=(l.top+l.bottom)/2}else i=o.clientY;let a=e.lineBlockAtHeight(i-e.documentTop);r.domEventHandlers[n](e,a,o)&&o.preventDefault()});this.markers=VO(r.markers(e)),r.initialSpacer&&(this.spacer=new Lb(e,0,0,[r.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let r=this.markers;if(this.markers=VO(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let o=this.config.updateSpacer(this.spacer.markers[0],e);o!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[o])}let n=e.view.viewport;return!Dt.eq(this.markers,r,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Lb=class{constructor(e,r,n,o){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,r,n,o)}update(e,r,n,o){this.height!=r&&(this.height=r,this.dom.style.height=r+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),_K(this.markers,o)||this.setMarkers(e,o)}setMarkers(e,r){let n="cm-gutterElement",o=this.dom.firstChild;for(let s=0,i=0;;){let a=i,l=s<r.length?r[s++]:null,c=!1;if(l){let d=l.elementClass;d&&(n+=" "+d);for(let u=i;u<this.markers.length;u++)if(this.markers[u].compare(l)){a=u,c=!0;break}}else a=this.markers.length;for(;i<a;){let d=this.markers[i++];if(d.toDOM){d.destroy(o);let u=o.nextSibling;o.remove(),o=u}}if(!l)break;l.toDOM&&(c?o=o.nextSibling:this.dom.insertBefore(l.toDOM(e),o)),c&&i++}this.dom.className=n,this.markers=r}destroy(){this.setMarkers(null,[])}};function _K(t,e){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].compare(e[r]))return!1;return!0}var LK=Ce.define(),BK=Ce.define(),vu=Ce.define({combine(t){return ao(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,r){let n=Object.assign({},e);for(let o in r){let s=n[o],i=r[o];n[o]=s?(a,l,c)=>s(a,l,c)||i(a,l,c):i}return n}})}}),Cp=class extends is{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Pw(t,e){return t.state.facet(vu).formatNumber(e,t.state)}var zK=Np.compute([vu],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(LK)},lineMarker(e,r,n){return n.some(o=>o.toDOM)?null:new Cp(Pw(e,e.state.doc.lineAt(r.from).number))},widgetMarker:(e,r,n)=>{for(let o of e.state.facet(BK)){let s=o(e,r,n);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(vu)!=e.state.facet(vu),initialSpacer(e){return new Cp(Pw(e,jO(e.state.doc.lines)))},updateSpacer(e,r){let n=Pw(r.view,jO(r.view.state.doc.lines));return n==e.number?e:new Cp(n)},domEventHandlers:t.facet(vu).domEventHandlers,side:"before"}));function e3(t={}){return[vu.of(t),Q_(),zK]}function jO(t){let e=9;for(;e<t;)e=e*10+9;return e}var $K=new class extends is{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},FK=yb.compute(["selection"],t=>{let e=[],r=-1;for(let n of t.selection.ranges){let o=t.doc.lineAt(n.head).from;o>r&&(r=o,e.push($K.range(o)))}return Dt.of(e)});function t3(){return FK}var HK=0,Dp=class{constructor(e,r){this.from=e,this.to=r}},yt=class{constructor(e={}){this.id=HK++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=as.match(e)),r=>{let n=e(r);return n===void 0?null:[this,n]}}};yt.closedBy=new yt({deserialize:t=>t.split(" ")});yt.openedBy=new yt({deserialize:t=>t.split(" ")});yt.group=new yt({deserialize:t=>t.split(" ")});yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});yt.contextHash=new yt({perNode:!0});yt.lookAhead=new yt({perNode:!0});yt.mounted=new yt({perNode:!0});var zc=class{constructor(e,r,n,o=!1){this.tree=e,this.overlay=r,this.parser=n,this.bracketed=o}static get(e){return e&&e.props&&e.props[yt.mounted.id]}},VK=Object.create(null),as=class t{constructor(e,r,n,o=0){this.name=e,this.props=r,this.id=n,this.flags=o}static define(e){let r=e.props&&e.props.length?Object.create(null):VK,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),o=new t(e.name||"",r,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(o)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");r[s[0].id]=s[1]}}return o}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let r=this.prop(yt.group);return r?r.indexOf(e)>-1:!1}return this.id==e}static match(e){let r=Object.create(null);for(let n in e)for(let o of n.split(" "))r[o]=e[n];return n=>{for(let o=n.prop(yt.group),s=-1;s<(o?o.length:0);s++){let i=r[s<0?n.name:o[s]];if(i)return i}}}};as.none=new as("",Object.create(null),0,8);var Fb=new WeakMap,r3=new WeakMap,Zr;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Zr||(Zr={}));var Yn=class t{constructor(e,r,n,o,s){if(this.type=e,this.children=r,this.positions=n,this.length=o,this.props=null,s&&s.length){this.props=Object.create(null);for(let[i,a]of s)this.props[typeof i=="number"?i:i.id]=a}}toString(){let e=zc.get(this);if(e&&!e.overlay)return e.tree.toString();let r="";for(let n of this.children){let o=n.toString();o&&(r&&(r+=","),r+=o)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(r.length?"("+r+")":""):r}cursor(e=0){return new Lp(this.topNode,e)}cursorAt(e,r=0,n=0){let o=Fb.get(this)||this.topNode,s=new Lp(o);return s.moveTo(e,r),Fb.set(this,s._tree),s}get topNode(){return new $i(this,0,0,null)}resolve(e,r=0){let n=Op(Fb.get(this)||this.topNode,e,r,!1);return Fb.set(this,n),n}resolveInner(e,r=0){let n=Op(r3.get(this)||this.topNode,e,r,!0);return r3.set(this,n),n}resolveStack(e,r=0){return jK(this,e,r)}iterate(e){let{enter:r,leave:n,from:o=0,to:s=this.length}=e,i=e.mode||0,a=(i&Zr.IncludeAnonymous)>0;for(let l=this.cursor(i|Zr.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=o&&(!a&&l.type.isAnonymous||r(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&n&&(a||!l.type.isAnonymous)&&n(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let r in this.props)e.push([+r,this.props[r]]);return e}balance(e={}){return this.children.length<=8?this:G1(as.none,this.children,this.positions,0,this.children.length,0,this.length,(r,n,o)=>new t(this.type,r,n,o,this.propValues),e.makeTree||((r,n,o)=>new t(as.none,r,n,o)))}static build(e){return WK(e)}};Yn.empty=new Yn(as.none,[],[],0);var F1=class t{constructor(e,r){this.buffer=e,this.index=r}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new t(this.buffer,this.index)}},yl=class t{constructor(e,r,n){this.buffer=e,this.length=r,this.set=n}get type(){return as.none}toString(){let e=[];for(let r=0;r<this.buffer.length;)e.push(this.childString(r)),r=this.buffer[r+3];return e.join(",")}childString(e){let r=this.buffer[e],n=this.buffer[e+3],o=this.set.types[r],s=o.name;if(/\W/.test(s)&&!o.isError&&(s=JSON.stringify(s)),e+=4,n==e)return s;let i=[];for(;e<n;)i.push(this.childString(e)),e=this.buffer[e+3];return s+"("+i.join(",")+")"}findChild(e,r,n,o,s){let{buffer:i}=this,a=-1;for(let l=e;l!=r&&!(s3(s,o,i[l+1],i[l+2])&&(a=l,n>0));l=i[l+3]);return a}slice(e,r,n){let o=this.buffer,s=new Uint16Array(r-e),i=0;for(let a=e,l=0;a<r;){s[l++]=o[a++],s[l++]=o[a++]-n;let c=s[l++]=o[a++]-n;s[l++]=o[a++]-e,i=Math.max(i,c)}return new t(s,i,this.set)}};function s3(t,e,r,n){switch(t){case-2:return r<e;case-1:return n>=e&&r<e;case 0:return r<e&&n>e;case 1:return r<=e&&n>e;case 2:return n>e;case 4:return!0}}function Op(t,e,r,n){for(var o;t.from==t.to||(r<1?t.from>=e:t.from>e)||(r>-1?t.to<=e:t.to<e);){let i=!n&&t instanceof $i&&t.index<0?null:t.parent;if(!i)return t;t=i}let s=n?0:Zr.IgnoreOverlays;if(n)for(let i=t,a=i.parent;a;i=a,a=i.parent)i instanceof $i&&i.index<0&&((o=a.enter(e,r,s))===null||o===void 0?void 0:o.from)!=i.from&&(t=a);for(;;){let i=t.enter(e,r,s);if(!i)return t;t=i}}var Vb=class{cursor(e=0){return new Lp(this,e)}getChild(e,r=null,n=null){let o=n3(this,e,r,n);return o.length?o[0]:null}getChildren(e,r=null,n=null){return n3(this,e,r,n)}resolve(e,r=0){return Op(this,e,r,!1)}resolveInner(e,r=0){return Op(this,e,r,!0)}matchContext(e){return H1(this.parent,e)}enterUnfinishedNodesBefore(e){let r=this.childBefore(e),n=this;for(;r;){let o=r.lastChild;if(!o||o.to!=r.to)break;o.type.isError&&o.from==o.to?(n=r,r=o.prevSibling):r=o}return n}get node(){return this}get next(){return this.parent}},$i=class t extends Vb{constructor(e,r,n,o){super(),this._tree=e,this.from=r,this.index=n,this._parent=o}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,r,n,o,s=0){for(let i=this;;){for(let{children:a,positions:l}=i._tree,c=r>0?a.length:-1;e!=c;e+=r){let d=a[e],u=l[e]+i.from,f;if(!(!(s&Zr.EnterBracketed&&d instanceof Yn&&(f=zc.get(d))&&!f.overlay&&f.bracketed&&n>=u&&n<=u+d.length)&&!s3(o,n,u,u+d.length))){if(d instanceof yl){if(s&Zr.ExcludeBuffers)continue;let p=d.findChild(0,d.buffer.length,r,n-u,o);if(p>-1)return new _p(new V1(i,d,e,u),null,p)}else if(s&Zr.IncludeAnonymous||!d.type.isAnonymous||U1(d)){let p;if(!(s&Zr.IgnoreMounts)&&(p=zc.get(d))&&!p.overlay)return new t(p.tree,u,e,i);let h=new t(d,u,e,i);return s&Zr.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(r<0?d.children.length-1:0,r,n,o,s)}}}if(s&Zr.IncludeAnonymous||!i.type.isAnonymous||(i.index>=0?e=i.index+r:e=r<0?-1:i._parent._tree.children.length,i=i._parent,!i))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,r,n=0){let o;if(!(n&Zr.IgnoreOverlays)&&(o=zc.get(this._tree))&&o.overlay){let s=e-this.from,i=n&Zr.EnterBracketed&&o.bracketed;for(let{from:a,to:l}of o.overlay)if((r>0||i?a<=s:a<s)&&(r<0||i?l>=s:l>s))return new t(o.tree,o.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,r,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function n3(t,e,r,n){let o=t.cursor(),s=[];if(!o.firstChild())return s;if(r!=null){for(let i=!1;!i;)if(i=o.type.is(r),!o.nextSibling())return s}for(;;){if(n!=null&&o.type.is(n))return s;if(o.type.is(e)&&s.push(o.node),!o.nextSibling())return n==null?s:[]}}function H1(t,e,r=e.length-1){for(let n=t;r>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[r]&&e[r]!=n.name)return!1;r--}}return!0}var V1=class{constructor(e,r,n,o){this.parent=e,this.buffer=r,this.index=n,this.start=o}},_p=class t extends Vb{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,r,n){super(),this.context=e,this._parent=r,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,r,n){let{buffer:o}=this.context,s=o.findChild(this.index+4,o.buffer[this.index+3],e,r-this.context.start,n);return s<0?null:new t(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,r,n=0){if(n&Zr.ExcludeBuffers)return null;let{buffer:o}=this.context,s=o.findChild(this.index+4,o.buffer[this.index+3],r>0?1:-1,e-this.context.start,r);return s<0?null:new t(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,r=e.buffer[this.index+3];return r<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new t(this.context,this._parent,r):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,r=this._parent?this._parent.index+4:0;return this.index==r?this.externalSibling(-1):new t(this.context,this._parent,e.findChild(r,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],r=[],{buffer:n}=this.context,o=this.index+4,s=n.buffer[this.index+3];if(s>o){let i=n.buffer[this.index+1];e.push(n.slice(o,s,i)),r.push(0)}return new Yn(this.type,e,r,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function i3(t){if(!t.length)return null;let e=0,r=t[0];for(let s=1;s<t.length;s++){let i=t[s];(i.from>r.from||i.to<r.to)&&(r=i,e=s)}let n=r instanceof $i&&r.index<0?null:r.parent,o=t.slice();return n?o[e]=n:o.splice(e,1),new j1(o,r)}var j1=class{constructor(e,r){this.heads=e,this.node=r}get next(){return i3(this.heads)}};function jK(t,e,r){let n=t.resolveInner(e,r),o=null;for(let s=n instanceof $i?n:n.context.parent;s;s=s.parent)if(s.index<0){let i=s.parent;(o||(o=[n])).push(i.resolve(e,r)),s=i}else{let i=zc.get(s.tree);if(i&&i.overlay&&i.overlay[0].from<=e&&i.overlay[i.overlay.length-1].to>=e){let a=new $i(i.tree,i.overlay[0].from+s.from,-1,s);(o||(o=[n])).push(Op(a,e,r,!1))}}return o?i3(o):n}var Lp=class{get name(){return this.type.name}constructor(e,r=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=r&~Zr.EnterBracketed,e instanceof $i)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,r){this.index=e;let{start:n,buffer:o}=this.buffer;return this.type=r||o.set.types[o.buffer[e]],this.from=n+o.buffer[e+1],this.to=n+o.buffer[e+2],!0}yield(e){return e?e instanceof $i?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,r,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,r,n,this.mode));let{buffer:o}=this.buffer,s=o.findChild(this.index+4,o.buffer[this.index+3],e,r-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,r,n=this.mode){return this.buffer?n&Zr.ExcludeBuffers?!1:this.enterChild(1,e,r):this.yield(this._tree.enter(e,r,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Zr.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Zr.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:r}=this.buffer,n=this.stack.length-1;if(e<0){let o=n<0?0:this.stack[n]+4;if(this.index!=o)return this.yieldBuf(r.findChild(o,this.index,-1,0,4))}else{let o=r.buffer[this.index+3];if(o<(n<0?r.buffer.length:r.buffer[this.stack[n]+3]))return this.yieldBuf(o)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let r,n,{buffer:o}=this;if(o){if(e>0){if(this.index<o.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(o.buffer.buffer[s+3]<this.index)return!1;({index:r,parent:n}=o)}else({index:r,_parent:n}=this._tree);for(;n;{index:r,_parent:n}=n)if(r>-1)for(let s=r+e,i=e<0?-1:n._tree.children.length;s!=i;s+=e){let a=n._tree.children[s];if(this.mode&Zr.IncludeAnonymous||a instanceof yl||!a.type.isAnonymous||U1(a))return!1}return!0}move(e,r){if(r&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,r=0){for(;(this.from==this.to||(r<1?this.from>=e:this.from>e)||(r>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,r););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,r=null,n=0;if(e&&e.context==this.buffer)e:for(let o=this.index,s=this.stack.length;s>=0;){for(let i=e;i;i=i._parent)if(i.index==o){if(o==this.index)return i;r=i,n=s+1;break e}o=this.stack[--s]}for(let o=n;o<this.stack.length;o++)r=new _p(this.buffer,r,this.stack[o]);return this.bufferNode=new _p(this.buffer,r,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,r){for(let n=0;;){let o=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(o=!0)}for(;;){if(o&&r&&r(this),o=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,o=!0}}}matchContext(e){if(!this.buffer)return H1(this.node.parent,e);let{buffer:r}=this.buffer,{types:n}=r.set;for(let o=e.length-1,s=this.stack.length-1;o>=0;s--){if(s<0)return H1(this._tree,e,o);let i=n[r.buffer[this.stack[s]]];if(!i.isAnonymous){if(e[o]&&e[o]!=i.name)return!1;o--}}return!0}};function U1(t){return t.children.some(e=>e instanceof yl||!e.type.isAnonymous||U1(e))}function WK(t){var e;let{buffer:r,nodeSet:n,maxBufferLength:o=1024,reused:s=[],minRepeatType:i=n.types.length}=t,a=Array.isArray(r)?new F1(r,r.length):r,l=n.types,c=0,d=0;function u(S,w,C,A,k,M){let{id:T,start:E,end:P,size:N}=a,D=d,R=c;if(N<0)if(a.next(),N==-1){let j=s[T];C.push(j),A.push(E-S);return}else if(N==-3){c=T;return}else if(N==-4){d=T;return}else throw new RangeError(`Unrecognized record size: ${N}`);let O=l[T],B,L,H=E-S;if(P-E<=o&&(L=g(a.pos-w,k))){let j=new Uint16Array(L.size-L.skip),$=a.pos-L.size,q=j.length;for(;a.pos>$;)q=x(L.start,j,q);B=new yl(j,P-L.start,n),H=L.start-S}else{let j=a.pos-N;a.next();let $=[],q=[],F=T>=i?T:-1,_=0,W=P;for(;a.pos>j;)F>=0&&a.id==F&&a.size>=0?(a.end<=W-o&&(h($,q,E,_,a.end,W,F,D,R),_=$.length,W=a.end),a.next()):M>2500?f(E,j,$,q):u(E,j,$,q,F,M+1);if(F>=0&&_>0&&_<$.length&&h($,q,E,_,E,W,F,D,R),$.reverse(),q.reverse(),F>-1&&_>0){let V=p(O,R);B=G1(O,$,q,0,$.length,0,P-E,V,V)}else B=b(O,$,q,P-E,D-P,R)}C.push(B),A.push(H)}function f(S,w,C,A){let k=[],M=0,T=-1;for(;a.pos>w;){let{id:E,start:P,end:N,size:D}=a;if(D>4)a.next();else{if(T>-1&&P<T)break;T<0&&(T=N-o),k.push(E,P,N),M++,a.next()}}if(M){let E=new Uint16Array(M*4),P=k[k.length-2];for(let N=k.length-3,D=0;N>=0;N-=3)E[D++]=k[N],E[D++]=k[N+1]-P,E[D++]=k[N+2]-P,E[D++]=D;C.push(new yl(E,k[2]-P,n)),A.push(P-S)}}function p(S,w){return(C,A,k)=>{let M=0,T=C.length-1,E,P;if(T>=0&&(E=C[T])instanceof Yn){if(!T&&E.type==S&&E.length==k)return E;(P=E.prop(yt.lookAhead))&&(M=A[T]+E.length+P)}return b(S,C,A,k,M,w)}}function h(S,w,C,A,k,M,T,E,P){let N=[],D=[];for(;S.length>A;)N.push(S.pop()),D.push(w.pop()+C-k);S.push(b(n.types[T],N,D,M-k,E-M,P)),w.push(k-C)}function b(S,w,C,A,k,M,T){if(M){let E=[yt.contextHash,M];T=T?[E].concat(T):[E]}if(k>25){let E=[yt.lookAhead,k];T=T?[E].concat(T):[E]}return new Yn(S,w,C,A,T)}function g(S,w){let C=a.fork(),A=0,k=0,M=0,T=C.end-o,E={size:0,start:0,skip:0};e:for(let P=C.pos-S;C.pos>P;){let N=C.size;if(C.id==w&&N>=0){E.size=A,E.start=k,E.skip=M,M+=4,A+=4,C.next();continue}let D=C.pos-N;if(N<0||D<P||C.start<T)break;let R=C.id>=i?4:0,O=C.start;for(C.next();C.pos>D;){if(C.size<0)if(C.size==-3||C.size==-4)R+=4;else break e;else C.id>=i&&(R+=4);C.next()}k=O,A+=N,M+=R}return(w<0||A==S)&&(E.size=A,E.start=k,E.skip=M),E.size>4?E:void 0}function x(S,w,C){let{id:A,start:k,end:M,size:T}=a;if(a.next(),T>=0&&A<i){let E=C;if(T>4){let P=a.pos-(T-4);for(;a.pos>P;)C=x(S,w,C)}w[--C]=E,w[--C]=M-S,w[--C]=k-S,w[--C]=A}else T==-3?c=A:T==-4&&(d=A);return C}let y=[],m=[];for(;a.pos>0;)u(t.start||0,t.bufferStart||0,y,m,-1,0);let v=(e=t.length)!==null&&e!==void 0?e:y.length?m[0]+y[0].length:0;return new Yn(l[t.topID],y.reverse(),m.reverse(),v)}var o3=new WeakMap;function Hb(t,e){if(!t.isAnonymous||e instanceof yl||e.type!=t)return 1;let r=o3.get(e);if(r==null){r=1;for(let n of e.children){if(n.type!=t||!(n instanceof Yn)){r=1;break}r+=Hb(t,n)}o3.set(e,r)}return r}function G1(t,e,r,n,o,s,i,a,l){let c=0;for(let h=n;h<o;h++)c+=Hb(t,e[h]);let d=Math.ceil(c*1.5/8),u=[],f=[];function p(h,b,g,x,y){for(let m=g;m<x;){let v=m,S=b[m],w=Hb(t,h[m]);for(m++;m<x;m++){let C=Hb(t,h[m]);if(w+C>=d)break;w+=C}if(m==v+1){if(w>d){let C=h[v];p(C.children,C.positions,0,C.children.length,b[v]+y);continue}u.push(h[v])}else{let C=b[m-1]+h[m-1].length-S;u.push(G1(t,h,b,v,m,S,C,null,l))}f.push(S+y-s)}}return p(e,r,n,o,0),(a||l)(u,f,i)}var $c=class t{constructor(e,r,n,o,s=!1,i=!1){this.from=e,this.to=r,this.tree=n,this.offset=o,this.open=(s?1:0)|(i?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,r=[],n=!1){let o=[new t(0,e.length,e,0,!1,n)];for(let s of r)s.to>e.length&&o.push(s);return o}static applyChanges(e,r,n=128){if(!r.length)return e;let o=[],s=1,i=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let d=a<r.length?r[a]:null,u=d?d.fromA:1e9;if(u-l>=n)for(;i&&i.from<u;){let f=i;if(l>=f.from||u<=f.to||c){let p=Math.max(f.from,l)-c,h=Math.min(f.to,u)-c;f=p>=h?null:new t(p,h,f.tree,f.offset+c,a>0,!!d)}if(f&&o.push(f),i.to>u)break;i=s<e.length?e[s++]:null}if(!d)break;l=d.toA,c=d.toA-d.toB}return o}},jb=class{startParse(e,r,n){return typeof e=="string"&&(e=new W1(e)),n=n?n.length?n.map(o=>new Dp(o.from,o.to)):[new Dp(0,0)]:[new Dp(0,e.length)],this.createParse(e,r||[],n)}parse(e,r,n){let o=this.startParse(e,r,n);for(;;){let s=o.advance();if(s)return s}}},W1=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,r){return this.string.slice(e,r)}};var Dme=new yt({perNode:!0});var UK=0,li=class t{constructor(e,r,n,o){this.name=e,this.set=r,this.base=n,this.modified=o,this.id=UK++}toString(){let{name:e}=this;for(let r of this.modified)r.name&&(e=`${r.name}(${e})`);return e}static define(e,r){let n=typeof e=="string"?e:"?";if(e instanceof t&&(r=e),r?.base)throw new Error("Can not derive from a modified tag");let o=new t(n,[],null,[]);if(o.set.push(o),r)for(let s of r.set)o.set.push(s);return o}static defineModifier(e){let r=new Kb(e);return n=>n.modified.indexOf(r)>-1?n:Kb.get(n.base||n,n.modified.concat(r).sort((o,s)=>o.id-s.id))}},GK=0,Kb=class t{constructor(e){this.name=e,this.instances=[],this.id=GK++}static get(e,r){if(!r.length)return e;let n=r[0].instances.find(a=>a.base==e&&KK(r,a.modified));if(n)return n;let o=[],s=new li(e.name,o,e,r);for(let a of r)a.instances.push(s);let i=qK(r);for(let a of e.set)if(!a.modified.length)for(let l of i)o.push(t.get(a,l));return s}};function KK(t,e){return t.length==e.length&&t.every((r,n)=>r==e[n])}function qK(t){let e=[[]];for(let r=0;r<t.length;r++)for(let n=0,o=e.length;n<o;n++)e.push(e[n].concat(t[r]));return e.sort((r,n)=>n.length-r.length)}function c3(t){let e=Object.create(null);for(let r in t){let n=t[r];Array.isArray(n)||(n=[n]);for(let o of r.split(" "))if(o){let s=[],i=2,a=o;for(let u=0;;){if(a=="..."&&u>0&&u+3==o.length){i=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!f)throw new RangeError("Invalid path: "+o);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),u+=f[0].length,u==o.length)break;let p=o[u++];if(u==o.length&&p=="!"){i=0;break}if(p!="/")throw new RangeError("Invalid path: "+o);a=o.slice(u)}let l=s.length-1,c=s[l];if(!c)throw new RangeError("Invalid path: "+o);let d=new Hc(n,i,l>0?s.slice(0,l):null);e[c]=d.sort(e[c])}}return d3.add(e)}var d3=new yt({combine(t,e){let r,n,o;for(;t||e;){if(!t||e&&t.depth>=e.depth?(o=e,e=e.next):(o=t,t=t.next),r&&r.mode==o.mode&&!o.context&&!r.context)continue;let s=new Hc(o.tags,o.mode,o.context);r?r.next=s:n=s,r=s}return n}}),Hc=class{constructor(e,r,n,o){this.tags=e,this.mode=r,this.context=n,this.next=o}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Hc.empty=new Hc([],2,null);function X1(t,e){let r=Object.create(null);for(let s of t)if(!Array.isArray(s.tag))r[s.tag.id]=s.class;else for(let i of s.tag)r[i.id]=s.class;let{scope:n,all:o=null}=e||{};return{style:s=>{let i=o;for(let a of s)for(let l of a.set){let c=r[l.id];if(c){i=i?i+" "+c:c;break}}return i},scope:n}}function YK(t,e){let r=null;for(let n of t){let o=n.style(e);o&&(r=r?r+" "+o:o)}return r}function u3(t,e,r,n=0,o=t.length){let s=new q1(n,Array.isArray(e)?e:[e],r);s.highlightRange(t.cursor(),n,o,"",s.highlighters),s.flush(o)}var q1=class{constructor(e,r,n){this.at=e,this.highlighters=r,this.span=n,this.class=""}startSpan(e,r){r!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=r)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,r,n,o,s){let{type:i,from:a,to:l}=e;if(a>=n||l<=r)return;i.isTop&&(s=this.highlighters.filter(p=>!p.scope||p.scope(i)));let c=o,d=XK(e)||Hc.empty,u=YK(s,d.tags);if(u&&(c&&(c+=" "),c+=u,d.mode==1&&(o+=(o?" ":"")+u)),this.startSpan(Math.max(r,a),c),d.opaque)return;let f=e.tree&&e.tree.prop(yt.mounted);if(f&&f.overlay){let p=e.node.enter(f.overlay[0].from+a,1),h=this.highlighters.filter(g=>!g.scope||g.scope(f.tree.type)),b=e.firstChild();for(let g=0,x=a;;g++){let y=g<f.overlay.length?f.overlay[g]:null,m=y?y.from+a:l,v=Math.max(r,x),S=Math.min(n,m);if(v<S&&b)for(;e.from<S&&(this.highlightRange(e,v,S,o,s),this.startSpan(Math.min(S,e.to),c),!(e.to>=m||!e.nextSibling())););if(!y||m>n)break;x=y.to+a,x>r&&(this.highlightRange(p.cursor(),Math.max(r,y.from+a),Math.min(n,x),"",h),this.startSpan(Math.min(n,x),c))}b&&e.parent()}else if(e.firstChild()){f&&(o="");do if(!(e.to<=r)){if(e.from>=n)break;this.highlightRange(e,r,n,o,s),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function XK(t){let e=t.type.prop(d3);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}var Ne=li.define,Wb=Ne(),vl=Ne(),a3=Ne(vl),l3=Ne(vl),wl=Ne(),Ub=Ne(wl),K1=Ne(wl),Vi=Ne(),Fc=Ne(Vi),Fi=Ne(),Hi=Ne(),Y1=Ne(),Bp=Ne(Y1),Gb=Ne(),re={comment:Wb,lineComment:Ne(Wb),blockComment:Ne(Wb),docComment:Ne(Wb),name:vl,variableName:Ne(vl),typeName:a3,tagName:Ne(a3),propertyName:l3,attributeName:Ne(l3),className:Ne(vl),labelName:Ne(vl),namespace:Ne(vl),macroName:Ne(vl),literal:wl,string:Ub,docString:Ne(Ub),character:Ne(Ub),attributeValue:Ne(Ub),number:K1,integer:Ne(K1),float:Ne(K1),bool:Ne(wl),regexp:Ne(wl),escape:Ne(wl),color:Ne(wl),url:Ne(wl),keyword:Fi,self:Ne(Fi),null:Ne(Fi),atom:Ne(Fi),unit:Ne(Fi),modifier:Ne(Fi),operatorKeyword:Ne(Fi),controlKeyword:Ne(Fi),definitionKeyword:Ne(Fi),moduleKeyword:Ne(Fi),operator:Hi,derefOperator:Ne(Hi),arithmeticOperator:Ne(Hi),logicOperator:Ne(Hi),bitwiseOperator:Ne(Hi),compareOperator:Ne(Hi),updateOperator:Ne(Hi),definitionOperator:Ne(Hi),typeOperator:Ne(Hi),controlOperator:Ne(Hi),punctuation:Y1,separator:Ne(Y1),bracket:Bp,angleBracket:Ne(Bp),squareBracket:Ne(Bp),paren:Ne(Bp),brace:Ne(Bp),content:Vi,heading:Fc,heading1:Ne(Fc),heading2:Ne(Fc),heading3:Ne(Fc),heading4:Ne(Fc),heading5:Ne(Fc),heading6:Ne(Fc),contentSeparator:Ne(Vi),list:Ne(Vi),quote:Ne(Vi),emphasis:Ne(Vi),strong:Ne(Vi),link:Ne(Vi),monospace:Ne(Vi),strikethrough:Ne(Vi),inserted:Ne(),deleted:Ne(),changed:Ne(),invalid:Ne(),meta:Gb,documentMeta:Ne(Gb),annotation:Ne(Gb),processingInstruction:Ne(Gb),definition:li.defineModifier("definition"),constant:li.defineModifier("constant"),function:li.defineModifier("function"),standard:li.defineModifier("standard"),local:li.defineModifier("local"),special:li.defineModifier("special")};for(let t in re){let e=re[t];e instanceof li&&(e.name=t)}var Lme=X1([{tag:re.link,class:"tok-link"},{tag:re.heading,class:"tok-heading"},{tag:re.emphasis,class:"tok-emphasis"},{tag:re.strong,class:"tok-strong"},{tag:re.keyword,class:"tok-keyword"},{tag:re.atom,class:"tok-atom"},{tag:re.bool,class:"tok-bool"},{tag:re.url,class:"tok-url"},{tag:re.labelName,class:"tok-labelName"},{tag:re.inserted,class:"tok-inserted"},{tag:re.deleted,class:"tok-deleted"},{tag:re.literal,class:"tok-literal"},{tag:re.string,class:"tok-string"},{tag:re.number,class:"tok-number"},{tag:[re.regexp,re.escape,re.special(re.string)],class:"tok-string2"},{tag:re.variableName,class:"tok-variableName"},{tag:re.local(re.variableName),class:"tok-variableName tok-local"},{tag:re.definition(re.variableName),class:"tok-variableName tok-definition"},{tag:re.special(re.variableName),class:"tok-variableName2"},{tag:re.definition(re.propertyName),class:"tok-propertyName tok-definition"},{tag:re.typeName,class:"tok-typeName"},{tag:re.namespace,class:"tok-namespace"},{tag:re.className,class:"tok-className"},{tag:re.macroName,class:"tok-macroName"},{tag:re.propertyName,class:"tok-propertyName"},{tag:re.operator,class:"tok-operator"},{tag:re.comment,class:"tok-comment"},{tag:re.meta,class:"tok-meta"},{tag:re.invalid,class:"tok-invalid"},{tag:re.punctuation,class:"tok-punctuation"}]);var J1,$p=new yt;var JK=new yt,Fs=class{constructor(e,r,n=[],o=""){this.data=e,this.name=o,jt.prototype.hasOwnProperty("tree")||Object.defineProperty(jt.prototype,"tree",{get(){return Bn(this)}}),this.parser=r,this.extension=[Sl.of(this),jt.languageData.of((s,i,a)=>{let l=f3(s,i,a),c=l.type.prop($p);if(!c)return[];let d=s.facet(c),u=l.type.prop(JK);if(u){let f=l.resolve(i-l.from,a);for(let p of u)if(p.test(f,s)){let h=s.facet(p.facet);return p.type=="replace"?h:h.concat(d)}}return d})].concat(n)}isActiveAt(e,r,n=-1){return f3(e,r,n).type.prop($p)==this.data}findRegions(e){let r=e.facet(Sl);if(r?.data==this.data)return[{from:0,to:e.doc.length}];if(!r||!r.allowsNesting)return[];let n=[],o=(s,i)=>{if(s.prop($p)==this.data){n.push({from:i,to:i+s.length});return}let a=s.prop(yt.mounted);if(a){if(a.tree.prop($p)==this.data){if(a.overlay)for(let l of a.overlay)n.push({from:l.from+i,to:l.to+i});else n.push({from:i,to:i+s.length});return}else if(a.overlay){let l=n.length;if(o(a.tree,a.overlay[0].from+i),n.length>l)return}}for(let l=0;l<s.children.length;l++){let c=s.children[l];c instanceof Yn&&o(c,s.positions[l]+i)}};return o(Bn(e),0),n}get allowsNesting(){return!0}};Fs.setState=Qe.define();function f3(t,e,r){let n=t.facet(Sl),o=Bn(t).topNode;if(!n||n.allowsNesting)for(let s=o;s;s=s.enter(e,r,Zr.ExcludeBuffers|Zr.EnterBracketed))s.type.isTop&&(o=s);return o}function Bn(t){let e=t.field(Fs.state,!1);return e?e.tree:Yn.empty}var tS=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,r){let n=this.cursorPos-this.string.length;return e<n||r>=this.cursorPos?this.doc.sliceString(e,r):this.string.slice(e-n,r-n)}},zp=null,rS=class t{constructor(e,r,n=[],o,s,i,a,l){this.parser=e,this.state=r,this.fragments=n,this.tree=o,this.treeLen=s,this.viewport=i,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,r,n){return new t(e,r,[],Yn.empty,0,n,[],null)}startParse(){return this.parser.startParse(new tS(this.state.doc),this.fragments)}work(e,r){return r!=null&&r>=this.state.doc.length&&(r=void 0),this.tree!=Yn.empty&&this.isDone(r??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let o=Date.now()+e;e=()=>Date.now()>o}for(this.parse||(this.parse=this.startParse()),r!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>r)&&r<this.state.doc.length&&this.parse.stopAt(r);;){let o=this.parse.advance();if(o)if(this.fragments=this.withoutTempSkipped($c.addTree(o,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=o,this.parse=null,this.treeLen<(r??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,r;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(r=this.parse.advance()););}),this.treeLen=e,this.tree=r,this.fragments=this.withoutTempSkipped($c.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let r=zp;zp=this;try{return e()}finally{zp=r}}withoutTempSkipped(e){for(let r;r=this.tempSkipped.pop();)e=p3(e,r.from,r.to);return e}changes(e,r){let{fragments:n,tree:o,treeLen:s,viewport:i,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,d,u,f)=>l.push({fromA:c,toA:d,fromB:u,toB:f})),n=$c.applyChanges(n,l),o=Yn.empty,s=0,i={from:e.mapPos(i.from,-1),to:e.mapPos(i.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let d=e.mapPos(c.from,1),u=e.mapPos(c.to,-1);d<u&&a.push({from:d,to:u})}}}return new t(this.parser,r,n,o,s,i,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let r=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:o,to:s}=this.skipped[n];o<e.to&&s>e.from&&(this.fragments=p3(this.fragments,o,s),this.skipped.splice(n--,1))}return this.skipped.length>=r?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,r){this.skipped.push({from:e,to:r})}static getSkippingParser(e){return new class extends jb{createParse(r,n,o){let s=o[0].from,i=o[o.length-1].to;return{parsedPos:s,advance(){let l=zp;if(l){for(let c of o)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=i,new Yn(as.none,[],[],i-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let r=this.fragments;return this.treeLen>=e&&r.length&&r[0].from==0&&r[0].to>=e}static get(){return zp}};function p3(t,e,r){return $c.applyChanges(t,[{fromA:e,toA:r,fromB:e,toB:r}])}var Hp=class t{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let r=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),r.viewport.to);return r.work(20,n)||r.takeTree(),new t(r)}static init(e){let r=Math.min(3e3,e.doc.length),n=rS.create(e.facet(Sl).parser,e,{from:0,to:r});return n.work(20,r)||n.takeTree(),new t(n)}};Fs.state=Jr.define({create:Hp.init,update(t,e){for(let r of e.effects)if(r.is(Fs.setState))return r.value;return e.startState.facet(Sl)!=e.state.facet(Sl)?Hp.init(e.state):t.apply(e)}});var v3=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(v3=t=>{let e=-1,r=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(r):cancelIdleCallback(e)});var Z1=typeof navigator<"u"&&(!((J1=navigator.scheduling)===null||J1===void 0)&&J1.isInputPending)?()=>navigator.scheduling.isInputPending():null,ZK=Er.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let r=this.view.state.field(Fs.state).context;(r.updateViewport(e.view.viewport)||this.view.viewport.to>r.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(r)}scheduleWork(){if(this.working)return;let{state:e}=this.view,r=e.field(Fs.state);(r.tree!=r.context.tree||!r.context.isDone(e.doc.length))&&(this.working=v3(this.work))}work(e){this.working=null;let r=Date.now();if(this.chunkEnd<r&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=r+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:o}}=this.view,s=n.field(Fs.state);if(s.tree==s.context.tree&&s.context.isDone(o+1e5))return;let i=Date.now()+Math.min(this.chunkBudget,100,e&&!Z1?Math.max(25,e.timeRemaining()-5):1e9),a=s.context.treeLen<o&&n.doc.length>o+1e3,l=s.context.work(()=>Z1&&Z1()||Date.now()>i,o+(a?0:1e5));this.chunkBudget-=Date.now()-r,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Fs.setState.of(new Hp(s.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(r=>Kn(this.view.state,r)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Sl=Ce.define({combine(t){return t.length?t[0]:null},enables:t=>[Fs.state,ZK,ve.contentAttributes.compute([t],e=>{let r=e.facet(t);return r&&r.name?{"data-language":r.name}:{}})]});var QK=Ce.define(),Wc=Ce.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(r=>r!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Vp(t){let e=t.facet(Wc);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Mu(t,e){let r="",n=t.tabSize,o=t.facet(Wc)[0];if(o==" "){for(;e>=n;)r+=" ",e-=n;o=" "}for(let s=0;s<e;s++)r+=o;return r}function Xb(t,e){t instanceof jt&&(t=new Vc(t));for(let n of t.state.facet(QK)){let o=n(t,e);if(o!==void 0)return o}let r=Bn(t.state);return r.length>=e?tq(t,r,e):null}var Vc=class{constructor(e,r={}){this.state=e,this.options=r,this.unit=Vp(e)}lineAt(e,r=1){let n=this.state.doc.lineAt(e),{simulateBreak:o,simulateDoubleBreak:s}=this.options;return o!=null&&o>=n.from&&o<=n.to?s&&o==e?{text:"",from:e}:(r<0?o<e:o<=e)?{text:n.text.slice(o-n.from),from:o}:{text:n.text.slice(0,o-n.from),from:n.from}:n}textAfterPos(e,r=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:o}=this.lineAt(e,r);return n.slice(e-o,Math.min(n.length,e+100-o))}column(e,r=1){let{text:n,from:o}=this.lineAt(e,r),s=this.countColumn(n,e-o),i=this.options.overrideIndentation?this.options.overrideIndentation(o):-1;return i>-1&&(s+=i-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,r=e.length){return va(e,this.state.tabSize,r)}lineIndent(e,r=1){let{text:n,from:o}=this.lineAt(e,r),s=this.options.overrideIndentation;if(s){let i=s(o);if(i>-1)return i}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},eq=new yt;function tq(t,e,r){let n=e.resolveStack(r),o=e.resolveInner(r,-1).resolve(r,0).enterUnfinishedNodesBefore(r);if(o!=n.node){let s=[];for(let i=o;i&&!(i.from<n.node.from||i.to>n.node.to||i.from==n.node.from&&i.type==n.node.type);i=i.parent)s.push(i);for(let i=s.length-1;i>=0;i--)n={node:s[i],next:n}}return w3(n,t,r)}function w3(t,e,r){for(let n=t;n;n=n.next){let o=nq(n.node);if(o)return o(nS.create(e,r,n))}return 0}function rq(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function nq(t){let e=t.type.prop(eq);if(e)return e;let r=t.firstChild,n;if(r&&(n=r.type.prop(yt.closedBy))){let o=t.lastChild,s=o&&n.indexOf(o.name)>-1;return i=>aq(i,!0,1,void 0,s&&!rq(i)?o.from:void 0)}return t.parent==null?oq:null}function oq(){return 0}var nS=class t extends Vc{constructor(e,r,n){super(e.state,e.options),this.base=e,this.pos=r,this.context=n}get node(){return this.context.node}static create(e,r,n){return new t(e,r,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let r=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(r.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(sq(n,e))break;r=this.state.doc.lineAt(n.from)}return this.lineIndent(r.from)}continue(){return w3(this.context.next,this.base,this.pos)}};function sq(t,e){for(let r=e;r;r=r.parent)if(t==r)return!0;return!1}function iq(t){let e=t.node,r=e.childAfter(e.from),n=e.lastChild;if(!r)return null;let o=t.options.simulateBreak,s=t.state.doc.lineAt(r.from),i=o==null||o<=s.from?s.to:Math.min(s.to,o);for(let a=r.to;;){let l=e.childAfter(a);if(!l||l==n)return null;if(!l.type.isSkipped){if(l.from>=i)return null;let c=/^ */.exec(s.text.slice(r.to-s.from))[0].length;return{from:r.from,to:r.to+c}}a=l.to}}function aq(t,e,r,n,o){let s=t.textAfter,i=s.match(/^\s*/)[0].length,a=n&&s.slice(i,i+n.length)==n||o==t.pos+i,l=e?iq(t):null;return l?a?t.column(l.from):t.column(l.to):t.baseIndent+(a?0:t.unit*r)}var lq=200;function S3(){return jt.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let r=t.newDoc,{head:n}=t.newSelection.main,o=r.lineAt(n);if(n>o.from+lq)return t;let s=r.sliceString(o.from,n);if(!e.some(c=>c.test(s)))return t;let{state:i}=t,a=-1,l=[];for(let{head:c}of i.selection.ranges){let d=i.doc.lineAt(c);if(d.from==a)continue;a=d.from;let u=Xb(i,d.from);if(u==null)continue;let f=/^\s*/.exec(d.text)[0],p=Mu(i,u);f!=p&&l.push({from:d.from,to:d.from+f.length,insert:p})}return l.length?[t,{changes:l,sequential:!0}]:t})}var cq=Ce.define(),dq=new yt;function uq(t,e,r){let n=Bn(t);if(n.length<r)return null;let o=n.resolveStack(r,1),s=null;for(let i=o;i;i=i.next){let a=i.node;if(a.to<=r||a.from>r)continue;if(s&&a.from<e)break;let l=a.type.prop(dq);if(l&&(a.to<n.length-50||n.length==t.doc.length||!fq(a))){let c=l(a,t);c&&c.from<=r&&c.from>=e&&c.to>r&&(s=c)}}return s}function fq(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function qb(t,e,r){for(let n of t.facet(cq)){let o=n(t,e,r);if(o)return o}return uq(t,e,r)}function N3(t,e){let r=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return r>=n?void 0:{from:r,to:n}}var Jb=Qe.define({map:N3}),jp=Qe.define({map:N3});function C3(t){let e=[];for(let{head:r}of t.state.selection.ranges)e.some(n=>n.from<=r&&n.to>=r)||e.push(t.lineBlockAt(r));return e}var jc=Jr.define({create(){return Fe.none},update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((r,n)=>t=h3(t,r,n)),t=t.map(e.changes);for(let r of e.effects)if(r.is(Jb)&&!pq(t,r.value.from,r.value.to)){let{preparePlaceholder:n}=e.state.facet(cS),o=n?Fe.replace({widget:new oS(n(e.state,r.value))}):m3;t=t.update({add:[o.range(r.value.from,r.value.to)]})}else r.is(jp)&&(t=t.update({filter:(n,o)=>r.value.from!=n||r.value.to!=o,filterFrom:r.value.from,filterTo:r.value.to}));return e.selection&&(t=h3(t,e.selection.main.head)),t},provide:t=>ve.decorations.from(t),toJSON(t,e){let r=[];return t.between(0,e.doc.length,(n,o)=>{r.push(n,o)}),r},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let r=0;r<t.length;){let n=t[r++],o=t[r++];if(typeof n!="number"||typeof o!="number")throw new RangeError("Invalid JSON for fold state");e.push(m3.range(n,o))}return Fe.set(e,!0)}});function h3(t,e,r=e){let n=!1;return t.between(e,r,(o,s)=>{o<r&&s>e&&(n=!0)}),n?t.update({filterFrom:e,filterTo:r,filter:(o,s)=>o>=r||s<=e}):t}function Yb(t,e,r){var n;let o=null;return(n=t.field(jc,!1))===null||n===void 0||n.between(e,r,(s,i)=>{(!o||o.from>s)&&(o={from:s,to:i})}),o}function pq(t,e,r){let n=!1;return t.between(e,e,(o,s)=>{o==e&&s==r&&(n=!0)}),n}function k3(t,e){return t.field(jc,!1)?e:e.concat(Qe.appendConfig.of(I3()))}var hq=t=>{for(let e of C3(t)){let r=qb(t.state,e.from,e.to);if(r)return t.dispatch({effects:k3(t.state,[Jb.of(r),E3(t,r)])}),!0}return!1},mq=t=>{if(!t.state.field(jc,!1))return!1;let e=[];for(let r of C3(t)){let n=Yb(t.state,r.from,r.to);n&&e.push(jp.of(n),E3(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function E3(t,e,r=!0){let n=t.state.doc.lineAt(e.from).number,o=t.state.doc.lineAt(e.to).number;return ve.announce.of(`${t.state.phrase(r?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${o}.`)}var gq=t=>{let{state:e}=t,r=[];for(let n=0;n<e.doc.length;){let o=t.lineBlockAt(n),s=qb(e,o.from,o.to);s&&r.push(Jb.of(s)),n=(s?t.lineBlockAt(s.to):o).to+1}return r.length&&t.dispatch({effects:k3(t.state,r)}),!!r.length},bq=t=>{let e=t.state.field(jc,!1);if(!e||!e.size)return!1;let r=[];return e.between(0,t.state.doc.length,(n,o)=>{r.push(jp.of({from:n,to:o}))}),t.dispatch({effects:r}),!0};var T3=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:hq},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:mq},{key:"Ctrl-Alt-[",run:gq},{key:"Ctrl-Alt-]",run:bq}],xq={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},cS=Ce.define({combine(t){return ao(t,xq)}});function I3(t){let e=[jc,vq];return t&&e.push(cS.of(t)),e}function A3(t,e){let{state:r}=t,n=r.facet(cS),o=i=>{let a=t.lineBlockAt(t.posAtDOM(i.target)),l=Yb(t.state,a.from,a.to);l&&t.dispatch({effects:jp.of(l)}),i.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,o,e);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",r.phrase("folded code")),s.title=r.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=o,s}var m3=Fe.replace({widget:new class extends Io{toDOM(t){return A3(t,null)}}}),oS=class extends Io{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return A3(e,this.value)}},yq={openText:"\u2304",closedText:"\u203A",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},Fp=class extends is{constructor(e,r){super(),this.config=e,this.open=r}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let r=document.createElement("span");return r.textContent=this.open?this.config.openText:this.config.closedText,r.title=e.state.phrase(this.open?"Fold line":"Unfold line"),r}};function M3(t={}){let e={...yq,...t},r=new Fp(e,!0),n=new Fp(e,!1),o=Er.fromClass(class{constructor(i){this.from=i.viewport.from,this.markers=this.buildMarkers(i)}update(i){(i.docChanged||i.viewportChanged||i.startState.facet(Sl)!=i.state.facet(Sl)||i.startState.field(jc,!1)!=i.state.field(jc,!1)||Bn(i.startState)!=Bn(i.state)||e.foldingChanged(i))&&(this.markers=this.buildMarkers(i.view))}buildMarkers(i){let a=new ns;for(let l of i.viewportLineBlocks){let c=Yb(i.state,l.from,l.to)?n:qb(i.state,l.from,l.to)?r:null;c&&a.add(l.from,l.from,c)}return a.finish()}}),{domEventHandlers:s}=e;return[o,$1({class:"cm-foldGutter",markers(i){var a;return((a=i.plugin(o))===null||a===void 0?void 0:a.markers)||Dt.empty},initialSpacer(){return new Fp(e,!1)},domEventHandlers:{...s,click:(i,a,l)=>{if(s.click&&s.click(i,a,l))return!0;let c=Yb(i.state,a.from,a.to);if(c)return i.dispatch({effects:jp.of(c)}),!0;let d=qb(i.state,a.from,a.to);return d?(i.dispatch({effects:Jb.of(d)}),!0):!1}}}),I3()]}var vq=ve.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}}),Au=class t{constructor(e,r){this.specs=e;let n;function o(a){let l=Ls.newName();return(n||(n=Object.create(null)))["."+l]=a,l}let s=typeof r.all=="string"?r.all:r.all?o(r.all):void 0,i=r.scope;this.scope=i instanceof Fs?a=>a.prop($p)==i.data:i?a=>a==i:void 0,this.style=X1(e.map(a=>({tag:a.tag,class:a.class||o(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=n?new Ls(n):null,this.themeType=r.themeType}static define(e,r){return new t(e,r||{})}},sS=Ce.define(),P3=Ce.define({combine(t){return t.length?[t[0]]:null}});function Q1(t){let e=t.facet(sS);return e.length?e:t.facet(P3)}function Zb(t,e){let r=[wq],n;return t instanceof Au&&(t.module&&r.push(ve.styleModule.of(t.module)),n=t.themeType),e?.fallback?r.push(P3.of(t)):n?r.push(sS.computeN([ve.darkTheme],o=>o.facet(ve.darkTheme)==(n=="dark")?[t]:[])):r.push(sS.of(t)),r}var iS=class{constructor(e){this.markCache=Object.create(null),this.tree=Bn(e.state),this.decorations=this.buildDeco(e,Q1(e.state)),this.decoratedTo=e.viewport.to}update(e){let r=Bn(e.state),n=Q1(e.state),o=n!=Q1(e.startState),{viewport:s}=e.view,i=e.changes.mapPos(this.decoratedTo,1);r.length<s.to&&!o&&r.type==this.tree.type&&i>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=i):(r!=this.tree||e.viewportChanged||o)&&(this.tree=r,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=s.to)}buildDeco(e,r){if(!r||!this.tree.length)return Fe.none;let n=new ns;for(let{from:o,to:s}of e.visibleRanges)u3(this.tree,r,(i,a,l)=>{n.add(i,a,this.markCache[l]||(this.markCache[l]=Fe.mark({class:l})))},o,s);return n.finish()}},wq=oi.high(Er.fromClass(iS,{decorations:t=>t.decorations})),R3=Au.define([{tag:re.meta,color:"#404740"},{tag:re.link,textDecoration:"underline"},{tag:re.heading,textDecoration:"underline",fontWeight:"bold"},{tag:re.emphasis,fontStyle:"italic"},{tag:re.strong,fontWeight:"bold"},{tag:re.strikethrough,textDecoration:"line-through"},{tag:re.keyword,color:"#708"},{tag:[re.atom,re.bool,re.url,re.contentSeparator,re.labelName],color:"#219"},{tag:[re.literal,re.inserted],color:"#164"},{tag:[re.string,re.deleted],color:"#a11"},{tag:[re.regexp,re.escape,re.special(re.string)],color:"#e40"},{tag:re.definition(re.variableName),color:"#00f"},{tag:re.local(re.variableName),color:"#30a"},{tag:[re.typeName,re.namespace],color:"#085"},{tag:re.className,color:"#167"},{tag:[re.special(re.variableName),re.macroName],color:"#256"},{tag:re.definition(re.propertyName),color:"#00c"},{tag:re.comment,color:"#940"},{tag:re.invalid,color:"#f00"}]),Sq=ve.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),D3=1e4,O3="()[]{}",_3=Ce.define({combine(t){return ao(t,{afterCursor:!0,brackets:O3,maxScanDistance:D3,renderMatch:kq})}}),Nq=Fe.mark({class:"cm-matchingBracket"}),Cq=Fe.mark({class:"cm-nonmatchingBracket"});function kq(t){let e=[],r=t.matched?Nq:Cq;return e.push(r.range(t.start.from,t.start.to)),t.end&&e.push(r.range(t.end.from,t.end.to)),e}function g3(t){let e=[],r=t.facet(_3);for(let n of t.selection.ranges){if(!n.empty)continue;let o=ci(t,n.head,-1,r)||n.head>0&&ci(t,n.head-1,1,r)||r.afterCursor&&(ci(t,n.head,1,r)||n.head<t.doc.length&&ci(t,n.head+1,-1,r));o&&(e=e.concat(r.renderMatch(o,t)))}return Fe.set(e,!0)}var Eq=Er.fromClass(class{constructor(t){this.paused=!1,this.decorations=g3(t.state)}update(t){(t.docChanged||t.selectionSet||this.paused)&&(t.view.composing?(this.decorations=this.decorations.map(t.changes),this.paused=!0):(this.decorations=g3(t.state),this.paused=!1))}},{decorations:t=>t.decorations}),Tq=[Eq,Sq];function L3(t={}){return[_3.of(t),Tq]}var Iq=new yt;function aS(t,e,r){let n=t.prop(e<0?yt.openedBy:yt.closedBy);if(n)return n;if(t.name.length==1){let o=r.indexOf(t.name);if(o>-1&&o%2==(e<0?1:0))return[r[o+e]]}return null}function lS(t){let e=t.type.prop(Iq);return e?e(t.node):t}function ci(t,e,r,n={}){let o=n.maxScanDistance||D3,s=n.brackets||O3,i=Bn(t),a=i.resolveInner(e,r);for(let l=a;l;l=l.parent){let c=aS(l.type,r,s);if(c&&l.from<l.to){let d=lS(l);if(d&&(r>0?e>=d.from&&e<d.to:e>d.from&&e<=d.to))return Aq(t,e,r,l,d,c,s)}}return Mq(t,e,r,i,a.type,o,s)}function Aq(t,e,r,n,o,s,i){let a=n.parent,l={from:o.from,to:o.to},c=0,d=a?.cursor();if(d&&(r<0?d.childBefore(n.from):d.childAfter(n.to)))do if(r<0?d.to<=n.from:d.from>=n.to){if(c==0&&s.indexOf(d.type.name)>-1&&d.from<d.to){let u=lS(d);return{start:l,end:u?{from:u.from,to:u.to}:void 0,matched:!0}}else if(aS(d.type,r,i))c++;else if(aS(d.type,-r,i)){if(c==0){let u=lS(d);return{start:l,end:u&&u.from<u.to?{from:u.from,to:u.to}:void 0,matched:!1}}c--}}while(r<0?d.prevSibling():d.nextSibling());return{start:l,matched:!1}}function Mq(t,e,r,n,o,s,i){if(r<0?!e:e==t.doc.length)return null;let a=r<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=i.indexOf(a);if(l<0||l%2==0!=r>0)return null;let c={from:r<0?e-1:e,to:r>0?e+1:e},d=t.doc.iterRange(e,r>0?t.doc.length:0),u=0;for(let f=0;!d.next().done&&f<=s;){let p=d.value;r<0&&(f+=p.length);let h=e+f*r;for(let b=r>0?0:p.length-1,g=r>0?p.length:-1;b!=g;b+=r){let x=i.indexOf(p[b]);if(!(x<0||n.resolveInner(h+b,1).type!=o))if(x%2==0==r>0)u++;else{if(u==1)return{start:c,end:{from:h+b,to:h+b+1},matched:x>>1==l>>1};u--}}r>0&&(f+=p.length)}return d.done?{start:c,matched:!1}:null}var Pq=Object.create(null),b3=[as.none];var x3=[],y3=Object.create(null),Rq=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Rq[t]=Dq(Pq,e);function eS(t,e){x3.indexOf(t)>-1||(x3.push(t),console.warn(e))}function Dq(t,e){let r=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let d=t[c]||re[c];d?typeof d=="function"?l.length?l=l.map(d):eS(c,`Modifier ${c} used at start of tag`):l.length?eS(c,`Tag ${c} used as modifier`):l=Array.isArray(d)?d:[d]:eS(c,`Unknown highlighting tag ${c}`)}for(let c of l)r.push(c)}if(!r.length)return 0;let n=e.replace(/ /g,"_"),o=n+" "+r.map(a=>a.id),s=y3[o];if(s)return s.id;let i=y3[o]=as.define({id:b3.length,name:n,props:[c3({[n]:r})]});return b3.push(i),i.id}var Ume={rtl:Fe.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:Xt.RTL}),ltr:Fe.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:Xt.LTR}),auto:Fe.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var Oq=t=>{let{state:e}=t,r=e.doc.lineAt(e.selection.main.from),n=gS(t.state,r.from);return n.line?_q(t):n.block?Bq(t):!1};function mS(t,e){return({state:r,dispatch:n})=>{if(r.readOnly)return!1;let o=t(e,r);return o?(n(r.update(o)),!0):!1}}var _q=mS(Fq,0);var Lq=mS(U3,0);var Bq=mS((t,e)=>U3(t,e,$q(e)),0);function gS(t,e){let r=t.languageDataAt("commentTokens",e,1);return r.length?r[0]:{}}var Wp=50;function zq(t,{open:e,close:r},n,o){let s=t.sliceDoc(n-Wp,n),i=t.sliceDoc(o,o+Wp),a=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(i)[0].length,c=s.length-a;if(s.slice(c-e.length,c)==e&&i.slice(l,l+r.length)==r)return{open:{pos:n-a,margin:a&&1},close:{pos:o+l,margin:l&&1}};let d,u;o-n<=2*Wp?d=u=t.sliceDoc(n,o):(d=t.sliceDoc(n,n+Wp),u=t.sliceDoc(o-Wp,o));let f=/^\s*/.exec(d)[0].length,p=/\s*$/.exec(u)[0].length,h=u.length-p-r.length;return d.slice(f,f+e.length)==e&&u.slice(h,h+r.length)==r?{open:{pos:n+f+e.length,margin:/\s/.test(d.charAt(f+e.length))?1:0},close:{pos:o-p-r.length,margin:/\s/.test(u.charAt(h-1))?1:0}}:null}function $q(t){let e=[];for(let r of t.selection.ranges){let n=t.doc.lineAt(r.from),o=r.to<=n.to?n:t.doc.lineAt(r.to);o.from>n.from&&o.from==r.to&&(o=r.to==n.to+1?n:t.doc.lineAt(r.to-1));let s=e.length-1;s>=0&&e[s].to>n.from?e[s].to=o.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:o.to})}return e}function U3(t,e,r=e.selection.ranges){let n=r.map(s=>gS(e,s.from).block);if(!n.every(s=>s))return null;let o=r.map((s,i)=>zq(e,n[i],s.from,s.to));if(t!=2&&!o.every(s=>s))return{changes:e.changes(r.map((s,i)=>o[i]?[]:[{from:s.from,insert:n[i].open+" "},{from:s.to,insert:" "+n[i].close}]))};if(t!=1&&o.some(s=>s)){let s=[];for(let i=0,a;i<o.length;i++)if(a=o[i]){let l=n[i],{open:c,close:d}=a;s.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:d.pos-d.margin,to:d.pos+l.close.length})}return{changes:s}}return null}function Fq(t,e,r=e.selection.ranges){let n=[],o=-1;e:for(let{from:s,to:i}of r){let a=n.length,l=1e9,c;for(let d=s;d<=i;){let u=e.doc.lineAt(d);if(c==null&&(c=gS(e,u.from).line,!c))continue e;if(u.from>o&&(s==i||i>u.from)){o=u.from;let f=/^\s*/.exec(u.text)[0].length,p=f==u.length,h=u.text.slice(f,f+c.length)==c?f:-1;f<u.text.length&&f<l&&(l=f),n.push({line:u,comment:h,token:c,indent:f,empty:p,single:!1})}d=u.to+1}if(l<1e9)for(let d=a;d<n.length;d++)n[d].indent<n[d].line.text.length&&(n[d].indent=l);n.length==a+1&&(n[a].single=!0)}if(t!=2&&n.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:a,token:l,indent:c,empty:d,single:u}of n)(u||!d)&&s.push({from:a.from+c,insert:l+" "});let i=e.changes(s);return{changes:i,selection:e.selection.map(i,1)}}else if(t!=1&&n.some(s=>s.comment>=0)){let s=[];for(let{line:i,comment:a,token:l}of n)if(a>=0){let c=i.from+a,d=c+l.length;i.text[d-i.from]==" "&&d++,s.push({from:c,to:d})}return{changes:s}}return null}var uS=io.define(),Hq=io.define(),Vq=Ce.define(),G3=Ce.define({combine(t){return ao(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,r)=>r},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,r)=>(n,o)=>e(n,o)||r(n,o)})}}),K3=Jr.define({create(){return Uc.empty},update(t,e){let r=e.state.facet(G3),n=e.annotation(uS);if(n){let l=di.fromTransaction(e,n.selection),c=n.side,d=c==0?t.undone:t.done;return l?d=e0(d,d.length,r.minDepth,l):d=J3(d,e.startState.selection),new Uc(c==0?n.rest:d,c==0?d:n.rest)}let o=e.annotation(Hq);if((o=="full"||o=="before")&&(t=t.isolate()),e.annotation(kn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=di.fromTransaction(e),i=e.annotation(kn.time),a=e.annotation(kn.userEvent);return s?t=t.addChanges(s,i,a,r,e):e.selection&&(t=t.addSelection(e.startState.selection,i,a,r.newGroupDelay)),(o=="full"||o=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Uc(t.done.map(di.fromJSON),t.undone.map(di.fromJSON))}});function q3(t={}){return[K3,G3.of(t),ve.domEventHandlers({beforeinput(e,r){let n=e.inputType=="historyUndo"?Y3:e.inputType=="historyRedo"?fS:null;return n?(e.preventDefault(),n(r)):!1}})]}function t0(t,e){return function({state:r,dispatch:n}){if(!e&&r.readOnly)return!1;let o=r.field(K3,!1);if(!o)return!1;let s=o.pop(t,r,e);return s?(n(s),!0):!1}}var Y3=t0(0,!1),fS=t0(1,!1),jq=t0(0,!0),Wq=t0(1,!0);var di=class t{constructor(e,r,n,o,s){this.changes=e,this.effects=r,this.mapped=n,this.startSelection=o,this.selectionsAfter=s}setSelAfter(e){return new t(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,r,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(r=this.mapped)===null||r===void 0?void 0:r.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(o=>o.toJSON())}}static fromJSON(e){return new t(e.changes&&Eo.fromJSON(e.changes),[],e.mapped&&ya.fromJSON(e.mapped),e.startSelection&&ie.fromJSON(e.startSelection),e.selectionsAfter.map(ie.fromJSON))}static fromTransaction(e,r){let n=Hs;for(let o of e.startState.facet(Vq)){let s=o(e);s.length&&(n=n.concat(s))}return!n.length&&e.changes.empty?null:new t(e.changes.invert(e.startState.doc),n,void 0,r||e.startState.selection,Hs)}static selection(e){return new t(void 0,Hs,void 0,void 0,e)}};function e0(t,e,r,n){let o=e+1>r+20?e-r-1:0,s=t.slice(o,e);return s.push(n),s}function Uq(t,e){let r=[],n=!1;return t.iterChangedRanges((o,s)=>r.push(o,s)),e.iterChangedRanges((o,s,i,a)=>{for(let l=0;l<r.length;){let c=r[l++],d=r[l++];a>=c&&i<=d&&(n=!0)}}),n}function Gq(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((r,n)=>r.empty!=e.ranges[n].empty).length===0}function X3(t,e){return t.length?e.length?t.concat(e):t:e}var Hs=[],Kq=200;function J3(t,e){if(t.length){let r=t[t.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-Kq));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),e0(t,t.length-1,1e9,r.setSelAfter(n)))}else return[di.selection([e])]}function qq(t){let e=t[t.length-1],r=t.slice();return r[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),r}function dS(t,e){if(!t.length)return t;let r=t.length,n=Hs;for(;r;){let o=Yq(t[r-1],e,n);if(o.changes&&!o.changes.empty||o.effects.length){let s=t.slice(0,r);return s[r-1]=o,s}else e=o.mapped,r--,n=o.selectionsAfter}return n.length?[di.selection(n)]:Hs}function Yq(t,e,r){let n=X3(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):Hs,r);if(!t.changes)return di.selection(n);let o=t.changes.map(e),s=e.mapDesc(t.changes,!0),i=t.mapped?t.mapped.composeDesc(s):s;return new di(o,Qe.mapEffects(t.effects,e),i,t.startSelection.map(s),n)}var Xq=/^(input\.type|delete)($|\.)/,Uc=class t{constructor(e,r,n=0,o=void 0){this.done=e,this.undone=r,this.prevTime=n,this.prevUserEvent=o}isolate(){return this.prevTime?new t(this.done,this.undone):this}addChanges(e,r,n,o,s){let i=this.done,a=i[i.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!n||Xq.test(n))&&(!a.selectionsAfter.length&&r-this.prevTime<o.newGroupDelay&&o.joinToEvent(s,Uq(a.changes,e.changes))||n=="input.type.compose")?i=e0(i,i.length-1,o.minDepth,new di(e.changes.compose(a.changes),X3(Qe.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,Hs)):i=e0(i,i.length,o.minDepth,e),new t(i,Hs,r,n)}addSelection(e,r,n,o){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Hs;return s.length>0&&r-this.prevTime<o&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&Gq(s[s.length-1],e)?this:new t(J3(this.done,e),this.undone,r,n)}addMapping(e){return new t(dS(this.done,e),dS(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,r,n){let o=e==0?this.done:this.undone;if(o.length==0)return null;let s=o[o.length-1],i=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):r.selection);if(n&&s.selectionsAfter.length)return r.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:uS.of({side:e,rest:qq(o),selection:i}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let a=o.length==1?Hs:o.slice(0,o.length-1);return s.mapped&&(a=dS(a,s.mapped)),r.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:uS.of({side:e,rest:a,selection:i}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};Uc.empty=new Uc(Hs,Hs);var Z3=[{key:"Mod-z",run:Y3,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:fS,preventDefault:!0},{linux:"Ctrl-Shift-z",run:fS,preventDefault:!0},{key:"Mod-u",run:jq,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Wq,preventDefault:!0}];function Pu(t,e){return ie.create(t.ranges.map(e),t.mainIndex)}function ui(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function fi({state:t,dispatch:e},r){let n=Pu(t.selection,r);return n.eq(t.selection,!0)?!1:(e(ui(t,n)),!0)}function r0(t,e){return ie.cursor(e?t.to:t.from)}function Q3(t,e){return fi(t,r=>r.empty?t.moveByChar(r,e):r0(r,e))}function lo(t){return t.textDirectionAt(t.state.selection.main.head)==Xt.LTR}var eL=t=>Q3(t,!lo(t)),tL=t=>Q3(t,lo(t));function rL(t,e){return fi(t,r=>r.empty?t.moveByGroup(r,e):r0(r,e))}var Jq=t=>rL(t,!lo(t)),Zq=t=>rL(t,lo(t));var tge=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Qq(t,e,r){if(e.type.prop(r))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function n0(t,e,r){let n=Bn(t).resolveInner(e.head),o=r?yt.closedBy:yt.openedBy;for(let l=e.head;;){let c=r?n.childAfter(l):n.childBefore(l);if(!c)break;Qq(t,c,o)?n=c:l=r?c.to:c.from}let s=n.type.prop(o),i,a;return s&&(i=r?ci(t,n.from,1):ci(t,n.to,-1))&&i.matched?a=r?i.end.to:i.end.from:a=r?n.to:n.from,ie.cursor(a,r?-1:1)}var eY=t=>fi(t,e=>n0(t.state,e,!lo(t))),tY=t=>fi(t,e=>n0(t.state,e,lo(t)));function nL(t,e){return fi(t,r=>{if(!r.empty)return r0(r,e);let n=t.moveVertically(r,e);return n.head!=r.head?n:t.moveToLineBoundary(r,e)})}var oL=t=>nL(t,!1),sL=t=>nL(t,!0);function iL(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,r=0,n=0,o;if(e){for(let s of t.state.facet(ve.scrollMargins)){let i=s(t);i?.top&&(r=Math.max(i?.top,r)),i?.bottom&&(n=Math.max(i?.bottom,n))}o=t.scrollDOM.clientHeight-r-n}else o=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:n,selfScroll:e,height:Math.max(t.defaultLineHeight,o-5)}}function aL(t,e){let r=iL(t),{state:n}=t,o=Pu(n.selection,i=>i.empty?t.moveVertically(i,e,r.height):r0(i,e));if(o.eq(n.selection))return!1;let s;if(r.selfScroll){let i=t.coordsAtPos(n.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),l=a.top+r.marginTop,c=a.bottom-r.marginBottom;i&&i.top>l&&i.bottom<c&&(s=ve.scrollIntoView(o.main.head,{y:"start",yMargin:i.top-l}))}return t.dispatch(ui(n,o),{effects:s}),!0}var B3=t=>aL(t,!1),pS=t=>aL(t,!0);function Nl(t,e,r){let n=t.lineBlockAt(e.head),o=t.moveToLineBoundary(e,r);if(o.head==e.head&&o.head!=(r?n.to:n.from)&&(o=t.moveToLineBoundary(e,r,!1)),!r&&o.head==n.from&&n.length){let s=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;s&&e.head!=n.from+s&&(o=ie.cursor(n.from+s))}return o}var rY=t=>fi(t,e=>Nl(t,e,!0)),nY=t=>fi(t,e=>Nl(t,e,!1)),oY=t=>fi(t,e=>Nl(t,e,!lo(t))),sY=t=>fi(t,e=>Nl(t,e,lo(t))),iY=t=>fi(t,e=>ie.cursor(t.lineBlockAt(e.head).from,1)),aY=t=>fi(t,e=>ie.cursor(t.lineBlockAt(e.head).to,-1));function lY(t,e,r){let n=!1,o=Pu(t.selection,s=>{let i=ci(t,s.head,-1)||ci(t,s.head,1)||s.head>0&&ci(t,s.head-1,1)||s.head<t.doc.length&&ci(t,s.head+1,-1);if(!i||!i.end)return s;n=!0;let a=i.start.from==s.head?i.end.to:i.end.from;return r?ie.range(s.anchor,a):ie.cursor(a)});return n?(e(ui(t,o)),!0):!1}var cY=({state:t,dispatch:e})=>lY(t,e,!1);function Vs(t,e){let r=Pu(t.state.selection,n=>{let o=e(n);return ie.range(n.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(ui(t.state,r)),!0)}function lL(t,e){return Vs(t,r=>t.moveByChar(r,e))}var cL=t=>lL(t,!lo(t)),dL=t=>lL(t,lo(t));function uL(t,e){return Vs(t,r=>t.moveByGroup(r,e))}var dY=t=>uL(t,!lo(t)),uY=t=>uL(t,lo(t));var fY=t=>Vs(t,e=>n0(t.state,e,!lo(t))),pY=t=>Vs(t,e=>n0(t.state,e,lo(t)));function fL(t,e){return Vs(t,r=>t.moveVertically(r,e))}var pL=t=>fL(t,!1),hL=t=>fL(t,!0);function mL(t,e){return Vs(t,r=>t.moveVertically(r,e,iL(t).height))}var z3=t=>mL(t,!1),$3=t=>mL(t,!0),hY=t=>Vs(t,e=>Nl(t,e,!0)),mY=t=>Vs(t,e=>Nl(t,e,!1)),gY=t=>Vs(t,e=>Nl(t,e,!lo(t))),bY=t=>Vs(t,e=>Nl(t,e,lo(t))),xY=t=>Vs(t,e=>ie.cursor(t.lineBlockAt(e.head).from)),yY=t=>Vs(t,e=>ie.cursor(t.lineBlockAt(e.head).to)),F3=({state:t,dispatch:e})=>(e(ui(t,{anchor:0})),!0),H3=({state:t,dispatch:e})=>(e(ui(t,{anchor:t.doc.length})),!0),V3=({state:t,dispatch:e})=>(e(ui(t,{anchor:t.selection.main.anchor,head:0})),!0),j3=({state:t,dispatch:e})=>(e(ui(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),vY=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),wY=({state:t,dispatch:e})=>{let r=o0(t).map(({from:n,to:o})=>ie.range(n,Math.min(o+1,t.doc.length)));return e(t.update({selection:ie.create(r),userEvent:"select"})),!0},SY=({state:t,dispatch:e})=>{let r=Pu(t.selection,n=>{let o=Bn(t),s=o.resolveStack(n.from,1);if(n.empty){let i=o.resolveStack(n.from,-1);i.node.from>=s.node.from&&i.node.to<=s.node.to&&(s=i)}for(let i=s;i;i=i.next){let{node:a}=i;if((a.from<n.from&&a.to>=n.to||a.to>n.to&&a.from<=n.from)&&i.next)return ie.range(a.to,a.from)}return n});return r.eq(t.selection)?!1:(e(ui(t,r)),!0)};function gL(t,e){let{state:r}=t,n=r.selection,o=r.selection.ranges.slice();for(let s of r.selection.ranges){let i=r.doc.lineAt(s.head);if(e?i.to<t.state.doc.length:i.from>0)for(let a=s;;){let l=t.moveVertically(a,e);if(l.head<i.from||l.head>i.to){o.some(c=>c.head==l.head)||o.push(l);break}else{if(l.head==a.head)break;a=l}}}return o.length==n.ranges.length?!1:(t.dispatch(ui(r,ie.create(o,o.length-1))),!0)}var NY=t=>gL(t,!1),CY=t=>gL(t,!0),kY=({state:t,dispatch:e})=>{let r=t.selection,n=null;return r.ranges.length>1?n=ie.create([r.main]):r.main.empty||(n=ie.create([ie.cursor(r.main.head)])),n?(e(ui(t,n)),!0):!1};function Up(t,e){if(t.state.readOnly)return!1;let r="delete.selection",{state:n}=t,o=n.changeByRange(s=>{let{from:i,to:a}=s;if(i==a){let l=e(s);l<i?(r="delete.backward",l=Qb(t,l,!1)):l>i&&(r="delete.forward",l=Qb(t,l,!0)),i=Math.min(i,l),a=Math.max(a,l)}else i=Qb(t,i,!1),a=Qb(t,a,!0);return i==a?{range:s}:{changes:{from:i,to:a},range:ie.cursor(i,i<s.head?-1:1)}});return o.changes.empty?!1:(t.dispatch(n.update(o,{scrollIntoView:!0,userEvent:r,effects:r=="delete.selection"?ve.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function Qb(t,e,r){if(t instanceof ve)for(let n of t.state.facet(ve.atomicRanges).map(o=>o(t)))n.between(e,e,(o,s)=>{o<e&&s>e&&(e=r?s:o)});return e}var bL=(t,e,r)=>Up(t,n=>{let o=n.from,{state:s}=t,i=s.doc.lineAt(o),a,l;if(r&&!e&&o>i.from&&o<i.from+200&&!/[^ \t]/.test(a=i.text.slice(0,o-i.from))){if(a[a.length-1]==" ")return o-1;let c=va(a,s.tabSize),d=c%Vp(s)||Vp(s);for(let u=0;u<d&&a[a.length-1-u]==" ";u++)o--;l=o}else l=an(i.text,o-i.from,e,e)+i.from,l==o&&i.number!=(e?s.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(i.text.slice(l-i.from,o-i.from))&&(l=an(i.text,l-i.from,!1,!1)+i.from);return l}),hS=t=>bL(t,!1,!0);var xL=t=>bL(t,!0,!1),yL=(t,e)=>Up(t,r=>{let n=r.head,{state:o}=t,s=o.doc.lineAt(n),i=o.charCategorizer(n);for(let a=null;;){if(n==(e?s.to:s.from)){n==r.head&&s.number!=(e?o.doc.lines:1)&&(n+=e?1:-1);break}let l=an(s.text,n-s.from,e)+s.from,c=s.text.slice(Math.min(n,l)-s.from,Math.max(n,l)-s.from),d=i(c);if(a!=null&&d!=a)break;(c!=" "||n!=r.head)&&(a=d),n=l}return n}),vL=t=>yL(t,!1),EY=t=>yL(t,!0);var TY=t=>Up(t,e=>{let r=t.lineBlockAt(e.head).to;return e.head<r?r:Math.min(t.state.doc.length,e.head+1)});var IY=t=>Up(t,e=>{let r=t.moveToLineBoundary(e,!1).head;return e.head>r?r:Math.max(0,e.head-1)}),AY=t=>Up(t,e=>{let r=t.moveToLineBoundary(e,!0).head;return e.head<r?r:Math.min(t.state.doc.length,e.head+1)});var MY=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:kt.of(["",""])},range:ie.cursor(n.from)}));return e(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0},PY=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{if(!n.empty||n.from==0||n.from==t.doc.length)return{range:n};let o=n.from,s=t.doc.lineAt(o),i=o==s.from?o-1:an(s.text,o-s.from,!1)+s.from,a=o==s.to?o+1:an(s.text,o-s.from,!0)+s.from;return{changes:{from:i,to:a,insert:t.doc.slice(o,a).append(t.doc.slice(i,o))},range:ie.cursor(a)}});return r.changes.empty?!1:(e(t.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function o0(t){let e=[],r=-1;for(let n of t.selection.ranges){let o=t.doc.lineAt(n.from),s=t.doc.lineAt(n.to);if(!n.empty&&n.to==s.from&&(s=t.doc.lineAt(n.to-1)),r>=o.number){let i=e[e.length-1];i.to=s.to,i.ranges.push(n)}else e.push({from:o.from,to:s.to,ranges:[n]});r=s.number+1}return e}function wL(t,e,r){if(t.readOnly)return!1;let n=[],o=[];for(let s of o0(t)){if(r?s.to==t.doc.length:s.from==0)continue;let i=t.doc.lineAt(r?s.to+1:s.from-1),a=i.length+1;if(r){n.push({from:s.to,to:i.to},{from:s.from,insert:i.text+t.lineBreak});for(let l of s.ranges)o.push(ie.range(Math.min(t.doc.length,l.anchor+a),Math.min(t.doc.length,l.head+a)))}else{n.push({from:i.from,to:s.from},{from:s.to,insert:t.lineBreak+i.text});for(let l of s.ranges)o.push(ie.range(l.anchor-a,l.head-a))}}return n.length?(e(t.update({changes:n,scrollIntoView:!0,selection:ie.create(o,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}var RY=({state:t,dispatch:e})=>wL(t,e,!1),DY=({state:t,dispatch:e})=>wL(t,e,!0);function SL(t,e,r){if(t.readOnly)return!1;let n=[];for(let s of o0(t))r?n.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):n.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let o=t.changes(n);return e(t.update({changes:o,selection:t.selection.map(o,r?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var OY=({state:t,dispatch:e})=>SL(t,e,!1),_Y=({state:t,dispatch:e})=>SL(t,e,!0),LY=t=>{if(t.state.readOnly)return!1;let{state:e}=t,r=e.changes(o0(e).map(({from:o,to:s})=>(o>0?o--:s<e.doc.length&&s++,{from:o,to:s}))),n=Pu(e.selection,o=>{let s;if(t.lineWrapping){let i=t.lineBlockAt(o.head),a=t.coordsAtPos(o.head,o.assoc||1);a&&(s=i.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(o,!0,s)}).map(r);return t.dispatch({changes:r,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function BY(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let r=Bn(t).resolveInner(e),n=r.childBefore(e),o=r.childAfter(e),s;return n&&o&&n.to<=e&&o.from>=e&&(s=n.type.prop(yt.closedBy))&&s.indexOf(o.name)>-1&&t.doc.lineAt(n.to).from==t.doc.lineAt(o.from).from&&!/\S/.test(t.sliceDoc(n.to,o.from))?{from:n.to,to:o.from}:null}var W3=NL(!1),zY=NL(!0);function NL(t){return({state:e,dispatch:r})=>{if(e.readOnly)return!1;let n=e.changeByRange(o=>{let{from:s,to:i}=o,a=e.doc.lineAt(s),l=!t&&s==i&&BY(e,s);t&&(s=i=(i<=a.to?a:e.doc.lineAt(i)).to);let c=new Vc(e,{simulateBreak:s,simulateDoubleBreak:!!l}),d=Xb(c,s);for(d==null&&(d=va(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));i<a.to&&/\s/.test(a.text[i-a.from]);)i++;l?{from:s,to:i}=l:s>a.from&&s<a.from+100&&!/\S/.test(a.text.slice(0,s))&&(s=a.from);let u=["",Mu(e,d)];return l&&u.push(Mu(e,c.lineIndent(a.from,-1))),{changes:{from:s,to:i,insert:kt.of(u)},range:ie.cursor(s+1+u[1].length)}});return r(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function bS(t,e){let r=-1;return t.changeByRange(n=>{let o=[];for(let i=n.from;i<=n.to;){let a=t.doc.lineAt(i);a.number>r&&(n.empty||n.to>a.from)&&(e(a,o,n),r=a.number),i=a.to+1}let s=t.changes(o);return{changes:o,range:ie.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}})}var $Y=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=Object.create(null),n=new Vc(t,{overrideIndentation:s=>{let i=r[s];return i??-1}}),o=bS(t,(s,i,a)=>{let l=Xb(n,s.from);if(l==null)return;/\S/.test(s.text)||(l=0);let c=/^\s*/.exec(s.text)[0],d=Mu(t,l);(c!=d||a.from<s.from+c.length)&&(r[s.from]=l,i.push({from:s.from,to:s.from+c.length,insert:d}))});return o.changes.empty||e(t.update(o,{userEvent:"indent"})),!0},CL=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(bS(t,(r,n)=>{n.push({from:r.from,insert:t.facet(Wc)})}),{userEvent:"input.indent"})),!0),kL=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(bS(t,(r,n)=>{let o=/^\s*/.exec(r.text)[0];if(!o)return;let s=va(o,t.tabSize),i=0,a=Mu(t,Math.max(0,s-Vp(t)));for(;i<o.length&&i<a.length&&o.charCodeAt(i)==a.charCodeAt(i);)i++;n.push({from:r.from+i,to:r.from+o.length,insert:a.slice(i)})}),{userEvent:"delete.dedent"})),!0),FY=t=>(t.setTabFocusMode(),!0);var HY=[{key:"Ctrl-b",run:eL,shift:cL,preventDefault:!0},{key:"Ctrl-f",run:tL,shift:dL},{key:"Ctrl-p",run:oL,shift:pL},{key:"Ctrl-n",run:sL,shift:hL},{key:"Ctrl-a",run:iY,shift:xY},{key:"Ctrl-e",run:aY,shift:yY},{key:"Ctrl-d",run:xL},{key:"Ctrl-h",run:hS},{key:"Ctrl-k",run:TY},{key:"Ctrl-Alt-h",run:vL},{key:"Ctrl-o",run:MY},{key:"Ctrl-t",run:PY},{key:"Ctrl-v",run:pS}],VY=[{key:"ArrowLeft",run:eL,shift:cL,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Jq,shift:dY,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:oY,shift:gY,preventDefault:!0},{key:"ArrowRight",run:tL,shift:dL,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Zq,shift:uY,preventDefault:!0},{mac:"Cmd-ArrowRight",run:sY,shift:bY,preventDefault:!0},{key:"ArrowUp",run:oL,shift:pL,preventDefault:!0},{mac:"Cmd-ArrowUp",run:F3,shift:V3},{mac:"Ctrl-ArrowUp",run:B3,shift:z3},{key:"ArrowDown",run:sL,shift:hL,preventDefault:!0},{mac:"Cmd-ArrowDown",run:H3,shift:j3},{mac:"Ctrl-ArrowDown",run:pS,shift:$3},{key:"PageUp",run:B3,shift:z3},{key:"PageDown",run:pS,shift:$3},{key:"Home",run:nY,shift:mY,preventDefault:!0},{key:"Mod-Home",run:F3,shift:V3},{key:"End",run:rY,shift:hY,preventDefault:!0},{key:"Mod-End",run:H3,shift:j3},{key:"Enter",run:W3,shift:W3},{key:"Mod-a",run:vY},{key:"Backspace",run:hS,shift:hS,preventDefault:!0},{key:"Delete",run:xL,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:vL,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:EY,preventDefault:!0},{mac:"Mod-Backspace",run:IY,preventDefault:!0},{mac:"Mod-Delete",run:AY,preventDefault:!0}].concat(HY.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),EL=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:eY,shift:fY},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:tY,shift:pY},{key:"Alt-ArrowUp",run:RY},{key:"Shift-Alt-ArrowUp",run:OY},{key:"Alt-ArrowDown",run:DY},{key:"Shift-Alt-ArrowDown",run:_Y},{key:"Mod-Alt-ArrowUp",run:NY},{key:"Mod-Alt-ArrowDown",run:CY},{key:"Escape",run:kY},{key:"Mod-Enter",run:zY},{key:"Alt-l",mac:"Ctrl-l",run:wY},{key:"Mod-i",run:SY,preventDefault:!0},{key:"Mod-[",run:kL},{key:"Mod-]",run:CL},{key:"Mod-Alt-\\",run:$Y},{key:"Shift-Mod-k",run:LY},{key:"Shift-Mod-\\",run:cY},{key:"Mod-/",run:Oq},{key:"Alt-A",run:Lq},{key:"Ctrl-m",mac:"Shift-Alt-m",run:FY}].concat(VY),TL={key:"Tab",run:CL,shift:kL};var IL=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t,kl=class{constructor(e,r,n=0,o=e.length,s,i){this.test=i,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,o),this.bufferStart=n,this.normalize=s?a=>s(IL(a)):IL,this.query=this.normalize(r)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Gn(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let r=up(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=os(e);let o=this.normalize(r);if(o.length)for(let s=0,i=n;;s++){let a=o.charCodeAt(s),l=this.match(a,i,this.bufferPos+this.bufferStart);if(s==o.length-1){if(l)return this.value=l,this;break}i==n&&s<r.length&&r.charCodeAt(s)==a&&i++}}}match(e,r,n){let o=null;for(let s=0;s<this.matches.length;s+=2){let i=this.matches[s],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?o={from:this.matches[s+1],to:n}:(this.matches[s]++,a=!0)),a||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?o={from:r,to:n}:this.matches.push(1,r)),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}};typeof Symbol<"u"&&(kl.prototype[Symbol.iterator]=function(){return this});var PL={from:-1,to:-1,match:/.*/.exec("")},NS="gm"+(/x/.unicode==null?"":"u"),a0=class{constructor(e,r,n,o=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=PL,/\\[sWDnr]|\n|\r|\[\^/.test(r))return new c0(e,r,n,o,s);this.re=new RegExp(r,NS+(n?.ignoreCase?"i":"")),this.test=n?.test,this.iter=e.iter();let i=e.lineAt(o);this.curLineStart=i.from,this.matchPos=d0(e,o),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let r=this.matchPos<=this.to&&this.re.exec(this.curLine);if(r){let n=this.curLineStart+r.index,o=n+r[0].length;if(this.matchPos=d0(this.text,o+(n==o?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<o||n>this.value.to)&&(!this.test||this.test(n,o,r)))return this.value={from:n,to:o,match:r},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},xS=new WeakMap,l0=class t{constructor(e,r){this.from=e,this.text=r}get to(){return this.from+this.text.length}static get(e,r,n){let o=xS.get(e);if(!o||o.from>=n||o.to<=r){let a=new t(r,e.sliceString(r,n));return xS.set(e,a),a}if(o.from==r&&o.to==n)return o;let{text:s,from:i}=o;return i>r&&(s=e.sliceString(r,i)+s,i=r),o.to<n&&(s+=e.sliceString(o.to,n)),xS.set(e,new t(i,s)),new t(r,s.slice(r-i,n-i))}},c0=class{constructor(e,r,n,o,s){this.text=e,this.to=s,this.done=!1,this.value=PL,this.matchPos=d0(e,o),this.re=new RegExp(r,NS+(n?.ignoreCase?"i":"")),this.test=n?.test,this.flat=l0.get(e,o,this.chunkEnd(o+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,r=this.re.exec(this.flat.text);if(r&&!r[0]&&r.index==e&&(this.re.lastIndex=e+1,r=this.re.exec(this.flat.text)),r){let n=this.flat.from+r.index,o=n+r[0].length;if((this.flat.to>=this.to||r.index+r[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,o,r)))return this.value={from:n,to:o,match:r},this.matchPos=d0(this.text,o+(n==o?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=l0.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(a0.prototype[Symbol.iterator]=c0.prototype[Symbol.iterator]=function(){return this});function jY(t){try{return new RegExp(t,NS),!0}catch{return!1}}function d0(t,e){if(e>=t.length)return e;let r=t.lineAt(e),n;for(;e<r.to&&(n=r.text.charCodeAt(e-r.from))>=56320&&n<57344;)e++;return e}var WY=t=>{let{state:e}=t,r=String(e.doc.lineAt(t.state.selection.main.head).number),{close:n,result:o}=X_(t,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:r},focus:!0,submitLabel:e.phrase("go")});return o.then(s=>{let i=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!i){t.dispatch({effects:n});return}let a=e.doc.lineAt(e.selection.main.head),[,l,c,d,u]=i,f=d?+d.slice(1):0,p=c?+c:a.number;if(c&&u){let g=p/100;l&&(g=g*(l=="-"?-1:1)+a.number/e.doc.lines),p=Math.round(e.doc.lines*g)}else c&&l&&(p=p*(l=="-"?-1:1)+a.number);let h=e.doc.line(Math.max(1,Math.min(e.doc.lines,p))),b=ie.cursor(h.from+Math.max(0,Math.min(f,h.length)));t.dispatch({effects:[n,ve.scrollIntoView(b.from,{y:"center"})],selection:b})}),!0},UY={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},RL=Ce.define({combine(t){return ao(t,UY,{highlightWordAroundCursor:(e,r)=>e||r,minSelectionLength:Math.min,maxMatches:Math.min})}});function DL(t){let e=[XY,YY];return t&&e.push(RL.of(t)),e}var GY=Fe.mark({class:"cm-selectionMatch"}),KY=Fe.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function AL(t,e,r,n){return(r==0||t(e.sliceDoc(r-1,r))!=cr.Word)&&(n==e.doc.length||t(e.sliceDoc(n,n+1))!=cr.Word)}function qY(t,e,r,n){return t(e.sliceDoc(r,r+1))==cr.Word&&t(e.sliceDoc(n-1,n))==cr.Word}var YY=Er.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(RL),{state:r}=t,n=r.selection;if(n.ranges.length>1)return Fe.none;let o=n.main,s,i=null;if(o.empty){if(!e.highlightWordAroundCursor)return Fe.none;let l=r.wordAt(o.head);if(!l)return Fe.none;i=r.charCategorizer(o.head),s=r.sliceDoc(l.from,l.to)}else{let l=o.to-o.from;if(l<e.minSelectionLength||l>200)return Fe.none;if(e.wholeWords){if(s=r.sliceDoc(o.from,o.to),i=r.charCategorizer(o.head),!(AL(i,r,o.from,o.to)&&qY(i,r,o.from,o.to)))return Fe.none}else if(s=r.sliceDoc(o.from,o.to),!s)return Fe.none}let a=[];for(let l of t.visibleRanges){let c=new kl(r.doc,s,l.from,l.to);for(;!c.next().done;){let{from:d,to:u}=c.value;if((!i||AL(i,r,d,u))&&(o.empty&&d<=o.from&&u>=o.to?a.push(KY.range(d,u)):(d>=o.to||u<=o.from)&&a.push(GY.range(d,u)),a.length>e.maxMatches))return Fe.none}}return Fe.set(a)}},{decorations:t=>t.decorations}),XY=ve.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),JY=({state:t,dispatch:e})=>{let{selection:r}=t,n=ie.create(r.ranges.map(o=>t.wordAt(o.head)||ie.cursor(o.head)),r.mainIndex);return n.eq(r)?!1:(e(t.update({selection:n})),!0)};function ZY(t,e){let{main:r,ranges:n}=t.selection,o=t.wordAt(r.head),s=o&&o.from==r.from&&o.to==r.to;for(let i=!1,a=new kl(t.doc,e,n[n.length-1].to);;)if(a.next(),a.done){if(i)return null;a=new kl(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),i=!0}else{if(i&&n.some(l=>l.from==a.value.from))continue;if(s){let l=t.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}var QY=({state:t,dispatch:e})=>{let{ranges:r}=t.selection;if(r.some(s=>s.from===s.to))return JY({state:t,dispatch:e});let n=t.sliceDoc(r[0].from,r[0].to);if(t.selection.ranges.some(s=>t.sliceDoc(s.from,s.to)!=n))return!1;let o=ZY(t,n);return o?(e(t.update({selection:t.selection.addRange(ie.range(o.from,o.to),!1),effects:ve.scrollIntoView(o.to)})),!0):!1},Ou=Ce.define({combine(t){return ao(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new SS(e),scrollToMatch:e=>ve.scrollIntoView(e)})}});var u0=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||jY(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(r,n)=>n=="n"?`
|
|
491
|
+
`:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new vS(this):new yS(this)}getCursor(e,r=0,n){let o=e.doc?e:jt.create({doc:e});return n==null&&(n=o.doc.length),this.regexp?Du(this,o,r,n):Ru(this,o,r,n)}},f0=class{constructor(e){this.spec=e}};function eX(t,e,r){return(n,o,s,i)=>{if(r&&!r(n,o,s,i))return!1;let a=n>=i&&o<=i+s.length?s.slice(n-i,o-i):e.doc.sliceString(n,o);return t(a,e,n,o)}}function Ru(t,e,r,n){let o;return t.wholeWord&&(o=tX(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(o=eX(t.test,e,o)),new kl(e.doc,t.unquoted,r,n,t.caseSensitive?void 0:s=>s.toLowerCase(),o)}function tX(t,e){return(r,n,o,s)=>((s>r||s+o.length<n)&&(s=Math.max(0,r-2),o=t.sliceString(s,Math.min(t.length,n+2))),(e(p0(o,r-s))!=cr.Word||e(h0(o,r-s))!=cr.Word)&&(e(h0(o,n-s))!=cr.Word||e(p0(o,n-s))!=cr.Word))}var yS=class extends f0{constructor(e){super(e)}nextMatch(e,r,n){let o=Ru(this.spec,e,n,e.doc.length).nextOverlapping();if(o.done){let s=Math.min(e.doc.length,r+this.spec.unquoted.length);o=Ru(this.spec,e,0,s).nextOverlapping()}return o.done||o.value.from==r&&o.value.to==n?null:o.value}prevMatchInRange(e,r,n){for(let o=n;;){let s=Math.max(r,o-1e4-this.spec.unquoted.length),i=Ru(this.spec,e,s,o),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(s==r)return null;o-=1e4}}prevMatch(e,r,n){let o=this.prevMatchInRange(e,0,r);return o||(o=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),o&&(o.from!=r||o.to!=n)?o:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,r){let n=Ru(this.spec,e,0,e.doc.length),o=[];for(;!n.next().done;){if(o.length>=r)return null;o.push(n.value)}return o}highlight(e,r,n,o){let s=Ru(this.spec,e,Math.max(0,r-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)o(s.value.from,s.value.to)}};function rX(t,e,r){return(n,o,s)=>(!r||r(n,o,s))&&t(s[0],e,n,o)}function Du(t,e,r,n){let o;return t.wholeWord&&(o=nX(e.charCategorizer(e.selection.main.head))),t.test&&(o=rX(t.test,e,o)),new a0(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:o},r,n)}function p0(t,e){return t.slice(an(t,e,!1),e)}function h0(t,e){return t.slice(e,an(t,e))}function nX(t){return(e,r,n)=>!n[0].length||(t(p0(n.input,n.index))!=cr.Word||t(h0(n.input,n.index))!=cr.Word)&&(t(h0(n.input,n.index+n[0].length))!=cr.Word||t(p0(n.input,n.index+n[0].length))!=cr.Word)}var vS=class extends f0{nextMatch(e,r,n){let o=Du(this.spec,e,n,e.doc.length).next();return o.done&&(o=Du(this.spec,e,0,r).next()),o.done?null:o.value}prevMatchInRange(e,r,n){for(let o=1;;o++){let s=Math.max(r,n-o*1e4),i=Du(this.spec,e,s,n),a=null;for(;!i.next().done;)a=i.value;if(a&&(s==r||a.from>s+10))return a;if(s==r)return null}}prevMatch(e,r,n){return this.prevMatchInRange(e,0,r)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(r,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let o=n.length;o>0;o--){let s=+n.slice(0,o);if(s>0&&s<e.match.length)return e.match[s]+n.slice(o)}return r})}matchAll(e,r){let n=Du(this.spec,e,0,e.doc.length),o=[];for(;!n.next().done;){if(o.length>=r)return null;o.push(n.value)}return o}highlight(e,r,n,o){let s=Du(this.spec,e,Math.max(0,r-250),Math.min(n+250,e.doc.length));for(;!s.next().done;)o(s.value.from,s.value.to)}},Kp=Qe.define(),CS=Qe.define(),Cl=Jr.define({create(t){return new Gp(wS(t).create(),null)},update(t,e){for(let r of e.effects)r.is(Kp)?t=new Gp(r.value.create(),t.panel):r.is(CS)&&(t=new Gp(t.query,r.value?kS:null));return t},provide:t=>Bc.from(t,e=>e.panel)});var Gp=class{constructor(e,r){this.query=e,this.panel=r}},oX=Fe.mark({class:"cm-searchMatch"}),sX=Fe.mark({class:"cm-searchMatch cm-searchMatch-selected"}),iX=Er.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Cl))}update(t){let e=t.state.field(Cl);(e!=t.startState.field(Cl)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Fe.none;let{view:r}=this,n=new ns;for(let o=0,s=r.visibleRanges,i=s.length;o<i;o++){let{from:a,to:l}=s[o];for(;o<i-1&&l>s[o+1].from-500;)l=s[++o].to;t.highlight(r.state,a,l,(c,d)=>{let u=r.state.selection.ranges.some(f=>f.from==c&&f.to==d);n.add(c,d,u?sX:oX)})}return n.finish()}},{decorations:t=>t.decorations});function qp(t){return e=>{let r=e.state.field(Cl,!1);return r&&r.query.spec.valid?t(e,r):LL(e)}}var m0=qp((t,{query:e})=>{let{to:r}=t.state.selection.main,n=e.nextMatch(t.state,r,r);if(!n)return!1;let o=ie.single(n.from,n.to),s=t.state.facet(Ou);return t.dispatch({selection:o,effects:[ES(t,n),s.scrollToMatch(o.main,t)],userEvent:"select.search"}),_L(t),!0}),g0=qp((t,{query:e})=>{let{state:r}=t,{from:n}=r.selection.main,o=e.prevMatch(r,n,n);if(!o)return!1;let s=ie.single(o.from,o.to),i=t.state.facet(Ou);return t.dispatch({selection:s,effects:[ES(t,o),i.scrollToMatch(s.main,t)],userEvent:"select.search"}),_L(t),!0}),aX=qp((t,{query:e})=>{let r=e.matchAll(t.state,1e3);return!r||!r.length?!1:(t.dispatch({selection:ie.create(r.map(n=>ie.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),lX=({state:t,dispatch:e})=>{let r=t.selection;if(r.ranges.length>1||r.main.empty)return!1;let{from:n,to:o}=r.main,s=[],i=0;for(let a=new kl(t.doc,t.sliceDoc(n,o));!a.next().done;){if(s.length>1e3)return!1;a.value.from==n&&(i=s.length),s.push(ie.range(a.value.from,a.value.to))}return e(t.update({selection:ie.create(s,i),userEvent:"select.search.matches"})),!0},ML=qp((t,{query:e})=>{let{state:r}=t,{from:n,to:o}=r.selection.main;if(r.readOnly)return!1;let s=e.nextMatch(r,n,n);if(!s)return!1;let i=s,a=[],l,c,d=[];i.from==n&&i.to==o&&(c=r.toText(e.getReplacement(i)),a.push({from:i.from,to:i.to,insert:c}),i=e.nextMatch(r,i.from,i.to),d.push(ve.announce.of(r.phrase("replaced match on line $",r.doc.lineAt(n).number)+".")));let u=t.state.changes(a);return i&&(l=ie.single(i.from,i.to).map(u),d.push(ES(t,i)),d.push(r.facet(Ou).scrollToMatch(l.main,t))),t.dispatch({changes:u,selection:l,effects:d,userEvent:"input.replace"}),!0}),cX=qp((t,{query:e})=>{if(t.state.readOnly)return!1;let r=e.matchAll(t.state,1e9).map(o=>{let{from:s,to:i}=o;return{from:s,to:i,insert:e.getReplacement(o)}});if(!r.length)return!1;let n=t.state.phrase("replaced $ matches",r.length)+".";return t.dispatch({changes:r,effects:ve.announce.of(n),userEvent:"input.replace.all"}),!0});function kS(t){return t.state.facet(Ou).createPanel(t)}function wS(t,e){var r,n,o,s,i;let a=t.selection.main,l=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=t.facet(Ou);return new u0({search:((r=e?.literal)!==null&&r!==void 0?r:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(n=e?.caseSensitive)!==null&&n!==void 0?n:c.caseSensitive,literal:(o=e?.literal)!==null&&o!==void 0?o:c.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:c.regexp,wholeWord:(i=e?.wholeWord)!==null&&i!==void 0?i:c.wholeWord})}function OL(t){let e=Rp(t,kS);return e&&e.dom.querySelector("[main-field]")}function _L(t){let e=OL(t);e&&e==t.root.activeElement&&e.select()}var LL=t=>{let e=t.state.field(Cl,!1);if(e&&e.panel){let r=OL(t);if(r&&r!=t.root.activeElement){let n=wS(t.state,e.query.spec);n.valid&&t.dispatch({effects:Kp.of(n)}),r.focus(),r.select()}}else t.dispatch({effects:[CS.of(!0),e?Kp.of(wS(t.state,e.query.spec)):Qe.appendConfig.of(uX)]});return!0},BL=t=>{let e=t.state.field(Cl,!1);if(!e||!e.panel)return!1;let r=Rp(t,kS);return r&&r.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:CS.of(!1)}),!0},zL=[{key:"Mod-f",run:LL,scope:"editor search-panel"},{key:"F3",run:m0,shift:g0,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:m0,shift:g0,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:BL,scope:"editor search-panel"},{key:"Mod-Shift-l",run:lX},{key:"Mod-Alt-g",run:WY},{key:"Mod-d",run:QY,preventDefault:!0}],SS=class{constructor(e){this.view=e;let r=this.query=e.state.field(Cl).query.spec;this.commit=this.commit.bind(this),this.searchField=Wt("input",{value:r.search,placeholder:ls(e,"Find"),"aria-label":ls(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Wt("input",{value:r.replace,placeholder:ls(e,"Replace"),"aria-label":ls(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Wt("input",{type:"checkbox",name:"case",form:"",checked:r.caseSensitive,onchange:this.commit}),this.reField=Wt("input",{type:"checkbox",name:"re",form:"",checked:r.regexp,onchange:this.commit}),this.wordField=Wt("input",{type:"checkbox",name:"word",form:"",checked:r.wholeWord,onchange:this.commit});function n(o,s,i){return Wt("button",{class:"cm-button",name:o,onclick:s,type:"button"},i)}this.dom=Wt("div",{onkeydown:o=>this.keydown(o),class:"cm-search"},[this.searchField,n("next",()=>m0(e),[ls(e,"next")]),n("prev",()=>g0(e),[ls(e,"previous")]),n("select",()=>aX(e),[ls(e,"all")]),Wt("label",null,[this.caseField,ls(e,"match case")]),Wt("label",null,[this.reField,ls(e,"regexp")]),Wt("label",null,[this.wordField,ls(e,"by word")]),...e.state.readOnly?[]:[Wt("br"),this.replaceField,n("replace",()=>ML(e),[ls(e,"replace")]),n("replaceAll",()=>cX(e),[ls(e,"replace all")])],Wt("button",{name:"close",onclick:()=>BL(e),"aria-label":ls(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new u0({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Kp.of(e)}))}keydown(e){__(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?g0:m0)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),ML(this.view))}update(e){for(let r of e.transactions)for(let n of r.effects)n.is(Kp)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Ou).top}};function ls(t,e){return t.state.phrase(e)}var s0=30,i0=/[\s\.,:;?!]/;function ES(t,{from:e,to:r}){let n=t.state.doc.lineAt(e),o=t.state.doc.lineAt(r).to,s=Math.max(n.from,e-s0),i=Math.min(o,r+s0),a=t.state.sliceDoc(s,i);if(s!=n.from){for(let l=0;l<s0;l++)if(!i0.test(a[l+1])&&i0.test(a[l])){a=a.slice(l);break}}if(i!=o){for(let l=a.length-1;l>a.length-s0;l--)if(!i0.test(a[l-1])&&i0.test(a[l])){a=a.slice(0,l);break}}return ve.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${n.number}.`)}var dX=ve.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),uX=[Cl,oi.low(iX),dX];var x0=class{constructor(e,r,n,o){this.state=e,this.pos=r,this.explicit=n,this.view=o,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let r=Bn(this.state).resolveInner(this.pos,-1);for(;r&&e.indexOf(r.name)<0;)r=r.parent;return r?{from:r.from,to:this.pos,text:this.state.sliceDoc(r.from,this.pos),type:r.type}:null}matchBefore(e){let r=this.state.doc.lineAt(this.pos),n=Math.max(r.from,this.pos-250),o=r.text.slice(n-r.from,this.pos-r.from),s=o.search(GL(e,!1));return s<0?null:{from:n+s,to:this.pos,text:o.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,r,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(r),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function $L(t){let e=Object.keys(t).join(""),r=/\w/.test(e);return r&&(e=e.replace(/\w/g,"")),`[${r?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function fX(t){let e=Object.create(null),r=Object.create(null);for(let{label:o}of t){e[o[0]]=!0;for(let s=1;s<o.length;s++)r[o[s]]=!0}let n=$L(e)+$L(r)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function pX(t){let e=t.map(o=>typeof o=="string"?{label:o}:o),[r,n]=e.every(o=>/^\w+$/.test(o.label))?[/\w*$/,/\w+$/]:fX(e);return o=>{let s=o.matchBefore(n);return s||o.explicit?{from:s?s.from:o.pos,options:e,validFor:r}:null}}var y0=class{constructor(e,r,n,o){this.completion=e,this.source=r,this.match=n,this.score=o}};function Kc(t){return t.selection.main.from}function GL(t,e){var r;let{source:n}=t,o=e&&n[0]!="^",s=n[n.length-1]!="$";return!o&&!s?t:new RegExp(`${o?"^":""}(?:${n})${s?"$":""}`,(r=t.flags)!==null&&r!==void 0?r:t.ignoreCase?"i":"")}var KL=io.define();function hX(t,e,r,n){let{main:o}=t.selection,s=r-o.from,i=n-o.from;return{...t.changeByRange(a=>{if(a!=o&&r!=n&&t.sliceDoc(a.from+s,a.from+i)!=t.sliceDoc(r,n))return{range:a};let l=t.toText(e);return{changes:{from:a.from+s,to:n==o.from?a.to:a.from+i,insert:l},range:ie.cursor(a.from+s+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}var FL=new WeakMap;function mX(t){if(!Array.isArray(t))return t;let e=FL.get(t);return e||FL.set(t,e=pX(t)),e}var v0=Qe.define(),Yp=Qe.define(),MS=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let r=0;r<e.length;){let n=Gn(e,r),o=os(n);this.chars.push(n);let s=e.slice(r,r+o),i=s.toUpperCase();this.folded.push(Gn(i==s?s.toLowerCase():i,0)),r+=o}this.astral=e.length!=this.chars.length}ret(e,r){return this.score=e,this.matched=r,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:r,folded:n,any:o,precise:s,byWord:i}=this;if(r.length==1){let y=Gn(e,0),m=os(y),v=m==e.length?0:-100;if(y!=r[0])if(y==n[0])v+=-200;else return null;return this.ret(v,[0,m])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=r.length,c=0;if(a<0){for(let y=0,m=Math.min(e.length,200);y<m&&c<l;){let v=Gn(e,y);(v==r[c]||v==n[c])&&(o[c++]=y),y+=os(v)}if(c<l)return null}let d=0,u=0,f=!1,p=0,h=-1,b=-1,g=/[a-z]/.test(e),x=!0;for(let y=0,m=Math.min(e.length,200),v=0;y<m&&u<l;){let S=Gn(e,y);a<0&&(d<l&&S==r[d]&&(s[d++]=y),p<l&&(S==r[p]||S==n[p]?(p==0&&(h=y),b=y+1,p++):p=0));let w,C=S<255?S>=48&&S<=57||S>=97&&S<=122?2:S>=65&&S<=90?1:0:(w=up(S))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!y||C==1&&g||v==0&&C!=0)&&(r[u]==S||n[u]==S&&(f=!0)?i[u++]=y:i.length&&(x=!1)),v=C,y+=os(S)}return u==l&&i[0]==0&&x?this.result(-100+(f?-200:0),i,e):p==l&&h==0?this.ret(-200-e.length+(b==e.length?0:-100),[0,b]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):p==l?this.ret(-900-e.length,[h,b]):u==l?this.result(-100+(f?-200:0)+-700+(x?0:-1100),i,e):r.length==2?null:this.result((o[0]?-700:0)+-200+-1100,o,e)}result(e,r,n){let o=[],s=0;for(let i of r){let a=i+(this.astral?os(Gn(n,i)):1);s&&o[s-1]==i?o[s-1]=a:(o[s++]=i,o[s++]=a)}return this.ret(e-n.length,o)}},PS=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let r=e.slice(0,this.pattern.length),n=r==this.pattern?0:r.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,r.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},zn=Ce.define({combine(t){return ao(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:gX,filterStrict:!1,compareCompletions:(e,r)=>(e.sortText||e.label).localeCompare(r.sortText||r.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,r)=>e&&r,closeOnBlur:(e,r)=>e&&r,icons:(e,r)=>e&&r,tooltipClass:(e,r)=>n=>HL(e(n),r(n)),optionClass:(e,r)=>n=>HL(e(n),r(n)),addToOptions:(e,r)=>e.concat(r),filterStrict:(e,r)=>e||r})}});function HL(t,e){return t?e?t+" "+e:t:e}function gX(t,e,r,n,o,s){let i=t.textDirection==Xt.RTL,a=i,l=!1,c="top",d,u,f=e.left-o.left,p=o.right-e.right,h=n.right-n.left,b=n.bottom-n.top;if(a&&f<Math.min(h,p)?a=!1:!a&&p<Math.min(h,f)&&(a=!0),h<=(a?f:p))d=Math.max(o.top,Math.min(r.top,o.bottom-b))-e.top,u=Math.min(400,a?f:p);else{l=!0,u=Math.min(400,(i?e.right:o.right-e.left)-30);let y=o.bottom-e.bottom;y>=b||y>e.top?d=r.bottom-e.top:(c="bottom",d=e.bottom-r.top)}let g=(e.bottom-e.top)/s.offsetHeight,x=(e.right-e.left)/s.offsetWidth;return{style:`${c}: ${d/g}px; max-width: ${u/x}px`,class:"cm-completionInfo-"+(l?i?"left-narrow":"right-narrow":a?"left":"right")}}var LS=Qe.define();function bX(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(r){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),r.type&&n.classList.add(...r.type.split(/\s+/g).map(o=>"cm-completionIcon-"+o)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(r,n,o,s){let i=document.createElement("span");i.className="cm-completionLabel";let a=r.displayLabel||r.label,l=0;for(let c=0;c<s.length;){let d=s[c++],u=s[c++];d>l&&i.appendChild(document.createTextNode(a.slice(l,d)));let f=i.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(a.slice(d,u))),f.className="cm-completionMatchedText",l=u}return l<a.length&&i.appendChild(document.createTextNode(a.slice(l))),i},position:50},{render(r){if(!r.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=r.detail,n},position:80}),e.sort((r,n)=>r.position-n.position).map(r=>r.render)}function TS(t,e,r){if(t<=r)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let o=Math.floor(e/r);return{from:o*r,to:(o+1)*r}}let n=Math.floor((t-e)/r);return{from:t-(n+1)*r,to:t-n*r}}var RS=class{constructor(e,r,n){this.view=e,this.stateField=r,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let o=e.state.field(r),{options:s,selected:i}=o.open,a=e.state.facet(zn);this.optionContent=bX(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=TS(s.length,i,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(r).open;for(let d=l.target,u;d&&d!=this.dom;d=d.parentNode)if(d.nodeName=="LI"&&(u=/-(\d+)$/.exec(d.id))&&+u[1]<c.length){this.applyCompletion(e,c[+u[1]]),l.preventDefault();return}if(l.target==this.list){let d=this.list.classList.contains("cm-completionListIncompleteTop")&&l.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&l.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;d!=null&&(e.dispatch({effects:LS.of(d)}),l.preventDefault())}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(zn).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Yp.of(null)})}),this.showOptions(s,o.id)}mount(){this.updateSel()}showOptions(e,r){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,r,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var r;let n=e.state.field(this.stateField),o=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=o){let{options:s,selected:i,disabled:a}=n.open;(!o.open||o.open.options!=s)&&(this.range=TS(s.length,i,e.state.facet(zn).maxRenderedOptions),this.showOptions(s,n.id)),this.updateSel(),a!=((r=o.open)===null||r===void 0?void 0:r.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let r=this.tooltipClass(e);if(r!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of r.split(" "))n&&this.dom.classList.add(n);this.currentClass=r}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),r=e.open;(r.selected>-1&&r.selected<this.range.from||r.selected>=this.range.to)&&(this.range=TS(r.options.length,r.selected,this.view.state.facet(zn).maxRenderedOptions),this.showOptions(r.options,e.id));let n=this.updateSelectedOption(r.selected);if(n){this.destroyInfo();let{completion:o}=r.options[r.selected],{info:s}=o;if(!s)return;let i=typeof s=="string"?document.createTextNode(s):s(o);if(!i)return;"then"in i?i.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,o)}).catch(a=>Kn(this.view.state,a,"completion info")):(this.addInfoPane(i,o),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,r){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:o,destroy:s}=e;n.appendChild(o),this.infoDestroy=s||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let r=null;for(let n=this.list.firstChild,o=this.range.from;n;n=n.nextSibling,o++)n.nodeName!="LI"||!n.id?o--:o==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),r=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby"));return r&&yX(this.list,r),r}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let r=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),o=e.getBoundingClientRect(),s=this.space;if(!s){let i=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:i.clientWidth,bottom:i.clientHeight}}return o.top>Math.min(s.bottom,r.bottom)-10||o.bottom<Math.max(s.top,r.top)+10?null:this.view.state.facet(zn).positionInfo(this.view,r,o,n,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,r,n){let o=document.createElement("ul");o.id=r,o.setAttribute("role","listbox"),o.setAttribute("aria-expanded","true"),o.setAttribute("aria-label",this.view.state.phrase("Completions")),o.addEventListener("mousedown",i=>{i.target==o&&i.preventDefault()});let s=null;for(let i=n.from;i<n.to;i++){let{completion:a,match:l}=e[i],{section:c}=a;if(c){let f=typeof c=="string"?c:c.name;if(f!=s&&(i>n.from||n.from==0))if(s=f,typeof c!="string"&&c.header)o.appendChild(c.header(c));else{let p=o.appendChild(document.createElement("completion-section"));p.textContent=f}}let d=o.appendChild(document.createElement("li"));d.id=r+"-"+i,d.setAttribute("role","option");let u=this.optionClass(a);u&&(d.className=u);for(let f of this.optionContent){let p=f(a,this.view.state,this.view,l);p&&d.appendChild(p)}}return n.from&&o.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&o.classList.add("cm-completionListIncompleteBottom"),o}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}};function xX(t,e){return r=>new RS(r,t,e)}function yX(t,e){let r=t.getBoundingClientRect(),n=e.getBoundingClientRect(),o=r.height/t.offsetHeight;n.top<r.top?t.scrollTop-=(r.top-n.top)/o:n.bottom>r.bottom&&(t.scrollTop+=(n.bottom-r.bottom)/o)}function VL(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function vX(t,e){let r=[],n=null,o=null,s=d=>{r.push(d);let{section:u}=d.completion;if(u){n||(n=[]);let f=typeof u=="string"?u:u.name;n.some(p=>p.name==f)||n.push(typeof u=="string"?{name:f}:u)}},i=e.facet(zn);for(let d of t)if(d.hasResult()){let u=d.result.getMatch;if(d.result.filter===!1)for(let f of d.result.options)s(new y0(f,d.source,u?u(f):[],1e9-r.length));else{let f=e.sliceDoc(d.from,d.to),p,h=i.filterStrict?new PS(f):new MS(f);for(let b of d.result.options)if(p=h.match(b.label)){let g=b.displayLabel?u?u(b,p.matched):[]:p.matched,x=p.score+(b.boost||0);if(s(new y0(b,d.source,g,x)),typeof b.section=="object"&&b.section.rank==="dynamic"){let{name:y}=b.section;o||(o=Object.create(null)),o[y]=Math.max(x,o[y]||-1e9)}}}}if(n){let d=Object.create(null),u=0,f=(p,h)=>(p.rank==="dynamic"&&h.rank==="dynamic"?o[h.name]-o[p.name]:0)||(typeof p.rank=="number"?p.rank:1e9)-(typeof h.rank=="number"?h.rank:1e9)||(p.name<h.name?-1:1);for(let p of n.sort(f))u-=1e5,d[p.name]=u;for(let p of r){let{section:h}=p.completion;h&&(p.score+=d[typeof h=="string"?h:h.name])}}let a=[],l=null,c=i.compareCompletions;for(let d of r.sort((u,f)=>f.score-u.score||c(u.completion,f.completion))){let u=d.completion;!l||l.label!=u.label||l.detail!=u.detail||l.type!=null&&u.type!=null&&l.type!=u.type||l.apply!=u.apply||l.boost!=u.boost?a.push(d):VL(d.completion)>VL(l)&&(a[a.length-1]=d),l=d.completion}return a}var DS=class t{constructor(e,r,n,o,s,i){this.options=e,this.attrs=r,this.tooltip=n,this.timestamp=o,this.selected=s,this.disabled=i}setSelected(e,r){return e==this.selected||e>=this.options.length?this:new t(this.options,jL(r,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,r,n,o,s,i){if(o&&!i&&e.some(c=>c.isPending))return o.setDisabled();let a=vX(e,r);if(!a.length)return o&&e.some(c=>c.isPending)?o.setDisabled():null;let l=r.facet(zn).selectOnOpen?0:-1;if(o&&o.selected!=l&&o.selected!=-1){let c=o.options[o.selected].completion;for(let d=0;d<a.length;d++)if(a[d].completion==c){l=d;break}}return new t(a,jL(n,l),{pos:e.reduce((c,d)=>d.hasResult()?Math.min(c,d.from):c,1e8),create:EX,above:s.aboveCursor},o?o.timestamp:Date.now(),l,!1)}map(e){return new t(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new t(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},OS=class t{constructor(e,r,n){this.active=e,this.id=r,this.open=n}static start(){return new t(CX,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:r}=e,n=r.facet(zn),s=(n.override||r.languageDataAt("autocomplete",Kc(r)).map(mX)).map(l=>(this.active.find(d=>d.source==l)||new Ea(l,this.active.some(d=>d.state!=0)?1:0)).update(e,n));s.length==this.active.length&&s.every((l,c)=>l==this.active[c])&&(s=this.active);let i=this.open,a=e.effects.some(l=>l.is(BS));i&&e.docChanged&&(i=i.map(e.changes)),e.selection||s.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!wX(s,this.active)||a?i=DS.build(s,r,this.id,i,n,a):i&&i.disabled&&!s.some(l=>l.isPending)&&(i=null),!i&&s.every(l=>!l.isPending)&&s.some(l=>l.hasResult())&&(s=s.map(l=>l.hasResult()?new Ea(l.source,0):l));for(let l of e.effects)l.is(LS)&&(i=i&&i.setSelected(l.value,this.id));return s==this.active&&i==this.open?this:new t(s,this.id,i)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?SX:NX}};function wX(t,e){if(t==e)return!0;for(let r=0,n=0;;){for(;r<t.length&&!t[r].hasResult();)r++;for(;n<e.length&&!e[n].hasResult();)n++;let o=r==t.length,s=n==e.length;if(o||s)return o==s;if(t[r++].result!=e[n++].result)return!1}}var SX={"aria-autocomplete":"list"},NX={};function jL(t,e){let r={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(r["aria-activedescendant"]=t+"-"+e),r}var CX=[];function qL(t,e){if(t.isUserEvent("input.complete")){let n=t.annotation(KL);if(n&&e.activateOnCompletion(n))return 12}let r=t.isUserEvent("input.type");return r&&e.activateOnTyping?5:r?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}var Ea=class t{constructor(e,r,n=!1){this.source=e,this.state=r,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(e,r){let n=qL(e,r),o=this;(n&8||n&16&&this.touches(e))&&(o=new t(o.source,0)),n&4&&o.state==0&&(o=new t(this.source,1)),o=o.updateFor(e,n);for(let s of e.effects)if(s.is(v0))o=new t(o.source,1,s.value);else if(s.is(Yp))o=new t(o.source,0);else if(s.is(BS))for(let i of s.value)i.source==o.source&&(o=i);return o}updateFor(e,r){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Kc(e.state))}},w0=class t extends Ea{constructor(e,r,n,o,s,i){super(e,3,r),this.limit=n,this.result=o,this.from=s,this.to=i}hasResult(){return!0}updateFor(e,r){var n;if(!(r&3))return this.map(e.changes);let o=this.result;o.map&&!e.changes.empty&&(o=o.map(o,e.changes));let s=e.changes.mapPos(this.from),i=e.changes.mapPos(this.to,1),a=Kc(e.state);if(a>i||!o||r&2&&(Kc(e.startState)==this.from||a<this.limit))return new Ea(this.source,r&4?1:0);let l=e.changes.mapPos(this.limit);return kX(o.validFor,e.state,s,i)?new t(this.source,this.explicit,l,o,s,i):o.update&&(o=o.update(o,s,i,new x0(e.state,a,!1)))?new t(this.source,this.explicit,l,o,o.from,(n=o.to)!==null&&n!==void 0?n:Kc(e.state)):new Ea(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new t(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Ea(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function kX(t,e,r,n){if(!t)return!1;let o=e.sliceDoc(r,n);return typeof t=="function"?t(o,r,n,e):GL(t,!0).test(o)}var BS=Qe.define({map(t,e){return t.map(r=>r.map(e))}}),Vo=Jr.define({create(){return OS.start()},update(t,e){return t.update(e)},provide:t=>[Pp.from(t,e=>e.tooltip),ve.contentAttributes.from(t,e=>e.attrs)]});function zS(t,e){let r=e.completion.apply||e.completion.label,n=t.state.field(Vo).active.find(o=>o.source==e.source);return n instanceof w0?(typeof r=="string"?t.dispatch({...hX(t.state,r,n.from,n.to),annotations:KL.of(e.completion)}):r(t,e.completion,n.from,n.to),!0):!1}var EX=xX(Vo,zS);function b0(t,e="option"){return r=>{let n=r.state.field(Vo,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<r.state.facet(zn).interactionDelay)return!1;let o=1,s;e=="page"&&(s=z1(r,n.open.tooltip))&&(o=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:i}=n.open.options,a=n.open.selected>-1?n.open.selected+o*(t?1:-1):t?0:i-1;return a<0?a=e=="page"?0:i-1:a>=i&&(a=e=="page"?i-1:0),r.dispatch({effects:LS.of(a)}),!0}}var TX=t=>{let e=t.state.field(Vo,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(zn).interactionDelay?!1:zS(t,e.open.options[e.open.selected])},IS=t=>t.state.field(Vo,!1)?(t.dispatch({effects:v0.of(!0)}),!0):!1,IX=t=>{let e=t.state.field(Vo,!1);return!e||!e.active.some(r=>r.state!=0)?!1:(t.dispatch({effects:Yp.of(null)}),!0)},_S=class{constructor(e,r){this.active=e,this.context=r,this.time=Date.now(),this.updates=[],this.done=void 0}},AX=50,MX=1e3,PX=Er.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(Vo).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(Vo),r=t.state.facet(zn);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Vo)==e)return;let n=t.transactions.some(s=>{let i=qL(s,r);return i&8||(s.selection||s.docChanged)&&!(i&3)});for(let s=0;s<this.running.length;s++){let i=this.running[s];if(n||i.context.abortOnDocChange&&t.docChanged||i.updates.length+t.transactions.length>AX&&Date.now()-i.time>MX){for(let a of i.context.abortListeners)try{a()}catch(l){Kn(this.view.state,l)}i.context.abortListeners=null,this.running.splice(s--,1)}else i.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(s=>s.effects.some(i=>i.is(v0)))&&(this.pendingStart=!0);let o=this.pendingStart?50:r.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(i=>i.active.source==s.source))?setTimeout(()=>this.startUpdate(),o):-1,this.composing!=0)for(let s of t.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(Vo);for(let r of e.active)r.isPending&&!this.running.some(n=>n.active.source==r.source)&&this.startQuery(r);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(zn).updateSyncTime))}startQuery(t){let{state:e}=this.view,r=Kc(e),n=new x0(e,r,t.explicit,this.view),o=new _S(t,n);this.running.push(o),Promise.resolve(t.source(n)).then(s=>{o.context.aborted||(o.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Yp.of(null)}),Kn(this.view.state,s)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(zn).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],r=this.view.state.facet(zn),n=this.view.state.field(Vo);for(let o=0;o<this.running.length;o++){let s=this.running[o];if(s.done===void 0)continue;if(this.running.splice(o--,1),s.done){let a=Kc(s.updates.length?s.updates[0].startState:this.view.state),l=Math.min(a,s.done.from+(s.active.explicit?0:1)),c=new w0(s.active.source,s.active.explicit,l,s.done,s.done.from,(t=s.done.to)!==null&&t!==void 0?t:a);for(let d of s.updates)c=c.update(d,r);if(c.hasResult()){e.push(c);continue}}let i=n.active.find(a=>a.source==s.active.source);if(i&&i.isPending)if(s.done==null){let a=new Ea(s.active.source,0);for(let l of s.updates)a=a.update(l,r);a.isPending||e.push(a)}else this.startQuery(i)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:BS.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(Vo,!1);if(e&&e.tooltip&&this.view.state.facet(zn).closeOnBlur){let r=e.open&&z1(this.view,e.open.tooltip);(!r||!r.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Yp.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:v0.of(!1)}),20),this.composing=0}}}),RX=typeof navigator=="object"&&/Win/.test(navigator.platform),DX=oi.highest(ve.domEventHandlers({keydown(t,e){let r=e.state.field(Vo,!1);if(!r||!r.open||r.open.disabled||r.open.selected<0||t.key.length>1||t.ctrlKey&&!(RX&&t.altKey)||t.metaKey)return!1;let n=r.open.options[r.open.selected],o=r.active.find(i=>i.source==n.source),s=n.completion.commitCharacters||o.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&zS(e,n),!1}})),OX=ve.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});var Xp={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Gc=Qe.define({map(t,e){let r=e.mapPos(t,-1,Un.TrackAfter);return r??void 0}}),$S=new class extends _s{};$S.startSide=1;$S.endSide=-1;var YL=Jr.define({create(){return Dt.empty},update(t,e){if(t=t.map(e.changes),e.selection){let r=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:n=>n>=r.from&&n<=r.to})}for(let r of e.effects)r.is(Gc)&&(t=t.update({add:[$S.range(r.value,r.value+1)]}));return t}});function XL(){return[LX,YL]}var AS="()[]{}<>\xAB\xBB\xBB\xAB\uFF3B\uFF3D\uFF5B\uFF5D";function JL(t){for(let e=0;e<AS.length;e+=2)if(AS.charCodeAt(e)==t)return AS.charAt(e+1);return up(t<128?t:t+1)}function ZL(t,e){return t.languageDataAt("closeBrackets",e)[0]||Xp}var _X=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),LX=ve.inputHandler.of((t,e,r,n)=>{if((_X?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let o=t.state.selection.main;if(n.length>2||n.length==2&&os(Gn(n,0))==1||e!=o.from||r!=o.to)return!1;let s=zX(t.state,n);return s?(t.dispatch(s),!0):!1}),BX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=ZL(t,t.selection.main.head).brackets||Xp.brackets,o=null,s=t.changeByRange(i=>{if(i.empty){let a=$X(t.doc,i.head);for(let l of n)if(l==a&&S0(t.doc,i.head)==JL(Gn(l,0)))return{changes:{from:i.head-l.length,to:i.head+l.length},range:ie.cursor(i.head-l.length)}}return{range:o=i}});return o||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!o},QL=[{key:"Backspace",run:BX}];function zX(t,e){let r=ZL(t,t.selection.main.head),n=r.brackets||Xp.brackets;for(let o of n){let s=JL(Gn(o,0));if(e==o)return s==o?VX(t,o,n.indexOf(o+o+o)>-1,r):FX(t,o,s,r.before||Xp.before);if(e==s&&eB(t,t.selection.main.from))return HX(t,o,s)}return null}function eB(t,e){let r=!1;return t.field(YL).between(0,t.doc.length,n=>{n==e&&(r=!0)}),r}function S0(t,e){let r=t.sliceString(e,e+2);return r.slice(0,os(Gn(r,0)))}function $X(t,e){let r=t.sliceString(e-2,e);return os(Gn(r,0))==r.length?r:r.slice(1)}function FX(t,e,r,n){let o=null,s=t.changeByRange(i=>{if(!i.empty)return{changes:[{insert:e,from:i.from},{insert:r,from:i.to}],effects:Gc.of(i.to+e.length),range:ie.range(i.anchor+e.length,i.head+e.length)};let a=S0(t.doc,i.head);return!a||/\s/.test(a)||n.indexOf(a)>-1?{changes:{insert:e+r,from:i.head},effects:Gc.of(i.head+e.length),range:ie.cursor(i.head+e.length)}:{range:o=i}});return o?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function HX(t,e,r){let n=null,o=t.changeByRange(s=>s.empty&&S0(t.doc,s.head)==r?{changes:{from:s.head,to:s.head+r.length,insert:r},range:ie.cursor(s.head+r.length)}:n={range:s});return n?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function VX(t,e,r,n){let o=n.stringPrefixes||Xp.stringPrefixes,s=null,i=t.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:Gc.of(a.to+e.length),range:ie.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=S0(t.doc,l),d;if(c==e){if(WL(t,l))return{changes:{insert:e+e,from:l},effects:Gc.of(l+e.length),range:ie.cursor(l+e.length)};if(eB(t,l)){let f=r&&t.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+f.length,insert:f},range:ie.cursor(l+f.length)}}}else{if(r&&t.sliceDoc(l-2*e.length,l)==e+e&&(d=UL(t,l-2*e.length,o))>-1&&WL(t,d))return{changes:{insert:e+e+e+e,from:l},effects:Gc.of(l+e.length),range:ie.cursor(l+e.length)};if(t.charCategorizer(l)(c)!=cr.Word&&UL(t,l,o)>-1&&!jX(t,l,e,o))return{changes:{insert:e+e,from:l},effects:Gc.of(l+e.length),range:ie.cursor(l+e.length)}}return{range:s=a}});return s?null:t.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function WL(t,e){let r=Bn(t).resolveInner(e+1);return r.parent&&r.from==e}function jX(t,e,r,n){let o=Bn(t).resolveInner(e,-1),s=n.reduce((i,a)=>Math.max(i,a.length),0);for(let i=0;i<5;i++){let a=t.sliceDoc(o.from,Math.min(o.to,o.from+r.length+s)),l=a.indexOf(r);if(!l||l>-1&&n.indexOf(a.slice(0,l))>-1){let d=o.firstChild;for(;d&&d.from==o.from&&d.to-d.from>r.length+l;){if(t.sliceDoc(d.to-r.length,d.to)==r)return!1;d=d.firstChild}return!0}let c=o.to==e&&o.parent;if(!c)break;o=c}return!1}function UL(t,e,r){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=cr.Word)return e;for(let o of r){let s=e-o.length;if(t.sliceDoc(s,e)==o&&n(t.sliceDoc(s-1,s))!=cr.Word)return s}return-1}function N0(t={}){return[DX,Vo,zn.of(t),PX,WX,OX]}var FS=[{key:"Ctrl-Space",run:IS},{mac:"Alt-`",run:IS},{mac:"Alt-i",run:IS},{key:"Escape",run:IX},{key:"ArrowDown",run:b0(!0)},{key:"ArrowUp",run:b0(!1)},{key:"PageDown",run:b0(!0,"page")},{key:"PageUp",run:b0(!1,"page")},{key:"Enter",run:TX}],WX=oi.highest(ka.computeN([zn],t=>t.facet(zn).defaultKeymap?[FS]:[]));var k0=class{constructor(e,r,n){this.from=e,this.to=r,this.diagnostic=n}},qc=class t{constructor(e,r,n){this.diagnostics=e,this.panel=r,this.selected=n}static init(e,r,n){let o=n.facet(Jp).markerFilter;o&&(e=o(e,n));let s=e.slice().sort((p,h)=>p.from-h.from||p.to-h.to),i=new ns,a=[],l=0,c=n.doc.iter(),d=0,u=n.doc.length;for(let p=0;;){let h=p==s.length?null:s[p];if(!h&&!a.length)break;let b,g;if(a.length)b=l,g=a.reduce((m,v)=>Math.min(m,v.to),h&&h.from>b?h.from:1e8);else{if(b=h.from,b>u)break;g=h.to,a.push(h),p++}for(;p<s.length;){let m=s[p];if(m.from==b&&(m.to>m.from||m.to==b))a.push(m),p++,g=Math.min(m.to,g);else{g=Math.min(m.from,g);break}}g=Math.min(g,u);let x=!1;if(a.some(m=>m.from==b&&(m.to==g||g==u))&&(x=b==g,!x&&g-b<10)){let m=b-(d+c.value.length);m>0&&(c.next(m),d=b);for(let v=b;;){if(v>=g){x=!0;break}if(!c.lineBreak&&d+c.value.length>v)break;v=d+c.value.length,d+=c.value.length,c.next()}}let y=tJ(a);if(x)i.add(b,b,Fe.widget({widget:new HS(y),diagnostics:a.slice()}));else{let m=a.reduce((v,S)=>S.markClass?v+" "+S.markClass:v,"");i.add(b,g,Fe.mark({class:"cm-lintRange cm-lintRange-"+y+m,diagnostics:a.slice(),inclusiveEnd:a.some(v=>v.to>g)}))}if(l=g,l==u)break;for(let m=0;m<a.length;m++)a[m].to<=l&&a.splice(m--,1)}let f=i.finish();return new t(f,r,El(f))}};function El(t,e=null,r=0){let n=null;return t.between(r,1e9,(o,s,{spec:i})=>{if(!(e&&i.diagnostics.indexOf(e)<0))if(!n)n=new k0(o,s,e||i.diagnostics[0]);else{if(i.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new k0(n.from,s,n.diagnostic)}}),n}function UX(t,e){let r=e.pos,n=e.end||r,o=t.state.facet(Jp).hideOn(t,r,n);if(o!=null)return o;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(i=>i.is(nB))||t.changes.touchesRange(s.from,Math.max(s.to,n)))}function GX(t,e){return t.field(cs,!1)?e:e.concat(Qe.appendConfig.of(rJ))}var nB=Qe.define(),VS=Qe.define(),oB=Qe.define(),cs=Jr.define({create(){return new qc(Fe.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let r=t.diagnostics.map(e.changes),n=null,o=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);n=El(r,t.selected.diagnostic,s)||El(r,null,s)}!r.size&&o&&e.state.facet(Jp).autoPanel&&(o=null),t=new qc(r,o,n)}for(let r of e.effects)if(r.is(nB)){let n=e.state.facet(Jp).autoPanel?r.value.length?Zp.open:null:t.panel;t=qc.init(r.value,n,e.state)}else r.is(VS)?t=new qc(t.diagnostics,r.value?Zp.open:null,t.selected):r.is(oB)&&(t=new qc(t.diagnostics,t.panel,r.value));return t},provide:t=>[Bc.from(t,e=>e.panel),ve.decorations.from(t,e=>e.diagnostics)]});var KX=Fe.mark({class:"cm-lintRange cm-lintRange-active"});function qX(t,e,r){let{diagnostics:n}=t.state.field(cs),o,s=-1,i=-1;n.between(e-(r<0?1:0),e+(r>0?1:0),(l,c,{spec:d})=>{if(e>=l&&e<=c&&(l==c||(e>l||r>0)&&(e<c||r<0)))return o=d.diagnostics,s=l,i=c,!1});let a=t.state.facet(Jp).tooltipFilter;return o&&a&&(o=a(o,t.state)),o?{pos:s,end:i,above:t.state.doc.lineAt(s).to<i,create(){return{dom:YX(t,o)}}}:null}function YX(t,e){return Wt("ul",{class:"cm-tooltip-lint"},e.map(r=>aB(t,r,!1)))}var XX=t=>{let e=t.state.field(cs,!1);(!e||!e.panel)&&t.dispatch({effects:GX(t.state,[VS.of(!0)])});let r=Rp(t,Zp.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},tB=t=>{let e=t.state.field(cs,!1);return!e||!e.panel?!1:(t.dispatch({effects:VS.of(!1)}),!0)},JX=t=>{let e=t.state.field(cs,!1);if(!e)return!1;let r=t.state.selection.main,n=El(e.diagnostics,null,r.to+1);return!n&&(n=El(e.diagnostics,null,0),!n||n.from==r.from&&n.to==r.to)?!1:(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)};var sB=[{key:"Mod-Shift-m",run:XX,preventDefault:!0},{key:"F8",run:JX}];var Jp=Ce.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...ao(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:rB,tooltipFilter:rB,needsRefresh:(e,r)=>e?r?n=>e(n)||r(n):e:r,hideOn:(e,r)=>e?r?(n,o,s)=>e(n,o,s)||r(n,o,s):e:r,autoPanel:(e,r)=>e||r})}}});function rB(t,e){return t?e?(r,n)=>e(t(r,n),n):t:e}function iB(t){let e=[];if(t)e:for(let{name:r}of t){for(let n=0;n<r.length;n++){let o=r[n];if(/[a-zA-Z]/.test(o)&&!e.some(s=>s.toLowerCase()==o.toLowerCase())){e.push(o);continue e}}e.push("")}return e}function aB(t,e,r){var n;let o=r?iB(e.actions):[];return Wt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Wt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((s,i)=>{let a=!1,l=p=>{if(p.preventDefault(),a)return;a=!0;let h=El(t.state.field(cs).diagnostics,e);h&&s.apply(t,h.from,h.to)},{name:c}=s,d=o[i]?c.indexOf(o[i]):-1,u=d<0?c:[c.slice(0,d),Wt("u",c.slice(d,d+1)),c.slice(d+1)],f=s.markClass?" "+s.markClass:"";return Wt("button",{type:"button",class:"cm-diagnosticAction"+f,onclick:l,onmousedown:l,"aria-label":` Action: ${c}${d<0?"":` (access key "${o[i]})"`}.`},u)}),e.source&&Wt("div",{class:"cm-diagnosticSource"},e.source))}var HS=class extends Io{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Wt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},E0=class{constructor(e,r){this.diagnostic=r,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=aB(e,r,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Zp=class t{constructor(e){this.view=e,this.items=[];let r=o=>{if(!(o.ctrlKey||o.altKey||o.metaKey)){if(o.keyCode==27)tB(this.view),this.view.focus();else if(o.keyCode==38||o.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(o.keyCode==40||o.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(o.keyCode==36)this.moveSelection(0);else if(o.keyCode==35)this.moveSelection(this.items.length-1);else if(o.keyCode==13)this.view.focus();else if(o.keyCode>=65&&o.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],i=iB(s.actions);for(let a=0;a<i.length;a++)if(i[a].toUpperCase().charCodeAt(0)==o.keyCode){let l=El(this.view.state.field(cs).diagnostics,s);l&&s.actions[a].apply(e,l.from,l.to)}}else return;o.preventDefault()}},n=o=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(o.target)&&this.moveSelection(s)};this.list=Wt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:r,onclick:n}),this.dom=Wt("div",{class:"cm-panel-lint"},this.list,Wt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>tB(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(cs).selected;if(!e)return-1;for(let r=0;r<this.items.length;r++)if(this.items[r].diagnostic==e.diagnostic)return r;return-1}update(){let{diagnostics:e,selected:r}=this.view.state.field(cs),n=0,o=!1,s=null,i=new Set;for(e.between(0,this.view.state.doc.length,(a,l,{spec:c})=>{for(let d of c.diagnostics){if(i.has(d))continue;i.add(d);let u=-1,f;for(let p=n;p<this.items.length;p++)if(this.items[p].diagnostic==d){u=p;break}u<0?(f=new E0(this.view,d),this.items.splice(n,0,f),o=!0):(f=this.items[u],u>n&&(this.items.splice(n,u-n),o=!0)),r&&f.diagnostic==r.diagnostic?f.dom.hasAttribute("aria-selected")||(f.dom.setAttribute("aria-selected","true"),s=f):f.dom.hasAttribute("aria-selected")&&f.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)o=!0,this.items.pop();this.items.length==0&&(this.items.push(new E0(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),o=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let c=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/c:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),o&&this.sync()}sync(){let e=this.list.firstChild;function r(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)r();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)r()}moveSelection(e){if(this.selectedIndex<0)return;let r=this.view.state.field(cs),n=El(r.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:oB.of(n)})}static open(e){return new t(e)}};function ZX(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function C0(t){return ZX(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var QX=ve.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:C0("#d11")},".cm-lintRange-warning":{backgroundImage:C0("orange")},".cm-lintRange-info":{backgroundImage:C0("#999")},".cm-lintRange-hint":{backgroundImage:C0("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function eJ(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function tJ(t){let e="hint",r=1;for(let n of t){let o=eJ(n.severity);o>r&&(r=o,e=n.severity)}return e}var rJ=[cs,ve.decorations.compute([cs],t=>{let{selected:e,panel:r}=t.field(cs);return!e||!r||e.from==e.to?Fe.none:Fe.set([KX.range(e.from,e.to)])}),q_(qX,{hideOn:UX}),QX];var jS=function(e){e===void 0&&(e={});var{crosshairCursor:r=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(QL)),e.defaultKeymap!==!1&&(n=n.concat(EL)),e.searchKeymap!==!1&&(n=n.concat(zL)),e.historyKeymap!==!1&&(n=n.concat(Z3)),e.foldKeymap!==!1&&(n=n.concat(T3)),e.completionKeymap!==!1&&(n=n.concat(FS)),e.lintKeymap!==!1&&(n=n.concat(sB));var o=[];return e.lineNumbers!==!1&&o.push(e3()),e.highlightActiveLineGutter!==!1&&o.push(t3()),e.highlightSpecialChars!==!1&&o.push(j_()),e.history!==!1&&o.push(q3()),e.foldGutter!==!1&&o.push(M3()),e.drawSelection!==!1&&o.push($_()),e.dropCursor!==!1&&o.push(V_()),e.allowMultipleSelections!==!1&&o.push(jt.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&o.push(S3()),e.syntaxHighlighting!==!1&&o.push(Zb(R3,{fallback:!0})),e.bracketMatching!==!1&&o.push(L3()),e.closeBrackets!==!1&&o.push(XL()),e.autocompletion!==!1&&o.push(N0()),e.rectangularSelection!==!1&&o.push(G_()),r!==!1&&o.push(K_()),e.highlightActiveLine!==!1&&o.push(W_()),e.highlightSelectionMatches!==!1&&o.push(DL()),e.tabSize&&typeof e.tabSize=="number"&&o.push(Wc.of(" ".repeat(e.tabSize))),o.concat([ka.of(n.flat())]).filter(Boolean)};var nJ="#e5c07b",lB="#e06c75",oJ="#56b6c2",sJ="#ffffff",T0="#abb2bf",US="#7d8799",iJ="#61afef",aJ="#98c379",cB="#d19a66",lJ="#c678dd",cJ="#21252b",dB="#2c313a",uB="#282c34",WS="#353a42",dJ="#3E4451",fB="#528bff";var uJ=ve.theme({"&":{color:T0,backgroundColor:uB},".cm-content":{caretColor:fB},".cm-cursor, .cm-dropCursor":{borderLeftColor:fB},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:dJ},".cm-panels":{backgroundColor:cJ,color:T0},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:uB,color:US,border:"none"},".cm-activeLineGutter":{backgroundColor:dB},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:WS},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:WS,borderBottomColor:WS},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:dB,color:T0}}},{dark:!0}),fJ=Au.define([{tag:re.keyword,color:lJ},{tag:[re.name,re.deleted,re.character,re.propertyName,re.macroName],color:lB},{tag:[re.function(re.variableName),re.labelName],color:iJ},{tag:[re.color,re.constant(re.name),re.standard(re.name)],color:cB},{tag:[re.definition(re.name),re.separator],color:T0},{tag:[re.typeName,re.className,re.number,re.changed,re.annotation,re.modifier,re.self,re.namespace],color:nJ},{tag:[re.operator,re.operatorKeyword,re.url,re.escape,re.regexp,re.link,re.special(re.string)],color:oJ},{tag:[re.meta,re.comment],color:US},{tag:re.strong,fontWeight:"bold"},{tag:re.emphasis,fontStyle:"italic"},{tag:re.strikethrough,textDecoration:"line-through"},{tag:re.link,color:US,textDecoration:"underline"},{tag:re.heading,fontWeight:"bold",color:lB},{tag:[re.atom,re.bool,re.special(re.variableName)],color:cB},{tag:[re.processingInstruction,re.string,re.inserted],color:aJ},{tag:re.invalid,color:sJ}]),pB=[uJ,Zb(fJ)];var hB=ve.theme({"&":{backgroundColor:"#fff"}},{dark:!1});var mB=function(e){e===void 0&&(e={});var{indentWithTab:r=!0,editable:n=!0,readOnly:o=!1,theme:s="light",placeholder:i="",basicSetup:a=!0}=e,l=[];switch(r&&l.unshift(ka.of([TL])),a&&(typeof a=="boolean"?l.unshift(jS()):l.unshift(jS(a))),i&&l.unshift(U_(i)),s){case"light":l.push(hB);break;case"dark":l.push(pB);break;case"none":break;default:l.push(s);break}return n===!1&&l.push(ve.editable.of(!1)),o&&l.push(jt.readOnly.of(!0)),[...l]};var gB=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)});var I0=class{constructor(e,r){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=r,this.timeoutMS=r,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(r=>{try{r()}catch(n){console.error("TimeoutLatch callback error:",n)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}},A0=class{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}},GS=null,bB=()=>typeof window>"u"?new A0:(GS||(GS=new A0),GS);var xB=io.define(),pJ=200,hJ=[];function yB(t){var{value:e,selection:r,onChange:n,onStatistics:o,onCreateEditor:s,onUpdate:i,extensions:a=hJ,autoFocus:l,theme:c="light",height:d=null,minHeight:u=null,maxHeight:f=null,width:p=null,minWidth:h=null,maxWidth:b=null,placeholder:g="",editable:x=!0,readOnly:y=!1,indentWithTab:m=!0,basicSetup:v=!0,root:S,initialState:w}=t,[C,A]=(0,jo.useState)(),[k,M]=(0,jo.useState)(),[T,E]=(0,jo.useState)(),P=(0,jo.useState)(()=>({current:null}))[0],N=(0,jo.useState)(()=>({current:null}))[0],D=ve.theme({"&":{height:d,minHeight:u,maxHeight:f,width:p,minWidth:h,maxWidth:b},"& .cm-scroller":{height:"100% !important"}}),R=ve.updateListener.of(L=>{if(L.docChanged&&typeof n=="function"&&!L.transactions.some($=>$.annotation(xB))){P.current?P.current.reset():(P.current=new I0(()=>{if(N.current){var $=N.current;N.current=null,$()}P.current=null},pJ),bB().add(P.current));var H=L.state.doc,j=H.toString();n(j,L)}o&&o(gB(L))}),O=mB({theme:c,editable:x,readOnly:y,placeholder:g,indentWithTab:m,basicSetup:v}),B=[R,D,...O];return i&&typeof i=="function"&&B.push(ve.updateListener.of(i)),B=B.concat(a),(0,jo.useLayoutEffect)(()=>{if(C&&!T){var L={doc:e,selection:r,extensions:B},H=w?jt.fromJSON(w.json,L,w.fields):jt.create(L);if(E(H),!k){var j=new ve({state:H,parent:C,root:S});M(j),s&&s(j,H)}}return()=>{k&&(E(void 0),M(void 0))}},[C,T]),(0,jo.useEffect)(()=>{t.container&&A(t.container)},[t.container]),(0,jo.useEffect)(()=>()=>{k&&(k.destroy(),M(void 0)),P.current&&(P.current.cancel(),P.current=null)},[k]),(0,jo.useEffect)(()=>{l&&k&&k.focus()},[l,k]),(0,jo.useEffect)(()=>{k&&k.dispatch({effects:Qe.reconfigure.of(B)})},[c,a,d,u,f,p,h,b,g,x,y,m,v,n,i]),(0,jo.useEffect)(()=>{if(e!==void 0){var L=k?k.state.doc.toString():"";if(k&&e!==L){var H=P.current&&!P.current.isDone,j=()=>{k&&e!==k.state.doc.toString()&&k.dispatch({changes:{from:0,to:k.state.doc.toString().length,insert:e||""},annotations:[xB.of(!0)]})};H?N.current=j:j()}}},[e,k]),{state:T,setState:E,view:k,setView:M,container:C,setContainer:A}}var SB=require("react/jsx-runtime"),mJ=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],NB=(0,Tl.forwardRef)((t,e)=>{var{className:r,value:n="",selection:o,extensions:s=[],onChange:i,onStatistics:a,onCreateEditor:l,onUpdate:c,autoFocus:d,theme:u="light",height:f,minHeight:p,maxHeight:h,width:b,minWidth:g,maxWidth:x,basicSetup:y,placeholder:m,indentWithTab:v,editable:S,readOnly:w,root:C,initialState:A}=t,k=(0,wB.default)(t,mJ),M=(0,Tl.useRef)(null),{state:T,view:E,container:P,setContainer:N}=yB({root:C,value:n,autoFocus:d,theme:u,height:f,minHeight:p,maxHeight:h,width:b,minWidth:g,maxWidth:x,basicSetup:y,placeholder:m,indentWithTab:v,editable:S,readOnly:w,selection:o,onChange:i,onStatistics:a,onCreateEditor:l,onUpdate:c,extensions:s,initialState:A});(0,Tl.useImperativeHandle)(e,()=>({editor:M.current,state:T,view:E}),[M,P,T,E]);var D=(0,Tl.useCallback)(O=>{M.current=O,N(O)},[N]);if(typeof n!="string")throw new Error("value must be typeof string but got "+typeof n);var R=typeof u=="string"?"cm-theme-"+u:"cm-theme";return(0,SB.jsx)("div",(0,vB.default)({ref:D,className:""+R+(r?" "+r:"")},k))});NB.displayName="CodeMirror";var CB=NB;var kB=require("zustand"),EB=require("zustand/middleware"),TB=(0,kB.create)()((0,EB.persist)(t=>({commandHistory:[],addCommand:e=>t(r=>{let n=e.trim();return!n||r.commandHistory[r.commandHistory.length-1]===n?r:{commandHistory:[...r.commandHistory,n].slice(-50)}}),clearHistory:()=>t({commandHistory:[]})}),{name:"decido-dataway-history-v1"}));var Or=require("react/jsx-runtime"),gJ={},IB=({onExecute:t,onClear:e,activeResource:r,activeConnector:n,isLoading:o,schemaColumns:s=[]})=>{let[i,a]=(0,Il.useState)(""),[l,c]=(0,Il.useState)(!1),[d,u]=(0,Il.useState)(""),[f,p]=(0,Il.useState)(!1),{commandHistory:h,addCommand:b}=TB(),[g,x]=(0,Il.useState)(-1),y=()=>{i.trim()?(b(i),x(-1),t(i)):e()},m=()=>{a(""),x(-1),e()},v=(0,Il.useCallback)(C=>{if(C.key==="ArrowUp"&&(C.ctrlKey||C.metaKey)){if(C.preventDefault(),h.length>0){let A=g===-1?h.length-1:Math.max(0,g-1);x(A),a(h[A])}}else if(C.key==="ArrowDown"&&(C.ctrlKey||C.metaKey)&&(C.preventDefault(),g!==-1)){let A=g+1;A>=h.length?(x(-1),a("")):(x(A),a(h[A]))}},[h,g]),S=async()=>{if(!(!d.trim()||!r)){p(!0);try{let C=gJ.env?.VITE_API_BASE_URL||"http://localhost:3001",A=await fetch(`${C}/api/dataway/copilot`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:d,connectorId:n,resource:r})});if(!A.ok)throw new Error("Fall\xF3 la generaci\xF3n IA");let k=await A.json();a(k.script),c(!1),u(""),Bt.success("M-Script Generado por Inteligencia Artificial")}catch(C){Bt.error("Error del Copilot",{description:C.message})}finally{p(!1)}}},w=[ka.of([{key:"Enter",run:()=>(y(),!0),shift:()=>!1}]),N0({override:[C=>{let A=C.matchBefore(/["\w.]+/);if(!A||A.from===A.to&&!C.explicit)return null;let k=[{label:"Table.SelectRows",type:"function",info:"Table.SelectRows(table, column, value)"},{label:"Table.AddColumn",type:"function",info:"Table.AddColumn(table, newColumn, value)"},{label:"Table.RenameColumns",type:"function",info:'Table.RenameColumns(table, {{"old", "new"}})'},{label:"Table.SelectColumns",type:"function",info:'Table.SelectColumns(table, {"col1", "col2"})'},{label:"Table.RemoveColumns",type:"function",info:'Table.RemoveColumns(table, {"col1", "col2"})'},{label:"Table.FirstN",type:"function",info:"Table.FirstN(table, count)"},{label:"Table.LastN",type:"function",info:"Table.LastN(table, count)"},{label:"Table.Distinct",type:"function",info:"Table.Distinct(table)"},{label:"Table.Sort",type:"function",info:'Table.Sort(table, {{"col", Order.Descending}})'},{label:"Order.Ascending",type:"variable"},{label:"Order.Descending",type:"variable"},{label:"Source",type:"variable",info:"The active resource dataset"}],M=s.map(T=>({label:`"${T}"`,type:"property",info:`Column in ${r}`}));return{from:A.from,options:[...k,...M]}}]})];return(0,Or.jsxs)("div",{className:"w-full bg-[var(--bg-primary)] border-b border-[var(--border-color)] px-6 py-3 flex items-center gap-3 shadow-sm z-30",onKeyDown:v,children:[(0,Or.jsx)("div",{className:"bg-[var(--brand-primary)]/10 p-1.5 rounded-lg text-[var(--brand-primary)]",children:(0,Or.jsx)(ds.FunctionSquare,{className:"w-5 h-5"})}),l?(0,Or.jsxs)("div",{className:"flex-1 relative group border border-purple-400 ring-2 ring-purple-400/20 rounded-xl overflow-hidden shadow-inner bg-purple-50/50 flex items-center transition-all",children:[(0,Or.jsx)("input",{type:"text",autoFocus:!0,value:d,onChange:C=>u(C.target.value),placeholder:"Dile a Gemini qu\xE9 necesitas... (Ej: filtra los urgentes y ordena por fecha)",className:"w-full bg-transparent border-none outline-none py-2.5 px-4 text-sm font-medium text-purple-900 placeholder:text-purple-400/70",onKeyDown:C=>{C.key==="Enter"&&S(),C.key==="Escape"&&c(!1)},disabled:f}),(0,Or.jsx)("button",{onClick:()=>c(!1),className:"pr-3 text-purple-400 hover:text-purple-600 transition-colors",children:(0,Or.jsx)(ds.XCircle,{className:"w-4 h-4"})})]}):(0,Or.jsxs)("div",{className:"flex-1 relative group border border-[var(--border-color)] rounded-xl overflow-hidden shadow-inner focus-within:ring-2 focus-within:ring-[var(--brand-primary)]/30 focus-within:border-[var(--brand-primary)] transition-all bg-[var(--bg-surface)] flex items-center",children:[(0,Or.jsx)("div",{className:"flex-1",children:(0,Or.jsx)(CB,{value:i,height:"auto",placeholder:r?`Ej: Table.SelectRows(Source, "${r}_id", "==", "10") (Ctrl+\u2191 Hist\xF3rico)`:"Selecciona un recurso para escribir una f\xF3rmula M-Script...",extensions:w,onChange:C=>a(C),editable:!!r&&!o,basicSetup:{lineNumbers:!1,foldGutter:!1,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!1,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightActiveLine:!1,highlightActiveLineGutter:!1},className:"text-sm font-mono text-[var(--text-primary)] w-full [&_.cm-editor]:bg-transparent [&_.cm-scroller]:p-2.5",theme:"none"})}),i&&(0,Or.jsx)("button",{onClick:m,className:"absolute right-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)] hover:text-red-500 transition-colors bg-[var(--bg-surface)] pl-2 h-full flex items-center",title:"Limpiar F\xF3rmula",style:{zIndex:10},children:(0,Or.jsx)(ds.XCircle,{className:"w-4 h-4"})})]}),(0,Or.jsx)("button",{onClick:()=>l?S():c(!0),disabled:!r||o||f,className:`flex items-center justify-center w-10 h-10 rounded-xl transition-all ${l?"bg-gradient-to-r from-purple-500 to-indigo-600 text-white shadow-md shadow-purple-500/20":"bg-[var(--bg-surface)] text-[var(--text-secondary)] hover:text-purple-600 hover:bg-purple-50"}`,title:"AI Copilot (M-Script Maker)",children:f?(0,Or.jsx)(ds.Loader2,{className:"w-5 h-5 animate-spin"}):(0,Or.jsx)(ds.Sparkles,{className:"w-5 h-5"})}),h.length>0&&(0,Or.jsxs)("div",{className:"text-[10px] text-[var(--text-secondary)] font-medium flex items-center gap-1 cursor-help relative",title:"Consultas en el historial (Ctrl+\u2191 / Ctrl+\u2193)",children:[(0,Or.jsx)(ds.History,{className:"w-3 h-3 opacity-60"}),(0,Or.jsx)("span",{className:"opacity-60",children:h.length})]}),(0,Or.jsxs)("button",{onClick:y,disabled:!r||o||!i.trim(),className:"flex items-center gap-2 bg-[var(--brand-primary)] hover:bg-[var(--brand-primary-hover)] text-white px-5 py-2.5 rounded-xl text-sm font-bold shadow-md shadow-[var(--brand-primary)]/20 transition-all active:scale-95 disabled:opacity-50 disabled:grayscale ml-2",children:[o?(0,Or.jsx)("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):(0,Or.jsx)(ds.Play,{className:"w-4 h-4 fill-current"}),(0,Or.jsx)("span",{children:"Ejecutar"})]})]})};var M0=Re(require("react")),Ot=require("recharts"),Ta=require("lucide-react"),st=require("react/jsx-runtime"),AB=({data:t,columns:e})=>{let[r,n]=M0.default.useState("bar"),{dimension:o,metrics:s}=(0,M0.useMemo)(()=>{if(t.length===0||e.length===0)return{dimension:"",metrics:[]};let a=e.find(c=>{let d=t.find(u=>u[c]!==null&&u[c]!==void 0)?.[c];return d!==void 0&&(typeof d=="string"||isNaN(Number(d)))});a=a||e[0];let l=e.filter(c=>{if(c===a)return!1;let d=t.find(u=>u[c]!==null&&u[c]!==void 0)?.[c];return d!==void 0&&!isNaN(Number(d))&&String(d).trim()!==""});return{dimension:a,metrics:l}},[t,e]);if(t.length===0)return(0,st.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center opacity-40",children:[(0,st.jsx)(Ta.Activity,{className:"w-16 h-16 mb-4"}),(0,st.jsx)("h2",{className:"text-xl font-bold",children:"Sin Datos para Graficar"}),(0,st.jsx)("p",{className:"text-sm",children:"La tabla procesada est\xE1 vac\xEDa."})]});if(s.length===0)return(0,st.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center opacity-60",children:[(0,st.jsx)(Ta.BarChart3,{className:"w-16 h-16 mb-4"}),(0,st.jsx)("h2",{className:"text-lg font-bold",children:"Sin Columnas Num\xE9ricas"}),(0,st.jsx)("p",{className:"text-sm text-center max-w-sm mt-2",children:"El motor de gr\xE1ficos necesita al menos una m\xE9trica num\xE9rica para generar la visualizaci\xF3n. (Usa M-Script para castear o generar n\xFAmeros)."})]});let i=["#6366f1","#ec4899","#14b8a6","#f59e0b","#8b5cf6","#10b981"];return(0,st.jsxs)("div",{className:"flex-1 flex flex-col h-full bg-[var(--bg-primary)] p-6",children:[(0,st.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,st.jsxs)("div",{children:[(0,st.jsx)("h2",{className:"text-lg font-bold text-[var(--text-primary)]",children:"Analytics Auto-Dashboard"}),(0,st.jsxs)("p",{className:"text-[11px] font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:["Dimensi\xF3n: ",(0,st.jsx)("span",{className:"text-[var(--brand-primary)]",children:o})," | M\xE9tricas: ",s.join(", ")]})]}),(0,st.jsxs)("div",{className:"flex bg-[var(--bg-elevated)] p-1 rounded-lg border border-[var(--border-color)]",children:[(0,st.jsx)("button",{onClick:()=>n("bar"),className:`p-2 rounded-md transition-all ${r==="bar"?"bg-white shadow-sm text-[var(--brand-primary)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-surface)]"}`,title:"Gr\xE1fico de Barras",children:(0,st.jsx)(Ta.BarChart3,{className:"w-4 h-4"})}),(0,st.jsx)("button",{onClick:()=>n("line"),className:`p-2 rounded-md transition-all ${r==="line"?"bg-white shadow-sm text-[var(--brand-primary)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-surface)]"}`,title:"Gr\xE1fico de L\xEDneas",children:(0,st.jsx)(Ta.LineChart,{className:"w-4 h-4"})}),(0,st.jsx)("button",{onClick:()=>n("area"),className:`p-2 rounded-md transition-all ${r==="area"?"bg-white shadow-sm text-[var(--brand-primary)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-surface)]"}`,title:"Gr\xE1fico de \xC1rea",children:(0,st.jsx)(Ta.PieChart,{className:"w-4 h-4"})})]})]}),(0,st.jsx)("div",{className:"flex-1 min-h-0 bg-white border border-[var(--border-color)] rounded-xl p-4 shadow-inner",children:(0,st.jsx)(Ot.ResponsiveContainer,{width:"100%",height:"100%",children:r==="bar"?(0,st.jsxs)(Ot.BarChart,{data:t,margin:{top:20,right:30,left:20,bottom:20},children:[(0,st.jsx)(Ot.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"#e2e8f0"}),(0,st.jsx)(Ot.XAxis,{dataKey:o,tick:{fontSize:12,fill:"#64748b"},axisLine:{stroke:"#cbd5e1"},tickLine:!1}),(0,st.jsx)(Ot.YAxis,{tick:{fontSize:12,fill:"#64748b"},axisLine:!1,tickLine:!1}),(0,st.jsx)(Ot.Tooltip,{contentStyle:{borderRadius:"8px",border:"none",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"},cursor:{fill:"#f1f5f9"}}),(0,st.jsx)(Ot.Legend,{wrapperStyle:{paddingTop:"20px"}}),s.map((a,l)=>(0,st.jsx)(Ot.Bar,{dataKey:a,fill:i[l%i.length],radius:[4,4,0,0]},a))]}):r==="line"?(0,st.jsxs)(Ot.LineChart,{data:t,margin:{top:20,right:30,left:20,bottom:20},children:[(0,st.jsx)(Ot.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"#e2e8f0"}),(0,st.jsx)(Ot.XAxis,{dataKey:o,tick:{fontSize:12,fill:"#64748b"},axisLine:{stroke:"#cbd5e1"},tickLine:!1}),(0,st.jsx)(Ot.YAxis,{tick:{fontSize:12,fill:"#64748b"},axisLine:!1,tickLine:!1}),(0,st.jsx)(Ot.Tooltip,{contentStyle:{borderRadius:"8px",border:"none",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"}}),(0,st.jsx)(Ot.Legend,{wrapperStyle:{paddingTop:"20px"}}),s.map((a,l)=>(0,st.jsx)(Ot.Line,{type:"monotone",dataKey:a,stroke:i[l%i.length],strokeWidth:3,dot:{r:4},activeDot:{r:6}},a))]}):(0,st.jsxs)(Ot.AreaChart,{data:t,margin:{top:20,right:30,left:20,bottom:20},children:[(0,st.jsx)(Ot.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"#e2e8f0"}),(0,st.jsx)(Ot.XAxis,{dataKey:o,tick:{fontSize:12,fill:"#64748b"},axisLine:{stroke:"#cbd5e1"},tickLine:!1}),(0,st.jsx)(Ot.YAxis,{tick:{fontSize:12,fill:"#64748b"},axisLine:!1,tickLine:!1}),(0,st.jsx)(Ot.Tooltip,{contentStyle:{borderRadius:"8px",border:"none",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"}}),(0,st.jsx)(Ot.Legend,{wrapperStyle:{paddingTop:"20px"}}),s.map((a,l)=>(0,st.jsx)(Ot.Area,{type:"monotone",dataKey:a,fill:i[l%i.length],stroke:i[l%i.length],fillOpacity:.3,strokeWidth:2},a))]})})})]})};var Qp=require("react"),ji=require("lucide-react"),hr=require("react/jsx-runtime"),MB=({isOpen:t,column:e,colType:r,onClose:n,onApply:o})=>{let[s,i]=(0,Qp.useState)("="),[a,l]=(0,Qp.useState)("");if((0,Qp.useEffect)(()=>{t&&(i("="),l(""))},[t]),!t)return null;let d={text:[{val:"=",label:"Es igual a"},{val:"contains",label:"Contiene"},{val:"starts_with",label:"Empieza con"}],number:[{val:"=",label:"Es igual a"},{val:">",label:"Es mayor que"},{val:"<",label:"Es menor que"},{val:">=",label:"Mayor o igual"},{val:"<=",label:"Menor o igual"}],date:[{val:"=",label:"Es exactamente"},{val:"<",label:"Antes de"},{val:">",label:"Despu\xE9s de"}]}[r];return(0,hr.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm p-4 animate-in fade-in duration-200",children:(0,hr.jsxs)("div",{className:"bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-2xl shadow-2xl w-full max-w-sm overflow-hidden animate-in zoom-in-95 duration-200",children:[(0,hr.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)] bg-[var(--bg-elevated)]",children:[(0,hr.jsxs)("h3",{className:"font-bold flex items-center gap-2 text-[var(--text-primary)]",children:[(0,hr.jsx)(ji.Filter,{className:"w-4 h-4 text-[var(--brand-primary)]"}),"Filtro Inteligente"]}),(0,hr.jsx)("button",{onClick:n,className:"p-1 hover:bg-[var(--bg-surface)] rounded-md transition-colors text-[var(--text-secondary)]",children:(0,hr.jsx)(ji.X,{className:"w-4 h-4"})})]}),(0,hr.jsxs)("form",{onSubmit:f=>{f.preventDefault(),a.trim()&&o(e,s,a.trim())},className:"p-5 space-y-4",children:[(0,hr.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,hr.jsxs)("label",{className:"text-xs font-bold text-[var(--text-secondary)] uppercase tracking-wider flex items-center gap-1.5",children:[r==="text"&&(0,hr.jsx)(ji.Type,{className:"w-3.5 h-3.5"}),r==="number"&&(0,hr.jsx)(ji.Hash,{className:"w-3.5 h-3.5"}),r==="date"&&(0,hr.jsx)(ji.Calendar,{className:"w-3.5 h-3.5"}),"Columna Objetivo"]}),(0,hr.jsxs)("div",{className:"px-3 py-2 bg-[var(--bg-surface)] border border-[var(--border-color)] rounded-lg text-sm font-semibold text-[var(--text-primary)]",children:[e,(0,hr.jsx)("span",{className:"ml-2 text-[10px] bg-[var(--brand-primary)]/10 text-[var(--brand-primary)] px-2 py-0.5 rounded-full uppercase",children:r})]})]}),(0,hr.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,hr.jsx)("label",{className:"text-xs font-bold text-[var(--text-secondary)] uppercase tracking-wider",children:"Condici\xF3n"}),(0,hr.jsx)("select",{value:s,onChange:f=>i(f.target.value),className:"w-full px-3 py-2 bg-[var(--bg-surface)] border border-[var(--border-color)] rounded-lg text-sm outline-none focus:ring-2 focus:ring-[var(--brand-primary)]/50 transition-shadow appearance-none",children:d.map(f=>(0,hr.jsx)("option",{value:f.val,children:f.label},f.val))})]}),(0,hr.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,hr.jsx)("label",{className:"text-xs font-bold text-[var(--text-secondary)] uppercase tracking-wider",children:"Valor"}),(0,hr.jsx)("input",{type:r==="date"?"date":r==="number"?"number":"text",step:"any",autoFocus:!0,value:a,onChange:f=>l(f.target.value),placeholder:"Escribe el valor...",className:"w-full px-3 py-2 bg-transparent border border-[var(--border-color)] rounded-lg text-sm outline-none focus:ring-2 focus:ring-[var(--brand-primary)]/50 transition-shadow"})]}),(0,hr.jsxs)("div",{className:"pt-2 flex gap-3",children:[(0,hr.jsx)("button",{type:"button",onClick:n,className:"flex-1 px-4 py-2 border border-[var(--border-color)] rounded-xl text-sm font-medium hover:bg-[var(--bg-surface)] transition-colors",children:"Cancelar"}),(0,hr.jsx)("button",{type:"submit",disabled:!a.trim(),className:"flex-1 px-4 py-2 bg-[var(--brand-primary)] hover:opacity-90 text-white rounded-xl text-sm font-medium transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:"Aplicar Filtro"})]})]})]})})};var Yc=require("react"),Xc=require("lucide-react"),zt=require("react/jsx-runtime"),PB=({isOpen:t,columns:e,onClose:r,onApply:n})=>{let[o,s]=(0,Yc.useState)(""),[i,a]=(0,Yc.useState)(e[0]||""),[l,c]=(0,Yc.useState)("+"),[d,u]=(0,Yc.useState)("");return(0,Yc.useEffect)(()=>{t&&(s(""),a(e[0]||""),c("+"),u(""))},[t,e]),t?(0,zt.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm p-4 animate-in fade-in duration-200",children:(0,zt.jsxs)("div",{className:"bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-2xl shadow-2xl w-full max-w-sm overflow-hidden animate-in zoom-in-95 duration-200",children:[(0,zt.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)] bg-[var(--bg-elevated)]",children:[(0,zt.jsxs)("h3",{className:"font-bold flex items-center gap-2 text-[var(--text-primary)]",children:[(0,zt.jsx)(Xc.Calculator,{className:"w-4 h-4 text-purple-600"}),"Columna Calculada"]}),(0,zt.jsx)("button",{onClick:r,className:"p-1 hover:bg-[var(--bg-surface)] rounded-md transition-colors text-[var(--text-secondary)]",children:(0,zt.jsx)(Xc.X,{className:"w-4 h-4"})})]}),(0,zt.jsxs)("form",{onSubmit:p=>{p.preventDefault(),!(!o.trim()||!d.trim())&&n(o.trim(),i,l,d.trim())},className:"p-5 space-y-4",children:[(0,zt.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,zt.jsxs)("label",{className:"text-xs font-bold text-[var(--text-secondary)] uppercase tracking-wider flex items-center gap-1.5",children:[(0,zt.jsx)(Xc.Edit3,{className:"w-3.5 h-3.5"})," Nombre Nueva Columna"]}),(0,zt.jsx)("input",{type:"text",autoFocus:!0,value:o,onChange:p=>s(p.target.value),placeholder:"Ej. Ingresos Netos",className:"w-full px-3 py-2 bg-transparent border border-[var(--border-color)] rounded-lg text-sm outline-none focus:ring-2 focus:ring-purple-600/50 transition-shadow"})]}),(0,zt.jsxs)("div",{className:"flex bg-[var(--bg-surface)] p-3 rounded-xl border border-[var(--border-color)] gap-3 items-center",children:[(0,zt.jsxs)("div",{className:"flex-1 flex flex-col gap-1",children:[(0,zt.jsx)("label",{className:"text-[10px] font-bold text-[var(--text-secondary)] uppercase",children:"Columna (A)"}),(0,zt.jsx)("select",{value:i,onChange:p=>a(p.target.value),className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-md text-sm outline-none",children:e.map(p=>(0,zt.jsx)("option",{value:p,children:p},p))})]}),(0,zt.jsxs)("div",{className:"w-12 flex flex-col gap-1",children:[(0,zt.jsx)("label",{className:"text-[10px] font-bold text-[var(--text-secondary)] uppercase text-center",children:"Op"}),(0,zt.jsxs)("select",{value:l,onChange:p=>c(p.target.value),className:"w-full px-1 py-1.5 bg-purple-50 text-purple-700 border border-purple-200 rounded-md text-sm outline-none text-center font-bold font-mono",children:[(0,zt.jsx)("option",{value:"+",children:"+"}),(0,zt.jsx)("option",{value:"-",children:"-"}),(0,zt.jsx)("option",{value:"*",children:"*"}),(0,zt.jsx)("option",{value:"/",children:"/"})]})]}),(0,zt.jsxs)("div",{className:"flex-1 flex flex-col gap-1",children:[(0,zt.jsx)("label",{className:"text-[10px] font-bold text-[var(--text-secondary)] uppercase",title:"Puede ser otra columna o un n\xFAmero fijo",children:"Columna o # (B)"}),(0,zt.jsx)("input",{type:"text",value:d,onChange:p=>u(p.target.value),placeholder:"Col o #...",className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-md text-sm outline-none"})]})]}),(0,zt.jsxs)("div",{className:"pt-2 flex gap-3",children:[(0,zt.jsx)("button",{type:"button",onClick:r,className:"flex-1 px-4 py-2 border border-[var(--border-color)] rounded-xl text-sm font-medium hover:bg-[var(--bg-surface)] transition-colors",children:"Cancelar"}),(0,zt.jsxs)("button",{type:"submit",disabled:!o.trim()||!d.trim(),className:"flex-1 px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-xl text-sm font-medium transition-all disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:[(0,zt.jsx)(Xc.Calculator,{className:"w-4 h-4"})," Calcular"]})]})]})]})}):null};var Ia=require("react"),co=require("lucide-react"),Ge=require("react/jsx-runtime"),RB=({isOpen:t,onClose:e,currentScript:r,activeConnector:n,activeResource:o,onLoadPipeline:s})=>{let[i,a]=(0,Ia.useState)("list"),[l,c]=(0,Ia.useState)([]),[d,u]=(0,Ia.useState)(!1),[f,p]=(0,Ia.useState)(""),[h,b]=(0,Ia.useState)(""),[g,x]=(0,Ia.useState)(!1);(0,Ia.useEffect)(()=>{t&&(a("list"),y())},[t]);let y=async()=>{u(!0);try{let w=await(await fetch("http://localhost:3000/api/dataway/pipelines")).json();w.pipelines&&c(w.pipelines)}catch(S){console.error("Failed to fetch pipelines",S)}finally{u(!1)}},m=async S=>{if(S.preventDefault(),!(!f.trim()||!n||!o||!r)){x(!0);try{(await fetch("http://localhost:3000/api/dataway/pipelines",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:f,description:h,connectorId:n,resource:o,mScript:r})})).ok&&(p(""),b(""),a("list"),y())}catch(w){console.error("Failed to save pipeline",w)}finally{x(!1)}}},v=async S=>{if(confirm("\xBFSeguro que deseas borrar esta plantilla?"))try{await fetch(`http://localhost:3000/api/dataway/pipelines/${S}`,{method:"DELETE"}),y()}catch(w){console.error("Failed to delete",w)}};return t?(0,Ge.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm p-4 animate-in fade-in duration-200",children:(0,Ge.jsxs)("div",{className:"bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-2xl shadow-2xl w-full max-w-2xl overflow-hidden flex flex-col max-h-[85vh]",children:[(0,Ge.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)] bg-[var(--bg-elevated)]",children:[(0,Ge.jsxs)("h3",{className:"font-bold flex items-center gap-2 text-[var(--text-primary)]",children:[(0,Ge.jsx)(co.Database,{className:"w-4 h-4 text-[var(--brand-primary)]"}),"Librer\xEDa de Pipelines ETL"]}),(0,Ge.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Ge.jsxs)("div",{className:"flex bg-[var(--bg-surface)] p-1 rounded-lg border border-[var(--border-color)]",children:[(0,Ge.jsx)("button",{onClick:()=>a("list"),className:`px-3 py-1 rounded-md text-xs font-semibold transition-colors ${i==="list"?"bg-white shadow text-[var(--brand-primary)]":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Cat\xE1logo"}),(0,Ge.jsx)("button",{onClick:()=>a("save"),className:`px-3 py-1 rounded-md text-xs font-semibold transition-colors ${i==="save"?"bg-white shadow text-[var(--brand-primary)]":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Nueva Plantilla"})]}),(0,Ge.jsx)("div",{className:"w-px h-6 bg-[var(--border-color)] mx-2"}),(0,Ge.jsx)("button",{onClick:e,className:"p-1.5 hover:bg-[var(--bg-surface)] rounded-md transition-colors text-[var(--text-secondary)]",children:(0,Ge.jsx)(co.X,{className:"w-4 h-4"})})]})]}),(0,Ge.jsx)("div",{className:"flex-1 overflow-y-auto p-4 bg-[var(--bg-primary)]",children:i==="list"?(0,Ge.jsx)("div",{className:"space-y-3",children:d?(0,Ge.jsx)("div",{className:"flex justify-center p-8",children:(0,Ge.jsx)(co.Loader2,{className:"w-6 h-6 animate-spin text-[var(--brand-primary)]"})}):l.length===0?(0,Ge.jsxs)("div",{className:"text-center p-8 text-[var(--text-secondary)]",children:[(0,Ge.jsx)(co.Database,{className:"w-12 h-12 mx-auto mb-3 opacity-20"}),(0,Ge.jsx)("p",{children:"No tienes pipelines guardados."})]}):l.map(S=>(0,Ge.jsxs)("div",{className:"border border-[var(--border-color)] rounded-xl p-4 hover:border-[var(--brand-primary)]/50 transition-colors bg-[var(--bg-surface)]/30 group",children:[(0,Ge.jsxs)("div",{className:"flex justify-between items-start mb-2",children:[(0,Ge.jsxs)("div",{children:[(0,Ge.jsx)("h4",{className:"font-bold text-[var(--text-primary)]",children:S.name}),(0,Ge.jsx)("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:S.description||"Sin descripci\xF3n"})]}),(0,Ge.jsxs)("div",{className:"flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,Ge.jsxs)("button",{onClick:()=>{s(S.m_script),e()},className:"flex items-center gap-1.5 bg-[var(--brand-primary)] hover:opacity-90 text-white px-3 py-1.5 rounded-lg text-xs font-bold transition-opacity",children:[(0,Ge.jsx)(co.Play,{className:"w-3.5 h-3.5"})," Cargar & Ejecutar"]}),(0,Ge.jsx)("button",{onClick:()=>v(S.id),className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors",children:(0,Ge.jsx)(co.Trash2,{className:"w-4 h-4"})})]})]}),(0,Ge.jsxs)("div",{className:"mt-3 flex items-center gap-3 text-[10px] font-mono font-medium text-[var(--text-secondary)]",children:[(0,Ge.jsxs)("span",{className:"bg-[var(--bg-elevated)] px-2 py-1 rounded border border-[var(--border-color)]",children:[S.connector_id," : ",S.resource]}),(0,Ge.jsxs)("span",{className:"truncate flex-1 flex items-center gap-1.5",children:[(0,Ge.jsx)(co.Code2,{className:"w-3 h-3"}),S.m_script.substring(0,50),"..."]}),(0,Ge.jsx)("span",{children:new Date(S.created_at).toLocaleDateString()})]})]},S.id))}):(0,Ge.jsx)("form",{onSubmit:m,className:"max-w-md mx-auto space-y-4 py-4",children:r?(0,Ge.jsxs)(Ge.Fragment,{children:[(0,Ge.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,Ge.jsx)("label",{className:"text-xs font-bold text-[var(--text-secondary)] uppercase",children:"Nombre del Pipeline"}),(0,Ge.jsx)("input",{type:"text",autoFocus:!0,required:!0,value:f,onChange:S=>p(S.target.value),placeholder:"Ej. Limpieza de Ventas Mensuales",className:"w-full px-3 py-2 bg-[var(--bg-surface)] border border-[var(--border-color)] rounded-lg text-sm outline-none focus:ring-2 focus:ring-[var(--brand-primary)]/50"})]}),(0,Ge.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,Ge.jsx)("label",{className:"text-xs font-bold text-[var(--text-secondary)] uppercase",children:"Descripci\xF3n (Opcional)"}),(0,Ge.jsx)("textarea",{value:h,onChange:S=>b(S.target.value),placeholder:"\xBFQu\xE9 hace esta transformaci\xF3n?",rows:3,className:"w-full px-3 py-2 bg-[var(--bg-surface)] border border-[var(--border-color)] rounded-lg text-sm outline-none focus:ring-2 focus:ring-[var(--brand-primary)]/50 resize-none"})]}),(0,Ge.jsxs)("div",{className:"p-3 bg-[var(--bg-elevated)] border border-[var(--border-color)] rounded-lg",children:[(0,Ge.jsx)("div",{className:"text-[10px] font-bold text-[var(--text-secondary)] uppercase mb-1",children:"M-Script a Guardar"}),(0,Ge.jsx)("pre",{className:"text-xs font-mono text-[var(--text-primary)] whitespace-pre-wrap truncate max-h-24 overflow-hidden",children:r})]}),(0,Ge.jsxs)("button",{type:"submit",disabled:g||!f.trim(),className:"w-full py-2.5 bg-[var(--brand-primary)] hover:opacity-90 text-white rounded-xl text-sm font-bold shadow-sm transition-all disabled:opacity-50 flex items-center justify-center gap-2 mt-4",children:[g?(0,Ge.jsx)(co.Loader2,{className:"w-4 h-4 animate-spin"}):(0,Ge.jsx)(co.Save,{className:"w-4 h-4"}),"Guardar en Postgres"]})]}):(0,Ge.jsx)("div",{className:"p-4 bg-orange-50 border border-orange-200 text-orange-800 rounded-lg text-sm text-center",children:"No hay un script activo en el editor para guardar."})})})]})}):null};var eh=require("react");Ri();zf();var pt=require("react/jsx-runtime"),yJ={},bJ=({data:t})=>(0,pt.jsxs)("div",{className:"bg-slate-900 border border-slate-700 rounded-lg shadow-xl w-72 text-sm overflow-hidden font-mono",children:[(0,pt.jsxs)("div",{className:`px-4 py-2 font-bold text-white uppercase tracking-wider flex items-center justify-between ${t.side==="source"?"bg-indigo-600":"bg-emerald-600"}`,children:[(0,pt.jsx)("span",{children:t.title}),(0,pt.jsxs)("span",{className:"text-xs opacity-75",children:[t.columns.length," cols"]})]}),(0,pt.jsx)("div",{className:"flex flex-col",children:t.columns.map((e,r)=>(0,pt.jsxs)("div",{className:"relative px-4 py-2 border-b border-slate-800 flex items-center justify-between hover:bg-slate-800 transition-colors group",children:[t.side==="source"&&(0,pt.jsx)(qr,{type:"source",position:Te.Right,id:`src-${e.name}`,className:"w-3 h-3 bg-indigo-400 !border-2 !border-slate-900 right-[-6px]"}),t.side==="target"&&(0,pt.jsx)(qr,{type:"target",position:Te.Left,id:`tgt-${e.name}`,className:"w-3 h-3 bg-emerald-400 !border-2 !border-slate-900 left-[-6px]"}),(0,pt.jsxs)("div",{className:"flex items-center gap-2 overflow-hidden",children:[(0,pt.jsx)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${t.side==="source"?"bg-indigo-500":"bg-emerald-500"}`}),(0,pt.jsx)("span",{className:"text-slate-200 truncate font-semibold",title:e.name,children:e.name})]}),(0,pt.jsxs)("div",{className:"flex flex-col items-end",children:[(0,pt.jsx)("span",{className:"text-xs text-slate-500",children:e.type}),e.formula&&(0,pt.jsx)("span",{className:"text-[10px] text-cyan-400 opacity-0 group-hover:opacity-100 transition-opacity absolute right-6 bg-slate-900 px-1 rounded z-10",title:e.formula,children:e.formula})]})]},e.name))})]}),xJ={tableNode:bJ},DB=({sourceConnector:t,sourceResource:e,targetConnector:r,targetResource:n,onClose:o})=>{let[s,i,a]=Kd([]),[l,c,d]=qd([]),[u,f]=(0,eh.useState)(!0),[p,h]=(0,eh.useState)({mapped:0,missingSource:0,missingTarget:0}),b=yJ.env?.VITE_API_BASE_URL||"http://localhost:3001";return(0,eh.useEffect)(()=>{(async()=>{try{let x=await fetch(`${b}/api/dataway/schema/mapper?sourceConnector=${t}&sourceResource=${e}&targetConnector=${r}&targetResource=${n}`);if(!x.ok)throw new Error("Failed to fetch schema mapping");let y=await x.json(),m=[{id:"source-table",type:"tableNode",position:{x:100,y:100},data:{title:e,columns:y.sourceSchema.columns,side:"source"}},{id:"target-table",type:"tableNode",position:{x:700,y:100},data:{title:n,columns:y.targetSchema.columns,side:"target"}}];y.sourceSchema.inferences&&y.sourceSchema.inferences.length>0&&y.sourceSchema.inferences.forEach((C,A)=>{m.push({id:`inf-${C}`,type:"default",position:{x:100+A*150,y:-100},data:{label:`\u{1F4CE} Ref: ${C}`},style:{background:"#1e293b",color:"#94a3b8",border:"1px solid #334155",borderRadius:"8px",padding:"10px"}})}),i(m);let v=[],S=0,w=y.targetSchema.columns.map(C=>C.name.toLowerCase());y.sourceSchema.columns.forEach(C=>{let A=C.name.toLowerCase(),k=w.findIndex(M=>{let T=A.replace(/[^a-z0-9]/g,""),E=M.replace(/[^a-z0-9]/g,"");return T===E});if(k!==-1){let M=y.targetSchema.columns[k];v.push({id:`e-${C.name}-${M.name}`,source:"source-table",target:"target-table",sourceHandle:`src-${C.name}`,targetHandle:`tgt-${M.name}`,animated:!0,style:{stroke:"#10b981",strokeWidth:2},markerEnd:{type:pn.ArrowClosed,color:"#10b981"}}),S++}C.formula&&y.sourceSchema.inferences.forEach(M=>{C.formula?.includes(M)&&v.push({id:`infe-${C.name}-${M}`,source:`inf-${M}`,target:"source-table",targetHandle:`src-${C.name}`,animated:!0,style:{stroke:"#cbd5e1",strokeWidth:1,strokeDasharray:"5,5"}})})}),c(v),h({mapped:S,missingSource:y.sourceSchema.columns.length-S,missingTarget:y.targetSchema.columns.length-S})}catch(x){console.error("Schema Map error:",x)}finally{f(!1)}})()},[t,e,r,n]),(0,pt.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4 text-white",children:(0,pt.jsxs)("div",{className:"bg-[#0b0e14] w-[95vw] h-[90vh] rounded-2xl border border-slate-700 shadow-2xl flex flex-col overflow-hidden relative",children:[(0,pt.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-slate-800 bg-slate-900/50 backdrop-blur-md",children:[(0,pt.jsxs)("div",{children:[(0,pt.jsxs)("h2",{className:"text-xl font-bold bg-gradient-to-r from-blue-400 to-indigo-400 bg-clip-text text-transparent flex items-center gap-2",children:[(0,pt.jsx)("span",{className:"material-symbols-outlined text-indigo-400",children:"schema"}),"Dataway ERD Mapper"]}),(0,pt.jsxs)("p",{className:"text-slate-400 text-sm mt-1",children:["Analyzed Source ",(0,pt.jsxs)("b",{children:["(",e,")"]})," against Target ",(0,pt.jsxs)("b",{children:["(",n,")"]})]})]}),(0,pt.jsxs)("div",{className:"flex gap-6 items-center",children:[(0,pt.jsxs)("div",{className:"flex gap-4 text-sm font-mono bg-black/40 px-4 py-2 rounded-lg border border-slate-800",children:[(0,pt.jsxs)("div",{className:"flex flex-col items-center px-2",children:[(0,pt.jsx)("span",{className:"text-emerald-400 text-lg font-bold",children:p.mapped}),(0,pt.jsx)("span",{className:"text-slate-500 text-[10px] uppercase",children:"Mapped"})]}),(0,pt.jsx)("div",{className:"w-px bg-slate-800"}),(0,pt.jsxs)("div",{className:"flex flex-col items-center px-2",children:[(0,pt.jsx)("span",{className:"text-rose-400 text-lg font-bold",children:p.missingTarget}),(0,pt.jsx)("span",{className:"text-slate-500 text-[10px] uppercase",children:"Orphans"})]})]}),(0,pt.jsx)("button",{onClick:o,className:"w-10 h-10 rounded-xl bg-slate-800 hover:bg-rose-500/20 hover:text-rose-400 flex items-center justify-center transition-all",children:(0,pt.jsx)("span",{className:"material-symbols-outlined",children:"close"})})]})]}),(0,pt.jsx)("div",{className:"flex-1 w-full h-full bg-[#0a0a0a]",children:u?(0,pt.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,pt.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-500"})}):(0,pt.jsxs)(el,{nodes:s,edges:l,onNodesChange:a,onEdgesChange:d,nodeTypes:xJ,fitView:!0,attributionPosition:"bottom-left",className:"bg-[#050505]",children:[(0,pt.jsx)(tl,{color:"#334155",gap:20,size:1}),(0,pt.jsx)(rl,{className:"!bg-slate-900 !border-slate-700 !fill-slate-400"}),(0,pt.jsx)(nl,{className:"!bg-slate-900 !border-slate-700 rounded-lg",maskColor:"rgba(0,0,0,0.5)",nodeColor:g=>g.id.includes("source")?"#4f46e5":"#10b981"})]})})]})})};var js=require("react");Ri();zf();var Xn=require("lucide-react"),pe=require("react/jsx-runtime"),vJ=({data:t})=>(0,pe.jsxs)("div",{className:"bg-slate-900 border border-amber-500/50 rounded-xl shadow-2xl p-4 w-64 text-slate-200",children:[(0,pe.jsxs)("div",{className:"flex items-center gap-2 mb-3 text-amber-400",children:[(0,pe.jsx)(Xn.Clock,{size:18}),(0,pe.jsx)("span",{className:"font-bold text-sm tracking-wide",children:"CRON TRIGGER"})]}),(0,pe.jsx)("div",{className:"bg-black/50 p-2 rounded-lg font-mono text-center text-lg text-emerald-400 border border-slate-700",children:t.cron}),(0,pe.jsx)("div",{className:"text-xs text-slate-500 mt-2 text-center uppercase",children:"Schedule Expression"}),(0,pe.jsx)(qr,{type:"source",position:Te.Right,className:"w-3 h-3 bg-amber-500"})]}),wJ=({data:t})=>(0,pe.jsxs)("div",{className:"bg-indigo-950 border border-indigo-500/50 rounded-xl shadow-2xl p-4 w-72 text-slate-200",children:[(0,pe.jsx)(qr,{type:"target",position:Te.Left,className:"w-3 h-3 bg-indigo-500"}),(0,pe.jsxs)("div",{className:"flex items-center gap-2 mb-3 text-indigo-400",children:[(0,pe.jsx)(Xn.FastForward,{size:18}),(0,pe.jsx)("span",{className:"font-bold text-sm tracking-wide",children:"ETL PIPELINE"})]}),(0,pe.jsx)("div",{className:"font-semibold text-white bg-indigo-900/50 p-2 rounded-lg border border-indigo-500/30 truncate",children:t.name}),(0,pe.jsx)(qr,{type:"source",position:Te.Right,className:"w-3 h-3 bg-indigo-500"})]}),SJ=({data:t})=>(0,pe.jsxs)("div",{className:"bg-emerald-950 border border-emerald-500/50 rounded-xl shadow-2xl p-4 w-64 text-slate-200 relative overflow-hidden",children:[t.isActive?(0,pe.jsx)("div",{className:"absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-emerald-400 to-teal-400 animate-pulse"}):(0,pe.jsx)("div",{className:"absolute top-0 left-0 w-full h-1 bg-slate-700"}),(0,pe.jsx)(qr,{type:"target",position:Te.Left,className:"w-3 h-3 bg-emerald-500"}),(0,pe.jsxs)("div",{className:"flex items-center gap-2 mb-3 text-emerald-400",children:[(0,pe.jsx)(Xn.Database,{size:18}),(0,pe.jsx)("span",{className:"font-bold text-sm tracking-wide",children:"TARGET DB"})]}),(0,pe.jsxs)("div",{className:"text-sm font-mono text-slate-300",children:[(0,pe.jsx)("span",{className:"opacity-50",children:"Conn:"})," ",t.connector,(0,pe.jsx)("br",{}),(0,pe.jsx)("span",{className:"opacity-50",children:"Table:"})," ",t.resource]}),t.lastStatus&&(0,pe.jsxs)("div",{className:"mt-3 text-[10px] text-slate-400 bg-black/40 p-1.5 rounded flex items-center gap-1.5",children:[(0,pe.jsx)(Xn.CheckCircle2,{size:12,className:t.lastStatus.includes("Failed")?"text-rose-400":"text-emerald-400"}),(0,pe.jsx)("span",{className:"truncate",children:t.lastStatus})]})]}),NJ={trigger:vJ,pipeline:wJ,destination:SJ},OB=({onClose:t})=>{let[e,r,n]=Kd([]),[o,s,i]=qd([]),[a,l]=(0,js.useState)([]),[c,d]=(0,js.useState)([]),[u,f]=(0,js.useState)(""),[p,h]=(0,js.useState)("0 3 * * *"),[b,g]=(0,js.useState)(""),[x,y]=(0,js.useState)("googlesheets"),[m,v]=(0,js.useState)(""),[S,w]=(0,js.useState)("postgres"),[C,A]=(0,js.useState)("ventas"),k=async()=>{try{let[N,D]=await Promise.all([fetch("/api/dataway/crons").then(R=>R.json()),fetch("/api/dataway/pipelines").then(R=>R.json())]);l(N.crons||[]),d(D.pipelines||[]),M(N.crons||[])}catch(N){console.error("Failed to load orchestrator data",N)}},M=N=>{let D=[],R=[];N.forEach((O,B)=>{let L=B*250+50;D.push({id:`trigger-${O.id}`,type:"trigger",position:{x:50,y:L},data:{cron:O.cron_expression}}),D.push({id:`pipe-${O.id}`,type:"pipeline",position:{x:400,y:L+10},data:{name:O.pipeline_name||`Pipeline #${O.pipeline_id}`}}),D.push({id:`dest-${O.id}`,type:"destination",position:{x:800,y:L},data:{connector:O.target_connector,resource:O.target_resource,lastStatus:O.last_status,isActive:O.is_active}}),R.push({id:`e1-${O.id}`,source:`trigger-${O.id}`,target:`pipe-${O.id}`,animated:O.is_active,style:{stroke:O.is_active?"#f59e0b":"#334155",strokeWidth:2},markerEnd:{type:pn.ArrowClosed,color:O.is_active?"#f59e0b":"#334155"}}),R.push({id:`e2-${O.id}`,source:`pipe-${O.id}`,target:`dest-${O.id}`,animated:O.is_active,style:{stroke:O.is_active?"#10b981":"#334155",strokeWidth:2},markerEnd:{type:pn.ArrowClosed,color:O.is_active?"#10b981":"#334155"}})}),r(D),s(R)};(0,js.useEffect)(()=>{k()},[]);let T=async()=>{if(!u||!b||!m||!C)return alert("Faltan campos (Origen, Destino, Plantilla)");await fetch("/api/dataway/crons",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:u,cron_expression:p,pipeline_id:parseInt(b),source_connector:x,source_resource:m,target_connector:S,target_resource:C,is_active:!1})}),k()},E=async(N,D)=>{await fetch(`/api/dataway/crons/${N}/toggle`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_active:!D})}),k()},P=async N=>{confirm("Are you sure?")&&(await fetch(`/api/dataway/crons/${N}`,{method:"DELETE"}),k())};return(0,pe.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-md p-4 flex-col text-slate-200",children:(0,pe.jsxs)("div",{className:"w-[98vw] h-[95vh] bg-[#090b11] rounded-2xl border border-slate-700 shadow-2xl flex overflow-hidden",children:[(0,pe.jsxs)("div",{className:"flex-1 relative",children:[(0,pe.jsxs)(el,{nodes:e,edges:o,onNodesChange:n,onEdgesChange:i,nodeTypes:NJ,fitView:!0,className:"bg-[#050505]",children:[(0,pe.jsx)(tl,{color:"#334155",gap:20,size:1}),(0,pe.jsx)(rl,{className:"!bg-slate-900 !border-slate-700 !fill-slate-400"}),(0,pe.jsx)(nl,{className:"!bg-slate-900 !border-slate-700",maskColor:"rgba(0,0,0,0.6)"})]}),(0,pe.jsxs)("div",{className:"absolute top-4 left-4 bg-slate-900/60 backdrop-blur p-4 rounded-xl border border-slate-700 shadow-xl",children:[(0,pe.jsxs)("h2",{className:"text-xl font-bold bg-gradient-to-r from-teal-400 to-indigo-400 bg-clip-text text-transparent flex items-center gap-2",children:[(0,pe.jsx)(Xn.Clock,{className:"text-teal-400"}),"Dataway Orchestrator (Level 14) \u{1F680}"]}),(0,pe.jsx)("p",{className:"text-sm text-slate-400 mt-1",children:"Autonomous ETL Cron Engine linked to Postgres Templates"})]}),(0,pe.jsx)("button",{onClick:t,className:"absolute top-4 right-4 bg-slate-800 p-2 rounded-lg hover:bg-rose-500/20 text-slate-400 transition-colors",children:"Cerrar Orchestrator"})]}),(0,pe.jsxs)("div",{className:"w-[400px] border-l border-slate-800 bg-slate-900 flex flex-col",children:[(0,pe.jsx)("div",{className:"p-4 border-b border-slate-800 font-bold bg-slate-950 uppercase tracking-widest text-xs text-slate-500",children:"Create Auto-Job"}),(0,pe.jsxs)("div",{className:"p-4 space-y-4 border-b border-slate-800",children:[(0,pe.jsxs)("div",{children:[(0,pe.jsx)("label",{className:"text-xs text-slate-400 mb-1 block",children:"Job Name"}),(0,pe.jsx)("input",{value:u,onChange:N=>f(N.target.value),className:"w-full bg-black/40 border border-slate-700 rounded-md px-3 py-2 text-sm",placeholder:"Sincronizaci\xF3n Nocturna"})]}),(0,pe.jsx)("div",{className:"flex gap-2",children:(0,pe.jsxs)("div",{className:"flex-1",children:[(0,pe.jsx)("label",{className:"text-xs text-slate-400 mb-1 block",children:"Cron Format"}),(0,pe.jsx)("input",{value:p,onChange:N=>h(N.target.value),className:"w-full bg-black/40 border border-slate-700 rounded-md px-3 py-2 text-sm font-mono text-amber-400"})]})}),(0,pe.jsxs)("div",{children:[(0,pe.jsx)("label",{className:"text-xs text-slate-400 mb-1 block",children:"Pipeline Template"}),(0,pe.jsxs)("select",{value:b,onChange:N=>g(N.target.value),className:"w-full bg-black/40 border border-slate-700 rounded-md px-3 py-2 text-sm text-indigo-300",children:[(0,pe.jsx)("option",{value:"",children:"Select Pipeline..."}),c.map(N=>(0,pe.jsx)("option",{value:N.id,children:N.name},N.id))]})]}),(0,pe.jsxs)("div",{className:"grid grid-cols-2 gap-2 p-3 bg-black/30 rounded-lg border border-slate-800",children:[(0,pe.jsxs)("div",{children:[(0,pe.jsx)("label",{className:"text-xs text-slate-500 mb-1 block",children:"Source Conn"}),(0,pe.jsx)("input",{value:x,onChange:N=>y(N.target.value),className:"w-full bg-transparent border-b border-slate-700 text-xs py-1"})]}),(0,pe.jsxs)("div",{children:[(0,pe.jsx)("label",{className:"text-xs text-slate-500 mb-1 block",children:"Source Table/Sheet"}),(0,pe.jsx)("input",{value:m,onChange:N=>v(N.target.value),className:"w-full bg-transparent border-b border-slate-700 text-xs py-1"})]}),(0,pe.jsxs)("div",{children:[(0,pe.jsx)("label",{className:"text-xs text-slate-500 mb-1 block mt-2",children:"Target Conn"}),(0,pe.jsx)("input",{value:S,onChange:N=>w(N.target.value),className:"w-full bg-transparent border-b border-slate-700 text-xs py-1"})]}),(0,pe.jsxs)("div",{children:[(0,pe.jsx)("label",{className:"text-xs text-slate-500 mb-1 block mt-2",children:"Target Table"}),(0,pe.jsx)("input",{value:C,onChange:N=>A(N.target.value),className:"w-full bg-transparent border-b border-slate-700 text-xs py-1 text-emerald-400"})]})]}),(0,pe.jsxs)("button",{onClick:T,className:"w-full bg-indigo-600 hover:bg-indigo-500 text-white font-bold py-2 rounded-lg transition-colors flex justify-center items-center gap-2 text-sm",children:[(0,pe.jsx)(Xn.FastForward,{size:16})," Deploy to Engine"]})]}),(0,pe.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-3",children:[(0,pe.jsx)("h3",{className:"text-xs font-bold text-slate-500 uppercase tracking-widest mb-4",children:"Deployed Engine Jobs"}),a.map(N=>(0,pe.jsxs)("div",{className:`p-3 rounded-xl border transition-all ${N.is_active?"bg-indigo-950/30 border-indigo-500/50":"bg-slate-800/50 border-slate-700"}`,children:[(0,pe.jsxs)("div",{className:"flex justify-between items-start mb-2",children:[(0,pe.jsx)("div",{className:"font-bold text-sm truncate pr-2",children:N.name}),(0,pe.jsxs)("div",{className:"flex gap-2",children:[(0,pe.jsx)("button",{onClick:()=>E(N.id,N.is_active),className:`p-1.5 rounded-md ${N.is_active?"bg-amber-500/20 text-amber-500":"bg-emerald-500/20 text-emerald-500"}`,children:N.is_active?(0,pe.jsx)(Xn.Pause,{size:14}):(0,pe.jsx)(Xn.Play,{size:14})}),(0,pe.jsx)("button",{onClick:()=>P(N.id),className:"p-1.5 bg-rose-500/10 text-rose-500 rounded-md hover:bg-rose-500/20",children:(0,pe.jsx)(Xn.Trash2,{size:14})})]})]}),(0,pe.jsxs)("div",{className:"flex items-center gap-2 text-xs font-mono mb-2",children:[(0,pe.jsx)(Xn.Clock,{size:12,className:"text-slate-500"}),(0,pe.jsx)("span",{className:"text-amber-400",children:N.cron_expression}),(0,pe.jsx)("span",{className:`px-2 py-0.5 rounded-full text-[10px] ${N.is_active?"bg-emerald-500/20 text-emerald-400":"bg-slate-700 text-slate-400"}`,children:N.is_active?"RUNNING IN BACKGROUND":"PAUSED"})]}),N.last_status&&(0,pe.jsxs)("div",{className:"text-[10px] bg-black/30 p-1.5 rounded text-amber-100/70 border border-slate-800 truncate",children:["Status: ",N.last_status]})]},N.id)),a.length===0&&(0,pe.jsx)("div",{className:"text-center text-slate-500 text-sm mt-10",children:"No cron jobs scheduled via Orchestrator."})]})]})]})})};var J=require("react/jsx-runtime"),CJ={},KS=CJ.env?.VITE_API_BASE_URL||"http://localhost:3001",_B=()=>{let[t]=(0,Et.useState)([{id:"postgres",name:"PostgreSQL Core"},{id:"google_sheets",name:"Google Sheets MCP"}]),[e,r]=(0,Et.useState)("google_sheets"),[n,o]=(0,Et.useState)([]),[s,i]=(0,Et.useState)({}),[a,l]=(0,Et.useState)([]),[c,d]=(0,Et.useState)(null),[u,f]=(0,Et.useState)(null),[p,h]=(0,Et.useState)("grid"),[b,g]=(0,Et.useState)(!0),[x,y]=(0,Et.useState)(!1),[m,v]=(0,Et.useState)(!1),[S,w]=(0,Et.useState)([]),[C,A]=(0,Et.useState)([]),[k,M]=(0,Et.useState)(""),[T,E]=(0,Et.useState)(null),[P,N]=(0,Et.useState)(null),[D,R]=(0,Et.useState)(null),[O,B]=(0,Et.useState)(null),[L,H]=(0,Et.useState)(null),[j,$]=(0,Et.useState)(!1),[q,F]=(0,Et.useState)(!1),[_,W]=(0,Et.useState)(!1),[V,z]=(0,Et.useState)(!1),[G,Y]=(0,Et.useState)(!1),[Z,se]=(0,Et.useState)(!1),[we,_e]=(0,Et.useState)(""),Pe=async()=>{g(!0),N(null);try{let ne=await fetch(`${KS}/api/dataway/resources?connectorId=${e}`,{headers:{"x-api-key":"dev_ak_chameleon_studio_99x"}});if(!ne.ok)throw new Error("API Endpoint no disponible");let be=await ne.json(),me=Array.isArray(be.resources)?be.resources:[];o(me),me.length>0?f(me[0]):f(null)}catch(ne){N(ne.message)}finally{g(!1)}};(0,Et.useEffect)(()=>{Pe(),localStorage.setItem("dataway_active_connector",e)},[e]);let K=(ne,be)=>{let me="";for(let ue of ne)if(me?me=ue.script.replace(/\bSource\b/g,me):me=ue.script,be&&ue.id===be)break;return me},he=ne=>{let be={id:Date.now().toString(),name:"Plantilla ETL",script:ne,isValidData:!0,isComputed:!1};l([be]),d(be.id),_e(ne),u&<(u,ne)},lt=async(ne,be)=>{y(!0),M(""),E(null),R(null);try{let me=await fetch(`${KS}/api/dataway/query`,{method:"POST",headers:{"x-api-key":"dev_ak_chameleon_studio_99x","Content-Type":"application/json"},body:JSON.stringify({connectorId:e,resource:ne,type:e==="postgres"?"table":"range",m_script:be||void 0,secondaryResources:C.length>0?C:void 0})});if(!me.ok){let ht=await me.json().catch(()=>({}));throw new Error(ht.error||`El backend Dataway rechaz\xF3 la solicitud (HTTP ${me.status})`)}let ue=await me.json();w(Array.isArray(ue.data)?ue.data:[]),be!==void 0&&_e(be)}catch(me){R(me.message),Bt.error("Error en la consulta",{description:me.message}),w([])}finally{y(!1)}};(0,Et.useEffect)(()=>{if(u){localStorage.setItem("dataway_active_resource",u);let ne=K(a,c||void 0);lt(u,ne)}else localStorage.removeItem("dataway_active_resource")},[u]);let He=(ne,be)=>{if(!ne.trim())return;let me=[...a],ue=be&&be!==u;ue&&(me=[]);let ht=ue?-1:me.findIndex(Gt=>Gt.id===c);if(ht===me.length-1||c===null||ht===-1){let Gt={id:Math.random().toString(36).substr(2,9),name:`Paso ${me.length+1}`,script:ne};me.push(Gt),l(me),d(Gt.id)}else me[ht].script=ne,l(me);let Zt=ue?me[0].id:c||void 0,Wo=K(me,Zt),Qt=be||u;Qt&<(Qt,Wo)};(0,Et.useEffect)(()=>{let ne=be=>{let me=be.detail?.script,ue=be.detail?.resource;me&&typeof me=="string"&&(ue&&ue!==u?(f(ue),He(me,ue),Bt.success(`Cambiando de forma aut\xF3noma a la tabla ${ue}`)):(He(me),Bt.success("Recibido desde Agente AI")))};return window.addEventListener("intent:dataway-generate-script",ne),()=>window.removeEventListener("intent:dataway-generate-script",ne)},[a,c,u]);let nt=ne=>{d(ne);let be=K(a,ne);u&<(u,be)},dr=(ne,be)=>{ne.stopPropagation();let me=a.filter(Zt=>Zt.id!==be);l(me);let ue=me.length>0?me[me.length-1].id:null;d(ue);let ht=K(me,ue||void 0);u?lt(u,ht):w([])},ln=()=>{l([]),d(null),_e(""),u&<(u,"")},Tr=ne=>{let be="asc";T&&T.key===ne&&T.direction==="asc"&&(be="desc"),E({key:ne,direction:be})},bn=(ne,be)=>{B(null);let me="";if(ne==="rename"){let ue=prompt(`Renombrar columna '${be}':`,be);if(!ue||ue===be)return;me=`Table.RenameColumns(Source, {{"${be}", "${ue}"}})`}else if(ne==="remove"){if(!confirm(`\xBFEst\xE1s seguro de eliminar la columna '${be}'?`))return;me=`Table.RemoveColumns(Source, "${be}")`}else if(ne==="sort")me=`Table.Sort(Source, "${be}")`;else if(ne==="filter"){let ue=je.find(Zt=>Zt[be]!==null&&Zt[be]!==void 0)?.[be],ht="text";ue!=null&&(!isNaN(Number(ue))&&String(ue).trim()!==""?ht="number":isNaN(Number(ue))&&!isNaN(Date.parse(String(ue)))&&(ht="date")),H({isOpen:!0,col:be,type:ht});return}else if(ne==="group_sum"){let ue=prompt(`Vas a agrupar por '${be}'. \xBFQu\xE9 columna deseas SUMAR para totalizar?`,"");if(!ue)return;me=`Table.GroupSum(Source, "${be}", "${ue}", "Total_${ue}")`}else if(ne==="drop_nulls")me=`Table.DropNulls(Source, "${be}")`;else if(ne==="fill_nulls"){let ue=prompt(`\xBFCon qu\xE9 valor (ej. 0 o "N/A") deseas rellenar los datos vac\xEDos en '${be}'?`,"0");if(ue===null||ue==="")return;let Zt=!isNaN(Number(ue))&&ue.trim()!==""?ue:`"${ue}"`;me=`Table.FillNulls(Source, "${be}", ${Zt})`}me&&(He(me),Bt.success("Paso generado exitosamente"))},St=(ne,be,me)=>{H(null);let ue=`"${me}"`;!isNaN(Number(me))&&me.trim()!==""&&(ue=me);let Zt=`Table.Filter(Source, "${ne}", "${be}", ${ue})`;He(Zt),Bt.success("Filtro Inteligente aplicado")},mt=(ne,be,me,ue)=>{$(!1);let ht=`"${ue}"`,Zt=`Table.MathColumn(Source, "${ne}", "${be}", "${me}", ${ht})`;He(Zt),Bt.success("Columna Calculada agregada")},je=(0,Et.useMemo)(()=>{let ne=[...S];if(k){let be=k.toLowerCase();ne=ne.filter(me=>Object.keys(me).some(ue=>String(me[ue]).toLowerCase().includes(be)))}return T!==null&&ne.sort((be,me)=>{let ue=be[T.key],ht=me[T.key];return ue<ht?T.direction==="asc"?-1:1:ue>ht?T.direction==="asc"?1:-1:0}),ne},[S,k,T]),or=S.length>0?Object.keys(S[0]):[],fo=(0,Et.useMemo)(()=>{if(je.length===0)return{};let ne={};return or.forEach(be=>{let me=0,ue=0,ht=je.length;for(let Zt=0;Zt<ht;Zt++){let Wo=je[Zt][be];Wo==null||Wo===""?ue++:me++}ne[be]={valid:me,empty:ue,total:ht}}),ne},[je,or]),Jn=()=>{if(je.length===0)return;let ne=[];ne.push(or.join(","));for(let ht of je){let Zt=or.map(Wo=>{let Qt=ht[Wo];return Qt==null?"":`"${String(Qt).replace(/"/g,'""')}"`});ne.push(Zt.join(","))}let be=new Blob([ne.join(`
|
|
492
|
+
`)],{type:"text/csv;charset=utf-8;"}),me=URL.createObjectURL(be),ue=document.createElement("a");ue.setAttribute("href",me),ue.setAttribute("download",`dataway_${u}_${new Date().getTime()}.csv`),document.body.appendChild(ue),ue.click(),document.body.removeChild(ue),Bt.success(`Exportados ${je.length} registros exitosamente`)},Ao=async()=>{if(je.length===0)return;let ne=prompt("Ingrese el nombre de la tabla de destino en PostgreSQL:");if(ne){v(!0),Bt.loading(`Sincronizando ${je.length} registros hacia ${ne}...`,{id:"sync-db"});try{let be={connectorId:"postgres",destinationTable:ne,data:je},me=await fetch(`${KS}/api/dataway/sync`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":"dev_ak_chameleon_studio_99x"},body:JSON.stringify(be)});if(!me.ok){let ht=await me.json();throw new Error(ht.error||"Error en sincronizaci\xF3n")}let ue=await me.json();Bt.success(`Sincronizaci\xF3n Exitosa: ${ue.rowsInserted} filas insertadas en ${ue.destination}`,{id:"sync-db"})}catch(be){Bt.error("Error de Sincronizaci\xF3n",{description:be.message,id:"sync-db"})}finally{v(!1)}}},pi=(0,Et.useRef)(null),ps=A4({count:je.length,getScrollElement:()=>pi.current,estimateSize:()=>45,overscan:10}),cn=ps.getVirtualItems();return(0,J.jsxs)("div",{className:"w-full h-full flex flex-row overflow-hidden",style:{"--bg-primary":"var(--ds-surface-primary, #ffffff)","--bg-elevated":"var(--ds-surface-secondary, #f8fafc)","--bg-surface":"var(--ds-surface-tertiary, #f1f5f9)","--border-color":"var(--ds-border-default, #e2e8f0)","--text-primary":"var(--ds-text-primary, #0f172a)","--text-secondary":"var(--ds-text-secondary, #64748b)","--brand-primary":"var(--ds-accent-blue, #6366f1)","--brand-primary-hover":"var(--ds-accent-blue-hover, #4f46e5)"},children:[(0,J.jsx)(_u.AnimatePresence,{children:G&&(0,J.jsx)(_u.motion.div,{initial:{width:0,opacity:0},animate:{width:288,opacity:1},exit:{width:0,opacity:0},transition:{duration:.2},className:"border-r border-[var(--border-color)] bg-[var(--bg-elevated)] flex flex-col h-full z-10 shrink-0 overflow-hidden",children:(0,J.jsxs)("div",{className:"w-72 flex flex-col h-full",children:[(0,J.jsxs)("div",{className:"p-6 border-b border-[var(--border-color)] flex flex-col gap-4 bg-[var(--bg-primary)]",children:[(0,J.jsxs)("div",{className:"flex items-center gap-3",children:[(0,J.jsx)("div",{className:"p-2 bg-[var(--brand-primary)]/10 rounded-xl",children:(0,J.jsx)(Ke.FunctionSquare,{className:"w-6 h-6 text-[var(--brand-primary)]"})}),(0,J.jsxs)("div",{children:[(0,J.jsx)("h2",{className:"font-extrabold text-[var(--text-primary)] tracking-tight text-lg leading-none",children:"Dataway Studio"}),(0,J.jsx)("p",{className:"text-[11px] font-medium text-[var(--text-secondary)] uppercase tracking-wider mt-1",children:"M-Script Engine"})]})]}),(0,J.jsx)("select",{value:e,onChange:ne=>r(ne.target.value),className:"w-full bg-[var(--bg-surface)] border border-[var(--border-color)] text-[var(--text-primary)] text-sm font-bold rounded-lg px-3 py-2 outline-none cursor-pointer",children:t.map(ne=>(0,J.jsx)("option",{value:ne.id,children:ne.name},ne.id))})]}),(0,J.jsxs)("div",{className:"p-4 flex-1 overflow-y-auto w-full space-y-1.5 custom-scrollbar",children:[(0,J.jsxs)("h3",{className:"text-xs font-bold text-[var(--text-secondary)] tracking-wider uppercase mb-3 px-2 flex items-center justify-between",children:["Recursos",(0,J.jsx)("button",{onClick:Pe,className:"hover:text-[var(--text-primary)] transition-colors p-1 rounded-md",children:(0,J.jsx)(Ke.RefreshCw,{className:"w-3 h-3"})})]}),b?(0,J.jsx)("div",{className:"space-y-2 px-2",children:[1,2,3].map(ne=>(0,J.jsx)("div",{className:"h-10 bg-[var(--bg-surface)] rounded-lg animate-pulse w-full"},ne))}):n.map((ne,be)=>(0,J.jsxs)("button",{onClick:()=>f(ne),className:`w-full flex items-center justify-between px-3 py-2.5 rounded-xl text-sm font-semibold transition-all group ${u===ne?"bg-[var(--brand-primary)] text-white shadow-md":"text-[var(--text-secondary)] hover:bg-[var(--bg-surface)] hover:text-[var(--text-primary)]"}`,children:[(0,J.jsxs)("div",{className:"flex items-center gap-3",children:[(0,J.jsx)(Ke.TableProperties,{className:`w-4 h-4 ${u===ne?"text-[var(--bg-surface)]":""}`}),(0,J.jsx)("span",{className:"capitalize",children:ne})]}),(0,J.jsxs)("div",{className:"flex items-center gap-2",children:[(0,J.jsx)("div",{onClick:me=>{me.stopPropagation();let ue=`${e}_${ne}`.replace(/[^a-zA-Z0-9_]/g,""),ht=prompt("Asignar nombre de variable local (ej. Clientes) para el JOIN:",ue);if(ht){if(C.some(Zt=>Zt.boundName===ht)){Bt.error("El nombre de la variable ya existe.");return}A(Zt=>[...Zt,{connectorId:e,resource:ne,boundName:ht}]),Bt.success(`Referencia: ${ht} agregada al contexto.`)}},className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-black/10 rounded transition-colors",title:"Inyectar en Contexto Secundario (Federated Join)",children:(0,J.jsx)(Ke.Plus,{className:"w-3.5 h-3.5"})}),u===ne&&(0,J.jsx)(Ke.ChevronRight,{className:"w-4 h-4 opacity-70"})]})]},`${ne}-${be}`))]})]})})}),(0,J.jsxs)("div",{className:"flex-1 bg-[var(--bg-surface)] flex flex-col h-full min-w-0",children:[(0,J.jsx)(IB,{activeResource:u,activeConnector:e,isLoading:x,schemaColumns:or,onExecute:He,onClear:ln}),(0,J.jsxs)("div",{className:"bg-[var(--bg-primary)] border-b border-[var(--border-color)] px-4 py-2 flex items-center justify-between z-10 overflow-x-auto custom-scrollbar",children:[(0,J.jsxs)("div",{className:"flex items-center gap-2",children:[(0,J.jsx)("button",{onClick:()=>Y(!G),className:`p-1.5 rounded-md border transition-colors flex items-center justify-center ${G?"bg-slate-800 text-white border-slate-700 dark:bg-indigo-500/20 dark:text-indigo-300":"bg-[var(--bg-surface)] text-[var(--text-secondary)] border-[var(--border-color)] hover:bg-[var(--bg-elevated)]"}`,title:"Alternar panel de Recursos",children:(0,J.jsx)(Ke.Database,{className:"w-4 h-4"})}),(0,J.jsx)("button",{onClick:()=>se(!Z),className:`p-1.5 rounded-md border transition-colors flex items-center justify-center ${Z?"bg-slate-800 text-white border-slate-700 dark:bg-indigo-500/20 dark:text-indigo-300":"bg-[var(--bg-surface)] text-[var(--text-secondary)] border-[var(--border-color)] hover:bg-[var(--bg-elevated)]"}`,title:"Alternar panel de Pasos Aplicados",children:(0,J.jsx)(Ke.Layers,{className:"w-4 h-4"})}),(0,J.jsx)("div",{className:"w-px h-4 bg-[var(--border-color)] mx-1"}),(0,J.jsxs)("button",{onClick:()=>$(!0),disabled:or.length===0,className:"text-xs font-semibold px-3 py-1.5 rounded-md bg-purple-50 text-purple-700 border border-purple-200 hover:bg-purple-100 transition-colors flex items-center gap-2 disabled:opacity-50",children:[(0,J.jsx)(Ke.Plus,{className:"w-3.5 h-3.5"}),"Columna Calculada"]})]}),(0,J.jsx)("div",{children:(0,J.jsxs)("button",{onClick:()=>F(!0),className:"text-xs font-semibold px-3 py-1.5 rounded-md bg-[var(--bg-surface)] border border-[var(--border-color)] hover:bg-[var(--bg-elevated)] transition-colors flex items-center gap-2 text-[var(--text-primary)]",children:[(0,J.jsx)(Ke.Database,{className:"w-3.5 h-3.5"}),"Gestor de Plantillas"]})}),(0,J.jsx)("div",{children:(0,J.jsxs)("button",{onClick:()=>z(!0),className:"text-xs font-semibold px-3 py-1.5 rounded-md bg-amber-50 text-amber-700 border border-amber-200 hover:bg-amber-100 transition-colors flex items-center gap-2",children:[(0,J.jsx)(Ke.Clock,{className:"w-3.5 h-3.5"}),"Dataway Cron (Orchestrator)"]})}),(0,J.jsx)("div",{children:(0,J.jsxs)("button",{onClick:()=>W(!0),disabled:!u,className:"text-xs font-semibold px-3 py-1.5 rounded-md bg-indigo-50 text-indigo-700 border border-indigo-200 hover:bg-indigo-100 transition-colors flex items-center gap-2 disabled:opacity-50",children:[(0,J.jsx)(Ke.Network,{className:"w-3.5 h-3.5"}),"Mapa Relacional (ERD)"]})})]}),(0,J.jsxs)("div",{className:"flex-1 flex min-w-0 min-h-0 bg-[var(--bg-primary)]",children:[(0,J.jsx)(_u.AnimatePresence,{children:Z&&(0,J.jsx)(_u.motion.div,{initial:{width:0,opacity:0},animate:{width:256,opacity:1},exit:{width:0,opacity:0},transition:{duration:.2},className:"border-r border-[var(--border-color)] bg-[var(--bg-elevated)] flex flex-col min-h-0 shrink-0 overflow-hidden",children:(0,J.jsxs)("div",{className:"w-64 flex flex-col h-full",children:[(0,J.jsxs)("div",{className:"p-4 border-b border-[var(--border-color)] flex items-center justify-between",children:[(0,J.jsxs)("h3",{className:"text-xs font-bold text-[var(--text-primary)] uppercase tracking-wider flex items-center gap-2",children:[(0,J.jsx)(Ke.Layers,{className:"w-4 h-4 text-[var(--brand-primary)]"}),"Pasos Aplicados"]}),a.length>0&&(0,J.jsx)("button",{onClick:ln,className:"text-[var(--text-secondary)] hover:text-red-500 transition-colors",title:"Limpiar Pipeline",children:(0,J.jsx)(Ke.Trash2,{className:"w-4 h-4"})})]}),(0,J.jsxs)("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",children:[(0,J.jsxs)("div",{className:`p-3 rounded-lg border cursor-pointer transition-all text-sm mb-2 ${c===null?"border-[var(--brand-primary)] bg-[var(--brand-primary)]/10 text-[var(--brand-primary)]":"border-[var(--border-color)] hover:border-[var(--brand-primary)]/50 text-[var(--text-secondary)]"}`,onClick:()=>nt("source"),children:[(0,J.jsxs)("div",{className:"font-semibold flex items-center gap-2",children:[(0,J.jsx)(Ke.Database,{className:"w-4 h-4"}),"Origen de Datos"]}),(0,J.jsx)("div",{className:"text-[10px] opacity-70 mt-1 truncate",children:u||"Seleccione una tabla"})]}),a.map((ne,be)=>(0,J.jsxs)("div",{className:"flex flex-col relative",children:[(0,J.jsx)("div",{className:"absolute -top-3 left-4 h-3 w-px bg-[var(--border-color)]"}),(0,J.jsxs)("div",{className:`flex items-start justify-between p-3 rounded-lg border group cursor-pointer transition-all text-sm ${c===ne.id?"border-purple-500 bg-purple-50/50 text-purple-900 shadow-sm":"border-[var(--border-color)] hover:border-purple-300 text-[var(--text-secondary)] bg-[var(--bg-primary)]"}`,onClick:()=>nt(ne.id),children:[(0,J.jsxs)("div",{className:"min-w-0 pr-2",children:[(0,J.jsx)("div",{className:"font-semibold",children:ne.name}),(0,J.jsx)("div",{className:"text-[10px] opacity-70 mt-1 truncate font-mono",children:ne.script.length>30?ne.script.substring(0,30)+"...":ne.script})]}),(0,J.jsx)("button",{className:"opacity-0 group-hover:opacity-100 text-red-400 hover:text-red-600 transition-opacity p-1",onClick:me=>dr(me,ne.id),title:"Eliminar Paso",children:(0,J.jsx)(Ke.X,{className:"w-3.5 h-3.5"})})]})]},ne.id)),(0,J.jsx)("div",{className:"text-center pt-2",children:(0,J.jsx)("span",{className:"text-[10px] text-[var(--text-secondary)] font-medium",children:"Ejecuta c\xF3digo para a\xF1adir pasos"})}),C.length>0&&(0,J.jsxs)("div",{className:"mt-6 border-t border-[var(--border-color)] pt-4",children:[(0,J.jsxs)("h4",{className:"text-[10px] font-bold text-[var(--text-secondary)] uppercase tracking-wider mb-2 flex items-center justify-between",children:[(0,J.jsx)("span",{children:"Recursos Vinculados"}),(0,J.jsx)("span",{className:"bg-[var(--brand-primary)]/20 text-[var(--brand-primary)] px-1.5 py-0.5 rounded text-[9px]",children:C.length})]}),(0,J.jsx)("div",{className:"space-y-1.5",children:C.map((ne,be)=>(0,J.jsxs)("div",{className:"flex flex-col p-2 rounded-lg bg-[var(--bg-primary)] border border-[var(--border-color)] group",children:[(0,J.jsxs)("div",{className:"flex items-center justify-between",children:[(0,J.jsx)("span",{className:"text-xs font-bold text-[var(--text-primary)]",children:ne.boundName}),(0,J.jsx)("button",{onClick:()=>A(me=>me.filter(ue=>ue.boundName!==ne.boundName)),className:"opacity-0 group-hover:opacity-100 text-red-400 hover:text-red-600 transition-opacity p-0.5",title:"Remover Binding",children:(0,J.jsx)(Ke.X,{className:"w-3 h-3"})})]}),(0,J.jsxs)("div",{className:"text-[9px] text-[var(--text-secondary)] truncate flex items-center gap-1 mt-0.5",children:[(0,J.jsx)(Ke.Database,{className:"w-2.5 h-2.5"}),ne.connectorId," : ",ne.resource]})]},be))}),(0,J.jsx)("div",{className:"text-[9px] text-[var(--text-secondary)] mt-2 text-center opacity-70",children:"Utilizalos en Table.NestedJoin(...)"})]})]})]})})}),(0,J.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden p-6 flex flex-col relative",children:u?p==="dashboard"?(0,J.jsx)(AB,{data:je,columns:or}):(0,J.jsxs)("div",{className:"flex-1 min-w-0 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-2xl shadow-sm overflow-hidden flex flex-col relative",children:[(0,J.jsx)("div",{ref:pi,className:"overflow-auto flex-1 custom-scrollbar relative",children:(0,J.jsxs)("table",{className:"w-full text-left text-sm whitespace-nowrap",children:[(0,J.jsx)("thead",{className:"bg-[var(--bg-elevated)] sticky top-0 shadow-[0_1px_2px_rgba(0,0,0,0.05)]",style:{zIndex:10},children:(0,J.jsx)("tr",{children:or.map(ne=>{let be=je.length>0?je.find(ht=>ht[ne]!==null&&ht[ne]!==void 0)?.[ne]:null,me=be!=null&&!isNaN(Number(be))&&String(be).trim()!=="",ue=fo[ne];return(0,J.jsxs)("th",{className:"px-6 py-4 hover:bg-[var(--bg-surface)] transition-colors select-none relative group",children:[(0,J.jsxs)("div",{className:"flex flex-col gap-1 w-full",children:[(0,J.jsxs)("div",{className:`flex items-center gap-2 text-xs font-bold text-[var(--text-secondary)] uppercase tracking-wider cursor-pointer ${me?"justify-end":""}`,onClick:()=>B(O===ne?null:ne),children:[ne,(0,J.jsx)(Ke.ChevronDown,{className:`w-3.5 h-3.5 transition-transform ${O===ne?"rotate-180 text-[var(--brand-primary)]":"opacity-0 group-hover:opacity-100"}`})]}),ue&&(0,J.jsxs)("div",{className:"h-[3px] w-full bg-red-400 mt-0.5 flex overflow-hidden rounded-full opacity-70",title:`V\xE1lidos: ${ue.valid} | Vac\xEDos: ${ue.empty}`,children:[(0,J.jsx)("div",{className:"bg-green-500 h-full",style:{width:`${ue.valid/ue.total*100}%`}}),(0,J.jsx)("div",{className:"bg-gray-300 h-full",style:{width:`${ue.empty/ue.total*100}%`}})]})]}),O===ne&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>B(null)}),(0,J.jsxs)("div",{className:"absolute top-full left-4 mt-1 w-48 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-xl shadow-xl z-50 overflow-hidden flex flex-col py-1 animate-in fade-in zoom-in-95 duration-150",children:[(0,J.jsxs)("button",{onClick:()=>bn("sort",ne),className:"px-3 py-2 text-xs font-medium text-left hover:bg-[var(--bg-surface)] flex items-center gap-2 text-[var(--text-primary)]",children:[(0,J.jsx)(Ke.ArrowUpDown,{className:"w-3.5 h-3.5 opacity-70"})," Ordenar Ascendente"]}),(0,J.jsxs)("button",{onClick:()=>bn("filter",ne),className:"px-3 py-2 text-xs font-medium text-left hover:bg-[var(--bg-surface)] flex items-center gap-2 text-[var(--text-primary)]",children:[(0,J.jsx)(Ke.Filter,{className:"w-3.5 h-3.5 opacity-70"})," Filtrar Valor Exacto"]}),(0,J.jsx)("div",{className:"h-px bg-[var(--border-color)] my-1 w-full"}),(0,J.jsxs)("button",{onClick:()=>bn("group_sum",ne),className:"px-3 py-2 text-xs font-medium text-left hover:bg-[var(--bg-surface)] flex items-center gap-2 text-purple-600",children:[(0,J.jsx)(Ke.Layers,{className:"w-3.5 h-3.5 opacity-70"})," Agrupar y Sumar"]}),(0,J.jsx)("div",{className:"h-px bg-[var(--border-color)] my-1 w-full"}),(0,J.jsxs)("button",{onClick:()=>bn("rename",ne),className:"px-3 py-2 text-xs font-medium text-left hover:bg-[var(--bg-surface)] flex items-center gap-2 text-[var(--text-primary)]",children:[(0,J.jsx)(Ke.Edit2,{className:"w-3.5 h-3.5 opacity-70"})," Renombrar Columna"]}),(0,J.jsxs)("button",{onClick:()=>bn("remove",ne),className:"px-3 py-2 text-xs font-medium text-left hover:bg-red-50 text-red-600 flex items-center gap-2",children:[(0,J.jsx)(Ke.Trash2,{className:"w-3.5 h-3.5 opacity-70"})," Remover Columna"]}),(0,J.jsx)("div",{className:"h-px bg-[var(--border-color)] my-1 w-full"}),(0,J.jsxs)("button",{onClick:()=>bn("drop_nulls",ne),className:"px-3 py-2 text-xs font-medium text-left hover:bg-orange-50 text-orange-600 flex items-center gap-2",children:[(0,J.jsx)(Ke.Trash2,{className:"w-3.5 h-3.5 opacity-70"})," Eliminar filas vac\xEDas"]}),(0,J.jsxs)("button",{onClick:()=>bn("fill_nulls",ne),className:"px-3 py-2 text-xs font-medium text-left hover:bg-orange-50 text-orange-600 flex items-center gap-2",children:[(0,J.jsx)(Ke.Edit2,{className:"w-3.5 h-3.5 opacity-70"})," Rellenar vac\xEDos"]})]})]})]},ne)})})}),(0,J.jsx)("tbody",{className:"divide-y divide-[var(--border-color)] text-[var(--text-primary)] font-medium",children:je.length===0?(0,J.jsx)("tr",{children:(0,J.jsx)("td",{colSpan:or.length,className:"h-48 text-center text-[var(--text-secondary)]",children:x?(0,J.jsx)(Ke.Loader2,{className:"w-8 h-8 animate-spin mx-auto mb-2 text-[var(--brand-primary)]"}):(0,J.jsxs)("span",{children:["Genera una consulta o ajusta tu filtro (",we||"Vac\xEDo",")."]})})}):(0,J.jsxs)(J.Fragment,{children:[cn.length>0&&cn[0].start>0&&(0,J.jsx)("tr",{children:(0,J.jsx)("td",{style:{height:`${cn[0].start}px`}})}),cn.map(ne=>{let be=je[ne.index];return(0,J.jsx)("tr",{"data-index":ne.index,ref:ps.measureElement,className:"hover:bg-[var(--bg-surface)]/70 transition-colors",children:or.map(me=>{let ue=be[me],ht=ue!=null&&!isNaN(Number(ue))&&String(ue).trim()!=="";return(0,J.jsx)("td",{className:`px-6 py-3 max-w-[250px] truncate text-ellipsis ${ht?"text-right font-mono text-purple-700 font-semibold bg-purple-50/20":""}`,children:(0,J.jsx)("span",{title:String(ue),children:ue!=null?String(ue):(0,J.jsx)("span",{className:"text-gray-400 italic",children:"null"})})},me)})},ne.key)}),cn.length>0&&cn[cn.length-1].end<ps.getTotalSize()&&(0,J.jsx)("tr",{children:(0,J.jsx)("td",{style:{height:`${ps.getTotalSize()-cn[cn.length-1].end}px`}})})]})})]})}),(0,J.jsxs)("div",{className:"px-6 py-3 border-t border-[var(--border-color)] bg-[var(--bg-elevated)] text-xs font-semibold text-[var(--text-secondary)] flex justify-between items-center z-10",children:[(0,J.jsxs)("div",{className:"flex items-center gap-4",children:[(0,J.jsxs)("span",{children:["Total Records: ",je.length]}),(0,J.jsx)("div",{className:"h-4 w-px bg-[var(--border-color)]"}),(0,J.jsxs)("div",{className:"flex bg-[var(--bg-surface)] p-0.5 rounded-md border border-[var(--border-color)]",children:[(0,J.jsxs)("button",{onClick:()=>h("grid"),className:`px-3 py-1 flex items-center gap-1.5 rounded-md transition-colors ${p==="grid"?"bg-white shadow-sm text-[var(--brand-primary)]":"hover:text-[var(--text-primary)]"}`,children:[(0,J.jsx)(Ke.Table2,{className:"w-3.5 h-3.5"})," DataGrid"]}),(0,J.jsxs)("button",{onClick:()=>h("dashboard"),className:`px-3 py-1 flex items-center gap-1.5 rounded-md transition-colors ${p==="dashboard"?"bg-white shadow-sm text-[var(--brand-primary)]":"hover:text-[var(--text-primary)]"}`,disabled:je.length===0,children:[(0,J.jsx)(Ke.BarChart3,{className:"w-3.5 h-3.5"})," Graficar"]})]})]}),(0,J.jsxs)("div",{className:"flex items-center gap-4",children:[(0,J.jsx)("span",{className:"opacity-70",children:"Powered by Polars & Rust"}),(0,J.jsxs)("button",{onClick:Jn,disabled:je.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md hover:bg-[var(--border-color)] transition-colors text-[var(--text-primary)] disabled:opacity-50",title:"Descargar datos en pantalla como CSV",children:[(0,J.jsx)(Ke.Download,{className:"w-3.5 h-3.5"}),(0,J.jsx)("span",{children:"Exportar CSV"})]}),(0,J.jsxs)("button",{onClick:Ao,disabled:je.length===0||m,className:"flex items-center gap-1.5 px-4 py-1.5 rounded-lg bg-[var(--brand-primary)] hover:bg-[var(--brand-primary-hover)] transition-colors text-white font-bold disabled:opacity-50",title:"Empujar datos transformados a una tabla en Postgres",children:[m?(0,J.jsx)(Ke.Loader2,{className:"w-4 h-4 animate-spin"}):(0,J.jsx)(Ke.Server,{className:"w-4 h-4"}),(0,J.jsx)("span",{children:"Sync (Push)"})]})]})]}),L&&(0,J.jsx)(MB,{isOpen:L.isOpen,column:L.col,colType:L.type,onClose:()=>H(null),onApply:St}),(0,J.jsx)(PB,{isOpen:j,columns:or,onClose:()=>$(!1),onApply:mt}),(0,J.jsx)(RB,{isOpen:q,onClose:()=>F(!1),currentScript:K(a),activeConnector:e,activeResource:u,onLoadPipeline:he}),_&&u&&(0,J.jsx)(DB,{sourceConnector:e,sourceResource:u,targetConnector:"postgres",targetResource:"ventas",onClose:()=>W(!1)}),V&&(0,J.jsx)(OB,{onClose:()=>z(!1)})]}):(0,J.jsxs)("div",{className:"m-auto flex flex-col items-center justify-center opacity-40",children:[(0,J.jsx)(Ke.LayoutGrid,{className:"w-16 h-16 mb-4"}),(0,J.jsx)("h2",{className:"text-xl font-bold",children:"Sin Datos Activos"}),(0,J.jsx)("p",{className:"text-sm",children:"Selecciona o crea un Dataway."})]})})]})]}),(0,J.jsx)("style",{children:`
|
|
493
|
+
.custom-scrollbar::-webkit-scrollbar { width: 6px; height: 6px; }
|
|
494
|
+
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
|
|
495
|
+
.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
|
|
496
|
+
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
|
|
497
|
+
`})]})};var qS=[],BB=(0,LB.definePlugin)({manifest:{id:"macia-chameleon-agent",version:"2.1.0",name:"Madefront",description:"Proactive Intelligence & Liquid UI Engine",author:"Decido AI",permissions:["cortex:view","os:capture_screen"],intents:["chameleon-change-view"],widgets:[{id:"chameleon-kanban-view",name:"Madefront Kanban",defaultZone:"ide-editor",component:Fg},{id:"chameleon-ventas-view",name:"Ventas & Dise\xF1o",defaultZone:"ide-editor",component:WD},{id:"chameleon-caja-view",name:"Caja & Pagos",defaultZone:"ide-editor",component:UD},{id:"chameleon-planta-view",name:"Producci\xF3n",defaultZone:"ide-editor",component:GD},{id:"chameleon-despacho-view",name:"Log\xEDstica",defaultZone:"ide-editor",component:KD},{id:"chameleon-discovery-view",name:"Studio Admin",defaultZone:"ide-editor",component:g4},{id:"chameleon-sheet-view",name:"Vista Excel (Datos)",defaultZone:"ide-editor",component:Vg},{id:"chameleon-database-admin",name:"Database Admin (CRUD)",defaultZone:"ide-editor",component:b4},{id:"chameleon-dataway-studio",name:"Dataway M-Script Studio",defaultZone:"ide-editor",component:_B}],blueprints:[]},onMount:t=>{t.logger.log("Chameleon AI mounting..."),qS=[t.subscribeToEvent("intent:chameleon-change-view",r=>{let n=r?.matches;if(!n||!n[0])return;let o=n[0].toLowerCase(),s=i=>{t.callKernel("activate_plugin",{pluginId:i}).catch(a=>{t.logger.warn(`Failed to activate ${i}:`,a)})};o.includes("venta")&&s("cortex-omnichannel"),o.includes("caja")&&s("cortex-commander"),o.includes("planta")&&s("cortex-forge"),o.includes("admin")&&s("cortex-admin")})]},onUnmount:()=>{qS.forEach(t=>t()),qS=[],console.log("[Chameleon] Cleaned up \u2014 all subscriptions removed.")},onError:(t,e)=>{console.error(`[Chameleon] Error during ${e}:`,t)}});var En=require("react/jsx-runtime");(0,Al.registerManifestLoader)("sentinel-ui",async()=>({manifest:{...MR,baseUrl:"http://localhost:3333",iframeUrls:{"sentinel-telemetry":"/","sentinel-errors":"/errors","sentinel-replays":"/replays"}},iframeUrls:PR}));(0,Al.registerManifestLoader)("macia-chameleon-agent",async()=>({manifest:BB.manifest}));function th({aiProvider:t,VoiceWidget:e,config:r}={}){let n=X(w=>w.isBooting),o=X(w=>w.isSidebarOpen),s=X(w=>w.setIsSidebarOpen),i=X(w=>w.isCreatorMode),a=X(w=>w.creatorViewMode),l=X(w=>w.prototypeBrand),c=ke(w=>w.isImmersive),d=ke(w=>w.setIsImmersive);kR(),TR(),(0,zB.useTriggerRouter)();let{activeConfig:u}=Xh(r,l),{showCanvas:f}=Ed();AR();let p=(0,Al.useManifestRegistry)(w=>w.manifests),h=(0,Al.useManifestRegistry)(w=>w.loading),b=(0,Al.useManifestRegistry)(w=>w.syncWithRegistry),g=(0,Al.useManifestRegistry)(w=>w.getManifest);us.default.useEffect(()=>{let w=Object.values(p);if(w.length===0)return;mn.restoreFromPersistence(A=>{if(A.startsWith("sdui-")){let k=A.replace("sdui-","");for(let M of w){let T=M.widgets?.find(E=>E.id===k);if(T?.schema)return T.schema}}})&&mn.size>0&&ke.getState().setSlot("R3","widget-panel")},[p]);let x=(0,us.useCallback)((w,C,A)=>{let k=g(w);if(!k){console.warn(`[Plugin] No manifest loaded for ${w}`);return}console.log(`[Plugin] Opening widgets for ${w}:${C}`);let M=k.widgets?.find(E=>E.id===C);M?.schema&&mn.register({id:`sdui-${C}`,pluginId:w,title:`${A} (SDUI)`,icon:"\u{1F7E2}",slot:"tab",schema:M.schema,order:1});let T=k.iframeUrls?.[C];if(T!==void 0){let E=T.startsWith("http")?T:`${k.baseUrl||""}${T}`;mn.register({id:`iframe-${C}`,pluginId:w,title:`${A} (iframe)`,icon:"\u{1F535}",slot:"tab",url:E,order:2})}M?.component&&mn.register({id:`react-${C}`,pluginId:w,title:`${A}`,icon:"\u26A1",slot:"tab",component:M.component,order:3}),M?.schema?mn.setActive(`sdui-${C}`):M?.component?mn.setActive(`react-${C}`):mn.setActive(`iframe-${C}`),ke.getState().setSlot("R3","widget-panel")},[g]);(0,us.useEffect)(()=>{let w=A=>{let k=A.detail?.pluginId,M=A.detail?.view;if(k==="chameleon"){let T=A.detail?.viewId;T||(M==="discovery_admin"||M==="whatsapp_studio"?T="chameleon-discovery-view":M==="enterprise_kanban"?T="chameleon-kanban-view":T="chameleon-discovery-view"),x("macia-chameleon-agent",T,M||"WhatsApp Studio"),M&&setTimeout(()=>window.dispatchEvent(new CustomEvent("chameleon:set-view",{detail:{view:M}})),100)}},C=A=>{let k=A.detail?.view?.toLowerCase();k&&(k.includes("kanban")||k.includes("producci\xF3n")||k.includes("produccion")?x("macia-chameleon-agent","chameleon-kanban-view","Kanban de Producci\xF3n"):k.includes("excel")||k.includes("ventas")||k.includes("datos")?x("macia-chameleon-agent","chameleon-sheet-view","Google Sheets"):(k.includes("chat")||k.includes("whatsapp")||k.includes("studio")||k.includes("discovery"))&&x("macia-chameleon-agent","chameleon-discovery-view","WhatsApp Studio"))};return window.addEventListener("studio:open-plugin",w),window.addEventListener("studio:change-view",C),()=>{window.removeEventListener("studio:open-plugin",w),window.removeEventListener("studio:change-view",C)}},[x]);let y=us.default.useCallback(()=>{try{let w=localStorage.getItem("decido-plugin-registry-v10"),C=localStorage.getItem("decido-plugin-registry-v9"),A=w||C,k=[];A&&(k=JSON.parse(A)?.state?.registry||[]);let M=k.filter(T=>T.enabled).map(T=>({name:T.name,url:T.url||""}));return M.some(T=>T.name==="macia-chameleon-agent")||M.push({name:"macia-chameleon-agent",url:""}),M}catch(w){console.error("[ManifestRegistry] Error reading plugin registry:",w)}return[{name:"macia-chameleon-agent",url:""}]},[]),[m,v]=us.default.useState(y);(0,us.useEffect)(()=>{v(y());let w=()=>{let A=y();v(k=>JSON.stringify(k)===JSON.stringify(A)?k:A)};window.addEventListener("storage",w),window.addEventListener("focus",w);let C=setInterval(w,5e3);return()=>{window.removeEventListener("storage",w),window.removeEventListener("focus",w),clearInterval(C)}},[y]),(0,us.useEffect)(()=>{m.length>0&&b(m)},[m,b]);let S=(0,us.useMemo)(()=>{let w=[],C=Object.values(p);for(let A of C)if(m.some(M=>M.name===A.id||M.name.includes(A.id)||A.id.includes(M.name)))if(A.sidebarItems?.length){let M=new Map;for(let T of A.sidebarItems){let E=T.section||"default";M.has(E)||M.set(E,{title:T.sectionTitle||A.name,items:[]}),M.get(E).items.push(T)}for(let[T,E]of M)w.push({id:`plugin-${A.id}-${T}`,title:E.title,collapsible:!0,items:E.items.map(P=>({id:`${A.id}-${P.id}`,label:P.label,onClick:()=>{x(A.id,P.targetWidget||"",P.label)}}))})}else w.push({id:`plugin-${A.id}`,title:`\u{1F9E9} ${A.name}`,collapsible:!0,items:A.widgets.map(M=>({id:`${A.id}-${M.id}`,label:M.name,onClick:()=>x(A.id,M.id,M.name)}))});for(let A of h)w.push({id:`loading-${A}`,title:"\u23F3 Loading...",collapsible:!1,items:[{id:"loading",label:A,onClick:()=>{}}]});if(typeof window<"u"&&"__TAURI_INTERNALS__"in window&&w.push({id:"wasm-plugins",title:"\u26A1 WASM Plugins",collapsible:!0,items:[{id:"wasm-demo-math",label:"demo-math-plugin",onClick:()=>{mn.register({id:"wasm-demo-math",pluginId:"wasm-native",title:"Demo Math (WASM)",icon:"\u26A1",slot:"tab",scriptUrl:"wasm://demo-math-plugin/run",order:10}),mn.setActive("wasm-demo-math"),ke.getState().setSlot("R3","widget-panel")}}]}),w.length===0&&m.length>0)for(let A of m)!A.url&&!p[A.name]&&w.push({id:`plugin-${A.name}`,title:"\u{1F50C} Plugin Instalado",collapsible:!0,items:[{id:"info",label:A.name.substring(0,24),onClick:()=>{}}]});return console.log("[ManifestRegistry] Sidebar sections:",w.length,w.map(A=>A.title)),w},[p,m,x,h]);return(0,us.useEffect)(()=>{let w=ke.getState();w.slots?.R3!=="widget-panel"&&(i?w.setSlot("R3",a==="timeline"?"timeline-editor":"graph-editor"):w.setSlot("R3",null))},[i,a]),n?(0,En.jsx)(SR,{}):(0,En.jsxs)(En.Fragment,{children:[(0,En.jsx)(iC,{}),(0,En.jsxs)("div",{className:"h-full w-full bg-surface-primary flex font-sans relative overflow-hidden text-text-primary",children:[(0,En.jsx)("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E')] opacity-[0.15] mix-blend-overlay pointer-events-none z-0"}),(0,En.jsx)("div",{className:"md:hidden",children:(0,En.jsx)(bh,{isOpen:o,onClose:()=>s(!1),menuSections:S})}),(0,En.jsxs)("div",{className:"flex-1 flex h-full relative z-20",children:[(0,En.jsx)("div",{className:`hidden md:flex shrink-0 h-full transition-all duration-300 ease-in-out overflow-hidden bg-surface-secondary ${o&&!c?"w-[280px] min-w-[280px]":"w-0 min-w-0"}`,children:(0,En.jsx)(bh,{isOpen:o&&!c,onClose:()=>s(!1),menuSections:S})}),(0,En.jsxs)("div",{className:"flex-1 flex flex-col h-full min-w-0 overflow-hidden relative",children:[!c&&(0,En.jsx)(ju,{modelLabel:u?.greetingText||"yo.decido"}),c&&(0,En.jsx)("button",{onClick:()=>d(!1),className:"fixed top-3 right-3 z-900 px-3 py-1.5 rounded-full bg-surface-overlay backdrop-blur-md border border-border-default text-[10px] text-text-secondary hover:text-text-primary hover:bg-surface-overlay transition-all opacity-0 hover:opacity-100 focus:opacity-100",title:"Salir de modo inmersivo (\u2318\u21E7F)",children:"ESC \xB7 Salir inmersivo"}),(0,En.jsx)(wg,{slotProps:{aiProvider:t,VoiceWidget:e,config:r},children:(0,En.jsx)(nf,{})})]})]})]})]})}var Jc=require("react"),Zc=require("react-resizable-panels");ot();var $B=require("@decido/engine"),FB=require("@decido/engine");qh();var HB=require("@decido/engine");Mh();vx();ux();Ol();var VB=require("react"),uo=require("react/jsx-runtime");function YS({aiProvider:t,VoiceWidget:e,config:r,socketInstance:n,width:o="100%",height:s="100%"}){let{step:i,selectedProfile:a,isBooting:l,prototypeBrand:c,setInputValue:d}=X(),{resetEngine:u}=(0,$B.useEngineStore)(),f=(0,FB.useTimelineStore)(k=>k.setActiveTimeline),{demoState:p,showCanvas:h,setShowCanvas:b}=Ed(),g=(0,VB.useRef)(null),x=(0,Jc.useMemo)(()=>({id:`tape-${c}`,events:[{t:.1,event:{type:"SYSTEM_START"},description:"Arranque Autom\xE1tico (Player)"}]}),[c]),{isPlaying:y,setIsPlaying:m,resetSimulation:v}=(0,HB.usePlaybackSimulator)(x);(0,Jc.useEffect)(()=>{f(c),u(),v();let k=setTimeout(()=>m(!0),100);return()=>clearTimeout(k)},[c]);let S=r||{environments:{},voices:[]},w=S.environments[c]||Object.values(S.environments)[0]||{},[C,A]=(0,Jc.useState)([]);return(0,Jc.useEffect)(()=>{A(k=>{let M=w.suggestions||[];return JSON.stringify(k)===JSON.stringify(M)?k:M})},[w.suggestions]),(0,uo.jsx)(Dl,{socketInstance:n,isConnected:!!n?.connected,children:(0,uo.jsx)("div",{style:{width:o,height:s},className:"bg-surface-primary flex font-sans relative overflow-hidden text-text-primary rounded-xl border border-border-default shadow-lg",children:(0,uo.jsxs)(Zc.Group,{orientation:"horizontal",className:"flex-1 w-full h-full relative z-20",children:[(0,uo.jsx)(Zc.Panel,{id:"player-chat",defaultSize:h?60:100,minSize:30,className:"flex flex-col relative h-full bg-surface-primary",children:(0,uo.jsx)("div",{className:"flex-1 w-full relative z-20 overflow-hidden flex flex-col",children:(0,uo.jsx)(Ba,{fallbackName:"Motor de Chat (Player)",children:(0,uo.jsx)(Gu,{step:i,selectedProfile:a,authAvailableLicenses:[],handleProfileSelect:()=>{},activeConfig:w,demoState:p,suggestions:C,setInputValue:d,isGenerating:!1,config:S,isCreatorMode:!1,handleGeneratePlayground:async()=>{}})})})}),h&&(0,uo.jsxs)(uo.Fragment,{children:[(0,uo.jsx)(Zc.Separator,{className:"w-1.5 hover:bg-cyan-500/20 active:bg-cyan-500/30 transition-colors cursor-col-resize z-40 relative group flex items-center justify-center border-l-2 border-border-subtle"}),(0,uo.jsx)(Zc.Panel,{id:"player-canvas",defaultSize:40,minSize:20,className:"bg-surface-secondary h-full relative z-30 overflow-hidden",children:(0,uo.jsx)(Ba,{fallbackName:"Lienzo 3D (Player)",children:(0,uo.jsx)(tm,{showCanvas:h,setShowCanvas:b,activeConfig:w,prototypeBrand:c,activeState:p,chartData:[],dragConstraintsRef:g})})})]})]})})})}var rh=require("react"),O0=require("react-resizable-panels");var P0=require("react"),R0=require("motion/react"),D0=require("lucide-react");ix();var Jt=require("react/jsx-runtime"),jB=({messages:t,onSendMessage:e,isGenerating:r,agentName:n="Decido OS",themeBrand:o="decido"})=>{let s=(0,P0.useRef)(null);return(0,P0.useEffect)(()=>{s.current&&s.current.scrollTo({top:s.current.scrollHeight,behavior:"smooth"})},[t,r]),(0,Jt.jsxs)("div",{className:"flex flex-col h-full overflow-hidden w-full max-w-4xl mx-auto pb-4 relative",children:[(0,Jt.jsxs)("div",{ref:s,className:"flex-1 overflow-y-auto pr-4 custom-scrollbar scroll-smooth flex flex-col gap-6 pb-20 mt-8",children:[t.length===0&&(0,Jt.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,Jt.jsxs)("h1",{className:"text-3xl font-semibold leading-tight text-text-primary/50",children:[(0,Jt.jsx)("span",{className:"bg-gradient-to-r from-cyan-400 to-blue-500 text-transparent bg-clip-text",children:"Modo Agente Aut\xF3nomo"}),(0,Jt.jsx)("br",{}),"\xBFQu\xE9 vamos a construir en el Sandbox?"]}),(0,Jt.jsxs)("p",{className:"text-sm text-text-muted font-mono",children:["// ",n," conectado al demonio Rust (core-rust) con ejecuci\xF3n nativa."]})]}),t.map(i=>(0,Jt.jsxs)("div",{className:`flex flex-col gap-2 ${i.role==="user"?"items-end":"items-start"}`,children:[i.text&&(0,Jt.jsx)("div",{className:`p-4 rounded-2xl max-w-[85%] ${i.role==="user"?"bg-cyan-500/10 border border-cyan-500/20 text-cyan-50":i.role==="system"?"bg-orange-500/10 border border-orange-500/20 text-orange-200 font-mono text-xs":"bg-surface-tertiary border border-border-subtle text-text-primary"}`,children:i.text}),i.toolCalls&&i.toolCalls.map((a,l)=>(0,Jt.jsxs)("div",{className:"w-full max-w-[85%] bg-[#0d1117] border border-border-strong rounded-lg overflow-hidden my-2",children:[(0,Jt.jsxs)("div",{className:"flex items-center gap-2 bg-[#161b22] px-3 py-2 border-b border-border-strong",children:[(0,Jt.jsx)(D0.Terminal,{size:14,className:"text-slate-400"}),(0,Jt.jsx)("span",{className:"text-xs font-mono text-cyan-400 font-bold",children:a.name}),(0,Jt.jsx)("span",{className:"flex-1"}),(0,Jt.jsx)("span",{className:`text-[10px] uppercase font-bold px-2 py-0.5 rounded-full ${a.status==="running"?"bg-amber-500/20 text-amber-500 animate-pulse":a.status==="success"?"bg-emerald-500/20 text-emerald-500":a.status==="error"?"bg-red-500/20 text-red-500":"bg-slate-500/20 text-slate-500"}`,children:a.status})]}),(0,Jt.jsxs)("div",{className:"p-3",children:[(0,Jt.jsxs)("pre",{className:"text-[10px] font-mono text-slate-300 whitespace-pre-wrap break-words",children:[(0,Jt.jsx)("span",{className:"text-slate-500",children:"// Argumentos:"}),(0,Jt.jsx)("br",{}),JSON.stringify(a.args,null,2)]}),a.output&&(0,Jt.jsx)("div",{className:"mt-2 pt-2 border-t border-slate-800",children:(0,Jt.jsx)("pre",{className:"text-[10px] font-mono whitespace-pre-wrap break-words text-emerald-400/80",children:a.output.length>500?a.output.substring(0,500)+"... [TRUNCADO]":a.output})})]})]},l))]},i.id)),(0,Jt.jsx)(R0.AnimatePresence,{children:r&&(0,Jt.jsxs)(R0.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0},className:"flex gap-4 items-center",children:[(0,Jt.jsx)("div",{className:"w-8 h-8 rounded-full border border-cyan-500/30 flex items-center justify-center bg-cyan-500/10",children:(0,Jt.jsx)(D0.Sparkles,{size:14,className:"text-cyan-400 animate-pulse"})}),(0,Jt.jsx)("span",{className:"text-xs text-cyan-400/70 font-mono animate-pulse",children:"Razonando siguiente acci\xF3n..."})]})})]}),(0,Jt.jsx)("div",{className:"shrink-0 w-full px-4 pb-2 z-50",children:(0,Jt.jsx)(Th,{isGenerating:r,onSend:e,isVoiceActive:!1,setIsVoiceActive:()=>{},showCanvas:!1,setShowCanvas:()=>{},prototypeBrand:o,setPrototypeBrand:()=>{}})})]})};Ol();var Qc=require("react/jsx-runtime");function XS({socketInstance:t}){let[e,r]=(0,rh.useState)([]),[n,o]=(0,rh.useState)(!1);(0,rh.useEffect)(()=>{if(!t)return;let i=a=>{if(console.log("[AgentPlayer] Recibido orchestrator-event:",a),a.event_type==="AgentStreamEvent"&&a.data){let l=a.data,c=a.agent_id||"decido-agent";r(d=>{let u=d[d.length-1],f=u&&u.role==="agent"&&u.id===c,p=f?[...u.toolCalls||[]]:[],h=f?u.text:"";if(l.type==="Think"?h+=l.content:l.type==="ToolCall"?p.push({name:l.tool_name||"unknown_tool",args:l.tool_args||{},status:"running"}):l.type==="ToolResult"?p.length>0&&(p[p.length-1].status="success",p[p.length-1].output=l.content):l.type==="Message"&&(h+=l.content,o(!1)),f){let b=[...d];return b[b.length-1]={...u,text:h,toolCalls:p},b}else return[...d,{id:c,role:"agent",text:h,toolCalls:p}]})}else a.event_type==="SpawnAgentRequest"&&o(!0)};return t.on("orchestrator-event",i),()=>{t.off("orchestrator-event",i)}},[t]);let s=i=>{if(!i.trim()||!t)return;let a={id:Date.now().toString(),role:"user",text:i};r(l=>[...l,a]),o(!0),t.emit("rpc_call",{cmd:"send_message",args:{from:"AgentPlayerUI",to:"dev-master",intent:"chat_request",payload:i,priority:"High"}})};return(0,Qc.jsx)(Dl,{socketInstance:t,isConnected:!!t?.connected,children:(0,Qc.jsx)("div",{className:"bg-surface-primary flex font-sans relative overflow-hidden text-text-primary rounded-xl border border-border-default shadow-lg w-full h-[800px]",children:(0,Qc.jsx)(O0.Group,{orientation:"horizontal",className:"flex-1 w-full h-full relative z-20",children:(0,Qc.jsx)(O0.Panel,{id:"agent-chat",defaultSize:100,minSize:30,className:"flex flex-col relative h-full bg-surface-primary",children:(0,Qc.jsx)("div",{className:"flex-1 w-full relative z-20 overflow-hidden flex flex-col pt-4",children:(0,Qc.jsx)(jB,{messages:e,onSendMessage:s,isGenerating:n})})})})})})}var Aa=require("react");ot();var kJ={},JS={maxAttempts:3,initialDelay:500,maxDelay:3e4,retryableStatusCodes:[429,500,502,503]};function WB(t={}){let{model:e="gemini-flash-lite-latest",systemInstruction:r,maxRetries:n=JS.maxAttempts,initialRetryDelay:o=JS.initialDelay}=t,[s,i]=(0,Aa.useState)(!1),[a,l]=(0,Aa.useState)(null),c=(0,Aa.useRef)(null),d=X(h=>h.addChatMessage),u=(0,Aa.useCallback)(()=>localStorage.getItem("google_gemini_api_key")||kJ.env?.VITE_GEMINI_API_KEY||"",[]),f=(0,Aa.useCallback)(async h=>{let b=u();if(!b){l('No Gemini API key found. Set it in localStorage "google_gemini_api_key" or VITE_GEMINI_API_KEY.'),d({type:"error",sender:"system",text:'\u26A0\uFE0F No se encontr\xF3 API key de Gemini. Config\xFArala en localStorage como "google_gemini_api_key".'});return}i(!0),l(null),d({type:"text",sender:"user",text:h});let g=[],x=Date.now();g.push({type:"thinking",label:"Processing",startTime:x});let y=new AbortController;c.current=y;let m={...JS,maxAttempts:n,initialDelay:o};try{let v=`https://generativelanguage.googleapis.com/v1beta/models/${e}:streamGenerateContent?alt=sse&key=${b}`,S={contents:[{role:"user",parts:[{text:h}]}],generationConfig:{temperature:.7,maxOutputTokens:4096}};r&&(S.systemInstruction={parts:[{text:r}]});let w=null,C=m.initialDelay;for(let P=1;P<=m.maxAttempts&&!y.signal.aborted;P++)try{if(w=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S),signal:y.signal}),w.ok)break;if(m.retryableStatusCodes.includes(w.status)&&P<m.maxAttempts){g.push({type:"retry",label:`Retry ${P}/${m.maxAttempts} (HTTP ${w.status})`,startTime:Date.now()});let D=`retry-${Date.now()}`;X.getState().upsertChatMessage(D,{id:D,type:"alert",sender:"system",text:`\u{1F504} Reintentando (${P}/${m.maxAttempts})... HTTP ${w.status}`,timestamp:Date.now()}),await new Promise(R=>setTimeout(R,C)),C=Math.min(C*2,m.maxDelay),w=null;continue}let N=await w.text();throw new Error(`Gemini API error ${w.status}: ${N.slice(0,200)}`)}catch(N){if(N.name==="AbortError"||P>=m.maxAttempts)throw N;g.push({type:"retry",label:`Retry ${P}/${m.maxAttempts} (network)`,startTime:Date.now()}),await new Promise(D=>setTimeout(D,C)),C=Math.min(C*2,m.maxDelay)}if(!w||!w.ok)throw new Error("All retry attempts exhausted");g[0].endTime=Date.now();let A=Date.now();g.push({type:"text_delta",label:"Streaming",startTime:A});let k=w.body?.getReader();if(!k)throw new Error("No response body reader");let M=new TextDecoder,T="",E=`gemini-${Date.now()}`;for(;;){let{done:P,value:N}=await k.read();if(P)break;let R=M.decode(N,{stream:!0}).split(`
|
|
498
|
+
`);for(let O of R){if(!O.startsWith("data: "))continue;let B=O.slice(6).trim();if(!(!B||B==="[DONE]"))try{let H=JSON.parse(B)?.candidates?.[0];if(!H)continue;let j=H?.content?.parts?.[0]?.text;j&&(T+=j,X.getState().upsertChatMessage(E,{id:E,type:"text",sender:"agent",text:T,timestamp:Date.now(),executionSteps:[...g]})),H.finishReason&&H.finishReason!=="STOP"&&g.push({type:"text_complete",label:`Finished: ${H.finishReason}`,startTime:Date.now(),endTime:Date.now()})}catch{}}}if(!T.trim()&&!y.signal.aborted)return g.push({type:"retry",label:"Content retry (empty response)",startTime:Date.now()}),d({type:"alert",sender:"system",text:"\u{1F504} Respuesta vac\xEDa, reintentando..."}),i(!1),c.current=null,f(h);g[g.length-1].endTime??=Date.now(),g.push({type:"text_complete",label:"Complete",startTime:Date.now(),endTime:Date.now()}),X.getState().upsertChatMessage(E,{id:E,type:"text",sender:"agent",text:T,timestamp:Date.now(),executionSteps:g})}catch(v){v.name==="AbortError"?d({type:"alert",sender:"system",text:"\u23F9\uFE0F Generaci\xF3n cancelada por el usuario."}):(l(v.message),d({type:"error",sender:"system",text:`\u274C Error: ${v.message}`}))}finally{i(!1),c.current=null}},[e,r,n,o,u,d]),p=(0,Aa.useCallback)(()=>{c.current?.abort()},[]);return{sendMessage:f,abort:p,isStreaming:s,error:a}}ys();ot();Vl();mo();xi();Qn();Us();Fu();tx();gx();kx();hd();var XB=require("react");Ol();Qn();ot();ys();var JB=require("@decido/engine"),fs=require("@decido/core"),Ws=require("@decido/engine");var Wi=Re(require("react")),nh=require("motion/react"),Sr=require("lucide-react");Qn();ys();var UB=require("@decido/plugin-engine"),bt=require("react/jsx-runtime");function _0(){let[t,e]=Wi.default.useState(!1),[r,n]=Wi.default.useState(""),o=Wi.default.useRef(null),s=(0,UB.useManifestRegistry)(d=>d.manifests),i=Wi.default.useMemo(()=>{let d=[];return Object.values(s).forEach(u=>{u.widgets&&u.widgets.forEach(f=>{f.defaultZone==="overlay"&&f.component&&d.push({id:f.id,component:f.component})})}),d},[s]);(0,Wi.useEffect)(()=>{let d=u=>{(u.metaKey||u.ctrlKey)&&u.key==="k"&&(u.preventDefault(),e(f=>!f)),u.key==="Escape"&&t&&e(!1)};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[t]),(0,Wi.useEffect)(()=>{t&&o.current&&setTimeout(()=>o.current?.focus(),100)},[t]);let a=(0,Wi.useCallback)(d=>{e(!1),n("");let u=ke.getState();if(d.startsWith("slot:")){let[f,p,h]=d.split(":");u.setSlot(p,h||null);return}if(d.startsWith("preset:")){let f=d.split(":")[1];u.resetLayout(f);return}if(d==="open:omnichannel"){_t.getState().pushStage({id:`omni-${Date.now()}`,name:"Bandeja Omnicanal",shellType:"shell-omnichannel",data:{}});return}switch(d){case"toggle-creator":u.setIsCreatorMode(!u.isCreatorMode);break;case"toggle-sidebar":u.setIsSidebarOpen(!u.isSidebarOpen);break;case"toggle-canvas":u.setShowCanvas(!u.showCanvas);break;case"toggle-immersive":u.setIsImmersive(!u.isImmersive);break;case"reset-layout":u.resetLayout("player");break;default:break}},[]),l=[{id:"toggle-creator",label:"Toggle Creator Mode",shortcut:"\u2318\u21E7C",icon:(0,bt.jsx)(Sr.Command,{size:14}),category:"Modo"},{id:"toggle-sidebar",label:"Toggle Sidebar",shortcut:"\u2318B",icon:(0,bt.jsx)(Sr.ArrowRight,{size:14}),category:"Modo"},{id:"toggle-canvas",label:"Toggle Canvas",shortcut:"\u2318\u21E7V",icon:(0,bt.jsx)(Sr.Package,{size:14}),category:"Modo"},{id:"toggle-immersive",label:"Modo Inmersivo",shortcut:"\u2318\u21E7F",icon:(0,bt.jsx)(Sr.Maximize2,{size:14}),category:"Modo"},{id:"preset:creator",label:"Preset: Creator",shortcut:"",icon:(0,bt.jsx)(Sr.Layout,{size:14}),category:"Layout"},{id:"preset:player",label:"Preset: Player",shortcut:"",icon:(0,bt.jsx)(Sr.Layout,{size:14}),category:"Layout"},{id:"preset:minimal",label:"Preset: Minimal",shortcut:"",icon:(0,bt.jsx)(Sr.Layout,{size:14}),category:"Layout"},{id:"preset:studio",label:"Preset: Studio",shortcut:"",icon:(0,bt.jsx)(Sr.Layout,{size:14}),category:"Layout"},{id:"reset-layout",label:"Reset Layout",shortcut:"",icon:(0,bt.jsx)(Sr.RotateCcw,{size:14}),category:"Layout"},{id:"slot:R1:chat",label:"R1 \u2192 Chat",shortcut:"",icon:(0,bt.jsx)(Sr.Grid3X3,{size:14}),category:"Slots"},{id:"slot:R1:debug",label:"R1 \u2192 Debug",shortcut:"",icon:(0,bt.jsx)(Sr.Grid3X3,{size:14}),category:"Slots"},{id:"slot:R3:graph-editor",label:"R3 \u2192 Graph Editor",shortcut:"",icon:(0,bt.jsx)(Sr.Grid3X3,{size:14}),category:"Slots"},{id:"slot:R3:canvas",label:"R3 \u2192 Canvas",shortcut:"",icon:(0,bt.jsx)(Sr.Grid3X3,{size:14}),category:"Slots"},{id:"slot:R4:terminal",label:"R4 \u2192 Terminal",shortcut:"",icon:(0,bt.jsx)(Sr.Grid3X3,{size:14}),category:"Slots"},{id:"slot:R4:debug",label:"R4 \u2192 Debug",shortcut:"",icon:(0,bt.jsx)(Sr.Grid3X3,{size:14}),category:"Slots"},{id:"open:omnichannel",label:"Abrir Bandeja Omnicanal (WhatsApp)",shortcut:"",icon:(0,bt.jsx)(Sr.MessageSquare,{size:14}),category:"Herramientas"}],c=r?l.filter(d=>d.label.toLowerCase().includes(r.toLowerCase())):l;return(0,bt.jsxs)(bt.Fragment,{children:[(0,bt.jsx)(nh.AnimatePresence,{children:t&&(0,bt.jsxs)(bt.Fragment,{children:[(0,bt.jsx)(nh.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>e(!1),className:"fixed inset-0 bg-surface-overlay backdrop-blur-xs z-9998"}),(0,bt.jsxs)(nh.motion.div,{initial:{opacity:0,y:-20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed top-[15%] left-1/2 -translate-x-1/2 w-[540px] max-w-[90vw] z-9999
|
|
499
|
+
bg-surface-tertiary border border-border-default rounded-2xl shadow-2xl overflow-hidden`,children:[(0,bt.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border-subtle",children:[(0,bt.jsx)(Sr.Search,{size:18,className:"text-text-muted shrink-0"}),(0,bt.jsx)("input",{ref:o,value:r,onChange:d=>n(d.target.value),placeholder:"Buscar comandos, slots, plugins...",className:"flex-1 bg-transparent text-text-primary text-sm outline-hidden placeholder:text-text-muted"}),(0,bt.jsx)("kbd",{className:"text-[10px] text-text-muted bg-surface-glass px-1.5 py-0.5 rounded border border-border-default font-mono",children:"ESC"})]}),(0,bt.jsxs)("div",{className:"max-h-[300px] overflow-y-auto p-2",children:[c.map(d=>(0,bt.jsxs)("button",{onClick:()=>a(d.id),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-xl text-sm
|
|
500
|
+
text-text-secondary hover:text-text-primary hover:bg-surface-glass transition-colors group`,children:[(0,bt.jsx)("span",{className:`w-6 h-6 rounded-lg bg-surface-glass flex items-center justify-center
|
|
501
|
+
group-hover:bg-cyan-500/10 group-hover:text-cyan-400 transition-colors`,children:d.icon}),(0,bt.jsx)("span",{className:"flex-1 text-left",children:d.label}),d.shortcut&&(0,bt.jsx)("kbd",{className:"text-[10px] text-text-muted font-mono",children:d.shortcut})]},d.id)),c.length===0&&(0,bt.jsxs)("div",{className:"text-center py-8 text-text-muted text-sm",children:['No se encontraron comandos para "',r,'"']})]}),(0,bt.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-t border-border-subtle text-[10px] text-text-muted",children:[(0,bt.jsx)("span",{children:"\u2318K para abrir \xB7 ESC para cerrar"}),(0,bt.jsxs)("span",{className:"flex items-center gap-1",children:[(0,bt.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500/60"}),"Decido OS"]})]})]})]})}),i.map(d=>{let u=d.component;return(0,bt.jsx)(u,{},d.id)})]})}var GB=require("react");Qn();ot();Us();var ZS=require("@decido/engine");function KB(){(0,GB.useEffect)(()=>{let t=e=>{if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement)return;let r=e.metaKey||e.ctrlKey;if(r&&e.shiftKey&&e.code==="KeyC"){e.preventDefault();let n=ke.getState(),o=X.getState(),s=!n.isCreatorMode;n.setIsCreatorMode(s),o.setIsCreatorMode(s);return}if(r&&!e.shiftKey&&e.code==="KeyB"){e.preventDefault();let n=ke.getState(),o=X.getState(),s=!n.isSidebarOpen;n.setIsSidebarOpen(s),o.setIsSidebarOpen(s);return}if(r&&e.shiftKey&&e.code==="KeyV"){e.preventDefault();let n=ke.getState(),o=X.getState(),s=!n.showCanvas;n.setShowCanvas(s),o.setShowCanvas(s);return}if(r&&e.shiftKey&&e.code==="KeyX"){e.preventDefault();let n=ke.getState(),o=X.getState(),s=!n.showChat;n.setShowChat(s),o.setShowChat(s);return}if(r&&e.shiftKey&&e.code==="KeyF"){e.preventDefault();let n=ke.getState();n.setIsImmersive(!n.isImmersive);return}if(r&&e.shiftKey&&e.code==="KeyP"){e.preventDefault(),ke.getState().resetLayout("player");return}if(e.code==="Escape"&&ke.getState().isImmersive){e.preventDefault(),ke.getState().setIsImmersive(!1);return}if(r&&e.shiftKey&&e.code==="KeyD"){e.preventDefault(),Ut.getState().togglePanel();return}if(r&&e.key==="z"&&X.getState().isCreatorMode){e.preventDefault(),e.shiftKey?(ZS.useTimelineStore.getState().redo(),X.getState().addLog("Topolog\xEDa: Acci\xF3n Rehecha","info")):(ZS.useTimelineStore.getState().undo(),X.getState().addLog("Topolog\xEDa: Acci\xF3n Deshecha","info"));return}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[])}var oh=require("react/jsx-runtime"),qB=!1;function EJ(){qB||(qB=!0,(0,JB.registerUIBridge)({addLog:(t,e)=>X.getState().addLog(t,e),pushMorphStage:t=>{_t.getState().pushStage(t),ke.getState().pushStage(t)},clearMorphStages:()=>{_t.getState().clearStages(),ke.getState().clearStages()},showCanvas:t=>{X.getState().setShowCanvas(t),ke.getState().setShowCanvas(t)},setSidebarOpen:t=>{X.getState().setIsSidebarOpen(t),ke.getState().setIsSidebarOpen(t)},setDemoState:t=>X.getState().setDemoState(t),getActiveBrand:()=>X.getState().prototypeBrand,setActiveBrand:t=>X.getState().setPrototypeBrand(t),addChatMessage:t=>X.getState().addChatMessage(t),isMuted:()=>X.getState().isMuted,getSelectedVoice:()=>X.getState().selectedVoice}))}var YB=!1;function TJ(){YB||(YB=!0,fs.PluginRegistry.get("ai:dialogue")||fs.PluginRegistry.register(Ws.DialoguePlugin),fs.PluginRegistry.get("mcp:execute")||fs.PluginRegistry.register(Ws.LogicPlugin),fs.PluginRegistry.get("ui:state")||fs.PluginRegistry.register(Ws.UIStatePlugin),fs.PluginRegistry.get("core:subflow")||fs.PluginRegistry.register(Ws.SubflowPlugin),fs.PluginRegistry.get("core:return")||fs.PluginRegistry.register(Ws.EndSubflowPlugin),fs.PluginRegistry.get("ui:render")||fs.PluginRegistry.register(Ws.UIRendererPlugin))}function ZB({aiProvider:t,VoiceWidget:e,config:r,socketInstance:n,children:o,renderOverlays:s}){return EJ(),TJ(),KB(),(0,XB.useEffect)(()=>X.subscribe(a=>{let l=ke.getState();a.isCreatorMode!==l.isCreatorMode&&l.setIsCreatorMode(a.isCreatorMode),a.showCanvas!==l.showCanvas&&l.setShowCanvas(a.showCanvas),a.isSidebarOpen!==l.isSidebarOpen&&l.setIsSidebarOpen(a.isSidebarOpen)}),[]),(0,oh.jsxs)(Dl,{socketInstance:n,isConnected:!!n?.connected,children:[s?.(),(0,oh.jsx)(_0,{}),(0,oh.jsx)(th,{aiProvider:t,VoiceWidget:e,config:r,socketInstance:n}),o]})}im();wx();Gh();0&&(module.exports={AIDirector,AgentPlayer,AppHeader,AppShell,ArtifactBar,BUILT_IN_PRESETS,DebugPanel,DecidoPlayer,DecidoShell,EventBus,GlobalOverlays,LayoutConfigurator,LayoutGrid,MarketplaceWidget,McpToolsWidget,MorphShell,NetworkProvider,OpsDashboard,PanelSplitter,PluginErrorBoundary,SafeLiquidUI,ShellPluginProvider,SlotRenderer,THEME_DECIDO_DARK,THEME_DECIDO_LIGHT,THEME_EMERALD_NOIR,THEME_MIDNIGHT_BLUE,THEME_OLED_PURE,THEME_PRESETS,THEME_ROSE_GOLD,TabBar,TransientLayer,bridgeToMorph,detectShellType,getAvailableSlotComponents,getMorphComponent,getMorphComponentCompat,getRegisteredMorphComponents,getRegisteredShellTypes,getShellMeta,initBridgeAgent,isShellRegistered,registerMorphComponent,registerMorphComponentCompat,registerShell,registerSlotComponent,registerStore,resolveColor,resolveColorClasses,resolveIcon,resolveShell,useAutoUpdater,useDebugPanelStore,useGeminiStream,useIntentLens,useKeyboardShortcuts,useLayoutStore,useMcpStore,useMorphInstanceStore,useMorphologyStore,useNetwork,useNetworkEvent,usePlaygroundStore,usePluginContext,usePluginEngine,usePluginState,useShellKeyboard,useShellStore,useSystemBoot,useTheme,useUIComponentStore,useUpdaterStore,...require("@decido/shell-auth"),...require("@decido/plugin-engine")});
|
|
502
|
+
/*! Bundled license information:
|
|
503
|
+
|
|
504
|
+
@dagrejs/dagre/dist/dagre.esm.js:
|
|
505
|
+
(*! For license information please see dagre.esm.js.LEGAL.txt *)
|
|
506
|
+
*/
|