ima2-gen 3.8.2 → 3.9.0

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 (39) hide show
  1. package/bin/commands/gen.js +10 -0
  2. package/docs/migration/runtime-test-inventory.md +5 -1
  3. package/lib/alphaDecode.js +18 -0
  4. package/lib/atlasCloudImageAdapter.js +6 -1
  5. package/lib/backgroundPresets.js +28 -1
  6. package/lib/generatePipeline.js +74 -5
  7. package/lib/imageBackgroundParam.js +108 -0
  8. package/lib/promptImport/gptImageHints.js +4 -1
  9. package/lib/responsesFallback.js +8 -2
  10. package/lib/responsesImageAdapter.js +10 -1
  11. package/package.json +2 -2
  12. package/routes/video.js +7 -0
  13. package/skills/ima2/SKILL.md +28 -4
  14. package/skills/ima2-front/references/asset-requirements.md +23 -8
  15. package/skills/ima2-uiux/SKILL.md +15 -4
  16. package/ui/dist/.vite/manifest.json +32 -32
  17. package/ui/dist/assets/{AgentWorkspace-bUd5NsQ_.js → AgentWorkspace-fcIXiWV6.js} +1 -1
  18. package/ui/dist/assets/AssetGenWorkspace-CqXyN9at.js +2 -0
  19. package/ui/dist/assets/{AssetsWorkspace-DO_wfFQB.js → AssetsWorkspace-xwHFVOb7.js} +1 -1
  20. package/ui/dist/assets/{CardNewsWorkspace-D3M0w8pg.js → CardNewsWorkspace-ltdjG40R.js} +1 -1
  21. package/ui/dist/assets/{GenerationRequestLogPanel-WvSV0yXP.js → GenerationRequestLogPanel-B68EUfUg.js} +1 -1
  22. package/ui/dist/assets/{HomeWorkspace-BGCBf9iK.js → HomeWorkspace-BBOG_aNm.js} +1 -1
  23. package/ui/dist/assets/KeyingPanel-Bv0n_bhk.js +1 -0
  24. package/ui/dist/assets/{NodeCanvas-DwbR2nol.js → NodeCanvas-VwdctvAW.js} +1 -1
  25. package/ui/dist/assets/{PromptBuilderPanel-KSH3ChjC.js → PromptBuilderPanel-BBMpF_3Q.js} +1 -1
  26. package/ui/dist/assets/{PromptImportDialog-CjHiCEo9.js → PromptImportDialog-D4QYbRfH.js} +2 -2
  27. package/ui/dist/assets/{PromptImportDiscoverySection-CWU-vKyM.js → PromptImportDiscoverySection-Bx7BeTFh.js} +1 -1
  28. package/ui/dist/assets/{PromptImportFolderSection-_zRnJGkJ.js → PromptImportFolderSection-Bwf60URx.js} +1 -1
  29. package/ui/dist/assets/{PromptLibraryPanel-64VN4nml.js → PromptLibraryPanel-mNG2wZkQ.js} +2 -2
  30. package/ui/dist/assets/{SettingsWorkspace-DZMNEpuq.js → SettingsWorkspace-DA5tIa0Q.js} +1 -1
  31. package/ui/dist/assets/{SpriteRecipeWorkspace-Y6GqpVHs.js → SpriteRecipeWorkspace-Da9qTQX0.js} +1 -1
  32. package/ui/dist/assets/{index-CFixfKaC.js → index-Bv1Yrz8W.js} +3 -3
  33. package/ui/dist/assets/{index-waPOg2eb.css → index-C0nfanMr.css} +1 -1
  34. package/ui/dist/assets/{index-XXtoj9ME.js → index-CxEuSZMC.js} +16 -16
  35. package/ui/dist/assets/{pptxgen.es-hCJot2gG.js → pptxgen.es-BE4CSd5F.js} +1 -1
  36. package/ui/dist/assets/{useAgentDialogFocus-PWmMjerz.js → useAgentDialogFocus-R64NV-ZZ.js} +1 -1
  37. package/ui/dist/index.html +2 -2
  38. package/ui/dist/assets/AssetGenWorkspace-8fK-K64E.js +0 -2
  39. package/ui/dist/assets/KeyingPanel-CEBLIhhu.js +0 -1
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PromptImportDiscoverySection-CWU-vKyM.js","assets/index-XXtoj9ME.js","assets/index-waPOg2eb.css","assets/PromptImportFolderSection-_zRnJGkJ.js"])))=>i.map(i=>d[i]);
2
- import{u as V,j as e,b as ce,a as o,aJ as Q,aK as U,aL as pe,aM as de,aN as me,aa as J}from"./index-XXtoj9ME.js";function ue(i){const t=i.source;if(!t)return"";if(t.owner&&t.repo){const u=t.ref?`@${t.ref}`:"",s=t.path?`:${t.path}`:"";return`${t.owner}/${t.repo}${u}${s}`}return t.filename??t.sourceId??t.kind??""}function he(i,t){const u=i.tags.find(s=>s.toLowerCase().startsWith(t));return u?u.slice(t.length):null}function be(i){return i.tags.includes("attribution-required")||i.warnings?.some(t=>t.toLowerCase().includes("attribution"))===!0}function ge({candidate:i,selected:t,disabled:u=!1,onToggleSelected:s,onImportOne:g}){const{t:n}=V();if(!i)return e.jsx("aside",{className:"prompt-import-dialog__candidate-preview","aria-label":n("promptLibrary.previewPrompt"),children:e.jsx("div",{className:"prompt-import-dialog__empty",children:n("promptLibrary.importPreviewEmpty")})});const x=ue(i),v=he(i,"license:"),h=be(i);return e.jsxs("aside",{className:"prompt-import-dialog__candidate-preview","aria-label":n("promptLibrary.previewPrompt"),children:[e.jsxs("div",{className:"prompt-import-dialog__preview-header",children:[e.jsxs("div",{children:[e.jsx("span",{children:n("promptLibrary.previewPrompt")}),e.jsx("h4",{children:i.name})]}),e.jsx("button",{type:"button",onClick:()=>g(i),disabled:u,children:n("promptLibrary.importThisPrompt")})]}),e.jsxs("label",{className:"prompt-import-dialog__preview-select",children:[e.jsx("input",{type:"checkbox",checked:t,disabled:u,onChange:l=>s(i.id,l.target.checked)}),e.jsx("span",{children:n(t?"promptLibrary.selectedPrompt":"promptLibrary.selectPrompt")})]}),e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:n("promptLibrary.promptText")}),e.jsx("p",{children:i.text})]}),i.tags.length>0?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:n("promptLibrary.tags")}),e.jsx("div",{className:"prompt-import-dialog__preview-chips",children:i.tags.map(l=>e.jsx("em",{children:l},l))})]}):null,i.warnings?.length?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:n("promptLibrary.compatibilityWarnings")}),e.jsx("div",{className:"prompt-import-dialog__preview-chips",children:i.warnings.map(l=>e.jsx("b",{children:l},l))})]}):null,x||v||h?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:n("promptLibrary.sourceDetails")}),x?e.jsx("small",{children:x}):null,v?e.jsxs("small",{children:[n("promptLibrary.license"),": ",v]}):null,h?e.jsx("small",{children:n("promptLibrary.attributionRequired")}):null]}):null]})}function fe(i){const t=i.source;if(!t)return"";if(t.owner&&t.repo){const u=t.path?` · ${t.path}`:"";return`github · ${t.owner}/${t.repo}${u}`}return t.filename?t.filename:t.sourceId?t.sourceId:t.kind??""}function ye(i){const t=i.replace(/\s+/g," ").trim();return t.length>220?`${t.slice(0,220)}...`:t}function xe({candidates:i,selectedIds:t,activeCandidateId:u,busy:s=!1,onSelectCandidate:g,onToggleSelected:n,onSelectAll:x,onClearSelection:v,onImportOne:h}){const{t:l}=V();if(i.length===0)return e.jsx("section",{className:"prompt-import-dialog__results","aria-label":l("promptLibrary.searchResults"),children:e.jsx("div",{className:"prompt-import-dialog__empty",children:l("promptLibrary.importPreviewEmpty")})});const f=i.every(p=>t.has(p.id));return e.jsxs("section",{className:"prompt-import-dialog__results","aria-label":l("promptLibrary.searchResults"),children:[e.jsxs("header",{className:"prompt-import-dialog__results-header",children:[e.jsx("strong",{children:l("promptLibrary.searchResultsHeader",{count:i.length})}),e.jsxs("div",{className:"prompt-import-dialog__results-header-actions",children:[e.jsx("button",{type:"button",onClick:x,disabled:f,children:l("promptLibrary.selectAllCandidates")}),e.jsx("button",{type:"button",onClick:v,disabled:t.size===0,children:l("promptLibrary.clearCandidateSelection")})]})]}),i.map(p=>{const y=t.has(p.id),S=u===p.id,j=fe(p);return e.jsxs("article",{className:`prompt-import-dialog__result-card${S?" active":""}`,children:[e.jsxs("button",{type:"button",className:"prompt-import-dialog__result-main",onClick:()=>g(p),children:[e.jsx("strong",{children:p.name}),e.jsx("span",{children:ye(p.text)}),j?e.jsx("small",{children:j}):null]}),e.jsxs("div",{className:"prompt-import-dialog__result-meta",children:[p.warnings?.slice(0,2).map(b=>e.jsx("b",{className:"prompt-import-dialog__hint-chip",children:b},b)),p.tags.slice(0,4).map(b=>e.jsx("em",{children:b},b))]}),e.jsxs("div",{className:"prompt-import-dialog__result-actions",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:y,onChange:b=>n(p.id,b.target.checked)}),e.jsx("span",{children:l(y?"promptLibrary.selectedPrompt":"promptLibrary.selectPrompt")})]}),e.jsx("button",{type:"button",onClick:()=>g(p),children:l("promptLibrary.previewPrompt")}),e.jsx("button",{type:"button",onClick:()=>h(p),disabled:s,children:l("promptLibrary.importThisPrompt")})]})]},p.id)})]})}const ve=o.lazy(()=>J(()=>import("./PromptImportDiscoverySection-CWU-vKyM.js"),__vite__mapDeps([0,1,2])).then(i=>({default:i.PromptImportDiscoverySection}))),je=o.lazy(()=>J(()=>import("./PromptImportFolderSection-_zRnJGkJ.js"),__vite__mapDeps([3,1,2])).then(i=>({default:i.PromptImportFolderSection}))),_e=/\.(txt|md|markdown)$/i;function Se({open:i,onClose:t,onImported:u}){const{t:s}=V(),g=ce(r=>r.showToast),n=o.useRef(null),x=o.useRef(null),v=o.useRef(null),[h,l]=o.useState(""),[f,p]=o.useState([]),[y,S]=o.useState(new Set),[j,b]=o.useState(null),[_,L]=o.useState(!1),[W,m]=o.useState(null),[X,N]=o.useState(!1),[Y,A]=o.useState([]),[$,Z]=o.useState(""),[P,z]=o.useState(new Set),[O,E]=o.useState(!1),[q,I]=o.useState([]),[C,B]=o.useState("curated"),[G,ee]=o.useState(!1),H=f.length>0,D=!H||G;o.useEffect(()=>{if(i)return v.current=document.activeElement,window.setTimeout(()=>x.current?.focus(),0),()=>v.current?.focus()},[i]);const re=o.useCallback(async()=>{const r=await Q();A(r.sources),z(new Set)},[]);o.useEffect(()=>{if(!i)return;let r=!1;return Q().then(a=>{r||(A(a.sources),z(new Set))}).catch(()=>{r||A([])}),()=>{r=!0}},[i]);const w=o.useCallback(r=>{p(a=>{const c=new Set(a.map(k=>k.id)),d=[...a];for(const k of r)c.has(k.id)||d.push(k);return b(k=>k??d[0]?.id??null),d})},[]),R=o.useCallback(async r=>{const a=r.filter(c=>_e.test(c.name));if(a.length===0){m(s("promptLibrary.importNoValidFiles"));return}L(!0),m(null);try{const c=[];for(const d of a)c.push(await U({source:{kind:"local",filename:d.name,text:await d.text()}}));w(c.flatMap(d=>d.candidates))}catch(c){m(c instanceof Error?c.message:s("promptLibrary.importFailed"))}finally{L(!1)}},[w,s]),te=o.useCallback(async()=>{if(h.trim()){L(!0),m(null);try{const r=await U({source:{kind:"github",input:h.trim()}});w(r.candidates)}catch(r){m(r instanceof Error?r.message:s("promptLibrary.importFailed"))}finally{L(!1)}}},[w,h,s]),se=o.useCallback(async()=>{E(!0),m(null),I([]);try{const r=await pe({q:$.trim(),sourceIds:[...P]});w(r.results),I(r.warnings),r.results.length===0&&m(s("promptLibrary.noCuratedResults"))}catch(r){m(r instanceof Error?r.message:s("promptLibrary.importFailed"))}finally{E(!1)}},[w,$,P,s]),ie=o.useCallback(async r=>{E(!0),m(null),I([]);try{const a=await de({sourceId:r});I(a.warnings),g(s("promptLibrary.curatedRefreshed",{count:a.candidateCount}))}catch(a){m(a instanceof Error?a.message:s("promptLibrary.importFailed"))}finally{E(!1)}},[g,s]),K=o.useCallback((r,a)=>{S(c=>{const d=new Set(c);return a?d.add(r):d.delete(r),d})},[]),oe=o.useCallback(()=>{S(new Set(f.map(r=>r.id)))},[f]),ae=o.useCallback(()=>{S(new Set)},[]),T=o.useCallback(async r=>{if(r.length===0){m(s("promptLibrary.importSelectAtLeastOne"));return}L(!0),m(null);try{const a=await me({candidates:r});await u(),g(s("promptLibrary.imported",{count:a.promptsImported})),t()}catch(a){m(a instanceof Error?a.message:s("promptLibrary.importFailed"))}finally{L(!1)}},[t,u,g,s]),le=o.useCallback(async()=>{const r=f.filter(a=>y.has(a.id));await T(r)},[f,T,y]),M=o.useCallback(r=>{S(new Set([r.id])),T([r])},[T]),ne=o.useCallback(r=>{const a=Array.from(r.target.files??[]);a.length>0&&R(a),r.target.value=""},[R]),F=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),N(!1);const a=Array.from(r.dataTransfer?.files??[]);a.length>0&&R(a)},[R]);return o.useEffect(()=>{if(!i)return;const r=c=>{c.preventDefault(),N(!0)},a=c=>{c.relatedTarget===null&&N(!1)};return window.addEventListener("dragover",r),window.addEventListener("dragleave",a),window.addEventListener("drop",F),()=>{window.removeEventListener("dragover",r),window.removeEventListener("dragleave",a),window.removeEventListener("drop",F)}},[F,i]),i?e.jsxs("div",{className:"prompt-import-dialog",role:"presentation",children:[e.jsx("div",{className:"prompt-import-dialog__backdrop",onClick:t}),e.jsxs("div",{ref:x,className:"prompt-import-dialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":"prompt-import-title",tabIndex:-1,onKeyDown:r=>{r.key==="Escape"&&t()},children:[e.jsxs("div",{className:"prompt-import-dialog__header",children:[e.jsx("h3",{id:"prompt-import-title",children:s("promptLibrary.importTitle")}),e.jsx("button",{type:"button",onClick:t,"aria-label":s("common.close"),children:"×"})]}),D&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`prompt-import-dialog__dropzone${X?" active":""}`,onDragOver:r=>{r.preventDefault(),N(!0)},onDragLeave:()=>N(!1),onDrop:F,children:[e.jsx("strong",{children:s("promptLibrary.importDropTitle")}),e.jsx("span",{children:s("promptLibrary.importDropHint")}),e.jsx("button",{type:"button",onClick:()=>n.current?.click(),children:s("promptLibrary.importChooseFiles")}),e.jsx("input",{ref:n,className:"prompt-library-panel__file-input",type:"file",accept:".txt,.md,.markdown,text/plain,text/markdown",multiple:!0,onChange:ne})]}),e.jsxs("div",{className:"prompt-import-dialog__github",children:[e.jsx("label",{htmlFor:"prompt-import-github",children:s("promptLibrary.importGithubLabel")}),e.jsxs("div",{children:[e.jsx("input",{id:"prompt-import-github",type:"text",value:h,onChange:r=>l(r.target.value),placeholder:"owner/repo:path/to/prompts.md"}),e.jsx("button",{type:"button",onClick:()=>{te()},disabled:_||!h.trim(),children:s("promptLibrary.importPreview")})]})]}),e.jsx(o.Suspense,{fallback:null,children:e.jsx(je,{input:h,disabled:_,onCandidates:w,onError:m})}),e.jsxs("div",{className:"prompt-import-dialog__source-tabs",role:"tablist","aria-label":s("promptLibrary.curatedSources"),children:[e.jsx("button",{type:"button",className:C==="curated"?"active":"",onClick:()=>B("curated"),"aria-pressed":C==="curated",children:s("promptLibrary.curatedSources")}),e.jsx("button",{type:"button",className:C==="discovery"?"active":"",onClick:()=>B("discovery"),"aria-pressed":C==="discovery",children:s("promptLibrary.discovery")})]})]}),(D?C==="curated":!0)&&e.jsxs("div",{className:"prompt-import-dialog__curated",children:[D&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"prompt-import-dialog__section-title",children:[e.jsx("strong",{children:s("promptLibrary.curatedSources")}),e.jsx("span",{children:s("promptLibrary.curatedSourcesHint")})]}),e.jsx("div",{className:"prompt-import-dialog__source-list",children:Y.filter(r=>r.trustTier!=="manual-review").map(r=>e.jsxs("label",{className:"prompt-import-dialog__source",children:[e.jsx("input",{type:"checkbox",checked:P.has(r.id),onChange:a=>{z(c=>{const d=new Set(c);return a.target.checked?d.add(r.id):d.delete(r.id),d})}}),e.jsxs("span",{children:[e.jsx("strong",{children:r.displayName}),e.jsxs("small",{children:[r.licenseSpdx," · ",r.trustTier]})]}),e.jsx("button",{type:"button",onClick:()=>{ie(r.id)},disabled:O,children:s("promptLibrary.refreshSource")})]},r.id))})]}),e.jsxs("div",{className:"prompt-import-dialog__search-results",children:[e.jsx("input",{type:"text",value:$,onChange:r=>Z(r.target.value),placeholder:s("promptLibrary.curatedSearchPlaceholder"),"aria-label":s("promptLibrary.curatedSearch")}),e.jsx("button",{type:"button",onClick:()=>{se()},disabled:O||P.size===0,children:s(O?"common.loading":"promptLibrary.curatedSearch")})]}),q.length>0?e.jsx("div",{className:"prompt-import-dialog__warning",children:q.slice(0,3).join(" · ")}):null]}),D&&C==="discovery"&&e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"prompt-import-dialog__empty",children:s("common.loading")}),children:e.jsx(ve,{disabled:_,onError:m,onSourcesChanged:re})}),H&&!G&&e.jsx("button",{type:"button",className:"prompt-import-dialog__add-source-toggle",onClick:()=>ee(!0),children:s("promptLibrary.addAnotherSource")}),W?e.jsx("div",{className:"prompt-import-dialog__error",role:"alert",children:W}):null,e.jsxs("div",{className:"prompt-import-dialog__workspace","aria-live":"polite",children:[e.jsx(xe,{candidates:f,selectedIds:y,activeCandidateId:j,busy:_,onSelectCandidate:r=>b(r.id),onToggleSelected:K,onSelectAll:oe,onClearSelection:ae,onImportOne:M}),e.jsx(ge,{candidate:f.find(r=>r.id===j)??null,selected:j?y.has(j):!1,disabled:_,onToggleSelected:K,onImportOne:M})]}),e.jsxs("div",{className:"prompt-import-dialog__footer",children:[e.jsx("button",{type:"button",onClick:t,children:s("common.cancel")}),e.jsx("button",{type:"button",onClick:()=>{le()},disabled:_||y.size===0,children:_?s("common.loading"):s("promptLibrary.importSelected",{count:y.size})})]})]})]}):null}export{Se as PromptImportDialog};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PromptImportDiscoverySection-Bx7BeTFh.js","assets/index-CxEuSZMC.js","assets/index-C0nfanMr.css","assets/PromptImportFolderSection-Bwf60URx.js"])))=>i.map(i=>d[i]);
2
+ import{u as V,j as e,b as ce,a as o,aJ as Q,aK as U,aL as pe,aM as de,aN as me,aa as J}from"./index-CxEuSZMC.js";function ue(i){const t=i.source;if(!t)return"";if(t.owner&&t.repo){const u=t.ref?`@${t.ref}`:"",s=t.path?`:${t.path}`:"";return`${t.owner}/${t.repo}${u}${s}`}return t.filename??t.sourceId??t.kind??""}function he(i,t){const u=i.tags.find(s=>s.toLowerCase().startsWith(t));return u?u.slice(t.length):null}function be(i){return i.tags.includes("attribution-required")||i.warnings?.some(t=>t.toLowerCase().includes("attribution"))===!0}function ge({candidate:i,selected:t,disabled:u=!1,onToggleSelected:s,onImportOne:g}){const{t:n}=V();if(!i)return e.jsx("aside",{className:"prompt-import-dialog__candidate-preview","aria-label":n("promptLibrary.previewPrompt"),children:e.jsx("div",{className:"prompt-import-dialog__empty",children:n("promptLibrary.importPreviewEmpty")})});const x=ue(i),v=he(i,"license:"),h=be(i);return e.jsxs("aside",{className:"prompt-import-dialog__candidate-preview","aria-label":n("promptLibrary.previewPrompt"),children:[e.jsxs("div",{className:"prompt-import-dialog__preview-header",children:[e.jsxs("div",{children:[e.jsx("span",{children:n("promptLibrary.previewPrompt")}),e.jsx("h4",{children:i.name})]}),e.jsx("button",{type:"button",onClick:()=>g(i),disabled:u,children:n("promptLibrary.importThisPrompt")})]}),e.jsxs("label",{className:"prompt-import-dialog__preview-select",children:[e.jsx("input",{type:"checkbox",checked:t,disabled:u,onChange:l=>s(i.id,l.target.checked)}),e.jsx("span",{children:n(t?"promptLibrary.selectedPrompt":"promptLibrary.selectPrompt")})]}),e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:n("promptLibrary.promptText")}),e.jsx("p",{children:i.text})]}),i.tags.length>0?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:n("promptLibrary.tags")}),e.jsx("div",{className:"prompt-import-dialog__preview-chips",children:i.tags.map(l=>e.jsx("em",{children:l},l))})]}):null,i.warnings?.length?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:n("promptLibrary.compatibilityWarnings")}),e.jsx("div",{className:"prompt-import-dialog__preview-chips",children:i.warnings.map(l=>e.jsx("b",{children:l},l))})]}):null,x||v||h?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:n("promptLibrary.sourceDetails")}),x?e.jsx("small",{children:x}):null,v?e.jsxs("small",{children:[n("promptLibrary.license"),": ",v]}):null,h?e.jsx("small",{children:n("promptLibrary.attributionRequired")}):null]}):null]})}function fe(i){const t=i.source;if(!t)return"";if(t.owner&&t.repo){const u=t.path?` · ${t.path}`:"";return`github · ${t.owner}/${t.repo}${u}`}return t.filename?t.filename:t.sourceId?t.sourceId:t.kind??""}function ye(i){const t=i.replace(/\s+/g," ").trim();return t.length>220?`${t.slice(0,220)}...`:t}function xe({candidates:i,selectedIds:t,activeCandidateId:u,busy:s=!1,onSelectCandidate:g,onToggleSelected:n,onSelectAll:x,onClearSelection:v,onImportOne:h}){const{t:l}=V();if(i.length===0)return e.jsx("section",{className:"prompt-import-dialog__results","aria-label":l("promptLibrary.searchResults"),children:e.jsx("div",{className:"prompt-import-dialog__empty",children:l("promptLibrary.importPreviewEmpty")})});const f=i.every(p=>t.has(p.id));return e.jsxs("section",{className:"prompt-import-dialog__results","aria-label":l("promptLibrary.searchResults"),children:[e.jsxs("header",{className:"prompt-import-dialog__results-header",children:[e.jsx("strong",{children:l("promptLibrary.searchResultsHeader",{count:i.length})}),e.jsxs("div",{className:"prompt-import-dialog__results-header-actions",children:[e.jsx("button",{type:"button",onClick:x,disabled:f,children:l("promptLibrary.selectAllCandidates")}),e.jsx("button",{type:"button",onClick:v,disabled:t.size===0,children:l("promptLibrary.clearCandidateSelection")})]})]}),i.map(p=>{const y=t.has(p.id),S=u===p.id,j=fe(p);return e.jsxs("article",{className:`prompt-import-dialog__result-card${S?" active":""}`,children:[e.jsxs("button",{type:"button",className:"prompt-import-dialog__result-main",onClick:()=>g(p),children:[e.jsx("strong",{children:p.name}),e.jsx("span",{children:ye(p.text)}),j?e.jsx("small",{children:j}):null]}),e.jsxs("div",{className:"prompt-import-dialog__result-meta",children:[p.warnings?.slice(0,2).map(b=>e.jsx("b",{className:"prompt-import-dialog__hint-chip",children:b},b)),p.tags.slice(0,4).map(b=>e.jsx("em",{children:b},b))]}),e.jsxs("div",{className:"prompt-import-dialog__result-actions",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:y,onChange:b=>n(p.id,b.target.checked)}),e.jsx("span",{children:l(y?"promptLibrary.selectedPrompt":"promptLibrary.selectPrompt")})]}),e.jsx("button",{type:"button",onClick:()=>g(p),children:l("promptLibrary.previewPrompt")}),e.jsx("button",{type:"button",onClick:()=>h(p),disabled:s,children:l("promptLibrary.importThisPrompt")})]})]},p.id)})]})}const ve=o.lazy(()=>J(()=>import("./PromptImportDiscoverySection-Bx7BeTFh.js"),__vite__mapDeps([0,1,2])).then(i=>({default:i.PromptImportDiscoverySection}))),je=o.lazy(()=>J(()=>import("./PromptImportFolderSection-Bwf60URx.js"),__vite__mapDeps([3,1,2])).then(i=>({default:i.PromptImportFolderSection}))),_e=/\.(txt|md|markdown)$/i;function Se({open:i,onClose:t,onImported:u}){const{t:s}=V(),g=ce(r=>r.showToast),n=o.useRef(null),x=o.useRef(null),v=o.useRef(null),[h,l]=o.useState(""),[f,p]=o.useState([]),[y,S]=o.useState(new Set),[j,b]=o.useState(null),[_,L]=o.useState(!1),[W,m]=o.useState(null),[X,N]=o.useState(!1),[Y,A]=o.useState([]),[$,Z]=o.useState(""),[P,z]=o.useState(new Set),[O,E]=o.useState(!1),[q,I]=o.useState([]),[C,B]=o.useState("curated"),[G,ee]=o.useState(!1),H=f.length>0,D=!H||G;o.useEffect(()=>{if(i)return v.current=document.activeElement,window.setTimeout(()=>x.current?.focus(),0),()=>v.current?.focus()},[i]);const re=o.useCallback(async()=>{const r=await Q();A(r.sources),z(new Set)},[]);o.useEffect(()=>{if(!i)return;let r=!1;return Q().then(a=>{r||(A(a.sources),z(new Set))}).catch(()=>{r||A([])}),()=>{r=!0}},[i]);const w=o.useCallback(r=>{p(a=>{const c=new Set(a.map(k=>k.id)),d=[...a];for(const k of r)c.has(k.id)||d.push(k);return b(k=>k??d[0]?.id??null),d})},[]),R=o.useCallback(async r=>{const a=r.filter(c=>_e.test(c.name));if(a.length===0){m(s("promptLibrary.importNoValidFiles"));return}L(!0),m(null);try{const c=[];for(const d of a)c.push(await U({source:{kind:"local",filename:d.name,text:await d.text()}}));w(c.flatMap(d=>d.candidates))}catch(c){m(c instanceof Error?c.message:s("promptLibrary.importFailed"))}finally{L(!1)}},[w,s]),te=o.useCallback(async()=>{if(h.trim()){L(!0),m(null);try{const r=await U({source:{kind:"github",input:h.trim()}});w(r.candidates)}catch(r){m(r instanceof Error?r.message:s("promptLibrary.importFailed"))}finally{L(!1)}}},[w,h,s]),se=o.useCallback(async()=>{E(!0),m(null),I([]);try{const r=await pe({q:$.trim(),sourceIds:[...P]});w(r.results),I(r.warnings),r.results.length===0&&m(s("promptLibrary.noCuratedResults"))}catch(r){m(r instanceof Error?r.message:s("promptLibrary.importFailed"))}finally{E(!1)}},[w,$,P,s]),ie=o.useCallback(async r=>{E(!0),m(null),I([]);try{const a=await de({sourceId:r});I(a.warnings),g(s("promptLibrary.curatedRefreshed",{count:a.candidateCount}))}catch(a){m(a instanceof Error?a.message:s("promptLibrary.importFailed"))}finally{E(!1)}},[g,s]),K=o.useCallback((r,a)=>{S(c=>{const d=new Set(c);return a?d.add(r):d.delete(r),d})},[]),oe=o.useCallback(()=>{S(new Set(f.map(r=>r.id)))},[f]),ae=o.useCallback(()=>{S(new Set)},[]),T=o.useCallback(async r=>{if(r.length===0){m(s("promptLibrary.importSelectAtLeastOne"));return}L(!0),m(null);try{const a=await me({candidates:r});await u(),g(s("promptLibrary.imported",{count:a.promptsImported})),t()}catch(a){m(a instanceof Error?a.message:s("promptLibrary.importFailed"))}finally{L(!1)}},[t,u,g,s]),le=o.useCallback(async()=>{const r=f.filter(a=>y.has(a.id));await T(r)},[f,T,y]),M=o.useCallback(r=>{S(new Set([r.id])),T([r])},[T]),ne=o.useCallback(r=>{const a=Array.from(r.target.files??[]);a.length>0&&R(a),r.target.value=""},[R]),F=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),N(!1);const a=Array.from(r.dataTransfer?.files??[]);a.length>0&&R(a)},[R]);return o.useEffect(()=>{if(!i)return;const r=c=>{c.preventDefault(),N(!0)},a=c=>{c.relatedTarget===null&&N(!1)};return window.addEventListener("dragover",r),window.addEventListener("dragleave",a),window.addEventListener("drop",F),()=>{window.removeEventListener("dragover",r),window.removeEventListener("dragleave",a),window.removeEventListener("drop",F)}},[F,i]),i?e.jsxs("div",{className:"prompt-import-dialog",role:"presentation",children:[e.jsx("div",{className:"prompt-import-dialog__backdrop",onClick:t}),e.jsxs("div",{ref:x,className:"prompt-import-dialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":"prompt-import-title",tabIndex:-1,onKeyDown:r=>{r.key==="Escape"&&t()},children:[e.jsxs("div",{className:"prompt-import-dialog__header",children:[e.jsx("h3",{id:"prompt-import-title",children:s("promptLibrary.importTitle")}),e.jsx("button",{type:"button",onClick:t,"aria-label":s("common.close"),children:"×"})]}),D&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`prompt-import-dialog__dropzone${X?" active":""}`,onDragOver:r=>{r.preventDefault(),N(!0)},onDragLeave:()=>N(!1),onDrop:F,children:[e.jsx("strong",{children:s("promptLibrary.importDropTitle")}),e.jsx("span",{children:s("promptLibrary.importDropHint")}),e.jsx("button",{type:"button",onClick:()=>n.current?.click(),children:s("promptLibrary.importChooseFiles")}),e.jsx("input",{ref:n,className:"prompt-library-panel__file-input",type:"file",accept:".txt,.md,.markdown,text/plain,text/markdown",multiple:!0,onChange:ne})]}),e.jsxs("div",{className:"prompt-import-dialog__github",children:[e.jsx("label",{htmlFor:"prompt-import-github",children:s("promptLibrary.importGithubLabel")}),e.jsxs("div",{children:[e.jsx("input",{id:"prompt-import-github",type:"text",value:h,onChange:r=>l(r.target.value),placeholder:"owner/repo:path/to/prompts.md"}),e.jsx("button",{type:"button",onClick:()=>{te()},disabled:_||!h.trim(),children:s("promptLibrary.importPreview")})]})]}),e.jsx(o.Suspense,{fallback:null,children:e.jsx(je,{input:h,disabled:_,onCandidates:w,onError:m})}),e.jsxs("div",{className:"prompt-import-dialog__source-tabs",role:"tablist","aria-label":s("promptLibrary.curatedSources"),children:[e.jsx("button",{type:"button",className:C==="curated"?"active":"",onClick:()=>B("curated"),"aria-pressed":C==="curated",children:s("promptLibrary.curatedSources")}),e.jsx("button",{type:"button",className:C==="discovery"?"active":"",onClick:()=>B("discovery"),"aria-pressed":C==="discovery",children:s("promptLibrary.discovery")})]})]}),(D?C==="curated":!0)&&e.jsxs("div",{className:"prompt-import-dialog__curated",children:[D&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"prompt-import-dialog__section-title",children:[e.jsx("strong",{children:s("promptLibrary.curatedSources")}),e.jsx("span",{children:s("promptLibrary.curatedSourcesHint")})]}),e.jsx("div",{className:"prompt-import-dialog__source-list",children:Y.filter(r=>r.trustTier!=="manual-review").map(r=>e.jsxs("label",{className:"prompt-import-dialog__source",children:[e.jsx("input",{type:"checkbox",checked:P.has(r.id),onChange:a=>{z(c=>{const d=new Set(c);return a.target.checked?d.add(r.id):d.delete(r.id),d})}}),e.jsxs("span",{children:[e.jsx("strong",{children:r.displayName}),e.jsxs("small",{children:[r.licenseSpdx," · ",r.trustTier]})]}),e.jsx("button",{type:"button",onClick:()=>{ie(r.id)},disabled:O,children:s("promptLibrary.refreshSource")})]},r.id))})]}),e.jsxs("div",{className:"prompt-import-dialog__search-results",children:[e.jsx("input",{type:"text",value:$,onChange:r=>Z(r.target.value),placeholder:s("promptLibrary.curatedSearchPlaceholder"),"aria-label":s("promptLibrary.curatedSearch")}),e.jsx("button",{type:"button",onClick:()=>{se()},disabled:O||P.size===0,children:s(O?"common.loading":"promptLibrary.curatedSearch")})]}),q.length>0?e.jsx("div",{className:"prompt-import-dialog__warning",children:q.slice(0,3).join(" · ")}):null]}),D&&C==="discovery"&&e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"prompt-import-dialog__empty",children:s("common.loading")}),children:e.jsx(ve,{disabled:_,onError:m,onSourcesChanged:re})}),H&&!G&&e.jsx("button",{type:"button",className:"prompt-import-dialog__add-source-toggle",onClick:()=>ee(!0),children:s("promptLibrary.addAnotherSource")}),W?e.jsx("div",{className:"prompt-import-dialog__error",role:"alert",children:W}):null,e.jsxs("div",{className:"prompt-import-dialog__workspace","aria-live":"polite",children:[e.jsx(xe,{candidates:f,selectedIds:y,activeCandidateId:j,busy:_,onSelectCandidate:r=>b(r.id),onToggleSelected:K,onSelectAll:oe,onClearSelection:ae,onImportOne:M}),e.jsx(ge,{candidate:f.find(r=>r.id===j)??null,selected:j?y.has(j):!1,disabled:_,onToggleSelected:K,onImportOne:M})]}),e.jsxs("div",{className:"prompt-import-dialog__footer",children:[e.jsx("button",{type:"button",onClick:t,children:s("common.cancel")}),e.jsx("button",{type:"button",onClick:()=>{le()},disabled:_||y.size===0,children:_?s("common.loading"):s("promptLibrary.importSelected",{count:y.size})})]})]})]}):null}export{Se as PromptImportDialog};
@@ -1 +1 @@
1
- import{u as L,a as t,aP as S,aQ as P,aR as R,j as r}from"./index-XXtoj9ME.js";const C=["gpt-image-2 prompt","nano banana prompts","typography image prompt"];function k({disabled:d=!1,onError:a,onSourcesChanged:y}){const{t:s}=L(),[l,N]=t.useState("gpt-image-2 prompt"),[v,p]=t.useState([]),[n,c]=t.useState(!1),[g,m]=t.useState([]),[h,_]=t.useState({});t.useEffect(()=>{let e=!1;return S().then(i=>{e||p(i.candidates)}).catch(()=>{e||p([])}),()=>{e=!0}},[]);const w=t.useCallback(async()=>{c(!0),m([]),a(null);try{const e=await P({q:l.trim(),seeds:C});p(e.candidates),m([...e.warnings,...e.rateLimit?.remaining===0?["github-rate-limit-exhausted"]:[]]),e.candidates.length===0&&a(s("promptLibrary.discoveryNoResults"))}catch(e){a(e instanceof Error?e.message:s("promptLibrary.importFailed"))}finally{c(!1)}},[a,l,s]),x=t.useCallback(async(e,i)=>{c(!0),m([]),a(null);try{const j=(h[e.fullName]||"").split(/\r?\n|,/).map(u=>u.trim()).filter(Boolean),b=await R({repo:e.fullName,status:i,allowedPaths:i==="approved"?j:[],defaultSearch:i==="approved"&&j.length>0});m(b.warnings),p(u=>u.map(f=>f.fullName===e.fullName?b.candidate:f)),await y()}catch(o){a(o instanceof Error?o.message:s("promptLibrary.importFailed"))}finally{c(!1)}},[h,a,y,s]);return r.jsxs("div",{className:"prompt-import-dialog__discovery",children:[r.jsxs("div",{className:"prompt-import-dialog__section-title",children:[r.jsx("strong",{children:s("promptLibrary.discovery")}),r.jsx("span",{children:s("promptLibrary.discoveryReviewQueue")})]}),r.jsxs("div",{className:"prompt-import-dialog__discovery-actions",children:[r.jsx("input",{type:"text",value:l,onChange:e=>N(e.target.value),placeholder:s("promptLibrary.discoverySearchPlaceholder"),"aria-label":s("promptLibrary.discoverySearch")}),r.jsx("button",{type:"button",onClick:()=>{w()},disabled:d||n||!l.trim(),children:s(n?"common.loading":"promptLibrary.discoverySearch")})]}),g.length>0?r.jsx("div",{className:"prompt-import-dialog__discovery-warning",children:g.slice(0,3).join(" · ")}):null,v.length===0?r.jsx("div",{className:"prompt-import-dialog__empty",children:s("promptLibrary.discoveryNoResults")}):r.jsx("div",{className:"prompt-import-dialog__discovery-list",children:v.map(e=>r.jsxs("article",{className:"prompt-import-dialog__discovery-candidate",children:[r.jsxs("div",{children:[r.jsx("strong",{children:e.fullName}),r.jsx("small",{children:e.description||e.htmlUrl})]}),r.jsxs("div",{className:"prompt-import-dialog__score",children:[r.jsxs("span",{children:[s("promptLibrary.discoveryScore"),": ",e.score]}),r.jsx("span",{children:e.licenseSpdx}),r.jsx("span",{children:e.status})]}),e.scoreReasons.length>0?r.jsx("em",{children:e.scoreReasons.slice(0,3).join(" · ")}):null,e.warnings.length>0?r.jsx("b",{children:e.warnings.slice(0,2).join(" · ")}):null,r.jsx("textarea",{value:h[e.fullName]||"",onChange:i=>_(o=>({...o,[e.fullName]:i.target.value})),placeholder:"README.md, prompts/example.md","aria-label":s("promptLibrary.discoveryRequiresPaths")}),r.jsxs("div",{className:"prompt-import-dialog__review-actions",children:[r.jsx("button",{type:"button",onClick:()=>{x(e,"approved")},disabled:d||n,children:s("promptLibrary.discoveryApprove")}),r.jsx("button",{type:"button",onClick:()=>{x(e,"rejected")},disabled:d||n,children:s("promptLibrary.discoveryReject")})]})]},e.fullName))})]})}export{k as PromptImportDiscoverySection};
1
+ import{u as L,a as t,aP as S,aQ as P,aR as R,j as r}from"./index-CxEuSZMC.js";const C=["gpt-image-2 prompt","nano banana prompts","typography image prompt"];function k({disabled:d=!1,onError:a,onSourcesChanged:y}){const{t:s}=L(),[l,N]=t.useState("gpt-image-2 prompt"),[v,p]=t.useState([]),[n,c]=t.useState(!1),[g,m]=t.useState([]),[h,_]=t.useState({});t.useEffect(()=>{let e=!1;return S().then(i=>{e||p(i.candidates)}).catch(()=>{e||p([])}),()=>{e=!0}},[]);const w=t.useCallback(async()=>{c(!0),m([]),a(null);try{const e=await P({q:l.trim(),seeds:C});p(e.candidates),m([...e.warnings,...e.rateLimit?.remaining===0?["github-rate-limit-exhausted"]:[]]),e.candidates.length===0&&a(s("promptLibrary.discoveryNoResults"))}catch(e){a(e instanceof Error?e.message:s("promptLibrary.importFailed"))}finally{c(!1)}},[a,l,s]),x=t.useCallback(async(e,i)=>{c(!0),m([]),a(null);try{const j=(h[e.fullName]||"").split(/\r?\n|,/).map(u=>u.trim()).filter(Boolean),b=await R({repo:e.fullName,status:i,allowedPaths:i==="approved"?j:[],defaultSearch:i==="approved"&&j.length>0});m(b.warnings),p(u=>u.map(f=>f.fullName===e.fullName?b.candidate:f)),await y()}catch(o){a(o instanceof Error?o.message:s("promptLibrary.importFailed"))}finally{c(!1)}},[h,a,y,s]);return r.jsxs("div",{className:"prompt-import-dialog__discovery",children:[r.jsxs("div",{className:"prompt-import-dialog__section-title",children:[r.jsx("strong",{children:s("promptLibrary.discovery")}),r.jsx("span",{children:s("promptLibrary.discoveryReviewQueue")})]}),r.jsxs("div",{className:"prompt-import-dialog__discovery-actions",children:[r.jsx("input",{type:"text",value:l,onChange:e=>N(e.target.value),placeholder:s("promptLibrary.discoverySearchPlaceholder"),"aria-label":s("promptLibrary.discoverySearch")}),r.jsx("button",{type:"button",onClick:()=>{w()},disabled:d||n||!l.trim(),children:s(n?"common.loading":"promptLibrary.discoverySearch")})]}),g.length>0?r.jsx("div",{className:"prompt-import-dialog__discovery-warning",children:g.slice(0,3).join(" · ")}):null,v.length===0?r.jsx("div",{className:"prompt-import-dialog__empty",children:s("promptLibrary.discoveryNoResults")}):r.jsx("div",{className:"prompt-import-dialog__discovery-list",children:v.map(e=>r.jsxs("article",{className:"prompt-import-dialog__discovery-candidate",children:[r.jsxs("div",{children:[r.jsx("strong",{children:e.fullName}),r.jsx("small",{children:e.description||e.htmlUrl})]}),r.jsxs("div",{className:"prompt-import-dialog__score",children:[r.jsxs("span",{children:[s("promptLibrary.discoveryScore"),": ",e.score]}),r.jsx("span",{children:e.licenseSpdx}),r.jsx("span",{children:e.status})]}),e.scoreReasons.length>0?r.jsx("em",{children:e.scoreReasons.slice(0,3).join(" · ")}):null,e.warnings.length>0?r.jsx("b",{children:e.warnings.slice(0,2).join(" · ")}):null,r.jsx("textarea",{value:h[e.fullName]||"",onChange:i=>_(o=>({...o,[e.fullName]:i.target.value})),placeholder:"README.md, prompts/example.md","aria-label":s("promptLibrary.discoveryRequiresPaths")}),r.jsxs("div",{className:"prompt-import-dialog__review-actions",children:[r.jsx("button",{type:"button",onClick:()=>{x(e,"approved")},disabled:d||n,children:s("promptLibrary.discoveryApprove")}),r.jsx("button",{type:"button",onClick:()=>{x(e,"rejected")},disabled:d||n,children:s("promptLibrary.discoveryReject")})]})]},e.fullName))})]})}export{k as PromptImportDiscoverySection};
@@ -1 +1 @@
1
- import{u as w,a,aS as S,aT as _,j as t}from"./index-XXtoj9ME.js";function F({input:i,disabled:h=!1,onCandidates:u,onError:l}){const{t:s}=w(),[f,g]=a.useState([]),[o,p]=a.useState(new Set),[d,n]=a.useState(!1),[x,c]=a.useState([]),y=a.useCallback(async()=>{if(i.trim()){n(!0),c([]),l(null);try{const e=await S({source:{kind:"github-folder",input:i.trim()}});g(e.files),p(new Set(e.files.slice(0,5).map(r=>r.path))),c(e.warnings),e.files.length===0&&l(s("promptLibrary.folderFilesEmpty"))}catch(e){g([]),p(new Set),l(e instanceof Error?e.message:s("promptLibrary.folderUnsupported"))}finally{n(!1)}}},[i,l,s]),b=a.useCallback(async()=>{const e=[...o];if(e.length===0){l(s("promptLibrary.folderNoSelection"));return}n(!0),c([]),l(null);try{const r=await _({source:{kind:"github-folder",input:i.trim()},paths:e});c(r.warnings),u(r.candidates)}catch(r){l(r instanceof Error?r.message:s("promptLibrary.importFailed"))}finally{n(!1)}},[i,u,l,o,s]);return t.jsxs("div",{className:"prompt-import-dialog__folder",children:[t.jsxs("div",{className:"prompt-import-dialog__section-title",children:[t.jsx("strong",{children:s("promptLibrary.folderFiles")}),t.jsx("span",{children:s("promptLibrary.folderBrowseHint")})]}),t.jsxs("div",{className:"prompt-import-dialog__folder-actions",children:[t.jsx("button",{type:"button",onClick:()=>{y()},disabled:h||d||!i.trim(),children:s(d?"common.loading":"promptLibrary.folderBrowse")}),t.jsx("button",{type:"button",onClick:()=>{b()},disabled:h||d||o.size===0,children:s("promptLibrary.folderPreviewSelected")}),t.jsx("span",{children:s("promptLibrary.folderSelectedCount",{count:o.size})})]}),f.length>0?t.jsx("div",{className:"prompt-import-dialog__folder-list",children:f.map(e=>t.jsxs("label",{className:"prompt-import-dialog__folder-file",children:[t.jsx("input",{type:"checkbox",checked:o.has(e.path),onChange:r=>{p(j=>{const m=new Set(j);return r.target.checked?m.add(e.path):m.delete(e.path),m})}}),t.jsxs("span",{children:[t.jsx("strong",{children:e.name}),t.jsx("small",{children:e.path})]}),t.jsxs("em",{children:[Math.ceil(e.sizeBytes/1024)," KB"]})]},e.path))}):null,x.length>0?t.jsx("div",{className:"prompt-import-dialog__folder-warning",children:x.slice(0,3).join(" · ")}):null]})}export{F as PromptImportFolderSection};
1
+ import{u as w,a,aS as S,aT as _,j as t}from"./index-CxEuSZMC.js";function F({input:i,disabled:h=!1,onCandidates:u,onError:l}){const{t:s}=w(),[f,g]=a.useState([]),[o,p]=a.useState(new Set),[d,n]=a.useState(!1),[x,c]=a.useState([]),y=a.useCallback(async()=>{if(i.trim()){n(!0),c([]),l(null);try{const e=await S({source:{kind:"github-folder",input:i.trim()}});g(e.files),p(new Set(e.files.slice(0,5).map(r=>r.path))),c(e.warnings),e.files.length===0&&l(s("promptLibrary.folderFilesEmpty"))}catch(e){g([]),p(new Set),l(e instanceof Error?e.message:s("promptLibrary.folderUnsupported"))}finally{n(!1)}}},[i,l,s]),b=a.useCallback(async()=>{const e=[...o];if(e.length===0){l(s("promptLibrary.folderNoSelection"));return}n(!0),c([]),l(null);try{const r=await _({source:{kind:"github-folder",input:i.trim()},paths:e});c(r.warnings),u(r.candidates)}catch(r){l(r instanceof Error?r.message:s("promptLibrary.importFailed"))}finally{n(!1)}},[i,u,l,o,s]);return t.jsxs("div",{className:"prompt-import-dialog__folder",children:[t.jsxs("div",{className:"prompt-import-dialog__section-title",children:[t.jsx("strong",{children:s("promptLibrary.folderFiles")}),t.jsx("span",{children:s("promptLibrary.folderBrowseHint")})]}),t.jsxs("div",{className:"prompt-import-dialog__folder-actions",children:[t.jsx("button",{type:"button",onClick:()=>{y()},disabled:h||d||!i.trim(),children:s(d?"common.loading":"promptLibrary.folderBrowse")}),t.jsx("button",{type:"button",onClick:()=>{b()},disabled:h||d||o.size===0,children:s("promptLibrary.folderPreviewSelected")}),t.jsx("span",{children:s("promptLibrary.folderSelectedCount",{count:o.size})})]}),f.length>0?t.jsx("div",{className:"prompt-import-dialog__folder-list",children:f.map(e=>t.jsxs("label",{className:"prompt-import-dialog__folder-file",children:[t.jsx("input",{type:"checkbox",checked:o.has(e.path),onChange:r=>{p(j=>{const m=new Set(j);return r.target.checked?m.add(e.path):m.delete(e.path),m})}}),t.jsxs("span",{children:[t.jsx("strong",{children:e.name}),t.jsx("small",{children:e.path})]}),t.jsxs("em",{children:[Math.ceil(e.sizeBytes/1024)," KB"]})]},e.path))}):null,x.length>0?t.jsx("div",{className:"prompt-import-dialog__folder-warning",children:x.slice(0,3).join(" · ")}):null]})}export{F as PromptImportFolderSection};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PromptImportDialog-CjHiCEo9.js","assets/index-XXtoj9ME.js","assets/index-waPOg2eb.css"])))=>i.map(i=>d[i]);
2
- import{u as v,aq as R,j as e,ar as j,a as i,b as s,S as $,aa as A}from"./index-XXtoj9ME.js";function z({prompt:r,onClose:d,onLoad:c,onInsert:t,onDelete:b,onToggleFavorite:l}){const{t:o}=v(),n=R(!0,d),m=async()=>{try{await navigator.clipboard.writeText(r.text)}catch{}};return e.jsxs("div",{className:"prompt-detail-modal",role:"presentation",children:[e.jsx("div",{className:"prompt-detail-modal__backdrop",onClick:d}),e.jsxs("div",{ref:n,className:"prompt-detail-modal__content",role:"dialog","aria-modal":"true","aria-labelledby":"prompt-detail-title",tabIndex:-1,children:[e.jsxs("div",{className:"prompt-detail-modal__header",children:[e.jsx("h2",{id:"prompt-detail-title",className:"prompt-detail-modal__title",children:r.name||o("promptLibrary.untitled")}),e.jsx("button",{className:"prompt-detail-modal__close",onClick:d,"aria-label":o("common.close"),children:"×"})]}),e.jsxs("div",{className:"prompt-detail-modal__body",children:[e.jsx("div",{className:"prompt-detail-modal__label",children:o("promptLibrary.content")}),e.jsx("div",{className:"prompt-detail-modal__prompt",children:r.text}),r.tags.length>0&&e.jsxs("div",{className:"prompt-detail-modal__tags",children:[e.jsx("div",{className:"prompt-detail-modal__label",children:o("promptLibrary.tags")}),e.jsx("div",{className:"prompt-detail-modal__tag-list",children:r.tags.map(p=>e.jsxs("span",{className:"prompt-detail-modal__tag",children:["#",p]},p))})]})]}),e.jsxs("div",{className:"prompt-detail-modal__footer",children:[e.jsx("button",{className:"prompt-detail-modal__load",onClick:c,children:o("promptLibrary.load")}),e.jsx("button",{className:"prompt-detail-modal__copy",onClick:m,children:o("promptLibrary.copy")}),e.jsxs("button",{className:"prompt-detail-modal__insert",onClick:t,children:["+ ",o("promptLibrary.insert")]}),e.jsxs("button",{className:`prompt-detail-modal__favorite${r.isFavorite?" prompt-detail-modal__favorite--on":""}`,onClick:l,"aria-pressed":r.isFavorite,children:[e.jsx(j,{}),r.isFavorite?o("promptLibrary.unfavorite"):o("promptLibrary.favorite")]}),e.jsx("button",{className:"prompt-detail-modal__delete",onClick:b,children:o("common.delete")})]})]})]})}function M({prompt:r,onLoad:d,onInsert:c,onDelete:t,onToggleFavorite:b}){const{t:l}=v(),[o,n]=i.useState(!1),m=r.text.length>45?r.text.slice(0,45)+"...":r.text;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"prompt-library-row",onClick:()=>n(!0),children:[e.jsxs("div",{className:"prompt-library-row__main",children:[e.jsx("div",{className:"prompt-library-row__title",children:r.name||l("promptLibrary.untitled")}),e.jsx("div",{className:"prompt-library-row__preview",children:m})]}),e.jsxs("div",{className:"prompt-library-row__actions",children:[e.jsx("button",{className:"prompt-library-row__insert",onClick:p=>{p.stopPropagation(),c()},title:l("promptLibrary.insert"),"aria-label":l("promptLibrary.insert"),children:"+"}),e.jsx("button",{className:`prompt-library-row__star${r.isFavorite?" prompt-library-row__star--on":""}`,onClick:p=>{p.stopPropagation(),b()},"aria-label":r.isFavorite?l("promptLibrary.unfavorite"):l("promptLibrary.favorite"),"aria-pressed":r.isFavorite,children:e.jsx(j,{})}),e.jsx("span",{className:"prompt-library-row__chevron",children:"›"})]})]}),o&&e.jsx(z,{prompt:r,onClose:()=>n(!1),onLoad:()=>{d(),n(!1)},onInsert:()=>{c(),n(!1)},onDelete:t,onToggleFavorite:b})]})}const q=i.lazy(()=>A(()=>import("./PromptImportDialog-CjHiCEo9.js"),__vite__mapDeps([0,1,2])).then(r=>({default:r.PromptImportDialog})));function B({variant:r="overlay",forceOpen:d=!1,onRequestClose:c}){const{t}=v(),b=s(a=>a.promptLibraryOpen),l=s(a=>a.togglePromptLibrary),o=s(a=>a.promptLibrary),n=s(a=>a.promptLibraryLoading),m=s(a=>a.loadPromptLibrary),p=s(a=>a.deletePromptFromLibrary),w=s(a=>a.togglePromptFavorite),k=s(a=>a.setPrompt),L=s(a=>a.insertPromptToComposer),F=s(a=>a.clearInsertedPrompts),N=s(a=>a.showToast),[y,I]=i.useState(""),[x,S]=i.useState(!1),[O,f]=i.useState(!1),[g,C]=i.useState(!1),h=d||b,_=c??l;i.useEffect(()=>{h&&m()},[h,m]);const D=i.useCallback(a=>{L({id:a.id,name:a.name||t("promptLibrary.untitled"),text:a.text}),N(t("promptLibrary.inserted")),_()},[_,L,N,t]);if(!h)return null;const P=o.prompts.filter(a=>{if(x&&!a.isFavorite)return!1;if(!y.trim())return!0;const u=y.toLowerCase();return a.name.toLowerCase().includes(u)||a.text.toLowerCase().includes(u)||a.tags.some(E=>E.toLowerCase().includes(u))}),T=e.jsxs("div",{className:"prompt-library-panel__drawer",children:[e.jsxs("div",{className:"prompt-library-panel__header",children:[e.jsx("h3",{children:t("promptLibrary.title")}),e.jsxs("div",{className:"prompt-library-panel__actions",children:[e.jsx("button",{className:"prompt-library-panel__add",onClick:()=>f(a=>!a),title:t("promptLibrary.addNew"),"aria-label":t("promptLibrary.addNew"),children:"+"}),e.jsx("button",{className:"prompt-library-panel__import",onClick:()=>C(!0),title:t("promptLibrary.importFiles"),"aria-label":t("promptLibrary.importFiles"),children:t("promptLibrary.import")}),e.jsx("button",{onClick:_,"aria-label":t("common.close"),children:"×"})]}),O&&e.jsx($,{text:"",onClose:()=>f(!1)})]}),e.jsxs("div",{className:"prompt-library-panel__search",children:[e.jsx("input",{type:"text",placeholder:t("promptLibrary.search"),value:y,onChange:a=>I(a.target.value)}),e.jsxs("button",{type:"button",className:`prompt-library-panel__filter-toggle${x?" active":""}`,"aria-pressed":x,title:t("promptLibrary.favorites"),onClick:()=>S(a=>!a),children:[e.jsx(j,{}),e.jsx("span",{children:t("promptLibrary.favorites")})]})]}),n?e.jsx("div",{className:"prompt-library-panel__loading",children:t("common.loading")}):e.jsx("div",{className:"prompt-library-panel__list",children:P.length===0?e.jsx("div",{className:"prompt-library-panel__empty",children:t("promptLibrary.empty")}):P.map(a=>e.jsx(M,{prompt:a,onLoad:()=>{F(),k(a.text),l()},onInsert:()=>D(a),onDelete:()=>p(a.id),onToggleFavorite:()=>w(a.id)},a.id))}),g?e.jsx(i.Suspense,{fallback:null,children:e.jsx(q,{open:g,onClose:()=>C(!1),onImported:m})}):null]});return e.jsxs("div",{className:`prompt-library-panel prompt-library-panel--${r}`,children:[r==="overlay"?e.jsx("div",{className:"prompt-library-panel__backdrop",onClick:_}):null,T]})}export{B as PromptLibraryPanel};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PromptImportDialog-D4QYbRfH.js","assets/index-CxEuSZMC.js","assets/index-C0nfanMr.css"])))=>i.map(i=>d[i]);
2
+ import{u as v,aq as R,j as e,ar as j,a as i,b as s,S as $,aa as A}from"./index-CxEuSZMC.js";function z({prompt:r,onClose:d,onLoad:c,onInsert:t,onDelete:b,onToggleFavorite:l}){const{t:o}=v(),n=R(!0,d),m=async()=>{try{await navigator.clipboard.writeText(r.text)}catch{}};return e.jsxs("div",{className:"prompt-detail-modal",role:"presentation",children:[e.jsx("div",{className:"prompt-detail-modal__backdrop",onClick:d}),e.jsxs("div",{ref:n,className:"prompt-detail-modal__content",role:"dialog","aria-modal":"true","aria-labelledby":"prompt-detail-title",tabIndex:-1,children:[e.jsxs("div",{className:"prompt-detail-modal__header",children:[e.jsx("h2",{id:"prompt-detail-title",className:"prompt-detail-modal__title",children:r.name||o("promptLibrary.untitled")}),e.jsx("button",{className:"prompt-detail-modal__close",onClick:d,"aria-label":o("common.close"),children:"×"})]}),e.jsxs("div",{className:"prompt-detail-modal__body",children:[e.jsx("div",{className:"prompt-detail-modal__label",children:o("promptLibrary.content")}),e.jsx("div",{className:"prompt-detail-modal__prompt",children:r.text}),r.tags.length>0&&e.jsxs("div",{className:"prompt-detail-modal__tags",children:[e.jsx("div",{className:"prompt-detail-modal__label",children:o("promptLibrary.tags")}),e.jsx("div",{className:"prompt-detail-modal__tag-list",children:r.tags.map(p=>e.jsxs("span",{className:"prompt-detail-modal__tag",children:["#",p]},p))})]})]}),e.jsxs("div",{className:"prompt-detail-modal__footer",children:[e.jsx("button",{className:"prompt-detail-modal__load",onClick:c,children:o("promptLibrary.load")}),e.jsx("button",{className:"prompt-detail-modal__copy",onClick:m,children:o("promptLibrary.copy")}),e.jsxs("button",{className:"prompt-detail-modal__insert",onClick:t,children:["+ ",o("promptLibrary.insert")]}),e.jsxs("button",{className:`prompt-detail-modal__favorite${r.isFavorite?" prompt-detail-modal__favorite--on":""}`,onClick:l,"aria-pressed":r.isFavorite,children:[e.jsx(j,{}),r.isFavorite?o("promptLibrary.unfavorite"):o("promptLibrary.favorite")]}),e.jsx("button",{className:"prompt-detail-modal__delete",onClick:b,children:o("common.delete")})]})]})]})}function M({prompt:r,onLoad:d,onInsert:c,onDelete:t,onToggleFavorite:b}){const{t:l}=v(),[o,n]=i.useState(!1),m=r.text.length>45?r.text.slice(0,45)+"...":r.text;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"prompt-library-row",onClick:()=>n(!0),children:[e.jsxs("div",{className:"prompt-library-row__main",children:[e.jsx("div",{className:"prompt-library-row__title",children:r.name||l("promptLibrary.untitled")}),e.jsx("div",{className:"prompt-library-row__preview",children:m})]}),e.jsxs("div",{className:"prompt-library-row__actions",children:[e.jsx("button",{className:"prompt-library-row__insert",onClick:p=>{p.stopPropagation(),c()},title:l("promptLibrary.insert"),"aria-label":l("promptLibrary.insert"),children:"+"}),e.jsx("button",{className:`prompt-library-row__star${r.isFavorite?" prompt-library-row__star--on":""}`,onClick:p=>{p.stopPropagation(),b()},"aria-label":r.isFavorite?l("promptLibrary.unfavorite"):l("promptLibrary.favorite"),"aria-pressed":r.isFavorite,children:e.jsx(j,{})}),e.jsx("span",{className:"prompt-library-row__chevron",children:"›"})]})]}),o&&e.jsx(z,{prompt:r,onClose:()=>n(!1),onLoad:()=>{d(),n(!1)},onInsert:()=>{c(),n(!1)},onDelete:t,onToggleFavorite:b})]})}const q=i.lazy(()=>A(()=>import("./PromptImportDialog-D4QYbRfH.js"),__vite__mapDeps([0,1,2])).then(r=>({default:r.PromptImportDialog})));function B({variant:r="overlay",forceOpen:d=!1,onRequestClose:c}){const{t}=v(),b=s(a=>a.promptLibraryOpen),l=s(a=>a.togglePromptLibrary),o=s(a=>a.promptLibrary),n=s(a=>a.promptLibraryLoading),m=s(a=>a.loadPromptLibrary),p=s(a=>a.deletePromptFromLibrary),w=s(a=>a.togglePromptFavorite),k=s(a=>a.setPrompt),L=s(a=>a.insertPromptToComposer),F=s(a=>a.clearInsertedPrompts),N=s(a=>a.showToast),[y,I]=i.useState(""),[x,S]=i.useState(!1),[O,f]=i.useState(!1),[g,C]=i.useState(!1),h=d||b,_=c??l;i.useEffect(()=>{h&&m()},[h,m]);const D=i.useCallback(a=>{L({id:a.id,name:a.name||t("promptLibrary.untitled"),text:a.text}),N(t("promptLibrary.inserted")),_()},[_,L,N,t]);if(!h)return null;const P=o.prompts.filter(a=>{if(x&&!a.isFavorite)return!1;if(!y.trim())return!0;const u=y.toLowerCase();return a.name.toLowerCase().includes(u)||a.text.toLowerCase().includes(u)||a.tags.some(E=>E.toLowerCase().includes(u))}),T=e.jsxs("div",{className:"prompt-library-panel__drawer",children:[e.jsxs("div",{className:"prompt-library-panel__header",children:[e.jsx("h3",{children:t("promptLibrary.title")}),e.jsxs("div",{className:"prompt-library-panel__actions",children:[e.jsx("button",{className:"prompt-library-panel__add",onClick:()=>f(a=>!a),title:t("promptLibrary.addNew"),"aria-label":t("promptLibrary.addNew"),children:"+"}),e.jsx("button",{className:"prompt-library-panel__import",onClick:()=>C(!0),title:t("promptLibrary.importFiles"),"aria-label":t("promptLibrary.importFiles"),children:t("promptLibrary.import")}),e.jsx("button",{onClick:_,"aria-label":t("common.close"),children:"×"})]}),O&&e.jsx($,{text:"",onClose:()=>f(!1)})]}),e.jsxs("div",{className:"prompt-library-panel__search",children:[e.jsx("input",{type:"text",placeholder:t("promptLibrary.search"),value:y,onChange:a=>I(a.target.value)}),e.jsxs("button",{type:"button",className:`prompt-library-panel__filter-toggle${x?" active":""}`,"aria-pressed":x,title:t("promptLibrary.favorites"),onClick:()=>S(a=>!a),children:[e.jsx(j,{}),e.jsx("span",{children:t("promptLibrary.favorites")})]})]}),n?e.jsx("div",{className:"prompt-library-panel__loading",children:t("common.loading")}):e.jsx("div",{className:"prompt-library-panel__list",children:P.length===0?e.jsx("div",{className:"prompt-library-panel__empty",children:t("promptLibrary.empty")}):P.map(a=>e.jsx(M,{prompt:a,onLoad:()=>{F(),k(a.text),l()},onInsert:()=>D(a),onDelete:()=>p(a.id),onToggleFavorite:()=>w(a.id)},a.id))}),g?e.jsx(i.Suspense,{fallback:null,children:e.jsx(q,{open:g,onClose:()=>C(!1),onImported:m})}):null]});return e.jsxs("div",{className:`prompt-library-panel prompt-library-panel--${r}`,children:[r==="overlay"?e.jsx("div",{className:"prompt-library-panel__backdrop",onClick:_}):null,T]})}export{B as PromptLibraryPanel};
@@ -1 +1 @@
1
- import{a as d,u as C,j as e,t as I,v as ee,x as se,y as te,z as ne,b as N,I as ae,A as q,V as R,B as G,C as ie,O as D,G as U,D as re,U as le,E as ce,F as oe,H as de,J as ue,K as ge,L as he,W as pe}from"./index-XXtoj9ME.js";function me(){const[s,a]=d.useState(null);return d.useEffect(()=>{let r=!1;return(async()=>{try{const n=await fetch("/api/agy/status");if(r)return;const h=await n.json();a(h)}catch{r||a({installed:!1})}})(),()=>{r=!0}},[]),s}function O({provider:s,label:a,placeholder:r,maskedKey:t,source:n,configured:h,onSaved:u}){const{t:c}=C(),[x,p]=d.useState(""),[m,j]=d.useState(!1),[b,g]=d.useState(!1),[i,f]=d.useState(null),[y,k]=d.useState(!1),S=n==="env",w=x.trim().length>0,K=h&&!m&&!w,A=d.useCallback(async()=>{if(w){g(!0),f(null),k(!1);try{const v=await(await fetch(`/api/keys/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:x.trim()})})).json();v.ok?(p(""),j(!1),k(!0),u(),setTimeout(()=>k(!1),3e3)):f(v.error||c("settings.apiKeys.saveFailed"))}catch{f(c("settings.apiKeys.networkError"))}finally{g(!1)}}},[x,s,w,u,c]),T=d.useCallback(async()=>{try{if(!(await fetch(`/api/keys/${s}`,{method:"DELETE"})).ok){f(c("settings.apiKeys.removeFailed"));return}p(""),j(!1),u()}catch{f(c("settings.apiKeys.networkError"))}},[s,u,c]),E=d.useCallback(()=>{h&&j(!0)},[h]),$=d.useCallback(()=>{w||j(!1)},[w]);return e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("p",{className:"settings-eyebrow",children:c(S?"settings.apiKeys.envSource":"settings.apiKeys.configSource")}),e.jsx("h4",{children:a}),e.jsxs("div",{className:"api-key-input-group",children:[K?e.jsx("input",{type:"text",className:"api-key-input is-masked",value:t||"●●●●●●",readOnly:!0,onFocus:E,onClick:E}):e.jsx("input",{type:"password",className:`api-key-input${i?" is-invalid":""}`,placeholder:r,value:x,onChange:l=>{p(l.target.value),f(null)},onBlur:$,readOnly:!1,autoComplete:"off",autoFocus:m,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":"true","data-form-type":"other"}),e.jsxs("div",{className:"api-key-actions",children:[e.jsx("button",{type:"button",className:"settings-action-btn",onClick:A,disabled:!w||b,children:c(b?"settings.apiKeys.saving":y?"settings.apiKeys.saved":"settings.apiKeys.save")}),h&&!S&&e.jsx("button",{type:"button",className:"settings-action-btn settings-action-btn--danger",onClick:T,children:c("settings.apiKeys.remove")})]})]}),i&&e.jsx("p",{className:"api-key-error",children:i})]}),e.jsxs("div",{className:`settings-status${h?" is-ok":""}`,children:[e.jsx("span",{"aria-hidden":"true"}),c(h?"settings.apiKeys.status.valid":"settings.apiKeys.status.notConfigured")]})]})}function fe({configured:s,maskedKey:a,source:r,onSaved:t}){const{t:n}=C(),[h,u]=d.useState(""),[c,x]=d.useState(!1),[p,m]=d.useState(!1),[j,b]=d.useState(null),[g,i]=d.useState(!1),f=r==="env",y=h.trim().length>0,k=s&&!c&&!y,S=d.useCallback(async()=>{if(y){m(!0),b(null),i(!1);try{const E=await(await fetch("/api/keys/vertex",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({serviceAccountJson:h.trim()})})).json();E.ok?(u(""),x(!1),i(!0),t(),setTimeout(()=>i(!1),3e3)):b(E.error||n("settings.apiKeys.saveFailed"))}catch{b(n("settings.apiKeys.networkError"))}finally{m(!1)}}},[h,y,t,n]),w=d.useCallback(async()=>{try{if(!(await fetch("/api/keys/vertex",{method:"DELETE"})).ok){b(n("settings.apiKeys.removeFailed"));return}u(""),x(!1),t()}catch{b(n("settings.apiKeys.networkError"))}},[t,n]),K=d.useCallback(()=>{s&&!f&&x(!0)},[s,f]),A=d.useCallback(()=>{y||x(!1)},[y]);return e.jsxs("div",{className:"vertex-json-section",children:[e.jsx("p",{className:"settings-eyebrow",children:n(f?"settings.apiKeys.envSource":"settings.apiKeys.configSource")}),s&&a&&e.jsx("p",{className:"vertex-project-id",children:a}),k?e.jsx("textarea",{className:"vertex-json-textarea is-masked",value:`●●● (${n("settings.apiKeys.configuredReplace")})`,readOnly:!0,onFocus:K,onClick:K}):e.jsx("textarea",{className:`vertex-json-textarea${j?" is-invalid":""}`,placeholder:n("settings.apiKeys.vertex.placeholder"),value:h,onChange:T=>{u(T.target.value),b(null)},onBlur:A,readOnly:f,autoFocus:c,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":"true","data-form-type":"other"}),e.jsxs("div",{className:"api-key-actions",style:{marginTop:8},children:[!f&&e.jsx("button",{type:"button",className:"settings-action-btn",onClick:S,disabled:!y||p,children:n(p?"settings.apiKeys.saving":g?"settings.apiKeys.saved":"settings.apiKeys.save")}),s&&!f&&e.jsx("button",{type:"button",className:"settings-action-btn settings-action-btn--danger",onClick:w,children:n("settings.apiKeys.remove")})]}),j&&e.jsx("p",{className:"api-key-error",children:j}),e.jsxs("div",{className:`settings-status${s?" is-ok":""}`,style:{marginTop:8},children:[e.jsx("span",{"aria-hidden":"true"}),n(s?"settings.apiKeys.status.valid":"settings.apiKeys.status.notConfigured")]})]})}function xe({keyStatus:s,onSaved:a}){const{t:r}=C(),t=s.vertex?.configured??!1,n=s.gemini?.configured??!1,h=s.geminiAuthMode==="vertex"?"vertex":"apikey",[u,c]=d.useState(h),[x,p]=d.useState(!1);d.useEffect(()=>{x||c(h)},[h,x]);const m=j=>{p(!0),c(j),fetch("/api/keys/gemini-auth-mode",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:j})}).catch(()=>{})};return e.jsxs("div",{className:"gemini-key-section",children:[e.jsxs("div",{className:"gemini-key-section__header",children:[e.jsx("h5",{children:r("settings.apiKeys.gemini.label")}),e.jsx(I,{value:u,onChange:m,items:[{value:"apikey",label:r("settings.apiKeys.vertex.authModeApiKey")},{value:"vertex",label:r("settings.apiKeys.vertex.authModeVertex")}]})]}),u==="apikey"?e.jsx(O,{provider:"gemini",label:"",placeholder:r("settings.apiKeys.gemini.placeholder"),maskedKey:s.gemini?.maskedKey??null,source:s.gemini?.source??"none",configured:n,onSaved:a}):e.jsx(fe,{configured:t,maskedKey:s.vertex?.maskedKey??null,source:s.vertex?.source??"none",onSaved:a})]})}function ye(s){return s>80?"var(--error, #e53935)":s>50?"var(--warning, #f59e0b)":"var(--info, #3b82f6)"}function je(s){if(!s)return"";const a=new Date(s);return`${a.getMonth()+1}/${a.getDate()} ${String(a.getHours()).padStart(2,"0")}:${String(a.getMinutes()).padStart(2,"0")}`}function J({window:s}){const a=je(s.resetsAt);return e.jsxs("div",{className:"quota-bar",children:[e.jsx("span",{className:"quota-bar__label",children:s.label}),e.jsx("div",{className:"quota-bar__track",children:e.jsx("div",{className:"quota-bar__fill",style:{width:`${Math.min(s.percent,100)}%`,background:ye(s.percent)}})}),e.jsxs("span",{className:"quota-bar__pct",children:[s.percent,"%"]}),a&&e.jsx("span",{className:"quota-bar__reset",children:a})]})}function Q({provider:s,onComplete:a}){const{t:r}=C(),[t,n]=d.useState({phase:"idle"}),[h,u]=d.useState(!1),c=d.useRef(!1),x=d.useCallback(async()=>{if(!c.current){c.current=!0,n({phase:"starting"});try{const p=await fetch("/api/auth/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:s})});if(!p.ok){const j=await p.json().catch(()=>({error:r("settings.quota.switchFailed")}));n({phase:"error",error:j.error||`HTTP ${p.status}`});return}const m=await p.json();n({phase:"waiting",...m}),window.open(m.verificationUrl,"_blank")}catch(p){c.current=!1,n({phase:"error",error:p.message})}}},[s]);return d.useEffect(()=>{if(t.phase!=="waiting"||!t.sessionId)return;let p=!1;const m=async()=>{try{const g=await(await fetch(`/api/auth/switch/${t.sessionId}`)).json();if(p)return;if(g.status==="complete"){n({phase:"complete"}),setTimeout(a,1e3);return}if(g.status==="error"||g.status==="expired"){n({phase:"error",error:g.error||g.status});return}}catch{}p||setTimeout(m,3e3)},j=setTimeout(m,3e3);return()=>{p=!0,clearTimeout(j)}},[t.phase,t.sessionId,a]),t.phase==="idle"?e.jsx("button",{type:"button",className:"settings-action-btn",style:{width:"100%",marginTop:"6px"},onClick:x,children:r("settings.quota.switchAccount",{provider:s==="grok"?"Grok":"Codex"})}):t.phase==="starting"?e.jsx("div",{className:"quota-card__hint",style:{textAlign:"center",marginTop:"6px"},children:r("settings.quota.startingLogin")}):t.phase==="waiting"?e.jsxs("div",{style:{marginTop:"6px",padding:"8px",background:"var(--surface, #f5f5f5)",borderRadius:"6px",fontSize:"12px"},children:[e.jsx("div",{style:{textAlign:"center",marginBottom:"4px"},children:r("settings.quota.enterCode")}),e.jsx("div",{style:{textAlign:"center",fontSize:"18px",fontWeight:700,fontFamily:"monospace",letterSpacing:"2px",margin:"6px 0"},children:t.userCode}),t.verificationUrl&&e.jsxs("div",{style:{display:"flex",gap:"4px",margin:"6px 0"},children:[e.jsx("button",{type:"button",className:"settings-action-btn",style:{flex:1,fontSize:"11px"},onClick:()=>{c.current=!1,x()},children:r("settings.quota.retry")}),e.jsx("button",{type:"button",className:"settings-action-btn",style:{flex:1,fontSize:"11px"},onClick:()=>{navigator.clipboard?.writeText(t.verificationUrl).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)})},children:r(h?"settings.quota.copied":"settings.quota.copyLink")})]}),e.jsx("div",{style:{textAlign:"center",color:"var(--text-dim, #888)",fontSize:"11px"},children:r("settings.quota.waitingApproval")})]}):t.phase==="complete"?e.jsx("div",{className:"quota-card__hint",style:{textAlign:"center",marginTop:"6px",color:"var(--success, #22c55e)"},children:r("settings.quota.switchComplete")}):t.phase==="error"?e.jsxs("div",{style:{marginTop:"6px"},children:[e.jsx("div",{className:"quota-card__hint",style:{color:"var(--error, #e53935)",marginBottom:"4px"},children:t.error||r("settings.quota.switchFailed")}),e.jsx("button",{type:"button",className:"settings-action-btn",style:{width:"100%",fontSize:"11px"},onClick:()=>{c.current=!1,n({phase:"idle"})},children:r("settings.quota.tryAgain")})]}):null}function ve(){const[s,a]=d.useState(null),[r,t]=d.useState(!0),n=d.useCallback(()=>{t(!0),fetch("/api/quota").then(h=>h.json()).then(a).catch(()=>a(null)).finally(()=>t(!1))},[]);return d.useEffect(()=>{const h=setTimeout(n,1500);return()=>clearTimeout(h)},[n]),{data:s,loading:r,refreshQuota:n}}function be({data:s,loading:a,onRefresh:r}){const{t}=C(),n=s?.codex,h=n?.windows&&n.windows.length>0,u=n?.account?[n.account.email,n.account.plan].filter(Boolean).join(" · "):null;return e.jsxs("div",{className:"quota-card",children:[u?e.jsx("div",{className:"quota-card__header",children:e.jsx("span",{className:"quota-card__account",children:u})}):null,a?e.jsx("span",{className:"quota-card__loading",children:t("common.loading")}):h?n.windows.map(c=>e.jsx(J,{window:c},c.label)):n?.authenticated===!1?e.jsx("span",{className:"quota-card__hint",children:t("settings.quota.codexNotLoggedIn")}):n?.error?e.jsx("span",{className:"quota-card__hint",children:t("settings.quota.fetchError")}):e.jsx("span",{className:"quota-card__hint",children:t("settings.quota.noData")}),e.jsx(Q,{provider:"codex",onComplete:r})]})}function _e({data:s,loading:a,onRefresh:r}){const{t}=C(),n=s?.grok,h=n?.windows&&n.windows.length>0,u=n?.account?[n.account.email,n.account.plan].filter(Boolean).join(" · "):null;return e.jsxs("div",{className:"quota-card",children:[u||n?.billing?e.jsxs("div",{className:"quota-card__header",style:{display:"flex",alignItems:"center"},children:[u&&e.jsx("span",{className:"quota-card__account",children:u}),n?.billing&&e.jsxs("span",{style:{marginLeft:"auto",fontSize:"11px",color:"var(--text-dim, #888)",whiteSpace:"nowrap"},children:["$",n.billing.usedUsd.toFixed(1),"/$",n.billing.limitUsd]})]}):null,a?e.jsx("span",{className:"quota-card__loading",children:t("common.loading")}):h?n.windows.map(c=>e.jsx(J,{window:c},c.label)):n?.authenticated===!1?e.jsx("span",{className:"quota-card__hint",children:t("settings.quota.codexNotLoggedIn")}):e.jsx("a",{href:"https://grok.com/?_s=usage",target:"_blank",rel:"noopener noreferrer",className:"settings-action-btn",children:t("settings.quota.grokUsageLink")}),e.jsx(Q,{provider:"grok",onComplete:r})]})}function H(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a5.998 5.998 0 0 0-3.998 2.9 6.049 6.049 0 0 0 .743 7.097 5.98 5.98 0 0 0 .51 4.911 6.051 6.051 0 0 0 6.515 2.9A5.985 5.985 0 0 0 13.26 24a6.056 6.056 0 0 0 5.772-4.206 5.99 5.99 0 0 0 3.997-2.9 6.056 6.056 0 0 0-.747-7.073zM13.26 22.43a4.476 4.476 0 0 1-2.876-1.04l.141-.081 4.779-2.758a.795.795 0 0 0 .392-.681v-6.737l2.02 1.168a.071.071 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494zM3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.771.771 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646zM2.34 7.896a4.485 4.485 0 0 1 2.366-1.973V11.6a.766.766 0 0 0 .388.676l5.815 3.355-2.02 1.168a.076.076 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855l-5.833-3.387L15.119 7.2a.076.076 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667zm2.01-3.023l-.141-.085-4.774-2.782a.776.776 0 0 0-.785 0L9.409 9.23V6.897a.066.066 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135l-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.795.795 0 0 0-.393.681zm1.097-2.365l2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.612-1.5z"})})}function we(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd","aria-hidden":"true",children:e.jsx("path",{d:"M9.27 15.29l7.978-5.897c.391-.29.95-.177 1.137.272.98 2.369.542 5.215-1.41 7.169-1.951 1.954-4.667 2.382-7.149 1.406l-2.711 1.257c3.889 2.661 8.611 2.003 11.562-.953 2.341-2.344 3.066-5.539 2.388-8.42l.006.007c-.983-4.232.242-5.924 2.75-9.383.06-.082.12-.164.179-.248l-3.301 3.305v-.01L9.267 15.292M7.623 16.723c-2.792-2.67-2.31-6.801.071-9.184 1.761-1.763 4.647-2.483 7.166-1.425l2.705-1.25a7.808 7.808 0 00-1.829-1A8.975 8.975 0 005.984 5.83c-2.533 2.536-3.33 6.436-1.962 9.764 1.022 2.487-.653 4.246-2.34 6.022-.599.63-1.199 1.259-1.682 1.925l7.62-6.815"})})}function Ne(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M12 24A14.304 14.304 0 0 0 0 12 14.304 14.304 0 0 0 12 0a14.305 14.305 0 0 0 12 12 14.305 14.305 0 0 0-12 12"})})}function V(s,a){return s(a==="ready"?"settings.account.status.ready":a==="auth_required"?"settings.account.status.authRequired":a==="starting"?"settings.account.status.starting":a==="offline"?"settings.account.status.offline":a==="no_image_model"?"settings.account.status.noImageModel":a==="error"?"settings.account.status.error":"settings.account.status.checking")}function W(s){return s==="ready"?"ok":s==="error"||s==="offline"?"err":"warn"}function ke(){const{t:s}=C(),a=ee(),r=se(),t=me(),{data:n,error:h}=te(),{data:u,mutate:c}=ne(),x=ve(),[p,m]=d.useState(!1),j=n?.apiKeySource==="env"||n?.apiKeySource==="config"||n?.apiKeyValid===!0,b=n?.apiKeySource==="config"?s("settings.account.apiSourceConfig"):s("settings.account.apiSourceEnv"),g=n?.apiKeyValid===!0;return e.jsxs(e.Fragment,{children:[e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__brand",children:e.jsx(H,{})}),e.jsx("h4",{children:s("settings.account.oauthTitle")}),e.jsx("span",{className:"provider-card__eyebrow",children:s("settings.account.primaryEyebrow")}),e.jsx("span",{className:`provider-chip provider-chip--${W(a?.status)}`,children:V(s,a?.status)})]}),e.jsx("div",{className:"settings-row__copy",children:e.jsx("p",{children:s("settings.account.oauthBody")})}),e.jsx(be,{data:x.data,loading:x.loading,onRefresh:x.refreshQuota})]}),j?e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__brand",children:e.jsx(H,{})}),e.jsx("h4",{children:s("settings.account.apiTitle")}),e.jsx("span",{className:"provider-card__eyebrow",children:b}),e.jsx("span",{className:`provider-chip provider-chip--${h?"err":g?"ok":"warn"}`,children:s(h?"settings.account.apiUnknown":g?"settings.account.apiReady":"settings.account.apiUnavailable")})]}),e.jsx("div",{className:"settings-row__copy",children:e.jsx("p",{children:s("settings.account.apiBody")})})]}):null,e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__brand",children:e.jsx(we,{})}),e.jsx("h4",{children:s("settings.account.grokTitle")}),e.jsx("span",{className:"provider-card__eyebrow",children:s("settings.account.grokEyebrow")}),e.jsx("span",{className:`provider-chip provider-chip--${W(r?.status)}`,children:V(s,r?.status)})]}),e.jsx("div",{className:"settings-row__copy",children:e.jsx("p",{children:s("settings.account.grokBody")})}),e.jsx(_e,{data:x.data,loading:x.loading,onRefresh:x.refreshQuota})]}),e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__brand",children:e.jsx(Ne,{})}),e.jsx("h4",{children:s("settings.account.agyTitle")}),e.jsx("span",{className:"provider-card__eyebrow",children:s("settings.account.agyEyebrow")}),e.jsx("span",{className:`provider-chip provider-chip--${t?.installed?"ok":"warn"}`,children:t?.installed?s("settings.account.agyInstalled"):s("settings.account.agyMissing")})]}),e.jsxs("div",{className:"settings-row__copy",children:[t?.installed?e.jsx("p",{children:s("settings.account.agyInstalledBody")}):e.jsxs("p",{children:[s("settings.account.agyMissingBody")," ",e.jsx("a",{href:"https://antigravity.google/docs/cli-install",target:"_blank",rel:"noopener noreferrer",children:s("settings.account.agyMissingLink")})]}),e.jsx("p",{style:{fontSize:"12px",color:"var(--text-dim, #888)",marginTop:"4px"},children:s("settings.account.agyFineprint")})]})]}),u&&e.jsxs("article",{className:"settings-row settings-accordion",children:[e.jsxs("button",{type:"button",className:"settings-accordion__trigger",onClick:()=>m(!p),children:[e.jsx("h4",{children:s("settings.apiKeys.accordionTitle")}),e.jsx("span",{className:`settings-accordion__arrow${p?" is-open":""}`,children:"▼"})]}),p&&e.jsxs("div",{className:"settings-accordion__body",children:[e.jsx(O,{provider:"openai",label:s("settings.apiKeys.openai.label"),placeholder:s("settings.apiKeys.openai.placeholder"),maskedKey:u.openai?.maskedKey??null,source:u.openai?.source??"none",configured:u.openai?.configured??!1,onSaved:c}),e.jsx(O,{provider:"xai",label:s("settings.apiKeys.xai.label"),placeholder:s("settings.apiKeys.xai.placeholder"),maskedKey:u.xai?.maskedKey??null,source:u.xai?.source??"none",configured:u.xai?.configured??!1,onSaved:c}),e.jsx(O,{provider:"atlascloud",label:s("settings.apiKeys.atlascloud.label"),placeholder:s("settings.apiKeys.atlascloud.placeholder"),maskedKey:u.atlascloud?.maskedKey??null,source:u.atlascloud?.source??"none",configured:u.atlascloud?.configured??!1,onSaved:c}),e.jsx(O,{provider:"minimax",label:s("settings.apiKeys.minimax.label"),placeholder:s("settings.apiKeys.minimax.placeholder"),maskedKey:u.minimax?.maskedKey??null,source:u.minimax?.source??"none",configured:u.minimax?.configured??!1,onSaved:c}),e.jsx(xe,{keyStatus:u,onSaved:c})]})]})]})}function Se({variant:s}){const{t:a}=C(),[r,t]=d.useState(!1),n=d.useRef(null),h=d.useRef(null),u=d.useRef(null),c=d.useRef([]),[x,p]=d.useState({top:0,left:12,width:280,maxHeight:480}),m=N(l=>l.imageModel),j=N(l=>l.provider),b=N(l=>l.setImageModel),g=N(l=>l.setProvider),i=N(l=>l.videoModelSelected),f=N(l=>l.selectVideoModel),y=N(l=>l.reasoningEffort),k=N(l=>l.setReasoningEffort),S=s==="settings"?"settings-image-model":"sidebar-image-model",w=ae,K=w.find(l=>l.value===m&&(!l.providerHint||l.providerHint===j))??w.find(l=>l.value===m)??w[0],A=q.find(l=>l.value===y)??q[0],T=()=>c.current.filter(l=>l!==null),E=l=>{const v=T();if(v.length===0)return;const o=(l+v.length)%v.length;v[o]?.focus()},$=l=>{const v=T();if(v.length===0)return;const o=v.findIndex(L=>L===document.activeElement),_=v.length-1;if(l.key==="ArrowDown"||l.key==="ArrowRight"){l.preventDefault(),E(o>=0?o+1:0);return}if(l.key==="ArrowUp"||l.key==="ArrowLeft"){l.preventDefault(),E(o>=0?o-1:_);return}if(l.key==="Home"){l.preventDefault(),E(0);return}if(l.key==="End"){l.preventDefault(),E(_);return}l.key==="Escape"&&(l.preventDefault(),t(!1),h.current?.focus())};if(d.useEffect(()=>{if(s!=="sidebar"||!r)return;const l=o=>{const _=o.target;_ instanceof Node&&(n.current?.contains(_)||u.current?.contains(_)||t(!1))},v=o=>{o.key==="Escape"&&t(!1)};return document.addEventListener("pointerdown",l),document.addEventListener("keydown",v),()=>{document.removeEventListener("pointerdown",l),document.removeEventListener("keydown",v)}},[r,s]),d.useLayoutEffect(()=>{if(s!=="sidebar"||!r)return;(()=>{const _=h.current?.getBoundingClientRect();if(_){const M=Math.min(280,Math.max(218,window.innerWidth-24)),B=_.right-M,X=window.innerWidth-M-12,Y=Math.max(12,Math.min(B,X)),z=_.bottom+7,Z=Math.max(160,window.innerHeight-z-12);p({top:z,left:Y,width:M,maxHeight:Z})}})();const v=_=>{_&&u.current?.contains(_.target)||t(!1)},o=document.querySelector(".sidebar__scroll");return o?.addEventListener("scroll",v,{passive:!0}),window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{o?.removeEventListener("scroll",v),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[r,s]),d.useEffect(()=>{if(s!=="sidebar"||!r)return;const l=w.findIndex(o=>o.value===m),v=requestAnimationFrame(()=>{E(l>=0?l:0)});return()=>cancelAnimationFrame(v)},[m,w,r,s]),s==="sidebar"){const l=i?R.find(o=>o.value===i)?.shortLabel??R[0].shortLabel:K.shortLabel.split(" ")[0],v=G(m)?K.shortLabel.split(" ")[1]||"":A.shortLabel;return e.jsxs("div",{ref:n,className:"image-model-select image-model-select--sidebar",children:[e.jsxs("button",{ref:h,id:S,type:"button",className:"image-model-select__trigger image-model-select__trigger--pill","aria-haspopup":"menu","aria-expanded":r,"aria-label":a("sidebar.quickSettingsAria",{model:l,effort:v}),onClick:()=>t(o=>!o),children:[e.jsxs("span",{className:"image-model-select__trigger-top",children:[e.jsx("span",{className:"image-model-select__trigger-model",children:l}),e.jsx("span",{className:"image-model-select__trigger-chevron","aria-hidden":"true",children:"▾"})]}),e.jsx("span",{className:"image-model-select__trigger-effort",children:v})]}),r?ie.createPortal(e.jsxs("div",{ref:u,className:"image-model-select__menu",role:"menu","aria-label":a("sidebar.quickSettingsMenu"),onKeyDown:$,style:{position:"fixed",top:x.top,left:x.left,width:x.width,maxHeight:x.maxHeight,overflowY:"auto",zIndex:160},children:[e.jsxs("div",{className:"image-model-select__section",role:"group","aria-label":a("sidebar.imageSectionLabel"),children:[e.jsx("div",{className:"image-model-select__section-title",children:a("sidebar.imageSectionLabel")}),e.jsx("div",{className:"image-model-select__subsection-title",children:a("sidebar.gptImageSubLabel")}),D.map((o,_)=>e.jsxs("button",{ref:L=>{c.current[_]=L},type:"button",className:`image-model-select__item${o.value===m&&!i?" is-active":""}`,role:"menuitemradio","aria-checked":o.value===m&&!i,tabIndex:-1,onClick:()=>{b(o.value),t(!1)},children:[e.jsx("span",{children:o.shortLabel}),e.jsx("small",{children:a(o.fullLabelKey)})]},o.value)),e.jsx("div",{className:"image-model-select__subsection-title",children:a("sidebar.grokImageSubLabel")}),U.map((o,_)=>e.jsxs("button",{ref:L=>{c.current[D.length+_]=L},type:"button",className:`image-model-select__item${o.value===m&&!i?" is-active":""}`,role:"menuitemradio","aria-checked":o.value===m&&!i,tabIndex:-1,onClick:()=>{b(o.value),t(!1)},children:[e.jsx("span",{children:o.shortLabel}),e.jsx("small",{children:a(o.fullLabelKey)})]},o.value)),e.jsx("div",{className:"image-model-select__subsection-title",children:a("sidebar.geminiImageSubLabel")}),re.map((o,_)=>{const L=o.providerHint,M=o.value===m&&L===j&&!i;return e.jsxs("button",{ref:B=>{c.current[D.length+U.length+_]=B},type:"button",className:`image-model-select__item${M?" is-active":""}`,role:"menuitemradio","aria-checked":M,tabIndex:-1,onClick:()=>{L&&g(L),b(o.value),t(!1)},children:[e.jsx("span",{children:o.shortLabel}),e.jsx("small",{children:a(o.fullLabelKey)})]},`${o.value}-${L||_}`)})]}),e.jsxs("div",{className:"image-model-select__section",role:"group","aria-label":a("sidebar.videoSectionLabel"),children:[e.jsx("div",{className:"image-model-select__section-title",children:a("sidebar.videoSectionLabel")}),R.map((o,_)=>e.jsxs("button",{ref:L=>{c.current[w.length+_]=L},type:"button",className:`image-model-select__item${i===o.value?" is-active":""}`,role:"menuitemradio","aria-checked":i===o.value,tabIndex:-1,onClick:()=>{f(o.value),t(!1)},children:[e.jsx("span",{children:o.shortLabel}),e.jsx("small",{children:a(o.fullLabelKey)})]},o.value))]}),!G(m)&&e.jsxs("details",{className:"image-model-select__section image-model-select__collapsible",children:[e.jsxs("summary",{className:"image-model-select__section-title image-model-select__section-title--toggle",children:[a("sidebar.reasoningLabel"),e.jsx("span",{className:"image-model-select__chevron","aria-hidden":"true",children:"▸"})]}),e.jsx("div",{role:"group","aria-label":a("sidebar.reasoningLabel"),children:q.map((o,_)=>e.jsxs("button",{ref:L=>{c.current[w.length+R.length+_]=L},type:"button",className:`image-model-select__item${o.value===y?" is-active":""}`,role:"menuitemradio","aria-checked":o.value===y,tabIndex:-1,onClick:()=>{k(o.value),t(!1)},children:[e.jsx("span",{children:o.shortLabel}),e.jsx("small",{children:a(o.fullLabelKey)})]},o.value))})]})]}),document.body):null]})}return e.jsx("div",{className:"image-model-select image-model-select--settings",children:e.jsx(I,{id:S,value:m,onChange:l=>b(l),items:[...w.map(l=>({value:l.value,label:a(l.fullLabelKey)})),...le.map(l=>({value:l.value,label:a(l.fullLabelKey),disabled:!0}))]})})}function Ce(){const{t:s}=C(),a=N(n=>n.reasoningEffort),r=N(n=>n.setReasoningEffort),t=q.map(n=>({value:n.value,label:s(n.fullLabelKey)}));return e.jsx("div",{className:"ctl-select-wrap settings-reasoning-effort",children:e.jsx(I,{id:"settings-reasoning-effort",items:t,value:a,onChange:r})})}const Le={ko:"KO",en:"EN","zh-Hant":"正體","zh-Hans":"简体"};function Ee(){const{t:s,locale:a}=C(),r=N(t=>t.setLocale);return e.jsx("div",{className:"lang-toggle",role:"group","aria-label":s("language.label"),children:ce.map(t=>e.jsx("button",{type:"button",className:`lang-toggle__btn ${a===t?"is-active":""}`,onClick:()=>r(t),"aria-pressed":a===t,title:s(`language.${t}`),children:e.jsx("span",{className:"lang-toggle__label",children:Le[t]})},t))})}const Ke=["rail","horizontal","sidebar"];function Te(){const{t:s}=C(),a=N(t=>t.historyStripLayout),r=N(t=>t.setHistoryStripLayout);return e.jsx(oe,{className:"history-layout-toggle",items:Ke.map(t=>({value:t,label:s(`settings.appearance.historyStripLayout.${t}`)})),value:a,onChange:r})}const Me=[{value:"default",labelKey:"workspace.defaultLabel",descKey:"workspace.defaultDesc"},{value:"prompt-studio",labelKey:"workspace.promptStudioLabel",descKey:"workspace.promptStudioDesc"}];function Ie(){const s=N(t=>t.workspaceProfile),a=N(t=>t.setWorkspaceProfile),{t:r}=C();return e.jsx("div",{className:"settings-field",children:e.jsx(I,{id:"workspace-profile-select",value:s,onChange:t=>a(t),ariaLabel:r("workspace.profileLabel"),items:Me.map(t=>({value:t.value,label:r(t.labelKey)}))})})}function Ae(){const{t:s}=C(),[a,r]=d.useState(null);d.useEffect(()=>{fetch("/api/config/grok-planner").then(n=>n.json()).then(r).catch(()=>{})},[]);const t=async n=>{try{await fetch("/api/config/grok-planner",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:n})}),r(h=>h?{...h,model:n}:null)}catch{}};return a?e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.grokPlanner.title")}),e.jsx("p",{children:s("settings.grokPlanner.body")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(I,{items:a.options.map(n=>({value:n,label:n})),value:a.model,onChange:n=>{t(n)},ariaLabel:s("settings.grokPlanner.title")})})]}):null}function Oe(s){return s==="connected"?"ok":s==="error"||s==="offline"?"err":"warn"}function Re(s){const a=s.status.snapshotDiff;return a?a.drifted.length+a.missing.length+a.added.length:0}function Pe(){const{t:s}=C(),{providers:a,loading:r,error:t,refresh:n}=de(),[h,u]=d.useState(null),[c,x]=d.useState(!1),[p,m]=d.useState(null),j=async()=>{if(!c){x(!0);try{await n()}finally{x(!1)}}},b=async(g,i)=>{u({provider:g.id,action:i}),m(null);try{i==="connect"?await ue(g.id):i==="refresh"?await ge(g.id):await he(g.id),await n()}catch(f){const y=f instanceof Error&&f.message==="MCP_POPUP_BLOCKED"?s("mcp.popupBlocked"):s("mcp.connectionActionFailed");m({provider:g.id,message:y})}finally{u(null)}};return e.jsxs("div",{"aria-labelledby":"mcp-provider-connections-title",children:[e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{id:"mcp-provider-connections-title",children:s("mcp.connectionsTitle")}),e.jsx("p",{children:s("mcp.connectionsBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx("button",{type:"button",className:"settings-action-btn",onClick:()=>{j()},disabled:r||c,"aria-busy":r||c,children:s(r||c?"mcp.loadingProviders":"mcp.refreshList")})})]}),t?e.jsx("p",{role:"alert",className:"settings-row__microcopy",children:s("mcp.providersLoadFailed")}):null,a.map(g=>{const i=g.status.state,f=!g.enabled||g.executable===!1,y=h?.provider===g.id?h.action:null,k=y!==null,S=Re(g);return e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("h4",{children:g.id}),e.jsx("span",{className:"provider-card__eyebrow",children:"MCP"}),e.jsx("span",{className:`provider-chip provider-chip--${Oe(i)}`,children:s(`mcp.status.${i}`)})]}),e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("p",{children:g.endpoint}),e.jsxs("p",{children:[typeof g.status.toolCount=="number"?s("mcp.toolCount",{count:g.status.toolCount}):s("mcp.toolCountUnknown"),S>0?` · ${s("mcp.snapshotChanges",{count:S})}`:""]}),f?e.jsx("p",{className:"settings-row__microcopy",children:g.enabled?g.lockReason??s("mcp.higgsfieldLocked"):s("mcp.disabledProvider")}):g.status.detail?e.jsx("p",{className:"settings-row__microcopy",children:g.status.detail}):null,p?.provider===g.id?e.jsx("p",{role:"alert",className:"settings-row__microcopy",children:p.message}):null]}),e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__eyebrow",children:s("mcp.billingLabel")}),e.jsx("span",{className:"provider-chip provider-chip--warn",children:s("mcp.billingUnknown")})]}),e.jsx("div",{className:"settings-row__control","aria-live":"polite",children:i==="connected"&&!f?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"settings-action-btn",onClick:()=>{b(g,"refresh")},disabled:k,"aria-busy":y==="refresh",children:s(y==="refresh"?"mcp.refreshingConnection":"mcp.refreshConnection")}),e.jsx("button",{type:"button",className:"settings-action-btn settings-action-btn--danger",onClick:()=>{b(g,"disconnect")},disabled:k,"aria-busy":y==="disconnect",children:s("mcp.disconnect")})]}):e.jsx("button",{type:"button",className:"settings-action-btn",onClick:()=>{b(g,"connect")},disabled:k||f,"aria-busy":y==="connect",title:s(f?"mcp.higgsfieldLocked":"mcp.connectOpensBrowser"),children:s(y==="connect"?"mcp.connecting":"mcp.connect")})})]},g.id)})]})}const P=["providers","workspace","general"];function F({id:s,setRef:a,children:r}){const{t}=C();return e.jsxs("section",{id:s,ref:n=>a(s,n),className:"settings-section","aria-labelledby":`settings-section-${s}`,children:[e.jsx("header",{className:"settings-section__header",children:e.jsx("h3",{id:`settings-section-${s}`,children:t(`settings.sections.${s}.title`)})}),e.jsx("div",{className:"settings-section__body",children:r})]})}function $e(){const{t:s}=C(),a=N(i=>i.activeSettingsSection),r=N(i=>i.setActiveSettingsSection),t=N(i=>i.closeSettings),n=N(i=>i.openReadinessPopup),h=N(i=>i.galleryDefaultScope),u=N(i=>i.setGalleryDefaultScope),c=N(i=>i.provider),x=d.useRef(null),p=d.useRef(null),m=d.useRef(!1),j=d.useRef({providers:null,workspace:null,general:null}),b=(i,f)=>{j.current[i]=f},g=i=>{r(i),m.current=!0;const f=x.current,y=j.current[i];if(f&&y){const k=f.getBoundingClientRect().top,S=y.getBoundingClientRect().top,w=Number.parseFloat(window.getComputedStyle(y).scrollMarginTop)||0;f.scrollTo({top:f.scrollTop+S-k-w,behavior:"auto"})}p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{m.current=!1,p.current=null},120)};return d.useEffect(()=>{const i=f=>{f.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),d.useEffect(()=>{const i=x.current;if(!i||typeof IntersectionObserver!="function")return;const f=new IntersectionObserver(y=>{if(m.current)return;const S=y.filter(w=>w.isIntersecting).sort((w,K)=>K.intersectionRatio-w.intersectionRatio)[0]?.target.id;S&&P.includes(S)&&r(S)},{root:i,threshold:[.35,.6]});for(const y of P){const k=j.current[y];k&&f.observe(k)}return()=>f.disconnect()},[r]),d.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]),e.jsx("main",{className:"settings-workspace","aria-labelledby":"settings-title",children:e.jsxs("div",{className:"settings-shell",children:[e.jsxs("header",{className:"settings-header",children:[e.jsx("div",{children:e.jsx("h2",{id:"settings-title",children:s("settings.title")})}),e.jsx("button",{type:"button",className:"settings-close",onClick:t,"aria-label":s("settings.closeAria"),title:s("settings.closeTitle"),children:"X"})]}),e.jsxs("div",{className:"settings-layout",children:[e.jsx("nav",{className:"settings-nav settings-nav--mobile","aria-label":s("settings.navAria"),children:e.jsx("div",{className:"settings-mobile-nav",role:"list",children:P.map(i=>e.jsxs("button",{type:"button",className:`settings-mobile-nav__item${a===i?" is-active":""}`,onClick:()=>g(i),"aria-current":a===i?"true":void 0,children:[e.jsx("span",{children:s(`settings.sections.${i}.title`)}),e.jsx("small",{children:s(`settings.sections.${i}.hint`)})]},i))})}),e.jsx("nav",{className:"settings-nav","aria-label":s("settings.navAria"),children:P.map(i=>e.jsxs("button",{type:"button",className:`settings-nav__item${a===i?" is-active":""}`,onClick:()=>g(i),"aria-label":s("settings.jumpTo",{section:s(`settings.sections.${i}.title`)}),children:[e.jsx("span",{children:s(`settings.sections.${i}.title`)}),e.jsx("small",{children:s(`settings.sections.${i}.hint`)})]},i))}),e.jsxs("section",{ref:x,className:"settings-content","aria-label":s("settings.contentAria"),children:[e.jsxs(F,{id:"providers",setRef:b,children:[e.jsx(ke,{}),e.jsx(Pe,{}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("readiness.settingsTitle")}),e.jsx("p",{children:s("readiness.settingsBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx("button",{type:"button",className:"settings-action-btn",onClick:n,children:s("readiness.open")})})]}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.imageModel.title")}),e.jsx("p",{children:s("settings.imageModel.body")}),e.jsx("p",{className:"settings-row__microcopy",children:s("settings.imageModel.unsupportedHelp")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(Se,{variant:"settings"})})]}),c==="grok"?e.jsxs(e.Fragment,{children:[e.jsx("article",{className:"settings-row",children:e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.grokCompatibility.title")}),e.jsx("p",{children:s("settings.grokCompatibility.body")})]})}),e.jsx(Ae,{})]}):c==="agy"||c==="gemini-api"?e.jsx("article",{className:"settings-row",children:e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s(c==="gemini-api"?"provider.geminiApiCompatTitle":"provider.agyCompatTitle")}),e.jsx("p",{children:s(c==="gemini-api"?"provider.geminiApiCompatBodyLong":"provider.agyCompatBodyLong")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.reasoning.title")}),e.jsx("p",{children:s("settings.reasoning.body")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(Ce,{})})]}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.webSearch.title")}),e.jsx("p",{children:s("settings.webSearch.body")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(pe,{})})]})]})]}),e.jsxs(F,{id:"workspace",setRef:b,children:[e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("workspace.sectionTitle")}),e.jsx("p",{children:s("workspace.sectionBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(Ie,{})})]}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.appearance.historyStripLayoutTitle")}),e.jsx("p",{children:s("settings.appearance.historyStripLayoutBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(Te,{})})]}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.gallery.defaultScopeTitle")}),e.jsx("p",{children:s("settings.gallery.defaultScopeBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(I,{ariaLabel:s("settings.gallery.defaultScopeTitle"),value:h,onChange:i=>u(i),items:[{value:"current-session",label:s("gallery.scope.current")},{value:"all",label:s("gallery.scope.all")}]})})]})]}),e.jsx(F,{id:"general",setRef:b,children:e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.language.title")}),e.jsx("p",{children:s("settings.language.body")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(Ee,{})})]})})]})]})]})})}export{$e as SettingsWorkspace};
1
+ import{a as d,u as C,j as e,t as I,v as ee,x as se,y as te,z as ne,b as N,I as ae,A as q,V as R,B as G,C as ie,O as D,G as U,D as re,U as le,E as ce,F as oe,H as de,J as ue,K as ge,L as he,W as pe}from"./index-CxEuSZMC.js";function me(){const[s,a]=d.useState(null);return d.useEffect(()=>{let r=!1;return(async()=>{try{const n=await fetch("/api/agy/status");if(r)return;const h=await n.json();a(h)}catch{r||a({installed:!1})}})(),()=>{r=!0}},[]),s}function O({provider:s,label:a,placeholder:r,maskedKey:t,source:n,configured:h,onSaved:u}){const{t:c}=C(),[x,p]=d.useState(""),[m,j]=d.useState(!1),[b,g]=d.useState(!1),[i,f]=d.useState(null),[y,k]=d.useState(!1),S=n==="env",w=x.trim().length>0,K=h&&!m&&!w,A=d.useCallback(async()=>{if(w){g(!0),f(null),k(!1);try{const v=await(await fetch(`/api/keys/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:x.trim()})})).json();v.ok?(p(""),j(!1),k(!0),u(),setTimeout(()=>k(!1),3e3)):f(v.error||c("settings.apiKeys.saveFailed"))}catch{f(c("settings.apiKeys.networkError"))}finally{g(!1)}}},[x,s,w,u,c]),T=d.useCallback(async()=>{try{if(!(await fetch(`/api/keys/${s}`,{method:"DELETE"})).ok){f(c("settings.apiKeys.removeFailed"));return}p(""),j(!1),u()}catch{f(c("settings.apiKeys.networkError"))}},[s,u,c]),E=d.useCallback(()=>{h&&j(!0)},[h]),$=d.useCallback(()=>{w||j(!1)},[w]);return e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("p",{className:"settings-eyebrow",children:c(S?"settings.apiKeys.envSource":"settings.apiKeys.configSource")}),e.jsx("h4",{children:a}),e.jsxs("div",{className:"api-key-input-group",children:[K?e.jsx("input",{type:"text",className:"api-key-input is-masked",value:t||"●●●●●●",readOnly:!0,onFocus:E,onClick:E}):e.jsx("input",{type:"password",className:`api-key-input${i?" is-invalid":""}`,placeholder:r,value:x,onChange:l=>{p(l.target.value),f(null)},onBlur:$,readOnly:!1,autoComplete:"off",autoFocus:m,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":"true","data-form-type":"other"}),e.jsxs("div",{className:"api-key-actions",children:[e.jsx("button",{type:"button",className:"settings-action-btn",onClick:A,disabled:!w||b,children:c(b?"settings.apiKeys.saving":y?"settings.apiKeys.saved":"settings.apiKeys.save")}),h&&!S&&e.jsx("button",{type:"button",className:"settings-action-btn settings-action-btn--danger",onClick:T,children:c("settings.apiKeys.remove")})]})]}),i&&e.jsx("p",{className:"api-key-error",children:i})]}),e.jsxs("div",{className:`settings-status${h?" is-ok":""}`,children:[e.jsx("span",{"aria-hidden":"true"}),c(h?"settings.apiKeys.status.valid":"settings.apiKeys.status.notConfigured")]})]})}function fe({configured:s,maskedKey:a,source:r,onSaved:t}){const{t:n}=C(),[h,u]=d.useState(""),[c,x]=d.useState(!1),[p,m]=d.useState(!1),[j,b]=d.useState(null),[g,i]=d.useState(!1),f=r==="env",y=h.trim().length>0,k=s&&!c&&!y,S=d.useCallback(async()=>{if(y){m(!0),b(null),i(!1);try{const E=await(await fetch("/api/keys/vertex",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({serviceAccountJson:h.trim()})})).json();E.ok?(u(""),x(!1),i(!0),t(),setTimeout(()=>i(!1),3e3)):b(E.error||n("settings.apiKeys.saveFailed"))}catch{b(n("settings.apiKeys.networkError"))}finally{m(!1)}}},[h,y,t,n]),w=d.useCallback(async()=>{try{if(!(await fetch("/api/keys/vertex",{method:"DELETE"})).ok){b(n("settings.apiKeys.removeFailed"));return}u(""),x(!1),t()}catch{b(n("settings.apiKeys.networkError"))}},[t,n]),K=d.useCallback(()=>{s&&!f&&x(!0)},[s,f]),A=d.useCallback(()=>{y||x(!1)},[y]);return e.jsxs("div",{className:"vertex-json-section",children:[e.jsx("p",{className:"settings-eyebrow",children:n(f?"settings.apiKeys.envSource":"settings.apiKeys.configSource")}),s&&a&&e.jsx("p",{className:"vertex-project-id",children:a}),k?e.jsx("textarea",{className:"vertex-json-textarea is-masked",value:`●●● (${n("settings.apiKeys.configuredReplace")})`,readOnly:!0,onFocus:K,onClick:K}):e.jsx("textarea",{className:`vertex-json-textarea${j?" is-invalid":""}`,placeholder:n("settings.apiKeys.vertex.placeholder"),value:h,onChange:T=>{u(T.target.value),b(null)},onBlur:A,readOnly:f,autoFocus:c,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":"true","data-form-type":"other"}),e.jsxs("div",{className:"api-key-actions",style:{marginTop:8},children:[!f&&e.jsx("button",{type:"button",className:"settings-action-btn",onClick:S,disabled:!y||p,children:n(p?"settings.apiKeys.saving":g?"settings.apiKeys.saved":"settings.apiKeys.save")}),s&&!f&&e.jsx("button",{type:"button",className:"settings-action-btn settings-action-btn--danger",onClick:w,children:n("settings.apiKeys.remove")})]}),j&&e.jsx("p",{className:"api-key-error",children:j}),e.jsxs("div",{className:`settings-status${s?" is-ok":""}`,style:{marginTop:8},children:[e.jsx("span",{"aria-hidden":"true"}),n(s?"settings.apiKeys.status.valid":"settings.apiKeys.status.notConfigured")]})]})}function xe({keyStatus:s,onSaved:a}){const{t:r}=C(),t=s.vertex?.configured??!1,n=s.gemini?.configured??!1,h=s.geminiAuthMode==="vertex"?"vertex":"apikey",[u,c]=d.useState(h),[x,p]=d.useState(!1);d.useEffect(()=>{x||c(h)},[h,x]);const m=j=>{p(!0),c(j),fetch("/api/keys/gemini-auth-mode",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:j})}).catch(()=>{})};return e.jsxs("div",{className:"gemini-key-section",children:[e.jsxs("div",{className:"gemini-key-section__header",children:[e.jsx("h5",{children:r("settings.apiKeys.gemini.label")}),e.jsx(I,{value:u,onChange:m,items:[{value:"apikey",label:r("settings.apiKeys.vertex.authModeApiKey")},{value:"vertex",label:r("settings.apiKeys.vertex.authModeVertex")}]})]}),u==="apikey"?e.jsx(O,{provider:"gemini",label:"",placeholder:r("settings.apiKeys.gemini.placeholder"),maskedKey:s.gemini?.maskedKey??null,source:s.gemini?.source??"none",configured:n,onSaved:a}):e.jsx(fe,{configured:t,maskedKey:s.vertex?.maskedKey??null,source:s.vertex?.source??"none",onSaved:a})]})}function ye(s){return s>80?"var(--error, #e53935)":s>50?"var(--warning, #f59e0b)":"var(--info, #3b82f6)"}function je(s){if(!s)return"";const a=new Date(s);return`${a.getMonth()+1}/${a.getDate()} ${String(a.getHours()).padStart(2,"0")}:${String(a.getMinutes()).padStart(2,"0")}`}function J({window:s}){const a=je(s.resetsAt);return e.jsxs("div",{className:"quota-bar",children:[e.jsx("span",{className:"quota-bar__label",children:s.label}),e.jsx("div",{className:"quota-bar__track",children:e.jsx("div",{className:"quota-bar__fill",style:{width:`${Math.min(s.percent,100)}%`,background:ye(s.percent)}})}),e.jsxs("span",{className:"quota-bar__pct",children:[s.percent,"%"]}),a&&e.jsx("span",{className:"quota-bar__reset",children:a})]})}function Q({provider:s,onComplete:a}){const{t:r}=C(),[t,n]=d.useState({phase:"idle"}),[h,u]=d.useState(!1),c=d.useRef(!1),x=d.useCallback(async()=>{if(!c.current){c.current=!0,n({phase:"starting"});try{const p=await fetch("/api/auth/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:s})});if(!p.ok){const j=await p.json().catch(()=>({error:r("settings.quota.switchFailed")}));n({phase:"error",error:j.error||`HTTP ${p.status}`});return}const m=await p.json();n({phase:"waiting",...m}),window.open(m.verificationUrl,"_blank")}catch(p){c.current=!1,n({phase:"error",error:p.message})}}},[s]);return d.useEffect(()=>{if(t.phase!=="waiting"||!t.sessionId)return;let p=!1;const m=async()=>{try{const g=await(await fetch(`/api/auth/switch/${t.sessionId}`)).json();if(p)return;if(g.status==="complete"){n({phase:"complete"}),setTimeout(a,1e3);return}if(g.status==="error"||g.status==="expired"){n({phase:"error",error:g.error||g.status});return}}catch{}p||setTimeout(m,3e3)},j=setTimeout(m,3e3);return()=>{p=!0,clearTimeout(j)}},[t.phase,t.sessionId,a]),t.phase==="idle"?e.jsx("button",{type:"button",className:"settings-action-btn",style:{width:"100%",marginTop:"6px"},onClick:x,children:r("settings.quota.switchAccount",{provider:s==="grok"?"Grok":"Codex"})}):t.phase==="starting"?e.jsx("div",{className:"quota-card__hint",style:{textAlign:"center",marginTop:"6px"},children:r("settings.quota.startingLogin")}):t.phase==="waiting"?e.jsxs("div",{style:{marginTop:"6px",padding:"8px",background:"var(--surface, #f5f5f5)",borderRadius:"6px",fontSize:"12px"},children:[e.jsx("div",{style:{textAlign:"center",marginBottom:"4px"},children:r("settings.quota.enterCode")}),e.jsx("div",{style:{textAlign:"center",fontSize:"18px",fontWeight:700,fontFamily:"monospace",letterSpacing:"2px",margin:"6px 0"},children:t.userCode}),t.verificationUrl&&e.jsxs("div",{style:{display:"flex",gap:"4px",margin:"6px 0"},children:[e.jsx("button",{type:"button",className:"settings-action-btn",style:{flex:1,fontSize:"11px"},onClick:()=>{c.current=!1,x()},children:r("settings.quota.retry")}),e.jsx("button",{type:"button",className:"settings-action-btn",style:{flex:1,fontSize:"11px"},onClick:()=>{navigator.clipboard?.writeText(t.verificationUrl).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)})},children:r(h?"settings.quota.copied":"settings.quota.copyLink")})]}),e.jsx("div",{style:{textAlign:"center",color:"var(--text-dim, #888)",fontSize:"11px"},children:r("settings.quota.waitingApproval")})]}):t.phase==="complete"?e.jsx("div",{className:"quota-card__hint",style:{textAlign:"center",marginTop:"6px",color:"var(--success, #22c55e)"},children:r("settings.quota.switchComplete")}):t.phase==="error"?e.jsxs("div",{style:{marginTop:"6px"},children:[e.jsx("div",{className:"quota-card__hint",style:{color:"var(--error, #e53935)",marginBottom:"4px"},children:t.error||r("settings.quota.switchFailed")}),e.jsx("button",{type:"button",className:"settings-action-btn",style:{width:"100%",fontSize:"11px"},onClick:()=>{c.current=!1,n({phase:"idle"})},children:r("settings.quota.tryAgain")})]}):null}function ve(){const[s,a]=d.useState(null),[r,t]=d.useState(!0),n=d.useCallback(()=>{t(!0),fetch("/api/quota").then(h=>h.json()).then(a).catch(()=>a(null)).finally(()=>t(!1))},[]);return d.useEffect(()=>{const h=setTimeout(n,1500);return()=>clearTimeout(h)},[n]),{data:s,loading:r,refreshQuota:n}}function be({data:s,loading:a,onRefresh:r}){const{t}=C(),n=s?.codex,h=n?.windows&&n.windows.length>0,u=n?.account?[n.account.email,n.account.plan].filter(Boolean).join(" · "):null;return e.jsxs("div",{className:"quota-card",children:[u?e.jsx("div",{className:"quota-card__header",children:e.jsx("span",{className:"quota-card__account",children:u})}):null,a?e.jsx("span",{className:"quota-card__loading",children:t("common.loading")}):h?n.windows.map(c=>e.jsx(J,{window:c},c.label)):n?.authenticated===!1?e.jsx("span",{className:"quota-card__hint",children:t("settings.quota.codexNotLoggedIn")}):n?.error?e.jsx("span",{className:"quota-card__hint",children:t("settings.quota.fetchError")}):e.jsx("span",{className:"quota-card__hint",children:t("settings.quota.noData")}),e.jsx(Q,{provider:"codex",onComplete:r})]})}function _e({data:s,loading:a,onRefresh:r}){const{t}=C(),n=s?.grok,h=n?.windows&&n.windows.length>0,u=n?.account?[n.account.email,n.account.plan].filter(Boolean).join(" · "):null;return e.jsxs("div",{className:"quota-card",children:[u||n?.billing?e.jsxs("div",{className:"quota-card__header",style:{display:"flex",alignItems:"center"},children:[u&&e.jsx("span",{className:"quota-card__account",children:u}),n?.billing&&e.jsxs("span",{style:{marginLeft:"auto",fontSize:"11px",color:"var(--text-dim, #888)",whiteSpace:"nowrap"},children:["$",n.billing.usedUsd.toFixed(1),"/$",n.billing.limitUsd]})]}):null,a?e.jsx("span",{className:"quota-card__loading",children:t("common.loading")}):h?n.windows.map(c=>e.jsx(J,{window:c},c.label)):n?.authenticated===!1?e.jsx("span",{className:"quota-card__hint",children:t("settings.quota.codexNotLoggedIn")}):e.jsx("a",{href:"https://grok.com/?_s=usage",target:"_blank",rel:"noopener noreferrer",className:"settings-action-btn",children:t("settings.quota.grokUsageLink")}),e.jsx(Q,{provider:"grok",onComplete:r})]})}function H(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a5.998 5.998 0 0 0-3.998 2.9 6.049 6.049 0 0 0 .743 7.097 5.98 5.98 0 0 0 .51 4.911 6.051 6.051 0 0 0 6.515 2.9A5.985 5.985 0 0 0 13.26 24a6.056 6.056 0 0 0 5.772-4.206 5.99 5.99 0 0 0 3.997-2.9 6.056 6.056 0 0 0-.747-7.073zM13.26 22.43a4.476 4.476 0 0 1-2.876-1.04l.141-.081 4.779-2.758a.795.795 0 0 0 .392-.681v-6.737l2.02 1.168a.071.071 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494zM3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.771.771 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646zM2.34 7.896a4.485 4.485 0 0 1 2.366-1.973V11.6a.766.766 0 0 0 .388.676l5.815 3.355-2.02 1.168a.076.076 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855l-5.833-3.387L15.119 7.2a.076.076 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667zm2.01-3.023l-.141-.085-4.774-2.782a.776.776 0 0 0-.785 0L9.409 9.23V6.897a.066.066 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135l-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.795.795 0 0 0-.393.681zm1.097-2.365l2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.612-1.5z"})})}function we(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd","aria-hidden":"true",children:e.jsx("path",{d:"M9.27 15.29l7.978-5.897c.391-.29.95-.177 1.137.272.98 2.369.542 5.215-1.41 7.169-1.951 1.954-4.667 2.382-7.149 1.406l-2.711 1.257c3.889 2.661 8.611 2.003 11.562-.953 2.341-2.344 3.066-5.539 2.388-8.42l.006.007c-.983-4.232.242-5.924 2.75-9.383.06-.082.12-.164.179-.248l-3.301 3.305v-.01L9.267 15.292M7.623 16.723c-2.792-2.67-2.31-6.801.071-9.184 1.761-1.763 4.647-2.483 7.166-1.425l2.705-1.25a7.808 7.808 0 00-1.829-1A8.975 8.975 0 005.984 5.83c-2.533 2.536-3.33 6.436-1.962 9.764 1.022 2.487-.653 4.246-2.34 6.022-.599.63-1.199 1.259-1.682 1.925l7.62-6.815"})})}function Ne(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M12 24A14.304 14.304 0 0 0 0 12 14.304 14.304 0 0 0 12 0a14.305 14.305 0 0 0 12 12 14.305 14.305 0 0 0-12 12"})})}function V(s,a){return s(a==="ready"?"settings.account.status.ready":a==="auth_required"?"settings.account.status.authRequired":a==="starting"?"settings.account.status.starting":a==="offline"?"settings.account.status.offline":a==="no_image_model"?"settings.account.status.noImageModel":a==="error"?"settings.account.status.error":"settings.account.status.checking")}function W(s){return s==="ready"?"ok":s==="error"||s==="offline"?"err":"warn"}function ke(){const{t:s}=C(),a=ee(),r=se(),t=me(),{data:n,error:h}=te(),{data:u,mutate:c}=ne(),x=ve(),[p,m]=d.useState(!1),j=n?.apiKeySource==="env"||n?.apiKeySource==="config"||n?.apiKeyValid===!0,b=n?.apiKeySource==="config"?s("settings.account.apiSourceConfig"):s("settings.account.apiSourceEnv"),g=n?.apiKeyValid===!0;return e.jsxs(e.Fragment,{children:[e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__brand",children:e.jsx(H,{})}),e.jsx("h4",{children:s("settings.account.oauthTitle")}),e.jsx("span",{className:"provider-card__eyebrow",children:s("settings.account.primaryEyebrow")}),e.jsx("span",{className:`provider-chip provider-chip--${W(a?.status)}`,children:V(s,a?.status)})]}),e.jsx("div",{className:"settings-row__copy",children:e.jsx("p",{children:s("settings.account.oauthBody")})}),e.jsx(be,{data:x.data,loading:x.loading,onRefresh:x.refreshQuota})]}),j?e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__brand",children:e.jsx(H,{})}),e.jsx("h4",{children:s("settings.account.apiTitle")}),e.jsx("span",{className:"provider-card__eyebrow",children:b}),e.jsx("span",{className:`provider-chip provider-chip--${h?"err":g?"ok":"warn"}`,children:s(h?"settings.account.apiUnknown":g?"settings.account.apiReady":"settings.account.apiUnavailable")})]}),e.jsx("div",{className:"settings-row__copy",children:e.jsx("p",{children:s("settings.account.apiBody")})})]}):null,e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__brand",children:e.jsx(we,{})}),e.jsx("h4",{children:s("settings.account.grokTitle")}),e.jsx("span",{className:"provider-card__eyebrow",children:s("settings.account.grokEyebrow")}),e.jsx("span",{className:`provider-chip provider-chip--${W(r?.status)}`,children:V(s,r?.status)})]}),e.jsx("div",{className:"settings-row__copy",children:e.jsx("p",{children:s("settings.account.grokBody")})}),e.jsx(_e,{data:x.data,loading:x.loading,onRefresh:x.refreshQuota})]}),e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__brand",children:e.jsx(Ne,{})}),e.jsx("h4",{children:s("settings.account.agyTitle")}),e.jsx("span",{className:"provider-card__eyebrow",children:s("settings.account.agyEyebrow")}),e.jsx("span",{className:`provider-chip provider-chip--${t?.installed?"ok":"warn"}`,children:t?.installed?s("settings.account.agyInstalled"):s("settings.account.agyMissing")})]}),e.jsxs("div",{className:"settings-row__copy",children:[t?.installed?e.jsx("p",{children:s("settings.account.agyInstalledBody")}):e.jsxs("p",{children:[s("settings.account.agyMissingBody")," ",e.jsx("a",{href:"https://antigravity.google/docs/cli-install",target:"_blank",rel:"noopener noreferrer",children:s("settings.account.agyMissingLink")})]}),e.jsx("p",{style:{fontSize:"12px",color:"var(--text-dim, #888)",marginTop:"4px"},children:s("settings.account.agyFineprint")})]})]}),u&&e.jsxs("article",{className:"settings-row settings-accordion",children:[e.jsxs("button",{type:"button",className:"settings-accordion__trigger",onClick:()=>m(!p),children:[e.jsx("h4",{children:s("settings.apiKeys.accordionTitle")}),e.jsx("span",{className:`settings-accordion__arrow${p?" is-open":""}`,children:"▼"})]}),p&&e.jsxs("div",{className:"settings-accordion__body",children:[e.jsx(O,{provider:"openai",label:s("settings.apiKeys.openai.label"),placeholder:s("settings.apiKeys.openai.placeholder"),maskedKey:u.openai?.maskedKey??null,source:u.openai?.source??"none",configured:u.openai?.configured??!1,onSaved:c}),e.jsx(O,{provider:"xai",label:s("settings.apiKeys.xai.label"),placeholder:s("settings.apiKeys.xai.placeholder"),maskedKey:u.xai?.maskedKey??null,source:u.xai?.source??"none",configured:u.xai?.configured??!1,onSaved:c}),e.jsx(O,{provider:"atlascloud",label:s("settings.apiKeys.atlascloud.label"),placeholder:s("settings.apiKeys.atlascloud.placeholder"),maskedKey:u.atlascloud?.maskedKey??null,source:u.atlascloud?.source??"none",configured:u.atlascloud?.configured??!1,onSaved:c}),e.jsx(O,{provider:"minimax",label:s("settings.apiKeys.minimax.label"),placeholder:s("settings.apiKeys.minimax.placeholder"),maskedKey:u.minimax?.maskedKey??null,source:u.minimax?.source??"none",configured:u.minimax?.configured??!1,onSaved:c}),e.jsx(xe,{keyStatus:u,onSaved:c})]})]})]})}function Se({variant:s}){const{t:a}=C(),[r,t]=d.useState(!1),n=d.useRef(null),h=d.useRef(null),u=d.useRef(null),c=d.useRef([]),[x,p]=d.useState({top:0,left:12,width:280,maxHeight:480}),m=N(l=>l.imageModel),j=N(l=>l.provider),b=N(l=>l.setImageModel),g=N(l=>l.setProvider),i=N(l=>l.videoModelSelected),f=N(l=>l.selectVideoModel),y=N(l=>l.reasoningEffort),k=N(l=>l.setReasoningEffort),S=s==="settings"?"settings-image-model":"sidebar-image-model",w=ae,K=w.find(l=>l.value===m&&(!l.providerHint||l.providerHint===j))??w.find(l=>l.value===m)??w[0],A=q.find(l=>l.value===y)??q[0],T=()=>c.current.filter(l=>l!==null),E=l=>{const v=T();if(v.length===0)return;const o=(l+v.length)%v.length;v[o]?.focus()},$=l=>{const v=T();if(v.length===0)return;const o=v.findIndex(L=>L===document.activeElement),_=v.length-1;if(l.key==="ArrowDown"||l.key==="ArrowRight"){l.preventDefault(),E(o>=0?o+1:0);return}if(l.key==="ArrowUp"||l.key==="ArrowLeft"){l.preventDefault(),E(o>=0?o-1:_);return}if(l.key==="Home"){l.preventDefault(),E(0);return}if(l.key==="End"){l.preventDefault(),E(_);return}l.key==="Escape"&&(l.preventDefault(),t(!1),h.current?.focus())};if(d.useEffect(()=>{if(s!=="sidebar"||!r)return;const l=o=>{const _=o.target;_ instanceof Node&&(n.current?.contains(_)||u.current?.contains(_)||t(!1))},v=o=>{o.key==="Escape"&&t(!1)};return document.addEventListener("pointerdown",l),document.addEventListener("keydown",v),()=>{document.removeEventListener("pointerdown",l),document.removeEventListener("keydown",v)}},[r,s]),d.useLayoutEffect(()=>{if(s!=="sidebar"||!r)return;(()=>{const _=h.current?.getBoundingClientRect();if(_){const M=Math.min(280,Math.max(218,window.innerWidth-24)),B=_.right-M,X=window.innerWidth-M-12,Y=Math.max(12,Math.min(B,X)),z=_.bottom+7,Z=Math.max(160,window.innerHeight-z-12);p({top:z,left:Y,width:M,maxHeight:Z})}})();const v=_=>{_&&u.current?.contains(_.target)||t(!1)},o=document.querySelector(".sidebar__scroll");return o?.addEventListener("scroll",v,{passive:!0}),window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{o?.removeEventListener("scroll",v),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[r,s]),d.useEffect(()=>{if(s!=="sidebar"||!r)return;const l=w.findIndex(o=>o.value===m),v=requestAnimationFrame(()=>{E(l>=0?l:0)});return()=>cancelAnimationFrame(v)},[m,w,r,s]),s==="sidebar"){const l=i?R.find(o=>o.value===i)?.shortLabel??R[0].shortLabel:K.shortLabel.split(" ")[0],v=G(m)?K.shortLabel.split(" ")[1]||"":A.shortLabel;return e.jsxs("div",{ref:n,className:"image-model-select image-model-select--sidebar",children:[e.jsxs("button",{ref:h,id:S,type:"button",className:"image-model-select__trigger image-model-select__trigger--pill","aria-haspopup":"menu","aria-expanded":r,"aria-label":a("sidebar.quickSettingsAria",{model:l,effort:v}),onClick:()=>t(o=>!o),children:[e.jsxs("span",{className:"image-model-select__trigger-top",children:[e.jsx("span",{className:"image-model-select__trigger-model",children:l}),e.jsx("span",{className:"image-model-select__trigger-chevron","aria-hidden":"true",children:"▾"})]}),e.jsx("span",{className:"image-model-select__trigger-effort",children:v})]}),r?ie.createPortal(e.jsxs("div",{ref:u,className:"image-model-select__menu",role:"menu","aria-label":a("sidebar.quickSettingsMenu"),onKeyDown:$,style:{position:"fixed",top:x.top,left:x.left,width:x.width,maxHeight:x.maxHeight,overflowY:"auto",zIndex:160},children:[e.jsxs("div",{className:"image-model-select__section",role:"group","aria-label":a("sidebar.imageSectionLabel"),children:[e.jsx("div",{className:"image-model-select__section-title",children:a("sidebar.imageSectionLabel")}),e.jsx("div",{className:"image-model-select__subsection-title",children:a("sidebar.gptImageSubLabel")}),D.map((o,_)=>e.jsxs("button",{ref:L=>{c.current[_]=L},type:"button",className:`image-model-select__item${o.value===m&&!i?" is-active":""}`,role:"menuitemradio","aria-checked":o.value===m&&!i,tabIndex:-1,onClick:()=>{b(o.value),t(!1)},children:[e.jsx("span",{children:o.shortLabel}),e.jsx("small",{children:a(o.fullLabelKey)})]},o.value)),e.jsx("div",{className:"image-model-select__subsection-title",children:a("sidebar.grokImageSubLabel")}),U.map((o,_)=>e.jsxs("button",{ref:L=>{c.current[D.length+_]=L},type:"button",className:`image-model-select__item${o.value===m&&!i?" is-active":""}`,role:"menuitemradio","aria-checked":o.value===m&&!i,tabIndex:-1,onClick:()=>{b(o.value),t(!1)},children:[e.jsx("span",{children:o.shortLabel}),e.jsx("small",{children:a(o.fullLabelKey)})]},o.value)),e.jsx("div",{className:"image-model-select__subsection-title",children:a("sidebar.geminiImageSubLabel")}),re.map((o,_)=>{const L=o.providerHint,M=o.value===m&&L===j&&!i;return e.jsxs("button",{ref:B=>{c.current[D.length+U.length+_]=B},type:"button",className:`image-model-select__item${M?" is-active":""}`,role:"menuitemradio","aria-checked":M,tabIndex:-1,onClick:()=>{L&&g(L),b(o.value),t(!1)},children:[e.jsx("span",{children:o.shortLabel}),e.jsx("small",{children:a(o.fullLabelKey)})]},`${o.value}-${L||_}`)})]}),e.jsxs("div",{className:"image-model-select__section",role:"group","aria-label":a("sidebar.videoSectionLabel"),children:[e.jsx("div",{className:"image-model-select__section-title",children:a("sidebar.videoSectionLabel")}),R.map((o,_)=>e.jsxs("button",{ref:L=>{c.current[w.length+_]=L},type:"button",className:`image-model-select__item${i===o.value?" is-active":""}`,role:"menuitemradio","aria-checked":i===o.value,tabIndex:-1,onClick:()=>{f(o.value),t(!1)},children:[e.jsx("span",{children:o.shortLabel}),e.jsx("small",{children:a(o.fullLabelKey)})]},o.value))]}),!G(m)&&e.jsxs("details",{className:"image-model-select__section image-model-select__collapsible",children:[e.jsxs("summary",{className:"image-model-select__section-title image-model-select__section-title--toggle",children:[a("sidebar.reasoningLabel"),e.jsx("span",{className:"image-model-select__chevron","aria-hidden":"true",children:"▸"})]}),e.jsx("div",{role:"group","aria-label":a("sidebar.reasoningLabel"),children:q.map((o,_)=>e.jsxs("button",{ref:L=>{c.current[w.length+R.length+_]=L},type:"button",className:`image-model-select__item${o.value===y?" is-active":""}`,role:"menuitemradio","aria-checked":o.value===y,tabIndex:-1,onClick:()=>{k(o.value),t(!1)},children:[e.jsx("span",{children:o.shortLabel}),e.jsx("small",{children:a(o.fullLabelKey)})]},o.value))})]})]}),document.body):null]})}return e.jsx("div",{className:"image-model-select image-model-select--settings",children:e.jsx(I,{id:S,value:m,onChange:l=>b(l),items:[...w.map(l=>({value:l.value,label:a(l.fullLabelKey)})),...le.map(l=>({value:l.value,label:a(l.fullLabelKey),disabled:!0}))]})})}function Ce(){const{t:s}=C(),a=N(n=>n.reasoningEffort),r=N(n=>n.setReasoningEffort),t=q.map(n=>({value:n.value,label:s(n.fullLabelKey)}));return e.jsx("div",{className:"ctl-select-wrap settings-reasoning-effort",children:e.jsx(I,{id:"settings-reasoning-effort",items:t,value:a,onChange:r})})}const Le={ko:"KO",en:"EN","zh-Hant":"正體","zh-Hans":"简体"};function Ee(){const{t:s,locale:a}=C(),r=N(t=>t.setLocale);return e.jsx("div",{className:"lang-toggle",role:"group","aria-label":s("language.label"),children:ce.map(t=>e.jsx("button",{type:"button",className:`lang-toggle__btn ${a===t?"is-active":""}`,onClick:()=>r(t),"aria-pressed":a===t,title:s(`language.${t}`),children:e.jsx("span",{className:"lang-toggle__label",children:Le[t]})},t))})}const Ke=["rail","horizontal","sidebar"];function Te(){const{t:s}=C(),a=N(t=>t.historyStripLayout),r=N(t=>t.setHistoryStripLayout);return e.jsx(oe,{className:"history-layout-toggle",items:Ke.map(t=>({value:t,label:s(`settings.appearance.historyStripLayout.${t}`)})),value:a,onChange:r})}const Me=[{value:"default",labelKey:"workspace.defaultLabel",descKey:"workspace.defaultDesc"},{value:"prompt-studio",labelKey:"workspace.promptStudioLabel",descKey:"workspace.promptStudioDesc"}];function Ie(){const s=N(t=>t.workspaceProfile),a=N(t=>t.setWorkspaceProfile),{t:r}=C();return e.jsx("div",{className:"settings-field",children:e.jsx(I,{id:"workspace-profile-select",value:s,onChange:t=>a(t),ariaLabel:r("workspace.profileLabel"),items:Me.map(t=>({value:t.value,label:r(t.labelKey)}))})})}function Ae(){const{t:s}=C(),[a,r]=d.useState(null);d.useEffect(()=>{fetch("/api/config/grok-planner").then(n=>n.json()).then(r).catch(()=>{})},[]);const t=async n=>{try{await fetch("/api/config/grok-planner",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:n})}),r(h=>h?{...h,model:n}:null)}catch{}};return a?e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.grokPlanner.title")}),e.jsx("p",{children:s("settings.grokPlanner.body")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(I,{items:a.options.map(n=>({value:n,label:n})),value:a.model,onChange:n=>{t(n)},ariaLabel:s("settings.grokPlanner.title")})})]}):null}function Oe(s){return s==="connected"?"ok":s==="error"||s==="offline"?"err":"warn"}function Re(s){const a=s.status.snapshotDiff;return a?a.drifted.length+a.missing.length+a.added.length:0}function Pe(){const{t:s}=C(),{providers:a,loading:r,error:t,refresh:n}=de(),[h,u]=d.useState(null),[c,x]=d.useState(!1),[p,m]=d.useState(null),j=async()=>{if(!c){x(!0);try{await n()}finally{x(!1)}}},b=async(g,i)=>{u({provider:g.id,action:i}),m(null);try{i==="connect"?await ue(g.id):i==="refresh"?await ge(g.id):await he(g.id),await n()}catch(f){const y=f instanceof Error&&f.message==="MCP_POPUP_BLOCKED"?s("mcp.popupBlocked"):s("mcp.connectionActionFailed");m({provider:g.id,message:y})}finally{u(null)}};return e.jsxs("div",{"aria-labelledby":"mcp-provider-connections-title",children:[e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{id:"mcp-provider-connections-title",children:s("mcp.connectionsTitle")}),e.jsx("p",{children:s("mcp.connectionsBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx("button",{type:"button",className:"settings-action-btn",onClick:()=>{j()},disabled:r||c,"aria-busy":r||c,children:s(r||c?"mcp.loadingProviders":"mcp.refreshList")})})]}),t?e.jsx("p",{role:"alert",className:"settings-row__microcopy",children:s("mcp.providersLoadFailed")}):null,a.map(g=>{const i=g.status.state,f=!g.enabled||g.executable===!1,y=h?.provider===g.id?h.action:null,k=y!==null,S=Re(g);return e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("h4",{children:g.id}),e.jsx("span",{className:"provider-card__eyebrow",children:"MCP"}),e.jsx("span",{className:`provider-chip provider-chip--${Oe(i)}`,children:s(`mcp.status.${i}`)})]}),e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("p",{children:g.endpoint}),e.jsxs("p",{children:[typeof g.status.toolCount=="number"?s("mcp.toolCount",{count:g.status.toolCount}):s("mcp.toolCountUnknown"),S>0?` · ${s("mcp.snapshotChanges",{count:S})}`:""]}),f?e.jsx("p",{className:"settings-row__microcopy",children:g.enabled?g.lockReason??s("mcp.higgsfieldLocked"):s("mcp.disabledProvider")}):g.status.detail?e.jsx("p",{className:"settings-row__microcopy",children:g.status.detail}):null,p?.provider===g.id?e.jsx("p",{role:"alert",className:"settings-row__microcopy",children:p.message}):null]}),e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__eyebrow",children:s("mcp.billingLabel")}),e.jsx("span",{className:"provider-chip provider-chip--warn",children:s("mcp.billingUnknown")})]}),e.jsx("div",{className:"settings-row__control","aria-live":"polite",children:i==="connected"&&!f?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"settings-action-btn",onClick:()=>{b(g,"refresh")},disabled:k,"aria-busy":y==="refresh",children:s(y==="refresh"?"mcp.refreshingConnection":"mcp.refreshConnection")}),e.jsx("button",{type:"button",className:"settings-action-btn settings-action-btn--danger",onClick:()=>{b(g,"disconnect")},disabled:k,"aria-busy":y==="disconnect",children:s("mcp.disconnect")})]}):e.jsx("button",{type:"button",className:"settings-action-btn",onClick:()=>{b(g,"connect")},disabled:k||f,"aria-busy":y==="connect",title:s(f?"mcp.higgsfieldLocked":"mcp.connectOpensBrowser"),children:s(y==="connect"?"mcp.connecting":"mcp.connect")})})]},g.id)})]})}const P=["providers","workspace","general"];function F({id:s,setRef:a,children:r}){const{t}=C();return e.jsxs("section",{id:s,ref:n=>a(s,n),className:"settings-section","aria-labelledby":`settings-section-${s}`,children:[e.jsx("header",{className:"settings-section__header",children:e.jsx("h3",{id:`settings-section-${s}`,children:t(`settings.sections.${s}.title`)})}),e.jsx("div",{className:"settings-section__body",children:r})]})}function $e(){const{t:s}=C(),a=N(i=>i.activeSettingsSection),r=N(i=>i.setActiveSettingsSection),t=N(i=>i.closeSettings),n=N(i=>i.openReadinessPopup),h=N(i=>i.galleryDefaultScope),u=N(i=>i.setGalleryDefaultScope),c=N(i=>i.provider),x=d.useRef(null),p=d.useRef(null),m=d.useRef(!1),j=d.useRef({providers:null,workspace:null,general:null}),b=(i,f)=>{j.current[i]=f},g=i=>{r(i),m.current=!0;const f=x.current,y=j.current[i];if(f&&y){const k=f.getBoundingClientRect().top,S=y.getBoundingClientRect().top,w=Number.parseFloat(window.getComputedStyle(y).scrollMarginTop)||0;f.scrollTo({top:f.scrollTop+S-k-w,behavior:"auto"})}p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{m.current=!1,p.current=null},120)};return d.useEffect(()=>{const i=f=>{f.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),d.useEffect(()=>{const i=x.current;if(!i||typeof IntersectionObserver!="function")return;const f=new IntersectionObserver(y=>{if(m.current)return;const S=y.filter(w=>w.isIntersecting).sort((w,K)=>K.intersectionRatio-w.intersectionRatio)[0]?.target.id;S&&P.includes(S)&&r(S)},{root:i,threshold:[.35,.6]});for(const y of P){const k=j.current[y];k&&f.observe(k)}return()=>f.disconnect()},[r]),d.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]),e.jsx("main",{className:"settings-workspace","aria-labelledby":"settings-title",children:e.jsxs("div",{className:"settings-shell",children:[e.jsxs("header",{className:"settings-header",children:[e.jsx("div",{children:e.jsx("h2",{id:"settings-title",children:s("settings.title")})}),e.jsx("button",{type:"button",className:"settings-close",onClick:t,"aria-label":s("settings.closeAria"),title:s("settings.closeTitle"),children:"X"})]}),e.jsxs("div",{className:"settings-layout",children:[e.jsx("nav",{className:"settings-nav settings-nav--mobile","aria-label":s("settings.navAria"),children:e.jsx("div",{className:"settings-mobile-nav",role:"list",children:P.map(i=>e.jsxs("button",{type:"button",className:`settings-mobile-nav__item${a===i?" is-active":""}`,onClick:()=>g(i),"aria-current":a===i?"true":void 0,children:[e.jsx("span",{children:s(`settings.sections.${i}.title`)}),e.jsx("small",{children:s(`settings.sections.${i}.hint`)})]},i))})}),e.jsx("nav",{className:"settings-nav","aria-label":s("settings.navAria"),children:P.map(i=>e.jsxs("button",{type:"button",className:`settings-nav__item${a===i?" is-active":""}`,onClick:()=>g(i),"aria-label":s("settings.jumpTo",{section:s(`settings.sections.${i}.title`)}),children:[e.jsx("span",{children:s(`settings.sections.${i}.title`)}),e.jsx("small",{children:s(`settings.sections.${i}.hint`)})]},i))}),e.jsxs("section",{ref:x,className:"settings-content","aria-label":s("settings.contentAria"),children:[e.jsxs(F,{id:"providers",setRef:b,children:[e.jsx(ke,{}),e.jsx(Pe,{}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("readiness.settingsTitle")}),e.jsx("p",{children:s("readiness.settingsBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx("button",{type:"button",className:"settings-action-btn",onClick:n,children:s("readiness.open")})})]}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.imageModel.title")}),e.jsx("p",{children:s("settings.imageModel.body")}),e.jsx("p",{className:"settings-row__microcopy",children:s("settings.imageModel.unsupportedHelp")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(Se,{variant:"settings"})})]}),c==="grok"?e.jsxs(e.Fragment,{children:[e.jsx("article",{className:"settings-row",children:e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.grokCompatibility.title")}),e.jsx("p",{children:s("settings.grokCompatibility.body")})]})}),e.jsx(Ae,{})]}):c==="agy"||c==="gemini-api"?e.jsx("article",{className:"settings-row",children:e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s(c==="gemini-api"?"provider.geminiApiCompatTitle":"provider.agyCompatTitle")}),e.jsx("p",{children:s(c==="gemini-api"?"provider.geminiApiCompatBodyLong":"provider.agyCompatBodyLong")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.reasoning.title")}),e.jsx("p",{children:s("settings.reasoning.body")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(Ce,{})})]}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.webSearch.title")}),e.jsx("p",{children:s("settings.webSearch.body")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(pe,{})})]})]})]}),e.jsxs(F,{id:"workspace",setRef:b,children:[e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("workspace.sectionTitle")}),e.jsx("p",{children:s("workspace.sectionBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(Ie,{})})]}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.appearance.historyStripLayoutTitle")}),e.jsx("p",{children:s("settings.appearance.historyStripLayoutBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(Te,{})})]}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.gallery.defaultScopeTitle")}),e.jsx("p",{children:s("settings.gallery.defaultScopeBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(I,{ariaLabel:s("settings.gallery.defaultScopeTitle"),value:h,onChange:i=>u(i),items:[{value:"current-session",label:s("gallery.scope.current")},{value:"all",label:s("gallery.scope.all")}]})})]})]}),e.jsx(F,{id:"general",setRef:b,children:e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.language.title")}),e.jsx("p",{children:s("settings.language.body")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(Ee,{})})]})})]})]})]})})}export{$e as SettingsWorkspace};
@@ -1 +1 @@
1
- import{u as h,j as e,a as m,b as x}from"./index-XXtoj9ME.js";import{P as j}from"./AssetGenWorkspace-8fK-K64E.js";import"./KeyingPanel-CEBLIhhu.js";import"./useAgentDialogFocus-PWmMjerz.js";function v({draft:i,disabled:s,errors:l,onChange:a,onSubmit:n}){const{t:r}=h(),c=t=>e.jsxs("label",{children:[r(`sprite.recipe.${t}`),e.jsx("input",{value:i[t],disabled:s,"aria-invalid":!!l[t],onChange:p=>a({[t]:p.target.value})}),l[t]?e.jsx("span",{role:"alert",children:l[t]}):null]});return e.jsxs("form",{className:"sprite-recipe-form",onSubmit:t=>{t.preventDefault(),n()},children:[c("name"),c("characterId"),c("description"),c("style"),c("baseAssetId"),e.jsxs("fieldset",{children:[e.jsx("legend",{children:r("sprite.cell.title")}),["width","height","safeMarginX","safeMarginY"].map(t=>e.jsxs("label",{children:[r(`sprite.cell.${t}`),e.jsx("input",{type:"number",min:"0",value:i.cell[t],onChange:p=>a({cell:{...i.cell,[t]:Number(p.target.value)}})})]},t))]}),e.jsxs("label",{children:[r("sprite.chroma.hex"),e.jsx("input",{type:"color",value:i.chroma.hex,onChange:t=>a({chroma:{...i.chroma,hex:t.target.value}})})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{children:r("sprite.states.title")}),i.states.map((t,p)=>e.jsxs("div",{className:"sprite-state",children:[e.jsx("input",{"aria-label":r("sprite.states.key"),value:t.key,onChange:d=>a({states:i.states.map((o,u)=>u===p?{...o,key:d.target.value}:o)})}),e.jsx("input",{"aria-label":r("sprite.states.frames"),type:"number",min:"1",value:t.frames,onChange:d=>a({states:i.states.map((o,u)=>u===p?{...o,frames:Number(d.target.value)}:o)})}),e.jsx("button",{type:"button",onClick:()=>a({states:i.states.filter((d,o)=>o!==p)}),children:r("sprite.states.remove")})]},`${t.key}-${p}`)),e.jsx("button",{type:"button",onClick:()=>a({states:[...i.states,{key:"",frames:4,fps:8,loop:!0,action:""}]}),children:r("sprite.states.add")})]}),e.jsx("button",{className:"assetgen-generate",disabled:s||!i.name.trim()||!i.characterId.trim(),children:r(s?"sprite.recipe.saving":"sprite.recipe.save")})]})}function g({recipe:i,candidate:s,generating:l,onGenerate:a,onApprove:n}){const{t:r}=h(),[c,t]=m.useState(!1);return e.jsxs("section",{className:"sprite-anchor-gate","aria-labelledby":"sprite-anchor-title",children:[e.jsx("h2",{id:"sprite-anchor-title",children:r("sprite.anchor.title")}),s?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:s.url,alt:""}),e.jsx("p",{children:r("sprite.anchor.candidate")}),e.jsx("button",{onClick:a,disabled:l,children:r("sprite.anchor.regenerate")}),e.jsx("button",{onClick:()=>t(!0),children:r("sprite.anchor.approve")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{children:r(i.anchorStatus==="approved"?"sprite.anchor.approved":"sprite.anchor.missing")}),e.jsx("button",{onClick:a,disabled:l,children:r(l?"sprite.anchor.generating":"sprite.anchor.generate")})]}),c?e.jsxs("div",{className:"sprite-anchor-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"sprite-confirm-title",children:[e.jsx("h3",{id:"sprite-confirm-title",children:r("sprite.anchor.confirmTitle")}),e.jsx("p",{children:r("sprite.anchor.confirmBody")}),e.jsx("button",{onClick:()=>t(!1),children:r("sprite.anchor.cancel")}),e.jsx("button",{onClick:()=>{n(s.assetId),t(!1)},children:r("sprite.anchor.confirm")})]}):null]})}function b({recipe:i,selected:s,onSelectionChange:l,onGenerate:a,onCancel:n,onPreview:r}){const{t:c}=h();return e.jsxs("section",{className:"sprite-row-list","aria-live":"polite",children:[e.jsx("h2",{children:c("sprite.rows.title")}),e.jsxs("div",{className:"sprite-row-actions",children:[e.jsx("button",{onClick:()=>a(),children:c("sprite.rows.generateAll")}),e.jsx("button",{disabled:!s.length,onClick:()=>a(s),children:c("sprite.rows.generateSelected")})]}),i.rows.map(t=>e.jsxs("article",{children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:s.includes(t.stateKey),onChange:()=>l(s.includes(t.stateKey)?s.filter(p=>p!==t.stateKey):[...s,t.stateKey])}),t.stateKey]}),e.jsx("span",{children:c(`sprite.rows.status.${t.status}`)}),t.progress!=null?e.jsx("progress",{value:t.progress,max:"100"}):null,t.imageUrl||t.previewUrl?e.jsxs("button",{onClick:()=>r(t),children:[e.jsx("img",{src:t.imageUrl||t.previewUrl,alt:""}),c("sprite.rows.preview")]}):null,t.status==="error"?e.jsx("button",{onClick:()=>a([t.stateKey]),children:c("sprite.rows.regenerate")}):null,t.requestId&&(t.status==="running"||t.status==="queued")?e.jsx("button",{onClick:()=>n(t.requestId),children:c("sprite.rows.cancel")}):null,t.error?e.jsx("p",{role:"alert",children:t.error}):null]},t.stateKey))]})}function C(){const{t:i}=h(),s=x();m.useEffect(()=>{s.loadSpriteRecipes()},[]);const l=s.activeSpriteRecipe,a=s.spriteRecipeDraft.name.trim()?{}:{name:i("sprite.error.INVALID_SPRITE_RECIPE")};return e.jsxs("section",{className:"sprite-recipe-workspace",children:[e.jsxs("aside",{children:[e.jsx(j,{}),e.jsxs("label",{children:[i("sprite.recipe.select"),e.jsxs("select",{value:s.activeSpriteRecipeId??"",onChange:n=>{s.selectSpriteRecipe(n.target.value||null)},children:[e.jsx("option",{value:"",children:i("sprite.recipe.new")}),s.spriteRecipes.map(n=>e.jsx("option",{value:n.id,children:n.name},n.id))]})]}),e.jsx(v,{draft:s.spriteRecipeDraft,disabled:s.spriteRecipeSaving,errors:a,onChange:s.updateSpriteRecipeDraft,onSubmit:()=>{s.saveSpriteRecipe()}})]}),e.jsxs("main",{children:[s.spriteRecipeError?e.jsxs("div",{role:"alert",children:[s.spriteRecipeError,e.jsx("button",{onClick:()=>{s.loadSpriteRecipes()},children:i("sprite.retry")})]}):null,s.spriteRecipeLoading?e.jsx("p",{role:"status",children:i("sprite.loading")}):l?l.anchorStatus!=="approved"?e.jsx(g,{recipe:l,candidate:l.candidate??null,generating:s.spriteRecipeGenerating,onGenerate:()=>{s.generateSpriteAnchor()},onApprove:n=>{s.approveSpriteAnchor(n)}}):e.jsx(b,{recipe:l,selected:s.spriteSelectedStates,onSelectionChange:n=>x.setState({spriteSelectedStates:n}),onGenerate:n=>{s.generateSpriteRows(n)},onCancel:n=>{s.cancelSpriteJob(n)},onPreview:()=>{}}):e.jsxs("div",{className:"sprite-empty",children:[e.jsx("h2",{children:i("sprite.empty.title")}),e.jsx("p",{children:i("sprite.empty.body")})]})]})]})}export{C as SpriteRecipeWorkspace};
1
+ import{u as h,j as e,a as m,b as x}from"./index-CxEuSZMC.js";import{P as j}from"./AssetGenWorkspace-CqXyN9at.js";import"./KeyingPanel-Bv0n_bhk.js";import"./useAgentDialogFocus-R64NV-ZZ.js";function v({draft:i,disabled:s,errors:l,onChange:a,onSubmit:n}){const{t:r}=h(),c=t=>e.jsxs("label",{children:[r(`sprite.recipe.${t}`),e.jsx("input",{value:i[t],disabled:s,"aria-invalid":!!l[t],onChange:p=>a({[t]:p.target.value})}),l[t]?e.jsx("span",{role:"alert",children:l[t]}):null]});return e.jsxs("form",{className:"sprite-recipe-form",onSubmit:t=>{t.preventDefault(),n()},children:[c("name"),c("characterId"),c("description"),c("style"),c("baseAssetId"),e.jsxs("fieldset",{children:[e.jsx("legend",{children:r("sprite.cell.title")}),["width","height","safeMarginX","safeMarginY"].map(t=>e.jsxs("label",{children:[r(`sprite.cell.${t}`),e.jsx("input",{type:"number",min:"0",value:i.cell[t],onChange:p=>a({cell:{...i.cell,[t]:Number(p.target.value)}})})]},t))]}),e.jsxs("label",{children:[r("sprite.chroma.hex"),e.jsx("input",{type:"color",value:i.chroma.hex,onChange:t=>a({chroma:{...i.chroma,hex:t.target.value}})})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{children:r("sprite.states.title")}),i.states.map((t,p)=>e.jsxs("div",{className:"sprite-state",children:[e.jsx("input",{"aria-label":r("sprite.states.key"),value:t.key,onChange:d=>a({states:i.states.map((o,u)=>u===p?{...o,key:d.target.value}:o)})}),e.jsx("input",{"aria-label":r("sprite.states.frames"),type:"number",min:"1",value:t.frames,onChange:d=>a({states:i.states.map((o,u)=>u===p?{...o,frames:Number(d.target.value)}:o)})}),e.jsx("button",{type:"button",onClick:()=>a({states:i.states.filter((d,o)=>o!==p)}),children:r("sprite.states.remove")})]},`${t.key}-${p}`)),e.jsx("button",{type:"button",onClick:()=>a({states:[...i.states,{key:"",frames:4,fps:8,loop:!0,action:""}]}),children:r("sprite.states.add")})]}),e.jsx("button",{className:"assetgen-generate",disabled:s||!i.name.trim()||!i.characterId.trim(),children:r(s?"sprite.recipe.saving":"sprite.recipe.save")})]})}function g({recipe:i,candidate:s,generating:l,onGenerate:a,onApprove:n}){const{t:r}=h(),[c,t]=m.useState(!1);return e.jsxs("section",{className:"sprite-anchor-gate","aria-labelledby":"sprite-anchor-title",children:[e.jsx("h2",{id:"sprite-anchor-title",children:r("sprite.anchor.title")}),s?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:s.url,alt:""}),e.jsx("p",{children:r("sprite.anchor.candidate")}),e.jsx("button",{onClick:a,disabled:l,children:r("sprite.anchor.regenerate")}),e.jsx("button",{onClick:()=>t(!0),children:r("sprite.anchor.approve")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{children:r(i.anchorStatus==="approved"?"sprite.anchor.approved":"sprite.anchor.missing")}),e.jsx("button",{onClick:a,disabled:l,children:r(l?"sprite.anchor.generating":"sprite.anchor.generate")})]}),c?e.jsxs("div",{className:"sprite-anchor-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"sprite-confirm-title",children:[e.jsx("h3",{id:"sprite-confirm-title",children:r("sprite.anchor.confirmTitle")}),e.jsx("p",{children:r("sprite.anchor.confirmBody")}),e.jsx("button",{onClick:()=>t(!1),children:r("sprite.anchor.cancel")}),e.jsx("button",{onClick:()=>{n(s.assetId),t(!1)},children:r("sprite.anchor.confirm")})]}):null]})}function b({recipe:i,selected:s,onSelectionChange:l,onGenerate:a,onCancel:n,onPreview:r}){const{t:c}=h();return e.jsxs("section",{className:"sprite-row-list","aria-live":"polite",children:[e.jsx("h2",{children:c("sprite.rows.title")}),e.jsxs("div",{className:"sprite-row-actions",children:[e.jsx("button",{onClick:()=>a(),children:c("sprite.rows.generateAll")}),e.jsx("button",{disabled:!s.length,onClick:()=>a(s),children:c("sprite.rows.generateSelected")})]}),i.rows.map(t=>e.jsxs("article",{children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:s.includes(t.stateKey),onChange:()=>l(s.includes(t.stateKey)?s.filter(p=>p!==t.stateKey):[...s,t.stateKey])}),t.stateKey]}),e.jsx("span",{children:c(`sprite.rows.status.${t.status}`)}),t.progress!=null?e.jsx("progress",{value:t.progress,max:"100"}):null,t.imageUrl||t.previewUrl?e.jsxs("button",{onClick:()=>r(t),children:[e.jsx("img",{src:t.imageUrl||t.previewUrl,alt:""}),c("sprite.rows.preview")]}):null,t.status==="error"?e.jsx("button",{onClick:()=>a([t.stateKey]),children:c("sprite.rows.regenerate")}):null,t.requestId&&(t.status==="running"||t.status==="queued")?e.jsx("button",{onClick:()=>n(t.requestId),children:c("sprite.rows.cancel")}):null,t.error?e.jsx("p",{role:"alert",children:t.error}):null]},t.stateKey))]})}function C(){const{t:i}=h(),s=x();m.useEffect(()=>{s.loadSpriteRecipes()},[]);const l=s.activeSpriteRecipe,a=s.spriteRecipeDraft.name.trim()?{}:{name:i("sprite.error.INVALID_SPRITE_RECIPE")};return e.jsxs("section",{className:"sprite-recipe-workspace",children:[e.jsxs("aside",{children:[e.jsx(j,{}),e.jsxs("label",{children:[i("sprite.recipe.select"),e.jsxs("select",{value:s.activeSpriteRecipeId??"",onChange:n=>{s.selectSpriteRecipe(n.target.value||null)},children:[e.jsx("option",{value:"",children:i("sprite.recipe.new")}),s.spriteRecipes.map(n=>e.jsx("option",{value:n.id,children:n.name},n.id))]})]}),e.jsx(v,{draft:s.spriteRecipeDraft,disabled:s.spriteRecipeSaving,errors:a,onChange:s.updateSpriteRecipeDraft,onSubmit:()=>{s.saveSpriteRecipe()}})]}),e.jsxs("main",{children:[s.spriteRecipeError?e.jsxs("div",{role:"alert",children:[s.spriteRecipeError,e.jsx("button",{onClick:()=>{s.loadSpriteRecipes()},children:i("sprite.retry")})]}):null,s.spriteRecipeLoading?e.jsx("p",{role:"status",children:i("sprite.loading")}):l?l.anchorStatus!=="approved"?e.jsx(g,{recipe:l,candidate:l.candidate??null,generating:s.spriteRecipeGenerating,onGenerate:()=>{s.generateSpriteAnchor()},onApprove:n=>{s.approveSpriteAnchor(n)}}):e.jsx(b,{recipe:l,selected:s.spriteSelectedStates,onSelectionChange:n=>x.setState({spriteSelectedStates:n}),onGenerate:n=>{s.generateSpriteRows(n)},onCancel:n=>{s.cancelSpriteJob(n)},onPreview:()=>{}}):e.jsxs("div",{className:"sprite-empty",children:[e.jsx("h2",{children:i("sprite.empty.title")}),e.jsx("p",{children:i("sprite.empty.body")})]})]})]})}export{C as SpriteRecipeWorkspace};