crewx 0.8.6-rc.5 → 0.8.6-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{MarketPage-mVKZxAhV.js → MarketPage-B9p1jCZM.js} +5 -5
- package/dist/assets/{PromptTab-CHZVcQ0-.js → PromptTab-B6alya5Y.js} +7 -7
- package/dist/assets/{arc-DvfI2u44.js → arc-BnOowx7b.js} +1 -1
- package/dist/assets/architectureDiagram-UYN6MBPD-DpWepWlq.js +36 -0
- package/dist/assets/blockDiagram-ZHA2E4KO-D4dQzhTw.js +121 -0
- package/dist/assets/{c4Diagram-6F5ED5ID-iHz_3Ous.js → c4Diagram-6F5ED5ID-BOFHPGH4.js} +1 -1
- package/dist/assets/channel-B5-t1F_R.js +1 -0
- package/dist/assets/{chunk-5HRBRIJM-Dvamw7fs.js → chunk-5HRBRIJM-Izr_7J6b.js} +1 -1
- package/dist/assets/{chunk-7U56Z5CX-Cu_JH-RY.js → chunk-7U56Z5CX-4pCO3vUT.js} +1 -1
- package/dist/assets/{chunk-ASOPGD6M-6px_k6Np.js → chunk-ASOPGD6M-341SL8LK.js} +1 -1
- package/dist/assets/{chunk-KFBOBJHC-DLGOlW0g.js → chunk-KFBOBJHC-DA3_U6Ss.js} +1 -1
- package/dist/assets/{chunk-T2TOU4HS-D30qMJj9.js → chunk-T2TOU4HS-C3Eves8b.js} +1 -1
- package/dist/assets/{chunk-TMUBEWPD-Drcfx8Gk.js → chunk-TMUBEWPD-De4j_N23.js} +1 -1
- package/dist/assets/classDiagram-LNE6IOMH-BP2EiNBf.js +1 -0
- package/dist/assets/classDiagram-v2-MQ7JQ4JX-BP2EiNBf.js +1 -0
- package/dist/assets/dagre-4EVJKHTY-4pLPU8fC.js +4 -0
- package/dist/assets/diagram-QW4FP2JN-C2G2AfKZ.js +24 -0
- package/dist/assets/{erDiagram-6RL3IURR-snPgs7kz.js → erDiagram-6RL3IURR-O6W9AKEL.js} +2 -2
- package/dist/assets/{flowDiagram-7ASYPVHJ-DKbBapLU.js → flowDiagram-7ASYPVHJ-CU2ThLkX.js} +1 -1
- package/dist/assets/{ganttDiagram-NTVNEXSI-CEcJRPl_.js → ganttDiagram-NTVNEXSI-Cygfk2I9.js} +3 -3
- package/dist/assets/gitGraph-YCYPL57B-GW6UyAl1.js +133 -0
- package/dist/assets/gitGraphDiagram-NRZ2UAAF-CYiwmB3t.js +65 -0
- package/dist/assets/graph-BlwPajkw.js +1 -0
- package/dist/assets/infoDiagram-A4XQUW5V-CgybL7D6.js +2 -0
- package/dist/assets/{journeyDiagram-G5WM74LC-CZHCM3j3.js → journeyDiagram-G5WM74LC-BGtGSh98.js} +1 -1
- package/dist/assets/{kanban-definition-QRCXZQQD-Dgpn6JHA.js → kanban-definition-QRCXZQQD-DWHExtnz.js} +1 -1
- package/dist/assets/layout-Bvwu4dCi.js +1 -0
- package/dist/assets/{linear-CsJv5BvN.js → linear-CMGNzu-C.js} +1 -1
- package/dist/assets/{main-D83eZdBk.js → main-DgXktCKZ.js} +5 -5
- package/dist/assets/{mindmap-definition-GWI6TPTV-Ddc-wr24.js → mindmap-definition-GWI6TPTV-BY1fpgzu.js} +1 -1
- package/dist/assets/pieDiagram-YF2LJOPJ-DO04PFao.js +30 -0
- package/dist/assets/{quadrantDiagram-OS5C2QUG-BfnCmQHo.js → quadrantDiagram-OS5C2QUG-CaEXe7D8.js} +1 -1
- package/dist/assets/{requirementDiagram-MIRIMTAZ-BCwCsU93.js → requirementDiagram-MIRIMTAZ-CcYJEXCA.js} +2 -2
- package/dist/assets/{sankeyDiagram-Y46BX6SQ-BI0jILV9.js → sankeyDiagram-Y46BX6SQ-BLjO2tfL.js} +1 -1
- package/dist/assets/{sequenceDiagram-G6AWOVSC-CVHmaxGU.js → sequenceDiagram-G6AWOVSC-DakpjQoP.js} +1 -1
- package/dist/assets/stateDiagram-MAYHULR4-DTYPjV3D.js +1 -0
- package/dist/assets/stateDiagram-v2-4JROLMXI-DvqQAajG.js +1 -0
- package/dist/assets/{timeline-definition-U7ZMHBDA-DPP6BzEU.js → timeline-definition-U7ZMHBDA-CfD6vbfv.js} +1 -1
- package/dist/assets/{xychartDiagram-6QU3TZC5-D6e0Gp3a.js → xychartDiagram-6QU3TZC5-Bq7bgIBm.js} +2 -2
- package/dist/index.html +1 -1
- package/dist-server/adapters/adapter.service.js +17 -7
- package/dist-server/adapters/http-router.service.js +2 -2
- package/dist-server/app.module.js +1 -0
- package/dist-server/bootstrap/crewx-server.js +2 -2
- package/dist-server/bootstrap/tls.js +2 -2
- package/dist-server/common/cors.js +1 -2
- package/dist-server/common/interceptor/http-logging.interceptor.js +1 -1
- package/dist-server/common/middleware/workspace.middleware.js +17 -7
- package/dist-server/common/workspace-context.store.js +3 -3
- package/dist-server/domain/agent/agent.service.js +1 -1
- package/dist-server/domain/auth/guards/base-auth.guard.js +5 -2
- package/dist-server/domain/auth/session-store.js +3 -4
- package/dist-server/domain/auth/utils/ip.utils.js +5 -6
- package/dist-server/domain/cli/cli.service.js +9 -9
- package/dist-server/domain/fs/fs.service.js +17 -7
- package/dist-server/domain/git/git.service.js +18 -8
- package/dist-server/domain/mcp/crewx-tool.factory.js +1 -2
- package/dist-server/domain/mcp/tool-router.service.js +5 -5
- package/dist-server/domain/skill/skill.service.js +17 -7
- package/dist-server/domain/task/task.service.js +7 -1
- package/dist-server/domain/usage/usage.service.js +17 -7
- package/dist-server/domain/workflow/workflow.service.js +17 -7
- package/dist-server/domain/workspace/workspace.service.js +17 -7
- package/dist-server/main.js +17 -7
- package/dist-server/shared/crewx-home.js +18 -9
- package/dist-server/shared/crewx-state.js +19 -10
- package/dist-server/utils/tokenizer.js +1 -2
- package/package.json +20 -25
- package/packages/cli/dist/bootstrap/crewx-cli.js +1 -0
- package/packages/cli/package.json +2 -2
- package/dist/assets/_baseUniq-Db1u033g.js +0 -1
- package/dist/assets/architectureDiagram-UYN6MBPD-DLBgy7Pv.js +0 -36
- package/dist/assets/blockDiagram-ZHA2E4KO-BRtXBq3c.js +0 -121
- package/dist/assets/channel-B6fPa9rF.js +0 -1
- package/dist/assets/classDiagram-LNE6IOMH-V5r85D9M.js +0 -1
- package/dist/assets/classDiagram-v2-MQ7JQ4JX-V5r85D9M.js +0 -1
- package/dist/assets/clone-DA0G-j1Y.js +0 -1
- package/dist/assets/dagre-4EVJKHTY-DMUzQU_t.js +0 -4
- package/dist/assets/diagram-QW4FP2JN-DxehNWAY.js +0 -24
- package/dist/assets/gitGraph-YCYPL57B-CdEdvjry.js +0 -133
- package/dist/assets/gitGraphDiagram-NRZ2UAAF-DTulb7Ly.js +0 -65
- package/dist/assets/graph-D9ElhIkL.js +0 -1
- package/dist/assets/infoDiagram-A4XQUW5V-CQfyXyRH.js +0 -2
- package/dist/assets/layout-mj1X2Ybo.js +0 -1
- package/dist/assets/min-CaqYNmLk.js +0 -1
- package/dist/assets/pieDiagram-YF2LJOPJ-iFWXxfMM.js +0 -30
- package/dist/assets/stateDiagram-MAYHULR4-9teeMOYD.js +0 -1
- package/dist/assets/stateDiagram-v2-4JROLMXI-zpa2BPhE.js +0 -1
- package/dist-server/package.json +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aB as v,aC as we,aD as b,aE as k,aF as Se,aG as u,aH as e,aI as ae,aJ as se,aK as Y,aL as N,aM as re,aN as Ie,aO as le,aP as O,aQ as ze,aR as Ce,aS as ie,aT as Re,aU as Me}from"./main-DgXktCKZ.js";/**
|
|
2
2
|
* @license lucide-react v0.563.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -18,19 +18,19 @@ import{aJ as v,aK as we,aL as b,aM as k,aN as Se,aO as u,aP as e,aQ as ae,aR as
|
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const Ee=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],oe=v("puzzle",Ee);/**
|
|
22
22
|
* @license lucide-react v0.563.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const $e=[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"m19 8 3 8a5 5 0 0 1-6 0zV7",key:"zcdpyk"}],["path",{d:"M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1",key:"1yorad"}],["path",{d:"m5 8 3 8a5 5 0 0 1-6 0zV7",key:"eua70x"}],["path",{d:"M7 21h10",key:"1b0cd5"}]],_e=v("scale",$e);/**
|
|
27
27
|
* @license lucide-react v0.563.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const Fe=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Ve=v("settings-2",Fe);/**
|
|
32
32
|
* @license lucide-react v0.563.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const Pe=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],Oe=v("star",Pe);function I(t){return t instanceof Error?t.message:String(t)}function Ue(t){return[...t].sort((a,s)=>a.isInstalled!==s.isInstalled?a.isInstalled?-1:1:(a.displayName||a.name).localeCompare(s.displayName||s.name))}function Be(t=[],a=[]){return Array.from(new Set([...t,...a]))}function He(t,a){var s;return t?{...t,...a,displayName:a.displayName||t.displayName||a.name,description:a.description||t.description,author:a.author||t.author,version:a.version||t.version,tags:Be(t.tags,a.tags),type:a.type||t.type,isVerified:t.isVerified||a.isVerified,isInstalled:t.isInstalled||a.isInstalled,registryId:a.registryId??t.registryId,registryName:a.registryName??t.registryName,installSource:a.installSource??t.installSource,authors:(s=a.authors)!=null&&s.length?a.authors:t.authors,updatedAt:a.updatedAt??t.updatedAt,stars:a.stars??t.stars,license:a.license??t.license,installCount:a.installCount??t.installCount}:a}function T(t){const a=new Map;for(const s of t){const r=a.get(s.name);a.set(s.name,He(r,s))}return Ue(Array.from(a.values()))}function Qe(t,a){return t.map(s=>({...s,registryId:s.registryId??a.id,registryName:s.registryName??a.name,isVerified:s.isVerified||a.isVerified}))}function qe(t){return t.find(a=>a.isDefault)??t.find(a=>a.isVerified)??t[0]??null}function We(t,a){return T([...t,...a])}function O(t,a){var s;return a&&t.some(r=>r.name===a)?a:((s=t[0])==null?void 0:s.name)??null}const Ze=we((t,a)=>({initialized:!1,loading:!1,loadingOfficial:!1,loadingInstalled:!1,savingRegistry:!1,deletingRegistryId:null,mutatingSkillName:null,error:null,registries:[],officialRegistryId:null,allSkills:[],activeFilter:"all",searchQuery:"",selectedSkillName:null,setActiveFilter:s=>t({activeFilter:s}),setSearchQuery:s=>t({searchQuery:s}),setSelectedSkill:s=>t({selectedSkillName:s}),initialize:async()=>{const s=a().selectedSkillName;t({loading:!0,loadingOfficial:!0,loadingInstalled:!0,error:null});try{const n=(await b.getSkillRegistries()).registries,o=qe(n),[d,m]=await Promise.all([o?b.getRegistrySkills(o.id):Promise.resolve({skills:[]}),b.getInstalledSkills()]),y=o?Qe(d.skills,o):[],c=T(m.skills.filter(f=>!f.source||f.source==="local")),h=We(y,c);t({initialized:!0,loading:!1,loadingOfficial:!1,loadingInstalled:!1,registries:n,officialRegistryId:(o==null?void 0:o.id)??null,allSkills:h,selectedSkillName:O(h,s)})}catch(r){throw t({loading:!1,loadingOfficial:!1,loadingInstalled:!1,error:I(r)}),r}},refresh:async()=>{await a().initialize()},addRegistry:async s=>{const r=s.trim();if(!r){const n=new Error("Registry URL is required");throw t({error:n.message}),n}t({savingRegistry:!0,error:null});try{await b.addSkillRegistry(r),await a().initialize(),t({savingRegistry:!1})}catch(n){throw t({savingRegistry:!1,error:I(n)}),n}},deleteRegistry:async s=>{t({deletingRegistryId:s,error:null});try{await b.deleteSkillRegistry(s),await a().initialize(),t({deletingRegistryId:null})}catch(r){throw t({deletingRegistryId:null,error:I(r)}),r}},installSkill:async(s,r)=>{t({mutatingSkillName:r,error:null});try{await b.installSkill(s,r),t(n=>{const o=n.registries.find(m=>m.id===s),d=T(n.allSkills.map(m=>m.name===r?{...m,isInstalled:!0,registryId:m.registryId??s,registryName:m.registryName??(o==null?void 0:o.name)}:m));return{allSkills:d,mutatingSkillName:null,selectedSkillName:O(d,n.selectedSkillName??r)}})}catch(n){throw t({mutatingSkillName:null,error:I(n)}),n}},uninstallSkill:async s=>{t({mutatingSkillName:s,error:null});try{await b.uninstallSkill(s),t(r=>{const n=T(r.allSkills.map(o=>o.name===s?{...o,isInstalled:!1}:o));return{allSkills:n,mutatingSkillName:null,selectedSkillName:O(n,r.selectedSkillName)}})}catch(r){throw t({mutatingSkillName:null,error:I(r)}),r}},clearError:()=>t({error:null})}));function ce(t,a){if(!t)return"—";const s=new Date(t);return Number.isNaN(s.getTime())?"—":new Intl.DateTimeFormat(a,{year:"numeric",month:"short",day:"numeric"}).format(s)}function Je(t,a){if(!t)return null;const s=new Date(t);if(Number.isNaN(s.getTime()))return null;const r=s.getTime()-Date.now(),n=[{unit:"year",ms:1e3*60*60*24*365},{unit:"month",ms:1e3*60*60*24*30},{unit:"week",ms:1e3*60*60*24*7},{unit:"day",ms:1e3*60*60*24},{unit:"hour",ms:1e3*60*60},{unit:"minute",ms:1e3*60}],o=new Intl.RelativeTimeFormat(a,{numeric:"auto"});for(const d of n)if(Math.abs(r)>=d.ms||d.unit==="minute")return o.format(Math.round(r/d.ms),d.unit);return null}function ee(t,a){return typeof t!="number"?"—":new Intl.NumberFormat(a,{notation:"compact",compactDisplay:"short",maximumFractionDigits:1}).format(t)}function B(t){switch(t==null?void 0:t.toLowerCase()){case"template":return"template";case"agent":return"agent";default:return"skill"}}function me({type:t}){const{t:a}=k(),s=B(t),r={skill:"bg-violet-50 text-violet-700",template:"bg-amber-50 text-amber-700",agent:"bg-emerald-50 text-emerald-700"},n={skill:oe,template:de,agent:re},o={skill:a("market.types.skill"),template:a("market.types.template"),agent:a("market.types.agent")},d=n[s];return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${r[s]}`,children:[e.jsx(d,{size:12}),o[s]]})}function Ke({url:t,error:a,submitting:s,onChange:r,onClose:n,onSubmit:o}){const{t:d}=k(),m=y=>{y.preventDefault(),o()};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true",className:"w-full max-w-xl overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-xl",children:[e.jsxs("div",{className:"border-b border-gray-200 px-6 py-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:d("market.addRegistryModal.title")}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:d("market.addRegistryModal.description")})]}),e.jsxs("form",{onSubmit:m,children:[e.jsxs("div",{className:"space-y-4 px-6 py-5",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"registry-url",className:"mb-2 block text-sm font-medium text-gray-700",children:d("market.addRegistryModal.urlLabel")}),e.jsx("input",{id:"registry-url",type:"url",value:t,onChange:y=>r(y.target.value),placeholder:d("market.addRegistryModal.urlPlaceholder"),className:"w-full rounded-lg border border-gray-300 px-4 py-3 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500",autoFocus:!0})]}),e.jsx("div",{className:"rounded-xl border border-blue-200 bg-blue-50 px-4 py-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-white text-blue-600",children:e.jsx(Ce,{size:18})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-blue-900",children:d("market.addRegistryModal.compatibilityTitle")}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-blue-800",children:d("market.addRegistryModal.compatibilityDescription")})]})]})}),a&&e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-red-700",children:[e.jsx(se,{size:18,className:"mt-0.5 shrink-0"}),e.jsx("p",{className:"text-sm",children:a})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 px-6 py-4",children:[e.jsx("button",{type:"button",onClick:n,disabled:s,className:"rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200 disabled:cursor-not-allowed disabled:opacity-50",children:d("market.actions.cancel")}),e.jsxs("button",{type:"submit",disabled:s,className:"inline-flex items-center gap-2 rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-600 disabled:cursor-not-allowed disabled:opacity-50",children:[s?e.jsx(N,{size:16,className:"animate-spin"}):e.jsx(U,{size:16}),d("market.actions.addRegistry")]})]})]})]})})}function Xe({registry:t,deleting:a,onDelete:s}){const{t:r,i18n:n}=k();return e.jsxs("article",{className:"flex flex-col gap-4 rounded-xl border border-gray-200 bg-white p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-xl ${t.isVerified?"bg-blue-50 text-blue-600":"bg-gray-100 text-gray-500"}`,children:e.jsx(ie,{size:20})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"truncate text-base font-semibold text-gray-900",children:t.name}),e.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${t.isDefault?"bg-amber-50 text-amber-700":"bg-gray-100 text-gray-600"}`,children:t.isDefault?r("market.registryCard.defaultBadge"):r("market.registryCard.customBadge")})]}),e.jsxs("a",{href:t.url,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex break-all text-sm text-blue-600 hover:text-blue-700",children:[e.jsx("span",{children:t.url}),e.jsx(Me,{size:14,className:"ml-1 mt-0.5 shrink-0"})]})]})]}),e.jsxs("button",{type:"button",onClick:()=>s(t.id),disabled:t.isDefault||a,className:`inline-flex items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium transition-colors ${t.isDefault?"cursor-not-allowed bg-gray-100 text-gray-400":"bg-red-50 text-red-600 hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50"}`,children:[a?e.jsx(N,{size:15,className:"animate-spin"}):e.jsx(le,{size:15}),t.isDefault?r("market.registryCard.lockedAction"):r("market.actions.deleteRegistry")]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:r("market.registryCard.skillCount")}),e.jsx("p",{className:"mt-1 text-lg font-semibold text-gray-900",children:t.skillCount})]}),e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:r("market.registryCard.addedAt")}),e.jsx("p",{className:"mt-1 text-sm font-medium text-gray-900",children:ce(t.addedAt,n.language)})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:t.isDefault?r("market.registryCard.defaultHint"):r("market.registryCard.customHint")})]})}function Ye({registries:t,loading:a,deletingRegistryId:s,onAdd:r,onClose:n,onDelete:o}){const{t:d}=k();return e.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true",className:"flex max-h-[85vh] w-full max-w-4xl flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-gray-200 px-6 py-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:d("market.registryModal.title")}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:d("market.registryModal.description")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:r,className:"inline-flex items-center gap-2 rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-600",children:[e.jsx(U,{size:16}),d("market.actions.addRegistry")]}),e.jsx("button",{type:"button",onClick:n,className:"rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:d("market.actions.close")})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5",children:a?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(N,{size:22,className:"animate-spin text-gray-400"})}):t.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-300 px-6 py-16 text-center",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-gray-100 text-gray-400",children:e.jsx(ie,{size:20})}),e.jsx("h3",{className:"mt-4 text-base font-semibold text-gray-900",children:d("market.empty.registryTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:d("market.empty.registryDescription")})]}):e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:t.map(m=>e.jsx(Xe,{registry:m,deleting:s===m.id,onDelete:o},m.id))})})]})})}function te({skill:t,selected:a,onSelect:s}){const{t:r,i18n:n}=k(),o=Je(t.updatedAt,n.language),d=B(t.type),m={skill:oe,template:de,agent:re},y={skill:t.isInstalled?"bg-blue-100 text-blue-600":"bg-gray-100 text-gray-500",template:"bg-amber-100 text-amber-700",agent:"bg-emerald-100 text-emerald-700"},c=m[d];return e.jsx("button",{type:"button",onClick:()=>s(t.name),className:`w-full rounded-xl border p-3 text-left transition-colors ${a?"border-blue-200 bg-blue-50 shadow-sm":"border-transparent bg-white hover:border-gray-200 hover:bg-gray-50"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl ${y[d]}`,children:e.jsx(c,{size:18})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-gray-900",children:t.displayName||t.name}),t.isVerified&&e.jsx(ne,{className:"h-3.5 w-3.5 shrink-0 text-blue-500"}),e.jsx(me,{type:t.type})]}),e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-gray-500",children:t.description||r("market.card.noDescription")}),e.jsxs("p",{className:"mt-2 text-[11px] text-gray-400",children:[t.registryName||t.author||r("market.card.unknownAuthor"),o?` · ${r("market.list.updatedLabel",{time:o})}`:""]})]}),t.isInstalled&&e.jsx("span",{className:"shrink-0 rounded-full bg-green-100 px-2 py-0.5 text-[10px] font-medium text-green-700",children:r("market.badges.installed")})]})})}function L({icon:t,label:a,value:s}){return e.jsxs("div",{className:"rounded-xl border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[e.jsx("span",{className:"text-gray-400",children:t}),e.jsx("span",{children:a})]}),e.jsx("p",{className:"mt-2 text-sm font-semibold text-gray-900",children:s})]})}function Ge({skill:t,markdownBody:a,descriptionLoading:s,descriptionError:r,busy:n,canInstall:o,onInstall:d,onUninstall:m,onRefresh:y}){const{t:c,i18n:h}=k(),f=typeof(t==null?void 0:t.installCount)=="number";return t?e.jsxs("section",{className:"flex h-full min-h-[520px] flex-col rounded-2xl border border-gray-200 bg-white p-6 shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b border-gray-200 pb-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-2xl font-semibold text-gray-900",children:t.displayName||t.name}),e.jsxs("span",{className:"rounded-full bg-gray-100 px-2.5 py-1 text-xs font-medium text-gray-600",children:["v",t.version]}),e.jsx(me,{type:t.type}),t.isVerified&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-blue-50 px-2.5 py-1 text-xs font-medium text-blue-700",children:[e.jsx(ne,{size:13}),c("market.badges.verified")]})]}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:t.registryName||t.author||c("market.card.unknownAuthor")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.isInstalled?e.jsxs("button",{type:"button",onClick:()=>m(t.name),disabled:n,className:"inline-flex items-center gap-2 rounded-lg bg-red-50 px-4 py-2 text-sm font-medium text-red-600 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[n?e.jsx(N,{size:16,className:"animate-spin"}):e.jsx(le,{size:16}),c("market.actions.uninstall")]}):e.jsxs("button",{type:"button",onClick:()=>d(t),disabled:n||!o,className:"inline-flex items-center gap-2 rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-600 disabled:cursor-not-allowed disabled:opacity-50",children:[n?e.jsx(N,{size:16,className:"animate-spin"}):e.jsx(U,{size:16}),c("market.actions.install")]}),e.jsxs("button",{type:"button",onClick:y,className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:[e.jsx(ae,{size:16}),c("market.actions.checkUpdates")]})]})]}),e.jsxs("div",{className:"space-y-6 py-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:c("market.detail.description")}),e.jsx("div",{className:"mt-2",children:s?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(N,{size:16,className:"animate-spin"}),e.jsx("span",{children:c("market.detail.loadingBody")})]}):t.isInstalled?a!=null&&a.trim()?e.jsx(ze,{content:a,className:"text-sm"}):e.jsxs(e.Fragment,{children:[r&&e.jsx("div",{className:"mb-3 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800",children:r}),e.jsx("p",{className:"whitespace-pre-wrap text-sm leading-6 text-gray-600",children:t.description||c("market.card.noDescription")})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"whitespace-pre-wrap text-sm leading-6 text-gray-600",children:t.description||c("market.card.noDescription")}),e.jsx("div",{className:"rounded-xl border border-blue-200 bg-blue-50 px-4 py-3 text-sm text-blue-800",children:c("market.detail.installToViewBody")})]})})]}),t.tags.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:c("market.detail.tags")}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:t.tags.map(p=>e.jsxs("span",{className:"rounded-full border border-gray-200 bg-gray-50 px-2.5 py-1 text-xs text-gray-600",children:["#",p]},p))})]}),t.authors&&t.authors.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:c("market.detail.developers")}),e.jsx("div",{className:"mt-3 space-y-3",children:t.authors.map(p=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:p.avatarUrl,alt:`@${p.login}`,className:"h-8 w-8 rounded-full border border-gray-200 object-cover"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-gray-900",children:p.name||p.login}),e.jsxs("div",{className:"text-xs text-gray-500",children:["@",p.login]})]}),typeof p.contributions=="number"&&e.jsx("div",{className:"text-xs text-gray-400",children:c("market.detail.contributions",{count:p.contributions})})]},`${t.name}-${p.login}`))})]})]}),e.jsxs("div",{className:`mt-auto grid gap-3 border-t border-gray-200 pt-6 sm:grid-cols-2 ${f?"xl:grid-cols-4":"xl:grid-cols-3"}`,children:[e.jsx(L,{icon:e.jsx(Oe,{size:14}),label:c("market.detail.stats.stars"),value:ee(t.stars,h.language)}),f&&e.jsx(L,{icon:e.jsx(Re,{size:14}),label:c("market.detail.stats.installs"),value:ee(t.installCount,h.language)}),e.jsx(L,{icon:e.jsx(_e,{size:14}),label:c("market.detail.stats.license"),value:t.license||c("market.detail.unavailable")}),e.jsx(L,{icon:e.jsx(Le,{size:14}),label:c("market.detail.stats.updatedAt"),value:ce(t.updatedAt,h.language)})]})]}):e.jsx("div",{className:"flex h-full min-h-[520px] items-center justify-center rounded-2xl border border-gray-200 bg-white p-8 shadow-sm",children:e.jsxs("div",{className:"max-w-sm text-center",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-gray-100 text-gray-400",children:e.jsx(Ie,{size:20})}),e.jsx("h3",{className:"mt-4 text-base font-semibold text-gray-900",children:c("market.detail.emptyTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:c("market.detail.emptyDescription")})]})})}function tt(){const{t}=k(),{setPageHeader:a}=Se(),[s,r]=u.useState(!1),[n,o]=u.useState(!1),[d,m]=u.useState(""),[y,c]=u.useState(null),[h,f]=u.useState({}),[p,$]=u.useState(null),[xe,z]=u.useState(null),{initialized:H,loading:R,savingRegistry:ue,deletingRegistryId:ge,mutatingSkillName:pe,error:Q,registries:ye,officialRegistryId:E,allSkills:w,activeFilter:S,searchQuery:_,selectedSkillName:C,setActiveFilter:he,setSearchQuery:fe,setSelectedSkill:M,initialize:q,refresh:D,addRegistry:W,deleteRegistry:Z,installSkill:J,uninstallSkill:K,clearError:A}=Ze();u.useEffect(()=>{H||q().catch(()=>{})},[H,q]);const X=u.useMemo(()=>w.filter(l=>l.isInstalled).length,[w]),j=u.useMemo(()=>{const l=_.trim().toLowerCase();return w.filter(x=>S==="installed"&&!x.isInstalled||S!=="all"&&S!=="installed"&&B(x.type)!==S?!1:l?[x.displayName,x.name,x.description,x.author,x.registryName,...x.tags].filter(g=>!!g).some(g=>g.toLowerCase().includes(l)):!0)},[S,w,_]),i=u.useMemo(()=>j.find(l=>l.name===C)??j[0]??null,[j,C]),V=i?h[i.name]:void 0;u.useEffect(()=>{const l=(i==null?void 0:i.name)??null;l!==C&&M(l)},[i,C,M]),u.useEffect(()=>{if(!(i!=null&&i.isInstalled)){z(null),$(g=>g===(i==null?void 0:i.name)?null:g);return}if(V!==void 0){z(null);return}let l=!1;const x=i.name;return $(x),z(null),b.getInstalledSkillDetail(x).then(g=>{l||f(ke=>({...ke,[x]:g.body??""}))}).catch(g=>{l||z(g instanceof Error?g.message:t("market.errors.detailLoad"))}).finally(()=>{l||$(g=>g===x?null:g)}),()=>{l=!0}},[i==null?void 0:i.isInstalled,i==null?void 0:i.name,V,t]);const F=u.useCallback(l=>{l&&f(x=>{if(!(l in x))return x;const g={...x};return delete g[l],g})},[]);u.useEffect(()=>{a({title:t("market.title"),subtitle:t("market.subtitle.summary",{total:w.length,installed:X}),actions:e.jsxs("button",{type:"button",onClick:()=>{A(),F((i==null?void 0:i.name)??null),D().catch(()=>{})},className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-3 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:[e.jsx(ae,{size:16,className:R?"animate-spin":""}),t("market.actions.refresh")]})})},[w.length,A,R,D,F,i==null?void 0:i.name,a,t,X]);const be=u.useCallback(l=>{const x=l.registryId??E;x&&J(x,l.name).catch(()=>{})},[J,E]),je=u.useCallback(l=>{window.confirm(t("market.actions.confirmUninstall",{name:l}))&&K(l).catch(()=>{})},[t,K]),Ne=u.useCallback(l=>{Z(l).catch(()=>{})},[Z]),ve=u.useCallback(async()=>{c(null);try{await W(d),m(""),o(!1)}catch(l){c(l instanceof Error?l.message:t("market.errors.addRegistry"))}},[W,d,t]),P=j.filter(l=>l.isInstalled),Y=j.filter(l=>!l.isInstalled);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-6",children:[Q&&e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-red-700",children:[e.jsx(se,{size:18,className:"mt-0.5 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t("market.errors.bannerTitle")}),e.jsx("p",{className:"mt-1 break-words text-sm",children:Q})]}),e.jsx("button",{type:"button",onClick:()=>{A(),D().catch(()=>{})},className:"shrink-0 rounded-md bg-red-100 px-3 py-1.5 text-xs font-medium text-red-700 transition-colors hover:bg-red-200",children:t("market.actions.retry")})]}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-2xl border border-gray-200 bg-white p-4 shadow-sm lg:flex-row lg:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(G,{size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search",value:_,onChange:l=>fe(l.target.value),placeholder:t("market.searchPlaceholder"),className:"w-full rounded-xl border border-gray-300 py-2.5 pl-10 pr-4 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("button",{type:"button",onClick:()=>r(!0),className:"inline-flex items-center justify-center gap-2 rounded-xl border border-gray-200 bg-gray-50 px-4 py-2.5 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100",children:[e.jsx(Fe,{size:16}),t("market.actions.manageSources")]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["all","installed","skill","template","agent"].map(l=>e.jsx("button",{type:"button",onClick:()=>he(l),className:`rounded-full border px-3 py-1.5 text-sm font-medium transition-colors ${S===l?"border-blue-500 bg-blue-500 text-white":"border-gray-200 bg-white text-gray-600 hover:bg-gray-50"}`,children:t(`market.filters.${l}`)},l))}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs("section",{className:"rounded-2xl border border-gray-200 bg-white shadow-sm",children:[e.jsxs("div",{className:"border-b border-gray-200 px-4 py-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-900",children:t("market.list.title")}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:t("market.list.count",{count:j.length})})]}),e.jsx("div",{className:"max-h-[640px] overflow-y-auto p-3",children:R?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(N,{size:22,className:"animate-spin text-gray-400"})}):j.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-300 px-4 py-12 text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-full bg-gray-100 text-gray-400",children:e.jsx(G,{size:18})}),e.jsx("h3",{className:"mt-3 text-sm font-semibold text-gray-900",children:t("market.empty.filteredTitle")}),e.jsx("p",{className:"mt-2 text-xs leading-5 text-gray-500",children:t("market.empty.filteredDescription")})]}):e.jsxs("div",{className:"space-y-3",children:[P.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"px-1 text-xs font-semibold uppercase tracking-wide text-gray-400",children:t("market.list.installedHeading")}),P.map(l=>e.jsx(te,{skill:l,selected:(i==null?void 0:i.name)===l.name,onSelect:M},l.name))]}),Y.length>0&&e.jsxs("div",{className:"space-y-2",children:[P.length>0&&e.jsx("p",{className:"px-1 pt-2 text-xs font-semibold uppercase tracking-wide text-gray-400",children:t("market.list.availableHeading")}),Y.map(l=>e.jsx(te,{skill:l,selected:(i==null?void 0:i.name)===l.name,onSelect:M},l.name))]})]})})]}),e.jsx(Ge,{skill:i,markdownBody:V,descriptionLoading:i?p===i.name:!1,descriptionError:xe,busy:i?pe===i.name:!1,canInstall:!!((i==null?void 0:i.registryId)??E),onInstall:be,onUninstall:je,onRefresh:()=>{A(),F((i==null?void 0:i.name)??null),D().catch(()=>{})}})]})]}),s&&e.jsx(Ye,{registries:ye,loading:R,deletingRegistryId:ge,onAdd:()=>{c(null),m(""),o(!0)},onClose:()=>r(!1),onDelete:Ne}),n&&e.jsx(Ke,{url:d,error:y,submitting:ue,onChange:m,onClose:()=>{c(null),o(!1)},onSubmit:ve})]})}export{tt as default};
|
|
36
|
+
*/const Pe=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],Be=v("star",Pe);function I(t){return t instanceof Error?t.message:String(t)}function Oe(t){return[...t].sort((a,s)=>a.isInstalled!==s.isInstalled?a.isInstalled?-1:1:(a.displayName||a.name).localeCompare(s.displayName||s.name))}function Ue(t=[],a=[]){return Array.from(new Set([...t,...a]))}function He(t,a){var s;return t?{...t,...a,displayName:a.displayName||t.displayName||a.name,description:a.description||t.description,author:a.author||t.author,version:a.version||t.version,tags:Ue(t.tags,a.tags),type:a.type||t.type,isVerified:t.isVerified||a.isVerified,isInstalled:t.isInstalled||a.isInstalled,registryId:a.registryId??t.registryId,registryName:a.registryName??t.registryName,installSource:a.installSource??t.installSource,authors:(s=a.authors)!=null&&s.length?a.authors:t.authors,updatedAt:a.updatedAt??t.updatedAt,stars:a.stars??t.stars,license:a.license??t.license,installCount:a.installCount??t.installCount}:a}function T(t){const a=new Map;for(const s of t){const r=a.get(s.name);a.set(s.name,He(r,s))}return Oe(Array.from(a.values()))}function Qe(t,a){return t.map(s=>({...s,registryId:s.registryId??a.id,registryName:s.registryName??a.name,isVerified:s.isVerified||a.isVerified}))}function qe(t){return t.find(a=>a.isDefault)??t.find(a=>a.isVerified)??t[0]??null}function Ge(t,a){return T([...t,...a])}function B(t,a){var s;return a&&t.some(r=>r.name===a)?a:((s=t[0])==null?void 0:s.name)??null}const Je=we((t,a)=>({initialized:!1,loading:!1,loadingOfficial:!1,loadingInstalled:!1,savingRegistry:!1,deletingRegistryId:null,mutatingSkillName:null,error:null,registries:[],officialRegistryId:null,allSkills:[],activeFilter:"all",searchQuery:"",selectedSkillName:null,setActiveFilter:s=>t({activeFilter:s}),setSearchQuery:s=>t({searchQuery:s}),setSelectedSkill:s=>t({selectedSkillName:s}),initialize:async()=>{const s=a().selectedSkillName;t({loading:!0,loadingOfficial:!0,loadingInstalled:!0,error:null});try{const n=(await b.getSkillRegistries()).registries,o=qe(n),[d,m]=await Promise.all([o?b.getRegistrySkills(o.id):Promise.resolve({skills:[]}),b.getInstalledSkills()]),y=o?Qe(d.skills,o):[],c=T(m.skills.filter(f=>!f.source||f.source==="local")),h=Ge(y,c);t({initialized:!0,loading:!1,loadingOfficial:!1,loadingInstalled:!1,registries:n,officialRegistryId:(o==null?void 0:o.id)??null,allSkills:h,selectedSkillName:B(h,s)})}catch(r){throw t({loading:!1,loadingOfficial:!1,loadingInstalled:!1,error:I(r)}),r}},refresh:async()=>{await a().initialize()},addRegistry:async s=>{const r=s.trim();if(!r){const n=new Error("Registry URL is required");throw t({error:n.message}),n}t({savingRegistry:!0,error:null});try{await b.addSkillRegistry(r),await a().initialize(),t({savingRegistry:!1})}catch(n){throw t({savingRegistry:!1,error:I(n)}),n}},deleteRegistry:async s=>{t({deletingRegistryId:s,error:null});try{await b.deleteSkillRegistry(s),await a().initialize(),t({deletingRegistryId:null})}catch(r){throw t({deletingRegistryId:null,error:I(r)}),r}},installSkill:async(s,r)=>{t({mutatingSkillName:r,error:null});try{await b.installSkill(s,r),t(n=>{const o=n.registries.find(m=>m.id===s),d=T(n.allSkills.map(m=>m.name===r?{...m,isInstalled:!0,registryId:m.registryId??s,registryName:m.registryName??(o==null?void 0:o.name)}:m));return{allSkills:d,mutatingSkillName:null,selectedSkillName:B(d,n.selectedSkillName??r)}})}catch(n){throw t({mutatingSkillName:null,error:I(n)}),n}},uninstallSkill:async s=>{t({mutatingSkillName:s,error:null});try{await b.uninstallSkill(s),t(r=>{const n=T(r.allSkills.map(o=>o.name===s?{...o,isInstalled:!1}:o));return{allSkills:n,mutatingSkillName:null,selectedSkillName:B(n,r.selectedSkillName)}})}catch(r){throw t({mutatingSkillName:null,error:I(r)}),r}},clearError:()=>t({error:null})}));function ce(t,a){if(!t)return"—";const s=new Date(t);return Number.isNaN(s.getTime())?"—":new Intl.DateTimeFormat(a,{year:"numeric",month:"short",day:"numeric"}).format(s)}function Ke(t,a){if(!t)return null;const s=new Date(t);if(Number.isNaN(s.getTime()))return null;const r=s.getTime()-Date.now(),n=[{unit:"year",ms:1e3*60*60*24*365},{unit:"month",ms:1e3*60*60*24*30},{unit:"week",ms:1e3*60*60*24*7},{unit:"day",ms:1e3*60*60*24},{unit:"hour",ms:1e3*60*60},{unit:"minute",ms:1e3*60}],o=new Intl.RelativeTimeFormat(a,{numeric:"auto"});for(const d of n)if(Math.abs(r)>=d.ms||d.unit==="minute")return o.format(Math.round(r/d.ms),d.unit);return null}function ee(t,a){return typeof t!="number"?"—":new Intl.NumberFormat(a,{notation:"compact",compactDisplay:"short",maximumFractionDigits:1}).format(t)}function U(t){switch(t==null?void 0:t.toLowerCase()){case"template":return"template";case"agent":return"agent";default:return"skill"}}function me({type:t}){const{t:a}=k(),s=U(t),r={skill:"bg-violet-50 text-violet-700",template:"bg-amber-50 text-amber-700",agent:"bg-emerald-50 text-emerald-700"},n={skill:oe,template:de,agent:re},o={skill:a("market.types.skill"),template:a("market.types.template"),agent:a("market.types.agent")},d=n[s];return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${r[s]}`,children:[e.jsx(d,{size:12}),o[s]]})}function We({url:t,error:a,submitting:s,onChange:r,onClose:n,onSubmit:o}){const{t:d}=k(),m=y=>{y.preventDefault(),o()};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true",className:"w-full max-w-xl overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-xl",children:[e.jsxs("div",{className:"border-b border-gray-200 px-6 py-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:d("market.addRegistryModal.title")}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:d("market.addRegistryModal.description")})]}),e.jsxs("form",{onSubmit:m,children:[e.jsxs("div",{className:"space-y-4 px-6 py-5",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"registry-url",className:"mb-2 block text-sm font-medium text-gray-700",children:d("market.addRegistryModal.urlLabel")}),e.jsx("input",{id:"registry-url",type:"url",value:t,onChange:y=>r(y.target.value),placeholder:d("market.addRegistryModal.urlPlaceholder"),className:"w-full rounded-lg border border-gray-300 px-4 py-3 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500",autoFocus:!0})]}),e.jsx("div",{className:"rounded-xl border border-blue-200 bg-blue-50 px-4 py-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-white text-blue-600",children:e.jsx(Re,{size:18})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-blue-900",children:d("market.addRegistryModal.compatibilityTitle")}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-blue-800",children:d("market.addRegistryModal.compatibilityDescription")})]})]})}),a&&e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-red-700",children:[e.jsx(se,{size:18,className:"mt-0.5 shrink-0"}),e.jsx("p",{className:"text-sm",children:a})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 px-6 py-4",children:[e.jsx("button",{type:"button",onClick:n,disabled:s,className:"rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200 disabled:cursor-not-allowed disabled:opacity-50",children:d("market.actions.cancel")}),e.jsxs("button",{type:"submit",disabled:s,className:"inline-flex items-center gap-2 rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-600 disabled:cursor-not-allowed disabled:opacity-50",children:[s?e.jsx(N,{size:16,className:"animate-spin"}):e.jsx(O,{size:16}),d("market.actions.addRegistry")]})]})]})]})})}function Ze({registry:t,deleting:a,onDelete:s}){const{t:r,i18n:n}=k();return e.jsxs("article",{className:"flex flex-col gap-4 rounded-xl border border-gray-200 bg-white p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-xl ${t.isVerified?"bg-blue-50 text-blue-600":"bg-gray-100 text-gray-500"}`,children:e.jsx(ie,{size:20})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"truncate text-base font-semibold text-gray-900",children:t.name}),e.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${t.isDefault?"bg-amber-50 text-amber-700":"bg-gray-100 text-gray-600"}`,children:t.isDefault?r("market.registryCard.defaultBadge"):r("market.registryCard.customBadge")})]}),e.jsxs("a",{href:t.url,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex break-all text-sm text-blue-600 hover:text-blue-700",children:[e.jsx("span",{children:t.url}),e.jsx(Me,{size:14,className:"ml-1 mt-0.5 shrink-0"})]})]})]}),e.jsxs("button",{type:"button",onClick:()=>s(t.id),disabled:t.isDefault||a,className:`inline-flex items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium transition-colors ${t.isDefault?"cursor-not-allowed bg-gray-100 text-gray-400":"bg-red-50 text-red-600 hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50"}`,children:[a?e.jsx(N,{size:15,className:"animate-spin"}):e.jsx(le,{size:15}),t.isDefault?r("market.registryCard.lockedAction"):r("market.actions.deleteRegistry")]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:r("market.registryCard.skillCount")}),e.jsx("p",{className:"mt-1 text-lg font-semibold text-gray-900",children:t.skillCount})]}),e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:r("market.registryCard.addedAt")}),e.jsx("p",{className:"mt-1 text-sm font-medium text-gray-900",children:ce(t.addedAt,n.language)})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:t.isDefault?r("market.registryCard.defaultHint"):r("market.registryCard.customHint")})]})}function Xe({registries:t,loading:a,deletingRegistryId:s,onAdd:r,onClose:n,onDelete:o}){const{t:d}=k();return e.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true",className:"flex max-h-[85vh] w-full max-w-4xl flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-gray-200 px-6 py-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:d("market.registryModal.title")}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:d("market.registryModal.description")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:r,className:"inline-flex items-center gap-2 rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-600",children:[e.jsx(O,{size:16}),d("market.actions.addRegistry")]}),e.jsx("button",{type:"button",onClick:n,className:"rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:d("market.actions.close")})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5",children:a?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(N,{size:22,className:"animate-spin text-gray-400"})}):t.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-300 px-6 py-16 text-center",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-gray-100 text-gray-400",children:e.jsx(ie,{size:20})}),e.jsx("h3",{className:"mt-4 text-base font-semibold text-gray-900",children:d("market.empty.registryTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:d("market.empty.registryDescription")})]}):e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:t.map(m=>e.jsx(Ze,{registry:m,deleting:s===m.id,onDelete:o},m.id))})})]})})}function te({skill:t,selected:a,onSelect:s}){const{t:r,i18n:n}=k(),o=Ke(t.updatedAt,n.language),d=U(t.type),m={skill:oe,template:de,agent:re},y={skill:t.isInstalled?"bg-blue-100 text-blue-600":"bg-gray-100 text-gray-500",template:"bg-amber-100 text-amber-700",agent:"bg-emerald-100 text-emerald-700"},c=m[d];return e.jsx("button",{type:"button",onClick:()=>s(t.name),className:`w-full rounded-xl border p-3 text-left transition-colors ${a?"border-blue-200 bg-blue-50 shadow-sm":"border-transparent bg-white hover:border-gray-200 hover:bg-gray-50"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl ${y[d]}`,children:e.jsx(c,{size:18})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-gray-900",children:t.displayName||t.name}),t.isVerified&&e.jsx(ne,{className:"h-3.5 w-3.5 shrink-0 text-blue-500"}),e.jsx(me,{type:t.type})]}),e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-gray-500",children:t.description||r("market.card.noDescription")}),e.jsxs("p",{className:"mt-2 text-[11px] text-gray-400",children:[t.registryName||t.author||r("market.card.unknownAuthor"),o?` · ${r("market.list.updatedLabel",{time:o})}`:""]})]}),t.isInstalled&&e.jsx("span",{className:"shrink-0 rounded-full bg-green-100 px-2 py-0.5 text-[10px] font-medium text-green-700",children:r("market.badges.installed")})]})})}function L({icon:t,label:a,value:s}){return e.jsxs("div",{className:"rounded-xl border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[e.jsx("span",{className:"text-gray-400",children:t}),e.jsx("span",{children:a})]}),e.jsx("p",{className:"mt-2 text-sm font-semibold text-gray-900",children:s})]})}function Ye({skill:t,markdownBody:a,descriptionLoading:s,descriptionError:r,busy:n,canInstall:o,onInstall:d,onUninstall:m,onRefresh:y}){const{t:c,i18n:h}=k(),f=typeof(t==null?void 0:t.installCount)=="number";return t?e.jsxs("section",{className:"flex h-full min-h-[520px] flex-col rounded-2xl border border-gray-200 bg-white p-6 shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b border-gray-200 pb-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-2xl font-semibold text-gray-900",children:t.displayName||t.name}),e.jsxs("span",{className:"rounded-full bg-gray-100 px-2.5 py-1 text-xs font-medium text-gray-600",children:["v",t.version]}),e.jsx(me,{type:t.type}),t.isVerified&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-blue-50 px-2.5 py-1 text-xs font-medium text-blue-700",children:[e.jsx(ne,{size:13}),c("market.badges.verified")]})]}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:t.registryName||t.author||c("market.card.unknownAuthor")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.isInstalled?e.jsxs("button",{type:"button",onClick:()=>m(t.name),disabled:n,className:"inline-flex items-center gap-2 rounded-lg bg-red-50 px-4 py-2 text-sm font-medium text-red-600 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[n?e.jsx(N,{size:16,className:"animate-spin"}):e.jsx(le,{size:16}),c("market.actions.uninstall")]}):e.jsxs("button",{type:"button",onClick:()=>d(t),disabled:n||!o,className:"inline-flex items-center gap-2 rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-600 disabled:cursor-not-allowed disabled:opacity-50",children:[n?e.jsx(N,{size:16,className:"animate-spin"}):e.jsx(O,{size:16}),c("market.actions.install")]}),e.jsxs("button",{type:"button",onClick:y,className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:[e.jsx(ae,{size:16}),c("market.actions.checkUpdates")]})]})]}),e.jsxs("div",{className:"space-y-6 py-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:c("market.detail.description")}),e.jsx("div",{className:"mt-2",children:s?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(N,{size:16,className:"animate-spin"}),e.jsx("span",{children:c("market.detail.loadingBody")})]}):t.isInstalled?a!=null&&a.trim()?e.jsx(ze,{content:a,className:"text-sm"}):e.jsxs(e.Fragment,{children:[r&&e.jsx("div",{className:"mb-3 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800",children:r}),e.jsx("p",{className:"whitespace-pre-wrap text-sm leading-6 text-gray-600",children:t.description||c("market.card.noDescription")})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"whitespace-pre-wrap text-sm leading-6 text-gray-600",children:t.description||c("market.card.noDescription")}),e.jsx("div",{className:"rounded-xl border border-blue-200 bg-blue-50 px-4 py-3 text-sm text-blue-800",children:c("market.detail.installToViewBody")})]})})]}),t.tags.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:c("market.detail.tags")}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:t.tags.map(p=>e.jsxs("span",{className:"rounded-full border border-gray-200 bg-gray-50 px-2.5 py-1 text-xs text-gray-600",children:["#",p]},p))})]}),t.authors&&t.authors.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:c("market.detail.developers")}),e.jsx("div",{className:"mt-3 space-y-3",children:t.authors.map(p=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:p.avatarUrl,alt:`@${p.login}`,className:"h-8 w-8 rounded-full border border-gray-200 object-cover"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-gray-900",children:p.name||p.login}),e.jsxs("div",{className:"text-xs text-gray-500",children:["@",p.login]})]}),typeof p.contributions=="number"&&e.jsx("div",{className:"text-xs text-gray-400",children:c("market.detail.contributions",{count:p.contributions})})]},`${t.name}-${p.login}`))})]})]}),e.jsxs("div",{className:`mt-auto grid gap-3 border-t border-gray-200 pt-6 sm:grid-cols-2 ${f?"xl:grid-cols-4":"xl:grid-cols-3"}`,children:[e.jsx(L,{icon:e.jsx(Be,{size:14}),label:c("market.detail.stats.stars"),value:ee(t.stars,h.language)}),f&&e.jsx(L,{icon:e.jsx(Ce,{size:14}),label:c("market.detail.stats.installs"),value:ee(t.installCount,h.language)}),e.jsx(L,{icon:e.jsx(_e,{size:14}),label:c("market.detail.stats.license"),value:t.license||c("market.detail.unavailable")}),e.jsx(L,{icon:e.jsx(Le,{size:14}),label:c("market.detail.stats.updatedAt"),value:ce(t.updatedAt,h.language)})]})]}):e.jsx("div",{className:"flex h-full min-h-[520px] items-center justify-center rounded-2xl border border-gray-200 bg-white p-8 shadow-sm",children:e.jsxs("div",{className:"max-w-sm text-center",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-gray-100 text-gray-400",children:e.jsx(Ie,{size:20})}),e.jsx("h3",{className:"mt-4 text-base font-semibold text-gray-900",children:c("market.detail.emptyTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:c("market.detail.emptyDescription")})]})})}function tt(){const{t}=k(),{setPageHeader:a}=Se(),[s,r]=u.useState(!1),[n,o]=u.useState(!1),[d,m]=u.useState(""),[y,c]=u.useState(null),[h,f]=u.useState({}),[p,E]=u.useState(null),[xe,z]=u.useState(null),{initialized:H,loading:C,savingRegistry:ue,deletingRegistryId:ge,mutatingSkillName:pe,error:Q,registries:ye,officialRegistryId:$,allSkills:w,activeFilter:S,searchQuery:_,selectedSkillName:R,setActiveFilter:he,setSearchQuery:fe,setSelectedSkill:M,initialize:q,refresh:D,addRegistry:G,deleteRegistry:J,installSkill:K,uninstallSkill:W,clearError:A}=Je();u.useEffect(()=>{H||q().catch(()=>{})},[H,q]);const Z=u.useMemo(()=>w.filter(l=>l.isInstalled).length,[w]),j=u.useMemo(()=>{const l=_.trim().toLowerCase();return w.filter(x=>S==="installed"&&!x.isInstalled||S!=="all"&&S!=="installed"&&U(x.type)!==S?!1:l?[x.displayName,x.name,x.description,x.author,x.registryName,...x.tags].filter(g=>!!g).some(g=>g.toLowerCase().includes(l)):!0)},[S,w,_]),i=u.useMemo(()=>j.find(l=>l.name===R)??j[0]??null,[j,R]),F=i?h[i.name]:void 0;u.useEffect(()=>{const l=(i==null?void 0:i.name)??null;l!==R&&M(l)},[i,R,M]),u.useEffect(()=>{if(!(i!=null&&i.isInstalled)){z(null),E(g=>g===(i==null?void 0:i.name)?null:g);return}if(F!==void 0){z(null);return}let l=!1;const x=i.name;return E(x),z(null),b.getInstalledSkillDetail(x).then(g=>{l||f(ke=>({...ke,[x]:g.body??""}))}).catch(g=>{l||z(g instanceof Error?g.message:t("market.errors.detailLoad"))}).finally(()=>{l||E(g=>g===x?null:g)}),()=>{l=!0}},[i==null?void 0:i.isInstalled,i==null?void 0:i.name,F,t]);const V=u.useCallback(l=>{l&&f(x=>{if(!(l in x))return x;const g={...x};return delete g[l],g})},[]);u.useEffect(()=>{a({title:t("market.title"),subtitle:t("market.subtitle.summary",{total:w.length,installed:Z}),actions:e.jsxs("button",{type:"button",onClick:()=>{A(),V((i==null?void 0:i.name)??null),D().catch(()=>{})},className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-3 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:[e.jsx(ae,{size:16,className:C?"animate-spin":""}),t("market.actions.refresh")]})})},[w.length,A,C,D,V,i==null?void 0:i.name,a,t,Z]);const be=u.useCallback(l=>{const x=l.registryId??$;x&&K(x,l.name).catch(()=>{})},[K,$]),je=u.useCallback(l=>{window.confirm(t("market.actions.confirmUninstall",{name:l}))&&W(l).catch(()=>{})},[t,W]),Ne=u.useCallback(l=>{J(l).catch(()=>{})},[J]),ve=u.useCallback(async()=>{c(null);try{await G(d),m(""),o(!1)}catch(l){c(l instanceof Error?l.message:t("market.errors.addRegistry"))}},[G,d,t]),P=j.filter(l=>l.isInstalled),X=j.filter(l=>!l.isInstalled);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-6",children:[Q&&e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-red-700",children:[e.jsx(se,{size:18,className:"mt-0.5 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t("market.errors.bannerTitle")}),e.jsx("p",{className:"mt-1 break-words text-sm",children:Q})]}),e.jsx("button",{type:"button",onClick:()=>{A(),D().catch(()=>{})},className:"shrink-0 rounded-md bg-red-100 px-3 py-1.5 text-xs font-medium text-red-700 transition-colors hover:bg-red-200",children:t("market.actions.retry")})]}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-2xl border border-gray-200 bg-white p-4 shadow-sm lg:flex-row lg:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Y,{size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search",value:_,onChange:l=>fe(l.target.value),placeholder:t("market.searchPlaceholder"),className:"w-full rounded-xl border border-gray-300 py-2.5 pl-10 pr-4 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("button",{type:"button",onClick:()=>r(!0),className:"inline-flex items-center justify-center gap-2 rounded-xl border border-gray-200 bg-gray-50 px-4 py-2.5 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100",children:[e.jsx(Ve,{size:16}),t("market.actions.manageSources")]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["all","installed","skill","template","agent"].map(l=>e.jsx("button",{type:"button",onClick:()=>he(l),className:`rounded-full border px-3 py-1.5 text-sm font-medium transition-colors ${S===l?"border-blue-500 bg-blue-500 text-white":"border-gray-200 bg-white text-gray-600 hover:bg-gray-50"}`,children:t(`market.filters.${l}`)},l))}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs("section",{className:"rounded-2xl border border-gray-200 bg-white shadow-sm",children:[e.jsxs("div",{className:"border-b border-gray-200 px-4 py-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-900",children:t("market.list.title")}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:t("market.list.count",{count:j.length})})]}),e.jsx("div",{className:"max-h-[640px] overflow-y-auto p-3",children:C?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(N,{size:22,className:"animate-spin text-gray-400"})}):j.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-300 px-4 py-12 text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-full bg-gray-100 text-gray-400",children:e.jsx(Y,{size:18})}),e.jsx("h3",{className:"mt-3 text-sm font-semibold text-gray-900",children:t("market.empty.filteredTitle")}),e.jsx("p",{className:"mt-2 text-xs leading-5 text-gray-500",children:t("market.empty.filteredDescription")})]}):e.jsxs("div",{className:"space-y-3",children:[P.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"px-1 text-xs font-semibold uppercase tracking-wide text-gray-400",children:t("market.list.installedHeading")}),P.map(l=>e.jsx(te,{skill:l,selected:(i==null?void 0:i.name)===l.name,onSelect:M},l.name))]}),X.length>0&&e.jsxs("div",{className:"space-y-2",children:[P.length>0&&e.jsx("p",{className:"px-1 pt-2 text-xs font-semibold uppercase tracking-wide text-gray-400",children:t("market.list.availableHeading")}),X.map(l=>e.jsx(te,{skill:l,selected:(i==null?void 0:i.name)===l.name,onSelect:M},l.name))]})]})})]}),e.jsx(Ye,{skill:i,markdownBody:F,descriptionLoading:i?p===i.name:!1,descriptionError:xe,busy:i?pe===i.name:!1,canInstall:!!((i==null?void 0:i.registryId)??$),onInstall:be,onUninstall:je,onRefresh:()=>{A(),V((i==null?void 0:i.name)??null),D().catch(()=>{})}})]})]}),s&&e.jsx(Xe,{registries:ye,loading:C,deletingRegistryId:ge,onAdd:()=>{c(null),m(""),o(!0)},onClose:()=>r(!1),onDelete:Ne}),n&&e.jsx(We,{url:d,error:y,submitting:ue,onChange:m,onClose:()=>{c(null),o(!1)},onSubmit:ve})]})}export{tt as default};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aB as F,aE as B,aG as d,aH as r,aV as ve,aL as X,aQ as ke,aW as we,aD as q,aX as ce,aK as de,aY as K,aS as je,aZ as Ne,a_ as Ce,a$ as Le,aO as _e,b0 as ue,b1 as Ee,b2 as Se,b3 as De,b4 as Me,b5 as Ae,b6 as $e,b7 as Te,b8 as Ie,b9 as Pe,ba as Re,bb as Be,bc as Oe,bd as ze,be as Ve,bf as qe,bg as Fe,bh as He,bi as Ke,bj as We,bk as Qe,bl as Ue,bm as Xe,bn as Je,bo as Y}from"./main-DgXktCKZ.js";/**
|
|
2
2
|
* @license lucide-react v0.563.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Ge=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],Ze=
|
|
6
|
+
*/const Ge=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],Ze=F("braces",Ge);/**
|
|
7
7
|
* @license lucide-react v0.563.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Ye=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],et=
|
|
11
|
+
*/const Ye=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],et=F("eye",Ye);/**
|
|
12
12
|
* @license lucide-react v0.563.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const tt=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],nt=
|
|
16
|
+
*/const tt=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],nt=F("link-2",tt);/**
|
|
17
17
|
* @license lucide-react v0.563.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const rt=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],st=V("refresh-ccw",rt);function at(e,s){return(e??"").toLowerCase().includes(s)}function pe(e,s){if(!s)return{nodes:e,autoExpanded:new Set};const n=new Set;return{nodes:e.flatMap(o=>{if(o.type==="file")return at(o.name,s)?[o]:[];const u=pe(o.children??[],s);return u.nodes.length>0?(n.add(o.path),u.autoExpanded.forEach(c=>n.add(c)),[{...o,children:u.nodes}]):[]}),autoExpanded:n}}function me(e){return e instanceof Error?/HTTP (404|405|501|503)\b|Failed to fetch|NetworkError/i.test(e.message):!1}const R={id:"agent_id",name:"에이전트 이름",role:"에이전트 역할",team:"팀",description:"에이전트 설명"};function ot(e){return{id:e.id.trim()||R.id,name:e.name.trim()||R.name,role:e.role.trim()||R.role,team:e.team.trim()||R.team,description:e.description.trim()||R.description}}function it(e,s,n){let t=!1;return e.state.doc.descendants(o=>o.type.name==="documentBlock"&&o.attrs.key===s&&o.attrs.variant===n?(t=!0,!1):!t),t}const fe=["[&_h1]:mt-0","[&_h1]:mb-3","[&_h1]:text-2xl","[&_h1]:font-bold","[&_h2]:mt-0","[&_h2]:mb-2","[&_h2]:text-xl","[&_h2]:font-semibold","[&_h3]:mt-0","[&_h3]:mb-2","[&_h3]:text-lg","[&_h3]:font-semibold","[&_p]:my-2","[&_p]:leading-7","[&_ul]:my-2","[&_ol]:my-2","[&_ul]:list-disc","[&_ol]:list-decimal","[&_ul]:pl-6","[&_ol]:pl-6","[&_li]:my-1","[&_blockquote]:my-3","[&_blockquote]:border-l-4","[&_blockquote]:border-gray-300","[&_blockquote]:pl-4","[&_blockquote]:text-gray-600","[&_blockquote]:italic","[&_blockquote_p]:my-0","[&_a]:text-blue-600","[&_a]:underline","[&_hr]:my-4","[&_hr]:border-gray-300","[&_code]:rounded","[&_code]:bg-gray-100","[&_code]:px-1.5","[&_code]:py-0.5","[&_code]:font-mono","[&_code]:text-[13px]","[&_pre]:my-3","[&_pre]:overflow-x-auto","[&_pre]:rounded-lg","[&_pre]:bg-gray-900","[&_pre]:p-4","[&_pre]:text-sm","[&_pre]:text-gray-100","[&_pre_code]:bg-transparent","[&_pre_code]:p-0","[&_pre_code]:text-inherit"].join(" "),lt=["min-h-[420px]","rounded-xl","border","border-gray-200","bg-white","px-4","py-3","text-sm","text-gray-900","shadow-sm","focus:outline-none","prose","prose-sm","max-w-none",fe,"[&_.is-editor-empty:first-child::before]:pointer-events-none","[&_.is-editor-empty:first-child::before]:float-left","[&_.is-editor-empty:first-child::before]:h-0","[&_.is-editor-empty:first-child::before]:text-gray-400","[&_.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]"].join(" ");function ct({open:e,request:s,onClose:n}){const{t}=B(),o=d.useRef(null),u=d.useRef(s),[c,p]=d.useState(""),[m,x]=d.useState(!1),[i,y]=d.useState(null),[b,k]=d.useState(!1),w=t("agent.prompt.preview.error");u.current=s;const h=async()=>{var g;if((g=o.current)==null||g.abort(),!u.current.template.trim()){p(""),y(null),k(!1),x(!1);return}const l=new AbortController;o.current=l,x(!0),y(null),k(!1);try{const v=await F.previewPrompt(u.current,{signal:l.signal});if(l.signal.aborted)return;p(v.rendered),y(null),k(!1)}catch(v){if(l.signal.aborted)return;if(me(v)){p(""),y(null),k(!0);return}p(""),k(!1),y(v instanceof Error?v.message:w)}finally{o.current===l&&(o.current=null),x(!1)}};return d.useEffect(()=>{var l;if(!e){(l=o.current)==null||l.abort();return}h()},[e]),d.useEffect(()=>{if(!e)return;const l=g=>{g.key==="Escape"&&(g.preventDefault(),n())};return window.addEventListener("keydown",l),()=>{window.removeEventListener("keydown",l)}},[n,e]),d.useEffect(()=>()=>{var l;(l=o.current)==null||l.abort()},[]),e?r.jsx("div",{"data-testid":"preview-modal-backdrop",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",onClick:n,children:r.jsxs("div",{role:"dialog","aria-modal":"true","data-testid":"preview-modal",onClick:l=>l.stopPropagation(),className:"flex max-h-[85vh] w-full max-w-4xl flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-xl",children:[r.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-gray-200 px-6 py-5",children:[r.jsx("div",{children:r.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:t("agent.prompt.preview.title")})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>{h()},disabled:m,className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200 disabled:cursor-not-allowed disabled:opacity-50",children:[r.jsx(st,{size:14,className:m?"animate-spin":""}),t("agent.prompt.preview.refresh")]}),r.jsxs("button",{type:"button",onClick:n,className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:[r.jsx(ve,{size:14}),t("common.close")]})]})]}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5",children:s.template.trim()?m?r.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[r.jsx(J,{size:16,className:"animate-spin"}),r.jsx("span",{children:t("agent.prompt.preview.loading")})]}):b?r.jsx("div",{className:"text-sm text-gray-500",children:t("agent.prompt.preview.unavailable")}):i?r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-medium text-red-600",children:t("agent.prompt.preview.error")}),r.jsx("div",{className:"text-sm text-red-500",children:i})]}):r.jsx(ke,{content:c,className:fe}):r.jsx("div",{className:"text-sm text-gray-500",children:t("agent.prompt.preview.empty")})}),r.jsxs("div",{className:"flex justify-end gap-2 border-t border-gray-200 px-6 py-4",children:[r.jsxs("button",{type:"button",onClick:()=>{var l;return void((l=navigator.clipboard)==null?void 0:l.writeText(c))},disabled:!c,className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200 disabled:cursor-not-allowed disabled:opacity-50",children:[r.jsx(we,{size:14}),t("agent.prompt.preview.copy")]}),r.jsx("button",{type:"button",onClick:n,className:"rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-600",children:t("common.close")})]})]})}):null}function dt({trigger:e,items:s,searchable:n=!1,searchPlaceholder:t,emptyLabel:o}){const u=d.useRef(null),c=d.useRef(null),[p,m]=d.useState(!1),[x,i]=d.useState(""),[y,b]=d.useState(0),k=d.useMemo(()=>{const l=x.trim().toLowerCase();return l?s.filter(g=>g.label.toLowerCase().includes(l)?!0:g.actions.some(v=>v.label.toLowerCase().includes(l))):s},[s,x]),w=d.useMemo(()=>k.flatMap(l=>l.actions.map(g=>({itemLabel:l.label,actionLabel:g.label,onClick:g.onClick}))),[k]);d.useEffect(()=>{var l;if(!p){i(""),b(0);return}n&&((l=c.current)==null||l.focus())},[p,n]),d.useEffect(()=>{y<w.length||b(Math.max(w.length-1,0))},[w.length,y]),d.useEffect(()=>{if(!p)return;const l=v=>{var _;(_=u.current)!=null&&_.contains(v.target)||m(!1)},g=v=>{var _;if(v.key==="Escape"){v.preventDefault(),m(!1);return}if(w.length!==0){if(v.key==="ArrowDown"){v.preventDefault(),b(M=>(M+1)%w.length);return}if(v.key==="ArrowUp"){v.preventDefault(),b(M=>(M-1+w.length)%w.length);return}v.key==="Enter"&&(v.preventDefault(),(_=w[y])==null||_.onClick(),m(!1))}};return window.addEventListener("mousedown",l),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",l),window.removeEventListener("keydown",g)}},[w,y,p]);let h=-1;return r.jsxs("div",{ref:u,className:"relative",children:[r.jsxs("button",{type:"button",onMouseDown:l=>l.preventDefault(),onClick:()=>m(l=>!l),className:"inline-flex items-center gap-1 rounded-md border border-gray-200 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-700 transition hover:border-gray-300 hover:bg-gray-100",children:[r.jsx("span",{children:e}),r.jsx(ce,{size:14})]}),p?r.jsxs("div",{className:"absolute left-0 top-[calc(100%+0.5rem)] z-20 w-72 rounded-xl border border-gray-200 bg-white p-2 shadow-lg",children:[n?r.jsxs("label",{className:"mb-2 flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-500",children:[r.jsx(de,{size:14}),r.jsx("input",{ref:c,value:x,onChange:l=>{i(l.target.value),b(0)},className:"w-full bg-transparent text-sm text-gray-700 outline-none","aria-label":t,placeholder:t})]}):null,r.jsx("div",{className:"max-h-80 space-y-1 overflow-y-auto",children:k.length===0?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:o??""}):k.map(l=>r.jsxs("div",{className:"rounded-lg border border-gray-100 px-3 py-2",children:[r.jsx("div",{className:"text-sm font-medium text-gray-900",children:l.label}),l.actions.length>0?r.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:l.actions.map(g=>{h+=1;const v=h===y;return r.jsx("button",{type:"button",onMouseDown:_=>_.preventDefault(),onClick:()=>{g.onClick(),m(!1)},className:`rounded-md px-2.5 py-1 text-xs font-medium transition ${v?"bg-blue-500 text-white":"border border-gray-200 bg-white text-gray-700 hover:border-gray-300 hover:bg-gray-100"}`,children:g.label},`${l.label}-${g.label}`)})}):r.jsx("div",{className:"mt-1 text-xs text-gray-500",children:o??l.label})]},l.label))})]}):null]})}function ee(e){return e.replace(/\\/g,"/").replace(/^\.?\//,"")}function te(e,s){return(e??"").toLowerCase().includes(s)}function ut({documents:e,documentsLoading:s,documentsError:n,documentsUnavailable:t,onInsertDocument:o,onRefetchDocuments:u}){const{t:c}=B(),p=d.useRef(null),m=d.useRef(null),[x,i]=d.useState(!1),[y,b]=d.useState(""),[k,w]=d.useState([]),[h,l]=d.useState(!1),[g,v]=d.useState(null),[_,M]=d.useState(new Set),[a,j]=d.useState(!1),[C,D]=d.useState(null);d.useEffect(()=>{var N;if(!x||((N=m.current)==null||N.focus(),k.length>0||h))return;let f=!1;return(async()=>{l(!0),v(null);try{const E=await F.getDocTree();f||w(E)}catch(E){f||v(E instanceof Error?E.message:c("agent.prompt.documentPicker.treeError"))}finally{f||l(!1)}})(),()=>{f=!0}},[x,k.length]),d.useEffect(()=>{x||(b(f=>f&&""),M(f=>f.size>0?new Set:f))},[x]),d.useEffect(()=>{if(!x)return;const f=N=>{var E;(E=p.current)!=null&&E.contains(N.target)||i(!1)},L=N=>{N.key==="Escape"&&(N.preventDefault(),i(!1))};return window.addEventListener("mousedown",f),window.addEventListener("keydown",L),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",L)}},[x]);const S=y.trim().toLowerCase(),T=d.useMemo(()=>e.filter(f=>f.type==="inline"),[e]),O=d.useMemo(()=>{const f=e.filter(L=>L.type==="file"&&L.path);return L=>{const N=ee(L),E=f.find(ye=>ee(ye.path??"")===N);return E==null?void 0:E.key}},[e]),$=d.useMemo(()=>S?T.filter(f=>te(f.key,S)||te(f.summary,S)):T,[T,S]),P=d.useMemo(()=>pe(k,S),[S,k]),xe=d.useMemo(()=>{if(!S)return _;const f=new Set(_);return P.autoExpanded.forEach(L=>f.add(L)),f},[_,P.autoExpanded,S]),H=f=>{o(f,"content"),i(!1)},be=async f=>{D(null);const L=O(f);if(L){H(L);return}try{j(!0);const N=await F.registerDocument({path:f});H(N.key),u==null||u()}catch(N){D(N instanceof Error?N.message:c("agent.prompt.documentPicker.registerError"))}finally{j(!1)}},G=s||n||t||$.length>0,Z=h||g||P.nodes.length>0;return r.jsxs("div",{ref:p,className:"relative",children:[r.jsxs("button",{type:"button",onMouseDown:f=>f.preventDefault(),onClick:()=>i(f=>!f),className:"inline-flex items-center gap-1 rounded-md border border-gray-200 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-700 transition hover:border-gray-300 hover:bg-gray-100","aria-label":c("agent.prompt.documentInsert"),children:[r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[r.jsx(K,{className:"h-4 w-4"}),r.jsx("span",{children:c("agent.prompt.documentInsert")})]}),r.jsx(ce,{size:14})]}),x?r.jsxs("div",{className:"absolute left-0 top-[calc(100%+0.5rem)] z-20 w-80 rounded-xl border border-gray-200 bg-white p-2 shadow-lg","data-testid":"document-picker-popover",children:[r.jsxs("label",{className:"mb-2 flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-500",children:[r.jsx(de,{size:14}),r.jsx("input",{ref:m,value:y,onChange:f=>b(f.target.value),className:"w-full bg-transparent text-sm text-gray-700 outline-none","aria-label":c("agent.prompt.documentPicker.searchPlaceholder"),placeholder:c("agent.prompt.documentPicker.searchPlaceholder")})]}),r.jsxs("div",{className:"max-h-96 space-y-3 overflow-y-auto",children:[G?r.jsxs("section",{children:[r.jsxs("div",{className:"mb-1 flex items-center gap-2 px-2 py-1 text-xs font-semibold uppercase tracking-wide text-gray-400",children:[r.jsx(je,{className:"h-3.5 w-3.5"}),r.jsx("span",{children:c("agent.prompt.documentPicker.inlineSection")})]}),s?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentInsertLoading")}):n?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-red-500",children:n}):t?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentInsertUnavailable")}):$.length===0?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentPicker.noInlineResults")}):r.jsx("div",{className:"space-y-1",children:$.map(f=>r.jsxs("button",{type:"button",onMouseDown:L=>L.preventDefault(),onClick:()=>H(f.key),className:"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm text-gray-700 transition hover:bg-gray-100",children:[r.jsx(K,{className:"h-4 w-4 shrink-0 text-gray-400"}),r.jsx("span",{className:"truncate",children:f.key})]},f.key))})]}):null,Z?r.jsxs("section",{children:[r.jsxs("div",{className:"mb-1 flex items-center gap-2 px-2 py-1 text-xs font-semibold uppercase tracking-wide text-gray-400",children:[r.jsx(K,{className:"h-3.5 w-3.5"}),r.jsx("span",{children:c("agent.prompt.documentPicker.docsSection")})]}),h?r.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-3 py-2 text-sm text-gray-500",children:[r.jsx(J,{className:"h-4 w-4 animate-spin"}),r.jsx("span",{children:c("agent.prompt.documentPicker.treeLoading")})]}):g?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-red-500",children:g}):P.nodes.length===0?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentPicker.noTreeResults")}):r.jsxs(r.Fragment,{children:[r.jsx(Ne,{nodes:P.nodes,expandedFolders:xe,onToggle:f=>M(L=>{const N=new Set(L);return N.has(f)?N.delete(f):N.add(f),N}),onSelect:f=>{a||be(f)},selectedPath:null,isFileDisabled:()=>a,renderFileSuffix:f=>O(f.path)?r.jsx(nt,{className:"h-3.5 w-3.5 shrink-0 text-blue-500","aria-label":c("agent.prompt.documentPicker.linked")}):a?r.jsx(J,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-gray-400"}):null}),C?r.jsx("div",{className:"mt-1 rounded-lg px-3 py-2 text-sm text-red-500",role:"alert",children:C}):null]})]}):null,!G&&!Z?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentInsertEmpty")}):null]})]}):null]})}function pt({deleteNode:e,extension:s,node:n,updateAttributes:t}){const{t:o}=B(),u=d.useRef(null),[c,p]=d.useState(!1),m=String(n.attrs.key??""),x=String(n.attrs.variant??"content"),i=s.options.getVariantLabel;d.useEffect(()=>{if(!c)return;const b=w=>{var h;(h=u.current)!=null&&h.contains(w.target)||p(!1)},k=w=>{w.key==="Escape"&&(w.preventDefault(),p(!1))};return window.addEventListener("mousedown",b),window.addEventListener("keydown",k),()=>{window.removeEventListener("mousedown",b),window.removeEventListener("keydown",k)}},[c]);const y=[{value:"content",label:i("content")},{value:"toc",label:i("toc")}];return r.jsxs(Ce,{as:"span",ref:u,className:"relative inline-flex","data-testid":"document-block-node",children:[r.jsx("button",{type:"button","data-testid":"document-block-trigger",onMouseDown:b=>b.preventDefault(),onClick:()=>p(b=>!b),className:"inline-flex items-center rounded-lg border border-amber-200 bg-amber-50 px-2 py-0.5 text-xs font-medium text-amber-700",children:`📄 ${m} · ${i(x)}`}),c?r.jsxs("span",{className:"absolute left-0 top-[calc(100%+0.375rem)] z-20 min-w-32 rounded-lg border border-gray-200 bg-white p-1 shadow-lg","data-testid":"document-block-popover",children:[y.map(b=>{const k=b.value===x;return r.jsxs("button",{type:"button","data-testid":`document-block-option-${b.value}`,onMouseDown:w=>w.preventDefault(),onClick:()=>{t({variant:b.value}),p(!1)},className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-gray-700 transition hover:bg-gray-100",children:[r.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center",children:k?r.jsx(Le,{className:"h-4 w-4 text-blue-500"}):null}),r.jsx("span",{children:b.label})]},b.value)}),r.jsx("div",{className:"my-1 border-t border-gray-100"}),r.jsxs("button",{type:"button","data-testid":"document-block-delete",onMouseDown:b=>b.preventDefault(),onClick:()=>{e(),p(!1)},className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-red-600 transition hover:bg-red-50",children:[r.jsx(_e,{className:"h-4 w-4"}),r.jsx("span",{children:o("agent.prompt.documentChip.delete")})]})]}):null]})}const mt=ue.create({name:"documentBlock",addOptions(){return{getVariantLabel:e=>String(e)}},inline:!0,group:"inline",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{key:{default:""},variant:{default:"content"}}},parseHTML(){return[{tag:"span[data-doc-block]"}]},renderHTML({HTMLAttributes:e,node:s}){const n=String(s.attrs.key??""),t=String(s.attrs.variant??"content"),o=this.options.getVariantLabel(t);return["span",Ee(e,{"data-doc-block":"true","data-key":n,"data-variant":t,"data-testid":"document-block",class:"inline-flex items-center rounded-lg border border-amber-200 bg-amber-50 px-2 py-0.5 text-xs font-medium text-amber-700"}),`📄 ${n} · ${o}`]},addNodeView(){return Se(pt)}}),ft=De.extend({name:"variableMention",addAttributes(){return{variable:{default:"",parseHTML:e=>e.getAttribute("data-variable")??"",renderHTML:e=>({"data-variable":e.variable})}}},renderText({node:e}){return`{{${String(e.attrs.variable??"")}}}`},renderHTML({node:e,HTMLAttributes:s}){return["span",{...s,class:"inline-flex items-center rounded-full bg-blue-500 px-2 py-0.5 text-xs font-semibold text-white","data-testid":"variable-chip"},String(e.attrs.variable??"")]}}),he=["agent.id","agent.name","agent.role","agent.team","agent.description"],ne=["bold","italic","strike","code"],re={bold:{open:"**",close:"**"},italic:{open:"*",close:"*"},strike:{open:"~~",close:"~~"},code:{open:"`",close:"`"}};function ht(e){return he.includes(e)}function ge(e,s){return s&&s.length>0?{type:"text",text:e,marks:s}:{type:"text",text:e}}function W(e,s,n){if(!s)return;const t=e[e.length-1],o=JSON.stringify(n??[]),u=JSON.stringify((t==null?void 0:t.marks)??[]);if((t==null?void 0:t.type)==="text"&&o===u){t.text=`${t.text??""}${s}`;return}e.push(ge(s,n))}function z(e,...s){return e.map(n=>{if(n.type!=="text")return n;const t=new Set((n.marks??[]).map(u=>u.type)),o=s.filter(u=>!t.has(u)).map(u=>({type:u}));return{...n,marks:[...n.marks??[],...o]}})}function gt(e){const s=e.match(/^\{\{(agent\.(?:id|name|role|team|description))\}\}$/);return!s||!ht(s[1])?null:{type:"variableMention",attrs:{variable:s[1]}}}function X(e){const s=e.match(/^\{\{\{documents\.([^.\s}]+)\.(content|toc)\}\}\}$/);return s?{type:"documentBlock",attrs:{key:s[1],variant:s[2]}}:null}function xt(e,s){const n=e[s].match(/^<document\b[^>]*>\s*(\{\{\{documents\.([^.\s}]+)\.(content|toc)\}\}\})\s*<\/document>\s*$/);if(n){const m=X(n[1]);if(m)return{node:{type:"paragraph",content:[m]},nextIndex:s+1}}if(!/^<document\b[^>]*>\s*$/.test(e[s]??""))return null;let t=s+1;for(;t<e.length&&(e[t]??"").trim()==="";)t+=1;const u=(e[t]??"").trim();for(t+=1;t<e.length&&(e[t]??"").trim()==="";)t+=1;if((e[t]??"").trim()!=="</document>")return null;const p=X(u);return p?{node:{type:"paragraph",content:[p]},nextIndex:t+1}:null}function U(e,s,n,t){return e.startsWith(s,t)?e.indexOf(n,t+s.length):-1}function bt(e,s){const n=[e.indexOf("{{{documents.",s),e.indexOf("{{agent.",s),e.indexOf("**",s),e.indexOf("~~",s),e.indexOf("`",s),e.indexOf("*",s)].filter(t=>t>=0);return n.length>0?Math.min(...n):-1}function A(e,s=!1){const n=[];let t=0;for(;t<e.length;){const o=U(e,"***","***",t);if(o>t){const i=e.slice(t+3,o);n.push(...z(A(i,s),"bold","italic")),t=o+3;continue}if(!s&&e.startsWith("{{{documents.",t)){const i=e.indexOf("}}}",t);if(i>t){const y=e.slice(t,i+3),b=X(y);if(b){n.push(b),t=i+3;continue}}}if(!s&&e.startsWith("{{agent.",t)){const i=e.indexOf("}}",t);if(i>t){const y=e.slice(t,i+2),b=gt(y);if(b){n.push(b),t=i+2;continue}}}const u=U(e,"**","**",t);if(u>t){const i=e.slice(t+2,u);n.push(...z(A(i,s),"bold")),t=u+2;continue}const c=U(e,"~~","~~",t);if(c>t){const i=e.slice(t+2,c);n.push(...z(A(i,s),"strike")),t=c+2;continue}const p=e[t]==="*"&&!e.startsWith("**",t)?e.indexOf("*",t+1):-1;if(p>t){const i=e.slice(t+1,p);n.push(...z(A(i,s),"italic")),t=p+1;continue}if(e[t]==="`"){const i=e.indexOf("`",t+1);if(i>t){W(n,e.slice(t+1,i),[{type:"code"}]),t=i+1;continue}}const m=bt(e,t),x=m>=0?m:e.length;if(x===t){W(n,e[t]),t+=1;continue}W(n,e.slice(t,x)),t=x}return n}function yt(e){const s=e.split(`
|
|
21
|
+
*/const rt=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],st=F("refresh-ccw",rt);function at(e,s){return(e??"").toLowerCase().includes(s)}function pe(e,s){if(!s)return{nodes:e,autoExpanded:new Set};const n=new Set;return{nodes:e.flatMap(o=>{if(o.type==="file")return at(o.name,s)?[o]:[];const u=pe(o.children??[],s);return u.nodes.length>0?(n.add(o.path),u.autoExpanded.forEach(c=>n.add(c)),[{...o,children:u.nodes}]):[]}),autoExpanded:n}}function me(e){return e instanceof Error?/HTTP (404|405|501|503)\b|Failed to fetch|NetworkError/i.test(e.message):!1}const R={id:"agent_id",name:"에이전트 이름",role:"에이전트 역할",team:"팀",description:"에이전트 설명"};function ot(e){return{id:e.id.trim()||R.id,name:e.name.trim()||R.name,role:e.role.trim()||R.role,team:e.team.trim()||R.team,description:e.description.trim()||R.description}}function it(e,s,n){let t=!1;return e.state.doc.descendants(o=>o.type.name==="documentBlock"&&o.attrs.key===s&&o.attrs.variant===n?(t=!0,!1):!t),t}const fe=["[&_h1]:mt-0","[&_h1]:mb-3","[&_h1]:text-2xl","[&_h1]:font-bold","[&_h2]:mt-0","[&_h2]:mb-2","[&_h2]:text-xl","[&_h2]:font-semibold","[&_h3]:mt-0","[&_h3]:mb-2","[&_h3]:text-lg","[&_h3]:font-semibold","[&_p]:my-2","[&_p]:leading-7","[&_ul]:my-2","[&_ol]:my-2","[&_ul]:list-disc","[&_ol]:list-decimal","[&_ul]:pl-6","[&_ol]:pl-6","[&_li]:my-1","[&_blockquote]:my-3","[&_blockquote]:border-l-4","[&_blockquote]:border-gray-300","[&_blockquote]:pl-4","[&_blockquote]:text-gray-600","[&_blockquote]:italic","[&_blockquote_p]:my-0","[&_a]:text-blue-600","[&_a]:underline","[&_hr]:my-4","[&_hr]:border-gray-300","[&_code]:rounded","[&_code]:bg-gray-100","[&_code]:px-1.5","[&_code]:py-0.5","[&_code]:font-mono","[&_code]:text-[13px]","[&_pre]:my-3","[&_pre]:overflow-x-auto","[&_pre]:rounded-lg","[&_pre]:bg-gray-900","[&_pre]:p-4","[&_pre]:text-sm","[&_pre]:text-gray-100","[&_pre_code]:bg-transparent","[&_pre_code]:p-0","[&_pre_code]:text-inherit"].join(" "),lt=["min-h-[420px]","rounded-xl","border","border-gray-200","bg-white","px-4","py-3","text-sm","text-gray-900","shadow-sm","focus:outline-none","prose","prose-sm","max-w-none",fe,"[&_.is-editor-empty:first-child::before]:pointer-events-none","[&_.is-editor-empty:first-child::before]:float-left","[&_.is-editor-empty:first-child::before]:h-0","[&_.is-editor-empty:first-child::before]:text-gray-400","[&_.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]"].join(" ");function ct({open:e,request:s,onClose:n}){const{t}=B(),o=d.useRef(null),u=d.useRef(s),[c,p]=d.useState(""),[m,x]=d.useState(!1),[i,y]=d.useState(null),[b,k]=d.useState(!1),w=t("agent.prompt.preview.error");u.current=s;const h=async()=>{var g;if((g=o.current)==null||g.abort(),!u.current.template.trim()){p(""),y(null),k(!1),x(!1);return}const l=new AbortController;o.current=l,x(!0),y(null),k(!1);try{const v=await q.previewPrompt(u.current,{signal:l.signal});if(l.signal.aborted)return;p(v.rendered),y(null),k(!1)}catch(v){if(l.signal.aborted)return;if(me(v)){p(""),y(null),k(!0);return}p(""),k(!1),y(v instanceof Error?v.message:w)}finally{o.current===l&&(o.current=null),x(!1)}};return d.useEffect(()=>{var l;if(!e){(l=o.current)==null||l.abort();return}h()},[e]),d.useEffect(()=>{if(!e)return;const l=g=>{g.key==="Escape"&&(g.preventDefault(),n())};return window.addEventListener("keydown",l),()=>{window.removeEventListener("keydown",l)}},[n,e]),d.useEffect(()=>()=>{var l;(l=o.current)==null||l.abort()},[]),e?r.jsx("div",{"data-testid":"preview-modal-backdrop",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",onClick:n,children:r.jsxs("div",{role:"dialog","aria-modal":"true","data-testid":"preview-modal",onClick:l=>l.stopPropagation(),className:"flex max-h-[85vh] w-full max-w-4xl flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-xl",children:[r.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-gray-200 px-6 py-5",children:[r.jsx("div",{children:r.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:t("agent.prompt.preview.title")})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>{h()},disabled:m,className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200 disabled:cursor-not-allowed disabled:opacity-50",children:[r.jsx(st,{size:14,className:m?"animate-spin":""}),t("agent.prompt.preview.refresh")]}),r.jsxs("button",{type:"button",onClick:n,className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:[r.jsx(ve,{size:14}),t("common.close")]})]})]}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5",children:s.template.trim()?m?r.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[r.jsx(X,{size:16,className:"animate-spin"}),r.jsx("span",{children:t("agent.prompt.preview.loading")})]}):b?r.jsx("div",{className:"text-sm text-gray-500",children:t("agent.prompt.preview.unavailable")}):i?r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-medium text-red-600",children:t("agent.prompt.preview.error")}),r.jsx("div",{className:"text-sm text-red-500",children:i})]}):r.jsx(ke,{content:c,className:fe}):r.jsx("div",{className:"text-sm text-gray-500",children:t("agent.prompt.preview.empty")})}),r.jsxs("div",{className:"flex justify-end gap-2 border-t border-gray-200 px-6 py-4",children:[r.jsxs("button",{type:"button",onClick:()=>{var l;return void((l=navigator.clipboard)==null?void 0:l.writeText(c))},disabled:!c,className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200 disabled:cursor-not-allowed disabled:opacity-50",children:[r.jsx(we,{size:14}),t("agent.prompt.preview.copy")]}),r.jsx("button",{type:"button",onClick:n,className:"rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-600",children:t("common.close")})]})]})}):null}function dt({trigger:e,items:s,searchable:n=!1,searchPlaceholder:t,emptyLabel:o}){const u=d.useRef(null),c=d.useRef(null),[p,m]=d.useState(!1),[x,i]=d.useState(""),[y,b]=d.useState(0),k=d.useMemo(()=>{const l=x.trim().toLowerCase();return l?s.filter(g=>g.label.toLowerCase().includes(l)?!0:g.actions.some(v=>v.label.toLowerCase().includes(l))):s},[s,x]),w=d.useMemo(()=>k.flatMap(l=>l.actions.map(g=>({itemLabel:l.label,actionLabel:g.label,onClick:g.onClick}))),[k]);d.useEffect(()=>{var l;if(!p){i(""),b(0);return}n&&((l=c.current)==null||l.focus())},[p,n]),d.useEffect(()=>{y<w.length||b(Math.max(w.length-1,0))},[w.length,y]),d.useEffect(()=>{if(!p)return;const l=v=>{var _;(_=u.current)!=null&&_.contains(v.target)||m(!1)},g=v=>{var _;if(v.key==="Escape"){v.preventDefault(),m(!1);return}if(w.length!==0){if(v.key==="ArrowDown"){v.preventDefault(),b(M=>(M+1)%w.length);return}if(v.key==="ArrowUp"){v.preventDefault(),b(M=>(M-1+w.length)%w.length);return}v.key==="Enter"&&(v.preventDefault(),(_=w[y])==null||_.onClick(),m(!1))}};return window.addEventListener("mousedown",l),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",l),window.removeEventListener("keydown",g)}},[w,y,p]);let h=-1;return r.jsxs("div",{ref:u,className:"relative",children:[r.jsxs("button",{type:"button",onMouseDown:l=>l.preventDefault(),onClick:()=>m(l=>!l),className:"inline-flex items-center gap-1 rounded-md border border-gray-200 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-700 transition hover:border-gray-300 hover:bg-gray-100",children:[r.jsx("span",{children:e}),r.jsx(ce,{size:14})]}),p?r.jsxs("div",{className:"absolute left-0 top-[calc(100%+0.5rem)] z-20 w-72 rounded-xl border border-gray-200 bg-white p-2 shadow-lg",children:[n?r.jsxs("label",{className:"mb-2 flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-500",children:[r.jsx(de,{size:14}),r.jsx("input",{ref:c,value:x,onChange:l=>{i(l.target.value),b(0)},className:"w-full bg-transparent text-sm text-gray-700 outline-none","aria-label":t,placeholder:t})]}):null,r.jsx("div",{className:"max-h-80 space-y-1 overflow-y-auto",children:k.length===0?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:o??""}):k.map(l=>r.jsxs("div",{className:"rounded-lg border border-gray-100 px-3 py-2",children:[r.jsx("div",{className:"text-sm font-medium text-gray-900",children:l.label}),l.actions.length>0?r.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:l.actions.map(g=>{h+=1;const v=h===y;return r.jsx("button",{type:"button",onMouseDown:_=>_.preventDefault(),onClick:()=>{g.onClick(),m(!1)},className:`rounded-md px-2.5 py-1 text-xs font-medium transition ${v?"bg-blue-500 text-white":"border border-gray-200 bg-white text-gray-700 hover:border-gray-300 hover:bg-gray-100"}`,children:g.label},`${l.label}-${g.label}`)})}):r.jsx("div",{className:"mt-1 text-xs text-gray-500",children:o??l.label})]},l.label))})]}):null]})}function ee(e){return e.replace(/\\/g,"/").replace(/^\.?\//,"")}function te(e,s){return(e??"").toLowerCase().includes(s)}function ut({documents:e,documentsLoading:s,documentsError:n,documentsUnavailable:t,onInsertDocument:o,onRefetchDocuments:u}){const{t:c}=B(),p=d.useRef(null),m=d.useRef(null),[x,i]=d.useState(!1),[y,b]=d.useState(""),[k,w]=d.useState([]),[h,l]=d.useState(!1),[g,v]=d.useState(null),[_,M]=d.useState(new Set),[a,j]=d.useState(!1),[C,D]=d.useState(null);d.useEffect(()=>{var N;if(!x||((N=m.current)==null||N.focus(),k.length>0||h))return;let f=!1;return(async()=>{l(!0),v(null);try{const S=await q.getDocTree();f||w(S)}catch(S){f||v(S instanceof Error?S.message:c("agent.prompt.documentPicker.treeError"))}finally{f||l(!1)}})(),()=>{f=!0}},[x,k.length]),d.useEffect(()=>{x||(b(f=>f&&""),M(f=>f.size>0?new Set:f))},[x]),d.useEffect(()=>{if(!x)return;const f=N=>{var S;(S=p.current)!=null&&S.contains(N.target)||i(!1)},L=N=>{N.key==="Escape"&&(N.preventDefault(),i(!1))};return window.addEventListener("mousedown",f),window.addEventListener("keydown",L),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",L)}},[x]);const E=y.trim().toLowerCase(),$=d.useMemo(()=>e.filter(f=>f.type==="inline"),[e]),O=d.useMemo(()=>{const f=e.filter(L=>L.type==="file"&&L.path);return L=>{const N=ee(L),S=f.find(ye=>ee(ye.path??"")===N);return S==null?void 0:S.key}},[e]),T=d.useMemo(()=>E?$.filter(f=>te(f.key,E)||te(f.summary,E)):$,[$,E]),P=d.useMemo(()=>pe(k,E),[E,k]),xe=d.useMemo(()=>{if(!E)return _;const f=new Set(_);return P.autoExpanded.forEach(L=>f.add(L)),f},[_,P.autoExpanded,E]),H=f=>{o(f,"content"),i(!1)},be=async f=>{D(null);const L=O(f);if(L){H(L);return}try{j(!0);const N=await q.registerDocument({path:f});H(N.key),u==null||u()}catch(N){D(N instanceof Error?N.message:c("agent.prompt.documentPicker.registerError"))}finally{j(!1)}},G=s||n||t||T.length>0,Z=h||g||P.nodes.length>0;return r.jsxs("div",{ref:p,className:"relative",children:[r.jsxs("button",{type:"button",onMouseDown:f=>f.preventDefault(),onClick:()=>i(f=>!f),className:"inline-flex items-center gap-1 rounded-md border border-gray-200 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-700 transition hover:border-gray-300 hover:bg-gray-100","aria-label":c("agent.prompt.documentInsert"),children:[r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[r.jsx(K,{className:"h-4 w-4"}),r.jsx("span",{children:c("agent.prompt.documentInsert")})]}),r.jsx(ce,{size:14})]}),x?r.jsxs("div",{className:"absolute left-0 top-[calc(100%+0.5rem)] z-20 w-80 rounded-xl border border-gray-200 bg-white p-2 shadow-lg","data-testid":"document-picker-popover",children:[r.jsxs("label",{className:"mb-2 flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-500",children:[r.jsx(de,{size:14}),r.jsx("input",{ref:m,value:y,onChange:f=>b(f.target.value),className:"w-full bg-transparent text-sm text-gray-700 outline-none","aria-label":c("agent.prompt.documentPicker.searchPlaceholder"),placeholder:c("agent.prompt.documentPicker.searchPlaceholder")})]}),r.jsxs("div",{className:"max-h-96 space-y-3 overflow-y-auto",children:[G?r.jsxs("section",{children:[r.jsxs("div",{className:"mb-1 flex items-center gap-2 px-2 py-1 text-xs font-semibold uppercase tracking-wide text-gray-400",children:[r.jsx(je,{className:"h-3.5 w-3.5"}),r.jsx("span",{children:c("agent.prompt.documentPicker.inlineSection")})]}),s?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentInsertLoading")}):n?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-red-500",children:n}):t?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentInsertUnavailable")}):T.length===0?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentPicker.noInlineResults")}):r.jsx("div",{className:"space-y-1",children:T.map(f=>r.jsxs("button",{type:"button",onMouseDown:L=>L.preventDefault(),onClick:()=>H(f.key),className:"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm text-gray-700 transition hover:bg-gray-100",children:[r.jsx(K,{className:"h-4 w-4 shrink-0 text-gray-400"}),r.jsx("span",{className:"truncate",children:f.key})]},f.key))})]}):null,Z?r.jsxs("section",{children:[r.jsxs("div",{className:"mb-1 flex items-center gap-2 px-2 py-1 text-xs font-semibold uppercase tracking-wide text-gray-400",children:[r.jsx(K,{className:"h-3.5 w-3.5"}),r.jsx("span",{children:c("agent.prompt.documentPicker.docsSection")})]}),h?r.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-3 py-2 text-sm text-gray-500",children:[r.jsx(X,{className:"h-4 w-4 animate-spin"}),r.jsx("span",{children:c("agent.prompt.documentPicker.treeLoading")})]}):g?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-red-500",children:g}):P.nodes.length===0?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentPicker.noTreeResults")}):r.jsxs(r.Fragment,{children:[r.jsx(Ne,{nodes:P.nodes,expandedFolders:xe,onToggle:f=>M(L=>{const N=new Set(L);return N.has(f)?N.delete(f):N.add(f),N}),onSelect:f=>{a||be(f)},selectedPath:null,isFileDisabled:()=>a,renderFileSuffix:f=>O(f.path)?r.jsx(nt,{className:"h-3.5 w-3.5 shrink-0 text-blue-500","aria-label":c("agent.prompt.documentPicker.linked")}):a?r.jsx(X,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-gray-400"}):null}),C?r.jsx("div",{className:"mt-1 rounded-lg px-3 py-2 text-sm text-red-500",role:"alert",children:C}):null]})]}):null,!G&&!Z?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentInsertEmpty")}):null]})]}):null]})}function pt({deleteNode:e,extension:s,node:n,updateAttributes:t}){const{t:o}=B(),u=d.useRef(null),[c,p]=d.useState(!1),m=String(n.attrs.key??""),x=String(n.attrs.variant??"content"),i=s.options.getVariantLabel;d.useEffect(()=>{if(!c)return;const b=w=>{var h;(h=u.current)!=null&&h.contains(w.target)||p(!1)},k=w=>{w.key==="Escape"&&(w.preventDefault(),p(!1))};return window.addEventListener("mousedown",b),window.addEventListener("keydown",k),()=>{window.removeEventListener("mousedown",b),window.removeEventListener("keydown",k)}},[c]);const y=[{value:"content",label:i("content")},{value:"toc",label:i("toc")}];return r.jsxs(Ce,{as:"span",ref:u,className:"relative inline-flex","data-testid":"document-block-node",children:[r.jsx("button",{type:"button","data-testid":"document-block-trigger",onMouseDown:b=>b.preventDefault(),onClick:()=>p(b=>!b),className:"inline-flex items-center rounded-lg border border-amber-200 bg-amber-50 px-2 py-0.5 text-xs font-medium text-amber-700",children:`📄 ${m} · ${i(x)}`}),c?r.jsxs("span",{className:"absolute left-0 top-[calc(100%+0.375rem)] z-20 min-w-32 rounded-lg border border-gray-200 bg-white p-1 shadow-lg","data-testid":"document-block-popover",children:[y.map(b=>{const k=b.value===x;return r.jsxs("button",{type:"button","data-testid":`document-block-option-${b.value}`,onMouseDown:w=>w.preventDefault(),onClick:()=>{t({variant:b.value}),p(!1)},className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-gray-700 transition hover:bg-gray-100",children:[r.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center",children:k?r.jsx(Le,{className:"h-4 w-4 text-blue-500"}):null}),r.jsx("span",{children:b.label})]},b.value)}),r.jsx("div",{className:"my-1 border-t border-gray-100"}),r.jsxs("button",{type:"button","data-testid":"document-block-delete",onMouseDown:b=>b.preventDefault(),onClick:()=>{e(),p(!1)},className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-red-600 transition hover:bg-red-50",children:[r.jsx(_e,{className:"h-4 w-4"}),r.jsx("span",{children:o("agent.prompt.documentChip.delete")})]})]}):null]})}const mt=ue.create({name:"documentBlock",addOptions(){return{getVariantLabel:e=>String(e)}},inline:!0,group:"inline",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{key:{default:""},variant:{default:"content"}}},parseHTML(){return[{tag:"span[data-doc-block]"}]},renderHTML({HTMLAttributes:e,node:s}){const n=String(s.attrs.key??""),t=String(s.attrs.variant??"content"),o=this.options.getVariantLabel(t);return["span",Se(e,{"data-doc-block":"true","data-key":n,"data-variant":t,"data-testid":"document-block",class:"inline-flex items-center rounded-lg border border-amber-200 bg-amber-50 px-2 py-0.5 text-xs font-medium text-amber-700"}),`📄 ${n} · ${o}`]},addNodeView(){return Ee(pt)}}),ft=De.extend({name:"variableMention",addAttributes(){return{variable:{default:"",parseHTML:e=>e.getAttribute("data-variable")??"",renderHTML:e=>({"data-variable":e.variable})}}},renderText({node:e}){return`{{${String(e.attrs.variable??"")}}}`},renderHTML({node:e,HTMLAttributes:s}){return["span",{...s,class:"inline-flex items-center rounded-full bg-blue-500 px-2 py-0.5 text-xs font-semibold text-white","data-testid":"variable-chip"},String(e.attrs.variable??"")]}}),he=["agent.id","agent.name","agent.role","agent.team","agent.description"],ne=["bold","italic","strike","code"],re={bold:{open:"**",close:"**"},italic:{open:"*",close:"*"},strike:{open:"~~",close:"~~"},code:{open:"`",close:"`"}};function ht(e){return he.includes(e)}function ge(e,s){return s&&s.length>0?{type:"text",text:e,marks:s}:{type:"text",text:e}}function W(e,s,n){if(!s)return;const t=e[e.length-1],o=JSON.stringify(n??[]),u=JSON.stringify((t==null?void 0:t.marks)??[]);if((t==null?void 0:t.type)==="text"&&o===u){t.text=`${t.text??""}${s}`;return}e.push(ge(s,n))}function z(e,...s){return e.map(n=>{if(n.type!=="text")return n;const t=new Set((n.marks??[]).map(u=>u.type)),o=s.filter(u=>!t.has(u)).map(u=>({type:u}));return{...n,marks:[...n.marks??[],...o]}})}function gt(e){const s=e.match(/^\{\{(agent\.(?:id|name|role|team|description))\}\}$/);return!s||!ht(s[1])?null:{type:"variableMention",attrs:{variable:s[1]}}}function J(e){const s=e.match(/^\{\{\{documents\.([^.\s}]+)\.(content|toc)\}\}\}$/);return s?{type:"documentBlock",attrs:{key:s[1],variant:s[2]}}:null}function xt(e,s){const n=e[s].match(/^<document\b[^>]*>\s*(\{\{\{documents\.([^.\s}]+)\.(content|toc)\}\}\})\s*<\/document>\s*$/);if(n){const m=J(n[1]);if(m)return{node:{type:"paragraph",content:[m]},nextIndex:s+1}}if(!/^<document\b[^>]*>\s*$/.test(e[s]??""))return null;let t=s+1;for(;t<e.length&&(e[t]??"").trim()==="";)t+=1;const u=(e[t]??"").trim();for(t+=1;t<e.length&&(e[t]??"").trim()==="";)t+=1;if((e[t]??"").trim()!=="</document>")return null;const p=J(u);return p?{node:{type:"paragraph",content:[p]},nextIndex:t+1}:null}function Q(e,s,n,t){return e.startsWith(s,t)?e.indexOf(n,t+s.length):-1}function bt(e,s){const n=[e.indexOf("{{{documents.",s),e.indexOf("{{agent.",s),e.indexOf("**",s),e.indexOf("~~",s),e.indexOf("`",s),e.indexOf("*",s)].filter(t=>t>=0);return n.length>0?Math.min(...n):-1}function A(e,s=!1){const n=[];let t=0;for(;t<e.length;){const o=Q(e,"***","***",t);if(o>t){const i=e.slice(t+3,o);n.push(...z(A(i,s),"bold","italic")),t=o+3;continue}if(!s&&e.startsWith("{{{documents.",t)){const i=e.indexOf("}}}",t);if(i>t){const y=e.slice(t,i+3),b=J(y);if(b){n.push(b),t=i+3;continue}}}if(!s&&e.startsWith("{{agent.",t)){const i=e.indexOf("}}",t);if(i>t){const y=e.slice(t,i+2),b=gt(y);if(b){n.push(b),t=i+2;continue}}}const u=Q(e,"**","**",t);if(u>t){const i=e.slice(t+2,u);n.push(...z(A(i,s),"bold")),t=u+2;continue}const c=Q(e,"~~","~~",t);if(c>t){const i=e.slice(t+2,c);n.push(...z(A(i,s),"strike")),t=c+2;continue}const p=e[t]==="*"&&!e.startsWith("**",t)?e.indexOf("*",t+1):-1;if(p>t){const i=e.slice(t+1,p);n.push(...z(A(i,s),"italic")),t=p+1;continue}if(e[t]==="`"){const i=e.indexOf("`",t+1);if(i>t){W(n,e.slice(t+1,i),[{type:"code"}]),t=i+1;continue}}const m=bt(e,t),x=m>=0?m:e.length;if(x===t){W(n,e[t]),t+=1;continue}W(n,e.slice(t,x)),t=x}return n}function yt(e){const s=e.split(`
|
|
22
22
|
`),n=[];return s.forEach((t,o)=>{n.push(...A(t)),o<s.length-1&&n.push({type:"hardBreak"})}),{type:"paragraph",content:n}}function se(e,s){const n=s?"orderedList":"bulletList",t=s?/^\d+\.\s+/:/^[-*]\s+/;return{type:n,content:e.map(o=>({type:"listItem",content:[{type:"paragraph",content:A(o.replace(t,""))}]}))}}function vt(e){return/^#{1,3}\s+/.test(e)||/^```/.test(e)||/^---+$/.test(e)||/^[-*]\s+/.test(e)||/^\d+\.\s+/.test(e)}function kt(e){const s=new Set((e??[]).map(n=>n.type).filter(n=>ne.includes(n)));return ne.filter(n=>s.has(n))}function wt(e,s){let n=0;for(;n<e.length&&n<s.length&&e[n]===s[n];)n+=1;return n}function ae(e){return e.replace(/&/g,"&").replace(/"/g,""").trim()}function jt(e,s,n){var t,o,u,c;if(e.type==="hardBreak")return`
|
|
23
23
|
`;if(e.type==="variableMention"){const p=String(((t=e.attrs)==null?void 0:t.variable)??"");return s==="preview"?`**{{${p}}}**`:`{{${p}}}`}if(e.type==="documentBlock"){const p=String(((o=e.attrs)==null?void 0:o.key)??""),m=String(((u=e.attrs)==null?void 0:u.variant)??"content"),x=`{{{documents.${p}.${m}}}}`,i=((c=n==null?void 0:n.getDocumentMeta)==null?void 0:c.call(n,p))??{name:p},y=[`name="${ae(i.name)}"`];return i.path&&y.push(`path="${ae(i.path)}"`),y.push(`type="${m}"`),`<document ${y.join(" ")}>
|
|
24
24
|
|
|
25
25
|
${x}
|
|
26
26
|
|
|
27
|
-
</document>`}return I(e.content,s,n)}function I(e,s,n){let t="",o=[];const u=c=>{const p=wt(o,c);for(let m=o.length-1;m>=p;m-=1)t+=re[o[m]].close;for(let m=p;m<c.length;m+=1)t+=re[c[m]].open;o=c};for(const c of e??[]){if(c.type==="text"){u(kt(c.marks)),t+=c.text??"";continue}u([]),t+=jt(c,s,n)}return u([]),t}function
|
|
27
|
+
</document>`}return I(e.content,s,n)}function I(e,s,n){let t="",o=[];const u=c=>{const p=wt(o,c);for(let m=o.length-1;m>=p;m-=1)t+=re[o[m]].close;for(let m=p;m<c.length;m+=1)t+=re[c[m]].open;o=c};for(const c of e??[]){if(c.type==="text"){u(kt(c.marks)),t+=c.text??"";continue}u([]),t+=jt(c,s,n)}return u([]),t}function U(e){const s=e.replace(/\r\n?/g,`
|
|
28
28
|
`);if(!s.trim())return{type:"doc",content:[]};const n=s.split(`
|
|
29
29
|
`),t=[];let o=0;for(;o<n.length;){const u=n[o];if(!u.trim()){o+=1;continue}const c=xt(n,o);if(c){t.push(c.node),o=c.nextIndex;continue}const p=u.match(/^```(\S+)?\s*$/);if(p){const i=p[1]??null,y=[];for(o+=1;o<n.length&&!/^```/.test(n[o]);)y.push(n[o]),o+=1;o<n.length&&(o+=1),t.push({type:"codeBlock",attrs:i?{language:i}:{},content:[ge(y.join(`
|
|
30
30
|
`))]});continue}const m=u.match(/^(#{1,3})\s+(.*)$/);if(m){t.push({type:"heading",attrs:{level:m[1].length},content:A(m[2])}),o+=1;continue}if(/^---+$/.test(u)){t.push({type:"horizontalRule"}),o+=1;continue}if(/^[-*]\s+/.test(u)){const i=[];for(;o<n.length&&/^[-*]\s+/.test(n[o]);)i.push(n[o]),o+=1;t.push(se(i,!1));continue}if(/^\d+\.\s+/.test(u)){const i=[];for(;o<n.length&&/^\d+\.\s+/.test(n[o]);)i.push(n[o]),o+=1;t.push(se(i,!0));continue}const x=[u];for(o+=1;o<n.length&&n[o].trim()&&!vt(n[o]);)x.push(n[o]),o+=1;t.push(yt(x.join(`
|
|
@@ -34,4 +34,4 @@ ${x}
|
|
|
34
34
|
${m}
|
|
35
35
|
\`\`\``}case"horizontalRule":return"---";case"paragraph":return I(e.content,s,n);default:return I(e.content,s,n)}}function oe(e,s){return(e.content??[]).map(n=>Nt(n,"hbs",s)).join(`
|
|
36
36
|
|
|
37
|
-
`)}function Ct(e){return/\{\{agent\.(?:id|name|role|team|description)\}\}|\{\{\{documents\.[^.\s}]+\.(?:content|toc)\}\}\}|<document\b[^>]*>/.test(e)}function Lt(e,s){return{type:"documentBlock",attrs:{key:e,variant:s}}}function ie(e){return{type:"variableMention",attrs:{variable:e}}}function
|
|
37
|
+
`)}function Ct(e){return/\{\{agent\.(?:id|name|role|team|description)\}\}|\{\{\{documents\.[^.\s}]+\.(?:content|toc)\}\}\}|<document\b[^>]*>/.test(e)}function Lt(e,s){return{type:"documentBlock",attrs:{key:e,variant:s}}}function ie(e){return{type:"variableMention",attrs:{variable:e}}}function V(e){return!e.isActive("codeBlock")&&!e.isActive("code")}function le(e,s,n){return V(e)?it(e,s,n)?!1:(e.chain().focus().insertContent(Lt(s,n)).run(),!0):(e.chain().focus().insertContent(`{{{documents.${s}.${n}}}}`).run(),!0)}const _t=d.forwardRef(function({value:s,onChange:n,documents:t,documentsLoading:o,documentsError:u,documentsUnavailable:c,onPreview:p,onRefetchDocuments:m},x){const{t:i}=B(),y=d.useRef(null),b=d.useMemo(()=>({content:i("agent.prompt.variantContent"),toc:i("agent.prompt.variantToc")}),[i]),k=d.useMemo(()=>a=>{var C;const j=t.find(D=>D.key===a);if((j==null?void 0:j.type)==="file"&&j.path){const D=j.path.split("/").filter(Boolean);return{name:D[D.length-1]??a,path:j.path}}return{name:((C=j==null?void 0:j.summary)==null?void 0:C.trim())||a}},[t]),w=d.useMemo(()=>[{key:"headings",buttons:[{key:"h1",label:i("agent.prompt.toolbar.h1"),icon:Me,shortcut:"Cmd+Alt+1",action:a=>{a.chain().focus().toggleHeading({level:1}).run()},isActive:a=>a.isActive("heading",{level:1})},{key:"h2",label:i("agent.prompt.toolbar.h2"),icon:Ae,shortcut:"Cmd+Alt+2",action:a=>{a.chain().focus().toggleHeading({level:2}).run()},isActive:a=>a.isActive("heading",{level:2})},{key:"h3",label:i("agent.prompt.toolbar.h3"),icon:$e,shortcut:"Cmd+Alt+3",action:a=>{a.chain().focus().toggleHeading({level:3}).run()},isActive:a=>a.isActive("heading",{level:3})}]},{key:"text",buttons:[{key:"bold",label:i("agent.prompt.toolbar.bold"),icon:Te,shortcut:"Cmd+B",action:a=>{a.chain().focus().toggleBold().run()},isActive:a=>a.isActive("bold")},{key:"italic",label:i("agent.prompt.toolbar.italic"),icon:Ie,shortcut:"Cmd+I",action:a=>{a.chain().focus().toggleItalic().run()},isActive:a=>a.isActive("italic")},{key:"strike",label:i("agent.prompt.toolbar.strike"),icon:Pe,shortcut:"Cmd+Shift+S",action:a=>{a.chain().focus().toggleStrike().run()},isActive:a=>a.isActive("strike")}]},{key:"lists",buttons:[{key:"bulletList",label:i("agent.prompt.toolbar.bulletList"),icon:Re,shortcut:"Cmd+Shift+8",action:a=>{a.chain().focus().toggleBulletList().run()},isActive:a=>a.isActive("bulletList")},{key:"orderedList",label:i("agent.prompt.toolbar.orderedList"),icon:Be,shortcut:"Cmd+Shift+7",action:a=>{a.chain().focus().toggleOrderedList().run()},isActive:a=>a.isActive("orderedList")},{key:"blockquote",label:i("agent.prompt.toolbar.blockquote"),icon:Oe,shortcut:"Cmd+Shift+B",action:a=>{a.chain().focus().toggleBlockquote().run()},isActive:a=>a.isActive("blockquote")}]},{key:"code",buttons:[{key:"code",label:i("agent.prompt.toolbar.code"),icon:ze,shortcut:"Cmd+E",action:a=>{a.chain().focus().toggleCode().run()},isActive:a=>a.isActive("code")},{key:"codeBlock",label:i("agent.prompt.toolbar.codeBlock"),icon:Ve,shortcut:"Cmd+Alt+C",action:a=>{a.chain().focus().toggleCodeBlock().run()},isActive:a=>a.isActive("codeBlock")},{key:"horizontalRule",label:i("agent.prompt.toolbar.horizontalRule"),icon:qe,shortcut:"Cmd+Alt+-",action:a=>{a.chain().focus().setHorizontalRule().run()}}]},{key:"history",buttons:[{key:"undo",label:i("agent.prompt.toolbar.undo"),icon:Fe,shortcut:"Cmd+Z",action:a=>{a.chain().focus().undo().run()},isDisabled:a=>!a.can().chain().focus().undo().run()},{key:"redo",label:i("agent.prompt.toolbar.redo"),icon:He,shortcut:"Cmd+Shift+Z",action:a=>{a.chain().focus().redo().run()},isDisabled:a=>!a.can().chain().focus().redo().run()}]}],[i]),h=Ke({immediatelyRender:!1,extensions:[We.configure({heading:{levels:[1,2,3]}}),Qe.configure({placeholder:i("agent.prompt.placeholder")}),ft.configure({HTMLAttributes:{class:"inline-flex items-center rounded-full bg-blue-500 px-2 py-0.5 text-xs font-semibold text-white"}}),mt.configure({getVariantLabel:a=>a==="toc"?b.toc:b.content}),ue.create({name:"fallbackInline",inline:!0,group:"inline"})],content:U(s),editorProps:{attributes:{class:lt,"data-testid":"prompt-editor-content","aria-label":i("agent.prompt.editorLabel"),role:"textbox"}},onUpdate({editor:a}){const j=oe(a.getJSON(),{getDocumentMeta:k});y.current=j,n(j)}}),l=Ue({editor:h,selector:({editor:a})=>a?{active:{h1:a.isActive("heading",{level:1}),h2:a.isActive("heading",{level:2}),h3:a.isActive("heading",{level:3}),bold:a.isActive("bold"),italic:a.isActive("italic"),strike:a.isActive("strike"),bulletList:a.isActive("bulletList"),orderedList:a.isActive("orderedList"),blockquote:a.isActive("blockquote"),code:a.isActive("code"),codeBlock:a.isActive("codeBlock")},disabled:{undo:!a.can().chain().focus().undo().run(),redo:!a.can().chain().focus().redo().run()}}:{active:{},disabled:{}}}),g=d.useMemo(()=>he.map(a=>({label:a,actions:[{label:i("agent.prompt.toolbar.insert"),onClick:()=>{if(h){if(V(h)){h.chain().focus().insertContent(ie(a)).run();return}h.chain().focus().insertContent(`{{${a}}}`).run()}}}]})),[h,i]);d.useEffect(()=>{if(!h)return;const a=oe(h.getJSON(),{getDocumentMeta:k});s===a||s===y.current||(h.commands.setContent(U(s)),y.current=s)},[h,k,s]),d.useImperativeHandle(x,()=>({insertVariable(a){if(h){if(V(h)){h.chain().focus().insertContent(ie(a)).run();return}h.chain().focus().insertContent(`{{${a}}}`).run()}},insertDocumentBlock(a,j){return h?le(h,a,j):!1},selectAll(){h==null||h.chain().focus().selectAll().run()}}),[h]);const v=a=>{if(!h||!V(h))return;const j=a.clipboardData.getData("text/plain");if(!j||!Ct(j))return;a.preventDefault();const C=U(j);h.chain().focus().insertContent(C.content??[]).run()},_=a=>`${a.label} (${a.shortcut})`,M=(a,j)=>h?le(h,a,j):!1;return r.jsxs("section",{className:"rounded-xl border border-gray-200 bg-gray-50 p-4 shadow-sm",children:[r.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2 rounded-xl border border-gray-200 bg-white p-2 shadow-sm",children:[w.map((a,j)=>r.jsxs("div",{className:"flex items-center gap-1",children:[j>0?r.jsx("div",{className:"mx-1 h-6 border-l border-gray-300","aria-hidden":"true"}):null,a.buttons.map(C=>{var T;const D=_(C),E=(l==null?void 0:l.active[C.key])??!1,$=h?(((T=C.isDisabled)==null?void 0:T.call(C,h))??!1)||((l==null?void 0:l.disabled[C.key])??!1):!0,O=C.icon;return r.jsx("button",{type:"button",title:D,"aria-label":D,"data-testid":`prompt-toolbar-${C.key}`,disabled:$,onClick:()=>h&&C.action(h),className:`flex h-8 w-8 items-center justify-center rounded-md transition-colors ${E?"bg-gray-200 text-gray-900":"text-gray-600 hover:bg-gray-100 hover:text-gray-900"} ${$?"cursor-not-allowed opacity-40":""}`,children:r.jsx(O,{className:"h-4 w-4"})},C.key)})]},a.key)),r.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[r.jsx("div",{className:"mx-1 h-6 border-l border-gray-300","aria-hidden":"true"}),r.jsx(dt,{trigger:r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[r.jsx(Ze,{className:"h-4 w-4"}),r.jsx("span",{children:i("agent.prompt.toolbar.variable")})]}),items:g,emptyLabel:i("agent.prompt.toolbar.empty")}),r.jsx(ut,{documents:t,documentsLoading:o,documentsError:u,documentsUnavailable:c,onInsertDocument:M,onRefetchDocuments:m}),r.jsx("button",{type:"button",title:`${i("agent.prompt.preview.button")} (Cmd+P)`,"aria-label":`${i("agent.prompt.preview.button")} (Cmd+P)`,"data-testid":"prompt-toolbar-preview",onClick:p,className:"flex h-8 w-8 items-center justify-center rounded-md text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900",children:r.jsx(et,{className:"h-4 w-4"})})]})]}),r.jsx("div",{"data-testid":"prompt-editor",onPaste:v,children:r.jsx(Xe,{editor:h})})]})});function St({previewAgentId:e=null}){const{t:s}=B(),n=Je(g=>g.currentWorkspaceId),t=Y(g=>g.form),o=Y(g=>g.setField),[u,c]=d.useState([]),[p,m]=d.useState(!0),[x,i]=d.useState(null),[y,b]=d.useState(!1),[k,w]=d.useState(!1),h=d.useMemo(()=>{const g=ot(t);return{template:t.prompt,...e?{agentId:e}:{},context:{agent:g}}},[t,e]),l=d.useCallback(async()=>{m(!0),i(null),b(!1);try{const g=await q.getDocuments();c(g.documents)}catch(g){if(me(g)){c([]),b(!0);return}i(g instanceof Error?g.message:s("agent.prompt.documentInsertError"))}finally{m(!1)}},[s]);return d.useEffect(()=>{l()},[n,l]),d.useEffect(()=>{const g=v=>{!(v.metaKey||v.ctrlKey)||v.key.toLowerCase()!=="p"||(v.preventDefault(),w(!0))};return window.addEventListener("keydown",g),()=>{window.removeEventListener("keydown",g)}},[]),r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-base font-semibold text-gray-900",children:s("agent.section.promptTitle")}),r.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s("agent.section.promptDescription")})]}),r.jsx("div",{className:"grid grid-cols-1 gap-5",children:r.jsx(_t,{value:t.prompt,onChange:g=>o("prompt",g),documents:u,documentsLoading:p,documentsError:x,documentsUnavailable:y,onPreview:()=>w(!0),onRefetchDocuments:()=>void l()})}),r.jsx(ct,{open:k,request:h,onClose:()=>w(!1)})]})}export{St as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as ln,a0 as an,a1 as y,a2 as tn,a3 as G,a4 as q,a5 as _,a6 as un,a7 as rn,a8 as K,a9 as o,aa as z,ab as sn,ac as on,ad as fn}from"./main-
|
|
1
|
+
import{$ as ln,a0 as an,a1 as y,a2 as tn,a3 as G,a4 as q,a5 as _,a6 as un,a7 as rn,a8 as K,a9 as o,aa as z,ab as sn,ac as on,ad as fn}from"./main-DgXktCKZ.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,B,a){var O=I-l,i=D-h,n=B-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function V(l,h,I,D,v,A,B){var a=l-I,O=h-D,i=(B?A:-A)/K(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,C=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*K(fn(0,T*T*R-P*P)),$=(P*g-m*S)/R,j=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=$-C,e=j-t,r=w-C,F=p-t;return x*x+e*e>r*r+F*F&&($=w,j=p),{cx:$,cy:j,x01:-n,y01:-d,x11:$*(v/T-1),y11:j*(v/T-1)}}function hn(){var l=cn,h=yn,I=z(0),D=null,v=gn,A=dn,B=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=A.apply(this,arguments)-an,C=un(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(C>tn-y)a.moveTo(s*G(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*G(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=C,S=C,$=B.apply(this,arguments)/2,j=$>y&&(D?+D.apply(this,arguments):K(u*u+s*s)),w=_(un(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if(j>y){var F=sn(j/u*q($)),L=sn(j/s*q($));(P-=F*2)>y?(F*=t?1:-1,R+=F,T-=F):(P=0,R=T=(f+c)/2),(S-=L*2)>y?(L*=t?1:-1,m+=L,g-=L):(S=0,m=g=(f+c)/2)}var H=s*G(m),J=s*q(m),M=u*G(T),N=u*q(T);if(w>y){var Q=s*G(g),U=s*q(g),W=u*G(R),X=u*q(R),E;if(C<rn)if(E=pn(H,J,W,X,Q,U,M,N)){var Y=H-E[0],Z=J-E[1],b=Q-E[0],k=U-E[1],nn=1/q(on((Y*b+Z*k)/(K(Y*Y+Z*Z)*K(b*b+k*k)))/2),en=K(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=V(W,X,H,J,s,x,t),r=V(Q,U,M,N,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(H,J),a.arc(0,0,s,m,g,!t)):a.moveTo(H,J),!(u>y)||!(P>y)?a.lineTo(M,N):p>y?(e=V(M,N,Q,U,u,-p,t),r=V(H,J,W,X,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-rn/2;return[G(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:z(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:z(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:z(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:z(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:z(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:z(+n),i):A},i.padAngle=function(n){return arguments.length?(B=typeof n=="function"?n:z(+n),i):B},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
|