@cedros/pay-react 1.1.27 → 1.1.29
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/{AISettingsSection-DELur7D2.js → AISettingsSection-B7qrycfY.js} +2 -2
- package/dist/{AISettingsSection-BlIv3CzS.mjs → AISettingsSection-DtAgMsDw.mjs} +6 -4
- package/dist/{AutosaveIndicator-Bed0-ekg.mjs → AutosaveIndicator-BEvABoKU.mjs} +1 -1
- package/dist/AutosaveIndicator-DiyeAg93.js +1 -0
- package/dist/CedrosContext-5Gjveoba.mjs +2555 -0
- package/dist/CedrosContext-CCakH2SZ.js +3 -0
- package/dist/CedrosPayAdminDashboard-CAwEvn66.js +1 -0
- package/dist/CedrosPayAdminDashboard-CBuvNAtB.mjs +250 -0
- package/dist/{ChatLogsSection-v4zwzCTC.mjs → ChatLogsSection-Ber5o8hF.mjs} +19 -17
- package/dist/ChatLogsSection-DLxMMi9I.js +1 -0
- package/dist/ComplianceSection-Buu0zTiL.js +1 -0
- package/dist/{ComplianceSection-CemgfDrL.mjs → ComplianceSection-ZCr0wsvw.mjs} +18 -15
- package/dist/{CryptoButton-BV9owVe2.mjs → CryptoButton-Cl2kZbOP.mjs} +26 -24
- package/dist/CryptoButton-DxFCYDlJ.js +1 -0
- package/dist/CustomersSection-BywmMLur.js +1 -0
- package/dist/{CustomersSection-D_j7OrfS.mjs → CustomersSection-D9UknSKC.mjs} +21 -19
- package/dist/{DisputesSection-BcAbXp3K.mjs → DisputesSection-C_eySK-W.mjs} +19 -17
- package/dist/DisputesSection-DwkHGv2a.js +1 -0
- package/dist/Dropdown-B90Zabxr.mjs +111 -0
- package/dist/Dropdown-CtY91emj.js +1 -0
- package/dist/ErrorBanner-CZXsHi3H.mjs +22 -0
- package/dist/ErrorBanner-Cx2dUhps.js +1 -0
- package/dist/{FAQSection-Dn38OhB_.mjs → FAQSection-Bv_Hdt8B.mjs} +8 -6
- package/dist/FAQSection-DlPLnIJD.js +1 -0
- package/dist/ImagesSection-B4Jzet79.js +1 -0
- package/dist/{ImagesSection-Ctw9Icym.mjs → ImagesSection-DpdXQ6qu.mjs} +6 -4
- package/dist/InventorySection-BgRdpn1l.js +1 -0
- package/dist/{InventorySection-DmhjUlRZ.mjs → InventorySection-DZMu9DMw.mjs} +25 -23
- package/dist/MessagingSection-CxV-pf-f.js +1 -0
- package/dist/{MessagingSection-B1FaGxkp.mjs → MessagingSection-D_cOBfFt.mjs} +5 -4
- package/dist/OrdersSection-BbAX79Ff.js +1 -0
- package/dist/{OrdersSection-Bj8bPdg8.mjs → OrdersSection-wfPavit9.mjs} +27 -24
- package/dist/PaymentSettingsSection-BdBDgaRg.js +1 -0
- package/dist/PaymentSettingsSection-DunzBo9n.mjs +648 -0
- package/dist/ReturnsSection-7k4LZ8yp.js +1 -0
- package/dist/{ReturnsSection-BC0L8r2e.mjs → ReturnsSection-B4FL7bUv.mjs} +11 -9
- package/dist/{SettingsSection-vdYFSNxB.js → SettingsSection-Cz2Yjdhr.js} +1 -1
- package/dist/{SettingsSection-KYdEizq_.mjs → SettingsSection-DoeNDbqd.mjs} +1 -1
- package/dist/{ShippingSection-BOgto6_9.mjs → ShippingSection-BlVsYC6B.mjs} +5 -3
- package/dist/ShippingSection-C-HI8rOb.js +1 -0
- package/dist/{SingleCategorySettings-suJ8z9d8.mjs → SingleCategorySettings-B406nnF-.mjs} +143 -140
- package/dist/SingleCategorySettings-BqC2UXt3.js +3 -0
- package/dist/StatsBar-D4v-I_Dj.mjs +25 -0
- package/dist/StatsBar-m6GSRNxs.js +1 -0
- package/dist/StorefrontSection-Axvh_KeS.js +1 -0
- package/dist/{StorefrontSection-BRvIGBEJ.mjs → StorefrontSection-BK_rhrAi.mjs} +121 -119
- package/dist/{SubscriptionsSection-D60qrX9a.mjs → SubscriptionsSection-D8V9RBv-.mjs} +11 -9
- package/dist/SubscriptionsSection-EeULMWIB.js +1 -0
- package/dist/{TaxSection-C7-pv-Rl.mjs → TaxSection-Cj6TXL6x.mjs} +23 -21
- package/dist/TaxSection-CzHPhaHl.js +1 -0
- package/dist/ThemeContext-CFXyYx7A.js +1 -0
- package/dist/ThemeContext-l0bqcOGW.mjs +126 -0
- package/dist/Token22Section-DqRKVG_G.js +1 -0
- package/dist/{Token22Section-CrHLQ0EB.mjs → Token22Section-DtYAcT54.mjs} +7 -6
- package/dist/{WalletManager-BIwH8Dw_.mjs → WalletManager-D-eoqUDy.mjs} +21 -19
- package/dist/WalletManager-DXChB9LA.js +1 -0
- package/dist/WebhooksSection-D--iPZuM.js +1 -0
- package/dist/{WebhooksSection-COPW4Ec0.mjs → WebhooksSection-DBAIxtBy.mjs} +40 -38
- package/dist/admin.d.ts +2 -0
- package/dist/admin.js +1 -0
- package/dist/admin.mjs +8 -0
- package/dist/configApi-BS5UJfzm.js +1 -0
- package/dist/{configApi-6XhAJGKX.mjs → configApi-BUXZOMWK.mjs} +57 -3
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +214 -202
- package/dist/dateHelpers-BKW_lGND.js +1 -0
- package/dist/dateHelpers-yvPkofYQ.mjs +6 -0
- package/dist/fetchWithTimeout-CG0EKbhf.js +1 -0
- package/dist/fetchWithTimeout-DmMOwL0Q.mjs +195 -0
- package/dist/index-9QF_UfSN.mjs +18668 -0
- package/dist/index-Cq9ya93W.js +84 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +74 -64
- package/dist/safeHref-DqJPLPl5.mjs +12 -0
- package/dist/safeHref-DyHIpVjY.js +1 -0
- package/dist/sectionIds-B_tFiNvF.js +1 -0
- package/dist/sectionIds-DBavltrL.mjs +359 -0
- package/dist/sections-BHph7CYj.mjs +9 -0
- package/dist/sections-C2zEJr5G.js +1 -0
- package/dist/sections-more-C1VNVwkp.js +1 -0
- package/dist/sections-more-CMFgfU4d.mjs +3082 -0
- package/dist/src/admin/index.d.ts +3 -3
- package/dist/src/admin/index.d.ts.map +1 -1
- package/dist/src/admin/plugin.d.ts.map +1 -1
- package/dist/src/admin/types.d.ts +2 -6
- package/dist/src/admin/types.d.ts.map +1 -1
- package/dist/src/admin.d.ts +9 -0
- package/dist/src/admin.d.ts.map +1 -0
- package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts +4 -0
- package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts.map +1 -0
- package/dist/src/components/admin/PaymentReadinessChecklist.d.ts +9 -0
- package/dist/src/components/admin/PaymentReadinessChecklist.d.ts.map +1 -0
- package/dist/src/components/admin/PaymentSettingsSection.d.ts.map +1 -1
- package/dist/src/components/admin/PaymentSetupGuide.d.ts +6 -0
- package/dist/src/components/admin/PaymentSetupGuide.d.ts.map +1 -0
- package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/src/components/admin/configApi.d.ts +1 -1
- package/dist/src/components/admin/configApi.d.ts.map +1 -1
- package/dist/src/components/admin/icons.d.ts +3 -50
- package/dist/src/components/admin/icons.d.ts.map +1 -1
- package/dist/src/components/admin/index.d.ts +1 -1
- package/dist/src/components/admin/index.d.ts.map +1 -1
- package/dist/src/components/admin/types.d.ts +43 -0
- package/dist/src/components/admin/types.d.ts.map +1 -1
- package/dist/src/context/CedrosContext.d.ts +2 -0
- package/dist/src/context/CedrosContext.d.ts.map +1 -1
- package/dist/src/ecommerce/__tests__/featureFlags.test.d.ts +2 -0
- package/dist/src/ecommerce/__tests__/featureFlags.test.d.ts.map +1 -0
- package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/components/general/ErrorBoundary.d.ts +1 -1
- package/dist/src/ecommerce/components/ui/button.d.ts +1 -1
- package/dist/src/ecommerce/components/ui/sheet.d.ts +1 -1
- package/dist/src/ecommerce/config/context.d.ts +2 -0
- package/dist/src/ecommerce/config/context.d.ts.map +1 -1
- package/dist/src/ecommerce/config/types.d.ts +2 -0
- package/dist/src/ecommerce/config/types.d.ts.map +1 -1
- package/dist/src/ecommerce/index.d.ts +2 -0
- package/dist/src/ecommerce/index.d.ts.map +1 -1
- package/dist/src/featureFlags.d.ts +41 -0
- package/dist/src/featureFlags.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/managers/StripeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionManager.d.ts +1 -0
- package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +14 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/subscription.d.ts +47 -1
- package/dist/src/types/subscription.d.ts.map +1 -1
- package/dist/src/utils/validateConfig.d.ts.map +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +35 -33
- package/dist/styles--fxb3lCl.js +1 -0
- package/dist/{styles-D4SQkuV3.mjs → styles-DGagylUj.mjs} +53 -51
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/tokenMintValidator-DAjQld0r.mjs +98 -0
- package/dist/tokenMintValidator-DNBhoefh.js +4 -0
- package/dist/{walletPool-DE-t1wSW.mjs → walletPool-9MylB2QK.mjs} +1 -1
- package/dist/walletPool-BjTXX6Vn.js +1 -0
- package/package.json +6 -5
- package/dist/AutosaveIndicator-Dn_qA2hK.js +0 -1
- package/dist/CedrosContext-C2RjHLaQ.js +0 -6
- package/dist/CedrosContext-CY6zvjvJ.mjs +0 -2801
- package/dist/ChatLogsSection-BH5tLA4T.js +0 -1
- package/dist/ComplianceSection-DP2a9-S0.js +0 -1
- package/dist/CryptoButton-DpiCnyXE.js +0 -1
- package/dist/CustomersSection-CBwy_waO.js +0 -1
- package/dist/DisputesSection-BLjIk60n.js +0 -1
- package/dist/FAQSection-wNeH0i6Q.js +0 -1
- package/dist/ImagesSection-0ZzKlzMJ.js +0 -1
- package/dist/InventorySection-zV6lTmue.js +0 -1
- package/dist/MessagingSection-B_wdFR0j.js +0 -1
- package/dist/OrdersSection-Dw2FX-1d.js +0 -1
- package/dist/PaymentSettingsSection-BYF4D-GR.js +0 -1
- package/dist/PaymentSettingsSection-EnMxeWjv.mjs +0 -94
- package/dist/ReturnsSection-D_pJVxuG.js +0 -1
- package/dist/ShippingSection-1DRSTu49.js +0 -1
- package/dist/SingleCategorySettings-DwCnBdRf.js +0 -3
- package/dist/StorefrontSection-RumGkb3C.js +0 -1
- package/dist/SubscriptionsSection-C2aLLn7L.js +0 -1
- package/dist/TaxSection-Dt1DnM51.js +0 -1
- package/dist/Token22Section-DY3mUwTY.js +0 -1
- package/dist/WalletManager-B3UdQ5pQ.js +0 -1
- package/dist/WebhooksSection-CKeiJ7Py.js +0 -1
- package/dist/configApi-DkduMQg1.js +0 -1
- package/dist/index-C0g-JxJk.js +0 -84
- package/dist/index-DXnuQp5x.mjs +0 -22128
- package/dist/sections-C1NpK7hk.mjs +0 -9
- package/dist/sections-DVVSZBhW.js +0 -1
- package/dist/styles-BT4bhFey.js +0 -1
- package/dist/walletPool-IS7R3MR1.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),v=require("./sectionIds-B_tFiNvF.js"),G=require("./ErrorBanner-Cx2dUhps.js"),z=require("./Dropdown-CtY91emj.js"),B=require("./AutosaveIndicator-DiyeAg93.js"),w=[{id:"not_set",label:"Disabled",provider:null},{id:"gemini-2.5-flash",label:"Gemini 2.5 Flash",provider:"gemini"},{id:"gemini-2.5-pro",label:"Gemini 2.5 Pro",provider:"gemini"},{id:"openai-4o",label:"OpenAI 4o",provider:"openai"},{id:"openai-5.1",label:"OpenAI 5.1",provider:"openai"},{id:"openai-5.2",label:"OpenAI 5.2",provider:"openai"}],P=[{task:"site_chat",label:"Site Chat",description:"The conversational model that crafts responses to customer messages",defaultPrompt:`You are a friendly and helpful shopping assistant for our store. Your role is to:
|
|
2
2
|
|
|
3
3
|
- Help customers find products that match their needs
|
|
4
4
|
- Answer questions about products, shipping, returns, and store policies
|
|
@@ -48,4 +48,4 @@ Guidelines:
|
|
|
48
48
|
- Use sensory language when appropriate
|
|
49
49
|
- Keep descriptions scannable with short paragraphs
|
|
50
50
|
- Avoid superlatives and unverifiable claims
|
|
51
|
-
- Include relevant keywords naturally for SEO`}],q=[{id:"gemini",label:"Google Gemini API",placeholder:"AIza..."},{id:"openai",label:"OpenAI API",placeholder:"sk-..."}],N={apiKeys:[{provider:"gemini",isConfigured:!1},{provider:"openai",isConfigured:!1}],taskAssignments:P.map(o=>({task:o.task,label:o.label,description:o.description,assignedModel:"not_set",systemPrompt:o.defaultPrompt}))};function W({serverUrl:o,apiKey:d,authManager:c}){const[h,_]=a.useState("api-keys"),[f,y]=a.useState(N),[j,g]=a.useState(!0),[u,l]=a.useState(!1),[v,p]=a.useState(null),[C,x]=a.useState(!1),[E,$]=a.useState(null),m=a.useRef(null),[A,T]=a.useState({gemini:"",openai:""}),[S,R]=a.useState({gemini:!1,openai:!1}),I=a.useCallback(async()=>{try{let e;if(c?.isAuthenticated())e=await c.fetchWithAuth("/admin/config/ai");else{const i={"Content-Type":"application/json"};d&&(i["X-API-Key"]=d);const s=await fetch(`${o}/admin/config/ai`,{headers:i});if(!s.ok)throw new Error(`Failed to fetch: ${s.status}`);e=await s.json()}e.settings&&y(e.settings)}catch{y(N),$("Could not load saved AI settings. Showing defaults.")}finally{g(!1)}},[o,d,c]);a.useEffect(()=>{I()},[I]);const F=a.useCallback(async e=>{const i=A[e];if(i.trim()){l(!0),p(null);try{const s={provider:e,apiKey:i};if(c?.isAuthenticated())await c.fetchWithAuth("/admin/config/ai/api-key",{method:"PUT",body:JSON.stringify(s)});else{const n={"Content-Type":"application/json"};d&&(n["X-API-Key"]=d);const r=await fetch(`${o}/admin/config/ai/api-key`,{method:"PUT",headers:n,body:JSON.stringify(s)});if(!r.ok)throw new Error(`Failed to save: ${r.status}`)}y(n=>({...n,apiKeys:n.apiKeys.map(r=>r.provider===e?{...r,isConfigured:!0,maskedKey:`${i.slice(0,4)}...${i.slice(-4)}`,updatedAt:new Date().toISOString()}:r)})),T(n=>({...n,[e]:""})),x(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>x(!1),3e3)}catch(s){p(s instanceof Error?s.message:"Failed to save API key")}finally{l(!1)}}},[A,o,d,c]),O=a.useCallback(async e=>{if(confirm(`Are you sure you want to delete the ${e==="gemini"?"Google Gemini":"OpenAI"} API key?`)){l(!0),p(null);try{if(c?.isAuthenticated())await c.fetchWithAuth(`/admin/config/ai/api-key/${e}`,{method:"DELETE"});else{const i={"Content-Type":"application/json"};d&&(i["X-API-Key"]=d);const s=await fetch(`${o}/admin/config/ai/api-key/${e}`,{method:"DELETE",headers:i});if(!s.ok)throw new Error(`Failed to delete: ${s.status}`)}y(i=>({...i,apiKeys:i.apiKeys.map(s=>s.provider===e?{provider:e,isConfigured:!1}:s)}))}catch(i){p(i instanceof Error?i.message:"Failed to delete API key")}finally{l(!1)}}},[o,d,c]),D=a.useCallback(async(e,i)=>{l(!0),p(null);try{const s={task:e,model:i};if(c?.isAuthenticated())await c.fetchWithAuth("/admin/config/ai/assignment",{method:"PUT",body:JSON.stringify(s)});else{const n={"Content-Type":"application/json"};d&&(n["X-API-Key"]=d);const r=await fetch(`${o}/admin/config/ai/assignment`,{method:"PUT",headers:n,body:JSON.stringify(s)});if(!r.ok)throw new Error(`Failed to save: ${r.status}`)}y(n=>({...n,taskAssignments:n.taskAssignments.map(r=>r.task===e?{...r,assignedModel:i}:r)})),x(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>x(!1),3e3)}catch(s){p(s instanceof Error?s.message:"Failed to save assignment")}finally{l(!1)}},[o,d,c]),k=a.useCallback(e=>{if(e==="not_set")return!0;const i=w.find(n=>n.id===e);return i?.provider?f.apiKeys.find(n=>n.provider===i.provider)?.isConfigured??!1:!0},[f.apiKeys]),K=a.useMemo(()=>w.map(e=>{const i=k(e.id);return{value:e.id,label:i?e.label:`${e.label} (API key required)`,disabled:!i}}),[k]),G=a.useCallback(async(e,i)=>{l(!0),p(null);try{const s={task:e,systemPrompt:i};if(c?.isAuthenticated())await c.fetchWithAuth("/admin/config/ai/prompt",{method:"PUT",body:JSON.stringify(s)});else{const n={"Content-Type":"application/json"};d&&(n["X-API-Key"]=d);const r=await fetch(`${o}/admin/config/ai/prompt`,{method:"PUT",headers:n,body:JSON.stringify(s)});if(!r.ok)throw new Error(`Failed to save: ${r.status}`)}y(n=>({...n,taskAssignments:n.taskAssignments.map(r=>r.task===e?{...r,systemPrompt:i}:r)})),x(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>x(!1),3e3)}catch(s){p(s instanceof Error?s.message:"Failed to save prompt")}finally{l(!1)}},[o,d,c]);return a.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),j?t.jsx("div",{className:"cedros-admin__section",children:t.jsxs("div",{className:"cedros-admin__loading",children:[b.Icons.loading," Loading AI settings..."]})}):t.jsxs("div",{className:"cedros-admin__ai-settings",children:[t.jsxs("div",{className:"cedros-admin__page-header",children:[t.jsx("h2",{className:"cedros-admin__page-title",children:"Store AI"}),t.jsx("p",{className:"cedros-admin__page-description",children:"Configure AI providers, model assignments, and system prompts."})]}),t.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:[t.jsx("button",{type:"button",className:`cedros-admin__tab ${h==="api-keys"?"cedros-admin__tab--active":""}`,onClick:()=>_("api-keys"),children:"API Keys"}),t.jsx("button",{type:"button",className:`cedros-admin__tab ${h==="assignments"?"cedros-admin__tab--active":""}`,onClick:()=>_("assignments"),children:"Model Assignments"}),t.jsx("button",{type:"button",className:`cedros-admin__tab ${h==="prompts"?"cedros-admin__tab--active":""}`,onClick:()=>_("prompts"),children:"Prompts"})]}),v&&t.jsx("div",{className:"cedros-admin__error-banner",style:{marginTop:"1rem"},children:v}),t.jsx(b.ErrorBanner,{message:E,onRetry:I}),C&&t.jsxs("div",{className:"cedros-admin__success-banner",style:{marginTop:"1rem"},children:[b.Icons.check," Settings saved successfully"]}),h==="api-keys"&&t.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[t.jsx("div",{className:"cedros-admin__section-header",children:t.jsx("h3",{className:"cedros-admin__section-title",children:"API Keys"})}),t.jsx("p",{style:{marginBottom:"1.5rem",opacity:.7,fontSize:14},children:"Configure API keys for AI providers. Keys are stored securely and never exposed."}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:q.map(e=>{const i=f.apiKeys.find(n=>n.provider===e.id),s=i?.isConfigured??!1;return t.jsxs("div",{className:"cedros-admin__api-key-card",style:{padding:"1rem",border:"1px solid var(--cedros-admin-border)",borderRadius:8},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.75rem"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600},children:e.label}),s&&i?.maskedKey&&t.jsxs("div",{style:{fontSize:12,opacity:.6,marginTop:2},children:["Current key: ",i.maskedKey,i.updatedAt&&t.jsxs("span",{children:[" (updated ",new Date(i.updatedAt).toLocaleDateString(),")"]})]})]}),t.jsx("span",{className:`cedros-admin__badge ${s?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:s?"Configured":"Not Set"})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:t.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[t.jsx("input",{type:S[e.id]?"text":"password",className:"cedros-admin__input",placeholder:s?"Enter new key to replace":e.placeholder,value:A[e.id],onChange:n=>T(r=>({...r,[e.id]:n.target.value})),onBlur:()=>{A[e.id].trim()&&F(e.id)},style:{flex:1}}),t.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>R(n=>({...n,[e.id]:!n[e.id]})),title:S[e.id]?"Hide key":"Show key",style:{padding:"0.5rem"},children:S[e.id]?b.Icons.eyeOff:b.Icons.eye}),s&&t.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--danger",onClick:()=>O(e.id),disabled:u,title:"Remove API key",style:{padding:"0.5rem"},children:b.Icons.trash})]})})]},e.id)})})]}),h==="assignments"&&t.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[t.jsx("div",{className:"cedros-admin__section-header",children:t.jsx("h3",{className:"cedros-admin__section-title",children:"Model Assignments"})}),t.jsx("p",{style:{marginBottom:"1.5rem",opacity:.7,fontSize:14},children:"Assign AI models to specific tasks. Models require their provider's API key to be configured."}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:f.taskAssignments.map(e=>{const i=P.find(n=>n.task===e.task),s=w.find(n=>n.id===e.assignedModel);return t.jsxs("div",{style:{padding:"1rem",border:"1px solid var(--cedros-admin-border)",borderRadius:8},children:[t.jsxs("div",{style:{marginBottom:"0.75rem"},children:[t.jsx("div",{style:{fontWeight:600},children:i?.label??e.task}),t.jsx("div",{style:{fontSize:13,opacity:.7,marginTop:2},children:i?.description})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[t.jsx(b.FormDropdown,{value:e.assignedModel,onChange:n=>D(e.task,n),options:K,label:"",disabled:u,style:{flex:1,maxWidth:280}}),s&&s.provider&&t.jsx("span",{className:`cedros-admin__badge ${k(s.id)?"cedros-admin__badge--success":"cedros-admin__badge--warning"}`,children:k(s.id)?"Ready":"Missing API Key"})]})]},e.task)})})]}),h==="prompts"&&t.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[t.jsx("div",{className:"cedros-admin__section-header",children:t.jsx("h3",{className:"cedros-admin__section-title",children:"System Prompts"})}),t.jsx("p",{style:{marginBottom:"1.5rem",opacity:.7,fontSize:14},children:"Configure the default system prompts for each AI task. These prompts guide the AI's behavior and responses."}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:f.taskAssignments.map(e=>{const i=P.find(s=>s.task===e.task);return t.jsx(B,{task:e.task,label:i?.label??e.task,description:i?.description??"",initialPrompt:e.systemPrompt??"",onSave:G},e.task)})})]})]})}function B({task:o,label:d,description:c,initialPrompt:h,onSave:_}){const[f,y]=a.useState(h),[j,g]=a.useState("idle"),u=a.useRef(null),l=a.useRef(null),v=a.useRef(!0);return a.useEffect(()=>{if(v.current){v.current=!1;return}return u.current&&clearTimeout(u.current),l.current&&clearTimeout(l.current),g("pending"),u.current=setTimeout(async()=>{g("saving");try{await _(o,f),g("saved"),l.current=setTimeout(()=>g("idle"),2e3)}catch{g("error")}},1500),()=>{u.current&&clearTimeout(u.current)}},[f,o,_]),a.useEffect(()=>()=>{u.current&&clearTimeout(u.current),l.current&&clearTimeout(l.current)},[]),t.jsxs("div",{style:{padding:"1rem",border:"1px solid var(--cedros-admin-border)",borderRadius:8},children:[t.jsxs("div",{style:{marginBottom:"0.75rem",display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600},children:d}),t.jsx("div",{style:{fontSize:13,opacity:.7,marginTop:2},children:c})]}),t.jsx(z.AutosaveIndicator,{status:j})]}),t.jsx("textarea",{className:"cedros-admin__input",value:f,onChange:p=>y(p.target.value),placeholder:"Enter system prompt...",rows:4,style:{width:"100%",resize:"vertical",fontFamily:"inherit",minHeight:100}})]})}exports.AISettingsSection=W;
|
|
51
|
+
- Include relevant keywords naturally for SEO`}],W=[{id:"gemini",label:"Google Gemini API",placeholder:"AIza..."},{id:"openai",label:"OpenAI API",placeholder:"sk-..."}],N={apiKeys:[{provider:"gemini",isConfigured:!1},{provider:"openai",isConfigured:!1}],taskAssignments:P.map(o=>({task:o.task,label:o.label,description:o.description,assignedModel:"not_set",systemPrompt:o.defaultPrompt}))};function L({serverUrl:o,apiKey:c,authManager:d}){const[h,b]=a.useState("api-keys"),[f,y]=a.useState(N),[j,g]=a.useState(!0),[u,l]=a.useState(!1),[x,p]=a.useState(null),[C,_]=a.useState(!1),[E,$]=a.useState(null),m=a.useRef(null),[A,T]=a.useState({gemini:"",openai:""}),[S,R]=a.useState({gemini:!1,openai:!1}),I=a.useCallback(async()=>{try{let e;if(d?.isAuthenticated())e=await d.fetchWithAuth("/admin/config/ai");else{const i={"Content-Type":"application/json"};c&&(i["X-API-Key"]=c);const s=await fetch(`${o}/admin/config/ai`,{headers:i});if(!s.ok)throw new Error(`Failed to fetch: ${s.status}`);e=await s.json()}e.settings&&y(e.settings)}catch{y(N),$("Could not load saved AI settings. Showing defaults.")}finally{g(!1)}},[o,c,d]);a.useEffect(()=>{I()},[I]);const D=a.useCallback(async e=>{const i=A[e];if(i.trim()){l(!0),p(null);try{const s={provider:e,apiKey:i};if(d?.isAuthenticated())await d.fetchWithAuth("/admin/config/ai/api-key",{method:"PUT",body:JSON.stringify(s)});else{const n={"Content-Type":"application/json"};c&&(n["X-API-Key"]=c);const r=await fetch(`${o}/admin/config/ai/api-key`,{method:"PUT",headers:n,body:JSON.stringify(s)});if(!r.ok)throw new Error(`Failed to save: ${r.status}`)}y(n=>({...n,apiKeys:n.apiKeys.map(r=>r.provider===e?{...r,isConfigured:!0,maskedKey:`${i.slice(0,4)}...${i.slice(-4)}`,updatedAt:new Date().toISOString()}:r)})),T(n=>({...n,[e]:""})),_(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>_(!1),3e3)}catch(s){p(s instanceof Error?s.message:"Failed to save API key")}finally{l(!1)}}},[A,o,c,d]),F=a.useCallback(async e=>{if(confirm(`Are you sure you want to delete the ${e==="gemini"?"Google Gemini":"OpenAI"} API key?`)){l(!0),p(null);try{if(d?.isAuthenticated())await d.fetchWithAuth(`/admin/config/ai/api-key/${e}`,{method:"DELETE"});else{const i={"Content-Type":"application/json"};c&&(i["X-API-Key"]=c);const s=await fetch(`${o}/admin/config/ai/api-key/${e}`,{method:"DELETE",headers:i});if(!s.ok)throw new Error(`Failed to delete: ${s.status}`)}y(i=>({...i,apiKeys:i.apiKeys.map(s=>s.provider===e?{provider:e,isConfigured:!1}:s)}))}catch(i){p(i instanceof Error?i.message:"Failed to delete API key")}finally{l(!1)}}},[o,c,d]),O=a.useCallback(async(e,i)=>{l(!0),p(null);try{const s={task:e,model:i};if(d?.isAuthenticated())await d.fetchWithAuth("/admin/config/ai/assignment",{method:"PUT",body:JSON.stringify(s)});else{const n={"Content-Type":"application/json"};c&&(n["X-API-Key"]=c);const r=await fetch(`${o}/admin/config/ai/assignment`,{method:"PUT",headers:n,body:JSON.stringify(s)});if(!r.ok)throw new Error(`Failed to save: ${r.status}`)}y(n=>({...n,taskAssignments:n.taskAssignments.map(r=>r.task===e?{...r,assignedModel:i}:r)})),_(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>_(!1),3e3)}catch(s){p(s instanceof Error?s.message:"Failed to save assignment")}finally{l(!1)}},[o,c,d]),k=a.useCallback(e=>{if(e==="not_set")return!0;const i=w.find(n=>n.id===e);return i?.provider?f.apiKeys.find(n=>n.provider===i.provider)?.isConfigured??!1:!0},[f.apiKeys]),K=a.useMemo(()=>w.map(e=>{const i=k(e.id);return{value:e.id,label:i?e.label:`${e.label} (API key required)`,disabled:!i}}),[k]),q=a.useCallback(async(e,i)=>{l(!0),p(null);try{const s={task:e,systemPrompt:i};if(d?.isAuthenticated())await d.fetchWithAuth("/admin/config/ai/prompt",{method:"PUT",body:JSON.stringify(s)});else{const n={"Content-Type":"application/json"};c&&(n["X-API-Key"]=c);const r=await fetch(`${o}/admin/config/ai/prompt`,{method:"PUT",headers:n,body:JSON.stringify(s)});if(!r.ok)throw new Error(`Failed to save: ${r.status}`)}y(n=>({...n,taskAssignments:n.taskAssignments.map(r=>r.task===e?{...r,systemPrompt:i}:r)})),_(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>_(!1),3e3)}catch(s){p(s instanceof Error?s.message:"Failed to save prompt")}finally{l(!1)}},[o,c,d]);return a.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),j?t.jsx("div",{className:"cedros-admin__section",children:t.jsxs("div",{className:"cedros-admin__loading",children:[v.Icons.loading," Loading AI settings..."]})}):t.jsxs("div",{className:"cedros-admin__ai-settings",children:[t.jsxs("div",{className:"cedros-admin__page-header",children:[t.jsx("h2",{className:"cedros-admin__page-title",children:"Store AI"}),t.jsx("p",{className:"cedros-admin__page-description",children:"Configure AI providers, model assignments, and system prompts."})]}),t.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:[t.jsx("button",{type:"button",className:`cedros-admin__tab ${h==="api-keys"?"cedros-admin__tab--active":""}`,onClick:()=>b("api-keys"),children:"API Keys"}),t.jsx("button",{type:"button",className:`cedros-admin__tab ${h==="assignments"?"cedros-admin__tab--active":""}`,onClick:()=>b("assignments"),children:"Model Assignments"}),t.jsx("button",{type:"button",className:`cedros-admin__tab ${h==="prompts"?"cedros-admin__tab--active":""}`,onClick:()=>b("prompts"),children:"Prompts"})]}),x&&t.jsx("div",{className:"cedros-admin__error-banner",style:{marginTop:"1rem"},children:x}),t.jsx(G.ErrorBanner,{message:E,onRetry:I}),C&&t.jsxs("div",{className:"cedros-admin__success-banner",style:{marginTop:"1rem"},children:[v.Icons.check," Settings saved successfully"]}),h==="api-keys"&&t.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[t.jsx("div",{className:"cedros-admin__section-header",children:t.jsx("h3",{className:"cedros-admin__section-title",children:"API Keys"})}),t.jsx("p",{style:{marginBottom:"1.5rem",opacity:.7,fontSize:14},children:"Configure API keys for AI providers. Keys are stored securely and never exposed."}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:W.map(e=>{const i=f.apiKeys.find(n=>n.provider===e.id),s=i?.isConfigured??!1;return t.jsxs("div",{className:"cedros-admin__api-key-card",style:{padding:"1rem",border:"1px solid var(--cedros-admin-border)",borderRadius:8},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.75rem"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600},children:e.label}),s&&i?.maskedKey&&t.jsxs("div",{style:{fontSize:12,opacity:.6,marginTop:2},children:["Current key: ",i.maskedKey,i.updatedAt&&t.jsxs("span",{children:[" (updated ",new Date(i.updatedAt).toLocaleDateString(),")"]})]})]}),t.jsx("span",{className:`cedros-admin__badge ${s?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:s?"Configured":"Not Set"})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:t.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[t.jsx("input",{type:S[e.id]?"text":"password",className:"cedros-admin__input",placeholder:s?"Enter new key to replace":e.placeholder,value:A[e.id],onChange:n=>T(r=>({...r,[e.id]:n.target.value})),onBlur:()=>{A[e.id].trim()&&D(e.id)},style:{flex:1}}),t.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>R(n=>({...n,[e.id]:!n[e.id]})),title:S[e.id]?"Hide key":"Show key",style:{padding:"0.5rem"},children:S[e.id]?v.Icons.eyeOff:v.Icons.eye}),s&&t.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--danger",onClick:()=>F(e.id),disabled:u,title:"Remove API key",style:{padding:"0.5rem"},children:v.Icons.trash})]})})]},e.id)})})]}),h==="assignments"&&t.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[t.jsx("div",{className:"cedros-admin__section-header",children:t.jsx("h3",{className:"cedros-admin__section-title",children:"Model Assignments"})}),t.jsx("p",{style:{marginBottom:"1.5rem",opacity:.7,fontSize:14},children:"Assign AI models to specific tasks. Models require their provider's API key to be configured."}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:f.taskAssignments.map(e=>{const i=P.find(n=>n.task===e.task),s=w.find(n=>n.id===e.assignedModel);return t.jsxs("div",{style:{padding:"1rem",border:"1px solid var(--cedros-admin-border)",borderRadius:8},children:[t.jsxs("div",{style:{marginBottom:"0.75rem"},children:[t.jsx("div",{style:{fontWeight:600},children:i?.label??e.task}),t.jsx("div",{style:{fontSize:13,opacity:.7,marginTop:2},children:i?.description})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[t.jsx(z.FormDropdown,{value:e.assignedModel,onChange:n=>O(e.task,n),options:K,label:"",disabled:u,style:{flex:1,maxWidth:280}}),s&&s.provider&&t.jsx("span",{className:`cedros-admin__badge ${k(s.id)?"cedros-admin__badge--success":"cedros-admin__badge--warning"}`,children:k(s.id)?"Ready":"Missing API Key"})]})]},e.task)})})]}),h==="prompts"&&t.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[t.jsx("div",{className:"cedros-admin__section-header",children:t.jsx("h3",{className:"cedros-admin__section-title",children:"System Prompts"})}),t.jsx("p",{style:{marginBottom:"1.5rem",opacity:.7,fontSize:14},children:"Configure the default system prompts for each AI task. These prompts guide the AI's behavior and responses."}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:f.taskAssignments.map(e=>{const i=P.find(s=>s.task===e.task);return t.jsx(J,{task:e.task,label:i?.label??e.task,description:i?.description??"",initialPrompt:e.systemPrompt??"",onSave:q},e.task)})})]})]})}function J({task:o,label:c,description:d,initialPrompt:h,onSave:b}){const[f,y]=a.useState(h),[j,g]=a.useState("idle"),u=a.useRef(null),l=a.useRef(null),x=a.useRef(!0);return a.useEffect(()=>{if(x.current){x.current=!1;return}return u.current&&clearTimeout(u.current),l.current&&clearTimeout(l.current),g("pending"),u.current=setTimeout(async()=>{g("saving");try{await b(o,f),g("saved"),l.current=setTimeout(()=>g("idle"),2e3)}catch{g("error")}},1500),()=>{u.current&&clearTimeout(u.current)}},[f,o,b]),a.useEffect(()=>()=>{u.current&&clearTimeout(u.current),l.current&&clearTimeout(l.current)},[]),t.jsxs("div",{style:{padding:"1rem",border:"1px solid var(--cedros-admin-border)",borderRadius:8},children:[t.jsxs("div",{style:{marginBottom:"0.75rem",display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600},children:c}),t.jsx("div",{style:{fontSize:13,opacity:.7,marginTop:2},children:d})]}),t.jsx(B.AutosaveIndicator,{status:j})]}),t.jsx("textarea",{className:"cedros-admin__input",value:f,onChange:p=>y(p.target.value),placeholder:"Enter system prompt...",rows:4,style:{width:"100%",resize:"vertical",fontFamily:"inherit",minHeight:100}})]})}exports.AISettingsSection=L;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
2
2
|
import { useState as u, useRef as S, useCallback as A, useEffect as T, useMemo as q } from "react";
|
|
3
|
-
import { I as w
|
|
4
|
-
import {
|
|
3
|
+
import { I as w } from "./sectionIds-DBavltrL.mjs";
|
|
4
|
+
import { E as J } from "./ErrorBanner-CZXsHi3H.mjs";
|
|
5
|
+
import { F as Y } from "./Dropdown-B90Zabxr.mjs";
|
|
6
|
+
import { A as X } from "./AutosaveIndicator-BEvABoKU.mjs";
|
|
5
7
|
const C = [
|
|
6
8
|
{ id: "not_set", label: "Disabled", provider: null },
|
|
7
9
|
{ id: "gemini-2.5-flash", label: "Gemini 2.5 Flash", provider: "gemini" },
|
|
@@ -100,7 +102,7 @@ Guidelines:
|
|
|
100
102
|
systemPrompt: o.defaultPrompt
|
|
101
103
|
}))
|
|
102
104
|
};
|
|
103
|
-
function
|
|
105
|
+
function se({ serverUrl: o, apiKey: d, authManager: c }) {
|
|
104
106
|
const [y, _] = u("api-keys"), [h, g] = u(D), [N, b] = u(!0), [p, l] = u(!1), [k, f] = u(null), [O, v] = u(!1), [K, R] = u(null), m = S(null), [I, F] = u({
|
|
105
107
|
gemini: "",
|
|
106
108
|
openai: ""
|
|
@@ -535,5 +537,5 @@ function M({
|
|
|
535
537
|
);
|
|
536
538
|
}
|
|
537
539
|
export {
|
|
538
|
-
|
|
540
|
+
se as AISettingsSection
|
|
539
541
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as n, jsx as r, Fragment as i } from "react/jsx-runtime";
|
|
2
|
-
import { I as d } from "./
|
|
2
|
+
import { I as d } from "./sectionIds-DBavltrL.mjs";
|
|
3
3
|
function l({ status: e, error: a }) {
|
|
4
4
|
return e === "idle" ? null : /* @__PURE__ */ n(
|
|
5
5
|
"span",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),i=require("./sectionIds-B_tFiNvF.js");function s({status:n,error:r}){return n==="idle"?null:e.jsxs("span",{className:`cedros-admin__autosave-indicator cedros-admin__autosave-indicator--${n}`,style:{display:"inline-flex",alignItems:"center",gap:"0.375rem",fontSize:"0.8125rem",color:n==="error"?"var(--cedros-admin-error, #ef4444)":"var(--cedros-admin-text-muted, #64748b)"},children:[n==="pending"&&e.jsx("span",{style:{opacity:.7},children:"Unsaved changes"}),n==="saving"&&e.jsxs(e.Fragment,{children:[i.Icons.loading,e.jsx("span",{children:"Saving..."})]}),n==="saved"&&e.jsxs(e.Fragment,{children:[i.Icons.check,e.jsx("span",{style:{color:"var(--cedros-admin-success, #22c55e)"},children:"Saved"})]}),n==="error"&&e.jsxs("span",{children:["Save failed",r?`: ${r}`:""]})]})}exports.AutosaveIndicator=s;
|