@yuriai/web 0.3.3-beta.7 → 0.3.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/assets/{AgentAvatar-BMyOvw1S.js → AgentAvatar-CHCjMxCF.js} +1 -1
- package/dist/assets/{AgentSelector-DjvFTge_.js → AgentSelector-uBoLtut8.js} +1 -1
- package/dist/assets/ArchivedSessionsDialog-DZcicxVO.js +1 -0
- package/dist/assets/{AssistantConversationSurface-CbB08eUc.js → AssistantConversationSurface-36aP0hRf.js} +3 -3
- package/dist/assets/{AssistantSessionCard-B5uaSamD.js → AssistantSessionCard-CZ-1oJiE.js} +2 -2
- package/dist/assets/{AssistantUnreadBadge-CrffD9Ox.js → AssistantUnreadBadge-p9mkpbMC.js} +1 -1
- package/dist/assets/{AssistantView-CWPh6KhU.js → AssistantView-8fyAae7J.js} +1 -1
- package/dist/assets/{AssistantWorkingAvatar-C7TLqC2c.js → AssistantWorkingAvatar-CoxhuMvM.js} +1 -1
- package/dist/assets/{AssistantsSettingsPage-CqUeZz_6.js → AssistantsSettingsPage-DD6spbXz.js} +1 -1
- package/dist/assets/{BinaryFileFallback-D85qP-k5.js → BinaryFileFallback-DgYaMG9f.js} +1 -1
- package/dist/assets/BtwPanel-BkobGcf3.js +6 -0
- package/dist/assets/BusyDots-COTTwItx.js +4 -0
- package/dist/assets/{ChatContainer-B7K4osTN.js → ChatContainer-BfQ7RXwY.js} +21 -21
- package/dist/assets/ChatView-ByMRjY1h.js +3 -0
- package/dist/assets/{DiagramView-DPUg5cMA.js → DiagramView-DGnmjS2b.js} +1 -1
- package/dist/assets/{DiffView-C6DEdXdm.js → DiffView-Bbit6OZ8.js} +1 -1
- package/dist/assets/{DiffViewToggle-BTeyGjzp.js → DiffViewToggle-BwJ6MYB7.js} +1 -1
- package/dist/assets/{ErrorBoundary-DtsSmzjn.js → ErrorBoundary-D7QcwhmL.js} +1 -1
- package/dist/assets/{FadeInOnReveal-CsCYrMAl.js → FadeInOnReveal-B3uT04YJ.js} +1 -1
- package/dist/assets/{GuiPluginMount-CivDyUvN.js → GuiPluginMount-TC5FELtQ.js} +1 -1
- package/dist/assets/{GuiPluginPage-BeFJN9rd.js → GuiPluginPage-BPjU8N49.js} +1 -1
- package/dist/assets/{GuiPluginSurface-C770Vmoc.js → GuiPluginSurface-CYPH6XzX.js} +1 -1
- package/dist/assets/{GuiPluginTitlebarItems-CjphhXcO.js → GuiPluginTitlebarItems-DxFINwbr.js} +1 -1
- package/dist/assets/{GuiPluginWindow-LOsErAXl.js → GuiPluginWindow-BkAFJyFd.js} +1 -1
- package/dist/assets/{Icon-BLvjcKMe.js → Icon-DmykXZL1.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-CepamQfa.js → ImageLoadingPlaceholder-DgM_EFHn.js} +1 -1
- package/dist/assets/{LoadingImage-CJQhmN6k.js → LoadingImage-Df22Rkor.js} +1 -1
- package/dist/assets/MarkdownRenderer-VvziwyJB.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-BBmjvHcO.js → MarkdownRendererImpl-D8q0FMnr.js} +2 -2
- package/dist/assets/{MarkstreamRendererImpl-BrUwQjka.js → MarkstreamRendererImpl-U_m_ZKG7.js} +1 -1
- package/dist/assets/{MobileAssistantSettingsPage-DBl7VNVJ.js → MobileAssistantSettingsPage-Dgq5FMho.js} +1 -1
- package/dist/assets/{MobileAssistantTab-BsxiOYep.js → MobileAssistantTab-CMIQansR.js} +1 -1
- package/dist/assets/{MobileBtwPage-CdFSaIWx.js → MobileBtwPage-DQUkSO6N.js} +1 -1
- package/dist/assets/{MobileChangesSurface-G84PMQ4F.js → MobileChangesSurface-DsYNmAuM.js} +1 -1
- package/dist/assets/{MobileChatScreen-BxkkAw15.js → MobileChatScreen-p356_BCN.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-DzmPZiX2.js → MobileDetailNavigation-ldTzGo19.js} +1 -1
- package/dist/assets/{MobileFilesSurface-CXb_s2LT.js → MobileFilesSurface-CF3EW_SK.js} +2 -2
- package/dist/assets/{MobileHtmlNetworkBoundary-Dnzk1vzw.js → MobileHtmlNetworkBoundary-DlPF4iPS.js} +2 -2
- package/dist/assets/{MobileOverlayPanel-Bqorq1sh.js → MobileOverlayPanel-C36VWWmN.js} +1 -1
- package/dist/assets/{MobileResizableSheet-DqBQmWZR.js → MobileResizableSheet-CqphcaKq.js} +1 -1
- package/dist/assets/{MobileSettingsTab-CtVgHZJU.js → MobileSettingsTab-DaTtRHo1.js} +1 -1
- package/dist/assets/{MobileShareBridge-BoZE2atm.js → MobileShareBridge-CZpFYmiy.js} +1 -1
- package/dist/assets/{MobileSurface-qkgXdsHc.js → MobileSurface-cmaGf3hZ.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-BcxLuIaE.js → MobileTabPageHeader-D6P4K98S.js} +1 -1
- package/dist/assets/{ModelLogo-DTkCJzj-.js → ModelLogo-BkbD514M.js} +1 -1
- package/dist/assets/{ModelSelector-BN7tJsu7.js → ModelSelector-EmtltPnd.js} +1 -1
- package/dist/assets/{MultiRunWindow-BOLguz2X.js → MultiRunWindow-CeSxAB8w.js} +1 -1
- package/dist/assets/{OnboardingScreen-C8BRto1e.js → OnboardingScreen-BubjTNcy.js} +1 -1
- package/dist/assets/{OverlayScrollbar-lHvfLKuz.js → OverlayScrollbar-D6vmoMkQ.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CW1R8hHt.js → PierreDiffViewer-DVKsdwJR.js} +1 -1
- package/dist/assets/{ProviderLogo-BcbWSLI8.js → ProviderLogo-DA98yu7M.js} +1 -1
- package/dist/assets/{RemoteAssistantSessionCard-B53bp3bD.js → RemoteAssistantSessionCard-DAoFvZht.js} +1 -1
- package/dist/assets/{RemoteDesktopPanel-DgiOjJIb.js → RemoteDesktopPanel-f3vRj4ZP.js} +1 -1
- package/dist/assets/{ScheduledTasksDialog-CgzzcaoZ.js → ScheduledTasksDialog-D_hBP47Y.js} +2 -2
- package/dist/assets/{ScrollableOverlay-By9Xj7Dt.js → ScrollableOverlay-stxT7gLf.js} +1 -1
- package/dist/assets/{SettingsGroup-HFyD41Fr.js → SettingsGroup-CvaPYznp.js} +1 -1
- package/dist/assets/{SettingsView-Dq1ykKpv.js → SettingsView-DEU94-h1.js} +10 -10
- package/dist/assets/{SettingsWindow-CIMjBpqt.js → SettingsWindow-DMVAV_el.js} +1 -1
- package/dist/assets/{SetupTourDialog-CMiSn6j9.js → SetupTourDialog-BlR7FJvd.js} +1 -1
- package/dist/assets/{SyncActions-CIrflsf0.js → SyncActions-CrOoREWF.js} +1 -1
- package/dist/assets/{TerminalView-CuvylS2B.js → TerminalView-Xcwp3SG1.js} +1 -1
- package/dist/assets/{TextSelectionMenu-Cu7FN5ja.js → TextSelectionMenu-h8iUeNzE.js} +1 -1
- package/dist/assets/{ToolOutputDialog-ph2fXE2y.js → ToolOutputDialog-DpaaQ1uZ.js} +1 -1
- package/dist/assets/{YuriLogo-Dh6Zy7-k.js → YuriLogo-Cp6vWDWp.js} +1 -1
- package/dist/assets/{assistantMessagePreview-CDi-qTU6.js → assistantMessagePreview-DLBvPQtq.js} +1 -1
- package/dist/assets/{assistantQueries-DlXx9G2k.js → assistantQueries-NdPqu6rx.js} +1 -1
- package/dist/assets/{auto-read-context-CgvMs7Ew.js → auto-read-context-ClBUErN2.js} +1 -1
- package/dist/assets/{capgoAdapter-LNbcqkI5.js → capgoAdapter-pfQJmvW2.js} +1 -1
- package/dist/assets/{card-DG0czc0D.js → card-DmysoUAV.js} +1 -1
- package/dist/assets/{chatUpwardIntent-PAbn9QBv.js → chatUpwardIntent-B2NrGMm-.js} +1 -1
- package/dist/assets/{checkbox-B6qJy2q5.js → checkbox-BMN5hAVm.js} +1 -1
- package/dist/assets/{collapsible-7JLOH-sI.js → collapsible-Z0IjDAMO.js} +1 -1
- package/dist/assets/{connection-hint-B5jzYxF5.js → connection-hint-B-kOWome.js} +1 -1
- package/dist/assets/{context-menu-DLkbq4VB.js → context-menu-CKlB6wxo.js} +1 -1
- package/dist/assets/{diagram-BjjqtBwW.js → diagram-CzY6n_4N.js} +1 -1
- package/dist/assets/{dialog-BjoDEvdt.js → dialog-BeFBA6ja.js} +1 -1
- package/dist/assets/{dropdown-menu-1XT-gOct.js → dropdown-menu-BblI9sN2.js} +1 -1
- package/dist/assets/{es-CgrPbaq2.js → es-DqYZgeC6.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-i5rR1buz.js → fileMentionTouchSelection-BQEUty_A.js} +1 -1
- package/dist/assets/{fr-B6DCYpJP.js → fr-BHaun7Zq.js} +1 -1
- package/dist/assets/{gitApi-D_jhXTt_.js → gitApi-CoVwjIDy.js} +1 -1
- package/dist/assets/{i18n-ByGlB3HF.js → i18n-DXc6czdR.js} +1 -1
- package/dist/assets/{icons-C-c38sK-.js → icons-Bd-INsoy.js} +1 -1
- package/dist/assets/{input-DCG7mwtP.js → input-Cf16qJ6g.js} +1 -1
- package/dist/assets/insertionBoundaries-Btqgsu1M.js +1 -0
- package/dist/assets/{ja-2cg_IC2I.js → ja-BGNugvrx.js} +1 -1
- package/dist/assets/{kbd-DUjBYHW8.js → kbd-CamdaxHJ.js} +1 -1
- package/dist/assets/{ko-Cu4ZaN5G.js → ko-CGbNBfDe.js} +1 -1
- package/dist/assets/main-CXH2hObl.js +169 -0
- package/dist/assets/{main-BBrAYdja.js → main-ClH7cLKr.js} +2 -2
- package/dist/assets/{markdownHeightCache-RG3lV4ki.js → markdownHeightCache-CHGGNhWI.js} +1 -1
- package/dist/assets/{mcpQueries-w3NIPhbC.js → mcpQueries-Rmp1BKeo.js} +1 -1
- package/dist/assets/miniChat-B_Bw6udu.js +2 -0
- package/dist/assets/{mobile-UvHaKFPy.js → mobile-BR73yoNi.js} +2 -2
- package/dist/assets/{mobileBackNavigation-4qLXJUZN.js → mobileBackNavigation-C94n2eLT.js} +1 -1
- package/dist/assets/{mobileConnections-Dpq17An0.js → mobileConnections-x07fHO_5.js} +2 -2
- package/dist/assets/multirun-CKQymP08.js +3 -0
- package/dist/assets/{native-config-DFjLIuqz.js → native-config-DVg8_Zx1.js} +1 -1
- package/dist/assets/{nativeComposerCover-CivHtrWS.js → nativeComposerCover-Bhv1EKPT.js} +1 -1
- package/dist/assets/{navigation-B_4E2p49.js → navigation-D1klsD7k.js} +1 -1
- package/dist/assets/{openRemoteProjectSession-DAER2JWb.js → openRemoteProjectSession-DNr74gHD.js} +1 -1
- package/dist/assets/{pl-7PeuQHGy.js → pl-k8-4URiE.js} +1 -1
- package/dist/assets/{pluginPresentation-BDGZINXk.js → pluginPresentation-DtyC8NF2.js} +2 -2
- package/dist/assets/{pt-BR-B18khyq7.js → pt-BR-DdwCzXBH.js} +1 -1
- package/dist/assets/pwa-CtDladgB.js +2 -0
- package/dist/assets/{queue-abort-optimistic-Coy1T1Qy.js → queue-abort-optimistic-DFbWDRKT.js} +1 -1
- package/dist/assets/{quota-CfWnlc-n.js → quota-CqWNkFzw.js} +1 -1
- package/dist/assets/{reference-history-BlQiy_nb.js → reference-history-IEuzG8KC.js} +1 -1
- package/dist/assets/{remoteSessionReference-CLzAvFKI.js → remoteSessionReference-ex07CtrZ.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-BqxpFP6D.js → renderElectronMiniChatApp-DM9y9qXo.js} +2 -2
- package/dist/assets/renderMobileApp-DqpPYtZI.js +17 -0
- package/dist/assets/{runtimeConfig-lcYYeoCg.js → runtimeConfig-CyvlrO58.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-CwRG2_aT.js → runtimeEndpointReset-C0zNrsI9.js} +4 -4
- package/dist/assets/{select-BjsrUiHl.js → select-vZCgcnYG.js} +1 -1
- package/dist/assets/{session-startup-barrier-BfAFvTz_.js → session-startup-barrier-DT-hIBRf.js} +1 -1
- package/dist/assets/{sessionLookup-C-6PgSD0.js → sessionLookup-DQOiycHr.js} +1 -1
- package/dist/assets/{sessionOwnership-QwBlmZrm.js → sessionOwnership-BjhXe6pi.js} +1 -1
- package/dist/assets/{shortcuts-kbr1xn9y.js → shortcuts-WkN3Gh8v.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-CitX5Org.js → sortable-tabs-strip-DmtfYPz0.js} +1 -1
- package/dist/assets/{speechSettingsQueries-BV_Pl_yS.js → speechSettingsQueries-BmkXNn4w.js} +1 -1
- package/dist/assets/src-QTj33Z0x.css +2 -0
- package/dist/assets/{store-CHWK-CqR.js → store-C1ifDY0C.js} +3 -3
- package/dist/assets/{switch-DiEXd4Rk.js → switch-CNmsFYfY.js} +1 -1
- package/dist/assets/{textarea-BXKtOkSw.js → textarea-ZiXxEOHK.js} +1 -1
- package/dist/assets/{timeFormat-CkKq2gbp.js → timeFormat-dCsf2MQv.js} +1 -1
- package/dist/assets/{tooltip-ccmDDb27.js → tooltip-CpTbxEOE.js} +1 -1
- package/dist/assets/{truncated-path-WQoHq84P.js → truncated-path-CcmWjgCQ.js} +1 -1
- package/dist/assets/types-DpcA-uDW.js +2 -0
- package/dist/assets/{ui-BBJAK87V.js → ui-ee2iN869.js} +12 -12
- package/dist/assets/{uk-B8oVVfyT.js → uk-DU-7fAP4.js} +1 -1
- package/dist/assets/{useAppFontEffects-Qz_MYSp2.js → useAppFontEffects-rbTKcF0f.js} +4 -4
- package/dist/assets/{useDesktopWindowControlsLayout-jzHx4r3Z.js → useDesktopWindowControlsLayout-BOkRz-p9.js} +1 -1
- package/dist/assets/{useDictation-DxbKP53d.js → useDictation-CZzAlsW0.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-BjJFgVDo.js → useEffectiveDirectory-DiJBIfai.js} +1 -1
- package/dist/assets/{useGitStore-__WQm2ss.js → useGitStore-Bv8xmXDa.js} +1 -1
- package/dist/assets/{useInlineCommentDraftStore-DDVhdall.js → useInlineCommentDraftStore-B2mkmAZd.js} +1 -1
- package/dist/assets/{useMcpConfigStore-B9xxBbIA.js → useMcpConfigStore-DKTl0PvE.js} +1 -1
- package/dist/assets/useMobileSwipeActions-XoxrtaUo.js +1 -0
- package/dist/assets/useMobileTranscriptSyncHint-DM8WG7kz.js +10 -0
- package/dist/assets/{useModelLists-BSDtEidb.js → useModelLists-Bf60FIJu.js} +1 -1
- package/dist/assets/{useOpenCodeReadiness-4gtPD0YS.js → useOpenCodeReadiness-Dm6BjA1T.js} +1 -1
- package/dist/assets/usePluginsStore-Du4WlceO.js +1 -0
- package/dist/assets/{useProjectGitActions-B4Gr0aOm.js → useProjectGitActions-D3B9ma9z.js} +1 -1
- package/dist/assets/{useProjectGitStore-YLxAq2tN.js → useProjectGitStore-DzU2pvrH.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-KvnGYSW7.js → useProjectRuntimeAPIs-tjGuODhu.js} +1 -1
- package/dist/assets/{useQuotaStore-BiF4Uh3a.js → useQuotaStore-CSn2pk3T.js} +1 -1
- package/dist/assets/{useSessionBtwStore-D0X_QY4j.js → useSessionBtwStore-CwvlMabN.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-n7T02P5g.js → useStreamingTextThrottle-C9SaKeil.js} +1 -1
- package/dist/assets/{worktreeManager-DG7xNQ2O.js → worktreeManager-DGu8M01Z.js} +1 -1
- package/dist/assets/{worktreeSourceBranchPreference-CkNHSsTL.js → worktreeSourceBranchPreference-CuLKwxkx.js} +1 -1
- package/dist/assets/{zh-CN-q5EBLCd8.js → zh-CN-DOHH7nht.js} +1 -1
- package/dist/assets/{zh-TW-B8dWtU1k.js → zh-TW-t1qlXGOg.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/mini-chat.html +6 -6
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
- package/dist/assets/ArchivedSessionsDialog-WPrvCBi1.js +0 -1
- package/dist/assets/BtwPanel-CtLW0udb.js +0 -6
- package/dist/assets/BusyDots-DbMzMIeN.js +0 -4
- package/dist/assets/ChatView-BFrPmZ4J.js +0 -3
- package/dist/assets/MarkdownRenderer-CSkl6FsA.js +0 -2
- package/dist/assets/insertionBoundaries-98_64UQf.js +0 -1
- package/dist/assets/main-BoXIEInN.js +0 -169
- package/dist/assets/miniChat-DsAFkq0l.js +0 -2
- package/dist/assets/multirun-Bzf-9V4P.js +0 -3
- package/dist/assets/pwa-ax7afoF2.js +0 -2
- package/dist/assets/renderMobileApp-CCZSPYop.js +0 -17
- package/dist/assets/src-CGjpov7O.css +0 -2
- package/dist/assets/types-C2asfTP5.js +0 -2
- package/dist/assets/useMobileSwipeActions-DAujwA-Y.js +0 -1
- package/dist/assets/useMobileTranscriptSyncHint-CI8AZGRi.js +0 -10
- package/dist/assets/usePluginsStore-BJYXkska.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-wXsskyKm.js";import{n as r}from"./vendor-react-BkccXcWz.js";import{r as i}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as a}from"./session-startup-barrier-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-wXsskyKm.js";import{n as r}from"./vendor-react-BkccXcWz.js";import{r as i}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as a}from"./session-startup-barrier-DT-hIBRf.js";import{n as o}from"./Icon-DmykXZL1.js";import{C as s,E as c,S as l,T as u,_ as d,a as f,b as p,c as m,d as h,f as g,g as _,h as v,i as y,l as b,m as x,n as S,o as C,p as w,r as T,s as E,t as D,u as O,v as k,w as A,x as j,y as M}from"./zhipuai-coding-plan-CcFj8zKy.js";var N=r(),P=e(n(),1),F=Object.assign({"../assets/provider-logos/anthropic.svg":c,"../assets/provider-logos/bailian-coding-plan.svg":u,"../assets/provider-logos/cursor.svg":A,"../assets/provider-logos/deepseek.svg":s,"../assets/provider-logos/evroc.svg":l,"../assets/provider-logos/github-copilot.svg":j,"../assets/provider-logos/gocode.svg":p,"../assets/provider-logos/google.svg":M,"../assets/provider-logos/kimi-for-coding.svg":k,"../assets/provider-logos/lmstudio.svg":d,"../assets/provider-logos/magpie.svg":_,"../assets/provider-logos/meta.svg":v,"../assets/provider-logos/minimax-cn-coding-plan.svg":x,"../assets/provider-logos/minimax-coding-plan.svg":w,"../assets/provider-logos/nano-gpt.svg":g,"../assets/provider-logos/ollama.svg":h,"../assets/provider-logos/openai.svg":O,"../assets/provider-logos/opencode.svg":b,"../assets/provider-logos/openrouter.svg":m,"../assets/provider-logos/qoder.svg":E,"../assets/provider-logos/trae.svg":C,"../assets/provider-logos/wafer.ai.svg":f,"../assets/provider-logos/workbuddy.svg":y,"../assets/provider-logos/xai.svg":T,"../assets/provider-logos/zai-coding-plan.svg":S,"../assets/provider-logos/zhipuai-coding-plan.svg":D}),I=new Map,L=new Set,R=new Map([[`codex`,`openai`],[`chatgpt`,`openai`],[`claude`,`anthropic`],[`gemini`,`google`],[`evroc-ai`,`evroc`],[`evrocai`,`evroc`],[`ollama-cloud`,`ollama`],[`opencode-go`,`opencode`],[`grok`,`xai`],[`supergrok`,`xai`],[`zcode`,`zai-coding-plan`],[`wafer-ai`,`wafer.ai`],[`wafer`,`wafer.ai`]]),z=e=>(e??``).toLowerCase().trim().replace(/^models\./,``).replace(/^provider\./,``).replace(/\s+/g,`-`),B=e=>{let t=e?.toLowerCase().includes(`magpie`)?[`magpie`]:[],n=e,r=e?.match(/^magpie:[^:]+:(.+)$/i);if(r)try{n=decodeURIComponent(r[1])}catch{return t}if(n&&/%[0-9a-f]{2}/i.test(n))try{n=decodeURIComponent(n)}catch{}let i=z(n);if(!i)return t;let a=i.replace(/[^a-z0-9_\-./:]/g,``),o=a.split(/[/:]/)[0]||a,s=[R.get(a),R.get(o),a,o].filter(e=>!!(e&&e.length>0));for(let e of i.split(/[^a-z0-9]+/)){let t=R.get(e)??e;I.has(t)&&s.push(t)}return[...new Set(s.filter(e=>e!==`magpie`)),...t]},V=e=>{let t=B(e).find(e=>I.has(e))??null;return t?I.get(t)??null:null},H=e=>{if(typeof Image>`u`)return;let t=V(e);if(!t||L.has(t))return;L.add(t);let n=new Image;n.decoding=`async`,n.onerror=()=>{L.delete(t)},n.src=t,n.decode?.().catch(()=>void 0)},U=e=>{for(let t of e)H(t)};for(let[e,t]of Object.entries(F)){let n=e.match(/provider-logos\/([^/]+)\.svg$/i);n?.[1]&&t&&I.set(n[1].toLowerCase(),t)}function W(e){let t=(0,N.c)(17),n,r,a;t[0]===e?(n=t[1],r=t[2],a=t[3]):(r=B(e).find(G)??null,n=!!r,a=r?I.get(r)??null:null,t[0]=e,t[1]=n,t[2]=r,t[3]=a);let o=a,[s,c]=(0,P.useState)(n?`local`:`none`),l;t[4]===n?l=t[5]:(l=()=>{c(n?`local`:`none`)},t[4]=n,t[5]=l);let u;t[6]!==n||t[7]!==r?(u=[n,r],t[6]=n,t[7]=r,t[8]=u):u=t[8],(0,P.useEffect)(l,u);let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{c(`none`)},t[9]=d):d=t[9];let f=i(d);if(!r){let e;return t[10]===f?e=t[11]:(e={src:null,onError:f,hasLogo:!1},t[10]=f,t[11]=e),e}if(s===`local`&&o){let e;return t[12]!==f||t[13]!==o?(e={src:o,onError:f,hasLogo:!0},t[12]=f,t[13]=o,t[14]=e):e=t[14],e}let p;return t[15]===f?p=t[16]:(p={src:null,onError:f,hasLogo:!1},t[15]=f,t[16]=p),p}function G(e){return I.has(e)}var K=t(),q=e=>{let t=(0,N.c)(4),{className:n}=e,r;t[0]===n?r=t[1]:(r=a(`text-muted-foreground`,n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,K.jsx)(o,{name:`stack`,className:r}),t[2]=r,t[3]=i),i},J=e=>{let t=(0,N.c)(19),{providerId:n,alt:r,className:i,onError:o}=e,{src:s,onError:c,hasLogo:l}=W(n),[u,d]=P.useState(!1),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{d(!1)},t[0]=f):f=t[0];let p;t[1]===s?p=t[2]:(p=[s],t[1]=s,t[2]=p),P.useEffect(f,p);let m,h;if(t[3]!==o||t[4]!==c||t[5]!==s?(m=()=>{if(!s||typeof Image>`u`)return;let e=!1,t=new Image;return t.onerror=()=>{e||(d(!0),c(),o?.())},t.src=s,()=>{e=!0}},h=[s,c,o],t[3]=o,t[4]=c,t[5]=s,t[6]=m,t[7]=h):(m=t[6],h=t[7]),P.useEffect(m,h),!l||!s||u){let e;return t[8]===i?e=t[9]:(e=(0,K.jsx)(q,{className:i}),t[8]=i,t[9]=e),e}let g=r||`${n} logo`,_;t[10]===i?_=t[11]:(_=a(`inline-block shrink-0 bg-foreground`,i),t[10]=i,t[11]=_);let v=`url("${s}") center / contain no-repeat`,y=`url("${s}") center / contain no-repeat`,b;t[12]!==v||t[13]!==y?(b={mask:v,WebkitMask:y},t[12]=v,t[13]=y,t[14]=b):b=t[14];let x;return t[15]!==g||t[16]!==_||t[17]!==b?(x=(0,K.jsx)(`span`,{role:`img`,"aria-label":g,className:_,style:b,draggable:!1}),t[15]=g,t[16]=_,t[17]=b,t[18]=x):x=t[18],x};export{U as n,J as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ot as e}from"./vendor-base-ui-wXsskyKm.js";import{n as t}from"./vendor-react-BkccXcWz.js";import{s as n}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{
|
|
1
|
+
import{ot as e}from"./vendor-base-ui-wXsskyKm.js";import{n as t}from"./vendor-react-BkccXcWz.js";import{s as n}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{qn as r}from"./ui-ee2iN869.js";import{m as i,p as a}from"./remoteProjectQueries-C8382jM8.js";import{n as o}from"./AssistantSessionCard-CZ-1oJiE.js";var s=t(),c=e();function l(e){let t=(0,s.c)(10),{card:i,entry:a,liveSession:l,liveType:u}=e,d;t[0]!==i.directory||t[1]!==a?(d=r(i.directory,void 0,void 0,void 0,a),t[0]=i.directory,t[1]=a,t[2]=d):d=t[2];let f=n(d),p;t[3]===f.data?.current?p=t[4]:(p=f.data?.current?.trim()||null,t[3]=f.data?.current,t[4]=p);let m;return t[5]!==i||t[6]!==l||t[7]!==u||t[8]!==p?(m=(0,c.jsx)(o,{card:i,liveSession:l,liveType:u,branch:p}),t[5]=i,t[6]=l,t[7]=u,t[8]=p,t[9]=m):m=t[9],m}function u({card:e}){let{catalog:t,registry:n}=i(!0),r=e.target,s=t?.hubId===r.hubId,u=a(s?n:void 0,r.hostId),d;try{s&&n&&(d=n.resolve({...r,directory:e.directory}))}catch{}let f=d?u.data?.directories.find(t=>t.directory===e.directory)?.sessions.find(t=>t.id===e.sessionID):void 0,p=u.data?.stale?void 0:(f?.metadata)?.yuri?.sessionStatus?.type;return d?(0,c.jsx)(l,{card:e,entry:d,liveSession:f,liveType:p},JSON.stringify(d.queryScope)):(0,c.jsx)(o,{card:e,branch:null})}export{u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{p as t}from"./runtime-auth-DA-qfGHk.js";import{c as n,f as r,i,n as a}from"./runtime-switch-DEPKHgdL.js";import{n as o}from"./runtime-fetch-V-iMWR8t.js";import{it as s,ot as c,st as l}from"./vendor-base-ui-wXsskyKm.js";import{xt as u}from"./gitApiHttp-Dd-FwgCq.js";import{n as d}from"./vendor-react-BkccXcWz.js";import{s as f}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{i as p,m,r as h}from"./vendor-reactuses-core-DjKFMfz7.js";import{a as g,n as _}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{i as v}from"./session-startup-barrier-BfAFvTz_.js";import{n as y}from"./Icon-BLvjcKMe.js";import{t as b}from"./i18n-ByGlB3HF.js";import{t as x}from"./tap-LkQum5bB.js";import{n as S,t as C}from"./mobileBackNavigation-4qLXJUZN.js";import{t as w}from"./input-DCG7mwtP.js";import{a as T}from"./nativeComposerCover-CivHtrWS.js";import{n as E}from"./touch-gestures-DOoBxhz5.js";var D=e(l(),1),O=e(s(),1);function k(e){let t=!1,r=0,o=0,s=!1,c,l,u,d=()=>e.transport===i()&&e.generation===a(),f=()=>document.visibilityState===`hidden`,p=()=>{o++;let e=c;c=void 0,clearTimeout(l),l=void 0,e?.close()},m=n=>{t||(t=!0,p(),x(),window.removeEventListener(`online`,_),window.removeEventListener(`pageshow`,y),window.removeEventListener(`yuri:system-resume`,v),document.removeEventListener(`visibilitychange`,b),e.onState(`closed`,n))},h=()=>{if(t||f())return;let e=navigator.onLine===!1||u===`permission_required`?6e4:Math.min(1e3*2**Math.min(r++,5),3e4);l=setTimeout(()=>{l=void 0,g()},e)},g=()=>{if(t||c||f())return;if(!d()){m(`runtime_changed`);return}if(clearTimeout(l),l=void 0,navigator.onLine===!1){h();return}let n=++o;c=A({...e,onState:(i,a)=>{if(!(t||n!==o)){if(i===`closed`){if(c=void 0,u=a,!a||[`runtime_changed`,`disabled`,`unsupported`,`helper_unavailable`,`authentication_required`,`permission_denied`].includes(a)){m(a);return}e.onState(i,a),h();return}(i===`webrtc`||i===`tunnel`)&&(r=0,u=void 0),e.onState(i,a)}}}),c.setZoomed(s)},_=()=>{!t&&!f()&&!c&&g()},v=()=>{t||(p(),_())},y=e=>{e.persisted&&v()},b=()=>{f()?(p(),e.onState(`connecting`,void 0)):_()},x=n(()=>m(`runtime_changed`));return window.addEventListener(`online`,_),window.addEventListener(`pageshow`,y),window.addEventListener(`yuri:system-resume`,v),document.addEventListener(`visibilitychange`,b),g(),{send:e=>{!t&&d()&&c?.send(e)},close:()=>m(),setZoomed:e=>{s=e,c?.setZoomed(e)}}}function A(e){let n=!1,o,s,c=!1,l,d,f=setTimeout(()=>D(`connection_failed`),6e4),p,m=Date.now(),h,g,_=!1,v=!1,y=!1,b=(t,n)=>{(h!==t||g!==n)&&(h=t,g=n,e.onState(t,n))},x=Promise.resolve(),S=0,C=[],w=()=>!n&&e.transport===i()&&e.generation===a(),T=e=>{if(!(!w()||o?.readyState!==1))try{o.send(JSON.stringify(e))}catch{D(`connection_failed`)}},E=()=>{!_||v===y||!w()||o?.readyState!==1||(T({type:`view`,zoomed:v}),y=v)},D=t=>{if(n)return;let r=w()&&o?.readyState===1;if(n=!0,r)try{o.send(JSON.stringify({type:`release`}))}catch{}clearInterval(d),clearTimeout(f),clearTimeout(p),o&&(o.onopen=null,o.onmessage=null,o.onerror=null,o.onclose=null,o.close()),s?.close();let i=e.video.srcObject;i instanceof MediaStream&&i.getTracks().forEach(e=>e.stop()),e.video.srcObject=null,e.video.onloadeddata=null,e.image.onload=null,e.image.onerror=null,e.image.removeAttribute(`src`),l&&URL.revokeObjectURL(l),b(`closed`,t)},O=()=>{!w()||c||(c=!0,s?.close(),clearTimeout(p),p=setTimeout(()=>D(`connection_failed`),15e3),T({type:`fallback`}))},k=async t=>{if(!w())return;if(m=Date.now(),t instanceof ArrayBuffer){if(t.byteLength>524288){D(`connection_failed`);return}l&&URL.revokeObjectURL(l),l=URL.createObjectURL(new Blob([t],{type:`image/jpeg`})),e.image.onload=()=>{w()&&(clearTimeout(f),clearTimeout(p),e.onSize(e.image.naturalWidth,e.image.naturalHeight),b(`tunnel`),T({type:`ack`}))},e.image.onerror=()=>D(`connection_failed`),e.image.src=l;return}let n=JSON.parse(t);if(n.type===`error`){D(typeof n.code==`string`?n.code:`connection_failed`);return}if(n.type===`ready`)_=n.zoomQuality===!0,E(),Number.isFinite(n.width)&&Number.isFinite(n.height)&&e.onSize(n.width,n.height);else if(n.type===`offer`&&!c){if(s||typeof n.sdp!=`string`||n.sdp.length>65536)throw Error(`invalid_offer`);if(typeof RTCPeerConnection>`u`){O();return}s=new RTCPeerConnection({iceServers:Array.isArray(n.iceServers)?n.iceServers:[]}),s.onicecandidate=e=>{e.candidate&&T({type:`ice`,candidate:e.candidate.toJSON()})},s.onconnectionstatechange=()=>{(s?.connectionState===`failed`||s?.connectionState===`disconnected`)&&O()},s.ontrack=t=>{w()&&(e.video.srcObject=new MediaStream([t.track]),e.video.onloadeddata=()=>{!w()||c||(clearTimeout(f),clearTimeout(p),e.onSize(e.video.videoWidth,e.video.videoHeight),b(`webrtc`))},e.video.play().catch(O))},await s.setRemoteDescription({type:`offer`,sdp:n.sdp});for(let e of C.splice(0))await s.addIceCandidate(e);if(await s.setLocalDescription(await s.createAnswer()),!w()||c)return;p=setTimeout(O,7e3),T({type:`answer`,sdp:s.localDescription?.sdp})}else n.type===`ice`&&n.candidate&&!c?s?.remoteDescription?await s.addIceCandidate(n.candidate):C.length<128&&C.push(n.candidate):n.type===`rtc-failed`&&O()};return b(`connecting`),(async()=>{try{if(await t(),!w())return;o=u(r().websocket(`/api/remote-desktop/ws`)),o.binaryType=`arraybuffer`,o.onopen=()=>{w()&&(m=Date.now(),d=setInterval(()=>{if(!w()){D(`runtime_changed`);return}if(Date.now()-m>3e4){D(`connection_failed`);return}T({type:`ping`})},5e3))},o.onmessage=e=>{if(w()){if(++S>128){D(`connection_failed`);return}x=x.then(()=>k(e.data)).catch(O).finally(()=>{S--})}},o.onerror=()=>D(`connection_failed`),o.onclose=e=>D(e.code===4001?`authentication_required`:`connection_failed`)}catch{D(`connection_failed`)}})(),{send:e=>T(e),close:D,setZoomed:e=>{v=e,E()}}}var j={scale:1,x:0,y:0};function M(e){let t=Math.min(e.width/e.remoteWidth,e.height/e.remoteHeight),n=e.remoteWidth*t,r=e.remoteHeight*t;return{width:n,height:r,x:(e.width-n)/2,y:(e.height-r)/2}}function N(e,t,n){if(t.width<=0||t.height<=0||t.remoteWidth<=0||t.remoteHeight<=0)return null;let r=M(t),i=((e.x-n.x)/n.scale-r.x)/r.width,a=((e.y-n.y)/n.scale-r.y)/r.height;return i>=0&&i<=1&&a>=0&&a<=1?{x:i,y:a}:null}function P(e,t,n=1){let r=Math.max(n,Math.min(5,e.scale)),i=M(t),a=(e,t,n,i)=>n*r<=i?(i-n*r)/2-t*r:Math.max(i-(t+n)*r,Math.min(-t*r,e));return{scale:r,x:a(e.x,i.x,i.width,t.width),y:a(e.y,i.y,i.height,t.height)}}function ee(e){let t=new Map,n={...j},r=null,i=null,a=!1,o=!1,s=!1,c=!1,l,u=null,d=0,f=null,p=()=>{a&&e.send({type:`release`}),a=!1},m=()=>{(n.scale!==1||n.x!==0||n.y!==0)&&(n={...j},e.apply(n,!0))},h=()=>{clearTimeout(l),p(),t.clear(),f=null,r=i=null,s=!1,u=null,n.scale<=1&&m()},g=()=>{let[e,n]=[...t.values()];return{midpoint:{x:(e.x+n.x)/2,y:(e.y+n.y)/2},distance:Math.max(1,Math.hypot(e.x-n.x,e.y-n.y))}},_={down(a,m){t.size>=2||(t.set(a,m),t.size===1&&(r=i=m,o=!1,s=!1,c=!1,d=Date.now(),e.mode()===`cursor`&&(l=setTimeout(()=>{let t=N(m,e.viewport(),n);t&&!o&&!s&&(e.send({type:`pointer`,action:`right`,...t}),c=!0)},550))),t.size===2&&(clearTimeout(l),s=!0,u=null,p(),f={...g(),transform:{...n}}))},move(d,p){if(t.has(d)){if(t.set(d,p),t.size===2&&f){let{midpoint:t,distance:r}=g(),i=Math.max(.5,Math.min(5,f.transform.scale*r/f.distance)),a=i/f.transform.scale;n=P({scale:i,x:t.x-(f.midpoint.x-f.transform.x)*a,y:t.y-(f.midpoint.y-f.transform.y)*a},e.viewport(),.5),e.apply(n);return}if(!(s||c||!r||!i)&&(Math.hypot(p.x-r.x,p.y-r.y)>6&&(o=!0,u=null,clearTimeout(l)),o)){if(e.mode()===`drag`)n={...n,x:n.x+p.x-i.x,y:n.y+p.y-i.y},e.apply(n);else{let t=N(p,e.viewport(),n);if(t){let i=N(r,e.viewport(),n);!a&&i&&(e.send({type:`pointer`,action:`down`,...i}),a=!0),a&&e.send({type:`pointer`,action:`move`,...t})}}i=p}}},moveMany(e){let n;for(let[r,i]of e)t.has(r)&&(t.set(r,i),n=[r,i]);n&&_.move(...n)},up(a,h,g=!1){if(t.has(a)){if(clearTimeout(l),t.delete(a),e.mode()===`cursor`&&!g&&!s&&!o&&!c){let t=N(h,e.viewport(),n);t&&e.send({type:`pointer`,action:`click`,...t})}if(e.mode()===`drag`&&!g&&!s&&!o&&Date.now()-d<450){let t=Date.now(),r={x:h.x,y:h.y,time:t};if(x(u,r)){if(n.scale>1)n={...j};else{let t=2.5,r=t/n.scale;n=P({scale:t,x:h.x-(h.x-n.x)*r,y:h.y-(h.y-n.y)*r},e.viewport())}e.apply(n,!0),u=null}else u=r}else u=null;p(),t.size||(f=null,r=i=null,s=!1,n.scale<=1&&m())}},cancel:h,refit(){if(n.scale<=1){m();return}n=P(n,e.viewport()),e.apply(n)},reset(){h(),n={...j},e.apply(n)}};return _}function F(e,t,n){return n===90?{x:e.y-t.top,y:t.right-e.x}:n===-90?{x:t.bottom-e.y,y:e.x-t.left}:{x:e.x-t.left,y:e.y-t.top}}var I=d(),L=g(`YuriOrientation`);function R(){return _.isNativePlatform()&&_.isPluginAvailable(`YuriOrientation`)}function z(e){return L.lock({orientation:e})}function te(e){let t=(0,I.c)(14),[n,r]=(0,D.useState)(G),[i]=(0,D.useState)(W),[a,o]=(0,D.useState)(i),[s]=(0,D.useState)(R),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{let[t]=e;if(!t)return;let{width:n,height:i}=t.contentRect;n>0&&i>0&&r(e=>e.width===n&&e.height===i?e:{width:n,height:i})},t[0]=c):c=t[0],m(e,c);let l,u;t[1]!==s||t[2]!==a?(l=()=>{s&&z(a).catch(U)},u=[s,a],t[1]=s,t[2]=a,t[3]=l,t[4]=u):(l=t[3],u=t[4]),(0,D.useEffect)(l,u);let d,f;t[5]===s?(d=t[6],f=t[7]):(d=()=>{if(s)return V},f=[s],t[5]=s,t[6]=d,t[7]=f),(0,D.useEffect)(d,f);let p=!s&&a!==i,h=p?90:0,g=p?n.height:n.width,_=p?n.width:n.height,v;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>o(B),t[8]=v):v=t[8];let y;return t[9]!==a||t[10]!==h||t[11]!==g||t[12]!==_?(y={orientation:a,rotation:h,width:g,height:_,toggle:v},t[9]=a,t[10]=h,t[11]=g,t[12]=_,t[13]=y):y=t[13],y}function B(e){return e===`portrait`?`landscape`:`portrait`}function V(){z(`portrait`).catch(H)}function H(){}function U(){}function W(){return window.innerWidth>window.innerHeight?`landscape`:`portrait`}function G(){return{width:window.innerWidth,height:window.innerHeight}}var K=(e,t)=>({queryKey:[e,`remote-desktop`,t],queryFn:async({signal:n})=>{let r=()=>{if(e!==i()||t!==a())throw Error(`runtime_changed`)};r();let s=new AbortController,c=()=>s.abort();n.addEventListener(`abort`,c,{once:!0}),n.aborted&&c();let l;try{return await Promise.race([(async()=>{let e=await o(`/api/remote-desktop`,{signal:s.signal,headers:{Accept:`application/json`}});if(r(),[401,403].includes(e.status))throw Error(`authentication_required`);if([404,501].includes(e.status))throw Error(`unsupported`);if(!e.ok)throw Error(`connection_failed`);if(!e.headers.get(`content-type`)?.includes(`application/json`))throw Error(`unsupported`);let t=await e.json();if(r(),!t||typeof t!=`object`||!(`supported`in t)||typeof t.supported!=`boolean`)throw Error(`unsupported`);return{supported:t.supported,enabled:`enabled`in t&&t.enabled===!0}})(),new Promise((e,t)=>{l=setTimeout(()=>{c(),t(Error(`connection_failed`))},1e4)})])}finally{clearTimeout(l),n.removeEventListener(`abort`,c)}},staleTime:3e4,retry:!1,refetchInterval:e=>{let t=e.state.error;return!t||[`unsupported`,`runtime_changed`,`authentication_required`].includes(t.message)?!1:Math.min(1e3*2**Math.min(Math.max(0,e.state.errorUpdateCount-1),5),3e4)},refetchIntervalInBackground:!1}),ne=(e,t)=>{let n=(0,I.c)(3),r;return n[0]!==t||n[1]!==e?(r=K(e,t),n[0]=t,n[1]=e,n[2]=r):r=n[2],f(r)},q=c(),re=[{key:`Escape`,icon:`corner-up-left`},{key:`Tab`,icon:`arrow-right-to-line`},{key:`Backspace`,icon:`delete-back`},{key:`Enter`,icon:`corner-down-left`},{key:`ArrowLeft`,icon:`arrow-left`},{key:`ArrowUp`,icon:`arrow-up`},{key:`ArrowDown`,icon:`arrow-down`},{key:`ArrowRight`,icon:`arrow-right`}];function ie({onClose:e,instanceName:t}){let{t:n}=b(),[r]=D.useState(()=>({transport:i(),generation:a()})),o=ne(r.transport,r.generation),[s,c]=D.useState(0),[l,u]=D.useState(`connecting`),[d,f]=D.useState(),[g,_]=D.useState(`drag`),[x,A]=D.useState(!1),[j,M]=D.useState(``),N=D.useRef(null),P=D.useRef(null),I=te(P),L=D.useRef(null),R=D.useRef(null),z=D.useRef(null),B=D.useRef({width:1,height:1,remoteWidth:1920,remoteHeight:1080}),V=D.useRef(null),H=D.useRef(null),U=D.useRef(new Map),W=D.useRef(new Set),G=D.useRef(!1),K=h(e=>{V.current?.send(e)}),ie=h(()=>g),[J]=D.useState(()=>ee({viewport:()=>B.current,send:K,mode:ie,apply:(e,t)=>{let n=e.scale>(G.current?1.01:1.05);n!==G.current&&(G.current=n,V.current?.setZoomed(n)),L.current&&(L.current.style.transition=t&&!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`transform 180ms ease-out`:`none`,L.current.style.transform=`translate(${e.x}px, ${e.y}px) scale(${e.scale})`)}})),Y=h(()=>{if(H.current!==null&&cancelAnimationFrame(H.current),H.current=null,U.current.size&&N.current){let e=N.current.getBoundingClientRect(),t=new Map([...U.current].map(([t,n])=>[t,F(n,e,I.rotation)]));J.moveMany(t)}U.current.clear()}),ae=h(()=>{Y(),J.reset(),V.current?.close(),V.current=null}),oe=h(()=>{ae(),e()});S({id:`remote-desktop-page`,active:!0,layer:`root`,onBack:oe,surfaceRef:P}),D.useEffect(()=>T(`remote-desktop-page`),[]),D.useLayoutEffect(()=>{let e=document.activeElement;return P.current?.focus({preventScroll:!0}),()=>{e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),p(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),C.requestBrowserBack())},()=>document);let se=h((e,t)=>{(e===`closed`||e===`connecting`)&&(U.current.clear(),W.current.clear(),J.cancel()),u(e),f(t)}),ce=h((e,t)=>{if(e<=0||t<=0||B.current.remoteWidth===e&&B.current.remoteHeight===t)return;let n=B.current;B.current={...n,remoteWidth:e,remoteHeight:t},!(Math.abs(n.remoteWidth/n.remoteHeight-e/t)<.01)&&!W.current.size&&J.reset()});m(N,([e])=>{if(!e)return;let{width:t,height:n}=e.contentRect,r=Math.abs(B.current.width-t)>=1||Math.abs(B.current.height-n)>=1;B.current={...B.current,width:t,height:n},r&&!W.current.size&&J.refit()}),E(N),D.useEffect(()=>{if(!o.data?.supported||!o.data.enabled||!R.current||!z.current)return;let e=k({...r,video:R.current,image:z.current,onSize:ce,onState:se});return V.current=e,e.setZoomed(G.current),()=>{e.close(),V.current=null}},[o.data?.supported,o.data?.enabled,r,s,ce,se]),D.useEffect(()=>()=>{Y(),J.reset()},[Y,J]);let X=e=>{let t=N.current.getBoundingClientRect();return F({x:e.clientX,y:e.clientY},t,I.rotation)},Z=l===`webrtc`||l===`tunnel`,Q=o.data?.supported===!1||o.error?.message===`unsupported`,$=o.data?.supported===!0&&o.data.enabled!==!0,le=Q||d===`helper_unavailable`?n(`remoteDesktop.unsupported`):$||d===`disabled`?n(`settings.remoteDesktop.disabled`):d===`permission_required`?n(`remoteDesktop.permissions`):d===`permission_denied`?n(`remoteDesktop.denied`):d===`runtime_changed`||o.error?.message===`runtime_changed`?n(`remoteDesktop.runtimeChanged`):d||o.error||l===`closed`?n(`remoteDesktop.failed`):n(`remoteDesktop.connecting`);return(0,O.createPortal)((0,q.jsx)(`div`,{ref:P,tabIndex:-1,"data-remote-desktop-page":!0,className:`yuri-keyboard-inset-surface yuri-keyboard-inset-snap fixed inset-0 z-[150] overflow-clip bg-background text-foreground outline-none`,children:(0,q.jsxs)(`main`,{"aria-label":t?`${n(`remoteDesktop.title`)} · ${t}`:n(`remoteDesktop.title`),className:`absolute left-0 top-0 flex flex-col overflow-clip bg-background`,style:{width:I.width,height:I.height,transformOrigin:`top left`,"--desktop-safe-top":`env(safe-area-inset-${I.rotation===90?`right`:I.rotation===-90?`left`:`top`}, 0px)`,"--desktop-safe-right":`env(safe-area-inset-${I.rotation===90?`bottom`:I.rotation===-90?`top`:`right`}, 0px)`,"--desktop-safe-bottom":`env(safe-area-inset-${I.rotation===90?`left`:I.rotation===-90?`right`:`bottom`}, 0px)`,"--desktop-safe-left":`env(safe-area-inset-${I.rotation===90?`top`:I.rotation===-90?`bottom`:`left`}, 0px)`,transform:I.rotation===90?`translateX(${I.height}px) rotate(90deg)`:I.rotation===-90?`translateY(${I.width}px) rotate(-90deg)`:void 0},children:[(0,q.jsxs)(`div`,{"data-remote-desktop-stage-region":!0,className:`relative min-h-0 flex-1 overflow-clip`,children:[(0,q.jsxs)(`div`,{ref:N,className:`absolute inset-0 touch-none overflow-clip bg-background`,"aria-label":n(`remoteDesktop.screen`),onPointerDown:e=>{Z&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),W.current.add(e.pointerId),Y(),J.down(e.pointerId,X(e)))},onPointerMove:e=>{!Z||!W.current.has(e.pointerId)||(e.preventDefault(),U.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),H.current===null&&(H.current=requestAnimationFrame(Y)))},onPointerUp:e=>{Y(),J.up(e.pointerId,X(e)),W.current.delete(e.pointerId),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:e=>{Y(),J.up(e.pointerId,X(e),!0),W.current.delete(e.pointerId)},onContextMenu:e=>e.preventDefault(),children:[(0,q.jsxs)(`div`,{ref:L,className:`absolute inset-0 origin-top-left will-change-transform`,children:[(0,q.jsx)(`video`,{ref:R,autoPlay:!0,muted:!0,playsInline:!0,className:`pointer-events-none absolute inset-0 size-full object-contain`,style:{visibility:l===`webrtc`?`visible`:`hidden`}}),(0,q.jsx)(`img`,{ref:z,alt:n(`remoteDesktop.screen`),draggable:!1,className:`pointer-events-none absolute inset-0 size-full object-contain`,style:{visibility:l===`tunnel`?`visible`:`hidden`}})]}),!Z&&(0,q.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-4 p-6 text-center text-sm text-muted-foreground`,role:`status`,children:[l===`connecting`&&!d&&!o.error&&!Q&&!$&&(0,q.jsx)(y,{name:`loader-4`,className:`size-5 animate-spin`}),(0,q.jsx)(`p`,{children:le}),(l===`closed`||o.error||$)&&!Q&&d!==`runtime_changed`&&o.error?.message!==`runtime_changed`&&(0,q.jsx)(v,{onClick:()=>{ae(),f(void 0),u(`connecting`),o.error||$?o.refetch():c(e=>e+1)},children:n(`remoteDesktop.retry`)})]})]}),(0,q.jsxs)(`div`,{className:`pointer-events-none absolute left-[max(0.75rem,var(--desktop-safe-left))] right-[max(0.75rem,var(--desktop-safe-right))] top-[max(0.75rem,var(--desktop-safe-top))] flex items-start justify-between gap-3`,children:[(0,q.jsx)(v,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto`,"aria-label":n(`header.actions.backAria`),onClick:()=>C.requestBrowserBack(),children:(0,q.jsx)(y,{name:`arrow-left`,className:`size-5`})}),(0,q.jsx)(v,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto`,"aria-label":n(`remoteDesktop.rotate`),title:n(`remoteDesktop.rotate`),onClick:()=>{Y(),J.reset(),A(!1),I.toggle()},children:(0,q.jsx)(y,{name:`smartphone`,className:`size-5 rotate-45`})})]}),(0,q.jsx)(`p`,{className:`sr-only`,children:n(`remoteDesktop.hint`)}),(0,q.jsx)(`div`,{className:`pointer-events-none absolute left-[max(0.75rem,var(--desktop-safe-left))] right-[max(0.75rem,var(--desktop-safe-right))] bottom-[max(0.75rem,var(--desktop-safe-bottom))] top-[calc(4rem+var(--desktop-safe-top))] flex flex-col items-end justify-end gap-3`,children:(0,q.jsxs)(`div`,{className:`flex w-full shrink-0 items-end justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`pointer-events-auto flex gap-3`,children:[(0,q.jsx)(v,{size:`mobileIcon`,variant:`mobileGlass`,className:g===`drag`?`yuri-mobile-inverse-action`:void 0,"aria-label":n(`remoteDesktop.drag`),title:n(`remoteDesktop.drag`),"aria-pressed":g===`drag`,disabled:!Z,onClick:()=>{Y(),J.cancel(),_(`drag`)},children:(0,q.jsx)(y,{name:`hand`,className:`size-5`})}),(0,q.jsx)(v,{size:`mobileIcon`,variant:`mobileGlass`,className:g===`cursor`?`yuri-mobile-inverse-action`:void 0,"aria-label":n(`remoteDesktop.cursor`),title:n(`remoteDesktop.cursor`),"aria-pressed":g===`cursor`,disabled:!Z,onClick:()=>{Y(),J.cancel(),_(`cursor`)},children:(0,q.jsx)(y,{name:`cursor`,className:`size-5`})})]}),(0,q.jsx)(v,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto${x?` yuri-mobile-inverse-action`:``}`,disabled:!Z,"aria-label":n(`remoteDesktop.text`),title:n(`remoteDesktop.text`),"aria-pressed":x,"aria-expanded":x,onClick:()=>A(e=>!e),children:(0,q.jsx)(y,{name:`keyboard`,className:`size-5`})})]})})]}),x&&(0,q.jsxs)(`footer`,{"data-remote-desktop-keyboard":!0,className:`max-h-[50%] w-full shrink-0 overflow-y-auto overscroll-contain border-t border-border bg-[var(--surface-elevated)] pt-3 pl-[max(0.75rem,var(--desktop-safe-left))] pr-[max(0.75rem,var(--desktop-safe-right))] pb-[max(0.75rem,var(--desktop-safe-bottom))]`,children:[(0,q.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),j&&Z&&(K({type:`text`,text:j}),M(``))},children:[(0,q.jsx)(w,{className:`min-w-0 flex-1`,value:j,maxLength:1024,onChange:e=>M(e.target.value),placeholder:n(`remoteDesktop.text`),"aria-label":n(`remoteDesktop.text`),disabled:!Z,autoComplete:`off`}),(0,q.jsx)(v,{type:`submit`,size:`icon`,disabled:!Z||!j,"aria-label":n(`remoteDesktop.send`),children:(0,q.jsx)(y,{name:`send-plane-2`,className:`size-4`})})]}),(0,q.jsx)(`div`,{className:`mt-2 grid grid-cols-4 gap-1 min-[360px]:grid-cols-8`,children:re.map(({key:e,icon:t})=>(0,q.jsx)(v,{size:`icon`,variant:`ghost`,className:`w-full`,disabled:!Z,onClick:()=>K({type:`key`,key:e}),"aria-label":n(`remoteDesktop.pressKey`,{key:e}),title:n(`remoteDesktop.pressKey`,{key:e}),children:(0,q.jsx)(y,{name:t,className:`size-4`})},e))})]})]})}),document.body)}var J=D.memo(ie);export{J as RemoteDesktopPanel};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{p as t}from"./runtime-auth-DA-qfGHk.js";import{c as n,f as r,i,n as a}from"./runtime-switch-DEPKHgdL.js";import{n as o}from"./runtime-fetch-V-iMWR8t.js";import{it as s,ot as c,st as l}from"./vendor-base-ui-wXsskyKm.js";import{xt as u}from"./gitApiHttp-Dd-FwgCq.js";import{n as d}from"./vendor-react-BkccXcWz.js";import{s as f}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{i as p,m,r as h}from"./vendor-reactuses-core-DjKFMfz7.js";import{a as g,n as _}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{i as v}from"./session-startup-barrier-DT-hIBRf.js";import{n as y}from"./Icon-DmykXZL1.js";import{t as b}from"./i18n-DXc6czdR.js";import{t as x}from"./tap-LkQum5bB.js";import{n as S,t as C}from"./mobileBackNavigation-C94n2eLT.js";import{t as w}from"./input-Cf16qJ6g.js";import{a as T}from"./nativeComposerCover-Bhv1EKPT.js";import{n as E}from"./touch-gestures-DOoBxhz5.js";var D=e(l(),1),O=e(s(),1);function k(e){let t=!1,r=0,o=0,s=!1,c,l,u,d=()=>e.transport===i()&&e.generation===a(),f=()=>document.visibilityState===`hidden`,p=()=>{o++;let e=c;c=void 0,clearTimeout(l),l=void 0,e?.close()},m=n=>{t||(t=!0,p(),x(),window.removeEventListener(`online`,_),window.removeEventListener(`pageshow`,y),window.removeEventListener(`yuri:system-resume`,v),document.removeEventListener(`visibilitychange`,b),e.onState(`closed`,n))},h=()=>{if(t||f())return;let e=navigator.onLine===!1||u===`permission_required`?6e4:Math.min(1e3*2**Math.min(r++,5),3e4);l=setTimeout(()=>{l=void 0,g()},e)},g=()=>{if(t||c||f())return;if(!d()){m(`runtime_changed`);return}if(clearTimeout(l),l=void 0,navigator.onLine===!1){h();return}let n=++o;c=A({...e,onState:(i,a)=>{if(!(t||n!==o)){if(i===`closed`){if(c=void 0,u=a,!a||[`runtime_changed`,`disabled`,`unsupported`,`helper_unavailable`,`authentication_required`,`permission_denied`].includes(a)){m(a);return}e.onState(i,a),h();return}(i===`webrtc`||i===`tunnel`)&&(r=0,u=void 0),e.onState(i,a)}}}),c.setZoomed(s)},_=()=>{!t&&!f()&&!c&&g()},v=()=>{t||(p(),_())},y=e=>{e.persisted&&v()},b=()=>{f()?(p(),e.onState(`connecting`,void 0)):_()},x=n(()=>m(`runtime_changed`));return window.addEventListener(`online`,_),window.addEventListener(`pageshow`,y),window.addEventListener(`yuri:system-resume`,v),document.addEventListener(`visibilitychange`,b),g(),{send:e=>{!t&&d()&&c?.send(e)},close:()=>m(),setZoomed:e=>{s=e,c?.setZoomed(e)}}}function A(e){let n=!1,o,s,c=!1,l,d,f=setTimeout(()=>D(`connection_failed`),6e4),p,m=Date.now(),h,g,_=!1,v=!1,y=!1,b=(t,n)=>{(h!==t||g!==n)&&(h=t,g=n,e.onState(t,n))},x=Promise.resolve(),S=0,C=[],w=()=>!n&&e.transport===i()&&e.generation===a(),T=e=>{if(!(!w()||o?.readyState!==1))try{o.send(JSON.stringify(e))}catch{D(`connection_failed`)}},E=()=>{!_||v===y||!w()||o?.readyState!==1||(T({type:`view`,zoomed:v}),y=v)},D=t=>{if(n)return;let r=w()&&o?.readyState===1;if(n=!0,r)try{o.send(JSON.stringify({type:`release`}))}catch{}clearInterval(d),clearTimeout(f),clearTimeout(p),o&&(o.onopen=null,o.onmessage=null,o.onerror=null,o.onclose=null,o.close()),s?.close();let i=e.video.srcObject;i instanceof MediaStream&&i.getTracks().forEach(e=>e.stop()),e.video.srcObject=null,e.video.onloadeddata=null,e.image.onload=null,e.image.onerror=null,e.image.removeAttribute(`src`),l&&URL.revokeObjectURL(l),b(`closed`,t)},O=()=>{!w()||c||(c=!0,s?.close(),clearTimeout(p),p=setTimeout(()=>D(`connection_failed`),15e3),T({type:`fallback`}))},k=async t=>{if(!w())return;if(m=Date.now(),t instanceof ArrayBuffer){if(t.byteLength>524288){D(`connection_failed`);return}l&&URL.revokeObjectURL(l),l=URL.createObjectURL(new Blob([t],{type:`image/jpeg`})),e.image.onload=()=>{w()&&(clearTimeout(f),clearTimeout(p),e.onSize(e.image.naturalWidth,e.image.naturalHeight),b(`tunnel`),T({type:`ack`}))},e.image.onerror=()=>D(`connection_failed`),e.image.src=l;return}let n=JSON.parse(t);if(n.type===`error`){D(typeof n.code==`string`?n.code:`connection_failed`);return}if(n.type===`ready`)_=n.zoomQuality===!0,E(),Number.isFinite(n.width)&&Number.isFinite(n.height)&&e.onSize(n.width,n.height);else if(n.type===`offer`&&!c){if(s||typeof n.sdp!=`string`||n.sdp.length>65536)throw Error(`invalid_offer`);if(typeof RTCPeerConnection>`u`){O();return}s=new RTCPeerConnection({iceServers:Array.isArray(n.iceServers)?n.iceServers:[]}),s.onicecandidate=e=>{e.candidate&&T({type:`ice`,candidate:e.candidate.toJSON()})},s.onconnectionstatechange=()=>{(s?.connectionState===`failed`||s?.connectionState===`disconnected`)&&O()},s.ontrack=t=>{w()&&(e.video.srcObject=new MediaStream([t.track]),e.video.onloadeddata=()=>{!w()||c||(clearTimeout(f),clearTimeout(p),e.onSize(e.video.videoWidth,e.video.videoHeight),b(`webrtc`))},e.video.play().catch(O))},await s.setRemoteDescription({type:`offer`,sdp:n.sdp});for(let e of C.splice(0))await s.addIceCandidate(e);if(await s.setLocalDescription(await s.createAnswer()),!w()||c)return;p=setTimeout(O,7e3),T({type:`answer`,sdp:s.localDescription?.sdp})}else n.type===`ice`&&n.candidate&&!c?s?.remoteDescription?await s.addIceCandidate(n.candidate):C.length<128&&C.push(n.candidate):n.type===`rtc-failed`&&O()};return b(`connecting`),(async()=>{try{if(await t(),!w())return;o=u(r().websocket(`/api/remote-desktop/ws`)),o.binaryType=`arraybuffer`,o.onopen=()=>{w()&&(m=Date.now(),d=setInterval(()=>{if(!w()){D(`runtime_changed`);return}if(Date.now()-m>3e4){D(`connection_failed`);return}T({type:`ping`})},5e3))},o.onmessage=e=>{if(w()){if(++S>128){D(`connection_failed`);return}x=x.then(()=>k(e.data)).catch(O).finally(()=>{S--})}},o.onerror=()=>D(`connection_failed`),o.onclose=e=>D(e.code===4001?`authentication_required`:`connection_failed`)}catch{D(`connection_failed`)}})(),{send:e=>T(e),close:D,setZoomed:e=>{v=e,E()}}}var j={scale:1,x:0,y:0};function M(e){let t=Math.min(e.width/e.remoteWidth,e.height/e.remoteHeight),n=e.remoteWidth*t,r=e.remoteHeight*t;return{width:n,height:r,x:(e.width-n)/2,y:(e.height-r)/2}}function N(e,t,n){if(t.width<=0||t.height<=0||t.remoteWidth<=0||t.remoteHeight<=0)return null;let r=M(t),i=((e.x-n.x)/n.scale-r.x)/r.width,a=((e.y-n.y)/n.scale-r.y)/r.height;return i>=0&&i<=1&&a>=0&&a<=1?{x:i,y:a}:null}function P(e,t,n=1){let r=Math.max(n,Math.min(5,e.scale)),i=M(t),a=(e,t,n,i)=>n*r<=i?(i-n*r)/2-t*r:Math.max(i-(t+n)*r,Math.min(-t*r,e));return{scale:r,x:a(e.x,i.x,i.width,t.width),y:a(e.y,i.y,i.height,t.height)}}function ee(e){let t=new Map,n={...j},r=null,i=null,a=!1,o=!1,s=!1,c=!1,l,u=null,d=0,f=null,p=()=>{a&&e.send({type:`release`}),a=!1},m=()=>{(n.scale!==1||n.x!==0||n.y!==0)&&(n={...j},e.apply(n,!0))},h=()=>{clearTimeout(l),p(),t.clear(),f=null,r=i=null,s=!1,u=null,n.scale<=1&&m()},g=()=>{let[e,n]=[...t.values()];return{midpoint:{x:(e.x+n.x)/2,y:(e.y+n.y)/2},distance:Math.max(1,Math.hypot(e.x-n.x,e.y-n.y))}},_={down(a,m){t.size>=2||(t.set(a,m),t.size===1&&(r=i=m,o=!1,s=!1,c=!1,d=Date.now(),e.mode()===`cursor`&&(l=setTimeout(()=>{let t=N(m,e.viewport(),n);t&&!o&&!s&&(e.send({type:`pointer`,action:`right`,...t}),c=!0)},550))),t.size===2&&(clearTimeout(l),s=!0,u=null,p(),f={...g(),transform:{...n}}))},move(d,p){if(t.has(d)){if(t.set(d,p),t.size===2&&f){let{midpoint:t,distance:r}=g(),i=Math.max(.5,Math.min(5,f.transform.scale*r/f.distance)),a=i/f.transform.scale;n=P({scale:i,x:t.x-(f.midpoint.x-f.transform.x)*a,y:t.y-(f.midpoint.y-f.transform.y)*a},e.viewport(),.5),e.apply(n);return}if(!(s||c||!r||!i)&&(Math.hypot(p.x-r.x,p.y-r.y)>6&&(o=!0,u=null,clearTimeout(l)),o)){if(e.mode()===`drag`)n={...n,x:n.x+p.x-i.x,y:n.y+p.y-i.y},e.apply(n);else{let t=N(p,e.viewport(),n);if(t){let i=N(r,e.viewport(),n);!a&&i&&(e.send({type:`pointer`,action:`down`,...i}),a=!0),a&&e.send({type:`pointer`,action:`move`,...t})}}i=p}}},moveMany(e){let n;for(let[r,i]of e)t.has(r)&&(t.set(r,i),n=[r,i]);n&&_.move(...n)},up(a,h,g=!1){if(t.has(a)){if(clearTimeout(l),t.delete(a),e.mode()===`cursor`&&!g&&!s&&!o&&!c){let t=N(h,e.viewport(),n);t&&e.send({type:`pointer`,action:`click`,...t})}if(e.mode()===`drag`&&!g&&!s&&!o&&Date.now()-d<450){let t=Date.now(),r={x:h.x,y:h.y,time:t};if(x(u,r)){if(n.scale>1)n={...j};else{let t=2.5,r=t/n.scale;n=P({scale:t,x:h.x-(h.x-n.x)*r,y:h.y-(h.y-n.y)*r},e.viewport())}e.apply(n,!0),u=null}else u=r}else u=null;p(),t.size||(f=null,r=i=null,s=!1,n.scale<=1&&m())}},cancel:h,refit(){if(n.scale<=1){m();return}n=P(n,e.viewport()),e.apply(n)},reset(){h(),n={...j},e.apply(n)}};return _}function F(e,t,n){return n===90?{x:e.y-t.top,y:t.right-e.x}:n===-90?{x:t.bottom-e.y,y:e.x-t.left}:{x:e.x-t.left,y:e.y-t.top}}var I=d(),L=g(`YuriOrientation`);function R(){return _.isNativePlatform()&&_.isPluginAvailable(`YuriOrientation`)}function z(e){return L.lock({orientation:e})}function te(e){let t=(0,I.c)(14),[n,r]=(0,D.useState)(G),[i]=(0,D.useState)(W),[a,o]=(0,D.useState)(i),[s]=(0,D.useState)(R),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{let[t]=e;if(!t)return;let{width:n,height:i}=t.contentRect;n>0&&i>0&&r(e=>e.width===n&&e.height===i?e:{width:n,height:i})},t[0]=c):c=t[0],m(e,c);let l,u;t[1]!==s||t[2]!==a?(l=()=>{s&&z(a).catch(U)},u=[s,a],t[1]=s,t[2]=a,t[3]=l,t[4]=u):(l=t[3],u=t[4]),(0,D.useEffect)(l,u);let d,f;t[5]===s?(d=t[6],f=t[7]):(d=()=>{if(s)return V},f=[s],t[5]=s,t[6]=d,t[7]=f),(0,D.useEffect)(d,f);let p=!s&&a!==i,h=p?90:0,g=p?n.height:n.width,_=p?n.width:n.height,v;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>o(B),t[8]=v):v=t[8];let y;return t[9]!==a||t[10]!==h||t[11]!==g||t[12]!==_?(y={orientation:a,rotation:h,width:g,height:_,toggle:v},t[9]=a,t[10]=h,t[11]=g,t[12]=_,t[13]=y):y=t[13],y}function B(e){return e===`portrait`?`landscape`:`portrait`}function V(){z(`portrait`).catch(H)}function H(){}function U(){}function W(){return window.innerWidth>window.innerHeight?`landscape`:`portrait`}function G(){return{width:window.innerWidth,height:window.innerHeight}}var K=(e,t)=>({queryKey:[e,`remote-desktop`,t],queryFn:async({signal:n})=>{let r=()=>{if(e!==i()||t!==a())throw Error(`runtime_changed`)};r();let s=new AbortController,c=()=>s.abort();n.addEventListener(`abort`,c,{once:!0}),n.aborted&&c();let l;try{return await Promise.race([(async()=>{let e=await o(`/api/remote-desktop`,{signal:s.signal,headers:{Accept:`application/json`}});if(r(),[401,403].includes(e.status))throw Error(`authentication_required`);if([404,501].includes(e.status))throw Error(`unsupported`);if(!e.ok)throw Error(`connection_failed`);if(!e.headers.get(`content-type`)?.includes(`application/json`))throw Error(`unsupported`);let t=await e.json();if(r(),!t||typeof t!=`object`||!(`supported`in t)||typeof t.supported!=`boolean`)throw Error(`unsupported`);return{supported:t.supported,enabled:`enabled`in t&&t.enabled===!0}})(),new Promise((e,t)=>{l=setTimeout(()=>{c(),t(Error(`connection_failed`))},1e4)})])}finally{clearTimeout(l),n.removeEventListener(`abort`,c)}},staleTime:3e4,retry:!1,refetchInterval:e=>{let t=e.state.error;return!t||[`unsupported`,`runtime_changed`,`authentication_required`].includes(t.message)?!1:Math.min(1e3*2**Math.min(Math.max(0,e.state.errorUpdateCount-1),5),3e4)},refetchIntervalInBackground:!1}),ne=(e,t)=>{let n=(0,I.c)(3),r;return n[0]!==t||n[1]!==e?(r=K(e,t),n[0]=t,n[1]=e,n[2]=r):r=n[2],f(r)},q=c(),re=[{key:`Escape`,icon:`corner-up-left`},{key:`Tab`,icon:`arrow-right-to-line`},{key:`Backspace`,icon:`delete-back`},{key:`Enter`,icon:`corner-down-left`},{key:`ArrowLeft`,icon:`arrow-left`},{key:`ArrowUp`,icon:`arrow-up`},{key:`ArrowDown`,icon:`arrow-down`},{key:`ArrowRight`,icon:`arrow-right`}];function ie({onClose:e,instanceName:t}){let{t:n}=b(),[r]=D.useState(()=>({transport:i(),generation:a()})),o=ne(r.transport,r.generation),[s,c]=D.useState(0),[l,u]=D.useState(`connecting`),[d,f]=D.useState(),[g,_]=D.useState(`drag`),[x,A]=D.useState(!1),[j,M]=D.useState(``),N=D.useRef(null),P=D.useRef(null),I=te(P),L=D.useRef(null),R=D.useRef(null),z=D.useRef(null),B=D.useRef({width:1,height:1,remoteWidth:1920,remoteHeight:1080}),V=D.useRef(null),H=D.useRef(null),U=D.useRef(new Map),W=D.useRef(new Set),G=D.useRef(!1),K=h(e=>{V.current?.send(e)}),ie=h(()=>g),[J]=D.useState(()=>ee({viewport:()=>B.current,send:K,mode:ie,apply:(e,t)=>{let n=e.scale>(G.current?1.01:1.05);n!==G.current&&(G.current=n,V.current?.setZoomed(n)),L.current&&(L.current.style.transition=t&&!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`transform 180ms ease-out`:`none`,L.current.style.transform=`translate(${e.x}px, ${e.y}px) scale(${e.scale})`)}})),Y=h(()=>{if(H.current!==null&&cancelAnimationFrame(H.current),H.current=null,U.current.size&&N.current){let e=N.current.getBoundingClientRect(),t=new Map([...U.current].map(([t,n])=>[t,F(n,e,I.rotation)]));J.moveMany(t)}U.current.clear()}),ae=h(()=>{Y(),J.reset(),V.current?.close(),V.current=null}),oe=h(()=>{ae(),e()});S({id:`remote-desktop-page`,active:!0,layer:`root`,onBack:oe,surfaceRef:P}),D.useEffect(()=>T(`remote-desktop-page`),[]),D.useLayoutEffect(()=>{let e=document.activeElement;return P.current?.focus({preventScroll:!0}),()=>{e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),p(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),C.requestBrowserBack())},()=>document);let se=h((e,t)=>{(e===`closed`||e===`connecting`)&&(U.current.clear(),W.current.clear(),J.cancel()),u(e),f(t)}),ce=h((e,t)=>{if(e<=0||t<=0||B.current.remoteWidth===e&&B.current.remoteHeight===t)return;let n=B.current;B.current={...n,remoteWidth:e,remoteHeight:t},!(Math.abs(n.remoteWidth/n.remoteHeight-e/t)<.01)&&!W.current.size&&J.reset()});m(N,([e])=>{if(!e)return;let{width:t,height:n}=e.contentRect,r=Math.abs(B.current.width-t)>=1||Math.abs(B.current.height-n)>=1;B.current={...B.current,width:t,height:n},r&&!W.current.size&&J.refit()}),E(N),D.useEffect(()=>{if(!o.data?.supported||!o.data.enabled||!R.current||!z.current)return;let e=k({...r,video:R.current,image:z.current,onSize:ce,onState:se});return V.current=e,e.setZoomed(G.current),()=>{e.close(),V.current=null}},[o.data?.supported,o.data?.enabled,r,s,ce,se]),D.useEffect(()=>()=>{Y(),J.reset()},[Y,J]);let X=e=>{let t=N.current.getBoundingClientRect();return F({x:e.clientX,y:e.clientY},t,I.rotation)},Z=l===`webrtc`||l===`tunnel`,Q=o.data?.supported===!1||o.error?.message===`unsupported`,$=o.data?.supported===!0&&o.data.enabled!==!0,le=Q||d===`helper_unavailable`?n(`remoteDesktop.unsupported`):$||d===`disabled`?n(`settings.remoteDesktop.disabled`):d===`permission_required`?n(`remoteDesktop.permissions`):d===`permission_denied`?n(`remoteDesktop.denied`):d===`runtime_changed`||o.error?.message===`runtime_changed`?n(`remoteDesktop.runtimeChanged`):d||o.error||l===`closed`?n(`remoteDesktop.failed`):n(`remoteDesktop.connecting`);return(0,O.createPortal)((0,q.jsx)(`div`,{ref:P,tabIndex:-1,"data-remote-desktop-page":!0,className:`yuri-keyboard-inset-surface yuri-keyboard-inset-snap fixed inset-0 z-[150] overflow-clip bg-background text-foreground outline-none`,children:(0,q.jsxs)(`main`,{"aria-label":t?`${n(`remoteDesktop.title`)} · ${t}`:n(`remoteDesktop.title`),className:`absolute left-0 top-0 flex flex-col overflow-clip bg-background`,style:{width:I.width,height:I.height,transformOrigin:`top left`,"--desktop-safe-top":`env(safe-area-inset-${I.rotation===90?`right`:I.rotation===-90?`left`:`top`}, 0px)`,"--desktop-safe-right":`env(safe-area-inset-${I.rotation===90?`bottom`:I.rotation===-90?`top`:`right`}, 0px)`,"--desktop-safe-bottom":`env(safe-area-inset-${I.rotation===90?`left`:I.rotation===-90?`right`:`bottom`}, 0px)`,"--desktop-safe-left":`env(safe-area-inset-${I.rotation===90?`top`:I.rotation===-90?`bottom`:`left`}, 0px)`,transform:I.rotation===90?`translateX(${I.height}px) rotate(90deg)`:I.rotation===-90?`translateY(${I.width}px) rotate(-90deg)`:void 0},children:[(0,q.jsxs)(`div`,{"data-remote-desktop-stage-region":!0,className:`relative min-h-0 flex-1 overflow-clip`,children:[(0,q.jsxs)(`div`,{ref:N,className:`absolute inset-0 touch-none overflow-clip bg-background`,"aria-label":n(`remoteDesktop.screen`),onPointerDown:e=>{Z&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),W.current.add(e.pointerId),Y(),J.down(e.pointerId,X(e)))},onPointerMove:e=>{!Z||!W.current.has(e.pointerId)||(e.preventDefault(),U.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),H.current===null&&(H.current=requestAnimationFrame(Y)))},onPointerUp:e=>{Y(),J.up(e.pointerId,X(e)),W.current.delete(e.pointerId),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:e=>{Y(),J.up(e.pointerId,X(e),!0),W.current.delete(e.pointerId)},onContextMenu:e=>e.preventDefault(),children:[(0,q.jsxs)(`div`,{ref:L,className:`absolute inset-0 origin-top-left will-change-transform`,children:[(0,q.jsx)(`video`,{ref:R,autoPlay:!0,muted:!0,playsInline:!0,className:`pointer-events-none absolute inset-0 size-full object-contain`,style:{visibility:l===`webrtc`?`visible`:`hidden`}}),(0,q.jsx)(`img`,{ref:z,alt:n(`remoteDesktop.screen`),draggable:!1,className:`pointer-events-none absolute inset-0 size-full object-contain`,style:{visibility:l===`tunnel`?`visible`:`hidden`}})]}),!Z&&(0,q.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-4 p-6 text-center text-sm text-muted-foreground`,role:`status`,children:[l===`connecting`&&!d&&!o.error&&!Q&&!$&&(0,q.jsx)(y,{name:`loader-4`,className:`size-5 animate-spin`}),(0,q.jsx)(`p`,{children:le}),(l===`closed`||o.error||$)&&!Q&&d!==`runtime_changed`&&o.error?.message!==`runtime_changed`&&(0,q.jsx)(v,{onClick:()=>{ae(),f(void 0),u(`connecting`),o.error||$?o.refetch():c(e=>e+1)},children:n(`remoteDesktop.retry`)})]})]}),(0,q.jsxs)(`div`,{className:`pointer-events-none absolute left-[max(0.75rem,var(--desktop-safe-left))] right-[max(0.75rem,var(--desktop-safe-right))] top-[max(0.75rem,var(--desktop-safe-top))] flex items-start justify-between gap-3`,children:[(0,q.jsx)(v,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto`,"aria-label":n(`header.actions.backAria`),onClick:()=>C.requestBrowserBack(),children:(0,q.jsx)(y,{name:`arrow-left`,className:`size-5`})}),(0,q.jsx)(v,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto`,"aria-label":n(`remoteDesktop.rotate`),title:n(`remoteDesktop.rotate`),onClick:()=>{Y(),J.reset(),A(!1),I.toggle()},children:(0,q.jsx)(y,{name:`smartphone`,className:`size-5 rotate-45`})})]}),(0,q.jsx)(`p`,{className:`sr-only`,children:n(`remoteDesktop.hint`)}),(0,q.jsx)(`div`,{className:`pointer-events-none absolute left-[max(0.75rem,var(--desktop-safe-left))] right-[max(0.75rem,var(--desktop-safe-right))] bottom-[max(0.75rem,var(--desktop-safe-bottom))] top-[calc(4rem+var(--desktop-safe-top))] flex flex-col items-end justify-end gap-3`,children:(0,q.jsxs)(`div`,{className:`flex w-full shrink-0 items-end justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`pointer-events-auto flex gap-3`,children:[(0,q.jsx)(v,{size:`mobileIcon`,variant:`mobileGlass`,className:g===`drag`?`yuri-mobile-inverse-action`:void 0,"aria-label":n(`remoteDesktop.drag`),title:n(`remoteDesktop.drag`),"aria-pressed":g===`drag`,disabled:!Z,onClick:()=>{Y(),J.cancel(),_(`drag`)},children:(0,q.jsx)(y,{name:`hand`,className:`size-5`})}),(0,q.jsx)(v,{size:`mobileIcon`,variant:`mobileGlass`,className:g===`cursor`?`yuri-mobile-inverse-action`:void 0,"aria-label":n(`remoteDesktop.cursor`),title:n(`remoteDesktop.cursor`),"aria-pressed":g===`cursor`,disabled:!Z,onClick:()=>{Y(),J.cancel(),_(`cursor`)},children:(0,q.jsx)(y,{name:`cursor`,className:`size-5`})})]}),(0,q.jsx)(v,{size:`mobileIcon`,variant:`mobileGlass`,className:`pointer-events-auto${x?` yuri-mobile-inverse-action`:``}`,disabled:!Z,"aria-label":n(`remoteDesktop.text`),title:n(`remoteDesktop.text`),"aria-pressed":x,"aria-expanded":x,onClick:()=>A(e=>!e),children:(0,q.jsx)(y,{name:`keyboard`,className:`size-5`})})]})})]}),x&&(0,q.jsxs)(`footer`,{"data-remote-desktop-keyboard":!0,className:`max-h-[50%] w-full shrink-0 overflow-y-auto overscroll-contain border-t border-border bg-[var(--surface-elevated)] pt-3 pl-[max(0.75rem,var(--desktop-safe-left))] pr-[max(0.75rem,var(--desktop-safe-right))] pb-[max(0.75rem,var(--desktop-safe-bottom))]`,children:[(0,q.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),j&&Z&&(K({type:`text`,text:j}),M(``))},children:[(0,q.jsx)(w,{className:`min-w-0 flex-1`,value:j,maxLength:1024,onChange:e=>M(e.target.value),placeholder:n(`remoteDesktop.text`),"aria-label":n(`remoteDesktop.text`),disabled:!Z,autoComplete:`off`}),(0,q.jsx)(v,{type:`submit`,size:`icon`,disabled:!Z||!j,"aria-label":n(`remoteDesktop.send`),children:(0,q.jsx)(y,{name:`send-plane-2`,className:`size-4`})})]}),(0,q.jsx)(`div`,{className:`mt-2 grid grid-cols-4 gap-1 min-[360px]:grid-cols-8`,children:re.map(({key:e,icon:t})=>(0,q.jsx)(v,{size:`icon`,variant:`ghost`,className:`w-full`,disabled:!Z,onClick:()=>K({type:`key`,key:e}),"aria-label":n(`remoteDesktop.pressKey`,{key:e}),title:n(`remoteDesktop.pressKey`,{key:e}),children:(0,q.jsx)(y,{name:t,className:`size-4`})},e))})]})]})}),document.body)}var J=D.memo(ie);export{J as RemoteDesktopPanel};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{r as n}from"./platform-CiUKDeXd.js";import{ot as r,st as i}from"./vendor-base-ui-wXsskyKm.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{n as o,s,t as c}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as l,l as u,r as d}from"./yuriEvents-BFrD5fMU.js";import{a as f,r as p}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as m}from"./useUIStore-C3ewjGgP.js";import{i as h,o as g,s as ee}from"./session-startup-barrier-BfAFvTz_.js";import{n as _}from"./Icon-BLvjcKMe.js";import{At as v,Ct as te,Ma as y,Qi as b,Vi as x,t as S}from"./ui-BBJAK87V.js";import{n as C,t as ne}from"./i18n-ByGlB3HF.js";import{n as w}from"./ScrollableOverlay-By9Xj7Dt.js";import{n as re,t as T}from"./MobileResizableSheet-DqBQmWZR.js";import{i as E,t as D}from"./vendor-framer-motion-D5NyyC73.js";import{n as ie,o as ae,r as oe,t as O}from"./dialog-BjoDEvdt.js";import{c as k,n as se,r as A,t as ce}from"./dropdown-menu-1XT-gOct.js";import{a as j,n as M,r as le,t as ue}from"./context-menu-DLkbq4VB.js";import{t as de}from"./textarea-BXKtOkSw.js";import{n as fe}from"./mobileBackNavigation-4qLXJUZN.js";import{t as pe}from"./input-DCG7mwtP.js";import{D as N,E as P,O as me,T as he,_ as F,k as ge}from"./assistantQueries-DlXx9G2k.js";import{n as I}from"./AgentAvatar-BMyOvw1S.js";import{t as L}from"./MobileDetailNavigation-DzmPZiX2.js";import{t as R}from"./checkbox-B6qJy2q5.js";import{a as z,c as B,r as _e}from"./insertionBoundaries-98_64UQf.js";import{t as ve}from"./MobileOverlayPanel-Bqorq1sh.js";import{t as V}from"./vendor-motion-vLNN8EMu.js";import{c as H,i as ye,n as be,s as xe,t as Se}from"./select-BjsrUiHl.js";import{a as U,i as Ce,n as we}from"./projectMeta-vIaGFaQr.js";import{r as Te,t as Ee}from"./router-DXUi1sBd.js";import{t as De}from"./scheduledTaskNavigation-VVTOq9n2.js";import{t as Oe}from"./switch-DiEXd4Rk.js";import{t as ke}from"./MobileTabPageHeader-BcxLuIaE.js";import{t as Ae}from"./sortAssistantContacts-CcEdm3mS.js";import{t as W}from"./ModelSelector-BN7tJsu7.js";import{t as je}from"./AgentSelector-DjvFTge_.js";import{t as Me}from"./vendor-cron-parser-BmO80h0C.js";var G=t(i(),1),Ne=a(),Pe=`yuri-settings-group-row border-b border-[var(--yuri-settings-row-divider)] last:border-b-0`,Fe=`yuri-settings-group-label`,Ie=Me();function K(e){if(!e||!e.trim())return{valid:!1,error:`required`};try{return Ie.CronExpressionParser.parse(e),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:`Invalid cron expression`}}}function Le(e,t,n=4){try{let r=t?{tz:t,currentDate:new Date}:{currentDate:new Date},i=Ie.CronExpressionParser.parse(e,r),a=[];for(let e=0;e<n;e+=1){let e=i.next();e&&a.push(e.toDate())}return a}catch{return[]}}var Re=[{expression:`*/5 * * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.every5min`},{expression:`0 * * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.everyHour`},{expression:`0 9 * * 1`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.monday9am`},{expression:`0 9,17 * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.9am5pm`},{expression:`0 0 1 * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.firstOfMonth`}],q=r(),ze=[0,1,2,3,4,5,6],Be=`!h-9 !min-h-9 w-full min-w-0 rounded-full border-0 bg-[var(--surface-elevated)] px-3 py-1 ring-1 ring-inset ring-border/60 transition-[background-color,box-shadow] duration-150 ease-out hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] data-[popup-open]:bg-[var(--surface-subtle)] data-[popup-open]:shadow-sm motion-reduce:transition-none`,Ve=`yuri-settings-inline-value`,He=`yuri-settings-split-row ${Pe}`,J=Ve,Y=He,Ue=()=>{let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`},X=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=new Date(n,r-1,i);return Number.isNaN(a.getTime())||a.getFullYear()!==n||a.getMonth()!==r-1||a.getDate()!==i?null:a},We=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,Ge=(e,t,n)=>{let r=X(e);return r?new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`,year:`numeric`}).format(r):t},Z=(e,t)=>new Date(e.getFullYear(),e.getMonth()+t,1),Ke=(e,t)=>{let n=e.getFullYear(),r=e.getMonth(),i=(new Date(n,r,1).getDay()-t+7)%7,a=new Date(n,r+1,0).getDate(),o=new Date(n,r,0).getDate(),s=[];for(let e=0;e<42;e+=1){let t=e-i+1;if(t<=0){let e=o+t;s.push({date:new Date(n,r-1,e),inCurrentMonth:!1});continue}if(t>a){s.push({date:new Date(n,r+1,t-a),inCurrentMonth:!1});continue}s.push({date:new Date(n,r,t),inCurrentMonth:!0})}return s},Q=e=>{let t=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(e);if(!t)return{hour24:`00`,hour12:`12`,minute:`00`,meridiem:`AM`};let n=Number(t[1]),r=t[2],i=n>=12?`PM`:`AM`,a=n%12==0?12:n%12;return{hour24:String(n).padStart(2,`0`),hour12:String(a).padStart(2,`0`),minute:r,meridiem:i}},qe=(e,t,n)=>{let r=Number(e),i=Number(t),a=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,o=Number.isFinite(i)?Math.min(59,Math.max(0,i)):0,s=a%12;return n===`PM`&&(s+=12),`${String(s).padStart(2,`0`)}:${String(o).padStart(2,`0`)}`},$=(e,t)=>{let{max:n,min:r=0,loop:i=!1}=t,a=Number.parseInt(e,10);return Number.isFinite(a)?(i?(a>n&&(a=r),a<r&&(a=n)):(a>n&&(a=n),a<r&&(a=r)),String(a).padStart(2,`0`)):`00`},Je=e=>/^(0[1-9]|1[0-2])$/.test(e)?e:$(e,{min:1,max:12}),Ye=e=>/^[0-5][0-9]$/.test(e)?e:$(e,{max:59}),Xe=(e,t)=>$(String(Number.parseInt(e,10)+t),{min:1,max:12,loop:!0}),Ze=(e,t)=>$(String(Number.parseInt(e,10)+t),{min:0,max:59,loop:!0}),Qe=e=>{try{let t=Intl.Locale;if(typeof t!=`function`)return 1;let n=new t(e).weekInfo?.firstDay;return typeof n==`number`?n%7:1}catch{return 1}},$e=e=>{try{let t=new Intl.DateTimeFormat(e,{hour:`numeric`}).resolvedOptions();return typeof t.hour12==`boolean`?!t.hour12:t.hourCycle===`h23`||t.hourCycle===`h24`}catch{return!0}},et=e=>{let t=new Intl.DateTimeFormat(e,{weekday:`short`}),n=new Date(2023,0,1);return ze.map(e=>t.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+e)))},tt=(e,t)=>[...e.slice(t),...e.slice(0,t)],nt=e=>{let t=(0,Ne.c)(9),{htmlFor:n,required:r,className:i,children:a}=e,o;t[0]===i?o=t[1]:(o=g(`typography-ui-label font-normal text-foreground`,i),t[0]=i,t[1]=o);let s;t[2]===r?s=t[3]:(s=r&&(0,q.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`}),t[2]=r,t[3]=s);let c;return t[4]!==a||t[5]!==n||t[6]!==o||t[7]!==s?(c=(0,q.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,q.jsxs)(`label`,{htmlFor:n,className:o,children:[a,s]})}),t[4]=a,t[5]=n,t[6]=o,t[7]=s,t[8]=c):c=t[8],c},rt=e=>{let t=(0,Ne.c)(85),{value:n,onChange:r,className:i,use24Hour:a,hourAriaLabel:o,minuteAriaLabel:s,periodAriaLabel:c,amLabel:l,pmLabel:u}=e,d;t[0]===n?d=t[1]:(d=Q(n),t[0]=n,t[1]=d);let f=d,p=G.useRef(null),m=G.useRef(null),[h,ee]=G.useState(null),[_,v]=G.useState(null),te=G.useRef(null),y=G.useRef(null),b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{te.current=e,ee(e)},t[2]=b):b=t[2];let x=b,S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{y.current=e,v(e)},t[3]=S):S=t[3];let C=S,ne=pt,w=mt,re=ht,T;t[4]!==r||t[5]!==f.meridiem||t[6]!==f.minute||t[7]!==a?(T=e=>{let t=e.replace(/\D/g,``).slice(0,2);x(t),t.length===2&&(r(a?re(ne(t),f.minute):qe(Je(t),f.minute,f.meridiem)),x(null),m.current?.focus())},t[4]=r,t[5]=f.meridiem,t[6]=f.minute,t[7]=a,t[8]=T):T=t[8];let E=T,D;t[9]!==r||t[10]!==f.meridiem||t[11]!==f.minute||t[12]!==a?(D=()=>{let e=te.current;if(e!==null&&(x(null),e.length!==0)){if(a){r(re(ne(e.padStart(2,`0`)),f.minute));return}r(qe(Je(e.padStart(2,`0`)),f.minute,f.meridiem))}},t[9]=r,t[10]=f.meridiem,t[11]=f.minute,t[12]=a,t[13]=D):D=t[13];let ie=D,ae;t[14]!==r||t[15]!==f.hour12||t[16]!==f.hour24||t[17]!==f.meridiem||t[18]!==a?(ae=e=>{let t=e.replace(/\D/g,``).slice(0,2);C(t),t.length===2&&(r(a?re(f.hour24,Ye(t)):qe(f.hour12,Ye(t),f.meridiem)),C(null))},t[14]=r,t[15]=f.hour12,t[16]=f.hour24,t[17]=f.meridiem,t[18]=a,t[19]=ae):ae=t[19];let oe=ae,O;t[20]!==r||t[21]!==f.hour12||t[22]!==f.hour24||t[23]!==f.meridiem||t[24]!==a?(O=()=>{let e=y.current;e!==null&&(C(null),e.length!==0&&r(a?re(f.hour24,Ye(e.padStart(2,`0`))):qe(f.hour12,Ye(e.padStart(2,`0`)),f.meridiem)))},t[20]=r,t[21]=f.hour12,t[22]=f.hour24,t[23]=f.meridiem,t[24]=a,t[25]=O):O=t[25];let k=O,se;t[26]!==r||t[27]!==f.hour12||t[28]!==f.hour24||t[29]!==f.meridiem||t[30]!==f.minute||t[31]!==a?(se=e=>r(a?re(w(f.hour24,e),f.minute):qe(Xe(f.hour12,e),f.minute,f.meridiem)),t[26]=r,t[27]=f.hour12,t[28]=f.hour24,t[29]=f.meridiem,t[30]=f.minute,t[31]=a,t[32]=se):se=t[32];let A=se,ce;t[33]!==r||t[34]!==f.hour12||t[35]!==f.hour24||t[36]!==f.meridiem||t[37]!==f.minute||t[38]!==a?(ce=e=>r(a?re(f.hour24,Ze(f.minute,e)):qe(f.hour12,Ze(f.minute,e),f.meridiem)),t[33]=r,t[34]=f.hour12,t[35]=f.hour24,t[36]=f.meridiem,t[37]=f.minute,t[38]=a,t[39]=ce):ce=t[39];let j=ce,M;t[40]!==r||t[41]!==f.hour12||t[42]!==f.meridiem||t[43]!==f.minute?(M=e=>{e!==f.meridiem&&r(qe(f.hour12,f.minute,e))},t[40]=r,t[41]=f.hour12,t[42]=f.meridiem,t[43]=f.minute,t[44]=M):M=t[44];let le=M,ue;t[45]!==ie||t[46]!==A?(ue=e=>{if(e.key===`ArrowRight`){e.preventDefault(),ie(),m.current?.focus();return}(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),x(null),A(e.key===`ArrowUp`?1:-1))},t[45]=ie,t[46]=A,t[47]=ue):ue=t[47];let de=ue,fe;t[48]!==k||t[49]!==j?(fe=e=>{if(e.key===`ArrowLeft`&&(e.currentTarget.selectionStart??0)===0){e.preventDefault(),k(),p.current?.focus();return}(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),C(null),j(e.key===`ArrowUp`?1:-1))},t[48]=k,t[49]=j,t[50]=fe):fe=t[50];let pe=fe,N=a?`px-2`:`pl-2 pr-1`,P;t[51]!==i||t[52]!==N?(P=g(`flex h-9 w-full min-w-0 items-center gap-1 rounded-full border-0 bg-[var(--surface-elevated)] ring-1 ring-inset ring-border/60 transition duration-200 ease-out hover:[&:not(:focus-within)]:bg-[var(--surface-subtle)] hover:[&:not(:focus-within)]:ring-transparent focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]`,N,i),t[51]=i,t[52]=N,t[53]=P):P=t[53];let me=h??(a?f.hour24:f.hour12),he;t[54]===E?he=t[55]:(he=e=>E(e.target.value),t[54]=E,t[55]=he);let F;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>x(``),t[56]=F):F=t[56];let ge;t[57]!==ie||t[58]!==o||t[59]!==de||t[60]!==me||t[61]!==he?(ge=(0,q.jsx)(`input`,{ref:p,inputMode:`numeric`,value:me,onChange:he,onKeyDown:de,onFocus:F,onBlur:ie,maxLength:2,"aria-label":o,className:`h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover`}),t[57]=ie,t[58]=o,t[59]=de,t[60]=me,t[61]=he,t[62]=ge):ge=t[62];let I;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,q.jsx)(`span`,{className:`font-mono text-sm text-muted-foreground`,children:`:`}),t[63]=I):I=t[63];let L=_??f.minute,R;t[64]===oe?R=t[65]:(R=e=>oe(e.target.value),t[64]=oe,t[65]=R);let z;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>C(``),t[66]=z):z=t[66];let B;t[67]!==k||t[68]!==s||t[69]!==pe||t[70]!==L||t[71]!==R?(B=(0,q.jsx)(`input`,{ref:m,inputMode:`numeric`,value:L,onChange:R,onKeyDown:pe,onFocus:z,onBlur:k,maxLength:2,"aria-label":s,className:`h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover`}),t[67]=k,t[68]=s,t[69]=pe,t[70]=L,t[71]=R,t[72]=B):B=t[72];let _e;t[73]!==l||t[74]!==f.meridiem||t[75]!==c||t[76]!==u||t[77]!==le||t[78]!==a?(_e=a?null:(0,q.jsxs)(Se,{value:f.meridiem,onValueChange:e=>le(e),children:[(0,q.jsx)(xe,{"aria-label":c,className:`ml-1 h-7 w-fit border-0 bg-transparent pl-2 pr-1 shadow-none hover:bg-interactive-hover focus:ring-0`,children:(0,q.jsx)(H,{})}),(0,q.jsxs)(be,{className:`motion-reduce:transition-none`,children:[(0,q.jsx)(ye,{value:`AM`,children:l}),(0,q.jsx)(ye,{value:`PM`,children:u})]})]}),t[73]=l,t[74]=f.meridiem,t[75]=c,t[76]=u,t[77]=le,t[78]=a,t[79]=_e):_e=t[79];let ve;return t[80]!==P||t[81]!==ge||t[82]!==B||t[83]!==_e?(ve=(0,q.jsxs)(`div`,{className:P,children:[ge,I,B,_e]}),t[80]=P,t[81]=ge,t[82]=B,t[83]=_e,t[84]=ve):ve=t[84],ve},it=e=>new Date(e.getFullYear(),e.getMonth(),1),at=()=>{let e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate())},ot=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),st=e=>{if(!e)return[`09:00`];let t=(Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[]).filter(e=>typeof e==`string`&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)).map(e=>e.trim()),n=Array.from(new Set(t)).sort((e,t)=>e.localeCompare(t));return n.length>0?n:[`09:00`]},ct=(e,t)=>{let n=Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`;return e?{id:e.id,name:e.name,enabled:e.enabled,schedule:{kind:e.schedule.kind===`cron`?`cron`:e.schedule.kind===`once`?`once`:e.schedule.kind===`weekly`?`weekly`:`daily`,times:st(e),onceDate:typeof e.schedule.date==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(e.schedule.date)?e.schedule.date:Ue(),onceTime:typeof e.schedule.time==`string`&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(e.schedule.time)?e.schedule.time:`09:00`,weekdays:Array.isArray(e.schedule.weekdays)?e.schedule.weekdays:[1],timezone:e.schedule.timezone||n,cronExpression:e.schedule.kind===`cron`&&typeof e.schedule.cron==`string`?e.schedule.cron:``},execution:{prompt:e.execution.prompt,providerID:e.execution.providerID,modelID:e.execution.modelID,variant:e.execution.variant||``,agent:e.execution.agent||``,goalEnabled:e.execution.goalEnabled===!0},state:e.state}:{name:``,enabled:!0,schedule:{kind:`daily`,times:[`09:00`],onceDate:Ue(),onceTime:`09:00`,weekdays:[1],timezone:n,cronExpression:``},execution:{prompt:``,providerID:t.providerID,modelID:t.modelID,variant:t.variant,agent:t.agent,goalEnabled:!1}}},lt=(e,t)=>{if(!e.name.trim())return t(`sessions.scheduledTasks.editor.validation.taskNameRequired`);if(!e.execution.prompt.trim())return t(`sessions.scheduledTasks.editor.validation.promptRequired`);if(!e.execution.providerID.trim()||!e.execution.modelID.trim())return t(`sessions.scheduledTasks.editor.validation.modelRequired`);if(e.schedule.kind===`once`){if(!/^\d{4}-\d{2}-\d{2}$/.test(e.schedule.onceDate))return t(`sessions.scheduledTasks.editor.validation.dateFormat`);if(!/^([01]\d|2[0-3]):([0-5]\d)$/.test(e.schedule.onceTime))return t(`sessions.scheduledTasks.editor.validation.timeFormat`)}else if(e.schedule.kind===`cron`){if(!e.schedule.cronExpression.trim())return t(`sessions.scheduledTasks.editor.validation.cronRequired`);if(!K(e.schedule.cronExpression).valid)return t(`sessions.scheduledTasks.editor.validation.cronInvalid`)}else if(e.schedule.times.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)).length===0)return t(`sessions.scheduledTasks.editor.validation.atLeastOneTime`);return e.schedule.kind===`weekly`&&e.schedule.weekdays.length===0?t(`sessions.scheduledTasks.editor.validation.atLeastOneWeekday`):e.schedule.timezone.trim()?null:t(`sessions.scheduledTasks.editor.validation.timezoneRequired`)},ut=e=>{let t=e.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e));return Array.from(new Set(t)).sort((e,t)=>e.localeCompare(t))},dt=e=>{let t=(0,Ne.c)(74),{draft:n,setDraft:r,locale:i,t:a,panel:o,mobilePanel:s}=e,c=o!==void 0&&o,l=s!==void 0&&s,u=c||l,d=l?Y:He,f=n.schedule.cronExpression,p;t[0]===f?p=t[1]:(p=f.trim()?K(f):null,t[0]=f,t[1]=p);let m=p,ee;bb0:{if(!m?.valid||!f.trim()){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[2]=e):e=t[2],ee=e;break bb0}let e;t[3]!==f||t[4]!==n.schedule.timezone?(e=Le(f,n.schedule.timezone),t[3]=f,t[4]=n.schedule.timezone,t[5]=e):e=t[5],ee=e}let _=ee,v;t[6]!==n.schedule.timezone||t[7]!==i?(v=e=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(e),t[6]=n.schedule.timezone,t[7]=i,t[8]=v):v=t[8];let te=v,y=u&&`gap-0`,b;t[9]===y?b=t[10]:(b=g(`flex flex-col gap-3`,y),t[9]=y,t[10]=b);let x=u&&d,S;t[11]===x?S=t[12]:(S=g(`flex flex-col gap-1`,x),t[11]=x,t[12]=S);let C;t[13]===a?C=t[14]:(C=a(`sessions.scheduledTasks.editor.cronExpression.label`),t[13]=a,t[14]=C);let ne;t[15]===C?ne=t[16]:(ne=(0,q.jsx)(nt,{htmlFor:`sched-cron`,required:!0,children:C}),t[15]=C,t[16]=ne);let w=u?``:void 0,re=u&&`yuri-settings-split-row-control flex-wrap`,T;t[17]===re?T=t[18]:(T=g(`min-w-0`,re),t[17]=re,t[18]=T);let E;t[19]===r?E=t[20]:(E=e=>r(t=>({...t,schedule:{...t.schedule,cronExpression:e.target.value}})),t[19]=r,t[20]=E);let D;t[21]===a?D=t[22]:(D=a(`sessions.scheduledTasks.editor.cronExpression.placeholder`),t[21]=a,t[22]=D);let ie=u&&`min-w-[140px] text-right`,ae;t[23]===ie?ae=t[24]:(ae=g(`w-full font-mono`,ie),t[23]=ie,t[24]=ae);let oe;t[25]!==f||t[26]!==E||t[27]!==D||t[28]!==ae?(oe=(0,q.jsx)(pe,{id:`sched-cron`,value:f,onChange:E,placeholder:D,className:ae}),t[25]=f,t[26]=E,t[27]=D,t[28]=ae,t[29]=oe):oe=t[29];let O;t[30]!==f||t[31]!==m||t[32]!==a?(O=m&&!m.valid&&f.trim()?(0,q.jsx)(`span`,{className:`w-full typography-micro text-right text-destructive`,children:a(`sessions.scheduledTasks.editor.validation.cronInvalid`)}):null,t[30]=f,t[31]=m,t[32]=a,t[33]=O):O=t[33];let k;t[34]!==w||t[35]!==T||t[36]!==oe||t[37]!==O?(k=(0,q.jsxs)(`div`,{"data-settings-value":w,className:T,children:[oe,O]}),t[34]=w,t[35]=T,t[36]=oe,t[37]=O,t[38]=k):k=t[38];let se;t[39]!==ne||t[40]!==k||t[41]!==S?(se=(0,q.jsxs)(`div`,{className:S,children:[ne,k]}),t[39]=ne,t[40]=k,t[41]=S,t[42]=se):se=t[42];let A;t[43]!==te||t[44]!==u||t[45]!==_||t[46]!==d||t[47]!==a?(A=_.length>0?(0,q.jsxs)(`div`,{className:g(`flex flex-col gap-1`,u&&[d,`yuri-scheduled-task-detail-row`]),children:[(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:a(`sessions.scheduledTasks.editor.cronExpression.nextRuns`)}),(0,q.jsx)(`span`,{"data-settings-value":u?``:void 0,className:`flex min-w-0 flex-wrap gap-x-4 gap-y-1 typography-micro text-muted-foreground`,children:_.map(e=>(0,q.jsx)(`span`,{className:`whitespace-nowrap tabular-nums`,children:te(e)},e.toISOString()))})]}):null,t[43]=te,t[44]=u,t[45]=_,t[46]=d,t[47]=a,t[48]=A):A=t[48];let ce;t[49]!==u||t[50]!==d?(ce=u&&[d,`yuri-scheduled-task-detail-row`],t[49]=u,t[50]=d,t[51]=ce):ce=t[51];let j;t[52]===ce?j=t[53]:(j=g(`flex flex-col gap-1`,ce),t[52]=ce,t[53]=j);let M;t[54]===a?M=t[55]:(M=a(`sessions.scheduledTasks.editor.cronExpression.examples`),t[54]=a,t[55]=M);let le;t[56]===M?le=t[57]:(le=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:M}),t[56]=M,t[57]=le);let ue=u?``:void 0,de;t[58]!==f||t[59]!==r||t[60]!==a?(de=Re.map(e=>(0,q.jsx)(h,{type:`button`,variant:`chip`,size:`xs`,"aria-pressed":f.trim()===e.expression,title:e.expression,onClick:()=>r(t=>({...t,schedule:{...t.schedule,cronExpression:e.expression}})),children:a(e.labelKey)},e.expression)),t[58]=f,t[59]=r,t[60]=a,t[61]=de):de=t[61];let fe;t[62]!==ue||t[63]!==de?(fe=(0,q.jsx)(`div`,{"data-settings-value":ue,className:`flex min-w-0 flex-wrap gap-1.5`,children:de}),t[62]=ue,t[63]=de,t[64]=fe):fe=t[64];let N;t[65]!==j||t[66]!==le||t[67]!==fe?(N=(0,q.jsxs)(`div`,{className:j,children:[le,fe]}),t[65]=j,t[66]=le,t[67]=fe,t[68]=N):N=t[68];let P;return t[69]!==se||t[70]!==A||t[71]!==N||t[72]!==b?(P=(0,q.jsxs)(`div`,{className:b,children:[se,A,N]}),t[69]=se,t[70]=A,t[71]=N,t[72]=b,t[73]=P):P=t[73],P};function ft(e){let{open:t,task:n,onOpenChange:r,onSave:i,presentation:a=`dialog`,onDirtyChange:o,onRun:s,onOpenTaskHistory:c,onDelete:l,onToggleEnabled:u,actionBusy:d=!1,projectID:f=``,projectOptions:p=[],onProjectChange:ee}=e,v=a===`panel`,te=a===`mobile-panel`,y=a===`mobile-tab`,C=te||y,re=te||y,T=v||C,E=C?J:Ve,D=C?Y:He,{t:j,locale:M}=ne(),le=x(e=>e.loadProviders),ue=x(e=>e.loadAgents),fe=x(e=>e.providers),N=x(e=>e.currentProviderId),P=x(e=>e.currentModelId),me=x(e=>e.currentVariant||``),he=x(e=>e.currentAgentName||``),F=m(e=>e.timeFormatPreference),ge=m(e=>e.weekStartPreference),I=m(e=>e.isMobile),[V,U]=G.useState(()=>ct(n,{providerID:N,modelID:P,variant:me,agent:he})),[Ce,we]=G.useState(!1),[Te,Ee]=G.useState(!1),[De,ke]=G.useState(!1),[Ae,Me]=G.useState(``),[Ne,Pe]=G.useState(!1),[Ie,K]=G.useState(``),[Le,Re]=G.useState(()=>{let e=X(n?.schedule?.date||``)||new Date;return new Date(e.getFullYear(),e.getMonth(),1)}),Ue=G.useRef(null),Q=G.useRef(null),qe=G.useRef(null),$=G.useRef(null),Je=G.useRef(``),Ye=G.useRef(void 0),Xe=G.useRef(n);Xe.current=n;let Ze=n?.id||null,st=G.useMemo(()=>$e(M),[M]),ft=G.useMemo(()=>Qe(M),[M]),pt=G.useMemo(()=>F===`24h`||F!==`12h`&&st,[F,st]),mt=G.useMemo(()=>ge===`sunday`?0:ge===`monday`?1:ft,[ge,ft]),ht=G.useMemo(()=>{let e=et(M);return tt(ze.map(t=>({value:t,label:e[t]||``})),mt)},[M,mt]);G.useEffect(()=>{t&&(le({source:`scheduledTaskEditor`}),ue({source:`scheduledTaskEditor`}))},[t,le,ue]),G.useEffect(()=>{if(!t){Ye.current=void 0;return}if(Ye.current===Ze)return;Ye.current=Ze;let e=Xe.current,n=ct(e,{providerID:N,modelID:P,variant:me,agent:he});Je.current=JSON.stringify(n),U(n),o?.(!1);let r=X(e?.schedule?.date||``)||new Date;Re(new Date(r.getFullYear(),r.getMonth(),1)),Ee(!1),Pe(!1),ke(!1),K(``),Me(``)},[t,Ze,N,P,me,he,o]),G.useEffect(()=>{if(!(!t||!n||V.id!==n.id||V.enabled===n.enabled)&&(U(e=>({...e,enabled:n.enabled})),Je.current)){let e=JSON.parse(Je.current);Je.current=JSON.stringify({...e,enabled:n.enabled})}},[V.enabled,V.id,t,n]),G.useEffect(()=>{!t||!Je.current||o?.(JSON.stringify(V)!==Je.current)},[V,o,t]),G.useEffect(()=>{if(!Te)return;let e=e=>{Ue.current&&!Ue.current.contains(e.target)&&Ee(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[Te]);let gt=G.useMemo(()=>fe.find(e=>e.id===V.execution.providerID)?.models?.find(e=>e.id===V.execution.modelID),[V.execution.modelID,V.execution.providerID,fe]),_t=G.useMemo(()=>gt?.variants?Object.keys(gt.variants):[],[gt]);G.useEffect(()=>{!gt||!V.execution.variant||_t.includes(V.execution.variant)||U(e=>({...e,execution:{...e.execution,variant:``}}))},[_t,V.execution.variant,gt]);let vt=G.useCallback((e,t)=>{U(n=>{let r=new Set(n.schedule.weekdays);return t?r.add(e):r.delete(e),{...n,schedule:{...n.schedule,weekdays:Array.from(r).sort((e,t)=>e-t)}}})},[]),yt=G.useCallback((e,t)=>{U(n=>{let r=n.schedule.times.slice();return r[e]=t,{...n,schedule:{...n.schedule,times:r}}})},[]),bt=G.useCallback(e=>{U(t=>{let n=t.schedule.times.filter((t,n)=>n!==e);return{...t,schedule:{...t.schedule,times:n.length>0?n:[`09:00`]}}})},[]),xt=G.useCallback(()=>{U(e=>({...e,schedule:{...e.schedule,times:[...e.schedule.times,`12:00`]}}))},[]),St=G.useMemo(()=>at(),[]),Ct=G.useMemo(()=>it(St),[St]),wt=G.useMemo(()=>{let e=X(V.schedule.onceDate);return e?ot(e,St)?j(`sessions.scheduledTasks.editor.date.today`):new Intl.DateTimeFormat(M,{weekday:`short`}).format(e):null},[V.schedule.onceDate,M,j,St]),Tt=G.useMemo(()=>it(Le).getTime()<=Ct.getTime(),[Le,Ct]),Et=G.useMemo(()=>ht.map(e=>e.label),[ht]),Dt=G.useCallback(e=>{U(t=>({...t,schedule:{...t.schedule,onceDate:e}}))},[]),Ot=G.useCallback((e,t)=>{if(e.startsWith(`/`)){let n=e.indexOf(` `),r=e.indexOf(`
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{r as n}from"./platform-CiUKDeXd.js";import{ot as r,st as i}from"./vendor-base-ui-wXsskyKm.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{n as o,s,t as c}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as l,l as u,r as d}from"./yuriEvents-BFrD5fMU.js";import{a as f,r as p}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as m}from"./useUIStore-C3ewjGgP.js";import{i as h,o as g,s as ee}from"./session-startup-barrier-DT-hIBRf.js";import{n as _}from"./Icon-DmykXZL1.js";import{$i as v,At as y,Ct as te,Hi as b,Na as x,t as S}from"./ui-ee2iN869.js";import{n as C,t as ne}from"./i18n-DXc6czdR.js";import{n as w}from"./ScrollableOverlay-stxT7gLf.js";import{n as re,t as T}from"./MobileResizableSheet-CqphcaKq.js";import{i as E,t as D}from"./vendor-framer-motion-D5NyyC73.js";import{n as ie,o as ae,r as oe,t as O}from"./dialog-BeFBA6ja.js";import{c as k,n as se,r as A,t as ce}from"./dropdown-menu-BblI9sN2.js";import{a as j,n as M,r as le,t as ue}from"./context-menu-CKlB6wxo.js";import{t as de}from"./textarea-ZiXxEOHK.js";import{n as fe}from"./mobileBackNavigation-C94n2eLT.js";import{t as pe}from"./input-Cf16qJ6g.js";import{D as N,E as P,O as me,T as he,_ as F,k as ge}from"./assistantQueries-NdPqu6rx.js";import{n as I}from"./AgentAvatar-CHCjMxCF.js";import{t as L}from"./MobileDetailNavigation-ldTzGo19.js";import{t as R}from"./checkbox-BMN5hAVm.js";import{a as z,c as B,r as _e}from"./insertionBoundaries-Btqgsu1M.js";import{t as ve}from"./MobileOverlayPanel-C36VWWmN.js";import{t as V}from"./vendor-motion-vLNN8EMu.js";import{c as H,i as ye,n as be,s as xe,t as Se}from"./select-vZCgcnYG.js";import{a as U,i as Ce,n as we}from"./projectMeta-vIaGFaQr.js";import{r as Te,t as Ee}from"./router-DXUi1sBd.js";import{t as De}from"./scheduledTaskNavigation-VVTOq9n2.js";import{t as Oe}from"./switch-CNmsFYfY.js";import{t as ke}from"./MobileTabPageHeader-D6P4K98S.js";import{t as Ae}from"./sortAssistantContacts-CcEdm3mS.js";import{t as W}from"./ModelSelector-EmtltPnd.js";import{t as je}from"./AgentSelector-uBoLtut8.js";import{t as Me}from"./vendor-cron-parser-BmO80h0C.js";var G=t(i(),1),Ne=a(),Pe=`yuri-settings-group-row border-b border-[var(--yuri-settings-row-divider)] last:border-b-0`,Fe=`yuri-settings-group-label`,Ie=Me();function K(e){if(!e||!e.trim())return{valid:!1,error:`required`};try{return Ie.CronExpressionParser.parse(e),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:`Invalid cron expression`}}}function Le(e,t,n=4){try{let r=t?{tz:t,currentDate:new Date}:{currentDate:new Date},i=Ie.CronExpressionParser.parse(e,r),a=[];for(let e=0;e<n;e+=1){let e=i.next();e&&a.push(e.toDate())}return a}catch{return[]}}var Re=[{expression:`*/5 * * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.every5min`},{expression:`0 * * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.everyHour`},{expression:`0 9 * * 1`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.monday9am`},{expression:`0 9,17 * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.9am5pm`},{expression:`0 0 1 * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.firstOfMonth`}],q=r(),ze=[0,1,2,3,4,5,6],Be=`!h-9 !min-h-9 w-full min-w-0 rounded-full border-0 bg-[var(--surface-elevated)] px-3 py-1 ring-1 ring-inset ring-border/60 transition-[background-color,box-shadow] duration-150 ease-out hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] data-[popup-open]:bg-[var(--surface-subtle)] data-[popup-open]:shadow-sm motion-reduce:transition-none`,Ve=`yuri-settings-inline-value`,He=`yuri-settings-split-row ${Pe}`,J=Ve,Y=He,Ue=()=>{let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`},X=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=new Date(n,r-1,i);return Number.isNaN(a.getTime())||a.getFullYear()!==n||a.getMonth()!==r-1||a.getDate()!==i?null:a},We=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,Ge=(e,t,n)=>{let r=X(e);return r?new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`,year:`numeric`}).format(r):t},Z=(e,t)=>new Date(e.getFullYear(),e.getMonth()+t,1),Ke=(e,t)=>{let n=e.getFullYear(),r=e.getMonth(),i=(new Date(n,r,1).getDay()-t+7)%7,a=new Date(n,r+1,0).getDate(),o=new Date(n,r,0).getDate(),s=[];for(let e=0;e<42;e+=1){let t=e-i+1;if(t<=0){let e=o+t;s.push({date:new Date(n,r-1,e),inCurrentMonth:!1});continue}if(t>a){s.push({date:new Date(n,r+1,t-a),inCurrentMonth:!1});continue}s.push({date:new Date(n,r,t),inCurrentMonth:!0})}return s},Q=e=>{let t=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(e);if(!t)return{hour24:`00`,hour12:`12`,minute:`00`,meridiem:`AM`};let n=Number(t[1]),r=t[2],i=n>=12?`PM`:`AM`,a=n%12==0?12:n%12;return{hour24:String(n).padStart(2,`0`),hour12:String(a).padStart(2,`0`),minute:r,meridiem:i}},qe=(e,t,n)=>{let r=Number(e),i=Number(t),a=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,o=Number.isFinite(i)?Math.min(59,Math.max(0,i)):0,s=a%12;return n===`PM`&&(s+=12),`${String(s).padStart(2,`0`)}:${String(o).padStart(2,`0`)}`},$=(e,t)=>{let{max:n,min:r=0,loop:i=!1}=t,a=Number.parseInt(e,10);return Number.isFinite(a)?(i?(a>n&&(a=r),a<r&&(a=n)):(a>n&&(a=n),a<r&&(a=r)),String(a).padStart(2,`0`)):`00`},Je=e=>/^(0[1-9]|1[0-2])$/.test(e)?e:$(e,{min:1,max:12}),Ye=e=>/^[0-5][0-9]$/.test(e)?e:$(e,{max:59}),Xe=(e,t)=>$(String(Number.parseInt(e,10)+t),{min:1,max:12,loop:!0}),Ze=(e,t)=>$(String(Number.parseInt(e,10)+t),{min:0,max:59,loop:!0}),Qe=e=>{try{let t=Intl.Locale;if(typeof t!=`function`)return 1;let n=new t(e).weekInfo?.firstDay;return typeof n==`number`?n%7:1}catch{return 1}},$e=e=>{try{let t=new Intl.DateTimeFormat(e,{hour:`numeric`}).resolvedOptions();return typeof t.hour12==`boolean`?!t.hour12:t.hourCycle===`h23`||t.hourCycle===`h24`}catch{return!0}},et=e=>{let t=new Intl.DateTimeFormat(e,{weekday:`short`}),n=new Date(2023,0,1);return ze.map(e=>t.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+e)))},tt=(e,t)=>[...e.slice(t),...e.slice(0,t)],nt=e=>{let t=(0,Ne.c)(9),{htmlFor:n,required:r,className:i,children:a}=e,o;t[0]===i?o=t[1]:(o=g(`typography-ui-label font-normal text-foreground`,i),t[0]=i,t[1]=o);let s;t[2]===r?s=t[3]:(s=r&&(0,q.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`}),t[2]=r,t[3]=s);let c;return t[4]!==a||t[5]!==n||t[6]!==o||t[7]!==s?(c=(0,q.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,q.jsxs)(`label`,{htmlFor:n,className:o,children:[a,s]})}),t[4]=a,t[5]=n,t[6]=o,t[7]=s,t[8]=c):c=t[8],c},rt=e=>{let t=(0,Ne.c)(85),{value:n,onChange:r,className:i,use24Hour:a,hourAriaLabel:o,minuteAriaLabel:s,periodAriaLabel:c,amLabel:l,pmLabel:u}=e,d;t[0]===n?d=t[1]:(d=Q(n),t[0]=n,t[1]=d);let f=d,p=G.useRef(null),m=G.useRef(null),[h,ee]=G.useState(null),[_,v]=G.useState(null),y=G.useRef(null),te=G.useRef(null),b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{y.current=e,ee(e)},t[2]=b):b=t[2];let x=b,S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{te.current=e,v(e)},t[3]=S):S=t[3];let C=S,ne=pt,w=mt,re=ht,T;t[4]!==r||t[5]!==f.meridiem||t[6]!==f.minute||t[7]!==a?(T=e=>{let t=e.replace(/\D/g,``).slice(0,2);x(t),t.length===2&&(r(a?re(ne(t),f.minute):qe(Je(t),f.minute,f.meridiem)),x(null),m.current?.focus())},t[4]=r,t[5]=f.meridiem,t[6]=f.minute,t[7]=a,t[8]=T):T=t[8];let E=T,D;t[9]!==r||t[10]!==f.meridiem||t[11]!==f.minute||t[12]!==a?(D=()=>{let e=y.current;if(e!==null&&(x(null),e.length!==0)){if(a){r(re(ne(e.padStart(2,`0`)),f.minute));return}r(qe(Je(e.padStart(2,`0`)),f.minute,f.meridiem))}},t[9]=r,t[10]=f.meridiem,t[11]=f.minute,t[12]=a,t[13]=D):D=t[13];let ie=D,ae;t[14]!==r||t[15]!==f.hour12||t[16]!==f.hour24||t[17]!==f.meridiem||t[18]!==a?(ae=e=>{let t=e.replace(/\D/g,``).slice(0,2);C(t),t.length===2&&(r(a?re(f.hour24,Ye(t)):qe(f.hour12,Ye(t),f.meridiem)),C(null))},t[14]=r,t[15]=f.hour12,t[16]=f.hour24,t[17]=f.meridiem,t[18]=a,t[19]=ae):ae=t[19];let oe=ae,O;t[20]!==r||t[21]!==f.hour12||t[22]!==f.hour24||t[23]!==f.meridiem||t[24]!==a?(O=()=>{let e=te.current;e!==null&&(C(null),e.length!==0&&r(a?re(f.hour24,Ye(e.padStart(2,`0`))):qe(f.hour12,Ye(e.padStart(2,`0`)),f.meridiem)))},t[20]=r,t[21]=f.hour12,t[22]=f.hour24,t[23]=f.meridiem,t[24]=a,t[25]=O):O=t[25];let k=O,se;t[26]!==r||t[27]!==f.hour12||t[28]!==f.hour24||t[29]!==f.meridiem||t[30]!==f.minute||t[31]!==a?(se=e=>r(a?re(w(f.hour24,e),f.minute):qe(Xe(f.hour12,e),f.minute,f.meridiem)),t[26]=r,t[27]=f.hour12,t[28]=f.hour24,t[29]=f.meridiem,t[30]=f.minute,t[31]=a,t[32]=se):se=t[32];let A=se,ce;t[33]!==r||t[34]!==f.hour12||t[35]!==f.hour24||t[36]!==f.meridiem||t[37]!==f.minute||t[38]!==a?(ce=e=>r(a?re(f.hour24,Ze(f.minute,e)):qe(f.hour12,Ze(f.minute,e),f.meridiem)),t[33]=r,t[34]=f.hour12,t[35]=f.hour24,t[36]=f.meridiem,t[37]=f.minute,t[38]=a,t[39]=ce):ce=t[39];let j=ce,M;t[40]!==r||t[41]!==f.hour12||t[42]!==f.meridiem||t[43]!==f.minute?(M=e=>{e!==f.meridiem&&r(qe(f.hour12,f.minute,e))},t[40]=r,t[41]=f.hour12,t[42]=f.meridiem,t[43]=f.minute,t[44]=M):M=t[44];let le=M,ue;t[45]!==ie||t[46]!==A?(ue=e=>{if(e.key===`ArrowRight`){e.preventDefault(),ie(),m.current?.focus();return}(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),x(null),A(e.key===`ArrowUp`?1:-1))},t[45]=ie,t[46]=A,t[47]=ue):ue=t[47];let de=ue,fe;t[48]!==k||t[49]!==j?(fe=e=>{if(e.key===`ArrowLeft`&&(e.currentTarget.selectionStart??0)===0){e.preventDefault(),k(),p.current?.focus();return}(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),C(null),j(e.key===`ArrowUp`?1:-1))},t[48]=k,t[49]=j,t[50]=fe):fe=t[50];let pe=fe,N=a?`px-2`:`pl-2 pr-1`,P;t[51]!==i||t[52]!==N?(P=g(`flex h-9 w-full min-w-0 items-center gap-1 rounded-full border-0 bg-[var(--surface-elevated)] ring-1 ring-inset ring-border/60 transition duration-200 ease-out hover:[&:not(:focus-within)]:bg-[var(--surface-subtle)] hover:[&:not(:focus-within)]:ring-transparent focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]`,N,i),t[51]=i,t[52]=N,t[53]=P):P=t[53];let me=h??(a?f.hour24:f.hour12),he;t[54]===E?he=t[55]:(he=e=>E(e.target.value),t[54]=E,t[55]=he);let F;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>x(``),t[56]=F):F=t[56];let ge;t[57]!==ie||t[58]!==o||t[59]!==de||t[60]!==me||t[61]!==he?(ge=(0,q.jsx)(`input`,{ref:p,inputMode:`numeric`,value:me,onChange:he,onKeyDown:de,onFocus:F,onBlur:ie,maxLength:2,"aria-label":o,className:`h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover`}),t[57]=ie,t[58]=o,t[59]=de,t[60]=me,t[61]=he,t[62]=ge):ge=t[62];let I;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,q.jsx)(`span`,{className:`font-mono text-sm text-muted-foreground`,children:`:`}),t[63]=I):I=t[63];let L=_??f.minute,R;t[64]===oe?R=t[65]:(R=e=>oe(e.target.value),t[64]=oe,t[65]=R);let z;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>C(``),t[66]=z):z=t[66];let B;t[67]!==k||t[68]!==s||t[69]!==pe||t[70]!==L||t[71]!==R?(B=(0,q.jsx)(`input`,{ref:m,inputMode:`numeric`,value:L,onChange:R,onKeyDown:pe,onFocus:z,onBlur:k,maxLength:2,"aria-label":s,className:`h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover`}),t[67]=k,t[68]=s,t[69]=pe,t[70]=L,t[71]=R,t[72]=B):B=t[72];let _e;t[73]!==l||t[74]!==f.meridiem||t[75]!==c||t[76]!==u||t[77]!==le||t[78]!==a?(_e=a?null:(0,q.jsxs)(Se,{value:f.meridiem,onValueChange:e=>le(e),children:[(0,q.jsx)(xe,{"aria-label":c,className:`ml-1 h-7 w-fit border-0 bg-transparent pl-2 pr-1 shadow-none hover:bg-interactive-hover focus:ring-0`,children:(0,q.jsx)(H,{})}),(0,q.jsxs)(be,{className:`motion-reduce:transition-none`,children:[(0,q.jsx)(ye,{value:`AM`,children:l}),(0,q.jsx)(ye,{value:`PM`,children:u})]})]}),t[73]=l,t[74]=f.meridiem,t[75]=c,t[76]=u,t[77]=le,t[78]=a,t[79]=_e):_e=t[79];let ve;return t[80]!==P||t[81]!==ge||t[82]!==B||t[83]!==_e?(ve=(0,q.jsxs)(`div`,{className:P,children:[ge,I,B,_e]}),t[80]=P,t[81]=ge,t[82]=B,t[83]=_e,t[84]=ve):ve=t[84],ve},it=e=>new Date(e.getFullYear(),e.getMonth(),1),at=()=>{let e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate())},ot=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),st=e=>{if(!e)return[`09:00`];let t=(Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[]).filter(e=>typeof e==`string`&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)).map(e=>e.trim()),n=Array.from(new Set(t)).sort((e,t)=>e.localeCompare(t));return n.length>0?n:[`09:00`]},ct=(e,t)=>{let n=Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`;return e?{id:e.id,name:e.name,enabled:e.enabled,schedule:{kind:e.schedule.kind===`cron`?`cron`:e.schedule.kind===`once`?`once`:e.schedule.kind===`weekly`?`weekly`:`daily`,times:st(e),onceDate:typeof e.schedule.date==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(e.schedule.date)?e.schedule.date:Ue(),onceTime:typeof e.schedule.time==`string`&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(e.schedule.time)?e.schedule.time:`09:00`,weekdays:Array.isArray(e.schedule.weekdays)?e.schedule.weekdays:[1],timezone:e.schedule.timezone||n,cronExpression:e.schedule.kind===`cron`&&typeof e.schedule.cron==`string`?e.schedule.cron:``},execution:{prompt:e.execution.prompt,providerID:e.execution.providerID,modelID:e.execution.modelID,variant:e.execution.variant||``,agent:e.execution.agent||``,goalEnabled:e.execution.goalEnabled===!0},state:e.state}:{name:``,enabled:!0,schedule:{kind:`daily`,times:[`09:00`],onceDate:Ue(),onceTime:`09:00`,weekdays:[1],timezone:n,cronExpression:``},execution:{prompt:``,providerID:t.providerID,modelID:t.modelID,variant:t.variant,agent:t.agent,goalEnabled:!1}}},lt=(e,t)=>{if(!e.name.trim())return t(`sessions.scheduledTasks.editor.validation.taskNameRequired`);if(!e.execution.prompt.trim())return t(`sessions.scheduledTasks.editor.validation.promptRequired`);if(!e.execution.providerID.trim()||!e.execution.modelID.trim())return t(`sessions.scheduledTasks.editor.validation.modelRequired`);if(e.schedule.kind===`once`){if(!/^\d{4}-\d{2}-\d{2}$/.test(e.schedule.onceDate))return t(`sessions.scheduledTasks.editor.validation.dateFormat`);if(!/^([01]\d|2[0-3]):([0-5]\d)$/.test(e.schedule.onceTime))return t(`sessions.scheduledTasks.editor.validation.timeFormat`)}else if(e.schedule.kind===`cron`){if(!e.schedule.cronExpression.trim())return t(`sessions.scheduledTasks.editor.validation.cronRequired`);if(!K(e.schedule.cronExpression).valid)return t(`sessions.scheduledTasks.editor.validation.cronInvalid`)}else if(e.schedule.times.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)).length===0)return t(`sessions.scheduledTasks.editor.validation.atLeastOneTime`);return e.schedule.kind===`weekly`&&e.schedule.weekdays.length===0?t(`sessions.scheduledTasks.editor.validation.atLeastOneWeekday`):e.schedule.timezone.trim()?null:t(`sessions.scheduledTasks.editor.validation.timezoneRequired`)},ut=e=>{let t=e.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e));return Array.from(new Set(t)).sort((e,t)=>e.localeCompare(t))},dt=e=>{let t=(0,Ne.c)(74),{draft:n,setDraft:r,locale:i,t:a,panel:o,mobilePanel:s}=e,c=o!==void 0&&o,l=s!==void 0&&s,u=c||l,d=l?Y:He,f=n.schedule.cronExpression,p;t[0]===f?p=t[1]:(p=f.trim()?K(f):null,t[0]=f,t[1]=p);let m=p,ee;bb0:{if(!m?.valid||!f.trim()){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[2]=e):e=t[2],ee=e;break bb0}let e;t[3]!==f||t[4]!==n.schedule.timezone?(e=Le(f,n.schedule.timezone),t[3]=f,t[4]=n.schedule.timezone,t[5]=e):e=t[5],ee=e}let _=ee,v;t[6]!==n.schedule.timezone||t[7]!==i?(v=e=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(e),t[6]=n.schedule.timezone,t[7]=i,t[8]=v):v=t[8];let y=v,te=u&&`gap-0`,b;t[9]===te?b=t[10]:(b=g(`flex flex-col gap-3`,te),t[9]=te,t[10]=b);let x=u&&d,S;t[11]===x?S=t[12]:(S=g(`flex flex-col gap-1`,x),t[11]=x,t[12]=S);let C;t[13]===a?C=t[14]:(C=a(`sessions.scheduledTasks.editor.cronExpression.label`),t[13]=a,t[14]=C);let ne;t[15]===C?ne=t[16]:(ne=(0,q.jsx)(nt,{htmlFor:`sched-cron`,required:!0,children:C}),t[15]=C,t[16]=ne);let w=u?``:void 0,re=u&&`yuri-settings-split-row-control flex-wrap`,T;t[17]===re?T=t[18]:(T=g(`min-w-0`,re),t[17]=re,t[18]=T);let E;t[19]===r?E=t[20]:(E=e=>r(t=>({...t,schedule:{...t.schedule,cronExpression:e.target.value}})),t[19]=r,t[20]=E);let D;t[21]===a?D=t[22]:(D=a(`sessions.scheduledTasks.editor.cronExpression.placeholder`),t[21]=a,t[22]=D);let ie=u&&`min-w-[140px] text-right`,ae;t[23]===ie?ae=t[24]:(ae=g(`w-full font-mono`,ie),t[23]=ie,t[24]=ae);let oe;t[25]!==f||t[26]!==E||t[27]!==D||t[28]!==ae?(oe=(0,q.jsx)(pe,{id:`sched-cron`,value:f,onChange:E,placeholder:D,className:ae}),t[25]=f,t[26]=E,t[27]=D,t[28]=ae,t[29]=oe):oe=t[29];let O;t[30]!==f||t[31]!==m||t[32]!==a?(O=m&&!m.valid&&f.trim()?(0,q.jsx)(`span`,{className:`w-full typography-micro text-right text-destructive`,children:a(`sessions.scheduledTasks.editor.validation.cronInvalid`)}):null,t[30]=f,t[31]=m,t[32]=a,t[33]=O):O=t[33];let k;t[34]!==w||t[35]!==T||t[36]!==oe||t[37]!==O?(k=(0,q.jsxs)(`div`,{"data-settings-value":w,className:T,children:[oe,O]}),t[34]=w,t[35]=T,t[36]=oe,t[37]=O,t[38]=k):k=t[38];let se;t[39]!==ne||t[40]!==k||t[41]!==S?(se=(0,q.jsxs)(`div`,{className:S,children:[ne,k]}),t[39]=ne,t[40]=k,t[41]=S,t[42]=se):se=t[42];let A;t[43]!==y||t[44]!==u||t[45]!==_||t[46]!==d||t[47]!==a?(A=_.length>0?(0,q.jsxs)(`div`,{className:g(`flex flex-col gap-1`,u&&[d,`yuri-scheduled-task-detail-row`]),children:[(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:a(`sessions.scheduledTasks.editor.cronExpression.nextRuns`)}),(0,q.jsx)(`span`,{"data-settings-value":u?``:void 0,className:`flex min-w-0 flex-wrap gap-x-4 gap-y-1 typography-micro text-muted-foreground`,children:_.map(e=>(0,q.jsx)(`span`,{className:`whitespace-nowrap tabular-nums`,children:y(e)},e.toISOString()))})]}):null,t[43]=y,t[44]=u,t[45]=_,t[46]=d,t[47]=a,t[48]=A):A=t[48];let ce;t[49]!==u||t[50]!==d?(ce=u&&[d,`yuri-scheduled-task-detail-row`],t[49]=u,t[50]=d,t[51]=ce):ce=t[51];let j;t[52]===ce?j=t[53]:(j=g(`flex flex-col gap-1`,ce),t[52]=ce,t[53]=j);let M;t[54]===a?M=t[55]:(M=a(`sessions.scheduledTasks.editor.cronExpression.examples`),t[54]=a,t[55]=M);let le;t[56]===M?le=t[57]:(le=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:M}),t[56]=M,t[57]=le);let ue=u?``:void 0,de;t[58]!==f||t[59]!==r||t[60]!==a?(de=Re.map(e=>(0,q.jsx)(h,{type:`button`,variant:`chip`,size:`xs`,"aria-pressed":f.trim()===e.expression,title:e.expression,onClick:()=>r(t=>({...t,schedule:{...t.schedule,cronExpression:e.expression}})),children:a(e.labelKey)},e.expression)),t[58]=f,t[59]=r,t[60]=a,t[61]=de):de=t[61];let fe;t[62]!==ue||t[63]!==de?(fe=(0,q.jsx)(`div`,{"data-settings-value":ue,className:`flex min-w-0 flex-wrap gap-1.5`,children:de}),t[62]=ue,t[63]=de,t[64]=fe):fe=t[64];let N;t[65]!==j||t[66]!==le||t[67]!==fe?(N=(0,q.jsxs)(`div`,{className:j,children:[le,fe]}),t[65]=j,t[66]=le,t[67]=fe,t[68]=N):N=t[68];let P;return t[69]!==se||t[70]!==A||t[71]!==N||t[72]!==b?(P=(0,q.jsxs)(`div`,{className:b,children:[se,A,N]}),t[69]=se,t[70]=A,t[71]=N,t[72]=b,t[73]=P):P=t[73],P};function ft(e){let{open:t,task:n,onOpenChange:r,onSave:i,presentation:a=`dialog`,onDirtyChange:o,onRun:s,onOpenTaskHistory:c,onDelete:l,onToggleEnabled:u,actionBusy:d=!1,projectID:f=``,projectOptions:p=[],onProjectChange:ee}=e,y=a===`panel`,te=a===`mobile-panel`,x=a===`mobile-tab`,C=te||x,re=te||x,T=y||C,E=C?J:Ve,D=C?Y:He,{t:j,locale:M}=ne(),le=b(e=>e.loadProviders),ue=b(e=>e.loadAgents),fe=b(e=>e.providers),N=b(e=>e.currentProviderId),P=b(e=>e.currentModelId),me=b(e=>e.currentVariant||``),he=b(e=>e.currentAgentName||``),F=m(e=>e.timeFormatPreference),ge=m(e=>e.weekStartPreference),I=m(e=>e.isMobile),[V,U]=G.useState(()=>ct(n,{providerID:N,modelID:P,variant:me,agent:he})),[Ce,we]=G.useState(!1),[Te,Ee]=G.useState(!1),[De,ke]=G.useState(!1),[Ae,Me]=G.useState(``),[Ne,Pe]=G.useState(!1),[Ie,K]=G.useState(``),[Le,Re]=G.useState(()=>{let e=X(n?.schedule?.date||``)||new Date;return new Date(e.getFullYear(),e.getMonth(),1)}),Ue=G.useRef(null),Q=G.useRef(null),qe=G.useRef(null),$=G.useRef(null),Je=G.useRef(``),Ye=G.useRef(void 0),Xe=G.useRef(n);Xe.current=n;let Ze=n?.id||null,st=G.useMemo(()=>$e(M),[M]),ft=G.useMemo(()=>Qe(M),[M]),pt=G.useMemo(()=>F===`24h`||F!==`12h`&&st,[F,st]),mt=G.useMemo(()=>ge===`sunday`?0:ge===`monday`?1:ft,[ge,ft]),ht=G.useMemo(()=>{let e=et(M);return tt(ze.map(t=>({value:t,label:e[t]||``})),mt)},[M,mt]);G.useEffect(()=>{t&&(le({source:`scheduledTaskEditor`}),ue({source:`scheduledTaskEditor`}))},[t,le,ue]),G.useEffect(()=>{if(!t){Ye.current=void 0;return}if(Ye.current===Ze)return;Ye.current=Ze;let e=Xe.current,n=ct(e,{providerID:N,modelID:P,variant:me,agent:he});Je.current=JSON.stringify(n),U(n),o?.(!1);let r=X(e?.schedule?.date||``)||new Date;Re(new Date(r.getFullYear(),r.getMonth(),1)),Ee(!1),Pe(!1),ke(!1),K(``),Me(``)},[t,Ze,N,P,me,he,o]),G.useEffect(()=>{if(!(!t||!n||V.id!==n.id||V.enabled===n.enabled)&&(U(e=>({...e,enabled:n.enabled})),Je.current)){let e=JSON.parse(Je.current);Je.current=JSON.stringify({...e,enabled:n.enabled})}},[V.enabled,V.id,t,n]),G.useEffect(()=>{!t||!Je.current||o?.(JSON.stringify(V)!==Je.current)},[V,o,t]),G.useEffect(()=>{if(!Te)return;let e=e=>{Ue.current&&!Ue.current.contains(e.target)&&Ee(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[Te]);let gt=G.useMemo(()=>fe.find(e=>e.id===V.execution.providerID)?.models?.find(e=>e.id===V.execution.modelID),[V.execution.modelID,V.execution.providerID,fe]),_t=G.useMemo(()=>gt?.variants?Object.keys(gt.variants):[],[gt]);G.useEffect(()=>{!gt||!V.execution.variant||_t.includes(V.execution.variant)||U(e=>({...e,execution:{...e.execution,variant:``}}))},[_t,V.execution.variant,gt]);let vt=G.useCallback((e,t)=>{U(n=>{let r=new Set(n.schedule.weekdays);return t?r.add(e):r.delete(e),{...n,schedule:{...n.schedule,weekdays:Array.from(r).sort((e,t)=>e-t)}}})},[]),yt=G.useCallback((e,t)=>{U(n=>{let r=n.schedule.times.slice();return r[e]=t,{...n,schedule:{...n.schedule,times:r}}})},[]),bt=G.useCallback(e=>{U(t=>{let n=t.schedule.times.filter((t,n)=>n!==e);return{...t,schedule:{...t.schedule,times:n.length>0?n:[`09:00`]}}})},[]),xt=G.useCallback(()=>{U(e=>({...e,schedule:{...e.schedule,times:[...e.schedule.times,`12:00`]}}))},[]),St=G.useMemo(()=>at(),[]),Ct=G.useMemo(()=>it(St),[St]),wt=G.useMemo(()=>{let e=X(V.schedule.onceDate);return e?ot(e,St)?j(`sessions.scheduledTasks.editor.date.today`):new Intl.DateTimeFormat(M,{weekday:`short`}).format(e):null},[V.schedule.onceDate,M,j,St]),Tt=G.useMemo(()=>it(Le).getTime()<=Ct.getTime(),[Le,Ct]),Et=G.useMemo(()=>ht.map(e=>e.label),[ht]),Dt=G.useCallback(e=>{U(t=>({...t,schedule:{...t.schedule,onceDate:e}}))},[]),Ot=G.useCallback((e,t)=>{if(e.startsWith(`/`)){let n=e.indexOf(` `),r=e.indexOf(`
|
|
2
2
|
`),i=Math.min(n===-1?e.length:n,r===-1?e.length:r);if(t<=i&&n===-1){K(e.substring(1,i)),Pe(!0),ke(!1);return}}Pe(!1);let n=e.substring(0,t),r=n.lastIndexOf(`@`);if(r!==-1){let e=r>0?n[r-1]:null,t=n.substring(r+1);(!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
|
|
3
|
-
`)?(Me(t),ke(!0)):ke(!1);return}ke(!1)},[]),kt=G.useCallback(e=>{U(t=>({...t,execution:{...t.execution,prompt:e}}))},[]),At=G.useCallback(e=>{let t=V.execution.prompt,n=Q.current?.selectionStart??t.length,r=t.substring(0,n).lastIndexOf(`@`),i=e.relativePath&&e.relativePath.trim().length>0?e.relativePath.trim():e.path||e.name,a=_e(t,r===-1?n:r,n,`@${i}`);kt(a.text),ke(!1),Me(``),requestAnimationFrame(()=>{let e=Q.current;e&&(e.selectionStart=a.caret,e.selectionEnd=a.caret,e.focus()),Ot(a.text,a.caret)})},[V.execution.prompt,kt,Ot]),jt=G.useCallback(e=>{let t=V.execution.prompt,n=Q.current?.selectionStart??t.length,r=t.substring(0,n).lastIndexOf(`@`),i=_e(t,r===-1?n:r,n,`@${e}`);kt(i.text),ke(!1),Me(``),requestAnimationFrame(()=>{let e=Q.current;e&&(e.selectionStart=i.caret,e.selectionEnd=i.caret,e.focus()),Ot(i.text,i.caret)})},[V.execution.prompt,kt,Ot]),Mt=G.useCallback(e=>{let t=`/${e.name} `;kt(t),Pe(!1),K(``),requestAnimationFrame(()=>{let e=Q.current;e&&(e.focus(),e.selectionStart=e.value.length,e.selectionEnd=e.value.length),Ot(t,t.length)})},[kt,Ot]),Nt=G.useCallback(e=>{if(Ne&&$.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)){e.preventDefault(),$.current.handleKeyDown(e.key);return}De&&qe.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),qe.current.handleKeyDown(e.key))},[Ne,De]),Pt=G.useCallback(async()=>{let e=lt(V,j);if(e){S.error(e);return}let t={...V.id?{id:V.id}:{},name:V.name.trim(),enabled:V.enabled,schedule:{kind:V.schedule.kind,timezone:V.schedule.timezone.trim(),...V.schedule.kind===`cron`?{cron:V.schedule.cronExpression.trim()}:V.schedule.kind===`once`?{date:V.schedule.onceDate,time:V.schedule.onceTime}:{times:ut(V.schedule.times),...V.schedule.kind===`weekly`?{weekdays:V.schedule.weekdays}:{}}},execution:{prompt:V.execution.prompt,providerID:V.execution.providerID,modelID:V.execution.modelID,...V.execution.variant.trim()?{variant:V.execution.variant.trim()}:{},...V.execution.agent.trim()?{agent:V.execution.agent.trim()}:{},...V.execution.goalEnabled?{goalEnabled:!0}:{}},...V.state?{state:V.state}:{}};we(!0);try{let e=await i(t);if(a===`panel`){let t=ct(e||n,{providerID:N,modelID:P,variant:me,agent:he});Je.current=JSON.stringify(t),U(t),o?.(!1)}else r(!1)}catch(e){S.error(e instanceof Error?e.message:j(`sessions.scheduledTasks.editor.toast.saveFailed`))}finally{we(!1)}},[he,P,N,me,V,o,r,i,a,j,n]),Ft=G.useId(),It=G.useCallback(()=>typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"], [data-slot="select-content"]`),[]),Lt=j(n?`sessions.scheduledTasks.editor.title.edit`:`sessions.scheduledTasks.editor.title.new`),Rt=j(`sessions.scheduledTasks.editor.description`),zt=(0,q.jsxs)(`div`,{className:g(`yuri-settings-workspace yuri-settings-page-content yuri-scheduled-task-form`,I?`yuri-settings-workspace-mobile`:`yuri-settings-workspace-desktop`),children:[(0,q.jsxs)(`div`,{className:g(`flex flex-col gap-1`,(v||y)&&`hidden`),children:[(0,q.jsx)(nt,{htmlFor:`sched-name`,required:!0,children:j(`sessions.scheduledTasks.editor.taskName.label`)}),(0,q.jsx)(pe,{id:`sched-name`,value:V.name,onChange:e=>U(t=>({...t,name:e.target.value})),placeholder:j(`sessions.scheduledTasks.editor.taskName.placeholder`),maxLength:80,required:!0,"aria-invalid":!V.name.trim(),className:`yuri-scheduled-task-title w-full`})]}),(0,q.jsxs)(`div`,{className:g(`flex flex-col gap-3 border-t border-border/40 pt-5`,T&&`yuri-settings-group order-4 animate-in fade-in slide-in-from-right-1 border-0 pt-0 duration-200 [animation-delay:80ms] [animation-fill-mode:both] motion-reduce:animate-none`),children:[T?(0,q.jsx)(`h3`,{className:Fe,children:j(`sessions.scheduledTasks.editor.panel.frequency`)}):null,(0,q.jsxs)(`div`,{className:g(T&&`yuri-settings-group-card`,T&&V.schedule.kind===`once`&&Te&&`overflow-visible`),children:[(0,q.jsx)(`div`,{className:g(`grid grid-cols-1 gap-x-4 gap-y-3`,T&&`flex flex-col gap-0`,!I&&!T&&`sm:grid-cols-2`),children:(0,q.jsxs)(`div`,{className:g(`flex min-w-0 flex-col gap-1`,T&&[D,`last:border-b`]),children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.editor.scheduleType.label`)}),(0,q.jsx)(`div`,{"data-settings-value":T?``:void 0,className:g(T&&`yuri-settings-split-row-control`),children:(0,q.jsxs)(Se,{value:V.schedule.kind,onValueChange:e=>{U(t=>({...t,schedule:{...t.schedule,kind:e,...e===`cron`&&!t.schedule.cronExpression?{cronExpression:`0 * * * *`}:{}}}))},children:[(0,q.jsx)(xe,{className:g(!T&&Be,T&&E),children:(0,q.jsx)(H,{children:e=>j(e===`daily`?`sessions.scheduledTasks.editor.scheduleType.daily`:e===`weekly`?`sessions.scheduledTasks.editor.scheduleType.weekly`:e===`cron`?`sessions.scheduledTasks.editor.scheduleType.cron`:`sessions.scheduledTasks.editor.scheduleType.once`)})}),(0,q.jsxs)(be,{className:`motion-reduce:transition-none`,children:[(0,q.jsx)(ye,{value:`daily`,children:j(`sessions.scheduledTasks.editor.scheduleType.daily`)}),(0,q.jsx)(ye,{value:`weekly`,children:j(`sessions.scheduledTasks.editor.scheduleType.weekly`)}),(0,q.jsx)(ye,{value:`once`,children:j(`sessions.scheduledTasks.editor.scheduleType.once`)}),(0,q.jsx)(ye,{value:`cron`,children:j(`sessions.scheduledTasks.editor.scheduleType.cron`)})]})]})})]})}),V.schedule.kind===`cron`?(0,q.jsx)(dt,{draft:V,setDraft:U,locale:M,t:j,panel:v,mobilePanel:C}):V.schedule.kind===`once`?(0,q.jsxs)(`div`,{className:g(`grid grid-cols-1 gap-x-4 gap-y-3`,T&&`flex flex-col gap-0`,!I&&!T&&`sm:grid-cols-2`),children:[(0,q.jsxs)(`div`,{className:g(`flex min-w-0 flex-col gap-1`,T&&D),ref:Ue,children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.editor.date.label`)}),(0,q.jsxs)(`div`,{"data-settings-value":T?``:void 0,className:g(`relative`,T&&`yuri-settings-split-row-control`),children:[(0,q.jsxs)(`button`,{type:`button`,className:g(!T&&Be,`flex items-center justify-between gap-2 text-left`,T&&[E,`w-full`]),onClick:()=>Ee(e=>!e),children:[(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(_,{name:`calendar`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:Ge(V.schedule.onceDate,j(`sessions.scheduledTasks.editor.date.placeholder`),M)})]}),(0,q.jsx)(_,{name:`arrow-down-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]}),Te?(0,q.jsxs)(`div`,{className:g(`absolute top-[calc(100%+6px)] z-50 w-[min(288px,calc(100vw-2rem))] animate-in fade-in zoom-in-95 slide-in-from-top-1 rounded-xl border border-border bg-background p-3 shadow-sm duration-150 motion-reduce:animate-none`,C?`right-0`:`left-0`),children:[(0,q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,q.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>Re(e=>Z(e,-1)),"aria-label":j(`sessions.scheduledTasks.editor.date.previousMonth`),disabled:Tt,children:(0,q.jsx)(_,{name:`arrow-left-s`,className:`h-4 w-4`})}),(0,q.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:new Intl.DateTimeFormat(M,{month:`long`,year:`numeric`}).format(Le)}),(0,q.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover`,onClick:()=>Re(e=>Z(e,1)),"aria-label":j(`sessions.scheduledTasks.editor.date.nextMonth`),children:(0,q.jsx)(_,{name:`arrow-right-s`,className:`h-4 w-4`})})]}),(0,q.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1 px-1`,children:Et.map((e,t)=>(0,q.jsx)(`div`,{className:`py-1 text-center typography-micro text-muted-foreground`,children:e},`${e}-${t}`))}),(0,q.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,children:Ke(Le,mt).map(({date:e,inCurrentMonth:t})=>{let n=We(e),r=n===V.schedule.onceDate,i=ot(e,St),a=e.getTime()<St.getTime();return(0,q.jsx)(`button`,{type:`button`,onClick:()=>{a||(Dt(n),Ee(!1))},disabled:a,className:[`h-8 rounded-md typography-ui-label`,r?`bg-interactive-selection text-interactive-selection-foreground`:a?`text-muted-foreground/40`:t?`text-foreground hover:bg-interactive-hover`:`text-muted-foreground/60 hover:bg-interactive-hover`,i&&!r?`ring-1 ring-inset ring-interactive-focusRing bg-interactive-hover/50`:``,a?`cursor-not-allowed opacity-45`:``].join(` `),children:e.getDate()},n)})}),(0,q.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-border pt-2`,children:[(0,q.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:wt||``}),(0,q.jsx)(h,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{Dt(We(St)),Re(new Date(St.getFullYear(),St.getMonth(),1))},children:j(`sessions.scheduledTasks.editor.date.jumpToToday`)})]})]}):null]})]}),(0,q.jsxs)(`div`,{className:g(`flex min-w-0 flex-col gap-1`,T&&D),children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.editor.time.label`)}),(0,q.jsx)(`div`,{"data-settings-value":T?``:void 0,className:g(T&&`yuri-settings-split-row-control`),children:(0,q.jsx)(rt,{value:V.schedule.onceTime,className:g(T&&`yuri-settings-inline-value w-fit min-w-0 justify-end`),use24Hour:pt,hourAriaLabel:j(`sessions.scheduledTasks.editor.time.hourAria`),minuteAriaLabel:j(`sessions.scheduledTasks.editor.time.minuteAria`),periodAriaLabel:j(`sessions.scheduledTasks.editor.time.periodAria`),amLabel:j(`sessions.scheduledTasks.editor.time.period.am`),pmLabel:j(`sessions.scheduledTasks.editor.time.period.pm`),onChange:e=>U(t=>({...t,schedule:{...t.schedule,onceTime:e}}))})})]})]}):(0,q.jsxs)(`div`,{className:g(`grid grid-cols-1 gap-x-4 gap-y-3`,T&&`flex flex-col gap-0`,!I&&!T&&`sm:grid-cols-2`),children:[V.schedule.kind===`weekly`?(0,q.jsxs)(`div`,{className:g(`flex flex-col gap-1`,T&&[`yuri-settings-group-row border-b border-[var(--yuri-settings-row-divider)] last:border-b-0`,`yuri-settings-split-row`],!I&&!T&&`sm:col-span-2`),children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.editor.weekdays.label`)}),(0,q.jsx)(`div`,{"data-settings-value":T?``:void 0,className:g(`flex flex-wrap gap-x-3 gap-y-2`,T&&`yuri-settings-split-row-control justify-end`),children:ht.map(e=>{let t=V.schedule.weekdays.includes(e.value);return(0,q.jsxs)(`div`,{className:[`group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta`,t?`text-foreground`:`text-muted-foreground`].join(` `),children:[(0,q.jsx)(R,{checked:t,onChange:t=>vt(e.value,t),ariaLabel:e.label}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>vt(e.value,!t),className:`group-hover:text-foreground`,children:e.label})]},e.value)})})]}):null,(0,q.jsxs)(`div`,{className:g(`flex min-w-0 flex-col gap-2`,T&&[D,`justify-start`],C&&`flex-col items-stretch`),children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.editor.times.label`)}),(0,q.jsxs)(`div`,{"data-settings-value":T?``:void 0,className:g(T?`yuri-settings-split-row-control relative flex-wrap justify-end`:`contents`),children:[(0,q.jsx)(`div`,{className:g(`flex flex-col gap-2`,T&&`flex-row flex-wrap justify-end transition-[padding] motion-reduce:transition-none`,v&&`group-hover:pr-8`),children:V.schedule.times.map((e,t)=>(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(rt,{value:e,className:g(T&&`yuri-settings-inline-value w-fit min-w-0`),use24Hour:pt,hourAriaLabel:j(`sessions.scheduledTasks.editor.time.hourAria`),minuteAriaLabel:j(`sessions.scheduledTasks.editor.time.minuteAria`),periodAriaLabel:j(`sessions.scheduledTasks.editor.time.periodAria`),amLabel:j(`sessions.scheduledTasks.editor.time.period.am`),pmLabel:j(`sessions.scheduledTasks.editor.time.period.pm`),onChange:e=>yt(t,e)}),V.schedule.times.length>1?(0,q.jsx)(h,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>bt(t),"aria-label":j(`sessions.scheduledTasks.editor.times.removeAria`),children:(0,q.jsx)(_,{name:`close`,className:`h-4 w-4`})}):null]},t))}),(0,q.jsx)(`div`,{className:g(T&&`shrink-0`,v&&`absolute right-0`),children:(0,q.jsxs)(h,{type:`button`,size:T?`icon`:`sm`,variant:T?`ghost`:`outline`,className:g(`h-9`,v&&`size-7 opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100 motion-reduce:transition-none`,C&&`size-9`),onClick:xt,"aria-label":j(`sessions.scheduledTasks.editor.times.add`),children:[(0,q.jsx)(_,{name:`add`,className:g(`h-4 w-4`,!T&&`mr-1`)}),T?null:j(`sessions.scheduledTasks.editor.times.add`)]})})]})]})]})]})]}),(0,q.jsxs)(`div`,{className:g(`flex flex-col gap-3 border-t border-border/40 pt-5`,T&&`contents`),children:[(0,q.jsxs)(`div`,{className:g(T?`yuri-settings-group order-2`:`contents`),children:[T?(0,q.jsx)(`h3`,{className:Fe,children:j(`sessions.scheduledTasks.editor.panel.details`)}):null,(0,q.jsxs)(`div`,{className:g(`grid grid-cols-1 gap-x-4 gap-y-3`,T&&[`flex flex-col gap-0 animate-in fade-in slide-in-from-right-1 duration-200 [animation-delay:40ms] [animation-fill-mode:both] motion-reduce:animate-none`,`yuri-settings-group-card`],!I&&!T&&`sm:grid-cols-2`),children:[p.length>0?(0,q.jsxs)(`div`,{className:g(`flex min-w-0 flex-col gap-1`,T&&D),children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.dialog.project.label`)}),(0,q.jsx)(`div`,{"data-settings-value":T?``:void 0,className:g(T&&`yuri-settings-split-row-control`),children:(0,q.jsxs)(Se,{value:f,disabled:!ee,onValueChange:ee,children:[(0,q.jsx)(xe,{className:g(!T&&Be,T&&E),children:(0,q.jsx)(H,{children:e=>p.find(t=>t.id===e)?.label})}),(0,q.jsx)(be,{className:`motion-reduce:transition-none`,children:p.map(e=>(0,q.jsx)(ye,{value:e.id,children:e.label},e.id))})]})})]}):null,(0,q.jsxs)(`div`,{className:g(`flex min-w-0 flex-col gap-1`,T&&D),children:[(0,q.jsx)(nt,{required:!0,children:j(`sessions.scheduledTasks.editor.model.label`)}),(0,q.jsx)(`div`,{"data-settings-value":T?``:void 0,className:g(T&&`yuri-settings-split-row-control`),children:(0,q.jsx)(W,{providerId:V.execution.providerID,modelId:V.execution.modelID,variant:V.execution.variant,className:g(!T&&Be,T&&E,`[&>div]:min-w-0 [&>div]:flex-1 [&_span]:truncate`),showIcon:!v,onChange:(e,t,n=``)=>{U(r=>({...r,execution:{...r.execution,providerID:e,modelID:t,variant:n}}))}})})]}),T?(0,q.jsxs)(`div`,{className:D,children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.editor.agent.label`)}),(0,q.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,q.jsx)(je,{agentName:V.execution.agent,className:g(E,`[&>div]:min-w-0 [&>div]:flex-1 [&_span]:truncate`),showIcon:!0,filter:e=>b(e.mode),onChange:e=>U(t=>({...t,execution:{...t.execution,agent:e}}))})})]}):null,T?(0,q.jsxs)(`label`,{className:g(D,`cursor-pointer`),children:[(0,q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:j(`sessions.scheduledTasks.editor.goal.label`)}),(0,q.jsx)(`span`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,q.jsx)(R,{checked:V.execution.goalEnabled,onChange:e=>U(t=>({...t,execution:{...t.execution,goalEnabled:e}})),ariaLabel:j(`sessions.scheduledTasks.editor.goal.aria`)})})]}):null]})]}),T?null:(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.editor.agent.label`)}),(0,q.jsx)(je,{agentName:V.execution.agent,className:g(Be,`[&>div]:min-w-0 [&>div]:flex-1 [&_span]:truncate`),filter:e=>b(e.mode),onChange:e=>U(t=>({...t,execution:{...t.execution,agent:e}}))})]}),(0,q.jsxs)(`div`,{className:g(`flex flex-col gap-1`,T&&`order-1`),children:[(0,q.jsx)(`div`,{className:g(T&&`sr-only`),children:(0,q.jsx)(nt,{htmlFor:`sched-prompt`,required:!0,children:j(`sessions.scheduledTasks.editor.prompt.label`)})}),(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(de,{id:`sched-prompt`,ref:Q,value:V.execution.prompt,onChange:e=>{let t=e.target.value;kt(t);let n=e.target.selectionStart??t.length;Ot(t,n)},onKeyDown:Nt,rows:8,outerClassName:`h-64 min-h-32`,placeholder:j(`sessions.scheduledTasks.editor.prompt.placeholder`),className:g(`typography-meta min-h-0 overflow-y-auto`,T&&`px-4 pt-4 text-base placeholder:text-muted-foreground/65`)}),Ne?(0,q.jsx)(z,{ref:$,searchQuery:Ie,onCommandSelect:Mt,onClose:()=>Pe(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,De?(0,q.jsx)(B,{ref:qe,searchQuery:Ae,onFileSelect:At,onAgentSelect:jt,onSkillSelect:e=>jt(e.name),onClose:()=>ke(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null]})]}),T?null:(0,q.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-8 gap-y-2`,children:(0,q.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2`,children:[(0,q.jsx)(R,{checked:V.execution.goalEnabled,onChange:e=>U(t=>({...t,execution:{...t.execution,goalEnabled:e}})),ariaLabel:j(`sessions.scheduledTasks.editor.goal.aria`)}),(0,q.jsx)(`span`,{className:`typography-meta`,children:j(`sessions.scheduledTasks.editor.goal.label`)})]})})]})]}),Bt=(0,q.jsxs)(`div`,{className:g(`flex flex-wrap items-center justify-between gap-3`,a===`panel`&&`justify-end`,re&&`flex-nowrap gap-2`),children:[(0,q.jsxs)(`label`,{className:g(`inline-flex items-center gap-2`,a===`panel`&&`hidden`),children:[(0,q.jsx)(R,{checked:V.enabled,onChange:e=>U(t=>({...t,enabled:e})),ariaLabel:j(`sessions.scheduledTasks.editor.enabled.aria`)}),(0,q.jsx)(`span`,{className:`typography-meta`,children:j(`sessions.scheduledTasks.editor.enabled.label`)})]}),(0,q.jsxs)(`div`,{className:g(`flex flex-wrap items-center justify-end gap-2`,re&&`ml-auto flex-nowrap`),children:[a!==`panel`&&!re?(0,q.jsx)(h,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r(!1),disabled:Ce,children:j(`sessions.scheduledTasks.editor.actions.cancel`)}):null,(0,q.jsx)(h,{type:`button`,size:`sm`,className:g(a===`panel`&&`rounded-lg`,re&&`min-h-11 px-5`),onClick:Pt,disabled:Ce,children:j(Ce?`sessions.scheduledTasks.editor.actions.saving`:n?`sessions.scheduledTasks.editor.actions.save`:`sessions.scheduledTasks.dialog.actions.create`)})]})]}),Vt=!!(n&&c),Ht=n&&l&&s?(0,q.jsxs)(ce,{children:[(0,q.jsx)(k,{asChild:!0,children:(0,q.jsx)(h,{type:`button`,variant:y?`mobileGlass`:`ghost`,size:y?`mobileIcon`:`icon`,className:g(!y&&`rounded-lg`,!y&&(I?`size-11`:`size-8`)),disabled:Ce||d,"aria-label":j(`sessions.scheduledTasks.dialog.actions.moreAria`,{taskName:n.name}),children:(0,q.jsx)(_,{name:`more-2`,className:y?`size-5`:`size-4`})})}),(0,q.jsxs)(se,{align:`end`,className:`min-w-40 motion-reduce:transition-none`,children:[(0,q.jsxs)(A,{className:g(y&&`min-h-11`),onSelect:()=>void s(n),children:[(0,q.jsx)(_,{name:`play`,className:`size-4`}),j(`sessions.scheduledTasks.dialog.actions.runNow`)]}),Vt?(0,q.jsxs)(A,{className:g(y&&`min-h-11`),onSelect:()=>c?.(n),children:[(0,q.jsx)(_,{name:`history`,className:`size-4`}),j(`sessions.scheduledTasks.workspace.views.history`)]}):null,u?(0,q.jsxs)(A,{className:g(y&&`min-h-11`),onSelect:()=>void u(n,!n.enabled),children:[(0,q.jsx)(_,{name:n.enabled?`pause`:`play`,className:`size-4`}),n.enabled?j(`sessions.scheduledTasks.dialog.taskToggle.pauseAria`,{taskName:n.name}):j(`sessions.scheduledTasks.dialog.taskToggle.enableAria`,{taskName:n.name})]}):null,(0,q.jsxs)(A,{variant:`destructive`,className:g(y&&`min-h-11`),onSelect:()=>void l(n),children:[(0,q.jsx)(_,{name:`delete-bin`,className:`size-4`}),j(`sessions.scheduledTasks.dialog.actions.delete`)]})]})]}):null;return a===`panel`?t?(0,q.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-labelledby":`scheduled-task-panel-title`,children:[(0,q.jsxs)(`header`,{className:`shrink-0 animate-in fade-in slide-in-from-right-1 px-6 pb-4 pt-5 duration-200 motion-reduce:animate-none`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`span`,{className:g(`typography-meta font-medium`,n?.enabled?`text-[var(--status-info)]`:`text-muted-foreground`),children:n?n.enabled?j(`sessions.scheduledTasks.dialog.taskToggle.enabled`):j(`sessions.scheduledTasks.dialog.taskToggle.paused`):Lt}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Ht,n&&u?(0,q.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:g(`rounded-lg`,I?`size-11`:`size-8`),disabled:Ce||d,onClick:()=>void u(n,!n.enabled),"aria-label":n.enabled?j(`sessions.scheduledTasks.dialog.taskToggle.pauseAria`,{taskName:n.name}):j(`sessions.scheduledTasks.dialog.taskToggle.enableAria`,{taskName:n.name}),children:(0,q.jsx)(_,{name:n.enabled?`pause`:`play`,className:`size-4`})}):null,(0,q.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:g(`rounded-lg`,I?`size-11`:`size-8`),onClick:()=>r(!1),"aria-label":j(`sessions.scheduledTasks.editor.actions.cancel`),children:(0,q.jsx)(_,{name:I?`arrow-left`:`close`,className:`size-4`})})]})]}),(0,q.jsx)(`h2`,{id:`scheduled-task-panel-title`,className:`sr-only`,children:Lt}),(0,q.jsx)(pe,{value:V.name,onChange:e=>U(t=>({...t,name:e.target.value})),placeholder:j(`sessions.scheduledTasks.editor.taskName.placeholder`),"aria-label":j(`sessions.scheduledTasks.editor.taskName.label`),maxLength:80,required:!0,"aria-invalid":!V.name.trim(),className:`yuri-scheduled-task-title mt-1 !h-9 !min-h-9 border-0 bg-transparent px-0 text-lg font-semibold shadow-none ring-0 hover:!bg-transparent focus:!bg-transparent focus:ring-0`})]}),(0,q.jsx)(w,{className:`min-h-0 flex-1 overflow-auto [scrollbar-gutter:stable]`,size:64,hideTopShadow:!0,children:(0,q.jsx)(`div`,{className:`px-6 pb-6 pt-2`,children:zt})}),(0,q.jsx)(`footer`,{className:`shrink-0 border-t border-border/50 bg-background/95 px-6 py-3 backdrop-blur-sm`,children:Bt})]}):null:a===`mobile-panel`?t?(0,q.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"aria-label":Lt,children:[(0,q.jsx)(w,{className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden`,size:48,hideTopShadow:!0,children:(0,q.jsx)(`div`,{className:`w-full px-3 pb-6 pt-4`,children:zt})}),(0,q.jsx)(`footer`,{className:`shrink-0 border-t border-border/50 bg-background/95 px-3 py-2 backdrop-blur-sm`,children:Bt})]}):null:a===`mobile-tab`?t?(0,q.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":Lt,children:[(0,q.jsx)(L,{sticky:!0,title:Lt,backAriaLabel:j(`header.actions.backAria`),onBack:()=>r(!1),backDisabled:Ce,trailing:[(0,q.jsx)(h,{type:`button`,size:`mobileIcon`,onClick:Pt,disabled:Ce,"aria-label":j(Ce?`sessions.scheduledTasks.editor.actions.saving`:n?`sessions.scheduledTasks.editor.actions.save`:`sessions.scheduledTasks.dialog.actions.create`),"aria-busy":Ce,children:(0,q.jsx)(_,{name:Ce?`loader-4`:`check`,className:g(`size-5`,Ce&&`animate-spin motion-reduce:animate-none`)})},`save`),Ht?(0,q.jsx)(G.Fragment,{children:Ht},`more`):null]}),(0,q.jsxs)(`div`,{className:`yuri-mobile-scheduled-editor-body min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-[var(--yuri-mobile-page-inline-inset)] pt-4`,children:[(0,q.jsxs)(`div`,{className:`mb-5 flex items-center gap-4`,children:[(0,q.jsx)(pe,{value:V.name,onChange:e=>U(t=>({...t,name:e.target.value})),placeholder:j(`sessions.scheduledTasks.editor.taskName.placeholder`),"aria-label":j(`sessions.scheduledTasks.editor.taskName.label`),maxLength:80,required:!0,"aria-invalid":!V.name.trim(),className:`yuri-scheduled-task-title yuri-mobile-detail-editor-title min-w-0 flex-1 !h-auto min-h-0 border-0 bg-transparent px-0 py-0 text-xl font-semibold shadow-none ring-0 hover:!bg-transparent focus:!bg-transparent focus:ring-0`}),(0,q.jsx)(Oe,{checked:V.enabled,onCheckedChange:e=>U(t=>({...t,enabled:e})),disabled:Ce,"aria-label":j(`sessions.scheduledTasks.editor.enabled.aria`)})]}),zt]})]}):null:I?(0,q.jsx)(ve,{open:t,title:Lt,onClose:()=>r(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,q.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:Lt}),e]}),(0,q.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:Rt})]}),footer:Bt,children:zt}):(0,q.jsx)(O,{open:t,onOpenChange:e=>{!e&&It()||r(e)},children:(0,q.jsxs)(ie,{"aria-describedby":Ft,className:`!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden`,children:[(0,q.jsx)(oe,{id:Ft,className:`sr-only`,children:Rt}),(0,q.jsx)(`header`,{className:`shrink-0 px-4 sm:px-6 pt-5 pb-3`,children:(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,q.jsx)(ae,{className:`typography-ui-label font-medium text-foreground`,children:Lt}),(0,q.jsx)(`p`,{className:`typography-meta mt-0.5 text-muted-foreground`,children:Rt})]})}),(0,q.jsx)(w,{className:`flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]`,size:64,hideTopShadow:!0,children:(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5`,children:zt})}),(0,q.jsx)(`div`,{className:`shrink-0 px-4 sm:px-6 py-3`,children:(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-2xl`,children:Bt})})]})})}function pt(e){return $(e,{min:0,max:23})}function mt(e,t){return $(String(Number.parseInt(e,10)+t),{min:0,max:23,loop:!0})}function ht(e,t){let n=Number(e),r=Number(t),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,a=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`}var gt=e=>{if(!e.enabled)return null;let t=Ae(e.assistants).pinned[0]??e.assistants[0];return t?{id:t.id,name:t.name,seed:t.avatarSeed??t.id}:null};function _t(e){let t=(0,Ne.c)(20),{assistant:n}=e,{t:r}=ne(),[i,a]=G.useState(!0),o=i?`true`:`false`,s;t[0]!==n.name||t[1]!==r?(s=r(`sessions.scheduledTasks.assistant.openAria`,{name:n.name}),t[0]=n.name,t[1]=r,t[2]=s):s=t[2];let c;t[3]===n.id?c=t[4]:(c=()=>v.getState().openAssistant(n.id),t[3]=n.id,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=e=>{e.target===e.currentTarget&&e.animationName===`yuri-schedule-assistant-clip`&&a(!1)},t[5]=l):l=t[5];let u;t[6]!==n.id||t[7]!==n.seed||t[8]!==i?(u=(0,q.jsx)(`span`,{className:`yuri-mobile-schedule-assistant-face`,"aria-hidden":`true`,children:(0,q.jsx)(I,{seed:n.seed,size:40,motion:`idle`,animateIdle:i,followPointer:!1,animationKey:n.id,blinkOnMount:2})}),t[6]=n.id,t[7]=n.seed,t[8]=i,t[9]=u):u=t[9];let d;t[10]===r?d=t[11]:(d=r(`sessions.scheduledTasks.assistant.offer`),t[10]=r,t[11]=d);let f;t[12]===d?f=t[13]:(f=(0,q.jsx)(`span`,{className:`yuri-mobile-schedule-assistant-label`,"aria-hidden":`true`,children:d}),t[12]=d,t[13]=f);let p;return t[14]!==o||t[15]!==s||t[16]!==c||t[17]!==u||t[18]!==f?(p=(0,q.jsx)(`span`,{className:`yuri-mobile-schedule-assistant-anchor`,children:(0,q.jsxs)(h,{type:`button`,variant:`ghost`,size:`mobileIcon`,className:`yuri-mobile-schedule-assistant`,"data-visiting":o,"aria-label":s,onClick:c,onAnimationEnd:l,children:[u,f]})}),t[14]=o,t[15]=s,t[16]=c,t[17]=u,t[18]=f,t[19]=p):p=t[19],p}function vt(){let e=(0,Ne.c)(2),{data:t}=F(gt),n;return e[0]===t?n=e[1]:(n=t?(0,q.jsx)(_t,{assistant:t},t.id):null,e[0]=t,e[1]=n),n}var yt=G.memo(function(e){let t=(0,Ne.c)(3),{active:n}=e,r=v(bt),i;return t[0]!==n||t[1]!==r?(i=n&&r?(0,q.jsx)(vt,{}):null,t[0]=n,t[1]=r,t[2]=i):i=t[2],i});function bt(e){return e.activeTab===`scheduled`&&e.secondary===null}var xt=e({ScheduledTasksDialog:()=>Pt,ScheduledTasksWorkspace:()=>zt}),St=e=>{let t=(Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[]).filter(e=>typeof e==`string`&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(e));return Array.from(new Set(t)).sort((e,t)=>e.localeCompare(t))},Ct=(e,t,n=!0)=>{let r=St(e).join(`, `)||`--:--`,i=e=>t(e===0?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sun`:e===1?`sessions.scheduledTasks.dialog.schedule.weekdayShort.mon`:e===2?`sessions.scheduledTasks.dialog.schedule.weekdayShort.tue`:e===3?`sessions.scheduledTasks.dialog.schedule.weekdayShort.wed`:e===4?`sessions.scheduledTasks.dialog.schedule.weekdayShort.thu`:e===5?`sessions.scheduledTasks.dialog.schedule.weekdayShort.fri`:e===6?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sat`:`sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown`);if(e.schedule.kind===`daily`)return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.dailyWithTimezone`,{time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.daily`,{time:r});if(e.schedule.kind===`weekly`){let a=Array.isArray(e.schedule.weekdays)?e.schedule.weekdays.map(e=>i(e)).join(`, `):``;return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone`,{days:a,time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.weekly`,{days:a,time:r})}if(e.schedule.kind===`once`){let r=typeof e.schedule.date==`string`&&e.schedule.date.trim().length>0?e.schedule.date:t(`sessions.scheduledTasks.dialog.schedule.unknownDate`),i=typeof e.schedule.time==`string`&&e.schedule.time.trim().length>0?e.schedule.time:`--:--`;return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.onceWithTimezone`,{date:r,time:i,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.once`,{date:r,time:i})}return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.cronWithTimezone`,{cron:e.schedule.cron||``,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.cron`,{cron:e.schedule.cron||``})},wt=(e,t)=>{if(!e||!Number.isFinite(e))return``;let n=e-Date.now(),r=Math.abs(n),i=6e4,a=60*i,o=24*a,s=n>=0;if(r<i)return t(s?`sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute`:`sessions.scheduledTasks.dialog.relativeTime.justNow`);if(r<a){let e=Math.round(r/i);return t(s?`sessions.scheduledTasks.dialog.relativeTime.inMinutes`:`sessions.scheduledTasks.dialog.relativeTime.minutesAgo`,{count:e})}if(r<o){let e=Math.floor(r/a),n=Math.round(r%a/i),o=n>0?`${e}h ${n}m`:`${e}h`;return t(s?`sessions.scheduledTasks.dialog.relativeTime.inDuration`:`sessions.scheduledTasks.dialog.relativeTime.durationAgo`,{duration:o})}let c=Math.floor(r/o),l=Math.round(r%o/a),u=l>0?`${c}d ${l}h`:`${c}d`;return t(s?`sessions.scheduledTasks.dialog.relativeTime.inDuration`:`sessions.scheduledTasks.dialog.relativeTime.durationAgo`,{duration:u})},Tt=e=>new Intl.DateTimeFormat(C(),{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e)),Et=(e,t)=>{if(e.status===`running`)return Math.max(0,t-e.startedAt);if(typeof e.finishedAt==`number`&&Number.isFinite(e.finishedAt)){let t=Math.max(0,e.finishedAt-e.startedAt);return typeof e.durationMs==`number`&&Number.isFinite(e.durationMs)&&e.durationMs>=0?Math.max(e.durationMs,t):t}return typeof e.durationMs==`number`&&Number.isFinite(e.durationMs)&&e.durationMs>=0?e.durationMs:null},Dt=e=>{if(e===null||!Number.isFinite(e)||e<0)return null;if(e<1e3)return`<1s`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;if(n<60)return r>0?`${n}m ${r}s`:`${n}m`;let i=Math.floor(n/60),a=n%60;return a>0?`${i}h ${a}m`:`${i}h`},Ot={success:{tone:`success`,Icon:`checkbox-circle`},error:{tone:`error`,Icon:`error-warning`},running:{tone:`warning`,Icon:`loader-4`,spin:!0},idle:{tone:`muted`,Icon:`pulse`}},kt=e=>e===`muted`?{}:{color:`var(--status-${e})`,backgroundColor:`var(--status-${e}-background)`,borderColor:`var(--status-${e}-border)`},At=({projectId:e,taskId:t})=>`${e}:${t}`,jt=null,Mt=()=>jt?jt():(m.getState().setScheduledTasksDialogOpen(!1),!0),Nt=(e,t,n)=>({tasks:[...e?.tasks.filter(e=>e.projectId!==t)??[],...n.map(e=>({projectId:t,task:e}))],failedProjectIds:e?.failedProjectIds.filter(e=>e!==t)??[]});function Pt(){let e=(0,Ne.c)(18),{t}=ne(),n=m(Rt),r=m(Lt);if(!m(It))return null;let i;e[0]===t?i=e[1]:(i=t(`sessions.scheduledTasks.dialog.title`),e[0]=t,e[1]=i);let a;e[2]===t?a=e[3]:(a=t(`sessions.scheduledTasks.dialog.title`),e[2]=t,e[3]=a);let o;e[4]===t?o=e[5]:(o=t(`mobile.surface.closeAria`),e[4]=t,e[5]=o);let s;e[6]===t?s=e[7]:(s=t(`mobile.sessions.sheet.resizeAria`),e[6]=t,e[7]=s);let c;e[8]!==n||e[9]!==r?(c=(0,q.jsx)(zt,{presentation:`mobile-panel`,open:n,onOpenChange:r}),e[8]=n,e[9]=r,e[10]=c):c=e[10];let l;return e[11]!==n||e[12]!==i||e[13]!==a||e[14]!==o||e[15]!==s||e[16]!==c?(l=(0,q.jsx)(T,{id:`scheduled-tasks`,open:n,initiallyExpanded:!0,title:i,ariaLabel:a,closeAriaLabel:o,resizeAriaLabel:s,onOpenChange:Ft,children:c}),e[11]=n,e[12]=i,e[13]=a,e[14]=o,e[15]=s,e[16]=c,e[17]=l):l=e[17],l}function Ft(e){e||Mt()}function It(e){return e.isMobile}function Lt(e){return e.setScheduledTasksDialogOpen}function Rt(e){return e.isScheduledTasksDialogOpen}function zt({presentation:e=`workspace`,open:t=!0,onOpenChange:r,registerEditorBackHandler:i,onEditorActiveChange:a}={}){let{t:v}=ne(),b=u.runtime()[0],x=G.useMemo(()=>[b,`scheduled-tasks`],[b]),C=G.useMemo(()=>[b,`scheduled-task-runs`],[b]),w=D(),T=m(e=>e.isMobile),ie=m(e=>e.scheduledTaskOpenRequest),ae=m(e=>e.isScheduledTasksDialogOpen),oe=m(e=>e.setMainTabGuard),O=y(e=>e.projects),de=y(e=>e.getActiveProject())?.id||O[0]?.id||``,[F,I]=G.useState(de),[L,R]=G.useState(()=>{if(T&&e!==`mobile-panel`)return null;let t=Te();return t.scheduleProjectId&&t.scheduleTaskId?{projectId:t.scheduleProjectId,taskId:t.scheduleTaskId}:null}),[z,B]=G.useState(()=>L?`edit`:`closed`),[_e,ve]=G.useState(`all`),[H,ye]=G.useState(()=>Te().scheduleView===`history`?`history`:`tasks`),[be,xe]=G.useState(``),[Se,Oe]=G.useState(!1),Ae=G.useRef(!1),W=p(e=>{Ae.current=e,Oe(e)}),[je,Me]=G.useState(null),[Ne,Pe]=G.useState(null),[Fe,Ie]=G.useState(null),[K,Le]=G.useState(null),Re=G.useRef(null),[ze,Be]=G.useState(null),Ve=G.useRef(null),He=G.useRef(null),J=e===`mobile-tab`,Y=e===`mobile-panel`||J,Ue=p(e=>{Be(J?e?.closest(`[role="tabpanel"]`)??null:e)});G.useEffect(()=>{if(J)return a?.(z!==`closed`),()=>a?.(!1)},[z,J,a]),G.useEffect(()=>{if(!t)return;let n=t=>{let n=Te();if(n.tab===`schedule`){if(T&&e!==`mobile-panel`&&n.scheduleTaskId){R(null),B(`closed`),W(!1);return}let t=n.scheduleView===`history`?`history`:`tasks`;ye(e=>e===t?e:t);let r=n.scheduleProjectId&&n.scheduleTaskId?{projectId:n.scheduleProjectId,taskId:n.scheduleTaskId}:null;R(r),B(r?`edit`:`closed`),W(!1)}else t&&e===`mobile-panel`&&r?.(!1)};return n(),window.addEventListener(`popstate`,n),()=>window.removeEventListener(`popstate`,n)},[t,T,e,r,W]),G.useEffect(()=>{!t||!ie||T&&e!==`mobile-panel`&&ae||(R(ie),B(`edit`),ye(`tasks`),W(!1),m.getState().setScheduledTaskOpenRequest(null))},[t,ie,T,e,ae,W]),G.useEffect(()=>{O.some(e=>e.id===F)||I(de)},[F,de,O]);let X=s({queryKey:x,enabled:t,refetchOnMount:`always`,queryFn:P,select:e=>({...e,tasks:[...e.tasks].sort((e,t)=>e.task.enabled===t.task.enabled?e.task.name.localeCompare(t.task.name):e.task.enabled?-1:1)})}),We=G.useMemo(()=>X.data?.tasks??[],[X.data]),Ge=X.data?.failedProjectIds??[],Z=G.useMemo(()=>L?We.find(({projectId:e,task:t})=>e===L.projectId&&t.id===L.taskId)??null:null,[L,We]),Ke=Z?.task??null,Q=c({queryKey:[...C,K?.projectId??``,K?.taskId??``],enabled:t&&H===`history`,initialPageParam:void 0,queryFn:({pageParam:e,signal:t})=>N({before:e,limit:20,...K?{projectId:K.projectId,taskId:K.taskId}:{}},t),getNextPageParam:e=>e.complete?void 0:e.nextCursor??void 0,refetchOnMount:`always`}),qe=t&&H===`history`&&z===`closed`&&!!ze&&Q.hasNextPage&&!Q.isFetching&&!Q.error;f(qe?Re:null,p(e=>{qe&&e.some(e=>e.isIntersecting)&&Q.fetchNextPage({cancelRefetch:!1})}),{root:ze,rootMargin:`0px 0px 240px 0px`});let $=G.useMemo(()=>{let e=new Set,t=[];for(let n of Q.data?.pages??[])for(let r of n.runs)e.has(r.id)||(e.add(r.id),t.push(r));return t},[Q.data]),Je=G.useMemo(()=>$.some(e=>e.status===`running`),[$]),Ye=G.useMemo(()=>{if(!K)return null;let e=We.find(({projectId:e,task:t})=>e===K.projectId&&t.id===K.taskId);return e?.task.name?e.task.name:$.find(e=>e.projectId===K.projectId&&e.taskId===K.taskId)?.taskName||K.taskId},[K,$,We]),[Xe,Ze]=G.useState(()=>Date.now());G.useEffect(()=>{if(!t||H!==`history`||!Je)return;Ze(Date.now());let e=window.setInterval(()=>Ze(Date.now()),1e3);return()=>window.clearInterval(e)},[Je,t,H]);let Qe=G.useMemo(()=>new Map(O.map(e=>[e.id,e])),[O]);G.useEffect(()=>{let e=null,t=d(t=>{(t.type===`scheduled-task-ran`||t.type===`event-stream-ready`)&&(e&&clearTimeout(e),e=setTimeout(()=>{l.invalidateQueries({queryKey:x,exact:!0}),l.invalidateQueries({queryKey:C})},400))});return()=>{e&&clearTimeout(e),t()}},[x,C]);let $e=o({mutationFn:({projectID:e,taskDraft:t})=>ge(e,t),onSuccess:(e,{projectID:t})=>{l.setQueryData(x,n=>Nt(n,t,e))}}),et=o({mutationFn:({projectID:e,taskID:t})=>he(e,t),onSuccess:(e,{projectID:t})=>{l.setQueryData(x,n=>Nt(n,t,e))}}),tt=o({mutationFn:({projectID:e,taskID:t})=>me(e,t),onSuccess:()=>{l.invalidateQueries({queryKey:x,exact:!0}),l.invalidateQueries({queryKey:C})}}),nt=o({mutationFn:({projectID:e,task:t})=>ge(e,t),onMutate:({projectID:e,task:t})=>{let n=l.getQueryData(x);return l.setQueryData(x,n=>n&&{...n,tasks:n.tasks.map(n=>n.projectId===e&&n.task.id===t.id?{projectId:e,task:t}:n)}),{previousTasks:n}},onSuccess:(e,{projectID:t})=>{l.setQueryData(x,n=>Nt(n,t,e))},onError:(e,t,n)=>{n?.previousTasks&&l.setQueryData(x,n.previousTasks)}}),rt=p(()=>!Ae.current||window.confirm(v(`sessions.scheduledTasks.workspace.confirm.discardChanges`)));G.useEffect(()=>{if(!Se){oe(null);return}let e=e=>e===`schedule`||window.confirm(v(`sessions.scheduledTasks.workspace.confirm.discardChanges`));return oe(e),()=>{m.getState().mainTabGuard===e&&oe(null)}},[Se,oe,v]);let it=p(t=>{let n={projectId:t.projectId,taskId:t.task.id};if((At(n)!==(L?At(L):``)||z!==`edit`)&&rt()){if(T&&e!==`mobile-panel`){De(n.projectId,n.taskId);return}R(n),B(`edit`),W(!1),ot(`tasks`,n)}}),at=p(()=>{!F||!rt()||(R(null),B(`create`),W(!1),ot(`tasks`,null))}),ot=p((e,t)=>{let n=m.getState();Ee({sessionId:null,tab:`schedule`,isSettingsOpen:n.isSettingsDialogOpen,settingsPath:n.settingsPage,diffFile:null,scheduleView:e,scheduleProjectId:t?.projectId??null,scheduleTaskId:t?.taskId??null})}),st=p(e=>{H!==e&&(z!==`closed`&&!rt()||(R(null),B(`closed`),W(!1),Le(null),ye(e),ot(e,null)))}),ct=p((t,i)=>{e===`mobile-panel`&&t&&i&&r?.(!1),te(t,i,{phoneShell:!!(Y&&!n()),switchToChat:!0})}),lt=p(e=>{ct(e.sessionId,e.directory)}),ut=p(e=>{z!==`closed`&&!rt()||(R(null),B(`closed`),W(!1),Le({projectId:e.projectId,taskId:e.task.id}),ye(`history`),ot(`history`,null))}),dt=p(()=>{Le(null)}),pt=p(()=>{Z&&ut(Z)}),mt=p(async()=>{if(Q.data&&Q.hasNextPage){await Q.fetchNextPage();return}await Q.refetch()}),ht=p(e=>{e||!rt()||(R(null),B(`closed`),W(!1),ot(`tasks`,null))}),gt=p(()=>e===`mobile-panel`?!rt()||(R(null),B(`closed`),W(!1),ot(`tasks`,null),r?.(!1),!0):z===`closed`?(r?.(!1),!0):(ht(!1),!0));G.useEffect(()=>{if(e!==`mobile-panel`||!t)return;jt=gt;let n=()=>gt();return window.addEventListener(`yuri:scheduled-tasks-close-request`,n),()=>{jt===gt&&(jt=null),window.removeEventListener(`yuri:scheduled-tasks-close-request`,n)}},[e,t]);let _t=p(()=>z!==`closed`&&(ht(!1),!0));fe({id:`mobile-scheduled-editor`,active:J&&z!==`closed`,onBack:_t,surfaceRef:Ve,underlayRef:He}),G.useEffect(()=>{if(i)return i(_t),()=>i(null)},[i]);let vt=p(async e=>{let t=L?.projectId||F;if(!t)throw Error(v(`sessions.scheduledTasks.dialog.error.chooseProjectFirst`));let n=new Set(We.filter(e=>e.projectId===t).map(e=>e.task.id)),r=await $e.mutateAsync({projectID:t,taskDraft:e}),i=e.id?r.find(t=>t.id===e.id):r.find(e=>!n.has(e.id)),a=[...r].filter(t=>t.name===e.name).sort((e,t)=>(t.state?.updatedAt||0)-(e.state?.updatedAt||0))[0],o=i||a;return o&&(R({projectId:t,taskId:o.id}),B(`edit`),ot(`tasks`,{projectId:t,taskId:o.id})),W(!1),S.success(v(`sessions.scheduledTasks.dialog.toast.saved`)),o}),bt=p(async e=>{let{projectId:t,task:n}=e;if(window.confirm(v(`sessions.scheduledTasks.dialog.confirm.deleteTask`,{taskName:n.name}))){Me(At({projectId:t,taskId:n.id}));try{await et.mutateAsync({projectID:t,taskID:n.id});let e=At({projectId:t,taskId:n.id});L&&At(L)===e&&(R(null),B(`closed`),W(!1),ot(`tasks`,null)),S.success(v(`sessions.scheduledTasks.dialog.toast.deleted`))}catch(e){S.error(e instanceof Error?e.message:v(`sessions.scheduledTasks.dialog.toast.deleteFailed`))}finally{Me(null)}}}),xt=p(async({projectId:e,task:t})=>{Me(At({projectId:e,taskId:t.id}));try{await tt.mutateAsync({projectID:e,taskID:t.id}),S.success(v(`sessions.scheduledTasks.dialog.toast.started`))}catch(e){S.error(e instanceof Error?e.message:v(`sessions.scheduledTasks.dialog.toast.runFailed`))}finally{Me(null)}}),St=p(async({projectId:e,task:t},n)=>{Me(At({projectId:e,taskId:t.id}));try{await nt.mutateAsync({projectID:e,task:{...t,enabled:n}})}catch(e){S.error(e instanceof Error?e.message:v(`sessions.scheduledTasks.dialog.toast.updateFailed`))}finally{Me(null)}}),Mt=G.useMemo(()=>{let e=be.trim().toLocaleLowerCase();return We.filter(({task:t})=>_e===`active`&&!t.enabled||_e===`paused`&&t.enabled?!1:!e||t.name.toLocaleLowerCase().includes(e)||Ct(t,v).toLocaleLowerCase().includes(e))},[_e,be,v,We]),Pt=e=>{let t=e.icon?Ce[e.icon]:null,n=e.color?we[e.color]:void 0,r=(0,q.jsx)(_,{name:t??`folder`,className:`size-3.5`,style:n?{color:n}:void 0});return(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`relative top-px flex size-4 shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,children:e.iconImage?(0,q.jsx)(U,{project:e,className:`size-full object-contain`,fallback:r}):r}),(0,q.jsx)(`span`,{className:`truncate`,children:ee(e.path)})]})},Ft=O.map(e=>({id:e.id,label:Pt(e)}));return(0,q.jsxs)(`div`,{className:g(`relative flex min-h-0`,J?`yuri-mobile-scheduled-workspace w-full flex-col overflow-visible bg-transparent`:`h-full overflow-hidden bg-background`,Y&&`flex-col`),"data-presentation":e,children:[(0,q.jsxs)(`div`,{ref:J?He:void 0,"data-mobile-navigation-underlay":J?`true`:void 0,"aria-hidden":J&&z!==`closed`?!0:void 0,inert:J&&z!==`closed`?!0:void 0,className:g(J?`flex w-full min-w-0 flex-col gap-[var(--yuri-mobile-page-gap)]`:`contents`),children:[J?(0,q.jsx)(ke,{title:v(`sessions.scheduledTasks.dialog.title`),trailing:(0,q.jsx)(yt,{active:z===`closed`})}):null,Y&&!J?(0,q.jsx)(re,{children:z===`edit`&&Z?(0,q.jsxs)(ce,{children:[(0,q.jsx)(k,{asChild:!0,children:(0,q.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:`size-11 shrink-0 rounded-lg`,disabled:!!je,"aria-label":v(`sessions.scheduledTasks.dialog.actions.moreAria`,{taskName:Z.task.name}),children:(0,q.jsx)(_,{name:`more-2`,className:`size-5`})})}),(0,q.jsxs)(se,{align:`end`,className:`min-w-40`,children:[(0,q.jsxs)(A,{className:`min-h-11`,onSelect:()=>void xt(Z),children:[(0,q.jsx)(_,{name:`play`,className:`size-4`}),v(`sessions.scheduledTasks.dialog.actions.runNow`)]}),(0,q.jsxs)(A,{className:`min-h-11`,onSelect:()=>ut(Z),children:[(0,q.jsx)(_,{name:`history`,className:`size-4`}),v(`sessions.scheduledTasks.workspace.views.history`)]}),(0,q.jsxs)(A,{className:`min-h-11`,onSelect:()=>void St(Z,!Z.task.enabled),children:[(0,q.jsx)(_,{name:Z.task.enabled?`pause`:`play`,className:`size-4`}),Z.task.enabled?v(`sessions.scheduledTasks.dialog.actions.pause`):v(`sessions.scheduledTasks.dialog.actions.resume`)]}),(0,q.jsxs)(A,{variant:`destructive`,className:`min-h-11`,onSelect:()=>void bt(Z),children:[(0,q.jsx)(_,{name:`delete-bin`,className:`size-4`}),v(`sessions.scheduledTasks.dialog.actions.delete`)]})]})]}):null}):null,(0,q.jsxs)(`section`,{className:g(`min-w-0 flex-col transition-[width] duration-300 ease-out`,J?`flex-none overflow-visible`:`flex-1 overflow-hidden`,Y&&!J&&z!==`closed`?`hidden`:`flex`),children:[(0,q.jsx)(`header`,{className:g(`shrink-0`,J?`pb-0 pt-0`:Y?`px-3 pb-3 pt-3`:`px-4 pb-5 pt-4 sm:px-6`),children:(0,q.jsxs)(`div`,{className:g(`mx-auto w-full`,J?`max-w-[26rem]`:`max-w-4xl`),children:[(0,q.jsx)(`div`,{className:g((H===`tasks`||K||!J)&&`mb-3`,J?`yuri-mobile-floating-surface yuri-mobile-segmented-track`:`grid grid-cols-2 gap-1 rounded-xl bg-[var(--surface-muted)] p-1`),role:`tablist`,"aria-label":v(`sessions.scheduledTasks.workspace.views.aria`),children:[`tasks`,`history`].map(e=>(0,q.jsxs)(h,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":H===e,className:g(J?`yuri-mobile-segmented-item`:`relative min-h-9 rounded-lg text-muted-foreground transition-[background-color,color,box-shadow] motion-reduce:transition-none`,!J&&Y&&`min-h-11`,!J&&(H===e?`text-foreground hover:bg-transparent hover:text-foreground`:`hover:bg-interactive-hover/40 hover:text-foreground`)),onClick:()=>st(e),children:[H===e?(0,q.jsx)(V.span,{layoutId:`scheduled-workspace-view-pill`,className:g(`yuri-segmented-selected-pill absolute inset-0`,!J&&`rounded-lg`),transition:{duration:w?0:.18,ease:[.22,1,.36,1]},"aria-hidden":`true`}):null,(0,q.jsxs)(`span`,{className:`relative z-[1] inline-flex items-center gap-1.5`,children:[(0,q.jsx)(_,{name:e===`tasks`?`calendar-schedule`:`history`,className:`size-4 shrink-0`}),v(`sessions.scheduledTasks.workspace.views.${e}`)]})]},e))}),H===`history`&&Ye?(0,q.jsx)(`div`,{className:g(`flex min-w-0 items-center`,J?`mt-[var(--yuri-mobile-page-gap)]`:`mt-3`),role:`status`,"aria-label":v(`sessions.scheduledTasks.history.filter.aria`,{name:Ye}),children:(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1 rounded-full border border-border/60 bg-[var(--surface-elevated)] py-1 pl-3 pr-1`,children:[(0,q.jsx)(`span`,{className:`min-w-0 truncate typography-meta text-foreground`,children:Ye}),(0,q.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:g(`shrink-0 rounded-full`,Y?`size-8`:`size-7`),onClick:dt,"aria-label":v(`sessions.scheduledTasks.history.filter.clearAria`),children:(0,q.jsx)(_,{name:`close`,className:`size-3.5`})})]})}):null,H===`tasks`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:g(J?`yuri-mobile-floating-surface yuri-mobile-segmented-track yuri-mobile-scheduled-controls`:g(`flex items-center justify-between`,Y?`gap-2`:`gap-3`)),children:[(0,q.jsx)(`div`,{className:g(J?`yuri-mobile-segmented-group`:g(`flex items-center gap-1`,Y&&`min-w-0 flex-1`)),role:`group`,"aria-label":v(`sessions.scheduledTasks.dialog.title`),children:[`all`,`active`,`paused`].map(e=>(0,q.jsxs)(h,{type:`button`,variant:`ghost`,size:`sm`,className:g(J?`yuri-mobile-segmented-item`:`relative border-0 bg-transparent text-muted-foreground shadow-none transition-[color,background-color] duration-150 ease-out motion-reduce:transition-none`,!J&&(Y?`h-11 min-h-11 min-w-0 flex-1 rounded-xl px-2`:`!h-9 !min-h-9 rounded-xl px-3`),!J&&(_e===e?`text-foreground hover:bg-transparent hover:text-foreground`:`hover:bg-interactive-hover/40 hover:text-foreground`)),"aria-pressed":_e===e,onClick:()=>ve(e),children:[_e===e?(0,q.jsx)(V.span,{layoutId:`scheduled-task-filter-pill`,className:g(`yuri-segmented-selected-pill absolute inset-0`,!J&&`rounded-xl`),transition:{duration:w?0:.18,ease:[.22,1,.36,1]},"aria-hidden":`true`}):null,(0,q.jsx)(`span`,{className:`relative z-[1]`,children:v(`sessions.scheduledTasks.workspace.filters.${e}`)})]},e))}),J?(0,q.jsx)(h,{variant:`mobileGlass`,size:`mobileIcon`,"data-mobile-press-feedback":`compact`,className:`yuri-mobile-segmented-action yuri-mobile-inverse-action shrink-0`,onClick:at,disabled:!F,"aria-label":v(`sessions.scheduledTasks.dialog.actions.create`),children:(0,q.jsx)(_,{name:`add`,className:`size-5`})}):(0,q.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,q.jsxs)(h,{variant:`ghost`,"data-mobile-press-feedback":Y?`compact`:void 0,className:g(`shrink-0 rounded-full bg-foreground text-background transition-[background-color,box-shadow] duration-150 ease-out hover:bg-foreground/90 hover:text-background hover:shadow-sm active:bg-interactive-active motion-reduce:transition-none`,Y?`size-11 min-h-11 px-0 min-[400px]:w-auto min-[400px]:px-3.5`:`!h-9 !min-h-9 px-3.5`),onClick:at,disabled:!F,"aria-label":v(`sessions.scheduledTasks.dialog.actions.create`),children:[(0,q.jsx)(_,{name:`add`,className:`h-4 w-4`}),` `,(0,q.jsx)(`span`,{className:g(Y&&`hidden min-[400px]:inline`),children:v(`sessions.scheduledTasks.dialog.actions.create`)})]})})]}),J?null:(0,q.jsxs)(`div`,{className:g(`group relative w-full`,Y?`mt-3`:`mt-7`),children:[(0,q.jsx)(_,{name:`search`,className:`pointer-events-none absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground transition-[color,transform] duration-150 ease-out group-focus-within:scale-105 group-focus-within:text-foreground motion-reduce:transition-none`}),(0,q.jsx)(pe,{value:be,onChange:e=>xe(e.target.value),placeholder:v(`sessions.scheduledTasks.workspace.search.placeholder`),className:g(`rounded-full bg-[var(--surface-elevated)] pl-10 pr-4 ring-1 ring-inset ring-border/50 transition-[background-color,box-shadow,color] duration-200 ease-out hover:[&:not(:focus)]:ring-border focus:bg-[var(--surface-elevated)] focus:shadow-sm focus:ring-2 focus:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,Y?`h-11 min-h-11`:`!h-9 !min-h-9`)})]})]}):null]})}),(0,q.jsx)(`div`,{ref:Ue,className:g(J?`flex-none overflow-visible pt-[var(--yuri-mobile-page-gap)]`:`min-h-0 flex-1 overflow-y-auto`,!J&&(Y?`overscroll-none px-3 pb-[max(1rem,env(safe-area-inset-bottom))]`:`px-6 pb-6 [scrollbar-gutter:stable]`)),children:(0,q.jsx)(`div`,{className:g(`mx-auto w-full`,J?`max-w-[26rem]`:`max-w-4xl pt-4`),children:H===`history`?(0,q.jsxs)(`div`,{className:`space-y-3`,children:[Q.isLoading?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 typography-meta text-muted-foreground`,children:[(0,q.jsx)(_,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}),v(`sessions.scheduledTasks.history.loading`)]}):Q.error&&$.length===0?(0,q.jsx)(`div`,{className:`rounded-xl border border-dashed border-border p-4`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(_,{name:`error-warning`,className:`mt-0.5 size-4 shrink-0 text-[var(--status-error)]`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`p`,{className:`typography-ui-label font-medium text-foreground`,children:v(`sessions.scheduledTasks.history.error.title`)}),(0,q.jsx)(`p`,{className:`mt-1 break-words typography-meta text-muted-foreground`,children:Q.error instanceof Error?Q.error.message:v(`sessions.scheduledTasks.history.error.description`)})]}),(0,q.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>void mt(),children:v(`sessions.scheduledTasks.history.retry`)})]})}):$.length===0?(0,q.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border p-6 text-center`,children:[(0,q.jsx)(_,{name:`history`,className:`mx-auto size-5 text-muted-foreground`}),(0,q.jsx)(`p`,{className:`mt-2 typography-ui-label font-medium text-foreground`,children:v(`sessions.scheduledTasks.history.empty.title`)}),(0,q.jsx)(`p`,{className:`mt-1 typography-meta text-muted-foreground`,children:v(`sessions.scheduledTasks.history.empty.description`)})]}):(0,q.jsxs)(`div`,{className:g(J?`space-y-4`:Y?`space-y-2`:`divide-y divide-border/50 overflow-hidden rounded-xl border border-border/60 bg-[var(--surface-elevated)]`),children:[$.map(e=>{let t=Qe.get(e.projectId),n=t?ee(t.path):e.projectId,r=e.directory?ee(e.directory):null,i=r&&r!==n?`${n} · ${r}`:n,a=Ot[e.status],o=!!(e.sessionId&&e.directory),s=Dt(Et(e,Xe))??(e.status===`running`?v(`sessions.scheduledTasks.history.duration.pending`):null),c=Tt(e.startedAt),l=v(`sessions.scheduledTasks.history.trigger.${e.trigger}`),u=e.trigger===`manual`?`play`:`calendar-schedule`,d=v(`sessions.scheduledTasks.dialog.status.${e.status}`),f=a.tone===`muted`?void 0:{color:`var(--status-${a.tone})`},p=t?.icon?Ce[t.icon]??`folder`:`folder`,m=t?.color?we[t.color]:void 0,h=(0,q.jsx)(`span`,{className:`flex size-3.5 shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,children:t?.iconImage?(0,q.jsx)(U,{project:t,className:`size-full object-contain`,fallback:(0,q.jsx)(_,{name:p,className:`size-3.5`,style:m?{color:m}:void 0})}):(0,q.jsx)(_,{name:p,className:`size-3.5`,style:m?{color:m}:void 0})}),te=(0,q.jsx)(`span`,{className:g(`mt-0.5 flex shrink-0 items-center justify-center rounded-full border`,Y?`size-7`:`size-8`),style:kt(a.tone),title:d,"aria-label":d,children:(0,q.jsx)(_,{name:a.Icon,className:g(Y?`size-3.5`:`size-4`,a.spin&&`animate-spin motion-reduce:animate-none`)})}),y=(0,q.jsxs)(`p`,{className:g(`mt-0.5 flex min-w-0 items-center gap-1.5 text-muted-foreground`,Y?`typography-micro`:`truncate typography-meta`),title:e.directory??n,children:[h,(0,q.jsx)(`span`,{className:g(`min-w-0`,Y?`break-words`:`truncate`),children:i})]}),b=(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[s?(0,q.jsx)(`span`,{className:`typography-micro tabular-nums text-muted-foreground`,title:s,children:s}):null,(0,q.jsx)(`span`,{className:`typography-micro font-medium`,style:f,children:d})]}),x=(0,q.jsxs)(`div`,{className:g(`flex w-full min-w-0 items-start`,Y?`gap-2.5`:`gap-3`),children:[te,(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex w-full min-w-0 items-start justify-between gap-2`,children:[(0,q.jsx)(`h3`,{className:g(`min-w-0 flex-1 font-semibold text-foreground`,Y?`break-words typography-meta leading-snug`:`truncate typography-ui-label`),children:e.taskName}),b]}),y,(0,q.jsxs)(`div`,{className:g(`mt-1 flex w-full min-w-0 gap-2`,Y?`items-center`:`items-center justify-between gap-3`),children:[(0,q.jsxs)(`div`,{className:g(`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1 typography-micro text-muted-foreground`,Y&&`gap-x-2.5 gap-y-0.5`),children:[(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,title:c,children:[(0,q.jsx)(_,{name:`time`,className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`whitespace-nowrap tabular-nums`,children:c})]}),(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,title:l,children:[(0,q.jsx)(_,{name:u,className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`whitespace-nowrap`,children:l})]})]}),!Y&&o?(0,q.jsx)(`span`,{className:`shrink-0 self-center typography-ui-label font-medium text-foreground`,children:v(`sessions.scheduledTasks.history.openSession`)}):null]}),e.error?(0,q.jsxs)(`p`,{className:g(`mt-1.5 min-w-0 break-words typography-micro text-[var(--surface-muted-foreground)] [overflow-wrap:anywhere]`,Y?`line-clamp-3`:`line-clamp-1`),title:e.error.slice(0,300),children:[(0,q.jsx)(_,{name:`error-warning`,className:`mr-1 inline-block size-3 align-[-0.125em] text-[var(--status-error)]`,"aria-hidden":`true`}),e.error.slice(0,300)]}):null]})]});if(Y){let t=v(`sessions.scheduledTasks.history.openSession`),n=g(`yuri-mobile-scheduled-task-card w-full`,J?`yuri-mobile-floating-surface yuri-mobile-project-shell rounded-[var(--yuri-mobile-surface-radius)]`:`rounded-xl border border-border/60 bg-[var(--surface-elevated)] shadow-sm dark:shadow-none`);return o?(0,q.jsx)(`article`,{"data-mobile-press-surface":`soft`,className:n,children:(0,q.jsx)(`button`,{type:`button`,"data-mobile-press-surface-trigger":!0,className:g(`yuri-mobile-scheduled-task-row w-full p-3 text-left outline-none`,`focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`),"aria-label":t,onClick:()=>lt(e),children:x})},e.id):(0,q.jsx)(`article`,{className:g(n,`p-3`),children:x},e.id)}return o?(0,q.jsx)(`article`,{className:`w-full min-w-0`,children:(0,q.jsx)(`button`,{type:`button`,className:`w-full min-w-0 px-4 py-3 text-left outline-none transition-colors hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,"aria-label":v(`sessions.scheduledTasks.history.openSession`),onClick:()=>lt(e),children:x})},e.id):(0,q.jsx)(`article`,{className:`w-full min-w-0 px-4 py-3`,children:x},e.id)}),Q.error?(0,q.jsxs)(`div`,{className:g(`flex flex-wrap items-center justify-between gap-2 p-3 typography-meta text-[var(--status-error-foreground)]`,Y?`rounded-xl border border-[var(--status-error-border)] bg-[var(--status-error-background)]`:`border-t border-[var(--status-error-border)] bg-[var(--status-error-background)]`),children:[(0,q.jsx)(`span`,{children:v(`sessions.scheduledTasks.history.error.more`)}),(0,q.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>void mt(),children:v(`sessions.scheduledTasks.history.retry`)})]}):null]}),Q.hasNextPage?(0,q.jsx)(`div`,{ref:Re,className:`flex min-h-px justify-center`,children:Q.isFetchingNextPage?(0,q.jsx)(`span`,{role:`status`,"aria-label":v(`sessions.scheduledTasks.history.loadingMore`),className:`py-1 text-muted-foreground`,children:(0,q.jsx)(_,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":`true`})}):null}):null]}):(0,q.jsxs)(q.Fragment,{children:[Ge.length>0?(0,q.jsx)(`div`,{className:`mb-3 rounded-xl border p-3 typography-meta`,style:kt(`warning`),children:v(`sessions.scheduledTasks.workspace.partialLoadWarning`)}):null,X.isLoading?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 typography-meta text-muted-foreground`,children:[(0,q.jsx)(_,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),` `,v(`sessions.scheduledTasks.dialog.loading`)]}):X.error&&!X.data?(0,q.jsx)(`div`,{className:`rounded-xl border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:X.error instanceof Error?X.error.message:v(`sessions.scheduledTasks.dialog.toast.loadFailed`)}):(0,q.jsx)(E,{initial:!1,mode:`popLayout`,children:Mt.length===0?(0,q.jsx)(V.div,{initial:w?{opacity:0}:{opacity:0,y:4},animate:{opacity:1,y:0},exit:w?{opacity:0}:{opacity:0,y:-4},transition:{duration:w?0:.18,ease:[.22,1,.36,1]},className:`rounded-xl border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:We.length>0?v(`sessions.scheduledTasks.workspace.search.noResults`):v(`sessions.scheduledTasks.dialog.empty.noTasks`)},`empty`):(0,q.jsx)(V.div,{initial:w?{opacity:0}:{opacity:0,y:4},animate:{opacity:1,y:0},exit:w?{opacity:0}:{opacity:0,y:-4},transition:{duration:w?0:.18,ease:[.22,1,.36,1]},className:g(J?`space-y-4`:`space-y-1`),children:(0,q.jsx)(E,{initial:!1,mode:`popLayout`,children:Mt.map(e=>{let{projectId:t,task:n}=e,r=At({projectId:t,taskId:n.id}),i=z===`edit`&&L!==null&&At(L)===r,a=n.state?.nextRunAt,o=n.state?.lastStatus||`idle`,s=Ot[o],c=je===r,l=t=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(t,{className:g(Y&&`min-h-11`),onClick:t=>{t.stopPropagation(),xt(e)},disabled:c,children:[(0,q.jsx)(_,{name:`play`,className:`size-4`}),v(`sessions.scheduledTasks.dialog.actions.runNow`)]}),(0,q.jsxs)(t,{className:g(Y&&`min-h-11`),onClick:t=>{t.stopPropagation(),ut(e)},children:[(0,q.jsx)(_,{name:`history`,className:`size-4`}),v(`sessions.scheduledTasks.workspace.views.history`)]}),(0,q.jsxs)(t,{className:g(Y&&`min-h-11`),onClick:t=>{t.stopPropagation(),St(e,!n.enabled)},disabled:c,children:[(0,q.jsx)(_,{name:n.enabled?`pause`:`play`,className:`size-4`}),n.enabled?v(`sessions.scheduledTasks.dialog.actions.pause`):v(`sessions.scheduledTasks.dialog.actions.resume`)]}),(0,q.jsxs)(t,{onClick:t=>{t.stopPropagation(),bt(e)},disabled:c,className:g(`text-destructive focus:text-destructive`,Y&&`min-h-11`),children:[(0,q.jsx)(_,{name:`delete-bin`,className:`size-4 text-inherit`}),v(`sessions.scheduledTasks.dialog.actions.delete`)]})]});return(0,q.jsx)(V.div,{layout:`position`,initial:!w&&{opacity:0,y:6},animate:{opacity:1,y:0},exit:w?{opacity:0}:{opacity:0,y:-6},transition:{duration:w?0:.18,ease:[.22,1,.36,1]},"data-mobile-press-surface":J?`soft`:void 0,className:g(J&&`yuri-mobile-floating-surface yuri-mobile-project-shell yuri-mobile-scheduled-task-card`),children:(0,q.jsxs)(ue,{open:Ne===r,onOpenChange:e=>{e&&Ie(null),Pe(e?r:null)},children:[(0,q.jsxs)(`div`,{className:g(`group flex w-full items-center gap-1`,J&&`yuri-mobile-project-card`),children:[(0,q.jsxs)(j,{render:(0,q.jsx)(`button`,{type:`button`,onClick:()=>it(e),onContextMenu:!Y&&!T?e=>{e.preventDefault(),Ie(null),Pe(r)}:void 0,"data-mobile-press-surface-trigger":J?!0:void 0,className:g(`flex min-h-11 min-w-0 flex-1 items-center rounded-xl border py-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,J?`yuri-mobile-project-trigger yuri-mobile-scheduled-task-row border-0 bg-transparent transition-opacity duration-150`:`transition-[background-color,border-color,box-shadow,opacity] duration-150 ease-out active:bg-interactive-active`,Y&&!J?`gap-2.5 px-3`:J?void 0:`gap-3 px-4`,!J&&(i?`border-border/50 bg-[var(--surface-elevated)] shadow-sm dark:shadow-none`:`border-transparent hover:bg-interactive-hover`),!n.enabled&&`opacity-65`),"aria-pressed":i}),children:[(0,q.jsx)(`span`,{className:g(`flex shrink-0 items-center justify-center rounded-full text-muted-foreground transition-[border-color,color,background-color] duration-150 motion-reduce:transition-none`,J?`yuri-mobile-project-icon yuri-mobile-glass-control`:`size-5 border border-border`),style:n.enabled&&s.tone!==`muted`?{color:`var(--status-${s.tone})`}:void 0,children:(0,q.jsx)(E,{initial:!1,mode:`wait`,children:(0,q.jsx)(V.span,{initial:!w&&{opacity:0,scale:.72},animate:{opacity:1,scale:1},exit:w?{opacity:0}:{opacity:0,scale:.72},transition:{duration:w?0:.15},className:`flex`,children:(0,q.jsx)(_,{name:n.enabled?s.Icon:`pause`,className:g(J?`yuri-mobile-project-icon-glyph`:`size-3.5`,s.spin&&n.enabled&&`animate-spin`)})},`${n.enabled}-${o}`)})}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:g(`block truncate font-medium`,J?`yuri-mobile-project-title yuri-mobile-entity-title font-semibold`:`typography-ui-label`),children:n.name}),(0,q.jsxs)(`span`,{className:g(`mt-1 flex min-w-0 items-center text-muted-foreground`,J?`yuri-mobile-project-meta yuri-mobile-entity-meta`:`gap-1 typography-micro`),children:[(0,q.jsx)(`span`,{className:`truncate`,children:Ct(n,v,!J)}),(0,q.jsx)(`span`,{className:`shrink-0 text-muted-foreground/50`,children:`·`}),(0,q.jsx)(`span`,{className:`shrink-0 truncate`,children:a?wt(a,v):`—`})]})]})]}),(0,q.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:g(`shrink-0 self-center rounded-lg text-muted-foreground`,Y?`size-11 rounded-full`:`size-9`),onClick:t=>{t.stopPropagation(),ut(e)},"aria-label":v(`sessions.scheduledTasks.workspace.views.history`),children:(0,q.jsx)(_,{name:`history`,className:`size-4`})}),(0,q.jsxs)(ce,{open:Fe===r,onOpenChange:e=>{e&&Pe(null),Ie(e?r:null)},children:[(0,q.jsx)(k,{asChild:!0,children:(0,q.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:g(`shrink-0 self-center text-muted-foreground transition-[opacity,transform,background-color] duration-150 ease-out data-[popup-open]:bg-interactive-hover motion-reduce:transition-none`,J?`yuri-mobile-project-action yuri-mobile-scheduled-task-action rounded-full`:`rounded-lg`,J?void 0:Y?`size-11`:`size-8 translate-x-1 opacity-0 group-hover:translate-x-0 group-hover:opacity-100 data-[popup-open]:translate-x-0 data-[popup-open]:opacity-100`,i&&!J&&`opacity-100`),onClick:e=>e.stopPropagation(),"aria-label":v(`sessions.scheduledTasks.dialog.actions.moreAria`,{taskName:n.name}),children:(0,q.jsx)(_,{name:`more-2`,className:J?`size-5`:`size-4`})})}),(0,q.jsx)(se,{align:`end`,className:`min-w-40 motion-reduce:transition-none`,onClick:e=>e.stopPropagation(),children:l(A)})]})]}),(0,q.jsx)(M,{className:`min-w-40 motion-reduce:transition-none`,children:l(le)})]})},r)})})},`tasks`)})]})})})]})]}),z===`edit`&&!Ke?(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-4`,role:`status`,children:[X.isPending?v(`sessions.scheduledTasks.dialog.loading`):v(`common.unavailable`),X.isPending?null:(0,q.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>void X.refetch(),children:v(`assistants.actions.retry`)})]}):null,T?z===`create`||z===`edit`&&Ke?(0,q.jsx)(`div`,{ref:J?Ve:void 0,className:g(J?`yuri-mobile-scheduled-editor-overlay flex w-full min-w-0 max-w-full flex-col overflow-hidden bg-background [contain:layout_paint]`:`contents`),children:(0,q.jsx)(ft,{open:!0,presentation:J?`mobile-tab`:Y?`mobile-panel`:void 0,task:z===`edit`?Ke:null,onOpenChange:ht,onSave:vt,onDirtyChange:W,onRun:async()=>{Z&&await xt(Z)},onOpenTaskHistory:pt,onDelete:async()=>{Z&&await bt(Z)},onToggleEnabled:async(e,t)=>{Z&&await St(Z,t)},actionBusy:!!je,projectID:L?.projectId||F,projectOptions:Ft,onProjectChange:z===`create`?I:void 0})}):null:(0,q.jsx)(E,{initial:!1,children:z===`create`||z===`edit`&&Ke?(0,q.jsx)(V.div,{initial:w?{opacity:1,width:0}:{opacity:0,width:0,x:24},animate:{opacity:1,width:`clamp(380px, 36vw, 480px)`,x:0},exit:w?{opacity:0,width:0}:{opacity:0,width:0,x:24},transition:{duration:w?0:.26,ease:[.22,1,.36,1]},className:`h-full min-h-0 max-w-[480px] shrink-0 overflow-hidden`,children:(0,q.jsx)(`aside`,{className:`h-full min-h-0 w-[clamp(380px,36vw,480px)] border-l border-border/60 bg-background`,children:(0,q.jsx)(ft,{open:!0,presentation:`panel`,task:z===`edit`?Ke:null,onOpenChange:ht,onSave:vt,onDirtyChange:W,onRun:async()=>{Z&&await xt(Z)},onOpenTaskHistory:pt,onDelete:async()=>{Z&&await bt(Z)},onToggleEnabled:async(e,t)=>{Z&&await St(Z,t)},actionBusy:!!je,projectID:L?.projectId||F,projectOptions:Ft,onProjectChange:z===`create`?I:void 0})})},`scheduled-task-details`):null})]})}export{zt as n,xt as t};
|
|
3
|
+
`)?(Me(t),ke(!0)):ke(!1);return}ke(!1)},[]),kt=G.useCallback(e=>{U(t=>({...t,execution:{...t.execution,prompt:e}}))},[]),At=G.useCallback(e=>{let t=V.execution.prompt,n=Q.current?.selectionStart??t.length,r=t.substring(0,n).lastIndexOf(`@`),i=e.relativePath&&e.relativePath.trim().length>0?e.relativePath.trim():e.path||e.name,a=_e(t,r===-1?n:r,n,`@${i}`);kt(a.text),ke(!1),Me(``),requestAnimationFrame(()=>{let e=Q.current;e&&(e.selectionStart=a.caret,e.selectionEnd=a.caret,e.focus()),Ot(a.text,a.caret)})},[V.execution.prompt,kt,Ot]),jt=G.useCallback(e=>{let t=V.execution.prompt,n=Q.current?.selectionStart??t.length,r=t.substring(0,n).lastIndexOf(`@`),i=_e(t,r===-1?n:r,n,`@${e}`);kt(i.text),ke(!1),Me(``),requestAnimationFrame(()=>{let e=Q.current;e&&(e.selectionStart=i.caret,e.selectionEnd=i.caret,e.focus()),Ot(i.text,i.caret)})},[V.execution.prompt,kt,Ot]),Mt=G.useCallback(e=>{let t=`/${e.name} `;kt(t),Pe(!1),K(``),requestAnimationFrame(()=>{let e=Q.current;e&&(e.focus(),e.selectionStart=e.value.length,e.selectionEnd=e.value.length),Ot(t,t.length)})},[kt,Ot]),Nt=G.useCallback(e=>{if(Ne&&$.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)){e.preventDefault(),$.current.handleKeyDown(e.key);return}De&&qe.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),qe.current.handleKeyDown(e.key))},[Ne,De]),Pt=G.useCallback(async()=>{let e=lt(V,j);if(e){S.error(e);return}let t={...V.id?{id:V.id}:{},name:V.name.trim(),enabled:V.enabled,schedule:{kind:V.schedule.kind,timezone:V.schedule.timezone.trim(),...V.schedule.kind===`cron`?{cron:V.schedule.cronExpression.trim()}:V.schedule.kind===`once`?{date:V.schedule.onceDate,time:V.schedule.onceTime}:{times:ut(V.schedule.times),...V.schedule.kind===`weekly`?{weekdays:V.schedule.weekdays}:{}}},execution:{prompt:V.execution.prompt,providerID:V.execution.providerID,modelID:V.execution.modelID,...V.execution.variant.trim()?{variant:V.execution.variant.trim()}:{},...V.execution.agent.trim()?{agent:V.execution.agent.trim()}:{},...V.execution.goalEnabled?{goalEnabled:!0}:{}},...V.state?{state:V.state}:{}};we(!0);try{let e=await i(t);if(a===`panel`){let t=ct(e||n,{providerID:N,modelID:P,variant:me,agent:he});Je.current=JSON.stringify(t),U(t),o?.(!1)}else r(!1)}catch(e){S.error(e instanceof Error?e.message:j(`sessions.scheduledTasks.editor.toast.saveFailed`))}finally{we(!1)}},[he,P,N,me,V,o,r,i,a,j,n]),Ft=G.useId(),It=G.useCallback(()=>typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"], [data-slot="select-content"]`),[]),Lt=j(n?`sessions.scheduledTasks.editor.title.edit`:`sessions.scheduledTasks.editor.title.new`),Rt=j(`sessions.scheduledTasks.editor.description`),zt=(0,q.jsxs)(`div`,{className:g(`yuri-settings-workspace yuri-settings-page-content yuri-scheduled-task-form`,I?`yuri-settings-workspace-mobile`:`yuri-settings-workspace-desktop`),children:[(0,q.jsxs)(`div`,{className:g(`flex flex-col gap-1`,(y||x)&&`hidden`),children:[(0,q.jsx)(nt,{htmlFor:`sched-name`,required:!0,children:j(`sessions.scheduledTasks.editor.taskName.label`)}),(0,q.jsx)(pe,{id:`sched-name`,value:V.name,onChange:e=>U(t=>({...t,name:e.target.value})),placeholder:j(`sessions.scheduledTasks.editor.taskName.placeholder`),maxLength:80,required:!0,"aria-invalid":!V.name.trim(),className:`yuri-scheduled-task-title w-full`})]}),(0,q.jsxs)(`div`,{className:g(`flex flex-col gap-3 border-t border-border/40 pt-5`,T&&`yuri-settings-group order-4 animate-in fade-in slide-in-from-right-1 border-0 pt-0 duration-200 [animation-delay:80ms] [animation-fill-mode:both] motion-reduce:animate-none`),children:[T?(0,q.jsx)(`h3`,{className:Fe,children:j(`sessions.scheduledTasks.editor.panel.frequency`)}):null,(0,q.jsxs)(`div`,{className:g(T&&`yuri-settings-group-card`,T&&V.schedule.kind===`once`&&Te&&`overflow-visible`),children:[(0,q.jsx)(`div`,{className:g(`grid grid-cols-1 gap-x-4 gap-y-3`,T&&`flex flex-col gap-0`,!I&&!T&&`sm:grid-cols-2`),children:(0,q.jsxs)(`div`,{className:g(`flex min-w-0 flex-col gap-1`,T&&[D,`last:border-b`]),children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.editor.scheduleType.label`)}),(0,q.jsx)(`div`,{"data-settings-value":T?``:void 0,className:g(T&&`yuri-settings-split-row-control`),children:(0,q.jsxs)(Se,{value:V.schedule.kind,onValueChange:e=>{U(t=>({...t,schedule:{...t.schedule,kind:e,...e===`cron`&&!t.schedule.cronExpression?{cronExpression:`0 * * * *`}:{}}}))},children:[(0,q.jsx)(xe,{className:g(!T&&Be,T&&E),children:(0,q.jsx)(H,{children:e=>j(e===`daily`?`sessions.scheduledTasks.editor.scheduleType.daily`:e===`weekly`?`sessions.scheduledTasks.editor.scheduleType.weekly`:e===`cron`?`sessions.scheduledTasks.editor.scheduleType.cron`:`sessions.scheduledTasks.editor.scheduleType.once`)})}),(0,q.jsxs)(be,{className:`motion-reduce:transition-none`,children:[(0,q.jsx)(ye,{value:`daily`,children:j(`sessions.scheduledTasks.editor.scheduleType.daily`)}),(0,q.jsx)(ye,{value:`weekly`,children:j(`sessions.scheduledTasks.editor.scheduleType.weekly`)}),(0,q.jsx)(ye,{value:`once`,children:j(`sessions.scheduledTasks.editor.scheduleType.once`)}),(0,q.jsx)(ye,{value:`cron`,children:j(`sessions.scheduledTasks.editor.scheduleType.cron`)})]})]})})]})}),V.schedule.kind===`cron`?(0,q.jsx)(dt,{draft:V,setDraft:U,locale:M,t:j,panel:y,mobilePanel:C}):V.schedule.kind===`once`?(0,q.jsxs)(`div`,{className:g(`grid grid-cols-1 gap-x-4 gap-y-3`,T&&`flex flex-col gap-0`,!I&&!T&&`sm:grid-cols-2`),children:[(0,q.jsxs)(`div`,{className:g(`flex min-w-0 flex-col gap-1`,T&&D),ref:Ue,children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.editor.date.label`)}),(0,q.jsxs)(`div`,{"data-settings-value":T?``:void 0,className:g(`relative`,T&&`yuri-settings-split-row-control`),children:[(0,q.jsxs)(`button`,{type:`button`,className:g(!T&&Be,`flex items-center justify-between gap-2 text-left`,T&&[E,`w-full`]),onClick:()=>Ee(e=>!e),children:[(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(_,{name:`calendar`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:Ge(V.schedule.onceDate,j(`sessions.scheduledTasks.editor.date.placeholder`),M)})]}),(0,q.jsx)(_,{name:`arrow-down-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]}),Te?(0,q.jsxs)(`div`,{className:g(`absolute top-[calc(100%+6px)] z-50 w-[min(288px,calc(100vw-2rem))] animate-in fade-in zoom-in-95 slide-in-from-top-1 rounded-xl border border-border bg-background p-3 shadow-sm duration-150 motion-reduce:animate-none`,C?`right-0`:`left-0`),children:[(0,q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,q.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>Re(e=>Z(e,-1)),"aria-label":j(`sessions.scheduledTasks.editor.date.previousMonth`),disabled:Tt,children:(0,q.jsx)(_,{name:`arrow-left-s`,className:`h-4 w-4`})}),(0,q.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:new Intl.DateTimeFormat(M,{month:`long`,year:`numeric`}).format(Le)}),(0,q.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover`,onClick:()=>Re(e=>Z(e,1)),"aria-label":j(`sessions.scheduledTasks.editor.date.nextMonth`),children:(0,q.jsx)(_,{name:`arrow-right-s`,className:`h-4 w-4`})})]}),(0,q.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1 px-1`,children:Et.map((e,t)=>(0,q.jsx)(`div`,{className:`py-1 text-center typography-micro text-muted-foreground`,children:e},`${e}-${t}`))}),(0,q.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,children:Ke(Le,mt).map(({date:e,inCurrentMonth:t})=>{let n=We(e),r=n===V.schedule.onceDate,i=ot(e,St),a=e.getTime()<St.getTime();return(0,q.jsx)(`button`,{type:`button`,onClick:()=>{a||(Dt(n),Ee(!1))},disabled:a,className:[`h-8 rounded-md typography-ui-label`,r?`bg-interactive-selection text-interactive-selection-foreground`:a?`text-muted-foreground/40`:t?`text-foreground hover:bg-interactive-hover`:`text-muted-foreground/60 hover:bg-interactive-hover`,i&&!r?`ring-1 ring-inset ring-interactive-focusRing bg-interactive-hover/50`:``,a?`cursor-not-allowed opacity-45`:``].join(` `),children:e.getDate()},n)})}),(0,q.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-border pt-2`,children:[(0,q.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:wt||``}),(0,q.jsx)(h,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{Dt(We(St)),Re(new Date(St.getFullYear(),St.getMonth(),1))},children:j(`sessions.scheduledTasks.editor.date.jumpToToday`)})]})]}):null]})]}),(0,q.jsxs)(`div`,{className:g(`flex min-w-0 flex-col gap-1`,T&&D),children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.editor.time.label`)}),(0,q.jsx)(`div`,{"data-settings-value":T?``:void 0,className:g(T&&`yuri-settings-split-row-control`),children:(0,q.jsx)(rt,{value:V.schedule.onceTime,className:g(T&&`yuri-settings-inline-value w-fit min-w-0 justify-end`),use24Hour:pt,hourAriaLabel:j(`sessions.scheduledTasks.editor.time.hourAria`),minuteAriaLabel:j(`sessions.scheduledTasks.editor.time.minuteAria`),periodAriaLabel:j(`sessions.scheduledTasks.editor.time.periodAria`),amLabel:j(`sessions.scheduledTasks.editor.time.period.am`),pmLabel:j(`sessions.scheduledTasks.editor.time.period.pm`),onChange:e=>U(t=>({...t,schedule:{...t.schedule,onceTime:e}}))})})]})]}):(0,q.jsxs)(`div`,{className:g(`grid grid-cols-1 gap-x-4 gap-y-3`,T&&`flex flex-col gap-0`,!I&&!T&&`sm:grid-cols-2`),children:[V.schedule.kind===`weekly`?(0,q.jsxs)(`div`,{className:g(`flex flex-col gap-1`,T&&[`yuri-settings-group-row border-b border-[var(--yuri-settings-row-divider)] last:border-b-0`,`yuri-settings-split-row`],!I&&!T&&`sm:col-span-2`),children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.editor.weekdays.label`)}),(0,q.jsx)(`div`,{"data-settings-value":T?``:void 0,className:g(`flex flex-wrap gap-x-3 gap-y-2`,T&&`yuri-settings-split-row-control justify-end`),children:ht.map(e=>{let t=V.schedule.weekdays.includes(e.value);return(0,q.jsxs)(`div`,{className:[`group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta`,t?`text-foreground`:`text-muted-foreground`].join(` `),children:[(0,q.jsx)(R,{checked:t,onChange:t=>vt(e.value,t),ariaLabel:e.label}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>vt(e.value,!t),className:`group-hover:text-foreground`,children:e.label})]},e.value)})})]}):null,(0,q.jsxs)(`div`,{className:g(`flex min-w-0 flex-col gap-2`,T&&[D,`justify-start`],C&&`flex-col items-stretch`),children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.editor.times.label`)}),(0,q.jsxs)(`div`,{"data-settings-value":T?``:void 0,className:g(T?`yuri-settings-split-row-control relative flex-wrap justify-end`:`contents`),children:[(0,q.jsx)(`div`,{className:g(`flex flex-col gap-2`,T&&`flex-row flex-wrap justify-end transition-[padding] motion-reduce:transition-none`,y&&`group-hover:pr-8`),children:V.schedule.times.map((e,t)=>(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(rt,{value:e,className:g(T&&`yuri-settings-inline-value w-fit min-w-0`),use24Hour:pt,hourAriaLabel:j(`sessions.scheduledTasks.editor.time.hourAria`),minuteAriaLabel:j(`sessions.scheduledTasks.editor.time.minuteAria`),periodAriaLabel:j(`sessions.scheduledTasks.editor.time.periodAria`),amLabel:j(`sessions.scheduledTasks.editor.time.period.am`),pmLabel:j(`sessions.scheduledTasks.editor.time.period.pm`),onChange:e=>yt(t,e)}),V.schedule.times.length>1?(0,q.jsx)(h,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>bt(t),"aria-label":j(`sessions.scheduledTasks.editor.times.removeAria`),children:(0,q.jsx)(_,{name:`close`,className:`h-4 w-4`})}):null]},t))}),(0,q.jsx)(`div`,{className:g(T&&`shrink-0`,y&&`absolute right-0`),children:(0,q.jsxs)(h,{type:`button`,size:T?`icon`:`sm`,variant:T?`ghost`:`outline`,className:g(`h-9`,y&&`size-7 opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100 motion-reduce:transition-none`,C&&`size-9`),onClick:xt,"aria-label":j(`sessions.scheduledTasks.editor.times.add`),children:[(0,q.jsx)(_,{name:`add`,className:g(`h-4 w-4`,!T&&`mr-1`)}),T?null:j(`sessions.scheduledTasks.editor.times.add`)]})})]})]})]})]})]}),(0,q.jsxs)(`div`,{className:g(`flex flex-col gap-3 border-t border-border/40 pt-5`,T&&`contents`),children:[(0,q.jsxs)(`div`,{className:g(T?`yuri-settings-group order-2`:`contents`),children:[T?(0,q.jsx)(`h3`,{className:Fe,children:j(`sessions.scheduledTasks.editor.panel.details`)}):null,(0,q.jsxs)(`div`,{className:g(`grid grid-cols-1 gap-x-4 gap-y-3`,T&&[`flex flex-col gap-0 animate-in fade-in slide-in-from-right-1 duration-200 [animation-delay:40ms] [animation-fill-mode:both] motion-reduce:animate-none`,`yuri-settings-group-card`],!I&&!T&&`sm:grid-cols-2`),children:[p.length>0?(0,q.jsxs)(`div`,{className:g(`flex min-w-0 flex-col gap-1`,T&&D),children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.dialog.project.label`)}),(0,q.jsx)(`div`,{"data-settings-value":T?``:void 0,className:g(T&&`yuri-settings-split-row-control`),children:(0,q.jsxs)(Se,{value:f,disabled:!ee,onValueChange:ee,children:[(0,q.jsx)(xe,{className:g(!T&&Be,T&&E),children:(0,q.jsx)(H,{children:e=>p.find(t=>t.id===e)?.label})}),(0,q.jsx)(be,{className:`motion-reduce:transition-none`,children:p.map(e=>(0,q.jsx)(ye,{value:e.id,children:e.label},e.id))})]})})]}):null,(0,q.jsxs)(`div`,{className:g(`flex min-w-0 flex-col gap-1`,T&&D),children:[(0,q.jsx)(nt,{required:!0,children:j(`sessions.scheduledTasks.editor.model.label`)}),(0,q.jsx)(`div`,{"data-settings-value":T?``:void 0,className:g(T&&`yuri-settings-split-row-control`),children:(0,q.jsx)(W,{providerId:V.execution.providerID,modelId:V.execution.modelID,variant:V.execution.variant,className:g(!T&&Be,T&&E,`[&>div]:min-w-0 [&>div]:flex-1 [&_span]:truncate`),showIcon:!y,onChange:(e,t,n=``)=>{U(r=>({...r,execution:{...r.execution,providerID:e,modelID:t,variant:n}}))}})})]}),T?(0,q.jsxs)(`div`,{className:D,children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.editor.agent.label`)}),(0,q.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,q.jsx)(je,{agentName:V.execution.agent,className:g(E,`[&>div]:min-w-0 [&>div]:flex-1 [&_span]:truncate`),showIcon:!0,filter:e=>v(e.mode),onChange:e=>U(t=>({...t,execution:{...t.execution,agent:e}}))})})]}):null,T?(0,q.jsxs)(`label`,{className:g(D,`cursor-pointer`),children:[(0,q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:j(`sessions.scheduledTasks.editor.goal.label`)}),(0,q.jsx)(`span`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,q.jsx)(R,{checked:V.execution.goalEnabled,onChange:e=>U(t=>({...t,execution:{...t.execution,goalEnabled:e}})),ariaLabel:j(`sessions.scheduledTasks.editor.goal.aria`)})})]}):null]})]}),T?null:(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,q.jsx)(nt,{children:j(`sessions.scheduledTasks.editor.agent.label`)}),(0,q.jsx)(je,{agentName:V.execution.agent,className:g(Be,`[&>div]:min-w-0 [&>div]:flex-1 [&_span]:truncate`),filter:e=>v(e.mode),onChange:e=>U(t=>({...t,execution:{...t.execution,agent:e}}))})]}),(0,q.jsxs)(`div`,{className:g(`flex flex-col gap-1`,T&&`order-1`),children:[(0,q.jsx)(`div`,{className:g(T&&`sr-only`),children:(0,q.jsx)(nt,{htmlFor:`sched-prompt`,required:!0,children:j(`sessions.scheduledTasks.editor.prompt.label`)})}),(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(de,{id:`sched-prompt`,ref:Q,value:V.execution.prompt,onChange:e=>{let t=e.target.value;kt(t);let n=e.target.selectionStart??t.length;Ot(t,n)},onKeyDown:Nt,rows:8,outerClassName:`h-64 min-h-32`,placeholder:j(`sessions.scheduledTasks.editor.prompt.placeholder`),className:g(`typography-meta min-h-0 overflow-y-auto`,T&&`px-4 pt-4 text-base placeholder:text-muted-foreground/65`)}),Ne?(0,q.jsx)(z,{ref:$,searchQuery:Ie,onCommandSelect:Mt,onClose:()=>Pe(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,De?(0,q.jsx)(B,{ref:qe,searchQuery:Ae,onFileSelect:At,onAgentSelect:jt,onSkillSelect:e=>jt(e.name),onClose:()=>ke(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null]})]}),T?null:(0,q.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-8 gap-y-2`,children:(0,q.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2`,children:[(0,q.jsx)(R,{checked:V.execution.goalEnabled,onChange:e=>U(t=>({...t,execution:{...t.execution,goalEnabled:e}})),ariaLabel:j(`sessions.scheduledTasks.editor.goal.aria`)}),(0,q.jsx)(`span`,{className:`typography-meta`,children:j(`sessions.scheduledTasks.editor.goal.label`)})]})})]})]}),Bt=(0,q.jsxs)(`div`,{className:g(`flex flex-wrap items-center justify-between gap-3`,a===`panel`&&`justify-end`,re&&`flex-nowrap gap-2`),children:[(0,q.jsxs)(`label`,{className:g(`inline-flex items-center gap-2`,a===`panel`&&`hidden`),children:[(0,q.jsx)(R,{checked:V.enabled,onChange:e=>U(t=>({...t,enabled:e})),ariaLabel:j(`sessions.scheduledTasks.editor.enabled.aria`)}),(0,q.jsx)(`span`,{className:`typography-meta`,children:j(`sessions.scheduledTasks.editor.enabled.label`)})]}),(0,q.jsxs)(`div`,{className:g(`flex flex-wrap items-center justify-end gap-2`,re&&`ml-auto flex-nowrap`),children:[a!==`panel`&&!re?(0,q.jsx)(h,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r(!1),disabled:Ce,children:j(`sessions.scheduledTasks.editor.actions.cancel`)}):null,(0,q.jsx)(h,{type:`button`,size:`sm`,className:g(a===`panel`&&`rounded-lg`,re&&`min-h-11 px-5`),onClick:Pt,disabled:Ce,children:j(Ce?`sessions.scheduledTasks.editor.actions.saving`:n?`sessions.scheduledTasks.editor.actions.save`:`sessions.scheduledTasks.dialog.actions.create`)})]})]}),Vt=!!(n&&c),Ht=n&&l&&s?(0,q.jsxs)(ce,{children:[(0,q.jsx)(k,{asChild:!0,children:(0,q.jsx)(h,{type:`button`,variant:x?`mobileGlass`:`ghost`,size:x?`mobileIcon`:`icon`,className:g(!x&&`rounded-lg`,!x&&(I?`size-11`:`size-8`)),disabled:Ce||d,"aria-label":j(`sessions.scheduledTasks.dialog.actions.moreAria`,{taskName:n.name}),children:(0,q.jsx)(_,{name:`more-2`,className:x?`size-5`:`size-4`})})}),(0,q.jsxs)(se,{align:`end`,className:`min-w-40 motion-reduce:transition-none`,children:[(0,q.jsxs)(A,{className:g(x&&`min-h-11`),onSelect:()=>void s(n),children:[(0,q.jsx)(_,{name:`play`,className:`size-4`}),j(`sessions.scheduledTasks.dialog.actions.runNow`)]}),Vt?(0,q.jsxs)(A,{className:g(x&&`min-h-11`),onSelect:()=>c?.(n),children:[(0,q.jsx)(_,{name:`history`,className:`size-4`}),j(`sessions.scheduledTasks.workspace.views.history`)]}):null,u?(0,q.jsxs)(A,{className:g(x&&`min-h-11`),onSelect:()=>void u(n,!n.enabled),children:[(0,q.jsx)(_,{name:n.enabled?`pause`:`play`,className:`size-4`}),n.enabled?j(`sessions.scheduledTasks.dialog.taskToggle.pauseAria`,{taskName:n.name}):j(`sessions.scheduledTasks.dialog.taskToggle.enableAria`,{taskName:n.name})]}):null,(0,q.jsxs)(A,{variant:`destructive`,className:g(x&&`min-h-11`),onSelect:()=>void l(n),children:[(0,q.jsx)(_,{name:`delete-bin`,className:`size-4`}),j(`sessions.scheduledTasks.dialog.actions.delete`)]})]})]}):null;return a===`panel`?t?(0,q.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-labelledby":`scheduled-task-panel-title`,children:[(0,q.jsxs)(`header`,{className:`shrink-0 animate-in fade-in slide-in-from-right-1 px-6 pb-4 pt-5 duration-200 motion-reduce:animate-none`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`span`,{className:g(`typography-meta font-medium`,n?.enabled?`text-[var(--status-info)]`:`text-muted-foreground`),children:n?n.enabled?j(`sessions.scheduledTasks.dialog.taskToggle.enabled`):j(`sessions.scheduledTasks.dialog.taskToggle.paused`):Lt}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Ht,n&&u?(0,q.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:g(`rounded-lg`,I?`size-11`:`size-8`),disabled:Ce||d,onClick:()=>void u(n,!n.enabled),"aria-label":n.enabled?j(`sessions.scheduledTasks.dialog.taskToggle.pauseAria`,{taskName:n.name}):j(`sessions.scheduledTasks.dialog.taskToggle.enableAria`,{taskName:n.name}),children:(0,q.jsx)(_,{name:n.enabled?`pause`:`play`,className:`size-4`})}):null,(0,q.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:g(`rounded-lg`,I?`size-11`:`size-8`),onClick:()=>r(!1),"aria-label":j(`sessions.scheduledTasks.editor.actions.cancel`),children:(0,q.jsx)(_,{name:I?`arrow-left`:`close`,className:`size-4`})})]})]}),(0,q.jsx)(`h2`,{id:`scheduled-task-panel-title`,className:`sr-only`,children:Lt}),(0,q.jsx)(pe,{value:V.name,onChange:e=>U(t=>({...t,name:e.target.value})),placeholder:j(`sessions.scheduledTasks.editor.taskName.placeholder`),"aria-label":j(`sessions.scheduledTasks.editor.taskName.label`),maxLength:80,required:!0,"aria-invalid":!V.name.trim(),className:`yuri-scheduled-task-title mt-1 !h-9 !min-h-9 border-0 bg-transparent px-0 text-lg font-semibold shadow-none ring-0 hover:!bg-transparent focus:!bg-transparent focus:ring-0`})]}),(0,q.jsx)(w,{className:`min-h-0 flex-1 overflow-auto [scrollbar-gutter:stable]`,size:64,hideTopShadow:!0,children:(0,q.jsx)(`div`,{className:`px-6 pb-6 pt-2`,children:zt})}),(0,q.jsx)(`footer`,{className:`shrink-0 border-t border-border/50 bg-background/95 px-6 py-3 backdrop-blur-sm`,children:Bt})]}):null:a===`mobile-panel`?t?(0,q.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"aria-label":Lt,children:[(0,q.jsx)(w,{className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden`,size:48,hideTopShadow:!0,children:(0,q.jsx)(`div`,{className:`w-full px-3 pb-6 pt-4`,children:zt})}),(0,q.jsx)(`footer`,{className:`shrink-0 border-t border-border/50 bg-background/95 px-3 py-2 backdrop-blur-sm`,children:Bt})]}):null:a===`mobile-tab`?t?(0,q.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":Lt,children:[(0,q.jsx)(L,{sticky:!0,title:Lt,backAriaLabel:j(`header.actions.backAria`),onBack:()=>r(!1),backDisabled:Ce,trailing:[(0,q.jsx)(h,{type:`button`,size:`mobileIcon`,onClick:Pt,disabled:Ce,"aria-label":j(Ce?`sessions.scheduledTasks.editor.actions.saving`:n?`sessions.scheduledTasks.editor.actions.save`:`sessions.scheduledTasks.dialog.actions.create`),"aria-busy":Ce,children:(0,q.jsx)(_,{name:Ce?`loader-4`:`check`,className:g(`size-5`,Ce&&`animate-spin motion-reduce:animate-none`)})},`save`),Ht?(0,q.jsx)(G.Fragment,{children:Ht},`more`):null]}),(0,q.jsxs)(`div`,{className:`yuri-mobile-scheduled-editor-body min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-[var(--yuri-mobile-page-inline-inset)] pt-4`,children:[(0,q.jsxs)(`div`,{className:`mb-5 flex items-center gap-4`,children:[(0,q.jsx)(pe,{value:V.name,onChange:e=>U(t=>({...t,name:e.target.value})),placeholder:j(`sessions.scheduledTasks.editor.taskName.placeholder`),"aria-label":j(`sessions.scheduledTasks.editor.taskName.label`),maxLength:80,required:!0,"aria-invalid":!V.name.trim(),className:`yuri-scheduled-task-title yuri-mobile-detail-editor-title min-w-0 flex-1 !h-auto min-h-0 border-0 bg-transparent px-0 py-0 text-xl font-semibold shadow-none ring-0 hover:!bg-transparent focus:!bg-transparent focus:ring-0`}),(0,q.jsx)(Oe,{checked:V.enabled,onCheckedChange:e=>U(t=>({...t,enabled:e})),disabled:Ce,"aria-label":j(`sessions.scheduledTasks.editor.enabled.aria`)})]}),zt]})]}):null:I?(0,q.jsx)(ve,{open:t,title:Lt,onClose:()=>r(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,q.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:Lt}),e]}),(0,q.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:Rt})]}),footer:Bt,children:zt}):(0,q.jsx)(O,{open:t,onOpenChange:e=>{!e&&It()||r(e)},children:(0,q.jsxs)(ie,{"aria-describedby":Ft,className:`!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden`,children:[(0,q.jsx)(oe,{id:Ft,className:`sr-only`,children:Rt}),(0,q.jsx)(`header`,{className:`shrink-0 px-4 sm:px-6 pt-5 pb-3`,children:(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,q.jsx)(ae,{className:`typography-ui-label font-medium text-foreground`,children:Lt}),(0,q.jsx)(`p`,{className:`typography-meta mt-0.5 text-muted-foreground`,children:Rt})]})}),(0,q.jsx)(w,{className:`flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]`,size:64,hideTopShadow:!0,children:(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5`,children:zt})}),(0,q.jsx)(`div`,{className:`shrink-0 px-4 sm:px-6 py-3`,children:(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-2xl`,children:Bt})})]})})}function pt(e){return $(e,{min:0,max:23})}function mt(e,t){return $(String(Number.parseInt(e,10)+t),{min:0,max:23,loop:!0})}function ht(e,t){let n=Number(e),r=Number(t),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,a=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`}var gt=e=>{if(!e.enabled)return null;let t=Ae(e.assistants).pinned[0]??e.assistants[0];return t?{id:t.id,name:t.name,seed:t.avatarSeed??t.id}:null};function _t(e){let t=(0,Ne.c)(20),{assistant:n}=e,{t:r}=ne(),[i,a]=G.useState(!0),o=i?`true`:`false`,s;t[0]!==n.name||t[1]!==r?(s=r(`sessions.scheduledTasks.assistant.openAria`,{name:n.name}),t[0]=n.name,t[1]=r,t[2]=s):s=t[2];let c;t[3]===n.id?c=t[4]:(c=()=>y.getState().openAssistant(n.id),t[3]=n.id,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=e=>{e.target===e.currentTarget&&e.animationName===`yuri-schedule-assistant-clip`&&a(!1)},t[5]=l):l=t[5];let u;t[6]!==n.id||t[7]!==n.seed||t[8]!==i?(u=(0,q.jsx)(`span`,{className:`yuri-mobile-schedule-assistant-face`,"aria-hidden":`true`,children:(0,q.jsx)(I,{seed:n.seed,size:40,motion:`idle`,animateIdle:i,followPointer:!1,animationKey:n.id,blinkOnMount:2})}),t[6]=n.id,t[7]=n.seed,t[8]=i,t[9]=u):u=t[9];let d;t[10]===r?d=t[11]:(d=r(`sessions.scheduledTasks.assistant.offer`),t[10]=r,t[11]=d);let f;t[12]===d?f=t[13]:(f=(0,q.jsx)(`span`,{className:`yuri-mobile-schedule-assistant-label`,"aria-hidden":`true`,children:d}),t[12]=d,t[13]=f);let p;return t[14]!==o||t[15]!==s||t[16]!==c||t[17]!==u||t[18]!==f?(p=(0,q.jsx)(`span`,{className:`yuri-mobile-schedule-assistant-anchor`,children:(0,q.jsxs)(h,{type:`button`,variant:`ghost`,size:`mobileIcon`,className:`yuri-mobile-schedule-assistant`,"data-visiting":o,"aria-label":s,onClick:c,onAnimationEnd:l,children:[u,f]})}),t[14]=o,t[15]=s,t[16]=c,t[17]=u,t[18]=f,t[19]=p):p=t[19],p}function vt(){let e=(0,Ne.c)(2),{data:t}=F(gt),n;return e[0]===t?n=e[1]:(n=t?(0,q.jsx)(_t,{assistant:t},t.id):null,e[0]=t,e[1]=n),n}var yt=G.memo(function(e){let t=(0,Ne.c)(3),{active:n}=e,r=y(bt),i;return t[0]!==n||t[1]!==r?(i=n&&r?(0,q.jsx)(vt,{}):null,t[0]=n,t[1]=r,t[2]=i):i=t[2],i});function bt(e){return e.activeTab===`scheduled`&&e.secondary===null}var xt=e({ScheduledTasksDialog:()=>Pt,ScheduledTasksWorkspace:()=>zt}),St=e=>{let t=(Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[]).filter(e=>typeof e==`string`&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(e));return Array.from(new Set(t)).sort((e,t)=>e.localeCompare(t))},Ct=(e,t,n=!0)=>{let r=St(e).join(`, `)||`--:--`,i=e=>t(e===0?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sun`:e===1?`sessions.scheduledTasks.dialog.schedule.weekdayShort.mon`:e===2?`sessions.scheduledTasks.dialog.schedule.weekdayShort.tue`:e===3?`sessions.scheduledTasks.dialog.schedule.weekdayShort.wed`:e===4?`sessions.scheduledTasks.dialog.schedule.weekdayShort.thu`:e===5?`sessions.scheduledTasks.dialog.schedule.weekdayShort.fri`:e===6?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sat`:`sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown`);if(e.schedule.kind===`daily`)return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.dailyWithTimezone`,{time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.daily`,{time:r});if(e.schedule.kind===`weekly`){let a=Array.isArray(e.schedule.weekdays)?e.schedule.weekdays.map(e=>i(e)).join(`, `):``;return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone`,{days:a,time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.weekly`,{days:a,time:r})}if(e.schedule.kind===`once`){let r=typeof e.schedule.date==`string`&&e.schedule.date.trim().length>0?e.schedule.date:t(`sessions.scheduledTasks.dialog.schedule.unknownDate`),i=typeof e.schedule.time==`string`&&e.schedule.time.trim().length>0?e.schedule.time:`--:--`;return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.onceWithTimezone`,{date:r,time:i,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.once`,{date:r,time:i})}return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.cronWithTimezone`,{cron:e.schedule.cron||``,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.cron`,{cron:e.schedule.cron||``})},wt=(e,t)=>{if(!e||!Number.isFinite(e))return``;let n=e-Date.now(),r=Math.abs(n),i=6e4,a=60*i,o=24*a,s=n>=0;if(r<i)return t(s?`sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute`:`sessions.scheduledTasks.dialog.relativeTime.justNow`);if(r<a){let e=Math.round(r/i);return t(s?`sessions.scheduledTasks.dialog.relativeTime.inMinutes`:`sessions.scheduledTasks.dialog.relativeTime.minutesAgo`,{count:e})}if(r<o){let e=Math.floor(r/a),n=Math.round(r%a/i),o=n>0?`${e}h ${n}m`:`${e}h`;return t(s?`sessions.scheduledTasks.dialog.relativeTime.inDuration`:`sessions.scheduledTasks.dialog.relativeTime.durationAgo`,{duration:o})}let c=Math.floor(r/o),l=Math.round(r%o/a),u=l>0?`${c}d ${l}h`:`${c}d`;return t(s?`sessions.scheduledTasks.dialog.relativeTime.inDuration`:`sessions.scheduledTasks.dialog.relativeTime.durationAgo`,{duration:u})},Tt=e=>new Intl.DateTimeFormat(C(),{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e)),Et=(e,t)=>{if(e.status===`running`)return Math.max(0,t-e.startedAt);if(typeof e.finishedAt==`number`&&Number.isFinite(e.finishedAt)){let t=Math.max(0,e.finishedAt-e.startedAt);return typeof e.durationMs==`number`&&Number.isFinite(e.durationMs)&&e.durationMs>=0?Math.max(e.durationMs,t):t}return typeof e.durationMs==`number`&&Number.isFinite(e.durationMs)&&e.durationMs>=0?e.durationMs:null},Dt=e=>{if(e===null||!Number.isFinite(e)||e<0)return null;if(e<1e3)return`<1s`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;if(n<60)return r>0?`${n}m ${r}s`:`${n}m`;let i=Math.floor(n/60),a=n%60;return a>0?`${i}h ${a}m`:`${i}h`},Ot={success:{tone:`success`,Icon:`checkbox-circle`},error:{tone:`error`,Icon:`error-warning`},running:{tone:`warning`,Icon:`loader-4`,spin:!0},idle:{tone:`muted`,Icon:`pulse`}},kt=e=>e===`muted`?{}:{color:`var(--status-${e})`,backgroundColor:`var(--status-${e}-background)`,borderColor:`var(--status-${e}-border)`},At=({projectId:e,taskId:t})=>`${e}:${t}`,jt=null,Mt=()=>jt?jt():(m.getState().setScheduledTasksDialogOpen(!1),!0),Nt=(e,t,n)=>({tasks:[...e?.tasks.filter(e=>e.projectId!==t)??[],...n.map(e=>({projectId:t,task:e}))],failedProjectIds:e?.failedProjectIds.filter(e=>e!==t)??[]});function Pt(){let e=(0,Ne.c)(18),{t}=ne(),n=m(Rt),r=m(Lt);if(!m(It))return null;let i;e[0]===t?i=e[1]:(i=t(`sessions.scheduledTasks.dialog.title`),e[0]=t,e[1]=i);let a;e[2]===t?a=e[3]:(a=t(`sessions.scheduledTasks.dialog.title`),e[2]=t,e[3]=a);let o;e[4]===t?o=e[5]:(o=t(`mobile.surface.closeAria`),e[4]=t,e[5]=o);let s;e[6]===t?s=e[7]:(s=t(`mobile.sessions.sheet.resizeAria`),e[6]=t,e[7]=s);let c;e[8]!==n||e[9]!==r?(c=(0,q.jsx)(zt,{presentation:`mobile-panel`,open:n,onOpenChange:r}),e[8]=n,e[9]=r,e[10]=c):c=e[10];let l;return e[11]!==n||e[12]!==i||e[13]!==a||e[14]!==o||e[15]!==s||e[16]!==c?(l=(0,q.jsx)(T,{id:`scheduled-tasks`,open:n,initiallyExpanded:!0,title:i,ariaLabel:a,closeAriaLabel:o,resizeAriaLabel:s,onOpenChange:Ft,children:c}),e[11]=n,e[12]=i,e[13]=a,e[14]=o,e[15]=s,e[16]=c,e[17]=l):l=e[17],l}function Ft(e){e||Mt()}function It(e){return e.isMobile}function Lt(e){return e.setScheduledTasksDialogOpen}function Rt(e){return e.isScheduledTasksDialogOpen}function zt({presentation:e=`workspace`,open:t=!0,onOpenChange:r,registerEditorBackHandler:i,onEditorActiveChange:a}={}){let{t:v}=ne(),y=u.runtime()[0],b=G.useMemo(()=>[y,`scheduled-tasks`],[y]),C=G.useMemo(()=>[y,`scheduled-task-runs`],[y]),w=D(),T=m(e=>e.isMobile),ie=m(e=>e.scheduledTaskOpenRequest),ae=m(e=>e.isScheduledTasksDialogOpen),oe=m(e=>e.setMainTabGuard),O=x(e=>e.projects),de=x(e=>e.getActiveProject())?.id||O[0]?.id||``,[F,I]=G.useState(de),[L,R]=G.useState(()=>{if(T&&e!==`mobile-panel`)return null;let t=Te();return t.scheduleProjectId&&t.scheduleTaskId?{projectId:t.scheduleProjectId,taskId:t.scheduleTaskId}:null}),[z,B]=G.useState(()=>L?`edit`:`closed`),[_e,ve]=G.useState(`all`),[H,ye]=G.useState(()=>Te().scheduleView===`history`?`history`:`tasks`),[be,xe]=G.useState(``),[Se,Oe]=G.useState(!1),Ae=G.useRef(!1),W=p(e=>{Ae.current=e,Oe(e)}),[je,Me]=G.useState(null),[Ne,Pe]=G.useState(null),[Fe,Ie]=G.useState(null),[K,Le]=G.useState(null),Re=G.useRef(null),[ze,Be]=G.useState(null),Ve=G.useRef(null),He=G.useRef(null),J=e===`mobile-tab`,Y=e===`mobile-panel`||J,Ue=p(e=>{Be(J?e?.closest(`[role="tabpanel"]`)??null:e)});G.useEffect(()=>{if(J)return a?.(z!==`closed`),()=>a?.(!1)},[z,J,a]),G.useEffect(()=>{if(!t)return;let n=t=>{let n=Te();if(n.tab===`schedule`){if(T&&e!==`mobile-panel`&&n.scheduleTaskId){R(null),B(`closed`),W(!1);return}let t=n.scheduleView===`history`?`history`:`tasks`;ye(e=>e===t?e:t);let r=n.scheduleProjectId&&n.scheduleTaskId?{projectId:n.scheduleProjectId,taskId:n.scheduleTaskId}:null;R(r),B(r?`edit`:`closed`),W(!1)}else t&&e===`mobile-panel`&&r?.(!1)};return n(),window.addEventListener(`popstate`,n),()=>window.removeEventListener(`popstate`,n)},[t,T,e,r,W]),G.useEffect(()=>{!t||!ie||T&&e!==`mobile-panel`&&ae||(R(ie),B(`edit`),ye(`tasks`),W(!1),m.getState().setScheduledTaskOpenRequest(null))},[t,ie,T,e,ae,W]),G.useEffect(()=>{O.some(e=>e.id===F)||I(de)},[F,de,O]);let X=s({queryKey:b,enabled:t,refetchOnMount:`always`,queryFn:P,select:e=>({...e,tasks:[...e.tasks].sort((e,t)=>e.task.enabled===t.task.enabled?e.task.name.localeCompare(t.task.name):e.task.enabled?-1:1)})}),We=G.useMemo(()=>X.data?.tasks??[],[X.data]),Ge=X.data?.failedProjectIds??[],Z=G.useMemo(()=>L?We.find(({projectId:e,task:t})=>e===L.projectId&&t.id===L.taskId)??null:null,[L,We]),Ke=Z?.task??null,Q=c({queryKey:[...C,K?.projectId??``,K?.taskId??``],enabled:t&&H===`history`,initialPageParam:void 0,queryFn:({pageParam:e,signal:t})=>N({before:e,limit:20,...K?{projectId:K.projectId,taskId:K.taskId}:{}},t),getNextPageParam:e=>e.complete?void 0:e.nextCursor??void 0,refetchOnMount:`always`}),qe=t&&H===`history`&&z===`closed`&&!!ze&&Q.hasNextPage&&!Q.isFetching&&!Q.error;f(qe?Re:null,p(e=>{qe&&e.some(e=>e.isIntersecting)&&Q.fetchNextPage({cancelRefetch:!1})}),{root:ze,rootMargin:`0px 0px 240px 0px`});let $=G.useMemo(()=>{let e=new Set,t=[];for(let n of Q.data?.pages??[])for(let r of n.runs)e.has(r.id)||(e.add(r.id),t.push(r));return t},[Q.data]),Je=G.useMemo(()=>$.some(e=>e.status===`running`),[$]),Ye=G.useMemo(()=>{if(!K)return null;let e=We.find(({projectId:e,task:t})=>e===K.projectId&&t.id===K.taskId);return e?.task.name?e.task.name:$.find(e=>e.projectId===K.projectId&&e.taskId===K.taskId)?.taskName||K.taskId},[K,$,We]),[Xe,Ze]=G.useState(()=>Date.now());G.useEffect(()=>{if(!t||H!==`history`||!Je)return;Ze(Date.now());let e=window.setInterval(()=>Ze(Date.now()),1e3);return()=>window.clearInterval(e)},[Je,t,H]);let Qe=G.useMemo(()=>new Map(O.map(e=>[e.id,e])),[O]);G.useEffect(()=>{let e=null,t=d(t=>{(t.type===`scheduled-task-ran`||t.type===`event-stream-ready`)&&(e&&clearTimeout(e),e=setTimeout(()=>{l.invalidateQueries({queryKey:b,exact:!0}),l.invalidateQueries({queryKey:C})},400))});return()=>{e&&clearTimeout(e),t()}},[b,C]);let $e=o({mutationFn:({projectID:e,taskDraft:t})=>ge(e,t),onSuccess:(e,{projectID:t})=>{l.setQueryData(b,n=>Nt(n,t,e))}}),et=o({mutationFn:({projectID:e,taskID:t})=>he(e,t),onSuccess:(e,{projectID:t})=>{l.setQueryData(b,n=>Nt(n,t,e))}}),tt=o({mutationFn:({projectID:e,taskID:t})=>me(e,t),onSuccess:()=>{l.invalidateQueries({queryKey:b,exact:!0}),l.invalidateQueries({queryKey:C})}}),nt=o({mutationFn:({projectID:e,task:t})=>ge(e,t),onMutate:({projectID:e,task:t})=>{let n=l.getQueryData(b);return l.setQueryData(b,n=>n&&{...n,tasks:n.tasks.map(n=>n.projectId===e&&n.task.id===t.id?{projectId:e,task:t}:n)}),{previousTasks:n}},onSuccess:(e,{projectID:t})=>{l.setQueryData(b,n=>Nt(n,t,e))},onError:(e,t,n)=>{n?.previousTasks&&l.setQueryData(b,n.previousTasks)}}),rt=p(()=>!Ae.current||window.confirm(v(`sessions.scheduledTasks.workspace.confirm.discardChanges`)));G.useEffect(()=>{if(!Se){oe(null);return}let e=e=>e===`schedule`||window.confirm(v(`sessions.scheduledTasks.workspace.confirm.discardChanges`));return oe(e),()=>{m.getState().mainTabGuard===e&&oe(null)}},[Se,oe,v]);let it=p(t=>{let n={projectId:t.projectId,taskId:t.task.id};if((At(n)!==(L?At(L):``)||z!==`edit`)&&rt()){if(T&&e!==`mobile-panel`){De(n.projectId,n.taskId);return}R(n),B(`edit`),W(!1),ot(`tasks`,n)}}),at=p(()=>{!F||!rt()||(R(null),B(`create`),W(!1),ot(`tasks`,null))}),ot=p((e,t)=>{let n=m.getState();Ee({sessionId:null,tab:`schedule`,isSettingsOpen:n.isSettingsDialogOpen,settingsPath:n.settingsPage,diffFile:null,scheduleView:e,scheduleProjectId:t?.projectId??null,scheduleTaskId:t?.taskId??null})}),st=p(e=>{H!==e&&(z!==`closed`&&!rt()||(R(null),B(`closed`),W(!1),Le(null),ye(e),ot(e,null)))}),ct=p((t,i)=>{e===`mobile-panel`&&t&&i&&r?.(!1),te(t,i,{phoneShell:!!(Y&&!n()),switchToChat:!0})}),lt=p(e=>{ct(e.sessionId,e.directory)}),ut=p(e=>{z!==`closed`&&!rt()||(R(null),B(`closed`),W(!1),Le({projectId:e.projectId,taskId:e.task.id}),ye(`history`),ot(`history`,null))}),dt=p(()=>{Le(null)}),pt=p(()=>{Z&&ut(Z)}),mt=p(async()=>{if(Q.data&&Q.hasNextPage){await Q.fetchNextPage();return}await Q.refetch()}),ht=p(e=>{e||!rt()||(R(null),B(`closed`),W(!1),ot(`tasks`,null))}),gt=p(()=>e===`mobile-panel`?!rt()||(R(null),B(`closed`),W(!1),ot(`tasks`,null),r?.(!1),!0):z===`closed`?(r?.(!1),!0):(ht(!1),!0));G.useEffect(()=>{if(e!==`mobile-panel`||!t)return;jt=gt;let n=()=>gt();return window.addEventListener(`yuri:scheduled-tasks-close-request`,n),()=>{jt===gt&&(jt=null),window.removeEventListener(`yuri:scheduled-tasks-close-request`,n)}},[e,t]);let _t=p(()=>z!==`closed`&&(ht(!1),!0));fe({id:`mobile-scheduled-editor`,active:J&&z!==`closed`,onBack:_t,surfaceRef:Ve,underlayRef:He}),G.useEffect(()=>{if(i)return i(_t),()=>i(null)},[i]);let vt=p(async e=>{let t=L?.projectId||F;if(!t)throw Error(v(`sessions.scheduledTasks.dialog.error.chooseProjectFirst`));let n=new Set(We.filter(e=>e.projectId===t).map(e=>e.task.id)),r=await $e.mutateAsync({projectID:t,taskDraft:e}),i=e.id?r.find(t=>t.id===e.id):r.find(e=>!n.has(e.id)),a=[...r].filter(t=>t.name===e.name).sort((e,t)=>(t.state?.updatedAt||0)-(e.state?.updatedAt||0))[0],o=i||a;return o&&(R({projectId:t,taskId:o.id}),B(`edit`),ot(`tasks`,{projectId:t,taskId:o.id})),W(!1),S.success(v(`sessions.scheduledTasks.dialog.toast.saved`)),o}),bt=p(async e=>{let{projectId:t,task:n}=e;if(window.confirm(v(`sessions.scheduledTasks.dialog.confirm.deleteTask`,{taskName:n.name}))){Me(At({projectId:t,taskId:n.id}));try{await et.mutateAsync({projectID:t,taskID:n.id});let e=At({projectId:t,taskId:n.id});L&&At(L)===e&&(R(null),B(`closed`),W(!1),ot(`tasks`,null)),S.success(v(`sessions.scheduledTasks.dialog.toast.deleted`))}catch(e){S.error(e instanceof Error?e.message:v(`sessions.scheduledTasks.dialog.toast.deleteFailed`))}finally{Me(null)}}}),xt=p(async({projectId:e,task:t})=>{Me(At({projectId:e,taskId:t.id}));try{await tt.mutateAsync({projectID:e,taskID:t.id}),S.success(v(`sessions.scheduledTasks.dialog.toast.started`))}catch(e){S.error(e instanceof Error?e.message:v(`sessions.scheduledTasks.dialog.toast.runFailed`))}finally{Me(null)}}),St=p(async({projectId:e,task:t},n)=>{Me(At({projectId:e,taskId:t.id}));try{await nt.mutateAsync({projectID:e,task:{...t,enabled:n}})}catch(e){S.error(e instanceof Error?e.message:v(`sessions.scheduledTasks.dialog.toast.updateFailed`))}finally{Me(null)}}),Mt=G.useMemo(()=>{let e=be.trim().toLocaleLowerCase();return We.filter(({task:t})=>_e===`active`&&!t.enabled||_e===`paused`&&t.enabled?!1:!e||t.name.toLocaleLowerCase().includes(e)||Ct(t,v).toLocaleLowerCase().includes(e))},[_e,be,v,We]),Pt=e=>{let t=e.icon?Ce[e.icon]:null,n=e.color?we[e.color]:void 0,r=(0,q.jsx)(_,{name:t??`folder`,className:`size-3.5`,style:n?{color:n}:void 0});return(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`relative top-px flex size-4 shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,children:e.iconImage?(0,q.jsx)(U,{project:e,className:`size-full object-contain`,fallback:r}):r}),(0,q.jsx)(`span`,{className:`truncate`,children:ee(e.path)})]})},Ft=O.map(e=>({id:e.id,label:Pt(e)}));return(0,q.jsxs)(`div`,{className:g(`relative flex min-h-0`,J?`yuri-mobile-scheduled-workspace w-full flex-col overflow-visible bg-transparent`:`h-full overflow-hidden bg-background`,Y&&`flex-col`),"data-presentation":e,children:[(0,q.jsxs)(`div`,{ref:J?He:void 0,"data-mobile-navigation-underlay":J?`true`:void 0,"aria-hidden":J&&z!==`closed`?!0:void 0,inert:J&&z!==`closed`?!0:void 0,className:g(J?`flex w-full min-w-0 flex-col gap-[var(--yuri-mobile-page-gap)]`:`contents`),children:[J?(0,q.jsx)(ke,{title:v(`sessions.scheduledTasks.dialog.title`),trailing:(0,q.jsx)(yt,{active:z===`closed`})}):null,Y&&!J?(0,q.jsx)(re,{children:z===`edit`&&Z?(0,q.jsxs)(ce,{children:[(0,q.jsx)(k,{asChild:!0,children:(0,q.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:`size-11 shrink-0 rounded-lg`,disabled:!!je,"aria-label":v(`sessions.scheduledTasks.dialog.actions.moreAria`,{taskName:Z.task.name}),children:(0,q.jsx)(_,{name:`more-2`,className:`size-5`})})}),(0,q.jsxs)(se,{align:`end`,className:`min-w-40`,children:[(0,q.jsxs)(A,{className:`min-h-11`,onSelect:()=>void xt(Z),children:[(0,q.jsx)(_,{name:`play`,className:`size-4`}),v(`sessions.scheduledTasks.dialog.actions.runNow`)]}),(0,q.jsxs)(A,{className:`min-h-11`,onSelect:()=>ut(Z),children:[(0,q.jsx)(_,{name:`history`,className:`size-4`}),v(`sessions.scheduledTasks.workspace.views.history`)]}),(0,q.jsxs)(A,{className:`min-h-11`,onSelect:()=>void St(Z,!Z.task.enabled),children:[(0,q.jsx)(_,{name:Z.task.enabled?`pause`:`play`,className:`size-4`}),Z.task.enabled?v(`sessions.scheduledTasks.dialog.actions.pause`):v(`sessions.scheduledTasks.dialog.actions.resume`)]}),(0,q.jsxs)(A,{variant:`destructive`,className:`min-h-11`,onSelect:()=>void bt(Z),children:[(0,q.jsx)(_,{name:`delete-bin`,className:`size-4`}),v(`sessions.scheduledTasks.dialog.actions.delete`)]})]})]}):null}):null,(0,q.jsxs)(`section`,{className:g(`min-w-0 flex-col transition-[width] duration-300 ease-out`,J?`flex-none overflow-visible`:`flex-1 overflow-hidden`,Y&&!J&&z!==`closed`?`hidden`:`flex`),children:[(0,q.jsx)(`header`,{className:g(`shrink-0`,J?`pb-0 pt-0`:Y?`px-3 pb-3 pt-3`:`px-4 pb-5 pt-4 sm:px-6`),children:(0,q.jsxs)(`div`,{className:g(`mx-auto w-full`,J?`max-w-[26rem]`:`max-w-4xl`),children:[(0,q.jsx)(`div`,{className:g((H===`tasks`||K||!J)&&`mb-3`,J?`yuri-mobile-floating-surface yuri-mobile-segmented-track`:`grid grid-cols-2 gap-1 rounded-xl bg-[var(--surface-muted)] p-1`),role:`tablist`,"aria-label":v(`sessions.scheduledTasks.workspace.views.aria`),children:[`tasks`,`history`].map(e=>(0,q.jsxs)(h,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":H===e,className:g(J?`yuri-mobile-segmented-item`:`relative min-h-9 rounded-lg text-muted-foreground transition-[background-color,color,box-shadow] motion-reduce:transition-none`,!J&&Y&&`min-h-11`,!J&&(H===e?`text-foreground hover:bg-transparent hover:text-foreground`:`hover:bg-interactive-hover/40 hover:text-foreground`)),onClick:()=>st(e),children:[H===e?(0,q.jsx)(V.span,{layoutId:`scheduled-workspace-view-pill`,className:g(`yuri-segmented-selected-pill absolute inset-0`,!J&&`rounded-lg`),transition:{duration:w?0:.18,ease:[.22,1,.36,1]},"aria-hidden":`true`}):null,(0,q.jsxs)(`span`,{className:`relative z-[1] inline-flex items-center gap-1.5`,children:[(0,q.jsx)(_,{name:e===`tasks`?`calendar-schedule`:`history`,className:`size-4 shrink-0`}),v(`sessions.scheduledTasks.workspace.views.${e}`)]})]},e))}),H===`history`&&Ye?(0,q.jsx)(`div`,{className:g(`flex min-w-0 items-center`,J?`mt-[var(--yuri-mobile-page-gap)]`:`mt-3`),role:`status`,"aria-label":v(`sessions.scheduledTasks.history.filter.aria`,{name:Ye}),children:(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1 rounded-full border border-border/60 bg-[var(--surface-elevated)] py-1 pl-3 pr-1`,children:[(0,q.jsx)(`span`,{className:`min-w-0 truncate typography-meta text-foreground`,children:Ye}),(0,q.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:g(`shrink-0 rounded-full`,Y?`size-8`:`size-7`),onClick:dt,"aria-label":v(`sessions.scheduledTasks.history.filter.clearAria`),children:(0,q.jsx)(_,{name:`close`,className:`size-3.5`})})]})}):null,H===`tasks`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:g(J?`yuri-mobile-floating-surface yuri-mobile-segmented-track yuri-mobile-scheduled-controls`:g(`flex items-center justify-between`,Y?`gap-2`:`gap-3`)),children:[(0,q.jsx)(`div`,{className:g(J?`yuri-mobile-segmented-group`:g(`flex items-center gap-1`,Y&&`min-w-0 flex-1`)),role:`group`,"aria-label":v(`sessions.scheduledTasks.dialog.title`),children:[`all`,`active`,`paused`].map(e=>(0,q.jsxs)(h,{type:`button`,variant:`ghost`,size:`sm`,className:g(J?`yuri-mobile-segmented-item`:`relative border-0 bg-transparent text-muted-foreground shadow-none transition-[color,background-color] duration-150 ease-out motion-reduce:transition-none`,!J&&(Y?`h-11 min-h-11 min-w-0 flex-1 rounded-xl px-2`:`!h-9 !min-h-9 rounded-xl px-3`),!J&&(_e===e?`text-foreground hover:bg-transparent hover:text-foreground`:`hover:bg-interactive-hover/40 hover:text-foreground`)),"aria-pressed":_e===e,onClick:()=>ve(e),children:[_e===e?(0,q.jsx)(V.span,{layoutId:`scheduled-task-filter-pill`,className:g(`yuri-segmented-selected-pill absolute inset-0`,!J&&`rounded-xl`),transition:{duration:w?0:.18,ease:[.22,1,.36,1]},"aria-hidden":`true`}):null,(0,q.jsx)(`span`,{className:`relative z-[1]`,children:v(`sessions.scheduledTasks.workspace.filters.${e}`)})]},e))}),J?(0,q.jsx)(h,{variant:`mobileGlass`,size:`mobileIcon`,"data-mobile-press-feedback":`compact`,className:`yuri-mobile-segmented-action yuri-mobile-inverse-action shrink-0`,onClick:at,disabled:!F,"aria-label":v(`sessions.scheduledTasks.dialog.actions.create`),children:(0,q.jsx)(_,{name:`add`,className:`size-5`})}):(0,q.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,q.jsxs)(h,{variant:`ghost`,"data-mobile-press-feedback":Y?`compact`:void 0,className:g(`shrink-0 rounded-full bg-foreground text-background transition-[background-color,box-shadow] duration-150 ease-out hover:bg-foreground/90 hover:text-background hover:shadow-sm active:bg-interactive-active motion-reduce:transition-none`,Y?`size-11 min-h-11 px-0 min-[400px]:w-auto min-[400px]:px-3.5`:`!h-9 !min-h-9 px-3.5`),onClick:at,disabled:!F,"aria-label":v(`sessions.scheduledTasks.dialog.actions.create`),children:[(0,q.jsx)(_,{name:`add`,className:`h-4 w-4`}),` `,(0,q.jsx)(`span`,{className:g(Y&&`hidden min-[400px]:inline`),children:v(`sessions.scheduledTasks.dialog.actions.create`)})]})})]}),J?null:(0,q.jsxs)(`div`,{className:g(`group relative w-full`,Y?`mt-3`:`mt-7`),children:[(0,q.jsx)(_,{name:`search`,className:`pointer-events-none absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground transition-[color,transform] duration-150 ease-out group-focus-within:scale-105 group-focus-within:text-foreground motion-reduce:transition-none`}),(0,q.jsx)(pe,{value:be,onChange:e=>xe(e.target.value),placeholder:v(`sessions.scheduledTasks.workspace.search.placeholder`),className:g(`rounded-full bg-[var(--surface-elevated)] pl-10 pr-4 ring-1 ring-inset ring-border/50 transition-[background-color,box-shadow,color] duration-200 ease-out hover:[&:not(:focus)]:ring-border focus:bg-[var(--surface-elevated)] focus:shadow-sm focus:ring-2 focus:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,Y?`h-11 min-h-11`:`!h-9 !min-h-9`)})]})]}):null]})}),(0,q.jsx)(`div`,{ref:Ue,className:g(J?`flex-none overflow-visible pt-[var(--yuri-mobile-page-gap)]`:`min-h-0 flex-1 overflow-y-auto`,!J&&(Y?`overscroll-none px-3 pb-[max(1rem,env(safe-area-inset-bottom))]`:`px-6 pb-6 [scrollbar-gutter:stable]`)),children:(0,q.jsx)(`div`,{className:g(`mx-auto w-full`,J?`max-w-[26rem]`:`max-w-4xl pt-4`),children:H===`history`?(0,q.jsxs)(`div`,{className:`space-y-3`,children:[Q.isLoading?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 typography-meta text-muted-foreground`,children:[(0,q.jsx)(_,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}),v(`sessions.scheduledTasks.history.loading`)]}):Q.error&&$.length===0?(0,q.jsx)(`div`,{className:`rounded-xl border border-dashed border-border p-4`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(_,{name:`error-warning`,className:`mt-0.5 size-4 shrink-0 text-[var(--status-error)]`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`p`,{className:`typography-ui-label font-medium text-foreground`,children:v(`sessions.scheduledTasks.history.error.title`)}),(0,q.jsx)(`p`,{className:`mt-1 break-words typography-meta text-muted-foreground`,children:Q.error instanceof Error?Q.error.message:v(`sessions.scheduledTasks.history.error.description`)})]}),(0,q.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>void mt(),children:v(`sessions.scheduledTasks.history.retry`)})]})}):$.length===0?(0,q.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border p-6 text-center`,children:[(0,q.jsx)(_,{name:`history`,className:`mx-auto size-5 text-muted-foreground`}),(0,q.jsx)(`p`,{className:`mt-2 typography-ui-label font-medium text-foreground`,children:v(`sessions.scheduledTasks.history.empty.title`)}),(0,q.jsx)(`p`,{className:`mt-1 typography-meta text-muted-foreground`,children:v(`sessions.scheduledTasks.history.empty.description`)})]}):(0,q.jsxs)(`div`,{className:g(J?`space-y-4`:Y?`space-y-2`:`divide-y divide-border/50 overflow-hidden rounded-xl border border-border/60 bg-[var(--surface-elevated)]`),children:[$.map(e=>{let t=Qe.get(e.projectId),n=t?ee(t.path):e.projectId,r=e.directory?ee(e.directory):null,i=r&&r!==n?`${n} · ${r}`:n,a=Ot[e.status],o=!!(e.sessionId&&e.directory),s=Dt(Et(e,Xe))??(e.status===`running`?v(`sessions.scheduledTasks.history.duration.pending`):null),c=Tt(e.startedAt),l=v(`sessions.scheduledTasks.history.trigger.${e.trigger}`),u=e.trigger===`manual`?`play`:`calendar-schedule`,d=v(`sessions.scheduledTasks.dialog.status.${e.status}`),f=a.tone===`muted`?void 0:{color:`var(--status-${a.tone})`},p=t?.icon?Ce[t.icon]??`folder`:`folder`,m=t?.color?we[t.color]:void 0,h=(0,q.jsx)(`span`,{className:`flex size-3.5 shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,children:t?.iconImage?(0,q.jsx)(U,{project:t,className:`size-full object-contain`,fallback:(0,q.jsx)(_,{name:p,className:`size-3.5`,style:m?{color:m}:void 0})}):(0,q.jsx)(_,{name:p,className:`size-3.5`,style:m?{color:m}:void 0})}),y=(0,q.jsx)(`span`,{className:g(`mt-0.5 flex shrink-0 items-center justify-center rounded-full border`,Y?`size-7`:`size-8`),style:kt(a.tone),title:d,"aria-label":d,children:(0,q.jsx)(_,{name:a.Icon,className:g(Y?`size-3.5`:`size-4`,a.spin&&`animate-spin motion-reduce:animate-none`)})}),te=(0,q.jsxs)(`p`,{className:g(`mt-0.5 flex min-w-0 items-center gap-1.5 text-muted-foreground`,Y?`typography-micro`:`truncate typography-meta`),title:e.directory??n,children:[h,(0,q.jsx)(`span`,{className:g(`min-w-0`,Y?`break-words`:`truncate`),children:i})]}),b=(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[s?(0,q.jsx)(`span`,{className:`typography-micro tabular-nums text-muted-foreground`,title:s,children:s}):null,(0,q.jsx)(`span`,{className:`typography-micro font-medium`,style:f,children:d})]}),x=(0,q.jsxs)(`div`,{className:g(`flex w-full min-w-0 items-start`,Y?`gap-2.5`:`gap-3`),children:[y,(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex w-full min-w-0 items-start justify-between gap-2`,children:[(0,q.jsx)(`h3`,{className:g(`min-w-0 flex-1 font-semibold text-foreground`,Y?`break-words typography-meta leading-snug`:`truncate typography-ui-label`),children:e.taskName}),b]}),te,(0,q.jsxs)(`div`,{className:g(`mt-1 flex w-full min-w-0 gap-2`,Y?`items-center`:`items-center justify-between gap-3`),children:[(0,q.jsxs)(`div`,{className:g(`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1 typography-micro text-muted-foreground`,Y&&`gap-x-2.5 gap-y-0.5`),children:[(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,title:c,children:[(0,q.jsx)(_,{name:`time`,className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`whitespace-nowrap tabular-nums`,children:c})]}),(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,title:l,children:[(0,q.jsx)(_,{name:u,className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`whitespace-nowrap`,children:l})]})]}),!Y&&o?(0,q.jsx)(`span`,{className:`shrink-0 self-center typography-ui-label font-medium text-foreground`,children:v(`sessions.scheduledTasks.history.openSession`)}):null]}),e.error?(0,q.jsxs)(`p`,{className:g(`mt-1.5 min-w-0 break-words typography-micro text-[var(--surface-muted-foreground)] [overflow-wrap:anywhere]`,Y?`line-clamp-3`:`line-clamp-1`),title:e.error.slice(0,300),children:[(0,q.jsx)(_,{name:`error-warning`,className:`mr-1 inline-block size-3 align-[-0.125em] text-[var(--status-error)]`,"aria-hidden":`true`}),e.error.slice(0,300)]}):null]})]});if(Y){let t=v(`sessions.scheduledTasks.history.openSession`),n=g(`yuri-mobile-scheduled-task-card w-full`,J?`yuri-mobile-floating-surface yuri-mobile-project-shell rounded-[var(--yuri-mobile-surface-radius)]`:`rounded-xl border border-border/60 bg-[var(--surface-elevated)] shadow-sm dark:shadow-none`);return o?(0,q.jsx)(`article`,{"data-mobile-press-surface":`soft`,className:n,children:(0,q.jsx)(`button`,{type:`button`,"data-mobile-press-surface-trigger":!0,className:g(`yuri-mobile-scheduled-task-row w-full p-3 text-left outline-none`,`focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`),"aria-label":t,onClick:()=>lt(e),children:x})},e.id):(0,q.jsx)(`article`,{className:g(n,`p-3`),children:x},e.id)}return o?(0,q.jsx)(`article`,{className:`w-full min-w-0`,children:(0,q.jsx)(`button`,{type:`button`,className:`w-full min-w-0 px-4 py-3 text-left outline-none transition-colors hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,"aria-label":v(`sessions.scheduledTasks.history.openSession`),onClick:()=>lt(e),children:x})},e.id):(0,q.jsx)(`article`,{className:`w-full min-w-0 px-4 py-3`,children:x},e.id)}),Q.error?(0,q.jsxs)(`div`,{className:g(`flex flex-wrap items-center justify-between gap-2 p-3 typography-meta text-[var(--status-error-foreground)]`,Y?`rounded-xl border border-[var(--status-error-border)] bg-[var(--status-error-background)]`:`border-t border-[var(--status-error-border)] bg-[var(--status-error-background)]`),children:[(0,q.jsx)(`span`,{children:v(`sessions.scheduledTasks.history.error.more`)}),(0,q.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>void mt(),children:v(`sessions.scheduledTasks.history.retry`)})]}):null]}),Q.hasNextPage?(0,q.jsx)(`div`,{ref:Re,className:`flex min-h-px justify-center`,children:Q.isFetchingNextPage?(0,q.jsx)(`span`,{role:`status`,"aria-label":v(`sessions.scheduledTasks.history.loadingMore`),className:`py-1 text-muted-foreground`,children:(0,q.jsx)(_,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":`true`})}):null}):null]}):(0,q.jsxs)(q.Fragment,{children:[Ge.length>0?(0,q.jsx)(`div`,{className:`mb-3 rounded-xl border p-3 typography-meta`,style:kt(`warning`),children:v(`sessions.scheduledTasks.workspace.partialLoadWarning`)}):null,X.isLoading?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 typography-meta text-muted-foreground`,children:[(0,q.jsx)(_,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),` `,v(`sessions.scheduledTasks.dialog.loading`)]}):X.error&&!X.data?(0,q.jsx)(`div`,{className:`rounded-xl border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:X.error instanceof Error?X.error.message:v(`sessions.scheduledTasks.dialog.toast.loadFailed`)}):(0,q.jsx)(E,{initial:!1,mode:`popLayout`,children:Mt.length===0?(0,q.jsx)(V.div,{initial:w?{opacity:0}:{opacity:0,y:4},animate:{opacity:1,y:0},exit:w?{opacity:0}:{opacity:0,y:-4},transition:{duration:w?0:.18,ease:[.22,1,.36,1]},className:`rounded-xl border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:We.length>0?v(`sessions.scheduledTasks.workspace.search.noResults`):v(`sessions.scheduledTasks.dialog.empty.noTasks`)},`empty`):(0,q.jsx)(V.div,{initial:w?{opacity:0}:{opacity:0,y:4},animate:{opacity:1,y:0},exit:w?{opacity:0}:{opacity:0,y:-4},transition:{duration:w?0:.18,ease:[.22,1,.36,1]},className:g(J?`space-y-4`:`space-y-1`),children:(0,q.jsx)(E,{initial:!1,mode:`popLayout`,children:Mt.map(e=>{let{projectId:t,task:n}=e,r=At({projectId:t,taskId:n.id}),i=z===`edit`&&L!==null&&At(L)===r,a=n.state?.nextRunAt,o=n.state?.lastStatus||`idle`,s=Ot[o],c=je===r,l=t=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(t,{className:g(Y&&`min-h-11`),onClick:t=>{t.stopPropagation(),xt(e)},disabled:c,children:[(0,q.jsx)(_,{name:`play`,className:`size-4`}),v(`sessions.scheduledTasks.dialog.actions.runNow`)]}),(0,q.jsxs)(t,{className:g(Y&&`min-h-11`),onClick:t=>{t.stopPropagation(),ut(e)},children:[(0,q.jsx)(_,{name:`history`,className:`size-4`}),v(`sessions.scheduledTasks.workspace.views.history`)]}),(0,q.jsxs)(t,{className:g(Y&&`min-h-11`),onClick:t=>{t.stopPropagation(),St(e,!n.enabled)},disabled:c,children:[(0,q.jsx)(_,{name:n.enabled?`pause`:`play`,className:`size-4`}),n.enabled?v(`sessions.scheduledTasks.dialog.actions.pause`):v(`sessions.scheduledTasks.dialog.actions.resume`)]}),(0,q.jsxs)(t,{onClick:t=>{t.stopPropagation(),bt(e)},disabled:c,className:g(`text-destructive focus:text-destructive`,Y&&`min-h-11`),children:[(0,q.jsx)(_,{name:`delete-bin`,className:`size-4 text-inherit`}),v(`sessions.scheduledTasks.dialog.actions.delete`)]})]});return(0,q.jsx)(V.div,{layout:`position`,initial:!w&&{opacity:0,y:6},animate:{opacity:1,y:0},exit:w?{opacity:0}:{opacity:0,y:-6},transition:{duration:w?0:.18,ease:[.22,1,.36,1]},"data-mobile-press-surface":J?`soft`:void 0,className:g(J&&`yuri-mobile-floating-surface yuri-mobile-project-shell yuri-mobile-scheduled-task-card`),children:(0,q.jsxs)(ue,{open:Ne===r,onOpenChange:e=>{e&&Ie(null),Pe(e?r:null)},children:[(0,q.jsxs)(`div`,{className:g(`group flex w-full items-center gap-1`,J&&`yuri-mobile-project-card`),children:[(0,q.jsxs)(j,{render:(0,q.jsx)(`button`,{type:`button`,onClick:()=>it(e),onContextMenu:!Y&&!T?e=>{e.preventDefault(),Ie(null),Pe(r)}:void 0,"data-mobile-press-surface-trigger":J?!0:void 0,className:g(`flex min-h-11 min-w-0 flex-1 items-center rounded-xl border py-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,J?`yuri-mobile-project-trigger yuri-mobile-scheduled-task-row border-0 bg-transparent transition-opacity duration-150`:`transition-[background-color,border-color,box-shadow,opacity] duration-150 ease-out active:bg-interactive-active`,Y&&!J?`gap-2.5 px-3`:J?void 0:`gap-3 px-4`,!J&&(i?`border-border/50 bg-[var(--surface-elevated)] shadow-sm dark:shadow-none`:`border-transparent hover:bg-interactive-hover`),!n.enabled&&`opacity-65`),"aria-pressed":i}),children:[(0,q.jsx)(`span`,{className:g(`flex shrink-0 items-center justify-center rounded-full text-muted-foreground transition-[border-color,color,background-color] duration-150 motion-reduce:transition-none`,J?`yuri-mobile-project-icon yuri-mobile-glass-control`:`size-5 border border-border`),style:n.enabled&&s.tone!==`muted`?{color:`var(--status-${s.tone})`}:void 0,children:(0,q.jsx)(E,{initial:!1,mode:`wait`,children:(0,q.jsx)(V.span,{initial:!w&&{opacity:0,scale:.72},animate:{opacity:1,scale:1},exit:w?{opacity:0}:{opacity:0,scale:.72},transition:{duration:w?0:.15},className:`flex`,children:(0,q.jsx)(_,{name:n.enabled?s.Icon:`pause`,className:g(J?`yuri-mobile-project-icon-glyph`:`size-3.5`,s.spin&&n.enabled&&`animate-spin`)})},`${n.enabled}-${o}`)})}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:g(`block truncate font-medium`,J?`yuri-mobile-project-title yuri-mobile-entity-title font-semibold`:`typography-ui-label`),children:n.name}),(0,q.jsxs)(`span`,{className:g(`mt-1 flex min-w-0 items-center text-muted-foreground`,J?`yuri-mobile-project-meta yuri-mobile-entity-meta`:`gap-1 typography-micro`),children:[(0,q.jsx)(`span`,{className:`truncate`,children:Ct(n,v,!J)}),(0,q.jsx)(`span`,{className:`shrink-0 text-muted-foreground/50`,children:`·`}),(0,q.jsx)(`span`,{className:`shrink-0 truncate`,children:a?wt(a,v):`—`})]})]})]}),(0,q.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:g(`shrink-0 self-center rounded-lg text-muted-foreground`,Y?`size-11 rounded-full`:`size-9`),onClick:t=>{t.stopPropagation(),ut(e)},"aria-label":v(`sessions.scheduledTasks.workspace.views.history`),children:(0,q.jsx)(_,{name:`history`,className:`size-4`})}),(0,q.jsxs)(ce,{open:Fe===r,onOpenChange:e=>{e&&Pe(null),Ie(e?r:null)},children:[(0,q.jsx)(k,{asChild:!0,children:(0,q.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:g(`shrink-0 self-center text-muted-foreground transition-[opacity,transform,background-color] duration-150 ease-out data-[popup-open]:bg-interactive-hover motion-reduce:transition-none`,J?`yuri-mobile-project-action yuri-mobile-scheduled-task-action rounded-full`:`rounded-lg`,J?void 0:Y?`size-11`:`size-8 translate-x-1 opacity-0 group-hover:translate-x-0 group-hover:opacity-100 data-[popup-open]:translate-x-0 data-[popup-open]:opacity-100`,i&&!J&&`opacity-100`),onClick:e=>e.stopPropagation(),"aria-label":v(`sessions.scheduledTasks.dialog.actions.moreAria`,{taskName:n.name}),children:(0,q.jsx)(_,{name:`more-2`,className:J?`size-5`:`size-4`})})}),(0,q.jsx)(se,{align:`end`,className:`min-w-40 motion-reduce:transition-none`,onClick:e=>e.stopPropagation(),children:l(A)})]})]}),(0,q.jsx)(M,{className:`min-w-40 motion-reduce:transition-none`,children:l(le)})]})},r)})})},`tasks`)})]})})})]})]}),z===`edit`&&!Ke?(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-4`,role:`status`,children:[X.isPending?v(`sessions.scheduledTasks.dialog.loading`):v(`common.unavailable`),X.isPending?null:(0,q.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>void X.refetch(),children:v(`assistants.actions.retry`)})]}):null,T?z===`create`||z===`edit`&&Ke?(0,q.jsx)(`div`,{ref:J?Ve:void 0,className:g(J?`yuri-mobile-scheduled-editor-overlay flex w-full min-w-0 max-w-full flex-col overflow-hidden bg-background [contain:layout_paint]`:`contents`),children:(0,q.jsx)(ft,{open:!0,presentation:J?`mobile-tab`:Y?`mobile-panel`:void 0,task:z===`edit`?Ke:null,onOpenChange:ht,onSave:vt,onDirtyChange:W,onRun:async()=>{Z&&await xt(Z)},onOpenTaskHistory:pt,onDelete:async()=>{Z&&await bt(Z)},onToggleEnabled:async(e,t)=>{Z&&await St(Z,t)},actionBusy:!!je,projectID:L?.projectId||F,projectOptions:Ft,onProjectChange:z===`create`?I:void 0})}):null:(0,q.jsx)(E,{initial:!1,children:z===`create`||z===`edit`&&Ke?(0,q.jsx)(V.div,{initial:w?{opacity:1,width:0}:{opacity:0,width:0,x:24},animate:{opacity:1,width:`clamp(380px, 36vw, 480px)`,x:0},exit:w?{opacity:0,width:0}:{opacity:0,width:0,x:24},transition:{duration:w?0:.26,ease:[.22,1,.36,1]},className:`h-full min-h-0 max-w-[480px] shrink-0 overflow-hidden`,children:(0,q.jsx)(`aside`,{className:`h-full min-h-0 w-[clamp(380px,36vw,480px)] border-l border-border/60 bg-background`,children:(0,q.jsx)(ft,{open:!0,presentation:`panel`,task:z===`edit`?Ke:null,onOpenChange:ht,onSave:vt,onDirtyChange:W,onRun:async()=>{Z&&await xt(Z)},onOpenTaskHistory:pt,onDelete:async()=>{Z&&await bt(Z)},onToggleEnabled:async(e,t)=>{Z&&await St(Z,t)},actionBusy:!!je,projectID:L?.projectId||F,projectOptions:Ft,onProjectChange:z===`create`?I:void 0})})},`scheduled-task-details`):null})]})}export{zt as n,xt as t};
|