SCGR commited on
Commit
ba2fd37
·
1 Parent(s): fc6253e
frontend/src/App.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { createHashRouter, RouterProvider } from 'react-router-dom';
2
  import { AlertContext, type AlertContextProps, type AlertParams, LanguageContext, type LanguageContextProps } from '@ifrc-go/ui/contexts';
3
  import { useCallback, useMemo, useState, lazy, Suspense, useEffect } from 'react';
4
  import { unique } from '@togglecorp/fujs';
@@ -48,7 +48,7 @@ const prefetchAllPages = () => {
48
  }
49
  };
50
 
51
- const router = createHashRouter([
52
  {
53
  element: <RootLayout />,
54
  children: [
@@ -90,7 +90,9 @@ const router = createHashRouter([
90
  },
91
  ],
92
  },
93
- ]);
 
 
94
 
95
  function Application() {
96
  const [alerts, setAlerts] = useState<AlertParams[]>([]);
 
1
+ import { createBrowserRouter, RouterProvider } from 'react-router-dom';
2
  import { AlertContext, type AlertContextProps, type AlertParams, LanguageContext, type LanguageContextProps } from '@ifrc-go/ui/contexts';
3
  import { useCallback, useMemo, useState, lazy, Suspense, useEffect } from 'react';
4
  import { unique } from '@togglecorp/fujs';
 
48
  }
49
  };
50
 
51
+ const router = createBrowserRouter([
52
  {
53
  element: <RootLayout />,
54
  children: [
 
90
  },
91
  ],
92
  },
93
+ ], {
94
+ basename: import.meta.env.BASE_URL, // This will be '/app/' from Vite
95
+ });
96
 
97
  function Application() {
98
  const [alerts, setAlerts] = useState<AlertParams[]>([]);
py_backend/static/assets/AdminPage-KksT68Fe.js ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{r as d,j as a}from"./vendor-react-BxsGb6Ph.js";import{u as we}from"./useAdmin-6S8boYmH.js";import{N as B,R as Fe,O as h,z as f,n as t,f as S}from"./vendor-ui-l_DttnRj.js";import"./vendor-DxpCibxB.js";import"./index-C6NSRolP.js";const ke="_adminContainer_j11pf_5",Te="_adminHeader_j11pf_13",Ae="_adminSection_j11pf_20",Pe="_modelSelectionArea_j11pf_29",Ie="_modelSelectionRow_j11pf_36",$e="_modelsTable_j11pf_89",Le="_promptSubsection_j11pf_97",Ee="_promptSubsectionTitle_j11pf_109",Be="_modelCode_j11pf_152",Oe="_modelId_j11pf_157",Re="_modelActions_j11pf_163",De="_addModelButtonContainer_j11pf_169",Ue="_addModelForm_j11pf_177",ze="_addModelFormTitle_j11pf_185",He="_addModelFormGrid_j11pf_193",Ge="_addModelFormField_j11pf_206",Ve="_addModelFormCheckbox_j11pf_250",Je="_addModelFormActions_j11pf_268",Ke="_modalOverlay_j11pf_277",We="_modalContent_j11pf_291",qe="_modalBody_j11pf_302",Ye="_modalTitle_j11pf_312",Qe="_modalText_j11pf_320",Xe="_modalTextLeft_j11pf_332",Ze="_modalButtons_j11pf_355",ea="_modalForm_j11pf_363",aa="_formField_j11pf_372",la="_formLabel_j11pf_376",sa="_formInput_j11pf_385",oa="_textarea_j11pf_407",l={adminContainer:ke,adminHeader:Te,adminSection:Ae,modelSelectionArea:Pe,modelSelectionRow:Ie,modelsTable:$e,promptSubsection:Le,promptSubsectionTitle:Ee,modelCode:Be,modelId:Oe,modelActions:Re,addModelButtonContainer:De,addModelForm:Ue,addModelFormTitle:ze,addModelFormGrid:He,addModelFormField:Ge,addModelFormCheckbox:Ve,addModelFormActions:Je,modalOverlay:Ke,modalContent:We,modalBody:qe,modalTitle:Ye,modalText:Qe,modalTextLeft:Xe,modalButtons:Ze,modalForm:ea,formField:aa,formLabel:la,formInput:sa,textarea:oa},w="selectedVlmModel";function ca(){const{isAuthenticated:F,isLoading:X,login:Z,logout:ee}=we(),[k,O]=d.useState(""),[R,u]=d.useState(""),[D,U]=d.useState(!1),[z,H]=d.useState([]),[ae,b]=d.useState(""),[G,le]=d.useState([]),[se,oe]=d.useState([]),[te,y]=d.useState(!1),[de,N]=d.useState(!1),[ie,T]=d.useState(null),[C,A]=d.useState(null),[n,r]=d.useState({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1}),[V,P]=d.useState(!1),[ne,I]=d.useState(!1),[$,L]=d.useState(null),[o,c]=d.useState({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1}),[re,M]=d.useState(!1),[ce,E]=d.useState(!1),[me,p]=d.useState(!1),[J,K]=d.useState(""),[he,pe]=d.useState(""),[_e,_]=d.useState(""),[ue,j]=d.useState(""),x=d.useCallback(()=>{fetch("/api/models").then(e=>e.json()).then(e=>{console.log("Models data received:",e),H(e.models||[]);const s=localStorage.getItem(w);if(e.models&&e.models.length>0)if(s==="random")b("random");else if(s&&e.models.find(i=>i.m_code===s&&i.is_available))b(s);else{const i=e.models.find(m=>m.is_available)||e.models[0];b(i.m_code),localStorage.setItem(w,i.m_code)}}).catch(()=>{})},[]),v=d.useCallback(()=>{console.log("=== fetchPrompts called ==="),fetch("/api/prompts").then(e=>e.json()).then(e=>{console.log("Prompts data received:",e),le(e||[]),console.log("State update triggered with:",e||[])}).catch(e=>{console.error("Error fetching prompts:",e)})},[]),W=d.useCallback(()=>{fetch("/api/image-types").then(e=>e.json()).then(e=>{console.log("Image types data received:",e),oe(e||[])}).catch(()=>{})},[]);d.useEffect(()=>{F&&(x(),v(),W())},[F,x,v,W]);const q=e=>{A(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}),y(!0)},je=async()=>{try{if(!C){alert("No prompt selected for editing");return}const e=await fetch(`/api/prompts/${C.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)v(),y(!1),A(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")}},Y=async(e,s)=>{try{const i=await fetch(`/api/prompts/${e}/toggle-active?image_type=${s}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(i.ok)v();else{const m=await i.json();alert(`Failed to toggle prompt active status: ${m.detail||"Unknown error"}`)}}catch{alert("Error toggling prompt active status")}},Q=e=>{T(e),r({p_code:"",label:"",metadata_instructions:"",image_type:e,is_active:!1}),N(!0)},xe=async()=>{try{const e=await fetch("/api/prompts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(e.ok)v(),N(!1),T(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")}},ve=async(e,s)=>{try{const i=await fetch(`/api/models/${e}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_available:!s})});if(i.ok)H(m=>m.map(g=>g.m_code===e?{...g,is_available:!s}:g));else{const m=await i.json();alert(`Failed to toggle model availability: ${m.error||"Unknown error"}`)}}catch{alert("Error toggling model availability")}},ge=e=>{b(e),e==="random"?localStorage.setItem(w,"random"):localStorage.setItem(w,e)},fe=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=`
2
+ Model "${o.label}" added successfully!
3
+
4
+ ⚠️ IMPORTANT: Model will NOT work until you complete these steps:
5
+
6
+ 1. 🔑 Ensure API key is set and valid.
7
+
8
+ 2. 📝 Verify model_id format.
9
+
10
+ 3. 📚 Check model specific documentation for details.
11
+ `;pe(s),E(!0),P(!1),c({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1}),x()}else{const s=await e.json();alert(`Failed to add model: ${s.detail||"Unknown error"}`)}}catch{alert("Error adding model")}},be=e=>{L(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}),I(!0)},ye=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),!$){alert("No model selected for editing");return}const s=await fetch(`/api/admin/models/${$.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 i=await s.json();console.log("Update successful:",i),I(!1),L(null),c({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1}),console.log("Refreshing models..."),x()}else{const i=await s.json();console.error("Update failed:",i),alert(`Failed to update model: ${i.detail||"Unknown error"}`)}}catch(e){console.error("Update error:",e),alert("Error updating model")}},Ne=async e=>{K(e),M(!0)},Ce=async()=>{try{const e=await fetch(`/api/admin/models/${J}`,{method:"DELETE",headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}});if(e.ok)M(!1),K(""),x();else{const s=await e.json();alert(`Failed to delete model: ${s.detail||"Unknown error"}`)}}catch{alert("Error deleting model")}},Me=async e=>{if(e.preventDefault(),!k.trim()){u("Please enter a password");return}U(!0),u("");try{await Z(k)||u("Invalid password")}catch{u("Login failed. Please try again.")}finally{U(!1)}},Se=()=>{ee(),O(""),u("")};return X?a.jsx(B,{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..."})]})})}):F?a.jsxs(B,{children:[a.jsxs("div",{className:l.adminContainer,children:[a.jsx("div",{className:l.adminHeader,children:a.jsx(t,{name:"logout",variant:"secondary",onClick:Se,children:"Logout"})}),a.jsxs("div",{className:l.adminSection,children:[a.jsx(f,{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.jsx("div",{className:l.modelSelectionRow,children:a.jsx(S,{label:"Model",name:"selected-model",value:ae,onChange:e=>ge(e||""),options:[{value:"random",label:"Random"},...z.filter(e=>e.is_available).map(e=>({value:e.m_code,label:e.label}))],keySelector:e=>e.value,labelSelector:e=>e.label})})]})}),a.jsx(f,{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:z.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(t,{name:`toggle-${e.m_code}`,variant:e.is_available?"primary":"secondary",size:1,onClick:()=>ve(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(t,{name:`edit-${e.m_code}`,variant:"secondary",size:1,onClick:()=>be(e),children:"Edit"}),a.jsx(t,{name:`delete-${e.m_code}`,variant:"secondary",size:1,onClick:()=>Ne(e.m_code),children:"Delete"})]})})]},e.m_code))})]})}),!V&&a.jsx("div",{className:l.addModelButtonContainer,children:a.jsx(t,{name:"show-add-form",variant:"primary",onClick:()=>P(!0),children:"Add New Model"})}),V&&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(h,{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(h,{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(S,{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(h,{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(t,{name:"save-model",variant:"primary",onClick:fe,disabled:!o.m_code||!o.label||!o.model_id,children:"Save Model"}),a.jsx(t,{name:"cancel-add",variant:"secondary",onClick:()=>P(!1),children:"Cancel"})]})]}),ne&&a.jsxs("div",{className:l.addModelForm,children:[a.jsxs("h4",{className:l.addModelFormTitle,children:["Edit Model: ",$?.label]}),a.jsxs("div",{className:l.addModelFormGrid,children:[a.jsx("div",{className:l.addModelFormField,children:a.jsx(h,{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(h,{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(S,{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(h,{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(t,{name:"update-model",variant:"primary",onClick:ye,disabled:!o.m_code||!o.label||!o.model_id,children:"Update Model"}),a.jsx(t,{name:"cancel-edit",variant:"secondary",onClick:()=>{I(!1),L(null),c({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1})},children:"Cancel"})]})]})]})}),a.jsx(f,{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:G.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(t,{name:`toggle-crisis-${e.p_code}`,variant:e.is_active?"primary":"secondary",size:1,onClick:()=>Y(e.p_code,"crisis_map"),children:e.is_active?"Active":"Inactive"})}),a.jsx("td",{children:a.jsxs("div",{className:l.modelActions,children:[a.jsx(t,{name:`view-${e.p_code}`,variant:"secondary",size:1,onClick:()=>{_(`=== Prompt Details ===
12
+ Code: ${e.p_code}
13
+ Label: ${e.label}
14
+ Image Type: ${e.image_type}
15
+ Active: ${e.is_active}
16
+
17
+ Metadata Instructions:
18
+ ${e.metadata_instructions||"No instructions available"}`),j(`Prompt: ${e.p_code}`),p(!0)},children:"View"}),a.jsx(t,{name:`edit-${e.p_code}`,variant:"secondary",size:1,onClick:()=>q(e),children:"Edit"})]})})]},e.p_code))})]})}),a.jsx("div",{className:l.addModelButtonContainer,children:a.jsx(t,{name:"add-crisis-prompt",variant:"primary",onClick:()=>Q("crisis_map"),children:"Add New Crisis Map Prompt"})})]}),a.jsxs("div",{className:l.promptSubsection,children:[a.jsx("h4",{className:l.promptSubsectionTitle,children:"Drone Images"}),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:G.filter(e=>e.image_type==="drone_image").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(t,{name:`toggle-drone-${e.p_code}`,variant:e.is_active?"primary":"secondary",size:1,onClick:()=>Y(e.p_code,"drone_image"),children:e.is_active?"Active":"Inactive"})}),a.jsx("td",{children:a.jsxs("div",{className:l.modelActions,children:[a.jsx(t,{name:`view-${e.p_code}`,variant:"secondary",size:1,onClick:()=>{_(`=== Prompt Details ===
19
+ Code: ${e.p_code}
20
+ Label: ${e.label}
21
+ Image Type: ${e.image_type}
22
+ Active: ${e.is_active}
23
+
24
+ Metadata Instructions:
25
+ ${e.metadata_instructions||"No instructions available"}`),j(`Prompt: ${e.p_code}`),p(!0)},children:"View"}),a.jsx(t,{name:`edit-${e.p_code}`,variant:"secondary",size:1,onClick:()=>q(e),children:"Edit"})]})})]},e.p_code))})]})}),a.jsx("div",{className:l.addModelButtonContainer,children:a.jsx(t,{name:"add-drone-prompt",variant:"primary",onClick:()=>Q("drone_image"),children:"Add New Drone Image Prompt"})})]})]})}),a.jsx(f,{heading:"Utilities",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsxs("div",{className:"flex flex-wrap gap-4",children:[a.jsx(t,{name:"test-connection",variant:"secondary",onClick:async()=>{_("Testing API connection..."),j("Connection Test Results");try{const e=await fetch("/api/models");if(e.ok){const s=await e.json(),i=`✅ API connection successful!
26
+
27
+ Found ${s.models?.length||0} models in database.
28
+
29
+ Available models:
30
+ ${s.models?.filter(m=>m.is_available).map(m=>`- ${m.label} (${m.m_code})`).join(`
31
+ `)||"None"}`;_(i)}else{const s=`❌ API connection failed: HTTP ${e.status}`;_(s)}p(!0)}catch(e){const s=`❌ Connection error: ${e}`;_(s),p(!0)}},children:"Test Connection"}),a.jsx(t,{name:"view-schemas",variant:"secondary",onClick:()=>{fetch("/api/schemas",{headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}}).then(e=>e.json()).then(e=>{console.log("Schemas Response:",e);let s="",i="Schemas Response";e&&Array.isArray(e)?(s=`Found ${e.length} schemas:
32
+
33
+ `,e.forEach((m,g)=>{s+=`=== Schema ${g+1} ===
34
+ `,s+=JSON.stringify(m,null,2),s+=`
35
+
36
+ `})):e&&typeof e=="object"?s=`Prompts Response:
37
+
38
+ Response type: ${typeof e}
39
+ Keys: ${Object.keys(e).join(", ")}
40
+
41
+ Raw data:
42
+ ${JSON.stringify(e,null,2)}`:s=`Prompts Response:
43
+
44
+ Unexpected data type: ${typeof e}
45
+ Value: ${e}`,_(s),j(i),p(!0)}).catch(e=>{console.error("Schemas Error:",e);const s=`Failed to fetch prompts: ${e.message||"Unknown error"}`;_(s),j("Schemas Error"),p(!0)})},children:"View Schemas"})]})})]})]}),re&&a.jsx("div",{className:l.modalOverlay,onClick:()=>M(!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:J}),"? This action cannot be undone."]}),a.jsxs("div",{className:l.modalButtons,children:[a.jsx(t,{name:"cancel-delete",variant:"tertiary",onClick:()=>M(!1),children:"Cancel"}),a.jsx(t,{name:"confirm-delete",variant:"secondary",onClick:Ce,children:"Delete"})]})]})})}),ce&&a.jsx("div",{className:l.modalOverlay,onClick:()=>E(!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:he}),a.jsx("div",{className:l.modalButtons,children:a.jsx(t,{name:"close-setup-instructions",variant:"secondary",onClick:()=>E(!1),children:"Got it!"})})]})})}),me&&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:ue}),a.jsx("div",{className:`${l.modalText} ${l.modalTextLeft}`,children:a.jsx("div",{className:"whitespace-pre-wrap font-mono text-sm leading-relaxed",children:_e})}),a.jsx("div",{className:l.modalButtons,children:a.jsx(t,{name:"close-test-results",variant:"secondary",onClick:()=>p(!1),children:"Close"})})]})})}),te&&a.jsx("div",{className:l.modalOverlay,onClick:()=>y(!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: ",C?.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(h,{name:"prompt-code",value:C?.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(h,{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(S,{name:"prompt-image-type",value:n.image_type,onChange:e=>r(s=>({...s,image_type:e||"crisis_map"})),options:se,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(t,{name:"cancel-edit-prompt",variant:"tertiary",onClick:()=>{y(!1),A(null),r({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1})},children:"Cancel"}),a.jsx(t,{name:"save-prompt",variant:"primary",onClick:je,children:"Save Changes"})]})]})})}),de&&a.jsx("div",{className:l.modalOverlay,onClick:()=>N(!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 ",ie==="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(h,{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(h,{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(h,{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(t,{name:"cancel-add-prompt",variant:"tertiary",onClick:()=>{N(!1),T(null),r({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1})},children:"Cancel"}),a.jsx(t,{name:"save-new-prompt",variant:"primary",onClick:xe,disabled:!n.p_code||!n.label,children:"Create Prompt"})]})]})})})]}):a.jsx(B,{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(Fe,{level:2,children:"Admin Login"})}),a.jsxs("form",{onSubmit:Me,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(h,{id:"password",name:"password",type:"password",value:k,onChange:e=>O(e||""),placeholder:"Enter admin password",required:!0,className:"w-full"})]}),R&&a.jsx("div",{className:"bg-ifrcRed/10 border border-ifrcRed/20 rounded-md p-3",children:a.jsx("p",{className:"text-sm text-ifrcRed font-medium",children:R})}),a.jsx("div",{className:"flex justify-center",children:a.jsx(f,{withInternalPadding:!0,className:"p-2",children:a.jsx(t,{name:"login",type:"submit",variant:"primary",size:2,disabled:D,children:D?"Logging in...":"Login"})})})]})]})})}export{ca as default};
py_backend/static/assets/ExportModal-5QTtY4mk.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{r as o,j as e}from"./vendor-react-BxsGb6Ph.js";import{z as i,n as r,F as W,O,f as v,d as P,_ as N,L as B,j as F}from"./vendor-ui-l_DttnRj.js";import{u as A}from"./index-C6NSRolP.js";function ie({sources:_,types:S,regions:f,countries:I,imageTypes:k,isLoadingFilters:a=!1}){const[d,y]=o.useState(!1),{search:T,setSearch:p,srcFilter:w,setSrcFilter:m,catFilter:z,setCatFilter:u,regionFilter:h,setRegionFilter:g,countryFilter:x,setCountryFilter:j,imageTypeFilter:M,setImageTypeFilter:b,uploadTypeFilter:E,setUploadTypeFilter:C,showReferenceExamples:c,setShowReferenceExamples:t,clearAllFilters:n}=A();return e.jsxs("div",{className:"mb-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsx(i,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:e.jsx(r,{name:"toggle-filters",variant:"secondary",onClick:()=>y(!d),className:"whitespace-nowrap",title:d?"Hide Filters":"Show Filters",children:e.jsx(W,{className:"w-4 h-4"})})}),e.jsx(i,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2 flex-1 min-w-[300px]",children:e.jsx(O,{name:"search",placeholder:"Search examples...",value:T,onChange:l=>p(l||"")})}),e.jsx(i,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:e.jsx(r,{name:"clear-filters",variant:"secondary",onClick:n,children:"Clear Filters"})})]}),d&&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(i,{withInternalPadding:!0,className:"p-2",children:e.jsx(v,{name:"source",placeholder:a?"Loading...":"All Sources",options:_,value:w||null,onChange:l=>m(l||""),keySelector:l=>l.s_code,labelSelector:l=>l.label,required:!1,disabled:a})}),e.jsx(i,{withInternalPadding:!0,className:"p-2",children:e.jsx(v,{name:"category",placeholder:a?"Loading...":"All Categories",options:S,value:z||null,onChange:l=>u(l||""),keySelector:l=>l.t_code,labelSelector:l=>l.label,required:!1,disabled:a})}),e.jsx(i,{withInternalPadding:!0,className:"p-2",children:e.jsx(v,{name:"region",placeholder:a?"Loading...":"All Regions",options:f,value:h||null,onChange:l=>g(l||""),keySelector:l=>l.r_code,labelSelector:l=>l.label,required:!1,disabled:a})}),e.jsx(i,{withInternalPadding:!0,className:"p-2",children:e.jsx(P,{name:"country",placeholder:a?"Loading...":"All Countries",options:I,value:x?[x]:[],onChange:l=>j(l[0]||""),keySelector:l=>l.c_code,labelSelector:l=>l.label,disabled:a})}),e.jsx(i,{withInternalPadding:!0,className:"p-2",children:e.jsx(v,{name:"imageType",placeholder:a?"Loading...":"All Image Types",options:k,value:M||null,onChange:l=>b(l||""),keySelector:l=>l.image_type,labelSelector:l=>l.label,required:!1,disabled:a})}),e.jsx(i,{withInternalPadding:!0,className:"p-2",children:e.jsx(v,{name:"uploadType",placeholder:"All Upload Types",options:[{key:"single",label:"Single Upload"},{key:"multiple",label:"Multiple Upload"}],value:E||null,onChange:l=>C(l||""),keySelector:l=>l.key,labelSelector:l=>l.label,required:!1,disabled:!1})})]})})]})}const R="_fullSizeModalOverlay_cyz3b_1",q="_fullSizeModalContent_cyz3b_29",G="_ratingWarningContent_cyz3b_53",U="_ratingWarningTitle_cyz3b_65",D="_exportModeSection_cyz3b_133",V="_splitConfigSection_cyz3b_143",Y="_splitConfigTitle_cyz3b_153",$="_splitInputsContainer_cyz3b_167",H="_splitInputGroup_cyz3b_183",J="_splitInputLabel_cyz3b_197",K="_splitInput_cyz3b_167",Q="_splitTotal_cyz3b_247",X="_splitTotalError_cyz3b_261",Z="_checkboxesContainer_cyz3b_271",L="_ratingWarningButtons_cyz3b_289",ee="_singleExportMessage_cyz3b_309",le="_navigateButtonContainer_cyz3b_333",se="_loadingOverlay_cyz3b_349",s={fullSizeModalOverlay:R,fullSizeModalContent:q,ratingWarningContent:G,ratingWarningTitle:U,exportModeSection:D,splitConfigSection:V,splitConfigTitle:Y,splitInputsContainer:$,splitInputGroup:H,splitInputLabel:J,splitInput:K,splitTotal:Q,splitTotalError:X,checkboxesContainer:Z,ratingWarningButtons:L,singleExportMessage:ee,navigateButtonContainer:le,loadingOverlay:se};function re({isOpen:_,onClose:S,onExport:f,crisisMapsCount:I,droneImagesCount:k,isLoading:a=!1,exportSuccess:d=!1,variant:y="bulk",onNavigateAndExport:T}){const[p,w]=o.useState("standard"),[m,z]=o.useState(80),[u,h]=o.useState(10),[g,x]=o.useState(10),[j,M]=o.useState(!0),[b,E]=o.useState(!0),C=()=>{if(y==="single"){f(p,["crisis_map","drone_image"]);return}if(!j&&!b){alert("Please select at least one image type to export.");return}const t=[];j&&t.push("crisis_map"),b&&t.push("drone_image"),f(p,t)},c=()=>{S()};return _?y==="single"?e.jsx("div",{className:s.fullSizeModalOverlay,onClick:c,children:e.jsxs("div",{className:s.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:[a&&e.jsx("div",{className:s.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(N,{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"})]})}),d&&e.jsx("div",{className:s.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(r,{name:"close-export-success",onClick:c,className:"mt-4",children:"Close"})]})}),e.jsxs("div",{className:s.ratingWarningContent,children:[e.jsx("h3",{className:s.ratingWarningTitle,children:"Export Single Item"}),e.jsxs("div",{className:s.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:s.navigateButtonContainer,children:e.jsx(r,{name:"navigate-to-list",variant:"secondary",onClick:T,children:"Navigate to List View"})}),e.jsxs("div",{className:s.ratingWarningButtons,children:[e.jsx(r,{name:"continue-export",onClick:C,disabled:a,children:a?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{className:"text-white"}),"Exporting..."]}):"Continue"}),e.jsx(r,{name:"cancel-export",variant:"tertiary",onClick:c,disabled:a,children:"Cancel"})]})]})]})}):e.jsx("div",{className:s.fullSizeModalOverlay,onClick:c,children:e.jsxs("div",{className:s.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:[a&&e.jsx("div",{className:s.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(N,{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"})]})}),d&&e.jsx("div",{className:s.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(r,{name:"close-export-success",onClick:c,className:"mt-4",children:"Close"})]})}),e.jsxs("div",{className:s.ratingWarningContent,children:[e.jsx("h3",{className:s.ratingWarningTitle,children:"Export Dataset"}),e.jsx("div",{className:s.exportModeSection,children:e.jsx(B,{name:"export-mode",value:p,onChange:t=>{(t==="standard"||t==="fine-tuning")&&w(t)},options:[{key:"standard",label:"Standard"},{key:"fine-tuning",label:"Fine-tuning"}],keySelector:t=>t.key,labelSelector:t=>t.label,disabled:a})}),p==="fine-tuning"&&e.jsxs("div",{className:s.splitConfigSection,children:[e.jsx("div",{className:s.splitConfigTitle,children:"Dataset Split Configuration"}),e.jsxs("div",{className:s.splitInputsContainer,children:[e.jsxs("div",{className:s.splitInputGroup,children:[e.jsx("label",{htmlFor:"train-split",className:s.splitInputLabel,children:"Train (%)"}),e.jsx("input",{id:"train-split",type:"number",min:"0",max:"100",value:m,onChange:t=>{const n=parseInt(t.target.value)||0,l=100-n;l>=0&&(z(n),u+g>l&&(h(Math.floor(l/2)),x(l-Math.floor(l/2))))},className:s.splitInput,disabled:a})]}),e.jsxs("div",{className:s.splitInputGroup,children:[e.jsx("label",{htmlFor:"test-split",className:s.splitInputLabel,children:"Test (%)"}),e.jsx("input",{id:"test-split",type:"number",min:"0",max:"100",value:u,onChange:t=>{const n=parseInt(t.target.value)||0,l=100-m-n;l>=0&&(h(n),x(l))},className:s.splitInput,disabled:a})]}),e.jsxs("div",{className:s.splitInputGroup,children:[e.jsx("label",{htmlFor:"val-split",className:s.splitInputLabel,children:"Val (%)"}),e.jsx("input",{id:"val-split",type:"number",min:"0",max:"100",value:g,onChange:t=>{const n=parseInt(t.target.value)||0,l=100-m-n;l>=0&&(x(n),h(l))},className:s.splitInput,disabled:a})]})]}),m+u+g!==100&&e.jsx("div",{className:s.splitTotal,children:e.jsx("span",{className:s.splitTotalError,children:"Must equal 100%"})})]}),e.jsxs("div",{className:s.checkboxesContainer,children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(F,{name:"crisis-maps",label:`Crisis Maps (${I} images)`,value:j,onChange:t=>M(t),disabled:a})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(F,{name:"drone-images",label:`Drone Images (${k} images)`,value:b,onChange:t=>E(t),disabled:a})})]}),e.jsxs("div",{className:s.ratingWarningButtons,children:[e.jsx(r,{name:"confirm-export",onClick:C,disabled:a,children:a?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{className:"text-white"}),"Exporting..."]}):"Export Selected"}),e.jsx(r,{name:"cancel-export",variant:"tertiary",onClick:c,disabled:a,children:"Cancel"})]})]})]})}):null}export{re as E,ie as F};
py_backend/static/assets/index-B3MZlOIS.js ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-utils-Db80MiSc.js","assets/vendor-DxpCibxB.js","assets/vendor-react-BxsGb6Ph.js"])))=>i.map(i=>d[i]);
2
+ import{u as Xe,F as Ye,_ as ea}from"./index-C6NSRolP.js";import{j as a,r as g}from"./vendor-react-BxsGb6Ph.js";import{N as X,n as T,_ as ve,L as aa,z as E,C as se,c as ie,D as ta}from"./vendor-ui-l_DttnRj.js";import{u as sa}from"./useAdmin-6S8boYmH.js";import{F as ia,E as na}from"./ExportModal-5QTtY4mk.js";import{n as oa,a as ra}from"./vendor-DxpCibxB.js";const la="_tabSelector_usssr_1",ca="_imageContainer_usssr_12",da="_imagePlaceholder_usssr_33",ga="_metadataTags_usssr_45",ma="_metadataTag_usssr_45",ua="_captionContainer_usssr_67",pa="_captionText_usssr_74",fa="_gridLayout_usssr_131",ha="_detailsSection_usssr_155",_a="_loadingContainer_usssr_161",xa="_errorContainer_usssr_171",ya="_fullSizeModalOverlay_usssr_205",va="_fullSizeModalContent_usssr_219",wa="_ratingWarningContent_usssr_230",Ca="_ratingWarningTitle_usssr_236",ja="_ratingWarningText_usssr_243",Ia="_ratingWarningButtons_usssr_250",Na="_carouselContainer_usssr_365",ba="_carouselImageWrapper_usssr_370",Sa="_carouselImage_usssr_370",La="_carouselNavigation_usssr_393",Da="_carouselButton_usssr_405",ka="_carouselIndicators_usssr_429",Ma="_carouselIndicator_usssr_429",Ta="_carouselIndicatorActive_usssr_458",Fa="_singleImageContainer_usssr_488",Ea="_viewImageButtonContainer_usssr_494",p={tabSelector:la,imageContainer:ca,imagePlaceholder:da,metadataTags:ga,metadataTag:ma,captionContainer:ua,captionText:pa,gridLayout:fa,detailsSection:ha,loadingContainer:_a,errorContainer:xa,fullSizeModalOverlay:ya,fullSizeModalContent:va,ratingWarningContent:wa,ratingWarningTitle:Ca,ratingWarningText:ja,ratingWarningButtons:Ia,carouselContainer:Na,carouselImageWrapper:ba,carouselImage:Sa,carouselNavigation:La,carouselButton:Da,carouselIndicators:ka,carouselIndicator:Ma,carouselIndicatorActive:Ta,singleImageContainer:Fa,viewImageButtonContainer:Ea};function it(){const{mapId:u}=oa(),y=ra(),{isAuthenticated:ne}=sa();console.log("MapDetailsPage: Current URL:",window.location.href),console.log("MapDetailsPage: Hash:",window.location.hash),console.log("MapDetailsPage: mapId from useParams:",u),console.log("MapDetailsPage: mapId type:",typeof u),console.log("MapDetailsPage: mapId length:",u?.length),console.log("MapDetailsPage: mapId value:",JSON.stringify(u));const we=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;if(!u||u==="undefined"||u==="null"||u.trim()===""||!we.test(u))return a.jsx(X,{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 = "',u,'" (type: ',typeof u,")"]}),a.jsx(T,{name:"back-to-explore",variant:"secondary",onClick:()=>y("/explore"),children:"Return to Explore"})]})});const[oe,Ce]=g.useState("mapDetails"),[e,Y]=g.useState(null),[W,P]=g.useState(!0),[re,O]=g.useState(null),[le,je]=g.useState([]),[ce,Ie]=g.useState([]),[de,Ne]=g.useState([]),[ge,be]=g.useState([]),[Se,Le]=g.useState([]),[De,ke]=g.useState(!1),[Me,Te]=g.useState(!1),[B,q]=g.useState(!1),[Fe,G]=g.useState(!1),[me,Z]=g.useState(!1),[Ee,ee]=g.useState(!1),[Re,ae]=g.useState(!1),[Ra,$a]=g.useState("standard"),[R,Pa]=g.useState(80),[J,Aa]=g.useState(10),[za,Oa]=g.useState(10),[Ua,Wa]=g.useState(!0),[Ba,Ja]=g.useState(!0),[K,Q]=g.useState(!1),[$e,ue]=g.useState(!1),[Pe,pe]=g.useState(null),[D,H]=g.useState([]),[A,z]=g.useState(0),[V,fe]=g.useState(!1),{search:d,setSearch:Ha,srcFilter:v,setSrcFilter:Va,catFilter:w,setCatFilter:qa,regionFilter:C,setRegionFilter:Ga,countryFilter:j,setCountryFilter:Za,imageTypeFilter:I,setImageTypeFilter:Ka,uploadTypeFilter:N,setUploadTypeFilter:Qa,showReferenceExamples:k,setShowReferenceExamples:Ae,clearAllFilters:ze}=Xe(),Oe=[{key:"explore",label:"List"},{key:"mapDetails",label:"Carousel"}],he=g.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"),P(!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"),P(!1);return}console.log("fetchMapData: Making API call for id:",t),q(!0),P(!0);try{const f=await fetch(`/api/images/${t}`);if(!f.ok)throw new Error("Map not found");const s=await f.json();if(Y(s),s.all_image_ids&&s.all_image_ids.length>1)await _e(s.all_image_ids);else if(s.image_count&&s.image_count>1){console.log("Multi-upload detected but no all_image_ids, trying grouped endpoint");try{const l=await fetch("/api/images/grouped");if(l.ok){const r=(await l.json()).find(c=>c.all_image_ids&&c.all_image_ids.includes(s.image_id));r&&r.all_image_ids?await _e(r.all_image_ids):(H([s]),z(0))}else H([s]),z(0)}catch(l){console.error("Failed to fetch from grouped endpoint:",l),H([s]),z(0)}}else H([s]),z(0);await te(t)}catch(f){O(f instanceof Error?f.message:"Unknown error occurred")}finally{P(!1),q(!1)}},[]),_e=g.useCallback(async t=>{console.log("fetchAllImages called with imageIds:",t),fe(!0);try{const o=t.map(async s=>{const l=await fetch(`/api/images/${s}`);if(!l.ok)throw new Error(`Failed to fetch image ${s}`);return l.json()}),f=await Promise.all(o);H(f),z(0),console.log("fetchAllImages: Loaded",f.length,"images")}catch(o){console.error("fetchAllImages error:",o),O(o instanceof Error?o.message:"Failed to load all images")}finally{fe(!1)}},[]),Ue=g.useCallback(()=>{D.length>1&&z(t=>t>0?t-1:D.length-1)},[D.length]),We=g.useCallback(()=>{D.length>1&&z(t=>t<D.length-1?t+1:0)},[D.length]),Be=g.useCallback(t=>{t>=0&&t<D.length&&z(t)},[D.length]),xe=g.useCallback(t=>{const o=t||(D.length>0?D[A]:e);o&&(pe(o),ue(!0))},[D,A,e]),Je=g.useCallback(()=>{ue(!1),pe(null)},[]);g.useEffect(()=>{if(console.log("MapDetailsPage: mapId from useParams:",u),console.log("MapDetailsPage: mapId type:",typeof u),console.log("MapDetailsPage: mapId value:",u),!u||u==="undefined"||u==="null"||u.trim()===""||u===void 0||u===null){console.log("MapDetailsPage: Invalid mapId, setting error"),O("Map ID is required"),P(!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(u)){console.log("MapDetailsPage: Invalid UUID format:",u),O("Invalid Map ID format"),P(!1);return}console.log("MapDetailsPage: Fetching data for mapId:",u),he(u)},[u,he]),g.useEffect(()=>{if(!e||W||K)return;if(!u||u==="undefined"||u==="null"||u.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(u)){console.log("Auto-navigation skipped: Invalid mapId format");return}(()=>{const f=!d||e.title?.toLowerCase().includes(d.toLowerCase())||e.generated?.toLowerCase().includes(d.toLowerCase())||e.source?.toLowerCase().includes(d.toLowerCase())||e.event_type?.toLowerCase().includes(d.toLowerCase()),s=!v||e.source===v,l=!w||e.event_type===w,i=!C||e.countries.some(M=>M.r_code===C),r=!j||e.countries.some(M=>M.c_code===j),c=!I||e.image_type===I,n=!k||e.starred===!0,x=f&&s&&l&&i&&r&&c&&n;return console.log("Auto-navigation check:",{mapId:u,search:d,srcFilter:v,catFilter:w,regionFilter:C,countryFilter:j,imageTypeFilter:I,showReferenceExamples:k,matchesSearch:f,matchesSource:s,matchesCategory:l,matchesRegion:i,matchesCountry:r,matchesImageType:c,matchesReferenceExamples:n,matches:x}),x})()||(console.log("Current map does not match filters, looking for first matching item"),fetch("/api/images").then(f=>f.json()).then(f=>{console.log("Auto-navigation: Received images from API:",f.length),console.log("Auto-navigation: First few images:",f.slice(0,3).map(l=>({image_id:l.image_id,title:l.title})));const s=f.find(l=>{const i=!d||l.title?.toLowerCase().includes(d.toLowerCase())||l.generated?.toLowerCase().includes(d.toLowerCase())||l.source?.toLowerCase().includes(d.toLowerCase())||l.event_type?.toLowerCase().includes(d.toLowerCase()),r=!v||l.source===v,c=!w||l.event_type===w,n=!C||l.countries?.some(m=>m.r_code===C),x=!j||l.countries?.some(m=>m.c_code===j),M=!I||l.image_type===I,S=!k||l.starred===!0;return i&&r&&c&&n&&x&&M&&S});console.log("Auto-navigation: Found first matching image:",s?{image_id:s.image_id,title:s.title,source:s.source}:"No matching image found"),s&&s.image_id&&s.image_id!=="undefined"&&s.image_id!=="null"&&s.image_id.trim()!==""&&s.image_id!==u&&(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s.image_id)?(console.log("Auto-navigating to:",s.image_id),y(`/map/${s.image_id}`)):console.error("Auto-navigation blocked: Invalid image_id format:",s.image_id))}).catch(console.error))},[e,d,v,w,C,j,I,k,u,y,W,K]);const te=async t=>{if(!(!t||t==="undefined"||t==="null"||t.trim()===""))try{const o=await fetch("/api/images/grouped");if(o.ok){const s=(await o.json()).filter(i=>{const r=!d||i.title?.toLowerCase().includes(d.toLowerCase())||i.generated?.toLowerCase().includes(d.toLowerCase())||i.source?.toLowerCase().includes(d.toLowerCase())||i.event_type?.toLowerCase().includes(d.toLowerCase()),c=!v||i.source===v,n=!w||i.event_type===w,x=!C||i.countries?.some(_=>_.r_code===C),M=!j||i.countries?.some(_=>_.c_code===j),S=!I||i.image_type===I,m=!N||N==="single"&&(!i.image_count||i.image_count<=1)||N==="multiple"&&i.image_count&&i.image_count>1,b=!k||i.starred===!0;return r&&c&&n&&x&&M&&S&&m&&b}),l=s.findIndex(i=>i.image_id===t);ke(s.length>1&&l>0),Te(s.length>1&&l<s.length-1)}}catch(o){console.error("Failed to check navigation availability:",o)}},ye=async t=>{if(!B){q(!0);try{const o=await fetch("/api/images/grouped");if(o.ok){const f=await o.json(),s=f.filter(n=>{const x=!d||n.title?.toLowerCase().includes(d.toLowerCase())||n.generated?.toLowerCase().includes(d.toLowerCase())||n.source?.toLowerCase().includes(d.toLowerCase())||n.event_type?.toLowerCase().includes(d.toLowerCase()),M=!v||n.source===v,S=!w||n.event_type===w,m=!C||n.countries?.some($=>$.r_code===C),b=!j||n.countries?.some($=>$.c_code===j),_=!I||n.image_type===I,L=!N||N==="single"&&(!n.image_count||n.image_count<=1)||N==="multiple"&&n.image_count&&n.image_count>1,U=!k||n.starred===!0;return x&&M&&S&&m&&b&&_&&L&&U});if(s.findIndex(n=>n.image_id===u)===-1){const n=f.find(x=>x.image_id===u);n&&s.push(n)}const i=s.findIndex(n=>n.image_id===u);if(i===-1){console.error("Current image not found in filtered list");return}let r;t==="previous"?r=i>0?i-1:s.length-1:r=i<s.length-1?i+1:0;const c=s[r];c&&c.image_id&&c.image_id!=="undefined"&&c.image_id!=="null"&&c.image_id.trim()!==""&&(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(c.image_id)?(console.log("Carousel navigating to:",c.image_id),y(`/map/${c.image_id}`)):console.error("Carousel navigation blocked: Invalid image_id format:",c.image_id))}}catch(o){console.error("Failed to navigate to item:",o)}finally{q(!1)}}};g.useEffect(()=>{e&&u&&!W&&!K&&te(u)},[e,u,d,v,w,C,j,I,N,k,W,K,te]),g.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,o,f,s,l])=>{je(t),Ie(o),Ne(f),be(s),Le(l)}).catch(console.error)},[]);const He=async()=>{e&&G(!0)},Ve=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?Y(o=>o?{...o,starred:!o.starred}:null):console.error("Failed to toggle starred status")}catch(t){console.error("Error toggling starred status:",t)}},qe=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){Y(o=>o?{...o,starred:!o.starred}:null),G(!1);try{const o=await fetch("/api/images/grouped");if(o.ok){const s=(await o.json()).filter(i=>{const r=!d||i.title?.toLowerCase().includes(d.toLowerCase())||i.generated?.toLowerCase().includes(d.toLowerCase())||i.source?.toLowerCase().includes(d.toLowerCase())||i.event_type?.toLowerCase().includes(d.toLowerCase()),c=!v||i.source===v,n=!w||i.event_type===w,x=!C||i.countries?.some(_=>_.r_code===C),M=!j||i.countries?.some(_=>_.c_code===j),S=!I||i.image_type===I,m=!N||N==="single"&&(!i.image_count||i.image_count<=1)||N==="multiple"&&i.image_count&&i.image_count>1,b=!k||i.starred===!0;return r&&c&&n&&x&&M&&S&&m&&b}),l=s.filter(i=>i.image_id!==e.image_id);if(l.length>0){const i=s.findIndex(c=>c.image_id===e.image_id);let r;if(i===s.length-1?r=i-1:r=i,console.log("Navigation target:",{currentIndex:i,targetIndex:r,targetId:l[r]?.image_id}),r>=0&&r<l.length){const c=l[r];c&&c.image_id&&c.image_id!=="undefined"&&c.image_id!=="null"&&c.image_id.trim()!==""?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(c.image_id)?(console.log("Navigating to:",c.image_id),y(`/map/${c.image_id}`)):(console.error("Navigation blocked: Invalid image_id format:",c.image_id),y("/explore")):(console.error("Navigation blocked: Invalid image_id:",c?.image_id),y("/explore"))}else l[0]&&l[0].image_id&&l[0].image_id!=="undefined"&&l[0].image_id!=="null"&&l[0].image_id.trim()!==""?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(l[0].image_id)?(console.log("Fallback navigation to first item:",l[0].image_id),y(`/map/${l[0].image_id}`)):(console.error("Fallback navigation blocked: Invalid image_id format:",l[0].image_id),y("/explore")):(console.log("No valid remaining items, going to explore page"),y("/explore"))}else console.log("No remaining items, going to explore page"),y("/explore")}else y("/explore")}catch(o){console.error("Failed to navigate to next item:",o),y("/explore")}finally{Q(!1)}}else console.error("Delete failed"),Q(!1)}catch(t){console.error("Delete failed:",t),Q(!1)}}},h=g.useMemo(()=>{if(!e)return null;if(!d&&!v&&!w&&!C&&!j&&!I&&!N&&!k)return e;const t=!d||e.title?.toLowerCase().includes(d.toLowerCase())||e.generated?.toLowerCase().includes(d.toLowerCase())||e.source?.toLowerCase().includes(d.toLowerCase())||e.event_type?.toLowerCase().includes(d.toLowerCase()),o=!v||e.source===v,f=!w||e.event_type===w,s=!C||e.countries.some(x=>x.r_code===C),l=!j||e.countries.some(x=>x.c_code===j),i=!I||e.image_type===I,r=!N||N==="single"&&(!e.image_count||e.image_count<=1)||N==="multiple"&&e.image_count&&e.image_count>1,c=!k||e.starred===!0,n=t&&o&&f&&s&&l&&i&&r&&c;return!n&&(d||v||w||C||j||I||N||k)?(setTimeout(()=>{Ge()},100),e):n?e:null},[e,d,v,w,C,j,I,N,k]),Ge=g.useCallback(async()=>{P(!0);try{const t=await fetch("/api/images/grouped");if(t.ok){const f=(await t.json()).filter(s=>{const l=!d||s.title?.toLowerCase().includes(d.toLowerCase())||s.generated?.toLowerCase().includes(d.toLowerCase())||s.source?.toLowerCase().includes(d.toLowerCase())||s.event_type?.toLowerCase().includes(d.toLowerCase()),i=!v||s.source===v,r=!w||s.event_type===w,c=!C||s.countries?.some(m=>m.r_code===C),n=!j||s.countries?.some(m=>m.c_code===j),x=!I||s.image_type===I,M=!N||N==="single"&&(!s.image_count||s.image_count<=1)||N==="multiple"&&s.image_count&&s.image_count>1,S=!k||s.starred===!0;return l&&i&&r&&c&&n&&x&&M&&S});if(f.length>0){const s=f[0];s&&s.image_id&&y(`/map/${s.image_id}`)}else y("/explore")}}catch(t){console.error("Failed to navigate to matching image:",t),y("/explore")}finally{P(!1)}},[d,v,w,C,j,I,N,k,y]),Ze=()=>{if(!e)return;if(!e.all_image_ids||e.all_image_ids.length<=1){const s=`/upload?step=1&contribute=true&imageIds=${[e.image_id].join(",")}`;y(s);return}const o=`/upload?step=1&contribute=true&imageIds=${e.all_image_ids.join(",")}`;y(o)},F=(t,o)=>({image:`images/${o}`,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}}),Ke=async t=>{if(e){ee(!0),ae(!1);try{const o=(await ea(async()=>{const{default:r}=await import("./vendor-utils-Db80MiSc.js").then(c=>c.j);return{default:r}},__vite__mapDeps([0,1,2]))).default,f=new o;if(e.image_type==="crisis_map"){const r=f.folder("crisis_maps_dataset"),c=r?.folder("images");if(c)try{const n=e.image_count&&e.image_count>1?e.all_image_ids||[e.image_id]:[e.image_id],x=n.map(async(m,b)=>{try{const _=await fetch(`/api/images/${m}/file`);if(!_.ok)throw new Error(`Failed to fetch image ${m}`);const L=await _.blob(),U=e.file_key.split(".").pop()||"jpg",$=`0001_${String(b+1).padStart(2,"0")}.${U}`;return c.file($,L),{success:!0,fileName:$,imageId:m}}catch(_){return console.error(`Failed to process image ${m}:`,_),{success:!1,fileName:"",imageId:m}}}),S=(await Promise.all(x)).filter(m=>m.success);if(S.length===0)throw new Error("No images could be processed");if(t==="fine-tuning"){const m=[],b=[],_=[],L=S.map(Qe=>`images/${Qe.fileName}`),U=Math.random(),$={image:L.length===1?L[0]:L,caption:e.edited||e.generated||"",metadata:{image_id:n,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}};U<R/100?m.push($):U<(R+J)/100?b.push($):_.push($),r&&(r.file("train.jsonl",JSON.stringify(m,null,2)),r.file("test.jsonl",JSON.stringify(b,null,2)),r.file("val.jsonl",JSON.stringify(_,null,2)))}else{const m=S.map(_=>`images/${_.fileName}`),b={image:m.length===1?m[0]:m,caption:e.edited||e.generated||"",metadata:{image_id:n,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}};r&&r.file("0001.json",JSON.stringify(b,null,2))}}catch(n){throw console.error(`Failed to process image ${e.image_id}:`,n),n}}else if(e.image_type==="drone_image"){const r=f.folder("drone_images_dataset"),c=r?.folder("images");if(c)try{const n=await fetch(`/api/images/${e.image_id}/file`);if(!n.ok)throw new Error(`Failed to fetch image ${e.image_id}`);const x=await n.blob(),S=`0001.${e.file_key.split(".").pop()||"jpg"}`;if(c.file(S,x),t==="fine-tuning"){const m=[],b=[],_=[];if(String(e?.image_type)==="crisis_map"){const L=Math.random();L<R/100?m.push(F(e,"0001")):L<(R+J)/100?b.push(F(e,"0001")):_.push(F(e,"0001"))}else if(String(e?.image_type)==="drone_image"){const L=Math.random();L<R/100?m.push(F(e,"0001")):L<(R+J)/100?b.push(F(e,"0001")):_.push(F(e,"0001"))}r&&(r.file("train.jsonl",JSON.stringify(m,null,2)),r.file("test.jsonl",JSON.stringify(b,null,2)),r.file("val.jsonl",JSON.stringify(_,null,2)))}else{const m={image:`images/${S}`,caption:e.edited||e.generated||"",metadata:{image_id:e.image_count&&e.image_count>1?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}};r&&r.file("0001.json",JSON.stringify(m,null,2))}}catch(n){throw console.error(`Failed to process image ${e.image_id}:`,n),n}}else{const r=f.folder("generic_dataset"),c=r?.folder("images");if(c)try{const n=await fetch(`/api/images/${e.image_id}/file`);if(!n.ok)throw new Error(`Failed to fetch image ${e.image_id}`);const x=await n.blob(),S=`0001.${e.file_key.split(".").pop()||"jpg"}`;if(c.file(S,x),t==="fine-tuning"){const m=[],b=[],_=[];if(String(e?.image_type)==="crisis_map"){const L=Math.random();L<R/100?m.push(F(e,"0001")):L<(R+J)/100?b.push(F(e,"0001")):_.push(F(e,"0001"))}else if(String(e?.image_type)==="drone_image"){const L=Math.random();L<R/100?m.push(F(e,"0001")):L<(R+J)/100?b.push(F(e,"0001")):_.push(F(e,"0001"))}r&&(r.file("train.jsonl",JSON.stringify(m,null,2)),r.file("test.jsonl",JSON.stringify(b,null,2)),r.file("val.jsonl",JSON.stringify(_,null,2)))}else{const m={image:`images/${S}`,caption:e.edited||e.generated||"",metadata:{image_id:e.image_count&&e.image_count>1?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}};r&&r.file("0001.json",JSON.stringify(m,null,2))}}catch(n){throw console.error(`Failed to process image ${e.image_id}:`,n),n}}const s=await f.generateAsync({type:"blob"}),l=URL.createObjectURL(s),i=document.createElement("a");i.href=l,i.download=`dataset_${e.image_type}_${e.image_id}_${t}_${new Date().toISOString().split("T")[0]}.zip`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(l),console.log(`Exported ${e.image_type} dataset with 1 image in ${t} mode`),ae(!0)}catch(o){console.error("Export failed:",o),alert("Failed to export dataset. Please try again.")}finally{ee(!1)}}};return W?a.jsx(X,{children:a.jsx("div",{className:p.loadingContainer,children:a.jsxs("div",{className:"flex flex-col items-center gap-4",children:[a.jsx(ve,{className:"text-ifrcRed"}),a.jsx("div",{children:"Loading map details..."})]})})}):re||!e?a.jsx(X,{children:a.jsx("div",{className:p.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:re||"Map not found"}),a.jsx(T,{name:"back-to-explore",variant:"secondary",onClick:()=>y("/explore"),children:"Return to Explore"})]})})}):a.jsxs(X,{children:[a.jsxs("div",{className:"max-w-7xl mx-auto",children:[a.jsxs("div",{className:p.tabSelector,children:[a.jsx(aa,{name:"map-details-view",value:oe,onChange:t=>{(t==="mapDetails"||t==="explore")&&(Ce(t),t==="explore"&&y("/explore"))},options:Oe,keySelector:t=>t.key,labelSelector:t=>t.label}),a.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[a.jsx(E,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:a.jsxs(T,{name:"reference-examples",variant:k?"primary":"secondary",onClick:()=>Ae(!k),className:"whitespace-nowrap",children:[a.jsx("span",{className:"mr-2",children:k?a.jsx("span",{className:"text-yellow-400",children:"★"}):a.jsx("span",{className:"text-yellow-400",children:"☆"})}),"Reference Examples"]})}),a.jsx(T,{name:"export-dataset",variant:"secondary",onClick:()=>Z(!0),children:"Export"})]})]}),a.jsx(ia,{sources:le,types:ce,regions:ge,countries:Se,imageTypes:de,isLoadingFilters:!1}),oe==="mapDetails"?a.jsx("div",{className:"relative",children:h?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:p.gridLayout,children:[a.jsxs(E,{heading:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{children:h.title||"Map Image"}),h.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:p.imageContainer,children:e?.image_count&&e.image_count>1||D.length>1?a.jsxs("div",{className:p.carouselContainer,children:[a.jsx("div",{className:p.carouselImageWrapper,children:V?a.jsxs("div",{className:p.imagePlaceholder,children:[a.jsx(ve,{className:"text-ifrcRed"}),a.jsx("div",{children:"Loading images..."})]}):D[A]?.image_url?a.jsx("img",{src:D[A].image_url,alt:D[A].file_key,className:p.carouselImage}):a.jsx("div",{className:p.imagePlaceholder,children:"No image available"})}),a.jsxs("div",{className:p.carouselNavigation,children:[a.jsx(T,{name:"previous-image",variant:"tertiary",size:1,onClick:Ue,disabled:V,className:p.carouselButton,children:a.jsx(se,{className:"w-4 h-4"})}),a.jsx("div",{className:p.carouselIndicators,children:D.map((t,o)=>a.jsx("button",{onClick:()=>Be(o),className:`${p.carouselIndicator} ${o===A?p.carouselIndicatorActive:""}`,disabled:V,children:o+1},o))}),a.jsx(T,{name:"next-image",variant:"tertiary",size:1,onClick:We,disabled:V,className:p.carouselButton,children:a.jsx(ie,{className:"w-4 h-4"})})]}),a.jsx("div",{className:p.viewImageButtonContainer,children:a.jsx(T,{name:"view-full-size-carousel",variant:"secondary",size:1,onClick:()=>xe(D[A]),disabled:V||!D[A]?.image_url,children:"View Image"})})]}):a.jsxs("div",{className:p.singleImageContainer,children:[h.image_url?a.jsx("img",{src:h.image_url,alt:h.file_key}):a.jsx("div",{className:p.imagePlaceholder,children:"No image available"}),a.jsx("div",{className:p.viewImageButtonContainer,children:a.jsx(T,{name:"view-full-size-single",variant:"secondary",size:1,onClick:()=>xe(h),disabled:!h.image_url,children:"View Image"})})]})}),a.jsx(E,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:a.jsxs("div",{className:p.metadataTags,children:[h.image_type!=="drone_image"&&a.jsx("span",{className:p.metadataTag,children:le.find(t=>t.s_code===h.source)?.label||h.source}),a.jsx("span",{className:p.metadataTag,children:ce.find(t=>t.t_code===h.event_type)?.label||h.event_type}),a.jsx("span",{className:p.metadataTag,children:de.find(t=>t.image_type===h.image_type)?.label||h.image_type}),h.countries&&h.countries.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:p.metadataTag,children:ge.find(t=>t.r_code===h.countries[0].r_code)?.label||"Unknown Region"}),a.jsx("span",{className:p.metadataTag,children:h.countries.map(t=>t.label).join(", ")})]}),h.image_count&&h.image_count>1&&a.jsxs("span",{className:p.metadataTag,title:`Multi-upload with ${h.image_count} images`,children:["📷 ",h.image_count]}),(!h.image_count||h.image_count<=1)&&a.jsx("span",{className:p.metadataTag,title:"Single Upload",children:"Single"})]})})]}),a.jsx("div",{className:p.detailsSection,children:h.edited&&h.edited.includes("Description:")||h.generated&&h.generated.includes("Description:")?a.jsx(E,{heading:"AI Generated Content",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,spacing:"comfortable",children:a.jsx("div",{className:p.captionContainer,children:a.jsx("div",{className:p.captionText,children:(h.edited||h.generated||"").split(`
3
+ `).map((t,o)=>a.jsx("div",{children:t.startsWith("Description:")||t.startsWith("Analysis:")||t.startsWith("Recommended Actions:")?a.jsx("h4",{className:"font-semibold text-gray-800 mt-4 mb-2",children:t}):t.trim()===""?a.jsx("br",{}):a.jsx("p",{className:"mb-2",children:t})},o))})})}):a.jsx(E,{heading:"Description",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,spacing:"comfortable",children:a.jsx("div",{className:p.captionContainer,children:h.generated?a.jsx("div",{className:p.captionText,children:a.jsx("p",{children:h.edited||h.generated})}):a.jsx("p",{children:"— no caption yet —"})})})})]}),a.jsx("div",{className:"flex items-center justify-center mt-8",children:a.jsx(E,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center gap-4",children:[De&&a.jsx(E,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(T,{name:"previous-item",variant:"tertiary",size:1,className:`bg-white/90 hover:bg-white shadow-lg border border-gray-200 ${B?"opacity-50 cursor-not-allowed":"hover:scale-110"}`,onClick:()=>ye("previous"),disabled:B,children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("div",{className:"flex -space-x-1",children:[a.jsx(se,{className:"w-4 h-4"}),a.jsx(se,{className:"w-4 h-4"})]}),a.jsx("span",{className:"font-semibold",children:"Previous"})]})})}),ne&&a.jsx(E,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(T,{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:He,title:"Delete","aria-label":"Delete saved image",children:a.jsx(ta,{className:"w-4 h-4"})})}),a.jsx(E,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(T,{name:"contribute",onClick:Ze,children:"Contribute"})}),ne&&a.jsx(E,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(T,{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:Ve,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?"★":"☆"})})}),Me&&a.jsx(E,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(T,{name:"next-item",variant:"tertiary",size:1,className:`bg-white/90 hover:bg-white shadow-lg border border-gray-200 ${B?"opacity-50 cursor-not-allowed":"hover:scale-110"}`,onClick:()=>ye("next"),disabled:B,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(ie,{className:"w-4 h-4"}),a.jsx(ie,{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(T,{name:"clear-filters",variant:"secondary",onClick:ze,children:"Clear Filters"})})]})}):null]}),Fe&&a.jsx("div",{className:p.fullSizeModalOverlay,onClick:()=>G(!1),children:a.jsx("div",{className:p.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:a.jsxs("div",{className:p.ratingWarningContent,children:[a.jsx("h3",{className:p.ratingWarningTitle,children:"Delete Image?"}),a.jsx("p",{className:p.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:p.ratingWarningButtons,children:[a.jsx(T,{name:"confirm-delete",variant:"secondary",onClick:qe,children:"Delete"}),a.jsx(T,{name:"cancel-delete",variant:"tertiary",onClick:()=>G(!1),children:"Cancel"})]})]})})}),me&&a.jsx(na,{isOpen:me,onClose:()=>{Z(!1),ae(!1),ee(!1)},onExport:(t,o)=>{o.includes(e.image_type)&&Ke(t)},filteredCount:1,totalCount:1,hasFilters:!1,crisisMapsCount:e.image_type==="crisis_map"?1:0,droneImagesCount:e.image_type==="drone_image"?1:0,isLoading:Ee,exportSuccess:Re,variant:"single",onNavigateToList:()=>{Z(!1),y("/explore")},onNavigateAndExport:()=>{Z(!1),y("/explore?export=true")}}),a.jsx(Ye,{isOpen:$e,imageUrl:Pe?.image_url||null,preview:null,selectedImageData:null,onClose:Je})]})}export{it as default};
py_backend/static/assets/index-C6NSRolP.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DMU6q_dg.js","assets/vendor-react-BxsGb6Ph.js","assets/vendor-DxpCibxB.js","assets/vendor-ui-l_DttnRj.js","assets/vendor-ui-DpEM1HT6.css","assets/index-BsrMOmjk.css","assets/index-C8xjpbHZ.js","assets/useAdmin-6S8boYmH.js","assets/ExportModal-5QTtY4mk.js","assets/ExportModal-BoB3JpqO.css","assets/index-BzPMJFRS.css","assets/AdminPage-KksT68Fe.js","assets/AdminPage-VgSjQ50W.css","assets/index-B3MZlOIS.js","assets/index-tDgjKyWF.css"])))=>i.map(i=>d[i]);
2
+ import{r as a,j as e,L as zt,u as Ot,c as $t,R as Bt,b as Ut}from"./vendor-react-BxsGb6Ph.js";import{N as ln,G as Wt,U as Fn,S as Ht,A as Vt,z as U,n as w,M as Gt,Q as qt,a as Yt,b as Zt,L as Kt,B as cn,D as dn,C as Jt,c as Qt,O as D,f as J,d as Ln,e as Xt,_ as rn,R as te,l as ea,t as na}from"./vendor-ui-l_DttnRj.js";import{u as ta,a as un,O as aa,k as sa}from"./vendor-DxpCibxB.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))p(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const _ of d.addedNodes)_.tagName==="LINK"&&_.rel==="modulepreload"&&p(_)}).observe(document,{childList:!0,subtree:!0});function o(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function p(c){if(c.ep)return;c.ep=!0;const d=o(c);fetch(c.href,d)}})();const ia="modulepreload",oa=function(i){return"/app/"+i},Tn={},B=function(s,o,p){let c=Promise.resolve();if(o&&o.length>0){let S=function(x){return Promise.all(x.map(l=>Promise.resolve(l).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const _=document.querySelector("meta[property=csp-nonce]"),C=_?.nonce||_?.getAttribute("nonce");c=S(o.map(x=>{if(x=oa(x),x in Tn)return;Tn[x]=!0;const l=x.endsWith(".css"),b=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${x}"]${b}`))return;const M=document.createElement("link");if(M.rel=l?"stylesheet":ia,l||(M.as="script"),M.crossOrigin="",M.href=x,C&&M.setAttribute("nonce",C),document.head.appendChild(M),l)return new Promise((P,j)=>{M.addEventListener("load",P),M.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${x}`)))})}))}function d(_){const C=new Event("vite:preloadError",{cancelable:!0});if(C.payload=_,window.dispatchEvent(C),!C.defaultPrevented)throw _}return c.then(_=>{for(const C of _||[])C.status==="rejected"&&d(C.reason);return s().catch(d)})},ra="_dropdownContainer_1six7_3",la="_dropdownMenu_1six7_15",ca="_dropdownContent_1six7_43",on={dropdownContainer:ra,dropdownMenu:la,dropdownContent:ca},da=[{to:"/upload",label:"Upload",Icon:Fn},{to:"/explore",label:"Explore",Icon:Ht},{to:"/analytics",label:"Analytics",Icon:Vt}];function ua(){const i=ta(),s=un(),[o,p]=a.useState(!1),c=a.useRef(null);return a.useEffect(()=>{const d=_=>{c.current&&!c.current.contains(_.target)&&p(!1)};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[]),e.jsx("nav",{className:"border-b border-gray-200 bg-white shadow-sm sticky top-0 z-50 backdrop-blur-sm bg-white/95",children:e.jsxs(ln,{className:"border-b-2 border-ifrcRed",contentClassName:"grid grid-cols-3 items-center py-6",children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0 cursor-pointer group transition-all duration-200 hover:scale-105",onClick:()=>{if(!(i.pathname==="/upload"||i.pathname==="/")){if(i.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}s("/")}},children:[e.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:e.jsx(Wt,{className:"h-8 w-8 flex-shrink-0 text-ifrcRed"})}),e.jsx("div",{className:"flex flex-col",children:e.jsx("span",{className:"font-bold text-xl text-gray-900 leading-tight",children:"PromptAid Vision"})})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx("nav",{className:"flex items-center space-x-4 bg-gray-50/80 rounded-xl p-2 backdrop-blur-sm",children:da.map(({to:d,label:_,Icon:C})=>{const S=i.pathname===d||d==="/upload"&&i.pathname==="/"||d==="/explore"&&i.pathname.startsWith("/map/"),x=i.pathname==="/upload"||i.pathname==="/",l=d==="/upload"||d==="/";return e.jsxs("div",{className:"relative",children:[e.jsx(U,{withInternalPadding:!0,className:"p-2",children:e.jsxs(w,{name:_.toLowerCase(),variant:S?"primary":"tertiary",size:1,className:`transition-all duration-200 ${S?"shadow-lg shadow-ifrcRed/20 transform scale-105":"hover:bg-white hover:shadow-md hover:scale-105"}`,onClick:()=>{if(!(x&&l)){if(i.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded(d);return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}s(d)}},children:[e.jsx(C,{className:`w-4 h-4 transition-transform duration-200 ${S?"scale-110":"group-hover:scale-110"}`}),e.jsx("span",{className:"inline ml-2 font-semibold",children:_})]})}),S&&e.jsx("div",{className:"absolute -bottom-2 left-1/2 transform -translate-x-1/2 w-8 h-1 bg-ifrcRed rounded-full animate-pulse"})]},d)})})}),e.jsx("div",{className:"flex justify-end",children:e.jsxs("div",{className:on.dropdownContainer,ref:c,children:[e.jsx(U,{withInternalPadding:!0,className:"p-2",children:e.jsx(w,{name:"more-options",variant:o?"primary":"tertiary",size:1,className:"transition-all duration-200",onClick:()=>p(!o),children:e.jsx(Gt,{className:"w-4 h-4"})})}),o&&e.jsx("div",{className:on.dropdownMenu,children:e.jsxs("div",{className:on.dropdownContent,children:[e.jsx(U,{withInternalPadding:!0,className:"p-2",children:e.jsxs(w,{name:"help-support",variant:"tertiary",size:1,className:"w-full justify-start",onClick:()=>{if(p(!1),i.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/help");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}s("/help")},children:[e.jsx(qt,{className:"w-4 h-4"}),e.jsx("span",{className:"ml-2 font-semibold",children:"Help & Support"})]})}),e.jsx(U,{withInternalPadding:!0,className:"p-2",children:e.jsxs(w,{name:"dev",variant:"tertiary",size:1,className:"w-full justify-start",onClick:()=>{if(p(!1),i.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/admin");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}s("/admin")},children:[e.jsx(Yt,{className:"w-4 h-4"}),e.jsx("span",{className:"ml-2 font-semibold",children:"Dev"})]})})]})})]})})]})})}function ga(){return e.jsxs(e.Fragment,{children:[e.jsx(ua,{}),e.jsx(aa,{})]})}const pa="_uploadContainer_1w5i1_1",ma="_dropZone_1w5i1_9",ha="_hasFile_1w5i1_30",fa="_dropZoneIcon_1w5i1_37",xa="_dropZoneText_1w5i1_43",va="_dropZoneSubtext_1w5i1_49",_a="_filePreview_1w5i1_55",ja="_filePreviewImage_1w5i1_64",wa="_fileName_1w5i1_110",Ca="_fileInfo_1w5i1_118",ya="_helpLink_1w5i1_125",Sa="_loadingContainer_1w5i1_145",ba="_loadingText_1w5i1_153",Na="_generateButtonContainer_1w5i1_157",ka="_uploadedMapContainer_1w5i1_165",Ia="_uploadedMapImage_1w5i1_169",Ma="_formGrid_1w5i1_209",La="_titleField_1w5i1_222",Ta="_ratingDescription_1w5i1_230",Da="_ratingSlider_1w5i1_235",Pa="_ratingLabel_1w5i1_242",Ea="_ratingInput_1w5i1_251",Fa="_ratingValue_1w5i1_256",Ra="_submitSection_1w5i1_266",Aa="_successContainer_1w5i1_275",za="_successHeading_1w5i1_280",Oa="_successText_1w5i1_285",$a="_successButton_1w5i1_291",Ba="_viewFullSizeButton_1w5i1_297",Ua="_fullSizeModalOverlay_1w5i1_306",Wa="_lightModalOverlay_1w5i1_320",Ha="_fullSizeModalContent_1w5i1_334",Va="_fullSizeModalHeader_1w5i1_345",Ga="_fullSizeModalImage_1w5i1_361",qa="_confirmSection_1w5i1_398",Ya="_step2Layout_1w5i1_407",Za="_topRow_1w5i1_413",Ka="_ratingHidden_1w5i1_421",Ja="_imageSection_1w5i1_425",Qa="_ratingContent_1w5i1_435",Xa="_mapColumn_1w5i1_453",es="_contentColumn_1w5i1_458",ns="_step2bLayout_1w5i1_465",ts="_metadataSectionCard_1w5i1_562",as="_droneMetadataSection_1w5i1_571",ss="_droneMetadataHeading_1w5i1_577",is="_droneMetadataGrid_1w5i1_585",os="_rtkFixContainer_1w5i1_591",rs="_rtkFixLabel_1w5i1_597",ls="_rtkFixCheckbox_1w5i1_606",cs="_confirmButtonContainer_1w5i1_621",ds="_ratingWarningContent_1w5i1_629",us="_ratingWarningTitle_1w5i1_637",gs="_ratingWarningText_1w5i1_644",ps="_ratingWarningButtons_1w5i1_651",ms="_preprocessingProgress_1w5i1_658",hs="_carouselContainer_1w5i1_711",fs="_carouselImageWrapper_1w5i1_716",xs="_carouselImage_1w5i1_716",vs="_carouselNavigation_1w5i1_739",_s="_carouselButton_1w5i1_751",js="_carouselIndicators_1w5i1_775",ws="_carouselIndicator_1w5i1_775",Cs="_carouselIndicatorActive_1w5i1_804",ys="_viewImageButtonContainer_1w5i1_840",t={uploadContainer:pa,dropZone:ma,hasFile:ha,dropZoneIcon:fa,dropZoneText:xa,dropZoneSubtext:va,filePreview:_a,filePreviewImage:ja,fileName:wa,fileInfo:Ca,helpLink:ya,loadingContainer:Sa,loadingText:ba,generateButtonContainer:Na,uploadedMapContainer:ka,uploadedMapImage:Ia,formGrid:Ma,titleField:La,ratingDescription:Ta,ratingSlider:Da,ratingLabel:Pa,ratingInput:Ea,ratingValue:Fa,submitSection:Ra,successContainer:Aa,successHeading:za,successText:Oa,successButton:$a,viewFullSizeButton:Ba,fullSizeModalOverlay:Ua,lightModalOverlay:Wa,fullSizeModalContent:Ha,fullSizeModalHeader:Va,fullSizeModalImage:Ga,confirmSection:qa,step2Layout:Ya,topRow:Za,ratingHidden:Ka,imageSection:Ja,ratingContent:Qa,mapColumn:Xa,contentColumn:es,step2bLayout:ns,metadataSectionCard:ts,droneMetadataSection:as,droneMetadataHeading:ss,droneMetadataGrid:is,rtkFixContainer:os,rtkFixLabel:rs,rtkFixCheckbox:ls,confirmButtonContainer:cs,ratingWarningContent:ds,ratingWarningTitle:us,ratingWarningText:gs,ratingWarningButtons:ps,preprocessingProgress:ms,carouselContainer:hs,carouselImageWrapper:fs,carouselImage:xs,carouselNavigation:vs,carouselButton:_s,carouselIndicators:js,carouselIndicator:ws,carouselIndicatorActive:Cs,viewImageButtonContainer:ys},Rn=a.createContext(void 0),Ss=({children:i})=>{const[s,o]=a.useState(""),[p,c]=a.useState(""),[d,_]=a.useState(""),[C,S]=a.useState(""),[x,l]=a.useState(""),[b,M]=a.useState(""),[P,j]=a.useState(""),[F,A]=a.useState(!1),L={search:s,srcFilter:p,catFilter:d,regionFilter:C,countryFilter:x,imageTypeFilter:b,uploadTypeFilter:P,showReferenceExamples:F,setSearch:o,setSrcFilter:c,setCatFilter:_,setRegionFilter:S,setCountryFilter:l,setImageTypeFilter:M,setUploadTypeFilter:j,setShowReferenceExamples:A,clearAllFilters:()=>{o(""),c(""),_(""),S(""),l(""),M(""),j(""),A(!1)}};return e.jsx(Rn.Provider,{value:L,children:i})},bs=()=>{const i=a.useContext(Rn);if(i===void 0)throw new Error("useFilterContext must be used within a FilterProvider");return i};function Dn({files:i,file:s,preview:o,imageType:p,onFileChange:c,onRemoveImage:d,onAddImage:_,onImageTypeChange:C,onChangeFile:S}){const x=l=>{l.preventDefault();const b=l.dataTransfer.files?.[0];b&&c(b)};return e.jsxs("div",{className:"space-y-6",children:[e.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."}),e.jsx("div",{className:t.helpLink,children:e.jsxs(zt,{to:"/help",className:t.helpLink,children:["More ",e.jsx(Zt,{className:"w-3 h-3"})]})}),e.jsx("div",{className:"flex justify-center",children:e.jsx(U,{withInternalPadding:!0,className:"bg-transparent border-none shadow-none",children:e.jsx(Kt,{name:"image-type",value:p,onChange:l=>C(l),options:[{key:"crisis_map",label:"Crisis Maps"},{key:"drone_image",label:"Drone Imagery"}],keySelector:l=>l.key,labelSelector:l=>l.label})})}),e.jsxs("div",{className:`${t.dropZone} ${s?t.hasFile:""}`,onDragOver:l=>l.preventDefault(),onDrop:x,children:[i.length>1?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4 mb-4",children:i.map((l,b)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:URL.createObjectURL(l),alt:`Image ${b+1}`,className:"w-full h-32 object-cover rounded"}),e.jsx(cn,{name:"remove-image",variant:"tertiary",onClick:()=>d(b),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:e.jsx(dn,{className:"w-4 h-4"})}),e.jsx("div",{className:"text-xs text-center mt-1",children:l.name})]},b))}):s&&o?e.jsxs("div",{className:t.filePreview,children:[e.jsx("div",{className:t.filePreviewImage,children:e.jsx("img",{src:o,alt:"File preview"})}),e.jsx("p",{className:t.fileName,children:s.name}),e.jsxs("p",{className:t.fileInfo,children:[(s.size/1024/1024).toFixed(2)," MB"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fn,{className:t.dropZoneIcon}),e.jsx("p",{className:t.dropZoneText,children:"Drag & Drop any file here"}),e.jsx("p",{className:t.dropZoneSubtext,children:"or"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("label",{className:"inline-block cursor-pointer",children:[e.jsx("input",{type:"file",className:"sr-only",accept:".jpg,.jpeg,.png,.tiff,.tif,.heic,.heif,.webp,.gif,.pdf",onChange:l=>{s&&S?S(l.target.files?.[0]):c(l.target.files?.[0])}}),e.jsx(w,{name:"upload",variant:"secondary",size:1,onClick:()=>document.querySelector('input[type="file"]')?.click(),children:s?"Change Image":"Browse Files"})]}),s&&i.length<5&&e.jsx(w,{name:"add-image",variant:"secondary",size:1,onClick:_,children:"Add Image"})]})]})]})}function Pn({files:i,imageUrl:s,preview:o,onViewFullSize:p,currentImageIndex:c=0,onGoToPrevious:d,onGoToNext:_,onGoToImage:C,showCarousel:S=!1}){return S&&i.length>1?e.jsx(U,{heading:"Uploaded Images",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsxs("div",{className:t.carouselContainer,children:[e.jsx("div",{className:t.carouselImageWrapper,children:i[c]?e.jsx("img",{src:URL.createObjectURL(i[c]),alt:`Image ${c+1}`,className:t.carouselImage}):e.jsx("div",{className:t.imagePlaceholder,children:"No image available"})}),e.jsxs("div",{className:t.carouselNavigation,children:[e.jsx(w,{name:"previous-image",variant:"tertiary",size:1,onClick:d,className:t.carouselButton,children:e.jsx(Jt,{className:"w-4 h-4"})}),e.jsx("div",{className:t.carouselIndicators,children:i.map((x,l)=>e.jsx("button",{onClick:()=>C?.(l),className:`${t.carouselIndicator} ${l===c?t.carouselIndicatorActive:""}`,children:l+1},l))}),e.jsx(w,{name:"next-image",variant:"tertiary",size:1,onClick:_,className:t.carouselButton,children:e.jsx(Qt,{className:"w-4 h-4"})})]}),e.jsx("div",{className:t.viewImageButtonContainer,children:e.jsx(w,{name:"view-full-size-carousel",variant:"secondary",size:1,onClick:()=>p({file:i[c],index:c}),disabled:!i[c],children:"View Image"})})]})}):i.length>1?e.jsx("div",{className:"space-y-6",children:i.map((x,l)=>e.jsx(U,{heading:`Image ${l+1}: ${x.name}`,headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsxs("div",{className:t.uploadedMapContainer,children:[e.jsx("div",{className:t.uploadedMapImage,children:e.jsx("img",{src:URL.createObjectURL(x),alt:`Image ${l+1}`})}),e.jsx("div",{className:t.viewFullSizeButton,children:e.jsx(w,{name:`view-full-size-${l}`,variant:"secondary",size:1,onClick:()=>p({file:x,index:l}),children:"View Image"})})]})},l))}):e.jsx(U,{heading:"Uploaded Image",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsxs("div",{className:t.uploadedMapContainer,children:[e.jsx("div",{className:t.uploadedMapImage,children:e.jsx("img",{src:s||o||void 0,alt:"Uploaded image preview"})}),e.jsx("div",{className:t.viewFullSizeButton,children:e.jsx(w,{name:"view-full-size",variant:"secondary",size:1,onClick:()=>p(),children:"View Image"})})]})})}function Ns({files:i,imageType:s,title:o,source:p,eventType:c,epsg:d,countries:_,centerLon:C,centerLat:S,amslM:x,aglM:l,headingDeg:b,yawDeg:M,pitchDeg:P,rollDeg:j,rtkFix:F,stdHM:A,stdVM:z,metadataArray:L,sources:G,types:q,spatialReferences:Y,imageTypes:R,countriesOptions:Q,onTitleChange:Z,onSourceChange:ae,onEventTypeChange:K,onEpsgChange:se,onCountriesChange:ie,onCenterLonChange:oe,onCenterLatChange:re,onAmslMChange:le,onAglMChange:ce,onHeadingDegChange:de,onYawDegChange:ue,onPitchDegChange:ge,onRollDegChange:pe,onRtkFixChange:me,onStdHMChange:he,onStdVMChange:fe,onImageTypeChange:xe,updateMetadataForImage:E}){return i.length>1?e.jsxs("div",{children:[e.jsx("div",{className:"mb-4",children:e.jsx(D,{label:"Shared Title",name:"title",value:o,onChange:Z,placeholder:"Enter a title for all images...",required:!0})}),i.map((N,m)=>e.jsx("div",{className:"mb-6",children:e.jsx(U,{heading:`Image ${m+1}: ${N.name}`,headingLevel:4,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsxs("div",{className:t.formGrid,children:[s!=="drone_image"&&e.jsx(J,{label:"Source",name:`source_${m}`,value:L[m]?.source||"",onChange:h=>E(m,"source",h),options:G,keySelector:h=>h.s_code,labelSelector:h=>h.label,required:!0}),e.jsx(J,{label:"Event Type",name:`event_type_${m}`,value:L[m]?.eventType||"",onChange:h=>E(m,"eventType",h),options:q,keySelector:h=>h.t_code,labelSelector:h=>h.label,required:s!=="drone_image"}),e.jsx(J,{label:"EPSG",name:`epsg_${m}`,value:L[m]?.epsg||"",onChange:h=>E(m,"epsg",h),options:Y,keySelector:h=>h.epsg,labelSelector:h=>`${h.srid} (EPSG:${h.epsg})`,placeholder:"EPSG",required:s!=="drone_image"}),e.jsx(Ln,{label:"Countries (optional)",name:`countries_${m}`,value:L[m]?.countries||[],onChange:h=>E(m,"countries",h),options:Q,keySelector:h=>h.c_code,labelSelector:h=>h.label,placeholder:"Select one or more"}),s==="drone_image"&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:t.droneMetadataSection,children:[e.jsx("h4",{className:t.droneMetadataHeading,children:"Drone Flight Data"}),e.jsxs("div",{className:t.droneMetadataGrid,children:[e.jsx(D,{label:"Center Longitude",name:`center_lon_${m}`,value:L[m]?.centerLon||"",onChange:h=>E(m,"centerLon",h),placeholder:"e.g., -122.4194",step:"any"}),e.jsx(D,{label:"Center Latitude",name:`center_lat_${m}`,value:L[m]?.centerLat||"",onChange:h=>E(m,"centerLat",h),placeholder:"e.g., 37.7749",step:"any"}),e.jsx(D,{label:"Altitude AMSL (m)",name:`amsl_m_${m}`,value:L[m]?.amslM||"",onChange:h=>E(m,"amslM",h),placeholder:"e.g., 100.5",step:"any"}),e.jsx(D,{label:"Altitude AGL (m)",name:`agl_m_${m}`,value:L[m]?.aglM||"",onChange:h=>E(m,"aglM",h),placeholder:"e.g., 50.2",step:"any"}),e.jsx(D,{label:"Heading (degrees)",name:`heading_deg_${m}`,value:L[m]?.headingDeg||"",onChange:h=>E(m,"headingDeg",h),placeholder:"e.g., 180.0",step:"any"}),e.jsx(D,{label:"Yaw (degrees)",name:`yaw_deg_${m}`,value:L[m]?.yawDeg||"",onChange:h=>E(m,"yawDeg",h),placeholder:"e.g., 90.0",step:"any"}),e.jsx(D,{label:"Pitch (degrees)",name:`pitch_deg_${m}`,value:L[m]?.pitchDeg||"",onChange:h=>E(m,"pitchDeg",h),placeholder:"e.g., 0.0",step:"any"}),e.jsx(D,{label:"Roll (degrees)",name:`roll_deg_${m}`,value:L[m]?.rollDeg||"",onChange:h=>E(m,"rollDeg",h),placeholder:"e.g., 0.0",step:"any"}),e.jsx("div",{className:t.rtkFixContainer,children:e.jsxs("label",{className:t.rtkFixLabel,children:[e.jsx("input",{type:"checkbox",checked:L[m]?.rtkFix||!1,onChange:h=>E(m,"rtkFix",h.target.checked),className:t.rtkFixCheckbox}),"RTK Fix Available"]})}),e.jsx(D,{label:"Horizontal Std Dev (m)",name:`std_h_m_${m}`,value:L[m]?.stdHM||"",onChange:h=>E(m,"stdHM",h),placeholder:"e.g., 0.1",step:"any"}),e.jsx(D,{label:"Vertical Std Dev (m)",name:`std_v_m_${m}`,value:L[m]?.stdVM||"",onChange:h=>E(m,"stdVM",h),placeholder:"e.g., 0.2",step:"any"})]})]})})]})})},m))]}):e.jsxs("div",{className:t.formGrid,children:[e.jsx("div",{className:t.titleField,children:e.jsx(D,{label:"Title",name:"title",value:o,onChange:Z,placeholder:"Enter a title for this map...",required:!0})}),s!=="drone_image"&&e.jsx(J,{label:"Source",name:"source",value:p,onChange:ae,options:G,keySelector:N=>N.s_code,labelSelector:N=>N.label,required:!0}),e.jsx(J,{label:"Event Type",name:"event_type",value:c,onChange:K,options:q,keySelector:N=>N.t_code,labelSelector:N=>N.label,required:s!=="drone_image"}),e.jsx(J,{label:"EPSG",name:"epsg",value:d,onChange:se,options:Y,keySelector:N=>N.epsg,labelSelector:N=>`${N.srid} (EPSG:${N.epsg})`,placeholder:"EPSG",required:s!=="drone_image"}),e.jsx(J,{label:"Image Type",name:"image_type",value:s,onChange:xe,options:R,keySelector:N=>N.image_type,labelSelector:N=>N.label,required:!0}),e.jsx(Ln,{label:"Countries (optional)",name:"countries",value:_,onChange:ie,options:Q,keySelector:N=>N.c_code,labelSelector:N=>N.label,placeholder:"Select one or more"}),s==="drone_image"&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:t.droneMetadataSection,children:[e.jsx("h4",{className:t.droneMetadataHeading,children:"Drone Flight Data"}),e.jsxs("div",{className:t.droneMetadataGrid,children:[e.jsx(D,{label:"Center Longitude",name:"center_lon",value:C,onChange:oe,placeholder:"e.g., -122.4194",step:"any"}),e.jsx(D,{label:"Center Latitude",name:"center_lat",value:S,onChange:re,placeholder:"e.g., 37.7749",step:"any"}),e.jsx(D,{label:"Altitude AMSL (m)",name:"amsl_m",value:x,onChange:le,placeholder:"e.g., 100.5",step:"any"}),e.jsx(D,{label:"Altitude AGL (m)",name:"agl_m",value:l,onChange:ce,placeholder:"e.g., 50.2",step:"any"}),e.jsx(D,{label:"Heading (degrees)",name:"heading_deg",value:b,onChange:de,placeholder:"e.g., 180.0",step:"any"}),e.jsx(D,{label:"Yaw (degrees)",name:"yaw_deg",value:M,onChange:ue,placeholder:"e.g., 90.0",step:"any"}),e.jsx(D,{label:"Pitch (degrees)",name:"pitch_deg",value:P,onChange:ge,placeholder:"e.g., 0.0",step:"any"}),e.jsx(D,{label:"Roll (degrees)",name:"roll_deg",value:j,onChange:pe,placeholder:"e.g., 0.0",step:"any"}),e.jsx("div",{className:t.rtkFixContainer,children:e.jsxs("label",{className:t.rtkFixLabel,children:[e.jsx("input",{type:"checkbox",checked:F,onChange:N=>me(N.target.checked),className:t.rtkFixCheckbox}),"RTK Fix Available"]})}),e.jsx(D,{label:"Horizontal Std Dev (m)",name:"std_h_m",value:A,onChange:he,placeholder:"e.g., 0.1",step:"any"}),e.jsx(D,{label:"Vertical Std Dev (m)",name:"std_v_m",value:z,onChange:fe,placeholder:"e.g., 0.2",step:"any"})]})]})})]})}function ks({isPerformanceConfirmed:i,scores:s,onScoreChange:o,onConfirmRatings:p,onEditRatings:c}){return i?null:e.jsx(U,{heading:"AI Performance Rating",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsxs("div",{className:t.ratingContent,children:[e.jsx("p",{className:t.ratingDescription,children:"How well did the AI perform on the task?"}),["accuracy","context","usability"].map(d=>e.jsxs("div",{className:t.ratingSlider,children:[e.jsx("label",{className:t.ratingLabel,children:d}),e.jsx("input",{type:"range",min:0,max:100,value:s[d],onChange:_=>o(d,Number(_.target.value)),className:t.ratingInput}),e.jsx("span",{className:t.ratingValue,children:s[d]})]},d)),e.jsx("div",{className:t.confirmButtonContainer,children:e.jsx(w,{name:"confirm-ratings",variant:"secondary",onClick:p,children:"Confirm Ratings"})})]})})}function Is({description:i,analysis:s,recommendedActions:o,onDescriptionChange:p,onAnalysisChange:c,onRecommendedActionsChange:d,onBack:_,onDelete:C,onSubmit:S,onEditRatings:x,isPerformanceConfirmed:l=!1}){const b=M=>{if(M){const P=M.split(`
3
+ `),j=P.findIndex(z=>z.startsWith("Description:")),F=P.findIndex(z=>z.startsWith("Analysis:")),A=P.findIndex(z=>z.startsWith("Recommended Actions:"));j!==-1&&F!==-1&&A!==-1&&(p(P.slice(j+1,F).join(`
4
+ `).trim()),c(P.slice(F+1,A).join(`
5
+ `).trim()),d(P.slice(A+1).join(`
6
+ `).trim()))}};return e.jsxs(U,{heading:"Generated Text",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsx("div",{className:"text-left space-y-4",children:e.jsx("div",{children:e.jsx(Xt,{name:"generatedContent",value:`Description:
7
+ ${i||"AI-generated description will appear here..."}
8
+
9
+ Analysis:
10
+ ${s||"AI-generated analysis will appear here..."}
11
+
12
+ Recommended Actions:
13
+ ${o||"AI-generated recommended actions will appear here..."}`,onChange:b,rows:12,placeholder:"AI-generated content will appear here..."})})}),e.jsxs("div",{className:t.submitSection,children:[e.jsx(w,{name:"back",variant:"secondary",onClick:_,children:"Back"}),l&&x&&e.jsx(w,{name:"edit-ratings",variant:"secondary",onClick:x,children:"Edit Ratings"}),e.jsx(cn,{name:"delete",variant:"tertiary",onClick:C,title:"Delete",ariaLabel:"Delete uploaded image",children:e.jsx(dn,{})}),e.jsx(w,{name:"submit",onClick:S,children:"Submit"})]})]})}function Ms({isOpen:i,imageUrl:s,preview:o,selectedImageData:p,onClose:c}){if(!i)return null;let d,_;return p?(d=URL.createObjectURL(p.file),_=`Image ${p.index+1}: ${p.file.name}`):(d=s||o||void 0,_="Full size map"),e.jsx("div",{className:t.fullSizeModalOverlay,onClick:c,children:e.jsxs("div",{className:t.fullSizeModalContent,onClick:C=>C.stopPropagation(),children:[e.jsx("div",{className:t.fullSizeModalHeader,children:e.jsx(w,{name:"close-modal",variant:"tertiary",size:1,onClick:c,children:"✕"})}),e.jsx("div",{className:t.fullSizeModalImage,children:e.jsx("img",{src:d,alt:_})})]})})}function Ls({isOpen:i,onClose:s}){return i?e.jsx("div",{className:t.fullSizeModalOverlay,onClick:s,children:e.jsx("div",{className:t.fullSizeModalContent,onClick:o=>o.stopPropagation(),children:e.jsxs("div",{className:t.ratingWarningContent,children:[e.jsx("h3",{className:t.ratingWarningTitle,children:"Please Confirm Your Ratings"}),e.jsx("p",{className:t.ratingWarningText,children:'You must confirm your performance ratings before submitting. Please go back to the rating section and click "Confirm Ratings".'}),e.jsx("div",{className:t.ratingWarningButtons,children:e.jsx(w,{name:"close-warning",variant:"secondary",onClick:s,children:"Close"})})]})})}):null}function Ts({isOpen:i,onConfirm:s,onCancel:o}){return i?e.jsx("div",{className:t.fullSizeModalOverlay,onClick:o,children:e.jsx("div",{className:t.fullSizeModalContent,onClick:p=>p.stopPropagation(),children:e.jsxs("div",{className:t.ratingWarningContent,children:[e.jsx("h3",{className:t.ratingWarningTitle,children:"Delete Image?"}),e.jsx("p",{className:t.ratingWarningText,children:"This action cannot be undone. Are you sure you want to delete this uploaded image?"}),e.jsxs("div",{className:t.ratingWarningButtons,children:[e.jsx(w,{name:"confirm-delete",variant:"secondary",onClick:s,children:"Delete"}),e.jsx(w,{name:"cancel-delete",variant:"tertiary",onClick:o,children:"Cancel"})]})]})})}):null}function Ds({isOpen:i,onConfirm:s,onCancel:o}){return i?e.jsx("div",{className:t.fullSizeModalOverlay,onClick:o,children:e.jsx("div",{className:t.fullSizeModalContent,onClick:p=>p.stopPropagation(),children:e.jsxs("div",{className:t.ratingWarningContent,children:[e.jsx("h3",{className:t.ratingWarningTitle,children:"Leave Page?"}),e.jsx("p",{className:t.ratingWarningText,children:"Your uploaded image will be deleted if you leave this page. Are you sure you want to continue?"}),e.jsxs("div",{className:t.ratingWarningButtons,children:[e.jsx(w,{name:"confirm-navigation",variant:"secondary",onClick:s,children:"Leave Page"}),e.jsx(w,{name:"cancel-navigation",variant:"tertiary",onClick:o,children:"Stay"})]})]})})}):null}function Ps({isOpen:i,fallbackInfo:s,onClose:o}){return!i||!s?null:e.jsx("div",{className:t.fullSizeModalOverlay,onClick:o,children:e.jsx("div",{className:t.fullSizeModalContent,onClick:p=>p.stopPropagation(),children:e.jsxs("div",{className:t.ratingWarningContent,children:[e.jsx("h3",{className:t.ratingWarningTitle,children:"Model Changed"}),e.jsxs("p",{className:t.ratingWarningText,children:[s.originalModel," is currently unavailable. We've automatically switched to ",s.fallbackModel," to complete your request."]}),e.jsx("div",{className:t.ratingWarningButtons,children:e.jsx(w,{name:"close-fallback",variant:"secondary",onClick:o,children:"Got it"})})]})})})}function Es({isOpen:i,preprocessingInfo:s,onClose:o}){return!i||!s?null:e.jsx("div",{className:t.fullSizeModalOverlay,onClick:o,children:e.jsx("div",{className:t.fullSizeModalContent,onClick:p=>p.stopPropagation(),children:e.jsxs("div",{className:t.ratingWarningContent,children:[e.jsx("h3",{className:t.ratingWarningTitle,children:"File Converted"}),e.jsxs("p",{className:t.ratingWarningText,children:["Your file ",e.jsx("strong",{children:s.original_filename})," has been converted from",e.jsxs("strong",{children:[" ",s.original_mime_type]})," to",e.jsxs("strong",{children:[" ",s.processed_mime_type]})," for optimal processing.",e.jsx("br",{}),e.jsx("br",{}),"This conversion ensures your file is in the best format for our AI models to analyze."]}),e.jsx("div",{className:t.ratingWarningButtons,children:e.jsx(w,{name:"close-preprocessing",variant:"secondary",onClick:o,children:"Got it"})})]})})})}function Fs({isOpen:i,preprocessingFile:s,isPreprocessing:o,preprocessingProgress:p,onConfirm:c,onCancel:d}){return i?e.jsx("div",{className:t.fullSizeModalOverlay,onClick:o?void 0:d,children:e.jsx("div",{className:t.fullSizeModalContent,onClick:_=>_.stopPropagation(),children:e.jsxs("div",{className:t.ratingWarningContent,children:[e.jsx("h3",{className:t.ratingWarningTitle,children:"File Conversion Required"}),e.jsx("p",{className:t.ratingWarningText,children:"The file you selected will be converted to PNG format. This ensures optimal compatibility and processing by our AI models."}),!o&&e.jsxs("div",{className:t.ratingWarningButtons,children:[e.jsx(w,{name:"confirm-preprocessing",variant:"secondary",onClick:c,children:"Convert File"}),e.jsx(w,{name:"cancel-preprocessing",variant:"tertiary",onClick:d,children:"Cancel"})]}),o&&e.jsxs("div",{className:t.preprocessingProgress,children:[e.jsx("p",{children:p}),e.jsx(rn,{className:"text-ifrcRed"})]})]})})}):null}function Rs({isOpen:i,unsupportedFile:s,onClose:o}){return!i||!s?null:e.jsx("div",{className:t.fullSizeModalOverlay,onClick:o,children:e.jsx("div",{className:t.fullSizeModalContent,onClick:p=>p.stopPropagation(),children:e.jsxs("div",{className:t.ratingWarningContent,children:[e.jsx("h3",{className:t.ratingWarningTitle,children:"Unsupported File Format"}),e.jsxs("p",{className:t.ratingWarningText,children:["The file ",e.jsx("strong",{children:s.name})," is not supported for upload.",e.jsx("br",{}),e.jsx("br",{}),e.jsx("strong",{children:"Supported formats:"}),e.jsx("br",{}),"• Images: JPEG, PNG, TIFF, HEIC, WebP, GIF",e.jsx("br",{}),"• Documents: PDF (will be converted to image)",e.jsx("br",{}),e.jsx("br",{}),e.jsx("strong",{children:"Recommendation:"})," Convert your file to JPEG or PNG format for best compatibility."]}),e.jsx("div",{className:t.ratingWarningButtons,children:e.jsx(w,{name:"close-unsupported",variant:"secondary",onClick:o,children:"Got it"})})]})})})}function As({isOpen:i,oversizedFile:s,onClose:o,onCancel:p}){return!i||!s?null:e.jsx("div",{className:t.lightModalOverlay,onClick:p,children:e.jsx("div",{className:t.fullSizeModalContent,onClick:c=>c.stopPropagation(),children:e.jsxs("div",{className:t.ratingWarningContent,children:[e.jsx("h3",{className:t.ratingWarningTitle,children:"File Size Warning"}),e.jsxs("p",{className:t.ratingWarningText,children:["The file ",e.jsx("strong",{children:s.name})," is large (",(s.size/(1024*1024)).toFixed(1),"MB).",e.jsx("br",{}),e.jsx("br",{}),e.jsx("strong",{children:"Warning:"})," This file size might exceed the limits of the AI models we use.",e.jsx("br",{}),e.jsx("br",{}),"You can still proceed, but consider using a smaller file if you encounter issues."]}),e.jsxs("div",{className:t.ratingWarningButtons,children:[e.jsx(w,{name:"continue-size-warning",variant:"secondary",onClick:o,children:"Continue"}),e.jsx(w,{name:"cancel-size-warning",variant:"tertiary",onClick:p,children:"Cancel"})]})]})})})}const Ee="selectedVlmModel";function En(){const[i]=Ot(),s=un(),[o,p]=a.useState(1),[c,d]=a.useState(!1),[_,C]=a.useState(!1),S=a.useRef(o),x=a.useRef(null),[l,b]=a.useState(null),[M,P]=a.useState(null),[j,F]=a.useState([]),[A,z]=a.useState(""),[L,G]=a.useState(""),[q,Y]=a.useState(""),[R,Q]=a.useState("crisis_map"),[Z,ae]=a.useState([]),[K,se]=a.useState(""),[ie,oe]=a.useState(""),[re,le]=a.useState(""),[ce,de]=a.useState(""),[ue,ge]=a.useState(""),[pe,me]=a.useState(""),[he,fe]=a.useState(""),[xe,E]=a.useState(""),[N,m]=a.useState(""),[h,Fe]=a.useState(!1),[Re,Ae]=a.useState(""),[ze,Oe]=a.useState(""),[$e,Se]=a.useState([]),[An,zn]=a.useState([]),[On,$n]=a.useState([]),[Bn,Un]=a.useState([]),[Wn,Hn]=a.useState([]),[Vn,Gn]=a.useState([]),[W,be]=a.useState(null),[Be,X]=a.useState([]),[Ne,gn]=a.useState(null),[qn,pn]=a.useState(""),[mn,Ue]=a.useState(""),[hn,We]=a.useState(""),[fn,He]=a.useState(""),[ke,xn]=a.useState({accuracy:50,context:50,usability:50}),[Yn,Ve]=a.useState(!1),[Zn,Ge]=a.useState(null),[ve,Ie]=a.useState(!1),[Kn,vn]=a.useState(!1),[Jn,qe]=a.useState(!1),[Qn,Me]=a.useState(!1),[Ye,Ze]=a.useState(null),[Xn,Ke]=a.useState(!1),[et,_n]=a.useState(null),[nt,Je]=a.useState(!1),[tt,jn]=a.useState(null),[at,ee]=a.useState(!1),[Qe,ne]=a.useState(null),[st,_e]=a.useState(!1),[it,H]=a.useState(""),[ot,Le]=a.useState(!1),[rt,Xe]=a.useState(null),[lt,je]=a.useState(!1),[ct,en]=a.useState(null),[dt,Te]=a.useState(0);S.current=o,x.current=W;const ut=n=>z(n||""),gt=n=>G(n||""),pt=n=>Y(n||""),nn=n=>Q(n||""),mt=n=>ae(Array.isArray(n)?n:[]),ht=n=>oe(n||""),ft=n=>le(n||""),xt=n=>de(n||""),vt=n=>ge(n||""),_t=n=>me(n||""),jt=n=>fe(n||""),wt=n=>E(n||""),Ct=n=>m(n||""),yt=n=>Fe(n||!1),St=n=>Ae(n||""),bt=n=>Oe(n||""),De=n=>p(n),Nt=a.useCallback(()=>{j.length>1&&Te(n=>n>0?n-1:j.length-1)},[j.length]),kt=a.useCallback(()=>{j.length>1&&Te(n=>n<j.length-1?n+1:0)},[j.length]),It=a.useCallback(n=>{n>=0&&n<j.length&&Te(n)},[j.length]),wn=()=>{if(j.length<5){const n=document.createElement("input");n.type="file",n.accept=".jpg,.jpeg,.png,.tiff,.tif,.heic,.heif,.webp,.gif,.pdf",n.onchange=f=>{const u=f.target;if(u.files&&u.files[0]){const g=u.files[0];tn(g)}},n.click()}},Cn=n=>{F(f=>{const u=f.filter((g,r)=>r!==n);return u.length===1?P(u[0]):u.length===0&&P(null),u}),Se(f=>f.filter((u,g)=>g!==n))},Mt=(n,f,u)=>{Se(g=>{const r=[...g];return r[n]||(r[n]={source:"",eventType:"",epsg:"",countries:[],centerLon:"",centerLat:"",amslM:"",aglM:"",headingDeg:"",yawDeg:"",pitchDeg:"",rollDeg:"",rtkFix:!1,stdHM:"",stdVM:""}),r[n]={...r[n],[f]:u},r})},yn=n=>{const f=["image/jpeg","image/jpg","image/png"],u=[".jpg",".jpeg",".png"];let g=!f.includes(n.type);if(!g&&n.name){const r=n.name.toLowerCase().substring(n.name.lastIndexOf("."));g=!u.includes(r)}return g},Sn=n=>{const f=["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 u of f)if(n.type.startsWith(u))return!0;if(n.name){const u=n.name.toLowerCase().substring(n.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(u))return!0}return!1},tn=n=>{if(n){if(console.log("File selected:",n.name,"Type:",n.type,"Size:",n.size),n.size/(1024*1024)>5&&(console.log("File too large, showing size warning modal"),en(n),je(!0)),Sn(n)){console.log("File format not supported at all, showing unsupported format modal"),Xe(n),Le(!0);return}yn(n)?(console.log("File needs preprocessing, showing modal"),ne(n),ee(!0)):(console.log("File does not need preprocessing, setting directly"),j.length===0?(P(n),F([n])):F(u=>[...u,n]))}},bn=n=>{if(n){if(console.log("File changed:",n.name,"Type:",n.type,"Size:",n.size),n.size/(1024*1024)>5&&(console.log("File too large, showing size warning modal"),en(n),je(!0)),Sn(n)){console.log("File format not supported at all, showing unsupported format modal"),Xe(n),Le(!0);return}yn(n)?(console.log("File needs preprocessing, showing modal"),ne(n),ee(!0)):(console.log("File does not need preprocessing, replacing last file"),j.length>1?(F(u=>{const g=[...u];return g[g.length-1]=n,g}),j.length===1&&P(n)):(P(n),F([n])))}};async function we(n){const f=await n.text();try{return f?JSON.parse(f):{}}catch{return{error:f}}}function an(n,f){const u=n instanceof Error?n.message:`Failed to ${f.toLowerCase()}`;alert(u)}async function Nn(){if(j.length!==0){d(!0);try{j.length===1?await Lt():await Tt()}catch(n){an(n,"Upload")}finally{d(!1)}}}async function Lt(){console.log("DEBUG: Starting single image upload");const n=new FormData;n.append("file",j[0]),n.append("title",K),n.append("image_type",R),A&&n.append("source",A),L&&n.append("event_type",L),q&&n.append("epsg",q),Z.length>0&&Z.forEach(r=>n.append("countries",r)),R==="drone_image"&&(ie&&n.append("center_lon",ie),re&&n.append("center_lat",re),ce&&n.append("amsl_m",ce),ue&&n.append("agl_m",ue),pe&&n.append("heading_deg",pe),he&&n.append("yaw_deg",he),xe&&n.append("pitch_deg",xe),N&&n.append("roll_deg",N),h&&n.append("rtk_fix",h.toString()),Re&&n.append("std_h_m",Re),ze&&n.append("std_v_m",ze));const f=localStorage.getItem(Ee);f&&n.append("model_name",f);const u=await fetch("/api/images/",{method:"POST",body:n}),g=await we(u);if(!u.ok)throw new Error(g.error||"Upload failed");console.log("DEBUG: Single upload response:",g),await kn(g,!1)}async function Tt(){console.log("DEBUG: Starting multi-image upload");const n=new FormData;j.forEach(r=>n.append("files",r)),n.append("title",K),n.append("image_type",R),$e.forEach((r,v)=>{r.source&&n.append(`source_${v}`,r.source),r.eventType&&n.append(`event_type_${v}`,r.eventType),r.epsg&&n.append(`epsg_${v}`,r.epsg),r.countries.length>0&&r.countries.forEach(T=>n.append(`countries_${v}`,T)),R==="drone_image"&&(r.centerLon&&n.append(`center_lon_${v}`,r.centerLon),r.centerLat&&n.append(`center_lat_${v}`,r.centerLat),r.amslM&&n.append(`amsl_m_${v}`,r.amslM),r.aglM&&n.append(`agl_m_${v}`,r.aglM),r.headingDeg&&n.append(`heading_deg_${v}`,r.headingDeg),r.yawDeg&&n.append(`yaw_deg_${v}`,r.yawDeg),r.pitchDeg&&n.append(`pitch_deg_${v}`,r.pitchDeg),r.rollDeg&&n.append(`roll_deg_${v}`,r.rollDeg),r.rtkFix&&n.append(`rtk_fix_${v}`,r.rtkFix.toString()),r.stdHM&&n.append(`std_h_m_${v}`,r.stdHM),r.stdVM&&n.append(`std_v_m_${v}`,r.stdVM))});const f=localStorage.getItem(Ee);f&&n.append("model_name",f);const u=await fetch("/api/images/multi",{method:"POST",body:n}),g=await we(u);if(!u.ok)throw new Error(g.error||"Upload failed");console.log("DEBUG: Multi upload response:",g),await kn(g,!0)}async function kn(n,f){gn(n.image_url),n.preprocessing_info&&typeof n.preprocessing_info=="object"&&"was_preprocessed"in n.preprocessing_info&&n.preprocessing_info.was_preprocessed===!0&&(jn(n.preprocessing_info),Je(!0));const u=n.image_id;if(!u)throw new Error("Upload failed: image_id not found");if(be(u),f)if(n.image_ids&&Array.isArray(n.image_ids)){const y=n.image_ids;console.log("DEBUG: Storing image IDs for multi-upload:",y),X(y)}else console.log("DEBUG: Multi-upload but no image_ids found, using single ID"),X([u]);else console.log("DEBUG: Storing single image ID:",u),X([u]);const g=n,r=g.raw_json?.fallback_info;r&&(_n({originalModel:r.original_model,fallbackModel:r.fallback_model,reason:r.reason}),Ke(!0));const v=g.raw_json?.metadata;if(v){const y=v.metadata||v;if(y&&typeof y=="object"){const O=[];if(f){const k=y.metadata_images;if(k&&typeof k=="object")for(let $=1;$<=j.length;$++){const Ce=`image${$}`,sn=k[Ce];if(sn&&typeof sn=="object"){const ye=sn;O.push({source:ye.source||"",eventType:ye.type||"",epsg:ye.epsg||"",countries:Array.isArray(ye.countries)?ye.countries:[],centerLon:"",centerLat:"",amslM:"",aglM:"",headingDeg:"",yawDeg:"",pitchDeg:"",rollDeg:"",rtkFix:!1,stdHM:"",stdVM:""})}else O.push({source:"",eventType:"",epsg:"",countries:[],centerLon:"",centerLat:"",amslM:"",aglM:"",headingDeg:"",yawDeg:"",pitchDeg:"",rollDeg:"",rtkFix:!1,stdHM:"",stdVM:""})}else{const $={source:y.source||"",eventType:y.type||"",epsg:y.epsg||"",countries:Array.isArray(y.countries)?y.countries:[],centerLon:"",centerLat:"",amslM:"",aglM:"",headingDeg:"",yawDeg:"",pitchDeg:"",rollDeg:"",rtkFix:!1,stdHM:"",stdVM:""};for(let Ce=0;Ce<j.length;Ce++)O.push({...$})}}else{const k={source:y.source||"",eventType:y.type||"",epsg:y.epsg||"",countries:Array.isArray(y.countries)?y.countries:[],centerLon:"",centerLat:"",amslM:"",aglM:"",headingDeg:"",yawDeg:"",pitchDeg:"",rollDeg:"",rtkFix:!1,stdHM:"",stdVM:""};O.push(k)}if(Se(O),O.length>0){const k=O[0];if(y&&typeof y=="object"){const $=y.title;$&&se($||"")}z(k.source||""),G(k.eventType||""),Y(k.epsg||""),ae(k.countries||[]),R==="drone_image"&&(oe(k.centerLon||""),le(k.centerLat||""),de(k.amslM||""),ge(k.aglM||""),me(k.headingDeg||""),fe(k.yawDeg||""),E(k.pitchDeg||""),m(k.rollDeg||""),Fe(k.rtkFix||!1),Ae(k.stdHM||""),Oe(k.stdVM||""))}}}const T=g.raw_json?.metadata;T&&(T.description&&Ue(T.description),T.analysis&&We(T.analysis),T.recommended_actions&&He(T.recommended_actions)),g.generated&&pn(g.generated),De("2a")}async function Dt(){if(console.log("handleSubmit called with:",{uploadedImageId:W,title:K,draft:qn}),!W)return alert("No image to submit");if(!ve){vn(!0);return}try{const n=Be.length>0?Be:[W];console.log("DEBUG: Submit - Using image IDs:",n),console.log("DEBUG: Submit - uploadedImageIds:",Be),console.log("DEBUG: Submit - uploadedImageId:",W);for(let v=0;v<n.length;v++){const T=n[v],y=$e[v]||{source:A||"OTHER",eventType:L||"OTHER",epsg:q||"OTHER",countries:Z||[]},O={source:R==="drone_image"?void 0:y.source||"OTHER",event_type:y.eventType||"OTHER",epsg:y.epsg||"OTHER",image_type:R,countries:y.countries||[]};console.log(`Updating metadata for image ${v+1}:`,O);const k=await fetch(`/api/images/${T}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)}),$=await we(k);if(!k.ok)throw new Error($.error||`Metadata update failed for image ${v+1}`)}const f=`Description: ${mn}
14
+
15
+ Analysis: ${hn}
16
+
17
+ Recommended Actions: ${fn}`,u={title:K,edited:f,accuracy:ke.accuracy,context:ke.context,usability:ke.usability};console.log("Updating caption:",u);const g=await fetch(`/api/images/${W}/caption`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}),r=await we(g);if(!g.ok)throw new Error(r.error||"Caption update failed");be(null),X([]),De(3)}catch(n){an(n,"Submit")}}async function In(){if(console.log("handleDelete called with uploadedImageId:",W),!W){alert("No image to delete. Please try refreshing the page.");return}qe(!0)}async function Pt(){try{console.log("Deleting image with ID:",W);const n=await fetch(`/api/images/${W}`,{method:"DELETE"});if(!n.ok){const f=await we(n);throw new Error(f.error||`Delete failed with status ${n.status}`)}qe(!1),Mn()}catch(n){an(n,"Delete")}}const Mn=()=>{Ie(!1),p(1),P(null),F([]),b(null),be(null),X([]),gn(null),se(""),z(""),G(""),Y(""),ae([]),oe(""),le(""),de(""),ge(""),me(""),fe(""),E(""),m(""),Fe(!1),Ae(""),Oe(""),xn({accuracy:50,context:50,usability:50}),pn(""),Ue(""),We(""),He(""),Se([]),Ke(!1),_n(null),Je(!1),jn(null),ee(!1),ne(null),_e(!1),H(""),Le(!1),Xe(null),je(!1),en(null),s("/upload",{replace:!0})},Pe=a.useCallback(n=>{n==="/upload"||n==="/"||(x.current?(Ze(n),Me(!0)):s(n))},[s]);async function Et(){if(Ye&&x.current)try{await fetch(`/api/images/${x.current}`,{method:"DELETE"}),Me(!1),Ze(null),s(Ye)}catch(n){console.error("Failed to delete image before navigation:",n),Me(!1),Ze(null),s(Ye)}}const Ft=async()=>{if(Qe){_e(!0),H("Starting file conversion...");try{const n=new FormData;n.append("file",Qe),n.append("preprocess_only","true"),H("Converting file format...");const f=await fetch("/api/images/preprocess",{method:"POST",body:n});if(!f.ok)throw new Error("Preprocessing failed");const u=await f.json();H("Finalizing conversion...");const g=atob(u.processed_content),r=new Uint8Array(g.length);for(let y=0;y<g.length;y++)r[y]=g.charCodeAt(y);const v=new File([r],u.processed_filename,{type:u.processed_mime_type}),T=URL.createObjectURL(v);j.length===0?(P(v),F([v])):F(y=>[...y,v]),b(T),H("Conversion complete!"),setTimeout(()=>{ee(!1),ne(null),_e(!1),H("")},1e3)}catch(n){console.error("Preprocessing error:",n),H("Conversion failed. Please try again."),setTimeout(()=>{ee(!1),ne(null),_e(!1),H("")},2e3)}}},Rt=()=>{ee(!1),ne(null),_e(!1),H("")},At=async n=>{C(!0);try{const f=n.map(async v=>{const T=await fetch(`/api/images/${v}`);if(!T.ok)throw new Error(`Failed to fetch image ${v}`);const y=await T.json(),O=await fetch(`/api/images/${v}/file`);if(!O.ok)throw new Error(`Failed to fetch image file ${v}`);const k=await O.blob(),$=y.file_key.split("/").pop()||`contributed_${v}.png`;return{file:new File([k],$,{type:k.type}),imageData:y}}),u=await Promise.all(f),g=u.map(v=>v.file),r=u[0]?.imageData;F(g),X(n),n.length===1&&be(n[0]),g.length>=1&&P(g[0]),r?.image_type&&Q(r.image_type)}catch(f){console.error("Failed to fetch contributed images:",f),alert(`Failed to load contributed images: ${f instanceof Error?f.message:"Unknown error"}`)}finally{C(!1)}};return a.useEffect(()=>{Promise.all([fetch("/api/sources").then(n=>n.json()),fetch("/api/types").then(n=>n.json()),fetch("/api/spatial-references").then(n=>n.json()),fetch("/api/image-types").then(n=>n.json()),fetch("/api/countries").then(n=>n.json()),fetch("/api/models").then(n=>n.json())]).then(([n,f,u,g,r,v])=>{!localStorage.getItem(Ee)&&v?.length&&localStorage.setItem(Ee,v[0].m_code),zn(n),$n(f),Un(u),Hn(g),Gn(r),n.length>0&&z(n[0].s_code),G("OTHER"),Y("OTHER"),g.length>0&&!i.get("imageType")&&!R&&Q(g[0].image_type)})},[i,R]),a.useEffect(()=>(window.confirmNavigationIfNeeded=n=>{Pe(n)},()=>{delete window.confirmNavigationIfNeeded}),[Pe]),a.useEffect(()=>{const n=g=>{if(x.current){const r="You have an uploaded image that will be deleted if you leave this page. Are you sure you want to leave?";return g.preventDefault(),g.returnValue=r,r}},f=()=>{x.current&&fetch(`/api/images/${x.current}`,{method:"DELETE"}).catch(console.error)},u=g=>{const r=g.target,v=r.closest("a[href]")||r.closest("[data-navigate]");if(v&&x.current){const T=v.getAttribute("href")||v.getAttribute("data-navigate");T&&T!=="#"&&!T.startsWith("javascript:")&&!T.startsWith("mailto:")&&(g.preventDefault(),g.stopPropagation(),Pe(T))}};return window.addEventListener("beforeunload",n),document.addEventListener("click",u,!0),()=>{window.removeEventListener("beforeunload",n),document.removeEventListener("click",u,!0),f()}},[Pe]),a.useEffect(()=>{if(!M){b(null);return}const n=URL.createObjectURL(M);return b(n),()=>URL.revokeObjectURL(n)},[M]),a.useEffect(()=>{const n=i.get("contribute"),f=i.get("imageIds");if(n==="true"&&f){const u=f.split(",").filter(g=>g.trim());u.length>0&&At(u)}},[i]),a.useEffect(()=>{o==="2b"&&Te(0)},[o]),e.jsxs(ln,{children:[o!==3&&e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsxs("div",{className:t.uploadContainer,"data-step":o,children:[o===1&&!i.get("step")&&!_&&e.jsx(Dn,{files:j,file:M,preview:l,imageType:R,onFileChange:tn,onRemoveImage:Cn,onAddImage:wn,onImageTypeChange:nn,onChangeFile:bn}),o===1&&i.get("contribute")==="true"&&!_&&j.length>0&&e.jsx(Dn,{files:j,file:M,preview:l,imageType:R,onFileChange:tn,onRemoveImage:Cn,onAddImage:wn,onImageTypeChange:nn,onChangeFile:bn}),c&&e.jsxs("div",{className:t.loadingContainer,children:[e.jsx(rn,{className:"text-ifrcRed"}),e.jsx("p",{className:t.loadingText,children:"Generating..."})]}),_&&e.jsxs("div",{className:t.loadingContainer,children:[e.jsx(rn,{className:"text-ifrcRed"}),e.jsx("p",{className:t.loadingText,children:"Loading contribution..."})]}),(o===1&&!c&&!_||o===1&&i.get("contribute")==="true"&&!c&&!_&&j.length>0)&&e.jsx("div",{className:t.generateButtonContainer,children:Ne?e.jsx(w,{name:"generate-from-url",onClick:Nn,children:"Generate Caption"}):e.jsx(w,{name:"generate",disabled:j.length===0,onClick:Nn,children:"Generate"})}),o==="2a"&&e.jsxs("div",{className:t.step2Layout,children:[e.jsx("div",{className:t.mapColumn,children:e.jsx(Pn,{files:j,imageUrl:Ne,preview:l,onViewFullSize:n=>{Ge(n||null),Ve(!0)}})}),e.jsx("div",{className:t.contentColumn,children:e.jsxs("div",{className:t.metadataSectionCard,children:[e.jsx(Ns,{files:j,imageType:R,title:K,source:A,eventType:L,epsg:q,countries:Z,centerLon:ie,centerLat:re,amslM:ce,aglM:ue,headingDeg:pe,yawDeg:he,pitchDeg:xe,rollDeg:N,rtkFix:h,stdHM:Re,stdVM:ze,metadataArray:$e,sources:An,types:On,spatialReferences:Bn,imageTypes:Wn,countriesOptions:Vn,onTitleChange:n=>se(n||""),onSourceChange:ut,onEventTypeChange:gt,onEpsgChange:pt,onCountriesChange:mt,onCenterLonChange:ht,onCenterLatChange:ft,onAmslMChange:xt,onAglMChange:vt,onHeadingDegChange:_t,onYawDegChange:jt,onPitchDegChange:wt,onRollDegChange:Ct,onRtkFixChange:yt,onStdHMChange:St,onStdVMChange:bt,onImageTypeChange:nn,updateMetadataForImage:Mt}),e.jsxs("div",{className:t.confirmSection,children:[e.jsx(cn,{name:"delete",variant:"tertiary",onClick:In,title:"Delete",ariaLabel:"Delete uploaded image",children:e.jsx(dn,{})}),e.jsx(w,{name:"confirm-metadata",onClick:()=>De("2b"),children:"Next"})]})]})})]}),o==="2b"&&e.jsxs("div",{className:t.step2bLayout,children:[e.jsxs("div",{className:`${t.topRow} ${ve?t.ratingHidden:""}`,children:[e.jsx("div",{className:t.imageSection,children:e.jsx(Pn,{files:j,imageUrl:Ne,preview:l,onViewFullSize:n=>{Ge(n||null),Ve(!0)},currentImageIndex:dt,onGoToPrevious:Nt,onGoToNext:kt,onGoToImage:It,showCarousel:!0})}),!ve&&e.jsx("div",{className:t.metadataSectionCard,children:e.jsx(ks,{isPerformanceConfirmed:ve,scores:ke,onScoreChange:(n,f)=>xn(u=>({...u,[n]:f})),onConfirmRatings:()=>Ie(!0),onEditRatings:()=>Ie(!1)})})]}),e.jsx("div",{className:t.metadataSectionCard,children:e.jsx(Is,{description:mn,analysis:hn,recommendedActions:fn,onDescriptionChange:n=>Ue(n||""),onAnalysisChange:n=>We(n||""),onRecommendedActionsChange:n=>He(n||""),onBack:()=>De("2a"),onDelete:In,onSubmit:Dt,onEditRatings:()=>Ie(!1),isPerformanceConfirmed:ve})})]})]})}),o===3&&e.jsxs("div",{className:t.successContainer,children:[e.jsx(te,{level:2,className:t.successHeading,children:"Saved!"}),e.jsx("p",{className:t.successText,children:i.get("contribute")==="true"?"Your contribution has been successfully saved.":"Your caption has been successfully saved."}),e.jsx("div",{className:t.successButton,children:e.jsx(w,{name:"upload-another",onClick:()=>{Mn()},children:"Upload Another"})})]}),e.jsx(Ms,{isOpen:Yn,imageUrl:Ne,preview:l,selectedImageData:Zn,onClose:()=>{Ve(!1),Ge(null)}}),e.jsx(Ls,{isOpen:Kn,onClose:()=>vn(!1)}),e.jsx(Ts,{isOpen:Jn,onConfirm:Pt,onCancel:()=>qe(!1)}),e.jsx(Ds,{isOpen:Qn,onConfirm:Et,onCancel:()=>Me(!1)}),e.jsx(Ps,{isOpen:Xn,fallbackInfo:et,onClose:()=>Ke(!1)}),e.jsx(Es,{isOpen:nt,preprocessingInfo:tt,onClose:()=>Je(!1)}),e.jsx(Fs,{isOpen:at,preprocessingFile:Qe,isPreprocessing:st,preprocessingProgress:it,onConfirm:Ft,onCancel:Rt}),e.jsx(Rs,{isOpen:ot,unsupportedFile:rt,onClose:()=>Le(!1)}),e.jsx(As,{isOpen:lt,oversizedFile:ct,onClose:()=>je(!1),onCancel:()=>je(!1)})]})}const zs="_helpContainer_1wavj_1",Os="_helpSection_1wavj_13",$s="_sectionHeader_1wavj_49",Bs="_sectionTitle_1wavj_91",Us="_sectionContent_1wavj_105",Ws="_guidelinesList_1wavj_119",Hs="_buttonContainer_1wavj_181",I={helpContainer:zs,helpSection:Os,sectionHeader:$s,sectionTitle:Bs,sectionContent:Us,guidelinesList:Ws,buttonContainer:Hs};function Vs(){const i=un(),{setShowReferenceExamples:s}=bs(),o=()=>{i("/upload")},p=()=>{s(!0),i("/explore")},c=()=>{i("/analytics?view=crisis_maps")};return e.jsx(ln,{className:"py-10",children:e.jsx("div",{className:I.helpContainer,children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:I.helpSection,children:[e.jsx("div",{className:I.sectionHeader,children:e.jsx(te,{level:3,className:I.sectionTitle,children:"Introduction"})}),e.jsx("div",{className:I.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."}),e.jsx("div",{className:I.buttonContainer,children:e.jsx(w,{name:"upload-now",variant:"secondary",onClick:o,children:"Upload now →"})})]}),e.jsxs("div",{className:I.helpSection,children:[e.jsx("div",{className:I.sectionHeader,children:e.jsx(te,{level:3,className:I.sectionTitle,children:"Guidelines"})}),e.jsxs("div",{className:I.sectionContent,children:["To make the process smoother, please follow the guidelines below:",e.jsxs("ul",{className:I.guidelinesList,children:[e.jsx("li",{children:"Avoid uploading images that are not crisis maps/crisis drone images."}),e.jsx("li",{children:"Confirm the image details prior to modifying the description."}),e.jsx("li",{children:"Before the modification, please read the description generated and provide a rating via the rating sliders."}),e.jsx("li",{children:'Click the "Submit" button to save the description.'})]})]}),e.jsx("div",{className:I.buttonContainer,children:e.jsx(w,{name:"see-examples",variant:"secondary",onClick:p,children:"See examples →"})})]}),e.jsxs("div",{className:I.helpSection,children:[e.jsx("div",{className:I.sectionHeader,children:e.jsx(te,{level:3,className:I.sectionTitle,children:"VLMs"})}),e.jsx("div",{className:I.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:"}),e.jsx("div",{className:I.buttonContainer,children:e.jsx(w,{name:"view-vlm-details",variant:"secondary",onClick:c,children:"View VLM details →"})})]}),e.jsxs("div",{className:I.helpSection,children:[e.jsx("div",{className:I.sectionHeader,children:e.jsx(te,{level:3,className:I.sectionTitle,children:"Dataset"})}),e.jsx("div",{className:I.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."}),e.jsx("div",{className:I.buttonContainer,children:e.jsx(w,{name:"export-dataset",variant:"secondary",onClick:()=>{s(!1),i("/explore"),setTimeout(()=>{const d=document.querySelector('[name="export-dataset"]');d&&d.click()},100)},children:"Export dataset →"})})]}),e.jsxs("div",{className:I.helpSection,children:[e.jsx("div",{className:I.sectionHeader,children:e.jsx(te,{level:3,className:I.sectionTitle,children:"Contact us"})}),e.jsx("div",{className:I.sectionContent,children:"Need help or have questions about PromptAid Vision? Our team is here to support you."}),e.jsx("div",{className:I.buttonContainer,children:e.jsx(w,{name:"contact-support",variant:"secondary",disabled:!0,children:"Get in touch →"})})]})]})})})}const Gs=a.createContext(void 0),qs=({children:i})=>{const[s,o]=a.useState(!1),[p,c]=a.useState(!0),d=async()=>{const x=localStorage.getItem("adminToken");if(!x){o(!1),c(!1);return}try{(await fetch("/api/admin/verify",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x}`}})).ok?o(!0):(localStorage.removeItem("adminToken"),o(!1))}catch(l){console.error("Error verifying admin token:",l),localStorage.removeItem("adminToken"),o(!1)}finally{c(!1)}},_=async x=>{try{const l=await fetch("/api/admin/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:x})});if(l.ok){const b=await l.json();return localStorage.setItem("adminToken",b.access_token),o(!0),!0}else return!1}catch(l){return console.error("Login error:",l),!1}},C=()=>{localStorage.removeItem("adminToken"),o(!1)};a.useEffect(()=>{d()},[]);const S={isAuthenticated:s,isLoading:p,login:_,logout:C,verifyToken:d};return e.jsx(Gs.Provider,{value:S,children:i})},Ys=a.lazy(()=>B(()=>import("./index-DMU6q_dg.js"),__vite__mapDeps([0,1,2,3,4,5]))),Zs=a.lazy(()=>B(()=>import("./index-C8xjpbHZ.js"),__vite__mapDeps([6,1,2,3,4,7,8,9,10]))),Ks=a.lazy(()=>B(()=>import("./AdminPage-KksT68Fe.js"),__vite__mapDeps([11,1,2,7,3,4,12]))),Js=a.lazy(()=>B(()=>import("./index-B3MZlOIS.js"),__vite__mapDeps([13,1,2,3,4,7,8,9,14]))),V=i=>{const s=i();return s.catch(()=>{}),s},Qs=()=>{"requestIdleCallback"in window?requestIdleCallback(()=>{V(()=>B(()=>import("./index-DMU6q_dg.js"),__vite__mapDeps([0,1,2,3,4,5]))),V(()=>B(()=>import("./index-C8xjpbHZ.js"),__vite__mapDeps([6,1,2,3,4,7,8,9,10]))),V(()=>B(()=>import("./AdminPage-KksT68Fe.js"),__vite__mapDeps([11,1,2,7,3,4,12]))),V(()=>B(()=>import("./index-B3MZlOIS.js"),__vite__mapDeps([13,1,2,3,4,7,8,9,14])))}):setTimeout(()=>{V(()=>B(()=>import("./index-DMU6q_dg.js"),__vite__mapDeps([0,1,2,3,4,5]))),V(()=>B(()=>import("./index-C8xjpbHZ.js"),__vite__mapDeps([6,1,2,3,4,7,8,9,10]))),V(()=>B(()=>import("./AdminPage-KksT68Fe.js"),__vite__mapDeps([11,1,2,7,3,4,12]))),V(()=>B(()=>import("./index-B3MZlOIS.js"),__vite__mapDeps([13,1,2,3,4,7,8,9,14])))},1e3)},Xs=$t([{element:e.jsx(ga,{}),children:[{path:"/",element:e.jsx(En,{})},{path:"/upload",element:e.jsx(En,{})},{path:"/analytics",element:e.jsx(a.Suspense,{fallback:e.jsx("div",{children:"Loading Analytics..."}),children:e.jsx(Ys,{})})},{path:"/explore",element:e.jsx(a.Suspense,{fallback:e.jsx("div",{children:"Loading Explore..."}),children:e.jsx(Zs,{})})},{path:"/help",element:e.jsx(Vs,{})},{path:"/admin",element:e.jsx(a.Suspense,{fallback:e.jsx("div",{children:"Loading Admin..."}),children:e.jsx(Ks,{})})},{path:"/map/:mapId",element:e.jsx(a.Suspense,{fallback:e.jsx("div",{children:"Loading Map Details..."}),children:e.jsx(Js,{})})}]}],{basename:"/app/"});function ei(){const[i,s]=a.useState([]);a.useEffect(()=>{Qs()},[]);const o=a.useCallback(C=>{s(S=>sa([...S,C],x=>x.name)??S)},[s]),p=a.useCallback(C=>{s(S=>{const x=S.findIndex(b=>b.name===C);if(x===-1)return S;const l=[...S];return l.splice(x,1),l})},[s]),c=a.useCallback((C,S)=>{s(x=>{const l=x.findIndex(M=>M.name===C);if(l===-1)return x;const b=[...x];return b[l]={...b[l],...S},b})},[s]),d=a.useMemo(()=>({alerts:i,addAlert:o,removeAlert:p,updateAlert:c}),[i,o,p,c]),_=a.useMemo(()=>({languageNamespaceStatus:{},setLanguageNamespaceStatus:()=>{},currentLanguage:"en",setCurrentLanguage:()=>{},strings:{},setStrings:()=>{},registerNamespace:()=>{}}),[]);return e.jsx(ea.Provider,{value:d,children:e.jsx(na.Provider,{value:_,children:e.jsx(qs,{children:e.jsx(Ss,{children:e.jsx(Bt,{router:Xs})})})})})}function ni(){return e.jsx(ei,{})}Ut.createRoot(document.getElementById("root")).render(e.jsx(a.StrictMode,{children:e.jsx(ni,{})}));export{Gs as A,Ms as F,B as _,bs as u};
py_backend/static/assets/index-C8xjpbHZ.js ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-utils-Db80MiSc.js","assets/vendor-DxpCibxB.js","assets/vendor-react-BxsGb6Ph.js"])))=>i.map(i=>d[i]);
2
+ import{u as Se,_ as Te}from"./index-C6NSRolP.js";import{r as m,j as t}from"./vendor-react-BxsGb6Ph.js";import{N as Ie,_ as ie,L as Ee,z as Z,n as D,D as be}from"./vendor-ui-l_DttnRj.js";import{u as Ce}from"./useAdmin-6S8boYmH.js";import{F as $e,E as Pe}from"./ExportModal-5QTtY4mk.js";import{a as Fe,u as De}from"./vendor-DxpCibxB.js";const ke="_tabSelector_o9y1f_1",Le="_metadataTags_o9y1f_8",Oe="_metadataTag_o9y1f_8",Me="_metadataTagSource_o9y1f_32",Re="_metadataTagType_o9y1f_43",Je="_mapItem_o9y1f_54",We="_mapItemImage_o9y1f_72",ze="_mapItemContent_o9y1f_92",Ue="_mapItemTitle_o9y1f_97",Ae="_mapItemMetadata_o9y1f_105",Be="_fullSizeModalOverlay_o9y1f_134",He="_fullSizeModalContent_o9y1f_148",Ve="_ratingWarningContent_o9y1f_159",Ge="_ratingWarningTitle_o9y1f_165",Ze="_ratingWarningText_o9y1f_172",qe="_ratingWarningButtons_o9y1f_179",g={tabSelector:ke,metadataTags:Le,metadataTag:Oe,metadataTagSource:Me,metadataTagType:Re,mapItem:Je,mapItemImage:We,mapItemContent:ze,mapItemTitle:Ue,mapItemMetadata:Ae,fullSizeModalOverlay:Be,fullSizeModalContent:He,ratingWarningContent:Ve,ratingWarningTitle:Ge,ratingWarningText:Ze,ratingWarningButtons:qe};function at(){const k=Fe(),q=De(),{isAuthenticated:ne}=Ce(),[K,oe]=m.useState("explore"),[_,L]=m.useState([]),{search:y,srcFilter:E,catFilter:b,regionFilter:C,countryFilter:$,imageTypeFilter:P,uploadTypeFilter:F,showReferenceExamples:j,setShowReferenceExamples:le}=Se(),[J,re]=m.useState([]),[W,ce]=m.useState([]),[Q,me]=m.useState([]),[ge,de]=m.useState([]),[X,pe]=m.useState([]),[ue,Y]=m.useState(!0),[z,ee]=m.useState(!0),[fe,U]=m.useState(!1),[he,A]=m.useState(!1),[_e,B]=m.useState(!1),[xe,O]=m.useState(!1),[M,te]=m.useState(""),[H,ae]=m.useState(!1),ye=[{key:"explore",label:"List"},{key:"mapDetails",label:"Carousel"}],se=()=>{ee(!0),fetch("/api/images/grouped").then(e=>e.ok?e.json():(console.error("ExplorePage: Grouped endpoint failed, trying legacy endpoint"),fetch("/api/captions/legacy").then(s=>s.ok?s.json():(console.error("ExplorePage: Legacy endpoint failed, trying regular images endpoint"),fetch("/api/images").then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);return o.json()}))))).then(e=>{if(console.log("ExplorePage: API response data:",e),Array.isArray(e)){const s=e.filter(o=>{const f=o.generated&&o.model,u=o.image_id&&o.image_id!=="undefined"&&o.image_id!=="null";return u||console.error("ExplorePage: Item missing valid image_id:",o),f&&u});console.log("ExplorePage: Filtered images with captions:",s.length),L(s)}else console.error("ExplorePage: API response is not an array:",e),L([])}).catch(()=>{L([])}).finally(()=>{ee(!1)})};m.useEffect(()=>{se()},[]),m.useEffect(()=>{const e=()=>{document.hidden||se()};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[]),m.useEffect(()=>{new URLSearchParams(q.search).get("export")==="true"&&(U(!0),k("/explore",{replace:!0}))},[q.search,k,y,E,b,C,$,P,j]),m.useEffect(()=>{Y(!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,o,f,u])=>{re(e),ce(s),me(o),de(f),pe(u)}).catch(()=>{}).finally(()=>{Y(!1)})},[]);const v=m.useMemo(()=>_.filter(e=>{const s=!y||e.title?.toLowerCase().includes(y.toLowerCase())||e.generated?.toLowerCase().includes(y.toLowerCase())||e.source?.toLowerCase().includes(y.toLowerCase())||e.event_type?.toLowerCase().includes(y.toLowerCase()),o=!E||e.source&&e.source.split(", ").some(x=>x.trim()===E),f=!b||e.event_type&&e.event_type.split(", ").some(x=>x.trim()===b),u=!C||e.countries.some(x=>x.r_code===C),N=!$||e.countries.some(x=>x.c_code===$),V=!P||e.image_type===P,R=!F||F==="single"&&(!e.image_count||e.image_count<=1)||F==="multiple"&&e.image_count&&e.image_count>1,w=!j||e.starred===!0;return s&&o&&f&&u&&N&&V&&R&&w}),[_,y,E,b,C,$,P,F,j]),je=async(e,s="fine-tuning")=>{if(e.length===0){alert("No images to export");return}A(!0),B(!1);try{const o=(await Te(async()=>{const{default:i}=await import("./vendor-utils-Db80MiSc.js").then(S=>S.j);return{default:i}},__vite__mapDeps([0,1,2]))).default,f=new o,u=e.filter(i=>i.image_type==="crisis_map"),N=e.filter(i=>i.image_type==="drone_image");if(u.length>0){const i=f.folder("crisis_maps_dataset"),S=i?.folder("images");if(S){let T=1;for(const a of u)try{const h=a.image_count&&a.image_count>1?a.all_image_ids||[a.image_id]:[a.image_id],G=h.map(async(n,p)=>{try{const l=await fetch(`/api/images/${n}/file`);if(!l.ok)throw new Error(`Failed to fetch image ${n}`);const r=await l.blob(),c=a.file_key.split(".").pop()||"jpg",d=`${String(T).padStart(4,"0")}_${String(p+1).padStart(2,"0")}.${c}`;return S.file(d,r),{success:!0,fileName:d,imageId:n}}catch(l){return console.error(`Failed to process image ${n}:`,l),{success:!1,fileName:"",imageId:n}}}),I=(await Promise.all(G)).filter(n=>n.success);if(I.length>0){if(s==="fine-tuning"){const n=I.map(r=>`images/${r.fileName}`),p=Math.random(),l={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:h,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(p<.8){const r=i.file("train.jsonl");if(r){const c=await r.async("string").then(d=>JSON.parse(d||"[]")).catch(()=>[]);c.push(l),i.file("train.jsonl",JSON.stringify(c,null,2))}else i.file("train.jsonl",JSON.stringify([l],null,2))}else if(p<.9){const r=i.file("test.jsonl");if(r){const c=await r.async("string").then(d=>JSON.parse(d||"[]")).catch(()=>[]);c.push(l),i.file("test.jsonl",JSON.stringify(c,null,2))}else i.file("test.jsonl",JSON.stringify([l],null,2))}else{const r=i.file("val.jsonl");if(r){const c=await r.async("string").then(d=>JSON.parse(d||"[]")).catch(()=>[]);c.push(l),i.file("val.jsonl",JSON.stringify(c,null,2))}else i.file("val.jsonl",JSON.stringify([l],null,2))}}else{const n=I.map(l=>`images/${l.fileName}`),p={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:h,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(T).padStart(4,"0")}.json`,JSON.stringify(p,null,2))}T++}}catch(h){console.error(`Failed to process caption ${a.image_id}:`,h)}}}if(N.length>0){const i=f.folder("drone_images_dataset"),S=i?.folder("images");if(S){let T=1;for(const a of N)try{const h=a.image_count&&a.image_count>1?a.all_image_ids||[a.image_id]:[a.image_id],G=h.map(async(n,p)=>{try{const l=await fetch(`/api/images/${n}/file`);if(!l.ok)throw new Error(`Failed to fetch image ${n}`);const r=await l.blob(),c=a.file_key.split(".").pop()||"jpg",d=`${String(T).padStart(4,"0")}_${String(p+1).padStart(2,"0")}.${c}`;return S.file(d,r),{success:!0,fileName:d,imageId:n}}catch(l){return console.error(`Failed to process image ${n}:`,l),{success:!1,fileName:"",imageId:n}}}),I=(await Promise.all(G)).filter(n=>n.success);if(I.length>0){if(s==="fine-tuning"){const n=I.map(r=>`images/${r.fileName}`),p=Math.random(),l={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:h,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(p<.8){const r=i.file("train.jsonl");if(r){const c=await r.async("string").then(d=>JSON.parse(d||"[]")).catch(()=>[]);c.push(l),i.file("train.jsonl",JSON.stringify(c,null,2))}else i.file("train.jsonl",JSON.stringify([l],null,2))}else if(p<.9){const r=i.file("test.jsonl");if(r){const c=await r.async("string").then(d=>JSON.parse(d||"[]")).catch(()=>[]);c.push(l),i.file("test.jsonl",JSON.stringify(c,null,2))}else i.file("test.jsonl",JSON.stringify([l],null,2))}else{const r=i.file("val.jsonl");if(r){const c=await r.async("string").then(d=>JSON.parse(d||"[]")).catch(()=>[]);c.push(l),i.file("val.jsonl",JSON.stringify(c,null,2))}else i.file("val.jsonl",JSON.stringify([l],null,2))}}else{const n=I.map(l=>`images/${l.fileName}`),p={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:h,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(T).padStart(4,"0")}.json`,JSON.stringify(p,null,2))}T++}}catch(h){console.error(`Failed to process caption ${a.image_id}:`,h)}}}const V=await f.generateAsync({type:"blob"}),R=URL.createObjectURL(V),w=document.createElement("a");w.href=R,w.download=`datasets_${s}_${new Date().toISOString().split("T")[0]}.zip`,document.body.appendChild(w),w.click(),document.body.removeChild(w),URL.revokeObjectURL(R);const x=(u.length||0)+(N.length||0);console.log(`Exported ${s} datasets with ${x} total images:`),u.length>0&&console.log(`- Crisis maps: ${u.length} images`),N.length>0&&console.log(`- Drone images: ${N.length} images`),B(!0)}catch(o){console.error("Export failed:",o),alert("Failed to export dataset. Please try again.")}finally{A(!1)}},ve=e=>{te(e),O(!0)},Ne=async()=>{if(M){ae(!0);try{console.log("Deleting image with ID:",M),(await fetch(`/api/images/${M}`,{method:"DELETE"})).ok?(L(s=>s.filter(o=>o.image_id!==M)),O(!1),te("")):(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{ae(!1)}}};return t.jsxs(Ie,{children:[z?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(ie,{className:"text-ifrcRed"}),t.jsx("div",{children:"Loading examples..."})]})}):t.jsxs("div",{className:"max-w-7xl mx-auto",children:[t.jsxs("div",{className:g.tabSelector,children:[t.jsx(Ee,{name:"explore-view",value:K,onChange:e=>{(e==="explore"||e==="mapDetails")&&(oe(e),e==="mapDetails"&&_.length>0&&(_[0]?.image_id&&_[0].image_id!=="undefined"&&_[0].image_id!=="null"?k(`/map/${_[0].image_id}`):console.error("Invalid image_id for navigation:",_[0]?.image_id)))},options:ye,keySelector:e=>e.key,labelSelector:e=>e.label}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[t.jsx(Z,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsxs(D,{name:"reference-examples",variant:j?"primary":"secondary",onClick:()=>le(!j),className:"whitespace-nowrap",children:[t.jsx("span",{className:"mr-2",children:j?t.jsx("span",{className:"text-yellow-400",children:"★"}):t.jsx("span",{className:"text-yellow-400",children:"☆"})}),"Reference Examples"]})}),t.jsx(D,{name:"export-dataset",variant:"secondary",onClick:()=>U(!0),children:"Export"})]})]}),K==="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(Z,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2 flex-1 min-w-[300px]",children:t.jsx($e,{sources:J,types:W,regions:Q,countries:ge,imageTypes:X,isLoadingFilters:ue})})})}),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:[v.length," of ",_.length," examples"]})}),z&&t.jsx("div",{className:"text-center py-12",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(ie,{className:"text-ifrcRed"}),t.jsx("div",{children:"Loading examples..."})]})}),!z&&t.jsxs("div",{className:"space-y-4",children:[v.map(e=>t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:`${g.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}`),k(`/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:g.mapItemImage,style:{width:"120px",height:"80px"},children:e.image_url?t.jsxs(t.Fragment,{children:[console.log("ExplorePage: Rendering image with URL:",e.image_url),t.jsx("img",{src:e.image_url,alt:e.file_key,onError:s=>{console.error("ExplorePage: Image failed to load:",e.image_url);const o=s.target;o.style.display="none",o.parentElement.innerHTML="Img"},onLoad:()=>console.log("ExplorePage: Image loaded successfully:",e.image_url)})]}):t.jsxs(t.Fragment,{children:[console.log("ExplorePage: No image_url provided for item:",e),"'Img'"]})}),t.jsxs("div",{className:g.mapItemContent,children:[t.jsx("h3",{className:g.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:g.mapItemMetadata,children:t.jsxs("div",{className:g.metadataTags,children:[e.image_type!=="drone_image"&&t.jsx("span",{className:g.metadataTagSource,children:e.source&&e.source.includes(", ")?e.source.split(", ").map(s=>J.find(o=>o.s_code===s.trim())?.label||s.trim()).join(", "):J.find(s=>s.s_code===e.source)?.label||e.source}),t.jsx("span",{className:g.metadataTagType,children:e.event_type&&e.event_type.includes(", ")?e.event_type.split(", ").map(s=>W.find(o=>o.t_code===s.trim())?.label||s.trim()).join(", "):W.find(s=>s.t_code===e.event_type)?.label||e.event_type}),t.jsx("span",{className:g.metadataTag,children:X.find(s=>s.image_type===e.image_type)?.label||e.image_type}),e.image_count&&e.image_count>1&&t.jsxs("span",{className:g.metadataTag,title:`Multi-upload with ${e.image_count} images`,children:["📷 ",e.image_count]}),(!e.image_count||e.image_count<=1)&&t.jsx("span",{className:g.metadataTag,title:"Single Upload",children:"Single"}),e.countries&&e.countries.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:g.metadataTag,children:Q.find(s=>s.r_code===e.countries[0].r_code)?.label||"Unknown Region"}),t.jsx("span",{className:g.metadataTag,children:e.countries.map(s=>s.label).join(", ")})]})]})})]})]}),ne&&t.jsx(Z,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(D,{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:()=>ve(e.image_id),title:"Delete","aria-label":"Delete saved image",children:t.jsx(be,{className:"w-4 h-4"})})})]},e.image_id)),!v.length&&t.jsx("div",{className:"text-center py-12",children:t.jsx("p",{className:"text-gray-500",children:"No examples found."})})]})]})]}):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"})]})})]}),xe&&t.jsx("div",{className:g.fullSizeModalOverlay,onClick:()=>O(!1),children:t.jsx("div",{className:g.fullSizeModalContent,onClick:e=>e.stopPropagation(),children:t.jsxs("div",{className:g.ratingWarningContent,children:[t.jsx("h3",{className:g.ratingWarningTitle,children:"Delete Image?"}),t.jsx("p",{className:g.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:g.ratingWarningButtons,children:[t.jsx(D,{name:"confirm-delete",variant:"secondary",onClick:Ne,disabled:H,children:H?"Deleting...":"Delete"}),t.jsx(D,{name:"cancel-delete",variant:"tertiary",onClick:()=>O(!1),disabled:H,children:"Cancel"})]})]})})}),t.jsx(Pe,{isOpen:fe,onClose:()=>{U(!1),B(!1),A(!1)},onExport:(e,s)=>{const o=v.filter(f=>s.includes(f.image_type));je(o,e)},filteredCount:v.length,totalCount:_.length,hasFilters:!!(y||E||b||C||$||P||F||j),crisisMapsCount:v.filter(e=>e.image_type==="crisis_map").length,droneImagesCount:v.filter(e=>e.image_type==="drone_image").length,isLoading:he,exportSuccess:_e})]})}export{at as default};
py_backend/static/assets/index-DMU6q_dg.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{u as Oe,r as d,j as t}from"./vendor-react-BxsGb6Ph.js";import{g as C,h as u,N as $,_ as Qe,L as Ue,z as _,P as be,K as F,n as p,y as h,i as f}from"./vendor-ui-l_DttnRj.js";import"./vendor-DxpCibxB.js";const Ge="_tabSelector_vlxoe_1",$e="_progressSection_vlxoe_14",ze="_progressLabel_vlxoe_20",qe="_chartGrid_vlxoe_28",Ke="_chartContainer_vlxoe_40",We="_tableContainer_vlxoe_51",Je="_modelPerformance_vlxoe_59",Xe="_loadingContainer_vlxoe_67",Ye="_errorContainer_vlxoe_77",Ze="_userInteractionCards_vlxoe_96",et="_userInteractionCard_vlxoe_96",tt="_userInteractionCardValue_vlxoe_116",at="_userInteractionCardLabel_vlxoe_123",st="_userInteractionCardButton_vlxoe_130",nt="_summaryStatsCards_vlxoe_148",rt="_summaryStatsCard_vlxoe_148",it="_summaryStatsCardValue_vlxoe_169",ot="_summaryStatsCardLabel_vlxoe_176",i={tabSelector:Ge,progressSection:$e,progressLabel:ze,chartGrid:qe,chartContainer:Ke,tableContainer:We,modelPerformance:Je,loadingContainer:Xe,errorContainer:Ye,userInteractionCards:Ze,userInteractionCard:et,userInteractionCardValue:tt,userInteractionCardLabel:at,userInteractionCardButton:st,summaryStatsCards:nt,summaryStatsCard:rt,summaryStatsCardValue:it,summaryStatsCardLabel:ot};function ut(){const[z]=Oe(),[c,q]=d.useState(null),[Me,K]=d.useState(!0),[W,J]=d.useState("crisis_maps"),[I,Se]=d.useState([]),[w,Ie]=d.useState([]),[N,we]=d.useState([]),[b,Ne]=d.useState([]),[D,De]=d.useState(!1),[T,Te]=d.useState(!1),[k,ke]=d.useState(!1),[P,Pe]=d.useState(!1),[H,Ee]=d.useState(!1),[E,Le]=d.useState(!1),j=e=>{De(e==="editTime"),Te(e==="percentage"),ke(e==="delete"),Pe(e==="regions"),Ee(e==="sources"),Le(e==="types")},Be=[{key:"crisis_maps",label:"Crisis Maps"},{key:"drone_images",label:"Drone Images"}],G=d.useCallback((e,r)=>{if(!e||!r)return 0;const s=e.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(l=>l.length>0),a=r.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(l=>l.length>0);if(s.length===0&&a.length===0)return 1;if(s.length===0||a.length===0)return 0;const n=new Set(s),o=new Set(a),g=new Set([...n].filter(l=>o.has(l))),y=new Set([...n,...o]);return g.size/y.size},[]),X=d.useCallback(async()=>{K(!0);try{const r=await(await fetch("/api/images")).json(),s={},a=r.filter(l=>l.image_type==="crisis_map"),n=r.filter(l=>l.image_type==="drone_image"),o={totalCaptions:r.length,sources:{},types:{},regions:{},models:{},modelEditTimes:s,percentageModified:0,modelPercentageData:{},totalDeleteCount:0,deleteRate:0,crisisMaps:a,droneImages:n};r.forEach(l=>{if(l.source&&(o.sources[l.source]=(o.sources[l.source]||0)+1),l.event_type&&(o.types[l.event_type]=(o.types[l.event_type]||0)+1),l.countries&&l.countries.forEach(m=>{m.r_code&&(o.regions[m.r_code]=(o.regions[m.r_code]||0)+1)}),l.model){const m=l.model,v=o.models[m]||={count:0,avgAccuracy:0,avgContext:0,avgUsability:0,totalScore:0,deleteCount:0};if(v.count++,l.accuracy!=null&&(v.avgAccuracy+=l.accuracy),l.context!=null&&(v.avgContext+=l.context),l.usability!=null&&(v.avgUsability+=l.usability),l.created_at&&l.updated_at){const S=new Date(l.created_at).getTime(),U=new Date(l.updated_at).getTime()-S;U>0&&(s[m]||(s[m]=[]),s[m].push(U))}}}),I.forEach(l=>{l.s_code&&!o.sources[l.s_code]&&(o.sources[l.s_code]=0)}),w.forEach(l=>{l.t_code&&!o.types[l.t_code]&&(o.types[l.t_code]=0)}),N.forEach(l=>{l.r_code&&!o.regions[l.r_code]&&(o.regions[l.r_code]=0)}),["GPT-4","Claude","Gemini","Llama","Other"].forEach(l=>{o.models[l]||(o.models[l]={count:0,avgAccuracy:0,avgContext:0,avgUsability:0,totalScore:0,deleteCount:0})}),Object.values(o.models).forEach(l=>{l.count>0&&(l.avgAccuracy=Math.round(l.avgAccuracy/l.count),l.avgContext=Math.round(l.avgContext/l.count),l.avgUsability=Math.round(l.avgUsability/l.count),l.totalScore=Math.round((l.avgAccuracy+l.avgContext+l.avgUsability)/3))});const y=r.filter(l=>l.generated&&l.edited);if(y.length>0){const m=[...y.map(L=>G(L.generated,L.edited))].sort((L,U)=>L-U),v=Math.floor(m.length/2),S=m.length%2===0?(m[v-1]+m[v])/2:m[v];o.percentageModified=Math.round((1-S)*100)}const x={};r.forEach(l=>{if(l.model&&l.generated&&l.edited){const m=G(l.generated,l.edited),v=Math.round((1-m)*100);x[l.model]||(x[l.model]=[]),x[l.model].push(v)}}),o.modelPercentageData=x;try{const l=await fetch("/api/models");if(l.ok){const m=await l.json();if(m.models){m.models.forEach(S=>{o.models[S.m_code]&&(o.models[S.m_code].deleteCount=S.delete_count||0)});const v=m.models.reduce((S,L)=>S+(L.delete_count||0),0);o.totalDeleteCount=v,o.deleteRate=v>0?Math.round(v/(v+r.length)*100):0}}}catch(l){console.log("Could not fetch model delete counts:",l)}q(o)}catch{q(null)}finally{K(!1)}},[I,w,N,G]),Y=d.useCallback(async()=>{try{const[e,r,s,a]=await Promise.all([fetch("/api/sources"),fetch("/api/types"),fetch("/api/regions"),fetch("/api/models")]),n=await e.json(),o=await r.json(),g=await s.json(),y=await a.json();Se(n),Ie(o),we(g),Ne(y.models||[])}catch(e){console.log("Could not fetch lookup data:",e)}},[]);d.useEffect(()=>{const e=z.get("view");(e==="crisis_maps"||e==="drone_images")&&J(e)},[z]),d.useEffect(()=>{Y()},[Y]),d.useEffect(()=>{I.length>0&&w.length>0&&N.length>0&&b.length>0&&X()},[I,w,N,b,X]);const O=d.useCallback(e=>{const r=I.find(s=>s.s_code===e);return r?r.label:e},[I]),B=d.useCallback(e=>{if(e.length===0)return 0;const r=[...e].sort((a,n)=>a-n),s=Math.floor(r.length/2);return r.length%2===0?Math.round((r[s-1]+r[s])/2):r[s]},[]),A=d.useCallback(e=>{const r=Math.floor(e/1e3),s=Math.floor(r/60),a=Math.floor(s/60);return a>0?`${a}h ${s%60}m`:s>0?`${s}m ${r%60}s`:`${r}s`},[]),Q=d.useCallback(e=>{const r=w.find(s=>s.t_code===e);return r?r.label:e},[w]),M=d.useCallback(e=>{const r=b.find(s=>s.m_code===e);return r?r.label:e},[b]),Z=d.useMemo(()=>c?Object.entries(c.modelEditTimes||{}).filter(([,e])=>e.length>0).sort(([,e],[,r])=>B(r)-B(e)).map(([e,r],s)=>({id:s+1,name:M(e),count:r.length,avgEditTime:B(r),minEditTime:Math.min(...r),maxEditTime:Math.max(...r)})):[],[c,B,M]),ee=d.useMemo(()=>c?Object.entries(c.modelPercentageData||{}).filter(([,e])=>e.length>0).sort(([,e],[,r])=>{const s=[...e].sort((x,l)=>x-l),a=[...r].sort((x,l)=>x-l),n=Math.floor(s.length/2),o=Math.floor(a.length/2),g=s.length%2===0?(s[n-1]+s[n])/2:s[n];return(a.length%2===0?(a[o-1]+a[o])/2:a[o])-g}).map(([e,r],s)=>{const a=[...r].sort((g,y)=>g-y),n=Math.floor(a.length/2),o=a.length%2===0?Math.round((a[n-1]+a[n])/2):a[n];return{id:s+1,name:M(e),count:r.length,avgPercentageModified:o,minPercentageModified:Math.min(...r),maxPercentageModified:Math.max(...r)}}):[],[c,M]),te=d.useMemo(()=>c?Object.entries(c.models).filter(([,e])=>e.count>0).map(([e,r],s)=>{const a=[r.avgAccuracy,r.avgContext,r.avgUsability],n=a.reduce((y,x)=>y+x,0)/a.length,o=a.reduce((y,x)=>y+Math.pow(x-n,2),0)/a.length,g=Math.round(100-Math.sqrt(o));return{id:s+1,name:M(e),consistency:Math.max(0,g),avgScore:Math.round(n),count:r.count}}).sort((e,r)=>r.consistency-e.consistency):[],[c,M]),ae=d.useMemo(()=>[C("name","Region",e=>e.name),u("count","Count",e=>e.count),u("percentage","% of Total",e=>e.percentage,{suffix:"%",maximumFractionDigits:0})],[]),se=d.useMemo(()=>[C("name","Type",e=>e.name),u("count","Count",e=>e.count),u("percentage","% of Total",e=>e.percentage,{suffix:"%",maximumFractionDigits:0})],[]),Ve=d.useMemo(()=>[C("name","Source",e=>e.name),u("count","Count",e=>e.count),u("percentage","% of Total",e=>e.percentage,{suffix:"%",maximumFractionDigits:0})],[]),ne=d.useMemo(()=>[C("name","Model",e=>e.name),u("count","Count",e=>e.count),u("accuracy","Accuracy",e=>e.accuracy,{suffix:"%",maximumFractionDigits:0}),u("context","Context",e=>e.context,{suffix:"%",maximumFractionDigits:0}),u("usability","Usability",e=>e.usability,{suffix:"%",maximumFractionDigits:0}),u("totalScore","Total Score",e=>e.totalScore,{suffix:"%",maximumFractionDigits:0})],[]),re=d.useMemo(()=>[C("name","Model",e=>e.name),u("count","Count",e=>e.count),C("avgEditTime","Median Edit Time",e=>A(e.avgEditTime)),C("minEditTime","Min Edit Time",e=>A(e.minEditTime)),C("maxEditTime","Max Edit Time",e=>A(e.maxEditTime))],[]),ie=d.useMemo(()=>[C("name","Model",e=>e.name),u("count","Count",e=>e.count),u("avgPercentageModified","Median % Modified",e=>e.avgPercentageModified,{suffix:"%",maximumFractionDigits:0}),u("minPercentageModified","Min % Modified",e=>e.minPercentageModified,{suffix:"%",maximumFractionDigits:0}),u("maxPercentageModified","Max % Modified",e=>e.maxPercentageModified,{suffix:"%",maximumFractionDigits:0})],[]),oe=d.useMemo(()=>[C("name","Model",e=>e.name),u("count","Total Count",e=>e.count),u("deleteCount","Delete Count",e=>e.deleteCount),u("deleteRate","Delete Rate",e=>e.deleteRate,{suffix:"%",maximumFractionDigits:1})],[]),Ae=d.useMemo(()=>[C("source","Source",e=>e.source),u("avgQuality","Average Quality",e=>e.avgQuality,{suffix:"%",maximumFractionDigits:0}),u("count","Count",e=>e.count)],[]),ce=d.useMemo(()=>[C("eventType","Event Type",e=>e.eventType),u("avgQuality","Average Quality",e=>e.avgQuality,{suffix:"%",maximumFractionDigits:0}),u("count","Count",e=>e.count)],[]),le=d.useMemo(()=>[C("name","Model",e=>e.name),u("consistency","Consistency",e=>e.consistency,{suffix:"%",maximumFractionDigits:0}),u("avgScore","Average Score",e=>e.avgScore,{suffix:"%",maximumFractionDigits:0}),u("count","Count",e=>e.count)],[]),V=d.useCallback(e=>c?e==="crisis_map"?c.crisisMaps.length:e==="drone_image"?c.droneImages.length:0:0,[c]),de=d.useCallback(e=>{if(!c)return[];const r=e==="crisis_map"?c.crisisMaps:c.droneImages,s={};return r.forEach(a=>{a.countries&&a.countries.forEach(n=>{n.r_code&&(s[n.r_code]=(s[n.r_code]||0)+1)})}),Object.entries(s).filter(([,a])=>a>0).map(([a,n])=>({name:N.find(o=>o.r_code===a)?.label||a,value:n}))},[c,N]),ue=d.useCallback(e=>{if(!c)return[];const r=e==="crisis_map"?c.crisisMaps:c.droneImages,s={};r.forEach(n=>{n.countries&&n.countries.forEach(o=>{o.r_code&&(s[o.r_code]=(s[o.r_code]||0)+1)})});const a=N.reduce((n,o)=>(o.r_code&&(n[o.r_code]={name:o.label,count:s[o.r_code]||0}),n),{});return Object.entries(a).sort(([,n],[,o])=>o.count-n.count).map(([,{name:n,count:o}],g)=>({id:g+1,name:n,count:o,percentage:r.length>0?Math.round(o/r.length*100):0}))},[c,N]),Re=d.useCallback(e=>{if(!c)return[];const r=e==="crisis_map"?c.crisisMaps:c.droneImages,s={};return r.forEach(a=>{a.source&&(s[a.source]=(s[a.source]||0)+1)}),Object.entries(s).filter(([,a])=>a>0).map(([a,n])=>({name:I.find(o=>o.s_code===a)?.label||a,value:n}))},[c,I]),Fe=d.useCallback(e=>{if(!c)return[];const r=e==="crisis_map"?c.crisisMaps:c.droneImages,s={};return r.forEach(a=>{a.source&&(s[a.source]=(s[a.source]||0)+1)}),Object.entries(s).sort(([,a],[,n])=>n-a).map(([a,n],o)=>({id:o+1,name:O(a),count:n,percentage:r.length>0?Math.round(n/r.length*100):0}))},[c,O]),me=d.useCallback(e=>{if(!c)return[];const r=e==="crisis_map"?c.crisisMaps:c.droneImages,s={};return r.forEach(a=>{a.event_type&&(s[a.event_type]=(s[a.event_type]||0)+1)}),Object.entries(s).filter(([,a])=>a>0).map(([a,n])=>({name:w.find(o=>o.t_code===a)?.label||a,value:n}))},[c,w]),ge=d.useCallback(e=>{if(!c)return[];const r=e==="crisis_map"?c.crisisMaps:c.droneImages,s={};return r.forEach(a=>{a.event_type&&(s[a.event_type]=(s[a.event_type]||0)+1)}),Object.entries(s).sort(([,a],[,n])=>n-a).map(([a,n],o)=>({id:o+1,name:Q(a),count:n,percentage:r.length>0?Math.round(n/r.length*100):0}))},[c,Q]),he=d.useCallback(e=>{if(!c)return"No data available";const r=e==="crisis_map"?c.crisisMaps:c.droneImages,s=new Set;r.forEach(o=>{o.model&&s.add(o.model)}),console.log(`Debug ${e}:`,{totalImages:r.length,usedModels:Array.from(s),availableEditTimes:Object.keys(c.modelEditTimes),modelEditTimesData:c.modelEditTimes});const n=Object.entries(c.modelEditTimes).filter(([o])=>s.has(o)).flatMap(([,o])=>o);return n.length===0?"No data available":A(B(n))},[c,A,B]),fe=d.useCallback(()=>{if(!c)return"No data available";const e=c.totalCaptions||0,r=c.percentageModified||0;return e>0?Math.round(r/e*100):0},[c]),ye=d.useCallback(()=>c&&c.deleteRate>=0?`${c.deleteRate}%`:"No data available",[c]),xe=d.useCallback(e=>{if(!c)return[];const r=e==="crisis_map"?c.crisisMaps:c.droneImages,s=new Set;return r.forEach(n=>{n.model&&s.add(n.model)}),Z.filter(n=>{const o=b.find(g=>g.label===n.name)?.m_code;return o&&s.has(o)})},[c,Z,b]),ve=d.useCallback(e=>{if(!c)return[];const r=e==="crisis_map"?c.crisisMaps:c.droneImages,s=new Set;return r.forEach(n=>{n.model&&s.add(n.model)}),ee.filter(n=>{const o=b.find(g=>g.label===n.name)?.m_code;return o&&s.has(o)})},[c,ee,b]),Ce=d.useCallback(e=>{if(!c)return[];const r=e==="crisis_map"?c.crisisMaps:c.droneImages,s={};return r.forEach(a=>{a.model&&(s[a.model]||(s[a.model]={count:0,deleteCount:0}),s[a.model].count++)}),Object.entries(s).map(([a,n],o)=>{const y=c.models?.[a]?.deleteCount||0,x=n.count>0?Math.round(y/n.count*100*10)/10:0;return{id:o+1,name:M(a),count:n.count,deleteCount:y,deleteRate:x}}).sort((a,n)=>n.count-a.count)},[c,M]),_e=d.useCallback(e=>{if(!c)return[];const r=e==="crisis_map"?c.crisisMaps:c.droneImages,s={};return r.forEach(a=>{a.model&&(s[a.model]||(s[a.model]={count:0,totalAccuracy:0,totalContext:0,totalUsability:0}),s[a.model].count++,a.accuracy!=null&&(s[a.model].totalAccuracy+=a.accuracy),a.context!=null&&(s[a.model].totalContext+=a.context),a.usability!=null&&(s[a.model].totalUsability+=a.usability))}),Object.entries(s).map(([a,n],o)=>({id:o+1,name:M(a),count:n.count,accuracy:n.count>0?Math.round(n.totalAccuracy/n.count):0,context:n.count>0?Math.round(n.totalContext/n.count):0,usability:n.count>0?Math.round(n.totalUsability/n.count):0,totalScore:n.count>0?Math.round((n.totalAccuracy+n.totalContext+n.totalUsability)/(3*n.count)):0})).sort((a,n)=>n.totalScore-a.totalScore)},[c,M]),He=d.useCallback(e=>{if(!c)return[];const r=e==="crisis_map"?c.crisisMaps:c.droneImages,s={};return r.forEach(a=>{a.source&&(s[a.source]||(s[a.source]={total:0,count:0,totalImages:0}),s[a.source].totalImages+=1,a.accuracy!=null&&(s[a.source].total+=a.accuracy,s[a.source].count+=1))}),Object.entries(s).map(([a,n],o)=>({id:o+1,source:O(a),avgQuality:n.count>0?Math.round(n.total/n.count):0,count:n.totalImages}))},[c,O]),je=d.useCallback(e=>{if(!c)return[];const r=e==="crisis_map"?c.crisisMaps:c.droneImages,s={};return r.forEach(a=>{a.event_type&&(s[a.event_type]||(s[a.event_type]={total:0,count:0,totalImages:0}),s[a.event_type].totalImages+=1,a.accuracy!=null&&(s[a.event_type].total+=a.accuracy,s[a.event_type].count+=1))}),Object.entries(s).map(([a,n],o)=>({id:o+1,eventType:Q(a),avgQuality:n.count>0?Math.round(n.total/n.count):0,count:n.totalImages}))},[c,Q]),pe=d.useCallback(e=>{if(!c)return[];const r=e==="crisis_map"?c.crisisMaps:c.droneImages,s=new Set;return r.forEach(n=>{n.model&&s.add(n.model)}),te.filter(n=>{const o=b.find(g=>g.label===n.name)?.m_code;return o&&s.has(o)})},[c,te,b]);if(Me)return t.jsx($,{children:t.jsx("div",{className:i.loadingContainer,children:t.jsx(Qe,{})})});if(!c)return t.jsx($,{children:t.jsx("div",{className:i.errorContainer,children:t.jsx("div",{className:"text-red-500",children:"Failed to load analytics data. Please try again."})})});const R=["#F5333F","#F64752","#F75C65","#F87079","#F9858C","#FA999F","#FBADB2","#FCC2C5"];return t.jsx($,{children:t.jsxs("div",{className:"max-w-7xl mx-auto",children:[t.jsx("div",{className:i.tabSelector,children:t.jsx(Ue,{name:"analytics-view",value:W,onChange:e=>{(e==="crisis_maps"||e==="drone_images")&&J(e)},options:Be,keySelector:e=>e.key,labelSelector:e=>e.label})}),W==="crisis_maps"?t.jsxs("div",{className:i.chartGrid,children:[t.jsxs(_,{heading:"Summary Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[t.jsxs("div",{className:i.summaryStatsCards,children:[t.jsxs("div",{className:i.summaryStatsCard,children:[t.jsx("div",{className:i.summaryStatsCardValue,children:V("crisis_map")}),t.jsx("div",{className:i.summaryStatsCardLabel,children:"Total Crisis Maps"})]}),t.jsxs("div",{className:i.summaryStatsCard,children:[t.jsx("div",{className:i.summaryStatsCardValue,children:"2000"}),t.jsx("div",{className:i.summaryStatsCardLabel,children:"Target Amount"})]})]}),t.jsxs("div",{className:i.progressSection,children:[t.jsxs("div",{className:i.progressLabel,children:[t.jsx("span",{children:"Progress towards target"}),t.jsxs("span",{children:[Math.round(V("crisis_map")/2e3*100),"%"]})]}),t.jsx(be,{value:V("crisis_map"),totalValue:2e3})]})]}),t.jsxs(_,{heading:"Distribution Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[t.jsxs("div",{className:i.userInteractionCards,children:[t.jsxs("div",{className:i.userInteractionCard,children:[t.jsx("div",{className:i.userInteractionCardLabel,children:"Regions Distribution"}),t.jsx("div",{className:i.chartContainer,children:t.jsx(F,{data:de("crisis_map"),valueSelector:e=>e.value,labelSelector:e=>e.name,keySelector:e=>e.name,colors:R,showPercentageInLegend:!0})}),t.jsx(p,{name:"view-regions-details",variant:P?"primary":"secondary",onClick:()=>j(P?"none":"regions"),className:i.userInteractionCardButton,children:P?"Hide Details":"View Details"})]}),t.jsxs("div",{className:i.userInteractionCard,children:[t.jsx("div",{className:i.userInteractionCardLabel,children:"Sources Distribution"}),t.jsx("div",{className:i.chartContainer,children:t.jsx(F,{data:Re("crisis_map"),valueSelector:e=>e.value,labelSelector:e=>e.name,keySelector:e=>e.name,colors:R,showPercentageInLegend:!0})}),t.jsx(p,{name:"view-sources-details",variant:H?"primary":"secondary",onClick:()=>j(H?"none":"sources"),className:i.userInteractionCardButton,children:H?"Hide Details":"View Details"})]}),t.jsxs("div",{className:i.userInteractionCard,children:[t.jsx("div",{className:i.userInteractionCardLabel,children:"Types Distribution"}),t.jsx("div",{className:i.chartContainer,children:t.jsx(F,{data:me("crisis_map"),valueSelector:e=>e.value,labelSelector:e=>e.name,keySelector:e=>e.name,colors:R,showPercentageInLegend:!0})}),t.jsx(p,{name:"view-types-details",variant:E?"primary":"secondary",onClick:()=>j(E?"none":"types"),className:i.userInteractionCardButton,children:E?"Hide Details":"View Details"})]})]}),P&&t.jsx("div",{className:i.modelPerformance,children:t.jsx(h,{data:ue("crisis_map"),columns:ae,keySelector:f,filtered:!1,pending:!1})}),H&&t.jsx("div",{className:i.modelPerformance,children:t.jsx(h,{data:Fe("crisis_map"),columns:Ve,keySelector:f,filtered:!1,pending:!1})}),E&&t.jsx("div",{className:i.modelPerformance,children:t.jsx(h,{data:ge("crisis_map"),columns:se,keySelector:f,filtered:!1,pending:!1})})]}),t.jsxs(_,{heading:"User Interaction Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[t.jsxs("div",{className:i.userInteractionCards,children:[t.jsxs("div",{className:i.userInteractionCard,children:[t.jsx("div",{className:i.userInteractionCardValue,children:he("crisis_map")}),t.jsx("div",{className:i.userInteractionCardLabel,children:"Median Edit Time"}),t.jsx(p,{name:"view-edit-time-details",variant:D?"primary":"secondary",onClick:()=>j(D?"none":"editTime"),className:i.userInteractionCardButton,children:D?"Hide Details":"View Details"})]}),t.jsxs("div",{className:i.userInteractionCard,children:[t.jsx("div",{className:i.userInteractionCardValue,children:fe()}),t.jsx("div",{className:i.userInteractionCardLabel,children:"Median % Modified"}),t.jsx(p,{name:"view-percentage-details",variant:T?"primary":"secondary",onClick:()=>j(T?"none":"percentage"),className:i.userInteractionCardButton,children:T?"Hide Details":"View Details"})]}),t.jsxs("div",{className:i.userInteractionCard,children:[t.jsx("div",{className:i.userInteractionCardValue,children:ye()}),t.jsx("div",{className:i.userInteractionCardLabel,children:"Delete Rate"}),t.jsx(p,{name:"view-delete-details",variant:k?"primary":"secondary",onClick:()=>j(k?"none":"delete"),className:i.userInteractionCardButton,children:k?"Hide Details":"View Details"})]})]}),D&&t.jsx("div",{className:i.modelPerformance,children:t.jsx(h,{data:xe("crisis_map"),columns:re,keySelector:f,filtered:!1,pending:!1})}),T&&t.jsx("div",{className:i.modelPerformance,children:t.jsx(h,{data:ve("crisis_map"),columns:ie,keySelector:f,filtered:!1,pending:!1})}),k&&t.jsx("div",{className:i.modelPerformance,children:t.jsx(h,{data:Ce("crisis_map"),columns:oe,keySelector:f,filtered:!1,pending:!1})})]}),t.jsx(_,{heading:"Model Performance",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:t.jsx("div",{className:i.modelPerformance,children:t.jsx(h,{data:_e("crisis_map"),columns:ne,keySelector:f,filtered:!1,pending:!1})})}),t.jsx(_,{heading:"Quality-Source Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:t.jsx("div",{className:i.tableContainer,children:t.jsx(h,{data:He("crisis_map"),columns:Ae,keySelector:f,filtered:!1,pending:!1})})}),t.jsx(_,{heading:"Quality-Event Type Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:t.jsx("div",{className:i.tableContainer,children:t.jsx(h,{data:je("crisis_map"),columns:ce,keySelector:f,filtered:!1,pending:!1})})}),t.jsx(_,{heading:"Model Consistency Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:t.jsx("div",{className:i.tableContainer,children:t.jsx(h,{data:pe("crisis_map"),columns:le,keySelector:f,filtered:!1,pending:!1})})})]}):t.jsxs("div",{className:i.chartGrid,children:[t.jsxs(_,{heading:"Summary Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[t.jsxs("div",{className:i.summaryStatsCards,children:[t.jsxs("div",{className:i.summaryStatsCard,children:[t.jsx("div",{className:i.summaryStatsCardValue,children:V("drone_image")}),t.jsx("div",{className:i.summaryStatsCardLabel,children:"Total Drone Images"})]}),t.jsxs("div",{className:i.summaryStatsCard,children:[t.jsx("div",{className:i.summaryStatsCardValue,children:"2000"}),t.jsx("div",{className:i.summaryStatsCardLabel,children:"Target Amount"})]})]}),t.jsxs("div",{className:i.progressSection,children:[t.jsxs("div",{className:i.progressLabel,children:[t.jsx("span",{children:"Progress towards target"}),t.jsxs("span",{children:[Math.round(V("drone_image")/2e3*100),"%"]})]}),t.jsx(be,{value:V("drone_image"),totalValue:2e3})]})]}),t.jsxs(_,{heading:"Distribution Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[t.jsxs("div",{className:i.userInteractionCards,children:[t.jsxs("div",{className:i.userInteractionCard,children:[t.jsx("div",{className:i.userInteractionCardLabel,children:"Regions Distribution"}),t.jsx("div",{className:i.chartContainer,children:t.jsx(F,{data:de("drone_image"),valueSelector:e=>e.value,labelSelector:e=>e.name,keySelector:e=>e.name,colors:R,showPercentageInLegend:!0})}),t.jsx(p,{name:"view-regions-details",variant:P?"primary":"secondary",onClick:()=>j(P?"none":"regions"),className:i.userInteractionCardButton,children:P?"Hide Details":"View Details"})]}),t.jsxs("div",{className:i.userInteractionCard,children:[t.jsx("div",{className:i.userInteractionCardLabel,children:"Types Distribution"}),t.jsx("div",{className:i.chartContainer,children:t.jsx(F,{data:me("drone_image"),valueSelector:e=>e.value,labelSelector:e=>e.name,keySelector:e=>e.name,colors:R,showPercentageInLegend:!0})}),t.jsx(p,{name:"view-types-details",variant:E?"primary":"secondary",onClick:()=>j(E?"none":"types"),className:i.userInteractionCardButton,children:E?"Hide Details":"View Details"})]})]}),P&&t.jsx("div",{className:i.modelPerformance,children:t.jsx(h,{data:ue("drone_image"),columns:ae,keySelector:f,filtered:!1,pending:!1})}),E&&t.jsx("div",{className:i.modelPerformance,children:t.jsx(h,{data:ge("drone_image"),columns:se,keySelector:f,filtered:!1,pending:!1})})]}),t.jsxs(_,{heading:"User Interaction Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[t.jsxs("div",{className:i.userInteractionCards,children:[t.jsxs("div",{className:i.userInteractionCard,children:[t.jsx("div",{className:i.userInteractionCardValue,children:he("drone_image")}),t.jsx("div",{className:i.userInteractionCardLabel,children:"Median Edit Time"}),t.jsx(p,{name:"view-edit-time-details",variant:D?"primary":"secondary",onClick:()=>j(D?"none":"editTime"),className:i.userInteractionCardButton,children:D?"Hide Details":"View Details"})]}),t.jsxs("div",{className:i.userInteractionCard,children:[t.jsx("div",{className:i.userInteractionCardValue,children:fe()}),t.jsx("div",{className:i.userInteractionCardLabel,children:"Median % Modified"}),t.jsx(p,{name:"view-percentage-details",variant:T?"primary":"secondary",onClick:()=>j(T?"none":"percentage"),className:i.userInteractionCardButton,children:T?"Hide Details":"View Details"})]}),t.jsxs("div",{className:i.userInteractionCard,children:[t.jsx("div",{className:i.userInteractionCardValue,children:ye()}),t.jsx("div",{className:i.userInteractionCardLabel,children:"Delete Rate"}),t.jsx(p,{name:"view-delete-details",variant:k?"primary":"secondary",onClick:()=>j(k?"none":"delete"),className:i.userInteractionCardButton,children:k?"Hide Details":"View Details"})]})]}),D&&t.jsx("div",{className:i.modelPerformance,children:t.jsx(h,{data:xe("drone_image"),columns:re,keySelector:f,filtered:!1,pending:!1})}),T&&t.jsx("div",{className:i.modelPerformance,children:t.jsx(h,{data:ve("drone_image"),columns:ie,keySelector:f,filtered:!1,pending:!1})}),k&&t.jsx("div",{className:i.modelPerformance,children:t.jsx(h,{data:Ce("drone_image"),columns:oe,keySelector:f,filtered:!1,pending:!1})})]}),t.jsx(_,{heading:"Model Performance",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:t.jsx("div",{className:i.modelPerformance,children:t.jsx(h,{data:_e("drone_image"),columns:ne,keySelector:f,filtered:!1,pending:!1})})}),t.jsx(_,{heading:"Quality-Event Type Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:t.jsx("div",{className:i.tableContainer,children:t.jsx(h,{data:je("drone_image"),columns:ce,keySelector:f,filtered:!1,pending:!1})})}),t.jsx(_,{heading:"Model Consistency Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:t.jsx("div",{className:i.tableContainer,children:t.jsx(h,{data:pe("drone_image"),columns:le,keySelector:f,filtered:!1,pending:!1})})})]})]})})}export{ut as default};
py_backend/static/assets/useAdmin-6S8boYmH.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{r}from"./vendor-react-BxsGb6Ph.js";import{A as o}from"./index-C6NSRolP.js";const i=()=>{const t=r.useContext(o);if(t===void 0)throw new Error("useAdmin must be used within an AdminProvider");return t};export{i as u};
py_backend/static/assets/vendor-DxpCibxB.js ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{r as C}from"./vendor-react-BxsGb6Ph.js";var na=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function aa(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var pt={exports:{}},vt={};/**
2
+ * @license React
3
+ * scheduler.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Vt;function zr(){return Vt||(Vt=1,function(e){function t(y,L){var U=y.length;y.push(L);e:for(;0<U;){var H=U-1>>>1,W=y[H];if(0<a(W,L))y[H]=L,y[U]=W,U=H;else break e}}function r(y){return y.length===0?null:y[0]}function n(y){if(y.length===0)return null;var L=y[0],U=y.pop();if(U!==L){y[0]=U;e:for(var H=0,W=y.length,fe=W>>>1;H<fe;){var ue=2*(H+1)-1,ie=y[ue],oe=ue+1,ce=y[oe];if(0>a(ie,U))oe<W&&0>a(ce,ie)?(y[H]=ce,y[oe]=U,H=oe):(y[H]=ie,y[ue]=U,H=ue);else if(oe<W&&0>a(ce,U))y[H]=ce,y[oe]=U,H=oe;else break e}}return L}function a(y,L){var U=y.sortIndex-L.sortIndex;return U!==0?U:y.id-L.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var o=Date,c=o.now();e.unstable_now=function(){return o.now()-c}}var s=[],m=[],v=1,f=null,g=3,w=!1,S=!1,R=!1,_=typeof setTimeout=="function"?setTimeout:null,z=typeof clearTimeout=="function"?clearTimeout:null,F=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function G(y){for(var L=r(m);L!==null;){if(L.callback===null)n(m);else if(L.startTime<=y)n(m),L.sortIndex=L.expirationTime,t(s,L);else break;L=r(m)}}function re(y){if(R=!1,G(y),!S)if(r(s)!==null)S=!0,Re(Z);else{var L=r(m);L!==null&&Pe(re,L.startTime-y)}}function Z(y,L){S=!1,R&&(R=!1,z(B),B=-1),w=!0;var U=g;try{for(G(L),f=r(s);f!==null&&(!(f.expirationTime>L)||y&&!ne());){var H=f.callback;if(typeof H=="function"){f.callback=null,g=f.priorityLevel;var W=H(f.expirationTime<=L);L=e.unstable_now(),typeof W=="function"?f.callback=W:f===r(s)&&n(s),G(L)}else n(s);f=r(s)}if(f!==null)var fe=!0;else{var ue=r(m);ue!==null&&Pe(re,ue.startTime-L),fe=!1}return fe}finally{f=null,g=U,w=!1}}var me=!1,h=null,B=-1,Q=5,V=-1;function ne(){return!(e.unstable_now()-V<Q)}function ae(){if(h!==null){var y=e.unstable_now();V=y;var L=!0;try{L=h(!0,y)}finally{L?ee():(me=!1,h=null)}}else me=!1}var ee;if(typeof F=="function")ee=function(){F(ae)};else if(typeof MessageChannel<"u"){var ve=new MessageChannel,ge=ve.port2;ve.port1.onmessage=ae,ee=function(){ge.postMessage(null)}}else ee=function(){_(ae,0)};function Re(y){h=y,me||(me=!0,ee())}function Pe(y,L){B=_(function(){y(e.unstable_now())},L)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(y){y.callback=null},e.unstable_continueExecution=function(){S||w||(S=!0,Re(Z))},e.unstable_forceFrameRate=function(y){0>y||125<y?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Q=0<y?Math.floor(1e3/y):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return r(s)},e.unstable_next=function(y){switch(g){case 1:case 2:case 3:var L=3;break;default:L=g}var U=g;g=L;try{return y()}finally{g=U}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(y,L){switch(y){case 1:case 2:case 3:case 4:case 5:break;default:y=3}var U=g;g=y;try{return L()}finally{g=U}},e.unstable_scheduleCallback=function(y,L,U){var H=e.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?H+U:H):U=H,y){case 1:var W=-1;break;case 2:W=250;break;case 5:W=1073741823;break;case 4:W=1e4;break;default:W=5e3}return W=U+W,y={id:v++,callback:L,priorityLevel:y,startTime:U,expirationTime:W,sortIndex:-1},U>H?(y.sortIndex=U,t(m,y),r(s)===null&&y===r(m)&&(R?(z(B),B=-1):R=!0,Pe(re,U-H))):(y.sortIndex=W,t(s,y),S||w||(S=!0,Re(Z))),y},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(y){var L=g;return function(){var U=g;g=L;try{return y.apply(this,arguments)}finally{g=U}}}}(vt)),vt}var $t;function ia(){return $t||($t=1,pt.exports=zr()),pt.exports}/**
10
+ * @remix-run/router v1.23.0
11
+ *
12
+ * Copyright (c) Remix Software Inc.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE.md file in the root directory of this source tree.
16
+ *
17
+ * @license MIT
18
+ */function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},J.apply(this,arguments)}var q;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(q||(q={}));const Jt="popstate";function oa(e){e===void 0&&(e={});function t(n,a){let{pathname:u,search:o,hash:c}=n.location;return Ge("",{pathname:u,search:o,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function r(n,a){return typeof a=="string"?a:qe(a)}return Wr(t,r,null,e)}function N(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function ke(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Hr(){return Math.random().toString(36).substr(2,8)}function Kt(e,t){return{usr:e.state,key:e.key,idx:t}}function Ge(e,t,r,n){return r===void 0&&(r=null),J({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?Ce(t):t,{state:r,key:t&&t.key||n||Hr()})}function qe(e){let{pathname:t="/",search:r="",hash:n=""}=e;return r&&r!=="?"&&(t+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function Ce(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substr(r),e=e.substr(0,r));let n=e.indexOf("?");n>=0&&(t.search=e.substr(n),e=e.substr(0,n)),e&&(t.pathname=e)}return t}function Wr(e,t,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:u=!1}=n,o=a.history,c=q.Pop,s=null,m=v();m==null&&(m=0,o.replaceState(J({},o.state,{idx:m}),""));function v(){return(o.state||{idx:null}).idx}function f(){c=q.Pop;let _=v(),z=_==null?null:_-m;m=_,s&&s({action:c,location:R.location,delta:z})}function g(_,z){c=q.Push;let F=Ge(R.location,_,z);m=v()+1;let G=Kt(F,m),re=R.createHref(F);try{o.pushState(G,"",re)}catch(Z){if(Z instanceof DOMException&&Z.name==="DataCloneError")throw Z;a.location.assign(re)}u&&s&&s({action:c,location:R.location,delta:1})}function w(_,z){c=q.Replace;let F=Ge(R.location,_,z);m=v();let G=Kt(F,m),re=R.createHref(F);o.replaceState(G,"",re),u&&s&&s({action:c,location:R.location,delta:0})}function S(_){let z=a.location.origin!=="null"?a.location.origin:a.location.href,F=typeof _=="string"?_:qe(_);return F=F.replace(/ $/,"%20"),N(z,"No window.location.(origin|href) available to create URL for href: "+F),new URL(F,z)}let R={get action(){return c},get location(){return e(a,o)},listen(_){if(s)throw new Error("A history only accepts one active listener");return a.addEventListener(Jt,f),s=_,()=>{a.removeEventListener(Jt,f),s=null}},createHref(_){return t(a,_)},createURL:S,encodeLocation(_){let z=S(_);return{pathname:z.pathname,search:z.search,hash:z.hash}},push:g,replace:w,go(_){return o.go(_)}};return R}var k;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(k||(k={}));const Vr=new Set(["lazy","caseSensitive","path","id","index","children"]);function $r(e){return e.index===!0}function ut(e,t,r,n){return r===void 0&&(r=[]),n===void 0&&(n={}),e.map((a,u)=>{let o=[...r,String(u)],c=typeof a.id=="string"?a.id:o.join("-");if(N(a.index!==!0||!a.children,"Cannot specify children on an index route"),N(!n[c],'Found a route id collision on id "'+c+`". Route id's must be globally unique within Data Router usages`),$r(a)){let s=J({},a,t(a),{id:c});return n[c]=s,s}else{let s=J({},a,t(a),{id:c,children:void 0});return n[c]=s,a.children&&(s.children=ut(a.children,t,o,n)),s}})}function Ue(e,t,r){return r===void 0&&(r="/"),st(e,t,r,!1)}function st(e,t,r,n){let a=typeof t=="string"?Ce(t):t,u=Qe(a.pathname||"/",r);if(u==null)return null;let o=dr(e);Kr(o);let c=null;for(let s=0;c==null&&s<o.length;++s){let m=an(u);c=rn(o[s],m,n)}return c}function Jr(e,t){let{route:r,pathname:n,params:a}=e;return{id:r.id,pathname:n,params:a,data:t[r.id],handle:r.handle}}function dr(e,t,r,n){t===void 0&&(t=[]),r===void 0&&(r=[]),n===void 0&&(n="");let a=(u,o,c)=>{let s={relativePath:c===void 0?u.path||"":c,caseSensitive:u.caseSensitive===!0,childrenIndex:o,route:u};s.relativePath.startsWith("/")&&(N(s.relativePath.startsWith(n),'Absolute route path "'+s.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),s.relativePath=s.relativePath.slice(n.length));let m=we([n,s.relativePath]),v=r.concat(s);u.children&&u.children.length>0&&(N(u.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+m+'".')),dr(u.children,t,v,m)),!(u.path==null&&!u.index)&&t.push({path:m,score:en(m,u.index),routesMeta:v})};return e.forEach((u,o)=>{var c;if(u.path===""||!((c=u.path)!=null&&c.includes("?")))a(u,o);else for(let s of cr(u.path))a(u,o,s)}),t}function cr(e){let t=e.split("/");if(t.length===0)return[];let[r,...n]=t,a=r.endsWith("?"),u=r.replace(/\?$/,"");if(n.length===0)return a?[u,""]:[u];let o=cr(n.join("/")),c=[];return c.push(...o.map(s=>s===""?u:[u,s].join("/"))),a&&c.push(...o),c.map(s=>e.startsWith("/")&&s===""?"/":s)}function Kr(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:tn(t.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const Yr=/^:[\w-]+$/,Gr=3,Xr=2,qr=1,Qr=10,Zr=-2,Yt=e=>e==="*";function en(e,t){let r=e.split("/"),n=r.length;return r.some(Yt)&&(n+=Zr),t&&(n+=Xr),r.filter(a=>!Yt(a)).reduce((a,u)=>a+(Yr.test(u)?Gr:u===""?qr:Qr),n)}function tn(e,t){return e.length===t.length&&e.slice(0,-1).every((n,a)=>n===t[a])?e[e.length-1]-t[t.length-1]:0}function rn(e,t,r){r===void 0&&(r=!1);let{routesMeta:n}=e,a={},u="/",o=[];for(let c=0;c<n.length;++c){let s=n[c],m=c===n.length-1,v=u==="/"?t:t.slice(u.length)||"/",f=Gt({path:s.relativePath,caseSensitive:s.caseSensitive,end:m},v),g=s.route;if(!f&&m&&r&&!n[n.length-1].route.index&&(f=Gt({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},v)),!f)return null;Object.assign(a,f.params),o.push({params:a,pathname:we([u,f.pathname]),pathnameBase:sn(we([u,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(u=we([u,f.pathnameBase]))}return o}function Gt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,n]=nn(e.path,e.caseSensitive,e.end),a=t.match(r);if(!a)return null;let u=a[0],o=u.replace(/(.)\/+$/,"$1"),c=a.slice(1);return{params:n.reduce((m,v,f)=>{let{paramName:g,isOptional:w}=v;if(g==="*"){let R=c[f]||"";o=u.slice(0,u.length-R.length).replace(/(.)\/+$/,"$1")}const S=c[f];return w&&!S?m[g]=void 0:m[g]=(S||"").replace(/%2F/g,"/"),m},{}),pathname:u,pathnameBase:o,pattern:e}}function nn(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!0),ke(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let n=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,c,s)=>(n.push({paramName:c,isOptional:s!=null}),s?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(n.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),n]}function an(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return ke(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Qe(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&n!=="/"?null:e.slice(r)||"/"}function on(e,t){t===void 0&&(t="/");let{pathname:r,search:n="",hash:a=""}=typeof e=="string"?Ce(e):e;return{pathname:r?r.startsWith("/")?r:ln(r,t):t,search:un(n),hash:dn(a)}}function ln(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function gt(e,t,r,n){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function fr(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function Dt(e,t){let r=fr(e);return t?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function xt(e,t,r,n){n===void 0&&(n=!1);let a;typeof e=="string"?a=Ce(e):(a=J({},e),N(!a.pathname||!a.pathname.includes("?"),gt("?","pathname","search",a)),N(!a.pathname||!a.pathname.includes("#"),gt("#","pathname","hash",a)),N(!a.search||!a.search.includes("#"),gt("#","search","hash",a)));let u=e===""||a.pathname==="",o=u?"/":a.pathname,c;if(o==null)c=r;else{let f=t.length-1;if(!n&&o.startsWith("..")){let g=o.split("/");for(;g[0]==="..";)g.shift(),f-=1;a.pathname=g.join("/")}c=f>=0?t[f]:"/"}let s=on(a,c),m=o&&o!=="/"&&o.endsWith("/"),v=(u||o===".")&&r.endsWith("/");return!s.pathname.endsWith("/")&&(m||v)&&(s.pathname+="/"),s}const we=e=>e.join("/").replace(/\/\/+/g,"/"),sn=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),un=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,dn=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;class wt{constructor(t,r,n,a){a===void 0&&(a=!1),this.status=t,this.statusText=r||"",this.internal=a,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}}function Xe(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const hr=["post","put","patch","delete"],cn=new Set(hr),fn=["get",...hr],hn=new Set(fn),mn=new Set([301,302,303,307,308]),pn=new Set([307,308]),yt={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},vn={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Je={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},St=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,gn=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),mr="remix-router-transitions";function la(e){const t=e.window?e.window:typeof window<"u"?window:void 0,r=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u",n=!r;N(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let a;if(e.mapRouteProperties)a=e.mapRouteProperties;else if(e.detectErrorBoundary){let i=e.detectErrorBoundary;a=l=>({hasErrorBoundary:i(l)})}else a=gn;let u={},o=ut(e.routes,a,void 0,u),c,s=e.basename||"/",m=e.dataStrategy||En,v=e.patchRoutesOnNavigation,f=J({v7_fetcherPersist:!1,v7_normalizeFormMethod:!1,v7_partialHydration:!1,v7_prependBasename:!1,v7_relativeSplatPath:!1,v7_skipActionErrorRevalidation:!1},e.future),g=null,w=new Set,S=null,R=null,_=null,z=e.hydrationData!=null,F=Ue(o,e.history.location,s),G=!1,re=null;if(F==null&&!v){let i=se(404,{pathname:e.history.location.pathname}),{matches:l,route:d}=or(o);F=l,re={[d.id]:i}}F&&!e.hydrationData&&nt(F,o,e.history.location.pathname).active&&(F=null);let Z;if(F)if(F.some(i=>i.route.lazy))Z=!1;else if(!F.some(i=>i.route.loader))Z=!0;else if(f.v7_partialHydration){let i=e.hydrationData?e.hydrationData.loaderData:null,l=e.hydrationData?e.hydrationData.errors:null;if(l){let d=F.findIndex(p=>l[p.route.id]!==void 0);Z=F.slice(0,d+1).every(p=>!Rt(p.route,i,l))}else Z=F.every(d=>!Rt(d.route,i,l))}else Z=e.hydrationData!=null;else if(Z=!1,F=[],f.v7_partialHydration){let i=nt(null,o,e.history.location.pathname);i.active&&i.matches&&(G=!0,F=i.matches)}let me,h={historyAction:e.history.action,location:e.history.location,matches:F,initialized:Z,navigation:yt,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||re,fetchers:new Map,blockers:new Map},B=q.Pop,Q=!1,V,ne=!1,ae=new Map,ee=null,ve=!1,ge=!1,Re=[],Pe=new Set,y=new Map,L=0,U=-1,H=new Map,W=new Set,fe=new Map,ue=new Map,ie=new Set,oe=new Map,ce=new Map,et;function Dr(){if(g=e.history.listen(i=>{let{action:l,location:d,delta:p}=i;if(et){et(),et=void 0;return}ke(ce.size===0||p!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let b=kt({currentLocation:h.location,nextLocation:d,historyAction:l});if(b&&p!=null){let M=new Promise(T=>{et=T});e.history.go(p*-1),rt(b,{state:"blocked",location:d,proceed(){rt(b,{state:"proceeding",proceed:void 0,reset:void 0,location:d}),M.then(()=>e.history.go(p))},reset(){let T=new Map(h.blockers);T.set(b,Je),le({blockers:T})}});return}return Le(l,d)}),r){Nn(t,ae);let i=()=>jn(t,ae);t.addEventListener("pagehide",i),ee=()=>t.removeEventListener("pagehide",i)}return h.initialized||Le(q.Pop,h.location,{initialHydration:!0}),me}function xr(){g&&g(),ee&&ee(),w.clear(),V&&V.abort(),h.fetchers.forEach((i,l)=>tt(l)),h.blockers.forEach((i,l)=>Bt(l))}function Sr(i){return w.add(i),()=>w.delete(i)}function le(i,l){l===void 0&&(l={}),h=J({},h,i);let d=[],p=[];f.v7_fetcherPersist&&h.fetchers.forEach((b,M)=>{b.state==="idle"&&(ie.has(M)?p.push(M):d.push(M))}),ie.forEach(b=>{!h.fetchers.has(b)&&!y.has(b)&&p.push(b)}),[...w].forEach(b=>b(h,{deletedFetchers:p,viewTransitionOpts:l.viewTransitionOpts,flushSync:l.flushSync===!0})),f.v7_fetcherPersist?(d.forEach(b=>h.fetchers.delete(b)),p.forEach(b=>tt(b))):p.forEach(b=>ie.delete(b))}function Ne(i,l,d){var p,b;let{flushSync:M}=d===void 0?{}:d,T=h.actionData!=null&&h.navigation.formMethod!=null&&he(h.navigation.formMethod)&&h.navigation.state==="loading"&&((p=i.state)==null?void 0:p._isRedirect)!==!0,P;l.actionData?Object.keys(l.actionData).length>0?P=l.actionData:P=null:T?P=h.actionData:P=null;let D=l.loaderData?ar(h.loaderData,l.loaderData,l.matches||[],l.errors):h.loaderData,E=h.blockers;E.size>0&&(E=new Map(E),E.forEach((j,te)=>E.set(te,Je)));let x=Q===!0||h.navigation.formMethod!=null&&he(h.navigation.formMethod)&&((b=i.state)==null?void 0:b._isRedirect)!==!0;c&&(o=c,c=void 0),ve||B===q.Pop||(B===q.Push?e.history.push(i,i.state):B===q.Replace&&e.history.replace(i,i.state));let I;if(B===q.Pop){let j=ae.get(h.location.pathname);j&&j.has(i.pathname)?I={currentLocation:h.location,nextLocation:i}:ae.has(i.pathname)&&(I={currentLocation:i,nextLocation:h.location})}else if(ne){let j=ae.get(h.location.pathname);j?j.add(i.pathname):(j=new Set([i.pathname]),ae.set(h.location.pathname,j)),I={currentLocation:h.location,nextLocation:i}}le(J({},l,{actionData:P,loaderData:D,historyAction:B,location:i,initialized:!0,navigation:yt,revalidation:"idle",restoreScrollPosition:Ht(i,l.matches||h.matches),preventScrollReset:x,blockers:E}),{viewTransitionOpts:I,flushSync:M===!0}),B=q.Pop,Q=!1,ne=!1,ve=!1,ge=!1,Re=[]}async function Ut(i,l){if(typeof i=="number"){e.history.go(i);return}let d=Et(h.location,h.matches,s,f.v7_prependBasename,i,f.v7_relativeSplatPath,l?.fromRouteId,l?.relative),{path:p,submission:b,error:M}=Xt(f.v7_normalizeFormMethod,!1,d,l),T=h.location,P=Ge(h.location,p,l&&l.state);P=J({},P,e.history.encodeLocation(P));let D=l&&l.replace!=null?l.replace:void 0,E=q.Push;D===!0?E=q.Replace:D===!1||b!=null&&he(b.formMethod)&&b.formAction===h.location.pathname+h.location.search&&(E=q.Replace);let x=l&&"preventScrollReset"in l?l.preventScrollReset===!0:void 0,I=(l&&l.flushSync)===!0,j=kt({currentLocation:T,nextLocation:P,historyAction:E});if(j){rt(j,{state:"blocked",location:P,proceed(){rt(j,{state:"proceeding",proceed:void 0,reset:void 0,location:P}),Ut(i,l)},reset(){let te=new Map(h.blockers);te.set(j,Je),le({blockers:te})}});return}return await Le(E,P,{submission:b,pendingError:M,preventScrollReset:x,replace:l&&l.replace,enableViewTransition:l&&l.viewTransition,flushSync:I})}function Mr(){if(ct(),le({revalidation:"loading"}),h.navigation.state!=="submitting"){if(h.navigation.state==="idle"){Le(h.historyAction,h.location,{startUninterruptedRevalidation:!0});return}Le(B||h.historyAction,h.navigation.location,{overrideNavigation:h.navigation,enableViewTransition:ne===!0})}}async function Le(i,l,d){V&&V.abort(),V=null,B=i,ve=(d&&d.startUninterruptedRevalidation)===!0,Or(h.location,h.matches),Q=(d&&d.preventScrollReset)===!0,ne=(d&&d.enableViewTransition)===!0;let p=c||o,b=d&&d.overrideNavigation,M=d!=null&&d.initialHydration&&h.matches&&h.matches.length>0&&!G?h.matches:Ue(p,l,s),T=(d&&d.flushSync)===!0;if(M&&h.initialized&&!ge&&Mn(h.location,l)&&!(d&&d.submission&&he(d.submission.formMethod))){Ne(l,{matches:M},{flushSync:T});return}let P=nt(M,p,l.pathname);if(P.active&&P.matches&&(M=P.matches),!M){let{error:$,notFoundMatches:A,route:K}=ft(l.pathname);Ne(l,{matches:A,loaderData:{},errors:{[K.id]:$}},{flushSync:T});return}V=new AbortController;let D=Be(e.history,l,V.signal,d&&d.submission),E;if(d&&d.pendingError)E=[Fe(M).route.id,{type:k.error,error:d.pendingError}];else if(d&&d.submission&&he(d.submission.formMethod)){let $=await Cr(D,l,d.submission,M,P.active,{replace:d.replace,flushSync:T});if($.shortCircuited)return;if($.pendingActionResult){let[A,K]=$.pendingActionResult;if(de(K)&&Xe(K.error)&&K.error.status===404){V=null,Ne(l,{matches:$.matches,loaderData:{},errors:{[A]:K.error}});return}}M=$.matches||M,E=$.pendingActionResult,b=bt(l,d.submission),T=!1,P.active=!1,D=Be(e.history,D.url,D.signal)}let{shortCircuited:x,matches:I,loaderData:j,errors:te}=await Lr(D,l,M,P.active,b,d&&d.submission,d&&d.fetcherSubmission,d&&d.replace,d&&d.initialHydration===!0,T,E);x||(V=null,Ne(l,J({matches:I||M},ir(E),{loaderData:j,errors:te})))}async function Cr(i,l,d,p,b,M){M===void 0&&(M={}),ct();let T=Fn(l,d);if(le({navigation:T},{flushSync:M.flushSync===!0}),b){let E=await at(p,l.pathname,i.signal);if(E.type==="aborted")return{shortCircuited:!0};if(E.type==="error"){let x=Fe(E.partialMatches).route.id;return{matches:E.partialMatches,pendingActionResult:[x,{type:k.error,error:E.error}]}}else if(E.matches)p=E.matches;else{let{notFoundMatches:x,error:I,route:j}=ft(l.pathname);return{matches:x,pendingActionResult:[j.id,{type:k.error,error:I}]}}}let P,D=Ye(p,l);if(!D.route.action&&!D.route.lazy)P={type:k.error,error:se(405,{method:i.method,pathname:l.pathname,routeId:D.route.id})};else if(P=(await He("action",h,i,[D],p,null))[D.route.id],i.signal.aborted)return{shortCircuited:!0};if(Ie(P)){let E;return M&&M.replace!=null?E=M.replace:E=tr(P.response.headers.get("Location"),new URL(i.url),s)===h.location.pathname+h.location.search,await Te(i,P,!0,{submission:d,replace:E}),{shortCircuited:!0}}if(Me(P))throw se(400,{type:"defer-action"});if(de(P)){let E=Fe(p,D.route.id);return(M&&M.replace)!==!0&&(B=q.Push),{matches:p,pendingActionResult:[E.route.id,P]}}return{matches:p,pendingActionResult:[D.route.id,P]}}async function Lr(i,l,d,p,b,M,T,P,D,E,x){let I=b||bt(l,M),j=M||T||sr(I),te=!ve&&(!f.v7_partialHydration||!D);if(p){if(te){let Y=Ft(x);le(J({navigation:I},Y!==void 0?{actionData:Y}:{}),{flushSync:E})}let O=await at(d,l.pathname,i.signal);if(O.type==="aborted")return{shortCircuited:!0};if(O.type==="error"){let Y=Fe(O.partialMatches).route.id;return{matches:O.partialMatches,loaderData:{},errors:{[Y]:O.error}}}else if(O.matches)d=O.matches;else{let{error:Y,notFoundMatches:Oe,route:$e}=ft(l.pathname);return{matches:Oe,loaderData:{},errors:{[$e.id]:Y}}}}let $=c||o,[A,K]=Qt(e.history,h,d,j,l,f.v7_partialHydration&&D===!0,f.v7_skipActionErrorRevalidation,ge,Re,Pe,ie,fe,W,$,s,x);if(ht(O=>!(d&&d.some(Y=>Y.route.id===O))||A&&A.some(Y=>Y.route.id===O)),U=++L,A.length===0&&K.length===0){let O=Ot();return Ne(l,J({matches:d,loaderData:{},errors:x&&de(x[1])?{[x[0]]:x[1].error}:null},ir(x),O?{fetchers:new Map(h.fetchers)}:{}),{flushSync:E}),{shortCircuited:!0}}if(te){let O={};if(!p){O.navigation=I;let Y=Ft(x);Y!==void 0&&(O.actionData=Y)}K.length>0&&(O.fetchers=Tr(K)),le(O,{flushSync:E})}K.forEach(O=>{xe(O.key),O.controller&&y.set(O.key,O.controller)});let je=()=>K.forEach(O=>xe(O.key));V&&V.signal.addEventListener("abort",je);let{loaderResults:We,fetcherResults:be}=await It(h,d,A,K,i);if(i.signal.aborted)return{shortCircuited:!0};V&&V.signal.removeEventListener("abort",je),K.forEach(O=>y.delete(O.key));let pe=lt(We);if(pe)return await Te(i,pe.result,!0,{replace:P}),{shortCircuited:!0};if(pe=lt(be),pe)return W.add(pe.key),await Te(i,pe.result,!0,{replace:P}),{shortCircuited:!0};let{loaderData:mt,errors:Ve}=nr(h,d,We,x,K,be,oe);oe.forEach((O,Y)=>{O.subscribe(Oe=>{(Oe||O.done)&&oe.delete(Y)})}),f.v7_partialHydration&&D&&h.errors&&(Ve=J({},h.errors,Ve));let _e=Ot(),it=At(U),ot=_e||it||K.length>0;return J({matches:d,loaderData:mt,errors:Ve},ot?{fetchers:new Map(h.fetchers)}:{})}function Ft(i){if(i&&!de(i[1]))return{[i[0]]:i[1].data};if(h.actionData)return Object.keys(h.actionData).length===0?null:h.actionData}function Tr(i){return i.forEach(l=>{let d=h.fetchers.get(l.key),p=Ke(void 0,d?d.data:void 0);h.fetchers.set(l.key,p)}),new Map(h.fetchers)}function _r(i,l,d,p){if(n)throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");xe(i);let b=(p&&p.flushSync)===!0,M=c||o,T=Et(h.location,h.matches,s,f.v7_prependBasename,d,f.v7_relativeSplatPath,l,p?.relative),P=Ue(M,T,s),D=nt(P,M,T);if(D.active&&D.matches&&(P=D.matches),!P){ye(i,l,se(404,{pathname:T}),{flushSync:b});return}let{path:E,submission:x,error:I}=Xt(f.v7_normalizeFormMethod,!0,T,p);if(I){ye(i,l,I,{flushSync:b});return}let j=Ye(P,E),te=(p&&p.preventScrollReset)===!0;if(x&&he(x.formMethod)){Ur(i,l,E,j,P,D.active,b,te,x);return}fe.set(i,{routeId:l,path:E}),Fr(i,l,E,j,P,D.active,b,te,x)}async function Ur(i,l,d,p,b,M,T,P,D){ct(),fe.delete(i);function E(X){if(!X.route.action&&!X.route.lazy){let Ae=se(405,{method:D.formMethod,pathname:d,routeId:l});return ye(i,l,Ae,{flushSync:T}),!0}return!1}if(!M&&E(p))return;let x=h.fetchers.get(i);De(i,In(D,x),{flushSync:T});let I=new AbortController,j=Be(e.history,d,I.signal,D);if(M){let X=await at(b,new URL(j.url).pathname,j.signal,i);if(X.type==="aborted")return;if(X.type==="error"){ye(i,l,X.error,{flushSync:T});return}else if(X.matches){if(b=X.matches,p=Ye(b,d),E(p))return}else{ye(i,l,se(404,{pathname:d}),{flushSync:T});return}}y.set(i,I);let te=L,A=(await He("action",h,j,[p],b,i))[p.route.id];if(j.signal.aborted){y.get(i)===I&&y.delete(i);return}if(f.v7_fetcherPersist&&ie.has(i)){if(Ie(A)||de(A)){De(i,Se(void 0));return}}else{if(Ie(A))if(y.delete(i),U>te){De(i,Se(void 0));return}else return W.add(i),De(i,Ke(D)),Te(j,A,!1,{fetcherSubmission:D,preventScrollReset:P});if(de(A)){ye(i,l,A.error);return}}if(Me(A))throw se(400,{type:"defer-action"});let K=h.navigation.location||h.location,je=Be(e.history,K,I.signal),We=c||o,be=h.navigation.state!=="idle"?Ue(We,h.navigation.location,s):h.matches;N(be,"Didn't find any matches after fetcher action");let pe=++L;H.set(i,pe);let mt=Ke(D,A.data);h.fetchers.set(i,mt);let[Ve,_e]=Qt(e.history,h,be,D,K,!1,f.v7_skipActionErrorRevalidation,ge,Re,Pe,ie,fe,W,We,s,[p.route.id,A]);_e.filter(X=>X.key!==i).forEach(X=>{let Ae=X.key,Wt=h.fetchers.get(Ae),kr=Ke(void 0,Wt?Wt.data:void 0);h.fetchers.set(Ae,kr),xe(Ae),X.controller&&y.set(Ae,X.controller)}),le({fetchers:new Map(h.fetchers)});let it=()=>_e.forEach(X=>xe(X.key));I.signal.addEventListener("abort",it);let{loaderResults:ot,fetcherResults:O}=await It(h,be,Ve,_e,je);if(I.signal.aborted)return;I.signal.removeEventListener("abort",it),H.delete(i),y.delete(i),_e.forEach(X=>y.delete(X.key));let Y=lt(ot);if(Y)return Te(je,Y.result,!1,{preventScrollReset:P});if(Y=lt(O),Y)return W.add(Y.key),Te(je,Y.result,!1,{preventScrollReset:P});let{loaderData:Oe,errors:$e}=nr(h,be,ot,void 0,_e,O,oe);if(h.fetchers.has(i)){let X=Se(A.data);h.fetchers.set(i,X)}At(pe),h.navigation.state==="loading"&&pe>U?(N(B,"Expected pending action"),V&&V.abort(),Ne(h.navigation.location,{matches:be,loaderData:Oe,errors:$e,fetchers:new Map(h.fetchers)})):(le({errors:$e,loaderData:ar(h.loaderData,Oe,be,$e),fetchers:new Map(h.fetchers)}),ge=!1)}async function Fr(i,l,d,p,b,M,T,P,D){let E=h.fetchers.get(i);De(i,Ke(D,E?E.data:void 0),{flushSync:T});let x=new AbortController,I=Be(e.history,d,x.signal);if(M){let A=await at(b,new URL(I.url).pathname,I.signal,i);if(A.type==="aborted")return;if(A.type==="error"){ye(i,l,A.error,{flushSync:T});return}else if(A.matches)b=A.matches,p=Ye(b,d);else{ye(i,l,se(404,{pathname:d}),{flushSync:T});return}}y.set(i,x);let j=L,$=(await He("loader",h,I,[p],b,i))[p.route.id];if(Me($)&&($=await Mt($,I.signal,!0)||$),y.get(i)===x&&y.delete(i),!I.signal.aborted){if(ie.has(i)){De(i,Se(void 0));return}if(Ie($))if(U>j){De(i,Se(void 0));return}else{W.add(i),await Te(I,$,!1,{preventScrollReset:P});return}if(de($)){ye(i,l,$.error);return}N(!Me($),"Unhandled fetcher deferred data"),De(i,Se($.data))}}async function Te(i,l,d,p){let{submission:b,fetcherSubmission:M,preventScrollReset:T,replace:P}=p===void 0?{}:p;l.response.headers.has("X-Remix-Revalidate")&&(ge=!0);let D=l.response.headers.get("Location");N(D,"Expected a Location header on the redirect Response"),D=tr(D,new URL(i.url),s);let E=Ge(h.location,D,{_isRedirect:!0});if(r){let A=!1;if(l.response.headers.has("X-Remix-Reload-Document"))A=!0;else if(St.test(D)){const K=e.history.createURL(D);A=K.origin!==t.location.origin||Qe(K.pathname,s)==null}if(A){P?t.location.replace(D):t.location.assign(D);return}}V=null;let x=P===!0||l.response.headers.has("X-Remix-Replace")?q.Replace:q.Push,{formMethod:I,formAction:j,formEncType:te}=h.navigation;!b&&!M&&I&&j&&te&&(b=sr(h.navigation));let $=b||M;if(pn.has(l.response.status)&&$&&he($.formMethod))await Le(x,E,{submission:J({},$,{formAction:D}),preventScrollReset:T||Q,enableViewTransition:d?ne:void 0});else{let A=bt(E,b);await Le(x,E,{overrideNavigation:A,fetcherSubmission:M,preventScrollReset:T||Q,enableViewTransition:d?ne:void 0})}}async function He(i,l,d,p,b,M){let T,P={};try{T=await Rn(m,i,l,d,p,b,M,u,a)}catch(D){return p.forEach(E=>{P[E.route.id]={type:k.error,error:D}}),P}for(let[D,E]of Object.entries(T))if(Cn(E)){let x=E.result;P[D]={type:k.redirect,response:xn(x,d,D,b,s,f.v7_relativeSplatPath)}}else P[D]=await Dn(E);return P}async function It(i,l,d,p,b){let M=i.matches,T=He("loader",i,b,d,l,null),P=Promise.all(p.map(async x=>{if(x.matches&&x.match&&x.controller){let j=(await He("loader",i,Be(e.history,x.path,x.controller.signal),[x.match],x.matches,x.key))[x.match.route.id];return{[x.key]:j}}else return Promise.resolve({[x.key]:{type:k.error,error:se(404,{pathname:x.path})}})})),D=await T,E=(await P).reduce((x,I)=>Object.assign(x,I),{});return await Promise.all([_n(l,D,b.signal,M,i.loaderData),Un(l,E,p)]),{loaderResults:D,fetcherResults:E}}function ct(){ge=!0,Re.push(...ht()),fe.forEach((i,l)=>{y.has(l)&&Pe.add(l),xe(l)})}function De(i,l,d){d===void 0&&(d={}),h.fetchers.set(i,l),le({fetchers:new Map(h.fetchers)},{flushSync:(d&&d.flushSync)===!0})}function ye(i,l,d,p){p===void 0&&(p={});let b=Fe(h.matches,l);tt(i),le({errors:{[b.route.id]:d},fetchers:new Map(h.fetchers)},{flushSync:(p&&p.flushSync)===!0})}function Nt(i){return ue.set(i,(ue.get(i)||0)+1),ie.has(i)&&ie.delete(i),h.fetchers.get(i)||vn}function tt(i){let l=h.fetchers.get(i);y.has(i)&&!(l&&l.state==="loading"&&H.has(i))&&xe(i),fe.delete(i),H.delete(i),W.delete(i),f.v7_fetcherPersist&&ie.delete(i),Pe.delete(i),h.fetchers.delete(i)}function Ir(i){let l=(ue.get(i)||0)-1;l<=0?(ue.delete(i),ie.add(i),f.v7_fetcherPersist||tt(i)):ue.set(i,l),le({fetchers:new Map(h.fetchers)})}function xe(i){let l=y.get(i);l&&(l.abort(),y.delete(i))}function jt(i){for(let l of i){let d=Nt(l),p=Se(d.data);h.fetchers.set(l,p)}}function Ot(){let i=[],l=!1;for(let d of W){let p=h.fetchers.get(d);N(p,"Expected fetcher: "+d),p.state==="loading"&&(W.delete(d),i.push(d),l=!0)}return jt(i),l}function At(i){let l=[];for(let[d,p]of H)if(p<i){let b=h.fetchers.get(d);N(b,"Expected fetcher: "+d),b.state==="loading"&&(xe(d),H.delete(d),l.push(d))}return jt(l),l.length>0}function Nr(i,l){let d=h.blockers.get(i)||Je;return ce.get(i)!==l&&ce.set(i,l),d}function Bt(i){h.blockers.delete(i),ce.delete(i)}function rt(i,l){let d=h.blockers.get(i)||Je;N(d.state==="unblocked"&&l.state==="blocked"||d.state==="blocked"&&l.state==="blocked"||d.state==="blocked"&&l.state==="proceeding"||d.state==="blocked"&&l.state==="unblocked"||d.state==="proceeding"&&l.state==="unblocked","Invalid blocker state transition: "+d.state+" -> "+l.state);let p=new Map(h.blockers);p.set(i,l),le({blockers:p})}function kt(i){let{currentLocation:l,nextLocation:d,historyAction:p}=i;if(ce.size===0)return;ce.size>1&&ke(!1,"A router only supports one blocker at a time");let b=Array.from(ce.entries()),[M,T]=b[b.length-1],P=h.blockers.get(M);if(!(P&&P.state==="proceeding")&&T({currentLocation:l,nextLocation:d,historyAction:p}))return M}function ft(i){let l=se(404,{pathname:i}),d=c||o,{matches:p,route:b}=or(d);return ht(),{notFoundMatches:p,route:b,error:l}}function ht(i){let l=[];return oe.forEach((d,p)=>{(!i||i(p))&&(d.cancel(),l.push(p),oe.delete(p))}),l}function jr(i,l,d){if(S=i,_=l,R=d||null,!z&&h.navigation===yt){z=!0;let p=Ht(h.location,h.matches);p!=null&&le({restoreScrollPosition:p})}return()=>{S=null,_=null,R=null}}function zt(i,l){return R&&R(i,l.map(p=>Jr(p,h.loaderData)))||i.key}function Or(i,l){if(S&&_){let d=zt(i,l);S[d]=_()}}function Ht(i,l){if(S){let d=zt(i,l),p=S[d];if(typeof p=="number")return p}return null}function nt(i,l,d){if(v)if(i){if(Object.keys(i[0].params).length>0)return{active:!0,matches:st(l,d,s,!0)}}else return{active:!0,matches:st(l,d,s,!0)||[]};return{active:!1,matches:null}}async function at(i,l,d,p){if(!v)return{type:"success",matches:i};let b=i;for(;;){let M=c==null,T=c||o,P=u;try{await v({signal:d,path:l,matches:b,fetcherKey:p,patch:(x,I)=>{d.aborted||er(x,I,T,P,a)}})}catch(x){return{type:"error",error:x,partialMatches:b}}finally{M&&!d.aborted&&(o=[...o])}if(d.aborted)return{type:"aborted"};let D=Ue(T,l,s);if(D)return{type:"success",matches:D};let E=st(T,l,s,!0);if(!E||b.length===E.length&&b.every((x,I)=>x.route.id===E[I].route.id))return{type:"success",matches:null};b=E}}function Ar(i){u={},c=ut(i,a,void 0,u)}function Br(i,l){let d=c==null;er(i,l,c||o,u,a),d&&(o=[...o],le({}))}return me={get basename(){return s},get future(){return f},get state(){return h},get routes(){return o},get window(){return t},initialize:Dr,subscribe:Sr,enableScrollRestoration:jr,navigate:Ut,fetch:_r,revalidate:Mr,createHref:i=>e.history.createHref(i),encodeLocation:i=>e.history.encodeLocation(i),getFetcher:Nt,deleteFetcher:Ir,dispose:xr,getBlocker:Nr,deleteBlocker:Bt,patchRoutes:Br,_internalFetchControllers:y,_internalActiveDeferreds:oe,_internalSetRoutes:Ar},me}function yn(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function Et(e,t,r,n,a,u,o,c){let s,m;if(o){s=[];for(let f of t)if(s.push(f),f.route.id===o){m=f;break}}else s=t,m=t[t.length-1];let v=xt(a||".",Dt(s,u),Qe(e.pathname,r)||e.pathname,c==="path");if(a==null&&(v.search=e.search,v.hash=e.hash),(a==null||a===""||a===".")&&m){let f=Ct(v.search);if(m.route.index&&!f)v.search=v.search?v.search.replace(/^\?/,"?index&"):"?index";else if(!m.route.index&&f){let g=new URLSearchParams(v.search),w=g.getAll("index");g.delete("index"),w.filter(R=>R).forEach(R=>g.append("index",R));let S=g.toString();v.search=S?"?"+S:""}}return n&&r!=="/"&&(v.pathname=v.pathname==="/"?r:we([r,v.pathname])),qe(v)}function Xt(e,t,r,n){if(!n||!yn(n))return{path:r};if(n.formMethod&&!Tn(n.formMethod))return{path:r,error:se(405,{method:n.formMethod})};let a=()=>({path:r,error:se(400,{type:"invalid-body"})}),u=n.formMethod||"get",o=e?u.toUpperCase():u.toLowerCase(),c=gr(r);if(n.body!==void 0){if(n.formEncType==="text/plain"){if(!he(o))return a();let g=typeof n.body=="string"?n.body:n.body instanceof FormData||n.body instanceof URLSearchParams?Array.from(n.body.entries()).reduce((w,S)=>{let[R,_]=S;return""+w+R+"="+_+`
19
+ `},""):String(n.body);return{path:r,submission:{formMethod:o,formAction:c,formEncType:n.formEncType,formData:void 0,json:void 0,text:g}}}else if(n.formEncType==="application/json"){if(!he(o))return a();try{let g=typeof n.body=="string"?JSON.parse(n.body):n.body;return{path:r,submission:{formMethod:o,formAction:c,formEncType:n.formEncType,formData:void 0,json:g,text:void 0}}}catch{return a()}}}N(typeof FormData=="function","FormData is not available in this environment");let s,m;if(n.formData)s=Pt(n.formData),m=n.formData;else if(n.body instanceof FormData)s=Pt(n.body),m=n.body;else if(n.body instanceof URLSearchParams)s=n.body,m=rr(s);else if(n.body==null)s=new URLSearchParams,m=new FormData;else try{s=new URLSearchParams(n.body),m=rr(s)}catch{return a()}let v={formMethod:o,formAction:c,formEncType:n&&n.formEncType||"application/x-www-form-urlencoded",formData:m,json:void 0,text:void 0};if(he(v.formMethod))return{path:r,submission:v};let f=Ce(r);return t&&f.search&&Ct(f.search)&&s.append("index",""),f.search="?"+s,{path:qe(f),submission:v}}function qt(e,t,r){r===void 0&&(r=!1);let n=e.findIndex(a=>a.route.id===t);return n>=0?e.slice(0,r?n+1:n):e}function Qt(e,t,r,n,a,u,o,c,s,m,v,f,g,w,S,R){let _=R?de(R[1])?R[1].error:R[1].data:void 0,z=e.createURL(t.location),F=e.createURL(a),G=r;u&&t.errors?G=qt(r,Object.keys(t.errors)[0],!0):R&&de(R[1])&&(G=qt(r,R[0]));let re=R?R[1].statusCode:void 0,Z=o&&re&&re>=400,me=G.filter((B,Q)=>{let{route:V}=B;if(V.lazy)return!0;if(V.loader==null)return!1;if(u)return Rt(V,t.loaderData,t.errors);if(bn(t.loaderData,t.matches[Q],B)||s.some(ee=>ee===B.route.id))return!0;let ne=t.matches[Q],ae=B;return Zt(B,J({currentUrl:z,currentParams:ne.params,nextUrl:F,nextParams:ae.params},n,{actionResult:_,actionStatus:re,defaultShouldRevalidate:Z?!1:c||z.pathname+z.search===F.pathname+F.search||z.search!==F.search||pr(ne,ae)}))}),h=[];return f.forEach((B,Q)=>{if(u||!r.some(ve=>ve.route.id===B.routeId)||v.has(Q))return;let V=Ue(w,B.path,S);if(!V){h.push({key:Q,routeId:B.routeId,path:B.path,matches:null,match:null,controller:null});return}let ne=t.fetchers.get(Q),ae=Ye(V,B.path),ee=!1;g.has(Q)?ee=!1:m.has(Q)?(m.delete(Q),ee=!0):ne&&ne.state!=="idle"&&ne.data===void 0?ee=c:ee=Zt(ae,J({currentUrl:z,currentParams:t.matches[t.matches.length-1].params,nextUrl:F,nextParams:r[r.length-1].params},n,{actionResult:_,actionStatus:re,defaultShouldRevalidate:Z?!1:c})),ee&&h.push({key:Q,routeId:B.routeId,path:B.path,matches:V,match:ae,controller:new AbortController})}),[me,h]}function Rt(e,t,r){if(e.lazy)return!0;if(!e.loader)return!1;let n=t!=null&&t[e.id]!==void 0,a=r!=null&&r[e.id]!==void 0;return!n&&a?!1:typeof e.loader=="function"&&e.loader.hydrate===!0?!0:!n&&!a}function bn(e,t,r){let n=!t||r.route.id!==t.route.id,a=e[r.route.id]===void 0;return n||a}function pr(e,t){let r=e.route.path;return e.pathname!==t.pathname||r!=null&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function Zt(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if(typeof r=="boolean")return r}return t.defaultShouldRevalidate}function er(e,t,r,n,a){var u;let o;if(e){let m=n[e];N(m,"No route found to patch children into: routeId = "+e),m.children||(m.children=[]),o=m.children}else o=r;let c=t.filter(m=>!o.some(v=>vr(m,v))),s=ut(c,a,[e||"_","patch",String(((u=o)==null?void 0:u.length)||"0")],n);o.push(...s)}function vr(e,t){return"id"in e&&"id"in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children.every((r,n)=>{var a;return(a=t.children)==null?void 0:a.some(u=>vr(r,u))}):!1}async function wn(e,t,r){if(!e.lazy)return;let n=await e.lazy();if(!e.lazy)return;let a=r[e.id];N(a,"No route found in manifest");let u={};for(let o in n){let s=a[o]!==void 0&&o!=="hasErrorBoundary";ke(!s,'Route "'+a.id+'" has a static property "'+o+'" defined but its lazy function is also returning a value for this property. '+('The lazy route property "'+o+'" will be ignored.')),!s&&!Vr.has(o)&&(u[o]=n[o])}Object.assign(a,u),Object.assign(a,J({},t(a),{lazy:void 0}))}async function En(e){let{matches:t}=e,r=t.filter(a=>a.shouldLoad);return(await Promise.all(r.map(a=>a.resolve()))).reduce((a,u,o)=>Object.assign(a,{[r[o].route.id]:u}),{})}async function Rn(e,t,r,n,a,u,o,c,s,m){let v=u.map(w=>w.route.lazy?wn(w.route,s,c):void 0),f=u.map((w,S)=>{let R=v[S],_=a.some(F=>F.route.id===w.route.id);return J({},w,{shouldLoad:_,resolve:async F=>(F&&n.method==="GET"&&(w.route.lazy||w.route.loader)&&(_=!0),_?Pn(t,n,w,R,F,m):Promise.resolve({type:k.data,result:void 0}))})}),g=await e({matches:f,request:n,params:u[0].params,fetcherKey:o,context:m});try{await Promise.all(v)}catch{}return g}async function Pn(e,t,r,n,a,u){let o,c,s=m=>{let v,f=new Promise((S,R)=>v=R);c=()=>v(),t.signal.addEventListener("abort",c);let g=S=>typeof m!="function"?Promise.reject(new Error("You cannot call the handler for a route which defines a boolean "+('"'+e+'" [routeId: '+r.route.id+"]"))):m({request:t,params:r.params,context:u},...S!==void 0?[S]:[]),w=(async()=>{try{return{type:"data",result:await(a?a(R=>g(R)):g())}}catch(S){return{type:"error",result:S}}})();return Promise.race([w,f])};try{let m=r.route[e];if(n)if(m){let v,[f]=await Promise.all([s(m).catch(g=>{v=g}),n]);if(v!==void 0)throw v;o=f}else if(await n,m=r.route[e],m)o=await s(m);else if(e==="action"){let v=new URL(t.url),f=v.pathname+v.search;throw se(405,{method:t.method,pathname:f,routeId:r.route.id})}else return{type:k.data,result:void 0};else if(m)o=await s(m);else{let v=new URL(t.url),f=v.pathname+v.search;throw se(404,{pathname:f})}N(o.result!==void 0,"You defined "+(e==="action"?"an action":"a loader")+" for route "+('"'+r.route.id+"\" but didn't return anything from your `"+e+"` ")+"function. Please return a value or `null`.")}catch(m){return{type:k.error,result:m}}finally{c&&t.signal.removeEventListener("abort",c)}return o}async function Dn(e){let{result:t,type:r}=e;if(yr(t)){let f;try{let g=t.headers.get("Content-Type");g&&/\bapplication\/json\b/.test(g)?t.body==null?f=null:f=await t.json():f=await t.text()}catch(g){return{type:k.error,error:g}}return r===k.error?{type:k.error,error:new wt(t.status,t.statusText,f),statusCode:t.status,headers:t.headers}:{type:k.data,data:f,statusCode:t.status,headers:t.headers}}if(r===k.error){if(lr(t)){var n,a;if(t.data instanceof Error){var u,o;return{type:k.error,error:t.data,statusCode:(u=t.init)==null?void 0:u.status,headers:(o=t.init)!=null&&o.headers?new Headers(t.init.headers):void 0}}return{type:k.error,error:new wt(((n=t.init)==null?void 0:n.status)||500,void 0,t.data),statusCode:Xe(t)?t.status:void 0,headers:(a=t.init)!=null&&a.headers?new Headers(t.init.headers):void 0}}return{type:k.error,error:t,statusCode:Xe(t)?t.status:void 0}}if(Ln(t)){var c,s;return{type:k.deferred,deferredData:t,statusCode:(c=t.init)==null?void 0:c.status,headers:((s=t.init)==null?void 0:s.headers)&&new Headers(t.init.headers)}}if(lr(t)){var m,v;return{type:k.data,data:t.data,statusCode:(m=t.init)==null?void 0:m.status,headers:(v=t.init)!=null&&v.headers?new Headers(t.init.headers):void 0}}return{type:k.data,data:t}}function xn(e,t,r,n,a,u){let o=e.headers.get("Location");if(N(o,"Redirects returned/thrown from loaders/actions must have a Location header"),!St.test(o)){let c=n.slice(0,n.findIndex(s=>s.route.id===r)+1);o=Et(new URL(t.url),c,a,!0,o,u),e.headers.set("Location",o)}return e}function tr(e,t,r){if(St.test(e)){let n=e,a=n.startsWith("//")?new URL(t.protocol+n):new URL(n),u=Qe(a.pathname,r)!=null;if(a.origin===t.origin&&u)return a.pathname+a.search+a.hash}return e}function Be(e,t,r,n){let a=e.createURL(gr(t)).toString(),u={signal:r};if(n&&he(n.formMethod)){let{formMethod:o,formEncType:c}=n;u.method=o.toUpperCase(),c==="application/json"?(u.headers=new Headers({"Content-Type":c}),u.body=JSON.stringify(n.json)):c==="text/plain"?u.body=n.text:c==="application/x-www-form-urlencoded"&&n.formData?u.body=Pt(n.formData):u.body=n.formData}return new Request(a,u)}function Pt(e){let t=new URLSearchParams;for(let[r,n]of e.entries())t.append(r,typeof n=="string"?n:n.name);return t}function rr(e){let t=new FormData;for(let[r,n]of e.entries())t.append(r,n);return t}function Sn(e,t,r,n,a){let u={},o=null,c,s=!1,m={},v=r&&de(r[1])?r[1].error:void 0;return e.forEach(f=>{if(!(f.route.id in t))return;let g=f.route.id,w=t[g];if(N(!Ie(w),"Cannot handle redirect results in processLoaderData"),de(w)){let S=w.error;v!==void 0&&(S=v,v=void 0),o=o||{};{let R=Fe(e,g);o[R.route.id]==null&&(o[R.route.id]=S)}u[g]=void 0,s||(s=!0,c=Xe(w.error)?w.error.status:500),w.headers&&(m[g]=w.headers)}else Me(w)?(n.set(g,w.deferredData),u[g]=w.deferredData.data,w.statusCode!=null&&w.statusCode!==200&&!s&&(c=w.statusCode),w.headers&&(m[g]=w.headers)):(u[g]=w.data,w.statusCode&&w.statusCode!==200&&!s&&(c=w.statusCode),w.headers&&(m[g]=w.headers))}),v!==void 0&&r&&(o={[r[0]]:v},u[r[0]]=void 0),{loaderData:u,errors:o,statusCode:c||200,loaderHeaders:m}}function nr(e,t,r,n,a,u,o){let{loaderData:c,errors:s}=Sn(t,r,n,o);return a.forEach(m=>{let{key:v,match:f,controller:g}=m,w=u[v];if(N(w,"Did not find corresponding fetcher result"),!(g&&g.signal.aborted))if(de(w)){let S=Fe(e.matches,f?.route.id);s&&s[S.route.id]||(s=J({},s,{[S.route.id]:w.error})),e.fetchers.delete(v)}else if(Ie(w))N(!1,"Unhandled fetcher revalidation redirect");else if(Me(w))N(!1,"Unhandled fetcher deferred data");else{let S=Se(w.data);e.fetchers.set(v,S)}}),{loaderData:c,errors:s}}function ar(e,t,r,n){let a=J({},t);for(let u of r){let o=u.route.id;if(t.hasOwnProperty(o)?t[o]!==void 0&&(a[o]=t[o]):e[o]!==void 0&&u.route.loader&&(a[o]=e[o]),n&&n.hasOwnProperty(o))break}return a}function ir(e){return e?de(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function Fe(e,t){return(t?e.slice(0,e.findIndex(n=>n.route.id===t)+1):[...e]).reverse().find(n=>n.route.hasErrorBoundary===!0)||e[0]}function or(e){let t=e.length===1?e[0]:e.find(r=>r.index||!r.path||r.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function se(e,t){let{pathname:r,routeId:n,method:a,type:u,message:o}=t===void 0?{}:t,c="Unknown Server Error",s="Unknown @remix-run/router error";return e===400?(c="Bad Request",a&&r&&n?s="You made a "+a+' request to "'+r+'" but '+('did not provide a `loader` for route "'+n+'", ')+"so there is no way to handle the request.":u==="defer-action"?s="defer() is not supported in actions":u==="invalid-body"&&(s="Unable to encode submission body")):e===403?(c="Forbidden",s='Route "'+n+'" does not match URL "'+r+'"'):e===404?(c="Not Found",s='No route matches URL "'+r+'"'):e===405&&(c="Method Not Allowed",a&&r&&n?s="You made a "+a.toUpperCase()+' request to "'+r+'" but '+('did not provide an `action` for route "'+n+'", ')+"so there is no way to handle the request.":a&&(s='Invalid request method "'+a.toUpperCase()+'"')),new wt(e||500,c,new Error(s),!0)}function lt(e){let t=Object.entries(e);for(let r=t.length-1;r>=0;r--){let[n,a]=t[r];if(Ie(a))return{key:n,result:a}}}function gr(e){let t=typeof e=="string"?Ce(e):e;return qe(J({},t,{hash:""}))}function Mn(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===""?t.hash!=="":e.hash===t.hash?!0:t.hash!==""}function Cn(e){return yr(e.result)&&mn.has(e.result.status)}function Me(e){return e.type===k.deferred}function de(e){return e.type===k.error}function Ie(e){return(e&&e.type)===k.redirect}function lr(e){return typeof e=="object"&&e!=null&&"type"in e&&"data"in e&&"init"in e&&e.type==="DataWithResponseInit"}function Ln(e){let t=e;return t&&typeof t=="object"&&typeof t.data=="object"&&typeof t.subscribe=="function"&&typeof t.cancel=="function"&&typeof t.resolveData=="function"}function yr(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.headers=="object"&&typeof e.body<"u"}function Tn(e){return hn.has(e.toLowerCase())}function he(e){return cn.has(e.toLowerCase())}async function _n(e,t,r,n,a){let u=Object.entries(t);for(let o=0;o<u.length;o++){let[c,s]=u[o],m=e.find(g=>g?.route.id===c);if(!m)continue;let v=n.find(g=>g.route.id===m.route.id),f=v!=null&&!pr(v,m)&&(a&&a[m.route.id])!==void 0;Me(s)&&f&&await Mt(s,r,!1).then(g=>{g&&(t[c]=g)})}}async function Un(e,t,r){for(let n=0;n<r.length;n++){let{key:a,routeId:u,controller:o}=r[n],c=t[a];e.find(m=>m?.route.id===u)&&Me(c)&&(N(o,"Expected an AbortController for revalidating fetcher deferred result"),await Mt(c,o.signal,!0).then(m=>{m&&(t[a]=m)}))}}async function Mt(e,t,r){if(r===void 0&&(r=!1),!await e.deferredData.resolveData(t)){if(r)try{return{type:k.data,data:e.deferredData.unwrappedData}}catch(a){return{type:k.error,error:a}}return{type:k.data,data:e.deferredData.data}}}function Ct(e){return new URLSearchParams(e).getAll("index").some(t=>t==="")}function Ye(e,t){let r=typeof t=="string"?Ce(t).search:t.search;if(e[e.length-1].route.index&&Ct(r||""))return e[e.length-1];let n=fr(e);return n[n.length-1]}function sr(e){let{formMethod:t,formAction:r,formEncType:n,text:a,formData:u,json:o}=e;if(!(!t||!r||!n)){if(a!=null)return{formMethod:t,formAction:r,formEncType:n,formData:void 0,json:void 0,text:a};if(u!=null)return{formMethod:t,formAction:r,formEncType:n,formData:u,json:void 0,text:void 0};if(o!==void 0)return{formMethod:t,formAction:r,formEncType:n,formData:void 0,json:o,text:void 0}}}function bt(e,t){return t?{state:"loading",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}:{state:"loading",location:e,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function Fn(e,t){return{state:"submitting",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}function Ke(e,t){return e?{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function In(e,t){return{state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function Se(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function Nn(e,t){try{let r=e.sessionStorage.getItem(mr);if(r){let n=JSON.parse(r);for(let[a,u]of Object.entries(n||{}))u&&Array.isArray(u)&&t.set(a,new Set(u||[]))}}catch{}}function jn(e,t){if(t.size>0){let r={};for(let[n,a]of t)r[n]=[...a];try{e.sessionStorage.setItem(mr,JSON.stringify(r))}catch(n){ke(!1,"Failed to save applied view transitions in sessionStorage ("+n+").")}}}/**
20
+ * React Router v6.30.1
21
+ *
22
+ * Copyright (c) Remix Software Inc.
23
+ *
24
+ * This source code is licensed under the MIT license found in the
25
+ * LICENSE.md file in the root directory of this source tree.
26
+ *
27
+ * @license MIT
28
+ */function dt(){return dt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},dt.apply(this,arguments)}const Lt=C.createContext(null),On=C.createContext(null),ze=C.createContext(null),Tt=C.createContext(null),Ee=C.createContext({outlet:null,matches:[],isDataRoute:!1}),br=C.createContext(null);function sa(e,t){let{relative:r}=t===void 0?{}:t;Ze()||N(!1);let{basename:n,navigator:a}=C.useContext(ze),{hash:u,pathname:o,search:c}=zn(e,{relative:r}),s=o;return n!=="/"&&(s=o==="/"?n:we([n,o])),a.createHref({pathname:s,search:c,hash:u})}function Ze(){return C.useContext(Tt)!=null}function _t(){return Ze()||N(!1),C.useContext(Tt).location}function wr(e){C.useContext(ze).static||C.useLayoutEffect(e)}function ua(){let{isDataRoute:e}=C.useContext(Ee);return e?qn():An()}function An(){Ze()||N(!1);let e=C.useContext(Lt),{basename:t,future:r,navigator:n}=C.useContext(ze),{matches:a}=C.useContext(Ee),{pathname:u}=_t(),o=JSON.stringify(Dt(a,r.v7_relativeSplatPath)),c=C.useRef(!1);return wr(()=>{c.current=!0}),C.useCallback(function(m,v){if(v===void 0&&(v={}),!c.current)return;if(typeof m=="number"){n.go(m);return}let f=xt(m,JSON.parse(o),u,v.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:we([t,f.pathname])),(v.replace?n.replace:n.push)(f,v.state,v)},[t,n,o,u,e])}const Bn=C.createContext(null);function kn(e){let t=C.useContext(Ee).outlet;return t&&C.createElement(Bn.Provider,{value:e},t)}function da(){let{matches:e}=C.useContext(Ee),t=e[e.length-1];return t?t.params:{}}function zn(e,t){let{relative:r}=t===void 0?{}:t,{future:n}=C.useContext(ze),{matches:a}=C.useContext(Ee),{pathname:u}=_t(),o=JSON.stringify(Dt(a,n.v7_relativeSplatPath));return C.useMemo(()=>xt(e,JSON.parse(o),u,r==="path"),[e,o,u,r])}function ca(e,t,r,n){Ze()||N(!1);let{navigator:a}=C.useContext(ze),{matches:u}=C.useContext(Ee),o=u[u.length-1],c=o?o.params:{};o&&o.pathname;let s=o?o.pathnameBase:"/";o&&o.route;let m=_t(),v;v=m;let f=v.pathname||"/",g=f;if(s!=="/"){let R=s.replace(/^\//,"").split("/");g="/"+f.replace(/^\//,"").split("/").slice(R.length).join("/")}let w=Ue(e,{pathname:g});return Jn(w&&w.map(R=>Object.assign({},R,{params:Object.assign({},c,R.params),pathname:we([s,a.encodeLocation?a.encodeLocation(R.pathname).pathname:R.pathname]),pathnameBase:R.pathnameBase==="/"?s:we([s,a.encodeLocation?a.encodeLocation(R.pathnameBase).pathname:R.pathnameBase])})),u,r,n)}function Hn(){let e=Xn(),t=Xe(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return C.createElement(C.Fragment,null,C.createElement("h2",null,"Unexpected Application Error!"),C.createElement("h3",{style:{fontStyle:"italic"}},t),r?C.createElement("pre",{style:a},r):null,null)}const Wn=C.createElement(Hn,null);class Vn extends C.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,r){return r.location!==t.location||r.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:r.error,location:r.location,revalidation:t.revalidation||r.revalidation}}componentDidCatch(t,r){console.error("React Router caught the following error during render",t,r)}render(){return this.state.error!==void 0?C.createElement(Ee.Provider,{value:this.props.routeContext},C.createElement(br.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function $n(e){let{routeContext:t,match:r,children:n}=e,a=C.useContext(Lt);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),C.createElement(Ee.Provider,{value:t},n)}function Jn(e,t,r,n){var a;if(t===void 0&&(t=[]),r===void 0&&(r=null),n===void 0&&(n=null),e==null){var u;if(!r)return null;if(r.errors)e=r.matches;else if((u=n)!=null&&u.v7_partialHydration&&t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let o=e,c=(a=r)==null?void 0:a.errors;if(c!=null){let v=o.findIndex(f=>f.route.id&&c?.[f.route.id]!==void 0);v>=0||N(!1),o=o.slice(0,Math.min(o.length,v+1))}let s=!1,m=-1;if(r&&n&&n.v7_partialHydration)for(let v=0;v<o.length;v++){let f=o[v];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(m=v),f.route.id){let{loaderData:g,errors:w}=r,S=f.route.loader&&g[f.route.id]===void 0&&(!w||w[f.route.id]===void 0);if(f.route.lazy||S){s=!0,m>=0?o=o.slice(0,m+1):o=[o[0]];break}}}return o.reduceRight((v,f,g)=>{let w,S=!1,R=null,_=null;r&&(w=c&&f.route.id?c[f.route.id]:void 0,R=f.route.errorElement||Wn,s&&(m<0&&g===0?(Qn("route-fallback"),S=!0,_=null):m===g&&(S=!0,_=f.route.hydrateFallbackElement||null)));let z=t.concat(o.slice(0,g+1)),F=()=>{let G;return w?G=R:S?G=_:f.route.Component?G=C.createElement(f.route.Component,null):f.route.element?G=f.route.element:G=v,C.createElement($n,{match:f,routeContext:{outlet:v,matches:z,isDataRoute:r!=null},children:G})};return r&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?C.createElement(Vn,{location:r.location,revalidation:r.revalidation,component:R,error:w,children:F(),routeContext:{outlet:null,matches:z,isDataRoute:!0}}):F()},null)}var Er=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Er||{}),Rr=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(Rr||{});function Kn(e){let t=C.useContext(Lt);return t||N(!1),t}function Yn(e){let t=C.useContext(On);return t||N(!1),t}function Gn(e){let t=C.useContext(Ee);return t||N(!1),t}function Pr(e){let t=Gn(),r=t.matches[t.matches.length-1];return r.route.id||N(!1),r.route.id}function Xn(){var e;let t=C.useContext(br),r=Yn(),n=Pr();return t!==void 0?t:(e=r.errors)==null?void 0:e[n]}function qn(){let{router:e}=Kn(Er.UseNavigateStable),t=Pr(Rr.UseNavigateStable),r=C.useRef(!1);return wr(()=>{r.current=!0}),C.useCallback(function(a,u){u===void 0&&(u={}),r.current&&(typeof a=="number"?e.navigate(a):e.navigate(a,dt({fromRouteId:t},u)))},[e,t])}const ur={};function Qn(e,t,r){ur[e]||(ur[e]=!0)}function fa(e,t){e?.v7_startTransition,e?.v7_relativeSplatPath===void 0&&(!t||t.v7_relativeSplatPath),t&&(t.v7_fetcherPersist,t.v7_normalizeFormMethod,t.v7_partialHydration,t.v7_skipActionErrorRevalidation)}function ha(e){return kn(e.context)}function ma(e){let{basename:t="/",children:r=null,location:n,navigationType:a=q.Pop,navigator:u,static:o=!1,future:c}=e;Ze()&&N(!1);let s=t.replace(/^\/*/,"/"),m=C.useMemo(()=>({basename:s,navigator:u,static:o,future:dt({v7_relativeSplatPath:!1},c)}),[s,c,u,o]);typeof n=="string"&&(n=Ce(n));let{pathname:v="/",search:f="",hash:g="",state:w=null,key:S="default"}=n,R=C.useMemo(()=>{let _=Qe(v,s);return _==null?null:{location:{pathname:_,search:f,hash:g,state:w,key:S},navigationType:a}},[s,v,f,g,w,S,a]);return R==null?null:C.createElement(ze.Provider,{value:m},C.createElement(Tt.Provider,{children:r,value:R}))}new Promise(()=>{});function pa(e){let t={hasErrorBoundary:e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&Object.assign(t,{element:C.createElement(e.Component),Component:void 0}),e.HydrateFallback&&Object.assign(t,{hydrateFallbackElement:C.createElement(e.HydrateFallback),HydrateFallback:void 0}),e.ErrorBoundary&&Object.assign(t,{errorElement:C.createElement(e.ErrorBoundary),ErrorBoundary:void 0}),t}function Zn(e){return typeof e=="number"?Number.isNaN(e):!1}function ea(e){return e==null||Zn(e)}function va(e,t){if(ea(e))return;const r={},n=[];return e.forEach(a=>{const u=t?t(a):JSON.stringify(a);r[u]||(r[u]=!0,n.push(a))}),e.length===n.length?e:n}const ta=["Boolean","Number","String","Function","Array","Date","RegExp","Object","Error","Symbol"];ta.reduce((e,t)=>({...e,[`[object ${t}]`]:t.toLowerCase()}),{});export{Lt as D,wt as E,ze as N,ha as O,ma as R,ua as a,oa as b,la as c,On as d,sa as e,ca as f,aa as g,zn as h,qe as i,na as j,va as k,fa as l,pa as m,da as n,ia as r,Qe as s,_t as u};
py_backend/static/assets/vendor-react-BxsGb6Ph.js ADDED
The diff for this file is too large to render. See raw diff
 
py_backend/static/assets/vendor-ui-l_DttnRj.js ADDED
The diff for this file is too large to render. See raw diff
 
py_backend/static/assets/vendor-utils-Db80MiSc.js ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{j as bt,g as It}from"./vendor-DxpCibxB.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:{}};/*!
2
+
3
+ JSZip v3.10.1 - A JavaScript class for generating and reading zip files
4
+ <http://stuartk.com/jszip>
5
+
6
+ (c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
7
+ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
8
+
9
+ JSZip uses the library pako released under the MIT license :
10
+ https://github.com/nodeca/pako/blob/main/LICENSE
11
+ */var zt;function Ot(){return zt||(zt=1,function(yt,Tt){(function(b){yt.exports=b()})(function(){return function b(U,k,l){function o(_,y){if(!k[_]){if(!U[_]){var p=typeof vt=="function"&&vt;if(!y&&p)return p(_,!0);if(n)return n(_,!0);var g=new Error("Cannot find module '"+_+"'");throw g.code="MODULE_NOT_FOUND",g}var i=k[_]={exports:{}};U[_][0].call(i.exports,function(d){var r=U[_][1][d];return o(r||d)},i,i.exports,b,U,k,l)}return k[_].exports}for(var n=typeof vt=="function"&&vt,u=0;u<l.length;u++)o(l[u]);return o}({1:[function(b,U,k){var l=b("./utils"),o=b("./support"),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";k.encode=function(u){for(var _,y,p,g,i,d,r,h=[],a=0,c=u.length,v=c,S=l.getTypeOf(u)!=="string";a<u.length;)v=c-a,p=S?(_=u[a++],y=a<c?u[a++]:0,a<c?u[a++]:0):(_=u.charCodeAt(a++),y=a<c?u.charCodeAt(a++):0,a<c?u.charCodeAt(a++):0),g=_>>2,i=(3&_)<<4|y>>4,d=1<v?(15&y)<<2|p>>6:64,r=2<v?63&p:64,h.push(n.charAt(g)+n.charAt(i)+n.charAt(d)+n.charAt(r));return h.join("")},k.decode=function(u){var _,y,p,g,i,d,r=0,h=0,a="data:";if(u.substr(0,a.length)===a)throw new Error("Invalid base64 input, it looks like a data url.");var c,v=3*(u=u.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(u.charAt(u.length-1)===n.charAt(64)&&v--,u.charAt(u.length-2)===n.charAt(64)&&v--,v%1!=0)throw new Error("Invalid base64 input, bad content length.");for(c=o.uint8array?new Uint8Array(0|v):new Array(0|v);r<u.length;)_=n.indexOf(u.charAt(r++))<<2|(g=n.indexOf(u.charAt(r++)))>>4,y=(15&g)<<4|(i=n.indexOf(u.charAt(r++)))>>2,p=(3&i)<<6|(d=n.indexOf(u.charAt(r++))),c[h++]=_,i!==64&&(c[h++]=y),d!==64&&(c[h++]=p);return c}},{"./support":30,"./utils":32}],2:[function(b,U,k){var l=b("./external"),o=b("./stream/DataWorker"),n=b("./stream/Crc32Probe"),u=b("./stream/DataLengthProbe");function _(y,p,g,i,d){this.compressedSize=y,this.uncompressedSize=p,this.crc32=g,this.compression=i,this.compressedContent=d}_.prototype={getContentWorker:function(){var y=new o(l.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new u("data_length")),p=this;return y.on("end",function(){if(this.streamInfo.data_length!==p.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),y},getCompressedWorker:function(){return new o(l.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},_.createWorkerFrom=function(y,p,g){return y.pipe(new n).pipe(new u("uncompressedSize")).pipe(p.compressWorker(g)).pipe(new u("compressedSize")).withStreamInfo("compression",p)},U.exports=_},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(b,U,k){var l=b("./stream/GenericWorker");k.STORE={magic:"\0\0",compressWorker:function(){return new l("STORE compression")},uncompressWorker:function(){return new l("STORE decompression")}},k.DEFLATE=b("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(b,U,k){var l=b("./utils"),o=function(){for(var n,u=[],_=0;_<256;_++){n=_;for(var y=0;y<8;y++)n=1&n?3988292384^n>>>1:n>>>1;u[_]=n}return u}();U.exports=function(n,u){return n!==void 0&&n.length?l.getTypeOf(n)!=="string"?function(_,y,p,g){var i=o,d=g+p;_^=-1;for(var r=g;r<d;r++)_=_>>>8^i[255&(_^y[r])];return-1^_}(0|u,n,n.length,0):function(_,y,p,g){var i=o,d=g+p;_^=-1;for(var r=g;r<d;r++)_=_>>>8^i[255&(_^y.charCodeAt(r))];return-1^_}(0|u,n,n.length,0):0}},{"./utils":32}],5:[function(b,U,k){k.base64=!1,k.binary=!1,k.dir=!1,k.createFolders=!0,k.date=null,k.compression=null,k.compressionOptions=null,k.comment=null,k.unixPermissions=null,k.dosPermissions=null},{}],6:[function(b,U,k){var l=null;l=typeof Promise<"u"?Promise:b("lie"),U.exports={Promise:l}},{lie:37}],7:[function(b,U,k){var l=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=b("pako"),n=b("./utils"),u=b("./stream/GenericWorker"),_=l?"uint8array":"array";function y(p,g){u.call(this,"FlateWorker/"+p),this._pako=null,this._pakoAction=p,this._pakoOptions=g,this.meta={}}k.magic="\b\0",n.inherits(y,u),y.prototype.processChunk=function(p){this.meta=p.meta,this._pako===null&&this._createPako(),this._pako.push(n.transformTo(_,p.data),!1)},y.prototype.flush=function(){u.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},y.prototype.cleanUp=function(){u.prototype.cleanUp.call(this),this._pako=null},y.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var p=this;this._pako.onData=function(g){p.push({data:g,meta:p.meta})}},k.compressWorker=function(p){return new y("Deflate",p)},k.uncompressWorker=function(){return new y("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(b,U,k){function l(i,d){var r,h="";for(r=0;r<d;r++)h+=String.fromCharCode(255&i),i>>>=8;return h}function o(i,d,r,h,a,c){var v,S,x=i.file,D=i.compression,O=c!==_.utf8encode,j=n.transformTo("string",c(x.name)),I=n.transformTo("string",_.utf8encode(x.name)),W=x.comment,q=n.transformTo("string",c(W)),m=n.transformTo("string",_.utf8encode(W)),B=I.length!==x.name.length,e=m.length!==W.length,T="",J="",P="",$=x.dir,L=x.date,V={crc32:0,compressedSize:0,uncompressedSize:0};d&&!r||(V.crc32=i.crc32,V.compressedSize=i.compressedSize,V.uncompressedSize=i.uncompressedSize);var E=0;d&&(E|=8),O||!B&&!e||(E|=2048);var C=0,X=0;$&&(C|=16),a==="UNIX"?(X=798,C|=function(H,nt){var ot=H;return H||(ot=nt?16893:33204),(65535&ot)<<16}(x.unixPermissions,$)):(X=20,C|=function(H){return 63&(H||0)}(x.dosPermissions)),v=L.getUTCHours(),v<<=6,v|=L.getUTCMinutes(),v<<=5,v|=L.getUTCSeconds()/2,S=L.getUTCFullYear()-1980,S<<=4,S|=L.getUTCMonth()+1,S<<=5,S|=L.getUTCDate(),B&&(J=l(1,1)+l(y(j),4)+I,T+="up"+l(J.length,2)+J),e&&(P=l(1,1)+l(y(q),4)+m,T+="uc"+l(P.length,2)+P);var G="";return G+=`
12
+ \0`,G+=l(E,2),G+=D.magic,G+=l(v,2),G+=l(S,2),G+=l(V.crc32,4),G+=l(V.compressedSize,4),G+=l(V.uncompressedSize,4),G+=l(j.length,2),G+=l(T.length,2),{fileRecord:p.LOCAL_FILE_HEADER+G+j+T,dirRecord:p.CENTRAL_FILE_HEADER+l(X,2)+G+l(q.length,2)+"\0\0\0\0"+l(C,4)+l(h,4)+j+T+q}}var n=b("../utils"),u=b("../stream/GenericWorker"),_=b("../utf8"),y=b("../crc32"),p=b("../signature");function g(i,d,r,h){u.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=d,this.zipPlatform=r,this.encodeFileName=h,this.streamFiles=i,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}n.inherits(g,u),g.prototype.push=function(i){var d=i.meta.percent||0,r=this.entriesCount,h=this._sources.length;this.accumulate?this.contentBuffer.push(i):(this.bytesWritten+=i.data.length,u.prototype.push.call(this,{data:i.data,meta:{currentFile:this.currentFile,percent:r?(d+100*(r-h-1))/r:100}}))},g.prototype.openedSource=function(i){this.currentSourceOffset=this.bytesWritten,this.currentFile=i.file.name;var d=this.streamFiles&&!i.file.dir;if(d){var r=o(i,d,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(i){this.accumulate=!1;var d=this.streamFiles&&!i.file.dir,r=o(i,d,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),d)this.push({data:function(h){return p.DATA_DESCRIPTOR+l(h.crc32,4)+l(h.compressedSize,4)+l(h.uncompressedSize,4)}(i),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var i=this.bytesWritten,d=0;d<this.dirRecords.length;d++)this.push({data:this.dirRecords[d],meta:{percent:100}});var r=this.bytesWritten-i,h=function(a,c,v,S,x){var D=n.transformTo("string",x(S));return p.CENTRAL_DIRECTORY_END+"\0\0\0\0"+l(a,2)+l(a,2)+l(c,4)+l(v,4)+l(D.length,2)+D}(this.dirRecords.length,r,i,this.zipComment,this.encodeFileName);this.push({data:h,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(i){this._sources.push(i);var d=this;return i.on("data",function(r){d.processChunk(r)}),i.on("end",function(){d.closedSource(d.previous.streamInfo),d._sources.length?d.prepareNextSource():d.end()}),i.on("error",function(r){d.error(r)}),this},g.prototype.resume=function(){return!!u.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(i){var d=this._sources;if(!u.prototype.error.call(this,i))return!1;for(var r=0;r<d.length;r++)try{d[r].error(i)}catch{}return!0},g.prototype.lock=function(){u.prototype.lock.call(this);for(var i=this._sources,d=0;d<i.length;d++)i[d].lock()},U.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(b,U,k){var l=b("../compressions"),o=b("./ZipFileWorker");k.generateWorker=function(n,u,_){var y=new o(u.streamFiles,_,u.platform,u.encodeFileName),p=0;try{n.forEach(function(g,i){p++;var d=function(c,v){var S=c||v,x=l[S];if(!x)throw new Error(S+" is not a valid compression method !");return x}(i.options.compression,u.compression),r=i.options.compressionOptions||u.compressionOptions||{},h=i.dir,a=i.date;i._compressWorker(d,r).withStreamInfo("file",{name:g,dir:h,date:a,comment:i.comment||"",unixPermissions:i.unixPermissions,dosPermissions:i.dosPermissions}).pipe(y)}),y.entriesCount=p}catch(g){y.error(g)}return y}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(b,U,k){function l(){if(!(this instanceof l))return new l;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new l;for(var n in this)typeof this[n]!="function"&&(o[n]=this[n]);return o}}(l.prototype=b("./object")).loadAsync=b("./load"),l.support=b("./support"),l.defaults=b("./defaults"),l.version="3.10.1",l.loadAsync=function(o,n){return new l().loadAsync(o,n)},l.external=b("./external"),U.exports=l},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(b,U,k){var l=b("./utils"),o=b("./external"),n=b("./utf8"),u=b("./zipEntries"),_=b("./stream/Crc32Probe"),y=b("./nodejsUtils");function p(g){return new o.Promise(function(i,d){var r=g.decompressed.getContentWorker().pipe(new _);r.on("error",function(h){d(h)}).on("end",function(){r.streamInfo.crc32!==g.decompressed.crc32?d(new Error("Corrupted zip : CRC32 mismatch")):i()}).resume()})}U.exports=function(g,i){var d=this;return i=l.extend(i||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:n.utf8decode}),y.isNode&&y.isStream(g)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):l.prepareContent("the loaded zip file",g,!0,i.optimizedBinaryString,i.base64).then(function(r){var h=new u(i);return h.load(r),h}).then(function(r){var h=[o.Promise.resolve(r)],a=r.files;if(i.checkCRC32)for(var c=0;c<a.length;c++)h.push(p(a[c]));return o.Promise.all(h)}).then(function(r){for(var h=r.shift(),a=h.files,c=0;c<a.length;c++){var v=a[c],S=v.fileNameStr,x=l.resolve(v.fileNameStr);d.file(x,v.decompressed,{binary:!0,optimizedBinaryString:!0,date:v.date,dir:v.dir,comment:v.fileCommentStr.length?v.fileCommentStr:null,unixPermissions:v.unixPermissions,dosPermissions:v.dosPermissions,createFolders:i.createFolders}),v.dir||(d.file(x).unsafeOriginalName=S)}return h.zipComment.length&&(d.comment=h.zipComment),d})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(b,U,k){var l=b("../utils"),o=b("../stream/GenericWorker");function n(u,_){o.call(this,"Nodejs stream input adapter for "+u),this._upstreamEnded=!1,this._bindStream(_)}l.inherits(n,o),n.prototype._bindStream=function(u){var _=this;(this._stream=u).pause(),u.on("data",function(y){_.push({data:y,meta:{percent:0}})}).on("error",function(y){_.isPaused?this.generatedError=y:_.error(y)}).on("end",function(){_.isPaused?_._upstreamEnded=!0:_.end()})},n.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},n.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},U.exports=n},{"../stream/GenericWorker":28,"../utils":32}],13:[function(b,U,k){var l=b("readable-stream").Readable;function o(n,u,_){l.call(this,u),this._helper=n;var y=this;n.on("data",function(p,g){y.push(p)||y._helper.pause(),_&&_(g)}).on("error",function(p){y.emit("error",p)}).on("end",function(){y.push(null)})}b("../utils").inherits(o,l),o.prototype._read=function(){this._helper.resume()},U.exports=o},{"../utils":32,"readable-stream":16}],14:[function(b,U,k){U.exports={isNode:typeof Buffer<"u",newBufferFrom:function(l,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(l,o);if(typeof l=="number")throw new Error('The "data" argument must not be a number');return new Buffer(l,o)},allocBuffer:function(l){if(Buffer.alloc)return Buffer.alloc(l);var o=new Buffer(l);return o.fill(0),o},isBuffer:function(l){return Buffer.isBuffer(l)},isStream:function(l){return l&&typeof l.on=="function"&&typeof l.pause=="function"&&typeof l.resume=="function"}}},{}],15:[function(b,U,k){function l(x,D,O){var j,I=n.getTypeOf(D),W=n.extend(O||{},y);W.date=W.date||new Date,W.compression!==null&&(W.compression=W.compression.toUpperCase()),typeof W.unixPermissions=="string"&&(W.unixPermissions=parseInt(W.unixPermissions,8)),W.unixPermissions&&16384&W.unixPermissions&&(W.dir=!0),W.dosPermissions&&16&W.dosPermissions&&(W.dir=!0),W.dir&&(x=a(x)),W.createFolders&&(j=h(x))&&c.call(this,j,!0);var q=I==="string"&&W.binary===!1&&W.base64===!1;O&&O.binary!==void 0||(W.binary=!q),(D instanceof p&&D.uncompressedSize===0||W.dir||!D||D.length===0)&&(W.base64=!1,W.binary=!0,D="",W.compression="STORE",I="string");var m=null;m=D instanceof p||D instanceof u?D:d.isNode&&d.isStream(D)?new r(x,D):n.prepareContent(x,D,W.binary,W.optimizedBinaryString,W.base64);var B=new g(x,m,W);this.files[x]=B}var o=b("./utf8"),n=b("./utils"),u=b("./stream/GenericWorker"),_=b("./stream/StreamHelper"),y=b("./defaults"),p=b("./compressedObject"),g=b("./zipObject"),i=b("./generate"),d=b("./nodejsUtils"),r=b("./nodejs/NodejsStreamInputAdapter"),h=function(x){x.slice(-1)==="/"&&(x=x.substring(0,x.length-1));var D=x.lastIndexOf("/");return 0<D?x.substring(0,D):""},a=function(x){return x.slice(-1)!=="/"&&(x+="/"),x},c=function(x,D){return D=D!==void 0?D:y.createFolders,x=a(x),this.files[x]||l.call(this,x,null,{dir:!0,createFolders:D}),this.files[x]};function v(x){return Object.prototype.toString.call(x)==="[object RegExp]"}var S={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(x){var D,O,j;for(D in this.files)j=this.files[D],(O=D.slice(this.root.length,D.length))&&D.slice(0,this.root.length)===this.root&&x(O,j)},filter:function(x){var D=[];return this.forEach(function(O,j){x(O,j)&&D.push(j)}),D},file:function(x,D,O){if(arguments.length!==1)return x=this.root+x,l.call(this,x,D,O),this;if(v(x)){var j=x;return this.filter(function(W,q){return!q.dir&&j.test(W)})}var I=this.files[this.root+x];return I&&!I.dir?I:null},folder:function(x){if(!x)return this;if(v(x))return this.filter(function(I,W){return W.dir&&x.test(I)});var D=this.root+x,O=c.call(this,D),j=this.clone();return j.root=O.name,j},remove:function(x){x=this.root+x;var D=this.files[x];if(D||(x.slice(-1)!=="/"&&(x+="/"),D=this.files[x]),D&&!D.dir)delete this.files[x];else for(var O=this.filter(function(I,W){return W.name.slice(0,x.length)===x}),j=0;j<O.length;j++)delete this.files[O[j].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(x){var D,O={};try{if((O=n.extend(x||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=O.type.toLowerCase(),O.compression=O.compression.toUpperCase(),O.type==="binarystring"&&(O.type="string"),!O.type)throw new Error("No output type specified.");n.checkSupport(O.type),O.platform!=="darwin"&&O.platform!=="freebsd"&&O.platform!=="linux"&&O.platform!=="sunos"||(O.platform="UNIX"),O.platform==="win32"&&(O.platform="DOS");var j=O.comment||this.comment||"";D=i.generateWorker(this,O,j)}catch(I){(D=new u("error")).error(I)}return new _(D,O.type||"string",O.mimeType)},generateAsync:function(x,D){return this.generateInternalStream(x).accumulate(D)},generateNodeStream:function(x,D){return(x=x||{}).type||(x.type="nodebuffer"),this.generateInternalStream(x).toNodejsStream(D)}};U.exports=S},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(b,U,k){U.exports=b("stream")},{stream:void 0}],17:[function(b,U,k){var l=b("./DataReader");function o(n){l.call(this,n);for(var u=0;u<this.data.length;u++)n[u]=255&n[u]}b("../utils").inherits(o,l),o.prototype.byteAt=function(n){return this.data[this.zero+n]},o.prototype.lastIndexOfSignature=function(n){for(var u=n.charCodeAt(0),_=n.charCodeAt(1),y=n.charCodeAt(2),p=n.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===u&&this.data[g+1]===_&&this.data[g+2]===y&&this.data[g+3]===p)return g-this.zero;return-1},o.prototype.readAndCheckSignature=function(n){var u=n.charCodeAt(0),_=n.charCodeAt(1),y=n.charCodeAt(2),p=n.charCodeAt(3),g=this.readData(4);return u===g[0]&&_===g[1]&&y===g[2]&&p===g[3]},o.prototype.readData=function(n){if(this.checkOffset(n),n===0)return[];var u=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,u},U.exports=o},{"../utils":32,"./DataReader":18}],18:[function(b,U,k){var l=b("../utils");function o(n){this.data=n,this.length=n.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(n){this.checkIndex(this.index+n)},checkIndex:function(n){if(this.length<this.zero+n||n<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+n+"). Corrupted zip ?")},setIndex:function(n){this.checkIndex(n),this.index=n},skip:function(n){this.setIndex(this.index+n)},byteAt:function(){},readInt:function(n){var u,_=0;for(this.checkOffset(n),u=this.index+n-1;u>=this.index;u--)_=(_<<8)+this.byteAt(u);return this.index+=n,_},readString:function(n){return l.transformTo("string",this.readData(n))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var n=this.readInt(4);return new Date(Date.UTC(1980+(n>>25&127),(n>>21&15)-1,n>>16&31,n>>11&31,n>>5&63,(31&n)<<1))}},U.exports=o},{"../utils":32}],19:[function(b,U,k){var l=b("./Uint8ArrayReader");function o(n){l.call(this,n)}b("../utils").inherits(o,l),o.prototype.readData=function(n){this.checkOffset(n);var u=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,u},U.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(b,U,k){var l=b("./DataReader");function o(n){l.call(this,n)}b("../utils").inherits(o,l),o.prototype.byteAt=function(n){return this.data.charCodeAt(this.zero+n)},o.prototype.lastIndexOfSignature=function(n){return this.data.lastIndexOf(n)-this.zero},o.prototype.readAndCheckSignature=function(n){return n===this.readData(4)},o.prototype.readData=function(n){this.checkOffset(n);var u=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,u},U.exports=o},{"../utils":32,"./DataReader":18}],21:[function(b,U,k){var l=b("./ArrayReader");function o(n){l.call(this,n)}b("../utils").inherits(o,l),o.prototype.readData=function(n){if(this.checkOffset(n),n===0)return new Uint8Array(0);var u=this.data.subarray(this.zero+this.index,this.zero+this.index+n);return this.index+=n,u},U.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(b,U,k){var l=b("../utils"),o=b("../support"),n=b("./ArrayReader"),u=b("./StringReader"),_=b("./NodeBufferReader"),y=b("./Uint8ArrayReader");U.exports=function(p){var g=l.getTypeOf(p);return l.checkSupport(g),g!=="string"||o.uint8array?g==="nodebuffer"?new _(p):o.uint8array?new y(l.transformTo("uint8array",p)):new n(l.transformTo("array",p)):new u(p)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(b,U,k){k.LOCAL_FILE_HEADER="PK",k.CENTRAL_FILE_HEADER="PK",k.CENTRAL_DIRECTORY_END="PK",k.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",k.ZIP64_CENTRAL_DIRECTORY_END="PK",k.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(b,U,k){var l=b("./GenericWorker"),o=b("../utils");function n(u){l.call(this,"ConvertWorker to "+u),this.destType=u}o.inherits(n,l),n.prototype.processChunk=function(u){this.push({data:o.transformTo(this.destType,u.data),meta:u.meta})},U.exports=n},{"../utils":32,"./GenericWorker":28}],25:[function(b,U,k){var l=b("./GenericWorker"),o=b("../crc32");function n(){l.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}b("../utils").inherits(n,l),n.prototype.processChunk=function(u){this.streamInfo.crc32=o(u.data,this.streamInfo.crc32||0),this.push(u)},U.exports=n},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(b,U,k){var l=b("../utils"),o=b("./GenericWorker");function n(u){o.call(this,"DataLengthProbe for "+u),this.propName=u,this.withStreamInfo(u,0)}l.inherits(n,o),n.prototype.processChunk=function(u){if(u){var _=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=_+u.data.length}o.prototype.processChunk.call(this,u)},U.exports=n},{"../utils":32,"./GenericWorker":28}],27:[function(b,U,k){var l=b("../utils"),o=b("./GenericWorker");function n(u){o.call(this,"DataWorker");var _=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,u.then(function(y){_.dataIsReady=!0,_.data=y,_.max=y&&y.length||0,_.type=l.getTypeOf(y),_.isPaused||_._tickAndRepeat()},function(y){_.error(y)})}l.inherits(n,o),n.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},n.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,l.delay(this._tickAndRepeat,[],this)),!0)},n.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(l.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},n.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var u=null,_=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":u=this.data.substring(this.index,_);break;case"uint8array":u=this.data.subarray(this.index,_);break;case"array":case"nodebuffer":u=this.data.slice(this.index,_)}return this.index=_,this.push({data:u,meta:{percent:this.max?this.index/this.max*100:0}})},U.exports=n},{"../utils":32,"./GenericWorker":28}],28:[function(b,U,k){function l(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}l.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,n){return this._listeners[o].push(n),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,n){if(this._listeners[o])for(var u=0;u<this._listeners[o].length;u++)this._listeners[o][u].call(this,n)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var n=this;return o.on("data",function(u){n.processChunk(u)}),o.on("end",function(){n.end()}),o.on("error",function(u){n.error(u)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,n){return this.extraStreamInfo[o]=n,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},U.exports=l},{}],29:[function(b,U,k){var l=b("../utils"),o=b("./ConvertWorker"),n=b("./GenericWorker"),u=b("../base64"),_=b("../support"),y=b("../external"),p=null;if(_.nodestream)try{p=b("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(d,r){return new y.Promise(function(h,a){var c=[],v=d._internalType,S=d._outputType,x=d._mimeType;d.on("data",function(D,O){c.push(D),r&&r(O)}).on("error",function(D){c=[],a(D)}).on("end",function(){try{var D=function(O,j,I){switch(O){case"blob":return l.newBlob(l.transformTo("arraybuffer",j),I);case"base64":return u.encode(j);default:return l.transformTo(O,j)}}(S,function(O,j){var I,W=0,q=null,m=0;for(I=0;I<j.length;I++)m+=j[I].length;switch(O){case"string":return j.join("");case"array":return Array.prototype.concat.apply([],j);case"uint8array":for(q=new Uint8Array(m),I=0;I<j.length;I++)q.set(j[I],W),W+=j[I].length;return q;case"nodebuffer":return Buffer.concat(j);default:throw new Error("concat : unsupported type '"+O+"'")}}(v,c),x);h(D)}catch(O){a(O)}c=[]}).resume()})}function i(d,r,h){var a=r;switch(r){case"blob":case"arraybuffer":a="uint8array";break;case"base64":a="string"}try{this._internalType=a,this._outputType=r,this._mimeType=h,l.checkSupport(a),this._worker=d.pipe(new o(a)),d.lock()}catch(c){this._worker=new n("error"),this._worker.error(c)}}i.prototype={accumulate:function(d){return g(this,d)},on:function(d,r){var h=this;return d==="data"?this._worker.on(d,function(a){r.call(h,a.data,a.meta)}):this._worker.on(d,function(){l.delay(r,arguments,h)}),this},resume:function(){return l.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(d){if(l.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new p(this,{objectMode:this._outputType!=="nodebuffer"},d)}},U.exports=i},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(b,U,k){if(k.base64=!0,k.array=!0,k.string=!0,k.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",k.nodebuffer=typeof Buffer<"u",k.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")k.blob=!1;else{var l=new ArrayBuffer(0);try{k.blob=new Blob([l],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(l),k.blob=o.getBlob("application/zip").size===0}catch{k.blob=!1}}}try{k.nodestream=!!b("readable-stream").Readable}catch{k.nodestream=!1}},{"readable-stream":16}],31:[function(b,U,k){for(var l=b("./utils"),o=b("./support"),n=b("./nodejsUtils"),u=b("./stream/GenericWorker"),_=new Array(256),y=0;y<256;y++)_[y]=252<=y?6:248<=y?5:240<=y?4:224<=y?3:192<=y?2:1;_[254]=_[254]=1;function p(){u.call(this,"utf-8 decode"),this.leftOver=null}function g(){u.call(this,"utf-8 encode")}k.utf8encode=function(i){return o.nodebuffer?n.newBufferFrom(i,"utf-8"):function(d){var r,h,a,c,v,S=d.length,x=0;for(c=0;c<S;c++)(64512&(h=d.charCodeAt(c)))==55296&&c+1<S&&(64512&(a=d.charCodeAt(c+1)))==56320&&(h=65536+(h-55296<<10)+(a-56320),c++),x+=h<128?1:h<2048?2:h<65536?3:4;for(r=o.uint8array?new Uint8Array(x):new Array(x),c=v=0;v<x;c++)(64512&(h=d.charCodeAt(c)))==55296&&c+1<S&&(64512&(a=d.charCodeAt(c+1)))==56320&&(h=65536+(h-55296<<10)+(a-56320),c++),h<128?r[v++]=h:(h<2048?r[v++]=192|h>>>6:(h<65536?r[v++]=224|h>>>12:(r[v++]=240|h>>>18,r[v++]=128|h>>>12&63),r[v++]=128|h>>>6&63),r[v++]=128|63&h);return r}(i)},k.utf8decode=function(i){return o.nodebuffer?l.transformTo("nodebuffer",i).toString("utf-8"):function(d){var r,h,a,c,v=d.length,S=new Array(2*v);for(r=h=0;r<v;)if((a=d[r++])<128)S[h++]=a;else if(4<(c=_[a]))S[h++]=65533,r+=c-1;else{for(a&=c===2?31:c===3?15:7;1<c&&r<v;)a=a<<6|63&d[r++],c--;1<c?S[h++]=65533:a<65536?S[h++]=a:(a-=65536,S[h++]=55296|a>>10&1023,S[h++]=56320|1023&a)}return S.length!==h&&(S.subarray?S=S.subarray(0,h):S.length=h),l.applyFromCharCode(S)}(i=l.transformTo(o.uint8array?"uint8array":"array",i))},l.inherits(p,u),p.prototype.processChunk=function(i){var d=l.transformTo(o.uint8array?"uint8array":"array",i.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var r=d;(d=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),d.set(r,this.leftOver.length)}else d=this.leftOver.concat(d);this.leftOver=null}var h=function(c,v){var S;for((v=v||c.length)>c.length&&(v=c.length),S=v-1;0<=S&&(192&c[S])==128;)S--;return S<0||S===0?v:S+_[c[S]]>v?S:v}(d),a=d;h!==d.length&&(o.uint8array?(a=d.subarray(0,h),this.leftOver=d.subarray(h,d.length)):(a=d.slice(0,h),this.leftOver=d.slice(h,d.length))),this.push({data:k.utf8decode(a),meta:i.meta})},p.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:k.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},k.Utf8DecodeWorker=p,l.inherits(g,u),g.prototype.processChunk=function(i){this.push({data:k.utf8encode(i.data),meta:i.meta})},k.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(b,U,k){var l=b("./support"),o=b("./base64"),n=b("./nodejsUtils"),u=b("./external");function _(r){return r}function y(r,h){for(var a=0;a<r.length;++a)h[a]=255&r.charCodeAt(a);return h}b("setimmediate"),k.newBlob=function(r,h){k.checkSupport("blob");try{return new Blob([r],{type:h})}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return a.append(r),a.getBlob(h)}catch{throw new Error("Bug : can't construct the Blob.")}}};var p={stringifyByChunk:function(r,h,a){var c=[],v=0,S=r.length;if(S<=a)return String.fromCharCode.apply(null,r);for(;v<S;)h==="array"||h==="nodebuffer"?c.push(String.fromCharCode.apply(null,r.slice(v,Math.min(v+a,S)))):c.push(String.fromCharCode.apply(null,r.subarray(v,Math.min(v+a,S)))),v+=a;return c.join("")},stringifyByChar:function(r){for(var h="",a=0;a<r.length;a++)h+=String.fromCharCode(r[a]);return h},applyCanBeUsed:{uint8array:function(){try{return l.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}}(),nodebuffer:function(){try{return l.nodebuffer&&String.fromCharCode.apply(null,n.allocBuffer(1)).length===1}catch{return!1}}()}};function g(r){var h=65536,a=k.getTypeOf(r),c=!0;if(a==="uint8array"?c=p.applyCanBeUsed.uint8array:a==="nodebuffer"&&(c=p.applyCanBeUsed.nodebuffer),c)for(;1<h;)try{return p.stringifyByChunk(r,a,h)}catch{h=Math.floor(h/2)}return p.stringifyByChar(r)}function i(r,h){for(var a=0;a<r.length;a++)h[a]=r[a];return h}k.applyFromCharCode=g;var d={};d.string={string:_,array:function(r){return y(r,new Array(r.length))},arraybuffer:function(r){return d.string.uint8array(r).buffer},uint8array:function(r){return y(r,new Uint8Array(r.length))},nodebuffer:function(r){return y(r,n.allocBuffer(r.length))}},d.array={string:g,array:_,arraybuffer:function(r){return new Uint8Array(r).buffer},uint8array:function(r){return new Uint8Array(r)},nodebuffer:function(r){return n.newBufferFrom(r)}},d.arraybuffer={string:function(r){return g(new Uint8Array(r))},array:function(r){return i(new Uint8Array(r),new Array(r.byteLength))},arraybuffer:_,uint8array:function(r){return new Uint8Array(r)},nodebuffer:function(r){return n.newBufferFrom(new Uint8Array(r))}},d.uint8array={string:g,array:function(r){return i(r,new Array(r.length))},arraybuffer:function(r){return r.buffer},uint8array:_,nodebuffer:function(r){return n.newBufferFrom(r)}},d.nodebuffer={string:g,array:function(r){return i(r,new Array(r.length))},arraybuffer:function(r){return d.nodebuffer.uint8array(r).buffer},uint8array:function(r){return i(r,new Uint8Array(r.length))},nodebuffer:_},k.transformTo=function(r,h){if(h=h||"",!r)return h;k.checkSupport(r);var a=k.getTypeOf(h);return d[a][r](h)},k.resolve=function(r){for(var h=r.split("/"),a=[],c=0;c<h.length;c++){var v=h[c];v==="."||v===""&&c!==0&&c!==h.length-1||(v===".."?a.pop():a.push(v))}return a.join("/")},k.getTypeOf=function(r){return typeof r=="string"?"string":Object.prototype.toString.call(r)==="[object Array]"?"array":l.nodebuffer&&n.isBuffer(r)?"nodebuffer":l.uint8array&&r instanceof Uint8Array?"uint8array":l.arraybuffer&&r instanceof ArrayBuffer?"arraybuffer":void 0},k.checkSupport=function(r){if(!l[r.toLowerCase()])throw new Error(r+" is not supported by this platform")},k.MAX_VALUE_16BITS=65535,k.MAX_VALUE_32BITS=-1,k.pretty=function(r){var h,a,c="";for(a=0;a<(r||"").length;a++)c+="\\x"+((h=r.charCodeAt(a))<16?"0":"")+h.toString(16).toUpperCase();return c},k.delay=function(r,h,a){setImmediate(function(){r.apply(a||null,h||[])})},k.inherits=function(r,h){function a(){}a.prototype=h.prototype,r.prototype=new a},k.extend=function(){var r,h,a={};for(r=0;r<arguments.length;r++)for(h in arguments[r])Object.prototype.hasOwnProperty.call(arguments[r],h)&&a[h]===void 0&&(a[h]=arguments[r][h]);return a},k.prepareContent=function(r,h,a,c,v){return u.Promise.resolve(h).then(function(S){return l.blob&&(S instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(S))!==-1)&&typeof FileReader<"u"?new u.Promise(function(x,D){var O=new FileReader;O.onload=function(j){x(j.target.result)},O.onerror=function(j){D(j.target.error)},O.readAsArrayBuffer(S)}):S}).then(function(S){var x=k.getTypeOf(S);return x?(x==="arraybuffer"?S=k.transformTo("uint8array",S):x==="string"&&(v?S=o.decode(S):a&&c!==!0&&(S=function(D){return y(D,l.uint8array?new Uint8Array(D.length):new Array(D.length))}(S))),S):u.Promise.reject(new Error("Can't read the data of '"+r+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(b,U,k){var l=b("./reader/readerFor"),o=b("./utils"),n=b("./signature"),u=b("./zipEntry"),_=b("./support");function y(p){this.files=[],this.loadOptions=p}y.prototype={checkSignature:function(p){if(!this.reader.readAndCheckSignature(p)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(g)+", expected "+o.pretty(p)+")")}},isSignature:function(p,g){var i=this.reader.index;this.reader.setIndex(p);var d=this.reader.readString(4)===g;return this.reader.setIndex(i),d},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var p=this.reader.readData(this.zipCommentLength),g=_.uint8array?"uint8array":"array",i=o.transformTo(g,p);this.zipComment=this.loadOptions.decodeFileName(i)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var p,g,i,d=this.zip64EndOfCentralSize-44;0<d;)p=this.reader.readInt(2),g=this.reader.readInt(4),i=this.reader.readData(g),this.zip64ExtensibleData[p]={id:p,length:g,value:i}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var p,g;for(p=0;p<this.files.length;p++)g=this.files[p],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(n.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var p;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(n.CENTRAL_FILE_HEADER);)(p=new u({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(p);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var p=this.reader.lastIndexOfSignature(n.CENTRAL_DIRECTORY_END);if(p<0)throw this.isSignature(0,n.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(p);var g=p;if(this.checkSignature(n.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(p=this.reader.lastIndexOfSignature(n.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(p),this.checkSignature(n.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,n.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(n.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(n.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var i=this.centralDirOffset+this.centralDirSize;this.zip64&&(i+=20,i+=12+this.zip64EndOfCentralSize);var d=g-i;if(0<d)this.isSignature(g,n.CENTRAL_FILE_HEADER)||(this.reader.zero=d);else if(d<0)throw new Error("Corrupted zip: missing "+Math.abs(d)+" bytes.")},prepareReader:function(p){this.reader=l(p)},load:function(p){this.prepareReader(p),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},U.exports=y},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(b,U,k){var l=b("./reader/readerFor"),o=b("./utils"),n=b("./compressedObject"),u=b("./crc32"),_=b("./utf8"),y=b("./compressions"),p=b("./support");function g(i,d){this.options=i,this.loadOptions=d}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(i){var d,r;if(i.skip(22),this.fileNameLength=i.readInt(2),r=i.readInt(2),this.fileName=i.readData(this.fileNameLength),i.skip(r),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((d=function(h){for(var a in y)if(Object.prototype.hasOwnProperty.call(y,a)&&y[a].magic===h)return y[a];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new n(this.compressedSize,this.uncompressedSize,this.crc32,d,i.readData(this.compressedSize))},readCentralPart:function(i){this.versionMadeBy=i.readInt(2),i.skip(2),this.bitFlag=i.readInt(2),this.compressionMethod=i.readString(2),this.date=i.readDate(),this.crc32=i.readInt(4),this.compressedSize=i.readInt(4),this.uncompressedSize=i.readInt(4);var d=i.readInt(2);if(this.extraFieldsLength=i.readInt(2),this.fileCommentLength=i.readInt(2),this.diskNumberStart=i.readInt(2),this.internalFileAttributes=i.readInt(2),this.externalFileAttributes=i.readInt(4),this.localHeaderOffset=i.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");i.skip(d),this.readExtraFields(i),this.parseZIP64ExtraField(i),this.fileComment=i.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var i=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),i==0&&(this.dosPermissions=63&this.externalFileAttributes),i==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var i=l(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=i.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=i.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=i.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=i.readInt(4))}},readExtraFields:function(i){var d,r,h,a=i.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});i.index+4<a;)d=i.readInt(2),r=i.readInt(2),h=i.readData(r),this.extraFields[d]={id:d,length:r,value:h};i.setIndex(a)},handleUTF8:function(){var i=p.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=_.utf8decode(this.fileName),this.fileCommentStr=_.utf8decode(this.fileComment);else{var d=this.findExtraFieldUnicodePath();if(d!==null)this.fileNameStr=d;else{var r=o.transformTo(i,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(r)}var h=this.findExtraFieldUnicodeComment();if(h!==null)this.fileCommentStr=h;else{var a=o.transformTo(i,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(a)}}},findExtraFieldUnicodePath:function(){var i=this.extraFields[28789];if(i){var d=l(i.value);return d.readInt(1)!==1||u(this.fileName)!==d.readInt(4)?null:_.utf8decode(d.readData(i.length-5))}return null},findExtraFieldUnicodeComment:function(){var i=this.extraFields[25461];if(i){var d=l(i.value);return d.readInt(1)!==1||u(this.fileComment)!==d.readInt(4)?null:_.utf8decode(d.readData(i.length-5))}return null}},U.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(b,U,k){function l(d,r,h){this.name=d,this.dir=h.dir,this.date=h.date,this.comment=h.comment,this.unixPermissions=h.unixPermissions,this.dosPermissions=h.dosPermissions,this._data=r,this._dataBinary=h.binary,this.options={compression:h.compression,compressionOptions:h.compressionOptions}}var o=b("./stream/StreamHelper"),n=b("./stream/DataWorker"),u=b("./utf8"),_=b("./compressedObject"),y=b("./stream/GenericWorker");l.prototype={internalStream:function(d){var r=null,h="string";try{if(!d)throw new Error("No output type specified.");var a=(h=d.toLowerCase())==="string"||h==="text";h!=="binarystring"&&h!=="text"||(h="string"),r=this._decompressWorker();var c=!this._dataBinary;c&&!a&&(r=r.pipe(new u.Utf8EncodeWorker)),!c&&a&&(r=r.pipe(new u.Utf8DecodeWorker))}catch(v){(r=new y("error")).error(v)}return new o(r,h,"")},async:function(d,r){return this.internalStream(d).accumulate(r)},nodeStream:function(d,r){return this.internalStream(d||"nodebuffer").toNodejsStream(r)},_compressWorker:function(d,r){if(this._data instanceof _&&this._data.compression.magic===d.magic)return this._data.getCompressedWorker();var h=this._decompressWorker();return this._dataBinary||(h=h.pipe(new u.Utf8EncodeWorker)),_.createWorkerFrom(h,d,r)},_decompressWorker:function(){return this._data instanceof _?this._data.getContentWorker():this._data instanceof y?this._data:new n(this._data)}};for(var p=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},i=0;i<p.length;i++)l.prototype[p[i]]=g;U.exports=l},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(b,U,k){(function(l){var o,n,u=l.MutationObserver||l.WebKitMutationObserver;if(u){var _=0,y=new u(d),p=l.document.createTextNode("");y.observe(p,{characterData:!0}),o=function(){p.data=_=++_%2}}else if(l.setImmediate||l.MessageChannel===void 0)o="document"in l&&"onreadystatechange"in l.document.createElement("script")?function(){var r=l.document.createElement("script");r.onreadystatechange=function(){d(),r.onreadystatechange=null,r.parentNode.removeChild(r),r=null},l.document.documentElement.appendChild(r)}:function(){setTimeout(d,0)};else{var g=new l.MessageChannel;g.port1.onmessage=d,o=function(){g.port2.postMessage(0)}}var i=[];function d(){var r,h;n=!0;for(var a=i.length;a;){for(h=i,i=[],r=-1;++r<a;)h[r]();a=i.length}n=!1}U.exports=function(r){i.push(r)!==1||n||o()}}).call(this,typeof bt<"u"?bt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(b,U,k){var l=b("immediate");function o(){}var n={},u=["REJECTED"],_=["FULFILLED"],y=["PENDING"];function p(a){if(typeof a!="function")throw new TypeError("resolver must be a function");this.state=y,this.queue=[],this.outcome=void 0,a!==o&&r(this,a)}function g(a,c,v){this.promise=a,typeof c=="function"&&(this.onFulfilled=c,this.callFulfilled=this.otherCallFulfilled),typeof v=="function"&&(this.onRejected=v,this.callRejected=this.otherCallRejected)}function i(a,c,v){l(function(){var S;try{S=c(v)}catch(x){return n.reject(a,x)}S===a?n.reject(a,new TypeError("Cannot resolve promise with itself")):n.resolve(a,S)})}function d(a){var c=a&&a.then;if(a&&(typeof a=="object"||typeof a=="function")&&typeof c=="function")return function(){c.apply(a,arguments)}}function r(a,c){var v=!1;function S(O){v||(v=!0,n.reject(a,O))}function x(O){v||(v=!0,n.resolve(a,O))}var D=h(function(){c(x,S)});D.status==="error"&&S(D.value)}function h(a,c){var v={};try{v.value=a(c),v.status="success"}catch(S){v.status="error",v.value=S}return v}(U.exports=p).prototype.finally=function(a){if(typeof a!="function")return this;var c=this.constructor;return this.then(function(v){return c.resolve(a()).then(function(){return v})},function(v){return c.resolve(a()).then(function(){throw v})})},p.prototype.catch=function(a){return this.then(null,a)},p.prototype.then=function(a,c){if(typeof a!="function"&&this.state===_||typeof c!="function"&&this.state===u)return this;var v=new this.constructor(o);return this.state!==y?i(v,this.state===_?a:c,this.outcome):this.queue.push(new g(v,a,c)),v},g.prototype.callFulfilled=function(a){n.resolve(this.promise,a)},g.prototype.otherCallFulfilled=function(a){i(this.promise,this.onFulfilled,a)},g.prototype.callRejected=function(a){n.reject(this.promise,a)},g.prototype.otherCallRejected=function(a){i(this.promise,this.onRejected,a)},n.resolve=function(a,c){var v=h(d,c);if(v.status==="error")return n.reject(a,v.value);var S=v.value;if(S)r(a,S);else{a.state=_,a.outcome=c;for(var x=-1,D=a.queue.length;++x<D;)a.queue[x].callFulfilled(c)}return a},n.reject=function(a,c){a.state=u,a.outcome=c;for(var v=-1,S=a.queue.length;++v<S;)a.queue[v].callRejected(c);return a},p.resolve=function(a){return a instanceof this?a:n.resolve(new this(o),a)},p.reject=function(a){var c=new this(o);return n.reject(c,a)},p.all=function(a){var c=this;if(Object.prototype.toString.call(a)!=="[object Array]")return this.reject(new TypeError("must be an array"));var v=a.length,S=!1;if(!v)return this.resolve([]);for(var x=new Array(v),D=0,O=-1,j=new this(o);++O<v;)I(a[O],O);return j;function I(W,q){c.resolve(W).then(function(m){x[q]=m,++D!==v||S||(S=!0,n.resolve(j,x))},function(m){S||(S=!0,n.reject(j,m))})}},p.race=function(a){var c=this;if(Object.prototype.toString.call(a)!=="[object Array]")return this.reject(new TypeError("must be an array"));var v=a.length,S=!1;if(!v)return this.resolve([]);for(var x=-1,D=new this(o);++x<v;)O=a[x],c.resolve(O).then(function(j){S||(S=!0,n.resolve(D,j))},function(j){S||(S=!0,n.reject(D,j))});var O;return D}},{immediate:36}],38:[function(b,U,k){var l={};(0,b("./lib/utils/common").assign)(l,b("./lib/deflate"),b("./lib/inflate"),b("./lib/zlib/constants")),U.exports=l},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(b,U,k){var l=b("./zlib/deflate"),o=b("./utils/common"),n=b("./utils/strings"),u=b("./zlib/messages"),_=b("./zlib/zstream"),y=Object.prototype.toString,p=0,g=-1,i=0,d=8;function r(a){if(!(this instanceof r))return new r(a);this.options=o.assign({level:g,method:d,chunkSize:16384,windowBits:15,memLevel:8,strategy:i,to:""},a||{});var c=this.options;c.raw&&0<c.windowBits?c.windowBits=-c.windowBits:c.gzip&&0<c.windowBits&&c.windowBits<16&&(c.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new _,this.strm.avail_out=0;var v=l.deflateInit2(this.strm,c.level,c.method,c.windowBits,c.memLevel,c.strategy);if(v!==p)throw new Error(u[v]);if(c.header&&l.deflateSetHeader(this.strm,c.header),c.dictionary){var S;if(S=typeof c.dictionary=="string"?n.string2buf(c.dictionary):y.call(c.dictionary)==="[object ArrayBuffer]"?new Uint8Array(c.dictionary):c.dictionary,(v=l.deflateSetDictionary(this.strm,S))!==p)throw new Error(u[v]);this._dict_set=!0}}function h(a,c){var v=new r(c);if(v.push(a,!0),v.err)throw v.msg||u[v.err];return v.result}r.prototype.push=function(a,c){var v,S,x=this.strm,D=this.options.chunkSize;if(this.ended)return!1;S=c===~~c?c:c===!0?4:0,typeof a=="string"?x.input=n.string2buf(a):y.call(a)==="[object ArrayBuffer]"?x.input=new Uint8Array(a):x.input=a,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new o.Buf8(D),x.next_out=0,x.avail_out=D),(v=l.deflate(x,S))!==1&&v!==p)return this.onEnd(v),!(this.ended=!0);x.avail_out!==0&&(x.avail_in!==0||S!==4&&S!==2)||(this.options.to==="string"?this.onData(n.buf2binstring(o.shrinkBuf(x.output,x.next_out))):this.onData(o.shrinkBuf(x.output,x.next_out)))}while((0<x.avail_in||x.avail_out===0)&&v!==1);return S===4?(v=l.deflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===p):S!==2||(this.onEnd(p),!(x.avail_out=0))},r.prototype.onData=function(a){this.chunks.push(a)},r.prototype.onEnd=function(a){a===p&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},k.Deflate=r,k.deflate=h,k.deflateRaw=function(a,c){return(c=c||{}).raw=!0,h(a,c)},k.gzip=function(a,c){return(c=c||{}).gzip=!0,h(a,c)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(b,U,k){var l=b("./zlib/inflate"),o=b("./utils/common"),n=b("./utils/strings"),u=b("./zlib/constants"),_=b("./zlib/messages"),y=b("./zlib/zstream"),p=b("./zlib/gzheader"),g=Object.prototype.toString;function i(r){if(!(this instanceof i))return new i(r);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},r||{});var h=this.options;h.raw&&0<=h.windowBits&&h.windowBits<16&&(h.windowBits=-h.windowBits,h.windowBits===0&&(h.windowBits=-15)),!(0<=h.windowBits&&h.windowBits<16)||r&&r.windowBits||(h.windowBits+=32),15<h.windowBits&&h.windowBits<48&&(15&h.windowBits)==0&&(h.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new y,this.strm.avail_out=0;var a=l.inflateInit2(this.strm,h.windowBits);if(a!==u.Z_OK)throw new Error(_[a]);this.header=new p,l.inflateGetHeader(this.strm,this.header)}function d(r,h){var a=new i(h);if(a.push(r,!0),a.err)throw a.msg||_[a.err];return a.result}i.prototype.push=function(r,h){var a,c,v,S,x,D,O=this.strm,j=this.options.chunkSize,I=this.options.dictionary,W=!1;if(this.ended)return!1;c=h===~~h?h:h===!0?u.Z_FINISH:u.Z_NO_FLUSH,typeof r=="string"?O.input=n.binstring2buf(r):g.call(r)==="[object ArrayBuffer]"?O.input=new Uint8Array(r):O.input=r,O.next_in=0,O.avail_in=O.input.length;do{if(O.avail_out===0&&(O.output=new o.Buf8(j),O.next_out=0,O.avail_out=j),(a=l.inflate(O,u.Z_NO_FLUSH))===u.Z_NEED_DICT&&I&&(D=typeof I=="string"?n.string2buf(I):g.call(I)==="[object ArrayBuffer]"?new Uint8Array(I):I,a=l.inflateSetDictionary(this.strm,D)),a===u.Z_BUF_ERROR&&W===!0&&(a=u.Z_OK,W=!1),a!==u.Z_STREAM_END&&a!==u.Z_OK)return this.onEnd(a),!(this.ended=!0);O.next_out&&(O.avail_out!==0&&a!==u.Z_STREAM_END&&(O.avail_in!==0||c!==u.Z_FINISH&&c!==u.Z_SYNC_FLUSH)||(this.options.to==="string"?(v=n.utf8border(O.output,O.next_out),S=O.next_out-v,x=n.buf2string(O.output,v),O.next_out=S,O.avail_out=j-S,S&&o.arraySet(O.output,O.output,v,S,0),this.onData(x)):this.onData(o.shrinkBuf(O.output,O.next_out)))),O.avail_in===0&&O.avail_out===0&&(W=!0)}while((0<O.avail_in||O.avail_out===0)&&a!==u.Z_STREAM_END);return a===u.Z_STREAM_END&&(c=u.Z_FINISH),c===u.Z_FINISH?(a=l.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===u.Z_OK):c!==u.Z_SYNC_FLUSH||(this.onEnd(u.Z_OK),!(O.avail_out=0))},i.prototype.onData=function(r){this.chunks.push(r)},i.prototype.onEnd=function(r){r===u.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg},k.Inflate=i,k.inflate=d,k.inflateRaw=function(r,h){return(h=h||{}).raw=!0,d(r,h)},k.ungzip=d},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(b,U,k){var l=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";k.assign=function(u){for(var _=Array.prototype.slice.call(arguments,1);_.length;){var y=_.shift();if(y){if(typeof y!="object")throw new TypeError(y+"must be non-object");for(var p in y)y.hasOwnProperty(p)&&(u[p]=y[p])}}return u},k.shrinkBuf=function(u,_){return u.length===_?u:u.subarray?u.subarray(0,_):(u.length=_,u)};var o={arraySet:function(u,_,y,p,g){if(_.subarray&&u.subarray)u.set(_.subarray(y,y+p),g);else for(var i=0;i<p;i++)u[g+i]=_[y+i]},flattenChunks:function(u){var _,y,p,g,i,d;for(_=p=0,y=u.length;_<y;_++)p+=u[_].length;for(d=new Uint8Array(p),_=g=0,y=u.length;_<y;_++)i=u[_],d.set(i,g),g+=i.length;return d}},n={arraySet:function(u,_,y,p,g){for(var i=0;i<p;i++)u[g+i]=_[y+i]},flattenChunks:function(u){return[].concat.apply([],u)}};k.setTyped=function(u){u?(k.Buf8=Uint8Array,k.Buf16=Uint16Array,k.Buf32=Int32Array,k.assign(k,o)):(k.Buf8=Array,k.Buf16=Array,k.Buf32=Array,k.assign(k,n))},k.setTyped(l)},{}],42:[function(b,U,k){var l=b("./common"),o=!0,n=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{n=!1}for(var u=new l.Buf8(256),_=0;_<256;_++)u[_]=252<=_?6:248<=_?5:240<=_?4:224<=_?3:192<=_?2:1;function y(p,g){if(g<65537&&(p.subarray&&n||!p.subarray&&o))return String.fromCharCode.apply(null,l.shrinkBuf(p,g));for(var i="",d=0;d<g;d++)i+=String.fromCharCode(p[d]);return i}u[254]=u[254]=1,k.string2buf=function(p){var g,i,d,r,h,a=p.length,c=0;for(r=0;r<a;r++)(64512&(i=p.charCodeAt(r)))==55296&&r+1<a&&(64512&(d=p.charCodeAt(r+1)))==56320&&(i=65536+(i-55296<<10)+(d-56320),r++),c+=i<128?1:i<2048?2:i<65536?3:4;for(g=new l.Buf8(c),r=h=0;h<c;r++)(64512&(i=p.charCodeAt(r)))==55296&&r+1<a&&(64512&(d=p.charCodeAt(r+1)))==56320&&(i=65536+(i-55296<<10)+(d-56320),r++),i<128?g[h++]=i:(i<2048?g[h++]=192|i>>>6:(i<65536?g[h++]=224|i>>>12:(g[h++]=240|i>>>18,g[h++]=128|i>>>12&63),g[h++]=128|i>>>6&63),g[h++]=128|63&i);return g},k.buf2binstring=function(p){return y(p,p.length)},k.binstring2buf=function(p){for(var g=new l.Buf8(p.length),i=0,d=g.length;i<d;i++)g[i]=p.charCodeAt(i);return g},k.buf2string=function(p,g){var i,d,r,h,a=g||p.length,c=new Array(2*a);for(i=d=0;i<a;)if((r=p[i++])<128)c[d++]=r;else if(4<(h=u[r]))c[d++]=65533,i+=h-1;else{for(r&=h===2?31:h===3?15:7;1<h&&i<a;)r=r<<6|63&p[i++],h--;1<h?c[d++]=65533:r<65536?c[d++]=r:(r-=65536,c[d++]=55296|r>>10&1023,c[d++]=56320|1023&r)}return y(c,d)},k.utf8border=function(p,g){var i;for((g=g||p.length)>p.length&&(g=p.length),i=g-1;0<=i&&(192&p[i])==128;)i--;return i<0||i===0?g:i+u[p[i]]>g?i:g}},{"./common":41}],43:[function(b,U,k){U.exports=function(l,o,n,u){for(var _=65535&l|0,y=l>>>16&65535|0,p=0;n!==0;){for(n-=p=2e3<n?2e3:n;y=y+(_=_+o[u++]|0)|0,--p;);_%=65521,y%=65521}return _|y<<16|0}},{}],44:[function(b,U,k){U.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(b,U,k){var l=function(){for(var o,n=[],u=0;u<256;u++){o=u;for(var _=0;_<8;_++)o=1&o?3988292384^o>>>1:o>>>1;n[u]=o}return n}();U.exports=function(o,n,u,_){var y=l,p=_+u;o^=-1;for(var g=_;g<p;g++)o=o>>>8^y[255&(o^n[g])];return-1^o}},{}],46:[function(b,U,k){var l,o=b("../utils/common"),n=b("./trees"),u=b("./adler32"),_=b("./crc32"),y=b("./messages"),p=0,g=4,i=0,d=-2,r=-1,h=4,a=2,c=8,v=9,S=286,x=30,D=19,O=2*S+1,j=15,I=3,W=258,q=W+I+1,m=42,B=113,e=1,T=2,J=3,P=4;function $(t,R){return t.msg=y[R],R}function L(t){return(t<<1)-(4<t?9:0)}function V(t){for(var R=t.length;0<=--R;)t[R]=0}function E(t){var R=t.state,A=R.pending;A>t.avail_out&&(A=t.avail_out),A!==0&&(o.arraySet(t.output,R.pending_buf,R.pending_out,A,t.next_out),t.next_out+=A,R.pending_out+=A,t.total_out+=A,t.avail_out-=A,R.pending-=A,R.pending===0&&(R.pending_out=0))}function C(t,R){n._tr_flush_block(t,0<=t.block_start?t.block_start:-1,t.strstart-t.block_start,R),t.block_start=t.strstart,E(t.strm)}function X(t,R){t.pending_buf[t.pending++]=R}function G(t,R){t.pending_buf[t.pending++]=R>>>8&255,t.pending_buf[t.pending++]=255&R}function H(t,R){var A,f,s=t.max_chain_length,w=t.strstart,F=t.prev_length,N=t.nice_match,z=t.strstart>t.w_size-q?t.strstart-(t.w_size-q):0,Z=t.window,K=t.w_mask,M=t.prev,Y=t.strstart+W,rt=Z[w+F-1],tt=Z[w+F];t.prev_length>=t.good_match&&(s>>=2),N>t.lookahead&&(N=t.lookahead);do if(Z[(A=R)+F]===tt&&Z[A+F-1]===rt&&Z[A]===Z[w]&&Z[++A]===Z[w+1]){w+=2,A++;do;while(Z[++w]===Z[++A]&&Z[++w]===Z[++A]&&Z[++w]===Z[++A]&&Z[++w]===Z[++A]&&Z[++w]===Z[++A]&&Z[++w]===Z[++A]&&Z[++w]===Z[++A]&&Z[++w]===Z[++A]&&w<Y);if(f=W-(Y-w),w=Y-W,F<f){if(t.match_start=R,N<=(F=f))break;rt=Z[w+F-1],tt=Z[w+F]}}while((R=M[R&K])>z&&--s!=0);return F<=t.lookahead?F:t.lookahead}function nt(t){var R,A,f,s,w,F,N,z,Z,K,M=t.w_size;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=M+(M-q)){for(o.arraySet(t.window,t.window,M,M,0),t.match_start-=M,t.strstart-=M,t.block_start-=M,R=A=t.hash_size;f=t.head[--R],t.head[R]=M<=f?f-M:0,--A;);for(R=A=M;f=t.prev[--R],t.prev[R]=M<=f?f-M:0,--A;);s+=M}if(t.strm.avail_in===0)break;if(F=t.strm,N=t.window,z=t.strstart+t.lookahead,Z=s,K=void 0,K=F.avail_in,Z<K&&(K=Z),A=K===0?0:(F.avail_in-=K,o.arraySet(N,F.input,F.next_in,K,z),F.state.wrap===1?F.adler=u(F.adler,N,K,z):F.state.wrap===2&&(F.adler=_(F.adler,N,K,z)),F.next_in+=K,F.total_in+=K,K),t.lookahead+=A,t.lookahead+t.insert>=I)for(w=t.strstart-t.insert,t.ins_h=t.window[w],t.ins_h=(t.ins_h<<t.hash_shift^t.window[w+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[w+I-1])&t.hash_mask,t.prev[w&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=w,w++,t.insert--,!(t.lookahead+t.insert<I)););}while(t.lookahead<q&&t.strm.avail_in!==0)}function ot(t,R){for(var A,f;;){if(t.lookahead<q){if(nt(t),t.lookahead<q&&R===p)return e;if(t.lookahead===0)break}if(A=0,t.lookahead>=I&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+I-1])&t.hash_mask,A=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),A!==0&&t.strstart-A<=t.w_size-q&&(t.match_length=H(t,A)),t.match_length>=I)if(f=n._tr_tally(t,t.strstart-t.match_start,t.match_length-I),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=I){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+I-1])&t.hash_mask,A=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart,--t.match_length!=0;);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else f=n._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(f&&(C(t,!1),t.strm.avail_out===0))return e}return t.insert=t.strstart<I-1?t.strstart:I-1,R===g?(C(t,!0),t.strm.avail_out===0?J:P):t.last_lit&&(C(t,!1),t.strm.avail_out===0)?e:T}function Q(t,R){for(var A,f,s;;){if(t.lookahead<q){if(nt(t),t.lookahead<q&&R===p)return e;if(t.lookahead===0)break}if(A=0,t.lookahead>=I&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+I-1])&t.hash_mask,A=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=I-1,A!==0&&t.prev_length<t.max_lazy_match&&t.strstart-A<=t.w_size-q&&(t.match_length=H(t,A),t.match_length<=5&&(t.strategy===1||t.match_length===I&&4096<t.strstart-t.match_start)&&(t.match_length=I-1)),t.prev_length>=I&&t.match_length<=t.prev_length){for(s=t.strstart+t.lookahead-I,f=n._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-I),t.lookahead-=t.prev_length-1,t.prev_length-=2;++t.strstart<=s&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+I-1])&t.hash_mask,A=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),--t.prev_length!=0;);if(t.match_available=0,t.match_length=I-1,t.strstart++,f&&(C(t,!1),t.strm.avail_out===0))return e}else if(t.match_available){if((f=n._tr_tally(t,0,t.window[t.strstart-1]))&&C(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return e}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(f=n._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<I-1?t.strstart:I-1,R===g?(C(t,!0),t.strm.avail_out===0?J:P):t.last_lit&&(C(t,!1),t.strm.avail_out===0)?e:T}function et(t,R,A,f,s){this.good_length=t,this.max_lazy=R,this.nice_length=A,this.max_chain=f,this.func=s}function st(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=c,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(2*O),this.dyn_dtree=new o.Buf16(2*(2*x+1)),this.bl_tree=new o.Buf16(2*(2*D+1)),V(this.dyn_ltree),V(this.dyn_dtree),V(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(j+1),this.heap=new o.Buf16(2*S+1),V(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*S+1),V(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function it(t){var R;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=a,(R=t.state).pending=0,R.pending_out=0,R.wrap<0&&(R.wrap=-R.wrap),R.status=R.wrap?m:B,t.adler=R.wrap===2?0:1,R.last_flush=p,n._tr_init(R),i):$(t,d)}function lt(t){var R=it(t);return R===i&&function(A){A.window_size=2*A.w_size,V(A.head),A.max_lazy_match=l[A.level].max_lazy,A.good_match=l[A.level].good_length,A.nice_match=l[A.level].nice_length,A.max_chain_length=l[A.level].max_chain,A.strstart=0,A.block_start=0,A.lookahead=0,A.insert=0,A.match_length=A.prev_length=I-1,A.match_available=0,A.ins_h=0}(t.state),R}function ht(t,R,A,f,s,w){if(!t)return d;var F=1;if(R===r&&(R=6),f<0?(F=0,f=-f):15<f&&(F=2,f-=16),s<1||v<s||A!==c||f<8||15<f||R<0||9<R||w<0||h<w)return $(t,d);f===8&&(f=9);var N=new st;return(t.state=N).strm=t,N.wrap=F,N.gzhead=null,N.w_bits=f,N.w_size=1<<N.w_bits,N.w_mask=N.w_size-1,N.hash_bits=s+7,N.hash_size=1<<N.hash_bits,N.hash_mask=N.hash_size-1,N.hash_shift=~~((N.hash_bits+I-1)/I),N.window=new o.Buf8(2*N.w_size),N.head=new o.Buf16(N.hash_size),N.prev=new o.Buf16(N.w_size),N.lit_bufsize=1<<s+6,N.pending_buf_size=4*N.lit_bufsize,N.pending_buf=new o.Buf8(N.pending_buf_size),N.d_buf=1*N.lit_bufsize,N.l_buf=3*N.lit_bufsize,N.level=R,N.strategy=w,N.method=A,lt(t)}l=[new et(0,0,0,0,function(t,R){var A=65535;for(A>t.pending_buf_size-5&&(A=t.pending_buf_size-5);;){if(t.lookahead<=1){if(nt(t),t.lookahead===0&&R===p)return e;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;var f=t.block_start+A;if((t.strstart===0||t.strstart>=f)&&(t.lookahead=t.strstart-f,t.strstart=f,C(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-q&&(C(t,!1),t.strm.avail_out===0))return e}return t.insert=0,R===g?(C(t,!0),t.strm.avail_out===0?J:P):(t.strstart>t.block_start&&(C(t,!1),t.strm.avail_out),e)}),new et(4,4,8,4,ot),new et(4,5,16,8,ot),new et(4,6,32,32,ot),new et(4,4,16,16,Q),new et(8,16,32,32,Q),new et(8,16,128,128,Q),new et(8,32,128,256,Q),new et(32,128,258,1024,Q),new et(32,258,258,4096,Q)],k.deflateInit=function(t,R){return ht(t,R,c,15,8,0)},k.deflateInit2=ht,k.deflateReset=lt,k.deflateResetKeep=it,k.deflateSetHeader=function(t,R){return t&&t.state?t.state.wrap!==2?d:(t.state.gzhead=R,i):d},k.deflate=function(t,R){var A,f,s,w;if(!t||!t.state||5<R||R<0)return t?$(t,d):d;if(f=t.state,!t.output||!t.input&&t.avail_in!==0||f.status===666&&R!==g)return $(t,t.avail_out===0?-5:d);if(f.strm=t,A=f.last_flush,f.last_flush=R,f.status===m)if(f.wrap===2)t.adler=0,X(f,31),X(f,139),X(f,8),f.gzhead?(X(f,(f.gzhead.text?1:0)+(f.gzhead.hcrc?2:0)+(f.gzhead.extra?4:0)+(f.gzhead.name?8:0)+(f.gzhead.comment?16:0)),X(f,255&f.gzhead.time),X(f,f.gzhead.time>>8&255),X(f,f.gzhead.time>>16&255),X(f,f.gzhead.time>>24&255),X(f,f.level===9?2:2<=f.strategy||f.level<2?4:0),X(f,255&f.gzhead.os),f.gzhead.extra&&f.gzhead.extra.length&&(X(f,255&f.gzhead.extra.length),X(f,f.gzhead.extra.length>>8&255)),f.gzhead.hcrc&&(t.adler=_(t.adler,f.pending_buf,f.pending,0)),f.gzindex=0,f.status=69):(X(f,0),X(f,0),X(f,0),X(f,0),X(f,0),X(f,f.level===9?2:2<=f.strategy||f.level<2?4:0),X(f,3),f.status=B);else{var F=c+(f.w_bits-8<<4)<<8;F|=(2<=f.strategy||f.level<2?0:f.level<6?1:f.level===6?2:3)<<6,f.strstart!==0&&(F|=32),F+=31-F%31,f.status=B,G(f,F),f.strstart!==0&&(G(f,t.adler>>>16),G(f,65535&t.adler)),t.adler=1}if(f.status===69)if(f.gzhead.extra){for(s=f.pending;f.gzindex<(65535&f.gzhead.extra.length)&&(f.pending!==f.pending_buf_size||(f.gzhead.hcrc&&f.pending>s&&(t.adler=_(t.adler,f.pending_buf,f.pending-s,s)),E(t),s=f.pending,f.pending!==f.pending_buf_size));)X(f,255&f.gzhead.extra[f.gzindex]),f.gzindex++;f.gzhead.hcrc&&f.pending>s&&(t.adler=_(t.adler,f.pending_buf,f.pending-s,s)),f.gzindex===f.gzhead.extra.length&&(f.gzindex=0,f.status=73)}else f.status=73;if(f.status===73)if(f.gzhead.name){s=f.pending;do{if(f.pending===f.pending_buf_size&&(f.gzhead.hcrc&&f.pending>s&&(t.adler=_(t.adler,f.pending_buf,f.pending-s,s)),E(t),s=f.pending,f.pending===f.pending_buf_size)){w=1;break}w=f.gzindex<f.gzhead.name.length?255&f.gzhead.name.charCodeAt(f.gzindex++):0,X(f,w)}while(w!==0);f.gzhead.hcrc&&f.pending>s&&(t.adler=_(t.adler,f.pending_buf,f.pending-s,s)),w===0&&(f.gzindex=0,f.status=91)}else f.status=91;if(f.status===91)if(f.gzhead.comment){s=f.pending;do{if(f.pending===f.pending_buf_size&&(f.gzhead.hcrc&&f.pending>s&&(t.adler=_(t.adler,f.pending_buf,f.pending-s,s)),E(t),s=f.pending,f.pending===f.pending_buf_size)){w=1;break}w=f.gzindex<f.gzhead.comment.length?255&f.gzhead.comment.charCodeAt(f.gzindex++):0,X(f,w)}while(w!==0);f.gzhead.hcrc&&f.pending>s&&(t.adler=_(t.adler,f.pending_buf,f.pending-s,s)),w===0&&(f.status=103)}else f.status=103;if(f.status===103&&(f.gzhead.hcrc?(f.pending+2>f.pending_buf_size&&E(t),f.pending+2<=f.pending_buf_size&&(X(f,255&t.adler),X(f,t.adler>>8&255),t.adler=0,f.status=B)):f.status=B),f.pending!==0){if(E(t),t.avail_out===0)return f.last_flush=-1,i}else if(t.avail_in===0&&L(R)<=L(A)&&R!==g)return $(t,-5);if(f.status===666&&t.avail_in!==0)return $(t,-5);if(t.avail_in!==0||f.lookahead!==0||R!==p&&f.status!==666){var N=f.strategy===2?function(z,Z){for(var K;;){if(z.lookahead===0&&(nt(z),z.lookahead===0)){if(Z===p)return e;break}if(z.match_length=0,K=n._tr_tally(z,0,z.window[z.strstart]),z.lookahead--,z.strstart++,K&&(C(z,!1),z.strm.avail_out===0))return e}return z.insert=0,Z===g?(C(z,!0),z.strm.avail_out===0?J:P):z.last_lit&&(C(z,!1),z.strm.avail_out===0)?e:T}(f,R):f.strategy===3?function(z,Z){for(var K,M,Y,rt,tt=z.window;;){if(z.lookahead<=W){if(nt(z),z.lookahead<=W&&Z===p)return e;if(z.lookahead===0)break}if(z.match_length=0,z.lookahead>=I&&0<z.strstart&&(M=tt[Y=z.strstart-1])===tt[++Y]&&M===tt[++Y]&&M===tt[++Y]){rt=z.strstart+W;do;while(M===tt[++Y]&&M===tt[++Y]&&M===tt[++Y]&&M===tt[++Y]&&M===tt[++Y]&&M===tt[++Y]&&M===tt[++Y]&&M===tt[++Y]&&Y<rt);z.match_length=W-(rt-Y),z.match_length>z.lookahead&&(z.match_length=z.lookahead)}if(z.match_length>=I?(K=n._tr_tally(z,1,z.match_length-I),z.lookahead-=z.match_length,z.strstart+=z.match_length,z.match_length=0):(K=n._tr_tally(z,0,z.window[z.strstart]),z.lookahead--,z.strstart++),K&&(C(z,!1),z.strm.avail_out===0))return e}return z.insert=0,Z===g?(C(z,!0),z.strm.avail_out===0?J:P):z.last_lit&&(C(z,!1),z.strm.avail_out===0)?e:T}(f,R):l[f.level].func(f,R);if(N!==J&&N!==P||(f.status=666),N===e||N===J)return t.avail_out===0&&(f.last_flush=-1),i;if(N===T&&(R===1?n._tr_align(f):R!==5&&(n._tr_stored_block(f,0,0,!1),R===3&&(V(f.head),f.lookahead===0&&(f.strstart=0,f.block_start=0,f.insert=0))),E(t),t.avail_out===0))return f.last_flush=-1,i}return R!==g?i:f.wrap<=0?1:(f.wrap===2?(X(f,255&t.adler),X(f,t.adler>>8&255),X(f,t.adler>>16&255),X(f,t.adler>>24&255),X(f,255&t.total_in),X(f,t.total_in>>8&255),X(f,t.total_in>>16&255),X(f,t.total_in>>24&255)):(G(f,t.adler>>>16),G(f,65535&t.adler)),E(t),0<f.wrap&&(f.wrap=-f.wrap),f.pending!==0?i:1)},k.deflateEnd=function(t){var R;return t&&t.state?(R=t.state.status)!==m&&R!==69&&R!==73&&R!==91&&R!==103&&R!==B&&R!==666?$(t,d):(t.state=null,R===B?$(t,-3):i):d},k.deflateSetDictionary=function(t,R){var A,f,s,w,F,N,z,Z,K=R.length;if(!t||!t.state||(w=(A=t.state).wrap)===2||w===1&&A.status!==m||A.lookahead)return d;for(w===1&&(t.adler=u(t.adler,R,K,0)),A.wrap=0,K>=A.w_size&&(w===0&&(V(A.head),A.strstart=0,A.block_start=0,A.insert=0),Z=new o.Buf8(A.w_size),o.arraySet(Z,R,K-A.w_size,A.w_size,0),R=Z,K=A.w_size),F=t.avail_in,N=t.next_in,z=t.input,t.avail_in=K,t.next_in=0,t.input=R,nt(A);A.lookahead>=I;){for(f=A.strstart,s=A.lookahead-(I-1);A.ins_h=(A.ins_h<<A.hash_shift^A.window[f+I-1])&A.hash_mask,A.prev[f&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=f,f++,--s;);A.strstart=f,A.lookahead=I-1,nt(A)}return A.strstart+=A.lookahead,A.block_start=A.strstart,A.insert=A.lookahead,A.lookahead=0,A.match_length=A.prev_length=I-1,A.match_available=0,t.next_in=N,t.input=z,t.avail_in=F,A.wrap=w,i},k.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(b,U,k){U.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(b,U,k){U.exports=function(l,o){var n,u,_,y,p,g,i,d,r,h,a,c,v,S,x,D,O,j,I,W,q,m,B,e,T;n=l.state,u=l.next_in,e=l.input,_=u+(l.avail_in-5),y=l.next_out,T=l.output,p=y-(o-l.avail_out),g=y+(l.avail_out-257),i=n.dmax,d=n.wsize,r=n.whave,h=n.wnext,a=n.window,c=n.hold,v=n.bits,S=n.lencode,x=n.distcode,D=(1<<n.lenbits)-1,O=(1<<n.distbits)-1;t:do{v<15&&(c+=e[u++]<<v,v+=8,c+=e[u++]<<v,v+=8),j=S[c&D];e:for(;;){if(c>>>=I=j>>>24,v-=I,(I=j>>>16&255)===0)T[y++]=65535&j;else{if(!(16&I)){if((64&I)==0){j=S[(65535&j)+(c&(1<<I)-1)];continue e}if(32&I){n.mode=12;break t}l.msg="invalid literal/length code",n.mode=30;break t}W=65535&j,(I&=15)&&(v<I&&(c+=e[u++]<<v,v+=8),W+=c&(1<<I)-1,c>>>=I,v-=I),v<15&&(c+=e[u++]<<v,v+=8,c+=e[u++]<<v,v+=8),j=x[c&O];r:for(;;){if(c>>>=I=j>>>24,v-=I,!(16&(I=j>>>16&255))){if((64&I)==0){j=x[(65535&j)+(c&(1<<I)-1)];continue r}l.msg="invalid distance code",n.mode=30;break t}if(q=65535&j,v<(I&=15)&&(c+=e[u++]<<v,(v+=8)<I&&(c+=e[u++]<<v,v+=8)),i<(q+=c&(1<<I)-1)){l.msg="invalid distance too far back",n.mode=30;break t}if(c>>>=I,v-=I,(I=y-p)<q){if(r<(I=q-I)&&n.sane){l.msg="invalid distance too far back",n.mode=30;break t}if(B=a,(m=0)===h){if(m+=d-I,I<W){for(W-=I;T[y++]=a[m++],--I;);m=y-q,B=T}}else if(h<I){if(m+=d+h-I,(I-=h)<W){for(W-=I;T[y++]=a[m++],--I;);if(m=0,h<W){for(W-=I=h;T[y++]=a[m++],--I;);m=y-q,B=T}}}else if(m+=h-I,I<W){for(W-=I;T[y++]=a[m++],--I;);m=y-q,B=T}for(;2<W;)T[y++]=B[m++],T[y++]=B[m++],T[y++]=B[m++],W-=3;W&&(T[y++]=B[m++],1<W&&(T[y++]=B[m++]))}else{for(m=y-q;T[y++]=T[m++],T[y++]=T[m++],T[y++]=T[m++],2<(W-=3););W&&(T[y++]=T[m++],1<W&&(T[y++]=T[m++]))}break}}break}}while(u<_&&y<g);u-=W=v>>3,c&=(1<<(v-=W<<3))-1,l.next_in=u,l.next_out=y,l.avail_in=u<_?_-u+5:5-(u-_),l.avail_out=y<g?g-y+257:257-(y-g),n.hold=c,n.bits=v}},{}],49:[function(b,U,k){var l=b("../utils/common"),o=b("./adler32"),n=b("./crc32"),u=b("./inffast"),_=b("./inftrees"),y=1,p=2,g=0,i=-2,d=1,r=852,h=592;function a(m){return(m>>>24&255)+(m>>>8&65280)+((65280&m)<<8)+((255&m)<<24)}function c(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new l.Buf16(320),this.work=new l.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function v(m){var B;return m&&m.state?(B=m.state,m.total_in=m.total_out=B.total=0,m.msg="",B.wrap&&(m.adler=1&B.wrap),B.mode=d,B.last=0,B.havedict=0,B.dmax=32768,B.head=null,B.hold=0,B.bits=0,B.lencode=B.lendyn=new l.Buf32(r),B.distcode=B.distdyn=new l.Buf32(h),B.sane=1,B.back=-1,g):i}function S(m){var B;return m&&m.state?((B=m.state).wsize=0,B.whave=0,B.wnext=0,v(m)):i}function x(m,B){var e,T;return m&&m.state?(T=m.state,B<0?(e=0,B=-B):(e=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15<B)?i:(T.window!==null&&T.wbits!==B&&(T.window=null),T.wrap=e,T.wbits=B,S(m))):i}function D(m,B){var e,T;return m?(T=new c,(m.state=T).window=null,(e=x(m,B))!==g&&(m.state=null),e):i}var O,j,I=!0;function W(m){if(I){var B;for(O=new l.Buf32(512),j=new l.Buf32(32),B=0;B<144;)m.lens[B++]=8;for(;B<256;)m.lens[B++]=9;for(;B<280;)m.lens[B++]=7;for(;B<288;)m.lens[B++]=8;for(_(y,m.lens,0,288,O,0,m.work,{bits:9}),B=0;B<32;)m.lens[B++]=5;_(p,m.lens,0,32,j,0,m.work,{bits:5}),I=!1}m.lencode=O,m.lenbits=9,m.distcode=j,m.distbits=5}function q(m,B,e,T){var J,P=m.state;return P.window===null&&(P.wsize=1<<P.wbits,P.wnext=0,P.whave=0,P.window=new l.Buf8(P.wsize)),T>=P.wsize?(l.arraySet(P.window,B,e-P.wsize,P.wsize,0),P.wnext=0,P.whave=P.wsize):(T<(J=P.wsize-P.wnext)&&(J=T),l.arraySet(P.window,B,e-T,J,P.wnext),(T-=J)?(l.arraySet(P.window,B,e-T,T,0),P.wnext=T,P.whave=P.wsize):(P.wnext+=J,P.wnext===P.wsize&&(P.wnext=0),P.whave<P.wsize&&(P.whave+=J))),0}k.inflateReset=S,k.inflateReset2=x,k.inflateResetKeep=v,k.inflateInit=function(m){return D(m,15)},k.inflateInit2=D,k.inflate=function(m,B){var e,T,J,P,$,L,V,E,C,X,G,H,nt,ot,Q,et,st,it,lt,ht,t,R,A,f,s=0,w=new l.Buf8(4),F=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!m||!m.state||!m.output||!m.input&&m.avail_in!==0)return i;(e=m.state).mode===12&&(e.mode=13),$=m.next_out,J=m.output,V=m.avail_out,P=m.next_in,T=m.input,L=m.avail_in,E=e.hold,C=e.bits,X=L,G=V,R=g;t:for(;;)switch(e.mode){case d:if(e.wrap===0){e.mode=13;break}for(;C<16;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}if(2&e.wrap&&E===35615){w[e.check=0]=255&E,w[1]=E>>>8&255,e.check=n(e.check,w,2,0),C=E=0,e.mode=2;break}if(e.flags=0,e.head&&(e.head.done=!1),!(1&e.wrap)||(((255&E)<<8)+(E>>8))%31){m.msg="incorrect header check",e.mode=30;break}if((15&E)!=8){m.msg="unknown compression method",e.mode=30;break}if(C-=4,t=8+(15&(E>>>=4)),e.wbits===0)e.wbits=t;else if(t>e.wbits){m.msg="invalid window size",e.mode=30;break}e.dmax=1<<t,m.adler=e.check=1,e.mode=512&E?10:12,C=E=0;break;case 2:for(;C<16;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}if(e.flags=E,(255&e.flags)!=8){m.msg="unknown compression method",e.mode=30;break}if(57344&e.flags){m.msg="unknown header flags set",e.mode=30;break}e.head&&(e.head.text=E>>8&1),512&e.flags&&(w[0]=255&E,w[1]=E>>>8&255,e.check=n(e.check,w,2,0)),C=E=0,e.mode=3;case 3:for(;C<32;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}e.head&&(e.head.time=E),512&e.flags&&(w[0]=255&E,w[1]=E>>>8&255,w[2]=E>>>16&255,w[3]=E>>>24&255,e.check=n(e.check,w,4,0)),C=E=0,e.mode=4;case 4:for(;C<16;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}e.head&&(e.head.xflags=255&E,e.head.os=E>>8),512&e.flags&&(w[0]=255&E,w[1]=E>>>8&255,e.check=n(e.check,w,2,0)),C=E=0,e.mode=5;case 5:if(1024&e.flags){for(;C<16;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}e.length=E,e.head&&(e.head.extra_len=E),512&e.flags&&(w[0]=255&E,w[1]=E>>>8&255,e.check=n(e.check,w,2,0)),C=E=0}else e.head&&(e.head.extra=null);e.mode=6;case 6:if(1024&e.flags&&(L<(H=e.length)&&(H=L),H&&(e.head&&(t=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Array(e.head.extra_len)),l.arraySet(e.head.extra,T,P,H,t)),512&e.flags&&(e.check=n(e.check,T,H,P)),L-=H,P+=H,e.length-=H),e.length))break t;e.length=0,e.mode=7;case 7:if(2048&e.flags){if(L===0)break t;for(H=0;t=T[P+H++],e.head&&t&&e.length<65536&&(e.head.name+=String.fromCharCode(t)),t&&H<L;);if(512&e.flags&&(e.check=n(e.check,T,H,P)),L-=H,P+=H,t)break t}else e.head&&(e.head.name=null);e.length=0,e.mode=8;case 8:if(4096&e.flags){if(L===0)break t;for(H=0;t=T[P+H++],e.head&&t&&e.length<65536&&(e.head.comment+=String.fromCharCode(t)),t&&H<L;);if(512&e.flags&&(e.check=n(e.check,T,H,P)),L-=H,P+=H,t)break t}else e.head&&(e.head.comment=null);e.mode=9;case 9:if(512&e.flags){for(;C<16;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}if(E!==(65535&e.check)){m.msg="header crc mismatch",e.mode=30;break}C=E=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),m.adler=e.check=0,e.mode=12;break;case 10:for(;C<32;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}m.adler=e.check=a(E),C=E=0,e.mode=11;case 11:if(e.havedict===0)return m.next_out=$,m.avail_out=V,m.next_in=P,m.avail_in=L,e.hold=E,e.bits=C,2;m.adler=e.check=1,e.mode=12;case 12:if(B===5||B===6)break t;case 13:if(e.last){E>>>=7&C,C-=7&C,e.mode=27;break}for(;C<3;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}switch(e.last=1&E,C-=1,3&(E>>>=1)){case 0:e.mode=14;break;case 1:if(W(e),e.mode=20,B!==6)break;E>>>=2,C-=2;break t;case 2:e.mode=17;break;case 3:m.msg="invalid block type",e.mode=30}E>>>=2,C-=2;break;case 14:for(E>>>=7&C,C-=7&C;C<32;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}if((65535&E)!=(E>>>16^65535)){m.msg="invalid stored block lengths",e.mode=30;break}if(e.length=65535&E,C=E=0,e.mode=15,B===6)break t;case 15:e.mode=16;case 16:if(H=e.length){if(L<H&&(H=L),V<H&&(H=V),H===0)break t;l.arraySet(J,T,P,H,$),L-=H,P+=H,V-=H,$+=H,e.length-=H;break}e.mode=12;break;case 17:for(;C<14;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}if(e.nlen=257+(31&E),E>>>=5,C-=5,e.ndist=1+(31&E),E>>>=5,C-=5,e.ncode=4+(15&E),E>>>=4,C-=4,286<e.nlen||30<e.ndist){m.msg="too many length or distance symbols",e.mode=30;break}e.have=0,e.mode=18;case 18:for(;e.have<e.ncode;){for(;C<3;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}e.lens[F[e.have++]]=7&E,E>>>=3,C-=3}for(;e.have<19;)e.lens[F[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,A={bits:e.lenbits},R=_(0,e.lens,0,19,e.lencode,0,e.work,A),e.lenbits=A.bits,R){m.msg="invalid code lengths set",e.mode=30;break}e.have=0,e.mode=19;case 19:for(;e.have<e.nlen+e.ndist;){for(;et=(s=e.lencode[E&(1<<e.lenbits)-1])>>>16&255,st=65535&s,!((Q=s>>>24)<=C);){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}if(st<16)E>>>=Q,C-=Q,e.lens[e.have++]=st;else{if(st===16){for(f=Q+2;C<f;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}if(E>>>=Q,C-=Q,e.have===0){m.msg="invalid bit length repeat",e.mode=30;break}t=e.lens[e.have-1],H=3+(3&E),E>>>=2,C-=2}else if(st===17){for(f=Q+3;C<f;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}C-=Q,t=0,H=3+(7&(E>>>=Q)),E>>>=3,C-=3}else{for(f=Q+7;C<f;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}C-=Q,t=0,H=11+(127&(E>>>=Q)),E>>>=7,C-=7}if(e.have+H>e.nlen+e.ndist){m.msg="invalid bit length repeat",e.mode=30;break}for(;H--;)e.lens[e.have++]=t}}if(e.mode===30)break;if(e.lens[256]===0){m.msg="invalid code -- missing end-of-block",e.mode=30;break}if(e.lenbits=9,A={bits:e.lenbits},R=_(y,e.lens,0,e.nlen,e.lencode,0,e.work,A),e.lenbits=A.bits,R){m.msg="invalid literal/lengths set",e.mode=30;break}if(e.distbits=6,e.distcode=e.distdyn,A={bits:e.distbits},R=_(p,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,A),e.distbits=A.bits,R){m.msg="invalid distances set",e.mode=30;break}if(e.mode=20,B===6)break t;case 20:e.mode=21;case 21:if(6<=L&&258<=V){m.next_out=$,m.avail_out=V,m.next_in=P,m.avail_in=L,e.hold=E,e.bits=C,u(m,G),$=m.next_out,J=m.output,V=m.avail_out,P=m.next_in,T=m.input,L=m.avail_in,E=e.hold,C=e.bits,e.mode===12&&(e.back=-1);break}for(e.back=0;et=(s=e.lencode[E&(1<<e.lenbits)-1])>>>16&255,st=65535&s,!((Q=s>>>24)<=C);){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}if(et&&(240&et)==0){for(it=Q,lt=et,ht=st;et=(s=e.lencode[ht+((E&(1<<it+lt)-1)>>it)])>>>16&255,st=65535&s,!(it+(Q=s>>>24)<=C);){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}E>>>=it,C-=it,e.back+=it}if(E>>>=Q,C-=Q,e.back+=Q,e.length=st,et===0){e.mode=26;break}if(32&et){e.back=-1,e.mode=12;break}if(64&et){m.msg="invalid literal/length code",e.mode=30;break}e.extra=15&et,e.mode=22;case 22:if(e.extra){for(f=e.extra;C<f;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}e.length+=E&(1<<e.extra)-1,E>>>=e.extra,C-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=23;case 23:for(;et=(s=e.distcode[E&(1<<e.distbits)-1])>>>16&255,st=65535&s,!((Q=s>>>24)<=C);){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}if((240&et)==0){for(it=Q,lt=et,ht=st;et=(s=e.distcode[ht+((E&(1<<it+lt)-1)>>it)])>>>16&255,st=65535&s,!(it+(Q=s>>>24)<=C);){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}E>>>=it,C-=it,e.back+=it}if(E>>>=Q,C-=Q,e.back+=Q,64&et){m.msg="invalid distance code",e.mode=30;break}e.offset=st,e.extra=15&et,e.mode=24;case 24:if(e.extra){for(f=e.extra;C<f;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}e.offset+=E&(1<<e.extra)-1,E>>>=e.extra,C-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){m.msg="invalid distance too far back",e.mode=30;break}e.mode=25;case 25:if(V===0)break t;if(H=G-V,e.offset>H){if((H=e.offset-H)>e.whave&&e.sane){m.msg="invalid distance too far back",e.mode=30;break}nt=H>e.wnext?(H-=e.wnext,e.wsize-H):e.wnext-H,H>e.length&&(H=e.length),ot=e.window}else ot=J,nt=$-e.offset,H=e.length;for(V<H&&(H=V),V-=H,e.length-=H;J[$++]=ot[nt++],--H;);e.length===0&&(e.mode=21);break;case 26:if(V===0)break t;J[$++]=e.length,V--,e.mode=21;break;case 27:if(e.wrap){for(;C<32;){if(L===0)break t;L--,E|=T[P++]<<C,C+=8}if(G-=V,m.total_out+=G,e.total+=G,G&&(m.adler=e.check=e.flags?n(e.check,J,G,$-G):o(e.check,J,G,$-G)),G=V,(e.flags?E:a(E))!==e.check){m.msg="incorrect data check",e.mode=30;break}C=E=0}e.mode=28;case 28:if(e.wrap&&e.flags){for(;C<32;){if(L===0)break t;L--,E+=T[P++]<<C,C+=8}if(E!==(4294967295&e.total)){m.msg="incorrect length check",e.mode=30;break}C=E=0}e.mode=29;case 29:R=1;break t;case 30:R=-3;break t;case 31:return-4;case 32:default:return i}return m.next_out=$,m.avail_out=V,m.next_in=P,m.avail_in=L,e.hold=E,e.bits=C,(e.wsize||G!==m.avail_out&&e.mode<30&&(e.mode<27||B!==4))&&q(m,m.output,m.next_out,G-m.avail_out)?(e.mode=31,-4):(X-=m.avail_in,G-=m.avail_out,m.total_in+=X,m.total_out+=G,e.total+=G,e.wrap&&G&&(m.adler=e.check=e.flags?n(e.check,J,G,m.next_out-G):o(e.check,J,G,m.next_out-G)),m.data_type=e.bits+(e.last?64:0)+(e.mode===12?128:0)+(e.mode===20||e.mode===15?256:0),(X==0&&G===0||B===4)&&R===g&&(R=-5),R)},k.inflateEnd=function(m){if(!m||!m.state)return i;var B=m.state;return B.window&&(B.window=null),m.state=null,g},k.inflateGetHeader=function(m,B){var e;return m&&m.state?(2&(e=m.state).wrap)==0?i:((e.head=B).done=!1,g):i},k.inflateSetDictionary=function(m,B){var e,T=B.length;return m&&m.state?(e=m.state).wrap!==0&&e.mode!==11?i:e.mode===11&&o(1,B,T,0)!==e.check?-3:q(m,B,T,T)?(e.mode=31,-4):(e.havedict=1,g):i},k.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(b,U,k){var l=b("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],n=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],u=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],_=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];U.exports=function(y,p,g,i,d,r,h,a){var c,v,S,x,D,O,j,I,W,q=a.bits,m=0,B=0,e=0,T=0,J=0,P=0,$=0,L=0,V=0,E=0,C=null,X=0,G=new l.Buf16(16),H=new l.Buf16(16),nt=null,ot=0;for(m=0;m<=15;m++)G[m]=0;for(B=0;B<i;B++)G[p[g+B]]++;for(J=q,T=15;1<=T&&G[T]===0;T--);if(T<J&&(J=T),T===0)return d[r++]=20971520,d[r++]=20971520,a.bits=1,0;for(e=1;e<T&&G[e]===0;e++);for(J<e&&(J=e),m=L=1;m<=15;m++)if(L<<=1,(L-=G[m])<0)return-1;if(0<L&&(y===0||T!==1))return-1;for(H[1]=0,m=1;m<15;m++)H[m+1]=H[m]+G[m];for(B=0;B<i;B++)p[g+B]!==0&&(h[H[p[g+B]]++]=B);if(O=y===0?(C=nt=h,19):y===1?(C=o,X-=257,nt=n,ot-=257,256):(C=u,nt=_,-1),m=e,D=r,$=B=E=0,S=-1,x=(V=1<<(P=J))-1,y===1&&852<V||y===2&&592<V)return 1;for(;;){for(j=m-$,W=h[B]<O?(I=0,h[B]):h[B]>O?(I=nt[ot+h[B]],C[X+h[B]]):(I=96,0),c=1<<m-$,e=v=1<<P;d[D+(E>>$)+(v-=c)]=j<<24|I<<16|W|0,v!==0;);for(c=1<<m-1;E&c;)c>>=1;if(c!==0?(E&=c-1,E+=c):E=0,B++,--G[m]==0){if(m===T)break;m=p[g+h[B]]}if(J<m&&(E&x)!==S){for($===0&&($=J),D+=e,L=1<<(P=m-$);P+$<T&&!((L-=G[P+$])<=0);)P++,L<<=1;if(V+=1<<P,y===1&&852<V||y===2&&592<V)return 1;d[S=E&x]=J<<24|P<<16|D-r|0}}return E!==0&&(d[D+E]=m-$<<24|64<<16|0),a.bits=J,0}},{"../utils/common":41}],51:[function(b,U,k){U.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(b,U,k){var l=b("../utils/common"),o=0,n=1;function u(s){for(var w=s.length;0<=--w;)s[w]=0}var _=0,y=29,p=256,g=p+1+y,i=30,d=19,r=2*g+1,h=15,a=16,c=7,v=256,S=16,x=17,D=18,O=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],j=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],I=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],W=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],q=new Array(2*(g+2));u(q);var m=new Array(2*i);u(m);var B=new Array(512);u(B);var e=new Array(256);u(e);var T=new Array(y);u(T);var J,P,$,L=new Array(i);function V(s,w,F,N,z){this.static_tree=s,this.extra_bits=w,this.extra_base=F,this.elems=N,this.max_length=z,this.has_stree=s&&s.length}function E(s,w){this.dyn_tree=s,this.max_code=0,this.stat_desc=w}function C(s){return s<256?B[s]:B[256+(s>>>7)]}function X(s,w){s.pending_buf[s.pending++]=255&w,s.pending_buf[s.pending++]=w>>>8&255}function G(s,w,F){s.bi_valid>a-F?(s.bi_buf|=w<<s.bi_valid&65535,X(s,s.bi_buf),s.bi_buf=w>>a-s.bi_valid,s.bi_valid+=F-a):(s.bi_buf|=w<<s.bi_valid&65535,s.bi_valid+=F)}function H(s,w,F){G(s,F[2*w],F[2*w+1])}function nt(s,w){for(var F=0;F|=1&s,s>>>=1,F<<=1,0<--w;);return F>>>1}function ot(s,w,F){var N,z,Z=new Array(h+1),K=0;for(N=1;N<=h;N++)Z[N]=K=K+F[N-1]<<1;for(z=0;z<=w;z++){var M=s[2*z+1];M!==0&&(s[2*z]=nt(Z[M]++,M))}}function Q(s){var w;for(w=0;w<g;w++)s.dyn_ltree[2*w]=0;for(w=0;w<i;w++)s.dyn_dtree[2*w]=0;for(w=0;w<d;w++)s.bl_tree[2*w]=0;s.dyn_ltree[2*v]=1,s.opt_len=s.static_len=0,s.last_lit=s.matches=0}function et(s){8<s.bi_valid?X(s,s.bi_buf):0<s.bi_valid&&(s.pending_buf[s.pending++]=s.bi_buf),s.bi_buf=0,s.bi_valid=0}function st(s,w,F,N){var z=2*w,Z=2*F;return s[z]<s[Z]||s[z]===s[Z]&&N[w]<=N[F]}function it(s,w,F){for(var N=s.heap[F],z=F<<1;z<=s.heap_len&&(z<s.heap_len&&st(w,s.heap[z+1],s.heap[z],s.depth)&&z++,!st(w,N,s.heap[z],s.depth));)s.heap[F]=s.heap[z],F=z,z<<=1;s.heap[F]=N}function lt(s,w,F){var N,z,Z,K,M=0;if(s.last_lit!==0)for(;N=s.pending_buf[s.d_buf+2*M]<<8|s.pending_buf[s.d_buf+2*M+1],z=s.pending_buf[s.l_buf+M],M++,N===0?H(s,z,w):(H(s,(Z=e[z])+p+1,w),(K=O[Z])!==0&&G(s,z-=T[Z],K),H(s,Z=C(--N),F),(K=j[Z])!==0&&G(s,N-=L[Z],K)),M<s.last_lit;);H(s,v,w)}function ht(s,w){var F,N,z,Z=w.dyn_tree,K=w.stat_desc.static_tree,M=w.stat_desc.has_stree,Y=w.stat_desc.elems,rt=-1;for(s.heap_len=0,s.heap_max=r,F=0;F<Y;F++)Z[2*F]!==0?(s.heap[++s.heap_len]=rt=F,s.depth[F]=0):Z[2*F+1]=0;for(;s.heap_len<2;)Z[2*(z=s.heap[++s.heap_len]=rt<2?++rt:0)]=1,s.depth[z]=0,s.opt_len--,M&&(s.static_len-=K[2*z+1]);for(w.max_code=rt,F=s.heap_len>>1;1<=F;F--)it(s,Z,F);for(z=Y;F=s.heap[1],s.heap[1]=s.heap[s.heap_len--],it(s,Z,1),N=s.heap[1],s.heap[--s.heap_max]=F,s.heap[--s.heap_max]=N,Z[2*z]=Z[2*F]+Z[2*N],s.depth[z]=(s.depth[F]>=s.depth[N]?s.depth[F]:s.depth[N])+1,Z[2*F+1]=Z[2*N+1]=z,s.heap[1]=z++,it(s,Z,1),2<=s.heap_len;);s.heap[--s.heap_max]=s.heap[1],function(tt,ut){var ct,ft,pt,at,_t,wt,dt=ut.dyn_tree,xt=ut.max_code,Ct=ut.stat_desc.static_tree,Et=ut.stat_desc.has_stree,At=ut.stat_desc.extra_bits,St=ut.stat_desc.extra_base,mt=ut.stat_desc.max_length,gt=0;for(at=0;at<=h;at++)tt.bl_count[at]=0;for(dt[2*tt.heap[tt.heap_max]+1]=0,ct=tt.heap_max+1;ct<r;ct++)mt<(at=dt[2*dt[2*(ft=tt.heap[ct])+1]+1]+1)&&(at=mt,gt++),dt[2*ft+1]=at,xt<ft||(tt.bl_count[at]++,_t=0,St<=ft&&(_t=At[ft-St]),wt=dt[2*ft],tt.opt_len+=wt*(at+_t),Et&&(tt.static_len+=wt*(Ct[2*ft+1]+_t)));if(gt!==0){do{for(at=mt-1;tt.bl_count[at]===0;)at--;tt.bl_count[at]--,tt.bl_count[at+1]+=2,tt.bl_count[mt]--,gt-=2}while(0<gt);for(at=mt;at!==0;at--)for(ft=tt.bl_count[at];ft!==0;)xt<(pt=tt.heap[--ct])||(dt[2*pt+1]!==at&&(tt.opt_len+=(at-dt[2*pt+1])*dt[2*pt],dt[2*pt+1]=at),ft--)}}(s,w),ot(Z,rt,s.bl_count)}function t(s,w,F){var N,z,Z=-1,K=w[1],M=0,Y=7,rt=4;for(K===0&&(Y=138,rt=3),w[2*(F+1)+1]=65535,N=0;N<=F;N++)z=K,K=w[2*(N+1)+1],++M<Y&&z===K||(M<rt?s.bl_tree[2*z]+=M:z!==0?(z!==Z&&s.bl_tree[2*z]++,s.bl_tree[2*S]++):M<=10?s.bl_tree[2*x]++:s.bl_tree[2*D]++,Z=z,rt=(M=0)===K?(Y=138,3):z===K?(Y=6,3):(Y=7,4))}function R(s,w,F){var N,z,Z=-1,K=w[1],M=0,Y=7,rt=4;for(K===0&&(Y=138,rt=3),N=0;N<=F;N++)if(z=K,K=w[2*(N+1)+1],!(++M<Y&&z===K)){if(M<rt)for(;H(s,z,s.bl_tree),--M!=0;);else z!==0?(z!==Z&&(H(s,z,s.bl_tree),M--),H(s,S,s.bl_tree),G(s,M-3,2)):M<=10?(H(s,x,s.bl_tree),G(s,M-3,3)):(H(s,D,s.bl_tree),G(s,M-11,7));Z=z,rt=(M=0)===K?(Y=138,3):z===K?(Y=6,3):(Y=7,4)}}u(L);var A=!1;function f(s,w,F,N){G(s,(_<<1)+(N?1:0),3),function(z,Z,K,M){et(z),X(z,K),X(z,~K),l.arraySet(z.pending_buf,z.window,Z,K,z.pending),z.pending+=K}(s,w,F)}k._tr_init=function(s){A||(function(){var w,F,N,z,Z,K=new Array(h+1);for(z=N=0;z<y-1;z++)for(T[z]=N,w=0;w<1<<O[z];w++)e[N++]=z;for(e[N-1]=z,z=Z=0;z<16;z++)for(L[z]=Z,w=0;w<1<<j[z];w++)B[Z++]=z;for(Z>>=7;z<i;z++)for(L[z]=Z<<7,w=0;w<1<<j[z]-7;w++)B[256+Z++]=z;for(F=0;F<=h;F++)K[F]=0;for(w=0;w<=143;)q[2*w+1]=8,w++,K[8]++;for(;w<=255;)q[2*w+1]=9,w++,K[9]++;for(;w<=279;)q[2*w+1]=7,w++,K[7]++;for(;w<=287;)q[2*w+1]=8,w++,K[8]++;for(ot(q,g+1,K),w=0;w<i;w++)m[2*w+1]=5,m[2*w]=nt(w,5);J=new V(q,O,p+1,g,h),P=new V(m,j,0,i,h),$=new V(new Array(0),I,0,d,c)}(),A=!0),s.l_desc=new E(s.dyn_ltree,J),s.d_desc=new E(s.dyn_dtree,P),s.bl_desc=new E(s.bl_tree,$),s.bi_buf=0,s.bi_valid=0,Q(s)},k._tr_stored_block=f,k._tr_flush_block=function(s,w,F,N){var z,Z,K=0;0<s.level?(s.strm.data_type===2&&(s.strm.data_type=function(M){var Y,rt=4093624447;for(Y=0;Y<=31;Y++,rt>>>=1)if(1&rt&&M.dyn_ltree[2*Y]!==0)return o;if(M.dyn_ltree[18]!==0||M.dyn_ltree[20]!==0||M.dyn_ltree[26]!==0)return n;for(Y=32;Y<p;Y++)if(M.dyn_ltree[2*Y]!==0)return n;return o}(s)),ht(s,s.l_desc),ht(s,s.d_desc),K=function(M){var Y;for(t(M,M.dyn_ltree,M.l_desc.max_code),t(M,M.dyn_dtree,M.d_desc.max_code),ht(M,M.bl_desc),Y=d-1;3<=Y&&M.bl_tree[2*W[Y]+1]===0;Y--);return M.opt_len+=3*(Y+1)+5+5+4,Y}(s),z=s.opt_len+3+7>>>3,(Z=s.static_len+3+7>>>3)<=z&&(z=Z)):z=Z=F+5,F+4<=z&&w!==-1?f(s,w,F,N):s.strategy===4||Z===z?(G(s,2+(N?1:0),3),lt(s,q,m)):(G(s,4+(N?1:0),3),function(M,Y,rt,tt){var ut;for(G(M,Y-257,5),G(M,rt-1,5),G(M,tt-4,4),ut=0;ut<tt;ut++)G(M,M.bl_tree[2*W[ut]+1],3);R(M,M.dyn_ltree,Y-1),R(M,M.dyn_dtree,rt-1)}(s,s.l_desc.max_code+1,s.d_desc.max_code+1,K+1),lt(s,s.dyn_ltree,s.dyn_dtree)),Q(s),N&&et(s)},k._tr_tally=function(s,w,F){return s.pending_buf[s.d_buf+2*s.last_lit]=w>>>8&255,s.pending_buf[s.d_buf+2*s.last_lit+1]=255&w,s.pending_buf[s.l_buf+s.last_lit]=255&F,s.last_lit++,w===0?s.dyn_ltree[2*F]++:(s.matches++,w--,s.dyn_ltree[2*(e[F]+p+1)]++,s.dyn_dtree[2*C(w)]++),s.last_lit===s.lit_bufsize-1},k._tr_align=function(s){G(s,2,3),H(s,v,q),function(w){w.bi_valid===16?(X(w,w.bi_buf),w.bi_buf=0,w.bi_valid=0):8<=w.bi_valid&&(w.pending_buf[w.pending++]=255&w.bi_buf,w.bi_buf>>=8,w.bi_valid-=8)}(s)}},{"../utils/common":41}],53:[function(b,U,k){U.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(b,U,k){(function(l){(function(o,n){if(!o.setImmediate){var u,_,y,p,g=1,i={},d=!1,r=o.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(o);h=h&&h.setTimeout?h:o,u={}.toString.call(o.process)==="[object process]"?function(S){process.nextTick(function(){c(S)})}:function(){if(o.postMessage&&!o.importScripts){var S=!0,x=o.onmessage;return o.onmessage=function(){S=!1},o.postMessage("","*"),o.onmessage=x,S}}()?(p="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",v,!1):o.attachEvent("onmessage",v),function(S){o.postMessage(p+S,"*")}):o.MessageChannel?((y=new MessageChannel).port1.onmessage=function(S){c(S.data)},function(S){y.port2.postMessage(S)}):r&&"onreadystatechange"in r.createElement("script")?(_=r.documentElement,function(S){var x=r.createElement("script");x.onreadystatechange=function(){c(S),x.onreadystatechange=null,_.removeChild(x),x=null},_.appendChild(x)}):function(S){setTimeout(c,0,S)},h.setImmediate=function(S){typeof S!="function"&&(S=new Function(""+S));for(var x=new Array(arguments.length-1),D=0;D<x.length;D++)x[D]=arguments[D+1];var O={callback:S,args:x};return i[g]=O,u(g),g++},h.clearImmediate=a}function a(S){delete i[S]}function c(S){if(d)setTimeout(c,0,S);else{var x=i[S];if(x){d=!0;try{(function(D){var O=D.callback,j=D.args;switch(j.length){case 0:O();break;case 1:O(j[0]);break;case 2:O(j[0],j[1]);break;case 3:O(j[0],j[1],j[2]);break;default:O.apply(n,j)}})(x)}finally{a(S),d=!1}}}}function v(S){S.source===o&&typeof S.data=="string"&&S.data.indexOf(p)===0&&c(+S.data.slice(p.length))}})(typeof self>"u"?l===void 0?this:l:self)}).call(this,typeof bt<"u"?bt:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})}(kt)),kt.exports}var Bt=Ot();const Rt=It(Bt),Ft=Object.freeze(Object.defineProperty({__proto__:null,default:Rt},Symbol.toStringTag,{value:"Module"}));export{Ft as j};
py_backend/static/index.html CHANGED
@@ -35,10 +35,10 @@
35
  });
36
  }
37
  </script>
38
- <script type="module" crossorigin src="/app/assets/index-BRyvKFWv.js"></script>
39
- <link rel="modulepreload" crossorigin href="/app/assets/vendor-DyNqUykN.js">
40
- <link rel="modulepreload" crossorigin href="/app/assets/vendor-react-DAdyb5sm.js">
41
- <link rel="modulepreload" crossorigin href="/app/assets/vendor-ui-D6Mv63JJ.js">
42
  <link rel="stylesheet" crossorigin href="/app/assets/vendor-ui-DpEM1HT6.css">
43
  <link rel="stylesheet" crossorigin href="/app/assets/index-om3EFqpn.css">
44
  </head>
 
35
  });
36
  }
37
  </script>
38
+ <script type="module" crossorigin src="/app/assets/index-C6NSRolP.js"></script>
39
+ <link rel="modulepreload" crossorigin href="/app/assets/vendor-DxpCibxB.js">
40
+ <link rel="modulepreload" crossorigin href="/app/assets/vendor-react-BxsGb6Ph.js">
41
+ <link rel="modulepreload" crossorigin href="/app/assets/vendor-ui-l_DttnRj.js">
42
  <link rel="stylesheet" crossorigin href="/app/assets/vendor-ui-DpEM1HT6.css">
43
  <link rel="stylesheet" crossorigin href="/app/assets/index-om3EFqpn.css">
44
  </head>