tokentracker-cli 1.3.13 → 1.3.14

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.
Files changed (114) hide show
  1. package/dashboard/dist/assets/{AchievementBadge-DkNsd5tj.js → AchievementBadge-DJK8AWBF.js} +1 -1
  2. package/dashboard/dist/assets/{AchievementsPage-Dr72Hcog.js → AchievementsPage-Cle78oKH.js} +2 -2
  3. package/dashboard/dist/assets/{AchievementsSection-CkOdGlnD.js → AchievementsSection-BPqXDoPP.js} +1 -1
  4. package/dashboard/dist/assets/{BadgeDetailModal-DADLfBsK.js → BadgeDetailModal-HsH_Pwsu.js} +1 -1
  5. package/dashboard/dist/assets/{BotAnimated-k6u1GRzw.js → BotAnimated-BWy2-z4Q.js} +1 -1
  6. package/dashboard/dist/assets/{Card-Dk6s3h-P.js → Card-DPGBuBDb.js} +1 -1
  7. package/dashboard/dist/assets/{CloudCheckoutPage-DL0pvok0.js → CloudCheckoutPage-ohIQnIhe.js} +1 -1
  8. package/dashboard/dist/assets/{CloudPage-BizN1MZL.js → CloudPage-OYiiZ4c4.js} +2 -2
  9. package/dashboard/dist/assets/{CommandPalette-B2crDNlV.js → CommandPalette-BmDZmpMi.js} +1 -1
  10. package/dashboard/dist/assets/{CommunityStatsModal-C6Rc5NME.js → CommunityStatsModal-L86uJgyp.js} +1 -1
  11. package/dashboard/dist/assets/{ConfirmModal-BrxBQn4n.js → ConfirmModal-COQfPXos.js} +1 -1
  12. package/dashboard/dist/assets/{Controls-C2mEPI72.js → Controls-BkKlT6Dz.js} +1 -1
  13. package/dashboard/dist/assets/{DashboardPage-BomPd7nt.js → DashboardPage-3dlQBOjz.js} +1 -1
  14. package/dashboard/dist/assets/{DateRangePopover-Gz-N_D7O.js → DateRangePopover-D0UeP8ig.js} +1 -1
  15. package/dashboard/dist/assets/{DevicePage-wmnNx9bd.js → DevicePage-K3CdWKaf.js} +1 -1
  16. package/dashboard/dist/assets/{DialogClose-D1dzj_on.js → DialogClose-DKQ2ZVA0.js} +1 -1
  17. package/dashboard/dist/assets/DialogDescription-MbuaPFlj.js +1 -0
  18. package/dashboard/dist/assets/{DialogTitle-BBxNf3O8.js → DialogTitle-ufFnN-8D.js} +1 -1
  19. package/dashboard/dist/assets/{ElectricLogo-DCopeDc8.js → ElectricLogo-Bb79UnTo.js} +1 -1
  20. package/dashboard/dist/assets/{FadeIn-DSndojVd.js → FadeIn-DlAKIU4I.js} +1 -1
  21. package/dashboard/dist/assets/{HeaderGithubStar-BBAGbevf.js → HeaderGithubStar-CzwSyhEY.js} +1 -1
  22. package/dashboard/dist/assets/{HoverTooltip-COD3xE9E.js → HoverTooltip-BEpwekkd.js} +1 -1
  23. package/dashboard/dist/assets/{IpCheckPage-BtMWefop.js → IpCheckPage-C7kpZ9JX.js} +1 -1
  24. package/dashboard/dist/assets/{LandingPage-DN2IVBw7.js → LandingPage-CfYk0Jzy.js} +2 -2
  25. package/dashboard/dist/assets/{LeaderboardPage-DkJowsRI.js → LeaderboardPage-XgjAHwpy.js} +2 -2
  26. package/dashboard/dist/assets/{LeaderboardProBadge-CRRphJNs.js → LeaderboardProBadge-wSlqVjBb.js} +1 -1
  27. package/dashboard/dist/assets/{LeaderboardProfileModal-WmZAsZx5.js → LeaderboardProfileModal-DaQrNYnu.js} +3 -3
  28. package/dashboard/dist/assets/{LeaderboardProfilePage-DWHu-eOp.js → LeaderboardProfilePage-3SWjG8FQ.js} +1 -1
  29. package/dashboard/dist/assets/{LimitsPage-BRFAWm-1.js → LimitsPage-DvM57ri3.js} +1 -1
  30. package/dashboard/dist/assets/{LocalOnlyNotice-BjJ8N4Zc.js → LocalOnlyNotice-CY6eDJEk.js} +1 -1
  31. package/dashboard/dist/assets/{LoginCard-CYmjHoYK.js → LoginCard-4bdpPQeD.js} +1 -1
  32. package/dashboard/dist/assets/{LoginModal-DX1D9F8b.js → LoginModal-Bmw7-b3f.js} +1 -1
  33. package/dashboard/dist/assets/{LoginPage-D7Ok7HiZ.js → LoginPage-CEI4nnlT.js} +1 -1
  34. package/dashboard/dist/assets/{PetPage-BYISPev2.js → PetPage-7Udtc9GY.js} +2 -2
  35. package/dashboard/dist/assets/{PopoverPopup-BlzqlKqF.js → PopoverPopup-r2BvRKLO.js} +1 -1
  36. package/dashboard/dist/assets/{ProviderIcon-BuLwtYjj.js → ProviderIcon-Cy_pKLdw.js} +1 -1
  37. package/dashboard/dist/assets/{ResetPasswordPage-BJRKclq9.js → ResetPasswordPage-QKUaLtO3.js} +1 -1
  38. package/dashboard/dist/assets/{Select-0YyBw95W.js → Select-BsUrn8Ui.js} +1 -1
  39. package/dashboard/dist/assets/{SelectItemText-CZKyxUjE.js → SelectItemText-Nis0uGZT.js} +1 -1
  40. package/dashboard/dist/assets/{SelfHostPage-C_Afofs-.js → SelfHostPage-DF8EzBEV.js} +1 -1
  41. package/dashboard/dist/assets/{ServiceStatusPage-0KpLdpon.js → ServiceStatusPage-BYmKzI_v.js} +1 -1
  42. package/dashboard/dist/assets/{SessionsPage-YtSyWMd0.js → SessionsPage-BsCVe75l.js} +1 -1
  43. package/dashboard/dist/assets/{SettingsPage-Bm641_AH.js → SettingsPage-CIZ6WmNR.js} +3 -3
  44. package/dashboard/dist/assets/{SkillsPage-DNg-I2g_.js → SkillsPage-cwHyK0Hp.js} +1 -1
  45. package/dashboard/dist/assets/{TokenGalaxy-BMN7WiRH.js → TokenGalaxy-2S-ud67v.js} +1 -1
  46. package/dashboard/dist/assets/{TooltipPopup-BF56BHfc.js → TooltipPopup-GG7xjDOP.js} +1 -1
  47. package/dashboard/dist/assets/{TrendMonitor-D0ea5xMA.js → TrendMonitor-CrbXrVMe.js} +1 -1
  48. package/dashboard/dist/assets/{WidgetsPage-CIAoHmJG.js → WidgetsPage-HrhnI3C-.js} +1 -1
  49. package/dashboard/dist/assets/{WrappedPage-CC_57Zr2.js → WrappedPage-sm7UVFon.js} +1 -1
  50. package/dashboard/dist/assets/{__vite-browser-external-CPskAZuH.js → __vite-browser-external-C7JgMYNl.js} +2 -2
  51. package/dashboard/dist/assets/{agent-logos-CcJUaB75.js → agent-logos-DGrrmPth.js} +1 -1
  52. package/dashboard/dist/assets/{arrow-left-CUiT31ZF.js → arrow-left-DOzsdmqR.js} +1 -1
  53. package/dashboard/dist/assets/{arrow-right-Tds6Mert.js → arrow-right-CHb0kJou.js} +1 -1
  54. package/dashboard/dist/assets/{arrow-up-right-CGSxdyzM.js → arrow-up-right-CH8vEEN1.js} +1 -1
  55. package/dashboard/dist/assets/{calendar-days-Cc8AtMa3.js → calendar-days-_D5qnyH_.js} +1 -1
  56. package/dashboard/dist/assets/{check-CzJylQ9j.js → check-DZLesnNy.js} +1 -1
  57. package/dashboard/dist/assets/{chevron-down-DyG9JVDO.js → chevron-down-QL4xkUtL.js} +1 -1
  58. package/dashboard/dist/assets/{cloud-checkout-DP5zddOq.js → cloud-checkout-DiCcWJVl.js} +1 -1
  59. package/dashboard/dist/assets/{composite-I_1t6PMI.js → composite-DObGcQmb.js} +1 -1
  60. package/dashboard/dist/assets/{download-B_LvkErh.js → download-BKp8pusR.js} +1 -1
  61. package/dashboard/dist/assets/{external-link-DDA3ObBn.js → external-link-B3p_TVGc.js} +1 -1
  62. package/dashboard/dist/assets/{flame-BqpVWH_1.js → flame-Df9OTUym.js} +1 -1
  63. package/dashboard/dist/assets/{format-tokens-D6QEOnGq.js → format-tokens-DXrEDEYs.js} +1 -1
  64. package/dashboard/dist/assets/{gift-BxbKo3W6.js → gift-DtWubiuR.js} +1 -1
  65. package/dashboard/dist/assets/{host-mode-o3qQY7tz.js → host-mode-C069A_hB.js} +1 -1
  66. package/dashboard/dist/assets/{icons-oGPZPj2n.js → icons-lB1kfROy.js} +1 -1
  67. package/dashboard/dist/assets/{index-BxtvQ1J7.js → index-D356L-jw.js} +1 -1
  68. package/dashboard/dist/assets/{index-DX--5z1g.js → index-DsXIWrJx.js} +1 -1
  69. package/dashboard/dist/assets/{index-Byukv2Nu.js → index-M5BiC0jx.js} +1 -1
  70. package/dashboard/dist/assets/{info-BoTz1AGZ.js → info-CSG8OkG4.js} +1 -1
  71. package/dashboard/dist/assets/{link-2-C09a122s.js → link-2-BkBGu7FX.js} +1 -1
  72. package/dashboard/dist/assets/{loader-circle--9U0axVe.js → loader-circle-BERDkbsP.js} +1 -1
  73. package/dashboard/dist/assets/{modifiers.esm-Cra0I6RP.js → modifiers.esm-Ce5IvVw2.js} +1 -1
  74. package/dashboard/dist/assets/{monitor-smartphone-C1ENjmOu.js → monitor-smartphone-zKuoJldz.js} +1 -1
  75. package/dashboard/dist/assets/{play-NqPqbW59.js → play-C0x-pxft.js} +1 -1
  76. package/dashboard/dist/assets/{plus-DZP82JeP.js → plus-DJvks-CX.js} +1 -1
  77. package/dashboard/dist/assets/{provider-display-BLo4k0bi.js → provider-display-C0e4tAFu.js} +1 -1
  78. package/dashboard/dist/assets/{react-CTLavVze.js → react-Bg0_YfGs.js} +1 -1
  79. package/dashboard/dist/assets/{safePolygon-Yw5w5Nw8.js → safePolygon-CptquMWZ.js} +1 -1
  80. package/dashboard/dist/assets/{search-DgV6mpMO.js → search-CLESf2Tg.js} +1 -1
  81. package/dashboard/dist/assets/{server-BybwAQjW.js → server-Cdwhp-2m.js} +1 -1
  82. package/dashboard/dist/assets/{shield-check-BiTYwWdT.js → shield-check-8U4XqmW3.js} +1 -1
  83. package/dashboard/dist/assets/{skills-api-Dx_Z8_SO.js → skills-api-ioDaxLLo.js} +1 -1
  84. package/dashboard/dist/assets/{sortable.esm-CmJnBLcr.js → sortable.esm-CEohF5EK.js} +1 -1
  85. package/dashboard/dist/assets/{store-DzNIKGzf.js → store-CyOeiGFE.js} +1 -1
  86. package/dashboard/dist/assets/{terminal-DPly-UPW.js → terminal-BjgwEAH-.js} +1 -1
  87. package/dashboard/dist/assets/{trash-DsL2ZAN5.js → trash-Skj6z7D1.js} +1 -1
  88. package/dashboard/dist/assets/{use-community-stats-CSTkXFed.js → use-community-stats-Cworqjzy.js} +1 -1
  89. package/dashboard/dist/assets/{use-latest-request-guard-CbAXXNlU.js → use-latest-request-guard-DMVWXXHE.js} +1 -1
  90. package/dashboard/dist/assets/{use-limits-display-prefs-mDl6Yv_-.js → use-limits-display-prefs-DKJZcYfE.js} +1 -1
  91. package/dashboard/dist/assets/{use-native-settings-Bu2C3b20.js → use-native-settings-CQF4BLQl.js} +1 -1
  92. package/dashboard/dist/assets/{use-ordered-list-DkGSfMTv.js → use-ordered-list-B9yoUGUU.js} +1 -1
  93. package/dashboard/dist/assets/use-reduced-motion-DPUViCfp.js +1 -0
  94. package/dashboard/dist/assets/{use-session-efficiency-pref-B2GDf83h.js → use-session-efficiency-pref-K00bK2sQ.js} +1 -1
  95. package/dashboard/dist/assets/{use-transform-BVVduBPJ.js → use-transform-Cfw11yOU.js} +1 -1
  96. package/dashboard/dist/assets/{use-usage-limits-fuzpbbVh.js → use-usage-limits-BE2dJXFd.js} +1 -1
  97. package/dashboard/dist/assets/{useCurrency-CdDQzroJ.js → useCurrency-BW7y9Tdv.js} +1 -1
  98. package/dashboard/dist/assets/{usePositioner-b6XXJtxE.js → usePositioner-DhtQcPOC.js} +1 -1
  99. package/dashboard/dist/assets/{useTokenFormat-90RoMQgI.js → useTokenFormat-BnvzUc-t.js} +1 -1
  100. package/dashboard/dist/assets/{zap-xEHzTW-T.js → zap-BQ3BR9On.js} +1 -1
  101. package/dashboard/dist/index.html +1 -1
  102. package/dashboard/dist/ip-check.html +1 -1
  103. package/dashboard/dist/leaderboard.html +1 -1
  104. package/dashboard/dist/share.html +1 -1
  105. package/package.json +1 -1
  106. package/src/commands/status.js +5 -1
  107. package/src/commands/sync.js +28 -1
  108. package/src/lib/jsonl-lines.js +34 -4
  109. package/src/lib/pricing/seed-snapshot.json +1 -1
  110. package/src/lib/rollout.js +148 -52
  111. package/src/lib/session-analytics.js +11 -10
  112. package/src/lib/upload-queue.js +1 -1
  113. package/dashboard/dist/assets/DialogDescription-ChbOGLc_.js +0 -1
  114. package/dashboard/dist/assets/use-reduced-motion-6nBw3cR5.js +0 -1
