UNPKG

react-mada-location

Version:

Composants React pour la sélection géographique à Madagascar (provinces, régions, districts).

23 lines (22 loc) 29.1 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react");var D={exports:{}},E={};/** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var N;function pe(){if(N)return E;N=1;var t=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function a(f,d,p){var i=null;if(p!==void 0&&(i=""+p),d.key!==void 0&&(i=""+d.key),"key"in d){p={};for(var e in d)e!=="key"&&(p[e]=d[e])}else p=d;return d=p.ref,{$$typeof:t,type:f,key:i,ref:d!==void 0?d:null,props:p}}return E.Fragment=n,E.jsx=a,E.jsxs=a,E}var S={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Q;function fe(){return Q||(Q=1,process.env.NODE_ENV!=="production"&&function(){function t(o){if(o==null)return null;if(typeof o=="function")return o.$$typeof===de?null:o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case O:return"Fragment";case te:return"Profiler";case ee:return"StrictMode";case ne:return"Suspense";case oe:return"SuspenseList";case ae:return"Activity"}if(typeof o=="object")switch(typeof o.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),o.$$typeof){case I:return"Portal";case se:return(o.displayName||"Context")+".Provider";case ie:return(o._context.displayName||"Context")+".Consumer";case re:var g=o.render;return o=o.displayName,o||(o=g.displayName||g.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case ce:return g=o.displayName||null,g!==null?g:t(o.type)||"Memo";case V:g=o._payload,o=o._init;try{return t(o(g))}catch{}}return null}function n(o){return""+o}function a(o){try{n(o);var g=!1}catch{g=!0}if(g){g=console;var v=g.error,x=typeof Symbol=="function"&&Symbol.toStringTag&&o[Symbol.toStringTag]||o.constructor.name||"Object";return v.call(g,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",x),n(o)}}function f(o){if(o===O)return"<>";if(typeof o=="object"&&o!==null&&o.$$typeof===V)return"<...>";try{var g=t(o);return g?"<"+g+">":"<...>"}catch{return"<...>"}}function d(){var o=B.A;return o===null?null:o.getOwner()}function p(){return Error("react-stack-top-frame")}function i(o){if(H.call(o,"key")){var g=Object.getOwnPropertyDescriptor(o,"key").get;if(g&&g.isReactWarning)return!1}return o.key!==void 0}function e(o,g){function v(){U||(U=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",g))}v.isReactWarning=!0,Object.defineProperty(o,"key",{get:v,configurable:!0})}function c(){var o=t(this.type);return q[o]||(q[o]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),o=this.props.ref,o!==void 0?o:null}function r(o,g,v,x,z,j,F,W){return v=j.ref,o={$$typeof:R,type:o,key:g,props:j,_owner:z},(v!==void 0?v:null)!==null?Object.defineProperty(o,"ref",{enumerable:!1,get:c}):Object.defineProperty(o,"ref",{enumerable:!1,value:null}),o._store={},Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(o,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(o,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:F}),Object.defineProperty(o,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:W}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o}function u(o,g,v,x,z,j,F,W){var m=g.children;if(m!==void 0)if(x)if(le(m)){for(x=0;x<m.length;x++)h(m[x]);Object.freeze&&Object.freeze(m)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else h(m);if(H.call(g,"key")){m=t(o);var A=Object.keys(g).filter(function(ue){return ue!=="key"});x=0<A.length?"{key: someKey, "+A.join(": ..., ")+": ...}":"{key: someKey}",Z[m+x]||(A=0<A.length?"{"+A.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`,x,m,A,m),Z[m+x]=!0)}if(m=null,v!==void 0&&(a(v),m=""+v),i(g)&&(a(g.key),m=""+g.key),"key"in g){v={};for(var L in g)L!=="key"&&(v[L]=g[L])}else v=g;return m&&e(v,typeof o=="function"?o.displayName||o.name||"Unknown":o),r(o,m,j,z,d(),v,F,W)}function h(o){typeof o=="object"&&o!==null&&o.$$typeof===R&&o._store&&(o._store.validated=1)}var b=l,R=Symbol.for("react.transitional.element"),I=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),ee=Symbol.for("react.strict_mode"),te=Symbol.for("react.profiler"),ie=Symbol.for("react.consumer"),se=Symbol.for("react.context"),re=Symbol.for("react.forward_ref"),ne=Symbol.for("react.suspense"),oe=Symbol.for("react.suspense_list"),ce=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),ae=Symbol.for("react.activity"),de=Symbol.for("react.client.reference"),B=b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=Object.prototype.hasOwnProperty,le=Array.isArray,M=console.createTask?console.createTask:function(){return null};b={"react-stack-bottom-frame":function(o){return o()}};var U,q={},J=b["react-stack-bottom-frame"].bind(b,p)(),X=M(f(p)),Z={};S.Fragment=O,S.jsx=function(o,g,v,x,z){var j=1e4>B.recentlyCreatedOwnerStacks++;return u(o,g,v,!1,x,z,j?Error("react-stack-top-frame"):J,j?M(f(o)):X)},S.jsxs=function(o,g,v,x,z){var j=1e4>B.recentlyCreatedOwnerStacks++;return u(o,g,v,!0,x,z,j?Error("react-stack-top-frame"):J,j?M(f(o)):X)}}()),S}var K;function he(){return K||(K=1,process.env.NODE_ENV==="production"?D.exports=pe():D.exports=fe()),D.exports}var s=he();const ge={Analamanga:{region_id:4,districts:[{district:"Antananarivo-Renivohitra",zip_code:101},{district:"Antananarivo-Atsimondrano",zip_code:102},{district:"Antananarivo-Avaradrano",zip_code:103},{district:"Ambohidratrimo",zip_code:105},{district:"Andramasina",zip_code:106},{district:"Anjozorobe",zip_code:107},{district:"Ankazobe",zip_code:108},{district:"Manjakandriana",zip_code:116},{district:"Tsiroanomandidy",zip_code:119}]},Vakinankaratra:{region_id:5,districts:[{district:"Ambatolampy",zip_code:104},{district:"Antanifotsy",zip_code:109},{district:"Antsirabe-I",zip_code:110},{district:"Antsirabe-II",zip_code:111},{district:"Betafo",zip_code:113},{district:"Faratsiho",zip_code:114}]},Itasy:{region_id:3,districts:[{district:"Arivonimamo",zip_code:112},{district:"Miarinarivo",zip_code:117},{district:"Soavinandriana",zip_code:118}]},Bongolava:{region_id:6,districts:[{district:"Fenoarivo",zip_code:115}]}},be={Diana:{region_id:1,districts:[{district:"Antsiranana-I",zip_code:201},{district:"Antsiranana-II",zip_code:202},{district:"Ambanja",zip_code:203},{district:"Ambilobe",zip_code:204},{district:"Nosy-Be",zip_code:207}]},Sava:{region_id:2,districts:[{district:"Andapa",zip_code:205},{district:"Antalaha",zip_code:206},{district:"Sambava",zip_code:208},{district:"Vohimarina",zip_code:209}]}},ve={"Haute-Matsiatra":{region_id:15,districts:[{district:"Fianarantsoa-I",zip_code:301},{district:"Fianarantsoa-II",zip_code:302},{district:"Ambalavao",zip_code:303},{district:"Ambohimahasoa",zip_code:305},{district:"Ikalamavony",zip_code:314}]},"Amoron'i Mania":{region_id:14,districts:[{district:"Ambatofinandrahana",zip_code:304},{district:"Ambositra",zip_code:306},{district:"Fandriana",zip_code:308},{district:"Manandriana",zip_code:323}]},"Atsimo-Atsinanana":{region_id:17,districts:[{district:"Befotaka",zip_code:307},{district:"Farafangana",zip_code:309},{district:"Midongy-Atsimo",zip_code:318},{district:"Vangaindrano",zip_code:320},{district:"Vondrozo",zip_code:322}]},Vatovavy:{region_id:16,districts:[{district:"Ifanadiana",zip_code:312},{district:"Mananjary",zip_code:317},{district:"Nosy-Varika",zip_code:319}]},Fitovinany:{region_id:23,districts:[{district:"Ikongo",zip_code:310},{district:"Manakara",zip_code:316},{district:"Vohipeno",zip_code:321}]},Ihorombe:{region_id:18,districts:[{district:"Iakora",zip_code:311},{district:"Ihosy",zip_code:313},{district:"Ivohibe",zip_code:315}]}},_e={Boeny:{region_id:8,districts:[{district:"Mahajanga-I",zip_code:401},{district:"Mahajanga-II",zip_code:402},{district:"Ambato-Boeny",zip_code:403},{district:"Marovoay",zip_code:416},{district:"Mitsinjo",zip_code:417},{district:"Soalala",zip_code:420}]},Melaky:{region_id:10,districts:[{district:"Ambatomainty",zip_code:404},{district:"Antsalova",zip_code:406},{district:"Besalampy",zip_code:410},{district:"Maintirano",zip_code:413},{district:"Morafanobe",zip_code:418}]},Sofia:{region_id:7,districts:[{district:"Analalava",zip_code:405},{district:"Antsihihy",zip_code:407},{district:"Bealanana",zip_code:408},{district:"Befandriana-Avaratra",zip_code:409},{district:"Mampikony",zip_code:414},{district:"Mandritsara",zip_code:415},{district:"Port-Bergé",zip_code:419}]},Betsiboka:{region_id:9,districts:[{district:"Kandreho",zip_code:411},{district:"Maevatanana",zip_code:412},{district:"Tsaratanana",zip_code:421}]}},xe={Atsinanana:{region_id:12,districts:[{district:"Toamasina-I",zip_code:501},{district:"Toamasina-II",zip_code:502},{district:"Antanambao-Manampotsy",zip_code:507},{district:"Ampasimanolotra",zip_code:508},{district:"Mahanoro",zip_code:510},{district:"Marolambo",zip_code:513},{district:"Vatomandry",zip_code:517}]},"Alaotra-Mangoro":{region_id:11,districts:[{district:"Ambatondrazaka",zip_code:503},{district:"Amparafaravola",zip_code:504},{district:"Andilamena",zip_code:505},{district:"Anosibe",zip_code:506},{district:"Moramanga",zip_code:514}]},Analanjirofo:{region_id:13,districts:[{district:"Fenoarivo-Atsinanana",zip_code:509},{district:"Mananara",zip_code:511},{district:"Maroansetra",zip_code:512},{district:"Sainte-Marie",zip_code:515},{district:"Soanierana-Ivongo",zip_code:516},{district:"Vavatenina",zip_code:518}]}},me={"Atsimo-Andrefana":{region_id:20,districts:[{district:"Toliara-I",zip_code:601},{district:"Toliara-II",zip_code:602},{district:"Ampanihy",zip_code:605},{district:"Ankazoabo-Atsimo",zip_code:606},{district:"Benenitra",zip_code:610},{district:"Beroroha",zip_code:611},{district:"Betioky-Atsimo",zip_code:612},{district:"Morombe",zip_code:618},{district:"Sakaraha",zip_code:620}]},Anosy:{region_id:22,districts:[{district:"Amboasary-Atsimo",zip_code:603},{district:"Betroka",zip_code:613},{district:"Taolanaro",zip_code:614}]},Androy:{region_id:21,districts:[{district:"Ambovombe-Androy",zip_code:604},{district:"Bekily",zip_code:607},{district:"Beloha",zip_code:609},{district:"Tsiombe",zip_code:621}]},Menabe:{region_id:19,districts:[{district:"Belo-sur-Tsiribihina",zip_code:608},{district:"Mahabo",zip_code:615},{district:"Manja",zip_code:616},{district:"Miandrivazo",zip_code:617},{district:"Morondava",zip_code:619}]}},k={Antananarivo:ge,Antsiranana:be,Fianarantsoa:ve,Mahajanga:_e,Toamasina:xe,Toliara:me},P=()=>k,y=()=>{let t=[];return Object.entries(k).forEach(([n,a])=>{Object.entries(a).forEach(([f,d])=>{t.push({province:n,region:f,region_id:d.region_id,districts:d.districts})})}),t},T=()=>{let t=[];return Object.entries(k).forEach(([n,a])=>{Object.entries(a).forEach(([f,d])=>{d.districts.forEach(p=>{t.push({province:n,region:f,district:p.district,zip_code:p.zip_code||null})})})}),t},w=t=>t&&k[t]?Object.entries(k[t]).map(([n,a])=>({region:n,region_id:a.region_id,districts:a.districts})):[],_=t=>{let n=[];return Object.entries(k).forEach(([a,f])=>{f[t]&&f[t].districts.forEach(d=>{n.push({province:a,region:t,district:d.district,zip_code:d.zip_code||null})})}),n},C=t=>{let n=[];return t&&k[t]&&Object.entries(k[t]).forEach(([a,f])=>{f.districts.forEach(d=>{n.push({province:t,region:a,district:d.district,zip_code:d.zip_code||null})})}),n},Re=Object.freeze(Object.defineProperty({__proto__:null,getAllDistrictsInfo:T,getAllProvincesInfo:P,getAllRegionsInfo:y,getFullDistrictsByProvince:C,getFullDistrictsByRegion:_,getFullRegionsByProvince:w},Symbol.toStringTag,{value:"Module"})),ye=({onSelectionChange:t})=>{const[n,a]=l.useState([]),[f,d]=l.useState("");l.useEffect(()=>{(async()=>{const e=y();a(e)})()},[]);const p=async i=>{const e=i.target.value;if(d(e),e){const c=await _(e),r={[e]:{name:e,districts:c}};t&&t(r)}else t&&t({})};return s.jsxs("div",{style:Y.wrapper,children:[s.jsx("div",{style:Y.label,children:"Région"}),s.jsxs("select",{value:f,onChange:p,style:Y.select,children:[s.jsx("option",{value:"",children:"-- Sélectionnez une région --"}),n.map(i=>s.jsx("option",{value:i.region,children:i.region},i.region_id))]})]})},Y={wrapper:{display:"flex",alignItems:"center",border:"1px solid #e5e7eb",borderRadius:"12px",overflow:"hidden",fontFamily:"Inter, sans-serif",width:"fit-content",backgroundColor:"#fff",marginBottom:"1rem"},label:{backgroundColor:"#f3f4f6",padding:"8px 12px",color:"#374151",fontWeight:"500",borderRight:"1px solid #e5e7eb"},select:{padding:"8px 12px",border:"none",outline:"none",fontWeight:"500",color:"#374151",backgroundColor:"transparent",cursor:"pointer",fontSize:"14px"}},je=({onSelectionChange:t})=>{const[n,a]=l.useState([]),[f,d]=l.useState({});l.useEffect(()=>{(async()=>{const e=y();a(e)})()},[]);const p=async(i,e)=>{if(e){const c=await _(i);d(r=>{const u={...r,[i]:{name:i,districts:c}};return t&&t(u),u})}else d(c=>{const r={...c};return delete r[i],t&&t(r),r})};return s.jsx("div",{children:n.length>0?n.map(i=>s.jsx("div",{children:s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",onChange:e=>p(i.region,e.target.checked),checked:!!f[i.region]}),i.region]})},i.region)):s.jsx("p",{children:"Aucune région disponible."})})},ze=({onSelectionChange:t})=>{const[n,a]=l.useState([]),[f,d]=l.useState("");l.useEffect(()=>{(async()=>{const e=y();a(e)})()},[]);const p=async i=>{if(d(i),i){const e=await _(i),c={[i]:{name:i,districts:e}};t&&t(c)}else t&&t({})};return s.jsx("div",{children:n.length>0?s.jsx("div",{children:n.map(i=>s.jsx("div",{children:s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:"region",value:i.region,checked:f===i.region,onChange:()=>p(i.region)}),i.region]})},i.region_id))}):s.jsx("p",{children:"Aucune région disponible."})})},ke=({onRegionSelected:t,renderRegions:n,renderDistricts:a})=>{const[f,d]=l.useState([]),[p,i]=l.useState(null),[e,c]=l.useState([]);l.useEffect(()=>{(()=>{const h=y();d(h)})()},[]);const r=async u=>{i(u);const h=await _(u);c(h),t==null||t(u,h)};return s.jsxs(s.Fragment,{children:[n&&n(f,r),p&&(a==null?void 0:a(p,e))]})},Ae=({provinces:t=[],onSelectionChange:n})=>{const[a,f]=l.useState([]),[d,p]=l.useState("");l.useEffect(()=>{(()=>{const r=y().filter(u=>t.length===0||t.includes(u.province));f(r)})()},[t]);const i=async e=>{const c=e.target.value;if(p(c),c){const r=await _(c),u={[c]:{name:c,districts:r}};n&&n(u)}else n&&n({})};return a.length>0?s.jsxs("div",{style:$.wrapper,children:[s.jsx("div",{style:$.label,children:"Région"}),s.jsxs("select",{value:d,onChange:i,style:$.select,children:[s.jsx("option",{value:"",children:"-- Sélectionnez une région --"}),a.map(e=>s.jsx("option",{value:e.region,children:e.region},e.region))]})]}):s.jsx("p",{children:"Aucune région disponible pour cette/ces province(s)."})},$={wrapper:{display:"flex",alignItems:"center",border:"1px solid #e5e7eb",borderRadius:"12px",overflow:"hidden",fontFamily:"Inter, sans-serif",width:"fit-content",backgroundColor:"#fff",marginBottom:"1rem"},label:{backgroundColor:"#f3f4f6",padding:"8px 12px",color:"#374151",fontWeight:"500",borderRight:"1px solid #e5e7eb"},select:{padding:"8px 12px",border:"none",outline:"none",fontWeight:"500",color:"#374151",backgroundColor:"transparent",cursor:"pointer",fontSize:"14px"}},Ee=({provinces:t=[],onSelectionChange:n})=>{const[a,f]=l.useState([]),[d,p]=l.useState({});l.useEffect(()=>{(async()=>{const r=y().filter(u=>t.length===0||t.includes(u.province));f(r)})()},[t]);const i=async(e,c)=>{if(c){const r=await _(e);p(u=>{const h={...u,[e]:{name:e,districts:r}};return n&&n(h),h})}else p(r=>{const u={...r};return delete u[e],n&&n(u),u})};return s.jsx("div",{children:a.length>0?a.map(e=>s.jsx("div",{children:s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",onChange:c=>i(e.region,c.target.checked),checked:!!d[e.region]}),e.region]})},e.region)):s.jsx("p",{children:"Aucune région disponible pour cette/ces province(s)."})})},Se=({provinces:t=[],onSelectionChange:n})=>{const[a,f]=l.useState([]),[d,p]=l.useState("");l.useEffect(()=>{(async()=>{const r=y().filter(u=>t.length===0||t.includes(u.province));f(r)})()},[t]);const i=async e=>{p(e);const c=await _(e),r={[e]:{name:e,districts:c}};n&&n(r)};return s.jsx("div",{children:a.length>0?a.map(e=>s.jsx("div",{children:s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:"region",value:e.region,onChange:()=>i(e.region),checked:d===e.region}),e.region]})},e.region)):s.jsx("p",{children:"Aucune région disponible pour cette/ces province(s)."})})},Pe=({provinces:t=[],onRegionSelected:n,renderRegions:a,renderDistricts:f})=>{const[d,p]=l.useState([]),[i,e]=l.useState(null),[c,r]=l.useState([]);l.useEffect(()=>{(async()=>{const R=y().filter(I=>t.length===0||t.includes(I.province));p(R)})()},[t]);const u=async h=>{e(h);const b=await _(h);r(b),n&&n(h,b)};return s.jsxs("div",{children:[a&&a(d,u),i&&f&&f(i,c)]})},we=({onSelectionChange:t,renderRegionsAndDistricts:n})=>{const[a,f]=l.useState([]),[d,p]=l.useState(null),[i,e]=l.useState([]);l.useEffect(()=>{(()=>{const u=Object.entries(P()).map(([h,b])=>({name:h,regions:b}));f(u)})()},[]);const c=async r=>{const u=r.target.value;p(u);const h=await w(u),b=await Promise.all(h.map(async R=>({...R,districts:await _(R.region)})));e(b),t&&t(u,b)};return s.jsxs("div",{style:G.wrapper,children:[s.jsx("div",{style:G.label,children:"Province"}),s.jsxs("select",{value:d||"",onChange:c,style:G.select,children:[s.jsx("option",{value:"",children:"Choisissez une province"}),a.map(r=>s.jsx("option",{value:r.name,children:r.name},r.name))]})]})},G={wrapper:{display:"flex",alignItems:"center",border:"1px solid #e5e7eb",borderRadius:"12px",overflow:"hidden",fontFamily:"Inter, sans-serif",width:"fit-content",backgroundColor:"#fff",marginBottom:"1rem"},label:{backgroundColor:"#f3f4f6",padding:"8px 12px",color:"#374151",fontWeight:"500",borderRight:"1px solid #e5e7eb"},select:{padding:"8px 12px",border:"none",outline:"none",fontWeight:"500",color:"#374151",backgroundColor:"transparent",cursor:"pointer",fontSize:"14px"}},De=({onSelectionChange:t})=>{const[n,a]=l.useState([]),[f,d]=l.useState({});l.useEffect(()=>{(async()=>{const e=Object.entries(P()).map(([c,r])=>({name:c,regions:r}));a(e)})()},[]);const p=async(i,e)=>{if(e){const c=await w(i),r=await Promise.all(c.map(async u=>({...u,districts:await _(u.region)})));d(u=>{const h={...u,[i]:{name:i,regions:r}};return t&&t(h),h})}else d(c=>{const r={...c};return delete r[i],t&&t(r),r})};return s.jsx("div",{children:n.length>0?n.map(i=>s.jsx("div",{children:s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",onChange:e=>p(i.name,e.target.checked),checked:!!f[i.name]}),i.name]})},i.name)):s.jsx("p",{children:"Aucune province disponible."})})},Te=({onSelectionChange:t,renderRegionsAndDistricts:n})=>{const[a,f]=l.useState([]),[d,p]=l.useState(null),[i,e]=l.useState([]);l.useEffect(()=>{(async()=>{const u=Object.entries(P()).map(([h,b])=>({name:h,regions:b}));f(u)})()},[]);const c=async r=>{const u=r.target.value;p(u);const h=await w(u),b=await Promise.all(h.map(async R=>({...R,districts:await _(R.region)})));e(b),t&&t(u,b)};return s.jsxs("div",{children:[s.jsx("h3",{children:"Sélectionner une province :"}),a.map(r=>s.jsx("div",{children:s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:"province",value:r.name,onChange:c,checked:d===r.name}),r.name]})},r.name)),d&&n?n(d,i):s.jsx("div",{children:i.length>0?i.map((r,u)=>s.jsx("div",{children:s.jsx("pre",{children:JSON.stringify(r.districts,null,2)})},u)):s.jsx("p",{children:"Aucun district trouvé pour cette province."})})]})},Ce=({onProvinceSelected:t,renderProvinces:n,renderRegionsAndDistricts:a})=>{const[f,d]=l.useState([]),[p,i]=l.useState(null),[e,c]=l.useState([]);l.useEffect(()=>{(()=>{const h=Object.entries(P()).map(([b,R])=>({name:b,regions:R}));d(h)})()},[]);const r=async u=>{i(u);const h=await w(u),b=await Promise.all(h.map(async R=>({...R,districts:await _(R.region)})));c(b),t==null||t(u,b)};return s.jsxs(s.Fragment,{children:[n&&n(f,r),p&&(a==null?void 0:a(p,e))]})},Ie=({onSelectionChange:t})=>{var e;const[n,a]=l.useState([]),[f,d]=l.useState("");l.useEffect(()=>{(()=>{const r=T();a(r)})()},[]);const p=c=>{const r=c.target.value;d(r);const u=n.find(h=>h.district===r);t&&t(u)},i=f&&((e=n.find(c=>c.district===f))==null?void 0:e.zip_code);return s.jsxs("div",{style:{display:"flex",alignItems:"center",border:"1px solid #e5e7eb",borderRadius:"12px",overflow:"hidden",fontFamily:"Inter, sans-serif",width:"fit-content",backgroundColor:"#fff"},children:[s.jsx("div",{style:{backgroundColor:"#f3f4f6",padding:"8px 12px",color:"#374151",fontWeight:"500",borderRight:"1px solid #e5e7eb"},children:i||"ZIP"}),s.jsxs("select",{value:f,onChange:p,style:{padding:"8px 12px",border:"none",outline:"none",fontWeight:"500",color:"#374151",backgroundColor:"transparent",cursor:"pointer",fontSize:"14px"},children:[s.jsx("option",{value:"",children:"-- Sélectionner un district --"}),n.map(c=>s.jsx("option",{value:c.district,children:c.district},c.district))]})]})},Oe=({onSelectionChange:t})=>{const[n,a]=l.useState([]),[f,d]=l.useState({});l.useEffect(()=>{(async()=>{const e=T();a(e)})()},[]);const p=(i,e)=>{d(c=>{const r={...c},u=n.find(h=>h.district===i);return e?r[i]=u:delete r[i],t&&t(Object.values(r)),r})};return s.jsx("div",{children:n.length>0?n.map(i=>s.jsx("div",{children:s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",onChange:e=>p(i.district,e.target.checked),checked:!!f[i.district]}),i.district]})},i.district)):s.jsx("p",{children:"Aucun district disponible."})})},Be=({onSelectionChange:t})=>{const[n,a]=l.useState([]),[f,d]=l.useState("");l.useEffect(()=>{(()=>{const e=T();a(e)})()},[]);const p=i=>{const e=i.target.value;d(e);const c=n.find(r=>r.district===e);t&&t(c)};return s.jsx("div",{children:n.map(i=>s.jsx("div",{children:s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:"district",value:i.district,onChange:p,checked:f===i.district}),i.district]})},i.district))})},Me=({onDistrictSelected:t,renderDistricts:n})=>{const[a,f]=l.useState([]);l.useEffect(()=>{(async()=>{const i=y();let e=[];for(const c of i){const r=await _(c.region);e=[...e,...r]}f(e)})()},[]);const d=p=>{t==null||t(p)};return s.jsx(s.Fragment,{children:n&&n(a,d)})},Fe=({regions:t=[],onSelectionChange:n})=>{const[a,f]=l.useState([]),[d,p]=l.useState("");l.useEffect(()=>{let e=[];t.forEach(c=>{const r=_(c);e=[...e,...r]}),f(e)},[t]);const i=e=>{const c=e.target.value;p(c);const r=a.find(u=>u.district===c);n&&n(r||null)};return s.jsxs("div",{style:{display:"flex",alignItems:"center",border:"1px solid #e5e7eb",borderRadius:"12px",overflow:"hidden",fontFamily:"Inter, sans-serif",width:"fit-content",backgroundColor:"#fff"},children:[s.jsx("div",{style:{backgroundColor:"#f3f4f6",padding:"8px 12px",color:"#374151",fontWeight:"500",borderRight:"1px solid #e5e7eb"},children:"District"}),s.jsxs("select",{value:d,onChange:i,style:{padding:"8px 12px",border:"none",outline:"none",fontWeight:"500",color:"#374151",backgroundColor:"transparent",cursor:"pointer",fontSize:"14px"},children:[s.jsx("option",{value:"",children:"-- Sélectionner un district --"}),a.map(e=>s.jsxs("option",{value:e.district,children:[e.district," (",e.province,")"]},e.district))]})]})},We=({regions:t=[],onSelectionChange:n})=>{const[a,f]=l.useState([]),[d,p]=l.useState({});l.useEffect(()=>{let e=[];t.forEach(c=>{const r=_(c);e=[...e,...r]}),f(e)},[t]);const i=(e,c)=>{p(r=>{const u={...r},h=a.find(b=>b.district===e);return c?u[e]=h:delete u[e],n&&n(Object.values(u)),u})};return s.jsx("div",{children:a.length>0?a.map(e=>s.jsx("div",{children:s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",onChange:c=>i(e.district,c.target.checked),checked:!!d[e.district]}),e.district," (",e.province,")"]})},e.district)):s.jsx("p",{children:"Aucun district trouvé pour les régions sélectionnées."})})},Le=({provinces:t=[],onSelectionChange:n})=>{const[a,f]=l.useState([]),[d,p]=l.useState("");l.useEffect(()=>{(async()=>{const r=y().filter(u=>t.length===0||t.includes(u.province));f(r)})()},[t]);const i=async e=>{p(e);const c=await _(e),r={[e]:{name:e,districts:c}};n&&n(r)};return s.jsx("div",{children:a.length>0?a.map(e=>s.jsx("div",{children:s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:"region",value:e.region,onChange:()=>i(e.region),checked:d===e.region}),e.region]})},e.region)):s.jsx("p",{children:"Aucune région disponible pour cette/ces province(s)."})})},Ye=({regions:t=[],children:n,onSelectionChange:a})=>{const[f,d]=l.useState([]);return l.useEffect(()=>{let p=[];t.forEach(i=>{const e=_(i);p=[...p,...e]}),d(p)},[t]),n({districts:f,onSelectionChange:a})},$e=({provinces:t=[],onSelectionChange:n})=>{const[a,f]=l.useState([]),[d,p]=l.useState(null);l.useEffect(()=>{let e=[];t.forEach(c=>{const r=C(c);e=[...e,...r]}),f(e)},[t]);const i=e=>{const c=e.target.value,r=a.find(u=>u.district===c);p(r||null),n&&n(r||null)};return s.jsxs("div",{style:{fontFamily:"Inter, sans-serif"},children:[s.jsx("label",{style:{display:"block",marginBottom:"0.5rem",fontWeight:500},children:"Choisissez un district :"}),s.jsxs("div",{style:{display:"flex",alignItems:"center",border:"1px solid #e5e7eb",borderRadius:"12px",overflow:"hidden",backgroundColor:"#fff",width:"fit-content"},children:[s.jsx("div",{style:{backgroundColor:"#f3f4f6",padding:"8px 12px",color:"#374151",fontWeight:"500",borderRight:"1px solid #e5e7eb",minWidth:"50px",textAlign:"center"},children:(d==null?void 0:d.zip_code)||"ZIP"}),s.jsxs("select",{value:(d==null?void 0:d.district)||"",onChange:i,style:{padding:"8px 12px",border:"none",outline:"none",fontWeight:"500",color:"#374151",backgroundColor:"transparent",cursor:"pointer",fontSize:"14px"},children:[s.jsx("option",{value:"",children:"-- Sélectionner --"}),a.map(e=>s.jsxs("option",{value:e.district,children:[e.district," (",e.region,")"]},e.district))]})]})]})},Ge=({provinces:t=[],onSelectionChange:n})=>{const[a,f]=l.useState([]),[d,p]=l.useState({});l.useEffect(()=>{(async()=>{const r=y().filter(u=>t.length===0||t.includes(u.province));f(r)})()},[t]);const i=async(e,c)=>{if(c){const r=await _(e);p(u=>{const h={...u,[e]:{name:e,districts:r}};return n&&n(h),h})}else p(r=>{const u={...r};return delete u[e],n&&n(u),u})};return s.jsx("div",{children:a.length>0?a.map(e=>s.jsx("div",{children:s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",onChange:c=>i(e.region,c.target.checked),checked:!!d[e.region]}),e.region]})},e.region)):s.jsx("p",{children:"Aucune région disponible pour cette/ces province(s)."})})},Ve=({provinces:t=[],onSelectionChange:n})=>{const[a,f]=l.useState([]),[d,p]=l.useState("");l.useEffect(()=>{let e=[];t.forEach(c=>{const r=C(c);e=[...e,...r]}),f(e)},[t]);const i=e=>{p(e);const c=a.find(r=>r.district===e);n&&n(c)};return s.jsx("div",{children:a.map(e=>s.jsxs("label",{style:{display:"block"},children:[s.jsx("input",{type:"radio",name:"district",value:e.district,checked:d===e.district,onChange:()=>i(e.district)}),e.district," (",e.region,")"]},e.district))})},He=({provinces:t=[],children:n,onSelectionChange:a})=>{const[f,d]=l.useState([]);return l.useEffect(()=>{let p=[];t.forEach(i=>{const e=C(i);p=[...p,...e]}),d(p)},[t]),n({districts:f,onSelectionChange:a})};exports.DistrictByProvinceCheckboxList=Ge;exports.DistrictByProvinceDropdown=$e;exports.DistrictByProvinceRadioGroup=Ve;exports.DistrictByProvinceSelectorHeadless=He;exports.DistrictByRegionCheckboxList=We;exports.DistrictByRegionDropdown=Fe;exports.DistrictByRegionRadioGroup=Le;exports.DistrictByRegionSelectorHeadless=Ye;exports.DistrictCheckboxList=Oe;exports.DistrictDropdown=Ie;exports.DistrictRadioGroup=Be;exports.DistrictSelectorHeadless=Me;exports.ProvinceCheckboxList=De;exports.ProvinceDropdown=we;exports.ProvinceRadioGroup=Te;exports.ProvinceSelectorHeadless=Ce;exports.RegionByProvinceCheckboxList=Ee;exports.RegionByProvinceDropdown=Ae;exports.RegionByProvinceRadioGroup=Se;exports.RegionByProvinceSelectorHeadless=Pe;exports.RegionCheckboxList=je;exports.RegionDropdown=ye;exports.RegionRadioGroup=ze;exports.RegionSelectorHeadless=ke;exports.geoUtils=Re;