1import{c as I,r as t,j as e,b1 as W,C as j,a as w,b as v,M as P,d as S,e as _,L as h,l as C,I as H,i as x,a0 as f,S as q,x as V,J as l,k as G,B as X,s as Q}from"./index-BOi4GZy8.js";import{A as z,a as D}from"./alert-DgoHVgjN.js";import{u as Y}from"./useReceptionistConfig-844O5u_y.js";import{S as J}from"./send-Du81UX8q.js";import{I as Z}from"./info-BjEpPClt.js";import{C as ee}from"./copy-CTqhfe6o.js";import{S as se}from"./save-DG-cInQz.js";import"./edgeError-DSnFxpXo.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 ae=I("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]),g=async a=>{var u;const{data:y,error:n}=await Q.functions.invoke("ai-receptionist-notify",{body:a});if(n){const i=n==null?void 0:n.context;let o=n.message;if(typeof(i==null?void 0:i.body)=="string")try{o=((u=JSON.parse(i.body))==null?void 0:u.error)??i.body}catch{o=i.body}throw new Error(o)}return y},he=()=>{const{config:a,loading:y,saving:n,save:u}=Y(),[i,o]=t.useState(!1),[E,A]=t.useState(""),[R,K]=t.useState(!1),[M,T]=t.useState(!1),[B,F]=t.useState(""),[m,c]=t.useState(!1),[r,L]=t.useState(null),[k,U]=t.useState(null),[d,O]=t.useState(null);t.useEffect(()=>{a&&(o(a.notify_email_enabled),A((a.notify_email_recipients??[]).join(", ")),K(a.notify_email_high_priority_only),T(a.notify_webhook_enabled),F(a.notify_webhook_url??""),c(!1))},[a]),t.useEffect(()=>{a&&g({action:"get_webhook_secret"}).then(L).catch(()=>{})},[a]);const $=async()=>{const s=E.split(",").map(N=>N.trim()).filter(Boolean),p=await u({notify_email_enabled:i,notify_email_recipients:s,notify_email_high_priority_only:R,notify_webhook_enabled:M,notify_webhook_url:B.trim()||null});p.ok?(l.success("Notifieringar sparade."),c(!1)):l.error(p.message??"Kunde inte spara.")},b=async(s,p)=>{O(s);try{await p()}catch(N){l.error(N.message)}finally{O(null)}};return y?e.jsxs("div",{className:"space-y-4",children:[e.jsx(W,{className:"h-52 w-full"}),e.jsx(W,{className:"h-64 w-full"})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs(j,{children:[e.jsxs(w,{children:[e.jsxs(v,{className:"flex items-center gap-2",children:[e.jsx(P,{className:"h-5 w-5 text-primary","aria-hidden":"true"}),"E-post"]}),e.jsx(S,{children:"FÃ¥ ett mejl när receptionisten tagit emot ett ärende."})]}),e.jsxs(_,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsx(h,{htmlFor:"email-enabled",className:"text-sm font-medium",children:"Skicka e-post"}),e.jsx(C,{id:"email-enabled",checked:i,onCheckedChange:s=>{o(s),c(!0)}})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{htmlFor:"recipients",children:"Mottagare (kommaseparerade)"}),e.jsx(H,{id:"recipients",value:E,placeholder:"namn@företag.se, chef@företag.se",onChange:s=>{A(s.target.value),c(!0)}}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ogiltiga adresser sparas inte â servern filtrerar bort dem."})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"high-only",className:"text-sm font-medium",children:"Endast hög prioritet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Mejla bara när ärendet är brÃ¥dskande."})]}),e.jsx(C,{id:"high-only",checked:R,onCheckedChange:s=>{K(s),c(!0)}})]}),e.jsxs(x,{variant:"outline",disabled:d!==null||m,onClick:()=>b("email",async()=>{const s=await g({action:"test_email"});l.success(`Testmejl skickat till ${s.to}.`)}),children:[d==="email"?e.jsx(f,{className:"h-4 w-4 mr-2 animate-spin","aria-hidden":"true"}):e.jsx(J,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"Skicka testmejl"]}),m&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Spara först för att kunna testa."})]})]}),e.jsxs(j,{children:[e.jsxs(w,{children:[e.jsxs(v,{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-5 w-5 text-primary","aria-hidden":"true"}),"Webhook"]}),e.jsx(S,{children:"Skicka varje förfrÃ¥gan som signerad JSON till ditt eget system."})]}),e.jsxs(_,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsx(h,{htmlFor:"webhook-enabled",className:"text-sm font-medium",children:"Aktivera webhook"}),e.jsx(C,{id:"webhook-enabled",checked:M,onCheckedChange:s=>{T(s),c(!0)}})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{htmlFor:"webhook-url",children:"Webhook-URL"}),e.jsx(H,{id:"webhook-url",value:B,placeholder:"https://â¦",onChange:s=>{F(s.target.value),c(!0)}}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"MÃ¥ste vara https. Interna och privata adresser blockeras."})]}),e.jsx(q,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(h,{className:"text-sm font-medium",children:"Signeringsnyckel"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r!=null&&r.configured?`Konfigurerad (â¦${r.maskedSuffix??""})`:"Ingen nyckel genererad ännu."})]}),e.jsxs(x,{variant:"outline",size:"sm",disabled:d!==null,onClick:()=>b("secret",async()=>{const s=await g({action:"rotate_webhook_secret"});U(s.secret),L({configured:!0,maskedSuffix:s.secret.slice(-4)}),l.success("Ny signeringsnyckel skapad.")}),children:[d==="secret"?e.jsx(f,{className:"h-4 w-4 mr-2 animate-spin","aria-hidden":"true"}):e.jsx(V,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),r!=null&&r.configured?"Rotera":"Generera"]})]}),k&&e.jsxs(z,{children:[e.jsx(Z,{className:"h-4 w-4","aria-hidden":"true"}),e.jsxs(D,{className:"space-y-2",children:[e.jsx("p",{className:"text-sm",children:"Kopiera nyckeln nu â den visas bara denna gÃ¥ng."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-xs bg-muted px-2 py-1 rounded break-all flex-1",children:k}),e.jsx(x,{size:"sm",variant:"ghost","aria-label":"Kopiera signeringsnyckel",onClick:()=>{navigator.clipboard.writeText(k),l.success("Kopierad.")},children:e.jsx(ee,{className:"h-4 w-4","aria-hidden":"true"})})]})]})]})]}),e.jsx(z,{children:e.jsxs(D,{className:"text-xs space-y-1",children:[e.jsxs("p",{children:["Varje anrop signeras: ",e.jsx("code",{children:'X-SRP-Signature: t=<unix>,v1=<HMAC-SHA256(secret, t + "." + body)>'})]}),e.jsx("p",{children:"Verifiera signaturen och avvisa anrop äldre än 5 minuter."})]})}),e.jsxs(x,{variant:"outline",disabled:d!==null||m||!(r!=null&&r.configured),onClick:()=>b("webhook",async()=>{const s=await g({action:"test_webhook"});s.ok?l.success(`Testleverans lyckades (HTTP ${s.status}).`):l.error(`Testleverans misslyckades: ${s.errorCode??"okänt fel"}`)}),children:[d==="webhook"?e.jsx(f,{className:"h-4 w-4 mr-2 animate-spin","aria-hidden":"true"}):e.jsx(J,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"Skicka testwebhook"]})]})]}),e.jsx(j,{className:"opacity-70",children:e.jsxs(w,{children:[e.jsxs(v,{className:"flex items-center gap-2 text-base",children:[e.jsx(G,{className:"h-4 w-4","aria-hidden":"true"}),"Notiser i appen",e.jsx(X,{variant:"outline",children:"Kommer senare"})]}),e.jsx(S,{children:"SEORANKPLUS har ännu inget system för notiser inne i appen, sÃ¥ det visas inte som aktivt här. Använd e-post eller webhook tills vidare."})]})}),e.jsx("div",{className:"sticky bottom-4 z-10",children:e.jsx(j,{className:"shadow-lg",children:e.jsxs(_,{className:"flex items-center justify-between gap-4 py-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:m?"Du har osparade ändringar.":"Allt är sparat."}),e.jsxs(x,{onClick:$,disabled:n||!m,children:[n?e.jsx(f,{className:"h-4 w-4 mr-2 animate-spin","aria-hidden":"true"}):e.jsx(se,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"Spara"]})]})})})]})};export{he 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.