@@ -1 +1 @@
1
- import{o as be,Z as ye,a as fe,r as o,q as pe,$ as we,c as a,j as e,y as b}from"./__vite-browser-external-CPskAZuH.js";import{A as ke}from"./arrow-left-CUiT31ZF.js";const oe={name:"mail",size:24,node:[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]};oe.node;const ve=be(oe),je=e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1Z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23Z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18A10.96 10.96 0 0 0 1 12c0 1.77.42 3.44 1.18 4.93l3.66-2.84Z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53Z",fill:"#EA4335"})]}),Ne=e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12Z"})}),_e={google:je,github:Ne},Ce={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",apple:"Apple"};function Ae(n){return Ce[n]||String(n||"").replace(/-/g," ")}function Pe(n){if(typeof n=="string"&&n.trim())return n.trim();if(n&&typeof n=="object"){if(typeof n.token=="string"&&n.token.trim())return n.token.trim();if(typeof n.otp=="string"&&n.otp.trim())return n.otp.trim()}return""}function Le({title:n,subtitle:H,className:se="",onSuccess:S,oauthReturnPath:Z,hideTitle:ie=!1,hideLogo:G=!1,initialMode:f="signin",tokenFromUrl:E="",initialEmail:p="",initialCode:v=""}){ye();const{enabled:w,configurationError:ne,connectionHost:T,signedIn:j,refreshUser:L,signInWithPassword:V,signUp:U,signInWithOAuth:W,getPublicAuthConfig:$,sendResetPasswordEmail:z,exchangeResetPasswordToken:J,resetPassword:K}=fe(),[l,m]=o.useState(f),[g,k]=o.useState(p),[x,N]=o.useState(""),[O,q]=o.useState(""),[F,le]=o.useState(""),[I,Q]=o.useState(v),[_,h]=o.useState(!1),[X,s]=o.useState(null),[C,y]=o.useState(null),[M,R]=o.useState(!1),[de,ce]=o.useState(!!(f!=="signin"||p)),[A,Y]=o.useState(!0),[P,ee]=o.useState([]),[re,ge]=o.useState(8);o.useEffect(()=>{f&&m(f)},[f]),o.useEffect(()=>{p&&k(p)},[p]),o.useEffect(()=>{v&&Q(v)},[v]),o.useEffect(()=>{if(!w)return;let r=!0;return Y(!0),(async()=>{const{data:t,error:i}=await $();if(!r)return;const c=t&&typeof t=="object"&&!Array.isArray(t)&&Array.isArray(t.oAuthProviders)&&t.oAuthProviders.every(d=>typeof d=="string"&&d.length>0)&&(t.customOAuthProviders===void 0||Array.isArray(t.customOAuthProviders)&&t.customOAuthProviders.every(d=>typeof d=="string"&&d.length>0));if(i||!c)ee(["google","github"]);else{const d=t.oAuthProviders,he=Array.isArray(t.customOAuthProviders)?t.customOAuthProviders:[];ee([...d,...he]),typeof t.passwordMinLength=="number"&&t.passwordMinLength>0&&ge(t.passwordMinLength)}Y(!1)})(),()=>{r=!1}},[w,$]),o.useEffect(()=>{j&&S&&S()},[j,S]);const ae=o.useCallback(()=>typeof window>"u"?"":pe()?"tokentracker://auth/callback":`${window.location.origin}/`,[]),te=o.useMemo(()=>typeof window>"u"?"/reset-password":`${window.location.origin}/reset-password`,[]),B=o.useCallback(async r=>{s(null),h(!0);try{const t=we(Z);if(t)try{window.sessionStorage.setItem("tt.cloud.return",t)}catch{}const{error:i}=await W(r,ae());i&&s(i.message||String(i))}finally{h(!1)}},[W,ae,Z]);o.useEffect(()=>{if(!w||A||j||typeof window>"u")return;const r=window.location.search;if(!r)return;const t=new URLSearchParams(r),i=t.get("native")==="1",c=t.get("provider");i&&c&&[...P].includes(c)&&B(c)},[w,A,j,P,B]);const ue=o.useCallback(async r=>{r.preventDefault(),s(null),h(!0);try{if(l==="signup"){const{data:i,error:c}=await U({email:g.trim(),password:x,name:F.trim()||void 0});if(c){s(c.message||String(c));return}if(i?.requireEmailVerification){y(a("login.verify_email_pending")),m("signin");return}await L();return}const{error:t}=await V({email:g.trim(),password:x});if(t){s(t.message||String(t));return}await L()}finally{h(!1)}},[l,g,x,F,U,V,L]),me=o.useCallback(async r=>{r.preventDefault(),s(null),h(!0);try{const t=g.trim(),{error:i}=await z({email:t,redirectTo:te});if(i){s(i.message||String(i));return}k(t),y(a("reset_password.request.sent")),m("reset_confirm")}finally{h(!1)}},[g,te,z]),xe=o.useCallback(async r=>{if(r.preventDefault(),s(null),x!==O){s(a("reset_password.error.password_mismatch"));return}h(!0);try{let t=E;if(!t){const{data:c,error:d}=await J({email:g.trim(),code:I.trim()});if(d){s(d.message||String(d));return}if(t=Pe(c),!t){s(a("reset_password.error.missing_token"));return}}const{error:i}=await K({newPassword:x,otp:t});if(i){s(i.message||String(i));return}R(!0),y(a("reset_password.success"))}finally{h(!1)}},[I,O,g,J,x,K,E]);if(!w)return ne?e.jsx("p",{role:"alert",className:"p-4 text-sm leading-6 text-oai-gray-700 dark:text-oai-gray-300",children:a("instance.configuration.invalid")}):null;const u=l==="reset_email"||l==="reset_confirm",D=A||!!P.length;return e.jsxs("div",{className:b("w-full bg-white dark:bg-oai-gray-950 p-6 transition-colors duration-200",se),children:[u&&e.jsxs("button",{type:"button",onClick:()=>{m("signin"),y(null),s(null),R(!1),N(""),q("")},className:"flex items-center gap-1.5 text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors mb-4 focus:outline-none",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),a("reset_password.back_to_sign_in")]}),e.jsxs("div",{className:b("mb-6",u?"text-left":"text-center"),children:[!G&&!u&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:28,height:28,className:"rounded-md"}),e.jsx("span",{className:"text-lg font-semibold text-oai-black dark:text-white font-oai tracking-tight",children:a("shared.app_name")})]}),!ie||u?e.jsx("h2",{className:b("text-sm font-semibold text-oai-black dark:text-white tracking-tight mb-1",(G||u)&&"text-base font-bold md:text-lg"),children:u?a("reset_password.title"):n||a("login_modal.subtitle")}):null,!u&&H&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px] mx-auto",children:H}),u&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px]",children:C&&l==="reset_confirm"&&!M?C:a("reset_password.subtitle")})]}),T?e.jsx("p",{className:"mb-4 text-center text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:a("instance.connection.destination",{host:T})}):null,C&&(!u||M)&&e.jsx("div",{className:"mb-4 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900/50 px-3 py-2 text-xs text-oai-gray-700 dark:text-oai-gray-300",children:C}),X&&e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400 text-center",role:"alert",children:X}),l==="reset_email"&&e.jsxs("form",{onSubmit:me,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.request.submit")})]}),l==="reset_confirm"&&(M?e.jsx("button",{type:"button",onClick:()=>{m("signin"),R(!1),y(null),s(null),N(""),q("")},className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors text-center shadow-sm",children:a("reset_password.success_cta")}):e.jsxs("form",{onSubmit:xe,className:"space-y-3",children:[!E&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email-confirm",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-code",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.code")}),e.jsx("input",{id:"card-reset-code",type:"text",inputMode:"numeric",autoComplete:"one-time-code",required:!0,value:I,onChange:r=>Q(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.new_password")}),e.jsx("input",{id:"card-reset-password",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:x,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.confirm_password")}),e.jsx("input",{id:"card-reset-password-confirm",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:O,onChange:r=>q(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.reset.submit")})]})),!u&&e.jsxs(e.Fragment,{children:[D?e.jsx("div",{className:"space-y-2.5 mb-5",children:A?e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"}),e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"})]}):P.map(r=>e.jsxs("button",{type:"button",disabled:_,onClick:()=>B(r),className:b("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors disabled:opacity-50","flex items-center justify-center gap-2.5"),children:[_e[r]||null,a("login.oauth.continue",{provider:Ae(r)})]},r))}):null,de?e.jsxs(e.Fragment,{children:[D?e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login_modal.divider_email")})})]}):null,e.jsxs("div",{className:"flex rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 bg-oai-gray-50 dark:bg-oai-gray-900/50 mb-4",children:[e.jsx("button",{type:"button",className:b("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",l==="signin"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{m("signin"),s(null)},children:a("login.tab.sign_in")}),e.jsx("button",{type:"button",className:b("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",l==="signup"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{m("signup"),s(null)},children:a("login.tab.sign_up")})]}),e.jsxs("form",{onSubmit:ue,className:"space-y-3",children:[l==="signup"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.name")}),e.jsx("input",{id:"card-name",type:"text",autoComplete:"name",value:F,onChange:r=>le(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500",placeholder:a("login.field.name_placeholder")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-email",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.password")}),e.jsx("input",{id:"card-password",type:"password",autoComplete:l==="signup"?"new-password":"current-password",required:!0,minLength:l==="signup"?re:void 0,value:x,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"}),l==="signup"&&e.jsx("p",{className:"mt-1 text-xs text-oai-gray-400 dark:text-oai-gray-600",children:a("login.password_hint",{min:String(re)})}),l==="signin"&&e.jsx("div",{className:"mt-1 text-right",children:e.jsx("button",{type:"button",onClick:()=>{m("reset_email"),s(null),y(null)},className:"text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white no-underline bg-transparent border-0 p-0 cursor-pointer focus:outline-none",children:a("login.forgot_password")})})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:l==="signup"?a("login.submit.sign_up"):a("login.submit.sign_in")})]})]}):e.jsxs(e.Fragment,{children:[D?e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login.divider")})})]}):null,e.jsxs("button",{type:"button",onClick:()=>ce(!0),className:b("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors","flex items-center justify-center gap-2.5"),children:[e.jsx(ve,{className:"h-[18px] w-[18px] text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75}),a("login_modal.continue_email")]})]})]})]})}export{Le as L};
1
+ import{o as be,Z as ye,a as fe,r as o,q as pe,$ as we,c as a,j as e,y as b}from"./__vite-browser-external-C7JgMYNl.js";import{A as ke}from"./arrow-left-DOzsdmqR.js";const oe={name:"mail",size:24,node:[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]};oe.node;const ve=be(oe),je=e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1Z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23Z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18A10.96 10.96 0 0 0 1 12c0 1.77.42 3.44 1.18 4.93l3.66-2.84Z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53Z",fill:"#EA4335"})]}),Ne=e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12Z"})}),_e={google:je,github:Ne},Ce={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",apple:"Apple"};function Ae(n){return Ce[n]||String(n||"").replace(/-/g," ")}function Pe(n){if(typeof n=="string"&&n.trim())return n.trim();if(n&&typeof n=="object"){if(typeof n.token=="string"&&n.token.trim())return n.token.trim();if(typeof n.otp=="string"&&n.otp.trim())return n.otp.trim()}return""}function Le({title:n,subtitle:H,className:se="",onSuccess:S,oauthReturnPath:Z,hideTitle:ie=!1,hideLogo:G=!1,initialMode:f="signin",tokenFromUrl:E="",initialEmail:p="",initialCode:v=""}){ye();const{enabled:w,configurationError:ne,connectionHost:T,signedIn:j,refreshUser:L,signInWithPassword:V,signUp:U,signInWithOAuth:W,getPublicAuthConfig:$,sendResetPasswordEmail:z,exchangeResetPasswordToken:J,resetPassword:K}=fe(),[l,m]=o.useState(f),[g,k]=o.useState(p),[x,N]=o.useState(""),[O,q]=o.useState(""),[F,le]=o.useState(""),[I,Q]=o.useState(v),[_,h]=o.useState(!1),[X,s]=o.useState(null),[C,y]=o.useState(null),[M,R]=o.useState(!1),[de,ce]=o.useState(!!(f!=="signin"||p)),[A,Y]=o.useState(!0),[P,ee]=o.useState([]),[re,ge]=o.useState(8);o.useEffect(()=>{f&&m(f)},[f]),o.useEffect(()=>{p&&k(p)},[p]),o.useEffect(()=>{v&&Q(v)},[v]),o.useEffect(()=>{if(!w)return;let r=!0;return Y(!0),(async()=>{const{data:t,error:i}=await $();if(!r)return;const c=t&&typeof t=="object"&&!Array.isArray(t)&&Array.isArray(t.oAuthProviders)&&t.oAuthProviders.every(d=>typeof d=="string"&&d.length>0)&&(t.customOAuthProviders===void 0||Array.isArray(t.customOAuthProviders)&&t.customOAuthProviders.every(d=>typeof d=="string"&&d.length>0));if(i||!c)ee(["google","github"]);else{const d=t.oAuthProviders,he=Array.isArray(t.customOAuthProviders)?t.customOAuthProviders:[];ee([...d,...he]),typeof t.passwordMinLength=="number"&&t.passwordMinLength>0&&ge(t.passwordMinLength)}Y(!1)})(),()=>{r=!1}},[w,$]),o.useEffect(()=>{j&&S&&S()},[j,S]);const ae=o.useCallback(()=>typeof window>"u"?"":pe()?"tokentracker://auth/callback":`${window.location.origin}/`,[]),te=o.useMemo(()=>typeof window>"u"?"/reset-password":`${window.location.origin}/reset-password`,[]),B=o.useCallback(async r=>{s(null),h(!0);try{const t=we(Z);if(t)try{window.sessionStorage.setItem("tt.cloud.return",t)}catch{}const{error:i}=await W(r,ae());i&&s(i.message||String(i))}finally{h(!1)}},[W,ae,Z]);o.useEffect(()=>{if(!w||A||j||typeof window>"u")return;const r=window.location.search;if(!r)return;const t=new URLSearchParams(r),i=t.get("native")==="1",c=t.get("provider");i&&c&&[...P].includes(c)&&B(c)},[w,A,j,P,B]);const ue=o.useCallback(async r=>{r.preventDefault(),s(null),h(!0);try{if(l==="signup"){const{data:i,error:c}=await U({email:g.trim(),password:x,name:F.trim()||void 0});if(c){s(c.message||String(c));return}if(i?.requireEmailVerification){y(a("login.verify_email_pending")),m("signin");return}await L();return}const{error:t}=await V({email:g.trim(),password:x});if(t){s(t.message||String(t));return}await L()}finally{h(!1)}},[l,g,x,F,U,V,L]),me=o.useCallback(async r=>{r.preventDefault(),s(null),h(!0);try{const t=g.trim(),{error:i}=await z({email:t,redirectTo:te});if(i){s(i.message||String(i));return}k(t),y(a("reset_password.request.sent")),m("reset_confirm")}finally{h(!1)}},[g,te,z]),xe=o.useCallback(async r=>{if(r.preventDefault(),s(null),x!==O){s(a("reset_password.error.password_mismatch"));return}h(!0);try{let t=E;if(!t){const{data:c,error:d}=await J({email:g.trim(),code:I.trim()});if(d){s(d.message||String(d));return}if(t=Pe(c),!t){s(a("reset_password.error.missing_token"));return}}const{error:i}=await K({newPassword:x,otp:t});if(i){s(i.message||String(i));return}R(!0),y(a("reset_password.success"))}finally{h(!1)}},[I,O,g,J,x,K,E]);if(!w)return ne?e.jsx("p",{role:"alert",className:"p-4 text-sm leading-6 text-oai-gray-700 dark:text-oai-gray-300",children:a("instance.configuration.invalid")}):null;const u=l==="reset_email"||l==="reset_confirm",D=A||!!P.length;return e.jsxs("div",{className:b("w-full bg-white dark:bg-oai-gray-950 p-6 transition-colors duration-200",se),children:[u&&e.jsxs("button",{type:"button",onClick:()=>{m("signin"),y(null),s(null),R(!1),N(""),q("")},className:"flex items-center gap-1.5 text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors mb-4 focus:outline-none",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),a("reset_password.back_to_sign_in")]}),e.jsxs("div",{className:b("mb-6",u?"text-left":"text-center"),children:[!G&&!u&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:28,height:28,className:"rounded-md"}),e.jsx("span",{className:"text-lg font-semibold text-oai-black dark:text-white font-oai tracking-tight",children:a("shared.app_name")})]}),!ie||u?e.jsx("h2",{className:b("text-sm font-semibold text-oai-black dark:text-white tracking-tight mb-1",(G||u)&&"text-base font-bold md:text-lg"),children:u?a("reset_password.title"):n||a("login_modal.subtitle")}):null,!u&&H&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px] mx-auto",children:H}),u&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px]",children:C&&l==="reset_confirm"&&!M?C:a("reset_password.subtitle")})]}),T?e.jsx("p",{className:"mb-4 text-center text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:a("instance.connection.destination",{host:T})}):null,C&&(!u||M)&&e.jsx("div",{className:"mb-4 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900/50 px-3 py-2 text-xs text-oai-gray-700 dark:text-oai-gray-300",children:C}),X&&e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400 text-center",role:"alert",children:X}),l==="reset_email"&&e.jsxs("form",{onSubmit:me,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.request.submit")})]}),l==="reset_confirm"&&(M?e.jsx("button",{type:"button",onClick:()=>{m("signin"),R(!1),y(null),s(null),N(""),q("")},className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors text-center shadow-sm",children:a("reset_password.success_cta")}):e.jsxs("form",{onSubmit:xe,className:"space-y-3",children:[!E&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email-confirm",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-code",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.code")}),e.jsx("input",{id:"card-reset-code",type:"text",inputMode:"numeric",autoComplete:"one-time-code",required:!0,value:I,onChange:r=>Q(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.new_password")}),e.jsx("input",{id:"card-reset-password",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:x,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.confirm_password")}),e.jsx("input",{id:"card-reset-password-confirm",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:O,onChange:r=>q(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.reset.submit")})]})),!u&&e.jsxs(e.Fragment,{children:[D?e.jsx("div",{className:"space-y-2.5 mb-5",children:A?e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"}),e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"})]}):P.map(r=>e.jsxs("button",{type:"button",disabled:_,onClick:()=>B(r),className:b("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors disabled:opacity-50","flex items-center justify-center gap-2.5"),children:[_e[r]||null,a("login.oauth.continue",{provider:Ae(r)})]},r))}):null,de?e.jsxs(e.Fragment,{children:[D?e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login_modal.divider_email")})})]}):null,e.jsxs("div",{className:"flex rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 bg-oai-gray-50 dark:bg-oai-gray-900/50 mb-4",children:[e.jsx("button",{type:"button",className:b("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",l==="signin"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{m("signin"),s(null)},children:a("login.tab.sign_in")}),e.jsx("button",{type:"button",className:b("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",l==="signup"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{m("signup"),s(null)},children:a("login.tab.sign_up")})]}),e.jsxs("form",{onSubmit:ue,className:"space-y-3",children:[l==="signup"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.name")}),e.jsx("input",{id:"card-name",type:"text",autoComplete:"name",value:F,onChange:r=>le(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500",placeholder:a("login.field.name_placeholder")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-email",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.password")}),e.jsx("input",{id:"card-password",type:"password",autoComplete:l==="signup"?"new-password":"current-password",required:!0,minLength:l==="signup"?re:void 0,value:x,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"}),l==="signup"&&e.jsx("p",{className:"mt-1 text-xs text-oai-gray-400 dark:text-oai-gray-600",children:a("login.password_hint",{min:String(re)})}),l==="signin"&&e.jsx("div",{className:"mt-1 text-right",children:e.jsx("button",{type:"button",onClick:()=>{m("reset_email"),s(null),y(null)},className:"text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white no-underline bg-transparent border-0 p-0 cursor-pointer focus:outline-none",children:a("login.forgot_password")})})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:l==="signup"?a("login.submit.sign_up"):a("login.submit.sign_in")})]})]}):e.jsxs(e.Fragment,{children:[D?e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login.divider")})})]}):null,e.jsxs("button",{type:"button",onClick:()=>ce(!0),className:b("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors","flex items-center justify-center gap-2.5"),children:[e.jsx(ve,{className:"h-[18px] w-[18px] text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75}),a("login_modal.continue_email")]})]})]})]})}export{Le as L};
@@ -1 +1 @@
1
- import{u as p,a as x,r as l,j as a,c as o,X as y}from"./__vite-browser-external-CPskAZuH.js";import{L as m}from"./LoginCard-CYmjHoYK.js";import{D as h,a as b,b as f,c as j,d as k,e as v}from"./DialogTitle-BBxNf3O8.js";import{D as w}from"./DialogDescription-ChbOGLc_.js";import"./arrow-left-CUiT31ZF.js";import"./composite-I_1t6PMI.js";import"./store-DzNIKGzf.js";function E(){const{isOpen:c,request:t,closeLoginModal:i,completeLoginModal:s}=p(),{enabled:d,configurationError:r}=x(),e=t?.id,n=l.useCallback(()=>i(e),[i,e]),g=l.useCallback(()=>{s(e)},[s,e]);return a.jsx(h,{open:c,onOpenChange:u=>{u||n()},children:a.jsxs(b,{children:[a.jsx(f,{className:"fixed inset-0 z-[100] bg-black/40 transition-opacity duration-200 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0 dark:bg-black/60"}),a.jsx(j,{className:"fixed inset-0 z-[101] flex items-center justify-center overflow-y-auto overscroll-contain p-4",children:a.jsxs(k,{className:"relative max-h-[calc(100dvh-2rem)] w-full max-w-[420px] overflow-y-auto overscroll-contain rounded-2xl border border-oai-gray-200 bg-white shadow-2xl transition-[opacity,transform] duration-200 data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.95] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.95] data-[starting-style]:opacity-0 motion-reduce:transition-none dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[a.jsx(v,{className:"sr-only",children:o("login.title")}),t?.subtitle?a.jsx(w,{className:"sr-only",children:t.subtitle}):null,a.jsx("button",{type:"button",onClick:n,"aria-label":o("shared.dialog.close"),className:"absolute right-2 top-2 z-10 flex h-11 w-11 items-center justify-center rounded-md text-oai-gray-400 transition-colors hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-500 dark:hover:text-white",children:a.jsx(y,{className:"h-5 w-5","aria-hidden":!0})}),d?a.jsx(m,{title:t?.nextPath?o("login.title"):void 0,hideTitle:!0,subtitle:t?.subtitle,oauthReturnPath:t?.nextPath,onSuccess:g,className:"p-6 bg-transparent"},e):a.jsx("p",{role:r?"alert":"status",className:"p-6 pt-14 text-sm leading-6 text-oai-gray-700 dark:text-oai-gray-300",children:o(r?"instance.configuration.invalid":"login.cloud_only")})]})})]})})}export{E as LoginModal};
1
+ import{u as p,a as x,r as l,j as a,c as o,X as y}from"./__vite-browser-external-C7JgMYNl.js";import{L as m}from"./LoginCard-4bdpPQeD.js";import{D as h,a as b,b as f,c as j,d as k,e as v}from"./DialogTitle-ufFnN-8D.js";import{D as w}from"./DialogDescription-MbuaPFlj.js";import"./arrow-left-DOzsdmqR.js";import"./composite-DObGcQmb.js";import"./store-CyOeiGFE.js";function E(){const{isOpen:c,request:t,closeLoginModal:i,completeLoginModal:s}=p(),{enabled:d,configurationError:r}=x(),e=t?.id,n=l.useCallback(()=>i(e),[i,e]),g=l.useCallback(()=>{s(e)},[s,e]);return a.jsx(h,{open:c,onOpenChange:u=>{u||n()},children:a.jsxs(b,{children:[a.jsx(f,{className:"fixed inset-0 z-[100] bg-black/40 transition-opacity duration-200 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0 dark:bg-black/60"}),a.jsx(j,{className:"fixed inset-0 z-[101] flex items-center justify-center overflow-y-auto overscroll-contain p-4",children:a.jsxs(k,{className:"relative max-h-[calc(100dvh-2rem)] w-full max-w-[420px] overflow-y-auto overscroll-contain rounded-2xl border border-oai-gray-200 bg-white shadow-2xl transition-[opacity,transform] duration-200 data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.95] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.95] data-[starting-style]:opacity-0 motion-reduce:transition-none dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[a.jsx(v,{className:"sr-only",children:o("login.title")}),t?.subtitle?a.jsx(w,{className:"sr-only",children:t.subtitle}):null,a.jsx("button",{type:"button",onClick:n,"aria-label":o("shared.dialog.close"),className:"absolute right-2 top-2 z-10 flex h-11 w-11 items-center justify-center rounded-md text-oai-gray-400 transition-colors hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-500 dark:hover:text-white",children:a.jsx(y,{className:"h-5 w-5","aria-hidden":!0})}),d?a.jsx(m,{title:t?.nextPath?o("login.title"):void 0,hideTitle:!0,subtitle:t?.subtitle,oauthReturnPath:t?.nextPath,onSuccess:g,className:"p-6 bg-transparent"},e):a.jsx("p",{role:r?"alert":"status",className:"p-6 pt-14 text-sm leading-6 text-oai-gray-700 dark:text-oai-gray-300",children:o(r?"instance.configuration.invalid":"login.cloud_only")})]})})]})})}export{E as LoginModal};
@@ -1 +1 @@
1
- import{d as j,e as N,a as _,r,c as s,j as e,L as p}from"./__vite-browser-external-CPskAZuH.js";import{L as k}from"./LoginCard-CYmjHoYK.js";import"./arrow-left-CUiT31ZF.js";function L(n){const t=new URLSearchParams(n).get("next");return typeof t!="string"||t.length===0||!t.startsWith("/")||t.startsWith("//")?"/dashboard":t}function I(){const n=j(),[t,f]=N(),{enabled:o,configurationError:g,loading:x,signedIn:h,refreshUser:m}=_(),a=r.useMemo(()=>L(t.toString()),[t]),l=/^\/(cloud|billing\/checkout)(\?|$)/.test(a),w=l&&new URLSearchParams(a.split("?")[1]).get("intent")==="trial",[y,u]=r.useState(null);r.useEffect(()=>{if(/^\/(cloud|billing\/checkout)(\?|$)/.test(a))try{window.sessionStorage.setItem("tt.cloud.return",a)}catch{}},[a]),r.useEffect(()=>{const d=t.get("insforge_status"),i=t.get("insforge_type"),b=t.get("insforge_error");d==="success"&&i==="verify_email"?u(s("login.verify_email_success")):d==="error"&&i==="verify_email"&&b&&u(s("shared.error.prefix",{error:b}))},[t]);const c=r.useMemo(()=>t.get("native")==="1",[t]);r.useEffect(()=>{if(!(!o||x)&&h){if(c){window.location.href="/auth/native-callback";return}try{window.sessionStorage.removeItem("tt.cloud.return")}catch{}n(a,{replace:!0})}},[o,x,h,n,a,c]),r.useEffect(()=>{o&&m()},[o,m]),r.useEffect(()=>{if(c&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[c]);const v=r.useCallback(()=>{f(d=>{const i=new URLSearchParams(d);return i.delete("insforge_status"),i.delete("insforge_type"),i.delete("insforge_error"),i},{replace:!0}),u(null)},[f]);return o?e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:e.jsx(p,{to:l?"/cloud":"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 rounded",children:s(l?"cloud.checkout.back":"login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[y?e.jsxs("div",{className:"rounded-lg border border-oai-gray-800 bg-oai-gray-900/50 px-4 py-3 text-sm text-oai-gray-300 flex justify-between gap-3 items-start",role:"status",children:[e.jsx("span",{children:y}),e.jsx("button",{type:"button",onClick:v,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:s("login.dismiss")})]}):null,e.jsx("div",{className:"border border-oai-gray-900 bg-oai-gray-950 rounded-2xl overflow-hidden shadow-2xl",children:e.jsx(k,{hideLogo:!0,title:s("login.title"),subtitle:s(l?w?"cloud.login.trial_context":"cloud.login.purchase_context":"login.subtitle"),className:"p-8 bg-transparent",onSuccess:()=>{if(c)window.location.href="/auth/native-callback";else{try{window.sessionStorage.removeItem("tt.cloud.return")}catch{}n(a,{replace:!0})}}})})]})})]}):e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:e.jsx(p,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:s("login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:e.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",role:g?"alert":void 0,children:g?s("instance.configuration.invalid"):s("login.cloud_only")})})]})}export{I as LoginPage};
1
+ import{d as j,e as N,a as _,r,c as s,j as e,L as p}from"./__vite-browser-external-C7JgMYNl.js";import{L as k}from"./LoginCard-4bdpPQeD.js";import"./arrow-left-DOzsdmqR.js";function L(n){const t=new URLSearchParams(n).get("next");return typeof t!="string"||t.length===0||!t.startsWith("/")||t.startsWith("//")?"/dashboard":t}function I(){const n=j(),[t,f]=N(),{enabled:o,configurationError:g,loading:x,signedIn:h,refreshUser:m}=_(),a=r.useMemo(()=>L(t.toString()),[t]),l=/^\/(cloud|billing\/checkout)(\?|$)/.test(a),w=l&&new URLSearchParams(a.split("?")[1]).get("intent")==="trial",[y,u]=r.useState(null);r.useEffect(()=>{if(/^\/(cloud|billing\/checkout)(\?|$)/.test(a))try{window.sessionStorage.setItem("tt.cloud.return",a)}catch{}},[a]),r.useEffect(()=>{const d=t.get("insforge_status"),i=t.get("insforge_type"),b=t.get("insforge_error");d==="success"&&i==="verify_email"?u(s("login.verify_email_success")):d==="error"&&i==="verify_email"&&b&&u(s("shared.error.prefix",{error:b}))},[t]);const c=r.useMemo(()=>t.get("native")==="1",[t]);r.useEffect(()=>{if(!(!o||x)&&h){if(c){window.location.href="/auth/native-callback";return}try{window.sessionStorage.removeItem("tt.cloud.return")}catch{}n(a,{replace:!0})}},[o,x,h,n,a,c]),r.useEffect(()=>{o&&m()},[o,m]),r.useEffect(()=>{if(c&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[c]);const v=r.useCallback(()=>{f(d=>{const i=new URLSearchParams(d);return i.delete("insforge_status"),i.delete("insforge_type"),i.delete("insforge_error"),i},{replace:!0}),u(null)},[f]);return o?e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:e.jsx(p,{to:l?"/cloud":"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 rounded",children:s(l?"cloud.checkout.back":"login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[y?e.jsxs("div",{className:"rounded-lg border border-oai-gray-800 bg-oai-gray-900/50 px-4 py-3 text-sm text-oai-gray-300 flex justify-between gap-3 items-start",role:"status",children:[e.jsx("span",{children:y}),e.jsx("button",{type:"button",onClick:v,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:s("login.dismiss")})]}):null,e.jsx("div",{className:"border border-oai-gray-900 bg-oai-gray-950 rounded-2xl overflow-hidden shadow-2xl",children:e.jsx(k,{hideLogo:!0,title:s("login.title"),subtitle:s(l?w?"cloud.login.trial_context":"cloud.login.purchase_context":"login.subtitle"),className:"p-8 bg-transparent",onSuccess:()=>{if(c)window.location.href="/auth/native-callback";else{try{window.sessionStorage.removeItem("tt.cloud.return")}catch{}n(a,{replace:!0})}}})})]})})]}):e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:e.jsx(p,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:s("login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:e.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",role:g?"alert":void 0,children:g?s("instance.configuration.invalid"):s("login.cloud_only")})})]})}export{I as LoginPage};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BotAnimated-k6u1GRzw.js","assets/__vite-browser-external-CPskAZuH.js","assets/__vite-browser-external-kAUz3kFs.css","assets/Controls-C2mEPI72.js","assets/Card-Dk6s3h-P.js","assets/ProviderIcon-BuLwtYjj.js","assets/use-native-settings-Bu2C3b20.js","assets/FadeIn-DSndojVd.js","assets/react-CTLavVze.js","assets/use-reduced-motion-6nBw3cR5.js","assets/link-2-C09a122s.js","assets/loader-circle--9U0axVe.js","assets/zap-xEHzTW-T.js","assets/trash-DsL2ZAN5.js","assets/DialogTitle-BBxNf3O8.js","assets/composite-I_1t6PMI.js","assets/store-DzNIKGzf.js","assets/DialogDescription-ChbOGLc_.js","assets/DialogClose-D1dzj_on.js"])))=>i.map(i=>d[i]);
2
- import{o as Y,A as Me,p as Ce,ce as Pe,r as h,cf as Ae,cg as $e,ch as Ee,al as ue,j as r,_ as _e,c as u,y as j,ci as Ie,bj as ie,X as Le}from"./__vite-browser-external-CPskAZuH.js";import{T as ne,S as Oe}from"./Controls-C2mEPI72.js";import{P as Te}from"./ProviderIcon-BuLwtYjj.js";import{u as ze}from"./use-native-settings-Bu2C3b20.js";import{F as se}from"./FadeIn-DSndojVd.js";import{L as Re}from"./link-2-C09a122s.js";import{L as ge}from"./loader-circle--9U0axVe.js";import{Z as Be}from"./zap-xEHzTW-T.js";import{T as De}from"./trash-DsL2ZAN5.js";import{D as Ve,a as Ue,b as Fe,c as Ke,d as He,e as qe}from"./DialogTitle-BBxNf3O8.js";import{D as Ze}from"./DialogDescription-ChbOGLc_.js";import{D as We}from"./DialogClose-D1dzj_on.js";const pe={name:"file-archive",size:24,node:[["path",{d:"M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5",key:"4pqfef"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 12v-1",key:"1ej8lb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M8 7V6",key:"1nbb54"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]]};pe.node;const Ge=Y(pe);const me={name:"monitor-up",size:24,node:[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]};me.node;const Xe=Y(me);const he={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};he.node;const Ye=Y(he),Jt="cercle",Je="neutre",xe="encre",fe="creme",Qt={light:"#f8fafc",dark:"#0f172a"};function Qe(e){return e?fe:xe}const J=["auto","bleu","turquoise","vert","ambre","rose","violet"];function ea(e,t){const a=String(e||"auto");return a==="auto"||!J.includes(a)?Qe(t):a}const et={"idle-living":{state:"idle",expression:"neutre"},"idle-look":{state:"idle",expression:"curieux"},"idle-follow":{state:"idle",expression:"attentif"},"idle-yawn":{state:"idle",expression:"somnolent"},"static-base":{state:"idle",expression:"neutre"},sleeping:{state:"sleep"},"idle-doze":{state:"sleep"},"idle-collapse":{state:"sleep"},"collapse-sleep":{state:"sleep"},"mini-enter-sleep":{state:"sleep"},"mini-sleep":{state:"sleep"},waiting:{state:"sleep"},"working-typing":{state:"thinking"},"working-thinking":{state:"thinking"},"working-building":{state:"thinking"},"working-debugger":{state:"thinking"},running:{state:"thinking"},review:{state:"thinking"},"working-juggling":{state:"orbit"},"working-wizard":{state:"orbit"},"working-carrying":{state:"orbit"},"working-conducting":{state:"orbit"},"working-ultrathink":{state:"swirl"},"working-overheated":{state:"burst"},"working-confused":{state:"wide"},error:{state:"alert"},disconnected:{state:"alert"},happy:{state:"play"},jumping:{state:"play"},"mini-happy":{state:"play"},waking:{state:"play"},wake:{state:"play"},"react-double":{state:"play"},notification:{state:"notify"},"mini-alert":{state:"notify"},"mini-peek":{state:"wink"},waving:{state:"wink"},"mini-idle":{state:"idle",expression:"neutre"},"mini-enter":{state:"wink"},"running-left":{state:"comet"},"running-right":{state:"comet"},"react-drag":{state:"comet"}},tt={state:"idle",expression:Je};function ta(e){return et[e]||tt}const at=Object.assign(Object.create(null),{clawd:"clawd",bot:"vector"});function be(e){return at[T(e)]||"atlas"}function T(e){const t=String(e||"").trim().toLowerCase();return/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/.test(t)?t:"clawd"}const rt={visible:!1,character:"clawd",size:"medium",botColor:"auto"};function it(){const e=(Me()||Ce())&&Pe(),[t,a]=h.useState(rt),[i,n]=h.useState(!1);h.useEffect(()=>{if(!e)return;const o=Ae(l=>{n(!0),a({visible:!!l.visible,character:T(l.character),size:["small","medium","large"].includes(l.size)?l.size:"medium",botColor:J.includes(l.botColor)?l.botColor:"auto"})});return $e(),o},[e]);const s=h.useCallback((o,l)=>{a(c=>({...c,[o]:l})),e&&Ee(o,l)},[e]);return{available:e,loaded:i,settings:t,setSetting:s}}const L=[{id:"clawd",displayName:"Clawd",nameKey:"pet.character.clawd",spriteVersionNumber:1,custom:!1},{id:"bot",displayName:"Bot",nameKey:"pet.character.bot",spriteVersionNumber:1,custom:!1},{id:"sprout",displayName:"Sprout",nameKey:"pet.character.sprout",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/sprout/spritesheet.webp"},{id:"byte",displayName:"Byte",nameKey:"pet.character.byte",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/byte/spritesheet.webp"},{id:"ember",displayName:"Ember",nameKey:"pet.character.ember",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/ember/spritesheet.webp"}];async function V(e){const t=await e.json().catch(()=>null);if(!e.ok||t?.ok===!1)throw new Error(t?.error||`Pet request failed with HTTP ${e.status}`);return t}async function nt(){const e=await fetch("/functions/tokentracker-pets",{headers:{Accept:"application/json"},cache:"no-store"}),t=await V(e),a=new Set(Array.isArray(t.hiddenBuiltinIds)?t.hiddenBuiltinIds:[]);return[...L.filter(i=>!i.assetUrl||!a.has(i.id)),...Array.isArray(t.pets)?t.pets:[]]}async function Q(e){const t=await ue();return V(await fetch("/functions/tokentracker-pets",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...t},cache:"no-store",body:JSON.stringify(e)}))}function st(e){return Q({action:"install_url",url:e})}async function oe(e){const t=await ue();return V(await fetch("/api/pets/import",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/zip",...t},cache:"no-store",body:e}))}function ot(e){return Q({action:"remove",id:e})}async function lt(){const e=await fetch("/functions/tokentracker-pets?scope=codex",{headers:{Accept:"application/json"},cache:"no-store"}),t=await V(e);return{importable:Array.isArray(t.importable)?t.importable:[],codexDetected:t.codexDetected===!0}}function ct(e){return Q({action:"import_codex",ids:e})}let W=L;function dt(){const[e,t]=h.useState(W),[a,i]=h.useState(!0),[n,s]=h.useState(!1),o=h.useCallback(async()=>{i(!0);try{const l=await nt();return W=l,t(l),s(!0),l}catch{return W=L,t(L),s(!1),L}finally{i(!1)}},[]);return h.useEffect(()=>{o()},[o]),{pets:e,loading:a,available:n,refresh:o}}const w=64,ut={egg:[.8369,.8424,.8497,.8585,.8674,.8775,.8878,.8983,.9089,.9185,.9288,.9374,.9445,.9504,.9543,.9559,.9555,.9519,.9466,.9389,.9302,.9193,.9085,.8969,.8852,.8734,.8625,.8513,.8411,.8325,.8243,.8179,.8137,.8112,.8102,.8128,.8178,.8262,.8374,.8518,.8702,.8922,.9169,.9446,.9741,1.0023,1.0267,1.0433,1.0481,1.0393,1.0216,.997,.9697,.9418,.9169,.8949,.876,.8604,.849,.8394,.8337,.8314,.8305,.8326],hexagon:[.921,.9282,.9441,.9706,.9984,1.0059,.9896,.9562,.929,.9124,.9047,.9058,.9157,.9349,.9642,.9873,.9882,.9665,.9336,.9105,.8968,.8918,.8955,.908,.9293,.9611,.982,.9812,.959,.9282,.9089,.8978,.8964,.9026,.9189,.9439,.9778,.999,.9964,.9713,.9439,.9274,.9196,.9206,.9308,.9502,.9799,1.0121,1.0226,1.0071,.9752,.951,.9366,.9316,.9351,.9485,.9711,1.0026,1.0213,1.0155,.9863,.9547,.9347,.9232],triangle:[.7819,.8211,.8747,.944,1.0223,1.096,1.1401,1.134,1.0808,1.0047,.9265,.8603,.8104,.773,.745,.7273,.7151,.7118,.7148,.7245,.7427,.768,.8037,.8518,.9148,.9876,1.0583,1.1073,1.1109,1.0667,.994,.9164,.8482,.7948,.7555,.7261,.7056,.6925,.6859,.6869,.6938,.7084,.7305,.7615,.804,.8595,.9311,1.0092,1.0791,1.1171,1.1054,1.0501,.9779,.905,.845,.799,.7656,.7413,.7258,.716,.7146,.7204,.733,.7528]},S=Math.PI*2,aa=(e,t=0,a=1)=>e<t?t:e>a?a:e,$=(e,t,a)=>e+(t-e)*a,ra={easeOutCubic:e=>1-(1-e)**3,easeInOutCubic:e=>e<.5?4*e**3:1-(-2*e+2)**3/2,easeOutQuint:e=>1-(1-e)**5};function ia(e,t,a=0){const i=e/t*S;return .55*Math.sin(i+a)+.3*Math.sin(2*i+a*1.7+1.1)+.15*Math.sin(3*i+a*2.3+2.4)}function na(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let a=Math.imul(t^t>>>15,1|t);return a=a+Math.imul(a^a>>>7,61|a)^a,((a^a>>>14)>>>0)/4294967296}}const x=e=>Math.round(e*100)/100,ee=Array.from({length:w},(e,t)=>t/w*S),U=ee.map(Math.cos),F=ee.map(Math.sin);function sa(e,t={}){return{radii:[...ut[e]],rot:0,cx:0,cy:0,sx:1,sy:1,...t}}function oa(e,t={}){return{radii:new Array(w).fill(e),rot:0,cx:0,cy:0,sx:1,sy:1,...t}}function la(e,t,a,i){const n=i??{radii:new Array(w),rot:0,cx:0,cy:0,sx:1,sy:1};for(let o=0;o<w;o++)n.radii[o]=$(e.radii[o]??1,t.radii[o]??1,a);let s=t.rot-e.rot;for(;s>Math.PI;)s-=S;for(;s<-Math.PI;)s+=S;return n.rot=e.rot+s*a,n.cx=$(e.cx,t.cx,a),n.cy=$(e.cy,t.cy,a),n.sx=$(e.sx,t.sx,a),n.sy=$(e.sy,t.sy,a),n}function ca(e,t,a=[]){const i=Math.cos(e.rot),n=Math.sin(e.rot);for(let s=0;s<w;s++){const o=e.radii[s]??1,l=o*(U[s]??0),c=o*(F[s]??0),d=l*i-c*n,g=l*n+c*i,p=a[s]??{x:0,y:0};p.x=(d*e.sx+e.cx)*t,p.y=(g*e.sy+e.cy)*t,a[s]=p}return a.length=w,a}function da(e,t=1/6){const a=e.length;if(a<3)return"";const i=e[0];let n=`M${x(i.x)} ${x(i.y)}`;for(let s=0;s<a;s++){const o=e[(s-1+a)%a],l=e[s],c=e[(s+1)%a],d=e[(s+2)%a],g=l.x+(c.x-o.x)*t,p=l.y+(c.y-o.y)*t,f=c.x-(d.x-l.x)*t,b=c.y-(d.y-l.y)*t;n+=`C${x(g)} ${x(p)} ${x(f)} ${x(b)} ${x(c.x)} ${x(c.y)}`}return`${n}Z`}function te(e,t,a){const i=new Array(w).fill(0),n=e.length;for(let s=0;s<w;s++){const o=U[s]??0,l=F[s]??0;let c=0;for(let d=0;d<n;d++){const g=e[d],p=e[(d+1)%n],f=p.x-g.x,b=p.y-g.y,y=o*b-l*f;if(Math.abs(y)<1e-9)continue;const C=g.x-t,N=g.y-a,v=(C*b-N*f)/y,M=(C*l-N*o)/y;v>c&&M>=0&&M<=1&&(c=v)}i[s]=c}return i}function ye(e,t,a,i,n,s,o=96){const l=i-e,c=n-t,d=Math.hypot(l,c)||1e-6,g=Math.atan2(c,l),p=Math.acos(Math.max(-1,Math.min(1,(a-s)/d))),f=[];for(let b=0;b<=o/2;b++){const y=g+p+(S-2*p)*b/(o/2);f.push({x:e+Math.cos(y)*a,y:t+Math.sin(y)*a})}for(let b=0;b<=o/2;b++){const y=g-p+2*p*b/(o/2);f.push({x:i+Math.cos(y)*s,y:n+Math.sin(y)*s})}return f}function ua(e,t){const a=e.length,i=(t/S%1+1)%1*a,n=Math.floor(i);return $(e[n%a]??1,e[(n+1)%a]??1,i-n)}function gt(e,t=1,a=1){return ee.map((i,n)=>{const s=Math.abs((U[n]??0)/t)**e,o=Math.abs((F[n]??0)/a)**e;return(s+o)**(-1/e)})}function pt(e){const t=new Array(w).fill(0);for(let a=0;a<w;a++){const i=U[a]??0,n=F[a]??0;let s=0;for(const o of e){const l=i*o.x+n*o.y,c=l*l-(o.x*o.x+o.y*o.y-o.r*o.r);if(c<0)continue;const d=l+Math.sqrt(c);d>s&&(s=d)}t[a]=s}return t}function mt(e,t,a=10){const i=e.length,n=[],s=(o,l)=>{const c=l.x-o.x,d=l.y-o.y,g=Math.hypot(c,d)||1;return Math.atan2(-c/g,d/g)};for(let o=0;o<i;o++){const l=e[(o-1+i)%i],c=e[o],d=e[(o+1)%i],g=s(l,c);let f=s(c,d)-g;for(;f>Math.PI;)f-=S;for(;f<-Math.PI;)f+=S;for(let b=0;b<=a;b++){const y=g+f*b/a;n.push({x:c.x+Math.cos(y)*t,y:c.y+Math.sin(y)*t})}}return n}function le(e,t,a,i=0){const n=i*Math.PI/180,s=Array.from({length:e},(o,l)=>{const c=n+l/e*S;return{x:Math.cos(c)*(t-a),y:Math.sin(c)*(t-a)}});return te(mt(s,a),0,0)}function ga(e,t=1){if(e.length<3)return"";let a="";for(let i=0;i<e.length;i++){const n=e[i];a+=`${i===0?"M":"L"}${x(n.x*t)} ${x(n.y*t)}`}return`${a}Z`}function pa(e,t){const a=Math.max(e,.01)/2,i=Math.max(t,.01)/2,n=Math.min(a,i);return`M${x(-a)} ${x(-i+n)}A${x(n)} ${x(n)} 0 0 1 ${x(-a+n)} ${x(-i)}L${x(a-n)} ${x(-i)}A${x(n)} ${x(n)} 0 0 1 ${x(a)} ${x(-i+n)}L${x(a)} ${x(i-n)}A${x(n)} ${x(n)} 0 0 1 ${x(a-n)} ${x(i)}L${x(-a+n)} ${x(i)}A${x(n)} ${x(n)} 0 0 1 ${x(-a)} ${x(i-n)}Z`}function K(e,t=1){const a=Math.max(...e);if(a<=0)return e;const i=t/a;return e.map(n=>n*i)}const ht=Array.from({length:w},(e,t)=>t/w*Math.PI*2),xt=K(ht.map(e=>1+.075*Math.cos(2*e+.5)+.035*Math.cos(3*e+2.1)),1.02),ft=K(pt([{x:-.44,y:.2,r:.54},{x:.46,y:.2,r:.5},{x:.02,y:.3,r:.6},{x:-.24,y:-.3,r:.48},{x:.3,y:-.24,r:.44}]),1.02),bt=K(te(ye(0,.28,.66,0,-.96,.05),0,0),1.04),yt=te(ye(-.42,0,.62,.42,0,.62),0,0),wt=[{id:"cercle",radii:new Array(w).fill(1)},{id:"galet",radii:xt},{id:"squircle",radii:K(gt(4.2),1.15)},{id:"capsule",radii:yt},{id:"triangle",radii:le(3,1.12,.34,-90)},{id:"hexagone",radii:le(6,1.04,.26,0)},{id:"nuage",radii:ft},{id:"goutte",radii:bt}],ma=new Map(wt.map(e=>[e.id,e])),kt=[{id:"encre",hex:"#0a0a0c"},{id:"brun",hex:"#8b5e3c"},{id:"rouge",hex:"#e8483f"},{id:"orange",hex:"#f08a24"},{id:"ambre",hex:"#f0b429"},{id:"vert",hex:"#3ecf8e"},{id:"turquoise",hex:"#2fbfa0"},{id:"bleu",hex:"#3b93f0"},{id:"violet",hex:"#8b5cf6"},{id:"rose",hex:"#e152b0"},{id:"gris",hex:"#a3a3a3"},{id:"creme",hex:"#f1efe9"}],G=new Map(kt.map(e=>[e.id,e]));function ha(e,t,a){const i=l=>{const c=parseInt(l.slice(1),16);return[c>>16&255,c>>8&255,c&255]},n=i(e),s=i(t);return`#${n.map((l,c)=>Math.round(l+(s[c]-l)*a)).map(l=>l.toString(16).padStart(2,"0")).join("")}`}const vt=.84,jt=1.35,Nt=Object.assign(Object.create(null),{clawd:vt,bot:jt});function ce(e){return Nt[T(e)]??1}const St={idle:{row:0,durations:[280,110,110,140,140,320]},"running-right":{row:1,durations:[120,120,120,120,120,120,120,220]},"running-left":{row:2,durations:[120,120,120,120,120,120,120,220]},waving:{row:3,durations:[140,140,140,280]},jumping:{row:4,durations:[140,140,140,140,280]},failed:{row:5,durations:[140,140,140,140,140,140,140,240]},waiting:{row:6,durations:[150,150,150,150,150,260]},running:{row:7,durations:[120,120,120,120,120,220]},review:{row:8,durations:[150,150,150,150,150,280]}};function Mt(e){return["error","disconnected","working-overheated"].includes(e)?"failed":["happy","waking","mini-happy","jumping"].includes(e)?"jumping":["working-typing","working-ultrathink","working-juggling","running"].includes(e)?"running":["working-thinking","working-wizard","review"].includes(e)?"review":["sleeping","idle-doze","mini-sleep","waiting"].includes(e)?"waiting":["mini-peek","waving"].includes(e)?"waving":e==="running-left"||e==="running-right"?e:"idle"}function Ct(){const[e,t]=h.useState(()=>typeof document>"u"?!0:document.visibilityState!=="hidden");return h.useEffect(()=>{if(typeof document>"u")return;const a=()=>t(document.visibilityState!=="hidden");return document.addEventListener("visibilitychange",a),()=>document.removeEventListener("visibilitychange",a)},[]),e}function Pt(){const[e,t]=h.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return h.useEffect(()=>{if(typeof window.matchMedia!="function")return;const a=window.matchMedia("(prefers-reduced-motion: reduce)"),i=n=>t(n.matches);return a.addEventListener("change",i),()=>a.removeEventListener("change",i)},[]),e}function At({character:e,pet:t=null,state:a="idle-living",dragState:i=null,size:n=48,className:s="",lookDirectionIndex:o=null}){const l=T(e),c=i==="running-left"||i==="running-right"?i:Mt(a),d=St[c],g=t?.spriteVersionNumber===2?2:1,p=g===2?11:9,f=g===2&&c==="idle"&&Number.isInteger(o)?(o%16+16)%16:null,b=f==null?d.row:9+Math.floor(f/8),y=f==null?null:f%8,C=Pt(),N=Ct(),[v,M]=h.useState(0);h.useEffect(()=>{if(M(0),C||!N||f!=null)return;let P=!1,z=0;const E=_=>{z=window.setTimeout(()=>{if(P)return;const R=(_+1)%d.durations.length;M(R),E(R)},d.durations[_])};return E(0),()=>{P=!0,window.clearTimeout(z)}},[f,C,N,d]);const H=h.useMemo(()=>({width:n*(192/208),height:n,backgroundImage:`url(${t?.assetUrl||`/pets/${l}/spritesheet.webp`})`,backgroundRepeat:"no-repeat",backgroundSize:`800% ${p*100}%`,backgroundPosition:`${(y??v)/7*100}% ${b/(p-1)*100}%`,imageRendering:"pixelated"}),[p,y,b,v,l,t?.assetUrl,n]);return r.jsx("div",{"aria-hidden":"true",className:`pet-atlas-animated ${s}`,style:H})}const $t=h.lazy(()=>_e(()=>import("./BotAnimated-k6u1GRzw.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])).then(e=>({default:e.BotAnimated}))),de={"idle-living":"idle/living.svg","idle-doze":"idle/doze.svg","idle-follow":"idle/follow.svg","idle-look":"idle/look.svg","idle-yawn":"idle/yawn.svg","idle-collapse":"idle/collapse.svg","working-building":"working/building.svg","working-carrying":"working/carrying.svg","working-conducting":"working/conducting.svg","working-confused":"working/confused.svg","working-debugger":"working/debugger.svg","working-juggling":"working/juggling.svg","working-overheated":"working/overheated.svg","working-pushing":"working/pushing.svg","working-sweeping":"working/sweeping.svg","working-thinking":"working/thinking.svg","working-typing":"working/typing.svg","working-ultrathink":"working/ultrathink.svg","working-wizard":"working/wizard.svg","mini-alert":"mini/alert.svg","mini-crabwalk":"mini/crabwalk.svg","mini-enter":"mini/enter.svg","mini-enter-sleep":"mini/enter-sleep.svg","mini-happy":"mini/happy.svg","mini-idle":"mini/idle.svg","mini-peek":"mini/peek.svg","mini-sleep":"mini/sleep.svg","react-double":"react/double.svg","react-drag":"react/drag.svg","react-left":"react/left.svg","react-right":"react/right.svg","collapse-sleep":"sleep/collapse-sleep.svg",sleeping:"sleep/sleeping.svg",wake:"sleep/wake.svg",disconnected:"status/disconnected.svg",error:"status/error.svg",notification:"status/notification.svg",happy:"happy.svg","static-base":"static-base.svg"},X=new Map;async function Et(e){if(X.has(e))return X.get(e);if(typeof fetch!="function")return null;let t;try{t=await fetch(`/clawd/${e}`)}catch{return null}if(!t.ok)return null;const i=(await t.text()).replace(/<svg([^>]*)>/,(n,s)=>`<svg${s.replace(/\s+width="[^"]*"/g,"").replace(/\s+height="[^"]*"/g,"")} width="100%" height="100%">`);return X.set(e,i),i}function _t({state:e="idle-living",size:t=48,className:a=""}){const[i,n]=h.useState(""),s=h.useRef(null),l=It()?"static-base":e,c=de[l]||de["static-base"];return h.useEffect(()=>{let d=!1;return Et(c).then(g=>{!d&&g&&n(g)}),()=>{d=!0}},[c]),h.useEffect(()=>{const d=s.current?.querySelector("svg");if(d)try{const g=d.getBBox();g.width>0&&g.height>0&&d.setAttribute("viewBox",`${g.x-2} ${g.y-2} ${g.width+4} ${g.height+4}`)}catch{}},[i]),r.jsx("div",{ref:s,"aria-hidden":"true",className:`clawd-animated ${a}`,style:{width:t,height:t,display:"inline-flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},dangerouslySetInnerHTML:{__html:i}})}function we({state:e="idle-living",size:t=48,className:a="",character:i="clawd",pet:n=null,lookDirectionIndex:s=null,botColor:o="auto"}){const l=T(i),c=be(l);return c==="vector"?r.jsx(h.Suspense,{fallback:r.jsx("span",{"aria-hidden":"true",style:{width:t,height:t,display:"inline-block"}}),children:r.jsx($t,{state:e,size:t*ce(l),className:a,color:o})}):c==="atlas"?r.jsx(At,{character:l,pet:n,state:e,size:t,className:a,lookDirectionIndex:s}):r.jsx(_t,{state:e,size:t*ce(l),className:a})}function It(){const[e,t]=h.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return h.useEffect(()=>{if(typeof window.matchMedia!="function")return;const a=window.matchMedia("(prefers-reduced-motion: reduce)"),i=n=>t(n.matches);return a.addEventListener("change",i),()=>a.removeEventListener("change",i)},[]),e}const Lt={clawd:"from-oai-amber-50 dark:from-orange-950/70",bot:"from-oai-brand-50 dark:from-teal-950/70",sprout:"from-oai-brand-100 dark:from-emerald-950/70",byte:"from-oai-gray-200 dark:from-slate-800/70",ember:"from-orange-100 dark:from-orange-950/80"};function Ot(){const e=u("pet.import.subtitle"),t="codex-pets.net",a=e.indexOf(t);return a<0?e:r.jsxs(r.Fragment,{children:[e.slice(0,a),r.jsx("a",{href:"https://codex-pets.net",target:"_blank",rel:"noreferrer",className:"underline decoration-oai-gray-400 underline-offset-2 transition-colors hover:text-oai-black dark:decoration-oai-gray-500 dark:hover:text-white",children:t}),e.slice(a+t.length)]})}const O=[{id:"idle-living",labelKey:"pet.state.calm"},{id:"working-thinking",labelKey:"pet.state.focus"},{id:"working-juggling",labelKey:"pet.state.multitask"},{id:"working-wizard",labelKey:"pet.state.streak"},{id:"happy",labelKey:"pet.state.celebrate"},{id:"sleeping",labelKey:"pet.state.rest"}];function ke({character:e,selected:t,onSelect:a,onRemove:i,removeDisabled:n}){const s=e.nameKey?u(e.nameKey):e.displayName;return r.jsxs("div",{className:"group relative",children:[r.jsxs("button",{type:"button",onClick:a,"aria-pressed":t,className:j("relative w-full overflow-hidden rounded-xl border p-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",t?"border-oai-brand-500/40 bg-white dark:border-oai-brand-500/25 dark:bg-oai-gray-900/80":"border-oai-gray-200/80 bg-white/55 hover:border-oai-gray-400 dark:border-oai-gray-800 dark:bg-oai-gray-950/55 dark:hover:border-oai-gray-600"),children:[r.jsx("div",{className:j("absolute inset-0 bg-gradient-to-br to-transparent opacity-80 dark:opacity-55",Lt[e.id]||"from-oai-gray-200/80 dark:from-oai-gray-800/70")}),r.jsxs("div",{className:"relative flex items-center gap-2.5",children:[r.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center",children:r.jsx(we,{state:"idle-living",character:e.id,pet:e,size:44})}),r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"truncate text-sm font-semibold text-oai-black dark:text-white",children:s}),e.spriteVersionNumber===2?r.jsx("span",{className:"shrink-0 rounded border border-oai-gray-300/80 px-1 text-[9px] font-semibold text-oai-gray-500 dark:border-oai-gray-600 dark:text-oai-gray-400",children:u("pet.format.v2")}):null,t?r.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-oai-brand-500","aria-hidden":!0}):null]})]})]}),i?r.jsx("button",{type:"button",disabled:n,onClick:i,"aria-label":`${u("pet.import.remove")} · ${s}`,className:j("absolute right-1.5 top-1.5 flex h-6 w-6 items-center justify-center rounded-md border border-oai-gray-200/90 bg-white/95 text-oai-gray-500 transition-opacity hover:text-red-600 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-40 dark:border-oai-gray-700 dark:bg-oai-gray-900/95 dark:text-oai-gray-400 dark:hover:text-red-400","opacity-0 group-hover:opacity-100"),children:r.jsx(De,{className:"h-3 w-3","aria-hidden":!0})}):null]})}function Tt({value:e,onChange:t}){const a={auto:u("pet.bot.color.auto"),bleu:u("pet.bot.color.bleu"),turquoise:u("pet.bot.color.turquoise"),vert:u("pet.bot.color.vert"),ambre:u("pet.bot.color.ambre"),rose:u("pet.bot.color.rose"),violet:u("pet.bot.color.violet")};return r.jsx("div",{className:"flex flex-wrap items-center justify-end gap-1.5 rounded-full border border-black/5 bg-white/65 px-2.5 py-1.5 backdrop-blur-md dark:border-white/10 dark:bg-black/20",role:"radiogroup","aria-label":u("pet.bot.color"),children:J.map(i=>{const n=(e||"auto")===i;return r.jsx("button",{type:"button",role:"radio","aria-checked":n,"aria-label":a[i],title:a[i],onClick:()=>t(i),className:j("h-4 w-4 rounded-full border transition-transform duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",n?"scale-125 border-oai-black shadow-sm dark:border-white":"border-black/15 hover:scale-110 dark:border-white/25"),style:i==="auto"?{background:`linear-gradient(135deg, ${G.get(xe).hex} 0 50%, ${G.get(fe).hex} 50% 100%)`}:{background:G.get(i)?.hex}},i)})})}function zt({pet:e,state:t,onStateChange:a,botColor:i,onBotColorChange:n}){const[s,o]=h.useState(null),l=h.useRef(null),c=O.find(function(p){return p.id===t}),d=u(c?.labelKey||"pet.state.calm");return r.jsxs("section",{className:"relative flex min-h-[400px] flex-col overflow-hidden bg-oai-gray-50 dark:bg-oai-gray-950 sm:min-h-[440px] lg:min-h-[480px]",onPointerMove:g=>{if(e?.spriteVersionNumber!==2||!l.current)return;const p=l.current.getBoundingClientRect(),f=g.clientX-(p.left+p.width/2),b=g.clientY-(p.top+p.height/2),y=(Math.atan2(f,-b)*180/Math.PI+360)%360;o(Math.round(y/22.5)%16)},onPointerLeave:()=>o(null),children:[r.jsx("div",{className:"absolute inset-0 opacity-[0.16] dark:opacity-[0.12]",style:{backgroundImage:"radial-gradient(currentColor 0.7px, transparent 0.7px)",backgroundSize:"14px 14px"},"aria-hidden":!0}),r.jsxs("div",{className:"relative flex items-center justify-between gap-3 px-5 pt-5",children:[r.jsx("span",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-oai-gray-500 dark:text-oai-gray-400",children:u("pet.preview.states")}),r.jsxs("div",{className:"flex items-center gap-2",children:[be(e?.id)==="vector"?r.jsx(Tt,{value:i,onChange:n}):null,r.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-black/5 bg-white/65 px-3 py-1.5 text-[11px] font-medium text-oai-gray-600 backdrop-blur-md dark:border-white/10 dark:bg-black/20 dark:text-oai-gray-300",children:[r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500","aria-hidden":!0}),d]})]})]}),r.jsx("div",{className:"relative flex flex-1 items-center justify-center px-6 py-5",children:r.jsx("div",{ref:l,className:"relative flex h-52 w-52 items-center justify-center sm:h-56 sm:w-56 lg:h-64 lg:w-64",children:r.jsx("div",{className:"origin-bottom lg:scale-[1.18]",children:r.jsx(we,{state:t,character:e?.id||"clawd",pet:e,size:190,lookDirectionIndex:s,botColor:i})})})}),r.jsx("div",{className:"relative border-t border-oai-gray-200/70 bg-white/85 px-3 py-2 dark:border-oai-gray-800 dark:bg-oai-gray-950/85",children:r.jsx("div",{className:"grid grid-cols-3 gap-1","aria-label":u("pet.preview.states"),children:O.map(g=>r.jsxs("button",{type:"button",onClick:()=>a(g.id),"aria-pressed":t===g.id,className:j("flex min-h-10 flex-col items-center justify-center gap-1 rounded-lg px-1.5 text-xs transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500",t===g.id?"font-semibold text-oai-black dark:text-white":"font-medium text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:[r.jsx("span",{children:u(g.labelKey)}),r.jsx("span",{className:j("h-1 w-1 rounded-full transition-colors duration-200",t===g.id?"bg-oai-black dark:bg-white":"bg-transparent"),"aria-hidden":!0})]},g.id))})})]})}function Rt({pets:e,busy:t,error:a,onImport:i,onClose:n}){const[s,o]=h.useState(()=>new Set),l=d=>o(g=>{const p=new Set(g);return p.has(d)?p.delete(d):p.add(d),p}),c=e.length!==0&&s.size===e.length;return r.jsx(Ve,{open:!0,onOpenChange:d=>{!d&&!t&&n()},children:r.jsxs(Ue,{children:[r.jsx(Fe,{className:"fixed inset-0 z-50 bg-black/15 backdrop-blur-md dark:bg-black/40 animate-tt-fade-in"}),r.jsx(Ke,{className:"fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6",children:r.jsxs(He,{className:"relative flex max-h-[86vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-oai-gray-200/50 bg-white/95 shadow-2xl backdrop-blur-2xl dark:border-white/10 dark:bg-oai-gray-900/95 animate-tt-modal",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-oai-gray-200/70 px-5 py-4 dark:border-oai-gray-800",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx(qe,{className:"text-base font-semibold",children:u("pet.codex.title")}),r.jsx(Ze,{className:"mt-0.5 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:u("pet.codex.subtitle")})]}),r.jsx(We,{type:"button",disabled:t,"aria-label":u("pet.codex.close"),className:"shrink-0 rounded-full border border-oai-gray-200/60 p-1.5 text-oai-gray-500 transition-colors hover:text-oai-black disabled:opacity-40 dark:border-oai-gray-800/60 dark:text-oai-gray-400 dark:hover:text-white",children:r.jsx(Le,{size:16})})]}),r.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:[e.length===0?r.jsx("p",{className:"py-8 text-center text-sm text-oai-gray-400 dark:text-oai-gray-500",children:u("pet.codex.empty")}):r.jsx("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-3",children:e.map(d=>r.jsx(ke,{character:d,selected:s.has(d.id),onSelect:()=>l(d.id)},d.id))}),a?r.jsx("p",{role:"alert",className:"mt-3 text-xs text-red-600 dark:text-red-400",children:a}):null]}),r.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-oai-gray-200/70 px-5 py-3 dark:border-oai-gray-800",children:[r.jsx("button",{type:"button",disabled:t||e.length===0,onClick:()=>o(c?new Set:new Set(e.map(d=>d.id))),className:"text-xs font-medium text-oai-gray-500 underline-offset-2 hover:underline disabled:opacity-40 dark:text-oai-gray-400",children:u("pet.codex.select_all")}),r.jsxs("button",{type:"button",disabled:t||s.size===0,onClick:()=>i([...s]),className:"flex h-9 items-center gap-1.5 rounded-lg bg-oai-black px-4 text-xs font-semibold text-white transition-colors disabled:bg-oai-gray-200 disabled:text-oai-gray-400 dark:bg-white dark:text-black dark:disabled:bg-oai-gray-800 dark:disabled:text-oai-gray-500",children:[t?r.jsx(ge,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,s.size>0?`${u("pet.codex.import")} · ${s.size}`:u("pet.codex.import")]})]})]})})]})})}function Bt(){const{available:e,settings:t,setSetting:a}=it(),{pets:i,loading:n,available:s,refresh:o}=dt(),[l,c]=h.useState(""),[d,g]=h.useState(""),[p,f]=h.useState(!1),[b,y]=h.useState([]),[C,N]=h.useState(!1),[v,M]=h.useState(!1),[H,P]=h.useState(""),[z,E]=h.useState("idle-living"),[_,R]=h.useState(!0),I=t.character||"clawd",q=ze(),ae=q.settings?.menuBarIconStyle==="pet",ve=i.find(m=>m.id===I)||i[0],B=p?{kind:"busy",text:u("pet.import.busy")}:d?{kind:"error",text:d}:null,re=b.length!==0;h.useEffect(()=>{!n&&i.length>0&&!i.some(m=>m.id===I)&&a("character","clawd")},[n,i,I,a]);async function D(m,k=u("pet.import.success")){f(!0),g("");try{const A=await m();await o(),Ie(),A?.pet?.id&&a("character",A.pet.id),ie({title:k,timeout:4e3}),c("")}catch(A){g(A?.message||u("pet.import.failed"))}finally{f(!1)}}const Z=h.useCallback(async()=>{if(!s){y([]);return}try{const m=await lt();y(m.importable)}catch{y([])}},[s]);h.useEffect(()=>{Z()},[Z]);async function je(m){M(!0),P("");try{return await ct(m),await o(),await Z(),ie({title:u("pet.codex.imported"),timeout:4e3}),!0}catch(k){return P(k?.message||u("pet.import.failed")),!1}finally{M(!1)}}h.useEffect(()=>{if(!_)return;const m=window.setInterval(()=>{E(k=>{const A=O.findIndex(Se=>Se.id===k);return O[(A+1)%O.length].id})},5e3);return()=>window.clearInterval(m)},[_]);const Ne=[{value:"small",label:u("pet.size.small")},{value:"medium",label:u("pet.size.medium")},{value:"large",label:u("pet.size.large")}];return r.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:r.jsx("main",{className:"flex-1 pb-14 pt-8 sm:pt-10",children:r.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[r.jsx(se,{y:12,children:r.jsxs("header",{className:"mb-8",children:[r.jsx("h1",{className:"text-3xl font-semibold tracking-tight sm:text-4xl",children:u("pet.page.title")}),r.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:u("pet.page.subtitle")})]})}),r.jsx(se,{y:12,delay:.04,children:r.jsxs("div",{className:"overflow-hidden rounded-[28px] border border-oai-gray-200 bg-white/75 dark:border-oai-gray-800 dark:bg-oai-gray-900/60 lg:grid lg:grid-cols-[1.12fr_0.88fr]",children:[r.jsx(zt,{pet:ve,state:z,onStateChange:m=>{R(!1),E(m)},botColor:t.botColor,onBotColorChange:m=>a("botColor",m)}),r.jsxs("aside",{className:"flex flex-col border-t border-oai-gray-200 p-5 dark:border-oai-gray-800 lg:min-h-[480px] lg:border-l lg:border-t-0",children:[r.jsxs("section",{"aria-labelledby":"pet-character-title",children:[r.jsxs("div",{children:[r.jsx("h2",{id:"pet-character-title",className:"text-sm font-semibold",children:u("pet.characters.title")}),r.jsx("p",{className:"mt-1 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:u("pet.characters.subtitle")})]}),r.jsx("div",{className:"mt-4 grid max-h-72 grid-cols-2 gap-2 overflow-y-auto pr-1 -mr-1",children:i.map(m=>r.jsx(ke,{character:m,selected:I===m.id,onSelect:()=>a("character",m.id),removeDisabled:p,onRemove:s&&m.id!=="clawd"&&m.id!=="bot"?()=>D(async()=>(await ot(m.id),I===m.id&&a("character","clawd"),null),u("pet.import.removed")):void 0},m.id))}),q.available?r.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 rounded-xl border border-oai-gray-200/70 bg-oai-gray-50/60 px-3 py-2.5 dark:border-oai-gray-800 dark:bg-oai-gray-900/40",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"text-xs font-semibold",children:u("pet.menubar.title")}),r.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:u("pet.menubar.hint")})]}),r.jsx(ne,{checked:ae,onChange:()=>q.setSetting("menuBarIconStyle",ae?"clawd":"pet"),ariaLabel:u("pet.menubar.title")})]}):null]}),s?r.jsxs("section",{className:"mt-6 border-t border-oai-gray-200/70 pt-5 dark:border-oai-gray-800","aria-labelledby":"pet-import-title",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ye,{className:"h-4 w-4 shrink-0 text-oai-gray-500","aria-hidden":!0}),r.jsx("h2",{id:"pet-import-title",className:"text-sm font-semibold",children:u("pet.import.title")})]}),r.jsx("p",{className:"mt-1 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r.jsx(Ot,{})}),r.jsxs("form",{className:"mt-3 flex gap-2",onSubmit:m=>{m.preventDefault(),!p&&l.trim()&&D(()=>st(l))},children:[r.jsxs("label",{className:"relative flex min-w-0 flex-1 items-center",children:[r.jsx(Re,{className:"pointer-events-none absolute left-3 h-3.5 w-3.5 text-oai-gray-400","aria-hidden":!0}),r.jsx("input",{value:l,onChange:m=>c(m.target.value),"aria-label":u("pet.import.url_label"),placeholder:"codex-pets.net/#/pets/…",className:"h-9 w-full rounded-lg border border-oai-gray-200 bg-white pl-9 pr-3 text-xs outline-none focus:border-oai-brand-500 dark:border-oai-gray-700 dark:bg-oai-gray-950"})]}),r.jsxs("button",{type:"submit",disabled:p||!l.trim(),className:"flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-oai-black px-3.5 text-xs font-semibold text-white transition-colors disabled:bg-oai-gray-200 disabled:text-oai-gray-400 dark:bg-white dark:text-black dark:disabled:bg-oai-gray-800 dark:disabled:text-oai-gray-500",children:[p?r.jsx(ge,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,u("pet.import.add")]})]}),r.jsxs("div",{className:j("mt-2 grid gap-2",re?"grid-cols-2":"grid-cols-1"),children:[re?r.jsxs("button",{type:"button",disabled:p||v,onClick:()=>{P(""),N(!0)},className:j("flex h-9 cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-dashed border-oai-gray-300 text-xs font-medium text-oai-gray-500 transition-colors hover:border-oai-gray-500 hover:text-oai-black dark:border-oai-gray-600 dark:text-oai-gray-400 dark:hover:border-oai-gray-400 dark:hover:text-white",(p||v)&&"pointer-events-none opacity-40"),children:[r.jsx(Te,{provider:"codex",size:14,className:"fill-current"}),u("pet.codex.browse")]}):null,r.jsxs("label",{onDragOver:m=>m.preventDefault(),onDrop:m=>{if(m.preventDefault(),p)return;const k=m.dataTransfer?.files?.[0];k&&D(()=>oe(k))},className:j("flex h-9 cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-dashed border-oai-gray-300 text-xs font-medium text-oai-gray-500 transition-colors hover:border-oai-gray-500 hover:text-oai-black dark:border-oai-gray-600 dark:text-oai-gray-400 dark:hover:border-oai-gray-400 dark:hover:text-white",p&&"pointer-events-none opacity-40"),children:[r.jsx(Ge,{className:"h-3.5 w-3.5","aria-hidden":!0}),u("pet.import.zip"),r.jsx("input",{type:"file",accept:".zip,.codex-pet.zip,application/zip",className:"sr-only",disabled:p,onChange:m=>{const k=m.target.files?.[0];k&&D(()=>oe(k)),m.target.value=""}})]})]}),B?r.jsx("p",{role:B.kind==="error"?"alert":"status",className:j("mt-2 text-xs",B.kind==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400"),children:B.text}):null,C?r.jsx(Rt,{pets:b,busy:v,error:H,onClose:()=>{v||N(!1)},onImport:async m=>{await je(m)&&N(!1)}}):null]}):null,r.jsxs("section",{className:"mt-6 border-t border-oai-gray-200/70 pt-5 dark:border-oai-gray-800",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Xe,{className:"h-4 w-4 text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75,"aria-hidden":!0}),r.jsx("h2",{className:"text-sm font-semibold",children:u("pet.controls.title")})]}),r.jsxs("div",{className:"mt-4 space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsx("div",{className:"text-sm font-medium",children:u("pet.controls.show")}),r.jsx(ne,{checked:t.visible,onChange:()=>a("visible",!t.visible),disabled:!e,ariaLabel:u("pet.controls.show")})]}),r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsx("div",{className:"text-sm font-medium",children:u("pet.controls.size")}),r.jsx("div",{className:"shrink-0",children:r.jsx(Oe,{options:Ne,value:t.size,onChange:m=>a("size",m),disabled:!e})})]})]})]}),e?null:r.jsxs("div",{className:"mt-6 flex gap-2 rounded-xl bg-oai-gray-100 p-3 text-xs leading-relaxed text-oai-gray-500 dark:bg-oai-gray-800/70 dark:text-oai-gray-400",children:[r.jsx(Be,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),u("pet.controls.native_only")]})]})]})})]})})})}const xa=Object.freeze(Object.defineProperty({__proto__:null,PetPage:Bt},Symbol.toStringTag,{value:"Module"}));export{Jt as B,G as C,xa as P,wt as S,S as T,na as a,$ as b,aa as c,oa as d,ra as e,ga as f,ua as g,ye as h,da as i,pa as j,la as k,ia as l,ea as m,ma as n,Qt as o,te as p,ta as q,x as r,sa as s,ca as t,ha as u};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BotAnimated-BWy2-z4Q.js","assets/__vite-browser-external-C7JgMYNl.js","assets/__vite-browser-external-kAUz3kFs.css","assets/Controls-BkKlT6Dz.js","assets/Card-DPGBuBDb.js","assets/ProviderIcon-Cy_pKLdw.js","assets/use-native-settings-CQF4BLQl.js","assets/FadeIn-DlAKIU4I.js","assets/react-Bg0_YfGs.js","assets/use-reduced-motion-DPUViCfp.js","assets/link-2-BkBGu7FX.js","assets/loader-circle-BERDkbsP.js","assets/zap-BQ3BR9On.js","assets/trash-Skj6z7D1.js","assets/DialogTitle-ufFnN-8D.js","assets/composite-DObGcQmb.js","assets/store-CyOeiGFE.js","assets/DialogDescription-MbuaPFlj.js","assets/DialogClose-DKQ2ZVA0.js"])))=>i.map(i=>d[i]);
2
+ import{o as Y,A as Me,p as Ce,ce as Pe,r as h,cf as Ae,cg as $e,ch as Ee,al as ue,j as r,_ as _e,c as u,y as j,ci as Ie,bj as ie,X as Le}from"./__vite-browser-external-C7JgMYNl.js";import{T as ne,S as Oe}from"./Controls-BkKlT6Dz.js";import{P as Te}from"./ProviderIcon-Cy_pKLdw.js";import{u as ze}from"./use-native-settings-CQF4BLQl.js";import{F as se}from"./FadeIn-DlAKIU4I.js";import{L as Re}from"./link-2-BkBGu7FX.js";import{L as ge}from"./loader-circle-BERDkbsP.js";import{Z as Be}from"./zap-BQ3BR9On.js";import{T as De}from"./trash-Skj6z7D1.js";import{D as Ve,a as Ue,b as Fe,c as Ke,d as He,e as qe}from"./DialogTitle-ufFnN-8D.js";import{D as Ze}from"./DialogDescription-MbuaPFlj.js";import{D as We}from"./DialogClose-DKQ2ZVA0.js";const pe={name:"file-archive",size:24,node:[["path",{d:"M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5",key:"4pqfef"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 12v-1",key:"1ej8lb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M8 7V6",key:"1nbb54"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]]};pe.node;const Ge=Y(pe);const me={name:"monitor-up",size:24,node:[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]};me.node;const Xe=Y(me);const he={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};he.node;const Ye=Y(he),Jt="cercle",Je="neutre",xe="encre",fe="creme",Qt={light:"#f8fafc",dark:"#0f172a"};function Qe(e){return e?fe:xe}const J=["auto","bleu","turquoise","vert","ambre","rose","violet"];function ea(e,t){const a=String(e||"auto");return a==="auto"||!J.includes(a)?Qe(t):a}const et={"idle-living":{state:"idle",expression:"neutre"},"idle-look":{state:"idle",expression:"curieux"},"idle-follow":{state:"idle",expression:"attentif"},"idle-yawn":{state:"idle",expression:"somnolent"},"static-base":{state:"idle",expression:"neutre"},sleeping:{state:"sleep"},"idle-doze":{state:"sleep"},"idle-collapse":{state:"sleep"},"collapse-sleep":{state:"sleep"},"mini-enter-sleep":{state:"sleep"},"mini-sleep":{state:"sleep"},waiting:{state:"sleep"},"working-typing":{state:"thinking"},"working-thinking":{state:"thinking"},"working-building":{state:"thinking"},"working-debugger":{state:"thinking"},running:{state:"thinking"},review:{state:"thinking"},"working-juggling":{state:"orbit"},"working-wizard":{state:"orbit"},"working-carrying":{state:"orbit"},"working-conducting":{state:"orbit"},"working-ultrathink":{state:"swirl"},"working-overheated":{state:"burst"},"working-confused":{state:"wide"},error:{state:"alert"},disconnected:{state:"alert"},happy:{state:"play"},jumping:{state:"play"},"mini-happy":{state:"play"},waking:{state:"play"},wake:{state:"play"},"react-double":{state:"play"},notification:{state:"notify"},"mini-alert":{state:"notify"},"mini-peek":{state:"wink"},waving:{state:"wink"},"mini-idle":{state:"idle",expression:"neutre"},"mini-enter":{state:"wink"},"running-left":{state:"comet"},"running-right":{state:"comet"},"react-drag":{state:"comet"}},tt={state:"idle",expression:Je};function ta(e){return et[e]||tt}const at=Object.assign(Object.create(null),{clawd:"clawd",bot:"vector"});function be(e){return at[T(e)]||"atlas"}function T(e){const t=String(e||"").trim().toLowerCase();return/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/.test(t)?t:"clawd"}const rt={visible:!1,character:"clawd",size:"medium",botColor:"auto"};function it(){const e=(Me()||Ce())&&Pe(),[t,a]=h.useState(rt),[i,n]=h.useState(!1);h.useEffect(()=>{if(!e)return;const o=Ae(l=>{n(!0),a({visible:!!l.visible,character:T(l.character),size:["small","medium","large"].includes(l.size)?l.size:"medium",botColor:J.includes(l.botColor)?l.botColor:"auto"})});return $e(),o},[e]);const s=h.useCallback((o,l)=>{a(c=>({...c,[o]:l})),e&&Ee(o,l)},[e]);return{available:e,loaded:i,settings:t,setSetting:s}}const L=[{id:"clawd",displayName:"Clawd",nameKey:"pet.character.clawd",spriteVersionNumber:1,custom:!1},{id:"bot",displayName:"Bot",nameKey:"pet.character.bot",spriteVersionNumber:1,custom:!1},{id:"sprout",displayName:"Sprout",nameKey:"pet.character.sprout",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/sprout/spritesheet.webp"},{id:"byte",displayName:"Byte",nameKey:"pet.character.byte",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/byte/spritesheet.webp"},{id:"ember",displayName:"Ember",nameKey:"pet.character.ember",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/ember/spritesheet.webp"}];async function V(e){const t=await e.json().catch(()=>null);if(!e.ok||t?.ok===!1)throw new Error(t?.error||`Pet request failed with HTTP ${e.status}`);return t}async function nt(){const e=await fetch("/functions/tokentracker-pets",{headers:{Accept:"application/json"},cache:"no-store"}),t=await V(e),a=new Set(Array.isArray(t.hiddenBuiltinIds)?t.hiddenBuiltinIds:[]);return[...L.filter(i=>!i.assetUrl||!a.has(i.id)),...Array.isArray(t.pets)?t.pets:[]]}async function Q(e){const t=await ue();return V(await fetch("/functions/tokentracker-pets",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...t},cache:"no-store",body:JSON.stringify(e)}))}function st(e){return Q({action:"install_url",url:e})}async function oe(e){const t=await ue();return V(await fetch("/api/pets/import",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/zip",...t},cache:"no-store",body:e}))}function ot(e){return Q({action:"remove",id:e})}async function lt(){const e=await fetch("/functions/tokentracker-pets?scope=codex",{headers:{Accept:"application/json"},cache:"no-store"}),t=await V(e);return{importable:Array.isArray(t.importable)?t.importable:[],codexDetected:t.codexDetected===!0}}function ct(e){return Q({action:"import_codex",ids:e})}let W=L;function dt(){const[e,t]=h.useState(W),[a,i]=h.useState(!0),[n,s]=h.useState(!1),o=h.useCallback(async()=>{i(!0);try{const l=await nt();return W=l,t(l),s(!0),l}catch{return W=L,t(L),s(!1),L}finally{i(!1)}},[]);return h.useEffect(()=>{o()},[o]),{pets:e,loading:a,available:n,refresh:o}}const w=64,ut={egg:[.8369,.8424,.8497,.8585,.8674,.8775,.8878,.8983,.9089,.9185,.9288,.9374,.9445,.9504,.9543,.9559,.9555,.9519,.9466,.9389,.9302,.9193,.9085,.8969,.8852,.8734,.8625,.8513,.8411,.8325,.8243,.8179,.8137,.8112,.8102,.8128,.8178,.8262,.8374,.8518,.8702,.8922,.9169,.9446,.9741,1.0023,1.0267,1.0433,1.0481,1.0393,1.0216,.997,.9697,.9418,.9169,.8949,.876,.8604,.849,.8394,.8337,.8314,.8305,.8326],hexagon:[.921,.9282,.9441,.9706,.9984,1.0059,.9896,.9562,.929,.9124,.9047,.9058,.9157,.9349,.9642,.9873,.9882,.9665,.9336,.9105,.8968,.8918,.8955,.908,.9293,.9611,.982,.9812,.959,.9282,.9089,.8978,.8964,.9026,.9189,.9439,.9778,.999,.9964,.9713,.9439,.9274,.9196,.9206,.9308,.9502,.9799,1.0121,1.0226,1.0071,.9752,.951,.9366,.9316,.9351,.9485,.9711,1.0026,1.0213,1.0155,.9863,.9547,.9347,.9232],triangle:[.7819,.8211,.8747,.944,1.0223,1.096,1.1401,1.134,1.0808,1.0047,.9265,.8603,.8104,.773,.745,.7273,.7151,.7118,.7148,.7245,.7427,.768,.8037,.8518,.9148,.9876,1.0583,1.1073,1.1109,1.0667,.994,.9164,.8482,.7948,.7555,.7261,.7056,.6925,.6859,.6869,.6938,.7084,.7305,.7615,.804,.8595,.9311,1.0092,1.0791,1.1171,1.1054,1.0501,.9779,.905,.845,.799,.7656,.7413,.7258,.716,.7146,.7204,.733,.7528]},S=Math.PI*2,aa=(e,t=0,a=1)=>e<t?t:e>a?a:e,$=(e,t,a)=>e+(t-e)*a,ra={easeOutCubic:e=>1-(1-e)**3,easeInOutCubic:e=>e<.5?4*e**3:1-(-2*e+2)**3/2,easeOutQuint:e=>1-(1-e)**5};function ia(e,t,a=0){const i=e/t*S;return .55*Math.sin(i+a)+.3*Math.sin(2*i+a*1.7+1.1)+.15*Math.sin(3*i+a*2.3+2.4)}function na(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let a=Math.imul(t^t>>>15,1|t);return a=a+Math.imul(a^a>>>7,61|a)^a,((a^a>>>14)>>>0)/4294967296}}const x=e=>Math.round(e*100)/100,ee=Array.from({length:w},(e,t)=>t/w*S),U=ee.map(Math.cos),F=ee.map(Math.sin);function sa(e,t={}){return{radii:[...ut[e]],rot:0,cx:0,cy:0,sx:1,sy:1,...t}}function oa(e,t={}){return{radii:new Array(w).fill(e),rot:0,cx:0,cy:0,sx:1,sy:1,...t}}function la(e,t,a,i){const n=i??{radii:new Array(w),rot:0,cx:0,cy:0,sx:1,sy:1};for(let o=0;o<w;o++)n.radii[o]=$(e.radii[o]??1,t.radii[o]??1,a);let s=t.rot-e.rot;for(;s>Math.PI;)s-=S;for(;s<-Math.PI;)s+=S;return n.rot=e.rot+s*a,n.cx=$(e.cx,t.cx,a),n.cy=$(e.cy,t.cy,a),n.sx=$(e.sx,t.sx,a),n.sy=$(e.sy,t.sy,a),n}function ca(e,t,a=[]){const i=Math.cos(e.rot),n=Math.sin(e.rot);for(let s=0;s<w;s++){const o=e.radii[s]??1,l=o*(U[s]??0),c=o*(F[s]??0),d=l*i-c*n,g=l*n+c*i,p=a[s]??{x:0,y:0};p.x=(d*e.sx+e.cx)*t,p.y=(g*e.sy+e.cy)*t,a[s]=p}return a.length=w,a}function da(e,t=1/6){const a=e.length;if(a<3)return"";const i=e[0];let n=`M${x(i.x)} ${x(i.y)}`;for(let s=0;s<a;s++){const o=e[(s-1+a)%a],l=e[s],c=e[(s+1)%a],d=e[(s+2)%a],g=l.x+(c.x-o.x)*t,p=l.y+(c.y-o.y)*t,f=c.x-(d.x-l.x)*t,b=c.y-(d.y-l.y)*t;n+=`C${x(g)} ${x(p)} ${x(f)} ${x(b)} ${x(c.x)} ${x(c.y)}`}return`${n}Z`}function te(e,t,a){const i=new Array(w).fill(0),n=e.length;for(let s=0;s<w;s++){const o=U[s]??0,l=F[s]??0;let c=0;for(let d=0;d<n;d++){const g=e[d],p=e[(d+1)%n],f=p.x-g.x,b=p.y-g.y,y=o*b-l*f;if(Math.abs(y)<1e-9)continue;const C=g.x-t,N=g.y-a,v=(C*b-N*f)/y,M=(C*l-N*o)/y;v>c&&M>=0&&M<=1&&(c=v)}i[s]=c}return i}function ye(e,t,a,i,n,s,o=96){const l=i-e,c=n-t,d=Math.hypot(l,c)||1e-6,g=Math.atan2(c,l),p=Math.acos(Math.max(-1,Math.min(1,(a-s)/d))),f=[];for(let b=0;b<=o/2;b++){const y=g+p+(S-2*p)*b/(o/2);f.push({x:e+Math.cos(y)*a,y:t+Math.sin(y)*a})}for(let b=0;b<=o/2;b++){const y=g-p+2*p*b/(o/2);f.push({x:i+Math.cos(y)*s,y:n+Math.sin(y)*s})}return f}function ua(e,t){const a=e.length,i=(t/S%1+1)%1*a,n=Math.floor(i);return $(e[n%a]??1,e[(n+1)%a]??1,i-n)}function gt(e,t=1,a=1){return ee.map((i,n)=>{const s=Math.abs((U[n]??0)/t)**e,o=Math.abs((F[n]??0)/a)**e;return(s+o)**(-1/e)})}function pt(e){const t=new Array(w).fill(0);for(let a=0;a<w;a++){const i=U[a]??0,n=F[a]??0;let s=0;for(const o of e){const l=i*o.x+n*o.y,c=l*l-(o.x*o.x+o.y*o.y-o.r*o.r);if(c<0)continue;const d=l+Math.sqrt(c);d>s&&(s=d)}t[a]=s}return t}function mt(e,t,a=10){const i=e.length,n=[],s=(o,l)=>{const c=l.x-o.x,d=l.y-o.y,g=Math.hypot(c,d)||1;return Math.atan2(-c/g,d/g)};for(let o=0;o<i;o++){const l=e[(o-1+i)%i],c=e[o],d=e[(o+1)%i],g=s(l,c);let f=s(c,d)-g;for(;f>Math.PI;)f-=S;for(;f<-Math.PI;)f+=S;for(let b=0;b<=a;b++){const y=g+f*b/a;n.push({x:c.x+Math.cos(y)*t,y:c.y+Math.sin(y)*t})}}return n}function le(e,t,a,i=0){const n=i*Math.PI/180,s=Array.from({length:e},(o,l)=>{const c=n+l/e*S;return{x:Math.cos(c)*(t-a),y:Math.sin(c)*(t-a)}});return te(mt(s,a),0,0)}function ga(e,t=1){if(e.length<3)return"";let a="";for(let i=0;i<e.length;i++){const n=e[i];a+=`${i===0?"M":"L"}${x(n.x*t)} ${x(n.y*t)}`}return`${a}Z`}function pa(e,t){const a=Math.max(e,.01)/2,i=Math.max(t,.01)/2,n=Math.min(a,i);return`M${x(-a)} ${x(-i+n)}A${x(n)} ${x(n)} 0 0 1 ${x(-a+n)} ${x(-i)}L${x(a-n)} ${x(-i)}A${x(n)} ${x(n)} 0 0 1 ${x(a)} ${x(-i+n)}L${x(a)} ${x(i-n)}A${x(n)} ${x(n)} 0 0 1 ${x(a-n)} ${x(i)}L${x(-a+n)} ${x(i)}A${x(n)} ${x(n)} 0 0 1 ${x(-a)} ${x(i-n)}Z`}function K(e,t=1){const a=Math.max(...e);if(a<=0)return e;const i=t/a;return e.map(n=>n*i)}const ht=Array.from({length:w},(e,t)=>t/w*Math.PI*2),xt=K(ht.map(e=>1+.075*Math.cos(2*e+.5)+.035*Math.cos(3*e+2.1)),1.02),ft=K(pt([{x:-.44,y:.2,r:.54},{x:.46,y:.2,r:.5},{x:.02,y:.3,r:.6},{x:-.24,y:-.3,r:.48},{x:.3,y:-.24,r:.44}]),1.02),bt=K(te(ye(0,.28,.66,0,-.96,.05),0,0),1.04),yt=te(ye(-.42,0,.62,.42,0,.62),0,0),wt=[{id:"cercle",radii:new Array(w).fill(1)},{id:"galet",radii:xt},{id:"squircle",radii:K(gt(4.2),1.15)},{id:"capsule",radii:yt},{id:"triangle",radii:le(3,1.12,.34,-90)},{id:"hexagone",radii:le(6,1.04,.26,0)},{id:"nuage",radii:ft},{id:"goutte",radii:bt}],ma=new Map(wt.map(e=>[e.id,e])),kt=[{id:"encre",hex:"#0a0a0c"},{id:"brun",hex:"#8b5e3c"},{id:"rouge",hex:"#e8483f"},{id:"orange",hex:"#f08a24"},{id:"ambre",hex:"#f0b429"},{id:"vert",hex:"#3ecf8e"},{id:"turquoise",hex:"#2fbfa0"},{id:"bleu",hex:"#3b93f0"},{id:"violet",hex:"#8b5cf6"},{id:"rose",hex:"#e152b0"},{id:"gris",hex:"#a3a3a3"},{id:"creme",hex:"#f1efe9"}],G=new Map(kt.map(e=>[e.id,e]));function ha(e,t,a){const i=l=>{const c=parseInt(l.slice(1),16);return[c>>16&255,c>>8&255,c&255]},n=i(e),s=i(t);return`#${n.map((l,c)=>Math.round(l+(s[c]-l)*a)).map(l=>l.toString(16).padStart(2,"0")).join("")}`}const vt=.84,jt=1.35,Nt=Object.assign(Object.create(null),{clawd:vt,bot:jt});function ce(e){return Nt[T(e)]??1}const St={idle:{row:0,durations:[280,110,110,140,140,320]},"running-right":{row:1,durations:[120,120,120,120,120,120,120,220]},"running-left":{row:2,durations:[120,120,120,120,120,120,120,220]},waving:{row:3,durations:[140,140,140,280]},jumping:{row:4,durations:[140,140,140,140,280]},failed:{row:5,durations:[140,140,140,140,140,140,140,240]},waiting:{row:6,durations:[150,150,150,150,150,260]},running:{row:7,durations:[120,120,120,120,120,220]},review:{row:8,durations:[150,150,150,150,150,280]}};function Mt(e){return["error","disconnected","working-overheated"].includes(e)?"failed":["happy","waking","mini-happy","jumping"].includes(e)?"jumping":["working-typing","working-ultrathink","working-juggling","running"].includes(e)?"running":["working-thinking","working-wizard","review"].includes(e)?"review":["sleeping","idle-doze","mini-sleep","waiting"].includes(e)?"waiting":["mini-peek","waving"].includes(e)?"waving":e==="running-left"||e==="running-right"?e:"idle"}function Ct(){const[e,t]=h.useState(()=>typeof document>"u"?!0:document.visibilityState!=="hidden");return h.useEffect(()=>{if(typeof document>"u")return;const a=()=>t(document.visibilityState!=="hidden");return document.addEventListener("visibilitychange",a),()=>document.removeEventListener("visibilitychange",a)},[]),e}function Pt(){const[e,t]=h.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return h.useEffect(()=>{if(typeof window.matchMedia!="function")return;const a=window.matchMedia("(prefers-reduced-motion: reduce)"),i=n=>t(n.matches);return a.addEventListener("change",i),()=>a.removeEventListener("change",i)},[]),e}function At({character:e,pet:t=null,state:a="idle-living",dragState:i=null,size:n=48,className:s="",lookDirectionIndex:o=null}){const l=T(e),c=i==="running-left"||i==="running-right"?i:Mt(a),d=St[c],g=t?.spriteVersionNumber===2?2:1,p=g===2?11:9,f=g===2&&c==="idle"&&Number.isInteger(o)?(o%16+16)%16:null,b=f==null?d.row:9+Math.floor(f/8),y=f==null?null:f%8,C=Pt(),N=Ct(),[v,M]=h.useState(0);h.useEffect(()=>{if(M(0),C||!N||f!=null)return;let P=!1,z=0;const E=_=>{z=window.setTimeout(()=>{if(P)return;const R=(_+1)%d.durations.length;M(R),E(R)},d.durations[_])};return E(0),()=>{P=!0,window.clearTimeout(z)}},[f,C,N,d]);const H=h.useMemo(()=>({width:n*(192/208),height:n,backgroundImage:`url(${t?.assetUrl||`/pets/${l}/spritesheet.webp`})`,backgroundRepeat:"no-repeat",backgroundSize:`800% ${p*100}%`,backgroundPosition:`${(y??v)/7*100}% ${b/(p-1)*100}%`,imageRendering:"pixelated"}),[p,y,b,v,l,t?.assetUrl,n]);return r.jsx("div",{"aria-hidden":"true",className:`pet-atlas-animated ${s}`,style:H})}const $t=h.lazy(()=>_e(()=>import("./BotAnimated-BWy2-z4Q.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])).then(e=>({default:e.BotAnimated}))),de={"idle-living":"idle/living.svg","idle-doze":"idle/doze.svg","idle-follow":"idle/follow.svg","idle-look":"idle/look.svg","idle-yawn":"idle/yawn.svg","idle-collapse":"idle/collapse.svg","working-building":"working/building.svg","working-carrying":"working/carrying.svg","working-conducting":"working/conducting.svg","working-confused":"working/confused.svg","working-debugger":"working/debugger.svg","working-juggling":"working/juggling.svg","working-overheated":"working/overheated.svg","working-pushing":"working/pushing.svg","working-sweeping":"working/sweeping.svg","working-thinking":"working/thinking.svg","working-typing":"working/typing.svg","working-ultrathink":"working/ultrathink.svg","working-wizard":"working/wizard.svg","mini-alert":"mini/alert.svg","mini-crabwalk":"mini/crabwalk.svg","mini-enter":"mini/enter.svg","mini-enter-sleep":"mini/enter-sleep.svg","mini-happy":"mini/happy.svg","mini-idle":"mini/idle.svg","mini-peek":"mini/peek.svg","mini-sleep":"mini/sleep.svg","react-double":"react/double.svg","react-drag":"react/drag.svg","react-left":"react/left.svg","react-right":"react/right.svg","collapse-sleep":"sleep/collapse-sleep.svg",sleeping:"sleep/sleeping.svg",wake:"sleep/wake.svg",disconnected:"status/disconnected.svg",error:"status/error.svg",notification:"status/notification.svg",happy:"happy.svg","static-base":"static-base.svg"},X=new Map;async function Et(e){if(X.has(e))return X.get(e);if(typeof fetch!="function")return null;let t;try{t=await fetch(`/clawd/${e}`)}catch{return null}if(!t.ok)return null;const i=(await t.text()).replace(/<svg([^>]*)>/,(n,s)=>`<svg${s.replace(/\s+width="[^"]*"/g,"").replace(/\s+height="[^"]*"/g,"")} width="100%" height="100%">`);return X.set(e,i),i}function _t({state:e="idle-living",size:t=48,className:a=""}){const[i,n]=h.useState(""),s=h.useRef(null),l=It()?"static-base":e,c=de[l]||de["static-base"];return h.useEffect(()=>{let d=!1;return Et(c).then(g=>{!d&&g&&n(g)}),()=>{d=!0}},[c]),h.useEffect(()=>{const d=s.current?.querySelector("svg");if(d)try{const g=d.getBBox();g.width>0&&g.height>0&&d.setAttribute("viewBox",`${g.x-2} ${g.y-2} ${g.width+4} ${g.height+4}`)}catch{}},[i]),r.jsx("div",{ref:s,"aria-hidden":"true",className:`clawd-animated ${a}`,style:{width:t,height:t,display:"inline-flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},dangerouslySetInnerHTML:{__html:i}})}function we({state:e="idle-living",size:t=48,className:a="",character:i="clawd",pet:n=null,lookDirectionIndex:s=null,botColor:o="auto"}){const l=T(i),c=be(l);return c==="vector"?r.jsx(h.Suspense,{fallback:r.jsx("span",{"aria-hidden":"true",style:{width:t,height:t,display:"inline-block"}}),children:r.jsx($t,{state:e,size:t*ce(l),className:a,color:o})}):c==="atlas"?r.jsx(At,{character:l,pet:n,state:e,size:t,className:a,lookDirectionIndex:s}):r.jsx(_t,{state:e,size:t*ce(l),className:a})}function It(){const[e,t]=h.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return h.useEffect(()=>{if(typeof window.matchMedia!="function")return;const a=window.matchMedia("(prefers-reduced-motion: reduce)"),i=n=>t(n.matches);return a.addEventListener("change",i),()=>a.removeEventListener("change",i)},[]),e}const Lt={clawd:"from-oai-amber-50 dark:from-orange-950/70",bot:"from-oai-brand-50 dark:from-teal-950/70",sprout:"from-oai-brand-100 dark:from-emerald-950/70",byte:"from-oai-gray-200 dark:from-slate-800/70",ember:"from-orange-100 dark:from-orange-950/80"};function Ot(){const e=u("pet.import.subtitle"),t="codex-pets.net",a=e.indexOf(t);return a<0?e:r.jsxs(r.Fragment,{children:[e.slice(0,a),r.jsx("a",{href:"https://codex-pets.net",target:"_blank",rel:"noreferrer",className:"underline decoration-oai-gray-400 underline-offset-2 transition-colors hover:text-oai-black dark:decoration-oai-gray-500 dark:hover:text-white",children:t}),e.slice(a+t.length)]})}const O=[{id:"idle-living",labelKey:"pet.state.calm"},{id:"working-thinking",labelKey:"pet.state.focus"},{id:"working-juggling",labelKey:"pet.state.multitask"},{id:"working-wizard",labelKey:"pet.state.streak"},{id:"happy",labelKey:"pet.state.celebrate"},{id:"sleeping",labelKey:"pet.state.rest"}];function ke({character:e,selected:t,onSelect:a,onRemove:i,removeDisabled:n}){const s=e.nameKey?u(e.nameKey):e.displayName;return r.jsxs("div",{className:"group relative",children:[r.jsxs("button",{type:"button",onClick:a,"aria-pressed":t,className:j("relative w-full overflow-hidden rounded-xl border p-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",t?"border-oai-brand-500/40 bg-white dark:border-oai-brand-500/25 dark:bg-oai-gray-900/80":"border-oai-gray-200/80 bg-white/55 hover:border-oai-gray-400 dark:border-oai-gray-800 dark:bg-oai-gray-950/55 dark:hover:border-oai-gray-600"),children:[r.jsx("div",{className:j("absolute inset-0 bg-gradient-to-br to-transparent opacity-80 dark:opacity-55",Lt[e.id]||"from-oai-gray-200/80 dark:from-oai-gray-800/70")}),r.jsxs("div",{className:"relative flex items-center gap-2.5",children:[r.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center",children:r.jsx(we,{state:"idle-living",character:e.id,pet:e,size:44})}),r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"truncate text-sm font-semibold text-oai-black dark:text-white",children:s}),e.spriteVersionNumber===2?r.jsx("span",{className:"shrink-0 rounded border border-oai-gray-300/80 px-1 text-[9px] font-semibold text-oai-gray-500 dark:border-oai-gray-600 dark:text-oai-gray-400",children:u("pet.format.v2")}):null,t?r.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-oai-brand-500","aria-hidden":!0}):null]})]})]}),i?r.jsx("button",{type:"button",disabled:n,onClick:i,"aria-label":`${u("pet.import.remove")} · ${s}`,className:j("absolute right-1.5 top-1.5 flex h-6 w-6 items-center justify-center rounded-md border border-oai-gray-200/90 bg-white/95 text-oai-gray-500 transition-opacity hover:text-red-600 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-40 dark:border-oai-gray-700 dark:bg-oai-gray-900/95 dark:text-oai-gray-400 dark:hover:text-red-400","opacity-0 group-hover:opacity-100"),children:r.jsx(De,{className:"h-3 w-3","aria-hidden":!0})}):null]})}function Tt({value:e,onChange:t}){const a={auto:u("pet.bot.color.auto"),bleu:u("pet.bot.color.bleu"),turquoise:u("pet.bot.color.turquoise"),vert:u("pet.bot.color.vert"),ambre:u("pet.bot.color.ambre"),rose:u("pet.bot.color.rose"),violet:u("pet.bot.color.violet")};return r.jsx("div",{className:"flex flex-wrap items-center justify-end gap-1.5 rounded-full border border-black/5 bg-white/65 px-2.5 py-1.5 backdrop-blur-md dark:border-white/10 dark:bg-black/20",role:"radiogroup","aria-label":u("pet.bot.color"),children:J.map(i=>{const n=(e||"auto")===i;return r.jsx("button",{type:"button",role:"radio","aria-checked":n,"aria-label":a[i],title:a[i],onClick:()=>t(i),className:j("h-4 w-4 rounded-full border transition-transform duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",n?"scale-125 border-oai-black shadow-sm dark:border-white":"border-black/15 hover:scale-110 dark:border-white/25"),style:i==="auto"?{background:`linear-gradient(135deg, ${G.get(xe).hex} 0 50%, ${G.get(fe).hex} 50% 100%)`}:{background:G.get(i)?.hex}},i)})})}function zt({pet:e,state:t,onStateChange:a,botColor:i,onBotColorChange:n}){const[s,o]=h.useState(null),l=h.useRef(null),c=O.find(function(p){return p.id===t}),d=u(c?.labelKey||"pet.state.calm");return r.jsxs("section",{className:"relative flex min-h-[400px] flex-col overflow-hidden bg-oai-gray-50 dark:bg-oai-gray-950 sm:min-h-[440px] lg:min-h-[480px]",onPointerMove:g=>{if(e?.spriteVersionNumber!==2||!l.current)return;const p=l.current.getBoundingClientRect(),f=g.clientX-(p.left+p.width/2),b=g.clientY-(p.top+p.height/2),y=(Math.atan2(f,-b)*180/Math.PI+360)%360;o(Math.round(y/22.5)%16)},onPointerLeave:()=>o(null),children:[r.jsx("div",{className:"absolute inset-0 opacity-[0.16] dark:opacity-[0.12]",style:{backgroundImage:"radial-gradient(currentColor 0.7px, transparent 0.7px)",backgroundSize:"14px 14px"},"aria-hidden":!0}),r.jsxs("div",{className:"relative flex items-center justify-between gap-3 px-5 pt-5",children:[r.jsx("span",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-oai-gray-500 dark:text-oai-gray-400",children:u("pet.preview.states")}),r.jsxs("div",{className:"flex items-center gap-2",children:[be(e?.id)==="vector"?r.jsx(Tt,{value:i,onChange:n}):null,r.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-black/5 bg-white/65 px-3 py-1.5 text-[11px] font-medium text-oai-gray-600 backdrop-blur-md dark:border-white/10 dark:bg-black/20 dark:text-oai-gray-300",children:[r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500","aria-hidden":!0}),d]})]})]}),r.jsx("div",{className:"relative flex flex-1 items-center justify-center px-6 py-5",children:r.jsx("div",{ref:l,className:"relative flex h-52 w-52 items-center justify-center sm:h-56 sm:w-56 lg:h-64 lg:w-64",children:r.jsx("div",{className:"origin-bottom lg:scale-[1.18]",children:r.jsx(we,{state:t,character:e?.id||"clawd",pet:e,size:190,lookDirectionIndex:s,botColor:i})})})}),r.jsx("div",{className:"relative border-t border-oai-gray-200/70 bg-white/85 px-3 py-2 dark:border-oai-gray-800 dark:bg-oai-gray-950/85",children:r.jsx("div",{className:"grid grid-cols-3 gap-1","aria-label":u("pet.preview.states"),children:O.map(g=>r.jsxs("button",{type:"button",onClick:()=>a(g.id),"aria-pressed":t===g.id,className:j("flex min-h-10 flex-col items-center justify-center gap-1 rounded-lg px-1.5 text-xs transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500",t===g.id?"font-semibold text-oai-black dark:text-white":"font-medium text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:[r.jsx("span",{children:u(g.labelKey)}),r.jsx("span",{className:j("h-1 w-1 rounded-full transition-colors duration-200",t===g.id?"bg-oai-black dark:bg-white":"bg-transparent"),"aria-hidden":!0})]},g.id))})})]})}function Rt({pets:e,busy:t,error:a,onImport:i,onClose:n}){const[s,o]=h.useState(()=>new Set),l=d=>o(g=>{const p=new Set(g);return p.has(d)?p.delete(d):p.add(d),p}),c=e.length!==0&&s.size===e.length;return r.jsx(Ve,{open:!0,onOpenChange:d=>{!d&&!t&&n()},children:r.jsxs(Ue,{children:[r.jsx(Fe,{className:"fixed inset-0 z-50 bg-black/15 backdrop-blur-md dark:bg-black/40 animate-tt-fade-in"}),r.jsx(Ke,{className:"fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6",children:r.jsxs(He,{className:"relative flex max-h-[86vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-oai-gray-200/50 bg-white/95 shadow-2xl backdrop-blur-2xl dark:border-white/10 dark:bg-oai-gray-900/95 animate-tt-modal",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-oai-gray-200/70 px-5 py-4 dark:border-oai-gray-800",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx(qe,{className:"text-base font-semibold",children:u("pet.codex.title")}),r.jsx(Ze,{className:"mt-0.5 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:u("pet.codex.subtitle")})]}),r.jsx(We,{type:"button",disabled:t,"aria-label":u("pet.codex.close"),className:"shrink-0 rounded-full border border-oai-gray-200/60 p-1.5 text-oai-gray-500 transition-colors hover:text-oai-black disabled:opacity-40 dark:border-oai-gray-800/60 dark:text-oai-gray-400 dark:hover:text-white",children:r.jsx(Le,{size:16})})]}),r.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:[e.length===0?r.jsx("p",{className:"py-8 text-center text-sm text-oai-gray-400 dark:text-oai-gray-500",children:u("pet.codex.empty")}):r.jsx("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-3",children:e.map(d=>r.jsx(ke,{character:d,selected:s.has(d.id),onSelect:()=>l(d.id)},d.id))}),a?r.jsx("p",{role:"alert",className:"mt-3 text-xs text-red-600 dark:text-red-400",children:a}):null]}),r.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-oai-gray-200/70 px-5 py-3 dark:border-oai-gray-800",children:[r.jsx("button",{type:"button",disabled:t||e.length===0,onClick:()=>o(c?new Set:new Set(e.map(d=>d.id))),className:"text-xs font-medium text-oai-gray-500 underline-offset-2 hover:underline disabled:opacity-40 dark:text-oai-gray-400",children:u("pet.codex.select_all")}),r.jsxs("button",{type:"button",disabled:t||s.size===0,onClick:()=>i([...s]),className:"flex h-9 items-center gap-1.5 rounded-lg bg-oai-black px-4 text-xs font-semibold text-white transition-colors disabled:bg-oai-gray-200 disabled:text-oai-gray-400 dark:bg-white dark:text-black dark:disabled:bg-oai-gray-800 dark:disabled:text-oai-gray-500",children:[t?r.jsx(ge,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,s.size>0?`${u("pet.codex.import")} · ${s.size}`:u("pet.codex.import")]})]})]})})]})})}function Bt(){const{available:e,settings:t,setSetting:a}=it(),{pets:i,loading:n,available:s,refresh:o}=dt(),[l,c]=h.useState(""),[d,g]=h.useState(""),[p,f]=h.useState(!1),[b,y]=h.useState([]),[C,N]=h.useState(!1),[v,M]=h.useState(!1),[H,P]=h.useState(""),[z,E]=h.useState("idle-living"),[_,R]=h.useState(!0),I=t.character||"clawd",q=ze(),ae=q.settings?.menuBarIconStyle==="pet",ve=i.find(m=>m.id===I)||i[0],B=p?{kind:"busy",text:u("pet.import.busy")}:d?{kind:"error",text:d}:null,re=b.length!==0;h.useEffect(()=>{!n&&i.length>0&&!i.some(m=>m.id===I)&&a("character","clawd")},[n,i,I,a]);async function D(m,k=u("pet.import.success")){f(!0),g("");try{const A=await m();await o(),Ie(),A?.pet?.id&&a("character",A.pet.id),ie({title:k,timeout:4e3}),c("")}catch(A){g(A?.message||u("pet.import.failed"))}finally{f(!1)}}const Z=h.useCallback(async()=>{if(!s){y([]);return}try{const m=await lt();y(m.importable)}catch{y([])}},[s]);h.useEffect(()=>{Z()},[Z]);async function je(m){M(!0),P("");try{return await ct(m),await o(),await Z(),ie({title:u("pet.codex.imported"),timeout:4e3}),!0}catch(k){return P(k?.message||u("pet.import.failed")),!1}finally{M(!1)}}h.useEffect(()=>{if(!_)return;const m=window.setInterval(()=>{E(k=>{const A=O.findIndex(Se=>Se.id===k);return O[(A+1)%O.length].id})},5e3);return()=>window.clearInterval(m)},[_]);const Ne=[{value:"small",label:u("pet.size.small")},{value:"medium",label:u("pet.size.medium")},{value:"large",label:u("pet.size.large")}];return r.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:r.jsx("main",{className:"flex-1 pb-14 pt-8 sm:pt-10",children:r.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[r.jsx(se,{y:12,children:r.jsxs("header",{className:"mb-8",children:[r.jsx("h1",{className:"text-3xl font-semibold tracking-tight sm:text-4xl",children:u("pet.page.title")}),r.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:u("pet.page.subtitle")})]})}),r.jsx(se,{y:12,delay:.04,children:r.jsxs("div",{className:"overflow-hidden rounded-[28px] border border-oai-gray-200 bg-white/75 dark:border-oai-gray-800 dark:bg-oai-gray-900/60 lg:grid lg:grid-cols-[1.12fr_0.88fr]",children:[r.jsx(zt,{pet:ve,state:z,onStateChange:m=>{R(!1),E(m)},botColor:t.botColor,onBotColorChange:m=>a("botColor",m)}),r.jsxs("aside",{className:"flex flex-col border-t border-oai-gray-200 p-5 dark:border-oai-gray-800 lg:min-h-[480px] lg:border-l lg:border-t-0",children:[r.jsxs("section",{"aria-labelledby":"pet-character-title",children:[r.jsxs("div",{children:[r.jsx("h2",{id:"pet-character-title",className:"text-sm font-semibold",children:u("pet.characters.title")}),r.jsx("p",{className:"mt-1 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:u("pet.characters.subtitle")})]}),r.jsx("div",{className:"mt-4 grid max-h-72 grid-cols-2 gap-2 overflow-y-auto pr-1 -mr-1",children:i.map(m=>r.jsx(ke,{character:m,selected:I===m.id,onSelect:()=>a("character",m.id),removeDisabled:p,onRemove:s&&m.id!=="clawd"&&m.id!=="bot"?()=>D(async()=>(await ot(m.id),I===m.id&&a("character","clawd"),null),u("pet.import.removed")):void 0},m.id))}),q.available?r.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 rounded-xl border border-oai-gray-200/70 bg-oai-gray-50/60 px-3 py-2.5 dark:border-oai-gray-800 dark:bg-oai-gray-900/40",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"text-xs font-semibold",children:u("pet.menubar.title")}),r.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:u("pet.menubar.hint")})]}),r.jsx(ne,{checked:ae,onChange:()=>q.setSetting("menuBarIconStyle",ae?"clawd":"pet"),ariaLabel:u("pet.menubar.title")})]}):null]}),s?r.jsxs("section",{className:"mt-6 border-t border-oai-gray-200/70 pt-5 dark:border-oai-gray-800","aria-labelledby":"pet-import-title",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ye,{className:"h-4 w-4 shrink-0 text-oai-gray-500","aria-hidden":!0}),r.jsx("h2",{id:"pet-import-title",className:"text-sm font-semibold",children:u("pet.import.title")})]}),r.jsx("p",{className:"mt-1 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r.jsx(Ot,{})}),r.jsxs("form",{className:"mt-3 flex gap-2",onSubmit:m=>{m.preventDefault(),!p&&l.trim()&&D(()=>st(l))},children:[r.jsxs("label",{className:"relative flex min-w-0 flex-1 items-center",children:[r.jsx(Re,{className:"pointer-events-none absolute left-3 h-3.5 w-3.5 text-oai-gray-400","aria-hidden":!0}),r.jsx("input",{value:l,onChange:m=>c(m.target.value),"aria-label":u("pet.import.url_label"),placeholder:"codex-pets.net/#/pets/…",className:"h-9 w-full rounded-lg border border-oai-gray-200 bg-white pl-9 pr-3 text-xs outline-none focus:border-oai-brand-500 dark:border-oai-gray-700 dark:bg-oai-gray-950"})]}),r.jsxs("button",{type:"submit",disabled:p||!l.trim(),className:"flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-oai-black px-3.5 text-xs font-semibold text-white transition-colors disabled:bg-oai-gray-200 disabled:text-oai-gray-400 dark:bg-white dark:text-black dark:disabled:bg-oai-gray-800 dark:disabled:text-oai-gray-500",children:[p?r.jsx(ge,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,u("pet.import.add")]})]}),r.jsxs("div",{className:j("mt-2 grid gap-2",re?"grid-cols-2":"grid-cols-1"),children:[re?r.jsxs("button",{type:"button",disabled:p||v,onClick:()=>{P(""),N(!0)},className:j("flex h-9 cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-dashed border-oai-gray-300 text-xs font-medium text-oai-gray-500 transition-colors hover:border-oai-gray-500 hover:text-oai-black dark:border-oai-gray-600 dark:text-oai-gray-400 dark:hover:border-oai-gray-400 dark:hover:text-white",(p||v)&&"pointer-events-none opacity-40"),children:[r.jsx(Te,{provider:"codex",size:14,className:"fill-current"}),u("pet.codex.browse")]}):null,r.jsxs("label",{onDragOver:m=>m.preventDefault(),onDrop:m=>{if(m.preventDefault(),p)return;const k=m.dataTransfer?.files?.[0];k&&D(()=>oe(k))},className:j("flex h-9 cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-dashed border-oai-gray-300 text-xs font-medium text-oai-gray-500 transition-colors hover:border-oai-gray-500 hover:text-oai-black dark:border-oai-gray-600 dark:text-oai-gray-400 dark:hover:border-oai-gray-400 dark:hover:text-white",p&&"pointer-events-none opacity-40"),children:[r.jsx(Ge,{className:"h-3.5 w-3.5","aria-hidden":!0}),u("pet.import.zip"),r.jsx("input",{type:"file",accept:".zip,.codex-pet.zip,application/zip",className:"sr-only",disabled:p,onChange:m=>{const k=m.target.files?.[0];k&&D(()=>oe(k)),m.target.value=""}})]})]}),B?r.jsx("p",{role:B.kind==="error"?"alert":"status",className:j("mt-2 text-xs",B.kind==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400"),children:B.text}):null,C?r.jsx(Rt,{pets:b,busy:v,error:H,onClose:()=>{v||N(!1)},onImport:async m=>{await je(m)&&N(!1)}}):null]}):null,r.jsxs("section",{className:"mt-6 border-t border-oai-gray-200/70 pt-5 dark:border-oai-gray-800",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Xe,{className:"h-4 w-4 text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75,"aria-hidden":!0}),r.jsx("h2",{className:"text-sm font-semibold",children:u("pet.controls.title")})]}),r.jsxs("div",{className:"mt-4 space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsx("div",{className:"text-sm font-medium",children:u("pet.controls.show")}),r.jsx(ne,{checked:t.visible,onChange:()=>a("visible",!t.visible),disabled:!e,ariaLabel:u("pet.controls.show")})]}),r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsx("div",{className:"text-sm font-medium",children:u("pet.controls.size")}),r.jsx("div",{className:"shrink-0",children:r.jsx(Oe,{options:Ne,value:t.size,onChange:m=>a("size",m),disabled:!e})})]})]})]}),e?null:r.jsxs("div",{className:"mt-6 flex gap-2 rounded-xl bg-oai-gray-100 p-3 text-xs leading-relaxed text-oai-gray-500 dark:bg-oai-gray-800/70 dark:text-oai-gray-400",children:[r.jsx(Be,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),u("pet.controls.native_only")]})]})]})})]})})})}const xa=Object.freeze(Object.defineProperty({__proto__:null,PetPage:Bt},Symbol.toStringTag,{value:"Module"}));export{Jt as B,G as C,xa as P,wt as S,S as T,na as a,$ as b,aa as c,oa as d,ra as e,ga as f,ua as g,ye as h,da as i,pa as j,la as k,ia as l,ea as m,ma as n,Qt as o,te as p,ta as q,x as r,sa as s,ca as t,ha as u};
@@ -1 +1 @@
1
- import{r as a,bm as V,bn as re,b6 as X,bo as z,bp as ae,O as ie,bq as ce,ar as J,br as Q,a_ as ue,j as d,bs as le,N as W,bt as pe,bu as de,bv as ge,ba as fe,bw as me,bx as Pe,by as he,M as Ce,K as te,bz as Se,bA as $,bB as be,bC as Te,bD as ve,b1 as xe,bE as Re,b0 as Ie,bF as Ee,bG as Oe}from"./__vite-browser-external-CPskAZuH.js";import{p as ye,c as Fe}from"./store-DzNIKGzf.js";import{d as Me,e as ke,P as Ae,f as we,h as je,j as He,k as Be,l as Ge,m as Ne,n as _e,o as Le,u as Ke,p as Ue,q as De,t as Ve,r as qe,I as Ye,s as ze,v as Je,w as Qe,x as We,C as Xe,y as Ze}from"./composite-I_1t6PMI.js";import{k as $e,l as et,m as tt,n as ot}from"./SelectItemText-CZKyxUjE.js";import{u as nt,a as st,s as rt,b as at}from"./safePolygon-Yw5w5Nw8.js";import{u as it,a as ct,g as ut}from"./usePositioner-b6XXJtxE.js";const oe=a.createContext(void 0);function K(e){const o=a.useContext(oe);if(o===void 0&&!e)throw new Error(V(47));return o}const lt={...ye,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class pt extends re{constructor(o,t,i){const s=new Ae;super(dt(o,s,t,i),gt(s),lt)}setOpen=(o,t)=>{const i=t.reason===X,s=t.reason===z&&t.event.detail===0,g=!o&&(t.reason===ae||t.reason==null),l=Me(t),c=this.select("activeTriggerId");if(!o&&t.reason===ie&&t.trigger==null&&c!=null&&(t.trigger=this.context.triggerElements.getById(c)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(o,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(o,t);const f=()=>{const m=ke(this.state,o,t.trigger,l());m.openChangeReason=t.reason,this.update(m)};i?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(ce,()=>{this.set("stickIfOpen",!1)}),J.flushSync(f)):f();let n;s?n="click":g?n="dismiss":t.reason===Q&&(n="focus"),this.set("instantType",n)}}function dt(e,o,t,i=!1){const s={...Fe(o,t,i),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return s.open&&e?.mounted===void 0&&(s.mounted=!0),s}function gt(e){return{popupRef:a.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:a.createRef(),beforeContentFocusGuardRef:a.createRef(),stickIfOpenTimeout:new ue,triggerElements:e}}const ee=le(function({props:o}){const{children:t,open:i,defaultOpen:s=!1,onOpenChange:g,onOpenChangeComplete:l,modal:c=!1,handle:f,triggerId:n,defaultTriggerId:m=null}=o,r=ft(f,{modal:c,open:s,openProp:i,activeTriggerId:m,triggerIdProp:n});r.useControlledProp("openProp",i),r.useControlledProp("triggerIdProp",n);const P=r.useState("open"),I=r.useState("mounted"),b=r.useState("payload");r.useContextCallback("onOpenChange",g),r.useContextCallback("onOpenChangeComplete",l),je(r,P),He(r);const{forceUnmount:v}=Be(P,r,()=>{r.update({stickIfOpen:!0,openChangeReason:null})});r.useSyncedValues({modal:c}),a.useEffect(()=>{P||r.context.stickIfOpenTimeout.clear()},[r,P]),a.useImperativeHandle(o.actionsRef,()=>({unmount:v,close:()=>r.setOpen(!1,W(pe))}),[v,r]);const y=P||I;return d.jsxs(oe.Provider,{value:r,children:[f&&d.jsx(Ge,{handle:f,store:r}),y&&d.jsx(mt,{store:r,modal:c}),typeof t=="function"?t({payload:b}):t]})});function yt(e){return K(!0)?d.jsx(ee,{props:e}):d.jsx(we,{children:d.jsx(ee,{props:e})})}function ft(e,o){const t=Ne((i,s)=>new pt(o,i,s));return a.useEffect(()=>t.context.stickIfOpenTimeout.disposeEffect(),[t]),t}function mt({store:e,modal:o}){const t=e.useState("floatingRootContext"),i=_e(t,{outsidePressEvent:{mouse:o==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),s=i.reference,g=i.floating;return Le(e,{activeTriggerProps:s,inactiveTriggerProps:s,popupProps:g}),null}const Pt=300;function ht(e,o){const t=a.useRef(null);function i(g){J.flushSync(()=>{e.setOpen(!1,W(Q,g.nativeEvent,g.currentTarget))}),Pe(t.current)?.focus()}function s(g){const l=e.select("positionerElement");if(l&&de(g,l))e.context.beforeContentFocusGuardRef.current?.focus();else{J.flushSync(()=>{e.setOpen(!1,W(Q,g.nativeEvent,g.currentTarget))});let c=ge(e.context.triggerFocusTargetRef.current||o.current);for(;c!==null&&fe(l,c);){const f=c;if(c=me(c),c===f)break}c?.focus()}}return{preFocusGuardRef:t,handlePreFocusGuardFocus:i,handleFocusTargetFocus:s}}const Ft=he(function(o,t){const{render:i,className:s,style:g,disabled:l=!1,nativeButton:c=!0,handle:f,payload:n,openOnHover:m=!1,delay:r=Pt,closeDelay:P=0,id:I,...b}=o,v=K(!0),u=nt(f)??v;if(!u)throw new Error(V(74));const h=Ke(I),p=u.useState("isTriggerActive",h),F=u.useState("floatingRootContext"),E=u.useState("isOpenedByTrigger",h),M=u.useState("triggerPopupId",h),C=a.useRef(null),{registerTrigger:T,isMountedByThisTrigger:x}=Ue(h,C,u,{payload:n,disabled:l,openOnHover:m,closeDelay:P}),O=u.useState("openChangeReason"),B=u.useState("stickIfOpen"),G=u.useState("openMethod"),k=u.useState("focusManagerModal"),N=st(F,{enabled:!l&&m&&(G!=="touch"||O!==z),mouseOnly:!0,move:!1,handleClose:rt(),restMs:r,delay:{close:P},triggerElementRef:C,isActiveTrigger:p,isClosing:()=>u.select("transitionStatus")==="ending"}),A=$e(F,{stickIfOpen:B}),_=et(()=>u.select("open"),R=>{u.set("openMethod",R)}),w=u.useState("triggerProps",x),{getButtonProps:j,buttonRef:S}=Ce({disabled:l,native:c}),U={open(R){return R&&O===z?De.open(R):Ve.open(R)}},{preFocusGuardRef:D,handlePreFocusGuardFocus:q,handleFocusTargetFocus:Y}=ht(u,C),H=te("button",o,{state:{disabled:l,open:E},ref:[S,t,T,C],props:[A.reference,N,w,_,{[Se]:"",id:h,"aria-haspopup":"dialog","aria-expanded":E,"aria-controls":M},b,j],stateAttributesMapping:U}),L=d.jsx(a.Fragment,{children:H},h);return x&&!k?d.jsxs(a.Fragment,{children:[d.jsx($,{ref:D,onFocus:q}),L,d.jsx($,{ref:u.context.triggerFocusTargetRef,onFocus:Y})]}):L}),ne=a.createContext(void 0);function Ct(){const e=a.useContext(ne);if(e===void 0)throw new Error(V(45));return e}const Mt=a.forwardRef(function(o,t){const{keepMounted:i=!1,...s}=o;return K().useState("mounted")||i?d.jsx(ne.Provider,{value:i,children:d.jsx(be,{ref:t,...s})}):null}),se=a.createContext(void 0);function St(){const e=a.useContext(se);if(!e)throw new Error(V(46));return e}const kt=a.forwardRef(function(o,t){const{render:i,className:s,style:g,anchor:l,positionMethod:c,side:f,align:n,sideOffset:m,alignOffset:r,collisionBoundary:P="clipping-ancestors",collisionPadding:I,arrowPadding:b,sticky:v,disableAnchorTracking:y=!1,collisionAvoidance:u=Te,...h}=o,p=K(),F=Ct(),E=qe(),M=p.useState("floatingRootContext"),C=p.useState("mounted"),T=p.useState("open"),x=p.useState("openChangeReason"),O=p.useState("activeTriggerElement"),B=p.useState("modal"),G=p.useState("openMethod"),k=p.useState("positionerElement"),N=p.useState("instantType"),A=p.useState("transitionStatus"),_=p.useState("adaptiveOrigin"),w=a.useRef(null),j=ve(k),S=it({anchor:l,floatingRootContext:M,positionMethod:c,mounted:C,side:f,sideOffset:m,align:n,alignOffset:r,arrowPadding:b,collisionBoundary:P,collisionPadding:I,sticky:v,disableAnchorTracking:y,keepMounted:F,nodeId:E,collisionAvoidance:u,adaptiveOrigin:_}),U=M.useState("domReferenceElement");xe(()=>{const H=U,L=w.current;if(H&&(w.current=H),L&&H&&H!==L){p.set("instantType",void 0);const R=new AbortController;return j(()=>{p.set("instantType","trigger-change")},R.signal),()=>{R.abort()}}},[U,j,p]);const D=B===!0&&x!==X;tt(T&&D,G==="touch",k,O);const q=p.useStateSetter("positionerElement"),Y={open:T,side:S.side,align:S.align,anchorHidden:S.anchorHidden,instant:N},Z=ct(o,Y,{styles:S.positionerStyles,transitionStatus:A,props:h,refs:[t,q],hidden:!C,inert:!T});return d.jsxs(se.Provider,{value:S,children:[C&&D&&d.jsx(Ye,{inert:Re(!T),cutout:O}),d.jsx(ze,{id:E,children:Z})]})}),bt=a.createContext(void 0);function Tt(){const[e,o]=a.useState(0),t=Ie(()=>(o(s=>s+1),()=>{o(s=>Math.max(0,s-1))}));return{context:a.useMemo(()=>({register:t}),[t]),hasClosePart:e>0}}const At=a.forwardRef(function(o,t){const{render:i,className:s,style:g,initialFocus:l,finalFocus:c,...f}=o,n=K(),m=St(),r=ot()!=null,{context:P,hasClosePart:I}=Tt(),b=n.useState("open"),v=n.useState("openMethod"),y=n.useState("instantType"),u=n.useState("transitionStatus"),h=n.useState("popupProps"),p=n.useState("titleElementId"),F=n.useState("descriptionElementId"),E=n.useState("modal"),M=n.useState("mounted"),C=n.useState("openChangeReason"),T=n.useState("activeTriggerElement"),x=n.useState("floatingRootContext"),O=x.useState("floatingId"),B=n.useState("disabled"),G=n.useState("openOnHover"),k=n.useState("closeDelay");Ee({open:b,ref:n.context.popupRef,onComplete(){b&&n.context.onOpenChangeComplete?.(!0)}}),at(x,{enabled:G&&!B,closeDelay:k});const N=l===void 0?Je(n.context.popupRef):l,A=E!==!1&&I;n.useSyncedValue("focusManagerModal",A);const _=n.useStateSetter("popupElement"),w={open:b,side:m.side,align:m.align,instant:y,transitionStatus:u},j=te("div",o,{state:w,ref:[t,n.context.popupRef,_],props:[h,{id:O,role:"dialog",...We,"aria-labelledby":p,"aria-describedby":F,onKeyDown(S){r&&Xe.has(S.key)&&S.stopPropagation()}},ut(u),f],stateAttributesMapping:Ze});return d.jsx(Qe,{context:x,openInteractionType:v,modal:A,disabled:!M||C===X,initialFocus:N,returnFocus:c,restoreFocus:"popup",previousFocusableElement:Oe(T)?T:void 0,nextFocusableElement:n.context.triggerFocusTargetRef,beforeContentFocusGuardRef:n.context.beforeContentFocusGuardRef,children:d.jsx(bt.Provider,{value:P,children:j})})});export{yt as P,Ft as a,Mt as b,kt as c,At as d};
1
+ import{r as a,bm as V,bn as re,b6 as X,bo as z,bp as ae,O as ie,bq as ce,ar as J,br as Q,a_ as ue,j as d,bs as le,N as W,bt as pe,bu as de,bv as ge,ba as fe,bw as me,bx as Pe,by as he,M as Ce,K as te,bz as Se,bA as $,bB as be,bC as Te,bD as ve,b1 as xe,bE as Re,b0 as Ie,bF as Ee,bG as Oe}from"./__vite-browser-external-C7JgMYNl.js";import{p as ye,c as Fe}from"./store-CyOeiGFE.js";import{d as Me,e as ke,P as Ae,f as we,h as je,j as He,k as Be,l as Ge,m as Ne,n as _e,o as Le,u as Ke,p as Ue,q as De,t as Ve,r as qe,I as Ye,s as ze,v as Je,w as Qe,x as We,C as Xe,y as Ze}from"./composite-DObGcQmb.js";import{k as $e,l as et,m as tt,n as ot}from"./SelectItemText-Nis0uGZT.js";import{u as nt,a as st,s as rt,b as at}from"./safePolygon-CptquMWZ.js";import{u as it,a as ct,g as ut}from"./usePositioner-DhtQcPOC.js";const oe=a.createContext(void 0);function K(e){const o=a.useContext(oe);if(o===void 0&&!e)throw new Error(V(47));return o}const lt={...ye,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class pt extends re{constructor(o,t,i){const s=new Ae;super(dt(o,s,t,i),gt(s),lt)}setOpen=(o,t)=>{const i=t.reason===X,s=t.reason===z&&t.event.detail===0,g=!o&&(t.reason===ae||t.reason==null),l=Me(t),c=this.select("activeTriggerId");if(!o&&t.reason===ie&&t.trigger==null&&c!=null&&(t.trigger=this.context.triggerElements.getById(c)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(o,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(o,t);const f=()=>{const m=ke(this.state,o,t.trigger,l());m.openChangeReason=t.reason,this.update(m)};i?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(ce,()=>{this.set("stickIfOpen",!1)}),J.flushSync(f)):f();let n;s?n="click":g?n="dismiss":t.reason===Q&&(n="focus"),this.set("instantType",n)}}function dt(e,o,t,i=!1){const s={...Fe(o,t,i),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return s.open&&e?.mounted===void 0&&(s.mounted=!0),s}function gt(e){return{popupRef:a.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:a.createRef(),beforeContentFocusGuardRef:a.createRef(),stickIfOpenTimeout:new ue,triggerElements:e}}const ee=le(function({props:o}){const{children:t,open:i,defaultOpen:s=!1,onOpenChange:g,onOpenChangeComplete:l,modal:c=!1,handle:f,triggerId:n,defaultTriggerId:m=null}=o,r=ft(f,{modal:c,open:s,openProp:i,activeTriggerId:m,triggerIdProp:n});r.useControlledProp("openProp",i),r.useControlledProp("triggerIdProp",n);const P=r.useState("open"),I=r.useState("mounted"),b=r.useState("payload");r.useContextCallback("onOpenChange",g),r.useContextCallback("onOpenChangeComplete",l),je(r,P),He(r);const{forceUnmount:v}=Be(P,r,()=>{r.update({stickIfOpen:!0,openChangeReason:null})});r.useSyncedValues({modal:c}),a.useEffect(()=>{P||r.context.stickIfOpenTimeout.clear()},[r,P]),a.useImperativeHandle(o.actionsRef,()=>({unmount:v,close:()=>r.setOpen(!1,W(pe))}),[v,r]);const y=P||I;return d.jsxs(oe.Provider,{value:r,children:[f&&d.jsx(Ge,{handle:f,store:r}),y&&d.jsx(mt,{store:r,modal:c}),typeof t=="function"?t({payload:b}):t]})});function yt(e){return K(!0)?d.jsx(ee,{props:e}):d.jsx(we,{children:d.jsx(ee,{props:e})})}function ft(e,o){const t=Ne((i,s)=>new pt(o,i,s));return a.useEffect(()=>t.context.stickIfOpenTimeout.disposeEffect(),[t]),t}function mt({store:e,modal:o}){const t=e.useState("floatingRootContext"),i=_e(t,{outsidePressEvent:{mouse:o==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),s=i.reference,g=i.floating;return Le(e,{activeTriggerProps:s,inactiveTriggerProps:s,popupProps:g}),null}const Pt=300;function ht(e,o){const t=a.useRef(null);function i(g){J.flushSync(()=>{e.setOpen(!1,W(Q,g.nativeEvent,g.currentTarget))}),Pe(t.current)?.focus()}function s(g){const l=e.select("positionerElement");if(l&&de(g,l))e.context.beforeContentFocusGuardRef.current?.focus();else{J.flushSync(()=>{e.setOpen(!1,W(Q,g.nativeEvent,g.currentTarget))});let c=ge(e.context.triggerFocusTargetRef.current||o.current);for(;c!==null&&fe(l,c);){const f=c;if(c=me(c),c===f)break}c?.focus()}}return{preFocusGuardRef:t,handlePreFocusGuardFocus:i,handleFocusTargetFocus:s}}const Ft=he(function(o,t){const{render:i,className:s,style:g,disabled:l=!1,nativeButton:c=!0,handle:f,payload:n,openOnHover:m=!1,delay:r=Pt,closeDelay:P=0,id:I,...b}=o,v=K(!0),u=nt(f)??v;if(!u)throw new Error(V(74));const h=Ke(I),p=u.useState("isTriggerActive",h),F=u.useState("floatingRootContext"),E=u.useState("isOpenedByTrigger",h),M=u.useState("triggerPopupId",h),C=a.useRef(null),{registerTrigger:T,isMountedByThisTrigger:x}=Ue(h,C,u,{payload:n,disabled:l,openOnHover:m,closeDelay:P}),O=u.useState("openChangeReason"),B=u.useState("stickIfOpen"),G=u.useState("openMethod"),k=u.useState("focusManagerModal"),N=st(F,{enabled:!l&&m&&(G!=="touch"||O!==z),mouseOnly:!0,move:!1,handleClose:rt(),restMs:r,delay:{close:P},triggerElementRef:C,isActiveTrigger:p,isClosing:()=>u.select("transitionStatus")==="ending"}),A=$e(F,{stickIfOpen:B}),_=et(()=>u.select("open"),R=>{u.set("openMethod",R)}),w=u.useState("triggerProps",x),{getButtonProps:j,buttonRef:S}=Ce({disabled:l,native:c}),U={open(R){return R&&O===z?De.open(R):Ve.open(R)}},{preFocusGuardRef:D,handlePreFocusGuardFocus:q,handleFocusTargetFocus:Y}=ht(u,C),H=te("button",o,{state:{disabled:l,open:E},ref:[S,t,T,C],props:[A.reference,N,w,_,{[Se]:"",id:h,"aria-haspopup":"dialog","aria-expanded":E,"aria-controls":M},b,j],stateAttributesMapping:U}),L=d.jsx(a.Fragment,{children:H},h);return x&&!k?d.jsxs(a.Fragment,{children:[d.jsx($,{ref:D,onFocus:q}),L,d.jsx($,{ref:u.context.triggerFocusTargetRef,onFocus:Y})]}):L}),ne=a.createContext(void 0);function Ct(){const e=a.useContext(ne);if(e===void 0)throw new Error(V(45));return e}const Mt=a.forwardRef(function(o,t){const{keepMounted:i=!1,...s}=o;return K().useState("mounted")||i?d.jsx(ne.Provider,{value:i,children:d.jsx(be,{ref:t,...s})}):null}),se=a.createContext(void 0);function St(){const e=a.useContext(se);if(!e)throw new Error(V(46));return e}const kt=a.forwardRef(function(o,t){const{render:i,className:s,style:g,anchor:l,positionMethod:c,side:f,align:n,sideOffset:m,alignOffset:r,collisionBoundary:P="clipping-ancestors",collisionPadding:I,arrowPadding:b,sticky:v,disableAnchorTracking:y=!1,collisionAvoidance:u=Te,...h}=o,p=K(),F=Ct(),E=qe(),M=p.useState("floatingRootContext"),C=p.useState("mounted"),T=p.useState("open"),x=p.useState("openChangeReason"),O=p.useState("activeTriggerElement"),B=p.useState("modal"),G=p.useState("openMethod"),k=p.useState("positionerElement"),N=p.useState("instantType"),A=p.useState("transitionStatus"),_=p.useState("adaptiveOrigin"),w=a.useRef(null),j=ve(k),S=it({anchor:l,floatingRootContext:M,positionMethod:c,mounted:C,side:f,sideOffset:m,align:n,alignOffset:r,arrowPadding:b,collisionBoundary:P,collisionPadding:I,sticky:v,disableAnchorTracking:y,keepMounted:F,nodeId:E,collisionAvoidance:u,adaptiveOrigin:_}),U=M.useState("domReferenceElement");xe(()=>{const H=U,L=w.current;if(H&&(w.current=H),L&&H&&H!==L){p.set("instantType",void 0);const R=new AbortController;return j(()=>{p.set("instantType","trigger-change")},R.signal),()=>{R.abort()}}},[U,j,p]);const D=B===!0&&x!==X;tt(T&&D,G==="touch",k,O);const q=p.useStateSetter("positionerElement"),Y={open:T,side:S.side,align:S.align,anchorHidden:S.anchorHidden,instant:N},Z=ct(o,Y,{styles:S.positionerStyles,transitionStatus:A,props:h,refs:[t,q],hidden:!C,inert:!T});return d.jsxs(se.Provider,{value:S,children:[C&&D&&d.jsx(Ye,{inert:Re(!T),cutout:O}),d.jsx(ze,{id:E,children:Z})]})}),bt=a.createContext(void 0);function Tt(){const[e,o]=a.useState(0),t=Ie(()=>(o(s=>s+1),()=>{o(s=>Math.max(0,s-1))}));return{context:a.useMemo(()=>({register:t}),[t]),hasClosePart:e>0}}const At=a.forwardRef(function(o,t){const{render:i,className:s,style:g,initialFocus:l,finalFocus:c,...f}=o,n=K(),m=St(),r=ot()!=null,{context:P,hasClosePart:I}=Tt(),b=n.useState("open"),v=n.useState("openMethod"),y=n.useState("instantType"),u=n.useState("transitionStatus"),h=n.useState("popupProps"),p=n.useState("titleElementId"),F=n.useState("descriptionElementId"),E=n.useState("modal"),M=n.useState("mounted"),C=n.useState("openChangeReason"),T=n.useState("activeTriggerElement"),x=n.useState("floatingRootContext"),O=x.useState("floatingId"),B=n.useState("disabled"),G=n.useState("openOnHover"),k=n.useState("closeDelay");Ee({open:b,ref:n.context.popupRef,onComplete(){b&&n.context.onOpenChangeComplete?.(!0)}}),at(x,{enabled:G&&!B,closeDelay:k});const N=l===void 0?Je(n.context.popupRef):l,A=E!==!1&&I;n.useSyncedValue("focusManagerModal",A);const _=n.useStateSetter("popupElement"),w={open:b,side:m.side,align:m.align,instant:y,transitionStatus:u},j=te("div",o,{state:w,ref:[t,n.context.popupRef,_],props:[h,{id:O,role:"dialog",...We,"aria-labelledby":p,"aria-describedby":F,onKeyDown(S){r&&Xe.has(S.key)&&S.stopPropagation()}},ut(u),f],stateAttributesMapping:Ze});return d.jsx(Qe,{context:x,openInteractionType:v,modal:A,disabled:!M||C===X,initialFocus:N,returnFocus:c,restoreFocus:"popup",previousFocusableElement:Oe(T)?T:void 0,nextFocusableElement:n.context.triggerFocusTargetRef,beforeContentFocusGuardRef:n.context.beforeContentFocusGuardRef,children:d.jsx(bt.Provider,{value:P,children:j})})});export{yt as P,Ft as a,Mt as b,kt as c,At as d};