diff --git a/frontend/src/components/upload/ModalComponents.tsx b/frontend/src/components/upload/ModalComponents.tsx index 668497f07de84fa7856692270bed2be7c98d6824..9769a6b13c8464847be63beaf65b67d8ac761bf3 100644 --- a/frontend/src/components/upload/ModalComponents.tsx +++ b/frontend/src/components/upload/ModalComponents.tsx @@ -272,7 +272,6 @@ export function PreprocessingNotificationModal({ isOpen, preprocessingInfo, onCl interface PreprocessingModalProps { isOpen: boolean; - preprocessingFile: File | null; isPreprocessing: boolean; preprocessingProgress: string; onConfirm: () => void; @@ -281,7 +280,6 @@ interface PreprocessingModalProps { export function PreprocessingModal({ isOpen, - preprocessingFile, isPreprocessing, preprocessingProgress, onConfirm, diff --git a/frontend/src/components/upload/RatingSection.tsx b/frontend/src/components/upload/RatingSection.tsx index 68492a1ca46018256f326d0975d1c10daa8601de..ee6db1a8aab5d9f424cd3172822c9002878cab39 100644 --- a/frontend/src/components/upload/RatingSection.tsx +++ b/frontend/src/components/upload/RatingSection.tsx @@ -18,7 +18,6 @@ export default function RatingSection({ scores, onScoreChange, onConfirmRatings, - onEditRatings, }: RatingSectionProps) { // Don't render anything if ratings are confirmed if (isPerformanceConfirmed) { diff --git a/frontend/src/pages/AdminPage/AdminPage.tsx b/frontend/src/pages/AdminPage/AdminPage.tsx index 6ea01670c6a816a0eda249903ea31bd1655bb04f..2257dcca1e6912e55a33d016fc4faab511a0f228 100644 --- a/frontend/src/pages/AdminPage/AdminPage.tsx +++ b/frontend/src/pages/AdminPage/AdminPage.tsx @@ -41,7 +41,7 @@ interface SchemaData { title: string; version: string; created_at?: string; - schema: any; + schema: Record; } export default function AdminPage() { @@ -463,7 +463,7 @@ export default function AdminPage() { const errorData = await response.json(); alert(`Failed to toggle model availability: ${errorData.error || 'Unknown error'}`); } - } catch (_error) { + } catch { alert('Error toggling model availability'); } }; @@ -499,7 +499,7 @@ export default function AdminPage() { const errorData = await response.json(); alert(`Failed to set fallback model: ${errorData.detail || 'Unknown error'}`); } - } catch (error) { + } catch { alert('Error setting fallback model'); } }; @@ -548,7 +548,7 @@ Model "${newModelData.label}" added successfully! const errorData = await response.json(); alert(`Failed to add model: ${errorData.detail || 'Unknown error'}`); } - } catch (error) { + } catch { alert('Error adding model'); } }; @@ -1315,7 +1315,7 @@ Model "${newModelData.label}" added successfully! const response = await fetch('/api/models'); if (response.ok) { const data = await response.json(); - const results = `✅ API connection successful!\n\nFound ${data.models?.length || 0} models in database.\n\nAvailable models:\n${(data.models || []).filter((m: any) => m.is_available).map((m: any) => `- ${m.label} (${m.m_code})`).join('\n') || 'None'}`; + const results = `✅ API connection successful!\n\nFound ${data.models?.length || 0} models in database.\n\nAvailable models:\n${(data.models || []).filter((m: Record) => m.is_available).map((m: Record) => `- ${m.label} (${m.m_code})`).join('\n') || 'None'}`; setTestResults(results); } else { const results = `❌ API connection failed: HTTP ${response.status}`; @@ -1614,7 +1614,7 @@ Model "${newModelData.label}" added successfully! try { const parsedSchema = JSON.parse(e.target.value); setNewSchemaData(prev => ({ ...prev, schema: parsedSchema })); - } catch (error) { + } catch { // Invalid JSON, don't update } }} diff --git a/py_backend/static/assets/AdminPage-Ddcg9yuB.js b/py_backend/static/assets/AdminPage-0qyl8wHV.js similarity index 95% rename from py_backend/static/assets/AdminPage-Ddcg9yuB.js rename to py_backend/static/assets/AdminPage-0qyl8wHV.js index 3886e7c3b98d85b7b1c60c361381bf10cd3892e3..e1ae30fccf3641763611c59074091153e42000ec 100644 --- a/py_backend/static/assets/AdminPage-Ddcg9yuB.js +++ b/py_backend/static/assets/AdminPage-0qyl8wHV.js @@ -1,4 +1,4 @@ -import{r as t,j as a,N as K,H as Je,O as m,z as _,I as re,_ as Ge,n as i,J as b}from"./index-DieRAFRn.js";import{u as Ve}from"./useAdmin-SWj4UX1Y.js";const We="_adminContainer_j11pf_5",qe="_adminHeader_j11pf_13",Ke="_adminSection_j11pf_20",Ye="_modelSelectionArea_j11pf_29",Qe="_modelSelectionRow_j11pf_36",Xe="_modelsTable_j11pf_89",Ze="_promptSubsection_j11pf_97",ea="_promptSubsectionTitle_j11pf_109",aa="_modelCode_j11pf_152",la="_modelId_j11pf_157",sa="_modelActions_j11pf_163",oa="_addModelButtonContainer_j11pf_169",ta="_addModelForm_j11pf_177",ia="_addModelFormTitle_j11pf_185",da="_addModelFormGrid_j11pf_193",na="_addModelFormField_j11pf_206",ra="_addModelFormCheckbox_j11pf_250",ca="_addModelFormActions_j11pf_268",ma="_modalOverlay_j11pf_277",ha="_modalContent_j11pf_291",pa="_modalBody_j11pf_302",xa="_modalTitle_j11pf_312",ua="_modalText_j11pf_320",_a="_modalTextLeft_j11pf_332",ja="_modalButtons_j11pf_355",va="_modalForm_j11pf_363",ga="_formField_j11pf_372",fa="_formLabel_j11pf_376",ba="_formInput_j11pf_385",ya="_textarea_j11pf_407",l={adminContainer:We,adminHeader:qe,adminSection:Ke,modelSelectionArea:Ye,modelSelectionRow:Qe,modelsTable:Xe,promptSubsection:Ze,promptSubsectionTitle:ea,modelCode:aa,modelId:la,modelActions:sa,addModelButtonContainer:oa,addModelForm:ta,addModelFormTitle:ia,addModelFormGrid:da,addModelFormField:na,addModelFormCheckbox:ra,addModelFormActions:ca,modalOverlay:ma,modalContent:ha,modalBody:pa,modalTitle:xa,modalText:ua,modalTextLeft:_a,modalButtons:ja,modalForm:va,formField:ga,formLabel:fa,formInput:ba,textarea:ya},A="selectedVlmModel";function Sa(){const{isAuthenticated:j,isLoading:ce,login:me,logout:he,verifyToken:Y}=Ve(),[$,Q]=t.useState(""),[X,v]=t.useState(""),[Z,ee]=t.useState(!1),[I,y]=t.useState([]),[pe,N]=t.useState(""),[xe,C]=t.useState(""),[ae,P]=t.useState([]),[ue,E]=t.useState([]),[_e,L]=t.useState([]),[je,S]=t.useState(!1),[B,O]=t.useState(null),[D,g]=t.useState({schema_id:"",title:"",version:"",schema:{}}),[ve,k]=t.useState(!1),[ge,w]=t.useState(!1),[fe,U]=t.useState(null),[M,z]=t.useState(null),[n,r]=t.useState({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1}),[le,R]=t.useState(!1),[be,H]=t.useState(!1),[J,G]=t.useState(null),[o,c]=t.useState({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1,is_fallback:!1}),[ye,T]=t.useState(!1),[Ne,V]=t.useState(!1),[Ce,p]=t.useState(!1),[se,oe]=t.useState(""),[Se,ke]=t.useState(""),[we,x]=t.useState(""),[Me,F]=t.useState(""),u=t.useCallback(()=>{fetch("/api/models").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{if(console.log("Models data received:",e),e&&Array.isArray(e.models)){y(e.models);const s=localStorage.getItem(A);if(e.models.length>0)if(s==="random")N("random");else if(s&&e.models.find(d=>d.m_code===s&&d.is_available))N(s);else{const d=e.models.find(h=>h.is_available)||e.models[0];N(d.m_code),localStorage.setItem(A,d.m_code)}}else console.error("Expected models object but got:",e),y([])}).catch(e=>{console.error("Error fetching models:",e),y([])}),fetch("/api/admin/fallback-model",{headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}}).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{console.log("Fallback model data received:",e),e.fallback_model?C(e.fallback_model.m_code):C("")}).catch(e=>{console.error("Error fetching fallback model:",e),C("")})},[]),f=t.useCallback(()=>{console.log("=== fetchPrompts called ==="),fetch("/api/prompts").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{console.log("Prompts data received:",e),Array.isArray(e)?P(e):(console.error("Expected array but got:",e),P([])),console.log("State update triggered with:",e||[])}).catch(e=>{console.error("Error fetching prompts:",e),P([])})},[]),te=t.useCallback(()=>{fetch("/api/image-types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{console.log("Image types data received:",e),Array.isArray(e)?E(e):(console.error("Expected array but got:",e),E([]))}).catch(e=>{console.error("Error fetching image types:",e),E([])})},[]),W=t.useCallback(()=>{console.log("=== fetchSchemas called ==="),fetch("/api/schemas",{headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}}).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{console.log("Schemas data received:",e),Array.isArray(e)?L(e):(console.error("Expected array but got:",e),L([]))}).catch(e=>{console.error("Error fetching schemas:",e),L([])})},[]);t.useEffect(()=>{j&&(u(),f(),te(),W())},[j,u,f,te,W]),t.useEffect(()=>{j&&Y()},[j,Y]);const ie=e=>{z(e),r({p_code:e.p_code,label:e.label||"",metadata_instructions:e.metadata_instructions||"",image_type:e.image_type||"crisis_map",is_active:e.is_active||!1}),k(!0)},Te=async()=>{try{if(!M){alert("No prompt selected for editing");return}const e=await fetch(`/api/prompts/${M.p_code}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:n.label,metadata_instructions:n.metadata_instructions,image_type:n.image_type,is_active:n.is_active})});if(e.ok)f(),k(!1),z(null),r({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1});else{const s=await e.json();alert(`Failed to update prompt: ${s.error||"Unknown error"}`)}}catch{alert("Error updating prompt")}},de=async(e,s)=>{try{const d=await fetch(`/api/prompts/${e}/toggle-active?image_type=${s}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(d.ok)f();else{const h=await d.json();alert(`Failed to toggle prompt active status: ${h.detail||"Unknown error"}`)}}catch{alert("Error toggling prompt active status")}},ne=e=>{U(e),r({p_code:"",label:"",metadata_instructions:"",image_type:e,is_active:!1}),w(!0)},Fe=async()=>{try{const e=await fetch("/api/prompts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(e.ok)f(),w(!1),U(null),r({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1});else{const s=await e.json();alert(`Failed to create prompt: ${s.detail||"Unknown error"}`)}}catch{alert("Error creating prompt")}},Ae=e=>{O(e),g({schema_id:e.schema_id,title:e.title,version:e.version,schema:e.schema}),S(!0)},$e=async()=>{try{if(!B){alert("No schema selected for editing");return}const e=await fetch(`/api/schemas/${B.schema_id}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(D)});if(e.ok)W(),S(!1),O(null),g({schema_id:"",title:"",version:"",schema:{}});else{const s=await e.json();alert(`Failed to save schema: ${s.detail||"Unknown error"}`)}}catch(e){console.error("Error saving schema:",e),alert("Error saving schema")}},Ie=()=>{S(!1),O(null),g({schema_id:"",title:"",version:"",schema:{}})},Pe=async(e,s)=>{try{const d=await fetch(`/api/models/${e}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_available:!s})});if(d.ok)y(h=>(h||[]).map(q=>q.m_code===e?{...q,is_available:!s}:q));else{const h=await d.json();alert(`Failed to toggle model availability: ${h.error||"Unknown error"}`)}}catch{alert("Error toggling model availability")}},Ee=e=>{N(e),e==="random"?localStorage.setItem(A,"random"):localStorage.setItem(A,e)},Le=async e=>{try{const s=await fetch(`/api/admin/models/${e}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify({is_fallback:!0})});if(s.ok)C(e),u();else{const d=await s.json();alert(`Failed to set fallback model: ${d.detail||"Unknown error"}`)}}catch{alert("Error setting fallback model")}},Be=async()=>{try{const e=await fetch("/api/admin/models",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(o)});if(e.ok){const s=` +import{r as t,j as a,N as K,H as Je,O as m,z as j,I as re,_ as Ge,n as i,J as b}from"./index-B0L3qvtx.js";import{u as Ve}from"./useAdmin-DN0iYnPm.js";const We="_adminContainer_j11pf_5",qe="_adminHeader_j11pf_13",Ke="_adminSection_j11pf_20",Ye="_modelSelectionArea_j11pf_29",Qe="_modelSelectionRow_j11pf_36",Xe="_modelsTable_j11pf_89",Ze="_promptSubsection_j11pf_97",ea="_promptSubsectionTitle_j11pf_109",aa="_modelCode_j11pf_152",la="_modelId_j11pf_157",sa="_modelActions_j11pf_163",oa="_addModelButtonContainer_j11pf_169",ta="_addModelForm_j11pf_177",ia="_addModelFormTitle_j11pf_185",da="_addModelFormGrid_j11pf_193",na="_addModelFormField_j11pf_206",ra="_addModelFormCheckbox_j11pf_250",ca="_addModelFormActions_j11pf_268",ma="_modalOverlay_j11pf_277",ha="_modalContent_j11pf_291",pa="_modalBody_j11pf_302",xa="_modalTitle_j11pf_312",ua="_modalText_j11pf_320",ja="_modalTextLeft_j11pf_332",_a="_modalButtons_j11pf_355",va="_modalForm_j11pf_363",ga="_formField_j11pf_372",fa="_formLabel_j11pf_376",ba="_formInput_j11pf_385",ya="_textarea_j11pf_407",l={adminContainer:We,adminHeader:qe,adminSection:Ke,modelSelectionArea:Ye,modelSelectionRow:Qe,modelsTable:Xe,promptSubsection:Ze,promptSubsectionTitle:ea,modelCode:aa,modelId:la,modelActions:sa,addModelButtonContainer:oa,addModelForm:ta,addModelFormTitle:ia,addModelFormGrid:da,addModelFormField:na,addModelFormCheckbox:ra,addModelFormActions:ca,modalOverlay:ma,modalContent:ha,modalBody:pa,modalTitle:xa,modalText:ua,modalTextLeft:ja,modalButtons:_a,modalForm:va,formField:ga,formLabel:fa,formInput:ba,textarea:ya},A="selectedVlmModel";function Sa(){const{isAuthenticated:_,isLoading:ce,login:me,logout:he,verifyToken:Y}=Ve(),[$,Q]=t.useState(""),[X,v]=t.useState(""),[Z,ee]=t.useState(!1),[I,y]=t.useState([]),[pe,N]=t.useState(""),[xe,C]=t.useState(""),[ae,P]=t.useState([]),[ue,E]=t.useState([]),[je,L]=t.useState([]),[_e,S]=t.useState(!1),[B,O]=t.useState(null),[D,g]=t.useState({schema_id:"",title:"",version:"",schema:{}}),[ve,k]=t.useState(!1),[ge,w]=t.useState(!1),[fe,U]=t.useState(null),[M,z]=t.useState(null),[n,r]=t.useState({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1}),[le,R]=t.useState(!1),[be,H]=t.useState(!1),[J,G]=t.useState(null),[o,c]=t.useState({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1,is_fallback:!1}),[ye,T]=t.useState(!1),[Ne,V]=t.useState(!1),[Ce,p]=t.useState(!1),[se,oe]=t.useState(""),[Se,ke]=t.useState(""),[we,x]=t.useState(""),[Me,F]=t.useState(""),u=t.useCallback(()=>{fetch("/api/models").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{if(console.log("Models data received:",e),e&&Array.isArray(e.models)){y(e.models);const s=localStorage.getItem(A);if(e.models.length>0)if(s==="random")N("random");else if(s&&e.models.find(d=>d.m_code===s&&d.is_available))N(s);else{const d=e.models.find(h=>h.is_available)||e.models[0];N(d.m_code),localStorage.setItem(A,d.m_code)}}else console.error("Expected models object but got:",e),y([])}).catch(e=>{console.error("Error fetching models:",e),y([])}),fetch("/api/admin/fallback-model",{headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}}).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{console.log("Fallback model data received:",e),e.fallback_model?C(e.fallback_model.m_code):C("")}).catch(e=>{console.error("Error fetching fallback model:",e),C("")})},[]),f=t.useCallback(()=>{console.log("=== fetchPrompts called ==="),fetch("/api/prompts").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{console.log("Prompts data received:",e),Array.isArray(e)?P(e):(console.error("Expected array but got:",e),P([])),console.log("State update triggered with:",e||[])}).catch(e=>{console.error("Error fetching prompts:",e),P([])})},[]),te=t.useCallback(()=>{fetch("/api/image-types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{console.log("Image types data received:",e),Array.isArray(e)?E(e):(console.error("Expected array but got:",e),E([]))}).catch(e=>{console.error("Error fetching image types:",e),E([])})},[]),W=t.useCallback(()=>{console.log("=== fetchSchemas called ==="),fetch("/api/schemas",{headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}}).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{console.log("Schemas data received:",e),Array.isArray(e)?L(e):(console.error("Expected array but got:",e),L([]))}).catch(e=>{console.error("Error fetching schemas:",e),L([])})},[]);t.useEffect(()=>{_&&(u(),f(),te(),W())},[_,u,f,te,W]),t.useEffect(()=>{_&&Y()},[_,Y]);const ie=e=>{z(e),r({p_code:e.p_code,label:e.label||"",metadata_instructions:e.metadata_instructions||"",image_type:e.image_type||"crisis_map",is_active:e.is_active||!1}),k(!0)},Te=async()=>{try{if(!M){alert("No prompt selected for editing");return}const e=await fetch(`/api/prompts/${M.p_code}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:n.label,metadata_instructions:n.metadata_instructions,image_type:n.image_type,is_active:n.is_active})});if(e.ok)f(),k(!1),z(null),r({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1});else{const s=await e.json();alert(`Failed to update prompt: ${s.error||"Unknown error"}`)}}catch{alert("Error updating prompt")}},de=async(e,s)=>{try{const d=await fetch(`/api/prompts/${e}/toggle-active?image_type=${s}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(d.ok)f();else{const h=await d.json();alert(`Failed to toggle prompt active status: ${h.detail||"Unknown error"}`)}}catch{alert("Error toggling prompt active status")}},ne=e=>{U(e),r({p_code:"",label:"",metadata_instructions:"",image_type:e,is_active:!1}),w(!0)},Fe=async()=>{try{const e=await fetch("/api/prompts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(e.ok)f(),w(!1),U(null),r({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1});else{const s=await e.json();alert(`Failed to create prompt: ${s.detail||"Unknown error"}`)}}catch{alert("Error creating prompt")}},Ae=e=>{O(e),g({schema_id:e.schema_id,title:e.title,version:e.version,schema:e.schema}),S(!0)},$e=async()=>{try{if(!B){alert("No schema selected for editing");return}const e=await fetch(`/api/schemas/${B.schema_id}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(D)});if(e.ok)W(),S(!1),O(null),g({schema_id:"",title:"",version:"",schema:{}});else{const s=await e.json();alert(`Failed to save schema: ${s.detail||"Unknown error"}`)}}catch(e){console.error("Error saving schema:",e),alert("Error saving schema")}},Ie=()=>{S(!1),O(null),g({schema_id:"",title:"",version:"",schema:{}})},Pe=async(e,s)=>{try{const d=await fetch(`/api/models/${e}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_available:!s})});if(d.ok)y(h=>(h||[]).map(q=>q.m_code===e?{...q,is_available:!s}:q));else{const h=await d.json();alert(`Failed to toggle model availability: ${h.error||"Unknown error"}`)}}catch{alert("Error toggling model availability")}},Ee=e=>{N(e),e==="random"?localStorage.setItem(A,"random"):localStorage.setItem(A,e)},Le=async e=>{try{const s=await fetch(`/api/admin/models/${e}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify({is_fallback:!0})});if(s.ok)C(e),u();else{const d=await s.json();alert(`Failed to set fallback model: ${d.detail||"Unknown error"}`)}}catch{alert("Error setting fallback model")}},Be=async()=>{try{const e=await fetch("/api/admin/models",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(o)});if(e.ok){const s=` Model "${o.label}" added successfully! ⚠️ IMPORTANT: Model will NOT work until you complete these steps: @@ -8,7 +8,7 @@ Model "${o.label}" added successfully! 2. 📝 Verify model_id format. 3. 📚 Check model specific documentation for details. - `;ke(s),V(!0),R(!1),c({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1,is_fallback:!1}),u()}else{const s=await e.json();alert(`Failed to add model: ${s.detail||"Unknown error"}`)}}catch{alert("Error adding model")}},Oe=e=>{G(e),c({m_code:e.m_code,label:e.label,model_type:e.model_type||"custom",provider:e.provider||e.config?.provider||"huggingface",model_id:e.model_id||e.config?.model_id||e.m_code,is_available:e.is_available,is_fallback:e.is_fallback}),H(!0)},De=async()=>{try{console.log("Updating model with data:",o);const e={label:o.label,model_type:o.model_type,provider:o.provider,model_id:o.model_id,is_available:o.is_available};if(console.log("Update payload:",e),!J){alert("No model selected for editing");return}const s=await fetch(`/api/admin/models/${J.m_code}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(e)});if(console.log("Update response status:",s.status),s.ok){const d=await s.json();console.log("Update successful:",d),H(!1),G(null),c({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1,is_fallback:!1}),console.log("Refreshing models..."),u()}else{const d=await s.json();console.error("Update failed:",d),alert(`Failed to update model: ${d.detail||"Unknown error"}`)}}catch(e){console.error("Update error:",e),alert("Error updating model")}},Ue=async e=>{oe(e),T(!0)},ze=async()=>{try{const e=await fetch(`/api/admin/models/${se}`,{method:"DELETE",headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}});if(e.ok)T(!1),oe(""),u();else{const s=await e.json();alert(`Failed to delete model: ${s.detail||"Unknown error"}`)}}catch{alert("Error deleting model")}},Re=async e=>{if(e.preventDefault(),!$.trim()){v("Please enter a password");return}ee(!0),v("");try{await me($)||v("Invalid password")}catch{v("Login failed. Please try again.")}finally{ee(!1)}},He=()=>{he(),Q(""),v("")};return ce?a.jsx(K,{children:a.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-ifrcRed mx-auto mb-4"}),a.jsx("p",{className:"text-gray-600",children:"Loading..."})]})})}):j?a.jsxs(K,{children:[a.jsxs("div",{className:l.adminContainer,children:[a.jsx("div",{className:l.adminHeader,children:a.jsx(i,{name:"logout",variant:"secondary",onClick:He,children:"Logout"})}),a.jsxs("div",{className:l.adminSection,children:[a.jsx(_,{heading:"VLM Model Selection",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsxs("div",{className:l.modelSelectionArea,children:[a.jsx("p",{className:"text-gray-700",children:"Select which Vision Language Model to use for caption generation."}),a.jsxs("div",{className:l.modelSelectionRow,children:[a.jsx(b,{label:"Model",name:"selected-model",value:pe,onChange:e=>Ee(e||""),options:[{value:"random",label:"Random"},...(I||[]).filter(e=>e.is_available).map(e=>({value:e.m_code,label:e.label}))],keySelector:e=>e.value,labelSelector:e=>e.label}),a.jsx(b,{label:"Fallback",name:"fallback-model",value:xe,onChange:e=>Le(e||""),options:[{value:"",label:"No fallback (use STUB_MODEL)"},...(I||[]).filter(e=>e.is_available).map(e=>({value:e.m_code,label:e.label}))],keySelector:e=>e.value,labelSelector:e=>e.label})]})]})}),a.jsx(_,{heading:"Model Management",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsxs("div",{className:l.modelManagementArea,children:[a.jsx("div",{className:l.modelsTable,children:a.jsxs("table",{children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Code"}),a.jsx("th",{children:"Label"}),a.jsx("th",{children:"Provider"}),a.jsx("th",{children:"Model ID"}),a.jsx("th",{children:"Available"}),a.jsx("th",{children:"Actions"})]})}),a.jsx("tbody",{children:(I||[]).map(e=>a.jsxs("tr",{children:[a.jsx("td",{className:l.modelCode,children:e.m_code}),a.jsx("td",{children:e.label}),a.jsx("td",{children:e.provider||e.config?.provider||"huggingface"}),a.jsx("td",{className:l.modelId,children:e.model_id||e.config?.model_id||e.m_code||"N/A"}),a.jsx("td",{children:a.jsx(i,{name:`toggle-${e.m_code}`,variant:e.is_available?"primary":"secondary",size:1,onClick:()=>Pe(e.m_code,e.is_available),children:e.is_available?"Enabled":"Disabled"})}),a.jsx("td",{children:a.jsxs("div",{className:l.modelActions,children:[a.jsx(i,{name:`edit-${e.m_code}`,variant:"secondary",size:1,onClick:()=>Oe(e),children:"Edit"}),a.jsx(i,{name:`delete-${e.m_code}`,variant:"secondary",size:1,onClick:()=>Ue(e.m_code),children:"Delete"})]})})]},e.m_code))})]})}),!le&&a.jsx("div",{className:l.addModelButtonContainer,children:a.jsx(i,{name:"show-add-form",variant:"primary",onClick:()=>R(!0),children:"Add New Model"})}),le&&a.jsxs("div",{className:l.addModelForm,children:[a.jsx("h4",{className:l.addModelFormTitle,children:"Add New Model"}),a.jsxs("div",{className:l.addModelFormGrid,children:[a.jsx("div",{className:l.addModelFormField,children:a.jsx(m,{label:"Model Code",name:"model-code",value:o.m_code,onChange:e=>c({...o,m_code:e||""}),placeholder:"e.g., NEW_MODEL_123"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(m,{label:"Label",name:"model-label",value:o.label,onChange:e=>c({...o,label:e||""}),placeholder:"e.g., New Model Name"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(b,{label:"Provider",name:"model-provider",value:o.provider,onChange:e=>c({...o,provider:e||"huggingface"}),options:[{value:"huggingface",label:"HuggingFace"},{value:"openai",label:"OpenAI"},{value:"google",label:"Google"}],keySelector:e=>e.value,labelSelector:e=>e.label})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(m,{label:"Model ID",name:"model-id",value:o.model_id,onChange:e=>c({...o,model_id:e||""}),placeholder:"e.g., org/model-name"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsxs("div",{className:l.addModelFormCheckbox,children:[a.jsx("input",{type:"checkbox",checked:o.is_available,onChange:e=>c({...o,is_available:e.target.checked})}),a.jsx("span",{children:"Available for use"})]})})]}),a.jsxs("div",{className:l.addModelFormActions,children:[a.jsx(i,{name:"save-model",variant:"primary",onClick:Be,disabled:!o.m_code||!o.label||!o.model_id,children:"Save Model"}),a.jsx(i,{name:"cancel-add",variant:"secondary",onClick:()=>R(!1),children:"Cancel"})]})]}),be&&a.jsxs("div",{className:l.addModelForm,children:[a.jsxs("h4",{className:l.addModelFormTitle,children:["Edit Model: ",J?.label]}),a.jsxs("div",{className:l.addModelFormGrid,children:[a.jsx("div",{className:l.addModelFormField,children:a.jsx(m,{label:"Model Code",name:"model-code",value:o.m_code,onChange:e=>c({...o,m_code:e||""}),placeholder:"e.g., NEW_MODEL_123",disabled:!0})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(m,{label:"Label",name:"model-label",value:o.label,onChange:e=>c({...o,label:e||""}),placeholder:"e.g., New Model Name"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(b,{label:"Provider",name:"model-provider",value:o.provider,onChange:e=>c({...o,provider:e||"huggingface"}),options:[{value:"huggingface",label:"HuggingFace"},{value:"openai",label:"OpenAI"},{value:"google",label:"Google"}],keySelector:e=>e.value,labelSelector:e=>e.label})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(m,{label:"Model ID",name:"model-id",value:o.model_id,onChange:e=>c({...o,model_id:e||""}),placeholder:"e.g., org/model-name"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsxs("div",{className:l.addModelFormCheckbox,children:[a.jsx("input",{type:"checkbox",checked:o.is_available,onChange:e=>c({...o,is_available:e.target.checked})}),a.jsx("span",{children:"Available for use"})]})})]}),a.jsxs("div",{className:l.addModelFormActions,children:[a.jsx(i,{name:"update-model",variant:"primary",onClick:De,disabled:!o.m_code||!o.label||!o.model_id,children:"Update Model"}),a.jsx(i,{name:"cancel-edit",variant:"secondary",onClick:()=>{H(!1),G(null),c({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1,is_fallback:!1})},children:"Cancel"})]})]})]})}),a.jsx(_,{heading:"Prompt Management",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsxs("div",{className:l.modelManagementArea,children:[a.jsxs("div",{className:l.promptSubsection,children:[a.jsx("h4",{className:l.promptSubsectionTitle,children:"Crisis Maps"}),a.jsx("div",{className:l.modelsTable,children:a.jsxs("table",{children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Code"}),a.jsx("th",{children:"Label"}),a.jsx("th",{children:"Status"}),a.jsx("th",{children:"Actions"})]})}),a.jsx("tbody",{children:(ae||[]).filter(e=>e.image_type==="crisis_map").sort((e,s)=>e.p_code.localeCompare(s.p_code)).map(e=>a.jsxs("tr",{children:[a.jsx("td",{className:l.modelCode,children:e.p_code}),a.jsx("td",{className:l.promptLabel,children:e.label||"No label"}),a.jsx("td",{children:a.jsx(i,{name:`toggle-crisis-${e.p_code}`,variant:e.is_active?"primary":"secondary",size:1,onClick:()=>de(e.p_code,"crisis_map"),children:e.is_active?"Active":"Inactive"})}),a.jsx("td",{children:a.jsxs("div",{className:l.modelActions,children:[a.jsx(i,{name:`view-${e.p_code}`,variant:"secondary",size:1,onClick:()=>{x(`=== Prompt Details === + `;ke(s),V(!0),R(!1),c({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1,is_fallback:!1}),u()}else{const s=await e.json();alert(`Failed to add model: ${s.detail||"Unknown error"}`)}}catch{alert("Error adding model")}},Oe=e=>{G(e),c({m_code:e.m_code,label:e.label,model_type:e.model_type||"custom",provider:e.provider||e.config?.provider||"huggingface",model_id:e.model_id||e.config?.model_id||e.m_code,is_available:e.is_available,is_fallback:e.is_fallback}),H(!0)},De=async()=>{try{console.log("Updating model with data:",o);const e={label:o.label,model_type:o.model_type,provider:o.provider,model_id:o.model_id,is_available:o.is_available};if(console.log("Update payload:",e),!J){alert("No model selected for editing");return}const s=await fetch(`/api/admin/models/${J.m_code}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(e)});if(console.log("Update response status:",s.status),s.ok){const d=await s.json();console.log("Update successful:",d),H(!1),G(null),c({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1,is_fallback:!1}),console.log("Refreshing models..."),u()}else{const d=await s.json();console.error("Update failed:",d),alert(`Failed to update model: ${d.detail||"Unknown error"}`)}}catch(e){console.error("Update error:",e),alert("Error updating model")}},Ue=async e=>{oe(e),T(!0)},ze=async()=>{try{const e=await fetch(`/api/admin/models/${se}`,{method:"DELETE",headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}});if(e.ok)T(!1),oe(""),u();else{const s=await e.json();alert(`Failed to delete model: ${s.detail||"Unknown error"}`)}}catch{alert("Error deleting model")}},Re=async e=>{if(e.preventDefault(),!$.trim()){v("Please enter a password");return}ee(!0),v("");try{await me($)||v("Invalid password")}catch{v("Login failed. Please try again.")}finally{ee(!1)}},He=()=>{he(),Q(""),v("")};return ce?a.jsx(K,{children:a.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-ifrcRed mx-auto mb-4"}),a.jsx("p",{className:"text-gray-600",children:"Loading..."})]})})}):_?a.jsxs(K,{children:[a.jsxs("div",{className:l.adminContainer,children:[a.jsx("div",{className:l.adminHeader,children:a.jsx(i,{name:"logout",variant:"secondary",onClick:He,children:"Logout"})}),a.jsxs("div",{className:l.adminSection,children:[a.jsx(j,{heading:"VLM Model Selection",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsxs("div",{className:l.modelSelectionArea,children:[a.jsx("p",{className:"text-gray-700",children:"Select which Vision Language Model to use for caption generation."}),a.jsxs("div",{className:l.modelSelectionRow,children:[a.jsx(b,{label:"Model",name:"selected-model",value:pe,onChange:e=>Ee(e||""),options:[{value:"random",label:"Random"},...(I||[]).filter(e=>e.is_available).map(e=>({value:e.m_code,label:e.label}))],keySelector:e=>e.value,labelSelector:e=>e.label}),a.jsx(b,{label:"Fallback",name:"fallback-model",value:xe,onChange:e=>Le(e||""),options:[{value:"",label:"No fallback (use STUB_MODEL)"},...(I||[]).filter(e=>e.is_available).map(e=>({value:e.m_code,label:e.label}))],keySelector:e=>e.value,labelSelector:e=>e.label})]})]})}),a.jsx(j,{heading:"Model Management",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsxs("div",{className:l.modelManagementArea,children:[a.jsx("div",{className:l.modelsTable,children:a.jsxs("table",{children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Code"}),a.jsx("th",{children:"Label"}),a.jsx("th",{children:"Provider"}),a.jsx("th",{children:"Model ID"}),a.jsx("th",{children:"Available"}),a.jsx("th",{children:"Actions"})]})}),a.jsx("tbody",{children:(I||[]).map(e=>a.jsxs("tr",{children:[a.jsx("td",{className:l.modelCode,children:e.m_code}),a.jsx("td",{children:e.label}),a.jsx("td",{children:e.provider||e.config?.provider||"huggingface"}),a.jsx("td",{className:l.modelId,children:e.model_id||e.config?.model_id||e.m_code||"N/A"}),a.jsx("td",{children:a.jsx(i,{name:`toggle-${e.m_code}`,variant:e.is_available?"primary":"secondary",size:1,onClick:()=>Pe(e.m_code,e.is_available),children:e.is_available?"Enabled":"Disabled"})}),a.jsx("td",{children:a.jsxs("div",{className:l.modelActions,children:[a.jsx(i,{name:`edit-${e.m_code}`,variant:"secondary",size:1,onClick:()=>Oe(e),children:"Edit"}),a.jsx(i,{name:`delete-${e.m_code}`,variant:"secondary",size:1,onClick:()=>Ue(e.m_code),children:"Delete"})]})})]},e.m_code))})]})}),!le&&a.jsx("div",{className:l.addModelButtonContainer,children:a.jsx(i,{name:"show-add-form",variant:"primary",onClick:()=>R(!0),children:"Add New Model"})}),le&&a.jsxs("div",{className:l.addModelForm,children:[a.jsx("h4",{className:l.addModelFormTitle,children:"Add New Model"}),a.jsxs("div",{className:l.addModelFormGrid,children:[a.jsx("div",{className:l.addModelFormField,children:a.jsx(m,{label:"Model Code",name:"model-code",value:o.m_code,onChange:e=>c({...o,m_code:e||""}),placeholder:"e.g., NEW_MODEL_123"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(m,{label:"Label",name:"model-label",value:o.label,onChange:e=>c({...o,label:e||""}),placeholder:"e.g., New Model Name"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(b,{label:"Provider",name:"model-provider",value:o.provider,onChange:e=>c({...o,provider:e||"huggingface"}),options:[{value:"huggingface",label:"HuggingFace"},{value:"openai",label:"OpenAI"},{value:"google",label:"Google"}],keySelector:e=>e.value,labelSelector:e=>e.label})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(m,{label:"Model ID",name:"model-id",value:o.model_id,onChange:e=>c({...o,model_id:e||""}),placeholder:"e.g., org/model-name"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsxs("div",{className:l.addModelFormCheckbox,children:[a.jsx("input",{type:"checkbox",checked:o.is_available,onChange:e=>c({...o,is_available:e.target.checked})}),a.jsx("span",{children:"Available for use"})]})})]}),a.jsxs("div",{className:l.addModelFormActions,children:[a.jsx(i,{name:"save-model",variant:"primary",onClick:Be,disabled:!o.m_code||!o.label||!o.model_id,children:"Save Model"}),a.jsx(i,{name:"cancel-add",variant:"secondary",onClick:()=>R(!1),children:"Cancel"})]})]}),be&&a.jsxs("div",{className:l.addModelForm,children:[a.jsxs("h4",{className:l.addModelFormTitle,children:["Edit Model: ",J?.label]}),a.jsxs("div",{className:l.addModelFormGrid,children:[a.jsx("div",{className:l.addModelFormField,children:a.jsx(m,{label:"Model Code",name:"model-code",value:o.m_code,onChange:e=>c({...o,m_code:e||""}),placeholder:"e.g., NEW_MODEL_123",disabled:!0})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(m,{label:"Label",name:"model-label",value:o.label,onChange:e=>c({...o,label:e||""}),placeholder:"e.g., New Model Name"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(b,{label:"Provider",name:"model-provider",value:o.provider,onChange:e=>c({...o,provider:e||"huggingface"}),options:[{value:"huggingface",label:"HuggingFace"},{value:"openai",label:"OpenAI"},{value:"google",label:"Google"}],keySelector:e=>e.value,labelSelector:e=>e.label})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(m,{label:"Model ID",name:"model-id",value:o.model_id,onChange:e=>c({...o,model_id:e||""}),placeholder:"e.g., org/model-name"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsxs("div",{className:l.addModelFormCheckbox,children:[a.jsx("input",{type:"checkbox",checked:o.is_available,onChange:e=>c({...o,is_available:e.target.checked})}),a.jsx("span",{children:"Available for use"})]})})]}),a.jsxs("div",{className:l.addModelFormActions,children:[a.jsx(i,{name:"update-model",variant:"primary",onClick:De,disabled:!o.m_code||!o.label||!o.model_id,children:"Update Model"}),a.jsx(i,{name:"cancel-edit",variant:"secondary",onClick:()=>{H(!1),G(null),c({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1,is_fallback:!1})},children:"Cancel"})]})]})]})}),a.jsx(j,{heading:"Prompt Management",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsxs("div",{className:l.modelManagementArea,children:[a.jsxs("div",{className:l.promptSubsection,children:[a.jsx("h4",{className:l.promptSubsectionTitle,children:"Crisis Maps"}),a.jsx("div",{className:l.modelsTable,children:a.jsxs("table",{children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Code"}),a.jsx("th",{children:"Label"}),a.jsx("th",{children:"Status"}),a.jsx("th",{children:"Actions"})]})}),a.jsx("tbody",{children:(ae||[]).filter(e=>e.image_type==="crisis_map").sort((e,s)=>e.p_code.localeCompare(s.p_code)).map(e=>a.jsxs("tr",{children:[a.jsx("td",{className:l.modelCode,children:e.p_code}),a.jsx("td",{className:l.promptLabel,children:e.label||"No label"}),a.jsx("td",{children:a.jsx(i,{name:`toggle-crisis-${e.p_code}`,variant:e.is_active?"primary":"secondary",size:1,onClick:()=>de(e.p_code,"crisis_map"),children:e.is_active?"Active":"Inactive"})}),a.jsx("td",{children:a.jsxs("div",{className:l.modelActions,children:[a.jsx(i,{name:`view-${e.p_code}`,variant:"secondary",size:1,onClick:()=>{x(`=== Prompt Details === Code: ${e.p_code} Label: ${e.label} Image Type: ${e.image_type} @@ -22,14 +22,14 @@ Image Type: ${e.image_type} Active: ${e.is_active} Metadata Instructions: -${e.metadata_instructions||"No instructions available"}`),F(`Prompt: ${e.p_code}`),p(!0)},children:"View"}),a.jsx(i,{name:`edit-${e.p_code}`,variant:"secondary",size:1,onClick:()=>ie(e),children:"Edit"})]})})]},e.p_code))})]})}),a.jsx("div",{className:l.addModelButtonContainer,children:a.jsx(i,{name:"add-drone-prompt",variant:"primary",onClick:()=>ne("drone_image"),children:"Add New Drone Image Prompt"})})]})]})}),a.jsx(_,{heading:"Schema Management",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsx("div",{className:l.modelManagementArea,children:a.jsx("div",{className:l.modelsTable,children:a.jsxs("table",{children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Schema ID"}),a.jsx("th",{children:"Schema Content"}),a.jsx("th",{children:"Actions"})]})}),a.jsx("tbody",{children:(_e||[]).sort((e,s)=>e.schema_id.localeCompare(s.schema_id)).map(e=>a.jsxs("tr",{children:[a.jsx("td",{className:l.modelCode,children:e.schema_id}),a.jsx("td",{className:l.promptLabel,style:{maxWidth:"400px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:JSON.stringify(e.schema)}),a.jsx("td",{children:a.jsxs("div",{className:l.modelActions,children:[a.jsx(i,{name:`view-schema-${e.schema_id}`,variant:"secondary",size:1,onClick:()=>{x(`=== Schema Details === +${e.metadata_instructions||"No instructions available"}`),F(`Prompt: ${e.p_code}`),p(!0)},children:"View"}),a.jsx(i,{name:`edit-${e.p_code}`,variant:"secondary",size:1,onClick:()=>ie(e),children:"Edit"})]})})]},e.p_code))})]})}),a.jsx("div",{className:l.addModelButtonContainer,children:a.jsx(i,{name:"add-drone-prompt",variant:"primary",onClick:()=>ne("drone_image"),children:"Add New Drone Image Prompt"})})]})]})}),a.jsx(j,{heading:"Schema Management",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsx("div",{className:l.modelManagementArea,children:a.jsx("div",{className:l.modelsTable,children:a.jsxs("table",{children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Schema ID"}),a.jsx("th",{children:"Schema Content"}),a.jsx("th",{children:"Actions"})]})}),a.jsx("tbody",{children:(je||[]).sort((e,s)=>e.schema_id.localeCompare(s.schema_id)).map(e=>a.jsxs("tr",{children:[a.jsx("td",{className:l.modelCode,children:e.schema_id}),a.jsx("td",{className:l.promptLabel,style:{maxWidth:"400px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:JSON.stringify(e.schema)}),a.jsx("td",{children:a.jsxs("div",{className:l.modelActions,children:[a.jsx(i,{name:`view-schema-${e.schema_id}`,variant:"secondary",size:1,onClick:()=>{x(`=== Schema Details === Schema ID: ${e.schema_id} Schema Definition: -${JSON.stringify(e.schema,null,2)}`),F(`Schema: ${e.schema_id}`),p(!0)},children:"View"}),a.jsx(i,{name:`edit-schema-${e.schema_id}`,variant:"secondary",size:1,onClick:()=>Ae(e),children:"Edit"})]})})]},e.schema_id))})]})})})}),a.jsx(_,{heading:"Utilities",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsx("div",{className:"flex flex-wrap gap-4",children:a.jsx(i,{name:"test-connection",variant:"secondary",onClick:async()=>{x("Testing API connection..."),F("Connection Test Results");try{const e=await fetch("/api/models");if(e.ok){const s=await e.json(),d=`✅ API connection successful! +${JSON.stringify(e.schema,null,2)}`),F(`Schema: ${e.schema_id}`),p(!0)},children:"View"}),a.jsx(i,{name:`edit-schema-${e.schema_id}`,variant:"secondary",size:1,onClick:()=>Ae(e),children:"Edit"})]})})]},e.schema_id))})]})})})}),a.jsx(j,{heading:"Utilities",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsx("div",{className:"flex flex-wrap gap-4",children:a.jsx(i,{name:"test-connection",variant:"secondary",onClick:async()=>{x("Testing API connection..."),F("Connection Test Results");try{const e=await fetch("/api/models");if(e.ok){const s=await e.json(),d=`✅ API connection successful! Found ${s.models?.length||0} models in database. Available models: ${(s.models||[]).filter(h=>h.is_available).map(h=>`- ${h.label} (${h.m_code})`).join(` -`)||"None"}`;x(d)}else{const s=`❌ API connection failed: HTTP ${e.status}`;x(s)}p(!0)}catch(e){const s=`❌ Connection error: ${e}`;x(s),p(!0)}},children:"Test Connection"})})})]})]}),ye&&a.jsx("div",{className:l.modalOverlay,onClick:()=>T(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsx("h3",{className:l.modalTitle,children:"Delete Model"}),a.jsxs("p",{className:l.modalText,children:["Are you sure you want to delete model ",a.jsx("span",{className:l.modelCode,children:se}),"? This action cannot be undone."]}),a.jsxs("div",{className:l.modalButtons,children:[a.jsx(i,{name:"cancel-delete",variant:"tertiary",onClick:()=>T(!1),children:"Cancel"}),a.jsx(i,{name:"confirm-delete",variant:"secondary",onClick:ze,children:"Delete"})]})]})})}),Ne&&a.jsx("div",{className:l.modalOverlay,onClick:()=>V(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsx("h3",{className:l.modalTitle,children:"Model Added Successfully!"}),a.jsx("div",{className:`${l.modalText} ${l.modalTextLeft}`,children:Se}),a.jsx("div",{className:l.modalButtons,children:a.jsx(i,{name:"close-setup-instructions",variant:"secondary",onClick:()=>V(!1),children:"Got it!"})})]})})}),Ce&&a.jsx("div",{className:l.modalOverlay,onClick:()=>p(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsx("h3",{className:l.modalTitle,children:Me}),a.jsx("div",{className:`${l.modalText} ${l.modalTextLeft}`,children:a.jsx("div",{className:"whitespace-pre-wrap font-mono text-sm leading-relaxed",children:we})}),a.jsx("div",{className:l.modalButtons,children:a.jsx(i,{name:"close-test-results",variant:"secondary",onClick:()=>p(!1),children:"Close"})})]})})}),ve&&a.jsx("div",{className:l.modalOverlay,onClick:()=>k(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsxs("h3",{className:l.modalTitle,children:["Edit Prompt: ",M?.p_code]}),a.jsxs("div",{className:l.modalForm,children:[a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Code:"}),a.jsx(m,{name:"prompt-code",value:M?.p_code,onChange:()=>{},disabled:!0,className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Label:"}),a.jsx(m,{name:"prompt-label",value:n.label,onChange:e=>r(s=>({...s,label:e||""})),className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Image Type:"}),a.jsx(b,{name:"prompt-image-type",value:n.image_type,onChange:e=>r(s=>({...s,image_type:e||"crisis_map"})),options:ue||[],keySelector:e=>e.image_type,labelSelector:e=>e.label})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Active Status:"}),a.jsxs("div",{className:l.addModelFormCheckbox,children:[a.jsx("input",{type:"checkbox",checked:n.is_active,onChange:e=>r(s=>({...s,is_active:e.target.checked}))}),a.jsx("span",{children:"Active for this image type"})]})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Metadata Instructions:"}),a.jsx("textarea",{name:"prompt-instructions",value:n.metadata_instructions,onChange:e=>r(s=>({...s,metadata_instructions:e.target.value})),className:`${l.formInput} ${l.textarea}`,rows:8})]})]}),a.jsxs("div",{className:l.modalButtons,children:[a.jsx(i,{name:"cancel-edit-prompt",variant:"tertiary",onClick:()=>{k(!1),z(null),r({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1})},children:"Cancel"}),a.jsx(i,{name:"save-prompt",variant:"primary",onClick:Te,children:"Save Changes"})]})]})})}),ge&&a.jsx("div",{className:l.modalOverlay,onClick:()=>w(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsxs("h3",{className:l.modalTitle,children:["Add New ",fe==="crisis_map"?"Crisis Map":"Drone Image"," Prompt"]}),a.jsxs("div",{className:l.modalForm,children:[a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Code:"}),a.jsx(m,{name:"prompt-code",value:n.p_code,onChange:e=>r(s=>({...s,p_code:e||""})),placeholder:"e.g., CUSTOM_CRISIS_MAP_001",className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Label:"}),a.jsx(m,{name:"prompt-label",value:n.label,onChange:e=>r(s=>({...s,label:e||""})),placeholder:"Enter prompt description...",className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Image Type:"}),a.jsx(m,{name:"prompt-image-type",value:n.image_type,onChange:()=>{},disabled:!0,className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Active Status:"}),a.jsxs("div",{className:l.addModelFormCheckbox,children:[a.jsx("input",{type:"checkbox",checked:n.is_active,onChange:e=>r(s=>({...s,is_active:e.target.checked}))}),a.jsx("span",{children:"Active for this image type"})]})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Metadata Instructions:"}),a.jsx("textarea",{name:"prompt-instructions",value:n.metadata_instructions,onChange:e=>r(s=>({...s,metadata_instructions:e.target.value})),placeholder:"Enter metadata extraction instructions...",className:`${l.formInput} ${l.textarea}`,rows:8})]})]}),a.jsxs("div",{className:l.modalButtons,children:[a.jsx(i,{name:"cancel-add-prompt",variant:"tertiary",onClick:()=>{w(!1),U(null),r({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1})},children:"Cancel"}),a.jsx(i,{name:"save-new-prompt",variant:"primary",onClick:Fe,disabled:!n.p_code||!n.label,children:"Create Prompt"})]})]})})}),je&&a.jsx("div",{className:l.modalOverlay,onClick:()=>S(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsxs("h3",{className:l.modalTitle,children:["Edit Schema: ",B?.schema_id]}),a.jsxs("div",{className:l.modalForm,children:[a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Schema ID:"}),a.jsx(m,{name:"schema-id",value:D.schema_id,onChange:e=>g(s=>({...s,schema_id:e||""})),className:l.formInput,disabled:!0})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Schema Definition (JSON):"}),a.jsx("textarea",{name:"schema-definition",value:JSON.stringify(D.schema,null,2),onChange:e=>{try{const s=JSON.parse(e.target.value);g(d=>({...d,schema:s}))}catch{}},className:`${l.formInput} ${l.textarea}`,rows:20,style:{fontFamily:"monospace"}})]})]}),a.jsxs("div",{className:l.modalButtons,children:[a.jsx(i,{name:"cancel-edit-schema",variant:"tertiary",onClick:Ie,children:"Cancel"}),a.jsx(i,{name:"save-schema",variant:"primary",onClick:$e,children:"Save Changes"})]})]})})})]}):a.jsx(K,{children:a.jsxs("div",{className:"mx-auto max-w-md px-4 sm:px-6 lg:px-8 py-6 sm:py-10",children:[a.jsx("div",{className:"text-center mb-8",children:a.jsx(Je,{level:2,children:"Admin Login"})}),a.jsxs("form",{onSubmit:Re,className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-gray-700 mb-2",children:"Password"}),a.jsx(m,{id:"password",name:"password",type:"password",value:$,onChange:e=>Q(e||""),placeholder:"Enter admin password",required:!0,className:"w-full",disabled:Z})]}),X&&a.jsx("div",{children:a.jsx("p",{className:"text-sm text-ifrcRed font-medium",children:X})}),a.jsx("div",{className:"flex justify-center",children:a.jsx(_,{withInternalPadding:!0,className:"p-2",children:Z?a.jsxs("div",{className:re.loadingContainer,children:[a.jsx(Ge,{className:"text-ifrcRed"}),a.jsx("p",{className:re.loadingText,children:"Logging in..."})]}):a.jsx(i,{name:"login",type:"submit",variant:"primary",size:2,children:"Login"})})})]})]})})}export{Sa as default}; +`)||"None"}`;x(d)}else{const s=`❌ API connection failed: HTTP ${e.status}`;x(s)}p(!0)}catch(e){const s=`❌ Connection error: ${e}`;x(s),p(!0)}},children:"Test Connection"})})})]})]}),ye&&a.jsx("div",{className:l.modalOverlay,onClick:()=>T(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsx("h3",{className:l.modalTitle,children:"Delete Model"}),a.jsxs("p",{className:l.modalText,children:["Are you sure you want to delete model ",a.jsx("span",{className:l.modelCode,children:se}),"? This action cannot be undone."]}),a.jsxs("div",{className:l.modalButtons,children:[a.jsx(i,{name:"cancel-delete",variant:"tertiary",onClick:()=>T(!1),children:"Cancel"}),a.jsx(i,{name:"confirm-delete",variant:"secondary",onClick:ze,children:"Delete"})]})]})})}),Ne&&a.jsx("div",{className:l.modalOverlay,onClick:()=>V(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsx("h3",{className:l.modalTitle,children:"Model Added Successfully!"}),a.jsx("div",{className:`${l.modalText} ${l.modalTextLeft}`,children:Se}),a.jsx("div",{className:l.modalButtons,children:a.jsx(i,{name:"close-setup-instructions",variant:"secondary",onClick:()=>V(!1),children:"Got it!"})})]})})}),Ce&&a.jsx("div",{className:l.modalOverlay,onClick:()=>p(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsx("h3",{className:l.modalTitle,children:Me}),a.jsx("div",{className:`${l.modalText} ${l.modalTextLeft}`,children:a.jsx("div",{className:"whitespace-pre-wrap font-mono text-sm leading-relaxed",children:we})}),a.jsx("div",{className:l.modalButtons,children:a.jsx(i,{name:"close-test-results",variant:"secondary",onClick:()=>p(!1),children:"Close"})})]})})}),ve&&a.jsx("div",{className:l.modalOverlay,onClick:()=>k(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsxs("h3",{className:l.modalTitle,children:["Edit Prompt: ",M?.p_code]}),a.jsxs("div",{className:l.modalForm,children:[a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Code:"}),a.jsx(m,{name:"prompt-code",value:M?.p_code,onChange:()=>{},disabled:!0,className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Label:"}),a.jsx(m,{name:"prompt-label",value:n.label,onChange:e=>r(s=>({...s,label:e||""})),className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Image Type:"}),a.jsx(b,{name:"prompt-image-type",value:n.image_type,onChange:e=>r(s=>({...s,image_type:e||"crisis_map"})),options:ue||[],keySelector:e=>e.image_type,labelSelector:e=>e.label})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Active Status:"}),a.jsxs("div",{className:l.addModelFormCheckbox,children:[a.jsx("input",{type:"checkbox",checked:n.is_active,onChange:e=>r(s=>({...s,is_active:e.target.checked}))}),a.jsx("span",{children:"Active for this image type"})]})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Metadata Instructions:"}),a.jsx("textarea",{name:"prompt-instructions",value:n.metadata_instructions,onChange:e=>r(s=>({...s,metadata_instructions:e.target.value})),className:`${l.formInput} ${l.textarea}`,rows:8})]})]}),a.jsxs("div",{className:l.modalButtons,children:[a.jsx(i,{name:"cancel-edit-prompt",variant:"tertiary",onClick:()=>{k(!1),z(null),r({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1})},children:"Cancel"}),a.jsx(i,{name:"save-prompt",variant:"primary",onClick:Te,children:"Save Changes"})]})]})})}),ge&&a.jsx("div",{className:l.modalOverlay,onClick:()=>w(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsxs("h3",{className:l.modalTitle,children:["Add New ",fe==="crisis_map"?"Crisis Map":"Drone Image"," Prompt"]}),a.jsxs("div",{className:l.modalForm,children:[a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Code:"}),a.jsx(m,{name:"prompt-code",value:n.p_code,onChange:e=>r(s=>({...s,p_code:e||""})),placeholder:"e.g., CUSTOM_CRISIS_MAP_001",className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Label:"}),a.jsx(m,{name:"prompt-label",value:n.label,onChange:e=>r(s=>({...s,label:e||""})),placeholder:"Enter prompt description...",className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Image Type:"}),a.jsx(m,{name:"prompt-image-type",value:n.image_type,onChange:()=>{},disabled:!0,className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Active Status:"}),a.jsxs("div",{className:l.addModelFormCheckbox,children:[a.jsx("input",{type:"checkbox",checked:n.is_active,onChange:e=>r(s=>({...s,is_active:e.target.checked}))}),a.jsx("span",{children:"Active for this image type"})]})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Metadata Instructions:"}),a.jsx("textarea",{name:"prompt-instructions",value:n.metadata_instructions,onChange:e=>r(s=>({...s,metadata_instructions:e.target.value})),placeholder:"Enter metadata extraction instructions...",className:`${l.formInput} ${l.textarea}`,rows:8})]})]}),a.jsxs("div",{className:l.modalButtons,children:[a.jsx(i,{name:"cancel-add-prompt",variant:"tertiary",onClick:()=>{w(!1),U(null),r({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1})},children:"Cancel"}),a.jsx(i,{name:"save-new-prompt",variant:"primary",onClick:Fe,disabled:!n.p_code||!n.label,children:"Create Prompt"})]})]})})}),_e&&a.jsx("div",{className:l.modalOverlay,onClick:()=>S(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsxs("h3",{className:l.modalTitle,children:["Edit Schema: ",B?.schema_id]}),a.jsxs("div",{className:l.modalForm,children:[a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Schema ID:"}),a.jsx(m,{name:"schema-id",value:D.schema_id,onChange:e=>g(s=>({...s,schema_id:e||""})),className:l.formInput,disabled:!0})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Schema Definition (JSON):"}),a.jsx("textarea",{name:"schema-definition",value:JSON.stringify(D.schema,null,2),onChange:e=>{try{const s=JSON.parse(e.target.value);g(d=>({...d,schema:s}))}catch{}},className:`${l.formInput} ${l.textarea}`,rows:20,style:{fontFamily:"monospace"}})]})]}),a.jsxs("div",{className:l.modalButtons,children:[a.jsx(i,{name:"cancel-edit-schema",variant:"tertiary",onClick:Ie,children:"Cancel"}),a.jsx(i,{name:"save-schema",variant:"primary",onClick:$e,children:"Save Changes"})]})]})})})]}):a.jsx(K,{children:a.jsxs("div",{className:"mx-auto max-w-md px-4 sm:px-6 lg:px-8 py-6 sm:py-10",children:[a.jsx("div",{className:"text-center mb-8",children:a.jsx(Je,{level:2,children:"Admin Login"})}),a.jsxs("form",{onSubmit:Re,className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-gray-700 mb-2",children:"Password"}),a.jsx(m,{id:"password",name:"password",type:"password",value:$,onChange:e=>Q(e||""),placeholder:"Enter admin password",required:!0,className:"w-full",disabled:Z})]}),X&&a.jsx("div",{children:a.jsx("p",{className:"text-sm text-ifrcRed font-medium",children:X})}),a.jsx("div",{className:"flex justify-center",children:a.jsx(j,{withInternalPadding:!0,className:"p-2",children:Z?a.jsxs("div",{className:re.loadingContainer,children:[a.jsx(Ge,{className:"text-ifrcRed"}),a.jsx("p",{className:re.loadingText,children:"Logging in..."})]}):a.jsx(i,{name:"login",type:"submit",variant:"primary",size:2,children:"Login"})})})]})]})})}export{Sa as default}; diff --git a/py_backend/static/assets/ExportModal-BqSw_U2P.js b/py_backend/static/assets/ExportModal-BI_JlHOZ.js similarity index 99% rename from py_backend/static/assets/ExportModal-BqSw_U2P.js rename to py_backend/static/assets/ExportModal-BI_JlHOZ.js index be840dfbaf761f3104ad604bd18ea2e3f82b28b3..58b0e3077b570bb5ddfdbfcafd22214ed6c9fb81 100644 --- a/py_backend/static/assets/ExportModal-BqSw_U2P.js +++ b/py_backend/static/assets/ExportModal-BI_JlHOZ.js @@ -1 +1 @@ -import{r as n,j as e,P,S as W,o as F,T as V,D as A,z as g,n as b,O as H,J as M,V as q,_ as O,L as D}from"./index-DieRAFRn.js";const G=({title:c,titleId:i,...r})=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":i},r),c?n.createElement("title",{id:i},c):null,n.createElement("g",{clipPath:"url(#checkbox-indeterminate-line_svg__a)"},n.createElement("path",{d:"M4 3h16a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm1 2v14h14V5H5Zm2 6h10v2H7v-2Z"})),n.createElement("defs",null,n.createElement("clipPath",{id:"checkbox-indeterminate-line_svg__a"},n.createElement("path",{d:"M0 0h24v24H0z"})))),$=({title:c,titleId:i,...r})=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":i},r),c?n.createElement("title",{id:i},c):null,n.createElement("g",{clipPath:"url(#filter-line_svg__a)"},n.createElement("path",{d:"M9 13.5 4 6H3V4h18v2h-1l-5 7.5V22H9v-8.5ZM6.404 6 11 12.894V20h2v-7.106L17.596 6H6.404Z"})),n.createElement("defs",null,n.createElement("clipPath",{id:"filter-line_svg__a"},n.createElement("path",{d:"M0 0h24v24H0z"}))));function R(c){const{className:i,indeterminate:r,value:v}=c;return e.jsxs(e.Fragment,{children:[r&&e.jsx(G,{className:i}),v&&!r&&e.jsx(P,{className:i}),!v&&!r&&e.jsx(W,{className:i})]})}const U="_checkbox_12g7n_1",Z="_with-background_12g7n_7",Y="_checkmark-container_12g7n_12",J="_input_12g7n_18",K="_content_12g7n_33",Q="_description_12g7n_40",X="_checked_12g7n_45",L="_checkmark_12g7n_12",ee="_disabled-checkbox_12g7n_58",m={checkbox:U,withBackground:Z,checkmarkContainer:Y,input:J,content:K,description:Q,checked:X,checkmark:L,disabledCheckbox:ee};function B(c){const{className:i,checkmark:r=R,checkmarkClassName:v,checkmarkContainerClassName:T,disabled:s,error:h,indeterminate:y,inputClassName:w,invertedLogic:d=!1,label:j,labelContainerClassName:_,name:I,onChange:f,readOnly:x,tooltip:k,value:C,description:u,withBackground:E,...S}=c,z=n.useCallback(t=>{const o=t.currentTarget.checked;f(d?!o:o,I)},[I,f,d]),N=d?!C:C,p=F(m.checkbox,i,!y&&N&&m.checked,E&&m.withBackground,s&&m.disabledCheckbox,x&&m.readOnly);return e.jsxs("label",{className:p,title:k,children:[e.jsxs("div",{className:F(m.checkmarkContainer,T),children:[e.jsx("input",{onChange:z,className:F(m.input,w),type:"checkbox",checked:N??!1,disabled:s||x,readOnly:x,...S}),e.jsx(r,{className:F(m.checkmark,v),value:N??!1,indeterminate:y,"aria-hidden":"true"})]}),(j||u)&&e.jsxs("div",{className:m.content,children:[j&&e.jsx("div",{className:_,children:j}),u&&e.jsx("div",{className:m.description,children:u})]}),h&&e.jsx(V,{children:h})]})}function _e({sources:c,types:i,regions:r,countries:v,imageTypes:T,isLoadingFilters:s=!1}){const[h,y]=n.useState(!1),[w,d]=n.useState(""),{search:j,setSearch:_,srcFilter:I,setSrcFilter:f,catFilter:x,setCatFilter:k,regionFilter:C,setRegionFilter:u,countryFilter:E,setCountryFilter:S,imageTypeFilter:z,setImageTypeFilter:N,uploadTypeFilter:p,setUploadTypeFilter:t,clearAllFilters:o}=A();return n.useEffect(()=>{d(j)},[j]),e.jsxs("div",{className:"mb-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsx(g,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:e.jsx(b,{name:"toggle-filters",variant:"secondary",onClick:()=>y(!h),className:"whitespace-nowrap",title:h?"Hide Filters":"Show Filters",children:e.jsx($,{className:"w-4 h-4"})})}),e.jsx(g,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2 flex-1 min-w-[300px]",children:e.jsx(H,{name:"search",placeholder:"Search",value:w,onChange:a=>d(a||""),onKeyDown:a=>{a.key==="Enter"&&_(w)}})}),e.jsx(g,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:e.jsx(b,{name:"clear-filters",variant:"secondary",onClick:o,children:"Clear Filters"})})]}),h&&e.jsx("div",{className:"bg-white/20 backdrop-blur-sm rounded-md p-4",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[e.jsx(g,{withInternalPadding:!0,className:"p-2",children:e.jsx(M,{name:"source",placeholder:s?"Loading...":"All Sources",options:c,value:I||null,onChange:a=>f(a||""),keySelector:a=>a.s_code,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(g,{withInternalPadding:!0,className:"p-2",children:e.jsx(M,{name:"category",placeholder:s?"Loading...":"All Categories",options:i,value:x||null,onChange:a=>k(a||""),keySelector:a=>a.t_code,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(g,{withInternalPadding:!0,className:"p-2",children:e.jsx(M,{name:"region",placeholder:s?"Loading...":"All Regions",options:r,value:C||null,onChange:a=>u(a||""),keySelector:a=>a.r_code,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(g,{withInternalPadding:!0,className:"p-2",children:e.jsx(q,{name:"country",placeholder:s?"Loading...":"All Countries",options:v,value:E?[E]:[],onChange:a=>S(a[0]||""),keySelector:a=>a.c_code,labelSelector:a=>a.label,disabled:s})}),e.jsx(g,{withInternalPadding:!0,className:"p-2",children:e.jsx(M,{name:"imageType",placeholder:s?"Loading...":"All Image Types",options:T,value:z||null,onChange:a=>N(a||""),keySelector:a=>a.image_type,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(g,{withInternalPadding:!0,className:"p-2",children:e.jsx(M,{name:"uploadType",placeholder:"All Upload Types",options:[{key:"single",label:"Single Upload"},{key:"multiple",label:"Multiple Upload"}],value:p||null,onChange:a=>t(a||""),keySelector:a=>a.key,labelSelector:a=>a.label,required:!1,disabled:!1})})]})})]})}const ae="_fullSizeModalOverlay_cyz3b_1",le="_fullSizeModalContent_cyz3b_29",te="_ratingWarningContent_cyz3b_53",se="_ratingWarningTitle_cyz3b_65",ne="_exportModeSection_cyz3b_133",ie="_splitConfigSection_cyz3b_143",re="_splitConfigTitle_cyz3b_153",ce="_splitInputsContainer_cyz3b_167",oe="_splitInputGroup_cyz3b_183",de="_splitInputLabel_cyz3b_197",pe="_splitInput_cyz3b_167",me="_splitTotal_cyz3b_247",he="_splitTotalError_cyz3b_261",xe="_checkboxesContainer_cyz3b_271",ue="_ratingWarningButtons_cyz3b_289",ge="_singleExportMessage_cyz3b_309",be="_navigateButtonContainer_cyz3b_333",ve="_loadingOverlay_cyz3b_349",l={fullSizeModalOverlay:ae,fullSizeModalContent:le,ratingWarningContent:te,ratingWarningTitle:se,exportModeSection:ne,splitConfigSection:ie,splitConfigTitle:re,splitInputsContainer:ce,splitInputGroup:oe,splitInputLabel:de,splitInput:pe,splitTotal:me,splitTotalError:he,checkboxesContainer:xe,ratingWarningButtons:ue,singleExportMessage:ge,navigateButtonContainer:be,loadingOverlay:ve};function fe({isOpen:c,onClose:i,onExport:r,crisisMapsCount:v,droneImagesCount:T,isLoading:s=!1,exportSuccess:h=!1,variant:y="bulk",onNavigateAndExport:w}){const[d,j]=n.useState("standard"),[_,I]=n.useState(80),[f,x]=n.useState(10),[k,C]=n.useState(10),[u,E]=n.useState(!0),[S,z]=n.useState(!0),N=()=>{if(y==="single"){r(d,["crisis_map","drone_image"]);return}if(!u&&!S){alert("Please select at least one image type to export.");return}const t=[];u&&t.push("crisis_map"),S&&t.push("drone_image"),r(d,t)},p=()=>{i()};return c?y==="single"?e.jsx("div",{className:l.fullSizeModalOverlay,onClick:p,children:e.jsxs("div",{className:l.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:[s&&e.jsx("div",{className:l.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(O,{className:"text-ifrcRed"}),e.jsx("div",{className:"text-lg font-medium",children:"Exporting..."}),e.jsx("div",{className:"text-sm text-gray-600",children:"This might take a few seconds"})]})}),h&&e.jsx("div",{className:l.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("div",{className:"text-lg font-medium",children:"Export Successful!"}),e.jsx("div",{className:"text-sm text-gray-600",children:"Your dataset has been downloaded"}),e.jsx(b,{name:"close-export-success",onClick:p,className:"mt-4",children:"Close"})]})}),e.jsxs("div",{className:l.ratingWarningContent,children:[e.jsx("h3",{className:l.ratingWarningTitle,children:"Export Single Item"}),e.jsxs("div",{className:l.singleExportMessage,children:[e.jsx("p",{children:"This only exports the 1 item currently on display."}),e.jsx("p",{children:'You may export the entire dataset from the "list view" here:'})]}),e.jsx("div",{className:l.navigateButtonContainer,children:e.jsx(b,{name:"navigate-to-list",variant:"secondary",onClick:w,children:"Navigate to List View"})}),e.jsxs("div",{className:l.ratingWarningButtons,children:[e.jsx(b,{name:"continue-export",onClick:N,disabled:s,children:s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"text-white"}),"Exporting..."]}):"Continue"}),e.jsx(b,{name:"cancel-export",variant:"tertiary",onClick:p,disabled:s,children:"Cancel"})]})]})]})}):e.jsx("div",{className:l.fullSizeModalOverlay,onClick:p,children:e.jsxs("div",{className:l.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:[s&&e.jsx("div",{className:l.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(O,{className:"text-ifrcRed"}),e.jsx("div",{className:"text-lg font-medium",children:"Exporting..."}),e.jsx("div",{className:"text-sm text-gray-600",children:"This might take a few seconds"})]})}),h&&e.jsx("div",{className:l.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("div",{className:"text-lg font-medium",children:"Export Successful!"}),e.jsx("div",{className:"text-sm text-gray-600",children:"Your dataset has been downloaded"}),e.jsx(b,{name:"close-export-success",onClick:p,className:"mt-4",children:"Close"})]})}),e.jsxs("div",{className:l.ratingWarningContent,children:[e.jsx("h3",{className:l.ratingWarningTitle,children:"Export Dataset"}),e.jsx("div",{className:l.exportModeSection,children:e.jsx(D,{name:"export-mode",value:d,onChange:t=>{(t==="standard"||t==="fine-tuning")&&j(t)},options:[{key:"standard",label:"Standard"},{key:"fine-tuning",label:"Fine-tuning"}],keySelector:t=>t.key,labelSelector:t=>t.label,disabled:s})}),d==="fine-tuning"&&e.jsxs("div",{className:l.splitConfigSection,children:[e.jsx("div",{className:l.splitConfigTitle,children:"Dataset Split Configuration"}),e.jsxs("div",{className:l.splitInputsContainer,children:[e.jsxs("div",{className:l.splitInputGroup,children:[e.jsx("label",{htmlFor:"train-split",className:l.splitInputLabel,children:"Train (%)"}),e.jsx("input",{id:"train-split",type:"number",min:"0",max:"100",value:_,onChange:t=>{const o=parseInt(t.target.value)||0,a=100-o;a>=0&&(I(o),f+k>a&&(x(Math.floor(a/2)),C(a-Math.floor(a/2))))},className:l.splitInput,disabled:s})]}),e.jsxs("div",{className:l.splitInputGroup,children:[e.jsx("label",{htmlFor:"test-split",className:l.splitInputLabel,children:"Test (%)"}),e.jsx("input",{id:"test-split",type:"number",min:"0",max:"100",value:f,onChange:t=>{const o=parseInt(t.target.value)||0,a=100-_-o;a>=0&&(x(o),C(a))},className:l.splitInput,disabled:s})]}),e.jsxs("div",{className:l.splitInputGroup,children:[e.jsx("label",{htmlFor:"val-split",className:l.splitInputLabel,children:"Val (%)"}),e.jsx("input",{id:"val-split",type:"number",min:"0",max:"100",value:k,onChange:t=>{const o=parseInt(t.target.value)||0,a=100-_-o;a>=0&&(C(o),x(a))},className:l.splitInput,disabled:s})]})]}),_+f+k!==100&&e.jsx("div",{className:l.splitTotal,children:e.jsx("span",{className:l.splitTotalError,children:"Must equal 100%"})})]}),e.jsxs("div",{className:l.checkboxesContainer,children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(B,{name:"crisis-maps",label:`Crisis Maps (${v} images)`,value:u,onChange:t=>E(t),disabled:s})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(B,{name:"drone-images",label:`Drone Images (${T} images)`,value:S,onChange:t=>z(t),disabled:s})})]}),e.jsxs("div",{className:l.ratingWarningButtons,children:[e.jsx(b,{name:"confirm-export",onClick:N,disabled:s,children:s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"text-white"}),"Exporting..."]}):"Export Selected"}),e.jsx(b,{name:"cancel-export",variant:"tertiary",onClick:p,disabled:s,children:"Cancel"})]})]})]})}):null}export{fe as E,_e as F}; +import{r as n,j as e,P,S as W,o as F,T as V,D as A,z as g,n as b,O as H,J as M,V as q,_ as O,L as D}from"./index-B0L3qvtx.js";const G=({title:c,titleId:i,...r})=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":i},r),c?n.createElement("title",{id:i},c):null,n.createElement("g",{clipPath:"url(#checkbox-indeterminate-line_svg__a)"},n.createElement("path",{d:"M4 3h16a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm1 2v14h14V5H5Zm2 6h10v2H7v-2Z"})),n.createElement("defs",null,n.createElement("clipPath",{id:"checkbox-indeterminate-line_svg__a"},n.createElement("path",{d:"M0 0h24v24H0z"})))),$=({title:c,titleId:i,...r})=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":i},r),c?n.createElement("title",{id:i},c):null,n.createElement("g",{clipPath:"url(#filter-line_svg__a)"},n.createElement("path",{d:"M9 13.5 4 6H3V4h18v2h-1l-5 7.5V22H9v-8.5ZM6.404 6 11 12.894V20h2v-7.106L17.596 6H6.404Z"})),n.createElement("defs",null,n.createElement("clipPath",{id:"filter-line_svg__a"},n.createElement("path",{d:"M0 0h24v24H0z"}))));function R(c){const{className:i,indeterminate:r,value:v}=c;return e.jsxs(e.Fragment,{children:[r&&e.jsx(G,{className:i}),v&&!r&&e.jsx(P,{className:i}),!v&&!r&&e.jsx(W,{className:i})]})}const U="_checkbox_12g7n_1",Z="_with-background_12g7n_7",Y="_checkmark-container_12g7n_12",J="_input_12g7n_18",K="_content_12g7n_33",Q="_description_12g7n_40",X="_checked_12g7n_45",L="_checkmark_12g7n_12",ee="_disabled-checkbox_12g7n_58",m={checkbox:U,withBackground:Z,checkmarkContainer:Y,input:J,content:K,description:Q,checked:X,checkmark:L,disabledCheckbox:ee};function B(c){const{className:i,checkmark:r=R,checkmarkClassName:v,checkmarkContainerClassName:T,disabled:s,error:h,indeterminate:y,inputClassName:w,invertedLogic:d=!1,label:j,labelContainerClassName:_,name:I,onChange:f,readOnly:x,tooltip:k,value:C,description:u,withBackground:E,...S}=c,z=n.useCallback(t=>{const o=t.currentTarget.checked;f(d?!o:o,I)},[I,f,d]),N=d?!C:C,p=F(m.checkbox,i,!y&&N&&m.checked,E&&m.withBackground,s&&m.disabledCheckbox,x&&m.readOnly);return e.jsxs("label",{className:p,title:k,children:[e.jsxs("div",{className:F(m.checkmarkContainer,T),children:[e.jsx("input",{onChange:z,className:F(m.input,w),type:"checkbox",checked:N??!1,disabled:s||x,readOnly:x,...S}),e.jsx(r,{className:F(m.checkmark,v),value:N??!1,indeterminate:y,"aria-hidden":"true"})]}),(j||u)&&e.jsxs("div",{className:m.content,children:[j&&e.jsx("div",{className:_,children:j}),u&&e.jsx("div",{className:m.description,children:u})]}),h&&e.jsx(V,{children:h})]})}function _e({sources:c,types:i,regions:r,countries:v,imageTypes:T,isLoadingFilters:s=!1}){const[h,y]=n.useState(!1),[w,d]=n.useState(""),{search:j,setSearch:_,srcFilter:I,setSrcFilter:f,catFilter:x,setCatFilter:k,regionFilter:C,setRegionFilter:u,countryFilter:E,setCountryFilter:S,imageTypeFilter:z,setImageTypeFilter:N,uploadTypeFilter:p,setUploadTypeFilter:t,clearAllFilters:o}=A();return n.useEffect(()=>{d(j)},[j]),e.jsxs("div",{className:"mb-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsx(g,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:e.jsx(b,{name:"toggle-filters",variant:"secondary",onClick:()=>y(!h),className:"whitespace-nowrap",title:h?"Hide Filters":"Show Filters",children:e.jsx($,{className:"w-4 h-4"})})}),e.jsx(g,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2 flex-1 min-w-[300px]",children:e.jsx(H,{name:"search",placeholder:"Search",value:w,onChange:a=>d(a||""),onKeyDown:a=>{a.key==="Enter"&&_(w)}})}),e.jsx(g,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:e.jsx(b,{name:"clear-filters",variant:"secondary",onClick:o,children:"Clear Filters"})})]}),h&&e.jsx("div",{className:"bg-white/20 backdrop-blur-sm rounded-md p-4",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[e.jsx(g,{withInternalPadding:!0,className:"p-2",children:e.jsx(M,{name:"source",placeholder:s?"Loading...":"All Sources",options:c,value:I||null,onChange:a=>f(a||""),keySelector:a=>a.s_code,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(g,{withInternalPadding:!0,className:"p-2",children:e.jsx(M,{name:"category",placeholder:s?"Loading...":"All Categories",options:i,value:x||null,onChange:a=>k(a||""),keySelector:a=>a.t_code,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(g,{withInternalPadding:!0,className:"p-2",children:e.jsx(M,{name:"region",placeholder:s?"Loading...":"All Regions",options:r,value:C||null,onChange:a=>u(a||""),keySelector:a=>a.r_code,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(g,{withInternalPadding:!0,className:"p-2",children:e.jsx(q,{name:"country",placeholder:s?"Loading...":"All Countries",options:v,value:E?[E]:[],onChange:a=>S(a[0]||""),keySelector:a=>a.c_code,labelSelector:a=>a.label,disabled:s})}),e.jsx(g,{withInternalPadding:!0,className:"p-2",children:e.jsx(M,{name:"imageType",placeholder:s?"Loading...":"All Image Types",options:T,value:z||null,onChange:a=>N(a||""),keySelector:a=>a.image_type,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(g,{withInternalPadding:!0,className:"p-2",children:e.jsx(M,{name:"uploadType",placeholder:"All Upload Types",options:[{key:"single",label:"Single Upload"},{key:"multiple",label:"Multiple Upload"}],value:p||null,onChange:a=>t(a||""),keySelector:a=>a.key,labelSelector:a=>a.label,required:!1,disabled:!1})})]})})]})}const ae="_fullSizeModalOverlay_cyz3b_1",le="_fullSizeModalContent_cyz3b_29",te="_ratingWarningContent_cyz3b_53",se="_ratingWarningTitle_cyz3b_65",ne="_exportModeSection_cyz3b_133",ie="_splitConfigSection_cyz3b_143",re="_splitConfigTitle_cyz3b_153",ce="_splitInputsContainer_cyz3b_167",oe="_splitInputGroup_cyz3b_183",de="_splitInputLabel_cyz3b_197",pe="_splitInput_cyz3b_167",me="_splitTotal_cyz3b_247",he="_splitTotalError_cyz3b_261",xe="_checkboxesContainer_cyz3b_271",ue="_ratingWarningButtons_cyz3b_289",ge="_singleExportMessage_cyz3b_309",be="_navigateButtonContainer_cyz3b_333",ve="_loadingOverlay_cyz3b_349",l={fullSizeModalOverlay:ae,fullSizeModalContent:le,ratingWarningContent:te,ratingWarningTitle:se,exportModeSection:ne,splitConfigSection:ie,splitConfigTitle:re,splitInputsContainer:ce,splitInputGroup:oe,splitInputLabel:de,splitInput:pe,splitTotal:me,splitTotalError:he,checkboxesContainer:xe,ratingWarningButtons:ue,singleExportMessage:ge,navigateButtonContainer:be,loadingOverlay:ve};function fe({isOpen:c,onClose:i,onExport:r,crisisMapsCount:v,droneImagesCount:T,isLoading:s=!1,exportSuccess:h=!1,variant:y="bulk",onNavigateAndExport:w}){const[d,j]=n.useState("standard"),[_,I]=n.useState(80),[f,x]=n.useState(10),[k,C]=n.useState(10),[u,E]=n.useState(!0),[S,z]=n.useState(!0),N=()=>{if(y==="single"){r(d,["crisis_map","drone_image"]);return}if(!u&&!S){alert("Please select at least one image type to export.");return}const t=[];u&&t.push("crisis_map"),S&&t.push("drone_image"),r(d,t)},p=()=>{i()};return c?y==="single"?e.jsx("div",{className:l.fullSizeModalOverlay,onClick:p,children:e.jsxs("div",{className:l.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:[s&&e.jsx("div",{className:l.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(O,{className:"text-ifrcRed"}),e.jsx("div",{className:"text-lg font-medium",children:"Exporting..."}),e.jsx("div",{className:"text-sm text-gray-600",children:"This might take a few seconds"})]})}),h&&e.jsx("div",{className:l.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("div",{className:"text-lg font-medium",children:"Export Successful!"}),e.jsx("div",{className:"text-sm text-gray-600",children:"Your dataset has been downloaded"}),e.jsx(b,{name:"close-export-success",onClick:p,className:"mt-4",children:"Close"})]})}),e.jsxs("div",{className:l.ratingWarningContent,children:[e.jsx("h3",{className:l.ratingWarningTitle,children:"Export Single Item"}),e.jsxs("div",{className:l.singleExportMessage,children:[e.jsx("p",{children:"This only exports the 1 item currently on display."}),e.jsx("p",{children:'You may export the entire dataset from the "list view" here:'})]}),e.jsx("div",{className:l.navigateButtonContainer,children:e.jsx(b,{name:"navigate-to-list",variant:"secondary",onClick:w,children:"Navigate to List View"})}),e.jsxs("div",{className:l.ratingWarningButtons,children:[e.jsx(b,{name:"continue-export",onClick:N,disabled:s,children:s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"text-white"}),"Exporting..."]}):"Continue"}),e.jsx(b,{name:"cancel-export",variant:"tertiary",onClick:p,disabled:s,children:"Cancel"})]})]})]})}):e.jsx("div",{className:l.fullSizeModalOverlay,onClick:p,children:e.jsxs("div",{className:l.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:[s&&e.jsx("div",{className:l.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(O,{className:"text-ifrcRed"}),e.jsx("div",{className:"text-lg font-medium",children:"Exporting..."}),e.jsx("div",{className:"text-sm text-gray-600",children:"This might take a few seconds"})]})}),h&&e.jsx("div",{className:l.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("div",{className:"text-lg font-medium",children:"Export Successful!"}),e.jsx("div",{className:"text-sm text-gray-600",children:"Your dataset has been downloaded"}),e.jsx(b,{name:"close-export-success",onClick:p,className:"mt-4",children:"Close"})]})}),e.jsxs("div",{className:l.ratingWarningContent,children:[e.jsx("h3",{className:l.ratingWarningTitle,children:"Export Dataset"}),e.jsx("div",{className:l.exportModeSection,children:e.jsx(D,{name:"export-mode",value:d,onChange:t=>{(t==="standard"||t==="fine-tuning")&&j(t)},options:[{key:"standard",label:"Standard"},{key:"fine-tuning",label:"Fine-tuning"}],keySelector:t=>t.key,labelSelector:t=>t.label,disabled:s})}),d==="fine-tuning"&&e.jsxs("div",{className:l.splitConfigSection,children:[e.jsx("div",{className:l.splitConfigTitle,children:"Dataset Split Configuration"}),e.jsxs("div",{className:l.splitInputsContainer,children:[e.jsxs("div",{className:l.splitInputGroup,children:[e.jsx("label",{htmlFor:"train-split",className:l.splitInputLabel,children:"Train (%)"}),e.jsx("input",{id:"train-split",type:"number",min:"0",max:"100",value:_,onChange:t=>{const o=parseInt(t.target.value)||0,a=100-o;a>=0&&(I(o),f+k>a&&(x(Math.floor(a/2)),C(a-Math.floor(a/2))))},className:l.splitInput,disabled:s})]}),e.jsxs("div",{className:l.splitInputGroup,children:[e.jsx("label",{htmlFor:"test-split",className:l.splitInputLabel,children:"Test (%)"}),e.jsx("input",{id:"test-split",type:"number",min:"0",max:"100",value:f,onChange:t=>{const o=parseInt(t.target.value)||0,a=100-_-o;a>=0&&(x(o),C(a))},className:l.splitInput,disabled:s})]}),e.jsxs("div",{className:l.splitInputGroup,children:[e.jsx("label",{htmlFor:"val-split",className:l.splitInputLabel,children:"Val (%)"}),e.jsx("input",{id:"val-split",type:"number",min:"0",max:"100",value:k,onChange:t=>{const o=parseInt(t.target.value)||0,a=100-_-o;a>=0&&(C(o),x(a))},className:l.splitInput,disabled:s})]})]}),_+f+k!==100&&e.jsx("div",{className:l.splitTotal,children:e.jsx("span",{className:l.splitTotalError,children:"Must equal 100%"})})]}),e.jsxs("div",{className:l.checkboxesContainer,children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(B,{name:"crisis-maps",label:`Crisis Maps (${v} images)`,value:u,onChange:t=>E(t),disabled:s})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(B,{name:"drone-images",label:`Drone Images (${T} images)`,value:S,onChange:t=>z(t),disabled:s})})]}),e.jsxs("div",{className:l.ratingWarningButtons,children:[e.jsx(b,{name:"confirm-export",onClick:N,disabled:s,children:s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"text-white"}),"Exporting..."]}):"Export Selected"}),e.jsx(b,{name:"cancel-export",variant:"tertiary",onClick:p,disabled:s,children:"Cancel"})]})]})]})}):null}export{fe as E,_e as F}; diff --git a/py_backend/static/assets/index-DieRAFRn.js b/py_backend/static/assets/index-B0L3qvtx.js similarity index 96% rename from py_backend/static/assets/index-DieRAFRn.js rename to py_backend/static/assets/index-B0L3qvtx.js index ab2821b599cb9ffca190925d8444d1d1b2cecc8a..5ebf7118386db5e708841831c76aa0e2693e32c8 100644 --- a/py_backend/static/assets/index-DieRAFRn.js +++ b/py_backend/static/assets/index-B0L3qvtx.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-a9YqPexW.js","assets/index-B1uKTNcW.css","assets/index-RsSGWjBF.js","assets/useAdmin-SWj4UX1Y.js","assets/ExportModal-BqSw_U2P.js","assets/ExportModal-BoB3JpqO.css","assets/index-C85X4vtS.css","assets/AdminPage-Ddcg9yuB.js","assets/AdminPage-VgSjQ50W.css","assets/index-L-TN6RFj.js","assets/index-tDgjKyWF.css"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C4_t-iUv.js","assets/index-B1uKTNcW.css","assets/index-CWQiqOU3.js","assets/useAdmin-DN0iYnPm.js","assets/ExportModal-BI_JlHOZ.js","assets/ExportModal-BoB3JpqO.css","assets/index-C85X4vtS.css","assets/AdminPage-0qyl8wHV.js","assets/AdminPage-VgSjQ50W.css","assets/index-D5zar1LU.js","assets/index-tDgjKyWF.css"])))=>i.map(i=>d[i]); function zg(e,n){for(var i=0;io[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const u of s)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function i(s){const u={};return s.integrity&&(u.integrity=s.integrity),s.referrerPolicy&&(u.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?u.credentials="include":s.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(s){if(s.ep)return;s.ep=!0;const u=i(s);fetch(s.href,u)}})();var kP=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Bg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Kc={exports:{}},Ra={},Yc={exports:{}},qe={};/** * @license React * react.production.min.js @@ -143,7 +143,7 @@ Error generating stack: `+h.message+` `),this.css+=n+"/*# sourceMappingURL="+e+" */"}applyPrevMaps(){for(let e of this.previous()){let n=this.toUrl(this.path(e.file)),i=e.root||Gl(e.file),o;this.mapOpts.sourcesContent===!1?(o=new Qv(e.text),o.sourcesContent&&(o.sourcesContent=null)):o=e.consumer(),this.map.applySourceMap(o,n,this.toUrl(this.path(i)))}}clearAnnotation(){if(this.mapOpts.annotation!==!1)if(this.root){let e;for(let n=this.root.nodes.length-1;n>=0;n--)e=this.root.nodes[n],e.type==="comment"&&e.text.startsWith("# sourceMappingURL=")&&this.root.removeChild(n)}else this.css&&(this.css=this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm,""))}generate(){if(this.clearAnnotation(),TN&&NN&&this.isMap())return this.generateMap();{let e="";return this.stringify(this.root,n=>{e+=n}),[e]}}generateMap(){if(this.root)this.generateString();else if(this.previous().length===1){let e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=Zl.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new Zl({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):""});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css="",this.map=new Zl({file:this.outputFile(),ignoreInvalidMapping:!0});let e=1,n=1,i="",o={generated:{column:0,line:0},original:{column:0,line:0},source:""},s,u;this.stringify(this.root,(d,f,p)=>{if(this.css+=d,f&&p!=="end"&&(o.generated.line=e,o.generated.column=n-1,f.source&&f.source.start?(o.source=this.sourcePath(f),o.original.line=f.source.start.line,o.original.column=f.source.start.column-1,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,this.map.addMapping(o))),u=d.match(/\n/g),u?(e+=u.length,s=d.lastIndexOf(` `),n=d.length-s):n+=d.length,f&&p!=="start"){let y=f.parent||{raws:{}};(!(f.type==="decl"||f.type==="atrule"&&!f.nodes)||f!==y.last||y.raws.semicolon)&&(f.source&&f.source.end?(o.source=this.sourcePath(f),o.original.line=f.source.end.line,o.original.column=f.source.end.column-1,o.generated.line=e,o.generated.column=n-2,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,o.generated.line=e,o.generated.column=n-1,this.map.addMapping(o)))}})}isAnnotation(){return this.isInline()?!0:typeof this.mapOpts.annotation<"u"?this.mapOpts.annotation:this.previous().length?this.previous().some(e=>e.annotation):!0}isInline(){if(typeof this.mapOpts.inline<"u")return this.mapOpts.inline;let e=this.mapOpts.annotation;return typeof e<"u"&&e!==!0?!1:this.previous().length?this.previous().some(n=>n.inline):!0}isMap(){return typeof this.opts.map<"u"?!!this.opts.map:this.previous().length>0}isSourcesContent(){return typeof this.mapOpts.sourcesContent<"u"?this.mapOpts.sourcesContent:this.previous().length?this.previous().some(e=>e.withContent()):!0}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(e){if(this.mapOpts.absolute||e.charCodeAt(0)===60||/^\w+:\/\//.test(e))return e;let n=this.memoizedPaths.get(e);if(n)return n;let i=this.opts.to?Gl(this.opts.to):".";typeof this.mapOpts.annotation=="string"&&(i=Gl(Gv(i,this.mapOpts.annotation)));let o=Wv(i,e);return this.memoizedPaths.set(e,o),o}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(e=>{if(e.source&&e.source.input.map){let n=e.source.input.map;this.previousMaps.includes(n)||this.previousMaps.push(n)}});else{let e=new kN(this.originalCSS,this.opts);e.map&&this.previousMaps.push(e.map)}return this.previousMaps}setSourcesContent(){let e={};if(this.root)this.root.walk(n=>{if(n.source){let i=n.source.input.from;if(i&&!e[i]){e[i]=!0;let o=this.usesFileUrls?this.toFileUrl(i):this.toUrl(this.path(i));this.map.setSourceContent(o,n.source.input.css)}}});else if(this.css){let n=this.opts.from?this.toUrl(this.path(this.opts.from)):"";this.map.setSourceContent(n,this.css)}}sourcePath(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))}toBase64(e){return Buffer?Buffer.from(e).toString("base64"):window.btoa(unescape(encodeURIComponent(e)))}toFileUrl(e){let n=this.memoizedFileURLs.get(e);if(n)return n;if(bg){let i=bg(e).toString();return this.memoizedFileURLs.set(e,i),i}else throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(e){let n=this.memoizedURLs.get(e);if(n)return n;Zv==="\\"&&(e=e.replace(/\\/g,"/"));let i=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,i),i}};var Kv=jN;const Cd=39,_g=34,Ol=92,Eg=47,Rl=10,Va=32,Il=12,Al=9,Fl=13,PN=91,MN=93,LN=40,DN=41,ON=123,RN=125,IN=59,AN=42,FN=58,$N=64,$l=/[\t\n\f\r "#'()/;[\\\]{}]/g,zl=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,zN=/.[\r\n"'(/\\]/,kg=/[\da-f]/i;var BN=function(e,n={}){let i=e.css.valueOf(),o=n.ignoreErrors,s,u,d,f,p,y,w,C,m,x,E=i.length,b=0,N=[],P=[];function L(){return b}function $(O){throw e.error("Unclosed "+O,b)}function q(){return P.length===0&&b>=E}function Z(O){if(P.length)return P.pop();if(b>=E)return;let K=O?O.ignoreUnclosed:!1;switch(s=i.charCodeAt(b),s){case Rl:case Va:case Al:case Fl:case Il:{f=b;do f+=1,s=i.charCodeAt(f);while(s===Va||s===Rl||s===Al||s===Fl||s===Il);y=["space",i.slice(b,f)],b=f-1;break}case PN:case MN:case ON:case RN:case FN:case IN:case DN:{let ce=String.fromCharCode(s);y=[ce,ce,b];break}case LN:{if(x=N.length?N.pop()[1]:"",m=i.charCodeAt(b+1),x==="url"&&m!==Cd&&m!==_g&&m!==Va&&m!==Rl&&m!==Al&&m!==Il&&m!==Fl){f=b;do{if(w=!1,f=i.indexOf(")",f+1),f===-1)if(o||K){f=b;break}else $("bracket");for(C=f;i.charCodeAt(C-1)===Ol;)C-=1,w=!w}while(w);y=["brackets",i.slice(b,f+1),b,f],b=f}else f=i.indexOf(")",b+1),u=i.slice(b,f+1),f===-1||zN.test(u)?y=["(","(",b]:(y=["brackets",u,b,f],b=f);break}case Cd:case _g:{p=s===Cd?"'":'"',f=b;do{if(w=!1,f=i.indexOf(p,f+1),f===-1)if(o||K){f=b+1;break}else $("string");for(C=f;i.charCodeAt(C-1)===Ol;)C-=1,w=!w}while(w);y=["string",i.slice(b,f+1),b,f],b=f;break}case $N:{$l.lastIndex=b+1,$l.test(i),$l.lastIndex===0?f=i.length-1:f=$l.lastIndex-2,y=["at-word",i.slice(b,f+1),b,f],b=f;break}case Ol:{for(f=b,d=!0;i.charCodeAt(f+1)===Ol;)f+=1,d=!d;if(s=i.charCodeAt(f+1),d&&s!==Eg&&s!==Va&&s!==Rl&&s!==Al&&s!==Fl&&s!==Il&&(f+=1,kg.test(i.charAt(f)))){for(;kg.test(i.charAt(f+1));)f+=1;i.charCodeAt(f+1)===Va&&(f+=1)}y=["word",i.slice(b,f+1),b,f],b=f;break}default:{s===Eg&&i.charCodeAt(b+1)===AN?(f=i.indexOf("*/",b+2)+1,f===0&&(o||K?f=i.length:$("comment")),y=["comment",i.slice(b,f+1),b,f],b=f):(zl.lastIndex=b+1,zl.test(i),zl.lastIndex===0?f=i.length-1:f=zl.lastIndex-2,y=["word",i.slice(b,f+1),b,f],N.push(y),b=f);break}}return b++,y}function fe(O){P.push(O)}return{back:fe,endOfFile:q,nextToken:Z,position:L}};let UN=Hf,HN=wu,VN=xu,qN=xs,Ng=qf,WN=BN;const Tg={empty:!0,space:!0};function GN(e){for(let n=e.length-1;n>=0;n--){let i=e[n],o=i[3]||i[2];if(o)return o}}let ZN=class{constructor(e){this.input=e,this.root=new qN,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let n=new UN;n.name=e[1].slice(1),n.name===""&&this.unnamedAtrule(n,e),this.init(n,e[2]);let i,o,s,u=!1,d=!1,f=[],p=[];for(;!this.tokenizer.endOfFile();){if(e=this.tokenizer.nextToken(),i=e[0],i==="("||i==="["?p.push(i==="("?")":"]"):i==="{"&&p.length>0?p.push("}"):i===p[p.length-1]&&p.pop(),p.length===0)if(i===";"){n.source.end=this.getPosition(e[2]),n.source.end.offset++,this.semicolon=!0;break}else if(i==="{"){d=!0;break}else if(i==="}"){if(f.length>0){for(s=f.length-1,o=f[s];o&&o[0]==="space";)o=f[--s];o&&(n.source.end=this.getPosition(o[3]||o[2]),n.source.end.offset++)}this.end(e);break}else f.push(e);else f.push(e);if(this.tokenizer.endOfFile()){u=!0;break}}n.raws.between=this.spacesAndCommentsFromEnd(f),f.length?(n.raws.afterName=this.spacesAndCommentsFromStart(f),this.raw(n,"params",f),u&&(e=f[f.length-1],n.source.end=this.getPosition(e[3]||e[2]),n.source.end.offset++,this.spaces=n.raws.between,n.raws.between="")):(n.raws.afterName="",n.params=""),d&&(n.nodes=[],this.current=n)}checkMissedSemicolon(e){let n=this.colon(e);if(n===!1)return;let i=0,o;for(let s=n-1;s>=0&&(o=e[s],!(o[0]!=="space"&&(i+=1,i===2)));s--);throw this.input.error("Missed semicolon",o[0]==="word"?o[3]+1:o[2])}colon(e){let n=0,i,o,s;for(let[u,d]of e.entries()){if(o=d,s=o[0],s==="("&&(n+=1),s===")"&&(n-=1),n===0&&s===":")if(!i)this.doubleColon(o);else{if(i[0]==="word"&&i[1]==="progid")continue;return u}i=o}return!1}comment(e){let n=new HN;this.init(n,e[2]),n.source.end=this.getPosition(e[3]||e[2]),n.source.end.offset++;let i=e[1].slice(2,-2);if(/^\s*$/.test(i))n.text="",n.raws.left=i,n.raws.right="";else{let o=i.match(/^(\s*)([^]*\S)(\s*)$/);n.text=o[2],n.raws.left=o[1],n.raws.right=o[3]}}createTokenizer(){this.tokenizer=WN(this.input)}decl(e,n){let i=new VN;this.init(i,e[0][2]);let o=e[e.length-1];for(o[0]===";"&&(this.semicolon=!0,e.pop()),i.source.end=this.getPosition(o[3]||o[2]||GN(e)),i.source.end.offset++;e[0][0]!=="word";)e.length===1&&this.unknownWord(e),i.raws.before+=e.shift()[1];for(i.source.start=this.getPosition(e[0][2]),i.prop="";e.length;){let f=e[0][0];if(f===":"||f==="space"||f==="comment")break;i.prop+=e.shift()[1]}i.raws.between="";let s;for(;e.length;)if(s=e.shift(),s[0]===":"){i.raws.between+=s[1];break}else s[0]==="word"&&/\w/.test(s[1])&&this.unknownWord([s]),i.raws.between+=s[1];(i.prop[0]==="_"||i.prop[0]==="*")&&(i.raws.before+=i.prop[0],i.prop=i.prop.slice(1));let u=[],d;for(;e.length&&(d=e[0][0],!(d!=="space"&&d!=="comment"));)u.push(e.shift());this.precheckMissedSemicolon(e);for(let f=e.length-1;f>=0;f--){if(s=e[f],s[1].toLowerCase()==="!important"){i.important=!0;let p=this.stringFrom(e,f);p=this.spacesFromEnd(e)+p,p!==" !important"&&(i.raws.important=p);break}else if(s[1].toLowerCase()==="important"){let p=e.slice(0),y="";for(let w=f;w>0;w--){let C=p[w][0];if(y.trim().startsWith("!")&&C!=="space")break;y=p.pop()[1]+y}y.trim().startsWith("!")&&(i.important=!0,i.raws.important=y,e=p)}if(s[0]!=="space"&&s[0]!=="comment")break}e.some(f=>f[0]!=="space"&&f[0]!=="comment")&&(i.raws.between+=u.map(f=>f[1]).join(""),u=[]),this.raw(i,"value",u.concat(e),n),i.value.includes(":")&&!n&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error("Double colon",{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let n=new Ng;this.init(n,e[2]),n.selector="",n.raws.between="",this.current=n}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let n=this.current.nodes[this.current.nodes.length-1];n&&n.type==="rule"&&!n.raws.ownSemicolon&&(n.raws.ownSemicolon=this.spaces,this.spaces="")}}getPosition(e){let n=this.input.fromOffset(e);return{column:n.col,line:n.line,offset:e}}init(e,n){this.current.push(e),e.source={input:this.input,start:this.getPosition(n)},e.raws.before=this.spaces,this.spaces="",e.type!=="comment"&&(this.semicolon=!1)}other(e){let n=!1,i=null,o=!1,s=null,u=[],d=e[1].startsWith("--"),f=[],p=e;for(;p;){if(i=p[0],f.push(p),i==="("||i==="[")s||(s=p),u.push(i==="("?")":"]");else if(d&&o&&i==="{")s||(s=p),u.push("}");else if(u.length===0)if(i===";")if(o){this.decl(f,d);return}else break;else if(i==="{"){this.rule(f);return}else if(i==="}"){this.tokenizer.back(f.pop()),n=!0;break}else i===":"&&(o=!0);else i===u[u.length-1]&&(u.pop(),u.length===0&&(s=null));p=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(n=!0),u.length>0&&this.unclosedBracket(s),n&&o){if(!d)for(;f.length&&(p=f[f.length-1][0],!(p!=="space"&&p!=="comment"));)this.tokenizer.back(f.pop());this.decl(f,d)}else this.unknownWord(f)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case"space":this.spaces+=e[1];break;case";":this.freeSemicolon(e);break;case"}":this.end(e);break;case"comment":this.comment(e);break;case"at-word":this.atrule(e);break;case"{":this.emptyRule(e);break;default:this.other(e);break}this.endFile()}precheckMissedSemicolon(){}raw(e,n,i,o){let s,u,d=i.length,f="",p=!0,y,w;for(let C=0;Cm+x[1],"");e.raws[n]={raw:C,value:f}}e[n]=f}rule(e){e.pop();let n=new Ng;this.init(n,e[0][2]),n.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(n,"selector",e),this.current=n}spacesAndCommentsFromEnd(e){let n,i="";for(;e.length&&(n=e[e.length-1][0],!(n!=="space"&&n!=="comment"));)i=e.pop()[1]+i;return i}spacesAndCommentsFromStart(e){let n,i="";for(;e.length&&(n=e[0][0],!(n!=="space"&&n!=="comment"));)i+=e.shift()[1];return i}spacesFromEnd(e){let n,i="";for(;e.length&&(n=e[e.length-1][0],n==="space");)i=e.pop()[1]+i;return i}stringFrom(e,n){let i="";for(let o=n;oe.type==="warning")}get content(){return this.css}};var Gf=Qd;Qd.default=Qd;let e2=ho,t2=Vf,n2=Kv,r2=Wf,jg=Gf,i2=xs,o2=vu,{isClean:Cr,my:a2}=ws;const s2={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},l2={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},u2={Once:!0,postcssPlugin:!0,prepare:!0},ea=0;function qa(e){return typeof e=="object"&&typeof e.then=="function"}function Xv(e){let n=!1,i=s2[e.type];return e.type==="decl"?n=e.prop.toLowerCase():e.type==="atrule"&&(n=e.name.toLowerCase()),n&&e.append?[i,i+"-"+n,ea,i+"Exit",i+"Exit-"+n]:n?[i,i+"-"+n,i+"Exit",i+"Exit-"+n]:e.append?[i,ea,i+"Exit"]:[i,i+"Exit"]}function Pg(e){let n;return e.type==="document"?n=["Document",ea,"DocumentExit"]:e.type==="root"?n=["Root",ea,"RootExit"]:n=Xv(e),{eventIndex:0,events:n,iterator:0,node:e,visitorIndex:0,visitors:[]}}function Kd(e){return e[Cr]=!1,e.nodes&&e.nodes.forEach(n=>Kd(n)),e}let Yd={},ta=class Jv{constructor(n,i,o){this.stringified=!1,this.processed=!1;let s;if(typeof i=="object"&&i!==null&&(i.type==="root"||i.type==="document"))s=Kd(i);else if(i instanceof Jv||i instanceof jg)s=Kd(i.root),i.map&&(typeof o.map>"u"&&(o.map={}),o.map.inline||(o.map.inline=!1),o.map.prev=i.map);else{let u=r2;o.syntax&&(u=o.syntax.parse),o.parser&&(u=o.parser),u.parse&&(u=u.parse);try{s=u(i,o)}catch(d){this.processed=!0,this.error=d}s&&!s[a2]&&e2.rebuild(s)}this.result=new jg(n,s,o),this.helpers={...Yd,postcss:Yd,result:this.result},this.plugins=this.processor.plugins.map(u=>typeof u=="object"&&u.prepare?{...u,...u.prepare(this.result)}:u)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(n){return this.async().catch(n)}finally(n){return this.async().then(n,n)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(n,i){let o=this.result.lastPlugin;try{i&&i.addToError(n),this.error=n,n.name==="CssSyntaxError"&&!n.plugin?(n.plugin=o.postcssPlugin,n.setMessage()):o.postcssVersion}catch(s){console&&console.error&&console.error(s)}return n}prepareVisitors(){this.listeners={};let n=(i,o,s)=>{this.listeners[o]||(this.listeners[o]=[]),this.listeners[o].push([i,s])};for(let i of this.plugins)if(typeof i=="object")for(let o in i){if(!l2[o]&&/^[A-Z]/.test(o))throw new Error(`Unknown event ${o} in ${i.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);if(!u2[o])if(typeof i[o]=="object")for(let s in i[o])s==="*"?n(i,o,i[o][s]):n(i,o+"-"+s.toLowerCase(),i[o][s]);else typeof i[o]=="function"&&n(i,o,i[o])}this.hasListener=Object.keys(this.listeners).length>0}async runAsync(){this.plugin=0;for(let n=0;n0;){let o=this.visitTick(i);if(qa(o))try{await o}catch(s){let u=i[i.length-1].node;throw this.handleError(s,u)}}}if(this.listeners.OnceExit)for(let[i,o]of this.listeners.OnceExit){this.result.lastPlugin=i;try{if(n.type==="document"){let s=n.nodes.map(u=>o(u,this.helpers));await Promise.all(s)}else await o(n,this.helpers)}catch(s){throw this.handleError(s)}}}return this.processed=!0,this.stringify()}runOnRoot(n){this.result.lastPlugin=n;try{if(typeof n=="object"&&n.Once){if(this.result.root.type==="document"){let i=this.result.root.nodes.map(o=>n.Once(o,this.helpers));return qa(i[0])?Promise.all(i):i}return n.Once(this.result.root,this.helpers)}else if(typeof n=="function")return n(this.result.root,this.result)}catch(i){throw this.handleError(i)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();let n=this.result.opts,i=o2;n.syntax&&(i=n.syntax.stringify),n.stringifier&&(i=n.stringifier),i.stringify&&(i=i.stringify);let o=new n2(i,this.result.root,this.result.opts).generate();return this.result.css=o[0],this.result.map=o[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(let n of this.plugins){let i=this.runOnRoot(n);if(qa(i))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){let n=this.result.root;for(;!n[Cr];)n[Cr]=!0,this.walkSync(n);if(this.listeners.OnceExit)if(n.type==="document")for(let i of n.nodes)this.visitSync(this.listeners.OnceExit,i);else this.visitSync(this.listeners.OnceExit,n)}return this.result}then(n,i){return this.async().then(n,i)}toString(){return this.css}visitSync(n,i){for(let[o,s]of n){this.result.lastPlugin=o;let u;try{u=s(i,this.helpers)}catch(d){throw this.handleError(d,i.proxyOf)}if(i.type!=="root"&&i.type!=="document"&&!i.parent)return!0;if(qa(u))throw this.getAsyncError()}}visitTick(n){let i=n[n.length-1],{node:o,visitors:s}=i;if(o.type!=="root"&&o.type!=="document"&&!o.parent){n.pop();return}if(s.length>0&&i.visitorIndex{s[Cr]||this.walkSync(s)});else{let s=this.listeners[o];if(s&&this.visitSync(s,n.toProxy()))return}}warnings(){return this.sync().warnings()}get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}};ta.registerPostcss=e=>{Yd=e};var ey=ta;ta.default=ta;i2.registerLazyResult(ta);t2.registerLazyResult(ta);let c2=Kv,d2=Wf;const f2=Gf;let h2=vu,Xd=class{constructor(e,n,i){n=n.toString(),this.stringified=!1,this._processor=e,this._css=n,this._opts=i,this._map=void 0;let o,s=h2;this.result=new f2(this._processor,o,this._opts),this.result.css=n;let u=this;Object.defineProperty(this.result,"root",{get(){return u.root}});let d=new c2(s,o,this._opts,n);if(d.isMap()){let[f,p]=d.generate();f&&(this.result.css=f),p&&(this.result.map=p)}else d.clearAnnotation(),this.result.css=d.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}sync(){if(this.error)throw this.error;return this.result}then(e,n){return this.async().then(e,n)}toString(){return this._css}warnings(){return[]}get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;let e,n=d2;try{e=n(this._css,this._opts)}catch(i){this.error=i}if(this.error)throw this.error;return this._root=e,e}get[Symbol.toStringTag](){return"NoWorkResult"}};var p2=Xd;Xd.default=Xd;let m2=Vf,g2=ey,v2=p2,y2=xs,ds=class{constructor(n=[]){this.version="8.4.47",this.plugins=this.normalize(n)}normalize(n){let i=[];for(let o of n)if(o.postcss===!0?o=o():o.postcss&&(o=o.postcss),typeof o=="object"&&Array.isArray(o.plugins))i=i.concat(o.plugins);else if(typeof o=="object"&&o.postcssPlugin)i.push(o);else if(typeof o=="function")i.push(o);else if(!(typeof o=="object"&&(o.parse||o.stringify)))throw new Error(o+" is not a PostCSS plugin");return i}process(n,i={}){return!this.plugins.length&&!i.parser&&!i.stringifier&&!i.syntax?new v2(this,n,i):new g2(this,n,i)}use(n){return this.plugins=this.plugins.concat(this.normalize([n])),this}};var w2=ds;ds.default=ds;y2.registerProcessor(ds);m2.registerProcessor(ds);let ty=Hf,ny=wu,x2=ho,C2=zf,ry=xu,iy=Vf,S2=EN,b2=Cu,_2=ey,E2=Vv,k2=yu,N2=Wf,Zf=w2,T2=Gf,oy=xs,ay=qf,j2=vu,P2=Yv;function it(...e){return e.length===1&&Array.isArray(e[0])&&(e=e[0]),new Zf(e)}it.plugin=function(e,n){let i=!1;function o(...u){console&&console.warn&&!i&&(i=!0,console.warn(e+`: postcss.plugin was deprecated. Migration guide: https://evilmartians.com/chronicles/postcss-8-plugin-migration`),ag.LANG&&ag.LANG.startsWith("cn")&&console.warn(e+`: 里面 postcss.plugin 被弃用. 迁移指南: -https://www.w3ctech.com/topic/2226`));let d=n(...u);return d.postcssPlugin=e,d.postcssVersion=new Zf().version,d}let s;return Object.defineProperty(o,"postcss",{get(){return s||(s=o()),s}}),o.process=function(u,d,f){return it([o(f)]).process(u,d)},o};it.stringify=j2;it.parse=N2;it.fromJSON=S2;it.list=E2;it.comment=e=>new ny(e);it.atRule=e=>new ty(e);it.decl=e=>new ry(e);it.rule=e=>new ay(e);it.root=e=>new oy(e);it.document=e=>new iy(e);it.CssSyntaxError=C2;it.Declaration=ry;it.Container=x2;it.Processor=Zf;it.Document=iy;it.Comment=ny;it.Warning=P2;it.AtRule=ty;it.Result=T2;it.Input=b2;it.Rule=ay;it.Root=oy;it.Node=k2;_2.registerPostcss(it);var M2=it;it.default=it;const{isPlainObject:$P}=Ff,{parse:zP}=M2,L2="_list_1whuj_1",D2="_compact_1whuj_5",O2="_pending_1whuj_8",Sd={list:L2,compact:D2,pending:O2};function R2(e){const{className:n,data:i,keySelector:o,renderer:s,rendererParams:u,pending:d,errored:f,filtered:p,errorMessage:y,emptyMessage:w,pendingMessage:C,filteredEmptyMessage:m,compact:x,withoutMessage:E=!1,messageClassName:b}=e,N=$e(i)||i.length===0;return g.jsxs("div",{className:Oe(Sd.list,x&&Sd.compact,d&&Sd.pending,n),children:[g.jsx(h0,{data:i,keySelector:o,renderer:s,rendererParams:u}),!E&&g.jsx(u0,{className:b,pending:d,filtered:p,empty:N,errored:f,compact:x,emptyMessage:w,filteredEmptyMessage:m,pendingMessage:C,errorMessage:y,overlayPending:!0})]})}function sy(e,n){if($e(e))return;const i={},o=[];return e.forEach(s=>{const u=n?n(s):JSON.stringify(s);i[u]||(i[u]=!0,o.push(s))}),e.length===o.length?e:o}const I2=[40,38,13,8];function A2(e,n,i){return n.findIndex((o,s)=>i(o,s)===e)}function Mg(e,n,i,o){if(i.length<=0)return;let s=A2(e,i,o);s===-1&&(s=n>0?-1:0);const u=Gx(s+n,i.length);return o(i[u],u)}function F2(e,n,i,o,s,u,d,f,p){return v.useCallback(y=>{const{keyCode:w}=y,C=e?.key;if(o&&(w===9||w===27))u();else if(!o&&I2.includes(w))y.stopPropagation(),y.preventDefault(),d();else if(w===13)if(Lt(C)){y.stopPropagation(),y.preventDefault();const m=i.find((x,E)=>n(x,E)===C);m&&f(C,m)}else y.stopPropagation(),y.preventDefault(),p&&p();else if(w===40){y.stopPropagation(),y.preventDefault();const m=Mg(C,1,i,n);s(m?{key:m}:void 0)}else if(w===38){y.stopPropagation(),y.preventDefault();const m=Mg(C,-1,i,n);s(m?{key:m}:void 0)}},[e,o,n,s,u,f,d,p,i])}const $2="_generic-option_zv1n8_1",z2={genericOption:$2};function B2(e){const{optionContainerClassName:n,contentRenderer:i,contentRendererParam:o,option:s,onClick:u,optionKey:d,focusedKey:f}=e,p=o(d,s),{containerClassName:y,title:w,...C}=p,m=f?.key===d,x=v.useRef(null);v.useEffect(()=>{f&&f.key===d&&!f.mouse&&x.current&&x.current.scrollIntoView({behavior:"smooth",block:"center"})},[d,f]);const E=v.useCallback(()=>{u(d,s)},[d,s,u]);return g.jsx(uf,{elementRef:x,className:Oe(z2.genericOption,n,y),onClick:E,title:w,name:d,focused:m,children:i(C)})}const U2="common",H2={infoMessageAnd:"and",infoMessageMore:"more",buttonTitleSelect:"Select all",buttonTitleClear:"Clear",buttonTitleClose:"Close",buttonTitleOpen:"Open",selectInputPendingMessage:"Fetching options...",selectInputEmptyMessage:"No option available",selectInputFilteredMessage:"No option available for the search",selectInputErrorMessage:"Could not load options"},V2={namespace:U2,strings:H2},q2="_popup_poyjv_1",W2="_list_poyjv_4",G2="_list-item_poyjv_9",Z2="_info-message_poyjv_14",Q2="_icon_poyjv_21",Si={popup:q2,list:W2,listItem:G2,infoMessage:Z2,icon:Q2},K2=[];function ly(e){const{actions:n,actionsContainerClassName:i,className:o,disabled:s,error:u,errorContainerClassName:d,hint:f,hintContainerClassName:p,icons:y,iconsContainerClassName:w,inputSectionClassName:C,label:m,labelClassName:x,name:E,onOptionClick:b,searchText:N,onSearchTextChange:P,optionContainerClassName:L,optionKeySelector:$,optionRenderer:q,optionRendererParams:Z,options:fe,optionsPopupClassName:O,persistentOptionPopup:K,readOnly:ce,placeholder:de,valueDisplay:I="",nonClearable:U,onClearButtonClick:W,onSelectAllButtonClick:ne,optionsPending:he=!1,optionsFiltered:Ce=!1,optionsErrored:_e=!1,focused:G,focusedKey:ue,onFocusedKeyChange:T,onFocusedChange:H,dropdownShown:oe,onDropdownShownChange:Se,totalOptionsCount:se=0,hasValue:re,autoFocus:ee,onEnterWithoutOption:Q,withAsterisk:Y,required:et,variant:tn,errorOnTooltip:Wt,dropdownHidden:ot}=e,bt=fe??K2,st=l0(V2),wt=v.useRef(null),ft=v.useRef(null),ht=v.useRef(null),xt=v.useRef(null),nn=v.useCallback(pt=>{oe||Se(!0),P(pt)},[oe,Se,P]),Tn=v.useCallback((pt,Kt)=>{Kt.stopPropagation(),Se(!oe)},[oe,Se]),ln=v.useCallback(()=>{oe||Se(!0)},[oe,Se]),jn=v.useCallback(()=>{Se(!1)},[Se]),Jr=v.useCallback(()=>{ce||ln()},[ce,ln]),un=v.useCallback((pt,Kt)=>{pt||Kt?K&&ht.current&&ht.current.focus():jn()},[jn,K]),cn=v.useCallback((pt,Kt)=>{b(pt,Kt,E),K||jn()},[b,jn,K,E]),Er=v.useCallback((pt,Kt)=>({contentRendererParam:Z,option:Kt,optionKey:pt,focusedKey:ue,contentRenderer:q,onClick:cn,onFocus:T,optionContainerClassName:Oe(L,Si.listItem)}),[ue,cn,T,L,q,Z]);FE(oe,un,xt,wt);const Kn=F2(ue,$,bt,oe,T,jn,ln,cn,Q),lt=bt.length,Dt=se-lt>0?`${st.infoMessageAnd} ${se-lt} ${st.infoMessageMore}`:void 0,Qt=oe&&!ot;return g.jsxs(g.Fragment,{children:[g.jsx(Pf,{actionsContainerClassName:i,className:o,containerRef:wt,disabled:s,errorContainerClassName:d,error:u,errorOnTooltip:Wt,hintContainerClassName:p,hint:f,iconsContainerClassName:w,icons:y,inputSectionClassName:C,inputSectionRef:ft,labelClassName:x,label:m,readOnly:ce,required:et,variant:tn,withAsterisk:Y,actions:g.jsxs(g.Fragment,{children:[n,!ce&&ne&&g.jsx(Ue,{onClick:ne,disabled:s,variant:"tertiary",name:void 0,title:st.buttonTitleSelect,children:g.jsx(EC,{className:Si.icon})}),!ce&&!U&&re&&g.jsx(Ue,{onClick:W,disabled:s,variant:"tertiary",name:void 0,title:st.buttonTitleClear,children:g.jsx(LC,{className:Si.icon})}),!ce&&g.jsx(Ue,{onClick:Tn,variant:"tertiary",name:void 0,title:Qt?st.buttonTitleClose:st.buttonTitleOpen,children:Qt?g.jsx(_C,{className:Si.icon}):g.jsx(SC,{className:Si.icon})})]}),input:g.jsx(X0,{name:E,elementRef:ht,readOnly:ce,disabled:s,value:oe||G?N:I,onChange:nn,onClick:Jr,onFocus:()=>H(!0),onBlur:()=>H(!1),placeholder:ps(I)?I:de,autoComplete:"off",onKeyDown:Kn,autoFocus:ee})}),Qt&&g.jsxs(c0,{elementRef:xt,parentRef:ft,className:Oe(O,Si.popup),children:[g.jsx(R2,{className:Si.list,data:bt,keySelector:$,renderer:B2,rendererParams:Er,errored:_e,filtered:Ce,pending:he,pendingMessage:st.selectInputPendingMessage,emptyMessage:st.selectInputEmptyMessage,filteredEmptyMessage:st.selectInputFilteredMessage,errorMessage:st.selectInputErrorMessage,compact:!0}),!he&&!_e&&!!Dt&&g.jsx("div",{className:Si.infoMessage,children:Dt})]})]})}function Y2(e){const{children:n,isActive:i,iconClassName:o,labelClassName:s}=e;return g.jsxs(g.Fragment,{children:[g.jsx("div",{className:o,children:i?g.jsx(jC,{}):g.jsx(TC,{})}),g.jsx("div",{className:s,children:n})]})}const X2="_option_1kpl9_1",J2="_active_1kpl9_7",eT="_icon_1kpl9_11",tT="_label_1kpl9_17",Wa={option:X2,active:J2,icon:eT,label:tT},bd=[];function nT(e){const{keySelector:n,labelSelector:i,name:o,onChange:s,onOptionsChange:u,options:d,optionsPending:f,optionsErrored:p,value:y,sortFunction:w,searchOptions:C,onSearchValueChange:m,onShowDropdownChange:x,hideOptionFilter:E,selectedOnTop:b,...N}=e,P=d??bd,L=C??bd,$=y??bd,[q,Z]=v.useState(),[fe,O]=v.useState(!1),[K,ce]=v.useState(!1),[de,I]=v.useState(),[U,W]=v.useState({}),ne=v.useMemo(()=>Ka(P,n,se=>se),[P,n]),he=v.useMemo(()=>Ka(P,n,i),[P,n,i]),Ce=v.useMemo(()=>$.map(se=>he[se]??"?").join(", "),[$,he]),_e=v.useMemo(()=>$.map(se=>ne[se]).filter(Lt),[$,ne]),G=v.useMemo(()=>{const se=sy([...L,..._e],n);if(!b)return w?w(se,q,i):se;const re=se.filter(Q=>U[n(Q)]),ee=se.filter(Q=>!U[n(Q)]&&($e(E)||E(Q)));return w?[...lo(re,q,i),...w(ee,q,i)]:[...lo(re,q,i),...ee]},[b,n,i,q,L,U,_e,w,E]),ue=v.useCallback(se=>{Z(se),m&&m(se)},[m]),T=v.useCallback(se=>{O(se),x&&x(se),se?(W(Ka($,re=>re,()=>!0)),I(void 0)):(W({}),I(void 0),Z(void 0),m&&m(void 0))},[$,m,x]),H=v.useCallback((se,re)=>{const ee=$.findIndex(Q=>Q===se)!==-1;return{children:i(re),containerClassName:Oe(Wa.option,ee&&Wa.active),title:i(re),isActive:ee,labelClassName:Wa.label,iconClassName:Wa.icon}},[i,$]),oe=v.useCallback((se,re)=>{const ee=[...$],Q=$.findIndex(Y=>Y===se);Q!==-1?ee.splice(Q,1):(ee.push(se),u&&u(Y=>{const et=Y??[];return et.find(tn=>n(tn)===se)?Y:[...et,re]})),s(ee,o)},[$,s,o,u,n]),Se=v.useCallback(()=>{s([],o)},[o,s]);return g.jsx(ly,{...N,name:o,options:G,optionsPending:f,optionsFiltered:ps(q)&&q.length>0,optionsErrored:p,optionKeySelector:n,optionRenderer:Y2,optionRendererParams:H,optionContainerClassName:Wa.optionContainer,onOptionClick:oe,valueDisplay:Ce,onClearButtonClick:Se,searchText:q,onSearchTextChange:ue,dropdownShown:fe,onDropdownShownChange:T,focused:K,onFocusedChange:ce,focusedKey:de,onFocusedKeyChange:I,persistentOptionPopup:!0,nonClearable:!1,hasValue:Lt($)&&$.length>0})}function Lg(e){const{name:n,options:i,keySelector:o,onChange:s,withSelectAll:u,...d}=e,f=v.useCallback(()=>{if($e(i))return;const p=i.map(o);s(p,n)},[i,n,s,o]);return g.jsx(nT,{...d,name:n,onChange:s,options:i,keySelector:o,sortFunction:lo,searchOptions:i,onSelectAllButtonClick:u?f:void 0,selectedOnTop:!1})}const rT="_page-container_1cfro_1",iT="_content_1cfro_2",Dg={pageContainer:rT,content:iT};function Qf(e){const{className:n,contentClassName:i,children:o,contentAs:s="div",containerAs:u="div"}=e,d=s;return g.jsx(u,{className:Oe(Dg.pageContainer,n),children:g.jsx(d,{className:Oe(Dg.content,i),children:o})})}const oT="_raw-input_145mq_1",aT={rawInput:oT};function sT(e){const{className:n,onChange:i,elementRef:o,value:s,name:u,...d}=e,f=fr.useCallback(p=>{var y;const w=(y=p?.target)==null?void 0:y.value;i&&i(w===""?void 0:w,u,p)},[u,i]);return g.jsx("textarea",{...d,ref:o,className:Oe(aT.rawInput,n),name:Lt(u)?String(u):void 0,onChange:f,value:s??""})}const lT="_option_11p37_1",uT="_icon_11p37_6",cT="_label_11p37_14",dT="_overflow-container_11p37_20",fT="_description_11p37_25",Vo={option:lT,icon:uT,label:cT,overflowContainer:dT,description:fT};function hT(e){const{className:n,label:i,description:o,iconClassName:s,labelClassName:u}=e;return g.jsxs("div",{className:Oe(Vo.option,n),children:[g.jsx("div",{className:Oe(Vo.icon,s),children:g.jsx(kC,{})}),g.jsxs("div",{className:Oe(Vo.label,u),children:[g.jsx("div",{className:Vo.overflowContainer,children:i}),g.jsx("div",{className:Oe(Vo.overflowContainer,Vo.description),children:o})]})]})}const pT="_option-container_2k92q_1",mT="_option_2k92q_1",gT="_active_2k92q_9",vT="_icon_2k92q_12",Ga={optionContainer:pT,option:mT,active:gT,icon:vT},Og=[];function Rg(e){const{keySelector:n,labelSelector:i,descriptionSelector:o,name:s,onChange:u,onOptionsChange:d,options:f,optionsPending:p,optionsErrored:y,value:w,sortFunction:C,searchOptions:m,onSearchValueChange:x,onShowDropdownChange:E,hideOptionFilter:b,selectedOnTop:N,onEnterWithoutOption:P,...L}=e,$=f??Og,q=m??Og,[Z,fe]=v.useState(),[O,K]=v.useState(!1),[ce,de]=v.useState(!1),[I,U]=v.useState(),[W,ne]=v.useState({}),he=v.useMemo(()=>Ka($,n,i),[$,n,i]),Ce=Lt(w)?he[w]??"?":"",_e=v.useMemo(()=>{const re=$?.find(ee=>n(ee)===w);return $e(re)?[]:[re]},[w,$,n]),G=v.useMemo(()=>{const re=sy([...q,..._e],n);if(!N)return C?C(re,Z,i):re;const ee=re.filter(Y=>W[n(Y)]),Q=re.filter(Y=>!W[n(Y)]&&($e(b)||b(Y)));return C?[...lo(ee,Z,i),...C(Q,Z,i)]:[...lo(ee,Z,i),...Q]},[N,n,i,Z,q,W,_e,C,b]),ue=v.useCallback(re=>{fe(re),x&&x(re)},[x]),T=v.useCallback(()=>{K(!1),E&&E(!1),fe(void 0),x&&x(void 0),P&&P(Z)},[Z,E,P,x]),H=v.useCallback(re=>{K(re),E&&E(re),re?(ne(Ka(w?[w]:[],ee=>ee,()=>!0)),U(w?{key:w}:void 0)):(ne({}),U(void 0),fe(void 0),x&&x(void 0))},[w,x,E]),oe=v.useCallback((re,ee)=>{const Q=re===w;return{label:i(ee),description:o?o(ee):void 0,containerClassName:Oe(Ga.optionContainer,Q&&Ga.active),title:i(ee),className:Ga.option,iconClassName:Ga.icon}},[w,i,o]),Se=v.useCallback((re,ee)=>{d&&d(Q=>{const Y=Q??[];return Y.find(et=>n(et)===re)?Q:[...Y,ee]}),u(re,s,ee)},[u,s,d,n]),se=v.useCallback(()=>{if(!e.nonClearable){const re=e.onChange;re(void 0,s,void 0)}},[s,e.onChange,e.nonClearable]);return g.jsx(ly,{...L,name:s,options:G,optionsPending:p,optionsErrored:y,optionsFiltered:ps(Z)&&Z.length>0,optionKeySelector:n,optionRenderer:hT,optionRendererParams:oe,optionContainerClassName:Ga.optionContainer,onOptionClick:Se,valueDisplay:Ce,onClearButtonClick:se,searchText:Z,onSearchTextChange:ue,dropdownShown:O,onDropdownShownChange:H,focused:ce,onFocusedChange:de,focusedKey:I,onFocusedKeyChange:U,hasValue:Lt(w),persistentOptionPopup:!1,onEnterWithoutOption:T})}const yT="_segment-input_bykt7_1",wT="_segment-list_bykt7_4",xT="_segment_bykt7_1",CT="_active_bykt7_18",ST="_secondary-variant_bykt7_24",Xa={segmentInput:yT,segmentList:wT,segment:xT,active:CT,secondaryVariant:ST};function bT(e){const{label:n,name:i,onClick:o,value:s,className:u,variant:d="primary",inputName:f,...p}=e;return g.jsx(Ue,{...p,className:Oe(Xa.segment,s&&Xa.active,d==="secondary"&&Xa.secondaryVariant,u),name:i,onClick:o,variant:"tertiary",children:n})}function _T(e){const{rendererParams:n,listContainerClassName:i,keySelector:o,labelSelector:s,className:u,...d}=e;return g.jsx(wb,{className:Oe(u,Xa.segmentInput),...d,renderer:bT,rendererParams:n,listContainerClassName:Oe(i,Xa.segmentList),keySelector:o,labelSelector:s})}function eo(e){const{name:n,options:i,nonClearable:o,onChange:s,...u}=e;return e.nonClearable?g.jsx(Rg,{...u,onChange:e.onChange,nonClearable:e.nonClearable,name:n,options:i,sortFunction:lo,searchOptions:i,selectedOnTop:!1}):g.jsx(Rg,{...u,onChange:e.onChange,nonClearable:e.nonClearable,name:n,options:i,sortFunction:lo,searchOptions:i,selectedOnTop:!1})}v.createContext({tabs:[],step:0,disabled:!1,activeTab:"",variant:"primary",setActiveTab:()=>{console.warn("setActiveTab called before it was initialized")},registerTab:()=>{console.warn("registerTab called before it was initialized")},unregisterTab:()=>{console.warn("unregisterTab called before it was initialized")}});const Ig="•",ET="Enter";function kT(e){const{actions:n,className:i,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputClassName:p,label:y,labelClassName:w,readOnly:C,required:m,variant:x,inputSectionClassName:E,withAsterisk:b,onChange:N,name:P,autoBullets:L=!1,rows:$=5,...q}=e,Z=fr.useCallback(O=>{$e(N)||O.target.value===""&&N(`${Ig} `,P)},[N,P]),fe=fr.useCallback(O=>{$e(N)||O.key===ET&&N(`${O.currentTarget.value}${Ig} `,P)},[N,P]);return g.jsx(Pf,{actions:n,className:i,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputSectionClassName:E,labelClassName:w,label:y,readOnly:C,required:m,variant:x,withAsterisk:b,input:g.jsx(sT,{...q,readOnly:C,disabled:o,className:p,onChange:N,name:P,onFocus:L?Z:void 0,onKeyUp:L?fe:void 0,rows:$})})}function jt(e){const{actions:n,className:i,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputClassName:p,inputSectionClassName:y,label:w,readOnly:C,required:m,variant:x,withAsterisk:E,type:b="text",...N}=e;return g.jsx(Pf,{className:i,actions:n,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputSectionClassName:y,label:w,required:m,readOnly:C,variant:x,withAsterisk:E,input:g.jsx(X0,{...N,required:m,readOnly:C,disabled:o,className:p,type:b})})}const NT="_dropdownContainer_1six7_3",TT="_dropdownMenu_1six7_15",jT="_dropdownContent_1six7_43",_d={dropdownContainer:NT,dropdownMenu:TT,dropdownContent:jT},PT=[{to:"/upload",label:"Upload",Icon:s0},{to:"/explore",label:"Explore",Icon:AC},{to:"/analytics",label:"Analytics",Icon:a0}];function MT(){const e=ra(),n=hs(),[i,o]=v.useState(!1),s=v.useRef(null);return v.useEffect(()=>{const u=d=>{s.current&&!s.current.contains(d.target)&&o(!1)};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[]),g.jsx("nav",{className:"border-b border-gray-200 bg-white shadow-sm sticky top-0 z-50 backdrop-blur-sm bg-white/95",children:g.jsxs(Qf,{className:"border-b-2 border-ifrcRed",contentClassName:"grid grid-cols-3 items-center py-6",children:[g.jsxs("div",{className:"flex items-center gap-4 min-w-0 cursor-pointer group transition-all duration-200 hover:scale-105",onClick:()=>{if(!(e.pathname==="/upload"||e.pathname==="/")){if(e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n("/")}},children:[g.jsx("div",{className:"p-2 rounded-lg bg-gradient-to-br from-ifrcRed/10 to-ifrcRed/20 group-hover:from-ifrcRed/20 group-hover:to-ifrcRed/30 transition-all duration-200",children:g.jsx(DC,{className:"h-8 w-8 flex-shrink-0 text-ifrcRed"})}),g.jsx("div",{className:"flex flex-col",children:g.jsx("span",{className:"font-bold text-xl text-gray-900 leading-tight",children:"PromptAid Vision"})})]}),g.jsx("div",{className:"flex justify-center",children:g.jsx("nav",{className:"flex items-center space-x-4 bg-gray-50/80 rounded-xl p-2 backdrop-blur-sm",children:PT.map(({to:u,label:d,Icon:f})=>{const p=e.pathname===u||u==="/upload"&&e.pathname==="/"||u==="/explore"&&e.pathname.startsWith("/map/"),y=e.pathname==="/upload"||e.pathname==="/",w=u==="/upload"||u==="/";return g.jsxs("div",{className:"relative",children:[g.jsx(dr,{withInternalPadding:!0,className:"p-2",children:g.jsxs(Ue,{name:d.toLowerCase(),variant:p?"primary":"tertiary",size:1,className:`transition-all duration-200 ${p?"shadow-lg shadow-ifrcRed/20 transform scale-105":"hover:bg-white hover:shadow-md hover:scale-105"}`,onClick:()=>{if(!(y&&w)){if(e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded(u);return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n(u)}},children:[g.jsx(f,{className:`w-4 h-4 transition-transform duration-200 ${p?"scale-110":"group-hover:scale-110"}`}),g.jsx("span",{className:"inline ml-2 font-semibold",children:d})]})}),p&&g.jsx("div",{className:"absolute -bottom-2 left-1/2 transform -translate-x-1/2 w-8 h-1 bg-ifrcRed rounded-full animate-pulse"})]},u)})})}),g.jsx("div",{className:"flex justify-end",children:g.jsxs("div",{className:_d.dropdownContainer,ref:s,children:[g.jsx(dr,{withInternalPadding:!0,className:"p-2",children:g.jsx(Ue,{name:"more-options",variant:i?"primary":"tertiary",size:1,className:"transition-all duration-200",onClick:()=>o(!i),children:g.jsx(OC,{className:"w-4 h-4"})})}),i&&g.jsx("div",{className:_d.dropdownMenu,children:g.jsxs("div",{className:_d.dropdownContent,children:[g.jsx(dr,{withInternalPadding:!0,className:"p-2",children:g.jsxs(Ue,{name:"help-support",variant:"tertiary",size:1,className:"w-full justify-start",onClick:()=>{if(o(!1),e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/help");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n("/help")},children:[g.jsx(RC,{className:"w-4 h-4"}),g.jsx("span",{className:"ml-2 font-semibold",children:"Help & Support"})]})}),g.jsx(dr,{withInternalPadding:!0,className:"p-2",children:g.jsxs(Ue,{name:"dev",variant:"tertiary",size:1,className:"w-full justify-start",onClick:()=>{if(o(!1),e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/admin");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n("/admin")},children:[g.jsx(FC,{className:"w-4 h-4"}),g.jsx("span",{className:"ml-2 font-semibold",children:"Dev"})]})})]})})]})})]})})}function LT(){return g.jsxs(g.Fragment,{children:[g.jsx(MT,{}),g.jsx(lx,{})]})}const DT="_uploadContainer_1i3bv_1",OT="_dropZone_1i3bv_9",RT="_hasFile_1i3bv_30",IT="_dropZoneIcon_1i3bv_37",AT="_dropZoneText_1i3bv_43",FT="_dropZoneSubtext_1i3bv_49",$T="_filePreview_1i3bv_55",zT="_filePreviewImage_1i3bv_64",BT="_fileName_1i3bv_110",UT="_fileInfo_1i3bv_118",HT="_helpLink_1i3bv_125",VT="_loadingContainer_1i3bv_145",qT="_loadingText_1i3bv_153",WT="_generateButtonContainer_1i3bv_157",GT="_uploadedMapContainer_1i3bv_165",ZT="_uploadedMapImage_1i3bv_169",QT="_formGrid_1i3bv_209",KT="_titleField_1i3bv_222",YT="_ratingDescription_1i3bv_230",XT="_ratingSlider_1i3bv_235",JT="_ratingLabel_1i3bv_242",ej="_ratingInput_1i3bv_251",tj="_ratingValue_1i3bv_256",nj="_submitSection_1i3bv_266",rj="_successContainer_1i3bv_275",ij="_successHeading_1i3bv_280",oj="_successText_1i3bv_285",aj="_successButton_1i3bv_291",sj="_viewFullSizeButton_1i3bv_297",lj="_fullSizeModalOverlay_1i3bv_306",uj="_lightModalOverlay_1i3bv_320",cj="_fullSizeModalContent_1i3bv_334",dj="_fullSizeModalHeader_1i3bv_345",fj="_fullSizeModalImage_1i3bv_361",hj="_confirmSection_1i3bv_398",pj="_step2Layout_1i3bv_407",mj="_topRow_1i3bv_413",gj="_ratingHidden_1i3bv_421",vj="_imageSection_1i3bv_425",yj="_ratingContent_1i3bv_435",wj="_mapColumn_1i3bv_453",xj="_contentColumn_1i3bv_458",Cj="_step2bLayout_1i3bv_465",Sj="_metadataSectionCard_1i3bv_562",bj="_droneMetadataSection_1i3bv_571",_j="_droneMetadataHeading_1i3bv_577",Ej="_droneMetadataGrid_1i3bv_585",kj="_rtkFixContainer_1i3bv_591",Nj="_rtkFixLabel_1i3bv_597",Tj="_rtkFixCheckbox_1i3bv_606",jj="_confirmButtonContainer_1i3bv_621",Pj="_ratingWarningContent_1i3bv_629",Mj="_ratingWarningTitle_1i3bv_637",Lj="_ratingWarningText_1i3bv_644",Dj="_ratingWarningButtons_1i3bv_651",Oj="_fallbackReasonBox_1i3bv_659",Rj="_fallbackReasonTitle_1i3bv_668",Ij="_fallbackReasonText_1i3bv_675",Aj="_preprocessingProgress_1i3bv_682",Fj="_carouselContainer_1i3bv_735",$j="_carouselImageWrapper_1i3bv_740",zj="_carouselImage_1i3bv_740",Bj="_carouselNavigation_1i3bv_763",Uj="_carouselButton_1i3bv_775",Hj="_carouselIndicators_1i3bv_799",Vj="_carouselIndicator_1i3bv_799",qj="_carouselIndicatorActive_1i3bv_828",Wj="_viewImageButtonContainer_1i3bv_864",V={uploadContainer:DT,dropZone:OT,hasFile:RT,dropZoneIcon:IT,dropZoneText:AT,dropZoneSubtext:FT,filePreview:$T,filePreviewImage:zT,fileName:BT,fileInfo:UT,helpLink:HT,loadingContainer:VT,loadingText:qT,generateButtonContainer:WT,uploadedMapContainer:GT,uploadedMapImage:ZT,formGrid:QT,titleField:KT,ratingDescription:YT,ratingSlider:XT,ratingLabel:JT,ratingInput:ej,ratingValue:tj,submitSection:nj,successContainer:rj,successHeading:ij,successText:oj,successButton:aj,viewFullSizeButton:sj,fullSizeModalOverlay:lj,lightModalOverlay:uj,fullSizeModalContent:cj,fullSizeModalHeader:dj,fullSizeModalImage:fj,confirmSection:hj,step2Layout:pj,topRow:mj,ratingHidden:gj,imageSection:vj,ratingContent:yj,mapColumn:wj,contentColumn:xj,step2bLayout:Cj,metadataSectionCard:Sj,droneMetadataSection:bj,droneMetadataHeading:_j,droneMetadataGrid:Ej,rtkFixContainer:kj,rtkFixLabel:Nj,rtkFixCheckbox:Tj,confirmButtonContainer:jj,ratingWarningContent:Pj,ratingWarningTitle:Mj,ratingWarningText:Lj,ratingWarningButtons:Dj,fallbackReasonBox:Oj,fallbackReasonTitle:Rj,fallbackReasonText:Ij,preprocessingProgress:Aj,carouselContainer:Fj,carouselImageWrapper:$j,carouselImage:zj,carouselNavigation:Bj,carouselButton:Uj,carouselIndicators:Hj,carouselIndicator:Vj,carouselIndicatorActive:qj,viewImageButtonContainer:Wj},uy=v.createContext(void 0),Gj=({children:e})=>{const[n,i]=v.useState(""),[o,s]=v.useState(""),[u,d]=v.useState(""),[f,p]=v.useState(""),[y,w]=v.useState(""),[C,m]=v.useState(""),[x,E]=v.useState(""),[b,N]=v.useState(!1),L={search:n,srcFilter:o,catFilter:u,regionFilter:f,countryFilter:y,imageTypeFilter:C,uploadTypeFilter:x,showReferenceExamples:b,setSearch:i,setSrcFilter:s,setCatFilter:d,setRegionFilter:p,setCountryFilter:w,setImageTypeFilter:m,setUploadTypeFilter:E,setShowReferenceExamples:N,clearAllFilters:()=>{i(""),s(""),d(""),p(""),w(""),m(""),E(""),N(!1)}};return g.jsx(uy.Provider,{value:L,children:e})},Zj=()=>{const e=v.useContext(uy);if(e===void 0)throw new Error("useFilterContext must be used within a FilterProvider");return e};function Ag({files:e,file:n,preview:i,imageType:o,onFileChange:s,onRemoveImage:u,onAddImage:d,onImageTypeChange:f,onChangeFile:p}){const y=w=>{w.preventDefault();const C=w.dataTransfer.files?.[0];C&&s(C)};return g.jsxs("div",{className:"space-y-6",children:[g.jsx("p",{className:"text-gray-700 leading-relaxed max-w-2xl mx-auto",children:"This app evaluates how well multimodal AI models analyze and describe crisis maps and drone imagery. Upload an image and the AI will generate a description. Then you can review and rate the result based on your expertise."}),g.jsx("div",{className:V.helpLink,children:g.jsxs(Mx,{to:"/help",className:V.helpLink,children:["More ",g.jsx(bC,{className:"w-3 h-3"})]})}),g.jsx("div",{className:"flex justify-center",children:g.jsx(dr,{withInternalPadding:!0,className:"bg-transparent border-none shadow-none",children:g.jsx(_T,{name:"image-type",value:o,onChange:w=>f(w),options:[{key:"crisis_map",label:"Crisis Maps"},{key:"drone_image",label:"Drone Imagery"}],keySelector:w=>w.key,labelSelector:w=>w.label})})}),g.jsxs("div",{className:`${V.dropZone} ${n?V.hasFile:""}`,onDragOver:w=>w.preventDefault(),onDrop:y,children:[e.length>1?g.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4 mb-4",children:e.map((w,C)=>g.jsxs("div",{className:"relative",children:[g.jsx("img",{src:URL.createObjectURL(w),alt:`Image ${C+1}`,className:"w-full h-32 object-cover rounded"}),g.jsx(hf,{name:"remove-image",variant:"tertiary",onClick:()=>u(C),title:"Remove image",ariaLabel:"Remove image",className:"absolute top-2 right-2 bg-white/90 hover:bg-white shadow-md hover:shadow-lg border border-gray-200 hover:border-red-300 transition-all duration-200 backdrop-blur-sm",children:g.jsx(df,{className:"w-4 h-4"})}),g.jsx("div",{className:"text-xs text-center mt-1",children:w.name})]},C))}):n&&i?g.jsxs("div",{className:V.filePreview,children:[g.jsx("div",{className:V.filePreviewImage,children:g.jsx("img",{src:i,alt:"File preview"})}),g.jsx("p",{className:V.fileName,children:n.name}),g.jsxs("p",{className:V.fileInfo,children:[(n.size/1024/1024).toFixed(2)," MB"]})]}):g.jsxs(g.Fragment,{children:[g.jsx(s0,{className:V.dropZoneIcon}),g.jsx("p",{className:V.dropZoneText,children:"Drag & Drop any file here"}),g.jsx("p",{className:V.dropZoneSubtext,children:"or"})]}),g.jsxs("div",{className:"flex gap-2",children:[g.jsxs("label",{className:"inline-block cursor-pointer",children:[g.jsx("input",{type:"file",className:"sr-only",accept:".jpg,.jpeg,.png,.tiff,.tif,.heic,.heif,.webp,.gif,.pdf",onChange:w=>{n&&p?p(w.target.files?.[0]):s(w.target.files?.[0])}}),g.jsx(Ue,{name:"upload",variant:"secondary",size:1,onClick:()=>document.querySelector('input[type="file"]')?.click(),children:n?"Change Image":"Browse Files"})]}),n&&e.length<5&&g.jsx(Ue,{name:"add-image",variant:"secondary",size:1,onClick:d,children:"Add Image"})]})]})]})}function Fg({files:e,imageUrl:n,preview:i,onViewFullSize:o,currentImageIndex:s=0,onGoToPrevious:u,onGoToNext:d,onGoToImage:f,showCarousel:p=!1}){return p&&e.length>1?g.jsx(dr,{heading:"Uploaded Images",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:g.jsxs("div",{className:V.carouselContainer,children:[g.jsx("div",{className:V.carouselImageWrapper,children:e[s]?g.jsx("img",{src:URL.createObjectURL(e[s]),alt:`Image ${s+1}`,className:V.carouselImage}):g.jsx("div",{className:V.imagePlaceholder,children:"No image available"})}),g.jsxs("div",{className:V.carouselNavigation,children:[g.jsx(Ue,{name:"previous-image",variant:"tertiary",size:1,onClick:u,className:V.carouselButton,children:g.jsx(PC,{className:"w-4 h-4"})}),g.jsx("div",{className:V.carouselIndicators,children:e.map((y,w)=>g.jsx("button",{onClick:()=>f?.(w),className:`${V.carouselIndicator} ${w===s?V.carouselIndicatorActive:""}`,children:w+1},w))}),g.jsx(Ue,{name:"next-image",variant:"tertiary",size:1,onClick:d,className:V.carouselButton,children:g.jsx(MC,{className:"w-4 h-4"})})]}),g.jsx("div",{className:V.viewImageButtonContainer,children:g.jsx(Ue,{name:"view-full-size-carousel",variant:"secondary",size:1,onClick:()=>o({file:e[s],index:s}),disabled:!e[s],children:"View Image"})})]})}):e.length>1?g.jsx("div",{className:"space-y-6",children:e.map((y,w)=>g.jsx(dr,{heading:`Image ${w+1}: ${y.name}`,headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:g.jsxs("div",{className:V.uploadedMapContainer,children:[g.jsx("div",{className:V.uploadedMapImage,children:g.jsx("img",{src:URL.createObjectURL(y),alt:`Image ${w+1}`})}),g.jsx("div",{className:V.viewFullSizeButton,children:g.jsx(Ue,{name:`view-full-size-${w}`,variant:"secondary",size:1,onClick:()=>o({file:y,index:w}),children:"View Image"})})]})},w))}):g.jsx(dr,{heading:"Uploaded Image",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:g.jsxs("div",{className:V.uploadedMapContainer,children:[g.jsx("div",{className:V.uploadedMapImage,children:g.jsx("img",{src:n||i||void 0,alt:"Uploaded image preview"})}),g.jsx("div",{className:V.viewFullSizeButton,children:g.jsx(Ue,{name:"view-full-size",variant:"secondary",size:1,onClick:()=>o(),children:"View Image"})})]})})}function Qj({files:e,imageType:n,title:i,source:o,eventType:s,epsg:u,countries:d,centerLon:f,centerLat:p,amslM:y,aglM:w,headingDeg:C,yawDeg:m,pitchDeg:x,rollDeg:E,rtkFix:b,stdHM:N,stdVM:P,metadataArray:L,sources:$,types:q,spatialReferences:Z,imageTypes:fe,countriesOptions:O,onTitleChange:K,onSourceChange:ce,onEventTypeChange:de,onEpsgChange:I,onCountriesChange:U,onCenterLonChange:W,onCenterLatChange:ne,onAmslMChange:he,onAglMChange:Ce,onHeadingDegChange:_e,onYawDegChange:G,onPitchDegChange:ue,onRollDegChange:T,onRtkFixChange:H,onStdHMChange:oe,onStdVMChange:Se,onImageTypeChange:se,updateMetadataForImage:re}){return e.length>1?g.jsxs("div",{children:[g.jsx("div",{className:"mb-4",children:g.jsx(jt,{label:"Shared Title",name:"title",value:i,onChange:K,placeholder:"Enter a title for all images...",required:!0})}),e.map((ee,Q)=>g.jsx("div",{className:"mb-6",children:g.jsx(dr,{heading:`Image ${Q+1}: ${ee.name}`,headingLevel:4,withHeaderBorder:!0,withInternalPadding:!0,children:g.jsxs("div",{className:V.formGrid,children:[n!=="drone_image"&&g.jsx(eo,{label:"Source",name:`source_${Q}`,value:L[Q]?.source||"",onChange:Y=>re(Q,"source",Y),options:$,keySelector:Y=>Y.s_code,labelSelector:Y=>Y.label,required:!0}),g.jsx(eo,{label:"Event Type",name:`event_type_${Q}`,value:L[Q]?.eventType||"",onChange:Y=>re(Q,"eventType",Y),options:q,keySelector:Y=>Y.t_code,labelSelector:Y=>Y.label,required:n!=="drone_image"}),g.jsx(eo,{label:"EPSG",name:`epsg_${Q}`,value:L[Q]?.epsg||"",onChange:Y=>re(Q,"epsg",Y),options:Z,keySelector:Y=>Y.epsg,labelSelector:Y=>`${Y.srid} (EPSG:${Y.epsg})`,placeholder:"EPSG",required:n!=="drone_image"}),g.jsx(Lg,{label:"Countries (optional)",name:`countries_${Q}`,value:L[Q]?.countries||[],onChange:Y=>re(Q,"countries",Y),options:O,keySelector:Y=>Y.c_code,labelSelector:Y=>Y.label,placeholder:"Select one or more"}),n==="drone_image"&&g.jsx(g.Fragment,{children:g.jsxs("div",{className:V.droneMetadataSection,children:[g.jsx("h4",{className:V.droneMetadataHeading,children:"Drone Flight Data"}),g.jsxs("div",{className:V.droneMetadataGrid,children:[g.jsx(jt,{label:"Center Longitude",name:`center_lon_${Q}`,value:L[Q]?.centerLon||"",onChange:Y=>re(Q,"centerLon",Y),placeholder:"e.g., -122.4194",step:"any"}),g.jsx(jt,{label:"Center Latitude",name:`center_lat_${Q}`,value:L[Q]?.centerLat||"",onChange:Y=>re(Q,"centerLat",Y),placeholder:"e.g., 37.7749",step:"any"}),g.jsx(jt,{label:"Altitude AMSL (m)",name:`amsl_m_${Q}`,value:L[Q]?.amslM||"",onChange:Y=>re(Q,"amslM",Y),placeholder:"e.g., 100.5",step:"any"}),g.jsx(jt,{label:"Altitude AGL (m)",name:`agl_m_${Q}`,value:L[Q]?.aglM||"",onChange:Y=>re(Q,"aglM",Y),placeholder:"e.g., 50.2",step:"any"}),g.jsx(jt,{label:"Heading (degrees)",name:`heading_deg_${Q}`,value:L[Q]?.headingDeg||"",onChange:Y=>re(Q,"headingDeg",Y),placeholder:"e.g., 180.0",step:"any"}),g.jsx(jt,{label:"Yaw (degrees)",name:`yaw_deg_${Q}`,value:L[Q]?.yawDeg||"",onChange:Y=>re(Q,"yawDeg",Y),placeholder:"e.g., 90.0",step:"any"}),g.jsx(jt,{label:"Pitch (degrees)",name:`pitch_deg_${Q}`,value:L[Q]?.pitchDeg||"",onChange:Y=>re(Q,"pitchDeg",Y),placeholder:"e.g., 0.0",step:"any"}),g.jsx(jt,{label:"Roll (degrees)",name:`roll_deg_${Q}`,value:L[Q]?.rollDeg||"",onChange:Y=>re(Q,"rollDeg",Y),placeholder:"e.g., 0.0",step:"any"}),g.jsx("div",{className:V.rtkFixContainer,children:g.jsxs("label",{className:V.rtkFixLabel,children:[g.jsx("input",{type:"checkbox",checked:L[Q]?.rtkFix||!1,onChange:Y=>re(Q,"rtkFix",Y.target.checked),className:V.rtkFixCheckbox}),"RTK Fix Available"]})}),g.jsx(jt,{label:"Horizontal Std Dev (m)",name:`std_h_m_${Q}`,value:L[Q]?.stdHM||"",onChange:Y=>re(Q,"stdHM",Y),placeholder:"e.g., 0.1",step:"any"}),g.jsx(jt,{label:"Vertical Std Dev (m)",name:`std_v_m_${Q}`,value:L[Q]?.stdVM||"",onChange:Y=>re(Q,"stdVM",Y),placeholder:"e.g., 0.2",step:"any"})]})]})})]})})},Q))]}):g.jsxs("div",{className:V.formGrid,children:[g.jsx("div",{className:V.titleField,children:g.jsx(jt,{label:"Title",name:"title",value:i,onChange:K,placeholder:"Enter a title for this map...",required:!0})}),n!=="drone_image"&&g.jsx(eo,{label:"Source",name:"source",value:o,onChange:ce,options:$,keySelector:ee=>ee.s_code,labelSelector:ee=>ee.label,required:!0}),g.jsx(eo,{label:"Event Type",name:"event_type",value:s,onChange:de,options:q,keySelector:ee=>ee.t_code,labelSelector:ee=>ee.label,required:n!=="drone_image"}),g.jsx(eo,{label:"EPSG",name:"epsg",value:u,onChange:I,options:Z,keySelector:ee=>ee.epsg,labelSelector:ee=>`${ee.srid} (EPSG:${ee.epsg})`,placeholder:"EPSG",required:n!=="drone_image"}),g.jsx(eo,{label:"Image Type",name:"image_type",value:n,onChange:se,options:fe,keySelector:ee=>ee.image_type,labelSelector:ee=>ee.label,required:!0}),g.jsx(Lg,{label:"Countries (optional)",name:"countries",value:d,onChange:U,options:O,keySelector:ee=>ee.c_code,labelSelector:ee=>ee.label,placeholder:"Select one or more"}),n==="drone_image"&&g.jsx(g.Fragment,{children:g.jsxs("div",{className:V.droneMetadataSection,children:[g.jsx("h4",{className:V.droneMetadataHeading,children:"Drone Flight Data"}),g.jsxs("div",{className:V.droneMetadataGrid,children:[g.jsx(jt,{label:"Center Longitude",name:"center_lon",value:f,onChange:W,placeholder:"e.g., -122.4194",step:"any"}),g.jsx(jt,{label:"Center Latitude",name:"center_lat",value:p,onChange:ne,placeholder:"e.g., 37.7749",step:"any"}),g.jsx(jt,{label:"Altitude AMSL (m)",name:"amsl_m",value:y,onChange:he,placeholder:"e.g., 100.5",step:"any"}),g.jsx(jt,{label:"Altitude AGL (m)",name:"agl_m",value:w,onChange:Ce,placeholder:"e.g., 50.2",step:"any"}),g.jsx(jt,{label:"Heading (degrees)",name:"heading_deg",value:C,onChange:_e,placeholder:"e.g., 180.0",step:"any"}),g.jsx(jt,{label:"Yaw (degrees)",name:"yaw_deg",value:m,onChange:G,placeholder:"e.g., 90.0",step:"any"}),g.jsx(jt,{label:"Pitch (degrees)",name:"pitch_deg",value:x,onChange:ue,placeholder:"e.g., 0.0",step:"any"}),g.jsx(jt,{label:"Roll (degrees)",name:"roll_deg",value:E,onChange:T,placeholder:"e.g., 0.0",step:"any"}),g.jsx("div",{className:V.rtkFixContainer,children:g.jsxs("label",{className:V.rtkFixLabel,children:[g.jsx("input",{type:"checkbox",checked:b,onChange:ee=>H(ee.target.checked),className:V.rtkFixCheckbox}),"RTK Fix Available"]})}),g.jsx(jt,{label:"Horizontal Std Dev (m)",name:"std_h_m",value:N,onChange:oe,placeholder:"e.g., 0.1",step:"any"}),g.jsx(jt,{label:"Vertical Std Dev (m)",name:"std_v_m",value:P,onChange:Se,placeholder:"e.g., 0.2",step:"any"})]})]})})]})}function Kj({isPerformanceConfirmed:e,scores:n,onScoreChange:i,onConfirmRatings:o,onEditRatings:s}){return e?null:g.jsx(dr,{heading:"AI Performance Rating",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:g.jsxs("div",{className:V.ratingContent,children:[g.jsx("p",{className:V.ratingDescription,children:"How well did the AI perform on the task?"}),["accuracy","context","usability"].map(u=>g.jsxs("div",{className:V.ratingSlider,children:[g.jsx("label",{className:V.ratingLabel,children:u}),g.jsx("input",{type:"range",min:0,max:100,value:n[u],onChange:d=>i(u,Number(d.target.value)),className:V.ratingInput}),g.jsx("span",{className:V.ratingValue,children:n[u]})]},u)),g.jsx("div",{className:V.confirmButtonContainer,children:g.jsx(Ue,{name:"confirm-ratings",variant:"secondary",onClick:o,children:"Confirm Ratings"})})]})})}function Yj({description:e,analysis:n,recommendedActions:i,onDescriptionChange:o,onAnalysisChange:s,onRecommendedActionsChange:u,onBack:d,onDelete:f,onSubmit:p,onEditRatings:y,isPerformanceConfirmed:w=!1,isSubmitting:C=!1}){const m=x=>{if(x){const E=x.split(` +https://www.w3ctech.com/topic/2226`));let d=n(...u);return d.postcssPlugin=e,d.postcssVersion=new Zf().version,d}let s;return Object.defineProperty(o,"postcss",{get(){return s||(s=o()),s}}),o.process=function(u,d,f){return it([o(f)]).process(u,d)},o};it.stringify=j2;it.parse=N2;it.fromJSON=S2;it.list=E2;it.comment=e=>new ny(e);it.atRule=e=>new ty(e);it.decl=e=>new ry(e);it.rule=e=>new ay(e);it.root=e=>new oy(e);it.document=e=>new iy(e);it.CssSyntaxError=C2;it.Declaration=ry;it.Container=x2;it.Processor=Zf;it.Document=iy;it.Comment=ny;it.Warning=P2;it.AtRule=ty;it.Result=T2;it.Input=b2;it.Rule=ay;it.Root=oy;it.Node=k2;_2.registerPostcss(it);var M2=it;it.default=it;const{isPlainObject:$P}=Ff,{parse:zP}=M2,L2="_list_1whuj_1",D2="_compact_1whuj_5",O2="_pending_1whuj_8",Sd={list:L2,compact:D2,pending:O2};function R2(e){const{className:n,data:i,keySelector:o,renderer:s,rendererParams:u,pending:d,errored:f,filtered:p,errorMessage:y,emptyMessage:w,pendingMessage:C,filteredEmptyMessage:m,compact:x,withoutMessage:E=!1,messageClassName:b}=e,N=$e(i)||i.length===0;return g.jsxs("div",{className:Oe(Sd.list,x&&Sd.compact,d&&Sd.pending,n),children:[g.jsx(h0,{data:i,keySelector:o,renderer:s,rendererParams:u}),!E&&g.jsx(u0,{className:b,pending:d,filtered:p,empty:N,errored:f,compact:x,emptyMessage:w,filteredEmptyMessage:m,pendingMessage:C,errorMessage:y,overlayPending:!0})]})}function sy(e,n){if($e(e))return;const i={},o=[];return e.forEach(s=>{const u=n?n(s):JSON.stringify(s);i[u]||(i[u]=!0,o.push(s))}),e.length===o.length?e:o}const I2=[40,38,13,8];function A2(e,n,i){return n.findIndex((o,s)=>i(o,s)===e)}function Mg(e,n,i,o){if(i.length<=0)return;let s=A2(e,i,o);s===-1&&(s=n>0?-1:0);const u=Gx(s+n,i.length);return o(i[u],u)}function F2(e,n,i,o,s,u,d,f,p){return v.useCallback(y=>{const{keyCode:w}=y,C=e?.key;if(o&&(w===9||w===27))u();else if(!o&&I2.includes(w))y.stopPropagation(),y.preventDefault(),d();else if(w===13)if(Lt(C)){y.stopPropagation(),y.preventDefault();const m=i.find((x,E)=>n(x,E)===C);m&&f(C,m)}else y.stopPropagation(),y.preventDefault(),p&&p();else if(w===40){y.stopPropagation(),y.preventDefault();const m=Mg(C,1,i,n);s(m?{key:m}:void 0)}else if(w===38){y.stopPropagation(),y.preventDefault();const m=Mg(C,-1,i,n);s(m?{key:m}:void 0)}},[e,o,n,s,u,f,d,p,i])}const $2="_generic-option_zv1n8_1",z2={genericOption:$2};function B2(e){const{optionContainerClassName:n,contentRenderer:i,contentRendererParam:o,option:s,onClick:u,optionKey:d,focusedKey:f}=e,p=o(d,s),{containerClassName:y,title:w,...C}=p,m=f?.key===d,x=v.useRef(null);v.useEffect(()=>{f&&f.key===d&&!f.mouse&&x.current&&x.current.scrollIntoView({behavior:"smooth",block:"center"})},[d,f]);const E=v.useCallback(()=>{u(d,s)},[d,s,u]);return g.jsx(uf,{elementRef:x,className:Oe(z2.genericOption,n,y),onClick:E,title:w,name:d,focused:m,children:i(C)})}const U2="common",H2={infoMessageAnd:"and",infoMessageMore:"more",buttonTitleSelect:"Select all",buttonTitleClear:"Clear",buttonTitleClose:"Close",buttonTitleOpen:"Open",selectInputPendingMessage:"Fetching options...",selectInputEmptyMessage:"No option available",selectInputFilteredMessage:"No option available for the search",selectInputErrorMessage:"Could not load options"},V2={namespace:U2,strings:H2},q2="_popup_poyjv_1",W2="_list_poyjv_4",G2="_list-item_poyjv_9",Z2="_info-message_poyjv_14",Q2="_icon_poyjv_21",Si={popup:q2,list:W2,listItem:G2,infoMessage:Z2,icon:Q2},K2=[];function ly(e){const{actions:n,actionsContainerClassName:i,className:o,disabled:s,error:u,errorContainerClassName:d,hint:f,hintContainerClassName:p,icons:y,iconsContainerClassName:w,inputSectionClassName:C,label:m,labelClassName:x,name:E,onOptionClick:b,searchText:N,onSearchTextChange:P,optionContainerClassName:L,optionKeySelector:$,optionRenderer:q,optionRendererParams:Z,options:fe,optionsPopupClassName:O,persistentOptionPopup:K,readOnly:ce,placeholder:de,valueDisplay:I="",nonClearable:U,onClearButtonClick:W,onSelectAllButtonClick:ne,optionsPending:he=!1,optionsFiltered:Ce=!1,optionsErrored:_e=!1,focused:G,focusedKey:ue,onFocusedKeyChange:T,onFocusedChange:H,dropdownShown:oe,onDropdownShownChange:Se,totalOptionsCount:se=0,hasValue:re,autoFocus:ee,onEnterWithoutOption:Q,withAsterisk:Y,required:et,variant:tn,errorOnTooltip:Wt,dropdownHidden:ot}=e,bt=fe??K2,st=l0(V2),wt=v.useRef(null),ft=v.useRef(null),ht=v.useRef(null),xt=v.useRef(null),nn=v.useCallback(pt=>{oe||Se(!0),P(pt)},[oe,Se,P]),Tn=v.useCallback((pt,Kt)=>{Kt.stopPropagation(),Se(!oe)},[oe,Se]),ln=v.useCallback(()=>{oe||Se(!0)},[oe,Se]),jn=v.useCallback(()=>{Se(!1)},[Se]),Jr=v.useCallback(()=>{ce||ln()},[ce,ln]),un=v.useCallback((pt,Kt)=>{pt||Kt?K&&ht.current&&ht.current.focus():jn()},[jn,K]),cn=v.useCallback((pt,Kt)=>{b(pt,Kt,E),K||jn()},[b,jn,K,E]),Er=v.useCallback((pt,Kt)=>({contentRendererParam:Z,option:Kt,optionKey:pt,focusedKey:ue,contentRenderer:q,onClick:cn,onFocus:T,optionContainerClassName:Oe(L,Si.listItem)}),[ue,cn,T,L,q,Z]);FE(oe,un,xt,wt);const Kn=F2(ue,$,bt,oe,T,jn,ln,cn,Q),lt=bt.length,Dt=se-lt>0?`${st.infoMessageAnd} ${se-lt} ${st.infoMessageMore}`:void 0,Qt=oe&&!ot;return g.jsxs(g.Fragment,{children:[g.jsx(Pf,{actionsContainerClassName:i,className:o,containerRef:wt,disabled:s,errorContainerClassName:d,error:u,errorOnTooltip:Wt,hintContainerClassName:p,hint:f,iconsContainerClassName:w,icons:y,inputSectionClassName:C,inputSectionRef:ft,labelClassName:x,label:m,readOnly:ce,required:et,variant:tn,withAsterisk:Y,actions:g.jsxs(g.Fragment,{children:[n,!ce&&ne&&g.jsx(Ue,{onClick:ne,disabled:s,variant:"tertiary",name:void 0,title:st.buttonTitleSelect,children:g.jsx(EC,{className:Si.icon})}),!ce&&!U&&re&&g.jsx(Ue,{onClick:W,disabled:s,variant:"tertiary",name:void 0,title:st.buttonTitleClear,children:g.jsx(LC,{className:Si.icon})}),!ce&&g.jsx(Ue,{onClick:Tn,variant:"tertiary",name:void 0,title:Qt?st.buttonTitleClose:st.buttonTitleOpen,children:Qt?g.jsx(_C,{className:Si.icon}):g.jsx(SC,{className:Si.icon})})]}),input:g.jsx(X0,{name:E,elementRef:ht,readOnly:ce,disabled:s,value:oe||G?N:I,onChange:nn,onClick:Jr,onFocus:()=>H(!0),onBlur:()=>H(!1),placeholder:ps(I)?I:de,autoComplete:"off",onKeyDown:Kn,autoFocus:ee})}),Qt&&g.jsxs(c0,{elementRef:xt,parentRef:ft,className:Oe(O,Si.popup),children:[g.jsx(R2,{className:Si.list,data:bt,keySelector:$,renderer:B2,rendererParams:Er,errored:_e,filtered:Ce,pending:he,pendingMessage:st.selectInputPendingMessage,emptyMessage:st.selectInputEmptyMessage,filteredEmptyMessage:st.selectInputFilteredMessage,errorMessage:st.selectInputErrorMessage,compact:!0}),!he&&!_e&&!!Dt&&g.jsx("div",{className:Si.infoMessage,children:Dt})]})]})}function Y2(e){const{children:n,isActive:i,iconClassName:o,labelClassName:s}=e;return g.jsxs(g.Fragment,{children:[g.jsx("div",{className:o,children:i?g.jsx(jC,{}):g.jsx(TC,{})}),g.jsx("div",{className:s,children:n})]})}const X2="_option_1kpl9_1",J2="_active_1kpl9_7",eT="_icon_1kpl9_11",tT="_label_1kpl9_17",Wa={option:X2,active:J2,icon:eT,label:tT},bd=[];function nT(e){const{keySelector:n,labelSelector:i,name:o,onChange:s,onOptionsChange:u,options:d,optionsPending:f,optionsErrored:p,value:y,sortFunction:w,searchOptions:C,onSearchValueChange:m,onShowDropdownChange:x,hideOptionFilter:E,selectedOnTop:b,...N}=e,P=d??bd,L=C??bd,$=y??bd,[q,Z]=v.useState(),[fe,O]=v.useState(!1),[K,ce]=v.useState(!1),[de,I]=v.useState(),[U,W]=v.useState({}),ne=v.useMemo(()=>Ka(P,n,se=>se),[P,n]),he=v.useMemo(()=>Ka(P,n,i),[P,n,i]),Ce=v.useMemo(()=>$.map(se=>he[se]??"?").join(", "),[$,he]),_e=v.useMemo(()=>$.map(se=>ne[se]).filter(Lt),[$,ne]),G=v.useMemo(()=>{const se=sy([...L,..._e],n);if(!b)return w?w(se,q,i):se;const re=se.filter(Q=>U[n(Q)]),ee=se.filter(Q=>!U[n(Q)]&&($e(E)||E(Q)));return w?[...lo(re,q,i),...w(ee,q,i)]:[...lo(re,q,i),...ee]},[b,n,i,q,L,U,_e,w,E]),ue=v.useCallback(se=>{Z(se),m&&m(se)},[m]),T=v.useCallback(se=>{O(se),x&&x(se),se?(W(Ka($,re=>re,()=>!0)),I(void 0)):(W({}),I(void 0),Z(void 0),m&&m(void 0))},[$,m,x]),H=v.useCallback((se,re)=>{const ee=$.findIndex(Q=>Q===se)!==-1;return{children:i(re),containerClassName:Oe(Wa.option,ee&&Wa.active),title:i(re),isActive:ee,labelClassName:Wa.label,iconClassName:Wa.icon}},[i,$]),oe=v.useCallback((se,re)=>{const ee=[...$],Q=$.findIndex(Y=>Y===se);Q!==-1?ee.splice(Q,1):(ee.push(se),u&&u(Y=>{const et=Y??[];return et.find(tn=>n(tn)===se)?Y:[...et,re]})),s(ee,o)},[$,s,o,u,n]),Se=v.useCallback(()=>{s([],o)},[o,s]);return g.jsx(ly,{...N,name:o,options:G,optionsPending:f,optionsFiltered:ps(q)&&q.length>0,optionsErrored:p,optionKeySelector:n,optionRenderer:Y2,optionRendererParams:H,optionContainerClassName:Wa.optionContainer,onOptionClick:oe,valueDisplay:Ce,onClearButtonClick:Se,searchText:q,onSearchTextChange:ue,dropdownShown:fe,onDropdownShownChange:T,focused:K,onFocusedChange:ce,focusedKey:de,onFocusedKeyChange:I,persistentOptionPopup:!0,nonClearable:!1,hasValue:Lt($)&&$.length>0})}function Lg(e){const{name:n,options:i,keySelector:o,onChange:s,withSelectAll:u,...d}=e,f=v.useCallback(()=>{if($e(i))return;const p=i.map(o);s(p,n)},[i,n,s,o]);return g.jsx(nT,{...d,name:n,onChange:s,options:i,keySelector:o,sortFunction:lo,searchOptions:i,onSelectAllButtonClick:u?f:void 0,selectedOnTop:!1})}const rT="_page-container_1cfro_1",iT="_content_1cfro_2",Dg={pageContainer:rT,content:iT};function Qf(e){const{className:n,contentClassName:i,children:o,contentAs:s="div",containerAs:u="div"}=e,d=s;return g.jsx(u,{className:Oe(Dg.pageContainer,n),children:g.jsx(d,{className:Oe(Dg.content,i),children:o})})}const oT="_raw-input_145mq_1",aT={rawInput:oT};function sT(e){const{className:n,onChange:i,elementRef:o,value:s,name:u,...d}=e,f=fr.useCallback(p=>{var y;const w=(y=p?.target)==null?void 0:y.value;i&&i(w===""?void 0:w,u,p)},[u,i]);return g.jsx("textarea",{...d,ref:o,className:Oe(aT.rawInput,n),name:Lt(u)?String(u):void 0,onChange:f,value:s??""})}const lT="_option_11p37_1",uT="_icon_11p37_6",cT="_label_11p37_14",dT="_overflow-container_11p37_20",fT="_description_11p37_25",Vo={option:lT,icon:uT,label:cT,overflowContainer:dT,description:fT};function hT(e){const{className:n,label:i,description:o,iconClassName:s,labelClassName:u}=e;return g.jsxs("div",{className:Oe(Vo.option,n),children:[g.jsx("div",{className:Oe(Vo.icon,s),children:g.jsx(kC,{})}),g.jsxs("div",{className:Oe(Vo.label,u),children:[g.jsx("div",{className:Vo.overflowContainer,children:i}),g.jsx("div",{className:Oe(Vo.overflowContainer,Vo.description),children:o})]})]})}const pT="_option-container_2k92q_1",mT="_option_2k92q_1",gT="_active_2k92q_9",vT="_icon_2k92q_12",Ga={optionContainer:pT,option:mT,active:gT,icon:vT},Og=[];function Rg(e){const{keySelector:n,labelSelector:i,descriptionSelector:o,name:s,onChange:u,onOptionsChange:d,options:f,optionsPending:p,optionsErrored:y,value:w,sortFunction:C,searchOptions:m,onSearchValueChange:x,onShowDropdownChange:E,hideOptionFilter:b,selectedOnTop:N,onEnterWithoutOption:P,...L}=e,$=f??Og,q=m??Og,[Z,fe]=v.useState(),[O,K]=v.useState(!1),[ce,de]=v.useState(!1),[I,U]=v.useState(),[W,ne]=v.useState({}),he=v.useMemo(()=>Ka($,n,i),[$,n,i]),Ce=Lt(w)?he[w]??"?":"",_e=v.useMemo(()=>{const re=$?.find(ee=>n(ee)===w);return $e(re)?[]:[re]},[w,$,n]),G=v.useMemo(()=>{const re=sy([...q,..._e],n);if(!N)return C?C(re,Z,i):re;const ee=re.filter(Y=>W[n(Y)]),Q=re.filter(Y=>!W[n(Y)]&&($e(b)||b(Y)));return C?[...lo(ee,Z,i),...C(Q,Z,i)]:[...lo(ee,Z,i),...Q]},[N,n,i,Z,q,W,_e,C,b]),ue=v.useCallback(re=>{fe(re),x&&x(re)},[x]),T=v.useCallback(()=>{K(!1),E&&E(!1),fe(void 0),x&&x(void 0),P&&P(Z)},[Z,E,P,x]),H=v.useCallback(re=>{K(re),E&&E(re),re?(ne(Ka(w?[w]:[],ee=>ee,()=>!0)),U(w?{key:w}:void 0)):(ne({}),U(void 0),fe(void 0),x&&x(void 0))},[w,x,E]),oe=v.useCallback((re,ee)=>{const Q=re===w;return{label:i(ee),description:o?o(ee):void 0,containerClassName:Oe(Ga.optionContainer,Q&&Ga.active),title:i(ee),className:Ga.option,iconClassName:Ga.icon}},[w,i,o]),Se=v.useCallback((re,ee)=>{d&&d(Q=>{const Y=Q??[];return Y.find(et=>n(et)===re)?Q:[...Y,ee]}),u(re,s,ee)},[u,s,d,n]),se=v.useCallback(()=>{if(!e.nonClearable){const re=e.onChange;re(void 0,s,void 0)}},[s,e.onChange,e.nonClearable]);return g.jsx(ly,{...L,name:s,options:G,optionsPending:p,optionsErrored:y,optionsFiltered:ps(Z)&&Z.length>0,optionKeySelector:n,optionRenderer:hT,optionRendererParams:oe,optionContainerClassName:Ga.optionContainer,onOptionClick:Se,valueDisplay:Ce,onClearButtonClick:se,searchText:Z,onSearchTextChange:ue,dropdownShown:O,onDropdownShownChange:H,focused:ce,onFocusedChange:de,focusedKey:I,onFocusedKeyChange:U,hasValue:Lt(w),persistentOptionPopup:!1,onEnterWithoutOption:T})}const yT="_segment-input_bykt7_1",wT="_segment-list_bykt7_4",xT="_segment_bykt7_1",CT="_active_bykt7_18",ST="_secondary-variant_bykt7_24",Xa={segmentInput:yT,segmentList:wT,segment:xT,active:CT,secondaryVariant:ST};function bT(e){const{label:n,name:i,onClick:o,value:s,className:u,variant:d="primary",inputName:f,...p}=e;return g.jsx(Ue,{...p,className:Oe(Xa.segment,s&&Xa.active,d==="secondary"&&Xa.secondaryVariant,u),name:i,onClick:o,variant:"tertiary",children:n})}function _T(e){const{rendererParams:n,listContainerClassName:i,keySelector:o,labelSelector:s,className:u,...d}=e;return g.jsx(wb,{className:Oe(u,Xa.segmentInput),...d,renderer:bT,rendererParams:n,listContainerClassName:Oe(i,Xa.segmentList),keySelector:o,labelSelector:s})}function eo(e){const{name:n,options:i,nonClearable:o,onChange:s,...u}=e;return e.nonClearable?g.jsx(Rg,{...u,onChange:e.onChange,nonClearable:e.nonClearable,name:n,options:i,sortFunction:lo,searchOptions:i,selectedOnTop:!1}):g.jsx(Rg,{...u,onChange:e.onChange,nonClearable:e.nonClearable,name:n,options:i,sortFunction:lo,searchOptions:i,selectedOnTop:!1})}v.createContext({tabs:[],step:0,disabled:!1,activeTab:"",variant:"primary",setActiveTab:()=>{console.warn("setActiveTab called before it was initialized")},registerTab:()=>{console.warn("registerTab called before it was initialized")},unregisterTab:()=>{console.warn("unregisterTab called before it was initialized")}});const Ig="•",ET="Enter";function kT(e){const{actions:n,className:i,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputClassName:p,label:y,labelClassName:w,readOnly:C,required:m,variant:x,inputSectionClassName:E,withAsterisk:b,onChange:N,name:P,autoBullets:L=!1,rows:$=5,...q}=e,Z=fr.useCallback(O=>{$e(N)||O.target.value===""&&N(`${Ig} `,P)},[N,P]),fe=fr.useCallback(O=>{$e(N)||O.key===ET&&N(`${O.currentTarget.value}${Ig} `,P)},[N,P]);return g.jsx(Pf,{actions:n,className:i,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputSectionClassName:E,labelClassName:w,label:y,readOnly:C,required:m,variant:x,withAsterisk:b,input:g.jsx(sT,{...q,readOnly:C,disabled:o,className:p,onChange:N,name:P,onFocus:L?Z:void 0,onKeyUp:L?fe:void 0,rows:$})})}function jt(e){const{actions:n,className:i,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputClassName:p,inputSectionClassName:y,label:w,readOnly:C,required:m,variant:x,withAsterisk:E,type:b="text",...N}=e;return g.jsx(Pf,{className:i,actions:n,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputSectionClassName:y,label:w,required:m,readOnly:C,variant:x,withAsterisk:E,input:g.jsx(X0,{...N,required:m,readOnly:C,disabled:o,className:p,type:b})})}const NT="_dropdownContainer_1six7_3",TT="_dropdownMenu_1six7_15",jT="_dropdownContent_1six7_43",_d={dropdownContainer:NT,dropdownMenu:TT,dropdownContent:jT},PT=[{to:"/upload",label:"Upload",Icon:s0},{to:"/explore",label:"Explore",Icon:AC},{to:"/analytics",label:"Analytics",Icon:a0}];function MT(){const e=ra(),n=hs(),[i,o]=v.useState(!1),s=v.useRef(null);return v.useEffect(()=>{const u=d=>{s.current&&!s.current.contains(d.target)&&o(!1)};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[]),g.jsx("nav",{className:"border-b border-gray-200 bg-white shadow-sm sticky top-0 z-50 backdrop-blur-sm bg-white/95",children:g.jsxs(Qf,{className:"border-b-2 border-ifrcRed",contentClassName:"grid grid-cols-3 items-center py-6",children:[g.jsxs("div",{className:"flex items-center gap-4 min-w-0 cursor-pointer group transition-all duration-200 hover:scale-105",onClick:()=>{if(!(e.pathname==="/upload"||e.pathname==="/")){if(e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n("/")}},children:[g.jsx("div",{className:"p-2 rounded-lg bg-gradient-to-br from-ifrcRed/10 to-ifrcRed/20 group-hover:from-ifrcRed/20 group-hover:to-ifrcRed/30 transition-all duration-200",children:g.jsx(DC,{className:"h-8 w-8 flex-shrink-0 text-ifrcRed"})}),g.jsx("div",{className:"flex flex-col",children:g.jsx("span",{className:"font-bold text-xl text-gray-900 leading-tight",children:"PromptAid Vision"})})]}),g.jsx("div",{className:"flex justify-center",children:g.jsx("nav",{className:"flex items-center space-x-4 bg-gray-50/80 rounded-xl p-2 backdrop-blur-sm",children:PT.map(({to:u,label:d,Icon:f})=>{const p=e.pathname===u||u==="/upload"&&e.pathname==="/"||u==="/explore"&&e.pathname.startsWith("/map/"),y=e.pathname==="/upload"||e.pathname==="/",w=u==="/upload"||u==="/";return g.jsxs("div",{className:"relative",children:[g.jsx(dr,{withInternalPadding:!0,className:"p-2",children:g.jsxs(Ue,{name:d.toLowerCase(),variant:p?"primary":"tertiary",size:1,className:`transition-all duration-200 ${p?"shadow-lg shadow-ifrcRed/20 transform scale-105":"hover:bg-white hover:shadow-md hover:scale-105"}`,onClick:()=>{if(!(y&&w)){if(e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded(u);return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n(u)}},children:[g.jsx(f,{className:`w-4 h-4 transition-transform duration-200 ${p?"scale-110":"group-hover:scale-110"}`}),g.jsx("span",{className:"inline ml-2 font-semibold",children:d})]})}),p&&g.jsx("div",{className:"absolute -bottom-2 left-1/2 transform -translate-x-1/2 w-8 h-1 bg-ifrcRed rounded-full animate-pulse"})]},u)})})}),g.jsx("div",{className:"flex justify-end",children:g.jsxs("div",{className:_d.dropdownContainer,ref:s,children:[g.jsx(dr,{withInternalPadding:!0,className:"p-2",children:g.jsx(Ue,{name:"more-options",variant:i?"primary":"tertiary",size:1,className:"transition-all duration-200",onClick:()=>o(!i),children:g.jsx(OC,{className:"w-4 h-4"})})}),i&&g.jsx("div",{className:_d.dropdownMenu,children:g.jsxs("div",{className:_d.dropdownContent,children:[g.jsx(dr,{withInternalPadding:!0,className:"p-2",children:g.jsxs(Ue,{name:"help-support",variant:"tertiary",size:1,className:"w-full justify-start",onClick:()=>{if(o(!1),e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/help");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n("/help")},children:[g.jsx(RC,{className:"w-4 h-4"}),g.jsx("span",{className:"ml-2 font-semibold",children:"Help & Support"})]})}),g.jsx(dr,{withInternalPadding:!0,className:"p-2",children:g.jsxs(Ue,{name:"dev",variant:"tertiary",size:1,className:"w-full justify-start",onClick:()=>{if(o(!1),e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/admin");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n("/admin")},children:[g.jsx(FC,{className:"w-4 h-4"}),g.jsx("span",{className:"ml-2 font-semibold",children:"Dev"})]})})]})})]})})]})})}function LT(){return g.jsxs(g.Fragment,{children:[g.jsx(MT,{}),g.jsx(lx,{})]})}const DT="_uploadContainer_1i3bv_1",OT="_dropZone_1i3bv_9",RT="_hasFile_1i3bv_30",IT="_dropZoneIcon_1i3bv_37",AT="_dropZoneText_1i3bv_43",FT="_dropZoneSubtext_1i3bv_49",$T="_filePreview_1i3bv_55",zT="_filePreviewImage_1i3bv_64",BT="_fileName_1i3bv_110",UT="_fileInfo_1i3bv_118",HT="_helpLink_1i3bv_125",VT="_loadingContainer_1i3bv_145",qT="_loadingText_1i3bv_153",WT="_generateButtonContainer_1i3bv_157",GT="_uploadedMapContainer_1i3bv_165",ZT="_uploadedMapImage_1i3bv_169",QT="_formGrid_1i3bv_209",KT="_titleField_1i3bv_222",YT="_ratingDescription_1i3bv_230",XT="_ratingSlider_1i3bv_235",JT="_ratingLabel_1i3bv_242",ej="_ratingInput_1i3bv_251",tj="_ratingValue_1i3bv_256",nj="_submitSection_1i3bv_266",rj="_successContainer_1i3bv_275",ij="_successHeading_1i3bv_280",oj="_successText_1i3bv_285",aj="_successButton_1i3bv_291",sj="_viewFullSizeButton_1i3bv_297",lj="_fullSizeModalOverlay_1i3bv_306",uj="_lightModalOverlay_1i3bv_320",cj="_fullSizeModalContent_1i3bv_334",dj="_fullSizeModalHeader_1i3bv_345",fj="_fullSizeModalImage_1i3bv_361",hj="_confirmSection_1i3bv_398",pj="_step2Layout_1i3bv_407",mj="_topRow_1i3bv_413",gj="_ratingHidden_1i3bv_421",vj="_imageSection_1i3bv_425",yj="_ratingContent_1i3bv_435",wj="_mapColumn_1i3bv_453",xj="_contentColumn_1i3bv_458",Cj="_step2bLayout_1i3bv_465",Sj="_metadataSectionCard_1i3bv_562",bj="_droneMetadataSection_1i3bv_571",_j="_droneMetadataHeading_1i3bv_577",Ej="_droneMetadataGrid_1i3bv_585",kj="_rtkFixContainer_1i3bv_591",Nj="_rtkFixLabel_1i3bv_597",Tj="_rtkFixCheckbox_1i3bv_606",jj="_confirmButtonContainer_1i3bv_621",Pj="_ratingWarningContent_1i3bv_629",Mj="_ratingWarningTitle_1i3bv_637",Lj="_ratingWarningText_1i3bv_644",Dj="_ratingWarningButtons_1i3bv_651",Oj="_fallbackReasonBox_1i3bv_659",Rj="_fallbackReasonTitle_1i3bv_668",Ij="_fallbackReasonText_1i3bv_675",Aj="_preprocessingProgress_1i3bv_682",Fj="_carouselContainer_1i3bv_735",$j="_carouselImageWrapper_1i3bv_740",zj="_carouselImage_1i3bv_740",Bj="_carouselNavigation_1i3bv_763",Uj="_carouselButton_1i3bv_775",Hj="_carouselIndicators_1i3bv_799",Vj="_carouselIndicator_1i3bv_799",qj="_carouselIndicatorActive_1i3bv_828",Wj="_viewImageButtonContainer_1i3bv_864",V={uploadContainer:DT,dropZone:OT,hasFile:RT,dropZoneIcon:IT,dropZoneText:AT,dropZoneSubtext:FT,filePreview:$T,filePreviewImage:zT,fileName:BT,fileInfo:UT,helpLink:HT,loadingContainer:VT,loadingText:qT,generateButtonContainer:WT,uploadedMapContainer:GT,uploadedMapImage:ZT,formGrid:QT,titleField:KT,ratingDescription:YT,ratingSlider:XT,ratingLabel:JT,ratingInput:ej,ratingValue:tj,submitSection:nj,successContainer:rj,successHeading:ij,successText:oj,successButton:aj,viewFullSizeButton:sj,fullSizeModalOverlay:lj,lightModalOverlay:uj,fullSizeModalContent:cj,fullSizeModalHeader:dj,fullSizeModalImage:fj,confirmSection:hj,step2Layout:pj,topRow:mj,ratingHidden:gj,imageSection:vj,ratingContent:yj,mapColumn:wj,contentColumn:xj,step2bLayout:Cj,metadataSectionCard:Sj,droneMetadataSection:bj,droneMetadataHeading:_j,droneMetadataGrid:Ej,rtkFixContainer:kj,rtkFixLabel:Nj,rtkFixCheckbox:Tj,confirmButtonContainer:jj,ratingWarningContent:Pj,ratingWarningTitle:Mj,ratingWarningText:Lj,ratingWarningButtons:Dj,fallbackReasonBox:Oj,fallbackReasonTitle:Rj,fallbackReasonText:Ij,preprocessingProgress:Aj,carouselContainer:Fj,carouselImageWrapper:$j,carouselImage:zj,carouselNavigation:Bj,carouselButton:Uj,carouselIndicators:Hj,carouselIndicator:Vj,carouselIndicatorActive:qj,viewImageButtonContainer:Wj},uy=v.createContext(void 0),Gj=({children:e})=>{const[n,i]=v.useState(""),[o,s]=v.useState(""),[u,d]=v.useState(""),[f,p]=v.useState(""),[y,w]=v.useState(""),[C,m]=v.useState(""),[x,E]=v.useState(""),[b,N]=v.useState(!1),L={search:n,srcFilter:o,catFilter:u,regionFilter:f,countryFilter:y,imageTypeFilter:C,uploadTypeFilter:x,showReferenceExamples:b,setSearch:i,setSrcFilter:s,setCatFilter:d,setRegionFilter:p,setCountryFilter:w,setImageTypeFilter:m,setUploadTypeFilter:E,setShowReferenceExamples:N,clearAllFilters:()=>{i(""),s(""),d(""),p(""),w(""),m(""),E(""),N(!1)}};return g.jsx(uy.Provider,{value:L,children:e})},Zj=()=>{const e=v.useContext(uy);if(e===void 0)throw new Error("useFilterContext must be used within a FilterProvider");return e};function Ag({files:e,file:n,preview:i,imageType:o,onFileChange:s,onRemoveImage:u,onAddImage:d,onImageTypeChange:f,onChangeFile:p}){const y=w=>{w.preventDefault();const C=w.dataTransfer.files?.[0];C&&s(C)};return g.jsxs("div",{className:"space-y-6",children:[g.jsx("p",{className:"text-gray-700 leading-relaxed max-w-2xl mx-auto",children:"This app evaluates how well multimodal AI models analyze and describe crisis maps and drone imagery. Upload an image and the AI will generate a description. Then you can review and rate the result based on your expertise."}),g.jsx("div",{className:V.helpLink,children:g.jsxs(Mx,{to:"/help",className:V.helpLink,children:["More ",g.jsx(bC,{className:"w-3 h-3"})]})}),g.jsx("div",{className:"flex justify-center",children:g.jsx(dr,{withInternalPadding:!0,className:"bg-transparent border-none shadow-none",children:g.jsx(_T,{name:"image-type",value:o,onChange:w=>f(w),options:[{key:"crisis_map",label:"Crisis Maps"},{key:"drone_image",label:"Drone Imagery"}],keySelector:w=>w.key,labelSelector:w=>w.label})})}),g.jsxs("div",{className:`${V.dropZone} ${n?V.hasFile:""}`,onDragOver:w=>w.preventDefault(),onDrop:y,children:[e.length>1?g.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4 mb-4",children:e.map((w,C)=>g.jsxs("div",{className:"relative",children:[g.jsx("img",{src:URL.createObjectURL(w),alt:`Image ${C+1}`,className:"w-full h-32 object-cover rounded"}),g.jsx(hf,{name:"remove-image",variant:"tertiary",onClick:()=>u(C),title:"Remove image",ariaLabel:"Remove image",className:"absolute top-2 right-2 bg-white/90 hover:bg-white shadow-md hover:shadow-lg border border-gray-200 hover:border-red-300 transition-all duration-200 backdrop-blur-sm",children:g.jsx(df,{className:"w-4 h-4"})}),g.jsx("div",{className:"text-xs text-center mt-1",children:w.name})]},C))}):n&&i?g.jsxs("div",{className:V.filePreview,children:[g.jsx("div",{className:V.filePreviewImage,children:g.jsx("img",{src:i,alt:"File preview"})}),g.jsx("p",{className:V.fileName,children:n.name}),g.jsxs("p",{className:V.fileInfo,children:[(n.size/1024/1024).toFixed(2)," MB"]})]}):g.jsxs(g.Fragment,{children:[g.jsx(s0,{className:V.dropZoneIcon}),g.jsx("p",{className:V.dropZoneText,children:"Drag & Drop any file here"}),g.jsx("p",{className:V.dropZoneSubtext,children:"or"})]}),g.jsxs("div",{className:"flex gap-2",children:[g.jsxs("label",{className:"inline-block cursor-pointer",children:[g.jsx("input",{type:"file",className:"sr-only",accept:".jpg,.jpeg,.png,.tiff,.tif,.heic,.heif,.webp,.gif,.pdf",onChange:w=>{n&&p?p(w.target.files?.[0]):s(w.target.files?.[0])}}),g.jsx(Ue,{name:"upload",variant:"secondary",size:1,onClick:()=>document.querySelector('input[type="file"]')?.click(),children:n?"Change Image":"Browse Files"})]}),n&&e.length<5&&g.jsx(Ue,{name:"add-image",variant:"secondary",size:1,onClick:d,children:"Add Image"})]})]})]})}function Fg({files:e,imageUrl:n,preview:i,onViewFullSize:o,currentImageIndex:s=0,onGoToPrevious:u,onGoToNext:d,onGoToImage:f,showCarousel:p=!1}){return p&&e.length>1?g.jsx(dr,{heading:"Uploaded Images",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:g.jsxs("div",{className:V.carouselContainer,children:[g.jsx("div",{className:V.carouselImageWrapper,children:e[s]?g.jsx("img",{src:URL.createObjectURL(e[s]),alt:`Image ${s+1}`,className:V.carouselImage}):g.jsx("div",{className:V.imagePlaceholder,children:"No image available"})}),g.jsxs("div",{className:V.carouselNavigation,children:[g.jsx(Ue,{name:"previous-image",variant:"tertiary",size:1,onClick:u,className:V.carouselButton,children:g.jsx(PC,{className:"w-4 h-4"})}),g.jsx("div",{className:V.carouselIndicators,children:e.map((y,w)=>g.jsx("button",{onClick:()=>f?.(w),className:`${V.carouselIndicator} ${w===s?V.carouselIndicatorActive:""}`,children:w+1},w))}),g.jsx(Ue,{name:"next-image",variant:"tertiary",size:1,onClick:d,className:V.carouselButton,children:g.jsx(MC,{className:"w-4 h-4"})})]}),g.jsx("div",{className:V.viewImageButtonContainer,children:g.jsx(Ue,{name:"view-full-size-carousel",variant:"secondary",size:1,onClick:()=>o({file:e[s],index:s}),disabled:!e[s],children:"View Image"})})]})}):e.length>1?g.jsx("div",{className:"space-y-6",children:e.map((y,w)=>g.jsx(dr,{heading:`Image ${w+1}: ${y.name}`,headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:g.jsxs("div",{className:V.uploadedMapContainer,children:[g.jsx("div",{className:V.uploadedMapImage,children:g.jsx("img",{src:URL.createObjectURL(y),alt:`Image ${w+1}`})}),g.jsx("div",{className:V.viewFullSizeButton,children:g.jsx(Ue,{name:`view-full-size-${w}`,variant:"secondary",size:1,onClick:()=>o({file:y,index:w}),children:"View Image"})})]})},w))}):g.jsx(dr,{heading:"Uploaded Image",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:g.jsxs("div",{className:V.uploadedMapContainer,children:[g.jsx("div",{className:V.uploadedMapImage,children:g.jsx("img",{src:n||i||void 0,alt:"Uploaded image preview"})}),g.jsx("div",{className:V.viewFullSizeButton,children:g.jsx(Ue,{name:"view-full-size",variant:"secondary",size:1,onClick:()=>o(),children:"View Image"})})]})})}function Qj({files:e,imageType:n,title:i,source:o,eventType:s,epsg:u,countries:d,centerLon:f,centerLat:p,amslM:y,aglM:w,headingDeg:C,yawDeg:m,pitchDeg:x,rollDeg:E,rtkFix:b,stdHM:N,stdVM:P,metadataArray:L,sources:$,types:q,spatialReferences:Z,imageTypes:fe,countriesOptions:O,onTitleChange:K,onSourceChange:ce,onEventTypeChange:de,onEpsgChange:I,onCountriesChange:U,onCenterLonChange:W,onCenterLatChange:ne,onAmslMChange:he,onAglMChange:Ce,onHeadingDegChange:_e,onYawDegChange:G,onPitchDegChange:ue,onRollDegChange:T,onRtkFixChange:H,onStdHMChange:oe,onStdVMChange:Se,onImageTypeChange:se,updateMetadataForImage:re}){return e.length>1?g.jsxs("div",{children:[g.jsx("div",{className:"mb-4",children:g.jsx(jt,{label:"Shared Title",name:"title",value:i,onChange:K,placeholder:"Enter a title for all images...",required:!0})}),e.map((ee,Q)=>g.jsx("div",{className:"mb-6",children:g.jsx(dr,{heading:`Image ${Q+1}: ${ee.name}`,headingLevel:4,withHeaderBorder:!0,withInternalPadding:!0,children:g.jsxs("div",{className:V.formGrid,children:[n!=="drone_image"&&g.jsx(eo,{label:"Source",name:`source_${Q}`,value:L[Q]?.source||"",onChange:Y=>re(Q,"source",Y),options:$,keySelector:Y=>Y.s_code,labelSelector:Y=>Y.label,required:!0}),g.jsx(eo,{label:"Event Type",name:`event_type_${Q}`,value:L[Q]?.eventType||"",onChange:Y=>re(Q,"eventType",Y),options:q,keySelector:Y=>Y.t_code,labelSelector:Y=>Y.label,required:n!=="drone_image"}),g.jsx(eo,{label:"EPSG",name:`epsg_${Q}`,value:L[Q]?.epsg||"",onChange:Y=>re(Q,"epsg",Y),options:Z,keySelector:Y=>Y.epsg,labelSelector:Y=>`${Y.srid} (EPSG:${Y.epsg})`,placeholder:"EPSG",required:n!=="drone_image"}),g.jsx(Lg,{label:"Countries (optional)",name:`countries_${Q}`,value:L[Q]?.countries||[],onChange:Y=>re(Q,"countries",Y),options:O,keySelector:Y=>Y.c_code,labelSelector:Y=>Y.label,placeholder:"Select one or more"}),n==="drone_image"&&g.jsx(g.Fragment,{children:g.jsxs("div",{className:V.droneMetadataSection,children:[g.jsx("h4",{className:V.droneMetadataHeading,children:"Drone Flight Data"}),g.jsxs("div",{className:V.droneMetadataGrid,children:[g.jsx(jt,{label:"Center Longitude",name:`center_lon_${Q}`,value:L[Q]?.centerLon||"",onChange:Y=>re(Q,"centerLon",Y),placeholder:"e.g., -122.4194",step:"any"}),g.jsx(jt,{label:"Center Latitude",name:`center_lat_${Q}`,value:L[Q]?.centerLat||"",onChange:Y=>re(Q,"centerLat",Y),placeholder:"e.g., 37.7749",step:"any"}),g.jsx(jt,{label:"Altitude AMSL (m)",name:`amsl_m_${Q}`,value:L[Q]?.amslM||"",onChange:Y=>re(Q,"amslM",Y),placeholder:"e.g., 100.5",step:"any"}),g.jsx(jt,{label:"Altitude AGL (m)",name:`agl_m_${Q}`,value:L[Q]?.aglM||"",onChange:Y=>re(Q,"aglM",Y),placeholder:"e.g., 50.2",step:"any"}),g.jsx(jt,{label:"Heading (degrees)",name:`heading_deg_${Q}`,value:L[Q]?.headingDeg||"",onChange:Y=>re(Q,"headingDeg",Y),placeholder:"e.g., 180.0",step:"any"}),g.jsx(jt,{label:"Yaw (degrees)",name:`yaw_deg_${Q}`,value:L[Q]?.yawDeg||"",onChange:Y=>re(Q,"yawDeg",Y),placeholder:"e.g., 90.0",step:"any"}),g.jsx(jt,{label:"Pitch (degrees)",name:`pitch_deg_${Q}`,value:L[Q]?.pitchDeg||"",onChange:Y=>re(Q,"pitchDeg",Y),placeholder:"e.g., 0.0",step:"any"}),g.jsx(jt,{label:"Roll (degrees)",name:`roll_deg_${Q}`,value:L[Q]?.rollDeg||"",onChange:Y=>re(Q,"rollDeg",Y),placeholder:"e.g., 0.0",step:"any"}),g.jsx("div",{className:V.rtkFixContainer,children:g.jsxs("label",{className:V.rtkFixLabel,children:[g.jsx("input",{type:"checkbox",checked:L[Q]?.rtkFix||!1,onChange:Y=>re(Q,"rtkFix",Y.target.checked),className:V.rtkFixCheckbox}),"RTK Fix Available"]})}),g.jsx(jt,{label:"Horizontal Std Dev (m)",name:`std_h_m_${Q}`,value:L[Q]?.stdHM||"",onChange:Y=>re(Q,"stdHM",Y),placeholder:"e.g., 0.1",step:"any"}),g.jsx(jt,{label:"Vertical Std Dev (m)",name:`std_v_m_${Q}`,value:L[Q]?.stdVM||"",onChange:Y=>re(Q,"stdVM",Y),placeholder:"e.g., 0.2",step:"any"})]})]})})]})})},Q))]}):g.jsxs("div",{className:V.formGrid,children:[g.jsx("div",{className:V.titleField,children:g.jsx(jt,{label:"Title",name:"title",value:i,onChange:K,placeholder:"Enter a title for this map...",required:!0})}),n!=="drone_image"&&g.jsx(eo,{label:"Source",name:"source",value:o,onChange:ce,options:$,keySelector:ee=>ee.s_code,labelSelector:ee=>ee.label,required:!0}),g.jsx(eo,{label:"Event Type",name:"event_type",value:s,onChange:de,options:q,keySelector:ee=>ee.t_code,labelSelector:ee=>ee.label,required:n!=="drone_image"}),g.jsx(eo,{label:"EPSG",name:"epsg",value:u,onChange:I,options:Z,keySelector:ee=>ee.epsg,labelSelector:ee=>`${ee.srid} (EPSG:${ee.epsg})`,placeholder:"EPSG",required:n!=="drone_image"}),g.jsx(eo,{label:"Image Type",name:"image_type",value:n,onChange:se,options:fe,keySelector:ee=>ee.image_type,labelSelector:ee=>ee.label,required:!0}),g.jsx(Lg,{label:"Countries (optional)",name:"countries",value:d,onChange:U,options:O,keySelector:ee=>ee.c_code,labelSelector:ee=>ee.label,placeholder:"Select one or more"}),n==="drone_image"&&g.jsx(g.Fragment,{children:g.jsxs("div",{className:V.droneMetadataSection,children:[g.jsx("h4",{className:V.droneMetadataHeading,children:"Drone Flight Data"}),g.jsxs("div",{className:V.droneMetadataGrid,children:[g.jsx(jt,{label:"Center Longitude",name:"center_lon",value:f,onChange:W,placeholder:"e.g., -122.4194",step:"any"}),g.jsx(jt,{label:"Center Latitude",name:"center_lat",value:p,onChange:ne,placeholder:"e.g., 37.7749",step:"any"}),g.jsx(jt,{label:"Altitude AMSL (m)",name:"amsl_m",value:y,onChange:he,placeholder:"e.g., 100.5",step:"any"}),g.jsx(jt,{label:"Altitude AGL (m)",name:"agl_m",value:w,onChange:Ce,placeholder:"e.g., 50.2",step:"any"}),g.jsx(jt,{label:"Heading (degrees)",name:"heading_deg",value:C,onChange:_e,placeholder:"e.g., 180.0",step:"any"}),g.jsx(jt,{label:"Yaw (degrees)",name:"yaw_deg",value:m,onChange:G,placeholder:"e.g., 90.0",step:"any"}),g.jsx(jt,{label:"Pitch (degrees)",name:"pitch_deg",value:x,onChange:ue,placeholder:"e.g., 0.0",step:"any"}),g.jsx(jt,{label:"Roll (degrees)",name:"roll_deg",value:E,onChange:T,placeholder:"e.g., 0.0",step:"any"}),g.jsx("div",{className:V.rtkFixContainer,children:g.jsxs("label",{className:V.rtkFixLabel,children:[g.jsx("input",{type:"checkbox",checked:b,onChange:ee=>H(ee.target.checked),className:V.rtkFixCheckbox}),"RTK Fix Available"]})}),g.jsx(jt,{label:"Horizontal Std Dev (m)",name:"std_h_m",value:N,onChange:oe,placeholder:"e.g., 0.1",step:"any"}),g.jsx(jt,{label:"Vertical Std Dev (m)",name:"std_v_m",value:P,onChange:Se,placeholder:"e.g., 0.2",step:"any"})]})]})})]})}function Kj({isPerformanceConfirmed:e,scores:n,onScoreChange:i,onConfirmRatings:o}){return e?null:g.jsx(dr,{heading:"AI Performance Rating",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:g.jsxs("div",{className:V.ratingContent,children:[g.jsx("p",{className:V.ratingDescription,children:"How well did the AI perform on the task?"}),["accuracy","context","usability"].map(s=>g.jsxs("div",{className:V.ratingSlider,children:[g.jsx("label",{className:V.ratingLabel,children:s}),g.jsx("input",{type:"range",min:0,max:100,value:n[s],onChange:u=>i(s,Number(u.target.value)),className:V.ratingInput}),g.jsx("span",{className:V.ratingValue,children:n[s]})]},s)),g.jsx("div",{className:V.confirmButtonContainer,children:g.jsx(Ue,{name:"confirm-ratings",variant:"secondary",onClick:o,children:"Confirm Ratings"})})]})})}function Yj({description:e,analysis:n,recommendedActions:i,onDescriptionChange:o,onAnalysisChange:s,onRecommendedActionsChange:u,onBack:d,onDelete:f,onSubmit:p,onEditRatings:y,isPerformanceConfirmed:w=!1,isSubmitting:C=!1}){const m=x=>{if(x){const E=x.split(` `),b=E.findIndex(L=>L.startsWith("Description:")),N=E.findIndex(L=>L.startsWith("Analysis:")),P=E.findIndex(L=>L.startsWith("Recommended Actions:"));b!==-1&&N!==-1&&P!==-1&&(o(E.slice(b+1,N).join(` `).trim()),s(E.slice(N+1,P).join(` `).trim()),u(E.slice(P+1).join(` @@ -154,8 +154,8 @@ Analysis: ${n||"AI-generated analysis will appear here..."} Recommended Actions: -${i||"AI-generated recommended actions will appear here..."}`,onChange:m,rows:12,placeholder:"AI-generated content will appear here..."})})}),g.jsxs("div",{className:V.submitSection,children:[g.jsx(Ue,{name:"back",variant:"secondary",onClick:d,children:"Back"}),w&&y&&g.jsx(Ue,{name:"edit-ratings",variant:"secondary",onClick:y,children:"Edit Ratings"}),g.jsx(hf,{name:"delete",variant:"tertiary",onClick:f,title:"Delete",ariaLabel:"Delete uploaded image",children:g.jsx(df,{})}),g.jsx(Ue,{name:"submit",onClick:p,disabled:C,children:"Submit"})]})]})}function Xj({isOpen:e,imageUrl:n,preview:i,selectedImageData:o,onClose:s,isLoading:u=!1}){if(!e)return null;let d,f;return o?(d=URL.createObjectURL(o.file),f=`Image ${o.index+1}: ${o.file.name}`):(d=n||i||void 0,f="Full size map"),g.jsx("div",{className:V.fullSizeModalOverlay,onClick:s,children:g.jsxs("div",{className:V.fullSizeModalContent,onClick:p=>p.stopPropagation(),children:[g.jsx("div",{className:V.fullSizeModalHeader,children:g.jsx(Ue,{name:"close-modal",variant:"tertiary",size:1,onClick:s,children:"✕"})}),g.jsx("div",{className:V.fullSizeModalImage,children:u?g.jsxs("div",{className:V.loadingContainer,children:[g.jsx(Wo,{className:"text-ifrcRed"}),g.jsx("p",{className:V.loadingText,children:"Loading image..."})]}):g.jsx("img",{src:d,alt:f})})]})})}function Jj({isOpen:e,onClose:n}){return e?g.jsx("div",{className:V.fullSizeModalOverlay,onClick:n,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:i=>i.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"Please Confirm Your Ratings"}),g.jsx("p",{className:V.ratingWarningText,children:'You must confirm your performance ratings before submitting. Please go back to the rating section and click "Confirm Ratings".'}),g.jsx("div",{className:V.ratingWarningButtons,children:g.jsx(Ue,{name:"close-warning",variant:"secondary",onClick:n,children:"Close"})})]})})}):null}function eP({isOpen:e,onConfirm:n,onCancel:i}){return e?g.jsx("div",{className:V.fullSizeModalOverlay,onClick:i,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:o=>o.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"Delete Image?"}),g.jsx("p",{className:V.ratingWarningText,children:"This action cannot be undone. Are you sure you want to delete this uploaded image?"}),g.jsxs("div",{className:V.ratingWarningButtons,children:[g.jsx(Ue,{name:"confirm-delete",variant:"secondary",onClick:n,children:"Delete"}),g.jsx(Ue,{name:"cancel-delete",variant:"tertiary",onClick:i,children:"Cancel"})]})]})})}):null}function tP({isOpen:e,onConfirm:n,onCancel:i}){return e?g.jsx("div",{className:V.fullSizeModalOverlay,onClick:i,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:o=>o.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"Leave Page?"}),g.jsx("p",{className:V.ratingWarningText,children:"Your uploaded image will be deleted if you leave this page. Are you sure you want to continue?"}),g.jsxs("div",{className:V.ratingWarningButtons,children:[g.jsx(Ue,{name:"confirm-navigation",variant:"secondary",onClick:n,children:"Leave Page"}),g.jsx(Ue,{name:"cancel-navigation",variant:"tertiary",onClick:i,children:"Stay"})]})]})})}):null}function nP({isOpen:e,fallbackInfo:n,onClose:i}){if(!e||!n)return null;const s=(u=>u.includes("quota")||u.includes("credits")?"API quota exceeded - you've used up your monthly free credits":u.includes("rate")||u.includes("429")?"Rate limit exceeded - too many requests":u.includes("loading")||u.includes("503")?"Model is currently loading or unavailable":u.includes("network")||u.includes("timeout")?"Network connection issue":u.includes("MODEL_UNAVAILABLE")?"Model service is temporarily unavailable":u)(n.reason);return g.jsx("div",{className:V.fullSizeModalOverlay,onClick:i,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:u=>u.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"⚠️ Model Changed"}),g.jsxs("p",{className:V.ratingWarningText,children:[g.jsx("strong",{children:n.originalModel})," is currently unavailable. We've automatically switched to ",g.jsx("strong",{children:n.fallbackModel})," to complete your request."]}),g.jsxs("div",{className:V.fallbackReasonBox,children:[g.jsx("p",{className:V.fallbackReasonTitle,children:"Reason:"}),g.jsx("p",{className:V.fallbackReasonText,children:s})]}),g.jsx("div",{className:V.ratingWarningButtons,children:g.jsx(Ue,{name:"close-fallback",variant:"secondary",onClick:i,children:"Got it"})})]})})})}function rP({isOpen:e,preprocessingInfo:n,onClose:i}){return!e||!n?null:g.jsx("div",{className:V.fullSizeModalOverlay,onClick:i,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:o=>o.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"File Converted"}),g.jsxs("p",{className:V.ratingWarningText,children:["Your file ",g.jsx("strong",{children:n.original_filename})," has been converted from",g.jsxs("strong",{children:[" ",n.original_mime_type]})," to",g.jsxs("strong",{children:[" ",n.processed_mime_type]})," for optimal processing.",g.jsx("br",{}),g.jsx("br",{}),"This conversion ensures your file is in the best format for our AI models to analyze."]}),g.jsx("div",{className:V.ratingWarningButtons,children:g.jsx(Ue,{name:"close-preprocessing",variant:"secondary",onClick:i,children:"Got it"})})]})})})}function iP({isOpen:e,preprocessingFile:n,isPreprocessing:i,preprocessingProgress:o,onConfirm:s,onCancel:u}){return e?g.jsx("div",{className:V.fullSizeModalOverlay,onClick:i?void 0:u,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:d=>d.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"File Conversion Required"}),g.jsx("p",{className:V.ratingWarningText,children:"The file you selected will be converted to PNG format. This ensures optimal compatibility and processing by our AI models."}),!i&&g.jsxs("div",{className:V.ratingWarningButtons,children:[g.jsx(Ue,{name:"confirm-preprocessing",variant:"secondary",onClick:s,children:"Convert File"}),g.jsx(Ue,{name:"cancel-preprocessing",variant:"tertiary",onClick:u,children:"Cancel"})]}),i&&g.jsxs("div",{className:V.preprocessingProgress,children:[g.jsx("p",{children:o}),g.jsx(Wo,{className:"text-ifrcRed"})]})]})})}):null}function oP({isOpen:e,unsupportedFile:n,onClose:i}){return!e||!n?null:g.jsx("div",{className:V.fullSizeModalOverlay,onClick:i,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:o=>o.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"Unsupported File Format"}),g.jsxs("p",{className:V.ratingWarningText,children:["The file ",g.jsx("strong",{children:n.name})," is not supported for upload.",g.jsx("br",{}),g.jsx("br",{}),g.jsx("strong",{children:"Supported formats:"}),g.jsx("br",{}),"• Images: JPEG, PNG, TIFF, HEIC, WebP, GIF",g.jsx("br",{}),"• Documents: PDF (will be converted to image)",g.jsx("br",{}),g.jsx("br",{}),g.jsx("strong",{children:"Recommendation:"})," Convert your file to JPEG or PNG format for best compatibility."]}),g.jsx("div",{className:V.ratingWarningButtons,children:g.jsx(Ue,{name:"close-unsupported",variant:"secondary",onClick:i,children:"Got it"})})]})})})}function aP({isOpen:e,oversizedFile:n,onClose:i,onCancel:o}){return!e||!n?null:g.jsx("div",{className:V.lightModalOverlay,onClick:o,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:s=>s.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"File Size Warning"}),g.jsxs("p",{className:V.ratingWarningText,children:["The file ",g.jsx("strong",{children:n.name})," is large (",(n.size/(1024*1024)).toFixed(1),"MB).",g.jsx("br",{}),g.jsx("br",{}),g.jsx("strong",{children:"Warning:"})," This file size might exceed the limits of the AI models we use.",g.jsx("br",{}),g.jsx("br",{}),"You can still proceed, but consider using a smaller file if you encounter issues."]}),g.jsxs("div",{className:V.ratingWarningButtons,children:[g.jsx(Ue,{name:"continue-size-warning",variant:"secondary",onClick:i,children:"Continue"}),g.jsx(Ue,{name:"cancel-size-warning",variant:"tertiary",onClick:o,children:"Cancel"})]})]})})})}const Bl="selectedVlmModel";function $g(){let e,n;try{[e]=Dx(),n=hs()}catch(k){console.warn("Router context not available, using fallback:",k),e=new URLSearchParams,n=()=>{}}const[i,o]=v.useState(1),[s,u]=v.useState(!1),[d,f]=v.useState(!1),[p,y]=v.useState(!1),w=v.useRef(i),C=v.useRef(null),[m,x]=v.useState(null),[E,b]=v.useState(null),[N,P]=v.useState([]),[L,$]=v.useState(""),[q,Z]=v.useState(""),[fe,O]=v.useState(""),[K,ce]=v.useState("crisis_map"),[de,I]=v.useState([]),[U,W]=v.useState(""),[ne,he]=v.useState(""),[Ce,_e]=v.useState(""),[G,ue]=v.useState(""),[T,H]=v.useState(""),[oe,Se]=v.useState(""),[se,re]=v.useState(""),[ee,Q]=v.useState(""),[Y,et]=v.useState(""),[tn,Wt]=v.useState(!1),[ot,bt]=v.useState(""),[st,wt]=v.useState(""),[ft,ht]=v.useState([]),[xt,nn]=v.useState([]),[Tn,ln]=v.useState([]),[jn,Jr]=v.useState([]),[un,cn]=v.useState([]),[Er,Kn]=v.useState([]),[lt,Dt]=v.useState(null),[Qt,pt]=v.useState([]),[Kt,dn]=v.useState(null),[ji,Pi]=v.useState(""),[kr,Nr]=v.useState(""),[Tr,$n]=v.useState(""),[jr,fn]=v.useState(""),[rn,Mi]=v.useState({accuracy:50,context:50,usability:50}),[Li,ei]=v.useState(!1),[Di,Yn]=v.useState(null),[hn,Pr]=v.useState(!1),[Mr,j]=v.useState(!1),[R,z]=v.useState(!1),[X,le]=v.useState(!1),[Ee,Me]=v.useState(null),[ye,we]=v.useState(!1),[ge,ve]=v.useState(null),[Fe,ze]=v.useState(!1),[Pt,Ye]=v.useState(null),[Ge,Xe]=v.useState(!1),[Pn,pn]=v.useState(null),[Mn,Ve]=v.useState(!1),[Oi,At]=v.useState(""),[zn,mn]=v.useState(!1),[ti,He]=v.useState(null),[nt,_t]=v.useState(!1),[Lr,Ze]=v.useState(null),[pr,Dr]=v.useState(0);w.current=i,C.current=lt;const Or=k=>!k||xt.length===0?k:xt.find(Ne=>Ne.s_code===k||Ne.label===k)?.s_code||k,po=k=>{$(Or(k||""))},mo=k=>Z(k||""),Ri=k=>O(k||""),ni=k=>ce(k||""),Su=k=>I(Array.isArray(k)?k:[]),bu=k=>he(k||""),oa=k=>_e(k||""),Cs=k=>ue(k||""),aa=k=>H(k||""),Ii=k=>Se(k||""),_u=k=>re(k||""),sa=k=>Q(k||""),tt=k=>et(k||""),Ss=k=>Wt(k||!1),bs=k=>bt(k||""),la=k=>wt(k||""),Ai=k=>o(k),_s=v.useCallback(()=>{N.length>1&&Dr(k=>k>0?k-1:N.length-1)},[N.length]),Es=v.useCallback(()=>{N.length>1&&Dr(k=>k{k>=0&&k{if(N.length<5){const k=document.createElement("input");k.type="file",k.accept=".jpg,.jpeg,.png,.tiff,.tif,.heic,.heif,.webp,.gif,.pdf",k.onchange=Pe=>{const Ne=Pe.target;if(Ne.files&&Ne.files[0]){const ke=Ne.files[0];Rr(ke)}},k.click()}},Xn=k=>{P(Pe=>{const Ne=Pe.filter((ke,pe)=>pe!==k);return Ne.length===1?b(Ne[0]):Ne.length===0&&b(null),Ne}),ht(Pe=>Pe.filter((Ne,ke)=>ke!==k))},mr=(k,Pe,Ne)=>{ht(ke=>{const pe=[...ke];return pe[k]||(pe[k]={source:"",eventType:"",epsg:"",countries:[],centerLon:"",centerLat:"",amslM:"",aglM:"",headingDeg:"",yawDeg:"",pitchDeg:"",rollDeg:"",rtkFix:!1,stdHM:"",stdVM:""}),Pe==="source"?pe[k]={...pe[k],[Pe]:Or(Ne)}:pe[k]={...pe[k],[Pe]:Ne},pe})},Jn=k=>{const Pe=["image/jpeg","image/jpg","image/png"],Ne=[".jpg",".jpeg",".png"];let ke=!Pe.includes(k.type);if(!ke&&k.name){const pe=k.name.toLowerCase().substring(k.name.lastIndexOf("."));ke=!Ne.includes(pe)}return ke},ri=k=>{const Pe=["text/html","text/css","application/javascript","application/json","text/plain","application/xml","text/xml","application/zip","application/x-zip-compressed","application/x-rar-compressed","application/x-7z-compressed","audio/","video/","text/csv","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"];for(const Ne of Pe)if(k.type.startsWith(Ne))return!0;if(k.name){const Ne=k.name.toLowerCase().substring(k.name.lastIndexOf("."));if([".html",".htm",".css",".js",".json",".txt",".xml",".zip",".rar",".7z",".csv",".xlsx",".xls",".pptx",".ppt",".docx",".doc",".mp3",".mp4",".avi",".mov"].includes(Ne))return!0}return!1},Rr=k=>{if(k){if(console.log("File selected:",k.name,"Type:",k.type,"Size:",k.size),k.size/(1024*1024)>5&&(console.log("File too large, showing size warning modal"),Ze(k),_t(!0)),ri(k)){console.log("File format not supported at all, showing unsupported format modal"),He(k),mn(!0);return}Jn(k)?(console.log("File needs preprocessing, showing modal"),pn(k),Xe(!0)):(console.log("File does not need preprocessing, setting directly"),N.length===0?(b(k),P([k])):P(Ne=>[...Ne,k]))}},er=k=>{if(k){if(console.log("File changed:",k.name,"Type:",k.type,"Size:",k.size),k.size/(1024*1024)>5&&(console.log("File too large, showing size warning modal"),Ze(k),_t(!0)),ri(k)){console.log("File format not supported at all, showing unsupported format modal"),He(k),mn(!0);return}Jn(k)?(console.log("File needs preprocessing, showing modal"),pn(k),Xe(!0)):(console.log("File does not need preprocessing, replacing last file"),N.length>1?(P(Ne=>{const ke=[...Ne];return ke[ke.length-1]=k,ke}),N.length===1&&b(k)):(b(k),P([k])))}};async function $i(k){const Pe=await k.text();try{return Pe?JSON.parse(Pe):{}}catch{return{error:Pe}}}function go(k,Pe){const Ne=k instanceof Error?k.message:`Failed to ${Pe.toLowerCase()}`;alert(Ne)}async function ii(){if(N.length!==0){u(!0);try{N.length===1?await Eu():await ks()}catch(k){go(k,"Upload")}finally{u(!1)}}}async function Eu(){console.log("DEBUG: Starting single image upload");const k=new FormData;k.append("file",N[0]),k.append("title",U),k.append("image_type",K),L&&k.append("source",L),q&&k.append("event_type",q),fe&&k.append("epsg",fe),de.length>0&&de.forEach(pe=>k.append("countries",pe)),K==="drone_image"&&(ne&&k.append("center_lon",ne),Ce&&k.append("center_lat",Ce),G&&k.append("amsl_m",G),T&&k.append("agl_m",T),oe&&k.append("heading_deg",oe),se&&k.append("yaw_deg",se),ee&&k.append("pitch_deg",ee),Y&&k.append("roll_deg",Y),tn&&k.append("rtk_fix",tn.toString()),ot&&k.append("std_h_m",ot),st&&k.append("std_v_m",st));const Pe=localStorage.getItem(Bl);Pe&&k.append("model_name",Pe);const Ne=await fetch("/api/images/",{method:"POST",body:k}),ke=await $i(Ne);if(!Ne.ok)throw new Error(ke.error||"Upload failed");console.log("DEBUG: Single upload response:",ke),await zi(ke,!1)}async function ks(){console.log("DEBUG: Starting multi-image upload");const k=new FormData;N.forEach(pe=>k.append("files",pe)),k.append("title",U),k.append("image_type",K),ft.forEach((pe,Re)=>{pe.source&&k.append(`source_${Re}`,pe.source),pe.eventType&&k.append(`event_type_${Re}`,pe.eventType),pe.epsg&&k.append(`epsg_${Re}`,pe.epsg),pe.countries.length>0&&pe.countries.forEach(Ot=>k.append(`countries_${Re}`,Ot)),K==="drone_image"&&(pe.centerLon&&k.append(`center_lon_${Re}`,pe.centerLon),pe.centerLat&&k.append(`center_lat_${Re}`,pe.centerLat),pe.amslM&&k.append(`amsl_m_${Re}`,pe.amslM),pe.aglM&&k.append(`agl_m_${Re}`,pe.aglM),pe.headingDeg&&k.append(`heading_deg_${Re}`,pe.headingDeg),pe.yawDeg&&k.append(`yaw_deg_${Re}`,pe.yawDeg),pe.pitchDeg&&k.append(`pitch_deg_${Re}`,pe.pitchDeg),pe.rollDeg&&k.append(`roll_deg_${Re}`,pe.rollDeg),pe.rtkFix&&k.append(`rtk_fix_${Re}`,pe.rtkFix.toString()),pe.stdHM&&k.append(`std_h_m_${Re}`,pe.stdHM),pe.stdVM&&k.append(`std_v_m_${Re}`,pe.stdVM))});const Pe=localStorage.getItem(Bl);Pe&&k.append("model_name",Pe);const Ne=await fetch("/api/images/multi",{method:"POST",body:k}),ke=await $i(Ne);if(!Ne.ok)throw new Error(ke.error||"Upload failed");console.log("DEBUG: Multi upload response:",ke),await zi(ke,!0)}async function zi(k,Pe){dn(k.image_url),k.preprocessing_info&&typeof k.preprocessing_info=="object"&&"was_preprocessed"in k.preprocessing_info&&k.preprocessing_info.was_preprocessed===!0&&(Ye(k.preprocessing_info),ze(!0));const Ne=k.image_id;if(!Ne)throw new Error("Upload failed: image_id not found");if(Dt(Ne),Pe)if(k.image_ids&&Array.isArray(k.image_ids)){const ut=k.image_ids;console.log("DEBUG: Storing image IDs for multi-upload:",ut),pt(ut)}else console.log("DEBUG: Multi-upload but no image_ids found, using single ID"),pt([Ne]);else console.log("DEBUG: Storing single image ID:",Ne),pt([Ne]);const ke=k,pe=ke.raw_json,Re=pe?.fallback_used,Ot=pe?.original_model,Nt=pe?.fallback_reason,Bn=ke.model;Re&&Ot&&Nt&&(ve({originalModel:Ot,fallbackModel:Bn,reason:Nt}),we(!0));const Un=ke.raw_json?.metadata;if(Un){const ut=Un.metadata||Un;if(ut&&typeof ut=="object"){const nr=[];if(Pe){const ct=ut.metadata_images;if(ct&&typeof ct=="object")for(let rr=1;rr<=N.length;rr++){const ai=`image${rr}`,Ir=ct[ai];if(Ir&&typeof Ir=="object"){const gn=Ir,yo=gn.source||"",js=Or(yo);nr.push({source:js,eventType:gn.type||"",epsg:gn.epsg||"",countries:Array.isArray(gn.countries)?gn.countries:[],centerLon:"",centerLat:"",amslM:"",aglM:"",headingDeg:"",yawDeg:"",pitchDeg:"",rollDeg:"",rtkFix:!1,stdHM:"",stdVM:""})}else nr.push({source:"",eventType:"",epsg:"",countries:[],centerLon:"",centerLat:"",amslM:"",aglM:"",headingDeg:"",yawDeg:"",pitchDeg:"",rollDeg:"",rtkFix:!1,stdHM:"",stdVM:""})}else{const rr=ut.source||"",Ir={source:Or(rr),eventType:ut.type||"",epsg:ut.epsg||"",countries:Array.isArray(ut.countries)?ut.countries:[],centerLon:"",centerLat:"",amslM:"",aglM:"",headingDeg:"",yawDeg:"",pitchDeg:"",rollDeg:"",rtkFix:!1,stdHM:"",stdVM:""};for(let gn=0;gn0){const ct=nr[0];if(ut&&typeof ut=="object"){const rr=ut.title;rr&&W(rr||"")}$(ct.source||""),Z(ct.eventType||""),O(ct.epsg||""),I(ct.countries||[]),K==="drone_image"&&(he(ct.centerLon||""),_e(ct.centerLat||""),ue(ct.amslM||""),H(ct.aglM||""),Se(ct.headingDeg||""),re(ct.yawDeg||""),Q(ct.pitchDeg||""),et(ct.rollDeg||""),Wt(ct.rtkFix||!1),bt(ct.stdHM||""),wt(ct.stdVM||""))}}}const gt=ke.raw_json?.metadata;gt&&(gt.description&&Nr(gt.description),gt.analysis&&$n(gt.analysis),gt.recommended_actions&&fn(gt.recommended_actions)),ke.generated&&Pi(ke.generated),Ai("2a")}async function Ns(){if(console.log("handleSubmit called with:",{uploadedImageId:lt,title:U,draft:ji}),!lt)return alert("No image to submit");if(!hn){j(!0);return}y(!0);try{const k=Qt.length>0?Qt:[lt];console.log("DEBUG: Submit - Using image IDs:",k),console.log("DEBUG: Submit - uploadedImageIds:",Qt),console.log("DEBUG: Submit - uploadedImageId:",lt);for(let Re=0;Rep.stopPropagation(),children:[g.jsx("div",{className:V.fullSizeModalHeader,children:g.jsx(Ue,{name:"close-modal",variant:"tertiary",size:1,onClick:s,children:"✕"})}),g.jsx("div",{className:V.fullSizeModalImage,children:u?g.jsxs("div",{className:V.loadingContainer,children:[g.jsx(Wo,{className:"text-ifrcRed"}),g.jsx("p",{className:V.loadingText,children:"Loading image..."})]}):g.jsx("img",{src:d,alt:f})})]})})}function Jj({isOpen:e,onClose:n}){return e?g.jsx("div",{className:V.fullSizeModalOverlay,onClick:n,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:i=>i.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"Please Confirm Your Ratings"}),g.jsx("p",{className:V.ratingWarningText,children:'You must confirm your performance ratings before submitting. Please go back to the rating section and click "Confirm Ratings".'}),g.jsx("div",{className:V.ratingWarningButtons,children:g.jsx(Ue,{name:"close-warning",variant:"secondary",onClick:n,children:"Close"})})]})})}):null}function eP({isOpen:e,onConfirm:n,onCancel:i}){return e?g.jsx("div",{className:V.fullSizeModalOverlay,onClick:i,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:o=>o.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"Delete Image?"}),g.jsx("p",{className:V.ratingWarningText,children:"This action cannot be undone. Are you sure you want to delete this uploaded image?"}),g.jsxs("div",{className:V.ratingWarningButtons,children:[g.jsx(Ue,{name:"confirm-delete",variant:"secondary",onClick:n,children:"Delete"}),g.jsx(Ue,{name:"cancel-delete",variant:"tertiary",onClick:i,children:"Cancel"})]})]})})}):null}function tP({isOpen:e,onConfirm:n,onCancel:i}){return e?g.jsx("div",{className:V.fullSizeModalOverlay,onClick:i,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:o=>o.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"Leave Page?"}),g.jsx("p",{className:V.ratingWarningText,children:"Your uploaded image will be deleted if you leave this page. Are you sure you want to continue?"}),g.jsxs("div",{className:V.ratingWarningButtons,children:[g.jsx(Ue,{name:"confirm-navigation",variant:"secondary",onClick:n,children:"Leave Page"}),g.jsx(Ue,{name:"cancel-navigation",variant:"tertiary",onClick:i,children:"Stay"})]})]})})}):null}function nP({isOpen:e,fallbackInfo:n,onClose:i}){if(!e||!n)return null;const s=(u=>u.includes("quota")||u.includes("credits")?"API quota exceeded - you've used up your monthly free credits":u.includes("rate")||u.includes("429")?"Rate limit exceeded - too many requests":u.includes("loading")||u.includes("503")?"Model is currently loading or unavailable":u.includes("network")||u.includes("timeout")?"Network connection issue":u.includes("MODEL_UNAVAILABLE")?"Model service is temporarily unavailable":u)(n.reason);return g.jsx("div",{className:V.fullSizeModalOverlay,onClick:i,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:u=>u.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"⚠️ Model Changed"}),g.jsxs("p",{className:V.ratingWarningText,children:[g.jsx("strong",{children:n.originalModel})," is currently unavailable. We've automatically switched to ",g.jsx("strong",{children:n.fallbackModel})," to complete your request."]}),g.jsxs("div",{className:V.fallbackReasonBox,children:[g.jsx("p",{className:V.fallbackReasonTitle,children:"Reason:"}),g.jsx("p",{className:V.fallbackReasonText,children:s})]}),g.jsx("div",{className:V.ratingWarningButtons,children:g.jsx(Ue,{name:"close-fallback",variant:"secondary",onClick:i,children:"Got it"})})]})})})}function rP({isOpen:e,preprocessingInfo:n,onClose:i}){return!e||!n?null:g.jsx("div",{className:V.fullSizeModalOverlay,onClick:i,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:o=>o.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"File Converted"}),g.jsxs("p",{className:V.ratingWarningText,children:["Your file ",g.jsx("strong",{children:n.original_filename})," has been converted from",g.jsxs("strong",{children:[" ",n.original_mime_type]})," to",g.jsxs("strong",{children:[" ",n.processed_mime_type]})," for optimal processing.",g.jsx("br",{}),g.jsx("br",{}),"This conversion ensures your file is in the best format for our AI models to analyze."]}),g.jsx("div",{className:V.ratingWarningButtons,children:g.jsx(Ue,{name:"close-preprocessing",variant:"secondary",onClick:i,children:"Got it"})})]})})})}function iP({isOpen:e,isPreprocessing:n,preprocessingProgress:i,onConfirm:o,onCancel:s}){return e?g.jsx("div",{className:V.fullSizeModalOverlay,onClick:n?void 0:s,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:u=>u.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"File Conversion Required"}),g.jsx("p",{className:V.ratingWarningText,children:"The file you selected will be converted to PNG format. This ensures optimal compatibility and processing by our AI models."}),!n&&g.jsxs("div",{className:V.ratingWarningButtons,children:[g.jsx(Ue,{name:"confirm-preprocessing",variant:"secondary",onClick:o,children:"Convert File"}),g.jsx(Ue,{name:"cancel-preprocessing",variant:"tertiary",onClick:s,children:"Cancel"})]}),n&&g.jsxs("div",{className:V.preprocessingProgress,children:[g.jsx("p",{children:i}),g.jsx(Wo,{className:"text-ifrcRed"})]})]})})}):null}function oP({isOpen:e,unsupportedFile:n,onClose:i}){return!e||!n?null:g.jsx("div",{className:V.fullSizeModalOverlay,onClick:i,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:o=>o.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"Unsupported File Format"}),g.jsxs("p",{className:V.ratingWarningText,children:["The file ",g.jsx("strong",{children:n.name})," is not supported for upload.",g.jsx("br",{}),g.jsx("br",{}),g.jsx("strong",{children:"Supported formats:"}),g.jsx("br",{}),"• Images: JPEG, PNG, TIFF, HEIC, WebP, GIF",g.jsx("br",{}),"• Documents: PDF (will be converted to image)",g.jsx("br",{}),g.jsx("br",{}),g.jsx("strong",{children:"Recommendation:"})," Convert your file to JPEG or PNG format for best compatibility."]}),g.jsx("div",{className:V.ratingWarningButtons,children:g.jsx(Ue,{name:"close-unsupported",variant:"secondary",onClick:i,children:"Got it"})})]})})})}function aP({isOpen:e,oversizedFile:n,onClose:i,onCancel:o}){return!e||!n?null:g.jsx("div",{className:V.lightModalOverlay,onClick:o,children:g.jsx("div",{className:V.fullSizeModalContent,onClick:s=>s.stopPropagation(),children:g.jsxs("div",{className:V.ratingWarningContent,children:[g.jsx("h3",{className:V.ratingWarningTitle,children:"File Size Warning"}),g.jsxs("p",{className:V.ratingWarningText,children:["The file ",g.jsx("strong",{children:n.name})," is large (",(n.size/(1024*1024)).toFixed(1),"MB).",g.jsx("br",{}),g.jsx("br",{}),g.jsx("strong",{children:"Warning:"})," This file size might exceed the limits of the AI models we use.",g.jsx("br",{}),g.jsx("br",{}),"You can still proceed, but consider using a smaller file if you encounter issues."]}),g.jsxs("div",{className:V.ratingWarningButtons,children:[g.jsx(Ue,{name:"continue-size-warning",variant:"secondary",onClick:i,children:"Continue"}),g.jsx(Ue,{name:"cancel-size-warning",variant:"tertiary",onClick:o,children:"Cancel"})]})]})})})}const Bl="selectedVlmModel";function $g(){let e,n;try{[e]=Dx(),n=hs()}catch(k){console.warn("Router context not available, using fallback:",k),e=new URLSearchParams,n=()=>{}}const[i,o]=v.useState(1),[s,u]=v.useState(!1),[d,f]=v.useState(!1),[p,y]=v.useState(!1),w=v.useRef(i),C=v.useRef(null),[m,x]=v.useState(null),[E,b]=v.useState(null),[N,P]=v.useState([]),[L,$]=v.useState(""),[q,Z]=v.useState(""),[fe,O]=v.useState(""),[K,ce]=v.useState("crisis_map"),[de,I]=v.useState([]),[U,W]=v.useState(""),[ne,he]=v.useState(""),[Ce,_e]=v.useState(""),[G,ue]=v.useState(""),[T,H]=v.useState(""),[oe,Se]=v.useState(""),[se,re]=v.useState(""),[ee,Q]=v.useState(""),[Y,et]=v.useState(""),[tn,Wt]=v.useState(!1),[ot,bt]=v.useState(""),[st,wt]=v.useState(""),[ft,ht]=v.useState([]),[xt,nn]=v.useState([]),[Tn,ln]=v.useState([]),[jn,Jr]=v.useState([]),[un,cn]=v.useState([]),[Er,Kn]=v.useState([]),[lt,Dt]=v.useState(null),[Qt,pt]=v.useState([]),[Kt,dn]=v.useState(null),[ji,Pi]=v.useState(""),[kr,Nr]=v.useState(""),[Tr,$n]=v.useState(""),[jr,fn]=v.useState(""),[rn,Mi]=v.useState({accuracy:50,context:50,usability:50}),[Li,ei]=v.useState(!1),[Di,Yn]=v.useState(null),[hn,Pr]=v.useState(!1),[Mr,j]=v.useState(!1),[R,z]=v.useState(!1),[X,le]=v.useState(!1),[Ee,Me]=v.useState(null),[ye,we]=v.useState(!1),[ge,ve]=v.useState(null),[Fe,ze]=v.useState(!1),[Pt,Ye]=v.useState(null),[Ge,Xe]=v.useState(!1),[Pn,pn]=v.useState(null),[Mn,Ve]=v.useState(!1),[Oi,At]=v.useState(""),[zn,mn]=v.useState(!1),[ti,He]=v.useState(null),[nt,_t]=v.useState(!1),[Lr,Ze]=v.useState(null),[pr,Dr]=v.useState(0);w.current=i,C.current=lt;const Or=k=>!k||xt.length===0?k:xt.find(Ne=>Ne.s_code===k||Ne.label===k)?.s_code||k,po=k=>{$(Or(k||""))},mo=k=>Z(k||""),Ri=k=>O(k||""),ni=k=>ce(k||""),Su=k=>I(Array.isArray(k)?k:[]),bu=k=>he(k||""),oa=k=>_e(k||""),Cs=k=>ue(k||""),aa=k=>H(k||""),Ii=k=>Se(k||""),_u=k=>re(k||""),sa=k=>Q(k||""),tt=k=>et(k||""),Ss=k=>Wt(k||!1),bs=k=>bt(k||""),la=k=>wt(k||""),Ai=k=>o(k),_s=v.useCallback(()=>{N.length>1&&Dr(k=>k>0?k-1:N.length-1)},[N.length]),Es=v.useCallback(()=>{N.length>1&&Dr(k=>k{k>=0&&k{if(N.length<5){const k=document.createElement("input");k.type="file",k.accept=".jpg,.jpeg,.png,.tiff,.tif,.heic,.heif,.webp,.gif,.pdf",k.onchange=Pe=>{const Ne=Pe.target;if(Ne.files&&Ne.files[0]){const ke=Ne.files[0];Rr(ke)}},k.click()}},Xn=k=>{P(Pe=>{const Ne=Pe.filter((ke,pe)=>pe!==k);return Ne.length===1?b(Ne[0]):Ne.length===0&&b(null),Ne}),ht(Pe=>Pe.filter((Ne,ke)=>ke!==k))},mr=(k,Pe,Ne)=>{ht(ke=>{const pe=[...ke];return pe[k]||(pe[k]={source:"",eventType:"",epsg:"",countries:[],centerLon:"",centerLat:"",amslM:"",aglM:"",headingDeg:"",yawDeg:"",pitchDeg:"",rollDeg:"",rtkFix:!1,stdHM:"",stdVM:""}),Pe==="source"?pe[k]={...pe[k],[Pe]:Or(Ne)}:pe[k]={...pe[k],[Pe]:Ne},pe})},Jn=k=>{const Pe=["image/jpeg","image/jpg","image/png"],Ne=[".jpg",".jpeg",".png"];let ke=!Pe.includes(k.type);if(!ke&&k.name){const pe=k.name.toLowerCase().substring(k.name.lastIndexOf("."));ke=!Ne.includes(pe)}return ke},ri=k=>{const Pe=["text/html","text/css","application/javascript","application/json","text/plain","application/xml","text/xml","application/zip","application/x-zip-compressed","application/x-rar-compressed","application/x-7z-compressed","audio/","video/","text/csv","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"];for(const Ne of Pe)if(k.type.startsWith(Ne))return!0;if(k.name){const Ne=k.name.toLowerCase().substring(k.name.lastIndexOf("."));if([".html",".htm",".css",".js",".json",".txt",".xml",".zip",".rar",".7z",".csv",".xlsx",".xls",".pptx",".ppt",".docx",".doc",".mp3",".mp4",".avi",".mov"].includes(Ne))return!0}return!1},Rr=k=>{if(k){if(console.log("File selected:",k.name,"Type:",k.type,"Size:",k.size),k.size/(1024*1024)>5&&(console.log("File too large, showing size warning modal"),Ze(k),_t(!0)),ri(k)){console.log("File format not supported at all, showing unsupported format modal"),He(k),mn(!0);return}Jn(k)?(console.log("File needs preprocessing, showing modal"),pn(k),Xe(!0)):(console.log("File does not need preprocessing, setting directly"),N.length===0?(b(k),P([k])):P(Ne=>[...Ne,k]))}},er=k=>{if(k){if(console.log("File changed:",k.name,"Type:",k.type,"Size:",k.size),k.size/(1024*1024)>5&&(console.log("File too large, showing size warning modal"),Ze(k),_t(!0)),ri(k)){console.log("File format not supported at all, showing unsupported format modal"),He(k),mn(!0);return}Jn(k)?(console.log("File needs preprocessing, showing modal"),pn(k),Xe(!0)):(console.log("File does not need preprocessing, replacing last file"),N.length>1?(P(Ne=>{const ke=[...Ne];return ke[ke.length-1]=k,ke}),N.length===1&&b(k)):(b(k),P([k])))}};async function $i(k){const Pe=await k.text();try{return Pe?JSON.parse(Pe):{}}catch{return{error:Pe}}}function go(k,Pe){const Ne=k instanceof Error?k.message:`Failed to ${Pe.toLowerCase()}`;alert(Ne)}async function ii(){if(N.length!==0){u(!0);try{N.length===1?await Eu():await ks()}catch(k){go(k,"Upload")}finally{u(!1)}}}async function Eu(){console.log("DEBUG: Starting single image upload");const k=new FormData;k.append("file",N[0]),k.append("title",U),k.append("image_type",K),L&&k.append("source",L),q&&k.append("event_type",q),fe&&k.append("epsg",fe),de.length>0&&de.forEach(pe=>k.append("countries",pe)),K==="drone_image"&&(ne&&k.append("center_lon",ne),Ce&&k.append("center_lat",Ce),G&&k.append("amsl_m",G),T&&k.append("agl_m",T),oe&&k.append("heading_deg",oe),se&&k.append("yaw_deg",se),ee&&k.append("pitch_deg",ee),Y&&k.append("roll_deg",Y),tn&&k.append("rtk_fix",tn.toString()),ot&&k.append("std_h_m",ot),st&&k.append("std_v_m",st));const Pe=localStorage.getItem(Bl);Pe&&k.append("model_name",Pe);const Ne=await fetch("/api/images/",{method:"POST",body:k}),ke=await $i(Ne);if(!Ne.ok)throw new Error(ke.error||"Upload failed");console.log("DEBUG: Single upload response:",ke),await zi(ke,!1)}async function ks(){console.log("DEBUG: Starting multi-image upload");const k=new FormData;N.forEach(pe=>k.append("files",pe)),k.append("title",U),k.append("image_type",K),ft.forEach((pe,Re)=>{pe.source&&k.append(`source_${Re}`,pe.source),pe.eventType&&k.append(`event_type_${Re}`,pe.eventType),pe.epsg&&k.append(`epsg_${Re}`,pe.epsg),pe.countries.length>0&&pe.countries.forEach(Ot=>k.append(`countries_${Re}`,Ot)),K==="drone_image"&&(pe.centerLon&&k.append(`center_lon_${Re}`,pe.centerLon),pe.centerLat&&k.append(`center_lat_${Re}`,pe.centerLat),pe.amslM&&k.append(`amsl_m_${Re}`,pe.amslM),pe.aglM&&k.append(`agl_m_${Re}`,pe.aglM),pe.headingDeg&&k.append(`heading_deg_${Re}`,pe.headingDeg),pe.yawDeg&&k.append(`yaw_deg_${Re}`,pe.yawDeg),pe.pitchDeg&&k.append(`pitch_deg_${Re}`,pe.pitchDeg),pe.rollDeg&&k.append(`roll_deg_${Re}`,pe.rollDeg),pe.rtkFix&&k.append(`rtk_fix_${Re}`,pe.rtkFix.toString()),pe.stdHM&&k.append(`std_h_m_${Re}`,pe.stdHM),pe.stdVM&&k.append(`std_v_m_${Re}`,pe.stdVM))});const Pe=localStorage.getItem(Bl);Pe&&k.append("model_name",Pe);const Ne=await fetch("/api/images/multi",{method:"POST",body:k}),ke=await $i(Ne);if(!Ne.ok)throw new Error(ke.error||"Upload failed");console.log("DEBUG: Multi upload response:",ke),await zi(ke,!0)}async function zi(k,Pe){dn(k.image_url),k.preprocessing_info&&typeof k.preprocessing_info=="object"&&"was_preprocessed"in k.preprocessing_info&&k.preprocessing_info.was_preprocessed===!0&&(Ye(k.preprocessing_info),ze(!0));const Ne=k.image_id;if(!Ne)throw new Error("Upload failed: image_id not found");if(Dt(Ne),Pe)if(k.image_ids&&Array.isArray(k.image_ids)){const ut=k.image_ids;console.log("DEBUG: Storing image IDs for multi-upload:",ut),pt(ut)}else console.log("DEBUG: Multi-upload but no image_ids found, using single ID"),pt([Ne]);else console.log("DEBUG: Storing single image ID:",Ne),pt([Ne]);const ke=k,pe=ke.raw_json,Re=pe?.fallback_used,Ot=pe?.original_model,Nt=pe?.fallback_reason,Bn=ke.model;Re&&Ot&&Nt&&(ve({originalModel:Ot,fallbackModel:Bn,reason:Nt}),we(!0));const Un=ke.raw_json?.metadata;if(Un){const ut=Un.metadata||Un;if(ut&&typeof ut=="object"){const nr=[];if(Pe){const ct=ut.metadata_images;if(ct&&typeof ct=="object")for(let rr=1;rr<=N.length;rr++){const ai=`image${rr}`,Ir=ct[ai];if(Ir&&typeof Ir=="object"){const gn=Ir,yo=gn.source||"",js=Or(yo);nr.push({source:js,eventType:gn.type||"",epsg:gn.epsg||"",countries:Array.isArray(gn.countries)?gn.countries:[],centerLon:"",centerLat:"",amslM:"",aglM:"",headingDeg:"",yawDeg:"",pitchDeg:"",rollDeg:"",rtkFix:!1,stdHM:"",stdVM:""})}else nr.push({source:"",eventType:"",epsg:"",countries:[],centerLon:"",centerLat:"",amslM:"",aglM:"",headingDeg:"",yawDeg:"",pitchDeg:"",rollDeg:"",rtkFix:!1,stdHM:"",stdVM:""})}else{const rr=ut.source||"",Ir={source:Or(rr),eventType:ut.type||"",epsg:ut.epsg||"",countries:Array.isArray(ut.countries)?ut.countries:[],centerLon:"",centerLat:"",amslM:"",aglM:"",headingDeg:"",yawDeg:"",pitchDeg:"",rollDeg:"",rtkFix:!1,stdHM:"",stdVM:""};for(let gn=0;gn0){const ct=nr[0];if(ut&&typeof ut=="object"){const rr=ut.title;rr&&W(rr||"")}$(ct.source||""),Z(ct.eventType||""),O(ct.epsg||""),I(ct.countries||[]),K==="drone_image"&&(he(ct.centerLon||""),_e(ct.centerLat||""),ue(ct.amslM||""),H(ct.aglM||""),Se(ct.headingDeg||""),re(ct.yawDeg||""),Q(ct.pitchDeg||""),et(ct.rollDeg||""),Wt(ct.rtkFix||!1),bt(ct.stdHM||""),wt(ct.stdVM||""))}}}const gt=ke.raw_json?.metadata;gt&&(gt.description&&Nr(gt.description),gt.analysis&&$n(gt.analysis),gt.recommended_actions&&fn(gt.recommended_actions)),ke.generated&&Pi(ke.generated),Ai("2a")}async function Ns(){if(console.log("handleSubmit called with:",{uploadedImageId:lt,title:U,draft:ji}),!lt)return alert("No image to submit");if(!hn){j(!0);return}y(!0);try{const k=Qt.length>0?Qt:[lt];console.log("DEBUG: Submit - Using image IDs:",k),console.log("DEBUG: Submit - uploadedImageIds:",Qt),console.log("DEBUG: Submit - uploadedImageId:",lt);for(let Re=0;Re{Pr(!1),o(1),b(null),P([]),x(null),Dt(null),pt([]),dn(null),W(""),$(""),Z(""),O(""),I([]),he(""),_e(""),ue(""),H(""),Se(""),re(""),Q(""),et(""),Wt(!1),bt(""),wt(""),Mi({accuracy:50,context:50,usability:50}),Pi(""),Nr(""),$n(""),fn(""),ht([]),we(!1),ve(null),ze(!1),Ye(null),Xe(!1),pn(null),Ve(!1),At(""),mn(!1),He(null),_t(!1),Ze(null),n("/upload",{replace:!0})},tr=v.useCallback(k=>{k==="/upload"||k==="/"||(C.current?(Me(k),le(!0)):n(k))},[n]);async function vo(){if(Ee&&C.current)try{await fetch(`/api/images/${C.current}`,{method:"DELETE"}),le(!1),Me(null),n(Ee)}catch(k){console.error("Failed to delete image before navigation:",k),le(!1),Me(null),n(Ee)}}const ku=async()=>{if(Pn){Ve(!0),At("Starting file conversion...");try{const k=new FormData;k.append("file",Pn),k.append("preprocess_only","true"),At("Converting file format...");const Pe=await fetch("/api/images/preprocess",{method:"POST",body:k});if(!Pe.ok)throw new Error("Preprocessing failed");const Ne=await Pe.json();At("Finalizing conversion...");const ke=atob(Ne.processed_content),pe=new Uint8Array(ke.length);for(let Nt=0;Nt[...Nt,Re]),x(Ot),At("Conversion complete!"),setTimeout(()=>{Xe(!1),pn(null),Ve(!1),At("")},1e3)}catch(k){console.error("Preprocessing error:",k),At("Conversion failed. Please try again."),setTimeout(()=>{Xe(!1),pn(null),Ve(!1),At("")},2e3)}}},Nu=()=>{Xe(!1),pn(null),Ve(!1),At("")},ca=async k=>{f(!0);try{const Pe=k.map(async Re=>{const Ot=await fetch(`/api/images/${Re}`);if(!Ot.ok)throw new Error(`Failed to fetch image ${Re}`);const Nt=await Ot.json(),Bn=await fetch(`/api/images/${Re}/file`);if(!Bn.ok)throw new Error(`Failed to fetch image file ${Re}`);const Un=await Bn.blob(),gt=Nt.file_key.split("/").pop()||`contributed_${Re}.png`;return{file:new File([Un],gt,{type:Un.type}),imageData:Nt}}),Ne=await Promise.all(Pe),ke=Ne.map(Re=>Re.file),pe=Ne[0]?.imageData;P(ke),pt(k),k.length===1&&Dt(k[0]),ke.length>=1&&b(ke[0]),pe?.image_type&&ce(pe.image_type)}catch(Pe){console.error("Failed to fetch contributed images:",Pe),alert(`Failed to load contributed images: ${Pe instanceof Error?Pe.message:"Unknown error"}`)}finally{f(!1)}};return v.useEffect(()=>{Promise.all([fetch("/api/sources").then(k=>k.json()),fetch("/api/types").then(k=>k.json()),fetch("/api/spatial-references").then(k=>k.json()),fetch("/api/image-types").then(k=>k.json()),fetch("/api/countries").then(k=>k.json()),fetch("/api/models").then(k=>k.json())]).then(([k,Pe,Ne,ke,pe,Re])=>{!localStorage.getItem(Bl)&&Re?.length&&localStorage.setItem(Bl,Re[0].m_code),nn(k),ln(Pe),Jr(Ne),cn(ke),Kn(pe),k.length>0&&$(k[0].s_code),Z("OTHER"),O("OTHER"),ke.length>0&&!e.get("imageType")&&!K&&ce(ke[0].image_type)})},[e,K]),v.useEffect(()=>(window.confirmNavigationIfNeeded=k=>{tr(k)},()=>{delete window.confirmNavigationIfNeeded}),[tr]),v.useEffect(()=>{const k=ke=>{if(C.current){const pe="You have an uploaded image that will be deleted if you leave this page. Are you sure you want to leave?";return ke.preventDefault(),ke.returnValue=pe,pe}},Pe=()=>{C.current&&fetch(`/api/images/${C.current}`,{method:"DELETE"}).catch(console.error)},Ne=ke=>{const pe=ke.target,Re=pe.closest("a[href]")||pe.closest("[data-navigate]");if(Re&&C.current){const Ot=Re.getAttribute("href")||Re.getAttribute("data-navigate");Ot&&Ot!=="#"&&!Ot.startsWith("javascript:")&&!Ot.startsWith("mailto:")&&(ke.preventDefault(),ke.stopPropagation(),tr(Ot))}};return window.addEventListener("beforeunload",k),document.addEventListener("click",Ne,!0),()=>{window.removeEventListener("beforeunload",k),document.removeEventListener("click",Ne,!0),Pe()}},[tr]),v.useEffect(()=>{if(!E){x(null);return}const k=URL.createObjectURL(E);return x(k),()=>URL.revokeObjectURL(k)},[E]),v.useEffect(()=>{const k=e.get("contribute"),Pe=e.get("imageIds");if(k==="true"&&Pe){const Ne=Pe.split(",").filter(ke=>ke.trim());Ne.length>0&&ca(Ne)}},[e]),v.useEffect(()=>{i==="2b"&&Dr(0)},[i]),g.jsxs(Qf,{children:[i!==3&&g.jsx("div",{className:"max-w-7xl mx-auto",children:g.jsxs("div",{className:V.uploadContainer,"data-step":i,children:[i===1&&!e.get("step")&&!d&&g.jsx(Ag,{files:N,file:E,preview:m,imageType:K,onFileChange:Rr,onRemoveImage:Xn,onAddImage:Fi,onImageTypeChange:ni,onChangeFile:er}),i===1&&e.get("contribute")==="true"&&!d&&N.length>0&&g.jsx(Ag,{files:N,file:E,preview:m,imageType:K,onFileChange:Rr,onRemoveImage:Xn,onAddImage:Fi,onImageTypeChange:ni,onChangeFile:er}),s&&g.jsxs("div",{className:V.loadingContainer,children:[g.jsx(Wo,{className:"text-ifrcRed"}),g.jsx("p",{className:V.loadingText,children:"Generating..."})]}),d&&g.jsxs("div",{className:V.loadingContainer,children:[g.jsx(Wo,{className:"text-ifrcRed"}),g.jsx("p",{className:V.loadingText,children:"Loading contribution..."})]}),(i===1&&!s&&!d||i===1&&e.get("contribute")==="true"&&!s&&!d&&N.length>0)&&g.jsx("div",{className:V.generateButtonContainer,children:Kt?g.jsx(Ue,{name:"generate-from-url",onClick:ii,children:"Generate Caption"}):g.jsx(Ue,{name:"generate",disabled:N.length===0,onClick:ii,children:"Generate"})}),i==="2a"&&g.jsxs("div",{className:V.step2Layout,children:[g.jsx("div",{className:V.mapColumn,children:g.jsx(Fg,{files:N,imageUrl:Kt,preview:m,onViewFullSize:k=>{Yn(k||null),ei(!0)}})}),g.jsx("div",{className:V.contentColumn,children:g.jsxs("div",{className:V.metadataSectionCard,children:[g.jsx(Qj,{files:N,imageType:K,title:U,source:L,eventType:q,epsg:fe,countries:de,centerLon:ne,centerLat:Ce,amslM:G,aglM:T,headingDeg:oe,yawDeg:se,pitchDeg:ee,rollDeg:Y,rtkFix:tn,stdHM:ot,stdVM:st,metadataArray:ft,sources:xt,types:Tn,spatialReferences:jn,imageTypes:un,countriesOptions:Er,onTitleChange:k=>W(k||""),onSourceChange:po,onEventTypeChange:mo,onEpsgChange:Ri,onCountriesChange:Su,onCenterLonChange:bu,onCenterLatChange:oa,onAmslMChange:Cs,onAglMChange:aa,onHeadingDegChange:Ii,onYawDegChange:_u,onPitchDegChange:sa,onRollDegChange:tt,onRtkFixChange:Ss,onStdHMChange:bs,onStdVMChange:la,onImageTypeChange:ni,updateMetadataForImage:mr}),g.jsxs("div",{className:V.confirmSection,children:[g.jsx(hf,{name:"delete",variant:"tertiary",onClick:Ts,title:"Delete",ariaLabel:"Delete uploaded image",children:g.jsx(df,{})}),g.jsx(Ue,{name:"confirm-metadata",onClick:()=>Ai("2b"),children:"Next"})]})]})})]}),i==="2b"&&g.jsxs("div",{className:V.step2bLayout,children:[p&&g.jsxs("div",{className:V.loadingContainer,children:[g.jsx(Wo,{className:"text-ifrcRed"}),g.jsx("p",{className:V.loadingText,children:"Submitting..."})]}),g.jsxs("div",{className:`${V.topRow} ${hn?V.ratingHidden:""}`,children:[g.jsx("div",{className:V.imageSection,children:g.jsx(Fg,{files:N,imageUrl:Kt,preview:m,onViewFullSize:k=>{Yn(k||null),ei(!0)},currentImageIndex:pr,onGoToPrevious:_s,onGoToNext:Es,onGoToImage:ua,showCarousel:!0})}),!hn&&g.jsx("div",{className:V.metadataSectionCard,children:g.jsx(Kj,{isPerformanceConfirmed:hn,scores:rn,onScoreChange:(k,Pe)=>Mi(Ne=>({...Ne,[k]:Pe})),onConfirmRatings:()=>Pr(!0),onEditRatings:()=>Pr(!1)})})]}),g.jsx("div",{className:V.metadataSectionCard,children:g.jsx(Yj,{description:kr,analysis:Tr,recommendedActions:jr,onDescriptionChange:k=>Nr(k||""),onAnalysisChange:k=>$n(k||""),onRecommendedActionsChange:k=>fn(k||""),onBack:()=>Ai("2a"),onDelete:Ts,onSubmit:Ns,onEditRatings:()=>Pr(!1),isPerformanceConfirmed:hn,isSubmitting:p})})]})]})}),i===3&&g.jsxs("div",{className:V.successContainer,children:[g.jsx(ro,{level:2,className:V.successHeading,children:"Saved!"}),g.jsx("p",{className:V.successText,children:e.get("contribute")==="true"?"Your contribution has been successfully saved.":"Your caption has been successfully saved."}),g.jsx("div",{className:V.successButton,children:g.jsx(Ue,{name:"upload-another",onClick:()=>{oi()},children:"Upload Another"})})]}),g.jsx(Xj,{isOpen:Li,imageUrl:Kt,preview:m,selectedImageData:Di,onClose:()=>{ei(!1),Yn(null)}}),g.jsx(Jj,{isOpen:Mr,onClose:()=>j(!1)}),g.jsx(eP,{isOpen:R,onConfirm:Bi,onCancel:()=>z(!1)}),g.jsx(tP,{isOpen:X,onConfirm:vo,onCancel:()=>le(!1)}),g.jsx(nP,{isOpen:ye,fallbackInfo:ge,onClose:()=>we(!1)}),g.jsx(rP,{isOpen:Fe,preprocessingInfo:Pt,onClose:()=>ze(!1)}),g.jsx(iP,{isOpen:Ge,preprocessingFile:Pn,isPreprocessing:Mn,preprocessingProgress:Oi,onConfirm:ku,onCancel:Nu}),g.jsx(oP,{isOpen:zn,unsupportedFile:ti,onClose:()=>mn(!1)}),g.jsx(aP,{isOpen:nt,oversizedFile:Lr,onClose:()=>_t(!1),onCancel:()=>_t(!1)})]})}const sP="_helpContainer_1wavj_1",lP="_helpSection_1wavj_13",uP="_sectionHeader_1wavj_49",cP="_sectionTitle_1wavj_91",dP="_sectionContent_1wavj_105",fP="_guidelinesList_1wavj_119",hP="_buttonContainer_1wavj_181",dt={helpContainer:sP,helpSection:lP,sectionHeader:uP,sectionTitle:cP,sectionContent:dP,guidelinesList:fP,buttonContainer:hP};function pP(){const e=hs(),{setShowReferenceExamples:n}=Zj(),i=()=>{e("/upload")},o=()=>{n(!0),e("/explore")},s=()=>{e("/analytics?view=crisis_maps")};return g.jsx(Qf,{className:"py-10",children:g.jsx("div",{className:dt.helpContainer,children:g.jsxs("div",{className:"space-y-8",children:[g.jsxs("div",{className:dt.helpSection,children:[g.jsx("div",{className:dt.sectionHeader,children:g.jsx(ro,{level:3,className:dt.sectionTitle,children:"Introduction"})}),g.jsx("div",{className:dt.sectionContent,children:"In collaboration with the IFRC, PromptAid Vision is a tool that generates textual descriptions of crisis maps/crisis drone images utiliing Visual language models. This prototype is for collecting data for the fine-tuning of our own models. We aim to utilize AI tools to support national societies with rapid decision making during emergencies."}),g.jsx("div",{className:dt.buttonContainer,children:g.jsx(Ue,{name:"upload-now",variant:"secondary",onClick:i,children:"Upload now →"})})]}),g.jsxs("div",{className:dt.helpSection,children:[g.jsx("div",{className:dt.sectionHeader,children:g.jsx(ro,{level:3,className:dt.sectionTitle,children:"Guidelines"})}),g.jsxs("div",{className:dt.sectionContent,children:["To make the process smoother, please follow the guidelines below:",g.jsxs("ul",{className:dt.guidelinesList,children:[g.jsx("li",{children:"Avoid uploading images that are not crisis maps/crisis drone images."}),g.jsx("li",{children:"Confirm the image details prior to modifying the description."}),g.jsx("li",{children:"Before the modification, please read the description generated and provide a rating via the rating sliders."}),g.jsx("li",{children:'Click the "Submit" button to save the description.'})]})]}),g.jsx("div",{className:dt.buttonContainer,children:g.jsx(Ue,{name:"see-examples",variant:"secondary",onClick:o,children:"See examples →"})})]}),g.jsxs("div",{className:dt.helpSection,children:[g.jsx("div",{className:dt.sectionHeader,children:g.jsx(ro,{level:3,className:dt.sectionTitle,children:"VLMs"})}),g.jsx("div",{className:dt.sectionContent,children:"PromptAid Vision uses a variety of Visual Language Models (VLMs). A random VLM is selected for each upload. Therefore feel free to delete and reupload. You can view performance details here:"}),g.jsx("div",{className:dt.buttonContainer,children:g.jsx(Ue,{name:"view-vlm-details",variant:"secondary",onClick:s,children:"View VLM details →"})})]}),g.jsxs("div",{className:dt.helpSection,children:[g.jsx("div",{className:dt.sectionHeader,children:g.jsx(ro,{level:3,className:dt.sectionTitle,children:"Dataset"})}),g.jsx("div",{className:dt.sectionContent,children:"All users are able to export the dataset. You could apply filters when exporting, and it have the option to organize based on model fine-tuning formats."}),g.jsx("div",{className:dt.buttonContainer,children:g.jsx(Ue,{name:"export-dataset",variant:"secondary",onClick:()=>{n(!1),e("/explore"),setTimeout(()=>{const u=document.querySelector('[name="export-dataset"]');u&&u.click()},100)},children:"Export dataset →"})})]}),g.jsxs("div",{className:dt.helpSection,children:[g.jsx("div",{className:dt.sectionHeader,children:g.jsx(ro,{level:3,className:dt.sectionTitle,children:"Contact us"})}),g.jsx("div",{className:dt.sectionContent,children:"Need help or have questions about PromptAid Vision? Our team is here to support you."}),g.jsx("div",{className:dt.buttonContainer,children:g.jsx(Ue,{name:"contact-support",variant:"secondary",disabled:!0,children:"Get in touch →"})})]})]})})})}const mP=v.createContext(void 0),gP=({children:e})=>{const[n,i]=v.useState(!1),[o,s]=v.useState(!0),u=async()=>{const y=localStorage.getItem("adminToken");if(!y){i(!1),s(!1);return}try{(await fetch("/api/admin/verify",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`}})).ok?i(!0):(localStorage.removeItem("adminToken"),i(!1))}catch(w){console.error("Error verifying admin token:",w),localStorage.removeItem("adminToken"),i(!1)}finally{s(!1)}},d=async y=>{try{const w=await fetch("/api/admin/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:y})});if(w.ok){const C=await w.json();return localStorage.setItem("adminToken",C.access_token),i(!0),!0}else return!1}catch(w){return console.error("Login error:",w),!1}},f=()=>{localStorage.removeItem("adminToken"),i(!1)};v.useEffect(()=>{u()},[]);const p={isAuthenticated:n,isLoading:o,login:d,logout:f,verifyToken:u};return g.jsx(mP.Provider,{value:p,children:e})},vP=v.lazy(()=>Qn(()=>import("./index-a9YqPexW.js"),__vite__mapDeps([0,1]))),yP=v.lazy(()=>Qn(()=>import("./index-RsSGWjBF.js"),__vite__mapDeps([2,3,4,5,6]))),wP=v.lazy(()=>Qn(()=>import("./AdminPage-Ddcg9yuB.js"),__vite__mapDeps([7,3,8]))),xP=v.lazy(()=>Qn(()=>import("./index-L-TN6RFj.js"),__vite__mapDeps([9,3,4,5,10])));class CP extends v.Component{constructor(n){super(n),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n,i){console.error("Error caught by boundary:",n,i)}render(){return this.state.hasError?g.jsxs("div",{style:{padding:"20px",textAlign:"center"},children:[g.jsx("h2",{children:"Something went wrong"}),g.jsx("p",{children:"Please refresh the page to try again."}),g.jsx("button",{onClick:()=>window.location.reload(),children:"Refresh Page"})]}):this.props.children}}const bi=e=>{const n=e();return n.catch(()=>{}),n},SP=()=>{"requestIdleCallback"in window?requestIdleCallback(()=>{bi(()=>Qn(()=>import("./index-a9YqPexW.js"),__vite__mapDeps([0,1]))),bi(()=>Qn(()=>import("./index-RsSGWjBF.js"),__vite__mapDeps([2,3,4,5,6]))),bi(()=>Qn(()=>import("./AdminPage-Ddcg9yuB.js"),__vite__mapDeps([7,3,8]))),bi(()=>Qn(()=>import("./index-L-TN6RFj.js"),__vite__mapDeps([9,3,4,5,10])))}):setTimeout(()=>{bi(()=>Qn(()=>import("./index-a9YqPexW.js"),__vite__mapDeps([0,1]))),bi(()=>Qn(()=>import("./index-RsSGWjBF.js"),__vite__mapDeps([2,3,4,5,6]))),bi(()=>Qn(()=>import("./AdminPage-Ddcg9yuB.js"),__vite__mapDeps([7,3,8]))),bi(()=>Qn(()=>import("./index-L-TN6RFj.js"),__vite__mapDeps([9,3,4,5,10])))},1e3)},bP=vx([{element:g.jsx(LT,{}),children:[{path:"/",element:g.jsx($g,{})},{path:"/upload",element:g.jsx($g,{})},{path:"/analytics",element:g.jsx(v.Suspense,{fallback:g.jsx("div",{children:"Loading Analytics..."}),children:g.jsx(vP,{})})},{path:"/explore",element:g.jsx(v.Suspense,{fallback:g.jsx("div",{children:"Loading Explore..."}),children:g.jsx(yP,{})})},{path:"/help",element:g.jsx(pP,{})},{path:"/admin",element:g.jsx(v.Suspense,{fallback:g.jsx("div",{children:"Loading Admin..."}),children:g.jsx(wP,{})})},{path:"/map/:mapId",element:g.jsx(v.Suspense,{fallback:g.jsx("div",{children:"Loading Map Details..."}),children:g.jsx(xP,{})})}]}],{basename:"/"});function _P(){const[e,n]=v.useState([]);v.useEffect(()=>{SP()},[]);const i=v.useCallback(f=>{n(p=>Bx([...p,f],y=>y.name)??p)},[n]),o=v.useCallback(f=>{n(p=>{const y=p.findIndex(C=>C.name===f);if(y===-1)return p;const w=[...p];return w.splice(y,1),w})},[n]),s=v.useCallback((f,p)=>{n(y=>{const w=y.findIndex(m=>m.name===f);if(w===-1)return y;const C=[...y];return C[w]={...C[w],...p},C})},[n]),u=v.useMemo(()=>({alerts:e,addAlert:i,removeAlert:o,updateAlert:s}),[e,i,o,s]),d=v.useMemo(()=>({languageNamespaceStatus:{},setLanguageNamespaceStatus:()=>{},currentLanguage:"en",setCurrentLanguage:()=>{},strings:{},setStrings:()=>{},registerNamespace:()=>{}}),[]);return g.jsx(CP,{children:g.jsx(Fx.Provider,{value:u,children:g.jsx(o0.Provider,{value:d,children:g.jsx(gP,{children:g.jsx(Gj,{children:g.jsx(kx,{router:bP})})})})})})}function EP(){return g.jsx(_P,{})}console.log("React version at runtime:",v.version,"createContext exists?",!!v.createContext);V1.createRoot(document.getElementById("root")).render(g.jsx(v.StrictMode,{children:g.jsx(EP,{})}));export{_C as A,ra as B,TP as C,Zj as D,MP as E,df as F,Qn as G,ro as H,V as I,eo as J,NP as K,_T as L,Xj as M,Qf as N,jt as O,jC as P,DP as Q,c0 as R,TC as S,d0 as T,LP as U,Lg as V,mP as W,kP as X,Bg as Y,Wo as _,$e as a,Lt as b,IP as c,AP as d,jP as e,SC as f,l0 as g,RP as h,OP as i,g as j,fr as k,qx as l,FE as m,Ue as n,Oe as o,Zx as p,Ka as q,v as r,u0 as s,o0 as t,Dx as u,PC as v,MC as w,hs as x,PP as y,dr as z}; +Recommended Actions: ${jr}`,Ne={title:U,edited:Pe,accuracy:rn.accuracy,context:rn.context,usability:rn.usability};console.log("Updating caption:",Ne);const ke=await fetch(`/api/images/${lt}/caption`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ne)}),pe=await $i(ke);if(!ke.ok)throw new Error(pe.error||"Caption update failed");Dt(null),pt([]),Ai(3)}catch(k){go(k,"Submit")}finally{y(!1)}}async function Ts(){if(console.log("handleDelete called with uploadedImageId:",lt),!lt){alert("No image to delete. Please try refreshing the page.");return}z(!0)}async function Bi(){try{console.log("Deleting image with ID:",lt);const k=await fetch(`/api/images/${lt}`,{method:"DELETE"});if(!k.ok){const Pe=await $i(k);throw new Error(Pe.error||`Delete failed with status ${k.status}`)}z(!1),oi()}catch(k){go(k,"Delete")}}const oi=()=>{Pr(!1),o(1),b(null),P([]),x(null),Dt(null),pt([]),dn(null),W(""),$(""),Z(""),O(""),I([]),he(""),_e(""),ue(""),H(""),Se(""),re(""),Q(""),et(""),Wt(!1),bt(""),wt(""),Mi({accuracy:50,context:50,usability:50}),Pi(""),Nr(""),$n(""),fn(""),ht([]),we(!1),ve(null),ze(!1),Ye(null),Xe(!1),pn(null),Ve(!1),At(""),mn(!1),He(null),_t(!1),Ze(null),n("/upload",{replace:!0})},tr=v.useCallback(k=>{k==="/upload"||k==="/"||(C.current?(Me(k),le(!0)):n(k))},[n]);async function vo(){if(Ee&&C.current)try{await fetch(`/api/images/${C.current}`,{method:"DELETE"}),le(!1),Me(null),n(Ee)}catch(k){console.error("Failed to delete image before navigation:",k),le(!1),Me(null),n(Ee)}}const ku=async()=>{if(Pn){Ve(!0),At("Starting file conversion...");try{const k=new FormData;k.append("file",Pn),k.append("preprocess_only","true"),At("Converting file format...");const Pe=await fetch("/api/images/preprocess",{method:"POST",body:k});if(!Pe.ok)throw new Error("Preprocessing failed");const Ne=await Pe.json();At("Finalizing conversion...");const ke=atob(Ne.processed_content),pe=new Uint8Array(ke.length);for(let Nt=0;Nt[...Nt,Re]),x(Ot),At("Conversion complete!"),setTimeout(()=>{Xe(!1),pn(null),Ve(!1),At("")},1e3)}catch(k){console.error("Preprocessing error:",k),At("Conversion failed. Please try again."),setTimeout(()=>{Xe(!1),pn(null),Ve(!1),At("")},2e3)}}},Nu=()=>{Xe(!1),pn(null),Ve(!1),At("")},ca=async k=>{f(!0);try{const Pe=k.map(async Re=>{const Ot=await fetch(`/api/images/${Re}`);if(!Ot.ok)throw new Error(`Failed to fetch image ${Re}`);const Nt=await Ot.json(),Bn=await fetch(`/api/images/${Re}/file`);if(!Bn.ok)throw new Error(`Failed to fetch image file ${Re}`);const Un=await Bn.blob(),gt=Nt.file_key.split("/").pop()||`contributed_${Re}.png`;return{file:new File([Un],gt,{type:Un.type}),imageData:Nt}}),Ne=await Promise.all(Pe),ke=Ne.map(Re=>Re.file),pe=Ne[0]?.imageData;P(ke),pt(k),k.length===1&&Dt(k[0]),ke.length>=1&&b(ke[0]),pe?.image_type&&ce(pe.image_type)}catch(Pe){console.error("Failed to fetch contributed images:",Pe),alert(`Failed to load contributed images: ${Pe instanceof Error?Pe.message:"Unknown error"}`)}finally{f(!1)}};return v.useEffect(()=>{Promise.all([fetch("/api/sources").then(k=>k.json()),fetch("/api/types").then(k=>k.json()),fetch("/api/spatial-references").then(k=>k.json()),fetch("/api/image-types").then(k=>k.json()),fetch("/api/countries").then(k=>k.json()),fetch("/api/models").then(k=>k.json())]).then(([k,Pe,Ne,ke,pe,Re])=>{!localStorage.getItem(Bl)&&Re?.length&&localStorage.setItem(Bl,Re[0].m_code),nn(k),ln(Pe),Jr(Ne),cn(ke),Kn(pe),k.length>0&&$(k[0].s_code),Z("OTHER"),O("OTHER"),ke.length>0&&!e.get("imageType")&&!K&&ce(ke[0].image_type)})},[e,K]),v.useEffect(()=>(window.confirmNavigationIfNeeded=k=>{tr(k)},()=>{delete window.confirmNavigationIfNeeded}),[tr]),v.useEffect(()=>{const k=ke=>{if(C.current){const pe="You have an uploaded image that will be deleted if you leave this page. Are you sure you want to leave?";return ke.preventDefault(),ke.returnValue=pe,pe}},Pe=()=>{C.current&&fetch(`/api/images/${C.current}`,{method:"DELETE"}).catch(console.error)},Ne=ke=>{const pe=ke.target,Re=pe.closest("a[href]")||pe.closest("[data-navigate]");if(Re&&C.current){const Ot=Re.getAttribute("href")||Re.getAttribute("data-navigate");Ot&&Ot!=="#"&&!Ot.startsWith("javascript:")&&!Ot.startsWith("mailto:")&&(ke.preventDefault(),ke.stopPropagation(),tr(Ot))}};return window.addEventListener("beforeunload",k),document.addEventListener("click",Ne,!0),()=>{window.removeEventListener("beforeunload",k),document.removeEventListener("click",Ne,!0),Pe()}},[tr]),v.useEffect(()=>{if(!E){x(null);return}const k=URL.createObjectURL(E);return x(k),()=>URL.revokeObjectURL(k)},[E]),v.useEffect(()=>{const k=e.get("contribute"),Pe=e.get("imageIds");if(k==="true"&&Pe){const Ne=Pe.split(",").filter(ke=>ke.trim());Ne.length>0&&ca(Ne)}},[e]),v.useEffect(()=>{i==="2b"&&Dr(0)},[i]),g.jsxs(Qf,{children:[i!==3&&g.jsx("div",{className:"max-w-7xl mx-auto",children:g.jsxs("div",{className:V.uploadContainer,"data-step":i,children:[i===1&&!e.get("step")&&!d&&g.jsx(Ag,{files:N,file:E,preview:m,imageType:K,onFileChange:Rr,onRemoveImage:Xn,onAddImage:Fi,onImageTypeChange:ni,onChangeFile:er}),i===1&&e.get("contribute")==="true"&&!d&&N.length>0&&g.jsx(Ag,{files:N,file:E,preview:m,imageType:K,onFileChange:Rr,onRemoveImage:Xn,onAddImage:Fi,onImageTypeChange:ni,onChangeFile:er}),s&&g.jsxs("div",{className:V.loadingContainer,children:[g.jsx(Wo,{className:"text-ifrcRed"}),g.jsx("p",{className:V.loadingText,children:"Generating..."})]}),d&&g.jsxs("div",{className:V.loadingContainer,children:[g.jsx(Wo,{className:"text-ifrcRed"}),g.jsx("p",{className:V.loadingText,children:"Loading contribution..."})]}),(i===1&&!s&&!d||i===1&&e.get("contribute")==="true"&&!s&&!d&&N.length>0)&&g.jsx("div",{className:V.generateButtonContainer,children:Kt?g.jsx(Ue,{name:"generate-from-url",onClick:ii,children:"Generate Caption"}):g.jsx(Ue,{name:"generate",disabled:N.length===0,onClick:ii,children:"Generate"})}),i==="2a"&&g.jsxs("div",{className:V.step2Layout,children:[g.jsx("div",{className:V.mapColumn,children:g.jsx(Fg,{files:N,imageUrl:Kt,preview:m,onViewFullSize:k=>{Yn(k||null),ei(!0)}})}),g.jsx("div",{className:V.contentColumn,children:g.jsxs("div",{className:V.metadataSectionCard,children:[g.jsx(Qj,{files:N,imageType:K,title:U,source:L,eventType:q,epsg:fe,countries:de,centerLon:ne,centerLat:Ce,amslM:G,aglM:T,headingDeg:oe,yawDeg:se,pitchDeg:ee,rollDeg:Y,rtkFix:tn,stdHM:ot,stdVM:st,metadataArray:ft,sources:xt,types:Tn,spatialReferences:jn,imageTypes:un,countriesOptions:Er,onTitleChange:k=>W(k||""),onSourceChange:po,onEventTypeChange:mo,onEpsgChange:Ri,onCountriesChange:Su,onCenterLonChange:bu,onCenterLatChange:oa,onAmslMChange:Cs,onAglMChange:aa,onHeadingDegChange:Ii,onYawDegChange:_u,onPitchDegChange:sa,onRollDegChange:tt,onRtkFixChange:Ss,onStdHMChange:bs,onStdVMChange:la,onImageTypeChange:ni,updateMetadataForImage:mr}),g.jsxs("div",{className:V.confirmSection,children:[g.jsx(hf,{name:"delete",variant:"tertiary",onClick:Ts,title:"Delete",ariaLabel:"Delete uploaded image",children:g.jsx(df,{})}),g.jsx(Ue,{name:"confirm-metadata",onClick:()=>Ai("2b"),children:"Next"})]})]})})]}),i==="2b"&&g.jsxs("div",{className:V.step2bLayout,children:[p&&g.jsxs("div",{className:V.loadingContainer,children:[g.jsx(Wo,{className:"text-ifrcRed"}),g.jsx("p",{className:V.loadingText,children:"Submitting..."})]}),g.jsxs("div",{className:`${V.topRow} ${hn?V.ratingHidden:""}`,children:[g.jsx("div",{className:V.imageSection,children:g.jsx(Fg,{files:N,imageUrl:Kt,preview:m,onViewFullSize:k=>{Yn(k||null),ei(!0)},currentImageIndex:pr,onGoToPrevious:_s,onGoToNext:Es,onGoToImage:ua,showCarousel:!0})}),!hn&&g.jsx("div",{className:V.metadataSectionCard,children:g.jsx(Kj,{isPerformanceConfirmed:hn,scores:rn,onScoreChange:(k,Pe)=>Mi(Ne=>({...Ne,[k]:Pe})),onConfirmRatings:()=>Pr(!0),onEditRatings:()=>Pr(!1)})})]}),g.jsx("div",{className:V.metadataSectionCard,children:g.jsx(Yj,{description:kr,analysis:Tr,recommendedActions:jr,onDescriptionChange:k=>Nr(k||""),onAnalysisChange:k=>$n(k||""),onRecommendedActionsChange:k=>fn(k||""),onBack:()=>Ai("2a"),onDelete:Ts,onSubmit:Ns,onEditRatings:()=>Pr(!1),isPerformanceConfirmed:hn,isSubmitting:p})})]})]})}),i===3&&g.jsxs("div",{className:V.successContainer,children:[g.jsx(ro,{level:2,className:V.successHeading,children:"Saved!"}),g.jsx("p",{className:V.successText,children:e.get("contribute")==="true"?"Your contribution has been successfully saved.":"Your caption has been successfully saved."}),g.jsx("div",{className:V.successButton,children:g.jsx(Ue,{name:"upload-another",onClick:()=>{oi()},children:"Upload Another"})})]}),g.jsx(Xj,{isOpen:Li,imageUrl:Kt,preview:m,selectedImageData:Di,onClose:()=>{ei(!1),Yn(null)}}),g.jsx(Jj,{isOpen:Mr,onClose:()=>j(!1)}),g.jsx(eP,{isOpen:R,onConfirm:Bi,onCancel:()=>z(!1)}),g.jsx(tP,{isOpen:X,onConfirm:vo,onCancel:()=>le(!1)}),g.jsx(nP,{isOpen:ye,fallbackInfo:ge,onClose:()=>we(!1)}),g.jsx(rP,{isOpen:Fe,preprocessingInfo:Pt,onClose:()=>ze(!1)}),g.jsx(iP,{isOpen:Ge,preprocessingFile:Pn,isPreprocessing:Mn,preprocessingProgress:Oi,onConfirm:ku,onCancel:Nu}),g.jsx(oP,{isOpen:zn,unsupportedFile:ti,onClose:()=>mn(!1)}),g.jsx(aP,{isOpen:nt,oversizedFile:Lr,onClose:()=>_t(!1),onCancel:()=>_t(!1)})]})}const sP="_helpContainer_1wavj_1",lP="_helpSection_1wavj_13",uP="_sectionHeader_1wavj_49",cP="_sectionTitle_1wavj_91",dP="_sectionContent_1wavj_105",fP="_guidelinesList_1wavj_119",hP="_buttonContainer_1wavj_181",dt={helpContainer:sP,helpSection:lP,sectionHeader:uP,sectionTitle:cP,sectionContent:dP,guidelinesList:fP,buttonContainer:hP};function pP(){const e=hs(),{setShowReferenceExamples:n}=Zj(),i=()=>{e("/upload")},o=()=>{n(!0),e("/explore")},s=()=>{e("/analytics?view=crisis_maps")};return g.jsx(Qf,{className:"py-10",children:g.jsx("div",{className:dt.helpContainer,children:g.jsxs("div",{className:"space-y-8",children:[g.jsxs("div",{className:dt.helpSection,children:[g.jsx("div",{className:dt.sectionHeader,children:g.jsx(ro,{level:3,className:dt.sectionTitle,children:"Introduction"})}),g.jsx("div",{className:dt.sectionContent,children:"In collaboration with the IFRC, PromptAid Vision is a tool that generates textual descriptions of crisis maps/crisis drone images utiliing Visual language models. This prototype is for collecting data for the fine-tuning of our own models. We aim to utilize AI tools to support national societies with rapid decision making during emergencies."}),g.jsx("div",{className:dt.buttonContainer,children:g.jsx(Ue,{name:"upload-now",variant:"secondary",onClick:i,children:"Upload now →"})})]}),g.jsxs("div",{className:dt.helpSection,children:[g.jsx("div",{className:dt.sectionHeader,children:g.jsx(ro,{level:3,className:dt.sectionTitle,children:"Guidelines"})}),g.jsxs("div",{className:dt.sectionContent,children:["To make the process smoother, please follow the guidelines below:",g.jsxs("ul",{className:dt.guidelinesList,children:[g.jsx("li",{children:"Avoid uploading images that are not crisis maps/crisis drone images."}),g.jsx("li",{children:"Confirm the image details prior to modifying the description."}),g.jsx("li",{children:"Before the modification, please read the description generated and provide a rating via the rating sliders."}),g.jsx("li",{children:'Click the "Submit" button to save the description.'})]})]}),g.jsx("div",{className:dt.buttonContainer,children:g.jsx(Ue,{name:"see-examples",variant:"secondary",onClick:o,children:"See examples →"})})]}),g.jsxs("div",{className:dt.helpSection,children:[g.jsx("div",{className:dt.sectionHeader,children:g.jsx(ro,{level:3,className:dt.sectionTitle,children:"VLMs"})}),g.jsx("div",{className:dt.sectionContent,children:"PromptAid Vision uses a variety of Visual Language Models (VLMs). A random VLM is selected for each upload. Therefore feel free to delete and reupload. You can view performance details here:"}),g.jsx("div",{className:dt.buttonContainer,children:g.jsx(Ue,{name:"view-vlm-details",variant:"secondary",onClick:s,children:"View VLM details →"})})]}),g.jsxs("div",{className:dt.helpSection,children:[g.jsx("div",{className:dt.sectionHeader,children:g.jsx(ro,{level:3,className:dt.sectionTitle,children:"Dataset"})}),g.jsx("div",{className:dt.sectionContent,children:"All users are able to export the dataset. You could apply filters when exporting, and it have the option to organize based on model fine-tuning formats."}),g.jsx("div",{className:dt.buttonContainer,children:g.jsx(Ue,{name:"export-dataset",variant:"secondary",onClick:()=>{n(!1),e("/explore"),setTimeout(()=>{const u=document.querySelector('[name="export-dataset"]');u&&u.click()},100)},children:"Export dataset →"})})]}),g.jsxs("div",{className:dt.helpSection,children:[g.jsx("div",{className:dt.sectionHeader,children:g.jsx(ro,{level:3,className:dt.sectionTitle,children:"Contact us"})}),g.jsx("div",{className:dt.sectionContent,children:"Need help or have questions about PromptAid Vision? Our team is here to support you."}),g.jsx("div",{className:dt.buttonContainer,children:g.jsx(Ue,{name:"contact-support",variant:"secondary",disabled:!0,children:"Get in touch →"})})]})]})})})}const mP=v.createContext(void 0),gP=({children:e})=>{const[n,i]=v.useState(!1),[o,s]=v.useState(!0),u=async()=>{const y=localStorage.getItem("adminToken");if(!y){i(!1),s(!1);return}try{(await fetch("/api/admin/verify",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`}})).ok?i(!0):(localStorage.removeItem("adminToken"),i(!1))}catch(w){console.error("Error verifying admin token:",w),localStorage.removeItem("adminToken"),i(!1)}finally{s(!1)}},d=async y=>{try{const w=await fetch("/api/admin/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:y})});if(w.ok){const C=await w.json();return localStorage.setItem("adminToken",C.access_token),i(!0),!0}else return!1}catch(w){return console.error("Login error:",w),!1}},f=()=>{localStorage.removeItem("adminToken"),i(!1)};v.useEffect(()=>{u()},[]);const p={isAuthenticated:n,isLoading:o,login:d,logout:f,verifyToken:u};return g.jsx(mP.Provider,{value:p,children:e})},vP=v.lazy(()=>Qn(()=>import("./index-C4_t-iUv.js"),__vite__mapDeps([0,1]))),yP=v.lazy(()=>Qn(()=>import("./index-CWQiqOU3.js"),__vite__mapDeps([2,3,4,5,6]))),wP=v.lazy(()=>Qn(()=>import("./AdminPage-0qyl8wHV.js"),__vite__mapDeps([7,3,8]))),xP=v.lazy(()=>Qn(()=>import("./index-D5zar1LU.js"),__vite__mapDeps([9,3,4,5,10])));class CP extends v.Component{constructor(n){super(n),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n,i){console.error("Error caught by boundary:",n,i)}render(){return this.state.hasError?g.jsxs("div",{style:{padding:"20px",textAlign:"center"},children:[g.jsx("h2",{children:"Something went wrong"}),g.jsx("p",{children:"Please refresh the page to try again."}),g.jsx("button",{onClick:()=>window.location.reload(),children:"Refresh Page"})]}):this.props.children}}const bi=e=>{const n=e();return n.catch(()=>{}),n},SP=()=>{"requestIdleCallback"in window?requestIdleCallback(()=>{bi(()=>Qn(()=>import("./index-C4_t-iUv.js"),__vite__mapDeps([0,1]))),bi(()=>Qn(()=>import("./index-CWQiqOU3.js"),__vite__mapDeps([2,3,4,5,6]))),bi(()=>Qn(()=>import("./AdminPage-0qyl8wHV.js"),__vite__mapDeps([7,3,8]))),bi(()=>Qn(()=>import("./index-D5zar1LU.js"),__vite__mapDeps([9,3,4,5,10])))}):setTimeout(()=>{bi(()=>Qn(()=>import("./index-C4_t-iUv.js"),__vite__mapDeps([0,1]))),bi(()=>Qn(()=>import("./index-CWQiqOU3.js"),__vite__mapDeps([2,3,4,5,6]))),bi(()=>Qn(()=>import("./AdminPage-0qyl8wHV.js"),__vite__mapDeps([7,3,8]))),bi(()=>Qn(()=>import("./index-D5zar1LU.js"),__vite__mapDeps([9,3,4,5,10])))},1e3)},bP=vx([{element:g.jsx(LT,{}),children:[{path:"/",element:g.jsx($g,{})},{path:"/upload",element:g.jsx($g,{})},{path:"/analytics",element:g.jsx(v.Suspense,{fallback:g.jsx("div",{children:"Loading Analytics..."}),children:g.jsx(vP,{})})},{path:"/explore",element:g.jsx(v.Suspense,{fallback:g.jsx("div",{children:"Loading Explore..."}),children:g.jsx(yP,{})})},{path:"/help",element:g.jsx(pP,{})},{path:"/admin",element:g.jsx(v.Suspense,{fallback:g.jsx("div",{children:"Loading Admin..."}),children:g.jsx(wP,{})})},{path:"/map/:mapId",element:g.jsx(v.Suspense,{fallback:g.jsx("div",{children:"Loading Map Details..."}),children:g.jsx(xP,{})})}]}],{basename:"/"});function _P(){const[e,n]=v.useState([]);v.useEffect(()=>{SP()},[]);const i=v.useCallback(f=>{n(p=>Bx([...p,f],y=>y.name)??p)},[n]),o=v.useCallback(f=>{n(p=>{const y=p.findIndex(C=>C.name===f);if(y===-1)return p;const w=[...p];return w.splice(y,1),w})},[n]),s=v.useCallback((f,p)=>{n(y=>{const w=y.findIndex(m=>m.name===f);if(w===-1)return y;const C=[...y];return C[w]={...C[w],...p},C})},[n]),u=v.useMemo(()=>({alerts:e,addAlert:i,removeAlert:o,updateAlert:s}),[e,i,o,s]),d=v.useMemo(()=>({languageNamespaceStatus:{},setLanguageNamespaceStatus:()=>{},currentLanguage:"en",setCurrentLanguage:()=>{},strings:{},setStrings:()=>{},registerNamespace:()=>{}}),[]);return g.jsx(CP,{children:g.jsx(Fx.Provider,{value:u,children:g.jsx(o0.Provider,{value:d,children:g.jsx(gP,{children:g.jsx(Gj,{children:g.jsx(kx,{router:bP})})})})})})}function EP(){return g.jsx(_P,{})}console.log("React version at runtime:",v.version,"createContext exists?",!!v.createContext);V1.createRoot(document.getElementById("root")).render(g.jsx(v.StrictMode,{children:g.jsx(EP,{})}));export{_C as A,ra as B,TP as C,Zj as D,MP as E,df as F,Qn as G,ro as H,V as I,eo as J,NP as K,_T as L,Xj as M,Qf as N,jt as O,jC as P,DP as Q,c0 as R,TC as S,d0 as T,LP as U,Lg as V,mP as W,kP as X,Bg as Y,Wo as _,$e as a,Lt as b,IP as c,AP as d,jP as e,SC as f,l0 as g,RP as h,OP as i,g as j,fr as k,qx as l,FE as m,Ue as n,Oe as o,Zx as p,Ka as q,v as r,u0 as s,o0 as t,Dx as u,PC as v,MC as w,hs as x,PP as y,dr as z}; diff --git a/py_backend/static/assets/index-a9YqPexW.js b/py_backend/static/assets/index-C4_t-iUv.js similarity index 99% rename from py_backend/static/assets/index-a9YqPexW.js rename to py_backend/static/assets/index-C4_t-iUv.js index cdbf2625c2f689cbe0fe8d8d5d4107bcf274aa8f..7af01b4c3ebaf7935a35d204bab227180121a14d 100644 --- a/py_backend/static/assets/index-a9YqPexW.js +++ b/py_backend/static/assets/index-C4_t-iUv.js @@ -1 +1 @@ -import{r as s,y as nt,t as ht,a as q,c as gt,j as e,o as N,b as re,R as st,z,g as rt,d as ft,m as vt,e as pt,n as Z,A as xt,f as _t,h as Ct,i as yt,k as he,l as bt,p as ye,q as jt,s as Nt,E as wt,C as St,U as Mt,Q as It,u as Dt,N as je,_ as Et,L as Tt}from"./index-DieRAFRn.js";const kt=({title:m,titleId:a,...h})=>s.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?s.createElement("title",{id:a},m):null,s.createElement("g",{clipPath:"url(#arrow-drop-down-line_svg__a)"},s.createElement("path",{d:"m12 15-4.243-4.243 1.415-1.414L12 12.172l2.828-2.83 1.415 1.415L12 15Z"})),s.createElement("defs",null,s.createElement("clipPath",{id:"arrow-drop-down-line_svg__a"},s.createElement("path",{d:"M0 0h24v24H0z"})))),Lt=({title:m,titleId:a,...h})=>s.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?s.createElement("title",{id:a},m):null,s.createElement("g",{clipPath:"url(#arrow-drop-up-line_svg__a)"},s.createElement("path",{d:"m12 11.828-2.828 2.829-1.415-1.414L12 9l4.243 4.243-1.415 1.414L12 11.828Z"})),s.createElement("defs",null,s.createElement("clipPath",{id:"arrow-drop-up-line_svg__a"},s.createElement("path",{d:"M0 0h24v24H0z"})))),Pt=({title:m,titleId:a,...h})=>s.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?s.createElement("title",{id:a},m):null,s.createElement("g",{clipPath:"url(#information-line_svg__a)"},s.createElement("path",{d:"M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10Zm0-2a8 8 0 1 0 0-16.001A8 8 0 0 0 12 20ZM11 7h2v2h-2V7Zm0 4h2v6h-2v-6Z"})),s.createElement("defs",null,s.createElement("clipPath",{id:"information-line_svg__a"},s.createElement("path",{d:"M0 0h24v24H0z"})))),Rt=({title:m,titleId:a,...h})=>s.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?s.createElement("title",{id:a},m):null,s.createElement("path",{fillRule:"evenodd",d:"m15.063 12 .937.938-4 4-4-4L8.938 12 12 15.063 15.063 12Z",clipRule:"evenodd"}),s.createElement("mask",{id:"table-sorting-line_svg__a",width:8,height:5,x:8,y:12,maskUnits:"userSpaceOnUse",style:{maskType:"luminance"}},s.createElement("path",{fillRule:"evenodd",d:"m15.063 12 .937.938-4 4-4-4L8.938 12 12 15.063 15.063 12Z",clipRule:"evenodd"})),s.createElement("g",{mask:"url(#table-sorting-line_svg__a)"},s.createElement("path",{d:"M-24-22h72v72h-72z"})),s.createElement("path",{fillRule:"evenodd",d:"M8.938 11 8 10.062l4-4 4 4-.938.938L12 7.937 8.937 11Z",clipRule:"evenodd"}),s.createElement("mask",{id:"table-sorting-line_svg__b",width:8,height:5,x:8,y:6,maskUnits:"userSpaceOnUse",style:{maskType:"luminance"}},s.createElement("path",{fillRule:"evenodd",d:"M8.938 11 8 10.062l4-4 4 4-.938.938L12 7.937 8.937 11Z",clipRule:"evenodd"})),s.createElement("g",{mask:"url(#table-sorting-line_svg__b)"},s.createElement("path",{d:"M48 45h-72v-72h72z"}))),$t="_number-output_1blvi_1",Bt={numberOutput:$t};function we(m){const{className:a,invalidText:h=nt,separatorHidden:r,compact:f,currency:g,value:b,tooltip:_,unit:y,prefix:x,suffix:w,maximumFractionDigits:C=1}=m,{currentLanguage:j}=s.useContext(ht),v=s.useMemo(()=>{if(q(b))return h;const S=gt(b,{currency:g,compact:f,separatorHidden:r,maximumFractionDigits:C,unit:y,language:j});return e.jsxs(e.Fragment,{children:[x,S,w]})},[h,b,f,r,g,y,C,x,j,w]);return e.jsx("div",{className:N(Bt.numberOutput,a),title:re(_)?String(_):void 0,children:v})}const At="_tooltip-dummy_rbf3f_1",Ft="_tooltip-content_rbf3f_7",Ot="_pointer_rbf3f_14",Ne={tooltipDummy:At,tooltipContent:Ft,pointer:Ot};function Ht(m){const{className:a,title:h,description:r,preferredWidth:f}=m,[g,b]=s.useState(!1),[_,y]=s.useState(!1),x=s.useRef(),w=s.useRef(null);return s.useEffect(()=>{const C=()=>{y(!0)},j=()=>{y(!1)};if(q(w.current))return;const{current:{parentNode:v}}=w;if(!q(v))return x.current=v,v.addEventListener("mouseover",C),v.addEventListener("mouseout",j),b(!0),()=>{v.removeEventListener("mouseover",C),v.removeEventListener("mouseout",j)}},[]),e.jsxs(e.Fragment,{children:[!g&&e.jsx("div",{className:Ne.tooltipDummy,ref:w}),_&&e.jsx(st,{className:N(Ne.tooltipContent,a),parentRef:x,pointerClassName:Ne.pointer,preferredWidth:f,children:e.jsx(z,{heading:h,withInternalPadding:!0,contentViewType:"vertical",children:r})})]})}function $(m){return m.id}const Vt="common",zt={booleanYesLabel:"Yes",booleanNoLabel:"No"},Ut={namespace:Vt,strings:zt},Wt="_boolean-output_kg1uq_1",Qt={booleanOutput:Wt};function Zt(m){const{className:a,invalidText:h,value:r}=m,f=rt(Ut);let g;return r===!0?g=f.booleanYesLabel:r===!1?g=f.booleanNoLabel:g=h,e.jsx("div",{className:N(Qt.booleanOutput,a),children:g})}const qt="_date-output_4jzjo_1",Gt={dateOutput:qt};function Yt(m){const{value:a,format:h,className:r,invalidText:f}=m,g=s.useMemo(()=>ft(a,h),[a,h]);return e.jsx("div",{className:N(Gt.dateOutput,r),children:g??f})}const Kt="_dropdown-menu_16hml_1",Xt="_icons_16hml_4",Jt="_content_16hml_5",ea="_actions_16hml_6",ta="_dropdown-icon_16hml_10",aa="_dropdown-content_16hml_16",le={dropdownMenu:Kt,icons:Xt,content:Jt,actions:ea,dropdownIcon:ta,dropdownContent:aa};function na(m){const a=s.useRef(null),{className:h,popupClassName:r,children:f,label:g,activeClassName:b,icons:_,variant:y="secondary",actions:x,withoutDropdownIcon:w,componentRef:C,elementRef:j=a,persistent:v,preferredPopupWidth:S}=m,p=s.useRef(null),[k,I]=s.useState(!1);s.useEffect(()=>{C&&(C.current={setShowDropdown:I})},[C,I]);const R=s.useCallback(()=>{I(ie=>!ie)},[I]),T=s.useCallback((ie,ae)=>{ae||ie&&v||I(!1)},[I,v]);vt(k,T,p,j);const G=s.useMemo(()=>({setShowDropdown:I}),[I]),U=!!x||!w;return e.jsxs(pt.Provider,{value:G,children:[e.jsx(Z,{name:void 0,className:N(le.dropdownMenu,k&&b,h),elementRef:j,onClick:R,variant:y,actionsContainerClassName:le.actions,iconsContainerClassName:le.icons,childrenContainerClassName:le.content,actions:U?e.jsxs(e.Fragment,{children:[x,!w&&(k?e.jsx(xt,{className:le.dropdownIcon}):e.jsx(_t,{className:le.dropdownIcon}))]}):void 0,icons:_,children:g}),k&&e.jsx(st,{elementRef:p,className:N(le.dropdownContent,r),parentRef:j,preferredWidth:S,children:f})]})}const sa="_info-popup_i3rna_1",ra="_label_i3rna_2",ia="_icon_i3rna_7",oa="_dropdown-container_i3rna_15",la="_content_i3rna_20",ge={infoPopup:sa,label:ra,icon:ia,dropdownContainer:oa,content:la};function ca(m){const{className:a,icon:h=e.jsx(Pt,{}),infoLabel:r,title:f,description:g,withoutIcon:b,popupClassName:_,descriptionClassName:y}=m;return e.jsx(na,{label:e.jsxs("div",{className:ge.label,children:[r,!b&&h&&e.jsx("div",{className:ge.icon,children:h})]}),popupClassName:N(ge.dropdownContainer,_),className:N(ge.infoPopup,a),variant:"tertiary",withoutDropdownIcon:!0,children:e.jsx(z,{heading:f,childrenContainerClassName:N(y,ge.content),withInternalPadding:!0,children:g})})}const da="_progress-wrapper_x340w_1",ua="_title_x340w_7",ma="_total_x340w_11",ha="_progress_x340w_1",fe={progressWrapper:da,title:ua,total:ma,progress:ha};function Ye(m){const{className:a,title:h,description:r,totalValue:f,value:g,showPercentageInTitle:b,children:_,color:y="var(--go-ui-color-primary-red)"}=m,x=re(g)?g:0,w=re(f)?f:0;let C;return w===0?C=0:C=x/w*100,e.jsxs("div",{className:N(fe.progressWrapper,a),children:[(h||b)&&e.jsxs("div",{className:fe.title,children:[h,b&&e.jsx(we,{value:C,suffix:"%"})]}),e.jsx("div",{className:fe.total,children:e.jsx("div",{className:fe.progress,style:{width:`${C}%`,backgroundColor:y}})}),r&&e.jsx("div",{className:fe.description,children:r}),_]})}const ga="_legend-element_1a9ic_1",fa="_color_1a9ic_7",va="_icon-container_1a9ic_14",pa="_icon_1a9ic_14",xa="_label_1a9ic_31",ve={legendElement:ga,color:fa,iconContainer:va,icon:pa,label:xa};function _a(m){const{className:a,colorClassName:h,iconClassName:r,color:f,label:g,iconSrc:b}=m;return e.jsxs("div",{className:N(ve.legendElement,a),children:[b?e.jsx("div",{style:{backgroundColor:f},className:ve.iconContainer,children:e.jsx("img",{className:N(ve.icon,r),src:b,alt:""})}):e.jsx("div",{style:{backgroundColor:f},className:N(ve.color,h)}),e.jsx("div",{className:ve.label,children:g})]})}const Ca="_text-output_10oza_1",ya="_with-background_10oza_6",ba="_label_10oza_11",ja="_with-colon_10oza_12",Na="_value_10oza_17",wa="_text-type_10oza_18",Sa="_strong_10oza_24",ee={textOutput:Ca,withBackground:ya,label:ba,withColon:ja,value:Na,textType:wa,strong:Sa};function Ke(m){const{className:a,label:h,icon:r,description:f,labelClassName:g,descriptionClassName:b,valueClassName:_,strongLabel:y,strongValue:x,strongDescription:w,withoutLabelColon:C,withBackground:j,invalidText:v=nt,...S}=m,{value:p}=m;let k=v;return S.valueType==="number"?k=e.jsx(we,{...S,invalidText:v}):S.valueType==="date"?k=e.jsx(Yt,{...S,invalidText:v}):S.valueType==="boolean"?k=e.jsx(Zt,{...S,invalidText:v}):p instanceof Date||(k=p||v),e.jsxs("div",{className:N(ee.textOutput,j&&ee.withBackground,a),children:[r,h&&e.jsx("div",{className:N(ee.label,y&&ee.strong,g,!C&&ee.withColon),children:h}),e.jsx("div",{className:N(ee.value,x&&ee.strong,S.valueType==="text"&&ee.textType,_),children:k}),f&&e.jsx("div",{className:N(ee.description,w&&ee.strong,b),children:f})]})}const Ma="_pie-chart_pyr7m_1",Ia="_legend_pyr7m_7",Da="_legend-item_pyr7m_13",pe={pieChart:Ma,legend:Ia,legendItem:Da},Ea=70,Ta=40;function Xe(m,a=1){return Math.round(m*10**a)/10**a}function Je(m,a){const h=(a-90)*Math.PI/180;return{x:Xe(m+m*Math.cos(h)),y:Xe(m+m*Math.sin(h))}}function ka(m,a,h){let r=h;const f=r-a===360;f&&(r-=1);const g=Je(m,a),b=Je(m,r),_=r-a<=180?0:1,y=["M",g.x,g.y,"A",m,m,0,_,1,b.x,b.y];return f?y.push("Z"):y.push("L",m,m,"L",g.x,g.y,"Z"),y.join(" ")}function xe(m){const{className:a,data:h,valueSelector:r,labelSelector:f,keySelector:g,colorSelector:b,colors:_,pieRadius:y=Ea,chartPadding:x=Ta,legendClassName:w,showPercentageInLegend:C}=m,j=Ct(h?.map(p=>r(p))),v=q(j)||j===0?1:j,S=s.useMemo(()=>{let p=0;const k=h?.map(I=>{const R=r(I);if(q(R))return;const T=360*(R/v);return p+=T,{key:g(I),value:R,label:f(I),startAngle:p-T,percentage:yt(R,v),endAngle:p,datum:I}}).filter(re)??[];return b?k.map(({datum:I,...R})=>({...R,color:b(I)})):k.map(({datum:I,...R},T)=>({...R,color:_[T%_.length]}))},[h,g,r,f,v,b,_]);return e.jsxs("div",{className:N(pe.pieChart,a),children:[e.jsx("svg",{className:pe.svg,style:{width:`${x+y*2}px`,height:`${x+y*2}px`},children:e.jsx("g",{style:{transform:`translate(${x/2}px, ${x/2}px)`},children:S.map(p=>e.jsx("path",{className:pe.path,d:ka(y,p.startAngle,p.endAngle),fill:p.color,children:e.jsx(Ht,{description:e.jsx(Ke,{label:p.label,value:p.value})})},p.key))})}),e.jsx("div",{className:N(pe.legend,w),children:S.map(p=>e.jsx(_a,{className:pe.legendItem,label:C?e.jsx(Ke,{label:p.label,value:p.percentage,valueType:"number",prefix:"(",suffix:"%)",withoutLabelColon:!0}):p.label,color:p.color},p.key))})]})}const La="_td_1k4cn_1",Pa={td:La};function Ra(m){const{className:a,children:h,...r}=m;return e.jsx("td",{className:N(a,Pa.td),...r,children:h})}function it(m){const{className:a,children:h,...r}=m;return e.jsx("tr",{className:a,...r,children:h})}const $a="_row_1829z_1",Ba="_cell_1829z_2",et={row:$a,cell:Ba};function Aa(m){const{data:a,keySelector:h,columns:r,rowClassName:f,cellClassName:g,rowModifier:b}=m;return e.jsx(e.Fragment,{children:a?.map((_,y)=>{const x=h(_,y),w=r.map(v=>{const{id:S,cellRenderer:p,cellRendererClassName:k,cellRendererParams:I,cellContainerClassName:R}=v,T=I(x,_,y,a),G=e.jsx(p,{className:k,...T,name:S});return e.jsx(Ra,{className:N(et.cell,R,typeof g=="function"?g(x,_,S):g),children:G},S)}),C=e.jsx(it,{className:N(et.row,typeof f=="function"?f(x,_):f),children:w});let j=C;return b&&(j=b({rowKey:x,row:C,cells:w,columns:r,datum:_})),e.jsx(s.Fragment,{children:j},x)})})}const Fa="_th_cdv41_1",Oa="_resize-handle_cdv41_8",tt={th:Fa,resizeHandle:Oa};function Ha(m){const{className:a,children:h,onResize:r,onResizeComplete:f,name:g,...b}=m,_=s.useRef(null),y=s.useRef(),x=s.useRef(),w=s.useRef(),C=s.useCallback(v=>{var S;if(re(y.current)&&_.current&&r){v.preventDefault(),v.stopPropagation();const p=v.clientX-y.current;if(re(x.current)){const k=x.current+p;w.current=k,r(k,g)}else x.current=(S=_.current)==null?void 0:S.offsetWidth}},[r,g]),j=s.useCallback(v=>{var S;v.preventDefault(),y.current=v.clientX,x.current=(S=_.current)==null?void 0:S.offsetWidth,window.addEventListener("mousemove",C,!0)},[C]);return s.useEffect(()=>{const v=()=>{y.current=void 0,x.current=void 0,f&&re(w.current)&&f(w.current,g),window.removeEventListener("mousemove",C,!0)};return window.addEventListener("mouseup",v,!0),()=>{window.removeEventListener("mouseup",v,!0),window.removeEventListener("mousemove",C,!0)}},[C,g,f]),e.jsxs("th",{ref:_,className:N(a,tt.th),...b,children:[r&&e.jsx("div",{role:"presentation",className:tt.resizeHandle,onMouseDown:j}),h]})}const Va="_table_nilhy_1",za="_table-overflow-wrapper_nilhy_8",Ua="_table-element_nilhy_13",Wa="_header-row_nilhy_23",Qa="_header-element_nilhy_24",Za="_header-component_nilhy_29",ce={table:Va,tableOverflowWrapper:za,tableElement:Ua,headerRow:Wa,headerElement:Qa,headerComponent:Za};function qa(m,a){return a??m.columnWidth??wt}function B(m){const{data:a,keySelector:h,columns:r,caption:f,className:g,captionClassName:b,headerRowClassName:_,headerCellClassName:y,rowClassName:x,cellClassName:w,rowModifier:C,fixedColumnWidth:j,resizableColumn:v,headersHidden:S,pending:p,filtered:k,errored:I=!1}=m,R=s.useRef(null),[T]=he.useState(()=>bt()),[G,U]=he.useState({});s.useEffect(()=>{U(W=>{if(q(R.current))return W;const E=R.current.getBoundingClientRect(),{width:O}=E;let A=r.map(M=>({id:M.id,stretch:!!M.columnStretch,width:qa(M,W[M.id])}));const X=ye(A.filter(M=>M.stretch).map(M=>M.width)),ne=ye(A.filter(M=>!M.stretch).map(M=>M.width)),Y=(O-ne)/X;return Y>1&&(A=A.map(M=>({...M,width:M.stretch?M.width*Y:M.width}))),jt(A,M=>M.id,M=>M.width)})},[r]);const ie=he.useCallback((W,E)=>{const O=document.getElementById(`${T}-${E}`),A=Math.max(W,80);if(q(O)||(O.style.width=`${A}px`,!j))return;const X=document.getElementById(T);if(q(X))return;const ne=ye(r.map(Y=>Y.id===E?A:G[Y.id]));X.style.width=`${ne}px`},[T,G,r,j]),ae=he.useCallback((W,E)=>{re(E)&&U(O=>({...O,[E]:Math.max(W,80)}))},[U]),be=he.useMemo(()=>ye(r.map(W=>G[W.id])),[G,r]),K=q(a)||a.length===0||Object.keys(G).length===0;return e.jsxs("div",{ref:R,className:N(ce.table,g),children:[!K&&e.jsx("div",{className:ce.tableOverflowWrapper,children:e.jsxs("table",{className:ce.tableElement,style:j?{width:`${be}px`}:void 0,id:T,children:[f&&e.jsx("caption",{className:b,children:f}),e.jsx("colgroup",{children:r.map(W=>{const{id:E,columnClassName:O}=W,A=G[E],X=j?{width:`${A}px`}:void 0;return e.jsx("col",{id:`${T}-${E}`,style:X,className:N(ce.column,O)},E)})}),!S&&e.jsx("thead",{children:e.jsx(it,{className:N(ce.headerRow,_),children:r.map((W,E)=>{const{id:O,title:A,headerCellRenderer:X,headerCellRendererClassName:ne,headerCellRendererParams:Y,headerContainerClassName:M}=W,se=e.jsx(X,{...Y,name:O,title:A,index:E,className:N(ne,ce.headerComponent)});return e.jsx(Ha,{scope:"col",name:O,onResize:v?ie:void 0,onResizeComplete:v?ae:void 0,className:N(ce.headerElement,typeof y=="function"?y(O):y,M),children:se},O)})})}),e.jsx("tbody",{children:e.jsx(Aa,{data:a,keySelector:h,columns:r,rowClassName:x,cellClassName:w,rowModifier:C})})]})}),e.jsx(Nt,{filtered:k,empty:K,errored:I,pending:p,overlayPending:!0})]})}function Ga(m){const{className:a,value:h}=m;return q(h)?null:e.jsx("div",{className:a,children:h})}const Ya="common",Ka={sortTableButtonTitle:"Sort Table"},Xa={namespace:Ya,strings:Ka},Ja="_header-cell_vn24d_1",en="_sort-button_vn24d_8",tn="_icon_vn24d_12",an="_info-popup-icon_vn24d_17",de={headerCell:Ja,sortButton:en,icon:tn,infoPopupIcon:an};function ot(m){const{className:a,titleClassName:h,title:r,name:f,sortable:g,defaultSortDirection:b="asc",infoTitle:_,infoDescription:y}=m,{sorting:x,setSorting:w}=s.useContext(St),C=rt(Xa),j=x?.name===f?x.direction:void 0,v=s.useRef(null),S=s.useCallback(()=>{if(q(w))return;let p;q(j)?p=b:j==="asc"?p="dsc":j==="dsc"&&(p="asc"),w(p?{name:f,direction:p}:void 0)},[f,w,j,b]);return e.jsxs("div",{ref:v,className:N(a,de.headerCell),children:[g&&e.jsxs(Z,{name:void 0,variant:"tertiary",onClick:S,title:C.sortTableButtonTitle,className:de.sortButton,children:[q(j)&&e.jsx(Rt,{className:de.icon}),j==="asc"&&e.jsx(Lt,{className:de.icon}),j==="dsc"&&e.jsx(kt,{className:de.icon})]}),e.jsx("div",{className:N(h,de.title),children:r}),_&&y&&e.jsx(ca,{className:de.infoPopupIcon,title:_,description:y})]})}const at={};function Q(m,a,h,r){return{id:m,title:a,columnClassName:r?.columnClassName,headerCellRenderer:ot,headerCellRendererClassName:r?.headerCellRendererClassName,headerContainerClassName:r?.headerContainerClassName,headerCellRendererParams:{sortable:r?.sortable,infoTitle:r?.headerInfoTitle,infoDescription:r?.headerInfoDescription},cellRendererClassName:r?.cellRendererClassName,cellContainerClassName:r?.cellContainerClassName,cellRenderer:Ga,cellRendererParams:(f,g)=>({value:h(g)||"--"}),valueSelector:h,valueComparator:(f,g)=>Mt(h(f),h(g)),columnWidth:r?.columnWidth,columnStretch:r?.columnStretch,columnStyle:r?.columnStyle}}function D(m,a,h,r){return{id:m,title:a,columnClassName:r?.columnClassName,headerCellRenderer:ot,headerCellRendererClassName:N(at.numberCellHeader,r?.headerCellRendererClassName),headerContainerClassName:r?.headerContainerClassName,headerCellRendererParams:{sortable:r?.sortable,infoTitle:r?.headerInfoTitle,infoDescription:r?.headerInfoDescription},cellRendererClassName:N(at.numberCell,r?.cellRendererClassName),cellContainerClassName:r?.cellContainerClassName,cellRenderer:we,cellRendererParams:(f,g)=>({value:h(g),suffix:r?.suffix,maximumFractionDigits:r?.maximumFractionDigits,invalidText:"--"}),valueSelector:h,valueComparator:(f,g)=>It(h(f),h(g)),columnWidth:r?.columnWidth,columnStretch:r?.columnStretch,columnStyle:r?.columnStyle}}const nn="_tabSelector_vlxoe_1",sn="_progressSection_vlxoe_14",rn="_progressLabel_vlxoe_20",on="_chartGrid_vlxoe_28",ln="_chartContainer_vlxoe_40",cn="_tableContainer_vlxoe_51",dn="_modelPerformance_vlxoe_59",un="_loadingContainer_vlxoe_67",mn="_errorContainer_vlxoe_77",hn="_userInteractionCards_vlxoe_96",gn="_userInteractionCard_vlxoe_96",fn="_userInteractionCardValue_vlxoe_116",vn="_userInteractionCardLabel_vlxoe_123",pn="_userInteractionCardButton_vlxoe_130",xn="_summaryStatsCards_vlxoe_148",_n="_summaryStatsCard_vlxoe_148",Cn="_summaryStatsCardValue_vlxoe_169",yn="_summaryStatsCardLabel_vlxoe_176",c={tabSelector:nn,progressSection:sn,progressLabel:rn,chartGrid:on,chartContainer:ln,tableContainer:cn,modelPerformance:dn,loadingContainer:un,errorContainer:mn,userInteractionCards:hn,userInteractionCard:gn,userInteractionCardValue:fn,userInteractionCardLabel:vn,userInteractionCardButton:pn,summaryStatsCards:xn,summaryStatsCard:_n,summaryStatsCardValue:Cn,summaryStatsCardLabel:yn};function jn(){const[m]=Dt(),[a,h]=s.useState(null),[r,f]=s.useState(!0),[g,b]=s.useState("crisis_maps"),[_,y]=s.useState([]),[x,w]=s.useState([]),[C,j]=s.useState([]),[v,S]=s.useState([]),[p,k]=s.useState(!1),[I,R]=s.useState(!1),[T,G]=s.useState(!1),[U,ie]=s.useState(!1),[ae,be]=s.useState(!1),[K,W]=s.useState(!1),E=t=>{k(t==="editTime"),R(t==="percentage"),G(t==="delete"),ie(t==="regions"),be(t==="sources"),W(t==="types")},O=[{key:"crisis_maps",label:"Crisis Maps"},{key:"drone_images",label:"Drone Images"}],A=s.useCallback((t,l)=>{if(!t||!l)return 0;const i=t.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(u=>u.length>0),n=l.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(u=>u.length>0);if(i.length===0&&n.length===0)return 1;if(i.length===0||n.length===0)return 0;const o=new Set(i),d=new Set(n),P=new Set([...o].filter(u=>d.has(u))),F=new Set([...o,...d]);return P.size/F.size},[]),X=s.useCallback(async()=>{f(!0);try{const l=await(await fetch("/api/images")).json(),i={},n=l.filter(u=>u.image_type==="crisis_map"),o=l.filter(u=>u.image_type==="drone_image"),d={totalCaptions:l.length,sources:{},types:{},regions:{},models:{},modelEditTimes:i,percentageModified:0,modelPercentageData:{},totalDeleteCount:0,deleteRate:0,crisisMaps:n,droneImages:o};l.forEach(u=>{if(u.source&&(d.sources[u.source]=(d.sources[u.source]||0)+1),u.event_type&&(d.types[u.event_type]=(d.types[u.event_type]||0)+1),u.countries&&u.countries.forEach(L=>{L.r_code&&(d.regions[L.r_code]=(d.regions[L.r_code]||0)+1)}),u.model){const L=u.model,V=d.models[L]||={count:0,avgAccuracy:0,avgContext:0,avgUsability:0,totalScore:0,deleteCount:0};if(V.count++,u.accuracy!=null&&(V.avgAccuracy+=u.accuracy),u.context!=null&&(V.avgContext+=u.context),u.usability!=null&&(V.avgUsability+=u.usability),u.created_at&&u.updated_at){const te=new Date(u.created_at).getTime(),Ce=new Date(u.updated_at).getTime()-te;Ce>0&&(i[L]||(i[L]=[]),i[L].push(Ce))}}}),_.forEach(u=>{u.s_code&&!d.sources[u.s_code]&&(d.sources[u.s_code]=0)}),x.forEach(u=>{u.t_code&&!d.types[u.t_code]&&(d.types[u.t_code]=0)}),C.forEach(u=>{u.r_code&&!d.regions[u.r_code]&&(d.regions[u.r_code]=0)}),["GPT-4","Claude","Gemini","Llama","Other"].forEach(u=>{d.models[u]||(d.models[u]={count:0,avgAccuracy:0,avgContext:0,avgUsability:0,totalScore:0,deleteCount:0})}),Object.values(d.models).forEach(u=>{u.count>0&&(u.avgAccuracy=Math.round(u.avgAccuracy/u.count),u.avgContext=Math.round(u.avgContext/u.count),u.avgUsability=Math.round(u.avgUsability/u.count),u.totalScore=Math.round((u.avgAccuracy+u.avgContext+u.avgUsability)/3))});const F=l.filter(u=>u.generated&&u.edited);if(F.length>0){const L=[...F.map(oe=>A(oe.generated,oe.edited))].sort((oe,Ce)=>oe-Ce),V=Math.floor(L.length/2),te=L.length%2===0?(L[V-1]+L[V])/2:L[V];d.percentageModified=Math.round((1-te)*100)}const H={};l.forEach(u=>{if(u.model&&u.generated&&u.edited){const L=A(u.generated,u.edited),V=Math.round((1-L)*100);H[u.model]||(H[u.model]=[]),H[u.model].push(V)}}),d.modelPercentageData=H;try{const u=await fetch("/api/models");if(u.ok){const L=await u.json();if(L.models){L.models.forEach(te=>{d.models[te.m_code]&&(d.models[te.m_code].deleteCount=te.delete_count||0)});const V=L.models.reduce((te,oe)=>te+(oe.delete_count||0),0);d.totalDeleteCount=V,d.deleteRate=V>0?Math.round(V/(V+l.length)*100):0}}}catch(u){console.log("Could not fetch model delete counts:",u)}h(d)}catch{h(null)}finally{f(!1)}},[_,x,C,A]),ne=s.useCallback(async()=>{try{const[t,l,i,n]=await Promise.all([fetch("/api/sources"),fetch("/api/types"),fetch("/api/regions"),fetch("/api/models")]),o=await t.json(),d=await l.json(),P=await i.json(),F=await n.json();y(o),w(d),j(P),S(F.models||[])}catch(t){console.log("Could not fetch lookup data:",t)}},[]);s.useEffect(()=>{const t=m.get("view");(t==="crisis_maps"||t==="drone_images")&&b(t)},[m]),s.useEffect(()=>{ne()},[ne]),s.useEffect(()=>{_.length>0&&x.length>0&&C.length>0&&v.length>0&&X()},[_,x,C,v,X]);const Y=s.useCallback(t=>{const l=_.find(i=>i.s_code===t);return l?l.label:t},[_]),M=s.useCallback(t=>{if(t.length===0)return 0;const l=[...t].sort((n,o)=>n-o),i=Math.floor(l.length/2);return l.length%2===0?Math.round((l[i-1]+l[i])/2):l[i]},[]),se=s.useCallback(t=>{const l=Math.floor(t/1e3),i=Math.floor(l/60),n=Math.floor(i/60);return n>0?`${n}h ${i%60}m`:i>0?`${i}m ${l%60}s`:`${l}s`},[]),_e=s.useCallback(t=>{const l=x.find(i=>i.t_code===t);return l?l.label:t},[x]),J=s.useCallback(t=>{const l=v.find(i=>i.m_code===t);return l?l.label:t},[v]),Se=s.useMemo(()=>a?Object.entries(a.modelEditTimes||{}).filter(([,t])=>t.length>0).sort(([,t],[,l])=>M(l)-M(t)).map(([t,l],i)=>({id:i+1,name:J(t),count:l.length,avgEditTime:M(l),minEditTime:Math.min(...l),maxEditTime:Math.max(...l)})):[],[a,M,J]),Me=s.useMemo(()=>a?Object.entries(a.modelPercentageData||{}).filter(([,t])=>t.length>0).sort(([,t],[,l])=>{const i=[...t].sort((H,u)=>H-u),n=[...l].sort((H,u)=>H-u),o=Math.floor(i.length/2),d=Math.floor(n.length/2),P=i.length%2===0?(i[o-1]+i[o])/2:i[o];return(n.length%2===0?(n[d-1]+n[d])/2:n[d])-P}).map(([t,l],i)=>{const n=[...l].sort((P,F)=>P-F),o=Math.floor(n.length/2),d=n.length%2===0?Math.round((n[o-1]+n[o])/2):n[o];return{id:i+1,name:J(t),count:l.length,avgPercentageModified:d,minPercentageModified:Math.min(...l),maxPercentageModified:Math.max(...l)}}):[],[a,J]),Ie=s.useMemo(()=>a?Object.entries(a.models).filter(([,t])=>t.count>0).map(([t,l],i)=>{const n=[l.avgAccuracy,l.avgContext,l.avgUsability],o=n.reduce((F,H)=>F+H,0)/n.length,d=n.reduce((F,H)=>F+Math.pow(H-o,2),0)/n.length,P=Math.round(100-Math.sqrt(d));return{id:i+1,name:J(t),consistency:Math.max(0,P),avgScore:Math.round(o),count:l.count}}).sort((t,l)=>l.consistency-t.consistency):[],[a,J]),De=s.useMemo(()=>[Q("name","Region",t=>t.name),D("count","Count",t=>t.count),D("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),Ee=s.useMemo(()=>[Q("name","Type",t=>t.name),D("count","Count",t=>t.count),D("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),lt=s.useMemo(()=>[Q("name","Source",t=>t.name),D("count","Count",t=>t.count),D("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),Te=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Count",t=>t.count),D("accuracy","Accuracy",t=>t.accuracy,{suffix:"%",maximumFractionDigits:0}),D("context","Context",t=>t.context,{suffix:"%",maximumFractionDigits:0}),D("usability","Usability",t=>t.usability,{suffix:"%",maximumFractionDigits:0}),D("totalScore","Total Score",t=>t.totalScore,{suffix:"%",maximumFractionDigits:0})],[]),ke=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Count",t=>t.count),Q("avgEditTime","Median Edit Time",t=>se(t.avgEditTime)),Q("minEditTime","Min Edit Time",t=>se(t.minEditTime)),Q("maxEditTime","Max Edit Time",t=>se(t.maxEditTime))],[se]),Le=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Count",t=>t.count),D("avgPercentageModified","Median % Modified",t=>t.avgPercentageModified,{suffix:"%",maximumFractionDigits:0}),D("minPercentageModified","Min % Modified",t=>t.minPercentageModified,{suffix:"%",maximumFractionDigits:0}),D("maxPercentageModified","Max % Modified",t=>t.maxPercentageModified,{suffix:"%",maximumFractionDigits:0})],[]),Pe=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Total Count",t=>t.count),D("deleteCount","Delete Count",t=>t.deleteCount),D("deleteRate","Delete Rate",t=>t.deleteRate,{suffix:"%",maximumFractionDigits:1})],[]),ct=s.useMemo(()=>[Q("source","Source",t=>t.source),D("avgQuality","Average Quality",t=>t.avgQuality,{suffix:"%",maximumFractionDigits:0}),D("count","Count",t=>t.count)],[]),Re=s.useMemo(()=>[Q("eventType","Event Type",t=>t.eventType),D("avgQuality","Average Quality",t=>t.avgQuality,{suffix:"%",maximumFractionDigits:0}),D("count","Count",t=>t.count)],[]),$e=s.useMemo(()=>[Q("name","Model",t=>t.name),D("consistency","Consistency",t=>t.consistency,{suffix:"%",maximumFractionDigits:0}),D("avgScore","Average Score",t=>t.avgScore,{suffix:"%",maximumFractionDigits:0}),D("count","Count",t=>t.count)],[]),ue=s.useCallback(t=>a?t==="crisis_map"?a.crisisMaps.length:t==="drone_image"?a.droneImages.length:0:0,[a]),Be=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.countries&&n.countries.forEach(o=>{o.r_code&&(i[o.r_code]=(i[o.r_code]||0)+1)})}),Object.entries(i).filter(([,n])=>n>0).map(([n,o])=>({name:C.find(d=>d.r_code===n)?.label||n,value:o}))},[a,C]),Ae=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};l.forEach(o=>{o.countries&&o.countries.forEach(d=>{d.r_code&&(i[d.r_code]=(i[d.r_code]||0)+1)})});const n=C.reduce((o,d)=>(d.r_code&&(o[d.r_code]={name:d.label,count:i[d.r_code]||0}),o),{});return Object.entries(n).sort(([,o],[,d])=>d.count-o.count).map(([,{name:o,count:d}],P)=>({id:P+1,name:o,count:d,percentage:l.length>0?Math.round(d/l.length*100):0}))},[a,C]),dt=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.source&&(i[n.source]=(i[n.source]||0)+1)}),Object.entries(i).filter(([,n])=>n>0).map(([n,o])=>({name:_.find(d=>d.s_code===n)?.label||n,value:o}))},[a,_]),ut=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.source&&(i[n.source]=(i[n.source]||0)+1)}),Object.entries(i).sort(([,n],[,o])=>o-n).map(([n,o],d)=>({id:d+1,name:Y(n),count:o,percentage:l.length>0?Math.round(o/l.length*100):0}))},[a,Y]),Fe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.event_type&&(i[n.event_type]=(i[n.event_type]||0)+1)}),Object.entries(i).filter(([,n])=>n>0).map(([n,o])=>({name:x.find(d=>d.t_code===n)?.label||n,value:o}))},[a,x]),Oe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.event_type&&(i[n.event_type]=(i[n.event_type]||0)+1)}),Object.entries(i).sort(([,n],[,o])=>o-n).map(([n,o],d)=>({id:d+1,name:_e(n),count:o,percentage:l.length>0?Math.round(o/l.length*100):0}))},[a,_e]),He=s.useCallback(t=>{if(!a)return"No data available";const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;l.forEach(d=>{d.model&&i.add(d.model)}),console.log(`Debug ${t}:`,{totalImages:l.length,usedModels:Array.from(i),availableEditTimes:Object.keys(a.modelEditTimes),modelEditTimesData:a.modelEditTimes});const o=Object.entries(a.modelEditTimes).filter(([d])=>i.has(d)).flatMap(([,d])=>d);return o.length===0?"No data available":se(M(o))},[a,se,M]),Ve=s.useCallback(()=>{if(!a)return"No data available";const t=a.totalCaptions||0,l=a.percentageModified||0;return t>0?Math.round(l/t*100):0},[a]),ze=s.useCallback(()=>a&&a.deleteRate>=0?`${a.deleteRate}%`:"No data available",[a]),Ue=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;return l.forEach(o=>{o.model&&i.add(o.model)}),Se.filter(o=>{const d=v.find(P=>P.label===o.name)?.m_code;return d&&i.has(d)})},[a,Se,v]),We=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;return l.forEach(o=>{o.model&&i.add(o.model)}),Me.filter(o=>{const d=v.find(P=>P.label===o.name)?.m_code;return d&&i.has(d)})},[a,Me,v]),Qe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.model&&(i[n.model]||(i[n.model]={count:0,deleteCount:0}),i[n.model].count++)}),Object.entries(i).map(([n,o],d)=>{const F=a.models?.[n]?.deleteCount||0,H=o.count>0?Math.round(F/o.count*100*10)/10:0;return{id:d+1,name:J(n),count:o.count,deleteCount:F,deleteRate:H}}).sort((n,o)=>o.count-n.count)},[a,J]),Ze=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.model&&(i[n.model]||(i[n.model]={count:0,totalAccuracy:0,totalContext:0,totalUsability:0}),i[n.model].count++,n.accuracy!=null&&(i[n.model].totalAccuracy+=n.accuracy),n.context!=null&&(i[n.model].totalContext+=n.context),n.usability!=null&&(i[n.model].totalUsability+=n.usability))}),Object.entries(i).map(([n,o],d)=>({id:d+1,name:J(n),count:o.count,accuracy:o.count>0?Math.round(o.totalAccuracy/o.count):0,context:o.count>0?Math.round(o.totalContext/o.count):0,usability:o.count>0?Math.round(o.totalUsability/o.count):0,totalScore:o.count>0?Math.round((o.totalAccuracy+o.totalContext+o.totalUsability)/(3*o.count)):0})).sort((n,o)=>o.totalScore-n.totalScore)},[a,J]),mt=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.source&&(i[n.source]||(i[n.source]={total:0,count:0,totalImages:0}),i[n.source].totalImages+=1,n.accuracy!=null&&(i[n.source].total+=n.accuracy,i[n.source].count+=1))}),Object.entries(i).map(([n,o],d)=>({id:d+1,source:Y(n),avgQuality:o.count>0?Math.round(o.total/o.count):0,count:o.totalImages}))},[a,Y]),qe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.event_type&&(i[n.event_type]||(i[n.event_type]={total:0,count:0,totalImages:0}),i[n.event_type].totalImages+=1,n.accuracy!=null&&(i[n.event_type].total+=n.accuracy,i[n.event_type].count+=1))}),Object.entries(i).map(([n,o],d)=>({id:d+1,eventType:_e(n),avgQuality:o.count>0?Math.round(o.total/o.count):0,count:o.totalImages}))},[a,_e]),Ge=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;return l.forEach(o=>{o.model&&i.add(o.model)}),Ie.filter(o=>{const d=v.find(P=>P.label===o.name)?.m_code;return d&&i.has(d)})},[a,Ie,v]);if(r)return e.jsx(je,{children:e.jsx("div",{className:c.loadingContainer,children:e.jsx(Et,{})})});if(!a)return e.jsx(je,{children:e.jsx("div",{className:c.errorContainer,children:e.jsx("div",{className:"text-red-500",children:"Failed to load analytics data. Please try again."})})});const me=["#F5333F","#F64752","#F75C65","#F87079","#F9858C","#FA999F","#FBADB2","#FCC2C5"];return e.jsx(je,{children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsx("div",{className:c.tabSelector,children:e.jsx(Tt,{name:"analytics-view",value:g,onChange:t=>{(t==="crisis_maps"||t==="drone_images")&&b(t)},options:O,keySelector:t=>t.key,labelSelector:t=>t.label})}),g==="crisis_maps"?e.jsxs("div",{className:c.chartGrid,children:[e.jsxs(z,{heading:"Summary Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.summaryStatsCards,children:[e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:ue("crisis_map")}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Total Crisis Maps"})]}),e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:"2000"}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Target Amount"})]})]}),e.jsxs("div",{className:c.progressSection,children:[e.jsxs("div",{className:c.progressLabel,children:[e.jsx("span",{children:"Progress towards target"}),e.jsxs("span",{children:[Math.round(ue("crisis_map")/2e3*100),"%"]})]}),e.jsx(Ye,{value:ue("crisis_map"),totalValue:2e3})]})]}),e.jsxs(z,{heading:"Distribution Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Regions Distribution"}),e.jsx("div",{className:c.chartContainer,children:e.jsx(xe,{data:Be("crisis_map"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-regions-details",variant:U?"primary":"secondary",onClick:()=>E(U?"none":"regions"),className:c.userInteractionCardButton,children:U?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Sources Distribution"}),e.jsx("div",{className:c.chartContainer,children:e.jsx(xe,{data:dt("crisis_map"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-sources-details",variant:ae?"primary":"secondary",onClick:()=>E(ae?"none":"sources"),className:c.userInteractionCardButton,children:ae?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Types Distribution"}),e.jsx("div",{className:c.chartContainer,children:e.jsx(xe,{data:Fe("crisis_map"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-types-details",variant:K?"primary":"secondary",onClick:()=>E(K?"none":"types"),className:c.userInteractionCardButton,children:K?"Hide Details":"View Details"})]})]}),U&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ae("crisis_map"),columns:De,keySelector:$,filtered:!1,pending:!1})}),ae&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:ut("crisis_map"),columns:lt,keySelector:$,filtered:!1,pending:!1})}),K&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Oe("crisis_map"),columns:Ee,keySelector:$,filtered:!1,pending:!1})})]}),e.jsxs(z,{heading:"User Interaction Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:He("crisis_map")}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median Edit Time"}),e.jsx(Z,{name:"view-edit-time-details",variant:p?"primary":"secondary",onClick:()=>E(p?"none":"editTime"),className:c.userInteractionCardButton,children:p?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:Ve()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median % Modified"}),e.jsx(Z,{name:"view-percentage-details",variant:I?"primary":"secondary",onClick:()=>E(I?"none":"percentage"),className:c.userInteractionCardButton,children:I?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:ze()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Delete Rate"}),e.jsx(Z,{name:"view-delete-details",variant:T?"primary":"secondary",onClick:()=>E(T?"none":"delete"),className:c.userInteractionCardButton,children:T?"Hide Details":"View Details"})]})]}),p&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ue("crisis_map"),columns:ke,keySelector:$,filtered:!1,pending:!1})}),I&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:We("crisis_map"),columns:Le,keySelector:$,filtered:!1,pending:!1})}),T&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Qe("crisis_map"),columns:Pe,keySelector:$,filtered:!1,pending:!1})})]}),e.jsx(z,{heading:"Model Performance",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ze("crisis_map"),columns:Te,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Source Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:mt("crisis_map"),columns:ct,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Event Type Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:qe("crisis_map"),columns:Re,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Model Consistency Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:Ge("crisis_map"),columns:$e,keySelector:$,filtered:!1,pending:!1})})})]}):e.jsxs("div",{className:c.chartGrid,children:[e.jsxs(z,{heading:"Summary Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.summaryStatsCards,children:[e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:ue("drone_image")}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Total Drone Images"})]}),e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:"2000"}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Target Amount"})]})]}),e.jsxs("div",{className:c.progressSection,children:[e.jsxs("div",{className:c.progressLabel,children:[e.jsx("span",{children:"Progress towards target"}),e.jsxs("span",{children:[Math.round(ue("drone_image")/2e3*100),"%"]})]}),e.jsx(Ye,{value:ue("drone_image"),totalValue:2e3})]})]}),e.jsxs(z,{heading:"Distribution Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Regions Distribution"}),e.jsx("div",{className:c.chartContainer,children:e.jsx(xe,{data:Be("drone_image"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-regions-details",variant:U?"primary":"secondary",onClick:()=>E(U?"none":"regions"),className:c.userInteractionCardButton,children:U?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Types Distribution"}),e.jsx("div",{className:c.chartContainer,children:e.jsx(xe,{data:Fe("drone_image"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-types-details",variant:K?"primary":"secondary",onClick:()=>E(K?"none":"types"),className:c.userInteractionCardButton,children:K?"Hide Details":"View Details"})]})]}),U&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ae("drone_image"),columns:De,keySelector:$,filtered:!1,pending:!1})}),K&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Oe("drone_image"),columns:Ee,keySelector:$,filtered:!1,pending:!1})})]}),e.jsxs(z,{heading:"User Interaction Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:He("drone_image")}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median Edit Time"}),e.jsx(Z,{name:"view-edit-time-details",variant:p?"primary":"secondary",onClick:()=>E(p?"none":"editTime"),className:c.userInteractionCardButton,children:p?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:Ve()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median % Modified"}),e.jsx(Z,{name:"view-percentage-details",variant:I?"primary":"secondary",onClick:()=>E(I?"none":"percentage"),className:c.userInteractionCardButton,children:I?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:ze()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Delete Rate"}),e.jsx(Z,{name:"view-delete-details",variant:T?"primary":"secondary",onClick:()=>E(T?"none":"delete"),className:c.userInteractionCardButton,children:T?"Hide Details":"View Details"})]})]}),p&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ue("drone_image"),columns:ke,keySelector:$,filtered:!1,pending:!1})}),I&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:We("drone_image"),columns:Le,keySelector:$,filtered:!1,pending:!1})}),T&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Qe("drone_image"),columns:Pe,keySelector:$,filtered:!1,pending:!1})})]}),e.jsx(z,{heading:"Model Performance",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ze("drone_image"),columns:Te,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Event Type Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:qe("drone_image"),columns:Re,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Model Consistency Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:Ge("drone_image"),columns:$e,keySelector:$,filtered:!1,pending:!1})})})]})]})})}export{jn as default}; +import{r as s,y as nt,t as ht,a as q,c as gt,j as e,o as N,b as re,R as st,z,g as rt,d as ft,m as vt,e as pt,n as Z,A as xt,f as _t,h as Ct,i as yt,k as he,l as bt,p as ye,q as jt,s as Nt,E as wt,C as St,U as Mt,Q as It,u as Dt,N as je,_ as Et,L as Tt}from"./index-B0L3qvtx.js";const kt=({title:m,titleId:a,...h})=>s.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?s.createElement("title",{id:a},m):null,s.createElement("g",{clipPath:"url(#arrow-drop-down-line_svg__a)"},s.createElement("path",{d:"m12 15-4.243-4.243 1.415-1.414L12 12.172l2.828-2.83 1.415 1.415L12 15Z"})),s.createElement("defs",null,s.createElement("clipPath",{id:"arrow-drop-down-line_svg__a"},s.createElement("path",{d:"M0 0h24v24H0z"})))),Lt=({title:m,titleId:a,...h})=>s.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?s.createElement("title",{id:a},m):null,s.createElement("g",{clipPath:"url(#arrow-drop-up-line_svg__a)"},s.createElement("path",{d:"m12 11.828-2.828 2.829-1.415-1.414L12 9l4.243 4.243-1.415 1.414L12 11.828Z"})),s.createElement("defs",null,s.createElement("clipPath",{id:"arrow-drop-up-line_svg__a"},s.createElement("path",{d:"M0 0h24v24H0z"})))),Pt=({title:m,titleId:a,...h})=>s.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?s.createElement("title",{id:a},m):null,s.createElement("g",{clipPath:"url(#information-line_svg__a)"},s.createElement("path",{d:"M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10Zm0-2a8 8 0 1 0 0-16.001A8 8 0 0 0 12 20ZM11 7h2v2h-2V7Zm0 4h2v6h-2v-6Z"})),s.createElement("defs",null,s.createElement("clipPath",{id:"information-line_svg__a"},s.createElement("path",{d:"M0 0h24v24H0z"})))),Rt=({title:m,titleId:a,...h})=>s.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?s.createElement("title",{id:a},m):null,s.createElement("path",{fillRule:"evenodd",d:"m15.063 12 .937.938-4 4-4-4L8.938 12 12 15.063 15.063 12Z",clipRule:"evenodd"}),s.createElement("mask",{id:"table-sorting-line_svg__a",width:8,height:5,x:8,y:12,maskUnits:"userSpaceOnUse",style:{maskType:"luminance"}},s.createElement("path",{fillRule:"evenodd",d:"m15.063 12 .937.938-4 4-4-4L8.938 12 12 15.063 15.063 12Z",clipRule:"evenodd"})),s.createElement("g",{mask:"url(#table-sorting-line_svg__a)"},s.createElement("path",{d:"M-24-22h72v72h-72z"})),s.createElement("path",{fillRule:"evenodd",d:"M8.938 11 8 10.062l4-4 4 4-.938.938L12 7.937 8.937 11Z",clipRule:"evenodd"}),s.createElement("mask",{id:"table-sorting-line_svg__b",width:8,height:5,x:8,y:6,maskUnits:"userSpaceOnUse",style:{maskType:"luminance"}},s.createElement("path",{fillRule:"evenodd",d:"M8.938 11 8 10.062l4-4 4 4-.938.938L12 7.937 8.937 11Z",clipRule:"evenodd"})),s.createElement("g",{mask:"url(#table-sorting-line_svg__b)"},s.createElement("path",{d:"M48 45h-72v-72h72z"}))),$t="_number-output_1blvi_1",Bt={numberOutput:$t};function we(m){const{className:a,invalidText:h=nt,separatorHidden:r,compact:f,currency:g,value:b,tooltip:_,unit:y,prefix:x,suffix:w,maximumFractionDigits:C=1}=m,{currentLanguage:j}=s.useContext(ht),v=s.useMemo(()=>{if(q(b))return h;const S=gt(b,{currency:g,compact:f,separatorHidden:r,maximumFractionDigits:C,unit:y,language:j});return e.jsxs(e.Fragment,{children:[x,S,w]})},[h,b,f,r,g,y,C,x,j,w]);return e.jsx("div",{className:N(Bt.numberOutput,a),title:re(_)?String(_):void 0,children:v})}const At="_tooltip-dummy_rbf3f_1",Ft="_tooltip-content_rbf3f_7",Ot="_pointer_rbf3f_14",Ne={tooltipDummy:At,tooltipContent:Ft,pointer:Ot};function Ht(m){const{className:a,title:h,description:r,preferredWidth:f}=m,[g,b]=s.useState(!1),[_,y]=s.useState(!1),x=s.useRef(),w=s.useRef(null);return s.useEffect(()=>{const C=()=>{y(!0)},j=()=>{y(!1)};if(q(w.current))return;const{current:{parentNode:v}}=w;if(!q(v))return x.current=v,v.addEventListener("mouseover",C),v.addEventListener("mouseout",j),b(!0),()=>{v.removeEventListener("mouseover",C),v.removeEventListener("mouseout",j)}},[]),e.jsxs(e.Fragment,{children:[!g&&e.jsx("div",{className:Ne.tooltipDummy,ref:w}),_&&e.jsx(st,{className:N(Ne.tooltipContent,a),parentRef:x,pointerClassName:Ne.pointer,preferredWidth:f,children:e.jsx(z,{heading:h,withInternalPadding:!0,contentViewType:"vertical",children:r})})]})}function $(m){return m.id}const Vt="common",zt={booleanYesLabel:"Yes",booleanNoLabel:"No"},Ut={namespace:Vt,strings:zt},Wt="_boolean-output_kg1uq_1",Qt={booleanOutput:Wt};function Zt(m){const{className:a,invalidText:h,value:r}=m,f=rt(Ut);let g;return r===!0?g=f.booleanYesLabel:r===!1?g=f.booleanNoLabel:g=h,e.jsx("div",{className:N(Qt.booleanOutput,a),children:g})}const qt="_date-output_4jzjo_1",Gt={dateOutput:qt};function Yt(m){const{value:a,format:h,className:r,invalidText:f}=m,g=s.useMemo(()=>ft(a,h),[a,h]);return e.jsx("div",{className:N(Gt.dateOutput,r),children:g??f})}const Kt="_dropdown-menu_16hml_1",Xt="_icons_16hml_4",Jt="_content_16hml_5",ea="_actions_16hml_6",ta="_dropdown-icon_16hml_10",aa="_dropdown-content_16hml_16",le={dropdownMenu:Kt,icons:Xt,content:Jt,actions:ea,dropdownIcon:ta,dropdownContent:aa};function na(m){const a=s.useRef(null),{className:h,popupClassName:r,children:f,label:g,activeClassName:b,icons:_,variant:y="secondary",actions:x,withoutDropdownIcon:w,componentRef:C,elementRef:j=a,persistent:v,preferredPopupWidth:S}=m,p=s.useRef(null),[k,I]=s.useState(!1);s.useEffect(()=>{C&&(C.current={setShowDropdown:I})},[C,I]);const R=s.useCallback(()=>{I(ie=>!ie)},[I]),T=s.useCallback((ie,ae)=>{ae||ie&&v||I(!1)},[I,v]);vt(k,T,p,j);const G=s.useMemo(()=>({setShowDropdown:I}),[I]),U=!!x||!w;return e.jsxs(pt.Provider,{value:G,children:[e.jsx(Z,{name:void 0,className:N(le.dropdownMenu,k&&b,h),elementRef:j,onClick:R,variant:y,actionsContainerClassName:le.actions,iconsContainerClassName:le.icons,childrenContainerClassName:le.content,actions:U?e.jsxs(e.Fragment,{children:[x,!w&&(k?e.jsx(xt,{className:le.dropdownIcon}):e.jsx(_t,{className:le.dropdownIcon}))]}):void 0,icons:_,children:g}),k&&e.jsx(st,{elementRef:p,className:N(le.dropdownContent,r),parentRef:j,preferredWidth:S,children:f})]})}const sa="_info-popup_i3rna_1",ra="_label_i3rna_2",ia="_icon_i3rna_7",oa="_dropdown-container_i3rna_15",la="_content_i3rna_20",ge={infoPopup:sa,label:ra,icon:ia,dropdownContainer:oa,content:la};function ca(m){const{className:a,icon:h=e.jsx(Pt,{}),infoLabel:r,title:f,description:g,withoutIcon:b,popupClassName:_,descriptionClassName:y}=m;return e.jsx(na,{label:e.jsxs("div",{className:ge.label,children:[r,!b&&h&&e.jsx("div",{className:ge.icon,children:h})]}),popupClassName:N(ge.dropdownContainer,_),className:N(ge.infoPopup,a),variant:"tertiary",withoutDropdownIcon:!0,children:e.jsx(z,{heading:f,childrenContainerClassName:N(y,ge.content),withInternalPadding:!0,children:g})})}const da="_progress-wrapper_x340w_1",ua="_title_x340w_7",ma="_total_x340w_11",ha="_progress_x340w_1",fe={progressWrapper:da,title:ua,total:ma,progress:ha};function Ye(m){const{className:a,title:h,description:r,totalValue:f,value:g,showPercentageInTitle:b,children:_,color:y="var(--go-ui-color-primary-red)"}=m,x=re(g)?g:0,w=re(f)?f:0;let C;return w===0?C=0:C=x/w*100,e.jsxs("div",{className:N(fe.progressWrapper,a),children:[(h||b)&&e.jsxs("div",{className:fe.title,children:[h,b&&e.jsx(we,{value:C,suffix:"%"})]}),e.jsx("div",{className:fe.total,children:e.jsx("div",{className:fe.progress,style:{width:`${C}%`,backgroundColor:y}})}),r&&e.jsx("div",{className:fe.description,children:r}),_]})}const ga="_legend-element_1a9ic_1",fa="_color_1a9ic_7",va="_icon-container_1a9ic_14",pa="_icon_1a9ic_14",xa="_label_1a9ic_31",ve={legendElement:ga,color:fa,iconContainer:va,icon:pa,label:xa};function _a(m){const{className:a,colorClassName:h,iconClassName:r,color:f,label:g,iconSrc:b}=m;return e.jsxs("div",{className:N(ve.legendElement,a),children:[b?e.jsx("div",{style:{backgroundColor:f},className:ve.iconContainer,children:e.jsx("img",{className:N(ve.icon,r),src:b,alt:""})}):e.jsx("div",{style:{backgroundColor:f},className:N(ve.color,h)}),e.jsx("div",{className:ve.label,children:g})]})}const Ca="_text-output_10oza_1",ya="_with-background_10oza_6",ba="_label_10oza_11",ja="_with-colon_10oza_12",Na="_value_10oza_17",wa="_text-type_10oza_18",Sa="_strong_10oza_24",ee={textOutput:Ca,withBackground:ya,label:ba,withColon:ja,value:Na,textType:wa,strong:Sa};function Ke(m){const{className:a,label:h,icon:r,description:f,labelClassName:g,descriptionClassName:b,valueClassName:_,strongLabel:y,strongValue:x,strongDescription:w,withoutLabelColon:C,withBackground:j,invalidText:v=nt,...S}=m,{value:p}=m;let k=v;return S.valueType==="number"?k=e.jsx(we,{...S,invalidText:v}):S.valueType==="date"?k=e.jsx(Yt,{...S,invalidText:v}):S.valueType==="boolean"?k=e.jsx(Zt,{...S,invalidText:v}):p instanceof Date||(k=p||v),e.jsxs("div",{className:N(ee.textOutput,j&&ee.withBackground,a),children:[r,h&&e.jsx("div",{className:N(ee.label,y&&ee.strong,g,!C&&ee.withColon),children:h}),e.jsx("div",{className:N(ee.value,x&&ee.strong,S.valueType==="text"&&ee.textType,_),children:k}),f&&e.jsx("div",{className:N(ee.description,w&&ee.strong,b),children:f})]})}const Ma="_pie-chart_pyr7m_1",Ia="_legend_pyr7m_7",Da="_legend-item_pyr7m_13",pe={pieChart:Ma,legend:Ia,legendItem:Da},Ea=70,Ta=40;function Xe(m,a=1){return Math.round(m*10**a)/10**a}function Je(m,a){const h=(a-90)*Math.PI/180;return{x:Xe(m+m*Math.cos(h)),y:Xe(m+m*Math.sin(h))}}function ka(m,a,h){let r=h;const f=r-a===360;f&&(r-=1);const g=Je(m,a),b=Je(m,r),_=r-a<=180?0:1,y=["M",g.x,g.y,"A",m,m,0,_,1,b.x,b.y];return f?y.push("Z"):y.push("L",m,m,"L",g.x,g.y,"Z"),y.join(" ")}function xe(m){const{className:a,data:h,valueSelector:r,labelSelector:f,keySelector:g,colorSelector:b,colors:_,pieRadius:y=Ea,chartPadding:x=Ta,legendClassName:w,showPercentageInLegend:C}=m,j=Ct(h?.map(p=>r(p))),v=q(j)||j===0?1:j,S=s.useMemo(()=>{let p=0;const k=h?.map(I=>{const R=r(I);if(q(R))return;const T=360*(R/v);return p+=T,{key:g(I),value:R,label:f(I),startAngle:p-T,percentage:yt(R,v),endAngle:p,datum:I}}).filter(re)??[];return b?k.map(({datum:I,...R})=>({...R,color:b(I)})):k.map(({datum:I,...R},T)=>({...R,color:_[T%_.length]}))},[h,g,r,f,v,b,_]);return e.jsxs("div",{className:N(pe.pieChart,a),children:[e.jsx("svg",{className:pe.svg,style:{width:`${x+y*2}px`,height:`${x+y*2}px`},children:e.jsx("g",{style:{transform:`translate(${x/2}px, ${x/2}px)`},children:S.map(p=>e.jsx("path",{className:pe.path,d:ka(y,p.startAngle,p.endAngle),fill:p.color,children:e.jsx(Ht,{description:e.jsx(Ke,{label:p.label,value:p.value})})},p.key))})}),e.jsx("div",{className:N(pe.legend,w),children:S.map(p=>e.jsx(_a,{className:pe.legendItem,label:C?e.jsx(Ke,{label:p.label,value:p.percentage,valueType:"number",prefix:"(",suffix:"%)",withoutLabelColon:!0}):p.label,color:p.color},p.key))})]})}const La="_td_1k4cn_1",Pa={td:La};function Ra(m){const{className:a,children:h,...r}=m;return e.jsx("td",{className:N(a,Pa.td),...r,children:h})}function it(m){const{className:a,children:h,...r}=m;return e.jsx("tr",{className:a,...r,children:h})}const $a="_row_1829z_1",Ba="_cell_1829z_2",et={row:$a,cell:Ba};function Aa(m){const{data:a,keySelector:h,columns:r,rowClassName:f,cellClassName:g,rowModifier:b}=m;return e.jsx(e.Fragment,{children:a?.map((_,y)=>{const x=h(_,y),w=r.map(v=>{const{id:S,cellRenderer:p,cellRendererClassName:k,cellRendererParams:I,cellContainerClassName:R}=v,T=I(x,_,y,a),G=e.jsx(p,{className:k,...T,name:S});return e.jsx(Ra,{className:N(et.cell,R,typeof g=="function"?g(x,_,S):g),children:G},S)}),C=e.jsx(it,{className:N(et.row,typeof f=="function"?f(x,_):f),children:w});let j=C;return b&&(j=b({rowKey:x,row:C,cells:w,columns:r,datum:_})),e.jsx(s.Fragment,{children:j},x)})})}const Fa="_th_cdv41_1",Oa="_resize-handle_cdv41_8",tt={th:Fa,resizeHandle:Oa};function Ha(m){const{className:a,children:h,onResize:r,onResizeComplete:f,name:g,...b}=m,_=s.useRef(null),y=s.useRef(),x=s.useRef(),w=s.useRef(),C=s.useCallback(v=>{var S;if(re(y.current)&&_.current&&r){v.preventDefault(),v.stopPropagation();const p=v.clientX-y.current;if(re(x.current)){const k=x.current+p;w.current=k,r(k,g)}else x.current=(S=_.current)==null?void 0:S.offsetWidth}},[r,g]),j=s.useCallback(v=>{var S;v.preventDefault(),y.current=v.clientX,x.current=(S=_.current)==null?void 0:S.offsetWidth,window.addEventListener("mousemove",C,!0)},[C]);return s.useEffect(()=>{const v=()=>{y.current=void 0,x.current=void 0,f&&re(w.current)&&f(w.current,g),window.removeEventListener("mousemove",C,!0)};return window.addEventListener("mouseup",v,!0),()=>{window.removeEventListener("mouseup",v,!0),window.removeEventListener("mousemove",C,!0)}},[C,g,f]),e.jsxs("th",{ref:_,className:N(a,tt.th),...b,children:[r&&e.jsx("div",{role:"presentation",className:tt.resizeHandle,onMouseDown:j}),h]})}const Va="_table_nilhy_1",za="_table-overflow-wrapper_nilhy_8",Ua="_table-element_nilhy_13",Wa="_header-row_nilhy_23",Qa="_header-element_nilhy_24",Za="_header-component_nilhy_29",ce={table:Va,tableOverflowWrapper:za,tableElement:Ua,headerRow:Wa,headerElement:Qa,headerComponent:Za};function qa(m,a){return a??m.columnWidth??wt}function B(m){const{data:a,keySelector:h,columns:r,caption:f,className:g,captionClassName:b,headerRowClassName:_,headerCellClassName:y,rowClassName:x,cellClassName:w,rowModifier:C,fixedColumnWidth:j,resizableColumn:v,headersHidden:S,pending:p,filtered:k,errored:I=!1}=m,R=s.useRef(null),[T]=he.useState(()=>bt()),[G,U]=he.useState({});s.useEffect(()=>{U(W=>{if(q(R.current))return W;const E=R.current.getBoundingClientRect(),{width:O}=E;let A=r.map(M=>({id:M.id,stretch:!!M.columnStretch,width:qa(M,W[M.id])}));const X=ye(A.filter(M=>M.stretch).map(M=>M.width)),ne=ye(A.filter(M=>!M.stretch).map(M=>M.width)),Y=(O-ne)/X;return Y>1&&(A=A.map(M=>({...M,width:M.stretch?M.width*Y:M.width}))),jt(A,M=>M.id,M=>M.width)})},[r]);const ie=he.useCallback((W,E)=>{const O=document.getElementById(`${T}-${E}`),A=Math.max(W,80);if(q(O)||(O.style.width=`${A}px`,!j))return;const X=document.getElementById(T);if(q(X))return;const ne=ye(r.map(Y=>Y.id===E?A:G[Y.id]));X.style.width=`${ne}px`},[T,G,r,j]),ae=he.useCallback((W,E)=>{re(E)&&U(O=>({...O,[E]:Math.max(W,80)}))},[U]),be=he.useMemo(()=>ye(r.map(W=>G[W.id])),[G,r]),K=q(a)||a.length===0||Object.keys(G).length===0;return e.jsxs("div",{ref:R,className:N(ce.table,g),children:[!K&&e.jsx("div",{className:ce.tableOverflowWrapper,children:e.jsxs("table",{className:ce.tableElement,style:j?{width:`${be}px`}:void 0,id:T,children:[f&&e.jsx("caption",{className:b,children:f}),e.jsx("colgroup",{children:r.map(W=>{const{id:E,columnClassName:O}=W,A=G[E],X=j?{width:`${A}px`}:void 0;return e.jsx("col",{id:`${T}-${E}`,style:X,className:N(ce.column,O)},E)})}),!S&&e.jsx("thead",{children:e.jsx(it,{className:N(ce.headerRow,_),children:r.map((W,E)=>{const{id:O,title:A,headerCellRenderer:X,headerCellRendererClassName:ne,headerCellRendererParams:Y,headerContainerClassName:M}=W,se=e.jsx(X,{...Y,name:O,title:A,index:E,className:N(ne,ce.headerComponent)});return e.jsx(Ha,{scope:"col",name:O,onResize:v?ie:void 0,onResizeComplete:v?ae:void 0,className:N(ce.headerElement,typeof y=="function"?y(O):y,M),children:se},O)})})}),e.jsx("tbody",{children:e.jsx(Aa,{data:a,keySelector:h,columns:r,rowClassName:x,cellClassName:w,rowModifier:C})})]})}),e.jsx(Nt,{filtered:k,empty:K,errored:I,pending:p,overlayPending:!0})]})}function Ga(m){const{className:a,value:h}=m;return q(h)?null:e.jsx("div",{className:a,children:h})}const Ya="common",Ka={sortTableButtonTitle:"Sort Table"},Xa={namespace:Ya,strings:Ka},Ja="_header-cell_vn24d_1",en="_sort-button_vn24d_8",tn="_icon_vn24d_12",an="_info-popup-icon_vn24d_17",de={headerCell:Ja,sortButton:en,icon:tn,infoPopupIcon:an};function ot(m){const{className:a,titleClassName:h,title:r,name:f,sortable:g,defaultSortDirection:b="asc",infoTitle:_,infoDescription:y}=m,{sorting:x,setSorting:w}=s.useContext(St),C=rt(Xa),j=x?.name===f?x.direction:void 0,v=s.useRef(null),S=s.useCallback(()=>{if(q(w))return;let p;q(j)?p=b:j==="asc"?p="dsc":j==="dsc"&&(p="asc"),w(p?{name:f,direction:p}:void 0)},[f,w,j,b]);return e.jsxs("div",{ref:v,className:N(a,de.headerCell),children:[g&&e.jsxs(Z,{name:void 0,variant:"tertiary",onClick:S,title:C.sortTableButtonTitle,className:de.sortButton,children:[q(j)&&e.jsx(Rt,{className:de.icon}),j==="asc"&&e.jsx(Lt,{className:de.icon}),j==="dsc"&&e.jsx(kt,{className:de.icon})]}),e.jsx("div",{className:N(h,de.title),children:r}),_&&y&&e.jsx(ca,{className:de.infoPopupIcon,title:_,description:y})]})}const at={};function Q(m,a,h,r){return{id:m,title:a,columnClassName:r?.columnClassName,headerCellRenderer:ot,headerCellRendererClassName:r?.headerCellRendererClassName,headerContainerClassName:r?.headerContainerClassName,headerCellRendererParams:{sortable:r?.sortable,infoTitle:r?.headerInfoTitle,infoDescription:r?.headerInfoDescription},cellRendererClassName:r?.cellRendererClassName,cellContainerClassName:r?.cellContainerClassName,cellRenderer:Ga,cellRendererParams:(f,g)=>({value:h(g)||"--"}),valueSelector:h,valueComparator:(f,g)=>Mt(h(f),h(g)),columnWidth:r?.columnWidth,columnStretch:r?.columnStretch,columnStyle:r?.columnStyle}}function D(m,a,h,r){return{id:m,title:a,columnClassName:r?.columnClassName,headerCellRenderer:ot,headerCellRendererClassName:N(at.numberCellHeader,r?.headerCellRendererClassName),headerContainerClassName:r?.headerContainerClassName,headerCellRendererParams:{sortable:r?.sortable,infoTitle:r?.headerInfoTitle,infoDescription:r?.headerInfoDescription},cellRendererClassName:N(at.numberCell,r?.cellRendererClassName),cellContainerClassName:r?.cellContainerClassName,cellRenderer:we,cellRendererParams:(f,g)=>({value:h(g),suffix:r?.suffix,maximumFractionDigits:r?.maximumFractionDigits,invalidText:"--"}),valueSelector:h,valueComparator:(f,g)=>It(h(f),h(g)),columnWidth:r?.columnWidth,columnStretch:r?.columnStretch,columnStyle:r?.columnStyle}}const nn="_tabSelector_vlxoe_1",sn="_progressSection_vlxoe_14",rn="_progressLabel_vlxoe_20",on="_chartGrid_vlxoe_28",ln="_chartContainer_vlxoe_40",cn="_tableContainer_vlxoe_51",dn="_modelPerformance_vlxoe_59",un="_loadingContainer_vlxoe_67",mn="_errorContainer_vlxoe_77",hn="_userInteractionCards_vlxoe_96",gn="_userInteractionCard_vlxoe_96",fn="_userInteractionCardValue_vlxoe_116",vn="_userInteractionCardLabel_vlxoe_123",pn="_userInteractionCardButton_vlxoe_130",xn="_summaryStatsCards_vlxoe_148",_n="_summaryStatsCard_vlxoe_148",Cn="_summaryStatsCardValue_vlxoe_169",yn="_summaryStatsCardLabel_vlxoe_176",c={tabSelector:nn,progressSection:sn,progressLabel:rn,chartGrid:on,chartContainer:ln,tableContainer:cn,modelPerformance:dn,loadingContainer:un,errorContainer:mn,userInteractionCards:hn,userInteractionCard:gn,userInteractionCardValue:fn,userInteractionCardLabel:vn,userInteractionCardButton:pn,summaryStatsCards:xn,summaryStatsCard:_n,summaryStatsCardValue:Cn,summaryStatsCardLabel:yn};function jn(){const[m]=Dt(),[a,h]=s.useState(null),[r,f]=s.useState(!0),[g,b]=s.useState("crisis_maps"),[_,y]=s.useState([]),[x,w]=s.useState([]),[C,j]=s.useState([]),[v,S]=s.useState([]),[p,k]=s.useState(!1),[I,R]=s.useState(!1),[T,G]=s.useState(!1),[U,ie]=s.useState(!1),[ae,be]=s.useState(!1),[K,W]=s.useState(!1),E=t=>{k(t==="editTime"),R(t==="percentage"),G(t==="delete"),ie(t==="regions"),be(t==="sources"),W(t==="types")},O=[{key:"crisis_maps",label:"Crisis Maps"},{key:"drone_images",label:"Drone Images"}],A=s.useCallback((t,l)=>{if(!t||!l)return 0;const i=t.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(u=>u.length>0),n=l.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(u=>u.length>0);if(i.length===0&&n.length===0)return 1;if(i.length===0||n.length===0)return 0;const o=new Set(i),d=new Set(n),P=new Set([...o].filter(u=>d.has(u))),F=new Set([...o,...d]);return P.size/F.size},[]),X=s.useCallback(async()=>{f(!0);try{const l=await(await fetch("/api/images")).json(),i={},n=l.filter(u=>u.image_type==="crisis_map"),o=l.filter(u=>u.image_type==="drone_image"),d={totalCaptions:l.length,sources:{},types:{},regions:{},models:{},modelEditTimes:i,percentageModified:0,modelPercentageData:{},totalDeleteCount:0,deleteRate:0,crisisMaps:n,droneImages:o};l.forEach(u=>{if(u.source&&(d.sources[u.source]=(d.sources[u.source]||0)+1),u.event_type&&(d.types[u.event_type]=(d.types[u.event_type]||0)+1),u.countries&&u.countries.forEach(L=>{L.r_code&&(d.regions[L.r_code]=(d.regions[L.r_code]||0)+1)}),u.model){const L=u.model,V=d.models[L]||={count:0,avgAccuracy:0,avgContext:0,avgUsability:0,totalScore:0,deleteCount:0};if(V.count++,u.accuracy!=null&&(V.avgAccuracy+=u.accuracy),u.context!=null&&(V.avgContext+=u.context),u.usability!=null&&(V.avgUsability+=u.usability),u.created_at&&u.updated_at){const te=new Date(u.created_at).getTime(),Ce=new Date(u.updated_at).getTime()-te;Ce>0&&(i[L]||(i[L]=[]),i[L].push(Ce))}}}),_.forEach(u=>{u.s_code&&!d.sources[u.s_code]&&(d.sources[u.s_code]=0)}),x.forEach(u=>{u.t_code&&!d.types[u.t_code]&&(d.types[u.t_code]=0)}),C.forEach(u=>{u.r_code&&!d.regions[u.r_code]&&(d.regions[u.r_code]=0)}),["GPT-4","Claude","Gemini","Llama","Other"].forEach(u=>{d.models[u]||(d.models[u]={count:0,avgAccuracy:0,avgContext:0,avgUsability:0,totalScore:0,deleteCount:0})}),Object.values(d.models).forEach(u=>{u.count>0&&(u.avgAccuracy=Math.round(u.avgAccuracy/u.count),u.avgContext=Math.round(u.avgContext/u.count),u.avgUsability=Math.round(u.avgUsability/u.count),u.totalScore=Math.round((u.avgAccuracy+u.avgContext+u.avgUsability)/3))});const F=l.filter(u=>u.generated&&u.edited);if(F.length>0){const L=[...F.map(oe=>A(oe.generated,oe.edited))].sort((oe,Ce)=>oe-Ce),V=Math.floor(L.length/2),te=L.length%2===0?(L[V-1]+L[V])/2:L[V];d.percentageModified=Math.round((1-te)*100)}const H={};l.forEach(u=>{if(u.model&&u.generated&&u.edited){const L=A(u.generated,u.edited),V=Math.round((1-L)*100);H[u.model]||(H[u.model]=[]),H[u.model].push(V)}}),d.modelPercentageData=H;try{const u=await fetch("/api/models");if(u.ok){const L=await u.json();if(L.models){L.models.forEach(te=>{d.models[te.m_code]&&(d.models[te.m_code].deleteCount=te.delete_count||0)});const V=L.models.reduce((te,oe)=>te+(oe.delete_count||0),0);d.totalDeleteCount=V,d.deleteRate=V>0?Math.round(V/(V+l.length)*100):0}}}catch(u){console.log("Could not fetch model delete counts:",u)}h(d)}catch{h(null)}finally{f(!1)}},[_,x,C,A]),ne=s.useCallback(async()=>{try{const[t,l,i,n]=await Promise.all([fetch("/api/sources"),fetch("/api/types"),fetch("/api/regions"),fetch("/api/models")]),o=await t.json(),d=await l.json(),P=await i.json(),F=await n.json();y(o),w(d),j(P),S(F.models||[])}catch(t){console.log("Could not fetch lookup data:",t)}},[]);s.useEffect(()=>{const t=m.get("view");(t==="crisis_maps"||t==="drone_images")&&b(t)},[m]),s.useEffect(()=>{ne()},[ne]),s.useEffect(()=>{_.length>0&&x.length>0&&C.length>0&&v.length>0&&X()},[_,x,C,v,X]);const Y=s.useCallback(t=>{const l=_.find(i=>i.s_code===t);return l?l.label:t},[_]),M=s.useCallback(t=>{if(t.length===0)return 0;const l=[...t].sort((n,o)=>n-o),i=Math.floor(l.length/2);return l.length%2===0?Math.round((l[i-1]+l[i])/2):l[i]},[]),se=s.useCallback(t=>{const l=Math.floor(t/1e3),i=Math.floor(l/60),n=Math.floor(i/60);return n>0?`${n}h ${i%60}m`:i>0?`${i}m ${l%60}s`:`${l}s`},[]),_e=s.useCallback(t=>{const l=x.find(i=>i.t_code===t);return l?l.label:t},[x]),J=s.useCallback(t=>{const l=v.find(i=>i.m_code===t);return l?l.label:t},[v]),Se=s.useMemo(()=>a?Object.entries(a.modelEditTimes||{}).filter(([,t])=>t.length>0).sort(([,t],[,l])=>M(l)-M(t)).map(([t,l],i)=>({id:i+1,name:J(t),count:l.length,avgEditTime:M(l),minEditTime:Math.min(...l),maxEditTime:Math.max(...l)})):[],[a,M,J]),Me=s.useMemo(()=>a?Object.entries(a.modelPercentageData||{}).filter(([,t])=>t.length>0).sort(([,t],[,l])=>{const i=[...t].sort((H,u)=>H-u),n=[...l].sort((H,u)=>H-u),o=Math.floor(i.length/2),d=Math.floor(n.length/2),P=i.length%2===0?(i[o-1]+i[o])/2:i[o];return(n.length%2===0?(n[d-1]+n[d])/2:n[d])-P}).map(([t,l],i)=>{const n=[...l].sort((P,F)=>P-F),o=Math.floor(n.length/2),d=n.length%2===0?Math.round((n[o-1]+n[o])/2):n[o];return{id:i+1,name:J(t),count:l.length,avgPercentageModified:d,minPercentageModified:Math.min(...l),maxPercentageModified:Math.max(...l)}}):[],[a,J]),Ie=s.useMemo(()=>a?Object.entries(a.models).filter(([,t])=>t.count>0).map(([t,l],i)=>{const n=[l.avgAccuracy,l.avgContext,l.avgUsability],o=n.reduce((F,H)=>F+H,0)/n.length,d=n.reduce((F,H)=>F+Math.pow(H-o,2),0)/n.length,P=Math.round(100-Math.sqrt(d));return{id:i+1,name:J(t),consistency:Math.max(0,P),avgScore:Math.round(o),count:l.count}}).sort((t,l)=>l.consistency-t.consistency):[],[a,J]),De=s.useMemo(()=>[Q("name","Region",t=>t.name),D("count","Count",t=>t.count),D("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),Ee=s.useMemo(()=>[Q("name","Type",t=>t.name),D("count","Count",t=>t.count),D("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),lt=s.useMemo(()=>[Q("name","Source",t=>t.name),D("count","Count",t=>t.count),D("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),Te=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Count",t=>t.count),D("accuracy","Accuracy",t=>t.accuracy,{suffix:"%",maximumFractionDigits:0}),D("context","Context",t=>t.context,{suffix:"%",maximumFractionDigits:0}),D("usability","Usability",t=>t.usability,{suffix:"%",maximumFractionDigits:0}),D("totalScore","Total Score",t=>t.totalScore,{suffix:"%",maximumFractionDigits:0})],[]),ke=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Count",t=>t.count),Q("avgEditTime","Median Edit Time",t=>se(t.avgEditTime)),Q("minEditTime","Min Edit Time",t=>se(t.minEditTime)),Q("maxEditTime","Max Edit Time",t=>se(t.maxEditTime))],[se]),Le=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Count",t=>t.count),D("avgPercentageModified","Median % Modified",t=>t.avgPercentageModified,{suffix:"%",maximumFractionDigits:0}),D("minPercentageModified","Min % Modified",t=>t.minPercentageModified,{suffix:"%",maximumFractionDigits:0}),D("maxPercentageModified","Max % Modified",t=>t.maxPercentageModified,{suffix:"%",maximumFractionDigits:0})],[]),Pe=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Total Count",t=>t.count),D("deleteCount","Delete Count",t=>t.deleteCount),D("deleteRate","Delete Rate",t=>t.deleteRate,{suffix:"%",maximumFractionDigits:1})],[]),ct=s.useMemo(()=>[Q("source","Source",t=>t.source),D("avgQuality","Average Quality",t=>t.avgQuality,{suffix:"%",maximumFractionDigits:0}),D("count","Count",t=>t.count)],[]),Re=s.useMemo(()=>[Q("eventType","Event Type",t=>t.eventType),D("avgQuality","Average Quality",t=>t.avgQuality,{suffix:"%",maximumFractionDigits:0}),D("count","Count",t=>t.count)],[]),$e=s.useMemo(()=>[Q("name","Model",t=>t.name),D("consistency","Consistency",t=>t.consistency,{suffix:"%",maximumFractionDigits:0}),D("avgScore","Average Score",t=>t.avgScore,{suffix:"%",maximumFractionDigits:0}),D("count","Count",t=>t.count)],[]),ue=s.useCallback(t=>a?t==="crisis_map"?a.crisisMaps.length:t==="drone_image"?a.droneImages.length:0:0,[a]),Be=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.countries&&n.countries.forEach(o=>{o.r_code&&(i[o.r_code]=(i[o.r_code]||0)+1)})}),Object.entries(i).filter(([,n])=>n>0).map(([n,o])=>({name:C.find(d=>d.r_code===n)?.label||n,value:o}))},[a,C]),Ae=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};l.forEach(o=>{o.countries&&o.countries.forEach(d=>{d.r_code&&(i[d.r_code]=(i[d.r_code]||0)+1)})});const n=C.reduce((o,d)=>(d.r_code&&(o[d.r_code]={name:d.label,count:i[d.r_code]||0}),o),{});return Object.entries(n).sort(([,o],[,d])=>d.count-o.count).map(([,{name:o,count:d}],P)=>({id:P+1,name:o,count:d,percentage:l.length>0?Math.round(d/l.length*100):0}))},[a,C]),dt=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.source&&(i[n.source]=(i[n.source]||0)+1)}),Object.entries(i).filter(([,n])=>n>0).map(([n,o])=>({name:_.find(d=>d.s_code===n)?.label||n,value:o}))},[a,_]),ut=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.source&&(i[n.source]=(i[n.source]||0)+1)}),Object.entries(i).sort(([,n],[,o])=>o-n).map(([n,o],d)=>({id:d+1,name:Y(n),count:o,percentage:l.length>0?Math.round(o/l.length*100):0}))},[a,Y]),Fe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.event_type&&(i[n.event_type]=(i[n.event_type]||0)+1)}),Object.entries(i).filter(([,n])=>n>0).map(([n,o])=>({name:x.find(d=>d.t_code===n)?.label||n,value:o}))},[a,x]),Oe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.event_type&&(i[n.event_type]=(i[n.event_type]||0)+1)}),Object.entries(i).sort(([,n],[,o])=>o-n).map(([n,o],d)=>({id:d+1,name:_e(n),count:o,percentage:l.length>0?Math.round(o/l.length*100):0}))},[a,_e]),He=s.useCallback(t=>{if(!a)return"No data available";const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;l.forEach(d=>{d.model&&i.add(d.model)}),console.log(`Debug ${t}:`,{totalImages:l.length,usedModels:Array.from(i),availableEditTimes:Object.keys(a.modelEditTimes),modelEditTimesData:a.modelEditTimes});const o=Object.entries(a.modelEditTimes).filter(([d])=>i.has(d)).flatMap(([,d])=>d);return o.length===0?"No data available":se(M(o))},[a,se,M]),Ve=s.useCallback(()=>{if(!a)return"No data available";const t=a.totalCaptions||0,l=a.percentageModified||0;return t>0?Math.round(l/t*100):0},[a]),ze=s.useCallback(()=>a&&a.deleteRate>=0?`${a.deleteRate}%`:"No data available",[a]),Ue=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;return l.forEach(o=>{o.model&&i.add(o.model)}),Se.filter(o=>{const d=v.find(P=>P.label===o.name)?.m_code;return d&&i.has(d)})},[a,Se,v]),We=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;return l.forEach(o=>{o.model&&i.add(o.model)}),Me.filter(o=>{const d=v.find(P=>P.label===o.name)?.m_code;return d&&i.has(d)})},[a,Me,v]),Qe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.model&&(i[n.model]||(i[n.model]={count:0,deleteCount:0}),i[n.model].count++)}),Object.entries(i).map(([n,o],d)=>{const F=a.models?.[n]?.deleteCount||0,H=o.count>0?Math.round(F/o.count*100*10)/10:0;return{id:d+1,name:J(n),count:o.count,deleteCount:F,deleteRate:H}}).sort((n,o)=>o.count-n.count)},[a,J]),Ze=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.model&&(i[n.model]||(i[n.model]={count:0,totalAccuracy:0,totalContext:0,totalUsability:0}),i[n.model].count++,n.accuracy!=null&&(i[n.model].totalAccuracy+=n.accuracy),n.context!=null&&(i[n.model].totalContext+=n.context),n.usability!=null&&(i[n.model].totalUsability+=n.usability))}),Object.entries(i).map(([n,o],d)=>({id:d+1,name:J(n),count:o.count,accuracy:o.count>0?Math.round(o.totalAccuracy/o.count):0,context:o.count>0?Math.round(o.totalContext/o.count):0,usability:o.count>0?Math.round(o.totalUsability/o.count):0,totalScore:o.count>0?Math.round((o.totalAccuracy+o.totalContext+o.totalUsability)/(3*o.count)):0})).sort((n,o)=>o.totalScore-n.totalScore)},[a,J]),mt=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.source&&(i[n.source]||(i[n.source]={total:0,count:0,totalImages:0}),i[n.source].totalImages+=1,n.accuracy!=null&&(i[n.source].total+=n.accuracy,i[n.source].count+=1))}),Object.entries(i).map(([n,o],d)=>({id:d+1,source:Y(n),avgQuality:o.count>0?Math.round(o.total/o.count):0,count:o.totalImages}))},[a,Y]),qe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.event_type&&(i[n.event_type]||(i[n.event_type]={total:0,count:0,totalImages:0}),i[n.event_type].totalImages+=1,n.accuracy!=null&&(i[n.event_type].total+=n.accuracy,i[n.event_type].count+=1))}),Object.entries(i).map(([n,o],d)=>({id:d+1,eventType:_e(n),avgQuality:o.count>0?Math.round(o.total/o.count):0,count:o.totalImages}))},[a,_e]),Ge=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;return l.forEach(o=>{o.model&&i.add(o.model)}),Ie.filter(o=>{const d=v.find(P=>P.label===o.name)?.m_code;return d&&i.has(d)})},[a,Ie,v]);if(r)return e.jsx(je,{children:e.jsx("div",{className:c.loadingContainer,children:e.jsx(Et,{})})});if(!a)return e.jsx(je,{children:e.jsx("div",{className:c.errorContainer,children:e.jsx("div",{className:"text-red-500",children:"Failed to load analytics data. Please try again."})})});const me=["#F5333F","#F64752","#F75C65","#F87079","#F9858C","#FA999F","#FBADB2","#FCC2C5"];return e.jsx(je,{children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsx("div",{className:c.tabSelector,children:e.jsx(Tt,{name:"analytics-view",value:g,onChange:t=>{(t==="crisis_maps"||t==="drone_images")&&b(t)},options:O,keySelector:t=>t.key,labelSelector:t=>t.label})}),g==="crisis_maps"?e.jsxs("div",{className:c.chartGrid,children:[e.jsxs(z,{heading:"Summary Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.summaryStatsCards,children:[e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:ue("crisis_map")}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Total Crisis Maps"})]}),e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:"2000"}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Target Amount"})]})]}),e.jsxs("div",{className:c.progressSection,children:[e.jsxs("div",{className:c.progressLabel,children:[e.jsx("span",{children:"Progress towards target"}),e.jsxs("span",{children:[Math.round(ue("crisis_map")/2e3*100),"%"]})]}),e.jsx(Ye,{value:ue("crisis_map"),totalValue:2e3})]})]}),e.jsxs(z,{heading:"Distribution Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Regions Distribution"}),e.jsx("div",{className:c.chartContainer,children:e.jsx(xe,{data:Be("crisis_map"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-regions-details",variant:U?"primary":"secondary",onClick:()=>E(U?"none":"regions"),className:c.userInteractionCardButton,children:U?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Sources Distribution"}),e.jsx("div",{className:c.chartContainer,children:e.jsx(xe,{data:dt("crisis_map"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-sources-details",variant:ae?"primary":"secondary",onClick:()=>E(ae?"none":"sources"),className:c.userInteractionCardButton,children:ae?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Types Distribution"}),e.jsx("div",{className:c.chartContainer,children:e.jsx(xe,{data:Fe("crisis_map"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-types-details",variant:K?"primary":"secondary",onClick:()=>E(K?"none":"types"),className:c.userInteractionCardButton,children:K?"Hide Details":"View Details"})]})]}),U&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ae("crisis_map"),columns:De,keySelector:$,filtered:!1,pending:!1})}),ae&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:ut("crisis_map"),columns:lt,keySelector:$,filtered:!1,pending:!1})}),K&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Oe("crisis_map"),columns:Ee,keySelector:$,filtered:!1,pending:!1})})]}),e.jsxs(z,{heading:"User Interaction Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:He("crisis_map")}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median Edit Time"}),e.jsx(Z,{name:"view-edit-time-details",variant:p?"primary":"secondary",onClick:()=>E(p?"none":"editTime"),className:c.userInteractionCardButton,children:p?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:Ve()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median % Modified"}),e.jsx(Z,{name:"view-percentage-details",variant:I?"primary":"secondary",onClick:()=>E(I?"none":"percentage"),className:c.userInteractionCardButton,children:I?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:ze()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Delete Rate"}),e.jsx(Z,{name:"view-delete-details",variant:T?"primary":"secondary",onClick:()=>E(T?"none":"delete"),className:c.userInteractionCardButton,children:T?"Hide Details":"View Details"})]})]}),p&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ue("crisis_map"),columns:ke,keySelector:$,filtered:!1,pending:!1})}),I&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:We("crisis_map"),columns:Le,keySelector:$,filtered:!1,pending:!1})}),T&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Qe("crisis_map"),columns:Pe,keySelector:$,filtered:!1,pending:!1})})]}),e.jsx(z,{heading:"Model Performance",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ze("crisis_map"),columns:Te,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Source Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:mt("crisis_map"),columns:ct,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Event Type Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:qe("crisis_map"),columns:Re,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Model Consistency Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:Ge("crisis_map"),columns:$e,keySelector:$,filtered:!1,pending:!1})})})]}):e.jsxs("div",{className:c.chartGrid,children:[e.jsxs(z,{heading:"Summary Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.summaryStatsCards,children:[e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:ue("drone_image")}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Total Drone Images"})]}),e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:"2000"}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Target Amount"})]})]}),e.jsxs("div",{className:c.progressSection,children:[e.jsxs("div",{className:c.progressLabel,children:[e.jsx("span",{children:"Progress towards target"}),e.jsxs("span",{children:[Math.round(ue("drone_image")/2e3*100),"%"]})]}),e.jsx(Ye,{value:ue("drone_image"),totalValue:2e3})]})]}),e.jsxs(z,{heading:"Distribution Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Regions Distribution"}),e.jsx("div",{className:c.chartContainer,children:e.jsx(xe,{data:Be("drone_image"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-regions-details",variant:U?"primary":"secondary",onClick:()=>E(U?"none":"regions"),className:c.userInteractionCardButton,children:U?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Types Distribution"}),e.jsx("div",{className:c.chartContainer,children:e.jsx(xe,{data:Fe("drone_image"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-types-details",variant:K?"primary":"secondary",onClick:()=>E(K?"none":"types"),className:c.userInteractionCardButton,children:K?"Hide Details":"View Details"})]})]}),U&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ae("drone_image"),columns:De,keySelector:$,filtered:!1,pending:!1})}),K&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Oe("drone_image"),columns:Ee,keySelector:$,filtered:!1,pending:!1})})]}),e.jsxs(z,{heading:"User Interaction Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:He("drone_image")}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median Edit Time"}),e.jsx(Z,{name:"view-edit-time-details",variant:p?"primary":"secondary",onClick:()=>E(p?"none":"editTime"),className:c.userInteractionCardButton,children:p?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:Ve()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median % Modified"}),e.jsx(Z,{name:"view-percentage-details",variant:I?"primary":"secondary",onClick:()=>E(I?"none":"percentage"),className:c.userInteractionCardButton,children:I?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:ze()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Delete Rate"}),e.jsx(Z,{name:"view-delete-details",variant:T?"primary":"secondary",onClick:()=>E(T?"none":"delete"),className:c.userInteractionCardButton,children:T?"Hide Details":"View Details"})]})]}),p&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ue("drone_image"),columns:ke,keySelector:$,filtered:!1,pending:!1})}),I&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:We("drone_image"),columns:Le,keySelector:$,filtered:!1,pending:!1})}),T&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Qe("drone_image"),columns:Pe,keySelector:$,filtered:!1,pending:!1})})]}),e.jsx(z,{heading:"Model Performance",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ze("drone_image"),columns:Te,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Event Type Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:qe("drone_image"),columns:Re,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Model Consistency Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:Ge("drone_image"),columns:$e,keySelector:$,filtered:!1,pending:!1})})})]})]})})}export{jn as default}; diff --git a/py_backend/static/assets/index-RsSGWjBF.js b/py_backend/static/assets/index-CWQiqOU3.js similarity index 98% rename from py_backend/static/assets/index-RsSGWjBF.js rename to py_backend/static/assets/index-CWQiqOU3.js index 2fad88adadf5edcd1436fcf64c1be01149c2475b..07930ae80347188a5e131394bc6d27a7bfb79fbe 100644 --- a/py_backend/static/assets/index-RsSGWjBF.js +++ b/py_backend/static/assets/index-CWQiqOU3.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-BuKhrC7_.js","assets/index-DieRAFRn.js","assets/index-cCOeofBN.css"])))=>i.map(i=>d[i]); -import{j as t,z as b,n as w,v as Fe,w as De,x as Oe,B as Le,r,D as Me,N as Re,_ as me,L as Je,F as ze,G as We}from"./index-DieRAFRn.js";import{u as Ue}from"./useAdmin-SWj4UX1Y.js";import{F as Be,E as He}from"./ExportModal-BqSw_U2P.js";const Ve="_paginatorContainer_1l5ti_1",Ae="_paginationControls_1l5ti_19",ge={paginatorContainer:Ve,paginationControls:Ae};function Ge({currentPage:N,totalPages:u,onPageChange:$,className:z=""}){if(u<=1)return null;const f=(()=>{const h=[];if(u<=5)for(let p=1;p<=u;p++)h.push(p);else{let p=Math.max(1,N-2);const _=Math.min(u,p+5-1);_===u&&(p=Math.max(1,_-5+1));for(let y=p;y<=_;y++)h.push(y)}return h})();return t.jsx("div",{className:`${ge.paginatorContainer} ${z}`,children:t.jsxs("div",{className:ge.paginationControls,children:[t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsxs(w,{name:"prev-page",variant:"tertiary",size:1,onClick:()=>$(Math.max(1,N-1)),disabled:N===1,title:"Previous page",children:[t.jsx(Fe,{className:"w-4 h-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Previous"})]})}),t.jsxs("div",{className:"flex items-center gap-1",children:[f[0]>1&&t.jsxs(t.Fragment,{children:[t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:"page-1",variant:"tertiary",size:1,onClick:()=>$(1),children:"1"})}),f[0]>2&&t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx("span",{className:"px-2 text-gray-500",children:"..."})})]}),f.map(h=>t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:`page-${h}`,variant:N===h?"primary":"tertiary",size:1,onClick:()=>$(h),children:h})},h)),f[f.length-1]$(u),children:u})})]})]}),t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsxs(w,{name:"next-page",variant:"tertiary",size:1,onClick:()=>$(Math.min(u,N+1)),disabled:N===u,title:"Next page",children:[t.jsx("span",{className:"hidden sm:inline",children:"Next"}),t.jsx(De,{className:"w-4 h-4"})]})})]})})}const Ze="_tabSelector_o9y1f_1",qe="_metadataTags_o9y1f_8",Ke="_metadataTag_o9y1f_8",Qe="_metadataTagSource_o9y1f_32",Xe="_metadataTagType_o9y1f_43",Ye="_mapItem_o9y1f_54",et="_mapItemImage_o9y1f_72",tt="_mapItemContent_o9y1f_92",at="_mapItemTitle_o9y1f_97",st="_mapItemMetadata_o9y1f_105",it="_fullSizeModalOverlay_o9y1f_134",nt="_fullSizeModalContent_o9y1f_148",lt="_ratingWarningContent_o9y1f_159",rt="_ratingWarningTitle_o9y1f_165",ot="_ratingWarningText_o9y1f_172",ct="_ratingWarningButtons_o9y1f_179",m={tabSelector:Ze,metadataTags:qe,metadataTag:Ke,metadataTagSource:Qe,metadataTagType:Xe,mapItem:Ye,mapItemImage:et,mapItemContent:tt,mapItemTitle:at,mapItemMetadata:st,fullSizeModalOverlay:it,fullSizeModalContent:nt,ratingWarningContent:lt,ratingWarningTitle:rt,ratingWarningText:ot,ratingWarningButtons:ct};function pt(){const N=Oe(),u=Le(),{isAuthenticated:$}=Ue(),[z,Y]=r.useState("explore"),[f,h]=r.useState([]),{search:S,srcFilter:p,catFilter:_,regionFilter:y,countryFilter:E,imageTypeFilter:I,uploadTypeFilter:k,showReferenceExamples:T,setShowReferenceExamples:pe}=Me(),[V,ue]=r.useState([]),[A,fe]=r.useState([]),[ee,he]=r.useState([]),[xe,_e]=r.useState([]),[te,ye]=r.useState([]),[je,ae]=r.useState(!0),[W,se]=r.useState(!0),[Ne,G]=r.useState(!1),[ve,Z]=r.useState(!1),[be,q]=r.useState(!1),[we,U]=r.useState(!1),[B,ie]=r.useState(""),[K,ne]=r.useState(!1),[L,le]=r.useState(1),[M]=r.useState(10),[Q,re]=r.useState(0),[Se,oe]=r.useState(0),Te=[{key:"explore",label:"List"},{key:"mapDetails",label:"Carousel"}],H=r.useCallback(()=>{se(!0);const e=new URLSearchParams({page:L.toString(),limit:M.toString()});S&&e.append("search",S),p&&e.append("source",p),_&&e.append("event_type",_),y&&e.append("region",y),E&&e.append("country",E),I&&e.append("image_type",I),k&&e.append("upload_type",k),T&&e.append("starred_only","true"),fetch(`/api/images/grouped?${e.toString()}`).then(s=>s.ok?s.json():(console.error("ExplorePage: Grouped endpoint failed, trying legacy endpoint"),fetch("/api/captions/legacy").then(c=>c.ok?c.json():(console.error("ExplorePage: Legacy endpoint failed, trying regular images endpoint"),fetch("/api/images").then(j=>{if(!j.ok)throw new Error(`HTTP ${j.status}: ${j.statusText}`);return j.json()}))))).then(s=>{console.log("ExplorePage: Fetched captions:",s),h(s)}).catch(s=>{console.error("ExplorePage: Error fetching captions:",s),h([])}).finally(()=>{se(!1)})},[L,S,p,_,y,E,I,k,T,M]),ce=r.useCallback(()=>{const e=new URLSearchParams;S&&e.append("search",S),p&&e.append("source",p),_&&e.append("event_type",_),y&&e.append("region",y),E&&e.append("country",E),I&&e.append("image_type",I),k&&e.append("upload_type",k),T&&e.append("starred_only","true"),fetch(`/api/images/grouped/count?${e.toString()}`).then(s=>s.ok?s.json():(console.error("ExplorePage: Count endpoint failed"),{total_count:0})).then(s=>{console.log("ExplorePage: Total count:",s.total_count),re(s.total_count),oe(Math.ceil(s.total_count/M))}).catch(s=>{console.error("ExplorePage: Error fetching total count:",s),re(0),oe(0)})},[S,p,_,y,E,I,k,T,M]);r.useEffect(()=>{H(),ce()},[H,ce]),r.useEffect(()=>{L!==1&&le(1)},[L]),r.useEffect(()=>{const e=()=>{document.hidden||H()};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[H]),r.useEffect(()=>{new URLSearchParams(u.search).get("export")==="true"&&(G(!0),N("/explore",{replace:!0}))},[u.search,N,S,p,_,y,E,I,T]),r.useEffect(()=>{ae(!0),Promise.all([fetch("/api/sources").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/regions").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/countries").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/image-types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()})]).then(([e,s,c,j,P])=>{ue(e),fe(s),he(c),_e(j),ye(P)}).catch(()=>{}).finally(()=>{ae(!1)})},[]);const C=f,Ee=async(e,s="fine-tuning")=>{if(e.length===0){alert("No images to export");return}Z(!0),q(!1);try{const c=(await We(async()=>{const{default:i}=await import("./jszip.min-BuKhrC7_.js").then(F=>F.j);return{default:i}},__vite__mapDeps([0,1,2]))).default,j=new c,P=e.filter(i=>i.image_type==="crisis_map"),R=e.filter(i=>i.image_type==="drone_image");if(P.length>0){const i=j.folder("crisis_maps_dataset"),F=i?.folder("images");if(F){let D=1;for(const a of P)try{const v=a.image_count&&a.image_count>1?a.all_image_ids||[a.image_id]:[a.image_id],X=v.map(async(n,x)=>{try{const l=await fetch(`/api/images/${n}/file`);if(!l.ok)throw new Error(`Failed to fetch image ${n}`);const o=await l.blob(),d=a.file_key.split(".").pop()||"jpg",g=`${String(D).padStart(4,"0")}_${String(x+1).padStart(2,"0")}.${d}`;return F.file(g,o),{success:!0,fileName:g,imageId:n}}catch(l){return console.error(`Failed to process image ${n}:`,l),{success:!1,fileName:"",imageId:n}}}),O=(await Promise.all(X)).filter(n=>n.success);if(O.length>0){if(s==="fine-tuning"){const n=O.map(o=>`images/${o.fileName}`),x=Math.random(),l={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};if(!i)continue;if(x<.8){const o=i.file("train.jsonl");if(o){const d=await o.async("string").then(g=>JSON.parse(g||"[]")).catch(()=>[]);d.push(l),i.file("train.jsonl",JSON.stringify(d,null,2))}else i.file("train.jsonl",JSON.stringify([l],null,2))}else if(x<.9){const o=i.file("test.jsonl");if(o){const d=await o.async("string").then(g=>JSON.parse(g||"[]")).catch(()=>[]);d.push(l),i.file("test.jsonl",JSON.stringify(d,null,2))}else i.file("test.jsonl",JSON.stringify([l],null,2))}else{const o=i.file("val.jsonl");if(o){const d=await o.async("string").then(g=>JSON.parse(g||"[]")).catch(()=>[]);d.push(l),i.file("val.jsonl",JSON.stringify(d,null,2))}else i.file("val.jsonl",JSON.stringify([l],null,2))}}else{const n=O.map(l=>`images/${l.fileName}`),x={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};i&&i.file(`${String(D).padStart(4,"0")}.json`,JSON.stringify(x,null,2))}D++}}catch(v){console.error(`Failed to process caption ${a.image_id}:`,v)}}}if(R.length>0){const i=j.folder("drone_images_dataset"),F=i?.folder("images");if(F){let D=1;for(const a of R)try{const v=a.image_count&&a.image_count>1?a.all_image_ids||[a.image_id]:[a.image_id],X=v.map(async(n,x)=>{try{const l=await fetch(`/api/images/${n}/file`);if(!l.ok)throw new Error(`Failed to fetch image ${n}`);const o=await l.blob(),d=a.file_key.split(".").pop()||"jpg",g=`${String(D).padStart(4,"0")}_${String(x+1).padStart(2,"0")}.${d}`;return F.file(g,o),{success:!0,fileName:g,imageId:n}}catch(l){return console.error(`Failed to process image ${n}:`,l),{success:!1,fileName:"",imageId:n}}}),O=(await Promise.all(X)).filter(n=>n.success);if(O.length>0){if(s==="fine-tuning"){const n=O.map(o=>`images/${o.fileName}`),x=Math.random(),l={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};if(!i)continue;if(x<.8){const o=i.file("train.jsonl");if(o){const d=await o.async("string").then(g=>JSON.parse(g||"[]")).catch(()=>[]);d.push(l),i.file("train.jsonl",JSON.stringify(d,null,2))}else i.file("train.jsonl",JSON.stringify([l],null,2))}else if(x<.9){const o=i.file("test.jsonl");if(o){const d=await o.async("string").then(g=>JSON.parse(g||"[]")).catch(()=>[]);d.push(l),i.file("test.jsonl",JSON.stringify(d,null,2))}else i.file("test.jsonl",JSON.stringify([l],null,2))}else{const o=i.file("val.jsonl");if(o){const d=await o.async("string").then(g=>JSON.parse(g||"[]")).catch(()=>[]);d.push(l),i.file("val.jsonl",JSON.stringify(d,null,2))}else i.file("val.jsonl",JSON.stringify([l],null,2))}}else{const n=O.map(l=>`images/${l.fileName}`),x={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};i&&i.file(`${String(D).padStart(4,"0")}.json`,JSON.stringify(x,null,2))}D++}}catch(v){console.error(`Failed to process caption ${a.image_id}:`,v)}}}const $e=await j.generateAsync({type:"blob"}),de=URL.createObjectURL($e),J=document.createElement("a");J.href=de,J.download=`datasets_${s}_${new Date().toISOString().split("T")[0]}.zip`,document.body.appendChild(J),J.click(),document.body.removeChild(J),URL.revokeObjectURL(de);const ke=(P.length||0)+(R.length||0);console.log(`Exported ${s} datasets with ${ke} total images:`),P.length>0&&console.log(`- Crisis maps: ${P.length} images`),R.length>0&&console.log(`- Drone images: ${R.length} images`),q(!0)}catch(c){console.error("Export failed:",c),alert("Failed to export dataset. Please try again.")}finally{Z(!1)}},Ie=e=>{ie(e),U(!0)},Ce=async()=>{if(B){ne(!0);try{console.log("Deleting image with ID:",B),(await fetch(`/api/images/${B}`,{method:"DELETE"})).ok?(h(s=>s.filter(c=>c.image_id!==B)),U(!1),ie("")):(console.error("Delete failed"),alert("Failed to delete image. Please try again."))}catch(e){console.error("Delete failed:",e),alert("Failed to delete image. Please try again.")}finally{ne(!1)}}};return t.jsxs(Re,{children:[W?t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[60vh]",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(me,{className:"text-ifrcRed"}),t.jsx("div",{children:"Loading examples..."})]})}):t.jsxs("div",{className:"max-w-7xl mx-auto",children:[t.jsxs("div",{className:m.tabSelector,children:[t.jsx(Je,{name:"explore-view",value:z,onChange:e=>{(e==="explore"||e==="mapDetails")&&(Y(e),e==="mapDetails"&&f.length>0&&(f[0]?.image_id&&f[0].image_id!=="undefined"&&f[0].image_id!=="null"?N(`/map/${f[0].image_id}`):console.error("Invalid image_id for navigation:",f[0]?.image_id)))},options:Te,keySelector:e=>e.key,labelSelector:e=>e.label}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsxs(w,{name:"reference-examples",variant:T?"primary":"secondary",onClick:()=>pe(!T),className:"whitespace-nowrap",children:[t.jsx("span",{className:"mr-2",children:T?t.jsx("span",{className:"text-yellow-400",children:"★"}):t.jsx("span",{className:"text-yellow-400",children:"☆"})}),"Reference Examples"]})}),t.jsx(w,{name:"export-dataset",variant:"secondary",onClick:()=>G(!0),children:"Export"})]})]}),z==="explore"?t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"mb-6 space-y-4",children:t.jsx("div",{className:"flex flex-wrap items-center gap-4",children:t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2 flex-1 min-w-[300px]",children:t.jsx(Be,{sources:V,types:A,regions:ee,countries:xe,imageTypes:te,isLoadingFilters:je})})})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex justify-between items-center",children:t.jsxs("p",{className:"text-sm text-gray-600",children:[C.length," of ",Q," examples"]})}),W&&t.jsx("div",{className:"text-center py-12",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(me,{className:"text-ifrcRed"}),t.jsx("div",{children:"Loading examples..."})]})}),!W&&t.jsxs("div",{className:"space-y-4",children:[C.map(e=>t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:`${m.mapItem} flex-1`,onClick:()=>{console.log("ExplorePage: Clicking on image with ID:",e.image_id),console.log("ExplorePage: Image data:",e),e.image_id&&e.image_id!=="undefined"&&e.image_id!=="null"?(console.log("ExplorePage: Navigating to:",`/map/${e.image_id}`),console.log("ExplorePage: Full navigation URL:",`/#/map/${e.image_id}`),N(`/map/${e.image_id}`)):(console.error("Invalid image_id for navigation:",e.image_id),console.error("Full item data:",JSON.stringify(e,null,2)),alert(`Cannot navigate: Invalid image ID (${e.image_id})`))},children:[t.jsx("div",{className:m.mapItemImage,style:{width:"120px",height:"80px"},children:e.thumbnail_url?t.jsxs(t.Fragment,{children:[console.log("ExplorePage: Using thumbnail for fast loading:",e.thumbnail_url),t.jsx("img",{src:e.thumbnail_url,alt:e.file_key,onError:s=>{console.error("ExplorePage: Thumbnail failed to load, falling back to original:",e.thumbnail_url);const c=s.target;e.image_url?c.src=e.image_url:(c.style.display="none",c.parentElement.innerHTML="Img")},onLoad:()=>console.log("ExplorePage: Thumbnail loaded successfully:",e.thumbnail_url)})]}):e.image_url?t.jsxs(t.Fragment,{children:[console.log("ExplorePage: No thumbnail available, using original image:",e.image_url),t.jsx("img",{src:e.image_url,alt:e.file_key,onError:s=>{console.error("ExplorePage: Original image failed to load:",e.image_url);const c=s.target;c.style.display="none",c.parentElement.innerHTML="Img"},onLoad:()=>console.log("ExplorePage: Original image loaded successfully:",e.image_url)})]}):t.jsxs(t.Fragment,{children:[console.log("ExplorePage: No image_url or thumbnail provided for item:",e),"'Img'"]})}),t.jsxs("div",{className:m.mapItemContent,children:[t.jsx("h3",{className:m.mapItemTitle,children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{children:e.title||"Untitled"}),e.starred&&t.jsx("span",{className:"text-red-500 text-lg",title:"Starred image",children:"★"})]})}),t.jsx("div",{className:m.mapItemMetadata,children:t.jsxs("div",{className:m.metadataTags,children:[e.image_type!=="drone_image"&&t.jsx("span",{className:m.metadataTagSource,children:e.source&&e.source.includes(", ")?e.source.split(", ").map(s=>V.find(c=>c.s_code===s.trim())?.label||s.trim()).join(", "):V.find(s=>s.s_code===e.source)?.label||e.source}),t.jsx("span",{className:m.metadataTagType,children:e.event_type&&e.event_type.includes(", ")?e.event_type.split(", ").map(s=>A.find(c=>c.t_code===s.trim())?.label||s.trim()).join(", "):A.find(s=>s.t_code===e.event_type)?.label||e.event_type}),t.jsx("span",{className:m.metadataTag,children:te.find(s=>s.image_type===e.image_type)?.label||e.image_type}),e.image_count&&e.image_count>1&&t.jsxs("span",{className:m.metadataTag,title:`Multi-upload with ${e.image_count} images`,children:["📷 ",e.image_count]}),(!e.image_count||e.image_count<=1)&&t.jsx("span",{className:m.metadataTag,title:"Single Upload",children:"Single"}),e.countries&&e.countries.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:m.metadataTag,children:ee.find(s=>s.r_code===e.countries[0].r_code)?.label||"Unknown Region"}),t.jsx("span",{className:m.metadataTag,children:e.countries.map(s=>s.label).join(", ")})]})]})})]})]}),$&&t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:`delete-${e.image_id}`,variant:"tertiary",size:1,className:"bg-red-50 hover:bg-red-100 text-red-700 border border-red-200 hover:border-red-300",onClick:()=>Ie(e.image_id),title:"Delete","aria-label":"Delete saved image",children:t.jsx(ze,{className:"w-4 h-4"})})})]},e.image_id)),!C.length&&t.jsx("div",{className:"text-center py-12",children:t.jsx("p",{className:"text-gray-500",children:"No examples found."})}),!W&&C.length>0&&t.jsx(Ge,{currentPage:L,totalPages:Se,totalItems:Q,itemsPerPage:M,onPageChange:le})]})]})]}):t.jsx("div",{className:"space-y-6",children:t.jsxs("div",{className:"text-center py-12",children:[t.jsx("p",{className:"text-gray-500",children:"Map Details view coming soon..."}),t.jsx("p",{className:"text-sm text-gray-400 mt-2",children:"This will show detailed information about individual maps"})]})})]}),we&&t.jsx("div",{className:m.fullSizeModalOverlay,onClick:()=>U(!1),children:t.jsx("div",{className:m.fullSizeModalContent,onClick:e=>e.stopPropagation(),children:t.jsxs("div",{className:m.ratingWarningContent,children:[t.jsx("h3",{className:m.ratingWarningTitle,children:"Delete Image?"}),t.jsx("p",{className:m.ratingWarningText,children:"This action cannot be undone. Are you sure you want to delete this saved image and all related data?"}),t.jsxs("div",{className:m.ratingWarningButtons,children:[t.jsx(w,{name:"confirm-delete",variant:"secondary",onClick:Ce,disabled:K,children:K?"Deleting...":"Delete"}),t.jsx(w,{name:"cancel-delete",variant:"tertiary",onClick:()=>U(!1),disabled:K,children:"Cancel"})]})]})})}),t.jsx(He,{isOpen:Ne,onClose:()=>{G(!1),q(!1),Z(!1)},onExport:(e,s)=>{const c=C.filter(j=>s.includes(j.image_type));Ee(c,e)},filteredCount:C.length,totalCount:Q,hasFilters:!!(S||p||_||y||E||I||k||T),crisisMapsCount:C.filter(e=>e.image_type==="crisis_map").length,droneImagesCount:C.filter(e=>e.image_type==="drone_image").length,isLoading:ve,exportSuccess:be})]})}export{pt as default}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-uuN5m5dK.js","assets/index-B0L3qvtx.js","assets/index-cCOeofBN.css"])))=>i.map(i=>d[i]); +import{j as t,z as b,n as w,v as Fe,w as De,x as Oe,B as Le,r,D as Me,N as Re,_ as me,L as Je,F as ze,G as We}from"./index-B0L3qvtx.js";import{u as Ue}from"./useAdmin-DN0iYnPm.js";import{F as Be,E as He}from"./ExportModal-BI_JlHOZ.js";const Ve="_paginatorContainer_1l5ti_1",Ae="_paginationControls_1l5ti_19",ge={paginatorContainer:Ve,paginationControls:Ae};function Ge({currentPage:N,totalPages:u,onPageChange:$,className:z=""}){if(u<=1)return null;const f=(()=>{const h=[];if(u<=5)for(let p=1;p<=u;p++)h.push(p);else{let p=Math.max(1,N-2);const _=Math.min(u,p+5-1);_===u&&(p=Math.max(1,_-5+1));for(let y=p;y<=_;y++)h.push(y)}return h})();return t.jsx("div",{className:`${ge.paginatorContainer} ${z}`,children:t.jsxs("div",{className:ge.paginationControls,children:[t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsxs(w,{name:"prev-page",variant:"tertiary",size:1,onClick:()=>$(Math.max(1,N-1)),disabled:N===1,title:"Previous page",children:[t.jsx(Fe,{className:"w-4 h-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Previous"})]})}),t.jsxs("div",{className:"flex items-center gap-1",children:[f[0]>1&&t.jsxs(t.Fragment,{children:[t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:"page-1",variant:"tertiary",size:1,onClick:()=>$(1),children:"1"})}),f[0]>2&&t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx("span",{className:"px-2 text-gray-500",children:"..."})})]}),f.map(h=>t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:`page-${h}`,variant:N===h?"primary":"tertiary",size:1,onClick:()=>$(h),children:h})},h)),f[f.length-1]$(u),children:u})})]})]}),t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsxs(w,{name:"next-page",variant:"tertiary",size:1,onClick:()=>$(Math.min(u,N+1)),disabled:N===u,title:"Next page",children:[t.jsx("span",{className:"hidden sm:inline",children:"Next"}),t.jsx(De,{className:"w-4 h-4"})]})})]})})}const Ze="_tabSelector_o9y1f_1",qe="_metadataTags_o9y1f_8",Ke="_metadataTag_o9y1f_8",Qe="_metadataTagSource_o9y1f_32",Xe="_metadataTagType_o9y1f_43",Ye="_mapItem_o9y1f_54",et="_mapItemImage_o9y1f_72",tt="_mapItemContent_o9y1f_92",at="_mapItemTitle_o9y1f_97",st="_mapItemMetadata_o9y1f_105",it="_fullSizeModalOverlay_o9y1f_134",nt="_fullSizeModalContent_o9y1f_148",lt="_ratingWarningContent_o9y1f_159",rt="_ratingWarningTitle_o9y1f_165",ot="_ratingWarningText_o9y1f_172",ct="_ratingWarningButtons_o9y1f_179",m={tabSelector:Ze,metadataTags:qe,metadataTag:Ke,metadataTagSource:Qe,metadataTagType:Xe,mapItem:Ye,mapItemImage:et,mapItemContent:tt,mapItemTitle:at,mapItemMetadata:st,fullSizeModalOverlay:it,fullSizeModalContent:nt,ratingWarningContent:lt,ratingWarningTitle:rt,ratingWarningText:ot,ratingWarningButtons:ct};function pt(){const N=Oe(),u=Le(),{isAuthenticated:$}=Ue(),[z,Y]=r.useState("explore"),[f,h]=r.useState([]),{search:S,srcFilter:p,catFilter:_,regionFilter:y,countryFilter:E,imageTypeFilter:I,uploadTypeFilter:k,showReferenceExamples:T,setShowReferenceExamples:pe}=Me(),[V,ue]=r.useState([]),[A,fe]=r.useState([]),[ee,he]=r.useState([]),[xe,_e]=r.useState([]),[te,ye]=r.useState([]),[je,ae]=r.useState(!0),[W,se]=r.useState(!0),[Ne,G]=r.useState(!1),[ve,Z]=r.useState(!1),[be,q]=r.useState(!1),[we,U]=r.useState(!1),[B,ie]=r.useState(""),[K,ne]=r.useState(!1),[L,le]=r.useState(1),[M]=r.useState(10),[Q,re]=r.useState(0),[Se,oe]=r.useState(0),Te=[{key:"explore",label:"List"},{key:"mapDetails",label:"Carousel"}],H=r.useCallback(()=>{se(!0);const e=new URLSearchParams({page:L.toString(),limit:M.toString()});S&&e.append("search",S),p&&e.append("source",p),_&&e.append("event_type",_),y&&e.append("region",y),E&&e.append("country",E),I&&e.append("image_type",I),k&&e.append("upload_type",k),T&&e.append("starred_only","true"),fetch(`/api/images/grouped?${e.toString()}`).then(s=>s.ok?s.json():(console.error("ExplorePage: Grouped endpoint failed, trying legacy endpoint"),fetch("/api/captions/legacy").then(c=>c.ok?c.json():(console.error("ExplorePage: Legacy endpoint failed, trying regular images endpoint"),fetch("/api/images").then(j=>{if(!j.ok)throw new Error(`HTTP ${j.status}: ${j.statusText}`);return j.json()}))))).then(s=>{console.log("ExplorePage: Fetched captions:",s),h(s)}).catch(s=>{console.error("ExplorePage: Error fetching captions:",s),h([])}).finally(()=>{se(!1)})},[L,S,p,_,y,E,I,k,T,M]),ce=r.useCallback(()=>{const e=new URLSearchParams;S&&e.append("search",S),p&&e.append("source",p),_&&e.append("event_type",_),y&&e.append("region",y),E&&e.append("country",E),I&&e.append("image_type",I),k&&e.append("upload_type",k),T&&e.append("starred_only","true"),fetch(`/api/images/grouped/count?${e.toString()}`).then(s=>s.ok?s.json():(console.error("ExplorePage: Count endpoint failed"),{total_count:0})).then(s=>{console.log("ExplorePage: Total count:",s.total_count),re(s.total_count),oe(Math.ceil(s.total_count/M))}).catch(s=>{console.error("ExplorePage: Error fetching total count:",s),re(0),oe(0)})},[S,p,_,y,E,I,k,T,M]);r.useEffect(()=>{H(),ce()},[H,ce]),r.useEffect(()=>{L!==1&&le(1)},[L]),r.useEffect(()=>{const e=()=>{document.hidden||H()};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[H]),r.useEffect(()=>{new URLSearchParams(u.search).get("export")==="true"&&(G(!0),N("/explore",{replace:!0}))},[u.search,N,S,p,_,y,E,I,T]),r.useEffect(()=>{ae(!0),Promise.all([fetch("/api/sources").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/regions").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/countries").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/image-types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()})]).then(([e,s,c,j,P])=>{ue(e),fe(s),he(c),_e(j),ye(P)}).catch(()=>{}).finally(()=>{ae(!1)})},[]);const C=f,Ee=async(e,s="fine-tuning")=>{if(e.length===0){alert("No images to export");return}Z(!0),q(!1);try{const c=(await We(async()=>{const{default:i}=await import("./jszip.min-uuN5m5dK.js").then(F=>F.j);return{default:i}},__vite__mapDeps([0,1,2]))).default,j=new c,P=e.filter(i=>i.image_type==="crisis_map"),R=e.filter(i=>i.image_type==="drone_image");if(P.length>0){const i=j.folder("crisis_maps_dataset"),F=i?.folder("images");if(F){let D=1;for(const a of P)try{const v=a.image_count&&a.image_count>1?a.all_image_ids||[a.image_id]:[a.image_id],X=v.map(async(n,x)=>{try{const l=await fetch(`/api/images/${n}/file`);if(!l.ok)throw new Error(`Failed to fetch image ${n}`);const o=await l.blob(),d=a.file_key.split(".").pop()||"jpg",g=`${String(D).padStart(4,"0")}_${String(x+1).padStart(2,"0")}.${d}`;return F.file(g,o),{success:!0,fileName:g,imageId:n}}catch(l){return console.error(`Failed to process image ${n}:`,l),{success:!1,fileName:"",imageId:n}}}),O=(await Promise.all(X)).filter(n=>n.success);if(O.length>0){if(s==="fine-tuning"){const n=O.map(o=>`images/${o.fileName}`),x=Math.random(),l={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};if(!i)continue;if(x<.8){const o=i.file("train.jsonl");if(o){const d=await o.async("string").then(g=>JSON.parse(g||"[]")).catch(()=>[]);d.push(l),i.file("train.jsonl",JSON.stringify(d,null,2))}else i.file("train.jsonl",JSON.stringify([l],null,2))}else if(x<.9){const o=i.file("test.jsonl");if(o){const d=await o.async("string").then(g=>JSON.parse(g||"[]")).catch(()=>[]);d.push(l),i.file("test.jsonl",JSON.stringify(d,null,2))}else i.file("test.jsonl",JSON.stringify([l],null,2))}else{const o=i.file("val.jsonl");if(o){const d=await o.async("string").then(g=>JSON.parse(g||"[]")).catch(()=>[]);d.push(l),i.file("val.jsonl",JSON.stringify(d,null,2))}else i.file("val.jsonl",JSON.stringify([l],null,2))}}else{const n=O.map(l=>`images/${l.fileName}`),x={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};i&&i.file(`${String(D).padStart(4,"0")}.json`,JSON.stringify(x,null,2))}D++}}catch(v){console.error(`Failed to process caption ${a.image_id}:`,v)}}}if(R.length>0){const i=j.folder("drone_images_dataset"),F=i?.folder("images");if(F){let D=1;for(const a of R)try{const v=a.image_count&&a.image_count>1?a.all_image_ids||[a.image_id]:[a.image_id],X=v.map(async(n,x)=>{try{const l=await fetch(`/api/images/${n}/file`);if(!l.ok)throw new Error(`Failed to fetch image ${n}`);const o=await l.blob(),d=a.file_key.split(".").pop()||"jpg",g=`${String(D).padStart(4,"0")}_${String(x+1).padStart(2,"0")}.${d}`;return F.file(g,o),{success:!0,fileName:g,imageId:n}}catch(l){return console.error(`Failed to process image ${n}:`,l),{success:!1,fileName:"",imageId:n}}}),O=(await Promise.all(X)).filter(n=>n.success);if(O.length>0){if(s==="fine-tuning"){const n=O.map(o=>`images/${o.fileName}`),x=Math.random(),l={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};if(!i)continue;if(x<.8){const o=i.file("train.jsonl");if(o){const d=await o.async("string").then(g=>JSON.parse(g||"[]")).catch(()=>[]);d.push(l),i.file("train.jsonl",JSON.stringify(d,null,2))}else i.file("train.jsonl",JSON.stringify([l],null,2))}else if(x<.9){const o=i.file("test.jsonl");if(o){const d=await o.async("string").then(g=>JSON.parse(g||"[]")).catch(()=>[]);d.push(l),i.file("test.jsonl",JSON.stringify(d,null,2))}else i.file("test.jsonl",JSON.stringify([l],null,2))}else{const o=i.file("val.jsonl");if(o){const d=await o.async("string").then(g=>JSON.parse(g||"[]")).catch(()=>[]);d.push(l),i.file("val.jsonl",JSON.stringify(d,null,2))}else i.file("val.jsonl",JSON.stringify([l],null,2))}}else{const n=O.map(l=>`images/${l.fileName}`),x={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};i&&i.file(`${String(D).padStart(4,"0")}.json`,JSON.stringify(x,null,2))}D++}}catch(v){console.error(`Failed to process caption ${a.image_id}:`,v)}}}const $e=await j.generateAsync({type:"blob"}),de=URL.createObjectURL($e),J=document.createElement("a");J.href=de,J.download=`datasets_${s}_${new Date().toISOString().split("T")[0]}.zip`,document.body.appendChild(J),J.click(),document.body.removeChild(J),URL.revokeObjectURL(de);const ke=(P.length||0)+(R.length||0);console.log(`Exported ${s} datasets with ${ke} total images:`),P.length>0&&console.log(`- Crisis maps: ${P.length} images`),R.length>0&&console.log(`- Drone images: ${R.length} images`),q(!0)}catch(c){console.error("Export failed:",c),alert("Failed to export dataset. Please try again.")}finally{Z(!1)}},Ie=e=>{ie(e),U(!0)},Ce=async()=>{if(B){ne(!0);try{console.log("Deleting image with ID:",B),(await fetch(`/api/images/${B}`,{method:"DELETE"})).ok?(h(s=>s.filter(c=>c.image_id!==B)),U(!1),ie("")):(console.error("Delete failed"),alert("Failed to delete image. Please try again."))}catch(e){console.error("Delete failed:",e),alert("Failed to delete image. Please try again.")}finally{ne(!1)}}};return t.jsxs(Re,{children:[W?t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[60vh]",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(me,{className:"text-ifrcRed"}),t.jsx("div",{children:"Loading examples..."})]})}):t.jsxs("div",{className:"max-w-7xl mx-auto",children:[t.jsxs("div",{className:m.tabSelector,children:[t.jsx(Je,{name:"explore-view",value:z,onChange:e=>{(e==="explore"||e==="mapDetails")&&(Y(e),e==="mapDetails"&&f.length>0&&(f[0]?.image_id&&f[0].image_id!=="undefined"&&f[0].image_id!=="null"?N(`/map/${f[0].image_id}`):console.error("Invalid image_id for navigation:",f[0]?.image_id)))},options:Te,keySelector:e=>e.key,labelSelector:e=>e.label}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsxs(w,{name:"reference-examples",variant:T?"primary":"secondary",onClick:()=>pe(!T),className:"whitespace-nowrap",children:[t.jsx("span",{className:"mr-2",children:T?t.jsx("span",{className:"text-yellow-400",children:"★"}):t.jsx("span",{className:"text-yellow-400",children:"☆"})}),"Reference Examples"]})}),t.jsx(w,{name:"export-dataset",variant:"secondary",onClick:()=>G(!0),children:"Export"})]})]}),z==="explore"?t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"mb-6 space-y-4",children:t.jsx("div",{className:"flex flex-wrap items-center gap-4",children:t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2 flex-1 min-w-[300px]",children:t.jsx(Be,{sources:V,types:A,regions:ee,countries:xe,imageTypes:te,isLoadingFilters:je})})})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex justify-between items-center",children:t.jsxs("p",{className:"text-sm text-gray-600",children:[C.length," of ",Q," examples"]})}),W&&t.jsx("div",{className:"text-center py-12",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(me,{className:"text-ifrcRed"}),t.jsx("div",{children:"Loading examples..."})]})}),!W&&t.jsxs("div",{className:"space-y-4",children:[C.map(e=>t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:`${m.mapItem} flex-1`,onClick:()=>{console.log("ExplorePage: Clicking on image with ID:",e.image_id),console.log("ExplorePage: Image data:",e),e.image_id&&e.image_id!=="undefined"&&e.image_id!=="null"?(console.log("ExplorePage: Navigating to:",`/map/${e.image_id}`),console.log("ExplorePage: Full navigation URL:",`/#/map/${e.image_id}`),N(`/map/${e.image_id}`)):(console.error("Invalid image_id for navigation:",e.image_id),console.error("Full item data:",JSON.stringify(e,null,2)),alert(`Cannot navigate: Invalid image ID (${e.image_id})`))},children:[t.jsx("div",{className:m.mapItemImage,style:{width:"120px",height:"80px"},children:e.thumbnail_url?t.jsxs(t.Fragment,{children:[console.log("ExplorePage: Using thumbnail for fast loading:",e.thumbnail_url),t.jsx("img",{src:e.thumbnail_url,alt:e.file_key,onError:s=>{console.error("ExplorePage: Thumbnail failed to load, falling back to original:",e.thumbnail_url);const c=s.target;e.image_url?c.src=e.image_url:(c.style.display="none",c.parentElement.innerHTML="Img")},onLoad:()=>console.log("ExplorePage: Thumbnail loaded successfully:",e.thumbnail_url)})]}):e.image_url?t.jsxs(t.Fragment,{children:[console.log("ExplorePage: No thumbnail available, using original image:",e.image_url),t.jsx("img",{src:e.image_url,alt:e.file_key,onError:s=>{console.error("ExplorePage: Original image failed to load:",e.image_url);const c=s.target;c.style.display="none",c.parentElement.innerHTML="Img"},onLoad:()=>console.log("ExplorePage: Original image loaded successfully:",e.image_url)})]}):t.jsxs(t.Fragment,{children:[console.log("ExplorePage: No image_url or thumbnail provided for item:",e),"'Img'"]})}),t.jsxs("div",{className:m.mapItemContent,children:[t.jsx("h3",{className:m.mapItemTitle,children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{children:e.title||"Untitled"}),e.starred&&t.jsx("span",{className:"text-red-500 text-lg",title:"Starred image",children:"★"})]})}),t.jsx("div",{className:m.mapItemMetadata,children:t.jsxs("div",{className:m.metadataTags,children:[e.image_type!=="drone_image"&&t.jsx("span",{className:m.metadataTagSource,children:e.source&&e.source.includes(", ")?e.source.split(", ").map(s=>V.find(c=>c.s_code===s.trim())?.label||s.trim()).join(", "):V.find(s=>s.s_code===e.source)?.label||e.source}),t.jsx("span",{className:m.metadataTagType,children:e.event_type&&e.event_type.includes(", ")?e.event_type.split(", ").map(s=>A.find(c=>c.t_code===s.trim())?.label||s.trim()).join(", "):A.find(s=>s.t_code===e.event_type)?.label||e.event_type}),t.jsx("span",{className:m.metadataTag,children:te.find(s=>s.image_type===e.image_type)?.label||e.image_type}),e.image_count&&e.image_count>1&&t.jsxs("span",{className:m.metadataTag,title:`Multi-upload with ${e.image_count} images`,children:["📷 ",e.image_count]}),(!e.image_count||e.image_count<=1)&&t.jsx("span",{className:m.metadataTag,title:"Single Upload",children:"Single"}),e.countries&&e.countries.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:m.metadataTag,children:ee.find(s=>s.r_code===e.countries[0].r_code)?.label||"Unknown Region"}),t.jsx("span",{className:m.metadataTag,children:e.countries.map(s=>s.label).join(", ")})]})]})})]})]}),$&&t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:`delete-${e.image_id}`,variant:"tertiary",size:1,className:"bg-red-50 hover:bg-red-100 text-red-700 border border-red-200 hover:border-red-300",onClick:()=>Ie(e.image_id),title:"Delete","aria-label":"Delete saved image",children:t.jsx(ze,{className:"w-4 h-4"})})})]},e.image_id)),!C.length&&t.jsx("div",{className:"text-center py-12",children:t.jsx("p",{className:"text-gray-500",children:"No examples found."})}),!W&&C.length>0&&t.jsx(Ge,{currentPage:L,totalPages:Se,totalItems:Q,itemsPerPage:M,onPageChange:le})]})]})]}):t.jsx("div",{className:"space-y-6",children:t.jsxs("div",{className:"text-center py-12",children:[t.jsx("p",{className:"text-gray-500",children:"Map Details view coming soon..."}),t.jsx("p",{className:"text-sm text-gray-400 mt-2",children:"This will show detailed information about individual maps"})]})})]}),we&&t.jsx("div",{className:m.fullSizeModalOverlay,onClick:()=>U(!1),children:t.jsx("div",{className:m.fullSizeModalContent,onClick:e=>e.stopPropagation(),children:t.jsxs("div",{className:m.ratingWarningContent,children:[t.jsx("h3",{className:m.ratingWarningTitle,children:"Delete Image?"}),t.jsx("p",{className:m.ratingWarningText,children:"This action cannot be undone. Are you sure you want to delete this saved image and all related data?"}),t.jsxs("div",{className:m.ratingWarningButtons,children:[t.jsx(w,{name:"confirm-delete",variant:"secondary",onClick:Ce,disabled:K,children:K?"Deleting...":"Delete"}),t.jsx(w,{name:"cancel-delete",variant:"tertiary",onClick:()=>U(!1),disabled:K,children:"Cancel"})]})]})})}),t.jsx(He,{isOpen:Ne,onClose:()=>{G(!1),q(!1),Z(!1)},onExport:(e,s)=>{const c=C.filter(j=>s.includes(j.image_type));Ee(c,e)},filteredCount:C.length,totalCount:Q,hasFilters:!!(S||p||_||y||E||I||k||T),crisisMapsCount:C.filter(e=>e.image_type==="crisis_map").length,droneImagesCount:C.filter(e=>e.image_type==="drone_image").length,isLoading:ve,exportSuccess:be})]})}export{pt as default}; diff --git a/py_backend/static/assets/index-L-TN6RFj.js b/py_backend/static/assets/index-D5zar1LU.js similarity index 99% rename from py_backend/static/assets/index-L-TN6RFj.js rename to py_backend/static/assets/index-D5zar1LU.js index 56e3decdc097d92c978b04395420a947e598469b..4d8b8704fb7f7f9a8c6acbdc84b7c26427d09c10 100644 --- a/py_backend/static/assets/index-L-TN6RFj.js +++ b/py_backend/static/assets/index-D5zar1LU.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-BuKhrC7_.js","assets/index-DieRAFRn.js","assets/index-cCOeofBN.css"])))=>i.map(i=>d[i]); -import{K as ea,x as aa,j as a,N as ee,n as L,r as d,D as ta,_ as we,L as sa,z as P,v as ne,w as oe,F as ia,M as na,G as oa}from"./index-DieRAFRn.js";import{u as ra}from"./useAdmin-SWj4UX1Y.js";import{F as la,E as ca}from"./ExportModal-BqSw_U2P.js";const da="_tabSelector_usssr_1",ga="_imageContainer_usssr_12",ma="_imagePlaceholder_usssr_33",ua="_metadataTags_usssr_45",pa="_metadataTag_usssr_45",fa="_captionContainer_usssr_67",_a="_captionText_usssr_74",ha="_gridLayout_usssr_131",xa="_detailsSection_usssr_155",ya="_loadingContainer_usssr_161",va="_errorContainer_usssr_171",ja="_fullSizeModalOverlay_usssr_205",wa="_fullSizeModalContent_usssr_219",Ia="_ratingWarningContent_usssr_230",Na="_ratingWarningTitle_usssr_236",Ca="_ratingWarningText_usssr_243",ba="_ratingWarningButtons_usssr_250",Sa="_carouselContainer_usssr_365",Da="_carouselImageWrapper_usssr_370",ka="_carouselImage_usssr_370",Ma="_carouselNavigation_usssr_393",La="_carouselButton_usssr_405",Fa="_carouselIndicators_usssr_429",Ta="_carouselIndicator_usssr_429",Pa="_carouselIndicatorActive_usssr_458",Ea="_singleImageContainer_usssr_488",$a="_viewImageButtonContainer_usssr_494",m={tabSelector:da,imageContainer:ga,imagePlaceholder:ma,metadataTags:ua,metadataTag:pa,captionContainer:fa,captionText:_a,gridLayout:ha,detailsSection:xa,loadingContainer:ya,errorContainer:va,fullSizeModalOverlay:ja,fullSizeModalContent:wa,ratingWarningContent:Ia,ratingWarningTitle:Na,ratingWarningText:Ca,ratingWarningButtons:ba,carouselContainer:Sa,carouselImageWrapper:Da,carouselImage:ka,carouselNavigation:Ma,carouselButton:La,carouselIndicators:Fa,carouselIndicator:Ta,carouselIndicatorActive:Pa,singleImageContainer:Ea,viewImageButtonContainer:$a};function st(){const{mapId:g}=ea(),x=aa(),{isAuthenticated:re}=ra();console.log("MapDetailsPage: Current URL:",window.location.href),console.log("MapDetailsPage: Hash:",window.location.hash),console.log("MapDetailsPage: mapId from useParams:",g),console.log("MapDetailsPage: mapId type:",typeof g),console.log("MapDetailsPage: mapId length:",g?.length),console.log("MapDetailsPage: mapId value:",JSON.stringify(g));const Ie=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;if(!g||g==="undefined"||g==="null"||g.trim()===""||!Ie.test(g))return a.jsx(ee,{children:a.jsxs("div",{className:"flex flex-col items-center gap-4 text-center py-12",children:[a.jsx("div",{className:"text-4xl",children:"⚠️"}),a.jsx("div",{className:"text-xl font-semibold",children:"Invalid Map ID"}),a.jsx("div",{children:"The map ID provided is not valid."}),a.jsxs("div",{className:"text-sm text-gray-500 mt-2",children:['Debug Info: mapId = "',g,'" (type: ',typeof g,")"]}),a.jsx(L,{name:"back-to-explore",variant:"secondary",onClick:()=>x("/explore"),children:"Return to Explore"})]})});const[le,Ne]=d.useState("mapDetails"),[e,ae]=d.useState(null),[z,R]=d.useState(!0),[ce,O]=d.useState(null),[de,Ce]=d.useState([]),[ge,be]=d.useState([]),[me,Se]=d.useState([]),[ue,De]=d.useState([]),[ke,Me]=d.useState([]),[Le,Fe]=d.useState(!1),[Te,Pe]=d.useState(!1),[W,q]=d.useState(!1),[Ee,K]=d.useState(!1),[pe,Z]=d.useState(!1),[$e,te]=d.useState(!1),[Re,se]=d.useState(!1),[Ra,Aa]=d.useState("standard"),[E,za]=d.useState(80),[J,Oa]=d.useState(10),[Ua,Ba]=d.useState(10),[Wa,Ja]=d.useState(!0),[Va,Ha]=d.useState(!0),[U,Q]=d.useState(!1),[Ae,fe]=d.useState(!1),[ze,_e]=d.useState(null),[Oe,V]=d.useState(!1),[h,H]=d.useState([]),[D,A]=d.useState(0),[G,he]=d.useState(!1),{search:p,setSearch:Ga,srcFilter:y,setSrcFilter:qa,catFilter:v,setCatFilter:Ka,regionFilter:j,setRegionFilter:Za,countryFilter:w,setCountryFilter:Qa,imageTypeFilter:I,setImageTypeFilter:Xa,uploadTypeFilter:N,setUploadTypeFilter:Ya,showReferenceExamples:b,setShowReferenceExamples:Ue,clearAllFilters:Be}=ta(),We=[{key:"explore",label:"List"},{key:"mapDetails",label:"Carousel"}],xe=d.useCallback(async t=>{if(console.log("fetchMapData called with id:",t),console.log("fetchMapData id type:",typeof t),!t||t==="undefined"||t==="null"||t.trim()===""){console.log("fetchMapData: Invalid ID detected:",t),O("Invalid Map ID"),R(!1);return}if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)){console.log("fetchMapData: Invalid UUID format:",t),O("Invalid Map ID format"),R(!1);return}console.log("fetchMapData: Making API call for id:",t),q(!0),R(!0);try{const l=await fetch(`/api/images/${t}`);if(!l.ok)throw new Error("Map not found");const i=await l.json();if(ae(i),i.all_image_ids&&i.all_image_ids.length>1)await ie(i.all_image_ids);else if(i.image_count&&i.image_count>1){console.log("Multi-upload detected but no all_image_ids, trying grouped endpoint");try{const n=await fetch("/api/images/grouped");if(n.ok){const o=(await n.json()).find(u=>u.all_image_ids&&u.all_image_ids.includes(i.image_id));o&&o.all_image_ids?await ie(o.all_image_ids):(H([i]),A(0))}else H([i]),A(0)}catch(n){console.error("Failed to fetch from grouped endpoint:",n),H([i]),A(0)}}else H([i]),A(0);await X(t)}catch(l){O(l instanceof Error?l.message:"Unknown error occurred")}finally{R(!1),q(!1)}},[X,ie]),ie=d.useCallback(async t=>{console.log("fetchAllImages called with imageIds:",t),he(!0);try{const s=t.map(async i=>{const n=await fetch(`/api/images/${i}`);if(!n.ok)throw new Error(`Failed to fetch image ${i}`);return n.json()}),l=await Promise.all(s);H(l),A(0),console.log("fetchAllImages: Loaded",l.length,"images")}catch(s){console.error("fetchAllImages error:",s),O(s instanceof Error?s.message:"Failed to load all images")}finally{he(!1)}},[]),Je=d.useCallback(()=>{h.length>1&&A(t=>t>0?t-1:h.length-1)},[h.length]),Ve=d.useCallback(()=>{h.length>1&&A(t=>t{t>=0&&t{const s=t||(h.length>0?h[D]:e);if(s){V(!0),_e(s),fe(!0);try{const l=new Image;l.onload=()=>{V(!1)},l.onerror=()=>{V(!1)},l.src=s.image_url}catch(l){console.error("Error preloading full-size image:",l),V(!1)}}},[h,D,e]),Ge=d.useCallback(()=>{fe(!1),_e(null),V(!1)},[]);d.useEffect(()=>{if(console.log("MapDetailsPage: mapId from useParams:",g),console.log("MapDetailsPage: mapId type:",typeof g),console.log("MapDetailsPage: mapId value:",g),!g||g==="undefined"||g==="null"||g.trim()===""||g===void 0||g===null){console.log("MapDetailsPage: Invalid mapId, setting error"),O("Map ID is required"),R(!1);return}if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(g)){console.log("MapDetailsPage: Invalid UUID format:",g),O("Invalid Map ID format"),R(!1);return}console.log("MapDetailsPage: Fetching data for mapId:",g),xe(g)},[g,xe]),d.useEffect(()=>{if(!e||z||U)return;if(!g||g==="undefined"||g==="null"||g.trim()===""){console.log("Auto-navigation skipped: Invalid mapId");return}if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(g)){console.log("Auto-navigation skipped: Invalid mapId format");return}(()=>{const l=!p||e.title?.toLowerCase().includes(p.toLowerCase())||e.generated?.toLowerCase().includes(p.toLowerCase())||e.source?.toLowerCase().includes(p.toLowerCase())||e.event_type?.toLowerCase().includes(p.toLowerCase()),i=!y||e.source===y,n=!v||e.event_type===v,r=!j||e.countries.some($=>$.r_code===j),o=!w||e.countries.some($=>$.c_code===w),u=!I||e.image_type===I,_=!b||e.starred===!0,k=l&&i&&n&&r&&o&&u&&_;return console.log("Auto-navigation check:",{mapId:g,search:p,srcFilter:y,catFilter:v,regionFilter:j,countryFilter:w,imageTypeFilter:I,showReferenceExamples:b,matchesSearch:l,matchesSource:i,matchesCategory:n,matchesRegion:r,matchesCountry:o,matchesImageType:u,matchesReferenceExamples:_,matches:k}),k})()||(console.log("Current map does not match filters, looking for first matching item"),fetch("/api/images").then(l=>l.json()).then(l=>{console.log("Auto-navigation: Received images from API:",l.length),console.log("Auto-navigation: First few images:",l.slice(0,3).map(n=>({image_id:n.image_id,title:n.title})));const i=l.find(n=>{const r=!p||n.title?.toLowerCase().includes(p.toLowerCase())||n.generated?.toLowerCase().includes(p.toLowerCase())||n.source?.toLowerCase().includes(p.toLowerCase())||n.event_type?.toLowerCase().includes(p.toLowerCase()),o=!y||n.source===y,u=!v||n.event_type===v,_=!j||n.countries?.some(f=>f.r_code===j),k=!w||n.countries?.some(f=>f.c_code===w),$=!I||n.image_type===I,F=!b||n.starred===!0;return r&&o&&u&&_&&k&&$&&F});console.log("Auto-navigation: Found first matching image:",i?{image_id:i.image_id,title:i.title,source:i.source}:"No matching image found"),i&&i.image_id&&i.image_id!=="undefined"&&i.image_id!=="null"&&i.image_id.trim()!==""&&i.image_id!==g&&(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i.image_id)?(console.log("Auto-navigating to:",i.image_id),x(`/map/${i.image_id}`)):console.error("Auto-navigation blocked: Invalid image_id format:",i.image_id))}).catch(console.error))},[e,p,y,v,j,w,I,b,g,x,z,U]);const X=d.useCallback(async t=>{if(!(!t||t==="undefined"||t==="null"||t.trim()===""))try{const s=new URLSearchParams;p&&s.append("search",p),y&&s.append("source",y),v&&s.append("event_type",v),j&&s.append("region",j),w&&s.append("country",w),I&&s.append("image_type",I),N&&s.append("upload_type",N),b&&s.append("starred_only","true");const l=await fetch(`/api/images/grouped?${s.toString()}`);if(l.ok){const i=await l.json();console.log("Server response for upload_type=multiple:",{url:`/api/images/grouped?${s.toString()}`,count:i.length,images:i.map(r=>({image_id:r.image_id,image_count:r.image_count,all_image_ids:r.all_image_ids,all_image_ids_length:r.all_image_ids?.length}))});const n=i.findIndex(r=>r.image_id===t);console.log("Navigation availability check (server-side):",{filteredImagesCount:i.length,currentIndex:n,currentId:t,uploadTypeFilter:N,hasPrevious:i.length>1&&n>0,hasNext:i.length>1&&n({image_id:r.image_id,image_count:r.image_count,all_image_ids:r.all_image_ids,image_type:r.image_type}))}),Fe(i.length>1&&n>0),Pe(i.length>1&&n{if(!W){q(!0);try{const s=new URLSearchParams;p&&s.append("search",p),y&&s.append("source",y),v&&s.append("event_type",v),j&&s.append("region",j),w&&s.append("country",w),I&&s.append("image_type",I),N&&s.append("upload_type",N),b&&s.append("starred_only","true");const l=await fetch(`/api/images/grouped?${s.toString()}`);if(l.ok){const i=await l.json(),n=i.findIndex(u=>u.image_id===g);if(n===-1){console.error("Current image not found in filtered list");return}let r;t==="previous"?r=n>0?n-1:i.length-1:r=n{console.log("=== NAVIGATION USEEFFECT TRIGGERED ==="),console.log("Navigation useEffect triggered:",{map:!!e,mapId:g,loading:z,isDeleting:U,uploadTypeFilter:N,allFilters:{search:p,srcFilter:y,catFilter:v,regionFilter:j,countryFilter:w,imageTypeFilter:I,uploadTypeFilter:N,showReferenceExamples:b}}),e&&g&&!z&&!U?(console.log("Calling checkNavigationAvailability with:",g),X(g)):console.log("NOT calling checkNavigationAvailability because:",{map:!!e,mapId:!!g,loading:z,isDeleting:U})},[e,g,p,y,v,j,w,I,N,b,z,U,X]),d.useEffect(()=>{Promise.all([fetch("/api/sources").then(t=>t.json()),fetch("/api/types").then(t=>t.json()),fetch("/api/image-types").then(t=>t.json()),fetch("/api/regions").then(t=>t.json()),fetch("/api/countries").then(t=>t.json())]).then(([t,s,l,i,n])=>{Ce(t),be(s),Se(l),De(i),Me(n)}).catch(console.error)},[]);const qe=async()=>{e&&K(!0)},Ke=async()=>{if(e)try{(await fetch(`/api/images/${e.image_id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({starred:!e.starred})})).ok?ae(s=>s?{...s,starred:!s.starred}:null):console.error("Failed to toggle starred status")}catch(t){console.error("Error toggling starred status:",t)}},Ze=async()=>{if(e){Q(!0);try{if(console.log("Deleting image with ID:",e.image_id),(await fetch(`/api/images/${e.image_id}`,{method:"DELETE"})).ok){ae(s=>s?{...s,starred:!s.starred}:null),K(!1);try{const s=await fetch("/api/images/grouped");if(s.ok){const i=(await s.json()).filter(r=>{const o=!p||r.title?.toLowerCase().includes(p.toLowerCase())||r.generated?.toLowerCase().includes(p.toLowerCase())||r.source?.toLowerCase().includes(p.toLowerCase())||r.event_type?.toLowerCase().includes(p.toLowerCase()),u=!y||r.source===y,_=!v||r.event_type===v,k=!j||r.countries?.some(C=>C.r_code===j),$=!w||r.countries?.some(C=>C.c_code===w),F=!I||r.image_type===I,f=!N||N==="single"&&(!r.image_count||r.image_count<=1)||N==="multiple"&&r.image_count&&r.image_count>1,M=!b||r.starred===!0;return o&&u&&_&&k&&$&&F&&f&&M}),n=i.filter(r=>r.image_id!==e.image_id);if(n.length>0){const r=i.findIndex(u=>u.image_id===e.image_id);let o;if(r===i.length-1?o=r-1:o=r,console.log("Navigation target:",{currentIndex:r,targetIndex:o,targetId:n[o]?.image_id}),o>=0&&o{if(!e)return null;if(!p&&!y&&!v&&!j&&!w&&!I&&!N&&!b)return e;const t=!p||e.title?.toLowerCase().includes(p.toLowerCase())||e.generated?.toLowerCase().includes(p.toLowerCase())||e.source?.toLowerCase().includes(p.toLowerCase())||e.event_type?.toLowerCase().includes(p.toLowerCase()),s=!y||e.source===y,l=!v||e.event_type===v,i=!j||e.countries.some(k=>k.r_code===j),n=!w||e.countries.some(k=>k.c_code===w),r=!I||e.image_type===I,o=!N||N==="single"&&(!e.image_count||e.image_count<=1)&&(!e.all_image_ids||e.all_image_ids.length<=1)||N==="multiple"&&(e.image_count&&e.image_count>1||e.all_image_ids&&e.all_image_ids.length>1),u=!b||e.starred===!0,_=t&&s&&l&&i&&n&&r&&o&&u;return!_&&(p||y||v||j||w||I||N||b)?(setTimeout(()=>{je()},100),e):_?e:null},[e,p,y,v,j,w,I,N,b,je]),je=d.useCallback(async()=>{R(!0);try{const t=new URLSearchParams;p&&t.append("search",p),y&&t.append("source",y),v&&t.append("event_type",v),j&&t.append("region",j),w&&t.append("country",w),I&&t.append("image_type",I),N&&t.append("upload_type",N),b&&t.append("starred_only","true");const s=await fetch(`/api/images/grouped?${t.toString()}`);if(s.ok){const l=await s.json();if(l.length>0){const i=l[0];i&&i.image_id&&x(`/map/${i.image_id}`)}else x("/explore")}}catch(t){console.error("Failed to navigate to matching image:",t),x("/explore")}finally{R(!1)}},[p,y,v,j,w,I,N,b,x]),Qe=()=>{if(!e)return;if(!e.all_image_ids||e.all_image_ids.length<=1){const i=`/upload?step=1&contribute=true&imageIds=${[e.image_id].join(",")}`;x(i);return}const s=`/upload?step=1&contribute=true&imageIds=${e.all_image_ids.join(",")}`;x(s)},T=(t,s)=>({image:`images/${s}`,caption:t.edited||t.generated||"",metadata:{image_id:t.image_count&&t.image_count>1?t.all_image_ids||[t.image_id]:t.image_id,title:t.title,source:t.source,event_type:t.event_type,image_type:t.image_type,countries:t.countries,starred:t.starred,image_count:t.image_count||1}}),Xe=async t=>{if(e){te(!0),se(!1);try{const s=(await oa(async()=>{const{default:o}=await import("./jszip.min-BuKhrC7_.js").then(u=>u.j);return{default:o}},__vite__mapDeps([0,1,2]))).default,l=new s;if(e.image_type==="crisis_map"){const o=l.folder("crisis_maps_dataset"),u=o?.folder("images");if(u)try{const _=e.image_count&&e.image_count>1?e.all_image_ids||[e.image_id]:[e.image_id],k=_.map(async(f,M)=>{try{const C=await fetch(`/api/images/${f}/file`);if(!C.ok)throw new Error(`Failed to fetch image ${f}`);const S=await C.blob(),Y=e.file_key.split(".").pop()||"jpg",B=`0001_${String(M+1).padStart(2,"0")}.${Y}`;return u.file(B,S),{success:!0,fileName:B,imageId:f}}catch(C){return console.error(`Failed to process image ${f}:`,C),{success:!1,fileName:"",imageId:f}}}),F=(await Promise.all(k)).filter(f=>f.success);if(F.length===0)throw new Error("No images could be processed");if(t==="fine-tuning"){const f=[],M=[],C=[],S=F.map(Ye=>`images/${Ye.fileName}`),Y=Math.random(),B={image:S.length===1?S[0]:S,caption:e.edited||e.generated||"",metadata:{image_id:_,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};Y`images/${C.fileName}`),M={image:f.length===1?f[0]:f,caption:e.edited||e.generated||"",metadata:{image_id:_,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};o&&o.file("0001.json",JSON.stringify(M,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}else if(e.image_type==="drone_image"){const o=l.folder("drone_images_dataset"),u=o?.folder("images");if(u)try{const _=await fetch(`/api/images/${e.image_id}/file`);if(!_.ok)throw new Error(`Failed to fetch image ${e.image_id}`);const k=await _.blob(),F=`0001.${e.file_key.split(".").pop()||"jpg"}`;if(u.file(F,k),t==="fine-tuning"){const f=[],M=[],C=[];if(String(e?.image_type)==="crisis_map"){const S=Math.random();S1?e.all_image_ids||[e.image_id]:e.image_id,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};o&&o.file("0001.json",JSON.stringify(f,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}else{const o=l.folder("generic_dataset"),u=o?.folder("images");if(u)try{const _=await fetch(`/api/images/${e.image_id}/file`);if(!_.ok)throw new Error(`Failed to fetch image ${e.image_id}`);const k=await _.blob(),F=`0001.${e.file_key.split(".").pop()||"jpg"}`;if(u.file(F,k),t==="fine-tuning"){const f=[],M=[],C=[];if(String(e?.image_type)==="crisis_map"){const S=Math.random();S1?e.all_image_ids||[e.image_id]:e.image_id,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};o&&o.file("0001.json",JSON.stringify(f,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}const i=await l.generateAsync({type:"blob"}),n=URL.createObjectURL(i),r=document.createElement("a");r.href=n,r.download=`dataset_${e.image_type}_${e.image_id}_${t}_${new Date().toISOString().split("T")[0]}.zip`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n),console.log(`Exported ${e.image_type} dataset with 1 image in ${t} mode`),se(!0)}catch(s){console.error("Export failed:",s),alert("Failed to export dataset. Please try again.")}finally{te(!1)}}};return z?a.jsx(ee,{children:a.jsx("div",{className:m.loadingContainer,children:a.jsxs("div",{className:"flex flex-col items-center gap-4",children:[a.jsx(we,{className:"text-ifrcRed"}),a.jsx("div",{children:"Loading map details..."})]})})}):ce||!e?a.jsx(ee,{children:a.jsx("div",{className:m.errorContainer,children:a.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[a.jsx("div",{className:"text-4xl",children:"⚠️"}),a.jsx("div",{className:"text-xl font-semibold",children:"Unable to load map"}),a.jsx("div",{children:ce||"Map not found"}),a.jsx(L,{name:"back-to-explore",variant:"secondary",onClick:()=>x("/explore"),children:"Return to Explore"})]})})}):a.jsxs(ee,{children:[a.jsxs("div",{className:"max-w-7xl mx-auto",children:[a.jsxs("div",{className:m.tabSelector,children:[a.jsx(sa,{name:"map-details-view",value:le,onChange:t=>{(t==="mapDetails"||t==="explore")&&(Ne(t),t==="explore"&&x("/explore"))},options:We,keySelector:t=>t.key,labelSelector:t=>t.label}),a.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[a.jsx(P,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:a.jsxs(L,{name:"reference-examples",variant:b?"primary":"secondary",onClick:()=>Ue(!b),className:"whitespace-nowrap",children:[a.jsx("span",{className:"mr-2",children:b?a.jsx("span",{className:"text-yellow-400",children:"★"}):a.jsx("span",{className:"text-yellow-400",children:"☆"})}),"Reference Examples"]})}),a.jsx(L,{name:"export-dataset",variant:"secondary",onClick:()=>Z(!0),children:"Export"})]})]}),a.jsx(la,{sources:de,types:ge,regions:ue,countries:ke,imageTypes:me,isLoadingFilters:!1}),le==="mapDetails"?a.jsx("div",{className:"relative",children:c?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:m.gridLayout,children:[a.jsxs(P,{heading:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{children:c.title||"Map Image"}),c.starred&&a.jsx("span",{className:"text-red-500 text-xl",title:"Starred image",children:"★"})]}),headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,spacing:"comfortable",children:[a.jsx("div",{className:m.imageContainer,children:e?.image_count&&e.image_count>1||h.length>1?a.jsxs("div",{className:m.carouselContainer,children:[a.jsx("div",{className:m.carouselImageWrapper,children:G?a.jsxs("div",{className:m.imagePlaceholder,children:[a.jsx(we,{className:"text-ifrcRed"}),a.jsx("div",{children:"Loading images..."})]}):h[D]?.detail_url?a.jsx("img",{src:h[D].detail_url,alt:h[D].file_key,className:m.carouselImage,onError:t=>{console.log("MapDetailsPage: Detail image failed to load, falling back to original:",h[D].detail_url);const s=t.target;h[D].image_url&&(s.src=h[D].image_url)},onLoad:()=>console.log("MapDetailsPage: Detail image loaded successfully:",h[D].detail_url)}):h[D]?.image_url?a.jsx("img",{src:h[D].image_url,alt:h[D].file_key,className:m.carouselImage,onLoad:()=>console.log("MapDetailsPage: Original image loaded successfully:",h[D].image_url)}):a.jsx("div",{className:m.imagePlaceholder,children:"No image available"})}),a.jsxs("div",{className:m.carouselNavigation,children:[a.jsx(L,{name:"previous-image",variant:"tertiary",size:1,onClick:Je,disabled:G,className:m.carouselButton,children:a.jsx(ne,{className:"w-4 h-4"})}),a.jsx("div",{className:m.carouselIndicators,children:h.map((t,s)=>a.jsx("button",{onClick:()=>He(s),className:`${m.carouselIndicator} ${s===D?m.carouselIndicatorActive:""}`,disabled:G,children:s+1},s))}),a.jsx(L,{name:"next-image",variant:"tertiary",size:1,onClick:Ve,disabled:G,className:m.carouselButton,children:a.jsx(oe,{className:"w-4 h-4"})})]}),a.jsx("div",{className:m.viewImageButtonContainer,children:a.jsx(L,{name:"view-full-size-carousel",variant:"secondary",size:1,onClick:()=>ye(h[D]),disabled:G||!h[D]?.image_url,children:"View Image"})})]}):a.jsxs("div",{className:m.singleImageContainer,children:[c.detail_url?a.jsx("img",{src:c.detail_url,alt:c.file_key,onError:t=>{console.log("MapDetailsPage: Detail image failed to load, falling back to original:",c.detail_url);const s=t.target;c.image_url&&(s.src=c.image_url)},onLoad:()=>console.log("MapDetailsPage: Detail image loaded successfully:",c.detail_url)}):c.image_url?a.jsx("img",{src:c.image_url,alt:c.file_key,onLoad:()=>console.log("MapDetailsPage: Original image loaded successfully:",c.image_url)}):a.jsx("div",{className:m.imagePlaceholder,children:"No image available"}),a.jsx("div",{className:m.viewImageButtonContainer,children:a.jsx(L,{name:"view-full-size-single",variant:"secondary",size:1,onClick:()=>ye(c),disabled:!c.image_url,children:"View Image"})})]})}),a.jsx(P,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:a.jsxs("div",{className:m.metadataTags,children:[c.image_type!=="drone_image"&&a.jsx("span",{className:m.metadataTag,children:de.find(t=>t.s_code===c.source)?.label||c.source}),a.jsx("span",{className:m.metadataTag,children:ge.find(t=>t.t_code===c.event_type)?.label||c.event_type}),a.jsx("span",{className:m.metadataTag,children:me.find(t=>t.image_type===c.image_type)?.label||c.image_type}),c.countries&&c.countries.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:m.metadataTag,children:ue.find(t=>t.r_code===c.countries[0].r_code)?.label||"Unknown Region"}),a.jsx("span",{className:m.metadataTag,children:c.countries.map(t=>t.label).join(", ")})]}),c.image_count&&c.image_count>1&&a.jsxs("span",{className:m.metadataTag,title:`Multi-upload with ${c.image_count} images`,children:["📷 ",c.image_count]}),(!c.image_count||c.image_count<=1)&&a.jsx("span",{className:m.metadataTag,title:"Single Upload",children:"Single"})]})})]}),a.jsx("div",{className:m.detailsSection,children:c.edited&&c.edited.includes("Description:")||c.generated&&c.generated.includes("Description:")?a.jsx(P,{heading:"AI Generated Content",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,spacing:"comfortable",children:a.jsx("div",{className:m.captionContainer,children:a.jsx("div",{className:m.captionText,children:(c.edited||c.generated||"").split(/(Description:|Analysis:|Recommended Actions:)/).map((l,i)=>l.trim()===""?null:l==="Description:"||l==="Analysis:"||l==="Recommended Actions:"?a.jsx("h4",{className:"font-semibold text-gray-800 mt-4 mb-2",children:l},i):a.jsx("p",{className:"mb-2",children:l.trim()},i))})})}):a.jsx(P,{heading:"Description",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,spacing:"comfortable",children:a.jsx("div",{className:m.captionContainer,children:c.generated||c.edited?a.jsx("div",{className:m.captionText,children:a.jsx("p",{children:c.edited||c.generated})}):a.jsx("p",{children:"— no caption yet —"})})})})]}),a.jsx("div",{className:"flex items-center justify-center mt-8",children:a.jsx(P,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center gap-4",children:[Le&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"previous-item",variant:"tertiary",size:1,className:`bg-white/90 hover:bg-white shadow-lg border border-gray-200 ${W?"opacity-50 cursor-not-allowed":"hover:scale-110"}`,onClick:()=>ve("previous"),disabled:W,children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("div",{className:"flex -space-x-1",children:[a.jsx(ne,{className:"w-4 h-4"}),a.jsx(ne,{className:"w-4 h-4"})]}),a.jsx("span",{className:"font-semibold",children:"Previous"})]})})}),re&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"delete",variant:"tertiary",size:1,className:"bg-red-50 hover:bg-red-100 text-red-700 border border-red-200 hover:border-red-300",onClick:qe,title:"Delete","aria-label":"Delete saved image",children:a.jsx(ia,{className:"w-4 h-4"})})}),a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"contribute",onClick:Qe,children:"Contribute"})}),re&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"toggle-star",variant:"tertiary",size:1,className:`${e?.starred?"bg-red-100 hover:bg-red-200 text-red-800 border-2 border-red-400":"bg-gray-100 hover:bg-gray-200 text-gray-600 border-2 border-gray-300"} w-16 h-8 rounded-full transition-all duration-200 flex items-center justify-center`,onClick:Ke,title:e?.starred?"Unstar image":"Star image","aria-label":e?.starred?"Unstar image":"Star image",children:a.jsx("span",{className:`text-lg transition-all duration-200 ${e?.starred?"text-red-600":"text-gray-500"}`,children:e?.starred?"★":"☆"})})}),Te&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"next-item",variant:"tertiary",size:1,className:`bg-white/90 hover:bg-white shadow-lg border border-gray-200 ${W?"opacity-50 cursor-not-allowed":"hover:scale-110"}`,onClick:()=>ve("next"),disabled:W,children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"font-semibold",children:"Next"}),a.jsxs("div",{className:"flex -space-x-1",children:[a.jsx(oe,{className:"w-4 h-4"}),a.jsx(oe,{className:"w-4 h-4"})]})]})})})]})})})]}):a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"text-xl font-semibold text-gray-600 mb-4",children:"No matches found"}),a.jsx("div",{className:"mt-4",children:a.jsx(L,{name:"clear-filters",variant:"secondary",onClick:Be,children:"Clear Filters"})})]})}):null]}),Ee&&a.jsx("div",{className:m.fullSizeModalOverlay,onClick:()=>K(!1),children:a.jsx("div",{className:m.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:a.jsxs("div",{className:m.ratingWarningContent,children:[a.jsx("h3",{className:m.ratingWarningTitle,children:"Delete Image?"}),a.jsx("p",{className:m.ratingWarningText,children:"This action cannot be undone. Are you sure you want to delete this saved image and all related data?"}),a.jsxs("div",{className:m.ratingWarningButtons,children:[a.jsx(L,{name:"confirm-delete",variant:"secondary",onClick:Ze,children:"Delete"}),a.jsx(L,{name:"cancel-delete",variant:"tertiary",onClick:()=>K(!1),children:"Cancel"})]})]})})}),pe&&a.jsx(ca,{isOpen:pe,onClose:()=>{Z(!1),se(!1),te(!1)},onExport:(t,s)=>{s.includes(e.image_type)&&Xe(t)},filteredCount:1,totalCount:1,hasFilters:!1,crisisMapsCount:e.image_type==="crisis_map"?1:0,droneImagesCount:e.image_type==="drone_image"?1:0,isLoading:$e,exportSuccess:Re,variant:"single",onNavigateToList:()=>{Z(!1),x("/explore")},onNavigateAndExport:()=>{Z(!1),x("/explore?export=true")}}),a.jsx(na,{isOpen:Ae,imageUrl:ze?.image_url||null,preview:null,selectedImageData:null,onClose:Ge,isLoading:Oe})]})}export{st as default}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-uuN5m5dK.js","assets/index-B0L3qvtx.js","assets/index-cCOeofBN.css"])))=>i.map(i=>d[i]); +import{K as ea,x as aa,j as a,N as ee,n as L,r as d,D as ta,_ as we,L as sa,z as P,v as ne,w as oe,F as ia,M as na,G as oa}from"./index-B0L3qvtx.js";import{u as ra}from"./useAdmin-DN0iYnPm.js";import{F as la,E as ca}from"./ExportModal-BI_JlHOZ.js";const da="_tabSelector_usssr_1",ga="_imageContainer_usssr_12",ma="_imagePlaceholder_usssr_33",ua="_metadataTags_usssr_45",pa="_metadataTag_usssr_45",fa="_captionContainer_usssr_67",_a="_captionText_usssr_74",ha="_gridLayout_usssr_131",xa="_detailsSection_usssr_155",ya="_loadingContainer_usssr_161",va="_errorContainer_usssr_171",ja="_fullSizeModalOverlay_usssr_205",wa="_fullSizeModalContent_usssr_219",Ia="_ratingWarningContent_usssr_230",Na="_ratingWarningTitle_usssr_236",Ca="_ratingWarningText_usssr_243",ba="_ratingWarningButtons_usssr_250",Sa="_carouselContainer_usssr_365",Da="_carouselImageWrapper_usssr_370",ka="_carouselImage_usssr_370",Ma="_carouselNavigation_usssr_393",La="_carouselButton_usssr_405",Fa="_carouselIndicators_usssr_429",Ta="_carouselIndicator_usssr_429",Pa="_carouselIndicatorActive_usssr_458",Ea="_singleImageContainer_usssr_488",$a="_viewImageButtonContainer_usssr_494",m={tabSelector:da,imageContainer:ga,imagePlaceholder:ma,metadataTags:ua,metadataTag:pa,captionContainer:fa,captionText:_a,gridLayout:ha,detailsSection:xa,loadingContainer:ya,errorContainer:va,fullSizeModalOverlay:ja,fullSizeModalContent:wa,ratingWarningContent:Ia,ratingWarningTitle:Na,ratingWarningText:Ca,ratingWarningButtons:ba,carouselContainer:Sa,carouselImageWrapper:Da,carouselImage:ka,carouselNavigation:Ma,carouselButton:La,carouselIndicators:Fa,carouselIndicator:Ta,carouselIndicatorActive:Pa,singleImageContainer:Ea,viewImageButtonContainer:$a};function st(){const{mapId:g}=ea(),x=aa(),{isAuthenticated:re}=ra();console.log("MapDetailsPage: Current URL:",window.location.href),console.log("MapDetailsPage: Hash:",window.location.hash),console.log("MapDetailsPage: mapId from useParams:",g),console.log("MapDetailsPage: mapId type:",typeof g),console.log("MapDetailsPage: mapId length:",g?.length),console.log("MapDetailsPage: mapId value:",JSON.stringify(g));const Ie=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;if(!g||g==="undefined"||g==="null"||g.trim()===""||!Ie.test(g))return a.jsx(ee,{children:a.jsxs("div",{className:"flex flex-col items-center gap-4 text-center py-12",children:[a.jsx("div",{className:"text-4xl",children:"⚠️"}),a.jsx("div",{className:"text-xl font-semibold",children:"Invalid Map ID"}),a.jsx("div",{children:"The map ID provided is not valid."}),a.jsxs("div",{className:"text-sm text-gray-500 mt-2",children:['Debug Info: mapId = "',g,'" (type: ',typeof g,")"]}),a.jsx(L,{name:"back-to-explore",variant:"secondary",onClick:()=>x("/explore"),children:"Return to Explore"})]})});const[le,Ne]=d.useState("mapDetails"),[e,ae]=d.useState(null),[z,R]=d.useState(!0),[ce,O]=d.useState(null),[de,Ce]=d.useState([]),[ge,be]=d.useState([]),[me,Se]=d.useState([]),[ue,De]=d.useState([]),[ke,Me]=d.useState([]),[Le,Fe]=d.useState(!1),[Te,Pe]=d.useState(!1),[W,q]=d.useState(!1),[Ee,K]=d.useState(!1),[pe,Z]=d.useState(!1),[$e,te]=d.useState(!1),[Re,se]=d.useState(!1),[Ra,Aa]=d.useState("standard"),[E,za]=d.useState(80),[J,Oa]=d.useState(10),[Ua,Ba]=d.useState(10),[Wa,Ja]=d.useState(!0),[Va,Ha]=d.useState(!0),[U,Q]=d.useState(!1),[Ae,fe]=d.useState(!1),[ze,_e]=d.useState(null),[Oe,V]=d.useState(!1),[h,H]=d.useState([]),[D,A]=d.useState(0),[G,he]=d.useState(!1),{search:p,setSearch:Ga,srcFilter:y,setSrcFilter:qa,catFilter:v,setCatFilter:Ka,regionFilter:j,setRegionFilter:Za,countryFilter:w,setCountryFilter:Qa,imageTypeFilter:I,setImageTypeFilter:Xa,uploadTypeFilter:N,setUploadTypeFilter:Ya,showReferenceExamples:b,setShowReferenceExamples:Ue,clearAllFilters:Be}=ta(),We=[{key:"explore",label:"List"},{key:"mapDetails",label:"Carousel"}],xe=d.useCallback(async t=>{if(console.log("fetchMapData called with id:",t),console.log("fetchMapData id type:",typeof t),!t||t==="undefined"||t==="null"||t.trim()===""){console.log("fetchMapData: Invalid ID detected:",t),O("Invalid Map ID"),R(!1);return}if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)){console.log("fetchMapData: Invalid UUID format:",t),O("Invalid Map ID format"),R(!1);return}console.log("fetchMapData: Making API call for id:",t),q(!0),R(!0);try{const l=await fetch(`/api/images/${t}`);if(!l.ok)throw new Error("Map not found");const i=await l.json();if(ae(i),i.all_image_ids&&i.all_image_ids.length>1)await ie(i.all_image_ids);else if(i.image_count&&i.image_count>1){console.log("Multi-upload detected but no all_image_ids, trying grouped endpoint");try{const n=await fetch("/api/images/grouped");if(n.ok){const o=(await n.json()).find(u=>u.all_image_ids&&u.all_image_ids.includes(i.image_id));o&&o.all_image_ids?await ie(o.all_image_ids):(H([i]),A(0))}else H([i]),A(0)}catch(n){console.error("Failed to fetch from grouped endpoint:",n),H([i]),A(0)}}else H([i]),A(0);await X(t)}catch(l){O(l instanceof Error?l.message:"Unknown error occurred")}finally{R(!1),q(!1)}},[X,ie]),ie=d.useCallback(async t=>{console.log("fetchAllImages called with imageIds:",t),he(!0);try{const s=t.map(async i=>{const n=await fetch(`/api/images/${i}`);if(!n.ok)throw new Error(`Failed to fetch image ${i}`);return n.json()}),l=await Promise.all(s);H(l),A(0),console.log("fetchAllImages: Loaded",l.length,"images")}catch(s){console.error("fetchAllImages error:",s),O(s instanceof Error?s.message:"Failed to load all images")}finally{he(!1)}},[]),Je=d.useCallback(()=>{h.length>1&&A(t=>t>0?t-1:h.length-1)},[h.length]),Ve=d.useCallback(()=>{h.length>1&&A(t=>t{t>=0&&t{const s=t||(h.length>0?h[D]:e);if(s){V(!0),_e(s),fe(!0);try{const l=new Image;l.onload=()=>{V(!1)},l.onerror=()=>{V(!1)},l.src=s.image_url}catch(l){console.error("Error preloading full-size image:",l),V(!1)}}},[h,D,e]),Ge=d.useCallback(()=>{fe(!1),_e(null),V(!1)},[]);d.useEffect(()=>{if(console.log("MapDetailsPage: mapId from useParams:",g),console.log("MapDetailsPage: mapId type:",typeof g),console.log("MapDetailsPage: mapId value:",g),!g||g==="undefined"||g==="null"||g.trim()===""||g===void 0||g===null){console.log("MapDetailsPage: Invalid mapId, setting error"),O("Map ID is required"),R(!1);return}if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(g)){console.log("MapDetailsPage: Invalid UUID format:",g),O("Invalid Map ID format"),R(!1);return}console.log("MapDetailsPage: Fetching data for mapId:",g),xe(g)},[g,xe]),d.useEffect(()=>{if(!e||z||U)return;if(!g||g==="undefined"||g==="null"||g.trim()===""){console.log("Auto-navigation skipped: Invalid mapId");return}if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(g)){console.log("Auto-navigation skipped: Invalid mapId format");return}(()=>{const l=!p||e.title?.toLowerCase().includes(p.toLowerCase())||e.generated?.toLowerCase().includes(p.toLowerCase())||e.source?.toLowerCase().includes(p.toLowerCase())||e.event_type?.toLowerCase().includes(p.toLowerCase()),i=!y||e.source===y,n=!v||e.event_type===v,r=!j||e.countries.some($=>$.r_code===j),o=!w||e.countries.some($=>$.c_code===w),u=!I||e.image_type===I,_=!b||e.starred===!0,k=l&&i&&n&&r&&o&&u&&_;return console.log("Auto-navigation check:",{mapId:g,search:p,srcFilter:y,catFilter:v,regionFilter:j,countryFilter:w,imageTypeFilter:I,showReferenceExamples:b,matchesSearch:l,matchesSource:i,matchesCategory:n,matchesRegion:r,matchesCountry:o,matchesImageType:u,matchesReferenceExamples:_,matches:k}),k})()||(console.log("Current map does not match filters, looking for first matching item"),fetch("/api/images").then(l=>l.json()).then(l=>{console.log("Auto-navigation: Received images from API:",l.length),console.log("Auto-navigation: First few images:",l.slice(0,3).map(n=>({image_id:n.image_id,title:n.title})));const i=l.find(n=>{const r=!p||n.title?.toLowerCase().includes(p.toLowerCase())||n.generated?.toLowerCase().includes(p.toLowerCase())||n.source?.toLowerCase().includes(p.toLowerCase())||n.event_type?.toLowerCase().includes(p.toLowerCase()),o=!y||n.source===y,u=!v||n.event_type===v,_=!j||n.countries?.some(f=>f.r_code===j),k=!w||n.countries?.some(f=>f.c_code===w),$=!I||n.image_type===I,F=!b||n.starred===!0;return r&&o&&u&&_&&k&&$&&F});console.log("Auto-navigation: Found first matching image:",i?{image_id:i.image_id,title:i.title,source:i.source}:"No matching image found"),i&&i.image_id&&i.image_id!=="undefined"&&i.image_id!=="null"&&i.image_id.trim()!==""&&i.image_id!==g&&(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i.image_id)?(console.log("Auto-navigating to:",i.image_id),x(`/map/${i.image_id}`)):console.error("Auto-navigation blocked: Invalid image_id format:",i.image_id))}).catch(console.error))},[e,p,y,v,j,w,I,b,g,x,z,U]);const X=d.useCallback(async t=>{if(!(!t||t==="undefined"||t==="null"||t.trim()===""))try{const s=new URLSearchParams;p&&s.append("search",p),y&&s.append("source",y),v&&s.append("event_type",v),j&&s.append("region",j),w&&s.append("country",w),I&&s.append("image_type",I),N&&s.append("upload_type",N),b&&s.append("starred_only","true");const l=await fetch(`/api/images/grouped?${s.toString()}`);if(l.ok){const i=await l.json();console.log("Server response for upload_type=multiple:",{url:`/api/images/grouped?${s.toString()}`,count:i.length,images:i.map(r=>({image_id:r.image_id,image_count:r.image_count,all_image_ids:r.all_image_ids,all_image_ids_length:r.all_image_ids?.length}))});const n=i.findIndex(r=>r.image_id===t);console.log("Navigation availability check (server-side):",{filteredImagesCount:i.length,currentIndex:n,currentId:t,uploadTypeFilter:N,hasPrevious:i.length>1&&n>0,hasNext:i.length>1&&n({image_id:r.image_id,image_count:r.image_count,all_image_ids:r.all_image_ids,image_type:r.image_type}))}),Fe(i.length>1&&n>0),Pe(i.length>1&&n{if(!W){q(!0);try{const s=new URLSearchParams;p&&s.append("search",p),y&&s.append("source",y),v&&s.append("event_type",v),j&&s.append("region",j),w&&s.append("country",w),I&&s.append("image_type",I),N&&s.append("upload_type",N),b&&s.append("starred_only","true");const l=await fetch(`/api/images/grouped?${s.toString()}`);if(l.ok){const i=await l.json(),n=i.findIndex(u=>u.image_id===g);if(n===-1){console.error("Current image not found in filtered list");return}let r;t==="previous"?r=n>0?n-1:i.length-1:r=n{console.log("=== NAVIGATION USEEFFECT TRIGGERED ==="),console.log("Navigation useEffect triggered:",{map:!!e,mapId:g,loading:z,isDeleting:U,uploadTypeFilter:N,allFilters:{search:p,srcFilter:y,catFilter:v,regionFilter:j,countryFilter:w,imageTypeFilter:I,uploadTypeFilter:N,showReferenceExamples:b}}),e&&g&&!z&&!U?(console.log("Calling checkNavigationAvailability with:",g),X(g)):console.log("NOT calling checkNavigationAvailability because:",{map:!!e,mapId:!!g,loading:z,isDeleting:U})},[e,g,p,y,v,j,w,I,N,b,z,U,X]),d.useEffect(()=>{Promise.all([fetch("/api/sources").then(t=>t.json()),fetch("/api/types").then(t=>t.json()),fetch("/api/image-types").then(t=>t.json()),fetch("/api/regions").then(t=>t.json()),fetch("/api/countries").then(t=>t.json())]).then(([t,s,l,i,n])=>{Ce(t),be(s),Se(l),De(i),Me(n)}).catch(console.error)},[]);const qe=async()=>{e&&K(!0)},Ke=async()=>{if(e)try{(await fetch(`/api/images/${e.image_id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({starred:!e.starred})})).ok?ae(s=>s?{...s,starred:!s.starred}:null):console.error("Failed to toggle starred status")}catch(t){console.error("Error toggling starred status:",t)}},Ze=async()=>{if(e){Q(!0);try{if(console.log("Deleting image with ID:",e.image_id),(await fetch(`/api/images/${e.image_id}`,{method:"DELETE"})).ok){ae(s=>s?{...s,starred:!s.starred}:null),K(!1);try{const s=await fetch("/api/images/grouped");if(s.ok){const i=(await s.json()).filter(r=>{const o=!p||r.title?.toLowerCase().includes(p.toLowerCase())||r.generated?.toLowerCase().includes(p.toLowerCase())||r.source?.toLowerCase().includes(p.toLowerCase())||r.event_type?.toLowerCase().includes(p.toLowerCase()),u=!y||r.source===y,_=!v||r.event_type===v,k=!j||r.countries?.some(C=>C.r_code===j),$=!w||r.countries?.some(C=>C.c_code===w),F=!I||r.image_type===I,f=!N||N==="single"&&(!r.image_count||r.image_count<=1)||N==="multiple"&&r.image_count&&r.image_count>1,M=!b||r.starred===!0;return o&&u&&_&&k&&$&&F&&f&&M}),n=i.filter(r=>r.image_id!==e.image_id);if(n.length>0){const r=i.findIndex(u=>u.image_id===e.image_id);let o;if(r===i.length-1?o=r-1:o=r,console.log("Navigation target:",{currentIndex:r,targetIndex:o,targetId:n[o]?.image_id}),o>=0&&o{if(!e)return null;if(!p&&!y&&!v&&!j&&!w&&!I&&!N&&!b)return e;const t=!p||e.title?.toLowerCase().includes(p.toLowerCase())||e.generated?.toLowerCase().includes(p.toLowerCase())||e.source?.toLowerCase().includes(p.toLowerCase())||e.event_type?.toLowerCase().includes(p.toLowerCase()),s=!y||e.source===y,l=!v||e.event_type===v,i=!j||e.countries.some(k=>k.r_code===j),n=!w||e.countries.some(k=>k.c_code===w),r=!I||e.image_type===I,o=!N||N==="single"&&(!e.image_count||e.image_count<=1)&&(!e.all_image_ids||e.all_image_ids.length<=1)||N==="multiple"&&(e.image_count&&e.image_count>1||e.all_image_ids&&e.all_image_ids.length>1),u=!b||e.starred===!0,_=t&&s&&l&&i&&n&&r&&o&&u;return!_&&(p||y||v||j||w||I||N||b)?(setTimeout(()=>{je()},100),e):_?e:null},[e,p,y,v,j,w,I,N,b,je]),je=d.useCallback(async()=>{R(!0);try{const t=new URLSearchParams;p&&t.append("search",p),y&&t.append("source",y),v&&t.append("event_type",v),j&&t.append("region",j),w&&t.append("country",w),I&&t.append("image_type",I),N&&t.append("upload_type",N),b&&t.append("starred_only","true");const s=await fetch(`/api/images/grouped?${t.toString()}`);if(s.ok){const l=await s.json();if(l.length>0){const i=l[0];i&&i.image_id&&x(`/map/${i.image_id}`)}else x("/explore")}}catch(t){console.error("Failed to navigate to matching image:",t),x("/explore")}finally{R(!1)}},[p,y,v,j,w,I,N,b,x]),Qe=()=>{if(!e)return;if(!e.all_image_ids||e.all_image_ids.length<=1){const i=`/upload?step=1&contribute=true&imageIds=${[e.image_id].join(",")}`;x(i);return}const s=`/upload?step=1&contribute=true&imageIds=${e.all_image_ids.join(",")}`;x(s)},T=(t,s)=>({image:`images/${s}`,caption:t.edited||t.generated||"",metadata:{image_id:t.image_count&&t.image_count>1?t.all_image_ids||[t.image_id]:t.image_id,title:t.title,source:t.source,event_type:t.event_type,image_type:t.image_type,countries:t.countries,starred:t.starred,image_count:t.image_count||1}}),Xe=async t=>{if(e){te(!0),se(!1);try{const s=(await oa(async()=>{const{default:o}=await import("./jszip.min-uuN5m5dK.js").then(u=>u.j);return{default:o}},__vite__mapDeps([0,1,2]))).default,l=new s;if(e.image_type==="crisis_map"){const o=l.folder("crisis_maps_dataset"),u=o?.folder("images");if(u)try{const _=e.image_count&&e.image_count>1?e.all_image_ids||[e.image_id]:[e.image_id],k=_.map(async(f,M)=>{try{const C=await fetch(`/api/images/${f}/file`);if(!C.ok)throw new Error(`Failed to fetch image ${f}`);const S=await C.blob(),Y=e.file_key.split(".").pop()||"jpg",B=`0001_${String(M+1).padStart(2,"0")}.${Y}`;return u.file(B,S),{success:!0,fileName:B,imageId:f}}catch(C){return console.error(`Failed to process image ${f}:`,C),{success:!1,fileName:"",imageId:f}}}),F=(await Promise.all(k)).filter(f=>f.success);if(F.length===0)throw new Error("No images could be processed");if(t==="fine-tuning"){const f=[],M=[],C=[],S=F.map(Ye=>`images/${Ye.fileName}`),Y=Math.random(),B={image:S.length===1?S[0]:S,caption:e.edited||e.generated||"",metadata:{image_id:_,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};Y`images/${C.fileName}`),M={image:f.length===1?f[0]:f,caption:e.edited||e.generated||"",metadata:{image_id:_,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};o&&o.file("0001.json",JSON.stringify(M,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}else if(e.image_type==="drone_image"){const o=l.folder("drone_images_dataset"),u=o?.folder("images");if(u)try{const _=await fetch(`/api/images/${e.image_id}/file`);if(!_.ok)throw new Error(`Failed to fetch image ${e.image_id}`);const k=await _.blob(),F=`0001.${e.file_key.split(".").pop()||"jpg"}`;if(u.file(F,k),t==="fine-tuning"){const f=[],M=[],C=[];if(String(e?.image_type)==="crisis_map"){const S=Math.random();S1?e.all_image_ids||[e.image_id]:e.image_id,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};o&&o.file("0001.json",JSON.stringify(f,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}else{const o=l.folder("generic_dataset"),u=o?.folder("images");if(u)try{const _=await fetch(`/api/images/${e.image_id}/file`);if(!_.ok)throw new Error(`Failed to fetch image ${e.image_id}`);const k=await _.blob(),F=`0001.${e.file_key.split(".").pop()||"jpg"}`;if(u.file(F,k),t==="fine-tuning"){const f=[],M=[],C=[];if(String(e?.image_type)==="crisis_map"){const S=Math.random();S1?e.all_image_ids||[e.image_id]:e.image_id,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};o&&o.file("0001.json",JSON.stringify(f,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}const i=await l.generateAsync({type:"blob"}),n=URL.createObjectURL(i),r=document.createElement("a");r.href=n,r.download=`dataset_${e.image_type}_${e.image_id}_${t}_${new Date().toISOString().split("T")[0]}.zip`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n),console.log(`Exported ${e.image_type} dataset with 1 image in ${t} mode`),se(!0)}catch(s){console.error("Export failed:",s),alert("Failed to export dataset. Please try again.")}finally{te(!1)}}};return z?a.jsx(ee,{children:a.jsx("div",{className:m.loadingContainer,children:a.jsxs("div",{className:"flex flex-col items-center gap-4",children:[a.jsx(we,{className:"text-ifrcRed"}),a.jsx("div",{children:"Loading map details..."})]})})}):ce||!e?a.jsx(ee,{children:a.jsx("div",{className:m.errorContainer,children:a.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[a.jsx("div",{className:"text-4xl",children:"⚠️"}),a.jsx("div",{className:"text-xl font-semibold",children:"Unable to load map"}),a.jsx("div",{children:ce||"Map not found"}),a.jsx(L,{name:"back-to-explore",variant:"secondary",onClick:()=>x("/explore"),children:"Return to Explore"})]})})}):a.jsxs(ee,{children:[a.jsxs("div",{className:"max-w-7xl mx-auto",children:[a.jsxs("div",{className:m.tabSelector,children:[a.jsx(sa,{name:"map-details-view",value:le,onChange:t=>{(t==="mapDetails"||t==="explore")&&(Ne(t),t==="explore"&&x("/explore"))},options:We,keySelector:t=>t.key,labelSelector:t=>t.label}),a.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[a.jsx(P,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:a.jsxs(L,{name:"reference-examples",variant:b?"primary":"secondary",onClick:()=>Ue(!b),className:"whitespace-nowrap",children:[a.jsx("span",{className:"mr-2",children:b?a.jsx("span",{className:"text-yellow-400",children:"★"}):a.jsx("span",{className:"text-yellow-400",children:"☆"})}),"Reference Examples"]})}),a.jsx(L,{name:"export-dataset",variant:"secondary",onClick:()=>Z(!0),children:"Export"})]})]}),a.jsx(la,{sources:de,types:ge,regions:ue,countries:ke,imageTypes:me,isLoadingFilters:!1}),le==="mapDetails"?a.jsx("div",{className:"relative",children:c?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:m.gridLayout,children:[a.jsxs(P,{heading:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{children:c.title||"Map Image"}),c.starred&&a.jsx("span",{className:"text-red-500 text-xl",title:"Starred image",children:"★"})]}),headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,spacing:"comfortable",children:[a.jsx("div",{className:m.imageContainer,children:e?.image_count&&e.image_count>1||h.length>1?a.jsxs("div",{className:m.carouselContainer,children:[a.jsx("div",{className:m.carouselImageWrapper,children:G?a.jsxs("div",{className:m.imagePlaceholder,children:[a.jsx(we,{className:"text-ifrcRed"}),a.jsx("div",{children:"Loading images..."})]}):h[D]?.detail_url?a.jsx("img",{src:h[D].detail_url,alt:h[D].file_key,className:m.carouselImage,onError:t=>{console.log("MapDetailsPage: Detail image failed to load, falling back to original:",h[D].detail_url);const s=t.target;h[D].image_url&&(s.src=h[D].image_url)},onLoad:()=>console.log("MapDetailsPage: Detail image loaded successfully:",h[D].detail_url)}):h[D]?.image_url?a.jsx("img",{src:h[D].image_url,alt:h[D].file_key,className:m.carouselImage,onLoad:()=>console.log("MapDetailsPage: Original image loaded successfully:",h[D].image_url)}):a.jsx("div",{className:m.imagePlaceholder,children:"No image available"})}),a.jsxs("div",{className:m.carouselNavigation,children:[a.jsx(L,{name:"previous-image",variant:"tertiary",size:1,onClick:Je,disabled:G,className:m.carouselButton,children:a.jsx(ne,{className:"w-4 h-4"})}),a.jsx("div",{className:m.carouselIndicators,children:h.map((t,s)=>a.jsx("button",{onClick:()=>He(s),className:`${m.carouselIndicator} ${s===D?m.carouselIndicatorActive:""}`,disabled:G,children:s+1},s))}),a.jsx(L,{name:"next-image",variant:"tertiary",size:1,onClick:Ve,disabled:G,className:m.carouselButton,children:a.jsx(oe,{className:"w-4 h-4"})})]}),a.jsx("div",{className:m.viewImageButtonContainer,children:a.jsx(L,{name:"view-full-size-carousel",variant:"secondary",size:1,onClick:()=>ye(h[D]),disabled:G||!h[D]?.image_url,children:"View Image"})})]}):a.jsxs("div",{className:m.singleImageContainer,children:[c.detail_url?a.jsx("img",{src:c.detail_url,alt:c.file_key,onError:t=>{console.log("MapDetailsPage: Detail image failed to load, falling back to original:",c.detail_url);const s=t.target;c.image_url&&(s.src=c.image_url)},onLoad:()=>console.log("MapDetailsPage: Detail image loaded successfully:",c.detail_url)}):c.image_url?a.jsx("img",{src:c.image_url,alt:c.file_key,onLoad:()=>console.log("MapDetailsPage: Original image loaded successfully:",c.image_url)}):a.jsx("div",{className:m.imagePlaceholder,children:"No image available"}),a.jsx("div",{className:m.viewImageButtonContainer,children:a.jsx(L,{name:"view-full-size-single",variant:"secondary",size:1,onClick:()=>ye(c),disabled:!c.image_url,children:"View Image"})})]})}),a.jsx(P,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:a.jsxs("div",{className:m.metadataTags,children:[c.image_type!=="drone_image"&&a.jsx("span",{className:m.metadataTag,children:de.find(t=>t.s_code===c.source)?.label||c.source}),a.jsx("span",{className:m.metadataTag,children:ge.find(t=>t.t_code===c.event_type)?.label||c.event_type}),a.jsx("span",{className:m.metadataTag,children:me.find(t=>t.image_type===c.image_type)?.label||c.image_type}),c.countries&&c.countries.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:m.metadataTag,children:ue.find(t=>t.r_code===c.countries[0].r_code)?.label||"Unknown Region"}),a.jsx("span",{className:m.metadataTag,children:c.countries.map(t=>t.label).join(", ")})]}),c.image_count&&c.image_count>1&&a.jsxs("span",{className:m.metadataTag,title:`Multi-upload with ${c.image_count} images`,children:["📷 ",c.image_count]}),(!c.image_count||c.image_count<=1)&&a.jsx("span",{className:m.metadataTag,title:"Single Upload",children:"Single"})]})})]}),a.jsx("div",{className:m.detailsSection,children:c.edited&&c.edited.includes("Description:")||c.generated&&c.generated.includes("Description:")?a.jsx(P,{heading:"AI Generated Content",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,spacing:"comfortable",children:a.jsx("div",{className:m.captionContainer,children:a.jsx("div",{className:m.captionText,children:(c.edited||c.generated||"").split(/(Description:|Analysis:|Recommended Actions:)/).map((l,i)=>l.trim()===""?null:l==="Description:"||l==="Analysis:"||l==="Recommended Actions:"?a.jsx("h4",{className:"font-semibold text-gray-800 mt-4 mb-2",children:l},i):a.jsx("p",{className:"mb-2",children:l.trim()},i))})})}):a.jsx(P,{heading:"Description",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,spacing:"comfortable",children:a.jsx("div",{className:m.captionContainer,children:c.generated||c.edited?a.jsx("div",{className:m.captionText,children:a.jsx("p",{children:c.edited||c.generated})}):a.jsx("p",{children:"— no caption yet —"})})})})]}),a.jsx("div",{className:"flex items-center justify-center mt-8",children:a.jsx(P,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center gap-4",children:[Le&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"previous-item",variant:"tertiary",size:1,className:`bg-white/90 hover:bg-white shadow-lg border border-gray-200 ${W?"opacity-50 cursor-not-allowed":"hover:scale-110"}`,onClick:()=>ve("previous"),disabled:W,children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("div",{className:"flex -space-x-1",children:[a.jsx(ne,{className:"w-4 h-4"}),a.jsx(ne,{className:"w-4 h-4"})]}),a.jsx("span",{className:"font-semibold",children:"Previous"})]})})}),re&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"delete",variant:"tertiary",size:1,className:"bg-red-50 hover:bg-red-100 text-red-700 border border-red-200 hover:border-red-300",onClick:qe,title:"Delete","aria-label":"Delete saved image",children:a.jsx(ia,{className:"w-4 h-4"})})}),a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"contribute",onClick:Qe,children:"Contribute"})}),re&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"toggle-star",variant:"tertiary",size:1,className:`${e?.starred?"bg-red-100 hover:bg-red-200 text-red-800 border-2 border-red-400":"bg-gray-100 hover:bg-gray-200 text-gray-600 border-2 border-gray-300"} w-16 h-8 rounded-full transition-all duration-200 flex items-center justify-center`,onClick:Ke,title:e?.starred?"Unstar image":"Star image","aria-label":e?.starred?"Unstar image":"Star image",children:a.jsx("span",{className:`text-lg transition-all duration-200 ${e?.starred?"text-red-600":"text-gray-500"}`,children:e?.starred?"★":"☆"})})}),Te&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"next-item",variant:"tertiary",size:1,className:`bg-white/90 hover:bg-white shadow-lg border border-gray-200 ${W?"opacity-50 cursor-not-allowed":"hover:scale-110"}`,onClick:()=>ve("next"),disabled:W,children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"font-semibold",children:"Next"}),a.jsxs("div",{className:"flex -space-x-1",children:[a.jsx(oe,{className:"w-4 h-4"}),a.jsx(oe,{className:"w-4 h-4"})]})]})})})]})})})]}):a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"text-xl font-semibold text-gray-600 mb-4",children:"No matches found"}),a.jsx("div",{className:"mt-4",children:a.jsx(L,{name:"clear-filters",variant:"secondary",onClick:Be,children:"Clear Filters"})})]})}):null]}),Ee&&a.jsx("div",{className:m.fullSizeModalOverlay,onClick:()=>K(!1),children:a.jsx("div",{className:m.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:a.jsxs("div",{className:m.ratingWarningContent,children:[a.jsx("h3",{className:m.ratingWarningTitle,children:"Delete Image?"}),a.jsx("p",{className:m.ratingWarningText,children:"This action cannot be undone. Are you sure you want to delete this saved image and all related data?"}),a.jsxs("div",{className:m.ratingWarningButtons,children:[a.jsx(L,{name:"confirm-delete",variant:"secondary",onClick:Ze,children:"Delete"}),a.jsx(L,{name:"cancel-delete",variant:"tertiary",onClick:()=>K(!1),children:"Cancel"})]})]})})}),pe&&a.jsx(ca,{isOpen:pe,onClose:()=>{Z(!1),se(!1),te(!1)},onExport:(t,s)=>{s.includes(e.image_type)&&Xe(t)},filteredCount:1,totalCount:1,hasFilters:!1,crisisMapsCount:e.image_type==="crisis_map"?1:0,droneImagesCount:e.image_type==="drone_image"?1:0,isLoading:$e,exportSuccess:Re,variant:"single",onNavigateToList:()=>{Z(!1),x("/explore")},onNavigateAndExport:()=>{Z(!1),x("/explore?export=true")}}),a.jsx(na,{isOpen:Ae,imageUrl:ze?.image_url||null,preview:null,selectedImageData:null,onClose:Ge,isLoading:Oe})]})}export{st as default}; diff --git a/py_backend/static/assets/jszip.min-BuKhrC7_.js b/py_backend/static/assets/jszip.min-uuN5m5dK.js similarity index 99% rename from py_backend/static/assets/jszip.min-BuKhrC7_.js rename to py_backend/static/assets/jszip.min-uuN5m5dK.js index 4d3260a44f638a01052d50d2fbb9cc6e6b1c15af..3dcbfc474082b44202866b4c096dc7462d03c5e8 100644 --- a/py_backend/static/assets/jszip.min-BuKhrC7_.js +++ b/py_backend/static/assets/jszip.min-uuN5m5dK.js @@ -1,4 +1,4 @@ -import{X as bt,Y as It}from"./index-DieRAFRn.js";function vt(yt){throw new Error('Could not dynamically require "'+yt+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var kt={exports:{}};/*! +import{X as bt,Y as It}from"./index-B0L3qvtx.js";function vt(yt){throw new Error('Could not dynamically require "'+yt+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var kt={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files diff --git a/py_backend/static/assets/useAdmin-SWj4UX1Y.js b/py_backend/static/assets/useAdmin-DN0iYnPm.js similarity index 65% rename from py_backend/static/assets/useAdmin-SWj4UX1Y.js rename to py_backend/static/assets/useAdmin-DN0iYnPm.js index 57c2f377b1cdeb141857a35787af8d48e118815a..3744a7d2638015bbd158c713701f8e746887a034 100644 --- a/py_backend/static/assets/useAdmin-SWj4UX1Y.js +++ b/py_backend/static/assets/useAdmin-DN0iYnPm.js @@ -1 +1 @@ -import{r,W as e}from"./index-DieRAFRn.js";const o=()=>{const t=r.useContext(e);if(t===void 0)throw new Error("useAdmin must be used within an AdminProvider");return t};export{o as u}; +import{r,W as e}from"./index-B0L3qvtx.js";const o=()=>{const t=r.useContext(e);if(t===void 0)throw new Error("useAdmin must be used within an AdminProvider");return t};export{o as u}; diff --git a/py_backend/static/index.html b/py_backend/static/index.html index c13f87fe6181164cd4ebca4be7299dd70d5f2e96..709b49bebc4d1f479d7f7892517da7b2a13b1cf4 100644 --- a/py_backend/static/index.html +++ b/py_backend/static/index.html @@ -42,7 +42,7 @@ }); } - +