import{a as h,g as v,i as k,aH as A,ap as j,aF as P,H as C,j as e,_ as o,f as M,bG as S}from"./main-634.js";import{h as T,i as N}from"./bf-25-81.js";import{F as r}from"./bf-767-388.js";import{S as F}from"./bf-982-242.js";import"./bf-497-246.js";import"./bf-641-107.js";import"./bf-400-72.js";import"./bf-438-114.js";const K=[{value:"none",label:"None"},{value:"nominatim",label:"OpenStreetMap (Nominatim)"},{value:"google",label:"Google Places"},{value:"mapbox",label:"Mapbox"}];function H(){var c;const{css:l}=h(),{fieldKey:s}=v(),[n,u]=k(A),{keys:m}=T(),f=j(P),d=()=>f({show:!0,fieldType:"address",onConfigured:null});if(!s)return null;const i=C(n[s]),a=((c=i.config)==null?void 0:c.autocomplete)||"none",g=a==="google"||a==="mapbox",y=N(i.config,m),b=({target:{value:t}})=>{const p=M(n,x=>{x[s].config.autocomplete=t});u(p),S({event:`Address autocomplete provider set to '${t}': ${i.lbl||s}`,type:"address_autocomplete_changed",state:{fields:p,fldKey:s}})};return e.jsxs(F,{id:"addr-autocmpl-stng",title:o("Address Autocomplete"),className:l(r.fieldSection,r.hover_tip),tip:o("Provider for address lookup suggestions. Nominatim is free. Google and Mapbox require an API key."),open:!0,isPro:!0,children:[e.jsx("div",{className:l(r.placeholder),children:e.jsx("select",{"data-testid":"addr-autocmpl-stng-slct",className:l(r.input),"aria-label":o("Address autocomplete provider"),value:a,onChange:b,children:K.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})}),a==="nominatim"&&e.jsx("small",{style:{display:"block",marginTop:6,color:"var(--bf-text-clr-gray)"},children:o("Nominatim is free but rate-limited. Do not use for high-traffic forms.")}),g&&(y?e.jsxs("div",{style:{marginTop:8,padding:"8px 10px",borderRadius:6,background:"rgba(255, 168, 0, 0.08)",border:"1px solid rgba(255, 168, 0, 0.35)"},children:[e.jsx("small",{style:{display:"block",color:"var(--bf-text-clr-gray)",marginBottom:6},children:o("This provider needs an API key to work. Add the key once and all Address fields will use it (a per-field key overrides it).")}),e.jsx("button",{type:"button","data-testid":"addr-autocmpl-setup-key-btn",onClick:d,style:{background:"none",border:"none",padding:0,color:"var(--bf-primary-color, #0066ff)",fontWeight:600,cursor:"pointer",textDecoration:"underline"},children:o("Set up API Key")})]}):e.jsxs("small",{style:{display:"block",marginTop:6,color:"var(--bf-success-clr, #1a9d54)"},children:[o("✓ API key configured.")," ",e.jsx("button",{type:"button","data-testid":"addr-autocmpl-edit-key-btn",onClick:d,style:{background:"none",border:"none",padding:0,color:"var(--bf-primary-color, #0066ff)",cursor:"pointer",textDecoration:"underline"},children:o("Edit key")})]}))]})}export{H as default};
