PageSourceSearch

https://psychicguide.net/assets/AdminSettingsPage-CMZgdlYq.js

js psychicguide.net collected 2026-10-09 22:04:13 UTC 43,755 bytes, 6 lines download raw bytes

1import{c as ss,r as n,s as d,j as e,ac as as,f as ie,e as he,y as ts,B as k,a3 as Ce,bh as Ae,q as Ve,E as ls,bi as rs,aY as is,aW as ns,Y as B,I as E,P as cs,Q as os,R as ds,V as ms,ad as xs,ae as hs}from"./index-CdlRzbIO.js";import{C as h,a as g,b as v,c as y,d as F}from"./card-CM0Okv3Z.js";import{S as K}from"./switch-Bzjhjo9H.js";import{S as gs}from"./slider-CnkNojiL.js";import{S as C}from"./skeleton-CbzUyPBA.js";import{T as ps,a as us,b as _,c as T}from"./tabs-ANpfY9ht.js";import{C as ge}from"./chart-column-CKvdJsV9.js";import{D as Ie}from"./dollar-sign-xwhVXAmk.js";import{C as fs}from"./clock-BiLWpC_J.js";import{T as Z}from"./trending-up-CE5PUVoR.js";import{g as js,X as Le,Y as qe,f as Ns,R as _e,T as Te,P as bs,a as vs,C as ys}from"./PieChart-BTL7GaWG.js";import{L as $e}from"./Line-DeGTWCS7.js";import{C as ws}from"./CartesianGrid-CyzXjPF_.js";import{B as X}from"./bot-BNuaM9UM.js";import{T as ks}from"./thumbs-up-DrYqcw_i.js";import{f as J}from"./format-BJqsy1zW.js";import{s as Ss}from"./subDays-BRRH4jgv.js";import{T as Fe}from"./textarea-DQY33lpu.js";import{S as ne,a as ce,b as oe,c as de,d as Y}from"./select-Bn2PV-d6.js";import{S as De}from"./settings-74FzlYmx.js";import{R as Cs}from"./refresh-cw-DjQSYiT5.js";import{K as me}from"./key--UTC3VBT.js";import{C as xe}from"./credit-card-D4Ih1Zrr.js";import{C as We}from"./circle-x-JKaxBhH9.js";import{E as As}from"./eye-off-BgYtMpup.js";import{T as Q}from"./triangle-alert-B9XdSvlM.js";import{U as Is}from"./upload-CgwQGz6J.js";import{I as _s}from"./image-D8pgJAAe.js";import{S as Me}from"./save-bByY1Wzf.js";import{R as Pe}from"./rotate-ccw-CnjUfv25.js";import{G as Ts}from"./globe-CmZyV5dg.js";import{L as Fs}from"./lock-kPxdpFhd.js";import"./index-ClrCEPLH.js";import"./index-BdQq_4o_.js";import"./en-US-BEuxq60D.js";import"./addDays-Bjltv7Hz.js";import"./chevron-down-CJ0_mUBc.js";import"./chevron-up-QfggDjgX.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Ds=ss("SlidersVertical",[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]]);var Ms=js({chartName:"LineChart",GraphicalChild:$e,axisComponents:[{axisType:"xAxis",AxisComp:Le},{axisType:"yAxis",AxisComp:qe}],formatAxisMap:Ns});const H=["#8b5cf6","#06b6d4","#10b981","#f59e0b","#ef4444","#ec4899"],Ps=()=>{const[p,D]=n.useState(!0),[f,R]=n.useState({totalRequests:0,successfulRequests:0,totalTokens:0,totalCost:0,avgResponseTime:0}),[w,U]=n.useState([]),[V,A]=n.useState([]),[j,ee]=n.useState({totalFeedback:0,avgRating:0,helpful:0,accurate:0,wouldRecommend:0});n.useEffect(()=>{z()},[]);const z=async()=>{D(!0);try{const{data:l,error:m}=await d.from("ai_usage_logs").select("*").order("created_at",{ascending:!1});if(m)throw m;if(l&&l.length>0){const L=l.filter(i=>i.success),q=l.reduce((i,c)=>i+(c.total_tokens||0),0),$=l.reduce((i,c)=>i+(parseFloat(String(c.estimated_cost))||0),0),W=l.reduce((i,c)=>i+(c.response_time_ms||0),0)/l.length;R({totalRequests:l.length,successfulRequests:L.length,totalTokens:q,totalCost:$,avgResponseTime:W});const u=new Map;l.forEach(i=>{const c=u.get(i.model)||{model:i.model,count:0,tokens:0,cost:0};c.count++,c.tokens+=i.total_tokens||0,c.cost+=parseFloat(String(i.estimated_cost))||0,u.set(i.model,c)}),U(Array.from(u.values()));const b=new Map;for(let i=13;i>=0;i--){const c=J(Ss(new Date,i),"yyyy-MM-dd");b.set(c,{date:c,requests:0,tokens:0,cost:0})}l.forEach(i=>{const c=J(new Date(i.created_at),"yyyy-MM-dd");if(b.has(c)){const P=b.get(c);P.requests++,P.tokens+=i.total_tokens||0,P.cost+=parseFloat(String(i.estimated_cost))||0}}
6),A(Array.from(b.values()))}const{data:x,error:se}=await d.from("ai_feedback").select("*");if(!se&&x&&x.length>0){const L=x.reduce((u,b)=>u+b.rating,0)/x.length,q=x.filter(u=>u.helpful).length,$=x.filter(u=>u.accurate).length,W=x.filter(u=>u.would_recommend).length;ee({totalFeedback:x.length,avgRating:L,helpful:q,accurate:$,wouldRecommend:W})}}catch(l){console.error("Error fetching AI analytics:",l)}finally{D(!1)}},M=l=>{var m;return((m=l.split("/").pop())==null?void 0:m.replace(/-/g," ").replace(/\b\w/g,x=>x.toUpperCase()))||l};return p?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid gap-4 grid-cols-2 lg:grid-cols-4",children:[1,2,3,4].map(l=>e.jsx(h,{className:"border-0 shadow-sm",children:e.jsxs(g,{className:"p-4",children:[e.jsx(C,{className:"h-4 w-20 mb-2"}),e.jsx(C,{className:"h-8 w-24"})]})},l))}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(C,{className:"h-80"}),e.jsx(C,{className:"h-80"})]})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 grid-cols-2 lg:grid-cols-4",children:[e.jsx(h,{className:"border-0 shadow-sm bg-gradient-to-br from-violet-50 to-purple-50",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 rounded-xl bg-violet-100",children:e.jsx(as,{className:"h-5 w-5 text-violet-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-violet-600 font-medium",children:"Total Requests"}),e.jsx("p",{className:"text-2xl font-bold text-violet-900",children:f.totalRequests}),e.jsxs("p",{className:"text-xs text-violet-500",children:[f.successfulRequests," successful (",Math.round(f.successfulRequests/Math.max(f.totalRequests,1)*100),"%)"]})]})]})})}),e.jsx(h,{className:"border-0 shadow-sm bg-gradient-to-br from-emerald-50 to-green-50",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 rounded-xl bg-emerald-100",children:e.jsx(ge,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-emerald-600 font-medium",children:"Total Tokens"}),e.jsxs("p",{className:"text-2xl font-bold text-emerald-900",children:[(f.totalTokens/1e3).toFixed(1),"K"]}),e.jsx("p",{className:"text-xs text-emerald-500",children:"tokens used"})]})]})})}),e.jsx(h,{className:"border-0 shadow-sm bg-gradient-to-br from-amber-50 to-yellow-50",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 rounded-xl bg-amber-100",children:e.jsx(Ie,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-amber-600 font-medium",children:"Estimated Cost"}),e.jsxs("p",{className:"text-2xl font-bold text-amber-900",children:["$",f.totalCost.toFixed(2)]}),e.jsx("p",{className:"text-xs text-amber-500",children:"total spending"})]})]})})}),e.jsx(h,{className:"border-0 shadow-sm bg-gradient-to-br from-cyan-50 to-blue-50",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 rounded-xl bg-cyan-100",children:e.jsx(fs,{className:"h-5 w-5 text-cyan-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-cyan-600 font-medium",children:"Avg Response"}),e.jsxs("p",{className:"text-2xl font-bold text-cyan-900",children:[(f.avgResponseTime/1e3).toFixed(1),"s"]}),e.jsx("p",{className:"text-xs text-cyan-500",children:"response time"})]})]})})})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(h,{className:"border-0 shadow-sm",children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Z,{className:"h-4 w-4 text-violet-600"}),"Daily Usage (Last 14 Days)"]})}),e.jsx(g,{children:e.jsx("div",{className:"h-64",children:e.jsx(_e,{width:"100%",height:"100%",children:e.jsxs(Ms,{data:V,children:[e.jsx(ws,{strokeDasharray:"3 3",stroke:"#f0f0f0"}),e.jsx(Le,{dataKey:"date",tickFormatter:l=>J(new Date(l),"MM/dd"),fontSize:10}),e.jsx(qe,{fontSize:10}),e.jsx(Te,{labelFormatter:l=>J(new Date(l),"MMM d, yyyy"),formatter:(l,m)=>[m==="cost"?`$${l.toFixed(4)}`:l,m.charAt(0).toUpperCase()+m.slice(1)]}),e.jsx($e,{type:"monotone",dataKey:"requests",stroke:"#8b5cf6",strokeWidth:2,dot:{fill:"#8b5cf6",strokeWidth:0,r:3}})]})})})})]}),e.jsxs(h,{className:"border-0 shadow-sm",children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(X,{className:"h-4 w-4 text-violet-600"}),"Model Usage Distribution"]})}),e.jsx(g,{children:e.jsx("div",{className:"h-64",children:w.length>0?e.jsx(_e,{width:"100%",height:"100%",children:e.jsxs(bs,{children:[e.jsx(vs,{data:w,cx:"50%",cy:"50%",innerRadius:60,outerRadius:80,paddingAngle:5,dataKey:"count",nameKey:"model",label:({model:l,count:m})=>`${M(l)}: ${m}`,labelLine:!1,children:w.map((l,m)=>e.jsx(ys,{fill:H[m%H.length]},`cell-${m}`))}),e.jsx(Te,{formatter:(l,m,x)=>[`${l} requests ($${x.payload.cost.toFixed(4)})`,M(x.payload.model)]})]})}):e.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"No usage data yet"})})})]})]}),e.jsxs(h,{className:"border-0 shadow-sm",children:[e.jsxs(v,{className:"pb-2",children:[e.jsxs(y,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ie,{className:"h-4 w-4 text-amber-500"}),"Customer Feedback Summary"]}),e.jsxs(F,{children:["Based on ",j.totalFeedback," customer reviews"]})]}),e.jsx(g,{children:j.totalFeedback>0?e.jsxs("div",{className:"grid gap-4 grid-cols-2 lg:grid-cols-4",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-gradient-to-br from-amber-50 to-yellow-50 text-center",children:[e.jsx("div",{className:"flex items-center justify-center gap-1 mb-2",children:[1,2,3,4,5].map(l=>e.jsx(ie,{className:`h-4 w-4 ${l<=Math.round(j.avgRating)?"text-amber-400 fill-amber-400":"text-gray-300"}`},l))}),e.jsx("p",{className:"text-2xl font-bold text-amber-900",children:j.avgRating.toFixed(1)}),e.jsx("p",{className:"text-xs text-amber-600",children:"Average Rating"})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-gradient-to-br from-green-50 to-emerald-50 text-center",children:[e.jsx(ks,{className:"h-6 w-6 text-emerald-600 mx-auto mb-2"}),e.jsxs("p",{className:"text-2xl font-bold text-emerald-900",children:[Math.round(j.helpful/j.totalFeedback*100),"%"]}),e.jsx("p",{className:"text-xs text-emerald-600",children:"Found Helpful"})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-gradient-to-br from-blue-50 to-cyan-50 text-center",children:[e.jsx(ge,{className:"h-6 w-6 text-blue-600 mx-auto mb-2"}),e.jsxs("p",{className:"text-2xl font-bold text-blue-900",children:[Math.round(j.accurate/j.totalFeedback*100),"%"]}),e.jsx("p",{className:"text-xs text-blue-600",children:"Found Accurate"})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-gradient-to-br from-violet-50 to-purple-50 text-center",children:[e.jsx(Z,{className:"h-6 w-6 text-violet-600 mx-auto mb-2"}),e.jsxs("p",{className:"text-2xl font-bold text-violet-900",children:[Math.round(j.wouldRecommend/j.totalFeedback*100),"%"]}),e.jsx("p",{className:"text-xs text-violet-600",children:"Would Recommend"})]})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ie,{className:"h-12 w-12 mx-auto mb-3 text-gray-300"}),e.jsx("p",{children:"No customer feedback yet"}),e.jsx("p",{className:"text-sm",children:"Feedback will appear here once customers rate their AI readings"})]})})]}),w.length>0&&e.jsxs(h,{className:"border-0 shadow-sm",children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Ie,{className:"h-4 w-4 text-amber-600"}),"Cost Breakdown by Model"]})}),e.jsx(g,{children:e.jsx("div",{className:"space-y-3",children:w.map((l,m)=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:H[m%H.length]}}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium text-sm",children:M(l.model)}
6),e.jsxs(he,{variant:"secondary",className:"text-xs",children:[l.count," requests"]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground mt-1",children:[e.jsxs("span",{children:[(l.tokens/1e3).toFixed(1),"K tokens"]}),e.jsxs("span",{className:"font-semibold text-amber-600",children:["$",l.cost.toFixed(4)]})]})]})]},l.model))})})]})]})},Ee=[{value:"gemini-2.0-flash",label:"Gemini 2.0 Flash",description:"En hızlı model - günlük kullanım için ideal"},{value:"gemini-1.5-flash",label:"Gemini 1.5 Flash",description:"Dengeli seçim - hız ve kalite"},{value:"gemini-1.5-pro",label:"Gemini 1.5 Pro",description:"En güçlü model - karmaşık okumalar için"}],Re={bookings:3,reviews:2.5,rating:2,clicks:1,recency:.5},Ue={positivePrompt:"Provide detailed, personalized insights. Use warm and compassionate language. Include specific guidance and actionable advice. Structure the reading with clear sections.",negativePrompt:"Avoid generic responses. Do not make specific predictions about health, legal, or financial matters. Avoid negative or fear-based language."},Es="gemini-2.0-flash",G=({title:p,value:D,subtitle:f,icon:R,iconBg:w,iconColor:U,loading:V,status:A})=>V?e.jsx(h,{className:"border-0 shadow-sm bg-white",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(C,{className:"h-10 w-10 rounded-xl shrink-0"}),e.jsxs("div",{className:"space-y-1.5 flex-1",children:[e.jsx(C,{className:"h-3 w-20"}),e.jsx(C,{className:"h-6 w-24"})]})]})})}):e.jsx(h,{className:"border-0 shadow-sm bg-white hover:shadow-md transition-shadow",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2.5 rounded-xl ${w} shrink-0`,children:e.jsx(R,{className:`h-5 w-5 ${U}`})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs text-gray-500 font-medium",children:p}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"text-xl font-bold text-gray-900",children:D}),A==="success"&&e.jsx(Ve,{className:"h-4 w-4 text-emerald-500"}),A==="warning"&&e.jsx(Q,{className:"h-4 w-4 text-amber-500"}),A==="error"&&e.jsx(We,{className:"h-4 w-4 text-red-500"})]}),f&&e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:f})]})]})})}),ba=()=>{var ve,ye,we,ke;const{toast:p}=ts(),[D,f]=n.useState(!1),[R,w]=n.useState(!1),[U,V]=n.useState(!1),[A,j]=n.useState(!1),[ee,z]=n.useState(!0),[M,l]=n.useState(Re),[m,x]=n.useState(Ue),[se,L]=n.useState(Es),[q,$]=n.useState("psychic-guide"),[W,u]=n.useState(!1),[b,i]=n.useState(""),[c,P]=n.useState(""),[ae,pe]=n.useState(!1),[te,ue]=n.useState(!1),[S,fe]=n.useState([{name:"Gemini API Key",key:"gemini",envName:"GEMINI_API_KEY",description:"Used for AI reading generation",isConfigured:!1,isVisible:!1,maskedValue:""},{name:"Stripe Secret Key",key:"stripe_secret",envName:"STRIPE_SECRET_KEY",description:"Used for payment processing",isConfigured:!1,isVisible:!1,maskedValue:""},{name:"Stripe Publishable Key",key:"stripe_publishable",envName:"STRIPE_PUBLISHABLE_KEY",description:"Client-side Stripe integration",isConfigured:!1,isVisible:!1,maskedValue:""}]),[N,O]=n.useState({open:!1,keyIndex:-1,newValue:""});n.useEffect(()=>{re(),Ne(),ze(),Je(),Be()},[]);const Be=async()=>{try{const{data:s,error:t}=await d.from("platform_settings").select("key, value").in("key",["default_theme","favicon_url","logo_url"]);s&&s.forEach(a=>{const r=a.value;a.key==="default_theme"&&(r!=null&&r.theme&&$(r.theme),typeof(r==null?void 0:r.darkMode)=="boolean"&&u(r.darkMode)),a.key==="favicon_url"&&(r!=null&&r.url)&&i(r.url),a.key==="logo_url"&&(r!=null&&r.url)&&P(r.url)})}catch(s){console.error("Error loading appearance settings:",s)}},Oe=async()=>{j(!0);try{await le("default_theme",{theme:q,darkMode:W},"Default theme for visitors"),b&&await le("favicon_url",{url:b},"Custom favicon URL"),c&&await le("logo_url",{url:c},"Custom logo URL"),p({title:"Appearance Saved",description:"Theme and branding settings have been updated."})}catch(s){p({title:"Save Failed",description:s.message||"Failed to save appearance settings",variant:"destructive"})}finally{j(!1)}},le=async(s,t,a)=>{const{data:r}=await d.from("platform_settings").select("id").eq("key",s).single(),o=JSON.parse(JSON.stringify(t));if(r){const{error:I}=await d.from("platform_settings").update({value:o,description:a,updated_at:new Date().toISOString()}).eq("key",s);if(I)throw I}else{const{error:I}=await d.from("platform_settings").insert([{key:s,value:o,description:a}]);if(I)throw I}},je=async(s,t)=>{t==="favicon"?pe(!0):ue(!0);try{const a=s.name.split(".").pop(),o=`branding/${`${t}-${Date.now()}.${a}`}`,{error:I}=await d.storage.from("avatars").upload(o,s,{upsert:!0});if(I)throw I;const{data:{publicUrl:Se}}=d.storage.from("avatars").getPublicUrl(o);t==="favicon"?i(Se):P(Se),p({title:"Upload Successful",description:`${t==="favicon"?"Favicon":"Logo"} has been uploaded.`})}catch(a){p({title:"Upload Failed",description:a.message||`Failed to upload ${t}`,variant:"destructive"})}finally{t==="favicon"?pe(!1):ue(!1)}},Ne=async()=>{try{const{data:s,error:t}=await d.from("platform_settings").select("value").eq("key","algorithm_weights").single();if(s!=null&&s.value&&typeof s.value=="object"&&!Array.isArray(s.value)){const a=s.value;"bookings"in a&&"reviews"in a&&"rating"in a&&"clicks"in a&&"recency"in a&&l(a)}}catch(s){console.error("Error loading algorithm weights:",s)}},Ke=async()=>{w(!0);try{const{data:s}=await d.from("platform_settings").select("id").eq("key","algorithm_weights").single(),t=JSON.parse(JSON.stringify(M));if(s){const{error:a}=await d.from("platform_settings").update({value:t,description:"Weights for the service popularity algorithm",updated_at:new Date().toISOString()}).eq("key","algorithm_weights");if(a)throw a}else{const{error:a}=await d.from("platform_settings").insert([{key:"algorithm_weights",value:t,description:"Weights for the service popularity algorithm"}]);if(a)throw a}p({title:"Weights Saved",description:"Algorithm weights have been updated successfully."})}catch(s){p({title:"Save Failed",description:s.message||"Failed to save algorithm weights",variant:"destructive"})}finally{w(!1)}},Ge=()=>{l(Re)},ze=async()=>{try{const{data:s,error:t}=await d.from("platform_settings").select("value").eq("key","ai_prompt_templates").single();if(s!=null&&s.value&&typeof s.value=="object"&&!Array.isArray(s.value)){const a=s.value;"positivePrompt"in a&&"negativePrompt"in a&&x(a)}}catch(s){console.error("Error loading AI templates:",s)}},Je=async()=>{try{const{data:s,error:t}=await d.from("platform_settings").select("value").eq("key","ai_model").single();if(s!=null&&s.value&&typeof s.value=="object"&&!Array.isArray(s.value)){const a=s.value;"model"in a&&typeof a.model=="string"&&L(a.model)}}catch(s){console.error("Error loading AI model:",s)}},Ye=async s=>{var t;try{const{data:a}=await d.from("platform_settings").select("id").eq("key","ai_model").single(),r={model:s};if(a){const{error:o}=await d.from("platform_settings").update({value:r,description:"AI model configuration for readings",updated_at:new Date().toISOString()}).eq("key","ai_model");if(o)throw o}else{const{error:o}=await d.from("platform_settings").insert([{key:"ai_model",value:r,description:"AI model configuration for readings"}]);if(o)throw o}L(s),p({title:"AI Model Updated",description:`AI model changed to ${((t=Ee.find(o=>o.value===s))==null?void 0:t.label)||s}`})}catch(a){p({title:"Save Failed",description:a.message||"Failed to save AI model",variant:"destructive"})}},He=async()=>{V(!0);try{const{data:s}=await d.from("platform_settings").select("id").eq("key","ai_prompt_templates").single(),t=JSON.parse(JSON.stringify(m));if(s){const{error:a}=await d.from("platform_settings").update({value:t,description:"Default AI prompt templates for readers",updated_at:new Date().toISOString()}).eq("key","ai_prompt_templates");if(a)throw a}else{const{error:a}=await d.from("platform_settings").insert([{key:"ai_prompt_templates",value:t,description:"Default AI prompt templates for readers"}]);if(a)throw a}p({title:"AI Templates Saved",description:"Default AI prompt templates have been updated successfully."})}catch(s){p({title:"Save Failed",description:s.message||"Failed to save AI templates",variant:"destructive"})}finally{V(!1)}},Xe=()=>{x(Ue)},re=async()=>{z(!0);try{const{data:s,error:t}=await d.functions.invoke("check-api-keys");if(t)throw t;s!=null&&s.keys&&fe(a=>a.map(r=>{const o=s.keys[r.key];return{...r,isConfigured:(o==null?void 0:o.configured)||!1,maskedValue:(o==null?void 0:o.masked)||""}}))}catch(s){console.error("Error checking API key status:",s)}finally{z(!1)}},Qe=async()=>
6{if(N.keyIndex<0||!N.newValue.trim())return;const s=S[N.keyIndex];f(!0);try{const{data:t,error:a}=await d.functions.invoke("update-api-key",{body:{keyName:s.key,keyValue:N.newValue.trim()}});if(a)throw a;p({title:"API Key Updated",description:`${s.name} has been updated successfully.`}),O({open:!1,keyIndex:-1,newValue:""}),re()}catch(t){p({title:"Update Failed",description:t.message||"Failed to update API key",variant:"destructive"})}finally{f(!1)}},Ze=s=>{O({open:!0,keyIndex:s,newValue:""})},es=s=>{fe(t=>t.map((a,r)=>r===s?{...a,isVisible:!a.isVisible}:a))},be=S.filter(s=>s.isConfigured).length;return ee?e.jsxs("div",{className:"space-y-6 max-w-6xl mx-auto",children:[e.jsxs("div",{children:[e.jsx(C,{className:"h-8 w-48"}),e.jsx(C,{className:"h-4 w-64 mt-2"})]}),e.jsx("div",{className:"grid gap-3 grid-cols-2 lg:grid-cols-4",children:[1,2,3,4].map(s=>e.jsx(G,{title:"",value:"",icon:De,iconBg:"",iconColor:"",loading:!0},s))})]}):e.jsxs("div",{className:"space-y-6 max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Settings"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"Platform configuration and preferences"})]}),e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>{re(),Ne()},className:"gap-2",children:[e.jsx(Cs,{className:"h-4 w-4"}),"Refresh"]})]}),e.jsxs("div",{className:"grid gap-3 grid-cols-2 lg:grid-cols-4",children:[e.jsx(G,{title:"API Keys",value:`${be}/${S.length}`,subtitle:"Configured",icon:me,iconBg:"bg-violet-100",iconColor:"text-violet-600",status:be===S.length?"success":"warning"}),e.jsx(G,{title:"Security",value:"Active",subtitle:"All systems operational",icon:Ce,iconBg:"bg-emerald-100",iconColor:"text-emerald-600",status:"success"}),e.jsx(G,{title:"Commission",value:"15%",subtitle:"Platform fee",icon:xe,iconBg:"bg-blue-100",iconColor:"text-blue-600"}),e.jsx(G,{title:"Algorithm",value:"5",subtitle:"Weight factors",icon:Ds,iconBg:"bg-amber-100",iconColor:"text-amber-600"})]}),e.jsxs(ps,{defaultValue:"api",className:"w-full",children:[e.jsxs(us,{className:"bg-gray-100/50 p-1 h-auto flex-wrap",children:[e.jsxs(_,{value:"api",className:"text-xs data-[state=active]:bg-white gap-2",children:[e.jsx(me,{className:"h-3 w-3"}),"API Keys"]}),e.jsxs(_,{value:"appearance",className:"text-xs data-[state=active]:bg-white gap-2",children:[e.jsx(Ae,{className:"h-3 w-3"}),"Appearance"]}),e.jsxs(_,{value:"ai",className:"text-xs data-[state=active]:bg-white gap-2",children:[e.jsx(X,{className:"h-3 w-3"}),"AI Settings"]}),e.jsxs(_,{value:"ai-analytics",className:"text-xs data-[state=active]:bg-white gap-2",children:[e.jsx(ge,{className:"h-3 w-3"}),"AI Analytics"]}),e.jsxs(_,{value:"algorithm",className:"text-xs data-[state=active]:bg-white gap-2",children:[e.jsx(Z,{className:"h-3 w-3"}),"Algorithm"]}),e.jsxs(_,{value:"general",className:"text-xs data-[state=active]:bg-white gap-2",children:[e.jsx(De,{className:"h-3 w-3"}),"General"]}),e.jsxs(_,{value:"security",className:"text-xs data-[state=active]:bg-white gap-2",children:[e.jsx(Ce,{className:"h-3 w-3"}),"Security"]}),e.jsxs(_,{value:"payments",className:"text-xs data-[state=active]:bg-white gap-2",children:[e.jsx(xe,{className:"h-3 w-3"}),"Payments"]})]}),e.jsx(T,{value:"api",className:"mt-4",children:e.jsxs(h,{className:"border-0 shadow-sm",children:[e.jsx(v,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-violet-100",children:e.jsx(me,{className:"h-4 w-4 text-violet-600"})}),e.jsxs("div",{children:[e.jsx(y,{className:"text-base font-semibold",children:"API Keys"}),e.jsx(F,{children:"Manage external service integrations"})]})]})}),e.jsxs(g,{className:"space-y-3",children:[S.map((s,t)=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-gray-50 hover:bg-gray-100 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-gray-900",children:s.name}),s.isConfigured?e.jsxs(he,{className:"bg-emerald-100 text-emerald-700 border-0 text-xs",children:[e.jsx(Ve,{className:"w-3 h-3 mr-1"}),"Configured"]}):e.jsxs(he,{className:"bg-red-100 text-red-700 border-0 text-xs",children:[e.jsx(We,{className:"w-3 h-3 mr-1"}),"Not Set"]})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:s.description}),s.isConfigured&&s.maskedValue&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("code",{className:"text-xs bg-white px-2 py-1 rounded font-mono text-gray-600",children:s.isVisible?s.maskedValue:"••••••••••••••••"}),e.jsx("button",{onClick:()=>es(t),className:"text-gray-400 hover:text-gray-600",children:s.isVisible?e.jsx(As,{className:"w-4 h-4"}):e.jsx(ls,{className:"w-4 h-4"})})]})]}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>Ze(t),children:s.isConfigured?"Update":"Configure"})]},s.key)),e.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-amber-50 border border-amber-200",children:[e.jsx(Q,{className:"w-5 h-5 text-amber-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-amber-800",children:"Security Notice"}),e.jsx("p",{className:"text-xs text-amber-700 mt-0.5",children:"API keys are stored securely and encrypted. Never share your secret keys publicly."})]})]})]})]})}),e.jsx(T,{value:"appearance",className:"mt-4",children:e.jsxs(h,{className:"border-0 shadow-sm",children:[e.jsx(v,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-pink-100",children:e.jsx(Ae,{className:"h-4 w-4 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(y,{className:"text-base font-semibold",children:"Appearance Settings"}),e.jsx(F,{children:"Configure default theme, favicon, and logo"})]})]})}),e.jsxs(g,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Default Theme"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Select the default theme for new visitors. Users can still change their theme preference."}),e.jsxs(ne,{value:q,onValueChange:$,children:[e.jsx(ce,{className:"w-full bg-gray-50",children:e.jsx(oe,{placeholder:"Select default theme..."})}),e.jsx(de,{children:rs.map(s=>e.jsx(Y,{value:s.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:s.icon}),e.jsx("span",{className:"font-medium",children:s.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",s.description]})]})},s.id))})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Default Color Mode"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Select whether new visitors see light or dark mode by default."}),e.jsxs(ne,{value:W?"dark":"light",onValueChange:s=>u(s==="dark"),children:[e.jsx(ce,{className:"w-full bg-gray-50",children:e.jsx(oe,{placeholder:"Select default mode..."})}),e.jsxs(de,{children:[e.jsx(Y,{value:"light",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(is,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"font-medium",children:"Light Mode"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"- Bright, clear interface"})]})}),e.jsx(Y,{value:"dark",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ns,{className:"h-4 w-4 text-indigo-500"}),e.jsx("span",{className:"font-medium",children:"Dark Mode"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"- Easy on the eyes"})]})})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Favicon"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Upload a custom favicon (recommended: 32x32px or 64x64px, .ico, .png, or .svg)"}),e.jsxs("div",{className:"flex items-center gap-4",children:[b&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-gray-50 rounded-lg border",children:[e.jsx("img",{src:b,alt:"Current favicon",className:"w-8 h-8 object-contain"}),e.jsx("span",{className:"text-xs text-gray-500",children:"Current"})]}),e.jsx("div",{className:"flex-1",children:e.jsxs("label",{className:"flex items-center justify-center gap-2 px-4 py-3 border-2 border-dashed border-gray-300 rounded-lg cursor-pointer hover:border-pink-400 hover:bg-pink-50 transition-colors",children:[ae?e.jsx(B,{className:"h-5 w-5 animate-spin text-pink-500"}):e.jsx(Is,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-600",children:ae?"Uploading...":"Upload Favicon"}),e.jsx("input",{type:"file",accept:".ico,.png,.svg,.jpg,.jpeg",className:"hidden",onChange:s=>{var a;const t=(a=s.target.files)==null?void 0:a[0];t&&je(t,"favicon")},disabled:ae})]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Or enter URL:"}),e.jsx(E,{placeholder:"https://example.com/favicon.ico",value:b,onChange:s=>i(s.target.value),className:"flex-1 bg-gray-50 text-sm"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Logo"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Upload your site logo (recommended: transparent PNG, max width 200px)"}),e.jsxs("div",{className:"flex items-center gap-4",children:[c&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-gray-50 rounded-lg border",children:[e.jsx("img",{src:c,alt:"Current logo",className:"h-10 max-w-[120px] object-contain"}),e.jsx("span",{className:"text-xs text-gray-500",children:"Current"})]}),e.jsx("div",{className:"flex-1",children:e.jsxs("label",{className:"flex items-center justify-center gap-2 px-4 py-3 border-2 border-dashed border-gray-300 rounded-lg cursor-pointer hover:border-pink-400 hover:bg-pink-50 transition-colors",children:[te?e.jsx(B,{className:"h-5 w-5 animate-spin text-pink-500"}):e.jsx(_s,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-600",children:te?"Uploading...":"Upload Logo"}),e.jsx("input",{type:"file",accept:".png,.svg,.jpg,.jpeg,.webp",className:"hidden",onChange:s=>{var a;const t=(a=s.target.files)==null?void 0:a[0];t&&je(t,"logo")},disabled:te})]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Or enter URL:"}),e.jsx(E,{placeholder:"https://example.com/logo.png",value:c,onChange:s=>P(s.target.value),className:"flex-1 bg-gray-50 text-sm"})]})]}),e.jsx("div",{className:"flex items-center gap-3 pt-4 border-t",children:e.jsx(k,{onClick:Oe,disabled:A,className:"gap-2",children:A?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"h-4 w-4"}),"Save Appearance"]})})}),e.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-blue-50 border border-blue-200",children:[e.jsx(Q,{className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-blue-800",children:"Note"}),e.jsx("p",{className:"text-xs text-blue-700 mt-0.5",children:"Theme changes will apply to new visitors. Users who have already selected a theme will keep their preference."})]})]})]})]})}),e.jsx(T,{value:"ai",className:"mt-4",children:e.jsxs(h,{className:"border-0 shadow-sm",children:[e.jsx(v,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-violet-100",children:e.jsx(X,{className:"h-4 w-4 text-violet-600"})}),e.jsxs("div",{children:[e.jsx(y,{className:"text-base font-semibold",children:"AI Reading Generator Settings"}),e.jsx(F,{children:"Configure default AI prompt templates for readers"})]})]})}),e.jsxs(g,{className:"space-y-6",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-gradient-to-r from-violet-50 to-purple-50 border border-violet-200",children:[e.jsxs("div",{className:"flex items-center gap-2 text-violet-700 mb-3",children:[e.jsx(X,{className:"h-4 w-4"}),e.jsx("p",{className:"font-medium",children:"AI Model Configuration"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-2",children:"Select AI Model"}),e.jsxs(ne,{value:se,onValueChange:Ye,children:[e.jsx(ce,{className:"w-full bg-white",children:e.jsx(oe,{placeholder:"Select AI model..."})}),e.jsx(de,{children:Ee.map(s=>e.jsx(Y,{value:s.value,children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:s.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.description})]})},s.value))})]})]}),e.jsx("p",{className:"text-xs text-violet-600",children:"This model will be used for all AI-generated readings. Changes take effect immediately."})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Default Positive Prompt"}),e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Instructions for the AI on what to include and how to write the reading"}),e.jsx(Fe,{value:m.positivePrompt,onChange:s=>x(t=>({...t,positivePrompt:s.target.value})),placeholder:"Enter positive prompt instructions...",rows:4,className:"bg-gray-50"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Default Negative Prompt"}),e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Instructions for the AI on what to avoid in the reading"}),e.jsx(Fe,{value:m.negativePrompt,onChange:s=>x(t=>({...t,negativePrompt:s.target.value})),placeholder:"Enter negative prompt instructions...",rows:4,className:"bg-gray-50"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-4 border-t",children:[e.jsx(k,{onClick:He,disabled:U,className:"gap-2",children:U?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"h-4 w-4"}),"Save AI Templates"]})}),e.jsxs(k,{variant:"outline",onClick:Xe,className:"gap-2",children:[e.jsx(Pe,{className:"h-4 w-4"}),"Reset to Default"]})]}),e.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-blue-50 border border-blue-200",children:[e.jsx(Q,{className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-blue-800",children:"Note"}),e.jsx("p",{className:"text-xs text-blue-700 mt-0.5",children:"These templates serve as defaults for new readers. Existing readers can customize their own prompts in their AI settings."})]})]})]})]})}),e.jsx(T,{value:"ai-analytics",className:"mt-4",children:e.jsx(Ps,{})}),e.jsx(T,{value:"algorithm",className:"mt-4",children:e.jsxs(h,{className:"border-0 shadow-sm",children:[e.jsx(v,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-amber-100",children:e.jsx(Z,{className:"h-4 w-4 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(y,{className:"text-base font-semibold",children:"Algorithm Weights"}),e.jsx(F,{children:"Configure product ranking algorithm"})]})]})}),e.jsxs(g,{className:"space-y-6",children:[e.jsx("div",{className:"grid gap-6",children:[{key:"bookings",label:"Bookings Weight",desc:"Products with more sales rank higher"},{key:"reviews",label:"Reviews Weight",desc:"Products with more reviews rank higher"},{key:"rating",label:"Rating Weight",desc:"Products with better ratings rank higher"},{key:"clicks",label:"Clicks Weight",desc:"More clicked products rank higher"},{key:"recency",label:"Recency Weight",desc:"Newer products get a bigger boost"}].map(({key:s,label:t,desc:a})=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700",children:t}),e.jsx("span",{className:"text-sm text-gray-500 font-mono bg-gray-100 px-2 p
6y-0.5 rounded",children:M[s].toFixed(1)})]}),e.jsx(gs,{value:[M[s]],onValueChange:([r])=>l(o=>({...o,[s]:r})),min:0,max:5,step:.1,className:"w-full"}),e.jsx("p",{className:"text-xs text-gray-400",children:a})]},s))}),e.jsxs("div",{className:"flex items-center gap-3 pt-4 border-t",children:[e.jsxs(k,{variant:"outline",onClick:Ge,className:"gap-2",size:"sm",children:[e.jsx(Pe,{className:"w-4 h-4"}),"Reset to Default"]}),e.jsx(k,{onClick:Ke,disabled:R,size:"sm",children:R?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Weights"})]})]})]})}),e.jsx(T,{value:"general",className:"mt-4",children:e.jsxs(h,{className:"border-0 shadow-sm",children:[e.jsx(v,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-blue-100",children:e.jsx(Ts,{className:"h-4 w-4 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(y,{className:"text-base font-semibold",children:"General Settings"}),e.jsx(F,{children:"Basic platform configuration"})]})]})}),e.jsxs(g,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:"Platform Name"}),e.jsx(E,{defaultValue:"MysticMart",className:"bg-gray-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:"Support Email"}),e.jsx(E,{defaultValue:"[email protected]",className:"bg-gray-50"})]})]}),e.jsxs("div",{className:"space-y-3 pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:"Maintenance Mode"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Temporarily disable the platform"})]}),e.jsx(K,{})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:"Allow New Registrations"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Allow new users to sign up"})]}),e.jsx(K,{defaultChecked:!0})]})]})]})]})}),e.jsx(T,{value:"security",className:"mt-4",children:e.jsxs(h,{className:"border-0 shadow-sm",children:[e.jsx(v,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-emerald-100",children:e.jsx(Fs,{className:"h-4 w-4 text-emerald-600"})}),e.jsxs("div",{children:[e.jsx(y,{className:"text-base font-semibold",children:"Security Settings"}),e.jsx(F,{children:"Authentication and access options"})]})]})}),e.jsxs(g,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:"Two-Factor Authentication"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Require 2FA for admin accounts"})]}),e.jsx(K,{})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:"Email Verification"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Require email verification for new users"})]}),e.jsx(K,{defaultChecked:!0})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:"Session Timeout"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Automatically log out inactive users"})]}),e.jsx(K,{defaultChecked:!0})]})]})]})}),e.jsx(T,{value:"payments",className:"mt-4",children:e.jsxs(h,{className:"border-0 shadow-sm",children:[e.jsx(v,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-pink-100",children:e.jsx(xe,{className:"h-4 w-4 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(y,{className:"text-base font-semibold",children:"Payment Settings"}),e.jsx(F,{children:"Configure payment processing"})]})]})}),e.jsxs(g,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:"Platform Commission (%)"}),e.jsx(E,{type:"number",defaultValue:"15",className:"bg-gray-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:"Minimum Payout 
6($)"}),e.jsx(E,{type:"number",defaultValue:"50",className:"bg-gray-50"})]})]}),e.jsx("div",{className:"pt-4",children:e.jsx(k,{size:"sm",children:"Save Payment Settings"})})]})]})})]}),e.jsx(cs,{open:N.open,onOpenChange:s=>!s&&O({open:!1,keyIndex:-1,newValue:""}),children:e.jsxs(os,{children:[e.jsxs(ds,{children:[e.jsx(ms,{children:N.keyIndex>=0&&((ve=S[N.keyIndex])!=null&&ve.isConfigured)?`Update ${(ye=S[N.keyIndex])==null?void 0:ye.name}`:`Configure ${(we=S[N.keyIndex])==null?void 0:we.name}`}),e.jsx(xs,{children:"Enter your API key below. This will be securely stored and encrypted."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:"API Key"}),e.jsx(E,{type:"password",placeholder:"Enter your API key...",value:N.newValue,onChange:s=>O(t=>({...t,newValue:s.target.value})),className:"bg-gray-50"})]}),N.keyIndex>=0&&((ke=S[N.keyIndex])==null?void 0:ke.key)==="stripe_secret"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["You can find your Stripe Secret Key in the"," ",e.jsx("a",{href:"https://dashboard.stripe.com/apikeys",target:"_blank",rel:"noopener noreferrer",className:"text-violet-600 hover:underline",children:"Stripe Dashboard"})]})]}),e.jsxs(hs,{children:[e.jsx(k,{variant:"outline",onClick:()=>O({open:!1,keyIndex:-1,newValue:""}),children:"Cancel"}),e.jsx(k,{onClick:Qe,disabled:D||!N.newValue.trim(),children:D?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save API Key"})]})]})})]})};export{ba as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.