diff --git a/dist/assets/AdminDashboardView-JnGO4r61.js b/dist/assets/AdminDashboardView-DT-HY3B4.js similarity index 98% rename from dist/assets/AdminDashboardView-JnGO4r61.js rename to dist/assets/AdminDashboardView-DT-HY3B4.js index 193efed..434956f 100644 --- a/dist/assets/AdminDashboardView-JnGO4r61.js +++ b/dist/assets/AdminDashboardView-DT-HY3B4.js @@ -1 +1 @@ -import{d as $,q as F,m as g,c as o,a as t,i as I,j as P,t as a,b as C,s as T,v as R,F as S,x as B,e as D,f as q,r,l as K,o as l,p as A,n as W}from"./index-CWxNv9Fc.js";const Z={class:"min-h-screen bg-gray-100 dark:bg-gray-900"},G={class:"bg-white dark:bg-gray-800 shadow"},H={class:"max-w-7xl mx-auto px-4 py-4 flex items-center justify-between"},J={class:"max-w-7xl mx-auto px-4 py-8"},Q={key:0,class:"text-center py-12"},X={key:1,class:"card bg-red-50 text-red-700 text-center"},Y={key:2,class:"space-y-6"},tt={class:"grid grid-cols-1 md:grid-cols-4 gap-4"},et={class:"card"},st={class:"text-3xl font-bold text-primary-600"},at={class:"card"},nt={class:"text-3xl font-bold text-green-600"},ot={class:"card"},lt={class:"text-3xl font-bold text-blue-600"},rt={class:"card"},it={class:"text-3xl font-bold text-purple-600"},dt={class:"card"},ct={class:"flex gap-4"},ut=["disabled"],gt={class:"card"},xt={class:"overflow-x-auto"},vt={class:"w-full"},mt={class:"divide-y dark:divide-gray-700"},yt={class:"py-3 font-medium text-gray-900 dark:text-white"},_t={class:"py-3 text-gray-500"},pt={class:"py-3"},ft={class:"py-3 text-gray-500"},bt={class:"py-3 text-gray-500"},ht={class:"py-3 text-gray-500"},kt={class:"py-3"},wt=["onClick"],zt={key:0,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4"},Ct={class:"bg-white dark:bg-gray-800 rounded-xl shadow-xl max-w-2xl w-full max-h-[80vh] overflow-y-auto"},St={class:"p-6"},Bt={class:"flex items-center justify-between mb-6"},Dt={class:"text-xl font-bold text-gray-900 dark:text-white"},At={key:0,class:"space-y-6"},Et={class:"grid grid-cols-3 gap-4"},Ot={class:"bg-gray-50 dark:bg-gray-700 rounded-lg p-4 text-center"},Ut={class:"text-2xl font-bold"},Vt={class:"bg-gray-50 dark:bg-gray-700 rounded-lg p-4 text-center"},Lt={class:"text-2xl font-bold"},Nt={class:"bg-gray-50 dark:bg-gray-700 rounded-lg p-4 text-center"},jt={class:"text-2xl font-bold"},Mt={class:"space-y-2"},$t={class:"font-medium text-gray-900 dark:text-white"},Ft={key:0,class:"text-red-500 text-sm"},It={class:"text-sm text-gray-500"},Pt=["onClick"],Tt={key:1,class:"text-center py-8 text-gray-500"},Wt=$({__name:"AdminDashboardView",setup(Rt){const E=q(),v=r(!0),c=r(""),u=r({org_count:0,user_count:0,order_count:0,timesheet_count:0}),p=r([]),f=r(null),i=r(null),m=r(!1),d=r(""),y=r("info"),x=r(!1);F(async()=>{await O()});async function O(){v.value=!0,c.value="";try{const[n,e]=await Promise.all([g.get("/admin/dashboard"),g.get("/admin/organizations")]);u.value=n.data.stats,p.value=e.data.organizations}catch(n){c.value=n instanceof Error?n.message:"Laden fehlgeschlagen",c.value.includes("Super-Admin")&&E.push("/")}finally{v.value=!1}}async function U(n){f.value=n,m.value=!0;try{const e=await g.get(`/admin/organizations/${n.id}`);i.value=e.data}catch(e){console.error("Load org details failed:",e)}}async function V(n){if(confirm("Als dieser User einloggen?"))try{const e=await g.post(`/admin/impersonate/${n}`);localStorage.setItem("accessToken",e.data.token),localStorage.setItem("impersonating","true"),window.location.href="/"}catch(e){alert("Impersonation fehlgeschlagen: "+(e instanceof Error?e.message:"Unbekannter Fehler"))}}async function L(){if(d.value.trim()&&confirm("Nachricht an alle Organisationen senden?")){x.value=!0;try{await g.post("/admin/broadcast",{message:d.value,type:y.value}),alert("Broadcast gesendet!"),d.value=""}catch(n){alert("Fehler: "+(n instanceof Error?n.message:"Unbekannt"))}finally{x.value=!1}}}function N(n){return new Date(n).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}function j(n){const e={free:"badge bg-gray-100 text-gray-800",starter:"badge bg-blue-100 text-blue-800",business:"badge bg-purple-100 text-purple-800",enterprise:"badge bg-yellow-100 text-yellow-800"};return e[n]||e.free}return(n,e)=>{var b,h,k,w;const M=K("router-link");return l(),o("div",Z,[t("header",G,[t("div",H,[e[4]||(e[4]=t("div",{class:"flex items-center gap-3"},[t("span",{class:"text-2xl"},"🛡️"),t("h1",{class:"text-xl font-bold text-gray-900 dark:text-white"}," SeCu Admin Panel ")],-1)),I(M,{to:"/",class:"btn btn-secondary text-sm"},{default:P(()=>[...e[3]||(e[3]=[A(" ← Zurück zur App ",-1)])]),_:1})])]),t("main",J,[v.value?(l(),o("div",Q,[...e[5]||(e[5]=[t("p",{class:"text-gray-500"},"Lädt...",-1)])])):c.value?(l(),o("div",X,a(c.value),1)):(l(),o("div",Y,[t("div",tt,[t("div",et,[t("div",st,a(u.value.org_count),1),e[6]||(e[6]=t("div",{class:"text-sm text-gray-500"},"Organisationen",-1))]),t("div",at,[t("div",nt,a(u.value.user_count),1),e[7]||(e[7]=t("div",{class:"text-sm text-gray-500"},"Benutzer",-1))]),t("div",ot,[t("div",lt,a(u.value.order_count),1),e[8]||(e[8]=t("div",{class:"text-sm text-gray-500"},"Aufträge",-1))]),t("div",rt,[t("div",it,a(u.value.timesheet_count),1),e[9]||(e[9]=t("div",{class:"text-sm text-gray-500"},"Stundenzettel",-1))])]),t("div",dt,[e[11]||(e[11]=t("h2",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," 📢 Broadcast an alle Kunden ",-1)),t("div",ct,[C(t("select",{"onUpdate:modelValue":e[0]||(e[0]=s=>y.value=s),class:"input w-32"},[...e[10]||(e[10]=[t("option",{value:"info"},"Info",-1),t("option",{value:"warning"},"Warnung",-1),t("option",{value:"success"},"Erfolg",-1)])],512),[[T,y.value]]),C(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>d.value=s),type:"text",class:"input flex-1",placeholder:"Nachricht eingeben..."},null,512),[[R,d.value]]),t("button",{onClick:L,disabled:x.value||!d.value.trim(),class:"btn btn-primary"},a(x.value?"Sendet...":"Senden"),9,ut)])]),t("div",gt,[e[13]||(e[13]=t("h2",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," 🏢 Organisationen ",-1)),t("div",xt,[t("table",vt,[e[12]||(e[12]=t("thead",{class:"text-left text-sm text-gray-500 border-b dark:border-gray-700"},[t("tr",null,[t("th",{class:"pb-3 font-medium"},"Organisation"),t("th",{class:"pb-3 font-medium"},"Slug"),t("th",{class:"pb-3 font-medium"},"Plan"),t("th",{class:"pb-3 font-medium"},"Users"),t("th",{class:"pb-3 font-medium"},"Aufträge"),t("th",{class:"pb-3 font-medium"},"Erstellt"),t("th",{class:"pb-3 font-medium"})])],-1)),t("tbody",mt,[(l(!0),o(S,null,B(p.value,s=>{var _,z;return l(),o("tr",{key:s.id,class:"hover:bg-gray-50 dark:hover:bg-gray-800"},[t("td",yt,a(s.name),1),t("td",_t,a(s.slug),1),t("td",pt,[t("span",{class:W(j(((_=s.settings)==null?void 0:_.plan)||"free"))},a(((z=s.settings)==null?void 0:z.plan)||"free"),3)]),t("td",ft,a(s.user_count),1),t("td",bt,a(s.order_count),1),t("td",ht,a(N(s.created_at)),1),t("td",kt,[t("button",{onClick:qt=>U(s),class:"text-primary-600 hover:text-primary-800 text-sm"}," Details → ",8,wt)])])}),128))])])])])]))]),m.value?(l(),o("div",zt,[t("div",Ct,[t("div",St,[t("div",Bt,[t("h2",Dt,a((b=f.value)==null?void 0:b.name),1),t("button",{onClick:e[2]||(e[2]=s=>m.value=!1),class:"text-gray-400 hover:text-gray-600"}," ✕ ")]),i.value?(l(),o("div",At,[t("div",Et,[t("div",Ot,[t("div",Ut,a(((h=i.value.users)==null?void 0:h.length)||0),1),e[14]||(e[14]=t("div",{class:"text-sm text-gray-500"},"Benutzer",-1))]),t("div",Vt,[t("div",Lt,a(((k=i.value.stats)==null?void 0:k.order_count)||0),1),e[15]||(e[15]=t("div",{class:"text-sm text-gray-500"},"Aufträge",-1))]),t("div",Nt,[t("div",jt,a(((w=i.value.stats)==null?void 0:w.timesheet_count)||0),1),e[16]||(e[16]=t("div",{class:"text-sm text-gray-500"},"Stundenzettel",-1))])]),t("div",null,[e[17]||(e[17]=t("h3",{class:"font-semibold text-gray-900 dark:text-white mb-3"},"Benutzer",-1)),t("div",Mt,[(l(!0),o(S,null,B(i.value.users,s=>(l(),o("div",{key:s.id,class:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},[t("div",null,[t("div",$t,[A(a(s.first_name)+" "+a(s.last_name)+" ",1),s.active?D("",!0):(l(),o("span",Ft,"(inaktiv)"))]),t("div",It,a(s.email)+" • "+a(s.role),1)]),t("button",{onClick:_=>V(s.id),class:"text-sm text-primary-600 hover:text-primary-800"}," Als User einloggen ",8,Pt)]))),128))])])])):(l(),o("div",Tt," Lädt... "))])])])):D("",!0)])}}});export{Wt as default}; +import{d as $,q as F,m as g,c as o,a as t,i as I,j as P,t as a,b as C,s as T,v as R,F as S,x as B,e as D,f as q,r,l as K,p as A,o as l,n as W}from"./index-CgM2qJ96.js";const Z={class:"min-h-screen bg-gray-100 dark:bg-gray-900"},G={class:"bg-white dark:bg-gray-800 shadow"},H={class:"max-w-7xl mx-auto px-4 py-4 flex items-center justify-between"},J={class:"max-w-7xl mx-auto px-4 py-8"},Q={key:0,class:"text-center py-12"},X={key:1,class:"card bg-red-50 text-red-700 text-center"},Y={key:2,class:"space-y-6"},tt={class:"grid grid-cols-1 md:grid-cols-4 gap-4"},et={class:"card"},st={class:"text-3xl font-bold text-primary-600"},at={class:"card"},nt={class:"text-3xl font-bold text-green-600"},ot={class:"card"},lt={class:"text-3xl font-bold text-blue-600"},rt={class:"card"},it={class:"text-3xl font-bold text-purple-600"},dt={class:"card"},ct={class:"flex gap-4"},ut=["disabled"],gt={class:"card"},xt={class:"overflow-x-auto"},vt={class:"w-full"},mt={class:"divide-y dark:divide-gray-700"},yt={class:"py-3 font-medium text-gray-900 dark:text-white"},_t={class:"py-3 text-gray-500"},pt={class:"py-3"},ft={class:"py-3 text-gray-500"},bt={class:"py-3 text-gray-500"},ht={class:"py-3 text-gray-500"},kt={class:"py-3"},wt=["onClick"],zt={key:0,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4"},Ct={class:"bg-white dark:bg-gray-800 rounded-xl shadow-xl max-w-2xl w-full max-h-[80vh] overflow-y-auto"},St={class:"p-6"},Bt={class:"flex items-center justify-between mb-6"},Dt={class:"text-xl font-bold text-gray-900 dark:text-white"},At={key:0,class:"space-y-6"},Et={class:"grid grid-cols-3 gap-4"},Ot={class:"bg-gray-50 dark:bg-gray-700 rounded-lg p-4 text-center"},Ut={class:"text-2xl font-bold"},Vt={class:"bg-gray-50 dark:bg-gray-700 rounded-lg p-4 text-center"},Lt={class:"text-2xl font-bold"},Nt={class:"bg-gray-50 dark:bg-gray-700 rounded-lg p-4 text-center"},jt={class:"text-2xl font-bold"},Mt={class:"space-y-2"},$t={class:"font-medium text-gray-900 dark:text-white"},Ft={key:0,class:"text-red-500 text-sm"},It={class:"text-sm text-gray-500"},Pt=["onClick"],Tt={key:1,class:"text-center py-8 text-gray-500"},Wt=$({__name:"AdminDashboardView",setup(Rt){const E=q(),v=r(!0),c=r(""),u=r({org_count:0,user_count:0,order_count:0,timesheet_count:0}),p=r([]),f=r(null),i=r(null),m=r(!1),d=r(""),y=r("info"),x=r(!1);F(async()=>{await O()});async function O(){v.value=!0,c.value="";try{const[n,e]=await Promise.all([g.get("/admin/dashboard"),g.get("/admin/organizations")]);u.value=n.data.stats,p.value=e.data.organizations}catch(n){c.value=n instanceof Error?n.message:"Laden fehlgeschlagen",c.value.includes("Super-Admin")&&E.push("/")}finally{v.value=!1}}async function U(n){f.value=n,m.value=!0;try{const e=await g.get(`/admin/organizations/${n.id}`);i.value=e.data}catch(e){console.error("Load org details failed:",e)}}async function V(n){if(confirm("Als dieser User einloggen?"))try{const e=await g.post(`/admin/impersonate/${n}`);localStorage.setItem("accessToken",e.data.token),localStorage.setItem("impersonating","true"),window.location.href="/"}catch(e){alert("Impersonation fehlgeschlagen: "+(e instanceof Error?e.message:"Unbekannter Fehler"))}}async function L(){if(d.value.trim()&&confirm("Nachricht an alle Organisationen senden?")){x.value=!0;try{await g.post("/admin/broadcast",{message:d.value,type:y.value}),alert("Broadcast gesendet!"),d.value=""}catch(n){alert("Fehler: "+(n instanceof Error?n.message:"Unbekannt"))}finally{x.value=!1}}}function N(n){return new Date(n).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}function j(n){const e={free:"badge bg-gray-100 text-gray-800",starter:"badge bg-blue-100 text-blue-800",business:"badge bg-purple-100 text-purple-800",enterprise:"badge bg-yellow-100 text-yellow-800"};return e[n]||e.free}return(n,e)=>{var b,h,k,w;const M=K("router-link");return l(),o("div",Z,[t("header",G,[t("div",H,[e[4]||(e[4]=t("div",{class:"flex items-center gap-3"},[t("span",{class:"text-2xl"},"🛡️"),t("h1",{class:"text-xl font-bold text-gray-900 dark:text-white"}," SeCu Admin Panel ")],-1)),I(M,{to:"/",class:"btn btn-secondary text-sm"},{default:P(()=>[...e[3]||(e[3]=[A(" ← Zurück zur App ",-1)])]),_:1})])]),t("main",J,[v.value?(l(),o("div",Q,[...e[5]||(e[5]=[t("p",{class:"text-gray-500"},"Lädt...",-1)])])):c.value?(l(),o("div",X,a(c.value),1)):(l(),o("div",Y,[t("div",tt,[t("div",et,[t("div",st,a(u.value.org_count),1),e[6]||(e[6]=t("div",{class:"text-sm text-gray-500"},"Organisationen",-1))]),t("div",at,[t("div",nt,a(u.value.user_count),1),e[7]||(e[7]=t("div",{class:"text-sm text-gray-500"},"Benutzer",-1))]),t("div",ot,[t("div",lt,a(u.value.order_count),1),e[8]||(e[8]=t("div",{class:"text-sm text-gray-500"},"Aufträge",-1))]),t("div",rt,[t("div",it,a(u.value.timesheet_count),1),e[9]||(e[9]=t("div",{class:"text-sm text-gray-500"},"Stundenzettel",-1))])]),t("div",dt,[e[11]||(e[11]=t("h2",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," 📢 Broadcast an alle Kunden ",-1)),t("div",ct,[C(t("select",{"onUpdate:modelValue":e[0]||(e[0]=s=>y.value=s),class:"input w-32"},[...e[10]||(e[10]=[t("option",{value:"info"},"Info",-1),t("option",{value:"warning"},"Warnung",-1),t("option",{value:"success"},"Erfolg",-1)])],512),[[T,y.value]]),C(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>d.value=s),type:"text",class:"input flex-1",placeholder:"Nachricht eingeben..."},null,512),[[R,d.value]]),t("button",{onClick:L,disabled:x.value||!d.value.trim(),class:"btn btn-primary"},a(x.value?"Sendet...":"Senden"),9,ut)])]),t("div",gt,[e[13]||(e[13]=t("h2",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," 🏢 Organisationen ",-1)),t("div",xt,[t("table",vt,[e[12]||(e[12]=t("thead",{class:"text-left text-sm text-gray-500 border-b dark:border-gray-700"},[t("tr",null,[t("th",{class:"pb-3 font-medium"},"Organisation"),t("th",{class:"pb-3 font-medium"},"Slug"),t("th",{class:"pb-3 font-medium"},"Plan"),t("th",{class:"pb-3 font-medium"},"Users"),t("th",{class:"pb-3 font-medium"},"Aufträge"),t("th",{class:"pb-3 font-medium"},"Erstellt"),t("th",{class:"pb-3 font-medium"})])],-1)),t("tbody",mt,[(l(!0),o(S,null,B(p.value,s=>{var _,z;return l(),o("tr",{key:s.id,class:"hover:bg-gray-50 dark:hover:bg-gray-800"},[t("td",yt,a(s.name),1),t("td",_t,a(s.slug),1),t("td",pt,[t("span",{class:W(j(((_=s.settings)==null?void 0:_.plan)||"free"))},a(((z=s.settings)==null?void 0:z.plan)||"free"),3)]),t("td",ft,a(s.user_count),1),t("td",bt,a(s.order_count),1),t("td",ht,a(N(s.created_at)),1),t("td",kt,[t("button",{onClick:qt=>U(s),class:"text-primary-600 hover:text-primary-800 text-sm"}," Details → ",8,wt)])])}),128))])])])])]))]),m.value?(l(),o("div",zt,[t("div",Ct,[t("div",St,[t("div",Bt,[t("h2",Dt,a((b=f.value)==null?void 0:b.name),1),t("button",{onClick:e[2]||(e[2]=s=>m.value=!1),class:"text-gray-400 hover:text-gray-600"}," ✕ ")]),i.value?(l(),o("div",At,[t("div",Et,[t("div",Ot,[t("div",Ut,a(((h=i.value.users)==null?void 0:h.length)||0),1),e[14]||(e[14]=t("div",{class:"text-sm text-gray-500"},"Benutzer",-1))]),t("div",Vt,[t("div",Lt,a(((k=i.value.stats)==null?void 0:k.order_count)||0),1),e[15]||(e[15]=t("div",{class:"text-sm text-gray-500"},"Aufträge",-1))]),t("div",Nt,[t("div",jt,a(((w=i.value.stats)==null?void 0:w.timesheet_count)||0),1),e[16]||(e[16]=t("div",{class:"text-sm text-gray-500"},"Stundenzettel",-1))])]),t("div",null,[e[17]||(e[17]=t("h3",{class:"font-semibold text-gray-900 dark:text-white mb-3"},"Benutzer",-1)),t("div",Mt,[(l(!0),o(S,null,B(i.value.users,s=>(l(),o("div",{key:s.id,class:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},[t("div",null,[t("div",$t,[A(a(s.first_name)+" "+a(s.last_name)+" ",1),s.active?D("",!0):(l(),o("span",Ft,"(inaktiv)"))]),t("div",It,a(s.email)+" • "+a(s.role),1)]),t("button",{onClick:_=>V(s.id),class:"text-sm text-primary-600 hover:text-primary-800"}," Als User einloggen ",8,Pt)]))),128))])])])):(l(),o("div",Tt," Lädt... "))])])])):D("",!0)])}}});export{Wt as default}; diff --git a/dist/assets/AppLayout-AMYs4jcG.js b/dist/assets/AppLayout-AMYs4jcG.js deleted file mode 100644 index 4e68d30..0000000 --- a/dist/assets/AppLayout-AMYs4jcG.js +++ /dev/null @@ -1 +0,0 @@ -import{d as v,u as _,c as g,n as w,a as t,F as M,x as z,t as n,y as i,k as A,o as d,z as j,j as C,l as $,g as L,r as k,i as y,e as S,p as N,f as V}from"./index-CWxNv9Fc.js";const B={class:"mt-6 px-3"},E={class:"text-xl"},D={class:"font-medium"},F={class:"absolute bottom-0 left-0 right-0 p-4 border-t border-gray-200 dark:border-gray-700"},O={class:"flex items-center gap-3"},R={class:"w-10 h-10 rounded-full bg-primary-100 dark:bg-primary-900 flex items-center justify-center"},H={class:"text-primary-600 dark:text-primary-300 font-medium"},I={class:"flex-1 min-w-0"},T={class:"text-sm font-medium text-gray-900 dark:text-white truncate"},U={class:"text-xs text-gray-500 dark:text-gray-400 capitalize"},q=v({__name:"AppSidebar",props:{open:{type:Boolean}},emits:["close"],setup(x){const o=L(),r=_(),a=A(()=>{const s=[{name:"Dashboard",href:"/",icon:"📊"},{name:"Aufträge",href:"/orders",icon:"📋"}];return r.canManageUsers&&s.push({name:"Mitarbeiter",href:"/users",icon:"👥"},{name:"Schichtplanung",href:"/shifts",icon:"📅"}),s.push({name:"Verfügbarkeit",href:"/availability",icon:"🗓️"},{name:"Stundenzettel",href:"/timesheets",icon:"⏱️"},{name:"Qualifikationen",href:"/qualifications",icon:"🎓"},{name:"Objekte",href:"/objects",icon:"🏢"},{name:"Rundgänge",href:"/patrols",icon:"📍"},{name:"Vorfälle",href:"/incidents",icon:"🚨"},{name:"Dokumente",href:"/documents",icon:"📁"}),r.canManageUsers&&s.push({name:"Fahrzeuge",href:"/vehicles",icon:"🚗"},{name:"Kunden",href:"/customers",icon:"🤝"}),r.isChef&&s.push({name:"Abrechnung",href:"/billing",icon:"💰"},{name:"Module",href:"/modules",icon:"⚙️"}),s.push({name:"Einstellungen",href:"/settings",icon:"🔧"},{name:"Hilfe",href:"/help",icon:"📚"}),s});function c(s){return s==="/"?o.path==="/":o.path.startsWith(s)}return(s,e)=>{var l,p,f,b,u;const m=$("router-link");return d(),g("aside",{class:w(["fixed inset-y-0 left-0 z-50 w-64 bg-white dark:bg-gray-800 border-r border-gray-200 dark:border-gray-700 transform transition-transform lg:translate-x-0",x.open?"translate-x-0":"-translate-x-full"])},[e[1]||(e[1]=t("div",{class:"h-16 flex items-center px-6 border-b border-gray-200 dark:border-gray-700"},[t("span",{class:"text-2xl font-bold text-primary-600"},"🔐 SeCu")],-1)),t("nav",B,[(d(!0),g(M,null,z(a.value,h=>(d(),j(m,{key:h.href,to:h.href,class:w(["flex items-center gap-3 px-3 py-2 rounded-lg mb-1 transition-colors",c(h.href)?"bg-primary-100 text-primary-700 dark:bg-primary-900 dark:text-primary-200":"text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700"]),onClick:e[0]||(e[0]=re=>s.$emit("close"))},{default:C(()=>[t("span",E,n(h.icon),1),t("span",D,n(h.name),1)]),_:2},1032,["to","class"]))),128))]),t("div",F,[t("div",O,[t("div",R,[t("span",H,n((p=(l=i(r).user)==null?void 0:l.first_name)==null?void 0:p[0])+n((b=(f=i(r).user)==null?void 0:f.last_name)==null?void 0:b[0]),1)]),t("div",I,[t("p",T,n(i(r).fullName),1),t("p",U,n((u=i(r).user)==null?void 0:u.role),1)])])])],2)}}}),K={class:"h-16 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between px-4 lg:px-6"},Q={class:"flex items-center gap-2"},W={class:"text-xl"},G={class:"relative"},J={class:"w-8 h-8 rounded-full bg-primary-100 dark:bg-primary-900 flex items-center justify-center"},P={class:"text-primary-600 dark:text-primary-300 text-sm font-medium"},X={class:"hidden sm:block text-sm font-medium text-gray-700 dark:text-gray-200"},Y=v({__name:"AppHeader",emits:["toggle-sidebar","logout"],setup(x){const o=_(),r=k(localStorage.getItem("darkMode")==="true"),a=k(!1);function c(){r.value=!r.value,localStorage.setItem("darkMode",String(r.value)),document.documentElement.classList.toggle("dark",r.value)}return r.value&&document.documentElement.classList.add("dark"),(s,e)=>{var l,p,f,b;const m=$("router-link");return d(),g("header",K,[t("button",{class:"lg:hidden p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700",onClick:e[0]||(e[0]=u=>s.$emit("toggle-sidebar"))},[...e[4]||(e[4]=[t("span",{class:"text-2xl"},"☰",-1)])]),e[7]||(e[7]=t("div",{class:"flex-1 lg:ml-0"},[t("h1",{class:"text-lg font-semibold text-gray-900 dark:text-white hidden lg:block"}," Mitarbeiterverwaltung ")],-1)),t("div",Q,[t("button",{class:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700",onClick:c},[t("span",W,n(r.value?"☀️":"🌙"),1)]),t("div",G,[t("button",{class:"flex items-center gap-2 p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700",onClick:e[1]||(e[1]=u=>a.value=!a.value)},[t("div",J,[t("span",P,n((p=(l=i(o).user)==null?void 0:l.first_name)==null?void 0:p[0])+n((b=(f=i(o).user)==null?void 0:f.last_name)==null?void 0:b[0]),1)]),t("span",X,n(i(o).fullName),1)]),a.value?(d(),g("div",{key:0,class:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50",onClick:e[3]||(e[3]=u=>a.value=!1)},[y(m,{to:"/settings",class:"block px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700"},{default:C(()=>[...e[5]||(e[5]=[N(" ⚙️ Einstellungen ",-1)])]),_:1}),e[6]||(e[6]=t("hr",{class:"my-1 border-gray-200 dark:border-gray-700"},null,-1)),t("button",{class:"w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20",onClick:e[2]||(e[2]=u=>s.$emit("logout"))}," 🚪 Abmelden ")])):S("",!0)])])])}}}),Z={class:"min-h-screen bg-gray-50 dark:bg-gray-900"},ee={class:"lg:pl-64"},te={class:"p-6"},ae=v({__name:"AppLayout",setup(x){const o=_(),r=V(),a=k(!1);async function c(){await o.logout(),r.push("/login")}return(s,e)=>{const m=$("router-view");return d(),g("div",Z,[a.value?(d(),g("div",{key:0,class:"fixed inset-0 z-40 bg-black/50 lg:hidden",onClick:e[0]||(e[0]=l=>a.value=!1)})):S("",!0),y(q,{open:a.value,onClose:e[1]||(e[1]=l=>a.value=!1)},null,8,["open"]),t("div",ee,[y(Y,{onToggleSidebar:e[2]||(e[2]=l=>a.value=!a.value),onLogout:c}),t("main",te,[y(m)])])])}}});export{ae as default}; diff --git a/dist/assets/AppLayout-M3P9X3hb.js b/dist/assets/AppLayout-M3P9X3hb.js new file mode 100644 index 0000000..1d72f29 --- /dev/null +++ b/dist/assets/AppLayout-M3P9X3hb.js @@ -0,0 +1 @@ +import{d as w,y as S,u as L,c,n as _,a as e,F as B,x as j,t as o,z as n,k as A,A as E,j as M,l as z,g as N,o as d,w as O,i as f,T,r as k,e as $,S as C,B as V,p as D,f as I}from"./index-CgM2qJ96.js";const R={class:"mt-6 px-3"},U={class:"text-xl"},q={class:"font-medium"},F={class:"absolute bottom-0 left-0 right-0 p-4 border-t border-gray-200 dark:border-gray-700"},P={class:"flex items-center gap-3"},H={class:"w-10 h-10 rounded-full bg-primary-100 dark:bg-primary-900 flex items-center justify-center"},W={class:"text-primary-600 dark:text-primary-300 font-medium"},G={class:"flex-1 min-w-0"},J={class:"text-sm font-medium text-gray-900 dark:text-white truncate"},K={class:"text-xs text-gray-500 dark:text-gray-400 capitalize"},Q=w({__name:"AppSidebar",props:{open:{type:Boolean}},emits:["close"],setup(x){const l=N(),{t}=S(),r=L(),u=A(()=>{const s=[{name:t("nav.dashboard"),href:"/",icon:"📊"},{name:t("nav.orders"),href:"/orders",icon:"📋"}];return r.canManageUsers&&s.push({name:t("nav.users"),href:"/users",icon:"👥"},{name:t("nav.shifts"),href:"/shifts",icon:"📅"}),s.push({name:t("nav.availability"),href:"/availability",icon:"🗓️"},{name:t("nav.timesheets"),href:"/timesheets",icon:"⏱️"},{name:t("nav.qualifications"),href:"/qualifications",icon:"🎓"},{name:t("nav.objects"),href:"/objects",icon:"🏢"},{name:t("nav.patrols"),href:"/patrols",icon:"📍"},{name:t("nav.incidents"),href:"/incidents",icon:"🚨"},{name:t("nav.documents"),href:"/documents",icon:"📁"}),r.canManageUsers&&s.push({name:t("nav.vehicles"),href:"/vehicles",icon:"🚗"},{name:t("nav.customers"),href:"/customers",icon:"🤝"}),r.isChef&&s.push({name:t("nav.billing"),href:"/billing",icon:"💰"},{name:t("nav.modules"),href:"/modules",icon:"⚙️"}),s.push({name:t("nav.settings"),href:"/settings",icon:"🔧"},{name:t("nav.help"),href:"/help",icon:"📚"}),s});function g(s){return s==="/"?l.path==="/":l.path.startsWith(s)}return(s,a)=>{var m,v,h,y,p;const i=z("router-link");return d(),c("aside",{class:_(["fixed inset-y-0 left-0 z-50 w-64 bg-white dark:bg-gray-800 border-r border-gray-200 dark:border-gray-700 transform transition-transform lg:translate-x-0",x.open?"translate-x-0":"-translate-x-full"])},[a[1]||(a[1]=e("div",{class:"h-16 flex items-center px-6 border-b border-gray-200 dark:border-gray-700"},[e("span",{class:"text-2xl font-bold text-primary-600"},"🔐 SeCu")],-1)),e("nav",R,[(d(!0),c(B,null,j(u.value,b=>(d(),E(i,{key:b.href,to:b.href,class:_(["flex items-center gap-3 px-3 py-2 rounded-lg mb-1 transition-colors",g(b.href)?"bg-primary-100 text-primary-700 dark:bg-primary-900 dark:text-primary-200":"text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700"]),onClick:a[0]||(a[0]=_e=>s.$emit("close"))},{default:M(()=>[e("span",U,o(b.icon),1),e("span",q,o(b.name),1)]),_:2},1032,["to","class"]))),128))]),e("div",F,[e("div",P,[e("div",H,[e("span",W,o((v=(m=n(r).user)==null?void 0:m.first_name)==null?void 0:v[0])+o((y=(h=n(r).user)==null?void 0:h.last_name)==null?void 0:y[0]),1)]),e("div",G,[e("p",J,o(n(r).fullName),1),e("p",K,o((p=n(r).user)==null?void 0:p.role),1)])])])],2)}}}),X={class:"language-switcher relative"},Y=["title"],Z={class:"text-lg"},ee={class:"text-xs font-medium text-gray-600 dark:text-gray-300 uppercase"},te={key:0,class:"absolute right-0 mt-2 w-44 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50"},se=["onClick"],ae={class:"text-lg"},re={class:"flex-1 text-left"},oe={key:0,class:"w-4 h-4 text-primary-600 dark:text-primary-400",fill:"currentColor",viewBox:"0 0 20 20"},ne=w({__name:"LanguageSwitcher",setup(x){const{locale:l}=S(),t=k(!1),r=A(()=>C.find(s=>s.code===l.value)||C[0]);function u(s){V(s),t.value=!1}function g(s){s.target.closest(".language-switcher")||(t.value=!1)}return typeof window<"u"&&document.addEventListener("click",g),(s,a)=>(d(),c("div",X,[e("button",{class:"flex items-center gap-1.5 px-2 py-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",onClick:a[0]||(a[0]=O(i=>t.value=!t.value,["stop"])),title:s.$t("settings.language")},[e("span",Z,o(r.value.flag),1),e("span",ee,o(r.value.code),1),(d(),c("svg",{class:_(["w-3 h-3 text-gray-500 transition-transform",{"rotate-180":t.value}]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...a[1]||(a[1]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 9l-7 7-7-7"},null,-1)])],2))],8,Y),f(T,{"enter-active-class":"transition ease-out duration-100","enter-from-class":"transform opacity-0 scale-95","enter-to-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-from-class":"transform opacity-100 scale-100","leave-to-class":"transform opacity-0 scale-95"},{default:M(()=>[t.value?(d(),c("div",te,[(d(!0),c(B,null,j(n(C),i=>(d(),c("button",{key:i.code,class:_(["w-full flex items-center gap-3 px-3 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",{"bg-primary-50 dark:bg-primary-900/30 text-primary-600 dark:text-primary-400":i.code===n(l),"text-gray-700 dark:text-gray-200":i.code!==n(l)}]),onClick:m=>u(i.code)},[e("span",ae,o(i.flag),1),e("span",re,o(i.name),1),i.code===n(l)?(d(),c("svg",oe,[...a[2]||(a[2]=[e("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1)])])):$("",!0)],10,se))),128))])):$("",!0)]),_:1})]))}}),le={class:"h-16 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between px-4 lg:px-6"},ie={class:"flex-1 lg:ml-0"},de={class:"text-lg font-semibold text-gray-900 dark:text-white hidden lg:block"},ce={class:"flex items-center gap-2"},ue=["title"],ge={class:"text-xl"},me={class:"relative"},pe={class:"w-8 h-8 rounded-full bg-primary-100 dark:bg-primary-900 flex items-center justify-center"},fe={class:"text-primary-600 dark:text-primary-300 text-sm font-medium"},ve={class:"hidden sm:block text-sm font-medium text-gray-700 dark:text-gray-200"},he=w({__name:"AppHeader",emits:["toggle-sidebar","logout"],setup(x){const{t:l}=S(),t=L(),r=k(localStorage.getItem("darkMode")==="true"),u=k(!1);function g(){r.value=!r.value,localStorage.setItem("darkMode",String(r.value)),document.documentElement.classList.toggle("dark",r.value)}return r.value&&document.documentElement.classList.add("dark"),(s,a)=>{var m,v,h,y;const i=z("router-link");return d(),c("header",le,[e("button",{class:"lg:hidden p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700",onClick:a[0]||(a[0]=p=>s.$emit("toggle-sidebar"))},[...a[4]||(a[4]=[e("span",{class:"text-2xl"},"☰",-1)])]),e("div",ie,[e("h1",de,o(n(l)("app.title")),1)]),e("div",ce,[f(ne),e("button",{class:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700",onClick:g,title:r.value?n(l)("settings.lightMode"):n(l)("settings.darkMode")},[e("span",ge,o(r.value?"☀️":"🌙"),1)],8,ue),e("div",me,[e("button",{class:"flex items-center gap-2 p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700",onClick:a[1]||(a[1]=p=>u.value=!u.value)},[e("div",pe,[e("span",fe,o((v=(m=n(t).user)==null?void 0:m.first_name)==null?void 0:v[0])+o((y=(h=n(t).user)==null?void 0:h.last_name)==null?void 0:y[0]),1)]),e("span",ve,o(n(t).fullName),1)]),u.value?(d(),c("div",{key:0,class:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50",onClick:a[3]||(a[3]=p=>u.value=!1)},[f(i,{to:"/settings",class:"block px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700"},{default:M(()=>[D(" ⚙️ "+o(n(l)("nav.settings")),1)]),_:1}),a[5]||(a[5]=e("hr",{class:"my-1 border-gray-200 dark:border-gray-700"},null,-1)),e("button",{class:"w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20",onClick:a[2]||(a[2]=p=>s.$emit("logout"))}," 🚪 "+o(n(l)("auth.logout")),1)])):$("",!0)])])])}}}),ye={class:"min-h-screen bg-gray-50 dark:bg-gray-900"},be={class:"lg:pl-64"},xe={class:"p-6"},$e=w({__name:"AppLayout",setup(x){const l=L(),t=I(),r=k(!1);async function u(){await l.logout(),t.push("/login")}return(g,s)=>{const a=z("router-view");return d(),c("div",ye,[r.value?(d(),c("div",{key:0,class:"fixed inset-0 z-40 bg-black/50 lg:hidden",onClick:s[0]||(s[0]=i=>r.value=!1)})):$("",!0),f(Q,{open:r.value,onClose:s[1]||(s[1]=i=>r.value=!1)},null,8,["open"]),e("div",be,[f(he,{onToggleSidebar:s[2]||(s[2]=i=>r.value=!r.value),onLogout:u}),e("main",xe,[f(a)])])])}}});export{$e as default}; diff --git a/dist/assets/AvailabilityView-3FfkRQ5Z.js b/dist/assets/AvailabilityView-3FfkRQ5Z.js new file mode 100644 index 0000000..ae0eee1 --- /dev/null +++ b/dist/assets/AvailabilityView-3FfkRQ5Z.js @@ -0,0 +1 @@ +import{d as D,u as S,q as M,m as h,c as l,a as o,t as u,F as C,x as F,C as A,r as v,k as m,n as L,o as i}from"./index-CgM2qJ96.js";const O={class:"space-y-6"},V={class:"card"},E={class:"flex items-center justify-between mb-6"},I={class:"text-lg font-semibold"},W={key:0,class:"text-center py-8 text-gray-500"},Y={key:1,class:"grid grid-cols-7 gap-2"},B={class:"text-xs text-gray-500 mb-1"},N=["onClick"],j=D({__name:"AvailabilityView",setup(T){const f=S(),a=v(new Date),y=v([]),g=v(!0),p=m(()=>{const n=a.value.getFullYear(),e=a.value.getMonth(),t=new Date(n,e+1,0).getDate();return Array.from({length:t},(s,r)=>{const d=new Date(n,e,r+1);return{date:d.toISOString().split("T")[0],dayOfWeek:d.toLocaleDateString("de-DE",{weekday:"short"}),day:r+1,isWeekend:d.getDay()===0||d.getDay()===6}})}),_=m(()=>a.value.toLocaleDateString("de-DE",{month:"long",year:"numeric"}));M(c);async function c(){g.value=!0;const n=a.value.getFullYear(),e=a.value.getMonth(),t=new Date(n,e,1).toISOString().split("T")[0],s=new Date(n,e+1,0).toISOString().split("T")[0];try{const r=await h.get(`/availability?from=${t}&to=${s}`);y.value=r.data.availability}catch(r){console.error(r)}finally{g.value=!1}}function b(n){return y.value.find(e=>{var t;return e.date===n&&e.user_id===((t=f.user)==null?void 0:t.id)})}async function k(n){const e=b(n),t=!(e!=null&&e.available);try{await h.post("/availability",{date:n,available:t}),await c()}catch(s){alert(s instanceof Error?s.message:"Fehler")}}function x(){a.value=new Date(a.value.getFullYear(),a.value.getMonth()-1),c()}function w(){a.value=new Date(a.value.getFullYear(),a.value.getMonth()+1),c()}return(n,e)=>(i(),l("div",O,[e[1]||(e[1]=o("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"},"📅 Verfügbarkeit",-1)),o("div",V,[o("div",E,[o("button",{class:"btn btn-secondary",onClick:x},"←"),o("h2",I,u(_.value),1),o("button",{class:"btn btn-secondary",onClick:w},"→")]),g.value?(i(),l("div",W,"Lädt...")):(i(),l("div",Y,[(i(!0),l(C,null,F(p.value,t=>{var s;return i(),l("div",{key:t.date,class:"text-center"},[o("div",B,u(t.dayOfWeek),1),o("button",{class:L(["w-10 h-10 rounded-lg font-medium transition-colors",t.isWeekend?"bg-gray-100 dark:bg-gray-700":"",(s=b(t.date))!=null&&s.available?"bg-green-500 text-white hover:bg-green-600":"bg-gray-200 dark:bg-gray-600 hover:bg-gray-300 dark:hover:bg-gray-500"]),onClick:r=>k(t.date)},u(t.day),11,N)])}),128))])),e[0]||(e[0]=A('
Verfügbar
Nicht gemeldet
',1))])]))}});export{j as default}; diff --git a/dist/assets/AvailabilityView-BNPzNcWA.js b/dist/assets/AvailabilityView-BNPzNcWA.js deleted file mode 100644 index 12ee7f2..0000000 --- a/dist/assets/AvailabilityView-BNPzNcWA.js +++ /dev/null @@ -1 +0,0 @@ -import{d as D,u as S,q as M,m as h,c as l,a as o,t as u,F,x as A,A as C,r as v,k as m,o as i,n as L}from"./index-CWxNv9Fc.js";const O={class:"space-y-6"},V={class:"card"},E={class:"flex items-center justify-between mb-6"},I={class:"text-lg font-semibold"},W={key:0,class:"text-center py-8 text-gray-500"},Y={key:1,class:"grid grid-cols-7 gap-2"},B={class:"text-xs text-gray-500 mb-1"},N=["onClick"],j=D({__name:"AvailabilityView",setup(T){const f=S(),a=v(new Date),y=v([]),g=v(!0),p=m(()=>{const n=a.value.getFullYear(),e=a.value.getMonth(),t=new Date(n,e+1,0).getDate();return Array.from({length:t},(s,r)=>{const d=new Date(n,e,r+1);return{date:d.toISOString().split("T")[0],dayOfWeek:d.toLocaleDateString("de-DE",{weekday:"short"}),day:r+1,isWeekend:d.getDay()===0||d.getDay()===6}})}),_=m(()=>a.value.toLocaleDateString("de-DE",{month:"long",year:"numeric"}));M(c);async function c(){g.value=!0;const n=a.value.getFullYear(),e=a.value.getMonth(),t=new Date(n,e,1).toISOString().split("T")[0],s=new Date(n,e+1,0).toISOString().split("T")[0];try{const r=await h.get(`/availability?from=${t}&to=${s}`);y.value=r.data.availability}catch(r){console.error(r)}finally{g.value=!1}}function b(n){return y.value.find(e=>{var t;return e.date===n&&e.user_id===((t=f.user)==null?void 0:t.id)})}async function k(n){const e=b(n),t=!(e!=null&&e.available);try{await h.post("/availability",{date:n,available:t}),await c()}catch(s){alert(s instanceof Error?s.message:"Fehler")}}function x(){a.value=new Date(a.value.getFullYear(),a.value.getMonth()-1),c()}function w(){a.value=new Date(a.value.getFullYear(),a.value.getMonth()+1),c()}return(n,e)=>(i(),l("div",O,[e[1]||(e[1]=o("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"},"📅 Verfügbarkeit",-1)),o("div",V,[o("div",E,[o("button",{class:"btn btn-secondary",onClick:x},"←"),o("h2",I,u(_.value),1),o("button",{class:"btn btn-secondary",onClick:w},"→")]),g.value?(i(),l("div",W,"Lädt...")):(i(),l("div",Y,[(i(!0),l(F,null,A(p.value,t=>{var s;return i(),l("div",{key:t.date,class:"text-center"},[o("div",B,u(t.dayOfWeek),1),o("button",{class:L(["w-10 h-10 rounded-lg font-medium transition-colors",t.isWeekend?"bg-gray-100 dark:bg-gray-700":"",(s=b(t.date))!=null&&s.available?"bg-green-500 text-white hover:bg-green-600":"bg-gray-200 dark:bg-gray-600 hover:bg-gray-300 dark:hover:bg-gray-500"]),onClick:r=>k(t.date)},u(t.day),11,N)])}),128))])),e[0]||(e[0]=C('
Verfügbar
Nicht gemeldet
',1))])]))}});export{j as default}; diff --git a/dist/assets/BillingView-TAMo2net.js b/dist/assets/BillingView-CuPKcrTa.js similarity index 98% rename from dist/assets/BillingView-TAMo2net.js rename to dist/assets/BillingView-CuPKcrTa.js index c069e06..04ddeb5 100644 --- a/dist/assets/BillingView-TAMo2net.js +++ b/dist/assets/BillingView-CuPKcrTa.js @@ -1 +1 @@ -import{d as S,q as C,m as c,c as a,a as t,t as n,n as _,F as h,x as v,e as p,r as u,o}from"./index-CWxNv9Fc.js";const B={class:"p-6"},z={class:"grid grid-cols-4 gap-4 mb-6"},R={class:"bg-white rounded-lg shadow p-4"},D={class:"text-2xl font-bold text-blue-600"},$={class:"text-sm text-gray-500"},E={class:"bg-white rounded-lg shadow p-4"},F={class:"text-2xl font-bold text-red-600"},N={class:"text-sm text-gray-500"},A={class:"bg-white rounded-lg shadow p-4"},K={class:"text-2xl font-bold text-green-600"},L={class:"bg-white rounded-lg shadow p-4"},T={class:"text-2xl font-bold"},V={class:"flex space-x-1 border-b mb-6"},j={key:0,class:"text-center py-12"},I={key:1},M={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},P={key:1,class:"bg-white rounded-lg shadow overflow-hidden"},q={class:"min-w-full divide-y divide-gray-200"},G={class:"divide-y divide-gray-200"},O={class:"px-4 py-3 text-sm font-medium"},U={class:"px-4 py-3 text-sm"},H={class:"px-4 py-3 text-sm"},J={class:"px-4 py-3 text-sm text-right font-semibold"},Q={class:"px-4 py-3"},W={class:"px-4 py-3 text-right text-sm space-x-2"},X=["onClick"],Y=["onClick"],Z={key:2},tt={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},et={key:1,class:"grid md:grid-cols-2 lg:grid-cols-3 gap-4"},st={class:"flex justify-between items-start"},at={class:"font-semibold"},nt={class:"text-sm text-gray-500"},ot={key:0,class:"px-2 py-1 text-xs bg-blue-100 text-blue-700 rounded"},lt={class:"text-2xl font-bold mt-2"},dt={class:"text-sm text-gray-500"},ct=S({__name:"BillingView",setup(it){const g=u(!0),y=u([]),x=u([]),d=u({}),i=u("invoices");C(async()=>{await m()});async function m(){g.value=!0;try{const[l,e,s]=await Promise.all([c.get("/billing/invoices"),c.get("/billing/rates"),c.get("/billing/stats")]);y.value=l.data.invoices||[],x.value=e.data.rates||[],d.value=s.data.stats||{}}catch(l){console.error(l)}g.value=!1}async function f(l){try{await c.put(`/billing/invoices/${l}/send`,{}),await m()}catch(e){alert("Fehler: "+e.message)}}async function w(l){try{await c.put(`/billing/invoices/${l}/pay`,{payment_method:"Überweisung"}),await m()}catch(e){alert("Fehler: "+e.message)}}function b(l){return{draft:{text:"Entwurf",class:"bg-gray-100 text-gray-700"},sent:{text:"Gesendet",class:"bg-blue-100 text-blue-700"},paid:{text:"Bezahlt",class:"bg-green-100 text-green-700"},overdue:{text:"Überfällig",class:"bg-red-100 text-red-700"},cancelled:{text:"Storniert",class:"bg-gray-100 text-gray-700"}}[l]||{text:l,class:"bg-gray-100"}}function r(l){return new Intl.NumberFormat("de-DE",{style:"currency",currency:"EUR"}).format(l||0)}return(l,e)=>(o(),a("div",B,[e[9]||(e[9]=t("div",{class:"flex justify-between items-center mb-6"},[t("div",null,[t("h1",{class:"text-2xl font-bold"},"💰 Abrechnung"),t("p",{class:"text-gray-500"},"Rechnungen & Sätze")])],-1)),t("div",z,[t("div",R,[e[2]||(e[2]=t("p",{class:"text-sm text-gray-500"},"Offene Rechnungen",-1)),t("p",D,n(d.value.open_invoices||0),1),t("p",$,n(r(d.value.open_amount)),1)]),t("div",E,[e[3]||(e[3]=t("p",{class:"text-sm text-gray-500"},"Überfällig",-1)),t("p",F,n(d.value.overdue_invoices||0),1),t("p",N,n(r(d.value.overdue_amount)),1)]),t("div",A,[e[4]||(e[4]=t("p",{class:"text-sm text-gray-500"},"Bezahlt (30 Tage)",-1)),t("p",K,n(r(d.value.paid_last_30_days)),1)]),t("div",L,[e[5]||(e[5]=t("p",{class:"text-sm text-gray-500"},"Stundensätze",-1)),t("p",T,n(x.value.length),1)])]),t("div",V,[t("button",{onClick:e[0]||(e[0]=s=>i.value="invoices"),class:_(["px-4 py-2 font-medium border-b-2 -mb-px",i.value==="invoices"?"border-blue-600 text-blue-600":"border-transparent"])}," Rechnungen ",2),t("button",{onClick:e[1]||(e[1]=s=>i.value="rates"),class:_(["px-4 py-2 font-medium border-b-2 -mb-px",i.value==="rates"?"border-blue-600 text-blue-600":"border-transparent"])}," Stundensätze ",2)]),g.value?(o(),a("div",j,"Laden...")):i.value==="invoices"?(o(),a("div",I,[y.value.length===0?(o(),a("div",M,[...e[6]||(e[6]=[t("p",{class:"text-4xl mb-4"},"📄",-1),t("p",null,"Keine Rechnungen vorhanden",-1)])])):(o(),a("div",P,[t("table",q,[e[7]||(e[7]=t("thead",{class:"bg-gray-50"},[t("tr",null,[t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Nr."),t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Kunde"),t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Datum"),t("th",{class:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase"},"Betrag"),t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Status"),t("th",{class:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase"},"Aktionen")])],-1)),t("tbody",G,[(o(!0),a(h,null,v(y.value,s=>(o(),a("tr",{key:s.id,class:"hover:bg-gray-50"},[t("td",O,n(s.invoice_number),1),t("td",U,n(s.customer_name),1),t("td",H,n(new Date(s.invoice_date).toLocaleDateString("de-DE")),1),t("td",J,n(r(s.total)),1),t("td",Q,[t("span",{class:_(["px-2 py-1 text-xs rounded",b(s.status).class])},n(b(s.status).text),3)]),t("td",W,[s.status==="draft"?(o(),a("button",{key:0,onClick:k=>f(s.id),class:"text-blue-600 hover:underline"},"Senden",8,X)):p("",!0),s.status==="sent"||s.status==="overdue"?(o(),a("button",{key:1,onClick:k=>w(s.id),class:"text-green-600 hover:underline"},"Bezahlt",8,Y)):p("",!0)])]))),128))])])]))])):i.value==="rates"?(o(),a("div",Z,[x.value.length===0?(o(),a("div",tt,[...e[8]||(e[8]=[t("p",{class:"text-4xl mb-4"},"💵",-1),t("p",null,"Keine Stundensätze definiert",-1)])])):(o(),a("div",et,[(o(!0),a(h,null,v(x.value,s=>(o(),a("div",{key:s.id,class:"bg-white rounded-lg shadow p-4"},[t("div",st,[t("div",null,[t("h3",at,n(s.name),1),t("p",nt,n(s.customer_name||"Allgemein"),1)]),s.is_default?(o(),a("span",ot,"Standard")):p("",!0)]),t("p",lt,n(r(s.amount)),1),t("p",dt,"pro "+n(s.rate_type==="hourly"?"Stunde":s.rate_type==="daily"?"Tag":"Monat"),1)]))),128))]))])):p("",!0)]))}});export{ct as default}; +import{d as S,q as C,m as c,c as a,a as t,t as n,n as _,F as h,x as v,e as p,r as u,o}from"./index-CgM2qJ96.js";const B={class:"p-6"},z={class:"grid grid-cols-4 gap-4 mb-6"},R={class:"bg-white rounded-lg shadow p-4"},D={class:"text-2xl font-bold text-blue-600"},$={class:"text-sm text-gray-500"},E={class:"bg-white rounded-lg shadow p-4"},F={class:"text-2xl font-bold text-red-600"},N={class:"text-sm text-gray-500"},A={class:"bg-white rounded-lg shadow p-4"},K={class:"text-2xl font-bold text-green-600"},L={class:"bg-white rounded-lg shadow p-4"},T={class:"text-2xl font-bold"},V={class:"flex space-x-1 border-b mb-6"},j={key:0,class:"text-center py-12"},I={key:1},M={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},P={key:1,class:"bg-white rounded-lg shadow overflow-hidden"},q={class:"min-w-full divide-y divide-gray-200"},G={class:"divide-y divide-gray-200"},O={class:"px-4 py-3 text-sm font-medium"},U={class:"px-4 py-3 text-sm"},H={class:"px-4 py-3 text-sm"},J={class:"px-4 py-3 text-sm text-right font-semibold"},Q={class:"px-4 py-3"},W={class:"px-4 py-3 text-right text-sm space-x-2"},X=["onClick"],Y=["onClick"],Z={key:2},tt={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},et={key:1,class:"grid md:grid-cols-2 lg:grid-cols-3 gap-4"},st={class:"flex justify-between items-start"},at={class:"font-semibold"},nt={class:"text-sm text-gray-500"},ot={key:0,class:"px-2 py-1 text-xs bg-blue-100 text-blue-700 rounded"},lt={class:"text-2xl font-bold mt-2"},dt={class:"text-sm text-gray-500"},ct=S({__name:"BillingView",setup(it){const g=u(!0),y=u([]),x=u([]),d=u({}),i=u("invoices");C(async()=>{await m()});async function m(){g.value=!0;try{const[l,e,s]=await Promise.all([c.get("/billing/invoices"),c.get("/billing/rates"),c.get("/billing/stats")]);y.value=l.data.invoices||[],x.value=e.data.rates||[],d.value=s.data.stats||{}}catch(l){console.error(l)}g.value=!1}async function f(l){try{await c.put(`/billing/invoices/${l}/send`,{}),await m()}catch(e){alert("Fehler: "+e.message)}}async function w(l){try{await c.put(`/billing/invoices/${l}/pay`,{payment_method:"Überweisung"}),await m()}catch(e){alert("Fehler: "+e.message)}}function b(l){return{draft:{text:"Entwurf",class:"bg-gray-100 text-gray-700"},sent:{text:"Gesendet",class:"bg-blue-100 text-blue-700"},paid:{text:"Bezahlt",class:"bg-green-100 text-green-700"},overdue:{text:"Überfällig",class:"bg-red-100 text-red-700"},cancelled:{text:"Storniert",class:"bg-gray-100 text-gray-700"}}[l]||{text:l,class:"bg-gray-100"}}function r(l){return new Intl.NumberFormat("de-DE",{style:"currency",currency:"EUR"}).format(l||0)}return(l,e)=>(o(),a("div",B,[e[9]||(e[9]=t("div",{class:"flex justify-between items-center mb-6"},[t("div",null,[t("h1",{class:"text-2xl font-bold"},"💰 Abrechnung"),t("p",{class:"text-gray-500"},"Rechnungen & Sätze")])],-1)),t("div",z,[t("div",R,[e[2]||(e[2]=t("p",{class:"text-sm text-gray-500"},"Offene Rechnungen",-1)),t("p",D,n(d.value.open_invoices||0),1),t("p",$,n(r(d.value.open_amount)),1)]),t("div",E,[e[3]||(e[3]=t("p",{class:"text-sm text-gray-500"},"Überfällig",-1)),t("p",F,n(d.value.overdue_invoices||0),1),t("p",N,n(r(d.value.overdue_amount)),1)]),t("div",A,[e[4]||(e[4]=t("p",{class:"text-sm text-gray-500"},"Bezahlt (30 Tage)",-1)),t("p",K,n(r(d.value.paid_last_30_days)),1)]),t("div",L,[e[5]||(e[5]=t("p",{class:"text-sm text-gray-500"},"Stundensätze",-1)),t("p",T,n(x.value.length),1)])]),t("div",V,[t("button",{onClick:e[0]||(e[0]=s=>i.value="invoices"),class:_(["px-4 py-2 font-medium border-b-2 -mb-px",i.value==="invoices"?"border-blue-600 text-blue-600":"border-transparent"])}," Rechnungen ",2),t("button",{onClick:e[1]||(e[1]=s=>i.value="rates"),class:_(["px-4 py-2 font-medium border-b-2 -mb-px",i.value==="rates"?"border-blue-600 text-blue-600":"border-transparent"])}," Stundensätze ",2)]),g.value?(o(),a("div",j,"Laden...")):i.value==="invoices"?(o(),a("div",I,[y.value.length===0?(o(),a("div",M,[...e[6]||(e[6]=[t("p",{class:"text-4xl mb-4"},"📄",-1),t("p",null,"Keine Rechnungen vorhanden",-1)])])):(o(),a("div",P,[t("table",q,[e[7]||(e[7]=t("thead",{class:"bg-gray-50"},[t("tr",null,[t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Nr."),t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Kunde"),t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Datum"),t("th",{class:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase"},"Betrag"),t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Status"),t("th",{class:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase"},"Aktionen")])],-1)),t("tbody",G,[(o(!0),a(h,null,v(y.value,s=>(o(),a("tr",{key:s.id,class:"hover:bg-gray-50"},[t("td",O,n(s.invoice_number),1),t("td",U,n(s.customer_name),1),t("td",H,n(new Date(s.invoice_date).toLocaleDateString("de-DE")),1),t("td",J,n(r(s.total)),1),t("td",Q,[t("span",{class:_(["px-2 py-1 text-xs rounded",b(s.status).class])},n(b(s.status).text),3)]),t("td",W,[s.status==="draft"?(o(),a("button",{key:0,onClick:k=>f(s.id),class:"text-blue-600 hover:underline"},"Senden",8,X)):p("",!0),s.status==="sent"||s.status==="overdue"?(o(),a("button",{key:1,onClick:k=>w(s.id),class:"text-green-600 hover:underline"},"Bezahlt",8,Y)):p("",!0)])]))),128))])])]))])):i.value==="rates"?(o(),a("div",Z,[x.value.length===0?(o(),a("div",tt,[...e[8]||(e[8]=[t("p",{class:"text-4xl mb-4"},"💵",-1),t("p",null,"Keine Stundensätze definiert",-1)])])):(o(),a("div",et,[(o(!0),a(h,null,v(x.value,s=>(o(),a("div",{key:s.id,class:"bg-white rounded-lg shadow p-4"},[t("div",st,[t("div",null,[t("h3",at,n(s.name),1),t("p",nt,n(s.customer_name||"Allgemein"),1)]),s.is_default?(o(),a("span",ot,"Standard")):p("",!0)]),t("p",lt,n(r(s.amount)),1),t("p",dt,"pro "+n(s.rate_type==="hourly"?"Stunde":s.rate_type==="daily"?"Tag":"Monat"),1)]))),128))]))])):p("",!0)]))}});export{ct as default}; diff --git a/dist/assets/CustomersView-B4K9IT7m.js b/dist/assets/CustomersView-Cp1mYV9m.js similarity index 98% rename from dist/assets/CustomersView-B4K9IT7m.js rename to dist/assets/CustomersView-Cp1mYV9m.js index e525d76..b7b5b17 100644 --- a/dist/assets/CustomersView-B4K9IT7m.js +++ b/dist/assets/CustomersView-Cp1mYV9m.js @@ -1 +1 @@ -import{d as K,q as U,m as x,c as l,a as t,F as y,x as g,t as a,e as m,b as u,v as r,r as c,o as n,n as C}from"./index-CWxNv9Fc.js";const M={class:"p-6"},A={class:"flex justify-between items-center mb-6"},B={class:"flex gap-6"},F={class:"w-1/2"},$={key:0,class:"text-center py-12"},D={key:1,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},E={key:2,class:"space-y-2"},L=["onClick"],N={class:"flex justify-between items-start"},z={class:"font-semibold"},I={class:"text-sm text-gray-500"},O={class:"mt-2 flex gap-4 text-xs text-gray-500"},S={key:0},T={key:1},q={class:"w-1/2"},P={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-400"},R={key:1,class:"bg-white rounded-lg shadow p-6"},W={class:"text-xl font-bold mb-4"},Z={class:"space-y-4"},G={class:"text-sm"},H={class:"text-sm"},J={key:0},Q={class:"text-sm font-semibold text-gray-500 mb-2"},X={class:"font-medium"},Y={key:0,class:"ml-2 text-green-600"},tt={key:1},et={class:"text-sm font-semibold text-gray-500 mb-2"},st={key:0,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},lt={class:"bg-white rounded-lg shadow-xl w-full max-w-lg p-6"},nt={class:"space-y-4"},at={class:"grid grid-cols-2 gap-4"},ot={class:"grid grid-cols-2 gap-4"},it={class:"flex justify-end space-x-2 mt-6"},mt=K({__name:"CustomersView",setup(dt){const v=c(!0),b=c([]),p=c(!1),o=c(null),i=c({company_name:"",contact_person:"",email:"",phone:"",address:"",city:"",postal_code:""});U(async()=>{await _()});async function _(){v.value=!0;try{const d=await x.get("/customers");b.value=d.data.customers||[]}catch(d){console.error(d)}v.value=!1}async function V(d){try{const e=await x.get(`/customers/${d}`);o.value=e.data}catch(e){console.error(e)}}async function j(){try{await x.post("/customers",i.value),p.value=!1,i.value={company_name:"",contact_person:"",email:"",phone:"",address:"",city:"",postal_code:""},await _()}catch(d){alert("Fehler: "+d.message)}}function f(d){return{active:{text:"Aktiv",class:"bg-green-100 text-green-700"},inactive:{text:"Inaktiv",class:"bg-gray-100 text-gray-700"},prospect:{text:"Interessent",class:"bg-blue-100 text-blue-700"}}[d]||{text:d,class:"bg-gray-100"}}return(d,e)=>{var k,h;return n(),l("div",M,[t("div",A,[e[9]||(e[9]=t("div",null,[t("h1",{class:"text-2xl font-bold"},"👥 Kunden / CRM"),t("p",{class:"text-gray-500"},"Kundenverwaltung & Verträge")],-1)),t("button",{onClick:e[0]||(e[0]=s=>p.value=!0),class:"btn btn-primary"},"+ Kunde")]),t("div",B,[t("div",F,[v.value?(n(),l("div",$,"Laden...")):b.value.length===0?(n(),l("div",D,[...e[10]||(e[10]=[t("p",{class:"text-4xl mb-4"},"👥",-1),t("p",null,"Keine Kunden vorhanden",-1)])])):(n(),l("div",E,[(n(!0),l(y,null,g(b.value,s=>{var w;return n(),l("div",{key:s.id,onClick:ut=>V(s.id),class:C(["bg-white rounded-lg shadow p-4 cursor-pointer hover:shadow-md transition-shadow",((w=o.value)==null?void 0:w.id)===s.id?"ring-2 ring-blue-500":""])},[t("div",N,[t("div",null,[t("h3",z,a(s.company_name),1),t("p",I,a(s.contact_person),1)]),t("span",{class:C(["px-2 py-1 text-xs rounded",f(s.status).class])},a(f(s.status).text),3)]),t("div",O,[s.active_contracts?(n(),l("span",S,"📄 "+a(s.active_contracts)+" Verträge",1)):m("",!0),s.object_count?(n(),l("span",T,"🏢 "+a(s.object_count)+" Objekte",1)):m("",!0)])],10,L)}),128))]))]),t("div",q,[o.value?(n(),l("div",R,[t("h2",W,a(o.value.company_name),1),t("div",Z,[t("div",null,[e[12]||(e[12]=t("h3",{class:"text-sm font-semibold text-gray-500 mb-2"},"Kontakt",-1)),t("p",null,a(o.value.contact_person),1),t("p",G,"📧 "+a(o.value.email||"-"),1),t("p",H,"📞 "+a(o.value.phone||"-"),1)]),t("div",null,[e[13]||(e[13]=t("h3",{class:"text-sm font-semibold text-gray-500 mb-2"},"Adresse",-1)),t("p",null,a(o.value.address),1),t("p",null,a(o.value.postal_code)+" "+a(o.value.city),1)]),(k=o.value.contracts)!=null&&k.length?(n(),l("div",J,[t("h3",Q,"Verträge ("+a(o.value.contracts.length)+")",1),(n(!0),l(y,null,g(o.value.contracts,s=>(n(),l("div",{key:s.id,class:"text-sm p-2 bg-gray-50 rounded mb-1"},[t("span",X,a(s.title||s.contract_number),1),s.monthly_value?(n(),l("span",Y,a(s.monthly_value)+"€/Monat",1)):m("",!0)]))),128))])):m("",!0),(h=o.value.objects)!=null&&h.length?(n(),l("div",tt,[t("h3",et,"Objekte ("+a(o.value.objects.length)+")",1),(n(!0),l(y,null,g(o.value.objects,s=>(n(),l("div",{key:s.id,class:"text-sm"}," 🏢 "+a(s.name),1))),128))])):m("",!0)])])):(n(),l("div",P,[...e[11]||(e[11]=[t("p",null,"Wähle einen Kunden aus",-1)])]))])]),p.value?(n(),l("div",st,[t("div",lt,[e[21]||(e[21]=t("h2",{class:"text-xl font-bold mb-4"},"Neuer Kunde",-1)),t("div",nt,[t("div",null,[e[14]||(e[14]=t("label",{class:"block text-sm font-medium mb-1"},"Firmenname *",-1)),u(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>i.value.company_name=s),class:"input"},null,512),[[r,i.value.company_name]])]),t("div",null,[e[15]||(e[15]=t("label",{class:"block text-sm font-medium mb-1"},"Ansprechpartner",-1)),u(t("input",{"onUpdate:modelValue":e[2]||(e[2]=s=>i.value.contact_person=s),class:"input"},null,512),[[r,i.value.contact_person]])]),t("div",at,[t("div",null,[e[16]||(e[16]=t("label",{class:"block text-sm font-medium mb-1"},"E-Mail",-1)),u(t("input",{"onUpdate:modelValue":e[3]||(e[3]=s=>i.value.email=s),type:"email",class:"input"},null,512),[[r,i.value.email]])]),t("div",null,[e[17]||(e[17]=t("label",{class:"block text-sm font-medium mb-1"},"Telefon",-1)),u(t("input",{"onUpdate:modelValue":e[4]||(e[4]=s=>i.value.phone=s),class:"input"},null,512),[[r,i.value.phone]])])]),t("div",null,[e[18]||(e[18]=t("label",{class:"block text-sm font-medium mb-1"},"Adresse",-1)),u(t("input",{"onUpdate:modelValue":e[5]||(e[5]=s=>i.value.address=s),class:"input"},null,512),[[r,i.value.address]])]),t("div",ot,[t("div",null,[e[19]||(e[19]=t("label",{class:"block text-sm font-medium mb-1"},"PLZ",-1)),u(t("input",{"onUpdate:modelValue":e[6]||(e[6]=s=>i.value.postal_code=s),class:"input"},null,512),[[r,i.value.postal_code]])]),t("div",null,[e[20]||(e[20]=t("label",{class:"block text-sm font-medium mb-1"},"Stadt",-1)),u(t("input",{"onUpdate:modelValue":e[7]||(e[7]=s=>i.value.city=s),class:"input"},null,512),[[r,i.value.city]])])])]),t("div",it,[t("button",{onClick:e[8]||(e[8]=s=>p.value=!1),class:"btn"},"Abbrechen"),t("button",{onClick:j,class:"btn btn-primary"},"Erstellen")])])])):m("",!0)])}}});export{mt as default}; +import{d as K,q as U,m as x,c as l,a as t,F as y,x as g,t as a,e as m,b as u,v as r,r as c,n as C,o as n}from"./index-CgM2qJ96.js";const M={class:"p-6"},A={class:"flex justify-between items-center mb-6"},B={class:"flex gap-6"},F={class:"w-1/2"},$={key:0,class:"text-center py-12"},D={key:1,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},E={key:2,class:"space-y-2"},L=["onClick"],N={class:"flex justify-between items-start"},z={class:"font-semibold"},I={class:"text-sm text-gray-500"},O={class:"mt-2 flex gap-4 text-xs text-gray-500"},S={key:0},T={key:1},q={class:"w-1/2"},P={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-400"},R={key:1,class:"bg-white rounded-lg shadow p-6"},W={class:"text-xl font-bold mb-4"},Z={class:"space-y-4"},G={class:"text-sm"},H={class:"text-sm"},J={key:0},Q={class:"text-sm font-semibold text-gray-500 mb-2"},X={class:"font-medium"},Y={key:0,class:"ml-2 text-green-600"},tt={key:1},et={class:"text-sm font-semibold text-gray-500 mb-2"},st={key:0,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},lt={class:"bg-white rounded-lg shadow-xl w-full max-w-lg p-6"},nt={class:"space-y-4"},at={class:"grid grid-cols-2 gap-4"},ot={class:"grid grid-cols-2 gap-4"},it={class:"flex justify-end space-x-2 mt-6"},mt=K({__name:"CustomersView",setup(dt){const v=c(!0),b=c([]),p=c(!1),o=c(null),i=c({company_name:"",contact_person:"",email:"",phone:"",address:"",city:"",postal_code:""});U(async()=>{await _()});async function _(){v.value=!0;try{const d=await x.get("/customers");b.value=d.data.customers||[]}catch(d){console.error(d)}v.value=!1}async function V(d){try{const e=await x.get(`/customers/${d}`);o.value=e.data}catch(e){console.error(e)}}async function j(){try{await x.post("/customers",i.value),p.value=!1,i.value={company_name:"",contact_person:"",email:"",phone:"",address:"",city:"",postal_code:""},await _()}catch(d){alert("Fehler: "+d.message)}}function f(d){return{active:{text:"Aktiv",class:"bg-green-100 text-green-700"},inactive:{text:"Inaktiv",class:"bg-gray-100 text-gray-700"},prospect:{text:"Interessent",class:"bg-blue-100 text-blue-700"}}[d]||{text:d,class:"bg-gray-100"}}return(d,e)=>{var k,h;return n(),l("div",M,[t("div",A,[e[9]||(e[9]=t("div",null,[t("h1",{class:"text-2xl font-bold"},"👥 Kunden / CRM"),t("p",{class:"text-gray-500"},"Kundenverwaltung & Verträge")],-1)),t("button",{onClick:e[0]||(e[0]=s=>p.value=!0),class:"btn btn-primary"},"+ Kunde")]),t("div",B,[t("div",F,[v.value?(n(),l("div",$,"Laden...")):b.value.length===0?(n(),l("div",D,[...e[10]||(e[10]=[t("p",{class:"text-4xl mb-4"},"👥",-1),t("p",null,"Keine Kunden vorhanden",-1)])])):(n(),l("div",E,[(n(!0),l(y,null,g(b.value,s=>{var w;return n(),l("div",{key:s.id,onClick:ut=>V(s.id),class:C(["bg-white rounded-lg shadow p-4 cursor-pointer hover:shadow-md transition-shadow",((w=o.value)==null?void 0:w.id)===s.id?"ring-2 ring-blue-500":""])},[t("div",N,[t("div",null,[t("h3",z,a(s.company_name),1),t("p",I,a(s.contact_person),1)]),t("span",{class:C(["px-2 py-1 text-xs rounded",f(s.status).class])},a(f(s.status).text),3)]),t("div",O,[s.active_contracts?(n(),l("span",S,"📄 "+a(s.active_contracts)+" Verträge",1)):m("",!0),s.object_count?(n(),l("span",T,"🏢 "+a(s.object_count)+" Objekte",1)):m("",!0)])],10,L)}),128))]))]),t("div",q,[o.value?(n(),l("div",R,[t("h2",W,a(o.value.company_name),1),t("div",Z,[t("div",null,[e[12]||(e[12]=t("h3",{class:"text-sm font-semibold text-gray-500 mb-2"},"Kontakt",-1)),t("p",null,a(o.value.contact_person),1),t("p",G,"📧 "+a(o.value.email||"-"),1),t("p",H,"📞 "+a(o.value.phone||"-"),1)]),t("div",null,[e[13]||(e[13]=t("h3",{class:"text-sm font-semibold text-gray-500 mb-2"},"Adresse",-1)),t("p",null,a(o.value.address),1),t("p",null,a(o.value.postal_code)+" "+a(o.value.city),1)]),(k=o.value.contracts)!=null&&k.length?(n(),l("div",J,[t("h3",Q,"Verträge ("+a(o.value.contracts.length)+")",1),(n(!0),l(y,null,g(o.value.contracts,s=>(n(),l("div",{key:s.id,class:"text-sm p-2 bg-gray-50 rounded mb-1"},[t("span",X,a(s.title||s.contract_number),1),s.monthly_value?(n(),l("span",Y,a(s.monthly_value)+"€/Monat",1)):m("",!0)]))),128))])):m("",!0),(h=o.value.objects)!=null&&h.length?(n(),l("div",tt,[t("h3",et,"Objekte ("+a(o.value.objects.length)+")",1),(n(!0),l(y,null,g(o.value.objects,s=>(n(),l("div",{key:s.id,class:"text-sm"}," 🏢 "+a(s.name),1))),128))])):m("",!0)])])):(n(),l("div",P,[...e[11]||(e[11]=[t("p",null,"Wähle einen Kunden aus",-1)])]))])]),p.value?(n(),l("div",st,[t("div",lt,[e[21]||(e[21]=t("h2",{class:"text-xl font-bold mb-4"},"Neuer Kunde",-1)),t("div",nt,[t("div",null,[e[14]||(e[14]=t("label",{class:"block text-sm font-medium mb-1"},"Firmenname *",-1)),u(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>i.value.company_name=s),class:"input"},null,512),[[r,i.value.company_name]])]),t("div",null,[e[15]||(e[15]=t("label",{class:"block text-sm font-medium mb-1"},"Ansprechpartner",-1)),u(t("input",{"onUpdate:modelValue":e[2]||(e[2]=s=>i.value.contact_person=s),class:"input"},null,512),[[r,i.value.contact_person]])]),t("div",at,[t("div",null,[e[16]||(e[16]=t("label",{class:"block text-sm font-medium mb-1"},"E-Mail",-1)),u(t("input",{"onUpdate:modelValue":e[3]||(e[3]=s=>i.value.email=s),type:"email",class:"input"},null,512),[[r,i.value.email]])]),t("div",null,[e[17]||(e[17]=t("label",{class:"block text-sm font-medium mb-1"},"Telefon",-1)),u(t("input",{"onUpdate:modelValue":e[4]||(e[4]=s=>i.value.phone=s),class:"input"},null,512),[[r,i.value.phone]])])]),t("div",null,[e[18]||(e[18]=t("label",{class:"block text-sm font-medium mb-1"},"Adresse",-1)),u(t("input",{"onUpdate:modelValue":e[5]||(e[5]=s=>i.value.address=s),class:"input"},null,512),[[r,i.value.address]])]),t("div",ot,[t("div",null,[e[19]||(e[19]=t("label",{class:"block text-sm font-medium mb-1"},"PLZ",-1)),u(t("input",{"onUpdate:modelValue":e[6]||(e[6]=s=>i.value.postal_code=s),class:"input"},null,512),[[r,i.value.postal_code]])]),t("div",null,[e[20]||(e[20]=t("label",{class:"block text-sm font-medium mb-1"},"Stadt",-1)),u(t("input",{"onUpdate:modelValue":e[7]||(e[7]=s=>i.value.city=s),class:"input"},null,512),[[r,i.value.city]])])])]),t("div",it,[t("button",{onClick:e[8]||(e[8]=s=>p.value=!1),class:"btn"},"Abbrechen"),t("button",{onClick:j,class:"btn btn-primary"},"Erstellen")])])])):m("",!0)])}}});export{mt as default}; diff --git a/dist/assets/DashboardView-D1ilHHiP.js b/dist/assets/DashboardView-Thst2KBn.js similarity index 96% rename from dist/assets/DashboardView-D1ilHHiP.js rename to dist/assets/DashboardView-Thst2KBn.js index c69d136..9e4c2d9 100644 --- a/dist/assets/DashboardView-D1ilHHiP.js +++ b/dist/assets/DashboardView-Thst2KBn.js @@ -1 +1 @@ -import{d as k,u as w,q as A,m as u,c as o,a as e,t as r,y as x,e as y,n as p,i as T,j as v,F as O,x as S,r as m,k as j,l as M,o as d,p as B,z as C}from"./index-CWxNv9Fc.js";const V={class:"space-y-6"},z={class:"card bg-gradient-to-r from-primary-500 to-primary-700 text-white"},D={class:"text-2xl font-bold"},N={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4"},G={class:"card"},L={class:"flex items-center gap-4"},R={class:"text-2xl font-bold text-gray-900 dark:text-white"},$={key:0,class:"card"},E={class:"flex items-center gap-4"},F={class:"text-2xl font-bold text-gray-900 dark:text-white"},H={key:1,class:"card"},I={class:"flex items-center gap-4"},U={class:"text-2xl font-bold text-gray-900 dark:text-white"},q={class:"card"},J={class:"flex items-center gap-4"},K={class:"text-2xl"},W={class:"text-lg font-medium text-gray-900 dark:text-white"},P={class:"card"},Q={class:"flex items-center justify-between mb-4"},X={key:0,class:"text-center py-8 text-gray-500"},Y={key:1,class:"text-center py-8 text-gray-500"},Z={key:2,class:"space-y-3"},ee={class:"flex items-center justify-between"},te={class:"font-medium text-gray-900 dark:text-white"},se={key:0,class:"text-sm text-gray-500 dark:text-gray-400"},ne=k({__name:"DashboardView",setup(ae){const i=w(),n=m({openOrders:0,myOrders:0,pendingTimesheets:0,availableToday:!1}),g=m([]),b=m(!0),f=j(()=>{const s=new Date().getHours();return s<12?"Guten Morgen":s<18?"Guten Tag":"Guten Abend"});A(async()=>{try{const s=await u.get("/orders");if(g.value=s.data.orders.slice(0,5),n.value.openOrders=s.data.orders.filter(l=>["published","in_progress"].includes(l.status)).length,i.isMitarbeiter&&(n.value.myOrders=s.data.orders.length),i.canManageUsers){const l=await u.get("/timesheets?status=pending");n.value.pendingTimesheets=l.data.timesheets.length}const t=new Date().toISOString().split("T")[0],c=await u.get(`/availability?from=${t}&to=${t}`);n.value.availableToday=c.data.availability.some(l=>{var a;return l.available&&l.user_id===((a=i.user)==null?void 0:a.id)})}catch(s){console.error("Dashboard load error:",s)}finally{b.value=!1}});function _(s){return{draft:"badge-secondary",published:"badge-primary",in_progress:"badge-warning",completed:"badge-success",cancelled:"badge-danger"}[s]||"badge-secondary"}function h(s){return{draft:"Entwurf",published:"Veröffentlicht",in_progress:"In Bearbeitung",completed:"Abgeschlossen",cancelled:"Abgesagt"}[s]||s}return(s,t)=>{var l;const c=M("router-link");return d(),o("div",V,[e("div",z,[e("h1",D,r(f.value)+", "+r((l=x(i).user)==null?void 0:l.first_name)+"! 👋 ",1),t[0]||(t[0]=e("p",{class:"mt-1 text-primary-100"}," Willkommen zurück bei SeCu. ",-1))]),e("div",N,[e("div",G,[e("div",L,[t[2]||(t[2]=e("div",{class:"w-12 h-12 rounded-lg bg-blue-100 dark:bg-blue-900 flex items-center justify-center"},[e("span",{class:"text-2xl"},"📋")],-1)),e("div",null,[t[1]||(t[1]=e("p",{class:"text-sm text-gray-500 dark:text-gray-400"},"Offene Aufträge",-1)),e("p",R,r(n.value.openOrders),1)])])]),x(i).isMitarbeiter?(d(),o("div",$,[e("div",E,[t[4]||(t[4]=e("div",{class:"w-12 h-12 rounded-lg bg-green-100 dark:bg-green-900 flex items-center justify-center"},[e("span",{class:"text-2xl"},"✅")],-1)),e("div",null,[t[3]||(t[3]=e("p",{class:"text-sm text-gray-500 dark:text-gray-400"},"Meine Aufträge",-1)),e("p",F,r(n.value.myOrders),1)])])])):y("",!0),x(i).canManageUsers?(d(),o("div",H,[e("div",I,[t[6]||(t[6]=e("div",{class:"w-12 h-12 rounded-lg bg-yellow-100 dark:bg-yellow-900 flex items-center justify-center"},[e("span",{class:"text-2xl"},"⏱️")],-1)),e("div",null,[t[5]||(t[5]=e("p",{class:"text-sm text-gray-500 dark:text-gray-400"},"Ausstehende Stundenzettel",-1)),e("p",U,r(n.value.pendingTimesheets),1)])])])):y("",!0),e("div",q,[e("div",J,[e("div",{class:p(["w-12 h-12 rounded-lg flex items-center justify-center",n.value.availableToday?"bg-green-100 dark:bg-green-900":"bg-gray-100 dark:bg-gray-700"])},[e("span",K,r(n.value.availableToday?"✅":"❓"),1)],2),e("div",null,[t[7]||(t[7]=e("p",{class:"text-sm text-gray-500 dark:text-gray-400"},"Heute verfügbar",-1)),e("p",W,r(n.value.availableToday?"Ja":"Nicht gemeldet"),1)])])])]),e("div",P,[e("div",Q,[t[9]||(t[9]=e("h2",{class:"text-lg font-semibold text-gray-900 dark:text-white"}," Aktuelle Aufträge ",-1)),T(c,{to:"/orders",class:"text-sm text-primary-600 hover:text-primary-700"},{default:v(()=>[...t[8]||(t[8]=[B(" Alle anzeigen → ",-1)])]),_:1})]),b.value?(d(),o("div",X," Lädt... ")):g.value.length===0?(d(),o("div",Y," Keine Aufträge vorhanden ")):(d(),o("div",Z,[(d(!0),o(O,null,S(g.value,a=>(d(),C(c,{key:a.id,to:`/orders/${a.id}`,class:"block p-4 rounded-lg border border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors"},{default:v(()=>[e("div",ee,[e("div",null,[e("h3",te," #"+r(a.number)+" - "+r(a.title),1),a.location?(d(),o("p",se," 📍 "+r(a.location),1)):y("",!0)]),e("span",{class:p(["badge",_(a.status)])},r(h(a.status)),3)])]),_:2},1032,["to"]))),128))]))])])}}});export{ne as default}; +import{d as k,u as w,q as A,m as u,c as o,a as e,t as r,z as x,e as y,n as p,i as T,j as v,F as O,x as S,r as m,k as j,l as M,p as B,A as C,o as d}from"./index-CgM2qJ96.js";const V={class:"space-y-6"},z={class:"card bg-gradient-to-r from-primary-500 to-primary-700 text-white"},D={class:"text-2xl font-bold"},N={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4"},G={class:"card"},L={class:"flex items-center gap-4"},R={class:"text-2xl font-bold text-gray-900 dark:text-white"},$={key:0,class:"card"},E={class:"flex items-center gap-4"},F={class:"text-2xl font-bold text-gray-900 dark:text-white"},H={key:1,class:"card"},I={class:"flex items-center gap-4"},U={class:"text-2xl font-bold text-gray-900 dark:text-white"},q={class:"card"},J={class:"flex items-center gap-4"},K={class:"text-2xl"},W={class:"text-lg font-medium text-gray-900 dark:text-white"},P={class:"card"},Q={class:"flex items-center justify-between mb-4"},X={key:0,class:"text-center py-8 text-gray-500"},Y={key:1,class:"text-center py-8 text-gray-500"},Z={key:2,class:"space-y-3"},ee={class:"flex items-center justify-between"},te={class:"font-medium text-gray-900 dark:text-white"},se={key:0,class:"text-sm text-gray-500 dark:text-gray-400"},ne=k({__name:"DashboardView",setup(ae){const i=w(),n=m({openOrders:0,myOrders:0,pendingTimesheets:0,availableToday:!1}),g=m([]),b=m(!0),f=j(()=>{const s=new Date().getHours();return s<12?"Guten Morgen":s<18?"Guten Tag":"Guten Abend"});A(async()=>{try{const s=await u.get("/orders");if(g.value=s.data.orders.slice(0,5),n.value.openOrders=s.data.orders.filter(l=>["published","in_progress"].includes(l.status)).length,i.isMitarbeiter&&(n.value.myOrders=s.data.orders.length),i.canManageUsers){const l=await u.get("/timesheets?status=pending");n.value.pendingTimesheets=l.data.timesheets.length}const t=new Date().toISOString().split("T")[0],c=await u.get(`/availability?from=${t}&to=${t}`);n.value.availableToday=c.data.availability.some(l=>{var a;return l.available&&l.user_id===((a=i.user)==null?void 0:a.id)})}catch(s){console.error("Dashboard load error:",s)}finally{b.value=!1}});function _(s){return{draft:"badge-secondary",published:"badge-primary",in_progress:"badge-warning",completed:"badge-success",cancelled:"badge-danger"}[s]||"badge-secondary"}function h(s){return{draft:"Entwurf",published:"Veröffentlicht",in_progress:"In Bearbeitung",completed:"Abgeschlossen",cancelled:"Abgesagt"}[s]||s}return(s,t)=>{var l;const c=M("router-link");return d(),o("div",V,[e("div",z,[e("h1",D,r(f.value)+", "+r((l=x(i).user)==null?void 0:l.first_name)+"! 👋 ",1),t[0]||(t[0]=e("p",{class:"mt-1 text-primary-100"}," Willkommen zurück bei SeCu. ",-1))]),e("div",N,[e("div",G,[e("div",L,[t[2]||(t[2]=e("div",{class:"w-12 h-12 rounded-lg bg-blue-100 dark:bg-blue-900 flex items-center justify-center"},[e("span",{class:"text-2xl"},"📋")],-1)),e("div",null,[t[1]||(t[1]=e("p",{class:"text-sm text-gray-500 dark:text-gray-400"},"Offene Aufträge",-1)),e("p",R,r(n.value.openOrders),1)])])]),x(i).isMitarbeiter?(d(),o("div",$,[e("div",E,[t[4]||(t[4]=e("div",{class:"w-12 h-12 rounded-lg bg-green-100 dark:bg-green-900 flex items-center justify-center"},[e("span",{class:"text-2xl"},"✅")],-1)),e("div",null,[t[3]||(t[3]=e("p",{class:"text-sm text-gray-500 dark:text-gray-400"},"Meine Aufträge",-1)),e("p",F,r(n.value.myOrders),1)])])])):y("",!0),x(i).canManageUsers?(d(),o("div",H,[e("div",I,[t[6]||(t[6]=e("div",{class:"w-12 h-12 rounded-lg bg-yellow-100 dark:bg-yellow-900 flex items-center justify-center"},[e("span",{class:"text-2xl"},"⏱️")],-1)),e("div",null,[t[5]||(t[5]=e("p",{class:"text-sm text-gray-500 dark:text-gray-400"},"Ausstehende Stundenzettel",-1)),e("p",U,r(n.value.pendingTimesheets),1)])])])):y("",!0),e("div",q,[e("div",J,[e("div",{class:p(["w-12 h-12 rounded-lg flex items-center justify-center",n.value.availableToday?"bg-green-100 dark:bg-green-900":"bg-gray-100 dark:bg-gray-700"])},[e("span",K,r(n.value.availableToday?"✅":"❓"),1)],2),e("div",null,[t[7]||(t[7]=e("p",{class:"text-sm text-gray-500 dark:text-gray-400"},"Heute verfügbar",-1)),e("p",W,r(n.value.availableToday?"Ja":"Nicht gemeldet"),1)])])])]),e("div",P,[e("div",Q,[t[9]||(t[9]=e("h2",{class:"text-lg font-semibold text-gray-900 dark:text-white"}," Aktuelle Aufträge ",-1)),T(c,{to:"/orders",class:"text-sm text-primary-600 hover:text-primary-700"},{default:v(()=>[...t[8]||(t[8]=[B(" Alle anzeigen → ",-1)])]),_:1})]),b.value?(d(),o("div",X," Lädt... ")):g.value.length===0?(d(),o("div",Y," Keine Aufträge vorhanden ")):(d(),o("div",Z,[(d(!0),o(O,null,S(g.value,a=>(d(),C(c,{key:a.id,to:`/orders/${a.id}`,class:"block p-4 rounded-lg border border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors"},{default:v(()=>[e("div",ee,[e("div",null,[e("h3",te," #"+r(a.number)+" - "+r(a.title),1),a.location?(d(),o("p",se," 📍 "+r(a.location),1)):y("",!0)]),e("span",{class:p(["badge",_(a.status)])},r(h(a.status)),3)])]),_:2},1032,["to"]))),128))]))])])}}});export{ne as default}; diff --git a/dist/assets/DocumentsView-cD_00o40.js b/dist/assets/DocumentsView-BzU6xyPy.js similarity index 98% rename from dist/assets/DocumentsView-cD_00o40.js rename to dist/assets/DocumentsView-BzU6xyPy.js index b6558a0..a44f1ff 100644 --- a/dist/assets/DocumentsView-cD_00o40.js +++ b/dist/assets/DocumentsView-BzU6xyPy.js @@ -1 +1 @@ -import{d as w,q as D,m as u,c as l,a as e,t as o,F as y,x as b,e as d,b as c,v as f,s as B,B as C,r,o as n}from"./index-CWxNv9Fc.js";const V={class:"p-6"},U={class:"flex justify-between items-center mb-6"},j={key:0,class:"bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-6"},M={class:"flex"},F={class:"font-semibold text-yellow-800"},R={class:"mt-2 space-y-2"},$=["onClick"],L={key:1,class:"text-center py-12"},N={key:2,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},P={key:3,class:"grid md:grid-cols-2 lg:grid-cols-3 gap-4"},z={class:"flex items-start space-x-3"},A={class:"text-2xl"},E={class:"flex-1 min-w-0"},K={class:"font-semibold truncate"},S={class:"text-sm text-gray-500"},T={key:0,class:"text-sm text-gray-400 mt-1 line-clamp-2"},q={class:"mt-3 flex items-center justify-between text-xs"},H={key:0,class:"px-2 py-1 bg-red-100 text-red-700 rounded"},W={key:1,class:"text-green-600"},G={key:2,class:"text-orange-600"},I=["href"],J={key:4,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},O={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},Q={class:"space-y-4"},X=["value"],Y={class:"flex items-center"},Z={class:"flex justify-end space-x-2 mt-6"},le=w({__name:"DocumentsView",setup(ee){const v=r(!0),g=r([]),_=r([]),m=r([]),p=r(!1),a=r({title:"",description:"",category_id:"",file_url:"",is_mandatory:!1});D(async()=>{await x()});async function x(){v.value=!0;try{const[i,t,s]=await Promise.all([u.get("/documents"),u.get("/documents/categories"),u.get("/documents/pending/list")]);g.value=i.data.documents||[],_.value=t.data.categories||[],m.value=s.data.documents||[]}catch(i){console.error(i)}v.value=!1}async function k(i){try{await u.post(`/documents/${i}/acknowledge`,{}),await x()}catch(t){alert("Fehler: "+t.message)}}async function h(){try{await u.post("/documents",a.value),p.value=!1,a.value={title:"",description:"",category_id:"",file_url:"",is_mandatory:!1},await x()}catch(i){alert("Fehler: "+i.message)}}return(i,t)=>(n(),l("div",V,[e("div",U,[t[7]||(t[7]=e("div",null,[e("h1",{class:"text-2xl font-bold"},"📁 Dokumente"),e("p",{class:"text-gray-500"},"Unterlagen & Bestätigungen")],-1)),e("button",{onClick:t[0]||(t[0]=s=>p.value=!0),class:"btn btn-primary"},"+ Dokument")]),m.value.length>0?(n(),l("div",j,[e("div",M,[t[8]||(t[8]=e("span",{class:"text-yellow-600 text-xl mr-3"},"⚠️",-1)),e("div",null,[e("h3",F,o(m.value.length)+" Dokument(e) zu bestätigen",1),e("div",R,[(n(!0),l(y,null,b(m.value,s=>(n(),l("div",{key:s.id,class:"flex items-center justify-between bg-white p-2 rounded"},[e("span",null,o(s.category_icon)+" "+o(s.title),1),e("button",{onClick:te=>k(s.id),class:"text-sm text-blue-600 hover:underline"},"Bestätigen",8,$)]))),128))])])])])):d("",!0),v.value?(n(),l("div",L,"Laden...")):g.value.length===0?(n(),l("div",N,[...t[9]||(t[9]=[e("p",{class:"text-4xl mb-4"},"📄",-1),e("p",null,"Keine Dokumente vorhanden",-1)])])):(n(),l("div",P,[(n(!0),l(y,null,b(g.value,s=>(n(),l("div",{key:s.id,class:"bg-white rounded-lg shadow p-4 hover:shadow-md transition-shadow"},[e("div",z,[e("span",A,o(s.category_icon||"📄"),1),e("div",E,[e("h3",K,o(s.title),1),e("p",S,o(s.category_name),1),s.description?(n(),l("p",T,o(s.description),1)):d("",!0)])]),e("div",q,[s.is_mandatory?(n(),l("span",H,"Pflicht")):d("",!0),s.acknowledged?(n(),l("span",W,"✓ Bestätigt")):s.is_mandatory?(n(),l("span",G,"Ausstehend")):d("",!0)]),s.file_url?(n(),l("a",{key:0,href:s.file_url,target:"_blank",class:"mt-3 block text-center text-sm text-blue-600 hover:underline"}," 📥 Herunterladen ",8,I)):d("",!0)]))),128))])),p.value?(n(),l("div",J,[e("div",O,[t[16]||(t[16]=e("h2",{class:"text-xl font-bold mb-4"},"Neues Dokument",-1)),e("div",Q,[e("div",null,[t[10]||(t[10]=e("label",{class:"block text-sm font-medium mb-1"},"Titel *",-1)),c(e("input",{"onUpdate:modelValue":t[1]||(t[1]=s=>a.value.title=s),class:"input"},null,512),[[f,a.value.title]])]),e("div",null,[t[12]||(t[12]=e("label",{class:"block text-sm font-medium mb-1"},"Kategorie",-1)),c(e("select",{"onUpdate:modelValue":t[2]||(t[2]=s=>a.value.category_id=s),class:"input"},[t[11]||(t[11]=e("option",{value:""},"-- Wählen --",-1)),(n(!0),l(y,null,b(_.value,s=>(n(),l("option",{key:s.id,value:s.id},o(s.icon)+" "+o(s.name),9,X))),128))],512),[[B,a.value.category_id]])]),e("div",null,[t[13]||(t[13]=e("label",{class:"block text-sm font-medium mb-1"},"Datei-URL",-1)),c(e("input",{"onUpdate:modelValue":t[3]||(t[3]=s=>a.value.file_url=s),class:"input",placeholder:"https://..."},null,512),[[f,a.value.file_url]])]),e("div",null,[t[14]||(t[14]=e("label",{class:"block text-sm font-medium mb-1"},"Beschreibung",-1)),c(e("textarea",{"onUpdate:modelValue":t[4]||(t[4]=s=>a.value.description=s),rows:"2",class:"input"},null,512),[[f,a.value.description]])]),e("label",Y,[c(e("input",{"onUpdate:modelValue":t[5]||(t[5]=s=>a.value.is_mandatory=s),type:"checkbox",class:"mr-2"},null,512),[[C,a.value.is_mandatory]]),t[15]||(t[15]=e("span",{class:"text-sm"},"Pflichtdokument (Bestätigung erforderlich)",-1))])]),e("div",Z,[e("button",{onClick:t[6]||(t[6]=s=>p.value=!1),class:"btn"},"Abbrechen"),e("button",{onClick:h,class:"btn btn-primary"},"Erstellen")])])])):d("",!0)]))}});export{le as default}; +import{d as w,q as D,m as u,c as l,a as e,t as o,F as y,x as b,e as d,b as c,v as f,s as B,D as C,r,o as n}from"./index-CgM2qJ96.js";const V={class:"p-6"},U={class:"flex justify-between items-center mb-6"},j={key:0,class:"bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-6"},M={class:"flex"},F={class:"font-semibold text-yellow-800"},R={class:"mt-2 space-y-2"},$=["onClick"],L={key:1,class:"text-center py-12"},N={key:2,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},P={key:3,class:"grid md:grid-cols-2 lg:grid-cols-3 gap-4"},z={class:"flex items-start space-x-3"},A={class:"text-2xl"},E={class:"flex-1 min-w-0"},K={class:"font-semibold truncate"},S={class:"text-sm text-gray-500"},T={key:0,class:"text-sm text-gray-400 mt-1 line-clamp-2"},q={class:"mt-3 flex items-center justify-between text-xs"},H={key:0,class:"px-2 py-1 bg-red-100 text-red-700 rounded"},W={key:1,class:"text-green-600"},G={key:2,class:"text-orange-600"},I=["href"],J={key:4,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},O={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},Q={class:"space-y-4"},X=["value"],Y={class:"flex items-center"},Z={class:"flex justify-end space-x-2 mt-6"},le=w({__name:"DocumentsView",setup(ee){const v=r(!0),g=r([]),_=r([]),m=r([]),p=r(!1),a=r({title:"",description:"",category_id:"",file_url:"",is_mandatory:!1});D(async()=>{await x()});async function x(){v.value=!0;try{const[i,t,s]=await Promise.all([u.get("/documents"),u.get("/documents/categories"),u.get("/documents/pending/list")]);g.value=i.data.documents||[],_.value=t.data.categories||[],m.value=s.data.documents||[]}catch(i){console.error(i)}v.value=!1}async function k(i){try{await u.post(`/documents/${i}/acknowledge`,{}),await x()}catch(t){alert("Fehler: "+t.message)}}async function h(){try{await u.post("/documents",a.value),p.value=!1,a.value={title:"",description:"",category_id:"",file_url:"",is_mandatory:!1},await x()}catch(i){alert("Fehler: "+i.message)}}return(i,t)=>(n(),l("div",V,[e("div",U,[t[7]||(t[7]=e("div",null,[e("h1",{class:"text-2xl font-bold"},"📁 Dokumente"),e("p",{class:"text-gray-500"},"Unterlagen & Bestätigungen")],-1)),e("button",{onClick:t[0]||(t[0]=s=>p.value=!0),class:"btn btn-primary"},"+ Dokument")]),m.value.length>0?(n(),l("div",j,[e("div",M,[t[8]||(t[8]=e("span",{class:"text-yellow-600 text-xl mr-3"},"⚠️",-1)),e("div",null,[e("h3",F,o(m.value.length)+" Dokument(e) zu bestätigen",1),e("div",R,[(n(!0),l(y,null,b(m.value,s=>(n(),l("div",{key:s.id,class:"flex items-center justify-between bg-white p-2 rounded"},[e("span",null,o(s.category_icon)+" "+o(s.title),1),e("button",{onClick:te=>k(s.id),class:"text-sm text-blue-600 hover:underline"},"Bestätigen",8,$)]))),128))])])])])):d("",!0),v.value?(n(),l("div",L,"Laden...")):g.value.length===0?(n(),l("div",N,[...t[9]||(t[9]=[e("p",{class:"text-4xl mb-4"},"📄",-1),e("p",null,"Keine Dokumente vorhanden",-1)])])):(n(),l("div",P,[(n(!0),l(y,null,b(g.value,s=>(n(),l("div",{key:s.id,class:"bg-white rounded-lg shadow p-4 hover:shadow-md transition-shadow"},[e("div",z,[e("span",A,o(s.category_icon||"📄"),1),e("div",E,[e("h3",K,o(s.title),1),e("p",S,o(s.category_name),1),s.description?(n(),l("p",T,o(s.description),1)):d("",!0)])]),e("div",q,[s.is_mandatory?(n(),l("span",H,"Pflicht")):d("",!0),s.acknowledged?(n(),l("span",W,"✓ Bestätigt")):s.is_mandatory?(n(),l("span",G,"Ausstehend")):d("",!0)]),s.file_url?(n(),l("a",{key:0,href:s.file_url,target:"_blank",class:"mt-3 block text-center text-sm text-blue-600 hover:underline"}," 📥 Herunterladen ",8,I)):d("",!0)]))),128))])),p.value?(n(),l("div",J,[e("div",O,[t[16]||(t[16]=e("h2",{class:"text-xl font-bold mb-4"},"Neues Dokument",-1)),e("div",Q,[e("div",null,[t[10]||(t[10]=e("label",{class:"block text-sm font-medium mb-1"},"Titel *",-1)),c(e("input",{"onUpdate:modelValue":t[1]||(t[1]=s=>a.value.title=s),class:"input"},null,512),[[f,a.value.title]])]),e("div",null,[t[12]||(t[12]=e("label",{class:"block text-sm font-medium mb-1"},"Kategorie",-1)),c(e("select",{"onUpdate:modelValue":t[2]||(t[2]=s=>a.value.category_id=s),class:"input"},[t[11]||(t[11]=e("option",{value:""},"-- Wählen --",-1)),(n(!0),l(y,null,b(_.value,s=>(n(),l("option",{key:s.id,value:s.id},o(s.icon)+" "+o(s.name),9,X))),128))],512),[[B,a.value.category_id]])]),e("div",null,[t[13]||(t[13]=e("label",{class:"block text-sm font-medium mb-1"},"Datei-URL",-1)),c(e("input",{"onUpdate:modelValue":t[3]||(t[3]=s=>a.value.file_url=s),class:"input",placeholder:"https://..."},null,512),[[f,a.value.file_url]])]),e("div",null,[t[14]||(t[14]=e("label",{class:"block text-sm font-medium mb-1"},"Beschreibung",-1)),c(e("textarea",{"onUpdate:modelValue":t[4]||(t[4]=s=>a.value.description=s),rows:"2",class:"input"},null,512),[[f,a.value.description]])]),e("label",Y,[c(e("input",{"onUpdate:modelValue":t[5]||(t[5]=s=>a.value.is_mandatory=s),type:"checkbox",class:"mr-2"},null,512),[[C,a.value.is_mandatory]]),t[15]||(t[15]=e("span",{class:"text-sm"},"Pflichtdokument (Bestätigung erforderlich)",-1))])]),e("div",Z,[e("button",{onClick:t[6]||(t[6]=s=>p.value=!1),class:"btn"},"Abbrechen"),e("button",{onClick:h,class:"btn btn-primary"},"Erstellen")])])])):d("",!0)]))}});export{le as default}; diff --git a/dist/assets/HelpView-1PeoZaC4.js b/dist/assets/HelpView-D7FsGxgq.js similarity index 99% rename from dist/assets/HelpView-1PeoZaC4.js rename to dist/assets/HelpView-D7FsGxgq.js index 8135cad..47d03fd 100644 --- a/dist/assets/HelpView-1PeoZaC4.js +++ b/dist/assets/HelpView-D7FsGxgq.js @@ -1,4 +1,4 @@ -import{d as K,c as a,a as n,e as w,b as C,v as F,F as A,x,t as r,r as f,k as m,o as s}from"./index-CWxNv9Fc.js";const G={class:"space-y-6"},E={class:"flex items-center justify-between"},V={class:"flex items-center gap-3"},W={class:"relative"},N={key:0,class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},$=["onClick"],Z={class:"text-3xl mb-3"},I={class:"text-lg font-semibold mb-1 text-gray-900 dark:text-white"},L={class:"text-sm text-gray-500 dark:text-gray-400"},T={class:"text-xs text-gray-400 mt-2"},H={key:1,class:"space-y-4"},O={class:"card bg-gray-50 dark:bg-gray-800"},R={class:"flex items-center gap-3"},q={class:"text-3xl"},j={class:"text-xl font-semibold text-gray-900 dark:text-white"},U={class:"text-sm text-gray-500 dark:text-gray-400"},J={class:"grid gap-3"},Q=["onClick"],X={class:"text-2xl"},Y={class:"font-medium text-gray-900 dark:text-white"},ee={key:2,class:"card"},ne={class:"flex items-center gap-3 mb-6 pb-4 border-b dark:border-gray-700"},te={class:"text-3xl"},ie={class:"text-xl font-semibold text-gray-900 dark:text-white"},re=["innerHTML"],le=K({__name:"HelpView",setup(ae){const l=f(""),u=f(null),o=f(null),g=[{id:"getting-started",name:"Erste Schritte",icon:"🚀",description:"Grundlagen und Einrichtung",articles:[{id:"overview",title:"Übersicht",icon:"📋",content:` +import{d as K,c as a,a as n,e as w,b as C,v as F,F as A,x,t as r,r as f,k as m,o as s}from"./index-CgM2qJ96.js";const G={class:"space-y-6"},E={class:"flex items-center justify-between"},V={class:"flex items-center gap-3"},W={class:"relative"},N={key:0,class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},$=["onClick"],Z={class:"text-3xl mb-3"},I={class:"text-lg font-semibold mb-1 text-gray-900 dark:text-white"},L={class:"text-sm text-gray-500 dark:text-gray-400"},T={class:"text-xs text-gray-400 mt-2"},H={key:1,class:"space-y-4"},O={class:"card bg-gray-50 dark:bg-gray-800"},R={class:"flex items-center gap-3"},q={class:"text-3xl"},j={class:"text-xl font-semibold text-gray-900 dark:text-white"},U={class:"text-sm text-gray-500 dark:text-gray-400"},J={class:"grid gap-3"},Q=["onClick"],X={class:"text-2xl"},Y={class:"font-medium text-gray-900 dark:text-white"},ee={key:2,class:"card"},ne={class:"flex items-center gap-3 mb-6 pb-4 border-b dark:border-gray-700"},te={class:"text-3xl"},ie={class:"text-xl font-semibold text-gray-900 dark:text-white"},re=["innerHTML"],le=K({__name:"HelpView",setup(ae){const l=f(""),u=f(null),o=f(null),g=[{id:"getting-started",name:"Erste Schritte",icon:"🚀",description:"Grundlagen und Einrichtung",articles:[{id:"overview",title:"Übersicht",icon:"📋",content:` ## Was ist SeCu? SeCu ist eine modulare Mitarbeiterverwaltung speziell für Sicherheitsunternehmen. Die Software hilft Ihnen bei: diff --git a/dist/assets/IncidentsView-DPo8woI1.js b/dist/assets/IncidentsView-D5JtybkA.js similarity index 98% rename from dist/assets/IncidentsView-DPo8woI1.js rename to dist/assets/IncidentsView-D5JtybkA.js index 58a90c5..1765b76 100644 --- a/dist/assets/IncidentsView-DPo8woI1.js +++ b/dist/assets/IncidentsView-D5JtybkA.js @@ -1 +1 @@ -import{d as V,q as j,m as x,c as n,a as e,F as f,x as _,b as u,v as p,s as B,e as v,r,o,t as l,n as w}from"./index-CWxNv9Fc.js";const C={class:"p-6"},D={class:"flex justify-between items-center mb-6"},M={key:0,class:"text-center py-12"},S={key:1,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},G={key:2,class:"space-y-4"},I={class:"flex justify-between items-start"},K={class:"flex items-start space-x-3"},U={class:"text-2xl"},z={class:"font-semibold"},F={class:"text-sm text-gray-500"},L={class:"text-sm text-gray-400 mt-1"},O={class:"flex flex-col items-end space-y-1"},A={key:0,class:"mt-3 text-sm text-gray-600"},E={class:"mt-3 flex items-center text-xs text-gray-500"},N={key:0,class:"ml-4"},R={key:3,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},T={class:"bg-white rounded-lg shadow-xl w-full max-w-lg p-6"},$={class:"space-y-4"},q=["value"],P={class:"flex justify-end space-x-2 mt-6"},J=V({__name:"IncidentsView",setup(W){const c=r(!0),m=r([]),g=r([]),d=r(!1),i=r({title:"",description:"",category_id:"",severity:2,object_id:""});j(async()=>{await y()});async function y(){c.value=!0;try{const[a,t]=await Promise.all([x.get("/incidents"),x.get("/incidents/categories")]);m.value=a.data.incidents||[],g.value=t.data.categories||[]}catch(a){console.error(a)}c.value=!1}async function k(){try{await x.post("/incidents",i.value),d.value=!1,i.value={title:"",description:"",category_id:"",severity:2,object_id:""},await y()}catch(a){alert("Fehler: "+a.message)}}function h(a){return a>=4?"bg-red-100 text-red-700":a>=3?"bg-orange-100 text-orange-700":"bg-yellow-100 text-yellow-700"}function b(a){return{open:{text:"Offen",class:"bg-red-100 text-red-700"},in_progress:{text:"In Bearbeitung",class:"bg-yellow-100 text-yellow-700"},resolved:{text:"Gelöst",class:"bg-green-100 text-green-700"},closed:{text:"Geschlossen",class:"bg-gray-100 text-gray-700"}}[a]||{text:a,class:"bg-gray-100"}}return(a,t)=>(o(),n("div",C,[e("div",D,[t[6]||(t[6]=e("div",null,[e("h1",{class:"text-2xl font-bold"},"🚨 Vorfallberichte"),e("p",{class:"text-gray-500"},"Incidents dokumentieren und verfolgen")],-1)),e("button",{onClick:t[0]||(t[0]=s=>d.value=!0),class:"btn btn-primary"},"+ Vorfall melden")]),c.value?(o(),n("div",M,"Laden...")):m.value.length===0?(o(),n("div",S,[...t[7]||(t[7]=[e("p",{class:"text-4xl mb-4"},"✅",-1),e("p",null,"Keine Vorfälle gemeldet",-1)])])):(o(),n("div",G,[(o(!0),n(f,null,_(m.value,s=>(o(),n("div",{key:s.id,class:"bg-white rounded-lg shadow p-4"},[e("div",I,[e("div",K,[e("span",U,l(s.category_icon||"📋"),1),e("div",null,[e("h3",z,l(s.title),1),e("p",F,l(s.category_name)+" · "+l(s.object_name||"Ohne Objekt"),1),e("p",L,l(new Date(s.occurred_at).toLocaleString("de-DE")),1)])]),e("div",O,[e("span",{class:w(["px-2 py-1 text-xs rounded",b(s.status).class])},l(b(s.status).text),3),e("span",{class:w(["px-2 py-1 text-xs rounded",h(s.severity)])}," Stufe "+l(s.severity),3)])]),s.description?(o(),n("p",A,l(s.description),1)):v("",!0),e("div",E,[e("span",null,"Gemeldet von "+l(s.reporter_first)+" "+l(s.reporter_last),1),s.attachment_count?(o(),n("span",N,"📎 "+l(s.attachment_count)+" Anhänge",1)):v("",!0)])]))),128))])),d.value?(o(),n("div",R,[e("div",T,[t[14]||(t[14]=e("h2",{class:"text-xl font-bold mb-4"},"Vorfall melden",-1)),e("div",$,[e("div",null,[t[8]||(t[8]=e("label",{class:"block text-sm font-medium mb-1"},"Titel *",-1)),u(e("input",{"onUpdate:modelValue":t[1]||(t[1]=s=>i.value.title=s),class:"input",placeholder:"Kurze Beschreibung"},null,512),[[p,i.value.title]])]),e("div",null,[t[10]||(t[10]=e("label",{class:"block text-sm font-medium mb-1"},"Kategorie",-1)),u(e("select",{"onUpdate:modelValue":t[2]||(t[2]=s=>i.value.category_id=s),class:"input"},[t[9]||(t[9]=e("option",{value:""},"-- Wählen --",-1)),(o(!0),n(f,null,_(g.value,s=>(o(),n("option",{key:s.id,value:s.id},l(s.icon)+" "+l(s.name),9,q))),128))],512),[[B,i.value.category_id]])]),e("div",null,[t[11]||(t[11]=e("label",{class:"block text-sm font-medium mb-1"},"Schweregrad (1-5)",-1)),u(e("input",{"onUpdate:modelValue":t[3]||(t[3]=s=>i.value.severity=s),type:"range",min:"1",max:"5",class:"w-full"},null,512),[[p,i.value.severity,void 0,{number:!0}]]),t[12]||(t[12]=e("div",{class:"flex justify-between text-xs text-gray-500"},[e("span",null,"Gering"),e("span",null,"Kritisch")],-1))]),e("div",null,[t[13]||(t[13]=e("label",{class:"block text-sm font-medium mb-1"},"Beschreibung",-1)),u(e("textarea",{"onUpdate:modelValue":t[4]||(t[4]=s=>i.value.description=s),rows:"3",class:"input",placeholder:"Details..."},null,512),[[p,i.value.description]])])]),e("div",P,[e("button",{onClick:t[5]||(t[5]=s=>d.value=!1),class:"btn"},"Abbrechen"),e("button",{onClick:k,class:"btn btn-primary"},"Melden")])])])):v("",!0)]))}});export{J as default}; +import{d as V,q as j,m as x,c as n,a as e,F as f,x as _,b as u,v as p,s as B,e as v,r,t as l,n as w,o}from"./index-CgM2qJ96.js";const C={class:"p-6"},D={class:"flex justify-between items-center mb-6"},M={key:0,class:"text-center py-12"},S={key:1,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},G={key:2,class:"space-y-4"},I={class:"flex justify-between items-start"},K={class:"flex items-start space-x-3"},U={class:"text-2xl"},z={class:"font-semibold"},F={class:"text-sm text-gray-500"},L={class:"text-sm text-gray-400 mt-1"},O={class:"flex flex-col items-end space-y-1"},A={key:0,class:"mt-3 text-sm text-gray-600"},E={class:"mt-3 flex items-center text-xs text-gray-500"},N={key:0,class:"ml-4"},R={key:3,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},T={class:"bg-white rounded-lg shadow-xl w-full max-w-lg p-6"},$={class:"space-y-4"},q=["value"],P={class:"flex justify-end space-x-2 mt-6"},J=V({__name:"IncidentsView",setup(W){const c=r(!0),m=r([]),g=r([]),d=r(!1),i=r({title:"",description:"",category_id:"",severity:2,object_id:""});j(async()=>{await y()});async function y(){c.value=!0;try{const[a,t]=await Promise.all([x.get("/incidents"),x.get("/incidents/categories")]);m.value=a.data.incidents||[],g.value=t.data.categories||[]}catch(a){console.error(a)}c.value=!1}async function k(){try{await x.post("/incidents",i.value),d.value=!1,i.value={title:"",description:"",category_id:"",severity:2,object_id:""},await y()}catch(a){alert("Fehler: "+a.message)}}function h(a){return a>=4?"bg-red-100 text-red-700":a>=3?"bg-orange-100 text-orange-700":"bg-yellow-100 text-yellow-700"}function b(a){return{open:{text:"Offen",class:"bg-red-100 text-red-700"},in_progress:{text:"In Bearbeitung",class:"bg-yellow-100 text-yellow-700"},resolved:{text:"Gelöst",class:"bg-green-100 text-green-700"},closed:{text:"Geschlossen",class:"bg-gray-100 text-gray-700"}}[a]||{text:a,class:"bg-gray-100"}}return(a,t)=>(o(),n("div",C,[e("div",D,[t[6]||(t[6]=e("div",null,[e("h1",{class:"text-2xl font-bold"},"🚨 Vorfallberichte"),e("p",{class:"text-gray-500"},"Incidents dokumentieren und verfolgen")],-1)),e("button",{onClick:t[0]||(t[0]=s=>d.value=!0),class:"btn btn-primary"},"+ Vorfall melden")]),c.value?(o(),n("div",M,"Laden...")):m.value.length===0?(o(),n("div",S,[...t[7]||(t[7]=[e("p",{class:"text-4xl mb-4"},"✅",-1),e("p",null,"Keine Vorfälle gemeldet",-1)])])):(o(),n("div",G,[(o(!0),n(f,null,_(m.value,s=>(o(),n("div",{key:s.id,class:"bg-white rounded-lg shadow p-4"},[e("div",I,[e("div",K,[e("span",U,l(s.category_icon||"📋"),1),e("div",null,[e("h3",z,l(s.title),1),e("p",F,l(s.category_name)+" · "+l(s.object_name||"Ohne Objekt"),1),e("p",L,l(new Date(s.occurred_at).toLocaleString("de-DE")),1)])]),e("div",O,[e("span",{class:w(["px-2 py-1 text-xs rounded",b(s.status).class])},l(b(s.status).text),3),e("span",{class:w(["px-2 py-1 text-xs rounded",h(s.severity)])}," Stufe "+l(s.severity),3)])]),s.description?(o(),n("p",A,l(s.description),1)):v("",!0),e("div",E,[e("span",null,"Gemeldet von "+l(s.reporter_first)+" "+l(s.reporter_last),1),s.attachment_count?(o(),n("span",N,"📎 "+l(s.attachment_count)+" Anhänge",1)):v("",!0)])]))),128))])),d.value?(o(),n("div",R,[e("div",T,[t[14]||(t[14]=e("h2",{class:"text-xl font-bold mb-4"},"Vorfall melden",-1)),e("div",$,[e("div",null,[t[8]||(t[8]=e("label",{class:"block text-sm font-medium mb-1"},"Titel *",-1)),u(e("input",{"onUpdate:modelValue":t[1]||(t[1]=s=>i.value.title=s),class:"input",placeholder:"Kurze Beschreibung"},null,512),[[p,i.value.title]])]),e("div",null,[t[10]||(t[10]=e("label",{class:"block text-sm font-medium mb-1"},"Kategorie",-1)),u(e("select",{"onUpdate:modelValue":t[2]||(t[2]=s=>i.value.category_id=s),class:"input"},[t[9]||(t[9]=e("option",{value:""},"-- Wählen --",-1)),(o(!0),n(f,null,_(g.value,s=>(o(),n("option",{key:s.id,value:s.id},l(s.icon)+" "+l(s.name),9,q))),128))],512),[[B,i.value.category_id]])]),e("div",null,[t[11]||(t[11]=e("label",{class:"block text-sm font-medium mb-1"},"Schweregrad (1-5)",-1)),u(e("input",{"onUpdate:modelValue":t[3]||(t[3]=s=>i.value.severity=s),type:"range",min:"1",max:"5",class:"w-full"},null,512),[[p,i.value.severity,void 0,{number:!0}]]),t[12]||(t[12]=e("div",{class:"flex justify-between text-xs text-gray-500"},[e("span",null,"Gering"),e("span",null,"Kritisch")],-1))]),e("div",null,[t[13]||(t[13]=e("label",{class:"block text-sm font-medium mb-1"},"Beschreibung",-1)),u(e("textarea",{"onUpdate:modelValue":t[4]||(t[4]=s=>i.value.description=s),rows:"3",class:"input",placeholder:"Details..."},null,512),[[p,i.value.description]])])]),e("div",P,[e("button",{onClick:t[5]||(t[5]=s=>d.value=!1),class:"btn"},"Abbrechen"),e("button",{onClick:k,class:"btn btn-primary"},"Melden")])])])):v("",!0)]))}});export{J as default}; diff --git a/dist/assets/LoginView-D8QH8UMb.js b/dist/assets/LoginView-BF8xkNDz.js similarity index 98% rename from dist/assets/LoginView-D8QH8UMb.js rename to dist/assets/LoginView-BF8xkNDz.js index c877762..69da10d 100644 --- a/dist/assets/LoginView-D8QH8UMb.js +++ b/dist/assets/LoginView-BF8xkNDz.js @@ -1 +1 @@ -import{d as h,u as q,r as a,c,a as e,t as g,w as B,b as r,v as n,F as N,e as k,f as R,g as U,o as f}from"./index-CWxNv9Fc.js";const A={class:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 py-12 px-4 sm:px-6 lg:px-8"},M={class:"max-w-md w-full space-y-8"},C={class:"card"},E={class:"text-xl font-semibold text-gray-900 dark:text-white mb-6"},D={class:"grid grid-cols-2 gap-4"},F=["placeholder"],O={key:1,class:"p-3 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 rounded-lg text-sm"},T=["disabled"],j={class:"mt-4 text-center"},L=h({__name:"LoginView",setup(z){const w=R(),V=U(),m=q(),o=a(""),u=a(""),i=a(m.orgSlug||""),p=a(""),v=a(!1),s=a(!1),x=a(""),y=a(""),b=a("");async function S(){p.value="",v.value=!0;try{s.value?(await m.register({email:o.value,password:u.value,first_name:x.value,last_name:y.value,phone:b.value,org_slug:i.value}),await m.login(o.value,u.value,i.value)):await m.login(o.value,u.value,i.value);const d=V.query.redirect||"/";w.push(d)}catch(d){p.value=d instanceof Error?d.message:"Anmeldung fehlgeschlagen"}finally{v.value=!1}}return(d,t)=>(f(),c("div",A,[e("div",M,[t[13]||(t[13]=e("div",{class:"text-center"},[e("h1",{class:"text-4xl font-bold text-primary-600"},"🔐 SeCu"),e("p",{class:"mt-2 text-gray-600 dark:text-gray-400"},"Mitarbeiterverwaltung")],-1)),e("div",C,[e("h2",E,g(s.value?"Registrieren":"Anmelden"),1),e("form",{onSubmit:B(S,["prevent"]),class:"space-y-4"},[e("div",null,[t[7]||(t[7]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Organisation ",-1)),r(e("input",{"onUpdate:modelValue":t[0]||(t[0]=l=>i.value=l),type:"text",required:"",class:"input",placeholder:"z.B. demo"},null,512),[[n,i.value]])]),e("div",null,[t[8]||(t[8]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," E-Mail ",-1)),r(e("input",{"onUpdate:modelValue":t[1]||(t[1]=l=>o.value=l),type:"email",required:"",class:"input",placeholder:"name@firma.de"},null,512),[[n,o.value]])]),s.value?(f(),c(N,{key:0},[e("div",D,[e("div",null,[t[9]||(t[9]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Vorname ",-1)),r(e("input",{"onUpdate:modelValue":t[2]||(t[2]=l=>x.value=l),type:"text",required:"",class:"input"},null,512),[[n,x.value]])]),e("div",null,[t[10]||(t[10]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Nachname ",-1)),r(e("input",{"onUpdate:modelValue":t[3]||(t[3]=l=>y.value=l),type:"text",required:"",class:"input"},null,512),[[n,y.value]])])]),e("div",null,[t[11]||(t[11]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Telefon ",-1)),r(e("input",{"onUpdate:modelValue":t[4]||(t[4]=l=>b.value=l),type:"tel",class:"input",placeholder:"Optional"},null,512),[[n,b.value]])])],64)):k("",!0),e("div",null,[t[12]||(t[12]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Passwort ",-1)),r(e("input",{"onUpdate:modelValue":t[5]||(t[5]=l=>u.value=l),type:"password",required:"",class:"input",placeholder:s.value?"Mindestens 8 Zeichen":""},null,8,F),[[n,u.value]])]),p.value?(f(),c("div",O,g(p.value),1)):k("",!0),e("button",{type:"submit",disabled:v.value,class:"btn btn-primary w-full"},g(v.value?"Bitte warten...":s.value?"Registrieren":"Anmelden"),9,T)],32),e("div",j,[e("button",{type:"button",class:"text-sm text-primary-600 hover:text-primary-700",onClick:t[6]||(t[6]=l=>s.value=!s.value)},g(s.value?"Bereits registriert? Anmelden":"Noch kein Konto? Registrieren"),1)])])])]))}});export{L as default}; +import{d as h,u as q,r as a,c,a as e,t as g,w as B,b as r,v as n,F as N,e as k,f as R,g as U,o as f}from"./index-CgM2qJ96.js";const A={class:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 py-12 px-4 sm:px-6 lg:px-8"},M={class:"max-w-md w-full space-y-8"},C={class:"card"},E={class:"text-xl font-semibold text-gray-900 dark:text-white mb-6"},D={class:"grid grid-cols-2 gap-4"},F=["placeholder"],O={key:1,class:"p-3 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 rounded-lg text-sm"},T=["disabled"],j={class:"mt-4 text-center"},L=h({__name:"LoginView",setup(z){const w=R(),V=U(),m=q(),o=a(""),u=a(""),i=a(m.orgSlug||""),p=a(""),v=a(!1),s=a(!1),x=a(""),y=a(""),b=a("");async function S(){p.value="",v.value=!0;try{s.value?(await m.register({email:o.value,password:u.value,first_name:x.value,last_name:y.value,phone:b.value,org_slug:i.value}),await m.login(o.value,u.value,i.value)):await m.login(o.value,u.value,i.value);const d=V.query.redirect||"/";w.push(d)}catch(d){p.value=d instanceof Error?d.message:"Anmeldung fehlgeschlagen"}finally{v.value=!1}}return(d,t)=>(f(),c("div",A,[e("div",M,[t[13]||(t[13]=e("div",{class:"text-center"},[e("h1",{class:"text-4xl font-bold text-primary-600"},"🔐 SeCu"),e("p",{class:"mt-2 text-gray-600 dark:text-gray-400"},"Mitarbeiterverwaltung")],-1)),e("div",C,[e("h2",E,g(s.value?"Registrieren":"Anmelden"),1),e("form",{onSubmit:B(S,["prevent"]),class:"space-y-4"},[e("div",null,[t[7]||(t[7]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Organisation ",-1)),r(e("input",{"onUpdate:modelValue":t[0]||(t[0]=l=>i.value=l),type:"text",required:"",class:"input",placeholder:"z.B. demo"},null,512),[[n,i.value]])]),e("div",null,[t[8]||(t[8]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," E-Mail ",-1)),r(e("input",{"onUpdate:modelValue":t[1]||(t[1]=l=>o.value=l),type:"email",required:"",class:"input",placeholder:"name@firma.de"},null,512),[[n,o.value]])]),s.value?(f(),c(N,{key:0},[e("div",D,[e("div",null,[t[9]||(t[9]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Vorname ",-1)),r(e("input",{"onUpdate:modelValue":t[2]||(t[2]=l=>x.value=l),type:"text",required:"",class:"input"},null,512),[[n,x.value]])]),e("div",null,[t[10]||(t[10]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Nachname ",-1)),r(e("input",{"onUpdate:modelValue":t[3]||(t[3]=l=>y.value=l),type:"text",required:"",class:"input"},null,512),[[n,y.value]])])]),e("div",null,[t[11]||(t[11]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Telefon ",-1)),r(e("input",{"onUpdate:modelValue":t[4]||(t[4]=l=>b.value=l),type:"tel",class:"input",placeholder:"Optional"},null,512),[[n,b.value]])])],64)):k("",!0),e("div",null,[t[12]||(t[12]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Passwort ",-1)),r(e("input",{"onUpdate:modelValue":t[5]||(t[5]=l=>u.value=l),type:"password",required:"",class:"input",placeholder:s.value?"Mindestens 8 Zeichen":""},null,8,F),[[n,u.value]])]),p.value?(f(),c("div",O,g(p.value),1)):k("",!0),e("button",{type:"submit",disabled:v.value,class:"btn btn-primary w-full"},g(v.value?"Bitte warten...":s.value?"Registrieren":"Anmelden"),9,T)],32),e("div",j,[e("button",{type:"button",class:"text-sm text-primary-600 hover:text-primary-700",onClick:t[6]||(t[6]=l=>s.value=!s.value)},g(s.value?"Bereits registriert? Anmelden":"Noch kein Konto? Registrieren"),1)])])])]))}});export{L as default}; diff --git a/dist/assets/ModulesView-BNzetqIV.js b/dist/assets/ModulesView-DdZR_ST7.js similarity index 98% rename from dist/assets/ModulesView-BNzetqIV.js rename to dist/assets/ModulesView-DdZR_ST7.js index 86fb0db..561182e 100644 --- a/dist/assets/ModulesView-BNzetqIV.js +++ b/dist/assets/ModulesView-DdZR_ST7.js @@ -1 +1 @@ -import{d as k,q as h,m as d,c as l,a as t,t as r,e as u,F as w,x as M,r as c,o as n,n as f}from"./index-CWxNv9Fc.js";const S={class:"space-y-6"},C={key:0,class:"card bg-gradient-to-r from-primary-500 to-primary-700 text-white"},B={class:"grid grid-cols-2 md:grid-cols-4 gap-4"},V={class:"text-2xl font-bold"},z={class:"text-2xl font-bold"},A={class:"text-2xl font-bold"},F={class:"text-2xl font-bold"},D={class:"card"},E={key:0,class:"text-center py-8 text-gray-500"},L={key:1,class:"space-y-4"},N={class:"flex-1"},$={class:"flex items-center gap-2"},j={class:"font-medium text-gray-900 dark:text-white"},q={key:0,class:"badge badge-primary"},H={key:0,class:"text-sm text-gray-500 mt-1"},P=["disabled","onClick"],K=k({__name:"ModulesView",setup(G){const g=c([]),i=c(!0),o=c(null);h(async()=>{await Promise.all([b(),v()])});async function b(){i.value=!0;try{const s=await d.get("/modules/org");g.value=s.data.modules}catch(s){console.error(s)}finally{i.value=!1}}async function v(){try{const s=await d.get("/modules/developer/status");o.value=s.data}catch{console.log("Dev status not available")}}async function _(s){if(!s.is_core)try{await d.post(`/modules/${s.id}/toggle`,{enabled:!s.enabled}),s.enabled=!s.enabled}catch(e){alert(e instanceof Error?e.message:"Fehler")}}return(s,e)=>{var m,p,y,x;return n(),l("div",S,[e[6]||(e[6]=t("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"},"⚙️ Module",-1)),o.value?(n(),l("div",C,[e[4]||(e[4]=t("h2",{class:"text-lg font-semibold mb-4"},"System Status",-1)),t("div",B,[t("div",null,[e[0]||(e[0]=t("p",{class:"text-primary-100 text-sm"},"Benutzer",-1)),t("p",V,r(((m=o.value.stats)==null?void 0:m.user_count)||0),1)]),t("div",null,[e[1]||(e[1]=t("p",{class:"text-primary-100 text-sm"},"Aufträge",-1)),t("p",z,r(((p=o.value.stats)==null?void 0:p.order_count)||0),1)]),t("div",null,[e[2]||(e[2]=t("p",{class:"text-primary-100 text-sm"},"Stundenzettel",-1)),t("p",A,r(((y=o.value.stats)==null?void 0:y.timesheet_count)||0),1)]),t("div",null,[e[3]||(e[3]=t("p",{class:"text-primary-100 text-sm"},"Aktive Module",-1)),t("p",F,r(((x=o.value.stats)==null?void 0:x.enabled_modules)||0),1)])])])):u("",!0),t("div",D,[e[5]||(e[5]=t("h2",{class:"text-lg font-semibold mb-4"},"Verfügbare Module",-1)),i.value?(n(),l("div",E,"Lädt...")):(n(),l("div",L,[(n(!0),l(w,null,M(g.value,a=>(n(),l("div",{key:a.id,class:"flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg"},[t("div",N,[t("div",$,[t("h3",j,r(a.display_name),1),a.is_core?(n(),l("span",q,"Core")):u("",!0)]),a.description?(n(),l("p",H,r(a.description),1)):u("",!0)]),t("button",{disabled:a.is_core,class:f(["relative inline-flex h-6 w-11 items-center rounded-full transition-colors",a.enabled?"bg-primary-600":"bg-gray-200 dark:bg-gray-600",a.is_core?"opacity-50 cursor-not-allowed":"cursor-pointer"]),onClick:I=>_(a)},[t("span",{class:f(["inline-block h-4 w-4 transform rounded-full bg-white transition-transform",a.enabled?"translate-x-6":"translate-x-1"])},null,2)],10,P)]))),128))]))]),e[7]||(e[7]=t("div",{class:"card"},[t("h2",{class:"text-lg font-semibold mb-2"},"Hinweis"),t("p",{class:"text-gray-500 text-sm"}," Core-Module (Basis-System, Auftragsverwaltung) können nicht deaktiviert werden. Änderungen an Modulen werden sofort wirksam. ")],-1))])}}});export{K as default}; +import{d as k,q as h,m as d,c as l,a as t,t as r,e as u,F as w,x as M,r as c,n as f,o as n}from"./index-CgM2qJ96.js";const S={class:"space-y-6"},C={key:0,class:"card bg-gradient-to-r from-primary-500 to-primary-700 text-white"},B={class:"grid grid-cols-2 md:grid-cols-4 gap-4"},V={class:"text-2xl font-bold"},z={class:"text-2xl font-bold"},A={class:"text-2xl font-bold"},F={class:"text-2xl font-bold"},D={class:"card"},E={key:0,class:"text-center py-8 text-gray-500"},L={key:1,class:"space-y-4"},N={class:"flex-1"},$={class:"flex items-center gap-2"},j={class:"font-medium text-gray-900 dark:text-white"},q={key:0,class:"badge badge-primary"},H={key:0,class:"text-sm text-gray-500 mt-1"},P=["disabled","onClick"],K=k({__name:"ModulesView",setup(G){const g=c([]),i=c(!0),o=c(null);h(async()=>{await Promise.all([b(),v()])});async function b(){i.value=!0;try{const s=await d.get("/modules/org");g.value=s.data.modules}catch(s){console.error(s)}finally{i.value=!1}}async function v(){try{const s=await d.get("/modules/developer/status");o.value=s.data}catch{console.log("Dev status not available")}}async function _(s){if(!s.is_core)try{await d.post(`/modules/${s.id}/toggle`,{enabled:!s.enabled}),s.enabled=!s.enabled}catch(e){alert(e instanceof Error?e.message:"Fehler")}}return(s,e)=>{var m,p,y,x;return n(),l("div",S,[e[6]||(e[6]=t("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"},"⚙️ Module",-1)),o.value?(n(),l("div",C,[e[4]||(e[4]=t("h2",{class:"text-lg font-semibold mb-4"},"System Status",-1)),t("div",B,[t("div",null,[e[0]||(e[0]=t("p",{class:"text-primary-100 text-sm"},"Benutzer",-1)),t("p",V,r(((m=o.value.stats)==null?void 0:m.user_count)||0),1)]),t("div",null,[e[1]||(e[1]=t("p",{class:"text-primary-100 text-sm"},"Aufträge",-1)),t("p",z,r(((p=o.value.stats)==null?void 0:p.order_count)||0),1)]),t("div",null,[e[2]||(e[2]=t("p",{class:"text-primary-100 text-sm"},"Stundenzettel",-1)),t("p",A,r(((y=o.value.stats)==null?void 0:y.timesheet_count)||0),1)]),t("div",null,[e[3]||(e[3]=t("p",{class:"text-primary-100 text-sm"},"Aktive Module",-1)),t("p",F,r(((x=o.value.stats)==null?void 0:x.enabled_modules)||0),1)])])])):u("",!0),t("div",D,[e[5]||(e[5]=t("h2",{class:"text-lg font-semibold mb-4"},"Verfügbare Module",-1)),i.value?(n(),l("div",E,"Lädt...")):(n(),l("div",L,[(n(!0),l(w,null,M(g.value,a=>(n(),l("div",{key:a.id,class:"flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg"},[t("div",N,[t("div",$,[t("h3",j,r(a.display_name),1),a.is_core?(n(),l("span",q,"Core")):u("",!0)]),a.description?(n(),l("p",H,r(a.description),1)):u("",!0)]),t("button",{disabled:a.is_core,class:f(["relative inline-flex h-6 w-11 items-center rounded-full transition-colors",a.enabled?"bg-primary-600":"bg-gray-200 dark:bg-gray-600",a.is_core?"opacity-50 cursor-not-allowed":"cursor-pointer"]),onClick:I=>_(a)},[t("span",{class:f(["inline-block h-4 w-4 transform rounded-full bg-white transition-transform",a.enabled?"translate-x-6":"translate-x-1"])},null,2)],10,P)]))),128))]))]),e[7]||(e[7]=t("div",{class:"card"},[t("h2",{class:"text-lg font-semibold mb-2"},"Hinweis"),t("p",{class:"text-gray-500 text-sm"}," Core-Module (Basis-System, Auftragsverwaltung) können nicht deaktiviert werden. Änderungen an Modulen werden sofort wirksam. ")],-1))])}}});export{K as default}; diff --git a/dist/assets/ObjectsView-CzlgFF9j.js b/dist/assets/ObjectsView-bVbTDa5D.js similarity index 98% rename from dist/assets/ObjectsView-CzlgFF9j.js rename to dist/assets/ObjectsView-bVbTDa5D.js index af53d5b..6e57e48 100644 --- a/dist/assets/ObjectsView-CzlgFF9j.js +++ b/dist/assets/ObjectsView-bVbTDa5D.js @@ -1 +1 @@ -import{d as N,q as M,m as _,c as l,a as t,F as r,x as u,t as a,p as h,e as p,b as v,v as g,r as c,o as n,n as f}from"./index-CWxNv9Fc.js";const U={class:"p-6"},$={class:"flex justify-between items-center mb-6"},z={class:"flex gap-6"},F={class:"w-1/2"},L={key:0,class:"text-center py-12"},S={key:1,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},E={key:2,class:"space-y-2"},T=["onClick"],q={class:"flex justify-between items-start"},H={class:"font-semibold"},I={class:"text-sm text-gray-500"},P={class:"text-sm text-gray-400"},W={key:0,class:"mt-2 text-xs text-gray-500"},Z={class:"w-1/2"},G={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-400"},J={key:1,class:"bg-white rounded-lg shadow p-6"},Q={class:"text-xl font-bold mb-1"},R={class:"text-gray-500 mb-4"},X={class:"space-y-6"},Y={class:"text-sm font-semibold text-gray-500 mb-2 flex items-center"},tt={class:"ml-2 text-xs bg-gray-100 px-2 py-0.5 rounded"},et={key:0,class:"space-y-2"},st={class:"font-medium"},lt={class:"text-gray-400 font-normal"},nt={class:"text-gray-600"},at={key:1,class:"text-sm text-gray-400"},ot={class:"text-sm font-semibold text-gray-500 mb-2 flex items-center"},it={class:"ml-2 text-xs bg-gray-100 px-2 py-0.5 rounded"},dt={key:0,class:"space-y-2"},rt={class:"font-medium"},ut={class:"text-gray-600"},ct={key:1,class:"text-sm text-gray-400"},mt={key:0},pt={class:"flex flex-wrap gap-2"},vt=["href"],gt={key:1},xt={class:"flex flex-wrap gap-2"},yt={key:0,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},bt={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},_t={class:"space-y-4"},ht={class:"grid grid-cols-2 gap-4"},ft={class:"flex justify-end space-x-2 mt-6"},Ot=N({__name:"ObjectsView",setup(kt){const x=c(!0),y=c([]),o=c(null),m=c(!1),d=c({name:"",address:"",city:"",postal_code:"",customer_id:""});M(async()=>{await k()});async function k(){x.value=!0;try{const i=await _.get("/objects");y.value=i.data.objects||[]}catch(i){console.error(i)}x.value=!1}async function D(i){try{const e=await _.get(`/objects/${i}`);o.value=e.data}catch(e){console.error(e)}}async function K(){try{await _.post("/objects",d.value),m.value=!1,d.value={name:"",address:"",city:"",postal_code:"",customer_id:""},await k()}catch(i){alert("Fehler: "+i.message)}}function b(i){return{active:{text:"Aktiv",class:"bg-green-100 text-green-700",icon:"🟢"},inactive:{text:"Inaktiv",class:"bg-gray-100 text-gray-700",icon:"⚪"},pending:{text:"Ausstehend",class:"bg-yellow-100 text-yellow-700",icon:"🟡"}}[i]||{text:i,class:"bg-gray-100",icon:""}}return(i,e)=>{var w,C,O,A,V,j;return n(),l("div",U,[t("div",$,[e[6]||(e[6]=t("div",null,[t("h1",{class:"text-2xl font-bold"},"🏢 Objektverwaltung"),t("p",{class:"text-gray-500"},"Standorte, Kontakte & Anweisungen")],-1)),t("button",{onClick:e[0]||(e[0]=s=>m.value=!0),class:"btn btn-primary"},"+ Objekt")]),t("div",z,[t("div",F,[x.value?(n(),l("div",L,"Laden...")):y.value.length===0?(n(),l("div",S,[...e[7]||(e[7]=[t("p",{class:"text-4xl mb-4"},"🏢",-1),t("p",null,"Keine Objekte vorhanden",-1)])])):(n(),l("div",E,[(n(!0),l(r,null,u(y.value,s=>{var B;return n(),l("div",{key:s.id,onClick:wt=>D(s.id),class:f(["bg-white rounded-lg shadow p-4 cursor-pointer hover:shadow-md transition-shadow",((B=o.value)==null?void 0:B.id)===s.id?"ring-2 ring-blue-500":""])},[t("div",q,[t("div",null,[t("h3",H,a(s.name),1),t("p",I,a(s.address),1),t("p",P,a(s.postal_code)+" "+a(s.city),1)]),t("span",{class:f(["px-2 py-1 text-xs rounded",b(s.status).class])},a(b(s.status).icon)+" "+a(b(s.status).text),3)]),s.customer_name?(n(),l("div",W," 👤 "+a(s.customer_name),1)):p("",!0)],10,T)}),128))]))]),t("div",Z,[o.value?(n(),l("div",J,[t("h2",Q,a(o.value.name),1),t("p",R,a(o.value.address)+", "+a(o.value.postal_code)+" "+a(o.value.city),1),t("div",X,[t("div",null,[t("h3",Y,[e[9]||(e[9]=h(" 📞 Ansprechpartner ",-1)),t("span",tt,a(((w=o.value.contacts)==null?void 0:w.length)||0),1)]),(C=o.value.contacts)!=null&&C.length?(n(),l("div",et,[(n(!0),l(r,null,u(o.value.contacts,s=>(n(),l("div",{key:s.id,class:"p-2 bg-gray-50 rounded text-sm"},[t("div",st,[h(a(s.name)+" ",1),t("span",lt,a(s.role),1)]),t("div",nt,"📞 "+a(s.phone)+" · 📧 "+a(s.email),1)]))),128))])):(n(),l("p",at,"Keine Kontakte hinterlegt"))]),t("div",null,[t("h3",ot,[e[10]||(e[10]=h(" 📋 Anweisungen ",-1)),t("span",it,a(((O=o.value.instructions)==null?void 0:O.length)||0),1)]),(A=o.value.instructions)!=null&&A.length?(n(),l("div",dt,[(n(!0),l(r,null,u(o.value.instructions,s=>(n(),l("div",{key:s.id,class:f(["p-2 rounded text-sm",s.priority==="critical"?"bg-red-50 border-l-4 border-red-500":s.priority==="high"?"bg-orange-50 border-l-4 border-orange-500":"bg-gray-50"])},[t("div",rt,a(s.title),1),t("p",ut,a(s.content),1)],2))),128))])):(n(),l("p",ct,"Keine Anweisungen hinterlegt"))]),(V=o.value.documents)!=null&&V.length?(n(),l("div",mt,[e[11]||(e[11]=t("h3",{class:"text-sm font-semibold text-gray-500 mb-2"},"📁 Dokumente",-1)),t("div",pt,[(n(!0),l(r,null,u(o.value.documents,s=>(n(),l("a",{key:s.id,href:s.file_url,target:"_blank",class:"px-2 py-1 bg-blue-50 text-blue-700 rounded text-sm hover:bg-blue-100"},a(s.file_name||"Dokument"),9,vt))),128))])])):p("",!0),(j=o.value.checkpoints)!=null&&j.length?(n(),l("div",gt,[e[12]||(e[12]=t("h3",{class:"text-sm font-semibold text-gray-500 mb-2"},"📍 Checkpoints",-1)),t("div",xt,[(n(!0),l(r,null,u(o.value.checkpoints,s=>(n(),l("span",{key:s.id,class:"px-2 py-1 bg-gray-100 rounded text-sm"},a(s.name),1))),128))])])):p("",!0)])])):(n(),l("div",G,[...e[8]||(e[8]=[t("p",null,"Wähle ein Objekt aus",-1)])]))])]),m.value?(n(),l("div",yt,[t("div",bt,[e[17]||(e[17]=t("h2",{class:"text-xl font-bold mb-4"},"Neues Objekt",-1)),t("div",_t,[t("div",null,[e[13]||(e[13]=t("label",{class:"block text-sm font-medium mb-1"},"Name *",-1)),v(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>d.value.name=s),class:"input",placeholder:"z.B. Hauptgebäude Musterstraße"},null,512),[[g,d.value.name]])]),t("div",null,[e[14]||(e[14]=t("label",{class:"block text-sm font-medium mb-1"},"Adresse",-1)),v(t("input",{"onUpdate:modelValue":e[2]||(e[2]=s=>d.value.address=s),class:"input"},null,512),[[g,d.value.address]])]),t("div",ht,[t("div",null,[e[15]||(e[15]=t("label",{class:"block text-sm font-medium mb-1"},"PLZ",-1)),v(t("input",{"onUpdate:modelValue":e[3]||(e[3]=s=>d.value.postal_code=s),class:"input"},null,512),[[g,d.value.postal_code]])]),t("div",null,[e[16]||(e[16]=t("label",{class:"block text-sm font-medium mb-1"},"Stadt",-1)),v(t("input",{"onUpdate:modelValue":e[4]||(e[4]=s=>d.value.city=s),class:"input"},null,512),[[g,d.value.city]])])])]),t("div",ft,[t("button",{onClick:e[5]||(e[5]=s=>m.value=!1),class:"btn"},"Abbrechen"),t("button",{onClick:K,class:"btn btn-primary"},"Erstellen")])])])):p("",!0)])}}});export{Ot as default}; +import{d as N,q as M,m as _,c as l,a as t,F as r,x as u,t as a,p as h,e as p,b as v,v as g,r as c,n as f,o as n}from"./index-CgM2qJ96.js";const U={class:"p-6"},$={class:"flex justify-between items-center mb-6"},z={class:"flex gap-6"},F={class:"w-1/2"},L={key:0,class:"text-center py-12"},S={key:1,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},E={key:2,class:"space-y-2"},T=["onClick"],q={class:"flex justify-between items-start"},H={class:"font-semibold"},I={class:"text-sm text-gray-500"},P={class:"text-sm text-gray-400"},W={key:0,class:"mt-2 text-xs text-gray-500"},Z={class:"w-1/2"},G={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-400"},J={key:1,class:"bg-white rounded-lg shadow p-6"},Q={class:"text-xl font-bold mb-1"},R={class:"text-gray-500 mb-4"},X={class:"space-y-6"},Y={class:"text-sm font-semibold text-gray-500 mb-2 flex items-center"},tt={class:"ml-2 text-xs bg-gray-100 px-2 py-0.5 rounded"},et={key:0,class:"space-y-2"},st={class:"font-medium"},lt={class:"text-gray-400 font-normal"},nt={class:"text-gray-600"},at={key:1,class:"text-sm text-gray-400"},ot={class:"text-sm font-semibold text-gray-500 mb-2 flex items-center"},it={class:"ml-2 text-xs bg-gray-100 px-2 py-0.5 rounded"},dt={key:0,class:"space-y-2"},rt={class:"font-medium"},ut={class:"text-gray-600"},ct={key:1,class:"text-sm text-gray-400"},mt={key:0},pt={class:"flex flex-wrap gap-2"},vt=["href"],gt={key:1},xt={class:"flex flex-wrap gap-2"},yt={key:0,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},bt={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},_t={class:"space-y-4"},ht={class:"grid grid-cols-2 gap-4"},ft={class:"flex justify-end space-x-2 mt-6"},Ot=N({__name:"ObjectsView",setup(kt){const x=c(!0),y=c([]),o=c(null),m=c(!1),d=c({name:"",address:"",city:"",postal_code:"",customer_id:""});M(async()=>{await k()});async function k(){x.value=!0;try{const i=await _.get("/objects");y.value=i.data.objects||[]}catch(i){console.error(i)}x.value=!1}async function D(i){try{const e=await _.get(`/objects/${i}`);o.value=e.data}catch(e){console.error(e)}}async function K(){try{await _.post("/objects",d.value),m.value=!1,d.value={name:"",address:"",city:"",postal_code:"",customer_id:""},await k()}catch(i){alert("Fehler: "+i.message)}}function b(i){return{active:{text:"Aktiv",class:"bg-green-100 text-green-700",icon:"🟢"},inactive:{text:"Inaktiv",class:"bg-gray-100 text-gray-700",icon:"⚪"},pending:{text:"Ausstehend",class:"bg-yellow-100 text-yellow-700",icon:"🟡"}}[i]||{text:i,class:"bg-gray-100",icon:""}}return(i,e)=>{var w,C,O,A,V,j;return n(),l("div",U,[t("div",$,[e[6]||(e[6]=t("div",null,[t("h1",{class:"text-2xl font-bold"},"🏢 Objektverwaltung"),t("p",{class:"text-gray-500"},"Standorte, Kontakte & Anweisungen")],-1)),t("button",{onClick:e[0]||(e[0]=s=>m.value=!0),class:"btn btn-primary"},"+ Objekt")]),t("div",z,[t("div",F,[x.value?(n(),l("div",L,"Laden...")):y.value.length===0?(n(),l("div",S,[...e[7]||(e[7]=[t("p",{class:"text-4xl mb-4"},"🏢",-1),t("p",null,"Keine Objekte vorhanden",-1)])])):(n(),l("div",E,[(n(!0),l(r,null,u(y.value,s=>{var B;return n(),l("div",{key:s.id,onClick:wt=>D(s.id),class:f(["bg-white rounded-lg shadow p-4 cursor-pointer hover:shadow-md transition-shadow",((B=o.value)==null?void 0:B.id)===s.id?"ring-2 ring-blue-500":""])},[t("div",q,[t("div",null,[t("h3",H,a(s.name),1),t("p",I,a(s.address),1),t("p",P,a(s.postal_code)+" "+a(s.city),1)]),t("span",{class:f(["px-2 py-1 text-xs rounded",b(s.status).class])},a(b(s.status).icon)+" "+a(b(s.status).text),3)]),s.customer_name?(n(),l("div",W," 👤 "+a(s.customer_name),1)):p("",!0)],10,T)}),128))]))]),t("div",Z,[o.value?(n(),l("div",J,[t("h2",Q,a(o.value.name),1),t("p",R,a(o.value.address)+", "+a(o.value.postal_code)+" "+a(o.value.city),1),t("div",X,[t("div",null,[t("h3",Y,[e[9]||(e[9]=h(" 📞 Ansprechpartner ",-1)),t("span",tt,a(((w=o.value.contacts)==null?void 0:w.length)||0),1)]),(C=o.value.contacts)!=null&&C.length?(n(),l("div",et,[(n(!0),l(r,null,u(o.value.contacts,s=>(n(),l("div",{key:s.id,class:"p-2 bg-gray-50 rounded text-sm"},[t("div",st,[h(a(s.name)+" ",1),t("span",lt,a(s.role),1)]),t("div",nt,"📞 "+a(s.phone)+" · 📧 "+a(s.email),1)]))),128))])):(n(),l("p",at,"Keine Kontakte hinterlegt"))]),t("div",null,[t("h3",ot,[e[10]||(e[10]=h(" 📋 Anweisungen ",-1)),t("span",it,a(((O=o.value.instructions)==null?void 0:O.length)||0),1)]),(A=o.value.instructions)!=null&&A.length?(n(),l("div",dt,[(n(!0),l(r,null,u(o.value.instructions,s=>(n(),l("div",{key:s.id,class:f(["p-2 rounded text-sm",s.priority==="critical"?"bg-red-50 border-l-4 border-red-500":s.priority==="high"?"bg-orange-50 border-l-4 border-orange-500":"bg-gray-50"])},[t("div",rt,a(s.title),1),t("p",ut,a(s.content),1)],2))),128))])):(n(),l("p",ct,"Keine Anweisungen hinterlegt"))]),(V=o.value.documents)!=null&&V.length?(n(),l("div",mt,[e[11]||(e[11]=t("h3",{class:"text-sm font-semibold text-gray-500 mb-2"},"📁 Dokumente",-1)),t("div",pt,[(n(!0),l(r,null,u(o.value.documents,s=>(n(),l("a",{key:s.id,href:s.file_url,target:"_blank",class:"px-2 py-1 bg-blue-50 text-blue-700 rounded text-sm hover:bg-blue-100"},a(s.file_name||"Dokument"),9,vt))),128))])])):p("",!0),(j=o.value.checkpoints)!=null&&j.length?(n(),l("div",gt,[e[12]||(e[12]=t("h3",{class:"text-sm font-semibold text-gray-500 mb-2"},"📍 Checkpoints",-1)),t("div",xt,[(n(!0),l(r,null,u(o.value.checkpoints,s=>(n(),l("span",{key:s.id,class:"px-2 py-1 bg-gray-100 rounded text-sm"},a(s.name),1))),128))])])):p("",!0)])])):(n(),l("div",G,[...e[8]||(e[8]=[t("p",null,"Wähle ein Objekt aus",-1)])]))])]),m.value?(n(),l("div",yt,[t("div",bt,[e[17]||(e[17]=t("h2",{class:"text-xl font-bold mb-4"},"Neues Objekt",-1)),t("div",_t,[t("div",null,[e[13]||(e[13]=t("label",{class:"block text-sm font-medium mb-1"},"Name *",-1)),v(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>d.value.name=s),class:"input",placeholder:"z.B. Hauptgebäude Musterstraße"},null,512),[[g,d.value.name]])]),t("div",null,[e[14]||(e[14]=t("label",{class:"block text-sm font-medium mb-1"},"Adresse",-1)),v(t("input",{"onUpdate:modelValue":e[2]||(e[2]=s=>d.value.address=s),class:"input"},null,512),[[g,d.value.address]])]),t("div",ht,[t("div",null,[e[15]||(e[15]=t("label",{class:"block text-sm font-medium mb-1"},"PLZ",-1)),v(t("input",{"onUpdate:modelValue":e[3]||(e[3]=s=>d.value.postal_code=s),class:"input"},null,512),[[g,d.value.postal_code]])]),t("div",null,[e[16]||(e[16]=t("label",{class:"block text-sm font-medium mb-1"},"Stadt",-1)),v(t("input",{"onUpdate:modelValue":e[4]||(e[4]=s=>d.value.city=s),class:"input"},null,512),[[g,d.value.city]])])])]),t("div",ft,[t("button",{onClick:e[5]||(e[5]=s=>m.value=!1),class:"btn"},"Abbrechen"),t("button",{onClick:K,class:"btn btn-primary"},"Erstellen")])])])):p("",!0)])}}});export{Ot as default}; diff --git a/dist/assets/OrderDetailView-CrMXW-i2.js b/dist/assets/OrderDetailView-BuCP5BM8.js similarity index 82% rename from dist/assets/OrderDetailView-CrMXW-i2.js rename to dist/assets/OrderDetailView-BuCP5BM8.js index 46ee352..dd9a333 100644 --- a/dist/assets/OrderDetailView-CrMXW-i2.js +++ b/dist/assets/OrderDetailView-BuCP5BM8.js @@ -1 +1 @@ -import{d as A,u as $,q as B,m as p,c as r,i as S,j as V,a as e,t as o,e as l,n as _,y as k,F as h,x as E,g as M,f as N,r as y,l as D,o as i,p as F}from"./index-CWxNv9Fc.js";const L={key:0,class:"text-center py-12 text-gray-500"},j={key:1,class:"space-y-6"},z={class:"card"},O={class:"flex items-start justify-between"},q={class:"flex items-center gap-3"},I={class:"text-gray-500"},R={class:"text-2xl font-bold text-gray-900 dark:text-white"},Z={key:0,class:"mt-2 text-gray-600 dark:text-gray-400"},H={class:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-6"},K={key:0},T={class:"font-medium"},G={key:1},J={class:"font-medium"},P={key:2},Q={class:"font-medium"},U={class:"font-medium"},W={key:0,class:"mt-6 pt-6 border-t border-gray-200 dark:border-gray-700"},X={class:"flex flex-wrap gap-2"},Y={class:"card"},tt={key:0,class:"text-center py-4 text-gray-500"},et={key:1,class:"space-y-3"},st={class:"font-medium text-gray-900 dark:text-white"},at={class:"text-sm text-gray-500"},nt={class:"flex items-center gap-2"},rt={key:0,class:"card"},ot={class:"text-gray-600 dark:text-gray-400 whitespace-pre-wrap"},dt=A({__name:"OrderDetailView",setup(it){const c=M(),w=N(),m=$(),s=y(null),d=y([]),v=y(!0);B(async()=>{try{const n=await p.get(`/orders/${c.params.id}`);s.value=n.data.order,d.value=n.data.assignments}catch(n){console.error(n),w.push("/orders")}finally{v.value=!1}});async function u(n){try{await p.put(`/orders/${c.params.id}`,{status:n}),s.value.status=n}catch(t){alert(t instanceof Error?t.message:"Fehler")}}async function x(n){try{await p.put(`/orders/${c.params.id}/assignment`,{status:n?"confirmed":"declined"});const t=d.value.find(g=>{var a;return g.user_id===((a=m.user)==null?void 0:a.id)});t&&(t.status=n?"confirmed":"declined")}catch(t){alert(t instanceof Error?t.message:"Fehler")}}function b(n){return{draft:"Entwurf",published:"Veröffentlicht",in_progress:"In Bearbeitung",completed:"Abgeschlossen",cancelled:"Abgesagt",pending:"Ausstehend",confirmed:"Bestätigt",declined:"Abgelehnt"}[n]||n}return(n,t)=>{const g=D("router-link");return v.value?(i(),r("div",L,"Lädt...")):s.value?(i(),r("div",j,[S(g,{to:"/orders",class:"text-primary-600 hover:text-primary-700 text-sm"},{default:V(()=>[...t[6]||(t[6]=[F(" ← Zurück zu Aufträge ",-1)])]),_:1}),e("div",z,[e("div",O,[e("div",null,[e("div",q,[e("span",I,"#"+o(s.value.number),1),e("h1",R,o(s.value.title),1)]),s.value.description?(i(),r("p",Z,o(s.value.description),1)):l("",!0)]),e("span",{class:_(["badge",s.value.status==="completed"?"badge-success":"badge-primary"])},o(b(s.value.status)),3)]),e("div",H,[s.value.location?(i(),r("div",K,[t[7]||(t[7]=e("p",{class:"text-sm text-gray-500"},"Ort",-1)),e("p",T,"📍 "+o(s.value.location),1)])):l("",!0),s.value.start_time?(i(),r("div",G,[t[8]||(t[8]=e("p",{class:"text-sm text-gray-500"},"Start",-1)),e("p",J,o(new Date(s.value.start_time).toLocaleString("de-DE")),1)])):l("",!0),s.value.client_name?(i(),r("div",P,[t[9]||(t[9]=e("p",{class:"text-sm text-gray-500"},"Kunde",-1)),e("p",Q,o(s.value.client_name),1)])):l("",!0),e("div",null,[t[10]||(t[10]=e("p",{class:"text-sm text-gray-500"},"Benötigte MA",-1)),e("p",U,o(d.value.length)+"/"+o(s.value.required_staff),1)])]),k(m).canManageOrders?(i(),r("div",W,[t[11]||(t[11]=e("p",{class:"text-sm text-gray-500 mb-2"},"Status ändern:",-1)),e("div",X,[e("button",{class:"btn btn-secondary text-sm",onClick:t[0]||(t[0]=a=>u("draft"))},"Entwurf"),e("button",{class:"btn btn-primary text-sm",onClick:t[1]||(t[1]=a=>u("published"))},"Veröffentlichen"),e("button",{class:"btn btn-warning text-sm",onClick:t[2]||(t[2]=a=>u("in_progress"))},"In Bearbeitung"),e("button",{class:"btn btn-success text-sm",onClick:t[3]||(t[3]=a=>u("completed"))},"Abschließen")])])):l("",!0)]),e("div",Y,[t[12]||(t[12]=e("h2",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," 👥 Zugewiesene Mitarbeiter ",-1)),d.value.length===0?(i(),r("div",tt," Noch keine Mitarbeiter zugewiesen ")):(i(),r("div",et,[(i(!0),r(h,null,E(d.value,a=>{var f;return i(),r("div",{key:a.id,class:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg"},[e("div",null,[e("p",st,o(a.user_name),1),e("p",at,o(a.user_phone),1)]),e("div",nt,[e("span",{class:_(["badge",a.status==="confirmed"?"badge-success":a.status==="declined"?"badge-danger":"badge-warning"])},o(b(a.status)),3),a.user_id===((f=k(m).user)==null?void 0:f.id)&&a.status==="pending"?(i(),r(h,{key:0},[e("button",{class:"btn btn-success text-sm",onClick:t[4]||(t[4]=C=>x(!0))},"✓"),e("button",{class:"btn btn-danger text-sm",onClick:t[5]||(t[5]=C=>x(!1))},"✗")],64)):l("",!0)])])}),128))]))]),s.value.special_instructions?(i(),r("div",rt,[t[13]||(t[13]=e("h2",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," 📝 Besondere Hinweise ",-1)),e("p",ot,o(s.value.special_instructions),1)])):l("",!0)])):l("",!0)}}});export{dt as default}; +import{d as A,u as $,q as B,m as p,c as r,i as S,j as V,a as e,t as o,e as l,n as _,z as k,F as h,x as E,g as M,f as N,r as v,l as z,p as D,o as i}from"./index-CgM2qJ96.js";const F={key:0,class:"text-center py-12 text-gray-500"},L={key:1,class:"space-y-6"},j={class:"card"},O={class:"flex items-start justify-between"},q={class:"flex items-center gap-3"},I={class:"text-gray-500"},R={class:"text-2xl font-bold text-gray-900 dark:text-white"},Z={key:0,class:"mt-2 text-gray-600 dark:text-gray-400"},H={class:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-6"},K={key:0},T={class:"font-medium"},G={key:1},J={class:"font-medium"},P={key:2},Q={class:"font-medium"},U={class:"font-medium"},W={key:0,class:"mt-6 pt-6 border-t border-gray-200 dark:border-gray-700"},X={class:"flex flex-wrap gap-2"},Y={class:"card"},tt={key:0,class:"text-center py-4 text-gray-500"},et={key:1,class:"space-y-3"},st={class:"font-medium text-gray-900 dark:text-white"},at={class:"text-sm text-gray-500"},nt={class:"flex items-center gap-2"},rt={key:0,class:"card"},ot={class:"text-gray-600 dark:text-gray-400 whitespace-pre-wrap"},dt=A({__name:"OrderDetailView",setup(it){const c=M(),w=N(),m=$(),s=v(null),d=v([]),x=v(!0);B(async()=>{try{const n=await p.get(`/orders/${c.params.id}`);s.value=n.data.order,d.value=n.data.assignments}catch(n){console.error(n),w.push("/orders")}finally{x.value=!1}});async function u(n){try{await p.put(`/orders/${c.params.id}`,{status:n}),s.value.status=n}catch(t){alert(t instanceof Error?t.message:"Fehler")}}async function y(n){try{await p.put(`/orders/${c.params.id}/assignment`,{status:n?"confirmed":"declined"});const t=d.value.find(g=>{var a;return g.user_id===((a=m.user)==null?void 0:a.id)});t&&(t.status=n?"confirmed":"declined")}catch(t){alert(t instanceof Error?t.message:"Fehler")}}function b(n){return{draft:"Entwurf",published:"Veröffentlicht",in_progress:"In Bearbeitung",completed:"Abgeschlossen",cancelled:"Abgesagt",pending:"Ausstehend",confirmed:"Bestätigt",declined:"Abgelehnt"}[n]||n}return(n,t)=>{const g=z("router-link");return x.value?(i(),r("div",F,"Lädt...")):s.value?(i(),r("div",L,[S(g,{to:"/orders",class:"text-primary-600 hover:text-primary-700 text-sm"},{default:V(()=>[...t[6]||(t[6]=[D(" ← Zurück zu Aufträge ",-1)])]),_:1}),e("div",j,[e("div",O,[e("div",null,[e("div",q,[e("span",I,"#"+o(s.value.number),1),e("h1",R,o(s.value.title),1)]),s.value.description?(i(),r("p",Z,o(s.value.description),1)):l("",!0)]),e("span",{class:_(["badge",s.value.status==="completed"?"badge-success":"badge-primary"])},o(b(s.value.status)),3)]),e("div",H,[s.value.location?(i(),r("div",K,[t[7]||(t[7]=e("p",{class:"text-sm text-gray-500"},"Ort",-1)),e("p",T,"📍 "+o(s.value.location),1)])):l("",!0),s.value.start_time?(i(),r("div",G,[t[8]||(t[8]=e("p",{class:"text-sm text-gray-500"},"Start",-1)),e("p",J,o(new Date(s.value.start_time).toLocaleString("de-DE")),1)])):l("",!0),s.value.client_name?(i(),r("div",P,[t[9]||(t[9]=e("p",{class:"text-sm text-gray-500"},"Kunde",-1)),e("p",Q,o(s.value.client_name),1)])):l("",!0),e("div",null,[t[10]||(t[10]=e("p",{class:"text-sm text-gray-500"},"Benötigte MA",-1)),e("p",U,o(d.value.length)+"/"+o(s.value.required_staff),1)])]),k(m).canManageOrders?(i(),r("div",W,[t[11]||(t[11]=e("p",{class:"text-sm text-gray-500 mb-2"},"Status ändern:",-1)),e("div",X,[e("button",{class:"btn btn-secondary text-sm",onClick:t[0]||(t[0]=a=>u("draft"))},"Entwurf"),e("button",{class:"btn btn-primary text-sm",onClick:t[1]||(t[1]=a=>u("published"))},"Veröffentlichen"),e("button",{class:"btn btn-warning text-sm",onClick:t[2]||(t[2]=a=>u("in_progress"))},"In Bearbeitung"),e("button",{class:"btn btn-success text-sm",onClick:t[3]||(t[3]=a=>u("completed"))},"Abschließen")])])):l("",!0)]),e("div",Y,[t[12]||(t[12]=e("h2",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," 👥 Zugewiesene Mitarbeiter ",-1)),d.value.length===0?(i(),r("div",tt," Noch keine Mitarbeiter zugewiesen ")):(i(),r("div",et,[(i(!0),r(h,null,E(d.value,a=>{var f;return i(),r("div",{key:a.id,class:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg"},[e("div",null,[e("p",st,o(a.user_name),1),e("p",at,o(a.user_phone),1)]),e("div",nt,[e("span",{class:_(["badge",a.status==="confirmed"?"badge-success":a.status==="declined"?"badge-danger":"badge-warning"])},o(b(a.status)),3),a.user_id===((f=k(m).user)==null?void 0:f.id)&&a.status==="pending"?(i(),r(h,{key:0},[e("button",{class:"btn btn-success text-sm",onClick:t[4]||(t[4]=C=>y(!0))},"✓"),e("button",{class:"btn btn-danger text-sm",onClick:t[5]||(t[5]=C=>y(!1))},"✗")],64)):l("",!0)])])}),128))]))]),s.value.special_instructions?(i(),r("div",rt,[t[13]||(t[13]=e("h2",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," 📝 Besondere Hinweise ",-1)),e("p",ot,o(s.value.special_instructions),1)])):l("",!0)])):l("",!0)}}});export{dt as default}; diff --git a/dist/assets/OrdersView-Cykxo3M3.js b/dist/assets/OrdersView-D55YFtzq.js similarity index 92% rename from dist/assets/OrdersView-Cykxo3M3.js rename to dist/assets/OrdersView-D55YFtzq.js index 182d633..a614809 100644 --- a/dist/assets/OrdersView-Cykxo3M3.js +++ b/dist/assets/OrdersView-D55YFtzq.js @@ -1 +1 @@ -import{d as U,u as B,q as S,m as x,c as o,a as e,y as C,e as g,b as n,s as E,A as q,F as M,x as O,w as D,v as i,r as u,k as j,o as r,z as L,j as N,t as d,n as F,l as z}from"./index-CWxNv9Fc.js";const $={class:"space-y-6"},I={class:"flex items-center justify-between"},K={class:"card"},T={class:"flex items-center gap-4"},H={class:"card"},G={key:0,class:"text-center py-8 text-gray-500"},J={key:1,class:"text-center py-8 text-gray-500"},P={key:2,class:"divide-y divide-gray-200 dark:divide-gray-700"},Q={class:"flex items-start justify-between"},R={class:"flex-1"},W={class:"flex items-center gap-3"},X={class:"text-sm text-gray-500 dark:text-gray-400"},Y={class:"font-medium text-gray-900 dark:text-white"},Z={class:"mt-1 flex items-center gap-4 text-sm text-gray-500 dark:text-gray-400"},h={key:0},tt={key:1},et={key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/50"},st={class:"card w-full max-w-2xl max-h-[90vh] overflow-y-auto m-4"},at={class:"grid grid-cols-2 gap-4"},lt={class:"grid grid-cols-2 gap-4"},nt={class:"grid grid-cols-2 gap-4"},it={class:"flex justify-end gap-3 pt-4"},dt=U({__name:"OrdersView",setup(rt){const f=B(),c=u([]),v=u(!0),m=u(!1),p=u(""),a=u({title:"",description:"",location:"",address:"",client_name:"",client_contact:"",start_time:"",end_time:"",required_staff:1,special_instructions:""}),y=j(()=>p.value?c.value.filter(l=>l.status===p.value):c.value);S(async()=>{await b()});async function b(){v.value=!0;try{const l=await x.get("/orders");c.value=l.data.orders}catch(l){console.error("Load orders error:",l)}finally{v.value=!1}}async function k(){try{await x.post("/orders",a.value),m.value=!1,a.value={title:"",description:"",location:"",address:"",client_name:"",client_contact:"",start_time:"",end_time:"",required_staff:1,special_instructions:""},await b()}catch(l){alert(l instanceof Error?l.message:"Fehler beim Erstellen")}}function _(l){return{draft:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",published:"badge-primary",in_progress:"badge-warning",completed:"badge-success",cancelled:"badge-danger"}[l]||"badge-secondary"}function w(l){return{draft:"Entwurf",published:"Veröffentlicht",in_progress:"In Bearbeitung",completed:"Abgeschlossen",cancelled:"Abgesagt"}[l]||l}function V(l){return l?new Date(l).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"-"}return(l,t)=>{const A=z("router-link");return r(),o("div",$,[e("div",I,[t[13]||(t[13]=e("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"}," 📋 Aufträge ",-1)),C(f).canManageOrders?(r(),o("button",{key:0,class:"btn btn-primary",onClick:t[0]||(t[0]=s=>m.value=!0)}," + Neuer Auftrag ")):g("",!0)]),e("div",K,[e("div",T,[t[15]||(t[15]=e("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"Status:",-1)),n(e("select",{"onUpdate:modelValue":t[1]||(t[1]=s=>p.value=s),class:"input w-48"},[...t[14]||(t[14]=[q('',6)])],512),[[E,p.value]])])]),e("div",H,[v.value?(r(),o("div",G," Lädt... ")):y.value.length===0?(r(),o("div",J," Keine Aufträge gefunden ")):(r(),o("div",P,[(r(!0),o(M,null,O(y.value,s=>(r(),L(A,{key:s.id,to:`/orders/${s.id}`,class:"block py-4 hover:bg-gray-50 dark:hover:bg-gray-700/50 -mx-6 px-6 transition-colors"},{default:N(()=>[e("div",Q,[e("div",R,[e("div",W,[e("span",X,"#"+d(s.number),1),e("h3",Y,d(s.title),1),e("span",{class:F(["badge",_(s.status)])},d(w(s.status)),3)]),e("div",Z,[s.location?(r(),o("span",h,"📍 "+d(s.location),1)):g("",!0),s.start_time?(r(),o("span",tt,"🕐 "+d(V(s.start_time)),1)):g("",!0),e("span",null,"👥 "+d(s.assigned_count||0)+"/"+d(s.required_staff),1)])]),t[16]||(t[16]=e("span",{class:"text-gray-400"},"→",-1))])]),_:2},1032,["to"]))),128))]))]),m.value?(r(),o("div",et,[e("div",st,[t[28]||(t[28]=e("h2",{class:"text-xl font-semibold text-gray-900 dark:text-white mb-6"}," Neuer Auftrag ",-1)),e("form",{onSubmit:D(k,["prevent"]),class:"space-y-4"},[e("div",null,[t[17]||(t[17]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Titel *",-1)),n(e("input",{"onUpdate:modelValue":t[2]||(t[2]=s=>a.value.title=s),type:"text",required:"",class:"input"},null,512),[[i,a.value.title]])]),e("div",null,[t[18]||(t[18]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Beschreibung",-1)),n(e("textarea",{"onUpdate:modelValue":t[3]||(t[3]=s=>a.value.description=s),rows:"3",class:"input"},null,512),[[i,a.value.description]])]),e("div",at,[e("div",null,[t[19]||(t[19]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Ort",-1)),n(e("input",{"onUpdate:modelValue":t[4]||(t[4]=s=>a.value.location=s),type:"text",class:"input"},null,512),[[i,a.value.location]])]),e("div",null,[t[20]||(t[20]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Benötigte MA",-1)),n(e("input",{"onUpdate:modelValue":t[5]||(t[5]=s=>a.value.required_staff=s),type:"number",min:"1",class:"input"},null,512),[[i,a.value.required_staff,void 0,{number:!0}]])])]),e("div",null,[t[21]||(t[21]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Adresse",-1)),n(e("input",{"onUpdate:modelValue":t[6]||(t[6]=s=>a.value.address=s),type:"text",class:"input"},null,512),[[i,a.value.address]])]),e("div",lt,[e("div",null,[t[22]||(t[22]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Kunde",-1)),n(e("input",{"onUpdate:modelValue":t[7]||(t[7]=s=>a.value.client_name=s),type:"text",class:"input"},null,512),[[i,a.value.client_name]])]),e("div",null,[t[23]||(t[23]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Ansprechpartner",-1)),n(e("input",{"onUpdate:modelValue":t[8]||(t[8]=s=>a.value.client_contact=s),type:"text",class:"input"},null,512),[[i,a.value.client_contact]])])]),e("div",nt,[e("div",null,[t[24]||(t[24]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Start",-1)),n(e("input",{"onUpdate:modelValue":t[9]||(t[9]=s=>a.value.start_time=s),type:"datetime-local",class:"input"},null,512),[[i,a.value.start_time]])]),e("div",null,[t[25]||(t[25]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Ende",-1)),n(e("input",{"onUpdate:modelValue":t[10]||(t[10]=s=>a.value.end_time=s),type:"datetime-local",class:"input"},null,512),[[i,a.value.end_time]])])]),e("div",null,[t[26]||(t[26]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Besondere Hinweise",-1)),n(e("textarea",{"onUpdate:modelValue":t[11]||(t[11]=s=>a.value.special_instructions=s),rows:"2",class:"input"},null,512),[[i,a.value.special_instructions]])]),e("div",it,[e("button",{type:"button",class:"btn btn-secondary",onClick:t[12]||(t[12]=s=>m.value=!1)}," Abbrechen "),t[27]||(t[27]=e("button",{type:"submit",class:"btn btn-primary"}," Erstellen ",-1))])],32)])])):g("",!0)])}}});export{dt as default}; +import{d as U,u as B,q as S,m as x,c as o,a as e,z as C,e as g,b as n,s as E,C as q,F as M,x as O,w as D,v as i,r as u,k as j,A as L,j as N,t as d,n as F,l as z,o as r}from"./index-CgM2qJ96.js";const $={class:"space-y-6"},I={class:"flex items-center justify-between"},K={class:"card"},T={class:"flex items-center gap-4"},H={class:"card"},G={key:0,class:"text-center py-8 text-gray-500"},J={key:1,class:"text-center py-8 text-gray-500"},P={key:2,class:"divide-y divide-gray-200 dark:divide-gray-700"},Q={class:"flex items-start justify-between"},R={class:"flex-1"},W={class:"flex items-center gap-3"},X={class:"text-sm text-gray-500 dark:text-gray-400"},Y={class:"font-medium text-gray-900 dark:text-white"},Z={class:"mt-1 flex items-center gap-4 text-sm text-gray-500 dark:text-gray-400"},h={key:0},tt={key:1},et={key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/50"},st={class:"card w-full max-w-2xl max-h-[90vh] overflow-y-auto m-4"},at={class:"grid grid-cols-2 gap-4"},lt={class:"grid grid-cols-2 gap-4"},nt={class:"grid grid-cols-2 gap-4"},it={class:"flex justify-end gap-3 pt-4"},dt=U({__name:"OrdersView",setup(rt){const f=B(),c=u([]),v=u(!0),m=u(!1),p=u(""),a=u({title:"",description:"",location:"",address:"",client_name:"",client_contact:"",start_time:"",end_time:"",required_staff:1,special_instructions:""}),b=j(()=>p.value?c.value.filter(l=>l.status===p.value):c.value);S(async()=>{await y()});async function y(){v.value=!0;try{const l=await x.get("/orders");c.value=l.data.orders}catch(l){console.error("Load orders error:",l)}finally{v.value=!1}}async function k(){try{await x.post("/orders",a.value),m.value=!1,a.value={title:"",description:"",location:"",address:"",client_name:"",client_contact:"",start_time:"",end_time:"",required_staff:1,special_instructions:""},await y()}catch(l){alert(l instanceof Error?l.message:"Fehler beim Erstellen")}}function _(l){return{draft:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",published:"badge-primary",in_progress:"badge-warning",completed:"badge-success",cancelled:"badge-danger"}[l]||"badge-secondary"}function w(l){return{draft:"Entwurf",published:"Veröffentlicht",in_progress:"In Bearbeitung",completed:"Abgeschlossen",cancelled:"Abgesagt"}[l]||l}function V(l){return l?new Date(l).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"-"}return(l,t)=>{const A=z("router-link");return r(),o("div",$,[e("div",I,[t[13]||(t[13]=e("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"}," 📋 Aufträge ",-1)),C(f).canManageOrders?(r(),o("button",{key:0,class:"btn btn-primary",onClick:t[0]||(t[0]=s=>m.value=!0)}," + Neuer Auftrag ")):g("",!0)]),e("div",K,[e("div",T,[t[15]||(t[15]=e("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"Status:",-1)),n(e("select",{"onUpdate:modelValue":t[1]||(t[1]=s=>p.value=s),class:"input w-48"},[...t[14]||(t[14]=[q('',6)])],512),[[E,p.value]])])]),e("div",H,[v.value?(r(),o("div",G," Lädt... ")):b.value.length===0?(r(),o("div",J," Keine Aufträge gefunden ")):(r(),o("div",P,[(r(!0),o(M,null,O(b.value,s=>(r(),L(A,{key:s.id,to:`/orders/${s.id}`,class:"block py-4 hover:bg-gray-50 dark:hover:bg-gray-700/50 -mx-6 px-6 transition-colors"},{default:N(()=>[e("div",Q,[e("div",R,[e("div",W,[e("span",X,"#"+d(s.number),1),e("h3",Y,d(s.title),1),e("span",{class:F(["badge",_(s.status)])},d(w(s.status)),3)]),e("div",Z,[s.location?(r(),o("span",h,"📍 "+d(s.location),1)):g("",!0),s.start_time?(r(),o("span",tt,"🕐 "+d(V(s.start_time)),1)):g("",!0),e("span",null,"👥 "+d(s.assigned_count||0)+"/"+d(s.required_staff),1)])]),t[16]||(t[16]=e("span",{class:"text-gray-400"},"→",-1))])]),_:2},1032,["to"]))),128))]))]),m.value?(r(),o("div",et,[e("div",st,[t[28]||(t[28]=e("h2",{class:"text-xl font-semibold text-gray-900 dark:text-white mb-6"}," Neuer Auftrag ",-1)),e("form",{onSubmit:D(k,["prevent"]),class:"space-y-4"},[e("div",null,[t[17]||(t[17]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Titel *",-1)),n(e("input",{"onUpdate:modelValue":t[2]||(t[2]=s=>a.value.title=s),type:"text",required:"",class:"input"},null,512),[[i,a.value.title]])]),e("div",null,[t[18]||(t[18]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Beschreibung",-1)),n(e("textarea",{"onUpdate:modelValue":t[3]||(t[3]=s=>a.value.description=s),rows:"3",class:"input"},null,512),[[i,a.value.description]])]),e("div",at,[e("div",null,[t[19]||(t[19]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Ort",-1)),n(e("input",{"onUpdate:modelValue":t[4]||(t[4]=s=>a.value.location=s),type:"text",class:"input"},null,512),[[i,a.value.location]])]),e("div",null,[t[20]||(t[20]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Benötigte MA",-1)),n(e("input",{"onUpdate:modelValue":t[5]||(t[5]=s=>a.value.required_staff=s),type:"number",min:"1",class:"input"},null,512),[[i,a.value.required_staff,void 0,{number:!0}]])])]),e("div",null,[t[21]||(t[21]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Adresse",-1)),n(e("input",{"onUpdate:modelValue":t[6]||(t[6]=s=>a.value.address=s),type:"text",class:"input"},null,512),[[i,a.value.address]])]),e("div",lt,[e("div",null,[t[22]||(t[22]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Kunde",-1)),n(e("input",{"onUpdate:modelValue":t[7]||(t[7]=s=>a.value.client_name=s),type:"text",class:"input"},null,512),[[i,a.value.client_name]])]),e("div",null,[t[23]||(t[23]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Ansprechpartner",-1)),n(e("input",{"onUpdate:modelValue":t[8]||(t[8]=s=>a.value.client_contact=s),type:"text",class:"input"},null,512),[[i,a.value.client_contact]])])]),e("div",nt,[e("div",null,[t[24]||(t[24]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Start",-1)),n(e("input",{"onUpdate:modelValue":t[9]||(t[9]=s=>a.value.start_time=s),type:"datetime-local",class:"input"},null,512),[[i,a.value.start_time]])]),e("div",null,[t[25]||(t[25]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Ende",-1)),n(e("input",{"onUpdate:modelValue":t[10]||(t[10]=s=>a.value.end_time=s),type:"datetime-local",class:"input"},null,512),[[i,a.value.end_time]])])]),e("div",null,[t[26]||(t[26]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},"Besondere Hinweise",-1)),n(e("textarea",{"onUpdate:modelValue":t[11]||(t[11]=s=>a.value.special_instructions=s),rows:"2",class:"input"},null,512),[[i,a.value.special_instructions]])]),e("div",it,[e("button",{type:"button",class:"btn btn-secondary",onClick:t[12]||(t[12]=s=>m.value=!1)}," Abbrechen "),t[27]||(t[27]=e("button",{type:"submit",class:"btn btn-primary"}," Erstellen ",-1))])],32)])])):g("",!0)])}}});export{dt as default}; diff --git a/dist/assets/PartnershipsView-BTiY9iQS.js b/dist/assets/PartnershipsView-CoZdHk1r.js similarity index 99% rename from dist/assets/PartnershipsView-BTiY9iQS.js rename to dist/assets/PartnershipsView-CoZdHk1r.js index df46761..48c1473 100644 --- a/dist/assets/PartnershipsView-BTiY9iQS.js +++ b/dist/assets/PartnershipsView-CoZdHk1r.js @@ -1 +1 @@ -import{d as ge,u as ve,q as ye,m as u,c as n,a as e,n as w,t as r,F as h,x as k,e as p,b as f,v as A,p as S,B as me,s as Y,r as c,o as l}from"./index-CWxNv9Fc.js";const be={class:"p-6"},he={class:"flex justify-between items-center mb-6"},fe={class:"flex space-x-1 border-b mb-6"},_e={key:0,class:"text-center py-12"},we={key:1},ke={class:"grid grid-cols-4 gap-4 mb-6"},Ce={class:"bg-white rounded-lg shadow p-4"},Ae={class:"text-2xl font-bold text-gray-900"},Se={class:"bg-white rounded-lg shadow p-4"},$e={class:"text-2xl font-bold text-green-600"},ze={class:"bg-white rounded-lg shadow p-4"},Fe={class:"text-2xl font-bold text-blue-600"},Be={class:"bg-white rounded-lg shadow p-4"},Ve={class:"text-2xl font-bold text-yellow-600"},Pe={key:0,class:"mb-6"},Ne={class:"space-y-2"},je={class:"font-medium"},Oe={class:"flex space-x-2"},Re=["onClick"],Me=["onClick"],Ue={class:"mb-6"},De={key:0,class:"bg-gray-50 rounded-lg p-8 text-center text-gray-500"},Ie={key:1,class:"bg-white rounded-lg shadow overflow-hidden"},qe={class:"min-w-full divide-y divide-gray-200"},Te={class:"divide-y divide-gray-200"},Ee={class:"px-4 py-3"},Le={class:"font-medium"},Ke={class:"text-gray-500 text-sm ml-2"},We={class:"px-4 py-3"},Ge={class:"px-4 py-3 text-sm"},Qe={key:0,class:"text-yellow-600 ml-1"},Ze={class:"px-4 py-3 text-right space-x-2"},He=["onClick"],Je=["onClick"],Xe={key:0,class:"bg-gray-50 rounded-lg p-8 text-center text-gray-500"},Ye={key:1,class:"bg-white rounded-lg shadow overflow-hidden"},et={class:"min-w-full divide-y divide-gray-200"},tt={class:"divide-y divide-gray-200"},st={class:"px-4 py-3"},at={class:"font-medium"},nt={class:"px-4 py-3"},lt={class:"px-4 py-3 text-sm"},rt={key:0,class:"text-yellow-600 ml-1"},ot={class:"px-4 py-3 text-right"},dt=["onClick"],it={key:2},ut={class:"grid grid-cols-2 gap-6"},ct={key:0,class:"bg-gray-50 rounded-lg p-6 text-center text-gray-500"},pt={key:1,class:"space-y-2"},xt={class:"flex justify-between items-start"},gt={class:"font-medium"},vt={class:"text-sm text-gray-500"},yt={class:"text-sm text-gray-500"},mt={class:"text-sm mt-1"},bt={class:"font-medium"},ht={class:"text-right"},ft={key:0,class:"text-sm text-gray-500 mt-1"},_t={key:0,class:"mt-2 pt-2 border-t"},wt=["onClick"],kt={key:0,class:"bg-gray-50 rounded-lg p-6 text-center text-gray-500"},Ct={key:1,class:"space-y-2"},At={class:"flex justify-between items-start"},St={class:"font-medium"},$t={class:"text-sm text-gray-500"},zt={class:"text-sm text-gray-500"},Ft={class:"text-sm mt-1"},Bt={class:"font-medium"},Vt={class:"text-right"},Pt={key:0,class:"mt-2 pt-2 border-t flex space-x-2"},Nt=["onClick"],jt=["onClick"],Ot={key:3},Rt={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},Mt={key:1,class:"bg-white rounded-lg shadow overflow-hidden"},Ut={class:"min-w-full divide-y divide-gray-200"},Dt={class:"divide-y divide-gray-200"},It={class:"px-4 py-3"},qt={class:"px-4 py-3"},Tt={class:"px-4 py-3"},Et={class:"px-4 py-3"},Lt={class:"px-4 py-3"},Kt={class:"px-4 py-3"},Wt={class:"px-4 py-3 text-right space-x-2"},Gt=["onClick"],Qt=["onClick"],Zt={key:4},Ht={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},Jt={key:1,class:"bg-white rounded-lg shadow overflow-hidden"},Xt={class:"min-w-full divide-y divide-gray-200"},Yt={class:"divide-y divide-gray-200"},es={class:"px-4 py-3 font-mono"},ts={class:"px-4 py-3"},ss={class:"px-4 py-3"},as={class:"px-4 py-3"},ns={key:0,class:"text-red-600"},ls={key:1,class:"text-green-600"},rs={class:"px-4 py-3 text-right font-medium"},os={class:"px-4 py-3"},ds={class:"px-4 py-3 text-right"},is=["onClick"],us={key:5,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},cs={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},ps={class:"space-y-4"},xs={key:0,class:"mt-1 border rounded-lg shadow-sm max-h-40 overflow-y-auto"},gs=["onClick"],vs={class:"text-gray-500"},ys={class:"flex justify-end space-x-2 mt-6"},ms=["disabled"],bs={key:6,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},hs={class:"bg-white rounded-lg shadow-xl w-full max-w-2xl p-6 max-h-[90vh] overflow-y-auto"},fs={class:"flex justify-between items-start mb-4"},_s={class:"text-xl font-bold"},ws={class:"grid grid-cols-2 gap-4 mb-6 text-sm"},ks={key:0},Cs={key:0,class:"mb-6"},As={key:0,class:"text-gray-500 text-sm"},Ss={key:1,class:"space-y-2"},$s={class:"font-medium"},zs={key:0,class:"text-xs text-blue-600 ml-2"},Fs={class:"flex items-center space-x-4"},Bs={class:"font-mono"},Vs=["onClick"],Ps={key:1,class:"grid grid-cols-3 gap-4 mb-6"},Ns={class:"bg-gray-50 rounded p-3 text-center"},js={class:"text-xl font-bold"},Os={class:"bg-gray-50 rounded p-3 text-center"},Rs={class:"text-xl font-bold"},Ms={class:"bg-gray-50 rounded p-3 text-center"},Us={class:"text-xl font-bold"},Ds={key:2,class:"flex space-x-2"},Is={key:3,class:"flex space-x-2"},qs={key:7,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},Ts={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},Es={class:"space-y-4"},Ls={class:"flex items-center"},Ks={class:"flex justify-end space-x-2 mt-6"},Ws={key:8,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},Gs={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},Qs={class:"text-xl font-bold mb-4"},Zs={class:"space-y-4"},Hs=["value"],Js=["value"],Xs={class:"flex justify-end space-x-2 mt-6"},Ys=["disabled"],sa=ge({__name:"PartnershipsView",setup(ea){ve();const D=c(!0),I=c([]),F=c([]),B=c({}),m=c("overview"),j=c(!1),q=c(!1),O=c(!1),R=c(!1),T=c(null),i=c(null),$=c(""),z=c([]),G=c(!1),g=c({subcontractor_slug:"",notes:"",contract_start:"",contract_end:""}),M=c(!1),y=c({name:"",description:"",rate_type:"hourly",amount:0,is_default:!1}),V=c({asContractor:[],asSubcontractor:[]}),E=c([]),L=c([]),Q=c([]),x=c({partnership_id:"",order_id:"",rate_id:"",required_staff:1,notes:""});ye(async()=>{await P()});async function P(){D.value=!0;try{const a=await u.get("/partnerships");I.value=a.data.asContractor||[],F.value=a.data.asSubcontractor||[],B.value=a.data.stats||{}}catch(a){console.error("Load partnerships failed:",a)}D.value=!1}async function ee(){if($.value.length<2){z.value=[];return}G.value=!0;try{const a=await u.get(`/partnerships/search/orgs?q=${encodeURIComponent($.value)}`);z.value=a.data}catch(a){console.error("Search failed:",a)}G.value=!1}function te(a){g.value.subcontractor_slug=a.slug,$.value=a.name,z.value=[]}async function se(){var a,t;if(g.value.subcontractor_slug){M.value=!0;try{await u.post("/partnerships",{subcontractor_slug:g.value.subcontractor_slug,notes:g.value.notes||void 0,contract_start:g.value.contract_start||void 0,contract_end:g.value.contract_end||void 0}),j.value=!1,Z(),await P()}catch(o){alert("Fehler: "+(((t=(a=o.response)==null?void 0:a.data)==null?void 0:t.error)||o.message))}M.value=!1}}function Z(){g.value={subcontractor_slug:"",notes:"",contract_start:"",contract_end:""},$.value="",z.value=[]}async function ae(a){var t,o;try{await u.post(`/partnerships/${a.id}/accept`),await P()}catch(d){alert("Fehler: "+(((o=(t=d.response)==null?void 0:t.data)==null?void 0:o.error)||d.message))}}async function ne(a){var t,o;if(confirm("Einladung wirklich ablehnen?"))try{await u.post(`/partnerships/${a.id}/decline`),await P()}catch(d){alert("Fehler: "+(((o=(t=d.response)==null?void 0:t.data)==null?void 0:o.error)||d.message))}}async function K(a,t){var o,d,_;if(confirm(`Status auf "${t}" ändern?`))try{await u.put(`/partnerships/${a.id}/status`,{status:t}),await P(),((o=i.value)==null?void 0:o.id)===a.id&&(i.value.status=t)}catch(s){alert("Fehler: "+(((_=(d=s.response)==null?void 0:d.data)==null?void 0:_.error)||s.message))}}async function H(a){var t,o;T.value=a;try{const d=await u.get(`/partnerships/${a.id}`);i.value=d.data,q.value=!0}catch(d){alert("Fehler: "+(((o=(t=d.response)==null?void 0:t.data)==null?void 0:o.error)||d.message))}}function le(){y.value={name:"",description:"",rate_type:"hourly",amount:0,is_default:!1},O.value=!0}async function re(){var a,t;if(!y.value.name||!y.value.amount){alert("Name und Betrag erforderlich");return}try{await u.post(`/partnerships/${i.value.id}/rates`,{...y.value,amount_cents:Math.round(y.value.amount*100)});const o=await u.get(`/partnerships/${i.value.id}`);i.value=o.data,O.value=!1}catch(o){alert("Fehler: "+(((t=(a=o.response)==null?void 0:a.data)==null?void 0:t.error)||o.message))}}async function oe(a){var t,o;if(confirm(`Satz "${a.name}" löschen?`))try{await u.delete(`/partnerships/${i.value.id}/rates/${a.id}`);const d=await u.get(`/partnerships/${i.value.id}`);i.value=d.data}catch(d){alert("Fehler: "+(((o=(t=d.response)==null?void 0:t.data)==null?void 0:o.error)||d.message))}}async function U(){m.value="orders";try{const a=await u.get("/partnerships/orders/list");V.value=a.data}catch(a){console.error("Load shared orders failed:",a)}}async function de(a){T.value=a,x.value={partnership_id:a.id,order_id:"",rate_id:"",required_staff:1,notes:""};try{const t=await u.get("/orders");Q.value=t.data.orders||t.data||[];const o=await u.get(`/partnerships/${a.id}/rates`);i.value={...a,rates:o.data},R.value=!0}catch(t){console.error("Load orders failed:",t)}}async function ie(){var a,t;if(!x.value.order_id){alert("Bitte Auftrag auswählen");return}try{await u.post("/partnerships/orders",{partnership_id:x.value.partnership_id,order_id:x.value.order_id,rate_id:x.value.rate_id||void 0,required_staff:x.value.required_staff,notes:x.value.notes||void 0}),R.value=!1,await U()}catch(o){alert("Fehler: "+(((t=(a=o.response)==null?void 0:a.data)==null?void 0:t.error)||o.message))}}async function J(a,t){var o,d;try{await u.post(`/partnerships/orders/${a.id}/respond`,{accept:t,notes:""}),await U()}catch(_){alert("Fehler: "+(((d=(o=_.response)==null?void 0:o.data)==null?void 0:d.error)||_.message))}}async function ue(a){var t,o;if(confirm("Auftrag abschließen?"))try{await u.post(`/partnerships/orders/${a.id}/complete`),await U()}catch(d){alert("Fehler: "+(((o=(t=d.response)==null?void 0:t.data)==null?void 0:o.error)||d.message))}}async function W(){m.value="timesheets";try{const a=await u.get("/partnerships/timesheets/list");E.value=a.data}catch(a){console.error("Load timesheets failed:",a)}}async function ce(a){var t,o;try{await u.post(`/partnerships/timesheets/${a.id}/approve`),await W()}catch(d){alert("Fehler: "+(((o=(t=d.response)==null?void 0:t.data)==null?void 0:o.error)||d.message))}}async function pe(a){var o,d;const t=prompt("Grund für Beanstandung:");if(t)try{await u.post(`/partnerships/timesheets/${a.id}/dispute`,{reason:t}),await W()}catch(_){alert("Fehler: "+(((d=(o=_.response)==null?void 0:o.data)==null?void 0:d.error)||_.message))}}async function X(){m.value="invoices";try{const a=await u.get("/partnerships/invoices/list");L.value=a.data}catch(a){console.error("Load invoices failed:",a)}}async function xe(a){var t,o;if(confirm("Rechnung als bezahlt markieren?"))try{await u.put(`/partnerships/invoices/${a.id}/pay`),await X()}catch(d){alert("Fehler: "+(((o=(t=d.response)==null?void 0:t.data)==null?void 0:o.error)||d.message))}}function N(a){return(a/100).toFixed(2).replace(".",",")+" €"}function C(a){return a?new Date(a).toLocaleDateString("de-DE"):"-"}function v(a){return{pending:{text:"Ausstehend",class:"bg-yellow-100 text-yellow-800"},active:{text:"Aktiv",class:"bg-green-100 text-green-800"},paused:{text:"Pausiert",class:"bg-gray-100 text-gray-800"},terminated:{text:"Beendet",class:"bg-red-100 text-red-800"},requested:{text:"Angefragt",class:"bg-blue-100 text-blue-800"},accepted:{text:"Angenommen",class:"bg-green-100 text-green-800"},declined:{text:"Abgelehnt",class:"bg-red-100 text-red-800"},completed:{text:"Abgeschlossen",class:"bg-gray-100 text-gray-800"},approved:{text:"Freigegeben",class:"bg-green-100 text-green-800"},disputed:{text:"Beanstandet",class:"bg-red-100 text-red-800"},draft:{text:"Entwurf",class:"bg-gray-100 text-gray-800"},sent:{text:"Gesendet",class:"bg-blue-100 text-blue-800"},paid:{text:"Bezahlt",class:"bg-green-100 text-green-800"}}[a]||{text:a,class:"bg-gray-100 text-gray-800"}}return(a,t)=>{var o,d,_;return l(),n("div",be,[e("div",he,[t[24]||(t[24]=e("div",null,[e("h1",{class:"text-2xl font-bold text-gray-900"},"🤝 Subunternehmer"),e("p",{class:"text-gray-500"},"Partnerschaften mit anderen Sicherheitsunternehmen")],-1)),e("button",{onClick:t[0]||(t[0]=s=>j.value=!0),class:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700"}," + Partner einladen ")]),e("div",fe,[e("button",{onClick:t[1]||(t[1]=s=>m.value="overview"),class:w(["px-4 py-2 font-medium border-b-2 -mb-px",m.value==="overview"?"border-blue-600 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"])}," Übersicht ",2),e("button",{onClick:t[2]||(t[2]=s=>U()),class:w(["px-4 py-2 font-medium border-b-2 -mb-px",m.value==="orders"?"border-blue-600 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"])}," Geteilte Aufträge ",2),e("button",{onClick:t[3]||(t[3]=s=>W()),class:w(["px-4 py-2 font-medium border-b-2 -mb-px",m.value==="timesheets"?"border-blue-600 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"])}," Stundenzettel ",2),e("button",{onClick:t[4]||(t[4]=s=>X()),class:w(["px-4 py-2 font-medium border-b-2 -mb-px",m.value==="invoices"?"border-blue-600 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"])}," Rechnungen ",2)]),D.value?(l(),n("div",_e,[...t[25]||(t[25]=[e("div",{class:"animate-spin w-8 h-8 border-4 border-blue-600 border-t-transparent rounded-full mx-auto"},null,-1)])])):m.value==="overview"?(l(),n("div",we,[e("div",ke,[e("div",Ce,[e("div",Ae,r(B.value.totalPartnerships||0),1),t[26]||(t[26]=e("div",{class:"text-sm text-gray-500"},"Partnerschaften",-1))]),e("div",Se,[e("div",$e,r(B.value.activeAsContractor||0),1),t[27]||(t[27]=e("div",{class:"text-sm text-gray-500"},"Als Auftraggeber",-1))]),e("div",ze,[e("div",Fe,r(B.value.activeAsSubcontractor||0),1),t[28]||(t[28]=e("div",{class:"text-sm text-gray-500"},"Als Subunternehmer",-1))]),e("div",Be,[e("div",Ve,r(B.value.pendingInvitations||0),1),t[29]||(t[29]=e("div",{class:"text-sm text-gray-500"},"Offene Einladungen",-1))])]),F.value.filter(s=>s.status==="pending").length>0?(l(),n("div",Pe,[t[31]||(t[31]=e("h2",{class:"text-lg font-semibold mb-3"},"📩 Offene Einladungen",-1)),e("div",Ne,[(l(!0),n(h,null,k(F.value.filter(s=>s.status==="pending"),s=>(l(),n("div",{key:s.id,class:"bg-yellow-50 border border-yellow-200 rounded-lg p-4 flex justify-between items-center"},[e("div",null,[e("span",je,r(s.partner_name),1),t[30]||(t[30]=S(" möchte mit Ihnen zusammenarbeiten ",-1))]),e("div",Oe,[e("button",{onClick:b=>ae(s),class:"px-3 py-1 bg-green-600 text-white rounded hover:bg-green-700"}," Annehmen ",8,Re),e("button",{onClick:b=>ne(s),class:"px-3 py-1 bg-red-100 text-red-700 rounded hover:bg-red-200"}," Ablehnen ",8,Me)])]))),128))])])):p("",!0),e("div",Ue,[t[33]||(t[33]=e("h2",{class:"text-lg font-semibold mb-3"},"🏢 Wir als Auftraggeber",-1)),I.value.length===0?(l(),n("div",De," Noch keine Subunternehmer eingeladen ")):(l(),n("div",Ie,[e("table",qe,[t[32]||(t[32]=e("thead",{class:"bg-gray-50"},[e("tr",null,[e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Subunternehmer"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Status"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Aufträge"),e("th",{class:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase"},"Aktionen")])],-1)),e("tbody",Te,[(l(!0),n(h,null,k(I.value,s=>(l(),n("tr",{key:s.id,class:"hover:bg-gray-50"},[e("td",Ee,[e("span",Le,r(s.partner_name),1),e("span",Ke,"@"+r(s.partner_slug),1)]),e("td",We,[e("span",{class:w(["px-2 py-1 text-xs rounded-full",v(s.status).class])},r(v(s.status).text),3)]),e("td",Ge,[S(r(s.shared_orders_count||0)+" geteilt ",1),s.pending_orders>0?(l(),n("span",Qe," ("+r(s.pending_orders)+" offen) ",1)):p("",!0)]),e("td",Ze,[e("button",{onClick:b=>H(s),class:"text-blue-600 hover:text-blue-800"}," Details ",8,He),s.status==="active"?(l(),n("button",{key:0,onClick:b=>de(s),class:"text-green-600 hover:text-green-800"}," Auftrag teilen ",8,Je)):p("",!0)])]))),128))])])]))]),e("div",null,[t[35]||(t[35]=e("h2",{class:"text-lg font-semibold mb-3"},"👷 Wir als Subunternehmer",-1)),F.value.filter(s=>s.status!=="pending").length===0?(l(),n("div",Xe," Keine aktiven Partnerschaften als Subunternehmer ")):(l(),n("div",Ye,[e("table",et,[t[34]||(t[34]=e("thead",{class:"bg-gray-50"},[e("tr",null,[e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Auftraggeber"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Status"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Aufträge"),e("th",{class:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase"},"Aktionen")])],-1)),e("tbody",tt,[(l(!0),n(h,null,k(F.value.filter(s=>s.status!=="pending"),s=>(l(),n("tr",{key:s.id,class:"hover:bg-gray-50"},[e("td",st,[e("span",at,r(s.partner_name),1)]),e("td",nt,[e("span",{class:w(["px-2 py-1 text-xs rounded-full",v(s.status).class])},r(v(s.status).text),3)]),e("td",lt,[S(r(s.shared_orders_count||0)+" erhalten ",1),s.pending_orders>0?(l(),n("span",rt," ("+r(s.pending_orders)+" offen) ",1)):p("",!0)]),e("td",ot,[e("button",{onClick:b=>H(s),class:"text-blue-600 hover:text-blue-800"}," Details ",8,dt)])]))),128))])])]))])])):m.value==="orders"?(l(),n("div",it,[e("div",ut,[e("div",null,[t[37]||(t[37]=e("h2",{class:"text-lg font-semibold mb-3"},"📤 Von uns geteilt",-1)),V.value.asContractor.length===0?(l(),n("div",ct," Keine geteilten Aufträge ")):(l(),n("div",pt,[(l(!0),n(h,null,k(V.value.asContractor,s=>(l(),n("div",{key:s.id,class:"bg-white rounded-lg shadow p-4"},[e("div",xt,[e("div",null,[e("div",gt,r(s.order_title),1),e("div",vt,r(s.location),1),e("div",yt,r(C(s.start_date))+" - "+r(C(s.end_date)),1),e("div",mt,[t[36]||(t[36]=S(" → ",-1)),e("span",bt,r(s.subcontractor_name),1)])]),e("div",ht,[e("span",{class:w(["px-2 py-1 text-xs rounded-full",v(s.status).class])},r(v(s.status).text),3),s.rate_name?(l(),n("div",ft,r(s.rate_name)+": "+r(N(s.rate_amount))+"/h ",1)):p("",!0)])]),s.status==="accepted"?(l(),n("div",_t,[e("button",{onClick:b=>ue(s),class:"text-sm text-green-600 hover:text-green-800"}," ✓ Abschließen ",8,wt)])):p("",!0)]))),128))]))]),e("div",null,[t[39]||(t[39]=e("h2",{class:"text-lg font-semibold mb-3"},"📥 An uns übertragen",-1)),V.value.asSubcontractor.length===0?(l(),n("div",kt," Keine erhaltenen Aufträge ")):(l(),n("div",Ct,[(l(!0),n(h,null,k(V.value.asSubcontractor,s=>(l(),n("div",{key:s.id,class:"bg-white rounded-lg shadow p-4"},[e("div",At,[e("div",null,[e("div",St,r(s.order_title),1),e("div",$t,r(s.location),1),e("div",zt,r(C(s.start_date))+" - "+r(C(s.end_date)),1),e("div",Ft,[t[38]||(t[38]=S(" ← ",-1)),e("span",Bt,r(s.contractor_name),1)])]),e("div",Vt,[e("span",{class:w(["px-2 py-1 text-xs rounded-full",v(s.status).class])},r(v(s.status).text),3)])]),s.status==="requested"?(l(),n("div",Pt,[e("button",{onClick:b=>J(s,!0),class:"text-sm px-3 py-1 bg-green-600 text-white rounded hover:bg-green-700"}," Annehmen ",8,Nt),e("button",{onClick:b=>J(s,!1),class:"text-sm px-3 py-1 bg-red-100 text-red-700 rounded hover:bg-red-200"}," Ablehnen ",8,jt)])):p("",!0)]))),128))]))])])])):m.value==="timesheets"?(l(),n("div",Ot,[E.value.length===0?(l(),n("div",Rt," Keine Partnership-Stundenzettel vorhanden ")):(l(),n("div",Mt,[e("table",Ut,[t[40]||(t[40]=e("thead",{class:"bg-gray-50"},[e("tr",null,[e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Datum"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Mitarbeiter"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Auftrag"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Stunden"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Betrag"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Status"),e("th",{class:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase"},"Aktionen")])],-1)),e("tbody",Dt,[(l(!0),n(h,null,k(E.value,s=>(l(),n("tr",{key:s.id,class:"hover:bg-gray-50"},[e("td",It,r(C(s.date)),1),e("td",qt,r(s.first_name)+" "+r(s.last_name),1),e("td",Tt,r(s.order_title),1),e("td",Et,r(s.hours_worked)+"h",1),e("td",Lt,r(s.calculated_amount_cents?N(s.calculated_amount_cents):"-"),1),e("td",Kt,[e("span",{class:w(["px-2 py-1 text-xs rounded-full",v(s.approval_status).class])},r(v(s.approval_status).text),3)]),e("td",Wt,[s.approval_status==="pending"?(l(),n(h,{key:0},[e("button",{onClick:b=>ce(s),class:"text-green-600 hover:text-green-800"}," ✓ Freigeben ",8,Gt),e("button",{onClick:b=>pe(s),class:"text-red-600 hover:text-red-800"}," ✗ Beanstanden ",8,Qt)],64)):p("",!0)])]))),128))])])]))])):m.value==="invoices"?(l(),n("div",Zt,[L.value.length===0?(l(),n("div",Ht," Keine Rechnungen vorhanden ")):(l(),n("div",Jt,[e("table",Xt,[t[41]||(t[41]=e("thead",{class:"bg-gray-50"},[e("tr",null,[e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Nr."),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Partner"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Zeitraum"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Richtung"),e("th",{class:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase"},"Betrag"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Status"),e("th",{class:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase"},"Aktionen")])],-1)),e("tbody",Yt,[(l(!0),n(h,null,k(L.value,s=>(l(),n("tr",{key:s.id,class:"hover:bg-gray-50"},[e("td",es,r(s.invoice_number),1),e("td",ts,r(s.partner_name),1),e("td",ss,r(C(s.period_start))+" - "+r(C(s.period_end)),1),e("td",as,[s.direction==="outgoing"?(l(),n("span",ns,"📤 Ausgehend")):(l(),n("span",ls,"📥 Eingehend"))]),e("td",rs,r(N(s.total_cents)),1),e("td",os,[e("span",{class:w(["px-2 py-1 text-xs rounded-full",v(s.status).class])},r(v(s.status).text),3)]),e("td",ds,[s.direction==="incoming"&&s.status==="sent"?(l(),n("button",{key:0,onClick:b=>xe(s),class:"text-green-600 hover:text-green-800"}," Als bezahlt markieren ",8,is)):p("",!0)])]))),128))])])]))])):p("",!0),j.value?(l(),n("div",us,[e("div",cs,[t[46]||(t[46]=e("h2",{class:"text-xl font-bold mb-4"},"Partner einladen",-1)),e("div",ps,[e("div",null,[t[42]||(t[42]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Organisation suchen",-1)),f(e("input",{"onUpdate:modelValue":t[5]||(t[5]=s=>$.value=s),onInput:ee,type:"text",placeholder:"Name oder Slug eingeben...",class:"w-full border rounded-lg px-3 py-2"},null,544),[[A,$.value]]),z.value.length>0?(l(),n("div",xs,[(l(!0),n(h,null,k(z.value,s=>(l(),n("button",{key:s.id,onClick:b=>te(s),class:"w-full px-3 py-2 text-left hover:bg-gray-100"},[S(r(s.name)+" ",1),e("span",vs,"@"+r(s.slug),1)],8,gs))),128))])):p("",!0)]),e("div",null,[t[43]||(t[43]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Vertragsbeginn",-1)),f(e("input",{"onUpdate:modelValue":t[6]||(t[6]=s=>g.value.contract_start=s),type:"date",class:"w-full border rounded-lg px-3 py-2"},null,512),[[A,g.value.contract_start]])]),e("div",null,[t[44]||(t[44]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Vertragsende (optional)",-1)),f(e("input",{"onUpdate:modelValue":t[7]||(t[7]=s=>g.value.contract_end=s),type:"date",class:"w-full border rounded-lg px-3 py-2"},null,512),[[A,g.value.contract_end]])]),e("div",null,[t[45]||(t[45]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Notizen",-1)),f(e("textarea",{"onUpdate:modelValue":t[8]||(t[8]=s=>g.value.notes=s),rows:"3",class:"w-full border rounded-lg px-3 py-2",placeholder:"Optionale Nachricht..."},null,512),[[A,g.value.notes]])])]),e("div",ys,[e("button",{onClick:t[9]||(t[9]=s=>{j.value=!1,Z()}),class:"px-4 py-2 text-gray-700 hover:bg-gray-100 rounded-lg"}," Abbrechen "),e("button",{onClick:se,disabled:M.value||!g.value.subcontractor_slug,class:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},r(M.value?"Wird gesendet...":"Einladung senden"),9,ms)])])])):p("",!0),q.value&&i.value?(l(),n("div",bs,[e("div",hs,[e("div",fs,[e("div",null,[e("h2",_s," Partnerschaft mit "+r(i.value.isContractor?i.value.subcontractor_name:i.value.contractor_name),1),e("span",{class:w(["px-2 py-1 text-xs rounded-full",v(i.value.status).class])},r(v(i.value.status).text),3)]),e("button",{onClick:t[10]||(t[10]=s=>q.value=!1),class:"text-gray-500 hover:text-gray-700"},"✕")]),e("div",ws,[e("div",null,[t[47]||(t[47]=e("span",{class:"text-gray-500"},"Rolle:",-1)),S(" "+r(i.value.isContractor?"Wir sind Auftraggeber":"Wir sind Subunternehmer"),1)]),e("div",null,[t[48]||(t[48]=e("span",{class:"text-gray-500"},"Seit:",-1)),S(" "+r(C(i.value.contract_start||i.value.created_at)),1)]),i.value.contract_end?(l(),n("div",ks,[t[49]||(t[49]=e("span",{class:"text-gray-500"},"Bis:",-1)),S(" "+r(C(i.value.contract_end)),1)])):p("",!0)]),i.value.isContractor?(l(),n("div",Cs,[e("div",{class:"flex justify-between items-center mb-2"},[t[50]||(t[50]=e("h3",{class:"font-semibold"},"Stundensätze",-1)),e("button",{onClick:le,class:"text-sm text-blue-600 hover:text-blue-800"}," + Neuer Satz ")]),(o=i.value.rates)!=null&&o.length?(l(),n("div",Ss,[(l(!0),n(h,null,k(i.value.rates,s=>(l(),n("div",{key:s.id,class:"flex justify-between items-center bg-gray-50 rounded px-3 py-2"},[e("div",null,[e("span",$s,r(s.name),1),s.is_default?(l(),n("span",zs,"Standard")):p("",!0)]),e("div",Fs,[e("span",Bs,r(N(s.amount_cents))+"/h",1),e("button",{onClick:b=>oe(s),class:"text-red-500 hover:text-red-700"}," 🗑 ",8,Vs)])]))),128))])):(l(),n("div",As," Noch keine Sätze definiert "))])):p("",!0),i.value.stats?(l(),n("div",Ps,[e("div",Ns,[e("div",js,r(i.value.stats.completed_orders||0),1),t[51]||(t[51]=e("div",{class:"text-xs text-gray-500"},"Abgeschlossen",-1))]),e("div",Os,[e("div",Rs,r(i.value.stats.active_orders||0),1),t[52]||(t[52]=e("div",{class:"text-xs text-gray-500"},"Aktiv",-1))]),e("div",Ms,[e("div",Us,r(i.value.stats.pending_orders||0),1),t[53]||(t[53]=e("div",{class:"text-xs text-gray-500"},"Ausstehend",-1))])])):p("",!0),i.value.status==="active"?(l(),n("div",Ds,[e("button",{onClick:t[11]||(t[11]=s=>K(i.value,"paused")),class:"px-4 py-2 bg-yellow-100 text-yellow-700 rounded hover:bg-yellow-200"}," Pausieren "),e("button",{onClick:t[12]||(t[12]=s=>K(i.value,"terminated")),class:"px-4 py-2 bg-red-100 text-red-700 rounded hover:bg-red-200"}," Beenden ")])):i.value.status==="paused"?(l(),n("div",Is,[e("button",{onClick:t[13]||(t[13]=s=>K(i.value,"active")),class:"px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700"}," Reaktivieren ")])):p("",!0)])])):p("",!0),O.value?(l(),n("div",qs,[e("div",Ts,[t[58]||(t[58]=e("h2",{class:"text-xl font-bold mb-4"},"Neuer Stundensatz",-1)),e("div",Es,[e("div",null,[t[54]||(t[54]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Bezeichnung *",-1)),f(e("input",{"onUpdate:modelValue":t[14]||(t[14]=s=>y.value.name=s),type:"text",placeholder:"z.B. Normaldienst, Nachtschicht...",class:"w-full border rounded-lg px-3 py-2"},null,512),[[A,y.value.name]])]),e("div",null,[t[55]||(t[55]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Beschreibung",-1)),f(e("input",{"onUpdate:modelValue":t[15]||(t[15]=s=>y.value.description=s),type:"text",class:"w-full border rounded-lg px-3 py-2"},null,512),[[A,y.value.description]])]),e("div",null,[t[56]||(t[56]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Stundensatz (€) *",-1)),f(e("input",{"onUpdate:modelValue":t[16]||(t[16]=s=>y.value.amount=s),type:"number",step:"0.01",min:"0",class:"w-full border rounded-lg px-3 py-2"},null,512),[[A,y.value.amount,void 0,{number:!0}]])]),e("label",Ls,[f(e("input",{"onUpdate:modelValue":t[17]||(t[17]=s=>y.value.is_default=s),type:"checkbox",class:"mr-2"},null,512),[[me,y.value.is_default]]),t[57]||(t[57]=e("span",{class:"text-sm"},"Als Standard-Satz verwenden",-1))])]),e("div",Ks,[e("button",{onClick:t[18]||(t[18]=s=>O.value=!1),class:"px-4 py-2 text-gray-700 hover:bg-gray-100 rounded-lg"}," Abbrechen "),e("button",{onClick:re,class:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700"}," Speichern ")])])])):p("",!0),R.value?(l(),n("div",Ws,[e("div",Gs,[e("h2",Qs,"Auftrag teilen mit "+r((d=T.value)==null?void 0:d.partner_name),1),e("div",Zs,[e("div",null,[t[60]||(t[60]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Auftrag auswählen *",-1)),f(e("select",{"onUpdate:modelValue":t[19]||(t[19]=s=>x.value.order_id=s),class:"w-full border rounded-lg px-3 py-2"},[t[59]||(t[59]=e("option",{value:""},"Bitte wählen...",-1)),(l(!0),n(h,null,k(Q.value,s=>(l(),n("option",{key:s.id,value:s.id},r(s.title)+" ("+r(C(s.start_date))+") ",9,Hs))),128))],512),[[Y,x.value.order_id]])]),e("div",null,[t[62]||(t[62]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Stundensatz",-1)),f(e("select",{"onUpdate:modelValue":t[20]||(t[20]=s=>x.value.rate_id=s),class:"w-full border rounded-lg px-3 py-2"},[t[61]||(t[61]=e("option",{value:""},"Keiner / Später festlegen",-1)),(l(!0),n(h,null,k((_=i.value)==null?void 0:_.rates,s=>(l(),n("option",{key:s.id,value:s.id},r(s.name)+" ("+r(N(s.amount_cents))+"/h) ",9,Js))),128))],512),[[Y,x.value.rate_id]])]),e("div",null,[t[63]||(t[63]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Benötigte Mitarbeiter",-1)),f(e("input",{"onUpdate:modelValue":t[21]||(t[21]=s=>x.value.required_staff=s),type:"number",min:"1",class:"w-full border rounded-lg px-3 py-2"},null,512),[[A,x.value.required_staff,void 0,{number:!0}]])]),e("div",null,[t[64]||(t[64]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Notizen",-1)),f(e("textarea",{"onUpdate:modelValue":t[22]||(t[22]=s=>x.value.notes=s),rows:"2",class:"w-full border rounded-lg px-3 py-2"},null,512),[[A,x.value.notes]])])]),e("div",Xs,[e("button",{onClick:t[23]||(t[23]=s=>R.value=!1),class:"px-4 py-2 text-gray-700 hover:bg-gray-100 rounded-lg"}," Abbrechen "),e("button",{onClick:ie,disabled:!x.value.order_id,class:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"}," Auftrag teilen ",8,Ys)])])])):p("",!0)])}}});export{sa as default}; +import{d as ge,u as ve,q as ye,m as u,c as n,a as e,n as w,t as r,F as h,x as k,e as p,b as f,v as A,p as S,D as me,s as Y,r as c,o as l}from"./index-CgM2qJ96.js";const be={class:"p-6"},he={class:"flex justify-between items-center mb-6"},fe={class:"flex space-x-1 border-b mb-6"},_e={key:0,class:"text-center py-12"},we={key:1},ke={class:"grid grid-cols-4 gap-4 mb-6"},Ce={class:"bg-white rounded-lg shadow p-4"},Ae={class:"text-2xl font-bold text-gray-900"},Se={class:"bg-white rounded-lg shadow p-4"},$e={class:"text-2xl font-bold text-green-600"},ze={class:"bg-white rounded-lg shadow p-4"},Fe={class:"text-2xl font-bold text-blue-600"},Be={class:"bg-white rounded-lg shadow p-4"},Ve={class:"text-2xl font-bold text-yellow-600"},Pe={key:0,class:"mb-6"},Ne={class:"space-y-2"},je={class:"font-medium"},Oe={class:"flex space-x-2"},Re=["onClick"],Me=["onClick"],Ue={class:"mb-6"},De={key:0,class:"bg-gray-50 rounded-lg p-8 text-center text-gray-500"},Ie={key:1,class:"bg-white rounded-lg shadow overflow-hidden"},qe={class:"min-w-full divide-y divide-gray-200"},Te={class:"divide-y divide-gray-200"},Ee={class:"px-4 py-3"},Le={class:"font-medium"},Ke={class:"text-gray-500 text-sm ml-2"},We={class:"px-4 py-3"},Ge={class:"px-4 py-3 text-sm"},Qe={key:0,class:"text-yellow-600 ml-1"},Ze={class:"px-4 py-3 text-right space-x-2"},He=["onClick"],Je=["onClick"],Xe={key:0,class:"bg-gray-50 rounded-lg p-8 text-center text-gray-500"},Ye={key:1,class:"bg-white rounded-lg shadow overflow-hidden"},et={class:"min-w-full divide-y divide-gray-200"},tt={class:"divide-y divide-gray-200"},st={class:"px-4 py-3"},at={class:"font-medium"},nt={class:"px-4 py-3"},lt={class:"px-4 py-3 text-sm"},rt={key:0,class:"text-yellow-600 ml-1"},ot={class:"px-4 py-3 text-right"},dt=["onClick"],it={key:2},ut={class:"grid grid-cols-2 gap-6"},ct={key:0,class:"bg-gray-50 rounded-lg p-6 text-center text-gray-500"},pt={key:1,class:"space-y-2"},xt={class:"flex justify-between items-start"},gt={class:"font-medium"},vt={class:"text-sm text-gray-500"},yt={class:"text-sm text-gray-500"},mt={class:"text-sm mt-1"},bt={class:"font-medium"},ht={class:"text-right"},ft={key:0,class:"text-sm text-gray-500 mt-1"},_t={key:0,class:"mt-2 pt-2 border-t"},wt=["onClick"],kt={key:0,class:"bg-gray-50 rounded-lg p-6 text-center text-gray-500"},Ct={key:1,class:"space-y-2"},At={class:"flex justify-between items-start"},St={class:"font-medium"},$t={class:"text-sm text-gray-500"},zt={class:"text-sm text-gray-500"},Ft={class:"text-sm mt-1"},Bt={class:"font-medium"},Vt={class:"text-right"},Pt={key:0,class:"mt-2 pt-2 border-t flex space-x-2"},Nt=["onClick"],jt=["onClick"],Ot={key:3},Rt={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},Mt={key:1,class:"bg-white rounded-lg shadow overflow-hidden"},Ut={class:"min-w-full divide-y divide-gray-200"},Dt={class:"divide-y divide-gray-200"},It={class:"px-4 py-3"},qt={class:"px-4 py-3"},Tt={class:"px-4 py-3"},Et={class:"px-4 py-3"},Lt={class:"px-4 py-3"},Kt={class:"px-4 py-3"},Wt={class:"px-4 py-3 text-right space-x-2"},Gt=["onClick"],Qt=["onClick"],Zt={key:4},Ht={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},Jt={key:1,class:"bg-white rounded-lg shadow overflow-hidden"},Xt={class:"min-w-full divide-y divide-gray-200"},Yt={class:"divide-y divide-gray-200"},es={class:"px-4 py-3 font-mono"},ts={class:"px-4 py-3"},ss={class:"px-4 py-3"},as={class:"px-4 py-3"},ns={key:0,class:"text-red-600"},ls={key:1,class:"text-green-600"},rs={class:"px-4 py-3 text-right font-medium"},os={class:"px-4 py-3"},ds={class:"px-4 py-3 text-right"},is=["onClick"],us={key:5,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},cs={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},ps={class:"space-y-4"},xs={key:0,class:"mt-1 border rounded-lg shadow-sm max-h-40 overflow-y-auto"},gs=["onClick"],vs={class:"text-gray-500"},ys={class:"flex justify-end space-x-2 mt-6"},ms=["disabled"],bs={key:6,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},hs={class:"bg-white rounded-lg shadow-xl w-full max-w-2xl p-6 max-h-[90vh] overflow-y-auto"},fs={class:"flex justify-between items-start mb-4"},_s={class:"text-xl font-bold"},ws={class:"grid grid-cols-2 gap-4 mb-6 text-sm"},ks={key:0},Cs={key:0,class:"mb-6"},As={key:0,class:"text-gray-500 text-sm"},Ss={key:1,class:"space-y-2"},$s={class:"font-medium"},zs={key:0,class:"text-xs text-blue-600 ml-2"},Fs={class:"flex items-center space-x-4"},Bs={class:"font-mono"},Vs=["onClick"],Ps={key:1,class:"grid grid-cols-3 gap-4 mb-6"},Ns={class:"bg-gray-50 rounded p-3 text-center"},js={class:"text-xl font-bold"},Os={class:"bg-gray-50 rounded p-3 text-center"},Rs={class:"text-xl font-bold"},Ms={class:"bg-gray-50 rounded p-3 text-center"},Us={class:"text-xl font-bold"},Ds={key:2,class:"flex space-x-2"},Is={key:3,class:"flex space-x-2"},qs={key:7,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},Ts={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},Es={class:"space-y-4"},Ls={class:"flex items-center"},Ks={class:"flex justify-end space-x-2 mt-6"},Ws={key:8,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},Gs={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},Qs={class:"text-xl font-bold mb-4"},Zs={class:"space-y-4"},Hs=["value"],Js=["value"],Xs={class:"flex justify-end space-x-2 mt-6"},Ys=["disabled"],sa=ge({__name:"PartnershipsView",setup(ea){ve();const D=c(!0),I=c([]),F=c([]),B=c({}),m=c("overview"),j=c(!1),q=c(!1),O=c(!1),R=c(!1),T=c(null),i=c(null),$=c(""),z=c([]),G=c(!1),g=c({subcontractor_slug:"",notes:"",contract_start:"",contract_end:""}),M=c(!1),y=c({name:"",description:"",rate_type:"hourly",amount:0,is_default:!1}),V=c({asContractor:[],asSubcontractor:[]}),E=c([]),L=c([]),Q=c([]),x=c({partnership_id:"",order_id:"",rate_id:"",required_staff:1,notes:""});ye(async()=>{await P()});async function P(){D.value=!0;try{const a=await u.get("/partnerships");I.value=a.data.asContractor||[],F.value=a.data.asSubcontractor||[],B.value=a.data.stats||{}}catch(a){console.error("Load partnerships failed:",a)}D.value=!1}async function ee(){if($.value.length<2){z.value=[];return}G.value=!0;try{const a=await u.get(`/partnerships/search/orgs?q=${encodeURIComponent($.value)}`);z.value=a.data}catch(a){console.error("Search failed:",a)}G.value=!1}function te(a){g.value.subcontractor_slug=a.slug,$.value=a.name,z.value=[]}async function se(){var a,t;if(g.value.subcontractor_slug){M.value=!0;try{await u.post("/partnerships",{subcontractor_slug:g.value.subcontractor_slug,notes:g.value.notes||void 0,contract_start:g.value.contract_start||void 0,contract_end:g.value.contract_end||void 0}),j.value=!1,Z(),await P()}catch(o){alert("Fehler: "+(((t=(a=o.response)==null?void 0:a.data)==null?void 0:t.error)||o.message))}M.value=!1}}function Z(){g.value={subcontractor_slug:"",notes:"",contract_start:"",contract_end:""},$.value="",z.value=[]}async function ae(a){var t,o;try{await u.post(`/partnerships/${a.id}/accept`),await P()}catch(d){alert("Fehler: "+(((o=(t=d.response)==null?void 0:t.data)==null?void 0:o.error)||d.message))}}async function ne(a){var t,o;if(confirm("Einladung wirklich ablehnen?"))try{await u.post(`/partnerships/${a.id}/decline`),await P()}catch(d){alert("Fehler: "+(((o=(t=d.response)==null?void 0:t.data)==null?void 0:o.error)||d.message))}}async function K(a,t){var o,d,_;if(confirm(`Status auf "${t}" ändern?`))try{await u.put(`/partnerships/${a.id}/status`,{status:t}),await P(),((o=i.value)==null?void 0:o.id)===a.id&&(i.value.status=t)}catch(s){alert("Fehler: "+(((_=(d=s.response)==null?void 0:d.data)==null?void 0:_.error)||s.message))}}async function H(a){var t,o;T.value=a;try{const d=await u.get(`/partnerships/${a.id}`);i.value=d.data,q.value=!0}catch(d){alert("Fehler: "+(((o=(t=d.response)==null?void 0:t.data)==null?void 0:o.error)||d.message))}}function le(){y.value={name:"",description:"",rate_type:"hourly",amount:0,is_default:!1},O.value=!0}async function re(){var a,t;if(!y.value.name||!y.value.amount){alert("Name und Betrag erforderlich");return}try{await u.post(`/partnerships/${i.value.id}/rates`,{...y.value,amount_cents:Math.round(y.value.amount*100)});const o=await u.get(`/partnerships/${i.value.id}`);i.value=o.data,O.value=!1}catch(o){alert("Fehler: "+(((t=(a=o.response)==null?void 0:a.data)==null?void 0:t.error)||o.message))}}async function oe(a){var t,o;if(confirm(`Satz "${a.name}" löschen?`))try{await u.delete(`/partnerships/${i.value.id}/rates/${a.id}`);const d=await u.get(`/partnerships/${i.value.id}`);i.value=d.data}catch(d){alert("Fehler: "+(((o=(t=d.response)==null?void 0:t.data)==null?void 0:o.error)||d.message))}}async function U(){m.value="orders";try{const a=await u.get("/partnerships/orders/list");V.value=a.data}catch(a){console.error("Load shared orders failed:",a)}}async function de(a){T.value=a,x.value={partnership_id:a.id,order_id:"",rate_id:"",required_staff:1,notes:""};try{const t=await u.get("/orders");Q.value=t.data.orders||t.data||[];const o=await u.get(`/partnerships/${a.id}/rates`);i.value={...a,rates:o.data},R.value=!0}catch(t){console.error("Load orders failed:",t)}}async function ie(){var a,t;if(!x.value.order_id){alert("Bitte Auftrag auswählen");return}try{await u.post("/partnerships/orders",{partnership_id:x.value.partnership_id,order_id:x.value.order_id,rate_id:x.value.rate_id||void 0,required_staff:x.value.required_staff,notes:x.value.notes||void 0}),R.value=!1,await U()}catch(o){alert("Fehler: "+(((t=(a=o.response)==null?void 0:a.data)==null?void 0:t.error)||o.message))}}async function J(a,t){var o,d;try{await u.post(`/partnerships/orders/${a.id}/respond`,{accept:t,notes:""}),await U()}catch(_){alert("Fehler: "+(((d=(o=_.response)==null?void 0:o.data)==null?void 0:d.error)||_.message))}}async function ue(a){var t,o;if(confirm("Auftrag abschließen?"))try{await u.post(`/partnerships/orders/${a.id}/complete`),await U()}catch(d){alert("Fehler: "+(((o=(t=d.response)==null?void 0:t.data)==null?void 0:o.error)||d.message))}}async function W(){m.value="timesheets";try{const a=await u.get("/partnerships/timesheets/list");E.value=a.data}catch(a){console.error("Load timesheets failed:",a)}}async function ce(a){var t,o;try{await u.post(`/partnerships/timesheets/${a.id}/approve`),await W()}catch(d){alert("Fehler: "+(((o=(t=d.response)==null?void 0:t.data)==null?void 0:o.error)||d.message))}}async function pe(a){var o,d;const t=prompt("Grund für Beanstandung:");if(t)try{await u.post(`/partnerships/timesheets/${a.id}/dispute`,{reason:t}),await W()}catch(_){alert("Fehler: "+(((d=(o=_.response)==null?void 0:o.data)==null?void 0:d.error)||_.message))}}async function X(){m.value="invoices";try{const a=await u.get("/partnerships/invoices/list");L.value=a.data}catch(a){console.error("Load invoices failed:",a)}}async function xe(a){var t,o;if(confirm("Rechnung als bezahlt markieren?"))try{await u.put(`/partnerships/invoices/${a.id}/pay`),await X()}catch(d){alert("Fehler: "+(((o=(t=d.response)==null?void 0:t.data)==null?void 0:o.error)||d.message))}}function N(a){return(a/100).toFixed(2).replace(".",",")+" €"}function C(a){return a?new Date(a).toLocaleDateString("de-DE"):"-"}function v(a){return{pending:{text:"Ausstehend",class:"bg-yellow-100 text-yellow-800"},active:{text:"Aktiv",class:"bg-green-100 text-green-800"},paused:{text:"Pausiert",class:"bg-gray-100 text-gray-800"},terminated:{text:"Beendet",class:"bg-red-100 text-red-800"},requested:{text:"Angefragt",class:"bg-blue-100 text-blue-800"},accepted:{text:"Angenommen",class:"bg-green-100 text-green-800"},declined:{text:"Abgelehnt",class:"bg-red-100 text-red-800"},completed:{text:"Abgeschlossen",class:"bg-gray-100 text-gray-800"},approved:{text:"Freigegeben",class:"bg-green-100 text-green-800"},disputed:{text:"Beanstandet",class:"bg-red-100 text-red-800"},draft:{text:"Entwurf",class:"bg-gray-100 text-gray-800"},sent:{text:"Gesendet",class:"bg-blue-100 text-blue-800"},paid:{text:"Bezahlt",class:"bg-green-100 text-green-800"}}[a]||{text:a,class:"bg-gray-100 text-gray-800"}}return(a,t)=>{var o,d,_;return l(),n("div",be,[e("div",he,[t[24]||(t[24]=e("div",null,[e("h1",{class:"text-2xl font-bold text-gray-900"},"🤝 Subunternehmer"),e("p",{class:"text-gray-500"},"Partnerschaften mit anderen Sicherheitsunternehmen")],-1)),e("button",{onClick:t[0]||(t[0]=s=>j.value=!0),class:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700"}," + Partner einladen ")]),e("div",fe,[e("button",{onClick:t[1]||(t[1]=s=>m.value="overview"),class:w(["px-4 py-2 font-medium border-b-2 -mb-px",m.value==="overview"?"border-blue-600 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"])}," Übersicht ",2),e("button",{onClick:t[2]||(t[2]=s=>U()),class:w(["px-4 py-2 font-medium border-b-2 -mb-px",m.value==="orders"?"border-blue-600 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"])}," Geteilte Aufträge ",2),e("button",{onClick:t[3]||(t[3]=s=>W()),class:w(["px-4 py-2 font-medium border-b-2 -mb-px",m.value==="timesheets"?"border-blue-600 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"])}," Stundenzettel ",2),e("button",{onClick:t[4]||(t[4]=s=>X()),class:w(["px-4 py-2 font-medium border-b-2 -mb-px",m.value==="invoices"?"border-blue-600 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"])}," Rechnungen ",2)]),D.value?(l(),n("div",_e,[...t[25]||(t[25]=[e("div",{class:"animate-spin w-8 h-8 border-4 border-blue-600 border-t-transparent rounded-full mx-auto"},null,-1)])])):m.value==="overview"?(l(),n("div",we,[e("div",ke,[e("div",Ce,[e("div",Ae,r(B.value.totalPartnerships||0),1),t[26]||(t[26]=e("div",{class:"text-sm text-gray-500"},"Partnerschaften",-1))]),e("div",Se,[e("div",$e,r(B.value.activeAsContractor||0),1),t[27]||(t[27]=e("div",{class:"text-sm text-gray-500"},"Als Auftraggeber",-1))]),e("div",ze,[e("div",Fe,r(B.value.activeAsSubcontractor||0),1),t[28]||(t[28]=e("div",{class:"text-sm text-gray-500"},"Als Subunternehmer",-1))]),e("div",Be,[e("div",Ve,r(B.value.pendingInvitations||0),1),t[29]||(t[29]=e("div",{class:"text-sm text-gray-500"},"Offene Einladungen",-1))])]),F.value.filter(s=>s.status==="pending").length>0?(l(),n("div",Pe,[t[31]||(t[31]=e("h2",{class:"text-lg font-semibold mb-3"},"📩 Offene Einladungen",-1)),e("div",Ne,[(l(!0),n(h,null,k(F.value.filter(s=>s.status==="pending"),s=>(l(),n("div",{key:s.id,class:"bg-yellow-50 border border-yellow-200 rounded-lg p-4 flex justify-between items-center"},[e("div",null,[e("span",je,r(s.partner_name),1),t[30]||(t[30]=S(" möchte mit Ihnen zusammenarbeiten ",-1))]),e("div",Oe,[e("button",{onClick:b=>ae(s),class:"px-3 py-1 bg-green-600 text-white rounded hover:bg-green-700"}," Annehmen ",8,Re),e("button",{onClick:b=>ne(s),class:"px-3 py-1 bg-red-100 text-red-700 rounded hover:bg-red-200"}," Ablehnen ",8,Me)])]))),128))])])):p("",!0),e("div",Ue,[t[33]||(t[33]=e("h2",{class:"text-lg font-semibold mb-3"},"🏢 Wir als Auftraggeber",-1)),I.value.length===0?(l(),n("div",De," Noch keine Subunternehmer eingeladen ")):(l(),n("div",Ie,[e("table",qe,[t[32]||(t[32]=e("thead",{class:"bg-gray-50"},[e("tr",null,[e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Subunternehmer"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Status"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Aufträge"),e("th",{class:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase"},"Aktionen")])],-1)),e("tbody",Te,[(l(!0),n(h,null,k(I.value,s=>(l(),n("tr",{key:s.id,class:"hover:bg-gray-50"},[e("td",Ee,[e("span",Le,r(s.partner_name),1),e("span",Ke,"@"+r(s.partner_slug),1)]),e("td",We,[e("span",{class:w(["px-2 py-1 text-xs rounded-full",v(s.status).class])},r(v(s.status).text),3)]),e("td",Ge,[S(r(s.shared_orders_count||0)+" geteilt ",1),s.pending_orders>0?(l(),n("span",Qe," ("+r(s.pending_orders)+" offen) ",1)):p("",!0)]),e("td",Ze,[e("button",{onClick:b=>H(s),class:"text-blue-600 hover:text-blue-800"}," Details ",8,He),s.status==="active"?(l(),n("button",{key:0,onClick:b=>de(s),class:"text-green-600 hover:text-green-800"}," Auftrag teilen ",8,Je)):p("",!0)])]))),128))])])]))]),e("div",null,[t[35]||(t[35]=e("h2",{class:"text-lg font-semibold mb-3"},"👷 Wir als Subunternehmer",-1)),F.value.filter(s=>s.status!=="pending").length===0?(l(),n("div",Xe," Keine aktiven Partnerschaften als Subunternehmer ")):(l(),n("div",Ye,[e("table",et,[t[34]||(t[34]=e("thead",{class:"bg-gray-50"},[e("tr",null,[e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Auftraggeber"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Status"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Aufträge"),e("th",{class:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase"},"Aktionen")])],-1)),e("tbody",tt,[(l(!0),n(h,null,k(F.value.filter(s=>s.status!=="pending"),s=>(l(),n("tr",{key:s.id,class:"hover:bg-gray-50"},[e("td",st,[e("span",at,r(s.partner_name),1)]),e("td",nt,[e("span",{class:w(["px-2 py-1 text-xs rounded-full",v(s.status).class])},r(v(s.status).text),3)]),e("td",lt,[S(r(s.shared_orders_count||0)+" erhalten ",1),s.pending_orders>0?(l(),n("span",rt," ("+r(s.pending_orders)+" offen) ",1)):p("",!0)]),e("td",ot,[e("button",{onClick:b=>H(s),class:"text-blue-600 hover:text-blue-800"}," Details ",8,dt)])]))),128))])])]))])])):m.value==="orders"?(l(),n("div",it,[e("div",ut,[e("div",null,[t[37]||(t[37]=e("h2",{class:"text-lg font-semibold mb-3"},"📤 Von uns geteilt",-1)),V.value.asContractor.length===0?(l(),n("div",ct," Keine geteilten Aufträge ")):(l(),n("div",pt,[(l(!0),n(h,null,k(V.value.asContractor,s=>(l(),n("div",{key:s.id,class:"bg-white rounded-lg shadow p-4"},[e("div",xt,[e("div",null,[e("div",gt,r(s.order_title),1),e("div",vt,r(s.location),1),e("div",yt,r(C(s.start_date))+" - "+r(C(s.end_date)),1),e("div",mt,[t[36]||(t[36]=S(" → ",-1)),e("span",bt,r(s.subcontractor_name),1)])]),e("div",ht,[e("span",{class:w(["px-2 py-1 text-xs rounded-full",v(s.status).class])},r(v(s.status).text),3),s.rate_name?(l(),n("div",ft,r(s.rate_name)+": "+r(N(s.rate_amount))+"/h ",1)):p("",!0)])]),s.status==="accepted"?(l(),n("div",_t,[e("button",{onClick:b=>ue(s),class:"text-sm text-green-600 hover:text-green-800"}," ✓ Abschließen ",8,wt)])):p("",!0)]))),128))]))]),e("div",null,[t[39]||(t[39]=e("h2",{class:"text-lg font-semibold mb-3"},"📥 An uns übertragen",-1)),V.value.asSubcontractor.length===0?(l(),n("div",kt," Keine erhaltenen Aufträge ")):(l(),n("div",Ct,[(l(!0),n(h,null,k(V.value.asSubcontractor,s=>(l(),n("div",{key:s.id,class:"bg-white rounded-lg shadow p-4"},[e("div",At,[e("div",null,[e("div",St,r(s.order_title),1),e("div",$t,r(s.location),1),e("div",zt,r(C(s.start_date))+" - "+r(C(s.end_date)),1),e("div",Ft,[t[38]||(t[38]=S(" ← ",-1)),e("span",Bt,r(s.contractor_name),1)])]),e("div",Vt,[e("span",{class:w(["px-2 py-1 text-xs rounded-full",v(s.status).class])},r(v(s.status).text),3)])]),s.status==="requested"?(l(),n("div",Pt,[e("button",{onClick:b=>J(s,!0),class:"text-sm px-3 py-1 bg-green-600 text-white rounded hover:bg-green-700"}," Annehmen ",8,Nt),e("button",{onClick:b=>J(s,!1),class:"text-sm px-3 py-1 bg-red-100 text-red-700 rounded hover:bg-red-200"}," Ablehnen ",8,jt)])):p("",!0)]))),128))]))])])])):m.value==="timesheets"?(l(),n("div",Ot,[E.value.length===0?(l(),n("div",Rt," Keine Partnership-Stundenzettel vorhanden ")):(l(),n("div",Mt,[e("table",Ut,[t[40]||(t[40]=e("thead",{class:"bg-gray-50"},[e("tr",null,[e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Datum"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Mitarbeiter"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Auftrag"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Stunden"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Betrag"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Status"),e("th",{class:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase"},"Aktionen")])],-1)),e("tbody",Dt,[(l(!0),n(h,null,k(E.value,s=>(l(),n("tr",{key:s.id,class:"hover:bg-gray-50"},[e("td",It,r(C(s.date)),1),e("td",qt,r(s.first_name)+" "+r(s.last_name),1),e("td",Tt,r(s.order_title),1),e("td",Et,r(s.hours_worked)+"h",1),e("td",Lt,r(s.calculated_amount_cents?N(s.calculated_amount_cents):"-"),1),e("td",Kt,[e("span",{class:w(["px-2 py-1 text-xs rounded-full",v(s.approval_status).class])},r(v(s.approval_status).text),3)]),e("td",Wt,[s.approval_status==="pending"?(l(),n(h,{key:0},[e("button",{onClick:b=>ce(s),class:"text-green-600 hover:text-green-800"}," ✓ Freigeben ",8,Gt),e("button",{onClick:b=>pe(s),class:"text-red-600 hover:text-red-800"}," ✗ Beanstanden ",8,Qt)],64)):p("",!0)])]))),128))])])]))])):m.value==="invoices"?(l(),n("div",Zt,[L.value.length===0?(l(),n("div",Ht," Keine Rechnungen vorhanden ")):(l(),n("div",Jt,[e("table",Xt,[t[41]||(t[41]=e("thead",{class:"bg-gray-50"},[e("tr",null,[e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Nr."),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Partner"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Zeitraum"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Richtung"),e("th",{class:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase"},"Betrag"),e("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Status"),e("th",{class:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase"},"Aktionen")])],-1)),e("tbody",Yt,[(l(!0),n(h,null,k(L.value,s=>(l(),n("tr",{key:s.id,class:"hover:bg-gray-50"},[e("td",es,r(s.invoice_number),1),e("td",ts,r(s.partner_name),1),e("td",ss,r(C(s.period_start))+" - "+r(C(s.period_end)),1),e("td",as,[s.direction==="outgoing"?(l(),n("span",ns,"📤 Ausgehend")):(l(),n("span",ls,"📥 Eingehend"))]),e("td",rs,r(N(s.total_cents)),1),e("td",os,[e("span",{class:w(["px-2 py-1 text-xs rounded-full",v(s.status).class])},r(v(s.status).text),3)]),e("td",ds,[s.direction==="incoming"&&s.status==="sent"?(l(),n("button",{key:0,onClick:b=>xe(s),class:"text-green-600 hover:text-green-800"}," Als bezahlt markieren ",8,is)):p("",!0)])]))),128))])])]))])):p("",!0),j.value?(l(),n("div",us,[e("div",cs,[t[46]||(t[46]=e("h2",{class:"text-xl font-bold mb-4"},"Partner einladen",-1)),e("div",ps,[e("div",null,[t[42]||(t[42]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Organisation suchen",-1)),f(e("input",{"onUpdate:modelValue":t[5]||(t[5]=s=>$.value=s),onInput:ee,type:"text",placeholder:"Name oder Slug eingeben...",class:"w-full border rounded-lg px-3 py-2"},null,544),[[A,$.value]]),z.value.length>0?(l(),n("div",xs,[(l(!0),n(h,null,k(z.value,s=>(l(),n("button",{key:s.id,onClick:b=>te(s),class:"w-full px-3 py-2 text-left hover:bg-gray-100"},[S(r(s.name)+" ",1),e("span",vs,"@"+r(s.slug),1)],8,gs))),128))])):p("",!0)]),e("div",null,[t[43]||(t[43]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Vertragsbeginn",-1)),f(e("input",{"onUpdate:modelValue":t[6]||(t[6]=s=>g.value.contract_start=s),type:"date",class:"w-full border rounded-lg px-3 py-2"},null,512),[[A,g.value.contract_start]])]),e("div",null,[t[44]||(t[44]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Vertragsende (optional)",-1)),f(e("input",{"onUpdate:modelValue":t[7]||(t[7]=s=>g.value.contract_end=s),type:"date",class:"w-full border rounded-lg px-3 py-2"},null,512),[[A,g.value.contract_end]])]),e("div",null,[t[45]||(t[45]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Notizen",-1)),f(e("textarea",{"onUpdate:modelValue":t[8]||(t[8]=s=>g.value.notes=s),rows:"3",class:"w-full border rounded-lg px-3 py-2",placeholder:"Optionale Nachricht..."},null,512),[[A,g.value.notes]])])]),e("div",ys,[e("button",{onClick:t[9]||(t[9]=s=>{j.value=!1,Z()}),class:"px-4 py-2 text-gray-700 hover:bg-gray-100 rounded-lg"}," Abbrechen "),e("button",{onClick:se,disabled:M.value||!g.value.subcontractor_slug,class:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},r(M.value?"Wird gesendet...":"Einladung senden"),9,ms)])])])):p("",!0),q.value&&i.value?(l(),n("div",bs,[e("div",hs,[e("div",fs,[e("div",null,[e("h2",_s," Partnerschaft mit "+r(i.value.isContractor?i.value.subcontractor_name:i.value.contractor_name),1),e("span",{class:w(["px-2 py-1 text-xs rounded-full",v(i.value.status).class])},r(v(i.value.status).text),3)]),e("button",{onClick:t[10]||(t[10]=s=>q.value=!1),class:"text-gray-500 hover:text-gray-700"},"✕")]),e("div",ws,[e("div",null,[t[47]||(t[47]=e("span",{class:"text-gray-500"},"Rolle:",-1)),S(" "+r(i.value.isContractor?"Wir sind Auftraggeber":"Wir sind Subunternehmer"),1)]),e("div",null,[t[48]||(t[48]=e("span",{class:"text-gray-500"},"Seit:",-1)),S(" "+r(C(i.value.contract_start||i.value.created_at)),1)]),i.value.contract_end?(l(),n("div",ks,[t[49]||(t[49]=e("span",{class:"text-gray-500"},"Bis:",-1)),S(" "+r(C(i.value.contract_end)),1)])):p("",!0)]),i.value.isContractor?(l(),n("div",Cs,[e("div",{class:"flex justify-between items-center mb-2"},[t[50]||(t[50]=e("h3",{class:"font-semibold"},"Stundensätze",-1)),e("button",{onClick:le,class:"text-sm text-blue-600 hover:text-blue-800"}," + Neuer Satz ")]),(o=i.value.rates)!=null&&o.length?(l(),n("div",Ss,[(l(!0),n(h,null,k(i.value.rates,s=>(l(),n("div",{key:s.id,class:"flex justify-between items-center bg-gray-50 rounded px-3 py-2"},[e("div",null,[e("span",$s,r(s.name),1),s.is_default?(l(),n("span",zs,"Standard")):p("",!0)]),e("div",Fs,[e("span",Bs,r(N(s.amount_cents))+"/h",1),e("button",{onClick:b=>oe(s),class:"text-red-500 hover:text-red-700"}," 🗑 ",8,Vs)])]))),128))])):(l(),n("div",As," Noch keine Sätze definiert "))])):p("",!0),i.value.stats?(l(),n("div",Ps,[e("div",Ns,[e("div",js,r(i.value.stats.completed_orders||0),1),t[51]||(t[51]=e("div",{class:"text-xs text-gray-500"},"Abgeschlossen",-1))]),e("div",Os,[e("div",Rs,r(i.value.stats.active_orders||0),1),t[52]||(t[52]=e("div",{class:"text-xs text-gray-500"},"Aktiv",-1))]),e("div",Ms,[e("div",Us,r(i.value.stats.pending_orders||0),1),t[53]||(t[53]=e("div",{class:"text-xs text-gray-500"},"Ausstehend",-1))])])):p("",!0),i.value.status==="active"?(l(),n("div",Ds,[e("button",{onClick:t[11]||(t[11]=s=>K(i.value,"paused")),class:"px-4 py-2 bg-yellow-100 text-yellow-700 rounded hover:bg-yellow-200"}," Pausieren "),e("button",{onClick:t[12]||(t[12]=s=>K(i.value,"terminated")),class:"px-4 py-2 bg-red-100 text-red-700 rounded hover:bg-red-200"}," Beenden ")])):i.value.status==="paused"?(l(),n("div",Is,[e("button",{onClick:t[13]||(t[13]=s=>K(i.value,"active")),class:"px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700"}," Reaktivieren ")])):p("",!0)])])):p("",!0),O.value?(l(),n("div",qs,[e("div",Ts,[t[58]||(t[58]=e("h2",{class:"text-xl font-bold mb-4"},"Neuer Stundensatz",-1)),e("div",Es,[e("div",null,[t[54]||(t[54]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Bezeichnung *",-1)),f(e("input",{"onUpdate:modelValue":t[14]||(t[14]=s=>y.value.name=s),type:"text",placeholder:"z.B. Normaldienst, Nachtschicht...",class:"w-full border rounded-lg px-3 py-2"},null,512),[[A,y.value.name]])]),e("div",null,[t[55]||(t[55]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Beschreibung",-1)),f(e("input",{"onUpdate:modelValue":t[15]||(t[15]=s=>y.value.description=s),type:"text",class:"w-full border rounded-lg px-3 py-2"},null,512),[[A,y.value.description]])]),e("div",null,[t[56]||(t[56]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Stundensatz (€) *",-1)),f(e("input",{"onUpdate:modelValue":t[16]||(t[16]=s=>y.value.amount=s),type:"number",step:"0.01",min:"0",class:"w-full border rounded-lg px-3 py-2"},null,512),[[A,y.value.amount,void 0,{number:!0}]])]),e("label",Ls,[f(e("input",{"onUpdate:modelValue":t[17]||(t[17]=s=>y.value.is_default=s),type:"checkbox",class:"mr-2"},null,512),[[me,y.value.is_default]]),t[57]||(t[57]=e("span",{class:"text-sm"},"Als Standard-Satz verwenden",-1))])]),e("div",Ks,[e("button",{onClick:t[18]||(t[18]=s=>O.value=!1),class:"px-4 py-2 text-gray-700 hover:bg-gray-100 rounded-lg"}," Abbrechen "),e("button",{onClick:re,class:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700"}," Speichern ")])])])):p("",!0),R.value?(l(),n("div",Ws,[e("div",Gs,[e("h2",Qs,"Auftrag teilen mit "+r((d=T.value)==null?void 0:d.partner_name),1),e("div",Zs,[e("div",null,[t[60]||(t[60]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Auftrag auswählen *",-1)),f(e("select",{"onUpdate:modelValue":t[19]||(t[19]=s=>x.value.order_id=s),class:"w-full border rounded-lg px-3 py-2"},[t[59]||(t[59]=e("option",{value:""},"Bitte wählen...",-1)),(l(!0),n(h,null,k(Q.value,s=>(l(),n("option",{key:s.id,value:s.id},r(s.title)+" ("+r(C(s.start_date))+") ",9,Hs))),128))],512),[[Y,x.value.order_id]])]),e("div",null,[t[62]||(t[62]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Stundensatz",-1)),f(e("select",{"onUpdate:modelValue":t[20]||(t[20]=s=>x.value.rate_id=s),class:"w-full border rounded-lg px-3 py-2"},[t[61]||(t[61]=e("option",{value:""},"Keiner / Später festlegen",-1)),(l(!0),n(h,null,k((_=i.value)==null?void 0:_.rates,s=>(l(),n("option",{key:s.id,value:s.id},r(s.name)+" ("+r(N(s.amount_cents))+"/h) ",9,Js))),128))],512),[[Y,x.value.rate_id]])]),e("div",null,[t[63]||(t[63]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Benötigte Mitarbeiter",-1)),f(e("input",{"onUpdate:modelValue":t[21]||(t[21]=s=>x.value.required_staff=s),type:"number",min:"1",class:"w-full border rounded-lg px-3 py-2"},null,512),[[A,x.value.required_staff,void 0,{number:!0}]])]),e("div",null,[t[64]||(t[64]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Notizen",-1)),f(e("textarea",{"onUpdate:modelValue":t[22]||(t[22]=s=>x.value.notes=s),rows:"2",class:"w-full border rounded-lg px-3 py-2"},null,512),[[A,x.value.notes]])])]),e("div",Xs,[e("button",{onClick:t[23]||(t[23]=s=>R.value=!1),class:"px-4 py-2 text-gray-700 hover:bg-gray-100 rounded-lg"}," Abbrechen "),e("button",{onClick:ie,disabled:!x.value.order_id,class:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"}," Auftrag teilen ",8,Ys)])])])):p("",!0)])}}});export{sa as default}; diff --git a/dist/assets/PatrolsView-CE7IkVbv.js b/dist/assets/PatrolsView-B1roLsna.js similarity index 98% rename from dist/assets/PatrolsView-CE7IkVbv.js rename to dist/assets/PatrolsView-B1roLsna.js index 78124ad..9bf5819 100644 --- a/dist/assets/PatrolsView-CE7IkVbv.js +++ b/dist/assets/PatrolsView-B1roLsna.js @@ -1 +1 @@ -import{d as h,q as k,m,c as s,a as t,n as u,t as a,F as g,x as _,e as v,r as d,o as n}from"./index-CWxNv9Fc.js";const f={class:"p-6"},w={class:"flex space-x-1 border-b mb-6"},C={key:0,class:"text-center py-12"},R={key:1},j={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},M={key:1,class:"grid md:grid-cols-2 lg:grid-cols-3 gap-4"},D={class:"flex justify-between items-start"},B={class:"font-semibold"},E={class:"text-sm text-gray-500"},K={class:"text-xs text-gray-400 mt-1"},L={class:"text-2xl"},T={class:"mt-3 p-2 bg-gray-100 rounded text-xs font-mono break-all"},V={key:2},$={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},A={key:1,class:"space-y-4"},F={class:"flex justify-between items-start"},N={class:"font-semibold"},P={class:"text-sm text-gray-500"},S={class:"mt-3 flex gap-4 text-sm text-gray-600"},q={key:0},z={key:1},I={key:3},O={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},Q={key:1,class:"bg-white rounded-lg shadow overflow-hidden"},W={class:"min-w-full divide-y divide-gray-200"},Z={class:"divide-y divide-gray-200"},G={class:"px-4 py-3 text-sm"},H={class:"px-4 py-3 text-sm"},J={class:"px-4 py-3 text-sm"},U={class:"px-4 py-3 text-sm text-gray-500"},tt=h({__name:"PatrolsView",setup(X){const p=d(!0),r=d([]),c=d([]),x=d([]),l=d("checkpoints");k(async()=>{await y()});async function y(){p.value=!0;try{const[i,o,e]=await Promise.all([m.get("/patrols/checkpoints"),m.get("/patrols/routes"),m.get("/patrols/logs")]);r.value=i.data.checkpoints||[],c.value=o.data.routes||[],x.value=e.data.logs||[]}catch(i){console.error(i)}p.value=!1}function b(i){return new Date(i).toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})}return(i,o)=>(n(),s("div",f,[o[7]||(o[7]=t("div",{class:"flex justify-between items-center mb-6"},[t("div",null,[t("h1",{class:"text-2xl font-bold"},"📍 Wächterkontrolle"),t("p",{class:"text-gray-500"},"Checkpoints, Routen & Rundgänge")])],-1)),t("div",w,[t("button",{onClick:o[0]||(o[0]=e=>l.value="checkpoints"),class:u(["px-4 py-2 font-medium border-b-2 -mb-px",l.value==="checkpoints"?"border-blue-600 text-blue-600":"border-transparent"])}," Checkpoints ("+a(r.value.length)+") ",3),t("button",{onClick:o[1]||(o[1]=e=>l.value="routes"),class:u(["px-4 py-2 font-medium border-b-2 -mb-px",l.value==="routes"?"border-blue-600 text-blue-600":"border-transparent"])}," Routen ("+a(c.value.length)+") ",3),t("button",{onClick:o[2]||(o[2]=e=>l.value="logs"),class:u(["px-4 py-2 font-medium border-b-2 -mb-px",l.value==="logs"?"border-blue-600 text-blue-600":"border-transparent"])}," Rundgänge ",2)]),p.value?(n(),s("div",C,"Laden...")):l.value==="checkpoints"?(n(),s("div",R,[r.value.length===0?(n(),s("div",j,[...o[3]||(o[3]=[t("p",{class:"text-4xl mb-4"},"📍",-1),t("p",null,"Keine Checkpoints vorhanden",-1),t("p",{class:"text-sm mt-2"},"Erstelle Checkpoints mit QR-Codes für Rundgänge",-1)])])):(n(),s("div",M,[(n(!0),s(g,null,_(r.value,e=>(n(),s("div",{key:e.id,class:"bg-white rounded-lg shadow p-4"},[t("div",D,[t("div",null,[t("h3",B,a(e.name),1),t("p",E,a(e.object_name),1),t("p",K,a(e.location_description),1)]),t("span",L,a(e.checkpoint_type==="nfc"?"📶":"📱"),1)]),t("div",T,a(e.code),1)]))),128))]))])):l.value==="routes"?(n(),s("div",V,[c.value.length===0?(n(),s("div",$,[...o[4]||(o[4]=[t("p",{class:"text-4xl mb-4"},"🗺️",-1),t("p",null,"Keine Routen definiert",-1)])])):(n(),s("div",A,[(n(!0),s(g,null,_(c.value,e=>(n(),s("div",{key:e.id,class:"bg-white rounded-lg shadow p-4"},[t("div",F,[t("div",null,[t("h3",N,a(e.name),1),t("p",P,a(e.object_name),1)]),t("span",{class:u(["px-2 py-1 text-xs rounded",e.is_active?"bg-green-100 text-green-700":"bg-gray-100"])},a(e.is_active?"Aktiv":"Inaktiv"),3)]),t("div",S,[t("span",null,"📍 "+a(e.checkpoint_count||0)+" Checkpoints",1),e.time_limit_minutes?(n(),s("span",q,"⏱️ Max "+a(e.time_limit_minutes)+" Min",1)):v("",!0),e.interval_minutes?(n(),s("span",z,"🔄 Alle "+a(e.interval_minutes)+" Min",1)):v("",!0)])]))),128))]))])):l.value==="logs"?(n(),s("div",I,[x.value.length===0?(n(),s("div",O,[...o[5]||(o[5]=[t("p",{class:"text-4xl mb-4"},"📋",-1),t("p",null,"Keine Rundgänge heute",-1)])])):(n(),s("div",Q,[t("table",W,[o[6]||(o[6]=t("thead",{class:"bg-gray-50"},[t("tr",null,[t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Zeit"),t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Mitarbeiter"),t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Checkpoint"),t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Objekt")])],-1)),t("tbody",Z,[(n(!0),s(g,null,_(x.value,e=>(n(),s("tr",{key:e.id,class:"hover:bg-gray-50"},[t("td",G,a(b(e.scanned_at)),1),t("td",H,a(e.first_name)+" "+a(e.last_name),1),t("td",J,a(e.checkpoint_name),1),t("td",U,a(e.object_name),1)]))),128))])])]))])):v("",!0)]))}});export{tt as default}; +import{d as h,q as k,m,c as s,a as t,n as u,t as a,F as g,x as _,e as v,r as d,o as n}from"./index-CgM2qJ96.js";const f={class:"p-6"},w={class:"flex space-x-1 border-b mb-6"},C={key:0,class:"text-center py-12"},R={key:1},j={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},M={key:1,class:"grid md:grid-cols-2 lg:grid-cols-3 gap-4"},D={class:"flex justify-between items-start"},B={class:"font-semibold"},E={class:"text-sm text-gray-500"},K={class:"text-xs text-gray-400 mt-1"},L={class:"text-2xl"},T={class:"mt-3 p-2 bg-gray-100 rounded text-xs font-mono break-all"},V={key:2},$={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},A={key:1,class:"space-y-4"},F={class:"flex justify-between items-start"},N={class:"font-semibold"},P={class:"text-sm text-gray-500"},S={class:"mt-3 flex gap-4 text-sm text-gray-600"},q={key:0},z={key:1},I={key:3},O={key:0,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},Q={key:1,class:"bg-white rounded-lg shadow overflow-hidden"},W={class:"min-w-full divide-y divide-gray-200"},Z={class:"divide-y divide-gray-200"},G={class:"px-4 py-3 text-sm"},H={class:"px-4 py-3 text-sm"},J={class:"px-4 py-3 text-sm"},U={class:"px-4 py-3 text-sm text-gray-500"},tt=h({__name:"PatrolsView",setup(X){const p=d(!0),r=d([]),c=d([]),x=d([]),l=d("checkpoints");k(async()=>{await y()});async function y(){p.value=!0;try{const[i,o,e]=await Promise.all([m.get("/patrols/checkpoints"),m.get("/patrols/routes"),m.get("/patrols/logs")]);r.value=i.data.checkpoints||[],c.value=o.data.routes||[],x.value=e.data.logs||[]}catch(i){console.error(i)}p.value=!1}function b(i){return new Date(i).toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})}return(i,o)=>(n(),s("div",f,[o[7]||(o[7]=t("div",{class:"flex justify-between items-center mb-6"},[t("div",null,[t("h1",{class:"text-2xl font-bold"},"📍 Wächterkontrolle"),t("p",{class:"text-gray-500"},"Checkpoints, Routen & Rundgänge")])],-1)),t("div",w,[t("button",{onClick:o[0]||(o[0]=e=>l.value="checkpoints"),class:u(["px-4 py-2 font-medium border-b-2 -mb-px",l.value==="checkpoints"?"border-blue-600 text-blue-600":"border-transparent"])}," Checkpoints ("+a(r.value.length)+") ",3),t("button",{onClick:o[1]||(o[1]=e=>l.value="routes"),class:u(["px-4 py-2 font-medium border-b-2 -mb-px",l.value==="routes"?"border-blue-600 text-blue-600":"border-transparent"])}," Routen ("+a(c.value.length)+") ",3),t("button",{onClick:o[2]||(o[2]=e=>l.value="logs"),class:u(["px-4 py-2 font-medium border-b-2 -mb-px",l.value==="logs"?"border-blue-600 text-blue-600":"border-transparent"])}," Rundgänge ",2)]),p.value?(n(),s("div",C,"Laden...")):l.value==="checkpoints"?(n(),s("div",R,[r.value.length===0?(n(),s("div",j,[...o[3]||(o[3]=[t("p",{class:"text-4xl mb-4"},"📍",-1),t("p",null,"Keine Checkpoints vorhanden",-1),t("p",{class:"text-sm mt-2"},"Erstelle Checkpoints mit QR-Codes für Rundgänge",-1)])])):(n(),s("div",M,[(n(!0),s(g,null,_(r.value,e=>(n(),s("div",{key:e.id,class:"bg-white rounded-lg shadow p-4"},[t("div",D,[t("div",null,[t("h3",B,a(e.name),1),t("p",E,a(e.object_name),1),t("p",K,a(e.location_description),1)]),t("span",L,a(e.checkpoint_type==="nfc"?"📶":"📱"),1)]),t("div",T,a(e.code),1)]))),128))]))])):l.value==="routes"?(n(),s("div",V,[c.value.length===0?(n(),s("div",$,[...o[4]||(o[4]=[t("p",{class:"text-4xl mb-4"},"🗺️",-1),t("p",null,"Keine Routen definiert",-1)])])):(n(),s("div",A,[(n(!0),s(g,null,_(c.value,e=>(n(),s("div",{key:e.id,class:"bg-white rounded-lg shadow p-4"},[t("div",F,[t("div",null,[t("h3",N,a(e.name),1),t("p",P,a(e.object_name),1)]),t("span",{class:u(["px-2 py-1 text-xs rounded",e.is_active?"bg-green-100 text-green-700":"bg-gray-100"])},a(e.is_active?"Aktiv":"Inaktiv"),3)]),t("div",S,[t("span",null,"📍 "+a(e.checkpoint_count||0)+" Checkpoints",1),e.time_limit_minutes?(n(),s("span",q,"⏱️ Max "+a(e.time_limit_minutes)+" Min",1)):v("",!0),e.interval_minutes?(n(),s("span",z,"🔄 Alle "+a(e.interval_minutes)+" Min",1)):v("",!0)])]))),128))]))])):l.value==="logs"?(n(),s("div",I,[x.value.length===0?(n(),s("div",O,[...o[5]||(o[5]=[t("p",{class:"text-4xl mb-4"},"📋",-1),t("p",null,"Keine Rundgänge heute",-1)])])):(n(),s("div",Q,[t("table",W,[o[6]||(o[6]=t("thead",{class:"bg-gray-50"},[t("tr",null,[t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Zeit"),t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Mitarbeiter"),t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Checkpoint"),t("th",{class:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"},"Objekt")])],-1)),t("tbody",Z,[(n(!0),s(g,null,_(x.value,e=>(n(),s("tr",{key:e.id,class:"hover:bg-gray-50"},[t("td",G,a(b(e.scanned_at)),1),t("td",H,a(e.first_name)+" "+a(e.last_name),1),t("td",J,a(e.checkpoint_name),1),t("td",U,a(e.object_name),1)]))),128))])])]))])):v("",!0)]))}});export{tt as default}; diff --git a/dist/assets/QualificationsView-BbIklgwE.js b/dist/assets/QualificationsView-D_sQmuBz.js similarity index 93% rename from dist/assets/QualificationsView-BbIklgwE.js rename to dist/assets/QualificationsView-D_sQmuBz.js index 4df47c8..c7cdf26 100644 --- a/dist/assets/QualificationsView-BbIklgwE.js +++ b/dist/assets/QualificationsView-D_sQmuBz.js @@ -1 +1 @@ -import{d as R,u as X,q as Y,m as g,c as a,a as e,y as T,e as r,n as k,p as j,t as n,b as c,v as _,s as A,F as x,x as f,A as q,w as ee,r as d,k as N,o as l}from"./index-CWxNv9Fc.js";const te={class:"space-y-6"},ie={class:"flex items-center justify-between"},se={class:"flex gap-2 border-b dark:border-gray-700"},ae={key:0,class:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full"},le={key:0,class:"text-center py-12"},ne={key:1,class:"space-y-4"},oe={class:"card"},re={class:"grid grid-cols-1 md:grid-cols-4 gap-4"},de=["value"],ue=["value"],ce={key:0,class:"card text-center py-12 text-gray-500"},pe={key:1,class:"grid gap-4"},ve={class:"flex items-start justify-between"},xe={class:"flex items-start gap-4"},fe={class:"text-3xl"},me={class:"font-semibold text-gray-900 dark:text-white"},ye={class:"text-sm text-gray-500"},ge={class:"flex flex-wrap gap-2 mt-2"},_e={key:0,class:"text-xs text-gray-500"},be={key:1,class:"text-xs text-gray-500"},ke={key:2,class:"text-xs text-gray-500"},he={key:0,class:"flex gap-2"},we=["onClick"],Qe=["onClick"],Ce={key:2,class:"space-y-6"},Ue={key:0,class:"space-y-4"},Ae={class:"text-lg font-semibold text-red-600 flex items-center gap-2"},Se={class:"grid gap-3"},Ve={class:"flex items-center justify-between"},Me={class:"flex items-center gap-3"},Le={class:"text-2xl"},$e={class:"font-medium"},Te={class:"text-sm text-gray-600 dark:text-gray-400"},Ne={class:"text-right"},Be={class:"text-sm text-gray-500"},De={key:1,class:"space-y-4"},Fe={class:"text-lg font-semibold text-yellow-600 flex items-center gap-2"},ze={class:"grid gap-3"},je={class:"flex items-center justify-between"},Ee={class:"flex items-center gap-3"},Ke={class:"text-2xl"},Oe={class:"font-medium"},Ge={class:"text-sm text-gray-600 dark:text-gray-400"},Ie={class:"text-right"},He={class:"text-sm font-medium text-yellow-600"},Pe={class:"text-sm text-gray-500"},We={key:2,class:"card text-center py-12"},Ze={key:3,class:"card"},Je={key:4,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/50"},Re={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto"},Xe={class:"p-6"},Ye={class:"text-xl font-semibold mb-4"},qe={key:0},et=["value"],tt={key:1},it={class:"grid grid-cols-1 gap-2 max-h-48 overflow-y-auto border dark:border-gray-600 rounded-lg p-2"},st={class:"text-xs font-medium text-gray-500 sticky top-0 bg-white dark:bg-gray-800 py-1"},at=["onClick"],lt={key:0,class:"text-sm text-blue-600 mt-1"},nt={class:"grid grid-cols-2 gap-4"},ot={class:"flex gap-3 pt-4"},rt=["disabled"],pt=R({__name:"QualificationsView",setup(dt){const S=X(),B=d(!0),D=d([]),m=d({system:[],custom:[],categories:[]}),u=d({expired:[],expiring_soon:[]}),V=d([]),h=d(""),w=d(""),Q=d(""),C=d(""),b=d(!1),y=d(null),o=d({user_id:"",qualification_type_id:"",org_qualification_type_id:"",issued_date:"",expiry_date:"",issuer:"",certificate_number:"",level:"",notes:""}),U=d(!1),v=d("list");Y(async()=>{await Promise.all([E(),M(),L(),K()]),B.value=!1});async function E(){try{const s=await g.get("/qualifications/types");m.value=s}catch(s){console.error("Failed to load types:",s)}}async function M(){try{D.value=await g.get("/qualifications")}catch(s){console.error("Failed to load qualifications:",s)}}async function L(){try{u.value=await g.get("/qualifications/expiring?days=30")}catch(s){console.error("Failed to load expiring:",s)}}async function K(){try{V.value=await g.get("/users")}catch(s){console.error("Failed to load users:",s)}}const F=N(()=>{let s=[...D.value];if(h.value&&(s=s.filter(t=>t.user_id===h.value)),w.value&&(s=s.filter(t=>t.category===w.value)),Q.value&&(s=s.filter(t=>t.expiry_status===Q.value)),C.value){const t=C.value.toLowerCase();s=s.filter(i=>i.qualification_name.toLowerCase().includes(t)||i.first_name.toLowerCase().includes(t)||i.last_name.toLowerCase().includes(t))}return s}),O=N(()=>[...m.value.system,...m.value.custom]);function G(){y.value=null,o.value={user_id:"",qualification_type_id:"",org_qualification_type_id:"",issued_date:"",expiry_date:"",issuer:"",certificate_number:"",level:"",notes:""},b.value=!0}function I(s){y.value=s,o.value={user_id:s.user_id,qualification_type_id:"",org_qualification_type_id:"",issued_date:s.issued_date||"",expiry_date:s.expiry_date||"",issuer:s.issuer||"",certificate_number:s.certificate_number||"",level:s.level||"",notes:""},b.value=!0}async function H(){if(!(!o.value.user_id||!o.value.qualification_type_id&&!o.value.org_qualification_type_id)){U.value=!0;try{y.value?await g.put(`/qualifications/${y.value.id}`,o.value):await g.post("/qualifications",o.value),b.value=!1,await M(),await L()}catch(s){console.error("Failed to save:",s)}finally{U.value=!1}}}async function P(s){if(confirm("Qualifikation wirklich löschen?"))try{await g.delete(`/qualifications/${s}`),await M(),await L()}catch(t){console.error("Failed to delete:",t)}}function W(s){switch(s){case"valid":return"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200";case"expiring_soon":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200";case"expired":return"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200";case"no_expiry":return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-200";default:return"bg-gray-100 text-gray-800"}}function Z(s){switch(s){case"valid":return"Gültig";case"expiring_soon":return"Läuft ab";case"expired":return"Abgelaufen";case"no_expiry":return"Unbefristet";default:return s}}function $(s){return s?new Date(s).toLocaleDateString("de-DE"):"-"}function J(s){s.source==="system"?(o.value.qualification_type_id=s.id,o.value.org_qualification_type_id=""):(o.value.org_qualification_type_id=s.id,o.value.qualification_type_id="")}const z=N(()=>{const s=o.value.qualification_type_id||o.value.org_qualification_type_id;if(!s)return"";const t=O.value.find(i=>i.id===s);return t?`${t.icon} ${t.name}`:""});return(s,t)=>(l(),a("div",te,[e("div",ie,[t[15]||(t[15]=e("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"},"🎓 Qualifikationen",-1)),T(S).canManageUsers?(l(),a("button",{key:0,onClick:G,class:"btn btn-primary"}," ➕ Qualifikation hinzufügen ")):r("",!0)]),e("div",se,[e("button",{onClick:t[0]||(t[0]=i=>v.value="list"),class:k(["px-4 py-2 font-medium border-b-2 transition-colors",v.value==="list"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"])}," 📋 Übersicht ",2),e("button",{onClick:t[1]||(t[1]=i=>v.value="expiring"),class:k(["px-4 py-2 font-medium border-b-2 transition-colors flex items-center gap-2",v.value==="expiring"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"])},[t[16]||(t[16]=j(" ⚠️ Ablaufend ",-1)),u.value.expired.length+u.value.expiring_soon.length>0?(l(),a("span",ae,n(u.value.expired.length+u.value.expiring_soon.length),1)):r("",!0)],2),T(S).canManageUsers?(l(),a("button",{key:0,onClick:t[2]||(t[2]=i=>v.value="matrix"),class:k(["px-4 py-2 font-medium border-b-2 transition-colors",v.value==="matrix"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"])}," 📊 Matrix ",2)):r("",!0)]),B.value?(l(),a("div",le,[...t[17]||(t[17]=[e("div",{class:"animate-spin text-4xl"},"⏳",-1),e("p",{class:"mt-2 text-gray-500"},"Lade Qualifikationen...",-1)])])):v.value==="list"?(l(),a("div",ne,[e("div",oe,[e("div",re,[e("div",null,[t[18]||(t[18]=e("label",{class:"block text-sm font-medium mb-1"},"🔍 Suche",-1)),c(e("input",{"onUpdate:modelValue":t[3]||(t[3]=i=>C.value=i),type:"text",class:"input",placeholder:"Name oder Qualifikation..."},null,512),[[_,C.value]])]),e("div",null,[t[20]||(t[20]=e("label",{class:"block text-sm font-medium mb-1"},"👤 Mitarbeiter",-1)),c(e("select",{"onUpdate:modelValue":t[4]||(t[4]=i=>h.value=i),class:"input"},[t[19]||(t[19]=e("option",{value:""},"Alle",-1)),(l(!0),a(x,null,f(V.value,i=>(l(),a("option",{key:i.id,value:i.id},n(i.first_name)+" "+n(i.last_name),9,de))),128))],512),[[A,h.value]])]),e("div",null,[t[22]||(t[22]=e("label",{class:"block text-sm font-medium mb-1"},"📂 Kategorie",-1)),c(e("select",{"onUpdate:modelValue":t[5]||(t[5]=i=>w.value=i),class:"input"},[t[21]||(t[21]=e("option",{value:""},"Alle",-1)),(l(!0),a(x,null,f(m.value.categories,i=>(l(),a("option",{key:i.key,value:i.key},n(i.icon)+" "+n(i.name),9,ue))),128))],512),[[A,w.value]])]),e("div",null,[t[24]||(t[24]=e("label",{class:"block text-sm font-medium mb-1"},"📊 Status",-1)),c(e("select",{"onUpdate:modelValue":t[6]||(t[6]=i=>Q.value=i),class:"input"},[...t[23]||(t[23]=[q('',5)])],512),[[A,Q.value]])])])]),F.value.length===0?(l(),a("div",ce," Keine Qualifikationen gefunden ")):(l(),a("div",pe,[(l(!0),a(x,null,f(F.value,i=>(l(),a("div",{key:i.id,class:"card hover:shadow-md transition-shadow"},[e("div",ve,[e("div",xe,[e("div",fe,n(i.icon),1),e("div",null,[e("h3",me,n(i.qualification_name),1),e("p",ye,n(i.first_name)+" "+n(i.last_name),1),e("div",ge,[e("span",{class:k(["px-2 py-0.5 rounded text-xs font-medium",W(i.expiry_status)])},n(Z(i.expiry_status)),3),i.expiry_date?(l(),a("span",_e," 📅 "+n($(i.expiry_date)),1)):r("",!0),i.issuer?(l(),a("span",be," 🏢 "+n(i.issuer),1)):r("",!0),i.certificate_number?(l(),a("span",ke," #"+n(i.certificate_number),1)):r("",!0)])])]),T(S).canManageUsers?(l(),a("div",he,[e("button",{onClick:p=>I(i),class:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"}," ✏️ ",8,we),e("button",{onClick:p=>P(i.id),class:"p-2 hover:bg-red-100 dark:hover:bg-red-900 rounded text-red-600"}," 🗑️ ",8,Qe)])):r("",!0)])]))),128))]))])):v.value==="expiring"?(l(),a("div",Ce,[u.value.expired.length>0?(l(),a("div",Ue,[e("h2",Ae," ❌ Abgelaufen ("+n(u.value.expired.length)+") ",1),e("div",Se,[(l(!0),a(x,null,f(u.value.expired,i=>(l(),a("div",{key:i.id,class:"card border-l-4 border-red-500 bg-red-50 dark:bg-red-900/20"},[e("div",Ve,[e("div",Me,[e("span",Le,n(i.icon),1),e("div",null,[e("p",$e,n(i.qualification_name),1),e("p",Te,n(i.first_name)+" "+n(i.last_name),1)])]),e("div",Ne,[t[25]||(t[25]=e("p",{class:"text-sm font-medium text-red-600"},"Abgelaufen",-1)),e("p",Be,n($(i.expiry_date)),1)])])]))),128))])])):r("",!0),u.value.expiring_soon.length>0?(l(),a("div",De,[e("h2",Fe," ⚠️ Läuft bald ab ("+n(u.value.expiring_soon.length)+") ",1),e("div",ze,[(l(!0),a(x,null,f(u.value.expiring_soon,i=>(l(),a("div",{key:i.id,class:"card border-l-4 border-yellow-500 bg-yellow-50 dark:bg-yellow-900/20"},[e("div",je,[e("div",Ee,[e("span",Ke,n(i.icon),1),e("div",null,[e("p",Oe,n(i.qualification_name),1),e("p",Ge,n(i.first_name)+" "+n(i.last_name),1)])]),e("div",Ie,[e("p",He," Noch "+n(i.days_until_expiry)+" Tage ",1),e("p",Pe,n($(i.expiry_date)),1)])])]))),128))])])):r("",!0),u.value.expired.length===0&&u.value.expiring_soon.length===0?(l(),a("div",We,[...t[26]||(t[26]=[e("div",{class:"text-4xl mb-4"},"✅",-1),e("p",{class:"text-lg font-medium text-green-600"},"Alles in Ordnung!",-1),e("p",{class:"text-gray-500"},"Keine ablaufenden Qualifikationen in den nächsten 30 Tagen.",-1)])])):r("",!0)])):v.value==="matrix"?(l(),a("div",Ze,[...t[27]||(t[27]=[e("p",{class:"text-gray-500 text-center py-12"},[j(" 📊 Qualifikations-Matrix wird geladen..."),e("br"),e("span",{class:"text-sm"},"Übersicht: Welcher Mitarbeiter hat welche Qualifikation")],-1)])])):r("",!0),b.value?(l(),a("div",Je,[e("div",Re,[e("div",Xe,[e("h2",Ye,n(y.value?"✏️ Qualifikation bearbeiten":"➕ Neue Qualifikation"),1),e("form",{onSubmit:ee(H,["prevent"]),class:"space-y-4"},[y.value?r("",!0):(l(),a("div",qe,[t[29]||(t[29]=e("label",{class:"block text-sm font-medium mb-1"},"Mitarbeiter *",-1)),c(e("select",{"onUpdate:modelValue":t[7]||(t[7]=i=>o.value.user_id=i),class:"input",required:""},[t[28]||(t[28]=e("option",{value:""},"Bitte wählen...",-1)),(l(!0),a(x,null,f(V.value,i=>(l(),a("option",{key:i.id,value:i.id},n(i.first_name)+" "+n(i.last_name),9,et))),128))],512),[[A,o.value.user_id]])])),y.value?r("",!0):(l(),a("div",tt,[t[30]||(t[30]=e("label",{class:"block text-sm font-medium mb-1"},"Qualifikation *",-1)),e("div",it,[(l(!0),a(x,null,f(m.value.categories,i=>(l(),a("div",{key:i.key,class:"space-y-1"},[e("p",st,n(i.icon)+" "+n(i.name),1),(l(!0),a(x,null,f([...m.value.system,...m.value.custom].filter(p=>p.category===i.key),p=>(l(),a("button",{key:p.id,type:"button",onClick:ut=>J(p),class:k(["w-full text-left px-3 py-2 rounded text-sm transition-colors",o.value.qualification_type_id===p.id||o.value.org_qualification_type_id===p.id?"bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200":"hover:bg-gray-100 dark:hover:bg-gray-700"])},n(p.icon)+" "+n(p.name),11,at))),128))]))),128))]),z.value?(l(),a("p",lt," Ausgewählt: "+n(z.value),1)):r("",!0)])),e("div",nt,[e("div",null,[t[31]||(t[31]=e("label",{class:"block text-sm font-medium mb-1"},"Ausstellungsdatum",-1)),c(e("input",{"onUpdate:modelValue":t[8]||(t[8]=i=>o.value.issued_date=i),type:"date",class:"input"},null,512),[[_,o.value.issued_date]])]),e("div",null,[t[32]||(t[32]=e("label",{class:"block text-sm font-medium mb-1"},"Ablaufdatum",-1)),c(e("input",{"onUpdate:modelValue":t[9]||(t[9]=i=>o.value.expiry_date=i),type:"date",class:"input"},null,512),[[_,o.value.expiry_date]])])]),e("div",null,[t[33]||(t[33]=e("label",{class:"block text-sm font-medium mb-1"},"Ausstellende Stelle",-1)),c(e("input",{"onUpdate:modelValue":t[10]||(t[10]=i=>o.value.issuer=i),type:"text",class:"input",placeholder:"z.B. IHK Berlin"},null,512),[[_,o.value.issuer]])]),e("div",null,[t[34]||(t[34]=e("label",{class:"block text-sm font-medium mb-1"},"Zertifikatsnummer",-1)),c(e("input",{"onUpdate:modelValue":t[11]||(t[11]=i=>o.value.certificate_number=i),type:"text",class:"input",placeholder:"Optional"},null,512),[[_,o.value.certificate_number]])]),e("div",null,[t[35]||(t[35]=e("label",{class:"block text-sm font-medium mb-1"},"Stufe/Level",-1)),c(e("input",{"onUpdate:modelValue":t[12]||(t[12]=i=>o.value.level=i),type:"text",class:"input",placeholder:"z.B. B2 (für Sprachen)"},null,512),[[_,o.value.level]])]),e("div",null,[t[36]||(t[36]=e("label",{class:"block text-sm font-medium mb-1"},"Notizen",-1)),c(e("textarea",{"onUpdate:modelValue":t[13]||(t[13]=i=>o.value.notes=i),class:"input",rows:"2",placeholder:"Optional"},null,512),[[_,o.value.notes]])]),e("div",ot,[e("button",{type:"button",onClick:t[14]||(t[14]=i=>b.value=!1),class:"btn flex-1"}," Abbrechen "),e("button",{type:"submit",disabled:U.value,class:"btn btn-primary flex-1"},n(U.value?"Speichern...":"Speichern"),9,rt)])],32)])])])):r("",!0)]))}});export{pt as default}; +import{d as R,u as X,q as Y,m as g,c as a,a as e,z as T,e as r,n as k,p as j,t as n,b as c,v as _,s as S,F as x,x as f,C as q,w as ee,r as d,k as N,o as l}from"./index-CgM2qJ96.js";const te={class:"space-y-6"},ie={class:"flex items-center justify-between"},se={class:"flex gap-2 border-b dark:border-gray-700"},ae={key:0,class:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full"},le={key:0,class:"text-center py-12"},ne={key:1,class:"space-y-4"},oe={class:"card"},re={class:"grid grid-cols-1 md:grid-cols-4 gap-4"},de=["value"],ue=["value"],ce={key:0,class:"card text-center py-12 text-gray-500"},pe={key:1,class:"grid gap-4"},ve={class:"flex items-start justify-between"},xe={class:"flex items-start gap-4"},fe={class:"text-3xl"},me={class:"font-semibold text-gray-900 dark:text-white"},ye={class:"text-sm text-gray-500"},ge={class:"flex flex-wrap gap-2 mt-2"},_e={key:0,class:"text-xs text-gray-500"},be={key:1,class:"text-xs text-gray-500"},ke={key:2,class:"text-xs text-gray-500"},he={key:0,class:"flex gap-2"},we=["onClick"],Qe=["onClick"],Ce={key:2,class:"space-y-6"},Ue={key:0,class:"space-y-4"},Se={class:"text-lg font-semibold text-red-600 flex items-center gap-2"},Ae={class:"grid gap-3"},Ve={class:"flex items-center justify-between"},Me={class:"flex items-center gap-3"},Le={class:"text-2xl"},$e={class:"font-medium"},Te={class:"text-sm text-gray-600 dark:text-gray-400"},Ne={class:"text-right"},Be={class:"text-sm text-gray-500"},De={key:1,class:"space-y-4"},Fe={class:"text-lg font-semibold text-yellow-600 flex items-center gap-2"},ze={class:"grid gap-3"},je={class:"flex items-center justify-between"},Ee={class:"flex items-center gap-3"},Ke={class:"text-2xl"},Oe={class:"font-medium"},Ge={class:"text-sm text-gray-600 dark:text-gray-400"},Ie={class:"text-right"},He={class:"text-sm font-medium text-yellow-600"},Pe={class:"text-sm text-gray-500"},We={key:2,class:"card text-center py-12"},Ze={key:3,class:"card"},Je={key:4,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/50"},Re={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto"},Xe={class:"p-6"},Ye={class:"text-xl font-semibold mb-4"},qe={key:0},et=["value"],tt={key:1},it={class:"grid grid-cols-1 gap-2 max-h-48 overflow-y-auto border dark:border-gray-600 rounded-lg p-2"},st={class:"text-xs font-medium text-gray-500 sticky top-0 bg-white dark:bg-gray-800 py-1"},at=["onClick"],lt={key:0,class:"text-sm text-blue-600 mt-1"},nt={class:"grid grid-cols-2 gap-4"},ot={class:"flex gap-3 pt-4"},rt=["disabled"],pt=R({__name:"QualificationsView",setup(dt){const A=X(),B=d(!0),D=d([]),m=d({system:[],custom:[],categories:[]}),u=d({expired:[],expiring_soon:[]}),V=d([]),h=d(""),w=d(""),Q=d(""),C=d(""),b=d(!1),y=d(null),o=d({user_id:"",qualification_type_id:"",org_qualification_type_id:"",issued_date:"",expiry_date:"",issuer:"",certificate_number:"",level:"",notes:""}),U=d(!1),v=d("list");Y(async()=>{await Promise.all([E(),M(),L(),K()]),B.value=!1});async function E(){try{const s=await g.get("/qualifications/types");m.value=s}catch(s){console.error("Failed to load types:",s)}}async function M(){try{D.value=await g.get("/qualifications")}catch(s){console.error("Failed to load qualifications:",s)}}async function L(){try{u.value=await g.get("/qualifications/expiring?days=30")}catch(s){console.error("Failed to load expiring:",s)}}async function K(){try{V.value=await g.get("/users")}catch(s){console.error("Failed to load users:",s)}}const F=N(()=>{let s=[...D.value];if(h.value&&(s=s.filter(t=>t.user_id===h.value)),w.value&&(s=s.filter(t=>t.category===w.value)),Q.value&&(s=s.filter(t=>t.expiry_status===Q.value)),C.value){const t=C.value.toLowerCase();s=s.filter(i=>i.qualification_name.toLowerCase().includes(t)||i.first_name.toLowerCase().includes(t)||i.last_name.toLowerCase().includes(t))}return s}),O=N(()=>[...m.value.system,...m.value.custom]);function G(){y.value=null,o.value={user_id:"",qualification_type_id:"",org_qualification_type_id:"",issued_date:"",expiry_date:"",issuer:"",certificate_number:"",level:"",notes:""},b.value=!0}function I(s){y.value=s,o.value={user_id:s.user_id,qualification_type_id:"",org_qualification_type_id:"",issued_date:s.issued_date||"",expiry_date:s.expiry_date||"",issuer:s.issuer||"",certificate_number:s.certificate_number||"",level:s.level||"",notes:""},b.value=!0}async function H(){if(!(!o.value.user_id||!o.value.qualification_type_id&&!o.value.org_qualification_type_id)){U.value=!0;try{y.value?await g.put(`/qualifications/${y.value.id}`,o.value):await g.post("/qualifications",o.value),b.value=!1,await M(),await L()}catch(s){console.error("Failed to save:",s)}finally{U.value=!1}}}async function P(s){if(confirm("Qualifikation wirklich löschen?"))try{await g.delete(`/qualifications/${s}`),await M(),await L()}catch(t){console.error("Failed to delete:",t)}}function W(s){switch(s){case"valid":return"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200";case"expiring_soon":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200";case"expired":return"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200";case"no_expiry":return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-200";default:return"bg-gray-100 text-gray-800"}}function Z(s){switch(s){case"valid":return"Gültig";case"expiring_soon":return"Läuft ab";case"expired":return"Abgelaufen";case"no_expiry":return"Unbefristet";default:return s}}function $(s){return s?new Date(s).toLocaleDateString("de-DE"):"-"}function J(s){s.source==="system"?(o.value.qualification_type_id=s.id,o.value.org_qualification_type_id=""):(o.value.org_qualification_type_id=s.id,o.value.qualification_type_id="")}const z=N(()=>{const s=o.value.qualification_type_id||o.value.org_qualification_type_id;if(!s)return"";const t=O.value.find(i=>i.id===s);return t?`${t.icon} ${t.name}`:""});return(s,t)=>(l(),a("div",te,[e("div",ie,[t[15]||(t[15]=e("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"},"🎓 Qualifikationen",-1)),T(A).canManageUsers?(l(),a("button",{key:0,onClick:G,class:"btn btn-primary"}," ➕ Qualifikation hinzufügen ")):r("",!0)]),e("div",se,[e("button",{onClick:t[0]||(t[0]=i=>v.value="list"),class:k(["px-4 py-2 font-medium border-b-2 transition-colors",v.value==="list"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"])}," 📋 Übersicht ",2),e("button",{onClick:t[1]||(t[1]=i=>v.value="expiring"),class:k(["px-4 py-2 font-medium border-b-2 transition-colors flex items-center gap-2",v.value==="expiring"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"])},[t[16]||(t[16]=j(" ⚠️ Ablaufend ",-1)),u.value.expired.length+u.value.expiring_soon.length>0?(l(),a("span",ae,n(u.value.expired.length+u.value.expiring_soon.length),1)):r("",!0)],2),T(A).canManageUsers?(l(),a("button",{key:0,onClick:t[2]||(t[2]=i=>v.value="matrix"),class:k(["px-4 py-2 font-medium border-b-2 transition-colors",v.value==="matrix"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"])}," 📊 Matrix ",2)):r("",!0)]),B.value?(l(),a("div",le,[...t[17]||(t[17]=[e("div",{class:"animate-spin text-4xl"},"⏳",-1),e("p",{class:"mt-2 text-gray-500"},"Lade Qualifikationen...",-1)])])):v.value==="list"?(l(),a("div",ne,[e("div",oe,[e("div",re,[e("div",null,[t[18]||(t[18]=e("label",{class:"block text-sm font-medium mb-1"},"🔍 Suche",-1)),c(e("input",{"onUpdate:modelValue":t[3]||(t[3]=i=>C.value=i),type:"text",class:"input",placeholder:"Name oder Qualifikation..."},null,512),[[_,C.value]])]),e("div",null,[t[20]||(t[20]=e("label",{class:"block text-sm font-medium mb-1"},"👤 Mitarbeiter",-1)),c(e("select",{"onUpdate:modelValue":t[4]||(t[4]=i=>h.value=i),class:"input"},[t[19]||(t[19]=e("option",{value:""},"Alle",-1)),(l(!0),a(x,null,f(V.value,i=>(l(),a("option",{key:i.id,value:i.id},n(i.first_name)+" "+n(i.last_name),9,de))),128))],512),[[S,h.value]])]),e("div",null,[t[22]||(t[22]=e("label",{class:"block text-sm font-medium mb-1"},"📂 Kategorie",-1)),c(e("select",{"onUpdate:modelValue":t[5]||(t[5]=i=>w.value=i),class:"input"},[t[21]||(t[21]=e("option",{value:""},"Alle",-1)),(l(!0),a(x,null,f(m.value.categories,i=>(l(),a("option",{key:i.key,value:i.key},n(i.icon)+" "+n(i.name),9,ue))),128))],512),[[S,w.value]])]),e("div",null,[t[24]||(t[24]=e("label",{class:"block text-sm font-medium mb-1"},"📊 Status",-1)),c(e("select",{"onUpdate:modelValue":t[6]||(t[6]=i=>Q.value=i),class:"input"},[...t[23]||(t[23]=[q('',5)])],512),[[S,Q.value]])])])]),F.value.length===0?(l(),a("div",ce," Keine Qualifikationen gefunden ")):(l(),a("div",pe,[(l(!0),a(x,null,f(F.value,i=>(l(),a("div",{key:i.id,class:"card hover:shadow-md transition-shadow"},[e("div",ve,[e("div",xe,[e("div",fe,n(i.icon),1),e("div",null,[e("h3",me,n(i.qualification_name),1),e("p",ye,n(i.first_name)+" "+n(i.last_name),1),e("div",ge,[e("span",{class:k(["px-2 py-0.5 rounded text-xs font-medium",W(i.expiry_status)])},n(Z(i.expiry_status)),3),i.expiry_date?(l(),a("span",_e," 📅 "+n($(i.expiry_date)),1)):r("",!0),i.issuer?(l(),a("span",be," 🏢 "+n(i.issuer),1)):r("",!0),i.certificate_number?(l(),a("span",ke," #"+n(i.certificate_number),1)):r("",!0)])])]),T(A).canManageUsers?(l(),a("div",he,[e("button",{onClick:p=>I(i),class:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"}," ✏️ ",8,we),e("button",{onClick:p=>P(i.id),class:"p-2 hover:bg-red-100 dark:hover:bg-red-900 rounded text-red-600"}," 🗑️ ",8,Qe)])):r("",!0)])]))),128))]))])):v.value==="expiring"?(l(),a("div",Ce,[u.value.expired.length>0?(l(),a("div",Ue,[e("h2",Se," ❌ Abgelaufen ("+n(u.value.expired.length)+") ",1),e("div",Ae,[(l(!0),a(x,null,f(u.value.expired,i=>(l(),a("div",{key:i.id,class:"card border-l-4 border-red-500 bg-red-50 dark:bg-red-900/20"},[e("div",Ve,[e("div",Me,[e("span",Le,n(i.icon),1),e("div",null,[e("p",$e,n(i.qualification_name),1),e("p",Te,n(i.first_name)+" "+n(i.last_name),1)])]),e("div",Ne,[t[25]||(t[25]=e("p",{class:"text-sm font-medium text-red-600"},"Abgelaufen",-1)),e("p",Be,n($(i.expiry_date)),1)])])]))),128))])])):r("",!0),u.value.expiring_soon.length>0?(l(),a("div",De,[e("h2",Fe," ⚠️ Läuft bald ab ("+n(u.value.expiring_soon.length)+") ",1),e("div",ze,[(l(!0),a(x,null,f(u.value.expiring_soon,i=>(l(),a("div",{key:i.id,class:"card border-l-4 border-yellow-500 bg-yellow-50 dark:bg-yellow-900/20"},[e("div",je,[e("div",Ee,[e("span",Ke,n(i.icon),1),e("div",null,[e("p",Oe,n(i.qualification_name),1),e("p",Ge,n(i.first_name)+" "+n(i.last_name),1)])]),e("div",Ie,[e("p",He," Noch "+n(i.days_until_expiry)+" Tage ",1),e("p",Pe,n($(i.expiry_date)),1)])])]))),128))])])):r("",!0),u.value.expired.length===0&&u.value.expiring_soon.length===0?(l(),a("div",We,[...t[26]||(t[26]=[e("div",{class:"text-4xl mb-4"},"✅",-1),e("p",{class:"text-lg font-medium text-green-600"},"Alles in Ordnung!",-1),e("p",{class:"text-gray-500"},"Keine ablaufenden Qualifikationen in den nächsten 30 Tagen.",-1)])])):r("",!0)])):v.value==="matrix"?(l(),a("div",Ze,[...t[27]||(t[27]=[e("p",{class:"text-gray-500 text-center py-12"},[j(" 📊 Qualifikations-Matrix wird geladen..."),e("br"),e("span",{class:"text-sm"},"Übersicht: Welcher Mitarbeiter hat welche Qualifikation")],-1)])])):r("",!0),b.value?(l(),a("div",Je,[e("div",Re,[e("div",Xe,[e("h2",Ye,n(y.value?"✏️ Qualifikation bearbeiten":"➕ Neue Qualifikation"),1),e("form",{onSubmit:ee(H,["prevent"]),class:"space-y-4"},[y.value?r("",!0):(l(),a("div",qe,[t[29]||(t[29]=e("label",{class:"block text-sm font-medium mb-1"},"Mitarbeiter *",-1)),c(e("select",{"onUpdate:modelValue":t[7]||(t[7]=i=>o.value.user_id=i),class:"input",required:""},[t[28]||(t[28]=e("option",{value:""},"Bitte wählen...",-1)),(l(!0),a(x,null,f(V.value,i=>(l(),a("option",{key:i.id,value:i.id},n(i.first_name)+" "+n(i.last_name),9,et))),128))],512),[[S,o.value.user_id]])])),y.value?r("",!0):(l(),a("div",tt,[t[30]||(t[30]=e("label",{class:"block text-sm font-medium mb-1"},"Qualifikation *",-1)),e("div",it,[(l(!0),a(x,null,f(m.value.categories,i=>(l(),a("div",{key:i.key,class:"space-y-1"},[e("p",st,n(i.icon)+" "+n(i.name),1),(l(!0),a(x,null,f([...m.value.system,...m.value.custom].filter(p=>p.category===i.key),p=>(l(),a("button",{key:p.id,type:"button",onClick:ut=>J(p),class:k(["w-full text-left px-3 py-2 rounded text-sm transition-colors",o.value.qualification_type_id===p.id||o.value.org_qualification_type_id===p.id?"bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200":"hover:bg-gray-100 dark:hover:bg-gray-700"])},n(p.icon)+" "+n(p.name),11,at))),128))]))),128))]),z.value?(l(),a("p",lt," Ausgewählt: "+n(z.value),1)):r("",!0)])),e("div",nt,[e("div",null,[t[31]||(t[31]=e("label",{class:"block text-sm font-medium mb-1"},"Ausstellungsdatum",-1)),c(e("input",{"onUpdate:modelValue":t[8]||(t[8]=i=>o.value.issued_date=i),type:"date",class:"input"},null,512),[[_,o.value.issued_date]])]),e("div",null,[t[32]||(t[32]=e("label",{class:"block text-sm font-medium mb-1"},"Ablaufdatum",-1)),c(e("input",{"onUpdate:modelValue":t[9]||(t[9]=i=>o.value.expiry_date=i),type:"date",class:"input"},null,512),[[_,o.value.expiry_date]])])]),e("div",null,[t[33]||(t[33]=e("label",{class:"block text-sm font-medium mb-1"},"Ausstellende Stelle",-1)),c(e("input",{"onUpdate:modelValue":t[10]||(t[10]=i=>o.value.issuer=i),type:"text",class:"input",placeholder:"z.B. IHK Berlin"},null,512),[[_,o.value.issuer]])]),e("div",null,[t[34]||(t[34]=e("label",{class:"block text-sm font-medium mb-1"},"Zertifikatsnummer",-1)),c(e("input",{"onUpdate:modelValue":t[11]||(t[11]=i=>o.value.certificate_number=i),type:"text",class:"input",placeholder:"Optional"},null,512),[[_,o.value.certificate_number]])]),e("div",null,[t[35]||(t[35]=e("label",{class:"block text-sm font-medium mb-1"},"Stufe/Level",-1)),c(e("input",{"onUpdate:modelValue":t[12]||(t[12]=i=>o.value.level=i),type:"text",class:"input",placeholder:"z.B. B2 (für Sprachen)"},null,512),[[_,o.value.level]])]),e("div",null,[t[36]||(t[36]=e("label",{class:"block text-sm font-medium mb-1"},"Notizen",-1)),c(e("textarea",{"onUpdate:modelValue":t[13]||(t[13]=i=>o.value.notes=i),class:"input",rows:"2",placeholder:"Optional"},null,512),[[_,o.value.notes]])]),e("div",ot,[e("button",{type:"button",onClick:t[14]||(t[14]=i=>b.value=!1),class:"btn flex-1"}," Abbrechen "),e("button",{type:"submit",disabled:U.value,class:"btn btn-primary flex-1"},n(U.value?"Speichern...":"Speichern"),9,rt)])],32)])])])):r("",!0)]))}});export{pt as default}; diff --git a/dist/assets/RegisterOrgView-CpcADoEU.js b/dist/assets/RegisterOrgView-CL8_vGlU.js similarity index 98% rename from dist/assets/RegisterOrgView-CpcADoEU.js rename to dist/assets/RegisterOrgView-CL8_vGlU.js index c2979dc..103b31a 100644 --- a/dist/assets/RegisterOrgView-CpcADoEU.js +++ b/dist/assets/RegisterOrgView-CL8_vGlU.js @@ -1 +1 @@ -import{d as T,h as U,c as n,a as t,n as C,b as o,v as u,e as g,i as B,j as L,w as M,t as j,r as l,k as z,l as O,o as r,m as R,f as $,p as E}from"./index-CWxNv9Fc.js";const D={class:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 py-12 px-4"},W={class:"max-w-lg w-full"},Z={class:"flex items-center justify-center mb-8"},A={class:"flex items-center"},F={class:"card"},q={key:0},G={class:"space-y-4"},H={class:"flex items-center gap-2"},I={key:0,class:"text-gray-400"},J={key:1,class:"text-green-500"},Q={key:2,class:"text-red-500"},X={key:0,class:"mt-1 text-xs text-red-500"},Y={class:"mt-6 flex justify-between"},ee=["disabled"],te={key:1},se={class:"grid grid-cols-2 gap-4"},le={key:0,class:"mt-1 text-xs text-red-500"},ae={key:0,class:"p-3 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 rounded-lg text-sm"},ne={class:"mt-6 flex justify-between"},re=["disabled"],ue=T({__name:"RegisterOrgView",setup(ie){const P=$(),d=l(1),c=l(!1),y=l(""),w=l(!1),m=l(null),p=l(""),i=l(""),x=l(""),v=l(""),b=l(""),f=l(""),k=l(""),h=l("");U(p,a=>{a&&!i.value&&(i.value=a.toLowerCase().replace(/[äöüß]/g,e=>({ä:"ae",ö:"oe",ü:"ue",ß:"ss"})[e]||e).replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,30))});let _;U(i,async a=>{clearTimeout(_),m.value=null,!(a.length<3)&&(w.value=!0,_=setTimeout(async()=>{try{const V=await(await fetch(`/api/organizations/check/${a}`)).json();m.value=V.available}catch{m.value=null}w.value=!1},500))});const S=z(()=>p.value.length>=2&&i.value.length>=3&&m.value===!0),N=z(()=>x.value.includes("@")&&v.value.length>=8&&v.value===b.value&&f.value.length>=2&&k.value.length>=2);async function K(){if(N.value){y.value="",c.value=!0;try{await R.post("/organizations/register",{name:p.value,slug:i.value,admin_email:x.value,admin_password:v.value,admin_first_name:f.value,admin_last_name:k.value,admin_phone:h.value||void 0}),P.push({name:"login",query:{registered:"true",org:i.value,email:x.value}})}catch(a){y.value=a instanceof Error?a.message:"Registrierung fehlgeschlagen"}finally{c.value=!1}}}return(a,e)=>{const V=O("router-link");return r(),n("div",D,[t("div",W,[e[22]||(e[22]=t("div",{class:"text-center mb-8"},[t("h1",{class:"text-4xl font-bold text-primary-600"},"🔐 SeCu"),t("p",{class:"mt-2 text-gray-600 dark:text-gray-400"},"Organisation registrieren")],-1)),t("div",Z,[t("div",A,[t("div",{class:C(["w-10 h-10 rounded-full flex items-center justify-center text-white font-bold",d.value>=1?"bg-primary-600":"bg-gray-300"])},"1",2),t("div",{class:C(["w-24 h-1 mx-2",d.value>=2?"bg-primary-600":"bg-gray-300"])},null,2),t("div",{class:C(["w-10 h-10 rounded-full flex items-center justify-center font-bold",d.value>=2?"bg-primary-600 text-white":"bg-gray-300 text-gray-600"])},"2",2)])]),t("div",F,[d.value===1?(r(),n("div",q,[e[14]||(e[14]=t("h2",{class:"text-xl font-semibold text-gray-900 dark:text-white mb-6"}," Ihre Organisation ",-1)),t("div",G,[t("div",null,[e[10]||(e[10]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Firmenname * ",-1)),o(t("input",{"onUpdate:modelValue":e[0]||(e[0]=s=>p.value=s),type:"text",class:"input",placeholder:"z.B. Muster Sicherheit GmbH"},null,512),[[u,p.value]])]),t("div",null,[e[11]||(e[11]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," URL-Kürzel * ",-1)),t("div",H,[o(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>i.value=s),type:"text",class:"input",placeholder:"muster-sicherheit"},null,512),[[u,i.value]]),w.value?(r(),n("span",I,"⏳")):m.value===!0?(r(),n("span",J,"✓")):m.value===!1?(r(),n("span",Q,"✗")):g("",!0)]),e[12]||(e[12]=t("p",{class:"mt-1 text-xs text-gray-500"}," Wird für den Login verwendet. Nur Kleinbuchstaben und Bindestriche. ",-1)),m.value===!1?(r(),n("p",X," Dieses Kürzel ist bereits vergeben. ")):g("",!0)])]),t("div",Y,[B(V,{to:"/login",class:"btn btn-secondary"},{default:L(()=>[...e[13]||(e[13]=[E(" ← Zurück zum Login ",-1)])]),_:1}),t("button",{onClick:e[2]||(e[2]=s=>d.value=2),disabled:!S.value,class:"btn btn-primary"}," Weiter → ",8,ee)])])):g("",!0),d.value===2?(r(),n("div",te,[e[21]||(e[21]=t("h2",{class:"text-xl font-semibold text-gray-900 dark:text-white mb-6"}," Administrator-Konto ",-1)),t("form",{onSubmit:M(K,["prevent"]),class:"space-y-4"},[t("div",se,[t("div",null,[e[15]||(e[15]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Vorname * ",-1)),o(t("input",{"onUpdate:modelValue":e[3]||(e[3]=s=>f.value=s),type:"text",class:"input"},null,512),[[u,f.value]])]),t("div",null,[e[16]||(e[16]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Nachname * ",-1)),o(t("input",{"onUpdate:modelValue":e[4]||(e[4]=s=>k.value=s),type:"text",class:"input"},null,512),[[u,k.value]])])]),t("div",null,[e[17]||(e[17]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," E-Mail * ",-1)),o(t("input",{"onUpdate:modelValue":e[5]||(e[5]=s=>x.value=s),type:"email",class:"input"},null,512),[[u,x.value]])]),t("div",null,[e[18]||(e[18]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Telefon ",-1)),o(t("input",{"onUpdate:modelValue":e[6]||(e[6]=s=>h.value=s),type:"tel",class:"input",placeholder:"Optional"},null,512),[[u,h.value]])]),t("div",null,[e[19]||(e[19]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Passwort * ",-1)),o(t("input",{"onUpdate:modelValue":e[7]||(e[7]=s=>v.value=s),type:"password",class:"input",placeholder:"Mindestens 8 Zeichen"},null,512),[[u,v.value]])]),t("div",null,[e[20]||(e[20]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Passwort bestätigen * ",-1)),o(t("input",{"onUpdate:modelValue":e[8]||(e[8]=s=>b.value=s),type:"password",class:"input"},null,512),[[u,b.value]]),v.value&&b.value&&v.value!==b.value?(r(),n("p",le," Passwörter stimmen nicht überein ")):g("",!0)]),y.value?(r(),n("div",ae,j(y.value),1)):g("",!0),t("div",ne,[t("button",{type:"button",onClick:e[9]||(e[9]=s=>d.value=1),class:"btn btn-secondary"}," ← Zurück "),t("button",{type:"submit",disabled:!N.value||c.value,class:"btn btn-primary"},j(c.value?"Wird erstellt...":"Organisation erstellen"),9,re)])],32)])):g("",!0)]),e[23]||(e[23]=t("div",{class:"mt-6 text-center text-sm text-gray-500 dark:text-gray-400"},[t("p",null,"Nach der Registrierung können Sie sofort loslegen."),t("p",{class:"mt-1"},"Kostenlos starten • Keine Kreditkarte nötig")],-1))])])}}});export{ue as default}; +import{d as T,h as U,c as n,a as t,n as C,b as o,v as u,e as g,i as B,j as L,w as M,t as j,r as l,k as z,l as O,m as R,f as $,o as r,p as E}from"./index-CgM2qJ96.js";const D={class:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 py-12 px-4"},W={class:"max-w-lg w-full"},Z={class:"flex items-center justify-center mb-8"},A={class:"flex items-center"},F={class:"card"},q={key:0},G={class:"space-y-4"},H={class:"flex items-center gap-2"},I={key:0,class:"text-gray-400"},J={key:1,class:"text-green-500"},Q={key:2,class:"text-red-500"},X={key:0,class:"mt-1 text-xs text-red-500"},Y={class:"mt-6 flex justify-between"},ee=["disabled"],te={key:1},se={class:"grid grid-cols-2 gap-4"},le={key:0,class:"mt-1 text-xs text-red-500"},ae={key:0,class:"p-3 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 rounded-lg text-sm"},ne={class:"mt-6 flex justify-between"},re=["disabled"],ue=T({__name:"RegisterOrgView",setup(ie){const P=$(),d=l(1),c=l(!1),y=l(""),w=l(!1),m=l(null),p=l(""),i=l(""),x=l(""),v=l(""),b=l(""),f=l(""),k=l(""),h=l("");U(p,a=>{a&&!i.value&&(i.value=a.toLowerCase().replace(/[äöüß]/g,e=>({ä:"ae",ö:"oe",ü:"ue",ß:"ss"})[e]||e).replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,30))});let _;U(i,async a=>{clearTimeout(_),m.value=null,!(a.length<3)&&(w.value=!0,_=setTimeout(async()=>{try{const V=await(await fetch(`/api/organizations/check/${a}`)).json();m.value=V.available}catch{m.value=null}w.value=!1},500))});const S=z(()=>p.value.length>=2&&i.value.length>=3&&m.value===!0),N=z(()=>x.value.includes("@")&&v.value.length>=8&&v.value===b.value&&f.value.length>=2&&k.value.length>=2);async function K(){if(N.value){y.value="",c.value=!0;try{await R.post("/organizations/register",{name:p.value,slug:i.value,admin_email:x.value,admin_password:v.value,admin_first_name:f.value,admin_last_name:k.value,admin_phone:h.value||void 0}),P.push({name:"login",query:{registered:"true",org:i.value,email:x.value}})}catch(a){y.value=a instanceof Error?a.message:"Registrierung fehlgeschlagen"}finally{c.value=!1}}}return(a,e)=>{const V=O("router-link");return r(),n("div",D,[t("div",W,[e[22]||(e[22]=t("div",{class:"text-center mb-8"},[t("h1",{class:"text-4xl font-bold text-primary-600"},"🔐 SeCu"),t("p",{class:"mt-2 text-gray-600 dark:text-gray-400"},"Organisation registrieren")],-1)),t("div",Z,[t("div",A,[t("div",{class:C(["w-10 h-10 rounded-full flex items-center justify-center text-white font-bold",d.value>=1?"bg-primary-600":"bg-gray-300"])},"1",2),t("div",{class:C(["w-24 h-1 mx-2",d.value>=2?"bg-primary-600":"bg-gray-300"])},null,2),t("div",{class:C(["w-10 h-10 rounded-full flex items-center justify-center font-bold",d.value>=2?"bg-primary-600 text-white":"bg-gray-300 text-gray-600"])},"2",2)])]),t("div",F,[d.value===1?(r(),n("div",q,[e[14]||(e[14]=t("h2",{class:"text-xl font-semibold text-gray-900 dark:text-white mb-6"}," Ihre Organisation ",-1)),t("div",G,[t("div",null,[e[10]||(e[10]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Firmenname * ",-1)),o(t("input",{"onUpdate:modelValue":e[0]||(e[0]=s=>p.value=s),type:"text",class:"input",placeholder:"z.B. Muster Sicherheit GmbH"},null,512),[[u,p.value]])]),t("div",null,[e[11]||(e[11]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," URL-Kürzel * ",-1)),t("div",H,[o(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>i.value=s),type:"text",class:"input",placeholder:"muster-sicherheit"},null,512),[[u,i.value]]),w.value?(r(),n("span",I,"⏳")):m.value===!0?(r(),n("span",J,"✓")):m.value===!1?(r(),n("span",Q,"✗")):g("",!0)]),e[12]||(e[12]=t("p",{class:"mt-1 text-xs text-gray-500"}," Wird für den Login verwendet. Nur Kleinbuchstaben und Bindestriche. ",-1)),m.value===!1?(r(),n("p",X," Dieses Kürzel ist bereits vergeben. ")):g("",!0)])]),t("div",Y,[B(V,{to:"/login",class:"btn btn-secondary"},{default:L(()=>[...e[13]||(e[13]=[E(" ← Zurück zum Login ",-1)])]),_:1}),t("button",{onClick:e[2]||(e[2]=s=>d.value=2),disabled:!S.value,class:"btn btn-primary"}," Weiter → ",8,ee)])])):g("",!0),d.value===2?(r(),n("div",te,[e[21]||(e[21]=t("h2",{class:"text-xl font-semibold text-gray-900 dark:text-white mb-6"}," Administrator-Konto ",-1)),t("form",{onSubmit:M(K,["prevent"]),class:"space-y-4"},[t("div",se,[t("div",null,[e[15]||(e[15]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Vorname * ",-1)),o(t("input",{"onUpdate:modelValue":e[3]||(e[3]=s=>f.value=s),type:"text",class:"input"},null,512),[[u,f.value]])]),t("div",null,[e[16]||(e[16]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Nachname * ",-1)),o(t("input",{"onUpdate:modelValue":e[4]||(e[4]=s=>k.value=s),type:"text",class:"input"},null,512),[[u,k.value]])])]),t("div",null,[e[17]||(e[17]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," E-Mail * ",-1)),o(t("input",{"onUpdate:modelValue":e[5]||(e[5]=s=>x.value=s),type:"email",class:"input"},null,512),[[u,x.value]])]),t("div",null,[e[18]||(e[18]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Telefon ",-1)),o(t("input",{"onUpdate:modelValue":e[6]||(e[6]=s=>h.value=s),type:"tel",class:"input",placeholder:"Optional"},null,512),[[u,h.value]])]),t("div",null,[e[19]||(e[19]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Passwort * ",-1)),o(t("input",{"onUpdate:modelValue":e[7]||(e[7]=s=>v.value=s),type:"password",class:"input",placeholder:"Mindestens 8 Zeichen"},null,512),[[u,v.value]])]),t("div",null,[e[20]||(e[20]=t("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Passwort bestätigen * ",-1)),o(t("input",{"onUpdate:modelValue":e[8]||(e[8]=s=>b.value=s),type:"password",class:"input"},null,512),[[u,b.value]]),v.value&&b.value&&v.value!==b.value?(r(),n("p",le," Passwörter stimmen nicht überein ")):g("",!0)]),y.value?(r(),n("div",ae,j(y.value),1)):g("",!0),t("div",ne,[t("button",{type:"button",onClick:e[9]||(e[9]=s=>d.value=1),class:"btn btn-secondary"}," ← Zurück "),t("button",{type:"submit",disabled:!N.value||c.value,class:"btn btn-primary"},j(c.value?"Wird erstellt...":"Organisation erstellen"),9,re)])],32)])):g("",!0)]),e[23]||(e[23]=t("div",{class:"mt-6 text-center text-sm text-gray-500 dark:text-gray-400"},[t("p",null,"Nach der Registrierung können Sie sofort loslegen."),t("p",{class:"mt-1"},"Kostenlos starten • Keine Kreditkarte nötig")],-1))])])}}});export{ue as default}; diff --git a/dist/assets/SettingsView-4DujBg5S.js b/dist/assets/SettingsView-CIJivDOn.js similarity index 98% rename from dist/assets/SettingsView-4DujBg5S.js rename to dist/assets/SettingsView-CIJivDOn.js index 67c8657..fa0dc0c 100644 --- a/dist/assets/SettingsView-4DujBg5S.js +++ b/dist/assets/SettingsView-CIJivDOn.js @@ -1 +1 @@ -import{d as E,q as U,o as n,c as r,a as e,n as P,t as c,e as b,F,x as D,r as i,u as j,y as A,w as K,b as N,v as _,z as q,k as z,m as Z}from"./index-CWxNv9Fc.js";const L={class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4"},T={class:"bg-white rounded-2xl shadow-xl w-full max-w-md overflow-hidden"},J={class:"bg-gradient-to-r from-purple-600 to-indigo-600 p-6 text-white"},R={class:"flex justify-between items-center"},W={class:"p-6"},G={key:0,class:"space-y-4"},H={class:"bg-gray-50 rounded-lg p-4 mb-4"},O={class:"flex items-center justify-between"},Q={class:"space-y-3"},X={class:"flex-1"},Y={class:"text-sm text-gray-500"},ee={key:0,class:"text-purple-600"},te={class:"flex-1"},se={class:"text-sm text-gray-500"},le={key:0,class:"text-purple-600"},ne={key:1,class:"text-center"},ie={class:"text-lg font-semibold mb-2"},re={class:"flex justify-center space-x-3 mb-8"},ae={key:0,class:"text-red-500 text-sm mb-4"},oe={class:"grid grid-cols-3 gap-3 max-w-xs mx-auto"},ue=["onClick"],de={key:2,class:"text-center py-8"},ce={key:0,class:"text-red-500 text-sm"},me=E({__name:"SecuritySettings",emits:["close"],setup(V,{emit:w}){const h=w,l=i("menu"),g=i(""),f=i(""),a=i(""),m=i(["","","","","",""]),v=i(0),u=i(!1),x=i(!1),S=i(!1),o=i("none");U(async()=>{if(x.value=!!localStorage.getItem("appPin"),u.value=!!localStorage.getItem("biometricCredentialId"),o.value=localStorage.getItem("lockMethod")||"none",window.PublicKeyCredential)try{S.value=await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}catch{S.value=!1}});function I(p){v.value<6&&(m.value[v.value]=p,v.value++,v.value===6&&(l.value==="setup-pin"?(g.value=m.value.join(""),s(),l.value="confirm-pin"):l.value==="confirm-pin"&&(f.value=m.value.join(""),C())))}function y(){v.value>0&&(v.value--,m.value[v.value]=""),a.value=""}function s(){m.value=["","","","","",""],v.value=0,a.value=""}function C(){g.value===f.value?(localStorage.setItem("appPin",g.value),localStorage.setItem("lockMethod","pin"),x.value=!0,o.value="pin",l.value="menu",g.value="",f.value="",s()):(a.value="PINs stimmen nicht überein",setTimeout(()=>{s(),l.value="setup-pin",g.value="",f.value=""},1e3))}async function $(){l.value="setup-biometric",a.value="";try{if(!window.PublicKeyCredential)throw new Error("WebAuthn nicht unterstützt");const p=new Uint8Array(16);crypto.getRandomValues(p);const t=await navigator.credentials.create({publicKey:{challenge:new Uint8Array(32),rp:{name:"SeCu",id:window.location.hostname},user:{id:p,name:localStorage.getItem("userEmail")||"user",displayName:"SeCu User"},pubKeyCredParams:[{type:"public-key",alg:-7},{type:"public-key",alg:-257}],authenticatorSelection:{authenticatorAttachment:"platform",userVerification:"required",residentKey:"preferred"},timeout:6e4,attestation:"none"}});if(t){const d=btoa(String.fromCharCode(...new Uint8Array(t.rawId)));localStorage.setItem("biometricCredentialId",d),localStorage.setItem("lockMethod","biometric"),u.value=!0,o.value="biometric",l.value="menu"}}catch(p){console.error("Biometric setup failed:",p),a.value=p.message||"Biometrie-Einrichtung fehlgeschlagen",l.value="menu"}}function k(){confirm("App-Sperre wirklich deaktivieren?")&&(localStorage.removeItem("appPin"),localStorage.removeItem("biometricCredentialId"),localStorage.removeItem("lockMethod"),x.value=!1,u.value=!1,o.value="none")}function M(p){localStorage.setItem("lockMethod",p),o.value=p}return(p,t)=>(n(),r("div",L,[e("div",T,[e("div",J,[e("div",R,[t[7]||(t[7]=e("h2",{class:"text-xl font-bold"},"🔐 App-Sicherheit",-1)),e("button",{onClick:t[0]||(t[0]=d=>h("close")),class:"text-white/70 hover:text-white"},"✕")])]),e("div",W,[l.value==="menu"?(n(),r("div",G,[t[14]||(t[14]=e("p",{class:"text-gray-600 text-sm mb-4"}," Schütze deine App mit Fingerabdruck, Face ID oder PIN. ",-1)),e("div",H,[e("div",O,[t[8]||(t[8]=e("span",{class:"text-gray-700"},"Aktueller Schutz:",-1)),e("span",{class:P(["px-3 py-1 rounded-full text-sm font-medium",o.value==="none"?"bg-red-100 text-red-700":"bg-green-100 text-green-700"])},c(o.value==="biometric"?"👆 Biometrie":o.value==="pin"?"🔢 PIN":"❌ Aus"),3)])]),e("div",Q,[S.value?(n(),r("button",{key:0,onClick:t[1]||(t[1]=d=>u.value?M("biometric"):$()),class:P(["w-full p-4 rounded-lg border-2 text-left transition flex items-center",o.value==="biometric"?"border-purple-500 bg-purple-50":"border-gray-200 hover:border-purple-300"])},[t[10]||(t[10]=e("span",{class:"text-2xl mr-4"},"👆",-1)),e("div",X,[t[9]||(t[9]=e("div",{class:"font-semibold"},"Fingerabdruck / Face ID",-1)),e("div",Y,c(u.value?"Eingerichtet":"Jetzt einrichten"),1)]),o.value==="biometric"?(n(),r("span",ee,"✓")):b("",!0)],2)):b("",!0),e("button",{onClick:t[2]||(t[2]=d=>x.value?M("pin"):l.value="setup-pin"),class:P(["w-full p-4 rounded-lg border-2 text-left transition flex items-center",o.value==="pin"?"border-purple-500 bg-purple-50":"border-gray-200 hover:border-purple-300"])},[t[12]||(t[12]=e("span",{class:"text-2xl mr-4"},"🔢",-1)),e("div",te,[t[11]||(t[11]=e("div",{class:"font-semibold"},"PIN-Code (6 Ziffern)",-1)),e("div",se,c(x.value?"Eingerichtet":"Jetzt einrichten"),1)]),o.value==="pin"?(n(),r("span",le,"✓")):b("",!0)],2),o.value!=="none"?(n(),r("button",{key:1,onClick:k,class:"w-full p-4 rounded-lg border-2 border-red-200 text-left transition flex items-center hover:border-red-300 hover:bg-red-50"},[...t[13]||(t[13]=[e("span",{class:"text-2xl mr-4"},"🔓",-1),e("div",{class:"flex-1"},[e("div",{class:"font-semibold text-red-700"},"Sperre deaktivieren"),e("div",{class:"text-sm text-gray-500"},"Nicht empfohlen")],-1)])])):b("",!0)]),x.value?(n(),r("button",{key:0,onClick:t[3]||(t[3]=d=>l.value="setup-pin"),class:"w-full text-center text-purple-600 text-sm hover:underline mt-4"}," PIN ändern ")):b("",!0)])):l.value==="setup-pin"||l.value==="confirm-pin"?(n(),r("div",ne,[e("h3",ie,c(l.value==="setup-pin"?"Neuen PIN eingeben":"PIN bestätigen"),1),t[15]||(t[15]=e("p",{class:"text-gray-500 text-sm mb-6"},"6 Ziffern",-1)),e("div",re,[(n(!0),r(F,null,D(m.value,(d,B)=>(n(),r("div",{key:B,class:P(["w-4 h-4 rounded-full transition-all",d?"bg-purple-600 scale-110":"bg-gray-300",a.value?"bg-red-400 animate-shake":""])},null,2))),128))]),a.value?(n(),r("p",ae,c(a.value),1)):b("",!0),e("div",oe,[(n(),r(F,null,D([1,2,3,4,5,6,7,8,9],d=>e("button",{key:d,onClick:B=>I(String(d)),class:"w-14 h-14 bg-gray-100 rounded-full text-xl font-semibold hover:bg-gray-200 transition"},c(d),9,ue)),64)),e("button",{onClick:t[4]||(t[4]=d=>{l.value="menu",s()}),class:"w-14 h-14 text-gray-500 text-sm"}," Zurück "),e("button",{onClick:t[5]||(t[5]=d=>I("0")),class:"w-14 h-14 bg-gray-100 rounded-full text-xl font-semibold hover:bg-gray-200 transition"}," 0 "),e("button",{onClick:y,class:"w-14 h-14 text-xl hover:bg-gray-100 rounded-full transition"}," ⌫ ")])])):l.value==="setup-biometric"?(n(),r("div",de,[t[16]||(t[16]=e("div",{class:"text-6xl mb-4 animate-pulse"},"👆",-1)),t[17]||(t[17]=e("h3",{class:"text-lg font-semibold mb-2"},"Biometrie einrichten",-1)),t[18]||(t[18]=e("p",{class:"text-gray-500 text-sm mb-4"}," Bitte Fingerabdruck scannen oder Face ID verwenden... ",-1)),a.value?(n(),r("p",ce,c(a.value),1)):b("",!0),e("button",{onClick:t[6]||(t[6]=d=>l.value="menu"),class:"mt-4 text-gray-500 text-sm hover:underline"}," Abbrechen ")])):b("",!0)])])]))}}),ve={class:"space-y-6"},pe={class:"card"},be={class:"grid grid-cols-2 gap-4"},ge={class:"font-medium"},fe={class:"font-medium"},xe={class:"font-medium capitalize"},ye={class:"card"},ke={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},we={class:"card"},he={key:0,class:"text-red-600 text-sm"},Se={key:1,class:"text-green-600 text-sm"},Pe=["disabled"],Ce=E({__name:"SettingsView",setup(V){const w=j(),h=i(""),l=i(""),g=i(""),f=i(!1),a=i(""),m=i(""),v=i(!1),u=i(null);U(()=>{var y;u.value=localStorage.getItem("lockMethod"),(y=w.user)!=null&&y.email&&localStorage.setItem("userEmail",w.user.email)});const x=z(()=>!u.value||u.value==="none"?"Deaktiviert":u.value==="biometric"?"Fingerabdruck / Face ID":u.value==="pin"?"PIN-Code":"Unbekannt"),S=z(()=>!u.value||u.value==="none"?"bg-red-100 text-red-700":"bg-green-100 text-green-700");async function o(){if(l.value!==g.value){m.value="Passwörter stimmen nicht überein";return}if(l.value.length<8){m.value="Passwort muss mindestens 8 Zeichen haben";return}f.value=!0,m.value="",a.value="";try{await Z.post("/auth/change-password",{currentPassword:h.value,newPassword:l.value}),a.value="Passwort erfolgreich geändert",h.value="",l.value="",g.value=""}catch(y){m.value=y instanceof Error?y.message:"Fehler beim Ändern"}finally{f.value=!1}}function I(){v.value=!1,u.value=localStorage.getItem("lockMethod")}return(y,s)=>{var C,$;return n(),r("div",ve,[s[15]||(s[15]=e("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"},"🔧 Einstellungen",-1)),e("div",pe,[s[7]||(s[7]=e("h2",{class:"text-lg font-semibold mb-4"},"👤 Profil",-1)),e("div",be,[e("div",null,[s[4]||(s[4]=e("label",{class:"block text-sm text-gray-500"},"Name",-1)),e("p",ge,c(A(w).fullName),1)]),e("div",null,[s[5]||(s[5]=e("label",{class:"block text-sm text-gray-500"},"E-Mail",-1)),e("p",fe,c((C=A(w).user)==null?void 0:C.email),1)]),e("div",null,[s[6]||(s[6]=e("label",{class:"block text-sm text-gray-500"},"Rolle",-1)),e("p",xe,c(($=A(w).user)==null?void 0:$.role),1)])])]),e("div",ye,[s[9]||(s[9]=e("h2",{class:"text-lg font-semibold mb-4"},"🔐 App-Sicherheit",-1)),s[10]||(s[10]=e("p",{class:"text-gray-600 text-sm mb-4"}," Schütze deine App mit Fingerabdruck, Face ID oder PIN. Bei jedem Öffnen der App musst du dich verifizieren. ",-1)),e("div",ke,[e("div",null,[s[8]||(s[8]=e("div",{class:"font-medium"},"App-Sperre",-1)),e("div",{class:P(["inline-block px-2 py-1 rounded text-sm mt-1",S.value])},c(x.value),3)]),e("button",{onClick:s[0]||(s[0]=k=>v.value=!0),class:"btn btn-primary"}," Konfigurieren ")])]),e("div",we,[s[14]||(s[14]=e("h2",{class:"text-lg font-semibold mb-4"},"🔑 Passwort ändern",-1)),e("form",{onSubmit:K(o,["prevent"]),class:"space-y-4 max-w-md"},[e("div",null,[s[11]||(s[11]=e("label",{class:"block text-sm font-medium mb-1"},"Aktuelles Passwort",-1)),N(e("input",{"onUpdate:modelValue":s[1]||(s[1]=k=>h.value=k),type:"password",required:"",class:"input"},null,512),[[_,h.value]])]),e("div",null,[s[12]||(s[12]=e("label",{class:"block text-sm font-medium mb-1"},"Neues Passwort",-1)),N(e("input",{"onUpdate:modelValue":s[2]||(s[2]=k=>l.value=k),type:"password",required:"",class:"input"},null,512),[[_,l.value]])]),e("div",null,[s[13]||(s[13]=e("label",{class:"block text-sm font-medium mb-1"},"Passwort bestätigen",-1)),N(e("input",{"onUpdate:modelValue":s[3]||(s[3]=k=>g.value=k),type:"password",required:"",class:"input"},null,512),[[_,g.value]])]),m.value?(n(),r("div",he,c(m.value),1)):b("",!0),a.value?(n(),r("div",Se,c(a.value),1)):b("",!0),e("button",{type:"submit",disabled:f.value,class:"btn btn-primary"},c(f.value?"Speichern...":"Passwort ändern"),9,Pe)],32)]),v.value?(n(),q(me,{key:0,onClose:I})):b("",!0)])}}});export{Ce as default}; +import{d as E,q as U,c as r,a as e,n as P,t as c,e as b,F,x as D,r as i,o as n,u as j,z as A,w as K,b as N,v as _,A as q,k as z,m as Z}from"./index-CgM2qJ96.js";const L={class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4"},T={class:"bg-white rounded-2xl shadow-xl w-full max-w-md overflow-hidden"},J={class:"bg-gradient-to-r from-purple-600 to-indigo-600 p-6 text-white"},R={class:"flex justify-between items-center"},W={class:"p-6"},G={key:0,class:"space-y-4"},H={class:"bg-gray-50 rounded-lg p-4 mb-4"},O={class:"flex items-center justify-between"},Q={class:"space-y-3"},X={class:"flex-1"},Y={class:"text-sm text-gray-500"},ee={key:0,class:"text-purple-600"},te={class:"flex-1"},se={class:"text-sm text-gray-500"},le={key:0,class:"text-purple-600"},ne={key:1,class:"text-center"},ie={class:"text-lg font-semibold mb-2"},re={class:"flex justify-center space-x-3 mb-8"},ae={key:0,class:"text-red-500 text-sm mb-4"},oe={class:"grid grid-cols-3 gap-3 max-w-xs mx-auto"},ue=["onClick"],de={key:2,class:"text-center py-8"},ce={key:0,class:"text-red-500 text-sm"},me=E({__name:"SecuritySettings",emits:["close"],setup(V,{emit:w}){const h=w,l=i("menu"),g=i(""),f=i(""),a=i(""),m=i(["","","","","",""]),v=i(0),u=i(!1),x=i(!1),S=i(!1),o=i("none");U(async()=>{if(x.value=!!localStorage.getItem("appPin"),u.value=!!localStorage.getItem("biometricCredentialId"),o.value=localStorage.getItem("lockMethod")||"none",window.PublicKeyCredential)try{S.value=await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}catch{S.value=!1}});function I(p){v.value<6&&(m.value[v.value]=p,v.value++,v.value===6&&(l.value==="setup-pin"?(g.value=m.value.join(""),s(),l.value="confirm-pin"):l.value==="confirm-pin"&&(f.value=m.value.join(""),C())))}function y(){v.value>0&&(v.value--,m.value[v.value]=""),a.value=""}function s(){m.value=["","","","","",""],v.value=0,a.value=""}function C(){g.value===f.value?(localStorage.setItem("appPin",g.value),localStorage.setItem("lockMethod","pin"),x.value=!0,o.value="pin",l.value="menu",g.value="",f.value="",s()):(a.value="PINs stimmen nicht überein",setTimeout(()=>{s(),l.value="setup-pin",g.value="",f.value=""},1e3))}async function $(){l.value="setup-biometric",a.value="";try{if(!window.PublicKeyCredential)throw new Error("WebAuthn nicht unterstützt");const p=new Uint8Array(16);crypto.getRandomValues(p);const t=await navigator.credentials.create({publicKey:{challenge:new Uint8Array(32),rp:{name:"SeCu",id:window.location.hostname},user:{id:p,name:localStorage.getItem("userEmail")||"user",displayName:"SeCu User"},pubKeyCredParams:[{type:"public-key",alg:-7},{type:"public-key",alg:-257}],authenticatorSelection:{authenticatorAttachment:"platform",userVerification:"required",residentKey:"preferred"},timeout:6e4,attestation:"none"}});if(t){const d=btoa(String.fromCharCode(...new Uint8Array(t.rawId)));localStorage.setItem("biometricCredentialId",d),localStorage.setItem("lockMethod","biometric"),u.value=!0,o.value="biometric",l.value="menu"}}catch(p){console.error("Biometric setup failed:",p),a.value=p.message||"Biometrie-Einrichtung fehlgeschlagen",l.value="menu"}}function k(){confirm("App-Sperre wirklich deaktivieren?")&&(localStorage.removeItem("appPin"),localStorage.removeItem("biometricCredentialId"),localStorage.removeItem("lockMethod"),x.value=!1,u.value=!1,o.value="none")}function M(p){localStorage.setItem("lockMethod",p),o.value=p}return(p,t)=>(n(),r("div",L,[e("div",T,[e("div",J,[e("div",R,[t[7]||(t[7]=e("h2",{class:"text-xl font-bold"},"🔐 App-Sicherheit",-1)),e("button",{onClick:t[0]||(t[0]=d=>h("close")),class:"text-white/70 hover:text-white"},"✕")])]),e("div",W,[l.value==="menu"?(n(),r("div",G,[t[14]||(t[14]=e("p",{class:"text-gray-600 text-sm mb-4"}," Schütze deine App mit Fingerabdruck, Face ID oder PIN. ",-1)),e("div",H,[e("div",O,[t[8]||(t[8]=e("span",{class:"text-gray-700"},"Aktueller Schutz:",-1)),e("span",{class:P(["px-3 py-1 rounded-full text-sm font-medium",o.value==="none"?"bg-red-100 text-red-700":"bg-green-100 text-green-700"])},c(o.value==="biometric"?"👆 Biometrie":o.value==="pin"?"🔢 PIN":"❌ Aus"),3)])]),e("div",Q,[S.value?(n(),r("button",{key:0,onClick:t[1]||(t[1]=d=>u.value?M("biometric"):$()),class:P(["w-full p-4 rounded-lg border-2 text-left transition flex items-center",o.value==="biometric"?"border-purple-500 bg-purple-50":"border-gray-200 hover:border-purple-300"])},[t[10]||(t[10]=e("span",{class:"text-2xl mr-4"},"👆",-1)),e("div",X,[t[9]||(t[9]=e("div",{class:"font-semibold"},"Fingerabdruck / Face ID",-1)),e("div",Y,c(u.value?"Eingerichtet":"Jetzt einrichten"),1)]),o.value==="biometric"?(n(),r("span",ee,"✓")):b("",!0)],2)):b("",!0),e("button",{onClick:t[2]||(t[2]=d=>x.value?M("pin"):l.value="setup-pin"),class:P(["w-full p-4 rounded-lg border-2 text-left transition flex items-center",o.value==="pin"?"border-purple-500 bg-purple-50":"border-gray-200 hover:border-purple-300"])},[t[12]||(t[12]=e("span",{class:"text-2xl mr-4"},"🔢",-1)),e("div",te,[t[11]||(t[11]=e("div",{class:"font-semibold"},"PIN-Code (6 Ziffern)",-1)),e("div",se,c(x.value?"Eingerichtet":"Jetzt einrichten"),1)]),o.value==="pin"?(n(),r("span",le,"✓")):b("",!0)],2),o.value!=="none"?(n(),r("button",{key:1,onClick:k,class:"w-full p-4 rounded-lg border-2 border-red-200 text-left transition flex items-center hover:border-red-300 hover:bg-red-50"},[...t[13]||(t[13]=[e("span",{class:"text-2xl mr-4"},"🔓",-1),e("div",{class:"flex-1"},[e("div",{class:"font-semibold text-red-700"},"Sperre deaktivieren"),e("div",{class:"text-sm text-gray-500"},"Nicht empfohlen")],-1)])])):b("",!0)]),x.value?(n(),r("button",{key:0,onClick:t[3]||(t[3]=d=>l.value="setup-pin"),class:"w-full text-center text-purple-600 text-sm hover:underline mt-4"}," PIN ändern ")):b("",!0)])):l.value==="setup-pin"||l.value==="confirm-pin"?(n(),r("div",ne,[e("h3",ie,c(l.value==="setup-pin"?"Neuen PIN eingeben":"PIN bestätigen"),1),t[15]||(t[15]=e("p",{class:"text-gray-500 text-sm mb-6"},"6 Ziffern",-1)),e("div",re,[(n(!0),r(F,null,D(m.value,(d,B)=>(n(),r("div",{key:B,class:P(["w-4 h-4 rounded-full transition-all",d?"bg-purple-600 scale-110":"bg-gray-300",a.value?"bg-red-400 animate-shake":""])},null,2))),128))]),a.value?(n(),r("p",ae,c(a.value),1)):b("",!0),e("div",oe,[(n(),r(F,null,D([1,2,3,4,5,6,7,8,9],d=>e("button",{key:d,onClick:B=>I(String(d)),class:"w-14 h-14 bg-gray-100 rounded-full text-xl font-semibold hover:bg-gray-200 transition"},c(d),9,ue)),64)),e("button",{onClick:t[4]||(t[4]=d=>{l.value="menu",s()}),class:"w-14 h-14 text-gray-500 text-sm"}," Zurück "),e("button",{onClick:t[5]||(t[5]=d=>I("0")),class:"w-14 h-14 bg-gray-100 rounded-full text-xl font-semibold hover:bg-gray-200 transition"}," 0 "),e("button",{onClick:y,class:"w-14 h-14 text-xl hover:bg-gray-100 rounded-full transition"}," ⌫ ")])])):l.value==="setup-biometric"?(n(),r("div",de,[t[16]||(t[16]=e("div",{class:"text-6xl mb-4 animate-pulse"},"👆",-1)),t[17]||(t[17]=e("h3",{class:"text-lg font-semibold mb-2"},"Biometrie einrichten",-1)),t[18]||(t[18]=e("p",{class:"text-gray-500 text-sm mb-4"}," Bitte Fingerabdruck scannen oder Face ID verwenden... ",-1)),a.value?(n(),r("p",ce,c(a.value),1)):b("",!0),e("button",{onClick:t[6]||(t[6]=d=>l.value="menu"),class:"mt-4 text-gray-500 text-sm hover:underline"}," Abbrechen ")])):b("",!0)])])]))}}),ve={class:"space-y-6"},pe={class:"card"},be={class:"grid grid-cols-2 gap-4"},ge={class:"font-medium"},fe={class:"font-medium"},xe={class:"font-medium capitalize"},ye={class:"card"},ke={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},we={class:"card"},he={key:0,class:"text-red-600 text-sm"},Se={key:1,class:"text-green-600 text-sm"},Pe=["disabled"],Ce=E({__name:"SettingsView",setup(V){const w=j(),h=i(""),l=i(""),g=i(""),f=i(!1),a=i(""),m=i(""),v=i(!1),u=i(null);U(()=>{var y;u.value=localStorage.getItem("lockMethod"),(y=w.user)!=null&&y.email&&localStorage.setItem("userEmail",w.user.email)});const x=z(()=>!u.value||u.value==="none"?"Deaktiviert":u.value==="biometric"?"Fingerabdruck / Face ID":u.value==="pin"?"PIN-Code":"Unbekannt"),S=z(()=>!u.value||u.value==="none"?"bg-red-100 text-red-700":"bg-green-100 text-green-700");async function o(){if(l.value!==g.value){m.value="Passwörter stimmen nicht überein";return}if(l.value.length<8){m.value="Passwort muss mindestens 8 Zeichen haben";return}f.value=!0,m.value="",a.value="";try{await Z.post("/auth/change-password",{currentPassword:h.value,newPassword:l.value}),a.value="Passwort erfolgreich geändert",h.value="",l.value="",g.value=""}catch(y){m.value=y instanceof Error?y.message:"Fehler beim Ändern"}finally{f.value=!1}}function I(){v.value=!1,u.value=localStorage.getItem("lockMethod")}return(y,s)=>{var C,$;return n(),r("div",ve,[s[15]||(s[15]=e("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"},"🔧 Einstellungen",-1)),e("div",pe,[s[7]||(s[7]=e("h2",{class:"text-lg font-semibold mb-4"},"👤 Profil",-1)),e("div",be,[e("div",null,[s[4]||(s[4]=e("label",{class:"block text-sm text-gray-500"},"Name",-1)),e("p",ge,c(A(w).fullName),1)]),e("div",null,[s[5]||(s[5]=e("label",{class:"block text-sm text-gray-500"},"E-Mail",-1)),e("p",fe,c((C=A(w).user)==null?void 0:C.email),1)]),e("div",null,[s[6]||(s[6]=e("label",{class:"block text-sm text-gray-500"},"Rolle",-1)),e("p",xe,c(($=A(w).user)==null?void 0:$.role),1)])])]),e("div",ye,[s[9]||(s[9]=e("h2",{class:"text-lg font-semibold mb-4"},"🔐 App-Sicherheit",-1)),s[10]||(s[10]=e("p",{class:"text-gray-600 text-sm mb-4"}," Schütze deine App mit Fingerabdruck, Face ID oder PIN. Bei jedem Öffnen der App musst du dich verifizieren. ",-1)),e("div",ke,[e("div",null,[s[8]||(s[8]=e("div",{class:"font-medium"},"App-Sperre",-1)),e("div",{class:P(["inline-block px-2 py-1 rounded text-sm mt-1",S.value])},c(x.value),3)]),e("button",{onClick:s[0]||(s[0]=k=>v.value=!0),class:"btn btn-primary"}," Konfigurieren ")])]),e("div",we,[s[14]||(s[14]=e("h2",{class:"text-lg font-semibold mb-4"},"🔑 Passwort ändern",-1)),e("form",{onSubmit:K(o,["prevent"]),class:"space-y-4 max-w-md"},[e("div",null,[s[11]||(s[11]=e("label",{class:"block text-sm font-medium mb-1"},"Aktuelles Passwort",-1)),N(e("input",{"onUpdate:modelValue":s[1]||(s[1]=k=>h.value=k),type:"password",required:"",class:"input"},null,512),[[_,h.value]])]),e("div",null,[s[12]||(s[12]=e("label",{class:"block text-sm font-medium mb-1"},"Neues Passwort",-1)),N(e("input",{"onUpdate:modelValue":s[2]||(s[2]=k=>l.value=k),type:"password",required:"",class:"input"},null,512),[[_,l.value]])]),e("div",null,[s[13]||(s[13]=e("label",{class:"block text-sm font-medium mb-1"},"Passwort bestätigen",-1)),N(e("input",{"onUpdate:modelValue":s[3]||(s[3]=k=>g.value=k),type:"password",required:"",class:"input"},null,512),[[_,g.value]])]),m.value?(n(),r("div",he,c(m.value),1)):b("",!0),a.value?(n(),r("div",Se,c(a.value),1)):b("",!0),e("button",{type:"submit",disabled:f.value,class:"btn btn-primary"},c(f.value?"Speichern...":"Passwort ändern"),9,Pe)],32)]),v.value?(n(),q(me,{key:0,onClose:I})):b("",!0)])}}});export{Ce as default}; diff --git a/dist/assets/ShiftsView-Qxa8m19e.js b/dist/assets/ShiftsView-Qxa8m19e.js new file mode 100644 index 0000000..1513dec --- /dev/null +++ b/dist/assets/ShiftsView-Qxa8m19e.js @@ -0,0 +1 @@ +import{d as B,q as $,m as x,c as i,a as t,F as h,x as k,e as S,t as r,b as c,v,r as d,k as N,E as C,o}from"./index-CgM2qJ96.js";const U={class:"p-6"},j={class:"flex justify-between items-center mb-6"},L={class:"bg-white rounded-lg shadow p-4 mb-6"},M={class:"flex flex-wrap gap-2"},z={key:0,class:"text-gray-500"},A={class:"bg-white rounded-lg shadow overflow-hidden"},T={class:"flex items-center justify-between p-4 border-b"},W={class:"font-semibold"},P={class:"grid grid-cols-7 divide-x"},R={class:"text-xs font-semibold text-gray-500 mb-2"},q={key:0,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},I={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},K={class:"space-y-4"},O={class:"grid grid-cols-2 gap-4"},G={class:"grid grid-cols-2 gap-4"},H={class:"flex justify-end space-x-2 mt-6"},X=B({__name:"ShiftsView",setup(J){const D=d(!0),p=d([]),w=d([]),f=d(!1),u=d(new Date),l=d({name:"",start_time:"06:00",end_time:"14:00",break_minutes:30,color:"#3B82F6",is_night_shift:!1});$(async()=>{await b()});async function b(){D.value=!0;try{const[n,e]=await Promise.all([x.get("/shifts/definitions"),x.get(`/shifts/assignments?start=${y(g())}&end=${y(_())}`)]);p.value=n.data.shifts||[],w.value=e.data.assignments||[]}catch(n){console.error(n)}D.value=!1}function g(){const n=new Date(u.value);return n.setDate(n.getDate()-n.getDay()+1),n}function _(){const n=new Date(g());return n.setDate(n.getDate()+6),n}function y(n){return n.toISOString().split("T")[0]}const V=N(()=>{const n=[],e=g();for(let s=0;s<7;s++){const a=new Date(e);a.setDate(a.getDate()+s),n.push({date:y(a),label:a.toLocaleDateString("de-DE",{weekday:"short",day:"2-digit"})})}return n});async function E(){try{await x.post("/shifts/definitions",l.value),f.value=!1,l.value={name:"",start_time:"06:00",end_time:"14:00",break_minutes:30,color:"#3B82F6",is_night_shift:!1},await b()}catch(n){alert("Fehler: "+n.message)}}function F(n){return w.value.filter(e=>e.date===n)}return(n,e)=>(o(),i("div",U,[t("div",j,[e[9]||(e[9]=t("div",null,[t("h1",{class:"text-2xl font-bold"},"📅 Schichtplanung"),t("p",{class:"text-gray-500"},"Dienstpläne verwalten")],-1)),t("button",{onClick:e[0]||(e[0]=s=>f.value=!0),class:"btn btn-primary"},"+ Schicht definieren")]),t("div",L,[e[10]||(e[10]=t("h2",{class:"font-semibold mb-3"},"Schicht-Typen",-1)),t("div",M,[(o(!0),i(h,null,k(p.value,s=>{var a,m;return o(),i("div",{key:s.id,style:C({backgroundColor:s.color+"20",borderColor:s.color}),class:"px-3 py-1 rounded-full border text-sm"},r(s.name)+" ("+r((a=s.start_time)==null?void 0:a.slice(0,5))+" - "+r((m=s.end_time)==null?void 0:m.slice(0,5))+") ",5)}),128)),p.value.length===0?(o(),i("div",z,"Keine Schichten definiert")):S("",!0)])]),t("div",A,[t("div",T,[t("button",{onClick:e[1]||(e[1]=s=>{u.value.setDate(u.value.getDate()-7),b()}),class:"text-gray-600 hover:text-gray-900"},"← Vorherige"),t("span",W,r(g().toLocaleDateString("de-DE"))+" - "+r(_().toLocaleDateString("de-DE")),1),t("button",{onClick:e[2]||(e[2]=s=>{u.value.setDate(u.value.getDate()+7),b()}),class:"text-gray-600 hover:text-gray-900"},"Nächste →")]),t("div",P,[(o(!0),i(h,null,k(V.value,s=>(o(),i("div",{key:s.date,class:"min-h-32 p-2"},[t("div",R,r(s.label),1),(o(!0),i(h,null,k(F(s.date),a=>{var m;return o(),i("div",{key:a.id,style:C({backgroundColor:a.color+"40"}),class:"text-xs p-1 rounded mb-1"},r(a.first_name)+" "+r((m=a.last_name)==null?void 0:m.charAt(0))+". ",5)}),128))]))),128))])]),f.value?(o(),i("div",q,[t("div",I,[e[16]||(e[16]=t("h2",{class:"text-xl font-bold mb-4"},"Neue Schicht definieren",-1)),t("div",K,[t("div",null,[e[11]||(e[11]=t("label",{class:"block text-sm font-medium mb-1"},"Name",-1)),c(t("input",{"onUpdate:modelValue":e[3]||(e[3]=s=>l.value.name=s),class:"input",placeholder:"z.B. Frühschicht"},null,512),[[v,l.value.name]])]),t("div",O,[t("div",null,[e[12]||(e[12]=t("label",{class:"block text-sm font-medium mb-1"},"Beginn",-1)),c(t("input",{"onUpdate:modelValue":e[4]||(e[4]=s=>l.value.start_time=s),type:"time",class:"input"},null,512),[[v,l.value.start_time]])]),t("div",null,[e[13]||(e[13]=t("label",{class:"block text-sm font-medium mb-1"},"Ende",-1)),c(t("input",{"onUpdate:modelValue":e[5]||(e[5]=s=>l.value.end_time=s),type:"time",class:"input"},null,512),[[v,l.value.end_time]])])]),t("div",G,[t("div",null,[e[14]||(e[14]=t("label",{class:"block text-sm font-medium mb-1"},"Pause (Min.)",-1)),c(t("input",{"onUpdate:modelValue":e[6]||(e[6]=s=>l.value.break_minutes=s),type:"number",class:"input"},null,512),[[v,l.value.break_minutes,void 0,{number:!0}]])]),t("div",null,[e[15]||(e[15]=t("label",{class:"block text-sm font-medium mb-1"},"Farbe",-1)),c(t("input",{"onUpdate:modelValue":e[7]||(e[7]=s=>l.value.color=s),type:"color",class:"w-full h-10 rounded"},null,512),[[v,l.value.color]])])])]),t("div",H,[t("button",{onClick:e[8]||(e[8]=s=>f.value=!1),class:"btn"},"Abbrechen"),t("button",{onClick:E,class:"btn btn-primary"},"Erstellen")])])])):S("",!0)]))}});export{X as default}; diff --git a/dist/assets/ShiftsView-gFZrEy1d.js b/dist/assets/ShiftsView-gFZrEy1d.js deleted file mode 100644 index 4caf7ad..0000000 --- a/dist/assets/ShiftsView-gFZrEy1d.js +++ /dev/null @@ -1 +0,0 @@ -import{d as E,q as $,m as x,c as i,a as t,F as h,x as k,e as S,t as r,b as c,v,r as d,k as N,o,C}from"./index-CWxNv9Fc.js";const U={class:"p-6"},j={class:"flex justify-between items-center mb-6"},L={class:"bg-white rounded-lg shadow p-4 mb-6"},M={class:"flex flex-wrap gap-2"},z={key:0,class:"text-gray-500"},A={class:"bg-white rounded-lg shadow overflow-hidden"},T={class:"flex items-center justify-between p-4 border-b"},W={class:"font-semibold"},P={class:"grid grid-cols-7 divide-x"},R={class:"text-xs font-semibold text-gray-500 mb-2"},q={key:0,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},I={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},K={class:"space-y-4"},O={class:"grid grid-cols-2 gap-4"},G={class:"grid grid-cols-2 gap-4"},H={class:"flex justify-end space-x-2 mt-6"},X=E({__name:"ShiftsView",setup(J){const D=d(!0),p=d([]),w=d([]),f=d(!1),u=d(new Date),l=d({name:"",start_time:"06:00",end_time:"14:00",break_minutes:30,color:"#3B82F6",is_night_shift:!1});$(async()=>{await b()});async function b(){D.value=!0;try{const[n,e]=await Promise.all([x.get("/shifts/definitions"),x.get(`/shifts/assignments?start=${y(g())}&end=${y(_())}`)]);p.value=n.data.shifts||[],w.value=e.data.assignments||[]}catch(n){console.error(n)}D.value=!1}function g(){const n=new Date(u.value);return n.setDate(n.getDate()-n.getDay()+1),n}function _(){const n=new Date(g());return n.setDate(n.getDate()+6),n}function y(n){return n.toISOString().split("T")[0]}const V=N(()=>{const n=[],e=g();for(let s=0;s<7;s++){const a=new Date(e);a.setDate(a.getDate()+s),n.push({date:y(a),label:a.toLocaleDateString("de-DE",{weekday:"short",day:"2-digit"})})}return n});async function F(){try{await x.post("/shifts/definitions",l.value),f.value=!1,l.value={name:"",start_time:"06:00",end_time:"14:00",break_minutes:30,color:"#3B82F6",is_night_shift:!1},await b()}catch(n){alert("Fehler: "+n.message)}}function B(n){return w.value.filter(e=>e.date===n)}return(n,e)=>(o(),i("div",U,[t("div",j,[e[9]||(e[9]=t("div",null,[t("h1",{class:"text-2xl font-bold"},"📅 Schichtplanung"),t("p",{class:"text-gray-500"},"Dienstpläne verwalten")],-1)),t("button",{onClick:e[0]||(e[0]=s=>f.value=!0),class:"btn btn-primary"},"+ Schicht definieren")]),t("div",L,[e[10]||(e[10]=t("h2",{class:"font-semibold mb-3"},"Schicht-Typen",-1)),t("div",M,[(o(!0),i(h,null,k(p.value,s=>{var a,m;return o(),i("div",{key:s.id,style:C({backgroundColor:s.color+"20",borderColor:s.color}),class:"px-3 py-1 rounded-full border text-sm"},r(s.name)+" ("+r((a=s.start_time)==null?void 0:a.slice(0,5))+" - "+r((m=s.end_time)==null?void 0:m.slice(0,5))+") ",5)}),128)),p.value.length===0?(o(),i("div",z,"Keine Schichten definiert")):S("",!0)])]),t("div",A,[t("div",T,[t("button",{onClick:e[1]||(e[1]=s=>{u.value.setDate(u.value.getDate()-7),b()}),class:"text-gray-600 hover:text-gray-900"},"← Vorherige"),t("span",W,r(g().toLocaleDateString("de-DE"))+" - "+r(_().toLocaleDateString("de-DE")),1),t("button",{onClick:e[2]||(e[2]=s=>{u.value.setDate(u.value.getDate()+7),b()}),class:"text-gray-600 hover:text-gray-900"},"Nächste →")]),t("div",P,[(o(!0),i(h,null,k(V.value,s=>(o(),i("div",{key:s.date,class:"min-h-32 p-2"},[t("div",R,r(s.label),1),(o(!0),i(h,null,k(B(s.date),a=>{var m;return o(),i("div",{key:a.id,style:C({backgroundColor:a.color+"40"}),class:"text-xs p-1 rounded mb-1"},r(a.first_name)+" "+r((m=a.last_name)==null?void 0:m.charAt(0))+". ",5)}),128))]))),128))])]),f.value?(o(),i("div",q,[t("div",I,[e[16]||(e[16]=t("h2",{class:"text-xl font-bold mb-4"},"Neue Schicht definieren",-1)),t("div",K,[t("div",null,[e[11]||(e[11]=t("label",{class:"block text-sm font-medium mb-1"},"Name",-1)),c(t("input",{"onUpdate:modelValue":e[3]||(e[3]=s=>l.value.name=s),class:"input",placeholder:"z.B. Frühschicht"},null,512),[[v,l.value.name]])]),t("div",O,[t("div",null,[e[12]||(e[12]=t("label",{class:"block text-sm font-medium mb-1"},"Beginn",-1)),c(t("input",{"onUpdate:modelValue":e[4]||(e[4]=s=>l.value.start_time=s),type:"time",class:"input"},null,512),[[v,l.value.start_time]])]),t("div",null,[e[13]||(e[13]=t("label",{class:"block text-sm font-medium mb-1"},"Ende",-1)),c(t("input",{"onUpdate:modelValue":e[5]||(e[5]=s=>l.value.end_time=s),type:"time",class:"input"},null,512),[[v,l.value.end_time]])])]),t("div",G,[t("div",null,[e[14]||(e[14]=t("label",{class:"block text-sm font-medium mb-1"},"Pause (Min.)",-1)),c(t("input",{"onUpdate:modelValue":e[6]||(e[6]=s=>l.value.break_minutes=s),type:"number",class:"input"},null,512),[[v,l.value.break_minutes,void 0,{number:!0}]])]),t("div",null,[e[15]||(e[15]=t("label",{class:"block text-sm font-medium mb-1"},"Farbe",-1)),c(t("input",{"onUpdate:modelValue":e[7]||(e[7]=s=>l.value.color=s),type:"color",class:"w-full h-10 rounded"},null,512),[[v,l.value.color]])])])]),t("div",H,[t("button",{onClick:e[8]||(e[8]=s=>f.value=!1),class:"btn"},"Abbrechen"),t("button",{onClick:F,class:"btn btn-primary"},"Erstellen")])])])):S("",!0)]))}});export{X as default}; diff --git a/dist/assets/TimesheetsView-Cx-KwgCo.js b/dist/assets/TimesheetsView-DmVkzXLM.js similarity index 90% rename from dist/assets/TimesheetsView-Cx-KwgCo.js rename to dist/assets/TimesheetsView-DmVkzXLM.js index 385de42..4132265 100644 --- a/dist/assets/TimesheetsView-Cx-KwgCo.js +++ b/dist/assets/TimesheetsView-DmVkzXLM.js @@ -1 +1 @@ -import{d as A,u as M,q as T,m,c as a,a as s,F as y,x as w,w as D,b as p,v as _,s as E,e as i,r as d,o as r,t as l,p as U,y as h,n as z}from"./index-CWxNv9Fc.js";const N={class:"space-y-6"},$={class:"flex items-center justify-between"},B={class:"card"},F={key:0,class:"text-center py-8 text-gray-500"},L={key:1,class:"text-center py-8 text-gray-500"},q={key:2,class:"space-y-3"},K={class:"font-medium"},G={class:"text-sm text-gray-500"},O={key:0},P={key:0,class:"text-sm text-gray-500"},H={key:1,class:"text-sm text-gray-500"},I={class:"flex items-center gap-2"},J=["onClick"],Q=["onClick"],R={key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/50"},W={class:"card w-full max-w-md m-4"},X={class:"grid grid-cols-2 gap-4"},Y=["value"],Z={class:"flex justify-end gap-3 pt-4"},se=A({__name:"TimesheetsView",setup(ee){const f=M(),v=d([]),b=d(!0),u=d(!1),o=d({work_date:"",start_time:"",end_time:"",order_id:""}),x=d([]);T(async()=>{await Promise.all([g(),S()])});async function g(){b.value=!0;try{const n=await m.get("/timesheets");v.value=n.data.timesheets}catch(n){console.error(n)}finally{b.value=!1}}async function S(){try{const n=await m.get("/orders");x.value=n.data.orders}catch(n){console.error(n)}}async function j(){try{await m.post("/timesheets",o.value),u.value=!1,o.value={work_date:"",start_time:"",end_time:"",order_id:""},await g()}catch(n){alert(n instanceof Error?n.message:"Fehler")}}async function k(n,e){const t=e==="rejected"?prompt("Ablehnungsgrund:"):null;if(!(e==="rejected"&&!t))try{await m.post(`/timesheets/${n}/review`,{status:e,rejection_reason:t}),await g()}catch(c){alert(c instanceof Error?c.message:"Fehler")}}function C(n){return{pending:"badge-warning",approved:"badge-success",rejected:"badge-danger"}[n]||""}function V(n){return{pending:"Ausstehend",approved:"Genehmigt",rejected:"Abgelehnt"}[n]||n}return(n,e)=>(r(),a("div",N,[s("div",$,[e[6]||(e[6]=s("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"},"⏱️ Stundenzettel",-1)),s("button",{class:"btn btn-primary",onClick:e[0]||(e[0]=t=>u.value=!0)},"+ Neu")]),s("div",B,[b.value?(r(),a("div",F,"Lädt...")):v.value.length===0?(r(),a("div",L,"Keine Stundenzettel")):(r(),a("div",q,[(r(!0),a(y,null,w(v.value,t=>(r(),a("div",{key:t.id,class:"flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg"},[s("div",null,[s("p",K,l(new Date(t.work_date).toLocaleDateString("de-DE")),1),s("p",G,[U(l(t.start_time)+" - "+l(t.end_time)+" ",1),t.hours_worked?(r(),a("span",O,"("+l(t.hours_worked)+"h)",1)):i("",!0)]),t.order_title?(r(),a("p",P,"📋 "+l(t.order_title),1)):i("",!0),h(f).canManageUsers?(r(),a("p",H,"👤 "+l(t.user_name),1)):i("",!0)]),s("div",I,[s("span",{class:z(["badge",C(t.status)])},l(V(t.status)),3),h(f).canManageUsers&&t.status==="pending"?(r(),a(y,{key:0},[s("button",{class:"btn btn-success text-sm",onClick:c=>k(t.id,"approved")},"✓",8,J),s("button",{class:"btn btn-danger text-sm",onClick:c=>k(t.id,"rejected")},"✗",8,Q)],64)):i("",!0)])]))),128))]))]),u.value?(r(),a("div",R,[s("div",W,[e[13]||(e[13]=s("h2",{class:"text-xl font-semibold mb-6"},"Neuer Stundenzettel",-1)),s("form",{onSubmit:D(j,["prevent"]),class:"space-y-4"},[s("div",null,[e[7]||(e[7]=s("label",{class:"block text-sm font-medium mb-1"},"Datum *",-1)),p(s("input",{"onUpdate:modelValue":e[1]||(e[1]=t=>o.value.work_date=t),type:"date",required:"",class:"input"},null,512),[[_,o.value.work_date]])]),s("div",X,[s("div",null,[e[8]||(e[8]=s("label",{class:"block text-sm font-medium mb-1"},"Start",-1)),p(s("input",{"onUpdate:modelValue":e[2]||(e[2]=t=>o.value.start_time=t),type:"time",class:"input"},null,512),[[_,o.value.start_time]])]),s("div",null,[e[9]||(e[9]=s("label",{class:"block text-sm font-medium mb-1"},"Ende",-1)),p(s("input",{"onUpdate:modelValue":e[3]||(e[3]=t=>o.value.end_time=t),type:"time",class:"input"},null,512),[[_,o.value.end_time]])])]),s("div",null,[e[11]||(e[11]=s("label",{class:"block text-sm font-medium mb-1"},"Auftrag",-1)),p(s("select",{"onUpdate:modelValue":e[4]||(e[4]=t=>o.value.order_id=t),class:"input"},[e[10]||(e[10]=s("option",{value:""},"-- Kein Auftrag --",-1)),(r(!0),a(y,null,w(x.value,t=>(r(),a("option",{key:t.id,value:t.id},"#"+l(t.number)+" - "+l(t.title),9,Y))),128))],512),[[E,o.value.order_id]])]),s("div",Z,[s("button",{type:"button",class:"btn btn-secondary",onClick:e[5]||(e[5]=t=>u.value=!1)},"Abbrechen"),e[12]||(e[12]=s("button",{type:"submit",class:"btn btn-primary"},"Einreichen",-1))])],32)])])):i("",!0)]))}});export{se as default}; +import{d as A,u as M,q as T,m,c as a,a as s,F as y,x as w,w as z,b as p,v as _,s as D,e as i,r as d,t as l,p as E,z as h,n as U,o as r}from"./index-CgM2qJ96.js";const N={class:"space-y-6"},$={class:"flex items-center justify-between"},B={class:"card"},F={key:0,class:"text-center py-8 text-gray-500"},L={key:1,class:"text-center py-8 text-gray-500"},q={key:2,class:"space-y-3"},K={class:"font-medium"},G={class:"text-sm text-gray-500"},O={key:0},P={key:0,class:"text-sm text-gray-500"},H={key:1,class:"text-sm text-gray-500"},I={class:"flex items-center gap-2"},J=["onClick"],Q=["onClick"],R={key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/50"},W={class:"card w-full max-w-md m-4"},X={class:"grid grid-cols-2 gap-4"},Y=["value"],Z={class:"flex justify-end gap-3 pt-4"},se=A({__name:"TimesheetsView",setup(ee){const f=M(),v=d([]),b=d(!0),u=d(!1),o=d({work_date:"",start_time:"",end_time:"",order_id:""}),x=d([]);T(async()=>{await Promise.all([g(),S()])});async function g(){b.value=!0;try{const n=await m.get("/timesheets");v.value=n.data.timesheets}catch(n){console.error(n)}finally{b.value=!1}}async function S(){try{const n=await m.get("/orders");x.value=n.data.orders}catch(n){console.error(n)}}async function j(){try{await m.post("/timesheets",o.value),u.value=!1,o.value={work_date:"",start_time:"",end_time:"",order_id:""},await g()}catch(n){alert(n instanceof Error?n.message:"Fehler")}}async function k(n,e){const t=e==="rejected"?prompt("Ablehnungsgrund:"):null;if(!(e==="rejected"&&!t))try{await m.post(`/timesheets/${n}/review`,{status:e,rejection_reason:t}),await g()}catch(c){alert(c instanceof Error?c.message:"Fehler")}}function C(n){return{pending:"badge-warning",approved:"badge-success",rejected:"badge-danger"}[n]||""}function V(n){return{pending:"Ausstehend",approved:"Genehmigt",rejected:"Abgelehnt"}[n]||n}return(n,e)=>(r(),a("div",N,[s("div",$,[e[6]||(e[6]=s("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"},"⏱️ Stundenzettel",-1)),s("button",{class:"btn btn-primary",onClick:e[0]||(e[0]=t=>u.value=!0)},"+ Neu")]),s("div",B,[b.value?(r(),a("div",F,"Lädt...")):v.value.length===0?(r(),a("div",L,"Keine Stundenzettel")):(r(),a("div",q,[(r(!0),a(y,null,w(v.value,t=>(r(),a("div",{key:t.id,class:"flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg"},[s("div",null,[s("p",K,l(new Date(t.work_date).toLocaleDateString("de-DE")),1),s("p",G,[E(l(t.start_time)+" - "+l(t.end_time)+" ",1),t.hours_worked?(r(),a("span",O,"("+l(t.hours_worked)+"h)",1)):i("",!0)]),t.order_title?(r(),a("p",P,"📋 "+l(t.order_title),1)):i("",!0),h(f).canManageUsers?(r(),a("p",H,"👤 "+l(t.user_name),1)):i("",!0)]),s("div",I,[s("span",{class:U(["badge",C(t.status)])},l(V(t.status)),3),h(f).canManageUsers&&t.status==="pending"?(r(),a(y,{key:0},[s("button",{class:"btn btn-success text-sm",onClick:c=>k(t.id,"approved")},"✓",8,J),s("button",{class:"btn btn-danger text-sm",onClick:c=>k(t.id,"rejected")},"✗",8,Q)],64)):i("",!0)])]))),128))]))]),u.value?(r(),a("div",R,[s("div",W,[e[13]||(e[13]=s("h2",{class:"text-xl font-semibold mb-6"},"Neuer Stundenzettel",-1)),s("form",{onSubmit:z(j,["prevent"]),class:"space-y-4"},[s("div",null,[e[7]||(e[7]=s("label",{class:"block text-sm font-medium mb-1"},"Datum *",-1)),p(s("input",{"onUpdate:modelValue":e[1]||(e[1]=t=>o.value.work_date=t),type:"date",required:"",class:"input"},null,512),[[_,o.value.work_date]])]),s("div",X,[s("div",null,[e[8]||(e[8]=s("label",{class:"block text-sm font-medium mb-1"},"Start",-1)),p(s("input",{"onUpdate:modelValue":e[2]||(e[2]=t=>o.value.start_time=t),type:"time",class:"input"},null,512),[[_,o.value.start_time]])]),s("div",null,[e[9]||(e[9]=s("label",{class:"block text-sm font-medium mb-1"},"Ende",-1)),p(s("input",{"onUpdate:modelValue":e[3]||(e[3]=t=>o.value.end_time=t),type:"time",class:"input"},null,512),[[_,o.value.end_time]])])]),s("div",null,[e[11]||(e[11]=s("label",{class:"block text-sm font-medium mb-1"},"Auftrag",-1)),p(s("select",{"onUpdate:modelValue":e[4]||(e[4]=t=>o.value.order_id=t),class:"input"},[e[10]||(e[10]=s("option",{value:""},"-- Kein Auftrag --",-1)),(r(!0),a(y,null,w(x.value,t=>(r(),a("option",{key:t.id,value:t.id},"#"+l(t.number)+" - "+l(t.title),9,Y))),128))],512),[[D,o.value.order_id]])]),s("div",Z,[s("button",{type:"button",class:"btn btn-secondary",onClick:e[5]||(e[5]=t=>u.value=!1)},"Abbrechen"),e[12]||(e[12]=s("button",{type:"submit",class:"btn btn-primary"},"Einreichen",-1))])],32)])])):i("",!0)]))}});export{se as default}; diff --git a/dist/assets/UsersView-Df5a9eIx.js b/dist/assets/UsersView-Bv4Sb2KQ.js similarity index 86% rename from dist/assets/UsersView-Df5a9eIx.js rename to dist/assets/UsersView-Bv4Sb2KQ.js index 1d8d308..91e176d 100644 --- a/dist/assets/UsersView-Df5a9eIx.js +++ b/dist/assets/UsersView-Bv4Sb2KQ.js @@ -1 +1 @@ -import{d as C,u as U,q as V,m,c as n,a as e,F as E,x as N,w as S,b as o,v as d,y as x,s as q,e as y,r as b,o as i,t as r,n as k}from"./index-CWxNv9Fc.js";const A={class:"space-y-6"},D={class:"flex items-center justify-between"},$={class:"card"},B={key:0,class:"text-center py-8 text-gray-500"},F={key:1,class:"text-center py-8 text-gray-500"},R={key:2,class:"w-full"},j={class:"py-3 font-medium"},L={class:"py-3 text-gray-500"},z={class:"py-3"},T={class:"py-3"},I={class:"py-3 text-right"},K=["onClick"],P={key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/50"},G={class:"card w-full max-w-md m-4"},H={class:"grid grid-cols-2 gap-4"},J={key:0},O={class:"flex justify-end gap-3 pt-4"},Y=C({__name:"UsersView",setup(Q){const f=U(),p=b([]),c=b(!0),u=b(!1),l=b({email:"",password:"",first_name:"",last_name:"",phone:"",role:"mitarbeiter"});V(async()=>{await v()});async function v(){c.value=!0;try{const a=await m.get("/users");p.value=a.data.users}catch(a){console.error(a)}finally{c.value=!1}}async function w(){try{await m.post("/users",l.value),u.value=!1,l.value={email:"",password:"",first_name:"",last_name:"",phone:"",role:"mitarbeiter"},await v()}catch(a){alert(a instanceof Error?a.message:"Fehler beim Erstellen")}}async function _(a){try{a.active?await m.delete(`/users/${a.id}`):await m.put(`/users/${a.id}`,{active:!0}),await v()}catch(t){alert(t instanceof Error?t.message:"Fehler")}}function h(a){return{chef:"badge-danger",disponent:"badge-primary",mitarbeiter:"badge-success"}[a]||"badge-secondary"}function M(a){return{chef:"Chef",disponent:"Disponent",mitarbeiter:"Mitarbeiter"}[a]||a}return(a,t)=>(i(),n("div",A,[e("div",D,[t[8]||(t[8]=e("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"},"👥 Mitarbeiter",-1)),e("button",{class:"btn btn-primary",onClick:t[0]||(t[0]=s=>u.value=!0)},"+ Neu")]),e("div",$,[c.value?(i(),n("div",B,"Lädt...")):p.value.length===0?(i(),n("div",F,"Keine Mitarbeiter")):(i(),n("table",R,[t[9]||(t[9]=e("thead",null,[e("tr",{class:"text-left text-sm text-gray-500 border-b border-gray-200 dark:border-gray-700"},[e("th",{class:"pb-3"},"Name"),e("th",{class:"pb-3"},"E-Mail"),e("th",{class:"pb-3"},"Rolle"),e("th",{class:"pb-3"},"Status"),e("th",{class:"pb-3"})])],-1)),e("tbody",null,[(i(!0),n(E,null,N(p.value,s=>{var g;return i(),n("tr",{key:s.id,class:"border-b border-gray-100 dark:border-gray-800"},[e("td",j,r(s.first_name)+" "+r(s.last_name),1),e("td",L,r(s.email),1),e("td",z,[e("span",{class:k(["badge",h(s.role)])},r(M(s.role)),3)]),e("td",T,[e("span",{class:k(s.active?"text-green-600":"text-red-600")},r(s.active?"Aktiv":"Inaktiv"),3)]),e("td",I,[s.id!==((g=x(f).user)==null?void 0:g.id)&&s.role!=="chef"?(i(),n("button",{key:0,class:"text-sm text-gray-500 hover:text-red-600",onClick:W=>_(s)},r(s.active?"Deaktivieren":"Aktivieren"),9,K)):y("",!0)])])}),128))])]))]),u.value?(i(),n("div",P,[e("div",G,[t[18]||(t[18]=e("h2",{class:"text-xl font-semibold mb-6"},"Neuer Mitarbeiter",-1)),e("form",{onSubmit:S(w,["prevent"]),class:"space-y-4"},[e("div",H,[e("div",null,[t[10]||(t[10]=e("label",{class:"block text-sm font-medium mb-1"},"Vorname *",-1)),o(e("input",{"onUpdate:modelValue":t[1]||(t[1]=s=>l.value.first_name=s),type:"text",required:"",class:"input"},null,512),[[d,l.value.first_name]])]),e("div",null,[t[11]||(t[11]=e("label",{class:"block text-sm font-medium mb-1"},"Nachname *",-1)),o(e("input",{"onUpdate:modelValue":t[2]||(t[2]=s=>l.value.last_name=s),type:"text",required:"",class:"input"},null,512),[[d,l.value.last_name]])])]),e("div",null,[t[12]||(t[12]=e("label",{class:"block text-sm font-medium mb-1"},"E-Mail *",-1)),o(e("input",{"onUpdate:modelValue":t[3]||(t[3]=s=>l.value.email=s),type:"email",required:"",class:"input"},null,512),[[d,l.value.email]])]),e("div",null,[t[13]||(t[13]=e("label",{class:"block text-sm font-medium mb-1"},"Passwort *",-1)),o(e("input",{"onUpdate:modelValue":t[4]||(t[4]=s=>l.value.password=s),type:"password",required:"",class:"input"},null,512),[[d,l.value.password]])]),e("div",null,[t[14]||(t[14]=e("label",{class:"block text-sm font-medium mb-1"},"Telefon",-1)),o(e("input",{"onUpdate:modelValue":t[5]||(t[5]=s=>l.value.phone=s),type:"tel",class:"input"},null,512),[[d,l.value.phone]])]),x(f).isChef?(i(),n("div",J,[t[16]||(t[16]=e("label",{class:"block text-sm font-medium mb-1"},"Rolle",-1)),o(e("select",{"onUpdate:modelValue":t[6]||(t[6]=s=>l.value.role=s),class:"input"},[...t[15]||(t[15]=[e("option",{value:"mitarbeiter"},"Mitarbeiter",-1),e("option",{value:"disponent"},"Disponent",-1)])],512),[[q,l.value.role]])])):y("",!0),e("div",O,[e("button",{type:"button",class:"btn btn-secondary",onClick:t[7]||(t[7]=s=>u.value=!1)},"Abbrechen"),t[17]||(t[17]=e("button",{type:"submit",class:"btn btn-primary"},"Erstellen",-1))])],32)])])):y("",!0)]))}});export{Y as default}; +import{d as C,u as U,q as V,m,c as n,a as e,F as E,x as N,w as S,b as o,v as d,z as x,s as q,e as f,r as b,t as r,n as k,o as i}from"./index-CgM2qJ96.js";const A={class:"space-y-6"},D={class:"flex items-center justify-between"},$={class:"card"},B={key:0,class:"text-center py-8 text-gray-500"},F={key:1,class:"text-center py-8 text-gray-500"},R={key:2,class:"w-full"},j={class:"py-3 font-medium"},z={class:"py-3 text-gray-500"},L={class:"py-3"},T={class:"py-3"},I={class:"py-3 text-right"},K=["onClick"],P={key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/50"},G={class:"card w-full max-w-md m-4"},H={class:"grid grid-cols-2 gap-4"},J={key:0},O={class:"flex justify-end gap-3 pt-4"},Y=C({__name:"UsersView",setup(Q){const y=U(),p=b([]),c=b(!0),u=b(!1),l=b({email:"",password:"",first_name:"",last_name:"",phone:"",role:"mitarbeiter"});V(async()=>{await v()});async function v(){c.value=!0;try{const a=await m.get("/users");p.value=a.data.users}catch(a){console.error(a)}finally{c.value=!1}}async function w(){try{await m.post("/users",l.value),u.value=!1,l.value={email:"",password:"",first_name:"",last_name:"",phone:"",role:"mitarbeiter"},await v()}catch(a){alert(a instanceof Error?a.message:"Fehler beim Erstellen")}}async function _(a){try{a.active?await m.delete(`/users/${a.id}`):await m.put(`/users/${a.id}`,{active:!0}),await v()}catch(t){alert(t instanceof Error?t.message:"Fehler")}}function h(a){return{chef:"badge-danger",disponent:"badge-primary",mitarbeiter:"badge-success"}[a]||"badge-secondary"}function M(a){return{chef:"Chef",disponent:"Disponent",mitarbeiter:"Mitarbeiter"}[a]||a}return(a,t)=>(i(),n("div",A,[e("div",D,[t[8]||(t[8]=e("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"},"👥 Mitarbeiter",-1)),e("button",{class:"btn btn-primary",onClick:t[0]||(t[0]=s=>u.value=!0)},"+ Neu")]),e("div",$,[c.value?(i(),n("div",B,"Lädt...")):p.value.length===0?(i(),n("div",F,"Keine Mitarbeiter")):(i(),n("table",R,[t[9]||(t[9]=e("thead",null,[e("tr",{class:"text-left text-sm text-gray-500 border-b border-gray-200 dark:border-gray-700"},[e("th",{class:"pb-3"},"Name"),e("th",{class:"pb-3"},"E-Mail"),e("th",{class:"pb-3"},"Rolle"),e("th",{class:"pb-3"},"Status"),e("th",{class:"pb-3"})])],-1)),e("tbody",null,[(i(!0),n(E,null,N(p.value,s=>{var g;return i(),n("tr",{key:s.id,class:"border-b border-gray-100 dark:border-gray-800"},[e("td",j,r(s.first_name)+" "+r(s.last_name),1),e("td",z,r(s.email),1),e("td",L,[e("span",{class:k(["badge",h(s.role)])},r(M(s.role)),3)]),e("td",T,[e("span",{class:k(s.active?"text-green-600":"text-red-600")},r(s.active?"Aktiv":"Inaktiv"),3)]),e("td",I,[s.id!==((g=x(y).user)==null?void 0:g.id)&&s.role!=="chef"?(i(),n("button",{key:0,class:"text-sm text-gray-500 hover:text-red-600",onClick:W=>_(s)},r(s.active?"Deaktivieren":"Aktivieren"),9,K)):f("",!0)])])}),128))])]))]),u.value?(i(),n("div",P,[e("div",G,[t[18]||(t[18]=e("h2",{class:"text-xl font-semibold mb-6"},"Neuer Mitarbeiter",-1)),e("form",{onSubmit:S(w,["prevent"]),class:"space-y-4"},[e("div",H,[e("div",null,[t[10]||(t[10]=e("label",{class:"block text-sm font-medium mb-1"},"Vorname *",-1)),o(e("input",{"onUpdate:modelValue":t[1]||(t[1]=s=>l.value.first_name=s),type:"text",required:"",class:"input"},null,512),[[d,l.value.first_name]])]),e("div",null,[t[11]||(t[11]=e("label",{class:"block text-sm font-medium mb-1"},"Nachname *",-1)),o(e("input",{"onUpdate:modelValue":t[2]||(t[2]=s=>l.value.last_name=s),type:"text",required:"",class:"input"},null,512),[[d,l.value.last_name]])])]),e("div",null,[t[12]||(t[12]=e("label",{class:"block text-sm font-medium mb-1"},"E-Mail *",-1)),o(e("input",{"onUpdate:modelValue":t[3]||(t[3]=s=>l.value.email=s),type:"email",required:"",class:"input"},null,512),[[d,l.value.email]])]),e("div",null,[t[13]||(t[13]=e("label",{class:"block text-sm font-medium mb-1"},"Passwort *",-1)),o(e("input",{"onUpdate:modelValue":t[4]||(t[4]=s=>l.value.password=s),type:"password",required:"",class:"input"},null,512),[[d,l.value.password]])]),e("div",null,[t[14]||(t[14]=e("label",{class:"block text-sm font-medium mb-1"},"Telefon",-1)),o(e("input",{"onUpdate:modelValue":t[5]||(t[5]=s=>l.value.phone=s),type:"tel",class:"input"},null,512),[[d,l.value.phone]])]),x(y).isChef?(i(),n("div",J,[t[16]||(t[16]=e("label",{class:"block text-sm font-medium mb-1"},"Rolle",-1)),o(e("select",{"onUpdate:modelValue":t[6]||(t[6]=s=>l.value.role=s),class:"input"},[...t[15]||(t[15]=[e("option",{value:"mitarbeiter"},"Mitarbeiter",-1),e("option",{value:"disponent"},"Disponent",-1)])],512),[[q,l.value.role]])])):f("",!0),e("div",O,[e("button",{type:"button",class:"btn btn-secondary",onClick:t[7]||(t[7]=s=>u.value=!1)},"Abbrechen"),t[17]||(t[17]=e("button",{type:"submit",class:"btn btn-primary"},"Erstellen",-1))])],32)])])):f("",!0)]))}});export{Y as default}; diff --git a/dist/assets/VehiclesView-C2kXdRXZ.js b/dist/assets/VehiclesView-C2kXdRXZ.js deleted file mode 100644 index 2a3d3f1..0000000 --- a/dist/assets/VehiclesView-C2kXdRXZ.js +++ /dev/null @@ -1 +0,0 @@ -import{d as _,q as h,m as y,c as n,a as e,F as V,x as z,b as r,v as u,s as B,e as g,r as p,o,t as i,n as f,p as k}from"./index-CWxNv9Fc.js";const D={class:"p-6"},F={class:"flex justify-between items-center mb-6"},M={key:0,class:"text-center py-12"},j={key:1,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},C={key:2,class:"grid md:grid-cols-2 lg:grid-cols-3 gap-4"},S={class:"flex justify-between items-start"},E={class:"font-semibold text-lg"},K={class:"text-gray-600"},U={key:0,class:"text-sm text-gray-400"},L={class:"mt-4 grid grid-cols-2 gap-2 text-sm"},N={key:3,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},T={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},A={class:"space-y-4"},W={class:"grid grid-cols-2 gap-4"},$={class:"grid grid-cols-2 gap-4"},q={class:"flex justify-end space-x-2 mt-6"},P=_({__name:"VehiclesView",setup(H){const c=p(!0),m=p([]),d=p(!1),s=p({license_plate:"",brand:"",model:"",year:2024,color:"",fuel_type:"diesel"});h(async()=>{await v()});async function v(){c.value=!0;try{const a=await y.get("/vehicles");m.value=a.data.vehicles||[]}catch(a){console.error(a)}c.value=!1}async function w(){try{await y.post("/vehicles",s.value),d.value=!1,s.value={license_plate:"",brand:"",model:"",year:2024,color:"",fuel_type:"diesel"},await v()}catch(a){alert("Fehler: "+a.message)}}function b(a){return{available:{text:"Verfügbar",class:"bg-green-100 text-green-700",icon:"✅"},in_use:{text:"Im Einsatz",class:"bg-blue-100 text-blue-700",icon:"🚗"},maintenance:{text:"Wartung",class:"bg-yellow-100 text-yellow-700",icon:"🔧"},retired:{text:"Stillgelegt",class:"bg-gray-100 text-gray-700",icon:"⛔"}}[a]||{text:a,class:"bg-gray-100",icon:""}}return(a,t)=>(o(),n("div",D,[e("div",F,[t[7]||(t[7]=e("div",null,[e("h1",{class:"text-2xl font-bold"},"🚗 Fahrzeuge"),e("p",{class:"text-gray-500"},"Fuhrpark verwalten")],-1)),e("button",{onClick:t[0]||(t[0]=l=>d.value=!0),class:"btn btn-primary"},"+ Fahrzeug")]),c.value?(o(),n("div",M,"Laden...")):m.value.length===0?(o(),n("div",j,[...t[8]||(t[8]=[e("p",{class:"text-4xl mb-4"},"🚗",-1),e("p",null,"Keine Fahrzeuge vorhanden",-1)])])):(o(),n("div",C,[(o(!0),n(V,null,z(m.value,l=>{var x;return o(),n("div",{key:l.id,class:"bg-white rounded-lg shadow p-4"},[e("div",S,[e("div",null,[e("h3",E,i(l.license_plate),1),e("p",K,i(l.brand)+" "+i(l.model),1),l.year?(o(),n("p",U,"Baujahr "+i(l.year),1)):g("",!0)]),e("span",{class:f(["px-2 py-1 text-xs rounded",b(l.status).class])},i(b(l.status).icon)+" "+i(b(l.status).text),3)]),e("div",L,[e("div",null,[t[9]||(t[9]=e("span",{class:"text-gray-500"},"KM-Stand:",-1)),k(" "+i(((x=l.current_mileage)==null?void 0:x.toLocaleString())||"-"),1)]),e("div",null,[t[10]||(t[10]=e("span",{class:"text-gray-500"},"Kraftstoff:",-1)),k(" "+i(l.fuel_type),1)]),l.tuev_expires?(o(),n("div",{key:0,class:f(["col-span-2",new Date(l.tuev_expires)s.value.license_plate=l),class:"input",placeholder:"B-AB 1234"},null,512),[[u,s.value.license_plate]])]),e("div",W,[e("div",null,[t[12]||(t[12]=e("label",{class:"block text-sm font-medium mb-1"},"Marke",-1)),r(e("input",{"onUpdate:modelValue":t[2]||(t[2]=l=>s.value.brand=l),class:"input",placeholder:"VW"},null,512),[[u,s.value.brand]])]),e("div",null,[t[13]||(t[13]=e("label",{class:"block text-sm font-medium mb-1"},"Modell",-1)),r(e("input",{"onUpdate:modelValue":t[3]||(t[3]=l=>s.value.model=l),class:"input",placeholder:"Passat"},null,512),[[u,s.value.model]])])]),e("div",$,[e("div",null,[t[14]||(t[14]=e("label",{class:"block text-sm font-medium mb-1"},"Baujahr",-1)),r(e("input",{"onUpdate:modelValue":t[4]||(t[4]=l=>s.value.year=l),type:"number",class:"input"},null,512),[[u,s.value.year,void 0,{number:!0}]])]),e("div",null,[t[16]||(t[16]=e("label",{class:"block text-sm font-medium mb-1"},"Kraftstoff",-1)),r(e("select",{"onUpdate:modelValue":t[5]||(t[5]=l=>s.value.fuel_type=l),class:"input"},[...t[15]||(t[15]=[e("option",{value:"diesel"},"Diesel",-1),e("option",{value:"petrol"},"Benzin",-1),e("option",{value:"electric"},"Elektro",-1),e("option",{value:"hybrid"},"Hybrid",-1)])],512),[[B,s.value.fuel_type]])])])]),e("div",q,[e("button",{onClick:t[6]||(t[6]=l=>d.value=!1),class:"btn"},"Abbrechen"),e("button",{onClick:w,class:"btn btn-primary"},"Erstellen")])])])):g("",!0)]))}});export{P as default}; diff --git a/dist/assets/VehiclesView-m5j3FcFM.js b/dist/assets/VehiclesView-m5j3FcFM.js new file mode 100644 index 0000000..51f8aca --- /dev/null +++ b/dist/assets/VehiclesView-m5j3FcFM.js @@ -0,0 +1 @@ +import{d as _,q as h,m as y,c as n,a as e,F as V,x as z,b as r,v as u,s as B,e as g,r as p,t as o,n as f,p as k,o as i}from"./index-CgM2qJ96.js";const D={class:"p-6"},F={class:"flex justify-between items-center mb-6"},M={key:0,class:"text-center py-12"},j={key:1,class:"bg-gray-50 rounded-lg p-12 text-center text-gray-500"},C={key:2,class:"grid md:grid-cols-2 lg:grid-cols-3 gap-4"},S={class:"flex justify-between items-start"},E={class:"font-semibold text-lg"},K={class:"text-gray-600"},U={key:0,class:"text-sm text-gray-400"},L={class:"mt-4 grid grid-cols-2 gap-2 text-sm"},N={key:3,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},T={class:"bg-white rounded-lg shadow-xl w-full max-w-md p-6"},A={class:"space-y-4"},W={class:"grid grid-cols-2 gap-4"},$={class:"grid grid-cols-2 gap-4"},q={class:"flex justify-end space-x-2 mt-6"},P=_({__name:"VehiclesView",setup(H){const c=p(!0),m=p([]),d=p(!1),s=p({license_plate:"",brand:"",model:"",year:2024,color:"",fuel_type:"diesel"});h(async()=>{await v()});async function v(){c.value=!0;try{const a=await y.get("/vehicles");m.value=a.data.vehicles||[]}catch(a){console.error(a)}c.value=!1}async function w(){try{await y.post("/vehicles",s.value),d.value=!1,s.value={license_plate:"",brand:"",model:"",year:2024,color:"",fuel_type:"diesel"},await v()}catch(a){alert("Fehler: "+a.message)}}function b(a){return{available:{text:"Verfügbar",class:"bg-green-100 text-green-700",icon:"✅"},in_use:{text:"Im Einsatz",class:"bg-blue-100 text-blue-700",icon:"🚗"},maintenance:{text:"Wartung",class:"bg-yellow-100 text-yellow-700",icon:"🔧"},retired:{text:"Stillgelegt",class:"bg-gray-100 text-gray-700",icon:"⛔"}}[a]||{text:a,class:"bg-gray-100",icon:""}}return(a,t)=>(i(),n("div",D,[e("div",F,[t[7]||(t[7]=e("div",null,[e("h1",{class:"text-2xl font-bold"},"🚗 Fahrzeuge"),e("p",{class:"text-gray-500"},"Fuhrpark verwalten")],-1)),e("button",{onClick:t[0]||(t[0]=l=>d.value=!0),class:"btn btn-primary"},"+ Fahrzeug")]),c.value?(i(),n("div",M,"Laden...")):m.value.length===0?(i(),n("div",j,[...t[8]||(t[8]=[e("p",{class:"text-4xl mb-4"},"🚗",-1),e("p",null,"Keine Fahrzeuge vorhanden",-1)])])):(i(),n("div",C,[(i(!0),n(V,null,z(m.value,l=>{var x;return i(),n("div",{key:l.id,class:"bg-white rounded-lg shadow p-4"},[e("div",S,[e("div",null,[e("h3",E,o(l.license_plate),1),e("p",K,o(l.brand)+" "+o(l.model),1),l.year?(i(),n("p",U,"Baujahr "+o(l.year),1)):g("",!0)]),e("span",{class:f(["px-2 py-1 text-xs rounded",b(l.status).class])},o(b(l.status).icon)+" "+o(b(l.status).text),3)]),e("div",L,[e("div",null,[t[9]||(t[9]=e("span",{class:"text-gray-500"},"KM-Stand:",-1)),k(" "+o(((x=l.current_mileage)==null?void 0:x.toLocaleString())||"-"),1)]),e("div",null,[t[10]||(t[10]=e("span",{class:"text-gray-500"},"Kraftstoff:",-1)),k(" "+o(l.fuel_type),1)]),l.tuev_expires?(i(),n("div",{key:0,class:f(["col-span-2",new Date(l.tuev_expires)s.value.license_plate=l),class:"input",placeholder:"B-AB 1234"},null,512),[[u,s.value.license_plate]])]),e("div",W,[e("div",null,[t[12]||(t[12]=e("label",{class:"block text-sm font-medium mb-1"},"Marke",-1)),r(e("input",{"onUpdate:modelValue":t[2]||(t[2]=l=>s.value.brand=l),class:"input",placeholder:"VW"},null,512),[[u,s.value.brand]])]),e("div",null,[t[13]||(t[13]=e("label",{class:"block text-sm font-medium mb-1"},"Modell",-1)),r(e("input",{"onUpdate:modelValue":t[3]||(t[3]=l=>s.value.model=l),class:"input",placeholder:"Passat"},null,512),[[u,s.value.model]])])]),e("div",$,[e("div",null,[t[14]||(t[14]=e("label",{class:"block text-sm font-medium mb-1"},"Baujahr",-1)),r(e("input",{"onUpdate:modelValue":t[4]||(t[4]=l=>s.value.year=l),type:"number",class:"input"},null,512),[[u,s.value.year,void 0,{number:!0}]])]),e("div",null,[t[16]||(t[16]=e("label",{class:"block text-sm font-medium mb-1"},"Kraftstoff",-1)),r(e("select",{"onUpdate:modelValue":t[5]||(t[5]=l=>s.value.fuel_type=l),class:"input"},[...t[15]||(t[15]=[e("option",{value:"diesel"},"Diesel",-1),e("option",{value:"petrol"},"Benzin",-1),e("option",{value:"electric"},"Elektro",-1),e("option",{value:"hybrid"},"Hybrid",-1)])],512),[[B,s.value.fuel_type]])])])]),e("div",q,[e("button",{onClick:t[6]||(t[6]=l=>d.value=!1),class:"btn"},"Abbrechen"),e("button",{onClick:w,class:"btn btn-primary"},"Erstellen")])])])):g("",!0)]))}});export{P as default}; diff --git a/dist/assets/index-BtrpDjiv.css b/dist/assets/index-BtrpDjiv.css deleted file mode 100644 index 6ad8937..0000000 --- a/dist/assets/index-BtrpDjiv.css +++ /dev/null @@ -1 +0,0 @@ -@keyframes shake-5cf90e48{0%,to{transform:translate(0)}25%{transform:translate(-5px)}75%{transform:translate(5px)}}.animate-shake[data-v-5cf90e48]{animation:shake-5cf90e48 .3s ease-in-out}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}body{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}body:is(.dark *){--tw-text-opacity: 1;color:rgb(243 244 246 / var(--tw-text-opacity, 1))}.btn{border-radius:.5rem;padding:.5rem 1rem;font-weight:500;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.2s}.btn-primary{--tw-bg-opacity: 1;background-color:rgb(79 70 229 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.btn-primary:hover{--tw-bg-opacity: 1;background-color:rgb(67 56 202 / var(--tw-bg-opacity, 1))}.btn-primary:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000);--tw-ring-opacity: 1;--tw-ring-color: rgb(99 102 241 / var(--tw-ring-opacity, 1));--tw-ring-offset-width: 2px}.btn-secondary{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.btn-secondary:hover{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.btn-secondary:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(55 65 81 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(229 231 235 / var(--tw-text-opacity, 1))}.btn-secondary:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(75 85 99 / var(--tw-bg-opacity, 1))}.btn-danger{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.btn-danger:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity, 1))}.btn-success{--tw-bg-opacity: 1;background-color:rgb(22 163 74 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.btn-success:hover{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity, 1))}.input{width:100%;border-radius:.5rem;border-width:1px;--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));padding:.5rem .75rem}.input:focus{--tw-border-opacity: 1;border-color:rgb(99 102 241 / var(--tw-border-opacity, 1));--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000);--tw-ring-opacity: 1;--tw-ring-color: rgb(99 102 241 / var(--tw-ring-opacity, 1))}.input:is(.dark *){--tw-border-opacity: 1;border-color:rgb(75 85 99 / var(--tw-border-opacity, 1));--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.card{border-radius:.75rem;border-width:1px;--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem;--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.card:is(.dark *){--tw-border-opacity: 1;border-color:rgb(55 65 81 / var(--tw-border-opacity, 1));--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.badge{display:inline-flex;align-items:center;border-radius:9999px;padding:.125rem .625rem;font-size:.75rem;line-height:1rem;font-weight:500}.badge-primary{--tw-bg-opacity: 1;background-color:rgb(224 231 255 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(55 48 163 / var(--tw-text-opacity, 1))}.badge-primary:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(49 46 129 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(199 210 254 / var(--tw-text-opacity, 1))}.badge-success{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.badge-success:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(187 247 208 / var(--tw-text-opacity, 1))}.badge-warning{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(133 77 14 / var(--tw-text-opacity, 1))}.badge-warning:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(113 63 18 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(254 240 138 / var(--tw-text-opacity, 1))}.badge-danger{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.badge-danger:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(254 202 202 / var(--tw-text-opacity, 1))}.visible{visibility:visible}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.right-0{right:0}.right-3{right:.75rem}.top-0{top:0}.top-1\/2{top:50%}.z-40{z-index:40}.z-50{z-index:50}.col-span-2{grid-column:span 2 / span 2}.m-4{margin:1rem}.-mx-6{margin-left:-1.5rem;margin-right:-1.5rem}.mx-2{margin-left:.5rem;margin-right:.5rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-top:.25rem;margin-bottom:.25rem}.my-3{margin-top:.75rem;margin-bottom:.75rem}.my-4{margin-top:1rem;margin-bottom:1rem}.my-6{margin-top:1.5rem;margin-bottom:1.5rem}.-mb-px{margin-bottom:-1px}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-6{margin-left:1.5rem}.ml-auto{margin-left:auto}.mr-2{margin-right:.5rem}.mr-3{margin-right:.75rem}.mr-4{margin-right:1rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-1{height:.25rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-20{height:5rem}.h-4{height:1rem}.h-6{height:1.5rem}.h-8{height:2rem}.max-h-40{max-height:10rem}.max-h-48{max-height:12rem}.max-h-\[80vh\]{max-height:80vh}.max-h-\[90vh\]{max-height:90vh}.min-h-32{min-height:8rem}.min-h-screen{min-height:100vh}.w-1\/2{width:50%}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-20{width:5rem}.w-24{width:6rem}.w-32{width:8rem}.w-4{width:1rem}.w-48{width:12rem}.w-64{width:16rem}.w-8{width:2rem}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-full{min-width:100%}.max-w-2xl{max-width:42rem}.max-w-7xl{max-width:80rem}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-none{max-width:none}.max-w-xs{max-width:20rem}.flex-1{flex:1 1 0%}.-translate-x-full{--tw-translate-x: -100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-110{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.space-x-1>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.25rem * var(--tw-space-x-reverse));margin-left:calc(.25rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-3>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.75rem * var(--tw-space-x-reverse));margin-left:calc(.75rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1rem * var(--tw-space-x-reverse));margin-left:calc(1rem * calc(1 - var(--tw-space-x-reverse)))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.divide-x>:not([hidden])~:not([hidden]){--tw-divide-x-reverse: 0;border-right-width:calc(1px * var(--tw-divide-x-reverse));border-left-width:calc(1px * calc(1 - var(--tw-divide-x-reverse)))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-gray-200>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(229 231 235 / var(--tw-divide-opacity, 1))}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:1rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-xl{border-radius:.75rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.border{border-width:1px}.border-2{border-width:2px}.border-4{border-width:4px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l-4{border-left-width:4px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-blue-500{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-blue-600{--tw-border-opacity: 1;border-color:rgb(37 99 235 / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-orange-500{--tw-border-opacity: 1;border-color:rgb(249 115 22 / var(--tw-border-opacity, 1))}.border-purple-500{--tw-border-opacity: 1;border-color:rgb(168 85 247 / var(--tw-border-opacity, 1))}.border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.border-red-500{--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-transparent{border-color:transparent}.border-yellow-200{--tw-border-opacity: 1;border-color:rgb(254 240 138 / var(--tw-border-opacity, 1))}.border-yellow-400{--tw-border-opacity: 1;border-color:rgb(250 204 21 / var(--tw-border-opacity, 1))}.border-yellow-500{--tw-border-opacity: 1;border-color:rgb(234 179 8 / var(--tw-border-opacity, 1))}.border-t-transparent{border-top-color:transparent}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.bg-black\/50{background-color:#00000080}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-green-600{--tw-bg-opacity: 1;background-color:rgb(22 163 74 / var(--tw-bg-opacity, 1))}.bg-orange-100{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.bg-orange-50{--tw-bg-opacity: 1;background-color:rgb(255 247 237 / var(--tw-bg-opacity, 1))}.bg-primary-100{--tw-bg-opacity: 1;background-color:rgb(224 231 255 / var(--tw-bg-opacity, 1))}.bg-primary-600{--tw-bg-opacity: 1;background-color:rgb(79 70 229 / var(--tw-bg-opacity, 1))}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(250 245 255 / var(--tw-bg-opacity, 1))}.bg-purple-600{--tw-bg-opacity: 1;background-color:rgb(147 51 234 / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.bg-red-400{--tw-bg-opacity: 1;background-color:rgb(248 113 113 / var(--tw-bg-opacity, 1))}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-white\/10{background-color:#ffffff1a}.bg-white\/20{background-color:#fff3}.bg-white\/30{background-color:#ffffff4d}.bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.bg-yellow-50{--tw-bg-opacity: 1;background-color:rgb(254 252 232 / var(--tw-bg-opacity, 1))}.bg-opacity-50{--tw-bg-opacity: .5}.bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.bg-gradient-to-r{background-image:linear-gradient(to right,var(--tw-gradient-stops))}.from-primary-500{--tw-gradient-from: #6366f1 var(--tw-gradient-from-position);--tw-gradient-to: rgb(99 102 241 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-purple-600{--tw-gradient-from: #9333ea var(--tw-gradient-from-position);--tw-gradient-to: rgb(147 51 234 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-indigo-600{--tw-gradient-to: #4f46e5 var(--tw-gradient-to-position)}.to-indigo-700,.to-primary-700{--tw-gradient-to: #4338ca var(--tw-gradient-to-position)}.p-1{padding:.25rem}.p-12{padding:3rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pl-4{padding-left:1rem}.pr-10{padding-right:2.5rem}.pr-4{padding-right:1rem}.pt-2{padding-top:.5rem}.pt-4{padding-top:1rem}.pt-6{padding-top:1.5rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-6xl{font-size:3.75rem;line-height:1}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity, 1))}.text-orange-700{--tw-text-opacity: 1;color:rgb(194 65 12 / var(--tw-text-opacity, 1))}.text-primary-100{--tw-text-opacity: 1;color:rgb(224 231 255 / var(--tw-text-opacity, 1))}.text-primary-600{--tw-text-opacity: 1;color:rgb(79 70 229 / var(--tw-text-opacity, 1))}.text-primary-700{--tw-text-opacity: 1;color:rgb(67 56 202 / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.text-purple-800{--tw-text-opacity: 1;color:rgb(107 33 168 / var(--tw-text-opacity, 1))}.text-red-300{--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-white\/50{color:#ffffff80}.text-white\/70{color:#ffffffb3}.text-yellow-600{--tw-text-opacity: 1;color:rgb(202 138 4 / var(--tw-text-opacity, 1))}.text-yellow-700{--tw-text-opacity: 1;color:rgb(161 98 7 / var(--tw-text-opacity, 1))}.text-yellow-800{--tw-text-opacity: 1;color:rgb(133 77 14 / var(--tw-text-opacity, 1))}.underline{text-decoration-line:underline}.opacity-50{opacity:.5}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-blue-500{--tw-ring-opacity: 1;--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity, 1))}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-shadow{transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover\:scale-\[1\.02\]:hover{--tw-scale-x: 1.02;--tw-scale-y: 1.02;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:border-blue-500:hover{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.hover\:border-purple-300:hover{--tw-border-opacity: 1;border-color:rgb(216 180 254 / var(--tw-border-opacity, 1))}.hover\:border-red-300:hover{--tw-border-opacity: 1;border-color:rgb(252 165 165 / var(--tw-border-opacity, 1))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-700:hover{--tw-bg-opacity: 1;background-color:rgb(29 78 216 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-300:hover{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.hover\:bg-green-600:hover{--tw-bg-opacity: 1;background-color:rgb(22 163 74 / var(--tw-bg-opacity, 1))}.hover\:bg-green-700:hover{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity, 1))}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.hover\:bg-red-200:hover{--tw-bg-opacity: 1;background-color:rgb(254 202 202 / var(--tw-bg-opacity, 1))}.hover\:bg-red-50:hover{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.hover\:bg-white\/20:hover{background-color:#fff3}.hover\:bg-white\/30:hover{background-color:#ffffff4d}.hover\:bg-yellow-200:hover{--tw-bg-opacity: 1;background-color:rgb(254 240 138 / var(--tw-bg-opacity, 1))}.hover\:text-blue-800:hover{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.hover\:text-green-800:hover{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.hover\:text-primary-700:hover{--tw-text-opacity: 1;color:rgb(67 56 202 / var(--tw-text-opacity, 1))}.hover\:text-primary-800:hover{--tw-text-opacity: 1;color:rgb(55 48 163 / var(--tw-text-opacity, 1))}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:text-red-700:hover{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.hover\:text-red-800:hover{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.hover\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\:shadow-md:hover{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.disabled\:opacity-50:disabled{opacity:.5}.dark\:divide-gray-700:is(.dark *)>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(55 65 81 / var(--tw-divide-opacity, 1))}.dark\:border-gray-600:is(.dark *){--tw-border-opacity: 1;border-color:rgb(75 85 99 / var(--tw-border-opacity, 1))}.dark\:border-gray-700:is(.dark *){--tw-border-opacity: 1;border-color:rgb(55 65 81 / var(--tw-border-opacity, 1))}.dark\:border-gray-800:is(.dark *){--tw-border-opacity: 1;border-color:rgb(31 41 55 / var(--tw-border-opacity, 1))}.dark\:bg-blue-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(30 58 138 / var(--tw-bg-opacity, 1))}.dark\:bg-blue-900\/20:is(.dark *){background-color:#1e3a8a33}.dark\:bg-gray-600:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(75 85 99 / var(--tw-bg-opacity, 1))}.dark\:bg-gray-700:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(55 65 81 / var(--tw-bg-opacity, 1))}.dark\:bg-gray-700\/50:is(.dark *){background-color:#37415180}.dark\:bg-gray-800:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.dark\:bg-gray-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(17 24 39 / var(--tw-bg-opacity, 1))}.dark\:bg-green-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity, 1))}.dark\:bg-primary-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(49 46 129 / var(--tw-bg-opacity, 1))}.dark\:bg-red-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.dark\:bg-red-900\/20:is(.dark *){background-color:#7f1d1d33}.dark\:bg-yellow-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(113 63 18 / var(--tw-bg-opacity, 1))}.dark\:bg-yellow-900\/20:is(.dark *){background-color:#713f1233}.dark\:text-blue-200:is(.dark *){--tw-text-opacity: 1;color:rgb(191 219 254 / var(--tw-text-opacity, 1))}.dark\:text-gray-200:is(.dark *){--tw-text-opacity: 1;color:rgb(229 231 235 / var(--tw-text-opacity, 1))}.dark\:text-gray-300:is(.dark *){--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.dark\:text-gray-400:is(.dark *){--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.dark\:text-green-200:is(.dark *){--tw-text-opacity: 1;color:rgb(187 247 208 / var(--tw-text-opacity, 1))}.dark\:text-primary-200:is(.dark *){--tw-text-opacity: 1;color:rgb(199 210 254 / var(--tw-text-opacity, 1))}.dark\:text-primary-300:is(.dark *){--tw-text-opacity: 1;color:rgb(165 180 252 / var(--tw-text-opacity, 1))}.dark\:text-red-200:is(.dark *){--tw-text-opacity: 1;color:rgb(254 202 202 / var(--tw-text-opacity, 1))}.dark\:text-red-400:is(.dark *){--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.dark\:text-white:is(.dark *){--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.dark\:text-yellow-200:is(.dark *){--tw-text-opacity: 1;color:rgb(254 240 138 / var(--tw-text-opacity, 1))}.dark\:hover\:bg-gray-500:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(107 114 128 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-gray-700:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(55 65 81 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-gray-700\/50:hover:is(.dark *){background-color:#37415180}.dark\:hover\:bg-gray-800:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-red-900:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-red-900\/20:hover:is(.dark *){background-color:#7f1d1d33}@media (min-width: 640px){.sm\:block{display:block}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width: 768px){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width: 1024px){.lg\:ml-0{margin-left:0}.lg\:block{display:block}.lg\:hidden{display:none}.lg\:translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:px-6{padding-left:1.5rem;padding-right:1.5rem}.lg\:px-8{padding-left:2rem;padding-right:2rem}.lg\:pl-64{padding-left:16rem}} diff --git a/dist/assets/index-CWxNv9Fc.js b/dist/assets/index-CWxNv9Fc.js deleted file mode 100644 index 1992c8e..0000000 --- a/dist/assets/index-CWxNv9Fc.js +++ /dev/null @@ -1,29 +0,0 @@ -var ji=Object.defineProperty;var Ui=(e,t,n)=>t in e?ji(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var cr=(e,t,n)=>Ui(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();/** -* @vue/shared v3.5.30 -* (c) 2018-present Yuxi (Evan) You and Vue contributors -* @license MIT -**/function ks(e){const t=Object.create(null);for(const n of e.split(","))t[n]=1;return n=>n in t}const ee={},Vt=[],Ye=()=>{},uo=()=>!1,Un=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),Vs=e=>e.startsWith("onUpdate:"),de=Object.assign,Fs=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},Bi=Object.prototype.hasOwnProperty,Y=(e,t)=>Bi.call(e,t),V=Array.isArray,Ft=e=>vn(e)==="[object Map]",Wt=e=>vn(e)==="[object Set]",ur=e=>vn(e)==="[object Date]",B=e=>typeof e=="function",ae=e=>typeof e=="string",Xe=e=>typeof e=="symbol",Z=e=>e!==null&&typeof e=="object",ao=e=>(Z(e)||B(e))&&B(e.then)&&B(e.catch),fo=Object.prototype.toString,vn=e=>fo.call(e),Hi=e=>vn(e).slice(8,-1),ho=e=>vn(e)==="[object Object]",Bn=e=>ae(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,en=ks(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),Hn=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},Ki=/-\w/g,Ee=Hn(e=>e.replace(Ki,t=>t.slice(1).toUpperCase())),Gi=/\B([A-Z])/g,Pt=Hn(e=>e.replace(Gi,"-$1").toLowerCase()),Kn=Hn(e=>e.charAt(0).toUpperCase()+e.slice(1)),os=Hn(e=>e?`on${Kn(e)}`:""),Qe=(e,t)=>!Object.is(e,t),An=(e,...t)=>{for(let n=0;n{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:s,value:n})},Gn=e=>{const t=parseFloat(e);return isNaN(t)?e:t};let ar;const Wn=()=>ar||(ar=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function js(e){if(V(e)){const t={};for(let n=0;n{if(n){const s=n.split(qi);s.length>1&&(t[s[0].trim()]=s[1].trim())}}),t}function qn(e){let t="";if(ae(e))t=e;else if(V(e))for(let n=0;nqt(n,t))}const mo=e=>!!(e&&e.__v_isRef===!0),ys=e=>ae(e)?e:e==null?"":V(e)||Z(e)&&(e.toString===fo||!B(e.toString))?mo(e)?ys(e.value):JSON.stringify(e,_o,2):String(e),_o=(e,t)=>mo(t)?_o(e,t.value):Ft(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((n,[s,r],o)=>(n[is(s,o)+" =>"]=r,n),{})}:Wt(t)?{[`Set(${t.size})`]:[...t.values()].map(n=>is(n))}:Xe(t)?is(t):Z(t)&&!V(t)&&!ho(t)?String(t):t,is=(e,t="")=>{var n;return Xe(e)?`Symbol(${(n=e.description)!=null?n:t})`:e};/** -* @vue/reactivity v3.5.30 -* (c) 2018-present Yuxi (Evan) You and Vue contributors -* @license MIT -**/let he;class vo{constructor(t=!1){this.detached=t,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.__v_skip=!0,this.parent=he,!t&&he&&(this.index=(he.scopes||(he.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let t,n;if(this.scopes)for(t=0,n=this.scopes.length;t0&&--this._on===0&&(he=this.prevScope,this.prevScope=void 0)}stop(t){if(this._active){this._active=!1;let n,s;for(n=0,s=this.effects.length;n0)return;if(nn){let t=nn;for(nn=void 0;t;){const n=t.next;t.next=void 0,t.flags&=-9,t=n}}let e;for(;tn;){let t=tn;for(tn=void 0;t;){const n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(s){e||(e=s)}t=n}}if(e)throw e}function xo(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function Ao(e){let t,n=e.depsTail,s=n;for(;s;){const r=s.prevDep;s.version===-1?(s===n&&(n=r),Ks(s),Zi(s)):t=s,s.dep.activeLink=s.prevActiveLink,s.prevActiveLink=void 0,s=r}e.deps=t,e.depsTail=n}function bs(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(Ro(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function Ro(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===fn)||(e.globalVersion=fn,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!bs(e))))return;e.flags|=2;const t=e.dep,n=ne,s=je;ne=e,je=!0;try{xo(e);const r=e.fn(e._value);(t.version===0||Qe(r,e._value))&&(e.flags|=128,e._value=r,t.version++)}catch(r){throw t.version++,r}finally{ne=n,je=s,Ao(e),e.flags&=-3}}function Ks(e,t=!1){const{dep:n,prevSub:s,nextSub:r}=e;if(s&&(s.nextSub=r,e.prevSub=void 0),r&&(r.prevSub=s,e.nextSub=void 0),n.subs===e&&(n.subs=s,!s&&n.computed)){n.computed.flags&=-5;for(let o=n.computed.deps;o;o=o.nextDep)Ks(o,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function Zi(e){const{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}let je=!0;const Co=[];function ut(){Co.push(je),je=!1}function at(){const e=Co.pop();je=e===void 0?!0:e}function fr(e){const{cleanup:t}=e;if(e.cleanup=void 0,t){const n=ne;ne=void 0;try{t()}finally{ne=n}}}let fn=0;class el{constructor(t,n){this.sub=t,this.dep=n,this.version=n.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class Gs{constructor(t){this.computed=t,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(t){if(!ne||!je||ne===this.computed)return;let n=this.activeLink;if(n===void 0||n.sub!==ne)n=this.activeLink=new el(ne,this),ne.deps?(n.prevDep=ne.depsTail,ne.depsTail.nextDep=n,ne.depsTail=n):ne.deps=ne.depsTail=n,Oo(n);else if(n.version===-1&&(n.version=this.version,n.nextDep)){const s=n.nextDep;s.prevDep=n.prevDep,n.prevDep&&(n.prevDep.nextDep=s),n.prevDep=ne.depsTail,n.nextDep=void 0,ne.depsTail.nextDep=n,ne.depsTail=n,ne.deps===n&&(ne.deps=s)}return n}trigger(t){this.version++,fn++,this.notify(t)}notify(t){Bs();try{for(let n=this.subs;n;n=n.prevSub)n.sub.notify()&&n.sub.dep.notify()}finally{Hs()}}}function Oo(e){if(e.dep.sc++,e.sub.flags&4){const t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let s=t.deps;s;s=s.nextDep)Oo(s)}const n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}const Pn=new WeakMap,Ct=Symbol(""),Es=Symbol(""),dn=Symbol("");function pe(e,t,n){if(je&&ne){let s=Pn.get(e);s||Pn.set(e,s=new Map);let r=s.get(n);r||(s.set(n,r=new Gs),r.map=s,r.key=n),r.track()}}function ot(e,t,n,s,r,o){const i=Pn.get(e);if(!i){fn++;return}const l=c=>{c&&c.trigger()};if(Bs(),t==="clear")i.forEach(l);else{const c=V(e),f=c&&Bn(n);if(c&&n==="length"){const u=Number(s);i.forEach((d,g)=>{(g==="length"||g===dn||!Xe(g)&&g>=u)&&l(d)})}else switch((n!==void 0||i.has(void 0))&&l(i.get(n)),f&&l(i.get(dn)),t){case"add":c?f&&l(i.get("length")):(l(i.get(Ct)),Ft(e)&&l(i.get(Es)));break;case"delete":c||(l(i.get(Ct)),Ft(e)&&l(i.get(Es)));break;case"set":Ft(e)&&l(i.get(Ct));break}}Hs()}function tl(e,t){const n=Pn.get(e);return n&&n.get(t)}function Dt(e){const t=z(e);return t===e?t:(pe(t,"iterate",dn),Me(e)?t:t.map(Ue))}function $n(e){return pe(e=z(e),"iterate",dn),e}function ze(e,t){return ft(e)?Ut(lt(e)?Ue(t):t):Ue(t)}const nl={__proto__:null,[Symbol.iterator](){return cs(this,Symbol.iterator,e=>ze(this,e))},concat(...e){return Dt(this).concat(...e.map(t=>V(t)?Dt(t):t))},entries(){return cs(this,"entries",e=>(e[1]=ze(this,e[1]),e))},every(e,t){return tt(this,"every",e,t,void 0,arguments)},filter(e,t){return tt(this,"filter",e,t,n=>n.map(s=>ze(this,s)),arguments)},find(e,t){return tt(this,"find",e,t,n=>ze(this,n),arguments)},findIndex(e,t){return tt(this,"findIndex",e,t,void 0,arguments)},findLast(e,t){return tt(this,"findLast",e,t,n=>ze(this,n),arguments)},findLastIndex(e,t){return tt(this,"findLastIndex",e,t,void 0,arguments)},forEach(e,t){return tt(this,"forEach",e,t,void 0,arguments)},includes(...e){return us(this,"includes",e)},indexOf(...e){return us(this,"indexOf",e)},join(e){return Dt(this).join(e)},lastIndexOf(...e){return us(this,"lastIndexOf",e)},map(e,t){return tt(this,"map",e,t,void 0,arguments)},pop(){return zt(this,"pop")},push(...e){return zt(this,"push",e)},reduce(e,...t){return dr(this,"reduce",e,t)},reduceRight(e,...t){return dr(this,"reduceRight",e,t)},shift(){return zt(this,"shift")},some(e,t){return tt(this,"some",e,t,void 0,arguments)},splice(...e){return zt(this,"splice",e)},toReversed(){return Dt(this).toReversed()},toSorted(e){return Dt(this).toSorted(e)},toSpliced(...e){return Dt(this).toSpliced(...e)},unshift(...e){return zt(this,"unshift",e)},values(){return cs(this,"values",e=>ze(this,e))}};function cs(e,t,n){const s=$n(e),r=s[t]();return s!==e&&!Me(e)&&(r._next=r.next,r.next=()=>{const o=r._next();return o.done||(o.value=n(o.value)),o}),r}const sl=Array.prototype;function tt(e,t,n,s,r,o){const i=$n(e),l=i!==e&&!Me(e),c=i[t];if(c!==sl[t]){const d=c.apply(e,o);return l?Ue(d):d}let f=n;i!==e&&(l?f=function(d,g){return n.call(this,ze(e,d),g,e)}:n.length>2&&(f=function(d,g){return n.call(this,d,g,e)}));const u=c.call(i,f,s);return l&&r?r(u):u}function dr(e,t,n,s){const r=$n(e),o=r!==e&&!Me(e);let i=n,l=!1;r!==e&&(o?(l=s.length===0,i=function(f,u,d){return l&&(l=!1,f=ze(e,f)),n.call(this,f,ze(e,u),d,e)}):n.length>3&&(i=function(f,u,d){return n.call(this,f,u,d,e)}));const c=r[t](i,...s);return l?ze(e,c):c}function us(e,t,n){const s=z(e);pe(s,"iterate",dn);const r=s[t](...n);return(r===-1||r===!1)&&zn(n[0])?(n[0]=z(n[0]),s[t](...n)):r}function zt(e,t,n=[]){ut(),Bs();const s=z(e)[t].apply(e,n);return Hs(),at(),s}const rl=ks("__proto__,__v_isRef,__isVue"),To=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!=="arguments"&&e!=="caller").map(e=>Symbol[e]).filter(Xe));function ol(e){Xe(e)||(e=String(e));const t=z(this);return pe(t,"has",e),t.hasOwnProperty(e)}class Po{constructor(t=!1,n=!1){this._isReadonly=t,this._isShallow=n}get(t,n,s){if(n==="__v_skip")return t.__v_skip;const r=this._isReadonly,o=this._isShallow;if(n==="__v_isReactive")return!r;if(n==="__v_isReadonly")return r;if(n==="__v_isShallow")return o;if(n==="__v_raw")return s===(r?o?gl:Mo:o?Do:No).get(t)||Object.getPrototypeOf(t)===Object.getPrototypeOf(s)?t:void 0;const i=V(t);if(!r){let c;if(i&&(c=nl[n]))return c;if(n==="hasOwnProperty")return ol}const l=Reflect.get(t,n,le(t)?t:s);if((Xe(n)?To.has(n):rl(n))||(r||pe(t,"get",n),o))return l;if(le(l)){const c=i&&Bn(n)?l:l.value;return r&&Z(c)?ws(c):c}return Z(l)?r?ws(l):yn(l):l}}class Io extends Po{constructor(t=!1){super(!1,t)}set(t,n,s,r){let o=t[n];const i=V(t)&&Bn(n);if(!this._isShallow){const f=ft(o);if(!Me(s)&&!ft(s)&&(o=z(o),s=z(s)),!i&&le(o)&&!le(s))return f||(o.value=s),!0}const l=i?Number(n)e,Sn=e=>Reflect.getPrototypeOf(e);function al(e,t,n){return function(...s){const r=this.__v_raw,o=z(r),i=Ft(o),l=e==="entries"||e===Symbol.iterator&&i,c=e==="keys"&&i,f=r[e](...s),u=n?Ss:t?Ut:Ue;return!t&&pe(o,"iterate",c?Es:Ct),de(Object.create(f),{next(){const{value:d,done:g}=f.next();return g?{value:d,done:g}:{value:l?[u(d[0]),u(d[1])]:u(d),done:g}}})}}function wn(e){return function(...t){return e==="delete"?!1:e==="clear"?void 0:this}}function fl(e,t){const n={get(r){const o=this.__v_raw,i=z(o),l=z(r);e||(Qe(r,l)&&pe(i,"get",r),pe(i,"get",l));const{has:c}=Sn(i),f=t?Ss:e?Ut:Ue;if(c.call(i,r))return f(o.get(r));if(c.call(i,l))return f(o.get(l));o!==i&&o.get(r)},get size(){const r=this.__v_raw;return!e&&pe(z(r),"iterate",Ct),r.size},has(r){const o=this.__v_raw,i=z(o),l=z(r);return e||(Qe(r,l)&&pe(i,"has",r),pe(i,"has",l)),r===l?o.has(r):o.has(r)||o.has(l)},forEach(r,o){const i=this,l=i.__v_raw,c=z(l),f=t?Ss:e?Ut:Ue;return!e&&pe(c,"iterate",Ct),l.forEach((u,d)=>r.call(o,f(u),f(d),i))}};return de(n,e?{add:wn("add"),set:wn("set"),delete:wn("delete"),clear:wn("clear")}:{add(r){const o=z(this),i=Sn(o),l=z(r),c=!t&&!Me(r)&&!ft(r)?l:r;return i.has.call(o,c)||Qe(r,c)&&i.has.call(o,r)||Qe(l,c)&&i.has.call(o,l)||(o.add(c),ot(o,"add",c,c)),this},set(r,o){!t&&!Me(o)&&!ft(o)&&(o=z(o));const i=z(this),{has:l,get:c}=Sn(i);let f=l.call(i,r);f||(r=z(r),f=l.call(i,r));const u=c.call(i,r);return i.set(r,o),f?Qe(o,u)&&ot(i,"set",r,o):ot(i,"add",r,o),this},delete(r){const o=z(this),{has:i,get:l}=Sn(o);let c=i.call(o,r);c||(r=z(r),c=i.call(o,r)),l&&l.call(o,r);const f=o.delete(r);return c&&ot(o,"delete",r,void 0),f},clear(){const r=z(this),o=r.size!==0,i=r.clear();return o&&ot(r,"clear",void 0,void 0),i}}),["keys","values","entries",Symbol.iterator].forEach(r=>{n[r]=al(r,e,t)}),n}function Ws(e,t){const n=fl(e,t);return(s,r,o)=>r==="__v_isReactive"?!e:r==="__v_isReadonly"?e:r==="__v_raw"?s:Reflect.get(Y(n,r)&&r in s?n:s,r,o)}const dl={get:Ws(!1,!1)},hl={get:Ws(!1,!0)},pl={get:Ws(!0,!1)};const No=new WeakMap,Do=new WeakMap,Mo=new WeakMap,gl=new WeakMap;function ml(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function _l(e){return e.__v_skip||!Object.isExtensible(e)?0:ml(Hi(e))}function yn(e){return ft(e)?e:qs(e,!1,ll,dl,No)}function Lo(e){return qs(e,!1,ul,hl,Do)}function ws(e){return qs(e,!0,cl,pl,Mo)}function qs(e,t,n,s,r){if(!Z(e)||e.__v_raw&&!(t&&e.__v_isReactive))return e;const o=_l(e);if(o===0)return e;const i=r.get(e);if(i)return i;const l=new Proxy(e,o===2?s:n);return r.set(e,l),l}function lt(e){return ft(e)?lt(e.__v_raw):!!(e&&e.__v_isReactive)}function ft(e){return!!(e&&e.__v_isReadonly)}function Me(e){return!!(e&&e.__v_isShallow)}function zn(e){return e?!!e.__v_raw:!1}function z(e){const t=e&&e.__v_raw;return t?z(t):e}function $s(e){return!Y(e,"__v_skip")&&Object.isExtensible(e)&&po(e,"__v_skip",!0),e}const Ue=e=>Z(e)?yn(e):e,Ut=e=>Z(e)?ws(e):e;function le(e){return e?e.__v_isRef===!0:!1}function Ie(e){return ko(e,!1)}function vl(e){return ko(e,!0)}function ko(e,t){return le(e)?e:new yl(e,t)}class yl{constructor(t,n){this.dep=new Gs,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=n?t:z(t),this._value=n?t:Ue(t),this.__v_isShallow=n}get value(){return this.dep.track(),this._value}set value(t){const n=this._rawValue,s=this.__v_isShallow||Me(t)||ft(t);t=s?t:z(t),Qe(t,n)&&(this._rawValue=t,this._value=s?t:Ue(t),this.dep.trigger())}}function Ot(e){return le(e)?e.value:e}const bl={get:(e,t,n)=>t==="__v_raw"?e:Ot(Reflect.get(e,t,n)),set:(e,t,n,s)=>{const r=e[t];return le(r)&&!le(n)?(r.value=n,!0):Reflect.set(e,t,n,s)}};function Vo(e){return lt(e)?e:new Proxy(e,bl)}function El(e){const t=V(e)?new Array(e.length):{};for(const n in e)t[n]=wl(e,n);return t}class Sl{constructor(t,n,s){this._object=t,this._key=n,this._defaultValue=s,this.__v_isRef=!0,this._value=void 0,this._raw=z(t);let r=!0,o=t;if(!V(t)||!Bn(String(n)))do r=!zn(o)||Me(o);while(r&&(o=o.__v_raw));this._shallow=r}get value(){let t=this._object[this._key];return this._shallow&&(t=Ot(t)),this._value=t===void 0?this._defaultValue:t}set value(t){if(this._shallow&&le(this._raw[this._key])){const n=this._object[this._key];if(le(n)){n.value=t;return}}this._object[this._key]=t}get dep(){return tl(this._raw,this._key)}}function wl(e,t,n){return new Sl(e,t,n)}class xl{constructor(t,n,s){this.fn=t,this.setter=n,this._value=void 0,this.dep=new Gs(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=fn-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!n,this.isSSR=s}notify(){if(this.flags|=16,!(this.flags&8)&&ne!==this)return wo(this,!0),!0}get value(){const t=this.dep.track();return Ro(this),t&&(t.version=this.dep.version),this._value}set value(t){this.setter&&this.setter(t)}}function Al(e,t,n=!1){let s,r;return B(e)?s=e:(s=e.get,r=e.set),new xl(s,r,n)}const xn={},In=new WeakMap;let At;function Rl(e,t=!1,n=At){if(n){let s=In.get(n);s||In.set(n,s=[]),s.push(e)}}function Cl(e,t,n=ee){const{immediate:s,deep:r,once:o,scheduler:i,augmentJob:l,call:c}=n,f=w=>r?w:Me(w)||r===!1||r===0?it(w,1):it(w);let u,d,g,m,A=!1,S=!1;if(le(e)?(d=()=>e.value,A=Me(e)):lt(e)?(d=()=>f(e),A=!0):V(e)?(S=!0,A=e.some(w=>lt(w)||Me(w)),d=()=>e.map(w=>{if(le(w))return w.value;if(lt(w))return f(w);if(B(w))return c?c(w,2):w()})):B(e)?t?d=c?()=>c(e,2):e:d=()=>{if(g){ut();try{g()}finally{at()}}const w=At;At=u;try{return c?c(e,3,[m]):e(m)}finally{At=w}}:d=Ye,t&&r){const w=d,U=r===!0?1/0:r;d=()=>it(w(),U)}const N=bo(),M=()=>{u.stop(),N&&N.active&&Fs(N.effects,u)};if(o&&t){const w=t;t=(...U)=>{w(...U),M()}}let T=S?new Array(e.length).fill(xn):xn;const D=w=>{if(!(!(u.flags&1)||!u.dirty&&!w))if(t){const U=u.run();if(r||A||(S?U.some((ce,W)=>Qe(ce,T[W])):Qe(U,T))){g&&g();const ce=At;At=u;try{const W=[U,T===xn?void 0:S&&T[0]===xn?[]:T,m];T=U,c?c(t,3,W):t(...W)}finally{At=ce}}}else u.run()};return l&&l(D),u=new Eo(d),u.scheduler=i?()=>i(D,!1):D,m=w=>Rl(w,!1,u),g=u.onStop=()=>{const w=In.get(u);if(w){if(c)c(w,4);else for(const U of w)U();In.delete(u)}},t?s?D(!0):T=u.run():i?i(D.bind(null,!0),!0):u.run(),M.pause=u.pause.bind(u),M.resume=u.resume.bind(u),M.stop=M,M}function it(e,t=1/0,n){if(t<=0||!Z(e)||e.__v_skip||(n=n||new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,le(e))it(e.value,t,n);else if(V(e))for(let s=0;s{it(s,t,n)});else if(ho(e)){for(const s in e)it(e[s],t,n);for(const s of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,s)&&it(e[s],t,n)}return e}/** -* @vue/runtime-core v3.5.30 -* (c) 2018-present Yuxi (Evan) You and Vue contributors -* @license MIT -**/function bn(e,t,n,s){try{return s?e(...s):e()}catch(r){Jn(r,t,n)}}function Ze(e,t,n,s){if(B(e)){const r=bn(e,t,n,s);return r&&ao(r)&&r.catch(o=>{Jn(o,t,n)}),r}if(V(e)){const r=[];for(let o=0;o>>1,r=ye[s],o=hn(r);o=hn(n)?ye.push(e):ye.splice(Tl(t),0,e),e.flags|=1,jo()}}function jo(){Nn||(Nn=Fo.then(Bo))}function Pl(e){V(e)?jt.push(...e):_t&&e.id===-1?_t.splice(Lt+1,0,e):e.flags&1||(jt.push(e),e.flags|=1),jo()}function hr(e,t,n=$e+1){for(;nhn(n)-hn(s));if(jt.length=0,_t){_t.push(...t);return}for(_t=t,Lt=0;Lt<_t.length;Lt++){const n=_t[Lt];n.flags&4&&(n.flags&=-2),n.flags&8||n(),n.flags&=-2}_t=null,Lt=0}}const hn=e=>e.id==null?e.flags&2?-1:1/0:e.id;function Bo(e){try{for($e=0;$e{s._d&&kn(-1);const o=Dn(t);let i;try{i=e(...r)}finally{Dn(o),s._d&&kn(1)}return i};return s._n=!0,s._c=!0,s._d=!0,s}function Nl(e,t){if(Ne===null)return e;const n=ts(Ne),s=e.dirs||(e.dirs=[]);for(let r=0;r1)return n&&B(t)?t.call(s&&s.proxy):t}}function Dl(){return!!(gi()||Tt)}const Ml=Symbol.for("v-scx"),Ll=()=>Fe(Ml);function sn(e,t,n){return Ko(e,t,n)}function Ko(e,t,n=ee){const{immediate:s,deep:r,flush:o,once:i}=n,l=de({},n),c=t&&s||!t&&o!=="post";let f;if(gn){if(o==="sync"){const m=Ll();f=m.__watcherHandles||(m.__watcherHandles=[])}else if(!c){const m=()=>{};return m.stop=Ye,m.resume=Ye,m.pause=Ye,m}}const u=ge;l.call=(m,A,S)=>Ze(m,u,A,S);let d=!1;o==="post"?l.scheduler=m=>{Re(m,u&&u.suspense)}:o!=="sync"&&(d=!0,l.scheduler=(m,A)=>{A?m():zs(m)}),l.augmentJob=m=>{t&&(m.flags|=4),d&&(m.flags|=2,u&&(m.id=u.uid,m.i=u))};const g=Cl(e,t,l);return gn&&(f?f.push(g):c&&g()),g}function kl(e,t,n){const s=this.proxy,r=ae(e)?e.includes(".")?Go(s,e):()=>s[e]:e.bind(s,s);let o;B(t)?o=t:(o=t.handler,n=t);const i=En(this),l=Ko(r,o.bind(s),n);return i(),l}function Go(e,t){const n=t.split(".");return()=>{let s=e;for(let r=0;re.__isTeleport,jl=Symbol("_leaveCb");function Js(e,t){e.shapeFlag&6&&e.component?(e.transition=t,Js(e.component.subTree,t)):e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function Yn(e,t){return B(e)?de({name:e.name},t,{setup:e}):e}function Wo(e){e.ids=[e.ids[0]+e.ids[2]+++"-",0,0]}function pr(e,t){let n;return!!((n=Object.getOwnPropertyDescriptor(e,t))&&!n.configurable)}const Mn=new WeakMap;function rn(e,t,n,s,r=!1){if(V(e)){e.forEach((S,N)=>rn(S,t&&(V(t)?t[N]:t),n,s,r));return}if(on(s)&&!r){s.shapeFlag&512&&s.type.__asyncResolved&&s.component.subTree.component&&rn(e,t,n,s.component.subTree);return}const o=s.shapeFlag&4?ts(s.component):s.el,i=r?null:o,{i:l,r:c}=e,f=t&&t.r,u=l.refs===ee?l.refs={}:l.refs,d=l.setupState,g=z(d),m=d===ee?uo:S=>pr(u,S)?!1:Y(g,S),A=(S,N)=>!(N&&pr(u,N));if(f!=null&&f!==c){if(gr(t),ae(f))u[f]=null,m(f)&&(d[f]=null);else if(le(f)){const S=t;A(f,S.k)&&(f.value=null),S.k&&(u[S.k]=null)}}if(B(c))bn(c,l,12,[i,u]);else{const S=ae(c),N=le(c);if(S||N){const M=()=>{if(e.f){const T=S?m(c)?d[c]:u[c]:A()||!e.k?c.value:u[e.k];if(r)V(T)&&Fs(T,o);else if(V(T))T.includes(o)||T.push(o);else if(S)u[c]=[o],m(c)&&(d[c]=u[c]);else{const D=[o];A(c,e.k)&&(c.value=D),e.k&&(u[e.k]=D)}}else S?(u[c]=i,m(c)&&(d[c]=i)):N&&(A(c,e.k)&&(c.value=i),e.k&&(u[e.k]=i))};if(i){const T=()=>{M(),Mn.delete(e)};T.id=-1,Mn.set(e,T),Re(T,n)}else gr(e),M()}}}function gr(e){const t=Mn.get(e);t&&(t.flags|=8,Mn.delete(e))}Wn().requestIdleCallback;Wn().cancelIdleCallback;const on=e=>!!e.type.__asyncLoader,qo=e=>e.type.__isKeepAlive;function Ul(e,t){$o(e,"a",t)}function Bl(e,t){$o(e,"da",t)}function $o(e,t,n=ge){const s=e.__wdc||(e.__wdc=()=>{let r=n;for(;r;){if(r.isDeactivated)return;r=r.parent}return e()});if(Xn(t,s,n),n){let r=n.parent;for(;r&&r.parent;)qo(r.parent.vnode)&&Hl(s,t,n,r),r=r.parent}}function Hl(e,t,n,s){const r=Xn(t,e,s,!0);Ys(()=>{Fs(s[t],r)},n)}function Xn(e,t,n=ge,s=!1){if(n){const r=n[e]||(n[e]=[]),o=t.__weh||(t.__weh=(...i)=>{ut();const l=En(n),c=Ze(t,n,e,i);return l(),at(),c});return s?r.unshift(o):r.push(o),o}}const dt=e=>(t,n=ge)=>{(!gn||e==="sp")&&Xn(e,(...s)=>t(...s),n)},Kl=dt("bm"),Qs=dt("m"),Gl=dt("bu"),Wl=dt("u"),ql=dt("bum"),Ys=dt("um"),$l=dt("sp"),zl=dt("rtg"),Jl=dt("rtc");function Ql(e,t=ge){Xn("ec",e,t)}const Yl="components";function Xl(e,t){return ec(Yl,e,!0,t)||e}const Zl=Symbol.for("v-ndc");function ec(e,t,n=!0,s=!1){const r=Ne||ge;if(r){const o=r.type;{const l=jc(o,!1);if(l&&(l===t||l===Ee(t)||l===Kn(Ee(t))))return o}const i=mr(r[e]||o[e],t)||mr(r.appContext[e],t);return!i&&s?o:i}}function mr(e,t){return e&&(e[t]||e[Ee(t)]||e[Kn(Ee(t))])}function _r(e,t,n,s){let r;const o=n,i=V(e);if(i||ae(e)){const l=i&<(e);let c=!1,f=!1;l&&(c=!Me(e),f=ft(e),e=$n(e)),r=new Array(e.length);for(let u=0,d=e.length;ut(l,c,void 0,o));else{const l=Object.keys(e);r=new Array(l.length);for(let c=0,f=l.length;ce?mi(e)?ts(e):xs(e.parent):null,ln=de(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>xs(e.parent),$root:e=>xs(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>Jo(e),$forceUpdate:e=>e.f||(e.f=()=>{zs(e.update)}),$nextTick:e=>e.n||(e.n=Qn.bind(e.proxy)),$watch:e=>kl.bind(e)}),as=(e,t)=>e!==ee&&!e.__isScriptSetup&&Y(e,t),tc={get({_:e},t){if(t==="__v_skip")return!0;const{ctx:n,setupState:s,data:r,props:o,accessCache:i,type:l,appContext:c}=e;if(t[0]!=="$"){const g=i[t];if(g!==void 0)switch(g){case 1:return s[t];case 2:return r[t];case 4:return n[t];case 3:return o[t]}else{if(as(s,t))return i[t]=1,s[t];if(r!==ee&&Y(r,t))return i[t]=2,r[t];if(Y(o,t))return i[t]=3,o[t];if(n!==ee&&Y(n,t))return i[t]=4,n[t];As&&(i[t]=0)}}const f=ln[t];let u,d;if(f)return t==="$attrs"&&pe(e.attrs,"get",""),f(e);if((u=l.__cssModules)&&(u=u[t]))return u;if(n!==ee&&Y(n,t))return i[t]=4,n[t];if(d=c.config.globalProperties,Y(d,t))return d[t]},set({_:e},t,n){const{data:s,setupState:r,ctx:o}=e;return as(r,t)?(r[t]=n,!0):s!==ee&&Y(s,t)?(s[t]=n,!0):Y(e.props,t)||t[0]==="$"&&t.slice(1)in e?!1:(o[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:s,appContext:r,props:o,type:i}},l){let c;return!!(n[l]||e!==ee&&l[0]!=="$"&&Y(e,l)||as(t,l)||Y(o,l)||Y(s,l)||Y(ln,l)||Y(r.config.globalProperties,l)||(c=i.__cssModules)&&c[l])},defineProperty(e,t,n){return n.get!=null?e._.accessCache[t]=0:Y(n,"value")&&this.set(e,t,n.value,null),Reflect.defineProperty(e,t,n)}};function vr(e){return V(e)?e.reduce((t,n)=>(t[n]=null,t),{}):e}let As=!0;function nc(e){const t=Jo(e),n=e.proxy,s=e.ctx;As=!1,t.beforeCreate&&yr(t.beforeCreate,e,"bc");const{data:r,computed:o,methods:i,watch:l,provide:c,inject:f,created:u,beforeMount:d,mounted:g,beforeUpdate:m,updated:A,activated:S,deactivated:N,beforeDestroy:M,beforeUnmount:T,destroyed:D,unmounted:w,render:U,renderTracked:ce,renderTriggered:W,errorCaptured:K,serverPrefetch:G,expose:re,inheritAttrs:me,components:Oe,directives:Se,filters:Et}=t;if(f&&sc(f,s,null),i)for(const H in i){const J=i[H];B(J)&&(s[H]=J.bind(n))}if(r){const H=r.call(n,n);Z(H)&&(e.data=yn(H))}if(As=!0,o)for(const H in o){const J=o[H],et=B(J)?J.bind(n,n):B(J.get)?J.get.bind(n,n):Ye,pt=!B(J)&&B(J.set)?J.set.bind(n):Ye,He=ue({get:et,set:pt});Object.defineProperty(s,H,{enumerable:!0,configurable:!0,get:()=>He.value,set:we=>He.value=we})}if(l)for(const H in l)zo(l[H],s,n,H);if(c){const H=B(c)?c.call(n):c;Reflect.ownKeys(H).forEach(J=>{Rn(J,H[J])})}u&&yr(u,e,"c");function se(H,J){V(J)?J.forEach(et=>H(et.bind(n))):J&&H(J.bind(n))}if(se(Kl,d),se(Qs,g),se(Gl,m),se(Wl,A),se(Ul,S),se(Bl,N),se(Ql,K),se(Jl,ce),se(zl,W),se(ql,T),se(Ys,w),se($l,G),V(re))if(re.length){const H=e.exposed||(e.exposed={});re.forEach(J=>{Object.defineProperty(H,J,{get:()=>n[J],set:et=>n[J]=et,enumerable:!0})})}else e.exposed||(e.exposed={});U&&e.render===Ye&&(e.render=U),me!=null&&(e.inheritAttrs=me),Oe&&(e.components=Oe),Se&&(e.directives=Se),G&&Wo(e)}function sc(e,t,n=Ye){V(e)&&(e=Rs(e));for(const s in e){const r=e[s];let o;Z(r)?"default"in r?o=Fe(r.from||s,r.default,!0):o=Fe(r.from||s):o=Fe(r),le(o)?Object.defineProperty(t,s,{enumerable:!0,configurable:!0,get:()=>o.value,set:i=>o.value=i}):t[s]=o}}function yr(e,t,n){Ze(V(e)?e.map(s=>s.bind(t.proxy)):e.bind(t.proxy),t,n)}function zo(e,t,n,s){let r=s.includes(".")?Go(n,s):()=>n[s];if(ae(e)){const o=t[e];B(o)&&sn(r,o)}else if(B(e))sn(r,e.bind(n));else if(Z(e))if(V(e))e.forEach(o=>zo(o,t,n,s));else{const o=B(e.handler)?e.handler.bind(n):t[e.handler];B(o)&&sn(r,o,e)}}function Jo(e){const t=e.type,{mixins:n,extends:s}=t,{mixins:r,optionsCache:o,config:{optionMergeStrategies:i}}=e.appContext,l=o.get(t);let c;return l?c=l:!r.length&&!n&&!s?c=t:(c={},r.length&&r.forEach(f=>Ln(c,f,i,!0)),Ln(c,t,i)),Z(t)&&o.set(t,c),c}function Ln(e,t,n,s=!1){const{mixins:r,extends:o}=t;o&&Ln(e,o,n,!0),r&&r.forEach(i=>Ln(e,i,n,!0));for(const i in t)if(!(s&&i==="expose")){const l=rc[i]||n&&n[i];e[i]=l?l(e[i],t[i]):t[i]}return e}const rc={data:br,props:Er,emits:Er,methods:Zt,computed:Zt,beforeCreate:_e,created:_e,beforeMount:_e,mounted:_e,beforeUpdate:_e,updated:_e,beforeDestroy:_e,beforeUnmount:_e,destroyed:_e,unmounted:_e,activated:_e,deactivated:_e,errorCaptured:_e,serverPrefetch:_e,components:Zt,directives:Zt,watch:ic,provide:br,inject:oc};function br(e,t){return t?e?function(){return de(B(e)?e.call(this,this):e,B(t)?t.call(this,this):t)}:t:e}function oc(e,t){return Zt(Rs(e),Rs(t))}function Rs(e){if(V(e)){const t={};for(let n=0;nt==="modelValue"||t==="model-value"?e.modelModifiers:e[`${t}Modifiers`]||e[`${Ee(t)}Modifiers`]||e[`${Pt(t)}Modifiers`];function ac(e,t,...n){if(e.isUnmounted)return;const s=e.vnode.props||ee;let r=n;const o=t.startsWith("update:"),i=o&&uc(s,t.slice(7));i&&(i.trim&&(r=n.map(u=>ae(u)?u.trim():u)),i.number&&(r=n.map(Gn)));let l,c=s[l=os(t)]||s[l=os(Ee(t))];!c&&o&&(c=s[l=os(Pt(t))]),c&&Ze(c,e,6,r);const f=s[l+"Once"];if(f){if(!e.emitted)e.emitted={};else if(e.emitted[l])return;e.emitted[l]=!0,Ze(f,e,6,r)}}const fc=new WeakMap;function Yo(e,t,n=!1){const s=n?fc:t.emitsCache,r=s.get(e);if(r!==void 0)return r;const o=e.emits;let i={},l=!1;if(!B(e)){const c=f=>{const u=Yo(f,t,!0);u&&(l=!0,de(i,u))};!n&&t.mixins.length&&t.mixins.forEach(c),e.extends&&c(e.extends),e.mixins&&e.mixins.forEach(c)}return!o&&!l?(Z(e)&&s.set(e,null),null):(V(o)?o.forEach(c=>i[c]=null):de(i,o),Z(e)&&s.set(e,i),i)}function Zn(e,t){return!e||!Un(t)?!1:(t=t.slice(2).replace(/Once$/,""),Y(e,t[0].toLowerCase()+t.slice(1))||Y(e,Pt(t))||Y(e,t))}function Sr(e){const{type:t,vnode:n,proxy:s,withProxy:r,propsOptions:[o],slots:i,attrs:l,emit:c,render:f,renderCache:u,props:d,data:g,setupState:m,ctx:A,inheritAttrs:S}=e,N=Dn(e);let M,T;try{if(n.shapeFlag&4){const w=r||s,U=w;M=Je(f.call(U,w,u,d,m,g,A)),T=l}else{const w=t;M=Je(w.length>1?w(d,{attrs:l,slots:i,emit:c}):w(d,null)),T=t.props?l:dc(l)}}catch(w){cn.length=0,Jn(w,e,1),M=be(bt)}let D=M;if(T&&S!==!1){const w=Object.keys(T),{shapeFlag:U}=D;w.length&&U&7&&(o&&w.some(Vs)&&(T=hc(T,o)),D=Bt(D,T,!1,!0))}return n.dirs&&(D=Bt(D,null,!1,!0),D.dirs=D.dirs?D.dirs.concat(n.dirs):n.dirs),n.transition&&Js(D,n.transition),M=D,Dn(N),M}const dc=e=>{let t;for(const n in e)(n==="class"||n==="style"||Un(n))&&((t||(t={}))[n]=e[n]);return t},hc=(e,t)=>{const n={};for(const s in e)(!Vs(s)||!(s.slice(9)in t))&&(n[s]=e[s]);return n};function pc(e,t,n){const{props:s,children:r,component:o}=e,{props:i,children:l,patchFlag:c}=t,f=o.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&c>=0){if(c&1024)return!0;if(c&16)return s?wr(s,i,f):!!i;if(c&8){const u=t.dynamicProps;for(let d=0;dObject.create(Zo),ti=e=>Object.getPrototypeOf(e)===Zo;function mc(e,t,n,s=!1){const r={},o=ei();e.propsDefaults=Object.create(null),ni(e,t,r,o);for(const i in e.propsOptions[0])i in r||(r[i]=void 0);n?e.props=s?r:Lo(r):e.type.props?e.props=r:e.props=o,e.attrs=o}function _c(e,t,n,s){const{props:r,attrs:o,vnode:{patchFlag:i}}=e,l=z(r),[c]=e.propsOptions;let f=!1;if((s||i>0)&&!(i&16)){if(i&8){const u=e.vnode.dynamicProps;for(let d=0;d{c=!0;const[g,m]=si(d,t,!0);de(i,g),m&&l.push(...m)};!n&&t.mixins.length&&t.mixins.forEach(u),e.extends&&u(e.extends),e.mixins&&e.mixins.forEach(u)}if(!o&&!c)return Z(e)&&s.set(e,Vt),Vt;if(V(o))for(let u=0;ue==="_"||e==="_ctx"||e==="$stable",Zs=e=>V(e)?e.map(Je):[Je(e)],yc=(e,t,n)=>{if(t._n)return t;const s=Il((...r)=>Zs(t(...r)),n);return s._c=!1,s},ri=(e,t,n)=>{const s=e._ctx;for(const r in e){if(Xs(r))continue;const o=e[r];if(B(o))t[r]=yc(r,o,s);else if(o!=null){const i=Zs(o);t[r]=()=>i}}},oi=(e,t)=>{const n=Zs(t);e.slots.default=()=>n},ii=(e,t,n)=>{for(const s in t)(n||!Xs(s))&&(e[s]=t[s])},bc=(e,t,n)=>{const s=e.slots=ei();if(e.vnode.shapeFlag&32){const r=t._;r?(ii(s,t,n),n&&po(s,"_",r,!0)):ri(t,s)}else t&&oi(e,t)},Ec=(e,t,n)=>{const{vnode:s,slots:r}=e;let o=!0,i=ee;if(s.shapeFlag&32){const l=t._;l?n&&l===1?o=!1:ii(r,t,n):(o=!t.$stable,ri(t,r)),i=t}else t&&(oi(e,t),i={default:1});if(o)for(const l in r)!Xs(l)&&i[l]==null&&delete r[l]},Re=Rc;function Sc(e){return wc(e)}function wc(e,t){const n=Wn();n.__VUE__=!0;const{insert:s,remove:r,patchProp:o,createElement:i,createText:l,createComment:c,setText:f,setElementText:u,parentNode:d,nextSibling:g,setScopeId:m=Ye,insertStaticContent:A}=e,S=(a,h,p,_=null,b=null,v=null,C=void 0,R=null,x=!!h.dynamicChildren)=>{if(a===h)return;a&&!Jt(a,h)&&(_=y(a),we(a,b,v,!0),a=null),h.patchFlag===-2&&(x=!1,h.dynamicChildren=null);const{type:E,ref:F,shapeFlag:P}=h;switch(E){case es:N(a,h,p,_);break;case bt:M(a,h,p,_);break;case Cn:a==null&&T(h,p,_,C);break;case Ve:Oe(a,h,p,_,b,v,C,R,x);break;default:P&1?U(a,h,p,_,b,v,C,R,x):P&6?Se(a,h,p,_,b,v,C,R,x):(P&64||P&128)&&E.process(a,h,p,_,b,v,C,R,x,L)}F!=null&&b?rn(F,a&&a.ref,v,h||a,!h):F==null&&a&&a.ref!=null&&rn(a.ref,null,v,a,!0)},N=(a,h,p,_)=>{if(a==null)s(h.el=l(h.children),p,_);else{const b=h.el=a.el;h.children!==a.children&&f(b,h.children)}},M=(a,h,p,_)=>{a==null?s(h.el=c(h.children||""),p,_):h.el=a.el},T=(a,h,p,_)=>{[a.el,a.anchor]=A(a.children,h,p,_,a.el,a.anchor)},D=({el:a,anchor:h},p,_)=>{let b;for(;a&&a!==h;)b=g(a),s(a,p,_),a=b;s(h,p,_)},w=({el:a,anchor:h})=>{let p;for(;a&&a!==h;)p=g(a),r(a),a=p;r(h)},U=(a,h,p,_,b,v,C,R,x)=>{if(h.type==="svg"?C="svg":h.type==="math"&&(C="mathml"),a==null)ce(h,p,_,b,v,C,R,x);else{const E=a.el&&a.el._isVueCE?a.el:null;try{E&&E._beginPatch(),G(a,h,b,v,C,R,x)}finally{E&&E._endPatch()}}},ce=(a,h,p,_,b,v,C,R)=>{let x,E;const{props:F,shapeFlag:P,transition:k,dirs:j}=a;if(x=a.el=i(a.type,v,F&&F.is,F),P&8?u(x,a.children):P&16&&K(a.children,x,null,_,b,fs(a,v),C,R),j&&wt(a,null,_,"created"),W(x,a,a.scopeId,C,_),F){for(const te in F)te!=="value"&&!en(te)&&o(x,te,null,F[te],v,_);"value"in F&&o(x,"value",null,F.value,v),(E=F.onVnodeBeforeMount)&&qe(E,_,a)}j&&wt(a,null,_,"beforeMount");const $=xc(b,k);$&&k.beforeEnter(x),s(x,h,p),((E=F&&F.onVnodeMounted)||$||j)&&Re(()=>{E&&qe(E,_,a),$&&k.enter(x),j&&wt(a,null,_,"mounted")},b)},W=(a,h,p,_,b)=>{if(p&&m(a,p),_)for(let v=0;v<_.length;v++)m(a,_[v]);if(b){let v=b.subTree;if(h===v||ai(v.type)&&(v.ssContent===h||v.ssFallback===h)){const C=b.vnode;W(a,C,C.scopeId,C.slotScopeIds,b.parent)}}},K=(a,h,p,_,b,v,C,R,x=0)=>{for(let E=x;E{const R=h.el=a.el;let{patchFlag:x,dynamicChildren:E,dirs:F}=h;x|=a.patchFlag&16;const P=a.props||ee,k=h.props||ee;let j;if(p&&xt(p,!1),(j=k.onVnodeBeforeUpdate)&&qe(j,p,h,a),F&&wt(h,a,p,"beforeUpdate"),p&&xt(p,!0),(P.innerHTML&&k.innerHTML==null||P.textContent&&k.textContent==null)&&u(R,""),E?re(a.dynamicChildren,E,R,p,_,fs(h,b),v):C||J(a,h,R,null,p,_,fs(h,b),v,!1),x>0){if(x&16)me(R,P,k,p,b);else if(x&2&&P.class!==k.class&&o(R,"class",null,k.class,b),x&4&&o(R,"style",P.style,k.style,b),x&8){const $=h.dynamicProps;for(let te=0;te<$.length;te++){const X=$[te],xe=P[X],Ae=k[X];(Ae!==xe||X==="value")&&o(R,X,xe,Ae,b,p)}}x&1&&a.children!==h.children&&u(R,h.children)}else!C&&E==null&&me(R,P,k,p,b);((j=k.onVnodeUpdated)||F)&&Re(()=>{j&&qe(j,p,h,a),F&&wt(h,a,p,"updated")},_)},re=(a,h,p,_,b,v,C)=>{for(let R=0;R{if(h!==p){if(h!==ee)for(const v in h)!en(v)&&!(v in p)&&o(a,v,h[v],null,b,_);for(const v in p){if(en(v))continue;const C=p[v],R=h[v];C!==R&&v!=="value"&&o(a,v,R,C,b,_)}"value"in p&&o(a,"value",h.value,p.value,b)}},Oe=(a,h,p,_,b,v,C,R,x)=>{const E=h.el=a?a.el:l(""),F=h.anchor=a?a.anchor:l("");let{patchFlag:P,dynamicChildren:k,slotScopeIds:j}=h;j&&(R=R?R.concat(j):j),a==null?(s(E,p,_),s(F,p,_),K(h.children||[],p,F,b,v,C,R,x)):P>0&&P&64&&k&&a.dynamicChildren&&a.dynamicChildren.length===k.length?(re(a.dynamicChildren,k,p,b,v,C,R),(h.key!=null||b&&h===b.subTree)&&li(a,h,!0)):J(a,h,p,F,b,v,C,R,x)},Se=(a,h,p,_,b,v,C,R,x)=>{h.slotScopeIds=R,a==null?h.shapeFlag&512?b.ctx.activate(h,p,_,C,x):Et(h,p,_,b,v,C,x):ht(a,h,x)},Et=(a,h,p,_,b,v,C)=>{const R=a.component=Mc(a,_,b);if(qo(a)&&(R.ctx.renderer=L),Lc(R,!1,C),R.asyncDep){if(b&&b.registerDep(R,se,C),!a.el){const x=R.subTree=be(bt);M(null,x,h,p),a.placeholder=x.el}}else se(R,a,h,p,b,v,C)},ht=(a,h,p)=>{const _=h.component=a.component;if(pc(a,h,p))if(_.asyncDep&&!_.asyncResolved){H(_,h,p);return}else _.next=h,_.update();else h.el=a.el,_.vnode=h},se=(a,h,p,_,b,v,C)=>{const R=()=>{if(a.isMounted){let{next:P,bu:k,u:j,parent:$,vnode:te}=a;{const Ge=ci(a);if(Ge){P&&(P.el=te.el,H(a,P,C)),Ge.asyncDep.then(()=>{Re(()=>{a.isUnmounted||E()},b)});return}}let X=P,xe;xt(a,!1),P?(P.el=te.el,H(a,P,C)):P=te,k&&An(k),(xe=P.props&&P.props.onVnodeBeforeUpdate)&&qe(xe,$,P,te),xt(a,!0);const Ae=Sr(a),Ke=a.subTree;a.subTree=Ae,S(Ke,Ae,d(Ke.el),y(Ke),a,b,v),P.el=Ae.el,X===null&&gc(a,Ae.el),j&&Re(j,b),(xe=P.props&&P.props.onVnodeUpdated)&&Re(()=>qe(xe,$,P,te),b)}else{let P;const{el:k,props:j}=h,{bm:$,m:te,parent:X,root:xe,type:Ae}=a,Ke=on(h);xt(a,!1),$&&An($),!Ke&&(P=j&&j.onVnodeBeforeMount)&&qe(P,X,h),xt(a,!0);{xe.ce&&xe.ce._hasShadowRoot()&&xe.ce._injectChildStyle(Ae,a.parent?a.parent.type:void 0);const Ge=a.subTree=Sr(a);S(null,Ge,p,_,a,b,v),h.el=Ge.el}if(te&&Re(te,b),!Ke&&(P=j&&j.onVnodeMounted)){const Ge=h;Re(()=>qe(P,X,Ge),b)}(h.shapeFlag&256||X&&on(X.vnode)&&X.vnode.shapeFlag&256)&&a.a&&Re(a.a,b),a.isMounted=!0,h=p=_=null}};a.scope.on();const x=a.effect=new Eo(R);a.scope.off();const E=a.update=x.run.bind(x),F=a.job=x.runIfDirty.bind(x);F.i=a,F.id=a.uid,x.scheduler=()=>zs(F),xt(a,!0),E()},H=(a,h,p)=>{h.component=a;const _=a.vnode.props;a.vnode=h,a.next=null,_c(a,h.props,_,p),Ec(a,h.children,p),ut(),hr(a),at()},J=(a,h,p,_,b,v,C,R,x=!1)=>{const E=a&&a.children,F=a?a.shapeFlag:0,P=h.children,{patchFlag:k,shapeFlag:j}=h;if(k>0){if(k&128){pt(E,P,p,_,b,v,C,R,x);return}else if(k&256){et(E,P,p,_,b,v,C,R,x);return}}j&8?(F&16&&Le(E,b,v),P!==E&&u(p,P)):F&16?j&16?pt(E,P,p,_,b,v,C,R,x):Le(E,b,v,!0):(F&8&&u(p,""),j&16&&K(P,p,_,b,v,C,R,x))},et=(a,h,p,_,b,v,C,R,x)=>{a=a||Vt,h=h||Vt;const E=a.length,F=h.length,P=Math.min(E,F);let k;for(k=0;kF?Le(a,b,v,!0,!1,P):K(h,p,_,b,v,C,R,x,P)},pt=(a,h,p,_,b,v,C,R,x)=>{let E=0;const F=h.length;let P=a.length-1,k=F-1;for(;E<=P&&E<=k;){const j=a[E],$=h[E]=x?rt(h[E]):Je(h[E]);if(Jt(j,$))S(j,$,p,null,b,v,C,R,x);else break;E++}for(;E<=P&&E<=k;){const j=a[P],$=h[k]=x?rt(h[k]):Je(h[k]);if(Jt(j,$))S(j,$,p,null,b,v,C,R,x);else break;P--,k--}if(E>P){if(E<=k){const j=k+1,$=jk)for(;E<=P;)we(a[E],b,v,!0),E++;else{const j=E,$=E,te=new Map;for(E=$;E<=k;E++){const Te=h[E]=x?rt(h[E]):Je(h[E]);Te.key!=null&&te.set(Te.key,E)}let X,xe=0;const Ae=k-$+1;let Ke=!1,Ge=0;const $t=new Array(Ae);for(E=0;E=Ae){we(Te,b,v,!0);continue}let We;if(Te.key!=null)We=te.get(Te.key);else for(X=$;X<=k;X++)if($t[X-$]===0&&Jt(Te,h[X])){We=X;break}We===void 0?we(Te,b,v,!0):($t[We-$]=E+1,We>=Ge?Ge=We:Ke=!0,S(Te,h[We],p,null,b,v,C,R,x),xe++)}const or=Ke?Ac($t):Vt;for(X=or.length-1,E=Ae-1;E>=0;E--){const Te=$+E,We=h[Te],ir=h[Te+1],lr=Te+1{const{el:v,type:C,transition:R,children:x,shapeFlag:E}=a;if(E&6){He(a.component.subTree,h,p,_);return}if(E&128){a.suspense.move(h,p,_);return}if(E&64){C.move(a,h,p,L);return}if(C===Ve){s(v,h,p);for(let P=0;PR.enter(v),b);else{const{leave:P,delayLeave:k,afterLeave:j}=R,$=()=>{a.ctx.isUnmounted?r(v):s(v,h,p)},te=()=>{v._isLeaving&&v[jl](!0),P(v,()=>{$(),j&&j()})};k?k(v,$,te):te()}else s(v,h,p)},we=(a,h,p,_=!1,b=!1)=>{const{type:v,props:C,ref:R,children:x,dynamicChildren:E,shapeFlag:F,patchFlag:P,dirs:k,cacheIndex:j}=a;if(P===-2&&(b=!1),R!=null&&(ut(),rn(R,null,p,a,!0),at()),j!=null&&(h.renderCache[j]=void 0),F&256){h.ctx.deactivate(a);return}const $=F&1&&k,te=!on(a);let X;if(te&&(X=C&&C.onVnodeBeforeUnmount)&&qe(X,h,a),F&6)St(a.component,p,_);else{if(F&128){a.suspense.unmount(p,_);return}$&&wt(a,null,h,"beforeUnmount"),F&64?a.type.remove(a,h,p,L,_):E&&!E.hasOnce&&(v!==Ve||P>0&&P&64)?Le(E,h,p,!1,!0):(v===Ve&&P&384||!b&&F&16)&&Le(x,h,p),_&&It(a)}(te&&(X=C&&C.onVnodeUnmounted)||$)&&Re(()=>{X&&qe(X,h,a),$&&wt(a,null,h,"unmounted")},p)},It=a=>{const{type:h,el:p,anchor:_,transition:b}=a;if(h===Ve){Nt(p,_);return}if(h===Cn){w(a);return}const v=()=>{r(p),b&&!b.persisted&&b.afterLeave&&b.afterLeave()};if(a.shapeFlag&1&&b&&!b.persisted){const{leave:C,delayLeave:R}=b,x=()=>C(p,v);R?R(a.el,v,x):x()}else v()},Nt=(a,h)=>{let p;for(;a!==h;)p=g(a),r(a),a=p;r(h)},St=(a,h,p)=>{const{bum:_,scope:b,job:v,subTree:C,um:R,m:x,a:E}=a;Ar(x),Ar(E),_&&An(_),b.stop(),v&&(v.flags|=8,we(C,a,h,p)),R&&Re(R,h),Re(()=>{a.isUnmounted=!0},h)},Le=(a,h,p,_=!1,b=!1,v=0)=>{for(let C=v;C{if(a.shapeFlag&6)return y(a.component.subTree);if(a.shapeFlag&128)return a.suspense.next();const h=g(a.anchor||a.el),p=h&&h[Vl];return p?g(p):h};let I=!1;const O=(a,h,p)=>{let _;a==null?h._vnode&&(we(h._vnode,null,null,!0),_=h._vnode.component):S(h._vnode||null,a,h,null,null,null,p),h._vnode=a,I||(I=!0,hr(_),Uo(),I=!1)},L={p:S,um:we,m:He,r:It,mt:Et,mc:K,pc:J,pbc:re,n:y,o:e};return{render:O,hydrate:void 0,createApp:cc(O)}}function fs({type:e,props:t},n){return n==="svg"&&e==="foreignObject"||n==="mathml"&&e==="annotation-xml"&&t&&t.encoding&&t.encoding.includes("html")?void 0:n}function xt({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function xc(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function li(e,t,n=!1){const s=e.children,r=t.children;if(V(s)&&V(r))for(let o=0;o>1,e[n[l]]0&&(t[s]=n[o-1]),n[o]=s)}}for(o=n.length,i=n[o-1];o-- >0;)n[o]=i,i=t[i];return n}function ci(e){const t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:ci(t)}function Ar(e){if(e)for(let t=0;te.__isSuspense;function Rc(e,t){t&&t.pendingBranch?V(e)?t.effects.push(...e):t.effects.push(e):Pl(e)}const Ve=Symbol.for("v-fgt"),es=Symbol.for("v-txt"),bt=Symbol.for("v-cmt"),Cn=Symbol.for("v-stc"),cn=[];let De=null;function Ce(e=!1){cn.push(De=e?null:[])}function Cc(){cn.pop(),De=cn[cn.length-1]||null}let pn=1;function kn(e,t=!1){pn+=e,e<0&&De&&t&&(De.hasOnce=!0)}function fi(e){return e.dynamicChildren=pn>0?De||Vt:null,Cc(),pn>0&&De&&De.push(e),e}function ke(e,t,n,s,r,o){return fi(Pe(e,t,n,s,r,o,!0))}function di(e,t,n,s,r){return fi(be(e,t,n,s,r,!0))}function Vn(e){return e?e.__v_isVNode===!0:!1}function Jt(e,t){return e.type===t.type&&e.key===t.key}const hi=({key:e})=>e??null,On=({ref:e,ref_key:t,ref_for:n})=>(typeof e=="number"&&(e=""+e),e!=null?ae(e)||le(e)||B(e)?{i:Ne,r:e,k:t,f:!!n}:e:null);function Pe(e,t=null,n=null,s=0,r=null,o=e===Ve?0:1,i=!1,l=!1){const c={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&hi(t),ref:t&&On(t),scopeId:Ho,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:o,patchFlag:s,dynamicProps:r,dynamicChildren:null,appContext:null,ctx:Ne};return l?(er(c,n),o&128&&e.normalize(c)):n&&(c.shapeFlag|=ae(n)?8:16),pn>0&&!i&&De&&(c.patchFlag>0||o&6)&&c.patchFlag!==32&&De.push(c),c}const be=Oc;function Oc(e,t=null,n=null,s=0,r=null,o=!1){if((!e||e===Zl)&&(e=bt),Vn(e)){const l=Bt(e,t,!0);return n&&er(l,n),pn>0&&!o&&De&&(l.shapeFlag&6?De[De.indexOf(e)]=l:De.push(l)),l.patchFlag=-2,l}if(Uc(e)&&(e=e.__vccOpts),t){t=Tc(t);let{class:l,style:c}=t;l&&!ae(l)&&(t.class=qn(l)),Z(c)&&(zn(c)&&!V(c)&&(c=de({},c)),t.style=js(c))}const i=ae(e)?1:ai(e)?128:Fl(e)?64:Z(e)?4:B(e)?2:0;return Pe(e,t,n,s,r,i,o,!0)}function Tc(e){return e?zn(e)||ti(e)?de({},e):e:null}function Bt(e,t,n=!1,s=!1){const{props:r,ref:o,patchFlag:i,children:l,transition:c}=e,f=t?Ic(r||{},t):r,u={__v_isVNode:!0,__v_skip:!0,type:e.type,props:f,key:f&&hi(f),ref:t&&t.ref?n&&o?V(o)?o.concat(On(t)):[o,On(t)]:On(t):o,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:l,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==Ve?i===-1?16:i|16:i,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:c,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&Bt(e.ssContent),ssFallback:e.ssFallback&&Bt(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return c&&s&&Js(u,c.clone(u)),u}function Pc(e=" ",t=0){return be(es,null,e,t)}function Ja(e,t){const n=be(Cn,null,e);return n.staticCount=t,n}function pi(e="",t=!1){return t?(Ce(),di(bt,null,e)):be(bt,null,e)}function Je(e){return e==null||typeof e=="boolean"?be(bt):V(e)?be(Ve,null,e.slice()):Vn(e)?rt(e):be(es,null,String(e))}function rt(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:Bt(e)}function er(e,t){let n=0;const{shapeFlag:s}=e;if(t==null)t=null;else if(V(t))n=16;else if(typeof t=="object")if(s&65){const r=t.default;r&&(r._c&&(r._d=!1),er(e,r()),r._c&&(r._d=!0));return}else{n=32;const r=t._;!r&&!ti(t)?t._ctx=Ne:r===3&&Ne&&(Ne.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else B(t)?(t={default:t,_ctx:Ne},n=32):(t=String(t),s&64?(n=16,t=[Pc(t)]):n=8);e.children=t,e.shapeFlag|=n}function Ic(...e){const t={};for(let n=0;nge||Ne;let Fn,Os;{const e=Wn(),t=(n,s)=>{let r;return(r=e[n])||(r=e[n]=[]),r.push(s),o=>{r.length>1?r.forEach(i=>i(o)):r[0](o)}};Fn=t("__VUE_INSTANCE_SETTERS__",n=>ge=n),Os=t("__VUE_SSR_SETTERS__",n=>gn=n)}const En=e=>{const t=ge;return Fn(e),e.scope.on(),()=>{e.scope.off(),Fn(t)}},Rr=()=>{ge&&ge.scope.off(),Fn(null)};function mi(e){return e.vnode.shapeFlag&4}let gn=!1;function Lc(e,t=!1,n=!1){t&&Os(t);const{props:s,children:r}=e.vnode,o=mi(e);mc(e,s,o,t),bc(e,r,n||t);const i=o?kc(e,t):void 0;return t&&Os(!1),i}function kc(e,t){const n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,tc);const{setup:s}=n;if(s){ut();const r=e.setupContext=s.length>1?Fc(e):null,o=En(e),i=bn(s,e,0,[e.props,r]),l=ao(i);if(at(),o(),(l||e.sp)&&!on(e)&&Wo(e),l){if(i.then(Rr,Rr),t)return i.then(c=>{Cr(e,c)}).catch(c=>{Jn(c,e,0)});e.asyncDep=i}else Cr(e,i)}else _i(e)}function Cr(e,t,n){B(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:Z(t)&&(e.setupState=Vo(t)),_i(e)}function _i(e,t,n){const s=e.type;e.render||(e.render=s.render||Ye);{const r=En(e);ut();try{nc(e)}finally{at(),r()}}}const Vc={get(e,t){return pe(e,"get",""),e[t]}};function Fc(e){const t=n=>{e.exposed=n||{}};return{attrs:new Proxy(e.attrs,Vc),slots:e.slots,emit:e.emit,expose:t}}function ts(e){return e.exposed?e.exposeProxy||(e.exposeProxy=new Proxy(Vo($s(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in ln)return ln[n](e)},has(t,n){return n in t||n in ln}})):e.proxy}function jc(e,t=!0){return B(e)?e.displayName||e.name:e.name||t&&e.__name}function Uc(e){return B(e)&&"__vccOpts"in e}const ue=(e,t)=>Al(e,t,gn);function vi(e,t,n){try{kn(-1);const s=arguments.length;return s===2?Z(t)&&!V(t)?Vn(t)?be(e,null,[t]):be(e,t):be(e,null,t):(s>3?n=Array.prototype.slice.call(arguments,2):s===3&&Vn(n)&&(n=[n]),be(e,t,n))}finally{kn(1)}}const Bc="3.5.30";/** -* @vue/runtime-dom v3.5.30 -* (c) 2018-present Yuxi (Evan) You and Vue contributors -* @license MIT -**/let Ts;const Or=typeof window<"u"&&window.trustedTypes;if(Or)try{Ts=Or.createPolicy("vue",{createHTML:e=>e})}catch{}const yi=Ts?e=>Ts.createHTML(e):e=>e,Hc="http://www.w3.org/2000/svg",Kc="http://www.w3.org/1998/Math/MathML",st=typeof document<"u"?document:null,Tr=st&&st.createElement("template"),Gc={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,s)=>{const r=t==="svg"?st.createElementNS(Hc,e):t==="mathml"?st.createElementNS(Kc,e):n?st.createElement(e,{is:n}):st.createElement(e);return e==="select"&&s&&s.multiple!=null&&r.setAttribute("multiple",s.multiple),r},createText:e=>st.createTextNode(e),createComment:e=>st.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>st.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,s,r,o){const i=n?n.previousSibling:t.lastChild;if(r&&(r===o||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),n),!(r===o||!(r=r.nextSibling)););else{Tr.innerHTML=yi(s==="svg"?`${e}`:s==="mathml"?`${e}`:e);const l=Tr.content;if(s==="svg"||s==="mathml"){const c=l.firstChild;for(;c.firstChild;)l.appendChild(c.firstChild);l.removeChild(c)}t.insertBefore(l,n)}return[i?i.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},Wc=Symbol("_vtc");function qc(e,t,n){const s=e[Wc];s&&(t=(t?[t,...s]:[...s]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const jn=Symbol("_vod"),bi=Symbol("_vsh"),$c={name:"show",beforeMount(e,{value:t},{transition:n}){e[jn]=e.style.display==="none"?"":e.style.display,n&&t?n.beforeEnter(e):Qt(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:s}){!t!=!n&&(s?t?(s.beforeEnter(e),Qt(e,!0),s.enter(e)):s.leave(e,()=>{Qt(e,!1)}):Qt(e,t))},beforeUnmount(e,{value:t}){Qt(e,t)}};function Qt(e,t){e.style.display=t?e[jn]:"none",e[bi]=!t}const zc=Symbol(""),Jc=/(?:^|;)\s*display\s*:/;function Qc(e,t,n){const s=e.style,r=ae(n);let o=!1;if(n&&!r){if(t)if(ae(t))for(const i of t.split(";")){const l=i.slice(0,i.indexOf(":")).trim();n[l]==null&&Tn(s,l,"")}else for(const i in t)n[i]==null&&Tn(s,i,"");for(const i in n)i==="display"&&(o=!0),Tn(s,i,n[i])}else if(r){if(t!==n){const i=s[zc];i&&(n+=";"+i),s.cssText=n,o=Jc.test(n)}}else t&&e.removeAttribute("style");jn in e&&(e[jn]=o?s.display:"",e[bi]&&(s.display="none"))}const Pr=/\s*!important$/;function Tn(e,t,n){if(V(n))n.forEach(s=>Tn(e,t,s));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const s=Yc(e,t);Pr.test(n)?e.setProperty(Pt(s),n.replace(Pr,""),"important"):e[s]=n}}const Ir=["Webkit","Moz","ms"],ds={};function Yc(e,t){const n=ds[t];if(n)return n;let s=Ee(t);if(s!=="filter"&&s in e)return ds[t]=s;s=Kn(s);for(let r=0;rhs||(tu.then(()=>hs=0),hs=Date.now());function su(e,t){const n=s=>{if(!s._vts)s._vts=Date.now();else if(s._vts<=n.attached)return;Ze(ru(s,n.value),t,5,[s])};return n.value=e,n.attached=nu(),n}function ru(e,t){if(V(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(s=>r=>!r._stopped&&s&&s(r))}else return t}const Vr=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,ou=(e,t,n,s,r,o)=>{const i=r==="svg";t==="class"?qc(e,s,i):t==="style"?Qc(e,n,s):Un(t)?Vs(t)||Zc(e,t,n,s,o):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):iu(e,t,s,i))?(Mr(e,t,s),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&Dr(e,t,s,i,o,t!=="value")):e._isVueCE&&(lu(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!ae(s)))?Mr(e,Ee(t),s,o,t):(t==="true-value"?e._trueValue=s:t==="false-value"&&(e._falseValue=s),Dr(e,t,s,i))};function iu(e,t,n,s){if(s)return!!(t==="innerHTML"||t==="textContent"||t in e&&Vr(t)&&B(n));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const r=e.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return Vr(t)&&ae(n)?!1:t in e}function lu(e,t){const n=e._def.props;if(!n)return!1;const s=Ee(t);return Array.isArray(n)?n.some(r=>Ee(r)===s):Object.keys(n).some(r=>Ee(r)===s)}const Ht=e=>{const t=e.props["onUpdate:modelValue"]||!1;return V(t)?n=>An(t,n):t};function cu(e){e.target.composing=!0}function Fr(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const ct=Symbol("_assign");function jr(e,t,n){return t&&(e=e.trim()),n&&(e=Gn(e)),e}const Qa={created(e,{modifiers:{lazy:t,trim:n,number:s}},r){e[ct]=Ht(r);const o=s||r.props&&r.props.type==="number";yt(e,t?"change":"input",i=>{i.target.composing||e[ct](jr(e.value,n,o))}),(n||o)&&yt(e,"change",()=>{e.value=jr(e.value,n,o)}),t||(yt(e,"compositionstart",cu),yt(e,"compositionend",Fr),yt(e,"change",Fr))},mounted(e,{value:t}){e.value=t??""},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:s,trim:r,number:o}},i){if(e[ct]=Ht(i),e.composing)return;const l=(o||e.type==="number")&&!/^0\d/.test(e.value)?Gn(e.value):e.value,c=t??"";l!==c&&(document.activeElement===e&&e.type!=="range"&&(s&&t===n||r&&e.value.trim()===c)||(e.value=c))}},Ya={deep:!0,created(e,t,n){e[ct]=Ht(n),yt(e,"change",()=>{const s=e._modelValue,r=mn(e),o=e.checked,i=e[ct];if(V(s)){const l=Us(s,r),c=l!==-1;if(o&&!c)i(s.concat(r));else if(!o&&c){const f=[...s];f.splice(l,1),i(f)}}else if(Wt(s)){const l=new Set(s);o?l.add(r):l.delete(r),i(l)}else i(Ei(e,o))})},mounted:Ur,beforeUpdate(e,t,n){e[ct]=Ht(n),Ur(e,t,n)}};function Ur(e,{value:t,oldValue:n},s){e._modelValue=t;let r;if(V(t))r=Us(t,s.props.value)>-1;else if(Wt(t))r=t.has(s.props.value);else{if(t===n)return;r=qt(t,Ei(e,!0))}e.checked!==r&&(e.checked=r)}const Xa={deep:!0,created(e,{value:t,modifiers:{number:n}},s){const r=Wt(t);yt(e,"change",()=>{const o=Array.prototype.filter.call(e.options,i=>i.selected).map(i=>n?Gn(mn(i)):mn(i));e[ct](e.multiple?r?new Set(o):o:o[0]),e._assigning=!0,Qn(()=>{e._assigning=!1})}),e[ct]=Ht(s)},mounted(e,{value:t}){Br(e,t)},beforeUpdate(e,t,n){e[ct]=Ht(n)},updated(e,{value:t}){e._assigning||Br(e,t)}};function Br(e,t){const n=e.multiple,s=V(t);if(!(n&&!s&&!Wt(t))){for(let r=0,o=e.options.length;rString(f)===String(l)):i.selected=Us(t,l)>-1}else i.selected=t.has(l);else if(qt(mn(i),t)){e.selectedIndex!==r&&(e.selectedIndex=r);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function mn(e){return"_value"in e?e._value:e.value}function Ei(e,t){const n=t?"_trueValue":"_falseValue";return n in e?e[n]:t}const uu=["ctrl","shift","alt","meta"],au={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>uu.some(n=>e[`${n}Key`]&&!t.includes(n))},Za=(e,t)=>{if(!e)return e;const n=e._withMods||(e._withMods={}),s=t.join(".");return n[s]||(n[s]=(r,...o)=>{for(let i=0;i{const t=du().createApp(...e),{mount:n}=t;return t.mount=s=>{const r=gu(s);if(!r)return;const o=t._component;!B(o)&&!o.render&&!o.template&&(o.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const i=n(r,!1,pu(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),i},t};function pu(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function gu(e){return ae(e)?document.querySelector(e):e}/*! - * pinia v2.3.1 - * (c) 2025 Eduardo San Martin Morote - * @license MIT - */let Si;const ns=e=>Si=e,wi=Symbol();function Ps(e){return e&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"&&typeof e.toJSON!="function"}var un;(function(e){e.direct="direct",e.patchObject="patch object",e.patchFunction="patch function"})(un||(un={}));function mu(){const e=yo(!0),t=e.run(()=>Ie({}));let n=[],s=[];const r=$s({install(o){ns(r),r._a=o,o.provide(wi,r),o.config.globalProperties.$pinia=r,s.forEach(i=>n.push(i)),s=[]},use(o){return this._a?n.push(o):s.push(o),this},_p:n,_a:null,_e:e,_s:new Map,state:t});return r}const xi=()=>{};function Kr(e,t,n,s=xi){e.push(t);const r=()=>{const o=e.indexOf(t);o>-1&&(e.splice(o,1),s())};return!n&&bo()&&Xi(r),r}function Mt(e,...t){e.slice().forEach(n=>{n(...t)})}const _u=e=>e(),Gr=Symbol(),ps=Symbol();function Is(e,t){e instanceof Map&&t instanceof Map?t.forEach((n,s)=>e.set(s,n)):e instanceof Set&&t instanceof Set&&t.forEach(e.add,e);for(const n in t){if(!t.hasOwnProperty(n))continue;const s=t[n],r=e[n];Ps(r)&&Ps(s)&&e.hasOwnProperty(n)&&!le(s)&&!lt(s)?e[n]=Is(r,s):e[n]=s}return e}const vu=Symbol();function yu(e){return!Ps(e)||!e.hasOwnProperty(vu)}const{assign:mt}=Object;function bu(e){return!!(le(e)&&e.effect)}function Eu(e,t,n,s){const{state:r,actions:o,getters:i}=t,l=n.state.value[e];let c;function f(){l||(n.state.value[e]=r?r():{});const u=El(n.state.value[e]);return mt(u,o,Object.keys(i||{}).reduce((d,g)=>(d[g]=$s(ue(()=>{ns(n);const m=n._s.get(e);return i[g].call(m,m)})),d),{}))}return c=Ai(e,f,t,n,s,!0),c}function Ai(e,t,n={},s,r,o){let i;const l=mt({actions:{}},n),c={deep:!0};let f,u,d=[],g=[],m;const A=s.state.value[e];!o&&!A&&(s.state.value[e]={});let S;function N(K){let G;f=u=!1,typeof K=="function"?(K(s.state.value[e]),G={type:un.patchFunction,storeId:e,events:m}):(Is(s.state.value[e],K),G={type:un.patchObject,payload:K,storeId:e,events:m});const re=S=Symbol();Qn().then(()=>{S===re&&(f=!0)}),u=!0,Mt(d,G,s.state.value[e])}const M=o?function(){const{state:G}=n,re=G?G():{};this.$patch(me=>{mt(me,re)})}:xi;function T(){i.stop(),d=[],g=[],s._s.delete(e)}const D=(K,G="")=>{if(Gr in K)return K[ps]=G,K;const re=function(){ns(s);const me=Array.from(arguments),Oe=[],Se=[];function Et(H){Oe.push(H)}function ht(H){Se.push(H)}Mt(g,{args:me,name:re[ps],store:U,after:Et,onError:ht});let se;try{se=K.apply(this&&this.$id===e?this:U,me)}catch(H){throw Mt(Se,H),H}return se instanceof Promise?se.then(H=>(Mt(Oe,H),H)).catch(H=>(Mt(Se,H),Promise.reject(H))):(Mt(Oe,se),se)};return re[Gr]=!0,re[ps]=G,re},w={_p:s,$id:e,$onAction:Kr.bind(null,g),$patch:N,$reset:M,$subscribe(K,G={}){const re=Kr(d,K,G.detached,()=>me()),me=i.run(()=>sn(()=>s.state.value[e],Oe=>{(G.flush==="sync"?u:f)&&K({storeId:e,type:un.direct,events:m},Oe)},mt({},c,G)));return re},$dispose:T},U=yn(w);s._s.set(e,U);const W=(s._a&&s._a.runWithContext||_u)(()=>s._e.run(()=>(i=yo()).run(()=>t({action:D}))));for(const K in W){const G=W[K];if(le(G)&&!bu(G)||lt(G))o||(A&&yu(G)&&(le(G)?G.value=A[K]:Is(G,A[K])),s.state.value[e][K]=G);else if(typeof G=="function"){const re=D(G,K);W[K]=re,l.actions[K]=G}}return mt(U,W),mt(z(U),W),Object.defineProperty(U,"$state",{get:()=>s.state.value[e],set:K=>{N(G=>{mt(G,K)})}}),s._p.forEach(K=>{mt(U,i.run(()=>K({store:U,app:s._a,pinia:s,options:l})))}),A&&o&&n.hydrate&&n.hydrate(U.$state,A),f=!0,u=!0,U}/*! #__NO_SIDE_EFFECTS__ */function Su(e,t,n){let s,r;const o=typeof t=="function";s=e,r=o?n:t;function i(l,c){const f=Dl();return l=l||(f?Fe(wi,null):null),l&&ns(l),l=Si,l._s.has(s)||(o?Ai(s,t,r,l):Eu(s,r,l)),l._s.get(s)}return i.$id=s,i}const wu="/api";class xu{constructor(t){cr(this,"baseUrl");this.baseUrl=t}getToken(){return localStorage.getItem("accessToken")}async request(t,n,s){const r={"Content-Type":"application/json"},o=this.getToken();o&&(r.Authorization=`Bearer ${o}`);const i={method:t,headers:r};s&&(i.body=JSON.stringify(s));const l=await fetch(`${this.baseUrl}${n}`,i);if(l.status===401&&await this.tryRefreshToken()){r.Authorization=`Bearer ${this.getToken()}`;const u=await fetch(`${this.baseUrl}${n}`,{...i,headers:r});return{data:await u.json(),status:u.status}}const c=await l.json();if(!l.ok)throw new Error(c.error||"Request failed");return{data:c,status:l.status}}async tryRefreshToken(){const t=localStorage.getItem("refreshToken");if(!t)return!1;try{const n=await fetch(`${this.baseUrl}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})});if(!n.ok)return!1;const s=await n.json();return localStorage.setItem("accessToken",s.accessToken),!0}catch{return!1}}get(t){return this.request("GET",t)}post(t,n){return this.request("POST",t,n)}put(t,n){return this.request("PUT",t,n)}delete(t){return this.request("DELETE",t)}}const Yt=new xu(wu),tr=Su("auth",()=>{const e=Ie(null),t=Ie(localStorage.getItem("accessToken")),n=Ie(localStorage.getItem("refreshToken")),s=Ie(localStorage.getItem("orgSlug")||""),r=ue(()=>!!e.value&&!!t.value),o=ue(()=>!!t.value),i=ue(()=>{var w;return((w=e.value)==null?void 0:w.role)==="chef"}),l=ue(()=>{var w;return((w=e.value)==null?void 0:w.role)==="disponent"}),c=ue(()=>{var w;return((w=e.value)==null?void 0:w.role)==="mitarbeiter"}),f=ue(()=>i.value||l.value),u=ue(()=>i.value||l.value),d=ue(()=>e.value?`${e.value.first_name} ${e.value.last_name}`:"");function g(w,U){t.value=w,n.value=U,localStorage.setItem("accessToken",w),localStorage.setItem("refreshToken",U)}function m(w){s.value=w,localStorage.setItem("orgSlug",w)}function A(){e.value=null,t.value=null,n.value=null,localStorage.removeItem("accessToken"),localStorage.removeItem("refreshToken")}async function S(w,U,ce){const W=await Yt.post("/auth/login",{email:w,password:U,org_slug:ce});return g(W.data.accessToken,W.data.refreshToken),m(ce),e.value=W.data.user,W.data}async function N(w){return(await Yt.post("/auth/register",w)).data}async function M(){try{await Yt.post("/auth/logout")}catch{}A()}async function T(){try{const w=await Yt.get("/auth/me");e.value=w.data.user}catch{A()}}async function D(){if(!n.value)throw new Error("No refresh token");const w=await Yt.post("/auth/refresh",{refreshToken:n.value});return t.value=w.data.accessToken,localStorage.setItem("accessToken",w.data.accessToken),w.data.accessToken}return{user:e,accessToken:t,refreshToken:n,orgSlug:s,isAuthenticated:r,hasStoredToken:o,isChef:i,isDisponent:l,isMitarbeiter:c,canManageUsers:f,canManageOrders:u,fullName:d,login:S,register:N,logout:M,fetchCurrentUser:T,refreshAccessToken:D,setOrgSlug:m}}),Au={class:"fixed inset-0 bg-gradient-to-br from-purple-600 to-indigo-700 flex flex-col items-center justify-center z-50"},Ru={key:0,class:"text-center"},Cu=["disabled"],Ou={key:0,class:"animate-spin"},Tu={key:1},Pu={key:1,class:"text-center"},Iu={class:"flex space-x-3 mb-8"},Nu={key:0,class:"text-red-300 text-sm mb-4"},Du={class:"grid grid-cols-3 gap-4 max-w-xs"},Mu=["onClick"],Lu={key:1,class:"w-16 h-16"},ku=Yn({__name:"LockScreen",emits:["unlocked"],setup(e,{emit:t}){const n=t;tr();const s=Ie(null),r=Ie(""),o=Ie(!1),i=Ie(["","","","","",""]),l=Ie(0);Qs(()=>{s.value=localStorage.getItem("lockMethod"),s.value==="biometric"&&c()});async function c(){o.value=!0,r.value="";try{if(!window.PublicKeyCredential)throw new Error("Biometrie nicht verfügbar");const A=localStorage.getItem("biometricCredentialId");if(!A)throw new Error("Keine biometrischen Daten gespeichert");await navigator.credentials.get({publicKey:{challenge:new Uint8Array(32),timeout:6e4,userVerification:"required",allowCredentials:[{id:Uint8Array.from(atob(A),N=>N.charCodeAt(0)),type:"public-key",transports:["internal"]}]}})&&n("unlocked")}catch(A){console.error("Biometric auth failed:",A),r.value="Biometrie fehlgeschlagen. Bitte PIN verwenden.",s.value="pin"}o.value=!1}function f(A){l.value<6&&(i.value[l.value]=A,l.value++,l.value===6&&g())}function u(){l.value>0&&(l.value--,i.value[l.value]=""),r.value=""}function d(){i.value=["","","","","",""],l.value=0,r.value=""}async function g(){const A=i.value.join(""),S=localStorage.getItem("appPin");A===S?n("unlocked"):(r.value="Falscher PIN",setTimeout(d,500))}function m(){s.value="pin",r.value=""}return(A,S)=>(Ce(),ke("div",Au,[S[2]||(S[2]=Pe("div",{class:"text-6xl mb-4"},"🔐",-1)),S[3]||(S[3]=Pe("h1",{class:"text-2xl font-bold text-white mb-2"},"SeCu",-1)),S[4]||(S[4]=Pe("p",{class:"text-white/70 mb-8"},"Bitte entsperren",-1)),s.value==="biometric"&&!r.value?(Ce(),ke("div",Ru,[Pe("button",{onClick:c,disabled:o.value,class:"w-20 h-20 bg-white/20 rounded-full flex items-center justify-center text-4xl mb-4 hover:bg-white/30 transition"},[o.value?(Ce(),ke("span",Ou,"⏳")):(Ce(),ke("span",Tu,"👆"))],8,Cu),S[1]||(S[1]=Pe("p",{class:"text-white/70 text-sm"},"Fingerabdruck oder Face ID",-1)),Pe("button",{onClick:m,class:"mt-4 text-white/50 text-sm underline"}," Stattdessen PIN verwenden ")])):(Ce(),ke("div",Pu,[Pe("div",Iu,[(Ce(!0),ke(Ve,null,_r(i.value,(N,M)=>(Ce(),ke("div",{key:M,class:qn(["w-4 h-4 rounded-full transition-all",N?"bg-white scale-110":"bg-white/30",r.value?"animate-shake bg-red-400":""])},null,2))),128))]),r.value?(Ce(),ke("p",Nu,ys(r.value),1)):pi("",!0),Pe("div",Du,[(Ce(),ke(Ve,null,_r([1,2,3,4,5,6,7,8,9],N=>Pe("button",{key:N,onClick:M=>f(String(N)),class:"w-16 h-16 bg-white/20 rounded-full text-white text-2xl font-semibold hover:bg-white/30 transition"},ys(N),9,Mu)),64)),s.value==="biometric"||A.localStorage.getItem("biometricCredentialId")?(Ce(),ke("button",{key:0,onClick:c,class:"w-16 h-16 bg-white/20 rounded-full text-white text-2xl hover:bg-white/30 transition"}," 👆 ")):(Ce(),ke("div",Lu)),Pe("button",{onClick:S[0]||(S[0]=N=>f("0")),class:"w-16 h-16 bg-white/20 rounded-full text-white text-2xl font-semibold hover:bg-white/30 transition"}," 0 "),Pe("button",{onClick:u,class:"w-16 h-16 bg-white/10 rounded-full text-white text-xl hover:bg-white/20 transition"}," ⌫ ")])]))]))}}),Vu=(e,t)=>{const n=e.__vccOpts||e;for(const[s,r]of t)n[s]=r;return n},Fu=Vu(ku,[["__scopeId","data-v-5cf90e48"]]),Wr=3e4,ju=Yn({__name:"App",setup(e){const t=tr(),n=Ie(!1),s=Ie(Date.now()),r=ue(()=>localStorage.getItem("lockMethod")&&localStorage.getItem("lockMethod")!=="none"&&t.isAuthenticated);Qs(async()=>{if(t.hasStoredToken&&await t.fetchCurrentUser(),r.value){const c=localStorage.getItem("lastUnlockTime"),f=Date.now();(!c||f-parseInt(c)>Wr)&&(n.value=!0)}document.addEventListener("visibilitychange",i),document.addEventListener("touchstart",o),document.addEventListener("click",o),document.addEventListener("keydown",o)}),Ys(()=>{document.removeEventListener("visibilitychange",i),document.removeEventListener("touchstart",o),document.removeEventListener("click",o),document.removeEventListener("keydown",o)});function o(){s.value=Date.now()}function i(){if(document.visibilityState==="hidden")localStorage.setItem("backgroundTime",String(Date.now()));else if(document.visibilityState==="visible"&&r.value){const c=localStorage.getItem("backgroundTime"),f=Date.now();c&&f-parseInt(c)>Wr&&(n.value=!0)}}function l(){n.value=!1,localStorage.setItem("lastUnlockTime",String(Date.now()))}return(c,f)=>{const u=Xl("router-view");return Ce(),ke(Ve,null,[n.value&&r.value?(Ce(),di(Fu,{key:0,onUnlocked:l})):pi("",!0),Nl(be(u,null,null,512),[[$c,!n.value||!r.value]])],64)}}}),Uu="modulepreload",Bu=function(e){return"/app/"+e},qr={},oe=function(t,n,s){let r=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),l=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));r=Promise.allSettled(n.map(c=>{if(c=Bu(c),c in qr)return;qr[c]=!0;const f=c.endsWith(".css"),u=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const d=document.createElement("link");if(d.rel=f?"stylesheet":Uu,f||(d.as="script"),d.crossOrigin="",d.href=c,l&&d.setAttribute("nonce",l),document.head.appendChild(d),f)return new Promise((g,m)=>{d.addEventListener("load",g),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return r.then(i=>{for(const l of i||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};/*! - * vue-router v4.6.4 - * (c) 2025 Eduardo San Martin Morote - * @license MIT - */const kt=typeof document<"u";function Ri(e){return typeof e=="object"||"displayName"in e||"props"in e||"__vccOpts"in e}function Hu(e){return e.__esModule||e[Symbol.toStringTag]==="Module"||e.default&&Ri(e.default)}const Q=Object.assign;function gs(e,t){const n={};for(const s in t){const r=t[s];n[s]=Be(r)?r.map(e):e(r)}return n}const an=()=>{},Be=Array.isArray;function $r(e,t){const n={};for(const s in e)n[s]=s in t?t[s]:e[s];return n}const Ci=/#/g,Ku=/&/g,Gu=/\//g,Wu=/=/g,qu=/\?/g,Oi=/\+/g,$u=/%5B/g,zu=/%5D/g,Ti=/%5E/g,Ju=/%60/g,Pi=/%7B/g,Qu=/%7C/g,Ii=/%7D/g,Yu=/%20/g;function nr(e){return e==null?"":encodeURI(""+e).replace(Qu,"|").replace($u,"[").replace(zu,"]")}function Xu(e){return nr(e).replace(Pi,"{").replace(Ii,"}").replace(Ti,"^")}function Ns(e){return nr(e).replace(Oi,"%2B").replace(Yu,"+").replace(Ci,"%23").replace(Ku,"%26").replace(Ju,"`").replace(Pi,"{").replace(Ii,"}").replace(Ti,"^")}function Zu(e){return Ns(e).replace(Wu,"%3D")}function ea(e){return nr(e).replace(Ci,"%23").replace(qu,"%3F")}function ta(e){return ea(e).replace(Gu,"%2F")}function _n(e){if(e==null)return null;try{return decodeURIComponent(""+e)}catch{}return""+e}const na=/\/$/,sa=e=>e.replace(na,"");function ms(e,t,n="/"){let s,r={},o="",i="";const l=t.indexOf("#");let c=t.indexOf("?");return c=l>=0&&c>l?-1:c,c>=0&&(s=t.slice(0,c),o=t.slice(c,l>0?l:t.length),r=e(o.slice(1))),l>=0&&(s=s||t.slice(0,l),i=t.slice(l,t.length)),s=la(s??t,n),{fullPath:s+o+i,path:s,query:r,hash:_n(i)}}function ra(e,t){const n=t.query?e(t.query):"";return t.path+(n&&"?")+n+(t.hash||"")}function zr(e,t){return!t||!e.toLowerCase().startsWith(t.toLowerCase())?e:e.slice(t.length)||"/"}function oa(e,t,n){const s=t.matched.length-1,r=n.matched.length-1;return s>-1&&s===r&&Kt(t.matched[s],n.matched[r])&&Ni(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}function Kt(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function Ni(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var n in e)if(!ia(e[n],t[n]))return!1;return!0}function ia(e,t){return Be(e)?Jr(e,t):Be(t)?Jr(t,e):(e==null?void 0:e.valueOf())===(t==null?void 0:t.valueOf())}function Jr(e,t){return Be(t)?e.length===t.length&&e.every((n,s)=>n===t[s]):e.length===1&&e[0]===t}function la(e,t){if(e.startsWith("/"))return e;if(!e)return t;const n=t.split("/"),s=e.split("/"),r=s[s.length-1];(r===".."||r===".")&&s.push("");let o=n.length-1,i,l;for(i=0;i1&&o--;else break;return n.slice(0,o).join("/")+"/"+s.slice(i).join("/")}const gt={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0};let Ds=function(e){return e.pop="pop",e.push="push",e}({}),_s=function(e){return e.back="back",e.forward="forward",e.unknown="",e}({});function ca(e){if(!e)if(kt){const t=document.querySelector("base");e=t&&t.getAttribute("href")||"/",e=e.replace(/^\w+:\/\/[^\/]+/,"")}else e="/";return e[0]!=="/"&&e[0]!=="#"&&(e="/"+e),sa(e)}const ua=/^[^#]+#/;function aa(e,t){return e.replace(ua,"#")+t}function fa(e,t){const n=document.documentElement.getBoundingClientRect(),s=e.getBoundingClientRect();return{behavior:t.behavior,left:s.left-n.left-(t.left||0),top:s.top-n.top-(t.top||0)}}const ss=()=>({left:window.scrollX,top:window.scrollY});function da(e){let t;if("el"in e){const n=e.el,s=typeof n=="string"&&n.startsWith("#"),r=typeof n=="string"?s?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!r)return;t=fa(r,e)}else t=e;"scrollBehavior"in document.documentElement.style?window.scrollTo(t):window.scrollTo(t.left!=null?t.left:window.scrollX,t.top!=null?t.top:window.scrollY)}function Qr(e,t){return(history.state?history.state.position-t:-1)+e}const Ms=new Map;function ha(e,t){Ms.set(e,t)}function pa(e){const t=Ms.get(e);return Ms.delete(e),t}function ga(e){return typeof e=="string"||e&&typeof e=="object"}function Di(e){return typeof e=="string"||typeof e=="symbol"}let ie=function(e){return e[e.MATCHER_NOT_FOUND=1]="MATCHER_NOT_FOUND",e[e.NAVIGATION_GUARD_REDIRECT=2]="NAVIGATION_GUARD_REDIRECT",e[e.NAVIGATION_ABORTED=4]="NAVIGATION_ABORTED",e[e.NAVIGATION_CANCELLED=8]="NAVIGATION_CANCELLED",e[e.NAVIGATION_DUPLICATED=16]="NAVIGATION_DUPLICATED",e}({});const Mi=Symbol("");ie.MATCHER_NOT_FOUND+"",ie.NAVIGATION_GUARD_REDIRECT+"",ie.NAVIGATION_ABORTED+"",ie.NAVIGATION_CANCELLED+"",ie.NAVIGATION_DUPLICATED+"";function Gt(e,t){return Q(new Error,{type:e,[Mi]:!0},t)}function nt(e,t){return e instanceof Error&&Mi in e&&(t==null||!!(e.type&t))}const ma=["params","query","hash"];function _a(e){if(typeof e=="string")return e;if(e.path!=null)return e.path;const t={};for(const n of ma)n in e&&(t[n]=e[n]);return JSON.stringify(t,null,2)}function va(e){const t={};if(e===""||e==="?")return t;const n=(e[0]==="?"?e.slice(1):e).split("&");for(let s=0;sr&&Ns(r)):[s&&Ns(s)]).forEach(r=>{r!==void 0&&(t+=(t.length?"&":"")+n,r!=null&&(t+="="+r))})}return t}function ya(e){const t={};for(const n in e){const s=e[n];s!==void 0&&(t[n]=Be(s)?s.map(r=>r==null?null:""+r):s==null?s:""+s)}return t}const ba=Symbol(""),Xr=Symbol(""),rs=Symbol(""),sr=Symbol(""),Ls=Symbol("");function Xt(){let e=[];function t(s){return e.push(s),()=>{const r=e.indexOf(s);r>-1&&e.splice(r,1)}}function n(){e=[]}return{add:t,list:()=>e.slice(),reset:n}}function vt(e,t,n,s,r,o=i=>i()){const i=s&&(s.enterCallbacks[r]=s.enterCallbacks[r]||[]);return()=>new Promise((l,c)=>{const f=g=>{g===!1?c(Gt(ie.NAVIGATION_ABORTED,{from:n,to:t})):g instanceof Error?c(g):ga(g)?c(Gt(ie.NAVIGATION_GUARD_REDIRECT,{from:t,to:g})):(i&&s.enterCallbacks[r]===i&&typeof g=="function"&&i.push(g),l())},u=o(()=>e.call(s&&s.instances[r],t,n,f));let d=Promise.resolve(u);e.length<3&&(d=d.then(f)),d.catch(g=>c(g))})}function vs(e,t,n,s,r=o=>o()){const o=[];for(const i of e)for(const l in i.components){let c=i.components[l];if(!(t!=="beforeRouteEnter"&&!i.instances[l]))if(Ri(c)){const f=(c.__vccOpts||c)[t];f&&o.push(vt(f,n,s,i,l,r))}else{let f=c();o.push(()=>f.then(u=>{if(!u)throw new Error(`Couldn't resolve component "${l}" at "${i.path}"`);const d=Hu(u)?u.default:u;i.mods[l]=u,i.components[l]=d;const g=(d.__vccOpts||d)[t];return g&&vt(g,n,s,i,l,r)()}))}}return o}function Ea(e,t){const n=[],s=[],r=[],o=Math.max(t.matched.length,e.matched.length);for(let i=0;iKt(f,l))?s.push(l):n.push(l));const c=e.matched[i];c&&(t.matched.find(f=>Kt(f,c))||r.push(c))}return[n,s,r]}/*! - * vue-router v4.6.4 - * (c) 2025 Eduardo San Martin Morote - * @license MIT - */let Sa=()=>location.protocol+"//"+location.host;function Li(e,t){const{pathname:n,search:s,hash:r}=t,o=e.indexOf("#");if(o>-1){let i=r.includes(e.slice(o))?e.slice(o).length:1,l=r.slice(i);return l[0]!=="/"&&(l="/"+l),zr(l,"")}return zr(n,e)+s+r}function wa(e,t,n,s){let r=[],o=[],i=null;const l=({state:g})=>{const m=Li(e,location),A=n.value,S=t.value;let N=0;if(g){if(n.value=m,t.value=g,i&&i===A){i=null;return}N=S?g.position-S.position:0}else s(m);r.forEach(M=>{M(n.value,A,{delta:N,type:Ds.pop,direction:N?N>0?_s.forward:_s.back:_s.unknown})})};function c(){i=n.value}function f(g){r.push(g);const m=()=>{const A=r.indexOf(g);A>-1&&r.splice(A,1)};return o.push(m),m}function u(){if(document.visibilityState==="hidden"){const{history:g}=window;if(!g.state)return;g.replaceState(Q({},g.state,{scroll:ss()}),"")}}function d(){for(const g of o)g();o=[],window.removeEventListener("popstate",l),window.removeEventListener("pagehide",u),document.removeEventListener("visibilitychange",u)}return window.addEventListener("popstate",l),window.addEventListener("pagehide",u),document.addEventListener("visibilitychange",u),{pauseListeners:c,listen:f,destroy:d}}function Zr(e,t,n,s=!1,r=!1){return{back:e,current:t,forward:n,replaced:s,position:window.history.length,scroll:r?ss():null}}function xa(e){const{history:t,location:n}=window,s={value:Li(e,n)},r={value:t.state};r.value||o(s.value,{back:null,current:s.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0);function o(c,f,u){const d=e.indexOf("#"),g=d>-1?(n.host&&document.querySelector("base")?e:e.slice(d))+c:Sa()+e+c;try{t[u?"replaceState":"pushState"](f,"",g),r.value=f}catch(m){console.error(m),n[u?"replace":"assign"](g)}}function i(c,f){o(c,Q({},t.state,Zr(r.value.back,c,r.value.forward,!0),f,{position:r.value.position}),!0),s.value=c}function l(c,f){const u=Q({},r.value,t.state,{forward:c,scroll:ss()});o(u.current,u,!0),o(c,Q({},Zr(s.value,c,null),{position:u.position+1},f),!1),s.value=c}return{location:s,state:r,push:l,replace:i}}function Aa(e){e=ca(e);const t=xa(e),n=wa(e,t.state,t.location,t.replace);function s(o,i=!0){i||n.pauseListeners(),history.go(o)}const r=Q({location:"",base:e,go:s,createHref:aa.bind(null,e)},t,n);return Object.defineProperty(r,"location",{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(r,"state",{enumerable:!0,get:()=>t.state.value}),r}let Rt=function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.Group=2]="Group",e}({});var fe=function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.ParamRegExp=2]="ParamRegExp",e[e.ParamRegExpEnd=3]="ParamRegExpEnd",e[e.EscapeNext=4]="EscapeNext",e}(fe||{});const Ra={type:Rt.Static,value:""},Ca=/[a-zA-Z0-9_]/;function Oa(e){if(!e)return[[]];if(e==="/")return[[Ra]];if(!e.startsWith("/"))throw new Error(`Invalid path "${e}"`);function t(m){throw new Error(`ERR (${n})/"${f}": ${m}`)}let n=fe.Static,s=n;const r=[];let o;function i(){o&&r.push(o),o=[]}let l=0,c,f="",u="";function d(){f&&(n===fe.Static?o.push({type:Rt.Static,value:f}):n===fe.Param||n===fe.ParamRegExp||n===fe.ParamRegExpEnd?(o.length>1&&(c==="*"||c==="+")&&t(`A repeatable param (${f}) must be alone in its segment. eg: '/:ids+.`),o.push({type:Rt.Param,value:f,regexp:u,repeatable:c==="*"||c==="+",optional:c==="*"||c==="?"})):t("Invalid state to consume buffer"),f="")}function g(){f+=c}for(;lt.length?t.length===1&&t[0]===ve.Static+ve.Segment?1:-1:0}function ki(e,t){let n=0;const s=e.score,r=t.score;for(;n0&&t[t.length-1]<0}const Da={strict:!1,end:!0,sensitive:!1};function Ma(e,t,n){const s=Ia(Oa(e.path),n),r=Q(s,{record:e,parent:t,children:[],alias:[]});return t&&!r.record.aliasOf==!t.record.aliasOf&&t.children.push(r),r}function La(e,t){const n=[],s=new Map;t=$r(Da,t);function r(d){return s.get(d)}function o(d,g,m){const A=!m,S=so(d);S.aliasOf=m&&m.record;const N=$r(t,d),M=[S];if("alias"in d){const w=typeof d.alias=="string"?[d.alias]:d.alias;for(const U of w)M.push(so(Q({},S,{components:m?m.record.components:S.components,path:U,aliasOf:m?m.record:S})))}let T,D;for(const w of M){const{path:U}=w;if(g&&U[0]!=="/"){const ce=g.record.path,W=ce[ce.length-1]==="/"?"":"/";w.path=g.record.path+(U&&W+U)}if(T=Ma(w,g,N),m?m.alias.push(T):(D=D||T,D!==T&&D.alias.push(T),A&&d.name&&!ro(T)&&i(d.name)),Vi(T)&&c(T),S.children){const ce=S.children;for(let W=0;W{i(D)}:an}function i(d){if(Di(d)){const g=s.get(d);g&&(s.delete(d),n.splice(n.indexOf(g),1),g.children.forEach(i),g.alias.forEach(i))}else{const g=n.indexOf(d);g>-1&&(n.splice(g,1),d.record.name&&s.delete(d.record.name),d.children.forEach(i),d.alias.forEach(i))}}function l(){return n}function c(d){const g=Fa(d,n);n.splice(g,0,d),d.record.name&&!ro(d)&&s.set(d.record.name,d)}function f(d,g){let m,A={},S,N;if("name"in d&&d.name){if(m=s.get(d.name),!m)throw Gt(ie.MATCHER_NOT_FOUND,{location:d});N=m.record.name,A=Q(no(g.params,m.keys.filter(D=>!D.optional).concat(m.parent?m.parent.keys.filter(D=>D.optional):[]).map(D=>D.name)),d.params&&no(d.params,m.keys.map(D=>D.name))),S=m.stringify(A)}else if(d.path!=null)S=d.path,m=n.find(D=>D.re.test(S)),m&&(A=m.parse(S),N=m.record.name);else{if(m=g.name?s.get(g.name):n.find(D=>D.re.test(g.path)),!m)throw Gt(ie.MATCHER_NOT_FOUND,{location:d,currentLocation:g});N=m.record.name,A=Q({},g.params,d.params),S=m.stringify(A)}const M=[];let T=m;for(;T;)M.unshift(T.record),T=T.parent;return{name:N,path:S,params:A,matched:M,meta:Va(M)}}e.forEach(d=>o(d));function u(){n.length=0,s.clear()}return{addRoute:o,resolve:f,removeRoute:i,clearRoutes:u,getRoutes:l,getRecordMatcher:r}}function no(e,t){const n={};for(const s of t)s in e&&(n[s]=e[s]);return n}function so(e){const t={path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:e.aliasOf,beforeEnter:e.beforeEnter,props:ka(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in e?e.components||null:e.component&&{default:e.component}};return Object.defineProperty(t,"mods",{value:{}}),t}function ka(e){const t={},n=e.props||!1;if("component"in e)t.default=n;else for(const s in e.components)t[s]=typeof n=="object"?n[s]:n;return t}function ro(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function Va(e){return e.reduce((t,n)=>Q(t,n.meta),{})}function Fa(e,t){let n=0,s=t.length;for(;n!==s;){const o=n+s>>1;ki(e,t[o])<0?s=o:n=o+1}const r=ja(e);return r&&(s=t.lastIndexOf(r,s-1)),s}function ja(e){let t=e;for(;t=t.parent;)if(Vi(t)&&ki(e,t)===0)return t}function Vi({record:e}){return!!(e.name||e.components&&Object.keys(e.components).length||e.redirect)}function oo(e){const t=Fe(rs),n=Fe(sr),s=ue(()=>{const c=Ot(e.to);return t.resolve(c)}),r=ue(()=>{const{matched:c}=s.value,{length:f}=c,u=c[f-1],d=n.matched;if(!u||!d.length)return-1;const g=d.findIndex(Kt.bind(null,u));if(g>-1)return g;const m=io(c[f-2]);return f>1&&io(u)===m&&d[d.length-1].path!==m?d.findIndex(Kt.bind(null,c[f-2])):g}),o=ue(()=>r.value>-1&&Ga(n.params,s.value.params)),i=ue(()=>r.value>-1&&r.value===n.matched.length-1&&Ni(n.params,s.value.params));function l(c={}){if(Ka(c)){const f=t[Ot(e.replace)?"replace":"push"](Ot(e.to)).catch(an);return e.viewTransition&&typeof document<"u"&&"startViewTransition"in document&&document.startViewTransition(()=>f),f}return Promise.resolve()}return{route:s,href:ue(()=>s.value.href),isActive:o,isExactActive:i,navigate:l}}function Ua(e){return e.length===1?e[0]:e}const Ba=Yn({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"},viewTransition:Boolean},useLink:oo,setup(e,{slots:t}){const n=yn(oo(e)),{options:s}=Fe(rs),r=ue(()=>({[lo(e.activeClass,s.linkActiveClass,"router-link-active")]:n.isActive,[lo(e.exactActiveClass,s.linkExactActiveClass,"router-link-exact-active")]:n.isExactActive}));return()=>{const o=t.default&&Ua(t.default(n));return e.custom?o:vi("a",{"aria-current":n.isExactActive?e.ariaCurrentValue:null,href:n.href,onClick:n.navigate,class:r.value},o)}}}),Ha=Ba;function Ka(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!==void 0&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function Ga(e,t){for(const n in t){const s=t[n],r=e[n];if(typeof s=="string"){if(s!==r)return!1}else if(!Be(r)||r.length!==s.length||s.some((o,i)=>o.valueOf()!==r[i].valueOf()))return!1}return!0}function io(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}const lo=(e,t,n)=>e??t??n,Wa=Yn({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(e,{attrs:t,slots:n}){const s=Fe(Ls),r=ue(()=>e.route||s.value),o=Fe(Xr,0),i=ue(()=>{let f=Ot(o);const{matched:u}=r.value;let d;for(;(d=u[f])&&!d.components;)f++;return f}),l=ue(()=>r.value.matched[i.value]);Rn(Xr,ue(()=>i.value+1)),Rn(ba,l),Rn(Ls,r);const c=Ie();return sn(()=>[c.value,l.value,e.name],([f,u,d],[g,m,A])=>{u&&(u.instances[d]=f,m&&m!==u&&f&&f===g&&(u.leaveGuards.size||(u.leaveGuards=m.leaveGuards),u.updateGuards.size||(u.updateGuards=m.updateGuards))),f&&u&&(!m||!Kt(u,m)||!g)&&(u.enterCallbacks[d]||[]).forEach(S=>S(f))},{flush:"post"}),()=>{const f=r.value,u=e.name,d=l.value,g=d&&d.components[u];if(!g)return co(n.default,{Component:g,route:f});const m=d.props[u],A=m?m===!0?f.params:typeof m=="function"?m(f):m:null,N=vi(g,Q({},A,t,{onVnodeUnmounted:M=>{M.component.isUnmounted&&(d.instances[u]=null)},ref:c}));return co(n.default,{Component:N,route:f})||N}}});function co(e,t){if(!e)return null;const n=e(t);return n.length===1?n[0]:n}const qa=Wa;function $a(e){const t=La(e.routes,e),n=e.parseQuery||va,s=e.stringifyQuery||Yr,r=e.history,o=Xt(),i=Xt(),l=Xt(),c=vl(gt);let f=gt;kt&&e.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const u=gs.bind(null,y=>""+y),d=gs.bind(null,ta),g=gs.bind(null,_n);function m(y,I){let O,L;return Di(y)?(O=t.getRecordMatcher(y),L=I):L=y,t.addRoute(L,O)}function A(y){const I=t.getRecordMatcher(y);I&&t.removeRoute(I)}function S(){return t.getRoutes().map(y=>y.record)}function N(y){return!!t.getRecordMatcher(y)}function M(y,I){if(I=Q({},I||c.value),typeof y=="string"){const p=ms(n,y,I.path),_=t.resolve({path:p.path},I),b=r.createHref(p.fullPath);return Q(p,_,{params:g(_.params),hash:_n(p.hash),redirectedFrom:void 0,href:b})}let O;if(y.path!=null)O=Q({},y,{path:ms(n,y.path,I.path).path});else{const p=Q({},y.params);for(const _ in p)p[_]==null&&delete p[_];O=Q({},y,{params:d(p)}),I.params=d(I.params)}const L=t.resolve(O,I),q=y.hash||"";L.params=u(g(L.params));const a=ra(s,Q({},y,{hash:Xu(q),path:L.path})),h=r.createHref(a);return Q({fullPath:a,hash:q,query:s===Yr?ya(y.query):y.query||{}},L,{redirectedFrom:void 0,href:h})}function T(y){return typeof y=="string"?ms(n,y,c.value.path):Q({},y)}function D(y,I){if(f!==y)return Gt(ie.NAVIGATION_CANCELLED,{from:I,to:y})}function w(y){return W(y)}function U(y){return w(Q(T(y),{replace:!0}))}function ce(y,I){const O=y.matched[y.matched.length-1];if(O&&O.redirect){const{redirect:L}=O;let q=typeof L=="function"?L(y,I):L;return typeof q=="string"&&(q=q.includes("?")||q.includes("#")?q=T(q):{path:q},q.params={}),Q({query:y.query,hash:y.hash,params:q.path!=null?{}:y.params},q)}}function W(y,I){const O=f=M(y),L=c.value,q=y.state,a=y.force,h=y.replace===!0,p=ce(O,L);if(p)return W(Q(T(p),{state:typeof p=="object"?Q({},q,p.state):q,force:a,replace:h}),I||O);const _=O;_.redirectedFrom=I;let b;return!a&&oa(s,L,O)&&(b=Gt(ie.NAVIGATION_DUPLICATED,{to:_,from:L}),He(L,L,!0,!1)),(b?Promise.resolve(b):re(_,L)).catch(v=>nt(v)?nt(v,ie.NAVIGATION_GUARD_REDIRECT)?v:pt(v):J(v,_,L)).then(v=>{if(v){if(nt(v,ie.NAVIGATION_GUARD_REDIRECT))return W(Q({replace:h},T(v.to),{state:typeof v.to=="object"?Q({},q,v.to.state):q,force:a}),I||_)}else v=Oe(_,L,!0,h,q);return me(_,L,v),v})}function K(y,I){const O=D(y,I);return O?Promise.reject(O):Promise.resolve()}function G(y){const I=Nt.values().next().value;return I&&typeof I.runWithContext=="function"?I.runWithContext(y):y()}function re(y,I){let O;const[L,q,a]=Ea(y,I);O=vs(L.reverse(),"beforeRouteLeave",y,I);for(const p of L)p.leaveGuards.forEach(_=>{O.push(vt(_,y,I))});const h=K.bind(null,y,I);return O.push(h),Le(O).then(()=>{O=[];for(const p of o.list())O.push(vt(p,y,I));return O.push(h),Le(O)}).then(()=>{O=vs(q,"beforeRouteUpdate",y,I);for(const p of q)p.updateGuards.forEach(_=>{O.push(vt(_,y,I))});return O.push(h),Le(O)}).then(()=>{O=[];for(const p of a)if(p.beforeEnter)if(Be(p.beforeEnter))for(const _ of p.beforeEnter)O.push(vt(_,y,I));else O.push(vt(p.beforeEnter,y,I));return O.push(h),Le(O)}).then(()=>(y.matched.forEach(p=>p.enterCallbacks={}),O=vs(a,"beforeRouteEnter",y,I,G),O.push(h),Le(O))).then(()=>{O=[];for(const p of i.list())O.push(vt(p,y,I));return O.push(h),Le(O)}).catch(p=>nt(p,ie.NAVIGATION_CANCELLED)?p:Promise.reject(p))}function me(y,I,O){l.list().forEach(L=>G(()=>L(y,I,O)))}function Oe(y,I,O,L,q){const a=D(y,I);if(a)return a;const h=I===gt,p=kt?history.state:{};O&&(L||h?r.replace(y.fullPath,Q({scroll:h&&p&&p.scroll},q)):r.push(y.fullPath,q)),c.value=y,He(y,I,O,h),pt()}let Se;function Et(){Se||(Se=r.listen((y,I,O)=>{if(!St.listening)return;const L=M(y),q=ce(L,St.currentRoute.value);if(q){W(Q(q,{replace:!0,force:!0}),L).catch(an);return}f=L;const a=c.value;kt&&ha(Qr(a.fullPath,O.delta),ss()),re(L,a).catch(h=>nt(h,ie.NAVIGATION_ABORTED|ie.NAVIGATION_CANCELLED)?h:nt(h,ie.NAVIGATION_GUARD_REDIRECT)?(W(Q(T(h.to),{force:!0}),L).then(p=>{nt(p,ie.NAVIGATION_ABORTED|ie.NAVIGATION_DUPLICATED)&&!O.delta&&O.type===Ds.pop&&r.go(-1,!1)}).catch(an),Promise.reject()):(O.delta&&r.go(-O.delta,!1),J(h,L,a))).then(h=>{h=h||Oe(L,a,!1),h&&(O.delta&&!nt(h,ie.NAVIGATION_CANCELLED)?r.go(-O.delta,!1):O.type===Ds.pop&&nt(h,ie.NAVIGATION_ABORTED|ie.NAVIGATION_DUPLICATED)&&r.go(-1,!1)),me(L,a,h)}).catch(an)}))}let ht=Xt(),se=Xt(),H;function J(y,I,O){pt(y);const L=se.list();return L.length?L.forEach(q=>q(y,I,O)):console.error(y),Promise.reject(y)}function et(){return H&&c.value!==gt?Promise.resolve():new Promise((y,I)=>{ht.add([y,I])})}function pt(y){return H||(H=!y,Et(),ht.list().forEach(([I,O])=>y?O(y):I()),ht.reset()),y}function He(y,I,O,L){const{scrollBehavior:q}=e;if(!kt||!q)return Promise.resolve();const a=!O&&pa(Qr(y.fullPath,0))||(L||!O)&&history.state&&history.state.scroll||null;return Qn().then(()=>q(y,I,a)).then(h=>h&&da(h)).catch(h=>J(h,y,I))}const we=y=>r.go(y);let It;const Nt=new Set,St={currentRoute:c,listening:!0,addRoute:m,removeRoute:A,clearRoutes:t.clearRoutes,hasRoute:N,getRoutes:S,resolve:M,options:e,push:w,replace:U,go:we,back:()=>we(-1),forward:()=>we(1),beforeEach:o.add,beforeResolve:i.add,afterEach:l.add,onError:se.add,isReady:et,install(y){y.component("RouterLink",Ha),y.component("RouterView",qa),y.config.globalProperties.$router=St,Object.defineProperty(y.config.globalProperties,"$route",{enumerable:!0,get:()=>Ot(c)}),kt&&!It&&c.value===gt&&(It=!0,w(r.location).catch(L=>{}));const I={};for(const L in gt)Object.defineProperty(I,L,{get:()=>c.value[L],enumerable:!0});y.provide(rs,St),y.provide(sr,Lo(I)),y.provide(Ls,c);const O=y.unmount;Nt.add(y),y.unmount=function(){Nt.delete(y),Nt.size<1&&(f=gt,Se&&Se(),Se=null,c.value=gt,It=!1,H=!1),O()}}};function Le(y){return y.reduce((I,O)=>I.then(()=>G(O)),Promise.resolve())}return St}function ef(){return Fe(rs)}function tf(e){return Fe(sr)}const Fi=$a({history:Aa("/app/"),routes:[{path:"/login",name:"login",component:()=>oe(()=>import("./LoginView-D8QH8UMb.js"),[]),meta:{guest:!0}},{path:"/register",name:"register-org",component:()=>oe(()=>import("./RegisterOrgView-CpcADoEU.js"),[]),meta:{guest:!0}},{path:"/admin",name:"admin",component:()=>oe(()=>import("./AdminDashboardView-JnGO4r61.js"),[]),meta:{requiresAuth:!0}},{path:"/",component:()=>oe(()=>import("./AppLayout-AMYs4jcG.js"),[]),meta:{requiresAuth:!0},children:[{path:"",name:"dashboard",component:()=>oe(()=>import("./DashboardView-D1ilHHiP.js"),[])},{path:"orders",name:"orders",component:()=>oe(()=>import("./OrdersView-Cykxo3M3.js"),[])},{path:"orders/:id",name:"order-detail",component:()=>oe(()=>import("./OrderDetailView-CrMXW-i2.js"),[])},{path:"users",name:"users",component:()=>oe(()=>import("./UsersView-Df5a9eIx.js"),[]),meta:{roles:["chef","disponent"]}},{path:"availability",name:"availability",component:()=>oe(()=>import("./AvailabilityView-BNPzNcWA.js"),[])},{path:"timesheets",name:"timesheets",component:()=>oe(()=>import("./TimesheetsView-Cx-KwgCo.js"),[])},{path:"settings",name:"settings",component:()=>oe(()=>import("./SettingsView-4DujBg5S.js"),[])},{path:"modules",name:"modules",component:()=>oe(()=>import("./ModulesView-BNzetqIV.js"),[]),meta:{roles:["chef"]}},{path:"partnerships",name:"partnerships",component:()=>oe(()=>import("./PartnershipsView-BTiY9iQS.js"),[])},{path:"help",name:"help",component:()=>oe(()=>import("./HelpView-1PeoZaC4.js"),[])},{path:"qualifications",name:"qualifications",component:()=>oe(()=>import("./QualificationsView-BbIklgwE.js"),[])},{path:"objects",name:"objects",component:()=>oe(()=>import("./ObjectsView-CzlgFF9j.js"),[])},{path:"shifts",name:"shifts",component:()=>oe(()=>import("./ShiftsView-gFZrEy1d.js"),[]),meta:{roles:["chef","disponent"]}},{path:"patrols",name:"patrols",component:()=>oe(()=>import("./PatrolsView-CE7IkVbv.js"),[])},{path:"incidents",name:"incidents",component:()=>oe(()=>import("./IncidentsView-DPo8woI1.js"),[])},{path:"vehicles",name:"vehicles",component:()=>oe(()=>import("./VehiclesView-C2kXdRXZ.js"),[]),meta:{roles:["chef","disponent"]}},{path:"documents",name:"documents",component:()=>oe(()=>import("./DocumentsView-cD_00o40.js"),[])},{path:"customers",name:"customers",component:()=>oe(()=>import("./CustomersView-B4K9IT7m.js"),[]),meta:{roles:["chef","disponent"]}},{path:"billing",name:"billing",component:()=>oe(()=>import("./BillingView-TAMo2net.js"),[]),meta:{roles:["chef"]}}]}]});Fi.beforeEach(async(e,t,n)=>{var l;const s=tr();!s.isAuthenticated&&s.hasStoredToken&&await s.fetchCurrentUser();const r=e.matched.some(c=>c.meta.requiresAuth),o=e.matched.some(c=>c.meta.guest),i=e.meta.roles;r&&!s.isAuthenticated?n({name:"login",query:{redirect:e.fullPath}}):o&&s.isAuthenticated?n({name:"dashboard"}):i&&!i.includes(((l=s.user)==null?void 0:l.role)||"")?n({name:"dashboard"}):n()});const rr=hu(ju);rr.use(mu());rr.use(Fi);rr.mount("#app");export{Ja as A,Ya as B,js as C,Ve as F,Pe as a,Nl as b,ke as c,Yn as d,pi as e,ef as f,tf as g,sn as h,be as i,Il as j,ue as k,Xl as l,Yt as m,qn as n,Ce as o,Pc as p,Qs as q,Ie as r,Xa as s,ys as t,tr as u,Qa as v,Za as w,_r as x,Ot as y,di as z}; diff --git a/dist/assets/index-CgM2qJ96.js b/dist/assets/index-CgM2qJ96.js new file mode 100644 index 0000000..767a4a4 --- /dev/null +++ b/dist/assets/index-CgM2qJ96.js @@ -0,0 +1,47 @@ +var Gc=Object.defineProperty;var qc=(e,t,n)=>t in e?Gc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Wi=(e,t,n)=>qc(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();/** +* @vue/shared v3.5.30 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/function ui(e){const t=Object.create(null);for(const n of e.split(","))t[n]=1;return n=>n in t}const pe={},kn=[],It=()=>{},La=()=>!1,Kr=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),fi=e=>e.startsWith("onUpdate:"),Le=Object.assign,di=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},Yc=Object.prototype.hasOwnProperty,de=(e,t)=>Yc.call(e,t),X=Array.isArray,Cn=e=>pr(e)==="[object Map]",Fn=e=>pr(e)==="[object Set]",Bi=e=>pr(e)==="[object Date]",ne=e=>typeof e=="function",ke=e=>typeof e=="string",Ct=e=>typeof e=="symbol",me=e=>e!==null&&typeof e=="object",Ra=e=>(me(e)||ne(e))&&ne(e.then)&&ne(e.catch),Da=Object.prototype.toString,pr=e=>Da.call(e),Xc=e=>pr(e).slice(8,-1),Ma=e=>pr(e)==="[object Object]",Gr=e=>ke(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,qn=ui(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),qr=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},Jc=/-\w/g,Ye=qr(e=>e.replace(Jc,t=>t.slice(1).toUpperCase())),Qc=/\B([A-Z])/g,yn=qr(e=>e.replace(Qc,"-$1").toLowerCase()),Yr=qr(e=>e.charAt(0).toUpperCase()+e.slice(1)),_s=qr(e=>e?`on${Yr(e)}`:""),Nt=(e,t)=>!Object.is(e,t),Ir=(e,...t)=>{for(let n=0;n{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},Xr=e=>{const t=parseFloat(e);return isNaN(t)?e:t},Zc=e=>{const t=ke(e)?Number(e):NaN;return isNaN(t)?e:t};let $i;const Jr=()=>$i||($i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function mi(e){if(X(e)){const t={};for(let n=0;n{if(n){const r=n.split(tu);r.length>1&&(t[r[0].trim()]=r[1].trim())}}),t}function Qr(e){let t="";if(ke(e))t=e;else if(X(e))for(let n=0;nUn(n,t))}const Ua=e=>!!(e&&e.__v_isRef===!0),Fs=e=>ke(e)?e:e==null?"":X(e)||me(e)&&(e.toString===Da||!ne(e.toString))?Ua(e)?Fs(e.value):JSON.stringify(e,ja,2):String(e),ja=(e,t)=>Ua(t)?ja(e,t.value):Cn(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((n,[r,s],i)=>(n[vs(r,i)+" =>"]=s,n),{})}:Fn(t)?{[`Set(${t.size})`]:[...t.values()].map(n=>vs(n))}:Ct(t)?vs(t):me(t)&&!X(t)&&!Ma(t)?String(t):t,vs=(e,t="")=>{var n;return Ct(e)?`Symbol(${(n=e.description)!=null?n:t})`:e};/** +* @vue/reactivity v3.5.30 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/let Fe;class Va{constructor(t=!1){this.detached=t,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.__v_skip=!0,this.parent=Fe,!t&&Fe&&(this.index=(Fe.scopes||(Fe.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let t,n;if(this.scopes)for(t=0,n=this.scopes.length;t0&&--this._on===0&&(Fe=this.prevScope,this.prevScope=void 0)}stop(t){if(this._active){this._active=!1;let n,r;for(n=0,r=this.effects.length;n0)return;if(Xn){let t=Xn;for(Xn=void 0;t;){const n=t.next;t.next=void 0,t.flags&=-9,t=n}}let e;for(;Yn;){let t=Yn;for(Yn=void 0;t;){const n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(r){e||(e=r)}t=n}}if(e)throw e}function za(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function Ka(e){let t,n=e.depsTail,r=n;for(;r;){const s=r.prevDep;r.version===-1?(r===n&&(n=s),vi(r),lu(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=s}e.deps=t,e.depsTail=n}function Us(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(Ga(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function Ga(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===rr)||(e.globalVersion=rr,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!Us(e))))return;e.flags|=2;const t=e.dep,n=_e,r=pt;_e=e,pt=!0;try{za(e);const s=e.fn(e._value);(t.version===0||Nt(s,e._value))&&(e.flags|=128,e._value=s,t.version++)}catch(s){throw t.version++,s}finally{_e=n,pt=r,Ka(e),e.flags&=-3}}function vi(e,t=!1){const{dep:n,prevSub:r,nextSub:s}=e;if(r&&(r.nextSub=s,e.prevSub=void 0),s&&(s.prevSub=r,e.nextSub=void 0),n.subs===e&&(n.subs=r,!r&&n.computed)){n.computed.flags&=-5;for(let i=n.computed.deps;i;i=i.nextDep)vi(i,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function lu(e){const{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}let pt=!0;const qa=[];function Wt(){qa.push(pt),pt=!1}function Bt(){const e=qa.pop();pt=e===void 0?!0:e}function zi(e){const{cleanup:t}=e;if(e.cleanup=void 0,t){const n=_e;_e=void 0;try{t()}finally{_e=n}}}let rr=0;class cu{constructor(t,n){this.sub=t,this.dep=n,this.version=n.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class bi{constructor(t){this.computed=t,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(t){if(!_e||!pt||_e===this.computed)return;let n=this.activeLink;if(n===void 0||n.sub!==_e)n=this.activeLink=new cu(_e,this),_e.deps?(n.prevDep=_e.depsTail,_e.depsTail.nextDep=n,_e.depsTail=n):_e.deps=_e.depsTail=n,Ya(n);else if(n.version===-1&&(n.version=this.version,n.nextDep)){const r=n.nextDep;r.prevDep=n.prevDep,n.prevDep&&(n.prevDep.nextDep=r),n.prevDep=_e.depsTail,n.nextDep=void 0,_e.depsTail.nextDep=n,_e.depsTail=n,_e.deps===n&&(_e.deps=r)}return n}trigger(t){this.version++,rr++,this.notify(t)}notify(t){gi();try{for(let n=this.subs;n;n=n.prevSub)n.sub.notify()&&n.sub.dep.notify()}finally{_i()}}}function Ya(e){if(e.dep.sc++,e.sub.flags&4){const t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let r=t.deps;r;r=r.nextDep)Ya(r)}const n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}const Rr=new WeakMap,_n=Symbol(""),js=Symbol(""),sr=Symbol("");function Ue(e,t,n){if(pt&&_e){let r=Rr.get(e);r||Rr.set(e,r=new Map);let s=r.get(n);s||(r.set(n,s=new bi),s.map=r,s.key=n),s.track()}}function Ft(e,t,n,r,s,i){const o=Rr.get(e);if(!o){rr++;return}const a=l=>{l&&l.trigger()};if(gi(),t==="clear")o.forEach(a);else{const l=X(e),c=l&&Gr(n);if(l&&n==="length"){const u=Number(r);o.forEach((f,h)=>{(h==="length"||h===sr||!Ct(h)&&h>=u)&&a(f)})}else switch((n!==void 0||o.has(void 0))&&a(o.get(n)),c&&a(o.get(sr)),t){case"add":l?c&&a(o.get("length")):(a(o.get(_n)),Cn(e)&&a(o.get(js)));break;case"delete":l||(a(o.get(_n)),Cn(e)&&a(o.get(js)));break;case"set":Cn(e)&&a(o.get(_n));break}}_i()}function uu(e,t){const n=Rr.get(e);return n&&n.get(t)}function Tn(e){const t=le(e);return t===e?t:(Ue(t,"iterate",sr),ot(e)?t:t.map(gt))}function Zr(e){return Ue(e=le(e),"iterate",sr),e}function wt(e,t){return $t(e)?On(Vt(e)?gt(t):t):gt(t)}const fu={__proto__:null,[Symbol.iterator](){return ys(this,Symbol.iterator,e=>wt(this,e))},concat(...e){return Tn(this).concat(...e.map(t=>X(t)?Tn(t):t))},entries(){return ys(this,"entries",e=>(e[1]=wt(this,e[1]),e))},every(e,t){return Pt(this,"every",e,t,void 0,arguments)},filter(e,t){return Pt(this,"filter",e,t,n=>n.map(r=>wt(this,r)),arguments)},find(e,t){return Pt(this,"find",e,t,n=>wt(this,n),arguments)},findIndex(e,t){return Pt(this,"findIndex",e,t,void 0,arguments)},findLast(e,t){return Pt(this,"findLast",e,t,n=>wt(this,n),arguments)},findLastIndex(e,t){return Pt(this,"findLastIndex",e,t,void 0,arguments)},forEach(e,t){return Pt(this,"forEach",e,t,void 0,arguments)},includes(...e){return Es(this,"includes",e)},indexOf(...e){return Es(this,"indexOf",e)},join(e){return Tn(this).join(e)},lastIndexOf(...e){return Es(this,"lastIndexOf",e)},map(e,t){return Pt(this,"map",e,t,void 0,arguments)},pop(){return Vn(this,"pop")},push(...e){return Vn(this,"push",e)},reduce(e,...t){return Ki(this,"reduce",e,t)},reduceRight(e,...t){return Ki(this,"reduceRight",e,t)},shift(){return Vn(this,"shift")},some(e,t){return Pt(this,"some",e,t,void 0,arguments)},splice(...e){return Vn(this,"splice",e)},toReversed(){return Tn(this).toReversed()},toSorted(e){return Tn(this).toSorted(e)},toSpliced(...e){return Tn(this).toSpliced(...e)},unshift(...e){return Vn(this,"unshift",e)},values(){return ys(this,"values",e=>wt(this,e))}};function ys(e,t,n){const r=Zr(e),s=r[t]();return r!==e&&!ot(e)&&(s._next=s.next,s.next=()=>{const i=s._next();return i.done||(i.value=n(i.value)),i}),s}const du=Array.prototype;function Pt(e,t,n,r,s,i){const o=Zr(e),a=o!==e&&!ot(e),l=o[t];if(l!==du[t]){const f=l.apply(e,i);return a?gt(f):f}let c=n;o!==e&&(a?c=function(f,h){return n.call(this,wt(e,f),h,e)}:n.length>2&&(c=function(f,h){return n.call(this,f,h,e)}));const u=l.call(o,c,r);return a&&s?s(u):u}function Ki(e,t,n,r){const s=Zr(e),i=s!==e&&!ot(e);let o=n,a=!1;s!==e&&(i?(a=r.length===0,o=function(c,u,f){return a&&(a=!1,c=wt(e,c)),n.call(this,c,wt(e,u),f,e)}):n.length>3&&(o=function(c,u,f){return n.call(this,c,u,f,e)}));const l=s[t](o,...r);return a?wt(e,l):l}function Es(e,t,n){const r=le(e);Ue(r,"iterate",sr);const s=r[t](...n);return(s===-1||s===!1)&&es(n[0])?(n[0]=le(n[0]),r[t](...n)):s}function Vn(e,t,n=[]){Wt(),gi();const r=le(e)[t].apply(e,n);return _i(),Bt(),r}const mu=ui("__proto__,__v_isRef,__isVue"),Xa=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!=="arguments"&&e!=="caller").map(e=>Symbol[e]).filter(Ct));function hu(e){Ct(e)||(e=String(e));const t=le(this);return Ue(t,"has",e),t.hasOwnProperty(e)}class Ja{constructor(t=!1,n=!1){this._isReadonly=t,this._isShallow=n}get(t,n,r){if(n==="__v_skip")return t.__v_skip;const s=this._isReadonly,i=this._isShallow;if(n==="__v_isReactive")return!s;if(n==="__v_isReadonly")return s;if(n==="__v_isShallow")return i;if(n==="__v_raw")return r===(s?i?Au:tl:i?el:Za).get(t)||Object.getPrototypeOf(t)===Object.getPrototypeOf(r)?t:void 0;const o=X(t);if(!s){let l;if(o&&(l=fu[n]))return l;if(n==="hasOwnProperty")return hu}const a=Reflect.get(t,n,Te(t)?t:r);if((Ct(n)?Xa.has(n):mu(n))||(s||Ue(t,"get",n),i))return a;if(Te(a)){const l=o&&Gr(n)?a:a.value;return s&&me(l)?Hs(l):l}return me(a)?s?Hs(a):gr(a):a}}class Qa extends Ja{constructor(t=!1){super(!1,t)}set(t,n,r,s){let i=t[n];const o=X(t)&&Gr(n);if(!this._isShallow){const c=$t(i);if(!ot(r)&&!$t(r)&&(i=le(i),r=le(r)),!o&&Te(i)&&!Te(r))return c||(i.value=r),!0}const a=o?Number(n)e,Tr=e=>Reflect.getPrototypeOf(e);function bu(e,t,n){return function(...r){const s=this.__v_raw,i=le(s),o=Cn(i),a=e==="entries"||e===Symbol.iterator&&o,l=e==="keys"&&o,c=s[e](...r),u=n?Vs:t?On:gt;return!t&&Ue(i,"iterate",l?js:_n),Le(Object.create(c),{next(){const{value:f,done:h}=c.next();return h?{value:f,done:h}:{value:a?[u(f[0]),u(f[1])]:u(f),done:h}}})}}function wr(e){return function(...t){return e==="delete"?!1:e==="clear"?void 0:this}}function yu(e,t){const n={get(s){const i=this.__v_raw,o=le(i),a=le(s);e||(Nt(s,a)&&Ue(o,"get",s),Ue(o,"get",a));const{has:l}=Tr(o),c=t?Vs:e?On:gt;if(l.call(o,s))return c(i.get(s));if(l.call(o,a))return c(i.get(a));i!==o&&i.get(s)},get size(){const s=this.__v_raw;return!e&&Ue(le(s),"iterate",_n),s.size},has(s){const i=this.__v_raw,o=le(i),a=le(s);return e||(Nt(s,a)&&Ue(o,"has",s),Ue(o,"has",a)),s===a?i.has(s):i.has(s)||i.has(a)},forEach(s,i){const o=this,a=o.__v_raw,l=le(a),c=t?Vs:e?On:gt;return!e&&Ue(l,"iterate",_n),a.forEach((u,f)=>s.call(i,c(u),c(f),o))}};return Le(n,e?{add:wr("add"),set:wr("set"),delete:wr("delete"),clear:wr("clear")}:{add(s){const i=le(this),o=Tr(i),a=le(s),l=!t&&!ot(s)&&!$t(s)?a:s;return o.has.call(i,l)||Nt(s,l)&&o.has.call(i,s)||Nt(a,l)&&o.has.call(i,a)||(i.add(l),Ft(i,"add",l,l)),this},set(s,i){!t&&!ot(i)&&!$t(i)&&(i=le(i));const o=le(this),{has:a,get:l}=Tr(o);let c=a.call(o,s);c||(s=le(s),c=a.call(o,s));const u=l.call(o,s);return o.set(s,i),c?Nt(i,u)&&Ft(o,"set",s,i):Ft(o,"add",s,i),this},delete(s){const i=le(this),{has:o,get:a}=Tr(i);let l=o.call(i,s);l||(s=le(s),l=o.call(i,s)),a&&a.call(i,s);const c=i.delete(s);return l&&Ft(i,"delete",s,void 0),c},clear(){const s=le(this),i=s.size!==0,o=s.clear();return i&&Ft(s,"clear",void 0,void 0),o}}),["keys","values","entries",Symbol.iterator].forEach(s=>{n[s]=bu(s,e,t)}),n}function yi(e,t){const n=yu(e,t);return(r,s,i)=>s==="__v_isReactive"?!e:s==="__v_isReadonly"?e:s==="__v_raw"?r:Reflect.get(de(n,s)&&s in r?n:r,s,i)}const Eu={get:yi(!1,!1)},Tu={get:yi(!1,!0)},wu={get:yi(!0,!1)};const Za=new WeakMap,el=new WeakMap,tl=new WeakMap,Au=new WeakMap;function Nu(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function Su(e){return e.__v_skip||!Object.isExtensible(e)?0:Nu(Xc(e))}function gr(e){return $t(e)?e:Ei(e,!1,gu,Eu,Za)}function nl(e){return Ei(e,!1,vu,Tu,el)}function Hs(e){return Ei(e,!0,_u,wu,tl)}function Ei(e,t,n,r,s){if(!me(e)||e.__v_raw&&!(t&&e.__v_isReactive))return e;const i=Su(e);if(i===0)return e;const o=s.get(e);if(o)return o;const a=new Proxy(e,i===2?r:n);return s.set(e,a),a}function Vt(e){return $t(e)?Vt(e.__v_raw):!!(e&&e.__v_isReactive)}function $t(e){return!!(e&&e.__v_isReadonly)}function ot(e){return!!(e&&e.__v_isShallow)}function es(e){return e?!!e.__v_raw:!1}function le(e){const t=e&&e.__v_raw;return t?le(t):e}function Ti(e){return!de(e,"__v_skip")&&Object.isExtensible(e)&&xa(e,"__v_skip",!0),e}const gt=e=>me(e)?gr(e):e,On=e=>me(e)?Hs(e):e;function Te(e){return e?e.__v_isRef===!0:!1}function Pe(e){return rl(e,!1)}function wi(e){return rl(e,!0)}function rl(e,t){return Te(e)?e:new Iu(e,t)}class Iu{constructor(t,n){this.dep=new bi,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=n?t:le(t),this._value=n?t:gt(t),this.__v_isShallow=n}get value(){return this.dep.track(),this._value}set value(t){const n=this._rawValue,r=this.__v_isShallow||ot(t)||$t(t);t=r?t:le(t),Nt(t,n)&&(this._rawValue=t,this._value=r?t:gt(t),this.dep.trigger())}}function vn(e){return Te(e)?e.value:e}const ku={get:(e,t,n)=>t==="__v_raw"?e:vn(Reflect.get(e,t,n)),set:(e,t,n,r)=>{const s=e[t];return Te(s)&&!Te(n)?(s.value=n,!0):Reflect.set(e,t,n,r)}};function sl(e){return Vt(e)?e:new Proxy(e,ku)}function Cu(e){const t=X(e)?new Array(e.length):{};for(const n in e)t[n]=Ou(e,n);return t}class Pu{constructor(t,n,r){this._object=t,this._key=n,this._defaultValue=r,this.__v_isRef=!0,this._value=void 0,this._raw=le(t);let s=!0,i=t;if(!X(t)||!Gr(String(n)))do s=!es(i)||ot(i);while(s&&(i=i.__v_raw));this._shallow=s}get value(){let t=this._object[this._key];return this._shallow&&(t=vn(t)),this._value=t===void 0?this._defaultValue:t}set value(t){if(this._shallow&&Te(this._raw[this._key])){const n=this._object[this._key];if(Te(n)){n.value=t;return}}this._object[this._key]=t}get dep(){return uu(this._raw,this._key)}}function Ou(e,t,n){return new Pu(e,t,n)}class Lu{constructor(t,n,r){this.fn=t,this.setter=n,this._value=void 0,this.dep=new bi(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=rr-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!n,this.isSSR=r}notify(){if(this.flags|=16,!(this.flags&8)&&_e!==this)return $a(this,!0),!0}get value(){const t=this.dep.track();return Ga(this),t&&(t.version=this.dep.version),this._value}set value(t){this.setter&&this.setter(t)}}function Ru(e,t,n=!1){let r,s;return ne(e)?r=e:(r=e.get,s=e.set),new Lu(r,s,n)}const Ar={},Dr=new WeakMap;let hn;function Du(e,t=!1,n=hn){if(n){let r=Dr.get(n);r||Dr.set(n,r=[]),r.push(e)}}function Mu(e,t,n=pe){const{immediate:r,deep:s,once:i,scheduler:o,augmentJob:a,call:l}=n,c=b=>s?b:ot(b)||s===!1||s===0?Ut(b,1):Ut(b);let u,f,h,_,A=!1,E=!1;if(Te(e)?(f=()=>e.value,A=ot(e)):Vt(e)?(f=()=>c(e),A=!0):X(e)?(E=!0,A=e.some(b=>Vt(b)||ot(b)),f=()=>e.map(b=>{if(Te(b))return b.value;if(Vt(b))return c(b);if(ne(b))return l?l(b,2):b()})):ne(e)?t?f=l?()=>l(e,2):e:f=()=>{if(h){Wt();try{h()}finally{Bt()}}const b=hn;hn=u;try{return l?l(e,3,[_]):e(_)}finally{hn=b}}:f=It,t&&s){const b=f,I=s===!0?1/0:s;f=()=>Ut(b(),I)}const O=Ha(),R=()=>{u.stop(),O&&O.active&&di(O.effects,u)};if(i&&t){const b=t;t=(...I)=>{b(...I),R()}}let x=E?new Array(e.length).fill(Ar):Ar;const y=b=>{if(!(!(u.flags&1)||!u.dirty&&!b))if(t){const I=u.run();if(s||A||(E?I.some((k,M)=>Nt(k,x[M])):Nt(I,x))){h&&h();const k=hn;hn=u;try{const M=[I,x===Ar?void 0:E&&x[0]===Ar?[]:x,_];x=I,l?l(t,3,M):t(...M)}finally{hn=k}}}else u.run()};return a&&a(y),u=new Wa(f),u.scheduler=o?()=>o(y,!1):y,_=b=>Du(b,!1,u),h=u.onStop=()=>{const b=Dr.get(u);if(b){if(l)l(b,4);else for(const I of b)I();Dr.delete(u)}},t?r?y(!0):x=u.run():o?o(y.bind(null,!0),!0):u.run(),R.pause=u.pause.bind(u),R.resume=u.resume.bind(u),R.stop=R,R}function Ut(e,t=1/0,n){if(t<=0||!me(e)||e.__v_skip||(n=n||new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,Te(e))Ut(e.value,t,n);else if(X(e))for(let r=0;r{Ut(r,t,n)});else if(Ma(e)){for(const r in e)Ut(e[r],t,n);for(const r of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,r)&&Ut(e[r],t,n)}return e}/** +* @vue/runtime-core v3.5.30 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/function _r(e,t,n,r){try{return r?e(...r):e()}catch(s){ts(s,t,n)}}function _t(e,t,n,r){if(ne(e)){const s=_r(e,t,n,r);return s&&Ra(s)&&s.catch(i=>{ts(i,t,n)}),s}if(X(e)){const s=[];for(let i=0;i>>1,s=Ke[r],i=ir(s);i=ir(n)?Ke.push(e):Ke.splice(Fu(t),0,e),e.flags|=1,ol()}}function ol(){Mr||(Mr=il.then(ll))}function Uu(e){X(e)?Pn.push(...e):Xt&&e.id===-1?Xt.splice(An+1,0,e):e.flags&1||(Pn.push(e),e.flags|=1),ol()}function Gi(e,t,n=Et+1){for(;nir(n)-ir(r));if(Pn.length=0,Xt){Xt.push(...t);return}for(Xt=t,An=0;Ane.id==null?e.flags&2?-1:1/0:e.id;function ll(e){try{for(Et=0;Et{r._d&&jr(-1);const i=xr(t);let o;try{o=e(...s)}finally{xr(i),r._d&&jr(1)}return o};return r._n=!0,r._c=!0,r._d=!0,r}function Vu(e,t){if(st===null)return e;const n=as(st),r=e.dirs||(e.dirs=[]);for(let s=0;s1)return n&&ne(t)?t.call(r&&r.proxy):t}}function Hu(){return!!(tn()||bn)}const Wu=Symbol.for("v-scx"),Bu=()=>at(Wu);function Zt(e,t,n){return ul(e,t,n)}function ul(e,t,n=pe){const{immediate:r,deep:s,flush:i,once:o}=n,a=Le({},n),l=t&&r||!t&&i!=="post";let c;if(lr){if(i==="sync"){const _=Bu();c=_.__watcherHandles||(_.__watcherHandles=[])}else if(!l){const _=()=>{};return _.stop=It,_.resume=It,_.pause=It,_}}const u=je;a.call=(_,A,E)=>_t(_,u,A,E);let f=!1;i==="post"?a.scheduler=_=>{Qe(_,u&&u.suspense)}:i!=="sync"&&(f=!0,a.scheduler=(_,A)=>{A?_():Ai(_)}),a.augmentJob=_=>{t&&(_.flags|=4),f&&(_.flags|=2,u&&(_.id=u.uid,_.i=u))};const h=Mu(e,t,a);return lr&&(c?c.push(h):l&&h()),h}function $u(e,t,n){const r=this.proxy,s=ke(e)?e.includes(".")?fl(r,e):()=>r[e]:e.bind(r,r);let i;ne(t)?i=t:(i=t.handler,n=t);const o=yr(this),a=ul(s,i.bind(r),n);return o(),a}function fl(e,t){const n=t.split(".");return()=>{let r=e;for(let s=0;se.__isTeleport,Tt=Symbol("_leaveCb"),Hn=Symbol("_enterCb");function Ku(){const e={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return vr(()=>{e.isMounted=!0}),El(()=>{e.isUnmounting=!0}),e}const ct=[Function,Array],ml={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:ct,onEnter:ct,onAfterEnter:ct,onEnterCancelled:ct,onBeforeLeave:ct,onLeave:ct,onAfterLeave:ct,onLeaveCancelled:ct,onBeforeAppear:ct,onAppear:ct,onAfterAppear:ct,onAppearCancelled:ct},hl=e=>{const t=e.subTree;return t.component?hl(t.component):t},Gu={name:"BaseTransition",props:ml,setup(e,{slots:t}){const n=tn(),r=Ku();return()=>{const s=t.default&&_l(t.default(),!0);if(!s||!s.length)return;const i=pl(s),o=le(e),{mode:a}=o;if(r.isLeaving)return Ts(i);const l=qi(i);if(!l)return Ts(i);let c=Ws(l,o,r,n,f=>c=f);l.type!==qe&&or(l,c);let u=n.subTree&&qi(n.subTree);if(u&&u.type!==qe&&!pn(u,l)&&hl(n).type!==qe){let f=Ws(u,o,r,n);if(or(u,f),a==="out-in"&&l.type!==qe)return r.isLeaving=!0,f.afterLeave=()=>{r.isLeaving=!1,n.job.flags&8||n.update(),delete f.afterLeave,u=void 0},Ts(i);a==="in-out"&&l.type!==qe?f.delayLeave=(h,_,A)=>{const E=gl(r,u);E[String(u.key)]=u,h[Tt]=()=>{_(),h[Tt]=void 0,delete c.delayedLeave,u=void 0},c.delayedLeave=()=>{A(),delete c.delayedLeave,u=void 0}}:u=void 0}else u&&(u=void 0);return i}}};function pl(e){let t=e[0];if(e.length>1){for(const n of e)if(n.type!==qe){t=n;break}}return t}const qu=Gu;function gl(e,t){const{leavingVNodes:n}=e;let r=n.get(t.type);return r||(r=Object.create(null),n.set(t.type,r)),r}function Ws(e,t,n,r,s){const{appear:i,mode:o,persisted:a=!1,onBeforeEnter:l,onEnter:c,onAfterEnter:u,onEnterCancelled:f,onBeforeLeave:h,onLeave:_,onAfterLeave:A,onLeaveCancelled:E,onBeforeAppear:O,onAppear:R,onAfterAppear:x,onAppearCancelled:y}=t,b=String(e.key),I=gl(n,e),k=(S,G)=>{S&&_t(S,r,9,G)},M=(S,G)=>{const Z=G[1];k(S,G),X(S)?S.every(U=>U.length<=1)&&Z():S.length<=1&&Z()},j={mode:o,persisted:a,beforeEnter(S){let G=l;if(!n.isMounted)if(i)G=O||l;else return;S[Tt]&&S[Tt](!0);const Z=I[b];Z&&pn(e,Z)&&Z.el[Tt]&&Z.el[Tt](),k(G,[S])},enter(S){if(I[b]===e)return;let G=c,Z=u,U=f;if(!n.isMounted)if(i)G=R||c,Z=x||u,U=y||f;else return;let J=!1;S[Hn]=Se=>{J||(J=!0,Se?k(U,[S]):k(Z,[S]),j.delayedLeave&&j.delayedLeave(),S[Hn]=void 0)};const ge=S[Hn].bind(null,!1);G?M(G,[S,ge]):ge()},leave(S,G){const Z=String(e.key);if(S[Hn]&&S[Hn](!0),n.isUnmounting)return G();k(h,[S]);let U=!1;S[Tt]=ge=>{U||(U=!0,G(),ge?k(E,[S]):k(A,[S]),S[Tt]=void 0,I[Z]===e&&delete I[Z])};const J=S[Tt].bind(null,!1);I[Z]=e,_?M(_,[S,J]):J()},clone(S){const G=Ws(S,t,n,r,s);return s&&s(G),G}};return j}function Ts(e){if(rs(e))return e=en(e),e.children=null,e}function qi(e){if(!rs(e))return dl(e.type)&&e.children?pl(e.children):e;if(e.component)return e.component.subTree;const{shapeFlag:t,children:n}=e;if(n){if(t&16)return n[0];if(t&32&&ne(n.default))return n.default()}}function or(e,t){e.shapeFlag&6&&e.component?(e.transition=t,or(e.component.subTree,t)):e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function _l(e,t=!1,n){let r=[],s=0;for(let i=0;i1)for(let i=0;iJn(E,t&&(X(t)?t[O]:t),n,r,s));return}if(Qn(r)&&!s){r.shapeFlag&512&&r.type.__asyncResolved&&r.component.subTree.component&&Jn(e,t,n,r.component.subTree);return}const i=r.shapeFlag&4?as(r.component):r.el,o=s?null:i,{i:a,r:l}=e,c=t&&t.r,u=a.refs===pe?a.refs={}:a.refs,f=a.setupState,h=le(f),_=f===pe?La:E=>Yi(u,E)?!1:de(h,E),A=(E,O)=>!(O&&Yi(u,O));if(c!=null&&c!==l){if(Xi(t),ke(c))u[c]=null,_(c)&&(f[c]=null);else if(Te(c)){const E=t;A(c,E.k)&&(c.value=null),E.k&&(u[E.k]=null)}}if(ne(l))_r(l,a,12,[o,u]);else{const E=ke(l),O=Te(l);if(E||O){const R=()=>{if(e.f){const x=E?_(l)?f[l]:u[l]:A()||!e.k?l.value:u[e.k];if(s)X(x)&&di(x,i);else if(X(x))x.includes(i)||x.push(i);else if(E)u[l]=[i],_(l)&&(f[l]=u[l]);else{const y=[i];A(l,e.k)&&(l.value=y),e.k&&(u[e.k]=y)}}else E?(u[l]=o,_(l)&&(f[l]=o)):O&&(A(l,e.k)&&(l.value=o),e.k&&(u[e.k]=o))};if(o){const x=()=>{R(),Fr.delete(e)};x.id=-1,Fr.set(e,x),Qe(x,n)}else Xi(e),R()}}}function Xi(e){const t=Fr.get(e);t&&(t.flags|=8,Fr.delete(e))}Jr().requestIdleCallback;Jr().cancelIdleCallback;const Qn=e=>!!e.type.__asyncLoader,rs=e=>e.type.__isKeepAlive;function Yu(e,t){bl(e,"a",t)}function Xu(e,t){bl(e,"da",t)}function bl(e,t,n=je){const r=e.__wdc||(e.__wdc=()=>{let s=n;for(;s;){if(s.isDeactivated)return;s=s.parent}return e()});if(ss(t,r,n),n){let s=n.parent;for(;s&&s.parent;)rs(s.parent.vnode)&&Ju(r,t,n,s),s=s.parent}}function Ju(e,t,n,r){const s=ss(t,e,r,!0);is(()=>{di(r[t],s)},n)}function ss(e,t,n=je,r=!1){if(n){const s=n[e]||(n[e]=[]),i=t.__weh||(t.__weh=(...o)=>{Wt();const a=yr(n),l=_t(t,n,e,o);return a(),Bt(),l});return r?s.unshift(i):s.push(i),i}}const zt=e=>(t,n=je)=>{(!lr||e==="sp")&&ss(e,(...r)=>t(...r),n)},yl=zt("bm"),vr=zt("m"),Qu=zt("bu"),Zu=zt("u"),El=zt("bum"),is=zt("um"),ef=zt("sp"),tf=zt("rtg"),nf=zt("rtc");function rf(e,t=je){ss("ec",e,t)}const sf="components";function of(e,t){return lf(sf,e,!0,t)||e}const af=Symbol.for("v-ndc");function lf(e,t,n=!0,r=!1){const s=st||je;if(s){const i=s.type;{const a=Gf(i,!1);if(a&&(a===t||a===Ye(t)||a===Yr(Ye(t))))return i}const o=Ji(s[e]||i[e],t)||Ji(s.appContext[e],t);return!o&&r?i:o}}function Ji(e,t){return e&&(e[t]||e[Ye(t)]||e[Yr(Ye(t))])}function Qi(e,t,n,r){let s;const i=n,o=X(e);if(o||ke(e)){const a=o&&Vt(e);let l=!1,c=!1;a&&(l=!ot(e),c=$t(e),e=Zr(e)),s=new Array(e.length);for(let u=0,f=e.length;ut(a,l,void 0,i));else{const a=Object.keys(e);s=new Array(a.length);for(let l=0,c=a.length;le?Bl(e)?as(e):Bs(e.parent):null,Zn=Le(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>Bs(e.parent),$root:e=>Bs(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>wl(e),$forceUpdate:e=>e.f||(e.f=()=>{Ai(e.update)}),$nextTick:e=>e.n||(e.n=ns.bind(e.proxy)),$watch:e=>$u.bind(e)}),ws=(e,t)=>e!==pe&&!e.__isScriptSetup&&de(e,t),cf={get({_:e},t){if(t==="__v_skip")return!0;const{ctx:n,setupState:r,data:s,props:i,accessCache:o,type:a,appContext:l}=e;if(t[0]!=="$"){const h=o[t];if(h!==void 0)switch(h){case 1:return r[t];case 2:return s[t];case 4:return n[t];case 3:return i[t]}else{if(ws(r,t))return o[t]=1,r[t];if(s!==pe&&de(s,t))return o[t]=2,s[t];if(de(i,t))return o[t]=3,i[t];if(n!==pe&&de(n,t))return o[t]=4,n[t];$s&&(o[t]=0)}}const c=Zn[t];let u,f;if(c)return t==="$attrs"&&Ue(e.attrs,"get",""),c(e);if((u=a.__cssModules)&&(u=u[t]))return u;if(n!==pe&&de(n,t))return o[t]=4,n[t];if(f=l.config.globalProperties,de(f,t))return f[t]},set({_:e},t,n){const{data:r,setupState:s,ctx:i}=e;return ws(s,t)?(s[t]=n,!0):r!==pe&&de(r,t)?(r[t]=n,!0):de(e.props,t)||t[0]==="$"&&t.slice(1)in e?!1:(i[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:r,appContext:s,props:i,type:o}},a){let l;return!!(n[a]||e!==pe&&a[0]!=="$"&&de(e,a)||ws(t,a)||de(i,a)||de(r,a)||de(Zn,a)||de(s.config.globalProperties,a)||(l=o.__cssModules)&&l[a])},defineProperty(e,t,n){return n.get!=null?e._.accessCache[t]=0:de(n,"value")&&this.set(e,t,n.value,null),Reflect.defineProperty(e,t,n)}};function Zi(e){return X(e)?e.reduce((t,n)=>(t[n]=null,t),{}):e}let $s=!0;function uf(e){const t=wl(e),n=e.proxy,r=e.ctx;$s=!1,t.beforeCreate&&eo(t.beforeCreate,e,"bc");const{data:s,computed:i,methods:o,watch:a,provide:l,inject:c,created:u,beforeMount:f,mounted:h,beforeUpdate:_,updated:A,activated:E,deactivated:O,beforeDestroy:R,beforeUnmount:x,destroyed:y,unmounted:b,render:I,renderTracked:k,renderTriggered:M,errorCaptured:j,serverPrefetch:S,expose:G,inheritAttrs:Z,components:U,directives:J,filters:ge}=t;if(c&&ff(c,r,null),o)for(const ee in o){const oe=o[ee];ne(oe)&&(r[ee]=oe.bind(n))}if(s){const ee=s.call(n,n);me(ee)&&(e.data=gr(ee))}if($s=!0,i)for(const ee in i){const oe=i[ee],He=ne(oe)?oe.bind(n,n):ne(oe.get)?oe.get.bind(n,n):It,Xe=!ne(oe)&&ne(oe.set)?oe.set.bind(n):It,we=ue({get:He,set:Xe});Object.defineProperty(r,ee,{enumerable:!0,configurable:!0,get:()=>we.value,set:Ae=>we.value=Ae})}if(a)for(const ee in a)Tl(a[ee],r,n,ee);if(l){const ee=ne(l)?l.call(n):l;Reflect.ownKeys(ee).forEach(oe=>{kr(oe,ee[oe])})}u&&eo(u,e,"c");function se(ee,oe){X(oe)?oe.forEach(He=>ee(He.bind(n))):oe&&ee(oe.bind(n))}if(se(yl,f),se(vr,h),se(Qu,_),se(Zu,A),se(Yu,E),se(Xu,O),se(rf,j),se(nf,k),se(tf,M),se(El,x),se(is,b),se(ef,S),X(G))if(G.length){const ee=e.exposed||(e.exposed={});G.forEach(oe=>{Object.defineProperty(ee,oe,{get:()=>n[oe],set:He=>n[oe]=He,enumerable:!0})})}else e.exposed||(e.exposed={});I&&e.render===It&&(e.render=I),Z!=null&&(e.inheritAttrs=Z),U&&(e.components=U),J&&(e.directives=J),S&&vl(e)}function ff(e,t,n=It){X(e)&&(e=zs(e));for(const r in e){const s=e[r];let i;me(s)?"default"in s?i=at(s.from||r,s.default,!0):i=at(s.from||r):i=at(s),Te(i)?Object.defineProperty(t,r,{enumerable:!0,configurable:!0,get:()=>i.value,set:o=>i.value=o}):t[r]=i}}function eo(e,t,n){_t(X(e)?e.map(r=>r.bind(t.proxy)):e.bind(t.proxy),t,n)}function Tl(e,t,n,r){let s=r.includes(".")?fl(n,r):()=>n[r];if(ke(e)){const i=t[e];ne(i)&&Zt(s,i)}else if(ne(e))Zt(s,e.bind(n));else if(me(e))if(X(e))e.forEach(i=>Tl(i,t,n,r));else{const i=ne(e.handler)?e.handler.bind(n):t[e.handler];ne(i)&&Zt(s,i,e)}}function wl(e){const t=e.type,{mixins:n,extends:r}=t,{mixins:s,optionsCache:i,config:{optionMergeStrategies:o}}=e.appContext,a=i.get(t);let l;return a?l=a:!s.length&&!n&&!r?l=t:(l={},s.length&&s.forEach(c=>Ur(l,c,o,!0)),Ur(l,t,o)),me(t)&&i.set(t,l),l}function Ur(e,t,n,r=!1){const{mixins:s,extends:i}=t;i&&Ur(e,i,n,!0),s&&s.forEach(o=>Ur(e,o,n,!0));for(const o in t)if(!(r&&o==="expose")){const a=df[o]||n&&n[o];e[o]=a?a(e[o],t[o]):t[o]}return e}const df={data:to,props:no,emits:no,methods:Gn,computed:Gn,beforeCreate:Be,created:Be,beforeMount:Be,mounted:Be,beforeUpdate:Be,updated:Be,beforeDestroy:Be,beforeUnmount:Be,destroyed:Be,unmounted:Be,activated:Be,deactivated:Be,errorCaptured:Be,serverPrefetch:Be,components:Gn,directives:Gn,watch:hf,provide:to,inject:mf};function to(e,t){return t?e?function(){return Le(ne(e)?e.call(this,this):e,ne(t)?t.call(this,this):t)}:t:e}function mf(e,t){return Gn(zs(e),zs(t))}function zs(e){if(X(e)){const t={};for(let n=0;nt==="modelValue"||t==="model-value"?e.modelModifiers:e[`${t}Modifiers`]||e[`${Ye(t)}Modifiers`]||e[`${yn(t)}Modifiers`];function vf(e,t,...n){if(e.isUnmounted)return;const r=e.vnode.props||pe;let s=n;const i=t.startsWith("update:"),o=i&&_f(r,t.slice(7));o&&(o.trim&&(s=n.map(u=>ke(u)?u.trim():u)),o.number&&(s=n.map(Xr)));let a,l=r[a=_s(t)]||r[a=_s(Ye(t))];!l&&i&&(l=r[a=_s(yn(t))]),l&&_t(l,e,6,s);const c=r[a+"Once"];if(c){if(!e.emitted)e.emitted={};else if(e.emitted[a])return;e.emitted[a]=!0,_t(c,e,6,s)}}const bf=new WeakMap;function Nl(e,t,n=!1){const r=n?bf:t.emitsCache,s=r.get(e);if(s!==void 0)return s;const i=e.emits;let o={},a=!1;if(!ne(e)){const l=c=>{const u=Nl(c,t,!0);u&&(a=!0,Le(o,u))};!n&&t.mixins.length&&t.mixins.forEach(l),e.extends&&l(e.extends),e.mixins&&e.mixins.forEach(l)}return!i&&!a?(me(e)&&r.set(e,null),null):(X(i)?i.forEach(l=>o[l]=null):Le(o,i),me(e)&&r.set(e,o),o)}function os(e,t){return!e||!Kr(t)?!1:(t=t.slice(2).replace(/Once$/,""),de(e,t[0].toLowerCase()+t.slice(1))||de(e,yn(t))||de(e,t))}function ro(e){const{type:t,vnode:n,proxy:r,withProxy:s,propsOptions:[i],slots:o,attrs:a,emit:l,render:c,renderCache:u,props:f,data:h,setupState:_,ctx:A,inheritAttrs:E}=e,O=xr(e);let R,x;try{if(n.shapeFlag&4){const b=s||r,I=b;R=At(c.call(I,b,u,f,_,h,A)),x=a}else{const b=t;R=At(b.length>1?b(f,{attrs:a,slots:o,emit:l}):b(f,null)),x=t.props?a:yf(a)}}catch(b){er.length=0,ts(b,e,1),R=Ve(qe)}let y=R;if(x&&E!==!1){const b=Object.keys(x),{shapeFlag:I}=y;b.length&&I&7&&(i&&b.some(fi)&&(x=Ef(x,i)),y=en(y,x,!1,!0))}return n.dirs&&(y=en(y,null,!1,!0),y.dirs=y.dirs?y.dirs.concat(n.dirs):n.dirs),n.transition&&or(y,n.transition),R=y,xr(O),R}const yf=e=>{let t;for(const n in e)(n==="class"||n==="style"||Kr(n))&&((t||(t={}))[n]=e[n]);return t},Ef=(e,t)=>{const n={};for(const r in e)(!fi(r)||!(r.slice(9)in t))&&(n[r]=e[r]);return n};function Tf(e,t,n){const{props:r,children:s,component:i}=e,{props:o,children:a,patchFlag:l}=t,c=i.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&l>=0){if(l&1024)return!0;if(l&16)return r?so(r,o,c):!!o;if(l&8){const u=t.dynamicProps;for(let f=0;fObject.create(Il),Cl=e=>Object.getPrototypeOf(e)===Il;function Af(e,t,n,r=!1){const s={},i=kl();e.propsDefaults=Object.create(null),Pl(e,t,s,i);for(const o in e.propsOptions[0])o in s||(s[o]=void 0);n?e.props=r?s:nl(s):e.type.props?e.props=s:e.props=i,e.attrs=i}function Nf(e,t,n,r){const{props:s,attrs:i,vnode:{patchFlag:o}}=e,a=le(s),[l]=e.propsOptions;let c=!1;if((r||o>0)&&!(o&16)){if(o&8){const u=e.vnode.dynamicProps;for(let f=0;f{l=!0;const[h,_]=Ol(f,t,!0);Le(o,h),_&&a.push(..._)};!n&&t.mixins.length&&t.mixins.forEach(u),e.extends&&u(e.extends),e.mixins&&e.mixins.forEach(u)}if(!i&&!l)return me(e)&&r.set(e,kn),kn;if(X(i))for(let u=0;ue==="_"||e==="_ctx"||e==="$stable",Si=e=>X(e)?e.map(At):[At(e)],If=(e,t,n)=>{if(t._n)return t;const r=ju((...s)=>Si(t(...s)),n);return r._c=!1,r},Ll=(e,t,n)=>{const r=e._ctx;for(const s in e){if(Ni(s))continue;const i=e[s];if(ne(i))t[s]=If(s,i,r);else if(i!=null){const o=Si(i);t[s]=()=>o}}},Rl=(e,t)=>{const n=Si(t);e.slots.default=()=>n},Dl=(e,t,n)=>{for(const r in t)(n||!Ni(r))&&(e[r]=t[r])},kf=(e,t,n)=>{const r=e.slots=kl();if(e.vnode.shapeFlag&32){const s=t._;s?(Dl(r,t,n),n&&xa(r,"_",s,!0)):Ll(t,r)}else t&&Rl(e,t)},Cf=(e,t,n)=>{const{vnode:r,slots:s}=e;let i=!0,o=pe;if(r.shapeFlag&32){const a=t._;a?n&&a===1?i=!1:Dl(s,t,n):(i=!t.$stable,Ll(t,s)),o=t}else t&&(Rl(e,t),o={default:1});if(i)for(const a in s)!Ni(a)&&o[a]==null&&delete s[a]},Qe=Df;function Pf(e){return Of(e)}function Of(e,t){const n=Jr();n.__VUE__=!0;const{insert:r,remove:s,patchProp:i,createElement:o,createText:a,createComment:l,setText:c,setElementText:u,parentNode:f,nextSibling:h,setScopeId:_=It,insertStaticContent:A}=e,E=(p,v,g,N=null,F=null,L=null,W=void 0,H=null,d=!!v.dynamicChildren)=>{if(p===v)return;p&&!pn(p,v)&&(N=D(p),Ae(p,F,L,!0),p=null),v.patchFlag===-2&&(d=!1,v.dynamicChildren=null);const{type:m,ref:w,shapeFlag:C}=v;switch(m){case br:O(p,v,g,N);break;case qe:R(p,v,g,N);break;case Cr:p==null&&x(v,g,N,W);break;case Ge:U(p,v,g,N,F,L,W,H,d);break;default:C&1?I(p,v,g,N,F,L,W,H,d):C&6?J(p,v,g,N,F,L,W,H,d):(C&64||C&128)&&m.process(p,v,g,N,F,L,W,H,d,q)}w!=null&&F?Jn(w,p&&p.ref,L,v||p,!v):w==null&&p&&p.ref!=null&&Jn(p.ref,null,L,p,!0)},O=(p,v,g,N)=>{if(p==null)r(v.el=a(v.children),g,N);else{const F=v.el=p.el;v.children!==p.children&&c(F,v.children)}},R=(p,v,g,N)=>{p==null?r(v.el=l(v.children||""),g,N):v.el=p.el},x=(p,v,g,N)=>{[p.el,p.anchor]=A(p.children,v,g,N,p.el,p.anchor)},y=({el:p,anchor:v},g,N)=>{let F;for(;p&&p!==v;)F=h(p),r(p,g,N),p=F;r(v,g,N)},b=({el:p,anchor:v})=>{let g;for(;p&&p!==v;)g=h(p),s(p),p=g;s(v)},I=(p,v,g,N,F,L,W,H,d)=>{if(v.type==="svg"?W="svg":v.type==="math"&&(W="mathml"),p==null)k(v,g,N,F,L,W,H,d);else{const m=p.el&&p.el._isVueCE?p.el:null;try{m&&m._beginPatch(),S(p,v,F,L,W,H,d)}finally{m&&m._endPatch()}}},k=(p,v,g,N,F,L,W,H)=>{let d,m;const{props:w,shapeFlag:C,transition:B,dirs:V}=p;if(d=p.el=o(p.type,L,w&&w.is,w),C&8?u(d,p.children):C&16&&j(p.children,d,null,N,F,As(p,L),W,H),V&&ln(p,null,N,"created"),M(d,p,p.scopeId,W,N),w){for(const P in w)P!=="value"&&!qn(P)&&i(d,P,null,w[P],L,N);"value"in w&&i(d,"value",null,w.value,L),(m=w.onVnodeBeforeMount)&&yt(m,N,p)}V&&ln(p,null,N,"beforeMount");const T=Lf(F,B);T&&B.beforeEnter(d),r(d,v,g),((m=w&&w.onVnodeMounted)||T||V)&&Qe(()=>{m&&yt(m,N,p),T&&B.enter(d),V&&ln(p,null,N,"mounted")},F)},M=(p,v,g,N,F)=>{if(g&&_(p,g),N)for(let L=0;L{for(let m=d;m{const H=v.el=p.el;let{patchFlag:d,dynamicChildren:m,dirs:w}=v;d|=p.patchFlag&16;const C=p.props||pe,B=v.props||pe;let V;if(g&&cn(g,!1),(V=B.onVnodeBeforeUpdate)&&yt(V,g,v,p),w&&ln(v,p,g,"beforeUpdate"),g&&cn(g,!0),(C.innerHTML&&B.innerHTML==null||C.textContent&&B.textContent==null)&&u(H,""),m?G(p.dynamicChildren,m,H,g,N,As(v,F),L):W||oe(p,v,H,null,g,N,As(v,F),L,!1),d>0){if(d&16)Z(H,C,B,g,F);else if(d&2&&C.class!==B.class&&i(H,"class",null,B.class,F),d&4&&i(H,"style",C.style,B.style,F),d&8){const T=v.dynamicProps;for(let P=0;P{V&&yt(V,g,v,p),w&&ln(v,p,g,"updated")},N)},G=(p,v,g,N,F,L,W)=>{for(let H=0;H{if(v!==g){if(v!==pe)for(const L in v)!qn(L)&&!(L in g)&&i(p,L,v[L],null,F,N);for(const L in g){if(qn(L))continue;const W=g[L],H=v[L];W!==H&&L!=="value"&&i(p,L,H,W,F,N)}"value"in g&&i(p,"value",v.value,g.value,F)}},U=(p,v,g,N,F,L,W,H,d)=>{const m=v.el=p?p.el:a(""),w=v.anchor=p?p.anchor:a("");let{patchFlag:C,dynamicChildren:B,slotScopeIds:V}=v;V&&(H=H?H.concat(V):V),p==null?(r(m,g,N),r(w,g,N),j(v.children||[],g,w,F,L,W,H,d)):C>0&&C&64&&B&&p.dynamicChildren&&p.dynamicChildren.length===B.length?(G(p.dynamicChildren,B,g,F,L,W,H),(v.key!=null||F&&v===F.subTree)&&Ml(p,v,!0)):oe(p,v,g,w,F,L,W,H,d)},J=(p,v,g,N,F,L,W,H,d)=>{v.slotScopeIds=H,p==null?v.shapeFlag&512?F.ctx.activate(v,g,N,W,d):ge(v,g,N,F,L,W,d):Se(p,v,d)},ge=(p,v,g,N,F,L,W)=>{const H=p.component=Wf(p,N,F);if(rs(p)&&(H.ctx.renderer=q),Bf(H,!1,W),H.asyncDep){if(F&&F.registerDep(H,se,W),!p.el){const d=H.subTree=Ve(qe);R(null,d,v,g),p.placeholder=d.el}}else se(H,p,v,g,F,L,W)},Se=(p,v,g)=>{const N=v.component=p.component;if(Tf(p,v,g))if(N.asyncDep&&!N.asyncResolved){ee(N,v,g);return}else N.next=v,N.update();else v.el=p.el,N.vnode=v},se=(p,v,g,N,F,L,W)=>{const H=()=>{if(p.isMounted){let{next:C,bu:B,u:V,parent:T,vnode:P}=p;{const Me=xl(p);if(Me){C&&(C.el=P.el,ee(p,C,W)),Me.asyncDep.then(()=>{Qe(()=>{p.isUnmounted||m()},F)});return}}let Y=C,ae;cn(p,!1),C?(C.el=P.el,ee(p,C,W)):C=P,B&&Ir(B),(ae=C.props&&C.props.onVnodeBeforeUpdate)&&yt(ae,T,C,P),cn(p,!0);const ye=ro(p),We=p.subTree;p.subTree=ye,E(We,ye,f(We.el),D(We),p,F,L),C.el=ye.el,Y===null&&wf(p,ye.el),V&&Qe(V,F),(ae=C.props&&C.props.onVnodeUpdated)&&Qe(()=>yt(ae,T,C,P),F)}else{let C;const{el:B,props:V}=v,{bm:T,m:P,parent:Y,root:ae,type:ye}=p,We=Qn(v);cn(p,!1),T&&Ir(T),!We&&(C=V&&V.onVnodeBeforeMount)&&yt(C,Y,v),cn(p,!0);{ae.ce&&ae.ce._hasShadowRoot()&&ae.ce._injectChildStyle(ye,p.parent?p.parent.type:void 0);const Me=p.subTree=ro(p);E(null,Me,g,N,p,F,L),v.el=Me.el}if(P&&Qe(P,F),!We&&(C=V&&V.onVnodeMounted)){const Me=v;Qe(()=>yt(C,Y,Me),F)}(v.shapeFlag&256||Y&&Qn(Y.vnode)&&Y.vnode.shapeFlag&256)&&p.a&&Qe(p.a,F),p.isMounted=!0,v=g=N=null}};p.scope.on();const d=p.effect=new Wa(H);p.scope.off();const m=p.update=d.run.bind(d),w=p.job=d.runIfDirty.bind(d);w.i=p,w.id=p.uid,d.scheduler=()=>Ai(w),cn(p,!0),m()},ee=(p,v,g)=>{v.component=p;const N=p.vnode.props;p.vnode=v,p.next=null,Nf(p,v.props,N,g),Cf(p,v.children,g),Wt(),Gi(p),Bt()},oe=(p,v,g,N,F,L,W,H,d=!1)=>{const m=p&&p.children,w=p?p.shapeFlag:0,C=v.children,{patchFlag:B,shapeFlag:V}=v;if(B>0){if(B&128){Xe(m,C,g,N,F,L,W,H,d);return}else if(B&256){He(m,C,g,N,F,L,W,H,d);return}}V&8?(w&16&&Re(m,F,L),C!==m&&u(g,C)):w&16?V&16?Xe(m,C,g,N,F,L,W,H,d):Re(m,F,L,!0):(w&8&&u(g,""),V&16&&j(C,g,N,F,L,W,H,d))},He=(p,v,g,N,F,L,W,H,d)=>{p=p||kn,v=v||kn;const m=p.length,w=v.length,C=Math.min(m,w);let B;for(B=0;Bw?Re(p,F,L,!0,!1,C):j(v,g,N,F,L,W,H,d,C)},Xe=(p,v,g,N,F,L,W,H,d)=>{let m=0;const w=v.length;let C=p.length-1,B=w-1;for(;m<=C&&m<=B;){const V=p[m],T=v[m]=d?xt(v[m]):At(v[m]);if(pn(V,T))E(V,T,g,null,F,L,W,H,d);else break;m++}for(;m<=C&&m<=B;){const V=p[C],T=v[B]=d?xt(v[B]):At(v[B]);if(pn(V,T))E(V,T,g,null,F,L,W,H,d);else break;C--,B--}if(m>C){if(m<=B){const V=B+1,T=VB)for(;m<=C;)Ae(p[m],F,L,!0),m++;else{const V=m,T=m,P=new Map;for(m=T;m<=B;m++){const nt=v[m]=d?xt(v[m]):At(v[m]);nt.key!=null&&P.set(nt.key,m)}let Y,ae=0;const ye=B-T+1;let We=!1,Me=0;const an=new Array(ye);for(m=0;m=ye){Ae(nt,F,L,!0);continue}let bt;if(nt.key!=null)bt=P.get(nt.key);else for(Y=T;Y<=B;Y++)if(an[Y-T]===0&&pn(nt,v[Y])){bt=Y;break}bt===void 0?Ae(nt,F,L,!0):(an[bt-T]=m+1,bt>=Me?Me=bt:We=!0,E(nt,v[bt],g,null,F,L,W,H,d),ae++)}const gs=We?Rf(an):kn;for(Y=gs.length-1,m=ye-1;m>=0;m--){const nt=T+m,bt=v[nt],Vi=v[nt+1],Hi=nt+1{const{el:L,type:W,transition:H,children:d,shapeFlag:m}=p;if(m&6){we(p.component.subTree,v,g,N);return}if(m&128){p.suspense.move(v,g,N);return}if(m&64){W.move(p,v,g,q);return}if(W===Ge){r(L,v,g);for(let C=0;CH.enter(L),F);else{const{leave:C,delayLeave:B,afterLeave:V}=H,T=()=>{p.ctx.isUnmounted?s(L):r(L,v,g)},P=()=>{L._isLeaving&&L[Tt](!0),C(L,()=>{T(),V&&V()})};B?B(L,T,P):P()}else r(L,v,g)},Ae=(p,v,g,N=!1,F=!1)=>{const{type:L,props:W,ref:H,children:d,dynamicChildren:m,shapeFlag:w,patchFlag:C,dirs:B,cacheIndex:V}=p;if(C===-2&&(F=!1),H!=null&&(Wt(),Jn(H,null,g,p,!0),Bt()),V!=null&&(v.renderCache[V]=void 0),w&256){v.ctx.deactivate(p);return}const T=w&1&&B,P=!Qn(p);let Y;if(P&&(Y=W&&W.onVnodeBeforeUnmount)&&yt(Y,v,p),w&6)tt(p.component,g,N);else{if(w&128){p.suspense.unmount(g,N);return}T&&ln(p,null,v,"beforeUnmount"),w&64?p.type.remove(p,v,g,q,N):m&&!m.hasOnce&&(L!==Ge||C>0&&C&64)?Re(m,v,g,!1,!0):(L===Ge&&C&384||!F&&w&16)&&Re(d,v,g),N&<(p)}(P&&(Y=W&&W.onVnodeUnmounted)||T)&&Qe(()=>{Y&&yt(Y,v,p),T&&ln(p,null,v,"unmounted")},g)},lt=p=>{const{type:v,el:g,anchor:N,transition:F}=p;if(v===Ge){et(g,N);return}if(v===Cr){b(p);return}const L=()=>{s(g),F&&!F.persisted&&F.afterLeave&&F.afterLeave()};if(p.shapeFlag&1&&F&&!F.persisted){const{leave:W,delayLeave:H}=F,d=()=>W(g,L);H?H(p.el,L,d):d()}else L()},et=(p,v)=>{let g;for(;p!==v;)g=h(p),s(p),p=g;s(v)},tt=(p,v,g)=>{const{bum:N,scope:F,job:L,subTree:W,um:H,m:d,a:m}=p;oo(d),oo(m),N&&Ir(N),F.stop(),L&&(L.flags|=8,Ae(W,p,v,g)),H&&Qe(H,v),Qe(()=>{p.isUnmounted=!0},v)},Re=(p,v,g,N=!1,F=!1,L=0)=>{for(let W=L;W{if(p.shapeFlag&6)return D(p.component.subTree);if(p.shapeFlag&128)return p.suspense.next();const v=h(p.anchor||p.el),g=v&&v[zu];return g?h(g):v};let K=!1;const $=(p,v,g)=>{let N;p==null?v._vnode&&(Ae(v._vnode,null,null,!0),N=v._vnode.component):E(v._vnode||null,p,v,null,null,null,g),v._vnode=p,K||(K=!0,Gi(N),al(),K=!1)},q={p:E,um:Ae,m:we,r:lt,mt:ge,mc:j,pc:oe,pbc:G,n:D,o:e};return{render:$,hydrate:void 0,createApp:gf($)}}function As({type:e,props:t},n){return n==="svg"&&e==="foreignObject"||n==="mathml"&&e==="annotation-xml"&&t&&t.encoding&&t.encoding.includes("html")?void 0:n}function cn({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function Lf(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function Ml(e,t,n=!1){const r=e.children,s=t.children;if(X(r)&&X(s))for(let i=0;i>1,e[n[a]]0&&(t[r]=n[i-1]),n[i]=r)}}for(i=n.length,o=n[i-1];i-- >0;)n[i]=o,o=t[o];return n}function xl(e){const t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:xl(t)}function oo(e){if(e)for(let t=0;te.__isSuspense;function Df(e,t){t&&t.pendingBranch?X(e)?t.effects.push(...e):t.effects.push(e):Uu(e)}const Ge=Symbol.for("v-fgt"),br=Symbol.for("v-txt"),qe=Symbol.for("v-cmt"),Cr=Symbol.for("v-stc"),er=[];let it=null;function Ze(e=!1){er.push(it=e?null:[])}function Mf(){er.pop(),it=er[er.length-1]||null}let ar=1;function jr(e,t=!1){ar+=e,e<0&&it&&t&&(it.hasOnce=!0)}function jl(e){return e.dynamicChildren=ar>0?it||kn:null,Mf(),ar>0&&it&&it.push(e),e}function ut(e,t,n,r,s,i){return jl(rt(e,t,n,r,s,i,!0))}function Vl(e,t,n,r,s){return jl(Ve(e,t,n,r,s,!0))}function Vr(e){return e?e.__v_isVNode===!0:!1}function pn(e,t){return e.type===t.type&&e.key===t.key}const Hl=({key:e})=>e??null,Pr=({ref:e,ref_key:t,ref_for:n})=>(typeof e=="number"&&(e=""+e),e!=null?ke(e)||Te(e)||ne(e)?{i:st,r:e,k:t,f:!!n}:e:null);function rt(e,t=null,n=null,r=0,s=null,i=e===Ge?0:1,o=!1,a=!1){const l={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&Hl(t),ref:t&&Pr(t),scopeId:cl,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:i,patchFlag:r,dynamicProps:s,dynamicChildren:null,appContext:null,ctx:st};return a?(Ii(l,n),i&128&&e.normalize(l)):n&&(l.shapeFlag|=ke(n)?8:16),ar>0&&!o&&it&&(l.patchFlag>0||i&6)&&l.patchFlag!==32&&it.push(l),l}const Ve=xf;function xf(e,t=null,n=null,r=0,s=null,i=!1){if((!e||e===af)&&(e=qe),Vr(e)){const a=en(e,t,!0);return n&&Ii(a,n),ar>0&&!i&&it&&(a.shapeFlag&6?it[it.indexOf(e)]=a:it.push(a)),a.patchFlag=-2,a}if(qf(e)&&(e=e.__vccOpts),t){t=Ff(t);let{class:a,style:l}=t;a&&!ke(a)&&(t.class=Qr(a)),me(l)&&(es(l)&&!X(l)&&(l=Le({},l)),t.style=mi(l))}const o=ke(e)?1:Ul(e)?128:dl(e)?64:me(e)?4:ne(e)?2:0;return rt(e,t,n,r,s,o,i,!0)}function Ff(e){return e?es(e)||Cl(e)?Le({},e):e:null}function en(e,t,n=!1,r=!1){const{props:s,ref:i,patchFlag:o,children:a,transition:l}=e,c=t?jf(s||{},t):s,u={__v_isVNode:!0,__v_skip:!0,type:e.type,props:c,key:c&&Hl(c),ref:t&&t.ref?n&&i?X(i)?i.concat(Pr(t)):[i,Pr(t)]:Pr(t):i,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:a,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==Ge?o===-1?16:o|16:o,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:l,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&en(e.ssContent),ssFallback:e.ssFallback&&en(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return l&&r&&or(u,l.clone(u)),u}function Uf(e=" ",t=0){return Ve(br,null,e,t)}function wg(e,t){const n=Ve(Cr,null,e);return n.staticCount=t,n}function Wl(e="",t=!1){return t?(Ze(),Vl(qe,null,e)):Ve(qe,null,e)}function At(e){return e==null||typeof e=="boolean"?Ve(qe):X(e)?Ve(Ge,null,e.slice()):Vr(e)?xt(e):Ve(br,null,String(e))}function xt(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:en(e)}function Ii(e,t){let n=0;const{shapeFlag:r}=e;if(t==null)t=null;else if(X(t))n=16;else if(typeof t=="object")if(r&65){const s=t.default;s&&(s._c&&(s._d=!1),Ii(e,s()),s._c&&(s._d=!0));return}else{n=32;const s=t._;!s&&!Cl(t)?t._ctx=st:s===3&&st&&(st.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else ne(t)?(t={default:t,_ctx:st},n=32):(t=String(t),r&64?(n=16,t=[Uf(t)]):n=8);e.children=t,e.shapeFlag|=n}function jf(...e){const t={};for(let n=0;nje||st;let Hr,Gs;{const e=Jr(),t=(n,r)=>{let s;return(s=e[n])||(s=e[n]=[]),s.push(r),i=>{s.length>1?s.forEach(o=>o(i)):s[0](i)}};Hr=t("__VUE_INSTANCE_SETTERS__",n=>je=n),Gs=t("__VUE_SSR_SETTERS__",n=>lr=n)}const yr=e=>{const t=je;return Hr(e),e.scope.on(),()=>{e.scope.off(),Hr(t)}},ao=()=>{je&&je.scope.off(),Hr(null)};function Bl(e){return e.vnode.shapeFlag&4}let lr=!1;function Bf(e,t=!1,n=!1){t&&Gs(t);const{props:r,children:s}=e.vnode,i=Bl(e);Af(e,r,i,t),kf(e,s,n||t);const o=i?$f(e,t):void 0;return t&&Gs(!1),o}function $f(e,t){const n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,cf);const{setup:r}=n;if(r){Wt();const s=e.setupContext=r.length>1?Kf(e):null,i=yr(e),o=_r(r,e,0,[e.props,s]),a=Ra(o);if(Bt(),i(),(a||e.sp)&&!Qn(e)&&vl(e),a){if(o.then(ao,ao),t)return o.then(l=>{lo(e,l)}).catch(l=>{ts(l,e,0)});e.asyncDep=o}else lo(e,o)}else $l(e)}function lo(e,t,n){ne(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:me(t)&&(e.setupState=sl(t)),$l(e)}function $l(e,t,n){const r=e.type;e.render||(e.render=r.render||It);{const s=yr(e);Wt();try{uf(e)}finally{Bt(),s()}}}const zf={get(e,t){return Ue(e,"get",""),e[t]}};function Kf(e){const t=n=>{e.exposed=n||{}};return{attrs:new Proxy(e.attrs,zf),slots:e.slots,emit:e.emit,expose:t}}function as(e){return e.exposed?e.exposeProxy||(e.exposeProxy=new Proxy(sl(Ti(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in Zn)return Zn[n](e)},has(t,n){return n in t||n in Zn}})):e.proxy}function Gf(e,t=!0){return ne(e)?e.displayName||e.name:e.name||t&&e.__name}function qf(e){return ne(e)&&"__vccOpts"in e}const ue=(e,t)=>Ru(e,t,lr);function Er(e,t,n){try{jr(-1);const r=arguments.length;return r===2?me(t)&&!X(t)?Vr(t)?Ve(e,null,[t]):Ve(e,t):Ve(e,null,t):(r>3?n=Array.prototype.slice.call(arguments,2):r===3&&Vr(n)&&(n=[n]),Ve(e,t,n))}finally{jr(1)}}const Yf="3.5.30";/** +* @vue/runtime-dom v3.5.30 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/let qs;const co=typeof window<"u"&&window.trustedTypes;if(co)try{qs=co.createPolicy("vue",{createHTML:e=>e})}catch{}const zl=qs?e=>qs.createHTML(e):e=>e,Xf="http://www.w3.org/2000/svg",Jf="http://www.w3.org/1998/Math/MathML",Mt=typeof document<"u"?document:null,uo=Mt&&Mt.createElement("template"),Qf={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,r)=>{const s=t==="svg"?Mt.createElementNS(Xf,e):t==="mathml"?Mt.createElementNS(Jf,e):n?Mt.createElement(e,{is:n}):Mt.createElement(e);return e==="select"&&r&&r.multiple!=null&&s.setAttribute("multiple",r.multiple),s},createText:e=>Mt.createTextNode(e),createComment:e=>Mt.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>Mt.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,r,s,i){const o=n?n.previousSibling:t.lastChild;if(s&&(s===i||s.nextSibling))for(;t.insertBefore(s.cloneNode(!0),n),!(s===i||!(s=s.nextSibling)););else{uo.innerHTML=zl(r==="svg"?`${e}`:r==="mathml"?`${e}`:e);const a=uo.content;if(r==="svg"||r==="mathml"){const l=a.firstChild;for(;l.firstChild;)a.appendChild(l.firstChild);a.removeChild(l)}t.insertBefore(a,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},Kt="transition",Wn="animation",cr=Symbol("_vtc"),Kl={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},Zf=Le({},ml,Kl),ed=e=>(e.displayName="Transition",e.props=Zf,e),Ag=ed((e,{slots:t})=>Er(qu,td(e),t)),un=(e,t=[])=>{X(e)?e.forEach(n=>n(...t)):e&&e(...t)},fo=e=>e?X(e)?e.some(t=>t.length>1):e.length>1:!1;function td(e){const t={};for(const U in e)U in Kl||(t[U]=e[U]);if(e.css===!1)return t;const{name:n="v",type:r,duration:s,enterFromClass:i=`${n}-enter-from`,enterActiveClass:o=`${n}-enter-active`,enterToClass:a=`${n}-enter-to`,appearFromClass:l=i,appearActiveClass:c=o,appearToClass:u=a,leaveFromClass:f=`${n}-leave-from`,leaveActiveClass:h=`${n}-leave-active`,leaveToClass:_=`${n}-leave-to`}=e,A=nd(s),E=A&&A[0],O=A&&A[1],{onBeforeEnter:R,onEnter:x,onEnterCancelled:y,onLeave:b,onLeaveCancelled:I,onBeforeAppear:k=R,onAppear:M=x,onAppearCancelled:j=y}=t,S=(U,J,ge,Se)=>{U._enterCancelled=Se,fn(U,J?u:a),fn(U,J?c:o),ge&&ge()},G=(U,J)=>{U._isLeaving=!1,fn(U,f),fn(U,_),fn(U,h),J&&J()},Z=U=>(J,ge)=>{const Se=U?M:x,se=()=>S(J,U,ge);un(Se,[J,se]),mo(()=>{fn(J,U?l:i),Ot(J,U?u:a),fo(Se)||ho(J,r,E,se)})};return Le(t,{onBeforeEnter(U){un(R,[U]),Ot(U,i),Ot(U,o)},onBeforeAppear(U){un(k,[U]),Ot(U,l),Ot(U,c)},onEnter:Z(!1),onAppear:Z(!0),onLeave(U,J){U._isLeaving=!0;const ge=()=>G(U,J);Ot(U,f),U._enterCancelled?(Ot(U,h),_o(U)):(_o(U),Ot(U,h)),mo(()=>{U._isLeaving&&(fn(U,f),Ot(U,_),fo(b)||ho(U,r,O,ge))}),un(b,[U,ge])},onEnterCancelled(U){S(U,!1,void 0,!0),un(y,[U])},onAppearCancelled(U){S(U,!0,void 0,!0),un(j,[U])},onLeaveCancelled(U){G(U),un(I,[U])}})}function nd(e){if(e==null)return null;if(me(e))return[Ns(e.enter),Ns(e.leave)];{const t=Ns(e);return[t,t]}}function Ns(e){return Zc(e)}function Ot(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e[cr]||(e[cr]=new Set)).add(t)}function fn(e,t){t.split(/\s+/).forEach(r=>r&&e.classList.remove(r));const n=e[cr];n&&(n.delete(t),n.size||(e[cr]=void 0))}function mo(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let rd=0;function ho(e,t,n,r){const s=e._endId=++rd,i=()=>{s===e._endId&&r()};if(n!=null)return setTimeout(i,n);const{type:o,timeout:a,propCount:l}=sd(e,t);if(!o)return r();const c=o+"end";let u=0;const f=()=>{e.removeEventListener(c,h),i()},h=_=>{_.target===e&&++u>=l&&f()};setTimeout(()=>{u(n[A]||"").split(", "),s=r(`${Kt}Delay`),i=r(`${Kt}Duration`),o=po(s,i),a=r(`${Wn}Delay`),l=r(`${Wn}Duration`),c=po(a,l);let u=null,f=0,h=0;t===Kt?o>0&&(u=Kt,f=o,h=i.length):t===Wn?c>0&&(u=Wn,f=c,h=l.length):(f=Math.max(o,c),u=f>0?o>c?Kt:Wn:null,h=u?u===Kt?i.length:l.length:0);const _=u===Kt&&/\b(?:transform|all)(?:,|$)/.test(r(`${Kt}Property`).toString());return{type:u,timeout:f,propCount:h,hasTransform:_}}function po(e,t){for(;e.lengthgo(n)+go(e[r])))}function go(e){return e==="auto"?0:Number(e.slice(0,-1).replace(",","."))*1e3}function _o(e){return(e?e.ownerDocument:document).body.offsetHeight}function id(e,t,n){const r=e[cr];r&&(t=(t?[t,...r]:[...r]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const Wr=Symbol("_vod"),Gl=Symbol("_vsh"),od={name:"show",beforeMount(e,{value:t},{transition:n}){e[Wr]=e.style.display==="none"?"":e.style.display,n&&t?n.beforeEnter(e):Bn(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:r}){!t!=!n&&(r?t?(r.beforeEnter(e),Bn(e,!0),r.enter(e)):r.leave(e,()=>{Bn(e,!1)}):Bn(e,t))},beforeUnmount(e,{value:t}){Bn(e,t)}};function Bn(e,t){e.style.display=t?e[Wr]:"none",e[Gl]=!t}const ad=Symbol(""),ld=/(?:^|;)\s*display\s*:/;function cd(e,t,n){const r=e.style,s=ke(n);let i=!1;if(n&&!s){if(t)if(ke(t))for(const o of t.split(";")){const a=o.slice(0,o.indexOf(":")).trim();n[a]==null&&Or(r,a,"")}else for(const o in t)n[o]==null&&Or(r,o,"");for(const o in n)o==="display"&&(i=!0),Or(r,o,n[o])}else if(s){if(t!==n){const o=r[ad];o&&(n+=";"+o),r.cssText=n,i=ld.test(n)}}else t&&e.removeAttribute("style");Wr in e&&(e[Wr]=i?r.display:"",e[Gl]&&(r.display="none"))}const vo=/\s*!important$/;function Or(e,t,n){if(X(n))n.forEach(r=>Or(e,t,r));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const r=ud(e,t);vo.test(n)?e.setProperty(yn(r),n.replace(vo,""),"important"):e[r]=n}}const bo=["Webkit","Moz","ms"],Ss={};function ud(e,t){const n=Ss[t];if(n)return n;let r=Ye(t);if(r!=="filter"&&r in e)return Ss[t]=r;r=Yr(r);for(let s=0;sIs||(hd.then(()=>Is=0),Is=Date.now());function gd(e,t){const n=r=>{if(!r._vts)r._vts=Date.now();else if(r._vts<=n.attached)return;_t(_d(r,n.value),t,5,[r])};return n.value=e,n.attached=pd(),n}function _d(e,t){if(X(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(r=>s=>!s._stopped&&r&&r(s))}else return t}const No=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,vd=(e,t,n,r,s,i)=>{const o=s==="svg";t==="class"?id(e,r,o):t==="style"?cd(e,n,r):Kr(t)?fi(t)||dd(e,t,n,r,i):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):bd(e,t,r,o))?(To(e,t,r),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&Eo(e,t,r,o,i,t!=="value")):e._isVueCE&&(yd(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!ke(r)))?To(e,Ye(t),r,i,t):(t==="true-value"?e._trueValue=r:t==="false-value"&&(e._falseValue=r),Eo(e,t,r,o))};function bd(e,t,n,r){if(r)return!!(t==="innerHTML"||t==="textContent"||t in e&&No(t)&&ne(n));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const s=e.tagName;if(s==="IMG"||s==="VIDEO"||s==="CANVAS"||s==="SOURCE")return!1}return No(t)&&ke(n)?!1:t in e}function yd(e,t){const n=e._def.props;if(!n)return!1;const r=Ye(t);return Array.isArray(n)?n.some(s=>Ye(s)===r):Object.keys(n).some(s=>Ye(s)===r)}const Ln=e=>{const t=e.props["onUpdate:modelValue"]||!1;return X(t)?n=>Ir(t,n):t};function Ed(e){e.target.composing=!0}function So(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const Ht=Symbol("_assign");function Io(e,t,n){return t&&(e=e.trim()),n&&(e=Xr(e)),e}const Ng={created(e,{modifiers:{lazy:t,trim:n,number:r}},s){e[Ht]=Ln(s);const i=r||s.props&&s.props.type==="number";Qt(e,t?"change":"input",o=>{o.target.composing||e[Ht](Io(e.value,n,i))}),(n||i)&&Qt(e,"change",()=>{e.value=Io(e.value,n,i)}),t||(Qt(e,"compositionstart",Ed),Qt(e,"compositionend",So),Qt(e,"change",So))},mounted(e,{value:t}){e.value=t??""},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:s,number:i}},o){if(e[Ht]=Ln(o),e.composing)return;const a=(i||e.type==="number")&&!/^0\d/.test(e.value)?Xr(e.value):e.value,l=t??"";a!==l&&(document.activeElement===e&&e.type!=="range"&&(r&&t===n||s&&e.value.trim()===l)||(e.value=l))}},Sg={deep:!0,created(e,t,n){e[Ht]=Ln(n),Qt(e,"change",()=>{const r=e._modelValue,s=ur(e),i=e.checked,o=e[Ht];if(X(r)){const a=hi(r,s),l=a!==-1;if(i&&!l)o(r.concat(s));else if(!i&&l){const c=[...r];c.splice(a,1),o(c)}}else if(Fn(r)){const a=new Set(r);i?a.add(s):a.delete(s),o(a)}else o(ql(e,i))})},mounted:ko,beforeUpdate(e,t,n){e[Ht]=Ln(n),ko(e,t,n)}};function ko(e,{value:t,oldValue:n},r){e._modelValue=t;let s;if(X(t))s=hi(t,r.props.value)>-1;else if(Fn(t))s=t.has(r.props.value);else{if(t===n)return;s=Un(t,ql(e,!0))}e.checked!==s&&(e.checked=s)}const Ig={deep:!0,created(e,{value:t,modifiers:{number:n}},r){const s=Fn(t);Qt(e,"change",()=>{const i=Array.prototype.filter.call(e.options,o=>o.selected).map(o=>n?Xr(ur(o)):ur(o));e[Ht](e.multiple?s?new Set(i):i:i[0]),e._assigning=!0,ns(()=>{e._assigning=!1})}),e[Ht]=Ln(r)},mounted(e,{value:t}){Co(e,t)},beforeUpdate(e,t,n){e[Ht]=Ln(n)},updated(e,{value:t}){e._assigning||Co(e,t)}};function Co(e,t){const n=e.multiple,r=X(t);if(!(n&&!r&&!Fn(t))){for(let s=0,i=e.options.length;sString(c)===String(a)):o.selected=hi(t,a)>-1}else o.selected=t.has(a);else if(Un(ur(o),t)){e.selectedIndex!==s&&(e.selectedIndex=s);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function ur(e){return"_value"in e?e._value:e.value}function ql(e,t){const n=t?"_trueValue":"_falseValue";return n in e?e[n]:t}const Td=["ctrl","shift","alt","meta"],wd={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>Td.some(n=>e[`${n}Key`]&&!t.includes(n))},kg=(e,t)=>{if(!e)return e;const n=e._withMods||(e._withMods={}),r=t.join(".");return n[r]||(n[r]=(s,...i)=>{for(let o=0;o{const t=Nd().createApp(...e),{mount:n}=t;return t.mount=r=>{const s=kd(r);if(!s)return;const i=t._component;!ne(i)&&!i.render&&!i.template&&(i.template=s.innerHTML),s.nodeType===1&&(s.textContent="");const o=n(s,!1,Id(s));return s instanceof Element&&(s.removeAttribute("v-cloak"),s.setAttribute("data-v-app","")),o},t};function Id(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function kd(e){return ke(e)?document.querySelector(e):e}/*! + * pinia v2.3.1 + * (c) 2025 Eduardo San Martin Morote + * @license MIT + */let Yl;const ls=e=>Yl=e,Xl=Symbol();function Ys(e){return e&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"&&typeof e.toJSON!="function"}var tr;(function(e){e.direct="direct",e.patchObject="patch object",e.patchFunction="patch function"})(tr||(tr={}));function Cd(){const e=pi(!0),t=e.run(()=>Pe({}));let n=[],r=[];const s=Ti({install(i){ls(s),s._a=i,i.provide(Xl,s),i.config.globalProperties.$pinia=s,r.forEach(o=>n.push(o)),r=[]},use(i){return this._a?n.push(i):r.push(i),this},_p:n,_a:null,_e:e,_s:new Map,state:t});return s}const Jl=()=>{};function Oo(e,t,n,r=Jl){e.push(t);const s=()=>{const i=e.indexOf(t);i>-1&&(e.splice(i,1),r())};return!n&&Ha()&&au(s),s}function wn(e,...t){e.slice().forEach(n=>{n(...t)})}const Pd=e=>e(),Lo=Symbol(),ks=Symbol();function Xs(e,t){e instanceof Map&&t instanceof Map?t.forEach((n,r)=>e.set(r,n)):e instanceof Set&&t instanceof Set&&t.forEach(e.add,e);for(const n in t){if(!t.hasOwnProperty(n))continue;const r=t[n],s=e[n];Ys(s)&&Ys(r)&&e.hasOwnProperty(n)&&!Te(r)&&!Vt(r)?e[n]=Xs(s,r):e[n]=r}return e}const Od=Symbol();function Ld(e){return!Ys(e)||!e.hasOwnProperty(Od)}const{assign:Yt}=Object;function Rd(e){return!!(Te(e)&&e.effect)}function Dd(e,t,n,r){const{state:s,actions:i,getters:o}=t,a=n.state.value[e];let l;function c(){a||(n.state.value[e]=s?s():{});const u=Cu(n.state.value[e]);return Yt(u,i,Object.keys(o||{}).reduce((f,h)=>(f[h]=Ti(ue(()=>{ls(n);const _=n._s.get(e);return o[h].call(_,_)})),f),{}))}return l=Ql(e,c,t,n,r,!0),l}function Ql(e,t,n={},r,s,i){let o;const a=Yt({actions:{}},n),l={deep:!0};let c,u,f=[],h=[],_;const A=r.state.value[e];!i&&!A&&(r.state.value[e]={});let E;function O(j){let S;c=u=!1,typeof j=="function"?(j(r.state.value[e]),S={type:tr.patchFunction,storeId:e,events:_}):(Xs(r.state.value[e],j),S={type:tr.patchObject,payload:j,storeId:e,events:_});const G=E=Symbol();ns().then(()=>{E===G&&(c=!0)}),u=!0,wn(f,S,r.state.value[e])}const R=i?function(){const{state:S}=n,G=S?S():{};this.$patch(Z=>{Yt(Z,G)})}:Jl;function x(){o.stop(),f=[],h=[],r._s.delete(e)}const y=(j,S="")=>{if(Lo in j)return j[ks]=S,j;const G=function(){ls(r);const Z=Array.from(arguments),U=[],J=[];function ge(ee){U.push(ee)}function Se(ee){J.push(ee)}wn(h,{args:Z,name:G[ks],store:I,after:ge,onError:Se});let se;try{se=j.apply(this&&this.$id===e?this:I,Z)}catch(ee){throw wn(J,ee),ee}return se instanceof Promise?se.then(ee=>(wn(U,ee),ee)).catch(ee=>(wn(J,ee),Promise.reject(ee))):(wn(U,se),se)};return G[Lo]=!0,G[ks]=S,G},b={_p:r,$id:e,$onAction:Oo.bind(null,h),$patch:O,$reset:R,$subscribe(j,S={}){const G=Oo(f,j,S.detached,()=>Z()),Z=o.run(()=>Zt(()=>r.state.value[e],U=>{(S.flush==="sync"?u:c)&&j({storeId:e,type:tr.direct,events:_},U)},Yt({},l,S)));return G},$dispose:x},I=gr(b);r._s.set(e,I);const M=(r._a&&r._a.runWithContext||Pd)(()=>r._e.run(()=>(o=pi()).run(()=>t({action:y}))));for(const j in M){const S=M[j];if(Te(S)&&!Rd(S)||Vt(S))i||(A&&Ld(S)&&(Te(S)?S.value=A[j]:Xs(S,A[j])),r.state.value[e][j]=S);else if(typeof S=="function"){const G=y(S,j);M[j]=G,a.actions[j]=S}}return Yt(I,M),Yt(le(I),M),Object.defineProperty(I,"$state",{get:()=>r.state.value[e],set:j=>{O(S=>{Yt(S,j)})}}),r._p.forEach(j=>{Yt(I,o.run(()=>j({store:I,app:r._a,pinia:r,options:a})))}),A&&i&&n.hydrate&&n.hydrate(I.$state,A),c=!0,u=!0,I}/*! #__NO_SIDE_EFFECTS__ */function Md(e,t,n){let r,s;const i=typeof t=="function";r=e,s=i?n:t;function o(a,l){const c=Hu();return a=a||(c?at(Xl,null):null),a&&ls(a),a=Yl,a._s.has(r)||(i?Ql(r,t,s,a):Dd(r,s,a)),a._s.get(r)}return o.$id=r,o}const xd="/api";class Fd{constructor(t){Wi(this,"baseUrl");this.baseUrl=t}getToken(){return localStorage.getItem("accessToken")}async request(t,n,r){const s={"Content-Type":"application/json"},i=this.getToken();i&&(s.Authorization=`Bearer ${i}`);const o={method:t,headers:s};r&&(o.body=JSON.stringify(r));const a=await fetch(`${this.baseUrl}${n}`,o);if(a.status===401&&await this.tryRefreshToken()){s.Authorization=`Bearer ${this.getToken()}`;const u=await fetch(`${this.baseUrl}${n}`,{...o,headers:s});return{data:await u.json(),status:u.status}}const l=await a.json();if(!a.ok)throw new Error(l.error||"Request failed");return{data:l,status:a.status}}async tryRefreshToken(){const t=localStorage.getItem("refreshToken");if(!t)return!1;try{const n=await fetch(`${this.baseUrl}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})});if(!n.ok)return!1;const r=await n.json();return localStorage.setItem("accessToken",r.accessToken),!0}catch{return!1}}get(t){return this.request("GET",t)}post(t,n){return this.request("POST",t,n)}put(t,n){return this.request("PUT",t,n)}delete(t){return this.request("DELETE",t)}}const $n=new Fd(xd),ki=Md("auth",()=>{const e=Pe(null),t=Pe(localStorage.getItem("accessToken")),n=Pe(localStorage.getItem("refreshToken")),r=Pe(localStorage.getItem("orgSlug")||""),s=ue(()=>!!e.value&&!!t.value),i=ue(()=>!!t.value),o=ue(()=>{var b;return((b=e.value)==null?void 0:b.role)==="chef"}),a=ue(()=>{var b;return((b=e.value)==null?void 0:b.role)==="disponent"}),l=ue(()=>{var b;return((b=e.value)==null?void 0:b.role)==="mitarbeiter"}),c=ue(()=>o.value||a.value),u=ue(()=>o.value||a.value),f=ue(()=>e.value?`${e.value.first_name} ${e.value.last_name}`:"");function h(b,I){t.value=b,n.value=I,localStorage.setItem("accessToken",b),localStorage.setItem("refreshToken",I)}function _(b){r.value=b,localStorage.setItem("orgSlug",b)}function A(){e.value=null,t.value=null,n.value=null,localStorage.removeItem("accessToken"),localStorage.removeItem("refreshToken")}async function E(b,I,k){const M=await $n.post("/auth/login",{email:b,password:I,org_slug:k});return h(M.data.accessToken,M.data.refreshToken),_(k),e.value=M.data.user,M.data}async function O(b){return(await $n.post("/auth/register",b)).data}async function R(){try{await $n.post("/auth/logout")}catch{}A()}async function x(){try{const b=await $n.get("/auth/me");e.value=b.data.user}catch{A()}}async function y(){if(!n.value)throw new Error("No refresh token");const b=await $n.post("/auth/refresh",{refreshToken:n.value});return t.value=b.data.accessToken,localStorage.setItem("accessToken",b.data.accessToken),b.data.accessToken}return{user:e,accessToken:t,refreshToken:n,orgSlug:r,isAuthenticated:s,hasStoredToken:i,isChef:o,isDisponent:a,isMitarbeiter:l,canManageUsers:c,canManageOrders:u,fullName:f,login:E,register:O,logout:R,fetchCurrentUser:x,refreshAccessToken:y,setOrgSlug:_}}),Ud={class:"fixed inset-0 bg-gradient-to-br from-purple-600 to-indigo-700 flex flex-col items-center justify-center z-50"},jd={key:0,class:"text-center"},Vd=["disabled"],Hd={key:0,class:"animate-spin"},Wd={key:1},Bd={key:1,class:"text-center"},$d={class:"flex space-x-3 mb-8"},zd={key:0,class:"text-red-300 text-sm mb-4"},Kd={class:"grid grid-cols-3 gap-4 max-w-xs"},Gd=["onClick"],qd={key:1,class:"w-16 h-16"},Yd=En({__name:"LockScreen",emits:["unlocked"],setup(e,{emit:t}){const n=t;ki();const r=Pe(null),s=Pe(""),i=Pe(!1),o=Pe(["","","","","",""]),a=Pe(0);vr(()=>{r.value=localStorage.getItem("lockMethod"),r.value==="biometric"&&l()});async function l(){i.value=!0,s.value="";try{if(!window.PublicKeyCredential)throw new Error("Biometrie nicht verfügbar");const A=localStorage.getItem("biometricCredentialId");if(!A)throw new Error("Keine biometrischen Daten gespeichert");await navigator.credentials.get({publicKey:{challenge:new Uint8Array(32),timeout:6e4,userVerification:"required",allowCredentials:[{id:Uint8Array.from(atob(A),O=>O.charCodeAt(0)),type:"public-key",transports:["internal"]}]}})&&n("unlocked")}catch(A){console.error("Biometric auth failed:",A),s.value="Biometrie fehlgeschlagen. Bitte PIN verwenden.",r.value="pin"}i.value=!1}function c(A){a.value<6&&(o.value[a.value]=A,a.value++,a.value===6&&h())}function u(){a.value>0&&(a.value--,o.value[a.value]=""),s.value=""}function f(){o.value=["","","","","",""],a.value=0,s.value=""}async function h(){const A=o.value.join(""),E=localStorage.getItem("appPin");A===E?n("unlocked"):(s.value="Falscher PIN",setTimeout(f,500))}function _(){r.value="pin",s.value=""}return(A,E)=>(Ze(),ut("div",Ud,[E[2]||(E[2]=rt("div",{class:"text-6xl mb-4"},"🔐",-1)),E[3]||(E[3]=rt("h1",{class:"text-2xl font-bold text-white mb-2"},"SeCu",-1)),E[4]||(E[4]=rt("p",{class:"text-white/70 mb-8"},"Bitte entsperren",-1)),r.value==="biometric"&&!s.value?(Ze(),ut("div",jd,[rt("button",{onClick:l,disabled:i.value,class:"w-20 h-20 bg-white/20 rounded-full flex items-center justify-center text-4xl mb-4 hover:bg-white/30 transition"},[i.value?(Ze(),ut("span",Hd,"⏳")):(Ze(),ut("span",Wd,"👆"))],8,Vd),E[1]||(E[1]=rt("p",{class:"text-white/70 text-sm"},"Fingerabdruck oder Face ID",-1)),rt("button",{onClick:_,class:"mt-4 text-white/50 text-sm underline"}," Stattdessen PIN verwenden ")])):(Ze(),ut("div",Bd,[rt("div",$d,[(Ze(!0),ut(Ge,null,Qi(o.value,(O,R)=>(Ze(),ut("div",{key:R,class:Qr(["w-4 h-4 rounded-full transition-all",O?"bg-white scale-110":"bg-white/30",s.value?"animate-shake bg-red-400":""])},null,2))),128))]),s.value?(Ze(),ut("p",zd,Fs(s.value),1)):Wl("",!0),rt("div",Kd,[(Ze(),ut(Ge,null,Qi([1,2,3,4,5,6,7,8,9],O=>rt("button",{key:O,onClick:R=>c(String(O)),class:"w-16 h-16 bg-white/20 rounded-full text-white text-2xl font-semibold hover:bg-white/30 transition"},Fs(O),9,Gd)),64)),r.value==="biometric"||A.localStorage.getItem("biometricCredentialId")?(Ze(),ut("button",{key:0,onClick:l,class:"w-16 h-16 bg-white/20 rounded-full text-white text-2xl hover:bg-white/30 transition"}," 👆 ")):(Ze(),ut("div",qd)),rt("button",{onClick:E[0]||(E[0]=O=>c("0")),class:"w-16 h-16 bg-white/20 rounded-full text-white text-2xl font-semibold hover:bg-white/30 transition"}," 0 "),rt("button",{onClick:u,class:"w-16 h-16 bg-white/10 rounded-full text-white text-xl hover:bg-white/20 transition"}," ⌫ ")])]))]))}}),Xd=(e,t)=>{const n=e.__vccOpts||e;for(const[r,s]of t)n[r]=s;return n},Jd=Xd(Yd,[["__scopeId","data-v-5cf90e48"]]),Ro=3e4,Qd=En({__name:"App",setup(e){const t=ki(),n=Pe(!1),r=Pe(Date.now()),s=ue(()=>localStorage.getItem("lockMethod")&&localStorage.getItem("lockMethod")!=="none"&&t.isAuthenticated);vr(async()=>{if(t.hasStoredToken&&await t.fetchCurrentUser(),s.value){const l=localStorage.getItem("lastUnlockTime"),c=Date.now();(!l||c-parseInt(l)>Ro)&&(n.value=!0)}document.addEventListener("visibilitychange",o),document.addEventListener("touchstart",i),document.addEventListener("click",i),document.addEventListener("keydown",i)}),is(()=>{document.removeEventListener("visibilitychange",o),document.removeEventListener("touchstart",i),document.removeEventListener("click",i),document.removeEventListener("keydown",i)});function i(){r.value=Date.now()}function o(){if(document.visibilityState==="hidden")localStorage.setItem("backgroundTime",String(Date.now()));else if(document.visibilityState==="visible"&&s.value){const l=localStorage.getItem("backgroundTime"),c=Date.now();l&&c-parseInt(l)>Ro&&(n.value=!0)}}function a(){n.value=!1,localStorage.setItem("lastUnlockTime",String(Date.now()))}return(l,c)=>{const u=of("router-view");return Ze(),ut(Ge,null,[n.value&&s.value?(Ze(),Vl(Jd,{key:0,onUnlocked:a})):Wl("",!0),Vu(Ve(u,null,null,512),[[od,!n.value||!s.value]])],64)}}}),Zd="modulepreload",em=function(e){return"/app/"+e},Do={},Ee=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));s=Promise.allSettled(n.map(l=>{if(l=em(l),l in Do)return;Do[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const f=document.createElement("link");if(f.rel=c?"stylesheet":Zd,c||(f.as="script"),f.crossOrigin="",f.href=l,a&&f.setAttribute("nonce",a),document.head.appendChild(f),c)return new Promise((h,_)=>{f.addEventListener("load",h),f.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${l}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return t().catch(i)})};/*! + * vue-router v4.6.4 + * (c) 2025 Eduardo San Martin Morote + * @license MIT + */const Nn=typeof document<"u";function Zl(e){return typeof e=="object"||"displayName"in e||"props"in e||"__vccOpts"in e}function tm(e){return e.__esModule||e[Symbol.toStringTag]==="Module"||e.default&&Zl(e.default)}const fe=Object.assign;function Cs(e,t){const n={};for(const r in t){const s=t[r];n[r]=vt(s)?s.map(e):e(s)}return n}const nr=()=>{},vt=Array.isArray;function Mo(e,t){const n={};for(const r in e)n[r]=r in t?t[r]:e[r];return n}const ec=/#/g,nm=/&/g,rm=/\//g,sm=/=/g,im=/\?/g,tc=/\+/g,om=/%5B/g,am=/%5D/g,nc=/%5E/g,lm=/%60/g,rc=/%7B/g,cm=/%7C/g,sc=/%7D/g,um=/%20/g;function Ci(e){return e==null?"":encodeURI(""+e).replace(cm,"|").replace(om,"[").replace(am,"]")}function fm(e){return Ci(e).replace(rc,"{").replace(sc,"}").replace(nc,"^")}function Js(e){return Ci(e).replace(tc,"%2B").replace(um,"+").replace(ec,"%23").replace(nm,"%26").replace(lm,"`").replace(rc,"{").replace(sc,"}").replace(nc,"^")}function dm(e){return Js(e).replace(sm,"%3D")}function mm(e){return Ci(e).replace(ec,"%23").replace(im,"%3F")}function hm(e){return mm(e).replace(rm,"%2F")}function fr(e){if(e==null)return null;try{return decodeURIComponent(""+e)}catch{}return""+e}const pm=/\/$/,gm=e=>e.replace(pm,"");function Ps(e,t,n="/"){let r,s={},i="",o="";const a=t.indexOf("#");let l=t.indexOf("?");return l=a>=0&&l>a?-1:l,l>=0&&(r=t.slice(0,l),i=t.slice(l,a>0?a:t.length),s=e(i.slice(1))),a>=0&&(r=r||t.slice(0,a),o=t.slice(a,t.length)),r=ym(r??t,n),{fullPath:r+i+o,path:r,query:s,hash:fr(o)}}function _m(e,t){const n=t.query?e(t.query):"";return t.path+(n&&"?")+n+(t.hash||"")}function xo(e,t){return!t||!e.toLowerCase().startsWith(t.toLowerCase())?e:e.slice(t.length)||"/"}function vm(e,t,n){const r=t.matched.length-1,s=n.matched.length-1;return r>-1&&r===s&&Rn(t.matched[r],n.matched[s])&&ic(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}function Rn(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function ic(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var n in e)if(!bm(e[n],t[n]))return!1;return!0}function bm(e,t){return vt(e)?Fo(e,t):vt(t)?Fo(t,e):(e==null?void 0:e.valueOf())===(t==null?void 0:t.valueOf())}function Fo(e,t){return vt(t)?e.length===t.length&&e.every((n,r)=>n===t[r]):e.length===1&&e[0]===t}function ym(e,t){if(e.startsWith("/"))return e;if(!e)return t;const n=t.split("/"),r=e.split("/"),s=r[r.length-1];(s===".."||s===".")&&r.push("");let i=n.length-1,o,a;for(o=0;o1&&i--;else break;return n.slice(0,i).join("/")+"/"+r.slice(o).join("/")}const Gt={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0};let Qs=function(e){return e.pop="pop",e.push="push",e}({}),Os=function(e){return e.back="back",e.forward="forward",e.unknown="",e}({});function Em(e){if(!e)if(Nn){const t=document.querySelector("base");e=t&&t.getAttribute("href")||"/",e=e.replace(/^\w+:\/\/[^\/]+/,"")}else e="/";return e[0]!=="/"&&e[0]!=="#"&&(e="/"+e),gm(e)}const Tm=/^[^#]+#/;function wm(e,t){return e.replace(Tm,"#")+t}function Am(e,t){const n=document.documentElement.getBoundingClientRect(),r=e.getBoundingClientRect();return{behavior:t.behavior,left:r.left-n.left-(t.left||0),top:r.top-n.top-(t.top||0)}}const cs=()=>({left:window.scrollX,top:window.scrollY});function Nm(e){let t;if("el"in e){const n=e.el,r=typeof n=="string"&&n.startsWith("#"),s=typeof n=="string"?r?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!s)return;t=Am(s,e)}else t=e;"scrollBehavior"in document.documentElement.style?window.scrollTo(t):window.scrollTo(t.left!=null?t.left:window.scrollX,t.top!=null?t.top:window.scrollY)}function Uo(e,t){return(history.state?history.state.position-t:-1)+e}const Zs=new Map;function Sm(e,t){Zs.set(e,t)}function Im(e){const t=Zs.get(e);return Zs.delete(e),t}function km(e){return typeof e=="string"||e&&typeof e=="object"}function oc(e){return typeof e=="string"||typeof e=="symbol"}let Ne=function(e){return e[e.MATCHER_NOT_FOUND=1]="MATCHER_NOT_FOUND",e[e.NAVIGATION_GUARD_REDIRECT=2]="NAVIGATION_GUARD_REDIRECT",e[e.NAVIGATION_ABORTED=4]="NAVIGATION_ABORTED",e[e.NAVIGATION_CANCELLED=8]="NAVIGATION_CANCELLED",e[e.NAVIGATION_DUPLICATED=16]="NAVIGATION_DUPLICATED",e}({});const ac=Symbol("");Ne.MATCHER_NOT_FOUND+"",Ne.NAVIGATION_GUARD_REDIRECT+"",Ne.NAVIGATION_ABORTED+"",Ne.NAVIGATION_CANCELLED+"",Ne.NAVIGATION_DUPLICATED+"";function Dn(e,t){return fe(new Error,{type:e,[ac]:!0},t)}function Lt(e,t){return e instanceof Error&&ac in e&&(t==null||!!(e.type&t))}const Cm=["params","query","hash"];function Pm(e){if(typeof e=="string")return e;if(e.path!=null)return e.path;const t={};for(const n of Cm)n in e&&(t[n]=e[n]);return JSON.stringify(t,null,2)}function Om(e){const t={};if(e===""||e==="?")return t;const n=(e[0]==="?"?e.slice(1):e).split("&");for(let r=0;rs&&Js(s)):[r&&Js(r)]).forEach(s=>{s!==void 0&&(t+=(t.length?"&":"")+n,s!=null&&(t+="="+s))})}return t}function Lm(e){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=vt(r)?r.map(s=>s==null?null:""+s):r==null?r:""+r)}return t}const Rm=Symbol(""),Vo=Symbol(""),us=Symbol(""),Pi=Symbol(""),ei=Symbol("");function zn(){let e=[];function t(r){return e.push(r),()=>{const s=e.indexOf(r);s>-1&&e.splice(s,1)}}function n(){e=[]}return{add:t,list:()=>e.slice(),reset:n}}function Jt(e,t,n,r,s,i=o=>o()){const o=r&&(r.enterCallbacks[s]=r.enterCallbacks[s]||[]);return()=>new Promise((a,l)=>{const c=h=>{h===!1?l(Dn(Ne.NAVIGATION_ABORTED,{from:n,to:t})):h instanceof Error?l(h):km(h)?l(Dn(Ne.NAVIGATION_GUARD_REDIRECT,{from:t,to:h})):(o&&r.enterCallbacks[s]===o&&typeof h=="function"&&o.push(h),a())},u=i(()=>e.call(r&&r.instances[s],t,n,c));let f=Promise.resolve(u);e.length<3&&(f=f.then(c)),f.catch(h=>l(h))})}function Ls(e,t,n,r,s=i=>i()){const i=[];for(const o of e)for(const a in o.components){let l=o.components[a];if(!(t!=="beforeRouteEnter"&&!o.instances[a]))if(Zl(l)){const c=(l.__vccOpts||l)[t];c&&i.push(Jt(c,n,r,o,a,s))}else{let c=l();i.push(()=>c.then(u=>{if(!u)throw new Error(`Couldn't resolve component "${a}" at "${o.path}"`);const f=tm(u)?u.default:u;o.mods[a]=u,o.components[a]=f;const h=(f.__vccOpts||f)[t];return h&&Jt(h,n,r,o,a,s)()}))}}return i}function Dm(e,t){const n=[],r=[],s=[],i=Math.max(t.matched.length,e.matched.length);for(let o=0;oRn(c,a))?r.push(a):n.push(a));const l=e.matched[o];l&&(t.matched.find(c=>Rn(c,l))||s.push(l))}return[n,r,s]}/*! + * vue-router v4.6.4 + * (c) 2025 Eduardo San Martin Morote + * @license MIT + */let Mm=()=>location.protocol+"//"+location.host;function lc(e,t){const{pathname:n,search:r,hash:s}=t,i=e.indexOf("#");if(i>-1){let o=s.includes(e.slice(i))?e.slice(i).length:1,a=s.slice(o);return a[0]!=="/"&&(a="/"+a),xo(a,"")}return xo(n,e)+r+s}function xm(e,t,n,r){let s=[],i=[],o=null;const a=({state:h})=>{const _=lc(e,location),A=n.value,E=t.value;let O=0;if(h){if(n.value=_,t.value=h,o&&o===A){o=null;return}O=E?h.position-E.position:0}else r(_);s.forEach(R=>{R(n.value,A,{delta:O,type:Qs.pop,direction:O?O>0?Os.forward:Os.back:Os.unknown})})};function l(){o=n.value}function c(h){s.push(h);const _=()=>{const A=s.indexOf(h);A>-1&&s.splice(A,1)};return i.push(_),_}function u(){if(document.visibilityState==="hidden"){const{history:h}=window;if(!h.state)return;h.replaceState(fe({},h.state,{scroll:cs()}),"")}}function f(){for(const h of i)h();i=[],window.removeEventListener("popstate",a),window.removeEventListener("pagehide",u),document.removeEventListener("visibilitychange",u)}return window.addEventListener("popstate",a),window.addEventListener("pagehide",u),document.addEventListener("visibilitychange",u),{pauseListeners:l,listen:c,destroy:f}}function Ho(e,t,n,r=!1,s=!1){return{back:e,current:t,forward:n,replaced:r,position:window.history.length,scroll:s?cs():null}}function Fm(e){const{history:t,location:n}=window,r={value:lc(e,n)},s={value:t.state};s.value||i(r.value,{back:null,current:r.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0);function i(l,c,u){const f=e.indexOf("#"),h=f>-1?(n.host&&document.querySelector("base")?e:e.slice(f))+l:Mm()+e+l;try{t[u?"replaceState":"pushState"](c,"",h),s.value=c}catch(_){console.error(_),n[u?"replace":"assign"](h)}}function o(l,c){i(l,fe({},t.state,Ho(s.value.back,l,s.value.forward,!0),c,{position:s.value.position}),!0),r.value=l}function a(l,c){const u=fe({},s.value,t.state,{forward:l,scroll:cs()});i(u.current,u,!0),i(l,fe({},Ho(r.value,l,null),{position:u.position+1},c),!1),r.value=l}return{location:r,state:s,push:a,replace:o}}function Um(e){e=Em(e);const t=Fm(e),n=xm(e,t.state,t.location,t.replace);function r(i,o=!0){o||n.pauseListeners(),history.go(i)}const s=fe({location:"",base:e,go:r,createHref:wm.bind(null,e)},t,n);return Object.defineProperty(s,"location",{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(s,"state",{enumerable:!0,get:()=>t.state.value}),s}let gn=function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.Group=2]="Group",e}({});var Ce=function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.ParamRegExp=2]="ParamRegExp",e[e.ParamRegExpEnd=3]="ParamRegExpEnd",e[e.EscapeNext=4]="EscapeNext",e}(Ce||{});const jm={type:gn.Static,value:""},Vm=/[a-zA-Z0-9_]/;function Hm(e){if(!e)return[[]];if(e==="/")return[[jm]];if(!e.startsWith("/"))throw new Error(`Invalid path "${e}"`);function t(_){throw new Error(`ERR (${n})/"${c}": ${_}`)}let n=Ce.Static,r=n;const s=[];let i;function o(){i&&s.push(i),i=[]}let a=0,l,c="",u="";function f(){c&&(n===Ce.Static?i.push({type:gn.Static,value:c}):n===Ce.Param||n===Ce.ParamRegExp||n===Ce.ParamRegExpEnd?(i.length>1&&(l==="*"||l==="+")&&t(`A repeatable param (${c}) must be alone in its segment. eg: '/:ids+.`),i.push({type:gn.Param,value:c,regexp:u,repeatable:l==="*"||l==="+",optional:l==="*"||l==="?"})):t("Invalid state to consume buffer"),c="")}function h(){c+=l}for(;at.length?t.length===1&&t[0]===ze.Static+ze.Segment?1:-1:0}function cc(e,t){let n=0;const r=e.score,s=t.score;for(;n0&&t[t.length-1]<0}const Km={strict:!1,end:!0,sensitive:!1};function Gm(e,t,n){const r=$m(Hm(e.path),n),s=fe(r,{record:e,parent:t,children:[],alias:[]});return t&&!s.record.aliasOf==!t.record.aliasOf&&t.children.push(s),s}function qm(e,t){const n=[],r=new Map;t=Mo(Km,t);function s(f){return r.get(f)}function i(f,h,_){const A=!_,E=zo(f);E.aliasOf=_&&_.record;const O=Mo(t,f),R=[E];if("alias"in f){const b=typeof f.alias=="string"?[f.alias]:f.alias;for(const I of b)R.push(zo(fe({},E,{components:_?_.record.components:E.components,path:I,aliasOf:_?_.record:E})))}let x,y;for(const b of R){const{path:I}=b;if(h&&I[0]!=="/"){const k=h.record.path,M=k[k.length-1]==="/"?"":"/";b.path=h.record.path+(I&&M+I)}if(x=Gm(b,h,O),_?_.alias.push(x):(y=y||x,y!==x&&y.alias.push(x),A&&f.name&&!Ko(x)&&o(f.name)),uc(x)&&l(x),E.children){const k=E.children;for(let M=0;M{o(y)}:nr}function o(f){if(oc(f)){const h=r.get(f);h&&(r.delete(f),n.splice(n.indexOf(h),1),h.children.forEach(o),h.alias.forEach(o))}else{const h=n.indexOf(f);h>-1&&(n.splice(h,1),f.record.name&&r.delete(f.record.name),f.children.forEach(o),f.alias.forEach(o))}}function a(){return n}function l(f){const h=Jm(f,n);n.splice(h,0,f),f.record.name&&!Ko(f)&&r.set(f.record.name,f)}function c(f,h){let _,A={},E,O;if("name"in f&&f.name){if(_=r.get(f.name),!_)throw Dn(Ne.MATCHER_NOT_FOUND,{location:f});O=_.record.name,A=fe($o(h.params,_.keys.filter(y=>!y.optional).concat(_.parent?_.parent.keys.filter(y=>y.optional):[]).map(y=>y.name)),f.params&&$o(f.params,_.keys.map(y=>y.name))),E=_.stringify(A)}else if(f.path!=null)E=f.path,_=n.find(y=>y.re.test(E)),_&&(A=_.parse(E),O=_.record.name);else{if(_=h.name?r.get(h.name):n.find(y=>y.re.test(h.path)),!_)throw Dn(Ne.MATCHER_NOT_FOUND,{location:f,currentLocation:h});O=_.record.name,A=fe({},h.params,f.params),E=_.stringify(A)}const R=[];let x=_;for(;x;)R.unshift(x.record),x=x.parent;return{name:O,path:E,params:A,matched:R,meta:Xm(R)}}e.forEach(f=>i(f));function u(){n.length=0,r.clear()}return{addRoute:i,resolve:c,removeRoute:o,clearRoutes:u,getRoutes:a,getRecordMatcher:s}}function $o(e,t){const n={};for(const r of t)r in e&&(n[r]=e[r]);return n}function zo(e){const t={path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:e.aliasOf,beforeEnter:e.beforeEnter,props:Ym(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in e?e.components||null:e.component&&{default:e.component}};return Object.defineProperty(t,"mods",{value:{}}),t}function Ym(e){const t={},n=e.props||!1;if("component"in e)t.default=n;else for(const r in e.components)t[r]=typeof n=="object"?n[r]:n;return t}function Ko(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function Xm(e){return e.reduce((t,n)=>fe(t,n.meta),{})}function Jm(e,t){let n=0,r=t.length;for(;n!==r;){const i=n+r>>1;cc(e,t[i])<0?r=i:n=i+1}const s=Qm(e);return s&&(r=t.lastIndexOf(s,r-1)),r}function Qm(e){let t=e;for(;t=t.parent;)if(uc(t)&&cc(e,t)===0)return t}function uc({record:e}){return!!(e.name||e.components&&Object.keys(e.components).length||e.redirect)}function Go(e){const t=at(us),n=at(Pi),r=ue(()=>{const l=vn(e.to);return t.resolve(l)}),s=ue(()=>{const{matched:l}=r.value,{length:c}=l,u=l[c-1],f=n.matched;if(!u||!f.length)return-1;const h=f.findIndex(Rn.bind(null,u));if(h>-1)return h;const _=qo(l[c-2]);return c>1&&qo(u)===_&&f[f.length-1].path!==_?f.findIndex(Rn.bind(null,l[c-2])):h}),i=ue(()=>s.value>-1&&rh(n.params,r.value.params)),o=ue(()=>s.value>-1&&s.value===n.matched.length-1&&ic(n.params,r.value.params));function a(l={}){if(nh(l)){const c=t[vn(e.replace)?"replace":"push"](vn(e.to)).catch(nr);return e.viewTransition&&typeof document<"u"&&"startViewTransition"in document&&document.startViewTransition(()=>c),c}return Promise.resolve()}return{route:r,href:ue(()=>r.value.href),isActive:i,isExactActive:o,navigate:a}}function Zm(e){return e.length===1?e[0]:e}const eh=En({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"},viewTransition:Boolean},useLink:Go,setup(e,{slots:t}){const n=gr(Go(e)),{options:r}=at(us),s=ue(()=>({[Yo(e.activeClass,r.linkActiveClass,"router-link-active")]:n.isActive,[Yo(e.exactActiveClass,r.linkExactActiveClass,"router-link-exact-active")]:n.isExactActive}));return()=>{const i=t.default&&Zm(t.default(n));return e.custom?i:Er("a",{"aria-current":n.isExactActive?e.ariaCurrentValue:null,href:n.href,onClick:n.navigate,class:s.value},i)}}}),th=eh;function nh(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!==void 0&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function rh(e,t){for(const n in t){const r=t[n],s=e[n];if(typeof r=="string"){if(r!==s)return!1}else if(!vt(s)||s.length!==r.length||r.some((i,o)=>i.valueOf()!==s[o].valueOf()))return!1}return!0}function qo(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}const Yo=(e,t,n)=>e??t??n,sh=En({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(e,{attrs:t,slots:n}){const r=at(ei),s=ue(()=>e.route||r.value),i=at(Vo,0),o=ue(()=>{let c=vn(i);const{matched:u}=s.value;let f;for(;(f=u[c])&&!f.components;)c++;return c}),a=ue(()=>s.value.matched[o.value]);kr(Vo,ue(()=>o.value+1)),kr(Rm,a),kr(ei,s);const l=Pe();return Zt(()=>[l.value,a.value,e.name],([c,u,f],[h,_,A])=>{u&&(u.instances[f]=c,_&&_!==u&&c&&c===h&&(u.leaveGuards.size||(u.leaveGuards=_.leaveGuards),u.updateGuards.size||(u.updateGuards=_.updateGuards))),c&&u&&(!_||!Rn(u,_)||!h)&&(u.enterCallbacks[f]||[]).forEach(E=>E(c))},{flush:"post"}),()=>{const c=s.value,u=e.name,f=a.value,h=f&&f.components[u];if(!h)return Xo(n.default,{Component:h,route:c});const _=f.props[u],A=_?_===!0?c.params:typeof _=="function"?_(c):_:null,O=Er(h,fe({},A,t,{onVnodeUnmounted:R=>{R.component.isUnmounted&&(f.instances[u]=null)},ref:l}));return Xo(n.default,{Component:O,route:c})||O}}});function Xo(e,t){if(!e)return null;const n=e(t);return n.length===1?n[0]:n}const ih=sh;function oh(e){const t=qm(e.routes,e),n=e.parseQuery||Om,r=e.stringifyQuery||jo,s=e.history,i=zn(),o=zn(),a=zn(),l=wi(Gt);let c=Gt;Nn&&e.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const u=Cs.bind(null,D=>""+D),f=Cs.bind(null,hm),h=Cs.bind(null,fr);function _(D,K){let $,q;return oc(D)?($=t.getRecordMatcher(D),q=K):q=D,t.addRoute(q,$)}function A(D){const K=t.getRecordMatcher(D);K&&t.removeRoute(K)}function E(){return t.getRoutes().map(D=>D.record)}function O(D){return!!t.getRecordMatcher(D)}function R(D,K){if(K=fe({},K||l.value),typeof D=="string"){const g=Ps(n,D,K.path),N=t.resolve({path:g.path},K),F=s.createHref(g.fullPath);return fe(g,N,{params:h(N.params),hash:fr(g.hash),redirectedFrom:void 0,href:F})}let $;if(D.path!=null)$=fe({},D,{path:Ps(n,D.path,K.path).path});else{const g=fe({},D.params);for(const N in g)g[N]==null&&delete g[N];$=fe({},D,{params:f(g)}),K.params=f(K.params)}const q=t.resolve($,K),re=D.hash||"";q.params=u(h(q.params));const p=_m(r,fe({},D,{hash:fm(re),path:q.path})),v=s.createHref(p);return fe({fullPath:p,hash:re,query:r===jo?Lm(D.query):D.query||{}},q,{redirectedFrom:void 0,href:v})}function x(D){return typeof D=="string"?Ps(n,D,l.value.path):fe({},D)}function y(D,K){if(c!==D)return Dn(Ne.NAVIGATION_CANCELLED,{from:K,to:D})}function b(D){return M(D)}function I(D){return b(fe(x(D),{replace:!0}))}function k(D,K){const $=D.matched[D.matched.length-1];if($&&$.redirect){const{redirect:q}=$;let re=typeof q=="function"?q(D,K):q;return typeof re=="string"&&(re=re.includes("?")||re.includes("#")?re=x(re):{path:re},re.params={}),fe({query:D.query,hash:D.hash,params:re.path!=null?{}:D.params},re)}}function M(D,K){const $=c=R(D),q=l.value,re=D.state,p=D.force,v=D.replace===!0,g=k($,q);if(g)return M(fe(x(g),{state:typeof g=="object"?fe({},re,g.state):re,force:p,replace:v}),K||$);const N=$;N.redirectedFrom=K;let F;return!p&&vm(r,q,$)&&(F=Dn(Ne.NAVIGATION_DUPLICATED,{to:N,from:q}),we(q,q,!0,!1)),(F?Promise.resolve(F):G(N,q)).catch(L=>Lt(L)?Lt(L,Ne.NAVIGATION_GUARD_REDIRECT)?L:Xe(L):oe(L,N,q)).then(L=>{if(L){if(Lt(L,Ne.NAVIGATION_GUARD_REDIRECT))return M(fe({replace:v},x(L.to),{state:typeof L.to=="object"?fe({},re,L.to.state):re,force:p}),K||N)}else L=U(N,q,!0,v,re);return Z(N,q,L),L})}function j(D,K){const $=y(D,K);return $?Promise.reject($):Promise.resolve()}function S(D){const K=et.values().next().value;return K&&typeof K.runWithContext=="function"?K.runWithContext(D):D()}function G(D,K){let $;const[q,re,p]=Dm(D,K);$=Ls(q.reverse(),"beforeRouteLeave",D,K);for(const g of q)g.leaveGuards.forEach(N=>{$.push(Jt(N,D,K))});const v=j.bind(null,D,K);return $.push(v),Re($).then(()=>{$=[];for(const g of i.list())$.push(Jt(g,D,K));return $.push(v),Re($)}).then(()=>{$=Ls(re,"beforeRouteUpdate",D,K);for(const g of re)g.updateGuards.forEach(N=>{$.push(Jt(N,D,K))});return $.push(v),Re($)}).then(()=>{$=[];for(const g of p)if(g.beforeEnter)if(vt(g.beforeEnter))for(const N of g.beforeEnter)$.push(Jt(N,D,K));else $.push(Jt(g.beforeEnter,D,K));return $.push(v),Re($)}).then(()=>(D.matched.forEach(g=>g.enterCallbacks={}),$=Ls(p,"beforeRouteEnter",D,K,S),$.push(v),Re($))).then(()=>{$=[];for(const g of o.list())$.push(Jt(g,D,K));return $.push(v),Re($)}).catch(g=>Lt(g,Ne.NAVIGATION_CANCELLED)?g:Promise.reject(g))}function Z(D,K,$){a.list().forEach(q=>S(()=>q(D,K,$)))}function U(D,K,$,q,re){const p=y(D,K);if(p)return p;const v=K===Gt,g=Nn?history.state:{};$&&(q||v?s.replace(D.fullPath,fe({scroll:v&&g&&g.scroll},re)):s.push(D.fullPath,re)),l.value=D,we(D,K,$,v),Xe()}let J;function ge(){J||(J=s.listen((D,K,$)=>{if(!tt.listening)return;const q=R(D),re=k(q,tt.currentRoute.value);if(re){M(fe(re,{replace:!0,force:!0}),q).catch(nr);return}c=q;const p=l.value;Nn&&Sm(Uo(p.fullPath,$.delta),cs()),G(q,p).catch(v=>Lt(v,Ne.NAVIGATION_ABORTED|Ne.NAVIGATION_CANCELLED)?v:Lt(v,Ne.NAVIGATION_GUARD_REDIRECT)?(M(fe(x(v.to),{force:!0}),q).then(g=>{Lt(g,Ne.NAVIGATION_ABORTED|Ne.NAVIGATION_DUPLICATED)&&!$.delta&&$.type===Qs.pop&&s.go(-1,!1)}).catch(nr),Promise.reject()):($.delta&&s.go(-$.delta,!1),oe(v,q,p))).then(v=>{v=v||U(q,p,!1),v&&($.delta&&!Lt(v,Ne.NAVIGATION_CANCELLED)?s.go(-$.delta,!1):$.type===Qs.pop&&Lt(v,Ne.NAVIGATION_ABORTED|Ne.NAVIGATION_DUPLICATED)&&s.go(-1,!1)),Z(q,p,v)}).catch(nr)}))}let Se=zn(),se=zn(),ee;function oe(D,K,$){Xe(D);const q=se.list();return q.length?q.forEach(re=>re(D,K,$)):console.error(D),Promise.reject(D)}function He(){return ee&&l.value!==Gt?Promise.resolve():new Promise((D,K)=>{Se.add([D,K])})}function Xe(D){return ee||(ee=!D,ge(),Se.list().forEach(([K,$])=>D?$(D):K()),Se.reset()),D}function we(D,K,$,q){const{scrollBehavior:re}=e;if(!Nn||!re)return Promise.resolve();const p=!$&&Im(Uo(D.fullPath,0))||(q||!$)&&history.state&&history.state.scroll||null;return ns().then(()=>re(D,K,p)).then(v=>v&&Nm(v)).catch(v=>oe(v,D,K))}const Ae=D=>s.go(D);let lt;const et=new Set,tt={currentRoute:l,listening:!0,addRoute:_,removeRoute:A,clearRoutes:t.clearRoutes,hasRoute:O,getRoutes:E,resolve:R,options:e,push:b,replace:I,go:Ae,back:()=>Ae(-1),forward:()=>Ae(1),beforeEach:i.add,beforeResolve:o.add,afterEach:a.add,onError:se.add,isReady:He,install(D){D.component("RouterLink",th),D.component("RouterView",ih),D.config.globalProperties.$router=tt,Object.defineProperty(D.config.globalProperties,"$route",{enumerable:!0,get:()=>vn(l)}),Nn&&!lt&&l.value===Gt&&(lt=!0,b(s.location).catch(q=>{}));const K={};for(const q in Gt)Object.defineProperty(K,q,{get:()=>l.value[q],enumerable:!0});D.provide(us,tt),D.provide(Pi,nl(K)),D.provide(ei,l);const $=D.unmount;et.add(D),D.unmount=function(){et.delete(D),et.size<1&&(c=Gt,J&&J(),J=null,l.value=Gt,lt=!1,ee=!1),$()}}};function Re(D){return D.reduce((K,$)=>K.then(()=>S($)),Promise.resolve())}return tt}function Cg(){return at(us)}function Pg(e){return at(Pi)}const fc=oh({history:Um("/app/"),routes:[{path:"/login",name:"login",component:()=>Ee(()=>import("./LoginView-BF8xkNDz.js"),[]),meta:{guest:!0}},{path:"/register",name:"register-org",component:()=>Ee(()=>import("./RegisterOrgView-CL8_vGlU.js"),[]),meta:{guest:!0}},{path:"/admin",name:"admin",component:()=>Ee(()=>import("./AdminDashboardView-DT-HY3B4.js"),[]),meta:{requiresAuth:!0}},{path:"/",component:()=>Ee(()=>import("./AppLayout-M3P9X3hb.js"),[]),meta:{requiresAuth:!0},children:[{path:"",name:"dashboard",component:()=>Ee(()=>import("./DashboardView-Thst2KBn.js"),[])},{path:"orders",name:"orders",component:()=>Ee(()=>import("./OrdersView-D55YFtzq.js"),[])},{path:"orders/:id",name:"order-detail",component:()=>Ee(()=>import("./OrderDetailView-BuCP5BM8.js"),[])},{path:"users",name:"users",component:()=>Ee(()=>import("./UsersView-Bv4Sb2KQ.js"),[]),meta:{roles:["chef","disponent"]}},{path:"availability",name:"availability",component:()=>Ee(()=>import("./AvailabilityView-3FfkRQ5Z.js"),[])},{path:"timesheets",name:"timesheets",component:()=>Ee(()=>import("./TimesheetsView-DmVkzXLM.js"),[])},{path:"settings",name:"settings",component:()=>Ee(()=>import("./SettingsView-CIJivDOn.js"),[])},{path:"modules",name:"modules",component:()=>Ee(()=>import("./ModulesView-DdZR_ST7.js"),[]),meta:{roles:["chef"]}},{path:"partnerships",name:"partnerships",component:()=>Ee(()=>import("./PartnershipsView-CoZdHk1r.js"),[])},{path:"help",name:"help",component:()=>Ee(()=>import("./HelpView-D7FsGxgq.js"),[])},{path:"qualifications",name:"qualifications",component:()=>Ee(()=>import("./QualificationsView-D_sQmuBz.js"),[])},{path:"objects",name:"objects",component:()=>Ee(()=>import("./ObjectsView-bVbTDa5D.js"),[])},{path:"shifts",name:"shifts",component:()=>Ee(()=>import("./ShiftsView-Qxa8m19e.js"),[]),meta:{roles:["chef","disponent"]}},{path:"patrols",name:"patrols",component:()=>Ee(()=>import("./PatrolsView-B1roLsna.js"),[])},{path:"incidents",name:"incidents",component:()=>Ee(()=>import("./IncidentsView-D5JtybkA.js"),[])},{path:"vehicles",name:"vehicles",component:()=>Ee(()=>import("./VehiclesView-m5j3FcFM.js"),[]),meta:{roles:["chef","disponent"]}},{path:"documents",name:"documents",component:()=>Ee(()=>import("./DocumentsView-BzU6xyPy.js"),[])},{path:"customers",name:"customers",component:()=>Ee(()=>import("./CustomersView-Cp1mYV9m.js"),[]),meta:{roles:["chef","disponent"]}},{path:"billing",name:"billing",component:()=>Ee(()=>import("./BillingView-CuPKcrTa.js"),[]),meta:{roles:["chef"]}}]}]});fc.beforeEach(async(e,t,n)=>{var a;const r=ki();!r.isAuthenticated&&r.hasStoredToken&&await r.fetchCurrentUser();const s=e.matched.some(l=>l.meta.requiresAuth),i=e.matched.some(l=>l.meta.guest),o=e.meta.roles;s&&!r.isAuthenticated?n({name:"login",query:{redirect:e.fullPath}}):i&&r.isAuthenticated?n({name:"dashboard"}):o&&!o.includes(((a=r.user)==null?void 0:a.role)||"")?n({name:"dashboard"}):n()});/*! + * shared v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */function ah(e,t){typeof console<"u"&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}const Br=typeof window<"u",rn=(e,t=!1)=>t?Symbol.for(e):Symbol(e),lh=(e,t,n)=>ch({l:e,k:t,s:n}),ch=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),Ie=e=>typeof e=="number"&&isFinite(e),uh=e=>mc(e)==="[object Date]",nn=e=>mc(e)==="[object RegExp]",fs=e=>te(e)&&Object.keys(e).length===0,xe=Object.assign,fh=Object.create,he=(e=null)=>fh(e);let Jo;const jt=()=>Jo||(Jo=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:he());function Qo(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/").replace(/=/g,"=")}function Zo(e){return e.replace(/&(?![a-zA-Z0-9#]{2,6};)/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")}function dh(e){return e=e.replace(/(\w+)\s*=\s*"([^"]*)"/g,(r,s,i)=>`${s}="${Zo(i)}"`),e=e.replace(/(\w+)\s*=\s*'([^']*)'/g,(r,s,i)=>`${s}='${Zo(i)}'`),/\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi.test(e)&&(e=e.replace(/(\s+)(on)(\w+\s*=)/gi,"$1on$3")),[/(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi,/(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi].forEach(r=>{e=e.replace(r,"$1javascript:")}),e}const mh=Object.prototype.hasOwnProperty;function mt(e,t){return mh.call(e,t)}const be=Array.isArray,ve=e=>typeof e=="function",z=e=>typeof e=="string",ie=e=>typeof e=="boolean",ce=e=>e!==null&&typeof e=="object",hh=e=>ce(e)&&ve(e.then)&&ve(e.catch),dc=Object.prototype.toString,mc=e=>dc.call(e),te=e=>{if(!ce(e))return!1;const t=Object.getPrototypeOf(e);return t===null||t.constructor===Object},ph=e=>e==null?"":be(e)||te(e)&&e.toString===dc?JSON.stringify(e,null,2):String(e);function gh(e,t=""){return e.reduce((n,r,s)=>s===0?n+r:n+t+r,"")}function ds(e){let t=e;return()=>++t}const Nr=e=>!ce(e)||be(e);function Lr(e,t){if(Nr(e)||Nr(t))throw new Error("Invalid value");const n=[{src:e,des:t}];for(;n.length;){const{src:r,des:s}=n.pop();Object.keys(r).forEach(i=>{i!=="__proto__"&&(ce(r[i])&&!ce(s[i])&&(s[i]=Array.isArray(r[i])?[]:he()),Nr(s[i])||Nr(r[i])?s[i]=r[i]:n.push({src:r[i],des:s[i]}))})}}/*! + * message-compiler v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */function _h(e,t,n){return{line:e,column:t,offset:n}}function $r(e,t,n){return{start:e,end:t}}const vh=/\{([0-9a-zA-Z]+)\}/g;function hc(e,...t){return t.length===1&&bh(t[0])&&(t=t[0]),(!t||!t.hasOwnProperty)&&(t={}),e.replace(vh,(n,r)=>t.hasOwnProperty(r)?t[r]:"")}const pc=Object.assign,ea=e=>typeof e=="string",bh=e=>e!==null&&typeof e=="object";function gc(e,t=""){return e.reduce((n,r,s)=>s===0?n+r:n+t+r,"")}const Oi={USE_MODULO_SYNTAX:1,__EXTEND_POINT__:2},yh={[Oi.USE_MODULO_SYNTAX]:"Use modulo before '{{0}}'."};function Eh(e,t,...n){const r=hc(yh[e],...n||[]),s={message:String(r),code:e};return t&&(s.location=t),s}const Q={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16,__EXTEND_POINT__:17},Th={[Q.EXPECTED_TOKEN]:"Expected token: '{0}'",[Q.INVALID_TOKEN_IN_PLACEHOLDER]:"Invalid token in placeholder: '{0}'",[Q.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]:"Unterminated single quote in placeholder",[Q.UNKNOWN_ESCAPE_SEQUENCE]:"Unknown escape sequence: \\{0}",[Q.INVALID_UNICODE_ESCAPE_SEQUENCE]:"Invalid unicode escape sequence: {0}",[Q.UNBALANCED_CLOSING_BRACE]:"Unbalanced closing brace",[Q.UNTERMINATED_CLOSING_BRACE]:"Unterminated closing brace",[Q.EMPTY_PLACEHOLDER]:"Empty placeholder",[Q.NOT_ALLOW_NEST_PLACEHOLDER]:"Not allowed nest placeholder",[Q.INVALID_LINKED_FORMAT]:"Invalid linked format",[Q.MUST_HAVE_MESSAGES_IN_PLURAL]:"Plural must have messages",[Q.UNEXPECTED_EMPTY_LINKED_MODIFIER]:"Unexpected empty linked modifier",[Q.UNEXPECTED_EMPTY_LINKED_KEY]:"Unexpected empty linked key",[Q.UNEXPECTED_LEXICAL_ANALYSIS]:"Unexpected lexical analysis in token: '{0}'",[Q.UNHANDLED_CODEGEN_NODE_TYPE]:"unhandled codegen node type: '{0}'",[Q.UNHANDLED_MINIFIER_NODE_TYPE]:"unhandled mimifier node type: '{0}'"};function jn(e,t,n={}){const{domain:r,messages:s,args:i}=n,o=hc((s||Th)[e]||"",...i||[]),a=new SyntaxError(String(o));return a.code=e,t&&(a.location=t),a.domain=r,a}function wh(e){throw e}const Rt=" ",Ah="\r",$e=` +`,Nh="\u2028",Sh="\u2029";function Ih(e){const t=e;let n=0,r=1,s=1,i=0;const o=M=>t[M]===Ah&&t[M+1]===$e,a=M=>t[M]===$e,l=M=>t[M]===Sh,c=M=>t[M]===Nh,u=M=>o(M)||a(M)||l(M)||c(M),f=()=>n,h=()=>r,_=()=>s,A=()=>i,E=M=>o(M)||l(M)||c(M)?$e:t[M],O=()=>E(n),R=()=>E(n+i);function x(){return i=0,u(n)&&(r++,s=0),o(n)&&n++,n++,s++,t[n]}function y(){return o(n+i)&&i++,i++,t[n+i]}function b(){n=0,r=1,s=1,i=0}function I(M=0){i=M}function k(){const M=n+i;for(;M!==n;)x();i=0}return{index:f,line:h,column:_,peekOffset:A,charAt:E,currentChar:O,currentPeek:R,next:x,peek:y,reset:b,resetPeek:I,skipToPeek:k}}const qt=void 0,kh=".",ta="'",Ch="tokenizer";function Ph(e,t={}){const n=t.location!==!1,r=Ih(e),s=()=>r.index(),i=()=>_h(r.line(),r.column(),r.index()),o=i(),a=s(),l={currentType:14,offset:a,startLoc:o,endLoc:o,lastType:14,lastOffset:a,lastStartLoc:o,lastEndLoc:o,braceNest:0,inLinked:!1,text:""},c=()=>l,{onError:u}=t;function f(d,m,w,...C){const B=c();if(m.column+=w,m.offset+=w,u){const V=n?$r(B.startLoc,m):null,T=jn(d,V,{domain:Ch,args:C});u(T)}}function h(d,m,w){d.endLoc=i(),d.currentType=m;const C={type:m};return n&&(C.loc=$r(d.startLoc,d.endLoc)),w!=null&&(C.value=w),C}const _=d=>h(d,14);function A(d,m){return d.currentChar()===m?(d.next(),m):(f(Q.EXPECTED_TOKEN,i(),0,m),"")}function E(d){let m="";for(;d.currentPeek()===Rt||d.currentPeek()===$e;)m+=d.currentPeek(),d.peek();return m}function O(d){const m=E(d);return d.skipToPeek(),m}function R(d){if(d===qt)return!1;const m=d.charCodeAt(0);return m>=97&&m<=122||m>=65&&m<=90||m===95}function x(d){if(d===qt)return!1;const m=d.charCodeAt(0);return m>=48&&m<=57}function y(d,m){const{currentType:w}=m;if(w!==2)return!1;E(d);const C=R(d.currentPeek());return d.resetPeek(),C}function b(d,m){const{currentType:w}=m;if(w!==2)return!1;E(d);const C=d.currentPeek()==="-"?d.peek():d.currentPeek(),B=x(C);return d.resetPeek(),B}function I(d,m){const{currentType:w}=m;if(w!==2)return!1;E(d);const C=d.currentPeek()===ta;return d.resetPeek(),C}function k(d,m){const{currentType:w}=m;if(w!==8)return!1;E(d);const C=d.currentPeek()===".";return d.resetPeek(),C}function M(d,m){const{currentType:w}=m;if(w!==9)return!1;E(d);const C=R(d.currentPeek());return d.resetPeek(),C}function j(d,m){const{currentType:w}=m;if(!(w===8||w===12))return!1;E(d);const C=d.currentPeek()===":";return d.resetPeek(),C}function S(d,m){const{currentType:w}=m;if(w!==10)return!1;const C=()=>{const V=d.currentPeek();return V==="{"?R(d.peek()):V==="@"||V==="%"||V==="|"||V===":"||V==="."||V===Rt||!V?!1:V===$e?(d.peek(),C()):U(d,!1)},B=C();return d.resetPeek(),B}function G(d){E(d);const m=d.currentPeek()==="|";return d.resetPeek(),m}function Z(d){const m=E(d),w=d.currentPeek()==="%"&&d.peek()==="{";return d.resetPeek(),{isModulo:w,hasSpace:m.length>0}}function U(d,m=!0){const w=(B=!1,V="",T=!1)=>{const P=d.currentPeek();return P==="{"?V==="%"?!1:B:P==="@"||!P?V==="%"?!0:B:P==="%"?(d.peek(),w(B,"%",!0)):P==="|"?V==="%"||T?!0:!(V===Rt||V===$e):P===Rt?(d.peek(),w(!0,Rt,T)):P===$e?(d.peek(),w(!0,$e,T)):!0},C=w();return m&&d.resetPeek(),C}function J(d,m){const w=d.currentChar();return w===qt?qt:m(w)?(d.next(),w):null}function ge(d){const m=d.charCodeAt(0);return m>=97&&m<=122||m>=65&&m<=90||m>=48&&m<=57||m===95||m===36}function Se(d){return J(d,ge)}function se(d){const m=d.charCodeAt(0);return m>=97&&m<=122||m>=65&&m<=90||m>=48&&m<=57||m===95||m===36||m===45}function ee(d){return J(d,se)}function oe(d){const m=d.charCodeAt(0);return m>=48&&m<=57}function He(d){return J(d,oe)}function Xe(d){const m=d.charCodeAt(0);return m>=48&&m<=57||m>=65&&m<=70||m>=97&&m<=102}function we(d){return J(d,Xe)}function Ae(d){let m="",w="";for(;m=He(d);)w+=m;return w}function lt(d){O(d);const m=d.currentChar();return m!=="%"&&f(Q.EXPECTED_TOKEN,i(),0,m),d.next(),"%"}function et(d){let m="";for(;;){const w=d.currentChar();if(w==="{"||w==="}"||w==="@"||w==="|"||!w)break;if(w==="%")if(U(d))m+=w,d.next();else break;else if(w===Rt||w===$e)if(U(d))m+=w,d.next();else{if(G(d))break;m+=w,d.next()}else m+=w,d.next()}return m}function tt(d){O(d);let m="",w="";for(;m=ee(d);)w+=m;return d.currentChar()===qt&&f(Q.UNTERMINATED_CLOSING_BRACE,i(),0),w}function Re(d){O(d);let m="";return d.currentChar()==="-"?(d.next(),m+=`-${Ae(d)}`):m+=Ae(d),d.currentChar()===qt&&f(Q.UNTERMINATED_CLOSING_BRACE,i(),0),m}function D(d){return d!==ta&&d!==$e}function K(d){O(d),A(d,"'");let m="",w="";for(;m=J(d,D);)m==="\\"?w+=$(d):w+=m;const C=d.currentChar();return C===$e||C===qt?(f(Q.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,i(),0),C===$e&&(d.next(),A(d,"'")),w):(A(d,"'"),w)}function $(d){const m=d.currentChar();switch(m){case"\\":case"'":return d.next(),`\\${m}`;case"u":return q(d,m,4);case"U":return q(d,m,6);default:return f(Q.UNKNOWN_ESCAPE_SEQUENCE,i(),0,m),""}}function q(d,m,w){A(d,m);let C="";for(let B=0;B{const C=d.currentChar();return C==="{"||C==="%"||C==="@"||C==="|"||C==="("||C===")"||!C||C===Rt?w:(w+=C,d.next(),m(w))};return m("")}function N(d){O(d);const m=A(d,"|");return O(d),m}function F(d,m){let w=null;switch(d.currentChar()){case"{":return m.braceNest>=1&&f(Q.NOT_ALLOW_NEST_PLACEHOLDER,i(),0),d.next(),w=h(m,2,"{"),O(d),m.braceNest++,w;case"}":return m.braceNest>0&&m.currentType===2&&f(Q.EMPTY_PLACEHOLDER,i(),0),d.next(),w=h(m,3,"}"),m.braceNest--,m.braceNest>0&&O(d),m.inLinked&&m.braceNest===0&&(m.inLinked=!1),w;case"@":return m.braceNest>0&&f(Q.UNTERMINATED_CLOSING_BRACE,i(),0),w=L(d,m)||_(m),m.braceNest=0,w;default:{let B=!0,V=!0,T=!0;if(G(d))return m.braceNest>0&&f(Q.UNTERMINATED_CLOSING_BRACE,i(),0),w=h(m,1,N(d)),m.braceNest=0,m.inLinked=!1,w;if(m.braceNest>0&&(m.currentType===5||m.currentType===6||m.currentType===7))return f(Q.UNTERMINATED_CLOSING_BRACE,i(),0),m.braceNest=0,W(d,m);if(B=y(d,m))return w=h(m,5,tt(d)),O(d),w;if(V=b(d,m))return w=h(m,6,Re(d)),O(d),w;if(T=I(d,m))return w=h(m,7,K(d)),O(d),w;if(!B&&!V&&!T)return w=h(m,13,p(d)),f(Q.INVALID_TOKEN_IN_PLACEHOLDER,i(),0,w.value),O(d),w;break}}return w}function L(d,m){const{currentType:w}=m;let C=null;const B=d.currentChar();switch((w===8||w===9||w===12||w===10)&&(B===$e||B===Rt)&&f(Q.INVALID_LINKED_FORMAT,i(),0),B){case"@":return d.next(),C=h(m,8,"@"),m.inLinked=!0,C;case".":return O(d),d.next(),h(m,9,".");case":":return O(d),d.next(),h(m,10,":");default:return G(d)?(C=h(m,1,N(d)),m.braceNest=0,m.inLinked=!1,C):k(d,m)||j(d,m)?(O(d),L(d,m)):M(d,m)?(O(d),h(m,12,v(d))):S(d,m)?(O(d),B==="{"?F(d,m)||C:h(m,11,g(d))):(w===8&&f(Q.INVALID_LINKED_FORMAT,i(),0),m.braceNest=0,m.inLinked=!1,W(d,m))}}function W(d,m){let w={type:14};if(m.braceNest>0)return F(d,m)||_(m);if(m.inLinked)return L(d,m)||_(m);switch(d.currentChar()){case"{":return F(d,m)||_(m);case"}":return f(Q.UNBALANCED_CLOSING_BRACE,i(),0),d.next(),h(m,3,"}");case"@":return L(d,m)||_(m);default:{if(G(d))return w=h(m,1,N(d)),m.braceNest=0,m.inLinked=!1,w;const{isModulo:B,hasSpace:V}=Z(d);if(B)return V?h(m,0,et(d)):h(m,4,lt(d));if(U(d))return h(m,0,et(d));break}}return w}function H(){const{currentType:d,offset:m,startLoc:w,endLoc:C}=l;return l.lastType=d,l.lastOffset=m,l.lastStartLoc=w,l.lastEndLoc=C,l.offset=s(),l.startLoc=i(),r.currentChar()===qt?h(l,14):W(r,l)}return{nextToken:H,currentOffset:s,currentPosition:i,context:c}}const Oh="parser",Lh=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function Rh(e,t,n){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const r=parseInt(t||n,16);return r<=55295||r>=57344?String.fromCodePoint(r):"�"}}}function Dh(e={}){const t=e.location!==!1,{onError:n,onWarn:r}=e;function s(y,b,I,k,...M){const j=y.currentPosition();if(j.offset+=k,j.column+=k,n){const S=t?$r(I,j):null,G=jn(b,S,{domain:Oh,args:M});n(G)}}function i(y,b,I,k,...M){const j=y.currentPosition();if(j.offset+=k,j.column+=k,r){const S=t?$r(I,j):null;r(Eh(b,S,M))}}function o(y,b,I){const k={type:y};return t&&(k.start=b,k.end=b,k.loc={start:I,end:I}),k}function a(y,b,I,k){t&&(y.end=b,y.loc&&(y.loc.end=I))}function l(y,b){const I=y.context(),k=o(3,I.offset,I.startLoc);return k.value=b,a(k,y.currentOffset(),y.currentPosition()),k}function c(y,b){const I=y.context(),{lastOffset:k,lastStartLoc:M}=I,j=o(5,k,M);return j.index=parseInt(b,10),y.nextToken(),a(j,y.currentOffset(),y.currentPosition()),j}function u(y,b,I){const k=y.context(),{lastOffset:M,lastStartLoc:j}=k,S=o(4,M,j);return S.key=b,I===!0&&(S.modulo=!0),y.nextToken(),a(S,y.currentOffset(),y.currentPosition()),S}function f(y,b){const I=y.context(),{lastOffset:k,lastStartLoc:M}=I,j=o(9,k,M);return j.value=b.replace(Lh,Rh),y.nextToken(),a(j,y.currentOffset(),y.currentPosition()),j}function h(y){const b=y.nextToken(),I=y.context(),{lastOffset:k,lastStartLoc:M}=I,j=o(8,k,M);return b.type!==12?(s(y,Q.UNEXPECTED_EMPTY_LINKED_MODIFIER,I.lastStartLoc,0),j.value="",a(j,k,M),{nextConsumeToken:b,node:j}):(b.value==null&&s(y,Q.UNEXPECTED_LEXICAL_ANALYSIS,I.lastStartLoc,0,dt(b)),j.value=b.value||"",a(j,y.currentOffset(),y.currentPosition()),{node:j})}function _(y,b){const I=y.context(),k=o(7,I.offset,I.startLoc);return k.value=b,a(k,y.currentOffset(),y.currentPosition()),k}function A(y){const b=y.context(),I=o(6,b.offset,b.startLoc);let k=y.nextToken();if(k.type===9){const M=h(y);I.modifier=M.node,k=M.nextConsumeToken||y.nextToken()}switch(k.type!==10&&s(y,Q.UNEXPECTED_LEXICAL_ANALYSIS,b.lastStartLoc,0,dt(k)),k=y.nextToken(),k.type===2&&(k=y.nextToken()),k.type){case 11:k.value==null&&s(y,Q.UNEXPECTED_LEXICAL_ANALYSIS,b.lastStartLoc,0,dt(k)),I.key=_(y,k.value||"");break;case 5:k.value==null&&s(y,Q.UNEXPECTED_LEXICAL_ANALYSIS,b.lastStartLoc,0,dt(k)),I.key=u(y,k.value||"");break;case 6:k.value==null&&s(y,Q.UNEXPECTED_LEXICAL_ANALYSIS,b.lastStartLoc,0,dt(k)),I.key=c(y,k.value||"");break;case 7:k.value==null&&s(y,Q.UNEXPECTED_LEXICAL_ANALYSIS,b.lastStartLoc,0,dt(k)),I.key=f(y,k.value||"");break;default:{s(y,Q.UNEXPECTED_EMPTY_LINKED_KEY,b.lastStartLoc,0);const M=y.context(),j=o(7,M.offset,M.startLoc);return j.value="",a(j,M.offset,M.startLoc),I.key=j,a(I,M.offset,M.startLoc),{nextConsumeToken:k,node:I}}}return a(I,y.currentOffset(),y.currentPosition()),{node:I}}function E(y){const b=y.context(),I=b.currentType===1?y.currentOffset():b.offset,k=b.currentType===1?b.endLoc:b.startLoc,M=o(2,I,k);M.items=[];let j=null,S=null;do{const U=j||y.nextToken();switch(j=null,U.type){case 0:U.value==null&&s(y,Q.UNEXPECTED_LEXICAL_ANALYSIS,b.lastStartLoc,0,dt(U)),M.items.push(l(y,U.value||""));break;case 6:U.value==null&&s(y,Q.UNEXPECTED_LEXICAL_ANALYSIS,b.lastStartLoc,0,dt(U)),M.items.push(c(y,U.value||""));break;case 4:S=!0;break;case 5:U.value==null&&s(y,Q.UNEXPECTED_LEXICAL_ANALYSIS,b.lastStartLoc,0,dt(U)),M.items.push(u(y,U.value||"",!!S)),S&&(i(y,Oi.USE_MODULO_SYNTAX,b.lastStartLoc,0,dt(U)),S=null);break;case 7:U.value==null&&s(y,Q.UNEXPECTED_LEXICAL_ANALYSIS,b.lastStartLoc,0,dt(U)),M.items.push(f(y,U.value||""));break;case 8:{const J=A(y);M.items.push(J.node),j=J.nextConsumeToken||null;break}}}while(b.currentType!==14&&b.currentType!==1);const G=b.currentType===1?b.lastOffset:y.currentOffset(),Z=b.currentType===1?b.lastEndLoc:y.currentPosition();return a(M,G,Z),M}function O(y,b,I,k){const M=y.context();let j=k.items.length===0;const S=o(1,b,I);S.cases=[],S.cases.push(k);do{const G=E(y);j||(j=G.items.length===0),S.cases.push(G)}while(M.currentType!==14);return j&&s(y,Q.MUST_HAVE_MESSAGES_IN_PLURAL,I,0),a(S,y.currentOffset(),y.currentPosition()),S}function R(y){const b=y.context(),{offset:I,startLoc:k}=b,M=E(y);return b.currentType===14?M:O(y,I,k,M)}function x(y){const b=Ph(y,pc({},e)),I=b.context(),k=o(0,I.offset,I.startLoc);return t&&k.loc&&(k.loc.source=y),k.body=R(b),e.onCacheKey&&(k.cacheKey=e.onCacheKey(y)),I.currentType!==14&&s(b,Q.UNEXPECTED_LEXICAL_ANALYSIS,I.lastStartLoc,0,y[I.offset]||""),a(k,b.currentOffset(),b.currentPosition()),k}return{parse:x}}function dt(e){if(e.type===14)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function Mh(e,t={}){const n={ast:e,helpers:new Set};return{context:()=>n,helper:i=>(n.helpers.add(i),i)}}function na(e,t){for(let n=0;nra(n)),e}function ra(e){if(e.items.length===1){const t=e.items[0];(t.type===3||t.type===9)&&(e.static=t.value,delete t.value)}else{const t=[];for(let n=0;no;function l(E,O){o.code+=E}function c(E,O=!0){const R=O?r:"";l(s?R+" ".repeat(E):R)}function u(E=!0){const O=++o.indentLevel;E&&c(O)}function f(E=!0){const O=--o.indentLevel;E&&c(O)}function h(){c(o.indentLevel)}return{context:a,push:l,indent:u,deindent:f,newline:h,helper:E=>`_${E}`,needIndent:()=>o.needIndent}}function Hh(e,t){const{helper:n}=e;e.push(`${n("linked")}(`),Mn(e,t.key),t.modifier?(e.push(", "),Mn(e,t.modifier),e.push(", _type")):e.push(", undefined, _type"),e.push(")")}function Wh(e,t){const{helper:n,needIndent:r}=e;e.push(`${n("normalize")}([`),e.indent(r());const s=t.items.length;for(let i=0;i1){e.push(`${n("plural")}([`),e.indent(r());const s=t.cases.length;for(let i=0;i{const n=ea(t.mode)?t.mode:"normal",r=ea(t.filename)?t.filename:"message.intl";t.sourceMap;const s=t.breakLineCode!=null?t.breakLineCode:n==="arrow"?";":` +`,i=t.needIndent?t.needIndent:n!=="arrow",o=e.helpers||[],a=Vh(e,{filename:r,breakLineCode:s,needIndent:i});a.push(n==="normal"?"function __msg__ (ctx) {":"(ctx) => {"),a.indent(i),o.length>0&&(a.push(`const { ${gc(o.map(u=>`${u}: _${u}`),", ")} } = ctx`),a.newline()),a.push("return "),Mn(a,e),a.deindent(i),a.push("}"),delete e.helpers;const{code:l,map:c}=a.context();return{ast:e,code:l,map:c?c.toJSON():void 0}};function Kh(e,t={}){const n=pc({},t),r=!!n.jit,s=!!n.minify,i=n.optimize==null?!0:n.optimize,a=Dh(n).parse(e);return r?(i&&Fh(a),s&&Sn(a),{ast:a,code:""}):(xh(a,n),zh(a,n))}/*! + * core-base v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */function Gh(){typeof __INTLIFY_PROD_DEVTOOLS__!="boolean"&&(jt().__INTLIFY_PROD_DEVTOOLS__=!1),typeof __INTLIFY_JIT_COMPILATION__!="boolean"&&(jt().__INTLIFY_JIT_COMPILATION__=!1),typeof __INTLIFY_DROP_MESSAGE_COMPILER__!="boolean"&&(jt().__INTLIFY_DROP_MESSAGE_COMPILER__=!1)}function kt(e){return ce(e)&&Ri(e)===0&&(mt(e,"b")||mt(e,"body"))}const _c=["b","body"];function qh(e){return sn(e,_c)}const vc=["c","cases"];function Yh(e){return sn(e,vc,[])}const bc=["s","static"];function Xh(e){return sn(e,bc)}const yc=["i","items"];function Jh(e){return sn(e,yc,[])}const Ec=["t","type"];function Ri(e){return sn(e,Ec)}const Tc=["v","value"];function Sr(e,t){const n=sn(e,Tc);if(n!=null)return n;throw dr(t)}const wc=["m","modifier"];function Qh(e){return sn(e,wc)}const Ac=["k","key"];function Zh(e){const t=sn(e,Ac);if(t)return t;throw dr(6)}function sn(e,t,n){for(let r=0;r{o===void 0?o=a:o+=a},h[1]=()=>{o!==void 0&&(t.push(o),o=void 0)},h[2]=()=>{h[0](),s++},h[3]=()=>{if(s>0)s--,r=4,h[0]();else{if(s=0,o===void 0||(o=sp(o),o===!1))return!1;h[1]()}};function _(){const A=e[n+1];if(r===5&&A==="'"||r===6&&A==='"')return n++,a="\\"+A,h[0](),!0}for(;r!==null;)if(n++,i=e[n],!(i==="\\"&&_())){if(l=rp(i),f=on[r],c=f[l]||f.l||8,c===8||(r=c[0],c[1]!==void 0&&(u=h[c[1]],u&&(a=i,u()===!1))))return;if(r===7)return t}}const sa=new Map;function op(e,t){return ce(e)?e[t]:null}function ap(e,t){if(!ce(e))return null;let n=sa.get(t);if(n||(n=ip(t),n&&sa.set(t,n)),!n)return null;const r=n.length;let s=e,i=0;for(;ie,cp=e=>"",up="text",fp=e=>e.length===0?"":gh(e),dp=ph;function ia(e,t){return e=Math.abs(e),t===2?e?e>1?1:0:1:e?Math.min(e,2):0}function mp(e){const t=Ie(e.pluralIndex)?e.pluralIndex:-1;return e.named&&(Ie(e.named.count)||Ie(e.named.n))?Ie(e.named.count)?e.named.count:Ie(e.named.n)?e.named.n:t:t}function hp(e,t){t.count||(t.count=e),t.n||(t.n=e)}function pp(e={}){const t=e.locale,n=mp(e),r=ce(e.pluralRules)&&z(t)&&ve(e.pluralRules[t])?e.pluralRules[t]:ia,s=ce(e.pluralRules)&&z(t)&&ve(e.pluralRules[t])?ia:void 0,i=R=>R[r(n,R.length,s)],o=e.list||[],a=R=>o[R],l=e.named||he();Ie(e.pluralIndex)&&hp(n,l);const c=R=>l[R];function u(R){const x=ve(e.messages)?e.messages(R):ce(e.messages)?e.messages[R]:!1;return x||(e.parent?e.parent.message(R):cp)}const f=R=>e.modifiers?e.modifiers[R]:lp,h=te(e.processor)&&ve(e.processor.normalize)?e.processor.normalize:fp,_=te(e.processor)&&ve(e.processor.interpolate)?e.processor.interpolate:dp,A=te(e.processor)&&z(e.processor.type)?e.processor.type:up,O={list:a,named:c,plural:i,linked:(R,...x)=>{const[y,b]=x;let I="text",k="";x.length===1?ce(y)?(k=y.modifier||k,I=y.type||I):z(y)&&(k=y||k):x.length===2&&(z(y)&&(k=y||k),z(b)&&(I=b||I));const M=u(R)(O),j=I==="vnode"&&be(M)&&k?M[0]:M;return k?f(k)(j,I):j},message:u,type:A,interpolate:_,normalize:h,values:xe(he(),o,l)};return O}let mr=null;function gp(e){mr=e}function _p(e,t,n){mr&&mr.emit("i18n:init",{timestamp:Date.now(),i18n:e,version:t,meta:n})}const vp=bp("function:translate");function bp(e){return t=>mr&&mr.emit(e,t)}const yp=Oi.__EXTEND_POINT__,dn=ds(yp),Ep={FALLBACK_TO_TRANSLATE:dn(),CANNOT_FORMAT_NUMBER:dn(),FALLBACK_TO_NUMBER_FORMAT:dn(),CANNOT_FORMAT_DATE:dn(),FALLBACK_TO_DATE_FORMAT:dn(),EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER:dn(),__EXTEND_POINT__:dn()},Sc=Q.__EXTEND_POINT__,mn=ds(Sc),ht={INVALID_ARGUMENT:Sc,INVALID_DATE_ARGUMENT:mn(),INVALID_ISO_DATE_ARGUMENT:mn(),NOT_SUPPORT_NON_STRING_MESSAGE:mn(),NOT_SUPPORT_LOCALE_PROMISE_VALUE:mn(),NOT_SUPPORT_LOCALE_ASYNC_FUNCTION:mn(),NOT_SUPPORT_LOCALE_TYPE:mn(),__EXTEND_POINT__:mn()};function St(e){return jn(e,null,void 0)}function Di(e,t){return t.locale!=null?oa(t.locale):oa(e.locale)}let Rs;function oa(e){if(z(e))return e;if(ve(e)){if(e.resolvedOnce&&Rs!=null)return Rs;if(e.constructor.name==="Function"){const t=e();if(hh(t))throw St(ht.NOT_SUPPORT_LOCALE_PROMISE_VALUE);return Rs=t}else throw St(ht.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION)}else throw St(ht.NOT_SUPPORT_LOCALE_TYPE)}function Tp(e,t,n){return[...new Set([n,...be(t)?t:ce(t)?Object.keys(t):z(t)?[t]:[n]])]}function Ic(e,t,n){const r=z(n)?n:xn,s=e;s.__localeChainCache||(s.__localeChainCache=new Map);let i=s.__localeChainCache.get(r);if(!i){i=[];let o=[n];for(;be(o);)o=aa(i,o,t);const a=be(t)||!te(t)?t:t.default?t.default:null;o=z(a)?[a]:a,be(o)&&aa(i,o,!1),s.__localeChainCache.set(r,i)}return i}function aa(e,t,n){let r=!0;for(let s=0;s`${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;function Sp(){return{upper:(e,t)=>t==="text"&&z(e)?e.toUpperCase():t==="vnode"&&ce(e)&&"__v_isVNode"in e?e.children.toUpperCase():e,lower:(e,t)=>t==="text"&&z(e)?e.toLowerCase():t==="vnode"&&ce(e)&&"__v_isVNode"in e?e.children.toLowerCase():e,capitalize:(e,t)=>t==="text"&&z(e)?ca(e):t==="vnode"&&ce(e)&&"__v_isVNode"in e?ca(e.children):e}}let kc;function ua(e){kc=e}let Cc;function Ip(e){Cc=e}let Pc;function kp(e){Pc=e}let Oc=null;const Cp=e=>{Oc=e},Pp=()=>Oc;let Lc=null;const fa=e=>{Lc=e},Op=()=>Lc;let da=0;function Lp(e={}){const t=ve(e.onWarn)?e.onWarn:ah,n=z(e.version)?e.version:Np,r=z(e.locale)||ve(e.locale)?e.locale:xn,s=ve(r)?xn:r,i=be(e.fallbackLocale)||te(e.fallbackLocale)||z(e.fallbackLocale)||e.fallbackLocale===!1?e.fallbackLocale:s,o=te(e.messages)?e.messages:Ds(s),a=te(e.datetimeFormats)?e.datetimeFormats:Ds(s),l=te(e.numberFormats)?e.numberFormats:Ds(s),c=xe(he(),e.modifiers,Sp()),u=e.pluralRules||he(),f=ve(e.missing)?e.missing:null,h=ie(e.missingWarn)||nn(e.missingWarn)?e.missingWarn:!0,_=ie(e.fallbackWarn)||nn(e.fallbackWarn)?e.fallbackWarn:!0,A=!!e.fallbackFormat,E=!!e.unresolving,O=ve(e.postTranslation)?e.postTranslation:null,R=te(e.processor)?e.processor:null,x=ie(e.warnHtmlMessage)?e.warnHtmlMessage:!0,y=!!e.escapeParameter,b=ve(e.messageCompiler)?e.messageCompiler:kc,I=ve(e.messageResolver)?e.messageResolver:Cc||op,k=ve(e.localeFallbacker)?e.localeFallbacker:Pc||Tp,M=ce(e.fallbackContext)?e.fallbackContext:void 0,j=e,S=ce(j.__datetimeFormatters)?j.__datetimeFormatters:new Map,G=ce(j.__numberFormatters)?j.__numberFormatters:new Map,Z=ce(j.__meta)?j.__meta:{};da++;const U={version:n,cid:da,locale:r,fallbackLocale:i,messages:o,modifiers:c,pluralRules:u,missing:f,missingWarn:h,fallbackWarn:_,fallbackFormat:A,unresolving:E,postTranslation:O,processor:R,warnHtmlMessage:x,escapeParameter:y,messageCompiler:b,messageResolver:I,localeFallbacker:k,fallbackContext:M,onWarn:t,__meta:Z};return U.datetimeFormats=a,U.numberFormats=l,U.__datetimeFormatters=S,U.__numberFormatters=G,__INTLIFY_PROD_DEVTOOLS__&&_p(U,n,Z),U}const Ds=e=>({[e]:he()});function Mi(e,t,n,r,s){const{missing:i,onWarn:o}=e;if(i!==null){const a=i(e,n,t,s);return z(a)?a:t}else return t}function Kn(e,t,n){const r=e;r.__localeChainCache=new Map,e.localeFallbacker(e,n,t)}function Rp(e,t){return e===t?!1:e.split("-")[0]===t.split("-")[0]}function Dp(e,t){const n=t.indexOf(e);if(n===-1)return!1;for(let r=n+1;rMp(n,e)}function Mp(e,t){const n=qh(t);if(n==null)throw dr(0);if(Ri(n)===1){const i=Yh(n);return e.plural(i.reduce((o,a)=>[...o,ma(e,a)],[]))}else return ma(e,n)}function ma(e,t){const n=Xh(t);if(n!=null)return e.type==="text"?n:e.normalize([n]);{const r=Jh(t).reduce((s,i)=>[...s,ti(e,i)],[]);return e.normalize(r)}}function ti(e,t){const n=Ri(t);switch(n){case 3:return Sr(t,n);case 9:return Sr(t,n);case 4:{const r=t;if(mt(r,"k")&&r.k)return e.interpolate(e.named(r.k));if(mt(r,"key")&&r.key)return e.interpolate(e.named(r.key));throw dr(n)}case 5:{const r=t;if(mt(r,"i")&&Ie(r.i))return e.interpolate(e.list(r.i));if(mt(r,"index")&&Ie(r.index))return e.interpolate(e.list(r.index));throw dr(n)}case 6:{const r=t,s=Qh(r),i=Zh(r);return e.linked(ti(e,i),s?ti(e,s):void 0,e.type)}case 7:return Sr(t,n);case 8:return Sr(t,n);default:throw new Error(`unhandled node on format message part: ${n}`)}}const Rc=e=>e;let In=he();function Dc(e,t={}){let n=!1;const r=t.onError||wh;return t.onError=s=>{n=!0,r(s)},{...Kh(e,t),detectError:n}}const xp=(e,t)=>{if(!z(e))throw St(ht.NOT_SUPPORT_NON_STRING_MESSAGE);{ie(t.warnHtmlMessage)&&t.warnHtmlMessage;const r=(t.onCacheKey||Rc)(e),s=In[r];if(s)return s;const{code:i,detectError:o}=Dc(e,t),a=new Function(`return ${i}`)();return o?a:In[r]=a}};function Fp(e,t){if(__INTLIFY_JIT_COMPILATION__&&!__INTLIFY_DROP_MESSAGE_COMPILER__&&z(e)){ie(t.warnHtmlMessage)&&t.warnHtmlMessage;const r=(t.onCacheKey||Rc)(e),s=In[r];if(s)return s;const{ast:i,detectError:o}=Dc(e,{...t,location:!1,jit:!0}),a=Ms(i);return o?a:In[r]=a}else{const n=e.cacheKey;if(n){const r=In[n];return r||(In[n]=Ms(e))}else return Ms(e)}}const ha=()=>"",ft=e=>ve(e);function pa(e,...t){const{fallbackFormat:n,postTranslation:r,unresolving:s,messageCompiler:i,fallbackLocale:o,messages:a}=e,[l,c]=ni(...t),u=ie(c.missingWarn)?c.missingWarn:e.missingWarn,f=ie(c.fallbackWarn)?c.fallbackWarn:e.fallbackWarn,h=ie(c.escapeParameter)?c.escapeParameter:e.escapeParameter,_=!!c.resolvedMessage,A=z(c.default)||ie(c.default)?ie(c.default)?i?l:()=>l:c.default:n?i?l:()=>l:"",E=n||A!=="",O=Di(e,c);h&&Up(c);let[R,x,y]=_?[l,O,a[O]||he()]:Mc(e,l,O,o,f,u),b=R,I=l;if(!_&&!(z(b)||kt(b)||ft(b))&&E&&(b=A,I=b),!_&&(!(z(b)||kt(b)||ft(b))||!z(x)))return s?ms:l;let k=!1;const M=()=>{k=!0},j=ft(b)?b:xc(e,l,x,b,I,M);if(k)return b;const S=Hp(e,x,y,c),G=pp(S),Z=jp(e,j,G);let U=r?r(Z,l):Z;if(h&&z(U)&&(U=dh(U)),__INTLIFY_PROD_DEVTOOLS__){const J={timestamp:Date.now(),key:z(l)?l:ft(b)?b.key:"",locale:x||(ft(b)?b.locale:""),format:z(b)?b:ft(b)?b.source:"",message:U};J.meta=xe({},e.__meta,Pp()||{}),vp(J)}return U}function Up(e){be(e.list)?e.list=e.list.map(t=>z(t)?Qo(t):t):ce(e.named)&&Object.keys(e.named).forEach(t=>{z(e.named[t])&&(e.named[t]=Qo(e.named[t]))})}function Mc(e,t,n,r,s,i){const{messages:o,onWarn:a,messageResolver:l,localeFallbacker:c}=e,u=c(e,r,n);let f=he(),h,_=null;const A="translate";for(let E=0;Er;return c.locale=n,c.key=t,c}const l=o(r,Vp(e,n,s,r,a,i));return l.locale=n,l.key=t,l.source=r,l}function jp(e,t,n){return t(n)}function ni(...e){const[t,n,r]=e,s=he();if(!z(t)&&!Ie(t)&&!ft(t)&&!kt(t))throw St(ht.INVALID_ARGUMENT);const i=Ie(t)?String(t):(ft(t),t);return Ie(n)?s.plural=n:z(n)?s.default=n:te(n)&&!fs(n)?s.named=n:be(n)&&(s.list=n),Ie(r)?s.plural=r:z(r)?s.default=r:te(r)&&xe(s,r),[i,s]}function Vp(e,t,n,r,s,i){return{locale:t,key:n,warnHtmlMessage:s,onError:o=>{throw i&&i(o),o},onCacheKey:o=>lh(t,n,o)}}function Hp(e,t,n,r){const{modifiers:s,pluralRules:i,messageResolver:o,fallbackLocale:a,fallbackWarn:l,missingWarn:c,fallbackContext:u}=e,h={locale:t,modifiers:s,pluralRules:i,messages:_=>{let A=o(n,_);if(A==null&&u){const[,,E]=Mc(u,_,t,a,l,c);A=o(E,_)}if(z(A)||kt(A)){let E=!1;const R=xc(e,_,t,A,_,()=>{E=!0});return E?ha:R}else return ft(A)?A:ha}};return e.processor&&(h.processor=e.processor),r.list&&(h.list=r.list),r.named&&(h.named=r.named),Ie(r.plural)&&(h.pluralIndex=r.plural),h}function ga(e,...t){const{datetimeFormats:n,unresolving:r,fallbackLocale:s,onWarn:i,localeFallbacker:o}=e,{__datetimeFormatters:a}=e,[l,c,u,f]=ri(...t),h=ie(u.missingWarn)?u.missingWarn:e.missingWarn;ie(u.fallbackWarn)?u.fallbackWarn:e.fallbackWarn;const _=!!u.part,A=Di(e,u),E=o(e,s,A);if(!z(l)||l==="")return new Intl.DateTimeFormat(A,f).format(c);let O={},R,x=null;const y="datetime format";for(let k=0;k{Fc.includes(l)?o[l]=n[l]:i[l]=n[l]}),z(r)?i.locale=r:te(r)&&(o=r),te(s)&&(o=s),[i.key||"",a,i,o]}function _a(e,t,n){const r=e;for(const s in n){const i=`${t}__${s}`;r.__datetimeFormatters.has(i)&&r.__datetimeFormatters.delete(i)}}function va(e,...t){const{numberFormats:n,unresolving:r,fallbackLocale:s,onWarn:i,localeFallbacker:o}=e,{__numberFormatters:a}=e,[l,c,u,f]=si(...t),h=ie(u.missingWarn)?u.missingWarn:e.missingWarn;ie(u.fallbackWarn)?u.fallbackWarn:e.fallbackWarn;const _=!!u.part,A=Di(e,u),E=o(e,s,A);if(!z(l)||l==="")return new Intl.NumberFormat(A,f).format(c);let O={},R,x=null;const y="number format";for(let k=0;k{Uc.includes(l)?o[l]=n[l]:i[l]=n[l]}),z(r)?i.locale=r:te(r)&&(o=r),te(s)&&(o=s),[i.key||"",a,i,o]}function ba(e,t,n){const r=e;for(const s in n){const i=`${t}__${s}`;r.__numberFormatters.has(i)&&r.__numberFormatters.delete(i)}}Gh();/*! + * vue-i18n v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */const Wp="9.14.5";function Bp(){typeof __VUE_I18N_FULL_INSTALL__!="boolean"&&(jt().__VUE_I18N_FULL_INSTALL__=!0),typeof __VUE_I18N_LEGACY_API__!="boolean"&&(jt().__VUE_I18N_LEGACY_API__=!0),typeof __INTLIFY_JIT_COMPILATION__!="boolean"&&(jt().__INTLIFY_JIT_COMPILATION__=!1),typeof __INTLIFY_DROP_MESSAGE_COMPILER__!="boolean"&&(jt().__INTLIFY_DROP_MESSAGE_COMPILER__=!1),typeof __INTLIFY_PROD_DEVTOOLS__!="boolean"&&(jt().__INTLIFY_PROD_DEVTOOLS__=!1)}const $p=Ep.__EXTEND_POINT__,Dt=ds($p);Dt(),Dt(),Dt(),Dt(),Dt(),Dt(),Dt(),Dt(),Dt();const jc=ht.__EXTEND_POINT__,Je=ds(jc),Oe={UNEXPECTED_RETURN_TYPE:jc,INVALID_ARGUMENT:Je(),MUST_BE_CALL_SETUP_TOP:Je(),NOT_INSTALLED:Je(),NOT_AVAILABLE_IN_LEGACY_MODE:Je(),REQUIRED_VALUE:Je(),INVALID_VALUE:Je(),CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN:Je(),NOT_INSTALLED_WITH_PROVIDE:Je(),UNEXPECTED_ERROR:Je(),NOT_COMPATIBLE_LEGACY_VUE_I18N:Je(),BRIDGE_SUPPORT_VUE_2_ONLY:Je(),MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION:Je(),NOT_AVAILABLE_COMPOSITION_IN_LEGACY:Je(),__EXTEND_POINT__:Je()};function De(e,...t){return jn(e,null,void 0)}const ii=rn("__translateVNode"),oi=rn("__datetimeParts"),ai=rn("__numberParts"),Vc=rn("__setPluralRules"),Hc=rn("__injectWithOption"),li=rn("__dispose");function hr(e){if(!ce(e)||kt(e))return e;for(const t in e)if(mt(e,t))if(!t.includes("."))ce(e[t])&&hr(e[t]);else{const n=t.split("."),r=n.length-1;let s=e,i=!1;for(let o=0;o{if("locale"in a&&"resource"in a){const{locale:l,resource:c}=a;l?(o[l]=o[l]||he(),Lr(c,o[l])):Lr(c,o)}else z(a)&&Lr(JSON.parse(a),o)}),s==null&&i)for(const a in o)mt(o,a)&&hr(o[a]);return o}function Wc(e){return e.type}function Bc(e,t,n){let r=ce(t.messages)?t.messages:he();"__i18nGlobal"in n&&(r=hs(e.locale.value,{messages:r,__i18n:n.__i18nGlobal}));const s=Object.keys(r);s.length&&s.forEach(i=>{e.mergeLocaleMessage(i,r[i])});{if(ce(t.datetimeFormats)){const i=Object.keys(t.datetimeFormats);i.length&&i.forEach(o=>{e.mergeDateTimeFormat(o,t.datetimeFormats[o])})}if(ce(t.numberFormats)){const i=Object.keys(t.numberFormats);i.length&&i.forEach(o=>{e.mergeNumberFormat(o,t.numberFormats[o])})}}}function ya(e){return Ve(br,null,e,0)}const Ea="__INTLIFY_META__",Ta=()=>[],zp=()=>!1;let wa=0;function Aa(e){return(t,n,r,s)=>e(n,r,tn()||void 0,s)}const Kp=()=>{const e=tn();let t=null;return e&&(t=Wc(e)[Ea])?{[Ea]:t}:null};function xi(e={},t){const{__root:n,__injectWithOption:r}=e,s=n===void 0,i=e.flatJson,o=Br?Pe:wi,a=!!e.translateExistCompatible;let l=ie(e.inheritLocale)?e.inheritLocale:!0;const c=o(n&&l?n.locale.value:z(e.locale)?e.locale:xn),u=o(n&&l?n.fallbackLocale.value:z(e.fallbackLocale)||be(e.fallbackLocale)||te(e.fallbackLocale)||e.fallbackLocale===!1?e.fallbackLocale:c.value),f=o(hs(c.value,e)),h=o(te(e.datetimeFormats)?e.datetimeFormats:{[c.value]:{}}),_=o(te(e.numberFormats)?e.numberFormats:{[c.value]:{}});let A=n?n.missingWarn:ie(e.missingWarn)||nn(e.missingWarn)?e.missingWarn:!0,E=n?n.fallbackWarn:ie(e.fallbackWarn)||nn(e.fallbackWarn)?e.fallbackWarn:!0,O=n?n.fallbackRoot:ie(e.fallbackRoot)?e.fallbackRoot:!0,R=!!e.fallbackFormat,x=ve(e.missing)?e.missing:null,y=ve(e.missing)?Aa(e.missing):null,b=ve(e.postTranslation)?e.postTranslation:null,I=n?n.warnHtmlMessage:ie(e.warnHtmlMessage)?e.warnHtmlMessage:!0,k=!!e.escapeParameter;const M=n?n.modifiers:te(e.modifiers)?e.modifiers:{};let j=e.pluralRules||n&&n.pluralRules,S;S=(()=>{s&&fa(null);const T={version:Wp,locale:c.value,fallbackLocale:u.value,messages:f.value,modifiers:M,pluralRules:j,missing:y===null?void 0:y,missingWarn:A,fallbackWarn:E,fallbackFormat:R,unresolving:!0,postTranslation:b===null?void 0:b,warnHtmlMessage:I,escapeParameter:k,messageResolver:e.messageResolver,messageCompiler:e.messageCompiler,__meta:{framework:"vue"}};T.datetimeFormats=h.value,T.numberFormats=_.value,T.__datetimeFormatters=te(S)?S.__datetimeFormatters:void 0,T.__numberFormatters=te(S)?S.__numberFormatters:void 0;const P=Lp(T);return s&&fa(P),P})(),Kn(S,c.value,u.value);function Z(){return[c.value,u.value,f.value,h.value,_.value]}const U=ue({get:()=>c.value,set:T=>{c.value=T,S.locale=c.value}}),J=ue({get:()=>u.value,set:T=>{u.value=T,S.fallbackLocale=u.value,Kn(S,c.value,T)}}),ge=ue(()=>f.value),Se=ue(()=>h.value),se=ue(()=>_.value);function ee(){return ve(b)?b:null}function oe(T){b=T,S.postTranslation=T}function He(){return x}function Xe(T){T!==null&&(y=Aa(T)),x=T,S.missing=y}const we=(T,P,Y,ae,ye,We)=>{Z();let Me;try{__INTLIFY_PROD_DEVTOOLS__,s||(S.fallbackContext=n?Op():void 0),Me=T(S)}finally{__INTLIFY_PROD_DEVTOOLS__,s||(S.fallbackContext=void 0)}if(Y!=="translate exists"&&Ie(Me)&&Me===ms||Y==="translate exists"&&!Me){const[an,gs]=P();return n&&O?ae(n):ye(an)}else{if(We(Me))return Me;throw De(Oe.UNEXPECTED_RETURN_TYPE)}};function Ae(...T){return we(P=>Reflect.apply(pa,null,[P,...T]),()=>ni(...T),"translate",P=>Reflect.apply(P.t,P,[...T]),P=>P,P=>z(P))}function lt(...T){const[P,Y,ae]=T;if(ae&&!ce(ae))throw De(Oe.INVALID_ARGUMENT);return Ae(P,Y,xe({resolvedMessage:!0},ae||{}))}function et(...T){return we(P=>Reflect.apply(ga,null,[P,...T]),()=>ri(...T),"datetime format",P=>Reflect.apply(P.d,P,[...T]),()=>la,P=>z(P))}function tt(...T){return we(P=>Reflect.apply(va,null,[P,...T]),()=>si(...T),"number format",P=>Reflect.apply(P.n,P,[...T]),()=>la,P=>z(P))}function Re(T){return T.map(P=>z(P)||Ie(P)||ie(P)?ya(String(P)):P)}const K={normalize:Re,interpolate:T=>T,type:"vnode"};function $(...T){return we(P=>{let Y;const ae=P;try{ae.processor=K,Y=Reflect.apply(pa,null,[ae,...T])}finally{ae.processor=null}return Y},()=>ni(...T),"translate",P=>P[ii](...T),P=>[ya(P)],P=>be(P))}function q(...T){return we(P=>Reflect.apply(va,null,[P,...T]),()=>si(...T),"number format",P=>P[ai](...T),Ta,P=>z(P)||be(P))}function re(...T){return we(P=>Reflect.apply(ga,null,[P,...T]),()=>ri(...T),"datetime format",P=>P[oi](...T),Ta,P=>z(P)||be(P))}function p(T){j=T,S.pluralRules=j}function v(T,P){return we(()=>{if(!T)return!1;const Y=z(P)?P:c.value,ae=F(Y),ye=S.messageResolver(ae,T);return a?ye!=null:kt(ye)||ft(ye)||z(ye)},()=>[T],"translate exists",Y=>Reflect.apply(Y.te,Y,[T,P]),zp,Y=>ie(Y))}function g(T){let P=null;const Y=Ic(S,u.value,c.value);for(let ae=0;ae{l&&(c.value=T,S.locale=T,Kn(S,c.value,u.value))}),Zt(n.fallbackLocale,T=>{l&&(u.value=T,S.fallbackLocale=T,Kn(S,c.value,u.value))}));const V={id:wa,locale:U,fallbackLocale:J,get inheritLocale(){return l},set inheritLocale(T){l=T,T&&n&&(c.value=n.locale.value,u.value=n.fallbackLocale.value,Kn(S,c.value,u.value))},get availableLocales(){return Object.keys(f.value).sort()},messages:ge,get modifiers(){return M},get pluralRules(){return j||{}},get isGlobal(){return s},get missingWarn(){return A},set missingWarn(T){A=T,S.missingWarn=A},get fallbackWarn(){return E},set fallbackWarn(T){E=T,S.fallbackWarn=E},get fallbackRoot(){return O},set fallbackRoot(T){O=T},get fallbackFormat(){return R},set fallbackFormat(T){R=T,S.fallbackFormat=R},get warnHtmlMessage(){return I},set warnHtmlMessage(T){I=T,S.warnHtmlMessage=T},get escapeParameter(){return k},set escapeParameter(T){k=T,S.escapeParameter=T},t:Ae,getLocaleMessage:F,setLocaleMessage:L,mergeLocaleMessage:W,getPostTranslationHandler:ee,setPostTranslationHandler:oe,getMissingHandler:He,setMissingHandler:Xe,[Vc]:p};return V.datetimeFormats=Se,V.numberFormats=se,V.rt=lt,V.te=v,V.tm=N,V.d=et,V.n=tt,V.getDateTimeFormat=H,V.setDateTimeFormat=d,V.mergeDateTimeFormat=m,V.getNumberFormat=w,V.setNumberFormat=C,V.mergeNumberFormat=B,V[Hc]=r,V[ii]=$,V[oi]=re,V[ai]=q,V}function Gp(e){const t=z(e.locale)?e.locale:xn,n=z(e.fallbackLocale)||be(e.fallbackLocale)||te(e.fallbackLocale)||e.fallbackLocale===!1?e.fallbackLocale:t,r=ve(e.missing)?e.missing:void 0,s=ie(e.silentTranslationWarn)||nn(e.silentTranslationWarn)?!e.silentTranslationWarn:!0,i=ie(e.silentFallbackWarn)||nn(e.silentFallbackWarn)?!e.silentFallbackWarn:!0,o=ie(e.fallbackRoot)?e.fallbackRoot:!0,a=!!e.formatFallbackMessages,l=te(e.modifiers)?e.modifiers:{},c=e.pluralizationRules,u=ve(e.postTranslation)?e.postTranslation:void 0,f=z(e.warnHtmlInMessage)?e.warnHtmlInMessage!=="off":!0,h=!!e.escapeParameterHtml,_=ie(e.sync)?e.sync:!0;let A=e.messages;if(te(e.sharedMessages)){const k=e.sharedMessages;A=Object.keys(k).reduce((j,S)=>{const G=j[S]||(j[S]={});return xe(G,k[S]),j},A||{})}const{__i18n:E,__root:O,__injectWithOption:R}=e,x=e.datetimeFormats,y=e.numberFormats,b=e.flatJson,I=e.translateExistCompatible;return{locale:t,fallbackLocale:n,messages:A,flatJson:b,datetimeFormats:x,numberFormats:y,missing:r,missingWarn:s,fallbackWarn:i,fallbackRoot:o,fallbackFormat:a,modifiers:l,pluralRules:c,postTranslation:u,warnHtmlMessage:f,escapeParameter:h,messageResolver:e.messageResolver,inheritLocale:_,translateExistCompatible:I,__i18n:E,__root:O,__injectWithOption:R}}function ci(e={},t){{const n=xi(Gp(e)),{__extender:r}=e,s={id:n.id,get locale(){return n.locale.value},set locale(i){n.locale.value=i},get fallbackLocale(){return n.fallbackLocale.value},set fallbackLocale(i){n.fallbackLocale.value=i},get messages(){return n.messages.value},get datetimeFormats(){return n.datetimeFormats.value},get numberFormats(){return n.numberFormats.value},get availableLocales(){return n.availableLocales},get formatter(){return{interpolate(){return[]}}},set formatter(i){},get missing(){return n.getMissingHandler()},set missing(i){n.setMissingHandler(i)},get silentTranslationWarn(){return ie(n.missingWarn)?!n.missingWarn:n.missingWarn},set silentTranslationWarn(i){n.missingWarn=ie(i)?!i:i},get silentFallbackWarn(){return ie(n.fallbackWarn)?!n.fallbackWarn:n.fallbackWarn},set silentFallbackWarn(i){n.fallbackWarn=ie(i)?!i:i},get modifiers(){return n.modifiers},get formatFallbackMessages(){return n.fallbackFormat},set formatFallbackMessages(i){n.fallbackFormat=i},get postTranslation(){return n.getPostTranslationHandler()},set postTranslation(i){n.setPostTranslationHandler(i)},get sync(){return n.inheritLocale},set sync(i){n.inheritLocale=i},get warnHtmlInMessage(){return n.warnHtmlMessage?"warn":"off"},set warnHtmlInMessage(i){n.warnHtmlMessage=i!=="off"},get escapeParameterHtml(){return n.escapeParameter},set escapeParameterHtml(i){n.escapeParameter=i},get preserveDirectiveContent(){return!0},set preserveDirectiveContent(i){},get pluralizationRules(){return n.pluralRules||{}},__composer:n,t(...i){const[o,a,l]=i,c={};let u=null,f=null;if(!z(o))throw De(Oe.INVALID_ARGUMENT);const h=o;return z(a)?c.locale=a:be(a)?u=a:te(a)&&(f=a),be(l)?u=l:te(l)&&(f=l),Reflect.apply(n.t,n,[h,u||f||{},c])},rt(...i){return Reflect.apply(n.rt,n,[...i])},tc(...i){const[o,a,l]=i,c={plural:1};let u=null,f=null;if(!z(o))throw De(Oe.INVALID_ARGUMENT);const h=o;return z(a)?c.locale=a:Ie(a)?c.plural=a:be(a)?u=a:te(a)&&(f=a),z(l)?c.locale=l:be(l)?u=l:te(l)&&(f=l),Reflect.apply(n.t,n,[h,u||f||{},c])},te(i,o){return n.te(i,o)},tm(i){return n.tm(i)},getLocaleMessage(i){return n.getLocaleMessage(i)},setLocaleMessage(i,o){n.setLocaleMessage(i,o)},mergeLocaleMessage(i,o){n.mergeLocaleMessage(i,o)},d(...i){return Reflect.apply(n.d,n,[...i])},getDateTimeFormat(i){return n.getDateTimeFormat(i)},setDateTimeFormat(i,o){n.setDateTimeFormat(i,o)},mergeDateTimeFormat(i,o){n.mergeDateTimeFormat(i,o)},n(...i){return Reflect.apply(n.n,n,[...i])},getNumberFormat(i){return n.getNumberFormat(i)},setNumberFormat(i,o){n.setNumberFormat(i,o)},mergeNumberFormat(i,o){n.mergeNumberFormat(i,o)},getChoiceIndex(i,o){return-1}};return s.__extender=r,s}}const Fi={tag:{type:[String,Object]},locale:{type:String},scope:{type:String,validator:e=>e==="parent"||e==="global",default:"parent"},i18n:{type:Object}};function qp({slots:e},t){return t.length===1&&t[0]==="default"?(e.default?e.default():[]).reduce((r,s)=>[...r,...s.type===Ge?s.children:[s]],[]):t.reduce((n,r)=>{const s=e[r];return s&&(n[r]=s()),n},he())}function $c(e){return Ge}const Yp=En({name:"i18n-t",props:xe({keypath:{type:String,required:!0},plural:{type:[Number,String],validator:e=>Ie(e)||!isNaN(e)}},Fi),setup(e,t){const{slots:n,attrs:r}=t,s=e.i18n||Ui({useScope:e.scope,__useComponent:!0});return()=>{const i=Object.keys(n).filter(f=>f!=="_"),o=he();e.locale&&(o.locale=e.locale),e.plural!==void 0&&(o.plural=z(e.plural)?+e.plural:e.plural);const a=qp(t,i),l=s[ii](e.keypath,a,o),c=xe(he(),r),u=z(e.tag)||ce(e.tag)?e.tag:$c();return Er(u,c,l)}}}),Na=Yp;function Xp(e){return be(e)&&!z(e[0])}function zc(e,t,n,r){const{slots:s,attrs:i}=t;return()=>{const o={part:!0};let a=he();e.locale&&(o.locale=e.locale),z(e.format)?o.key=e.format:ce(e.format)&&(z(e.format.key)&&(o.key=e.format.key),a=Object.keys(e.format).reduce((h,_)=>n.includes(_)?xe(he(),h,{[_]:e.format[_]}):h,he()));const l=r(e.value,o,a);let c=[o.key];be(l)?c=l.map((h,_)=>{const A=s[h.type],E=A?A({[h.type]:h.value,index:_,parts:l}):[h.value];return Xp(E)&&(E[0].key=`${h.type}-${_}`),E}):z(l)&&(c=[l]);const u=xe(he(),i),f=z(e.tag)||ce(e.tag)?e.tag:$c();return Er(f,u,c)}}const Jp=En({name:"i18n-n",props:xe({value:{type:Number,required:!0},format:{type:[String,Object]}},Fi),setup(e,t){const n=e.i18n||Ui({useScope:e.scope,__useComponent:!0});return zc(e,t,Uc,(...r)=>n[ai](...r))}}),Sa=Jp,Qp=En({name:"i18n-d",props:xe({value:{type:[Number,Date],required:!0},format:{type:[String,Object]}},Fi),setup(e,t){const n=e.i18n||Ui({useScope:e.scope,__useComponent:!0});return zc(e,t,Fc,(...r)=>n[oi](...r))}}),Ia=Qp;function Zp(e,t){const n=e;if(e.mode==="composition")return n.__getInstance(t)||e.global;{const r=n.__getInstance(t);return r!=null?r.__composer:e.global.__composer}}function eg(e){const t=o=>{const{instance:a,modifiers:l,value:c}=o;if(!a||!a.$)throw De(Oe.UNEXPECTED_ERROR);const u=Zp(e,a.$),f=ka(c);return[Reflect.apply(u.t,u,[...Ca(f)]),u]};return{created:(o,a)=>{const[l,c]=t(a);Br&&e.global===c&&(o.__i18nWatcher=Zt(c.locale,()=>{a.instance&&a.instance.$forceUpdate()})),o.__composer=c,o.textContent=l},unmounted:o=>{Br&&o.__i18nWatcher&&(o.__i18nWatcher(),o.__i18nWatcher=void 0,delete o.__i18nWatcher),o.__composer&&(o.__composer=void 0,delete o.__composer)},beforeUpdate:(o,{value:a})=>{if(o.__composer){const l=o.__composer,c=ka(a);o.textContent=Reflect.apply(l.t,l,[...Ca(c)])}},getSSRProps:o=>{const[a]=t(o);return{textContent:a}}}}function ka(e){if(z(e))return{path:e};if(te(e)){if(!("path"in e))throw De(Oe.REQUIRED_VALUE,"path");return e}else throw De(Oe.INVALID_VALUE)}function Ca(e){const{path:t,locale:n,args:r,choice:s,plural:i}=e,o={},a=r||{};return z(n)&&(o.locale=n),Ie(s)&&(o.plural=s),Ie(i)&&(o.plural=i),[t,a,o]}function tg(e,t,...n){const r=te(n[0])?n[0]:{},s=!!r.useI18nComponentName;(ie(r.globalInstall)?r.globalInstall:!0)&&([s?"i18n":Na.name,"I18nT"].forEach(o=>e.component(o,Na)),[Sa.name,"I18nN"].forEach(o=>e.component(o,Sa)),[Ia.name,"I18nD"].forEach(o=>e.component(o,Ia))),e.directive("t",eg(t))}function ng(e,t,n){return{beforeCreate(){const r=tn();if(!r)throw De(Oe.UNEXPECTED_ERROR);const s=this.$options;if(s.i18n){const i=s.i18n;if(s.__i18n&&(i.__i18n=s.__i18n),i.__root=t,this===this.$root)this.$i18n=Pa(e,i);else{i.__injectWithOption=!0,i.__extender=n.__vueI18nExtend,this.$i18n=ci(i);const o=this.$i18n;o.__extender&&(o.__disposer=o.__extender(this.$i18n))}}else if(s.__i18n)if(this===this.$root)this.$i18n=Pa(e,s);else{this.$i18n=ci({__i18n:s.__i18n,__injectWithOption:!0,__extender:n.__vueI18nExtend,__root:t});const i=this.$i18n;i.__extender&&(i.__disposer=i.__extender(this.$i18n))}else this.$i18n=e;s.__i18nGlobal&&Bc(t,s,s),this.$t=(...i)=>this.$i18n.t(...i),this.$rt=(...i)=>this.$i18n.rt(...i),this.$tc=(...i)=>this.$i18n.tc(...i),this.$te=(i,o)=>this.$i18n.te(i,o),this.$d=(...i)=>this.$i18n.d(...i),this.$n=(...i)=>this.$i18n.n(...i),this.$tm=i=>this.$i18n.tm(i),n.__setInstance(r,this.$i18n)},mounted(){},unmounted(){const r=tn();if(!r)throw De(Oe.UNEXPECTED_ERROR);const s=this.$i18n;delete this.$t,delete this.$rt,delete this.$tc,delete this.$te,delete this.$d,delete this.$n,delete this.$tm,s.__disposer&&(s.__disposer(),delete s.__disposer,delete s.__extender),n.__deleteInstance(r),delete this.$i18n}}}function Pa(e,t){e.locale=t.locale||e.locale,e.fallbackLocale=t.fallbackLocale||e.fallbackLocale,e.missing=t.missing||e.missing,e.silentTranslationWarn=t.silentTranslationWarn||e.silentFallbackWarn,e.silentFallbackWarn=t.silentFallbackWarn||e.silentFallbackWarn,e.formatFallbackMessages=t.formatFallbackMessages||e.formatFallbackMessages,e.postTranslation=t.postTranslation||e.postTranslation,e.warnHtmlInMessage=t.warnHtmlInMessage||e.warnHtmlInMessage,e.escapeParameterHtml=t.escapeParameterHtml||e.escapeParameterHtml,e.sync=t.sync||e.sync,e.__composer[Vc](t.pluralizationRules||e.pluralizationRules);const n=hs(e.locale,{messages:t.messages,__i18n:t.__i18n});return Object.keys(n).forEach(r=>e.mergeLocaleMessage(r,n[r])),t.datetimeFormats&&Object.keys(t.datetimeFormats).forEach(r=>e.mergeDateTimeFormat(r,t.datetimeFormats[r])),t.numberFormats&&Object.keys(t.numberFormats).forEach(r=>e.mergeNumberFormat(r,t.numberFormats[r])),e}const rg=rn("global-vue-i18n");function sg(e={},t){const n=__VUE_I18N_LEGACY_API__&&ie(e.legacy)?e.legacy:__VUE_I18N_LEGACY_API__,r=ie(e.globalInjection)?e.globalInjection:!0,s=__VUE_I18N_LEGACY_API__&&n?!!e.allowComposition:!0,i=new Map,[o,a]=ig(e,n),l=rn("");function c(h){return i.get(h)||null}function u(h,_){i.set(h,_)}function f(h){i.delete(h)}{const h={get mode(){return __VUE_I18N_LEGACY_API__&&n?"legacy":"composition"},get allowComposition(){return s},async install(_,...A){if(_.__VUE_I18N_SYMBOL__=l,_.provide(_.__VUE_I18N_SYMBOL__,h),te(A[0])){const R=A[0];h.__composerExtend=R.__composerExtend,h.__vueI18nExtend=R.__vueI18nExtend}let E=null;!n&&r&&(E=hg(_,h.global)),__VUE_I18N_FULL_INSTALL__&&tg(_,h,...A),__VUE_I18N_LEGACY_API__&&n&&_.mixin(ng(a,a.__composer,h));const O=_.unmount;_.unmount=()=>{E&&E(),h.dispose(),O()}},get global(){return a},dispose(){o.stop()},__instances:i,__getInstance:c,__setInstance:u,__deleteInstance:f};return h}}function Ui(e={}){const t=tn();if(t==null)throw De(Oe.MUST_BE_CALL_SETUP_TOP);if(!t.isCE&&t.appContext.app!=null&&!t.appContext.app.__VUE_I18N_SYMBOL__)throw De(Oe.NOT_INSTALLED);const n=og(t),r=lg(n),s=Wc(t),i=ag(e,s);if(__VUE_I18N_LEGACY_API__&&n.mode==="legacy"&&!e.__useComponent){if(!n.allowComposition)throw De(Oe.NOT_AVAILABLE_IN_LEGACY_MODE);return dg(t,i,r,e)}if(i==="global")return Bc(r,e,s),r;if(i==="parent"){let l=cg(n,t,e.__useComponent);return l==null&&(l=r),l}const o=n;let a=o.__getInstance(t);if(a==null){const l=xe({},e);"__i18n"in s&&(l.__i18n=s.__i18n),r&&(l.__root=r),a=xi(l),o.__composerExtend&&(a[li]=o.__composerExtend(a)),fg(o,t,a),o.__setInstance(t,a)}return a}function ig(e,t,n){const r=pi();{const s=__VUE_I18N_LEGACY_API__&&t?r.run(()=>ci(e)):r.run(()=>xi(e));if(s==null)throw De(Oe.UNEXPECTED_ERROR);return[r,s]}}function og(e){{const t=at(e.isCE?rg:e.appContext.app.__VUE_I18N_SYMBOL__);if(!t)throw De(e.isCE?Oe.NOT_INSTALLED_WITH_PROVIDE:Oe.UNEXPECTED_ERROR);return t}}function ag(e,t){return fs(e)?"__i18n"in t?"local":"global":e.useScope?e.useScope:"local"}function lg(e){return e.mode==="composition"?e.global:e.global.__composer}function cg(e,t,n=!1){let r=null;const s=t.root;let i=ug(t,n);for(;i!=null;){const o=e;if(e.mode==="composition")r=o.__getInstance(i);else if(__VUE_I18N_LEGACY_API__){const a=o.__getInstance(i);a!=null&&(r=a.__composer,n&&r&&!r[Hc]&&(r=null))}if(r!=null||s===i)break;i=i.parent}return r}function ug(e,t=!1){return e==null?null:t&&e.vnode.ctx||e.parent}function fg(e,t,n){vr(()=>{},t),is(()=>{const r=n;e.__deleteInstance(t);const s=r[li];s&&(s(),delete r[li])},t)}function dg(e,t,n,r={}){const s=t==="local",i=wi(null);if(s&&e.proxy&&!(e.proxy.$options.i18n||e.proxy.$options.__i18n))throw De(Oe.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION);const o=ie(r.inheritLocale)?r.inheritLocale:!z(r.locale),a=Pe(!s||o?n.locale.value:z(r.locale)?r.locale:xn),l=Pe(!s||o?n.fallbackLocale.value:z(r.fallbackLocale)||be(r.fallbackLocale)||te(r.fallbackLocale)||r.fallbackLocale===!1?r.fallbackLocale:a.value),c=Pe(hs(a.value,r)),u=Pe(te(r.datetimeFormats)?r.datetimeFormats:{[a.value]:{}}),f=Pe(te(r.numberFormats)?r.numberFormats:{[a.value]:{}}),h=s?n.missingWarn:ie(r.missingWarn)||nn(r.missingWarn)?r.missingWarn:!0,_=s?n.fallbackWarn:ie(r.fallbackWarn)||nn(r.fallbackWarn)?r.fallbackWarn:!0,A=s?n.fallbackRoot:ie(r.fallbackRoot)?r.fallbackRoot:!0,E=!!r.fallbackFormat,O=ve(r.missing)?r.missing:null,R=ve(r.postTranslation)?r.postTranslation:null,x=s?n.warnHtmlMessage:ie(r.warnHtmlMessage)?r.warnHtmlMessage:!0,y=!!r.escapeParameter,b=s?n.modifiers:te(r.modifiers)?r.modifiers:{},I=r.pluralRules||s&&n.pluralRules;function k(){return[a.value,l.value,c.value,u.value,f.value]}const M=ue({get:()=>i.value?i.value.locale.value:a.value,set:g=>{i.value&&(i.value.locale.value=g),a.value=g}}),j=ue({get:()=>i.value?i.value.fallbackLocale.value:l.value,set:g=>{i.value&&(i.value.fallbackLocale.value=g),l.value=g}}),S=ue(()=>i.value?i.value.messages.value:c.value),G=ue(()=>u.value),Z=ue(()=>f.value);function U(){return i.value?i.value.getPostTranslationHandler():R}function J(g){i.value&&i.value.setPostTranslationHandler(g)}function ge(){return i.value?i.value.getMissingHandler():O}function Se(g){i.value&&i.value.setMissingHandler(g)}function se(g){return k(),g()}function ee(...g){return i.value?se(()=>Reflect.apply(i.value.t,null,[...g])):se(()=>"")}function oe(...g){return i.value?Reflect.apply(i.value.rt,null,[...g]):""}function He(...g){return i.value?se(()=>Reflect.apply(i.value.d,null,[...g])):se(()=>"")}function Xe(...g){return i.value?se(()=>Reflect.apply(i.value.n,null,[...g])):se(()=>"")}function we(g){return i.value?i.value.tm(g):{}}function Ae(g,N){return i.value?i.value.te(g,N):!1}function lt(g){return i.value?i.value.getLocaleMessage(g):{}}function et(g,N){i.value&&(i.value.setLocaleMessage(g,N),c.value[g]=N)}function tt(g,N){i.value&&i.value.mergeLocaleMessage(g,N)}function Re(g){return i.value?i.value.getDateTimeFormat(g):{}}function D(g,N){i.value&&(i.value.setDateTimeFormat(g,N),u.value[g]=N)}function K(g,N){i.value&&i.value.mergeDateTimeFormat(g,N)}function $(g){return i.value?i.value.getNumberFormat(g):{}}function q(g,N){i.value&&(i.value.setNumberFormat(g,N),f.value[g]=N)}function re(g,N){i.value&&i.value.mergeNumberFormat(g,N)}const p={get id(){return i.value?i.value.id:-1},locale:M,fallbackLocale:j,messages:S,datetimeFormats:G,numberFormats:Z,get inheritLocale(){return i.value?i.value.inheritLocale:o},set inheritLocale(g){i.value&&(i.value.inheritLocale=g)},get availableLocales(){return i.value?i.value.availableLocales:Object.keys(c.value)},get modifiers(){return i.value?i.value.modifiers:b},get pluralRules(){return i.value?i.value.pluralRules:I},get isGlobal(){return i.value?i.value.isGlobal:!1},get missingWarn(){return i.value?i.value.missingWarn:h},set missingWarn(g){i.value&&(i.value.missingWarn=g)},get fallbackWarn(){return i.value?i.value.fallbackWarn:_},set fallbackWarn(g){i.value&&(i.value.missingWarn=g)},get fallbackRoot(){return i.value?i.value.fallbackRoot:A},set fallbackRoot(g){i.value&&(i.value.fallbackRoot=g)},get fallbackFormat(){return i.value?i.value.fallbackFormat:E},set fallbackFormat(g){i.value&&(i.value.fallbackFormat=g)},get warnHtmlMessage(){return i.value?i.value.warnHtmlMessage:x},set warnHtmlMessage(g){i.value&&(i.value.warnHtmlMessage=g)},get escapeParameter(){return i.value?i.value.escapeParameter:y},set escapeParameter(g){i.value&&(i.value.escapeParameter=g)},t:ee,getPostTranslationHandler:U,setPostTranslationHandler:J,getMissingHandler:ge,setMissingHandler:Se,rt:oe,d:He,n:Xe,tm:we,te:Ae,getLocaleMessage:lt,setLocaleMessage:et,mergeLocaleMessage:tt,getDateTimeFormat:Re,setDateTimeFormat:D,mergeDateTimeFormat:K,getNumberFormat:$,setNumberFormat:q,mergeNumberFormat:re};function v(g){g.locale.value=a.value,g.fallbackLocale.value=l.value,Object.keys(c.value).forEach(N=>{g.mergeLocaleMessage(N,c.value[N])}),Object.keys(u.value).forEach(N=>{g.mergeDateTimeFormat(N,u.value[N])}),Object.keys(f.value).forEach(N=>{g.mergeNumberFormat(N,f.value[N])}),g.escapeParameter=y,g.fallbackFormat=E,g.fallbackRoot=A,g.fallbackWarn=_,g.missingWarn=h,g.warnHtmlMessage=x}return yl(()=>{if(e.proxy==null||e.proxy.$i18n==null)throw De(Oe.NOT_AVAILABLE_COMPOSITION_IN_LEGACY);const g=i.value=e.proxy.$i18n.__composer;t==="global"?(a.value=g.locale.value,l.value=g.fallbackLocale.value,c.value=g.messages.value,u.value=g.datetimeFormats.value,f.value=g.numberFormats.value):s&&v(g)}),p}const mg=["locale","fallbackLocale","availableLocales"],Oa=["t","rt","d","n","tm","te"];function hg(e,t){const n=Object.create(null);return mg.forEach(s=>{const i=Object.getOwnPropertyDescriptor(t,s);if(!i)throw De(Oe.UNEXPECTED_ERROR);const o=Te(i.value)?{get(){return i.value.value},set(a){i.value.value=a}}:{get(){return i.get&&i.get()}};Object.defineProperty(n,s,o)}),e.config.globalProperties.$i18n=n,Oa.forEach(s=>{const i=Object.getOwnPropertyDescriptor(t,s);if(!i||!i.value)throw De(Oe.UNEXPECTED_ERROR);Object.defineProperty(e.config.globalProperties,`$${s}`,i)}),()=>{delete e.config.globalProperties.$i18n,Oa.forEach(s=>{delete e.config.globalProperties[`$${s}`]})}}Bp();__INTLIFY_JIT_COMPILATION__?ua(Fp):ua(xp);Ip(ap);kp(Ic);if(__INTLIFY_PROD_DEVTOOLS__){const e=jt();e.__INTLIFY__=!0,gp(e.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__)}const pg={app:{name:"SeCu",title:"Mitarbeiterverwaltung",loading:"Laden...",save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",search:"Suchen",filter:"Filtern",actions:"Aktionen",close:"Schließen",confirm:"Bestätigen",yes:"Ja",no:"Nein",back:"Zurück",next:"Weiter",submit:"Absenden",reset:"Zurücksetzen",export:"Exportieren",import:"Importieren",download:"Herunterladen",upload:"Hochladen",all:"Alle",none:"Keine",status:"Status",date:"Datum",time:"Zeit",from:"Von",to:"Bis",total:"Gesamt",details:"Details",description:"Beschreibung",notes:"Notizen",created:"Erstellt",updated:"Aktualisiert"},auth:{login:"Anmelden",logout:"Abmelden",register:"Registrieren",email:"E-Mail",password:"Passwort",confirmPassword:"Passwort bestätigen",forgotPassword:"Passwort vergessen?",rememberMe:"Angemeldet bleiben",welcomeBack:"Willkommen zurück",loginToContinue:"Melden Sie sich an, um fortzufahren",noAccount:"Noch kein Konto?",hasAccount:"Bereits ein Konto?",createOrg:"Organisation erstellen",orgName:"Firmenname",firstName:"Vorname",lastName:"Nachname"},nav:{dashboard:"Dashboard",orders:"Aufträge",users:"Mitarbeiter",shifts:"Schichtplanung",availability:"Verfügbarkeit",timesheets:"Stundenzettel",qualifications:"Qualifikationen",objects:"Objekte",patrols:"Rundgänge",incidents:"Vorfälle",documents:"Dokumente",vehicles:"Fahrzeuge",customers:"Kunden",billing:"Abrechnung",modules:"Module",settings:"Einstellungen",help:"Hilfe",partnerships:"Partnerschaften"},dashboard:{welcome:"Willkommen",overview:"Übersicht",todayOrders:"Heutige Aufträge",activeEmployees:"Aktive Mitarbeiter",openIncidents:"Offene Vorfälle",pendingTimesheets:"Ausstehende Stundenzettel",recentActivity:"Letzte Aktivitäten",upcomingShifts:"Kommende Schichten",expiringQualifications:"Ablaufende Qualifikationen",quickActions:"Schnellaktionen"},orders:{title:"Aufträge",new:"Neuer Auftrag",orderNumber:"Auftragsnummer",client:"Kunde",location:"Einsatzort",startDate:"Startdatum",endDate:"Enddatum",assignedTo:"Zugewiesen an",priority:"Priorität",priorities:{low:"Niedrig",medium:"Mittel",high:"Hoch",urgent:"Dringend"},statuses:{draft:"Entwurf",scheduled:"Geplant",active:"Aktiv",completed:"Abgeschlossen",cancelled:"Storniert"}},users:{title:"Mitarbeiter",new:"Neuer Mitarbeiter",employee:"Mitarbeiter",employees:"Mitarbeiter",role:"Rolle",roles:{chef:"Chef",disponent:"Disponent",mitarbeiter:"Mitarbeiter"},phone:"Telefon",address:"Adresse",hireDate:"Einstellungsdatum",active:"Aktiv",inactive:"Inaktiv"},shifts:{title:"Schichtplanung",new:"Neue Schicht",shift:"Schicht",shiftPlan:"Schichtplan",morning:"Frühschicht",afternoon:"Spätschicht",night:"Nachtschicht",startTime:"Startzeit",endTime:"Endzeit",break:"Pause",assigned:"Zugewiesen",unassigned:"Nicht zugewiesen",swapRequest:"Tausch anfragen",approve:"Genehmigen",reject:"Ablehnen"},availability:{title:"Verfügbarkeit",available:"Verfügbar",unavailable:"Nicht verfügbar",partiallyAvailable:"Teilweise verfügbar",setAvailability:"Verfügbarkeit eintragen",reason:"Grund",vacation:"Urlaub",sick:"Krank",training:"Fortbildung",other:"Sonstiges"},timesheets:{title:"Stundenzettel",new:"Neuer Eintrag",hours:"Stunden",totalHours:"Gesamtstunden",workDate:"Arbeitstag",checkIn:"Einstempeln",checkOut:"Ausstempeln",breakTime:"Pausenzeit",overtime:"Überstunden",upload:"Stundenzettel hochladen",statuses:{pending:"Ausstehend",approved:"Genehmigt",rejected:"Abgelehnt"}},qualifications:{title:"Qualifikationen",new:"Neue Qualifikation",type:"Art",types:{"34a":"§34a Sachkundeprüfung",first_aid:"Erste-Hilfe-Kurs",fire_safety:"Brandschutzhelfer",security_check:"Sicherheitsüberprüfung",drivers_license:"Führerschein",other:"Sonstige"},issueDate:"Ausstellungsdatum",expiryDate:"Ablaufdatum",issuedBy:"Ausgestellt von",valid:"Gültig",expired:"Abgelaufen",expiringSoon:"Läuft bald ab",daysUntilExpiry:"Tage bis Ablauf",reminder:"Erinnerung"},objects:{title:"Objekte",new:"Neues Objekt",object:"Objekt",name:"Name",address:"Adresse",contact:"Ansprechpartner",phone:"Telefon",instructions:"Dienstanweisungen",documents:"Dokumente",accessInfo:"Zugangsinformationen"},patrols:{title:"Rundgänge",new:"Neuer Rundgang",checkpoint:"Checkpoint",checkpoints:"Checkpoints",route:"Route",routes:"Routen",log:"Protokoll",logs:"Protokolle",scanned:"Gescannt",missed:"Verpasst",scanTime:"Scan-Zeit",expectedTime:"Erwartete Zeit",deviation:"Abweichung"},incidents:{title:"Vorfälle",new:"Neuer Vorfall",incident:"Vorfall",category:"Kategorie",categories:{theft:"Diebstahl",vandalism:"Vandalismus",trespassing:"Hausfriedensbruch",fire:"Brand",medical:"Medizinischer Notfall",technical:"Technisches Problem",other:"Sonstiges"},severity:"Schweregrad",severities:{low:"Niedrig",medium:"Mittel",high:"Hoch",critical:"Kritisch"},reporter:"Gemeldet von",location:"Ort",witnesses:"Zeugen",attachments:"Anhänge",resolved:"Gelöst",unresolved:"Ungelöst"},documents:{title:"Dokumente",new:"Neues Dokument",document:"Dokument",category:"Kategorie",categories:{contract:"Vertrag",certificate:"Zertifikat",policy:"Richtlinie",manual:"Handbuch",form:"Formular",other:"Sonstiges"},uploadDate:"Hochgeladen am",fileType:"Dateityp",fileSize:"Dateigröße",mandatory:"Pflichtdokument",acknowledged:"Bestätigt",acknowledgement:"Kenntnisnahme"},vehicles:{title:"Fahrzeuge",new:"Neues Fahrzeug",vehicle:"Fahrzeug",licensePlate:"Kennzeichen",make:"Marke",model:"Modell",year:"Baujahr",mileage:"Kilometerstand",fuelLevel:"Tankstand",status:"Status",statuses:{available:"Verfügbar",inUse:"In Benutzung",maintenance:"Wartung",outOfService:"Außer Betrieb"},booking:"Buchung",bookings:"Buchungen",maintenance:"Wartung",nextService:"Nächste Wartung"},customers:{title:"Kunden",new:"Neuer Kunde",customer:"Kunde",company:"Firma",contact:"Ansprechpartner",email:"E-Mail",phone:"Telefon",address:"Adresse",contracts:"Verträge",communication:"Kommunikation",notes:"Notizen"},billing:{title:"Abrechnung",invoices:"Rechnungen",newInvoice:"Neue Rechnung",invoice:"Rechnung",invoiceNumber:"Rechnungsnummer",amount:"Betrag",tax:"MwSt.",subtotal:"Zwischensumme",total:"Gesamt",dueDate:"Fälligkeitsdatum",paidDate:"Bezahlt am",statuses:{draft:"Entwurf",sent:"Versendet",paid:"Bezahlt",overdue:"Überfällig",cancelled:"Storniert"},hourlyRates:"Stundensätze",rate:"Satz",reminders:"Mahnungen"},modules:{title:"Module",enabled:"Aktiviert",disabled:"Deaktiviert",enable:"Aktivieren",disable:"Deaktivieren",configure:"Konfigurieren"},settings:{title:"Einstellungen",profile:"Profil",account:"Konto",notifications:"Benachrichtigungen",security:"Sicherheit",language:"Sprache",theme:"Design",darkMode:"Dunkelmodus",lightMode:"Hellmodus",changePassword:"Passwort ändern",twoFactor:"Zwei-Faktor-Authentifizierung",lockScreen:"Bildschirmsperre",lockMethod:"Sperrmethode",pin:"PIN",pattern:"Muster"},help:{title:"Hilfe & Support",faq:"Häufige Fragen",contact:"Kontakt",documentation:"Dokumentation",tutorials:"Tutorials",feedback:"Feedback"},messages:{success:"Erfolgreich",error:"Fehler",warning:"Warnung",info:"Information",saved:"Gespeichert",deleted:"Gelöscht",updated:"Aktualisiert",created:"Erstellt",confirmDelete:"Sind Sie sicher, dass Sie dies löschen möchten?",noData:"Keine Daten vorhanden",loading:"Wird geladen...",required:"Pflichtfeld",invalid:"Ungültige Eingabe"},time:{today:"Heute",yesterday:"Gestern",tomorrow:"Morgen",thisWeek:"Diese Woche",lastWeek:"Letzte Woche",thisMonth:"Dieser Monat",lastMonth:"Letzter Monat",days:"Tage",hours:"Stunden",minutes:"Minuten"}},gg={app:{name:"SeCu",title:"Employee Management",loading:"Loading...",save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",search:"Search",filter:"Filter",actions:"Actions",close:"Close",confirm:"Confirm",yes:"Yes",no:"No",back:"Back",next:"Next",submit:"Submit",reset:"Reset",export:"Export",import:"Import",download:"Download",upload:"Upload",all:"All",none:"None",status:"Status",date:"Date",time:"Time",from:"From",to:"To",total:"Total",details:"Details",description:"Description",notes:"Notes",created:"Created",updated:"Updated"},auth:{login:"Login",logout:"Logout",register:"Register",email:"Email",password:"Password",confirmPassword:"Confirm Password",forgotPassword:"Forgot Password?",rememberMe:"Remember me",welcomeBack:"Welcome back",loginToContinue:"Sign in to continue",noAccount:"No account yet?",hasAccount:"Already have an account?",createOrg:"Create Organization",orgName:"Company Name",firstName:"First Name",lastName:"Last Name"},nav:{dashboard:"Dashboard",orders:"Orders",users:"Employees",shifts:"Shift Planning",availability:"Availability",timesheets:"Timesheets",qualifications:"Qualifications",objects:"Objects",patrols:"Patrols",incidents:"Incidents",documents:"Documents",vehicles:"Vehicles",customers:"Customers",billing:"Billing",modules:"Modules",settings:"Settings",help:"Help",partnerships:"Partnerships"},dashboard:{welcome:"Welcome",overview:"Overview",todayOrders:"Today's Orders",activeEmployees:"Active Employees",openIncidents:"Open Incidents",pendingTimesheets:"Pending Timesheets",recentActivity:"Recent Activity",upcomingShifts:"Upcoming Shifts",expiringQualifications:"Expiring Qualifications",quickActions:"Quick Actions"},orders:{title:"Orders",new:"New Order",orderNumber:"Order Number",client:"Client",location:"Location",startDate:"Start Date",endDate:"End Date",assignedTo:"Assigned To",priority:"Priority",priorities:{low:"Low",medium:"Medium",high:"High",urgent:"Urgent"},statuses:{draft:"Draft",scheduled:"Scheduled",active:"Active",completed:"Completed",cancelled:"Cancelled"}},users:{title:"Employees",new:"New Employee",employee:"Employee",employees:"Employees",role:"Role",roles:{chef:"Manager",disponent:"Dispatcher",mitarbeiter:"Employee"},phone:"Phone",address:"Address",hireDate:"Hire Date",active:"Active",inactive:"Inactive"},shifts:{title:"Shift Planning",new:"New Shift",shift:"Shift",shiftPlan:"Shift Plan",morning:"Morning Shift",afternoon:"Afternoon Shift",night:"Night Shift",startTime:"Start Time",endTime:"End Time",break:"Break",assigned:"Assigned",unassigned:"Unassigned",swapRequest:"Request Swap",approve:"Approve",reject:"Reject"},availability:{title:"Availability",available:"Available",unavailable:"Unavailable",partiallyAvailable:"Partially Available",setAvailability:"Set Availability",reason:"Reason",vacation:"Vacation",sick:"Sick",training:"Training",other:"Other"},timesheets:{title:"Timesheets",new:"New Entry",hours:"Hours",totalHours:"Total Hours",workDate:"Work Date",checkIn:"Check In",checkOut:"Check Out",breakTime:"Break Time",overtime:"Overtime",upload:"Upload Timesheet",statuses:{pending:"Pending",approved:"Approved",rejected:"Rejected"}},qualifications:{title:"Qualifications",new:"New Qualification",type:"Type",types:{"34a":"§34a Security Certificate",first_aid:"First Aid Course",fire_safety:"Fire Safety",security_check:"Security Clearance",drivers_license:"Driver's License",other:"Other"},issueDate:"Issue Date",expiryDate:"Expiry Date",issuedBy:"Issued By",valid:"Valid",expired:"Expired",expiringSoon:"Expiring Soon",daysUntilExpiry:"Days Until Expiry",reminder:"Reminder"},objects:{title:"Objects",new:"New Object",object:"Object",name:"Name",address:"Address",contact:"Contact Person",phone:"Phone",instructions:"Instructions",documents:"Documents",accessInfo:"Access Information"},patrols:{title:"Patrols",new:"New Patrol",checkpoint:"Checkpoint",checkpoints:"Checkpoints",route:"Route",routes:"Routes",log:"Log",logs:"Logs",scanned:"Scanned",missed:"Missed",scanTime:"Scan Time",expectedTime:"Expected Time",deviation:"Deviation"},incidents:{title:"Incidents",new:"New Incident",incident:"Incident",category:"Category",categories:{theft:"Theft",vandalism:"Vandalism",trespassing:"Trespassing",fire:"Fire",medical:"Medical Emergency",technical:"Technical Issue",other:"Other"},severity:"Severity",severities:{low:"Low",medium:"Medium",high:"High",critical:"Critical"},reporter:"Reported By",location:"Location",witnesses:"Witnesses",attachments:"Attachments",resolved:"Resolved",unresolved:"Unresolved"},documents:{title:"Documents",new:"New Document",document:"Document",category:"Category",categories:{contract:"Contract",certificate:"Certificate",policy:"Policy",manual:"Manual",form:"Form",other:"Other"},uploadDate:"Upload Date",fileType:"File Type",fileSize:"File Size",mandatory:"Mandatory",acknowledged:"Acknowledged",acknowledgement:"Acknowledgement"},vehicles:{title:"Vehicles",new:"New Vehicle",vehicle:"Vehicle",licensePlate:"License Plate",make:"Make",model:"Model",year:"Year",mileage:"Mileage",fuelLevel:"Fuel Level",status:"Status",statuses:{available:"Available",inUse:"In Use",maintenance:"Maintenance",outOfService:"Out of Service"},booking:"Booking",bookings:"Bookings",maintenance:"Maintenance",nextService:"Next Service"},customers:{title:"Customers",new:"New Customer",customer:"Customer",company:"Company",contact:"Contact Person",email:"Email",phone:"Phone",address:"Address",contracts:"Contracts",communication:"Communication",notes:"Notes"},billing:{title:"Billing",invoices:"Invoices",newInvoice:"New Invoice",invoice:"Invoice",invoiceNumber:"Invoice Number",amount:"Amount",tax:"Tax",subtotal:"Subtotal",total:"Total",dueDate:"Due Date",paidDate:"Paid Date",statuses:{draft:"Draft",sent:"Sent",paid:"Paid",overdue:"Overdue",cancelled:"Cancelled"},hourlyRates:"Hourly Rates",rate:"Rate",reminders:"Reminders"},modules:{title:"Modules",enabled:"Enabled",disabled:"Disabled",enable:"Enable",disable:"Disable",configure:"Configure"},settings:{title:"Settings",profile:"Profile",account:"Account",notifications:"Notifications",security:"Security",language:"Language",theme:"Theme",darkMode:"Dark Mode",lightMode:"Light Mode",changePassword:"Change Password",twoFactor:"Two-Factor Authentication",lockScreen:"Lock Screen",lockMethod:"Lock Method",pin:"PIN",pattern:"Pattern"},help:{title:"Help & Support",faq:"FAQ",contact:"Contact",documentation:"Documentation",tutorials:"Tutorials",feedback:"Feedback"},messages:{success:"Success",error:"Error",warning:"Warning",info:"Information",saved:"Saved",deleted:"Deleted",updated:"Updated",created:"Created",confirmDelete:"Are you sure you want to delete this?",noData:"No data available",loading:"Loading...",required:"Required field",invalid:"Invalid input"},time:{today:"Today",yesterday:"Yesterday",tomorrow:"Tomorrow",thisWeek:"This Week",lastWeek:"Last Week",thisMonth:"This Month",lastMonth:"Last Month",days:"days",hours:"hours",minutes:"minutes"}},_g={app:{name:"SeCu",title:"Gestión de Empleados",loading:"Cargando...",save:"Guardar",cancel:"Cancelar",delete:"Eliminar",edit:"Editar",add:"Añadir",search:"Buscar",filter:"Filtrar",actions:"Acciones",close:"Cerrar",confirm:"Confirmar",yes:"Sí",no:"No",back:"Atrás",next:"Siguiente",submit:"Enviar",reset:"Restablecer",export:"Exportar",import:"Importar",download:"Descargar",upload:"Subir",all:"Todos",none:"Ninguno",status:"Estado",date:"Fecha",time:"Hora",from:"Desde",to:"Hasta",total:"Total",details:"Detalles",description:"Descripción",notes:"Notas",created:"Creado",updated:"Actualizado"},auth:{login:"Iniciar sesión",logout:"Cerrar sesión",register:"Registrarse",email:"Correo electrónico",password:"Contraseña",confirmPassword:"Confirmar contraseña",forgotPassword:"¿Olvidaste tu contraseña?",rememberMe:"Recordarme",welcomeBack:"Bienvenido de nuevo",loginToContinue:"Inicia sesión para continuar",noAccount:"¿No tienes cuenta?",hasAccount:"¿Ya tienes una cuenta?",createOrg:"Crear organización",orgName:"Nombre de la empresa",firstName:"Nombre",lastName:"Apellido"},nav:{dashboard:"Panel",orders:"Pedidos",users:"Empleados",shifts:"Planificación de turnos",availability:"Disponibilidad",timesheets:"Hojas de horas",qualifications:"Cualificaciones",objects:"Objetos",patrols:"Rondas",incidents:"Incidentes",documents:"Documentos",vehicles:"Vehículos",customers:"Clientes",billing:"Facturación",modules:"Módulos",settings:"Configuración",help:"Ayuda",partnerships:"Asociaciones"},dashboard:{welcome:"Bienvenido",overview:"Resumen",todayOrders:"Pedidos de hoy",activeEmployees:"Empleados activos",openIncidents:"Incidentes abiertos",pendingTimesheets:"Hojas de horas pendientes",recentActivity:"Actividad reciente",upcomingShifts:"Próximos turnos",expiringQualifications:"Cualificaciones por vencer",quickActions:"Acciones rápidas"},orders:{title:"Pedidos",new:"Nuevo pedido",orderNumber:"Número de pedido",client:"Cliente",location:"Ubicación",startDate:"Fecha de inicio",endDate:"Fecha de fin",assignedTo:"Asignado a",priority:"Prioridad",priorities:{low:"Baja",medium:"Media",high:"Alta",urgent:"Urgente"},statuses:{draft:"Borrador",scheduled:"Programado",active:"Activo",completed:"Completado",cancelled:"Cancelado"}},users:{title:"Empleados",new:"Nuevo empleado",employee:"Empleado",employees:"Empleados",role:"Rol",roles:{chef:"Gerente",disponent:"Despachador",mitarbeiter:"Empleado"},phone:"Teléfono",address:"Dirección",hireDate:"Fecha de contratación",active:"Activo",inactive:"Inactivo"},shifts:{title:"Planificación de turnos",new:"Nuevo turno",shift:"Turno",shiftPlan:"Plan de turnos",morning:"Turno de mañana",afternoon:"Turno de tarde",night:"Turno de noche",startTime:"Hora de inicio",endTime:"Hora de fin",break:"Descanso",assigned:"Asignado",unassigned:"Sin asignar",swapRequest:"Solicitar cambio",approve:"Aprobar",reject:"Rechazar"},availability:{title:"Disponibilidad",available:"Disponible",unavailable:"No disponible",partiallyAvailable:"Parcialmente disponible",setAvailability:"Establecer disponibilidad",reason:"Motivo",vacation:"Vacaciones",sick:"Enfermedad",training:"Formación",other:"Otro"},timesheets:{title:"Hojas de horas",new:"Nueva entrada",hours:"Horas",totalHours:"Horas totales",workDate:"Día de trabajo",checkIn:"Entrada",checkOut:"Salida",breakTime:"Tiempo de descanso",overtime:"Horas extra",upload:"Subir hoja de horas",statuses:{pending:"Pendiente",approved:"Aprobado",rejected:"Rechazado"}},qualifications:{title:"Cualificaciones",new:"Nueva cualificación",type:"Tipo",types:{"34a":"Certificado de seguridad §34a",first_aid:"Curso de primeros auxilios",fire_safety:"Seguridad contra incendios",security_check:"Verificación de seguridad",drivers_license:"Licencia de conducir",other:"Otro"},issueDate:"Fecha de emisión",expiryDate:"Fecha de vencimiento",issuedBy:"Emitido por",valid:"Válido",expired:"Vencido",expiringSoon:"Próximo a vencer",daysUntilExpiry:"Días hasta el vencimiento",reminder:"Recordatorio"},objects:{title:"Objetos",new:"Nuevo objeto",object:"Objeto",name:"Nombre",address:"Dirección",contact:"Persona de contacto",phone:"Teléfono",instructions:"Instrucciones",documents:"Documentos",accessInfo:"Información de acceso"},patrols:{title:"Rondas",new:"Nueva ronda",checkpoint:"Punto de control",checkpoints:"Puntos de control",route:"Ruta",routes:"Rutas",log:"Registro",logs:"Registros",scanned:"Escaneado",missed:"Perdido",scanTime:"Hora de escaneo",expectedTime:"Hora esperada",deviation:"Desviación"},incidents:{title:"Incidentes",new:"Nuevo incidente",incident:"Incidente",category:"Categoría",categories:{theft:"Robo",vandalism:"Vandalismo",trespassing:"Allanamiento",fire:"Incendio",medical:"Emergencia médica",technical:"Problema técnico",other:"Otro"},severity:"Gravedad",severities:{low:"Baja",medium:"Media",high:"Alta",critical:"Crítica"},reporter:"Reportado por",location:"Ubicación",witnesses:"Testigos",attachments:"Adjuntos",resolved:"Resuelto",unresolved:"Sin resolver"},documents:{title:"Documentos",new:"Nuevo documento",document:"Documento",category:"Categoría",categories:{contract:"Contrato",certificate:"Certificado",policy:"Política",manual:"Manual",form:"Formulario",other:"Otro"},uploadDate:"Fecha de subida",fileType:"Tipo de archivo",fileSize:"Tamaño de archivo",mandatory:"Obligatorio",acknowledged:"Reconocido",acknowledgement:"Reconocimiento"},vehicles:{title:"Vehículos",new:"Nuevo vehículo",vehicle:"Vehículo",licensePlate:"Matrícula",make:"Marca",model:"Modelo",year:"Año",mileage:"Kilometraje",fuelLevel:"Nivel de combustible",status:"Estado",statuses:{available:"Disponible",inUse:"En uso",maintenance:"Mantenimiento",outOfService:"Fuera de servicio"},booking:"Reserva",bookings:"Reservas",maintenance:"Mantenimiento",nextService:"Próximo servicio"},customers:{title:"Clientes",new:"Nuevo cliente",customer:"Cliente",company:"Empresa",contact:"Persona de contacto",email:"Correo electrónico",phone:"Teléfono",address:"Dirección",contracts:"Contratos",communication:"Comunicación",notes:"Notas"},billing:{title:"Facturación",invoices:"Facturas",newInvoice:"Nueva factura",invoice:"Factura",invoiceNumber:"Número de factura",amount:"Importe",tax:"IVA",subtotal:"Subtotal",total:"Total",dueDate:"Fecha de vencimiento",paidDate:"Fecha de pago",statuses:{draft:"Borrador",sent:"Enviado",paid:"Pagado",overdue:"Vencido",cancelled:"Cancelado"},hourlyRates:"Tarifas por hora",rate:"Tarifa",reminders:"Recordatorios"},modules:{title:"Módulos",enabled:"Activado",disabled:"Desactivado",enable:"Activar",disable:"Desactivar",configure:"Configurar"},settings:{title:"Configuración",profile:"Perfil",account:"Cuenta",notifications:"Notificaciones",security:"Seguridad",language:"Idioma",theme:"Tema",darkMode:"Modo oscuro",lightMode:"Modo claro",changePassword:"Cambiar contraseña",twoFactor:"Autenticación de dos factores",lockScreen:"Pantalla de bloqueo",lockMethod:"Método de bloqueo",pin:"PIN",pattern:"Patrón"},help:{title:"Ayuda y soporte",faq:"Preguntas frecuentes",contact:"Contacto",documentation:"Documentación",tutorials:"Tutoriales",feedback:"Comentarios"},messages:{success:"Éxito",error:"Error",warning:"Advertencia",info:"Información",saved:"Guardado",deleted:"Eliminado",updated:"Actualizado",created:"Creado",confirmDelete:"¿Estás seguro de que quieres eliminar esto?",noData:"No hay datos disponibles",loading:"Cargando...",required:"Campo obligatorio",invalid:"Entrada inválida"},time:{today:"Hoy",yesterday:"Ayer",tomorrow:"Mañana",thisWeek:"Esta semana",lastWeek:"La semana pasada",thisMonth:"Este mes",lastMonth:"El mes pasado",days:"días",hours:"horas",minutes:"minutos"}},vg={app:{name:"SeCu",title:"Gestion des employés",loading:"Chargement...",save:"Enregistrer",cancel:"Annuler",delete:"Supprimer",edit:"Modifier",add:"Ajouter",search:"Rechercher",filter:"Filtrer",actions:"Actions",close:"Fermer",confirm:"Confirmer",yes:"Oui",no:"Non",back:"Retour",next:"Suivant",submit:"Soumettre",reset:"Réinitialiser",export:"Exporter",import:"Importer",download:"Télécharger",upload:"Téléverser",all:"Tous",none:"Aucun",status:"Statut",date:"Date",time:"Heure",from:"De",to:"À",total:"Total",details:"Détails",description:"Description",notes:"Notes",created:"Créé",updated:"Mis à jour"},auth:{login:"Connexion",logout:"Déconnexion",register:"S'inscrire",email:"E-mail",password:"Mot de passe",confirmPassword:"Confirmer le mot de passe",forgotPassword:"Mot de passe oublié ?",rememberMe:"Se souvenir de moi",welcomeBack:"Bon retour",loginToContinue:"Connectez-vous pour continuer",noAccount:"Pas encore de compte ?",hasAccount:"Déjà un compte ?",createOrg:"Créer une organisation",orgName:"Nom de l'entreprise",firstName:"Prénom",lastName:"Nom"},nav:{dashboard:"Tableau de bord",orders:"Commandes",users:"Employés",shifts:"Planification des équipes",availability:"Disponibilité",timesheets:"Feuilles de temps",qualifications:"Qualifications",objects:"Objets",patrols:"Rondes",incidents:"Incidents",documents:"Documents",vehicles:"Véhicules",customers:"Clients",billing:"Facturation",modules:"Modules",settings:"Paramètres",help:"Aide",partnerships:"Partenariats"},dashboard:{welcome:"Bienvenue",overview:"Aperçu",todayOrders:"Commandes d'aujourd'hui",activeEmployees:"Employés actifs",openIncidents:"Incidents ouverts",pendingTimesheets:"Feuilles de temps en attente",recentActivity:"Activité récente",upcomingShifts:"Équipes à venir",expiringQualifications:"Qualifications expirant",quickActions:"Actions rapides"},orders:{title:"Commandes",new:"Nouvelle commande",orderNumber:"Numéro de commande",client:"Client",location:"Lieu",startDate:"Date de début",endDate:"Date de fin",assignedTo:"Assigné à",priority:"Priorité",priorities:{low:"Basse",medium:"Moyenne",high:"Haute",urgent:"Urgente"},statuses:{draft:"Brouillon",scheduled:"Planifié",active:"Actif",completed:"Terminé",cancelled:"Annulé"}},users:{title:"Employés",new:"Nouvel employé",employee:"Employé",employees:"Employés",role:"Rôle",roles:{chef:"Responsable",disponent:"Répartiteur",mitarbeiter:"Employé"},phone:"Téléphone",address:"Adresse",hireDate:"Date d'embauche",active:"Actif",inactive:"Inactif"},shifts:{title:"Planification des équipes",new:"Nouvelle équipe",shift:"Équipe",shiftPlan:"Plan des équipes",morning:"Équipe du matin",afternoon:"Équipe de l'après-midi",night:"Équipe de nuit",startTime:"Heure de début",endTime:"Heure de fin",break:"Pause",assigned:"Assigné",unassigned:"Non assigné",swapRequest:"Demander un échange",approve:"Approuver",reject:"Rejeter"},availability:{title:"Disponibilité",available:"Disponible",unavailable:"Non disponible",partiallyAvailable:"Partiellement disponible",setAvailability:"Définir la disponibilité",reason:"Raison",vacation:"Vacances",sick:"Maladie",training:"Formation",other:"Autre"},timesheets:{title:"Feuilles de temps",new:"Nouvelle entrée",hours:"Heures",totalHours:"Heures totales",workDate:"Jour de travail",checkIn:"Pointage entrée",checkOut:"Pointage sortie",breakTime:"Temps de pause",overtime:"Heures supplémentaires",upload:"Téléverser la feuille de temps",statuses:{pending:"En attente",approved:"Approuvé",rejected:"Rejeté"}},qualifications:{title:"Qualifications",new:"Nouvelle qualification",type:"Type",types:{"34a":"Certificat de sécurité §34a",first_aid:"Formation aux premiers secours",fire_safety:"Sécurité incendie",security_check:"Habilitation sécurité",drivers_license:"Permis de conduire",other:"Autre"},issueDate:"Date de délivrance",expiryDate:"Date d'expiration",issuedBy:"Délivré par",valid:"Valide",expired:"Expiré",expiringSoon:"Expire bientôt",daysUntilExpiry:"Jours avant l'expiration",reminder:"Rappel"},objects:{title:"Objets",new:"Nouvel objet",object:"Objet",name:"Nom",address:"Adresse",contact:"Personne de contact",phone:"Téléphone",instructions:"Instructions",documents:"Documents",accessInfo:"Informations d'accès"},patrols:{title:"Rondes",new:"Nouvelle ronde",checkpoint:"Point de contrôle",checkpoints:"Points de contrôle",route:"Itinéraire",routes:"Itinéraires",log:"Journal",logs:"Journaux",scanned:"Scanné",missed:"Manqué",scanTime:"Heure du scan",expectedTime:"Heure prévue",deviation:"Écart"},incidents:{title:"Incidents",new:"Nouvel incident",incident:"Incident",category:"Catégorie",categories:{theft:"Vol",vandalism:"Vandalisme",trespassing:"Intrusion",fire:"Incendie",medical:"Urgence médicale",technical:"Problème technique",other:"Autre"},severity:"Gravité",severities:{low:"Basse",medium:"Moyenne",high:"Haute",critical:"Critique"},reporter:"Signalé par",location:"Lieu",witnesses:"Témoins",attachments:"Pièces jointes",resolved:"Résolu",unresolved:"Non résolu"},documents:{title:"Documents",new:"Nouveau document",document:"Document",category:"Catégorie",categories:{contract:"Contrat",certificate:"Certificat",policy:"Politique",manual:"Manuel",form:"Formulaire",other:"Autre"},uploadDate:"Date de téléversement",fileType:"Type de fichier",fileSize:"Taille du fichier",mandatory:"Obligatoire",acknowledged:"Accusé de réception",acknowledgement:"Accusé"},vehicles:{title:"Véhicules",new:"Nouveau véhicule",vehicle:"Véhicule",licensePlate:"Plaque d'immatriculation",make:"Marque",model:"Modèle",year:"Année",mileage:"Kilométrage",fuelLevel:"Niveau de carburant",status:"Statut",statuses:{available:"Disponible",inUse:"En utilisation",maintenance:"Maintenance",outOfService:"Hors service"},booking:"Réservation",bookings:"Réservations",maintenance:"Maintenance",nextService:"Prochain entretien"},customers:{title:"Clients",new:"Nouveau client",customer:"Client",company:"Entreprise",contact:"Personne de contact",email:"E-mail",phone:"Téléphone",address:"Adresse",contracts:"Contrats",communication:"Communication",notes:"Notes"},billing:{title:"Facturation",invoices:"Factures",newInvoice:"Nouvelle facture",invoice:"Facture",invoiceNumber:"Numéro de facture",amount:"Montant",tax:"TVA",subtotal:"Sous-total",total:"Total",dueDate:"Date d'échéance",paidDate:"Date de paiement",statuses:{draft:"Brouillon",sent:"Envoyé",paid:"Payé",overdue:"En retard",cancelled:"Annulé"},hourlyRates:"Tarifs horaires",rate:"Tarif",reminders:"Rappels"},modules:{title:"Modules",enabled:"Activé",disabled:"Désactivé",enable:"Activer",disable:"Désactiver",configure:"Configurer"},settings:{title:"Paramètres",profile:"Profil",account:"Compte",notifications:"Notifications",security:"Sécurité",language:"Langue",theme:"Thème",darkMode:"Mode sombre",lightMode:"Mode clair",changePassword:"Changer le mot de passe",twoFactor:"Authentification à deux facteurs",lockScreen:"Écran de verrouillage",lockMethod:"Méthode de verrouillage",pin:"PIN",pattern:"Motif"},help:{title:"Aide et support",faq:"FAQ",contact:"Contact",documentation:"Documentation",tutorials:"Tutoriels",feedback:"Commentaires"},messages:{success:"Succès",error:"Erreur",warning:"Avertissement",info:"Information",saved:"Enregistré",deleted:"Supprimé",updated:"Mis à jour",created:"Créé",confirmDelete:"Êtes-vous sûr de vouloir supprimer ceci ?",noData:"Aucune donnée disponible",loading:"Chargement...",required:"Champ obligatoire",invalid:"Entrée invalide"},time:{today:"Aujourd'hui",yesterday:"Hier",tomorrow:"Demain",thisWeek:"Cette semaine",lastWeek:"La semaine dernière",thisMonth:"Ce mois",lastMonth:"Le mois dernier",days:"jours",hours:"heures",minutes:"minutes"}},bg={app:{name:"SeCu",title:"إدارة الموظفين",loading:"جاري التحميل...",save:"حفظ",cancel:"إلغاء",delete:"حذف",edit:"تعديل",add:"إضافة",search:"بحث",filter:"تصفية",actions:"إجراءات",close:"إغلاق",confirm:"تأكيد",yes:"نعم",no:"لا",back:"رجوع",next:"التالي",submit:"إرسال",reset:"إعادة تعيين",export:"تصدير",import:"استيراد",download:"تحميل",upload:"رفع",all:"الكل",none:"لا شيء",status:"الحالة",date:"التاريخ",time:"الوقت",from:"من",to:"إلى",total:"المجموع",details:"التفاصيل",description:"الوصف",notes:"ملاحظات",created:"تم الإنشاء",updated:"تم التحديث"},auth:{login:"تسجيل الدخول",logout:"تسجيل الخروج",register:"التسجيل",email:"البريد الإلكتروني",password:"كلمة المرور",confirmPassword:"تأكيد كلمة المرور",forgotPassword:"نسيت كلمة المرور؟",rememberMe:"تذكرني",welcomeBack:"مرحباً بعودتك",loginToContinue:"سجل الدخول للمتابعة",noAccount:"ليس لديك حساب؟",hasAccount:"لديك حساب بالفعل؟",createOrg:"إنشاء منظمة",orgName:"اسم الشركة",firstName:"الاسم الأول",lastName:"اسم العائلة"},nav:{dashboard:"لوحة التحكم",orders:"الطلبات",users:"الموظفون",shifts:"جدولة المناوبات",availability:"التوفر",timesheets:"جداول الدوام",qualifications:"المؤهلات",objects:"المواقع",patrols:"الدوريات",incidents:"الحوادث",documents:"المستندات",vehicles:"المركبات",customers:"العملاء",billing:"الفواتير",modules:"الوحدات",settings:"الإعدادات",help:"المساعدة",partnerships:"الشراكات"},dashboard:{welcome:"مرحباً",overview:"نظرة عامة",todayOrders:"طلبات اليوم",activeEmployees:"الموظفون النشطون",openIncidents:"الحوادث المفتوحة",pendingTimesheets:"جداول الدوام المعلقة",recentActivity:"النشاط الأخير",upcomingShifts:"المناوبات القادمة",expiringQualifications:"المؤهلات المنتهية قريباً",quickActions:"إجراءات سريعة"},orders:{title:"الطلبات",new:"طلب جديد",orderNumber:"رقم الطلب",client:"العميل",location:"الموقع",startDate:"تاريخ البدء",endDate:"تاريخ الانتهاء",assignedTo:"مُعين إلى",priority:"الأولوية",priorities:{low:"منخفضة",medium:"متوسطة",high:"عالية",urgent:"عاجلة"},statuses:{draft:"مسودة",scheduled:"مجدول",active:"نشط",completed:"مكتمل",cancelled:"ملغي"}},users:{title:"الموظفون",new:"موظف جديد",employee:"موظف",employees:"الموظفون",role:"الدور",roles:{chef:"مدير",disponent:"منسق",mitarbeiter:"موظف"},phone:"الهاتف",address:"العنوان",hireDate:"تاريخ التوظيف",active:"نشط",inactive:"غير نشط"},shifts:{title:"جدولة المناوبات",new:"مناوبة جديدة",shift:"مناوبة",shiftPlan:"خطة المناوبات",morning:"مناوبة صباحية",afternoon:"مناوبة مسائية",night:"مناوبة ليلية",startTime:"وقت البدء",endTime:"وقت الانتهاء",break:"استراحة",assigned:"مُعين",unassigned:"غير مُعين",swapRequest:"طلب تبديل",approve:"موافقة",reject:"رفض"},availability:{title:"التوفر",available:"متاح",unavailable:"غير متاح",partiallyAvailable:"متاح جزئياً",setAvailability:"تحديد التوفر",reason:"السبب",vacation:"إجازة",sick:"مرض",training:"تدريب",other:"أخرى"},timesheets:{title:"جداول الدوام",new:"إدخال جديد",hours:"ساعات",totalHours:"إجمالي الساعات",workDate:"يوم العمل",checkIn:"تسجيل الحضور",checkOut:"تسجيل الانصراف",breakTime:"وقت الاستراحة",overtime:"ساعات إضافية",upload:"رفع جدول الدوام",statuses:{pending:"معلق",approved:"مُوافق عليه",rejected:"مرفوض"}},qualifications:{title:"المؤهلات",new:"مؤهل جديد",type:"النوع",types:{"34a":"شهادة الأمن §34a",first_aid:"دورة الإسعافات الأولية",fire_safety:"السلامة من الحريق",security_check:"التصريح الأمني",drivers_license:"رخصة القيادة",other:"أخرى"},issueDate:"تاريخ الإصدار",expiryDate:"تاريخ الانتهاء",issuedBy:"صادر من",valid:"صالح",expired:"منتهي",expiringSoon:"ينتهي قريباً",daysUntilExpiry:"أيام حتى الانتهاء",reminder:"تذكير"},objects:{title:"المواقع",new:"موقع جديد",object:"موقع",name:"الاسم",address:"العنوان",contact:"جهة الاتصال",phone:"الهاتف",instructions:"التعليمات",documents:"المستندات",accessInfo:"معلومات الدخول"},patrols:{title:"الدوريات",new:"دورية جديدة",checkpoint:"نقطة تفتيش",checkpoints:"نقاط التفتيش",route:"المسار",routes:"المسارات",log:"سجل",logs:"السجلات",scanned:"تم المسح",missed:"فائت",scanTime:"وقت المسح",expectedTime:"الوقت المتوقع",deviation:"الانحراف"},incidents:{title:"الحوادث",new:"حادثة جديدة",incident:"حادثة",category:"الفئة",categories:{theft:"سرقة",vandalism:"تخريب",trespassing:"تعدي",fire:"حريق",medical:"طوارئ طبية",technical:"مشكلة تقنية",other:"أخرى"},severity:"الشدة",severities:{low:"منخفضة",medium:"متوسطة",high:"عالية",critical:"حرجة"},reporter:"أبلغ عنها",location:"الموقع",witnesses:"الشهود",attachments:"المرفقات",resolved:"محلولة",unresolved:"غير محلولة"},documents:{title:"المستندات",new:"مستند جديد",document:"مستند",category:"الفئة",categories:{contract:"عقد",certificate:"شهادة",policy:"سياسة",manual:"دليل",form:"نموذج",other:"أخرى"},uploadDate:"تاريخ الرفع",fileType:"نوع الملف",fileSize:"حجم الملف",mandatory:"إلزامي",acknowledged:"تم الإقرار",acknowledgement:"إقرار"},vehicles:{title:"المركبات",new:"مركبة جديدة",vehicle:"مركبة",licensePlate:"لوحة الترخيص",make:"الشركة المصنعة",model:"الطراز",year:"السنة",mileage:"عداد المسافات",fuelLevel:"مستوى الوقود",status:"الحالة",statuses:{available:"متاحة",inUse:"قيد الاستخدام",maintenance:"صيانة",outOfService:"خارج الخدمة"},booking:"حجز",bookings:"الحجوزات",maintenance:"الصيانة",nextService:"الخدمة التالية"},customers:{title:"العملاء",new:"عميل جديد",customer:"عميل",company:"الشركة",contact:"جهة الاتصال",email:"البريد الإلكتروني",phone:"الهاتف",address:"العنوان",contracts:"العقود",communication:"التواصل",notes:"ملاحظات"},billing:{title:"الفواتير",invoices:"الفواتير",newInvoice:"فاتورة جديدة",invoice:"فاتورة",invoiceNumber:"رقم الفاتورة",amount:"المبلغ",tax:"الضريبة",subtotal:"المجموع الفرعي",total:"المجموع",dueDate:"تاريخ الاستحقاق",paidDate:"تاريخ الدفع",statuses:{draft:"مسودة",sent:"مُرسلة",paid:"مدفوعة",overdue:"متأخرة",cancelled:"ملغاة"},hourlyRates:"أسعار الساعة",rate:"السعر",reminders:"التذكيرات"},modules:{title:"الوحدات",enabled:"مُفعّل",disabled:"معطّل",enable:"تفعيل",disable:"تعطيل",configure:"تكوين"},settings:{title:"الإعدادات",profile:"الملف الشخصي",account:"الحساب",notifications:"الإشعارات",security:"الأمان",language:"اللغة",theme:"المظهر",darkMode:"الوضع الداكن",lightMode:"الوضع الفاتح",changePassword:"تغيير كلمة المرور",twoFactor:"المصادقة الثنائية",lockScreen:"قفل الشاشة",lockMethod:"طريقة القفل",pin:"رمز PIN",pattern:"نمط"},help:{title:"المساعدة والدعم",faq:"الأسئلة الشائعة",contact:"اتصل بنا",documentation:"التوثيق",tutorials:"الدروس",feedback:"ملاحظات"},messages:{success:"نجاح",error:"خطأ",warning:"تحذير",info:"معلومات",saved:"تم الحفظ",deleted:"تم الحذف",updated:"تم التحديث",created:"تم الإنشاء",confirmDelete:"هل أنت متأكد من أنك تريد حذف هذا؟",noData:"لا توجد بيانات متاحة",loading:"جاري التحميل...",required:"حقل مطلوب",invalid:"إدخال غير صالح"},time:{today:"اليوم",yesterday:"أمس",tomorrow:"غداً",thisWeek:"هذا الأسبوع",lastWeek:"الأسبوع الماضي",thisMonth:"هذا الشهر",lastMonth:"الشهر الماضي",days:"أيام",hours:"ساعات",minutes:"دقائق"}},yg={app:{name:"SeCu",title:"Управление персоналом",loading:"Загрузка...",save:"Сохранить",cancel:"Отмена",delete:"Удалить",edit:"Редактировать",add:"Добавить",search:"Поиск",filter:"Фильтр",actions:"Действия",close:"Закрыть",confirm:"Подтвердить",yes:"Да",no:"Нет",back:"Назад",next:"Далее",submit:"Отправить",reset:"Сбросить",export:"Экспорт",import:"Импорт",download:"Скачать",upload:"Загрузить",all:"Все",none:"Нет",status:"Статус",date:"Дата",time:"Время",from:"От",to:"До",total:"Итого",details:"Подробности",description:"Описание",notes:"Заметки",created:"Создано",updated:"Обновлено"},auth:{login:"Войти",logout:"Выйти",register:"Регистрация",email:"Эл. почта",password:"Пароль",confirmPassword:"Подтвердить пароль",forgotPassword:"Забыли пароль?",rememberMe:"Запомнить меня",welcomeBack:"Добро пожаловать",loginToContinue:"Войдите для продолжения",noAccount:"Нет аккаунта?",hasAccount:"Уже есть аккаунт?",createOrg:"Создать организацию",orgName:"Название компании",firstName:"Имя",lastName:"Фамилия"},nav:{dashboard:"Панель управления",orders:"Заказы",users:"Сотрудники",shifts:"Планирование смен",availability:"Доступность",timesheets:"Табели учёта",qualifications:"Квалификации",objects:"Объекты",patrols:"Патрули",incidents:"Инциденты",documents:"Документы",vehicles:"Транспорт",customers:"Клиенты",billing:"Выставление счетов",modules:"Модули",settings:"Настройки",help:"Помощь",partnerships:"Партнёрства"},dashboard:{welcome:"Добро пожаловать",overview:"Обзор",todayOrders:"Заказы на сегодня",activeEmployees:"Активные сотрудники",openIncidents:"Открытые инциденты",pendingTimesheets:"Ожидающие табели",recentActivity:"Последняя активность",upcomingShifts:"Предстоящие смены",expiringQualifications:"Истекающие квалификации",quickActions:"Быстрые действия"},orders:{title:"Заказы",new:"Новый заказ",orderNumber:"Номер заказа",client:"Клиент",location:"Местоположение",startDate:"Дата начала",endDate:"Дата окончания",assignedTo:"Назначен",priority:"Приоритет",priorities:{low:"Низкий",medium:"Средний",high:"Высокий",urgent:"Срочный"},statuses:{draft:"Черновик",scheduled:"Запланировано",active:"Активный",completed:"Завершён",cancelled:"Отменён"}},users:{title:"Сотрудники",new:"Новый сотрудник",employee:"Сотрудник",employees:"Сотрудники",role:"Роль",roles:{chef:"Руководитель",disponent:"Диспетчер",mitarbeiter:"Сотрудник"},phone:"Телефон",address:"Адрес",hireDate:"Дата приёма",active:"Активен",inactive:"Неактивен"},shifts:{title:"Планирование смен",new:"Новая смена",shift:"Смена",shiftPlan:"План смен",morning:"Утренняя смена",afternoon:"Дневная смена",night:"Ночная смена",startTime:"Время начала",endTime:"Время окончания",break:"Перерыв",assigned:"Назначено",unassigned:"Не назначено",swapRequest:"Запрос на обмен",approve:"Одобрить",reject:"Отклонить"},availability:{title:"Доступность",available:"Доступен",unavailable:"Недоступен",partiallyAvailable:"Частично доступен",setAvailability:"Указать доступность",reason:"Причина",vacation:"Отпуск",sick:"Больничный",training:"Обучение",other:"Другое"},timesheets:{title:"Табели учёта",new:"Новая запись",hours:"Часы",totalHours:"Всего часов",workDate:"Рабочий день",checkIn:"Приход",checkOut:"Уход",breakTime:"Время перерыва",overtime:"Сверхурочные",upload:"Загрузить табель",statuses:{pending:"Ожидает",approved:"Одобрено",rejected:"Отклонено"}},qualifications:{title:"Квалификации",new:"Новая квалификация",type:"Тип",types:{"34a":"Сертификат охраны §34a",first_aid:"Курс первой помощи",fire_safety:"Пожарная безопасность",security_check:"Проверка безопасности",drivers_license:"Водительские права",other:"Другое"},issueDate:"Дата выдачи",expiryDate:"Дата истечения",issuedBy:"Выдано",valid:"Действительна",expired:"Истекла",expiringSoon:"Скоро истекает",daysUntilExpiry:"Дней до истечения",reminder:"Напоминание"},objects:{title:"Объекты",new:"Новый объект",object:"Объект",name:"Название",address:"Адрес",contact:"Контактное лицо",phone:"Телефон",instructions:"Инструкции",documents:"Документы",accessInfo:"Информация о доступе"},patrols:{title:"Патрули",new:"Новый патруль",checkpoint:"Контрольная точка",checkpoints:"Контрольные точки",route:"Маршрут",routes:"Маршруты",log:"Журнал",logs:"Журналы",scanned:"Сканировано",missed:"Пропущено",scanTime:"Время сканирования",expectedTime:"Ожидаемое время",deviation:"Отклонение"},incidents:{title:"Инциденты",new:"Новый инцидент",incident:"Инцидент",category:"Категория",categories:{theft:"Кража",vandalism:"Вандализм",trespassing:"Незаконное проникновение",fire:"Пожар",medical:"Медицинская помощь",technical:"Техническая проблема",other:"Другое"},severity:"Серьёзность",severities:{low:"Низкая",medium:"Средняя",high:"Высокая",critical:"Критическая"},reporter:"Сообщил",location:"Место",witnesses:"Свидетели",attachments:"Вложения",resolved:"Решено",unresolved:"Не решено"},documents:{title:"Документы",new:"Новый документ",document:"Документ",category:"Категория",categories:{contract:"Контракт",certificate:"Сертификат",policy:"Политика",manual:"Руководство",form:"Форма",other:"Другое"},uploadDate:"Дата загрузки",fileType:"Тип файла",fileSize:"Размер файла",mandatory:"Обязательный",acknowledged:"Подтверждено",acknowledgement:"Подтверждение"},vehicles:{title:"Транспорт",new:"Новое транспортное средство",vehicle:"Транспортное средство",licensePlate:"Номерной знак",make:"Марка",model:"Модель",year:"Год",mileage:"Пробег",fuelLevel:"Уровень топлива",status:"Статус",statuses:{available:"Доступно",inUse:"Используется",maintenance:"На обслуживании",outOfService:"Не работает"},booking:"Бронирование",bookings:"Бронирования",maintenance:"Обслуживание",nextService:"Следующее ТО"},customers:{title:"Клиенты",new:"Новый клиент",customer:"Клиент",company:"Компания",contact:"Контактное лицо",email:"Эл. почта",phone:"Телефон",address:"Адрес",contracts:"Контракты",communication:"Коммуникация",notes:"Заметки"},billing:{title:"Выставление счетов",invoices:"Счета",newInvoice:"Новый счёт",invoice:"Счёт",invoiceNumber:"Номер счёта",amount:"Сумма",tax:"НДС",subtotal:"Подытог",total:"Итого",dueDate:"Срок оплаты",paidDate:"Дата оплаты",statuses:{draft:"Черновик",sent:"Отправлен",paid:"Оплачен",overdue:"Просрочен",cancelled:"Отменён"},hourlyRates:"Почасовые ставки",rate:"Ставка",reminders:"Напоминания"},modules:{title:"Модули",enabled:"Включен",disabled:"Отключен",enable:"Включить",disable:"Отключить",configure:"Настроить"},settings:{title:"Настройки",profile:"Профиль",account:"Аккаунт",notifications:"Уведомления",security:"Безопасность",language:"Язык",theme:"Тема",darkMode:"Тёмный режим",lightMode:"Светлый режим",changePassword:"Изменить пароль",twoFactor:"Двухфакторная аутентификация",lockScreen:"Экран блокировки",lockMethod:"Способ блокировки",pin:"PIN-код",pattern:"Графический ключ"},help:{title:"Помощь и поддержка",faq:"Частые вопросы",contact:"Контакты",documentation:"Документация",tutorials:"Обучение",feedback:"Обратная связь"},messages:{success:"Успешно",error:"Ошибка",warning:"Предупреждение",info:"Информация",saved:"Сохранено",deleted:"Удалено",updated:"Обновлено",created:"Создано",confirmDelete:"Вы уверены, что хотите удалить это?",noData:"Нет данных",loading:"Загрузка...",required:"Обязательное поле",invalid:"Неверный ввод"},time:{today:"Сегодня",yesterday:"Вчера",tomorrow:"Завтра",thisWeek:"На этой неделе",lastWeek:"На прошлой неделе",thisMonth:"В этом месяце",lastMonth:"В прошлом месяце",days:"дней",hours:"часов",minutes:"минут"}},Eg={app:{name:"SeCu",title:"Zarządzanie pracownikami",loading:"Ładowanie...",save:"Zapisz",cancel:"Anuluj",delete:"Usuń",edit:"Edytuj",add:"Dodaj",search:"Szukaj",filter:"Filtruj",actions:"Akcje",close:"Zamknij",confirm:"Potwierdź",yes:"Tak",no:"Nie",back:"Wstecz",next:"Dalej",submit:"Wyślij",reset:"Resetuj",export:"Eksportuj",import:"Importuj",download:"Pobierz",upload:"Prześlij",all:"Wszystkie",none:"Brak",status:"Status",date:"Data",time:"Czas",from:"Od",to:"Do",total:"Razem",details:"Szczegóły",description:"Opis",notes:"Notatki",created:"Utworzono",updated:"Zaktualizowano"},auth:{login:"Zaloguj się",logout:"Wyloguj się",register:"Zarejestruj się",email:"E-mail",password:"Hasło",confirmPassword:"Potwierdź hasło",forgotPassword:"Zapomniałeś hasła?",rememberMe:"Zapamiętaj mnie",welcomeBack:"Witaj ponownie",loginToContinue:"Zaloguj się, aby kontynuować",noAccount:"Nie masz jeszcze konta?",hasAccount:"Masz już konto?",createOrg:"Utwórz organizację",orgName:"Nazwa firmy",firstName:"Imię",lastName:"Nazwisko"},nav:{dashboard:"Pulpit",orders:"Zamówienia",users:"Pracownicy",shifts:"Planowanie zmian",availability:"Dostępność",timesheets:"Karty czasu pracy",qualifications:"Kwalifikacje",objects:"Obiekty",patrols:"Patrole",incidents:"Incydenty",documents:"Dokumenty",vehicles:"Pojazdy",customers:"Klienci",billing:"Rozliczenia",modules:"Moduły",settings:"Ustawienia",help:"Pomoc",partnerships:"Partnerstwa"},dashboard:{welcome:"Witaj",overview:"Przegląd",todayOrders:"Dzisiejsze zamówienia",activeEmployees:"Aktywni pracownicy",openIncidents:"Otwarte incydenty",pendingTimesheets:"Oczekujące karty czasu",recentActivity:"Ostatnia aktywność",upcomingShifts:"Nadchodzące zmiany",expiringQualifications:"Wygasające kwalifikacje",quickActions:"Szybkie akcje"},orders:{title:"Zamówienia",new:"Nowe zamówienie",orderNumber:"Numer zamówienia",client:"Klient",location:"Lokalizacja",startDate:"Data rozpoczęcia",endDate:"Data zakończenia",assignedTo:"Przypisano do",priority:"Priorytet",priorities:{low:"Niski",medium:"Średni",high:"Wysoki",urgent:"Pilny"},statuses:{draft:"Szkic",scheduled:"Zaplanowane",active:"Aktywne",completed:"Zakończone",cancelled:"Anulowane"}},users:{title:"Pracownicy",new:"Nowy pracownik",employee:"Pracownik",employees:"Pracownicy",role:"Rola",roles:{chef:"Kierownik",disponent:"Dyspozytor",mitarbeiter:"Pracownik"},phone:"Telefon",address:"Adres",hireDate:"Data zatrudnienia",active:"Aktywny",inactive:"Nieaktywny"},shifts:{title:"Planowanie zmian",new:"Nowa zmiana",shift:"Zmiana",shiftPlan:"Plan zmian",morning:"Zmiana poranna",afternoon:"Zmiana popołudniowa",night:"Zmiana nocna",startTime:"Czas rozpoczęcia",endTime:"Czas zakończenia",break:"Przerwa",assigned:"Przypisano",unassigned:"Nieprzypisano",swapRequest:"Prośba o zamianę",approve:"Zatwierdź",reject:"Odrzuć"},availability:{title:"Dostępność",available:"Dostępny",unavailable:"Niedostępny",partiallyAvailable:"Częściowo dostępny",setAvailability:"Ustaw dostępność",reason:"Powód",vacation:"Urlop",sick:"Choroba",training:"Szkolenie",other:"Inne"},timesheets:{title:"Karty czasu pracy",new:"Nowy wpis",hours:"Godziny",totalHours:"Suma godzin",workDate:"Dzień pracy",checkIn:"Wejście",checkOut:"Wyjście",breakTime:"Czas przerwy",overtime:"Nadgodziny",upload:"Prześlij kartę czasu",statuses:{pending:"Oczekujące",approved:"Zatwierdzone",rejected:"Odrzucone"}},qualifications:{title:"Kwalifikacje",new:"Nowa kwalifikacja",type:"Typ",types:{"34a":"Certyfikat ochrony §34a",first_aid:"Kurs pierwszej pomocy",fire_safety:"Bezpieczeństwo pożarowe",security_check:"Poświadczenie bezpieczeństwa",drivers_license:"Prawo jazdy",other:"Inne"},issueDate:"Data wydania",expiryDate:"Data ważności",issuedBy:"Wydane przez",valid:"Ważna",expired:"Wygasła",expiringSoon:"Wkrótce wygasa",daysUntilExpiry:"Dni do wygaśnięcia",reminder:"Przypomnienie"},objects:{title:"Obiekty",new:"Nowy obiekt",object:"Obiekt",name:"Nazwa",address:"Adres",contact:"Osoba kontaktowa",phone:"Telefon",instructions:"Instrukcje",documents:"Dokumenty",accessInfo:"Informacje o dostępie"},patrols:{title:"Patrole",new:"Nowy patrol",checkpoint:"Punkt kontrolny",checkpoints:"Punkty kontrolne",route:"Trasa",routes:"Trasy",log:"Dziennik",logs:"Dzienniki",scanned:"Zeskanowano",missed:"Pominięto",scanTime:"Czas skanowania",expectedTime:"Oczekiwany czas",deviation:"Odchylenie"},incidents:{title:"Incydenty",new:"Nowy incydent",incident:"Incydent",category:"Kategoria",categories:{theft:"Kradzież",vandalism:"Wandalizm",trespassing:"Wtargnięcie",fire:"Pożar",medical:"Nagły przypadek medyczny",technical:"Problem techniczny",other:"Inne"},severity:"Ważność",severities:{low:"Niska",medium:"Średnia",high:"Wysoka",critical:"Krytyczna"},reporter:"Zgłosił",location:"Lokalizacja",witnesses:"Świadkowie",attachments:"Załączniki",resolved:"Rozwiązany",unresolved:"Nierozwiązany"},documents:{title:"Dokumenty",new:"Nowy dokument",document:"Dokument",category:"Kategoria",categories:{contract:"Umowa",certificate:"Certyfikat",policy:"Polityka",manual:"Instrukcja",form:"Formularz",other:"Inne"},uploadDate:"Data przesłania",fileType:"Typ pliku",fileSize:"Rozmiar pliku",mandatory:"Obowiązkowy",acknowledged:"Potwierdzono",acknowledgement:"Potwierdzenie"},vehicles:{title:"Pojazdy",new:"Nowy pojazd",vehicle:"Pojazd",licensePlate:"Numer rejestracyjny",make:"Marka",model:"Model",year:"Rok",mileage:"Przebieg",fuelLevel:"Poziom paliwa",status:"Status",statuses:{available:"Dostępny",inUse:"W użyciu",maintenance:"W serwisie",outOfService:"Wyłączony z użytku"},booking:"Rezerwacja",bookings:"Rezerwacje",maintenance:"Serwis",nextService:"Następny przegląd"},customers:{title:"Klienci",new:"Nowy klient",customer:"Klient",company:"Firma",contact:"Osoba kontaktowa",email:"E-mail",phone:"Telefon",address:"Adres",contracts:"Umowy",communication:"Komunikacja",notes:"Notatki"},billing:{title:"Rozliczenia",invoices:"Faktury",newInvoice:"Nowa faktura",invoice:"Faktura",invoiceNumber:"Numer faktury",amount:"Kwota",tax:"VAT",subtotal:"Suma częściowa",total:"Razem",dueDate:"Termin płatności",paidDate:"Data płatności",statuses:{draft:"Szkic",sent:"Wysłana",paid:"Opłacona",overdue:"Przeterminowana",cancelled:"Anulowana"},hourlyRates:"Stawki godzinowe",rate:"Stawka",reminders:"Przypomnienia"},modules:{title:"Moduły",enabled:"Włączony",disabled:"Wyłączony",enable:"Włącz",disable:"Wyłącz",configure:"Konfiguruj"},settings:{title:"Ustawienia",profile:"Profil",account:"Konto",notifications:"Powiadomienia",security:"Bezpieczeństwo",language:"Język",theme:"Motyw",darkMode:"Tryb ciemny",lightMode:"Tryb jasny",changePassword:"Zmień hasło",twoFactor:"Uwierzytelnianie dwuskładnikowe",lockScreen:"Blokada ekranu",lockMethod:"Metoda blokady",pin:"PIN",pattern:"Wzór"},help:{title:"Pomoc i wsparcie",faq:"FAQ",contact:"Kontakt",documentation:"Dokumentacja",tutorials:"Samouczki",feedback:"Opinie"},messages:{success:"Sukces",error:"Błąd",warning:"Ostrzeżenie",info:"Informacja",saved:"Zapisano",deleted:"Usunięto",updated:"Zaktualizowano",created:"Utworzono",confirmDelete:"Czy na pewno chcesz to usunąć?",noData:"Brak danych",loading:"Ładowanie...",required:"Pole wymagane",invalid:"Nieprawidłowe dane"},time:{today:"Dzisiaj",yesterday:"Wczoraj",tomorrow:"Jutro",thisWeek:"Ten tydzień",lastWeek:"Ostatni tydzień",thisMonth:"Ten miesiąc",lastMonth:"Ostatni miesiąc",days:"dni",hours:"godzin",minutes:"minut"}},zr=[{code:"de",name:"Deutsch",flag:"🇩🇪"},{code:"es",name:"Español",flag:"🇪🇸"},{code:"en",name:"English",flag:"🇬🇧"},{code:"ar",name:"العربية",flag:"🇸🇦",rtl:!0},{code:"ru",name:"Русский",flag:"🇷🇺"},{code:"fr",name:"Français",flag:"🇫🇷"},{code:"pl",name:"Polski",flag:"🇵🇱"}];function ji(){const e=localStorage.getItem("locale");if(e&&zr.some(r=>r.code===e))return e;const t=navigator.language.split("-")[0],n=zr.find(r=>r.code===t);return n?n.code:"de"}const Kc=sg({legacy:!1,locale:ji(),fallbackLocale:"de",messages:{de:pg,en:gg,es:_g,fr:vg,ar:bg,ru:yg,pl:Eg}});function Og(e){const t=zr.find(n=>n.code===e);t&&(Kc.global.locale.value=e,localStorage.setItem("locale",e),document.documentElement.dir=t.rtl?"rtl":"ltr",document.documentElement.lang=e)}const xs=zr.find(e=>e.code===ji());xs!=null&&xs.rtl&&(document.documentElement.dir="rtl");document.documentElement.lang=ji();const ps=Sd(Qd);ps.use(Cd());ps.use(fc);ps.use(Kc);ps.mount("#app");export{Vl as A,Og as B,wg as C,Sg as D,mi as E,Ge as F,zr as S,Ag as T,rt as a,Vu as b,ut as c,En as d,Wl as e,Cg as f,Pg as g,Zt as h,Ve as i,ju as j,ue as k,of as l,$n as m,Qr as n,Ze as o,Uf as p,vr as q,Pe as r,Ig as s,Fs as t,ki as u,Ng as v,kg as w,Qi as x,Ui as y,vn as z}; diff --git a/dist/assets/index-FAo1Ctk1.css b/dist/assets/index-FAo1Ctk1.css new file mode 100644 index 0000000..974c07e --- /dev/null +++ b/dist/assets/index-FAo1Ctk1.css @@ -0,0 +1 @@ +@keyframes shake-5cf90e48{0%,to{transform:translate(0)}25%{transform:translate(-5px)}75%{transform:translate(5px)}}.animate-shake[data-v-5cf90e48]{animation:shake-5cf90e48 .3s ease-in-out}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}body{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}body:is(.dark *){--tw-text-opacity: 1;color:rgb(243 244 246 / var(--tw-text-opacity, 1))}.btn{border-radius:.5rem;padding:.5rem 1rem;font-weight:500;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.2s}.btn-primary{--tw-bg-opacity: 1;background-color:rgb(79 70 229 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.btn-primary:hover{--tw-bg-opacity: 1;background-color:rgb(67 56 202 / var(--tw-bg-opacity, 1))}.btn-primary:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000);--tw-ring-opacity: 1;--tw-ring-color: rgb(99 102 241 / var(--tw-ring-opacity, 1));--tw-ring-offset-width: 2px}.btn-secondary{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.btn-secondary:hover{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.btn-secondary:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(55 65 81 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(229 231 235 / var(--tw-text-opacity, 1))}.btn-secondary:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(75 85 99 / var(--tw-bg-opacity, 1))}.btn-danger{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.btn-danger:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity, 1))}.btn-success{--tw-bg-opacity: 1;background-color:rgb(22 163 74 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.btn-success:hover{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity, 1))}.input{width:100%;border-radius:.5rem;border-width:1px;--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));padding:.5rem .75rem}.input:focus{--tw-border-opacity: 1;border-color:rgb(99 102 241 / var(--tw-border-opacity, 1));--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000);--tw-ring-opacity: 1;--tw-ring-color: rgb(99 102 241 / var(--tw-ring-opacity, 1))}.input:is(.dark *){--tw-border-opacity: 1;border-color:rgb(75 85 99 / var(--tw-border-opacity, 1));--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.card{border-radius:.75rem;border-width:1px;--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem;--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.card:is(.dark *){--tw-border-opacity: 1;border-color:rgb(55 65 81 / var(--tw-border-opacity, 1));--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.badge{display:inline-flex;align-items:center;border-radius:9999px;padding:.125rem .625rem;font-size:.75rem;line-height:1rem;font-weight:500}.badge-primary{--tw-bg-opacity: 1;background-color:rgb(224 231 255 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(55 48 163 / var(--tw-text-opacity, 1))}.badge-primary:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(49 46 129 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(199 210 254 / var(--tw-text-opacity, 1))}.badge-success{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.badge-success:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(187 247 208 / var(--tw-text-opacity, 1))}.badge-warning{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(133 77 14 / var(--tw-text-opacity, 1))}.badge-warning:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(113 63 18 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(254 240 138 / var(--tw-text-opacity, 1))}.badge-danger{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.badge-danger:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1));--tw-text-opacity: 1;color:rgb(254 202 202 / var(--tw-text-opacity, 1))}.visible{visibility:visible}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.right-0{right:0}.right-3{right:.75rem}.top-0{top:0}.top-1\/2{top:50%}.z-40{z-index:40}.z-50{z-index:50}.col-span-2{grid-column:span 2 / span 2}.m-4{margin:1rem}.-mx-6{margin-left:-1.5rem;margin-right:-1.5rem}.mx-2{margin-left:.5rem;margin-right:.5rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-top:.25rem;margin-bottom:.25rem}.my-3{margin-top:.75rem;margin-bottom:.75rem}.my-4{margin-top:1rem;margin-bottom:1rem}.my-6{margin-top:1.5rem;margin-bottom:1.5rem}.-mb-px{margin-bottom:-1px}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-6{margin-left:1.5rem}.ml-auto{margin-left:auto}.mr-2{margin-right:.5rem}.mr-3{margin-right:.75rem}.mr-4{margin-right:1rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-1{height:.25rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-20{height:5rem}.h-3{height:.75rem}.h-4{height:1rem}.h-6{height:1.5rem}.h-8{height:2rem}.max-h-40{max-height:10rem}.max-h-48{max-height:12rem}.max-h-\[80vh\]{max-height:80vh}.max-h-\[90vh\]{max-height:90vh}.min-h-32{min-height:8rem}.min-h-screen{min-height:100vh}.w-1\/2{width:50%}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-20{width:5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-32{width:8rem}.w-4{width:1rem}.w-44{width:11rem}.w-48{width:12rem}.w-64{width:16rem}.w-8{width:2rem}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-full{min-width:100%}.max-w-2xl{max-width:42rem}.max-w-7xl{max-width:80rem}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-none{max-width:none}.max-w-xs{max-width:20rem}.flex-1{flex:1 1 0%}.-translate-x-full{--tw-translate-x: -100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-100{--tw-scale-x: 1;--tw-scale-y: 1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-110{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-95{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.space-x-1>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.25rem * var(--tw-space-x-reverse));margin-left:calc(.25rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-3>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.75rem * var(--tw-space-x-reverse));margin-left:calc(.75rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1rem * var(--tw-space-x-reverse));margin-left:calc(1rem * calc(1 - var(--tw-space-x-reverse)))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.divide-x>:not([hidden])~:not([hidden]){--tw-divide-x-reverse: 0;border-right-width:calc(1px * var(--tw-divide-x-reverse));border-left-width:calc(1px * calc(1 - var(--tw-divide-x-reverse)))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-gray-200>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(229 231 235 / var(--tw-divide-opacity, 1))}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:1rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-xl{border-radius:.75rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.border{border-width:1px}.border-2{border-width:2px}.border-4{border-width:4px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l-4{border-left-width:4px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-blue-500{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-blue-600{--tw-border-opacity: 1;border-color:rgb(37 99 235 / var(--tw-border-opacity, 1))}.border-gray-100{--tw-border-opacity: 1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-orange-500{--tw-border-opacity: 1;border-color:rgb(249 115 22 / var(--tw-border-opacity, 1))}.border-purple-500{--tw-border-opacity: 1;border-color:rgb(168 85 247 / var(--tw-border-opacity, 1))}.border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.border-red-500{--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-transparent{border-color:transparent}.border-yellow-200{--tw-border-opacity: 1;border-color:rgb(254 240 138 / var(--tw-border-opacity, 1))}.border-yellow-400{--tw-border-opacity: 1;border-color:rgb(250 204 21 / var(--tw-border-opacity, 1))}.border-yellow-500{--tw-border-opacity: 1;border-color:rgb(234 179 8 / var(--tw-border-opacity, 1))}.border-t-transparent{border-top-color:transparent}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.bg-black\/50{background-color:#00000080}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-green-600{--tw-bg-opacity: 1;background-color:rgb(22 163 74 / var(--tw-bg-opacity, 1))}.bg-orange-100{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.bg-orange-50{--tw-bg-opacity: 1;background-color:rgb(255 247 237 / var(--tw-bg-opacity, 1))}.bg-primary-100{--tw-bg-opacity: 1;background-color:rgb(224 231 255 / var(--tw-bg-opacity, 1))}.bg-primary-50{--tw-bg-opacity: 1;background-color:rgb(238 242 255 / var(--tw-bg-opacity, 1))}.bg-primary-600{--tw-bg-opacity: 1;background-color:rgb(79 70 229 / var(--tw-bg-opacity, 1))}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(250 245 255 / var(--tw-bg-opacity, 1))}.bg-purple-600{--tw-bg-opacity: 1;background-color:rgb(147 51 234 / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.bg-red-400{--tw-bg-opacity: 1;background-color:rgb(248 113 113 / var(--tw-bg-opacity, 1))}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-white\/10{background-color:#ffffff1a}.bg-white\/20{background-color:#fff3}.bg-white\/30{background-color:#ffffff4d}.bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.bg-yellow-50{--tw-bg-opacity: 1;background-color:rgb(254 252 232 / var(--tw-bg-opacity, 1))}.bg-opacity-50{--tw-bg-opacity: .5}.bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.bg-gradient-to-r{background-image:linear-gradient(to right,var(--tw-gradient-stops))}.from-primary-500{--tw-gradient-from: #6366f1 var(--tw-gradient-from-position);--tw-gradient-to: rgb(99 102 241 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-purple-600{--tw-gradient-from: #9333ea var(--tw-gradient-from-position);--tw-gradient-to: rgb(147 51 234 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-indigo-600{--tw-gradient-to: #4f46e5 var(--tw-gradient-to-position)}.to-indigo-700,.to-primary-700{--tw-gradient-to: #4338ca var(--tw-gradient-to-position)}.p-1{padding:.25rem}.p-12{padding:3rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pl-4{padding-left:1rem}.pr-10{padding-right:2.5rem}.pr-4{padding-right:1rem}.pt-2{padding-top:.5rem}.pt-4{padding-top:1rem}.pt-6{padding-top:1.5rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-6xl{font-size:3.75rem;line-height:1}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.text-gray-200{--tw-text-opacity: 1;color:rgb(229 231 235 / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity, 1))}.text-orange-700{--tw-text-opacity: 1;color:rgb(194 65 12 / var(--tw-text-opacity, 1))}.text-primary-100{--tw-text-opacity: 1;color:rgb(224 231 255 / var(--tw-text-opacity, 1))}.text-primary-400{--tw-text-opacity: 1;color:rgb(129 140 248 / var(--tw-text-opacity, 1))}.text-primary-600{--tw-text-opacity: 1;color:rgb(79 70 229 / var(--tw-text-opacity, 1))}.text-primary-700{--tw-text-opacity: 1;color:rgb(67 56 202 / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.text-purple-800{--tw-text-opacity: 1;color:rgb(107 33 168 / var(--tw-text-opacity, 1))}.text-red-300{--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-white\/50{color:#ffffff80}.text-white\/70{color:#ffffffb3}.text-yellow-600{--tw-text-opacity: 1;color:rgb(202 138 4 / var(--tw-text-opacity, 1))}.text-yellow-700{--tw-text-opacity: 1;color:rgb(161 98 7 / var(--tw-text-opacity, 1))}.text-yellow-800{--tw-text-opacity: 1;color:rgb(133 77 14 / var(--tw-text-opacity, 1))}.underline{text-decoration-line:underline}.opacity-0{opacity:0}.opacity-100{opacity:1}.opacity-50{opacity:.5}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-blue-500{--tw-ring-opacity: 1;--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity, 1))}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-shadow{transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-100{transition-duration:.1s}.duration-75{transition-duration:75ms}.ease-in{transition-timing-function:cubic-bezier(.4,0,1,1)}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}.hover\:scale-\[1\.02\]:hover{--tw-scale-x: 1.02;--tw-scale-y: 1.02;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:border-blue-500:hover{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.hover\:border-purple-300:hover{--tw-border-opacity: 1;border-color:rgb(216 180 254 / var(--tw-border-opacity, 1))}.hover\:border-red-300:hover{--tw-border-opacity: 1;border-color:rgb(252 165 165 / var(--tw-border-opacity, 1))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-700:hover{--tw-bg-opacity: 1;background-color:rgb(29 78 216 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-200:hover{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-300:hover{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.hover\:bg-green-600:hover{--tw-bg-opacity: 1;background-color:rgb(22 163 74 / var(--tw-bg-opacity, 1))}.hover\:bg-green-700:hover{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity, 1))}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.hover\:bg-red-200:hover{--tw-bg-opacity: 1;background-color:rgb(254 202 202 / var(--tw-bg-opacity, 1))}.hover\:bg-red-50:hover{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.hover\:bg-white\/20:hover{background-color:#fff3}.hover\:bg-white\/30:hover{background-color:#ffffff4d}.hover\:bg-yellow-200:hover{--tw-bg-opacity: 1;background-color:rgb(254 240 138 / var(--tw-bg-opacity, 1))}.hover\:text-blue-800:hover{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.hover\:text-gray-900:hover{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.hover\:text-green-800:hover{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.hover\:text-primary-700:hover{--tw-text-opacity: 1;color:rgb(67 56 202 / var(--tw-text-opacity, 1))}.hover\:text-primary-800:hover{--tw-text-opacity: 1;color:rgb(55 48 163 / var(--tw-text-opacity, 1))}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:text-red-700:hover{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.hover\:text-red-800:hover{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.hover\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\:shadow-md:hover{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.disabled\:opacity-50:disabled{opacity:.5}.dark\:divide-gray-700:is(.dark *)>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:rgb(55 65 81 / var(--tw-divide-opacity, 1))}.dark\:border-gray-600:is(.dark *){--tw-border-opacity: 1;border-color:rgb(75 85 99 / var(--tw-border-opacity, 1))}.dark\:border-gray-700:is(.dark *){--tw-border-opacity: 1;border-color:rgb(55 65 81 / var(--tw-border-opacity, 1))}.dark\:border-gray-800:is(.dark *){--tw-border-opacity: 1;border-color:rgb(31 41 55 / var(--tw-border-opacity, 1))}.dark\:bg-blue-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(30 58 138 / var(--tw-bg-opacity, 1))}.dark\:bg-blue-900\/20:is(.dark *){background-color:#1e3a8a33}.dark\:bg-gray-600:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(75 85 99 / var(--tw-bg-opacity, 1))}.dark\:bg-gray-700:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(55 65 81 / var(--tw-bg-opacity, 1))}.dark\:bg-gray-700\/50:is(.dark *){background-color:#37415180}.dark\:bg-gray-800:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.dark\:bg-gray-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(17 24 39 / var(--tw-bg-opacity, 1))}.dark\:bg-green-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity, 1))}.dark\:bg-primary-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(49 46 129 / var(--tw-bg-opacity, 1))}.dark\:bg-primary-900\/30:is(.dark *){background-color:#312e814d}.dark\:bg-red-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.dark\:bg-red-900\/20:is(.dark *){background-color:#7f1d1d33}.dark\:bg-yellow-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(113 63 18 / var(--tw-bg-opacity, 1))}.dark\:bg-yellow-900\/20:is(.dark *){background-color:#713f1233}.dark\:text-blue-200:is(.dark *){--tw-text-opacity: 1;color:rgb(191 219 254 / var(--tw-text-opacity, 1))}.dark\:text-gray-200:is(.dark *){--tw-text-opacity: 1;color:rgb(229 231 235 / var(--tw-text-opacity, 1))}.dark\:text-gray-300:is(.dark *){--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.dark\:text-gray-400:is(.dark *){--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.dark\:text-green-200:is(.dark *){--tw-text-opacity: 1;color:rgb(187 247 208 / var(--tw-text-opacity, 1))}.dark\:text-primary-200:is(.dark *){--tw-text-opacity: 1;color:rgb(199 210 254 / var(--tw-text-opacity, 1))}.dark\:text-primary-300:is(.dark *){--tw-text-opacity: 1;color:rgb(165 180 252 / var(--tw-text-opacity, 1))}.dark\:text-primary-400:is(.dark *){--tw-text-opacity: 1;color:rgb(129 140 248 / var(--tw-text-opacity, 1))}.dark\:text-red-200:is(.dark *){--tw-text-opacity: 1;color:rgb(254 202 202 / var(--tw-text-opacity, 1))}.dark\:text-red-400:is(.dark *){--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.dark\:text-white:is(.dark *){--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.dark\:text-yellow-200:is(.dark *){--tw-text-opacity: 1;color:rgb(254 240 138 / var(--tw-text-opacity, 1))}.dark\:hover\:bg-gray-500:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(107 114 128 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-gray-700:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(55 65 81 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-gray-700\/50:hover:is(.dark *){background-color:#37415180}.dark\:hover\:bg-gray-800:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-red-900:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-red-900\/20:hover:is(.dark *){background-color:#7f1d1d33}@media (min-width: 640px){.sm\:block{display:block}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width: 768px){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width: 1024px){.lg\:ml-0{margin-left:0}.lg\:block{display:block}.lg\:hidden{display:none}.lg\:translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:px-6{padding-left:1.5rem;padding-right:1.5rem}.lg\:px-8{padding-left:2rem;padding-right:2rem}.lg\:pl-64{padding-left:16rem}} diff --git a/dist/index.html b/dist/index.html index a8c80b6..0623ee3 100644 --- a/dist/index.html +++ b/dist/index.html @@ -18,8 +18,8 @@ - - + +
diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 8a860bf..e82ffcb 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -80,6 +80,50 @@ "node": ">=12" } }, + "node_modules/@intlify/core-base": { + "version": "9.14.5", + "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.14.5.tgz", + "integrity": "sha512-5ah5FqZG4pOoHjkvs8mjtv+gPKYU0zCISaYNjBNNqYiaITxW8ZtVih3GS/oTOqN8d9/mDLyrjD46GBApNxmlsA==", + "license": "MIT", + "dependencies": { + "@intlify/message-compiler": "9.14.5", + "@intlify/shared": "9.14.5" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@intlify/message-compiler": { + "version": "9.14.5", + "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.14.5.tgz", + "integrity": "sha512-IHzgEu61/YIpQV5Pc3aRWScDcnFKWvQA9kigcINcCBXN8mbW+vk9SK+lDxA6STzKQsVJxUPg9ACC52pKKo3SVQ==", + "license": "MIT", + "dependencies": { + "@intlify/shared": "9.14.5", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@intlify/shared": { + "version": "9.14.5", + "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-9.14.5.tgz", + "integrity": "sha512-9gB+E53BYuAEMhbCAxVgG38EZrk59sxBtv3jSizNL2hEWlgjBjAw1AwpLHtNaeda12pe6W20OGEa0TwuMSRbyQ==", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.13", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", @@ -1821,6 +1865,27 @@ } } }, + "node_modules/vue-i18n": { + "version": "9.14.5", + "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.14.5.tgz", + "integrity": "sha512-0jQ9Em3ymWngyiIkj0+c/k7WgaPO+TNzjKSNq9BvBQaKJECqn9cd9fL4tkDhB5G1QBskGl9YxxbDAhgbFtpe2g==", + "deprecated": "v9 and v10 no longer supported. please migrate to v11. about maintenance status, see https://vue-i18n.intlify.dev/guide/maintenance.html", + "license": "MIT", + "dependencies": { + "@intlify/core-base": "9.14.5", + "@intlify/shared": "9.14.5", + "@vue/devtools-api": "^6.5.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + }, + "peerDependencies": { + "vue": "^3.0.0" + } + }, "node_modules/vue-router": { "version": "4.6.4", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.6.4.tgz", diff --git a/node_modules/@intlify/core-base/LICENSE b/node_modules/@intlify/core-base/LICENSE new file mode 100644 index 0000000..c02ff3e --- /dev/null +++ b/node_modules/@intlify/core-base/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2020 kazuya kawaguchi + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/@intlify/core-base/README.md b/node_modules/@intlify/core-base/README.md new file mode 100644 index 0000000..1b7c348 --- /dev/null +++ b/node_modules/@intlify/core-base/README.md @@ -0,0 +1,7 @@ +# @intlify/core-base + +The intlify core base module + +## :copyright: License + +[MIT](http://opensource.org/licenses/MIT) diff --git a/node_modules/@intlify/core-base/dist/core-base.cjs b/node_modules/@intlify/core-base/dist/core-base.cjs new file mode 100644 index 0000000..9856f52 --- /dev/null +++ b/node_modules/@intlify/core-base/dist/core-base.cjs @@ -0,0 +1,1956 @@ +/*! + * core-base v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +'use strict'; + +var messageCompiler = require('@intlify/message-compiler'); +var shared = require('@intlify/shared'); + +function isMessageAST(val) { + return (shared.isObject(val) && + resolveType(val) === 0 && + (shared.hasOwn(val, 'b') || shared.hasOwn(val, 'body'))); +} +const PROPS_BODY = ['b', 'body']; +function resolveBody(node) { + return resolveProps(node, PROPS_BODY); +} +const PROPS_CASES = ['c', 'cases']; +function resolveCases(node) { + return resolveProps(node, PROPS_CASES, []); +} +const PROPS_STATIC = ['s', 'static']; +function resolveStatic(node) { + return resolveProps(node, PROPS_STATIC); +} +const PROPS_ITEMS = ['i', 'items']; +function resolveItems(node) { + return resolveProps(node, PROPS_ITEMS, []); +} +const PROPS_TYPE = ['t', 'type']; +function resolveType(node) { + return resolveProps(node, PROPS_TYPE); +} +const PROPS_VALUE = ['v', 'value']; +function resolveValue$1(node, type) { + const resolved = resolveProps(node, PROPS_VALUE); + if (resolved != null) { + return resolved; + } + else { + throw createUnhandleNodeError(type); + } +} +const PROPS_MODIFIER = ['m', 'modifier']; +function resolveLinkedModifier(node) { + return resolveProps(node, PROPS_MODIFIER); +} +const PROPS_KEY = ['k', 'key']; +function resolveLinkedKey(node) { + const resolved = resolveProps(node, PROPS_KEY); + if (resolved) { + return resolved; + } + else { + throw createUnhandleNodeError(6 /* NodeTypes.Linked */); + } +} +function resolveProps(node, props, defaultValue) { + for (let i = 0; i < props.length; i++) { + const prop = props[i]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (shared.hasOwn(node, prop) && node[prop] != null) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return node[prop]; + } + } + return defaultValue; +} +const AST_NODE_PROPS_KEYS = [ + ...PROPS_BODY, + ...PROPS_CASES, + ...PROPS_STATIC, + ...PROPS_ITEMS, + ...PROPS_KEY, + ...PROPS_MODIFIER, + ...PROPS_VALUE, + ...PROPS_TYPE +]; +function createUnhandleNodeError(type) { + return new Error(`unhandled node type: ${type}`); +} + +const pathStateMachine = []; +pathStateMachine[0 /* States.BEFORE_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [0 /* States.BEFORE_PATH */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] +}; +pathStateMachine[1 /* States.IN_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] +}; +pathStateMachine[2 /* States.BEFORE_IDENT */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [2 /* States.BEFORE_IDENT */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */] +}; +pathStateMachine[3 /* States.IN_IDENT */] = { + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */, 1 /* Actions.PUSH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */, 1 /* Actions.PUSH */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */, 1 /* Actions.PUSH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */, 1 /* Actions.PUSH */] +}; +pathStateMachine[4 /* States.IN_SUB_PATH */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */], + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [ + 4 /* States.IN_SUB_PATH */, + 2 /* Actions.INC_SUB_PATH_DEPTH */ + ], + ["]" /* PathCharTypes.RIGHT_BRACKET */]: [1 /* States.IN_PATH */, 3 /* Actions.PUSH_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */] +}; +pathStateMachine[5 /* States.IN_SINGLE_QUOTE */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */] +}; +pathStateMachine[6 /* States.IN_DOUBLE_QUOTE */] = { + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */] +}; +/** + * Check if an expression is a literal value. + */ +const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/; +function isLiteral(exp) { + return literalValueRE.test(exp); +} +/** + * Strip quotes from a string + */ +function stripQuotes(str) { + const a = str.charCodeAt(0); + const b = str.charCodeAt(str.length - 1); + return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str; +} +/** + * Determine the type of a character in a keypath. + */ +function getPathCharType(ch) { + if (ch === undefined || ch === null) { + return "o" /* PathCharTypes.END_OF_FAIL */; + } + const code = ch.charCodeAt(0); + switch (code) { + case 0x5b: // [ + case 0x5d: // ] + case 0x2e: // . + case 0x22: // " + case 0x27: // ' + return ch; + case 0x5f: // _ + case 0x24: // $ + case 0x2d: // - + return "i" /* PathCharTypes.IDENT */; + case 0x09: // Tab (HT) + case 0x0a: // Newline (LF) + case 0x0d: // Return (CR) + case 0xa0: // No-break space (NBSP) + case 0xfeff: // Byte Order Mark (BOM) + case 0x2028: // Line Separator (LS) + case 0x2029: // Paragraph Separator (PS) + return "w" /* PathCharTypes.WORKSPACE */; + } + return "i" /* PathCharTypes.IDENT */; +} +/** + * Format a subPath, return its plain form if it is + * a literal string or number. Otherwise prepend the + * dynamic indicator (*). + */ +function formatSubPath(path) { + const trimmed = path.trim(); + // invalid leading 0 + if (path.charAt(0) === '0' && isNaN(parseInt(path))) { + return false; + } + return isLiteral(trimmed) + ? stripQuotes(trimmed) + : "*" /* PathCharTypes.ASTARISK */ + trimmed; +} +/** + * Parse a string path into an array of segments + */ +function parse(path) { + const keys = []; + let index = -1; + let mode = 0 /* States.BEFORE_PATH */; + let subPathDepth = 0; + let c; + let key; // eslint-disable-line + let newChar; + let type; + let transition; + let action; + let typeMap; + const actions = []; + actions[0 /* Actions.APPEND */] = () => { + if (key === undefined) { + key = newChar; + } + else { + key += newChar; + } + }; + actions[1 /* Actions.PUSH */] = () => { + if (key !== undefined) { + keys.push(key); + key = undefined; + } + }; + actions[2 /* Actions.INC_SUB_PATH_DEPTH */] = () => { + actions[0 /* Actions.APPEND */](); + subPathDepth++; + }; + actions[3 /* Actions.PUSH_SUB_PATH */] = () => { + if (subPathDepth > 0) { + subPathDepth--; + mode = 4 /* States.IN_SUB_PATH */; + actions[0 /* Actions.APPEND */](); + } + else { + subPathDepth = 0; + if (key === undefined) { + return false; + } + key = formatSubPath(key); + if (key === false) { + return false; + } + else { + actions[1 /* Actions.PUSH */](); + } + } + }; + function maybeUnescapeQuote() { + const nextChar = path[index + 1]; + if ((mode === 5 /* States.IN_SINGLE_QUOTE */ && + nextChar === "'" /* PathCharTypes.SINGLE_QUOTE */) || + (mode === 6 /* States.IN_DOUBLE_QUOTE */ && + nextChar === "\"" /* PathCharTypes.DOUBLE_QUOTE */)) { + index++; + newChar = '\\' + nextChar; + actions[0 /* Actions.APPEND */](); + return true; + } + } + while (mode !== null) { + index++; + c = path[index]; + if (c === '\\' && maybeUnescapeQuote()) { + continue; + } + type = getPathCharType(c); + typeMap = pathStateMachine[mode]; + transition = typeMap[type] || typeMap["l" /* PathCharTypes.ELSE */] || 8 /* States.ERROR */; + // check parse error + if (transition === 8 /* States.ERROR */) { + return; + } + mode = transition[0]; + if (transition[1] !== undefined) { + action = actions[transition[1]]; + if (action) { + newChar = c; + if (action() === false) { + return; + } + } + } + // check parse finish + if (mode === 7 /* States.AFTER_PATH */) { + return keys; + } + } +} +// path token cache +const cache = new Map(); +/** + * key-value message resolver + * + * @remarks + * Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ +function resolveWithKeyValue(obj, path) { + return shared.isObject(obj) ? obj[path] : null; +} +/** + * message resolver + * + * @remarks + * Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default. + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ +function resolveValue(obj, path) { + // check object + if (!shared.isObject(obj)) { + return null; + } + // parse path + let hit = cache.get(path); + if (!hit) { + hit = parse(path); + if (hit) { + cache.set(path, hit); + } + } + // check hit + if (!hit) { + return null; + } + // resolve path value + const len = hit.length; + let last = obj; + let i = 0; + while (i < len) { + const key = hit[i]; + /** + * NOTE: + * if `key` is intlify message format AST node key and `last` is intlify message format AST, skip it. + * because the AST node is not a key-value structure. + */ + if (AST_NODE_PROPS_KEYS.includes(key) && isMessageAST(last)) { + return null; + } + const val = last[key]; + if (val === undefined) { + return null; + } + if (shared.isFunction(last)) { + return null; + } + last = val; + i++; + } + return last; +} + +const DEFAULT_MODIFIER = (str) => str; +const DEFAULT_MESSAGE = (ctx) => ''; // eslint-disable-line +const DEFAULT_MESSAGE_DATA_TYPE = 'text'; +const DEFAULT_NORMALIZE = (values) => values.length === 0 ? '' : shared.join(values); +const DEFAULT_INTERPOLATE = shared.toDisplayString; +function pluralDefault(choice, choicesLength) { + choice = Math.abs(choice); + if (choicesLength === 2) { + // prettier-ignore + return choice + ? choice > 1 + ? 1 + : 0 + : 1; + } + return choice ? Math.min(choice, 2) : 0; +} +function getPluralIndex(options) { + // prettier-ignore + const index = shared.isNumber(options.pluralIndex) + ? options.pluralIndex + : -1; + // prettier-ignore + return options.named && (shared.isNumber(options.named.count) || shared.isNumber(options.named.n)) + ? shared.isNumber(options.named.count) + ? options.named.count + : shared.isNumber(options.named.n) + ? options.named.n + : index + : index; +} +function normalizeNamed(pluralIndex, props) { + if (!props.count) { + props.count = pluralIndex; + } + if (!props.n) { + props.n = pluralIndex; + } +} +function createMessageContext(options = {}) { + const locale = options.locale; + const pluralIndex = getPluralIndex(options); + const pluralRule = shared.isObject(options.pluralRules) && + shared.isString(locale) && + shared.isFunction(options.pluralRules[locale]) + ? options.pluralRules[locale] + : pluralDefault; + const orgPluralRule = shared.isObject(options.pluralRules) && + shared.isString(locale) && + shared.isFunction(options.pluralRules[locale]) + ? pluralDefault + : undefined; + const plural = (messages) => { + return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)]; + }; + const _list = options.list || []; + const list = (index) => _list[index]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _named = options.named || shared.create(); + shared.isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named); + const named = (key) => _named[key]; + function message(key) { + // prettier-ignore + const msg = shared.isFunction(options.messages) + ? options.messages(key) + : shared.isObject(options.messages) + ? options.messages[key] + : false; + return !msg + ? options.parent + ? options.parent.message(key) // resolve from parent messages + : DEFAULT_MESSAGE + : msg; + } + const _modifier = (name) => options.modifiers + ? options.modifiers[name] + : DEFAULT_MODIFIER; + const normalize = shared.isPlainObject(options.processor) && shared.isFunction(options.processor.normalize) + ? options.processor.normalize + : DEFAULT_NORMALIZE; + const interpolate = shared.isPlainObject(options.processor) && + shared.isFunction(options.processor.interpolate) + ? options.processor.interpolate + : DEFAULT_INTERPOLATE; + const type = shared.isPlainObject(options.processor) && shared.isString(options.processor.type) + ? options.processor.type + : DEFAULT_MESSAGE_DATA_TYPE; + const linked = (key, ...args) => { + const [arg1, arg2] = args; + let type = 'text'; + let modifier = ''; + if (args.length === 1) { + if (shared.isObject(arg1)) { + modifier = arg1.modifier || modifier; + type = arg1.type || type; + } + else if (shared.isString(arg1)) { + modifier = arg1 || modifier; + } + } + else if (args.length === 2) { + if (shared.isString(arg1)) { + modifier = arg1 || modifier; + } + if (shared.isString(arg2)) { + type = arg2 || type; + } + } + const ret = message(key)(ctx); + const msg = + // The message in vnode resolved with linked are returned as an array by processor.nomalize + type === 'vnode' && shared.isArray(ret) && modifier + ? ret[0] + : ret; + return modifier ? _modifier(modifier)(msg, type) : msg; + }; + const ctx = { + ["list" /* HelperNameMap.LIST */]: list, + ["named" /* HelperNameMap.NAMED */]: named, + ["plural" /* HelperNameMap.PLURAL */]: plural, + ["linked" /* HelperNameMap.LINKED */]: linked, + ["message" /* HelperNameMap.MESSAGE */]: message, + ["type" /* HelperNameMap.TYPE */]: type, + ["interpolate" /* HelperNameMap.INTERPOLATE */]: interpolate, + ["normalize" /* HelperNameMap.NORMALIZE */]: normalize, + ["values" /* HelperNameMap.VALUES */]: shared.assign(shared.create(), _list, _named) + }; + return ctx; +} + +let devtools = null; +function setDevToolsHook(hook) { + devtools = hook; +} +function getDevToolsHook() { + return devtools; +} +function initI18nDevTools(i18n, version, meta) { + // TODO: queue if devtools is undefined + devtools && + devtools.emit("i18n:init" /* IntlifyDevToolsHooks.I18nInit */, { + timestamp: Date.now(), + i18n, + version, + meta + }); +} +const translateDevTools = /* #__PURE__*/ createDevToolsHook("function:translate" /* IntlifyDevToolsHooks.FunctionTranslate */); +function createDevToolsHook(hook) { + return (payloads) => devtools && devtools.emit(hook, payloads); +} + +const code$1 = messageCompiler.CompileWarnCodes.__EXTEND_POINT__; +const inc$1 = shared.incrementer(code$1); +const CoreWarnCodes = { + NOT_FOUND_KEY: code$1, // 2 + FALLBACK_TO_TRANSLATE: inc$1(), // 3 + CANNOT_FORMAT_NUMBER: inc$1(), // 4 + FALLBACK_TO_NUMBER_FORMAT: inc$1(), // 5 + CANNOT_FORMAT_DATE: inc$1(), // 6 + FALLBACK_TO_DATE_FORMAT: inc$1(), // 7 + EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc$1(), // 8 + __EXTEND_POINT__: inc$1() // 9 +}; +/** @internal */ +const warnMessages = { + [CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`, + [CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`, + [CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`, + [CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]: `This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future.` +}; +function getWarnMessage(code, ...args) { + return shared.format(warnMessages[code], ...args); +} + +const code = messageCompiler.CompileErrorCodes.__EXTEND_POINT__; +const inc = shared.incrementer(code); +const CoreErrorCodes = { + INVALID_ARGUMENT: code, // 17 + INVALID_DATE_ARGUMENT: inc(), // 18 + INVALID_ISO_DATE_ARGUMENT: inc(), // 19 + NOT_SUPPORT_NON_STRING_MESSAGE: inc(), // 20 + NOT_SUPPORT_LOCALE_PROMISE_VALUE: inc(), // 21 + NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: inc(), // 22 + NOT_SUPPORT_LOCALE_TYPE: inc(), // 23 + __EXTEND_POINT__: inc() // 24 +}; +function createCoreError(code) { + return messageCompiler.createCompileError(code, null, { messages: errorMessages } ); +} +/** @internal */ +const errorMessages = { + [CoreErrorCodes.INVALID_ARGUMENT]: 'Invalid arguments', + [CoreErrorCodes.INVALID_DATE_ARGUMENT]: 'The date provided is an invalid Date object.' + + 'Make sure your Date represents a valid date.', + [CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: 'The argument provided is not a valid ISO date string', + [CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE]: 'Not support non-string message', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]: 'cannot support promise value', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]: 'cannot support async function', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: 'cannot support locale type' +}; + +/** @internal */ +function getLocale(context, options) { + return options.locale != null + ? resolveLocale(options.locale) + : resolveLocale(context.locale); +} +let _resolveLocale; +/** @internal */ +function resolveLocale(locale) { + if (shared.isString(locale)) { + return locale; + } + else { + if (shared.isFunction(locale)) { + if (locale.resolvedOnce && _resolveLocale != null) { + return _resolveLocale; + } + else if (locale.constructor.name === 'Function') { + const resolve = locale(); + if (shared.isPromise(resolve)) { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE); + } + return (_resolveLocale = resolve); + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION); + } + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE); + } + } +} +/** + * Fallback with simple implemenation + * + * @remarks + * A fallback locale function implemented with a simple fallback algorithm. + * + * Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nGeneral + */ +function fallbackWithSimple(ctx, fallback, start // eslint-disable-line @typescript-eslint/no-unused-vars +) { + // prettier-ignore + return [...new Set([ + start, + ...(shared.isArray(fallback) + ? fallback + : shared.isObject(fallback) + ? Object.keys(fallback) + : shared.isString(fallback) + ? [fallback] + : [start]) + ])]; +} +/** + * Fallback with locale chain + * + * @remarks + * A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @VueI18nGeneral + */ +function fallbackWithLocaleChain(ctx, fallback, start) { + const startLocale = shared.isString(start) ? start : DEFAULT_LOCALE; + const context = ctx; + if (!context.__localeChainCache) { + context.__localeChainCache = new Map(); + } + let chain = context.__localeChainCache.get(startLocale); + if (!chain) { + chain = []; + // first block defined by start + let block = [start]; + // while any intervening block found + while (shared.isArray(block)) { + block = appendBlockToChain(chain, block, fallback); + } + // prettier-ignore + // last block defined by default + const defaults = shared.isArray(fallback) || !shared.isPlainObject(fallback) + ? fallback + : fallback['default'] + ? fallback['default'] + : null; + // convert defaults to array + block = shared.isString(defaults) ? [defaults] : defaults; + if (shared.isArray(block)) { + appendBlockToChain(chain, block, false); + } + context.__localeChainCache.set(startLocale, chain); + } + return chain; +} +function appendBlockToChain(chain, block, blocks) { + let follow = true; + for (let i = 0; i < block.length && shared.isBoolean(follow); i++) { + const locale = block[i]; + if (shared.isString(locale)) { + follow = appendLocaleToChain(chain, block[i], blocks); + } + } + return follow; +} +function appendLocaleToChain(chain, locale, blocks) { + let follow; + const tokens = locale.split('-'); + do { + const target = tokens.join('-'); + follow = appendItemToChain(chain, target, blocks); + tokens.splice(-1, 1); + } while (tokens.length && follow === true); + return follow; +} +function appendItemToChain(chain, target, blocks) { + let follow = false; + if (!chain.includes(target)) { + follow = true; + if (target) { + follow = target[target.length - 1] !== '!'; + const locale = target.replace(/!/g, ''); + chain.push(locale); + if ((shared.isArray(blocks) || shared.isPlainObject(blocks)) && + blocks[locale] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + follow = blocks[locale]; + } + } + } + return follow; +} + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Intlify core-base version + * @internal + */ +const VERSION = '9.14.5'; +const NOT_REOSLVED = -1; +const DEFAULT_LOCALE = 'en-US'; +const MISSING_RESOLVE_VALUE = ''; +const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`; +function getDefaultLinkedModifiers() { + return { + upper: (val, type) => { + // prettier-ignore + return type === 'text' && shared.isString(val) + ? val.toUpperCase() + : type === 'vnode' && shared.isObject(val) && '__v_isVNode' in val + ? val.children.toUpperCase() + : val; + }, + lower: (val, type) => { + // prettier-ignore + return type === 'text' && shared.isString(val) + ? val.toLowerCase() + : type === 'vnode' && shared.isObject(val) && '__v_isVNode' in val + ? val.children.toLowerCase() + : val; + }, + capitalize: (val, type) => { + // prettier-ignore + return (type === 'text' && shared.isString(val) + ? capitalize(val) + : type === 'vnode' && shared.isObject(val) && '__v_isVNode' in val + ? capitalize(val.children) + : val); + } + }; +} +let _compiler; +function registerMessageCompiler(compiler) { + _compiler = compiler; +} +let _resolver; +/** + * Register the message resolver + * + * @param resolver - A {@link MessageResolver} function + * + * @VueI18nGeneral + */ +function registerMessageResolver(resolver) { + _resolver = resolver; +} +let _fallbacker; +/** + * Register the locale fallbacker + * + * @param fallbacker - A {@link LocaleFallbacker} function + * + * @VueI18nGeneral + */ +function registerLocaleFallbacker(fallbacker) { + _fallbacker = fallbacker; +} +// Additional Meta for Intlify DevTools +let _additionalMeta = null; +/* #__NO_SIDE_EFFECTS__ */ +const setAdditionalMeta = (meta) => { + _additionalMeta = meta; +}; +/* #__NO_SIDE_EFFECTS__ */ +const getAdditionalMeta = () => _additionalMeta; +let _fallbackContext = null; +const setFallbackContext = (context) => { + _fallbackContext = context; +}; +const getFallbackContext = () => _fallbackContext; +// ID for CoreContext +let _cid = 0; +function createCoreContext(options = {}) { + // setup options + const onWarn = shared.isFunction(options.onWarn) ? options.onWarn : shared.warn; + const version = shared.isString(options.version) ? options.version : VERSION; + const locale = shared.isString(options.locale) || shared.isFunction(options.locale) + ? options.locale + : DEFAULT_LOCALE; + const _locale = shared.isFunction(locale) ? DEFAULT_LOCALE : locale; + const fallbackLocale = shared.isArray(options.fallbackLocale) || + shared.isPlainObject(options.fallbackLocale) || + shared.isString(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale; + const messages = shared.isPlainObject(options.messages) + ? options.messages + : createResources(_locale); + const datetimeFormats = shared.isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : createResources(_locale) + ; + const numberFormats = shared.isPlainObject(options.numberFormats) + ? options.numberFormats + : createResources(_locale) + ; + const modifiers = shared.assign(shared.create(), options.modifiers, getDefaultLinkedModifiers()); + const pluralRules = options.pluralRules || shared.create(); + const missing = shared.isFunction(options.missing) ? options.missing : null; + const missingWarn = shared.isBoolean(options.missingWarn) || shared.isRegExp(options.missingWarn) + ? options.missingWarn + : true; + const fallbackWarn = shared.isBoolean(options.fallbackWarn) || shared.isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + const fallbackFormat = !!options.fallbackFormat; + const unresolving = !!options.unresolving; + const postTranslation = shared.isFunction(options.postTranslation) + ? options.postTranslation + : null; + const processor = shared.isPlainObject(options.processor) ? options.processor : null; + const warnHtmlMessage = shared.isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const escapeParameter = !!options.escapeParameter; + const messageCompiler = shared.isFunction(options.messageCompiler) + ? options.messageCompiler + : _compiler; + if (shared.isFunction(options.messageCompiler)) { + shared.warnOnce(getWarnMessage(CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER)); + } + const messageResolver = shared.isFunction(options.messageResolver) + ? options.messageResolver + : _resolver || resolveWithKeyValue; + const localeFallbacker = shared.isFunction(options.localeFallbacker) + ? options.localeFallbacker + : _fallbacker || fallbackWithSimple; + const fallbackContext = shared.isObject(options.fallbackContext) + ? options.fallbackContext + : undefined; + // setup internal options + const internalOptions = options; + const __datetimeFormatters = shared.isObject(internalOptions.__datetimeFormatters) + ? internalOptions.__datetimeFormatters + : new Map() + ; + const __numberFormatters = shared.isObject(internalOptions.__numberFormatters) + ? internalOptions.__numberFormatters + : new Map() + ; + const __meta = shared.isObject(internalOptions.__meta) ? internalOptions.__meta : {}; + _cid++; + const context = { + version, + cid: _cid, + locale, + fallbackLocale, + messages, + modifiers, + pluralRules, + missing, + missingWarn, + fallbackWarn, + fallbackFormat, + unresolving, + postTranslation, + processor, + warnHtmlMessage, + escapeParameter, + messageCompiler, + messageResolver, + localeFallbacker, + fallbackContext, + onWarn, + __meta + }; + { + context.datetimeFormats = datetimeFormats; + context.numberFormats = numberFormats; + context.__datetimeFormatters = __datetimeFormatters; + context.__numberFormatters = __numberFormatters; + } + // for vue-devtools timeline event + { + context.__v_emitter = + internalOptions.__v_emitter != null + ? internalOptions.__v_emitter + : undefined; + } + // NOTE: experimental !! + { + initI18nDevTools(context, version, __meta); + } + return context; +} +const createResources = (locale) => ({ [locale]: shared.create() }); +/** @internal */ +function isTranslateFallbackWarn(fallback, key) { + return fallback instanceof RegExp ? fallback.test(key) : fallback; +} +/** @internal */ +function isTranslateMissingWarn(missing, key) { + return missing instanceof RegExp ? missing.test(key) : missing; +} +/** @internal */ +function handleMissing(context, key, locale, missingWarn, type) { + const { missing, onWarn } = context; + // for vue-devtools timeline event + { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("missing" /* VueDevToolsTimelineEvents.MISSING */, { + locale, + key, + type, + groupId: `${type}:${key}` + }); + } + } + if (missing !== null) { + const ret = missing(context, locale, key, type); + return shared.isString(ret) ? ret : key; + } + else { + if (isTranslateMissingWarn(missingWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.NOT_FOUND_KEY, { key, locale })); + } + return key; + } +} +/** @internal */ +function updateFallbackLocale(ctx, locale, fallback) { + const context = ctx; + context.__localeChainCache = new Map(); + ctx.localeFallbacker(ctx, fallback, locale); +} +/** @internal */ +function isAlmostSameLocale(locale, compareLocale) { + if (locale === compareLocale) + return false; + return locale.split('-')[0] === compareLocale.split('-')[0]; +} +/** @internal */ +function isImplicitFallback(targetLocale, locales) { + const index = locales.indexOf(targetLocale); + if (index === -1) { + return false; + } + for (let i = index + 1; i < locales.length; i++) { + if (isAlmostSameLocale(targetLocale, locales[i])) { + return true; + } + } + return false; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +function format(ast) { + const msg = (ctx) => formatParts(ctx, ast); + return msg; +} +function formatParts(ctx, ast) { + const body = resolveBody(ast); + if (body == null) { + throw createUnhandleNodeError(0 /* NodeTypes.Resource */); + } + const type = resolveType(body); + if (type === 1 /* NodeTypes.Plural */) { + const plural = body; + const cases = resolveCases(plural); + return ctx.plural(cases.reduce((messages, c) => [ + ...messages, + formatMessageParts(ctx, c) + ], [])); + } + else { + return formatMessageParts(ctx, body); + } +} +function formatMessageParts(ctx, node) { + const static_ = resolveStatic(node); + if (static_ != null) { + return ctx.type === 'text' + ? static_ + : ctx.normalize([static_]); + } + else { + const messages = resolveItems(node).reduce((acm, c) => [...acm, formatMessagePart(ctx, c)], []); + return ctx.normalize(messages); + } +} +function formatMessagePart(ctx, node) { + const type = resolveType(node); + switch (type) { + case 3 /* NodeTypes.Text */: { + return resolveValue$1(node, type); + } + case 9 /* NodeTypes.Literal */: { + return resolveValue$1(node, type); + } + case 4 /* NodeTypes.Named */: { + const named = node; + if (shared.hasOwn(named, 'k') && named.k) { + return ctx.interpolate(ctx.named(named.k)); + } + if (shared.hasOwn(named, 'key') && named.key) { + return ctx.interpolate(ctx.named(named.key)); + } + throw createUnhandleNodeError(type); + } + case 5 /* NodeTypes.List */: { + const list = node; + if (shared.hasOwn(list, 'i') && shared.isNumber(list.i)) { + return ctx.interpolate(ctx.list(list.i)); + } + if (shared.hasOwn(list, 'index') && shared.isNumber(list.index)) { + return ctx.interpolate(ctx.list(list.index)); + } + throw createUnhandleNodeError(type); + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + const modifier = resolveLinkedModifier(linked); + const key = resolveLinkedKey(linked); + return ctx.linked(formatMessagePart(ctx, key), modifier ? formatMessagePart(ctx, modifier) : undefined, ctx.type); + } + case 7 /* NodeTypes.LinkedKey */: { + return resolveValue$1(node, type); + } + case 8 /* NodeTypes.LinkedModifier */: { + return resolveValue$1(node, type); + } + default: + throw new Error(`unhandled node on format message part: ${type}`); + } +} + +const WARN_MESSAGE = `Detected HTML in '{source}' message. Recommend not using HTML messages to avoid XSS.`; +function checkHtmlMessage(source, warnHtmlMessage) { + if (warnHtmlMessage && messageCompiler.detectHtmlTag(source)) { + shared.warn(shared.format(WARN_MESSAGE, { source })); + } +} +const defaultOnCacheKey = (message) => message; +let compileCache = shared.create(); +function onCompileWarn(_warn) { + if (_warn.code === messageCompiler.CompileWarnCodes.USE_MODULO_SYNTAX) { + shared.warn(`The use of named interpolation with modulo syntax is deprecated. ` + + `It will be removed in v10.\n` + + `reference: https://vue-i18n.intlify.dev/guide/essentials/syntax#rails-i18n-format \n` + + `(message compiler warning message: ${_warn.message})`); + } +} +function clearCompileCache() { + compileCache = shared.create(); +} +function baseCompile(message, options = {}) { + // error detecting on compile + let detectError = false; + const onError = options.onError || messageCompiler.defaultOnError; + options.onError = (err) => { + detectError = true; + onError(err); + }; + // compile with mesasge-compiler + return { ...messageCompiler.baseCompile(message, options), detectError }; +} +/* #__NO_SIDE_EFFECTS__ */ +const compileToFunction = (message, context) => { + if (!shared.isString(message)) { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE); + } + // set onWarn + { + context.onWarn = onCompileWarn; + } + { + // check HTML message + const warnHtmlMessage = shared.isBoolean(context.warnHtmlMessage) + ? context.warnHtmlMessage + : true; + checkHtmlMessage(message, warnHtmlMessage); + // check caches + const onCacheKey = context.onCacheKey || defaultOnCacheKey; + const cacheKey = onCacheKey(message); + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compile + const { code, detectError } = baseCompile(message, context); + // evaluate function + const msg = new Function(`return ${code}`)(); + // if occurred compile error, don't cache + return !detectError + ? (compileCache[cacheKey] = msg) + : msg; + } +}; +function compile(message, context) { + // set onWarn + { + context.onWarn = onCompileWarn; + } + if (shared.isString(message)) { + // check HTML message + const warnHtmlMessage = shared.isBoolean(context.warnHtmlMessage) + ? context.warnHtmlMessage + : true; + checkHtmlMessage(message, warnHtmlMessage); + // check caches + const onCacheKey = context.onCacheKey || defaultOnCacheKey; + const cacheKey = onCacheKey(message); + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compile with JIT mode + const { ast, detectError } = baseCompile(message, { + ...context, + location: true, + jit: true + }); + // compose message function from AST + const msg = format(ast); + // if occurred compile error, don't cache + return !detectError + ? (compileCache[cacheKey] = msg) + : msg; + } + else { + if (!isMessageAST(message)) { + shared.warn(`the message that is resolve with key '${context.key}' is not supported for jit compilation`); + return (() => message); + } + // AST case (passed from bundler) + const cacheKey = message.cacheKey; + if (cacheKey) { + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compose message function from message (AST) + return (compileCache[cacheKey] = + format(message)); + } + else { + return format(message); + } + } +} + +const NOOP_MESSAGE_FUNCTION = () => ''; +const isMessageFunction = (val) => shared.isFunction(val); +// implementation of `translate` function +function translate(context, ...args) { + const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context; + const [key, options] = parseTranslateArgs(...args); + const missingWarn = shared.isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = shared.isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const escapeParameter = shared.isBoolean(options.escapeParameter) + ? options.escapeParameter + : context.escapeParameter; + const resolvedMessage = !!options.resolvedMessage; + // prettier-ignore + const defaultMsgOrKey = shared.isString(options.default) || shared.isBoolean(options.default) // default by function option + ? !shared.isBoolean(options.default) + ? options.default + : (!messageCompiler ? () => key : key) + : fallbackFormat // default by `fallbackFormat` option + ? (!messageCompiler ? () => key : key) + : ''; + const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== ''; + const locale = getLocale(context, options); + // escape params + escapeParameter && escapeParams(options); + // resolve message format + // eslint-disable-next-line prefer-const + let [formatScope, targetLocale, message] = !resolvedMessage + ? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) + : [ + key, + locale, + messages[locale] || shared.create() + ]; + // NOTE: + // Fix to work around `ssrTransfrom` bug in Vite. + // https://github.com/vitejs/vite/issues/4306 + // To get around this, use temporary variables. + // https://github.com/nuxt/framework/issues/1461#issuecomment-954606243 + let format = formatScope; + // if you use default message, set it as message format! + let cacheBaseKey = key; + if (!resolvedMessage && + !(shared.isString(format) || + isMessageAST(format) || + isMessageFunction(format))) { + if (enableDefaultMsg) { + format = defaultMsgOrKey; + cacheBaseKey = format; + } + } + // checking message format and target locale + if (!resolvedMessage && + (!(shared.isString(format) || + isMessageAST(format) || + isMessageFunction(format)) || + !shared.isString(targetLocale))) { + return unresolving ? NOT_REOSLVED : key; + } + // TODO: refactor + if (shared.isString(format) && context.messageCompiler == null) { + shared.warn(`The message format compilation is not supported in this build. ` + + `Because message compiler isn't included. ` + + `You need to pre-compilation all message format. ` + + `So translate function return '${key}'.`); + return key; + } + // setup compile error detecting + let occurred = false; + const onError = () => { + occurred = true; + }; + // compile message format + const msg = !isMessageFunction(format) + ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) + : format; + // if occurred compile error, return the message format + if (occurred) { + return format; + } + // evaluate message with context + const ctxOptions = getMessageContextOptions(context, targetLocale, message, options); + const msgContext = createMessageContext(ctxOptions); + const messaged = evaluateMessage(context, msg, msgContext); + // if use post translation option, proceed it with handler + let ret = postTranslation + ? postTranslation(messaged, key) + : messaged; + // apply HTML sanitization for security + if (escapeParameter && shared.isString(ret)) { + ret = shared.sanitizeTranslatedHtml(ret); + } + // NOTE: experimental !! + { + // prettier-ignore + const payloads = { + timestamp: Date.now(), + key: shared.isString(key) + ? key + : isMessageFunction(format) + ? format.key + : '', + locale: targetLocale || (isMessageFunction(format) + ? format.locale + : ''), + format: shared.isString(format) + ? format + : isMessageFunction(format) + ? format.source + : '', + message: ret + }; + payloads.meta = shared.assign({}, context.__meta, getAdditionalMeta() || {}); + translateDevTools(payloads); + } + return ret; +} +function escapeParams(options) { + if (shared.isArray(options.list)) { + options.list = options.list.map(item => shared.isString(item) ? shared.escapeHtml(item) : item); + } + else if (shared.isObject(options.named)) { + Object.keys(options.named).forEach(key => { + if (shared.isString(options.named[key])) { + options.named[key] = shared.escapeHtml(options.named[key]); + } + }); + } +} +function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) { + const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context; + const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any + let message = shared.create(); + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'translate'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + !isAlmostSameLocale(locale, targetLocale) && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_TRANSLATE, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + message = + messages[targetLocale] || shared.create(); + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (shared.inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-resolve-start'; + endTag = 'intlify-message-resolve-end'; + shared.mark && shared.mark(startTag); + } + if ((format = resolveValue(message, key)) === null) { + // if null, resolve with object key path + format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any + } + // for vue-devtools timeline event + if (shared.inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start && format) { + emitter.emit("message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, { + type: "message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, + key, + message: format, + time: end - start, + groupId: `${type}:${key}` + }); + } + if (startTag && endTag && shared.mark && shared.measure) { + shared.mark(endTag); + shared.measure('intlify message resolve', startTag, endTag); + } + } + if (shared.isString(format) || isMessageAST(format) || isMessageFunction(format)) { + break; + } + if (!isImplicitFallback(targetLocale, locales)) { + const missingRet = handleMissing(context, // eslint-disable-line @typescript-eslint/no-explicit-any + key, targetLocale, missingWarn, type); + if (missingRet !== key) { + format = missingRet; + } + } + from = to; + } + return [format, targetLocale, message]; +} +function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) { + const { messageCompiler, warnHtmlMessage } = context; + if (isMessageFunction(format)) { + const msg = format; + msg.locale = msg.locale || targetLocale; + msg.key = msg.key || key; + return msg; + } + if (messageCompiler == null) { + const msg = (() => format); + msg.locale = targetLocale; + msg.key = key; + return msg; + } + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (shared.inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-compilation-start'; + endTag = 'intlify-message-compilation-end'; + shared.mark && shared.mark(startTag); + } + const msg = messageCompiler(format, getCompileContext(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, onError)); + // for vue-devtools timeline event + if (shared.inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, { + type: "message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, + message: format, + time: end - start, + groupId: `${'translate'}:${key}` + }); + } + if (startTag && endTag && shared.mark && shared.measure) { + shared.mark(endTag); + shared.measure('intlify message compilation', startTag, endTag); + } + } + msg.locale = targetLocale; + msg.key = key; + msg.source = format; + return msg; +} +function evaluateMessage(context, msg, msgCtx) { + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (shared.inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-evaluation-start'; + endTag = 'intlify-message-evaluation-end'; + shared.mark && shared.mark(startTag); + } + const messaged = msg(msgCtx); + // for vue-devtools timeline event + if (shared.inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, { + type: "message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, + value: messaged, + time: end - start, + groupId: `${'translate'}:${msg.key}` + }); + } + if (startTag && endTag && shared.mark && shared.measure) { + shared.mark(endTag); + shared.measure('intlify message evaluation', startTag, endTag); + } + } + return messaged; +} +/** @internal */ +function parseTranslateArgs(...args) { + const [arg1, arg2, arg3] = args; + const options = shared.create(); + if (!shared.isString(arg1) && + !shared.isNumber(arg1) && + !isMessageFunction(arg1) && + !isMessageAST(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + // prettier-ignore + const key = shared.isNumber(arg1) + ? String(arg1) + : isMessageFunction(arg1) + ? arg1 + : arg1; + if (shared.isNumber(arg2)) { + options.plural = arg2; + } + else if (shared.isString(arg2)) { + options.default = arg2; + } + else if (shared.isPlainObject(arg2) && !shared.isEmptyObject(arg2)) { + options.named = arg2; + } + else if (shared.isArray(arg2)) { + options.list = arg2; + } + if (shared.isNumber(arg3)) { + options.plural = arg3; + } + else if (shared.isString(arg3)) { + options.default = arg3; + } + else if (shared.isPlainObject(arg3)) { + shared.assign(options, arg3); + } + return [key, options]; +} +function getCompileContext(context, locale, key, source, warnHtmlMessage, onError) { + return { + locale, + key, + warnHtmlMessage, + onError: (err) => { + onError && onError(err); + { + const _source = getSourceForCodeFrame(source); + const message = `Message compilation error: ${err.message}`; + const codeFrame = err.location && + _source && + shared.generateCodeFrame(_source, err.location.start.offset, err.location.end.offset); + const emitter = context.__v_emitter; + if (emitter && _source) { + emitter.emit("compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */, { + message: _source, + error: err.message, + start: err.location && err.location.start.offset, + end: err.location && err.location.end.offset, + groupId: `${'translate'}:${key}` + }); + } + console.error(codeFrame ? `${message}\n${codeFrame}` : message); + } + }, + onCacheKey: (source) => shared.generateFormatCacheKey(locale, key, source) + }; +} +function getSourceForCodeFrame(source) { + if (shared.isString(source)) { + return source; + } + else { + if (source.loc && source.loc.source) { + return source.loc.source; + } + } +} +function getMessageContextOptions(context, locale, message, options) { + const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context; + const resolveMessage = (key) => { + let val = resolveValue(message, key); + // fallback to root context + if (val == null && fallbackContext) { + const [, , message] = resolveMessageFormat(fallbackContext, key, locale, fallbackLocale, fallbackWarn, missingWarn); + val = resolveValue(message, key); + } + if (shared.isString(val) || isMessageAST(val)) { + let occurred = false; + const onError = () => { + occurred = true; + }; + const msg = compileMessageFormat(context, key, locale, val, key, onError); + return !occurred + ? msg + : NOOP_MESSAGE_FUNCTION; + } + else if (isMessageFunction(val)) { + return val; + } + else { + // TODO: should be implemented warning message + return NOOP_MESSAGE_FUNCTION; + } + }; + const ctxOptions = { + locale, + modifiers, + pluralRules, + messages: resolveMessage + }; + if (context.processor) { + ctxOptions.processor = context.processor; + } + if (options.list) { + ctxOptions.list = options.list; + } + if (options.named) { + ctxOptions.named = options.named; + } + if (shared.isNumber(options.plural)) { + ctxOptions.pluralIndex = options.plural; + } + return ctxOptions; +} + +const intlDefined = typeof Intl !== 'undefined'; +const Availabilities = { + dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined', + numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined' +}; + +// implementation of `datetime` function +function datetime(context, ...args) { + const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __datetimeFormatters } = context; + if (!Availabilities.dateTimeFormat) { + onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_DATE)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseDateTimeArgs(...args); + const missingWarn = shared.isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = shared.isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!shared.isString(key) || key === '') { + return new Intl.DateTimeFormat(locale, overrides).format(value); + } + // resolve format + let datetimeFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'datetime format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + datetimeFormat = + datetimeFormats[targetLocale] || {}; + format = datetimeFormat[key]; + if (shared.isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!shared.isPlainObject(format) || !shared.isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!shared.isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __datetimeFormatters.get(id); + if (!formatter) { + formatter = new Intl.DateTimeFormat(targetLocale, shared.assign({}, format, overrides)); + __datetimeFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); +} +/** @internal */ +const DATETIME_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'weekday', + 'era', + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second', + 'timeZoneName', + 'formatMatcher', + 'hour12', + 'timeZone', + 'dateStyle', + 'timeStyle', + 'calendar', + 'dayPeriod', + 'numberingSystem', + 'hourCycle', + 'fractionalSecondDigits' +]; +/** @internal */ +function parseDateTimeArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = shared.create(); + let overrides = shared.create(); + let value; + if (shared.isString(arg1)) { + // Only allow ISO strings - other date formats are often supported, + // but may cause different results in different browsers. + const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/); + if (!matches) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + // Some browsers can not parse the iso datetime separated by space, + // this is a compromise solution by replace the 'T'/' ' with 'T' + const dateTime = matches[3] + ? matches[3].trim().startsWith('T') + ? `${matches[1].trim()}${matches[3].trim()}` + : `${matches[1].trim()}T${matches[3].trim()}` + : matches[1].trim(); + value = new Date(dateTime); + try { + // This will fail if the date is not valid + value.toISOString(); + } + catch (e) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + } + else if (shared.isDate(arg1)) { + if (isNaN(arg1.getTime())) { + throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT); + } + value = arg1; + } + else if (shared.isNumber(arg1)) { + value = arg1; + } + else { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + if (shared.isString(arg2)) { + options.key = arg2; + } + else if (shared.isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (shared.isString(arg3)) { + options.locale = arg3; + } + else if (shared.isPlainObject(arg3)) { + overrides = arg3; + } + if (shared.isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; +} +/** @internal */ +function clearDateTimeFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__datetimeFormatters.has(id)) { + continue; + } + context.__datetimeFormatters.delete(id); + } +} + +// implementation of `number` function +function number(context, ...args) { + const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __numberFormatters } = context; + if (!Availabilities.numberFormat) { + onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_NUMBER)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseNumberArgs(...args); + const missingWarn = shared.isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = shared.isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!shared.isString(key) || key === '') { + return new Intl.NumberFormat(locale, overrides).format(value); + } + // resolve format + let numberFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'number format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + numberFormat = + numberFormats[targetLocale] || {}; + format = numberFormat[key]; + if (shared.isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!shared.isPlainObject(format) || !shared.isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!shared.isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __numberFormatters.get(id); + if (!formatter) { + formatter = new Intl.NumberFormat(targetLocale, shared.assign({}, format, overrides)); + __numberFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); +} +/** @internal */ +const NUMBER_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'style', + 'currency', + 'currencyDisplay', + 'currencySign', + 'useGrouping', + 'minimumIntegerDigits', + 'minimumFractionDigits', + 'maximumFractionDigits', + 'minimumSignificantDigits', + 'maximumSignificantDigits', + 'compactDisplay', + 'notation', + 'signDisplay', + 'unit', + 'unitDisplay', + 'roundingMode', + 'roundingPriority', + 'roundingIncrement', + 'trailingZeroDisplay' +]; +/** @internal */ +function parseNumberArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = shared.create(); + let overrides = shared.create(); + if (!shared.isNumber(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + const value = arg1; + if (shared.isString(arg2)) { + options.key = arg2; + } + else if (shared.isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (shared.isString(arg3)) { + options.locale = arg3; + } + else if (shared.isPlainObject(arg3)) { + overrides = arg3; + } + if (shared.isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; +} +/** @internal */ +function clearNumberFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__numberFormatters.has(id)) { + continue; + } + context.__numberFormatters.delete(id); + } +} + +exports.CompileErrorCodes = messageCompiler.CompileErrorCodes; +exports.createCompileError = messageCompiler.createCompileError; +exports.AST_NODE_PROPS_KEYS = AST_NODE_PROPS_KEYS; +exports.CoreErrorCodes = CoreErrorCodes; +exports.CoreWarnCodes = CoreWarnCodes; +exports.DATETIME_FORMAT_OPTIONS_KEYS = DATETIME_FORMAT_OPTIONS_KEYS; +exports.DEFAULT_LOCALE = DEFAULT_LOCALE; +exports.DEFAULT_MESSAGE_DATA_TYPE = DEFAULT_MESSAGE_DATA_TYPE; +exports.MISSING_RESOLVE_VALUE = MISSING_RESOLVE_VALUE; +exports.NOT_REOSLVED = NOT_REOSLVED; +exports.NUMBER_FORMAT_OPTIONS_KEYS = NUMBER_FORMAT_OPTIONS_KEYS; +exports.VERSION = VERSION; +exports.clearCompileCache = clearCompileCache; +exports.clearDateTimeFormat = clearDateTimeFormat; +exports.clearNumberFormat = clearNumberFormat; +exports.compile = compile; +exports.compileToFunction = compileToFunction; +exports.createCoreContext = createCoreContext; +exports.createCoreError = createCoreError; +exports.createMessageContext = createMessageContext; +exports.datetime = datetime; +exports.fallbackWithLocaleChain = fallbackWithLocaleChain; +exports.fallbackWithSimple = fallbackWithSimple; +exports.getAdditionalMeta = getAdditionalMeta; +exports.getDevToolsHook = getDevToolsHook; +exports.getFallbackContext = getFallbackContext; +exports.getLocale = getLocale; +exports.getWarnMessage = getWarnMessage; +exports.handleMissing = handleMissing; +exports.initI18nDevTools = initI18nDevTools; +exports.isAlmostSameLocale = isAlmostSameLocale; +exports.isImplicitFallback = isImplicitFallback; +exports.isMessageAST = isMessageAST; +exports.isMessageFunction = isMessageFunction; +exports.isTranslateFallbackWarn = isTranslateFallbackWarn; +exports.isTranslateMissingWarn = isTranslateMissingWarn; +exports.number = number; +exports.parse = parse; +exports.parseDateTimeArgs = parseDateTimeArgs; +exports.parseNumberArgs = parseNumberArgs; +exports.parseTranslateArgs = parseTranslateArgs; +exports.registerLocaleFallbacker = registerLocaleFallbacker; +exports.registerMessageCompiler = registerMessageCompiler; +exports.registerMessageResolver = registerMessageResolver; +exports.resolveLocale = resolveLocale; +exports.resolveValue = resolveValue; +exports.resolveWithKeyValue = resolveWithKeyValue; +exports.setAdditionalMeta = setAdditionalMeta; +exports.setDevToolsHook = setDevToolsHook; +exports.setFallbackContext = setFallbackContext; +exports.translate = translate; +exports.translateDevTools = translateDevTools; +exports.updateFallbackLocale = updateFallbackLocale; diff --git a/node_modules/@intlify/core-base/dist/core-base.cjs.js b/node_modules/@intlify/core-base/dist/core-base.cjs.js new file mode 100644 index 0000000..1cbc2b5 --- /dev/null +++ b/node_modules/@intlify/core-base/dist/core-base.cjs.js @@ -0,0 +1 @@ +module.exports = require('../dist/core-base.cjs') \ No newline at end of file diff --git a/node_modules/@intlify/core-base/dist/core-base.cjs.prod.js b/node_modules/@intlify/core-base/dist/core-base.cjs.prod.js new file mode 100644 index 0000000..51d47d3 --- /dev/null +++ b/node_modules/@intlify/core-base/dist/core-base.cjs.prod.js @@ -0,0 +1 @@ +module.exports = require('../dist/core-base.prod.cjs') \ No newline at end of file diff --git a/node_modules/@intlify/core-base/dist/core-base.d.ts b/node_modules/@intlify/core-base/dist/core-base.d.ts new file mode 100644 index 0000000..03443f0 --- /dev/null +++ b/node_modules/@intlify/core-base/dist/core-base.d.ts @@ -0,0 +1,1274 @@ +import type { BaseError } from '@intlify/shared'; +import { CompileError } from '@intlify/message-compiler'; +import { CompileErrorCodes } from '@intlify/message-compiler'; +import type { CompileOptions } from '@intlify/message-compiler'; +import type { CoreMissingType as CoreMissingType_2 } from '@intlify/core-base'; +import { createCompileError } from '@intlify/message-compiler'; +import type { Emittable } from '@intlify/shared'; +import type { Locale as Locale_2 } from '@intlify/core-base'; +import type { MessageFunction as MessageFunction_2 } from '@intlify/core-base'; +import type { Path as Path_2 } from '@intlify/core-base'; +import type { PathValue as PathValue_2 } from '@intlify/core-base'; +import { ResourceNode } from '@intlify/message-compiler'; +import type { ResourceNode as ResourceNode_2 } from '@intlify/core-base'; + +declare type __ResourceFormatPath = Key extends string ? T[Key] extends Record ? `${Key}` : never : never; + +export declare type __ResourcePath = Key extends string ? T[Key] extends Record ? `${Key}.${__ResourcePath> & string}` | `${Key}.${Exclude & string}` : never : never; + +declare type AdditionalPayloads = { + meta?: Record; +}; + +export declare const AST_NODE_PROPS_KEYS: string[]; + +export declare function clearCompileCache(): void; + +/* Excluded from this release type: clearDateTimeFormat */ + +/* Excluded from this release type: clearNumberFormat */ + +export declare function compile(message: MessageSource, context: MessageCompilerContext): MessageFunction; +export { CompileError } +export { CompileErrorCodes } + +export declare const compileToFunction: (message: MessageSource, context: MessageCompilerContext) => MessageFunction; + +export declare interface CoreCommonContext { + cid: number; + version: string; + locale: Locales; + fallbackLocale: FallbackLocales>; + missing: CoreMissingHandler | null; + missingWarn: boolean | RegExp; + fallbackWarn: boolean | RegExp; + fallbackFormat: boolean; + unresolving: boolean; + localeFallbacker: LocaleFallbacker; + onWarn(msg: string, err?: Error): void; +} + +export declare type CoreContext> | PickupLocales> | PickupLocales>, Locales = IsNever extends true ? LocaleType extends LocaleDetector | Locale ? LocaleType : Locale : ResourceLocales> = CoreCommonContext & CoreTranslationContext, Message> & CoreDateTimeContext> & CoreNumberContext> & { + fallbackContext?: CoreContext; +}; + +export declare interface CoreDateTimeContext { + datetimeFormats: { + [K in keyof DateTimeFormats]: DateTimeFormats[K]; + }; +} + +export declare interface CoreError extends BaseError { +} + +export declare const CoreErrorCodes: { + readonly INVALID_ARGUMENT: 17; + readonly INVALID_DATE_ARGUMENT: number; + readonly INVALID_ISO_DATE_ARGUMENT: number; + readonly NOT_SUPPORT_NON_STRING_MESSAGE: number; + readonly NOT_SUPPORT_LOCALE_PROMISE_VALUE: number; + readonly NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: number; + readonly NOT_SUPPORT_LOCALE_TYPE: number; + readonly __EXTEND_POINT__: number; +}; + +export declare type CoreErrorCodes = (typeof CoreErrorCodes)[keyof typeof CoreErrorCodes]; + +export declare interface CoreInternalContext { + __datetimeFormatters: Map; + __numberFormatters: Map; + __localeChainCache?: Map; + __v_emitter?: VueDevToolsEmitter; + __meta: MetaInfo; +} + +export declare interface CoreInternalOptions { + __datetimeFormatters?: Map; + __numberFormatters?: Map; + __v_emitter?: VueDevToolsEmitter; + __meta?: MetaInfo; +} + +export declare type CoreMissingHandler = (context: CoreContext, locale: Locale, key: Path, type: CoreMissingType, ...values: unknown[]) => string | void; + +export declare type CoreMissingType = 'translate' | 'datetime format' | 'number format' | 'translate exists'; + +export declare interface CoreNumberContext { + numberFormats: { + [K in keyof NumberFormats]: NumberFormats[K]; + }; +} + +export declare interface CoreOptions = LocaleMessages, _DateTimeFormats extends DateTimeFormats = DateTimeFormats, _NumberFormats extends NumberFormats = NumberFormats> { + version?: string; + locale?: Locale | LocaleDetector; + fallbackLocale?: FallbackLocale; + messages?: { + [K in keyof _Messages]: MessageSchema; + }; + datetimeFormats?: { + [K in keyof _DateTimeFormats]: DateTimeSchema; + }; + numberFormats?: { + [K in keyof _NumberFormats]: NumberSchema; + }; + modifiers?: LinkedModifiers; + pluralRules?: PluralizationRules; + missing?: CoreMissingHandler; + missingWarn?: boolean | RegExp; + fallbackWarn?: boolean | RegExp; + fallbackFormat?: boolean; + unresolving?: boolean; + postTranslation?: PostTranslationHandler; + processor?: MessageProcessor; + warnHtmlMessage?: boolean; + escapeParameter?: boolean; + messageCompiler?: MessageCompiler; + messageResolver?: MessageResolver; + localeFallbacker?: LocaleFallbacker; + fallbackContext?: CoreContext; + onWarn?: (msg: string, err?: Error) => void; +} + +export declare interface CoreTranslationContext { + messages: { + [K in keyof Messages]: Messages[K]; + }; + modifiers: LinkedModifiers; + pluralRules?: PluralizationRules; + postTranslation: PostTranslationHandler | null; + processor: MessageProcessor | null; + warnHtmlMessage: boolean; + escapeParameter: boolean; + messageCompiler: MessageCompiler | null; + messageResolver: MessageResolver; +} + +export declare const CoreWarnCodes: { + readonly NOT_FOUND_KEY: 2; + readonly FALLBACK_TO_TRANSLATE: number; + readonly CANNOT_FORMAT_NUMBER: number; + readonly FALLBACK_TO_NUMBER_FORMAT: number; + readonly CANNOT_FORMAT_DATE: number; + readonly FALLBACK_TO_DATE_FORMAT: number; + readonly EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: number; + readonly __EXTEND_POINT__: number; +}; + +export declare type CoreWarnCodes = (typeof CoreWarnCodes)[keyof typeof CoreWarnCodes]; +export { createCompileError } + +export declare function createCoreContext = CoreOptions, Messages extends Record = Options['messages'] extends Record ? Options['messages'] : {}, DateTimeFormats extends Record = Options['datetimeFormats'] extends Record ? Options['datetimeFormats'] : {}, NumberFormats extends Record = Options['numberFormats'] extends Record ? Options['numberFormats'] : {}, LocaleType = Locale | LocaleDetector>(options: Options): CoreContext; + +export declare function createCoreContext, LocaleParams> = CoreOptions, LocaleParams>, Messages extends Record = NonNullable extends Record ? NonNullable : {}, DateTimeFormats extends Record = NonNullable extends Record ? NonNullable : {}, NumberFormats extends Record = NonNullable extends Record ? NonNullable : {}, LocaleType = Locale | LocaleDetector>(options: Options): CoreContext; + +export declare function createCoreError(code: CoreErrorCodes): CoreError; + +export declare function createMessageContext(options?: MessageContextOptions): MessageContext; + +/** + * number + */ +export declare type CurrencyDisplay = 'symbol' | 'code' | 'name'; + +export declare interface CurrencyNumberFormatOptions extends Intl.NumberFormatOptions { + style: 'currency'; + currency: string; + currencyDisplay?: CurrencyDisplay; + localeMatcher?: LocaleMatcher; + formatMatcher?: FormatMatcher; +} + +/** + * `datetime` function overloads + */ +export declare function datetime, Message = string>(context: Context, value: number | string | Date): string | number | Intl.DateTimeFormatPart[]; + +export declare function datetime, Value extends number | string | Date = number, Key extends string = string, ResourceKeys extends PickupFormatKeys = PickupFormatKeys, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | DateTimeOptions): string | number | Intl.DateTimeFormatPart[]; + +export declare function datetime, Value extends number | string | Date = number, Key extends string = string, ResourceKeys extends PickupFormatKeys = PickupFormatKeys, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | DateTimeOptions, locale: Context['locale']): string | number | Intl.DateTimeFormatPart[]; + +export declare function datetime, Value extends number | string | Date = number, Key extends string = string, ResourceKeys extends PickupFormatKeys = PickupFormatKeys, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | DateTimeOptions, override: Intl.DateTimeFormatOptions): string | number | Intl.DateTimeFormatPart[]; + +export declare function datetime, Value extends number | string | Date = number, Key extends string = string, ResourceKeys extends PickupFormatKeys = PickupFormatKeys, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | DateTimeOptions, locale: Context['locale'], override: Intl.DateTimeFormatOptions): string | number | Intl.DateTimeFormatPart[]; + +/* Excluded from this release type: DATETIME_FORMAT_OPTIONS_KEYS */ + +export declare type DateTimeDigital = 'numeric' | '2-digit'; + +export declare type DateTimeFormat = { + [key: string]: DateTimeFormatOptions; +}; + +export declare type DateTimeFormatOptions = Intl.DateTimeFormatOptions | SpecificDateTimeFormatOptions; + +export declare type DateTimeFormats = LocaleRecord, Schema>; + +/** + * datetime + */ +export declare type DateTimeHumanReadable = 'long' | 'short' | 'narrow'; + +/** + * # datetime + * + * ## usages: + * // for example `context.datetimeFormats` below + * 'en-US': { + * short: { + * year: 'numeric', month: '2-digit', day: '2-digit', + * hour: '2-digit', minute: '2-digit' + * } + * }, + * 'ja-JP': { ... } + * + * // datetimeable value only + * datetime(context, value) + * + * // key argument + * datetime(context, value, 'short') + * + * // key & locale argument + * datetime(context, value, 'short', 'ja-JP') + * + * // object sytle argument + * datetime(context, value, { key: 'short', locale: 'ja-JP' }) + * + * // suppress localize miss warning option, override context.missingWarn + * datetime(context, value, { key: 'short', locale: 'ja-JP', missingWarn: false }) + * + * // suppress localize fallback warning option, override context.fallbackWarn + * datetime(context, value, { key: 'short', locale: 'ja-JP', fallbackWarn: false }) + * + * // if you specify `part` options, you can get an array of objects containing the formatted datetime in parts + * datetime(context, value, { key: 'short', part: true }) + * + * // orverride context.datetimeFormats[locale] options with functino options + * datetime(cnotext, value, 'short', { year: '2-digit' }) + * datetime(cnotext, value, 'short', 'ja-JP', { year: '2-digit' }) + * datetime(context, value, { key: 'short', part: true, year: '2-digit' }) + */ +/** + * DateTime options + * + * @remarks + * Options for Datetime formatting API + * + * @VueI18nGeneral + */ +export declare interface DateTimeOptions extends Intl.DateTimeFormatOptions, LocaleOptions { + /** + * @remarks + * The target format key + */ + key?: Key; + /** + * @remarks + * Whether suppress warnings outputted when localization fails + */ + missingWarn?: boolean; + /** + * @remarks + * Whether do resolve on format keys when your language lacks a formatting for a key + */ + fallbackWarn?: boolean; + /** + * @remarks + * Whether to use [Intel.DateTimeFormat#formatToParts](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts) + */ + part?: boolean; +} + +export declare const DEFAULT_LOCALE = "en-US"; + +export declare const DEFAULT_MESSAGE_DATA_TYPE = "text"; + +export declare type DefaultCoreLocaleMessageSchema> = IsEmptyObject extends true ? LocaleMessage : Schema; + +/** + * The type definition of Locale Message for `@intlify/core-base` package + * + * @remarks + * The typealias is used to strictly define the type of the Locale message. + * + * @example + * ```ts + * // type.d.ts (`.d.ts` file at your app) + * import { DefineCoreLocaleMessage } from '@intlify/core-base' + * + * declare module '@intlify/core-base' { + * export interface DefineCoreLocaleMessage { + * title: string + * menu: { + * login: string + * } + * } + * } + * ``` + * + * @VueI18nGeneral + */ +export declare interface DefineCoreLocaleMessage extends LocaleMessage { +} + +declare type ExtractToStringFunction = T[ExtractToStringKey]; + +declare type ExtractToStringKey = Extract; + +/** @VueI18nGeneral */ +export declare type FallbackLocale = Locale | Locale[] | { + [locale in string]: Locale[]; +} | false; + +export declare type FallbackLocales = Locales | Array | { + [locale in string]: Array>>; +} | false; + +/** + * Fallback with locale chain + * + * @remarks + * A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @VueI18nGeneral + */ +export declare function fallbackWithLocaleChain(ctx: CoreContext, fallback: FallbackLocale, start: Locale): Locale[]; + +/** + * Fallback with simple implemenation + * + * @remarks + * A fallback locale function implemented with a simple fallback algorithm. + * + * Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nGeneral + */ +export declare function fallbackWithSimple(ctx: CoreContext, fallback: FallbackLocale, start: Locale): Locale[]; + +export declare type First = T[0]; + +export declare type FormatMatcher = 'basic' | 'best fit'; + +export declare type FormattedNumberPart = { + type: FormattedNumberPartType; + value: string; +}; + +export declare type FormattedNumberPartType = 'currency' | 'decimal' | 'fraction' | 'group' | 'infinity' | 'integer' | 'literal' | 'minusSign' | 'nan' | 'plusSign' | 'percentSign'; + +export declare const getAdditionalMeta: () => MetaInfo | null; + +export declare function getDevToolsHook(): IntlifyDevToolsEmitter | null; + +export declare const getFallbackContext: () => CoreContext | null; + +/* Excluded from this release type: getLocale */ + +export declare function getWarnMessage(code: CoreWarnCodes, ...args: unknown[]): string; + +/* Excluded from this release type: handleMissing */ + +export declare function initI18nDevTools(i18n: unknown, version: string, meta?: Record): void; + +declare type IntlifyDevToolsEmitter = Emittable; + +declare type IntlifyDevToolsEmitterHooks = { + [IntlifyDevToolsHooks.I18nInit]: IntlifyDevToolsHookPayloads[IntlifyDevToolsHooks.I18nInit]; + [IntlifyDevToolsHooks.FunctionTranslate]: IntlifyDevToolsHookPayloads[IntlifyDevToolsHooks.FunctionTranslate]; +}; + +declare type IntlifyDevToolsHookPayloads = { + [IntlifyDevToolsHooks.I18nInit]: { + timestamp: number; + i18n: unknown; + version: string; + } & AdditionalPayloads; + [IntlifyDevToolsHooks.FunctionTranslate]: { + timestamp: number; + message: string | number; + key: string; + locale: string; + format?: string; + } & AdditionalPayloads; +}; + +declare const enum IntlifyDevToolsHooks { + I18nInit = "i18n:init", + FunctionTranslate = "function:translate" +} + +/* Excluded from this release type: isAlmostSameLocale */ + +export declare type IsEmptyObject = IsNever extends true ? true : false; + +/* Excluded from this release type: isImplicitFallback */ + +export declare function isMessageAST(val: unknown): val is ResourceNode; + +export declare const isMessageFunction: (val: unknown) => val is MessageFunction; + +export declare type IsNever = [T] extends [never] ? true : false; + +/* Excluded from this release type: isTranslateFallbackWarn */ + +/* Excluded from this release type: isTranslateMissingWarn */ + +export declare type IsUnion = T extends B ? [B] extends [T] ? false : true : never; + +export declare type LastInUnion = UnionToIntersection 0 : never> extends (x: infer L) => 0 ? L : never; + +/** @VueI18nGeneral */ +export declare type LinkedModifiers = { + [key: string]: LinkedModify; +}; + +export declare type LinkedModify = (value: T, type: string) => MessageType; + +export declare interface LinkedOptions { + /** + * The message type of linked message + */ + type?: string; + /** + * The modifier of linked message + */ + modifier?: string; +} + +/** @VueI18nGeneral */ +export declare type Locale = string; + +/** @VueI18nGeneral */ +export declare interface LocaleDetector { + (...args: Args): Locale | Promise; + resolvedOnce?: boolean; +} + +/** + * The locale fallbacker + * + * @VueI18nGeneral + */ +export declare type LocaleFallbacker = (ctx: CoreContext, fallback: FallbackLocale, start: Locale) => Locale[]; + +export declare type LocaleMatcher = 'lookup' | 'best fit'; + +/** @VueI18nGeneral */ +export declare type LocaleMessage = Record>; + +/** @VueI18nGeneral */ +export declare type LocaleMessageDictionary = { + [K in keyof T]: LocaleMessageType; +}; + +/** @VueI18nGeneral */ +export declare type LocaleMessages = LocaleRecord, Schema>; + +/** @VueI18nGeneral */ +export declare type LocaleMessageType = T extends string ? string : T extends () => Promise ? LocaleMessageDictionary : T extends (...args: infer Arguments) => any ? (...args: Arguments) => ReturnType : T extends Record ? LocaleMessageDictionary : T extends Array ? { + [K in keyof T]: T[K]; +} : T; + +/** @VueI18nGeneral */ +export declare type LocaleMessageValue = LocaleMessageDictionary | string; + +/** @VueI18nGeneral */ +export declare interface LocaleOptions { + /** + * @remarks + * The locale of localization + */ + locale?: Locales | LocaleDetector; +} + +export declare type LocaleParams = T extends IsUnion ? { + messages: T; + datetimeFormats: T; + numberFormats: T; +} : T extends { + messages?: infer M; + datetimeFormats?: infer D; + numberFormats?: infer N; +} ? { + messages: LocaleParamsType; + datetimeFormats: LocaleParamsType; + numberFormats: LocaleParamsType; +} : T extends string ? { + messages: T; + datetimeFormats: T; + numberFormats: T; +} : { + messages: Default; + datetimeFormats: Default; + numberFormats: Default; +}; + +declare type LocaleParamsType = T extends IsUnion ? T : T extends string ? T : R; + +export declare type LocaleRecord = { + [K in T[number]]: R; +}; + +/** + * The message compiler + * + * @param message - A resolved message that ususally will be passed the string. if you can transform to it with bundler, will be passed the AST. + * @param context - A message context {@link MessageCompilerContext} + * + * @returns A {@link MessageFunction} + * + * @VueI18nGeneral + */ +export declare type MessageCompiler = (message: MessageSource, context: MessageCompilerContext) => MessageFunction; + +/** + * The context that will pass the message compiler. + * + * @VueI18nGeneral + */ +export declare type MessageCompilerContext = Pick & { + /** + * Whether to allow the use locale messages of HTML formatting. + */ + warnHtmlMessage?: boolean; + /** + * The resolved locale message key + */ + key: string; + /** + * The locale + */ + locale: Locale; +}; + +/** + * The message context. + * + * @VueI18nGeneral + */ +export declare interface MessageContext { + /** + * Resolve message value from list. + * + * @param index - An index of message values. + * + * @returns A resolved message value. + * + * @example + * ```js + * const messages = { + * en: { + * greeting: ({ list }) => `hello, ${list(0)}!` + * } + * } + * ``` + */ + list(index: number): unknown; + /** + * Resolve message value from named. + * + * @param key - A key of message value. + * + * @returns A resolved message value. + * + * @example + * ```js + * const messages = { + * en: { + * greeting: ({ named }) => `hello, ${named('name')}!` + * } + * } + * ``` + */ + named(key: string): unknown; + /** + * Resolve message with plural index. + * + * @remarks + * That's resolved with plural index with translation function. + * + * @param messages - the messages, that is resolved with plural index with translation function. + * + * @returns A resolved message. + * + * @example + * ```js + * const messages = { + * en: { + * car: ({ plural }) => plural(['car', 'cars']), + * apple: ({ plural, named }) => + * plural([ + * 'no apples', + * 'one apple', + * `${named('count')} apples` + * ]) + * } + * } + * ``` + */ + plural(messages: T[]): T; + /** + * Resolve linked message. + * + * @param key - A message key + * @param modifier - A modifier + * + * @returns A resolve message. + */ + linked(key: Path, modifier?: string): MessageType; + /** + * Overloaded `linked` + * + * @param key - A message key + * @param modifier - A modifier + * @param type - A message type + * + * @returns A resolve message. + */ + linked(key: Path, modifier?: string, type?: string): MessageType; + /** + * Overloaded `linked` + * + * @param key - A message key + * @param optoins - An {@link LinkedOptions | linked options} + * + * @returns A resolve message. + */ + linked(key: Path, optoins?: LinkedOptions): MessageType; + /* Excluded from this release type: message */ + /** + * The message type to be handled by the message function. + * + * @remarks + * Usually `text`, you need to return **string** in message function. + */ + type: string; + /* Excluded from this release type: interpolate */ + /* Excluded from this release type: normalize */ + /** + * The message values. + * + * @remarks + * The message values are the argument values passed from translation fucntion, such as `$t`, `t`, or `translate`. + * + * @example + * vue-i18n `$t` (or `t`) case: + * ```html + *

{{ $t('greeting', { name: 'DIO' }) }}

+ * ``` + * + * `@intlify/core` (`@intlify/core-base`) `translate` case: + * ```js + * translate(context, 'foo.bar', ['dio']) // `['dio']` is message values + * ``` + */ + values: Record; +} + +export declare interface MessageContextOptions { + parent?: MessageContext; + locale?: string; + list?: unknown[]; + named?: NamedValue; + modifiers?: LinkedModifiers; + pluralIndex?: number; + pluralRules?: PluralizationRules; + messages?: MessageFunctions | MessageResolveFunction; + processor?: MessageProcessor; +} + +/** + * The Message Function. + * + * @param ctx - A {@link MessageContext} + * + * @return A resolved format message, that is string type basically. + * + * @VueI18nGeneral + */ +export declare type MessageFunction = MessageFunctionCallable | MessageFunctionInternal; + +export declare type MessageFunctionCallable = (ctx: MessageContext) => MessageFunctionReturn; + +export declare type MessageFunctionInternal = { + (ctx: MessageContext): MessageFunctionReturn; + key?: string; + locale?: string; + source?: string; +}; + +/** @VueI18nGeneral */ +export declare type MessageFunctionReturn = T extends string ? MessageType : MessageType[]; + +export declare type MessageFunctions = Record>; + +export declare type MessageInterpolate = (val: unknown) => MessageType; + +export declare type MessageNormalize = (values: MessageType[]) => MessageFunctionReturn; + +export declare interface MessageProcessor { + type?: string; + interpolate?: MessageInterpolate; + normalize?: MessageNormalize; +} + +export declare type MessageResolveFunction = (key: string) => MessageFunction; + +/** @VueI18nGeneral */ +export declare type MessageResolver = (obj: unknown, path: Path) => PathValue; + +export declare type MessageType = T extends string ? string : StringConvertable; + +export declare interface MetaInfo { + [field: string]: unknown; +} + +export declare const MISSING_RESOLVE_VALUE = ""; + +/** @VueI18nGeneral */ +export declare type NamedValue = T & Record; + +export declare const NOT_REOSLVED = -1; + +/** + * `number` function overloads + */ +export declare function number, Message = string>(context: Context, value: number): string | number | Intl.NumberFormatPart[]; + +export declare function number, Value extends number = number, Key extends string = string, ResourceKeys extends PickupFormatKeys = PickupFormatKeys, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | NumberOptions): string | number | Intl.NumberFormatPart[]; + +export declare function number, Value extends number = number, Key extends string = string, ResourceKeys extends PickupFormatKeys = PickupFormatKeys, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | NumberOptions, locale: Context['locale']): string | number | Intl.NumberFormatPart[]; + +export declare function number, Value extends number = number, Key extends string = string, ResourceKeys extends PickupFormatKeys = PickupFormatKeys, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | NumberOptions, override: Intl.NumberFormatOptions): string | number | Intl.NumberFormatPart[]; + +export declare function number, Value extends number = number, Key extends string = string, ResourceKeys extends PickupFormatKeys = PickupFormatKeys, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | NumberOptions, locale: Context['locale'], override: Intl.NumberFormatOptions): string | number | Intl.NumberFormatPart[]; + +/* Excluded from this release type: NUMBER_FORMAT_OPTIONS_KEYS */ + +export declare type NumberFormat = { + [key: string]: NumberFormatOptions; +}; + +export declare type NumberFormatOptions = Intl.NumberFormatOptions | SpecificNumberFormatOptions | CurrencyNumberFormatOptions; + +export declare type NumberFormats = LocaleRecord, Schema>; + +export declare type NumberFormatToPartsResult = { + [index: number]: FormattedNumberPart; +}; + +/** + * # number + * + * ## usages + * // for example `context.numberFormats` below + * 'en-US': { + * 'currency': { + * style: 'currency', currency: 'USD', currencyDisplay: 'symbol' + * } + * }, + * 'ja-JP: { ... } + * + * // value only + * number(context, value) + * + * // key argument + * number(context, value, 'currency') + * + * // key & locale argument + * number(context, value, 'currency', 'ja-JP') + * + * // object sytle argument + * number(context, value, { key: 'currency', locale: 'ja-JP' }) + * + * // suppress localize miss warning option, override context.missingWarn + * number(context, value, { key: 'currency', locale: 'ja-JP', missingWarn: false }) + * + * // suppress localize fallback warning option, override context.fallbackWarn + * number(context, value, { key: 'currency', locale: 'ja-JP', fallbackWarn: false }) + * + * // if you specify `part` options, you can get an array of objects containing the formatted number in parts + * number(context, value, { key: 'currenty', part: true }) + * + * // orverride context.numberFormats[locale] options with functino options + * number(cnotext, value, 'currency', { year: '2-digit' }) + * number(cnotext, value, 'currency', 'ja-JP', { year: '2-digit' }) + * number(context, value, { key: 'currenty', locale: 'ja-JP', part: true, year: '2-digit'}) + */ +/** + * Number Options + * + * @remarks + * Options for Number formatting API + * + * @VueI18nGeneral + */ +export declare interface NumberOptions extends Intl.NumberFormatOptions, LocaleOptions { + /** + * @remarks + * The target format key + */ + key?: Key; + /** + * @remarks + * Whether suppress warnings outputted when localization fails + */ + missingWarn?: boolean; + /** + * @remarks + * Whether do resolve on format keys when your language lacks a formatting for a key + */ + fallbackWarn?: boolean; + /** + * @remarks + * Whether to use [Intel.NumberFormat#formatToParts](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts) + */ + part?: boolean; +} + +/** + * Parse a string path into an array of segments + */ +export declare function parse(path: Path): string[] | undefined; + +/* Excluded from this release type: parseDateTimeArgs */ + +/* Excluded from this release type: parseNumberArgs */ + +/* Excluded from this release type: parseTranslateArgs */ + +/** @VueI18nGeneral */ +export declare type Path = string; + +/** @VueI18nGeneral */ +export declare type PathValue = string | number | boolean | Function | null | { + [key: string]: PathValue; +} | PathValue[]; + +export declare type PickupFallbackLocales = T[number] | `${T[number]}!`; + +export declare type PickupFormatKeys, K = keyof T> = K extends string ? ResourceFormatPath : never; + +export declare type PickupFormatPathKeys = ResourceFormatPath; + +export declare type PickupKeys, K = keyof T> = K extends string ? ResourcePath : never; + +export declare type PickupLocales, K = keyof T> = K extends string ? K : never; + +export declare type PickupPaths = ResourcePath; + +export declare type PluralizationProps = { + n?: number; + count?: number; +}; + +export declare type PluralizationRule = (choice: number, choicesLength: number, orgRule?: PluralizationRule) => number; + +/** @VueI18nGeneral */ +export declare type PluralizationRules = { + [locale: string]: PluralizationRule; +}; + +/** @VueI18nGeneral */ +export declare type PostTranslationHandler = (translated: MessageFunctionReturn, key: string) => MessageFunctionReturn; + +/** + * Register the locale fallbacker + * + * @param fallbacker - A {@link LocaleFallbacker} function + * + * @VueI18nGeneral + */ +export declare function registerLocaleFallbacker(fallbacker: LocaleFallbacker): void; + +export declare function registerMessageCompiler(compiler: MessageCompiler): void; + +/** + * Register the message resolver + * + * @param resolver - A {@link MessageResolver} function + * + * @VueI18nGeneral + */ +export declare function registerMessageResolver(resolver: MessageResolver): void; + +export declare type RemovedIndexResources = RemoveIndexSignature<{ + [K in keyof T]: T[K]; +}>; + +export declare type RemoveIndexSignature = { + [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K]; +}; + +/* Excluded from this release type: resolveLocale */ + +/** + * message resolver + * + * @remarks + * Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default. + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ +export declare function resolveValue(obj: unknown, path: Path): PathValue; + +/** + * key-value message resolver + * + * @remarks + * Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ +export declare function resolveWithKeyValue(obj: unknown, path: Path): PathValue; + +export declare type ResourceFormatPath = _ResourceFormatPath extends string | keyof T ? _ResourceFormatPath : keyof T; + +declare type _ResourceFormatPath = __ResourceFormatPath | keyof T; +export { ResourceNode } + +export declare type ResourcePath = _ResourcePath extends string | keyof T ? _ResourcePath : keyof T; + +export declare type _ResourcePath = __ResourcePath | keyof T; + +export declare type ResourceValue> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? Rest extends ResourcePath ? ResourceValue : never : never : P extends keyof T ? T[P] : never; + +export declare type SchemaParams = T extends readonly any[] ? { + message: First; + datetime: DateTimeFormat; + number: NumberFormat; +} : T extends { + message?: infer M; + datetime?: infer D; + number?: infer N; +} ? { + message: M extends LocaleMessage ? M : LocaleMessage; + datetime: D extends DateTimeFormat ? D : DateTimeFormat; + number: N extends NumberFormat ? N : NumberFormat; +} : { + message: LocaleMessage; + datetime: DateTimeFormat; + number: NumberFormat; +}; + +export declare const setAdditionalMeta: (meta: MetaInfo | null) => void; + +export declare function setDevToolsHook(hook: IntlifyDevToolsEmitter | null): void; + +export declare const setFallbackContext: (context: CoreContext | null) => void; + +export declare interface SpecificDateTimeFormatOptions extends Intl.DateTimeFormatOptions { + year?: DateTimeDigital; + month?: DateTimeDigital | DateTimeHumanReadable; + day?: DateTimeDigital; + hour?: DateTimeDigital; + minute?: DateTimeDigital; + second?: DateTimeDigital; + weekday?: DateTimeHumanReadable; + era?: DateTimeHumanReadable; + timeZoneName?: 'long' | 'short'; + localeMatcher?: LocaleMatcher; + formatMatcher?: FormatMatcher; +} + +export declare interface SpecificNumberFormatOptions extends Intl.NumberFormatOptions { + style?: 'decimal' | 'percent'; + currency?: string; + currencyDisplay?: CurrencyDisplay; + localeMatcher?: LocaleMatcher; + formatMatcher?: FormatMatcher; +} + +declare type StringConvertable = ExtractToStringKey extends never ? unknown : ExtractToStringFunction extends (...args: any) => string ? T : unknown; + +/** + * TODO: + * this type should be used (refactored) at `translate` type definition + * (Unfortunately, using this type will result in key completion failure due to type mismatch...) + */ +/** + * `translate` function overloads + */ +export declare function translate, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, CoreMessages = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, ContextMessages = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever extends false ? IsNever extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction, plural: number): MessageFunctionReturn | number; + +export declare function translate, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, CoreMessages = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, ContextMessages = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever extends false ? IsNever extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction): MessageFunctionReturn | number; + +export declare function translate, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, CoreMessages = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, ContextMessages = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever extends false ? IsNever extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction, plural: number): MessageFunctionReturn | number; + +export declare function translate, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, CoreMessages = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, ContextMessages = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever extends false ? IsNever extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction, plural: number, options: TranslateOptions): MessageFunctionReturn | number; + +export declare function translate, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, CoreMessages = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, ContextMessages = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever extends false ? IsNever extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction, defaultMsg: string): MessageFunctionReturn | number; + +export declare function translate, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, CoreMessages = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, ContextMessages = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever extends false ? IsNever extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction, defaultMsg: string, options: TranslateOptions): MessageFunctionReturn | number; + +export declare function translate, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, CoreMessages = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, ContextMessages = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever extends false ? IsNever extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction, list: unknown[]): MessageFunctionReturn | number; + +export declare function translate, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, CoreMessages = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, ContextMessages = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever extends false ? IsNever extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction, list: unknown[], plural: number): MessageFunctionReturn | number; + +export declare function translate, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, CoreMessages = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, ContextMessages = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever extends false ? IsNever extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction, list: unknown[], defaultMsg: string): MessageFunctionReturn | number; + +export declare function translate, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, CoreMessages = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, ContextMessages = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever extends false ? IsNever extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction, list: unknown[], options: TranslateOptions): MessageFunctionReturn | number; + +export declare function translate, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, CoreMessages = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, ContextMessages = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever extends false ? IsNever extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction, named: NamedValue): MessageFunctionReturn | number; + +export declare function translate, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, CoreMessages = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, ContextMessages = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever extends false ? IsNever extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction, named: NamedValue, plural: number): MessageFunctionReturn | number; + +export declare function translate, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, CoreMessages = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, ContextMessages = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever extends false ? IsNever extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction, named: NamedValue, defaultMsg: string): MessageFunctionReturn | number; + +export declare function translate, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, CoreMessages = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, ContextMessages = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever extends false ? IsNever extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction, named: NamedValue, options: TranslateOptions): MessageFunctionReturn | number; + +export declare const translateDevTools: (payloads: IntlifyDevToolsHookPayloads[IntlifyDevToolsHooks]) => void | null; + +/** + * # translate + * + * ## usages: + * // for example, locale messages key + * { 'foo.bar': 'hi {0} !' or 'hi {name} !' } + * + * // no argument, context & path only + * translate(context, 'foo.bar') + * + * // list argument + * translate(context, 'foo.bar', ['kazupon']) + * + * // named argument + * translate(context, 'foo.bar', { name: 'kazupon' }) + * + * // plural choice number + * translate(context, 'foo.bar', 2) + * + * // plural choice number with name argument + * translate(context, 'foo.bar', { name: 'kazupon' }, 2) + * + * // default message argument + * translate(context, 'foo.bar', 'this is default message') + * + * // default message with named argument + * translate(context, 'foo.bar', { name: 'kazupon' }, 'Hello {name} !') + * + * // use key as default message + * translate(context, 'hi {0} !', ['kazupon'], { default: true }) + * + * // locale option, override context.locale + * translate(context, 'foo.bar', { name: 'kazupon' }, { locale: 'ja' }) + * + * // suppress localize miss warning option, override context.missingWarn + * translate(context, 'foo.bar', { name: 'kazupon' }, { missingWarn: false }) + * + * // suppress localize fallback warning option, override context.fallbackWarn + * translate(context, 'foo.bar', { name: 'kazupon' }, { fallbackWarn: false }) + * + * // escape parameter option, override context.escapeParameter + * translate(context, 'foo.bar', { name: 'kazupon' }, { escapeParameter: true }) + */ +/** + * Translate Options + * + * @remarks + * Options for Translation API + * + * @VueI18nGeneral + */ +export declare interface TranslateOptions extends LocaleOptions { + /** + * @remarks + * List interpolation + */ + list?: unknown[]; + /** + * @remarks + * Named interpolation + */ + named?: NamedValue; + /** + * @remarks + * Plulralzation choice number + */ + plural?: number; + /** + * @remarks + * Default message when is occurred translation missing + */ + default?: string | boolean; + /** + * @remarks + * Whether suppress warnings outputted when localization fails + */ + missingWarn?: boolean; + /** + * @remarks + * Whether do template interpolation on translation keys when your language lacks a translation for a key + */ + fallbackWarn?: boolean; + /** + * @remarks + * Whether to escape parameters for list or named interpolation values. + * When enabled, this option: + * - Escapes HTML special characters (`<`, `>`, `"`, `'`, `&`, `/`, `=`) in interpolation parameters + * - Sanitizes the final translated HTML to prevent XSS attacks by: + * - Escaping dangerous characters in HTML attribute values + * - Neutralizing event handler attributes (onclick, onerror, etc.) + * - Disabling javascript: URLs in href, src, action, formaction, and style attributes + * + * @defaultValue false + * @see [HTML Message - Using the escapeParameter option](https://vue-i18n.intlify.dev/guide/essentials/syntax.html#using-the-escapeparameter-option) + */ + escapeParameter?: boolean; + /** + * @remarks + * Whether the message has been resolved + */ + resolvedMessage?: boolean; +} + +export declare type UnionToIntersection = (U extends any ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never; + +export declare type UnionToTuple> = [U] extends [never] ? [] : [...UnionToTuple>, Last]; + +/* Excluded from this release type: updateFallbackLocale */ + +/* Excluded from this release type: VERSION */ + +declare type VueDevToolsEmitter = Emittable; + +declare type VueDevToolsEmitterEvents = { + [VueDevToolsTimelineEvents.COMPILE_ERROR]: VueDevToolsTimelineEventPayloads[VueDevToolsTimelineEvents.COMPILE_ERROR]; + [VueDevToolsTimelineEvents.MISSING]: VueDevToolsTimelineEventPayloads[VueDevToolsTimelineEvents.MISSING]; + [VueDevToolsTimelineEvents.FALBACK]: VueDevToolsTimelineEventPayloads[VueDevToolsTimelineEvents.FALBACK]; + [VueDevToolsTimelineEvents.MESSAGE_RESOLVE]: VueDevToolsTimelineEventPayloads[VueDevToolsTimelineEvents.MESSAGE_RESOLVE]; + [VueDevToolsTimelineEvents.MESSAGE_COMPILATION]: VueDevToolsTimelineEventPayloads[VueDevToolsTimelineEvents.MESSAGE_COMPILATION]; + [VueDevToolsTimelineEvents.MESSAGE_EVALUATION]: VueDevToolsTimelineEventPayloads[VueDevToolsTimelineEvents.MESSAGE_EVALUATION]; +}; + +declare type VueDevToolsTimelineEventPayloads = { + [VueDevToolsTimelineEvents.COMPILE_ERROR]: { + message: string; + error: string; + start?: number; + end?: number; + groupId?: string; + }; + [VueDevToolsTimelineEvents.MISSING]: { + locale: Locale_2; + key: Path_2; + type: CoreMissingType_2; + groupId?: string; + }; + [VueDevToolsTimelineEvents.FALBACK]: { + key: Path_2; + type: CoreMissingType_2; + from?: Locale_2; + to: Locale_2 | 'global'; + groupId?: string; + }; + [VueDevToolsTimelineEvents.MESSAGE_RESOLVE]: { + type: VueDevToolsTimelineEvents.MESSAGE_RESOLVE; + key: Path_2; + message: PathValue_2; + time: number; + groupId?: string; + }; + [VueDevToolsTimelineEvents.MESSAGE_COMPILATION]: { + type: VueDevToolsTimelineEvents.MESSAGE_COMPILATION; + message: string | ResourceNode_2 | MessageFunction_2; + time: number; + groupId?: string; + }; + [VueDevToolsTimelineEvents.MESSAGE_EVALUATION]: { + type: VueDevToolsTimelineEvents.MESSAGE_EVALUATION; + value: unknown; + time: number; + groupId?: string; + }; +}; + +declare const enum VueDevToolsTimelineEvents { + COMPILE_ERROR = "compile-error", + MISSING = "missing", + FALBACK = "fallback", + MESSAGE_RESOLVE = "message-resolve", + MESSAGE_COMPILATION = "message-compilation", + MESSAGE_EVALUATION = "message-evaluation" +} + +export { } diff --git a/node_modules/@intlify/core-base/dist/core-base.esm-browser.js b/node_modules/@intlify/core-base/dist/core-base.esm-browser.js new file mode 100644 index 0000000..90db9c7 --- /dev/null +++ b/node_modules/@intlify/core-base/dist/core-base.esm-browser.js @@ -0,0 +1,3681 @@ +/*! + * core-base v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +function warn(msg, err) { + if (typeof console !== 'undefined') { + console.warn(`[intlify] ` + msg); + /* istanbul ignore if */ + if (err) { + console.warn(err.stack); + } + } +} +const hasWarned = {}; +function warnOnce(msg) { + if (!hasWarned[msg]) { + hasWarned[msg] = true; + warn(msg); + } +} + +/** + * Original Utilities + * written by kazuya kawaguchi + */ +const inBrowser = typeof window !== 'undefined'; +let mark; +let measure; +{ + const perf = inBrowser && window.performance; + if (perf && + perf.mark && + perf.measure && + perf.clearMarks && + // @ts-ignore browser compat + perf.clearMeasures) { + mark = (tag) => { + perf.mark(tag); + }; + measure = (name, startTag, endTag) => { + perf.measure(name, startTag, endTag); + perf.clearMarks(startTag); + perf.clearMarks(endTag); + }; + } +} +const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g; +/* eslint-disable */ +function format$1(message, ...args) { + if (args.length === 1 && isObject(args[0])) { + args = args[0]; + } + if (!args || !args.hasOwnProperty) { + args = {}; + } + return message.replace(RE_ARGS, (match, identifier) => { + return args.hasOwnProperty(identifier) ? args[identifier] : ''; + }); +} +const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({ l: locale, k: key, s: source }); +const friendlyJSONstringify = (json) => JSON.stringify(json) + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029') + .replace(/\u0027/g, '\\u0027'); +const isNumber = (val) => typeof val === 'number' && isFinite(val); +const isDate = (val) => toTypeString(val) === '[object Date]'; +const isRegExp = (val) => toTypeString(val) === '[object RegExp]'; +const isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0; +const assign = Object.assign; +const _create = Object.create; +const create = (obj = null) => _create(obj); +function escapeHtml(rawText) { + return rawText + .replace(/&/g, '&') // escape `&` first to avoid double escaping + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/\//g, '/') // escape `/` to prevent closing tags or JavaScript URLs + .replace(/=/g, '='); // escape `=` to prevent attribute injection +} +function escapeAttributeValue(value) { + return value + .replace(/&(?![a-zA-Z0-9#]{2,6};)/g, '&') // escape unescaped `&` + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(//g, '>'); +} +function sanitizeTranslatedHtml(html) { + // Escape dangerous characters in attribute values + // Process attributes with double quotes + html = html.replace(/(\w+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${escapeAttributeValue(attrValue)}"`); + // Process attributes with single quotes + html = html.replace(/(\w+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${escapeAttributeValue(attrValue)}'`); + // Detect and neutralize event handler attributes + const eventHandlerPattern = /\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi; + if (eventHandlerPattern.test(html)) { + { + warn('Potentially dangerous event handlers detected in translation. ' + + 'Consider removing onclick, onerror, etc. from your translation messages.'); + } + // Neutralize event handler attributes by escaping 'on' + html = html.replace(/(\s+)(on)(\w+\s*=)/gi, '$1on$3'); + } + // Disable javascript: URLs in various contexts + const javascriptUrlPattern = [ + // In href, src, action, formaction attributes + /(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi, + // In style attributes within url() + /(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi + ]; + javascriptUrlPattern.forEach(pattern => { + html = html.replace(pattern, '$1javascript:'); + }); + return html; +} +const hasOwnProperty = Object.prototype.hasOwnProperty; +function hasOwn(obj, key) { + return hasOwnProperty.call(obj, key); +} +/* eslint-enable */ +/** + * Useful Utilities By Evan you + * Modified by kazuya kawaguchi + * MIT License + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts + */ +const isArray = Array.isArray; +const isFunction = (val) => typeof val === 'function'; +const isString = (val) => typeof val === 'string'; +const isBoolean = (val) => typeof val === 'boolean'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isObject = (val) => val !== null && typeof val === 'object'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isPromise = (val) => { + return isObject(val) && isFunction(val.then) && isFunction(val.catch); +}; +const objectToString = Object.prototype.toString; +const toTypeString = (value) => objectToString.call(value); +const isPlainObject = (val) => { + if (!isObject(val)) + return false; + const proto = Object.getPrototypeOf(val); + return proto === null || proto.constructor === Object; +}; +// for converting list and named values to displayed strings. +const toDisplayString = (val) => { + return val == null + ? '' + : isArray(val) || (isPlainObject(val) && val.toString === objectToString) + ? JSON.stringify(val, null, 2) + : String(val); +}; +function join(items, separator = '') { + return items.reduce((str, item, index) => (index === 0 ? str + item : str + separator + item), ''); +} +const RANGE = 2; +function generateCodeFrame(source, start = 0, end = source.length) { + const lines = source.split(/\r?\n/); + let count = 0; + const res = []; + for (let i = 0; i < lines.length; i++) { + count += lines[i].length + 1; + if (count >= start) { + for (let j = i - RANGE; j <= i + RANGE || end > count; j++) { + if (j < 0 || j >= lines.length) + continue; + const line = j + 1; + res.push(`${line}${' '.repeat(3 - String(line).length)}| ${lines[j]}`); + const lineLength = lines[j].length; + if (j === i) { + // push underline + const pad = start - (count - lineLength) + 1; + const length = Math.max(1, end > count ? lineLength - pad : end - start); + res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length)); + } + else if (j > i) { + if (end > count) { + const length = Math.max(Math.min(end - count, lineLength), 1); + res.push(` | ` + '^'.repeat(length)); + } + count += lineLength + 1; + } + } + break; + } + } + return res.join('\n'); +} +function incrementer(code) { + let current = code; + return () => ++current; +} + +function createPosition(line, column, offset) { + return { line, column, offset }; +} +function createLocation(start, end, source) { + const loc = { start, end }; + if (source != null) { + loc.source = source; + } + return loc; +} + +const CompileWarnCodes = { + USE_MODULO_SYNTAX: 1, + __EXTEND_POINT__: 2 +}; +/** @internal */ +const warnMessages$1 = { + [CompileWarnCodes.USE_MODULO_SYNTAX]: `Use modulo before '{{0}}'.` +}; +function createCompileWarn(code, loc, ...args) { + const msg = format$1(warnMessages$1[code] || '', ...(args || [])) ; + const message = { message: String(msg), code }; + if (loc) { + message.location = loc; + } + return message; +} + +const CompileErrorCodes = { + // tokenizer error codes + EXPECTED_TOKEN: 1, + INVALID_TOKEN_IN_PLACEHOLDER: 2, + UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3, + UNKNOWN_ESCAPE_SEQUENCE: 4, + INVALID_UNICODE_ESCAPE_SEQUENCE: 5, + UNBALANCED_CLOSING_BRACE: 6, + UNTERMINATED_CLOSING_BRACE: 7, + EMPTY_PLACEHOLDER: 8, + NOT_ALLOW_NEST_PLACEHOLDER: 9, + INVALID_LINKED_FORMAT: 10, + // parser error codes + MUST_HAVE_MESSAGES_IN_PLURAL: 11, + UNEXPECTED_EMPTY_LINKED_MODIFIER: 12, + UNEXPECTED_EMPTY_LINKED_KEY: 13, + UNEXPECTED_LEXICAL_ANALYSIS: 14, + // generator error codes + UNHANDLED_CODEGEN_NODE_TYPE: 15, + // minifier error codes + UNHANDLED_MINIFIER_NODE_TYPE: 16, + // Special value for higher-order compilers to pick up the last code + // to avoid collision of error codes. This should always be kept as the last + // item. + __EXTEND_POINT__: 17 +}; +/** @internal */ +const errorMessages$1 = { + // tokenizer error messages + [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`, + [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`, + [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`, + [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`, + [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`, + [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`, + [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`, + [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`, + [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`, + [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`, + // parser error messages + [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`, + [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`, + // generator error messages + [CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`, + // minimizer error messages + [CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'` +}; +function createCompileError(code, loc, options = {}) { + const { domain, messages, args } = options; + const msg = format$1((messages || errorMessages$1)[code] || '', ...(args || [])) + ; + const error = new SyntaxError(String(msg)); + error.code = code; + if (loc) { + error.location = loc; + } + error.domain = domain; + return error; +} +/** @internal */ +function defaultOnError(error) { + throw error; +} + +// eslint-disable-next-line no-useless-escape +const RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/; +const detectHtmlTag = (source) => RE_HTML_TAG.test(source); + +const CHAR_SP = ' '; +const CHAR_CR = '\r'; +const CHAR_LF = '\n'; +const CHAR_LS = String.fromCharCode(0x2028); +const CHAR_PS = String.fromCharCode(0x2029); +function createScanner(str) { + const _buf = str; + let _index = 0; + let _line = 1; + let _column = 1; + let _peekOffset = 0; + const isCRLF = (index) => _buf[index] === CHAR_CR && _buf[index + 1] === CHAR_LF; + const isLF = (index) => _buf[index] === CHAR_LF; + const isPS = (index) => _buf[index] === CHAR_PS; + const isLS = (index) => _buf[index] === CHAR_LS; + const isLineEnd = (index) => isCRLF(index) || isLF(index) || isPS(index) || isLS(index); + const index = () => _index; + const line = () => _line; + const column = () => _column; + const peekOffset = () => _peekOffset; + const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset]; + const currentChar = () => charAt(_index); + const currentPeek = () => charAt(_index + _peekOffset); + function next() { + _peekOffset = 0; + if (isLineEnd(_index)) { + _line++; + _column = 0; + } + if (isCRLF(_index)) { + _index++; + } + _index++; + _column++; + return _buf[_index]; + } + function peek() { + if (isCRLF(_index + _peekOffset)) { + _peekOffset++; + } + _peekOffset++; + return _buf[_index + _peekOffset]; + } + function reset() { + _index = 0; + _line = 1; + _column = 1; + _peekOffset = 0; + } + function resetPeek(offset = 0) { + _peekOffset = offset; + } + function skipToPeek() { + const target = _index + _peekOffset; + // eslint-disable-next-line no-unmodified-loop-condition + while (target !== _index) { + next(); + } + _peekOffset = 0; + } + return { + index, + line, + column, + peekOffset, + charAt, + currentChar, + currentPeek, + next, + peek, + reset, + resetPeek, + skipToPeek + }; +} + +const EOF = undefined; +const DOT = '.'; +const LITERAL_DELIMITER = "'"; +const ERROR_DOMAIN$3 = 'tokenizer'; +function createTokenizer(source, options = {}) { + const location = options.location !== false; + const _scnr = createScanner(source); + const currentOffset = () => _scnr.index(); + const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index()); + const _initLoc = currentPosition(); + const _initOffset = currentOffset(); + const _context = { + currentType: 14 /* TokenTypes.EOF */, + offset: _initOffset, + startLoc: _initLoc, + endLoc: _initLoc, + lastType: 14 /* TokenTypes.EOF */, + lastOffset: _initOffset, + lastStartLoc: _initLoc, + lastEndLoc: _initLoc, + braceNest: 0, + inLinked: false, + text: '' + }; + const context = () => _context; + const { onError } = options; + function emitError(code, pos, offset, ...args) { + const ctx = context(); + pos.column += offset; + pos.offset += offset; + if (onError) { + const loc = location ? createLocation(ctx.startLoc, pos) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$3, + args + }); + onError(err); + } + } + function getToken(context, type, value) { + context.endLoc = currentPosition(); + context.currentType = type; + const token = { type }; + if (location) { + token.loc = createLocation(context.startLoc, context.endLoc); + } + if (value != null) { + token.value = value; + } + return token; + } + const getEndToken = (context) => getToken(context, 14 /* TokenTypes.EOF */); + function eat(scnr, ch) { + if (scnr.currentChar() === ch) { + scnr.next(); + return ch; + } + else { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + return ''; + } + } + function peekSpaces(scnr) { + let buf = ''; + while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) { + buf += scnr.currentPeek(); + scnr.peek(); + } + return buf; + } + function skipSpaces(scnr) { + const buf = peekSpaces(scnr); + scnr.skipToPeek(); + return buf; + } + function isIdentifierStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + cc === 95 // _ + ); + } + function isNumberStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function isNamedIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isListIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ch = scnr.currentPeek() === '-' ? scnr.peek() : scnr.currentPeek(); + const ret = isNumberStart(ch); + scnr.resetPeek(); + return ret; + } + function isLiteralStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === LITERAL_DELIMITER; + scnr.resetPeek(); + return ret; + } + function isLinkedDotStart(scnr, context) { + const { currentType } = context; + if (currentType !== 8 /* TokenTypes.LinkedAlias */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === "." /* TokenChars.LinkedDot */; + scnr.resetPeek(); + return ret; + } + function isLinkedModifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 9 /* TokenTypes.LinkedDot */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isLinkedDelimiterStart(scnr, context) { + const { currentType } = context; + if (!(currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 12 /* TokenTypes.LinkedModifier */)) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === ":" /* TokenChars.LinkedDelimiter */; + scnr.resetPeek(); + return ret; + } + function isLinkedReferStart(scnr, context) { + const { currentType } = context; + if (currentType !== 10 /* TokenTypes.LinkedDelimiter */) { + return false; + } + const fn = () => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return isIdentifierStart(scnr.peek()); + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "|" /* TokenChars.Pipe */ || + ch === ":" /* TokenChars.LinkedDelimiter */ || + ch === "." /* TokenChars.LinkedDot */ || + ch === CHAR_SP || + !ch) { + return false; + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(); + } + else { + // other characters + return isTextStart(scnr, false); + } + }; + const ret = fn(); + scnr.resetPeek(); + return ret; + } + function isPluralStart(scnr) { + peekSpaces(scnr); + const ret = scnr.currentPeek() === "|" /* TokenChars.Pipe */; + scnr.resetPeek(); + return ret; + } + function detectModuloStart(scnr) { + const spaces = peekSpaces(scnr); + const ret = scnr.currentPeek() === "%" /* TokenChars.Modulo */ && + scnr.peek() === "{" /* TokenChars.BraceLeft */; + scnr.resetPeek(); + return { + isModulo: ret, + hasSpace: spaces.length > 0 + }; + } + function isTextStart(scnr, reset = true) { + const fn = (hasSpace = false, prev = '', detectModulo = false) => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return prev === "%" /* TokenChars.Modulo */ ? false : hasSpace; + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || !ch) { + return prev === "%" /* TokenChars.Modulo */ ? true : hasSpace; + } + else if (ch === "%" /* TokenChars.Modulo */) { + scnr.peek(); + return fn(hasSpace, "%" /* TokenChars.Modulo */, true); + } + else if (ch === "|" /* TokenChars.Pipe */) { + return prev === "%" /* TokenChars.Modulo */ || detectModulo + ? true + : !(prev === CHAR_SP || prev === CHAR_LF); + } + else if (ch === CHAR_SP) { + scnr.peek(); + return fn(true, CHAR_SP, detectModulo); + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(true, CHAR_LF, detectModulo); + } + else { + return true; + } + }; + const ret = fn(); + reset && scnr.resetPeek(); + return ret; + } + function takeChar(scnr, fn) { + const ch = scnr.currentChar(); + if (ch === EOF) { + return EOF; + } + if (fn(ch)) { + scnr.next(); + return ch; + } + return null; + } + function isIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 // $ + ); + } + function takeIdentifierChar(scnr) { + return takeChar(scnr, isIdentifier); + } + function isNamedIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 || // $ + cc === 45 // - + ); + } + function takeNamedIdentifierChar(scnr) { + return takeChar(scnr, isNamedIdentifier); + } + function isDigit(ch) { + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function takeDigit(scnr) { + return takeChar(scnr, isDigit); + } + function isHexDigit(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 48 && cc <= 57) || // 0-9 + (cc >= 65 && cc <= 70) || // A-F + (cc >= 97 && cc <= 102)); // a-f + } + function takeHexDigit(scnr) { + return takeChar(scnr, isHexDigit); + } + function getDigits(scnr) { + let ch = ''; + let num = ''; + while ((ch = takeDigit(scnr))) { + num += ch; + } + return num; + } + function readModulo(scnr) { + skipSpaces(scnr); + const ch = scnr.currentChar(); + if (ch !== "%" /* TokenChars.Modulo */) { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + } + scnr.next(); + return "%" /* TokenChars.Modulo */; + } + function readText(scnr) { + let buf = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "}" /* TokenChars.BraceRight */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + !ch) { + break; + } + else if (ch === "%" /* TokenChars.Modulo */) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else { + break; + } + } + else if (ch === CHAR_SP || ch === CHAR_LF) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else if (isPluralStart(scnr)) { + break; + } + else { + buf += ch; + scnr.next(); + } + } + else { + buf += ch; + scnr.next(); + } + } + return buf; + } + function readNamedIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let name = ''; + while ((ch = takeNamedIdentifierChar(scnr))) { + name += ch; + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return name; + } + function readListIdentifier(scnr) { + skipSpaces(scnr); + let value = ''; + if (scnr.currentChar() === '-') { + scnr.next(); + value += `-${getDigits(scnr)}`; + } + else { + value += getDigits(scnr); + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return value; + } + function isLiteral(ch) { + return ch !== LITERAL_DELIMITER && ch !== CHAR_LF; + } + function readLiteral(scnr) { + skipSpaces(scnr); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + let ch = ''; + let literal = ''; + while ((ch = takeChar(scnr, isLiteral))) { + if (ch === '\\') { + literal += readEscapeSequence(scnr); + } + else { + literal += ch; + } + } + const current = scnr.currentChar(); + if (current === CHAR_LF || current === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, currentPosition(), 0); + // TODO: Is it correct really? + if (current === CHAR_LF) { + scnr.next(); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + } + return literal; + } + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + return literal; + } + function readEscapeSequence(scnr) { + const ch = scnr.currentChar(); + switch (ch) { + case '\\': + case `\'`: // eslint-disable-line no-useless-escape + scnr.next(); + return `\\${ch}`; + case 'u': + return readUnicodeEscapeSequence(scnr, ch, 4); + case 'U': + return readUnicodeEscapeSequence(scnr, ch, 6); + default: + emitError(CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, currentPosition(), 0, ch); + return ''; + } + } + function readUnicodeEscapeSequence(scnr, unicode, digits) { + eat(scnr, unicode); + let sequence = ''; + for (let i = 0; i < digits; i++) { + const ch = takeHexDigit(scnr); + if (!ch) { + emitError(CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`); + break; + } + sequence += ch; + } + return `\\${unicode}${sequence}`; + } + function isInvalidIdentifier(ch) { + return (ch !== "{" /* TokenChars.BraceLeft */ && + ch !== "}" /* TokenChars.BraceRight */ && + ch !== CHAR_SP && + ch !== CHAR_LF); + } + function readInvalidIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let identifiers = ''; + while ((ch = takeChar(scnr, isInvalidIdentifier))) { + identifiers += ch; + } + return identifiers; + } + function readLinkedModifier(scnr) { + let ch = ''; + let name = ''; + while ((ch = takeIdentifierChar(scnr))) { + name += ch; + } + return name; + } + function readLinkedRefer(scnr) { + const fn = (buf) => { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + ch === "(" /* TokenChars.ParenLeft */ || + ch === ")" /* TokenChars.ParenRight */ || + !ch) { + return buf; + } + else if (ch === CHAR_SP) { + return buf; + } + else if (ch === CHAR_LF || ch === DOT) { + buf += ch; + scnr.next(); + return fn(buf); + } + else { + buf += ch; + scnr.next(); + return fn(buf); + } + }; + return fn(''); + } + function readPlural(scnr) { + skipSpaces(scnr); + const plural = eat(scnr, "|" /* TokenChars.Pipe */); + skipSpaces(scnr); + return plural; + } + // TODO: We need refactoring of token parsing ... + function readTokenInPlaceholder(scnr, context) { + let token = null; + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + if (context.braceNest >= 1) { + emitError(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 2 /* TokenTypes.BraceLeft */, "{" /* TokenChars.BraceLeft */); + skipSpaces(scnr); + context.braceNest++; + return token; + case "}" /* TokenChars.BraceRight */: + if (context.braceNest > 0 && + context.currentType === 2 /* TokenTypes.BraceLeft */) { + emitError(CompileErrorCodes.EMPTY_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + context.braceNest--; + context.braceNest > 0 && skipSpaces(scnr); + if (context.inLinked && context.braceNest === 0) { + context.inLinked = false; + } + return token; + case "@" /* TokenChars.LinkedAlias */: + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = readTokenInLinked(scnr, context) || getEndToken(context); + context.braceNest = 0; + return token; + default: { + let validNamedIdentifier = true; + let validListIdentifier = true; + let validLiteral = true; + if (isPluralStart(scnr)) { + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (context.braceNest > 0 && + (context.currentType === 5 /* TokenTypes.Named */ || + context.currentType === 6 /* TokenTypes.List */ || + context.currentType === 7 /* TokenTypes.Literal */)) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + context.braceNest = 0; + return readToken(scnr, context); + } + if ((validNamedIdentifier = isNamedIdentifierStart(scnr, context))) { + token = getToken(context, 5 /* TokenTypes.Named */, readNamedIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validListIdentifier = isListIdentifierStart(scnr, context))) { + token = getToken(context, 6 /* TokenTypes.List */, readListIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validLiteral = isLiteralStart(scnr, context))) { + token = getToken(context, 7 /* TokenTypes.Literal */, readLiteral(scnr)); + skipSpaces(scnr); + return token; + } + if (!validNamedIdentifier && !validListIdentifier && !validLiteral) { + // TODO: we should be re-designed invalid cases, when we will extend message syntax near the future ... + token = getToken(context, 13 /* TokenTypes.InvalidPlace */, readInvalidIdentifier(scnr)); + emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value); + skipSpaces(scnr); + return token; + } + break; + } + } + return token; + } + // TODO: We need refactoring of token parsing ... + function readTokenInLinked(scnr, context) { + const { currentType } = context; + let token = null; + const ch = scnr.currentChar(); + if ((currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 9 /* TokenTypes.LinkedDot */ || + currentType === 12 /* TokenTypes.LinkedModifier */ || + currentType === 10 /* TokenTypes.LinkedDelimiter */) && + (ch === CHAR_LF || ch === CHAR_SP)) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + switch (ch) { + case "@" /* TokenChars.LinkedAlias */: + scnr.next(); + token = getToken(context, 8 /* TokenTypes.LinkedAlias */, "@" /* TokenChars.LinkedAlias */); + context.inLinked = true; + return token; + case "." /* TokenChars.LinkedDot */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 9 /* TokenTypes.LinkedDot */, "." /* TokenChars.LinkedDot */); + case ":" /* TokenChars.LinkedDelimiter */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 10 /* TokenTypes.LinkedDelimiter */, ":" /* TokenChars.LinkedDelimiter */); + default: + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (isLinkedDotStart(scnr, context) || + isLinkedDelimiterStart(scnr, context)) { + skipSpaces(scnr); + return readTokenInLinked(scnr, context); + } + if (isLinkedModifierStart(scnr, context)) { + skipSpaces(scnr); + return getToken(context, 12 /* TokenTypes.LinkedModifier */, readLinkedModifier(scnr)); + } + if (isLinkedReferStart(scnr, context)) { + skipSpaces(scnr); + if (ch === "{" /* TokenChars.BraceLeft */) { + // scan the placeholder + return readTokenInPlaceholder(scnr, context) || token; + } + else { + return getToken(context, 11 /* TokenTypes.LinkedKey */, readLinkedRefer(scnr)); + } + } + if (currentType === 8 /* TokenTypes.LinkedAlias */) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + context.braceNest = 0; + context.inLinked = false; + return readToken(scnr, context); + } + } + // TODO: We need refactoring of token parsing ... + function readToken(scnr, context) { + let token = { type: 14 /* TokenTypes.EOF */ }; + if (context.braceNest > 0) { + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + } + if (context.inLinked) { + return readTokenInLinked(scnr, context) || getEndToken(context); + } + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + case "}" /* TokenChars.BraceRight */: + emitError(CompileErrorCodes.UNBALANCED_CLOSING_BRACE, currentPosition(), 0); + scnr.next(); + return getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + case "@" /* TokenChars.LinkedAlias */: + return readTokenInLinked(scnr, context) || getEndToken(context); + default: { + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + const { isModulo, hasSpace } = detectModuloStart(scnr); + if (isModulo) { + return hasSpace + ? getToken(context, 0 /* TokenTypes.Text */, readText(scnr)) + : getToken(context, 4 /* TokenTypes.Modulo */, readModulo(scnr)); + } + if (isTextStart(scnr)) { + return getToken(context, 0 /* TokenTypes.Text */, readText(scnr)); + } + break; + } + } + return token; + } + function nextToken() { + const { currentType, offset, startLoc, endLoc } = _context; + _context.lastType = currentType; + _context.lastOffset = offset; + _context.lastStartLoc = startLoc; + _context.lastEndLoc = endLoc; + _context.offset = currentOffset(); + _context.startLoc = currentPosition(); + if (_scnr.currentChar() === EOF) { + return getToken(_context, 14 /* TokenTypes.EOF */); + } + return readToken(_scnr, _context); + } + return { + nextToken, + currentOffset, + currentPosition, + context + }; +} + +const ERROR_DOMAIN$2 = 'parser'; +// Backslash backslash, backslash quote, uHHHH, UHHHHHH. +const KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g; +function fromEscapeSequence(match, codePoint4, codePoint6) { + switch (match) { + case `\\\\`: + return `\\`; + // eslint-disable-next-line no-useless-escape + case `\\\'`: + // eslint-disable-next-line no-useless-escape + return `\'`; + default: { + const codePoint = parseInt(codePoint4 || codePoint6, 16); + if (codePoint <= 0xd7ff || codePoint >= 0xe000) { + return String.fromCodePoint(codePoint); + } + // invalid ... + // Replace them with U+FFFD REPLACEMENT CHARACTER. + return '�'; + } + } +} +function createParser(options = {}) { + const location = options.location !== false; + const { onError, onWarn } = options; + function emitError(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onError) { + const loc = location ? createLocation(start, end) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$2, + args + }); + onError(err); + } + } + function emitWarn(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onWarn) { + const loc = location ? createLocation(start, end) : null; + onWarn(createCompileWarn(code, loc, args)); + } + } + function startNode(type, offset, loc) { + const node = { type }; + if (location) { + node.start = offset; + node.end = offset; + node.loc = { start: loc, end: loc }; + } + return node; + } + function endNode(node, offset, pos, type) { + if (type) { + node.type = type; + } + if (location) { + node.end = offset; + if (node.loc) { + node.loc.end = pos; + } + } + } + function parseText(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(3 /* NodeTypes.Text */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseList(tokenizer, index) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(5 /* NodeTypes.List */, offset, loc); + node.index = parseInt(index, 10); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseNamed(tokenizer, key, modulo) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(4 /* NodeTypes.Named */, offset, loc); + node.key = key; + if (modulo === true) { + node.modulo = true; + } + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLiteral(tokenizer, value) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(9 /* NodeTypes.Literal */, offset, loc); + node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinkedModifier(tokenizer) { + const token = tokenizer.nextToken(); + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get linked dot loc + const node = startNode(8 /* NodeTypes.LinkedModifier */, offset, loc); + if (token.type !== 12 /* TokenTypes.LinkedModifier */) { + // empty modifier + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0); + node.value = ''; + endNode(node, offset, loc); + return { + nextConsumeToken: token, + node + }; + } + // check token + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.value = token.value || ''; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node + }; + } + function parseLinkedKey(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(7 /* NodeTypes.LinkedKey */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinked(tokenizer) { + const context = tokenizer.context(); + const linkedNode = startNode(6 /* NodeTypes.Linked */, context.offset, context.startLoc); + let token = tokenizer.nextToken(); + if (token.type === 9 /* TokenTypes.LinkedDot */) { + const parsed = parseLinkedModifier(tokenizer); + linkedNode.modifier = parsed.node; + token = parsed.nextConsumeToken || tokenizer.nextToken(); + } + // asset check token + if (token.type !== 10 /* TokenTypes.LinkedDelimiter */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + token = tokenizer.nextToken(); + // skip brace left + if (token.type === 2 /* TokenTypes.BraceLeft */) { + token = tokenizer.nextToken(); + } + switch (token.type) { + case 11 /* TokenTypes.LinkedKey */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseNamed(tokenizer, token.value || ''); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseList(tokenizer, token.value || ''); + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLiteral(tokenizer, token.value || ''); + break; + default: { + // empty key + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0); + const nextContext = tokenizer.context(); + const emptyLinkedKeyNode = startNode(7 /* NodeTypes.LinkedKey */, nextContext.offset, nextContext.startLoc); + emptyLinkedKeyNode.value = ''; + endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc); + linkedNode.key = emptyLinkedKeyNode; + endNode(linkedNode, nextContext.offset, nextContext.startLoc); + return { + nextConsumeToken: token, + node: linkedNode + }; + } + } + endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node: linkedNode + }; + } + function parseMessage(tokenizer) { + const context = tokenizer.context(); + const startOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? tokenizer.currentOffset() + : context.offset; + const startLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.endLoc + : context.startLoc; + const node = startNode(2 /* NodeTypes.Message */, startOffset, startLoc); + node.items = []; + let nextToken = null; + let modulo = null; + do { + const token = nextToken || tokenizer.nextToken(); + nextToken = null; + switch (token.type) { + case 0 /* TokenTypes.Text */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseText(tokenizer, token.value || '')); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseList(tokenizer, token.value || '')); + break; + case 4 /* TokenTypes.Modulo */: + modulo = true; + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseNamed(tokenizer, token.value || '', !!modulo)); + if (modulo) { + emitWarn(tokenizer, CompileWarnCodes.USE_MODULO_SYNTAX, context.lastStartLoc, 0, getTokenCaption(token)); + modulo = null; + } + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseLiteral(tokenizer, token.value || '')); + break; + case 8 /* TokenTypes.LinkedAlias */: { + const parsed = parseLinked(tokenizer); + node.items.push(parsed.node); + nextToken = parsed.nextConsumeToken || null; + break; + } + } + } while (context.currentType !== 14 /* TokenTypes.EOF */ && + context.currentType !== 1 /* TokenTypes.Pipe */); + // adjust message node loc + const endOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastOffset + : tokenizer.currentOffset(); + const endLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastEndLoc + : tokenizer.currentPosition(); + endNode(node, endOffset, endLoc); + return node; + } + function parsePlural(tokenizer, offset, loc, msgNode) { + const context = tokenizer.context(); + let hasEmptyMessage = msgNode.items.length === 0; + const node = startNode(1 /* NodeTypes.Plural */, offset, loc); + node.cases = []; + node.cases.push(msgNode); + do { + const msg = parseMessage(tokenizer); + if (!hasEmptyMessage) { + hasEmptyMessage = msg.items.length === 0; + } + node.cases.push(msg); + } while (context.currentType !== 14 /* TokenTypes.EOF */); + if (hasEmptyMessage) { + emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseResource(tokenizer) { + const context = tokenizer.context(); + const { offset, startLoc } = context; + const msgNode = parseMessage(tokenizer); + if (context.currentType === 14 /* TokenTypes.EOF */) { + return msgNode; + } + else { + return parsePlural(tokenizer, offset, startLoc, msgNode); + } + } + function parse(source) { + const tokenizer = createTokenizer(source, assign({}, options)); + const context = tokenizer.context(); + const node = startNode(0 /* NodeTypes.Resource */, context.offset, context.startLoc); + if (location && node.loc) { + node.loc.source = source; + } + node.body = parseResource(tokenizer); + if (options.onCacheKey) { + node.cacheKey = options.onCacheKey(source); + } + // assert whether achieved to EOF + if (context.currentType !== 14 /* TokenTypes.EOF */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || ''); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + return { parse }; +} +function getTokenCaption(token) { + if (token.type === 14 /* TokenTypes.EOF */) { + return 'EOF'; + } + const name = (token.value || '').replace(/\r?\n/gu, '\\n'); + return name.length > 10 ? name.slice(0, 9) + '…' : name; +} + +function createTransformer(ast, options = {} // eslint-disable-line +) { + const _context = { + ast, + helpers: new Set() + }; + const context = () => _context; + const helper = (name) => { + _context.helpers.add(name); + return name; + }; + return { context, helper }; +} +function traverseNodes(nodes, transformer) { + for (let i = 0; i < nodes.length; i++) { + traverseNode(nodes[i], transformer); + } +} +function traverseNode(node, transformer) { + // TODO: if we need pre-hook of transform, should be implemented to here + switch (node.type) { + case 1 /* NodeTypes.Plural */: + traverseNodes(node.cases, transformer); + transformer.helper("plural" /* HelperNameMap.PLURAL */); + break; + case 2 /* NodeTypes.Message */: + traverseNodes(node.items, transformer); + break; + case 6 /* NodeTypes.Linked */: { + const linked = node; + traverseNode(linked.key, transformer); + transformer.helper("linked" /* HelperNameMap.LINKED */); + transformer.helper("type" /* HelperNameMap.TYPE */); + break; + } + case 5 /* NodeTypes.List */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("list" /* HelperNameMap.LIST */); + break; + case 4 /* NodeTypes.Named */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("named" /* HelperNameMap.NAMED */); + break; + } + // TODO: if we need post-hook of transform, should be implemented to here +} +// transform AST +function transform(ast, options = {} // eslint-disable-line +) { + const transformer = createTransformer(ast); + transformer.helper("normalize" /* HelperNameMap.NORMALIZE */); + // traverse + ast.body && traverseNode(ast.body, transformer); + // set meta information + const context = transformer.context(); + ast.helpers = Array.from(context.helpers); +} + +function optimize(ast) { + const body = ast.body; + if (body.type === 2 /* NodeTypes.Message */) { + optimizeMessageNode(body); + } + else { + body.cases.forEach(c => optimizeMessageNode(c)); + } + return ast; +} +function optimizeMessageNode(message) { + if (message.items.length === 1) { + const item = message.items[0]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + message.static = item.value; + delete item.value; // optimization for size + } + } + else { + const values = []; + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (!(item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */)) { + break; + } + if (item.value == null) { + break; + } + values.push(item.value); + } + if (values.length === message.items.length) { + message.static = join(values); + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + delete item.value; // optimization for size + } + } + } + } +} + +const ERROR_DOMAIN$1 = 'minifier'; +/* eslint-disable @typescript-eslint/no-explicit-any */ +function minify(node) { + node.t = node.type; + switch (node.type) { + case 0 /* NodeTypes.Resource */: { + const resource = node; + minify(resource.body); + resource.b = resource.body; + delete resource.body; + break; + } + case 1 /* NodeTypes.Plural */: { + const plural = node; + const cases = plural.cases; + for (let i = 0; i < cases.length; i++) { + minify(cases[i]); + } + plural.c = cases; + delete plural.cases; + break; + } + case 2 /* NodeTypes.Message */: { + const message = node; + const items = message.items; + for (let i = 0; i < items.length; i++) { + minify(items[i]); + } + message.i = items; + delete message.items; + if (message.static) { + message.s = message.static; + delete message.static; + } + break; + } + case 3 /* NodeTypes.Text */: + case 9 /* NodeTypes.Literal */: + case 8 /* NodeTypes.LinkedModifier */: + case 7 /* NodeTypes.LinkedKey */: { + const valueNode = node; + if (valueNode.value) { + valueNode.v = valueNode.value; + delete valueNode.value; + } + break; + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + minify(linked.key); + linked.k = linked.key; + delete linked.key; + if (linked.modifier) { + minify(linked.modifier); + linked.m = linked.modifier; + delete linked.modifier; + } + break; + } + case 5 /* NodeTypes.List */: { + const list = node; + list.i = list.index; + delete list.index; + break; + } + case 4 /* NodeTypes.Named */: { + const named = node; + named.k = named.key; + delete named.key; + break; + } + default: + { + throw createCompileError(CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE, null, { + domain: ERROR_DOMAIN$1, + args: [node.type] + }); + } + } + delete node.type; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +// eslint-disable-next-line @typescript-eslint/triple-slash-reference +/// +const ERROR_DOMAIN = 'parser'; +function createCodeGenerator(ast, options) { + const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options; + const location = options.location !== false; + const _context = { + filename, + code: '', + column: 1, + line: 1, + offset: 0, + map: undefined, + breakLineCode, + needIndent: _needIndent, + indentLevel: 0 + }; + if (location && ast.loc) { + _context.source = ast.loc.source; + } + const context = () => _context; + function push(code, node) { + _context.code += code; + } + function _newline(n, withBreakLine = true) { + const _breakLineCode = withBreakLine ? breakLineCode : ''; + push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode); + } + function indent(withNewLine = true) { + const level = ++_context.indentLevel; + withNewLine && _newline(level); + } + function deindent(withNewLine = true) { + const level = --_context.indentLevel; + withNewLine && _newline(level); + } + function newline() { + _newline(_context.indentLevel); + } + const helper = (key) => `_${key}`; + const needIndent = () => _context.needIndent; + return { + context, + push, + indent, + deindent, + newline, + helper, + needIndent + }; +} +function generateLinkedNode(generator, node) { + const { helper } = generator; + generator.push(`${helper("linked" /* HelperNameMap.LINKED */)}(`); + generateNode(generator, node.key); + if (node.modifier) { + generator.push(`, `); + generateNode(generator, node.modifier); + generator.push(`, _type`); + } + else { + generator.push(`, undefined, _type`); + } + generator.push(`)`); +} +function generateMessageNode(generator, node) { + const { helper, needIndent } = generator; + generator.push(`${helper("normalize" /* HelperNameMap.NORMALIZE */)}([`); + generator.indent(needIndent()); + const length = node.items.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.items[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push('])'); +} +function generatePluralNode(generator, node) { + const { helper, needIndent } = generator; + if (node.cases.length > 1) { + generator.push(`${helper("plural" /* HelperNameMap.PLURAL */)}([`); + generator.indent(needIndent()); + const length = node.cases.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.cases[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push(`])`); + } +} +function generateResource(generator, node) { + if (node.body) { + generateNode(generator, node.body); + } + else { + generator.push('null'); + } +} +function generateNode(generator, node) { + const { helper } = generator; + switch (node.type) { + case 0 /* NodeTypes.Resource */: + generateResource(generator, node); + break; + case 1 /* NodeTypes.Plural */: + generatePluralNode(generator, node); + break; + case 2 /* NodeTypes.Message */: + generateMessageNode(generator, node); + break; + case 6 /* NodeTypes.Linked */: + generateLinkedNode(generator, node); + break; + case 8 /* NodeTypes.LinkedModifier */: + generator.push(JSON.stringify(node.value), node); + break; + case 7 /* NodeTypes.LinkedKey */: + generator.push(JSON.stringify(node.value), node); + break; + case 5 /* NodeTypes.List */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("list" /* HelperNameMap.LIST */)}(${node.index}))`, node); + break; + case 4 /* NodeTypes.Named */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("named" /* HelperNameMap.NAMED */)}(${JSON.stringify(node.key)}))`, node); + break; + case 9 /* NodeTypes.Literal */: + generator.push(JSON.stringify(node.value), node); + break; + case 3 /* NodeTypes.Text */: + generator.push(JSON.stringify(node.value), node); + break; + default: + { + throw createCompileError(CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE, null, { + domain: ERROR_DOMAIN, + args: [node.type] + }); + } + } +} +// generate code from AST +const generate = (ast, options = {} // eslint-disable-line +) => { + const mode = isString(options.mode) ? options.mode : 'normal'; + const filename = isString(options.filename) + ? options.filename + : 'message.intl'; + const sourceMap = !!options.sourceMap; + // prettier-ignore + const breakLineCode = options.breakLineCode != null + ? options.breakLineCode + : mode === 'arrow' + ? ';' + : '\n'; + const needIndent = options.needIndent ? options.needIndent : mode !== 'arrow'; + const helpers = ast.helpers || []; + const generator = createCodeGenerator(ast, { + mode, + filename, + sourceMap, + breakLineCode, + needIndent + }); + generator.push(mode === 'normal' ? `function __msg__ (ctx) {` : `(ctx) => {`); + generator.indent(needIndent); + if (helpers.length > 0) { + generator.push(`const { ${join(helpers.map(s => `${s}: _${s}`), ', ')} } = ctx`); + generator.newline(); + } + generator.push(`return `); + generateNode(generator, ast); + generator.deindent(needIndent); + generator.push(`}`); + delete ast.helpers; + const { code, map } = generator.context(); + return { + ast, + code, + map: map ? map.toJSON() : undefined // eslint-disable-line @typescript-eslint/no-explicit-any + }; +}; + +function baseCompile$1(source, options = {}) { + const assignedOptions = assign({}, options); + const jit = !!assignedOptions.jit; + const enalbeMinify = !!assignedOptions.minify; + const enambeOptimize = assignedOptions.optimize == null ? true : assignedOptions.optimize; + // parse source codes + const parser = createParser(assignedOptions); + const ast = parser.parse(source); + if (!jit) { + // transform ASTs + transform(ast, assignedOptions); + // generate javascript codes + return generate(ast, assignedOptions); + } + else { + // optimize ASTs + enambeOptimize && optimize(ast); + // minimize ASTs + enalbeMinify && minify(ast); + // In JIT mode, no ast transform, no code generation. + return { ast, code: '' }; + } +} + +function isMessageAST(val) { + return (isObject(val) && + resolveType(val) === 0 && + (hasOwn(val, 'b') || hasOwn(val, 'body'))); +} +const PROPS_BODY = ['b', 'body']; +function resolveBody(node) { + return resolveProps(node, PROPS_BODY); +} +const PROPS_CASES = ['c', 'cases']; +function resolveCases(node) { + return resolveProps(node, PROPS_CASES, []); +} +const PROPS_STATIC = ['s', 'static']; +function resolveStatic(node) { + return resolveProps(node, PROPS_STATIC); +} +const PROPS_ITEMS = ['i', 'items']; +function resolveItems(node) { + return resolveProps(node, PROPS_ITEMS, []); +} +const PROPS_TYPE = ['t', 'type']; +function resolveType(node) { + return resolveProps(node, PROPS_TYPE); +} +const PROPS_VALUE = ['v', 'value']; +function resolveValue$1(node, type) { + const resolved = resolveProps(node, PROPS_VALUE); + if (resolved != null) { + return resolved; + } + else { + throw createUnhandleNodeError(type); + } +} +const PROPS_MODIFIER = ['m', 'modifier']; +function resolveLinkedModifier(node) { + return resolveProps(node, PROPS_MODIFIER); +} +const PROPS_KEY = ['k', 'key']; +function resolveLinkedKey(node) { + const resolved = resolveProps(node, PROPS_KEY); + if (resolved) { + return resolved; + } + else { + throw createUnhandleNodeError(6 /* NodeTypes.Linked */); + } +} +function resolveProps(node, props, defaultValue) { + for (let i = 0; i < props.length; i++) { + const prop = props[i]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (hasOwn(node, prop) && node[prop] != null) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return node[prop]; + } + } + return defaultValue; +} +const AST_NODE_PROPS_KEYS = [ + ...PROPS_BODY, + ...PROPS_CASES, + ...PROPS_STATIC, + ...PROPS_ITEMS, + ...PROPS_KEY, + ...PROPS_MODIFIER, + ...PROPS_VALUE, + ...PROPS_TYPE +]; +function createUnhandleNodeError(type) { + return new Error(`unhandled node type: ${type}`); +} + +const pathStateMachine = []; +pathStateMachine[0 /* States.BEFORE_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [0 /* States.BEFORE_PATH */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] +}; +pathStateMachine[1 /* States.IN_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] +}; +pathStateMachine[2 /* States.BEFORE_IDENT */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [2 /* States.BEFORE_IDENT */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */] +}; +pathStateMachine[3 /* States.IN_IDENT */] = { + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */, 1 /* Actions.PUSH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */, 1 /* Actions.PUSH */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */, 1 /* Actions.PUSH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */, 1 /* Actions.PUSH */] +}; +pathStateMachine[4 /* States.IN_SUB_PATH */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */], + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [ + 4 /* States.IN_SUB_PATH */, + 2 /* Actions.INC_SUB_PATH_DEPTH */ + ], + ["]" /* PathCharTypes.RIGHT_BRACKET */]: [1 /* States.IN_PATH */, 3 /* Actions.PUSH_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */] +}; +pathStateMachine[5 /* States.IN_SINGLE_QUOTE */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */] +}; +pathStateMachine[6 /* States.IN_DOUBLE_QUOTE */] = { + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */] +}; +/** + * Check if an expression is a literal value. + */ +const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/; +function isLiteral(exp) { + return literalValueRE.test(exp); +} +/** + * Strip quotes from a string + */ +function stripQuotes(str) { + const a = str.charCodeAt(0); + const b = str.charCodeAt(str.length - 1); + return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str; +} +/** + * Determine the type of a character in a keypath. + */ +function getPathCharType(ch) { + if (ch === undefined || ch === null) { + return "o" /* PathCharTypes.END_OF_FAIL */; + } + const code = ch.charCodeAt(0); + switch (code) { + case 0x5b: // [ + case 0x5d: // ] + case 0x2e: // . + case 0x22: // " + case 0x27: // ' + return ch; + case 0x5f: // _ + case 0x24: // $ + case 0x2d: // - + return "i" /* PathCharTypes.IDENT */; + case 0x09: // Tab (HT) + case 0x0a: // Newline (LF) + case 0x0d: // Return (CR) + case 0xa0: // No-break space (NBSP) + case 0xfeff: // Byte Order Mark (BOM) + case 0x2028: // Line Separator (LS) + case 0x2029: // Paragraph Separator (PS) + return "w" /* PathCharTypes.WORKSPACE */; + } + return "i" /* PathCharTypes.IDENT */; +} +/** + * Format a subPath, return its plain form if it is + * a literal string or number. Otherwise prepend the + * dynamic indicator (*). + */ +function formatSubPath(path) { + const trimmed = path.trim(); + // invalid leading 0 + if (path.charAt(0) === '0' && isNaN(parseInt(path))) { + return false; + } + return isLiteral(trimmed) + ? stripQuotes(trimmed) + : "*" /* PathCharTypes.ASTARISK */ + trimmed; +} +/** + * Parse a string path into an array of segments + */ +function parse(path) { + const keys = []; + let index = -1; + let mode = 0 /* States.BEFORE_PATH */; + let subPathDepth = 0; + let c; + let key; // eslint-disable-line + let newChar; + let type; + let transition; + let action; + let typeMap; + const actions = []; + actions[0 /* Actions.APPEND */] = () => { + if (key === undefined) { + key = newChar; + } + else { + key += newChar; + } + }; + actions[1 /* Actions.PUSH */] = () => { + if (key !== undefined) { + keys.push(key); + key = undefined; + } + }; + actions[2 /* Actions.INC_SUB_PATH_DEPTH */] = () => { + actions[0 /* Actions.APPEND */](); + subPathDepth++; + }; + actions[3 /* Actions.PUSH_SUB_PATH */] = () => { + if (subPathDepth > 0) { + subPathDepth--; + mode = 4 /* States.IN_SUB_PATH */; + actions[0 /* Actions.APPEND */](); + } + else { + subPathDepth = 0; + if (key === undefined) { + return false; + } + key = formatSubPath(key); + if (key === false) { + return false; + } + else { + actions[1 /* Actions.PUSH */](); + } + } + }; + function maybeUnescapeQuote() { + const nextChar = path[index + 1]; + if ((mode === 5 /* States.IN_SINGLE_QUOTE */ && + nextChar === "'" /* PathCharTypes.SINGLE_QUOTE */) || + (mode === 6 /* States.IN_DOUBLE_QUOTE */ && + nextChar === "\"" /* PathCharTypes.DOUBLE_QUOTE */)) { + index++; + newChar = '\\' + nextChar; + actions[0 /* Actions.APPEND */](); + return true; + } + } + while (mode !== null) { + index++; + c = path[index]; + if (c === '\\' && maybeUnescapeQuote()) { + continue; + } + type = getPathCharType(c); + typeMap = pathStateMachine[mode]; + transition = typeMap[type] || typeMap["l" /* PathCharTypes.ELSE */] || 8 /* States.ERROR */; + // check parse error + if (transition === 8 /* States.ERROR */) { + return; + } + mode = transition[0]; + if (transition[1] !== undefined) { + action = actions[transition[1]]; + if (action) { + newChar = c; + if (action() === false) { + return; + } + } + } + // check parse finish + if (mode === 7 /* States.AFTER_PATH */) { + return keys; + } + } +} +// path token cache +const cache = new Map(); +/** + * key-value message resolver + * + * @remarks + * Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ +function resolveWithKeyValue(obj, path) { + return isObject(obj) ? obj[path] : null; +} +/** + * message resolver + * + * @remarks + * Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default. + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ +function resolveValue(obj, path) { + // check object + if (!isObject(obj)) { + return null; + } + // parse path + let hit = cache.get(path); + if (!hit) { + hit = parse(path); + if (hit) { + cache.set(path, hit); + } + } + // check hit + if (!hit) { + return null; + } + // resolve path value + const len = hit.length; + let last = obj; + let i = 0; + while (i < len) { + const key = hit[i]; + /** + * NOTE: + * if `key` is intlify message format AST node key and `last` is intlify message format AST, skip it. + * because the AST node is not a key-value structure. + */ + if (AST_NODE_PROPS_KEYS.includes(key) && isMessageAST(last)) { + return null; + } + const val = last[key]; + if (val === undefined) { + return null; + } + if (isFunction(last)) { + return null; + } + last = val; + i++; + } + return last; +} + +const DEFAULT_MODIFIER = (str) => str; +const DEFAULT_MESSAGE = (ctx) => ''; // eslint-disable-line +const DEFAULT_MESSAGE_DATA_TYPE = 'text'; +const DEFAULT_NORMALIZE = (values) => values.length === 0 ? '' : join(values); +const DEFAULT_INTERPOLATE = toDisplayString; +function pluralDefault(choice, choicesLength) { + choice = Math.abs(choice); + if (choicesLength === 2) { + // prettier-ignore + return choice + ? choice > 1 + ? 1 + : 0 + : 1; + } + return choice ? Math.min(choice, 2) : 0; +} +function getPluralIndex(options) { + // prettier-ignore + const index = isNumber(options.pluralIndex) + ? options.pluralIndex + : -1; + // prettier-ignore + return options.named && (isNumber(options.named.count) || isNumber(options.named.n)) + ? isNumber(options.named.count) + ? options.named.count + : isNumber(options.named.n) + ? options.named.n + : index + : index; +} +function normalizeNamed(pluralIndex, props) { + if (!props.count) { + props.count = pluralIndex; + } + if (!props.n) { + props.n = pluralIndex; + } +} +function createMessageContext(options = {}) { + const locale = options.locale; + const pluralIndex = getPluralIndex(options); + const pluralRule = isObject(options.pluralRules) && + isString(locale) && + isFunction(options.pluralRules[locale]) + ? options.pluralRules[locale] + : pluralDefault; + const orgPluralRule = isObject(options.pluralRules) && + isString(locale) && + isFunction(options.pluralRules[locale]) + ? pluralDefault + : undefined; + const plural = (messages) => { + return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)]; + }; + const _list = options.list || []; + const list = (index) => _list[index]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _named = options.named || create(); + isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named); + const named = (key) => _named[key]; + function message(key) { + // prettier-ignore + const msg = isFunction(options.messages) + ? options.messages(key) + : isObject(options.messages) + ? options.messages[key] + : false; + return !msg + ? options.parent + ? options.parent.message(key) // resolve from parent messages + : DEFAULT_MESSAGE + : msg; + } + const _modifier = (name) => options.modifiers + ? options.modifiers[name] + : DEFAULT_MODIFIER; + const normalize = isPlainObject(options.processor) && isFunction(options.processor.normalize) + ? options.processor.normalize + : DEFAULT_NORMALIZE; + const interpolate = isPlainObject(options.processor) && + isFunction(options.processor.interpolate) + ? options.processor.interpolate + : DEFAULT_INTERPOLATE; + const type = isPlainObject(options.processor) && isString(options.processor.type) + ? options.processor.type + : DEFAULT_MESSAGE_DATA_TYPE; + const linked = (key, ...args) => { + const [arg1, arg2] = args; + let type = 'text'; + let modifier = ''; + if (args.length === 1) { + if (isObject(arg1)) { + modifier = arg1.modifier || modifier; + type = arg1.type || type; + } + else if (isString(arg1)) { + modifier = arg1 || modifier; + } + } + else if (args.length === 2) { + if (isString(arg1)) { + modifier = arg1 || modifier; + } + if (isString(arg2)) { + type = arg2 || type; + } + } + const ret = message(key)(ctx); + const msg = + // The message in vnode resolved with linked are returned as an array by processor.nomalize + type === 'vnode' && isArray(ret) && modifier + ? ret[0] + : ret; + return modifier ? _modifier(modifier)(msg, type) : msg; + }; + const ctx = { + ["list" /* HelperNameMap.LIST */]: list, + ["named" /* HelperNameMap.NAMED */]: named, + ["plural" /* HelperNameMap.PLURAL */]: plural, + ["linked" /* HelperNameMap.LINKED */]: linked, + ["message" /* HelperNameMap.MESSAGE */]: message, + ["type" /* HelperNameMap.TYPE */]: type, + ["interpolate" /* HelperNameMap.INTERPOLATE */]: interpolate, + ["normalize" /* HelperNameMap.NORMALIZE */]: normalize, + ["values" /* HelperNameMap.VALUES */]: assign(create(), _list, _named) + }; + return ctx; +} + +let devtools = null; +function setDevToolsHook(hook) { + devtools = hook; +} +function getDevToolsHook() { + return devtools; +} +function initI18nDevTools(i18n, version, meta) { + // TODO: queue if devtools is undefined + devtools && + devtools.emit("i18n:init" /* IntlifyDevToolsHooks.I18nInit */, { + timestamp: Date.now(), + i18n, + version, + meta + }); +} +const translateDevTools = /* #__PURE__*/ createDevToolsHook("function:translate" /* IntlifyDevToolsHooks.FunctionTranslate */); +function createDevToolsHook(hook) { + return (payloads) => devtools && devtools.emit(hook, payloads); +} + +const code$1 = CompileWarnCodes.__EXTEND_POINT__; +const inc$1 = incrementer(code$1); +const CoreWarnCodes = { + NOT_FOUND_KEY: code$1, // 2 + FALLBACK_TO_TRANSLATE: inc$1(), // 3 + CANNOT_FORMAT_NUMBER: inc$1(), // 4 + FALLBACK_TO_NUMBER_FORMAT: inc$1(), // 5 + CANNOT_FORMAT_DATE: inc$1(), // 6 + FALLBACK_TO_DATE_FORMAT: inc$1(), // 7 + EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc$1(), // 8 + __EXTEND_POINT__: inc$1() // 9 +}; +/** @internal */ +const warnMessages = { + [CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`, + [CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`, + [CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`, + [CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]: `This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future.` +}; +function getWarnMessage(code, ...args) { + return format$1(warnMessages[code], ...args); +} + +const code = CompileErrorCodes.__EXTEND_POINT__; +const inc = incrementer(code); +const CoreErrorCodes = { + INVALID_ARGUMENT: code, // 17 + INVALID_DATE_ARGUMENT: inc(), // 18 + INVALID_ISO_DATE_ARGUMENT: inc(), // 19 + NOT_SUPPORT_NON_STRING_MESSAGE: inc(), // 20 + NOT_SUPPORT_LOCALE_PROMISE_VALUE: inc(), // 21 + NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: inc(), // 22 + NOT_SUPPORT_LOCALE_TYPE: inc(), // 23 + __EXTEND_POINT__: inc() // 24 +}; +function createCoreError(code) { + return createCompileError(code, null, { messages: errorMessages } ); +} +/** @internal */ +const errorMessages = { + [CoreErrorCodes.INVALID_ARGUMENT]: 'Invalid arguments', + [CoreErrorCodes.INVALID_DATE_ARGUMENT]: 'The date provided is an invalid Date object.' + + 'Make sure your Date represents a valid date.', + [CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: 'The argument provided is not a valid ISO date string', + [CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE]: 'Not support non-string message', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]: 'cannot support promise value', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]: 'cannot support async function', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: 'cannot support locale type' +}; + +/** @internal */ +function getLocale(context, options) { + return options.locale != null + ? resolveLocale(options.locale) + : resolveLocale(context.locale); +} +let _resolveLocale; +/** @internal */ +function resolveLocale(locale) { + if (isString(locale)) { + return locale; + } + else { + if (isFunction(locale)) { + if (locale.resolvedOnce && _resolveLocale != null) { + return _resolveLocale; + } + else if (locale.constructor.name === 'Function') { + const resolve = locale(); + if (isPromise(resolve)) { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE); + } + return (_resolveLocale = resolve); + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION); + } + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE); + } + } +} +/** + * Fallback with simple implemenation + * + * @remarks + * A fallback locale function implemented with a simple fallback algorithm. + * + * Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nGeneral + */ +function fallbackWithSimple(ctx, fallback, start // eslint-disable-line @typescript-eslint/no-unused-vars +) { + // prettier-ignore + return [...new Set([ + start, + ...(isArray(fallback) + ? fallback + : isObject(fallback) + ? Object.keys(fallback) + : isString(fallback) + ? [fallback] + : [start]) + ])]; +} +/** + * Fallback with locale chain + * + * @remarks + * A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @VueI18nGeneral + */ +function fallbackWithLocaleChain(ctx, fallback, start) { + const startLocale = isString(start) ? start : DEFAULT_LOCALE; + const context = ctx; + if (!context.__localeChainCache) { + context.__localeChainCache = new Map(); + } + let chain = context.__localeChainCache.get(startLocale); + if (!chain) { + chain = []; + // first block defined by start + let block = [start]; + // while any intervening block found + while (isArray(block)) { + block = appendBlockToChain(chain, block, fallback); + } + // prettier-ignore + // last block defined by default + const defaults = isArray(fallback) || !isPlainObject(fallback) + ? fallback + : fallback['default'] + ? fallback['default'] + : null; + // convert defaults to array + block = isString(defaults) ? [defaults] : defaults; + if (isArray(block)) { + appendBlockToChain(chain, block, false); + } + context.__localeChainCache.set(startLocale, chain); + } + return chain; +} +function appendBlockToChain(chain, block, blocks) { + let follow = true; + for (let i = 0; i < block.length && isBoolean(follow); i++) { + const locale = block[i]; + if (isString(locale)) { + follow = appendLocaleToChain(chain, block[i], blocks); + } + } + return follow; +} +function appendLocaleToChain(chain, locale, blocks) { + let follow; + const tokens = locale.split('-'); + do { + const target = tokens.join('-'); + follow = appendItemToChain(chain, target, blocks); + tokens.splice(-1, 1); + } while (tokens.length && follow === true); + return follow; +} +function appendItemToChain(chain, target, blocks) { + let follow = false; + if (!chain.includes(target)) { + follow = true; + if (target) { + follow = target[target.length - 1] !== '!'; + const locale = target.replace(/!/g, ''); + chain.push(locale); + if ((isArray(blocks) || isPlainObject(blocks)) && + blocks[locale] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + follow = blocks[locale]; + } + } + } + return follow; +} + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Intlify core-base version + * @internal + */ +const VERSION = '9.14.5'; +const NOT_REOSLVED = -1; +const DEFAULT_LOCALE = 'en-US'; +const MISSING_RESOLVE_VALUE = ''; +const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`; +function getDefaultLinkedModifiers() { + return { + upper: (val, type) => { + // prettier-ignore + return type === 'text' && isString(val) + ? val.toUpperCase() + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? val.children.toUpperCase() + : val; + }, + lower: (val, type) => { + // prettier-ignore + return type === 'text' && isString(val) + ? val.toLowerCase() + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? val.children.toLowerCase() + : val; + }, + capitalize: (val, type) => { + // prettier-ignore + return (type === 'text' && isString(val) + ? capitalize(val) + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? capitalize(val.children) + : val); + } + }; +} +let _compiler; +function registerMessageCompiler(compiler) { + _compiler = compiler; +} +let _resolver; +/** + * Register the message resolver + * + * @param resolver - A {@link MessageResolver} function + * + * @VueI18nGeneral + */ +function registerMessageResolver(resolver) { + _resolver = resolver; +} +let _fallbacker; +/** + * Register the locale fallbacker + * + * @param fallbacker - A {@link LocaleFallbacker} function + * + * @VueI18nGeneral + */ +function registerLocaleFallbacker(fallbacker) { + _fallbacker = fallbacker; +} +// Additional Meta for Intlify DevTools +let _additionalMeta = null; +/* #__NO_SIDE_EFFECTS__ */ +const setAdditionalMeta = (meta) => { + _additionalMeta = meta; +}; +/* #__NO_SIDE_EFFECTS__ */ +const getAdditionalMeta = () => _additionalMeta; +let _fallbackContext = null; +const setFallbackContext = (context) => { + _fallbackContext = context; +}; +const getFallbackContext = () => _fallbackContext; +// ID for CoreContext +let _cid = 0; +function createCoreContext(options = {}) { + // setup options + const onWarn = isFunction(options.onWarn) ? options.onWarn : warn; + const version = isString(options.version) ? options.version : VERSION; + const locale = isString(options.locale) || isFunction(options.locale) + ? options.locale + : DEFAULT_LOCALE; + const _locale = isFunction(locale) ? DEFAULT_LOCALE : locale; + const fallbackLocale = isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + isString(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale; + const messages = isPlainObject(options.messages) + ? options.messages + : createResources(_locale); + const datetimeFormats = isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : createResources(_locale) + ; + const numberFormats = isPlainObject(options.numberFormats) + ? options.numberFormats + : createResources(_locale) + ; + const modifiers = assign(create(), options.modifiers, getDefaultLinkedModifiers()); + const pluralRules = options.pluralRules || create(); + const missing = isFunction(options.missing) ? options.missing : null; + const missingWarn = isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + const fallbackWarn = isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + const fallbackFormat = !!options.fallbackFormat; + const unresolving = !!options.unresolving; + const postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + const processor = isPlainObject(options.processor) ? options.processor : null; + const warnHtmlMessage = isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const escapeParameter = !!options.escapeParameter; + const messageCompiler = isFunction(options.messageCompiler) + ? options.messageCompiler + : _compiler; + if (isFunction(options.messageCompiler)) { + warnOnce(getWarnMessage(CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER)); + } + const messageResolver = isFunction(options.messageResolver) + ? options.messageResolver + : _resolver || resolveWithKeyValue; + const localeFallbacker = isFunction(options.localeFallbacker) + ? options.localeFallbacker + : _fallbacker || fallbackWithSimple; + const fallbackContext = isObject(options.fallbackContext) + ? options.fallbackContext + : undefined; + // setup internal options + const internalOptions = options; + const __datetimeFormatters = isObject(internalOptions.__datetimeFormatters) + ? internalOptions.__datetimeFormatters + : new Map() + ; + const __numberFormatters = isObject(internalOptions.__numberFormatters) + ? internalOptions.__numberFormatters + : new Map() + ; + const __meta = isObject(internalOptions.__meta) ? internalOptions.__meta : {}; + _cid++; + const context = { + version, + cid: _cid, + locale, + fallbackLocale, + messages, + modifiers, + pluralRules, + missing, + missingWarn, + fallbackWarn, + fallbackFormat, + unresolving, + postTranslation, + processor, + warnHtmlMessage, + escapeParameter, + messageCompiler, + messageResolver, + localeFallbacker, + fallbackContext, + onWarn, + __meta + }; + { + context.datetimeFormats = datetimeFormats; + context.numberFormats = numberFormats; + context.__datetimeFormatters = __datetimeFormatters; + context.__numberFormatters = __numberFormatters; + } + // for vue-devtools timeline event + { + context.__v_emitter = + internalOptions.__v_emitter != null + ? internalOptions.__v_emitter + : undefined; + } + // NOTE: experimental !! + { + initI18nDevTools(context, version, __meta); + } + return context; +} +const createResources = (locale) => ({ [locale]: create() }); +/** @internal */ +function isTranslateFallbackWarn(fallback, key) { + return fallback instanceof RegExp ? fallback.test(key) : fallback; +} +/** @internal */ +function isTranslateMissingWarn(missing, key) { + return missing instanceof RegExp ? missing.test(key) : missing; +} +/** @internal */ +function handleMissing(context, key, locale, missingWarn, type) { + const { missing, onWarn } = context; + // for vue-devtools timeline event + { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("missing" /* VueDevToolsTimelineEvents.MISSING */, { + locale, + key, + type, + groupId: `${type}:${key}` + }); + } + } + if (missing !== null) { + const ret = missing(context, locale, key, type); + return isString(ret) ? ret : key; + } + else { + if (isTranslateMissingWarn(missingWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.NOT_FOUND_KEY, { key, locale })); + } + return key; + } +} +/** @internal */ +function updateFallbackLocale(ctx, locale, fallback) { + const context = ctx; + context.__localeChainCache = new Map(); + ctx.localeFallbacker(ctx, fallback, locale); +} +/** @internal */ +function isAlmostSameLocale(locale, compareLocale) { + if (locale === compareLocale) + return false; + return locale.split('-')[0] === compareLocale.split('-')[0]; +} +/** @internal */ +function isImplicitFallback(targetLocale, locales) { + const index = locales.indexOf(targetLocale); + if (index === -1) { + return false; + } + for (let i = index + 1; i < locales.length; i++) { + if (isAlmostSameLocale(targetLocale, locales[i])) { + return true; + } + } + return false; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +function format(ast) { + const msg = (ctx) => formatParts(ctx, ast); + return msg; +} +function formatParts(ctx, ast) { + const body = resolveBody(ast); + if (body == null) { + throw createUnhandleNodeError(0 /* NodeTypes.Resource */); + } + const type = resolveType(body); + if (type === 1 /* NodeTypes.Plural */) { + const plural = body; + const cases = resolveCases(plural); + return ctx.plural(cases.reduce((messages, c) => [ + ...messages, + formatMessageParts(ctx, c) + ], [])); + } + else { + return formatMessageParts(ctx, body); + } +} +function formatMessageParts(ctx, node) { + const static_ = resolveStatic(node); + if (static_ != null) { + return ctx.type === 'text' + ? static_ + : ctx.normalize([static_]); + } + else { + const messages = resolveItems(node).reduce((acm, c) => [...acm, formatMessagePart(ctx, c)], []); + return ctx.normalize(messages); + } +} +function formatMessagePart(ctx, node) { + const type = resolveType(node); + switch (type) { + case 3 /* NodeTypes.Text */: { + return resolveValue$1(node, type); + } + case 9 /* NodeTypes.Literal */: { + return resolveValue$1(node, type); + } + case 4 /* NodeTypes.Named */: { + const named = node; + if (hasOwn(named, 'k') && named.k) { + return ctx.interpolate(ctx.named(named.k)); + } + if (hasOwn(named, 'key') && named.key) { + return ctx.interpolate(ctx.named(named.key)); + } + throw createUnhandleNodeError(type); + } + case 5 /* NodeTypes.List */: { + const list = node; + if (hasOwn(list, 'i') && isNumber(list.i)) { + return ctx.interpolate(ctx.list(list.i)); + } + if (hasOwn(list, 'index') && isNumber(list.index)) { + return ctx.interpolate(ctx.list(list.index)); + } + throw createUnhandleNodeError(type); + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + const modifier = resolveLinkedModifier(linked); + const key = resolveLinkedKey(linked); + return ctx.linked(formatMessagePart(ctx, key), modifier ? formatMessagePart(ctx, modifier) : undefined, ctx.type); + } + case 7 /* NodeTypes.LinkedKey */: { + return resolveValue$1(node, type); + } + case 8 /* NodeTypes.LinkedModifier */: { + return resolveValue$1(node, type); + } + default: + throw new Error(`unhandled node on format message part: ${type}`); + } +} + +const WARN_MESSAGE = `Detected HTML in '{source}' message. Recommend not using HTML messages to avoid XSS.`; +function checkHtmlMessage(source, warnHtmlMessage) { + if (warnHtmlMessage && detectHtmlTag(source)) { + warn(format$1(WARN_MESSAGE, { source })); + } +} +const defaultOnCacheKey = (message) => message; +let compileCache = create(); +function onCompileWarn(_warn) { + if (_warn.code === CompileWarnCodes.USE_MODULO_SYNTAX) { + warn(`The use of named interpolation with modulo syntax is deprecated. ` + + `It will be removed in v10.\n` + + `reference: https://vue-i18n.intlify.dev/guide/essentials/syntax#rails-i18n-format \n` + + `(message compiler warning message: ${_warn.message})`); + } +} +function clearCompileCache() { + compileCache = create(); +} +function baseCompile(message, options = {}) { + // error detecting on compile + let detectError = false; + const onError = options.onError || defaultOnError; + options.onError = (err) => { + detectError = true; + onError(err); + }; + // compile with mesasge-compiler + return { ...baseCompile$1(message, options), detectError }; +} +/* #__NO_SIDE_EFFECTS__ */ +const compileToFunction = (message, context) => { + if (!isString(message)) { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE); + } + // set onWarn + { + context.onWarn = onCompileWarn; + } + { + // check HTML message + const warnHtmlMessage = isBoolean(context.warnHtmlMessage) + ? context.warnHtmlMessage + : true; + checkHtmlMessage(message, warnHtmlMessage); + // check caches + const onCacheKey = context.onCacheKey || defaultOnCacheKey; + const cacheKey = onCacheKey(message); + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compile + const { code, detectError } = baseCompile(message, context); + // evaluate function + const msg = new Function(`return ${code}`)(); + // if occurred compile error, don't cache + return !detectError + ? (compileCache[cacheKey] = msg) + : msg; + } +}; +function compile(message, context) { + // set onWarn + { + context.onWarn = onCompileWarn; + } + if (isString(message)) { + // check HTML message + const warnHtmlMessage = isBoolean(context.warnHtmlMessage) + ? context.warnHtmlMessage + : true; + checkHtmlMessage(message, warnHtmlMessage); + // check caches + const onCacheKey = context.onCacheKey || defaultOnCacheKey; + const cacheKey = onCacheKey(message); + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compile with JIT mode + const { ast, detectError } = baseCompile(message, { + ...context, + location: true, + jit: true + }); + // compose message function from AST + const msg = format(ast); + // if occurred compile error, don't cache + return !detectError + ? (compileCache[cacheKey] = msg) + : msg; + } + else { + if (!isMessageAST(message)) { + warn(`the message that is resolve with key '${context.key}' is not supported for jit compilation`); + return (() => message); + } + // AST case (passed from bundler) + const cacheKey = message.cacheKey; + if (cacheKey) { + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compose message function from message (AST) + return (compileCache[cacheKey] = + format(message)); + } + else { + return format(message); + } + } +} + +const NOOP_MESSAGE_FUNCTION = () => ''; +const isMessageFunction = (val) => isFunction(val); +// implementation of `translate` function +function translate(context, ...args) { + const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context; + const [key, options] = parseTranslateArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const escapeParameter = isBoolean(options.escapeParameter) + ? options.escapeParameter + : context.escapeParameter; + const resolvedMessage = !!options.resolvedMessage; + // prettier-ignore + const defaultMsgOrKey = isString(options.default) || isBoolean(options.default) // default by function option + ? !isBoolean(options.default) + ? options.default + : (!messageCompiler ? () => key : key) + : fallbackFormat // default by `fallbackFormat` option + ? (!messageCompiler ? () => key : key) + : ''; + const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== ''; + const locale = getLocale(context, options); + // escape params + escapeParameter && escapeParams(options); + // resolve message format + // eslint-disable-next-line prefer-const + let [formatScope, targetLocale, message] = !resolvedMessage + ? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) + : [ + key, + locale, + messages[locale] || create() + ]; + // NOTE: + // Fix to work around `ssrTransfrom` bug in Vite. + // https://github.com/vitejs/vite/issues/4306 + // To get around this, use temporary variables. + // https://github.com/nuxt/framework/issues/1461#issuecomment-954606243 + let format = formatScope; + // if you use default message, set it as message format! + let cacheBaseKey = key; + if (!resolvedMessage && + !(isString(format) || + isMessageAST(format) || + isMessageFunction(format))) { + if (enableDefaultMsg) { + format = defaultMsgOrKey; + cacheBaseKey = format; + } + } + // checking message format and target locale + if (!resolvedMessage && + (!(isString(format) || + isMessageAST(format) || + isMessageFunction(format)) || + !isString(targetLocale))) { + return unresolving ? NOT_REOSLVED : key; + } + // TODO: refactor + if (isString(format) && context.messageCompiler == null) { + warn(`The message format compilation is not supported in this build. ` + + `Because message compiler isn't included. ` + + `You need to pre-compilation all message format. ` + + `So translate function return '${key}'.`); + return key; + } + // setup compile error detecting + let occurred = false; + const onError = () => { + occurred = true; + }; + // compile message format + const msg = !isMessageFunction(format) + ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) + : format; + // if occurred compile error, return the message format + if (occurred) { + return format; + } + // evaluate message with context + const ctxOptions = getMessageContextOptions(context, targetLocale, message, options); + const msgContext = createMessageContext(ctxOptions); + const messaged = evaluateMessage(context, msg, msgContext); + // if use post translation option, proceed it with handler + let ret = postTranslation + ? postTranslation(messaged, key) + : messaged; + // apply HTML sanitization for security + if (escapeParameter && isString(ret)) { + ret = sanitizeTranslatedHtml(ret); + } + // NOTE: experimental !! + { + // prettier-ignore + const payloads = { + timestamp: Date.now(), + key: isString(key) + ? key + : isMessageFunction(format) + ? format.key + : '', + locale: targetLocale || (isMessageFunction(format) + ? format.locale + : ''), + format: isString(format) + ? format + : isMessageFunction(format) + ? format.source + : '', + message: ret + }; + payloads.meta = assign({}, context.__meta, getAdditionalMeta() || {}); + translateDevTools(payloads); + } + return ret; +} +function escapeParams(options) { + if (isArray(options.list)) { + options.list = options.list.map(item => isString(item) ? escapeHtml(item) : item); + } + else if (isObject(options.named)) { + Object.keys(options.named).forEach(key => { + if (isString(options.named[key])) { + options.named[key] = escapeHtml(options.named[key]); + } + }); + } +} +function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) { + const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context; + const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any + let message = create(); + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'translate'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + !isAlmostSameLocale(locale, targetLocale) && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_TRANSLATE, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + message = + messages[targetLocale] || create(); + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-resolve-start'; + endTag = 'intlify-message-resolve-end'; + mark && mark(startTag); + } + if ((format = resolveValue(message, key)) === null) { + // if null, resolve with object key path + format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any + } + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start && format) { + emitter.emit("message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, { + type: "message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, + key, + message: format, + time: end - start, + groupId: `${type}:${key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message resolve', startTag, endTag); + } + } + if (isString(format) || isMessageAST(format) || isMessageFunction(format)) { + break; + } + if (!isImplicitFallback(targetLocale, locales)) { + const missingRet = handleMissing(context, // eslint-disable-line @typescript-eslint/no-explicit-any + key, targetLocale, missingWarn, type); + if (missingRet !== key) { + format = missingRet; + } + } + from = to; + } + return [format, targetLocale, message]; +} +function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) { + const { messageCompiler, warnHtmlMessage } = context; + if (isMessageFunction(format)) { + const msg = format; + msg.locale = msg.locale || targetLocale; + msg.key = msg.key || key; + return msg; + } + if (messageCompiler == null) { + const msg = (() => format); + msg.locale = targetLocale; + msg.key = key; + return msg; + } + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-compilation-start'; + endTag = 'intlify-message-compilation-end'; + mark && mark(startTag); + } + const msg = messageCompiler(format, getCompileContext(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, onError)); + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, { + type: "message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, + message: format, + time: end - start, + groupId: `${'translate'}:${key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message compilation', startTag, endTag); + } + } + msg.locale = targetLocale; + msg.key = key; + msg.source = format; + return msg; +} +function evaluateMessage(context, msg, msgCtx) { + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-evaluation-start'; + endTag = 'intlify-message-evaluation-end'; + mark && mark(startTag); + } + const messaged = msg(msgCtx); + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, { + type: "message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, + value: messaged, + time: end - start, + groupId: `${'translate'}:${msg.key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message evaluation', startTag, endTag); + } + } + return messaged; +} +/** @internal */ +function parseTranslateArgs(...args) { + const [arg1, arg2, arg3] = args; + const options = create(); + if (!isString(arg1) && + !isNumber(arg1) && + !isMessageFunction(arg1) && + !isMessageAST(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + // prettier-ignore + const key = isNumber(arg1) + ? String(arg1) + : isMessageFunction(arg1) + ? arg1 + : arg1; + if (isNumber(arg2)) { + options.plural = arg2; + } + else if (isString(arg2)) { + options.default = arg2; + } + else if (isPlainObject(arg2) && !isEmptyObject(arg2)) { + options.named = arg2; + } + else if (isArray(arg2)) { + options.list = arg2; + } + if (isNumber(arg3)) { + options.plural = arg3; + } + else if (isString(arg3)) { + options.default = arg3; + } + else if (isPlainObject(arg3)) { + assign(options, arg3); + } + return [key, options]; +} +function getCompileContext(context, locale, key, source, warnHtmlMessage, onError) { + return { + locale, + key, + warnHtmlMessage, + onError: (err) => { + onError && onError(err); + { + const _source = getSourceForCodeFrame(source); + const message = `Message compilation error: ${err.message}`; + const codeFrame = err.location && + _source && + generateCodeFrame(_source, err.location.start.offset, err.location.end.offset); + const emitter = context.__v_emitter; + if (emitter && _source) { + emitter.emit("compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */, { + message: _source, + error: err.message, + start: err.location && err.location.start.offset, + end: err.location && err.location.end.offset, + groupId: `${'translate'}:${key}` + }); + } + console.error(codeFrame ? `${message}\n${codeFrame}` : message); + } + }, + onCacheKey: (source) => generateFormatCacheKey(locale, key, source) + }; +} +function getSourceForCodeFrame(source) { + if (isString(source)) { + return source; + } + else { + if (source.loc && source.loc.source) { + return source.loc.source; + } + } +} +function getMessageContextOptions(context, locale, message, options) { + const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context; + const resolveMessage = (key) => { + let val = resolveValue(message, key); + // fallback to root context + if (val == null && fallbackContext) { + const [, , message] = resolveMessageFormat(fallbackContext, key, locale, fallbackLocale, fallbackWarn, missingWarn); + val = resolveValue(message, key); + } + if (isString(val) || isMessageAST(val)) { + let occurred = false; + const onError = () => { + occurred = true; + }; + const msg = compileMessageFormat(context, key, locale, val, key, onError); + return !occurred + ? msg + : NOOP_MESSAGE_FUNCTION; + } + else if (isMessageFunction(val)) { + return val; + } + else { + // TODO: should be implemented warning message + return NOOP_MESSAGE_FUNCTION; + } + }; + const ctxOptions = { + locale, + modifiers, + pluralRules, + messages: resolveMessage + }; + if (context.processor) { + ctxOptions.processor = context.processor; + } + if (options.list) { + ctxOptions.list = options.list; + } + if (options.named) { + ctxOptions.named = options.named; + } + if (isNumber(options.plural)) { + ctxOptions.pluralIndex = options.plural; + } + return ctxOptions; +} + +const intlDefined = typeof Intl !== 'undefined'; +const Availabilities = { + dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined', + numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined' +}; + +// implementation of `datetime` function +function datetime(context, ...args) { + const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __datetimeFormatters } = context; + if (!Availabilities.dateTimeFormat) { + onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_DATE)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseDateTimeArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!isString(key) || key === '') { + return new Intl.DateTimeFormat(locale, overrides).format(value); + } + // resolve format + let datetimeFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'datetime format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + datetimeFormat = + datetimeFormats[targetLocale] || {}; + format = datetimeFormat[key]; + if (isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!isPlainObject(format) || !isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __datetimeFormatters.get(id); + if (!formatter) { + formatter = new Intl.DateTimeFormat(targetLocale, assign({}, format, overrides)); + __datetimeFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); +} +/** @internal */ +const DATETIME_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'weekday', + 'era', + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second', + 'timeZoneName', + 'formatMatcher', + 'hour12', + 'timeZone', + 'dateStyle', + 'timeStyle', + 'calendar', + 'dayPeriod', + 'numberingSystem', + 'hourCycle', + 'fractionalSecondDigits' +]; +/** @internal */ +function parseDateTimeArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = create(); + let overrides = create(); + let value; + if (isString(arg1)) { + // Only allow ISO strings - other date formats are often supported, + // but may cause different results in different browsers. + const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/); + if (!matches) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + // Some browsers can not parse the iso datetime separated by space, + // this is a compromise solution by replace the 'T'/' ' with 'T' + const dateTime = matches[3] + ? matches[3].trim().startsWith('T') + ? `${matches[1].trim()}${matches[3].trim()}` + : `${matches[1].trim()}T${matches[3].trim()}` + : matches[1].trim(); + value = new Date(dateTime); + try { + // This will fail if the date is not valid + value.toISOString(); + } + catch (e) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + } + else if (isDate(arg1)) { + if (isNaN(arg1.getTime())) { + throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT); + } + value = arg1; + } + else if (isNumber(arg1)) { + value = arg1; + } + else { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + if (isString(arg2)) { + options.key = arg2; + } + else if (isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isPlainObject(arg3)) { + overrides = arg3; + } + if (isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; +} +/** @internal */ +function clearDateTimeFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__datetimeFormatters.has(id)) { + continue; + } + context.__datetimeFormatters.delete(id); + } +} + +// implementation of `number` function +function number(context, ...args) { + const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __numberFormatters } = context; + if (!Availabilities.numberFormat) { + onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_NUMBER)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseNumberArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!isString(key) || key === '') { + return new Intl.NumberFormat(locale, overrides).format(value); + } + // resolve format + let numberFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'number format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + numberFormat = + numberFormats[targetLocale] || {}; + format = numberFormat[key]; + if (isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!isPlainObject(format) || !isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __numberFormatters.get(id); + if (!formatter) { + formatter = new Intl.NumberFormat(targetLocale, assign({}, format, overrides)); + __numberFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); +} +/** @internal */ +const NUMBER_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'style', + 'currency', + 'currencyDisplay', + 'currencySign', + 'useGrouping', + 'minimumIntegerDigits', + 'minimumFractionDigits', + 'maximumFractionDigits', + 'minimumSignificantDigits', + 'maximumSignificantDigits', + 'compactDisplay', + 'notation', + 'signDisplay', + 'unit', + 'unitDisplay', + 'roundingMode', + 'roundingPriority', + 'roundingIncrement', + 'trailingZeroDisplay' +]; +/** @internal */ +function parseNumberArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = create(); + let overrides = create(); + if (!isNumber(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + const value = arg1; + if (isString(arg2)) { + options.key = arg2; + } + else if (isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isPlainObject(arg3)) { + overrides = arg3; + } + if (isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; +} +/** @internal */ +function clearNumberFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__numberFormatters.has(id)) { + continue; + } + context.__numberFormatters.delete(id); + } +} + +export { AST_NODE_PROPS_KEYS, CompileErrorCodes, CoreErrorCodes, CoreWarnCodes, DATETIME_FORMAT_OPTIONS_KEYS, DEFAULT_LOCALE, DEFAULT_MESSAGE_DATA_TYPE, MISSING_RESOLVE_VALUE, NOT_REOSLVED, NUMBER_FORMAT_OPTIONS_KEYS, VERSION, clearCompileCache, clearDateTimeFormat, clearNumberFormat, compile, compileToFunction, createCompileError, createCoreContext, createCoreError, createMessageContext, datetime, fallbackWithLocaleChain, fallbackWithSimple, getAdditionalMeta, getDevToolsHook, getFallbackContext, getLocale, getWarnMessage, handleMissing, initI18nDevTools, isAlmostSameLocale, isImplicitFallback, isMessageAST, isMessageFunction, isTranslateFallbackWarn, isTranslateMissingWarn, number, parse, parseDateTimeArgs, parseNumberArgs, parseTranslateArgs, registerLocaleFallbacker, registerMessageCompiler, registerMessageResolver, resolveLocale, resolveValue, resolveWithKeyValue, setAdditionalMeta, setDevToolsHook, setFallbackContext, translate, translateDevTools, updateFallbackLocale }; diff --git a/node_modules/@intlify/core-base/dist/core-base.esm-browser.prod.js b/node_modules/@intlify/core-base/dist/core-base.esm-browser.prod.js new file mode 100644 index 0000000..b55a1e0 --- /dev/null +++ b/node_modules/@intlify/core-base/dist/core-base.esm-browser.prod.js @@ -0,0 +1,6 @@ +/*! + * core-base v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +function warn(e,t){"undefined"!=typeof console&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}const RE_ARGS=/\{([0-9a-zA-Z]+)\}/g;function format$1(e,...t){return 1===t.length&&isObject(t[0])&&(t=t[0]),t&&t.hasOwnProperty||(t={}),e.replace(RE_ARGS,((e,r)=>t.hasOwnProperty(r)?t[r]:""))}const generateFormatCacheKey=(e,t,r)=>friendlyJSONstringify({l:e,k:t,s:r}),friendlyJSONstringify=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),isNumber=e=>"number"==typeof e&&isFinite(e),isDate=e=>"[object Date]"===toTypeString(e),isRegExp=e=>"[object RegExp]"===toTypeString(e),isEmptyObject=e=>isPlainObject(e)&&0===Object.keys(e).length,assign=Object.assign,_create=Object.create,create=(e=null)=>_create(e);function escapeHtml(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/").replace(/=/g,"=")}function escapeAttributeValue(e){return e.replace(/&(?![a-zA-Z0-9#]{2,6};)/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")}function sanitizeTranslatedHtml(e){e=(e=e.replace(/(\w+)\s*=\s*"([^"]*)"/g,((e,t,r)=>`${t}="${escapeAttributeValue(r)}"`))).replace(/(\w+)\s*=\s*'([^']*)'/g,((e,t,r)=>`${t}='${escapeAttributeValue(r)}'`));/\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi.test(e)&&(e=e.replace(/(\s+)(on)(\w+\s*=)/gi,"$1on$3"));return[/(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi,/(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi].forEach((t=>{e=e.replace(t,"$1javascript:")})),e}const hasOwnProperty=Object.prototype.hasOwnProperty;function hasOwn(e,t){return hasOwnProperty.call(e,t)}const isArray=Array.isArray,isFunction=e=>"function"==typeof e,isString=e=>"string"==typeof e,isBoolean=e=>"boolean"==typeof e,isObject=e=>null!==e&&"object"==typeof e,isPromise=e=>isObject(e)&&isFunction(e.then)&&isFunction(e.catch),objectToString=Object.prototype.toString,toTypeString=e=>objectToString.call(e),isPlainObject=e=>{if(!isObject(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t.constructor===Object},toDisplayString=e=>null==e?"":isArray(e)||isPlainObject(e)&&e.toString===objectToString?JSON.stringify(e,null,2):String(e);function join(e,t=""){return e.reduce(((e,r,n)=>0===n?e+r:e+t+r),"")}function incrementer(e){let t=e;return()=>++t}function createPosition(e,t,r){return{line:e,column:t,offset:r}}function createLocation(e,t,r){const n={start:e,end:t};return null!=r&&(n.source=r),n}const CompileWarnCodes={USE_MODULO_SYNTAX:1,__EXTEND_POINT__:2};function createCompileWarn(e,t,...r){const n={message:String(e),code:e};return t&&(n.location=t),n}const CompileErrorCodes={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16,__EXTEND_POINT__:17};function createCompileError(e,t,r={}){const{domain:n,messages:o,args:s}=r,a=new SyntaxError(String(e));return a.code=e,t&&(a.location=t),a.domain=n,a}function defaultOnError(e){throw e}CompileErrorCodes.EXPECTED_TOKEN,CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER,CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE,CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE,CompileErrorCodes.UNBALANCED_CLOSING_BRACE,CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,CompileErrorCodes.EMPTY_PLACEHOLDER,CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER,CompileErrorCodes.INVALID_LINKED_FORMAT,CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL,CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER,CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY,CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE,CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE;const CHAR_SP=" ",CHAR_CR="\r",CHAR_LF="\n",CHAR_LS=String.fromCharCode(8232),CHAR_PS=String.fromCharCode(8233);function createScanner(e){const t=e;let r=0,n=1,o=1,s=0;const a=e=>t[e]===CHAR_CR&&t[e+1]===CHAR_LF,i=e=>t[e]===CHAR_PS,c=e=>t[e]===CHAR_LS,l=e=>a(e)||(e=>t[e]===CHAR_LF)(e)||i(e)||c(e),u=e=>a(e)||i(e)||c(e)?CHAR_LF:t[e];function E(){return s=0,l(r)&&(n++,o=0),a(r)&&r++,r++,o++,t[r]}return{index:()=>r,line:()=>n,column:()=>o,peekOffset:()=>s,charAt:u,currentChar:()=>u(r),currentPeek:()=>u(r+s),next:E,peek:function(){return a(r+s)&&s++,s++,t[r+s]},reset:function(){r=0,n=1,o=1,s=0},resetPeek:function(e=0){s=e},skipToPeek:function(){const e=r+s;for(;e!==r;)E();s=0}}}const EOF=void 0,DOT=".",LITERAL_DELIMITER="'",ERROR_DOMAIN$1="tokenizer";function createTokenizer(e,t={}){const r=!1!==t.location,n=createScanner(e),o=()=>n.index(),s=()=>createPosition(n.line(),n.column(),n.index()),a=s(),i=o(),c={currentType:14,offset:i,startLoc:a,endLoc:a,lastType:14,lastOffset:i,lastStartLoc:a,lastEndLoc:a,braceNest:0,inLinked:!1,text:""},l=()=>c,{onError:u}=t;function E(e,t,n){e.endLoc=s(),e.currentType=t;const o={type:t};return r&&(o.loc=createLocation(e.startLoc,e.endLoc)),null!=n&&(o.value=n),o}const f=e=>E(e,14);function _(e,t){return e.currentChar()===t?(e.next(),t):(CompileErrorCodes.EXPECTED_TOKEN,s(),"")}function m(e){let t="";for(;e.currentPeek()===CHAR_SP||e.currentPeek()===CHAR_LF;)t+=e.currentPeek(),e.peek();return t}function p(e){const t=m(e);return e.skipToPeek(),t}function C(e){if(e===EOF)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function d(e,t){const{currentType:r}=t;if(2!==r)return!1;m(e);const n=function(e){if(e===EOF)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),n}function T(e){m(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function g(e,t=!0){const r=(t=!1,n="",o=!1)=>{const s=e.currentPeek();return"{"===s?"%"!==n&&t:"@"!==s&&s?"%"===s?(e.peek(),r(t,"%",!0)):"|"===s?!("%"!==n&&!o)||!(n===CHAR_SP||n===CHAR_LF):s===CHAR_SP?(e.peek(),r(!0,CHAR_SP,o)):s!==CHAR_LF||(e.peek(),r(!0,CHAR_LF,o)):"%"===n||t},n=r();return t&&e.resetPeek(),n}function N(e,t){const r=e.currentChar();return r===EOF?EOF:t(r)?(e.next(),r):null}function A(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t}function O(e){return N(e,A)}function S(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t||45===t}function L(e){return N(e,S)}function P(e){const t=e.charCodeAt(0);return t>=48&&t<=57}function h(e){return N(e,P)}function b(e){const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function k(e){return N(e,b)}function I(e){let t="",r="";for(;t=h(e);)r+=t;return r}function R(e){let t="";for(;;){const r=e.currentChar();if("{"===r||"}"===r||"@"===r||"|"===r||!r)break;if("%"===r){if(!g(e))break;t+=r,e.next()}else if(r===CHAR_SP||r===CHAR_LF)if(g(e))t+=r,e.next();else{if(T(e))break;t+=r,e.next()}else t+=r,e.next()}return t}function M(e){return e!==LITERAL_DELIMITER&&e!==CHAR_LF}function y(e){const t=e.currentChar();switch(t){case"\\":case"'":return e.next(),`\\${t}`;case"u":return D(e,t,4);case"U":return D(e,t,6);default:return CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE,s(),""}}function D(e,t,r){_(e,t);let n="";for(let o=0;o=1&&(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER,s()),e.next(),r=E(t,2,"{"),p(e),t.braceNest++,r;case"}":return t.braceNest>0&&2===t.currentType&&(CompileErrorCodes.EMPTY_PLACEHOLDER,s()),e.next(),r=E(t,3,"}"),t.braceNest--,t.braceNest>0&&p(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),r;case"@":return t.braceNest>0&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),r=x(e,t)||f(t),t.braceNest=0,r;default:{let n=!0,o=!0,a=!0;if(T(e))return t.braceNest>0&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),r=E(t,1,v(e)),t.braceNest=0,t.inLinked=!1,r;if(t.braceNest>0&&(5===t.currentType||6===t.currentType||7===t.currentType))return CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s(),t.braceNest=0,w(e,t);if(n=function(e,t){const{currentType:r}=t;if(2!==r)return!1;m(e);const n=C(e.currentPeek());return e.resetPeek(),n}(e,t))return r=E(t,5,function(e){p(e);let t="",r="";for(;t=L(e);)r+=t;return e.currentChar()===EOF&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),r}(e)),p(e),r;if(o=d(e,t))return r=E(t,6,function(e){p(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${I(e)}`):t+=I(e),e.currentChar()===EOF&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),t}(e)),p(e),r;if(a=function(e,t){const{currentType:r}=t;if(2!==r)return!1;m(e);const n=e.currentPeek()===LITERAL_DELIMITER;return e.resetPeek(),n}(e,t))return r=E(t,7,function(e){p(e),_(e,"'");let t="",r="";for(;t=N(e,M);)r+="\\"===t?y(e):t;const n=e.currentChar();return n===CHAR_LF||n===EOF?(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,s(),n===CHAR_LF&&(e.next(),_(e,"'")),r):(_(e,"'"),r)}(e)),p(e),r;if(!n&&!o&&!a)return r=E(t,13,function(e){p(e);let t="",r="";for(;t=N(e,F);)r+=t;return r}(e)),CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER,s(),r.value,p(e),r;break}}return r}function x(e,t){const{currentType:r}=t;let n=null;const o=e.currentChar();switch(8!==r&&9!==r&&12!==r&&10!==r||o!==CHAR_LF&&o!==CHAR_SP||(CompileErrorCodes.INVALID_LINKED_FORMAT,s()),o){case"@":return e.next(),n=E(t,8,"@"),t.inLinked=!0,n;case".":return p(e),e.next(),E(t,9,".");case":":return p(e),e.next(),E(t,10,":");default:return T(e)?(n=E(t,1,v(e)),t.braceNest=0,t.inLinked=!1,n):function(e,t){const{currentType:r}=t;if(8!==r)return!1;m(e);const n="."===e.currentPeek();return e.resetPeek(),n}(e,t)||function(e,t){const{currentType:r}=t;if(8!==r&&12!==r)return!1;m(e);const n=":"===e.currentPeek();return e.resetPeek(),n}(e,t)?(p(e),x(e,t)):function(e,t){const{currentType:r}=t;if(9!==r)return!1;m(e);const n=C(e.currentPeek());return e.resetPeek(),n}(e,t)?(p(e),E(t,12,function(e){let t="",r="";for(;t=O(e);)r+=t;return r}(e))):function(e,t){const{currentType:r}=t;if(10!==r)return!1;const n=()=>{const t=e.currentPeek();return"{"===t?C(e.peek()):!("@"===t||"%"===t||"|"===t||":"===t||"."===t||t===CHAR_SP||!t)&&(t===CHAR_LF?(e.peek(),n()):g(e,!1))},o=n();return e.resetPeek(),o}(e,t)?(p(e),"{"===o?U(e,t)||n:E(t,11,function(e){const t=r=>{const n=e.currentChar();return"{"!==n&&"%"!==n&&"@"!==n&&"|"!==n&&"("!==n&&")"!==n&&n?n===CHAR_SP?r:(r+=n,e.next(),t(r)):r};return t("")}(e))):(8===r&&(CompileErrorCodes.INVALID_LINKED_FORMAT,s()),t.braceNest=0,t.inLinked=!1,w(e,t))}}function w(e,t){let r={type:14};if(t.braceNest>0)return U(e,t)||f(t);if(t.inLinked)return x(e,t)||f(t);switch(e.currentChar()){case"{":return U(e,t)||f(t);case"}":return CompileErrorCodes.UNBALANCED_CLOSING_BRACE,s(),e.next(),E(t,3,"}");case"@":return x(e,t)||f(t);default:{if(T(e))return r=E(t,1,v(e)),t.braceNest=0,t.inLinked=!1,r;const{isModulo:n,hasSpace:o}=function(e){const t=m(e),r="%"===e.currentPeek()&&"{"===e.peek();return e.resetPeek(),{isModulo:r,hasSpace:t.length>0}}(e);if(n)return o?E(t,0,R(e)):E(t,4,function(e){p(e);const t=e.currentChar();return"%"!==t&&(CompileErrorCodes.EXPECTED_TOKEN,s()),e.next(),"%"}(e));if(g(e))return E(t,0,R(e));break}}return r}return{nextToken:function(){const{currentType:e,offset:t,startLoc:r,endLoc:a}=c;return c.lastType=e,c.lastOffset=t,c.lastStartLoc=r,c.lastEndLoc=a,c.offset=o(),c.startLoc=s(),n.currentChar()===EOF?E(c,14):w(n,c)},currentOffset:o,currentPosition:s,context:l}}const ERROR_DOMAIN="parser",KNOWN_ESCAPES=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function fromEscapeSequence(e,t,r){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const e=parseInt(t||r,16);return e<=55295||e>=57344?String.fromCodePoint(e):"�"}}}function createParser(e={}){const t=!1!==e.location,{onError:r,onWarn:n}=e;function o(e,r,n){const o={type:e};return t&&(o.start=r,o.end=r,o.loc={start:n,end:n}),o}function s(e,r,n,o){o&&(e.type=o),t&&(e.end=r,e.loc&&(e.loc.end=n))}function a(e,t){const r=e.context(),n=o(3,r.offset,r.startLoc);return n.value=t,s(n,e.currentOffset(),e.currentPosition()),n}function i(e,t){const r=e.context(),{lastOffset:n,lastStartLoc:a}=r,i=o(5,n,a);return i.index=parseInt(t,10),e.nextToken(),s(i,e.currentOffset(),e.currentPosition()),i}function c(e,t,r){const n=e.context(),{lastOffset:a,lastStartLoc:i}=n,c=o(4,a,i);return c.key=t,!0===r&&(c.modulo=!0),e.nextToken(),s(c,e.currentOffset(),e.currentPosition()),c}function l(e,t){const r=e.context(),{lastOffset:n,lastStartLoc:a}=r,i=o(9,n,a);return i.value=t.replace(KNOWN_ESCAPES,fromEscapeSequence),e.nextToken(),s(i,e.currentOffset(),e.currentPosition()),i}function u(e){const t=e.context(),r=o(6,t.offset,t.startLoc);let n=e.nextToken();if(9===n.type){const t=function(e){const t=e.nextToken(),r=e.context(),{lastOffset:n,lastStartLoc:a}=r,i=o(8,n,a);return 12!==t.type?(CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER,r.lastStartLoc,i.value="",s(i,n,a),{nextConsumeToken:t,node:i}):(null==t.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,r.lastStartLoc,getTokenCaption(t)),i.value=t.value||"",s(i,e.currentOffset(),e.currentPosition()),{node:i})}(e);r.modifier=t.node,n=t.nextConsumeToken||e.nextToken()}switch(10!==n.type&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(n)),n=e.nextToken(),2===n.type&&(n=e.nextToken()),n.type){case 11:null==n.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(n)),r.key=function(e,t){const r=e.context(),n=o(7,r.offset,r.startLoc);return n.value=t,s(n,e.currentOffset(),e.currentPosition()),n}(e,n.value||"");break;case 5:null==n.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(n)),r.key=c(e,n.value||"");break;case 6:null==n.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(n)),r.key=i(e,n.value||"");break;case 7:null==n.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(n)),r.key=l(e,n.value||"");break;default:{CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const a=e.context(),i=o(7,a.offset,a.startLoc);return i.value="",s(i,a.offset,a.startLoc),r.key=i,s(r,a.offset,a.startLoc),{nextConsumeToken:n,node:r}}}return s(r,e.currentOffset(),e.currentPosition()),{node:r}}function E(e){const t=e.context(),r=o(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);r.items=[];let n=null,E=null;do{const o=n||e.nextToken();switch(n=null,o.type){case 0:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),r.items.push(a(e,o.value||""));break;case 6:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),r.items.push(i(e,o.value||""));break;case 4:E=!0;break;case 5:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),r.items.push(c(e,o.value||"",!!E)),E&&(CompileWarnCodes.USE_MODULO_SYNTAX,t.lastStartLoc,getTokenCaption(o),E=null);break;case 7:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),r.items.push(l(e,o.value||""));break;case 8:{const t=u(e);r.items.push(t.node),n=t.nextConsumeToken||null;break}}}while(14!==t.currentType&&1!==t.currentType);return s(r,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),r}function f(e){const t=e.context(),{offset:r,startLoc:n}=t,a=E(e);return 14===t.currentType?a:function(e,t,r,n){const a=e.context();let i=0===n.items.length;const c=o(1,t,r);c.cases=[],c.cases.push(n);do{const t=E(e);i||(i=0===t.items.length),c.cases.push(t)}while(14!==a.currentType);return i&&CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL,s(c,e.currentOffset(),e.currentPosition()),c}(e,r,n,a)}return{parse:function(r){const n=createTokenizer(r,assign({},e)),a=n.context(),i=o(0,a.offset,a.startLoc);return t&&i.loc&&(i.loc.source=r),i.body=f(n),e.onCacheKey&&(i.cacheKey=e.onCacheKey(r)),14!==a.currentType&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,a.lastStartLoc,r[a.offset]),s(i,n.currentOffset(),n.currentPosition()),i}}}function getTokenCaption(e){if(14===e.type)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function createTransformer(e,t={}){const r={ast:e,helpers:new Set};return{context:()=>r,helper:e=>(r.helpers.add(e),e)}}function traverseNodes(e,t){for(let r=0;roptimizeMessageNode(e))),e}function optimizeMessageNode(e){if(1===e.items.length){const t=e.items[0];3!==t.type&&9!==t.type||(e.static=t.value,delete t.value)}else{const t=[];for(let r=0;ri,push:c,indent:function(e=!0){const t=++i.indentLevel;e&&l(t)},deindent:function(e=!0){const t=--i.indentLevel;e&&l(t)},newline:function(){l(i.indentLevel)},helper:e=>`_${e}`,needIndent:()=>i.needIndent}}function generateLinkedNode(e,t){const{helper:r}=e;e.push(`${r("linked")}(`),generateNode(e,t.key),t.modifier?(e.push(", "),generateNode(e,t.modifier),e.push(", _type")):e.push(", undefined, _type"),e.push(")")}function generateMessageNode(e,t){const{helper:r,needIndent:n}=e;e.push(`${r("normalize")}([`),e.indent(n());const o=t.items.length;for(let s=0;s1){e.push(`${r("plural")}([`),e.indent(n());const o=t.cases.length;for(let r=0;r{const r=isString(t.mode)?t.mode:"normal",n=isString(t.filename)?t.filename:"message.intl",o=!!t.sourceMap,s=null!=t.breakLineCode?t.breakLineCode:"arrow"===r?";":"\n",a=t.needIndent?t.needIndent:"arrow"!==r,i=e.helpers||[],c=createCodeGenerator(e,{mode:r,filename:n,sourceMap:o,breakLineCode:s,needIndent:a});c.push("normal"===r?"function __msg__ (ctx) {":"(ctx) => {"),c.indent(a),i.length>0&&(c.push(`const { ${join(i.map((e=>`${e}: _${e}`)),", ")} } = ctx`),c.newline()),c.push("return "),generateNode(c,e),c.deindent(a),c.push("}"),delete e.helpers;const{code:l,map:u}=c.context();return{ast:e,code:l,map:u?u.toJSON():void 0}};function baseCompile$1(e,t={}){const r=assign({},t),n=!!r.jit,o=!!r.minify,s=null==r.optimize||r.optimize,a=createParser(r).parse(e);return n?(s&&optimize(a),o&&minify(a),{ast:a,code:""}):(transform(a,r),generate(a,r))}function isMessageAST(e){return isObject(e)&&0===resolveType(e)&&(hasOwn(e,"b")||hasOwn(e,"body"))}const PROPS_BODY=["b","body"];function resolveBody(e){return resolveProps(e,PROPS_BODY)}const PROPS_CASES=["c","cases"];function resolveCases(e){return resolveProps(e,PROPS_CASES,[])}const PROPS_STATIC=["s","static"];function resolveStatic(e){return resolveProps(e,PROPS_STATIC)}const PROPS_ITEMS=["i","items"];function resolveItems(e){return resolveProps(e,PROPS_ITEMS,[])}const PROPS_TYPE=["t","type"];function resolveType(e){return resolveProps(e,PROPS_TYPE)}const PROPS_VALUE=["v","value"];function resolveValue$1(e,t){const r=resolveProps(e,PROPS_VALUE);if(null!=r)return r;throw createUnhandleNodeError(t)}const PROPS_MODIFIER=["m","modifier"];function resolveLinkedModifier(e){return resolveProps(e,PROPS_MODIFIER)}const PROPS_KEY=["k","key"];function resolveLinkedKey(e){const t=resolveProps(e,PROPS_KEY);if(t)return t;throw createUnhandleNodeError(6)}function resolveProps(e,t,r){for(let n=0;n{void 0===n?n=o:n+=o},f[1]=()=>{void 0!==n&&(t.push(n),n=void 0)},f[2]=()=>{f[0](),E++},f[3]=()=>{if(E>0)E--,u=4,f[0]();else{if(E=0,void 0===n)return!1;if(n=formatSubPath(n),!1===n)return!1;f[1]()}};null!==u;)if(l++,r=e[l],"\\"!==r||!_()){if(s=getPathCharType(r),c=pathStateMachine[u],a=c[s]||c.l||8,8===a)return;if(u=a[0],void 0!==a[1]&&(i=f[a[1]],i&&(o=r,!1===i())))return;if(7===u)return t}}const cache=new Map;function resolveWithKeyValue(e,t){return isObject(e)?e[t]:null}function resolveValue(e,t){if(!isObject(e))return null;let r=cache.get(t);if(r||(r=parse(t),r&&cache.set(t,r)),!r)return null;const n=r.length;let o=e,s=0;for(;se,DEFAULT_MESSAGE=e=>"",DEFAULT_MESSAGE_DATA_TYPE="text",DEFAULT_NORMALIZE=e=>0===e.length?"":join(e),DEFAULT_INTERPOLATE=toDisplayString;function pluralDefault(e,t){return e=Math.abs(e),2===t?e?e>1?1:0:1:e?Math.min(e,2):0}function getPluralIndex(e){const t=isNumber(e.pluralIndex)?e.pluralIndex:-1;return e.named&&(isNumber(e.named.count)||isNumber(e.named.n))?isNumber(e.named.count)?e.named.count:isNumber(e.named.n)?e.named.n:t:t}function normalizeNamed(e,t){t.count||(t.count=e),t.n||(t.n=e)}function createMessageContext(e={}){const t=e.locale,r=getPluralIndex(e),n=isObject(e.pluralRules)&&isString(t)&&isFunction(e.pluralRules[t])?e.pluralRules[t]:pluralDefault,o=isObject(e.pluralRules)&&isString(t)&&isFunction(e.pluralRules[t])?pluralDefault:void 0,s=e.list||[],a=e.named||create();isNumber(e.pluralIndex)&&normalizeNamed(r,a);function i(t){const r=isFunction(e.messages)?e.messages(t):!!isObject(e.messages)&&e.messages[t];return r||(e.parent?e.parent.message(t):DEFAULT_MESSAGE)}const c=isPlainObject(e.processor)&&isFunction(e.processor.normalize)?e.processor.normalize:DEFAULT_NORMALIZE,l=isPlainObject(e.processor)&&isFunction(e.processor.interpolate)?e.processor.interpolate:DEFAULT_INTERPOLATE,u={list:e=>s[e],named:e=>a[e],plural:e=>e[n(r,e.length,o)],linked:(t,...r)=>{const[n,o]=r;let s="text",a="";1===r.length?isObject(n)?(a=n.modifier||a,s=n.type||s):isString(n)&&(a=n||a):2===r.length&&(isString(n)&&(a=n||a),isString(o)&&(s=o||s));const c=i(t)(u),l="vnode"===s&&isArray(c)&&a?c[0]:c;return a?(E=a,e.modifiers?e.modifiers[E]:DEFAULT_MODIFIER)(l,s):l;var E},message:i,type:isPlainObject(e.processor)&&isString(e.processor.type)?e.processor.type:DEFAULT_MESSAGE_DATA_TYPE,interpolate:l,normalize:c,values:assign(create(),s,a)};return u}let devtools=null;function setDevToolsHook(e){devtools=e}function getDevToolsHook(){return devtools}function initI18nDevTools(e,t,r){devtools&&devtools.emit("i18n:init",{timestamp:Date.now(),i18n:e,version:t,meta:r})}const translateDevTools=createDevToolsHook("function:translate");function createDevToolsHook(e){return t=>devtools&&devtools.emit(e,t)}const code$1=CompileWarnCodes.__EXTEND_POINT__,inc$1=incrementer(code$1),CoreWarnCodes={NOT_FOUND_KEY:code$1,FALLBACK_TO_TRANSLATE:inc$1(),CANNOT_FORMAT_NUMBER:inc$1(),FALLBACK_TO_NUMBER_FORMAT:inc$1(),CANNOT_FORMAT_DATE:inc$1(),FALLBACK_TO_DATE_FORMAT:inc$1(),EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER:inc$1(),__EXTEND_POINT__:inc$1()},warnMessages={[CoreWarnCodes.NOT_FOUND_KEY]:"Not found '{key}' key in '{locale}' locale messages.",[CoreWarnCodes.FALLBACK_TO_TRANSLATE]:"Fall back to translate '{key}' key with '{target}' locale.",[CoreWarnCodes.CANNOT_FORMAT_NUMBER]:"Cannot format a number value due to not supported Intl.NumberFormat.",[CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]:"Fall back to number format '{key}' key with '{target}' locale.",[CoreWarnCodes.CANNOT_FORMAT_DATE]:"Cannot format a date value due to not supported Intl.DateTimeFormat.",[CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]:"Fall back to datetime format '{key}' key with '{target}' locale.",[CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]:"This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future."};function getWarnMessage(e,...t){return format$1(warnMessages[e],...t)}const code=CompileErrorCodes.__EXTEND_POINT__,inc=incrementer(code),CoreErrorCodes={INVALID_ARGUMENT:code,INVALID_DATE_ARGUMENT:inc(),INVALID_ISO_DATE_ARGUMENT:inc(),NOT_SUPPORT_NON_STRING_MESSAGE:inc(),NOT_SUPPORT_LOCALE_PROMISE_VALUE:inc(),NOT_SUPPORT_LOCALE_ASYNC_FUNCTION:inc(),NOT_SUPPORT_LOCALE_TYPE:inc(),__EXTEND_POINT__:inc()};function createCoreError(e){return createCompileError(e,null,void 0)}function getLocale(e,t){return null!=t.locale?resolveLocale(t.locale):resolveLocale(e.locale)}let _resolveLocale;function resolveLocale(e){if(isString(e))return e;if(isFunction(e)){if(e.resolvedOnce&&null!=_resolveLocale)return _resolveLocale;if("Function"===e.constructor.name){const t=e();if(isPromise(t))throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE);return _resolveLocale=t}throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION)}throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE)}function fallbackWithSimple(e,t,r){return[...new Set([r,...isArray(t)?t:isObject(t)?Object.keys(t):isString(t)?[t]:[r]])]}function fallbackWithLocaleChain(e,t,r){const n=isString(r)?r:DEFAULT_LOCALE,o=e;o.__localeChainCache||(o.__localeChainCache=new Map);let s=o.__localeChainCache.get(n);if(!s){s=[];let e=[r];for(;isArray(e);)e=appendBlockToChain(s,e,t);const a=isArray(t)||!isPlainObject(t)?t:t.default?t.default:null;e=isString(a)?[a]:a,isArray(e)&&appendBlockToChain(s,e,!1),o.__localeChainCache.set(n,s)}return s}function appendBlockToChain(e,t,r){let n=!0;for(let o=0;o`${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;function getDefaultLinkedModifiers(){return{upper:(e,t)=>"text"===t&&isString(e)?e.toUpperCase():"vnode"===t&&isObject(e)&&"__v_isVNode"in e?e.children.toUpperCase():e,lower:(e,t)=>"text"===t&&isString(e)?e.toLowerCase():"vnode"===t&&isObject(e)&&"__v_isVNode"in e?e.children.toLowerCase():e,capitalize:(e,t)=>"text"===t&&isString(e)?capitalize(e):"vnode"===t&&isObject(e)&&"__v_isVNode"in e?capitalize(e.children):e}}let _compiler,_resolver,_fallbacker;function registerMessageCompiler(e){_compiler=e}function registerMessageResolver(e){_resolver=e}function registerLocaleFallbacker(e){_fallbacker=e}let _additionalMeta=null;const setAdditionalMeta=e=>{_additionalMeta=e},getAdditionalMeta=()=>_additionalMeta;let _fallbackContext=null;const setFallbackContext=e=>{_fallbackContext=e},getFallbackContext=()=>_fallbackContext;let _cid=0;function createCoreContext(e={}){const t=isFunction(e.onWarn)?e.onWarn:warn,r=isString(e.version)?e.version:VERSION,n=isString(e.locale)||isFunction(e.locale)?e.locale:DEFAULT_LOCALE,o=isFunction(n)?DEFAULT_LOCALE:n,s=isArray(e.fallbackLocale)||isPlainObject(e.fallbackLocale)||isString(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:o,a=isPlainObject(e.messages)?e.messages:createResources(o),i=isPlainObject(e.datetimeFormats)?e.datetimeFormats:createResources(o),c=isPlainObject(e.numberFormats)?e.numberFormats:createResources(o),l=assign(create(),e.modifiers,getDefaultLinkedModifiers()),u=e.pluralRules||create(),E=isFunction(e.missing)?e.missing:null,f=!isBoolean(e.missingWarn)&&!isRegExp(e.missingWarn)||e.missingWarn,_=!isBoolean(e.fallbackWarn)&&!isRegExp(e.fallbackWarn)||e.fallbackWarn,m=!!e.fallbackFormat,p=!!e.unresolving,C=isFunction(e.postTranslation)?e.postTranslation:null,d=isPlainObject(e.processor)?e.processor:null,T=!isBoolean(e.warnHtmlMessage)||e.warnHtmlMessage,g=!!e.escapeParameter,N=isFunction(e.messageCompiler)?e.messageCompiler:_compiler,A=isFunction(e.messageResolver)?e.messageResolver:_resolver||resolveWithKeyValue,O=isFunction(e.localeFallbacker)?e.localeFallbacker:_fallbacker||fallbackWithSimple,S=isObject(e.fallbackContext)?e.fallbackContext:void 0,L=e,P=isObject(L.__datetimeFormatters)?L.__datetimeFormatters:new Map,h=isObject(L.__numberFormatters)?L.__numberFormatters:new Map,b=isObject(L.__meta)?L.__meta:{};_cid++;const k={version:r,cid:_cid,locale:n,fallbackLocale:s,messages:a,modifiers:l,pluralRules:u,missing:E,missingWarn:f,fallbackWarn:_,fallbackFormat:m,unresolving:p,postTranslation:C,processor:d,warnHtmlMessage:T,escapeParameter:g,messageCompiler:N,messageResolver:A,localeFallbacker:O,fallbackContext:S,onWarn:t,__meta:b};return k.datetimeFormats=i,k.numberFormats=c,k.__datetimeFormatters=P,k.__numberFormatters=h,k}const createResources=e=>({[e]:create()});function isTranslateFallbackWarn(e,t){return e instanceof RegExp?e.test(t):e}function isTranslateMissingWarn(e,t){return e instanceof RegExp?e.test(t):e}function handleMissing(e,t,r,n,o){const{missing:s,onWarn:a}=e;if(null!==s){const n=s(e,r,t,o);return isString(n)?n:t}return t}function updateFallbackLocale(e,t,r){e.__localeChainCache=new Map,e.localeFallbacker(e,r,t)}function isAlmostSameLocale(e,t){return e!==t&&e.split("-")[0]===t.split("-")[0]}function isImplicitFallback(e,t){const r=t.indexOf(e);if(-1===r)return!1;for(let n=r+1;nformatParts(t,e)}function formatParts(e,t){const r=resolveBody(t);if(null==r)throw createUnhandleNodeError(0);if(1===resolveType(r)){const t=resolveCases(r);return e.plural(t.reduce(((t,r)=>[...t,formatMessageParts(e,r)]),[]))}return formatMessageParts(e,r)}function formatMessageParts(e,t){const r=resolveStatic(t);if(null!=r)return"text"===e.type?r:e.normalize([r]);{const r=resolveItems(t).reduce(((t,r)=>[...t,formatMessagePart(e,r)]),[]);return e.normalize(r)}}function formatMessagePart(e,t){const r=resolveType(t);switch(r){case 3:case 9:case 7:case 8:return resolveValue$1(t,r);case 4:{const n=t;if(hasOwn(n,"k")&&n.k)return e.interpolate(e.named(n.k));if(hasOwn(n,"key")&&n.key)return e.interpolate(e.named(n.key));throw createUnhandleNodeError(r)}case 5:{const n=t;if(hasOwn(n,"i")&&isNumber(n.i))return e.interpolate(e.list(n.i));if(hasOwn(n,"index")&&isNumber(n.index))return e.interpolate(e.list(n.index));throw createUnhandleNodeError(r)}case 6:{const r=t,n=resolveLinkedModifier(r),o=resolveLinkedKey(r);return e.linked(formatMessagePart(e,o),n?formatMessagePart(e,n):void 0,e.type)}default:throw new Error(`unhandled node on format message part: ${r}`)}}const defaultOnCacheKey=e=>e;let compileCache=create();function clearCompileCache(){compileCache=create()}function baseCompile(e,t={}){let r=!1;const n=t.onError||defaultOnError;return t.onError=e=>{r=!0,n(e)},{...baseCompile$1(e,t),detectError:r}}const compileToFunction=(e,t)=>{if(!isString(e))throw Error(CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE);{!isBoolean(t.warnHtmlMessage)||t.warnHtmlMessage;const r=(t.onCacheKey||defaultOnCacheKey)(e),n=compileCache[r];if(n)return n;const{code:o,detectError:s}=baseCompile(e,t),a=new Function(`return ${o}`)();return s?a:compileCache[r]=a}};function compile(e,t){if(isString(e)){!isBoolean(t.warnHtmlMessage)||t.warnHtmlMessage;const r=(t.onCacheKey||defaultOnCacheKey)(e),n=compileCache[r];if(n)return n;const{ast:o,detectError:s}=baseCompile(e,{...t,location:!1,jit:!0}),a=format(o);return s?a:compileCache[r]=a}{const t=e.cacheKey;if(t){const r=compileCache[t];return r||(compileCache[t]=format(e))}return format(e)}}const NOOP_MESSAGE_FUNCTION=()=>"",isMessageFunction=e=>isFunction(e);function translate(e,...t){const{fallbackFormat:r,postTranslation:n,unresolving:o,messageCompiler:s,fallbackLocale:a,messages:i}=e,[c,l]=parseTranslateArgs(...t),u=isBoolean(l.missingWarn)?l.missingWarn:e.missingWarn,E=isBoolean(l.fallbackWarn)?l.fallbackWarn:e.fallbackWarn,f=isBoolean(l.escapeParameter)?l.escapeParameter:e.escapeParameter,_=!!l.resolvedMessage,m=isString(l.default)||isBoolean(l.default)?isBoolean(l.default)?s?c:()=>c:l.default:r?s?c:()=>c:"",p=r||""!==m,C=getLocale(e,l);f&&escapeParams(l);let[d,T,g]=_?[c,C,i[C]||create()]:resolveMessageFormat(e,c,C,a,E,u),N=d,A=c;if(_||isString(N)||isMessageAST(N)||isMessageFunction(N)||p&&(N=m,A=N),!(_||(isString(N)||isMessageAST(N)||isMessageFunction(N))&&isString(T)))return o?-1:c;let O=!1;const S=isMessageFunction(N)?N:compileMessageFormat(e,c,T,N,A,(()=>{O=!0}));if(O)return N;const L=evaluateMessage(e,S,createMessageContext(getMessageContextOptions(e,T,g,l)));let P=n?n(L,c):L;return f&&isString(P)&&(P=sanitizeTranslatedHtml(P)),P}function escapeParams(e){isArray(e.list)?e.list=e.list.map((e=>isString(e)?escapeHtml(e):e)):isObject(e.named)&&Object.keys(e.named).forEach((t=>{isString(e.named[t])&&(e.named[t]=escapeHtml(e.named[t]))}))}function resolveMessageFormat(e,t,r,n,o,s){const{messages:a,onWarn:i,messageResolver:c,localeFallbacker:l}=e,u=l(e,n,r);let E,f=create(),_=null;for(let m=0;mn;return e.locale=r,e.key=t,e}const c=a(n,getCompileContext(e,r,o,n,i,s));return c.locale=r,c.key=t,c.source=n,c}function evaluateMessage(e,t,r){return t(r)}function parseTranslateArgs(...e){const[t,r,n]=e,o=create();if(!(isString(t)||isNumber(t)||isMessageFunction(t)||isMessageAST(t)))throw Error(CoreErrorCodes.INVALID_ARGUMENT);const s=isNumber(t)?String(t):(isMessageFunction(t),t);return isNumber(r)?o.plural=r:isString(r)?o.default=r:isPlainObject(r)&&!isEmptyObject(r)?o.named=r:isArray(r)&&(o.list=r),isNumber(n)?o.plural=n:isString(n)?o.default=n:isPlainObject(n)&&assign(o,n),[s,o]}function getCompileContext(e,t,r,n,o,s){return{locale:t,key:r,warnHtmlMessage:o,onError:e=>{throw s&&s(e),e},onCacheKey:e=>generateFormatCacheKey(t,r,e)}}function getMessageContextOptions(e,t,r,n){const{modifiers:o,pluralRules:s,messageResolver:a,fallbackLocale:i,fallbackWarn:c,missingWarn:l,fallbackContext:u}=e,E={locale:t,modifiers:o,pluralRules:s,messages:n=>{let o=a(r,n);if(null==o&&u){const[,,e]=resolveMessageFormat(u,n,t,i,c,l);o=a(e,n)}if(isString(o)||isMessageAST(o)){let r=!1;const s=compileMessageFormat(e,n,t,o,n,(()=>{r=!0}));return r?NOOP_MESSAGE_FUNCTION:s}return isMessageFunction(o)?o:NOOP_MESSAGE_FUNCTION}};return e.processor&&(E.processor=e.processor),n.list&&(E.list=n.list),n.named&&(E.named=n.named),isNumber(n.plural)&&(E.pluralIndex=n.plural),E}function datetime(e,...t){const{datetimeFormats:r,unresolving:n,fallbackLocale:o,onWarn:s,localeFallbacker:a}=e,{__datetimeFormatters:i}=e,[c,l,u,E]=parseDateTimeArgs(...t),f=isBoolean(u.missingWarn)?u.missingWarn:e.missingWarn;isBoolean(u.fallbackWarn)?u.fallbackWarn:e.fallbackWarn;const _=!!u.part,m=getLocale(e,u),p=a(e,o,m);if(!isString(c)||""===c)return new Intl.DateTimeFormat(m,E).format(l);let C,d={},T=null;for(let A=0;A{DATETIME_FORMAT_OPTIONS_KEYS.includes(e)?i[e]=r[e]:s[e]=r[e]})),isString(n)?s.locale=n:isPlainObject(n)&&(i=n),isPlainObject(o)&&(i=o),[s.key||"",a,s,i]}function clearDateTimeFormat(e,t,r){const n=e;for(const o in r){const e=`${t}__${o}`;n.__datetimeFormatters.has(e)&&n.__datetimeFormatters.delete(e)}}function number(e,...t){const{numberFormats:r,unresolving:n,fallbackLocale:o,onWarn:s,localeFallbacker:a}=e,{__numberFormatters:i}=e,[c,l,u,E]=parseNumberArgs(...t),f=isBoolean(u.missingWarn)?u.missingWarn:e.missingWarn;isBoolean(u.fallbackWarn)?u.fallbackWarn:e.fallbackWarn;const _=!!u.part,m=getLocale(e,u),p=a(e,o,m);if(!isString(c)||""===c)return new Intl.NumberFormat(m,E).format(l);let C,d={},T=null;for(let A=0;A{NUMBER_FORMAT_OPTIONS_KEYS.includes(e)?a[e]=r[e]:s[e]=r[e]})),isString(n)?s.locale=n:isPlainObject(n)&&(a=n),isPlainObject(o)&&(a=o),[s.key||"",i,s,a]}function clearNumberFormat(e,t,r){const n=e;for(const o in r){const e=`${t}__${o}`;n.__numberFormatters.has(e)&&n.__numberFormatters.delete(e)}}export{AST_NODE_PROPS_KEYS,CompileErrorCodes,CoreErrorCodes,CoreWarnCodes,DATETIME_FORMAT_OPTIONS_KEYS,DEFAULT_LOCALE,DEFAULT_MESSAGE_DATA_TYPE,MISSING_RESOLVE_VALUE,NOT_REOSLVED,NUMBER_FORMAT_OPTIONS_KEYS,VERSION,clearCompileCache,clearDateTimeFormat,clearNumberFormat,compile,compileToFunction,createCompileError,createCoreContext,createCoreError,createMessageContext,datetime,fallbackWithLocaleChain,fallbackWithSimple,getAdditionalMeta,getDevToolsHook,getFallbackContext,getLocale,getWarnMessage,handleMissing,initI18nDevTools,isAlmostSameLocale,isImplicitFallback,isMessageAST,isMessageFunction,isTranslateFallbackWarn,isTranslateMissingWarn,number,parse,parseDateTimeArgs,parseNumberArgs,parseTranslateArgs,registerLocaleFallbacker,registerMessageCompiler,registerMessageResolver,resolveLocale,resolveValue,resolveWithKeyValue,setAdditionalMeta,setDevToolsHook,setFallbackContext,translate,translateDevTools,updateFallbackLocale}; diff --git a/node_modules/@intlify/core-base/dist/core-base.esm-bundler.js b/node_modules/@intlify/core-base/dist/core-base.esm-bundler.js new file mode 100644 index 0000000..8676a61 --- /dev/null +++ b/node_modules/@intlify/core-base/dist/core-base.esm-bundler.js @@ -0,0 +1 @@ +export * from '../dist/core-base.mjs' \ No newline at end of file diff --git a/node_modules/@intlify/core-base/dist/core-base.global.js b/node_modules/@intlify/core-base/dist/core-base.global.js new file mode 100644 index 0000000..93f9ac8 --- /dev/null +++ b/node_modules/@intlify/core-base/dist/core-base.global.js @@ -0,0 +1,3730 @@ +/*! + * core-base v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +var IntlifyCoreBase = (function (exports) { + 'use strict'; + + function warn(msg, err) { + if (typeof console !== 'undefined') { + console.warn(`[intlify] ` + msg); + /* istanbul ignore if */ + if (err) { + console.warn(err.stack); + } + } + } + + /** + * Original Utilities + * written by kazuya kawaguchi + */ + const inBrowser = typeof window !== 'undefined'; + let mark; + let measure; + { + const perf = inBrowser && window.performance; + if (perf && + perf.mark && + perf.measure && + perf.clearMarks && + // @ts-ignore browser compat + perf.clearMeasures) { + mark = (tag) => { + perf.mark(tag); + }; + measure = (name, startTag, endTag) => { + perf.measure(name, startTag, endTag); + perf.clearMarks(startTag); + perf.clearMarks(endTag); + }; + } + } + const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g; + /* eslint-disable */ + function format$1(message, ...args) { + if (args.length === 1 && isObject(args[0])) { + args = args[0]; + } + if (!args || !args.hasOwnProperty) { + args = {}; + } + return message.replace(RE_ARGS, (match, identifier) => { + return args.hasOwnProperty(identifier) ? args[identifier] : ''; + }); + } + const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({ l: locale, k: key, s: source }); + const friendlyJSONstringify = (json) => JSON.stringify(json) + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029') + .replace(/\u0027/g, '\\u0027'); + const isNumber = (val) => typeof val === 'number' && isFinite(val); + const isDate = (val) => toTypeString(val) === '[object Date]'; + const isRegExp = (val) => toTypeString(val) === '[object RegExp]'; + const isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0; + const assign = Object.assign; + const _create = Object.create; + const create = (obj = null) => _create(obj); + function escapeHtml(rawText) { + return rawText + .replace(/&/g, '&') // escape `&` first to avoid double escaping + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/\//g, '/') // escape `/` to prevent closing tags or JavaScript URLs + .replace(/=/g, '='); // escape `=` to prevent attribute injection + } + function escapeAttributeValue(value) { + return value + .replace(/&(?![a-zA-Z0-9#]{2,6};)/g, '&') // escape unescaped `&` + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(//g, '>'); + } + function sanitizeTranslatedHtml(html) { + // Escape dangerous characters in attribute values + // Process attributes with double quotes + html = html.replace(/(\w+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${escapeAttributeValue(attrValue)}"`); + // Process attributes with single quotes + html = html.replace(/(\w+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${escapeAttributeValue(attrValue)}'`); + // Detect and neutralize event handler attributes + const eventHandlerPattern = /\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi; + if (eventHandlerPattern.test(html)) { + { + warn('Potentially dangerous event handlers detected in translation. ' + + 'Consider removing onclick, onerror, etc. from your translation messages.'); + } + // Neutralize event handler attributes by escaping 'on' + html = html.replace(/(\s+)(on)(\w+\s*=)/gi, '$1on$3'); + } + // Disable javascript: URLs in various contexts + const javascriptUrlPattern = [ + // In href, src, action, formaction attributes + /(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi, + // In style attributes within url() + /(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi + ]; + javascriptUrlPattern.forEach(pattern => { + html = html.replace(pattern, '$1javascript:'); + }); + return html; + } + const hasOwnProperty = Object.prototype.hasOwnProperty; + function hasOwn(obj, key) { + return hasOwnProperty.call(obj, key); + } + /* eslint-enable */ + /** + * Useful Utilities By Evan you + * Modified by kazuya kawaguchi + * MIT License + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts + */ + const isArray = Array.isArray; + const isFunction = (val) => typeof val === 'function'; + const isString = (val) => typeof val === 'string'; + const isBoolean = (val) => typeof val === 'boolean'; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const isObject = (val) => val !== null && typeof val === 'object'; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const isPromise = (val) => { + return isObject(val) && isFunction(val.then) && isFunction(val.catch); + }; + const objectToString = Object.prototype.toString; + const toTypeString = (value) => objectToString.call(value); + const isPlainObject = (val) => { + if (!isObject(val)) + return false; + const proto = Object.getPrototypeOf(val); + return proto === null || proto.constructor === Object; + }; + // for converting list and named values to displayed strings. + const toDisplayString = (val) => { + return val == null + ? '' + : isArray(val) || (isPlainObject(val) && val.toString === objectToString) + ? JSON.stringify(val, null, 2) + : String(val); + }; + function join(items, separator = '') { + return items.reduce((str, item, index) => (index === 0 ? str + item : str + separator + item), ''); + } + const RANGE = 2; + function generateCodeFrame(source, start = 0, end = source.length) { + const lines = source.split(/\r?\n/); + let count = 0; + const res = []; + for (let i = 0; i < lines.length; i++) { + count += lines[i].length + 1; + if (count >= start) { + for (let j = i - RANGE; j <= i + RANGE || end > count; j++) { + if (j < 0 || j >= lines.length) + continue; + const line = j + 1; + res.push(`${line}${' '.repeat(3 - String(line).length)}| ${lines[j]}`); + const lineLength = lines[j].length; + if (j === i) { + // push underline + const pad = start - (count - lineLength) + 1; + const length = Math.max(1, end > count ? lineLength - pad : end - start); + res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length)); + } + else if (j > i) { + if (end > count) { + const length = Math.max(Math.min(end - count, lineLength), 1); + res.push(` | ` + '^'.repeat(length)); + } + count += lineLength + 1; + } + } + break; + } + } + return res.join('\n'); + } + function incrementer(code) { + let current = code; + return () => ++current; + } + + function createPosition(line, column, offset) { + return { line, column, offset }; + } + function createLocation(start, end, source) { + const loc = { start, end }; + if (source != null) { + loc.source = source; + } + return loc; + } + + const CompileWarnCodes = { + USE_MODULO_SYNTAX: 1, + __EXTEND_POINT__: 2 + }; + /** @internal */ + const warnMessages$1 = { + [CompileWarnCodes.USE_MODULO_SYNTAX]: `Use modulo before '{{0}}'.` + }; + function createCompileWarn(code, loc, ...args) { + const msg = format$1(warnMessages$1[code] || '', ...(args || [])) ; + const message = { message: String(msg), code }; + if (loc) { + message.location = loc; + } + return message; + } + + const CompileErrorCodes = { + // tokenizer error codes + EXPECTED_TOKEN: 1, + INVALID_TOKEN_IN_PLACEHOLDER: 2, + UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3, + UNKNOWN_ESCAPE_SEQUENCE: 4, + INVALID_UNICODE_ESCAPE_SEQUENCE: 5, + UNBALANCED_CLOSING_BRACE: 6, + UNTERMINATED_CLOSING_BRACE: 7, + EMPTY_PLACEHOLDER: 8, + NOT_ALLOW_NEST_PLACEHOLDER: 9, + INVALID_LINKED_FORMAT: 10, + // parser error codes + MUST_HAVE_MESSAGES_IN_PLURAL: 11, + UNEXPECTED_EMPTY_LINKED_MODIFIER: 12, + UNEXPECTED_EMPTY_LINKED_KEY: 13, + UNEXPECTED_LEXICAL_ANALYSIS: 14, + // generator error codes + UNHANDLED_CODEGEN_NODE_TYPE: 15, + // minifier error codes + UNHANDLED_MINIFIER_NODE_TYPE: 16, + // Special value for higher-order compilers to pick up the last code + // to avoid collision of error codes. This should always be kept as the last + // item. + __EXTEND_POINT__: 17 + }; + /** @internal */ + const errorMessages$1 = { + // tokenizer error messages + [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`, + [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`, + [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`, + [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`, + [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`, + [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`, + [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`, + [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`, + [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`, + [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`, + // parser error messages + [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`, + [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`, + // generator error messages + [CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`, + // minimizer error messages + [CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'` + }; + function createCompileError(code, loc, options = {}) { + const { domain, messages, args } = options; + const msg = format$1((messages || errorMessages$1)[code] || '', ...(args || [])) + ; + const error = new SyntaxError(String(msg)); + error.code = code; + if (loc) { + error.location = loc; + } + error.domain = domain; + return error; + } + /** @internal */ + function defaultOnError(error) { + throw error; + } + + // eslint-disable-next-line no-useless-escape + const RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/; + const detectHtmlTag = (source) => RE_HTML_TAG.test(source); + + const CHAR_SP = ' '; + const CHAR_CR = '\r'; + const CHAR_LF = '\n'; + const CHAR_LS = String.fromCharCode(0x2028); + const CHAR_PS = String.fromCharCode(0x2029); + function createScanner(str) { + const _buf = str; + let _index = 0; + let _line = 1; + let _column = 1; + let _peekOffset = 0; + const isCRLF = (index) => _buf[index] === CHAR_CR && _buf[index + 1] === CHAR_LF; + const isLF = (index) => _buf[index] === CHAR_LF; + const isPS = (index) => _buf[index] === CHAR_PS; + const isLS = (index) => _buf[index] === CHAR_LS; + const isLineEnd = (index) => isCRLF(index) || isLF(index) || isPS(index) || isLS(index); + const index = () => _index; + const line = () => _line; + const column = () => _column; + const peekOffset = () => _peekOffset; + const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset]; + const currentChar = () => charAt(_index); + const currentPeek = () => charAt(_index + _peekOffset); + function next() { + _peekOffset = 0; + if (isLineEnd(_index)) { + _line++; + _column = 0; + } + if (isCRLF(_index)) { + _index++; + } + _index++; + _column++; + return _buf[_index]; + } + function peek() { + if (isCRLF(_index + _peekOffset)) { + _peekOffset++; + } + _peekOffset++; + return _buf[_index + _peekOffset]; + } + function reset() { + _index = 0; + _line = 1; + _column = 1; + _peekOffset = 0; + } + function resetPeek(offset = 0) { + _peekOffset = offset; + } + function skipToPeek() { + const target = _index + _peekOffset; + // eslint-disable-next-line no-unmodified-loop-condition + while (target !== _index) { + next(); + } + _peekOffset = 0; + } + return { + index, + line, + column, + peekOffset, + charAt, + currentChar, + currentPeek, + next, + peek, + reset, + resetPeek, + skipToPeek + }; + } + + const EOF = undefined; + const DOT = '.'; + const LITERAL_DELIMITER = "'"; + const ERROR_DOMAIN$3 = 'tokenizer'; + function createTokenizer(source, options = {}) { + const location = options.location !== false; + const _scnr = createScanner(source); + const currentOffset = () => _scnr.index(); + const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index()); + const _initLoc = currentPosition(); + const _initOffset = currentOffset(); + const _context = { + currentType: 14 /* TokenTypes.EOF */, + offset: _initOffset, + startLoc: _initLoc, + endLoc: _initLoc, + lastType: 14 /* TokenTypes.EOF */, + lastOffset: _initOffset, + lastStartLoc: _initLoc, + lastEndLoc: _initLoc, + braceNest: 0, + inLinked: false, + text: '' + }; + const context = () => _context; + const { onError } = options; + function emitError(code, pos, offset, ...args) { + const ctx = context(); + pos.column += offset; + pos.offset += offset; + if (onError) { + const loc = location ? createLocation(ctx.startLoc, pos) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$3, + args + }); + onError(err); + } + } + function getToken(context, type, value) { + context.endLoc = currentPosition(); + context.currentType = type; + const token = { type }; + if (location) { + token.loc = createLocation(context.startLoc, context.endLoc); + } + if (value != null) { + token.value = value; + } + return token; + } + const getEndToken = (context) => getToken(context, 14 /* TokenTypes.EOF */); + function eat(scnr, ch) { + if (scnr.currentChar() === ch) { + scnr.next(); + return ch; + } + else { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + return ''; + } + } + function peekSpaces(scnr) { + let buf = ''; + while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) { + buf += scnr.currentPeek(); + scnr.peek(); + } + return buf; + } + function skipSpaces(scnr) { + const buf = peekSpaces(scnr); + scnr.skipToPeek(); + return buf; + } + function isIdentifierStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + cc === 95 // _ + ); + } + function isNumberStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function isNamedIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isListIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ch = scnr.currentPeek() === '-' ? scnr.peek() : scnr.currentPeek(); + const ret = isNumberStart(ch); + scnr.resetPeek(); + return ret; + } + function isLiteralStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === LITERAL_DELIMITER; + scnr.resetPeek(); + return ret; + } + function isLinkedDotStart(scnr, context) { + const { currentType } = context; + if (currentType !== 8 /* TokenTypes.LinkedAlias */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === "." /* TokenChars.LinkedDot */; + scnr.resetPeek(); + return ret; + } + function isLinkedModifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 9 /* TokenTypes.LinkedDot */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isLinkedDelimiterStart(scnr, context) { + const { currentType } = context; + if (!(currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 12 /* TokenTypes.LinkedModifier */)) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === ":" /* TokenChars.LinkedDelimiter */; + scnr.resetPeek(); + return ret; + } + function isLinkedReferStart(scnr, context) { + const { currentType } = context; + if (currentType !== 10 /* TokenTypes.LinkedDelimiter */) { + return false; + } + const fn = () => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return isIdentifierStart(scnr.peek()); + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "|" /* TokenChars.Pipe */ || + ch === ":" /* TokenChars.LinkedDelimiter */ || + ch === "." /* TokenChars.LinkedDot */ || + ch === CHAR_SP || + !ch) { + return false; + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(); + } + else { + // other characters + return isTextStart(scnr, false); + } + }; + const ret = fn(); + scnr.resetPeek(); + return ret; + } + function isPluralStart(scnr) { + peekSpaces(scnr); + const ret = scnr.currentPeek() === "|" /* TokenChars.Pipe */; + scnr.resetPeek(); + return ret; + } + function detectModuloStart(scnr) { + const spaces = peekSpaces(scnr); + const ret = scnr.currentPeek() === "%" /* TokenChars.Modulo */ && + scnr.peek() === "{" /* TokenChars.BraceLeft */; + scnr.resetPeek(); + return { + isModulo: ret, + hasSpace: spaces.length > 0 + }; + } + function isTextStart(scnr, reset = true) { + const fn = (hasSpace = false, prev = '', detectModulo = false) => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return prev === "%" /* TokenChars.Modulo */ ? false : hasSpace; + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || !ch) { + return prev === "%" /* TokenChars.Modulo */ ? true : hasSpace; + } + else if (ch === "%" /* TokenChars.Modulo */) { + scnr.peek(); + return fn(hasSpace, "%" /* TokenChars.Modulo */, true); + } + else if (ch === "|" /* TokenChars.Pipe */) { + return prev === "%" /* TokenChars.Modulo */ || detectModulo + ? true + : !(prev === CHAR_SP || prev === CHAR_LF); + } + else if (ch === CHAR_SP) { + scnr.peek(); + return fn(true, CHAR_SP, detectModulo); + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(true, CHAR_LF, detectModulo); + } + else { + return true; + } + }; + const ret = fn(); + reset && scnr.resetPeek(); + return ret; + } + function takeChar(scnr, fn) { + const ch = scnr.currentChar(); + if (ch === EOF) { + return EOF; + } + if (fn(ch)) { + scnr.next(); + return ch; + } + return null; + } + function isIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 // $ + ); + } + function takeIdentifierChar(scnr) { + return takeChar(scnr, isIdentifier); + } + function isNamedIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 || // $ + cc === 45 // - + ); + } + function takeNamedIdentifierChar(scnr) { + return takeChar(scnr, isNamedIdentifier); + } + function isDigit(ch) { + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function takeDigit(scnr) { + return takeChar(scnr, isDigit); + } + function isHexDigit(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 48 && cc <= 57) || // 0-9 + (cc >= 65 && cc <= 70) || // A-F + (cc >= 97 && cc <= 102)); // a-f + } + function takeHexDigit(scnr) { + return takeChar(scnr, isHexDigit); + } + function getDigits(scnr) { + let ch = ''; + let num = ''; + while ((ch = takeDigit(scnr))) { + num += ch; + } + return num; + } + function readModulo(scnr) { + skipSpaces(scnr); + const ch = scnr.currentChar(); + if (ch !== "%" /* TokenChars.Modulo */) { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + } + scnr.next(); + return "%" /* TokenChars.Modulo */; + } + function readText(scnr) { + let buf = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "}" /* TokenChars.BraceRight */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + !ch) { + break; + } + else if (ch === "%" /* TokenChars.Modulo */) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else { + break; + } + } + else if (ch === CHAR_SP || ch === CHAR_LF) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else if (isPluralStart(scnr)) { + break; + } + else { + buf += ch; + scnr.next(); + } + } + else { + buf += ch; + scnr.next(); + } + } + return buf; + } + function readNamedIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let name = ''; + while ((ch = takeNamedIdentifierChar(scnr))) { + name += ch; + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return name; + } + function readListIdentifier(scnr) { + skipSpaces(scnr); + let value = ''; + if (scnr.currentChar() === '-') { + scnr.next(); + value += `-${getDigits(scnr)}`; + } + else { + value += getDigits(scnr); + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return value; + } + function isLiteral(ch) { + return ch !== LITERAL_DELIMITER && ch !== CHAR_LF; + } + function readLiteral(scnr) { + skipSpaces(scnr); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + let ch = ''; + let literal = ''; + while ((ch = takeChar(scnr, isLiteral))) { + if (ch === '\\') { + literal += readEscapeSequence(scnr); + } + else { + literal += ch; + } + } + const current = scnr.currentChar(); + if (current === CHAR_LF || current === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, currentPosition(), 0); + // TODO: Is it correct really? + if (current === CHAR_LF) { + scnr.next(); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + } + return literal; + } + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + return literal; + } + function readEscapeSequence(scnr) { + const ch = scnr.currentChar(); + switch (ch) { + case '\\': + case `\'`: // eslint-disable-line no-useless-escape + scnr.next(); + return `\\${ch}`; + case 'u': + return readUnicodeEscapeSequence(scnr, ch, 4); + case 'U': + return readUnicodeEscapeSequence(scnr, ch, 6); + default: + emitError(CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, currentPosition(), 0, ch); + return ''; + } + } + function readUnicodeEscapeSequence(scnr, unicode, digits) { + eat(scnr, unicode); + let sequence = ''; + for (let i = 0; i < digits; i++) { + const ch = takeHexDigit(scnr); + if (!ch) { + emitError(CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`); + break; + } + sequence += ch; + } + return `\\${unicode}${sequence}`; + } + function isInvalidIdentifier(ch) { + return (ch !== "{" /* TokenChars.BraceLeft */ && + ch !== "}" /* TokenChars.BraceRight */ && + ch !== CHAR_SP && + ch !== CHAR_LF); + } + function readInvalidIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let identifiers = ''; + while ((ch = takeChar(scnr, isInvalidIdentifier))) { + identifiers += ch; + } + return identifiers; + } + function readLinkedModifier(scnr) { + let ch = ''; + let name = ''; + while ((ch = takeIdentifierChar(scnr))) { + name += ch; + } + return name; + } + function readLinkedRefer(scnr) { + const fn = (buf) => { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + ch === "(" /* TokenChars.ParenLeft */ || + ch === ")" /* TokenChars.ParenRight */ || + !ch) { + return buf; + } + else if (ch === CHAR_SP) { + return buf; + } + else if (ch === CHAR_LF || ch === DOT) { + buf += ch; + scnr.next(); + return fn(buf); + } + else { + buf += ch; + scnr.next(); + return fn(buf); + } + }; + return fn(''); + } + function readPlural(scnr) { + skipSpaces(scnr); + const plural = eat(scnr, "|" /* TokenChars.Pipe */); + skipSpaces(scnr); + return plural; + } + // TODO: We need refactoring of token parsing ... + function readTokenInPlaceholder(scnr, context) { + let token = null; + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + if (context.braceNest >= 1) { + emitError(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 2 /* TokenTypes.BraceLeft */, "{" /* TokenChars.BraceLeft */); + skipSpaces(scnr); + context.braceNest++; + return token; + case "}" /* TokenChars.BraceRight */: + if (context.braceNest > 0 && + context.currentType === 2 /* TokenTypes.BraceLeft */) { + emitError(CompileErrorCodes.EMPTY_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + context.braceNest--; + context.braceNest > 0 && skipSpaces(scnr); + if (context.inLinked && context.braceNest === 0) { + context.inLinked = false; + } + return token; + case "@" /* TokenChars.LinkedAlias */: + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = readTokenInLinked(scnr, context) || getEndToken(context); + context.braceNest = 0; + return token; + default: { + let validNamedIdentifier = true; + let validListIdentifier = true; + let validLiteral = true; + if (isPluralStart(scnr)) { + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (context.braceNest > 0 && + (context.currentType === 5 /* TokenTypes.Named */ || + context.currentType === 6 /* TokenTypes.List */ || + context.currentType === 7 /* TokenTypes.Literal */)) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + context.braceNest = 0; + return readToken(scnr, context); + } + if ((validNamedIdentifier = isNamedIdentifierStart(scnr, context))) { + token = getToken(context, 5 /* TokenTypes.Named */, readNamedIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validListIdentifier = isListIdentifierStart(scnr, context))) { + token = getToken(context, 6 /* TokenTypes.List */, readListIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validLiteral = isLiteralStart(scnr, context))) { + token = getToken(context, 7 /* TokenTypes.Literal */, readLiteral(scnr)); + skipSpaces(scnr); + return token; + } + if (!validNamedIdentifier && !validListIdentifier && !validLiteral) { + // TODO: we should be re-designed invalid cases, when we will extend message syntax near the future ... + token = getToken(context, 13 /* TokenTypes.InvalidPlace */, readInvalidIdentifier(scnr)); + emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value); + skipSpaces(scnr); + return token; + } + break; + } + } + return token; + } + // TODO: We need refactoring of token parsing ... + function readTokenInLinked(scnr, context) { + const { currentType } = context; + let token = null; + const ch = scnr.currentChar(); + if ((currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 9 /* TokenTypes.LinkedDot */ || + currentType === 12 /* TokenTypes.LinkedModifier */ || + currentType === 10 /* TokenTypes.LinkedDelimiter */) && + (ch === CHAR_LF || ch === CHAR_SP)) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + switch (ch) { + case "@" /* TokenChars.LinkedAlias */: + scnr.next(); + token = getToken(context, 8 /* TokenTypes.LinkedAlias */, "@" /* TokenChars.LinkedAlias */); + context.inLinked = true; + return token; + case "." /* TokenChars.LinkedDot */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 9 /* TokenTypes.LinkedDot */, "." /* TokenChars.LinkedDot */); + case ":" /* TokenChars.LinkedDelimiter */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 10 /* TokenTypes.LinkedDelimiter */, ":" /* TokenChars.LinkedDelimiter */); + default: + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (isLinkedDotStart(scnr, context) || + isLinkedDelimiterStart(scnr, context)) { + skipSpaces(scnr); + return readTokenInLinked(scnr, context); + } + if (isLinkedModifierStart(scnr, context)) { + skipSpaces(scnr); + return getToken(context, 12 /* TokenTypes.LinkedModifier */, readLinkedModifier(scnr)); + } + if (isLinkedReferStart(scnr, context)) { + skipSpaces(scnr); + if (ch === "{" /* TokenChars.BraceLeft */) { + // scan the placeholder + return readTokenInPlaceholder(scnr, context) || token; + } + else { + return getToken(context, 11 /* TokenTypes.LinkedKey */, readLinkedRefer(scnr)); + } + } + if (currentType === 8 /* TokenTypes.LinkedAlias */) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + context.braceNest = 0; + context.inLinked = false; + return readToken(scnr, context); + } + } + // TODO: We need refactoring of token parsing ... + function readToken(scnr, context) { + let token = { type: 14 /* TokenTypes.EOF */ }; + if (context.braceNest > 0) { + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + } + if (context.inLinked) { + return readTokenInLinked(scnr, context) || getEndToken(context); + } + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + case "}" /* TokenChars.BraceRight */: + emitError(CompileErrorCodes.UNBALANCED_CLOSING_BRACE, currentPosition(), 0); + scnr.next(); + return getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + case "@" /* TokenChars.LinkedAlias */: + return readTokenInLinked(scnr, context) || getEndToken(context); + default: { + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + const { isModulo, hasSpace } = detectModuloStart(scnr); + if (isModulo) { + return hasSpace + ? getToken(context, 0 /* TokenTypes.Text */, readText(scnr)) + : getToken(context, 4 /* TokenTypes.Modulo */, readModulo(scnr)); + } + if (isTextStart(scnr)) { + return getToken(context, 0 /* TokenTypes.Text */, readText(scnr)); + } + break; + } + } + return token; + } + function nextToken() { + const { currentType, offset, startLoc, endLoc } = _context; + _context.lastType = currentType; + _context.lastOffset = offset; + _context.lastStartLoc = startLoc; + _context.lastEndLoc = endLoc; + _context.offset = currentOffset(); + _context.startLoc = currentPosition(); + if (_scnr.currentChar() === EOF) { + return getToken(_context, 14 /* TokenTypes.EOF */); + } + return readToken(_scnr, _context); + } + return { + nextToken, + currentOffset, + currentPosition, + context + }; + } + + const ERROR_DOMAIN$2 = 'parser'; + // Backslash backslash, backslash quote, uHHHH, UHHHHHH. + const KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g; + function fromEscapeSequence(match, codePoint4, codePoint6) { + switch (match) { + case `\\\\`: + return `\\`; + // eslint-disable-next-line no-useless-escape + case `\\\'`: + // eslint-disable-next-line no-useless-escape + return `\'`; + default: { + const codePoint = parseInt(codePoint4 || codePoint6, 16); + if (codePoint <= 0xd7ff || codePoint >= 0xe000) { + return String.fromCodePoint(codePoint); + } + // invalid ... + // Replace them with U+FFFD REPLACEMENT CHARACTER. + return '�'; + } + } + } + function createParser(options = {}) { + const location = options.location !== false; + const { onError, onWarn } = options; + function emitError(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onError) { + const loc = location ? createLocation(start, end) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$2, + args + }); + onError(err); + } + } + function emitWarn(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onWarn) { + const loc = location ? createLocation(start, end) : null; + onWarn(createCompileWarn(code, loc, args)); + } + } + function startNode(type, offset, loc) { + const node = { type }; + if (location) { + node.start = offset; + node.end = offset; + node.loc = { start: loc, end: loc }; + } + return node; + } + function endNode(node, offset, pos, type) { + if (type) { + node.type = type; + } + if (location) { + node.end = offset; + if (node.loc) { + node.loc.end = pos; + } + } + } + function parseText(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(3 /* NodeTypes.Text */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseList(tokenizer, index) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(5 /* NodeTypes.List */, offset, loc); + node.index = parseInt(index, 10); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseNamed(tokenizer, key, modulo) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(4 /* NodeTypes.Named */, offset, loc); + node.key = key; + if (modulo === true) { + node.modulo = true; + } + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLiteral(tokenizer, value) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(9 /* NodeTypes.Literal */, offset, loc); + node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinkedModifier(tokenizer) { + const token = tokenizer.nextToken(); + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get linked dot loc + const node = startNode(8 /* NodeTypes.LinkedModifier */, offset, loc); + if (token.type !== 12 /* TokenTypes.LinkedModifier */) { + // empty modifier + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0); + node.value = ''; + endNode(node, offset, loc); + return { + nextConsumeToken: token, + node + }; + } + // check token + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.value = token.value || ''; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node + }; + } + function parseLinkedKey(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(7 /* NodeTypes.LinkedKey */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinked(tokenizer) { + const context = tokenizer.context(); + const linkedNode = startNode(6 /* NodeTypes.Linked */, context.offset, context.startLoc); + let token = tokenizer.nextToken(); + if (token.type === 9 /* TokenTypes.LinkedDot */) { + const parsed = parseLinkedModifier(tokenizer); + linkedNode.modifier = parsed.node; + token = parsed.nextConsumeToken || tokenizer.nextToken(); + } + // asset check token + if (token.type !== 10 /* TokenTypes.LinkedDelimiter */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + token = tokenizer.nextToken(); + // skip brace left + if (token.type === 2 /* TokenTypes.BraceLeft */) { + token = tokenizer.nextToken(); + } + switch (token.type) { + case 11 /* TokenTypes.LinkedKey */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseNamed(tokenizer, token.value || ''); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseList(tokenizer, token.value || ''); + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLiteral(tokenizer, token.value || ''); + break; + default: { + // empty key + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0); + const nextContext = tokenizer.context(); + const emptyLinkedKeyNode = startNode(7 /* NodeTypes.LinkedKey */, nextContext.offset, nextContext.startLoc); + emptyLinkedKeyNode.value = ''; + endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc); + linkedNode.key = emptyLinkedKeyNode; + endNode(linkedNode, nextContext.offset, nextContext.startLoc); + return { + nextConsumeToken: token, + node: linkedNode + }; + } + } + endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node: linkedNode + }; + } + function parseMessage(tokenizer) { + const context = tokenizer.context(); + const startOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? tokenizer.currentOffset() + : context.offset; + const startLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.endLoc + : context.startLoc; + const node = startNode(2 /* NodeTypes.Message */, startOffset, startLoc); + node.items = []; + let nextToken = null; + let modulo = null; + do { + const token = nextToken || tokenizer.nextToken(); + nextToken = null; + switch (token.type) { + case 0 /* TokenTypes.Text */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseText(tokenizer, token.value || '')); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseList(tokenizer, token.value || '')); + break; + case 4 /* TokenTypes.Modulo */: + modulo = true; + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseNamed(tokenizer, token.value || '', !!modulo)); + if (modulo) { + emitWarn(tokenizer, CompileWarnCodes.USE_MODULO_SYNTAX, context.lastStartLoc, 0, getTokenCaption(token)); + modulo = null; + } + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseLiteral(tokenizer, token.value || '')); + break; + case 8 /* TokenTypes.LinkedAlias */: { + const parsed = parseLinked(tokenizer); + node.items.push(parsed.node); + nextToken = parsed.nextConsumeToken || null; + break; + } + } + } while (context.currentType !== 14 /* TokenTypes.EOF */ && + context.currentType !== 1 /* TokenTypes.Pipe */); + // adjust message node loc + const endOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastOffset + : tokenizer.currentOffset(); + const endLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastEndLoc + : tokenizer.currentPosition(); + endNode(node, endOffset, endLoc); + return node; + } + function parsePlural(tokenizer, offset, loc, msgNode) { + const context = tokenizer.context(); + let hasEmptyMessage = msgNode.items.length === 0; + const node = startNode(1 /* NodeTypes.Plural */, offset, loc); + node.cases = []; + node.cases.push(msgNode); + do { + const msg = parseMessage(tokenizer); + if (!hasEmptyMessage) { + hasEmptyMessage = msg.items.length === 0; + } + node.cases.push(msg); + } while (context.currentType !== 14 /* TokenTypes.EOF */); + if (hasEmptyMessage) { + emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseResource(tokenizer) { + const context = tokenizer.context(); + const { offset, startLoc } = context; + const msgNode = parseMessage(tokenizer); + if (context.currentType === 14 /* TokenTypes.EOF */) { + return msgNode; + } + else { + return parsePlural(tokenizer, offset, startLoc, msgNode); + } + } + function parse(source) { + const tokenizer = createTokenizer(source, assign({}, options)); + const context = tokenizer.context(); + const node = startNode(0 /* NodeTypes.Resource */, context.offset, context.startLoc); + if (location && node.loc) { + node.loc.source = source; + } + node.body = parseResource(tokenizer); + if (options.onCacheKey) { + node.cacheKey = options.onCacheKey(source); + } + // assert whether achieved to EOF + if (context.currentType !== 14 /* TokenTypes.EOF */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || ''); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + return { parse }; + } + function getTokenCaption(token) { + if (token.type === 14 /* TokenTypes.EOF */) { + return 'EOF'; + } + const name = (token.value || '').replace(/\r?\n/gu, '\\n'); + return name.length > 10 ? name.slice(0, 9) + '…' : name; + } + + function createTransformer(ast, options = {} // eslint-disable-line + ) { + const _context = { + ast, + helpers: new Set() + }; + const context = () => _context; + const helper = (name) => { + _context.helpers.add(name); + return name; + }; + return { context, helper }; + } + function traverseNodes(nodes, transformer) { + for (let i = 0; i < nodes.length; i++) { + traverseNode(nodes[i], transformer); + } + } + function traverseNode(node, transformer) { + // TODO: if we need pre-hook of transform, should be implemented to here + switch (node.type) { + case 1 /* NodeTypes.Plural */: + traverseNodes(node.cases, transformer); + transformer.helper("plural" /* HelperNameMap.PLURAL */); + break; + case 2 /* NodeTypes.Message */: + traverseNodes(node.items, transformer); + break; + case 6 /* NodeTypes.Linked */: { + const linked = node; + traverseNode(linked.key, transformer); + transformer.helper("linked" /* HelperNameMap.LINKED */); + transformer.helper("type" /* HelperNameMap.TYPE */); + break; + } + case 5 /* NodeTypes.List */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("list" /* HelperNameMap.LIST */); + break; + case 4 /* NodeTypes.Named */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("named" /* HelperNameMap.NAMED */); + break; + } + // TODO: if we need post-hook of transform, should be implemented to here + } + // transform AST + function transform(ast, options = {} // eslint-disable-line + ) { + const transformer = createTransformer(ast); + transformer.helper("normalize" /* HelperNameMap.NORMALIZE */); + // traverse + ast.body && traverseNode(ast.body, transformer); + // set meta information + const context = transformer.context(); + ast.helpers = Array.from(context.helpers); + } + + function optimize(ast) { + const body = ast.body; + if (body.type === 2 /* NodeTypes.Message */) { + optimizeMessageNode(body); + } + else { + body.cases.forEach(c => optimizeMessageNode(c)); + } + return ast; + } + function optimizeMessageNode(message) { + if (message.items.length === 1) { + const item = message.items[0]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + message.static = item.value; + delete item.value; // optimization for size + } + } + else { + const values = []; + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (!(item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */)) { + break; + } + if (item.value == null) { + break; + } + values.push(item.value); + } + if (values.length === message.items.length) { + message.static = join(values); + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + delete item.value; // optimization for size + } + } + } + } + } + + const ERROR_DOMAIN$1 = 'minifier'; + /* eslint-disable @typescript-eslint/no-explicit-any */ + function minify(node) { + node.t = node.type; + switch (node.type) { + case 0 /* NodeTypes.Resource */: { + const resource = node; + minify(resource.body); + resource.b = resource.body; + delete resource.body; + break; + } + case 1 /* NodeTypes.Plural */: { + const plural = node; + const cases = plural.cases; + for (let i = 0; i < cases.length; i++) { + minify(cases[i]); + } + plural.c = cases; + delete plural.cases; + break; + } + case 2 /* NodeTypes.Message */: { + const message = node; + const items = message.items; + for (let i = 0; i < items.length; i++) { + minify(items[i]); + } + message.i = items; + delete message.items; + if (message.static) { + message.s = message.static; + delete message.static; + } + break; + } + case 3 /* NodeTypes.Text */: + case 9 /* NodeTypes.Literal */: + case 8 /* NodeTypes.LinkedModifier */: + case 7 /* NodeTypes.LinkedKey */: { + const valueNode = node; + if (valueNode.value) { + valueNode.v = valueNode.value; + delete valueNode.value; + } + break; + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + minify(linked.key); + linked.k = linked.key; + delete linked.key; + if (linked.modifier) { + minify(linked.modifier); + linked.m = linked.modifier; + delete linked.modifier; + } + break; + } + case 5 /* NodeTypes.List */: { + const list = node; + list.i = list.index; + delete list.index; + break; + } + case 4 /* NodeTypes.Named */: { + const named = node; + named.k = named.key; + delete named.key; + break; + } + default: + { + throw createCompileError(CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE, null, { + domain: ERROR_DOMAIN$1, + args: [node.type] + }); + } + } + delete node.type; + } + /* eslint-enable @typescript-eslint/no-explicit-any */ + + // eslint-disable-next-line @typescript-eslint/triple-slash-reference + /// + const ERROR_DOMAIN = 'parser'; + function createCodeGenerator(ast, options) { + const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options; + const location = options.location !== false; + const _context = { + filename, + code: '', + column: 1, + line: 1, + offset: 0, + map: undefined, + breakLineCode, + needIndent: _needIndent, + indentLevel: 0 + }; + if (location && ast.loc) { + _context.source = ast.loc.source; + } + const context = () => _context; + function push(code, node) { + _context.code += code; + } + function _newline(n, withBreakLine = true) { + const _breakLineCode = withBreakLine ? breakLineCode : ''; + push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode); + } + function indent(withNewLine = true) { + const level = ++_context.indentLevel; + withNewLine && _newline(level); + } + function deindent(withNewLine = true) { + const level = --_context.indentLevel; + withNewLine && _newline(level); + } + function newline() { + _newline(_context.indentLevel); + } + const helper = (key) => `_${key}`; + const needIndent = () => _context.needIndent; + return { + context, + push, + indent, + deindent, + newline, + helper, + needIndent + }; + } + function generateLinkedNode(generator, node) { + const { helper } = generator; + generator.push(`${helper("linked" /* HelperNameMap.LINKED */)}(`); + generateNode(generator, node.key); + if (node.modifier) { + generator.push(`, `); + generateNode(generator, node.modifier); + generator.push(`, _type`); + } + else { + generator.push(`, undefined, _type`); + } + generator.push(`)`); + } + function generateMessageNode(generator, node) { + const { helper, needIndent } = generator; + generator.push(`${helper("normalize" /* HelperNameMap.NORMALIZE */)}([`); + generator.indent(needIndent()); + const length = node.items.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.items[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push('])'); + } + function generatePluralNode(generator, node) { + const { helper, needIndent } = generator; + if (node.cases.length > 1) { + generator.push(`${helper("plural" /* HelperNameMap.PLURAL */)}([`); + generator.indent(needIndent()); + const length = node.cases.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.cases[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push(`])`); + } + } + function generateResource(generator, node) { + if (node.body) { + generateNode(generator, node.body); + } + else { + generator.push('null'); + } + } + function generateNode(generator, node) { + const { helper } = generator; + switch (node.type) { + case 0 /* NodeTypes.Resource */: + generateResource(generator, node); + break; + case 1 /* NodeTypes.Plural */: + generatePluralNode(generator, node); + break; + case 2 /* NodeTypes.Message */: + generateMessageNode(generator, node); + break; + case 6 /* NodeTypes.Linked */: + generateLinkedNode(generator, node); + break; + case 8 /* NodeTypes.LinkedModifier */: + generator.push(JSON.stringify(node.value), node); + break; + case 7 /* NodeTypes.LinkedKey */: + generator.push(JSON.stringify(node.value), node); + break; + case 5 /* NodeTypes.List */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("list" /* HelperNameMap.LIST */)}(${node.index}))`, node); + break; + case 4 /* NodeTypes.Named */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("named" /* HelperNameMap.NAMED */)}(${JSON.stringify(node.key)}))`, node); + break; + case 9 /* NodeTypes.Literal */: + generator.push(JSON.stringify(node.value), node); + break; + case 3 /* NodeTypes.Text */: + generator.push(JSON.stringify(node.value), node); + break; + default: + { + throw createCompileError(CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE, null, { + domain: ERROR_DOMAIN, + args: [node.type] + }); + } + } + } + // generate code from AST + const generate = (ast, options = {} // eslint-disable-line + ) => { + const mode = isString(options.mode) ? options.mode : 'normal'; + const filename = isString(options.filename) + ? options.filename + : 'message.intl'; + const sourceMap = !!options.sourceMap; + // prettier-ignore + const breakLineCode = options.breakLineCode != null + ? options.breakLineCode + : mode === 'arrow' + ? ';' + : '\n'; + const needIndent = options.needIndent ? options.needIndent : mode !== 'arrow'; + const helpers = ast.helpers || []; + const generator = createCodeGenerator(ast, { + mode, + filename, + sourceMap, + breakLineCode, + needIndent + }); + generator.push(mode === 'normal' ? `function __msg__ (ctx) {` : `(ctx) => {`); + generator.indent(needIndent); + if (helpers.length > 0) { + generator.push(`const { ${join(helpers.map(s => `${s}: _${s}`), ', ')} } = ctx`); + generator.newline(); + } + generator.push(`return `); + generateNode(generator, ast); + generator.deindent(needIndent); + generator.push(`}`); + delete ast.helpers; + const { code, map } = generator.context(); + return { + ast, + code, + map: map ? map.toJSON() : undefined // eslint-disable-line @typescript-eslint/no-explicit-any + }; + }; + + function baseCompile$1(source, options = {}) { + const assignedOptions = assign({}, options); + const jit = !!assignedOptions.jit; + const enalbeMinify = !!assignedOptions.minify; + const enambeOptimize = assignedOptions.optimize == null ? true : assignedOptions.optimize; + // parse source codes + const parser = createParser(assignedOptions); + const ast = parser.parse(source); + if (!jit) { + // transform ASTs + transform(ast, assignedOptions); + // generate javascript codes + return generate(ast, assignedOptions); + } + else { + // optimize ASTs + enambeOptimize && optimize(ast); + // minimize ASTs + enalbeMinify && minify(ast); + // In JIT mode, no ast transform, no code generation. + return { ast, code: '' }; + } + } + + function isMessageAST(val) { + return (isObject(val) && + resolveType(val) === 0 && + (hasOwn(val, 'b') || hasOwn(val, 'body'))); + } + const PROPS_BODY = ['b', 'body']; + function resolveBody(node) { + return resolveProps(node, PROPS_BODY); + } + const PROPS_CASES = ['c', 'cases']; + function resolveCases(node) { + return resolveProps(node, PROPS_CASES, []); + } + const PROPS_STATIC = ['s', 'static']; + function resolveStatic(node) { + return resolveProps(node, PROPS_STATIC); + } + const PROPS_ITEMS = ['i', 'items']; + function resolveItems(node) { + return resolveProps(node, PROPS_ITEMS, []); + } + const PROPS_TYPE = ['t', 'type']; + function resolveType(node) { + return resolveProps(node, PROPS_TYPE); + } + const PROPS_VALUE = ['v', 'value']; + function resolveValue$1(node, type) { + const resolved = resolveProps(node, PROPS_VALUE); + if (resolved != null) { + return resolved; + } + else { + throw createUnhandleNodeError(type); + } + } + const PROPS_MODIFIER = ['m', 'modifier']; + function resolveLinkedModifier(node) { + return resolveProps(node, PROPS_MODIFIER); + } + const PROPS_KEY = ['k', 'key']; + function resolveLinkedKey(node) { + const resolved = resolveProps(node, PROPS_KEY); + if (resolved) { + return resolved; + } + else { + throw createUnhandleNodeError(6 /* NodeTypes.Linked */); + } + } + function resolveProps(node, props, defaultValue) { + for (let i = 0; i < props.length; i++) { + const prop = props[i]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (hasOwn(node, prop) && node[prop] != null) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return node[prop]; + } + } + return defaultValue; + } + const AST_NODE_PROPS_KEYS = [ + ...PROPS_BODY, + ...PROPS_CASES, + ...PROPS_STATIC, + ...PROPS_ITEMS, + ...PROPS_KEY, + ...PROPS_MODIFIER, + ...PROPS_VALUE, + ...PROPS_TYPE + ]; + function createUnhandleNodeError(type) { + return new Error(`unhandled node type: ${type}`); + } + + const pathStateMachine = []; + pathStateMachine[0 /* States.BEFORE_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [0 /* States.BEFORE_PATH */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] + }; + pathStateMachine[1 /* States.IN_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] + }; + pathStateMachine[2 /* States.BEFORE_IDENT */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [2 /* States.BEFORE_IDENT */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */] + }; + pathStateMachine[3 /* States.IN_IDENT */] = { + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */, 1 /* Actions.PUSH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */, 1 /* Actions.PUSH */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */, 1 /* Actions.PUSH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */, 1 /* Actions.PUSH */] + }; + pathStateMachine[4 /* States.IN_SUB_PATH */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */], + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [ + 4 /* States.IN_SUB_PATH */, + 2 /* Actions.INC_SUB_PATH_DEPTH */ + ], + ["]" /* PathCharTypes.RIGHT_BRACKET */]: [1 /* States.IN_PATH */, 3 /* Actions.PUSH_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */] + }; + pathStateMachine[5 /* States.IN_SINGLE_QUOTE */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */] + }; + pathStateMachine[6 /* States.IN_DOUBLE_QUOTE */] = { + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */] + }; + /** + * Check if an expression is a literal value. + */ + const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/; + function isLiteral(exp) { + return literalValueRE.test(exp); + } + /** + * Strip quotes from a string + */ + function stripQuotes(str) { + const a = str.charCodeAt(0); + const b = str.charCodeAt(str.length - 1); + return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str; + } + /** + * Determine the type of a character in a keypath. + */ + function getPathCharType(ch) { + if (ch === undefined || ch === null) { + return "o" /* PathCharTypes.END_OF_FAIL */; + } + const code = ch.charCodeAt(0); + switch (code) { + case 0x5b: // [ + case 0x5d: // ] + case 0x2e: // . + case 0x22: // " + case 0x27: // ' + return ch; + case 0x5f: // _ + case 0x24: // $ + case 0x2d: // - + return "i" /* PathCharTypes.IDENT */; + case 0x09: // Tab (HT) + case 0x0a: // Newline (LF) + case 0x0d: // Return (CR) + case 0xa0: // No-break space (NBSP) + case 0xfeff: // Byte Order Mark (BOM) + case 0x2028: // Line Separator (LS) + case 0x2029: // Paragraph Separator (PS) + return "w" /* PathCharTypes.WORKSPACE */; + } + return "i" /* PathCharTypes.IDENT */; + } + /** + * Format a subPath, return its plain form if it is + * a literal string or number. Otherwise prepend the + * dynamic indicator (*). + */ + function formatSubPath(path) { + const trimmed = path.trim(); + // invalid leading 0 + if (path.charAt(0) === '0' && isNaN(parseInt(path))) { + return false; + } + return isLiteral(trimmed) + ? stripQuotes(trimmed) + : "*" /* PathCharTypes.ASTARISK */ + trimmed; + } + /** + * Parse a string path into an array of segments + */ + function parse(path) { + const keys = []; + let index = -1; + let mode = 0 /* States.BEFORE_PATH */; + let subPathDepth = 0; + let c; + let key; // eslint-disable-line + let newChar; + let type; + let transition; + let action; + let typeMap; + const actions = []; + actions[0 /* Actions.APPEND */] = () => { + if (key === undefined) { + key = newChar; + } + else { + key += newChar; + } + }; + actions[1 /* Actions.PUSH */] = () => { + if (key !== undefined) { + keys.push(key); + key = undefined; + } + }; + actions[2 /* Actions.INC_SUB_PATH_DEPTH */] = () => { + actions[0 /* Actions.APPEND */](); + subPathDepth++; + }; + actions[3 /* Actions.PUSH_SUB_PATH */] = () => { + if (subPathDepth > 0) { + subPathDepth--; + mode = 4 /* States.IN_SUB_PATH */; + actions[0 /* Actions.APPEND */](); + } + else { + subPathDepth = 0; + if (key === undefined) { + return false; + } + key = formatSubPath(key); + if (key === false) { + return false; + } + else { + actions[1 /* Actions.PUSH */](); + } + } + }; + function maybeUnescapeQuote() { + const nextChar = path[index + 1]; + if ((mode === 5 /* States.IN_SINGLE_QUOTE */ && + nextChar === "'" /* PathCharTypes.SINGLE_QUOTE */) || + (mode === 6 /* States.IN_DOUBLE_QUOTE */ && + nextChar === "\"" /* PathCharTypes.DOUBLE_QUOTE */)) { + index++; + newChar = '\\' + nextChar; + actions[0 /* Actions.APPEND */](); + return true; + } + } + while (mode !== null) { + index++; + c = path[index]; + if (c === '\\' && maybeUnescapeQuote()) { + continue; + } + type = getPathCharType(c); + typeMap = pathStateMachine[mode]; + transition = typeMap[type] || typeMap["l" /* PathCharTypes.ELSE */] || 8 /* States.ERROR */; + // check parse error + if (transition === 8 /* States.ERROR */) { + return; + } + mode = transition[0]; + if (transition[1] !== undefined) { + action = actions[transition[1]]; + if (action) { + newChar = c; + if (action() === false) { + return; + } + } + } + // check parse finish + if (mode === 7 /* States.AFTER_PATH */) { + return keys; + } + } + } + // path token cache + const cache = new Map(); + /** + * key-value message resolver + * + * @remarks + * Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ + function resolveWithKeyValue(obj, path) { + return isObject(obj) ? obj[path] : null; + } + /** + * message resolver + * + * @remarks + * Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default. + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ + function resolveValue(obj, path) { + // check object + if (!isObject(obj)) { + return null; + } + // parse path + let hit = cache.get(path); + if (!hit) { + hit = parse(path); + if (hit) { + cache.set(path, hit); + } + } + // check hit + if (!hit) { + return null; + } + // resolve path value + const len = hit.length; + let last = obj; + let i = 0; + while (i < len) { + const key = hit[i]; + /** + * NOTE: + * if `key` is intlify message format AST node key and `last` is intlify message format AST, skip it. + * because the AST node is not a key-value structure. + */ + if (AST_NODE_PROPS_KEYS.includes(key) && isMessageAST(last)) { + return null; + } + const val = last[key]; + if (val === undefined) { + return null; + } + if (isFunction(last)) { + return null; + } + last = val; + i++; + } + return last; + } + + const DEFAULT_MODIFIER = (str) => str; + const DEFAULT_MESSAGE = (ctx) => ''; // eslint-disable-line + const DEFAULT_MESSAGE_DATA_TYPE = 'text'; + const DEFAULT_NORMALIZE = (values) => values.length === 0 ? '' : join(values); + const DEFAULT_INTERPOLATE = toDisplayString; + function pluralDefault(choice, choicesLength) { + choice = Math.abs(choice); + if (choicesLength === 2) { + // prettier-ignore + return choice + ? choice > 1 + ? 1 + : 0 + : 1; + } + return choice ? Math.min(choice, 2) : 0; + } + function getPluralIndex(options) { + // prettier-ignore + const index = isNumber(options.pluralIndex) + ? options.pluralIndex + : -1; + // prettier-ignore + return options.named && (isNumber(options.named.count) || isNumber(options.named.n)) + ? isNumber(options.named.count) + ? options.named.count + : isNumber(options.named.n) + ? options.named.n + : index + : index; + } + function normalizeNamed(pluralIndex, props) { + if (!props.count) { + props.count = pluralIndex; + } + if (!props.n) { + props.n = pluralIndex; + } + } + function createMessageContext(options = {}) { + const locale = options.locale; + const pluralIndex = getPluralIndex(options); + const pluralRule = isObject(options.pluralRules) && + isString(locale) && + isFunction(options.pluralRules[locale]) + ? options.pluralRules[locale] + : pluralDefault; + const orgPluralRule = isObject(options.pluralRules) && + isString(locale) && + isFunction(options.pluralRules[locale]) + ? pluralDefault + : undefined; + const plural = (messages) => { + return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)]; + }; + const _list = options.list || []; + const list = (index) => _list[index]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _named = options.named || create(); + isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named); + const named = (key) => _named[key]; + function message(key) { + // prettier-ignore + const msg = isFunction(options.messages) + ? options.messages(key) + : isObject(options.messages) + ? options.messages[key] + : false; + return !msg + ? options.parent + ? options.parent.message(key) // resolve from parent messages + : DEFAULT_MESSAGE + : msg; + } + const _modifier = (name) => options.modifiers + ? options.modifiers[name] + : DEFAULT_MODIFIER; + const normalize = isPlainObject(options.processor) && isFunction(options.processor.normalize) + ? options.processor.normalize + : DEFAULT_NORMALIZE; + const interpolate = isPlainObject(options.processor) && + isFunction(options.processor.interpolate) + ? options.processor.interpolate + : DEFAULT_INTERPOLATE; + const type = isPlainObject(options.processor) && isString(options.processor.type) + ? options.processor.type + : DEFAULT_MESSAGE_DATA_TYPE; + const linked = (key, ...args) => { + const [arg1, arg2] = args; + let type = 'text'; + let modifier = ''; + if (args.length === 1) { + if (isObject(arg1)) { + modifier = arg1.modifier || modifier; + type = arg1.type || type; + } + else if (isString(arg1)) { + modifier = arg1 || modifier; + } + } + else if (args.length === 2) { + if (isString(arg1)) { + modifier = arg1 || modifier; + } + if (isString(arg2)) { + type = arg2 || type; + } + } + const ret = message(key)(ctx); + const msg = + // The message in vnode resolved with linked are returned as an array by processor.nomalize + type === 'vnode' && isArray(ret) && modifier + ? ret[0] + : ret; + return modifier ? _modifier(modifier)(msg, type) : msg; + }; + const ctx = { + ["list" /* HelperNameMap.LIST */]: list, + ["named" /* HelperNameMap.NAMED */]: named, + ["plural" /* HelperNameMap.PLURAL */]: plural, + ["linked" /* HelperNameMap.LINKED */]: linked, + ["message" /* HelperNameMap.MESSAGE */]: message, + ["type" /* HelperNameMap.TYPE */]: type, + ["interpolate" /* HelperNameMap.INTERPOLATE */]: interpolate, + ["normalize" /* HelperNameMap.NORMALIZE */]: normalize, + ["values" /* HelperNameMap.VALUES */]: assign(create(), _list, _named) + }; + return ctx; + } + + let devtools = null; + function setDevToolsHook(hook) { + devtools = hook; + } + function getDevToolsHook() { + return devtools; + } + function initI18nDevTools(i18n, version, meta) { + // TODO: queue if devtools is undefined + devtools && + devtools.emit("i18n:init" /* IntlifyDevToolsHooks.I18nInit */, { + timestamp: Date.now(), + i18n, + version, + meta + }); + } + const translateDevTools = /* #__PURE__*/ createDevToolsHook("function:translate" /* IntlifyDevToolsHooks.FunctionTranslate */); + function createDevToolsHook(hook) { + return (payloads) => devtools && devtools.emit(hook, payloads); + } + + const code$1 = CompileWarnCodes.__EXTEND_POINT__; + const inc$1 = incrementer(code$1); + const CoreWarnCodes = { + NOT_FOUND_KEY: code$1, // 2 + FALLBACK_TO_TRANSLATE: inc$1(), // 3 + CANNOT_FORMAT_NUMBER: inc$1(), // 4 + FALLBACK_TO_NUMBER_FORMAT: inc$1(), // 5 + CANNOT_FORMAT_DATE: inc$1(), // 6 + FALLBACK_TO_DATE_FORMAT: inc$1(), // 7 + EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc$1(), // 8 + __EXTEND_POINT__: inc$1() // 9 + }; + /** @internal */ + const warnMessages = { + [CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`, + [CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`, + [CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`, + [CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]: `This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future.` + }; + function getWarnMessage(code, ...args) { + return format$1(warnMessages[code], ...args); + } + + const code = CompileErrorCodes.__EXTEND_POINT__; + const inc = incrementer(code); + const CoreErrorCodes = { + INVALID_ARGUMENT: code, // 17 + INVALID_DATE_ARGUMENT: inc(), // 18 + INVALID_ISO_DATE_ARGUMENT: inc(), // 19 + NOT_SUPPORT_NON_STRING_MESSAGE: inc(), // 20 + NOT_SUPPORT_LOCALE_PROMISE_VALUE: inc(), // 21 + NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: inc(), // 22 + NOT_SUPPORT_LOCALE_TYPE: inc(), // 23 + __EXTEND_POINT__: inc() // 24 + }; + function createCoreError(code) { + return createCompileError(code, null, { messages: errorMessages } ); + } + /** @internal */ + const errorMessages = { + [CoreErrorCodes.INVALID_ARGUMENT]: 'Invalid arguments', + [CoreErrorCodes.INVALID_DATE_ARGUMENT]: 'The date provided is an invalid Date object.' + + 'Make sure your Date represents a valid date.', + [CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: 'The argument provided is not a valid ISO date string', + [CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE]: 'Not support non-string message', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]: 'cannot support promise value', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]: 'cannot support async function', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: 'cannot support locale type' + }; + + /** @internal */ + function getLocale(context, options) { + return options.locale != null + ? resolveLocale(options.locale) + : resolveLocale(context.locale); + } + let _resolveLocale; + /** @internal */ + function resolveLocale(locale) { + if (isString(locale)) { + return locale; + } + else { + if (isFunction(locale)) { + if (locale.resolvedOnce && _resolveLocale != null) { + return _resolveLocale; + } + else if (locale.constructor.name === 'Function') { + const resolve = locale(); + if (isPromise(resolve)) { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE); + } + return (_resolveLocale = resolve); + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION); + } + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE); + } + } + } + /** + * Fallback with simple implemenation + * + * @remarks + * A fallback locale function implemented with a simple fallback algorithm. + * + * Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nGeneral + */ + function fallbackWithSimple(ctx, fallback, start // eslint-disable-line @typescript-eslint/no-unused-vars + ) { + // prettier-ignore + return [...new Set([ + start, + ...(isArray(fallback) + ? fallback + : isObject(fallback) + ? Object.keys(fallback) + : isString(fallback) + ? [fallback] + : [start]) + ])]; + } + /** + * Fallback with locale chain + * + * @remarks + * A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @VueI18nGeneral + */ + function fallbackWithLocaleChain(ctx, fallback, start) { + const startLocale = isString(start) ? start : DEFAULT_LOCALE; + const context = ctx; + if (!context.__localeChainCache) { + context.__localeChainCache = new Map(); + } + let chain = context.__localeChainCache.get(startLocale); + if (!chain) { + chain = []; + // first block defined by start + let block = [start]; + // while any intervening block found + while (isArray(block)) { + block = appendBlockToChain(chain, block, fallback); + } + // prettier-ignore + // last block defined by default + const defaults = isArray(fallback) || !isPlainObject(fallback) + ? fallback + : fallback['default'] + ? fallback['default'] + : null; + // convert defaults to array + block = isString(defaults) ? [defaults] : defaults; + if (isArray(block)) { + appendBlockToChain(chain, block, false); + } + context.__localeChainCache.set(startLocale, chain); + } + return chain; + } + function appendBlockToChain(chain, block, blocks) { + let follow = true; + for (let i = 0; i < block.length && isBoolean(follow); i++) { + const locale = block[i]; + if (isString(locale)) { + follow = appendLocaleToChain(chain, block[i], blocks); + } + } + return follow; + } + function appendLocaleToChain(chain, locale, blocks) { + let follow; + const tokens = locale.split('-'); + do { + const target = tokens.join('-'); + follow = appendItemToChain(chain, target, blocks); + tokens.splice(-1, 1); + } while (tokens.length && follow === true); + return follow; + } + function appendItemToChain(chain, target, blocks) { + let follow = false; + if (!chain.includes(target)) { + follow = true; + if (target) { + follow = target[target.length - 1] !== '!'; + const locale = target.replace(/!/g, ''); + chain.push(locale); + if ((isArray(blocks) || isPlainObject(blocks)) && + blocks[locale] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + follow = blocks[locale]; + } + } + } + return follow; + } + + /* eslint-disable @typescript-eslint/no-explicit-any */ + /** + * Intlify core-base version + * @internal + */ + const VERSION = '9.14.5'; + const NOT_REOSLVED = -1; + const DEFAULT_LOCALE = 'en-US'; + const MISSING_RESOLVE_VALUE = ''; + const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`; + function getDefaultLinkedModifiers() { + return { + upper: (val, type) => { + // prettier-ignore + return type === 'text' && isString(val) + ? val.toUpperCase() + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? val.children.toUpperCase() + : val; + }, + lower: (val, type) => { + // prettier-ignore + return type === 'text' && isString(val) + ? val.toLowerCase() + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? val.children.toLowerCase() + : val; + }, + capitalize: (val, type) => { + // prettier-ignore + return (type === 'text' && isString(val) + ? capitalize(val) + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? capitalize(val.children) + : val); + } + }; + } + let _compiler; + function registerMessageCompiler(compiler) { + _compiler = compiler; + } + let _resolver; + /** + * Register the message resolver + * + * @param resolver - A {@link MessageResolver} function + * + * @VueI18nGeneral + */ + function registerMessageResolver(resolver) { + _resolver = resolver; + } + let _fallbacker; + /** + * Register the locale fallbacker + * + * @param fallbacker - A {@link LocaleFallbacker} function + * + * @VueI18nGeneral + */ + function registerLocaleFallbacker(fallbacker) { + _fallbacker = fallbacker; + } + // Additional Meta for Intlify DevTools + let _additionalMeta = null; + /* #__NO_SIDE_EFFECTS__ */ + const setAdditionalMeta = (meta) => { + _additionalMeta = meta; + }; + /* #__NO_SIDE_EFFECTS__ */ + const getAdditionalMeta = () => _additionalMeta; + let _fallbackContext = null; + const setFallbackContext = (context) => { + _fallbackContext = context; + }; + const getFallbackContext = () => _fallbackContext; + // ID for CoreContext + let _cid = 0; + function createCoreContext(options = {}) { + // setup options + const onWarn = isFunction(options.onWarn) ? options.onWarn : warn; + const version = isString(options.version) ? options.version : VERSION; + const locale = isString(options.locale) || isFunction(options.locale) + ? options.locale + : DEFAULT_LOCALE; + const _locale = isFunction(locale) ? DEFAULT_LOCALE : locale; + const fallbackLocale = isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + isString(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale; + const messages = isPlainObject(options.messages) + ? options.messages + : createResources(_locale); + const datetimeFormats = isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : createResources(_locale) + ; + const numberFormats = isPlainObject(options.numberFormats) + ? options.numberFormats + : createResources(_locale) + ; + const modifiers = assign(create(), options.modifiers, getDefaultLinkedModifiers()); + const pluralRules = options.pluralRules || create(); + const missing = isFunction(options.missing) ? options.missing : null; + const missingWarn = isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + const fallbackWarn = isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + const fallbackFormat = !!options.fallbackFormat; + const unresolving = !!options.unresolving; + const postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + const processor = isPlainObject(options.processor) ? options.processor : null; + const warnHtmlMessage = isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const escapeParameter = !!options.escapeParameter; + const messageCompiler = isFunction(options.messageCompiler) + ? options.messageCompiler + : _compiler; + const messageResolver = isFunction(options.messageResolver) + ? options.messageResolver + : _resolver || resolveWithKeyValue; + const localeFallbacker = isFunction(options.localeFallbacker) + ? options.localeFallbacker + : _fallbacker || fallbackWithSimple; + const fallbackContext = isObject(options.fallbackContext) + ? options.fallbackContext + : undefined; + // setup internal options + const internalOptions = options; + const __datetimeFormatters = isObject(internalOptions.__datetimeFormatters) + ? internalOptions.__datetimeFormatters + : new Map() + ; + const __numberFormatters = isObject(internalOptions.__numberFormatters) + ? internalOptions.__numberFormatters + : new Map() + ; + const __meta = isObject(internalOptions.__meta) ? internalOptions.__meta : {}; + _cid++; + const context = { + version, + cid: _cid, + locale, + fallbackLocale, + messages, + modifiers, + pluralRules, + missing, + missingWarn, + fallbackWarn, + fallbackFormat, + unresolving, + postTranslation, + processor, + warnHtmlMessage, + escapeParameter, + messageCompiler, + messageResolver, + localeFallbacker, + fallbackContext, + onWarn, + __meta + }; + { + context.datetimeFormats = datetimeFormats; + context.numberFormats = numberFormats; + context.__datetimeFormatters = __datetimeFormatters; + context.__numberFormatters = __numberFormatters; + } + // for vue-devtools timeline event + { + context.__v_emitter = + internalOptions.__v_emitter != null + ? internalOptions.__v_emitter + : undefined; + } + // NOTE: experimental !! + { + initI18nDevTools(context, version, __meta); + } + return context; + } + const createResources = (locale) => ({ [locale]: create() }); + /** @internal */ + function isTranslateFallbackWarn(fallback, key) { + return fallback instanceof RegExp ? fallback.test(key) : fallback; + } + /** @internal */ + function isTranslateMissingWarn(missing, key) { + return missing instanceof RegExp ? missing.test(key) : missing; + } + /** @internal */ + function handleMissing(context, key, locale, missingWarn, type) { + const { missing, onWarn } = context; + // for vue-devtools timeline event + { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("missing" /* VueDevToolsTimelineEvents.MISSING */, { + locale, + key, + type, + groupId: `${type}:${key}` + }); + } + } + if (missing !== null) { + const ret = missing(context, locale, key, type); + return isString(ret) ? ret : key; + } + else { + if (isTranslateMissingWarn(missingWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.NOT_FOUND_KEY, { key, locale })); + } + return key; + } + } + /** @internal */ + function updateFallbackLocale(ctx, locale, fallback) { + const context = ctx; + context.__localeChainCache = new Map(); + ctx.localeFallbacker(ctx, fallback, locale); + } + /** @internal */ + function isAlmostSameLocale(locale, compareLocale) { + if (locale === compareLocale) + return false; + return locale.split('-')[0] === compareLocale.split('-')[0]; + } + /** @internal */ + function isImplicitFallback(targetLocale, locales) { + const index = locales.indexOf(targetLocale); + if (index === -1) { + return false; + } + for (let i = index + 1; i < locales.length; i++) { + if (isAlmostSameLocale(targetLocale, locales[i])) { + return true; + } + } + return false; + } + /* eslint-enable @typescript-eslint/no-explicit-any */ + + function format(ast) { + const msg = (ctx) => formatParts(ctx, ast); + return msg; + } + function formatParts(ctx, ast) { + const body = resolveBody(ast); + if (body == null) { + throw createUnhandleNodeError(0 /* NodeTypes.Resource */); + } + const type = resolveType(body); + if (type === 1 /* NodeTypes.Plural */) { + const plural = body; + const cases = resolveCases(plural); + return ctx.plural(cases.reduce((messages, c) => [ + ...messages, + formatMessageParts(ctx, c) + ], [])); + } + else { + return formatMessageParts(ctx, body); + } + } + function formatMessageParts(ctx, node) { + const static_ = resolveStatic(node); + if (static_ != null) { + return ctx.type === 'text' + ? static_ + : ctx.normalize([static_]); + } + else { + const messages = resolveItems(node).reduce((acm, c) => [...acm, formatMessagePart(ctx, c)], []); + return ctx.normalize(messages); + } + } + function formatMessagePart(ctx, node) { + const type = resolveType(node); + switch (type) { + case 3 /* NodeTypes.Text */: { + return resolveValue$1(node, type); + } + case 9 /* NodeTypes.Literal */: { + return resolveValue$1(node, type); + } + case 4 /* NodeTypes.Named */: { + const named = node; + if (hasOwn(named, 'k') && named.k) { + return ctx.interpolate(ctx.named(named.k)); + } + if (hasOwn(named, 'key') && named.key) { + return ctx.interpolate(ctx.named(named.key)); + } + throw createUnhandleNodeError(type); + } + case 5 /* NodeTypes.List */: { + const list = node; + if (hasOwn(list, 'i') && isNumber(list.i)) { + return ctx.interpolate(ctx.list(list.i)); + } + if (hasOwn(list, 'index') && isNumber(list.index)) { + return ctx.interpolate(ctx.list(list.index)); + } + throw createUnhandleNodeError(type); + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + const modifier = resolveLinkedModifier(linked); + const key = resolveLinkedKey(linked); + return ctx.linked(formatMessagePart(ctx, key), modifier ? formatMessagePart(ctx, modifier) : undefined, ctx.type); + } + case 7 /* NodeTypes.LinkedKey */: { + return resolveValue$1(node, type); + } + case 8 /* NodeTypes.LinkedModifier */: { + return resolveValue$1(node, type); + } + default: + throw new Error(`unhandled node on format message part: ${type}`); + } + } + + const WARN_MESSAGE = `Detected HTML in '{source}' message. Recommend not using HTML messages to avoid XSS.`; + function checkHtmlMessage(source, warnHtmlMessage) { + if (warnHtmlMessage && detectHtmlTag(source)) { + warn(format$1(WARN_MESSAGE, { source })); + } + } + const defaultOnCacheKey = (message) => message; + let compileCache = create(); + function onCompileWarn(_warn) { + if (_warn.code === CompileWarnCodes.USE_MODULO_SYNTAX) { + warn(`The use of named interpolation with modulo syntax is deprecated. ` + + `It will be removed in v10.\n` + + `reference: https://vue-i18n.intlify.dev/guide/essentials/syntax#rails-i18n-format \n` + + `(message compiler warning message: ${_warn.message})`); + } + } + function clearCompileCache() { + compileCache = create(); + } + function baseCompile(message, options = {}) { + // error detecting on compile + let detectError = false; + const onError = options.onError || defaultOnError; + options.onError = (err) => { + detectError = true; + onError(err); + }; + // compile with mesasge-compiler + return { ...baseCompile$1(message, options), detectError }; + } + /* #__NO_SIDE_EFFECTS__ */ + const compileToFunction = (message, context) => { + if (!isString(message)) { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE); + } + // set onWarn + { + context.onWarn = onCompileWarn; + } + { + // check HTML message + const warnHtmlMessage = isBoolean(context.warnHtmlMessage) + ? context.warnHtmlMessage + : true; + checkHtmlMessage(message, warnHtmlMessage); + // check caches + const onCacheKey = context.onCacheKey || defaultOnCacheKey; + const cacheKey = onCacheKey(message); + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compile + const { code, detectError } = baseCompile(message, context); + // evaluate function + const msg = new Function(`return ${code}`)(); + // if occurred compile error, don't cache + return !detectError + ? (compileCache[cacheKey] = msg) + : msg; + } + }; + function compile(message, context) { + // set onWarn + { + context.onWarn = onCompileWarn; + } + if (isString(message)) { + // check HTML message + const warnHtmlMessage = isBoolean(context.warnHtmlMessage) + ? context.warnHtmlMessage + : true; + checkHtmlMessage(message, warnHtmlMessage); + // check caches + const onCacheKey = context.onCacheKey || defaultOnCacheKey; + const cacheKey = onCacheKey(message); + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compile with JIT mode + const { ast, detectError } = baseCompile(message, { + ...context, + location: true, + jit: true + }); + // compose message function from AST + const msg = format(ast); + // if occurred compile error, don't cache + return !detectError + ? (compileCache[cacheKey] = msg) + : msg; + } + else { + if (!isMessageAST(message)) { + warn(`the message that is resolve with key '${context.key}' is not supported for jit compilation`); + return (() => message); + } + // AST case (passed from bundler) + const cacheKey = message.cacheKey; + if (cacheKey) { + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compose message function from message (AST) + return (compileCache[cacheKey] = + format(message)); + } + else { + return format(message); + } + } + } + + const NOOP_MESSAGE_FUNCTION = () => ''; + const isMessageFunction = (val) => isFunction(val); + // implementation of `translate` function + function translate(context, ...args) { + const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context; + const [key, options] = parseTranslateArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const escapeParameter = isBoolean(options.escapeParameter) + ? options.escapeParameter + : context.escapeParameter; + const resolvedMessage = !!options.resolvedMessage; + // prettier-ignore + const defaultMsgOrKey = isString(options.default) || isBoolean(options.default) // default by function option + ? !isBoolean(options.default) + ? options.default + : (!messageCompiler ? () => key : key) + : fallbackFormat // default by `fallbackFormat` option + ? (!messageCompiler ? () => key : key) + : ''; + const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== ''; + const locale = getLocale(context, options); + // escape params + escapeParameter && escapeParams(options); + // resolve message format + // eslint-disable-next-line prefer-const + let [formatScope, targetLocale, message] = !resolvedMessage + ? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) + : [ + key, + locale, + messages[locale] || create() + ]; + // NOTE: + // Fix to work around `ssrTransfrom` bug in Vite. + // https://github.com/vitejs/vite/issues/4306 + // To get around this, use temporary variables. + // https://github.com/nuxt/framework/issues/1461#issuecomment-954606243 + let format = formatScope; + // if you use default message, set it as message format! + let cacheBaseKey = key; + if (!resolvedMessage && + !(isString(format) || + isMessageAST(format) || + isMessageFunction(format))) { + if (enableDefaultMsg) { + format = defaultMsgOrKey; + cacheBaseKey = format; + } + } + // checking message format and target locale + if (!resolvedMessage && + (!(isString(format) || + isMessageAST(format) || + isMessageFunction(format)) || + !isString(targetLocale))) { + return unresolving ? NOT_REOSLVED : key; + } + // TODO: refactor + if (isString(format) && context.messageCompiler == null) { + warn(`The message format compilation is not supported in this build. ` + + `Because message compiler isn't included. ` + + `You need to pre-compilation all message format. ` + + `So translate function return '${key}'.`); + return key; + } + // setup compile error detecting + let occurred = false; + const onError = () => { + occurred = true; + }; + // compile message format + const msg = !isMessageFunction(format) + ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) + : format; + // if occurred compile error, return the message format + if (occurred) { + return format; + } + // evaluate message with context + const ctxOptions = getMessageContextOptions(context, targetLocale, message, options); + const msgContext = createMessageContext(ctxOptions); + const messaged = evaluateMessage(context, msg, msgContext); + // if use post translation option, proceed it with handler + let ret = postTranslation + ? postTranslation(messaged, key) + : messaged; + // apply HTML sanitization for security + if (escapeParameter && isString(ret)) { + ret = sanitizeTranslatedHtml(ret); + } + // NOTE: experimental !! + { + // prettier-ignore + const payloads = { + timestamp: Date.now(), + key: isString(key) + ? key + : isMessageFunction(format) + ? format.key + : '', + locale: targetLocale || (isMessageFunction(format) + ? format.locale + : ''), + format: isString(format) + ? format + : isMessageFunction(format) + ? format.source + : '', + message: ret + }; + payloads.meta = assign({}, context.__meta, getAdditionalMeta() || {}); + translateDevTools(payloads); + } + return ret; + } + function escapeParams(options) { + if (isArray(options.list)) { + options.list = options.list.map(item => isString(item) ? escapeHtml(item) : item); + } + else if (isObject(options.named)) { + Object.keys(options.named).forEach(key => { + if (isString(options.named[key])) { + options.named[key] = escapeHtml(options.named[key]); + } + }); + } + } + function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) { + const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context; + const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any + let message = create(); + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'translate'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + !isAlmostSameLocale(locale, targetLocale) && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_TRANSLATE, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + message = + messages[targetLocale] || create(); + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-resolve-start'; + endTag = 'intlify-message-resolve-end'; + mark && mark(startTag); + } + if ((format = resolveValue(message, key)) === null) { + // if null, resolve with object key path + format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any + } + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start && format) { + emitter.emit("message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, { + type: "message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, + key, + message: format, + time: end - start, + groupId: `${type}:${key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message resolve', startTag, endTag); + } + } + if (isString(format) || isMessageAST(format) || isMessageFunction(format)) { + break; + } + if (!isImplicitFallback(targetLocale, locales)) { + const missingRet = handleMissing(context, // eslint-disable-line @typescript-eslint/no-explicit-any + key, targetLocale, missingWarn, type); + if (missingRet !== key) { + format = missingRet; + } + } + from = to; + } + return [format, targetLocale, message]; + } + function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) { + const { messageCompiler, warnHtmlMessage } = context; + if (isMessageFunction(format)) { + const msg = format; + msg.locale = msg.locale || targetLocale; + msg.key = msg.key || key; + return msg; + } + if (messageCompiler == null) { + const msg = (() => format); + msg.locale = targetLocale; + msg.key = key; + return msg; + } + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-compilation-start'; + endTag = 'intlify-message-compilation-end'; + mark && mark(startTag); + } + const msg = messageCompiler(format, getCompileContext(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, onError)); + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, { + type: "message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, + message: format, + time: end - start, + groupId: `${'translate'}:${key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message compilation', startTag, endTag); + } + } + msg.locale = targetLocale; + msg.key = key; + msg.source = format; + return msg; + } + function evaluateMessage(context, msg, msgCtx) { + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-evaluation-start'; + endTag = 'intlify-message-evaluation-end'; + mark && mark(startTag); + } + const messaged = msg(msgCtx); + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, { + type: "message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, + value: messaged, + time: end - start, + groupId: `${'translate'}:${msg.key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message evaluation', startTag, endTag); + } + } + return messaged; + } + /** @internal */ + function parseTranslateArgs(...args) { + const [arg1, arg2, arg3] = args; + const options = create(); + if (!isString(arg1) && + !isNumber(arg1) && + !isMessageFunction(arg1) && + !isMessageAST(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + // prettier-ignore + const key = isNumber(arg1) + ? String(arg1) + : isMessageFunction(arg1) + ? arg1 + : arg1; + if (isNumber(arg2)) { + options.plural = arg2; + } + else if (isString(arg2)) { + options.default = arg2; + } + else if (isPlainObject(arg2) && !isEmptyObject(arg2)) { + options.named = arg2; + } + else if (isArray(arg2)) { + options.list = arg2; + } + if (isNumber(arg3)) { + options.plural = arg3; + } + else if (isString(arg3)) { + options.default = arg3; + } + else if (isPlainObject(arg3)) { + assign(options, arg3); + } + return [key, options]; + } + function getCompileContext(context, locale, key, source, warnHtmlMessage, onError) { + return { + locale, + key, + warnHtmlMessage, + onError: (err) => { + onError && onError(err); + { + const _source = getSourceForCodeFrame(source); + const message = `Message compilation error: ${err.message}`; + const codeFrame = err.location && + _source && + generateCodeFrame(_source, err.location.start.offset, err.location.end.offset); + const emitter = context.__v_emitter; + if (emitter && _source) { + emitter.emit("compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */, { + message: _source, + error: err.message, + start: err.location && err.location.start.offset, + end: err.location && err.location.end.offset, + groupId: `${'translate'}:${key}` + }); + } + console.error(codeFrame ? `${message}\n${codeFrame}` : message); + } + }, + onCacheKey: (source) => generateFormatCacheKey(locale, key, source) + }; + } + function getSourceForCodeFrame(source) { + if (isString(source)) { + return source; + } + else { + if (source.loc && source.loc.source) { + return source.loc.source; + } + } + } + function getMessageContextOptions(context, locale, message, options) { + const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context; + const resolveMessage = (key) => { + let val = resolveValue(message, key); + // fallback to root context + if (val == null && fallbackContext) { + const [, , message] = resolveMessageFormat(fallbackContext, key, locale, fallbackLocale, fallbackWarn, missingWarn); + val = resolveValue(message, key); + } + if (isString(val) || isMessageAST(val)) { + let occurred = false; + const onError = () => { + occurred = true; + }; + const msg = compileMessageFormat(context, key, locale, val, key, onError); + return !occurred + ? msg + : NOOP_MESSAGE_FUNCTION; + } + else if (isMessageFunction(val)) { + return val; + } + else { + // TODO: should be implemented warning message + return NOOP_MESSAGE_FUNCTION; + } + }; + const ctxOptions = { + locale, + modifiers, + pluralRules, + messages: resolveMessage + }; + if (context.processor) { + ctxOptions.processor = context.processor; + } + if (options.list) { + ctxOptions.list = options.list; + } + if (options.named) { + ctxOptions.named = options.named; + } + if (isNumber(options.plural)) { + ctxOptions.pluralIndex = options.plural; + } + return ctxOptions; + } + + const intlDefined = typeof Intl !== 'undefined'; + const Availabilities = { + dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined', + numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined' + }; + + // implementation of `datetime` function + function datetime(context, ...args) { + const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __datetimeFormatters } = context; + if (!Availabilities.dateTimeFormat) { + onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_DATE)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseDateTimeArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!isString(key) || key === '') { + return new Intl.DateTimeFormat(locale, overrides).format(value); + } + // resolve format + let datetimeFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'datetime format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + datetimeFormat = + datetimeFormats[targetLocale] || {}; + format = datetimeFormat[key]; + if (isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!isPlainObject(format) || !isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __datetimeFormatters.get(id); + if (!formatter) { + formatter = new Intl.DateTimeFormat(targetLocale, assign({}, format, overrides)); + __datetimeFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); + } + /** @internal */ + const DATETIME_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'weekday', + 'era', + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second', + 'timeZoneName', + 'formatMatcher', + 'hour12', + 'timeZone', + 'dateStyle', + 'timeStyle', + 'calendar', + 'dayPeriod', + 'numberingSystem', + 'hourCycle', + 'fractionalSecondDigits' + ]; + /** @internal */ + function parseDateTimeArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = create(); + let overrides = create(); + let value; + if (isString(arg1)) { + // Only allow ISO strings - other date formats are often supported, + // but may cause different results in different browsers. + const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/); + if (!matches) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + // Some browsers can not parse the iso datetime separated by space, + // this is a compromise solution by replace the 'T'/' ' with 'T' + const dateTime = matches[3] + ? matches[3].trim().startsWith('T') + ? `${matches[1].trim()}${matches[3].trim()}` + : `${matches[1].trim()}T${matches[3].trim()}` + : matches[1].trim(); + value = new Date(dateTime); + try { + // This will fail if the date is not valid + value.toISOString(); + } + catch (e) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + } + else if (isDate(arg1)) { + if (isNaN(arg1.getTime())) { + throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT); + } + value = arg1; + } + else if (isNumber(arg1)) { + value = arg1; + } + else { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + if (isString(arg2)) { + options.key = arg2; + } + else if (isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isPlainObject(arg3)) { + overrides = arg3; + } + if (isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; + } + /** @internal */ + function clearDateTimeFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__datetimeFormatters.has(id)) { + continue; + } + context.__datetimeFormatters.delete(id); + } + } + + // implementation of `number` function + function number(context, ...args) { + const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __numberFormatters } = context; + if (!Availabilities.numberFormat) { + onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_NUMBER)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseNumberArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!isString(key) || key === '') { + return new Intl.NumberFormat(locale, overrides).format(value); + } + // resolve format + let numberFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'number format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + numberFormat = + numberFormats[targetLocale] || {}; + format = numberFormat[key]; + if (isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!isPlainObject(format) || !isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __numberFormatters.get(id); + if (!formatter) { + formatter = new Intl.NumberFormat(targetLocale, assign({}, format, overrides)); + __numberFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); + } + /** @internal */ + const NUMBER_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'style', + 'currency', + 'currencyDisplay', + 'currencySign', + 'useGrouping', + 'minimumIntegerDigits', + 'minimumFractionDigits', + 'maximumFractionDigits', + 'minimumSignificantDigits', + 'maximumSignificantDigits', + 'compactDisplay', + 'notation', + 'signDisplay', + 'unit', + 'unitDisplay', + 'roundingMode', + 'roundingPriority', + 'roundingIncrement', + 'trailingZeroDisplay' + ]; + /** @internal */ + function parseNumberArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = create(); + let overrides = create(); + if (!isNumber(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + const value = arg1; + if (isString(arg2)) { + options.key = arg2; + } + else if (isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isPlainObject(arg3)) { + overrides = arg3; + } + if (isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; + } + /** @internal */ + function clearNumberFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__numberFormatters.has(id)) { + continue; + } + context.__numberFormatters.delete(id); + } + } + + exports.AST_NODE_PROPS_KEYS = AST_NODE_PROPS_KEYS; + exports.CompileErrorCodes = CompileErrorCodes; + exports.CoreErrorCodes = CoreErrorCodes; + exports.CoreWarnCodes = CoreWarnCodes; + exports.DATETIME_FORMAT_OPTIONS_KEYS = DATETIME_FORMAT_OPTIONS_KEYS; + exports.DEFAULT_LOCALE = DEFAULT_LOCALE; + exports.DEFAULT_MESSAGE_DATA_TYPE = DEFAULT_MESSAGE_DATA_TYPE; + exports.MISSING_RESOLVE_VALUE = MISSING_RESOLVE_VALUE; + exports.NOT_REOSLVED = NOT_REOSLVED; + exports.NUMBER_FORMAT_OPTIONS_KEYS = NUMBER_FORMAT_OPTIONS_KEYS; + exports.VERSION = VERSION; + exports.clearCompileCache = clearCompileCache; + exports.clearDateTimeFormat = clearDateTimeFormat; + exports.clearNumberFormat = clearNumberFormat; + exports.compile = compile; + exports.compileToFunction = compileToFunction; + exports.createCompileError = createCompileError; + exports.createCoreContext = createCoreContext; + exports.createCoreError = createCoreError; + exports.createMessageContext = createMessageContext; + exports.datetime = datetime; + exports.fallbackWithLocaleChain = fallbackWithLocaleChain; + exports.fallbackWithSimple = fallbackWithSimple; + exports.getAdditionalMeta = getAdditionalMeta; + exports.getDevToolsHook = getDevToolsHook; + exports.getFallbackContext = getFallbackContext; + exports.getLocale = getLocale; + exports.getWarnMessage = getWarnMessage; + exports.handleMissing = handleMissing; + exports.initI18nDevTools = initI18nDevTools; + exports.isAlmostSameLocale = isAlmostSameLocale; + exports.isImplicitFallback = isImplicitFallback; + exports.isMessageAST = isMessageAST; + exports.isMessageFunction = isMessageFunction; + exports.isTranslateFallbackWarn = isTranslateFallbackWarn; + exports.isTranslateMissingWarn = isTranslateMissingWarn; + exports.number = number; + exports.parse = parse; + exports.parseDateTimeArgs = parseDateTimeArgs; + exports.parseNumberArgs = parseNumberArgs; + exports.parseTranslateArgs = parseTranslateArgs; + exports.registerLocaleFallbacker = registerLocaleFallbacker; + exports.registerMessageCompiler = registerMessageCompiler; + exports.registerMessageResolver = registerMessageResolver; + exports.resolveLocale = resolveLocale; + exports.resolveValue = resolveValue; + exports.resolveWithKeyValue = resolveWithKeyValue; + exports.setAdditionalMeta = setAdditionalMeta; + exports.setDevToolsHook = setDevToolsHook; + exports.setFallbackContext = setFallbackContext; + exports.translate = translate; + exports.translateDevTools = translateDevTools; + exports.updateFallbackLocale = updateFallbackLocale; + + return exports; + +})({}); diff --git a/node_modules/@intlify/core-base/dist/core-base.global.prod.js b/node_modules/@intlify/core-base/dist/core-base.global.prod.js new file mode 100644 index 0000000..ab78049 --- /dev/null +++ b/node_modules/@intlify/core-base/dist/core-base.global.prod.js @@ -0,0 +1,6 @@ +/*! + * core-base v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +var IntlifyCoreBase=function(e){"use strict";function t(e,t){"undefined"!=typeof console&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}const n=/\{([0-9a-zA-Z]+)\}/g;const r=(e,t,n)=>o({l:e,k:t,s:n}),o=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),c=e=>"number"==typeof e&&isFinite(e),s=e=>"[object Date]"===k(e),a=e=>"[object RegExp]"===k(e),l=e=>O(e)&&0===Object.keys(e).length,i=Object.assign,u=Object.create,f=(e=null)=>u(e);function E(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/").replace(/=/g,"=")}function _(e){return e.replace(/&(?![a-zA-Z0-9#]{2,6};)/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")}const m=Object.prototype.hasOwnProperty;function p(e,t){return m.call(e,t)}const d=Array.isArray,N=e=>"function"==typeof e,T=e=>"string"==typeof e,L=e=>"boolean"==typeof e,A=e=>null!==e&&"object"==typeof e,C=e=>A(e)&&N(e.then)&&N(e.catch),h=Object.prototype.toString,k=e=>h.call(e),O=e=>{if(!A(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t.constructor===Object};function g(e,t=""){return e.reduce(((e,n,r)=>0===r?e+n:e+t+n),"")}function I(e){let t=e;return()=>++t}function S(e,t,n){const r={start:e,end:t};return null!=n&&(r.source=n),r}const y={USE_MODULO_SYNTAX:1,__EXTEND_POINT__:2};const b={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16,__EXTEND_POINT__:17};function P(e,t,n={}){const{domain:r,messages:o,args:c}=n,s=new SyntaxError(String(e));return s.code=e,t&&(s.location=t),s.domain=r,s}function D(e){throw e}b.EXPECTED_TOKEN,b.INVALID_TOKEN_IN_PLACEHOLDER,b.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,b.UNKNOWN_ESCAPE_SEQUENCE,b.INVALID_UNICODE_ESCAPE_SEQUENCE,b.UNBALANCED_CLOSING_BRACE,b.UNTERMINATED_CLOSING_BRACE,b.EMPTY_PLACEHOLDER,b.NOT_ALLOW_NEST_PLACEHOLDER,b.INVALID_LINKED_FORMAT,b.MUST_HAVE_MESSAGES_IN_PLURAL,b.UNEXPECTED_EMPTY_LINKED_MODIFIER,b.UNEXPECTED_EMPTY_LINKED_KEY,b.UNEXPECTED_LEXICAL_ANALYSIS,b.UNHANDLED_CODEGEN_NODE_TYPE,b.UNHANDLED_MINIFIER_NODE_TYPE;const M=" ",R="\r",U="\n",v=String.fromCharCode(8232),x=String.fromCharCode(8233);function F(e){const t=e;let n=0,r=1,o=1,c=0;const s=e=>t[e]===R&&t[e+1]===U,a=e=>t[e]===x,l=e=>t[e]===v,i=e=>s(e)||(e=>t[e]===U)(e)||a(e)||l(e),u=e=>s(e)||a(e)||l(e)?U:t[e];function f(){return c=0,i(n)&&(r++,o=0),s(n)&&n++,n++,o++,t[n]}return{index:()=>n,line:()=>r,column:()=>o,peekOffset:()=>c,charAt:u,currentChar:()=>u(n),currentPeek:()=>u(n+c),next:f,peek:function(){return s(n+c)&&c++,c++,t[n+c]},reset:function(){n=0,r=1,o=1,c=0},resetPeek:function(e=0){c=e},skipToPeek:function(){const e=n+c;for(;e!==n;)f();c=0}}}const w=void 0,W="'";function X(e,t={}){const n=!1!==t.location,r=F(e),o=()=>r.index(),c=()=>{return e=r.line(),t=r.column(),n=r.index(),{line:e,column:t,offset:n};var e,t,n},s=c(),a=o(),l={currentType:14,offset:a,startLoc:s,endLoc:s,lastType:14,lastOffset:a,lastStartLoc:s,lastEndLoc:s,braceNest:0,inLinked:!1,text:""},i=()=>l,{onError:u}=t;function f(e,t,r){e.endLoc=c(),e.currentType=t;const o={type:t};return n&&(o.loc=S(e.startLoc,e.endLoc)),null!=r&&(o.value=r),o}const E=e=>f(e,14);function _(e,t){return e.currentChar()===t?(e.next(),t):(b.EXPECTED_TOKEN,c(),"")}function m(e){let t="";for(;e.currentPeek()===M||e.currentPeek()===U;)t+=e.currentPeek(),e.peek();return t}function p(e){const t=m(e);return e.skipToPeek(),t}function d(e){if(e===w)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function N(e,t){const{currentType:n}=t;if(2!==n)return!1;m(e);const r=function(e){if(e===w)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function T(e){m(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function L(e,t=!0){const n=(t=!1,r="",o=!1)=>{const c=e.currentPeek();return"{"===c?"%"!==r&&t:"@"!==c&&c?"%"===c?(e.peek(),n(t,"%",!0)):"|"===c?!("%"!==r&&!o)||!(r===M||r===U):c===M?(e.peek(),n(!0,M,o)):c!==U||(e.peek(),n(!0,U,o)):"%"===r||t},r=n();return t&&e.resetPeek(),r}function A(e,t){const n=e.currentChar();return n===w?w:t(n)?(e.next(),n):null}function C(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t}function h(e){return A(e,C)}function k(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t||45===t}function O(e){return A(e,k)}function g(e){const t=e.charCodeAt(0);return t>=48&&t<=57}function I(e){return A(e,g)}function y(e){const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function P(e){return A(e,y)}function D(e){let t="",n="";for(;t=I(e);)n+=t;return n}function R(e){let t="";for(;;){const n=e.currentChar();if("{"===n||"}"===n||"@"===n||"|"===n||!n)break;if("%"===n){if(!L(e))break;t+=n,e.next()}else if(n===M||n===U)if(L(e))t+=n,e.next();else{if(T(e))break;t+=n,e.next()}else t+=n,e.next()}return t}function v(e){return e!==W&&e!==U}function x(e){const t=e.currentChar();switch(t){case"\\":case"'":return e.next(),`\\${t}`;case"u":return X(e,t,4);case"U":return X(e,t,6);default:return b.UNKNOWN_ESCAPE_SEQUENCE,c(),""}}function X(e,t,n){_(e,t);let r="";for(let o=0;o=1&&(b.NOT_ALLOW_NEST_PLACEHOLDER,c()),e.next(),n=f(t,2,"{"),p(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&(b.EMPTY_PLACEHOLDER,c()),e.next(),n=f(t,3,"}"),t.braceNest--,t.braceNest>0&&p(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),n;case"@":return t.braceNest>0&&(b.UNTERMINATED_CLOSING_BRACE,c()),n=G(e,t)||E(t),t.braceNest=0,n;default:{let r=!0,o=!0,s=!0;if(T(e))return t.braceNest>0&&(b.UNTERMINATED_CLOSING_BRACE,c()),n=f(t,1,Y(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(5===t.currentType||6===t.currentType||7===t.currentType))return b.UNTERMINATED_CLOSING_BRACE,c(),t.braceNest=0,V(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;m(e);const r=d(e.currentPeek());return e.resetPeek(),r}(e,t))return n=f(t,5,function(e){p(e);let t="",n="";for(;t=O(e);)n+=t;return e.currentChar()===w&&(b.UNTERMINATED_CLOSING_BRACE,c()),n}(e)),p(e),n;if(o=N(e,t))return n=f(t,6,function(e){p(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${D(e)}`):t+=D(e),e.currentChar()===w&&(b.UNTERMINATED_CLOSING_BRACE,c()),t}(e)),p(e),n;if(s=function(e,t){const{currentType:n}=t;if(2!==n)return!1;m(e);const r=e.currentPeek()===W;return e.resetPeek(),r}(e,t))return n=f(t,7,function(e){p(e),_(e,"'");let t="",n="";for(;t=A(e,v);)n+="\\"===t?x(e):t;const r=e.currentChar();return r===U||r===w?(b.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,c(),r===U&&(e.next(),_(e,"'")),n):(_(e,"'"),n)}(e)),p(e),n;if(!r&&!o&&!s)return n=f(t,13,function(e){p(e);let t="",n="";for(;t=A(e,$);)n+=t;return n}(e)),b.INVALID_TOKEN_IN_PLACEHOLDER,c(),n.value,p(e),n;break}}return n}function G(e,t){const{currentType:n}=t;let r=null;const o=e.currentChar();switch(8!==n&&9!==n&&12!==n&&10!==n||o!==U&&o!==M||(b.INVALID_LINKED_FORMAT,c()),o){case"@":return e.next(),r=f(t,8,"@"),t.inLinked=!0,r;case".":return p(e),e.next(),f(t,9,".");case":":return p(e),e.next(),f(t,10,":");default:return T(e)?(r=f(t,1,Y(e)),t.braceNest=0,t.inLinked=!1,r):function(e,t){const{currentType:n}=t;if(8!==n)return!1;m(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,t)||function(e,t){const{currentType:n}=t;if(8!==n&&12!==n)return!1;m(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,t)?(p(e),G(e,t)):function(e,t){const{currentType:n}=t;if(9!==n)return!1;m(e);const r=d(e.currentPeek());return e.resetPeek(),r}(e,t)?(p(e),f(t,12,function(e){let t="",n="";for(;t=h(e);)n+=t;return n}(e))):function(e,t){const{currentType:n}=t;if(10!==n)return!1;const r=()=>{const t=e.currentPeek();return"{"===t?d(e.peek()):!("@"===t||"%"===t||"|"===t||":"===t||"."===t||t===M||!t)&&(t===U?(e.peek(),r()):L(e,!1))},o=r();return e.resetPeek(),o}(e,t)?(p(e),"{"===o?K(e,t)||r:f(t,11,function(e){const t=n=>{const r=e.currentChar();return"{"!==r&&"%"!==r&&"@"!==r&&"|"!==r&&"("!==r&&")"!==r&&r?r===M?n:(n+=r,e.next(),t(n)):n};return t("")}(e))):(8===n&&(b.INVALID_LINKED_FORMAT,c()),t.braceNest=0,t.inLinked=!1,V(e,t))}}function V(e,t){let n={type:14};if(t.braceNest>0)return K(e,t)||E(t);if(t.inLinked)return G(e,t)||E(t);switch(e.currentChar()){case"{":return K(e,t)||E(t);case"}":return b.UNBALANCED_CLOSING_BRACE,c(),e.next(),f(t,3,"}");case"@":return G(e,t)||E(t);default:{if(T(e))return n=f(t,1,Y(e)),t.braceNest=0,t.inLinked=!1,n;const{isModulo:r,hasSpace:o}=function(e){const t=m(e),n="%"===e.currentPeek()&&"{"===e.peek();return e.resetPeek(),{isModulo:n,hasSpace:t.length>0}}(e);if(r)return o?f(t,0,R(e)):f(t,4,function(e){p(e);const t=e.currentChar();return"%"!==t&&(b.EXPECTED_TOKEN,c()),e.next(),"%"}(e));if(L(e))return f(t,0,R(e));break}}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:s}=l;return l.lastType=e,l.lastOffset=t,l.lastStartLoc=n,l.lastEndLoc=s,l.offset=o(),l.startLoc=c(),r.currentChar()===w?f(l,14):V(r,l)},currentOffset:o,currentPosition:c,context:i}}const $=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function Y(e,t,n){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const e=parseInt(t||n,16);return e<=55295||e>=57344?String.fromCodePoint(e):"�"}}}function K(e={}){const t=!1!==e.location,{onError:n,onWarn:r}=e;function o(e,n,r){const o={type:e};return t&&(o.start=n,o.end=n,o.loc={start:r,end:r}),o}function c(e,n,r,o){o&&(e.type=o),t&&(e.end=n,e.loc&&(e.loc.end=r))}function s(e,t){const n=e.context(),r=o(3,n.offset,n.startLoc);return r.value=t,c(r,e.currentOffset(),e.currentPosition()),r}function a(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:s}=n,a=o(5,r,s);return a.index=parseInt(t,10),e.nextToken(),c(a,e.currentOffset(),e.currentPosition()),a}function l(e,t,n){const r=e.context(),{lastOffset:s,lastStartLoc:a}=r,l=o(4,s,a);return l.key=t,!0===n&&(l.modulo=!0),e.nextToken(),c(l,e.currentOffset(),e.currentPosition()),l}function u(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:s}=n,a=o(9,r,s);return a.value=t.replace($,Y),e.nextToken(),c(a,e.currentOffset(),e.currentPosition()),a}function f(e){const t=e.context(),n=o(6,t.offset,t.startLoc);let r=e.nextToken();if(9===r.type){const t=function(e){const t=e.nextToken(),n=e.context(),{lastOffset:r,lastStartLoc:s}=n,a=o(8,r,s);return 12!==t.type?(b.UNEXPECTED_EMPTY_LINKED_MODIFIER,n.lastStartLoc,a.value="",c(a,r,s),{nextConsumeToken:t,node:a}):(null==t.value&&(b.UNEXPECTED_LEXICAL_ANALYSIS,n.lastStartLoc,G(t)),a.value=t.value||"",c(a,e.currentOffset(),e.currentPosition()),{node:a})}(e);n.modifier=t.node,r=t.nextConsumeToken||e.nextToken()}switch(10!==r.type&&(b.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,G(r)),r=e.nextToken(),2===r.type&&(r=e.nextToken()),r.type){case 11:null==r.value&&(b.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,G(r)),n.key=function(e,t){const n=e.context(),r=o(7,n.offset,n.startLoc);return r.value=t,c(r,e.currentOffset(),e.currentPosition()),r}(e,r.value||"");break;case 5:null==r.value&&(b.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,G(r)),n.key=l(e,r.value||"");break;case 6:null==r.value&&(b.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,G(r)),n.key=a(e,r.value||"");break;case 7:null==r.value&&(b.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,G(r)),n.key=u(e,r.value||"");break;default:{b.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const s=e.context(),a=o(7,s.offset,s.startLoc);return a.value="",c(a,s.offset,s.startLoc),n.key=a,c(n,s.offset,s.startLoc),{nextConsumeToken:r,node:n}}}return c(n,e.currentOffset(),e.currentPosition()),{node:n}}function E(e){const t=e.context(),n=o(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let r=null,i=null;do{const o=r||e.nextToken();switch(r=null,o.type){case 0:null==o.value&&(b.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,G(o)),n.items.push(s(e,o.value||""));break;case 6:null==o.value&&(b.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,G(o)),n.items.push(a(e,o.value||""));break;case 4:i=!0;break;case 5:null==o.value&&(b.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,G(o)),n.items.push(l(e,o.value||"",!!i)),i&&(y.USE_MODULO_SYNTAX,t.lastStartLoc,G(o),i=null);break;case 7:null==o.value&&(b.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,G(o)),n.items.push(u(e,o.value||""));break;case 8:{const t=f(e);n.items.push(t.node),r=t.nextConsumeToken||null;break}}}while(14!==t.currentType&&1!==t.currentType);return c(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function _(e){const t=e.context(),{offset:n,startLoc:r}=t,s=E(e);return 14===t.currentType?s:function(e,t,n,r){const s=e.context();let a=0===r.items.length;const l=o(1,t,n);l.cases=[],l.cases.push(r);do{const t=E(e);a||(a=0===t.items.length),l.cases.push(t)}while(14!==s.currentType);return a&&b.MUST_HAVE_MESSAGES_IN_PLURAL,c(l,e.currentOffset(),e.currentPosition()),l}(e,n,r,s)}return{parse:function(n){const r=X(n,i({},e)),s=r.context(),a=o(0,s.offset,s.startLoc);return t&&a.loc&&(a.loc.source=n),a.body=_(r),e.onCacheKey&&(a.cacheKey=e.onCacheKey(n)),14!==s.currentType&&(b.UNEXPECTED_LEXICAL_ANALYSIS,s.lastStartLoc,n[s.offset]),c(a,r.currentOffset(),r.currentPosition()),a}}}function G(e){if(14===e.type)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function V(e,t){for(let n=0;nn,helper:e=>(n.helpers.add(e),e)}}(e);n.helper("normalize"),e.body&&H(e.body,n);const r=n.context();e.helpers=Array.from(r.helpers)}function j(e){if(1===e.items.length){const t=e.items[0];3!==t.type&&9!==t.type||(e.static=t.value,delete t.value)}else{const t=[];for(let n=0;n1){e.push(`${n("plural")}([`),e.indent(r());const o=t.cases.length;for(let n=0;n{const n=T(t.mode)?t.mode:"normal",r=T(t.filename)?t.filename:"message.intl",o=!!t.sourceMap,c=null!=t.breakLineCode?t.breakLineCode:"arrow"===n?";":"\n",s=t.needIndent?t.needIndent:"arrow"!==n,a=e.helpers||[],l=function(e,t){const{sourceMap:n,filename:r,breakLineCode:o,needIndent:c}=t,s=!1!==t.location,a={filename:r,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:o,needIndent:c,indentLevel:0};function l(e,t){a.code+=e}function i(e,t=!0){const n=t?o:"";l(c?n+" ".repeat(e):n)}return s&&e.loc&&(a.source=e.loc.source),{context:()=>a,push:l,indent:function(e=!0){const t=++a.indentLevel;e&&i(t)},deindent:function(e=!0){const t=--a.indentLevel;e&&i(t)},newline:function(){i(a.indentLevel)},helper:e=>`_${e}`,needIndent:()=>a.needIndent}}(e,{mode:n,filename:r,sourceMap:o,breakLineCode:c,needIndent:s});l.push("normal"===n?"function __msg__ (ctx) {":"(ctx) => {"),l.indent(s),a.length>0&&(l.push(`const { ${g(a.map((e=>`${e}: _${e}`)),", ")} } = ctx`),l.newline()),l.push("return "),Q(l,e),l.deindent(s),l.push("}"),delete e.helpers;const{code:i,map:u}=l.context();return{ast:e,code:i,map:u?u.toJSON():void 0}};function Z(e,t={}){const n=i({},t),r=!!n.jit,o=!!n.minify,c=null==n.optimize||n.optimize,s=K(n).parse(e);return r?(c&&function(e){const t=e.body;2===t.type?j(t):t.cases.forEach((e=>j(e)))}(s),o&&z(s),{ast:s,code:""}):(B(s,n),J(s,n))}function q(e){return A(e)&&0===ce(e)&&(p(e,"b")||p(e,"body"))}const ee=["b","body"];const te=["c","cases"];const ne=["s","static"];const re=["i","items"];const oe=["t","type"];function ce(e){return ue(e,oe)}const se=["v","value"];function ae(e,t){const n=ue(e,se);if(null!=n)return n;throw Ee(t)}const le=["m","modifier"];const ie=["k","key"];function ue(e,t,n){for(let r=0;r{void 0===r?r=o:r+=o},E[1]=()=>{void 0!==r&&(t.push(r),r=void 0)},E[2]=()=>{E[0](),f++},E[3]=()=>{if(f>0)f--,u=4,E[0]();else{if(f=0,void 0===r)return!1;if(r=de(r),!1===r)return!1;E[1]()}};null!==u;)if(i++,n=e[i],"\\"!==n||!_()){if(c=pe(n),l=_e[u],s=l[c]||l.l||8,8===s)return;if(u=s[0],void 0!==s[1]&&(a=E[s[1]],a&&(o=n,!1===a())))return;if(7===u)return t}}const Te=new Map;function Le(e,t){return A(e)?e[t]:null}const Ae=e=>e,Ce=e=>"",he="text",ke=e=>0===e.length?"":g(e),Oe=e=>null==e?"":d(e)||O(e)&&e.toString===h?JSON.stringify(e,null,2):String(e);function ge(e,t){return e=Math.abs(e),2===t?e?e>1?1:0:1:e?Math.min(e,2):0}function Ie(e={}){const t=e.locale,n=function(e){const t=c(e.pluralIndex)?e.pluralIndex:-1;return e.named&&(c(e.named.count)||c(e.named.n))?c(e.named.count)?e.named.count:c(e.named.n)?e.named.n:t:t}(e),r=A(e.pluralRules)&&T(t)&&N(e.pluralRules[t])?e.pluralRules[t]:ge,o=A(e.pluralRules)&&T(t)&&N(e.pluralRules[t])?ge:void 0,s=e.list||[],a=e.named||f();c(e.pluralIndex)&&function(e,t){t.count||(t.count=e),t.n||(t.n=e)}(n,a);function l(t){const n=N(e.messages)?e.messages(t):!!A(e.messages)&&e.messages[t];return n||(e.parent?e.parent.message(t):Ce)}const u=O(e.processor)&&N(e.processor.normalize)?e.processor.normalize:ke,E=O(e.processor)&&N(e.processor.interpolate)?e.processor.interpolate:Oe,_={list:e=>s[e],named:e=>a[e],plural:e=>e[r(n,e.length,o)],linked:(t,...n)=>{const[r,o]=n;let c="text",s="";1===n.length?A(r)?(s=r.modifier||s,c=r.type||c):T(r)&&(s=r||s):2===n.length&&(T(r)&&(s=r||s),T(o)&&(c=o||c));const a=l(t)(_),i="vnode"===c&&d(a)&&s?a[0]:a;return s?(u=s,e.modifiers?e.modifiers[u]:Ae)(i,c):i;var u},message:l,type:O(e.processor)&&T(e.processor.type)?e.processor.type:he,interpolate:E,normalize:u,values:i(f(),s,a)};return _}let Se=null;const ye=be("function:translate");function be(e){return t=>Se&&Se.emit(e,t)}const Pe=y.__EXTEND_POINT__,De=I(Pe),Me={NOT_FOUND_KEY:Pe,FALLBACK_TO_TRANSLATE:De(),CANNOT_FORMAT_NUMBER:De(),FALLBACK_TO_NUMBER_FORMAT:De(),CANNOT_FORMAT_DATE:De(),FALLBACK_TO_DATE_FORMAT:De(),EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER:De(),__EXTEND_POINT__:De()},Re={[Me.NOT_FOUND_KEY]:"Not found '{key}' key in '{locale}' locale messages.",[Me.FALLBACK_TO_TRANSLATE]:"Fall back to translate '{key}' key with '{target}' locale.",[Me.CANNOT_FORMAT_NUMBER]:"Cannot format a number value due to not supported Intl.NumberFormat.",[Me.FALLBACK_TO_NUMBER_FORMAT]:"Fall back to number format '{key}' key with '{target}' locale.",[Me.CANNOT_FORMAT_DATE]:"Cannot format a date value due to not supported Intl.DateTimeFormat.",[Me.FALLBACK_TO_DATE_FORMAT]:"Fall back to datetime format '{key}' key with '{target}' locale.",[Me.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]:"This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future."};const Ue=b.__EXTEND_POINT__,ve=I(Ue),xe={INVALID_ARGUMENT:Ue,INVALID_DATE_ARGUMENT:ve(),INVALID_ISO_DATE_ARGUMENT:ve(),NOT_SUPPORT_NON_STRING_MESSAGE:ve(),NOT_SUPPORT_LOCALE_PROMISE_VALUE:ve(),NOT_SUPPORT_LOCALE_ASYNC_FUNCTION:ve(),NOT_SUPPORT_LOCALE_TYPE:ve(),__EXTEND_POINT__:ve()};function Fe(e,t){return null!=t.locale?We(t.locale):We(e.locale)}let we;function We(e){if(T(e))return e;if(N(e)){if(e.resolvedOnce&&null!=we)return we;if("Function"===e.constructor.name){const t=e();if(C(t))throw Error(xe.NOT_SUPPORT_LOCALE_PROMISE_VALUE);return we=t}throw Error(xe.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION)}throw Error(xe.NOT_SUPPORT_LOCALE_TYPE)}function Xe(e,t,n){return[...new Set([n,...d(t)?t:A(t)?Object.keys(t):T(t)?[t]:[n]])]}function $e(e,t,n){let r=!0;for(let o=0;o`${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;let Be,je,ze;let Qe=null;let Je=null;let Ze=0;const qe=e=>({[e]:f()});function et(e,t,n,r,o){const{missing:c,onWarn:s}=e;if(null!==c){const r=c(e,n,t,o);return T(r)?r:t}return t}function tt(e,t){return e!==t&&e.split("-")[0]===t.split("-")[0]}function nt(e,t){const n=t.indexOf(e);if(-1===n)return!1;for(let r=n+1;rfunction(e,t){const n=(r=t,ue(r,ee));var r;if(null==n)throw Ee(0);if(1===ce(n)){const t=function(e){return ue(e,te,[])}(n);return e.plural(t.reduce(((t,n)=>[...t,ot(e,n)]),[]))}return ot(e,n)}(t,e)}function ot(e,t){const n=function(e){return ue(e,ne)}(t);if(null!=n)return"text"===e.type?n:e.normalize([n]);{const n=function(e){return ue(e,re,[])}(t).reduce(((t,n)=>[...t,ct(e,n)]),[]);return e.normalize(n)}}function ct(e,t){const n=ce(t);switch(n){case 3:case 9:case 7:case 8:return ae(t,n);case 4:{const r=t;if(p(r,"k")&&r.k)return e.interpolate(e.named(r.k));if(p(r,"key")&&r.key)return e.interpolate(e.named(r.key));throw Ee(n)}case 5:{const r=t;if(p(r,"i")&&c(r.i))return e.interpolate(e.list(r.i));if(p(r,"index")&&c(r.index))return e.interpolate(e.list(r.index));throw Ee(n)}case 6:{const n=t,r=function(e){return ue(e,le)}(n),o=function(e){const t=ue(e,ie);if(t)return t;throw Ee(6)}(n);return e.linked(ct(e,o),r?ct(e,r):void 0,e.type)}default:throw new Error(`unhandled node on format message part: ${n}`)}}const st=e=>e;let at=f();function lt(e,t={}){let n=!1;const r=t.onError||D;return t.onError=e=>{n=!0,r(e)},{...Z(e,t),detectError:n}}const it=()=>"",ut=e=>N(e);function ft(e,t,n,r,o,c){const{messages:s,onWarn:a,messageResolver:l,localeFallbacker:i}=e,u=i(e,r,n);let E,_=f(),m=null;for(let p=0;po;return e.locale=n,e.key=t,e}const i=a(o,function(e,t,n,o,c,s){return{locale:t,key:n,warnHtmlMessage:c,onError:e=>{throw s&&s(e),e},onCacheKey:e=>r(t,n,e)}}(0,n,c,0,l,s));return i.locale=n,i.key=t,i.source=o,i}function _t(...e){const[t,n,r]=e,o=f();if(!(T(t)||c(t)||ut(t)||q(t)))throw Error(xe.INVALID_ARGUMENT);const s=c(t)?String(t):(ut(t),t);return c(n)?o.plural=n:T(n)?o.default=n:O(n)&&!l(n)?o.named=n:d(n)&&(o.list=n),c(r)?o.plural=r:T(r)?o.default=r:O(r)&&i(o,r),[s,o]}const mt=["localeMatcher","weekday","era","year","month","day","hour","minute","second","timeZoneName","formatMatcher","hour12","timeZone","dateStyle","timeStyle","calendar","dayPeriod","numberingSystem","hourCycle","fractionalSecondDigits"];function pt(...e){const[t,n,r,o]=e,a=f();let l,i=f();if(T(t)){const e=t.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/);if(!e)throw Error(xe.INVALID_ISO_DATE_ARGUMENT);const n=e[3]?e[3].trim().startsWith("T")?`${e[1].trim()}${e[3].trim()}`:`${e[1].trim()}T${e[3].trim()}`:e[1].trim();l=new Date(n);try{l.toISOString()}catch(u){throw Error(xe.INVALID_ISO_DATE_ARGUMENT)}}else if(s(t)){if(isNaN(t.getTime()))throw Error(xe.INVALID_DATE_ARGUMENT);l=t}else{if(!c(t))throw Error(xe.INVALID_ARGUMENT);l=t}return T(n)?a.key=n:O(n)&&Object.keys(n).forEach((e=>{mt.includes(e)?i[e]=n[e]:a[e]=n[e]})),T(r)?a.locale=r:O(r)&&(i=r),O(o)&&(i=o),[a.key||"",l,a,i]}const dt=["localeMatcher","style","currency","currencyDisplay","currencySign","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","compactDisplay","notation","signDisplay","unit","unitDisplay","roundingMode","roundingPriority","roundingIncrement","trailingZeroDisplay"];function Nt(...e){const[t,n,r,o]=e,s=f();let a=f();if(!c(t))throw Error(xe.INVALID_ARGUMENT);const l=t;return T(n)?s.key=n:O(n)&&Object.keys(n).forEach((e=>{dt.includes(e)?a[e]=n[e]:s[e]=n[e]})),T(r)?s.locale=r:O(r)&&(a=r),O(o)&&(a=o),[s.key||"",l,s,a]}return e.AST_NODE_PROPS_KEYS=fe,e.CompileErrorCodes=b,e.CoreErrorCodes=xe,e.CoreWarnCodes=Me,e.DATETIME_FORMAT_OPTIONS_KEYS=mt,e.DEFAULT_LOCALE=Ve,e.DEFAULT_MESSAGE_DATA_TYPE=he,e.MISSING_RESOLVE_VALUE="",e.NOT_REOSLVED=-1,e.NUMBER_FORMAT_OPTIONS_KEYS=dt,e.VERSION=Ge,e.clearCompileCache=function(){at=f()},e.clearDateTimeFormat=function(e,t,n){const r=e;for(const o in n){const e=`${t}__${o}`;r.__datetimeFormatters.has(e)&&r.__datetimeFormatters.delete(e)}},e.clearNumberFormat=function(e,t,n){const r=e;for(const o in n){const e=`${t}__${o}`;r.__numberFormatters.has(e)&&r.__numberFormatters.delete(e)}},e.compile=function(e,t){if(T(e)){!L(t.warnHtmlMessage)||t.warnHtmlMessage;const n=(t.onCacheKey||st)(e),r=at[n];if(r)return r;const{ast:o,detectError:c}=lt(e,{...t,location:!1,jit:!0}),s=rt(o);return c?s:at[n]=s}{const t=e.cacheKey;if(t){const n=at[t];return n||(at[t]=rt(e))}return rt(e)}},e.compileToFunction=(e,t)=>{if(!T(e))throw Error(xe.NOT_SUPPORT_NON_STRING_MESSAGE);{!L(t.warnHtmlMessage)||t.warnHtmlMessage;const n=(t.onCacheKey||st)(e),r=at[n];if(r)return r;const{code:o,detectError:c}=lt(e,t),s=new Function(`return ${o}`)();return c?s:at[n]=s}},e.createCompileError=P,e.createCoreContext=function(e={}){const n=N(e.onWarn)?e.onWarn:t,r=T(e.version)?e.version:Ge,o=T(e.locale)||N(e.locale)?e.locale:Ve,c=N(o)?Ve:o,s=d(e.fallbackLocale)||O(e.fallbackLocale)||T(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:c,l=O(e.messages)?e.messages:qe(c),u=O(e.datetimeFormats)?e.datetimeFormats:qe(c),E=O(e.numberFormats)?e.numberFormats:qe(c),_=i(f(),e.modifiers,{upper:(e,t)=>"text"===t&&T(e)?e.toUpperCase():"vnode"===t&&A(e)&&"__v_isVNode"in e?e.children.toUpperCase():e,lower:(e,t)=>"text"===t&&T(e)?e.toLowerCase():"vnode"===t&&A(e)&&"__v_isVNode"in e?e.children.toLowerCase():e,capitalize:(e,t)=>"text"===t&&T(e)?He(e):"vnode"===t&&A(e)&&"__v_isVNode"in e?He(e.children):e}),m=e.pluralRules||f(),p=N(e.missing)?e.missing:null,C=!L(e.missingWarn)&&!a(e.missingWarn)||e.missingWarn,h=!L(e.fallbackWarn)&&!a(e.fallbackWarn)||e.fallbackWarn,k=!!e.fallbackFormat,g=!!e.unresolving,I=N(e.postTranslation)?e.postTranslation:null,S=O(e.processor)?e.processor:null,y=!L(e.warnHtmlMessage)||e.warnHtmlMessage,b=!!e.escapeParameter,P=N(e.messageCompiler)?e.messageCompiler:Be,D=N(e.messageResolver)?e.messageResolver:je||Le,M=N(e.localeFallbacker)?e.localeFallbacker:ze||Xe,R=A(e.fallbackContext)?e.fallbackContext:void 0,U=e,v=A(U.__datetimeFormatters)?U.__datetimeFormatters:new Map,x=A(U.__numberFormatters)?U.__numberFormatters:new Map,F=A(U.__meta)?U.__meta:{};Ze++;const w={version:r,cid:Ze,locale:o,fallbackLocale:s,messages:l,modifiers:_,pluralRules:m,missing:p,missingWarn:C,fallbackWarn:h,fallbackFormat:k,unresolving:g,postTranslation:I,processor:S,warnHtmlMessage:y,escapeParameter:b,messageCompiler:P,messageResolver:D,localeFallbacker:M,fallbackContext:R,onWarn:n,__meta:F};return w.datetimeFormats=u,w.numberFormats=E,w.__datetimeFormatters=v,w.__numberFormatters=x,w},e.createCoreError=function(e){return P(e,null,void 0)},e.createMessageContext=Ie,e.datetime=function(e,...t){const{datetimeFormats:n,unresolving:r,fallbackLocale:o,onWarn:c,localeFallbacker:s}=e,{__datetimeFormatters:a}=e,[u,f,E,_]=pt(...t);L(E.missingWarn)?E.missingWarn:e.missingWarn,L(E.fallbackWarn)?E.fallbackWarn:e.fallbackWarn;const m=!!E.part,p=Fe(e,E),d=s(e,o,p);if(!T(u)||""===u)return new Intl.DateTimeFormat(p,_).format(f);let N,A={},C=null;for(let l=0;lQe,e.getDevToolsHook=function(){return Se},e.getFallbackContext=()=>Je,e.getLocale=Fe,e.getWarnMessage=function(e,...t){return function(e,...t){return 1===t.length&&A(t[0])&&(t=t[0]),t&&t.hasOwnProperty||(t={}),e.replace(n,((e,n)=>t.hasOwnProperty(n)?t[n]:""))}(Re[e],...t)},e.handleMissing=et,e.initI18nDevTools=function(e,t,n){Se&&Se.emit("i18n:init",{timestamp:Date.now(),i18n:e,version:t,meta:n})},e.isAlmostSameLocale=tt,e.isImplicitFallback=nt,e.isMessageAST=q,e.isMessageFunction=ut,e.isTranslateFallbackWarn=function(e,t){return e instanceof RegExp?e.test(t):e},e.isTranslateMissingWarn=function(e,t){return e instanceof RegExp?e.test(t):e},e.number=function(e,...t){const{numberFormats:n,unresolving:r,fallbackLocale:o,onWarn:c,localeFallbacker:s}=e,{__numberFormatters:a}=e,[u,f,E,_]=Nt(...t);L(E.missingWarn)?E.missingWarn:e.missingWarn,L(E.fallbackWarn)?E.fallbackWarn:e.fallbackWarn;const m=!!E.part,p=Fe(e,E),d=s(e,o,p);if(!T(u)||""===u)return new Intl.NumberFormat(p,_).format(f);let N,A={},C=null;for(let l=0;l{Qe=e},e.setDevToolsHook=function(e){Se=e},e.setFallbackContext=e=>{Je=e},e.translate=function(e,...t){const{fallbackFormat:n,postTranslation:r,unresolving:o,messageCompiler:s,fallbackLocale:a,messages:l}=e,[i,u]=_t(...t),m=L(u.missingWarn)?u.missingWarn:e.missingWarn,p=L(u.fallbackWarn)?u.fallbackWarn:e.fallbackWarn,N=L(u.escapeParameter)?u.escapeParameter:e.escapeParameter,C=!!u.resolvedMessage,h=T(u.default)||L(u.default)?L(u.default)?s?i:()=>i:u.default:n?s?i:()=>i:"",k=n||""!==h,O=Fe(e,u);N&&function(e){d(e.list)?e.list=e.list.map((e=>T(e)?E(e):e)):A(e.named)&&Object.keys(e.named).forEach((t=>{T(e.named[t])&&(e.named[t]=E(e.named[t]))}))}(u);let[g,I,S]=C?[i,O,l[O]||f()]:ft(e,i,O,a,p,m),y=g,b=i;if(C||T(y)||q(y)||ut(y)||k&&(y=h,b=y),!(C||(T(y)||q(y)||ut(y))&&T(I)))return o?-1:i;let P=!1;const D=ut(y)?y:Et(e,i,I,y,b,(()=>{P=!0}));if(P)return y;const M=function(e,t,n,r){const{modifiers:o,pluralRules:s,messageResolver:a,fallbackLocale:l,fallbackWarn:i,missingWarn:u,fallbackContext:f}=e,E=r=>{let o=a(n,r);if(null==o&&f){const[,,e]=ft(f,r,t,l,i,u);o=a(e,r)}if(T(o)||q(o)){let n=!1;const c=Et(e,r,t,o,r,(()=>{n=!0}));return n?it:c}return ut(o)?o:it},_={locale:t,modifiers:o,pluralRules:s,messages:E};e.processor&&(_.processor=e.processor);r.list&&(_.list=r.list);r.named&&(_.named=r.named);c(r.plural)&&(_.pluralIndex=r.plural);return _}(e,I,S,u),R=function(e,t,n){const r=t(n);return r}(0,D,Ie(M));let U=r?r(R,i):R;var v;return N&&T(U)&&(v=(v=(v=U).replace(/(\w+)\s*=\s*"([^"]*)"/g,((e,t,n)=>`${t}="${_(n)}"`))).replace(/(\w+)\s*=\s*'([^']*)'/g,((e,t,n)=>`${t}='${_(n)}'`)),/\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi.test(v)&&(v=v.replace(/(\s+)(on)(\w+\s*=)/gi,"$1on$3")),[/(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi,/(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi].forEach((e=>{v=v.replace(e,"$1javascript:")})),U=v),U},e.translateDevTools=ye,e.updateFallbackLocale=function(e,t,n){e.__localeChainCache=new Map,e.localeFallbacker(e,n,t)},e}({}); diff --git a/node_modules/@intlify/core-base/dist/core-base.mjs b/node_modules/@intlify/core-base/dist/core-base.mjs new file mode 100644 index 0000000..04bca83 --- /dev/null +++ b/node_modules/@intlify/core-base/dist/core-base.mjs @@ -0,0 +1,1933 @@ +/*! + * core-base v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +import { getGlobalThis, isObject, hasOwn, isFunction, isString, create, isNumber, isPlainObject, assign, join, toDisplayString, isArray, incrementer, format as format$1, isPromise, isBoolean, warn, isRegExp, warnOnce, sanitizeTranslatedHtml, escapeHtml, inBrowser, mark, measure, isEmptyObject, generateCodeFrame, generateFormatCacheKey, isDate } from '@intlify/shared'; +import { CompileWarnCodes, CompileErrorCodes, createCompileError, detectHtmlTag, defaultOnError, baseCompile as baseCompile$1 } from '@intlify/message-compiler'; +export { CompileErrorCodes, createCompileError } from '@intlify/message-compiler'; + +/** + * This is only called in esm-bundler builds. + * istanbul-ignore-next + */ +function initFeatureFlags() { + if (typeof __INTLIFY_PROD_DEVTOOLS__ !== 'boolean') { + getGlobalThis().__INTLIFY_PROD_DEVTOOLS__ = false; + } + if (typeof __INTLIFY_JIT_COMPILATION__ !== 'boolean') { + getGlobalThis().__INTLIFY_JIT_COMPILATION__ = false; + } + if (typeof __INTLIFY_DROP_MESSAGE_COMPILER__ !== 'boolean') { + getGlobalThis().__INTLIFY_DROP_MESSAGE_COMPILER__ = false; + } +} + +function isMessageAST(val) { + return (isObject(val) && + resolveType(val) === 0 && + (hasOwn(val, 'b') || hasOwn(val, 'body'))); +} +const PROPS_BODY = ['b', 'body']; +function resolveBody(node) { + return resolveProps(node, PROPS_BODY); +} +const PROPS_CASES = ['c', 'cases']; +function resolveCases(node) { + return resolveProps(node, PROPS_CASES, []); +} +const PROPS_STATIC = ['s', 'static']; +function resolveStatic(node) { + return resolveProps(node, PROPS_STATIC); +} +const PROPS_ITEMS = ['i', 'items']; +function resolveItems(node) { + return resolveProps(node, PROPS_ITEMS, []); +} +const PROPS_TYPE = ['t', 'type']; +function resolveType(node) { + return resolveProps(node, PROPS_TYPE); +} +const PROPS_VALUE = ['v', 'value']; +function resolveValue$1(node, type) { + const resolved = resolveProps(node, PROPS_VALUE); + if (resolved != null) { + return resolved; + } + else { + throw createUnhandleNodeError(type); + } +} +const PROPS_MODIFIER = ['m', 'modifier']; +function resolveLinkedModifier(node) { + return resolveProps(node, PROPS_MODIFIER); +} +const PROPS_KEY = ['k', 'key']; +function resolveLinkedKey(node) { + const resolved = resolveProps(node, PROPS_KEY); + if (resolved) { + return resolved; + } + else { + throw createUnhandleNodeError(6 /* NodeTypes.Linked */); + } +} +function resolveProps(node, props, defaultValue) { + for (let i = 0; i < props.length; i++) { + const prop = props[i]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (hasOwn(node, prop) && node[prop] != null) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return node[prop]; + } + } + return defaultValue; +} +const AST_NODE_PROPS_KEYS = [ + ...PROPS_BODY, + ...PROPS_CASES, + ...PROPS_STATIC, + ...PROPS_ITEMS, + ...PROPS_KEY, + ...PROPS_MODIFIER, + ...PROPS_VALUE, + ...PROPS_TYPE +]; +function createUnhandleNodeError(type) { + return new Error(`unhandled node type: ${type}`); +} + +const pathStateMachine = []; +pathStateMachine[0 /* States.BEFORE_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [0 /* States.BEFORE_PATH */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] +}; +pathStateMachine[1 /* States.IN_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] +}; +pathStateMachine[2 /* States.BEFORE_IDENT */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [2 /* States.BEFORE_IDENT */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */] +}; +pathStateMachine[3 /* States.IN_IDENT */] = { + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */, 1 /* Actions.PUSH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */, 1 /* Actions.PUSH */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */, 1 /* Actions.PUSH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */, 1 /* Actions.PUSH */] +}; +pathStateMachine[4 /* States.IN_SUB_PATH */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */], + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [ + 4 /* States.IN_SUB_PATH */, + 2 /* Actions.INC_SUB_PATH_DEPTH */ + ], + ["]" /* PathCharTypes.RIGHT_BRACKET */]: [1 /* States.IN_PATH */, 3 /* Actions.PUSH_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */] +}; +pathStateMachine[5 /* States.IN_SINGLE_QUOTE */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */] +}; +pathStateMachine[6 /* States.IN_DOUBLE_QUOTE */] = { + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */] +}; +/** + * Check if an expression is a literal value. + */ +const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/; +function isLiteral(exp) { + return literalValueRE.test(exp); +} +/** + * Strip quotes from a string + */ +function stripQuotes(str) { + const a = str.charCodeAt(0); + const b = str.charCodeAt(str.length - 1); + return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str; +} +/** + * Determine the type of a character in a keypath. + */ +function getPathCharType(ch) { + if (ch === undefined || ch === null) { + return "o" /* PathCharTypes.END_OF_FAIL */; + } + const code = ch.charCodeAt(0); + switch (code) { + case 0x5b: // [ + case 0x5d: // ] + case 0x2e: // . + case 0x22: // " + case 0x27: // ' + return ch; + case 0x5f: // _ + case 0x24: // $ + case 0x2d: // - + return "i" /* PathCharTypes.IDENT */; + case 0x09: // Tab (HT) + case 0x0a: // Newline (LF) + case 0x0d: // Return (CR) + case 0xa0: // No-break space (NBSP) + case 0xfeff: // Byte Order Mark (BOM) + case 0x2028: // Line Separator (LS) + case 0x2029: // Paragraph Separator (PS) + return "w" /* PathCharTypes.WORKSPACE */; + } + return "i" /* PathCharTypes.IDENT */; +} +/** + * Format a subPath, return its plain form if it is + * a literal string or number. Otherwise prepend the + * dynamic indicator (*). + */ +function formatSubPath(path) { + const trimmed = path.trim(); + // invalid leading 0 + if (path.charAt(0) === '0' && isNaN(parseInt(path))) { + return false; + } + return isLiteral(trimmed) + ? stripQuotes(trimmed) + : "*" /* PathCharTypes.ASTARISK */ + trimmed; +} +/** + * Parse a string path into an array of segments + */ +function parse(path) { + const keys = []; + let index = -1; + let mode = 0 /* States.BEFORE_PATH */; + let subPathDepth = 0; + let c; + let key; // eslint-disable-line + let newChar; + let type; + let transition; + let action; + let typeMap; + const actions = []; + actions[0 /* Actions.APPEND */] = () => { + if (key === undefined) { + key = newChar; + } + else { + key += newChar; + } + }; + actions[1 /* Actions.PUSH */] = () => { + if (key !== undefined) { + keys.push(key); + key = undefined; + } + }; + actions[2 /* Actions.INC_SUB_PATH_DEPTH */] = () => { + actions[0 /* Actions.APPEND */](); + subPathDepth++; + }; + actions[3 /* Actions.PUSH_SUB_PATH */] = () => { + if (subPathDepth > 0) { + subPathDepth--; + mode = 4 /* States.IN_SUB_PATH */; + actions[0 /* Actions.APPEND */](); + } + else { + subPathDepth = 0; + if (key === undefined) { + return false; + } + key = formatSubPath(key); + if (key === false) { + return false; + } + else { + actions[1 /* Actions.PUSH */](); + } + } + }; + function maybeUnescapeQuote() { + const nextChar = path[index + 1]; + if ((mode === 5 /* States.IN_SINGLE_QUOTE */ && + nextChar === "'" /* PathCharTypes.SINGLE_QUOTE */) || + (mode === 6 /* States.IN_DOUBLE_QUOTE */ && + nextChar === "\"" /* PathCharTypes.DOUBLE_QUOTE */)) { + index++; + newChar = '\\' + nextChar; + actions[0 /* Actions.APPEND */](); + return true; + } + } + while (mode !== null) { + index++; + c = path[index]; + if (c === '\\' && maybeUnescapeQuote()) { + continue; + } + type = getPathCharType(c); + typeMap = pathStateMachine[mode]; + transition = typeMap[type] || typeMap["l" /* PathCharTypes.ELSE */] || 8 /* States.ERROR */; + // check parse error + if (transition === 8 /* States.ERROR */) { + return; + } + mode = transition[0]; + if (transition[1] !== undefined) { + action = actions[transition[1]]; + if (action) { + newChar = c; + if (action() === false) { + return; + } + } + } + // check parse finish + if (mode === 7 /* States.AFTER_PATH */) { + return keys; + } + } +} +// path token cache +const cache = new Map(); +/** + * key-value message resolver + * + * @remarks + * Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ +function resolveWithKeyValue(obj, path) { + return isObject(obj) ? obj[path] : null; +} +/** + * message resolver + * + * @remarks + * Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default. + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ +function resolveValue(obj, path) { + // check object + if (!isObject(obj)) { + return null; + } + // parse path + let hit = cache.get(path); + if (!hit) { + hit = parse(path); + if (hit) { + cache.set(path, hit); + } + } + // check hit + if (!hit) { + return null; + } + // resolve path value + const len = hit.length; + let last = obj; + let i = 0; + while (i < len) { + const key = hit[i]; + /** + * NOTE: + * if `key` is intlify message format AST node key and `last` is intlify message format AST, skip it. + * because the AST node is not a key-value structure. + */ + if (AST_NODE_PROPS_KEYS.includes(key) && isMessageAST(last)) { + return null; + } + const val = last[key]; + if (val === undefined) { + return null; + } + if (isFunction(last)) { + return null; + } + last = val; + i++; + } + return last; +} + +const DEFAULT_MODIFIER = (str) => str; +const DEFAULT_MESSAGE = (ctx) => ''; // eslint-disable-line +const DEFAULT_MESSAGE_DATA_TYPE = 'text'; +const DEFAULT_NORMALIZE = (values) => values.length === 0 ? '' : join(values); +const DEFAULT_INTERPOLATE = toDisplayString; +function pluralDefault(choice, choicesLength) { + choice = Math.abs(choice); + if (choicesLength === 2) { + // prettier-ignore + return choice + ? choice > 1 + ? 1 + : 0 + : 1; + } + return choice ? Math.min(choice, 2) : 0; +} +function getPluralIndex(options) { + // prettier-ignore + const index = isNumber(options.pluralIndex) + ? options.pluralIndex + : -1; + // prettier-ignore + return options.named && (isNumber(options.named.count) || isNumber(options.named.n)) + ? isNumber(options.named.count) + ? options.named.count + : isNumber(options.named.n) + ? options.named.n + : index + : index; +} +function normalizeNamed(pluralIndex, props) { + if (!props.count) { + props.count = pluralIndex; + } + if (!props.n) { + props.n = pluralIndex; + } +} +function createMessageContext(options = {}) { + const locale = options.locale; + const pluralIndex = getPluralIndex(options); + const pluralRule = isObject(options.pluralRules) && + isString(locale) && + isFunction(options.pluralRules[locale]) + ? options.pluralRules[locale] + : pluralDefault; + const orgPluralRule = isObject(options.pluralRules) && + isString(locale) && + isFunction(options.pluralRules[locale]) + ? pluralDefault + : undefined; + const plural = (messages) => { + return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)]; + }; + const _list = options.list || []; + const list = (index) => _list[index]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _named = options.named || create(); + isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named); + const named = (key) => _named[key]; + function message(key) { + // prettier-ignore + const msg = isFunction(options.messages) + ? options.messages(key) + : isObject(options.messages) + ? options.messages[key] + : false; + return !msg + ? options.parent + ? options.parent.message(key) // resolve from parent messages + : DEFAULT_MESSAGE + : msg; + } + const _modifier = (name) => options.modifiers + ? options.modifiers[name] + : DEFAULT_MODIFIER; + const normalize = isPlainObject(options.processor) && isFunction(options.processor.normalize) + ? options.processor.normalize + : DEFAULT_NORMALIZE; + const interpolate = isPlainObject(options.processor) && + isFunction(options.processor.interpolate) + ? options.processor.interpolate + : DEFAULT_INTERPOLATE; + const type = isPlainObject(options.processor) && isString(options.processor.type) + ? options.processor.type + : DEFAULT_MESSAGE_DATA_TYPE; + const linked = (key, ...args) => { + const [arg1, arg2] = args; + let type = 'text'; + let modifier = ''; + if (args.length === 1) { + if (isObject(arg1)) { + modifier = arg1.modifier || modifier; + type = arg1.type || type; + } + else if (isString(arg1)) { + modifier = arg1 || modifier; + } + } + else if (args.length === 2) { + if (isString(arg1)) { + modifier = arg1 || modifier; + } + if (isString(arg2)) { + type = arg2 || type; + } + } + const ret = message(key)(ctx); + const msg = + // The message in vnode resolved with linked are returned as an array by processor.nomalize + type === 'vnode' && isArray(ret) && modifier + ? ret[0] + : ret; + return modifier ? _modifier(modifier)(msg, type) : msg; + }; + const ctx = { + ["list" /* HelperNameMap.LIST */]: list, + ["named" /* HelperNameMap.NAMED */]: named, + ["plural" /* HelperNameMap.PLURAL */]: plural, + ["linked" /* HelperNameMap.LINKED */]: linked, + ["message" /* HelperNameMap.MESSAGE */]: message, + ["type" /* HelperNameMap.TYPE */]: type, + ["interpolate" /* HelperNameMap.INTERPOLATE */]: interpolate, + ["normalize" /* HelperNameMap.NORMALIZE */]: normalize, + ["values" /* HelperNameMap.VALUES */]: assign(create(), _list, _named) + }; + return ctx; +} + +let devtools = null; +function setDevToolsHook(hook) { + devtools = hook; +} +function getDevToolsHook() { + return devtools; +} +function initI18nDevTools(i18n, version, meta) { + // TODO: queue if devtools is undefined + devtools && + devtools.emit("i18n:init" /* IntlifyDevToolsHooks.I18nInit */, { + timestamp: Date.now(), + i18n, + version, + meta + }); +} +const translateDevTools = /* #__PURE__*/ createDevToolsHook("function:translate" /* IntlifyDevToolsHooks.FunctionTranslate */); +function createDevToolsHook(hook) { + return (payloads) => devtools && devtools.emit(hook, payloads); +} + +const code$1 = CompileWarnCodes.__EXTEND_POINT__; +const inc$1 = incrementer(code$1); +const CoreWarnCodes = { + NOT_FOUND_KEY: code$1, // 2 + FALLBACK_TO_TRANSLATE: inc$1(), // 3 + CANNOT_FORMAT_NUMBER: inc$1(), // 4 + FALLBACK_TO_NUMBER_FORMAT: inc$1(), // 5 + CANNOT_FORMAT_DATE: inc$1(), // 6 + FALLBACK_TO_DATE_FORMAT: inc$1(), // 7 + EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc$1(), // 8 + __EXTEND_POINT__: inc$1() // 9 +}; +/** @internal */ +const warnMessages = { + [CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`, + [CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`, + [CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`, + [CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]: `This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future.` +}; +function getWarnMessage(code, ...args) { + return format$1(warnMessages[code], ...args); +} + +const code = CompileErrorCodes.__EXTEND_POINT__; +const inc = incrementer(code); +const CoreErrorCodes = { + INVALID_ARGUMENT: code, // 17 + INVALID_DATE_ARGUMENT: inc(), // 18 + INVALID_ISO_DATE_ARGUMENT: inc(), // 19 + NOT_SUPPORT_NON_STRING_MESSAGE: inc(), // 20 + NOT_SUPPORT_LOCALE_PROMISE_VALUE: inc(), // 21 + NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: inc(), // 22 + NOT_SUPPORT_LOCALE_TYPE: inc(), // 23 + __EXTEND_POINT__: inc() // 24 +}; +function createCoreError(code) { + return createCompileError(code, null, (process.env.NODE_ENV !== 'production') ? { messages: errorMessages } : undefined); +} +/** @internal */ +const errorMessages = { + [CoreErrorCodes.INVALID_ARGUMENT]: 'Invalid arguments', + [CoreErrorCodes.INVALID_DATE_ARGUMENT]: 'The date provided is an invalid Date object.' + + 'Make sure your Date represents a valid date.', + [CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: 'The argument provided is not a valid ISO date string', + [CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE]: 'Not support non-string message', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]: 'cannot support promise value', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]: 'cannot support async function', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: 'cannot support locale type' +}; + +/** @internal */ +function getLocale(context, options) { + return options.locale != null + ? resolveLocale(options.locale) + : resolveLocale(context.locale); +} +let _resolveLocale; +/** @internal */ +function resolveLocale(locale) { + if (isString(locale)) { + return locale; + } + else { + if (isFunction(locale)) { + if (locale.resolvedOnce && _resolveLocale != null) { + return _resolveLocale; + } + else if (locale.constructor.name === 'Function') { + const resolve = locale(); + if (isPromise(resolve)) { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE); + } + return (_resolveLocale = resolve); + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION); + } + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE); + } + } +} +/** + * Fallback with simple implemenation + * + * @remarks + * A fallback locale function implemented with a simple fallback algorithm. + * + * Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nGeneral + */ +function fallbackWithSimple(ctx, fallback, start // eslint-disable-line @typescript-eslint/no-unused-vars +) { + // prettier-ignore + return [...new Set([ + start, + ...(isArray(fallback) + ? fallback + : isObject(fallback) + ? Object.keys(fallback) + : isString(fallback) + ? [fallback] + : [start]) + ])]; +} +/** + * Fallback with locale chain + * + * @remarks + * A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @VueI18nGeneral + */ +function fallbackWithLocaleChain(ctx, fallback, start) { + const startLocale = isString(start) ? start : DEFAULT_LOCALE; + const context = ctx; + if (!context.__localeChainCache) { + context.__localeChainCache = new Map(); + } + let chain = context.__localeChainCache.get(startLocale); + if (!chain) { + chain = []; + // first block defined by start + let block = [start]; + // while any intervening block found + while (isArray(block)) { + block = appendBlockToChain(chain, block, fallback); + } + // prettier-ignore + // last block defined by default + const defaults = isArray(fallback) || !isPlainObject(fallback) + ? fallback + : fallback['default'] + ? fallback['default'] + : null; + // convert defaults to array + block = isString(defaults) ? [defaults] : defaults; + if (isArray(block)) { + appendBlockToChain(chain, block, false); + } + context.__localeChainCache.set(startLocale, chain); + } + return chain; +} +function appendBlockToChain(chain, block, blocks) { + let follow = true; + for (let i = 0; i < block.length && isBoolean(follow); i++) { + const locale = block[i]; + if (isString(locale)) { + follow = appendLocaleToChain(chain, block[i], blocks); + } + } + return follow; +} +function appendLocaleToChain(chain, locale, blocks) { + let follow; + const tokens = locale.split('-'); + do { + const target = tokens.join('-'); + follow = appendItemToChain(chain, target, blocks); + tokens.splice(-1, 1); + } while (tokens.length && follow === true); + return follow; +} +function appendItemToChain(chain, target, blocks) { + let follow = false; + if (!chain.includes(target)) { + follow = true; + if (target) { + follow = target[target.length - 1] !== '!'; + const locale = target.replace(/!/g, ''); + chain.push(locale); + if ((isArray(blocks) || isPlainObject(blocks)) && + blocks[locale] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + follow = blocks[locale]; + } + } + } + return follow; +} + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Intlify core-base version + * @internal + */ +const VERSION = '9.14.5'; +const NOT_REOSLVED = -1; +const DEFAULT_LOCALE = 'en-US'; +const MISSING_RESOLVE_VALUE = ''; +const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`; +function getDefaultLinkedModifiers() { + return { + upper: (val, type) => { + // prettier-ignore + return type === 'text' && isString(val) + ? val.toUpperCase() + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? val.children.toUpperCase() + : val; + }, + lower: (val, type) => { + // prettier-ignore + return type === 'text' && isString(val) + ? val.toLowerCase() + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? val.children.toLowerCase() + : val; + }, + capitalize: (val, type) => { + // prettier-ignore + return (type === 'text' && isString(val) + ? capitalize(val) + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? capitalize(val.children) + : val); + } + }; +} +let _compiler; +function registerMessageCompiler(compiler) { + _compiler = compiler; +} +let _resolver; +/** + * Register the message resolver + * + * @param resolver - A {@link MessageResolver} function + * + * @VueI18nGeneral + */ +function registerMessageResolver(resolver) { + _resolver = resolver; +} +let _fallbacker; +/** + * Register the locale fallbacker + * + * @param fallbacker - A {@link LocaleFallbacker} function + * + * @VueI18nGeneral + */ +function registerLocaleFallbacker(fallbacker) { + _fallbacker = fallbacker; +} +// Additional Meta for Intlify DevTools +let _additionalMeta = null; +/* #__NO_SIDE_EFFECTS__ */ +const setAdditionalMeta = (meta) => { + _additionalMeta = meta; +}; +/* #__NO_SIDE_EFFECTS__ */ +const getAdditionalMeta = () => _additionalMeta; +let _fallbackContext = null; +const setFallbackContext = (context) => { + _fallbackContext = context; +}; +const getFallbackContext = () => _fallbackContext; +// ID for CoreContext +let _cid = 0; +function createCoreContext(options = {}) { + // setup options + const onWarn = isFunction(options.onWarn) ? options.onWarn : warn; + const version = isString(options.version) ? options.version : VERSION; + const locale = isString(options.locale) || isFunction(options.locale) + ? options.locale + : DEFAULT_LOCALE; + const _locale = isFunction(locale) ? DEFAULT_LOCALE : locale; + const fallbackLocale = isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + isString(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale; + const messages = isPlainObject(options.messages) + ? options.messages + : createResources(_locale); + const datetimeFormats = isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : createResources(_locale) + ; + const numberFormats = isPlainObject(options.numberFormats) + ? options.numberFormats + : createResources(_locale) + ; + const modifiers = assign(create(), options.modifiers, getDefaultLinkedModifiers()); + const pluralRules = options.pluralRules || create(); + const missing = isFunction(options.missing) ? options.missing : null; + const missingWarn = isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + const fallbackWarn = isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + const fallbackFormat = !!options.fallbackFormat; + const unresolving = !!options.unresolving; + const postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + const processor = isPlainObject(options.processor) ? options.processor : null; + const warnHtmlMessage = isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const escapeParameter = !!options.escapeParameter; + const messageCompiler = isFunction(options.messageCompiler) + ? options.messageCompiler + : _compiler; + if ((process.env.NODE_ENV !== 'production') && + !false && + !false && + isFunction(options.messageCompiler)) { + warnOnce(getWarnMessage(CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER)); + } + const messageResolver = isFunction(options.messageResolver) + ? options.messageResolver + : _resolver || resolveWithKeyValue; + const localeFallbacker = isFunction(options.localeFallbacker) + ? options.localeFallbacker + : _fallbacker || fallbackWithSimple; + const fallbackContext = isObject(options.fallbackContext) + ? options.fallbackContext + : undefined; + // setup internal options + const internalOptions = options; + const __datetimeFormatters = isObject(internalOptions.__datetimeFormatters) + ? internalOptions.__datetimeFormatters + : new Map() + ; + const __numberFormatters = isObject(internalOptions.__numberFormatters) + ? internalOptions.__numberFormatters + : new Map() + ; + const __meta = isObject(internalOptions.__meta) ? internalOptions.__meta : {}; + _cid++; + const context = { + version, + cid: _cid, + locale, + fallbackLocale, + messages, + modifiers, + pluralRules, + missing, + missingWarn, + fallbackWarn, + fallbackFormat, + unresolving, + postTranslation, + processor, + warnHtmlMessage, + escapeParameter, + messageCompiler, + messageResolver, + localeFallbacker, + fallbackContext, + onWarn, + __meta + }; + { + context.datetimeFormats = datetimeFormats; + context.numberFormats = numberFormats; + context.__datetimeFormatters = __datetimeFormatters; + context.__numberFormatters = __numberFormatters; + } + // for vue-devtools timeline event + if ((process.env.NODE_ENV !== 'production')) { + context.__v_emitter = + internalOptions.__v_emitter != null + ? internalOptions.__v_emitter + : undefined; + } + // NOTE: experimental !! + if ((process.env.NODE_ENV !== 'production') || __INTLIFY_PROD_DEVTOOLS__) { + initI18nDevTools(context, version, __meta); + } + return context; +} +const createResources = (locale) => ({ [locale]: create() }); +/** @internal */ +function isTranslateFallbackWarn(fallback, key) { + return fallback instanceof RegExp ? fallback.test(key) : fallback; +} +/** @internal */ +function isTranslateMissingWarn(missing, key) { + return missing instanceof RegExp ? missing.test(key) : missing; +} +/** @internal */ +function handleMissing(context, key, locale, missingWarn, type) { + const { missing, onWarn } = context; + // for vue-devtools timeline event + if ((process.env.NODE_ENV !== 'production')) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("missing" /* VueDevToolsTimelineEvents.MISSING */, { + locale, + key, + type, + groupId: `${type}:${key}` + }); + } + } + if (missing !== null) { + const ret = missing(context, locale, key, type); + return isString(ret) ? ret : key; + } + else { + if ((process.env.NODE_ENV !== 'production') && isTranslateMissingWarn(missingWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.NOT_FOUND_KEY, { key, locale })); + } + return key; + } +} +/** @internal */ +function updateFallbackLocale(ctx, locale, fallback) { + const context = ctx; + context.__localeChainCache = new Map(); + ctx.localeFallbacker(ctx, fallback, locale); +} +/** @internal */ +function isAlmostSameLocale(locale, compareLocale) { + if (locale === compareLocale) + return false; + return locale.split('-')[0] === compareLocale.split('-')[0]; +} +/** @internal */ +function isImplicitFallback(targetLocale, locales) { + const index = locales.indexOf(targetLocale); + if (index === -1) { + return false; + } + for (let i = index + 1; i < locales.length; i++) { + if (isAlmostSameLocale(targetLocale, locales[i])) { + return true; + } + } + return false; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +function format(ast) { + const msg = (ctx) => formatParts(ctx, ast); + return msg; +} +function formatParts(ctx, ast) { + const body = resolveBody(ast); + if (body == null) { + throw createUnhandleNodeError(0 /* NodeTypes.Resource */); + } + const type = resolveType(body); + if (type === 1 /* NodeTypes.Plural */) { + const plural = body; + const cases = resolveCases(plural); + return ctx.plural(cases.reduce((messages, c) => [ + ...messages, + formatMessageParts(ctx, c) + ], [])); + } + else { + return formatMessageParts(ctx, body); + } +} +function formatMessageParts(ctx, node) { + const static_ = resolveStatic(node); + if (static_ != null) { + return ctx.type === 'text' + ? static_ + : ctx.normalize([static_]); + } + else { + const messages = resolveItems(node).reduce((acm, c) => [...acm, formatMessagePart(ctx, c)], []); + return ctx.normalize(messages); + } +} +function formatMessagePart(ctx, node) { + const type = resolveType(node); + switch (type) { + case 3 /* NodeTypes.Text */: { + return resolveValue$1(node, type); + } + case 9 /* NodeTypes.Literal */: { + return resolveValue$1(node, type); + } + case 4 /* NodeTypes.Named */: { + const named = node; + if (hasOwn(named, 'k') && named.k) { + return ctx.interpolate(ctx.named(named.k)); + } + if (hasOwn(named, 'key') && named.key) { + return ctx.interpolate(ctx.named(named.key)); + } + throw createUnhandleNodeError(type); + } + case 5 /* NodeTypes.List */: { + const list = node; + if (hasOwn(list, 'i') && isNumber(list.i)) { + return ctx.interpolate(ctx.list(list.i)); + } + if (hasOwn(list, 'index') && isNumber(list.index)) { + return ctx.interpolate(ctx.list(list.index)); + } + throw createUnhandleNodeError(type); + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + const modifier = resolveLinkedModifier(linked); + const key = resolveLinkedKey(linked); + return ctx.linked(formatMessagePart(ctx, key), modifier ? formatMessagePart(ctx, modifier) : undefined, ctx.type); + } + case 7 /* NodeTypes.LinkedKey */: { + return resolveValue$1(node, type); + } + case 8 /* NodeTypes.LinkedModifier */: { + return resolveValue$1(node, type); + } + default: + throw new Error(`unhandled node on format message part: ${type}`); + } +} + +const WARN_MESSAGE = `Detected HTML in '{source}' message. Recommend not using HTML messages to avoid XSS.`; +function checkHtmlMessage(source, warnHtmlMessage) { + if (warnHtmlMessage && detectHtmlTag(source)) { + warn(format$1(WARN_MESSAGE, { source })); + } +} +const defaultOnCacheKey = (message) => message; +let compileCache = create(); +function onCompileWarn(_warn) { + if (_warn.code === CompileWarnCodes.USE_MODULO_SYNTAX) { + warn(`The use of named interpolation with modulo syntax is deprecated. ` + + `It will be removed in v10.\n` + + `reference: https://vue-i18n.intlify.dev/guide/essentials/syntax#rails-i18n-format \n` + + `(message compiler warning message: ${_warn.message})`); + } +} +function clearCompileCache() { + compileCache = create(); +} +function baseCompile(message, options = {}) { + // error detecting on compile + let detectError = false; + const onError = options.onError || defaultOnError; + options.onError = (err) => { + detectError = true; + onError(err); + }; + // compile with mesasge-compiler + return { ...baseCompile$1(message, options), detectError }; +} +/* #__NO_SIDE_EFFECTS__ */ +const compileToFunction = (message, context) => { + if (!isString(message)) { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE); + } + // set onWarn + if ((process.env.NODE_ENV !== 'production')) { + context.onWarn = onCompileWarn; + } + { + // check HTML message + const warnHtmlMessage = isBoolean(context.warnHtmlMessage) + ? context.warnHtmlMessage + : true; + (process.env.NODE_ENV !== 'production') && checkHtmlMessage(message, warnHtmlMessage); + // check caches + const onCacheKey = context.onCacheKey || defaultOnCacheKey; + const cacheKey = onCacheKey(message); + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compile + const { code, detectError } = baseCompile(message, context); + // evaluate function + const msg = new Function(`return ${code}`)(); + // if occurred compile error, don't cache + return !detectError + ? (compileCache[cacheKey] = msg) + : msg; + } +}; +function compile(message, context) { + // set onWarn + if ((process.env.NODE_ENV !== 'production')) { + context.onWarn = onCompileWarn; + } + if (((__INTLIFY_JIT_COMPILATION__ && !__INTLIFY_DROP_MESSAGE_COMPILER__)) && + isString(message)) { + // check HTML message + const warnHtmlMessage = isBoolean(context.warnHtmlMessage) + ? context.warnHtmlMessage + : true; + (process.env.NODE_ENV !== 'production') && checkHtmlMessage(message, warnHtmlMessage); + // check caches + const onCacheKey = context.onCacheKey || defaultOnCacheKey; + const cacheKey = onCacheKey(message); + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compile with JIT mode + const { ast, detectError } = baseCompile(message, { + ...context, + location: (process.env.NODE_ENV !== 'production'), + jit: true + }); + // compose message function from AST + const msg = format(ast); + // if occurred compile error, don't cache + return !detectError + ? (compileCache[cacheKey] = msg) + : msg; + } + else { + if ((process.env.NODE_ENV !== 'production') && !isMessageAST(message)) { + warn(`the message that is resolve with key '${context.key}' is not supported for jit compilation`); + return (() => message); + } + // AST case (passed from bundler) + const cacheKey = message.cacheKey; + if (cacheKey) { + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compose message function from message (AST) + return (compileCache[cacheKey] = + format(message)); + } + else { + return format(message); + } + } +} + +const NOOP_MESSAGE_FUNCTION = () => ''; +const isMessageFunction = (val) => isFunction(val); +// implementation of `translate` function +function translate(context, ...args) { + const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context; + const [key, options] = parseTranslateArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const escapeParameter = isBoolean(options.escapeParameter) + ? options.escapeParameter + : context.escapeParameter; + const resolvedMessage = !!options.resolvedMessage; + // prettier-ignore + const defaultMsgOrKey = isString(options.default) || isBoolean(options.default) // default by function option + ? !isBoolean(options.default) + ? options.default + : (!messageCompiler ? () => key : key) + : fallbackFormat // default by `fallbackFormat` option + ? (!messageCompiler ? () => key : key) + : ''; + const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== ''; + const locale = getLocale(context, options); + // escape params + escapeParameter && escapeParams(options); + // resolve message format + // eslint-disable-next-line prefer-const + let [formatScope, targetLocale, message] = !resolvedMessage + ? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) + : [ + key, + locale, + messages[locale] || create() + ]; + // NOTE: + // Fix to work around `ssrTransfrom` bug in Vite. + // https://github.com/vitejs/vite/issues/4306 + // To get around this, use temporary variables. + // https://github.com/nuxt/framework/issues/1461#issuecomment-954606243 + let format = formatScope; + // if you use default message, set it as message format! + let cacheBaseKey = key; + if (!resolvedMessage && + !(isString(format) || + isMessageAST(format) || + isMessageFunction(format))) { + if (enableDefaultMsg) { + format = defaultMsgOrKey; + cacheBaseKey = format; + } + } + // checking message format and target locale + if (!resolvedMessage && + (!(isString(format) || + isMessageAST(format) || + isMessageFunction(format)) || + !isString(targetLocale))) { + return unresolving ? NOT_REOSLVED : key; + } + // TODO: refactor + if ((process.env.NODE_ENV !== 'production') && isString(format) && context.messageCompiler == null) { + warn(`The message format compilation is not supported in this build. ` + + `Because message compiler isn't included. ` + + `You need to pre-compilation all message format. ` + + `So translate function return '${key}'.`); + return key; + } + // setup compile error detecting + let occurred = false; + const onError = () => { + occurred = true; + }; + // compile message format + const msg = !isMessageFunction(format) + ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) + : format; + // if occurred compile error, return the message format + if (occurred) { + return format; + } + // evaluate message with context + const ctxOptions = getMessageContextOptions(context, targetLocale, message, options); + const msgContext = createMessageContext(ctxOptions); + const messaged = evaluateMessage(context, msg, msgContext); + // if use post translation option, proceed it with handler + let ret = postTranslation + ? postTranslation(messaged, key) + : messaged; + // apply HTML sanitization for security + if (escapeParameter && isString(ret)) { + ret = sanitizeTranslatedHtml(ret); + } + // NOTE: experimental !! + if ((process.env.NODE_ENV !== 'production') || __INTLIFY_PROD_DEVTOOLS__) { + // prettier-ignore + const payloads = { + timestamp: Date.now(), + key: isString(key) + ? key + : isMessageFunction(format) + ? format.key + : '', + locale: targetLocale || (isMessageFunction(format) + ? format.locale + : ''), + format: isString(format) + ? format + : isMessageFunction(format) + ? format.source + : '', + message: ret + }; + payloads.meta = assign({}, context.__meta, getAdditionalMeta() || {}); + translateDevTools(payloads); + } + return ret; +} +function escapeParams(options) { + if (isArray(options.list)) { + options.list = options.list.map(item => isString(item) ? escapeHtml(item) : item); + } + else if (isObject(options.named)) { + Object.keys(options.named).forEach(key => { + if (isString(options.named[key])) { + options.named[key] = escapeHtml(options.named[key]); + } + }); + } +} +function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) { + const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context; + const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any + let message = create(); + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'translate'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if ((process.env.NODE_ENV !== 'production') && + locale !== targetLocale && + !isAlmostSameLocale(locale, targetLocale) && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_TRANSLATE, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if ((process.env.NODE_ENV !== 'production') && locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + message = + messages[targetLocale] || create(); + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if ((process.env.NODE_ENV !== 'production') && inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-resolve-start'; + endTag = 'intlify-message-resolve-end'; + mark && mark(startTag); + } + if ((format = resolveValue(message, key)) === null) { + // if null, resolve with object key path + format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any + } + // for vue-devtools timeline event + if ((process.env.NODE_ENV !== 'production') && inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start && format) { + emitter.emit("message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, { + type: "message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, + key, + message: format, + time: end - start, + groupId: `${type}:${key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message resolve', startTag, endTag); + } + } + if (isString(format) || isMessageAST(format) || isMessageFunction(format)) { + break; + } + if (!isImplicitFallback(targetLocale, locales)) { + const missingRet = handleMissing(context, // eslint-disable-line @typescript-eslint/no-explicit-any + key, targetLocale, missingWarn, type); + if (missingRet !== key) { + format = missingRet; + } + } + from = to; + } + return [format, targetLocale, message]; +} +function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) { + const { messageCompiler, warnHtmlMessage } = context; + if (isMessageFunction(format)) { + const msg = format; + msg.locale = msg.locale || targetLocale; + msg.key = msg.key || key; + return msg; + } + if (messageCompiler == null) { + const msg = (() => format); + msg.locale = targetLocale; + msg.key = key; + return msg; + } + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if ((process.env.NODE_ENV !== 'production') && inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-compilation-start'; + endTag = 'intlify-message-compilation-end'; + mark && mark(startTag); + } + const msg = messageCompiler(format, getCompileContext(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, onError)); + // for vue-devtools timeline event + if ((process.env.NODE_ENV !== 'production') && inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, { + type: "message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, + message: format, + time: end - start, + groupId: `${'translate'}:${key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message compilation', startTag, endTag); + } + } + msg.locale = targetLocale; + msg.key = key; + msg.source = format; + return msg; +} +function evaluateMessage(context, msg, msgCtx) { + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if ((process.env.NODE_ENV !== 'production') && inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-evaluation-start'; + endTag = 'intlify-message-evaluation-end'; + mark && mark(startTag); + } + const messaged = msg(msgCtx); + // for vue-devtools timeline event + if ((process.env.NODE_ENV !== 'production') && inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, { + type: "message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, + value: messaged, + time: end - start, + groupId: `${'translate'}:${msg.key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message evaluation', startTag, endTag); + } + } + return messaged; +} +/** @internal */ +function parseTranslateArgs(...args) { + const [arg1, arg2, arg3] = args; + const options = create(); + if (!isString(arg1) && + !isNumber(arg1) && + !isMessageFunction(arg1) && + !isMessageAST(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + // prettier-ignore + const key = isNumber(arg1) + ? String(arg1) + : isMessageFunction(arg1) + ? arg1 + : arg1; + if (isNumber(arg2)) { + options.plural = arg2; + } + else if (isString(arg2)) { + options.default = arg2; + } + else if (isPlainObject(arg2) && !isEmptyObject(arg2)) { + options.named = arg2; + } + else if (isArray(arg2)) { + options.list = arg2; + } + if (isNumber(arg3)) { + options.plural = arg3; + } + else if (isString(arg3)) { + options.default = arg3; + } + else if (isPlainObject(arg3)) { + assign(options, arg3); + } + return [key, options]; +} +function getCompileContext(context, locale, key, source, warnHtmlMessage, onError) { + return { + locale, + key, + warnHtmlMessage, + onError: (err) => { + onError && onError(err); + if ((process.env.NODE_ENV !== 'production')) { + const _source = getSourceForCodeFrame(source); + const message = `Message compilation error: ${err.message}`; + const codeFrame = err.location && + _source && + generateCodeFrame(_source, err.location.start.offset, err.location.end.offset); + const emitter = context.__v_emitter; + if (emitter && _source) { + emitter.emit("compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */, { + message: _source, + error: err.message, + start: err.location && err.location.start.offset, + end: err.location && err.location.end.offset, + groupId: `${'translate'}:${key}` + }); + } + console.error(codeFrame ? `${message}\n${codeFrame}` : message); + } + else { + throw err; + } + }, + onCacheKey: (source) => generateFormatCacheKey(locale, key, source) + }; +} +function getSourceForCodeFrame(source) { + if (isString(source)) { + return source; + } + else { + if (source.loc && source.loc.source) { + return source.loc.source; + } + } +} +function getMessageContextOptions(context, locale, message, options) { + const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context; + const resolveMessage = (key) => { + let val = resolveValue(message, key); + // fallback to root context + if (val == null && fallbackContext) { + const [, , message] = resolveMessageFormat(fallbackContext, key, locale, fallbackLocale, fallbackWarn, missingWarn); + val = resolveValue(message, key); + } + if (isString(val) || isMessageAST(val)) { + let occurred = false; + const onError = () => { + occurred = true; + }; + const msg = compileMessageFormat(context, key, locale, val, key, onError); + return !occurred + ? msg + : NOOP_MESSAGE_FUNCTION; + } + else if (isMessageFunction(val)) { + return val; + } + else { + // TODO: should be implemented warning message + return NOOP_MESSAGE_FUNCTION; + } + }; + const ctxOptions = { + locale, + modifiers, + pluralRules, + messages: resolveMessage + }; + if (context.processor) { + ctxOptions.processor = context.processor; + } + if (options.list) { + ctxOptions.list = options.list; + } + if (options.named) { + ctxOptions.named = options.named; + } + if (isNumber(options.plural)) { + ctxOptions.pluralIndex = options.plural; + } + return ctxOptions; +} + +const intlDefined = typeof Intl !== 'undefined'; +const Availabilities = { + dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined', + numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined' +}; + +// implementation of `datetime` function +function datetime(context, ...args) { + const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __datetimeFormatters } = context; + if ((process.env.NODE_ENV !== 'production') && !Availabilities.dateTimeFormat) { + onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_DATE)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseDateTimeArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!isString(key) || key === '') { + return new Intl.DateTimeFormat(locale, overrides).format(value); + } + // resolve format + let datetimeFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'datetime format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if ((process.env.NODE_ENV !== 'production') && + locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if ((process.env.NODE_ENV !== 'production') && locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + datetimeFormat = + datetimeFormats[targetLocale] || {}; + format = datetimeFormat[key]; + if (isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!isPlainObject(format) || !isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __datetimeFormatters.get(id); + if (!formatter) { + formatter = new Intl.DateTimeFormat(targetLocale, assign({}, format, overrides)); + __datetimeFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); +} +/** @internal */ +const DATETIME_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'weekday', + 'era', + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second', + 'timeZoneName', + 'formatMatcher', + 'hour12', + 'timeZone', + 'dateStyle', + 'timeStyle', + 'calendar', + 'dayPeriod', + 'numberingSystem', + 'hourCycle', + 'fractionalSecondDigits' +]; +/** @internal */ +function parseDateTimeArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = create(); + let overrides = create(); + let value; + if (isString(arg1)) { + // Only allow ISO strings - other date formats are often supported, + // but may cause different results in different browsers. + const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/); + if (!matches) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + // Some browsers can not parse the iso datetime separated by space, + // this is a compromise solution by replace the 'T'/' ' with 'T' + const dateTime = matches[3] + ? matches[3].trim().startsWith('T') + ? `${matches[1].trim()}${matches[3].trim()}` + : `${matches[1].trim()}T${matches[3].trim()}` + : matches[1].trim(); + value = new Date(dateTime); + try { + // This will fail if the date is not valid + value.toISOString(); + } + catch (e) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + } + else if (isDate(arg1)) { + if (isNaN(arg1.getTime())) { + throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT); + } + value = arg1; + } + else if (isNumber(arg1)) { + value = arg1; + } + else { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + if (isString(arg2)) { + options.key = arg2; + } + else if (isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isPlainObject(arg3)) { + overrides = arg3; + } + if (isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; +} +/** @internal */ +function clearDateTimeFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__datetimeFormatters.has(id)) { + continue; + } + context.__datetimeFormatters.delete(id); + } +} + +// implementation of `number` function +function number(context, ...args) { + const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __numberFormatters } = context; + if ((process.env.NODE_ENV !== 'production') && !Availabilities.numberFormat) { + onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_NUMBER)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseNumberArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!isString(key) || key === '') { + return new Intl.NumberFormat(locale, overrides).format(value); + } + // resolve format + let numberFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'number format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if ((process.env.NODE_ENV !== 'production') && + locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if ((process.env.NODE_ENV !== 'production') && locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + numberFormat = + numberFormats[targetLocale] || {}; + format = numberFormat[key]; + if (isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!isPlainObject(format) || !isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __numberFormatters.get(id); + if (!formatter) { + formatter = new Intl.NumberFormat(targetLocale, assign({}, format, overrides)); + __numberFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); +} +/** @internal */ +const NUMBER_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'style', + 'currency', + 'currencyDisplay', + 'currencySign', + 'useGrouping', + 'minimumIntegerDigits', + 'minimumFractionDigits', + 'maximumFractionDigits', + 'minimumSignificantDigits', + 'maximumSignificantDigits', + 'compactDisplay', + 'notation', + 'signDisplay', + 'unit', + 'unitDisplay', + 'roundingMode', + 'roundingPriority', + 'roundingIncrement', + 'trailingZeroDisplay' +]; +/** @internal */ +function parseNumberArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = create(); + let overrides = create(); + if (!isNumber(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + const value = arg1; + if (isString(arg2)) { + options.key = arg2; + } + else if (isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isPlainObject(arg3)) { + overrides = arg3; + } + if (isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; +} +/** @internal */ +function clearNumberFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__numberFormatters.has(id)) { + continue; + } + context.__numberFormatters.delete(id); + } +} + +{ + initFeatureFlags(); +} + +export { AST_NODE_PROPS_KEYS, CoreErrorCodes, CoreWarnCodes, DATETIME_FORMAT_OPTIONS_KEYS, DEFAULT_LOCALE, DEFAULT_MESSAGE_DATA_TYPE, MISSING_RESOLVE_VALUE, NOT_REOSLVED, NUMBER_FORMAT_OPTIONS_KEYS, VERSION, clearCompileCache, clearDateTimeFormat, clearNumberFormat, compile, compileToFunction, createCoreContext, createCoreError, createMessageContext, datetime, fallbackWithLocaleChain, fallbackWithSimple, getAdditionalMeta, getDevToolsHook, getFallbackContext, getLocale, getWarnMessage, handleMissing, initI18nDevTools, isAlmostSameLocale, isImplicitFallback, isMessageAST, isMessageFunction, isTranslateFallbackWarn, isTranslateMissingWarn, number, parse, parseDateTimeArgs, parseNumberArgs, parseTranslateArgs, registerLocaleFallbacker, registerMessageCompiler, registerMessageResolver, resolveLocale, resolveValue, resolveWithKeyValue, setAdditionalMeta, setDevToolsHook, setFallbackContext, translate, translateDevTools, updateFallbackLocale }; diff --git a/node_modules/@intlify/core-base/dist/core-base.prod.cjs b/node_modules/@intlify/core-base/dist/core-base.prod.cjs new file mode 100644 index 0000000..4eb6db5 --- /dev/null +++ b/node_modules/@intlify/core-base/dist/core-base.prod.cjs @@ -0,0 +1,1677 @@ +/*! + * core-base v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +'use strict'; + +var messageCompiler = require('@intlify/message-compiler'); +var shared = require('@intlify/shared'); + +function isMessageAST(val) { + return (shared.isObject(val) && + resolveType(val) === 0 && + (shared.hasOwn(val, 'b') || shared.hasOwn(val, 'body'))); +} +const PROPS_BODY = ['b', 'body']; +function resolveBody(node) { + return resolveProps(node, PROPS_BODY); +} +const PROPS_CASES = ['c', 'cases']; +function resolveCases(node) { + return resolveProps(node, PROPS_CASES, []); +} +const PROPS_STATIC = ['s', 'static']; +function resolveStatic(node) { + return resolveProps(node, PROPS_STATIC); +} +const PROPS_ITEMS = ['i', 'items']; +function resolveItems(node) { + return resolveProps(node, PROPS_ITEMS, []); +} +const PROPS_TYPE = ['t', 'type']; +function resolveType(node) { + return resolveProps(node, PROPS_TYPE); +} +const PROPS_VALUE = ['v', 'value']; +function resolveValue$1(node, type) { + const resolved = resolveProps(node, PROPS_VALUE); + if (resolved != null) { + return resolved; + } + else { + throw createUnhandleNodeError(type); + } +} +const PROPS_MODIFIER = ['m', 'modifier']; +function resolveLinkedModifier(node) { + return resolveProps(node, PROPS_MODIFIER); +} +const PROPS_KEY = ['k', 'key']; +function resolveLinkedKey(node) { + const resolved = resolveProps(node, PROPS_KEY); + if (resolved) { + return resolved; + } + else { + throw createUnhandleNodeError(6 /* NodeTypes.Linked */); + } +} +function resolveProps(node, props, defaultValue) { + for (let i = 0; i < props.length; i++) { + const prop = props[i]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (shared.hasOwn(node, prop) && node[prop] != null) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return node[prop]; + } + } + return defaultValue; +} +const AST_NODE_PROPS_KEYS = [ + ...PROPS_BODY, + ...PROPS_CASES, + ...PROPS_STATIC, + ...PROPS_ITEMS, + ...PROPS_KEY, + ...PROPS_MODIFIER, + ...PROPS_VALUE, + ...PROPS_TYPE +]; +function createUnhandleNodeError(type) { + return new Error(`unhandled node type: ${type}`); +} + +const pathStateMachine = []; +pathStateMachine[0 /* States.BEFORE_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [0 /* States.BEFORE_PATH */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] +}; +pathStateMachine[1 /* States.IN_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] +}; +pathStateMachine[2 /* States.BEFORE_IDENT */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [2 /* States.BEFORE_IDENT */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */] +}; +pathStateMachine[3 /* States.IN_IDENT */] = { + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */, 1 /* Actions.PUSH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */, 1 /* Actions.PUSH */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */, 1 /* Actions.PUSH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */, 1 /* Actions.PUSH */] +}; +pathStateMachine[4 /* States.IN_SUB_PATH */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */], + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [ + 4 /* States.IN_SUB_PATH */, + 2 /* Actions.INC_SUB_PATH_DEPTH */ + ], + ["]" /* PathCharTypes.RIGHT_BRACKET */]: [1 /* States.IN_PATH */, 3 /* Actions.PUSH_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */] +}; +pathStateMachine[5 /* States.IN_SINGLE_QUOTE */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */] +}; +pathStateMachine[6 /* States.IN_DOUBLE_QUOTE */] = { + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */] +}; +/** + * Check if an expression is a literal value. + */ +const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/; +function isLiteral(exp) { + return literalValueRE.test(exp); +} +/** + * Strip quotes from a string + */ +function stripQuotes(str) { + const a = str.charCodeAt(0); + const b = str.charCodeAt(str.length - 1); + return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str; +} +/** + * Determine the type of a character in a keypath. + */ +function getPathCharType(ch) { + if (ch === undefined || ch === null) { + return "o" /* PathCharTypes.END_OF_FAIL */; + } + const code = ch.charCodeAt(0); + switch (code) { + case 0x5b: // [ + case 0x5d: // ] + case 0x2e: // . + case 0x22: // " + case 0x27: // ' + return ch; + case 0x5f: // _ + case 0x24: // $ + case 0x2d: // - + return "i" /* PathCharTypes.IDENT */; + case 0x09: // Tab (HT) + case 0x0a: // Newline (LF) + case 0x0d: // Return (CR) + case 0xa0: // No-break space (NBSP) + case 0xfeff: // Byte Order Mark (BOM) + case 0x2028: // Line Separator (LS) + case 0x2029: // Paragraph Separator (PS) + return "w" /* PathCharTypes.WORKSPACE */; + } + return "i" /* PathCharTypes.IDENT */; +} +/** + * Format a subPath, return its plain form if it is + * a literal string or number. Otherwise prepend the + * dynamic indicator (*). + */ +function formatSubPath(path) { + const trimmed = path.trim(); + // invalid leading 0 + if (path.charAt(0) === '0' && isNaN(parseInt(path))) { + return false; + } + return isLiteral(trimmed) + ? stripQuotes(trimmed) + : "*" /* PathCharTypes.ASTARISK */ + trimmed; +} +/** + * Parse a string path into an array of segments + */ +function parse(path) { + const keys = []; + let index = -1; + let mode = 0 /* States.BEFORE_PATH */; + let subPathDepth = 0; + let c; + let key; // eslint-disable-line + let newChar; + let type; + let transition; + let action; + let typeMap; + const actions = []; + actions[0 /* Actions.APPEND */] = () => { + if (key === undefined) { + key = newChar; + } + else { + key += newChar; + } + }; + actions[1 /* Actions.PUSH */] = () => { + if (key !== undefined) { + keys.push(key); + key = undefined; + } + }; + actions[2 /* Actions.INC_SUB_PATH_DEPTH */] = () => { + actions[0 /* Actions.APPEND */](); + subPathDepth++; + }; + actions[3 /* Actions.PUSH_SUB_PATH */] = () => { + if (subPathDepth > 0) { + subPathDepth--; + mode = 4 /* States.IN_SUB_PATH */; + actions[0 /* Actions.APPEND */](); + } + else { + subPathDepth = 0; + if (key === undefined) { + return false; + } + key = formatSubPath(key); + if (key === false) { + return false; + } + else { + actions[1 /* Actions.PUSH */](); + } + } + }; + function maybeUnescapeQuote() { + const nextChar = path[index + 1]; + if ((mode === 5 /* States.IN_SINGLE_QUOTE */ && + nextChar === "'" /* PathCharTypes.SINGLE_QUOTE */) || + (mode === 6 /* States.IN_DOUBLE_QUOTE */ && + nextChar === "\"" /* PathCharTypes.DOUBLE_QUOTE */)) { + index++; + newChar = '\\' + nextChar; + actions[0 /* Actions.APPEND */](); + return true; + } + } + while (mode !== null) { + index++; + c = path[index]; + if (c === '\\' && maybeUnescapeQuote()) { + continue; + } + type = getPathCharType(c); + typeMap = pathStateMachine[mode]; + transition = typeMap[type] || typeMap["l" /* PathCharTypes.ELSE */] || 8 /* States.ERROR */; + // check parse error + if (transition === 8 /* States.ERROR */) { + return; + } + mode = transition[0]; + if (transition[1] !== undefined) { + action = actions[transition[1]]; + if (action) { + newChar = c; + if (action() === false) { + return; + } + } + } + // check parse finish + if (mode === 7 /* States.AFTER_PATH */) { + return keys; + } + } +} +// path token cache +const cache = new Map(); +/** + * key-value message resolver + * + * @remarks + * Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ +function resolveWithKeyValue(obj, path) { + return shared.isObject(obj) ? obj[path] : null; +} +/** + * message resolver + * + * @remarks + * Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default. + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ +function resolveValue(obj, path) { + // check object + if (!shared.isObject(obj)) { + return null; + } + // parse path + let hit = cache.get(path); + if (!hit) { + hit = parse(path); + if (hit) { + cache.set(path, hit); + } + } + // check hit + if (!hit) { + return null; + } + // resolve path value + const len = hit.length; + let last = obj; + let i = 0; + while (i < len) { + const key = hit[i]; + /** + * NOTE: + * if `key` is intlify message format AST node key and `last` is intlify message format AST, skip it. + * because the AST node is not a key-value structure. + */ + if (AST_NODE_PROPS_KEYS.includes(key) && isMessageAST(last)) { + return null; + } + const val = last[key]; + if (val === undefined) { + return null; + } + if (shared.isFunction(last)) { + return null; + } + last = val; + i++; + } + return last; +} + +const DEFAULT_MODIFIER = (str) => str; +const DEFAULT_MESSAGE = (ctx) => ''; // eslint-disable-line +const DEFAULT_MESSAGE_DATA_TYPE = 'text'; +const DEFAULT_NORMALIZE = (values) => values.length === 0 ? '' : shared.join(values); +const DEFAULT_INTERPOLATE = shared.toDisplayString; +function pluralDefault(choice, choicesLength) { + choice = Math.abs(choice); + if (choicesLength === 2) { + // prettier-ignore + return choice + ? choice > 1 + ? 1 + : 0 + : 1; + } + return choice ? Math.min(choice, 2) : 0; +} +function getPluralIndex(options) { + // prettier-ignore + const index = shared.isNumber(options.pluralIndex) + ? options.pluralIndex + : -1; + // prettier-ignore + return options.named && (shared.isNumber(options.named.count) || shared.isNumber(options.named.n)) + ? shared.isNumber(options.named.count) + ? options.named.count + : shared.isNumber(options.named.n) + ? options.named.n + : index + : index; +} +function normalizeNamed(pluralIndex, props) { + if (!props.count) { + props.count = pluralIndex; + } + if (!props.n) { + props.n = pluralIndex; + } +} +function createMessageContext(options = {}) { + const locale = options.locale; + const pluralIndex = getPluralIndex(options); + const pluralRule = shared.isObject(options.pluralRules) && + shared.isString(locale) && + shared.isFunction(options.pluralRules[locale]) + ? options.pluralRules[locale] + : pluralDefault; + const orgPluralRule = shared.isObject(options.pluralRules) && + shared.isString(locale) && + shared.isFunction(options.pluralRules[locale]) + ? pluralDefault + : undefined; + const plural = (messages) => { + return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)]; + }; + const _list = options.list || []; + const list = (index) => _list[index]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _named = options.named || shared.create(); + shared.isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named); + const named = (key) => _named[key]; + function message(key) { + // prettier-ignore + const msg = shared.isFunction(options.messages) + ? options.messages(key) + : shared.isObject(options.messages) + ? options.messages[key] + : false; + return !msg + ? options.parent + ? options.parent.message(key) // resolve from parent messages + : DEFAULT_MESSAGE + : msg; + } + const _modifier = (name) => options.modifiers + ? options.modifiers[name] + : DEFAULT_MODIFIER; + const normalize = shared.isPlainObject(options.processor) && shared.isFunction(options.processor.normalize) + ? options.processor.normalize + : DEFAULT_NORMALIZE; + const interpolate = shared.isPlainObject(options.processor) && + shared.isFunction(options.processor.interpolate) + ? options.processor.interpolate + : DEFAULT_INTERPOLATE; + const type = shared.isPlainObject(options.processor) && shared.isString(options.processor.type) + ? options.processor.type + : DEFAULT_MESSAGE_DATA_TYPE; + const linked = (key, ...args) => { + const [arg1, arg2] = args; + let type = 'text'; + let modifier = ''; + if (args.length === 1) { + if (shared.isObject(arg1)) { + modifier = arg1.modifier || modifier; + type = arg1.type || type; + } + else if (shared.isString(arg1)) { + modifier = arg1 || modifier; + } + } + else if (args.length === 2) { + if (shared.isString(arg1)) { + modifier = arg1 || modifier; + } + if (shared.isString(arg2)) { + type = arg2 || type; + } + } + const ret = message(key)(ctx); + const msg = + // The message in vnode resolved with linked are returned as an array by processor.nomalize + type === 'vnode' && shared.isArray(ret) && modifier + ? ret[0] + : ret; + return modifier ? _modifier(modifier)(msg, type) : msg; + }; + const ctx = { + ["list" /* HelperNameMap.LIST */]: list, + ["named" /* HelperNameMap.NAMED */]: named, + ["plural" /* HelperNameMap.PLURAL */]: plural, + ["linked" /* HelperNameMap.LINKED */]: linked, + ["message" /* HelperNameMap.MESSAGE */]: message, + ["type" /* HelperNameMap.TYPE */]: type, + ["interpolate" /* HelperNameMap.INTERPOLATE */]: interpolate, + ["normalize" /* HelperNameMap.NORMALIZE */]: normalize, + ["values" /* HelperNameMap.VALUES */]: shared.assign(shared.create(), _list, _named) + }; + return ctx; +} + +let devtools = null; +function setDevToolsHook(hook) { + devtools = hook; +} +function getDevToolsHook() { + return devtools; +} +function initI18nDevTools(i18n, version, meta) { + // TODO: queue if devtools is undefined + devtools && + devtools.emit("i18n:init" /* IntlifyDevToolsHooks.I18nInit */, { + timestamp: Date.now(), + i18n, + version, + meta + }); +} +const translateDevTools = /* #__PURE__*/ createDevToolsHook("function:translate" /* IntlifyDevToolsHooks.FunctionTranslate */); +function createDevToolsHook(hook) { + return (payloads) => devtools && devtools.emit(hook, payloads); +} + +const code$1 = messageCompiler.CompileWarnCodes.__EXTEND_POINT__; +const inc$1 = shared.incrementer(code$1); +const CoreWarnCodes = { + NOT_FOUND_KEY: code$1, // 2 + FALLBACK_TO_TRANSLATE: inc$1(), // 3 + CANNOT_FORMAT_NUMBER: inc$1(), // 4 + FALLBACK_TO_NUMBER_FORMAT: inc$1(), // 5 + CANNOT_FORMAT_DATE: inc$1(), // 6 + FALLBACK_TO_DATE_FORMAT: inc$1(), // 7 + EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc$1(), // 8 + __EXTEND_POINT__: inc$1() // 9 +}; +/** @internal */ +const warnMessages = { + [CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`, + [CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`, + [CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`, + [CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]: `This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future.` +}; +function getWarnMessage(code, ...args) { + return shared.format(warnMessages[code], ...args); +} + +const code = messageCompiler.CompileErrorCodes.__EXTEND_POINT__; +const inc = shared.incrementer(code); +const CoreErrorCodes = { + INVALID_ARGUMENT: code, // 17 + INVALID_DATE_ARGUMENT: inc(), // 18 + INVALID_ISO_DATE_ARGUMENT: inc(), // 19 + NOT_SUPPORT_NON_STRING_MESSAGE: inc(), // 20 + NOT_SUPPORT_LOCALE_PROMISE_VALUE: inc(), // 21 + NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: inc(), // 22 + NOT_SUPPORT_LOCALE_TYPE: inc(), // 23 + __EXTEND_POINT__: inc() // 24 +}; +function createCoreError(code) { + return messageCompiler.createCompileError(code, null, undefined); +} +/** @internal */ +({ + [CoreErrorCodes.INVALID_ARGUMENT]: 'Invalid arguments', + [CoreErrorCodes.INVALID_DATE_ARGUMENT]: 'The date provided is an invalid Date object.' + + 'Make sure your Date represents a valid date.', + [CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: 'The argument provided is not a valid ISO date string', + [CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE]: 'Not support non-string message', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]: 'cannot support promise value', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]: 'cannot support async function', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: 'cannot support locale type' +}); + +/** @internal */ +function getLocale(context, options) { + return options.locale != null + ? resolveLocale(options.locale) + : resolveLocale(context.locale); +} +let _resolveLocale; +/** @internal */ +function resolveLocale(locale) { + if (shared.isString(locale)) { + return locale; + } + else { + if (shared.isFunction(locale)) { + if (locale.resolvedOnce && _resolveLocale != null) { + return _resolveLocale; + } + else if (locale.constructor.name === 'Function') { + const resolve = locale(); + if (shared.isPromise(resolve)) { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE); + } + return (_resolveLocale = resolve); + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION); + } + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE); + } + } +} +/** + * Fallback with simple implemenation + * + * @remarks + * A fallback locale function implemented with a simple fallback algorithm. + * + * Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nGeneral + */ +function fallbackWithSimple(ctx, fallback, start // eslint-disable-line @typescript-eslint/no-unused-vars +) { + // prettier-ignore + return [...new Set([ + start, + ...(shared.isArray(fallback) + ? fallback + : shared.isObject(fallback) + ? Object.keys(fallback) + : shared.isString(fallback) + ? [fallback] + : [start]) + ])]; +} +/** + * Fallback with locale chain + * + * @remarks + * A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @VueI18nGeneral + */ +function fallbackWithLocaleChain(ctx, fallback, start) { + const startLocale = shared.isString(start) ? start : DEFAULT_LOCALE; + const context = ctx; + if (!context.__localeChainCache) { + context.__localeChainCache = new Map(); + } + let chain = context.__localeChainCache.get(startLocale); + if (!chain) { + chain = []; + // first block defined by start + let block = [start]; + // while any intervening block found + while (shared.isArray(block)) { + block = appendBlockToChain(chain, block, fallback); + } + // prettier-ignore + // last block defined by default + const defaults = shared.isArray(fallback) || !shared.isPlainObject(fallback) + ? fallback + : fallback['default'] + ? fallback['default'] + : null; + // convert defaults to array + block = shared.isString(defaults) ? [defaults] : defaults; + if (shared.isArray(block)) { + appendBlockToChain(chain, block, false); + } + context.__localeChainCache.set(startLocale, chain); + } + return chain; +} +function appendBlockToChain(chain, block, blocks) { + let follow = true; + for (let i = 0; i < block.length && shared.isBoolean(follow); i++) { + const locale = block[i]; + if (shared.isString(locale)) { + follow = appendLocaleToChain(chain, block[i], blocks); + } + } + return follow; +} +function appendLocaleToChain(chain, locale, blocks) { + let follow; + const tokens = locale.split('-'); + do { + const target = tokens.join('-'); + follow = appendItemToChain(chain, target, blocks); + tokens.splice(-1, 1); + } while (tokens.length && follow === true); + return follow; +} +function appendItemToChain(chain, target, blocks) { + let follow = false; + if (!chain.includes(target)) { + follow = true; + if (target) { + follow = target[target.length - 1] !== '!'; + const locale = target.replace(/!/g, ''); + chain.push(locale); + if ((shared.isArray(blocks) || shared.isPlainObject(blocks)) && + blocks[locale] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + follow = blocks[locale]; + } + } + } + return follow; +} + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Intlify core-base version + * @internal + */ +const VERSION = '9.14.5'; +const NOT_REOSLVED = -1; +const DEFAULT_LOCALE = 'en-US'; +const MISSING_RESOLVE_VALUE = ''; +const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`; +function getDefaultLinkedModifiers() { + return { + upper: (val, type) => { + // prettier-ignore + return type === 'text' && shared.isString(val) + ? val.toUpperCase() + : type === 'vnode' && shared.isObject(val) && '__v_isVNode' in val + ? val.children.toUpperCase() + : val; + }, + lower: (val, type) => { + // prettier-ignore + return type === 'text' && shared.isString(val) + ? val.toLowerCase() + : type === 'vnode' && shared.isObject(val) && '__v_isVNode' in val + ? val.children.toLowerCase() + : val; + }, + capitalize: (val, type) => { + // prettier-ignore + return (type === 'text' && shared.isString(val) + ? capitalize(val) + : type === 'vnode' && shared.isObject(val) && '__v_isVNode' in val + ? capitalize(val.children) + : val); + } + }; +} +let _compiler; +function registerMessageCompiler(compiler) { + _compiler = compiler; +} +let _resolver; +/** + * Register the message resolver + * + * @param resolver - A {@link MessageResolver} function + * + * @VueI18nGeneral + */ +function registerMessageResolver(resolver) { + _resolver = resolver; +} +let _fallbacker; +/** + * Register the locale fallbacker + * + * @param fallbacker - A {@link LocaleFallbacker} function + * + * @VueI18nGeneral + */ +function registerLocaleFallbacker(fallbacker) { + _fallbacker = fallbacker; +} +// Additional Meta for Intlify DevTools +let _additionalMeta = null; +/* #__NO_SIDE_EFFECTS__ */ +const setAdditionalMeta = (meta) => { + _additionalMeta = meta; +}; +/* #__NO_SIDE_EFFECTS__ */ +const getAdditionalMeta = () => _additionalMeta; +let _fallbackContext = null; +const setFallbackContext = (context) => { + _fallbackContext = context; +}; +const getFallbackContext = () => _fallbackContext; +// ID for CoreContext +let _cid = 0; +function createCoreContext(options = {}) { + // setup options + const onWarn = shared.isFunction(options.onWarn) ? options.onWarn : shared.warn; + const version = shared.isString(options.version) ? options.version : VERSION; + const locale = shared.isString(options.locale) || shared.isFunction(options.locale) + ? options.locale + : DEFAULT_LOCALE; + const _locale = shared.isFunction(locale) ? DEFAULT_LOCALE : locale; + const fallbackLocale = shared.isArray(options.fallbackLocale) || + shared.isPlainObject(options.fallbackLocale) || + shared.isString(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale; + const messages = shared.isPlainObject(options.messages) + ? options.messages + : createResources(_locale); + const datetimeFormats = shared.isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : createResources(_locale) + ; + const numberFormats = shared.isPlainObject(options.numberFormats) + ? options.numberFormats + : createResources(_locale) + ; + const modifiers = shared.assign(shared.create(), options.modifiers, getDefaultLinkedModifiers()); + const pluralRules = options.pluralRules || shared.create(); + const missing = shared.isFunction(options.missing) ? options.missing : null; + const missingWarn = shared.isBoolean(options.missingWarn) || shared.isRegExp(options.missingWarn) + ? options.missingWarn + : true; + const fallbackWarn = shared.isBoolean(options.fallbackWarn) || shared.isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + const fallbackFormat = !!options.fallbackFormat; + const unresolving = !!options.unresolving; + const postTranslation = shared.isFunction(options.postTranslation) + ? options.postTranslation + : null; + const processor = shared.isPlainObject(options.processor) ? options.processor : null; + const warnHtmlMessage = shared.isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const escapeParameter = !!options.escapeParameter; + const messageCompiler = shared.isFunction(options.messageCompiler) + ? options.messageCompiler + : _compiler; + const messageResolver = shared.isFunction(options.messageResolver) + ? options.messageResolver + : _resolver || resolveWithKeyValue; + const localeFallbacker = shared.isFunction(options.localeFallbacker) + ? options.localeFallbacker + : _fallbacker || fallbackWithSimple; + const fallbackContext = shared.isObject(options.fallbackContext) + ? options.fallbackContext + : undefined; + // setup internal options + const internalOptions = options; + const __datetimeFormatters = shared.isObject(internalOptions.__datetimeFormatters) + ? internalOptions.__datetimeFormatters + : new Map() + ; + const __numberFormatters = shared.isObject(internalOptions.__numberFormatters) + ? internalOptions.__numberFormatters + : new Map() + ; + const __meta = shared.isObject(internalOptions.__meta) ? internalOptions.__meta : {}; + _cid++; + const context = { + version, + cid: _cid, + locale, + fallbackLocale, + messages, + modifiers, + pluralRules, + missing, + missingWarn, + fallbackWarn, + fallbackFormat, + unresolving, + postTranslation, + processor, + warnHtmlMessage, + escapeParameter, + messageCompiler, + messageResolver, + localeFallbacker, + fallbackContext, + onWarn, + __meta + }; + { + context.datetimeFormats = datetimeFormats; + context.numberFormats = numberFormats; + context.__datetimeFormatters = __datetimeFormatters; + context.__numberFormatters = __numberFormatters; + } + return context; +} +const createResources = (locale) => ({ [locale]: shared.create() }); +/** @internal */ +function isTranslateFallbackWarn(fallback, key) { + return fallback instanceof RegExp ? fallback.test(key) : fallback; +} +/** @internal */ +function isTranslateMissingWarn(missing, key) { + return missing instanceof RegExp ? missing.test(key) : missing; +} +/** @internal */ +function handleMissing(context, key, locale, missingWarn, type) { + const { missing, onWarn } = context; + if (missing !== null) { + const ret = missing(context, locale, key, type); + return shared.isString(ret) ? ret : key; + } + else { + return key; + } +} +/** @internal */ +function updateFallbackLocale(ctx, locale, fallback) { + const context = ctx; + context.__localeChainCache = new Map(); + ctx.localeFallbacker(ctx, fallback, locale); +} +/** @internal */ +function isAlmostSameLocale(locale, compareLocale) { + if (locale === compareLocale) + return false; + return locale.split('-')[0] === compareLocale.split('-')[0]; +} +/** @internal */ +function isImplicitFallback(targetLocale, locales) { + const index = locales.indexOf(targetLocale); + if (index === -1) { + return false; + } + for (let i = index + 1; i < locales.length; i++) { + if (isAlmostSameLocale(targetLocale, locales[i])) { + return true; + } + } + return false; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +function format(ast) { + const msg = (ctx) => formatParts(ctx, ast); + return msg; +} +function formatParts(ctx, ast) { + const body = resolveBody(ast); + if (body == null) { + throw createUnhandleNodeError(0 /* NodeTypes.Resource */); + } + const type = resolveType(body); + if (type === 1 /* NodeTypes.Plural */) { + const plural = body; + const cases = resolveCases(plural); + return ctx.plural(cases.reduce((messages, c) => [ + ...messages, + formatMessageParts(ctx, c) + ], [])); + } + else { + return formatMessageParts(ctx, body); + } +} +function formatMessageParts(ctx, node) { + const static_ = resolveStatic(node); + if (static_ != null) { + return ctx.type === 'text' + ? static_ + : ctx.normalize([static_]); + } + else { + const messages = resolveItems(node).reduce((acm, c) => [...acm, formatMessagePart(ctx, c)], []); + return ctx.normalize(messages); + } +} +function formatMessagePart(ctx, node) { + const type = resolveType(node); + switch (type) { + case 3 /* NodeTypes.Text */: { + return resolveValue$1(node, type); + } + case 9 /* NodeTypes.Literal */: { + return resolveValue$1(node, type); + } + case 4 /* NodeTypes.Named */: { + const named = node; + if (shared.hasOwn(named, 'k') && named.k) { + return ctx.interpolate(ctx.named(named.k)); + } + if (shared.hasOwn(named, 'key') && named.key) { + return ctx.interpolate(ctx.named(named.key)); + } + throw createUnhandleNodeError(type); + } + case 5 /* NodeTypes.List */: { + const list = node; + if (shared.hasOwn(list, 'i') && shared.isNumber(list.i)) { + return ctx.interpolate(ctx.list(list.i)); + } + if (shared.hasOwn(list, 'index') && shared.isNumber(list.index)) { + return ctx.interpolate(ctx.list(list.index)); + } + throw createUnhandleNodeError(type); + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + const modifier = resolveLinkedModifier(linked); + const key = resolveLinkedKey(linked); + return ctx.linked(formatMessagePart(ctx, key), modifier ? formatMessagePart(ctx, modifier) : undefined, ctx.type); + } + case 7 /* NodeTypes.LinkedKey */: { + return resolveValue$1(node, type); + } + case 8 /* NodeTypes.LinkedModifier */: { + return resolveValue$1(node, type); + } + default: + throw new Error(`unhandled node on format message part: ${type}`); + } +} + +const defaultOnCacheKey = (message) => message; +let compileCache = shared.create(); +function clearCompileCache() { + compileCache = shared.create(); +} +function baseCompile(message, options = {}) { + // error detecting on compile + let detectError = false; + const onError = options.onError || messageCompiler.defaultOnError; + options.onError = (err) => { + detectError = true; + onError(err); + }; + // compile with mesasge-compiler + return { ...messageCompiler.baseCompile(message, options), detectError }; +} +/* #__NO_SIDE_EFFECTS__ */ +const compileToFunction = (message, context) => { + if (!shared.isString(message)) { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE); + } + { + // check HTML message + shared.isBoolean(context.warnHtmlMessage) + ? context.warnHtmlMessage + : true; + // check caches + const onCacheKey = context.onCacheKey || defaultOnCacheKey; + const cacheKey = onCacheKey(message); + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compile + const { code, detectError } = baseCompile(message, context); + // evaluate function + const msg = new Function(`return ${code}`)(); + // if occurred compile error, don't cache + return !detectError + ? (compileCache[cacheKey] = msg) + : msg; + } +}; +function compile(message, context) { + if (shared.isString(message)) { + // check HTML message + shared.isBoolean(context.warnHtmlMessage) + ? context.warnHtmlMessage + : true; + // check caches + const onCacheKey = context.onCacheKey || defaultOnCacheKey; + const cacheKey = onCacheKey(message); + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compile with JIT mode + const { ast, detectError } = baseCompile(message, { + ...context, + location: false, + jit: true + }); + // compose message function from AST + const msg = format(ast); + // if occurred compile error, don't cache + return !detectError + ? (compileCache[cacheKey] = msg) + : msg; + } + else { + // AST case (passed from bundler) + const cacheKey = message.cacheKey; + if (cacheKey) { + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compose message function from message (AST) + return (compileCache[cacheKey] = + format(message)); + } + else { + return format(message); + } + } +} + +const NOOP_MESSAGE_FUNCTION = () => ''; +const isMessageFunction = (val) => shared.isFunction(val); +// implementation of `translate` function +function translate(context, ...args) { + const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context; + const [key, options] = parseTranslateArgs(...args); + const missingWarn = shared.isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = shared.isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const escapeParameter = shared.isBoolean(options.escapeParameter) + ? options.escapeParameter + : context.escapeParameter; + const resolvedMessage = !!options.resolvedMessage; + // prettier-ignore + const defaultMsgOrKey = shared.isString(options.default) || shared.isBoolean(options.default) // default by function option + ? !shared.isBoolean(options.default) + ? options.default + : (!messageCompiler ? () => key : key) + : fallbackFormat // default by `fallbackFormat` option + ? (!messageCompiler ? () => key : key) + : ''; + const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== ''; + const locale = getLocale(context, options); + // escape params + escapeParameter && escapeParams(options); + // resolve message format + // eslint-disable-next-line prefer-const + let [formatScope, targetLocale, message] = !resolvedMessage + ? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) + : [ + key, + locale, + messages[locale] || shared.create() + ]; + // NOTE: + // Fix to work around `ssrTransfrom` bug in Vite. + // https://github.com/vitejs/vite/issues/4306 + // To get around this, use temporary variables. + // https://github.com/nuxt/framework/issues/1461#issuecomment-954606243 + let format = formatScope; + // if you use default message, set it as message format! + let cacheBaseKey = key; + if (!resolvedMessage && + !(shared.isString(format) || + isMessageAST(format) || + isMessageFunction(format))) { + if (enableDefaultMsg) { + format = defaultMsgOrKey; + cacheBaseKey = format; + } + } + // checking message format and target locale + if (!resolvedMessage && + (!(shared.isString(format) || + isMessageAST(format) || + isMessageFunction(format)) || + !shared.isString(targetLocale))) { + return unresolving ? NOT_REOSLVED : key; + } + // setup compile error detecting + let occurred = false; + const onError = () => { + occurred = true; + }; + // compile message format + const msg = !isMessageFunction(format) + ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) + : format; + // if occurred compile error, return the message format + if (occurred) { + return format; + } + // evaluate message with context + const ctxOptions = getMessageContextOptions(context, targetLocale, message, options); + const msgContext = createMessageContext(ctxOptions); + const messaged = evaluateMessage(context, msg, msgContext); + // if use post translation option, proceed it with handler + let ret = postTranslation + ? postTranslation(messaged, key) + : messaged; + // apply HTML sanitization for security + if (escapeParameter && shared.isString(ret)) { + ret = shared.sanitizeTranslatedHtml(ret); + } + return ret; +} +function escapeParams(options) { + if (shared.isArray(options.list)) { + options.list = options.list.map(item => shared.isString(item) ? shared.escapeHtml(item) : item); + } + else if (shared.isObject(options.named)) { + Object.keys(options.named).forEach(key => { + if (shared.isString(options.named[key])) { + options.named[key] = shared.escapeHtml(options.named[key]); + } + }); + } +} +function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) { + const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context; + const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any + let message = shared.create(); + let targetLocale; + let format = null; + const type = 'translate'; + for (let i = 0; i < locales.length; i++) { + targetLocale = locales[i]; + message = + messages[targetLocale] || shared.create(); + if ((format = resolveValue(message, key)) === null) { + // if null, resolve with object key path + format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any + } + if (shared.isString(format) || isMessageAST(format) || isMessageFunction(format)) { + break; + } + if (!isImplicitFallback(targetLocale, locales)) { + const missingRet = handleMissing(context, // eslint-disable-line @typescript-eslint/no-explicit-any + key, targetLocale, missingWarn, type); + if (missingRet !== key) { + format = missingRet; + } + } + } + return [format, targetLocale, message]; +} +function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) { + const { messageCompiler, warnHtmlMessage } = context; + if (isMessageFunction(format)) { + const msg = format; + msg.locale = msg.locale || targetLocale; + msg.key = msg.key || key; + return msg; + } + if (messageCompiler == null) { + const msg = (() => format); + msg.locale = targetLocale; + msg.key = key; + return msg; + } + const msg = messageCompiler(format, getCompileContext(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, onError)); + msg.locale = targetLocale; + msg.key = key; + msg.source = format; + return msg; +} +function evaluateMessage(context, msg, msgCtx) { + const messaged = msg(msgCtx); + return messaged; +} +/** @internal */ +function parseTranslateArgs(...args) { + const [arg1, arg2, arg3] = args; + const options = shared.create(); + if (!shared.isString(arg1) && + !shared.isNumber(arg1) && + !isMessageFunction(arg1) && + !isMessageAST(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + // prettier-ignore + const key = shared.isNumber(arg1) + ? String(arg1) + : isMessageFunction(arg1) + ? arg1 + : arg1; + if (shared.isNumber(arg2)) { + options.plural = arg2; + } + else if (shared.isString(arg2)) { + options.default = arg2; + } + else if (shared.isPlainObject(arg2) && !shared.isEmptyObject(arg2)) { + options.named = arg2; + } + else if (shared.isArray(arg2)) { + options.list = arg2; + } + if (shared.isNumber(arg3)) { + options.plural = arg3; + } + else if (shared.isString(arg3)) { + options.default = arg3; + } + else if (shared.isPlainObject(arg3)) { + shared.assign(options, arg3); + } + return [key, options]; +} +function getCompileContext(context, locale, key, source, warnHtmlMessage, onError) { + return { + locale, + key, + warnHtmlMessage, + onError: (err) => { + onError && onError(err); + { + throw err; + } + }, + onCacheKey: (source) => shared.generateFormatCacheKey(locale, key, source) + }; +} +function getMessageContextOptions(context, locale, message, options) { + const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context; + const resolveMessage = (key) => { + let val = resolveValue(message, key); + // fallback to root context + if (val == null && fallbackContext) { + const [, , message] = resolveMessageFormat(fallbackContext, key, locale, fallbackLocale, fallbackWarn, missingWarn); + val = resolveValue(message, key); + } + if (shared.isString(val) || isMessageAST(val)) { + let occurred = false; + const onError = () => { + occurred = true; + }; + const msg = compileMessageFormat(context, key, locale, val, key, onError); + return !occurred + ? msg + : NOOP_MESSAGE_FUNCTION; + } + else if (isMessageFunction(val)) { + return val; + } + else { + // TODO: should be implemented warning message + return NOOP_MESSAGE_FUNCTION; + } + }; + const ctxOptions = { + locale, + modifiers, + pluralRules, + messages: resolveMessage + }; + if (context.processor) { + ctxOptions.processor = context.processor; + } + if (options.list) { + ctxOptions.list = options.list; + } + if (options.named) { + ctxOptions.named = options.named; + } + if (shared.isNumber(options.plural)) { + ctxOptions.pluralIndex = options.plural; + } + return ctxOptions; +} + +// implementation of `datetime` function +function datetime(context, ...args) { + const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __datetimeFormatters } = context; + const [key, value, options, overrides] = parseDateTimeArgs(...args); + const missingWarn = shared.isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + shared.isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!shared.isString(key) || key === '') { + return new Intl.DateTimeFormat(locale, overrides).format(value); + } + // resolve format + let datetimeFormat = {}; + let targetLocale; + let format = null; + const type = 'datetime format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = locales[i]; + datetimeFormat = + datetimeFormats[targetLocale] || {}; + format = datetimeFormat[key]; + if (shared.isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + } + // checking format and target locale + if (!shared.isPlainObject(format) || !shared.isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!shared.isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __datetimeFormatters.get(id); + if (!formatter) { + formatter = new Intl.DateTimeFormat(targetLocale, shared.assign({}, format, overrides)); + __datetimeFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); +} +/** @internal */ +const DATETIME_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'weekday', + 'era', + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second', + 'timeZoneName', + 'formatMatcher', + 'hour12', + 'timeZone', + 'dateStyle', + 'timeStyle', + 'calendar', + 'dayPeriod', + 'numberingSystem', + 'hourCycle', + 'fractionalSecondDigits' +]; +/** @internal */ +function parseDateTimeArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = shared.create(); + let overrides = shared.create(); + let value; + if (shared.isString(arg1)) { + // Only allow ISO strings - other date formats are often supported, + // but may cause different results in different browsers. + const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/); + if (!matches) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + // Some browsers can not parse the iso datetime separated by space, + // this is a compromise solution by replace the 'T'/' ' with 'T' + const dateTime = matches[3] + ? matches[3].trim().startsWith('T') + ? `${matches[1].trim()}${matches[3].trim()}` + : `${matches[1].trim()}T${matches[3].trim()}` + : matches[1].trim(); + value = new Date(dateTime); + try { + // This will fail if the date is not valid + value.toISOString(); + } + catch (e) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + } + else if (shared.isDate(arg1)) { + if (isNaN(arg1.getTime())) { + throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT); + } + value = arg1; + } + else if (shared.isNumber(arg1)) { + value = arg1; + } + else { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + if (shared.isString(arg2)) { + options.key = arg2; + } + else if (shared.isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (shared.isString(arg3)) { + options.locale = arg3; + } + else if (shared.isPlainObject(arg3)) { + overrides = arg3; + } + if (shared.isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; +} +/** @internal */ +function clearDateTimeFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__datetimeFormatters.has(id)) { + continue; + } + context.__datetimeFormatters.delete(id); + } +} + +// implementation of `number` function +function number(context, ...args) { + const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __numberFormatters } = context; + const [key, value, options, overrides] = parseNumberArgs(...args); + const missingWarn = shared.isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + shared.isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!shared.isString(key) || key === '') { + return new Intl.NumberFormat(locale, overrides).format(value); + } + // resolve format + let numberFormat = {}; + let targetLocale; + let format = null; + const type = 'number format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = locales[i]; + numberFormat = + numberFormats[targetLocale] || {}; + format = numberFormat[key]; + if (shared.isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + } + // checking format and target locale + if (!shared.isPlainObject(format) || !shared.isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!shared.isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __numberFormatters.get(id); + if (!formatter) { + formatter = new Intl.NumberFormat(targetLocale, shared.assign({}, format, overrides)); + __numberFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); +} +/** @internal */ +const NUMBER_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'style', + 'currency', + 'currencyDisplay', + 'currencySign', + 'useGrouping', + 'minimumIntegerDigits', + 'minimumFractionDigits', + 'maximumFractionDigits', + 'minimumSignificantDigits', + 'maximumSignificantDigits', + 'compactDisplay', + 'notation', + 'signDisplay', + 'unit', + 'unitDisplay', + 'roundingMode', + 'roundingPriority', + 'roundingIncrement', + 'trailingZeroDisplay' +]; +/** @internal */ +function parseNumberArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = shared.create(); + let overrides = shared.create(); + if (!shared.isNumber(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + const value = arg1; + if (shared.isString(arg2)) { + options.key = arg2; + } + else if (shared.isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (shared.isString(arg3)) { + options.locale = arg3; + } + else if (shared.isPlainObject(arg3)) { + overrides = arg3; + } + if (shared.isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; +} +/** @internal */ +function clearNumberFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__numberFormatters.has(id)) { + continue; + } + context.__numberFormatters.delete(id); + } +} + +exports.CompileErrorCodes = messageCompiler.CompileErrorCodes; +exports.createCompileError = messageCompiler.createCompileError; +exports.AST_NODE_PROPS_KEYS = AST_NODE_PROPS_KEYS; +exports.CoreErrorCodes = CoreErrorCodes; +exports.CoreWarnCodes = CoreWarnCodes; +exports.DATETIME_FORMAT_OPTIONS_KEYS = DATETIME_FORMAT_OPTIONS_KEYS; +exports.DEFAULT_LOCALE = DEFAULT_LOCALE; +exports.DEFAULT_MESSAGE_DATA_TYPE = DEFAULT_MESSAGE_DATA_TYPE; +exports.MISSING_RESOLVE_VALUE = MISSING_RESOLVE_VALUE; +exports.NOT_REOSLVED = NOT_REOSLVED; +exports.NUMBER_FORMAT_OPTIONS_KEYS = NUMBER_FORMAT_OPTIONS_KEYS; +exports.VERSION = VERSION; +exports.clearCompileCache = clearCompileCache; +exports.clearDateTimeFormat = clearDateTimeFormat; +exports.clearNumberFormat = clearNumberFormat; +exports.compile = compile; +exports.compileToFunction = compileToFunction; +exports.createCoreContext = createCoreContext; +exports.createCoreError = createCoreError; +exports.createMessageContext = createMessageContext; +exports.datetime = datetime; +exports.fallbackWithLocaleChain = fallbackWithLocaleChain; +exports.fallbackWithSimple = fallbackWithSimple; +exports.getAdditionalMeta = getAdditionalMeta; +exports.getDevToolsHook = getDevToolsHook; +exports.getFallbackContext = getFallbackContext; +exports.getLocale = getLocale; +exports.getWarnMessage = getWarnMessage; +exports.handleMissing = handleMissing; +exports.initI18nDevTools = initI18nDevTools; +exports.isAlmostSameLocale = isAlmostSameLocale; +exports.isImplicitFallback = isImplicitFallback; +exports.isMessageAST = isMessageAST; +exports.isMessageFunction = isMessageFunction; +exports.isTranslateFallbackWarn = isTranslateFallbackWarn; +exports.isTranslateMissingWarn = isTranslateMissingWarn; +exports.number = number; +exports.parse = parse; +exports.parseDateTimeArgs = parseDateTimeArgs; +exports.parseNumberArgs = parseNumberArgs; +exports.parseTranslateArgs = parseTranslateArgs; +exports.registerLocaleFallbacker = registerLocaleFallbacker; +exports.registerMessageCompiler = registerMessageCompiler; +exports.registerMessageResolver = registerMessageResolver; +exports.resolveLocale = resolveLocale; +exports.resolveValue = resolveValue; +exports.resolveWithKeyValue = resolveWithKeyValue; +exports.setAdditionalMeta = setAdditionalMeta; +exports.setDevToolsHook = setDevToolsHook; +exports.setFallbackContext = setFallbackContext; +exports.translate = translate; +exports.translateDevTools = translateDevTools; +exports.updateFallbackLocale = updateFallbackLocale; diff --git a/node_modules/@intlify/core-base/index.js b/node_modules/@intlify/core-base/index.js new file mode 100644 index 0000000..9a6a8be --- /dev/null +++ b/node_modules/@intlify/core-base/index.js @@ -0,0 +1,7 @@ +'use strict' + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./dist/core-base.prod.cjs') +} else { + module.exports = require('./dist/core-base.cjs') +} diff --git a/node_modules/@intlify/core-base/package.json b/node_modules/@intlify/core-base/package.json new file mode 100644 index 0000000..5f018e0 --- /dev/null +++ b/node_modules/@intlify/core-base/package.json @@ -0,0 +1,81 @@ +{ + "name": "@intlify/core-base", + "version": "9.14.5", + "description": "@intlify/core-base", + "keywords": [ + "core", + "fundamental", + "i18n", + "internationalization", + "intlify" + ], + "license": "MIT", + "author": { + "name": "kazuya kawaguchi", + "email": "kawakazu80@gmail.com" + }, + "homepage": "https://github.com/intlify/vue-i18n/tree/master/packages/core-base#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/intlify/vue-i18n.git", + "directory": "packages/core" + }, + "bugs": { + "url": "https://github.com/intlify/vue-i18n/issues" + }, + "files": [ + "index.js", + "dist" + ], + "main": "index.js", + "module": "dist/core-base.mjs", + "unpkg": "dist/core-base.global.js", + "jsdelivr": "dist/core-base.global.js", + "types": "dist/core-base.d.ts", + "dependencies": { + "@intlify/shared": "9.14.5", + "@intlify/message-compiler": "9.14.5" + }, + "devDependencies": { + "@intlify/devtools-if": "9.14.5", + "@intlify/vue-devtools": "9.14.5" + }, + "engines": { + "node": ">= 16" + }, + "buildOptions": { + "name": "IntlifyCoreBase", + "formats": [ + "mjs", + "browser", + "cjs", + "global" + ] + }, + "exports": { + ".": { + "types": "./dist/core-base.d.ts", + "import": "./dist/core-base.mjs", + "browser": "./dist/core-base.esm-browser.js", + "node": { + "import": { + "production": "./dist/core-base.prod.cjs", + "development": "./dist/core-base.mjs", + "default": "./dist/core-base.mjs" + }, + "require": { + "production": "./dist/core-base.prod.cjs", + "development": "./dist/core-base.cjs", + "default": "./index.js" + } + } + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" + }, + "funding": "https://github.com/sponsors/kazupon", + "publishConfig": { + "access": "public" + }, + "sideEffects": false +} \ No newline at end of file diff --git a/node_modules/@intlify/message-compiler/LICENSE b/node_modules/@intlify/message-compiler/LICENSE new file mode 100644 index 0000000..c02ff3e --- /dev/null +++ b/node_modules/@intlify/message-compiler/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2020 kazuya kawaguchi + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/@intlify/message-compiler/README.md b/node_modules/@intlify/message-compiler/README.md new file mode 100644 index 0000000..d3f03af --- /dev/null +++ b/node_modules/@intlify/message-compiler/README.md @@ -0,0 +1,7 @@ +# @intlify/message-compiler + +The message compiler for intlify project + +## :copyright: License + +[MIT](http://opensource.org/licenses/MIT) diff --git a/node_modules/@intlify/message-compiler/dist/message-compiler.cjs b/node_modules/@intlify/message-compiler/dist/message-compiler.cjs new file mode 100644 index 0000000..130c5c9 --- /dev/null +++ b/node_modules/@intlify/message-compiler/dist/message-compiler.cjs @@ -0,0 +1,1674 @@ +/*! + * message-compiler v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +'use strict'; + +var shared = require('@intlify/shared'); +var sourceMapJs = require('source-map-js'); + +const LOCATION_STUB = { + start: { line: 1, column: 1, offset: 0 }, + end: { line: 1, column: 1, offset: 0 } +}; +function createPosition(line, column, offset) { + return { line, column, offset }; +} +function createLocation(start, end, source) { + const loc = { start, end }; + if (source != null) { + loc.source = source; + } + return loc; +} + +const CompileWarnCodes = { + USE_MODULO_SYNTAX: 1, + __EXTEND_POINT__: 2 +}; +/** @internal */ +const warnMessages = { + [CompileWarnCodes.USE_MODULO_SYNTAX]: `Use modulo before '{{0}}'.` +}; +function createCompileWarn(code, loc, ...args) { + const msg = shared.format(warnMessages[code] || '', ...(args || [])) ; + const message = { message: String(msg), code }; + if (loc) { + message.location = loc; + } + return message; +} + +const CompileErrorCodes = { + // tokenizer error codes + EXPECTED_TOKEN: 1, + INVALID_TOKEN_IN_PLACEHOLDER: 2, + UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3, + UNKNOWN_ESCAPE_SEQUENCE: 4, + INVALID_UNICODE_ESCAPE_SEQUENCE: 5, + UNBALANCED_CLOSING_BRACE: 6, + UNTERMINATED_CLOSING_BRACE: 7, + EMPTY_PLACEHOLDER: 8, + NOT_ALLOW_NEST_PLACEHOLDER: 9, + INVALID_LINKED_FORMAT: 10, + // parser error codes + MUST_HAVE_MESSAGES_IN_PLURAL: 11, + UNEXPECTED_EMPTY_LINKED_MODIFIER: 12, + UNEXPECTED_EMPTY_LINKED_KEY: 13, + UNEXPECTED_LEXICAL_ANALYSIS: 14, + // generator error codes + UNHANDLED_CODEGEN_NODE_TYPE: 15, + // minifier error codes + UNHANDLED_MINIFIER_NODE_TYPE: 16, + // Special value for higher-order compilers to pick up the last code + // to avoid collision of error codes. This should always be kept as the last + // item. + __EXTEND_POINT__: 17 +}; +/** @internal */ +const errorMessages = { + // tokenizer error messages + [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`, + [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`, + [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`, + [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`, + [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`, + [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`, + [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`, + [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`, + [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`, + [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`, + // parser error messages + [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`, + [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`, + // generator error messages + [CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`, + // minimizer error messages + [CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'` +}; +function createCompileError(code, loc, options = {}) { + const { domain, messages, args } = options; + const msg = shared.format((messages || errorMessages)[code] || '', ...(args || [])) + ; + const error = new SyntaxError(String(msg)); + error.code = code; + if (loc) { + error.location = loc; + } + error.domain = domain; + return error; +} +/** @internal */ +function defaultOnError(error) { + throw error; +} + +// eslint-disable-next-line no-useless-escape +const RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/; +const detectHtmlTag = (source) => RE_HTML_TAG.test(source); + +const CHAR_SP = ' '; +const CHAR_CR = '\r'; +const CHAR_LF = '\n'; +const CHAR_LS = String.fromCharCode(0x2028); +const CHAR_PS = String.fromCharCode(0x2029); +function createScanner(str) { + const _buf = str; + let _index = 0; + let _line = 1; + let _column = 1; + let _peekOffset = 0; + const isCRLF = (index) => _buf[index] === CHAR_CR && _buf[index + 1] === CHAR_LF; + const isLF = (index) => _buf[index] === CHAR_LF; + const isPS = (index) => _buf[index] === CHAR_PS; + const isLS = (index) => _buf[index] === CHAR_LS; + const isLineEnd = (index) => isCRLF(index) || isLF(index) || isPS(index) || isLS(index); + const index = () => _index; + const line = () => _line; + const column = () => _column; + const peekOffset = () => _peekOffset; + const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset]; + const currentChar = () => charAt(_index); + const currentPeek = () => charAt(_index + _peekOffset); + function next() { + _peekOffset = 0; + if (isLineEnd(_index)) { + _line++; + _column = 0; + } + if (isCRLF(_index)) { + _index++; + } + _index++; + _column++; + return _buf[_index]; + } + function peek() { + if (isCRLF(_index + _peekOffset)) { + _peekOffset++; + } + _peekOffset++; + return _buf[_index + _peekOffset]; + } + function reset() { + _index = 0; + _line = 1; + _column = 1; + _peekOffset = 0; + } + function resetPeek(offset = 0) { + _peekOffset = offset; + } + function skipToPeek() { + const target = _index + _peekOffset; + // eslint-disable-next-line no-unmodified-loop-condition + while (target !== _index) { + next(); + } + _peekOffset = 0; + } + return { + index, + line, + column, + peekOffset, + charAt, + currentChar, + currentPeek, + next, + peek, + reset, + resetPeek, + skipToPeek + }; +} + +const EOF = undefined; +const DOT = '.'; +const LITERAL_DELIMITER = "'"; +const ERROR_DOMAIN$3 = 'tokenizer'; +function createTokenizer(source, options = {}) { + const location = options.location !== false; + const _scnr = createScanner(source); + const currentOffset = () => _scnr.index(); + const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index()); + const _initLoc = currentPosition(); + const _initOffset = currentOffset(); + const _context = { + currentType: 14 /* TokenTypes.EOF */, + offset: _initOffset, + startLoc: _initLoc, + endLoc: _initLoc, + lastType: 14 /* TokenTypes.EOF */, + lastOffset: _initOffset, + lastStartLoc: _initLoc, + lastEndLoc: _initLoc, + braceNest: 0, + inLinked: false, + text: '' + }; + const context = () => _context; + const { onError } = options; + function emitError(code, pos, offset, ...args) { + const ctx = context(); + pos.column += offset; + pos.offset += offset; + if (onError) { + const loc = location ? createLocation(ctx.startLoc, pos) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$3, + args + }); + onError(err); + } + } + function getToken(context, type, value) { + context.endLoc = currentPosition(); + context.currentType = type; + const token = { type }; + if (location) { + token.loc = createLocation(context.startLoc, context.endLoc); + } + if (value != null) { + token.value = value; + } + return token; + } + const getEndToken = (context) => getToken(context, 14 /* TokenTypes.EOF */); + function eat(scnr, ch) { + if (scnr.currentChar() === ch) { + scnr.next(); + return ch; + } + else { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + return ''; + } + } + function peekSpaces(scnr) { + let buf = ''; + while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) { + buf += scnr.currentPeek(); + scnr.peek(); + } + return buf; + } + function skipSpaces(scnr) { + const buf = peekSpaces(scnr); + scnr.skipToPeek(); + return buf; + } + function isIdentifierStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + cc === 95 // _ + ); + } + function isNumberStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function isNamedIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isListIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ch = scnr.currentPeek() === '-' ? scnr.peek() : scnr.currentPeek(); + const ret = isNumberStart(ch); + scnr.resetPeek(); + return ret; + } + function isLiteralStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === LITERAL_DELIMITER; + scnr.resetPeek(); + return ret; + } + function isLinkedDotStart(scnr, context) { + const { currentType } = context; + if (currentType !== 8 /* TokenTypes.LinkedAlias */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === "." /* TokenChars.LinkedDot */; + scnr.resetPeek(); + return ret; + } + function isLinkedModifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 9 /* TokenTypes.LinkedDot */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isLinkedDelimiterStart(scnr, context) { + const { currentType } = context; + if (!(currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 12 /* TokenTypes.LinkedModifier */)) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === ":" /* TokenChars.LinkedDelimiter */; + scnr.resetPeek(); + return ret; + } + function isLinkedReferStart(scnr, context) { + const { currentType } = context; + if (currentType !== 10 /* TokenTypes.LinkedDelimiter */) { + return false; + } + const fn = () => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return isIdentifierStart(scnr.peek()); + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "|" /* TokenChars.Pipe */ || + ch === ":" /* TokenChars.LinkedDelimiter */ || + ch === "." /* TokenChars.LinkedDot */ || + ch === CHAR_SP || + !ch) { + return false; + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(); + } + else { + // other characters + return isTextStart(scnr, false); + } + }; + const ret = fn(); + scnr.resetPeek(); + return ret; + } + function isPluralStart(scnr) { + peekSpaces(scnr); + const ret = scnr.currentPeek() === "|" /* TokenChars.Pipe */; + scnr.resetPeek(); + return ret; + } + function detectModuloStart(scnr) { + const spaces = peekSpaces(scnr); + const ret = scnr.currentPeek() === "%" /* TokenChars.Modulo */ && + scnr.peek() === "{" /* TokenChars.BraceLeft */; + scnr.resetPeek(); + return { + isModulo: ret, + hasSpace: spaces.length > 0 + }; + } + function isTextStart(scnr, reset = true) { + const fn = (hasSpace = false, prev = '', detectModulo = false) => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return prev === "%" /* TokenChars.Modulo */ ? false : hasSpace; + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || !ch) { + return prev === "%" /* TokenChars.Modulo */ ? true : hasSpace; + } + else if (ch === "%" /* TokenChars.Modulo */) { + scnr.peek(); + return fn(hasSpace, "%" /* TokenChars.Modulo */, true); + } + else if (ch === "|" /* TokenChars.Pipe */) { + return prev === "%" /* TokenChars.Modulo */ || detectModulo + ? true + : !(prev === CHAR_SP || prev === CHAR_LF); + } + else if (ch === CHAR_SP) { + scnr.peek(); + return fn(true, CHAR_SP, detectModulo); + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(true, CHAR_LF, detectModulo); + } + else { + return true; + } + }; + const ret = fn(); + reset && scnr.resetPeek(); + return ret; + } + function takeChar(scnr, fn) { + const ch = scnr.currentChar(); + if (ch === EOF) { + return EOF; + } + if (fn(ch)) { + scnr.next(); + return ch; + } + return null; + } + function isIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 // $ + ); + } + function takeIdentifierChar(scnr) { + return takeChar(scnr, isIdentifier); + } + function isNamedIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 || // $ + cc === 45 // - + ); + } + function takeNamedIdentifierChar(scnr) { + return takeChar(scnr, isNamedIdentifier); + } + function isDigit(ch) { + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function takeDigit(scnr) { + return takeChar(scnr, isDigit); + } + function isHexDigit(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 48 && cc <= 57) || // 0-9 + (cc >= 65 && cc <= 70) || // A-F + (cc >= 97 && cc <= 102)); // a-f + } + function takeHexDigit(scnr) { + return takeChar(scnr, isHexDigit); + } + function getDigits(scnr) { + let ch = ''; + let num = ''; + while ((ch = takeDigit(scnr))) { + num += ch; + } + return num; + } + function readModulo(scnr) { + skipSpaces(scnr); + const ch = scnr.currentChar(); + if (ch !== "%" /* TokenChars.Modulo */) { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + } + scnr.next(); + return "%" /* TokenChars.Modulo */; + } + function readText(scnr) { + let buf = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "}" /* TokenChars.BraceRight */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + !ch) { + break; + } + else if (ch === "%" /* TokenChars.Modulo */) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else { + break; + } + } + else if (ch === CHAR_SP || ch === CHAR_LF) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else if (isPluralStart(scnr)) { + break; + } + else { + buf += ch; + scnr.next(); + } + } + else { + buf += ch; + scnr.next(); + } + } + return buf; + } + function readNamedIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let name = ''; + while ((ch = takeNamedIdentifierChar(scnr))) { + name += ch; + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return name; + } + function readListIdentifier(scnr) { + skipSpaces(scnr); + let value = ''; + if (scnr.currentChar() === '-') { + scnr.next(); + value += `-${getDigits(scnr)}`; + } + else { + value += getDigits(scnr); + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return value; + } + function isLiteral(ch) { + return ch !== LITERAL_DELIMITER && ch !== CHAR_LF; + } + function readLiteral(scnr) { + skipSpaces(scnr); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + let ch = ''; + let literal = ''; + while ((ch = takeChar(scnr, isLiteral))) { + if (ch === '\\') { + literal += readEscapeSequence(scnr); + } + else { + literal += ch; + } + } + const current = scnr.currentChar(); + if (current === CHAR_LF || current === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, currentPosition(), 0); + // TODO: Is it correct really? + if (current === CHAR_LF) { + scnr.next(); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + } + return literal; + } + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + return literal; + } + function readEscapeSequence(scnr) { + const ch = scnr.currentChar(); + switch (ch) { + case '\\': + case `\'`: // eslint-disable-line no-useless-escape + scnr.next(); + return `\\${ch}`; + case 'u': + return readUnicodeEscapeSequence(scnr, ch, 4); + case 'U': + return readUnicodeEscapeSequence(scnr, ch, 6); + default: + emitError(CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, currentPosition(), 0, ch); + return ''; + } + } + function readUnicodeEscapeSequence(scnr, unicode, digits) { + eat(scnr, unicode); + let sequence = ''; + for (let i = 0; i < digits; i++) { + const ch = takeHexDigit(scnr); + if (!ch) { + emitError(CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`); + break; + } + sequence += ch; + } + return `\\${unicode}${sequence}`; + } + function isInvalidIdentifier(ch) { + return (ch !== "{" /* TokenChars.BraceLeft */ && + ch !== "}" /* TokenChars.BraceRight */ && + ch !== CHAR_SP && + ch !== CHAR_LF); + } + function readInvalidIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let identifiers = ''; + while ((ch = takeChar(scnr, isInvalidIdentifier))) { + identifiers += ch; + } + return identifiers; + } + function readLinkedModifier(scnr) { + let ch = ''; + let name = ''; + while ((ch = takeIdentifierChar(scnr))) { + name += ch; + } + return name; + } + function readLinkedRefer(scnr) { + const fn = (buf) => { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + ch === "(" /* TokenChars.ParenLeft */ || + ch === ")" /* TokenChars.ParenRight */ || + !ch) { + return buf; + } + else if (ch === CHAR_SP) { + return buf; + } + else if (ch === CHAR_LF || ch === DOT) { + buf += ch; + scnr.next(); + return fn(buf); + } + else { + buf += ch; + scnr.next(); + return fn(buf); + } + }; + return fn(''); + } + function readPlural(scnr) { + skipSpaces(scnr); + const plural = eat(scnr, "|" /* TokenChars.Pipe */); + skipSpaces(scnr); + return plural; + } + // TODO: We need refactoring of token parsing ... + function readTokenInPlaceholder(scnr, context) { + let token = null; + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + if (context.braceNest >= 1) { + emitError(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 2 /* TokenTypes.BraceLeft */, "{" /* TokenChars.BraceLeft */); + skipSpaces(scnr); + context.braceNest++; + return token; + case "}" /* TokenChars.BraceRight */: + if (context.braceNest > 0 && + context.currentType === 2 /* TokenTypes.BraceLeft */) { + emitError(CompileErrorCodes.EMPTY_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + context.braceNest--; + context.braceNest > 0 && skipSpaces(scnr); + if (context.inLinked && context.braceNest === 0) { + context.inLinked = false; + } + return token; + case "@" /* TokenChars.LinkedAlias */: + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = readTokenInLinked(scnr, context) || getEndToken(context); + context.braceNest = 0; + return token; + default: { + let validNamedIdentifier = true; + let validListIdentifier = true; + let validLiteral = true; + if (isPluralStart(scnr)) { + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (context.braceNest > 0 && + (context.currentType === 5 /* TokenTypes.Named */ || + context.currentType === 6 /* TokenTypes.List */ || + context.currentType === 7 /* TokenTypes.Literal */)) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + context.braceNest = 0; + return readToken(scnr, context); + } + if ((validNamedIdentifier = isNamedIdentifierStart(scnr, context))) { + token = getToken(context, 5 /* TokenTypes.Named */, readNamedIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validListIdentifier = isListIdentifierStart(scnr, context))) { + token = getToken(context, 6 /* TokenTypes.List */, readListIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validLiteral = isLiteralStart(scnr, context))) { + token = getToken(context, 7 /* TokenTypes.Literal */, readLiteral(scnr)); + skipSpaces(scnr); + return token; + } + if (!validNamedIdentifier && !validListIdentifier && !validLiteral) { + // TODO: we should be re-designed invalid cases, when we will extend message syntax near the future ... + token = getToken(context, 13 /* TokenTypes.InvalidPlace */, readInvalidIdentifier(scnr)); + emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value); + skipSpaces(scnr); + return token; + } + break; + } + } + return token; + } + // TODO: We need refactoring of token parsing ... + function readTokenInLinked(scnr, context) { + const { currentType } = context; + let token = null; + const ch = scnr.currentChar(); + if ((currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 9 /* TokenTypes.LinkedDot */ || + currentType === 12 /* TokenTypes.LinkedModifier */ || + currentType === 10 /* TokenTypes.LinkedDelimiter */) && + (ch === CHAR_LF || ch === CHAR_SP)) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + switch (ch) { + case "@" /* TokenChars.LinkedAlias */: + scnr.next(); + token = getToken(context, 8 /* TokenTypes.LinkedAlias */, "@" /* TokenChars.LinkedAlias */); + context.inLinked = true; + return token; + case "." /* TokenChars.LinkedDot */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 9 /* TokenTypes.LinkedDot */, "." /* TokenChars.LinkedDot */); + case ":" /* TokenChars.LinkedDelimiter */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 10 /* TokenTypes.LinkedDelimiter */, ":" /* TokenChars.LinkedDelimiter */); + default: + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (isLinkedDotStart(scnr, context) || + isLinkedDelimiterStart(scnr, context)) { + skipSpaces(scnr); + return readTokenInLinked(scnr, context); + } + if (isLinkedModifierStart(scnr, context)) { + skipSpaces(scnr); + return getToken(context, 12 /* TokenTypes.LinkedModifier */, readLinkedModifier(scnr)); + } + if (isLinkedReferStart(scnr, context)) { + skipSpaces(scnr); + if (ch === "{" /* TokenChars.BraceLeft */) { + // scan the placeholder + return readTokenInPlaceholder(scnr, context) || token; + } + else { + return getToken(context, 11 /* TokenTypes.LinkedKey */, readLinkedRefer(scnr)); + } + } + if (currentType === 8 /* TokenTypes.LinkedAlias */) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + context.braceNest = 0; + context.inLinked = false; + return readToken(scnr, context); + } + } + // TODO: We need refactoring of token parsing ... + function readToken(scnr, context) { + let token = { type: 14 /* TokenTypes.EOF */ }; + if (context.braceNest > 0) { + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + } + if (context.inLinked) { + return readTokenInLinked(scnr, context) || getEndToken(context); + } + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + case "}" /* TokenChars.BraceRight */: + emitError(CompileErrorCodes.UNBALANCED_CLOSING_BRACE, currentPosition(), 0); + scnr.next(); + return getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + case "@" /* TokenChars.LinkedAlias */: + return readTokenInLinked(scnr, context) || getEndToken(context); + default: { + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + const { isModulo, hasSpace } = detectModuloStart(scnr); + if (isModulo) { + return hasSpace + ? getToken(context, 0 /* TokenTypes.Text */, readText(scnr)) + : getToken(context, 4 /* TokenTypes.Modulo */, readModulo(scnr)); + } + if (isTextStart(scnr)) { + return getToken(context, 0 /* TokenTypes.Text */, readText(scnr)); + } + break; + } + } + return token; + } + function nextToken() { + const { currentType, offset, startLoc, endLoc } = _context; + _context.lastType = currentType; + _context.lastOffset = offset; + _context.lastStartLoc = startLoc; + _context.lastEndLoc = endLoc; + _context.offset = currentOffset(); + _context.startLoc = currentPosition(); + if (_scnr.currentChar() === EOF) { + return getToken(_context, 14 /* TokenTypes.EOF */); + } + return readToken(_scnr, _context); + } + return { + nextToken, + currentOffset, + currentPosition, + context + }; +} + +const ERROR_DOMAIN$2 = 'parser'; +// Backslash backslash, backslash quote, uHHHH, UHHHHHH. +const KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g; +function fromEscapeSequence(match, codePoint4, codePoint6) { + switch (match) { + case `\\\\`: + return `\\`; + // eslint-disable-next-line no-useless-escape + case `\\\'`: + // eslint-disable-next-line no-useless-escape + return `\'`; + default: { + const codePoint = parseInt(codePoint4 || codePoint6, 16); + if (codePoint <= 0xd7ff || codePoint >= 0xe000) { + return String.fromCodePoint(codePoint); + } + // invalid ... + // Replace them with U+FFFD REPLACEMENT CHARACTER. + return '�'; + } + } +} +function createParser(options = {}) { + const location = options.location !== false; + const { onError, onWarn } = options; + function emitError(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onError) { + const loc = location ? createLocation(start, end) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$2, + args + }); + onError(err); + } + } + function emitWarn(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onWarn) { + const loc = location ? createLocation(start, end) : null; + onWarn(createCompileWarn(code, loc, args)); + } + } + function startNode(type, offset, loc) { + const node = { type }; + if (location) { + node.start = offset; + node.end = offset; + node.loc = { start: loc, end: loc }; + } + return node; + } + function endNode(node, offset, pos, type) { + if (type) { + node.type = type; + } + if (location) { + node.end = offset; + if (node.loc) { + node.loc.end = pos; + } + } + } + function parseText(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(3 /* NodeTypes.Text */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseList(tokenizer, index) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(5 /* NodeTypes.List */, offset, loc); + node.index = parseInt(index, 10); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseNamed(tokenizer, key, modulo) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(4 /* NodeTypes.Named */, offset, loc); + node.key = key; + if (modulo === true) { + node.modulo = true; + } + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLiteral(tokenizer, value) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(9 /* NodeTypes.Literal */, offset, loc); + node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinkedModifier(tokenizer) { + const token = tokenizer.nextToken(); + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get linked dot loc + const node = startNode(8 /* NodeTypes.LinkedModifier */, offset, loc); + if (token.type !== 12 /* TokenTypes.LinkedModifier */) { + // empty modifier + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0); + node.value = ''; + endNode(node, offset, loc); + return { + nextConsumeToken: token, + node + }; + } + // check token + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.value = token.value || ''; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node + }; + } + function parseLinkedKey(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(7 /* NodeTypes.LinkedKey */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinked(tokenizer) { + const context = tokenizer.context(); + const linkedNode = startNode(6 /* NodeTypes.Linked */, context.offset, context.startLoc); + let token = tokenizer.nextToken(); + if (token.type === 9 /* TokenTypes.LinkedDot */) { + const parsed = parseLinkedModifier(tokenizer); + linkedNode.modifier = parsed.node; + token = parsed.nextConsumeToken || tokenizer.nextToken(); + } + // asset check token + if (token.type !== 10 /* TokenTypes.LinkedDelimiter */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + token = tokenizer.nextToken(); + // skip brace left + if (token.type === 2 /* TokenTypes.BraceLeft */) { + token = tokenizer.nextToken(); + } + switch (token.type) { + case 11 /* TokenTypes.LinkedKey */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseNamed(tokenizer, token.value || ''); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseList(tokenizer, token.value || ''); + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLiteral(tokenizer, token.value || ''); + break; + default: { + // empty key + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0); + const nextContext = tokenizer.context(); + const emptyLinkedKeyNode = startNode(7 /* NodeTypes.LinkedKey */, nextContext.offset, nextContext.startLoc); + emptyLinkedKeyNode.value = ''; + endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc); + linkedNode.key = emptyLinkedKeyNode; + endNode(linkedNode, nextContext.offset, nextContext.startLoc); + return { + nextConsumeToken: token, + node: linkedNode + }; + } + } + endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node: linkedNode + }; + } + function parseMessage(tokenizer) { + const context = tokenizer.context(); + const startOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? tokenizer.currentOffset() + : context.offset; + const startLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.endLoc + : context.startLoc; + const node = startNode(2 /* NodeTypes.Message */, startOffset, startLoc); + node.items = []; + let nextToken = null; + let modulo = null; + do { + const token = nextToken || tokenizer.nextToken(); + nextToken = null; + switch (token.type) { + case 0 /* TokenTypes.Text */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseText(tokenizer, token.value || '')); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseList(tokenizer, token.value || '')); + break; + case 4 /* TokenTypes.Modulo */: + modulo = true; + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseNamed(tokenizer, token.value || '', !!modulo)); + if (modulo) { + emitWarn(tokenizer, CompileWarnCodes.USE_MODULO_SYNTAX, context.lastStartLoc, 0, getTokenCaption(token)); + modulo = null; + } + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseLiteral(tokenizer, token.value || '')); + break; + case 8 /* TokenTypes.LinkedAlias */: { + const parsed = parseLinked(tokenizer); + node.items.push(parsed.node); + nextToken = parsed.nextConsumeToken || null; + break; + } + } + } while (context.currentType !== 14 /* TokenTypes.EOF */ && + context.currentType !== 1 /* TokenTypes.Pipe */); + // adjust message node loc + const endOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastOffset + : tokenizer.currentOffset(); + const endLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastEndLoc + : tokenizer.currentPosition(); + endNode(node, endOffset, endLoc); + return node; + } + function parsePlural(tokenizer, offset, loc, msgNode) { + const context = tokenizer.context(); + let hasEmptyMessage = msgNode.items.length === 0; + const node = startNode(1 /* NodeTypes.Plural */, offset, loc); + node.cases = []; + node.cases.push(msgNode); + do { + const msg = parseMessage(tokenizer); + if (!hasEmptyMessage) { + hasEmptyMessage = msg.items.length === 0; + } + node.cases.push(msg); + } while (context.currentType !== 14 /* TokenTypes.EOF */); + if (hasEmptyMessage) { + emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseResource(tokenizer) { + const context = tokenizer.context(); + const { offset, startLoc } = context; + const msgNode = parseMessage(tokenizer); + if (context.currentType === 14 /* TokenTypes.EOF */) { + return msgNode; + } + else { + return parsePlural(tokenizer, offset, startLoc, msgNode); + } + } + function parse(source) { + const tokenizer = createTokenizer(source, shared.assign({}, options)); + const context = tokenizer.context(); + const node = startNode(0 /* NodeTypes.Resource */, context.offset, context.startLoc); + if (location && node.loc) { + node.loc.source = source; + } + node.body = parseResource(tokenizer); + if (options.onCacheKey) { + node.cacheKey = options.onCacheKey(source); + } + // assert whether achieved to EOF + if (context.currentType !== 14 /* TokenTypes.EOF */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || ''); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + return { parse }; +} +function getTokenCaption(token) { + if (token.type === 14 /* TokenTypes.EOF */) { + return 'EOF'; + } + const name = (token.value || '').replace(/\r?\n/gu, '\\n'); + return name.length > 10 ? name.slice(0, 9) + '…' : name; +} + +function createTransformer(ast, options = {} // eslint-disable-line +) { + const _context = { + ast, + helpers: new Set() + }; + const context = () => _context; + const helper = (name) => { + _context.helpers.add(name); + return name; + }; + return { context, helper }; +} +function traverseNodes(nodes, transformer) { + for (let i = 0; i < nodes.length; i++) { + traverseNode(nodes[i], transformer); + } +} +function traverseNode(node, transformer) { + // TODO: if we need pre-hook of transform, should be implemented to here + switch (node.type) { + case 1 /* NodeTypes.Plural */: + traverseNodes(node.cases, transformer); + transformer.helper("plural" /* HelperNameMap.PLURAL */); + break; + case 2 /* NodeTypes.Message */: + traverseNodes(node.items, transformer); + break; + case 6 /* NodeTypes.Linked */: { + const linked = node; + traverseNode(linked.key, transformer); + transformer.helper("linked" /* HelperNameMap.LINKED */); + transformer.helper("type" /* HelperNameMap.TYPE */); + break; + } + case 5 /* NodeTypes.List */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("list" /* HelperNameMap.LIST */); + break; + case 4 /* NodeTypes.Named */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("named" /* HelperNameMap.NAMED */); + break; + } + // TODO: if we need post-hook of transform, should be implemented to here +} +// transform AST +function transform(ast, options = {} // eslint-disable-line +) { + const transformer = createTransformer(ast); + transformer.helper("normalize" /* HelperNameMap.NORMALIZE */); + // traverse + ast.body && traverseNode(ast.body, transformer); + // set meta information + const context = transformer.context(); + ast.helpers = Array.from(context.helpers); +} + +function optimize(ast) { + const body = ast.body; + if (body.type === 2 /* NodeTypes.Message */) { + optimizeMessageNode(body); + } + else { + body.cases.forEach(c => optimizeMessageNode(c)); + } + return ast; +} +function optimizeMessageNode(message) { + if (message.items.length === 1) { + const item = message.items[0]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + message.static = item.value; + delete item.value; // optimization for size + } + } + else { + const values = []; + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (!(item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */)) { + break; + } + if (item.value == null) { + break; + } + values.push(item.value); + } + if (values.length === message.items.length) { + message.static = shared.join(values); + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + delete item.value; // optimization for size + } + } + } + } +} + +const ERROR_DOMAIN$1 = 'minifier'; +/* eslint-disable @typescript-eslint/no-explicit-any */ +function minify(node) { + node.t = node.type; + switch (node.type) { + case 0 /* NodeTypes.Resource */: { + const resource = node; + minify(resource.body); + resource.b = resource.body; + delete resource.body; + break; + } + case 1 /* NodeTypes.Plural */: { + const plural = node; + const cases = plural.cases; + for (let i = 0; i < cases.length; i++) { + minify(cases[i]); + } + plural.c = cases; + delete plural.cases; + break; + } + case 2 /* NodeTypes.Message */: { + const message = node; + const items = message.items; + for (let i = 0; i < items.length; i++) { + minify(items[i]); + } + message.i = items; + delete message.items; + if (message.static) { + message.s = message.static; + delete message.static; + } + break; + } + case 3 /* NodeTypes.Text */: + case 9 /* NodeTypes.Literal */: + case 8 /* NodeTypes.LinkedModifier */: + case 7 /* NodeTypes.LinkedKey */: { + const valueNode = node; + if (valueNode.value) { + valueNode.v = valueNode.value; + delete valueNode.value; + } + break; + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + minify(linked.key); + linked.k = linked.key; + delete linked.key; + if (linked.modifier) { + minify(linked.modifier); + linked.m = linked.modifier; + delete linked.modifier; + } + break; + } + case 5 /* NodeTypes.List */: { + const list = node; + list.i = list.index; + delete list.index; + break; + } + case 4 /* NodeTypes.Named */: { + const named = node; + named.k = named.key; + delete named.key; + break; + } + default: + { + throw createCompileError(CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE, null, { + domain: ERROR_DOMAIN$1, + args: [node.type] + }); + } + } + delete node.type; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +// eslint-disable-next-line @typescript-eslint/triple-slash-reference +/// +const ERROR_DOMAIN = 'parser'; +function createCodeGenerator(ast, options) { + const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options; + const location = options.location !== false; + const _context = { + filename, + code: '', + column: 1, + line: 1, + offset: 0, + map: undefined, + breakLineCode, + needIndent: _needIndent, + indentLevel: 0 + }; + if (location && ast.loc) { + _context.source = ast.loc.source; + } + const context = () => _context; + function push(code, node) { + _context.code += code; + if (_context.map) { + if (node && node.loc && node.loc !== LOCATION_STUB) { + addMapping(node.loc.start, getMappingName(node)); + } + advancePositionWithSource(_context, code); + } + } + function _newline(n, withBreakLine = true) { + const _breakLineCode = withBreakLine ? breakLineCode : ''; + push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode); + } + function indent(withNewLine = true) { + const level = ++_context.indentLevel; + withNewLine && _newline(level); + } + function deindent(withNewLine = true) { + const level = --_context.indentLevel; + withNewLine && _newline(level); + } + function newline() { + _newline(_context.indentLevel); + } + const helper = (key) => `_${key}`; + const needIndent = () => _context.needIndent; + function addMapping(loc, name) { + _context.map.addMapping({ + name, + source: _context.filename, + original: { + line: loc.line, + column: loc.column - 1 + }, + generated: { + line: _context.line, + column: _context.column - 1 + } + }); + } + if (location && sourceMap) { + _context.map = new sourceMapJs.SourceMapGenerator(); + _context.map.setSourceContent(filename, _context.source); + } + return { + context, + push, + indent, + deindent, + newline, + helper, + needIndent + }; +} +function generateLinkedNode(generator, node) { + const { helper } = generator; + generator.push(`${helper("linked" /* HelperNameMap.LINKED */)}(`); + generateNode(generator, node.key); + if (node.modifier) { + generator.push(`, `); + generateNode(generator, node.modifier); + generator.push(`, _type`); + } + else { + generator.push(`, undefined, _type`); + } + generator.push(`)`); +} +function generateMessageNode(generator, node) { + const { helper, needIndent } = generator; + generator.push(`${helper("normalize" /* HelperNameMap.NORMALIZE */)}([`); + generator.indent(needIndent()); + const length = node.items.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.items[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push('])'); +} +function generatePluralNode(generator, node) { + const { helper, needIndent } = generator; + if (node.cases.length > 1) { + generator.push(`${helper("plural" /* HelperNameMap.PLURAL */)}([`); + generator.indent(needIndent()); + const length = node.cases.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.cases[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push(`])`); + } +} +function generateResource(generator, node) { + if (node.body) { + generateNode(generator, node.body); + } + else { + generator.push('null'); + } +} +function generateNode(generator, node) { + const { helper } = generator; + switch (node.type) { + case 0 /* NodeTypes.Resource */: + generateResource(generator, node); + break; + case 1 /* NodeTypes.Plural */: + generatePluralNode(generator, node); + break; + case 2 /* NodeTypes.Message */: + generateMessageNode(generator, node); + break; + case 6 /* NodeTypes.Linked */: + generateLinkedNode(generator, node); + break; + case 8 /* NodeTypes.LinkedModifier */: + generator.push(JSON.stringify(node.value), node); + break; + case 7 /* NodeTypes.LinkedKey */: + generator.push(JSON.stringify(node.value), node); + break; + case 5 /* NodeTypes.List */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("list" /* HelperNameMap.LIST */)}(${node.index}))`, node); + break; + case 4 /* NodeTypes.Named */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("named" /* HelperNameMap.NAMED */)}(${JSON.stringify(node.key)}))`, node); + break; + case 9 /* NodeTypes.Literal */: + generator.push(JSON.stringify(node.value), node); + break; + case 3 /* NodeTypes.Text */: + generator.push(JSON.stringify(node.value), node); + break; + default: + { + throw createCompileError(CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE, null, { + domain: ERROR_DOMAIN, + args: [node.type] + }); + } + } +} +// generate code from AST +const generate = (ast, options = {} // eslint-disable-line +) => { + const mode = shared.isString(options.mode) ? options.mode : 'normal'; + const filename = shared.isString(options.filename) + ? options.filename + : 'message.intl'; + const sourceMap = !!options.sourceMap; + // prettier-ignore + const breakLineCode = options.breakLineCode != null + ? options.breakLineCode + : mode === 'arrow' + ? ';' + : '\n'; + const needIndent = options.needIndent ? options.needIndent : mode !== 'arrow'; + const helpers = ast.helpers || []; + const generator = createCodeGenerator(ast, { + mode, + filename, + sourceMap, + breakLineCode, + needIndent + }); + generator.push(mode === 'normal' ? `function __msg__ (ctx) {` : `(ctx) => {`); + generator.indent(needIndent); + if (helpers.length > 0) { + generator.push(`const { ${shared.join(helpers.map(s => `${s}: _${s}`), ', ')} } = ctx`); + generator.newline(); + } + generator.push(`return `); + generateNode(generator, ast); + generator.deindent(needIndent); + generator.push(`}`); + delete ast.helpers; + const { code, map } = generator.context(); + return { + ast, + code, + map: map ? map.toJSON() : undefined // eslint-disable-line @typescript-eslint/no-explicit-any + }; +}; +function getMappingName(node) { + switch (node.type) { + case 3 /* NodeTypes.Text */: + case 9 /* NodeTypes.Literal */: + case 8 /* NodeTypes.LinkedModifier */: + case 7 /* NodeTypes.LinkedKey */: + return node.value; + case 5 /* NodeTypes.List */: + return node.index.toString(); + case 4 /* NodeTypes.Named */: + return node.key; + default: + return undefined; + } +} +function advancePositionWithSource(pos, source, numberOfCharacters = source.length) { + let linesCount = 0; + let lastNewLinePos = -1; + for (let i = 0; i < numberOfCharacters; i++) { + if (source.charCodeAt(i) === 10 /* newline char code */) { + linesCount++; + lastNewLinePos = i; + } + } + pos.offset += numberOfCharacters; + pos.line += linesCount; + pos.column = + lastNewLinePos === -1 + ? pos.column + numberOfCharacters + : numberOfCharacters - lastNewLinePos; + return pos; +} + +function baseCompile(source, options = {}) { + const assignedOptions = shared.assign({}, options); + const jit = !!assignedOptions.jit; + const enalbeMinify = !!assignedOptions.minify; + const enambeOptimize = assignedOptions.optimize == null ? true : assignedOptions.optimize; + // parse source codes + const parser = createParser(assignedOptions); + const ast = parser.parse(source); + if (!jit) { + // transform ASTs + transform(ast, assignedOptions); + // generate javascript codes + return generate(ast, assignedOptions); + } + else { + // optimize ASTs + enambeOptimize && optimize(ast); + // minimize ASTs + enalbeMinify && minify(ast); + // In JIT mode, no ast transform, no code generation. + return { ast, code: '' }; + } +} + +exports.CompileErrorCodes = CompileErrorCodes; +exports.CompileWarnCodes = CompileWarnCodes; +exports.ERROR_DOMAIN = ERROR_DOMAIN$2; +exports.LOCATION_STUB = LOCATION_STUB; +exports.baseCompile = baseCompile; +exports.createCompileError = createCompileError; +exports.createCompileWarn = createCompileWarn; +exports.createLocation = createLocation; +exports.createParser = createParser; +exports.createPosition = createPosition; +exports.defaultOnError = defaultOnError; +exports.detectHtmlTag = detectHtmlTag; +exports.errorMessages = errorMessages; +exports.warnMessages = warnMessages; diff --git a/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js b/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js new file mode 100644 index 0000000..7f9c178 --- /dev/null +++ b/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js @@ -0,0 +1 @@ +module.exports = require('../dist/message-compiler.cjs') \ No newline at end of file diff --git a/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.prod.js b/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.prod.js new file mode 100644 index 0000000..0119af3 --- /dev/null +++ b/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.prod.js @@ -0,0 +1 @@ +module.exports = require('../dist/message-compiler.prod.cjs') \ No newline at end of file diff --git a/node_modules/@intlify/message-compiler/dist/message-compiler.d.ts b/node_modules/@intlify/message-compiler/dist/message-compiler.d.ts new file mode 100644 index 0000000..65f956a --- /dev/null +++ b/node_modules/@intlify/message-compiler/dist/message-compiler.d.ts @@ -0,0 +1,249 @@ + + +import type { BaseError } from '@intlify/shared'; +import type { RawSourceMap } from 'source-map-js'; + +export declare function baseCompile(source: string, options?: CompileOptions): CompilerResult; + +export declare type CacheKeyHandler = (source: string) => string; + +export declare interface CodeGenOptions { + location?: boolean; + mode?: 'normal' | 'arrow'; + breakLineCode?: '\n' | ';'; + needIndent?: boolean; + onWarn?: CompileWarnHandler; + onError?: CompileErrorHandler; + sourceMap?: boolean; + filename?: string; +} + +declare interface CodeGenResult { + code: string; + ast: ResourceNode; + map?: RawSourceMap; +} + +export declare type CompileDomain = 'tokenizer' | 'parser' | 'generator' | 'transformer' | 'optimizer' | 'minifier'; + +export declare interface CompileError extends BaseError, SyntaxError { + domain?: CompileDomain; + location?: SourceLocation; +} + +export declare const CompileErrorCodes: { + readonly EXPECTED_TOKEN: 1; + readonly INVALID_TOKEN_IN_PLACEHOLDER: 2; + readonly UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3; + readonly UNKNOWN_ESCAPE_SEQUENCE: 4; + readonly INVALID_UNICODE_ESCAPE_SEQUENCE: 5; + readonly UNBALANCED_CLOSING_BRACE: 6; + readonly UNTERMINATED_CLOSING_BRACE: 7; + readonly EMPTY_PLACEHOLDER: 8; + readonly NOT_ALLOW_NEST_PLACEHOLDER: 9; + readonly INVALID_LINKED_FORMAT: 10; + readonly MUST_HAVE_MESSAGES_IN_PLURAL: 11; + readonly UNEXPECTED_EMPTY_LINKED_MODIFIER: 12; + readonly UNEXPECTED_EMPTY_LINKED_KEY: 13; + readonly UNEXPECTED_LEXICAL_ANALYSIS: 14; + readonly UNHANDLED_CODEGEN_NODE_TYPE: 15; + readonly UNHANDLED_MINIFIER_NODE_TYPE: 16; + readonly __EXTEND_POINT__: 17; +}; + +export declare type CompileErrorCodes = (typeof CompileErrorCodes)[keyof typeof CompileErrorCodes]; + +export declare type CompileErrorHandler = (error: CompileError) => void; + +export declare interface CompileErrorOptions { + domain?: CompileDomain; + messages?: { + [code: number]: string; + }; + args?: unknown[]; +} + +export declare type CompileOptions = { + optimize?: boolean; + minify?: boolean; + jit?: boolean; +} & TransformOptions & CodeGenOptions & ParserOptions & TokenizeOptions; + +export declare type CompilerResult = CodeGenResult; + +export declare interface CompileWarn { + message: string; + code: number; + location?: SourceLocation; +} + +export declare const CompileWarnCodes: { + readonly USE_MODULO_SYNTAX: 1; + readonly __EXTEND_POINT__: 2; +}; + +export declare type CompileWarnCodes = (typeof CompileWarnCodes)[keyof typeof CompileWarnCodes]; + +export declare type CompileWarnHandler = (warn: CompileWarn) => void; + +export declare function createCompileError(code: T, loc: SourceLocation | null, options?: CompileErrorOptions): CompileError; + +export declare function createCompileWarn(code: T, loc: SourceLocation | null, ...args: unknown[]): CompileWarn; + +export declare function createLocation(start: Position, end: Position, source?: string): SourceLocation; + +export declare function createParser(options?: ParserOptions): Parser; + +export declare function createPosition(line: number, column: number, offset: number): Position; + +/* Excluded from this release type: defaultOnError */ + +export declare const detectHtmlTag: (source: string) => boolean; + +export declare const ERROR_DOMAIN = "parser"; + +/* Excluded from this release type: errorMessages */ + +export declare const enum HelperNameMap { + LIST = "list", + NAMED = "named", + PLURAL = "plural", + LINKED = "linked", + MESSAGE = "message", + TYPE = "type", + INTERPOLATE = "interpolate", + NORMALIZE = "normalize", + VALUES = "values" +} + +export declare type Identifier = string; + +export declare interface LinkedKeyNode extends Node_2 { + type: NodeTypes.LinkedKey; + value: string; + /* Excluded from this release type: v */ +} + +export declare interface LinkedModifierNode extends Node_2 { + type: NodeTypes.LinkedModifier; + value: Identifier; + /* Excluded from this release type: v */ +} + +export declare interface LinkedNode extends Node_2 { + type: NodeTypes.Linked; + modifier?: LinkedModifierNode; + /* Excluded from this release type: m */ + key: LinkedKeyNode | NamedNode | ListNode | LiteralNode; + /* Excluded from this release type: k */ +} + +export declare interface ListNode extends Node_2 { + type: NodeTypes.List; + index: number; + /* Excluded from this release type: i */ +} + +export declare interface LiteralNode extends Node_2 { + type: NodeTypes.Literal; + value?: string; + /* Excluded from this release type: v */ +} + +export declare const LOCATION_STUB: SourceLocation; + +declare type MessageElementNode = TextNode | NamedNode | ListNode | LiteralNode | LinkedNode; + +export declare interface MessageNode extends Node_2 { + type: NodeTypes.Message; + static?: string; + /* Excluded from this release type: s */ + items: MessageElementNode[]; + /* Excluded from this release type: i */ +} + +export declare interface NamedNode extends Node_2 { + type: NodeTypes.Named; + key: Identifier; + modulo?: boolean; + /* Excluded from this release type: k */ +} + +declare interface Node_2 { + type: NodeTypes; + /* Excluded from this release type: t */ + start?: number; + end?: number; + loc?: SourceLocation; +} +export { Node_2 as Node } + +export declare const enum NodeTypes { + Resource = 0,// 0 + Plural = 1, + Message = 2, + Text = 3, + Named = 4, + List = 5,// 5 + Linked = 6, + LinkedKey = 7, + LinkedModifier = 8, + Literal = 9 +} + +export declare interface Parser { + parse(source: string): ResourceNode; +} + +export declare interface ParserOptions { + location?: boolean; + onCacheKey?: (source: string) => string; + onWarn?: CompileWarnHandler; + onError?: CompileErrorHandler; +} + +export declare interface PluralNode extends Node_2 { + type: NodeTypes.Plural; + cases: MessageNode[]; + /* Excluded from this release type: c */ +} + +export declare interface Position { + offset: number; + line: number; + column: number; +} + +export declare interface ResourceNode extends Node_2 { + type: NodeTypes.Resource; + body: MessageNode | PluralNode; + /* Excluded from this release type: b */ + cacheKey?: string; + helpers?: string[]; +} + +export declare interface SourceLocation { + start: Position; + end: Position; + source?: string; +} + +export declare interface TextNode extends Node_2 { + type: NodeTypes.Text; + value?: string; + /* Excluded from this release type: v */ +} + +export declare interface TokenizeOptions { + location?: boolean; + onError?: CompileErrorHandler; +} + +export declare interface TransformOptions { + onWarn?: CompileWarnHandler; + onError?: CompileErrorHandler; +} + +/* Excluded from this release type: warnMessages */ + +export { } diff --git a/node_modules/@intlify/message-compiler/dist/message-compiler.esm-browser.js b/node_modules/@intlify/message-compiler/dist/message-compiler.esm-browser.js new file mode 100644 index 0000000..d6cd2ec --- /dev/null +++ b/node_modules/@intlify/message-compiler/dist/message-compiler.esm-browser.js @@ -0,0 +1,1625 @@ +/*! + * message-compiler v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +const LOCATION_STUB = { + start: { line: 1, column: 1, offset: 0 }, + end: { line: 1, column: 1, offset: 0 } +}; +function createPosition(line, column, offset) { + return { line, column, offset }; +} +function createLocation(start, end, source) { + const loc = { start, end }; + if (source != null) { + loc.source = source; + } + return loc; +} + +/** + * Original Utilities + * written by kazuya kawaguchi + */ +const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g; +/* eslint-disable */ +function format(message, ...args) { + if (args.length === 1 && isObject(args[0])) { + args = args[0]; + } + if (!args || !args.hasOwnProperty) { + args = {}; + } + return message.replace(RE_ARGS, (match, identifier) => { + return args.hasOwnProperty(identifier) ? args[identifier] : ''; + }); +} +const assign = Object.assign; +const isString = (val) => typeof val === 'string'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isObject = (val) => val !== null && typeof val === 'object'; +function join(items, separator = '') { + return items.reduce((str, item, index) => (index === 0 ? str + item : str + separator + item), ''); +} + +const CompileWarnCodes = { + USE_MODULO_SYNTAX: 1, + __EXTEND_POINT__: 2 +}; +/** @internal */ +const warnMessages = { + [CompileWarnCodes.USE_MODULO_SYNTAX]: `Use modulo before '{{0}}'.` +}; +function createCompileWarn(code, loc, ...args) { + const msg = format(warnMessages[code] || '', ...(args || [])) ; + const message = { message: String(msg), code }; + if (loc) { + message.location = loc; + } + return message; +} + +const CompileErrorCodes = { + // tokenizer error codes + EXPECTED_TOKEN: 1, + INVALID_TOKEN_IN_PLACEHOLDER: 2, + UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3, + UNKNOWN_ESCAPE_SEQUENCE: 4, + INVALID_UNICODE_ESCAPE_SEQUENCE: 5, + UNBALANCED_CLOSING_BRACE: 6, + UNTERMINATED_CLOSING_BRACE: 7, + EMPTY_PLACEHOLDER: 8, + NOT_ALLOW_NEST_PLACEHOLDER: 9, + INVALID_LINKED_FORMAT: 10, + // parser error codes + MUST_HAVE_MESSAGES_IN_PLURAL: 11, + UNEXPECTED_EMPTY_LINKED_MODIFIER: 12, + UNEXPECTED_EMPTY_LINKED_KEY: 13, + UNEXPECTED_LEXICAL_ANALYSIS: 14, + // generator error codes + UNHANDLED_CODEGEN_NODE_TYPE: 15, + // minifier error codes + UNHANDLED_MINIFIER_NODE_TYPE: 16, + // Special value for higher-order compilers to pick up the last code + // to avoid collision of error codes. This should always be kept as the last + // item. + __EXTEND_POINT__: 17 +}; +/** @internal */ +const errorMessages = { + // tokenizer error messages + [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`, + [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`, + [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`, + [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`, + [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`, + [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`, + [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`, + [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`, + [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`, + [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`, + // parser error messages + [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`, + [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`, + // generator error messages + [CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`, + // minimizer error messages + [CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'` +}; +function createCompileError(code, loc, options = {}) { + const { domain, messages, args } = options; + const msg = format((messages || errorMessages)[code] || '', ...(args || [])) + ; + const error = new SyntaxError(String(msg)); + error.code = code; + if (loc) { + error.location = loc; + } + error.domain = domain; + return error; +} +/** @internal */ +function defaultOnError(error) { + throw error; +} + +// eslint-disable-next-line no-useless-escape +const RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/; +const detectHtmlTag = (source) => RE_HTML_TAG.test(source); + +const CHAR_SP = ' '; +const CHAR_CR = '\r'; +const CHAR_LF = '\n'; +const CHAR_LS = String.fromCharCode(0x2028); +const CHAR_PS = String.fromCharCode(0x2029); +function createScanner(str) { + const _buf = str; + let _index = 0; + let _line = 1; + let _column = 1; + let _peekOffset = 0; + const isCRLF = (index) => _buf[index] === CHAR_CR && _buf[index + 1] === CHAR_LF; + const isLF = (index) => _buf[index] === CHAR_LF; + const isPS = (index) => _buf[index] === CHAR_PS; + const isLS = (index) => _buf[index] === CHAR_LS; + const isLineEnd = (index) => isCRLF(index) || isLF(index) || isPS(index) || isLS(index); + const index = () => _index; + const line = () => _line; + const column = () => _column; + const peekOffset = () => _peekOffset; + const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset]; + const currentChar = () => charAt(_index); + const currentPeek = () => charAt(_index + _peekOffset); + function next() { + _peekOffset = 0; + if (isLineEnd(_index)) { + _line++; + _column = 0; + } + if (isCRLF(_index)) { + _index++; + } + _index++; + _column++; + return _buf[_index]; + } + function peek() { + if (isCRLF(_index + _peekOffset)) { + _peekOffset++; + } + _peekOffset++; + return _buf[_index + _peekOffset]; + } + function reset() { + _index = 0; + _line = 1; + _column = 1; + _peekOffset = 0; + } + function resetPeek(offset = 0) { + _peekOffset = offset; + } + function skipToPeek() { + const target = _index + _peekOffset; + // eslint-disable-next-line no-unmodified-loop-condition + while (target !== _index) { + next(); + } + _peekOffset = 0; + } + return { + index, + line, + column, + peekOffset, + charAt, + currentChar, + currentPeek, + next, + peek, + reset, + resetPeek, + skipToPeek + }; +} + +const EOF = undefined; +const DOT = '.'; +const LITERAL_DELIMITER = "'"; +const ERROR_DOMAIN$3 = 'tokenizer'; +function createTokenizer(source, options = {}) { + const location = options.location !== false; + const _scnr = createScanner(source); + const currentOffset = () => _scnr.index(); + const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index()); + const _initLoc = currentPosition(); + const _initOffset = currentOffset(); + const _context = { + currentType: 14 /* TokenTypes.EOF */, + offset: _initOffset, + startLoc: _initLoc, + endLoc: _initLoc, + lastType: 14 /* TokenTypes.EOF */, + lastOffset: _initOffset, + lastStartLoc: _initLoc, + lastEndLoc: _initLoc, + braceNest: 0, + inLinked: false, + text: '' + }; + const context = () => _context; + const { onError } = options; + function emitError(code, pos, offset, ...args) { + const ctx = context(); + pos.column += offset; + pos.offset += offset; + if (onError) { + const loc = location ? createLocation(ctx.startLoc, pos) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$3, + args + }); + onError(err); + } + } + function getToken(context, type, value) { + context.endLoc = currentPosition(); + context.currentType = type; + const token = { type }; + if (location) { + token.loc = createLocation(context.startLoc, context.endLoc); + } + if (value != null) { + token.value = value; + } + return token; + } + const getEndToken = (context) => getToken(context, 14 /* TokenTypes.EOF */); + function eat(scnr, ch) { + if (scnr.currentChar() === ch) { + scnr.next(); + return ch; + } + else { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + return ''; + } + } + function peekSpaces(scnr) { + let buf = ''; + while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) { + buf += scnr.currentPeek(); + scnr.peek(); + } + return buf; + } + function skipSpaces(scnr) { + const buf = peekSpaces(scnr); + scnr.skipToPeek(); + return buf; + } + function isIdentifierStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + cc === 95 // _ + ); + } + function isNumberStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function isNamedIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isListIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ch = scnr.currentPeek() === '-' ? scnr.peek() : scnr.currentPeek(); + const ret = isNumberStart(ch); + scnr.resetPeek(); + return ret; + } + function isLiteralStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === LITERAL_DELIMITER; + scnr.resetPeek(); + return ret; + } + function isLinkedDotStart(scnr, context) { + const { currentType } = context; + if (currentType !== 8 /* TokenTypes.LinkedAlias */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === "." /* TokenChars.LinkedDot */; + scnr.resetPeek(); + return ret; + } + function isLinkedModifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 9 /* TokenTypes.LinkedDot */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isLinkedDelimiterStart(scnr, context) { + const { currentType } = context; + if (!(currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 12 /* TokenTypes.LinkedModifier */)) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === ":" /* TokenChars.LinkedDelimiter */; + scnr.resetPeek(); + return ret; + } + function isLinkedReferStart(scnr, context) { + const { currentType } = context; + if (currentType !== 10 /* TokenTypes.LinkedDelimiter */) { + return false; + } + const fn = () => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return isIdentifierStart(scnr.peek()); + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "|" /* TokenChars.Pipe */ || + ch === ":" /* TokenChars.LinkedDelimiter */ || + ch === "." /* TokenChars.LinkedDot */ || + ch === CHAR_SP || + !ch) { + return false; + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(); + } + else { + // other characters + return isTextStart(scnr, false); + } + }; + const ret = fn(); + scnr.resetPeek(); + return ret; + } + function isPluralStart(scnr) { + peekSpaces(scnr); + const ret = scnr.currentPeek() === "|" /* TokenChars.Pipe */; + scnr.resetPeek(); + return ret; + } + function detectModuloStart(scnr) { + const spaces = peekSpaces(scnr); + const ret = scnr.currentPeek() === "%" /* TokenChars.Modulo */ && + scnr.peek() === "{" /* TokenChars.BraceLeft */; + scnr.resetPeek(); + return { + isModulo: ret, + hasSpace: spaces.length > 0 + }; + } + function isTextStart(scnr, reset = true) { + const fn = (hasSpace = false, prev = '', detectModulo = false) => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return prev === "%" /* TokenChars.Modulo */ ? false : hasSpace; + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || !ch) { + return prev === "%" /* TokenChars.Modulo */ ? true : hasSpace; + } + else if (ch === "%" /* TokenChars.Modulo */) { + scnr.peek(); + return fn(hasSpace, "%" /* TokenChars.Modulo */, true); + } + else if (ch === "|" /* TokenChars.Pipe */) { + return prev === "%" /* TokenChars.Modulo */ || detectModulo + ? true + : !(prev === CHAR_SP || prev === CHAR_LF); + } + else if (ch === CHAR_SP) { + scnr.peek(); + return fn(true, CHAR_SP, detectModulo); + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(true, CHAR_LF, detectModulo); + } + else { + return true; + } + }; + const ret = fn(); + reset && scnr.resetPeek(); + return ret; + } + function takeChar(scnr, fn) { + const ch = scnr.currentChar(); + if (ch === EOF) { + return EOF; + } + if (fn(ch)) { + scnr.next(); + return ch; + } + return null; + } + function isIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 // $ + ); + } + function takeIdentifierChar(scnr) { + return takeChar(scnr, isIdentifier); + } + function isNamedIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 || // $ + cc === 45 // - + ); + } + function takeNamedIdentifierChar(scnr) { + return takeChar(scnr, isNamedIdentifier); + } + function isDigit(ch) { + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function takeDigit(scnr) { + return takeChar(scnr, isDigit); + } + function isHexDigit(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 48 && cc <= 57) || // 0-9 + (cc >= 65 && cc <= 70) || // A-F + (cc >= 97 && cc <= 102)); // a-f + } + function takeHexDigit(scnr) { + return takeChar(scnr, isHexDigit); + } + function getDigits(scnr) { + let ch = ''; + let num = ''; + while ((ch = takeDigit(scnr))) { + num += ch; + } + return num; + } + function readModulo(scnr) { + skipSpaces(scnr); + const ch = scnr.currentChar(); + if (ch !== "%" /* TokenChars.Modulo */) { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + } + scnr.next(); + return "%" /* TokenChars.Modulo */; + } + function readText(scnr) { + let buf = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "}" /* TokenChars.BraceRight */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + !ch) { + break; + } + else if (ch === "%" /* TokenChars.Modulo */) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else { + break; + } + } + else if (ch === CHAR_SP || ch === CHAR_LF) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else if (isPluralStart(scnr)) { + break; + } + else { + buf += ch; + scnr.next(); + } + } + else { + buf += ch; + scnr.next(); + } + } + return buf; + } + function readNamedIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let name = ''; + while ((ch = takeNamedIdentifierChar(scnr))) { + name += ch; + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return name; + } + function readListIdentifier(scnr) { + skipSpaces(scnr); + let value = ''; + if (scnr.currentChar() === '-') { + scnr.next(); + value += `-${getDigits(scnr)}`; + } + else { + value += getDigits(scnr); + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return value; + } + function isLiteral(ch) { + return ch !== LITERAL_DELIMITER && ch !== CHAR_LF; + } + function readLiteral(scnr) { + skipSpaces(scnr); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + let ch = ''; + let literal = ''; + while ((ch = takeChar(scnr, isLiteral))) { + if (ch === '\\') { + literal += readEscapeSequence(scnr); + } + else { + literal += ch; + } + } + const current = scnr.currentChar(); + if (current === CHAR_LF || current === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, currentPosition(), 0); + // TODO: Is it correct really? + if (current === CHAR_LF) { + scnr.next(); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + } + return literal; + } + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + return literal; + } + function readEscapeSequence(scnr) { + const ch = scnr.currentChar(); + switch (ch) { + case '\\': + case `\'`: // eslint-disable-line no-useless-escape + scnr.next(); + return `\\${ch}`; + case 'u': + return readUnicodeEscapeSequence(scnr, ch, 4); + case 'U': + return readUnicodeEscapeSequence(scnr, ch, 6); + default: + emitError(CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, currentPosition(), 0, ch); + return ''; + } + } + function readUnicodeEscapeSequence(scnr, unicode, digits) { + eat(scnr, unicode); + let sequence = ''; + for (let i = 0; i < digits; i++) { + const ch = takeHexDigit(scnr); + if (!ch) { + emitError(CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`); + break; + } + sequence += ch; + } + return `\\${unicode}${sequence}`; + } + function isInvalidIdentifier(ch) { + return (ch !== "{" /* TokenChars.BraceLeft */ && + ch !== "}" /* TokenChars.BraceRight */ && + ch !== CHAR_SP && + ch !== CHAR_LF); + } + function readInvalidIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let identifiers = ''; + while ((ch = takeChar(scnr, isInvalidIdentifier))) { + identifiers += ch; + } + return identifiers; + } + function readLinkedModifier(scnr) { + let ch = ''; + let name = ''; + while ((ch = takeIdentifierChar(scnr))) { + name += ch; + } + return name; + } + function readLinkedRefer(scnr) { + const fn = (buf) => { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + ch === "(" /* TokenChars.ParenLeft */ || + ch === ")" /* TokenChars.ParenRight */ || + !ch) { + return buf; + } + else if (ch === CHAR_SP) { + return buf; + } + else if (ch === CHAR_LF || ch === DOT) { + buf += ch; + scnr.next(); + return fn(buf); + } + else { + buf += ch; + scnr.next(); + return fn(buf); + } + }; + return fn(''); + } + function readPlural(scnr) { + skipSpaces(scnr); + const plural = eat(scnr, "|" /* TokenChars.Pipe */); + skipSpaces(scnr); + return plural; + } + // TODO: We need refactoring of token parsing ... + function readTokenInPlaceholder(scnr, context) { + let token = null; + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + if (context.braceNest >= 1) { + emitError(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 2 /* TokenTypes.BraceLeft */, "{" /* TokenChars.BraceLeft */); + skipSpaces(scnr); + context.braceNest++; + return token; + case "}" /* TokenChars.BraceRight */: + if (context.braceNest > 0 && + context.currentType === 2 /* TokenTypes.BraceLeft */) { + emitError(CompileErrorCodes.EMPTY_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + context.braceNest--; + context.braceNest > 0 && skipSpaces(scnr); + if (context.inLinked && context.braceNest === 0) { + context.inLinked = false; + } + return token; + case "@" /* TokenChars.LinkedAlias */: + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = readTokenInLinked(scnr, context) || getEndToken(context); + context.braceNest = 0; + return token; + default: { + let validNamedIdentifier = true; + let validListIdentifier = true; + let validLiteral = true; + if (isPluralStart(scnr)) { + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (context.braceNest > 0 && + (context.currentType === 5 /* TokenTypes.Named */ || + context.currentType === 6 /* TokenTypes.List */ || + context.currentType === 7 /* TokenTypes.Literal */)) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + context.braceNest = 0; + return readToken(scnr, context); + } + if ((validNamedIdentifier = isNamedIdentifierStart(scnr, context))) { + token = getToken(context, 5 /* TokenTypes.Named */, readNamedIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validListIdentifier = isListIdentifierStart(scnr, context))) { + token = getToken(context, 6 /* TokenTypes.List */, readListIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validLiteral = isLiteralStart(scnr, context))) { + token = getToken(context, 7 /* TokenTypes.Literal */, readLiteral(scnr)); + skipSpaces(scnr); + return token; + } + if (!validNamedIdentifier && !validListIdentifier && !validLiteral) { + // TODO: we should be re-designed invalid cases, when we will extend message syntax near the future ... + token = getToken(context, 13 /* TokenTypes.InvalidPlace */, readInvalidIdentifier(scnr)); + emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value); + skipSpaces(scnr); + return token; + } + break; + } + } + return token; + } + // TODO: We need refactoring of token parsing ... + function readTokenInLinked(scnr, context) { + const { currentType } = context; + let token = null; + const ch = scnr.currentChar(); + if ((currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 9 /* TokenTypes.LinkedDot */ || + currentType === 12 /* TokenTypes.LinkedModifier */ || + currentType === 10 /* TokenTypes.LinkedDelimiter */) && + (ch === CHAR_LF || ch === CHAR_SP)) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + switch (ch) { + case "@" /* TokenChars.LinkedAlias */: + scnr.next(); + token = getToken(context, 8 /* TokenTypes.LinkedAlias */, "@" /* TokenChars.LinkedAlias */); + context.inLinked = true; + return token; + case "." /* TokenChars.LinkedDot */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 9 /* TokenTypes.LinkedDot */, "." /* TokenChars.LinkedDot */); + case ":" /* TokenChars.LinkedDelimiter */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 10 /* TokenTypes.LinkedDelimiter */, ":" /* TokenChars.LinkedDelimiter */); + default: + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (isLinkedDotStart(scnr, context) || + isLinkedDelimiterStart(scnr, context)) { + skipSpaces(scnr); + return readTokenInLinked(scnr, context); + } + if (isLinkedModifierStart(scnr, context)) { + skipSpaces(scnr); + return getToken(context, 12 /* TokenTypes.LinkedModifier */, readLinkedModifier(scnr)); + } + if (isLinkedReferStart(scnr, context)) { + skipSpaces(scnr); + if (ch === "{" /* TokenChars.BraceLeft */) { + // scan the placeholder + return readTokenInPlaceholder(scnr, context) || token; + } + else { + return getToken(context, 11 /* TokenTypes.LinkedKey */, readLinkedRefer(scnr)); + } + } + if (currentType === 8 /* TokenTypes.LinkedAlias */) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + context.braceNest = 0; + context.inLinked = false; + return readToken(scnr, context); + } + } + // TODO: We need refactoring of token parsing ... + function readToken(scnr, context) { + let token = { type: 14 /* TokenTypes.EOF */ }; + if (context.braceNest > 0) { + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + } + if (context.inLinked) { + return readTokenInLinked(scnr, context) || getEndToken(context); + } + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + case "}" /* TokenChars.BraceRight */: + emitError(CompileErrorCodes.UNBALANCED_CLOSING_BRACE, currentPosition(), 0); + scnr.next(); + return getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + case "@" /* TokenChars.LinkedAlias */: + return readTokenInLinked(scnr, context) || getEndToken(context); + default: { + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + const { isModulo, hasSpace } = detectModuloStart(scnr); + if (isModulo) { + return hasSpace + ? getToken(context, 0 /* TokenTypes.Text */, readText(scnr)) + : getToken(context, 4 /* TokenTypes.Modulo */, readModulo(scnr)); + } + if (isTextStart(scnr)) { + return getToken(context, 0 /* TokenTypes.Text */, readText(scnr)); + } + break; + } + } + return token; + } + function nextToken() { + const { currentType, offset, startLoc, endLoc } = _context; + _context.lastType = currentType; + _context.lastOffset = offset; + _context.lastStartLoc = startLoc; + _context.lastEndLoc = endLoc; + _context.offset = currentOffset(); + _context.startLoc = currentPosition(); + if (_scnr.currentChar() === EOF) { + return getToken(_context, 14 /* TokenTypes.EOF */); + } + return readToken(_scnr, _context); + } + return { + nextToken, + currentOffset, + currentPosition, + context + }; +} + +const ERROR_DOMAIN$2 = 'parser'; +// Backslash backslash, backslash quote, uHHHH, UHHHHHH. +const KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g; +function fromEscapeSequence(match, codePoint4, codePoint6) { + switch (match) { + case `\\\\`: + return `\\`; + // eslint-disable-next-line no-useless-escape + case `\\\'`: + // eslint-disable-next-line no-useless-escape + return `\'`; + default: { + const codePoint = parseInt(codePoint4 || codePoint6, 16); + if (codePoint <= 0xd7ff || codePoint >= 0xe000) { + return String.fromCodePoint(codePoint); + } + // invalid ... + // Replace them with U+FFFD REPLACEMENT CHARACTER. + return '�'; + } + } +} +function createParser(options = {}) { + const location = options.location !== false; + const { onError, onWarn } = options; + function emitError(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onError) { + const loc = location ? createLocation(start, end) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$2, + args + }); + onError(err); + } + } + function emitWarn(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onWarn) { + const loc = location ? createLocation(start, end) : null; + onWarn(createCompileWarn(code, loc, args)); + } + } + function startNode(type, offset, loc) { + const node = { type }; + if (location) { + node.start = offset; + node.end = offset; + node.loc = { start: loc, end: loc }; + } + return node; + } + function endNode(node, offset, pos, type) { + if (type) { + node.type = type; + } + if (location) { + node.end = offset; + if (node.loc) { + node.loc.end = pos; + } + } + } + function parseText(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(3 /* NodeTypes.Text */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseList(tokenizer, index) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(5 /* NodeTypes.List */, offset, loc); + node.index = parseInt(index, 10); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseNamed(tokenizer, key, modulo) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(4 /* NodeTypes.Named */, offset, loc); + node.key = key; + if (modulo === true) { + node.modulo = true; + } + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLiteral(tokenizer, value) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(9 /* NodeTypes.Literal */, offset, loc); + node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinkedModifier(tokenizer) { + const token = tokenizer.nextToken(); + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get linked dot loc + const node = startNode(8 /* NodeTypes.LinkedModifier */, offset, loc); + if (token.type !== 12 /* TokenTypes.LinkedModifier */) { + // empty modifier + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0); + node.value = ''; + endNode(node, offset, loc); + return { + nextConsumeToken: token, + node + }; + } + // check token + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.value = token.value || ''; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node + }; + } + function parseLinkedKey(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(7 /* NodeTypes.LinkedKey */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinked(tokenizer) { + const context = tokenizer.context(); + const linkedNode = startNode(6 /* NodeTypes.Linked */, context.offset, context.startLoc); + let token = tokenizer.nextToken(); + if (token.type === 9 /* TokenTypes.LinkedDot */) { + const parsed = parseLinkedModifier(tokenizer); + linkedNode.modifier = parsed.node; + token = parsed.nextConsumeToken || tokenizer.nextToken(); + } + // asset check token + if (token.type !== 10 /* TokenTypes.LinkedDelimiter */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + token = tokenizer.nextToken(); + // skip brace left + if (token.type === 2 /* TokenTypes.BraceLeft */) { + token = tokenizer.nextToken(); + } + switch (token.type) { + case 11 /* TokenTypes.LinkedKey */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseNamed(tokenizer, token.value || ''); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseList(tokenizer, token.value || ''); + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLiteral(tokenizer, token.value || ''); + break; + default: { + // empty key + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0); + const nextContext = tokenizer.context(); + const emptyLinkedKeyNode = startNode(7 /* NodeTypes.LinkedKey */, nextContext.offset, nextContext.startLoc); + emptyLinkedKeyNode.value = ''; + endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc); + linkedNode.key = emptyLinkedKeyNode; + endNode(linkedNode, nextContext.offset, nextContext.startLoc); + return { + nextConsumeToken: token, + node: linkedNode + }; + } + } + endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node: linkedNode + }; + } + function parseMessage(tokenizer) { + const context = tokenizer.context(); + const startOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? tokenizer.currentOffset() + : context.offset; + const startLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.endLoc + : context.startLoc; + const node = startNode(2 /* NodeTypes.Message */, startOffset, startLoc); + node.items = []; + let nextToken = null; + let modulo = null; + do { + const token = nextToken || tokenizer.nextToken(); + nextToken = null; + switch (token.type) { + case 0 /* TokenTypes.Text */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseText(tokenizer, token.value || '')); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseList(tokenizer, token.value || '')); + break; + case 4 /* TokenTypes.Modulo */: + modulo = true; + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseNamed(tokenizer, token.value || '', !!modulo)); + if (modulo) { + emitWarn(tokenizer, CompileWarnCodes.USE_MODULO_SYNTAX, context.lastStartLoc, 0, getTokenCaption(token)); + modulo = null; + } + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseLiteral(tokenizer, token.value || '')); + break; + case 8 /* TokenTypes.LinkedAlias */: { + const parsed = parseLinked(tokenizer); + node.items.push(parsed.node); + nextToken = parsed.nextConsumeToken || null; + break; + } + } + } while (context.currentType !== 14 /* TokenTypes.EOF */ && + context.currentType !== 1 /* TokenTypes.Pipe */); + // adjust message node loc + const endOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastOffset + : tokenizer.currentOffset(); + const endLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastEndLoc + : tokenizer.currentPosition(); + endNode(node, endOffset, endLoc); + return node; + } + function parsePlural(tokenizer, offset, loc, msgNode) { + const context = tokenizer.context(); + let hasEmptyMessage = msgNode.items.length === 0; + const node = startNode(1 /* NodeTypes.Plural */, offset, loc); + node.cases = []; + node.cases.push(msgNode); + do { + const msg = parseMessage(tokenizer); + if (!hasEmptyMessage) { + hasEmptyMessage = msg.items.length === 0; + } + node.cases.push(msg); + } while (context.currentType !== 14 /* TokenTypes.EOF */); + if (hasEmptyMessage) { + emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseResource(tokenizer) { + const context = tokenizer.context(); + const { offset, startLoc } = context; + const msgNode = parseMessage(tokenizer); + if (context.currentType === 14 /* TokenTypes.EOF */) { + return msgNode; + } + else { + return parsePlural(tokenizer, offset, startLoc, msgNode); + } + } + function parse(source) { + const tokenizer = createTokenizer(source, assign({}, options)); + const context = tokenizer.context(); + const node = startNode(0 /* NodeTypes.Resource */, context.offset, context.startLoc); + if (location && node.loc) { + node.loc.source = source; + } + node.body = parseResource(tokenizer); + if (options.onCacheKey) { + node.cacheKey = options.onCacheKey(source); + } + // assert whether achieved to EOF + if (context.currentType !== 14 /* TokenTypes.EOF */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || ''); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + return { parse }; +} +function getTokenCaption(token) { + if (token.type === 14 /* TokenTypes.EOF */) { + return 'EOF'; + } + const name = (token.value || '').replace(/\r?\n/gu, '\\n'); + return name.length > 10 ? name.slice(0, 9) + '…' : name; +} + +function createTransformer(ast, options = {} // eslint-disable-line +) { + const _context = { + ast, + helpers: new Set() + }; + const context = () => _context; + const helper = (name) => { + _context.helpers.add(name); + return name; + }; + return { context, helper }; +} +function traverseNodes(nodes, transformer) { + for (let i = 0; i < nodes.length; i++) { + traverseNode(nodes[i], transformer); + } +} +function traverseNode(node, transformer) { + // TODO: if we need pre-hook of transform, should be implemented to here + switch (node.type) { + case 1 /* NodeTypes.Plural */: + traverseNodes(node.cases, transformer); + transformer.helper("plural" /* HelperNameMap.PLURAL */); + break; + case 2 /* NodeTypes.Message */: + traverseNodes(node.items, transformer); + break; + case 6 /* NodeTypes.Linked */: { + const linked = node; + traverseNode(linked.key, transformer); + transformer.helper("linked" /* HelperNameMap.LINKED */); + transformer.helper("type" /* HelperNameMap.TYPE */); + break; + } + case 5 /* NodeTypes.List */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("list" /* HelperNameMap.LIST */); + break; + case 4 /* NodeTypes.Named */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("named" /* HelperNameMap.NAMED */); + break; + } + // TODO: if we need post-hook of transform, should be implemented to here +} +// transform AST +function transform(ast, options = {} // eslint-disable-line +) { + const transformer = createTransformer(ast); + transformer.helper("normalize" /* HelperNameMap.NORMALIZE */); + // traverse + ast.body && traverseNode(ast.body, transformer); + // set meta information + const context = transformer.context(); + ast.helpers = Array.from(context.helpers); +} + +function optimize(ast) { + const body = ast.body; + if (body.type === 2 /* NodeTypes.Message */) { + optimizeMessageNode(body); + } + else { + body.cases.forEach(c => optimizeMessageNode(c)); + } + return ast; +} +function optimizeMessageNode(message) { + if (message.items.length === 1) { + const item = message.items[0]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + message.static = item.value; + delete item.value; // optimization for size + } + } + else { + const values = []; + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (!(item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */)) { + break; + } + if (item.value == null) { + break; + } + values.push(item.value); + } + if (values.length === message.items.length) { + message.static = join(values); + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + delete item.value; // optimization for size + } + } + } + } +} + +const ERROR_DOMAIN$1 = 'minifier'; +/* eslint-disable @typescript-eslint/no-explicit-any */ +function minify(node) { + node.t = node.type; + switch (node.type) { + case 0 /* NodeTypes.Resource */: { + const resource = node; + minify(resource.body); + resource.b = resource.body; + delete resource.body; + break; + } + case 1 /* NodeTypes.Plural */: { + const plural = node; + const cases = plural.cases; + for (let i = 0; i < cases.length; i++) { + minify(cases[i]); + } + plural.c = cases; + delete plural.cases; + break; + } + case 2 /* NodeTypes.Message */: { + const message = node; + const items = message.items; + for (let i = 0; i < items.length; i++) { + minify(items[i]); + } + message.i = items; + delete message.items; + if (message.static) { + message.s = message.static; + delete message.static; + } + break; + } + case 3 /* NodeTypes.Text */: + case 9 /* NodeTypes.Literal */: + case 8 /* NodeTypes.LinkedModifier */: + case 7 /* NodeTypes.LinkedKey */: { + const valueNode = node; + if (valueNode.value) { + valueNode.v = valueNode.value; + delete valueNode.value; + } + break; + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + minify(linked.key); + linked.k = linked.key; + delete linked.key; + if (linked.modifier) { + minify(linked.modifier); + linked.m = linked.modifier; + delete linked.modifier; + } + break; + } + case 5 /* NodeTypes.List */: { + const list = node; + list.i = list.index; + delete list.index; + break; + } + case 4 /* NodeTypes.Named */: { + const named = node; + named.k = named.key; + delete named.key; + break; + } + default: + { + throw createCompileError(CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE, null, { + domain: ERROR_DOMAIN$1, + args: [node.type] + }); + } + } + delete node.type; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +// eslint-disable-next-line @typescript-eslint/triple-slash-reference +/// +const ERROR_DOMAIN = 'parser'; +function createCodeGenerator(ast, options) { + const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options; + const location = options.location !== false; + const _context = { + filename, + code: '', + column: 1, + line: 1, + offset: 0, + map: undefined, + breakLineCode, + needIndent: _needIndent, + indentLevel: 0 + }; + if (location && ast.loc) { + _context.source = ast.loc.source; + } + const context = () => _context; + function push(code, node) { + _context.code += code; + } + function _newline(n, withBreakLine = true) { + const _breakLineCode = withBreakLine ? breakLineCode : ''; + push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode); + } + function indent(withNewLine = true) { + const level = ++_context.indentLevel; + withNewLine && _newline(level); + } + function deindent(withNewLine = true) { + const level = --_context.indentLevel; + withNewLine && _newline(level); + } + function newline() { + _newline(_context.indentLevel); + } + const helper = (key) => `_${key}`; + const needIndent = () => _context.needIndent; + return { + context, + push, + indent, + deindent, + newline, + helper, + needIndent + }; +} +function generateLinkedNode(generator, node) { + const { helper } = generator; + generator.push(`${helper("linked" /* HelperNameMap.LINKED */)}(`); + generateNode(generator, node.key); + if (node.modifier) { + generator.push(`, `); + generateNode(generator, node.modifier); + generator.push(`, _type`); + } + else { + generator.push(`, undefined, _type`); + } + generator.push(`)`); +} +function generateMessageNode(generator, node) { + const { helper, needIndent } = generator; + generator.push(`${helper("normalize" /* HelperNameMap.NORMALIZE */)}([`); + generator.indent(needIndent()); + const length = node.items.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.items[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push('])'); +} +function generatePluralNode(generator, node) { + const { helper, needIndent } = generator; + if (node.cases.length > 1) { + generator.push(`${helper("plural" /* HelperNameMap.PLURAL */)}([`); + generator.indent(needIndent()); + const length = node.cases.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.cases[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push(`])`); + } +} +function generateResource(generator, node) { + if (node.body) { + generateNode(generator, node.body); + } + else { + generator.push('null'); + } +} +function generateNode(generator, node) { + const { helper } = generator; + switch (node.type) { + case 0 /* NodeTypes.Resource */: + generateResource(generator, node); + break; + case 1 /* NodeTypes.Plural */: + generatePluralNode(generator, node); + break; + case 2 /* NodeTypes.Message */: + generateMessageNode(generator, node); + break; + case 6 /* NodeTypes.Linked */: + generateLinkedNode(generator, node); + break; + case 8 /* NodeTypes.LinkedModifier */: + generator.push(JSON.stringify(node.value), node); + break; + case 7 /* NodeTypes.LinkedKey */: + generator.push(JSON.stringify(node.value), node); + break; + case 5 /* NodeTypes.List */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("list" /* HelperNameMap.LIST */)}(${node.index}))`, node); + break; + case 4 /* NodeTypes.Named */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("named" /* HelperNameMap.NAMED */)}(${JSON.stringify(node.key)}))`, node); + break; + case 9 /* NodeTypes.Literal */: + generator.push(JSON.stringify(node.value), node); + break; + case 3 /* NodeTypes.Text */: + generator.push(JSON.stringify(node.value), node); + break; + default: + { + throw createCompileError(CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE, null, { + domain: ERROR_DOMAIN, + args: [node.type] + }); + } + } +} +// generate code from AST +const generate = (ast, options = {} // eslint-disable-line +) => { + const mode = isString(options.mode) ? options.mode : 'normal'; + const filename = isString(options.filename) + ? options.filename + : 'message.intl'; + const sourceMap = !!options.sourceMap; + // prettier-ignore + const breakLineCode = options.breakLineCode != null + ? options.breakLineCode + : mode === 'arrow' + ? ';' + : '\n'; + const needIndent = options.needIndent ? options.needIndent : mode !== 'arrow'; + const helpers = ast.helpers || []; + const generator = createCodeGenerator(ast, { + mode, + filename, + sourceMap, + breakLineCode, + needIndent + }); + generator.push(mode === 'normal' ? `function __msg__ (ctx) {` : `(ctx) => {`); + generator.indent(needIndent); + if (helpers.length > 0) { + generator.push(`const { ${join(helpers.map(s => `${s}: _${s}`), ', ')} } = ctx`); + generator.newline(); + } + generator.push(`return `); + generateNode(generator, ast); + generator.deindent(needIndent); + generator.push(`}`); + delete ast.helpers; + const { code, map } = generator.context(); + return { + ast, + code, + map: map ? map.toJSON() : undefined // eslint-disable-line @typescript-eslint/no-explicit-any + }; +}; + +function baseCompile(source, options = {}) { + const assignedOptions = assign({}, options); + const jit = !!assignedOptions.jit; + const enalbeMinify = !!assignedOptions.minify; + const enambeOptimize = assignedOptions.optimize == null ? true : assignedOptions.optimize; + // parse source codes + const parser = createParser(assignedOptions); + const ast = parser.parse(source); + if (!jit) { + // transform ASTs + transform(ast, assignedOptions); + // generate javascript codes + return generate(ast, assignedOptions); + } + else { + // optimize ASTs + enambeOptimize && optimize(ast); + // minimize ASTs + enalbeMinify && minify(ast); + // In JIT mode, no ast transform, no code generation. + return { ast, code: '' }; + } +} + +export { CompileErrorCodes, CompileWarnCodes, ERROR_DOMAIN$2 as ERROR_DOMAIN, LOCATION_STUB, baseCompile, createCompileError, createCompileWarn, createLocation, createParser, createPosition, defaultOnError, detectHtmlTag, errorMessages, warnMessages }; diff --git a/node_modules/@intlify/message-compiler/dist/message-compiler.esm-browser.prod.js b/node_modules/@intlify/message-compiler/dist/message-compiler.esm-browser.prod.js new file mode 100644 index 0000000..1af914f --- /dev/null +++ b/node_modules/@intlify/message-compiler/dist/message-compiler.esm-browser.prod.js @@ -0,0 +1,6 @@ +/*! + * message-compiler v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +const LOCATION_STUB={start:{line:1,column:1,offset:0},end:{line:1,column:1,offset:0}};function createPosition(e,t,n){return{line:e,column:t,offset:n}}function createLocation(e,t,n){const r={start:e,end:t};return null!=n&&(r.source=n),r}const assign=Object.assign,isString=e=>"string"==typeof e;function join(e,t=""){return e.reduce(((e,n,r)=>0===r?e+n:e+t+n),"")}const CompileWarnCodes={USE_MODULO_SYNTAX:1,__EXTEND_POINT__:2},warnMessages={[CompileWarnCodes.USE_MODULO_SYNTAX]:"Use modulo before '{{0}}'."};function createCompileWarn(e,t,...n){const r={message:String(e),code:e};return t&&(r.location=t),r}const CompileErrorCodes={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16,__EXTEND_POINT__:17},errorMessages={[CompileErrorCodes.EXPECTED_TOKEN]:"Expected token: '{0}'",[CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]:"Invalid token in placeholder: '{0}'",[CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]:"Unterminated single quote in placeholder",[CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]:"Unknown escape sequence: \\{0}",[CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]:"Invalid unicode escape sequence: {0}",[CompileErrorCodes.UNBALANCED_CLOSING_BRACE]:"Unbalanced closing brace",[CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]:"Unterminated closing brace",[CompileErrorCodes.EMPTY_PLACEHOLDER]:"Empty placeholder",[CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]:"Not allowed nest placeholder",[CompileErrorCodes.INVALID_LINKED_FORMAT]:"Invalid linked format",[CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]:"Plural must have messages",[CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]:"Unexpected empty linked modifier",[CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]:"Unexpected empty linked key",[CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]:"Unexpected lexical analysis in token: '{0}'",[CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]:"unhandled codegen node type: '{0}'",[CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]:"unhandled mimifier node type: '{0}'"};function createCompileError(e,t,n={}){const{domain:r,messages:o,args:s}=n,c=new SyntaxError(String(e));return c.code=e,t&&(c.location=t),c.domain=r,c}function defaultOnError(e){throw e}const RE_HTML_TAG=/<\/?[\w\s="/.':;#-\/]+>/,detectHtmlTag=e=>RE_HTML_TAG.test(e),CHAR_SP=" ",CHAR_CR="\r",CHAR_LF="\n",CHAR_LS=String.fromCharCode(8232),CHAR_PS=String.fromCharCode(8233);function createScanner(e){const t=e;let n=0,r=1,o=1,s=0;const c=e=>t[e]===CHAR_CR&&t[e+1]===CHAR_LF,a=e=>t[e]===CHAR_PS,i=e=>t[e]===CHAR_LS,u=e=>c(e)||(e=>t[e]===CHAR_LF)(e)||a(e)||i(e),l=e=>c(e)||a(e)||i(e)?CHAR_LF:t[e];function E(){return s=0,u(n)&&(r++,o=0),c(n)&&n++,n++,o++,t[n]}return{index:()=>n,line:()=>r,column:()=>o,peekOffset:()=>s,charAt:l,currentChar:()=>l(n),currentPeek:()=>l(n+s),next:E,peek:function(){return c(n+s)&&s++,s++,t[n+s]},reset:function(){n=0,r=1,o=1,s=0},resetPeek:function(e=0){s=e},skipToPeek:function(){const e=n+s;for(;e!==n;)E();s=0}}}const EOF=void 0,DOT=".",LITERAL_DELIMITER="'",ERROR_DOMAIN$1="tokenizer";function createTokenizer(e,t={}){const n=!1!==t.location,r=createScanner(e),o=()=>r.index(),s=()=>createPosition(r.line(),r.column(),r.index()),c=s(),a=o(),i={currentType:14,offset:a,startLoc:c,endLoc:c,lastType:14,lastOffset:a,lastStartLoc:c,lastEndLoc:c,braceNest:0,inLinked:!1,text:""},u=()=>i,{onError:l}=t;function E(e,t,r){e.endLoc=s(),e.currentType=t;const o={type:t};return n&&(o.loc=createLocation(e.startLoc,e.endLoc)),null!=r&&(o.value=r),o}const C=e=>E(e,14);function f(e,t){return e.currentChar()===t?(e.next(),t):(CompileErrorCodes.EXPECTED_TOKEN,s(),"")}function d(e){let t="";for(;e.currentPeek()===CHAR_SP||e.currentPeek()===CHAR_LF;)t+=e.currentPeek(),e.peek();return t}function p(e){const t=d(e);return e.skipToPeek(),t}function _(e){if(e===EOF)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function L(e,t){const{currentType:n}=t;if(2!==n)return!1;d(e);const r=function(e){if(e===EOF)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function N(e){d(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function A(e,t=!0){const n=(t=!1,r="",o=!1)=>{const s=e.currentPeek();return"{"===s?"%"!==r&&t:"@"!==s&&s?"%"===s?(e.peek(),n(t,"%",!0)):"|"===s?!("%"!==r&&!o)||!(r===CHAR_SP||r===CHAR_LF):s===CHAR_SP?(e.peek(),n(!0,CHAR_SP,o)):s!==CHAR_LF||(e.peek(),n(!0,CHAR_LF,o)):"%"===r||t},r=n();return t&&e.resetPeek(),r}function T(e,t){const n=e.currentChar();return n===EOF?EOF:t(n)?(e.next(),n):null}function m(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t}function k(e){return T(e,m)}function I(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t||45===t}function S(e){return T(e,I)}function P(e){const t=e.charCodeAt(0);return t>=48&&t<=57}function h(e){return T(e,P)}function O(e){const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function D(e){return T(e,O)}function y(e){let t="",n="";for(;t=h(e);)n+=t;return n}function R(e){let t="";for(;;){const n=e.currentChar();if("{"===n||"}"===n||"@"===n||"|"===n||!n)break;if("%"===n){if(!A(e))break;t+=n,e.next()}else if(n===CHAR_SP||n===CHAR_LF)if(A(e))t+=n,e.next();else{if(N(e))break;t+=n,e.next()}else t+=n,e.next()}return t}function g(e){return e!==LITERAL_DELIMITER&&e!==CHAR_LF}function U(e){const t=e.currentChar();switch(t){case"\\":case"'":return e.next(),`\\${t}`;case"u":return b(e,t,4);case"U":return b(e,t,6);default:return CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE,s(),""}}function b(e,t,n){f(e,t);let r="";for(let o=0;o=1&&(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER,s()),e.next(),n=E(t,2,"{"),p(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&(CompileErrorCodes.EMPTY_PLACEHOLDER,s()),e.next(),n=E(t,3,"}"),t.braceNest--,t.braceNest>0&&p(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),n;case"@":return t.braceNest>0&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),n=H(e,t)||C(t),t.braceNest=0,n;default:{let r=!0,o=!0,c=!0;if(N(e))return t.braceNest>0&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),n=E(t,1,M(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(5===t.currentType||6===t.currentType||7===t.currentType))return CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s(),t.braceNest=0,X(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;d(e);const r=_(e.currentPeek());return e.resetPeek(),r}(e,t))return n=E(t,5,function(e){p(e);let t="",n="";for(;t=S(e);)n+=t;return e.currentChar()===EOF&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),n}(e)),p(e),n;if(o=L(e,t))return n=E(t,6,function(e){p(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${y(e)}`):t+=y(e),e.currentChar()===EOF&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),t}(e)),p(e),n;if(c=function(e,t){const{currentType:n}=t;if(2!==n)return!1;d(e);const r=e.currentPeek()===LITERAL_DELIMITER;return e.resetPeek(),r}(e,t))return n=E(t,7,function(e){p(e),f(e,"'");let t="",n="";for(;t=T(e,g);)n+="\\"===t?U(e):t;const r=e.currentChar();return r===CHAR_LF||r===EOF?(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,s(),r===CHAR_LF&&(e.next(),f(e,"'")),n):(f(e,"'"),n)}(e)),p(e),n;if(!r&&!o&&!c)return n=E(t,13,function(e){p(e);let t="",n="";for(;t=T(e,x);)n+=t;return n}(e)),CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER,s(),n.value,p(e),n;break}}return n}function H(e,t){const{currentType:n}=t;let r=null;const o=e.currentChar();switch(8!==n&&9!==n&&12!==n&&10!==n||o!==CHAR_LF&&o!==CHAR_SP||(CompileErrorCodes.INVALID_LINKED_FORMAT,s()),o){case"@":return e.next(),r=E(t,8,"@"),t.inLinked=!0,r;case".":return p(e),e.next(),E(t,9,".");case":":return p(e),e.next(),E(t,10,":");default:return N(e)?(r=E(t,1,M(e)),t.braceNest=0,t.inLinked=!1,r):function(e,t){const{currentType:n}=t;if(8!==n)return!1;d(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,t)||function(e,t){const{currentType:n}=t;if(8!==n&&12!==n)return!1;d(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,t)?(p(e),H(e,t)):function(e,t){const{currentType:n}=t;if(9!==n)return!1;d(e);const r=_(e.currentPeek());return e.resetPeek(),r}(e,t)?(p(e),E(t,12,function(e){let t="",n="";for(;t=k(e);)n+=t;return n}(e))):function(e,t){const{currentType:n}=t;if(10!==n)return!1;const r=()=>{const t=e.currentPeek();return"{"===t?_(e.peek()):!("@"===t||"%"===t||"|"===t||":"===t||"."===t||t===CHAR_SP||!t)&&(t===CHAR_LF?(e.peek(),r()):A(e,!1))},o=r();return e.resetPeek(),o}(e,t)?(p(e),"{"===o?v(e,t)||r:E(t,11,function(e){const t=n=>{const r=e.currentChar();return"{"!==r&&"%"!==r&&"@"!==r&&"|"!==r&&"("!==r&&")"!==r&&r?r===CHAR_SP?n:(n+=r,e.next(),t(n)):n};return t("")}(e))):(8===n&&(CompileErrorCodes.INVALID_LINKED_FORMAT,s()),t.braceNest=0,t.inLinked=!1,X(e,t))}}function X(e,t){let n={type:14};if(t.braceNest>0)return v(e,t)||C(t);if(t.inLinked)return H(e,t)||C(t);switch(e.currentChar()){case"{":return v(e,t)||C(t);case"}":return CompileErrorCodes.UNBALANCED_CLOSING_BRACE,s(),e.next(),E(t,3,"}");case"@":return H(e,t)||C(t);default:{if(N(e))return n=E(t,1,M(e)),t.braceNest=0,t.inLinked=!1,n;const{isModulo:r,hasSpace:o}=function(e){const t=d(e),n="%"===e.currentPeek()&&"{"===e.peek();return e.resetPeek(),{isModulo:n,hasSpace:t.length>0}}(e);if(r)return o?E(t,0,R(e)):E(t,4,function(e){p(e);const t=e.currentChar();return"%"!==t&&(CompileErrorCodes.EXPECTED_TOKEN,s()),e.next(),"%"}(e));if(A(e))return E(t,0,R(e));break}}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:c}=i;return i.lastType=e,i.lastOffset=t,i.lastStartLoc=n,i.lastEndLoc=c,i.offset=o(),i.startLoc=s(),r.currentChar()===EOF?E(i,14):X(r,i)},currentOffset:o,currentPosition:s,context:u}}const ERROR_DOMAIN="parser",KNOWN_ESCAPES=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function fromEscapeSequence(e,t,n){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const e=parseInt(t||n,16);return e<=55295||e>=57344?String.fromCodePoint(e):"�"}}}function createParser(e={}){const t=!1!==e.location,{onError:n,onWarn:r}=e;function o(e,n,r){const o={type:e};return t&&(o.start=n,o.end=n,o.loc={start:r,end:r}),o}function s(e,n,r,o){o&&(e.type=o),t&&(e.end=n,e.loc&&(e.loc.end=r))}function c(e,t){const n=e.context(),r=o(3,n.offset,n.startLoc);return r.value=t,s(r,e.currentOffset(),e.currentPosition()),r}function a(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:c}=n,a=o(5,r,c);return a.index=parseInt(t,10),e.nextToken(),s(a,e.currentOffset(),e.currentPosition()),a}function i(e,t,n){const r=e.context(),{lastOffset:c,lastStartLoc:a}=r,i=o(4,c,a);return i.key=t,!0===n&&(i.modulo=!0),e.nextToken(),s(i,e.currentOffset(),e.currentPosition()),i}function u(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:c}=n,a=o(9,r,c);return a.value=t.replace(KNOWN_ESCAPES,fromEscapeSequence),e.nextToken(),s(a,e.currentOffset(),e.currentPosition()),a}function l(e){const t=e.context(),n=o(6,t.offset,t.startLoc);let r=e.nextToken();if(9===r.type){const t=function(e){const t=e.nextToken(),n=e.context(),{lastOffset:r,lastStartLoc:c}=n,a=o(8,r,c);return 12!==t.type?(CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER,n.lastStartLoc,a.value="",s(a,r,c),{nextConsumeToken:t,node:a}):(null==t.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,n.lastStartLoc,getTokenCaption(t)),a.value=t.value||"",s(a,e.currentOffset(),e.currentPosition()),{node:a})}(e);n.modifier=t.node,r=t.nextConsumeToken||e.nextToken()}switch(10!==r.type&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),r=e.nextToken(),2===r.type&&(r=e.nextToken()),r.type){case 11:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.key=function(e,t){const n=e.context(),r=o(7,n.offset,n.startLoc);return r.value=t,s(r,e.currentOffset(),e.currentPosition()),r}(e,r.value||"");break;case 5:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.key=i(e,r.value||"");break;case 6:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.key=a(e,r.value||"");break;case 7:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.key=u(e,r.value||"");break;default:{CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const c=e.context(),a=o(7,c.offset,c.startLoc);return a.value="",s(a,c.offset,c.startLoc),n.key=a,s(n,c.offset,c.startLoc),{nextConsumeToken:r,node:n}}}return s(n,e.currentOffset(),e.currentPosition()),{node:n}}function E(e){const t=e.context(),n=o(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let r=null,E=null;do{const o=r||e.nextToken();switch(r=null,o.type){case 0:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),n.items.push(c(e,o.value||""));break;case 6:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),n.items.push(a(e,o.value||""));break;case 4:E=!0;break;case 5:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),n.items.push(i(e,o.value||"",!!E)),E&&(CompileWarnCodes.USE_MODULO_SYNTAX,t.lastStartLoc,getTokenCaption(o),E=null);break;case 7:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),n.items.push(u(e,o.value||""));break;case 8:{const t=l(e);n.items.push(t.node),r=t.nextConsumeToken||null;break}}}while(14!==t.currentType&&1!==t.currentType);return s(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function C(e){const t=e.context(),{offset:n,startLoc:r}=t,c=E(e);return 14===t.currentType?c:function(e,t,n,r){const c=e.context();let a=0===r.items.length;const i=o(1,t,n);i.cases=[],i.cases.push(r);do{const t=E(e);a||(a=0===t.items.length),i.cases.push(t)}while(14!==c.currentType);return a&&CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL,s(i,e.currentOffset(),e.currentPosition()),i}(e,n,r,c)}return{parse:function(n){const r=createTokenizer(n,assign({},e)),c=r.context(),a=o(0,c.offset,c.startLoc);return t&&a.loc&&(a.loc.source=n),a.body=C(r),e.onCacheKey&&(a.cacheKey=e.onCacheKey(n)),14!==c.currentType&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,c.lastStartLoc,n[c.offset]),s(a,r.currentOffset(),r.currentPosition()),a}}}function getTokenCaption(e){if(14===e.type)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function createTransformer(e,t={}){const n={ast:e,helpers:new Set};return{context:()=>n,helper:e=>(n.helpers.add(e),e)}}function traverseNodes(e,t){for(let n=0;noptimizeMessageNode(e))),e}function optimizeMessageNode(e){if(1===e.items.length){const t=e.items[0];3!==t.type&&9!==t.type||(e.static=t.value,delete t.value)}else{const t=[];for(let n=0;na,push:i,indent:function(e=!0){const t=++a.indentLevel;e&&u(t)},deindent:function(e=!0){const t=--a.indentLevel;e&&u(t)},newline:function(){u(a.indentLevel)},helper:e=>`_${e}`,needIndent:()=>a.needIndent}}function generateLinkedNode(e,t){const{helper:n}=e;e.push(`${n("linked")}(`),generateNode(e,t.key),t.modifier?(e.push(", "),generateNode(e,t.modifier),e.push(", _type")):e.push(", undefined, _type"),e.push(")")}function generateMessageNode(e,t){const{helper:n,needIndent:r}=e;e.push(`${n("normalize")}([`),e.indent(r());const o=t.items.length;for(let s=0;s1){e.push(`${n("plural")}([`),e.indent(r());const o=t.cases.length;for(let n=0;n{const n=isString(t.mode)?t.mode:"normal",r=isString(t.filename)?t.filename:"message.intl",o=!!t.sourceMap,s=null!=t.breakLineCode?t.breakLineCode:"arrow"===n?";":"\n",c=t.needIndent?t.needIndent:"arrow"!==n,a=e.helpers||[],i=createCodeGenerator(e,{mode:n,filename:r,sourceMap:o,breakLineCode:s,needIndent:c});i.push("normal"===n?"function __msg__ (ctx) {":"(ctx) => {"),i.indent(c),a.length>0&&(i.push(`const { ${join(a.map((e=>`${e}: _${e}`)),", ")} } = ctx`),i.newline()),i.push("return "),generateNode(i,e),i.deindent(c),i.push("}"),delete e.helpers;const{code:u,map:l}=i.context();return{ast:e,code:u,map:l?l.toJSON():void 0}};function baseCompile(e,t={}){const n=assign({},t),r=!!n.jit,o=!!n.minify,s=null==n.optimize||n.optimize,c=createParser(n).parse(e);return r?(s&&optimize(c),o&&minify(c),{ast:c,code:""}):(transform(c,n),generate(c,n))}export{CompileErrorCodes,CompileWarnCodes,ERROR_DOMAIN,LOCATION_STUB,baseCompile,createCompileError,createCompileWarn,createLocation,createParser,createPosition,defaultOnError,detectHtmlTag,errorMessages,warnMessages}; diff --git a/node_modules/@intlify/message-compiler/dist/message-compiler.esm-bundler.js b/node_modules/@intlify/message-compiler/dist/message-compiler.esm-bundler.js new file mode 100644 index 0000000..bf93151 --- /dev/null +++ b/node_modules/@intlify/message-compiler/dist/message-compiler.esm-bundler.js @@ -0,0 +1 @@ +export * from '../dist/message-compiler.mjs' \ No newline at end of file diff --git a/node_modules/@intlify/message-compiler/dist/message-compiler.global.js b/node_modules/@intlify/message-compiler/dist/message-compiler.global.js new file mode 100644 index 0000000..75b193f --- /dev/null +++ b/node_modules/@intlify/message-compiler/dist/message-compiler.global.js @@ -0,0 +1,1645 @@ +/*! + * message-compiler v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +var IntlifyMessageCompiler = (function (exports) { + 'use strict'; + + const LOCATION_STUB = { + start: { line: 1, column: 1, offset: 0 }, + end: { line: 1, column: 1, offset: 0 } + }; + function createPosition(line, column, offset) { + return { line, column, offset }; + } + function createLocation(start, end, source) { + const loc = { start, end }; + if (source != null) { + loc.source = source; + } + return loc; + } + + /** + * Original Utilities + * written by kazuya kawaguchi + */ + const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g; + /* eslint-disable */ + function format(message, ...args) { + if (args.length === 1 && isObject(args[0])) { + args = args[0]; + } + if (!args || !args.hasOwnProperty) { + args = {}; + } + return message.replace(RE_ARGS, (match, identifier) => { + return args.hasOwnProperty(identifier) ? args[identifier] : ''; + }); + } + const assign = Object.assign; + const isString = (val) => typeof val === 'string'; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const isObject = (val) => val !== null && typeof val === 'object'; + function join(items, separator = '') { + return items.reduce((str, item, index) => (index === 0 ? str + item : str + separator + item), ''); + } + + const CompileWarnCodes = { + USE_MODULO_SYNTAX: 1, + __EXTEND_POINT__: 2 + }; + /** @internal */ + const warnMessages = { + [CompileWarnCodes.USE_MODULO_SYNTAX]: `Use modulo before '{{0}}'.` + }; + function createCompileWarn(code, loc, ...args) { + const msg = format(warnMessages[code] || '', ...(args || [])) ; + const message = { message: String(msg), code }; + if (loc) { + message.location = loc; + } + return message; + } + + const CompileErrorCodes = { + // tokenizer error codes + EXPECTED_TOKEN: 1, + INVALID_TOKEN_IN_PLACEHOLDER: 2, + UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3, + UNKNOWN_ESCAPE_SEQUENCE: 4, + INVALID_UNICODE_ESCAPE_SEQUENCE: 5, + UNBALANCED_CLOSING_BRACE: 6, + UNTERMINATED_CLOSING_BRACE: 7, + EMPTY_PLACEHOLDER: 8, + NOT_ALLOW_NEST_PLACEHOLDER: 9, + INVALID_LINKED_FORMAT: 10, + // parser error codes + MUST_HAVE_MESSAGES_IN_PLURAL: 11, + UNEXPECTED_EMPTY_LINKED_MODIFIER: 12, + UNEXPECTED_EMPTY_LINKED_KEY: 13, + UNEXPECTED_LEXICAL_ANALYSIS: 14, + // generator error codes + UNHANDLED_CODEGEN_NODE_TYPE: 15, + // minifier error codes + UNHANDLED_MINIFIER_NODE_TYPE: 16, + // Special value for higher-order compilers to pick up the last code + // to avoid collision of error codes. This should always be kept as the last + // item. + __EXTEND_POINT__: 17 + }; + /** @internal */ + const errorMessages = { + // tokenizer error messages + [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`, + [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`, + [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`, + [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`, + [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`, + [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`, + [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`, + [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`, + [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`, + [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`, + // parser error messages + [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`, + [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`, + // generator error messages + [CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`, + // minimizer error messages + [CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'` + }; + function createCompileError(code, loc, options = {}) { + const { domain, messages, args } = options; + const msg = format((messages || errorMessages)[code] || '', ...(args || [])) + ; + const error = new SyntaxError(String(msg)); + error.code = code; + if (loc) { + error.location = loc; + } + error.domain = domain; + return error; + } + /** @internal */ + function defaultOnError(error) { + throw error; + } + + // eslint-disable-next-line no-useless-escape + const RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/; + const detectHtmlTag = (source) => RE_HTML_TAG.test(source); + + const CHAR_SP = ' '; + const CHAR_CR = '\r'; + const CHAR_LF = '\n'; + const CHAR_LS = String.fromCharCode(0x2028); + const CHAR_PS = String.fromCharCode(0x2029); + function createScanner(str) { + const _buf = str; + let _index = 0; + let _line = 1; + let _column = 1; + let _peekOffset = 0; + const isCRLF = (index) => _buf[index] === CHAR_CR && _buf[index + 1] === CHAR_LF; + const isLF = (index) => _buf[index] === CHAR_LF; + const isPS = (index) => _buf[index] === CHAR_PS; + const isLS = (index) => _buf[index] === CHAR_LS; + const isLineEnd = (index) => isCRLF(index) || isLF(index) || isPS(index) || isLS(index); + const index = () => _index; + const line = () => _line; + const column = () => _column; + const peekOffset = () => _peekOffset; + const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset]; + const currentChar = () => charAt(_index); + const currentPeek = () => charAt(_index + _peekOffset); + function next() { + _peekOffset = 0; + if (isLineEnd(_index)) { + _line++; + _column = 0; + } + if (isCRLF(_index)) { + _index++; + } + _index++; + _column++; + return _buf[_index]; + } + function peek() { + if (isCRLF(_index + _peekOffset)) { + _peekOffset++; + } + _peekOffset++; + return _buf[_index + _peekOffset]; + } + function reset() { + _index = 0; + _line = 1; + _column = 1; + _peekOffset = 0; + } + function resetPeek(offset = 0) { + _peekOffset = offset; + } + function skipToPeek() { + const target = _index + _peekOffset; + // eslint-disable-next-line no-unmodified-loop-condition + while (target !== _index) { + next(); + } + _peekOffset = 0; + } + return { + index, + line, + column, + peekOffset, + charAt, + currentChar, + currentPeek, + next, + peek, + reset, + resetPeek, + skipToPeek + }; + } + + const EOF = undefined; + const DOT = '.'; + const LITERAL_DELIMITER = "'"; + const ERROR_DOMAIN$3 = 'tokenizer'; + function createTokenizer(source, options = {}) { + const location = options.location !== false; + const _scnr = createScanner(source); + const currentOffset = () => _scnr.index(); + const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index()); + const _initLoc = currentPosition(); + const _initOffset = currentOffset(); + const _context = { + currentType: 14 /* TokenTypes.EOF */, + offset: _initOffset, + startLoc: _initLoc, + endLoc: _initLoc, + lastType: 14 /* TokenTypes.EOF */, + lastOffset: _initOffset, + lastStartLoc: _initLoc, + lastEndLoc: _initLoc, + braceNest: 0, + inLinked: false, + text: '' + }; + const context = () => _context; + const { onError } = options; + function emitError(code, pos, offset, ...args) { + const ctx = context(); + pos.column += offset; + pos.offset += offset; + if (onError) { + const loc = location ? createLocation(ctx.startLoc, pos) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$3, + args + }); + onError(err); + } + } + function getToken(context, type, value) { + context.endLoc = currentPosition(); + context.currentType = type; + const token = { type }; + if (location) { + token.loc = createLocation(context.startLoc, context.endLoc); + } + if (value != null) { + token.value = value; + } + return token; + } + const getEndToken = (context) => getToken(context, 14 /* TokenTypes.EOF */); + function eat(scnr, ch) { + if (scnr.currentChar() === ch) { + scnr.next(); + return ch; + } + else { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + return ''; + } + } + function peekSpaces(scnr) { + let buf = ''; + while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) { + buf += scnr.currentPeek(); + scnr.peek(); + } + return buf; + } + function skipSpaces(scnr) { + const buf = peekSpaces(scnr); + scnr.skipToPeek(); + return buf; + } + function isIdentifierStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + cc === 95 // _ + ); + } + function isNumberStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function isNamedIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isListIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ch = scnr.currentPeek() === '-' ? scnr.peek() : scnr.currentPeek(); + const ret = isNumberStart(ch); + scnr.resetPeek(); + return ret; + } + function isLiteralStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === LITERAL_DELIMITER; + scnr.resetPeek(); + return ret; + } + function isLinkedDotStart(scnr, context) { + const { currentType } = context; + if (currentType !== 8 /* TokenTypes.LinkedAlias */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === "." /* TokenChars.LinkedDot */; + scnr.resetPeek(); + return ret; + } + function isLinkedModifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 9 /* TokenTypes.LinkedDot */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isLinkedDelimiterStart(scnr, context) { + const { currentType } = context; + if (!(currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 12 /* TokenTypes.LinkedModifier */)) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === ":" /* TokenChars.LinkedDelimiter */; + scnr.resetPeek(); + return ret; + } + function isLinkedReferStart(scnr, context) { + const { currentType } = context; + if (currentType !== 10 /* TokenTypes.LinkedDelimiter */) { + return false; + } + const fn = () => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return isIdentifierStart(scnr.peek()); + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "|" /* TokenChars.Pipe */ || + ch === ":" /* TokenChars.LinkedDelimiter */ || + ch === "." /* TokenChars.LinkedDot */ || + ch === CHAR_SP || + !ch) { + return false; + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(); + } + else { + // other characters + return isTextStart(scnr, false); + } + }; + const ret = fn(); + scnr.resetPeek(); + return ret; + } + function isPluralStart(scnr) { + peekSpaces(scnr); + const ret = scnr.currentPeek() === "|" /* TokenChars.Pipe */; + scnr.resetPeek(); + return ret; + } + function detectModuloStart(scnr) { + const spaces = peekSpaces(scnr); + const ret = scnr.currentPeek() === "%" /* TokenChars.Modulo */ && + scnr.peek() === "{" /* TokenChars.BraceLeft */; + scnr.resetPeek(); + return { + isModulo: ret, + hasSpace: spaces.length > 0 + }; + } + function isTextStart(scnr, reset = true) { + const fn = (hasSpace = false, prev = '', detectModulo = false) => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return prev === "%" /* TokenChars.Modulo */ ? false : hasSpace; + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || !ch) { + return prev === "%" /* TokenChars.Modulo */ ? true : hasSpace; + } + else if (ch === "%" /* TokenChars.Modulo */) { + scnr.peek(); + return fn(hasSpace, "%" /* TokenChars.Modulo */, true); + } + else if (ch === "|" /* TokenChars.Pipe */) { + return prev === "%" /* TokenChars.Modulo */ || detectModulo + ? true + : !(prev === CHAR_SP || prev === CHAR_LF); + } + else if (ch === CHAR_SP) { + scnr.peek(); + return fn(true, CHAR_SP, detectModulo); + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(true, CHAR_LF, detectModulo); + } + else { + return true; + } + }; + const ret = fn(); + reset && scnr.resetPeek(); + return ret; + } + function takeChar(scnr, fn) { + const ch = scnr.currentChar(); + if (ch === EOF) { + return EOF; + } + if (fn(ch)) { + scnr.next(); + return ch; + } + return null; + } + function isIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 // $ + ); + } + function takeIdentifierChar(scnr) { + return takeChar(scnr, isIdentifier); + } + function isNamedIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 || // $ + cc === 45 // - + ); + } + function takeNamedIdentifierChar(scnr) { + return takeChar(scnr, isNamedIdentifier); + } + function isDigit(ch) { + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function takeDigit(scnr) { + return takeChar(scnr, isDigit); + } + function isHexDigit(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 48 && cc <= 57) || // 0-9 + (cc >= 65 && cc <= 70) || // A-F + (cc >= 97 && cc <= 102)); // a-f + } + function takeHexDigit(scnr) { + return takeChar(scnr, isHexDigit); + } + function getDigits(scnr) { + let ch = ''; + let num = ''; + while ((ch = takeDigit(scnr))) { + num += ch; + } + return num; + } + function readModulo(scnr) { + skipSpaces(scnr); + const ch = scnr.currentChar(); + if (ch !== "%" /* TokenChars.Modulo */) { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + } + scnr.next(); + return "%" /* TokenChars.Modulo */; + } + function readText(scnr) { + let buf = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "}" /* TokenChars.BraceRight */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + !ch) { + break; + } + else if (ch === "%" /* TokenChars.Modulo */) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else { + break; + } + } + else if (ch === CHAR_SP || ch === CHAR_LF) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else if (isPluralStart(scnr)) { + break; + } + else { + buf += ch; + scnr.next(); + } + } + else { + buf += ch; + scnr.next(); + } + } + return buf; + } + function readNamedIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let name = ''; + while ((ch = takeNamedIdentifierChar(scnr))) { + name += ch; + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return name; + } + function readListIdentifier(scnr) { + skipSpaces(scnr); + let value = ''; + if (scnr.currentChar() === '-') { + scnr.next(); + value += `-${getDigits(scnr)}`; + } + else { + value += getDigits(scnr); + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return value; + } + function isLiteral(ch) { + return ch !== LITERAL_DELIMITER && ch !== CHAR_LF; + } + function readLiteral(scnr) { + skipSpaces(scnr); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + let ch = ''; + let literal = ''; + while ((ch = takeChar(scnr, isLiteral))) { + if (ch === '\\') { + literal += readEscapeSequence(scnr); + } + else { + literal += ch; + } + } + const current = scnr.currentChar(); + if (current === CHAR_LF || current === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, currentPosition(), 0); + // TODO: Is it correct really? + if (current === CHAR_LF) { + scnr.next(); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + } + return literal; + } + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + return literal; + } + function readEscapeSequence(scnr) { + const ch = scnr.currentChar(); + switch (ch) { + case '\\': + case `\'`: // eslint-disable-line no-useless-escape + scnr.next(); + return `\\${ch}`; + case 'u': + return readUnicodeEscapeSequence(scnr, ch, 4); + case 'U': + return readUnicodeEscapeSequence(scnr, ch, 6); + default: + emitError(CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, currentPosition(), 0, ch); + return ''; + } + } + function readUnicodeEscapeSequence(scnr, unicode, digits) { + eat(scnr, unicode); + let sequence = ''; + for (let i = 0; i < digits; i++) { + const ch = takeHexDigit(scnr); + if (!ch) { + emitError(CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`); + break; + } + sequence += ch; + } + return `\\${unicode}${sequence}`; + } + function isInvalidIdentifier(ch) { + return (ch !== "{" /* TokenChars.BraceLeft */ && + ch !== "}" /* TokenChars.BraceRight */ && + ch !== CHAR_SP && + ch !== CHAR_LF); + } + function readInvalidIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let identifiers = ''; + while ((ch = takeChar(scnr, isInvalidIdentifier))) { + identifiers += ch; + } + return identifiers; + } + function readLinkedModifier(scnr) { + let ch = ''; + let name = ''; + while ((ch = takeIdentifierChar(scnr))) { + name += ch; + } + return name; + } + function readLinkedRefer(scnr) { + const fn = (buf) => { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + ch === "(" /* TokenChars.ParenLeft */ || + ch === ")" /* TokenChars.ParenRight */ || + !ch) { + return buf; + } + else if (ch === CHAR_SP) { + return buf; + } + else if (ch === CHAR_LF || ch === DOT) { + buf += ch; + scnr.next(); + return fn(buf); + } + else { + buf += ch; + scnr.next(); + return fn(buf); + } + }; + return fn(''); + } + function readPlural(scnr) { + skipSpaces(scnr); + const plural = eat(scnr, "|" /* TokenChars.Pipe */); + skipSpaces(scnr); + return plural; + } + // TODO: We need refactoring of token parsing ... + function readTokenInPlaceholder(scnr, context) { + let token = null; + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + if (context.braceNest >= 1) { + emitError(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 2 /* TokenTypes.BraceLeft */, "{" /* TokenChars.BraceLeft */); + skipSpaces(scnr); + context.braceNest++; + return token; + case "}" /* TokenChars.BraceRight */: + if (context.braceNest > 0 && + context.currentType === 2 /* TokenTypes.BraceLeft */) { + emitError(CompileErrorCodes.EMPTY_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + context.braceNest--; + context.braceNest > 0 && skipSpaces(scnr); + if (context.inLinked && context.braceNest === 0) { + context.inLinked = false; + } + return token; + case "@" /* TokenChars.LinkedAlias */: + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = readTokenInLinked(scnr, context) || getEndToken(context); + context.braceNest = 0; + return token; + default: { + let validNamedIdentifier = true; + let validListIdentifier = true; + let validLiteral = true; + if (isPluralStart(scnr)) { + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (context.braceNest > 0 && + (context.currentType === 5 /* TokenTypes.Named */ || + context.currentType === 6 /* TokenTypes.List */ || + context.currentType === 7 /* TokenTypes.Literal */)) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + context.braceNest = 0; + return readToken(scnr, context); + } + if ((validNamedIdentifier = isNamedIdentifierStart(scnr, context))) { + token = getToken(context, 5 /* TokenTypes.Named */, readNamedIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validListIdentifier = isListIdentifierStart(scnr, context))) { + token = getToken(context, 6 /* TokenTypes.List */, readListIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validLiteral = isLiteralStart(scnr, context))) { + token = getToken(context, 7 /* TokenTypes.Literal */, readLiteral(scnr)); + skipSpaces(scnr); + return token; + } + if (!validNamedIdentifier && !validListIdentifier && !validLiteral) { + // TODO: we should be re-designed invalid cases, when we will extend message syntax near the future ... + token = getToken(context, 13 /* TokenTypes.InvalidPlace */, readInvalidIdentifier(scnr)); + emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value); + skipSpaces(scnr); + return token; + } + break; + } + } + return token; + } + // TODO: We need refactoring of token parsing ... + function readTokenInLinked(scnr, context) { + const { currentType } = context; + let token = null; + const ch = scnr.currentChar(); + if ((currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 9 /* TokenTypes.LinkedDot */ || + currentType === 12 /* TokenTypes.LinkedModifier */ || + currentType === 10 /* TokenTypes.LinkedDelimiter */) && + (ch === CHAR_LF || ch === CHAR_SP)) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + switch (ch) { + case "@" /* TokenChars.LinkedAlias */: + scnr.next(); + token = getToken(context, 8 /* TokenTypes.LinkedAlias */, "@" /* TokenChars.LinkedAlias */); + context.inLinked = true; + return token; + case "." /* TokenChars.LinkedDot */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 9 /* TokenTypes.LinkedDot */, "." /* TokenChars.LinkedDot */); + case ":" /* TokenChars.LinkedDelimiter */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 10 /* TokenTypes.LinkedDelimiter */, ":" /* TokenChars.LinkedDelimiter */); + default: + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (isLinkedDotStart(scnr, context) || + isLinkedDelimiterStart(scnr, context)) { + skipSpaces(scnr); + return readTokenInLinked(scnr, context); + } + if (isLinkedModifierStart(scnr, context)) { + skipSpaces(scnr); + return getToken(context, 12 /* TokenTypes.LinkedModifier */, readLinkedModifier(scnr)); + } + if (isLinkedReferStart(scnr, context)) { + skipSpaces(scnr); + if (ch === "{" /* TokenChars.BraceLeft */) { + // scan the placeholder + return readTokenInPlaceholder(scnr, context) || token; + } + else { + return getToken(context, 11 /* TokenTypes.LinkedKey */, readLinkedRefer(scnr)); + } + } + if (currentType === 8 /* TokenTypes.LinkedAlias */) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + context.braceNest = 0; + context.inLinked = false; + return readToken(scnr, context); + } + } + // TODO: We need refactoring of token parsing ... + function readToken(scnr, context) { + let token = { type: 14 /* TokenTypes.EOF */ }; + if (context.braceNest > 0) { + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + } + if (context.inLinked) { + return readTokenInLinked(scnr, context) || getEndToken(context); + } + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + case "}" /* TokenChars.BraceRight */: + emitError(CompileErrorCodes.UNBALANCED_CLOSING_BRACE, currentPosition(), 0); + scnr.next(); + return getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + case "@" /* TokenChars.LinkedAlias */: + return readTokenInLinked(scnr, context) || getEndToken(context); + default: { + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + const { isModulo, hasSpace } = detectModuloStart(scnr); + if (isModulo) { + return hasSpace + ? getToken(context, 0 /* TokenTypes.Text */, readText(scnr)) + : getToken(context, 4 /* TokenTypes.Modulo */, readModulo(scnr)); + } + if (isTextStart(scnr)) { + return getToken(context, 0 /* TokenTypes.Text */, readText(scnr)); + } + break; + } + } + return token; + } + function nextToken() { + const { currentType, offset, startLoc, endLoc } = _context; + _context.lastType = currentType; + _context.lastOffset = offset; + _context.lastStartLoc = startLoc; + _context.lastEndLoc = endLoc; + _context.offset = currentOffset(); + _context.startLoc = currentPosition(); + if (_scnr.currentChar() === EOF) { + return getToken(_context, 14 /* TokenTypes.EOF */); + } + return readToken(_scnr, _context); + } + return { + nextToken, + currentOffset, + currentPosition, + context + }; + } + + const ERROR_DOMAIN$2 = 'parser'; + // Backslash backslash, backslash quote, uHHHH, UHHHHHH. + const KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g; + function fromEscapeSequence(match, codePoint4, codePoint6) { + switch (match) { + case `\\\\`: + return `\\`; + // eslint-disable-next-line no-useless-escape + case `\\\'`: + // eslint-disable-next-line no-useless-escape + return `\'`; + default: { + const codePoint = parseInt(codePoint4 || codePoint6, 16); + if (codePoint <= 0xd7ff || codePoint >= 0xe000) { + return String.fromCodePoint(codePoint); + } + // invalid ... + // Replace them with U+FFFD REPLACEMENT CHARACTER. + return '�'; + } + } + } + function createParser(options = {}) { + const location = options.location !== false; + const { onError, onWarn } = options; + function emitError(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onError) { + const loc = location ? createLocation(start, end) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$2, + args + }); + onError(err); + } + } + function emitWarn(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onWarn) { + const loc = location ? createLocation(start, end) : null; + onWarn(createCompileWarn(code, loc, args)); + } + } + function startNode(type, offset, loc) { + const node = { type }; + if (location) { + node.start = offset; + node.end = offset; + node.loc = { start: loc, end: loc }; + } + return node; + } + function endNode(node, offset, pos, type) { + if (type) { + node.type = type; + } + if (location) { + node.end = offset; + if (node.loc) { + node.loc.end = pos; + } + } + } + function parseText(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(3 /* NodeTypes.Text */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseList(tokenizer, index) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(5 /* NodeTypes.List */, offset, loc); + node.index = parseInt(index, 10); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseNamed(tokenizer, key, modulo) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(4 /* NodeTypes.Named */, offset, loc); + node.key = key; + if (modulo === true) { + node.modulo = true; + } + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLiteral(tokenizer, value) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(9 /* NodeTypes.Literal */, offset, loc); + node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinkedModifier(tokenizer) { + const token = tokenizer.nextToken(); + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get linked dot loc + const node = startNode(8 /* NodeTypes.LinkedModifier */, offset, loc); + if (token.type !== 12 /* TokenTypes.LinkedModifier */) { + // empty modifier + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0); + node.value = ''; + endNode(node, offset, loc); + return { + nextConsumeToken: token, + node + }; + } + // check token + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.value = token.value || ''; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node + }; + } + function parseLinkedKey(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(7 /* NodeTypes.LinkedKey */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinked(tokenizer) { + const context = tokenizer.context(); + const linkedNode = startNode(6 /* NodeTypes.Linked */, context.offset, context.startLoc); + let token = tokenizer.nextToken(); + if (token.type === 9 /* TokenTypes.LinkedDot */) { + const parsed = parseLinkedModifier(tokenizer); + linkedNode.modifier = parsed.node; + token = parsed.nextConsumeToken || tokenizer.nextToken(); + } + // asset check token + if (token.type !== 10 /* TokenTypes.LinkedDelimiter */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + token = tokenizer.nextToken(); + // skip brace left + if (token.type === 2 /* TokenTypes.BraceLeft */) { + token = tokenizer.nextToken(); + } + switch (token.type) { + case 11 /* TokenTypes.LinkedKey */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseNamed(tokenizer, token.value || ''); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseList(tokenizer, token.value || ''); + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLiteral(tokenizer, token.value || ''); + break; + default: { + // empty key + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0); + const nextContext = tokenizer.context(); + const emptyLinkedKeyNode = startNode(7 /* NodeTypes.LinkedKey */, nextContext.offset, nextContext.startLoc); + emptyLinkedKeyNode.value = ''; + endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc); + linkedNode.key = emptyLinkedKeyNode; + endNode(linkedNode, nextContext.offset, nextContext.startLoc); + return { + nextConsumeToken: token, + node: linkedNode + }; + } + } + endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node: linkedNode + }; + } + function parseMessage(tokenizer) { + const context = tokenizer.context(); + const startOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? tokenizer.currentOffset() + : context.offset; + const startLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.endLoc + : context.startLoc; + const node = startNode(2 /* NodeTypes.Message */, startOffset, startLoc); + node.items = []; + let nextToken = null; + let modulo = null; + do { + const token = nextToken || tokenizer.nextToken(); + nextToken = null; + switch (token.type) { + case 0 /* TokenTypes.Text */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseText(tokenizer, token.value || '')); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseList(tokenizer, token.value || '')); + break; + case 4 /* TokenTypes.Modulo */: + modulo = true; + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseNamed(tokenizer, token.value || '', !!modulo)); + if (modulo) { + emitWarn(tokenizer, CompileWarnCodes.USE_MODULO_SYNTAX, context.lastStartLoc, 0, getTokenCaption(token)); + modulo = null; + } + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseLiteral(tokenizer, token.value || '')); + break; + case 8 /* TokenTypes.LinkedAlias */: { + const parsed = parseLinked(tokenizer); + node.items.push(parsed.node); + nextToken = parsed.nextConsumeToken || null; + break; + } + } + } while (context.currentType !== 14 /* TokenTypes.EOF */ && + context.currentType !== 1 /* TokenTypes.Pipe */); + // adjust message node loc + const endOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastOffset + : tokenizer.currentOffset(); + const endLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastEndLoc + : tokenizer.currentPosition(); + endNode(node, endOffset, endLoc); + return node; + } + function parsePlural(tokenizer, offset, loc, msgNode) { + const context = tokenizer.context(); + let hasEmptyMessage = msgNode.items.length === 0; + const node = startNode(1 /* NodeTypes.Plural */, offset, loc); + node.cases = []; + node.cases.push(msgNode); + do { + const msg = parseMessage(tokenizer); + if (!hasEmptyMessage) { + hasEmptyMessage = msg.items.length === 0; + } + node.cases.push(msg); + } while (context.currentType !== 14 /* TokenTypes.EOF */); + if (hasEmptyMessage) { + emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseResource(tokenizer) { + const context = tokenizer.context(); + const { offset, startLoc } = context; + const msgNode = parseMessage(tokenizer); + if (context.currentType === 14 /* TokenTypes.EOF */) { + return msgNode; + } + else { + return parsePlural(tokenizer, offset, startLoc, msgNode); + } + } + function parse(source) { + const tokenizer = createTokenizer(source, assign({}, options)); + const context = tokenizer.context(); + const node = startNode(0 /* NodeTypes.Resource */, context.offset, context.startLoc); + if (location && node.loc) { + node.loc.source = source; + } + node.body = parseResource(tokenizer); + if (options.onCacheKey) { + node.cacheKey = options.onCacheKey(source); + } + // assert whether achieved to EOF + if (context.currentType !== 14 /* TokenTypes.EOF */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || ''); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + return { parse }; + } + function getTokenCaption(token) { + if (token.type === 14 /* TokenTypes.EOF */) { + return 'EOF'; + } + const name = (token.value || '').replace(/\r?\n/gu, '\\n'); + return name.length > 10 ? name.slice(0, 9) + '…' : name; + } + + function createTransformer(ast, options = {} // eslint-disable-line + ) { + const _context = { + ast, + helpers: new Set() + }; + const context = () => _context; + const helper = (name) => { + _context.helpers.add(name); + return name; + }; + return { context, helper }; + } + function traverseNodes(nodes, transformer) { + for (let i = 0; i < nodes.length; i++) { + traverseNode(nodes[i], transformer); + } + } + function traverseNode(node, transformer) { + // TODO: if we need pre-hook of transform, should be implemented to here + switch (node.type) { + case 1 /* NodeTypes.Plural */: + traverseNodes(node.cases, transformer); + transformer.helper("plural" /* HelperNameMap.PLURAL */); + break; + case 2 /* NodeTypes.Message */: + traverseNodes(node.items, transformer); + break; + case 6 /* NodeTypes.Linked */: { + const linked = node; + traverseNode(linked.key, transformer); + transformer.helper("linked" /* HelperNameMap.LINKED */); + transformer.helper("type" /* HelperNameMap.TYPE */); + break; + } + case 5 /* NodeTypes.List */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("list" /* HelperNameMap.LIST */); + break; + case 4 /* NodeTypes.Named */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("named" /* HelperNameMap.NAMED */); + break; + } + // TODO: if we need post-hook of transform, should be implemented to here + } + // transform AST + function transform(ast, options = {} // eslint-disable-line + ) { + const transformer = createTransformer(ast); + transformer.helper("normalize" /* HelperNameMap.NORMALIZE */); + // traverse + ast.body && traverseNode(ast.body, transformer); + // set meta information + const context = transformer.context(); + ast.helpers = Array.from(context.helpers); + } + + function optimize(ast) { + const body = ast.body; + if (body.type === 2 /* NodeTypes.Message */) { + optimizeMessageNode(body); + } + else { + body.cases.forEach(c => optimizeMessageNode(c)); + } + return ast; + } + function optimizeMessageNode(message) { + if (message.items.length === 1) { + const item = message.items[0]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + message.static = item.value; + delete item.value; // optimization for size + } + } + else { + const values = []; + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (!(item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */)) { + break; + } + if (item.value == null) { + break; + } + values.push(item.value); + } + if (values.length === message.items.length) { + message.static = join(values); + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + delete item.value; // optimization for size + } + } + } + } + } + + const ERROR_DOMAIN$1 = 'minifier'; + /* eslint-disable @typescript-eslint/no-explicit-any */ + function minify(node) { + node.t = node.type; + switch (node.type) { + case 0 /* NodeTypes.Resource */: { + const resource = node; + minify(resource.body); + resource.b = resource.body; + delete resource.body; + break; + } + case 1 /* NodeTypes.Plural */: { + const plural = node; + const cases = plural.cases; + for (let i = 0; i < cases.length; i++) { + minify(cases[i]); + } + plural.c = cases; + delete plural.cases; + break; + } + case 2 /* NodeTypes.Message */: { + const message = node; + const items = message.items; + for (let i = 0; i < items.length; i++) { + minify(items[i]); + } + message.i = items; + delete message.items; + if (message.static) { + message.s = message.static; + delete message.static; + } + break; + } + case 3 /* NodeTypes.Text */: + case 9 /* NodeTypes.Literal */: + case 8 /* NodeTypes.LinkedModifier */: + case 7 /* NodeTypes.LinkedKey */: { + const valueNode = node; + if (valueNode.value) { + valueNode.v = valueNode.value; + delete valueNode.value; + } + break; + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + minify(linked.key); + linked.k = linked.key; + delete linked.key; + if (linked.modifier) { + minify(linked.modifier); + linked.m = linked.modifier; + delete linked.modifier; + } + break; + } + case 5 /* NodeTypes.List */: { + const list = node; + list.i = list.index; + delete list.index; + break; + } + case 4 /* NodeTypes.Named */: { + const named = node; + named.k = named.key; + delete named.key; + break; + } + default: + { + throw createCompileError(CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE, null, { + domain: ERROR_DOMAIN$1, + args: [node.type] + }); + } + } + delete node.type; + } + /* eslint-enable @typescript-eslint/no-explicit-any */ + + // eslint-disable-next-line @typescript-eslint/triple-slash-reference + /// + const ERROR_DOMAIN = 'parser'; + function createCodeGenerator(ast, options) { + const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options; + const location = options.location !== false; + const _context = { + filename, + code: '', + column: 1, + line: 1, + offset: 0, + map: undefined, + breakLineCode, + needIndent: _needIndent, + indentLevel: 0 + }; + if (location && ast.loc) { + _context.source = ast.loc.source; + } + const context = () => _context; + function push(code, node) { + _context.code += code; + } + function _newline(n, withBreakLine = true) { + const _breakLineCode = withBreakLine ? breakLineCode : ''; + push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode); + } + function indent(withNewLine = true) { + const level = ++_context.indentLevel; + withNewLine && _newline(level); + } + function deindent(withNewLine = true) { + const level = --_context.indentLevel; + withNewLine && _newline(level); + } + function newline() { + _newline(_context.indentLevel); + } + const helper = (key) => `_${key}`; + const needIndent = () => _context.needIndent; + return { + context, + push, + indent, + deindent, + newline, + helper, + needIndent + }; + } + function generateLinkedNode(generator, node) { + const { helper } = generator; + generator.push(`${helper("linked" /* HelperNameMap.LINKED */)}(`); + generateNode(generator, node.key); + if (node.modifier) { + generator.push(`, `); + generateNode(generator, node.modifier); + generator.push(`, _type`); + } + else { + generator.push(`, undefined, _type`); + } + generator.push(`)`); + } + function generateMessageNode(generator, node) { + const { helper, needIndent } = generator; + generator.push(`${helper("normalize" /* HelperNameMap.NORMALIZE */)}([`); + generator.indent(needIndent()); + const length = node.items.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.items[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push('])'); + } + function generatePluralNode(generator, node) { + const { helper, needIndent } = generator; + if (node.cases.length > 1) { + generator.push(`${helper("plural" /* HelperNameMap.PLURAL */)}([`); + generator.indent(needIndent()); + const length = node.cases.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.cases[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push(`])`); + } + } + function generateResource(generator, node) { + if (node.body) { + generateNode(generator, node.body); + } + else { + generator.push('null'); + } + } + function generateNode(generator, node) { + const { helper } = generator; + switch (node.type) { + case 0 /* NodeTypes.Resource */: + generateResource(generator, node); + break; + case 1 /* NodeTypes.Plural */: + generatePluralNode(generator, node); + break; + case 2 /* NodeTypes.Message */: + generateMessageNode(generator, node); + break; + case 6 /* NodeTypes.Linked */: + generateLinkedNode(generator, node); + break; + case 8 /* NodeTypes.LinkedModifier */: + generator.push(JSON.stringify(node.value), node); + break; + case 7 /* NodeTypes.LinkedKey */: + generator.push(JSON.stringify(node.value), node); + break; + case 5 /* NodeTypes.List */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("list" /* HelperNameMap.LIST */)}(${node.index}))`, node); + break; + case 4 /* NodeTypes.Named */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("named" /* HelperNameMap.NAMED */)}(${JSON.stringify(node.key)}))`, node); + break; + case 9 /* NodeTypes.Literal */: + generator.push(JSON.stringify(node.value), node); + break; + case 3 /* NodeTypes.Text */: + generator.push(JSON.stringify(node.value), node); + break; + default: + { + throw createCompileError(CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE, null, { + domain: ERROR_DOMAIN, + args: [node.type] + }); + } + } + } + // generate code from AST + const generate = (ast, options = {} // eslint-disable-line + ) => { + const mode = isString(options.mode) ? options.mode : 'normal'; + const filename = isString(options.filename) + ? options.filename + : 'message.intl'; + const sourceMap = !!options.sourceMap; + // prettier-ignore + const breakLineCode = options.breakLineCode != null + ? options.breakLineCode + : mode === 'arrow' + ? ';' + : '\n'; + const needIndent = options.needIndent ? options.needIndent : mode !== 'arrow'; + const helpers = ast.helpers || []; + const generator = createCodeGenerator(ast, { + mode, + filename, + sourceMap, + breakLineCode, + needIndent + }); + generator.push(mode === 'normal' ? `function __msg__ (ctx) {` : `(ctx) => {`); + generator.indent(needIndent); + if (helpers.length > 0) { + generator.push(`const { ${join(helpers.map(s => `${s}: _${s}`), ', ')} } = ctx`); + generator.newline(); + } + generator.push(`return `); + generateNode(generator, ast); + generator.deindent(needIndent); + generator.push(`}`); + delete ast.helpers; + const { code, map } = generator.context(); + return { + ast, + code, + map: map ? map.toJSON() : undefined // eslint-disable-line @typescript-eslint/no-explicit-any + }; + }; + + function baseCompile(source, options = {}) { + const assignedOptions = assign({}, options); + const jit = !!assignedOptions.jit; + const enalbeMinify = !!assignedOptions.minify; + const enambeOptimize = assignedOptions.optimize == null ? true : assignedOptions.optimize; + // parse source codes + const parser = createParser(assignedOptions); + const ast = parser.parse(source); + if (!jit) { + // transform ASTs + transform(ast, assignedOptions); + // generate javascript codes + return generate(ast, assignedOptions); + } + else { + // optimize ASTs + enambeOptimize && optimize(ast); + // minimize ASTs + enalbeMinify && minify(ast); + // In JIT mode, no ast transform, no code generation. + return { ast, code: '' }; + } + } + + exports.CompileErrorCodes = CompileErrorCodes; + exports.CompileWarnCodes = CompileWarnCodes; + exports.ERROR_DOMAIN = ERROR_DOMAIN$2; + exports.LOCATION_STUB = LOCATION_STUB; + exports.baseCompile = baseCompile; + exports.createCompileError = createCompileError; + exports.createCompileWarn = createCompileWarn; + exports.createLocation = createLocation; + exports.createParser = createParser; + exports.createPosition = createPosition; + exports.defaultOnError = defaultOnError; + exports.detectHtmlTag = detectHtmlTag; + exports.errorMessages = errorMessages; + exports.warnMessages = warnMessages; + + return exports; + +})({}); diff --git a/node_modules/@intlify/message-compiler/dist/message-compiler.global.prod.js b/node_modules/@intlify/message-compiler/dist/message-compiler.global.prod.js new file mode 100644 index 0000000..f4bdcce --- /dev/null +++ b/node_modules/@intlify/message-compiler/dist/message-compiler.global.prod.js @@ -0,0 +1,6 @@ +/*! + * message-compiler v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +var IntlifyMessageCompiler=function(e){"use strict";function t(e,t,n){return{line:e,column:t,offset:n}}function n(e,t,n){const r={start:e,end:t};return null!=n&&(r.source=n),r}const r=Object.assign,c=e=>"string"==typeof e;function o(e,t=""){return e.reduce(((e,n,r)=>0===r?e+n:e+t+n),"")}const s={USE_MODULO_SYNTAX:1,__EXTEND_POINT__:2},u={[s.USE_MODULO_SYNTAX]:"Use modulo before '{{0}}'."};function a(e,t,...n){const r={message:String(e),code:e};return t&&(r.location=t),r}const i={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16,__EXTEND_POINT__:17},l={[i.EXPECTED_TOKEN]:"Expected token: '{0}'",[i.INVALID_TOKEN_IN_PLACEHOLDER]:"Invalid token in placeholder: '{0}'",[i.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]:"Unterminated single quote in placeholder",[i.UNKNOWN_ESCAPE_SEQUENCE]:"Unknown escape sequence: \\{0}",[i.INVALID_UNICODE_ESCAPE_SEQUENCE]:"Invalid unicode escape sequence: {0}",[i.UNBALANCED_CLOSING_BRACE]:"Unbalanced closing brace",[i.UNTERMINATED_CLOSING_BRACE]:"Unterminated closing brace",[i.EMPTY_PLACEHOLDER]:"Empty placeholder",[i.NOT_ALLOW_NEST_PLACEHOLDER]:"Not allowed nest placeholder",[i.INVALID_LINKED_FORMAT]:"Invalid linked format",[i.MUST_HAVE_MESSAGES_IN_PLURAL]:"Plural must have messages",[i.UNEXPECTED_EMPTY_LINKED_MODIFIER]:"Unexpected empty linked modifier",[i.UNEXPECTED_EMPTY_LINKED_KEY]:"Unexpected empty linked key",[i.UNEXPECTED_LEXICAL_ANALYSIS]:"Unexpected lexical analysis in token: '{0}'",[i.UNHANDLED_CODEGEN_NODE_TYPE]:"unhandled codegen node type: '{0}'",[i.UNHANDLED_MINIFIER_NODE_TYPE]:"unhandled mimifier node type: '{0}'"};function E(e,t,n={}){const{domain:r,messages:c,args:o}=n,s=new SyntaxError(String(e));return s.code=e,t&&(s.location=t),s.domain=r,s}const f=/<\/?[\w\s="/.':;#-\/]+>/,d=" ",L="\r",N="\n",_=String.fromCharCode(8232),p=String.fromCharCode(8233);function C(e){const t=e;let n=0,r=1,c=1,o=0;const s=e=>t[e]===L&&t[e+1]===N,u=e=>t[e]===p,a=e=>t[e]===_,i=e=>s(e)||(e=>t[e]===N)(e)||u(e)||a(e),l=e=>s(e)||u(e)||a(e)?N:t[e];function E(){return o=0,i(n)&&(r++,c=0),s(n)&&n++,n++,c++,t[n]}return{index:()=>n,line:()=>r,column:()=>c,peekOffset:()=>o,charAt:l,currentChar:()=>l(n),currentPeek:()=>l(n+o),next:E,peek:function(){return s(n+o)&&o++,o++,t[n+o]},reset:function(){n=0,r=1,c=1,o=0},resetPeek:function(e=0){o=e},skipToPeek:function(){const e=n+o;for(;e!==n;)E();o=0}}}const T=void 0,k="'";function A(e,r={}){const c=!1!==r.location,o=C(e),s=()=>o.index(),u=()=>t(o.line(),o.column(),o.index()),a=u(),l=s(),E={currentType:14,offset:l,startLoc:a,endLoc:a,lastType:14,lastOffset:l,lastStartLoc:a,lastEndLoc:a,braceNest:0,inLinked:!1,text:""},f=()=>E,{onError:L}=r;function _(e,t,r){e.endLoc=u(),e.currentType=t;const o={type:t};return c&&(o.loc=n(e.startLoc,e.endLoc)),null!=r&&(o.value=r),o}const p=e=>_(e,14);function A(e,t){return e.currentChar()===t?(e.next(),t):(i.EXPECTED_TOKEN,u(),"")}function I(e){let t="";for(;e.currentPeek()===d||e.currentPeek()===N;)t+=e.currentPeek(),e.peek();return t}function h(e){const t=I(e);return e.skipToPeek(),t}function S(e){if(e===T)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function P(e,t){const{currentType:n}=t;if(2!==n)return!1;I(e);const r=function(e){if(e===T)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function O(e){I(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function D(e,t=!0){const n=(t=!1,r="",c=!1)=>{const o=e.currentPeek();return"{"===o?"%"!==r&&t:"@"!==o&&o?"%"===o?(e.peek(),n(t,"%",!0)):"|"===o?!("%"!==r&&!c)||!(r===d||r===N):o===d?(e.peek(),n(!0,d,c)):o!==N||(e.peek(),n(!0,N,c)):"%"===r||t},r=n();return t&&e.resetPeek(),r}function y(e,t){const n=e.currentChar();return n===T?T:t(n)?(e.next(),n):null}function m(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t}function U(e){return y(e,m)}function b(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t||45===t}function x(e){return y(e,b)}function v(e){const t=e.charCodeAt(0);return t>=48&&t<=57}function R(e){return y(e,v)}function M(e){const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function g(e){return y(e,M)}function X(e){let t="",n="";for(;t=R(e);)n+=t;return n}function Y(e){let t="";for(;;){const n=e.currentChar();if("{"===n||"}"===n||"@"===n||"|"===n||!n)break;if("%"===n){if(!D(e))break;t+=n,e.next()}else if(n===d||n===N)if(D(e))t+=n,e.next();else{if(O(e))break;t+=n,e.next()}else t+=n,e.next()}return t}function K(e){return e!==k&&e!==N}function w(e){const t=e.currentChar();switch(t){case"\\":case"'":return e.next(),`\\${t}`;case"u":return H(e,t,4);case"U":return H(e,t,6);default:return i.UNKNOWN_ESCAPE_SEQUENCE,u(),""}}function H(e,t,n){A(e,t);let r="";for(let c=0;c=1&&(i.NOT_ALLOW_NEST_PLACEHOLDER,u()),e.next(),n=_(t,2,"{"),h(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&(i.EMPTY_PLACEHOLDER,u()),e.next(),n=_(t,3,"}"),t.braceNest--,t.braceNest>0&&h(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),n;case"@":return t.braceNest>0&&(i.UNTERMINATED_CLOSING_BRACE,u()),n=V(e,t)||p(t),t.braceNest=0,n;default:{let r=!0,c=!0,o=!0;if(O(e))return t.braceNest>0&&(i.UNTERMINATED_CLOSING_BRACE,u()),n=_(t,1,$(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(5===t.currentType||6===t.currentType||7===t.currentType))return i.UNTERMINATED_CLOSING_BRACE,u(),t.braceNest=0,F(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;I(e);const r=S(e.currentPeek());return e.resetPeek(),r}(e,t))return n=_(t,5,function(e){h(e);let t="",n="";for(;t=x(e);)n+=t;return e.currentChar()===T&&(i.UNTERMINATED_CLOSING_BRACE,u()),n}(e)),h(e),n;if(c=P(e,t))return n=_(t,6,function(e){h(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${X(e)}`):t+=X(e),e.currentChar()===T&&(i.UNTERMINATED_CLOSING_BRACE,u()),t}(e)),h(e),n;if(o=function(e,t){const{currentType:n}=t;if(2!==n)return!1;I(e);const r=e.currentPeek()===k;return e.resetPeek(),r}(e,t))return n=_(t,7,function(e){h(e),A(e,"'");let t="",n="";for(;t=y(e,K);)n+="\\"===t?w(e):t;const r=e.currentChar();return r===N||r===T?(i.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,u(),r===N&&(e.next(),A(e,"'")),n):(A(e,"'"),n)}(e)),h(e),n;if(!r&&!c&&!o)return n=_(t,13,function(e){h(e);let t="",n="";for(;t=y(e,G);)n+=t;return n}(e)),i.INVALID_TOKEN_IN_PLACEHOLDER,u(),n.value,h(e),n;break}}return n}function V(e,t){const{currentType:n}=t;let r=null;const c=e.currentChar();switch(8!==n&&9!==n&&12!==n&&10!==n||c!==N&&c!==d||(i.INVALID_LINKED_FORMAT,u()),c){case"@":return e.next(),r=_(t,8,"@"),t.inLinked=!0,r;case".":return h(e),e.next(),_(t,9,".");case":":return h(e),e.next(),_(t,10,":");default:return O(e)?(r=_(t,1,$(e)),t.braceNest=0,t.inLinked=!1,r):function(e,t){const{currentType:n}=t;if(8!==n)return!1;I(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,t)||function(e,t){const{currentType:n}=t;if(8!==n&&12!==n)return!1;I(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,t)?(h(e),V(e,t)):function(e,t){const{currentType:n}=t;if(9!==n)return!1;I(e);const r=S(e.currentPeek());return e.resetPeek(),r}(e,t)?(h(e),_(t,12,function(e){let t="",n="";for(;t=U(e);)n+=t;return n}(e))):function(e,t){const{currentType:n}=t;if(10!==n)return!1;const r=()=>{const t=e.currentPeek();return"{"===t?S(e.peek()):!("@"===t||"%"===t||"|"===t||":"===t||"."===t||t===d||!t)&&(t===N?(e.peek(),r()):D(e,!1))},c=r();return e.resetPeek(),c}(e,t)?(h(e),"{"===c?B(e,t)||r:_(t,11,function(e){const t=n=>{const r=e.currentChar();return"{"!==r&&"%"!==r&&"@"!==r&&"|"!==r&&"("!==r&&")"!==r&&r?r===d?n:(n+=r,e.next(),t(n)):n};return t("")}(e))):(8===n&&(i.INVALID_LINKED_FORMAT,u()),t.braceNest=0,t.inLinked=!1,F(e,t))}}function F(e,t){let n={type:14};if(t.braceNest>0)return B(e,t)||p(t);if(t.inLinked)return V(e,t)||p(t);switch(e.currentChar()){case"{":return B(e,t)||p(t);case"}":return i.UNBALANCED_CLOSING_BRACE,u(),e.next(),_(t,3,"}");case"@":return V(e,t)||p(t);default:{if(O(e))return n=_(t,1,$(e)),t.braceNest=0,t.inLinked=!1,n;const{isModulo:r,hasSpace:c}=function(e){const t=I(e),n="%"===e.currentPeek()&&"{"===e.peek();return e.resetPeek(),{isModulo:n,hasSpace:t.length>0}}(e);if(r)return c?_(t,0,Y(e)):_(t,4,function(e){h(e);const t=e.currentChar();return"%"!==t&&(i.EXPECTED_TOKEN,u()),e.next(),"%"}(e));if(D(e))return _(t,0,Y(e));break}}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:r}=E;return E.lastType=e,E.lastOffset=t,E.lastStartLoc=n,E.lastEndLoc=r,E.offset=s(),E.startLoc=u(),o.currentChar()===T?_(E,14):F(o,E)},currentOffset:s,currentPosition:u,context:f}}const I="parser",h=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function S(e,t,n){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const e=parseInt(t||n,16);return e<=55295||e>=57344?String.fromCodePoint(e):"�"}}}function P(e={}){const t=!1!==e.location,{onError:n,onWarn:c}=e;function o(e,n,r){const c={type:e};return t&&(c.start=n,c.end=n,c.loc={start:r,end:r}),c}function u(e,n,r,c){c&&(e.type=c),t&&(e.end=n,e.loc&&(e.loc.end=r))}function a(e,t){const n=e.context(),r=o(3,n.offset,n.startLoc);return r.value=t,u(r,e.currentOffset(),e.currentPosition()),r}function l(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:c}=n,s=o(5,r,c);return s.index=parseInt(t,10),e.nextToken(),u(s,e.currentOffset(),e.currentPosition()),s}function E(e,t,n){const r=e.context(),{lastOffset:c,lastStartLoc:s}=r,a=o(4,c,s);return a.key=t,!0===n&&(a.modulo=!0),e.nextToken(),u(a,e.currentOffset(),e.currentPosition()),a}function f(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:c}=n,s=o(9,r,c);return s.value=t.replace(h,S),e.nextToken(),u(s,e.currentOffset(),e.currentPosition()),s}function d(e){const t=e.context(),n=o(6,t.offset,t.startLoc);let r=e.nextToken();if(9===r.type){const t=function(e){const t=e.nextToken(),n=e.context(),{lastOffset:r,lastStartLoc:c}=n,s=o(8,r,c);return 12!==t.type?(i.UNEXPECTED_EMPTY_LINKED_MODIFIER,n.lastStartLoc,s.value="",u(s,r,c),{nextConsumeToken:t,node:s}):(null==t.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,n.lastStartLoc,O(t)),s.value=t.value||"",u(s,e.currentOffset(),e.currentPosition()),{node:s})}(e);n.modifier=t.node,r=t.nextConsumeToken||e.nextToken()}switch(10!==r.type&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,O(r)),r=e.nextToken(),2===r.type&&(r=e.nextToken()),r.type){case 11:null==r.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,O(r)),n.key=function(e,t){const n=e.context(),r=o(7,n.offset,n.startLoc);return r.value=t,u(r,e.currentOffset(),e.currentPosition()),r}(e,r.value||"");break;case 5:null==r.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,O(r)),n.key=E(e,r.value||"");break;case 6:null==r.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,O(r)),n.key=l(e,r.value||"");break;case 7:null==r.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,O(r)),n.key=f(e,r.value||"");break;default:{i.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const c=e.context(),s=o(7,c.offset,c.startLoc);return s.value="",u(s,c.offset,c.startLoc),n.key=s,u(n,c.offset,c.startLoc),{nextConsumeToken:r,node:n}}}return u(n,e.currentOffset(),e.currentPosition()),{node:n}}function L(e){const t=e.context(),n=o(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let r=null,c=null;do{const o=r||e.nextToken();switch(r=null,o.type){case 0:null==o.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,O(o)),n.items.push(a(e,o.value||""));break;case 6:null==o.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,O(o)),n.items.push(l(e,o.value||""));break;case 4:c=!0;break;case 5:null==o.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,O(o)),n.items.push(E(e,o.value||"",!!c)),c&&(s.USE_MODULO_SYNTAX,t.lastStartLoc,O(o),c=null);break;case 7:null==o.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,O(o)),n.items.push(f(e,o.value||""));break;case 8:{const t=d(e);n.items.push(t.node),r=t.nextConsumeToken||null;break}}}while(14!==t.currentType&&1!==t.currentType);return u(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function N(e){const t=e.context(),{offset:n,startLoc:r}=t,c=L(e);return 14===t.currentType?c:function(e,t,n,r){const c=e.context();let s=0===r.items.length;const a=o(1,t,n);a.cases=[],a.cases.push(r);do{const t=L(e);s||(s=0===t.items.length),a.cases.push(t)}while(14!==c.currentType);return s&&i.MUST_HAVE_MESSAGES_IN_PLURAL,u(a,e.currentOffset(),e.currentPosition()),a}(e,n,r,c)}return{parse:function(n){const c=A(n,r({},e)),s=c.context(),a=o(0,s.offset,s.startLoc);return t&&a.loc&&(a.loc.source=n),a.body=N(c),e.onCacheKey&&(a.cacheKey=e.onCacheKey(n)),14!==s.currentType&&(i.UNEXPECTED_LEXICAL_ANALYSIS,s.lastStartLoc,n[s.offset]),u(a,c.currentOffset(),c.currentPosition()),a}}}function O(e){if(14===e.type)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function D(e,t){for(let n=0;nn,helper:e=>(n.helpers.add(e),e)}}(e);n.helper("normalize"),e.body&&y(e.body,n);const r=n.context();e.helpers=Array.from(r.helpers)}function U(e){if(1===e.items.length){const t=e.items[0];3!==t.type&&9!==t.type||(e.static=t.value,delete t.value)}else{const t=[];for(let n=0;n1){e.push(`${n("plural")}([`),e.indent(r());const c=t.cases.length;for(let n=0;nU(e)))}(i),u&&b(i),{ast:i,code:""}):(m(i,n),((e,t={})=>{const n=c(t.mode)?t.mode:"normal",r=c(t.filename)?t.filename:"message.intl",s=!!t.sourceMap,u=null!=t.breakLineCode?t.breakLineCode:"arrow"===n?";":"\n",a=t.needIndent?t.needIndent:"arrow"!==n,i=e.helpers||[],l=function(e,t){const{sourceMap:n,filename:r,breakLineCode:c,needIndent:o}=t,s=!1!==t.location,u={filename:r,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:c,needIndent:o,indentLevel:0};function a(e,t){u.code+=e}function i(e,t=!0){const n=t?c:"";a(o?n+" ".repeat(e):n)}return s&&e.loc&&(u.source=e.loc.source),{context:()=>u,push:a,indent:function(e=!0){const t=++u.indentLevel;e&&i(t)},deindent:function(e=!0){const t=--u.indentLevel;e&&i(t)},newline:function(){i(u.indentLevel)},helper:e=>`_${e}`,needIndent:()=>u.needIndent}}(e,{mode:n,filename:r,sourceMap:s,breakLineCode:u,needIndent:a});l.push("normal"===n?"function __msg__ (ctx) {":"(ctx) => {"),l.indent(a),i.length>0&&(l.push(`const { ${o(i.map((e=>`${e}: _${e}`)),", ")} } = ctx`),l.newline()),l.push("return "),x(l,e),l.deindent(a),l.push("}"),delete e.helpers;const{code:E,map:f}=l.context();return{ast:e,code:E,map:f?f.toJSON():void 0}})(i,n))},e.createCompileError=E,e.createCompileWarn=a,e.createLocation=n,e.createParser=P,e.createPosition=t,e.defaultOnError=function(e){throw e},e.detectHtmlTag=e=>f.test(e),e.errorMessages=l,e.warnMessages=u,e}({}); diff --git a/node_modules/@intlify/message-compiler/dist/message-compiler.mjs b/node_modules/@intlify/message-compiler/dist/message-compiler.mjs new file mode 100644 index 0000000..7f36912 --- /dev/null +++ b/node_modules/@intlify/message-compiler/dist/message-compiler.mjs @@ -0,0 +1,1603 @@ +/*! + * message-compiler v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +import { format, assign, join, isString } from '@intlify/shared'; + +const LOCATION_STUB = { + start: { line: 1, column: 1, offset: 0 }, + end: { line: 1, column: 1, offset: 0 } +}; +function createPosition(line, column, offset) { + return { line, column, offset }; +} +function createLocation(start, end, source) { + const loc = { start, end }; + if (source != null) { + loc.source = source; + } + return loc; +} + +const CompileWarnCodes = { + USE_MODULO_SYNTAX: 1, + __EXTEND_POINT__: 2 +}; +/** @internal */ +const warnMessages = { + [CompileWarnCodes.USE_MODULO_SYNTAX]: `Use modulo before '{{0}}'.` +}; +function createCompileWarn(code, loc, ...args) { + const msg = (process.env.NODE_ENV !== 'production') ? format(warnMessages[code] || '', ...(args || [])) : code; + const message = { message: String(msg), code }; + if (loc) { + message.location = loc; + } + return message; +} + +const CompileErrorCodes = { + // tokenizer error codes + EXPECTED_TOKEN: 1, + INVALID_TOKEN_IN_PLACEHOLDER: 2, + UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3, + UNKNOWN_ESCAPE_SEQUENCE: 4, + INVALID_UNICODE_ESCAPE_SEQUENCE: 5, + UNBALANCED_CLOSING_BRACE: 6, + UNTERMINATED_CLOSING_BRACE: 7, + EMPTY_PLACEHOLDER: 8, + NOT_ALLOW_NEST_PLACEHOLDER: 9, + INVALID_LINKED_FORMAT: 10, + // parser error codes + MUST_HAVE_MESSAGES_IN_PLURAL: 11, + UNEXPECTED_EMPTY_LINKED_MODIFIER: 12, + UNEXPECTED_EMPTY_LINKED_KEY: 13, + UNEXPECTED_LEXICAL_ANALYSIS: 14, + // generator error codes + UNHANDLED_CODEGEN_NODE_TYPE: 15, + // minifier error codes + UNHANDLED_MINIFIER_NODE_TYPE: 16, + // Special value for higher-order compilers to pick up the last code + // to avoid collision of error codes. This should always be kept as the last + // item. + __EXTEND_POINT__: 17 +}; +/** @internal */ +const errorMessages = { + // tokenizer error messages + [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`, + [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`, + [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`, + [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`, + [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`, + [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`, + [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`, + [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`, + [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`, + [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`, + // parser error messages + [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`, + [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`, + // generator error messages + [CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`, + // minimizer error messages + [CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'` +}; +function createCompileError(code, loc, options = {}) { + const { domain, messages, args } = options; + const msg = (process.env.NODE_ENV !== 'production') + ? format((messages || errorMessages)[code] || '', ...(args || [])) + : code; + const error = new SyntaxError(String(msg)); + error.code = code; + if (loc) { + error.location = loc; + } + error.domain = domain; + return error; +} +/** @internal */ +function defaultOnError(error) { + throw error; +} + +// eslint-disable-next-line no-useless-escape +const RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/; +const detectHtmlTag = (source) => RE_HTML_TAG.test(source); + +const CHAR_SP = ' '; +const CHAR_CR = '\r'; +const CHAR_LF = '\n'; +const CHAR_LS = String.fromCharCode(0x2028); +const CHAR_PS = String.fromCharCode(0x2029); +function createScanner(str) { + const _buf = str; + let _index = 0; + let _line = 1; + let _column = 1; + let _peekOffset = 0; + const isCRLF = (index) => _buf[index] === CHAR_CR && _buf[index + 1] === CHAR_LF; + const isLF = (index) => _buf[index] === CHAR_LF; + const isPS = (index) => _buf[index] === CHAR_PS; + const isLS = (index) => _buf[index] === CHAR_LS; + const isLineEnd = (index) => isCRLF(index) || isLF(index) || isPS(index) || isLS(index); + const index = () => _index; + const line = () => _line; + const column = () => _column; + const peekOffset = () => _peekOffset; + const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset]; + const currentChar = () => charAt(_index); + const currentPeek = () => charAt(_index + _peekOffset); + function next() { + _peekOffset = 0; + if (isLineEnd(_index)) { + _line++; + _column = 0; + } + if (isCRLF(_index)) { + _index++; + } + _index++; + _column++; + return _buf[_index]; + } + function peek() { + if (isCRLF(_index + _peekOffset)) { + _peekOffset++; + } + _peekOffset++; + return _buf[_index + _peekOffset]; + } + function reset() { + _index = 0; + _line = 1; + _column = 1; + _peekOffset = 0; + } + function resetPeek(offset = 0) { + _peekOffset = offset; + } + function skipToPeek() { + const target = _index + _peekOffset; + // eslint-disable-next-line no-unmodified-loop-condition + while (target !== _index) { + next(); + } + _peekOffset = 0; + } + return { + index, + line, + column, + peekOffset, + charAt, + currentChar, + currentPeek, + next, + peek, + reset, + resetPeek, + skipToPeek + }; +} + +const EOF = undefined; +const DOT = '.'; +const LITERAL_DELIMITER = "'"; +const ERROR_DOMAIN$3 = 'tokenizer'; +function createTokenizer(source, options = {}) { + const location = options.location !== false; + const _scnr = createScanner(source); + const currentOffset = () => _scnr.index(); + const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index()); + const _initLoc = currentPosition(); + const _initOffset = currentOffset(); + const _context = { + currentType: 14 /* TokenTypes.EOF */, + offset: _initOffset, + startLoc: _initLoc, + endLoc: _initLoc, + lastType: 14 /* TokenTypes.EOF */, + lastOffset: _initOffset, + lastStartLoc: _initLoc, + lastEndLoc: _initLoc, + braceNest: 0, + inLinked: false, + text: '' + }; + const context = () => _context; + const { onError } = options; + function emitError(code, pos, offset, ...args) { + const ctx = context(); + pos.column += offset; + pos.offset += offset; + if (onError) { + const loc = location ? createLocation(ctx.startLoc, pos) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$3, + args + }); + onError(err); + } + } + function getToken(context, type, value) { + context.endLoc = currentPosition(); + context.currentType = type; + const token = { type }; + if (location) { + token.loc = createLocation(context.startLoc, context.endLoc); + } + if (value != null) { + token.value = value; + } + return token; + } + const getEndToken = (context) => getToken(context, 14 /* TokenTypes.EOF */); + function eat(scnr, ch) { + if (scnr.currentChar() === ch) { + scnr.next(); + return ch; + } + else { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + return ''; + } + } + function peekSpaces(scnr) { + let buf = ''; + while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) { + buf += scnr.currentPeek(); + scnr.peek(); + } + return buf; + } + function skipSpaces(scnr) { + const buf = peekSpaces(scnr); + scnr.skipToPeek(); + return buf; + } + function isIdentifierStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + cc === 95 // _ + ); + } + function isNumberStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function isNamedIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isListIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ch = scnr.currentPeek() === '-' ? scnr.peek() : scnr.currentPeek(); + const ret = isNumberStart(ch); + scnr.resetPeek(); + return ret; + } + function isLiteralStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === LITERAL_DELIMITER; + scnr.resetPeek(); + return ret; + } + function isLinkedDotStart(scnr, context) { + const { currentType } = context; + if (currentType !== 8 /* TokenTypes.LinkedAlias */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === "." /* TokenChars.LinkedDot */; + scnr.resetPeek(); + return ret; + } + function isLinkedModifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 9 /* TokenTypes.LinkedDot */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isLinkedDelimiterStart(scnr, context) { + const { currentType } = context; + if (!(currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 12 /* TokenTypes.LinkedModifier */)) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === ":" /* TokenChars.LinkedDelimiter */; + scnr.resetPeek(); + return ret; + } + function isLinkedReferStart(scnr, context) { + const { currentType } = context; + if (currentType !== 10 /* TokenTypes.LinkedDelimiter */) { + return false; + } + const fn = () => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return isIdentifierStart(scnr.peek()); + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "|" /* TokenChars.Pipe */ || + ch === ":" /* TokenChars.LinkedDelimiter */ || + ch === "." /* TokenChars.LinkedDot */ || + ch === CHAR_SP || + !ch) { + return false; + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(); + } + else { + // other characters + return isTextStart(scnr, false); + } + }; + const ret = fn(); + scnr.resetPeek(); + return ret; + } + function isPluralStart(scnr) { + peekSpaces(scnr); + const ret = scnr.currentPeek() === "|" /* TokenChars.Pipe */; + scnr.resetPeek(); + return ret; + } + function detectModuloStart(scnr) { + const spaces = peekSpaces(scnr); + const ret = scnr.currentPeek() === "%" /* TokenChars.Modulo */ && + scnr.peek() === "{" /* TokenChars.BraceLeft */; + scnr.resetPeek(); + return { + isModulo: ret, + hasSpace: spaces.length > 0 + }; + } + function isTextStart(scnr, reset = true) { + const fn = (hasSpace = false, prev = '', detectModulo = false) => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return prev === "%" /* TokenChars.Modulo */ ? false : hasSpace; + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || !ch) { + return prev === "%" /* TokenChars.Modulo */ ? true : hasSpace; + } + else if (ch === "%" /* TokenChars.Modulo */) { + scnr.peek(); + return fn(hasSpace, "%" /* TokenChars.Modulo */, true); + } + else if (ch === "|" /* TokenChars.Pipe */) { + return prev === "%" /* TokenChars.Modulo */ || detectModulo + ? true + : !(prev === CHAR_SP || prev === CHAR_LF); + } + else if (ch === CHAR_SP) { + scnr.peek(); + return fn(true, CHAR_SP, detectModulo); + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(true, CHAR_LF, detectModulo); + } + else { + return true; + } + }; + const ret = fn(); + reset && scnr.resetPeek(); + return ret; + } + function takeChar(scnr, fn) { + const ch = scnr.currentChar(); + if (ch === EOF) { + return EOF; + } + if (fn(ch)) { + scnr.next(); + return ch; + } + return null; + } + function isIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 // $ + ); + } + function takeIdentifierChar(scnr) { + return takeChar(scnr, isIdentifier); + } + function isNamedIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 || // $ + cc === 45 // - + ); + } + function takeNamedIdentifierChar(scnr) { + return takeChar(scnr, isNamedIdentifier); + } + function isDigit(ch) { + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function takeDigit(scnr) { + return takeChar(scnr, isDigit); + } + function isHexDigit(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 48 && cc <= 57) || // 0-9 + (cc >= 65 && cc <= 70) || // A-F + (cc >= 97 && cc <= 102)); // a-f + } + function takeHexDigit(scnr) { + return takeChar(scnr, isHexDigit); + } + function getDigits(scnr) { + let ch = ''; + let num = ''; + while ((ch = takeDigit(scnr))) { + num += ch; + } + return num; + } + function readModulo(scnr) { + skipSpaces(scnr); + const ch = scnr.currentChar(); + if (ch !== "%" /* TokenChars.Modulo */) { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + } + scnr.next(); + return "%" /* TokenChars.Modulo */; + } + function readText(scnr) { + let buf = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "}" /* TokenChars.BraceRight */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + !ch) { + break; + } + else if (ch === "%" /* TokenChars.Modulo */) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else { + break; + } + } + else if (ch === CHAR_SP || ch === CHAR_LF) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else if (isPluralStart(scnr)) { + break; + } + else { + buf += ch; + scnr.next(); + } + } + else { + buf += ch; + scnr.next(); + } + } + return buf; + } + function readNamedIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let name = ''; + while ((ch = takeNamedIdentifierChar(scnr))) { + name += ch; + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return name; + } + function readListIdentifier(scnr) { + skipSpaces(scnr); + let value = ''; + if (scnr.currentChar() === '-') { + scnr.next(); + value += `-${getDigits(scnr)}`; + } + else { + value += getDigits(scnr); + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return value; + } + function isLiteral(ch) { + return ch !== LITERAL_DELIMITER && ch !== CHAR_LF; + } + function readLiteral(scnr) { + skipSpaces(scnr); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + let ch = ''; + let literal = ''; + while ((ch = takeChar(scnr, isLiteral))) { + if (ch === '\\') { + literal += readEscapeSequence(scnr); + } + else { + literal += ch; + } + } + const current = scnr.currentChar(); + if (current === CHAR_LF || current === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, currentPosition(), 0); + // TODO: Is it correct really? + if (current === CHAR_LF) { + scnr.next(); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + } + return literal; + } + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + return literal; + } + function readEscapeSequence(scnr) { + const ch = scnr.currentChar(); + switch (ch) { + case '\\': + case `\'`: // eslint-disable-line no-useless-escape + scnr.next(); + return `\\${ch}`; + case 'u': + return readUnicodeEscapeSequence(scnr, ch, 4); + case 'U': + return readUnicodeEscapeSequence(scnr, ch, 6); + default: + emitError(CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, currentPosition(), 0, ch); + return ''; + } + } + function readUnicodeEscapeSequence(scnr, unicode, digits) { + eat(scnr, unicode); + let sequence = ''; + for (let i = 0; i < digits; i++) { + const ch = takeHexDigit(scnr); + if (!ch) { + emitError(CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`); + break; + } + sequence += ch; + } + return `\\${unicode}${sequence}`; + } + function isInvalidIdentifier(ch) { + return (ch !== "{" /* TokenChars.BraceLeft */ && + ch !== "}" /* TokenChars.BraceRight */ && + ch !== CHAR_SP && + ch !== CHAR_LF); + } + function readInvalidIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let identifiers = ''; + while ((ch = takeChar(scnr, isInvalidIdentifier))) { + identifiers += ch; + } + return identifiers; + } + function readLinkedModifier(scnr) { + let ch = ''; + let name = ''; + while ((ch = takeIdentifierChar(scnr))) { + name += ch; + } + return name; + } + function readLinkedRefer(scnr) { + const fn = (buf) => { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + ch === "(" /* TokenChars.ParenLeft */ || + ch === ")" /* TokenChars.ParenRight */ || + !ch) { + return buf; + } + else if (ch === CHAR_SP) { + return buf; + } + else if (ch === CHAR_LF || ch === DOT) { + buf += ch; + scnr.next(); + return fn(buf); + } + else { + buf += ch; + scnr.next(); + return fn(buf); + } + }; + return fn(''); + } + function readPlural(scnr) { + skipSpaces(scnr); + const plural = eat(scnr, "|" /* TokenChars.Pipe */); + skipSpaces(scnr); + return plural; + } + // TODO: We need refactoring of token parsing ... + function readTokenInPlaceholder(scnr, context) { + let token = null; + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + if (context.braceNest >= 1) { + emitError(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 2 /* TokenTypes.BraceLeft */, "{" /* TokenChars.BraceLeft */); + skipSpaces(scnr); + context.braceNest++; + return token; + case "}" /* TokenChars.BraceRight */: + if (context.braceNest > 0 && + context.currentType === 2 /* TokenTypes.BraceLeft */) { + emitError(CompileErrorCodes.EMPTY_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + context.braceNest--; + context.braceNest > 0 && skipSpaces(scnr); + if (context.inLinked && context.braceNest === 0) { + context.inLinked = false; + } + return token; + case "@" /* TokenChars.LinkedAlias */: + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = readTokenInLinked(scnr, context) || getEndToken(context); + context.braceNest = 0; + return token; + default: { + let validNamedIdentifier = true; + let validListIdentifier = true; + let validLiteral = true; + if (isPluralStart(scnr)) { + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (context.braceNest > 0 && + (context.currentType === 5 /* TokenTypes.Named */ || + context.currentType === 6 /* TokenTypes.List */ || + context.currentType === 7 /* TokenTypes.Literal */)) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + context.braceNest = 0; + return readToken(scnr, context); + } + if ((validNamedIdentifier = isNamedIdentifierStart(scnr, context))) { + token = getToken(context, 5 /* TokenTypes.Named */, readNamedIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validListIdentifier = isListIdentifierStart(scnr, context))) { + token = getToken(context, 6 /* TokenTypes.List */, readListIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validLiteral = isLiteralStart(scnr, context))) { + token = getToken(context, 7 /* TokenTypes.Literal */, readLiteral(scnr)); + skipSpaces(scnr); + return token; + } + if (!validNamedIdentifier && !validListIdentifier && !validLiteral) { + // TODO: we should be re-designed invalid cases, when we will extend message syntax near the future ... + token = getToken(context, 13 /* TokenTypes.InvalidPlace */, readInvalidIdentifier(scnr)); + emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value); + skipSpaces(scnr); + return token; + } + break; + } + } + return token; + } + // TODO: We need refactoring of token parsing ... + function readTokenInLinked(scnr, context) { + const { currentType } = context; + let token = null; + const ch = scnr.currentChar(); + if ((currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 9 /* TokenTypes.LinkedDot */ || + currentType === 12 /* TokenTypes.LinkedModifier */ || + currentType === 10 /* TokenTypes.LinkedDelimiter */) && + (ch === CHAR_LF || ch === CHAR_SP)) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + switch (ch) { + case "@" /* TokenChars.LinkedAlias */: + scnr.next(); + token = getToken(context, 8 /* TokenTypes.LinkedAlias */, "@" /* TokenChars.LinkedAlias */); + context.inLinked = true; + return token; + case "." /* TokenChars.LinkedDot */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 9 /* TokenTypes.LinkedDot */, "." /* TokenChars.LinkedDot */); + case ":" /* TokenChars.LinkedDelimiter */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 10 /* TokenTypes.LinkedDelimiter */, ":" /* TokenChars.LinkedDelimiter */); + default: + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (isLinkedDotStart(scnr, context) || + isLinkedDelimiterStart(scnr, context)) { + skipSpaces(scnr); + return readTokenInLinked(scnr, context); + } + if (isLinkedModifierStart(scnr, context)) { + skipSpaces(scnr); + return getToken(context, 12 /* TokenTypes.LinkedModifier */, readLinkedModifier(scnr)); + } + if (isLinkedReferStart(scnr, context)) { + skipSpaces(scnr); + if (ch === "{" /* TokenChars.BraceLeft */) { + // scan the placeholder + return readTokenInPlaceholder(scnr, context) || token; + } + else { + return getToken(context, 11 /* TokenTypes.LinkedKey */, readLinkedRefer(scnr)); + } + } + if (currentType === 8 /* TokenTypes.LinkedAlias */) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + context.braceNest = 0; + context.inLinked = false; + return readToken(scnr, context); + } + } + // TODO: We need refactoring of token parsing ... + function readToken(scnr, context) { + let token = { type: 14 /* TokenTypes.EOF */ }; + if (context.braceNest > 0) { + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + } + if (context.inLinked) { + return readTokenInLinked(scnr, context) || getEndToken(context); + } + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + case "}" /* TokenChars.BraceRight */: + emitError(CompileErrorCodes.UNBALANCED_CLOSING_BRACE, currentPosition(), 0); + scnr.next(); + return getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + case "@" /* TokenChars.LinkedAlias */: + return readTokenInLinked(scnr, context) || getEndToken(context); + default: { + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + const { isModulo, hasSpace } = detectModuloStart(scnr); + if (isModulo) { + return hasSpace + ? getToken(context, 0 /* TokenTypes.Text */, readText(scnr)) + : getToken(context, 4 /* TokenTypes.Modulo */, readModulo(scnr)); + } + if (isTextStart(scnr)) { + return getToken(context, 0 /* TokenTypes.Text */, readText(scnr)); + } + break; + } + } + return token; + } + function nextToken() { + const { currentType, offset, startLoc, endLoc } = _context; + _context.lastType = currentType; + _context.lastOffset = offset; + _context.lastStartLoc = startLoc; + _context.lastEndLoc = endLoc; + _context.offset = currentOffset(); + _context.startLoc = currentPosition(); + if (_scnr.currentChar() === EOF) { + return getToken(_context, 14 /* TokenTypes.EOF */); + } + return readToken(_scnr, _context); + } + return { + nextToken, + currentOffset, + currentPosition, + context + }; +} + +const ERROR_DOMAIN$2 = 'parser'; +// Backslash backslash, backslash quote, uHHHH, UHHHHHH. +const KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g; +function fromEscapeSequence(match, codePoint4, codePoint6) { + switch (match) { + case `\\\\`: + return `\\`; + // eslint-disable-next-line no-useless-escape + case `\\\'`: + // eslint-disable-next-line no-useless-escape + return `\'`; + default: { + const codePoint = parseInt(codePoint4 || codePoint6, 16); + if (codePoint <= 0xd7ff || codePoint >= 0xe000) { + return String.fromCodePoint(codePoint); + } + // invalid ... + // Replace them with U+FFFD REPLACEMENT CHARACTER. + return '�'; + } + } +} +function createParser(options = {}) { + const location = options.location !== false; + const { onError, onWarn } = options; + function emitError(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onError) { + const loc = location ? createLocation(start, end) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$2, + args + }); + onError(err); + } + } + function emitWarn(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onWarn) { + const loc = location ? createLocation(start, end) : null; + onWarn(createCompileWarn(code, loc, args)); + } + } + function startNode(type, offset, loc) { + const node = { type }; + if (location) { + node.start = offset; + node.end = offset; + node.loc = { start: loc, end: loc }; + } + return node; + } + function endNode(node, offset, pos, type) { + if (type) { + node.type = type; + } + if (location) { + node.end = offset; + if (node.loc) { + node.loc.end = pos; + } + } + } + function parseText(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(3 /* NodeTypes.Text */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseList(tokenizer, index) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(5 /* NodeTypes.List */, offset, loc); + node.index = parseInt(index, 10); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseNamed(tokenizer, key, modulo) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(4 /* NodeTypes.Named */, offset, loc); + node.key = key; + if (modulo === true) { + node.modulo = true; + } + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLiteral(tokenizer, value) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(9 /* NodeTypes.Literal */, offset, loc); + node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinkedModifier(tokenizer) { + const token = tokenizer.nextToken(); + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get linked dot loc + const node = startNode(8 /* NodeTypes.LinkedModifier */, offset, loc); + if (token.type !== 12 /* TokenTypes.LinkedModifier */) { + // empty modifier + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0); + node.value = ''; + endNode(node, offset, loc); + return { + nextConsumeToken: token, + node + }; + } + // check token + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.value = token.value || ''; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node + }; + } + function parseLinkedKey(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(7 /* NodeTypes.LinkedKey */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinked(tokenizer) { + const context = tokenizer.context(); + const linkedNode = startNode(6 /* NodeTypes.Linked */, context.offset, context.startLoc); + let token = tokenizer.nextToken(); + if (token.type === 9 /* TokenTypes.LinkedDot */) { + const parsed = parseLinkedModifier(tokenizer); + linkedNode.modifier = parsed.node; + token = parsed.nextConsumeToken || tokenizer.nextToken(); + } + // asset check token + if (token.type !== 10 /* TokenTypes.LinkedDelimiter */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + token = tokenizer.nextToken(); + // skip brace left + if (token.type === 2 /* TokenTypes.BraceLeft */) { + token = tokenizer.nextToken(); + } + switch (token.type) { + case 11 /* TokenTypes.LinkedKey */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseNamed(tokenizer, token.value || ''); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseList(tokenizer, token.value || ''); + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLiteral(tokenizer, token.value || ''); + break; + default: { + // empty key + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0); + const nextContext = tokenizer.context(); + const emptyLinkedKeyNode = startNode(7 /* NodeTypes.LinkedKey */, nextContext.offset, nextContext.startLoc); + emptyLinkedKeyNode.value = ''; + endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc); + linkedNode.key = emptyLinkedKeyNode; + endNode(linkedNode, nextContext.offset, nextContext.startLoc); + return { + nextConsumeToken: token, + node: linkedNode + }; + } + } + endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node: linkedNode + }; + } + function parseMessage(tokenizer) { + const context = tokenizer.context(); + const startOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? tokenizer.currentOffset() + : context.offset; + const startLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.endLoc + : context.startLoc; + const node = startNode(2 /* NodeTypes.Message */, startOffset, startLoc); + node.items = []; + let nextToken = null; + let modulo = null; + do { + const token = nextToken || tokenizer.nextToken(); + nextToken = null; + switch (token.type) { + case 0 /* TokenTypes.Text */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseText(tokenizer, token.value || '')); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseList(tokenizer, token.value || '')); + break; + case 4 /* TokenTypes.Modulo */: + modulo = true; + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseNamed(tokenizer, token.value || '', !!modulo)); + if (modulo) { + emitWarn(tokenizer, CompileWarnCodes.USE_MODULO_SYNTAX, context.lastStartLoc, 0, getTokenCaption(token)); + modulo = null; + } + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseLiteral(tokenizer, token.value || '')); + break; + case 8 /* TokenTypes.LinkedAlias */: { + const parsed = parseLinked(tokenizer); + node.items.push(parsed.node); + nextToken = parsed.nextConsumeToken || null; + break; + } + } + } while (context.currentType !== 14 /* TokenTypes.EOF */ && + context.currentType !== 1 /* TokenTypes.Pipe */); + // adjust message node loc + const endOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastOffset + : tokenizer.currentOffset(); + const endLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastEndLoc + : tokenizer.currentPosition(); + endNode(node, endOffset, endLoc); + return node; + } + function parsePlural(tokenizer, offset, loc, msgNode) { + const context = tokenizer.context(); + let hasEmptyMessage = msgNode.items.length === 0; + const node = startNode(1 /* NodeTypes.Plural */, offset, loc); + node.cases = []; + node.cases.push(msgNode); + do { + const msg = parseMessage(tokenizer); + if (!hasEmptyMessage) { + hasEmptyMessage = msg.items.length === 0; + } + node.cases.push(msg); + } while (context.currentType !== 14 /* TokenTypes.EOF */); + if (hasEmptyMessage) { + emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseResource(tokenizer) { + const context = tokenizer.context(); + const { offset, startLoc } = context; + const msgNode = parseMessage(tokenizer); + if (context.currentType === 14 /* TokenTypes.EOF */) { + return msgNode; + } + else { + return parsePlural(tokenizer, offset, startLoc, msgNode); + } + } + function parse(source) { + const tokenizer = createTokenizer(source, assign({}, options)); + const context = tokenizer.context(); + const node = startNode(0 /* NodeTypes.Resource */, context.offset, context.startLoc); + if (location && node.loc) { + node.loc.source = source; + } + node.body = parseResource(tokenizer); + if (options.onCacheKey) { + node.cacheKey = options.onCacheKey(source); + } + // assert whether achieved to EOF + if (context.currentType !== 14 /* TokenTypes.EOF */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || ''); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + return { parse }; +} +function getTokenCaption(token) { + if (token.type === 14 /* TokenTypes.EOF */) { + return 'EOF'; + } + const name = (token.value || '').replace(/\r?\n/gu, '\\n'); + return name.length > 10 ? name.slice(0, 9) + '…' : name; +} + +function createTransformer(ast, options = {} // eslint-disable-line +) { + const _context = { + ast, + helpers: new Set() + }; + const context = () => _context; + const helper = (name) => { + _context.helpers.add(name); + return name; + }; + return { context, helper }; +} +function traverseNodes(nodes, transformer) { + for (let i = 0; i < nodes.length; i++) { + traverseNode(nodes[i], transformer); + } +} +function traverseNode(node, transformer) { + // TODO: if we need pre-hook of transform, should be implemented to here + switch (node.type) { + case 1 /* NodeTypes.Plural */: + traverseNodes(node.cases, transformer); + transformer.helper("plural" /* HelperNameMap.PLURAL */); + break; + case 2 /* NodeTypes.Message */: + traverseNodes(node.items, transformer); + break; + case 6 /* NodeTypes.Linked */: { + const linked = node; + traverseNode(linked.key, transformer); + transformer.helper("linked" /* HelperNameMap.LINKED */); + transformer.helper("type" /* HelperNameMap.TYPE */); + break; + } + case 5 /* NodeTypes.List */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("list" /* HelperNameMap.LIST */); + break; + case 4 /* NodeTypes.Named */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("named" /* HelperNameMap.NAMED */); + break; + } + // TODO: if we need post-hook of transform, should be implemented to here +} +// transform AST +function transform(ast, options = {} // eslint-disable-line +) { + const transformer = createTransformer(ast); + transformer.helper("normalize" /* HelperNameMap.NORMALIZE */); + // traverse + ast.body && traverseNode(ast.body, transformer); + // set meta information + const context = transformer.context(); + ast.helpers = Array.from(context.helpers); +} + +function optimize(ast) { + const body = ast.body; + if (body.type === 2 /* NodeTypes.Message */) { + optimizeMessageNode(body); + } + else { + body.cases.forEach(c => optimizeMessageNode(c)); + } + return ast; +} +function optimizeMessageNode(message) { + if (message.items.length === 1) { + const item = message.items[0]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + message.static = item.value; + delete item.value; // optimization for size + } + } + else { + const values = []; + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (!(item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */)) { + break; + } + if (item.value == null) { + break; + } + values.push(item.value); + } + if (values.length === message.items.length) { + message.static = join(values); + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + delete item.value; // optimization for size + } + } + } + } +} + +const ERROR_DOMAIN$1 = 'minifier'; +/* eslint-disable @typescript-eslint/no-explicit-any */ +function minify(node) { + node.t = node.type; + switch (node.type) { + case 0 /* NodeTypes.Resource */: { + const resource = node; + minify(resource.body); + resource.b = resource.body; + delete resource.body; + break; + } + case 1 /* NodeTypes.Plural */: { + const plural = node; + const cases = plural.cases; + for (let i = 0; i < cases.length; i++) { + minify(cases[i]); + } + plural.c = cases; + delete plural.cases; + break; + } + case 2 /* NodeTypes.Message */: { + const message = node; + const items = message.items; + for (let i = 0; i < items.length; i++) { + minify(items[i]); + } + message.i = items; + delete message.items; + if (message.static) { + message.s = message.static; + delete message.static; + } + break; + } + case 3 /* NodeTypes.Text */: + case 9 /* NodeTypes.Literal */: + case 8 /* NodeTypes.LinkedModifier */: + case 7 /* NodeTypes.LinkedKey */: { + const valueNode = node; + if (valueNode.value) { + valueNode.v = valueNode.value; + delete valueNode.value; + } + break; + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + minify(linked.key); + linked.k = linked.key; + delete linked.key; + if (linked.modifier) { + minify(linked.modifier); + linked.m = linked.modifier; + delete linked.modifier; + } + break; + } + case 5 /* NodeTypes.List */: { + const list = node; + list.i = list.index; + delete list.index; + break; + } + case 4 /* NodeTypes.Named */: { + const named = node; + named.k = named.key; + delete named.key; + break; + } + default: + if ((process.env.NODE_ENV !== 'production')) { + throw createCompileError(CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE, null, { + domain: ERROR_DOMAIN$1, + args: [node.type] + }); + } + } + delete node.type; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +// eslint-disable-next-line @typescript-eslint/triple-slash-reference +/// +const ERROR_DOMAIN = 'parser'; +function createCodeGenerator(ast, options) { + const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options; + const location = options.location !== false; + const _context = { + filename, + code: '', + column: 1, + line: 1, + offset: 0, + map: undefined, + breakLineCode, + needIndent: _needIndent, + indentLevel: 0 + }; + if (location && ast.loc) { + _context.source = ast.loc.source; + } + const context = () => _context; + function push(code, node) { + _context.code += code; + } + function _newline(n, withBreakLine = true) { + const _breakLineCode = withBreakLine ? breakLineCode : ''; + push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode); + } + function indent(withNewLine = true) { + const level = ++_context.indentLevel; + withNewLine && _newline(level); + } + function deindent(withNewLine = true) { + const level = --_context.indentLevel; + withNewLine && _newline(level); + } + function newline() { + _newline(_context.indentLevel); + } + const helper = (key) => `_${key}`; + const needIndent = () => _context.needIndent; + return { + context, + push, + indent, + deindent, + newline, + helper, + needIndent + }; +} +function generateLinkedNode(generator, node) { + const { helper } = generator; + generator.push(`${helper("linked" /* HelperNameMap.LINKED */)}(`); + generateNode(generator, node.key); + if (node.modifier) { + generator.push(`, `); + generateNode(generator, node.modifier); + generator.push(`, _type`); + } + else { + generator.push(`, undefined, _type`); + } + generator.push(`)`); +} +function generateMessageNode(generator, node) { + const { helper, needIndent } = generator; + generator.push(`${helper("normalize" /* HelperNameMap.NORMALIZE */)}([`); + generator.indent(needIndent()); + const length = node.items.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.items[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push('])'); +} +function generatePluralNode(generator, node) { + const { helper, needIndent } = generator; + if (node.cases.length > 1) { + generator.push(`${helper("plural" /* HelperNameMap.PLURAL */)}([`); + generator.indent(needIndent()); + const length = node.cases.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.cases[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push(`])`); + } +} +function generateResource(generator, node) { + if (node.body) { + generateNode(generator, node.body); + } + else { + generator.push('null'); + } +} +function generateNode(generator, node) { + const { helper } = generator; + switch (node.type) { + case 0 /* NodeTypes.Resource */: + generateResource(generator, node); + break; + case 1 /* NodeTypes.Plural */: + generatePluralNode(generator, node); + break; + case 2 /* NodeTypes.Message */: + generateMessageNode(generator, node); + break; + case 6 /* NodeTypes.Linked */: + generateLinkedNode(generator, node); + break; + case 8 /* NodeTypes.LinkedModifier */: + generator.push(JSON.stringify(node.value), node); + break; + case 7 /* NodeTypes.LinkedKey */: + generator.push(JSON.stringify(node.value), node); + break; + case 5 /* NodeTypes.List */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("list" /* HelperNameMap.LIST */)}(${node.index}))`, node); + break; + case 4 /* NodeTypes.Named */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("named" /* HelperNameMap.NAMED */)}(${JSON.stringify(node.key)}))`, node); + break; + case 9 /* NodeTypes.Literal */: + generator.push(JSON.stringify(node.value), node); + break; + case 3 /* NodeTypes.Text */: + generator.push(JSON.stringify(node.value), node); + break; + default: + if ((process.env.NODE_ENV !== 'production')) { + throw createCompileError(CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE, null, { + domain: ERROR_DOMAIN, + args: [node.type] + }); + } + } +} +// generate code from AST +const generate = (ast, options = {} // eslint-disable-line +) => { + const mode = isString(options.mode) ? options.mode : 'normal'; + const filename = isString(options.filename) + ? options.filename + : 'message.intl'; + const sourceMap = !!options.sourceMap; + // prettier-ignore + const breakLineCode = options.breakLineCode != null + ? options.breakLineCode + : mode === 'arrow' + ? ';' + : '\n'; + const needIndent = options.needIndent ? options.needIndent : mode !== 'arrow'; + const helpers = ast.helpers || []; + const generator = createCodeGenerator(ast, { + mode, + filename, + sourceMap, + breakLineCode, + needIndent + }); + generator.push(mode === 'normal' ? `function __msg__ (ctx) {` : `(ctx) => {`); + generator.indent(needIndent); + if (helpers.length > 0) { + generator.push(`const { ${join(helpers.map(s => `${s}: _${s}`), ', ')} } = ctx`); + generator.newline(); + } + generator.push(`return `); + generateNode(generator, ast); + generator.deindent(needIndent); + generator.push(`}`); + delete ast.helpers; + const { code, map } = generator.context(); + return { + ast, + code, + map: map ? map.toJSON() : undefined // eslint-disable-line @typescript-eslint/no-explicit-any + }; +}; + +function baseCompile(source, options = {}) { + const assignedOptions = assign({}, options); + const jit = !!assignedOptions.jit; + const enalbeMinify = !!assignedOptions.minify; + const enambeOptimize = assignedOptions.optimize == null ? true : assignedOptions.optimize; + // parse source codes + const parser = createParser(assignedOptions); + const ast = parser.parse(source); + if (!jit) { + // transform ASTs + transform(ast, assignedOptions); + // generate javascript codes + return generate(ast, assignedOptions); + } + else { + // optimize ASTs + enambeOptimize && optimize(ast); + // minimize ASTs + enalbeMinify && minify(ast); + // In JIT mode, no ast transform, no code generation. + return { ast, code: '' }; + } +} + +export { CompileErrorCodes, CompileWarnCodes, ERROR_DOMAIN$2 as ERROR_DOMAIN, LOCATION_STUB, baseCompile, createCompileError, createCompileWarn, createLocation, createParser, createPosition, defaultOnError, detectHtmlTag, errorMessages, warnMessages }; diff --git a/node_modules/@intlify/message-compiler/dist/message-compiler.node.mjs b/node_modules/@intlify/message-compiler/dist/message-compiler.node.mjs new file mode 100644 index 0000000..7331db4 --- /dev/null +++ b/node_modules/@intlify/message-compiler/dist/message-compiler.node.mjs @@ -0,0 +1,1660 @@ +/*! + * message-compiler v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +import { format, assign, join, isString } from '@intlify/shared'; +import { SourceMapGenerator } from 'source-map-js'; + +const LOCATION_STUB = { + start: { line: 1, column: 1, offset: 0 }, + end: { line: 1, column: 1, offset: 0 } +}; +function createPosition(line, column, offset) { + return { line, column, offset }; +} +function createLocation(start, end, source) { + const loc = { start, end }; + if (source != null) { + loc.source = source; + } + return loc; +} + +const CompileWarnCodes = { + USE_MODULO_SYNTAX: 1, + __EXTEND_POINT__: 2 +}; +/** @internal */ +const warnMessages = { + [CompileWarnCodes.USE_MODULO_SYNTAX]: `Use modulo before '{{0}}'.` +}; +function createCompileWarn(code, loc, ...args) { + const msg = (process.env.NODE_ENV !== 'production') ? format(warnMessages[code] || '', ...(args || [])) : code; + const message = { message: String(msg), code }; + if (loc) { + message.location = loc; + } + return message; +} + +const CompileErrorCodes = { + // tokenizer error codes + EXPECTED_TOKEN: 1, + INVALID_TOKEN_IN_PLACEHOLDER: 2, + UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3, + UNKNOWN_ESCAPE_SEQUENCE: 4, + INVALID_UNICODE_ESCAPE_SEQUENCE: 5, + UNBALANCED_CLOSING_BRACE: 6, + UNTERMINATED_CLOSING_BRACE: 7, + EMPTY_PLACEHOLDER: 8, + NOT_ALLOW_NEST_PLACEHOLDER: 9, + INVALID_LINKED_FORMAT: 10, + // parser error codes + MUST_HAVE_MESSAGES_IN_PLURAL: 11, + UNEXPECTED_EMPTY_LINKED_MODIFIER: 12, + UNEXPECTED_EMPTY_LINKED_KEY: 13, + UNEXPECTED_LEXICAL_ANALYSIS: 14, + // generator error codes + UNHANDLED_CODEGEN_NODE_TYPE: 15, + // minifier error codes + UNHANDLED_MINIFIER_NODE_TYPE: 16, + // Special value for higher-order compilers to pick up the last code + // to avoid collision of error codes. This should always be kept as the last + // item. + __EXTEND_POINT__: 17 +}; +/** @internal */ +const errorMessages = { + // tokenizer error messages + [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`, + [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`, + [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`, + [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`, + [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`, + [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`, + [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`, + [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`, + [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`, + [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`, + // parser error messages + [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`, + [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`, + // generator error messages + [CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`, + // minimizer error messages + [CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'` +}; +function createCompileError(code, loc, options = {}) { + const { domain, messages, args } = options; + const msg = (process.env.NODE_ENV !== 'production') + ? format((messages || errorMessages)[code] || '', ...(args || [])) + : code; + const error = new SyntaxError(String(msg)); + error.code = code; + if (loc) { + error.location = loc; + } + error.domain = domain; + return error; +} +/** @internal */ +function defaultOnError(error) { + throw error; +} + +// eslint-disable-next-line no-useless-escape +const RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/; +const detectHtmlTag = (source) => RE_HTML_TAG.test(source); + +const CHAR_SP = ' '; +const CHAR_CR = '\r'; +const CHAR_LF = '\n'; +const CHAR_LS = String.fromCharCode(0x2028); +const CHAR_PS = String.fromCharCode(0x2029); +function createScanner(str) { + const _buf = str; + let _index = 0; + let _line = 1; + let _column = 1; + let _peekOffset = 0; + const isCRLF = (index) => _buf[index] === CHAR_CR && _buf[index + 1] === CHAR_LF; + const isLF = (index) => _buf[index] === CHAR_LF; + const isPS = (index) => _buf[index] === CHAR_PS; + const isLS = (index) => _buf[index] === CHAR_LS; + const isLineEnd = (index) => isCRLF(index) || isLF(index) || isPS(index) || isLS(index); + const index = () => _index; + const line = () => _line; + const column = () => _column; + const peekOffset = () => _peekOffset; + const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset]; + const currentChar = () => charAt(_index); + const currentPeek = () => charAt(_index + _peekOffset); + function next() { + _peekOffset = 0; + if (isLineEnd(_index)) { + _line++; + _column = 0; + } + if (isCRLF(_index)) { + _index++; + } + _index++; + _column++; + return _buf[_index]; + } + function peek() { + if (isCRLF(_index + _peekOffset)) { + _peekOffset++; + } + _peekOffset++; + return _buf[_index + _peekOffset]; + } + function reset() { + _index = 0; + _line = 1; + _column = 1; + _peekOffset = 0; + } + function resetPeek(offset = 0) { + _peekOffset = offset; + } + function skipToPeek() { + const target = _index + _peekOffset; + // eslint-disable-next-line no-unmodified-loop-condition + while (target !== _index) { + next(); + } + _peekOffset = 0; + } + return { + index, + line, + column, + peekOffset, + charAt, + currentChar, + currentPeek, + next, + peek, + reset, + resetPeek, + skipToPeek + }; +} + +const EOF = undefined; +const DOT = '.'; +const LITERAL_DELIMITER = "'"; +const ERROR_DOMAIN$3 = 'tokenizer'; +function createTokenizer(source, options = {}) { + const location = options.location !== false; + const _scnr = createScanner(source); + const currentOffset = () => _scnr.index(); + const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index()); + const _initLoc = currentPosition(); + const _initOffset = currentOffset(); + const _context = { + currentType: 14 /* TokenTypes.EOF */, + offset: _initOffset, + startLoc: _initLoc, + endLoc: _initLoc, + lastType: 14 /* TokenTypes.EOF */, + lastOffset: _initOffset, + lastStartLoc: _initLoc, + lastEndLoc: _initLoc, + braceNest: 0, + inLinked: false, + text: '' + }; + const context = () => _context; + const { onError } = options; + function emitError(code, pos, offset, ...args) { + const ctx = context(); + pos.column += offset; + pos.offset += offset; + if (onError) { + const loc = location ? createLocation(ctx.startLoc, pos) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$3, + args + }); + onError(err); + } + } + function getToken(context, type, value) { + context.endLoc = currentPosition(); + context.currentType = type; + const token = { type }; + if (location) { + token.loc = createLocation(context.startLoc, context.endLoc); + } + if (value != null) { + token.value = value; + } + return token; + } + const getEndToken = (context) => getToken(context, 14 /* TokenTypes.EOF */); + function eat(scnr, ch) { + if (scnr.currentChar() === ch) { + scnr.next(); + return ch; + } + else { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + return ''; + } + } + function peekSpaces(scnr) { + let buf = ''; + while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) { + buf += scnr.currentPeek(); + scnr.peek(); + } + return buf; + } + function skipSpaces(scnr) { + const buf = peekSpaces(scnr); + scnr.skipToPeek(); + return buf; + } + function isIdentifierStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + cc === 95 // _ + ); + } + function isNumberStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function isNamedIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isListIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ch = scnr.currentPeek() === '-' ? scnr.peek() : scnr.currentPeek(); + const ret = isNumberStart(ch); + scnr.resetPeek(); + return ret; + } + function isLiteralStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === LITERAL_DELIMITER; + scnr.resetPeek(); + return ret; + } + function isLinkedDotStart(scnr, context) { + const { currentType } = context; + if (currentType !== 8 /* TokenTypes.LinkedAlias */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === "." /* TokenChars.LinkedDot */; + scnr.resetPeek(); + return ret; + } + function isLinkedModifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 9 /* TokenTypes.LinkedDot */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isLinkedDelimiterStart(scnr, context) { + const { currentType } = context; + if (!(currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 12 /* TokenTypes.LinkedModifier */)) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === ":" /* TokenChars.LinkedDelimiter */; + scnr.resetPeek(); + return ret; + } + function isLinkedReferStart(scnr, context) { + const { currentType } = context; + if (currentType !== 10 /* TokenTypes.LinkedDelimiter */) { + return false; + } + const fn = () => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return isIdentifierStart(scnr.peek()); + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "|" /* TokenChars.Pipe */ || + ch === ":" /* TokenChars.LinkedDelimiter */ || + ch === "." /* TokenChars.LinkedDot */ || + ch === CHAR_SP || + !ch) { + return false; + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(); + } + else { + // other characters + return isTextStart(scnr, false); + } + }; + const ret = fn(); + scnr.resetPeek(); + return ret; + } + function isPluralStart(scnr) { + peekSpaces(scnr); + const ret = scnr.currentPeek() === "|" /* TokenChars.Pipe */; + scnr.resetPeek(); + return ret; + } + function detectModuloStart(scnr) { + const spaces = peekSpaces(scnr); + const ret = scnr.currentPeek() === "%" /* TokenChars.Modulo */ && + scnr.peek() === "{" /* TokenChars.BraceLeft */; + scnr.resetPeek(); + return { + isModulo: ret, + hasSpace: spaces.length > 0 + }; + } + function isTextStart(scnr, reset = true) { + const fn = (hasSpace = false, prev = '', detectModulo = false) => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return prev === "%" /* TokenChars.Modulo */ ? false : hasSpace; + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || !ch) { + return prev === "%" /* TokenChars.Modulo */ ? true : hasSpace; + } + else if (ch === "%" /* TokenChars.Modulo */) { + scnr.peek(); + return fn(hasSpace, "%" /* TokenChars.Modulo */, true); + } + else if (ch === "|" /* TokenChars.Pipe */) { + return prev === "%" /* TokenChars.Modulo */ || detectModulo + ? true + : !(prev === CHAR_SP || prev === CHAR_LF); + } + else if (ch === CHAR_SP) { + scnr.peek(); + return fn(true, CHAR_SP, detectModulo); + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(true, CHAR_LF, detectModulo); + } + else { + return true; + } + }; + const ret = fn(); + reset && scnr.resetPeek(); + return ret; + } + function takeChar(scnr, fn) { + const ch = scnr.currentChar(); + if (ch === EOF) { + return EOF; + } + if (fn(ch)) { + scnr.next(); + return ch; + } + return null; + } + function isIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 // $ + ); + } + function takeIdentifierChar(scnr) { + return takeChar(scnr, isIdentifier); + } + function isNamedIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 || // $ + cc === 45 // - + ); + } + function takeNamedIdentifierChar(scnr) { + return takeChar(scnr, isNamedIdentifier); + } + function isDigit(ch) { + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function takeDigit(scnr) { + return takeChar(scnr, isDigit); + } + function isHexDigit(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 48 && cc <= 57) || // 0-9 + (cc >= 65 && cc <= 70) || // A-F + (cc >= 97 && cc <= 102)); // a-f + } + function takeHexDigit(scnr) { + return takeChar(scnr, isHexDigit); + } + function getDigits(scnr) { + let ch = ''; + let num = ''; + while ((ch = takeDigit(scnr))) { + num += ch; + } + return num; + } + function readModulo(scnr) { + skipSpaces(scnr); + const ch = scnr.currentChar(); + if (ch !== "%" /* TokenChars.Modulo */) { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + } + scnr.next(); + return "%" /* TokenChars.Modulo */; + } + function readText(scnr) { + let buf = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "}" /* TokenChars.BraceRight */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + !ch) { + break; + } + else if (ch === "%" /* TokenChars.Modulo */) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else { + break; + } + } + else if (ch === CHAR_SP || ch === CHAR_LF) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else if (isPluralStart(scnr)) { + break; + } + else { + buf += ch; + scnr.next(); + } + } + else { + buf += ch; + scnr.next(); + } + } + return buf; + } + function readNamedIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let name = ''; + while ((ch = takeNamedIdentifierChar(scnr))) { + name += ch; + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return name; + } + function readListIdentifier(scnr) { + skipSpaces(scnr); + let value = ''; + if (scnr.currentChar() === '-') { + scnr.next(); + value += `-${getDigits(scnr)}`; + } + else { + value += getDigits(scnr); + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return value; + } + function isLiteral(ch) { + return ch !== LITERAL_DELIMITER && ch !== CHAR_LF; + } + function readLiteral(scnr) { + skipSpaces(scnr); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + let ch = ''; + let literal = ''; + while ((ch = takeChar(scnr, isLiteral))) { + if (ch === '\\') { + literal += readEscapeSequence(scnr); + } + else { + literal += ch; + } + } + const current = scnr.currentChar(); + if (current === CHAR_LF || current === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, currentPosition(), 0); + // TODO: Is it correct really? + if (current === CHAR_LF) { + scnr.next(); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + } + return literal; + } + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + return literal; + } + function readEscapeSequence(scnr) { + const ch = scnr.currentChar(); + switch (ch) { + case '\\': + case `\'`: // eslint-disable-line no-useless-escape + scnr.next(); + return `\\${ch}`; + case 'u': + return readUnicodeEscapeSequence(scnr, ch, 4); + case 'U': + return readUnicodeEscapeSequence(scnr, ch, 6); + default: + emitError(CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, currentPosition(), 0, ch); + return ''; + } + } + function readUnicodeEscapeSequence(scnr, unicode, digits) { + eat(scnr, unicode); + let sequence = ''; + for (let i = 0; i < digits; i++) { + const ch = takeHexDigit(scnr); + if (!ch) { + emitError(CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`); + break; + } + sequence += ch; + } + return `\\${unicode}${sequence}`; + } + function isInvalidIdentifier(ch) { + return (ch !== "{" /* TokenChars.BraceLeft */ && + ch !== "}" /* TokenChars.BraceRight */ && + ch !== CHAR_SP && + ch !== CHAR_LF); + } + function readInvalidIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let identifiers = ''; + while ((ch = takeChar(scnr, isInvalidIdentifier))) { + identifiers += ch; + } + return identifiers; + } + function readLinkedModifier(scnr) { + let ch = ''; + let name = ''; + while ((ch = takeIdentifierChar(scnr))) { + name += ch; + } + return name; + } + function readLinkedRefer(scnr) { + const fn = (buf) => { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + ch === "(" /* TokenChars.ParenLeft */ || + ch === ")" /* TokenChars.ParenRight */ || + !ch) { + return buf; + } + else if (ch === CHAR_SP) { + return buf; + } + else if (ch === CHAR_LF || ch === DOT) { + buf += ch; + scnr.next(); + return fn(buf); + } + else { + buf += ch; + scnr.next(); + return fn(buf); + } + }; + return fn(''); + } + function readPlural(scnr) { + skipSpaces(scnr); + const plural = eat(scnr, "|" /* TokenChars.Pipe */); + skipSpaces(scnr); + return plural; + } + // TODO: We need refactoring of token parsing ... + function readTokenInPlaceholder(scnr, context) { + let token = null; + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + if (context.braceNest >= 1) { + emitError(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 2 /* TokenTypes.BraceLeft */, "{" /* TokenChars.BraceLeft */); + skipSpaces(scnr); + context.braceNest++; + return token; + case "}" /* TokenChars.BraceRight */: + if (context.braceNest > 0 && + context.currentType === 2 /* TokenTypes.BraceLeft */) { + emitError(CompileErrorCodes.EMPTY_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + context.braceNest--; + context.braceNest > 0 && skipSpaces(scnr); + if (context.inLinked && context.braceNest === 0) { + context.inLinked = false; + } + return token; + case "@" /* TokenChars.LinkedAlias */: + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = readTokenInLinked(scnr, context) || getEndToken(context); + context.braceNest = 0; + return token; + default: { + let validNamedIdentifier = true; + let validListIdentifier = true; + let validLiteral = true; + if (isPluralStart(scnr)) { + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (context.braceNest > 0 && + (context.currentType === 5 /* TokenTypes.Named */ || + context.currentType === 6 /* TokenTypes.List */ || + context.currentType === 7 /* TokenTypes.Literal */)) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + context.braceNest = 0; + return readToken(scnr, context); + } + if ((validNamedIdentifier = isNamedIdentifierStart(scnr, context))) { + token = getToken(context, 5 /* TokenTypes.Named */, readNamedIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validListIdentifier = isListIdentifierStart(scnr, context))) { + token = getToken(context, 6 /* TokenTypes.List */, readListIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validLiteral = isLiteralStart(scnr, context))) { + token = getToken(context, 7 /* TokenTypes.Literal */, readLiteral(scnr)); + skipSpaces(scnr); + return token; + } + if (!validNamedIdentifier && !validListIdentifier && !validLiteral) { + // TODO: we should be re-designed invalid cases, when we will extend message syntax near the future ... + token = getToken(context, 13 /* TokenTypes.InvalidPlace */, readInvalidIdentifier(scnr)); + emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value); + skipSpaces(scnr); + return token; + } + break; + } + } + return token; + } + // TODO: We need refactoring of token parsing ... + function readTokenInLinked(scnr, context) { + const { currentType } = context; + let token = null; + const ch = scnr.currentChar(); + if ((currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 9 /* TokenTypes.LinkedDot */ || + currentType === 12 /* TokenTypes.LinkedModifier */ || + currentType === 10 /* TokenTypes.LinkedDelimiter */) && + (ch === CHAR_LF || ch === CHAR_SP)) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + switch (ch) { + case "@" /* TokenChars.LinkedAlias */: + scnr.next(); + token = getToken(context, 8 /* TokenTypes.LinkedAlias */, "@" /* TokenChars.LinkedAlias */); + context.inLinked = true; + return token; + case "." /* TokenChars.LinkedDot */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 9 /* TokenTypes.LinkedDot */, "." /* TokenChars.LinkedDot */); + case ":" /* TokenChars.LinkedDelimiter */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 10 /* TokenTypes.LinkedDelimiter */, ":" /* TokenChars.LinkedDelimiter */); + default: + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (isLinkedDotStart(scnr, context) || + isLinkedDelimiterStart(scnr, context)) { + skipSpaces(scnr); + return readTokenInLinked(scnr, context); + } + if (isLinkedModifierStart(scnr, context)) { + skipSpaces(scnr); + return getToken(context, 12 /* TokenTypes.LinkedModifier */, readLinkedModifier(scnr)); + } + if (isLinkedReferStart(scnr, context)) { + skipSpaces(scnr); + if (ch === "{" /* TokenChars.BraceLeft */) { + // scan the placeholder + return readTokenInPlaceholder(scnr, context) || token; + } + else { + return getToken(context, 11 /* TokenTypes.LinkedKey */, readLinkedRefer(scnr)); + } + } + if (currentType === 8 /* TokenTypes.LinkedAlias */) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + context.braceNest = 0; + context.inLinked = false; + return readToken(scnr, context); + } + } + // TODO: We need refactoring of token parsing ... + function readToken(scnr, context) { + let token = { type: 14 /* TokenTypes.EOF */ }; + if (context.braceNest > 0) { + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + } + if (context.inLinked) { + return readTokenInLinked(scnr, context) || getEndToken(context); + } + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + case "}" /* TokenChars.BraceRight */: + emitError(CompileErrorCodes.UNBALANCED_CLOSING_BRACE, currentPosition(), 0); + scnr.next(); + return getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + case "@" /* TokenChars.LinkedAlias */: + return readTokenInLinked(scnr, context) || getEndToken(context); + default: { + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + const { isModulo, hasSpace } = detectModuloStart(scnr); + if (isModulo) { + return hasSpace + ? getToken(context, 0 /* TokenTypes.Text */, readText(scnr)) + : getToken(context, 4 /* TokenTypes.Modulo */, readModulo(scnr)); + } + if (isTextStart(scnr)) { + return getToken(context, 0 /* TokenTypes.Text */, readText(scnr)); + } + break; + } + } + return token; + } + function nextToken() { + const { currentType, offset, startLoc, endLoc } = _context; + _context.lastType = currentType; + _context.lastOffset = offset; + _context.lastStartLoc = startLoc; + _context.lastEndLoc = endLoc; + _context.offset = currentOffset(); + _context.startLoc = currentPosition(); + if (_scnr.currentChar() === EOF) { + return getToken(_context, 14 /* TokenTypes.EOF */); + } + return readToken(_scnr, _context); + } + return { + nextToken, + currentOffset, + currentPosition, + context + }; +} + +const ERROR_DOMAIN$2 = 'parser'; +// Backslash backslash, backslash quote, uHHHH, UHHHHHH. +const KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g; +function fromEscapeSequence(match, codePoint4, codePoint6) { + switch (match) { + case `\\\\`: + return `\\`; + // eslint-disable-next-line no-useless-escape + case `\\\'`: + // eslint-disable-next-line no-useless-escape + return `\'`; + default: { + const codePoint = parseInt(codePoint4 || codePoint6, 16); + if (codePoint <= 0xd7ff || codePoint >= 0xe000) { + return String.fromCodePoint(codePoint); + } + // invalid ... + // Replace them with U+FFFD REPLACEMENT CHARACTER. + return '�'; + } + } +} +function createParser(options = {}) { + const location = options.location !== false; + const { onError, onWarn } = options; + function emitError(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onError) { + const loc = location ? createLocation(start, end) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$2, + args + }); + onError(err); + } + } + function emitWarn(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onWarn) { + const loc = location ? createLocation(start, end) : null; + onWarn(createCompileWarn(code, loc, args)); + } + } + function startNode(type, offset, loc) { + const node = { type }; + if (location) { + node.start = offset; + node.end = offset; + node.loc = { start: loc, end: loc }; + } + return node; + } + function endNode(node, offset, pos, type) { + if (type) { + node.type = type; + } + if (location) { + node.end = offset; + if (node.loc) { + node.loc.end = pos; + } + } + } + function parseText(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(3 /* NodeTypes.Text */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseList(tokenizer, index) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(5 /* NodeTypes.List */, offset, loc); + node.index = parseInt(index, 10); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseNamed(tokenizer, key, modulo) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(4 /* NodeTypes.Named */, offset, loc); + node.key = key; + if (modulo === true) { + node.modulo = true; + } + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLiteral(tokenizer, value) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(9 /* NodeTypes.Literal */, offset, loc); + node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinkedModifier(tokenizer) { + const token = tokenizer.nextToken(); + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get linked dot loc + const node = startNode(8 /* NodeTypes.LinkedModifier */, offset, loc); + if (token.type !== 12 /* TokenTypes.LinkedModifier */) { + // empty modifier + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0); + node.value = ''; + endNode(node, offset, loc); + return { + nextConsumeToken: token, + node + }; + } + // check token + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.value = token.value || ''; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node + }; + } + function parseLinkedKey(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(7 /* NodeTypes.LinkedKey */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinked(tokenizer) { + const context = tokenizer.context(); + const linkedNode = startNode(6 /* NodeTypes.Linked */, context.offset, context.startLoc); + let token = tokenizer.nextToken(); + if (token.type === 9 /* TokenTypes.LinkedDot */) { + const parsed = parseLinkedModifier(tokenizer); + linkedNode.modifier = parsed.node; + token = parsed.nextConsumeToken || tokenizer.nextToken(); + } + // asset check token + if (token.type !== 10 /* TokenTypes.LinkedDelimiter */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + token = tokenizer.nextToken(); + // skip brace left + if (token.type === 2 /* TokenTypes.BraceLeft */) { + token = tokenizer.nextToken(); + } + switch (token.type) { + case 11 /* TokenTypes.LinkedKey */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseNamed(tokenizer, token.value || ''); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseList(tokenizer, token.value || ''); + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLiteral(tokenizer, token.value || ''); + break; + default: { + // empty key + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0); + const nextContext = tokenizer.context(); + const emptyLinkedKeyNode = startNode(7 /* NodeTypes.LinkedKey */, nextContext.offset, nextContext.startLoc); + emptyLinkedKeyNode.value = ''; + endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc); + linkedNode.key = emptyLinkedKeyNode; + endNode(linkedNode, nextContext.offset, nextContext.startLoc); + return { + nextConsumeToken: token, + node: linkedNode + }; + } + } + endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node: linkedNode + }; + } + function parseMessage(tokenizer) { + const context = tokenizer.context(); + const startOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? tokenizer.currentOffset() + : context.offset; + const startLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.endLoc + : context.startLoc; + const node = startNode(2 /* NodeTypes.Message */, startOffset, startLoc); + node.items = []; + let nextToken = null; + let modulo = null; + do { + const token = nextToken || tokenizer.nextToken(); + nextToken = null; + switch (token.type) { + case 0 /* TokenTypes.Text */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseText(tokenizer, token.value || '')); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseList(tokenizer, token.value || '')); + break; + case 4 /* TokenTypes.Modulo */: + modulo = true; + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseNamed(tokenizer, token.value || '', !!modulo)); + if (modulo) { + emitWarn(tokenizer, CompileWarnCodes.USE_MODULO_SYNTAX, context.lastStartLoc, 0, getTokenCaption(token)); + modulo = null; + } + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseLiteral(tokenizer, token.value || '')); + break; + case 8 /* TokenTypes.LinkedAlias */: { + const parsed = parseLinked(tokenizer); + node.items.push(parsed.node); + nextToken = parsed.nextConsumeToken || null; + break; + } + } + } while (context.currentType !== 14 /* TokenTypes.EOF */ && + context.currentType !== 1 /* TokenTypes.Pipe */); + // adjust message node loc + const endOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastOffset + : tokenizer.currentOffset(); + const endLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastEndLoc + : tokenizer.currentPosition(); + endNode(node, endOffset, endLoc); + return node; + } + function parsePlural(tokenizer, offset, loc, msgNode) { + const context = tokenizer.context(); + let hasEmptyMessage = msgNode.items.length === 0; + const node = startNode(1 /* NodeTypes.Plural */, offset, loc); + node.cases = []; + node.cases.push(msgNode); + do { + const msg = parseMessage(tokenizer); + if (!hasEmptyMessage) { + hasEmptyMessage = msg.items.length === 0; + } + node.cases.push(msg); + } while (context.currentType !== 14 /* TokenTypes.EOF */); + if (hasEmptyMessage) { + emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseResource(tokenizer) { + const context = tokenizer.context(); + const { offset, startLoc } = context; + const msgNode = parseMessage(tokenizer); + if (context.currentType === 14 /* TokenTypes.EOF */) { + return msgNode; + } + else { + return parsePlural(tokenizer, offset, startLoc, msgNode); + } + } + function parse(source) { + const tokenizer = createTokenizer(source, assign({}, options)); + const context = tokenizer.context(); + const node = startNode(0 /* NodeTypes.Resource */, context.offset, context.startLoc); + if (location && node.loc) { + node.loc.source = source; + } + node.body = parseResource(tokenizer); + if (options.onCacheKey) { + node.cacheKey = options.onCacheKey(source); + } + // assert whether achieved to EOF + if (context.currentType !== 14 /* TokenTypes.EOF */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || ''); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + return { parse }; +} +function getTokenCaption(token) { + if (token.type === 14 /* TokenTypes.EOF */) { + return 'EOF'; + } + const name = (token.value || '').replace(/\r?\n/gu, '\\n'); + return name.length > 10 ? name.slice(0, 9) + '…' : name; +} + +function createTransformer(ast, options = {} // eslint-disable-line +) { + const _context = { + ast, + helpers: new Set() + }; + const context = () => _context; + const helper = (name) => { + _context.helpers.add(name); + return name; + }; + return { context, helper }; +} +function traverseNodes(nodes, transformer) { + for (let i = 0; i < nodes.length; i++) { + traverseNode(nodes[i], transformer); + } +} +function traverseNode(node, transformer) { + // TODO: if we need pre-hook of transform, should be implemented to here + switch (node.type) { + case 1 /* NodeTypes.Plural */: + traverseNodes(node.cases, transformer); + transformer.helper("plural" /* HelperNameMap.PLURAL */); + break; + case 2 /* NodeTypes.Message */: + traverseNodes(node.items, transformer); + break; + case 6 /* NodeTypes.Linked */: { + const linked = node; + traverseNode(linked.key, transformer); + transformer.helper("linked" /* HelperNameMap.LINKED */); + transformer.helper("type" /* HelperNameMap.TYPE */); + break; + } + case 5 /* NodeTypes.List */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("list" /* HelperNameMap.LIST */); + break; + case 4 /* NodeTypes.Named */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("named" /* HelperNameMap.NAMED */); + break; + } + // TODO: if we need post-hook of transform, should be implemented to here +} +// transform AST +function transform(ast, options = {} // eslint-disable-line +) { + const transformer = createTransformer(ast); + transformer.helper("normalize" /* HelperNameMap.NORMALIZE */); + // traverse + ast.body && traverseNode(ast.body, transformer); + // set meta information + const context = transformer.context(); + ast.helpers = Array.from(context.helpers); +} + +function optimize(ast) { + const body = ast.body; + if (body.type === 2 /* NodeTypes.Message */) { + optimizeMessageNode(body); + } + else { + body.cases.forEach(c => optimizeMessageNode(c)); + } + return ast; +} +function optimizeMessageNode(message) { + if (message.items.length === 1) { + const item = message.items[0]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + message.static = item.value; + delete item.value; // optimization for size + } + } + else { + const values = []; + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (!(item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */)) { + break; + } + if (item.value == null) { + break; + } + values.push(item.value); + } + if (values.length === message.items.length) { + message.static = join(values); + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + delete item.value; // optimization for size + } + } + } + } +} + +const ERROR_DOMAIN$1 = 'minifier'; +/* eslint-disable @typescript-eslint/no-explicit-any */ +function minify(node) { + node.t = node.type; + switch (node.type) { + case 0 /* NodeTypes.Resource */: { + const resource = node; + minify(resource.body); + resource.b = resource.body; + delete resource.body; + break; + } + case 1 /* NodeTypes.Plural */: { + const plural = node; + const cases = plural.cases; + for (let i = 0; i < cases.length; i++) { + minify(cases[i]); + } + plural.c = cases; + delete plural.cases; + break; + } + case 2 /* NodeTypes.Message */: { + const message = node; + const items = message.items; + for (let i = 0; i < items.length; i++) { + minify(items[i]); + } + message.i = items; + delete message.items; + if (message.static) { + message.s = message.static; + delete message.static; + } + break; + } + case 3 /* NodeTypes.Text */: + case 9 /* NodeTypes.Literal */: + case 8 /* NodeTypes.LinkedModifier */: + case 7 /* NodeTypes.LinkedKey */: { + const valueNode = node; + if (valueNode.value) { + valueNode.v = valueNode.value; + delete valueNode.value; + } + break; + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + minify(linked.key); + linked.k = linked.key; + delete linked.key; + if (linked.modifier) { + minify(linked.modifier); + linked.m = linked.modifier; + delete linked.modifier; + } + break; + } + case 5 /* NodeTypes.List */: { + const list = node; + list.i = list.index; + delete list.index; + break; + } + case 4 /* NodeTypes.Named */: { + const named = node; + named.k = named.key; + delete named.key; + break; + } + default: + if ((process.env.NODE_ENV !== 'production')) { + throw createCompileError(CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE, null, { + domain: ERROR_DOMAIN$1, + args: [node.type] + }); + } + } + delete node.type; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +// eslint-disable-next-line @typescript-eslint/triple-slash-reference +/// +const ERROR_DOMAIN = 'parser'; +function createCodeGenerator(ast, options) { + const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options; + const location = options.location !== false; + const _context = { + filename, + code: '', + column: 1, + line: 1, + offset: 0, + map: undefined, + breakLineCode, + needIndent: _needIndent, + indentLevel: 0 + }; + if (location && ast.loc) { + _context.source = ast.loc.source; + } + const context = () => _context; + function push(code, node) { + _context.code += code; + if (_context.map) { + if (node && node.loc && node.loc !== LOCATION_STUB) { + addMapping(node.loc.start, getMappingName(node)); + } + advancePositionWithSource(_context, code); + } + } + function _newline(n, withBreakLine = true) { + const _breakLineCode = withBreakLine ? breakLineCode : ''; + push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode); + } + function indent(withNewLine = true) { + const level = ++_context.indentLevel; + withNewLine && _newline(level); + } + function deindent(withNewLine = true) { + const level = --_context.indentLevel; + withNewLine && _newline(level); + } + function newline() { + _newline(_context.indentLevel); + } + const helper = (key) => `_${key}`; + const needIndent = () => _context.needIndent; + function addMapping(loc, name) { + _context.map.addMapping({ + name, + source: _context.filename, + original: { + line: loc.line, + column: loc.column - 1 + }, + generated: { + line: _context.line, + column: _context.column - 1 + } + }); + } + if (location && sourceMap) { + _context.map = new SourceMapGenerator(); + _context.map.setSourceContent(filename, _context.source); + } + return { + context, + push, + indent, + deindent, + newline, + helper, + needIndent + }; +} +function generateLinkedNode(generator, node) { + const { helper } = generator; + generator.push(`${helper("linked" /* HelperNameMap.LINKED */)}(`); + generateNode(generator, node.key); + if (node.modifier) { + generator.push(`, `); + generateNode(generator, node.modifier); + generator.push(`, _type`); + } + else { + generator.push(`, undefined, _type`); + } + generator.push(`)`); +} +function generateMessageNode(generator, node) { + const { helper, needIndent } = generator; + generator.push(`${helper("normalize" /* HelperNameMap.NORMALIZE */)}([`); + generator.indent(needIndent()); + const length = node.items.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.items[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push('])'); +} +function generatePluralNode(generator, node) { + const { helper, needIndent } = generator; + if (node.cases.length > 1) { + generator.push(`${helper("plural" /* HelperNameMap.PLURAL */)}([`); + generator.indent(needIndent()); + const length = node.cases.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.cases[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push(`])`); + } +} +function generateResource(generator, node) { + if (node.body) { + generateNode(generator, node.body); + } + else { + generator.push('null'); + } +} +function generateNode(generator, node) { + const { helper } = generator; + switch (node.type) { + case 0 /* NodeTypes.Resource */: + generateResource(generator, node); + break; + case 1 /* NodeTypes.Plural */: + generatePluralNode(generator, node); + break; + case 2 /* NodeTypes.Message */: + generateMessageNode(generator, node); + break; + case 6 /* NodeTypes.Linked */: + generateLinkedNode(generator, node); + break; + case 8 /* NodeTypes.LinkedModifier */: + generator.push(JSON.stringify(node.value), node); + break; + case 7 /* NodeTypes.LinkedKey */: + generator.push(JSON.stringify(node.value), node); + break; + case 5 /* NodeTypes.List */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("list" /* HelperNameMap.LIST */)}(${node.index}))`, node); + break; + case 4 /* NodeTypes.Named */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("named" /* HelperNameMap.NAMED */)}(${JSON.stringify(node.key)}))`, node); + break; + case 9 /* NodeTypes.Literal */: + generator.push(JSON.stringify(node.value), node); + break; + case 3 /* NodeTypes.Text */: + generator.push(JSON.stringify(node.value), node); + break; + default: + if ((process.env.NODE_ENV !== 'production')) { + throw createCompileError(CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE, null, { + domain: ERROR_DOMAIN, + args: [node.type] + }); + } + } +} +// generate code from AST +const generate = (ast, options = {} // eslint-disable-line +) => { + const mode = isString(options.mode) ? options.mode : 'normal'; + const filename = isString(options.filename) + ? options.filename + : 'message.intl'; + const sourceMap = !!options.sourceMap; + // prettier-ignore + const breakLineCode = options.breakLineCode != null + ? options.breakLineCode + : mode === 'arrow' + ? ';' + : '\n'; + const needIndent = options.needIndent ? options.needIndent : mode !== 'arrow'; + const helpers = ast.helpers || []; + const generator = createCodeGenerator(ast, { + mode, + filename, + sourceMap, + breakLineCode, + needIndent + }); + generator.push(mode === 'normal' ? `function __msg__ (ctx) {` : `(ctx) => {`); + generator.indent(needIndent); + if (helpers.length > 0) { + generator.push(`const { ${join(helpers.map(s => `${s}: _${s}`), ', ')} } = ctx`); + generator.newline(); + } + generator.push(`return `); + generateNode(generator, ast); + generator.deindent(needIndent); + generator.push(`}`); + delete ast.helpers; + const { code, map } = generator.context(); + return { + ast, + code, + map: map ? map.toJSON() : undefined // eslint-disable-line @typescript-eslint/no-explicit-any + }; +}; +function getMappingName(node) { + switch (node.type) { + case 3 /* NodeTypes.Text */: + case 9 /* NodeTypes.Literal */: + case 8 /* NodeTypes.LinkedModifier */: + case 7 /* NodeTypes.LinkedKey */: + return node.value; + case 5 /* NodeTypes.List */: + return node.index.toString(); + case 4 /* NodeTypes.Named */: + return node.key; + default: + return undefined; + } +} +function advancePositionWithSource(pos, source, numberOfCharacters = source.length) { + let linesCount = 0; + let lastNewLinePos = -1; + for (let i = 0; i < numberOfCharacters; i++) { + if (source.charCodeAt(i) === 10 /* newline char code */) { + linesCount++; + lastNewLinePos = i; + } + } + pos.offset += numberOfCharacters; + pos.line += linesCount; + pos.column = + lastNewLinePos === -1 + ? pos.column + numberOfCharacters + : numberOfCharacters - lastNewLinePos; + return pos; +} + +function baseCompile(source, options = {}) { + const assignedOptions = assign({}, options); + const jit = !!assignedOptions.jit; + const enalbeMinify = !!assignedOptions.minify; + const enambeOptimize = assignedOptions.optimize == null ? true : assignedOptions.optimize; + // parse source codes + const parser = createParser(assignedOptions); + const ast = parser.parse(source); + if (!jit) { + // transform ASTs + transform(ast, assignedOptions); + // generate javascript codes + return generate(ast, assignedOptions); + } + else { + // optimize ASTs + enambeOptimize && optimize(ast); + // minimize ASTs + enalbeMinify && minify(ast); + // In JIT mode, no ast transform, no code generation. + return { ast, code: '' }; + } +} + +export { CompileErrorCodes, CompileWarnCodes, ERROR_DOMAIN$2 as ERROR_DOMAIN, LOCATION_STUB, baseCompile, createCompileError, createCompileWarn, createLocation, createParser, createPosition, defaultOnError, detectHtmlTag, errorMessages, warnMessages }; diff --git a/node_modules/@intlify/message-compiler/dist/message-compiler.prod.cjs b/node_modules/@intlify/message-compiler/dist/message-compiler.prod.cjs new file mode 100644 index 0000000..64828fe --- /dev/null +++ b/node_modules/@intlify/message-compiler/dist/message-compiler.prod.cjs @@ -0,0 +1,1657 @@ +/*! + * message-compiler v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +'use strict'; + +var shared = require('@intlify/shared'); +var sourceMapJs = require('source-map-js'); + +const LOCATION_STUB = { + start: { line: 1, column: 1, offset: 0 }, + end: { line: 1, column: 1, offset: 0 } +}; +function createPosition(line, column, offset) { + return { line, column, offset }; +} +function createLocation(start, end, source) { + const loc = { start, end }; + if (source != null) { + loc.source = source; + } + return loc; +} + +const CompileWarnCodes = { + USE_MODULO_SYNTAX: 1, + __EXTEND_POINT__: 2 +}; +/** @internal */ +const warnMessages = { + [CompileWarnCodes.USE_MODULO_SYNTAX]: `Use modulo before '{{0}}'.` +}; +function createCompileWarn(code, loc, ...args) { + const msg = code; + const message = { message: String(msg), code }; + if (loc) { + message.location = loc; + } + return message; +} + +const CompileErrorCodes = { + // tokenizer error codes + EXPECTED_TOKEN: 1, + INVALID_TOKEN_IN_PLACEHOLDER: 2, + UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3, + UNKNOWN_ESCAPE_SEQUENCE: 4, + INVALID_UNICODE_ESCAPE_SEQUENCE: 5, + UNBALANCED_CLOSING_BRACE: 6, + UNTERMINATED_CLOSING_BRACE: 7, + EMPTY_PLACEHOLDER: 8, + NOT_ALLOW_NEST_PLACEHOLDER: 9, + INVALID_LINKED_FORMAT: 10, + // parser error codes + MUST_HAVE_MESSAGES_IN_PLURAL: 11, + UNEXPECTED_EMPTY_LINKED_MODIFIER: 12, + UNEXPECTED_EMPTY_LINKED_KEY: 13, + UNEXPECTED_LEXICAL_ANALYSIS: 14, + // generator error codes + UNHANDLED_CODEGEN_NODE_TYPE: 15, + // minifier error codes + UNHANDLED_MINIFIER_NODE_TYPE: 16, + // Special value for higher-order compilers to pick up the last code + // to avoid collision of error codes. This should always be kept as the last + // item. + __EXTEND_POINT__: 17 +}; +/** @internal */ +const errorMessages = { + // tokenizer error messages + [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`, + [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`, + [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`, + [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`, + [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`, + [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`, + [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`, + [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`, + [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`, + [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`, + // parser error messages + [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`, + [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`, + // generator error messages + [CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`, + // minimizer error messages + [CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'` +}; +function createCompileError(code, loc, options = {}) { + const { domain, messages, args } = options; + const msg = code; + const error = new SyntaxError(String(msg)); + error.code = code; + if (loc) { + error.location = loc; + } + error.domain = domain; + return error; +} +/** @internal */ +function defaultOnError(error) { + throw error; +} + +// eslint-disable-next-line no-useless-escape +const RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/; +const detectHtmlTag = (source) => RE_HTML_TAG.test(source); + +const CHAR_SP = ' '; +const CHAR_CR = '\r'; +const CHAR_LF = '\n'; +const CHAR_LS = String.fromCharCode(0x2028); +const CHAR_PS = String.fromCharCode(0x2029); +function createScanner(str) { + const _buf = str; + let _index = 0; + let _line = 1; + let _column = 1; + let _peekOffset = 0; + const isCRLF = (index) => _buf[index] === CHAR_CR && _buf[index + 1] === CHAR_LF; + const isLF = (index) => _buf[index] === CHAR_LF; + const isPS = (index) => _buf[index] === CHAR_PS; + const isLS = (index) => _buf[index] === CHAR_LS; + const isLineEnd = (index) => isCRLF(index) || isLF(index) || isPS(index) || isLS(index); + const index = () => _index; + const line = () => _line; + const column = () => _column; + const peekOffset = () => _peekOffset; + const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset]; + const currentChar = () => charAt(_index); + const currentPeek = () => charAt(_index + _peekOffset); + function next() { + _peekOffset = 0; + if (isLineEnd(_index)) { + _line++; + _column = 0; + } + if (isCRLF(_index)) { + _index++; + } + _index++; + _column++; + return _buf[_index]; + } + function peek() { + if (isCRLF(_index + _peekOffset)) { + _peekOffset++; + } + _peekOffset++; + return _buf[_index + _peekOffset]; + } + function reset() { + _index = 0; + _line = 1; + _column = 1; + _peekOffset = 0; + } + function resetPeek(offset = 0) { + _peekOffset = offset; + } + function skipToPeek() { + const target = _index + _peekOffset; + // eslint-disable-next-line no-unmodified-loop-condition + while (target !== _index) { + next(); + } + _peekOffset = 0; + } + return { + index, + line, + column, + peekOffset, + charAt, + currentChar, + currentPeek, + next, + peek, + reset, + resetPeek, + skipToPeek + }; +} + +const EOF = undefined; +const DOT = '.'; +const LITERAL_DELIMITER = "'"; +const ERROR_DOMAIN$1 = 'tokenizer'; +function createTokenizer(source, options = {}) { + const location = options.location !== false; + const _scnr = createScanner(source); + const currentOffset = () => _scnr.index(); + const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index()); + const _initLoc = currentPosition(); + const _initOffset = currentOffset(); + const _context = { + currentType: 14 /* TokenTypes.EOF */, + offset: _initOffset, + startLoc: _initLoc, + endLoc: _initLoc, + lastType: 14 /* TokenTypes.EOF */, + lastOffset: _initOffset, + lastStartLoc: _initLoc, + lastEndLoc: _initLoc, + braceNest: 0, + inLinked: false, + text: '' + }; + const context = () => _context; + const { onError } = options; + function emitError(code, pos, offset, ...args) { + const ctx = context(); + pos.column += offset; + pos.offset += offset; + if (onError) { + const loc = location ? createLocation(ctx.startLoc, pos) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$1, + args + }); + onError(err); + } + } + function getToken(context, type, value) { + context.endLoc = currentPosition(); + context.currentType = type; + const token = { type }; + if (location) { + token.loc = createLocation(context.startLoc, context.endLoc); + } + if (value != null) { + token.value = value; + } + return token; + } + const getEndToken = (context) => getToken(context, 14 /* TokenTypes.EOF */); + function eat(scnr, ch) { + if (scnr.currentChar() === ch) { + scnr.next(); + return ch; + } + else { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + return ''; + } + } + function peekSpaces(scnr) { + let buf = ''; + while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) { + buf += scnr.currentPeek(); + scnr.peek(); + } + return buf; + } + function skipSpaces(scnr) { + const buf = peekSpaces(scnr); + scnr.skipToPeek(); + return buf; + } + function isIdentifierStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + cc === 95 // _ + ); + } + function isNumberStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function isNamedIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isListIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ch = scnr.currentPeek() === '-' ? scnr.peek() : scnr.currentPeek(); + const ret = isNumberStart(ch); + scnr.resetPeek(); + return ret; + } + function isLiteralStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === LITERAL_DELIMITER; + scnr.resetPeek(); + return ret; + } + function isLinkedDotStart(scnr, context) { + const { currentType } = context; + if (currentType !== 8 /* TokenTypes.LinkedAlias */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === "." /* TokenChars.LinkedDot */; + scnr.resetPeek(); + return ret; + } + function isLinkedModifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 9 /* TokenTypes.LinkedDot */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isLinkedDelimiterStart(scnr, context) { + const { currentType } = context; + if (!(currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 12 /* TokenTypes.LinkedModifier */)) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === ":" /* TokenChars.LinkedDelimiter */; + scnr.resetPeek(); + return ret; + } + function isLinkedReferStart(scnr, context) { + const { currentType } = context; + if (currentType !== 10 /* TokenTypes.LinkedDelimiter */) { + return false; + } + const fn = () => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return isIdentifierStart(scnr.peek()); + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "|" /* TokenChars.Pipe */ || + ch === ":" /* TokenChars.LinkedDelimiter */ || + ch === "." /* TokenChars.LinkedDot */ || + ch === CHAR_SP || + !ch) { + return false; + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(); + } + else { + // other characters + return isTextStart(scnr, false); + } + }; + const ret = fn(); + scnr.resetPeek(); + return ret; + } + function isPluralStart(scnr) { + peekSpaces(scnr); + const ret = scnr.currentPeek() === "|" /* TokenChars.Pipe */; + scnr.resetPeek(); + return ret; + } + function detectModuloStart(scnr) { + const spaces = peekSpaces(scnr); + const ret = scnr.currentPeek() === "%" /* TokenChars.Modulo */ && + scnr.peek() === "{" /* TokenChars.BraceLeft */; + scnr.resetPeek(); + return { + isModulo: ret, + hasSpace: spaces.length > 0 + }; + } + function isTextStart(scnr, reset = true) { + const fn = (hasSpace = false, prev = '', detectModulo = false) => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return prev === "%" /* TokenChars.Modulo */ ? false : hasSpace; + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || !ch) { + return prev === "%" /* TokenChars.Modulo */ ? true : hasSpace; + } + else if (ch === "%" /* TokenChars.Modulo */) { + scnr.peek(); + return fn(hasSpace, "%" /* TokenChars.Modulo */, true); + } + else if (ch === "|" /* TokenChars.Pipe */) { + return prev === "%" /* TokenChars.Modulo */ || detectModulo + ? true + : !(prev === CHAR_SP || prev === CHAR_LF); + } + else if (ch === CHAR_SP) { + scnr.peek(); + return fn(true, CHAR_SP, detectModulo); + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(true, CHAR_LF, detectModulo); + } + else { + return true; + } + }; + const ret = fn(); + reset && scnr.resetPeek(); + return ret; + } + function takeChar(scnr, fn) { + const ch = scnr.currentChar(); + if (ch === EOF) { + return EOF; + } + if (fn(ch)) { + scnr.next(); + return ch; + } + return null; + } + function isIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 // $ + ); + } + function takeIdentifierChar(scnr) { + return takeChar(scnr, isIdentifier); + } + function isNamedIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 || // $ + cc === 45 // - + ); + } + function takeNamedIdentifierChar(scnr) { + return takeChar(scnr, isNamedIdentifier); + } + function isDigit(ch) { + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function takeDigit(scnr) { + return takeChar(scnr, isDigit); + } + function isHexDigit(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 48 && cc <= 57) || // 0-9 + (cc >= 65 && cc <= 70) || // A-F + (cc >= 97 && cc <= 102)); // a-f + } + function takeHexDigit(scnr) { + return takeChar(scnr, isHexDigit); + } + function getDigits(scnr) { + let ch = ''; + let num = ''; + while ((ch = takeDigit(scnr))) { + num += ch; + } + return num; + } + function readModulo(scnr) { + skipSpaces(scnr); + const ch = scnr.currentChar(); + if (ch !== "%" /* TokenChars.Modulo */) { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + } + scnr.next(); + return "%" /* TokenChars.Modulo */; + } + function readText(scnr) { + let buf = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "}" /* TokenChars.BraceRight */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + !ch) { + break; + } + else if (ch === "%" /* TokenChars.Modulo */) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else { + break; + } + } + else if (ch === CHAR_SP || ch === CHAR_LF) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else if (isPluralStart(scnr)) { + break; + } + else { + buf += ch; + scnr.next(); + } + } + else { + buf += ch; + scnr.next(); + } + } + return buf; + } + function readNamedIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let name = ''; + while ((ch = takeNamedIdentifierChar(scnr))) { + name += ch; + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return name; + } + function readListIdentifier(scnr) { + skipSpaces(scnr); + let value = ''; + if (scnr.currentChar() === '-') { + scnr.next(); + value += `-${getDigits(scnr)}`; + } + else { + value += getDigits(scnr); + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return value; + } + function isLiteral(ch) { + return ch !== LITERAL_DELIMITER && ch !== CHAR_LF; + } + function readLiteral(scnr) { + skipSpaces(scnr); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + let ch = ''; + let literal = ''; + while ((ch = takeChar(scnr, isLiteral))) { + if (ch === '\\') { + literal += readEscapeSequence(scnr); + } + else { + literal += ch; + } + } + const current = scnr.currentChar(); + if (current === CHAR_LF || current === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, currentPosition(), 0); + // TODO: Is it correct really? + if (current === CHAR_LF) { + scnr.next(); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + } + return literal; + } + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + return literal; + } + function readEscapeSequence(scnr) { + const ch = scnr.currentChar(); + switch (ch) { + case '\\': + case `\'`: // eslint-disable-line no-useless-escape + scnr.next(); + return `\\${ch}`; + case 'u': + return readUnicodeEscapeSequence(scnr, ch, 4); + case 'U': + return readUnicodeEscapeSequence(scnr, ch, 6); + default: + emitError(CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, currentPosition(), 0, ch); + return ''; + } + } + function readUnicodeEscapeSequence(scnr, unicode, digits) { + eat(scnr, unicode); + let sequence = ''; + for (let i = 0; i < digits; i++) { + const ch = takeHexDigit(scnr); + if (!ch) { + emitError(CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`); + break; + } + sequence += ch; + } + return `\\${unicode}${sequence}`; + } + function isInvalidIdentifier(ch) { + return (ch !== "{" /* TokenChars.BraceLeft */ && + ch !== "}" /* TokenChars.BraceRight */ && + ch !== CHAR_SP && + ch !== CHAR_LF); + } + function readInvalidIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let identifiers = ''; + while ((ch = takeChar(scnr, isInvalidIdentifier))) { + identifiers += ch; + } + return identifiers; + } + function readLinkedModifier(scnr) { + let ch = ''; + let name = ''; + while ((ch = takeIdentifierChar(scnr))) { + name += ch; + } + return name; + } + function readLinkedRefer(scnr) { + const fn = (buf) => { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + ch === "(" /* TokenChars.ParenLeft */ || + ch === ")" /* TokenChars.ParenRight */ || + !ch) { + return buf; + } + else if (ch === CHAR_SP) { + return buf; + } + else if (ch === CHAR_LF || ch === DOT) { + buf += ch; + scnr.next(); + return fn(buf); + } + else { + buf += ch; + scnr.next(); + return fn(buf); + } + }; + return fn(''); + } + function readPlural(scnr) { + skipSpaces(scnr); + const plural = eat(scnr, "|" /* TokenChars.Pipe */); + skipSpaces(scnr); + return plural; + } + // TODO: We need refactoring of token parsing ... + function readTokenInPlaceholder(scnr, context) { + let token = null; + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + if (context.braceNest >= 1) { + emitError(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 2 /* TokenTypes.BraceLeft */, "{" /* TokenChars.BraceLeft */); + skipSpaces(scnr); + context.braceNest++; + return token; + case "}" /* TokenChars.BraceRight */: + if (context.braceNest > 0 && + context.currentType === 2 /* TokenTypes.BraceLeft */) { + emitError(CompileErrorCodes.EMPTY_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + context.braceNest--; + context.braceNest > 0 && skipSpaces(scnr); + if (context.inLinked && context.braceNest === 0) { + context.inLinked = false; + } + return token; + case "@" /* TokenChars.LinkedAlias */: + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = readTokenInLinked(scnr, context) || getEndToken(context); + context.braceNest = 0; + return token; + default: { + let validNamedIdentifier = true; + let validListIdentifier = true; + let validLiteral = true; + if (isPluralStart(scnr)) { + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (context.braceNest > 0 && + (context.currentType === 5 /* TokenTypes.Named */ || + context.currentType === 6 /* TokenTypes.List */ || + context.currentType === 7 /* TokenTypes.Literal */)) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + context.braceNest = 0; + return readToken(scnr, context); + } + if ((validNamedIdentifier = isNamedIdentifierStart(scnr, context))) { + token = getToken(context, 5 /* TokenTypes.Named */, readNamedIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validListIdentifier = isListIdentifierStart(scnr, context))) { + token = getToken(context, 6 /* TokenTypes.List */, readListIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validLiteral = isLiteralStart(scnr, context))) { + token = getToken(context, 7 /* TokenTypes.Literal */, readLiteral(scnr)); + skipSpaces(scnr); + return token; + } + if (!validNamedIdentifier && !validListIdentifier && !validLiteral) { + // TODO: we should be re-designed invalid cases, when we will extend message syntax near the future ... + token = getToken(context, 13 /* TokenTypes.InvalidPlace */, readInvalidIdentifier(scnr)); + emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value); + skipSpaces(scnr); + return token; + } + break; + } + } + return token; + } + // TODO: We need refactoring of token parsing ... + function readTokenInLinked(scnr, context) { + const { currentType } = context; + let token = null; + const ch = scnr.currentChar(); + if ((currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 9 /* TokenTypes.LinkedDot */ || + currentType === 12 /* TokenTypes.LinkedModifier */ || + currentType === 10 /* TokenTypes.LinkedDelimiter */) && + (ch === CHAR_LF || ch === CHAR_SP)) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + switch (ch) { + case "@" /* TokenChars.LinkedAlias */: + scnr.next(); + token = getToken(context, 8 /* TokenTypes.LinkedAlias */, "@" /* TokenChars.LinkedAlias */); + context.inLinked = true; + return token; + case "." /* TokenChars.LinkedDot */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 9 /* TokenTypes.LinkedDot */, "." /* TokenChars.LinkedDot */); + case ":" /* TokenChars.LinkedDelimiter */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 10 /* TokenTypes.LinkedDelimiter */, ":" /* TokenChars.LinkedDelimiter */); + default: + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (isLinkedDotStart(scnr, context) || + isLinkedDelimiterStart(scnr, context)) { + skipSpaces(scnr); + return readTokenInLinked(scnr, context); + } + if (isLinkedModifierStart(scnr, context)) { + skipSpaces(scnr); + return getToken(context, 12 /* TokenTypes.LinkedModifier */, readLinkedModifier(scnr)); + } + if (isLinkedReferStart(scnr, context)) { + skipSpaces(scnr); + if (ch === "{" /* TokenChars.BraceLeft */) { + // scan the placeholder + return readTokenInPlaceholder(scnr, context) || token; + } + else { + return getToken(context, 11 /* TokenTypes.LinkedKey */, readLinkedRefer(scnr)); + } + } + if (currentType === 8 /* TokenTypes.LinkedAlias */) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + context.braceNest = 0; + context.inLinked = false; + return readToken(scnr, context); + } + } + // TODO: We need refactoring of token parsing ... + function readToken(scnr, context) { + let token = { type: 14 /* TokenTypes.EOF */ }; + if (context.braceNest > 0) { + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + } + if (context.inLinked) { + return readTokenInLinked(scnr, context) || getEndToken(context); + } + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + case "}" /* TokenChars.BraceRight */: + emitError(CompileErrorCodes.UNBALANCED_CLOSING_BRACE, currentPosition(), 0); + scnr.next(); + return getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + case "@" /* TokenChars.LinkedAlias */: + return readTokenInLinked(scnr, context) || getEndToken(context); + default: { + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + const { isModulo, hasSpace } = detectModuloStart(scnr); + if (isModulo) { + return hasSpace + ? getToken(context, 0 /* TokenTypes.Text */, readText(scnr)) + : getToken(context, 4 /* TokenTypes.Modulo */, readModulo(scnr)); + } + if (isTextStart(scnr)) { + return getToken(context, 0 /* TokenTypes.Text */, readText(scnr)); + } + break; + } + } + return token; + } + function nextToken() { + const { currentType, offset, startLoc, endLoc } = _context; + _context.lastType = currentType; + _context.lastOffset = offset; + _context.lastStartLoc = startLoc; + _context.lastEndLoc = endLoc; + _context.offset = currentOffset(); + _context.startLoc = currentPosition(); + if (_scnr.currentChar() === EOF) { + return getToken(_context, 14 /* TokenTypes.EOF */); + } + return readToken(_scnr, _context); + } + return { + nextToken, + currentOffset, + currentPosition, + context + }; +} + +const ERROR_DOMAIN = 'parser'; +// Backslash backslash, backslash quote, uHHHH, UHHHHHH. +const KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g; +function fromEscapeSequence(match, codePoint4, codePoint6) { + switch (match) { + case `\\\\`: + return `\\`; + // eslint-disable-next-line no-useless-escape + case `\\\'`: + // eslint-disable-next-line no-useless-escape + return `\'`; + default: { + const codePoint = parseInt(codePoint4 || codePoint6, 16); + if (codePoint <= 0xd7ff || codePoint >= 0xe000) { + return String.fromCodePoint(codePoint); + } + // invalid ... + // Replace them with U+FFFD REPLACEMENT CHARACTER. + return '�'; + } + } +} +function createParser(options = {}) { + const location = options.location !== false; + const { onError, onWarn } = options; + function emitError(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onError) { + const loc = location ? createLocation(start, end) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN, + args + }); + onError(err); + } + } + function emitWarn(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onWarn) { + const loc = location ? createLocation(start, end) : null; + onWarn(createCompileWarn(code, loc, args)); + } + } + function startNode(type, offset, loc) { + const node = { type }; + if (location) { + node.start = offset; + node.end = offset; + node.loc = { start: loc, end: loc }; + } + return node; + } + function endNode(node, offset, pos, type) { + if (type) { + node.type = type; + } + if (location) { + node.end = offset; + if (node.loc) { + node.loc.end = pos; + } + } + } + function parseText(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(3 /* NodeTypes.Text */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseList(tokenizer, index) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(5 /* NodeTypes.List */, offset, loc); + node.index = parseInt(index, 10); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseNamed(tokenizer, key, modulo) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(4 /* NodeTypes.Named */, offset, loc); + node.key = key; + if (modulo === true) { + node.modulo = true; + } + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLiteral(tokenizer, value) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(9 /* NodeTypes.Literal */, offset, loc); + node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinkedModifier(tokenizer) { + const token = tokenizer.nextToken(); + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get linked dot loc + const node = startNode(8 /* NodeTypes.LinkedModifier */, offset, loc); + if (token.type !== 12 /* TokenTypes.LinkedModifier */) { + // empty modifier + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0); + node.value = ''; + endNode(node, offset, loc); + return { + nextConsumeToken: token, + node + }; + } + // check token + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.value = token.value || ''; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node + }; + } + function parseLinkedKey(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(7 /* NodeTypes.LinkedKey */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinked(tokenizer) { + const context = tokenizer.context(); + const linkedNode = startNode(6 /* NodeTypes.Linked */, context.offset, context.startLoc); + let token = tokenizer.nextToken(); + if (token.type === 9 /* TokenTypes.LinkedDot */) { + const parsed = parseLinkedModifier(tokenizer); + linkedNode.modifier = parsed.node; + token = parsed.nextConsumeToken || tokenizer.nextToken(); + } + // asset check token + if (token.type !== 10 /* TokenTypes.LinkedDelimiter */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + token = tokenizer.nextToken(); + // skip brace left + if (token.type === 2 /* TokenTypes.BraceLeft */) { + token = tokenizer.nextToken(); + } + switch (token.type) { + case 11 /* TokenTypes.LinkedKey */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseNamed(tokenizer, token.value || ''); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseList(tokenizer, token.value || ''); + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLiteral(tokenizer, token.value || ''); + break; + default: { + // empty key + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0); + const nextContext = tokenizer.context(); + const emptyLinkedKeyNode = startNode(7 /* NodeTypes.LinkedKey */, nextContext.offset, nextContext.startLoc); + emptyLinkedKeyNode.value = ''; + endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc); + linkedNode.key = emptyLinkedKeyNode; + endNode(linkedNode, nextContext.offset, nextContext.startLoc); + return { + nextConsumeToken: token, + node: linkedNode + }; + } + } + endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node: linkedNode + }; + } + function parseMessage(tokenizer) { + const context = tokenizer.context(); + const startOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? tokenizer.currentOffset() + : context.offset; + const startLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.endLoc + : context.startLoc; + const node = startNode(2 /* NodeTypes.Message */, startOffset, startLoc); + node.items = []; + let nextToken = null; + let modulo = null; + do { + const token = nextToken || tokenizer.nextToken(); + nextToken = null; + switch (token.type) { + case 0 /* TokenTypes.Text */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseText(tokenizer, token.value || '')); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseList(tokenizer, token.value || '')); + break; + case 4 /* TokenTypes.Modulo */: + modulo = true; + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseNamed(tokenizer, token.value || '', !!modulo)); + if (modulo) { + emitWarn(tokenizer, CompileWarnCodes.USE_MODULO_SYNTAX, context.lastStartLoc, 0, getTokenCaption(token)); + modulo = null; + } + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseLiteral(tokenizer, token.value || '')); + break; + case 8 /* TokenTypes.LinkedAlias */: { + const parsed = parseLinked(tokenizer); + node.items.push(parsed.node); + nextToken = parsed.nextConsumeToken || null; + break; + } + } + } while (context.currentType !== 14 /* TokenTypes.EOF */ && + context.currentType !== 1 /* TokenTypes.Pipe */); + // adjust message node loc + const endOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastOffset + : tokenizer.currentOffset(); + const endLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastEndLoc + : tokenizer.currentPosition(); + endNode(node, endOffset, endLoc); + return node; + } + function parsePlural(tokenizer, offset, loc, msgNode) { + const context = tokenizer.context(); + let hasEmptyMessage = msgNode.items.length === 0; + const node = startNode(1 /* NodeTypes.Plural */, offset, loc); + node.cases = []; + node.cases.push(msgNode); + do { + const msg = parseMessage(tokenizer); + if (!hasEmptyMessage) { + hasEmptyMessage = msg.items.length === 0; + } + node.cases.push(msg); + } while (context.currentType !== 14 /* TokenTypes.EOF */); + if (hasEmptyMessage) { + emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseResource(tokenizer) { + const context = tokenizer.context(); + const { offset, startLoc } = context; + const msgNode = parseMessage(tokenizer); + if (context.currentType === 14 /* TokenTypes.EOF */) { + return msgNode; + } + else { + return parsePlural(tokenizer, offset, startLoc, msgNode); + } + } + function parse(source) { + const tokenizer = createTokenizer(source, shared.assign({}, options)); + const context = tokenizer.context(); + const node = startNode(0 /* NodeTypes.Resource */, context.offset, context.startLoc); + if (location && node.loc) { + node.loc.source = source; + } + node.body = parseResource(tokenizer); + if (options.onCacheKey) { + node.cacheKey = options.onCacheKey(source); + } + // assert whether achieved to EOF + if (context.currentType !== 14 /* TokenTypes.EOF */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || ''); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + return { parse }; +} +function getTokenCaption(token) { + if (token.type === 14 /* TokenTypes.EOF */) { + return 'EOF'; + } + const name = (token.value || '').replace(/\r?\n/gu, '\\n'); + return name.length > 10 ? name.slice(0, 9) + '…' : name; +} + +function createTransformer(ast, options = {} // eslint-disable-line +) { + const _context = { + ast, + helpers: new Set() + }; + const context = () => _context; + const helper = (name) => { + _context.helpers.add(name); + return name; + }; + return { context, helper }; +} +function traverseNodes(nodes, transformer) { + for (let i = 0; i < nodes.length; i++) { + traverseNode(nodes[i], transformer); + } +} +function traverseNode(node, transformer) { + // TODO: if we need pre-hook of transform, should be implemented to here + switch (node.type) { + case 1 /* NodeTypes.Plural */: + traverseNodes(node.cases, transformer); + transformer.helper("plural" /* HelperNameMap.PLURAL */); + break; + case 2 /* NodeTypes.Message */: + traverseNodes(node.items, transformer); + break; + case 6 /* NodeTypes.Linked */: { + const linked = node; + traverseNode(linked.key, transformer); + transformer.helper("linked" /* HelperNameMap.LINKED */); + transformer.helper("type" /* HelperNameMap.TYPE */); + break; + } + case 5 /* NodeTypes.List */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("list" /* HelperNameMap.LIST */); + break; + case 4 /* NodeTypes.Named */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("named" /* HelperNameMap.NAMED */); + break; + } + // TODO: if we need post-hook of transform, should be implemented to here +} +// transform AST +function transform(ast, options = {} // eslint-disable-line +) { + const transformer = createTransformer(ast); + transformer.helper("normalize" /* HelperNameMap.NORMALIZE */); + // traverse + ast.body && traverseNode(ast.body, transformer); + // set meta information + const context = transformer.context(); + ast.helpers = Array.from(context.helpers); +} + +function optimize(ast) { + const body = ast.body; + if (body.type === 2 /* NodeTypes.Message */) { + optimizeMessageNode(body); + } + else { + body.cases.forEach(c => optimizeMessageNode(c)); + } + return ast; +} +function optimizeMessageNode(message) { + if (message.items.length === 1) { + const item = message.items[0]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + message.static = item.value; + delete item.value; // optimization for size + } + } + else { + const values = []; + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (!(item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */)) { + break; + } + if (item.value == null) { + break; + } + values.push(item.value); + } + if (values.length === message.items.length) { + message.static = shared.join(values); + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + delete item.value; // optimization for size + } + } + } + } +} + +/* eslint-disable @typescript-eslint/no-explicit-any */ +function minify(node) { + node.t = node.type; + switch (node.type) { + case 0 /* NodeTypes.Resource */: { + const resource = node; + minify(resource.body); + resource.b = resource.body; + delete resource.body; + break; + } + case 1 /* NodeTypes.Plural */: { + const plural = node; + const cases = plural.cases; + for (let i = 0; i < cases.length; i++) { + minify(cases[i]); + } + plural.c = cases; + delete plural.cases; + break; + } + case 2 /* NodeTypes.Message */: { + const message = node; + const items = message.items; + for (let i = 0; i < items.length; i++) { + minify(items[i]); + } + message.i = items; + delete message.items; + if (message.static) { + message.s = message.static; + delete message.static; + } + break; + } + case 3 /* NodeTypes.Text */: + case 9 /* NodeTypes.Literal */: + case 8 /* NodeTypes.LinkedModifier */: + case 7 /* NodeTypes.LinkedKey */: { + const valueNode = node; + if (valueNode.value) { + valueNode.v = valueNode.value; + delete valueNode.value; + } + break; + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + minify(linked.key); + linked.k = linked.key; + delete linked.key; + if (linked.modifier) { + minify(linked.modifier); + linked.m = linked.modifier; + delete linked.modifier; + } + break; + } + case 5 /* NodeTypes.List */: { + const list = node; + list.i = list.index; + delete list.index; + break; + } + case 4 /* NodeTypes.Named */: { + const named = node; + named.k = named.key; + delete named.key; + break; + } + } + delete node.type; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +// eslint-disable-next-line @typescript-eslint/triple-slash-reference +/// +function createCodeGenerator(ast, options) { + const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options; + const location = options.location !== false; + const _context = { + filename, + code: '', + column: 1, + line: 1, + offset: 0, + map: undefined, + breakLineCode, + needIndent: _needIndent, + indentLevel: 0 + }; + if (location && ast.loc) { + _context.source = ast.loc.source; + } + const context = () => _context; + function push(code, node) { + _context.code += code; + if (_context.map) { + if (node && node.loc && node.loc !== LOCATION_STUB) { + addMapping(node.loc.start, getMappingName(node)); + } + advancePositionWithSource(_context, code); + } + } + function _newline(n, withBreakLine = true) { + const _breakLineCode = withBreakLine ? breakLineCode : ''; + push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode); + } + function indent(withNewLine = true) { + const level = ++_context.indentLevel; + withNewLine && _newline(level); + } + function deindent(withNewLine = true) { + const level = --_context.indentLevel; + withNewLine && _newline(level); + } + function newline() { + _newline(_context.indentLevel); + } + const helper = (key) => `_${key}`; + const needIndent = () => _context.needIndent; + function addMapping(loc, name) { + _context.map.addMapping({ + name, + source: _context.filename, + original: { + line: loc.line, + column: loc.column - 1 + }, + generated: { + line: _context.line, + column: _context.column - 1 + } + }); + } + if (location && sourceMap) { + _context.map = new sourceMapJs.SourceMapGenerator(); + _context.map.setSourceContent(filename, _context.source); + } + return { + context, + push, + indent, + deindent, + newline, + helper, + needIndent + }; +} +function generateLinkedNode(generator, node) { + const { helper } = generator; + generator.push(`${helper("linked" /* HelperNameMap.LINKED */)}(`); + generateNode(generator, node.key); + if (node.modifier) { + generator.push(`, `); + generateNode(generator, node.modifier); + generator.push(`, _type`); + } + else { + generator.push(`, undefined, _type`); + } + generator.push(`)`); +} +function generateMessageNode(generator, node) { + const { helper, needIndent } = generator; + generator.push(`${helper("normalize" /* HelperNameMap.NORMALIZE */)}([`); + generator.indent(needIndent()); + const length = node.items.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.items[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push('])'); +} +function generatePluralNode(generator, node) { + const { helper, needIndent } = generator; + if (node.cases.length > 1) { + generator.push(`${helper("plural" /* HelperNameMap.PLURAL */)}([`); + generator.indent(needIndent()); + const length = node.cases.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.cases[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push(`])`); + } +} +function generateResource(generator, node) { + if (node.body) { + generateNode(generator, node.body); + } + else { + generator.push('null'); + } +} +function generateNode(generator, node) { + const { helper } = generator; + switch (node.type) { + case 0 /* NodeTypes.Resource */: + generateResource(generator, node); + break; + case 1 /* NodeTypes.Plural */: + generatePluralNode(generator, node); + break; + case 2 /* NodeTypes.Message */: + generateMessageNode(generator, node); + break; + case 6 /* NodeTypes.Linked */: + generateLinkedNode(generator, node); + break; + case 8 /* NodeTypes.LinkedModifier */: + generator.push(JSON.stringify(node.value), node); + break; + case 7 /* NodeTypes.LinkedKey */: + generator.push(JSON.stringify(node.value), node); + break; + case 5 /* NodeTypes.List */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("list" /* HelperNameMap.LIST */)}(${node.index}))`, node); + break; + case 4 /* NodeTypes.Named */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("named" /* HelperNameMap.NAMED */)}(${JSON.stringify(node.key)}))`, node); + break; + case 9 /* NodeTypes.Literal */: + generator.push(JSON.stringify(node.value), node); + break; + case 3 /* NodeTypes.Text */: + generator.push(JSON.stringify(node.value), node); + break; + } +} +// generate code from AST +const generate = (ast, options = {} // eslint-disable-line +) => { + const mode = shared.isString(options.mode) ? options.mode : 'normal'; + const filename = shared.isString(options.filename) + ? options.filename + : 'message.intl'; + const sourceMap = !!options.sourceMap; + // prettier-ignore + const breakLineCode = options.breakLineCode != null + ? options.breakLineCode + : mode === 'arrow' + ? ';' + : '\n'; + const needIndent = options.needIndent ? options.needIndent : mode !== 'arrow'; + const helpers = ast.helpers || []; + const generator = createCodeGenerator(ast, { + mode, + filename, + sourceMap, + breakLineCode, + needIndent + }); + generator.push(mode === 'normal' ? `function __msg__ (ctx) {` : `(ctx) => {`); + generator.indent(needIndent); + if (helpers.length > 0) { + generator.push(`const { ${shared.join(helpers.map(s => `${s}: _${s}`), ', ')} } = ctx`); + generator.newline(); + } + generator.push(`return `); + generateNode(generator, ast); + generator.deindent(needIndent); + generator.push(`}`); + delete ast.helpers; + const { code, map } = generator.context(); + return { + ast, + code, + map: map ? map.toJSON() : undefined // eslint-disable-line @typescript-eslint/no-explicit-any + }; +}; +function getMappingName(node) { + switch (node.type) { + case 3 /* NodeTypes.Text */: + case 9 /* NodeTypes.Literal */: + case 8 /* NodeTypes.LinkedModifier */: + case 7 /* NodeTypes.LinkedKey */: + return node.value; + case 5 /* NodeTypes.List */: + return node.index.toString(); + case 4 /* NodeTypes.Named */: + return node.key; + default: + return undefined; + } +} +function advancePositionWithSource(pos, source, numberOfCharacters = source.length) { + let linesCount = 0; + let lastNewLinePos = -1; + for (let i = 0; i < numberOfCharacters; i++) { + if (source.charCodeAt(i) === 10 /* newline char code */) { + linesCount++; + lastNewLinePos = i; + } + } + pos.offset += numberOfCharacters; + pos.line += linesCount; + pos.column = + lastNewLinePos === -1 + ? pos.column + numberOfCharacters + : numberOfCharacters - lastNewLinePos; + return pos; +} + +function baseCompile(source, options = {}) { + const assignedOptions = shared.assign({}, options); + const jit = !!assignedOptions.jit; + const enalbeMinify = !!assignedOptions.minify; + const enambeOptimize = assignedOptions.optimize == null ? true : assignedOptions.optimize; + // parse source codes + const parser = createParser(assignedOptions); + const ast = parser.parse(source); + if (!jit) { + // transform ASTs + transform(ast, assignedOptions); + // generate javascript codes + return generate(ast, assignedOptions); + } + else { + // optimize ASTs + enambeOptimize && optimize(ast); + // minimize ASTs + enalbeMinify && minify(ast); + // In JIT mode, no ast transform, no code generation. + return { ast, code: '' }; + } +} + +exports.CompileErrorCodes = CompileErrorCodes; +exports.CompileWarnCodes = CompileWarnCodes; +exports.ERROR_DOMAIN = ERROR_DOMAIN; +exports.LOCATION_STUB = LOCATION_STUB; +exports.baseCompile = baseCompile; +exports.createCompileError = createCompileError; +exports.createCompileWarn = createCompileWarn; +exports.createLocation = createLocation; +exports.createParser = createParser; +exports.createPosition = createPosition; +exports.defaultOnError = defaultOnError; +exports.detectHtmlTag = detectHtmlTag; +exports.errorMessages = errorMessages; +exports.warnMessages = warnMessages; diff --git a/node_modules/@intlify/message-compiler/index.js b/node_modules/@intlify/message-compiler/index.js new file mode 100644 index 0000000..5109c76 --- /dev/null +++ b/node_modules/@intlify/message-compiler/index.js @@ -0,0 +1,7 @@ +'use strict' + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./dist/message-compiler.prod.cjs') +} else { + module.exports = require('./dist/message-compiler.cjs') +} diff --git a/node_modules/@intlify/message-compiler/package.json b/node_modules/@intlify/message-compiler/package.json new file mode 100644 index 0000000..392d9ac --- /dev/null +++ b/node_modules/@intlify/message-compiler/package.json @@ -0,0 +1,79 @@ +{ + "name": "@intlify/message-compiler", + "version": "9.14.5", + "description": "@intlify/message-compiler", + "keywords": [ + "compiler", + "i18n", + "internationalization", + "intlify", + "message-format" + ], + "license": "MIT", + "author": { + "name": "kazuya kawaguchi", + "email": "kawakazu80@gmail.com" + }, + "homepage": "https://github.com/intlify/vue-i18n/tree/master/packages/message-compiler#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/intlify/vue-i18n.git", + "directory": "packages/message-compiler" + }, + "bugs": { + "url": "https://github.com/intlify/vue-i18n/issues" + }, + "files": [ + "index.js", + "dist" + ], + "main": "index.js", + "module": "dist/message-compiler.mjs", + "unpkg": "dist/message-compiler.global.js", + "jsdelivr": "dist/message-compiler.global.js", + "types": "dist/message-compiler.d.ts", + "dependencies": { + "source-map-js": "^1.0.2", + "@intlify/shared": "9.14.5" + }, + "engines": { + "node": ">= 16" + }, + "buildOptions": { + "name": "IntlifyMessageCompiler", + "formats": [ + "mjs", + "mjs-node", + "browser", + "cjs", + "global" + ], + "enableFullBundleForEsmBrowser": true + }, + "exports": { + ".": { + "types": "./dist/message-compiler.d.ts", + "browser": "./dist/message-compiler.esm-browser.js", + "node": { + "import": { + "production": "./dist/message-compiler.node.mjs", + "development": "./dist/message-compiler.node.mjs", + "default": "./dist/message-compiler.node.mjs" + }, + "require": { + "production": "./dist/message-compiler.prod.cjs", + "development": "./dist/message-compiler.cjs", + "default": "./index.js" + } + }, + "import": "./dist/message-compiler.mjs" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" + }, + "funding": "https://github.com/sponsors/kazupon", + "publishConfig": { + "access": "public" + }, + "sideEffects": false +} \ No newline at end of file diff --git a/node_modules/@intlify/shared/LICENSE b/node_modules/@intlify/shared/LICENSE new file mode 100644 index 0000000..c02ff3e --- /dev/null +++ b/node_modules/@intlify/shared/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2020 kazuya kawaguchi + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/@intlify/shared/README.md b/node_modules/@intlify/shared/README.md new file mode 100644 index 0000000..5cf0556 --- /dev/null +++ b/node_modules/@intlify/shared/README.md @@ -0,0 +1,18 @@ +# @intlify/shared + +The shared utility package for intlify project + +## Forks +The implementation of this module is contains code forked from other packages or projects: + +- [@vue/shared](https://github.com/vuejs/vue-next/tree/master/packages/shared) + - Useful Utilities at `utils.ts` + - Author: Evan You + - License: MIT + - Event Emitter at `emitter.ts` and `emittable.ts` + - Author: Jason Miller + - License: MIT + +## :copyright: License + +[MIT](http://opensource.org/licenses/MIT) diff --git a/node_modules/@intlify/shared/dist/shared.cjs b/node_modules/@intlify/shared/dist/shared.cjs new file mode 100644 index 0000000..483d83f --- /dev/null +++ b/node_modules/@intlify/shared/dist/shared.cjs @@ -0,0 +1,324 @@ +/*! + * shared v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +'use strict'; + +function warn(msg, err) { + if (typeof console !== 'undefined') { + console.warn(`[intlify] ` + msg); + /* istanbul ignore if */ + if (err) { + console.warn(err.stack); + } + } +} +const hasWarned = {}; +function warnOnce(msg) { + if (!hasWarned[msg]) { + hasWarned[msg] = true; + warn(msg); + } +} + +/** + * Original Utilities + * written by kazuya kawaguchi + */ +const inBrowser = typeof window !== 'undefined'; +exports.mark = void 0; +exports.measure = void 0; +{ + const perf = inBrowser && window.performance; + if (perf && + perf.mark && + perf.measure && + perf.clearMarks && + // @ts-ignore browser compat + perf.clearMeasures) { + exports.mark = (tag) => { + perf.mark(tag); + }; + exports.measure = (name, startTag, endTag) => { + perf.measure(name, startTag, endTag); + perf.clearMarks(startTag); + perf.clearMarks(endTag); + }; + } +} +const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g; +/* eslint-disable */ +function format(message, ...args) { + if (args.length === 1 && isObject(args[0])) { + args = args[0]; + } + if (!args || !args.hasOwnProperty) { + args = {}; + } + return message.replace(RE_ARGS, (match, identifier) => { + return args.hasOwnProperty(identifier) ? args[identifier] : ''; + }); +} +const makeSymbol = (name, shareable = false) => !shareable ? Symbol(name) : Symbol.for(name); +const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({ l: locale, k: key, s: source }); +const friendlyJSONstringify = (json) => JSON.stringify(json) + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029') + .replace(/\u0027/g, '\\u0027'); +const isNumber = (val) => typeof val === 'number' && isFinite(val); +const isDate = (val) => toTypeString(val) === '[object Date]'; +const isRegExp = (val) => toTypeString(val) === '[object RegExp]'; +const isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0; +const assign = Object.assign; +const _create = Object.create; +const create = (obj = null) => _create(obj); +let _globalThis; +const getGlobalThis = () => { + // prettier-ignore + return (_globalThis || + (_globalThis = + typeof globalThis !== 'undefined' + ? globalThis + : typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : create())); +}; +function escapeHtml(rawText) { + return rawText + .replace(/&/g, '&') // escape `&` first to avoid double escaping + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/\//g, '/') // escape `/` to prevent closing tags or JavaScript URLs + .replace(/=/g, '='); // escape `=` to prevent attribute injection +} +function escapeAttributeValue(value) { + return value + .replace(/&(?![a-zA-Z0-9#]{2,6};)/g, '&') // escape unescaped `&` + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(//g, '>'); +} +function sanitizeTranslatedHtml(html) { + // Escape dangerous characters in attribute values + // Process attributes with double quotes + html = html.replace(/(\w+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${escapeAttributeValue(attrValue)}"`); + // Process attributes with single quotes + html = html.replace(/(\w+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${escapeAttributeValue(attrValue)}'`); + // Detect and neutralize event handler attributes + const eventHandlerPattern = /\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi; + if (eventHandlerPattern.test(html)) { + { + warn('Potentially dangerous event handlers detected in translation. ' + + 'Consider removing onclick, onerror, etc. from your translation messages.'); + } + // Neutralize event handler attributes by escaping 'on' + html = html.replace(/(\s+)(on)(\w+\s*=)/gi, '$1on$3'); + } + // Disable javascript: URLs in various contexts + const javascriptUrlPattern = [ + // In href, src, action, formaction attributes + /(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi, + // In style attributes within url() + /(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi + ]; + javascriptUrlPattern.forEach(pattern => { + html = html.replace(pattern, '$1javascript:'); + }); + return html; +} +const hasOwnProperty = Object.prototype.hasOwnProperty; +function hasOwn(obj, key) { + return hasOwnProperty.call(obj, key); +} +/* eslint-enable */ +/** + * Useful Utilities By Evan you + * Modified by kazuya kawaguchi + * MIT License + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts + */ +const isArray = Array.isArray; +const isFunction = (val) => typeof val === 'function'; +const isString = (val) => typeof val === 'string'; +const isBoolean = (val) => typeof val === 'boolean'; +const isSymbol = (val) => typeof val === 'symbol'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isObject = (val) => val !== null && typeof val === 'object'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isPromise = (val) => { + return isObject(val) && isFunction(val.then) && isFunction(val.catch); +}; +const objectToString = Object.prototype.toString; +const toTypeString = (value) => objectToString.call(value); +const isPlainObject = (val) => { + if (!isObject(val)) + return false; + const proto = Object.getPrototypeOf(val); + return proto === null || proto.constructor === Object; +}; +// for converting list and named values to displayed strings. +const toDisplayString = (val) => { + return val == null + ? '' + : isArray(val) || (isPlainObject(val) && val.toString === objectToString) + ? JSON.stringify(val, null, 2) + : String(val); +}; +function join(items, separator = '') { + return items.reduce((str, item, index) => (index === 0 ? str + item : str + separator + item), ''); +} +const RANGE = 2; +function generateCodeFrame(source, start = 0, end = source.length) { + const lines = source.split(/\r?\n/); + let count = 0; + const res = []; + for (let i = 0; i < lines.length; i++) { + count += lines[i].length + 1; + if (count >= start) { + for (let j = i - RANGE; j <= i + RANGE || end > count; j++) { + if (j < 0 || j >= lines.length) + continue; + const line = j + 1; + res.push(`${line}${' '.repeat(3 - String(line).length)}| ${lines[j]}`); + const lineLength = lines[j].length; + if (j === i) { + // push underline + const pad = start - (count - lineLength) + 1; + const length = Math.max(1, end > count ? lineLength - pad : end - start); + res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length)); + } + else if (j > i) { + if (end > count) { + const length = Math.max(Math.min(end - count, lineLength), 1); + res.push(` | ` + '^'.repeat(length)); + } + count += lineLength + 1; + } + } + break; + } + } + return res.join('\n'); +} +function incrementer(code) { + let current = code; + return () => ++current; +} + +/** + * Event emitter, forked from the below: + * - original repository url: https://github.com/developit/mitt + * - code url: https://github.com/developit/mitt/blob/master/src/index.ts + * - author: Jason Miller (https://github.com/developit) + * - license: MIT + */ +/** + * Create a event emitter + * + * @returns An event emitter + */ +function createEmitter() { + const events = new Map(); + const emitter = { + events, + on(event, handler) { + const handlers = events.get(event); + const added = handlers && handlers.push(handler); + if (!added) { + events.set(event, [handler]); + } + }, + off(event, handler) { + const handlers = events.get(event); + if (handlers) { + handlers.splice(handlers.indexOf(handler) >>> 0, 1); + } + }, + emit(event, payload) { + (events.get(event) || []) + .slice() + .map(handler => handler(payload)); + (events.get('*') || []) + .slice() + .map(handler => handler(event, payload)); + } + }; + return emitter; +} + +const isNotObjectOrIsArray = (val) => !isObject(val) || isArray(val); +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types +function deepCopy(src, des) { + // src and des should both be objects, and none of them can be a array + if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des)) { + throw new Error('Invalid value'); + } + const stack = [{ src, des }]; + while (stack.length) { + const { src, des } = stack.pop(); + // using `Object.keys` which skips prototype properties + Object.keys(src).forEach(key => { + if (key === '__proto__') { + return; + } + // if src[key] is an object/array, set des[key] + // to empty object/array to prevent setting by reference + if (isObject(src[key]) && !isObject(des[key])) { + des[key] = Array.isArray(src[key]) ? [] : create(); + } + if (isNotObjectOrIsArray(des[key]) || isNotObjectOrIsArray(src[key])) { + // replace with src[key] when: + // src[key] or des[key] is not an object, or + // src[key] or des[key] is an array + des[key] = src[key]; + } + else { + // src[key] and des[key] are both objects, merge them + stack.push({ src: src[key], des: des[key] }); + } + }); + } +} + +exports.assign = assign; +exports.create = create; +exports.createEmitter = createEmitter; +exports.deepCopy = deepCopy; +exports.escapeHtml = escapeHtml; +exports.format = format; +exports.friendlyJSONstringify = friendlyJSONstringify; +exports.generateCodeFrame = generateCodeFrame; +exports.generateFormatCacheKey = generateFormatCacheKey; +exports.getGlobalThis = getGlobalThis; +exports.hasOwn = hasOwn; +exports.inBrowser = inBrowser; +exports.incrementer = incrementer; +exports.isArray = isArray; +exports.isBoolean = isBoolean; +exports.isDate = isDate; +exports.isEmptyObject = isEmptyObject; +exports.isFunction = isFunction; +exports.isNumber = isNumber; +exports.isObject = isObject; +exports.isPlainObject = isPlainObject; +exports.isPromise = isPromise; +exports.isRegExp = isRegExp; +exports.isString = isString; +exports.isSymbol = isSymbol; +exports.join = join; +exports.makeSymbol = makeSymbol; +exports.objectToString = objectToString; +exports.sanitizeTranslatedHtml = sanitizeTranslatedHtml; +exports.toDisplayString = toDisplayString; +exports.toTypeString = toTypeString; +exports.warn = warn; +exports.warnOnce = warnOnce; diff --git a/node_modules/@intlify/shared/dist/shared.cjs.js b/node_modules/@intlify/shared/dist/shared.cjs.js new file mode 100644 index 0000000..565b49e --- /dev/null +++ b/node_modules/@intlify/shared/dist/shared.cjs.js @@ -0,0 +1 @@ +module.exports = require('../dist/shared.cjs') \ No newline at end of file diff --git a/node_modules/@intlify/shared/dist/shared.cjs.prod.js b/node_modules/@intlify/shared/dist/shared.cjs.prod.js new file mode 100644 index 0000000..9bd213d --- /dev/null +++ b/node_modules/@intlify/shared/dist/shared.cjs.prod.js @@ -0,0 +1 @@ +module.exports = require('../dist/shared.prod.cjs') \ No newline at end of file diff --git a/node_modules/@intlify/shared/dist/shared.d.ts b/node_modules/@intlify/shared/dist/shared.d.ts new file mode 100644 index 0000000..c765f6f --- /dev/null +++ b/node_modules/@intlify/shared/dist/shared.d.ts @@ -0,0 +1,161 @@ + +export declare const assign: { + (target: T, source: U): T & U; + (target: T_1, source1: U_1, source2: V): T_1 & U_1 & V; + (target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W; + (target: object, ...sources: any[]): any; +}; + +export declare interface BaseError { + code: number; +} + +export declare const create: (obj?: object | null) => object; + +/** + * Create a event emitter + * + * @returns An event emitter + */ +export declare function createEmitter>(): Emittable; + +export declare function deepCopy(src: any, des: any): void; + +/** + * Event emitter interface + */ +export declare interface Emittable = {}> { + /** + * A map of event names of registered event handlers + */ + events: EventHandlerMap; + /** + * Register an event handler with the event type + * + * @param event - An {@link EventType} + * @param handler - An {@link EventHandler}, or a {@link WildcardEventHandler} if you are specified "*" + */ + on(event: Key | '*', handler: EventHandler | WildcardEventHandler): void; + /** + * Unregister an event handler for the event type + * + * @param event - An {@link EventType} + * @param handler - An {@link EventHandler}, or a {@link WildcardEventHandler} if you are specified "*" + */ + off(event: Key | '*', handler: EventHandler | WildcardEventHandler): void; + /** + * Invoke all handlers with the event type + * + * @remarks + * Note Manually firing "*" handlers should be not supported + * + * @param event - An {@link EventType} + * @param payload - An event payload, optional + */ + emit(event: Key, payload?: Events[keyof Events]): void; +} + +export declare function escapeHtml(rawText: string): string; + +/** + * Event handler + */ +export declare type EventHandler = (payload?: T) => void; + +/** + * Event handler list + */ +export declare type EventHandlerList = Array>; + +/** + * Event handler map + */ +export declare type EventHandlerMap> = Map | WildcardEventHandlerList>; + +/** + * Event type + */ +export declare type EventType = string | symbol; + +export declare function format(message: string, ...args: any): string; + +export declare const friendlyJSONstringify: (json: unknown) => string; + +export declare function generateCodeFrame(source: string, start?: number, end?: number): string; + +export declare const generateFormatCacheKey: (locale: string, key: string, source: string) => string; + +export declare const getGlobalThis: () => any; + +export declare function hasOwn(obj: object | Array, key: string): boolean; + +/** + * Original Utilities + * written by kazuya kawaguchi + */ +export declare const inBrowser: boolean; + +export declare function incrementer(code: number): () => number; + +/** + * Useful Utilities By Evan you + * Modified by kazuya kawaguchi + * MIT License + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts + */ +export declare const isArray: (arg: any) => arg is any[]; + +export declare const isBoolean: (val: unknown) => val is boolean; + +export declare const isDate: (val: unknown) => val is Date; + +export declare const isEmptyObject: (val: unknown) => val is boolean; + +export declare const isFunction: (val: unknown) => val is Function; + +export declare const isNumber: (val: unknown) => val is number; + +export declare const isObject: (val: unknown) => val is Record; + +export declare const isPlainObject: (val: unknown) => val is object; + +export declare const isPromise: (val: unknown) => val is Promise; + +export declare const isRegExp: (val: unknown) => val is RegExp; + +export declare const isString: (val: unknown) => val is string; + +export declare const isSymbol: (val: unknown) => val is symbol; + +export declare function join(items: string[], separator?: string): string; + +export declare const makeSymbol: (name: string, shareable?: boolean) => symbol; + +export declare let mark: (tag: string) => void | undefined; + +export declare let measure: (name: string, startTag: string, endTag: string) => void | undefined; + +export declare const objectToString: () => string; + +export declare function sanitizeTranslatedHtml(html: string): string; + +export declare const toDisplayString: (val: unknown) => string; + +export declare const toTypeString: (value: unknown) => string; + +export declare function warn(msg: string, err?: Error): void; + +export declare function warnOnce(msg: string): void; + +/** + * Wildcard event handler + */ +export declare type WildcardEventHandler> = (event: keyof T, payload?: T[keyof T]) => void; + +/** + * Wildcard event handler list + */ +export declare type WildcardEventHandlerList> = Array>; + +export { } diff --git a/node_modules/@intlify/shared/dist/shared.esm-browser.js b/node_modules/@intlify/shared/dist/shared.esm-browser.js new file mode 100644 index 0000000..38120d4 --- /dev/null +++ b/node_modules/@intlify/shared/dist/shared.esm-browser.js @@ -0,0 +1,290 @@ +/*! + * shared v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +function warn(msg, err) { + if (typeof console !== 'undefined') { + console.warn(`[intlify] ` + msg); + /* istanbul ignore if */ + if (err) { + console.warn(err.stack); + } + } +} +const hasWarned = {}; +function warnOnce(msg) { + if (!hasWarned[msg]) { + hasWarned[msg] = true; + warn(msg); + } +} + +/** + * Original Utilities + * written by kazuya kawaguchi + */ +const inBrowser = typeof window !== 'undefined'; +let mark; +let measure; +{ + const perf = inBrowser && window.performance; + if (perf && + perf.mark && + perf.measure && + perf.clearMarks && + // @ts-ignore browser compat + perf.clearMeasures) { + mark = (tag) => { + perf.mark(tag); + }; + measure = (name, startTag, endTag) => { + perf.measure(name, startTag, endTag); + perf.clearMarks(startTag); + perf.clearMarks(endTag); + }; + } +} +const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g; +/* eslint-disable */ +function format(message, ...args) { + if (args.length === 1 && isObject(args[0])) { + args = args[0]; + } + if (!args || !args.hasOwnProperty) { + args = {}; + } + return message.replace(RE_ARGS, (match, identifier) => { + return args.hasOwnProperty(identifier) ? args[identifier] : ''; + }); +} +const makeSymbol = (name, shareable = false) => !shareable ? Symbol(name) : Symbol.for(name); +const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({ l: locale, k: key, s: source }); +const friendlyJSONstringify = (json) => JSON.stringify(json) + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029') + .replace(/\u0027/g, '\\u0027'); +const isNumber = (val) => typeof val === 'number' && isFinite(val); +const isDate = (val) => toTypeString(val) === '[object Date]'; +const isRegExp = (val) => toTypeString(val) === '[object RegExp]'; +const isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0; +const assign = Object.assign; +const _create = Object.create; +const create = (obj = null) => _create(obj); +let _globalThis; +const getGlobalThis = () => { + // prettier-ignore + return (_globalThis || + (_globalThis = + typeof globalThis !== 'undefined' + ? globalThis + : typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : create())); +}; +function escapeHtml(rawText) { + return rawText + .replace(/&/g, '&') // escape `&` first to avoid double escaping + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/\//g, '/') // escape `/` to prevent closing tags or JavaScript URLs + .replace(/=/g, '='); // escape `=` to prevent attribute injection +} +function escapeAttributeValue(value) { + return value + .replace(/&(?![a-zA-Z0-9#]{2,6};)/g, '&') // escape unescaped `&` + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(//g, '>'); +} +function sanitizeTranslatedHtml(html) { + // Escape dangerous characters in attribute values + // Process attributes with double quotes + html = html.replace(/(\w+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${escapeAttributeValue(attrValue)}"`); + // Process attributes with single quotes + html = html.replace(/(\w+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${escapeAttributeValue(attrValue)}'`); + // Detect and neutralize event handler attributes + const eventHandlerPattern = /\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi; + if (eventHandlerPattern.test(html)) { + { + warn('Potentially dangerous event handlers detected in translation. ' + + 'Consider removing onclick, onerror, etc. from your translation messages.'); + } + // Neutralize event handler attributes by escaping 'on' + html = html.replace(/(\s+)(on)(\w+\s*=)/gi, '$1on$3'); + } + // Disable javascript: URLs in various contexts + const javascriptUrlPattern = [ + // In href, src, action, formaction attributes + /(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi, + // In style attributes within url() + /(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi + ]; + javascriptUrlPattern.forEach(pattern => { + html = html.replace(pattern, '$1javascript:'); + }); + return html; +} +const hasOwnProperty = Object.prototype.hasOwnProperty; +function hasOwn(obj, key) { + return hasOwnProperty.call(obj, key); +} +/* eslint-enable */ +/** + * Useful Utilities By Evan you + * Modified by kazuya kawaguchi + * MIT License + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts + */ +const isArray = Array.isArray; +const isFunction = (val) => typeof val === 'function'; +const isString = (val) => typeof val === 'string'; +const isBoolean = (val) => typeof val === 'boolean'; +const isSymbol = (val) => typeof val === 'symbol'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isObject = (val) => val !== null && typeof val === 'object'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isPromise = (val) => { + return isObject(val) && isFunction(val.then) && isFunction(val.catch); +}; +const objectToString = Object.prototype.toString; +const toTypeString = (value) => objectToString.call(value); +const isPlainObject = (val) => { + if (!isObject(val)) + return false; + const proto = Object.getPrototypeOf(val); + return proto === null || proto.constructor === Object; +}; +// for converting list and named values to displayed strings. +const toDisplayString = (val) => { + return val == null + ? '' + : isArray(val) || (isPlainObject(val) && val.toString === objectToString) + ? JSON.stringify(val, null, 2) + : String(val); +}; +function join(items, separator = '') { + return items.reduce((str, item, index) => (index === 0 ? str + item : str + separator + item), ''); +} +const RANGE = 2; +function generateCodeFrame(source, start = 0, end = source.length) { + const lines = source.split(/\r?\n/); + let count = 0; + const res = []; + for (let i = 0; i < lines.length; i++) { + count += lines[i].length + 1; + if (count >= start) { + for (let j = i - RANGE; j <= i + RANGE || end > count; j++) { + if (j < 0 || j >= lines.length) + continue; + const line = j + 1; + res.push(`${line}${' '.repeat(3 - String(line).length)}| ${lines[j]}`); + const lineLength = lines[j].length; + if (j === i) { + // push underline + const pad = start - (count - lineLength) + 1; + const length = Math.max(1, end > count ? lineLength - pad : end - start); + res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length)); + } + else if (j > i) { + if (end > count) { + const length = Math.max(Math.min(end - count, lineLength), 1); + res.push(` | ` + '^'.repeat(length)); + } + count += lineLength + 1; + } + } + break; + } + } + return res.join('\n'); +} +function incrementer(code) { + let current = code; + return () => ++current; +} + +/** + * Event emitter, forked from the below: + * - original repository url: https://github.com/developit/mitt + * - code url: https://github.com/developit/mitt/blob/master/src/index.ts + * - author: Jason Miller (https://github.com/developit) + * - license: MIT + */ +/** + * Create a event emitter + * + * @returns An event emitter + */ +function createEmitter() { + const events = new Map(); + const emitter = { + events, + on(event, handler) { + const handlers = events.get(event); + const added = handlers && handlers.push(handler); + if (!added) { + events.set(event, [handler]); + } + }, + off(event, handler) { + const handlers = events.get(event); + if (handlers) { + handlers.splice(handlers.indexOf(handler) >>> 0, 1); + } + }, + emit(event, payload) { + (events.get(event) || []) + .slice() + .map(handler => handler(payload)); + (events.get('*') || []) + .slice() + .map(handler => handler(event, payload)); + } + }; + return emitter; +} + +const isNotObjectOrIsArray = (val) => !isObject(val) || isArray(val); +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types +function deepCopy(src, des) { + // src and des should both be objects, and none of them can be a array + if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des)) { + throw new Error('Invalid value'); + } + const stack = [{ src, des }]; + while (stack.length) { + const { src, des } = stack.pop(); + // using `Object.keys` which skips prototype properties + Object.keys(src).forEach(key => { + if (key === '__proto__') { + return; + } + // if src[key] is an object/array, set des[key] + // to empty object/array to prevent setting by reference + if (isObject(src[key]) && !isObject(des[key])) { + des[key] = Array.isArray(src[key]) ? [] : create(); + } + if (isNotObjectOrIsArray(des[key]) || isNotObjectOrIsArray(src[key])) { + // replace with src[key] when: + // src[key] or des[key] is not an object, or + // src[key] or des[key] is an array + des[key] = src[key]; + } + else { + // src[key] and des[key] are both objects, merge them + stack.push({ src: src[key], des: des[key] }); + } + }); + } +} + +export { assign, create, createEmitter, deepCopy, escapeHtml, format, friendlyJSONstringify, generateCodeFrame, generateFormatCacheKey, getGlobalThis, hasOwn, inBrowser, incrementer, isArray, isBoolean, isDate, isEmptyObject, isFunction, isNumber, isObject, isPlainObject, isPromise, isRegExp, isString, isSymbol, join, makeSymbol, mark, measure, objectToString, sanitizeTranslatedHtml, toDisplayString, toTypeString, warn, warnOnce }; diff --git a/node_modules/@intlify/shared/dist/shared.esm-browser.prod.js b/node_modules/@intlify/shared/dist/shared.esm-browser.prod.js new file mode 100644 index 0000000..2c480a9 --- /dev/null +++ b/node_modules/@intlify/shared/dist/shared.esm-browser.prod.js @@ -0,0 +1,6 @@ +/*! + * shared v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +function warn(e,t){"undefined"!=typeof console&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}const hasWarned={};function warnOnce(e){hasWarned[e]||(hasWarned[e]=!0,warn(e))}const inBrowser="undefined"!=typeof window;let mark,measure;const RE_ARGS=/\{([0-9a-zA-Z]+)\}/g;function format(e,...t){return 1===t.length&&isObject(t[0])&&(t=t[0]),t&&t.hasOwnProperty||(t={}),e.replace(RE_ARGS,((e,r)=>t.hasOwnProperty(r)?t[r]:""))}const makeSymbol=(e,t=!1)=>t?Symbol.for(e):Symbol(e),generateFormatCacheKey=(e,t,r)=>friendlyJSONstringify({l:e,k:t,s:r}),friendlyJSONstringify=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),isNumber=e=>"number"==typeof e&&isFinite(e),isDate=e=>"[object Date]"===toTypeString(e),isRegExp=e=>"[object RegExp]"===toTypeString(e),isEmptyObject=e=>isPlainObject(e)&&0===Object.keys(e).length,assign=Object.assign,_create=Object.create,create=(e=null)=>_create(e);let _globalThis;const getGlobalThis=()=>_globalThis||(_globalThis="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:create());function escapeHtml(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/").replace(/=/g,"=")}function escapeAttributeValue(e){return e.replace(/&(?![a-zA-Z0-9#]{2,6};)/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")}function sanitizeTranslatedHtml(e){e=(e=e.replace(/(\w+)\s*=\s*"([^"]*)"/g,((e,t,r)=>`${t}="${escapeAttributeValue(r)}"`))).replace(/(\w+)\s*=\s*'([^']*)'/g,((e,t,r)=>`${t}='${escapeAttributeValue(r)}'`));/\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi.test(e)&&(e=e.replace(/(\s+)(on)(\w+\s*=)/gi,"$1on$3"));return[/(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi,/(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi].forEach((t=>{e=e.replace(t,"$1javascript:")})),e}const hasOwnProperty=Object.prototype.hasOwnProperty;function hasOwn(e,t){return hasOwnProperty.call(e,t)}const isArray=Array.isArray,isFunction=e=>"function"==typeof e,isString=e=>"string"==typeof e,isBoolean=e=>"boolean"==typeof e,isSymbol=e=>"symbol"==typeof e,isObject=e=>null!==e&&"object"==typeof e,isPromise=e=>isObject(e)&&isFunction(e.then)&&isFunction(e.catch),objectToString=Object.prototype.toString,toTypeString=e=>objectToString.call(e),isPlainObject=e=>{if(!isObject(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t.constructor===Object},toDisplayString=e=>null==e?"":isArray(e)||isPlainObject(e)&&e.toString===objectToString?JSON.stringify(e,null,2):String(e);function join(e,t=""){return e.reduce(((e,r,n)=>0===n?e+r:e+t+r),"")}const RANGE=2;function generateCodeFrame(e,t=0,r=e.length){const n=e.split(/\r?\n/);let s=0;const i=[];for(let o=0;o=t){for(let e=o-2;e<=o+2||r>s;e++){if(e<0||e>=n.length)continue;const a=e+1;i.push(`${a}${" ".repeat(3-String(a).length)}| ${n[e]}`);const c=n[e].length;if(e===o){const e=t-(s-c)+1,n=Math.max(1,r>s?c-e:r-t);i.push(" | "+" ".repeat(e)+"^".repeat(n))}else if(e>o){if(r>s){const e=Math.max(Math.min(r-s,c),1);i.push(" | "+"^".repeat(e))}s+=c+1}}break}return i.join("\n")}function incrementer(e){let t=e;return()=>++t}function createEmitter(){const e=new Map;return{events:e,on(t,r){const n=e.get(t);n&&n.push(r)||e.set(t,[r])},off(t,r){const n=e.get(t);n&&n.splice(n.indexOf(r)>>>0,1)},emit(t,r){(e.get(t)||[]).slice().map((e=>e(r))),(e.get("*")||[]).slice().map((e=>e(t,r)))}}}const isNotObjectOrIsArray=e=>!isObject(e)||isArray(e);function deepCopy(e,t){if(isNotObjectOrIsArray(e)||isNotObjectOrIsArray(t))throw new Error("Invalid value");const r=[{src:e,des:t}];for(;r.length;){const{src:e,des:t}=r.pop();Object.keys(e).forEach((n=>{"__proto__"!==n&&(isObject(e[n])&&!isObject(t[n])&&(t[n]=Array.isArray(e[n])?[]:create()),isNotObjectOrIsArray(t[n])||isNotObjectOrIsArray(e[n])?t[n]=e[n]:r.push({src:e[n],des:t[n]}))}))}}export{assign,create,createEmitter,deepCopy,escapeHtml,format,friendlyJSONstringify,generateCodeFrame,generateFormatCacheKey,getGlobalThis,hasOwn,inBrowser,incrementer,isArray,isBoolean,isDate,isEmptyObject,isFunction,isNumber,isObject,isPlainObject,isPromise,isRegExp,isString,isSymbol,join,makeSymbol,mark,measure,objectToString,sanitizeTranslatedHtml,toDisplayString,toTypeString,warn,warnOnce}; diff --git a/node_modules/@intlify/shared/dist/shared.esm-bundler.js b/node_modules/@intlify/shared/dist/shared.esm-bundler.js new file mode 100644 index 0000000..6723d0f --- /dev/null +++ b/node_modules/@intlify/shared/dist/shared.esm-bundler.js @@ -0,0 +1 @@ +export * from '../dist/shared.mjs' \ No newline at end of file diff --git a/node_modules/@intlify/shared/dist/shared.mjs b/node_modules/@intlify/shared/dist/shared.mjs new file mode 100644 index 0000000..ee90797 --- /dev/null +++ b/node_modules/@intlify/shared/dist/shared.mjs @@ -0,0 +1,290 @@ +/*! + * shared v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +function warn(msg, err) { + if (typeof console !== 'undefined') { + console.warn(`[intlify] ` + msg); + /* istanbul ignore if */ + if (err) { + console.warn(err.stack); + } + } +} +const hasWarned = {}; +function warnOnce(msg) { + if (!hasWarned[msg]) { + hasWarned[msg] = true; + warn(msg); + } +} + +/** + * Original Utilities + * written by kazuya kawaguchi + */ +const inBrowser = typeof window !== 'undefined'; +let mark; +let measure; +if ((process.env.NODE_ENV !== 'production')) { + const perf = inBrowser && window.performance; + if (perf && + perf.mark && + perf.measure && + perf.clearMarks && + // @ts-ignore browser compat + perf.clearMeasures) { + mark = (tag) => { + perf.mark(tag); + }; + measure = (name, startTag, endTag) => { + perf.measure(name, startTag, endTag); + perf.clearMarks(startTag); + perf.clearMarks(endTag); + }; + } +} +const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g; +/* eslint-disable */ +function format(message, ...args) { + if (args.length === 1 && isObject(args[0])) { + args = args[0]; + } + if (!args || !args.hasOwnProperty) { + args = {}; + } + return message.replace(RE_ARGS, (match, identifier) => { + return args.hasOwnProperty(identifier) ? args[identifier] : ''; + }); +} +const makeSymbol = (name, shareable = false) => !shareable ? Symbol(name) : Symbol.for(name); +const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({ l: locale, k: key, s: source }); +const friendlyJSONstringify = (json) => JSON.stringify(json) + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029') + .replace(/\u0027/g, '\\u0027'); +const isNumber = (val) => typeof val === 'number' && isFinite(val); +const isDate = (val) => toTypeString(val) === '[object Date]'; +const isRegExp = (val) => toTypeString(val) === '[object RegExp]'; +const isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0; +const assign = Object.assign; +const _create = Object.create; +const create = (obj = null) => _create(obj); +let _globalThis; +const getGlobalThis = () => { + // prettier-ignore + return (_globalThis || + (_globalThis = + typeof globalThis !== 'undefined' + ? globalThis + : typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : create())); +}; +function escapeHtml(rawText) { + return rawText + .replace(/&/g, '&') // escape `&` first to avoid double escaping + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/\//g, '/') // escape `/` to prevent closing tags or JavaScript URLs + .replace(/=/g, '='); // escape `=` to prevent attribute injection +} +function escapeAttributeValue(value) { + return value + .replace(/&(?![a-zA-Z0-9#]{2,6};)/g, '&') // escape unescaped `&` + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(//g, '>'); +} +function sanitizeTranslatedHtml(html) { + // Escape dangerous characters in attribute values + // Process attributes with double quotes + html = html.replace(/(\w+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${escapeAttributeValue(attrValue)}"`); + // Process attributes with single quotes + html = html.replace(/(\w+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${escapeAttributeValue(attrValue)}'`); + // Detect and neutralize event handler attributes + const eventHandlerPattern = /\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi; + if (eventHandlerPattern.test(html)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('Potentially dangerous event handlers detected in translation. ' + + 'Consider removing onclick, onerror, etc. from your translation messages.'); + } + // Neutralize event handler attributes by escaping 'on' + html = html.replace(/(\s+)(on)(\w+\s*=)/gi, '$1on$3'); + } + // Disable javascript: URLs in various contexts + const javascriptUrlPattern = [ + // In href, src, action, formaction attributes + /(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi, + // In style attributes within url() + /(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi + ]; + javascriptUrlPattern.forEach(pattern => { + html = html.replace(pattern, '$1javascript:'); + }); + return html; +} +const hasOwnProperty = Object.prototype.hasOwnProperty; +function hasOwn(obj, key) { + return hasOwnProperty.call(obj, key); +} +/* eslint-enable */ +/** + * Useful Utilities By Evan you + * Modified by kazuya kawaguchi + * MIT License + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts + */ +const isArray = Array.isArray; +const isFunction = (val) => typeof val === 'function'; +const isString = (val) => typeof val === 'string'; +const isBoolean = (val) => typeof val === 'boolean'; +const isSymbol = (val) => typeof val === 'symbol'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isObject = (val) => val !== null && typeof val === 'object'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isPromise = (val) => { + return isObject(val) && isFunction(val.then) && isFunction(val.catch); +}; +const objectToString = Object.prototype.toString; +const toTypeString = (value) => objectToString.call(value); +const isPlainObject = (val) => { + if (!isObject(val)) + return false; + const proto = Object.getPrototypeOf(val); + return proto === null || proto.constructor === Object; +}; +// for converting list and named values to displayed strings. +const toDisplayString = (val) => { + return val == null + ? '' + : isArray(val) || (isPlainObject(val) && val.toString === objectToString) + ? JSON.stringify(val, null, 2) + : String(val); +}; +function join(items, separator = '') { + return items.reduce((str, item, index) => (index === 0 ? str + item : str + separator + item), ''); +} +const RANGE = 2; +function generateCodeFrame(source, start = 0, end = source.length) { + const lines = source.split(/\r?\n/); + let count = 0; + const res = []; + for (let i = 0; i < lines.length; i++) { + count += lines[i].length + 1; + if (count >= start) { + for (let j = i - RANGE; j <= i + RANGE || end > count; j++) { + if (j < 0 || j >= lines.length) + continue; + const line = j + 1; + res.push(`${line}${' '.repeat(3 - String(line).length)}| ${lines[j]}`); + const lineLength = lines[j].length; + if (j === i) { + // push underline + const pad = start - (count - lineLength) + 1; + const length = Math.max(1, end > count ? lineLength - pad : end - start); + res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length)); + } + else if (j > i) { + if (end > count) { + const length = Math.max(Math.min(end - count, lineLength), 1); + res.push(` | ` + '^'.repeat(length)); + } + count += lineLength + 1; + } + } + break; + } + } + return res.join('\n'); +} +function incrementer(code) { + let current = code; + return () => ++current; +} + +/** + * Event emitter, forked from the below: + * - original repository url: https://github.com/developit/mitt + * - code url: https://github.com/developit/mitt/blob/master/src/index.ts + * - author: Jason Miller (https://github.com/developit) + * - license: MIT + */ +/** + * Create a event emitter + * + * @returns An event emitter + */ +function createEmitter() { + const events = new Map(); + const emitter = { + events, + on(event, handler) { + const handlers = events.get(event); + const added = handlers && handlers.push(handler); + if (!added) { + events.set(event, [handler]); + } + }, + off(event, handler) { + const handlers = events.get(event); + if (handlers) { + handlers.splice(handlers.indexOf(handler) >>> 0, 1); + } + }, + emit(event, payload) { + (events.get(event) || []) + .slice() + .map(handler => handler(payload)); + (events.get('*') || []) + .slice() + .map(handler => handler(event, payload)); + } + }; + return emitter; +} + +const isNotObjectOrIsArray = (val) => !isObject(val) || isArray(val); +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types +function deepCopy(src, des) { + // src and des should both be objects, and none of them can be a array + if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des)) { + throw new Error('Invalid value'); + } + const stack = [{ src, des }]; + while (stack.length) { + const { src, des } = stack.pop(); + // using `Object.keys` which skips prototype properties + Object.keys(src).forEach(key => { + if (key === '__proto__') { + return; + } + // if src[key] is an object/array, set des[key] + // to empty object/array to prevent setting by reference + if (isObject(src[key]) && !isObject(des[key])) { + des[key] = Array.isArray(src[key]) ? [] : create(); + } + if (isNotObjectOrIsArray(des[key]) || isNotObjectOrIsArray(src[key])) { + // replace with src[key] when: + // src[key] or des[key] is not an object, or + // src[key] or des[key] is an array + des[key] = src[key]; + } + else { + // src[key] and des[key] are both objects, merge them + stack.push({ src: src[key], des: des[key] }); + } + }); + } +} + +export { assign, create, createEmitter, deepCopy, escapeHtml, format, friendlyJSONstringify, generateCodeFrame, generateFormatCacheKey, getGlobalThis, hasOwn, inBrowser, incrementer, isArray, isBoolean, isDate, isEmptyObject, isFunction, isNumber, isObject, isPlainObject, isPromise, isRegExp, isString, isSymbol, join, makeSymbol, mark, measure, objectToString, sanitizeTranslatedHtml, toDisplayString, toTypeString, warn, warnOnce }; diff --git a/node_modules/@intlify/shared/dist/shared.prod.cjs b/node_modules/@intlify/shared/dist/shared.prod.cjs new file mode 100644 index 0000000..ce6d989 --- /dev/null +++ b/node_modules/@intlify/shared/dist/shared.prod.cjs @@ -0,0 +1,304 @@ +/*! + * shared v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +'use strict'; + +function warn(msg, err) { + if (typeof console !== 'undefined') { + console.warn(`[intlify] ` + msg); + /* istanbul ignore if */ + if (err) { + console.warn(err.stack); + } + } +} +const hasWarned = {}; +function warnOnce(msg) { + if (!hasWarned[msg]) { + hasWarned[msg] = true; + warn(msg); + } +} + +/** + * Original Utilities + * written by kazuya kawaguchi + */ +const inBrowser = typeof window !== 'undefined'; +let mark; +let measure; +const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g; +/* eslint-disable */ +function format(message, ...args) { + if (args.length === 1 && isObject(args[0])) { + args = args[0]; + } + if (!args || !args.hasOwnProperty) { + args = {}; + } + return message.replace(RE_ARGS, (match, identifier) => { + return args.hasOwnProperty(identifier) ? args[identifier] : ''; + }); +} +const makeSymbol = (name, shareable = false) => !shareable ? Symbol(name) : Symbol.for(name); +const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({ l: locale, k: key, s: source }); +const friendlyJSONstringify = (json) => JSON.stringify(json) + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029') + .replace(/\u0027/g, '\\u0027'); +const isNumber = (val) => typeof val === 'number' && isFinite(val); +const isDate = (val) => toTypeString(val) === '[object Date]'; +const isRegExp = (val) => toTypeString(val) === '[object RegExp]'; +const isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0; +const assign = Object.assign; +const _create = Object.create; +const create = (obj = null) => _create(obj); +let _globalThis; +const getGlobalThis = () => { + // prettier-ignore + return (_globalThis || + (_globalThis = + typeof globalThis !== 'undefined' + ? globalThis + : typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : create())); +}; +function escapeHtml(rawText) { + return rawText + .replace(/&/g, '&') // escape `&` first to avoid double escaping + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/\//g, '/') // escape `/` to prevent closing tags or JavaScript URLs + .replace(/=/g, '='); // escape `=` to prevent attribute injection +} +function escapeAttributeValue(value) { + return value + .replace(/&(?![a-zA-Z0-9#]{2,6};)/g, '&') // escape unescaped `&` + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(//g, '>'); +} +function sanitizeTranslatedHtml(html) { + // Escape dangerous characters in attribute values + // Process attributes with double quotes + html = html.replace(/(\w+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${escapeAttributeValue(attrValue)}"`); + // Process attributes with single quotes + html = html.replace(/(\w+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${escapeAttributeValue(attrValue)}'`); + // Detect and neutralize event handler attributes + const eventHandlerPattern = /\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi; + if (eventHandlerPattern.test(html)) { + // Neutralize event handler attributes by escaping 'on' + html = html.replace(/(\s+)(on)(\w+\s*=)/gi, '$1on$3'); + } + // Disable javascript: URLs in various contexts + const javascriptUrlPattern = [ + // In href, src, action, formaction attributes + /(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi, + // In style attributes within url() + /(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi + ]; + javascriptUrlPattern.forEach(pattern => { + html = html.replace(pattern, '$1javascript:'); + }); + return html; +} +const hasOwnProperty = Object.prototype.hasOwnProperty; +function hasOwn(obj, key) { + return hasOwnProperty.call(obj, key); +} +/* eslint-enable */ +/** + * Useful Utilities By Evan you + * Modified by kazuya kawaguchi + * MIT License + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts + */ +const isArray = Array.isArray; +const isFunction = (val) => typeof val === 'function'; +const isString = (val) => typeof val === 'string'; +const isBoolean = (val) => typeof val === 'boolean'; +const isSymbol = (val) => typeof val === 'symbol'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isObject = (val) => val !== null && typeof val === 'object'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isPromise = (val) => { + return isObject(val) && isFunction(val.then) && isFunction(val.catch); +}; +const objectToString = Object.prototype.toString; +const toTypeString = (value) => objectToString.call(value); +const isPlainObject = (val) => { + if (!isObject(val)) + return false; + const proto = Object.getPrototypeOf(val); + return proto === null || proto.constructor === Object; +}; +// for converting list and named values to displayed strings. +const toDisplayString = (val) => { + return val == null + ? '' + : isArray(val) || (isPlainObject(val) && val.toString === objectToString) + ? JSON.stringify(val, null, 2) + : String(val); +}; +function join(items, separator = '') { + return items.reduce((str, item, index) => (index === 0 ? str + item : str + separator + item), ''); +} +const RANGE = 2; +function generateCodeFrame(source, start = 0, end = source.length) { + const lines = source.split(/\r?\n/); + let count = 0; + const res = []; + for (let i = 0; i < lines.length; i++) { + count += lines[i].length + 1; + if (count >= start) { + for (let j = i - RANGE; j <= i + RANGE || end > count; j++) { + if (j < 0 || j >= lines.length) + continue; + const line = j + 1; + res.push(`${line}${' '.repeat(3 - String(line).length)}| ${lines[j]}`); + const lineLength = lines[j].length; + if (j === i) { + // push underline + const pad = start - (count - lineLength) + 1; + const length = Math.max(1, end > count ? lineLength - pad : end - start); + res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length)); + } + else if (j > i) { + if (end > count) { + const length = Math.max(Math.min(end - count, lineLength), 1); + res.push(` | ` + '^'.repeat(length)); + } + count += lineLength + 1; + } + } + break; + } + } + return res.join('\n'); +} +function incrementer(code) { + let current = code; + return () => ++current; +} + +/** + * Event emitter, forked from the below: + * - original repository url: https://github.com/developit/mitt + * - code url: https://github.com/developit/mitt/blob/master/src/index.ts + * - author: Jason Miller (https://github.com/developit) + * - license: MIT + */ +/** + * Create a event emitter + * + * @returns An event emitter + */ +function createEmitter() { + const events = new Map(); + const emitter = { + events, + on(event, handler) { + const handlers = events.get(event); + const added = handlers && handlers.push(handler); + if (!added) { + events.set(event, [handler]); + } + }, + off(event, handler) { + const handlers = events.get(event); + if (handlers) { + handlers.splice(handlers.indexOf(handler) >>> 0, 1); + } + }, + emit(event, payload) { + (events.get(event) || []) + .slice() + .map(handler => handler(payload)); + (events.get('*') || []) + .slice() + .map(handler => handler(event, payload)); + } + }; + return emitter; +} + +const isNotObjectOrIsArray = (val) => !isObject(val) || isArray(val); +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types +function deepCopy(src, des) { + // src and des should both be objects, and none of them can be a array + if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des)) { + throw new Error('Invalid value'); + } + const stack = [{ src, des }]; + while (stack.length) { + const { src, des } = stack.pop(); + // using `Object.keys` which skips prototype properties + Object.keys(src).forEach(key => { + if (key === '__proto__') { + return; + } + // if src[key] is an object/array, set des[key] + // to empty object/array to prevent setting by reference + if (isObject(src[key]) && !isObject(des[key])) { + des[key] = Array.isArray(src[key]) ? [] : create(); + } + if (isNotObjectOrIsArray(des[key]) || isNotObjectOrIsArray(src[key])) { + // replace with src[key] when: + // src[key] or des[key] is not an object, or + // src[key] or des[key] is an array + des[key] = src[key]; + } + else { + // src[key] and des[key] are both objects, merge them + stack.push({ src: src[key], des: des[key] }); + } + }); + } +} + +exports.assign = assign; +exports.create = create; +exports.createEmitter = createEmitter; +exports.deepCopy = deepCopy; +exports.escapeHtml = escapeHtml; +exports.format = format; +exports.friendlyJSONstringify = friendlyJSONstringify; +exports.generateCodeFrame = generateCodeFrame; +exports.generateFormatCacheKey = generateFormatCacheKey; +exports.getGlobalThis = getGlobalThis; +exports.hasOwn = hasOwn; +exports.inBrowser = inBrowser; +exports.incrementer = incrementer; +exports.isArray = isArray; +exports.isBoolean = isBoolean; +exports.isDate = isDate; +exports.isEmptyObject = isEmptyObject; +exports.isFunction = isFunction; +exports.isNumber = isNumber; +exports.isObject = isObject; +exports.isPlainObject = isPlainObject; +exports.isPromise = isPromise; +exports.isRegExp = isRegExp; +exports.isString = isString; +exports.isSymbol = isSymbol; +exports.join = join; +exports.makeSymbol = makeSymbol; +exports.mark = mark; +exports.measure = measure; +exports.objectToString = objectToString; +exports.sanitizeTranslatedHtml = sanitizeTranslatedHtml; +exports.toDisplayString = toDisplayString; +exports.toTypeString = toTypeString; +exports.warn = warn; +exports.warnOnce = warnOnce; diff --git a/node_modules/@intlify/shared/index.js b/node_modules/@intlify/shared/index.js new file mode 100644 index 0000000..6aa3731 --- /dev/null +++ b/node_modules/@intlify/shared/index.js @@ -0,0 +1,7 @@ +'use strict' + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./dist/shared.prod.cjs') +} else { + module.exports = require('./dist/shared.cjs') +} diff --git a/node_modules/@intlify/shared/package.json b/node_modules/@intlify/shared/package.json new file mode 100644 index 0000000..316f9d0 --- /dev/null +++ b/node_modules/@intlify/shared/package.json @@ -0,0 +1,69 @@ +{ + "name": "@intlify/shared", + "version": "9.14.5", + "description": "@intlify/shared", + "keywords": [ + "i18n", + "internationalization", + "intlify", + "utitlity" + ], + "license": "MIT", + "author": { + "name": "kazuya kawaguchi", + "email": "kawakazu80@gmail.com" + }, + "homepage": "https://github.com/intlify/vue-i18n/tree/master/packages/shared#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/intlify/vue-i18n.git", + "directory": "packages/shared" + }, + "bugs": { + "url": "https://github.com/intlify/vue-i18n/issues" + }, + "files": [ + "index.js", + "dist" + ], + "main": "index.js", + "module": "dist/shared.mjs", + "types": "dist/shared.d.ts", + "engines": { + "node": ">= 16" + }, + "buildOptions": { + "name": "IntlifyShared", + "formats": [ + "mjs", + "browser", + "cjs" + ] + }, + "exports": { + ".": { + "types": "./dist/shared.d.ts", + "import": "./dist/shared.mjs", + "browser": "./dist/shared.esm-browser.js", + "node": { + "import": { + "production": "./dist/shared.prod.cjs", + "development": "./dist/shared.mjs", + "default": "./dist/shared.mjs" + }, + "require": { + "production": "./dist/shared.prod.cjs", + "development": "./dist/shared.cjs", + "default": "./index.js" + } + } + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" + }, + "funding": "https://github.com/sponsors/kazupon", + "publishConfig": { + "access": "public" + }, + "sideEffects": false +} \ No newline at end of file diff --git a/node_modules/vue-i18n/LICENSE b/node_modules/vue-i18n/LICENSE new file mode 100644 index 0000000..c02ff3e --- /dev/null +++ b/node_modules/vue-i18n/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2020 kazuya kawaguchi + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/vue-i18n/README.md b/node_modules/vue-i18n/README.md new file mode 100644 index 0000000..d6900a7 --- /dev/null +++ b/node_modules/vue-i18n/README.md @@ -0,0 +1,81 @@ +# vue-i18n + +Internationalization plugin for Vue.js + +## Which dist file to use? + +### From CDN or without a Bundler + +- **`vue-i18n(.runtime).global(.prod).js`**: + + - For direct use via ` + * ``` + * + * @VueI18nComposition + */ +export declare function useI18n, LocaleParams> = UseI18nOptions, LocaleParams>>(options?: Options): Composer, NonNullable, NonNullable, Options['locale'] extends unknown ? string : Options['locale']>; + +/** + * I18n Options for `useI18n` + * + * @remarks + * `UseI18nOptions` is inherited {@link ComposerAdditionalOptions} and {@link ComposerOptions}, so you can specify these options. + * + * @VueI18nSee [useI18n](composition#usei18n) + * + * @VueI18nComposition + */ +export declare type UseI18nOptions = ComposerOptions> = ComposerAdditionalOptions & Options; + +/** + * Vue I18n Version + * + * @remarks + * Semver format. Same format as the package.json `version` field. + * + * @VueI18nGeneral + */ +export declare const VERSION: string; + +export declare function vTDirective(i18n: I18n): TranslationDirective; + +export declare type VTDirectiveValue = { + path: string; + locale?: Locale; + args?: NamedValue; + choice?: number; + plural?: number; +}; + +/** + * VueI18n legacy interfaces + * + * @remarks + * This interface is compatible with interface of `VueI18n` class (offered with Vue I18n v8.x). + * + * @VueI18nLegacy + */ +export declare interface VueI18n = {}, DateTimeFormats extends Record = {}, NumberFormats extends Record = {}, OptionLocale = Locale, ResourceLocales = PickupLocales> | PickupLocales> | PickupLocales>, Locales = OptionLocale extends string ? [ResourceLocales] extends [never] ? Locale : ResourceLocales : OptionLocale | ResourceLocales, Composition extends Composer = Composer> { + /** + * @remarks + * Instance ID. + */ + id: number; + /** + * @remarks + * The current locale this VueI18n instance is using. + * + * If the locale contains a territory and a dialect, this locale contains an implicit fallback. + * + * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope) + */ + locale: Locales; + /** + * @remarks + * The current fallback locales this VueI18n instance is using. + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + */ + fallbackLocale: FallbackLocales; + /** + * @remarks + * The list of available locales in `messages` in lexical order. + */ + readonly availableLocales: Composition['availableLocales']; + /** + * @remarks + * The locale messages of localization. + * + * @VueI18nSee [Getting Started](../guide/essentials/started) + */ + readonly messages: { + [K in keyof Messages]: Messages[K]; + }; + /** + * @remarks + * The datetime formats of localization. + * + * @VueI18nSee [Datetime Formatting](../guide/essentials/datetime) + */ + readonly datetimeFormats: { + [K in keyof DateTimeFormats]: DateTimeFormats[K]; + }; + /** + * @remarks + * The number formats of localization. + * + * @VueI18nSee [Number Formatting](../guide/essentials/number) + */ + readonly numberFormats: { + [K in keyof NumberFormats]: NumberFormats[K]; + }; + /** + * @remarks + * Custom Modifiers for linked messages. + * + * @VueI18nSee [Custom Modifiers](../guide/essentials/syntax#custom-modifiers) + */ + readonly modifiers: Composition['modifiers']; + /** + * @remarks + * The formatter that implemented with Formatter interface. + * + * @deprecated See the [here](../guide/migration/breaking#remove-custom-formatter) + */ + formatter: Formatter; + /** + * @remarks + * A handler for localization missing. + */ + missing: MissingHandler | null; + /** + * @remarks + * A handler for post processing of translation. + */ + postTranslation: PostTranslationHandler | null; + /** + * @remarks + * Whether suppress warnings outputted when localization fails. + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + */ + silentTranslationWarn: Composition['missingWarn']; + /** + * @remarks + * Whether suppress fallback warnings when localization fails. + */ + silentFallbackWarn: Composition['fallbackWarn']; + /** + * @remarks + * Whether suppress warnings when falling back to either `fallbackLocale` or root. + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + */ + formatFallbackMessages: Composition['fallbackFormat']; + /** + * @remarks + * Whether synchronize the root level locale to the component localization locale. + * + * @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-2) + */ + sync: Composition['inheritLocale']; + /** + * @remarks + * Whether to allow the use locale messages of HTML formatting. + * + * If you set `warn` or` error`, will check the locale messages on the VueI18n instance. + * + * If you are specified `warn`, a warning will be output at console. + * + * If you are specified `error` will occurred an Error. + * + * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message) + * @VueI18nSee [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value) + */ + warnHtmlInMessage: WarnHtmlInMessageLevel; + /** + * @remarks + * Whether interpolation parameters are escaped before the message is translated. + * + * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message) + */ + escapeParameterHtml: Composition['escapeParameter']; + /** + * @remarks + * Whether `v-t` directive's element should preserve `textContent` after directive is unbinded. + * + * @VueI18nSee [Custom Directive](../guide/advanced/directive) + * @VueI18nSee [Remove preserveDirectiveContent option](../guide/migration/breaking#remove-preservedirectivecontent-option) + * + * @deprecated The `v-t` directive for Vue 3 now preserves the default content. Therefore, this option and its properties have been removed from the VueI18n instance. + */ + preserveDirectiveContent: boolean; + /** + * A set of rules for word pluralization + * + * @VueI18nSee [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization) + */ + pluralizationRules: Composition['pluralRules']; + /** + * Locale message translation + * + * @remarks + * About details functions, See the {@link VueI18nTranslation} + */ + t: VueI18nTranslation>; + /** + * Resolve locale message translation + * + * @remarks + * About details functions, See the {@link VueI18nResolveLocaleMessageTranslation} + */ + rt: VueI18nResolveLocaleMessageTranslation; + /** + * Locale message pluralization + * + * @remarks + * About details functions, See the {@link VueI18nTranslationChoice} + */ + tc: VueI18nTranslationChoice>; + /** + * Translation locale message exist + * + * @remarks + * whether do exist locale message on VueI18n instance [messages](legacy#messages). + * + * If you specified `locale`, check the locale messages of `locale`. + * + * @param key - A target locale message key + * @param locale - A target locale + * + * @returns If found locale message, `true`, else `false` + */ + te = PickupKeys>(key: Str | Key, locale?: Locales): boolean; + /** + * Locale messages getter + * + * @remarks + * If [i18n component options](injection#i18n) is specified, it’s get in preferentially local scope locale messages than global scope locale messages. + * + * If [i18n component options](injection#i18n) isn't specified, it’s get with global scope locale messages. + * + * Based on the current `locale`, locale messages will be returned from Composer instance messages. + * + * If you change the `locale`, the locale messages returned will also correspond to the locale. + * + * If there are no locale messages for the given `key` in the composer instance messages, they will be returned with [fallbacking](../guide/essentials/fallback). + * + * @VueI18nWarning + * You need to use `rt` for the locale message returned by `tm`. see the [rt](legacy#rt-message) details. + * + * @example + * template: + * ```html + *
+ * + *
+ * ``` + * + * ```js + * import { createI18n } from 'vue-i18n' + * + * const i18n = createI18n({ + * messages: { + * en: { + * contents: [ + * { + * title: 'Title1', + * // ... + * paragraphs: [ + * // ... + * ] + * } + * ] + * } + * } + * // ... + * }) + * ``` + * @param key - A target locale message key + * + * @return Locale messages + */ + tm: Composition['tm']; + /** + * Get locale message + * + * @remarks + * get locale message from VueI18n instance [messages](legacy#messages). + * + * @param locale - A target locale + * + * @returns Locale messages + */ + getLocaleMessage: Composition['getLocaleMessage']; + /** + * Set locale message + * + * @remarks + * Set locale message to VueI18n instance [messages](legacy#messages). + * + * @param locale - A target locale + * @param message - A message + */ + setLocaleMessage: Composition['setLocaleMessage']; + /** + * Merge locale message + * + * @remarks + * Merge locale message to VueI18n instance [messages](legacy#messages). + * + * @param locale - A target locale + * @param message - A message + */ + mergeLocaleMessage: Composition['mergeLocaleMessage']; + /** + * Datetime formatting + * + * @remarks + * About details functions, See the {@link VueI18nDateTimeFormatting} + */ + d: VueI18nDateTimeFormatting>; + /** + * Get datetime format + * + * @remarks + * get datetime format from VueI18n instance [datetimeFormats](legacy#datetimeformats). + * + * @param locale - A target locale + * + * @returns Datetime format + */ + getDateTimeFormat: Composition['getDateTimeFormat']; + /** + * Set datetime format + * + * @remarks + * Set datetime format to VueI18n instance [datetimeFormats](legacy#datetimeformats). + * + * @param locale - A target locale + * @param format - A target datetime format + */ + setDateTimeFormat: Composition['setDateTimeFormat']; + /** + * Merge datetime format + * + * @remarks + * Merge datetime format to VueI18n instance [datetimeFormats](legacy#datetimeformats). + * + * @param locale - A target locale + * @param format - A target datetime format + */ + mergeDateTimeFormat: Composition['mergeDateTimeFormat']; + /** + * Number Formatting + * + * @remarks + * About details functions, See the {@link VueI18nNumberFormatting} + */ + n: VueI18nNumberFormatting>; + /** + * Get number format + * + * @remarks + * get number format from VueI18n instance [numberFormats](legacy#numberFormats). + * + * @param locale - A target locale + * + * @returns Number format + */ + getNumberFormat: Composition['getNumberFormat']; + /** + * Set number format + * + * @remarks + * Set number format to VueI18n instance [numberFormats](legacy#numberFormats). + * + * @param locale - A target locale + * @param format - A target number format + */ + setNumberFormat: Composition['setNumberFormat']; + /** + * Merge number format + * + * @remarks + * Merge number format to VueI18n instance [numberFormats](legacy#numberFormats). + * + * @param locale - A target locale + * @param format - A target number format + */ + mergeNumberFormat: Composition['mergeNumberFormat']; + /** + * Get choice index + * + * @remarks + * Get pluralization index for current pluralizing number and a given amount of choices. + * + * @deprecated Use `pluralizationRules` option instead of `getChoiceIndex`. + */ + getChoiceIndex: (choice: Choice, choicesLength: number) => number; +} + +/** + * Datetime formatting functions for VueI18n legacy interfaces + * + * @remarks + * This is the interface for {@link VueI18n} + * + * @VueI18nLegacy + */ +export declare interface VueI18nDateTimeFormatting = {}, Locales = 'en-US', DefinedDateTimeFormat extends RemovedIndexResources = RemovedIndexResources, C = IsEmptyObject extends false ? PickupFormatPathKeys<{ + [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K]; +}> : never, M = IsEmptyObject extends false ? PickupFormatKeys : never, ResourceKeys extends C | M = IsNever extends false ? IsNever extends false ? C | M : C : IsNever extends false ? M : never> { + /** + * Datetime formatting + * + * @remarks + * If this is used in a reactive context, it will re-evaluate once the locale changes. + * + * If [i18n component options](injection#i18n) is specified, it’s formatted in preferentially local scope datetime formats than global scope locale messages. + * + * If [i18n component options](injection#i18n) isn't specified, it’s formatted with global scope datetime formats. + * + * @param value - A value, timestamp number or `Date` instance + * + * @returns Formatted value + * + * @VueI18nSee [Datetime formatting](../guide/essentials/datetime) + */ + (value: number | Date): DateTimeFormatResult; + /** + * Datetime formatting + * + * @remarks + * Overloaded `d`. About details, see the [call signature](legacy#value-number-date-datetimeformatresult) details. + * + * @param value - A value, timestamp number or `Date` instance + * @param key - A key of datetime formats + * + * @returns Formatted value + */ + (value: Value, key: Key | ResourceKeys): DateTimeFormatResult; + /** + * Datetime formatting + * + * @remarks + * Overloaded `d`. About details, see the [call signature](legacy#value-number-date-datetimeformatresult) details. + * + * @param value - A value, timestamp number or `Date` instance + * @param key - A key of datetime formats + * @param locale - A locale, it will be used over than global scope or local scope. + * + * @returns Formatted value + */ + (value: Value, key: Key | ResourceKeys, locale: Locales): DateTimeFormatResult; + /** + * Datetime formatting + * + * @remarks + * Overloaded `d`. About details, see the [call signature](legacy#value-number-date-datetimeformatresult) details. + * + * @param value - A value, timestamp number or `Date` instance + * @param args - An argument values + * + * @returns Formatted value + */ + (value: number | Date, args: { + [key: string]: string | boolean | number; + }): DateTimeFormatResult; +} + +export declare type VueI18nExtender = (vueI18n: VueI18n) => Disposer | undefined; + +/** + * Number formatting functions for VueI18n legacy interfaces + * + * @remarks + * This is the interface for {@link VueI18n} + * + * @VueI18nLegacy + */ +export declare interface VueI18nNumberFormatting = {}, Locales = 'en-US', DefinedNumberFormat extends RemovedIndexResources = RemovedIndexResources, C = IsEmptyObject extends false ? PickupFormatPathKeys<{ + [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K]; +}> : never, M = IsEmptyObject extends false ? PickupFormatKeys : never, ResourceKeys extends C | M = IsNever extends false ? IsNever extends false ? C | M : C : IsNever extends false ? M : never> { + /** + * Number formatting + * + * @remarks + * If this is used in a reactive context, it will re-evaluate once the locale changes. + * + * If [i18n component options](injection#i18n) is specified, it’s formatted in preferentially local scope number formats than global scope locale messages. + * + * If [i18n component options](injection#i18n) isn't specified, it’s formatted with global scope number formats. + * + * @param value - A number value + * + * @returns Formatted value + * + * @VueI18nSee [Number formatting](../guide/essentials/number) + */ + (value: number): NumberFormatResult; + /** + * Number formatting + * + * @remarks + * Overloaded `n`. About details, see the [call signature](legacy#value-number-numberformatresult) details. + * + * @param value - A number value + * @param key - A key of number formats + * + * @returns Formatted value + */ + (value: number, key: Key | ResourceKeys): NumberFormatResult; + /** + * Number formatting + * + * @remarks + * Overloaded `n`. About details, see the [call signature](legacy#value-number-numberformatresult) details. + * + * @param value - A number value + * @param key - A key of number formats + * @param locale - A locale, it will be used over than global scope or local scope. + * + * @returns Formatted value + */ + (value: number, key: Key | ResourceKeys, locale: Locales): NumberFormatResult; + /** + * Number formatting + * + * @remarks + * Overloaded `n`. About details, see the [call signature](legacy#value-number-numberformatresult) details. + * + * @param value - A number value + * @param args - An argument values + * + * @returns Formatted value + */ + (value: number, args: { + [key: string]: string | boolean | number; + }): NumberFormatResult; +} + +/** + * VueI18n Options + * + * @remarks + * This option is compatible with `VueI18n` class constructor options (offered with Vue I18n v8.x) + * + * @VueI18nLegacy + */ +export declare interface VueI18nOptions = ComposerOptions> { + /** + * @remarks + * The locale of localization. + * + * If the locale contains a territory and a dialect, this locale contains an implicit fallback. + * + * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope) + * + * @defaultValue `'en-US'` + */ + locale?: Options['locale']; + /** + * @remarks + * The locale of fallback localization. + * + * For more complex fallback definitions see fallback. + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @defaultValue The default `'en-US'` for the `locale` if it's not specified, or it's `locale` value + */ + fallbackLocale?: Options['fallbackLocale']; + /** + * @remarks + * The locale messages of localization. + * + * @VueI18nSee [Getting Started](../guide/essentials/started) + * + * @defaultValue `{}` + */ + messages?: Options['messages']; + /** + * @remarks + * Allow use flat json messages or not + * + * @defaultValue `false` + */ + flatJson?: Options['flatJson']; + /** + * @remarks + * The datetime formats of localization. + * + * @VueI18nSee [Datetime Formatting](../guide/essentials/datetime) + * + * @defaultValue `{}` + */ + datetimeFormats?: Options['datetimeFormats']; + /** + * @remarks + * The number formats of localization. + * + * @VueI18nSee [Number Formatting](../guide/essentials/number) + * + * @defaultValue `{}` + */ + numberFormats?: Options['numberFormats']; + /** + * @remarks + * The list of available locales in messages in lexical order. + * + * @defaultValue `[]` + */ + availableLocales?: Locale[]; + /** + * @remarks + * Custom Modifiers for linked messages. + * + * @VueI18nSee [Custom Modifiers](../guide/essentials/syntax#custom-modifiers) + */ + modifiers?: Options['modifiers']; + /** + * @remarks + * The formatter that implemented with Formatter interface. + * + * @deprecated See the [here](../guide/migration/breaking#remove-custom-formatter) + */ + formatter?: Formatter; + /** + * @remarks + * A handler for localization missing. + * + * The handler gets called with the localization target locale, localization path key, the Vue instance and values. + * + * If missing handler is assigned, and occurred localization missing, it's not warned. + * + * @defaultValue `null` + */ + missing?: Options['missing']; + /** + * @remarks + * In the component localization, whether to fall back to root level (global scope) localization when localization fails. + * + * If `false`, it's not fallback to root. + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @defaultValue `true` + */ + fallbackRoot?: Options['fallbackRoot']; + /** + * @remarks + * Whether suppress warnings outputted when localization fails. + * + * If `true`, suppress localization fail warnings. + * + * If you use regular expression, you can suppress localization fail warnings that it match with translation key (e.g. `t`). + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @defaultValue `false` + */ + silentTranslationWarn?: Options['missingWarn']; + /** + * @remarks + * Whether do template interpolation on translation keys when your language lacks a translation for a key. + * + * If `true`, skip writing templates for your "base" language; the keys are your templates. + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @defaultValue `false` + */ + silentFallbackWarn?: Options['fallbackWarn']; + /** + * @remarks + * Whether suppress warnings when falling back to either `fallbackLocale` or root. + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @defaultValue `false` + */ + formatFallbackMessages?: Options['fallbackFormat']; + /** + * @remarks + * Whether `v-t` directive's element should preserve `textContent` after directive is unbinded. + * + * @VueI18nSee [Custom Directive](../guide/advanced/directive) + * @VueI18nSee [Remove `preserveDirectiveContent` option](../guide/migration/breaking#remove-preservedirectivecontent-option) + * + * @defaultValue `false` + * + * @deprecated The `v-t` directive for Vue 3 now preserves the default content. Therefore, this option and its properties have been removed from the VueI18n instance. + */ + preserveDirectiveContent?: boolean; + /** + * @remarks + * Whether to allow the use locale messages of HTML formatting. + * + * See the warnHtmlInMessage property. + * + * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message) + * @VueI18nSee [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value) + * + * @defaultValue `'off'` + */ + warnHtmlInMessage?: WarnHtmlInMessageLevel; + /** + * @remarks + * Whether to escape parameters for list or named interpolation values. + * When enabled, this option: + * - Escapes HTML special characters (`<`, `>`, `"`, `'`, `&`, `/`, `=`) in interpolation parameters + * - Sanitizes the final translated HTML to prevent XSS attacks by: + * - Escaping dangerous characters in HTML attribute values + * - Neutralizing event handler attributes (onclick, onerror, etc.) + * - Disabling javascript: URLs in href, src, action, formaction, and style attributes + * + * This is useful when translation output is used in `v-html` and the translation resource contains html markup (e.g. around a user provided value). + * + * This usage pattern mostly occurs when passing precomputed text strings into UI components. + * + * Setting `escapeParameterHtml` as true should not break existing functionality but provides a safeguard against a subtle type of XSS attack vectors. + * + * @VueI18nSee [HTML Message - Using the escapeParameter option](../guide/essentials/syntax#using-the-escapeparameter-option) + * + * @defaultValue `false` + */ + escapeParameterHtml?: Options['escapeParameter']; + /** + * @remarks + * The shared locale messages of localization for components. More detail see Component based localization. + * + * @VueI18nSee [Shared locale messages for components](../guide/essentials/local#shared-locale-messages-for-components) + * + * @defaultValue `undefined` + */ + sharedMessages?: LocaleMessages; + /** + * @remarks + * A set of rules for word pluralization + * + * @VueI18nSee [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization) + * + * @defaultValue `{}` + */ + pluralizationRules?: Options['pluralRules']; + /** + * @remarks + * A handler for post processing of translation. The handler gets after being called with the `$t`, `t`, `$tc`, and `tc`. + * + * This handler is useful if you want to filter on translated text such as space trimming. + * + * @defaultValue `null` + */ + postTranslation?: Options['postTranslation']; + /** + * @remarks + * Whether synchronize the root level locale to the component localization locale. + * + * If `false`, regardless of the root level locale, localize for each component locale. + * + * @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-2) + * + * @defaultValue `true` + */ + sync?: boolean; + /** + * @remarks + * A message resolver to resolve [`messages`](legacy#messages). + * + * If not specified, the vue-i18n internal message resolver will be used by default. + * + * You need to implement a message resolver yourself that supports the following requirements: + * + * - Resolve the message using the locale message of [`locale`](legacy#locale) passed as the first argument of the message resolver, and the path passed as the second argument. + * + * - If the message could not be resolved, you need to return `null`. + * + * - If you will be returned `null`, the message resolver will also be called on fallback if [`fallbackLocale`](legacy#fallbacklocale-2) is enabled, so the message will need to be resolved as well. + * + * The message resolver is called indirectly by the following APIs: + * + * - [`t`](legacy#t-key) + * + * - [`tc`](legacy#tc-key) + * + * - [`te`](legacy#te-key-locale) + * + * - [`tm`](legacy#tm-key) + * + * - [Translation component](component#translation) + * + * @example + * Here is an example of how to set it up using your `createI18n`: + * ```js + * import { createI18n } from 'vue-i18n' + * + * // your message resolver + * function messageResolver(obj, path) { + * // simple message resolving! + * const msg = obj[path] + * return msg != null ? msg : null + * } + * + * // call with I18n option + * const i18n = createI18n({ + * locale: 'ja', + * messageResolver, // set your message resolver + * messages: { + * en: { ... }, + * ja: { ... } + * } + * }) + * + * // the below your something to do ... + * // ... + * ``` + * + * @VueI18nTip + * :new: v9.2+ + * + * @VueI18nWarning + * If you use the message resolver, the [`flatJson`](legacy#flatjson) setting will be ignored. That is, you need to resolve the flat JSON by yourself. + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @defaultValue `undefined` + */ + messageResolver?: MessageResolver; +} + +/** + * Resolve locale message translation functions for VueI18n legacy interfaces + * + * @remarks + * This is the interface for {@link VueI18n}. This interface is an alias of {@link ComposerResolveLocaleMessageTranslation}. + * + * @VueI18nLegacy + */ +export declare type VueI18nResolveLocaleMessageTranslation = ComposerResolveLocaleMessageTranslation; + +/** + * Locale message translation functions for VueI18n legacy interfaces + * + * @remarks + * This is the interface for {@link VueI18n} + * + * @VueI18nLegacy + */ +export declare interface VueI18nTranslation = {}, Locales = 'en-US', DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, C = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, M = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends C | M = IsNever extends false ? IsNever extends false ? C | M : C : IsNever extends false ? M : never> { + /** + * Locale message translation. + * + * @remarks + * If this is used in a reactive context, it will re-evaluate once the locale changes. + * + * If [i18n component options](injection#i18n) is specified, it’s translated in preferentially local scope locale messages than global scope locale messages. + * + * If [i18n component options](injection#i18n) isn't specified, it’s translated with global scope locale messages. + * + * @param key - A target locale message key + * + * @returns Translated message + * + * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope) + */ + (key: Key | ResourceKeys): TranslateResult; + /** + * Locale message translation. + * + * @remarks + * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + * + * @param key - A target locale message key + * @param locale - A locale, it will be used over than global scope or local scope. + * + * @returns Translated message + */ + (key: Key | ResourceKeys, locale: Locales | Locale): TranslateResult; + /** + * Locale message translation. + * + * @remarks + * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + * + * @param key - A target locale message key + * @param locale - A locale, it will be used over than global scope or local scope. + * @param list - A values of list interpolation + * + * @returns Translated message + * + * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) + */ + (key: Key | ResourceKeys, locale: Locales | Locale, list: unknown[]): TranslateResult; + /** + * Locale message translation. + * + * @remarks + * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + * + * @param key - A target locale message key + * @param locale - A locale, it will be used over than global scope or local scope. + * @param named - A values of named interpolation + * + * @returns Translated message + * + * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) + */ + (key: Key | ResourceKeys, locale: Locales | Locale, named: Record): TranslateResult; + /** + * Locale message translation. + * + * @remarks + * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + * + * @param key - A target locale message key + * @param list - A values of list interpolation + * + * @returns Translated message + * + * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) + */ + (key: Key | ResourceKeys, list: unknown[]): TranslateResult; + /** + * Locale message translation. + * + * @remarks + * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details. + * + * @param key - A target locale message key + * @param named - A values of named interpolation + * + * @returns Translated message + * + * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) + */ + (key: Key | ResourceKeys, named: Record): TranslateResult; +} + +/** + * Locale message pluralization functions for VueI18n legacy interfaces + * + * @remarks + * This is the interface for {@link VueI18n} + * + * @VueI18nLegacy + */ +export declare interface VueI18nTranslationChoice = {}, Locales = 'en-US', DefinedLocaleMessage extends RemovedIndexResources = RemovedIndexResources, C = IsEmptyObject extends false ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]; +}> : never, M = IsEmptyObject extends false ? PickupKeys : never, ResourceKeys extends C | M = IsNever extends false ? IsNever extends false ? C | M : C : IsNever extends false ? M : never> { + /** + * Locale message pluralization + * + * @remarks + * If this is used in a reactive context, it will re-evaluate once the locale changes. + * + * If [i18n component options](injection#i18n) is specified, it’s pluraled in preferentially local scope locale messages than global scope locale messages. + * + * If [i18n component options](injection#i18n) isn't specified, it’s pluraled with global scope locale messages. + * + * The plural choice number is handled with default `1`. + * + * @param key - A target locale message key + * + * @returns Pluraled message + * + * @VueI18nSee [Pluralization](../guide/essentials/pluralization) + */ + (key: Key | ResourceKeys): TranslateResult; + /** + * Locale message pluralization + * + * @remarks + * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details. + * + * @param key - A target locale message key + * @param locale - A locale, it will be used over than global scope or local scope. + * + * @returns Pluraled message + */ + (key: Key | ResourceKeys, locale: Locales | Locale): TranslateResult; + /** + * Locale message pluralization + * + * @remarks + * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details. + * + * @param key - A target locale message key + * @param list - A values of list interpolation + * + * @returns Pluraled message + */ + (key: Key | ResourceKeys, list: unknown[]): TranslateResult; + /** + * Locale message pluralization + * + * @remarks + * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details. + * + * @param key - A target locale message key + * @param named - A values of named interpolation + * + * @returns Pluraled message + */ + (key: Key | ResourceKeys, named: Record): TranslateResult; + /** + * Locale message pluralization + * + * @remarks + * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details. + * + * @param key - A target locale message key + * @param choice - Which plural string to get. 1 returns the first one. + * + * @returns Pluraled message + */ + (key: Key | ResourceKeys, choice: number): TranslateResult; + /** + * Locale message pluralization + * + * @remarks + * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details. + * + * @param key - A target locale message key + * @param choice - Which plural string to get. 1 returns the first one. + * @param locale - A locale, it will be used over than global scope or local scope. + * + * @returns Pluraled message + */ + (key: Key | ResourceKeys, choice: number, locale: Locales | Locale): TranslateResult; + /** + * Locale message pluralization + * + * @remarks + * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details. + * + * @param key - A target locale message key + * @param choice - Which plural string to get. 1 returns the first one. + * @param list - A values of list interpolation + * + * @returns Pluraled message + */ + (key: Key | ResourceKeys, choice: number, list: unknown[]): TranslateResult; + /** + * Locale message pluralization + * + * @remarks + * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details. + * + * @param key - A target locale message key + * @param choice - Which plural string to get. 1 returns the first one. + * @param named - A values of named interpolation + * + * @returns Pluraled message + */ + (key: Key | ResourceKeys, choice: number, named: Record): TranslateResult; +} + +/** @VueI18nComposition */ +export declare type VueMessageType = string | ResourceNode | VNode; + +export declare type WarnHtmlInMessageLevel = 'off' | 'warn' | 'error'; + +export { } + +declare module 'vue' { + /** + * Component Custom Options for Vue I18n + * + * @VueI18nInjection + */ + export interface ComponentCustomOptions { + /** + * VueI18n options + * + * @remarks + * See the {@link VueI18nOptions} + */ + i18n?: VueI18nOptions + /** + * For custom blocks options + * @internal + */ + __i18n?: CustomBlocks + /** + * For devtools + * @internal + */ + __INTLIFY_META__?: string + } + + /** + * Component Custom Properties for Vue I18n + * + * @VueI18nInjection + */ + export interface ComponentCustomProperties { + /** + * Exported Global Composer instance, or global VueI18n instance. + * + * @remarks + * You can get the {@link ExportedGlobalComposer | exported composer instance} which are exported from global {@link Composer | composer instance} created with {@link createI18n}, or global {@link VueI18n | VueI18n instance}. + * You can get the exported composer instance in {@link I18nMode | Composition API mode}, or the Vuei18n instance in {@link I18nMode | Legacy API mode}, which is the instance you can refer to with this property. + * The locales, locale messages, and other resources managed by the instance referenced by this property are valid as global scope. + * If the `i18n` component custom option is not specified, it's the same as the VueI18n instance that can be referenced by the i18n instance {@link I18n.global | global} property. + */ + $i18n: VueI18n | ExportedGlobalComposer + /** + * Locale message translation + * + * @remarks + * If this is used in a reactive context, it will re-evaluate once the locale changes. + * + * In {@link I18nMode | Legacy API mode}, the input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#t | `VueI18n#t`}. + * + * In {@link I18nMode | Composition API mode}, the `$t` is injected by `app.config.globalProperties`. + * the input / output is the same as for Composer, and it work on **global scope**. About that details, see {@link Composer#t | `Composer#t` }. + * + * @param key - A target locale message key + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path + ): TranslateResult + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param locale - A locale, override locale that global scope or local scope + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path + ): TranslateResult + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param locale - A locale, override locale that global scope or local scope + * @param list - A values of list interpolation + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + locale: Locale, + list: unknown[] + ): TranslateResult + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param locale - A locale, override locale that global scope or local scope + * @param named - A values of named interpolation + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + locale: Locale, + named: object + ): TranslateResult + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param list - A values of list interpolation + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + list: unknown[] + ): TranslateResult + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param named - A values of named interpolation + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + named: Record + ): TranslateResult + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path + ): string + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param plural - A choice number of plural + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + plural: number + ): string + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param plural - Which plural string to get. 1 returns the first one. + * @param options - An options, see the {@link TranslateOptions} + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + plural: number, + options: TranslateOptions + ): string + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param defaultMsg - A default message to return if no translation was found + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + defaultMsg: string + ): string + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param defaultMsg - A default message to return if no translation was found + * @param options - An options, see the {@link TranslateOptions} + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + defaultMsg: string, + options: TranslateOptions + ): string + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param list - A values of list interpolation + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + list: unknown[] + ): string + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param list - A values of list interpolation + * @param plural - A choice number of plural + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + list: unknown[], + plural: number + ): string + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param list - A values of list interpolation + * @param defaultMsg - A default message to return if no translation was found + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + list: unknown[], + defaultMsg: string + ): string + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param list - A values of list interpolation + * @param options - An options, see the {@link TranslateOptions} + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + list: unknown[], + options: TranslateOptions + ): string + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param named - A values of named interpolation + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + named: NamedValue + ): string + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param named - A values of named interpolation + * @param plural - A choice number of plural + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + named: NamedValue, + plural: number + ): string + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param named - A values of named interpolation + * @param defaultMsg - A default message to return if no translation was found + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + named: NamedValue, + defaultMsg: string + ): string + /** + * Locale message translation + * + * @remarks + * Overloaded `$t`. About details, see the {@link $t} remarks. + * + * @param key - A target locale message key + * @param named - A values of named interpolation + * @param options - An options, see the {@link TranslateOptions} + * + * @returns translation message + */ + $t< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + named: NamedValue, + options: TranslateOptions + ): string + /** + * Resolve locale message translation + * + * @remarks + * If this is used in a reactive context, it will re-evaluate once the locale changes. + * + * In {@link I18nMode | Legacy API mode}, the input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#rt | `VueI18n#rt`}. + * + * In {@link I18nMode | Composition API mode}, the `$rt` is injected by `app.config.globalProperties`. + * the input / output is the same as for Composer, and it work on **global scope**. About that details, see {@link Composer#rt | `Composer#rt` }. + * + * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`. + * + * @returns translated message + */ + $rt(message: MessageFunction | VueMessageType): string + /** + * Resolve locale message translation for plurals + * + * @remarks + * Overloaded `$rt`. About details, see the {@link $rt} remarks. + * + * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`. + * @param plural - Which plural string to get. 1 returns the first one. + * @param options - Additional {@link TranslateOptions | options} for translation + * + * @returns Translated message + */ + $rt( + message: MessageFunction | VueMessageType, + plural: number, + options?: TranslateOptions + ): string + /** + * Resolve locale message translation for list interpolations + * + * @remarks + * Overloaded `$rt`. About details, see the {@link $rt} remarks. + * + * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`. + * @param list - A values of list interpolation. + * @param options - Additional {@link TranslateOptions | options} for translation + * + * @returns Translated message + */ + $rt( + message: MessageFunction | VueMessageType, + list: unknown[], + options?: TranslateOptions + ): string + /** + * Resolve locale message translation for named interpolations + * + * @remarks + * Overloaded `$rt`. About details, see the {@link $rt} remarks. + * + * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`. + * @param named - A values of named interpolation. + * @param options - Additional {@link TranslateOptions | options} for translation + * + * @returns Translated message + */ + $rt( + message: MessageFunction | VueMessageType, + named: NamedValue, + options?: TranslateOptions + ): string + /** + * Locale message pluralization + * + * @remarks + * If this is used in a reactive context, it will re-evaluate once the locale changes. + * + * The input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#tc | `VueI18n#tc` }. + * The value of plural is handled with default `1`. + * Supported for Legacy API mode only. + * + * @param key - A target locale message key + * + * @returns translation message that is pluraled + */ + $tc< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path + ): TranslateResult + /** + * Locale message pluralization + * + * @remarks + * Overloaded `$tc`. About details, see the {@link $tc} remarks. + * Supported for Legacy API mode only. + * + * @param key - A target locale message key + * @param locale - A locale, override locale that global scope or local scope + * + * @returns translation message that is pluraled + */ + $tc< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + locale: Locale + ): TranslateResult + /** + * Locale message pluralization + * + * @remarks + * Overloaded `$tc`. About details, see the {@link $tc} remarks. + * Supported for Legacy API mode only. + * + * @param key - A target locale message key + * @param list - A values of list interpolation + * + * @returns translation message that is pluraled + */ + $tc< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + list: unknown[] + ): TranslateResult + /** + * Locale message pluralization + * Supported for Legacy API mode only. + * + * @remarks + * Overloaded `$tc`. About details, see the {@link $tc} remarks. + * Supported for Legacy API mode only. + * + * @param key - A target locale message key + * @param named - A values of named interpolation + * + * @returns translation message that is pluraled + */ + $tc< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + named: Record + ): TranslateResult + /** + * Locale message pluralization + * Supported for Legacy API mode only. + * + * @remarks + * Overloaded `$tc`. About details, see the {@link $tc} remarks. + * Supported for Legacy API mode only. + * + * @param key - A target locale message key + * @param choice - Which plural string to get. 1 returns the first one. + * + * @returns translation message that is pluraled + */ + $tc< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + choice: number + ): TranslateResult + /** + * Locale message pluralization + * Supported for Legacy API mode only. + * + * @remarks + * Overloaded `$tc`. About details, see the {@link $tc} remarks. + * Supported for Legacy API mode only. + * + * @param key - A target locale message key + * @param choice - Which plural string to get. 1 returns the first one. + * @param locale - A locale, override locale that global scope or local scope + * + * @returns translation message that is pluraled + */ + $tc< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + choice: number, + locale: Locale + ): TranslateResult + /** + * Locale message pluralization + * Supported for Legacy API mode only. + * + * @remarks + * Overloaded `$tc`. About details, see the {@link $tc} remarks. + * Supported for Legacy API mode only. + * + * @param key - A target locale message key + * @param choice - Which plural string to get. 1 returns the first one. + * @param list - A values of list interpolation + * + * @returns translation message that is pluraled + */ + $tc< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + choice: number, + list: unknown[] + ): TranslateResult + /** + * Locale message pluralization + * Supported for Legacy API mode only. + * + * @remarks + * Overloaded `$tc`. About details, see the {@link $tc} remarks. + * Supported for Legacy API mode only. + * + * @param key - A target locale message key + * @param choice - Which plural string to get. 1 returns the first one. + * @param named - A values of named interpolation + * + * @returns translation message that is pluraled + */ + $tc< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + choice: number, + named: Record + ): TranslateResult + /** + * Translation message exist + * + * @remarks + * About that details, see {@link VueI18n#te | `VueI18n#te` } or {@link Composer#te | `Composer#te`}. + * + * @param key - A target locale message key + * @param locale - A locale, optional, override locale that global scope or local scope + * + * @returns If found locale message, `true`, else `false`, Note that `false` is returned even if the value present in the key is not translatable, yet if `translateExistCompatible` is set to `true`, it will return `true` if the key is available, even if the value is not translatable. + */ + $te< + Key extends string, + DefinedLocaleMessage extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupPaths<{ + [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + key: Key | ResourceKeys | Path, + locale?: Locale + ): boolean + /** + * Datetime formatting + * + * @remarks + * If this is used in a reactive context, it will re-evaluate once the locale changes. + * + * In {@link I18nMode | Legacy API mode}, the input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#d | `VueI18n#d` }. + * + * In {@link I18nMode | Composition API mode}, the `$d` is injected by `app.config.globalProperties`. + * the input / output is the same as for Composer instance, and it work on **global scope**. About that details, see {@link Composer#d | `Composer#d` }. + * + * @param value - A value, timestamp number or `Date` instance + * + * @returns formatted value + */ + $d(value: number | Date): DateTimeFormatResult + /** + * Datetime formatting + * + * @remarks + * Overloaded `$d`. About details, see the {@link $d} remarks. + * + * @param value - A value, timestamp number or `Date` instance + * @param key - A key of datetime formats + * + * @returns formatted value + */ + $d< + Value extends number | Date = number, + Key extends string = string, + DefinedDateTimeFormat extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupFormatPathKeys<{ + [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + value: Value, + key: Key | ResourceKeys + ): DateTimeFormatResult + /** + * Datetime formatting + * + * @remarks + * Overloaded `$d`. About details, see the {@link $d} remarks. + * + * @param value - A value, timestamp number or `Date` instance + * @param key - A key of datetime formats + * @param locale - A locale, optional, override locale that global scope or local scope + * + * @returns formatted value + */ + $d< + Value extends number | Date = number, + Key extends string = string, + DefinedDateTimeFormat extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupFormatPathKeys<{ + [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + value: Value, + key: Key | ResourceKeys, + locale: Locale + ): DateTimeFormatResult + /** + * Datetime formatting + * + * @remarks + * Overloaded `$d`. About details, see the {@link $d} remarks. + * + * @param value - A value, timestamp number or `Date` instance + * @param args - An argument values + * + * @returns formatted value + */ + $d( + value: number | Date, + args: { [key: string]: string } + ): DateTimeFormatResult + /** + * Datetime formatting + * + * @remarks + * Overloaded `$d`. About details, see the {@link $d} remarks. + * + * @param value - A value, timestamp number or `Date` instance + * + * @returns formatted value + */ + $d(value: number | Date): string + /** + * Datetime formatting + * + * @remarks + * Overloaded `$d`. About details, see the {@link $d} remarks. + * + * @param value - A value, timestamp number or `Date` instance + * @param key - A key of datetime formats + * + * @returns formatted value + */ + $d< + Value extends number | Date = number, + Key extends string = string, + DefinedDateTimeFormat extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupFormatPathKeys<{ + [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + value: Value, + key: Key | ResourceKeys + ): string + /** + * Datetime formatting + * + * @remarks + * Overloaded `$d`. About details, see the {@link $d} remarks. + * + * @param value - A value, timestamp number or `Date` instance + * @param key - A key of datetime formats + * @param locale - A locale, optional, override locale that global scope or local scope + * + * @returns formatted value + */ + $d< + Value extends number | Date = number, + Key extends string = string, + DefinedDateTimeFormat extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupFormatPathKeys<{ + [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + value: Value, + key: Key | ResourceKeys, + locale: Locale + ): string + /** + * Datetime formatting + * + * @remarks + * Overloaded `$d`. About details, see the {@link $d} remarks. + * + * @param value - A value, timestamp number or `Date` instance + * @param options - An options, see the {@link DateTimeOptions} + * + * @returns formatted value + */ + $d(value: number | Date, options: DateTimeOptions): string + /** + * Number formatting + * + * @remarks + * If this is used in a reactive context, it will re-evaluate once the locale changes. + * + * In {@link I18nMode | Legacy API mode}, the input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#n | `VueI18n.n` }. + * + * In {@link I18nMode | Composition API mode}, the `$n` is injected by `app.config.globalProperties`. + * the input / output is the same as for Composer instance, and it work on **global scope**. About that details, see {@link Composer#n | `Composer.n` }. + * + * @param value - A number value + * + * @returns formatted value + */ + $n(value: number): NumberFormatResult + /** + * Number formatting + * + * @remarks + * Overloaded `$n`. About details, see the {@link $n} remarks. + * + * @param value - A number value + * @param key - A key of number formats + * + * @returns formatted value + */ + $n< + Key extends string = string, + DefinedNumberFormat extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupFormatPathKeys<{ + [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + value: number, + key: Key | ResourceKeys + ): NumberFormatResult + /** + * Number formatting + * + * @remarks + * Overloaded `$n`. About details, see the {@link $n} remarks. + * + * @param value - A number value + * @param key - A key of number formats + * @param locale - A locale, optional, override locale that global scope or local scope + * + * @returns formatted value + */ + $n< + Key extends string = string, + DefinedNumberFormat extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupFormatPathKeys<{ + [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + value: number, + key: Key | ResourceKeys, + locale: Locale + ): NumberFormatResult + /** + * Number formatting + * + * @remarks + * Overloaded `$n`. About details, see the {@link $n} remarks. + * + * @param value - A number value + * @param args - An argument values + * + * @returns formatted value + */ + $n( + value: number, + args: { [key: string]: string | boolean | number } + ): NumberFormatResult + /** + * Number formatting + * + * @remarks + * Overloaded `$n`. About details, see the {@link $n} remarks. + * + * @param value - A number value + * @param key - A key of number formats + * @param args - An argument values + * + * @returns formatted value + */ + $n( + value: number, + key: string, + args: { [key: string]: string | boolean | number } + ): NumberFormatResult + /** + * Number formatting + * + * @remarks + * Overloaded `$n`. About details, see the {@link $n} remarks. + * + * @param value - A number value + * @param key - A key of number formats + * @param locale - A locale, optional, override locale that global scope or local scope + * @param args - An argument values + * + * @returns formatted value + */ + $n( + value: number, + key: string, + locale: Locale, + args: { [key: string]: string | boolean | number } + ): NumberFormatResult + /** + * Number formatting + * + * @remarks + * Overloaded `$n`. About details, see the {@link $n} remarks. + * + * @param value - A number value + * + * @returns formatted value + */ + $n(value: number): string + /** + * Number formatting + * + * @remarks + * Overloaded `$n`. About details, see the {@link $n} remarks. + * + * @param value - A number value + * @param key - A key of number formats + * + * @returns formatted value + */ + $n< + Key extends string = string, + DefinedNumberFormat extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupFormatPathKeys<{ + [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + value: number, + key: Key | ResourceKeys + ): string + /** + * Number formatting + * + * @remarks + * Overloaded `$n`. About details, see the {@link $n} remarks. + * + * @param value - A number value + * @param key - A key of number formats + * @param locale - A locale, optional, override locale that global scope or local scope + * + * @returns formatted value + */ + $n< + Key extends string = string, + DefinedNumberFormat extends + RemovedIndexResources = RemovedIndexResources, + Keys = IsEmptyObject extends false + ? PickupFormatPathKeys<{ + [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K] + }> + : never, + ResourceKeys extends Keys = IsNever extends false ? Keys : never + >( + value: number, + key: Key | ResourceKeys, + locale: Locale + ): string + /** + * Number formatting + * + * @remarks + * Overloaded `$n`. About details, see the {@link $n} remarks. + * + * @param value - A number value + * @param options - An options, see the {@link NumberOptions} + * + * @returns formatted value + */ + $n(value: number, options: NumberOptions): string + /** + * Locale messages getter + * + * In {@link I18nMode | Legacy API mode}, the input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#tm | `VueI18n#tm` }. + * + * @remarks + * In {@link I18nMode | Composition API mode}, the `$tm` is injected by `app.config.globalProperties`. + * the input / output is the same as for Composer instance, and it work on **global scope**. About that details, see {@link Composer#tm | `Composer.tm` }. + * Based on the current `locale`, locale messages will be returned from Composer instance messages. + * If you change the `locale`, the locale messages returned will also correspond to the locale. + * If there are no locale messages for the given `key` in the composer instance messages, they will be returned with fallbacking. + * + * @param key - A target locale message key + * + * @returns locale messages + */ + $tm< + Key extends string, + Messages extends object = {}, + ResourceKeys extends PickupKeys = PickupKeys + >( + key: Key | ResourceKeys + ): LocaleMessageValue | {} + } +} + +declare module 'vue' { + export interface GlobalComponents { + ['i18n-t']: typeof Translation + ['i18n-d']: typeof DatetimeFormat + ['i18n-n']: typeof NumberFormat + ['I18nT']: typeof Translation + ['I18nD']: typeof DatetimeFormat + ['I18nN']: typeof NumberFormat + } +} diff --git a/node_modules/vue-i18n/dist/vue-i18n.esm-browser.js b/node_modules/vue-i18n/dist/vue-i18n.esm-browser.js new file mode 100644 index 0000000..0c228d7 --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.esm-browser.js @@ -0,0 +1,6847 @@ +/*! + * vue-i18n v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +import { createVNode, Text, computed, watch, getCurrentInstance, ref, shallowRef, Fragment, defineComponent, h, effectScope, inject, onMounted, onUnmounted, onBeforeMount, isRef } from 'vue'; + +function warn(msg, err) { + if (typeof console !== 'undefined') { + console.warn(`[intlify] ` + msg); + /* istanbul ignore if */ + if (err) { + console.warn(err.stack); + } + } +} +const hasWarned = {}; +function warnOnce(msg) { + if (!hasWarned[msg]) { + hasWarned[msg] = true; + warn(msg); + } +} + +/** + * Original Utilities + * written by kazuya kawaguchi + */ +const inBrowser = typeof window !== 'undefined'; +let mark; +let measure; +{ + const perf = inBrowser && window.performance; + if (perf && + perf.mark && + perf.measure && + perf.clearMarks && + // @ts-ignore browser compat + perf.clearMeasures) { + mark = (tag) => { + perf.mark(tag); + }; + measure = (name, startTag, endTag) => { + perf.measure(name, startTag, endTag); + perf.clearMarks(startTag); + perf.clearMarks(endTag); + }; + } +} +const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g; +/* eslint-disable */ +function format$1(message, ...args) { + if (args.length === 1 && isObject(args[0])) { + args = args[0]; + } + if (!args || !args.hasOwnProperty) { + args = {}; + } + return message.replace(RE_ARGS, (match, identifier) => { + return args.hasOwnProperty(identifier) ? args[identifier] : ''; + }); +} +const makeSymbol = (name, shareable = false) => !shareable ? Symbol(name) : Symbol.for(name); +const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({ l: locale, k: key, s: source }); +const friendlyJSONstringify = (json) => JSON.stringify(json) + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029') + .replace(/\u0027/g, '\\u0027'); +const isNumber = (val) => typeof val === 'number' && isFinite(val); +const isDate = (val) => toTypeString(val) === '[object Date]'; +const isRegExp = (val) => toTypeString(val) === '[object RegExp]'; +const isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0; +const assign = Object.assign; +const _create = Object.create; +const create = (obj = null) => _create(obj); +let _globalThis; +const getGlobalThis = () => { + // prettier-ignore + return (_globalThis || + (_globalThis = + typeof globalThis !== 'undefined' + ? globalThis + : typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : create())); +}; +function escapeHtml(rawText) { + return rawText + .replace(/&/g, '&') // escape `&` first to avoid double escaping + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/\//g, '/') // escape `/` to prevent closing tags or JavaScript URLs + .replace(/=/g, '='); // escape `=` to prevent attribute injection +} +function escapeAttributeValue(value) { + return value + .replace(/&(?![a-zA-Z0-9#]{2,6};)/g, '&') // escape unescaped `&` + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(//g, '>'); +} +function sanitizeTranslatedHtml(html) { + // Escape dangerous characters in attribute values + // Process attributes with double quotes + html = html.replace(/(\w+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${escapeAttributeValue(attrValue)}"`); + // Process attributes with single quotes + html = html.replace(/(\w+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${escapeAttributeValue(attrValue)}'`); + // Detect and neutralize event handler attributes + const eventHandlerPattern = /\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi; + if (eventHandlerPattern.test(html)) { + { + warn('Potentially dangerous event handlers detected in translation. ' + + 'Consider removing onclick, onerror, etc. from your translation messages.'); + } + // Neutralize event handler attributes by escaping 'on' + html = html.replace(/(\s+)(on)(\w+\s*=)/gi, '$1on$3'); + } + // Disable javascript: URLs in various contexts + const javascriptUrlPattern = [ + // In href, src, action, formaction attributes + /(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi, + // In style attributes within url() + /(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi + ]; + javascriptUrlPattern.forEach(pattern => { + html = html.replace(pattern, '$1javascript:'); + }); + return html; +} +const hasOwnProperty = Object.prototype.hasOwnProperty; +function hasOwn(obj, key) { + return hasOwnProperty.call(obj, key); +} +/* eslint-enable */ +/** + * Useful Utilities By Evan you + * Modified by kazuya kawaguchi + * MIT License + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts + */ +const isArray = Array.isArray; +const isFunction = (val) => typeof val === 'function'; +const isString = (val) => typeof val === 'string'; +const isBoolean = (val) => typeof val === 'boolean'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isObject = (val) => val !== null && typeof val === 'object'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isPromise = (val) => { + return isObject(val) && isFunction(val.then) && isFunction(val.catch); +}; +const objectToString = Object.prototype.toString; +const toTypeString = (value) => objectToString.call(value); +const isPlainObject = (val) => { + if (!isObject(val)) + return false; + const proto = Object.getPrototypeOf(val); + return proto === null || proto.constructor === Object; +}; +// for converting list and named values to displayed strings. +const toDisplayString = (val) => { + return val == null + ? '' + : isArray(val) || (isPlainObject(val) && val.toString === objectToString) + ? JSON.stringify(val, null, 2) + : String(val); +}; +function join(items, separator = '') { + return items.reduce((str, item, index) => (index === 0 ? str + item : str + separator + item), ''); +} +const RANGE = 2; +function generateCodeFrame(source, start = 0, end = source.length) { + const lines = source.split(/\r?\n/); + let count = 0; + const res = []; + for (let i = 0; i < lines.length; i++) { + count += lines[i].length + 1; + if (count >= start) { + for (let j = i - RANGE; j <= i + RANGE || end > count; j++) { + if (j < 0 || j >= lines.length) + continue; + const line = j + 1; + res.push(`${line}${' '.repeat(3 - String(line).length)}| ${lines[j]}`); + const lineLength = lines[j].length; + if (j === i) { + // push underline + const pad = start - (count - lineLength) + 1; + const length = Math.max(1, end > count ? lineLength - pad : end - start); + res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length)); + } + else if (j > i) { + if (end > count) { + const length = Math.max(Math.min(end - count, lineLength), 1); + res.push(` | ` + '^'.repeat(length)); + } + count += lineLength + 1; + } + } + break; + } + } + return res.join('\n'); +} +function incrementer(code) { + let current = code; + return () => ++current; +} + +/** + * Event emitter, forked from the below: + * - original repository url: https://github.com/developit/mitt + * - code url: https://github.com/developit/mitt/blob/master/src/index.ts + * - author: Jason Miller (https://github.com/developit) + * - license: MIT + */ +/** + * Create a event emitter + * + * @returns An event emitter + */ +function createEmitter() { + const events = new Map(); + const emitter = { + events, + on(event, handler) { + const handlers = events.get(event); + const added = handlers && handlers.push(handler); + if (!added) { + events.set(event, [handler]); + } + }, + off(event, handler) { + const handlers = events.get(event); + if (handlers) { + handlers.splice(handlers.indexOf(handler) >>> 0, 1); + } + }, + emit(event, payload) { + (events.get(event) || []) + .slice() + .map(handler => handler(payload)); + (events.get('*') || []) + .slice() + .map(handler => handler(event, payload)); + } + }; + return emitter; +} + +const isNotObjectOrIsArray = (val) => !isObject(val) || isArray(val); +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types +function deepCopy(src, des) { + // src and des should both be objects, and none of them can be a array + if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des)) { + throw new Error('Invalid value'); + } + const stack = [{ src, des }]; + while (stack.length) { + const { src, des } = stack.pop(); + // using `Object.keys` which skips prototype properties + Object.keys(src).forEach(key => { + if (key === '__proto__') { + return; + } + // if src[key] is an object/array, set des[key] + // to empty object/array to prevent setting by reference + if (isObject(src[key]) && !isObject(des[key])) { + des[key] = Array.isArray(src[key]) ? [] : create(); + } + if (isNotObjectOrIsArray(des[key]) || isNotObjectOrIsArray(src[key])) { + // replace with src[key] when: + // src[key] or des[key] is not an object, or + // src[key] or des[key] is an array + des[key] = src[key]; + } + else { + // src[key] and des[key] are both objects, merge them + stack.push({ src: src[key], des: des[key] }); + } + }); + } +} + +function createPosition(line, column, offset) { + return { line, column, offset }; +} +function createLocation(start, end, source) { + const loc = { start, end }; + if (source != null) { + loc.source = source; + } + return loc; +} + +const CompileWarnCodes = { + USE_MODULO_SYNTAX: 1, + __EXTEND_POINT__: 2 +}; +/** @internal */ +const warnMessages$2 = { + [CompileWarnCodes.USE_MODULO_SYNTAX]: `Use modulo before '{{0}}'.` +}; +function createCompileWarn(code, loc, ...args) { + const msg = format$1(warnMessages$2[code] || '', ...(args || [])) ; + const message = { message: String(msg), code }; + if (loc) { + message.location = loc; + } + return message; +} + +const CompileErrorCodes = { + // tokenizer error codes + EXPECTED_TOKEN: 1, + INVALID_TOKEN_IN_PLACEHOLDER: 2, + UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3, + UNKNOWN_ESCAPE_SEQUENCE: 4, + INVALID_UNICODE_ESCAPE_SEQUENCE: 5, + UNBALANCED_CLOSING_BRACE: 6, + UNTERMINATED_CLOSING_BRACE: 7, + EMPTY_PLACEHOLDER: 8, + NOT_ALLOW_NEST_PLACEHOLDER: 9, + INVALID_LINKED_FORMAT: 10, + // parser error codes + MUST_HAVE_MESSAGES_IN_PLURAL: 11, + UNEXPECTED_EMPTY_LINKED_MODIFIER: 12, + UNEXPECTED_EMPTY_LINKED_KEY: 13, + UNEXPECTED_LEXICAL_ANALYSIS: 14, + // generator error codes + UNHANDLED_CODEGEN_NODE_TYPE: 15, + // minifier error codes + UNHANDLED_MINIFIER_NODE_TYPE: 16, + // Special value for higher-order compilers to pick up the last code + // to avoid collision of error codes. This should always be kept as the last + // item. + __EXTEND_POINT__: 17 +}; +/** @internal */ +const errorMessages$2 = { + // tokenizer error messages + [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`, + [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`, + [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`, + [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`, + [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`, + [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`, + [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`, + [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`, + [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`, + [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`, + // parser error messages + [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`, + [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`, + // generator error messages + [CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`, + // minimizer error messages + [CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'` +}; +function createCompileError(code, loc, options = {}) { + const { domain, messages, args } = options; + const msg = format$1((messages || errorMessages$2)[code] || '', ...(args || [])) + ; + const error = new SyntaxError(String(msg)); + error.code = code; + if (loc) { + error.location = loc; + } + error.domain = domain; + return error; +} +/** @internal */ +function defaultOnError(error) { + throw error; +} + +// eslint-disable-next-line no-useless-escape +const RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/; +const detectHtmlTag = (source) => RE_HTML_TAG.test(source); + +const CHAR_SP = ' '; +const CHAR_CR = '\r'; +const CHAR_LF = '\n'; +const CHAR_LS = String.fromCharCode(0x2028); +const CHAR_PS = String.fromCharCode(0x2029); +function createScanner(str) { + const _buf = str; + let _index = 0; + let _line = 1; + let _column = 1; + let _peekOffset = 0; + const isCRLF = (index) => _buf[index] === CHAR_CR && _buf[index + 1] === CHAR_LF; + const isLF = (index) => _buf[index] === CHAR_LF; + const isPS = (index) => _buf[index] === CHAR_PS; + const isLS = (index) => _buf[index] === CHAR_LS; + const isLineEnd = (index) => isCRLF(index) || isLF(index) || isPS(index) || isLS(index); + const index = () => _index; + const line = () => _line; + const column = () => _column; + const peekOffset = () => _peekOffset; + const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset]; + const currentChar = () => charAt(_index); + const currentPeek = () => charAt(_index + _peekOffset); + function next() { + _peekOffset = 0; + if (isLineEnd(_index)) { + _line++; + _column = 0; + } + if (isCRLF(_index)) { + _index++; + } + _index++; + _column++; + return _buf[_index]; + } + function peek() { + if (isCRLF(_index + _peekOffset)) { + _peekOffset++; + } + _peekOffset++; + return _buf[_index + _peekOffset]; + } + function reset() { + _index = 0; + _line = 1; + _column = 1; + _peekOffset = 0; + } + function resetPeek(offset = 0) { + _peekOffset = offset; + } + function skipToPeek() { + const target = _index + _peekOffset; + // eslint-disable-next-line no-unmodified-loop-condition + while (target !== _index) { + next(); + } + _peekOffset = 0; + } + return { + index, + line, + column, + peekOffset, + charAt, + currentChar, + currentPeek, + next, + peek, + reset, + resetPeek, + skipToPeek + }; +} + +const EOF = undefined; +const DOT = '.'; +const LITERAL_DELIMITER = "'"; +const ERROR_DOMAIN$3 = 'tokenizer'; +function createTokenizer(source, options = {}) { + const location = options.location !== false; + const _scnr = createScanner(source); + const currentOffset = () => _scnr.index(); + const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index()); + const _initLoc = currentPosition(); + const _initOffset = currentOffset(); + const _context = { + currentType: 14 /* TokenTypes.EOF */, + offset: _initOffset, + startLoc: _initLoc, + endLoc: _initLoc, + lastType: 14 /* TokenTypes.EOF */, + lastOffset: _initOffset, + lastStartLoc: _initLoc, + lastEndLoc: _initLoc, + braceNest: 0, + inLinked: false, + text: '' + }; + const context = () => _context; + const { onError } = options; + function emitError(code, pos, offset, ...args) { + const ctx = context(); + pos.column += offset; + pos.offset += offset; + if (onError) { + const loc = location ? createLocation(ctx.startLoc, pos) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$3, + args + }); + onError(err); + } + } + function getToken(context, type, value) { + context.endLoc = currentPosition(); + context.currentType = type; + const token = { type }; + if (location) { + token.loc = createLocation(context.startLoc, context.endLoc); + } + if (value != null) { + token.value = value; + } + return token; + } + const getEndToken = (context) => getToken(context, 14 /* TokenTypes.EOF */); + function eat(scnr, ch) { + if (scnr.currentChar() === ch) { + scnr.next(); + return ch; + } + else { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + return ''; + } + } + function peekSpaces(scnr) { + let buf = ''; + while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) { + buf += scnr.currentPeek(); + scnr.peek(); + } + return buf; + } + function skipSpaces(scnr) { + const buf = peekSpaces(scnr); + scnr.skipToPeek(); + return buf; + } + function isIdentifierStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + cc === 95 // _ + ); + } + function isNumberStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function isNamedIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isListIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ch = scnr.currentPeek() === '-' ? scnr.peek() : scnr.currentPeek(); + const ret = isNumberStart(ch); + scnr.resetPeek(); + return ret; + } + function isLiteralStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === LITERAL_DELIMITER; + scnr.resetPeek(); + return ret; + } + function isLinkedDotStart(scnr, context) { + const { currentType } = context; + if (currentType !== 8 /* TokenTypes.LinkedAlias */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === "." /* TokenChars.LinkedDot */; + scnr.resetPeek(); + return ret; + } + function isLinkedModifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 9 /* TokenTypes.LinkedDot */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isLinkedDelimiterStart(scnr, context) { + const { currentType } = context; + if (!(currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 12 /* TokenTypes.LinkedModifier */)) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === ":" /* TokenChars.LinkedDelimiter */; + scnr.resetPeek(); + return ret; + } + function isLinkedReferStart(scnr, context) { + const { currentType } = context; + if (currentType !== 10 /* TokenTypes.LinkedDelimiter */) { + return false; + } + const fn = () => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return isIdentifierStart(scnr.peek()); + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "|" /* TokenChars.Pipe */ || + ch === ":" /* TokenChars.LinkedDelimiter */ || + ch === "." /* TokenChars.LinkedDot */ || + ch === CHAR_SP || + !ch) { + return false; + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(); + } + else { + // other characters + return isTextStart(scnr, false); + } + }; + const ret = fn(); + scnr.resetPeek(); + return ret; + } + function isPluralStart(scnr) { + peekSpaces(scnr); + const ret = scnr.currentPeek() === "|" /* TokenChars.Pipe */; + scnr.resetPeek(); + return ret; + } + function detectModuloStart(scnr) { + const spaces = peekSpaces(scnr); + const ret = scnr.currentPeek() === "%" /* TokenChars.Modulo */ && + scnr.peek() === "{" /* TokenChars.BraceLeft */; + scnr.resetPeek(); + return { + isModulo: ret, + hasSpace: spaces.length > 0 + }; + } + function isTextStart(scnr, reset = true) { + const fn = (hasSpace = false, prev = '', detectModulo = false) => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return prev === "%" /* TokenChars.Modulo */ ? false : hasSpace; + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || !ch) { + return prev === "%" /* TokenChars.Modulo */ ? true : hasSpace; + } + else if (ch === "%" /* TokenChars.Modulo */) { + scnr.peek(); + return fn(hasSpace, "%" /* TokenChars.Modulo */, true); + } + else if (ch === "|" /* TokenChars.Pipe */) { + return prev === "%" /* TokenChars.Modulo */ || detectModulo + ? true + : !(prev === CHAR_SP || prev === CHAR_LF); + } + else if (ch === CHAR_SP) { + scnr.peek(); + return fn(true, CHAR_SP, detectModulo); + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(true, CHAR_LF, detectModulo); + } + else { + return true; + } + }; + const ret = fn(); + reset && scnr.resetPeek(); + return ret; + } + function takeChar(scnr, fn) { + const ch = scnr.currentChar(); + if (ch === EOF) { + return EOF; + } + if (fn(ch)) { + scnr.next(); + return ch; + } + return null; + } + function isIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 // $ + ); + } + function takeIdentifierChar(scnr) { + return takeChar(scnr, isIdentifier); + } + function isNamedIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 || // $ + cc === 45 // - + ); + } + function takeNamedIdentifierChar(scnr) { + return takeChar(scnr, isNamedIdentifier); + } + function isDigit(ch) { + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function takeDigit(scnr) { + return takeChar(scnr, isDigit); + } + function isHexDigit(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 48 && cc <= 57) || // 0-9 + (cc >= 65 && cc <= 70) || // A-F + (cc >= 97 && cc <= 102)); // a-f + } + function takeHexDigit(scnr) { + return takeChar(scnr, isHexDigit); + } + function getDigits(scnr) { + let ch = ''; + let num = ''; + while ((ch = takeDigit(scnr))) { + num += ch; + } + return num; + } + function readModulo(scnr) { + skipSpaces(scnr); + const ch = scnr.currentChar(); + if (ch !== "%" /* TokenChars.Modulo */) { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + } + scnr.next(); + return "%" /* TokenChars.Modulo */; + } + function readText(scnr) { + let buf = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "}" /* TokenChars.BraceRight */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + !ch) { + break; + } + else if (ch === "%" /* TokenChars.Modulo */) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else { + break; + } + } + else if (ch === CHAR_SP || ch === CHAR_LF) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else if (isPluralStart(scnr)) { + break; + } + else { + buf += ch; + scnr.next(); + } + } + else { + buf += ch; + scnr.next(); + } + } + return buf; + } + function readNamedIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let name = ''; + while ((ch = takeNamedIdentifierChar(scnr))) { + name += ch; + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return name; + } + function readListIdentifier(scnr) { + skipSpaces(scnr); + let value = ''; + if (scnr.currentChar() === '-') { + scnr.next(); + value += `-${getDigits(scnr)}`; + } + else { + value += getDigits(scnr); + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return value; + } + function isLiteral(ch) { + return ch !== LITERAL_DELIMITER && ch !== CHAR_LF; + } + function readLiteral(scnr) { + skipSpaces(scnr); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + let ch = ''; + let literal = ''; + while ((ch = takeChar(scnr, isLiteral))) { + if (ch === '\\') { + literal += readEscapeSequence(scnr); + } + else { + literal += ch; + } + } + const current = scnr.currentChar(); + if (current === CHAR_LF || current === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, currentPosition(), 0); + // TODO: Is it correct really? + if (current === CHAR_LF) { + scnr.next(); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + } + return literal; + } + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + return literal; + } + function readEscapeSequence(scnr) { + const ch = scnr.currentChar(); + switch (ch) { + case '\\': + case `\'`: // eslint-disable-line no-useless-escape + scnr.next(); + return `\\${ch}`; + case 'u': + return readUnicodeEscapeSequence(scnr, ch, 4); + case 'U': + return readUnicodeEscapeSequence(scnr, ch, 6); + default: + emitError(CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, currentPosition(), 0, ch); + return ''; + } + } + function readUnicodeEscapeSequence(scnr, unicode, digits) { + eat(scnr, unicode); + let sequence = ''; + for (let i = 0; i < digits; i++) { + const ch = takeHexDigit(scnr); + if (!ch) { + emitError(CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`); + break; + } + sequence += ch; + } + return `\\${unicode}${sequence}`; + } + function isInvalidIdentifier(ch) { + return (ch !== "{" /* TokenChars.BraceLeft */ && + ch !== "}" /* TokenChars.BraceRight */ && + ch !== CHAR_SP && + ch !== CHAR_LF); + } + function readInvalidIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let identifiers = ''; + while ((ch = takeChar(scnr, isInvalidIdentifier))) { + identifiers += ch; + } + return identifiers; + } + function readLinkedModifier(scnr) { + let ch = ''; + let name = ''; + while ((ch = takeIdentifierChar(scnr))) { + name += ch; + } + return name; + } + function readLinkedRefer(scnr) { + const fn = (buf) => { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + ch === "(" /* TokenChars.ParenLeft */ || + ch === ")" /* TokenChars.ParenRight */ || + !ch) { + return buf; + } + else if (ch === CHAR_SP) { + return buf; + } + else if (ch === CHAR_LF || ch === DOT) { + buf += ch; + scnr.next(); + return fn(buf); + } + else { + buf += ch; + scnr.next(); + return fn(buf); + } + }; + return fn(''); + } + function readPlural(scnr) { + skipSpaces(scnr); + const plural = eat(scnr, "|" /* TokenChars.Pipe */); + skipSpaces(scnr); + return plural; + } + // TODO: We need refactoring of token parsing ... + function readTokenInPlaceholder(scnr, context) { + let token = null; + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + if (context.braceNest >= 1) { + emitError(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 2 /* TokenTypes.BraceLeft */, "{" /* TokenChars.BraceLeft */); + skipSpaces(scnr); + context.braceNest++; + return token; + case "}" /* TokenChars.BraceRight */: + if (context.braceNest > 0 && + context.currentType === 2 /* TokenTypes.BraceLeft */) { + emitError(CompileErrorCodes.EMPTY_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + context.braceNest--; + context.braceNest > 0 && skipSpaces(scnr); + if (context.inLinked && context.braceNest === 0) { + context.inLinked = false; + } + return token; + case "@" /* TokenChars.LinkedAlias */: + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = readTokenInLinked(scnr, context) || getEndToken(context); + context.braceNest = 0; + return token; + default: { + let validNamedIdentifier = true; + let validListIdentifier = true; + let validLiteral = true; + if (isPluralStart(scnr)) { + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (context.braceNest > 0 && + (context.currentType === 5 /* TokenTypes.Named */ || + context.currentType === 6 /* TokenTypes.List */ || + context.currentType === 7 /* TokenTypes.Literal */)) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + context.braceNest = 0; + return readToken(scnr, context); + } + if ((validNamedIdentifier = isNamedIdentifierStart(scnr, context))) { + token = getToken(context, 5 /* TokenTypes.Named */, readNamedIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validListIdentifier = isListIdentifierStart(scnr, context))) { + token = getToken(context, 6 /* TokenTypes.List */, readListIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validLiteral = isLiteralStart(scnr, context))) { + token = getToken(context, 7 /* TokenTypes.Literal */, readLiteral(scnr)); + skipSpaces(scnr); + return token; + } + if (!validNamedIdentifier && !validListIdentifier && !validLiteral) { + // TODO: we should be re-designed invalid cases, when we will extend message syntax near the future ... + token = getToken(context, 13 /* TokenTypes.InvalidPlace */, readInvalidIdentifier(scnr)); + emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value); + skipSpaces(scnr); + return token; + } + break; + } + } + return token; + } + // TODO: We need refactoring of token parsing ... + function readTokenInLinked(scnr, context) { + const { currentType } = context; + let token = null; + const ch = scnr.currentChar(); + if ((currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 9 /* TokenTypes.LinkedDot */ || + currentType === 12 /* TokenTypes.LinkedModifier */ || + currentType === 10 /* TokenTypes.LinkedDelimiter */) && + (ch === CHAR_LF || ch === CHAR_SP)) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + switch (ch) { + case "@" /* TokenChars.LinkedAlias */: + scnr.next(); + token = getToken(context, 8 /* TokenTypes.LinkedAlias */, "@" /* TokenChars.LinkedAlias */); + context.inLinked = true; + return token; + case "." /* TokenChars.LinkedDot */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 9 /* TokenTypes.LinkedDot */, "." /* TokenChars.LinkedDot */); + case ":" /* TokenChars.LinkedDelimiter */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 10 /* TokenTypes.LinkedDelimiter */, ":" /* TokenChars.LinkedDelimiter */); + default: + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (isLinkedDotStart(scnr, context) || + isLinkedDelimiterStart(scnr, context)) { + skipSpaces(scnr); + return readTokenInLinked(scnr, context); + } + if (isLinkedModifierStart(scnr, context)) { + skipSpaces(scnr); + return getToken(context, 12 /* TokenTypes.LinkedModifier */, readLinkedModifier(scnr)); + } + if (isLinkedReferStart(scnr, context)) { + skipSpaces(scnr); + if (ch === "{" /* TokenChars.BraceLeft */) { + // scan the placeholder + return readTokenInPlaceholder(scnr, context) || token; + } + else { + return getToken(context, 11 /* TokenTypes.LinkedKey */, readLinkedRefer(scnr)); + } + } + if (currentType === 8 /* TokenTypes.LinkedAlias */) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + context.braceNest = 0; + context.inLinked = false; + return readToken(scnr, context); + } + } + // TODO: We need refactoring of token parsing ... + function readToken(scnr, context) { + let token = { type: 14 /* TokenTypes.EOF */ }; + if (context.braceNest > 0) { + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + } + if (context.inLinked) { + return readTokenInLinked(scnr, context) || getEndToken(context); + } + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + case "}" /* TokenChars.BraceRight */: + emitError(CompileErrorCodes.UNBALANCED_CLOSING_BRACE, currentPosition(), 0); + scnr.next(); + return getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + case "@" /* TokenChars.LinkedAlias */: + return readTokenInLinked(scnr, context) || getEndToken(context); + default: { + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + const { isModulo, hasSpace } = detectModuloStart(scnr); + if (isModulo) { + return hasSpace + ? getToken(context, 0 /* TokenTypes.Text */, readText(scnr)) + : getToken(context, 4 /* TokenTypes.Modulo */, readModulo(scnr)); + } + if (isTextStart(scnr)) { + return getToken(context, 0 /* TokenTypes.Text */, readText(scnr)); + } + break; + } + } + return token; + } + function nextToken() { + const { currentType, offset, startLoc, endLoc } = _context; + _context.lastType = currentType; + _context.lastOffset = offset; + _context.lastStartLoc = startLoc; + _context.lastEndLoc = endLoc; + _context.offset = currentOffset(); + _context.startLoc = currentPosition(); + if (_scnr.currentChar() === EOF) { + return getToken(_context, 14 /* TokenTypes.EOF */); + } + return readToken(_scnr, _context); + } + return { + nextToken, + currentOffset, + currentPosition, + context + }; +} + +const ERROR_DOMAIN$2 = 'parser'; +// Backslash backslash, backslash quote, uHHHH, UHHHHHH. +const KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g; +function fromEscapeSequence(match, codePoint4, codePoint6) { + switch (match) { + case `\\\\`: + return `\\`; + // eslint-disable-next-line no-useless-escape + case `\\\'`: + // eslint-disable-next-line no-useless-escape + return `\'`; + default: { + const codePoint = parseInt(codePoint4 || codePoint6, 16); + if (codePoint <= 0xd7ff || codePoint >= 0xe000) { + return String.fromCodePoint(codePoint); + } + // invalid ... + // Replace them with U+FFFD REPLACEMENT CHARACTER. + return '�'; + } + } +} +function createParser(options = {}) { + const location = options.location !== false; + const { onError, onWarn } = options; + function emitError(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onError) { + const loc = location ? createLocation(start, end) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$2, + args + }); + onError(err); + } + } + function emitWarn(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onWarn) { + const loc = location ? createLocation(start, end) : null; + onWarn(createCompileWarn(code, loc, args)); + } + } + function startNode(type, offset, loc) { + const node = { type }; + if (location) { + node.start = offset; + node.end = offset; + node.loc = { start: loc, end: loc }; + } + return node; + } + function endNode(node, offset, pos, type) { + if (type) { + node.type = type; + } + if (location) { + node.end = offset; + if (node.loc) { + node.loc.end = pos; + } + } + } + function parseText(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(3 /* NodeTypes.Text */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseList(tokenizer, index) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(5 /* NodeTypes.List */, offset, loc); + node.index = parseInt(index, 10); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseNamed(tokenizer, key, modulo) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(4 /* NodeTypes.Named */, offset, loc); + node.key = key; + if (modulo === true) { + node.modulo = true; + } + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLiteral(tokenizer, value) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(9 /* NodeTypes.Literal */, offset, loc); + node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinkedModifier(tokenizer) { + const token = tokenizer.nextToken(); + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get linked dot loc + const node = startNode(8 /* NodeTypes.LinkedModifier */, offset, loc); + if (token.type !== 12 /* TokenTypes.LinkedModifier */) { + // empty modifier + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0); + node.value = ''; + endNode(node, offset, loc); + return { + nextConsumeToken: token, + node + }; + } + // check token + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.value = token.value || ''; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node + }; + } + function parseLinkedKey(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(7 /* NodeTypes.LinkedKey */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinked(tokenizer) { + const context = tokenizer.context(); + const linkedNode = startNode(6 /* NodeTypes.Linked */, context.offset, context.startLoc); + let token = tokenizer.nextToken(); + if (token.type === 9 /* TokenTypes.LinkedDot */) { + const parsed = parseLinkedModifier(tokenizer); + linkedNode.modifier = parsed.node; + token = parsed.nextConsumeToken || tokenizer.nextToken(); + } + // asset check token + if (token.type !== 10 /* TokenTypes.LinkedDelimiter */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + token = tokenizer.nextToken(); + // skip brace left + if (token.type === 2 /* TokenTypes.BraceLeft */) { + token = tokenizer.nextToken(); + } + switch (token.type) { + case 11 /* TokenTypes.LinkedKey */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseNamed(tokenizer, token.value || ''); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseList(tokenizer, token.value || ''); + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLiteral(tokenizer, token.value || ''); + break; + default: { + // empty key + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0); + const nextContext = tokenizer.context(); + const emptyLinkedKeyNode = startNode(7 /* NodeTypes.LinkedKey */, nextContext.offset, nextContext.startLoc); + emptyLinkedKeyNode.value = ''; + endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc); + linkedNode.key = emptyLinkedKeyNode; + endNode(linkedNode, nextContext.offset, nextContext.startLoc); + return { + nextConsumeToken: token, + node: linkedNode + }; + } + } + endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node: linkedNode + }; + } + function parseMessage(tokenizer) { + const context = tokenizer.context(); + const startOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? tokenizer.currentOffset() + : context.offset; + const startLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.endLoc + : context.startLoc; + const node = startNode(2 /* NodeTypes.Message */, startOffset, startLoc); + node.items = []; + let nextToken = null; + let modulo = null; + do { + const token = nextToken || tokenizer.nextToken(); + nextToken = null; + switch (token.type) { + case 0 /* TokenTypes.Text */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseText(tokenizer, token.value || '')); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseList(tokenizer, token.value || '')); + break; + case 4 /* TokenTypes.Modulo */: + modulo = true; + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseNamed(tokenizer, token.value || '', !!modulo)); + if (modulo) { + emitWarn(tokenizer, CompileWarnCodes.USE_MODULO_SYNTAX, context.lastStartLoc, 0, getTokenCaption(token)); + modulo = null; + } + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseLiteral(tokenizer, token.value || '')); + break; + case 8 /* TokenTypes.LinkedAlias */: { + const parsed = parseLinked(tokenizer); + node.items.push(parsed.node); + nextToken = parsed.nextConsumeToken || null; + break; + } + } + } while (context.currentType !== 14 /* TokenTypes.EOF */ && + context.currentType !== 1 /* TokenTypes.Pipe */); + // adjust message node loc + const endOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastOffset + : tokenizer.currentOffset(); + const endLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastEndLoc + : tokenizer.currentPosition(); + endNode(node, endOffset, endLoc); + return node; + } + function parsePlural(tokenizer, offset, loc, msgNode) { + const context = tokenizer.context(); + let hasEmptyMessage = msgNode.items.length === 0; + const node = startNode(1 /* NodeTypes.Plural */, offset, loc); + node.cases = []; + node.cases.push(msgNode); + do { + const msg = parseMessage(tokenizer); + if (!hasEmptyMessage) { + hasEmptyMessage = msg.items.length === 0; + } + node.cases.push(msg); + } while (context.currentType !== 14 /* TokenTypes.EOF */); + if (hasEmptyMessage) { + emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseResource(tokenizer) { + const context = tokenizer.context(); + const { offset, startLoc } = context; + const msgNode = parseMessage(tokenizer); + if (context.currentType === 14 /* TokenTypes.EOF */) { + return msgNode; + } + else { + return parsePlural(tokenizer, offset, startLoc, msgNode); + } + } + function parse(source) { + const tokenizer = createTokenizer(source, assign({}, options)); + const context = tokenizer.context(); + const node = startNode(0 /* NodeTypes.Resource */, context.offset, context.startLoc); + if (location && node.loc) { + node.loc.source = source; + } + node.body = parseResource(tokenizer); + if (options.onCacheKey) { + node.cacheKey = options.onCacheKey(source); + } + // assert whether achieved to EOF + if (context.currentType !== 14 /* TokenTypes.EOF */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || ''); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + return { parse }; +} +function getTokenCaption(token) { + if (token.type === 14 /* TokenTypes.EOF */) { + return 'EOF'; + } + const name = (token.value || '').replace(/\r?\n/gu, '\\n'); + return name.length > 10 ? name.slice(0, 9) + '…' : name; +} + +function createTransformer(ast, options = {} // eslint-disable-line +) { + const _context = { + ast, + helpers: new Set() + }; + const context = () => _context; + const helper = (name) => { + _context.helpers.add(name); + return name; + }; + return { context, helper }; +} +function traverseNodes(nodes, transformer) { + for (let i = 0; i < nodes.length; i++) { + traverseNode(nodes[i], transformer); + } +} +function traverseNode(node, transformer) { + // TODO: if we need pre-hook of transform, should be implemented to here + switch (node.type) { + case 1 /* NodeTypes.Plural */: + traverseNodes(node.cases, transformer); + transformer.helper("plural" /* HelperNameMap.PLURAL */); + break; + case 2 /* NodeTypes.Message */: + traverseNodes(node.items, transformer); + break; + case 6 /* NodeTypes.Linked */: { + const linked = node; + traverseNode(linked.key, transformer); + transformer.helper("linked" /* HelperNameMap.LINKED */); + transformer.helper("type" /* HelperNameMap.TYPE */); + break; + } + case 5 /* NodeTypes.List */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("list" /* HelperNameMap.LIST */); + break; + case 4 /* NodeTypes.Named */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("named" /* HelperNameMap.NAMED */); + break; + } + // TODO: if we need post-hook of transform, should be implemented to here +} +// transform AST +function transform(ast, options = {} // eslint-disable-line +) { + const transformer = createTransformer(ast); + transformer.helper("normalize" /* HelperNameMap.NORMALIZE */); + // traverse + ast.body && traverseNode(ast.body, transformer); + // set meta information + const context = transformer.context(); + ast.helpers = Array.from(context.helpers); +} + +function optimize(ast) { + const body = ast.body; + if (body.type === 2 /* NodeTypes.Message */) { + optimizeMessageNode(body); + } + else { + body.cases.forEach(c => optimizeMessageNode(c)); + } + return ast; +} +function optimizeMessageNode(message) { + if (message.items.length === 1) { + const item = message.items[0]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + message.static = item.value; + delete item.value; // optimization for size + } + } + else { + const values = []; + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (!(item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */)) { + break; + } + if (item.value == null) { + break; + } + values.push(item.value); + } + if (values.length === message.items.length) { + message.static = join(values); + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + delete item.value; // optimization for size + } + } + } + } +} + +const ERROR_DOMAIN$1 = 'minifier'; +/* eslint-disable @typescript-eslint/no-explicit-any */ +function minify(node) { + node.t = node.type; + switch (node.type) { + case 0 /* NodeTypes.Resource */: { + const resource = node; + minify(resource.body); + resource.b = resource.body; + delete resource.body; + break; + } + case 1 /* NodeTypes.Plural */: { + const plural = node; + const cases = plural.cases; + for (let i = 0; i < cases.length; i++) { + minify(cases[i]); + } + plural.c = cases; + delete plural.cases; + break; + } + case 2 /* NodeTypes.Message */: { + const message = node; + const items = message.items; + for (let i = 0; i < items.length; i++) { + minify(items[i]); + } + message.i = items; + delete message.items; + if (message.static) { + message.s = message.static; + delete message.static; + } + break; + } + case 3 /* NodeTypes.Text */: + case 9 /* NodeTypes.Literal */: + case 8 /* NodeTypes.LinkedModifier */: + case 7 /* NodeTypes.LinkedKey */: { + const valueNode = node; + if (valueNode.value) { + valueNode.v = valueNode.value; + delete valueNode.value; + } + break; + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + minify(linked.key); + linked.k = linked.key; + delete linked.key; + if (linked.modifier) { + minify(linked.modifier); + linked.m = linked.modifier; + delete linked.modifier; + } + break; + } + case 5 /* NodeTypes.List */: { + const list = node; + list.i = list.index; + delete list.index; + break; + } + case 4 /* NodeTypes.Named */: { + const named = node; + named.k = named.key; + delete named.key; + break; + } + default: + { + throw createCompileError(CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE, null, { + domain: ERROR_DOMAIN$1, + args: [node.type] + }); + } + } + delete node.type; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +// eslint-disable-next-line @typescript-eslint/triple-slash-reference +/// +const ERROR_DOMAIN = 'parser'; +function createCodeGenerator(ast, options) { + const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options; + const location = options.location !== false; + const _context = { + filename, + code: '', + column: 1, + line: 1, + offset: 0, + map: undefined, + breakLineCode, + needIndent: _needIndent, + indentLevel: 0 + }; + if (location && ast.loc) { + _context.source = ast.loc.source; + } + const context = () => _context; + function push(code, node) { + _context.code += code; + } + function _newline(n, withBreakLine = true) { + const _breakLineCode = withBreakLine ? breakLineCode : ''; + push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode); + } + function indent(withNewLine = true) { + const level = ++_context.indentLevel; + withNewLine && _newline(level); + } + function deindent(withNewLine = true) { + const level = --_context.indentLevel; + withNewLine && _newline(level); + } + function newline() { + _newline(_context.indentLevel); + } + const helper = (key) => `_${key}`; + const needIndent = () => _context.needIndent; + return { + context, + push, + indent, + deindent, + newline, + helper, + needIndent + }; +} +function generateLinkedNode(generator, node) { + const { helper } = generator; + generator.push(`${helper("linked" /* HelperNameMap.LINKED */)}(`); + generateNode(generator, node.key); + if (node.modifier) { + generator.push(`, `); + generateNode(generator, node.modifier); + generator.push(`, _type`); + } + else { + generator.push(`, undefined, _type`); + } + generator.push(`)`); +} +function generateMessageNode(generator, node) { + const { helper, needIndent } = generator; + generator.push(`${helper("normalize" /* HelperNameMap.NORMALIZE */)}([`); + generator.indent(needIndent()); + const length = node.items.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.items[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push('])'); +} +function generatePluralNode(generator, node) { + const { helper, needIndent } = generator; + if (node.cases.length > 1) { + generator.push(`${helper("plural" /* HelperNameMap.PLURAL */)}([`); + generator.indent(needIndent()); + const length = node.cases.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.cases[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push(`])`); + } +} +function generateResource(generator, node) { + if (node.body) { + generateNode(generator, node.body); + } + else { + generator.push('null'); + } +} +function generateNode(generator, node) { + const { helper } = generator; + switch (node.type) { + case 0 /* NodeTypes.Resource */: + generateResource(generator, node); + break; + case 1 /* NodeTypes.Plural */: + generatePluralNode(generator, node); + break; + case 2 /* NodeTypes.Message */: + generateMessageNode(generator, node); + break; + case 6 /* NodeTypes.Linked */: + generateLinkedNode(generator, node); + break; + case 8 /* NodeTypes.LinkedModifier */: + generator.push(JSON.stringify(node.value), node); + break; + case 7 /* NodeTypes.LinkedKey */: + generator.push(JSON.stringify(node.value), node); + break; + case 5 /* NodeTypes.List */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("list" /* HelperNameMap.LIST */)}(${node.index}))`, node); + break; + case 4 /* NodeTypes.Named */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("named" /* HelperNameMap.NAMED */)}(${JSON.stringify(node.key)}))`, node); + break; + case 9 /* NodeTypes.Literal */: + generator.push(JSON.stringify(node.value), node); + break; + case 3 /* NodeTypes.Text */: + generator.push(JSON.stringify(node.value), node); + break; + default: + { + throw createCompileError(CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE, null, { + domain: ERROR_DOMAIN, + args: [node.type] + }); + } + } +} +// generate code from AST +const generate = (ast, options = {} // eslint-disable-line +) => { + const mode = isString(options.mode) ? options.mode : 'normal'; + const filename = isString(options.filename) + ? options.filename + : 'message.intl'; + const sourceMap = !!options.sourceMap; + // prettier-ignore + const breakLineCode = options.breakLineCode != null + ? options.breakLineCode + : mode === 'arrow' + ? ';' + : '\n'; + const needIndent = options.needIndent ? options.needIndent : mode !== 'arrow'; + const helpers = ast.helpers || []; + const generator = createCodeGenerator(ast, { + mode, + filename, + sourceMap, + breakLineCode, + needIndent + }); + generator.push(mode === 'normal' ? `function __msg__ (ctx) {` : `(ctx) => {`); + generator.indent(needIndent); + if (helpers.length > 0) { + generator.push(`const { ${join(helpers.map(s => `${s}: _${s}`), ', ')} } = ctx`); + generator.newline(); + } + generator.push(`return `); + generateNode(generator, ast); + generator.deindent(needIndent); + generator.push(`}`); + delete ast.helpers; + const { code, map } = generator.context(); + return { + ast, + code, + map: map ? map.toJSON() : undefined // eslint-disable-line @typescript-eslint/no-explicit-any + }; +}; + +function baseCompile$1(source, options = {}) { + const assignedOptions = assign({}, options); + const jit = !!assignedOptions.jit; + const enalbeMinify = !!assignedOptions.minify; + const enambeOptimize = assignedOptions.optimize == null ? true : assignedOptions.optimize; + // parse source codes + const parser = createParser(assignedOptions); + const ast = parser.parse(source); + if (!jit) { + // transform ASTs + transform(ast, assignedOptions); + // generate javascript codes + return generate(ast, assignedOptions); + } + else { + // optimize ASTs + enambeOptimize && optimize(ast); + // minimize ASTs + enalbeMinify && minify(ast); + // In JIT mode, no ast transform, no code generation. + return { ast, code: '' }; + } +} + +function isMessageAST(val) { + return (isObject(val) && + resolveType(val) === 0 && + (hasOwn(val, 'b') || hasOwn(val, 'body'))); +} +const PROPS_BODY = ['b', 'body']; +function resolveBody(node) { + return resolveProps(node, PROPS_BODY); +} +const PROPS_CASES = ['c', 'cases']; +function resolveCases(node) { + return resolveProps(node, PROPS_CASES, []); +} +const PROPS_STATIC = ['s', 'static']; +function resolveStatic(node) { + return resolveProps(node, PROPS_STATIC); +} +const PROPS_ITEMS = ['i', 'items']; +function resolveItems(node) { + return resolveProps(node, PROPS_ITEMS, []); +} +const PROPS_TYPE = ['t', 'type']; +function resolveType(node) { + return resolveProps(node, PROPS_TYPE); +} +const PROPS_VALUE = ['v', 'value']; +function resolveValue$1(node, type) { + const resolved = resolveProps(node, PROPS_VALUE); + if (resolved != null) { + return resolved; + } + else { + throw createUnhandleNodeError(type); + } +} +const PROPS_MODIFIER = ['m', 'modifier']; +function resolveLinkedModifier(node) { + return resolveProps(node, PROPS_MODIFIER); +} +const PROPS_KEY = ['k', 'key']; +function resolveLinkedKey(node) { + const resolved = resolveProps(node, PROPS_KEY); + if (resolved) { + return resolved; + } + else { + throw createUnhandleNodeError(6 /* NodeTypes.Linked */); + } +} +function resolveProps(node, props, defaultValue) { + for (let i = 0; i < props.length; i++) { + const prop = props[i]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (hasOwn(node, prop) && node[prop] != null) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return node[prop]; + } + } + return defaultValue; +} +const AST_NODE_PROPS_KEYS = [ + ...PROPS_BODY, + ...PROPS_CASES, + ...PROPS_STATIC, + ...PROPS_ITEMS, + ...PROPS_KEY, + ...PROPS_MODIFIER, + ...PROPS_VALUE, + ...PROPS_TYPE +]; +function createUnhandleNodeError(type) { + return new Error(`unhandled node type: ${type}`); +} + +const pathStateMachine = []; +pathStateMachine[0 /* States.BEFORE_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [0 /* States.BEFORE_PATH */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] +}; +pathStateMachine[1 /* States.IN_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] +}; +pathStateMachine[2 /* States.BEFORE_IDENT */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [2 /* States.BEFORE_IDENT */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */] +}; +pathStateMachine[3 /* States.IN_IDENT */] = { + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */, 1 /* Actions.PUSH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */, 1 /* Actions.PUSH */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */, 1 /* Actions.PUSH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */, 1 /* Actions.PUSH */] +}; +pathStateMachine[4 /* States.IN_SUB_PATH */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */], + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [ + 4 /* States.IN_SUB_PATH */, + 2 /* Actions.INC_SUB_PATH_DEPTH */ + ], + ["]" /* PathCharTypes.RIGHT_BRACKET */]: [1 /* States.IN_PATH */, 3 /* Actions.PUSH_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */] +}; +pathStateMachine[5 /* States.IN_SINGLE_QUOTE */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */] +}; +pathStateMachine[6 /* States.IN_DOUBLE_QUOTE */] = { + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */] +}; +/** + * Check if an expression is a literal value. + */ +const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/; +function isLiteral(exp) { + return literalValueRE.test(exp); +} +/** + * Strip quotes from a string + */ +function stripQuotes(str) { + const a = str.charCodeAt(0); + const b = str.charCodeAt(str.length - 1); + return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str; +} +/** + * Determine the type of a character in a keypath. + */ +function getPathCharType(ch) { + if (ch === undefined || ch === null) { + return "o" /* PathCharTypes.END_OF_FAIL */; + } + const code = ch.charCodeAt(0); + switch (code) { + case 0x5b: // [ + case 0x5d: // ] + case 0x2e: // . + case 0x22: // " + case 0x27: // ' + return ch; + case 0x5f: // _ + case 0x24: // $ + case 0x2d: // - + return "i" /* PathCharTypes.IDENT */; + case 0x09: // Tab (HT) + case 0x0a: // Newline (LF) + case 0x0d: // Return (CR) + case 0xa0: // No-break space (NBSP) + case 0xfeff: // Byte Order Mark (BOM) + case 0x2028: // Line Separator (LS) + case 0x2029: // Paragraph Separator (PS) + return "w" /* PathCharTypes.WORKSPACE */; + } + return "i" /* PathCharTypes.IDENT */; +} +/** + * Format a subPath, return its plain form if it is + * a literal string or number. Otherwise prepend the + * dynamic indicator (*). + */ +function formatSubPath(path) { + const trimmed = path.trim(); + // invalid leading 0 + if (path.charAt(0) === '0' && isNaN(parseInt(path))) { + return false; + } + return isLiteral(trimmed) + ? stripQuotes(trimmed) + : "*" /* PathCharTypes.ASTARISK */ + trimmed; +} +/** + * Parse a string path into an array of segments + */ +function parse(path) { + const keys = []; + let index = -1; + let mode = 0 /* States.BEFORE_PATH */; + let subPathDepth = 0; + let c; + let key; // eslint-disable-line + let newChar; + let type; + let transition; + let action; + let typeMap; + const actions = []; + actions[0 /* Actions.APPEND */] = () => { + if (key === undefined) { + key = newChar; + } + else { + key += newChar; + } + }; + actions[1 /* Actions.PUSH */] = () => { + if (key !== undefined) { + keys.push(key); + key = undefined; + } + }; + actions[2 /* Actions.INC_SUB_PATH_DEPTH */] = () => { + actions[0 /* Actions.APPEND */](); + subPathDepth++; + }; + actions[3 /* Actions.PUSH_SUB_PATH */] = () => { + if (subPathDepth > 0) { + subPathDepth--; + mode = 4 /* States.IN_SUB_PATH */; + actions[0 /* Actions.APPEND */](); + } + else { + subPathDepth = 0; + if (key === undefined) { + return false; + } + key = formatSubPath(key); + if (key === false) { + return false; + } + else { + actions[1 /* Actions.PUSH */](); + } + } + }; + function maybeUnescapeQuote() { + const nextChar = path[index + 1]; + if ((mode === 5 /* States.IN_SINGLE_QUOTE */ && + nextChar === "'" /* PathCharTypes.SINGLE_QUOTE */) || + (mode === 6 /* States.IN_DOUBLE_QUOTE */ && + nextChar === "\"" /* PathCharTypes.DOUBLE_QUOTE */)) { + index++; + newChar = '\\' + nextChar; + actions[0 /* Actions.APPEND */](); + return true; + } + } + while (mode !== null) { + index++; + c = path[index]; + if (c === '\\' && maybeUnescapeQuote()) { + continue; + } + type = getPathCharType(c); + typeMap = pathStateMachine[mode]; + transition = typeMap[type] || typeMap["l" /* PathCharTypes.ELSE */] || 8 /* States.ERROR */; + // check parse error + if (transition === 8 /* States.ERROR */) { + return; + } + mode = transition[0]; + if (transition[1] !== undefined) { + action = actions[transition[1]]; + if (action) { + newChar = c; + if (action() === false) { + return; + } + } + } + // check parse finish + if (mode === 7 /* States.AFTER_PATH */) { + return keys; + } + } +} +// path token cache +const cache = new Map(); +/** + * key-value message resolver + * + * @remarks + * Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ +function resolveWithKeyValue(obj, path) { + return isObject(obj) ? obj[path] : null; +} +/** + * message resolver + * + * @remarks + * Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default. + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ +function resolveValue(obj, path) { + // check object + if (!isObject(obj)) { + return null; + } + // parse path + let hit = cache.get(path); + if (!hit) { + hit = parse(path); + if (hit) { + cache.set(path, hit); + } + } + // check hit + if (!hit) { + return null; + } + // resolve path value + const len = hit.length; + let last = obj; + let i = 0; + while (i < len) { + const key = hit[i]; + /** + * NOTE: + * if `key` is intlify message format AST node key and `last` is intlify message format AST, skip it. + * because the AST node is not a key-value structure. + */ + if (AST_NODE_PROPS_KEYS.includes(key) && isMessageAST(last)) { + return null; + } + const val = last[key]; + if (val === undefined) { + return null; + } + if (isFunction(last)) { + return null; + } + last = val; + i++; + } + return last; +} + +const DEFAULT_MODIFIER = (str) => str; +const DEFAULT_MESSAGE = (ctx) => ''; // eslint-disable-line +const DEFAULT_MESSAGE_DATA_TYPE = 'text'; +const DEFAULT_NORMALIZE = (values) => values.length === 0 ? '' : join(values); +const DEFAULT_INTERPOLATE = toDisplayString; +function pluralDefault(choice, choicesLength) { + choice = Math.abs(choice); + if (choicesLength === 2) { + // prettier-ignore + return choice + ? choice > 1 + ? 1 + : 0 + : 1; + } + return choice ? Math.min(choice, 2) : 0; +} +function getPluralIndex(options) { + // prettier-ignore + const index = isNumber(options.pluralIndex) + ? options.pluralIndex + : -1; + // prettier-ignore + return options.named && (isNumber(options.named.count) || isNumber(options.named.n)) + ? isNumber(options.named.count) + ? options.named.count + : isNumber(options.named.n) + ? options.named.n + : index + : index; +} +function normalizeNamed(pluralIndex, props) { + if (!props.count) { + props.count = pluralIndex; + } + if (!props.n) { + props.n = pluralIndex; + } +} +function createMessageContext(options = {}) { + const locale = options.locale; + const pluralIndex = getPluralIndex(options); + const pluralRule = isObject(options.pluralRules) && + isString(locale) && + isFunction(options.pluralRules[locale]) + ? options.pluralRules[locale] + : pluralDefault; + const orgPluralRule = isObject(options.pluralRules) && + isString(locale) && + isFunction(options.pluralRules[locale]) + ? pluralDefault + : undefined; + const plural = (messages) => { + return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)]; + }; + const _list = options.list || []; + const list = (index) => _list[index]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _named = options.named || create(); + isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named); + const named = (key) => _named[key]; + function message(key) { + // prettier-ignore + const msg = isFunction(options.messages) + ? options.messages(key) + : isObject(options.messages) + ? options.messages[key] + : false; + return !msg + ? options.parent + ? options.parent.message(key) // resolve from parent messages + : DEFAULT_MESSAGE + : msg; + } + const _modifier = (name) => options.modifiers + ? options.modifiers[name] + : DEFAULT_MODIFIER; + const normalize = isPlainObject(options.processor) && isFunction(options.processor.normalize) + ? options.processor.normalize + : DEFAULT_NORMALIZE; + const interpolate = isPlainObject(options.processor) && + isFunction(options.processor.interpolate) + ? options.processor.interpolate + : DEFAULT_INTERPOLATE; + const type = isPlainObject(options.processor) && isString(options.processor.type) + ? options.processor.type + : DEFAULT_MESSAGE_DATA_TYPE; + const linked = (key, ...args) => { + const [arg1, arg2] = args; + let type = 'text'; + let modifier = ''; + if (args.length === 1) { + if (isObject(arg1)) { + modifier = arg1.modifier || modifier; + type = arg1.type || type; + } + else if (isString(arg1)) { + modifier = arg1 || modifier; + } + } + else if (args.length === 2) { + if (isString(arg1)) { + modifier = arg1 || modifier; + } + if (isString(arg2)) { + type = arg2 || type; + } + } + const ret = message(key)(ctx); + const msg = + // The message in vnode resolved with linked are returned as an array by processor.nomalize + type === 'vnode' && isArray(ret) && modifier + ? ret[0] + : ret; + return modifier ? _modifier(modifier)(msg, type) : msg; + }; + const ctx = { + ["list" /* HelperNameMap.LIST */]: list, + ["named" /* HelperNameMap.NAMED */]: named, + ["plural" /* HelperNameMap.PLURAL */]: plural, + ["linked" /* HelperNameMap.LINKED */]: linked, + ["message" /* HelperNameMap.MESSAGE */]: message, + ["type" /* HelperNameMap.TYPE */]: type, + ["interpolate" /* HelperNameMap.INTERPOLATE */]: interpolate, + ["normalize" /* HelperNameMap.NORMALIZE */]: normalize, + ["values" /* HelperNameMap.VALUES */]: assign(create(), _list, _named) + }; + return ctx; +} + +let devtools = null; +function setDevToolsHook(hook) { + devtools = hook; +} +function initI18nDevTools(i18n, version, meta) { + // TODO: queue if devtools is undefined + devtools && + devtools.emit("i18n:init" /* IntlifyDevToolsHooks.I18nInit */, { + timestamp: Date.now(), + i18n, + version, + meta + }); +} +const translateDevTools = /* #__PURE__*/ createDevToolsHook("function:translate" /* IntlifyDevToolsHooks.FunctionTranslate */); +function createDevToolsHook(hook) { + return (payloads) => devtools && devtools.emit(hook, payloads); +} + +const code$3 = CompileWarnCodes.__EXTEND_POINT__; +const inc$3 = incrementer(code$3); +const CoreWarnCodes = { + NOT_FOUND_KEY: code$3, // 2 + FALLBACK_TO_TRANSLATE: inc$3(), // 3 + CANNOT_FORMAT_NUMBER: inc$3(), // 4 + FALLBACK_TO_NUMBER_FORMAT: inc$3(), // 5 + CANNOT_FORMAT_DATE: inc$3(), // 6 + FALLBACK_TO_DATE_FORMAT: inc$3(), // 7 + EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc$3(), // 8 + __EXTEND_POINT__: inc$3() // 9 +}; +/** @internal */ +const warnMessages$1 = { + [CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`, + [CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`, + [CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`, + [CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]: `This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future.` +}; +function getWarnMessage$1(code, ...args) { + return format$1(warnMessages$1[code], ...args); +} + +const code$2 = CompileErrorCodes.__EXTEND_POINT__; +const inc$2 = incrementer(code$2); +const CoreErrorCodes = { + INVALID_ARGUMENT: code$2, // 17 + INVALID_DATE_ARGUMENT: inc$2(), // 18 + INVALID_ISO_DATE_ARGUMENT: inc$2(), // 19 + NOT_SUPPORT_NON_STRING_MESSAGE: inc$2(), // 20 + NOT_SUPPORT_LOCALE_PROMISE_VALUE: inc$2(), // 21 + NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: inc$2(), // 22 + NOT_SUPPORT_LOCALE_TYPE: inc$2(), // 23 + __EXTEND_POINT__: inc$2() // 24 +}; +function createCoreError(code) { + return createCompileError(code, null, { messages: errorMessages$1 } ); +} +/** @internal */ +const errorMessages$1 = { + [CoreErrorCodes.INVALID_ARGUMENT]: 'Invalid arguments', + [CoreErrorCodes.INVALID_DATE_ARGUMENT]: 'The date provided is an invalid Date object.' + + 'Make sure your Date represents a valid date.', + [CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: 'The argument provided is not a valid ISO date string', + [CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE]: 'Not support non-string message', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]: 'cannot support promise value', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]: 'cannot support async function', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: 'cannot support locale type' +}; + +/** @internal */ +function getLocale(context, options) { + return options.locale != null + ? resolveLocale(options.locale) + : resolveLocale(context.locale); +} +let _resolveLocale; +/** @internal */ +function resolveLocale(locale) { + if (isString(locale)) { + return locale; + } + else { + if (isFunction(locale)) { + if (locale.resolvedOnce && _resolveLocale != null) { + return _resolveLocale; + } + else if (locale.constructor.name === 'Function') { + const resolve = locale(); + if (isPromise(resolve)) { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE); + } + return (_resolveLocale = resolve); + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION); + } + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE); + } + } +} +/** + * Fallback with simple implemenation + * + * @remarks + * A fallback locale function implemented with a simple fallback algorithm. + * + * Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nGeneral + */ +function fallbackWithSimple(ctx, fallback, start // eslint-disable-line @typescript-eslint/no-unused-vars +) { + // prettier-ignore + return [...new Set([ + start, + ...(isArray(fallback) + ? fallback + : isObject(fallback) + ? Object.keys(fallback) + : isString(fallback) + ? [fallback] + : [start]) + ])]; +} +/** + * Fallback with locale chain + * + * @remarks + * A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @VueI18nGeneral + */ +function fallbackWithLocaleChain(ctx, fallback, start) { + const startLocale = isString(start) ? start : DEFAULT_LOCALE; + const context = ctx; + if (!context.__localeChainCache) { + context.__localeChainCache = new Map(); + } + let chain = context.__localeChainCache.get(startLocale); + if (!chain) { + chain = []; + // first block defined by start + let block = [start]; + // while any intervening block found + while (isArray(block)) { + block = appendBlockToChain(chain, block, fallback); + } + // prettier-ignore + // last block defined by default + const defaults = isArray(fallback) || !isPlainObject(fallback) + ? fallback + : fallback['default'] + ? fallback['default'] + : null; + // convert defaults to array + block = isString(defaults) ? [defaults] : defaults; + if (isArray(block)) { + appendBlockToChain(chain, block, false); + } + context.__localeChainCache.set(startLocale, chain); + } + return chain; +} +function appendBlockToChain(chain, block, blocks) { + let follow = true; + for (let i = 0; i < block.length && isBoolean(follow); i++) { + const locale = block[i]; + if (isString(locale)) { + follow = appendLocaleToChain(chain, block[i], blocks); + } + } + return follow; +} +function appendLocaleToChain(chain, locale, blocks) { + let follow; + const tokens = locale.split('-'); + do { + const target = tokens.join('-'); + follow = appendItemToChain(chain, target, blocks); + tokens.splice(-1, 1); + } while (tokens.length && follow === true); + return follow; +} +function appendItemToChain(chain, target, blocks) { + let follow = false; + if (!chain.includes(target)) { + follow = true; + if (target) { + follow = target[target.length - 1] !== '!'; + const locale = target.replace(/!/g, ''); + chain.push(locale); + if ((isArray(blocks) || isPlainObject(blocks)) && + blocks[locale] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + follow = blocks[locale]; + } + } + } + return follow; +} + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Intlify core-base version + * @internal + */ +const VERSION$1 = '9.14.5'; +const NOT_REOSLVED = -1; +const DEFAULT_LOCALE = 'en-US'; +const MISSING_RESOLVE_VALUE = ''; +const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`; +function getDefaultLinkedModifiers() { + return { + upper: (val, type) => { + // prettier-ignore + return type === 'text' && isString(val) + ? val.toUpperCase() + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? val.children.toUpperCase() + : val; + }, + lower: (val, type) => { + // prettier-ignore + return type === 'text' && isString(val) + ? val.toLowerCase() + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? val.children.toLowerCase() + : val; + }, + capitalize: (val, type) => { + // prettier-ignore + return (type === 'text' && isString(val) + ? capitalize(val) + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? capitalize(val.children) + : val); + } + }; +} +let _compiler; +function registerMessageCompiler(compiler) { + _compiler = compiler; +} +let _resolver; +/** + * Register the message resolver + * + * @param resolver - A {@link MessageResolver} function + * + * @VueI18nGeneral + */ +function registerMessageResolver(resolver) { + _resolver = resolver; +} +let _fallbacker; +/** + * Register the locale fallbacker + * + * @param fallbacker - A {@link LocaleFallbacker} function + * + * @VueI18nGeneral + */ +function registerLocaleFallbacker(fallbacker) { + _fallbacker = fallbacker; +} +// Additional Meta for Intlify DevTools +let _additionalMeta = null; +/* #__NO_SIDE_EFFECTS__ */ +const setAdditionalMeta = (meta) => { + _additionalMeta = meta; +}; +/* #__NO_SIDE_EFFECTS__ */ +const getAdditionalMeta = () => _additionalMeta; +let _fallbackContext = null; +const setFallbackContext = (context) => { + _fallbackContext = context; +}; +const getFallbackContext = () => _fallbackContext; +// ID for CoreContext +let _cid = 0; +function createCoreContext(options = {}) { + // setup options + const onWarn = isFunction(options.onWarn) ? options.onWarn : warn; + const version = isString(options.version) ? options.version : VERSION$1; + const locale = isString(options.locale) || isFunction(options.locale) + ? options.locale + : DEFAULT_LOCALE; + const _locale = isFunction(locale) ? DEFAULT_LOCALE : locale; + const fallbackLocale = isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + isString(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale; + const messages = isPlainObject(options.messages) + ? options.messages + : createResources(_locale); + const datetimeFormats = isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : createResources(_locale) + ; + const numberFormats = isPlainObject(options.numberFormats) + ? options.numberFormats + : createResources(_locale) + ; + const modifiers = assign(create(), options.modifiers, getDefaultLinkedModifiers()); + const pluralRules = options.pluralRules || create(); + const missing = isFunction(options.missing) ? options.missing : null; + const missingWarn = isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + const fallbackWarn = isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + const fallbackFormat = !!options.fallbackFormat; + const unresolving = !!options.unresolving; + const postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + const processor = isPlainObject(options.processor) ? options.processor : null; + const warnHtmlMessage = isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const escapeParameter = !!options.escapeParameter; + const messageCompiler = isFunction(options.messageCompiler) + ? options.messageCompiler + : _compiler; + if (isFunction(options.messageCompiler)) { + warnOnce(getWarnMessage$1(CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER)); + } + const messageResolver = isFunction(options.messageResolver) + ? options.messageResolver + : _resolver || resolveWithKeyValue; + const localeFallbacker = isFunction(options.localeFallbacker) + ? options.localeFallbacker + : _fallbacker || fallbackWithSimple; + const fallbackContext = isObject(options.fallbackContext) + ? options.fallbackContext + : undefined; + // setup internal options + const internalOptions = options; + const __datetimeFormatters = isObject(internalOptions.__datetimeFormatters) + ? internalOptions.__datetimeFormatters + : new Map() + ; + const __numberFormatters = isObject(internalOptions.__numberFormatters) + ? internalOptions.__numberFormatters + : new Map() + ; + const __meta = isObject(internalOptions.__meta) ? internalOptions.__meta : {}; + _cid++; + const context = { + version, + cid: _cid, + locale, + fallbackLocale, + messages, + modifiers, + pluralRules, + missing, + missingWarn, + fallbackWarn, + fallbackFormat, + unresolving, + postTranslation, + processor, + warnHtmlMessage, + escapeParameter, + messageCompiler, + messageResolver, + localeFallbacker, + fallbackContext, + onWarn, + __meta + }; + { + context.datetimeFormats = datetimeFormats; + context.numberFormats = numberFormats; + context.__datetimeFormatters = __datetimeFormatters; + context.__numberFormatters = __numberFormatters; + } + // for vue-devtools timeline event + { + context.__v_emitter = + internalOptions.__v_emitter != null + ? internalOptions.__v_emitter + : undefined; + } + // NOTE: experimental !! + { + initI18nDevTools(context, version, __meta); + } + return context; +} +const createResources = (locale) => ({ [locale]: create() }); +/** @internal */ +function isTranslateFallbackWarn(fallback, key) { + return fallback instanceof RegExp ? fallback.test(key) : fallback; +} +/** @internal */ +function isTranslateMissingWarn(missing, key) { + return missing instanceof RegExp ? missing.test(key) : missing; +} +/** @internal */ +function handleMissing(context, key, locale, missingWarn, type) { + const { missing, onWarn } = context; + // for vue-devtools timeline event + { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("missing" /* VueDevToolsTimelineEvents.MISSING */, { + locale, + key, + type, + groupId: `${type}:${key}` + }); + } + } + if (missing !== null) { + const ret = missing(context, locale, key, type); + return isString(ret) ? ret : key; + } + else { + if (isTranslateMissingWarn(missingWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.NOT_FOUND_KEY, { key, locale })); + } + return key; + } +} +/** @internal */ +function updateFallbackLocale(ctx, locale, fallback) { + const context = ctx; + context.__localeChainCache = new Map(); + ctx.localeFallbacker(ctx, fallback, locale); +} +/** @internal */ +function isAlmostSameLocale(locale, compareLocale) { + if (locale === compareLocale) + return false; + return locale.split('-')[0] === compareLocale.split('-')[0]; +} +/** @internal */ +function isImplicitFallback(targetLocale, locales) { + const index = locales.indexOf(targetLocale); + if (index === -1) { + return false; + } + for (let i = index + 1; i < locales.length; i++) { + if (isAlmostSameLocale(targetLocale, locales[i])) { + return true; + } + } + return false; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +function format(ast) { + const msg = (ctx) => formatParts(ctx, ast); + return msg; +} +function formatParts(ctx, ast) { + const body = resolveBody(ast); + if (body == null) { + throw createUnhandleNodeError(0 /* NodeTypes.Resource */); + } + const type = resolveType(body); + if (type === 1 /* NodeTypes.Plural */) { + const plural = body; + const cases = resolveCases(plural); + return ctx.plural(cases.reduce((messages, c) => [ + ...messages, + formatMessageParts(ctx, c) + ], [])); + } + else { + return formatMessageParts(ctx, body); + } +} +function formatMessageParts(ctx, node) { + const static_ = resolveStatic(node); + if (static_ != null) { + return ctx.type === 'text' + ? static_ + : ctx.normalize([static_]); + } + else { + const messages = resolveItems(node).reduce((acm, c) => [...acm, formatMessagePart(ctx, c)], []); + return ctx.normalize(messages); + } +} +function formatMessagePart(ctx, node) { + const type = resolveType(node); + switch (type) { + case 3 /* NodeTypes.Text */: { + return resolveValue$1(node, type); + } + case 9 /* NodeTypes.Literal */: { + return resolveValue$1(node, type); + } + case 4 /* NodeTypes.Named */: { + const named = node; + if (hasOwn(named, 'k') && named.k) { + return ctx.interpolate(ctx.named(named.k)); + } + if (hasOwn(named, 'key') && named.key) { + return ctx.interpolate(ctx.named(named.key)); + } + throw createUnhandleNodeError(type); + } + case 5 /* NodeTypes.List */: { + const list = node; + if (hasOwn(list, 'i') && isNumber(list.i)) { + return ctx.interpolate(ctx.list(list.i)); + } + if (hasOwn(list, 'index') && isNumber(list.index)) { + return ctx.interpolate(ctx.list(list.index)); + } + throw createUnhandleNodeError(type); + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + const modifier = resolveLinkedModifier(linked); + const key = resolveLinkedKey(linked); + return ctx.linked(formatMessagePart(ctx, key), modifier ? formatMessagePart(ctx, modifier) : undefined, ctx.type); + } + case 7 /* NodeTypes.LinkedKey */: { + return resolveValue$1(node, type); + } + case 8 /* NodeTypes.LinkedModifier */: { + return resolveValue$1(node, type); + } + default: + throw new Error(`unhandled node on format message part: ${type}`); + } +} + +const WARN_MESSAGE = `Detected HTML in '{source}' message. Recommend not using HTML messages to avoid XSS.`; +function checkHtmlMessage(source, warnHtmlMessage) { + if (warnHtmlMessage && detectHtmlTag(source)) { + warn(format$1(WARN_MESSAGE, { source })); + } +} +const defaultOnCacheKey = (message) => message; +let compileCache = create(); +function onCompileWarn(_warn) { + if (_warn.code === CompileWarnCodes.USE_MODULO_SYNTAX) { + warn(`The use of named interpolation with modulo syntax is deprecated. ` + + `It will be removed in v10.\n` + + `reference: https://vue-i18n.intlify.dev/guide/essentials/syntax#rails-i18n-format \n` + + `(message compiler warning message: ${_warn.message})`); + } +} +function baseCompile(message, options = {}) { + // error detecting on compile + let detectError = false; + const onError = options.onError || defaultOnError; + options.onError = (err) => { + detectError = true; + onError(err); + }; + // compile with mesasge-compiler + return { ...baseCompile$1(message, options), detectError }; +} +function compile(message, context) { + // set onWarn + { + context.onWarn = onCompileWarn; + } + if (isString(message)) { + // check HTML message + const warnHtmlMessage = isBoolean(context.warnHtmlMessage) + ? context.warnHtmlMessage + : true; + checkHtmlMessage(message, warnHtmlMessage); + // check caches + const onCacheKey = context.onCacheKey || defaultOnCacheKey; + const cacheKey = onCacheKey(message); + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compile with JIT mode + const { ast, detectError } = baseCompile(message, { + ...context, + location: true, + jit: true + }); + // compose message function from AST + const msg = format(ast); + // if occurred compile error, don't cache + return !detectError + ? (compileCache[cacheKey] = msg) + : msg; + } + else { + if (!isMessageAST(message)) { + warn(`the message that is resolve with key '${context.key}' is not supported for jit compilation`); + return (() => message); + } + // AST case (passed from bundler) + const cacheKey = message.cacheKey; + if (cacheKey) { + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compose message function from message (AST) + return (compileCache[cacheKey] = + format(message)); + } + else { + return format(message); + } + } +} + +const NOOP_MESSAGE_FUNCTION = () => ''; +const isMessageFunction = (val) => isFunction(val); +// implementation of `translate` function +function translate(context, ...args) { + const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context; + const [key, options] = parseTranslateArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const escapeParameter = isBoolean(options.escapeParameter) + ? options.escapeParameter + : context.escapeParameter; + const resolvedMessage = !!options.resolvedMessage; + // prettier-ignore + const defaultMsgOrKey = isString(options.default) || isBoolean(options.default) // default by function option + ? !isBoolean(options.default) + ? options.default + : (!messageCompiler ? () => key : key) + : fallbackFormat // default by `fallbackFormat` option + ? (!messageCompiler ? () => key : key) + : ''; + const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== ''; + const locale = getLocale(context, options); + // escape params + escapeParameter && escapeParams(options); + // resolve message format + // eslint-disable-next-line prefer-const + let [formatScope, targetLocale, message] = !resolvedMessage + ? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) + : [ + key, + locale, + messages[locale] || create() + ]; + // NOTE: + // Fix to work around `ssrTransfrom` bug in Vite. + // https://github.com/vitejs/vite/issues/4306 + // To get around this, use temporary variables. + // https://github.com/nuxt/framework/issues/1461#issuecomment-954606243 + let format = formatScope; + // if you use default message, set it as message format! + let cacheBaseKey = key; + if (!resolvedMessage && + !(isString(format) || + isMessageAST(format) || + isMessageFunction(format))) { + if (enableDefaultMsg) { + format = defaultMsgOrKey; + cacheBaseKey = format; + } + } + // checking message format and target locale + if (!resolvedMessage && + (!(isString(format) || + isMessageAST(format) || + isMessageFunction(format)) || + !isString(targetLocale))) { + return unresolving ? NOT_REOSLVED : key; + } + // TODO: refactor + if (isString(format) && context.messageCompiler == null) { + warn(`The message format compilation is not supported in this build. ` + + `Because message compiler isn't included. ` + + `You need to pre-compilation all message format. ` + + `So translate function return '${key}'.`); + return key; + } + // setup compile error detecting + let occurred = false; + const onError = () => { + occurred = true; + }; + // compile message format + const msg = !isMessageFunction(format) + ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) + : format; + // if occurred compile error, return the message format + if (occurred) { + return format; + } + // evaluate message with context + const ctxOptions = getMessageContextOptions(context, targetLocale, message, options); + const msgContext = createMessageContext(ctxOptions); + const messaged = evaluateMessage(context, msg, msgContext); + // if use post translation option, proceed it with handler + let ret = postTranslation + ? postTranslation(messaged, key) + : messaged; + // apply HTML sanitization for security + if (escapeParameter && isString(ret)) { + ret = sanitizeTranslatedHtml(ret); + } + // NOTE: experimental !! + { + // prettier-ignore + const payloads = { + timestamp: Date.now(), + key: isString(key) + ? key + : isMessageFunction(format) + ? format.key + : '', + locale: targetLocale || (isMessageFunction(format) + ? format.locale + : ''), + format: isString(format) + ? format + : isMessageFunction(format) + ? format.source + : '', + message: ret + }; + payloads.meta = assign({}, context.__meta, getAdditionalMeta() || {}); + translateDevTools(payloads); + } + return ret; +} +function escapeParams(options) { + if (isArray(options.list)) { + options.list = options.list.map(item => isString(item) ? escapeHtml(item) : item); + } + else if (isObject(options.named)) { + Object.keys(options.named).forEach(key => { + if (isString(options.named[key])) { + options.named[key] = escapeHtml(options.named[key]); + } + }); + } +} +function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) { + const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context; + const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any + let message = create(); + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'translate'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + !isAlmostSameLocale(locale, targetLocale) && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.FALLBACK_TO_TRANSLATE, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + message = + messages[targetLocale] || create(); + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-resolve-start'; + endTag = 'intlify-message-resolve-end'; + mark && mark(startTag); + } + if ((format = resolveValue(message, key)) === null) { + // if null, resolve with object key path + format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any + } + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start && format) { + emitter.emit("message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, { + type: "message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, + key, + message: format, + time: end - start, + groupId: `${type}:${key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message resolve', startTag, endTag); + } + } + if (isString(format) || isMessageAST(format) || isMessageFunction(format)) { + break; + } + if (!isImplicitFallback(targetLocale, locales)) { + const missingRet = handleMissing(context, // eslint-disable-line @typescript-eslint/no-explicit-any + key, targetLocale, missingWarn, type); + if (missingRet !== key) { + format = missingRet; + } + } + from = to; + } + return [format, targetLocale, message]; +} +function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) { + const { messageCompiler, warnHtmlMessage } = context; + if (isMessageFunction(format)) { + const msg = format; + msg.locale = msg.locale || targetLocale; + msg.key = msg.key || key; + return msg; + } + if (messageCompiler == null) { + const msg = (() => format); + msg.locale = targetLocale; + msg.key = key; + return msg; + } + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-compilation-start'; + endTag = 'intlify-message-compilation-end'; + mark && mark(startTag); + } + const msg = messageCompiler(format, getCompileContext(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, onError)); + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, { + type: "message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, + message: format, + time: end - start, + groupId: `${'translate'}:${key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message compilation', startTag, endTag); + } + } + msg.locale = targetLocale; + msg.key = key; + msg.source = format; + return msg; +} +function evaluateMessage(context, msg, msgCtx) { + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-evaluation-start'; + endTag = 'intlify-message-evaluation-end'; + mark && mark(startTag); + } + const messaged = msg(msgCtx); + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, { + type: "message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, + value: messaged, + time: end - start, + groupId: `${'translate'}:${msg.key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message evaluation', startTag, endTag); + } + } + return messaged; +} +/** @internal */ +function parseTranslateArgs(...args) { + const [arg1, arg2, arg3] = args; + const options = create(); + if (!isString(arg1) && + !isNumber(arg1) && + !isMessageFunction(arg1) && + !isMessageAST(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + // prettier-ignore + const key = isNumber(arg1) + ? String(arg1) + : isMessageFunction(arg1) + ? arg1 + : arg1; + if (isNumber(arg2)) { + options.plural = arg2; + } + else if (isString(arg2)) { + options.default = arg2; + } + else if (isPlainObject(arg2) && !isEmptyObject(arg2)) { + options.named = arg2; + } + else if (isArray(arg2)) { + options.list = arg2; + } + if (isNumber(arg3)) { + options.plural = arg3; + } + else if (isString(arg3)) { + options.default = arg3; + } + else if (isPlainObject(arg3)) { + assign(options, arg3); + } + return [key, options]; +} +function getCompileContext(context, locale, key, source, warnHtmlMessage, onError) { + return { + locale, + key, + warnHtmlMessage, + onError: (err) => { + onError && onError(err); + { + const _source = getSourceForCodeFrame(source); + const message = `Message compilation error: ${err.message}`; + const codeFrame = err.location && + _source && + generateCodeFrame(_source, err.location.start.offset, err.location.end.offset); + const emitter = context.__v_emitter; + if (emitter && _source) { + emitter.emit("compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */, { + message: _source, + error: err.message, + start: err.location && err.location.start.offset, + end: err.location && err.location.end.offset, + groupId: `${'translate'}:${key}` + }); + } + console.error(codeFrame ? `${message}\n${codeFrame}` : message); + } + }, + onCacheKey: (source) => generateFormatCacheKey(locale, key, source) + }; +} +function getSourceForCodeFrame(source) { + if (isString(source)) { + return source; + } + else { + if (source.loc && source.loc.source) { + return source.loc.source; + } + } +} +function getMessageContextOptions(context, locale, message, options) { + const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context; + const resolveMessage = (key) => { + let val = resolveValue(message, key); + // fallback to root context + if (val == null && fallbackContext) { + const [, , message] = resolveMessageFormat(fallbackContext, key, locale, fallbackLocale, fallbackWarn, missingWarn); + val = resolveValue(message, key); + } + if (isString(val) || isMessageAST(val)) { + let occurred = false; + const onError = () => { + occurred = true; + }; + const msg = compileMessageFormat(context, key, locale, val, key, onError); + return !occurred + ? msg + : NOOP_MESSAGE_FUNCTION; + } + else if (isMessageFunction(val)) { + return val; + } + else { + // TODO: should be implemented warning message + return NOOP_MESSAGE_FUNCTION; + } + }; + const ctxOptions = { + locale, + modifiers, + pluralRules, + messages: resolveMessage + }; + if (context.processor) { + ctxOptions.processor = context.processor; + } + if (options.list) { + ctxOptions.list = options.list; + } + if (options.named) { + ctxOptions.named = options.named; + } + if (isNumber(options.plural)) { + ctxOptions.pluralIndex = options.plural; + } + return ctxOptions; +} + +const intlDefined = typeof Intl !== 'undefined'; +const Availabilities = { + dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined', + numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined' +}; + +// implementation of `datetime` function +function datetime(context, ...args) { + const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __datetimeFormatters } = context; + if (!Availabilities.dateTimeFormat) { + onWarn(getWarnMessage$1(CoreWarnCodes.CANNOT_FORMAT_DATE)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseDateTimeArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!isString(key) || key === '') { + return new Intl.DateTimeFormat(locale, overrides).format(value); + } + // resolve format + let datetimeFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'datetime format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + datetimeFormat = + datetimeFormats[targetLocale] || {}; + format = datetimeFormat[key]; + if (isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!isPlainObject(format) || !isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __datetimeFormatters.get(id); + if (!formatter) { + formatter = new Intl.DateTimeFormat(targetLocale, assign({}, format, overrides)); + __datetimeFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); +} +/** @internal */ +const DATETIME_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'weekday', + 'era', + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second', + 'timeZoneName', + 'formatMatcher', + 'hour12', + 'timeZone', + 'dateStyle', + 'timeStyle', + 'calendar', + 'dayPeriod', + 'numberingSystem', + 'hourCycle', + 'fractionalSecondDigits' +]; +/** @internal */ +function parseDateTimeArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = create(); + let overrides = create(); + let value; + if (isString(arg1)) { + // Only allow ISO strings - other date formats are often supported, + // but may cause different results in different browsers. + const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/); + if (!matches) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + // Some browsers can not parse the iso datetime separated by space, + // this is a compromise solution by replace the 'T'/' ' with 'T' + const dateTime = matches[3] + ? matches[3].trim().startsWith('T') + ? `${matches[1].trim()}${matches[3].trim()}` + : `${matches[1].trim()}T${matches[3].trim()}` + : matches[1].trim(); + value = new Date(dateTime); + try { + // This will fail if the date is not valid + value.toISOString(); + } + catch (e) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + } + else if (isDate(arg1)) { + if (isNaN(arg1.getTime())) { + throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT); + } + value = arg1; + } + else if (isNumber(arg1)) { + value = arg1; + } + else { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + if (isString(arg2)) { + options.key = arg2; + } + else if (isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isPlainObject(arg3)) { + overrides = arg3; + } + if (isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; +} +/** @internal */ +function clearDateTimeFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__datetimeFormatters.has(id)) { + continue; + } + context.__datetimeFormatters.delete(id); + } +} + +// implementation of `number` function +function number(context, ...args) { + const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __numberFormatters } = context; + if (!Availabilities.numberFormat) { + onWarn(getWarnMessage$1(CoreWarnCodes.CANNOT_FORMAT_NUMBER)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseNumberArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!isString(key) || key === '') { + return new Intl.NumberFormat(locale, overrides).format(value); + } + // resolve format + let numberFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'number format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + numberFormat = + numberFormats[targetLocale] || {}; + format = numberFormat[key]; + if (isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!isPlainObject(format) || !isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __numberFormatters.get(id); + if (!formatter) { + formatter = new Intl.NumberFormat(targetLocale, assign({}, format, overrides)); + __numberFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); +} +/** @internal */ +const NUMBER_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'style', + 'currency', + 'currencyDisplay', + 'currencySign', + 'useGrouping', + 'minimumIntegerDigits', + 'minimumFractionDigits', + 'maximumFractionDigits', + 'minimumSignificantDigits', + 'maximumSignificantDigits', + 'compactDisplay', + 'notation', + 'signDisplay', + 'unit', + 'unitDisplay', + 'roundingMode', + 'roundingPriority', + 'roundingIncrement', + 'trailingZeroDisplay' +]; +/** @internal */ +function parseNumberArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = create(); + let overrides = create(); + if (!isNumber(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + const value = arg1; + if (isString(arg2)) { + options.key = arg2; + } + else if (isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isPlainObject(arg3)) { + overrides = arg3; + } + if (isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; +} +/** @internal */ +function clearNumberFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__numberFormatters.has(id)) { + continue; + } + context.__numberFormatters.delete(id); + } +} + +/** + * Vue I18n Version + * + * @remarks + * Semver format. Same format as the package.json `version` field. + * + * @VueI18nGeneral + */ +const VERSION = '9.14.5'; +/** + * This is only called development env + * istanbul-ignore-next + */ +function initDev() { + { + { + console.info(`You are running a development build of vue-i18n.\n` + + `Make sure to use the production build (*.prod.js) when deploying for production.`); + } + } +} + +const code$1 = CoreWarnCodes.__EXTEND_POINT__; +const inc$1 = incrementer(code$1); +const I18nWarnCodes = { + FALLBACK_TO_ROOT: code$1, // 9 + NOT_SUPPORTED_PRESERVE: inc$1(), // 10 + NOT_SUPPORTED_FORMATTER: inc$1(), // 11 + NOT_SUPPORTED_PRESERVE_DIRECTIVE: inc$1(), // 12 + NOT_SUPPORTED_GET_CHOICE_INDEX: inc$1(), // 13 + COMPONENT_NAME_LEGACY_COMPATIBLE: inc$1(), // 14 + NOT_FOUND_PARENT_SCOPE: inc$1(), // 15 + IGNORE_OBJ_FLATTEN: inc$1(), // 16 + NOTICE_DROP_ALLOW_COMPOSITION: inc$1(), // 17 + NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG: inc$1() // 18 +}; +const warnMessages = { + [I18nWarnCodes.FALLBACK_TO_ROOT]: `Fall back to {type} '{key}' with root locale.`, + [I18nWarnCodes.NOT_SUPPORTED_PRESERVE]: `Not supported 'preserve'.`, + [I18nWarnCodes.NOT_SUPPORTED_FORMATTER]: `Not supported 'formatter'.`, + [I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE]: `Not supported 'preserveDirectiveContent'.`, + [I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX]: `Not supported 'getChoiceIndex'.`, + [I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE]: `Component name legacy compatible: '{name}' -> 'i18n'`, + [I18nWarnCodes.NOT_FOUND_PARENT_SCOPE]: `Not found parent scope. use the global scope.`, + [I18nWarnCodes.IGNORE_OBJ_FLATTEN]: `Ignore object flatten: '{key}' key has an string value`, + [I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION]: `'allowComposition' option will be dropped in the next major version. For more information, please see 👉 https://tinyurl.com/2p97mcze`, + [I18nWarnCodes.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG]: `'translateExistCompatible' option will be dropped in the next major version.` +}; +function getWarnMessage(code, ...args) { + return format$1(warnMessages[code], ...args); +} + +const code = CoreErrorCodes.__EXTEND_POINT__; +const inc = incrementer(code); +const I18nErrorCodes = { + // composer module errors + UNEXPECTED_RETURN_TYPE: code, // 24 + // legacy module errors + INVALID_ARGUMENT: inc(), // 25 + // i18n module errors + MUST_BE_CALL_SETUP_TOP: inc(), // 26 + NOT_INSTALLED: inc(), // 27 + NOT_AVAILABLE_IN_LEGACY_MODE: inc(), // 28 + // directive module errors + REQUIRED_VALUE: inc(), // 29 + INVALID_VALUE: inc(), // 30 + // vue-devtools errors + CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN: inc(), // 31 + NOT_INSTALLED_WITH_PROVIDE: inc(), // 32 + // unexpected error + UNEXPECTED_ERROR: inc(), // 33 + // not compatible legacy vue-i18n constructor + NOT_COMPATIBLE_LEGACY_VUE_I18N: inc(), // 34 + // bridge support vue 2.x only + BRIDGE_SUPPORT_VUE_2_ONLY: inc(), // 35 + // need to define `i18n` option in `allowComposition: true` and `useScope: 'local' at `useI18n`` + MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION: inc(), // 36 + // Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly + NOT_AVAILABLE_COMPOSITION_IN_LEGACY: inc(), // 37 + // for enhancement + __EXTEND_POINT__: inc() // 38 +}; +function createI18nError(code, ...args) { + return createCompileError(code, null, { messages: errorMessages, args } ); +} +const errorMessages = { + [I18nErrorCodes.UNEXPECTED_RETURN_TYPE]: 'Unexpected return type in composer', + [I18nErrorCodes.INVALID_ARGUMENT]: 'Invalid argument', + [I18nErrorCodes.MUST_BE_CALL_SETUP_TOP]: 'Must be called at the top of a `setup` function', + [I18nErrorCodes.NOT_INSTALLED]: 'Need to install with `app.use` function', + [I18nErrorCodes.UNEXPECTED_ERROR]: 'Unexpected error', + [I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE]: 'Not available in legacy mode', + [I18nErrorCodes.REQUIRED_VALUE]: `Required in value: {0}`, + [I18nErrorCodes.INVALID_VALUE]: `Invalid value`, + [I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN]: `Cannot setup vue-devtools plugin`, + [I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE]: 'Need to install with `provide` function', + [I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N]: 'Not compatible legacy VueI18n.', + [I18nErrorCodes.BRIDGE_SUPPORT_VUE_2_ONLY]: 'vue-i18n-bridge support Vue 2.x only', + [I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION]: 'Must define ‘i18n’ option or custom block in Composition API with using local scope in Legacy API mode', + [I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY]: 'Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly' +}; + +const TranslateVNodeSymbol = +/* #__PURE__*/ makeSymbol('__translateVNode'); +const DatetimePartsSymbol = /* #__PURE__*/ makeSymbol('__datetimeParts'); +const NumberPartsSymbol = /* #__PURE__*/ makeSymbol('__numberParts'); +const EnableEmitter = /* #__PURE__*/ makeSymbol('__enableEmitter'); +const DisableEmitter = /* #__PURE__*/ makeSymbol('__disableEmitter'); +const SetPluralRulesSymbol = makeSymbol('__setPluralRules'); +const InejctWithOptionSymbol = +/* #__PURE__*/ makeSymbol('__injectWithOption'); +const DisposeSymbol = /* #__PURE__*/ makeSymbol('__dispose'); +const __VUE_I18N_BRIDGE__ = '__VUE_I18N_BRIDGE__'; + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Transform flat json in obj to normal json in obj + */ +function handleFlatJson(obj) { + // check obj + if (!isObject(obj)) { + return obj; + } + if (isMessageAST(obj)) { + return obj; + } + for (const key in obj) { + // check key + if (!hasOwn(obj, key)) { + continue; + } + // handle for normal json + if (!key.includes('.')) { + // recursive process value if value is also a object + if (isObject(obj[key])) { + handleFlatJson(obj[key]); + } + } + // handle for flat json, transform to normal json + else { + // go to the last object + const subKeys = key.split('.'); + const lastIndex = subKeys.length - 1; + let currentObj = obj; + let hasStringValue = false; + for (let i = 0; i < lastIndex; i++) { + if (subKeys[i] === '__proto__') { + throw new Error(`unsafe key: ${subKeys[i]}`); + } + if (!(subKeys[i] in currentObj)) { + currentObj[subKeys[i]] = create(); + } + if (!isObject(currentObj[subKeys[i]])) { + warn(getWarnMessage(I18nWarnCodes.IGNORE_OBJ_FLATTEN, { + key: subKeys[i] + })); + hasStringValue = true; + break; + } + currentObj = currentObj[subKeys[i]]; + } + // update last object value, delete old property + if (!hasStringValue) { + if (!isMessageAST(currentObj)) { + currentObj[subKeys[lastIndex]] = obj[key]; + delete obj[key]; + } + else { + /** + * NOTE: + * if the last object is a message AST and subKeys[lastIndex] has message AST prop key, ignore to copy and key deletion + */ + if (!AST_NODE_PROPS_KEYS.includes(subKeys[lastIndex])) { + delete obj[key]; + } + } + } + // recursive process value if value is also a object + if (!isMessageAST(currentObj)) { + const target = currentObj[subKeys[lastIndex]]; + if (isObject(target)) { + handleFlatJson(target); + } + } + } + } + return obj; +} +function getLocaleMessages(locale, options) { + const { messages, __i18n, messageResolver, flatJson } = options; + // prettier-ignore + const ret = (isPlainObject(messages) + ? messages + : isArray(__i18n) + ? create() + : { [locale]: create() }); + // merge locale messages of i18n custom block + if (isArray(__i18n)) { + __i18n.forEach(custom => { + if ('locale' in custom && 'resource' in custom) { + const { locale, resource } = custom; + if (locale) { + ret[locale] = ret[locale] || create(); + deepCopy(resource, ret[locale]); + } + else { + deepCopy(resource, ret); + } + } + else { + isString(custom) && deepCopy(JSON.parse(custom), ret); + } + }); + } + // handle messages for flat json + if (messageResolver == null && flatJson) { + for (const key in ret) { + if (hasOwn(ret, key)) { + handleFlatJson(ret[key]); + } + } + } + return ret; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getComponentOptions(instance) { + return instance.type ; +} +function adjustI18nResources(gl, options, componentOptions // eslint-disable-line @typescript-eslint/no-explicit-any +) { + let messages = isObject(options.messages) + ? options.messages + : create(); + if ('__i18nGlobal' in componentOptions) { + messages = getLocaleMessages(gl.locale.value, { + messages, + __i18n: componentOptions.__i18nGlobal + }); + } + // merge locale messages + const locales = Object.keys(messages); + if (locales.length) { + locales.forEach(locale => { + gl.mergeLocaleMessage(locale, messages[locale]); + }); + } + { + // merge datetime formats + if (isObject(options.datetimeFormats)) { + const locales = Object.keys(options.datetimeFormats); + if (locales.length) { + locales.forEach(locale => { + gl.mergeDateTimeFormat(locale, options.datetimeFormats[locale]); + }); + } + } + // merge number formats + if (isObject(options.numberFormats)) { + const locales = Object.keys(options.numberFormats); + if (locales.length) { + locales.forEach(locale => { + gl.mergeNumberFormat(locale, options.numberFormats[locale]); + }); + } + } + } +} +function createTextNode(key) { + return createVNode(Text, null, key, 0) + ; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +/* eslint-disable @typescript-eslint/no-explicit-any */ +// extend VNode interface +const DEVTOOLS_META = '__INTLIFY_META__'; +const NOOP_RETURN_ARRAY = () => []; +const NOOP_RETURN_FALSE = () => false; +let composerID = 0; +function defineCoreMissingHandler(missing) { + return ((ctx, locale, key, type) => { + return missing(locale, key, getCurrentInstance() || undefined, type); + }); +} +// for Intlify DevTools +/* #__NO_SIDE_EFFECTS__ */ +const getMetaInfo = () => { + const instance = getCurrentInstance(); + let meta = null; // eslint-disable-line @typescript-eslint/no-explicit-any + return instance && (meta = getComponentOptions(instance)[DEVTOOLS_META]) + ? { [DEVTOOLS_META]: meta } // eslint-disable-line @typescript-eslint/no-explicit-any + : null; +}; +/** + * Create composer interface factory + * + * @internal + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function createComposer(options = {}, VueI18nLegacy) { + const { __root, __injectWithOption } = options; + const _isGlobal = __root === undefined; + const flatJson = options.flatJson; + const _ref = inBrowser ? ref : shallowRef; + const translateExistCompatible = !!options.translateExistCompatible; + { + if (translateExistCompatible && !false) { + warnOnce(getWarnMessage(I18nWarnCodes.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG)); + } + } + let _inheritLocale = isBoolean(options.inheritLocale) + ? options.inheritLocale + : true; + const _locale = _ref( + // prettier-ignore + __root && _inheritLocale + ? __root.locale.value + : isString(options.locale) + ? options.locale + : DEFAULT_LOCALE); + const _fallbackLocale = _ref( + // prettier-ignore + __root && _inheritLocale + ? __root.fallbackLocale.value + : isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale.value); + const _messages = _ref(getLocaleMessages(_locale.value, options)); + // prettier-ignore + const _datetimeFormats = _ref(isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : { [_locale.value]: {} }) + ; + // prettier-ignore + const _numberFormats = _ref(isPlainObject(options.numberFormats) + ? options.numberFormats + : { [_locale.value]: {} }) + ; + // warning suppress options + // prettier-ignore + let _missingWarn = __root + ? __root.missingWarn + : isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + // prettier-ignore + let _fallbackWarn = __root + ? __root.fallbackWarn + : isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + // prettier-ignore + let _fallbackRoot = __root + ? __root.fallbackRoot + : isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + // configure fall back to root + let _fallbackFormat = !!options.fallbackFormat; + // runtime missing + let _missing = isFunction(options.missing) ? options.missing : null; + let _runtimeMissing = isFunction(options.missing) + ? defineCoreMissingHandler(options.missing) + : null; + // postTranslation handler + let _postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + // prettier-ignore + let _warnHtmlMessage = __root + ? __root.warnHtmlMessage + : isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + let _escapeParameter = !!options.escapeParameter; + // custom linked modifiers + // prettier-ignore + const _modifiers = __root + ? __root.modifiers + : isPlainObject(options.modifiers) + ? options.modifiers + : {}; + // pluralRules + let _pluralRules = options.pluralRules || (__root && __root.pluralRules); + // runtime context + // eslint-disable-next-line prefer-const + let _context; + const getCoreContext = () => { + _isGlobal && setFallbackContext(null); + const ctxOptions = { + version: VERSION, + locale: _locale.value, + fallbackLocale: _fallbackLocale.value, + messages: _messages.value, + modifiers: _modifiers, + pluralRules: _pluralRules, + missing: _runtimeMissing === null ? undefined : _runtimeMissing, + missingWarn: _missingWarn, + fallbackWarn: _fallbackWarn, + fallbackFormat: _fallbackFormat, + unresolving: true, + postTranslation: _postTranslation === null ? undefined : _postTranslation, + warnHtmlMessage: _warnHtmlMessage, + escapeParameter: _escapeParameter, + messageResolver: options.messageResolver, + messageCompiler: options.messageCompiler, + __meta: { framework: 'vue' } + }; + { + ctxOptions.datetimeFormats = _datetimeFormats.value; + ctxOptions.numberFormats = _numberFormats.value; + ctxOptions.__datetimeFormatters = isPlainObject(_context) + ? _context.__datetimeFormatters + : undefined; + ctxOptions.__numberFormatters = isPlainObject(_context) + ? _context.__numberFormatters + : undefined; + } + { + ctxOptions.__v_emitter = isPlainObject(_context) + ? _context.__v_emitter + : undefined; + } + const ctx = createCoreContext(ctxOptions); + _isGlobal && setFallbackContext(ctx); + return ctx; + }; + _context = getCoreContext(); + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + // track reactivity + function trackReactivityValues() { + return [ + _locale.value, + _fallbackLocale.value, + _messages.value, + _datetimeFormats.value, + _numberFormats.value + ] + ; + } + // locale + const locale = computed({ + get: () => _locale.value, + set: val => { + _locale.value = val; + _context.locale = _locale.value; + } + }); + // fallbackLocale + const fallbackLocale = computed({ + get: () => _fallbackLocale.value, + set: val => { + _fallbackLocale.value = val; + _context.fallbackLocale = _fallbackLocale.value; + updateFallbackLocale(_context, _locale.value, val); + } + }); + // messages + const messages = computed(() => _messages.value); + // datetimeFormats + const datetimeFormats = /* #__PURE__*/ computed(() => _datetimeFormats.value); + // numberFormats + const numberFormats = /* #__PURE__*/ computed(() => _numberFormats.value); + // getPostTranslationHandler + function getPostTranslationHandler() { + return isFunction(_postTranslation) ? _postTranslation : null; + } + // setPostTranslationHandler + function setPostTranslationHandler(handler) { + _postTranslation = handler; + _context.postTranslation = handler; + } + // getMissingHandler + function getMissingHandler() { + return _missing; + } + // setMissingHandler + function setMissingHandler(handler) { + if (handler !== null) { + _runtimeMissing = defineCoreMissingHandler(handler); + } + _missing = handler; + _context.missing = _runtimeMissing; + } + function isResolvedTranslateMessage(type, arg // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + return type !== 'translate' || !arg.resolvedMessage; + } + const wrapWithDeps = (fn, argumentParser, warnType, fallbackSuccess, fallbackFail, successCondition) => { + trackReactivityValues(); // track reactive dependency + // NOTE: experimental !! + let ret; + try { + if (true || false) { + setAdditionalMeta(getMetaInfo()); + } + if (!_isGlobal) { + _context.fallbackContext = __root + ? getFallbackContext() + : undefined; + } + ret = fn(_context); + } + finally { + if (!_isGlobal) { + _context.fallbackContext = undefined; + } + } + if ((warnType !== 'translate exists' && // for not `te` (e.g `t`) + isNumber(ret) && + ret === NOT_REOSLVED) || + (warnType === 'translate exists' && !ret) // for `te` + ) { + const [key, arg2] = argumentParser(); + if (__root && + isString(key) && + isResolvedTranslateMessage(warnType, arg2)) { + if (_fallbackRoot && + (isTranslateFallbackWarn(_fallbackWarn, key) || + isTranslateMissingWarn(_missingWarn, key))) { + warn(getWarnMessage(I18nWarnCodes.FALLBACK_TO_ROOT, { + key, + type: warnType + })); + } + // for vue-devtools timeline event + { + const { __v_emitter: emitter } = _context; + if (emitter && _fallbackRoot) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type: warnType, + key, + to: 'global', + groupId: `${warnType}:${key}` + }); + } + } + } + return __root && _fallbackRoot + ? fallbackSuccess(__root) + : fallbackFail(key); + } + else if (successCondition(ret)) { + return ret; + } + else { + /* istanbul ignore next */ + throw createI18nError(I18nErrorCodes.UNEXPECTED_RETURN_TYPE); + } + }; + // t + function t(...args) { + return wrapWithDeps(context => Reflect.apply(translate, null, [context, ...args]), () => parseTranslateArgs(...args), 'translate', root => Reflect.apply(root.t, root, [...args]), key => key, val => isString(val)); + } + // rt + function rt(...args) { + const [arg1, arg2, arg3] = args; + if (arg3 && !isObject(arg3)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + return t(...[arg1, arg2, assign({ resolvedMessage: true }, arg3 || {})]); + } + // d + function d(...args) { + return wrapWithDeps(context => Reflect.apply(datetime, null, [context, ...args]), () => parseDateTimeArgs(...args), 'datetime format', root => Reflect.apply(root.d, root, [...args]), () => MISSING_RESOLVE_VALUE, val => isString(val)); + } + // n + function n(...args) { + return wrapWithDeps(context => Reflect.apply(number, null, [context, ...args]), () => parseNumberArgs(...args), 'number format', root => Reflect.apply(root.n, root, [...args]), () => MISSING_RESOLVE_VALUE, val => isString(val)); + } + // for custom processor + function normalize(values) { + return values.map(val => isString(val) || isNumber(val) || isBoolean(val) + ? createTextNode(String(val)) + : val); + } + const interpolate = (val) => val; + const processor = { + normalize, + interpolate, + type: 'vnode' + }; + // translateVNode, using for `i18n-t` component + function translateVNode(...args) { + return wrapWithDeps(context => { + let ret; + const _context = context; + try { + _context.processor = processor; + ret = Reflect.apply(translate, null, [_context, ...args]); + } + finally { + _context.processor = null; + } + return ret; + }, () => parseTranslateArgs(...args), 'translate', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[TranslateVNodeSymbol](...args), key => [createTextNode(key)], val => isArray(val)); + } + // numberParts, using for `i18n-n` component + function numberParts(...args) { + return wrapWithDeps(context => Reflect.apply(number, null, [context, ...args]), () => parseNumberArgs(...args), 'number format', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[NumberPartsSymbol](...args), NOOP_RETURN_ARRAY, val => isString(val) || isArray(val)); + } + // datetimeParts, using for `i18n-d` component + function datetimeParts(...args) { + return wrapWithDeps(context => Reflect.apply(datetime, null, [context, ...args]), () => parseDateTimeArgs(...args), 'datetime format', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[DatetimePartsSymbol](...args), NOOP_RETURN_ARRAY, val => isString(val) || isArray(val)); + } + function setPluralRules(rules) { + _pluralRules = rules; + _context.pluralRules = _pluralRules; + } + // te + function te(key, locale) { + return wrapWithDeps(() => { + if (!key) { + return false; + } + const targetLocale = isString(locale) ? locale : _locale.value; + const message = getLocaleMessage(targetLocale); + const resolved = _context.messageResolver(message, key); + return !translateExistCompatible + ? isMessageAST(resolved) || + isMessageFunction(resolved) || + isString(resolved) + : resolved != null; + }, () => [key], 'translate exists', root => { + return Reflect.apply(root.te, root, [key, locale]); + }, NOOP_RETURN_FALSE, val => isBoolean(val)); + } + function resolveMessages(key) { + let messages = null; + const locales = fallbackWithLocaleChain(_context, _fallbackLocale.value, _locale.value); + for (let i = 0; i < locales.length; i++) { + const targetLocaleMessages = _messages.value[locales[i]] || {}; + const messageValue = _context.messageResolver(targetLocaleMessages, key); + if (messageValue != null) { + messages = messageValue; + break; + } + } + return messages; + } + // tm + function tm(key) { + const messages = resolveMessages(key); + // prettier-ignore + return messages != null + ? messages + : __root + ? __root.tm(key) || {} + : {}; + } + // getLocaleMessage + function getLocaleMessage(locale) { + return (_messages.value[locale] || {}); + } + // setLocaleMessage + function setLocaleMessage(locale, message) { + if (flatJson) { + const _message = { [locale]: message }; + for (const key in _message) { + if (hasOwn(_message, key)) { + handleFlatJson(_message[key]); + } + } + message = _message[locale]; + } + _messages.value[locale] = message; + _context.messages = _messages.value; + } + // mergeLocaleMessage + function mergeLocaleMessage(locale, message) { + _messages.value[locale] = _messages.value[locale] || {}; + const _message = { [locale]: message }; + if (flatJson) { + for (const key in _message) { + if (hasOwn(_message, key)) { + handleFlatJson(_message[key]); + } + } + } + message = _message[locale]; + deepCopy(message, _messages.value[locale]); + _context.messages = _messages.value; + } + // getDateTimeFormat + function getDateTimeFormat(locale) { + return _datetimeFormats.value[locale] || {}; + } + // setDateTimeFormat + function setDateTimeFormat(locale, format) { + _datetimeFormats.value[locale] = format; + _context.datetimeFormats = _datetimeFormats.value; + clearDateTimeFormat(_context, locale, format); + } + // mergeDateTimeFormat + function mergeDateTimeFormat(locale, format) { + _datetimeFormats.value[locale] = assign(_datetimeFormats.value[locale] || {}, format); + _context.datetimeFormats = _datetimeFormats.value; + clearDateTimeFormat(_context, locale, format); + } + // getNumberFormat + function getNumberFormat(locale) { + return _numberFormats.value[locale] || {}; + } + // setNumberFormat + function setNumberFormat(locale, format) { + _numberFormats.value[locale] = format; + _context.numberFormats = _numberFormats.value; + clearNumberFormat(_context, locale, format); + } + // mergeNumberFormat + function mergeNumberFormat(locale, format) { + _numberFormats.value[locale] = assign(_numberFormats.value[locale] || {}, format); + _context.numberFormats = _numberFormats.value; + clearNumberFormat(_context, locale, format); + } + // for debug + composerID++; + // watch root locale & fallbackLocale + if (__root && inBrowser) { + watch(__root.locale, (val) => { + if (_inheritLocale) { + _locale.value = val; + _context.locale = val; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }); + watch(__root.fallbackLocale, (val) => { + if (_inheritLocale) { + _fallbackLocale.value = val; + _context.fallbackLocale = val; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }); + } + // define basic composition API! + const composer = { + id: composerID, + locale, + fallbackLocale, + get inheritLocale() { + return _inheritLocale; + }, + set inheritLocale(val) { + _inheritLocale = val; + if (val && __root) { + _locale.value = __root.locale.value; + _fallbackLocale.value = __root.fallbackLocale.value; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }, + get availableLocales() { + return Object.keys(_messages.value).sort(); + }, + messages, + get modifiers() { + return _modifiers; + }, + get pluralRules() { + return _pluralRules || {}; + }, + get isGlobal() { + return _isGlobal; + }, + get missingWarn() { + return _missingWarn; + }, + set missingWarn(val) { + _missingWarn = val; + _context.missingWarn = _missingWarn; + }, + get fallbackWarn() { + return _fallbackWarn; + }, + set fallbackWarn(val) { + _fallbackWarn = val; + _context.fallbackWarn = _fallbackWarn; + }, + get fallbackRoot() { + return _fallbackRoot; + }, + set fallbackRoot(val) { + _fallbackRoot = val; + }, + get fallbackFormat() { + return _fallbackFormat; + }, + set fallbackFormat(val) { + _fallbackFormat = val; + _context.fallbackFormat = _fallbackFormat; + }, + get warnHtmlMessage() { + return _warnHtmlMessage; + }, + set warnHtmlMessage(val) { + _warnHtmlMessage = val; + _context.warnHtmlMessage = val; + }, + get escapeParameter() { + return _escapeParameter; + }, + set escapeParameter(val) { + _escapeParameter = val; + _context.escapeParameter = val; + }, + t, + getLocaleMessage, + setLocaleMessage, + mergeLocaleMessage, + getPostTranslationHandler, + setPostTranslationHandler, + getMissingHandler, + setMissingHandler, + [SetPluralRulesSymbol]: setPluralRules + }; + { + composer.datetimeFormats = datetimeFormats; + composer.numberFormats = numberFormats; + composer.rt = rt; + composer.te = te; + composer.tm = tm; + composer.d = d; + composer.n = n; + composer.getDateTimeFormat = getDateTimeFormat; + composer.setDateTimeFormat = setDateTimeFormat; + composer.mergeDateTimeFormat = mergeDateTimeFormat; + composer.getNumberFormat = getNumberFormat; + composer.setNumberFormat = setNumberFormat; + composer.mergeNumberFormat = mergeNumberFormat; + composer[InejctWithOptionSymbol] = __injectWithOption; + composer[TranslateVNodeSymbol] = translateVNode; + composer[DatetimePartsSymbol] = datetimeParts; + composer[NumberPartsSymbol] = numberParts; + } + // for vue-devtools timeline event + { + composer[EnableEmitter] = (emitter) => { + _context.__v_emitter = emitter; + }; + composer[DisableEmitter] = () => { + _context.__v_emitter = undefined; + }; + } + return composer; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Convert to I18n Composer Options from VueI18n Options + * + * @internal + */ +function convertComposerOptions(options) { + const locale = isString(options.locale) ? options.locale : DEFAULT_LOCALE; + const fallbackLocale = isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : locale; + const missing = isFunction(options.missing) ? options.missing : undefined; + const missingWarn = isBoolean(options.silentTranslationWarn) || + isRegExp(options.silentTranslationWarn) + ? !options.silentTranslationWarn + : true; + const fallbackWarn = isBoolean(options.silentFallbackWarn) || + isRegExp(options.silentFallbackWarn) + ? !options.silentFallbackWarn + : true; + const fallbackRoot = isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + const fallbackFormat = !!options.formatFallbackMessages; + const modifiers = isPlainObject(options.modifiers) ? options.modifiers : {}; + const pluralizationRules = options.pluralizationRules; + const postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : undefined; + const warnHtmlMessage = isString(options.warnHtmlInMessage) + ? options.warnHtmlInMessage !== 'off' + : true; + const escapeParameter = !!options.escapeParameterHtml; + const inheritLocale = isBoolean(options.sync) ? options.sync : true; + if (options.formatter) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + } + if (options.preserveDirectiveContent) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + } + let messages = options.messages; + if (isPlainObject(options.sharedMessages)) { + const sharedMessages = options.sharedMessages; + const locales = Object.keys(sharedMessages); + messages = locales.reduce((messages, locale) => { + const message = messages[locale] || (messages[locale] = {}); + assign(message, sharedMessages[locale]); + return messages; + }, (messages || {})); + } + const { __i18n, __root, __injectWithOption } = options; + const datetimeFormats = options.datetimeFormats; + const numberFormats = options.numberFormats; + const flatJson = options.flatJson; + const translateExistCompatible = options + .translateExistCompatible; + return { + locale, + fallbackLocale, + messages, + flatJson, + datetimeFormats, + numberFormats, + missing, + missingWarn, + fallbackWarn, + fallbackRoot, + fallbackFormat, + modifiers, + pluralRules: pluralizationRules, + postTranslation, + warnHtmlMessage, + escapeParameter, + messageResolver: options.messageResolver, + inheritLocale, + translateExistCompatible, + __i18n, + __root, + __injectWithOption + }; +} +/** + * create VueI18n interface factory + * + * @internal + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function createVueI18n(options = {}, VueI18nLegacy) { + { + const composer = createComposer(convertComposerOptions(options)); + const { __extender } = options; + // defines VueI18n + const vueI18n = { + // id + id: composer.id, + // locale + get locale() { + return composer.locale.value; + }, + set locale(val) { + composer.locale.value = val; + }, + // fallbackLocale + get fallbackLocale() { + return composer.fallbackLocale.value; + }, + set fallbackLocale(val) { + composer.fallbackLocale.value = val; + }, + // messages + get messages() { + return composer.messages.value; + }, + // datetimeFormats + get datetimeFormats() { + return composer.datetimeFormats.value; + }, + // numberFormats + get numberFormats() { + return composer.numberFormats.value; + }, + // availableLocales + get availableLocales() { + return composer.availableLocales; + }, + // formatter + get formatter() { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + // dummy + return { + interpolate() { + return []; + } + }; + }, + set formatter(val) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + }, + // missing + get missing() { + return composer.getMissingHandler(); + }, + set missing(handler) { + composer.setMissingHandler(handler); + }, + // silentTranslationWarn + get silentTranslationWarn() { + return isBoolean(composer.missingWarn) + ? !composer.missingWarn + : composer.missingWarn; + }, + set silentTranslationWarn(val) { + composer.missingWarn = isBoolean(val) ? !val : val; + }, + // silentFallbackWarn + get silentFallbackWarn() { + return isBoolean(composer.fallbackWarn) + ? !composer.fallbackWarn + : composer.fallbackWarn; + }, + set silentFallbackWarn(val) { + composer.fallbackWarn = isBoolean(val) ? !val : val; + }, + // modifiers + get modifiers() { + return composer.modifiers; + }, + // formatFallbackMessages + get formatFallbackMessages() { + return composer.fallbackFormat; + }, + set formatFallbackMessages(val) { + composer.fallbackFormat = val; + }, + // postTranslation + get postTranslation() { + return composer.getPostTranslationHandler(); + }, + set postTranslation(handler) { + composer.setPostTranslationHandler(handler); + }, + // sync + get sync() { + return composer.inheritLocale; + }, + set sync(val) { + composer.inheritLocale = val; + }, + // warnInHtmlMessage + get warnHtmlInMessage() { + return composer.warnHtmlMessage ? 'warn' : 'off'; + }, + set warnHtmlInMessage(val) { + composer.warnHtmlMessage = val !== 'off'; + }, + // escapeParameterHtml + get escapeParameterHtml() { + return composer.escapeParameter; + }, + set escapeParameterHtml(val) { + composer.escapeParameter = val; + }, + // preserveDirectiveContent + get preserveDirectiveContent() { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + return true; + }, + set preserveDirectiveContent(val) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + }, + // pluralizationRules + get pluralizationRules() { + return composer.pluralRules || {}; + }, + // for internal + __composer: composer, + // t + t(...args) { + const [arg1, arg2, arg3] = args; + const options = {}; + let list = null; + let named = null; + if (!isString(arg1)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + const key = arg1; + if (isString(arg2)) { + options.locale = arg2; + } + else if (isArray(arg2)) { + list = arg2; + } + else if (isPlainObject(arg2)) { + named = arg2; + } + if (isArray(arg3)) { + list = arg3; + } + else if (isPlainObject(arg3)) { + named = arg3; + } + // return composer.t(key, (list || named || {}) as any, options) + return Reflect.apply(composer.t, composer, [ + key, + (list || named || {}), + options + ]); + }, + rt(...args) { + return Reflect.apply(composer.rt, composer, [...args]); + }, + // tc + tc(...args) { + const [arg1, arg2, arg3] = args; + const options = { plural: 1 }; + let list = null; + let named = null; + if (!isString(arg1)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + const key = arg1; + if (isString(arg2)) { + options.locale = arg2; + } + else if (isNumber(arg2)) { + options.plural = arg2; + } + else if (isArray(arg2)) { + list = arg2; + } + else if (isPlainObject(arg2)) { + named = arg2; + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isArray(arg3)) { + list = arg3; + } + else if (isPlainObject(arg3)) { + named = arg3; + } + // return composer.t(key, (list || named || {}) as any, options) + return Reflect.apply(composer.t, composer, [ + key, + (list || named || {}), + options + ]); + }, + // te + te(key, locale) { + return composer.te(key, locale); + }, + // tm + tm(key) { + return composer.tm(key); + }, + // getLocaleMessage + getLocaleMessage(locale) { + return composer.getLocaleMessage(locale); + }, + // setLocaleMessage + setLocaleMessage(locale, message) { + composer.setLocaleMessage(locale, message); + }, + // mergeLocaleMessage + mergeLocaleMessage(locale, message) { + composer.mergeLocaleMessage(locale, message); + }, + // d + d(...args) { + return Reflect.apply(composer.d, composer, [...args]); + }, + // getDateTimeFormat + getDateTimeFormat(locale) { + return composer.getDateTimeFormat(locale); + }, + // setDateTimeFormat + setDateTimeFormat(locale, format) { + composer.setDateTimeFormat(locale, format); + }, + // mergeDateTimeFormat + mergeDateTimeFormat(locale, format) { + composer.mergeDateTimeFormat(locale, format); + }, + // n + n(...args) { + return Reflect.apply(composer.n, composer, [...args]); + }, + // getNumberFormat + getNumberFormat(locale) { + return composer.getNumberFormat(locale); + }, + // setNumberFormat + setNumberFormat(locale, format) { + composer.setNumberFormat(locale, format); + }, + // mergeNumberFormat + mergeNumberFormat(locale, format) { + composer.mergeNumberFormat(locale, format); + }, + // getChoiceIndex + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getChoiceIndex(choice, choicesLength) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX)); + return -1; + } + }; + vueI18n.__extender = __extender; + // for vue-devtools timeline event + { + vueI18n.__enableEmitter = (emitter) => { + const __composer = composer; + __composer[EnableEmitter] && __composer[EnableEmitter](emitter); + }; + vueI18n.__disableEmitter = () => { + const __composer = composer; + __composer[DisableEmitter] && __composer[DisableEmitter](); + }; + } + return vueI18n; + } +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +const baseFormatProps = { + tag: { + type: [String, Object] + }, + locale: { + type: String + }, + scope: { + type: String, + // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050 + validator: (val /* ComponentI18nScope */) => val === 'parent' || val === 'global', + default: 'parent' /* ComponentI18nScope */ + }, + i18n: { + type: Object + } +}; + +function getInterpolateArg( +// eslint-disable-next-line @typescript-eslint/no-explicit-any +{ slots }, // SetupContext, +keys) { + if (keys.length === 1 && keys[0] === 'default') { + // default slot with list + const ret = slots.default ? slots.default() : []; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return ret.reduce((slot, current) => { + return [ + ...slot, + // prettier-ignore + ...(current.type === Fragment ? current.children : [current] + ) + ]; + }, []); + } + else { + // named slots + return keys.reduce((arg, key) => { + const slot = slots[key]; + if (slot) { + arg[key] = slot(); + } + return arg; + }, create()); + } +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getFragmentableTag(tag) { + return Fragment ; +} + +const TranslationImpl = /*#__PURE__*/ defineComponent({ + /* eslint-disable */ + name: 'i18n-t', + props: assign({ + keypath: { + type: String, + required: true + }, + plural: { + type: [Number, String], + // eslint-disable-next-line @typescript-eslint/no-explicit-any + validator: (val) => isNumber(val) || !isNaN(val) + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const { slots, attrs } = context; + // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050 + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return () => { + const keys = Object.keys(slots).filter(key => key !== '_'); + const options = create(); + if (props.locale) { + options.locale = props.locale; + } + if (props.plural !== undefined) { + options.plural = isString(props.plural) ? +props.plural : props.plural; + } + const arg = getInterpolateArg(context, keys); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const children = i18n[TranslateVNodeSymbol](props.keypath, arg, options); + const assignedAttrs = assign(create(), attrs); + const tag = isString(props.tag) || isObject(props.tag) + ? props.tag + : getFragmentableTag(); + return h(tag, assignedAttrs, children); + }; + } +}); +/** + * export the public type for h/tsx inference + * also to avoid inline import() in generated d.ts files + */ +/** + * Translation Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [TranslationProps](component#translationprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Component Interpolation](../guide/advanced/component) + * + * @example + * ```html + *
+ * + * + * {{ $t('tos') }} + * + * + *
+ * ``` + * ```js + * import { createApp } from 'vue' + * import { createI18n } from 'vue-i18n' + * + * const messages = { + * en: { + * tos: 'Term of Service', + * term: 'I accept xxx {0}.' + * }, + * ja: { + * tos: '利用規約', + * term: '私は xxx の{0}に同意します。' + * } + * } + * + * const i18n = createI18n({ + * locale: 'en', + * messages + * }) + * + * const app = createApp({ + * data: { + * url: '/term' + * } + * }).use(i18n).mount('#app') + * ``` + * + * @VueI18nComponent + */ +const Translation = TranslationImpl; +const I18nT = Translation; + +function isVNode(target) { + return isArray(target) && !isString(target[0]); +} +function renderFormatter(props, context, slotKeys, partFormatter) { + const { slots, attrs } = context; + return () => { + const options = { part: true }; + let overrides = create(); + if (props.locale) { + options.locale = props.locale; + } + if (isString(props.format)) { + options.key = props.format; + } + else if (isObject(props.format)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (isString(props.format.key)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + options.key = props.format.key; + } + // Filter out number format options only + overrides = Object.keys(props.format).reduce((options, prop) => { + return slotKeys.includes(prop) + ? assign(create(), options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any + : options; + }, create()); + } + const parts = partFormatter(...[props.value, options, overrides]); + let children = [options.key]; + if (isArray(parts)) { + children = parts.map((part, index) => { + const slot = slots[part.type]; + const node = slot + ? slot({ [part.type]: part.value, index, parts }) + : [part.value]; + if (isVNode(node)) { + node[0].key = `${part.type}-${index}`; + } + return node; + }); + } + else if (isString(parts)) { + children = [parts]; + } + const assignedAttrs = assign(create(), attrs); + const tag = isString(props.tag) || isObject(props.tag) + ? props.tag + : getFragmentableTag(); + return h(tag, assignedAttrs, children); + }; +} + +const NumberFormatImpl = /*#__PURE__*/ defineComponent({ + /* eslint-disable */ + name: 'i18n-n', + props: assign({ + value: { + type: Number, + required: true + }, + format: { + type: [String, Object] + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return renderFormatter(props, context, NUMBER_FORMAT_OPTIONS_KEYS, (...args) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + i18n[NumberPartsSymbol](...args)); + } +}); +/** + * export the public type for h/tsx inference + * also to avoid inline import() in generated d.ts files + */ +/** + * Number Format Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [FormattableProps](component#formattableprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Custom Formatting](../guide/essentials/number#custom-formatting) + * + * @VueI18nDanger + * Not supported IE, due to no support `Intl.NumberFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts) + * + * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-numberformat) + * + * @VueI18nComponent + */ +const NumberFormat = NumberFormatImpl; +const I18nN = NumberFormat; + +const DatetimeFormatImpl = /* #__PURE__*/ defineComponent({ + /* eslint-disable */ + name: 'i18n-d', + props: assign({ + value: { + type: [Number, Date], + required: true + }, + format: { + type: [String, Object] + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return renderFormatter(props, context, DATETIME_FORMAT_OPTIONS_KEYS, (...args) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + i18n[DatetimePartsSymbol](...args)); + } +}); +/** + * Datetime Format Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [FormattableProps](component#formattableprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Custom Formatting](../guide/essentials/datetime#custom-formatting) + * + * @VueI18nDanger + * Not supported IE, due to no support `Intl.DateTimeFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts) + * + * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-datetimeformat) + * + * @VueI18nComponent + */ +const DatetimeFormat = DatetimeFormatImpl; +const I18nD = DatetimeFormat; + +function getComposer$2(i18n, instance) { + const i18nInternal = i18n; + if (i18n.mode === 'composition') { + return (i18nInternal.__getInstance(instance) || i18n.global); + } + else { + const vueI18n = i18nInternal.__getInstance(instance); + return vueI18n != null + ? vueI18n.__composer + : i18n.global.__composer; + } +} +function vTDirective(i18n) { + const _process = (binding) => { + const { instance, modifiers, value } = binding; + /* istanbul ignore if */ + if (!instance || !instance.$) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const composer = getComposer$2(i18n, instance.$); + if (modifiers.preserve) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE)); + } + const parsedValue = parseValue(value); + return [ + Reflect.apply(composer.t, composer, [...makeParams(parsedValue)]), + composer + ]; + }; + const register = (el, binding) => { + const [textContent, composer] = _process(binding); + if (inBrowser && i18n.global === composer) { + // global scope only + el.__i18nWatcher = watch(composer.locale, () => { + binding.instance && binding.instance.$forceUpdate(); + }); + } + el.__composer = composer; + el.textContent = textContent; + }; + const unregister = (el) => { + if (inBrowser && el.__i18nWatcher) { + el.__i18nWatcher(); + el.__i18nWatcher = undefined; + delete el.__i18nWatcher; + } + if (el.__composer) { + el.__composer = undefined; + delete el.__composer; + } + }; + const update = (el, { value }) => { + if (el.__composer) { + const composer = el.__composer; + const parsedValue = parseValue(value); + el.textContent = Reflect.apply(composer.t, composer, [ + ...makeParams(parsedValue) + ]); + } + }; + const getSSRProps = (binding) => { + const [textContent] = _process(binding); + return { textContent }; + }; + return { + created: register, + unmounted: unregister, + beforeUpdate: update, + getSSRProps + }; +} +function parseValue(value) { + if (isString(value)) { + return { path: value }; + } + else if (isPlainObject(value)) { + if (!('path' in value)) { + throw createI18nError(I18nErrorCodes.REQUIRED_VALUE, 'path'); + } + return value; + } + else { + throw createI18nError(I18nErrorCodes.INVALID_VALUE); + } +} +function makeParams(value) { + const { path, locale, args, choice, plural } = value; + const options = {}; + const named = args || {}; + if (isString(locale)) { + options.locale = locale; + } + if (isNumber(choice)) { + options.plural = choice; + } + if (isNumber(plural)) { + options.plural = plural; + } + return [path, named, options]; +} + +function apply(app, i18n, ...options) { + const pluginOptions = isPlainObject(options[0]) + ? options[0] + : {}; + const useI18nComponentName = !!pluginOptions.useI18nComponentName; + const globalInstall = isBoolean(pluginOptions.globalInstall) + ? pluginOptions.globalInstall + : true; + if (globalInstall && useI18nComponentName) { + warn(getWarnMessage(I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE, { + name: Translation.name + })); + } + if (globalInstall) { + [!useI18nComponentName ? Translation.name : 'i18n', 'I18nT'].forEach(name => app.component(name, Translation)); + [NumberFormat.name, 'I18nN'].forEach(name => app.component(name, NumberFormat)); + [DatetimeFormat.name, 'I18nD'].forEach(name => app.component(name, DatetimeFormat)); + } + // install directive + { + app.directive('t', vTDirective(i18n)); + } +} + +var global$1 = (typeof global !== "undefined" ? global : + typeof self !== "undefined" ? self : + typeof window !== "undefined" ? window : {}); + +function getDevtoolsGlobalHook() { + return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__; +} +function getTarget() { + // @ts-ignore + return (typeof navigator !== 'undefined' && typeof window !== 'undefined') + ? window + : typeof global$1 !== 'undefined' + ? global$1 + : {}; +} +const isProxyAvailable = typeof Proxy === 'function'; + +const HOOK_SETUP = 'devtools-plugin:setup'; +const HOOK_PLUGIN_SETTINGS_SET = 'plugin:settings:set'; + +let supported; +let perf; +function isPerformanceSupported() { + var _a; + if (supported !== undefined) { + return supported; + } + if (typeof window !== 'undefined' && window.performance) { + supported = true; + perf = window.performance; + } + else if (typeof global$1 !== 'undefined' && ((_a = global$1.perf_hooks) === null || _a === void 0 ? void 0 : _a.performance)) { + supported = true; + perf = global$1.perf_hooks.performance; + } + else { + supported = false; + } + return supported; +} +function now() { + return isPerformanceSupported() ? perf.now() : Date.now(); +} + +class ApiProxy { + constructor(plugin, hook) { + this.target = null; + this.targetQueue = []; + this.onQueue = []; + this.plugin = plugin; + this.hook = hook; + const defaultSettings = {}; + if (plugin.settings) { + for (const id in plugin.settings) { + const item = plugin.settings[id]; + defaultSettings[id] = item.defaultValue; + } + } + const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin.id}`; + let currentSettings = Object.assign({}, defaultSettings); + try { + const raw = localStorage.getItem(localSettingsSaveId); + const data = JSON.parse(raw); + Object.assign(currentSettings, data); + } + catch (e) { + // noop + } + this.fallbacks = { + getSettings() { + return currentSettings; + }, + setSettings(value) { + try { + localStorage.setItem(localSettingsSaveId, JSON.stringify(value)); + } + catch (e) { + // noop + } + currentSettings = value; + }, + now() { + return now(); + }, + }; + if (hook) { + hook.on(HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => { + if (pluginId === this.plugin.id) { + this.fallbacks.setSettings(value); + } + }); + } + this.proxiedOn = new Proxy({}, { + get: (_target, prop) => { + if (this.target) { + return this.target.on[prop]; + } + else { + return (...args) => { + this.onQueue.push({ + method: prop, + args, + }); + }; + } + }, + }); + this.proxiedTarget = new Proxy({}, { + get: (_target, prop) => { + if (this.target) { + return this.target[prop]; + } + else if (prop === 'on') { + return this.proxiedOn; + } + else if (Object.keys(this.fallbacks).includes(prop)) { + return (...args) => { + this.targetQueue.push({ + method: prop, + args, + resolve: () => { }, + }); + return this.fallbacks[prop](...args); + }; + } + else { + return (...args) => { + return new Promise(resolve => { + this.targetQueue.push({ + method: prop, + args, + resolve, + }); + }); + }; + } + }, + }); + } + async setRealTarget(target) { + this.target = target; + for (const item of this.onQueue) { + this.target.on[item.method](...item.args); + } + for (const item of this.targetQueue) { + item.resolve(await this.target[item.method](...item.args)); + } + } +} + +function setupDevtoolsPlugin(pluginDescriptor, setupFn) { + const descriptor = pluginDescriptor; + const target = getTarget(); + const hook = getDevtoolsGlobalHook(); + const enableProxy = isProxyAvailable && descriptor.enableEarlyProxy; + if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) { + hook.emit(HOOK_SETUP, pluginDescriptor, setupFn); + } + else { + const proxy = enableProxy ? new ApiProxy(descriptor, hook) : null; + const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || []; + list.push({ + pluginDescriptor: descriptor, + setupFn, + proxy, + }); + if (proxy) + setupFn(proxy.proxiedTarget); + } +} + +const VueDevToolsLabels = { + ["vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */]: 'Vue I18n devtools', + ["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */]: 'I18n Resources', + ["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */]: 'Vue I18n' +}; +const VueDevToolsPlaceholders = { + ["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */]: 'Search for scopes ...' +}; +const VueDevToolsTimelineColors = { + ["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */]: 0xffcd19 +}; + +const VUE_I18N_COMPONENT_TYPES = 'vue-i18n: composer properties'; +let devtoolsApi; +async function enableDevTools(app, i18n) { + return new Promise((resolve, reject) => { + try { + setupDevtoolsPlugin({ + id: "vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */, + label: VueDevToolsLabels["vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */], + packageName: 'vue-i18n', + homepage: 'https://vue-i18n.intlify.dev', + logo: 'https://vue-i18n.intlify.dev/vue-i18n-devtools-logo.png', + componentStateTypes: [VUE_I18N_COMPONENT_TYPES], + app: app // eslint-disable-line @typescript-eslint/no-explicit-any + }, api => { + devtoolsApi = api; + api.on.visitComponentTree(({ componentInstance, treeNode }) => { + updateComponentTreeTags(componentInstance, treeNode, i18n); + }); + api.on.inspectComponent(({ componentInstance, instanceData }) => { + if (componentInstance.vnode.el && + componentInstance.vnode.el.__VUE_I18N__ && + instanceData) { + if (i18n.mode === 'legacy') { + // ignore global scope on legacy mode + if (componentInstance.vnode.el.__VUE_I18N__ !== + i18n.global.__composer) { + inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__); + } + } + else { + inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__); + } + } + }); + api.addInspector({ + id: "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */, + label: VueDevToolsLabels["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */], + icon: 'language', + treeFilterPlaceholder: VueDevToolsPlaceholders["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */] + }); + api.on.getInspectorTree(payload => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + registerScope(payload, i18n); + } + }); + const roots = new Map(); + api.on.getInspectorState(async (payload) => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + api.unhighlightElement(); + inspectScope(payload, i18n); + if (payload.nodeId === 'global') { + if (!roots.has(payload.app)) { + const [root] = await api.getComponentInstances(payload.app); + roots.set(payload.app, root); + } + api.highlightElement(roots.get(payload.app)); + } + else { + const instance = getComponentInstance(payload.nodeId, i18n); + instance && api.highlightElement(instance); + } + } + }); + api.on.editInspectorState(payload => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + editScope(payload, i18n); + } + }); + api.addTimelineLayer({ + id: "vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */, + label: VueDevToolsLabels["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */], + color: VueDevToolsTimelineColors["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */] + }); + resolve(true); + }); + } + catch (e) { + console.error(e); + reject(false); + } + }); +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getI18nScopeLable(instance) { + return (instance.type.name || + instance.type.displayName || + instance.type.__file || + 'Anonymous'); +} +function updateComponentTreeTags(instance, // eslint-disable-line @typescript-eslint/no-explicit-any +treeNode, i18n) { + // prettier-ignore + const global = i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + if (instance && instance.vnode.el && instance.vnode.el.__VUE_I18N__) { + // add custom tags local scope only + if (instance.vnode.el.__VUE_I18N__ !== global) { + const tag = { + label: `i18n (${getI18nScopeLable(instance)} Scope)`, + textColor: 0x000000, + backgroundColor: 0xffcd19 + }; + treeNode.tags.push(tag); + } + } +} +function inspectComposer(instanceData, composer) { + const type = VUE_I18N_COMPONENT_TYPES; + instanceData.state.push({ + type, + key: 'locale', + editable: true, + value: composer.locale.value + }); + instanceData.state.push({ + type, + key: 'availableLocales', + editable: false, + value: composer.availableLocales + }); + instanceData.state.push({ + type, + key: 'fallbackLocale', + editable: true, + value: composer.fallbackLocale.value + }); + instanceData.state.push({ + type, + key: 'inheritLocale', + editable: true, + value: composer.inheritLocale + }); + instanceData.state.push({ + type, + key: 'messages', + editable: false, + value: getLocaleMessageValue(composer.messages.value) + }); + { + instanceData.state.push({ + type, + key: 'datetimeFormats', + editable: false, + value: composer.datetimeFormats.value + }); + instanceData.state.push({ + type, + key: 'numberFormats', + editable: false, + value: composer.numberFormats.value + }); + } +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getLocaleMessageValue(messages) { + const value = {}; + Object.keys(messages).forEach((key) => { + const v = messages[key]; + if (isFunction(v) && 'source' in v) { + value[key] = getMessageFunctionDetails(v); + } + else if (isMessageAST(v) && v.loc && v.loc.source) { + value[key] = v.loc.source; + } + else if (isObject(v)) { + value[key] = getLocaleMessageValue(v); + } + else { + value[key] = v; + } + }); + return value; +} +const ESC = { + '<': '<', + '>': '>', + '"': '"', + '&': '&' +}; +function escape(s) { + return s.replace(/[<>"&]/g, escapeChar); +} +function escapeChar(a) { + return ESC[a] || a; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getMessageFunctionDetails(func) { + const argString = func.source ? `("${escape(func.source)}")` : `(?)`; + return { + _custom: { + type: 'function', + display: `ƒ ${argString}` + } + }; +} +function registerScope(payload, i18n) { + payload.rootNodes.push({ + id: 'global', + label: 'Global Scope' + }); + // prettier-ignore + const global = i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + for (const [keyInstance, instance] of i18n.__instances) { + // prettier-ignore + const composer = i18n.mode === 'composition' + ? instance + : instance.__composer; + if (global === composer) { + continue; + } + payload.rootNodes.push({ + id: composer.id.toString(), + label: `${getI18nScopeLable(keyInstance)} Scope` + }); + } +} +function getComponentInstance(nodeId, i18n) { + let instance = null; + if (nodeId !== 'global') { + for (const [component, composer] of i18n.__instances.entries()) { + if (composer.id.toString() === nodeId) { + instance = component; + break; + } + } + } + return instance; +} +function getComposer$1(nodeId, i18n) { + if (nodeId === 'global') { + return i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + } + else { + const instance = Array.from(i18n.__instances.values()).find(item => item.id.toString() === nodeId); + if (instance) { + return i18n.mode === 'composition' + ? instance + : instance.__composer; + } + else { + return null; + } + } +} +function inspectScope(payload, i18n +// eslint-disable-next-line @typescript-eslint/no-explicit-any +) { + const composer = getComposer$1(payload.nodeId, i18n); + if (composer) { + // TODO: + // eslint-disable-next-line @typescript-eslint/no-explicit-any + payload.state = makeScopeInspectState(composer); + } + return null; +} +function makeScopeInspectState(composer) { + const state = {}; + const localeType = 'Locale related info'; + const localeStates = [ + { + type: localeType, + key: 'locale', + editable: true, + value: composer.locale.value + }, + { + type: localeType, + key: 'fallbackLocale', + editable: true, + value: composer.fallbackLocale.value + }, + { + type: localeType, + key: 'availableLocales', + editable: false, + value: composer.availableLocales + }, + { + type: localeType, + key: 'inheritLocale', + editable: true, + value: composer.inheritLocale + } + ]; + state[localeType] = localeStates; + const localeMessagesType = 'Locale messages info'; + const localeMessagesStates = [ + { + type: localeMessagesType, + key: 'messages', + editable: false, + value: getLocaleMessageValue(composer.messages.value) + } + ]; + state[localeMessagesType] = localeMessagesStates; + { + const datetimeFormatsType = 'Datetime formats info'; + const datetimeFormatsStates = [ + { + type: datetimeFormatsType, + key: 'datetimeFormats', + editable: false, + value: composer.datetimeFormats.value + } + ]; + state[datetimeFormatsType] = datetimeFormatsStates; + const numberFormatsType = 'Datetime formats info'; + const numberFormatsStates = [ + { + type: numberFormatsType, + key: 'numberFormats', + editable: false, + value: composer.numberFormats.value + } + ]; + state[numberFormatsType] = numberFormatsStates; + } + return state; +} +function addTimelineEvent(event, payload) { + if (devtoolsApi) { + let groupId; + if (payload && 'groupId' in payload) { + groupId = payload.groupId; + delete payload.groupId; + } + devtoolsApi.addTimelineEvent({ + layerId: "vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */, + event: { + title: event, + groupId, + time: Date.now(), + meta: {}, + data: payload || {}, + logType: event === "compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */ + ? 'error' + : event === "fallback" /* VueDevToolsTimelineEvents.FALBACK */ || + event === "missing" /* VueDevToolsTimelineEvents.MISSING */ + ? 'warning' + : 'default' + } + }); + } +} +function editScope(payload, i18n) { + const composer = getComposer$1(payload.nodeId, i18n); + if (composer) { + const [field] = payload.path; + if (field === 'locale' && isString(payload.state.value)) { + composer.locale.value = payload.state.value; + } + else if (field === 'fallbackLocale' && + (isString(payload.state.value) || + isArray(payload.state.value) || + isObject(payload.state.value))) { + composer.fallbackLocale.value = payload.state.value; + } + else if (field === 'inheritLocale' && isBoolean(payload.state.value)) { + composer.inheritLocale = payload.state.value; + } + } +} + +/** + * Supports compatibility for legacy vue-i18n APIs + * This mixin is used when we use vue-i18n@v9.x or later + */ +function defineMixin(vuei18n, composer, i18n) { + return { + beforeCreate() { + const instance = getCurrentInstance(); + /* istanbul ignore if */ + if (!instance) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const options = this.$options; + if (options.i18n) { + const optionsI18n = options.i18n; + if (options.__i18n) { + optionsI18n.__i18n = options.__i18n; + } + optionsI18n.__root = composer; + if (this === this.$root) { + // merge option and gttach global + this.$i18n = mergeToGlobal(vuei18n, optionsI18n); + } + else { + optionsI18n.__injectWithOption = true; + optionsI18n.__extender = i18n.__vueI18nExtend; + // atttach local VueI18n instance + this.$i18n = createVueI18n(optionsI18n); + // extend VueI18n instance + const _vueI18n = this.$i18n; + if (_vueI18n.__extender) { + _vueI18n.__disposer = _vueI18n.__extender(this.$i18n); + } + } + } + else if (options.__i18n) { + if (this === this.$root) { + // merge option and gttach global + this.$i18n = mergeToGlobal(vuei18n, options); + } + else { + // atttach local VueI18n instance + this.$i18n = createVueI18n({ + __i18n: options.__i18n, + __injectWithOption: true, + __extender: i18n.__vueI18nExtend, + __root: composer + }); + // extend VueI18n instance + const _vueI18n = this.$i18n; + if (_vueI18n.__extender) { + _vueI18n.__disposer = _vueI18n.__extender(this.$i18n); + } + } + } + else { + // attach global VueI18n instance + this.$i18n = vuei18n; + } + if (options.__i18nGlobal) { + adjustI18nResources(composer, options, options); + } + // defines vue-i18n legacy APIs + this.$t = (...args) => this.$i18n.t(...args); + this.$rt = (...args) => this.$i18n.rt(...args); + this.$tc = (...args) => this.$i18n.tc(...args); + this.$te = (key, locale) => this.$i18n.te(key, locale); + this.$d = (...args) => this.$i18n.d(...args); + this.$n = (...args) => this.$i18n.n(...args); + this.$tm = (key) => this.$i18n.tm(key); + i18n.__setInstance(instance, this.$i18n); + }, + mounted() { + /* istanbul ignore if */ + if (this.$el && + this.$i18n) { + const _vueI18n = this.$i18n; + this.$el.__VUE_I18N__ = _vueI18n.__composer; + const emitter = (this.__v_emitter = + createEmitter()); + _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter); + emitter.on('*', addTimelineEvent); + } + }, + unmounted() { + const instance = getCurrentInstance(); + /* istanbul ignore if */ + if (!instance) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const _vueI18n = this.$i18n; + /* istanbul ignore if */ + if (this.$el && + this.$el.__VUE_I18N__) { + if (this.__v_emitter) { + this.__v_emitter.off('*', addTimelineEvent); + delete this.__v_emitter; + } + if (this.$i18n) { + _vueI18n.__disableEmitter && _vueI18n.__disableEmitter(); + delete this.$el.__VUE_I18N__; + } + } + delete this.$t; + delete this.$rt; + delete this.$tc; + delete this.$te; + delete this.$d; + delete this.$n; + delete this.$tm; + if (_vueI18n.__disposer) { + _vueI18n.__disposer(); + delete _vueI18n.__disposer; + delete _vueI18n.__extender; + } + i18n.__deleteInstance(instance); + delete this.$i18n; + } + }; +} +function mergeToGlobal(g, options) { + g.locale = options.locale || g.locale; + g.fallbackLocale = options.fallbackLocale || g.fallbackLocale; + g.missing = options.missing || g.missing; + g.silentTranslationWarn = + options.silentTranslationWarn || g.silentFallbackWarn; + g.silentFallbackWarn = options.silentFallbackWarn || g.silentFallbackWarn; + g.formatFallbackMessages = + options.formatFallbackMessages || g.formatFallbackMessages; + g.postTranslation = options.postTranslation || g.postTranslation; + g.warnHtmlInMessage = options.warnHtmlInMessage || g.warnHtmlInMessage; + g.escapeParameterHtml = options.escapeParameterHtml || g.escapeParameterHtml; + g.sync = options.sync || g.sync; + g.__composer[SetPluralRulesSymbol](options.pluralizationRules || g.pluralizationRules); + const messages = getLocaleMessages(g.locale, { + messages: options.messages, + __i18n: options.__i18n + }); + Object.keys(messages).forEach(locale => g.mergeLocaleMessage(locale, messages[locale])); + if (options.datetimeFormats) { + Object.keys(options.datetimeFormats).forEach(locale => g.mergeDateTimeFormat(locale, options.datetimeFormats[locale])); + } + if (options.numberFormats) { + Object.keys(options.numberFormats).forEach(locale => g.mergeNumberFormat(locale, options.numberFormats[locale])); + } + return g; +} + +/** + * Injection key for {@link useI18n} + * + * @remarks + * The global injection key for I18n instances with `useI18n`. this injection key is used in Web Components. + * Specify the i18n instance created by {@link createI18n} together with `provide` function. + * + * @VueI18nGeneral + */ +const I18nInjectionKey = +/* #__PURE__*/ makeSymbol('global-vue-i18n'); +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types +function createI18n(options = {}, VueI18nLegacy) { + // prettier-ignore + const __legacyMode = isBoolean(options.legacy) + ? options.legacy + : true; + // prettier-ignore + const __globalInjection = isBoolean(options.globalInjection) + ? options.globalInjection + : true; + // prettier-ignore + const __allowComposition = __legacyMode + ? !!options.allowComposition + : true; + const __instances = new Map(); + const [globalScope, __global] = createGlobal(options, __legacyMode); + const symbol = /* #__PURE__*/ makeSymbol('vue-i18n' ); + { + if (__legacyMode && __allowComposition && !false) { + warn(getWarnMessage(I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION)); + } + } + function __getInstance(component) { + return __instances.get(component) || null; + } + function __setInstance(component, instance) { + __instances.set(component, instance); + } + function __deleteInstance(component) { + __instances.delete(component); + } + { + const i18n = { + // mode + get mode() { + return __legacyMode + ? 'legacy' + : 'composition'; + }, + // allowComposition + get allowComposition() { + return __allowComposition; + }, + // install plugin + async install(app, ...options) { + { + app.__VUE_I18N__ = i18n; + } + // setup global provider + app.__VUE_I18N_SYMBOL__ = symbol; + app.provide(app.__VUE_I18N_SYMBOL__, i18n); + // set composer & vuei18n extend hook options from plugin options + if (isPlainObject(options[0])) { + const opts = options[0]; + i18n.__composerExtend = + opts.__composerExtend; + i18n.__vueI18nExtend = + opts.__vueI18nExtend; + } + // global method and properties injection for Composition API + let globalReleaseHandler = null; + if (!__legacyMode && __globalInjection) { + globalReleaseHandler = injectGlobalFields(app, i18n.global); + } + // install built-in components and directive + { + apply(app, i18n, ...options); + } + // setup mixin for Legacy API + if (__legacyMode) { + app.mixin(defineMixin(__global, __global.__composer, i18n)); + } + // release global scope + const unmountApp = app.unmount; + app.unmount = () => { + globalReleaseHandler && globalReleaseHandler(); + i18n.dispose(); + unmountApp(); + }; + // setup vue-devtools plugin + { + const ret = await enableDevTools(app, i18n); + if (!ret) { + throw createI18nError(I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN); + } + const emitter = createEmitter(); + if (__legacyMode) { + const _vueI18n = __global; + _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter); + } + else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = __global; + _composer[EnableEmitter] && _composer[EnableEmitter](emitter); + } + emitter.on('*', addTimelineEvent); + } + }, + // global accessor + get global() { + return __global; + }, + dispose() { + globalScope.stop(); + }, + // @internal + __instances, + // @internal + __getInstance, + // @internal + __setInstance, + // @internal + __deleteInstance + }; + return i18n; + } +} +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function useI18n(options = {}) { + const instance = getCurrentInstance(); + if (instance == null) { + throw createI18nError(I18nErrorCodes.MUST_BE_CALL_SETUP_TOP); + } + if (!instance.isCE && + instance.appContext.app != null && + !instance.appContext.app.__VUE_I18N_SYMBOL__) { + throw createI18nError(I18nErrorCodes.NOT_INSTALLED); + } + const i18n = getI18nInstance(instance); + const gl = getGlobalComposer(i18n); + const componentOptions = getComponentOptions(instance); + const scope = getScope(options, componentOptions); + { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (i18n.mode === 'legacy' && !options.__useComponent) { + if (!i18n.allowComposition) { + throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE); + } + return useI18nForLegacy(instance, scope, gl, options); + } + } + if (scope === 'global') { + adjustI18nResources(gl, options, componentOptions); + return gl; + } + if (scope === 'parent') { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let composer = getComposer(i18n, instance, options.__useComponent); + if (composer == null) { + { + warn(getWarnMessage(I18nWarnCodes.NOT_FOUND_PARENT_SCOPE)); + } + composer = gl; + } + return composer; + } + const i18nInternal = i18n; + let composer = i18nInternal.__getInstance(instance); + if (composer == null) { + const composerOptions = assign({}, options); + if ('__i18n' in componentOptions) { + composerOptions.__i18n = componentOptions.__i18n; + } + if (gl) { + composerOptions.__root = gl; + } + composer = createComposer(composerOptions); + if (i18nInternal.__composerExtend) { + composer[DisposeSymbol] = + i18nInternal.__composerExtend(composer); + } + setupLifeCycle(i18nInternal, instance, composer); + i18nInternal.__setInstance(instance, composer); + } + return composer; +} +/** + * Cast to VueI18n legacy compatible type + * + * @remarks + * This API is provided only with [vue-i18n-bridge](https://vue-i18n.intlify.dev/guide/migration/ways.html#what-is-vue-i18n-bridge). + * + * The purpose of this function is to convert an {@link I18n} instance created with {@link createI18n | createI18n(legacy: true)} into a `vue-i18n@v8.x` compatible instance of `new VueI18n` in a TypeScript environment. + * + * @param i18n - An instance of {@link I18n} + * @returns A i18n instance which is casted to {@link VueI18n} type + * + * @VueI18nTip + * :new: provided by **vue-i18n-bridge only** + * + * @VueI18nGeneral + */ +/* #__NO_SIDE_EFFECTS__ */ +const castToVueI18n = (i18n +// eslint-disable-next-line @typescript-eslint/no-explicit-any +) => { + if (!(__VUE_I18N_BRIDGE__ in i18n)) { + throw createI18nError(I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N); + } + return i18n; +}; +function createGlobal(options, legacyMode, VueI18nLegacy // eslint-disable-line @typescript-eslint/no-explicit-any +) { + const scope = effectScope(); + { + const obj = legacyMode + ? scope.run(() => createVueI18n(options)) + : scope.run(() => createComposer(options)); + if (obj == null) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + return [scope, obj]; + } +} +function getI18nInstance(instance) { + { + const i18n = inject(!instance.isCE + ? instance.appContext.app.__VUE_I18N_SYMBOL__ + : I18nInjectionKey); + /* istanbul ignore if */ + if (!i18n) { + throw createI18nError(!instance.isCE + ? I18nErrorCodes.UNEXPECTED_ERROR + : I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE); + } + return i18n; + } +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getScope(options, componentOptions) { + // prettier-ignore + return isEmptyObject(options) + ? ('__i18n' in componentOptions) + ? 'local' + : 'global' + : !options.useScope + ? 'local' + : options.useScope; +} +function getGlobalComposer(i18n) { + // prettier-ignore + return i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer + ; +} +function getComposer(i18n, target, useComponent = false) { + let composer = null; + const root = target.root; + let current = getParentComponentInstance(target, useComponent); + while (current != null) { + const i18nInternal = i18n; + if (i18n.mode === 'composition') { + composer = i18nInternal.__getInstance(current); + } + else { + { + const vueI18n = i18nInternal.__getInstance(current); + if (vueI18n != null) { + composer = vueI18n + .__composer; + if (useComponent && + composer && + !composer[InejctWithOptionSymbol] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + composer = null; + } + } + } + } + if (composer != null) { + break; + } + if (root === current) { + break; + } + current = current.parent; + } + return composer; +} +function getParentComponentInstance(target, useComponent = false) { + if (target == null) { + return null; + } + { + // if `useComponent: true` will be specified, we get lexical scope owner instance for use-case slots + return !useComponent + ? target.parent + : target.vnode.ctx || target.parent; // eslint-disable-line @typescript-eslint/no-explicit-any + } +} +function setupLifeCycle(i18n, target, composer) { + let emitter = null; + { + onMounted(() => { + // inject composer instance to DOM for intlify-devtools + if (target.vnode.el) { + target.vnode.el.__VUE_I18N__ = composer; + emitter = createEmitter(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = composer; + _composer[EnableEmitter] && _composer[EnableEmitter](emitter); + emitter.on('*', addTimelineEvent); + } + }, target); + onUnmounted(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = composer; + // remove composer instance from DOM for intlify-devtools + if (target.vnode.el && + target.vnode.el.__VUE_I18N__) { + emitter && emitter.off('*', addTimelineEvent); + _composer[DisableEmitter] && _composer[DisableEmitter](); + delete target.vnode.el.__VUE_I18N__; + } + i18n.__deleteInstance(target); + // dispose extended resources + const dispose = _composer[DisposeSymbol]; + if (dispose) { + dispose(); + delete _composer[DisposeSymbol]; + } + }, target); + } +} +function useI18nForLegacy(instance, scope, root, options = {} // eslint-disable-line @typescript-eslint/no-explicit-any +) { + const isLocalScope = scope === 'local'; + const _composer = shallowRef(null); + if (isLocalScope && + instance.proxy && + !(instance.proxy.$options.i18n || instance.proxy.$options.__i18n)) { + throw createI18nError(I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION); + } + const _inheritLocale = isBoolean(options.inheritLocale) + ? options.inheritLocale + : !isString(options.locale); + const _locale = ref( + // prettier-ignore + !isLocalScope || _inheritLocale + ? root.locale.value + : isString(options.locale) + ? options.locale + : DEFAULT_LOCALE); + const _fallbackLocale = ref( + // prettier-ignore + !isLocalScope || _inheritLocale + ? root.fallbackLocale.value + : isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale.value); + const _messages = ref(getLocaleMessages(_locale.value, options)); + // prettier-ignore + const _datetimeFormats = ref(isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : { [_locale.value]: {} }); + // prettier-ignore + const _numberFormats = ref(isPlainObject(options.numberFormats) + ? options.numberFormats + : { [_locale.value]: {} }); + // prettier-ignore + const _missingWarn = isLocalScope + ? root.missingWarn + : isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + // prettier-ignore + const _fallbackWarn = isLocalScope + ? root.fallbackWarn + : isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + // prettier-ignore + const _fallbackRoot = isLocalScope + ? root.fallbackRoot + : isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + // configure fall back to root + const _fallbackFormat = !!options.fallbackFormat; + // runtime missing + const _missing = isFunction(options.missing) ? options.missing : null; + // postTranslation handler + const _postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + // prettier-ignore + const _warnHtmlMessage = isLocalScope + ? root.warnHtmlMessage + : isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const _escapeParameter = !!options.escapeParameter; + // prettier-ignore + const _modifiers = isLocalScope + ? root.modifiers + : isPlainObject(options.modifiers) + ? options.modifiers + : {}; + // pluralRules + const _pluralRules = options.pluralRules || (isLocalScope && root.pluralRules); + // track reactivity + function trackReactivityValues() { + return [ + _locale.value, + _fallbackLocale.value, + _messages.value, + _datetimeFormats.value, + _numberFormats.value + ]; + } + // locale + const locale = computed({ + get: () => { + return _composer.value ? _composer.value.locale.value : _locale.value; + }, + set: val => { + if (_composer.value) { + _composer.value.locale.value = val; + } + _locale.value = val; + } + }); + // fallbackLocale + const fallbackLocale = computed({ + get: () => { + return _composer.value + ? _composer.value.fallbackLocale.value + : _fallbackLocale.value; + }, + set: val => { + if (_composer.value) { + _composer.value.fallbackLocale.value = val; + } + _fallbackLocale.value = val; + } + }); + // messages + const messages = computed(() => { + if (_composer.value) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return _composer.value.messages.value; + } + else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return _messages.value; + } + }); + const datetimeFormats = computed(() => _datetimeFormats.value); + const numberFormats = computed(() => _numberFormats.value); + function getPostTranslationHandler() { + return _composer.value + ? _composer.value.getPostTranslationHandler() + : _postTranslation; + } + function setPostTranslationHandler(handler) { + if (_composer.value) { + _composer.value.setPostTranslationHandler(handler); + } + } + function getMissingHandler() { + return _composer.value ? _composer.value.getMissingHandler() : _missing; + } + function setMissingHandler(handler) { + if (_composer.value) { + _composer.value.setMissingHandler(handler); + } + } + function warpWithDeps(fn) { + trackReactivityValues(); + return fn(); + } + function t(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.t, null, [...args])) + : warpWithDeps(() => ''); + } + function rt(...args) { + return _composer.value + ? Reflect.apply(_composer.value.rt, null, [...args]) + : ''; + } + function d(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.d, null, [...args])) + : warpWithDeps(() => ''); + } + function n(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.n, null, [...args])) + : warpWithDeps(() => ''); + } + function tm(key) { + return _composer.value ? _composer.value.tm(key) : {}; + } + function te(key, locale) { + return _composer.value ? _composer.value.te(key, locale) : false; + } + function getLocaleMessage(locale) { + return _composer.value ? _composer.value.getLocaleMessage(locale) : {}; + } + function setLocaleMessage(locale, message) { + if (_composer.value) { + _composer.value.setLocaleMessage(locale, message); + _messages.value[locale] = message; + } + } + function mergeLocaleMessage(locale, message) { + if (_composer.value) { + _composer.value.mergeLocaleMessage(locale, message); + } + } + function getDateTimeFormat(locale) { + return _composer.value ? _composer.value.getDateTimeFormat(locale) : {}; + } + function setDateTimeFormat(locale, format) { + if (_composer.value) { + _composer.value.setDateTimeFormat(locale, format); + _datetimeFormats.value[locale] = format; + } + } + function mergeDateTimeFormat(locale, format) { + if (_composer.value) { + _composer.value.mergeDateTimeFormat(locale, format); + } + } + function getNumberFormat(locale) { + return _composer.value ? _composer.value.getNumberFormat(locale) : {}; + } + function setNumberFormat(locale, format) { + if (_composer.value) { + _composer.value.setNumberFormat(locale, format); + _numberFormats.value[locale] = format; + } + } + function mergeNumberFormat(locale, format) { + if (_composer.value) { + _composer.value.mergeNumberFormat(locale, format); + } + } + const wrapper = { + get id() { + return _composer.value ? _composer.value.id : -1; + }, + locale, + fallbackLocale, + messages, + datetimeFormats, + numberFormats, + get inheritLocale() { + return _composer.value ? _composer.value.inheritLocale : _inheritLocale; + }, + set inheritLocale(val) { + if (_composer.value) { + _composer.value.inheritLocale = val; + } + }, + get availableLocales() { + return _composer.value + ? _composer.value.availableLocales + : Object.keys(_messages.value); + }, + get modifiers() { + return (_composer.value ? _composer.value.modifiers : _modifiers); + }, + get pluralRules() { + return (_composer.value ? _composer.value.pluralRules : _pluralRules); + }, + get isGlobal() { + return _composer.value ? _composer.value.isGlobal : false; + }, + get missingWarn() { + return _composer.value ? _composer.value.missingWarn : _missingWarn; + }, + set missingWarn(val) { + if (_composer.value) { + _composer.value.missingWarn = val; + } + }, + get fallbackWarn() { + return _composer.value ? _composer.value.fallbackWarn : _fallbackWarn; + }, + set fallbackWarn(val) { + if (_composer.value) { + _composer.value.missingWarn = val; + } + }, + get fallbackRoot() { + return _composer.value ? _composer.value.fallbackRoot : _fallbackRoot; + }, + set fallbackRoot(val) { + if (_composer.value) { + _composer.value.fallbackRoot = val; + } + }, + get fallbackFormat() { + return _composer.value ? _composer.value.fallbackFormat : _fallbackFormat; + }, + set fallbackFormat(val) { + if (_composer.value) { + _composer.value.fallbackFormat = val; + } + }, + get warnHtmlMessage() { + return _composer.value + ? _composer.value.warnHtmlMessage + : _warnHtmlMessage; + }, + set warnHtmlMessage(val) { + if (_composer.value) { + _composer.value.warnHtmlMessage = val; + } + }, + get escapeParameter() { + return _composer.value + ? _composer.value.escapeParameter + : _escapeParameter; + }, + set escapeParameter(val) { + if (_composer.value) { + _composer.value.escapeParameter = val; + } + }, + t, + getPostTranslationHandler, + setPostTranslationHandler, + getMissingHandler, + setMissingHandler, + rt, + d, + n, + tm, + te, + getLocaleMessage, + setLocaleMessage, + mergeLocaleMessage, + getDateTimeFormat, + setDateTimeFormat, + mergeDateTimeFormat, + getNumberFormat, + setNumberFormat, + mergeNumberFormat + }; + function sync(composer) { + composer.locale.value = _locale.value; + composer.fallbackLocale.value = _fallbackLocale.value; + Object.keys(_messages.value).forEach(locale => { + composer.mergeLocaleMessage(locale, _messages.value[locale]); + }); + Object.keys(_datetimeFormats.value).forEach(locale => { + composer.mergeDateTimeFormat(locale, _datetimeFormats.value[locale]); + }); + Object.keys(_numberFormats.value).forEach(locale => { + composer.mergeNumberFormat(locale, _numberFormats.value[locale]); + }); + composer.escapeParameter = _escapeParameter; + composer.fallbackFormat = _fallbackFormat; + composer.fallbackRoot = _fallbackRoot; + composer.fallbackWarn = _fallbackWarn; + composer.missingWarn = _missingWarn; + composer.warnHtmlMessage = _warnHtmlMessage; + } + onBeforeMount(() => { + if (instance.proxy == null || instance.proxy.$i18n == null) { + throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const composer = (_composer.value = instance.proxy.$i18n + .__composer); + if (scope === 'global') { + _locale.value = composer.locale.value; + _fallbackLocale.value = composer.fallbackLocale.value; + _messages.value = composer.messages.value; + _datetimeFormats.value = composer.datetimeFormats.value; + _numberFormats.value = composer.numberFormats.value; + } + else if (isLocalScope) { + sync(composer); + } + }); + return wrapper; +} +const globalExportProps = [ + 'locale', + 'fallbackLocale', + 'availableLocales' +]; +const globalExportMethods = ['t', 'rt', 'd', 'n', 'tm', 'te'] + ; +function injectGlobalFields(app, composer) { + const i18n = Object.create(null); + globalExportProps.forEach(prop => { + const desc = Object.getOwnPropertyDescriptor(composer, prop); + if (!desc) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const wrap = isRef(desc.value) // check computed props + ? { + get() { + return desc.value.value; + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + set(val) { + desc.value.value = val; + } + } + : { + get() { + return desc.get && desc.get(); + } + }; + Object.defineProperty(i18n, prop, wrap); + }); + app.config.globalProperties.$i18n = i18n; + globalExportMethods.forEach(method => { + const desc = Object.getOwnPropertyDescriptor(composer, method); + if (!desc || !desc.value) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + Object.defineProperty(app.config.globalProperties, `$${method}`, desc); + }); + const dispose = () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete app.config.globalProperties.$i18n; + globalExportMethods.forEach(method => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete app.config.globalProperties[`$${method}`]; + }); + }; + return dispose; +} + +// register message compiler at vue-i18n +{ + registerMessageCompiler(compile); +} +// register message resolver at vue-i18n +registerMessageResolver(resolveValue); +// register fallback locale at vue-i18n +registerLocaleFallbacker(fallbackWithLocaleChain); +// NOTE: experimental !! +{ + const target = getGlobalThis(); + target.__INTLIFY__ = true; + setDevToolsHook(target.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__); +} +{ + initDev(); +} + +export { DatetimeFormat, I18nD, I18nInjectionKey, I18nN, I18nT, NumberFormat, Translation, VERSION, castToVueI18n, createI18n, useI18n, vTDirective }; diff --git a/node_modules/vue-i18n/dist/vue-i18n.esm-browser.prod.js b/node_modules/vue-i18n/dist/vue-i18n.esm-browser.prod.js new file mode 100644 index 0000000..af66623 --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.esm-browser.prod.js @@ -0,0 +1,6 @@ +/*! + * vue-i18n v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +import{createVNode,Text,computed,watch,getCurrentInstance,ref,shallowRef,Fragment,defineComponent,h,effectScope,inject,onMounted,onUnmounted,onBeforeMount,isRef}from"vue";function warn(e,t){"undefined"!=typeof console&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}const inBrowser="undefined"!=typeof window,makeSymbol=(e,t=!1)=>t?Symbol.for(e):Symbol(e),generateFormatCacheKey=(e,t,r)=>friendlyJSONstringify({l:e,k:t,s:r}),friendlyJSONstringify=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),isNumber=e=>"number"==typeof e&&isFinite(e),isDate=e=>"[object Date]"===toTypeString(e),isRegExp=e=>"[object RegExp]"===toTypeString(e),isEmptyObject=e=>isPlainObject(e)&&0===Object.keys(e).length,assign=Object.assign,_create=Object.create,create=(e=null)=>_create(e);function escapeHtml(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/").replace(/=/g,"=")}function escapeAttributeValue(e){return e.replace(/&(?![a-zA-Z0-9#]{2,6};)/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")}function sanitizeTranslatedHtml(e){e=(e=e.replace(/(\w+)\s*=\s*"([^"]*)"/g,((e,t,r)=>`${t}="${escapeAttributeValue(r)}"`))).replace(/(\w+)\s*=\s*'([^']*)'/g,((e,t,r)=>`${t}='${escapeAttributeValue(r)}'`));/\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi.test(e)&&(e=e.replace(/(\s+)(on)(\w+\s*=)/gi,"$1on$3"));return[/(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi,/(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi].forEach((t=>{e=e.replace(t,"$1javascript:")})),e}const hasOwnProperty=Object.prototype.hasOwnProperty;function hasOwn(e,t){return hasOwnProperty.call(e,t)}const isArray=Array.isArray,isFunction=e=>"function"==typeof e,isString=e=>"string"==typeof e,isBoolean=e=>"boolean"==typeof e,isObject=e=>null!==e&&"object"==typeof e,isPromise=e=>isObject(e)&&isFunction(e.then)&&isFunction(e.catch),objectToString=Object.prototype.toString,toTypeString=e=>objectToString.call(e),isPlainObject=e=>{if(!isObject(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t.constructor===Object},toDisplayString=e=>null==e?"":isArray(e)||isPlainObject(e)&&e.toString===objectToString?JSON.stringify(e,null,2):String(e);function join(e,t=""){return e.reduce(((e,r,n)=>0===n?e+r:e+t+r),"")}function incrementer(e){let t=e;return()=>++t}const isNotObjectOrIsArray=e=>!isObject(e)||isArray(e);function deepCopy(e,t){if(isNotObjectOrIsArray(e)||isNotObjectOrIsArray(t))throw new Error("Invalid value");const r=[{src:e,des:t}];for(;r.length;){const{src:e,des:t}=r.pop();Object.keys(e).forEach((n=>{"__proto__"!==n&&(isObject(e[n])&&!isObject(t[n])&&(t[n]=Array.isArray(e[n])?[]:create()),isNotObjectOrIsArray(t[n])||isNotObjectOrIsArray(e[n])?t[n]=e[n]:r.push({src:e[n],des:t[n]}))}))}}function createPosition(e,t,r){return{line:e,column:t,offset:r}}function createLocation(e,t,r){const n={start:e,end:t};return null!=r&&(n.source=r),n}const CompileWarnCodes={USE_MODULO_SYNTAX:1,__EXTEND_POINT__:2};function createCompileWarn(e,t,...r){const n={message:String(e),code:e};return t&&(n.location=t),n}const CompileErrorCodes={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16,__EXTEND_POINT__:17};function createCompileError(e,t,r={}){const{domain:n,messages:a,args:o}=r,s=new SyntaxError(String(e));return s.code=e,t&&(s.location=t),s.domain=n,s}function defaultOnError(e){throw e}const CHAR_SP=" ",CHAR_CR="\r",CHAR_LF="\n",CHAR_LS=String.fromCharCode(8232),CHAR_PS=String.fromCharCode(8233);function createScanner(e){const t=e;let r=0,n=1,a=1,o=0;const s=e=>t[e]===CHAR_CR&&t[e+1]===CHAR_LF,l=e=>t[e]===CHAR_PS,i=e=>t[e]===CHAR_LS,c=e=>s(e)||(e=>t[e]===CHAR_LF)(e)||l(e)||i(e),u=e=>s(e)||l(e)||i(e)?CHAR_LF:t[e];function m(){return o=0,c(r)&&(n++,a=0),s(r)&&r++,r++,a++,t[r]}return{index:()=>r,line:()=>n,column:()=>a,peekOffset:()=>o,charAt:u,currentChar:()=>u(r),currentPeek:()=>u(r+o),next:m,peek:function(){return s(r+o)&&o++,o++,t[r+o]},reset:function(){r=0,n=1,a=1,o=0},resetPeek:function(e=0){o=e},skipToPeek:function(){const e=r+o;for(;e!==r;)m();o=0}}}const EOF=void 0,DOT=".",LITERAL_DELIMITER="'",ERROR_DOMAIN$1="tokenizer";function createTokenizer(e,t={}){const r=!1!==t.location,n=createScanner(e),a=()=>n.index(),o=()=>createPosition(n.line(),n.column(),n.index()),s=o(),l=a(),i={currentType:14,offset:l,startLoc:s,endLoc:s,lastType:14,lastOffset:l,lastStartLoc:s,lastEndLoc:s,braceNest:0,inLinked:!1,text:""},c=()=>i,{onError:u}=t;function m(e,t,n){e.endLoc=o(),e.currentType=t;const a={type:t};return r&&(a.loc=createLocation(e.startLoc,e.endLoc)),null!=n&&(a.value=n),a}const f=e=>m(e,14);function p(e,t){return e.currentChar()===t?(e.next(),t):(CompileErrorCodes.EXPECTED_TOKEN,o(),"")}function _(e){let t="";for(;e.currentPeek()===CHAR_SP||e.currentPeek()===CHAR_LF;)t+=e.currentPeek(),e.peek();return t}function g(e){const t=_(e);return e.skipToPeek(),t}function d(e){if(e===EOF)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function E(e,t){const{currentType:r}=t;if(2!==r)return!1;_(e);const n=function(e){if(e===EOF)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),n}function b(e){_(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function C(e,t=!0){const r=(t=!1,n="",a=!1)=>{const o=e.currentPeek();return"{"===o?"%"!==n&&t:"@"!==o&&o?"%"===o?(e.peek(),r(t,"%",!0)):"|"===o?!("%"!==n&&!a)||!(n===CHAR_SP||n===CHAR_LF):o===CHAR_SP?(e.peek(),r(!0,CHAR_SP,a)):o!==CHAR_LF||(e.peek(),r(!0,CHAR_LF,a)):"%"===n||t},n=r();return t&&e.resetPeek(),n}function O(e,t){const r=e.currentChar();return r===EOF?EOF:t(r)?(e.next(),r):null}function T(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t}function L(e){return O(e,T)}function N(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t||45===t}function S(e){return O(e,N)}function v(e){const t=e.charCodeAt(0);return t>=48&&t<=57}function h(e){return O(e,v)}function k(e){const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function P(e){return O(e,k)}function I(e){let t="",r="";for(;t=h(e);)r+=t;return r}function A(e){let t="";for(;;){const r=e.currentChar();if("{"===r||"}"===r||"@"===r||"|"===r||!r)break;if("%"===r){if(!C(e))break;t+=r,e.next()}else if(r===CHAR_SP||r===CHAR_LF)if(C(e))t+=r,e.next();else{if(b(e))break;t+=r,e.next()}else t+=r,e.next()}return t}function y(e){return e!==LITERAL_DELIMITER&&e!==CHAR_LF}function F(e){const t=e.currentChar();switch(t){case"\\":case"'":return e.next(),`\\${t}`;case"u":return R(e,t,4);case"U":return R(e,t,6);default:return CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE,o(),""}}function R(e,t,r){p(e,t);let n="";for(let a=0;a=1&&(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER,o()),e.next(),r=m(t,2,"{"),g(e),t.braceNest++,r;case"}":return t.braceNest>0&&2===t.currentType&&(CompileErrorCodes.EMPTY_PLACEHOLDER,o()),e.next(),r=m(t,3,"}"),t.braceNest--,t.braceNest>0&&g(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),r;case"@":return t.braceNest>0&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,o()),r=j(e,t)||f(t),t.braceNest=0,r;default:{let n=!0,a=!0,s=!0;if(b(e))return t.braceNest>0&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,o()),r=m(t,1,D(e)),t.braceNest=0,t.inLinked=!1,r;if(t.braceNest>0&&(5===t.currentType||6===t.currentType||7===t.currentType))return CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,o(),t.braceNest=0,w(e,t);if(n=function(e,t){const{currentType:r}=t;if(2!==r)return!1;_(e);const n=d(e.currentPeek());return e.resetPeek(),n}(e,t))return r=m(t,5,function(e){g(e);let t="",r="";for(;t=S(e);)r+=t;return e.currentChar()===EOF&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,o()),r}(e)),g(e),r;if(a=E(e,t))return r=m(t,6,function(e){g(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${I(e)}`):t+=I(e),e.currentChar()===EOF&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,o()),t}(e)),g(e),r;if(s=function(e,t){const{currentType:r}=t;if(2!==r)return!1;_(e);const n=e.currentPeek()===LITERAL_DELIMITER;return e.resetPeek(),n}(e,t))return r=m(t,7,function(e){g(e),p(e,"'");let t="",r="";for(;t=O(e,y);)r+="\\"===t?F(e):t;const n=e.currentChar();return n===CHAR_LF||n===EOF?(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,o(),n===CHAR_LF&&(e.next(),p(e,"'")),r):(p(e,"'"),r)}(e)),g(e),r;if(!n&&!a&&!s)return r=m(t,13,function(e){g(e);let t="",r="";for(;t=O(e,M);)r+=t;return r}(e)),CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER,o(),r.value,g(e),r;break}}return r}function j(e,t){const{currentType:r}=t;let n=null;const a=e.currentChar();switch(8!==r&&9!==r&&12!==r&&10!==r||a!==CHAR_LF&&a!==CHAR_SP||(CompileErrorCodes.INVALID_LINKED_FORMAT,o()),a){case"@":return e.next(),n=m(t,8,"@"),t.inLinked=!0,n;case".":return g(e),e.next(),m(t,9,".");case":":return g(e),e.next(),m(t,10,":");default:return b(e)?(n=m(t,1,D(e)),t.braceNest=0,t.inLinked=!1,n):function(e,t){const{currentType:r}=t;if(8!==r)return!1;_(e);const n="."===e.currentPeek();return e.resetPeek(),n}(e,t)||function(e,t){const{currentType:r}=t;if(8!==r&&12!==r)return!1;_(e);const n=":"===e.currentPeek();return e.resetPeek(),n}(e,t)?(g(e),j(e,t)):function(e,t){const{currentType:r}=t;if(9!==r)return!1;_(e);const n=d(e.currentPeek());return e.resetPeek(),n}(e,t)?(g(e),m(t,12,function(e){let t="",r="";for(;t=L(e);)r+=t;return r}(e))):function(e,t){const{currentType:r}=t;if(10!==r)return!1;const n=()=>{const t=e.currentPeek();return"{"===t?d(e.peek()):!("@"===t||"%"===t||"|"===t||":"===t||"."===t||t===CHAR_SP||!t)&&(t===CHAR_LF?(e.peek(),n()):C(e,!1))},a=n();return e.resetPeek(),a}(e,t)?(g(e),"{"===a?x(e,t)||n:m(t,11,function(e){const t=r=>{const n=e.currentChar();return"{"!==n&&"%"!==n&&"@"!==n&&"|"!==n&&"("!==n&&")"!==n&&n?n===CHAR_SP?r:(r+=n,e.next(),t(r)):r};return t("")}(e))):(8===r&&(CompileErrorCodes.INVALID_LINKED_FORMAT,o()),t.braceNest=0,t.inLinked=!1,w(e,t))}}function w(e,t){let r={type:14};if(t.braceNest>0)return x(e,t)||f(t);if(t.inLinked)return j(e,t)||f(t);switch(e.currentChar()){case"{":return x(e,t)||f(t);case"}":return CompileErrorCodes.UNBALANCED_CLOSING_BRACE,o(),e.next(),m(t,3,"}");case"@":return j(e,t)||f(t);default:{if(b(e))return r=m(t,1,D(e)),t.braceNest=0,t.inLinked=!1,r;const{isModulo:n,hasSpace:a}=function(e){const t=_(e),r="%"===e.currentPeek()&&"{"===e.peek();return e.resetPeek(),{isModulo:r,hasSpace:t.length>0}}(e);if(n)return a?m(t,0,A(e)):m(t,4,function(e){g(e);const t=e.currentChar();return"%"!==t&&(CompileErrorCodes.EXPECTED_TOKEN,o()),e.next(),"%"}(e));if(C(e))return m(t,0,A(e));break}}return r}return{nextToken:function(){const{currentType:e,offset:t,startLoc:r,endLoc:s}=i;return i.lastType=e,i.lastOffset=t,i.lastStartLoc=r,i.lastEndLoc=s,i.offset=a(),i.startLoc=o(),n.currentChar()===EOF?m(i,14):w(n,i)},currentOffset:a,currentPosition:o,context:c}}const ERROR_DOMAIN="parser",KNOWN_ESCAPES=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function fromEscapeSequence(e,t,r){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const e=parseInt(t||r,16);return e<=55295||e>=57344?String.fromCodePoint(e):"�"}}}function createParser(e={}){const t=!1!==e.location,{onError:r,onWarn:n}=e;function a(e,r,n){const a={type:e};return t&&(a.start=r,a.end=r,a.loc={start:n,end:n}),a}function o(e,r,n,a){a&&(e.type=a),t&&(e.end=r,e.loc&&(e.loc.end=n))}function s(e,t){const r=e.context(),n=a(3,r.offset,r.startLoc);return n.value=t,o(n,e.currentOffset(),e.currentPosition()),n}function l(e,t){const r=e.context(),{lastOffset:n,lastStartLoc:s}=r,l=a(5,n,s);return l.index=parseInt(t,10),e.nextToken(),o(l,e.currentOffset(),e.currentPosition()),l}function i(e,t,r){const n=e.context(),{lastOffset:s,lastStartLoc:l}=n,i=a(4,s,l);return i.key=t,!0===r&&(i.modulo=!0),e.nextToken(),o(i,e.currentOffset(),e.currentPosition()),i}function c(e,t){const r=e.context(),{lastOffset:n,lastStartLoc:s}=r,l=a(9,n,s);return l.value=t.replace(KNOWN_ESCAPES,fromEscapeSequence),e.nextToken(),o(l,e.currentOffset(),e.currentPosition()),l}function u(e){const t=e.context(),r=a(6,t.offset,t.startLoc);let n=e.nextToken();if(9===n.type){const t=function(e){const t=e.nextToken(),r=e.context(),{lastOffset:n,lastStartLoc:s}=r,l=a(8,n,s);return 12!==t.type?(CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER,r.lastStartLoc,l.value="",o(l,n,s),{nextConsumeToken:t,node:l}):(null==t.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,r.lastStartLoc,getTokenCaption(t)),l.value=t.value||"",o(l,e.currentOffset(),e.currentPosition()),{node:l})}(e);r.modifier=t.node,n=t.nextConsumeToken||e.nextToken()}switch(10!==n.type&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(n)),n=e.nextToken(),2===n.type&&(n=e.nextToken()),n.type){case 11:null==n.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(n)),r.key=function(e,t){const r=e.context(),n=a(7,r.offset,r.startLoc);return n.value=t,o(n,e.currentOffset(),e.currentPosition()),n}(e,n.value||"");break;case 5:null==n.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(n)),r.key=i(e,n.value||"");break;case 6:null==n.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(n)),r.key=l(e,n.value||"");break;case 7:null==n.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(n)),r.key=c(e,n.value||"");break;default:{CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const s=e.context(),l=a(7,s.offset,s.startLoc);return l.value="",o(l,s.offset,s.startLoc),r.key=l,o(r,s.offset,s.startLoc),{nextConsumeToken:n,node:r}}}return o(r,e.currentOffset(),e.currentPosition()),{node:r}}function m(e){const t=e.context(),r=a(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);r.items=[];let n=null,m=null;do{const a=n||e.nextToken();switch(n=null,a.type){case 0:null==a.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(a)),r.items.push(s(e,a.value||""));break;case 6:null==a.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(a)),r.items.push(l(e,a.value||""));break;case 4:m=!0;break;case 5:null==a.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(a)),r.items.push(i(e,a.value||"",!!m)),m&&(CompileWarnCodes.USE_MODULO_SYNTAX,t.lastStartLoc,getTokenCaption(a),m=null);break;case 7:null==a.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(a)),r.items.push(c(e,a.value||""));break;case 8:{const t=u(e);r.items.push(t.node),n=t.nextConsumeToken||null;break}}}while(14!==t.currentType&&1!==t.currentType);return o(r,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),r}function f(e){const t=e.context(),{offset:r,startLoc:n}=t,s=m(e);return 14===t.currentType?s:function(e,t,r,n){const s=e.context();let l=0===n.items.length;const i=a(1,t,r);i.cases=[],i.cases.push(n);do{const t=m(e);l||(l=0===t.items.length),i.cases.push(t)}while(14!==s.currentType);return o(i,e.currentOffset(),e.currentPosition()),i}(e,r,n,s)}return{parse:function(r){const n=createTokenizer(r,assign({},e)),s=n.context(),l=a(0,s.offset,s.startLoc);return t&&l.loc&&(l.loc.source=r),l.body=f(n),e.onCacheKey&&(l.cacheKey=e.onCacheKey(r)),14!==s.currentType&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,s.lastStartLoc,r[s.offset]),o(l,n.currentOffset(),n.currentPosition()),l}}}function getTokenCaption(e){if(14===e.type)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function createTransformer(e,t={}){const r={ast:e,helpers:new Set};return{context:()=>r,helper:e=>(r.helpers.add(e),e)}}function traverseNodes(e,t){for(let r=0;roptimizeMessageNode(e))),e}function optimizeMessageNode(e){if(1===e.items.length){const t=e.items[0];3!==t.type&&9!==t.type||(e.static=t.value,delete t.value)}else{const t=[];for(let r=0;rl,push:i,indent:function(e=!0){const t=++l.indentLevel;e&&c(t)},deindent:function(e=!0){const t=--l.indentLevel;e&&c(t)},newline:function(){c(l.indentLevel)},helper:e=>`_${e}`,needIndent:()=>l.needIndent}}function generateLinkedNode(e,t){const{helper:r}=e;e.push(`${r("linked")}(`),generateNode(e,t.key),t.modifier?(e.push(", "),generateNode(e,t.modifier),e.push(", _type")):e.push(", undefined, _type"),e.push(")")}function generateMessageNode(e,t){const{helper:r,needIndent:n}=e;e.push(`${r("normalize")}([`),e.indent(n());const a=t.items.length;for(let o=0;o1){e.push(`${r("plural")}([`),e.indent(n());const a=t.cases.length;for(let r=0;r{const r=isString(t.mode)?t.mode:"normal",n=isString(t.filename)?t.filename:"message.intl",a=!!t.sourceMap,o=null!=t.breakLineCode?t.breakLineCode:"arrow"===r?";":"\n",s=t.needIndent?t.needIndent:"arrow"!==r,l=e.helpers||[],i=createCodeGenerator(e,{mode:r,filename:n,sourceMap:a,breakLineCode:o,needIndent:s});i.push("normal"===r?"function __msg__ (ctx) {":"(ctx) => {"),i.indent(s),l.length>0&&(i.push(`const { ${join(l.map((e=>`${e}: _${e}`)),", ")} } = ctx`),i.newline()),i.push("return "),generateNode(i,e),i.deindent(s),i.push("}"),delete e.helpers;const{code:c,map:u}=i.context();return{ast:e,code:c,map:u?u.toJSON():void 0}};function baseCompile$1(e,t={}){const r=assign({},t),n=!!r.jit,a=!!r.minify,o=null==r.optimize||r.optimize,s=createParser(r).parse(e);return n?(o&&optimize(s),a&&minify(s),{ast:s,code:""}):(transform(s,r),generate(s,r))}function isMessageAST(e){return isObject(e)&&0===resolveType(e)&&(hasOwn(e,"b")||hasOwn(e,"body"))}const PROPS_BODY=["b","body"];function resolveBody(e){return resolveProps(e,PROPS_BODY)}const PROPS_CASES=["c","cases"];function resolveCases(e){return resolveProps(e,PROPS_CASES,[])}const PROPS_STATIC=["s","static"];function resolveStatic(e){return resolveProps(e,PROPS_STATIC)}const PROPS_ITEMS=["i","items"];function resolveItems(e){return resolveProps(e,PROPS_ITEMS,[])}const PROPS_TYPE=["t","type"];function resolveType(e){return resolveProps(e,PROPS_TYPE)}const PROPS_VALUE=["v","value"];function resolveValue$1(e,t){const r=resolveProps(e,PROPS_VALUE);if(null!=r)return r;throw createUnhandleNodeError(t)}const PROPS_MODIFIER=["m","modifier"];function resolveLinkedModifier(e){return resolveProps(e,PROPS_MODIFIER)}const PROPS_KEY=["k","key"];function resolveLinkedKey(e){const t=resolveProps(e,PROPS_KEY);if(t)return t;throw createUnhandleNodeError(6)}function resolveProps(e,t,r){for(let n=0;n{void 0===n?n=a:n+=a},f[1]=()=>{void 0!==n&&(t.push(n),n=void 0)},f[2]=()=>{f[0](),m++},f[3]=()=>{if(m>0)m--,u=4,f[0]();else{if(m=0,void 0===n)return!1;if(n=formatSubPath(n),!1===n)return!1;f[1]()}};null!==u;)if(c++,r=e[c],"\\"!==r||!p()){if(o=getPathCharType(r),i=pathStateMachine[u],s=i[o]||i.l||8,8===s)return;if(u=s[0],void 0!==s[1]&&(l=f[s[1]],l&&(a=r,!1===l())))return;if(7===u)return t}}const cache=new Map;function resolveWithKeyValue(e,t){return isObject(e)?e[t]:null}function resolveValue(e,t){if(!isObject(e))return null;let r=cache.get(t);if(r||(r=parse(t),r&&cache.set(t,r)),!r)return null;const n=r.length;let a=e,o=0;for(;oe,DEFAULT_MESSAGE=e=>"",DEFAULT_MESSAGE_DATA_TYPE="text",DEFAULT_NORMALIZE=e=>0===e.length?"":join(e),DEFAULT_INTERPOLATE=toDisplayString;function pluralDefault(e,t){return e=Math.abs(e),2===t?e?e>1?1:0:1:e?Math.min(e,2):0}function getPluralIndex(e){const t=isNumber(e.pluralIndex)?e.pluralIndex:-1;return e.named&&(isNumber(e.named.count)||isNumber(e.named.n))?isNumber(e.named.count)?e.named.count:isNumber(e.named.n)?e.named.n:t:t}function normalizeNamed(e,t){t.count||(t.count=e),t.n||(t.n=e)}function createMessageContext(e={}){const t=e.locale,r=getPluralIndex(e),n=isObject(e.pluralRules)&&isString(t)&&isFunction(e.pluralRules[t])?e.pluralRules[t]:pluralDefault,a=isObject(e.pluralRules)&&isString(t)&&isFunction(e.pluralRules[t])?pluralDefault:void 0,o=e.list||[],s=e.named||create();isNumber(e.pluralIndex)&&normalizeNamed(r,s);function l(t){const r=isFunction(e.messages)?e.messages(t):!!isObject(e.messages)&&e.messages[t];return r||(e.parent?e.parent.message(t):DEFAULT_MESSAGE)}const i=isPlainObject(e.processor)&&isFunction(e.processor.normalize)?e.processor.normalize:DEFAULT_NORMALIZE,c=isPlainObject(e.processor)&&isFunction(e.processor.interpolate)?e.processor.interpolate:DEFAULT_INTERPOLATE,u={list:e=>o[e],named:e=>s[e],plural:e=>e[n(r,e.length,a)],linked:(t,...r)=>{const[n,a]=r;let o="text",s="";1===r.length?isObject(n)?(s=n.modifier||s,o=n.type||o):isString(n)&&(s=n||s):2===r.length&&(isString(n)&&(s=n||s),isString(a)&&(o=a||o));const i=l(t)(u),c="vnode"===o&&isArray(i)&&s?i[0]:i;return s?(m=s,e.modifiers?e.modifiers[m]:DEFAULT_MODIFIER)(c,o):c;var m},message:l,type:isPlainObject(e.processor)&&isString(e.processor.type)?e.processor.type:DEFAULT_MESSAGE_DATA_TYPE,interpolate:c,normalize:i,values:assign(create(),o,s)};return u}const code$1=CompileErrorCodes.__EXTEND_POINT__,inc$1=incrementer(code$1),CoreErrorCodes={INVALID_ARGUMENT:code$1,INVALID_DATE_ARGUMENT:inc$1(),INVALID_ISO_DATE_ARGUMENT:inc$1(),NOT_SUPPORT_NON_STRING_MESSAGE:inc$1(),NOT_SUPPORT_LOCALE_PROMISE_VALUE:inc$1(),NOT_SUPPORT_LOCALE_ASYNC_FUNCTION:inc$1(),NOT_SUPPORT_LOCALE_TYPE:inc$1(),__EXTEND_POINT__:inc$1()};function getLocale(e,t){return null!=t.locale?resolveLocale(t.locale):resolveLocale(e.locale)}let _resolveLocale;function resolveLocale(e){if(isString(e))return e;if(isFunction(e)){if(e.resolvedOnce&&null!=_resolveLocale)return _resolveLocale;if("Function"===e.constructor.name){const t=e();if(isPromise(t))throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE);return _resolveLocale=t}throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION)}throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE)}function fallbackWithSimple(e,t,r){return[...new Set([r,...isArray(t)?t:isObject(t)?Object.keys(t):isString(t)?[t]:[r]])]}function fallbackWithLocaleChain(e,t,r){const n=isString(r)?r:DEFAULT_LOCALE,a=e;a.__localeChainCache||(a.__localeChainCache=new Map);let o=a.__localeChainCache.get(n);if(!o){o=[];let e=[r];for(;isArray(e);)e=appendBlockToChain(o,e,t);const s=isArray(t)||!isPlainObject(t)?t:t.default?t.default:null;e=isString(s)?[s]:s,isArray(e)&&appendBlockToChain(o,e,!1),a.__localeChainCache.set(n,o)}return o}function appendBlockToChain(e,t,r){let n=!0;for(let a=0;a`${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;function getDefaultLinkedModifiers(){return{upper:(e,t)=>"text"===t&&isString(e)?e.toUpperCase():"vnode"===t&&isObject(e)&&"__v_isVNode"in e?e.children.toUpperCase():e,lower:(e,t)=>"text"===t&&isString(e)?e.toLowerCase():"vnode"===t&&isObject(e)&&"__v_isVNode"in e?e.children.toLowerCase():e,capitalize:(e,t)=>"text"===t&&isString(e)?capitalize(e):"vnode"===t&&isObject(e)&&"__v_isVNode"in e?capitalize(e.children):e}}let _compiler,_resolver,_fallbacker;function registerMessageCompiler(e){_compiler=e}function registerMessageResolver(e){_resolver=e}function registerLocaleFallbacker(e){_fallbacker=e}const setAdditionalMeta=e=>{};let _fallbackContext=null;const setFallbackContext=e=>{_fallbackContext=e},getFallbackContext=()=>_fallbackContext;let _cid=0;function createCoreContext(e={}){const t=isFunction(e.onWarn)?e.onWarn:warn,r=isString(e.version)?e.version:VERSION$1,n=isString(e.locale)||isFunction(e.locale)?e.locale:DEFAULT_LOCALE,a=isFunction(n)?DEFAULT_LOCALE:n,o=isArray(e.fallbackLocale)||isPlainObject(e.fallbackLocale)||isString(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:a,s=isPlainObject(e.messages)?e.messages:createResources(a),l=isPlainObject(e.datetimeFormats)?e.datetimeFormats:createResources(a),i=isPlainObject(e.numberFormats)?e.numberFormats:createResources(a),c=assign(create(),e.modifiers,getDefaultLinkedModifiers()),u=e.pluralRules||create(),m=isFunction(e.missing)?e.missing:null,f=!isBoolean(e.missingWarn)&&!isRegExp(e.missingWarn)||e.missingWarn,p=!isBoolean(e.fallbackWarn)&&!isRegExp(e.fallbackWarn)||e.fallbackWarn,_=!!e.fallbackFormat,g=!!e.unresolving,d=isFunction(e.postTranslation)?e.postTranslation:null,E=isPlainObject(e.processor)?e.processor:null,b=!isBoolean(e.warnHtmlMessage)||e.warnHtmlMessage,C=!!e.escapeParameter,O=isFunction(e.messageCompiler)?e.messageCompiler:_compiler,T=isFunction(e.messageResolver)?e.messageResolver:_resolver||resolveWithKeyValue,L=isFunction(e.localeFallbacker)?e.localeFallbacker:_fallbacker||fallbackWithSimple,N=isObject(e.fallbackContext)?e.fallbackContext:void 0,S=e,v=isObject(S.__datetimeFormatters)?S.__datetimeFormatters:new Map,h=isObject(S.__numberFormatters)?S.__numberFormatters:new Map,k=isObject(S.__meta)?S.__meta:{};_cid++;const P={version:r,cid:_cid,locale:n,fallbackLocale:o,messages:s,modifiers:c,pluralRules:u,missing:m,missingWarn:f,fallbackWarn:p,fallbackFormat:_,unresolving:g,postTranslation:d,processor:E,warnHtmlMessage:b,escapeParameter:C,messageCompiler:O,messageResolver:T,localeFallbacker:L,fallbackContext:N,onWarn:t,__meta:k};return P.datetimeFormats=l,P.numberFormats=i,P.__datetimeFormatters=v,P.__numberFormatters=h,P}const createResources=e=>({[e]:create()});function handleMissing(e,t,r,n,a){const{missing:o,onWarn:s}=e;if(null!==o){const n=o(e,r,t,a);return isString(n)?n:t}return t}function updateFallbackLocale(e,t,r){e.__localeChainCache=new Map,e.localeFallbacker(e,r,t)}function isAlmostSameLocale(e,t){return e!==t&&e.split("-")[0]===t.split("-")[0]}function isImplicitFallback(e,t){const r=t.indexOf(e);if(-1===r)return!1;for(let n=r+1;nformatParts(t,e)}function formatParts(e,t){const r=resolveBody(t);if(null==r)throw createUnhandleNodeError(0);if(1===resolveType(r)){const t=resolveCases(r);return e.plural(t.reduce(((t,r)=>[...t,formatMessageParts(e,r)]),[]))}return formatMessageParts(e,r)}function formatMessageParts(e,t){const r=resolveStatic(t);if(null!=r)return"text"===e.type?r:e.normalize([r]);{const r=resolveItems(t).reduce(((t,r)=>[...t,formatMessagePart(e,r)]),[]);return e.normalize(r)}}function formatMessagePart(e,t){const r=resolveType(t);switch(r){case 3:case 9:case 7:case 8:return resolveValue$1(t,r);case 4:{const n=t;if(hasOwn(n,"k")&&n.k)return e.interpolate(e.named(n.k));if(hasOwn(n,"key")&&n.key)return e.interpolate(e.named(n.key));throw createUnhandleNodeError(r)}case 5:{const n=t;if(hasOwn(n,"i")&&isNumber(n.i))return e.interpolate(e.list(n.i));if(hasOwn(n,"index")&&isNumber(n.index))return e.interpolate(e.list(n.index));throw createUnhandleNodeError(r)}case 6:{const r=t,n=resolveLinkedModifier(r),a=resolveLinkedKey(r);return e.linked(formatMessagePart(e,a),n?formatMessagePart(e,n):void 0,e.type)}default:throw new Error(`unhandled node on format message part: ${r}`)}}const defaultOnCacheKey=e=>e;let compileCache=create();function baseCompile(e,t={}){let r=!1;const n=t.onError||defaultOnError;return t.onError=e=>{r=!0,n(e)},{...baseCompile$1(e,t),detectError:r}}function compile(e,t){if(isString(e)){!isBoolean(t.warnHtmlMessage)||t.warnHtmlMessage;const r=(t.onCacheKey||defaultOnCacheKey)(e),n=compileCache[r];if(n)return n;const{ast:a,detectError:o}=baseCompile(e,{...t,location:!1,jit:!0}),s=format(a);return o?s:compileCache[r]=s}{const t=e.cacheKey;if(t){const r=compileCache[t];return r||(compileCache[t]=format(e))}return format(e)}}const NOOP_MESSAGE_FUNCTION=()=>"",isMessageFunction=e=>isFunction(e);function translate(e,...t){const{fallbackFormat:r,postTranslation:n,unresolving:a,messageCompiler:o,fallbackLocale:s,messages:l}=e,[i,c]=parseTranslateArgs(...t),u=isBoolean(c.missingWarn)?c.missingWarn:e.missingWarn,m=isBoolean(c.fallbackWarn)?c.fallbackWarn:e.fallbackWarn,f=isBoolean(c.escapeParameter)?c.escapeParameter:e.escapeParameter,p=!!c.resolvedMessage,_=isString(c.default)||isBoolean(c.default)?isBoolean(c.default)?o?i:()=>i:c.default:r?o?i:()=>i:"",g=r||""!==_,d=getLocale(e,c);f&&escapeParams(c);let[E,b,C]=p?[i,d,l[d]||create()]:resolveMessageFormat(e,i,d,s,m,u),O=E,T=i;if(p||isString(O)||isMessageAST(O)||isMessageFunction(O)||g&&(O=_,T=O),!(p||(isString(O)||isMessageAST(O)||isMessageFunction(O))&&isString(b)))return a?NOT_REOSLVED:i;let L=!1;const N=isMessageFunction(O)?O:compileMessageFormat(e,i,b,O,T,(()=>{L=!0}));if(L)return O;const S=evaluateMessage(e,N,createMessageContext(getMessageContextOptions(e,b,C,c)));let v=n?n(S,i):S;return f&&isString(v)&&(v=sanitizeTranslatedHtml(v)),v}function escapeParams(e){isArray(e.list)?e.list=e.list.map((e=>isString(e)?escapeHtml(e):e)):isObject(e.named)&&Object.keys(e.named).forEach((t=>{isString(e.named[t])&&(e.named[t]=escapeHtml(e.named[t]))}))}function resolveMessageFormat(e,t,r,n,a,o){const{messages:s,onWarn:l,messageResolver:i,localeFallbacker:c}=e,u=c(e,n,r);let m,f=create(),p=null;for(let _=0;_n;return e.locale=r,e.key=t,e}const i=s(n,getCompileContext(e,r,a,n,l,o));return i.locale=r,i.key=t,i.source=n,i}function evaluateMessage(e,t,r){return t(r)}function parseTranslateArgs(...e){const[t,r,n]=e,a=create();if(!(isString(t)||isNumber(t)||isMessageFunction(t)||isMessageAST(t)))throw Error(CoreErrorCodes.INVALID_ARGUMENT);const o=isNumber(t)?String(t):(isMessageFunction(t),t);return isNumber(r)?a.plural=r:isString(r)?a.default=r:isPlainObject(r)&&!isEmptyObject(r)?a.named=r:isArray(r)&&(a.list=r),isNumber(n)?a.plural=n:isString(n)?a.default=n:isPlainObject(n)&&assign(a,n),[o,a]}function getCompileContext(e,t,r,n,a,o){return{locale:t,key:r,warnHtmlMessage:a,onError:e=>{throw o&&o(e),e},onCacheKey:e=>generateFormatCacheKey(t,r,e)}}function getMessageContextOptions(e,t,r,n){const{modifiers:a,pluralRules:o,messageResolver:s,fallbackLocale:l,fallbackWarn:i,missingWarn:c,fallbackContext:u}=e,m={locale:t,modifiers:a,pluralRules:o,messages:n=>{let a=s(r,n);if(null==a&&u){const[,,e]=resolveMessageFormat(u,n,t,l,i,c);a=s(e,n)}if(isString(a)||isMessageAST(a)){let r=!1;const o=compileMessageFormat(e,n,t,a,n,(()=>{r=!0}));return r?NOOP_MESSAGE_FUNCTION:o}return isMessageFunction(a)?a:NOOP_MESSAGE_FUNCTION}};return e.processor&&(m.processor=e.processor),n.list&&(m.list=n.list),n.named&&(m.named=n.named),isNumber(n.plural)&&(m.pluralIndex=n.plural),m}function datetime(e,...t){const{datetimeFormats:r,unresolving:n,fallbackLocale:a,onWarn:o,localeFallbacker:s}=e,{__datetimeFormatters:l}=e,[i,c,u,m]=parseDateTimeArgs(...t),f=isBoolean(u.missingWarn)?u.missingWarn:e.missingWarn;isBoolean(u.fallbackWarn)?u.fallbackWarn:e.fallbackWarn;const p=!!u.part,_=getLocale(e,u),g=s(e,a,_);if(!isString(i)||""===i)return new Intl.DateTimeFormat(_,m).format(c);let d,E={},b=null;for(let T=0;T{DATETIME_FORMAT_OPTIONS_KEYS.includes(e)?l[e]=r[e]:o[e]=r[e]})),isString(n)?o.locale=n:isPlainObject(n)&&(l=n),isPlainObject(a)&&(l=a),[o.key||"",s,o,l]}function clearDateTimeFormat(e,t,r){const n=e;for(const a in r){const e=`${t}__${a}`;n.__datetimeFormatters.has(e)&&n.__datetimeFormatters.delete(e)}}function number(e,...t){const{numberFormats:r,unresolving:n,fallbackLocale:a,onWarn:o,localeFallbacker:s}=e,{__numberFormatters:l}=e,[i,c,u,m]=parseNumberArgs(...t),f=isBoolean(u.missingWarn)?u.missingWarn:e.missingWarn;isBoolean(u.fallbackWarn)?u.fallbackWarn:e.fallbackWarn;const p=!!u.part,_=getLocale(e,u),g=s(e,a,_);if(!isString(i)||""===i)return new Intl.NumberFormat(_,m).format(c);let d,E={},b=null;for(let T=0;T{NUMBER_FORMAT_OPTIONS_KEYS.includes(e)?s[e]=r[e]:o[e]=r[e]})),isString(n)?o.locale=n:isPlainObject(n)&&(s=n),isPlainObject(a)&&(s=a),[o.key||"",l,o,s]}function clearNumberFormat(e,t,r){const n=e;for(const a in r){const e=`${t}__${a}`;n.__numberFormatters.has(e)&&n.__numberFormatters.delete(e)}}const VERSION="9.14.5",code=CoreErrorCodes.__EXTEND_POINT__,inc=incrementer(code),I18nErrorCodes={UNEXPECTED_RETURN_TYPE:code,INVALID_ARGUMENT:inc(),MUST_BE_CALL_SETUP_TOP:inc(),NOT_INSTALLED:inc(),NOT_AVAILABLE_IN_LEGACY_MODE:inc(),REQUIRED_VALUE:inc(),INVALID_VALUE:inc(),CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN:inc(),NOT_INSTALLED_WITH_PROVIDE:inc(),UNEXPECTED_ERROR:inc(),NOT_COMPATIBLE_LEGACY_VUE_I18N:inc(),BRIDGE_SUPPORT_VUE_2_ONLY:inc(),MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION:inc(),NOT_AVAILABLE_COMPOSITION_IN_LEGACY:inc(),__EXTEND_POINT__:inc()};function createI18nError(e,...t){return createCompileError(e,null,void 0)}const TranslateVNodeSymbol=makeSymbol("__translateVNode"),DatetimePartsSymbol=makeSymbol("__datetimeParts"),NumberPartsSymbol=makeSymbol("__numberParts"),SetPluralRulesSymbol=makeSymbol("__setPluralRules"),InejctWithOptionSymbol=makeSymbol("__injectWithOption"),DisposeSymbol=makeSymbol("__dispose"),__VUE_I18N_BRIDGE__="__VUE_I18N_BRIDGE__";function handleFlatJson(e){if(!isObject(e))return e;if(isMessageAST(e))return e;for(const t in e)if(hasOwn(e,t))if(t.includes(".")){const r=t.split("."),n=r.length-1;let a=e,o=!1;for(let e=0;e{if("locale"in e&&"resource"in e){const{locale:t,resource:r}=e;t?(s[t]=s[t]||create(),deepCopy(r,s[t])):deepCopy(r,s)}else isString(e)&&deepCopy(JSON.parse(e),s)})),null==a&&o)for(const l in s)hasOwn(s,l)&&handleFlatJson(s[l]);return s}function getComponentOptions(e){return e.type}function adjustI18nResources(e,t,r){let n=isObject(t.messages)?t.messages:create();"__i18nGlobal"in r&&(n=getLocaleMessages(e.locale.value,{messages:n,__i18n:r.__i18nGlobal}));const a=Object.keys(n);if(a.length&&a.forEach((t=>{e.mergeLocaleMessage(t,n[t])})),isObject(t.datetimeFormats)){const r=Object.keys(t.datetimeFormats);r.length&&r.forEach((r=>{e.mergeDateTimeFormat(r,t.datetimeFormats[r])}))}if(isObject(t.numberFormats)){const r=Object.keys(t.numberFormats);r.length&&r.forEach((r=>{e.mergeNumberFormat(r,t.numberFormats[r])}))}}function createTextNode(e){return createVNode(Text,null,e,0)}const DEVTOOLS_META="__INTLIFY_META__",NOOP_RETURN_ARRAY=()=>[],NOOP_RETURN_FALSE=()=>!1;let composerID=0;function defineCoreMissingHandler(e){return(t,r,n,a)=>e(r,n,getCurrentInstance()||void 0,a)}const getMetaInfo=()=>{const e=getCurrentInstance();let t=null;return e&&(t=getComponentOptions(e)[DEVTOOLS_META])?{[DEVTOOLS_META]:t}:null};function createComposer(e={},t){const{__root:r,__injectWithOption:n}=e,a=void 0===r,o=e.flatJson,s=inBrowser?ref:shallowRef,l=!!e.translateExistCompatible;let i=!isBoolean(e.inheritLocale)||e.inheritLocale;const c=s(r&&i?r.locale.value:isString(e.locale)?e.locale:DEFAULT_LOCALE),u=s(r&&i?r.fallbackLocale.value:isString(e.fallbackLocale)||isArray(e.fallbackLocale)||isPlainObject(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:c.value),m=s(getLocaleMessages(c.value,e)),f=s(isPlainObject(e.datetimeFormats)?e.datetimeFormats:{[c.value]:{}}),p=s(isPlainObject(e.numberFormats)?e.numberFormats:{[c.value]:{}});let _=r?r.missingWarn:!isBoolean(e.missingWarn)&&!isRegExp(e.missingWarn)||e.missingWarn,g=r?r.fallbackWarn:!isBoolean(e.fallbackWarn)&&!isRegExp(e.fallbackWarn)||e.fallbackWarn,d=r?r.fallbackRoot:!isBoolean(e.fallbackRoot)||e.fallbackRoot,E=!!e.fallbackFormat,b=isFunction(e.missing)?e.missing:null,C=isFunction(e.missing)?defineCoreMissingHandler(e.missing):null,O=isFunction(e.postTranslation)?e.postTranslation:null,T=r?r.warnHtmlMessage:!isBoolean(e.warnHtmlMessage)||e.warnHtmlMessage,L=!!e.escapeParameter;const N=r?r.modifiers:isPlainObject(e.modifiers)?e.modifiers:{};let S,v=e.pluralRules||r&&r.pluralRules;S=(()=>{a&&setFallbackContext(null);const t={version:VERSION,locale:c.value,fallbackLocale:u.value,messages:m.value,modifiers:N,pluralRules:v,missing:null===C?void 0:C,missingWarn:_,fallbackWarn:g,fallbackFormat:E,unresolving:!0,postTranslation:null===O?void 0:O,warnHtmlMessage:T,escapeParameter:L,messageResolver:e.messageResolver,messageCompiler:e.messageCompiler,__meta:{framework:"vue"}};t.datetimeFormats=f.value,t.numberFormats=p.value,t.__datetimeFormatters=isPlainObject(S)?S.__datetimeFormatters:void 0,t.__numberFormatters=isPlainObject(S)?S.__numberFormatters:void 0;const r=createCoreContext(t);return a&&setFallbackContext(r),r})(),updateFallbackLocale(S,c.value,u.value);const h=computed({get:()=>c.value,set:e=>{c.value=e,S.locale=c.value}}),k=computed({get:()=>u.value,set:e=>{u.value=e,S.fallbackLocale=u.value,updateFallbackLocale(S,c.value,e)}}),P=computed((()=>m.value)),I=computed((()=>f.value)),A=computed((()=>p.value));const y=(e,t,n,o,s,l)=>{let i;c.value,u.value,m.value,f.value,p.value;try{0,a||(S.fallbackContext=r?getFallbackContext():void 0),i=e(S)}finally{a||(S.fallbackContext=void 0)}if("translate exists"!==n&&isNumber(i)&&i===NOT_REOSLVED||"translate exists"===n&&!i){const[e,n]=t();return r&&d?o(r):s(e)}if(l(i))return i;throw Error(I18nErrorCodes.UNEXPECTED_RETURN_TYPE)};function F(...e){return y((t=>Reflect.apply(translate,null,[t,...e])),(()=>parseTranslateArgs(...e)),"translate",(t=>Reflect.apply(t.t,t,[...e])),(e=>e),(e=>isString(e)))}const R={normalize:function(e){return e.map((e=>isString(e)||isNumber(e)||isBoolean(e)?createTextNode(String(e)):e))},interpolate:e=>e,type:"vnode"};function M(e){return m.value[e]||{}}composerID++,r&&inBrowser&&(watch(r.locale,(e=>{i&&(c.value=e,S.locale=e,updateFallbackLocale(S,c.value,u.value))})),watch(r.fallbackLocale,(e=>{i&&(u.value=e,S.fallbackLocale=e,updateFallbackLocale(S,c.value,u.value))})));const D={id:composerID,locale:h,fallbackLocale:k,get inheritLocale(){return i},set inheritLocale(e){i=e,e&&r&&(c.value=r.locale.value,u.value=r.fallbackLocale.value,updateFallbackLocale(S,c.value,u.value))},get availableLocales(){return Object.keys(m.value).sort()},messages:P,get modifiers(){return N},get pluralRules(){return v||{}},get isGlobal(){return a},get missingWarn(){return _},set missingWarn(e){_=e,S.missingWarn=_},get fallbackWarn(){return g},set fallbackWarn(e){g=e,S.fallbackWarn=g},get fallbackRoot(){return d},set fallbackRoot(e){d=e},get fallbackFormat(){return E},set fallbackFormat(e){E=e,S.fallbackFormat=E},get warnHtmlMessage(){return T},set warnHtmlMessage(e){T=e,S.warnHtmlMessage=e},get escapeParameter(){return L},set escapeParameter(e){L=e,S.escapeParameter=e},t:F,getLocaleMessage:M,setLocaleMessage:function(e,t){if(o){const r={[e]:t};for(const e in r)hasOwn(r,e)&&handleFlatJson(r[e]);t=r[e]}m.value[e]=t,S.messages=m.value},mergeLocaleMessage:function(e,t){m.value[e]=m.value[e]||{};const r={[e]:t};if(o)for(const n in r)hasOwn(r,n)&&handleFlatJson(r[n]);deepCopy(t=r[e],m.value[e]),S.messages=m.value},getPostTranslationHandler:function(){return isFunction(O)?O:null},setPostTranslationHandler:function(e){O=e,S.postTranslation=e},getMissingHandler:function(){return b},setMissingHandler:function(e){null!==e&&(C=defineCoreMissingHandler(e)),b=e,S.missing=C},[SetPluralRulesSymbol]:function(e){v=e,S.pluralRules=v}};return D.datetimeFormats=I,D.numberFormats=A,D.rt=function(...e){const[t,r,n]=e;if(n&&!isObject(n))throw Error(I18nErrorCodes.INVALID_ARGUMENT);return F(t,r,assign({resolvedMessage:!0},n||{}))},D.te=function(e,t){return y((()=>{if(!e)return!1;const r=M(isString(t)?t:c.value),n=S.messageResolver(r,e);return l?null!=n:isMessageAST(n)||isMessageFunction(n)||isString(n)}),(()=>[e]),"translate exists",(r=>Reflect.apply(r.te,r,[e,t])),NOOP_RETURN_FALSE,(e=>isBoolean(e)))},D.tm=function(e){const t=function(e){let t=null;const r=fallbackWithLocaleChain(S,u.value,c.value);for(let n=0;nReflect.apply(datetime,null,[t,...e])),(()=>parseDateTimeArgs(...e)),"datetime format",(t=>Reflect.apply(t.d,t,[...e])),(()=>MISSING_RESOLVE_VALUE),(e=>isString(e)))},D.n=function(...e){return y((t=>Reflect.apply(number,null,[t,...e])),(()=>parseNumberArgs(...e)),"number format",(t=>Reflect.apply(t.n,t,[...e])),(()=>MISSING_RESOLVE_VALUE),(e=>isString(e)))},D.getDateTimeFormat=function(e){return f.value[e]||{}},D.setDateTimeFormat=function(e,t){f.value[e]=t,S.datetimeFormats=f.value,clearDateTimeFormat(S,e,t)},D.mergeDateTimeFormat=function(e,t){f.value[e]=assign(f.value[e]||{},t),S.datetimeFormats=f.value,clearDateTimeFormat(S,e,t)},D.getNumberFormat=function(e){return p.value[e]||{}},D.setNumberFormat=function(e,t){p.value[e]=t,S.numberFormats=p.value,clearNumberFormat(S,e,t)},D.mergeNumberFormat=function(e,t){p.value[e]=assign(p.value[e]||{},t),S.numberFormats=p.value,clearNumberFormat(S,e,t)},D[InejctWithOptionSymbol]=n,D[TranslateVNodeSymbol]=function(...e){return y((t=>{let r;const n=t;try{n.processor=R,r=Reflect.apply(translate,null,[n,...e])}finally{n.processor=null}return r}),(()=>parseTranslateArgs(...e)),"translate",(t=>t[TranslateVNodeSymbol](...e)),(e=>[createTextNode(e)]),(e=>isArray(e)))},D[DatetimePartsSymbol]=function(...e){return y((t=>Reflect.apply(datetime,null,[t,...e])),(()=>parseDateTimeArgs(...e)),"datetime format",(t=>t[DatetimePartsSymbol](...e)),NOOP_RETURN_ARRAY,(e=>isString(e)||isArray(e)))},D[NumberPartsSymbol]=function(...e){return y((t=>Reflect.apply(number,null,[t,...e])),(()=>parseNumberArgs(...e)),"number format",(t=>t[NumberPartsSymbol](...e)),NOOP_RETURN_ARRAY,(e=>isString(e)||isArray(e)))},D}function convertComposerOptions(e){const t=isString(e.locale)?e.locale:DEFAULT_LOCALE,r=isString(e.fallbackLocale)||isArray(e.fallbackLocale)||isPlainObject(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:t,n=isFunction(e.missing)?e.missing:void 0,a=!isBoolean(e.silentTranslationWarn)&&!isRegExp(e.silentTranslationWarn)||!e.silentTranslationWarn,o=!isBoolean(e.silentFallbackWarn)&&!isRegExp(e.silentFallbackWarn)||!e.silentFallbackWarn,s=!isBoolean(e.fallbackRoot)||e.fallbackRoot,l=!!e.formatFallbackMessages,i=isPlainObject(e.modifiers)?e.modifiers:{},c=e.pluralizationRules,u=isFunction(e.postTranslation)?e.postTranslation:void 0,m=!isString(e.warnHtmlInMessage)||"off"!==e.warnHtmlInMessage,f=!!e.escapeParameterHtml,p=!isBoolean(e.sync)||e.sync;let _=e.messages;if(isPlainObject(e.sharedMessages)){const t=e.sharedMessages;_=Object.keys(t).reduce(((e,r)=>{const n=e[r]||(e[r]={});return assign(n,t[r]),e}),_||{})}const{__i18n:g,__root:d,__injectWithOption:E}=e,b=e.datetimeFormats,C=e.numberFormats,O=e.flatJson,T=e.translateExistCompatible;return{locale:t,fallbackLocale:r,messages:_,flatJson:O,datetimeFormats:b,numberFormats:C,missing:n,missingWarn:a,fallbackWarn:o,fallbackRoot:s,fallbackFormat:l,modifiers:i,pluralRules:c,postTranslation:u,warnHtmlMessage:m,escapeParameter:f,messageResolver:e.messageResolver,inheritLocale:p,translateExistCompatible:T,__i18n:g,__root:d,__injectWithOption:E}}function createVueI18n(e={},t){{const t=createComposer(convertComposerOptions(e)),{__extender:r}=e,n={id:t.id,get locale(){return t.locale.value},set locale(e){t.locale.value=e},get fallbackLocale(){return t.fallbackLocale.value},set fallbackLocale(e){t.fallbackLocale.value=e},get messages(){return t.messages.value},get datetimeFormats(){return t.datetimeFormats.value},get numberFormats(){return t.numberFormats.value},get availableLocales(){return t.availableLocales},get formatter(){return{interpolate:()=>[]}},set formatter(e){},get missing(){return t.getMissingHandler()},set missing(e){t.setMissingHandler(e)},get silentTranslationWarn(){return isBoolean(t.missingWarn)?!t.missingWarn:t.missingWarn},set silentTranslationWarn(e){t.missingWarn=isBoolean(e)?!e:e},get silentFallbackWarn(){return isBoolean(t.fallbackWarn)?!t.fallbackWarn:t.fallbackWarn},set silentFallbackWarn(e){t.fallbackWarn=isBoolean(e)?!e:e},get modifiers(){return t.modifiers},get formatFallbackMessages(){return t.fallbackFormat},set formatFallbackMessages(e){t.fallbackFormat=e},get postTranslation(){return t.getPostTranslationHandler()},set postTranslation(e){t.setPostTranslationHandler(e)},get sync(){return t.inheritLocale},set sync(e){t.inheritLocale=e},get warnHtmlInMessage(){return t.warnHtmlMessage?"warn":"off"},set warnHtmlInMessage(e){t.warnHtmlMessage="off"!==e},get escapeParameterHtml(){return t.escapeParameter},set escapeParameterHtml(e){t.escapeParameter=e},get preserveDirectiveContent(){return!0},set preserveDirectiveContent(e){},get pluralizationRules(){return t.pluralRules||{}},__composer:t,t(...e){const[r,n,a]=e,o={};let s=null,l=null;if(!isString(r))throw Error(I18nErrorCodes.INVALID_ARGUMENT);const i=r;return isString(n)?o.locale=n:isArray(n)?s=n:isPlainObject(n)&&(l=n),isArray(a)?s=a:isPlainObject(a)&&(l=a),Reflect.apply(t.t,t,[i,s||l||{},o])},rt:(...e)=>Reflect.apply(t.rt,t,[...e]),tc(...e){const[r,n,a]=e,o={plural:1};let s=null,l=null;if(!isString(r))throw Error(I18nErrorCodes.INVALID_ARGUMENT);const i=r;return isString(n)?o.locale=n:isNumber(n)?o.plural=n:isArray(n)?s=n:isPlainObject(n)&&(l=n),isString(a)?o.locale=a:isArray(a)?s=a:isPlainObject(a)&&(l=a),Reflect.apply(t.t,t,[i,s||l||{},o])},te:(e,r)=>t.te(e,r),tm:e=>t.tm(e),getLocaleMessage:e=>t.getLocaleMessage(e),setLocaleMessage(e,r){t.setLocaleMessage(e,r)},mergeLocaleMessage(e,r){t.mergeLocaleMessage(e,r)},d:(...e)=>Reflect.apply(t.d,t,[...e]),getDateTimeFormat:e=>t.getDateTimeFormat(e),setDateTimeFormat(e,r){t.setDateTimeFormat(e,r)},mergeDateTimeFormat(e,r){t.mergeDateTimeFormat(e,r)},n:(...e)=>Reflect.apply(t.n,t,[...e]),getNumberFormat:e=>t.getNumberFormat(e),setNumberFormat(e,r){t.setNumberFormat(e,r)},mergeNumberFormat(e,r){t.mergeNumberFormat(e,r)},getChoiceIndex:(e,t)=>-1};return n.__extender=r,n}}const baseFormatProps={tag:{type:[String,Object]},locale:{type:String},scope:{type:String,validator:e=>"parent"===e||"global"===e,default:"parent"},i18n:{type:Object}};function getInterpolateArg({slots:e},t){if(1===t.length&&"default"===t[0]){return(e.default?e.default():[]).reduce(((e,t)=>[...e,...t.type===Fragment?t.children:[t]]),[])}return t.reduce(((t,r)=>{const n=e[r];return n&&(t[r]=n()),t}),create())}function getFragmentableTag(e){return Fragment}const TranslationImpl=defineComponent({name:"i18n-t",props:assign({keypath:{type:String,required:!0},plural:{type:[Number,String],validator:e=>isNumber(e)||!isNaN(e)}},baseFormatProps),setup(e,t){const{slots:r,attrs:n}=t,a=e.i18n||useI18n({useScope:e.scope,__useComponent:!0});return()=>{const o=Object.keys(r).filter((e=>"_"!==e)),s=create();e.locale&&(s.locale=e.locale),void 0!==e.plural&&(s.plural=isString(e.plural)?+e.plural:e.plural);const l=getInterpolateArg(t,o),i=a[TranslateVNodeSymbol](e.keypath,l,s),c=assign(create(),n),u=isString(e.tag)||isObject(e.tag)?e.tag:getFragmentableTag();return h(u,c,i)}}}),Translation=TranslationImpl,I18nT=Translation;function isVNode(e){return isArray(e)&&!isString(e[0])}function renderFormatter(e,t,r,n){const{slots:a,attrs:o}=t;return()=>{const t={part:!0};let s=create();e.locale&&(t.locale=e.locale),isString(e.format)?t.key=e.format:isObject(e.format)&&(isString(e.format.key)&&(t.key=e.format.key),s=Object.keys(e.format).reduce(((t,n)=>r.includes(n)?assign(create(),t,{[n]:e.format[n]}):t),create()));const l=n(e.value,t,s);let i=[t.key];isArray(l)?i=l.map(((e,t)=>{const r=a[e.type],n=r?r({[e.type]:e.value,index:t,parts:l}):[e.value];return isVNode(n)&&(n[0].key=`${e.type}-${t}`),n})):isString(l)&&(i=[l]);const c=assign(create(),o),u=isString(e.tag)||isObject(e.tag)?e.tag:getFragmentableTag();return h(u,c,i)}}const NumberFormatImpl=defineComponent({name:"i18n-n",props:assign({value:{type:Number,required:!0},format:{type:[String,Object]}},baseFormatProps),setup(e,t){const r=e.i18n||useI18n({useScope:e.scope,__useComponent:!0});return renderFormatter(e,t,NUMBER_FORMAT_OPTIONS_KEYS,((...e)=>r[NumberPartsSymbol](...e)))}}),NumberFormat=NumberFormatImpl,I18nN=NumberFormat,DatetimeFormatImpl=defineComponent({name:"i18n-d",props:assign({value:{type:[Number,Date],required:!0},format:{type:[String,Object]}},baseFormatProps),setup(e,t){const r=e.i18n||useI18n({useScope:e.scope,__useComponent:!0});return renderFormatter(e,t,DATETIME_FORMAT_OPTIONS_KEYS,((...e)=>r[DatetimePartsSymbol](...e)))}}),DatetimeFormat=DatetimeFormatImpl,I18nD=DatetimeFormat;function getComposer$1(e,t){const r=e;if("composition"===e.mode)return r.__getInstance(t)||e.global;{const n=r.__getInstance(t);return null!=n?n.__composer:e.global.__composer}}function vTDirective(e){const t=t=>{const{instance:r,modifiers:n,value:a}=t;if(!r||!r.$)throw Error(I18nErrorCodes.UNEXPECTED_ERROR);const o=getComposer$1(e,r.$),s=parseValue(a);return[Reflect.apply(o.t,o,[...makeParams(s)]),o]};return{created:(r,n)=>{const[a,o]=t(n);inBrowser&&e.global===o&&(r.__i18nWatcher=watch(o.locale,(()=>{n.instance&&n.instance.$forceUpdate()}))),r.__composer=o,r.textContent=a},unmounted:e=>{inBrowser&&e.__i18nWatcher&&(e.__i18nWatcher(),e.__i18nWatcher=void 0,delete e.__i18nWatcher),e.__composer&&(e.__composer=void 0,delete e.__composer)},beforeUpdate:(e,{value:t})=>{if(e.__composer){const r=e.__composer,n=parseValue(t);e.textContent=Reflect.apply(r.t,r,[...makeParams(n)])}},getSSRProps:e=>{const[r]=t(e);return{textContent:r}}}}function parseValue(e){if(isString(e))return{path:e};if(isPlainObject(e)){if(!("path"in e))throw Error(I18nErrorCodes.REQUIRED_VALUE,"path");return e}throw Error(I18nErrorCodes.INVALID_VALUE)}function makeParams(e){const{path:t,locale:r,args:n,choice:a,plural:o}=e,s={},l=n||{};return isString(r)&&(s.locale=r),isNumber(a)&&(s.plural=a),isNumber(o)&&(s.plural=o),[t,l,s]}function apply(e,t,...r){const n=isPlainObject(r[0])?r[0]:{},a=!!n.useI18nComponentName;(!isBoolean(n.globalInstall)||n.globalInstall)&&([a?"i18n":Translation.name,"I18nT"].forEach((t=>e.component(t,Translation))),[NumberFormat.name,"I18nN"].forEach((t=>e.component(t,NumberFormat))),[DatetimeFormat.name,"I18nD"].forEach((t=>e.component(t,DatetimeFormat)))),e.directive("t",vTDirective(t))}function defineMixin(e,t,r){return{beforeCreate(){const n=getCurrentInstance();if(!n)throw Error(I18nErrorCodes.UNEXPECTED_ERROR);const a=this.$options;if(a.i18n){const n=a.i18n;if(a.__i18n&&(n.__i18n=a.__i18n),n.__root=t,this===this.$root)this.$i18n=mergeToGlobal(e,n);else{n.__injectWithOption=!0,n.__extender=r.__vueI18nExtend,this.$i18n=createVueI18n(n);const e=this.$i18n;e.__extender&&(e.__disposer=e.__extender(this.$i18n))}}else if(a.__i18n)if(this===this.$root)this.$i18n=mergeToGlobal(e,a);else{this.$i18n=createVueI18n({__i18n:a.__i18n,__injectWithOption:!0,__extender:r.__vueI18nExtend,__root:t});const e=this.$i18n;e.__extender&&(e.__disposer=e.__extender(this.$i18n))}else this.$i18n=e;a.__i18nGlobal&&adjustI18nResources(t,a,a),this.$t=(...e)=>this.$i18n.t(...e),this.$rt=(...e)=>this.$i18n.rt(...e),this.$tc=(...e)=>this.$i18n.tc(...e),this.$te=(e,t)=>this.$i18n.te(e,t),this.$d=(...e)=>this.$i18n.d(...e),this.$n=(...e)=>this.$i18n.n(...e),this.$tm=e=>this.$i18n.tm(e),r.__setInstance(n,this.$i18n)},mounted(){},unmounted(){const e=getCurrentInstance();if(!e)throw Error(I18nErrorCodes.UNEXPECTED_ERROR);const t=this.$i18n;delete this.$t,delete this.$rt,delete this.$tc,delete this.$te,delete this.$d,delete this.$n,delete this.$tm,t.__disposer&&(t.__disposer(),delete t.__disposer,delete t.__extender),r.__deleteInstance(e),delete this.$i18n}}}function mergeToGlobal(e,t){e.locale=t.locale||e.locale,e.fallbackLocale=t.fallbackLocale||e.fallbackLocale,e.missing=t.missing||e.missing,e.silentTranslationWarn=t.silentTranslationWarn||e.silentFallbackWarn,e.silentFallbackWarn=t.silentFallbackWarn||e.silentFallbackWarn,e.formatFallbackMessages=t.formatFallbackMessages||e.formatFallbackMessages,e.postTranslation=t.postTranslation||e.postTranslation,e.warnHtmlInMessage=t.warnHtmlInMessage||e.warnHtmlInMessage,e.escapeParameterHtml=t.escapeParameterHtml||e.escapeParameterHtml,e.sync=t.sync||e.sync,e.__composer[SetPluralRulesSymbol](t.pluralizationRules||e.pluralizationRules);const r=getLocaleMessages(e.locale,{messages:t.messages,__i18n:t.__i18n});return Object.keys(r).forEach((t=>e.mergeLocaleMessage(t,r[t]))),t.datetimeFormats&&Object.keys(t.datetimeFormats).forEach((r=>e.mergeDateTimeFormat(r,t.datetimeFormats[r]))),t.numberFormats&&Object.keys(t.numberFormats).forEach((r=>e.mergeNumberFormat(r,t.numberFormats[r]))),e}const I18nInjectionKey=makeSymbol("global-vue-i18n");function createI18n(e={},t){const r=!isBoolean(e.legacy)||e.legacy,n=!isBoolean(e.globalInjection)||e.globalInjection,a=!r||!!e.allowComposition,o=new Map,[s,l]=createGlobal(e,r),i=makeSymbol("");{const e={get mode(){return r?"legacy":"composition"},get allowComposition(){return a},async install(t,...a){if(t.__VUE_I18N_SYMBOL__=i,t.provide(t.__VUE_I18N_SYMBOL__,e),isPlainObject(a[0])){const t=a[0];e.__composerExtend=t.__composerExtend,e.__vueI18nExtend=t.__vueI18nExtend}let o=null;!r&&n&&(o=injectGlobalFields(t,e.global)),apply(t,e,...a),r&&t.mixin(defineMixin(l,l.__composer,e));const s=t.unmount;t.unmount=()=>{o&&o(),e.dispose(),s()}},get global(){return l},dispose(){s.stop()},__instances:o,__getInstance:function(e){return o.get(e)||null},__setInstance:function(e,t){o.set(e,t)},__deleteInstance:function(e){o.delete(e)}};return e}}function useI18n(e={}){const t=getCurrentInstance();if(null==t)throw Error(I18nErrorCodes.MUST_BE_CALL_SETUP_TOP);if(!t.isCE&&null!=t.appContext.app&&!t.appContext.app.__VUE_I18N_SYMBOL__)throw Error(I18nErrorCodes.NOT_INSTALLED);const r=getI18nInstance(t),n=getGlobalComposer(r),a=getComponentOptions(t),o=getScope(e,a);if("legacy"===r.mode&&!e.__useComponent){if(!r.allowComposition)throw Error(I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE);return useI18nForLegacy(t,o,n,e)}if("global"===o)return adjustI18nResources(n,e,a),n;if("parent"===o){let a=getComposer(r,t,e.__useComponent);return null==a&&(a=n),a}const s=r;let l=s.__getInstance(t);if(null==l){const r=assign({},e);"__i18n"in a&&(r.__i18n=a.__i18n),n&&(r.__root=n),l=createComposer(r),s.__composerExtend&&(l[DisposeSymbol]=s.__composerExtend(l)),setupLifeCycle(s,t,l),s.__setInstance(t,l)}return l}const castToVueI18n=e=>{if(!(__VUE_I18N_BRIDGE__ in e))throw Error(I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N);return e};function createGlobal(e,t,r){const n=effectScope();{const r=t?n.run((()=>createVueI18n(e))):n.run((()=>createComposer(e)));if(null==r)throw Error(I18nErrorCodes.UNEXPECTED_ERROR);return[n,r]}}function getI18nInstance(e){{const t=inject(e.isCE?I18nInjectionKey:e.appContext.app.__VUE_I18N_SYMBOL__);if(!t)throw createI18nError(e.isCE?I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE:I18nErrorCodes.UNEXPECTED_ERROR);return t}}function getScope(e,t){return isEmptyObject(e)?"__i18n"in t?"local":"global":e.useScope?e.useScope:"local"}function getGlobalComposer(e){return"composition"===e.mode?e.global:e.global.__composer}function getComposer(e,t,r=!1){let n=null;const a=t.root;let o=getParentComponentInstance(t,r);for(;null!=o;){const t=e;if("composition"===e.mode)n=t.__getInstance(o);else{const e=t.__getInstance(o);null!=e&&(n=e.__composer,r&&n&&!n[InejctWithOptionSymbol]&&(n=null))}if(null!=n)break;if(a===o)break;o=o.parent}return n}function getParentComponentInstance(e,t=!1){return null==e?null:t&&e.vnode.ctx||e.parent}function setupLifeCycle(e,t,r){onMounted((()=>{}),t),onUnmounted((()=>{const n=r;e.__deleteInstance(t);const a=n[DisposeSymbol];a&&(a(),delete n[DisposeSymbol])}),t)}function useI18nForLegacy(e,t,r,n={}){const a="local"===t,o=shallowRef(null);if(a&&e.proxy&&!e.proxy.$options.i18n&&!e.proxy.$options.__i18n)throw Error(I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION);const s=isBoolean(n.inheritLocale)?n.inheritLocale:!isString(n.locale),l=ref(!a||s?r.locale.value:isString(n.locale)?n.locale:DEFAULT_LOCALE),i=ref(!a||s?r.fallbackLocale.value:isString(n.fallbackLocale)||isArray(n.fallbackLocale)||isPlainObject(n.fallbackLocale)||!1===n.fallbackLocale?n.fallbackLocale:l.value),c=ref(getLocaleMessages(l.value,n)),u=ref(isPlainObject(n.datetimeFormats)?n.datetimeFormats:{[l.value]:{}}),m=ref(isPlainObject(n.numberFormats)?n.numberFormats:{[l.value]:{}}),f=a?r.missingWarn:!isBoolean(n.missingWarn)&&!isRegExp(n.missingWarn)||n.missingWarn,p=a?r.fallbackWarn:!isBoolean(n.fallbackWarn)&&!isRegExp(n.fallbackWarn)||n.fallbackWarn,_=a?r.fallbackRoot:!isBoolean(n.fallbackRoot)||n.fallbackRoot,g=!!n.fallbackFormat,d=isFunction(n.missing)?n.missing:null,E=isFunction(n.postTranslation)?n.postTranslation:null,b=a?r.warnHtmlMessage:!isBoolean(n.warnHtmlMessage)||n.warnHtmlMessage,C=!!n.escapeParameter,O=a?r.modifiers:isPlainObject(n.modifiers)?n.modifiers:{},T=n.pluralRules||a&&r.pluralRules;function L(e){return l.value,i.value,c.value,u.value,m.value,e()}const N={get id(){return o.value?o.value.id:-1},locale:computed({get:()=>o.value?o.value.locale.value:l.value,set:e=>{o.value&&(o.value.locale.value=e),l.value=e}}),fallbackLocale:computed({get:()=>o.value?o.value.fallbackLocale.value:i.value,set:e=>{o.value&&(o.value.fallbackLocale.value=e),i.value=e}}),messages:computed((()=>o.value?o.value.messages.value:c.value)),datetimeFormats:computed((()=>u.value)),numberFormats:computed((()=>m.value)),get inheritLocale(){return o.value?o.value.inheritLocale:s},set inheritLocale(e){o.value&&(o.value.inheritLocale=e)},get availableLocales(){return o.value?o.value.availableLocales:Object.keys(c.value)},get modifiers(){return o.value?o.value.modifiers:O},get pluralRules(){return o.value?o.value.pluralRules:T},get isGlobal(){return!!o.value&&o.value.isGlobal},get missingWarn(){return o.value?o.value.missingWarn:f},set missingWarn(e){o.value&&(o.value.missingWarn=e)},get fallbackWarn(){return o.value?o.value.fallbackWarn:p},set fallbackWarn(e){o.value&&(o.value.missingWarn=e)},get fallbackRoot(){return o.value?o.value.fallbackRoot:_},set fallbackRoot(e){o.value&&(o.value.fallbackRoot=e)},get fallbackFormat(){return o.value?o.value.fallbackFormat:g},set fallbackFormat(e){o.value&&(o.value.fallbackFormat=e)},get warnHtmlMessage(){return o.value?o.value.warnHtmlMessage:b},set warnHtmlMessage(e){o.value&&(o.value.warnHtmlMessage=e)},get escapeParameter(){return o.value?o.value.escapeParameter:C},set escapeParameter(e){o.value&&(o.value.escapeParameter=e)},t:function(...e){return o.value?L((()=>Reflect.apply(o.value.t,null,[...e]))):L((()=>""))},getPostTranslationHandler:function(){return o.value?o.value.getPostTranslationHandler():E},setPostTranslationHandler:function(e){o.value&&o.value.setPostTranslationHandler(e)},getMissingHandler:function(){return o.value?o.value.getMissingHandler():d},setMissingHandler:function(e){o.value&&o.value.setMissingHandler(e)},rt:function(...e){return o.value?Reflect.apply(o.value.rt,null,[...e]):""},d:function(...e){return o.value?L((()=>Reflect.apply(o.value.d,null,[...e]))):L((()=>""))},n:function(...e){return o.value?L((()=>Reflect.apply(o.value.n,null,[...e]))):L((()=>""))},tm:function(e){return o.value?o.value.tm(e):{}},te:function(e,t){return!!o.value&&o.value.te(e,t)},getLocaleMessage:function(e){return o.value?o.value.getLocaleMessage(e):{}},setLocaleMessage:function(e,t){o.value&&(o.value.setLocaleMessage(e,t),c.value[e]=t)},mergeLocaleMessage:function(e,t){o.value&&o.value.mergeLocaleMessage(e,t)},getDateTimeFormat:function(e){return o.value?o.value.getDateTimeFormat(e):{}},setDateTimeFormat:function(e,t){o.value&&(o.value.setDateTimeFormat(e,t),u.value[e]=t)},mergeDateTimeFormat:function(e,t){o.value&&o.value.mergeDateTimeFormat(e,t)},getNumberFormat:function(e){return o.value?o.value.getNumberFormat(e):{}},setNumberFormat:function(e,t){o.value&&(o.value.setNumberFormat(e,t),m.value[e]=t)},mergeNumberFormat:function(e,t){o.value&&o.value.mergeNumberFormat(e,t)}};return onBeforeMount((()=>{if(null==e.proxy||null==e.proxy.$i18n)throw Error(I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY);const r=o.value=e.proxy.$i18n.__composer;"global"===t?(l.value=r.locale.value,i.value=r.fallbackLocale.value,c.value=r.messages.value,u.value=r.datetimeFormats.value,m.value=r.numberFormats.value):a&&function(e){e.locale.value=l.value,e.fallbackLocale.value=i.value,Object.keys(c.value).forEach((t=>{e.mergeLocaleMessage(t,c.value[t])})),Object.keys(u.value).forEach((t=>{e.mergeDateTimeFormat(t,u.value[t])})),Object.keys(m.value).forEach((t=>{e.mergeNumberFormat(t,m.value[t])})),e.escapeParameter=C,e.fallbackFormat=g,e.fallbackRoot=_,e.fallbackWarn=p,e.missingWarn=f,e.warnHtmlMessage=b}(r)})),N}const globalExportProps=["locale","fallbackLocale","availableLocales"],globalExportMethods=["t","rt","d","n","tm","te"];function injectGlobalFields(e,t){const r=Object.create(null);globalExportProps.forEach((e=>{const n=Object.getOwnPropertyDescriptor(t,e);if(!n)throw Error(I18nErrorCodes.UNEXPECTED_ERROR);const a=isRef(n.value)?{get:()=>n.value.value,set(e){n.value.value=e}}:{get:()=>n.get&&n.get()};Object.defineProperty(r,e,a)})),e.config.globalProperties.$i18n=r,globalExportMethods.forEach((r=>{const n=Object.getOwnPropertyDescriptor(t,r);if(!n||!n.value)throw Error(I18nErrorCodes.UNEXPECTED_ERROR);Object.defineProperty(e.config.globalProperties,`$${r}`,n)}));return()=>{delete e.config.globalProperties.$i18n,globalExportMethods.forEach((t=>{delete e.config.globalProperties[`$${t}`]}))}}registerMessageCompiler(compile),registerMessageResolver(resolveValue),registerLocaleFallbacker(fallbackWithLocaleChain);export{DatetimeFormat,I18nD,I18nInjectionKey,I18nN,I18nT,NumberFormat,Translation,VERSION,castToVueI18n,createI18n,useI18n,vTDirective}; diff --git a/node_modules/vue-i18n/dist/vue-i18n.esm-bundler.js b/node_modules/vue-i18n/dist/vue-i18n.esm-bundler.js new file mode 100644 index 0000000..8885434 --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.esm-bundler.js @@ -0,0 +1 @@ +export * from '../dist/vue-i18n.mjs' \ No newline at end of file diff --git a/node_modules/vue-i18n/dist/vue-i18n.global.js b/node_modules/vue-i18n/dist/vue-i18n.global.js new file mode 100644 index 0000000..aa34e4f --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.global.js @@ -0,0 +1,6860 @@ +/*! + * vue-i18n v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +var VueI18n = (function (exports, vue) { + 'use strict'; + + function warn(msg, err) { + if (typeof console !== 'undefined') { + console.warn(`[intlify] ` + msg); + /* istanbul ignore if */ + if (err) { + console.warn(err.stack); + } + } + } + const hasWarned = {}; + function warnOnce(msg) { + if (!hasWarned[msg]) { + hasWarned[msg] = true; + warn(msg); + } + } + + /** + * Original Utilities + * written by kazuya kawaguchi + */ + const inBrowser = typeof window !== 'undefined'; + let mark; + let measure; + { + const perf = inBrowser && window.performance; + if (perf && + perf.mark && + perf.measure && + perf.clearMarks && + // @ts-ignore browser compat + perf.clearMeasures) { + mark = (tag) => { + perf.mark(tag); + }; + measure = (name, startTag, endTag) => { + perf.measure(name, startTag, endTag); + perf.clearMarks(startTag); + perf.clearMarks(endTag); + }; + } + } + const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g; + /* eslint-disable */ + function format$1(message, ...args) { + if (args.length === 1 && isObject(args[0])) { + args = args[0]; + } + if (!args || !args.hasOwnProperty) { + args = {}; + } + return message.replace(RE_ARGS, (match, identifier) => { + return args.hasOwnProperty(identifier) ? args[identifier] : ''; + }); + } + const makeSymbol = (name, shareable = false) => !shareable ? Symbol(name) : Symbol.for(name); + const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({ l: locale, k: key, s: source }); + const friendlyJSONstringify = (json) => JSON.stringify(json) + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029') + .replace(/\u0027/g, '\\u0027'); + const isNumber = (val) => typeof val === 'number' && isFinite(val); + const isDate = (val) => toTypeString(val) === '[object Date]'; + const isRegExp = (val) => toTypeString(val) === '[object RegExp]'; + const isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0; + const assign = Object.assign; + const _create = Object.create; + const create = (obj = null) => _create(obj); + let _globalThis; + const getGlobalThis = () => { + // prettier-ignore + return (_globalThis || + (_globalThis = + typeof globalThis !== 'undefined' + ? globalThis + : typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : create())); + }; + function escapeHtml(rawText) { + return rawText + .replace(/&/g, '&') // escape `&` first to avoid double escaping + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/\//g, '/') // escape `/` to prevent closing tags or JavaScript URLs + .replace(/=/g, '='); // escape `=` to prevent attribute injection + } + function escapeAttributeValue(value) { + return value + .replace(/&(?![a-zA-Z0-9#]{2,6};)/g, '&') // escape unescaped `&` + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(//g, '>'); + } + function sanitizeTranslatedHtml(html) { + // Escape dangerous characters in attribute values + // Process attributes with double quotes + html = html.replace(/(\w+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${escapeAttributeValue(attrValue)}"`); + // Process attributes with single quotes + html = html.replace(/(\w+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${escapeAttributeValue(attrValue)}'`); + // Detect and neutralize event handler attributes + const eventHandlerPattern = /\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi; + if (eventHandlerPattern.test(html)) { + { + warn('Potentially dangerous event handlers detected in translation. ' + + 'Consider removing onclick, onerror, etc. from your translation messages.'); + } + // Neutralize event handler attributes by escaping 'on' + html = html.replace(/(\s+)(on)(\w+\s*=)/gi, '$1on$3'); + } + // Disable javascript: URLs in various contexts + const javascriptUrlPattern = [ + // In href, src, action, formaction attributes + /(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi, + // In style attributes within url() + /(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi + ]; + javascriptUrlPattern.forEach(pattern => { + html = html.replace(pattern, '$1javascript:'); + }); + return html; + } + const hasOwnProperty = Object.prototype.hasOwnProperty; + function hasOwn(obj, key) { + return hasOwnProperty.call(obj, key); + } + /* eslint-enable */ + /** + * Useful Utilities By Evan you + * Modified by kazuya kawaguchi + * MIT License + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts + */ + const isArray = Array.isArray; + const isFunction = (val) => typeof val === 'function'; + const isString = (val) => typeof val === 'string'; + const isBoolean = (val) => typeof val === 'boolean'; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const isObject = (val) => val !== null && typeof val === 'object'; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const isPromise = (val) => { + return isObject(val) && isFunction(val.then) && isFunction(val.catch); + }; + const objectToString = Object.prototype.toString; + const toTypeString = (value) => objectToString.call(value); + const isPlainObject = (val) => { + if (!isObject(val)) + return false; + const proto = Object.getPrototypeOf(val); + return proto === null || proto.constructor === Object; + }; + // for converting list and named values to displayed strings. + const toDisplayString = (val) => { + return val == null + ? '' + : isArray(val) || (isPlainObject(val) && val.toString === objectToString) + ? JSON.stringify(val, null, 2) + : String(val); + }; + function join(items, separator = '') { + return items.reduce((str, item, index) => (index === 0 ? str + item : str + separator + item), ''); + } + const RANGE = 2; + function generateCodeFrame(source, start = 0, end = source.length) { + const lines = source.split(/\r?\n/); + let count = 0; + const res = []; + for (let i = 0; i < lines.length; i++) { + count += lines[i].length + 1; + if (count >= start) { + for (let j = i - RANGE; j <= i + RANGE || end > count; j++) { + if (j < 0 || j >= lines.length) + continue; + const line = j + 1; + res.push(`${line}${' '.repeat(3 - String(line).length)}| ${lines[j]}`); + const lineLength = lines[j].length; + if (j === i) { + // push underline + const pad = start - (count - lineLength) + 1; + const length = Math.max(1, end > count ? lineLength - pad : end - start); + res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length)); + } + else if (j > i) { + if (end > count) { + const length = Math.max(Math.min(end - count, lineLength), 1); + res.push(` | ` + '^'.repeat(length)); + } + count += lineLength + 1; + } + } + break; + } + } + return res.join('\n'); + } + function incrementer(code) { + let current = code; + return () => ++current; + } + + /** + * Event emitter, forked from the below: + * - original repository url: https://github.com/developit/mitt + * - code url: https://github.com/developit/mitt/blob/master/src/index.ts + * - author: Jason Miller (https://github.com/developit) + * - license: MIT + */ + /** + * Create a event emitter + * + * @returns An event emitter + */ + function createEmitter() { + const events = new Map(); + const emitter = { + events, + on(event, handler) { + const handlers = events.get(event); + const added = handlers && handlers.push(handler); + if (!added) { + events.set(event, [handler]); + } + }, + off(event, handler) { + const handlers = events.get(event); + if (handlers) { + handlers.splice(handlers.indexOf(handler) >>> 0, 1); + } + }, + emit(event, payload) { + (events.get(event) || []) + .slice() + .map(handler => handler(payload)); + (events.get('*') || []) + .slice() + .map(handler => handler(event, payload)); + } + }; + return emitter; + } + + const isNotObjectOrIsArray = (val) => !isObject(val) || isArray(val); + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + function deepCopy(src, des) { + // src and des should both be objects, and none of them can be a array + if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des)) { + throw new Error('Invalid value'); + } + const stack = [{ src, des }]; + while (stack.length) { + const { src, des } = stack.pop(); + // using `Object.keys` which skips prototype properties + Object.keys(src).forEach(key => { + if (key === '__proto__') { + return; + } + // if src[key] is an object/array, set des[key] + // to empty object/array to prevent setting by reference + if (isObject(src[key]) && !isObject(des[key])) { + des[key] = Array.isArray(src[key]) ? [] : create(); + } + if (isNotObjectOrIsArray(des[key]) || isNotObjectOrIsArray(src[key])) { + // replace with src[key] when: + // src[key] or des[key] is not an object, or + // src[key] or des[key] is an array + des[key] = src[key]; + } + else { + // src[key] and des[key] are both objects, merge them + stack.push({ src: src[key], des: des[key] }); + } + }); + } + } + + function createPosition(line, column, offset) { + return { line, column, offset }; + } + function createLocation(start, end, source) { + const loc = { start, end }; + if (source != null) { + loc.source = source; + } + return loc; + } + + const CompileWarnCodes = { + USE_MODULO_SYNTAX: 1, + __EXTEND_POINT__: 2 + }; + /** @internal */ + const warnMessages$2 = { + [CompileWarnCodes.USE_MODULO_SYNTAX]: `Use modulo before '{{0}}'.` + }; + function createCompileWarn(code, loc, ...args) { + const msg = format$1(warnMessages$2[code] || '', ...(args || [])) ; + const message = { message: String(msg), code }; + if (loc) { + message.location = loc; + } + return message; + } + + const CompileErrorCodes = { + // tokenizer error codes + EXPECTED_TOKEN: 1, + INVALID_TOKEN_IN_PLACEHOLDER: 2, + UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3, + UNKNOWN_ESCAPE_SEQUENCE: 4, + INVALID_UNICODE_ESCAPE_SEQUENCE: 5, + UNBALANCED_CLOSING_BRACE: 6, + UNTERMINATED_CLOSING_BRACE: 7, + EMPTY_PLACEHOLDER: 8, + NOT_ALLOW_NEST_PLACEHOLDER: 9, + INVALID_LINKED_FORMAT: 10, + // parser error codes + MUST_HAVE_MESSAGES_IN_PLURAL: 11, + UNEXPECTED_EMPTY_LINKED_MODIFIER: 12, + UNEXPECTED_EMPTY_LINKED_KEY: 13, + UNEXPECTED_LEXICAL_ANALYSIS: 14, + // generator error codes + UNHANDLED_CODEGEN_NODE_TYPE: 15, + // minifier error codes + UNHANDLED_MINIFIER_NODE_TYPE: 16, + // Special value for higher-order compilers to pick up the last code + // to avoid collision of error codes. This should always be kept as the last + // item. + __EXTEND_POINT__: 17 + }; + /** @internal */ + const errorMessages$2 = { + // tokenizer error messages + [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`, + [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`, + [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`, + [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`, + [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`, + [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`, + [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`, + [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`, + [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`, + [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`, + // parser error messages + [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`, + [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`, + // generator error messages + [CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`, + // minimizer error messages + [CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'` + }; + function createCompileError(code, loc, options = {}) { + const { domain, messages, args } = options; + const msg = format$1((messages || errorMessages$2)[code] || '', ...(args || [])) + ; + const error = new SyntaxError(String(msg)); + error.code = code; + if (loc) { + error.location = loc; + } + error.domain = domain; + return error; + } + /** @internal */ + function defaultOnError(error) { + throw error; + } + + // eslint-disable-next-line no-useless-escape + const RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/; + const detectHtmlTag = (source) => RE_HTML_TAG.test(source); + + const CHAR_SP = ' '; + const CHAR_CR = '\r'; + const CHAR_LF = '\n'; + const CHAR_LS = String.fromCharCode(0x2028); + const CHAR_PS = String.fromCharCode(0x2029); + function createScanner(str) { + const _buf = str; + let _index = 0; + let _line = 1; + let _column = 1; + let _peekOffset = 0; + const isCRLF = (index) => _buf[index] === CHAR_CR && _buf[index + 1] === CHAR_LF; + const isLF = (index) => _buf[index] === CHAR_LF; + const isPS = (index) => _buf[index] === CHAR_PS; + const isLS = (index) => _buf[index] === CHAR_LS; + const isLineEnd = (index) => isCRLF(index) || isLF(index) || isPS(index) || isLS(index); + const index = () => _index; + const line = () => _line; + const column = () => _column; + const peekOffset = () => _peekOffset; + const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset]; + const currentChar = () => charAt(_index); + const currentPeek = () => charAt(_index + _peekOffset); + function next() { + _peekOffset = 0; + if (isLineEnd(_index)) { + _line++; + _column = 0; + } + if (isCRLF(_index)) { + _index++; + } + _index++; + _column++; + return _buf[_index]; + } + function peek() { + if (isCRLF(_index + _peekOffset)) { + _peekOffset++; + } + _peekOffset++; + return _buf[_index + _peekOffset]; + } + function reset() { + _index = 0; + _line = 1; + _column = 1; + _peekOffset = 0; + } + function resetPeek(offset = 0) { + _peekOffset = offset; + } + function skipToPeek() { + const target = _index + _peekOffset; + // eslint-disable-next-line no-unmodified-loop-condition + while (target !== _index) { + next(); + } + _peekOffset = 0; + } + return { + index, + line, + column, + peekOffset, + charAt, + currentChar, + currentPeek, + next, + peek, + reset, + resetPeek, + skipToPeek + }; + } + + const EOF = undefined; + const DOT = '.'; + const LITERAL_DELIMITER = "'"; + const ERROR_DOMAIN$3 = 'tokenizer'; + function createTokenizer(source, options = {}) { + const location = options.location !== false; + const _scnr = createScanner(source); + const currentOffset = () => _scnr.index(); + const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index()); + const _initLoc = currentPosition(); + const _initOffset = currentOffset(); + const _context = { + currentType: 14 /* TokenTypes.EOF */, + offset: _initOffset, + startLoc: _initLoc, + endLoc: _initLoc, + lastType: 14 /* TokenTypes.EOF */, + lastOffset: _initOffset, + lastStartLoc: _initLoc, + lastEndLoc: _initLoc, + braceNest: 0, + inLinked: false, + text: '' + }; + const context = () => _context; + const { onError } = options; + function emitError(code, pos, offset, ...args) { + const ctx = context(); + pos.column += offset; + pos.offset += offset; + if (onError) { + const loc = location ? createLocation(ctx.startLoc, pos) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$3, + args + }); + onError(err); + } + } + function getToken(context, type, value) { + context.endLoc = currentPosition(); + context.currentType = type; + const token = { type }; + if (location) { + token.loc = createLocation(context.startLoc, context.endLoc); + } + if (value != null) { + token.value = value; + } + return token; + } + const getEndToken = (context) => getToken(context, 14 /* TokenTypes.EOF */); + function eat(scnr, ch) { + if (scnr.currentChar() === ch) { + scnr.next(); + return ch; + } + else { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + return ''; + } + } + function peekSpaces(scnr) { + let buf = ''; + while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) { + buf += scnr.currentPeek(); + scnr.peek(); + } + return buf; + } + function skipSpaces(scnr) { + const buf = peekSpaces(scnr); + scnr.skipToPeek(); + return buf; + } + function isIdentifierStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + cc === 95 // _ + ); + } + function isNumberStart(ch) { + if (ch === EOF) { + return false; + } + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function isNamedIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isListIdentifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ch = scnr.currentPeek() === '-' ? scnr.peek() : scnr.currentPeek(); + const ret = isNumberStart(ch); + scnr.resetPeek(); + return ret; + } + function isLiteralStart(scnr, context) { + const { currentType } = context; + if (currentType !== 2 /* TokenTypes.BraceLeft */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === LITERAL_DELIMITER; + scnr.resetPeek(); + return ret; + } + function isLinkedDotStart(scnr, context) { + const { currentType } = context; + if (currentType !== 8 /* TokenTypes.LinkedAlias */) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === "." /* TokenChars.LinkedDot */; + scnr.resetPeek(); + return ret; + } + function isLinkedModifierStart(scnr, context) { + const { currentType } = context; + if (currentType !== 9 /* TokenTypes.LinkedDot */) { + return false; + } + peekSpaces(scnr); + const ret = isIdentifierStart(scnr.currentPeek()); + scnr.resetPeek(); + return ret; + } + function isLinkedDelimiterStart(scnr, context) { + const { currentType } = context; + if (!(currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 12 /* TokenTypes.LinkedModifier */)) { + return false; + } + peekSpaces(scnr); + const ret = scnr.currentPeek() === ":" /* TokenChars.LinkedDelimiter */; + scnr.resetPeek(); + return ret; + } + function isLinkedReferStart(scnr, context) { + const { currentType } = context; + if (currentType !== 10 /* TokenTypes.LinkedDelimiter */) { + return false; + } + const fn = () => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return isIdentifierStart(scnr.peek()); + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "|" /* TokenChars.Pipe */ || + ch === ":" /* TokenChars.LinkedDelimiter */ || + ch === "." /* TokenChars.LinkedDot */ || + ch === CHAR_SP || + !ch) { + return false; + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(); + } + else { + // other characters + return isTextStart(scnr, false); + } + }; + const ret = fn(); + scnr.resetPeek(); + return ret; + } + function isPluralStart(scnr) { + peekSpaces(scnr); + const ret = scnr.currentPeek() === "|" /* TokenChars.Pipe */; + scnr.resetPeek(); + return ret; + } + function detectModuloStart(scnr) { + const spaces = peekSpaces(scnr); + const ret = scnr.currentPeek() === "%" /* TokenChars.Modulo */ && + scnr.peek() === "{" /* TokenChars.BraceLeft */; + scnr.resetPeek(); + return { + isModulo: ret, + hasSpace: spaces.length > 0 + }; + } + function isTextStart(scnr, reset = true) { + const fn = (hasSpace = false, prev = '', detectModulo = false) => { + const ch = scnr.currentPeek(); + if (ch === "{" /* TokenChars.BraceLeft */) { + return prev === "%" /* TokenChars.Modulo */ ? false : hasSpace; + } + else if (ch === "@" /* TokenChars.LinkedAlias */ || !ch) { + return prev === "%" /* TokenChars.Modulo */ ? true : hasSpace; + } + else if (ch === "%" /* TokenChars.Modulo */) { + scnr.peek(); + return fn(hasSpace, "%" /* TokenChars.Modulo */, true); + } + else if (ch === "|" /* TokenChars.Pipe */) { + return prev === "%" /* TokenChars.Modulo */ || detectModulo + ? true + : !(prev === CHAR_SP || prev === CHAR_LF); + } + else if (ch === CHAR_SP) { + scnr.peek(); + return fn(true, CHAR_SP, detectModulo); + } + else if (ch === CHAR_LF) { + scnr.peek(); + return fn(true, CHAR_LF, detectModulo); + } + else { + return true; + } + }; + const ret = fn(); + reset && scnr.resetPeek(); + return ret; + } + function takeChar(scnr, fn) { + const ch = scnr.currentChar(); + if (ch === EOF) { + return EOF; + } + if (fn(ch)) { + scnr.next(); + return ch; + } + return null; + } + function isIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 // $ + ); + } + function takeIdentifierChar(scnr) { + return takeChar(scnr, isIdentifier); + } + function isNamedIdentifier(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 97 && cc <= 122) || // a-z + (cc >= 65 && cc <= 90) || // A-Z + (cc >= 48 && cc <= 57) || // 0-9 + cc === 95 || // _ + cc === 36 || // $ + cc === 45 // - + ); + } + function takeNamedIdentifierChar(scnr) { + return takeChar(scnr, isNamedIdentifier); + } + function isDigit(ch) { + const cc = ch.charCodeAt(0); + return cc >= 48 && cc <= 57; // 0-9 + } + function takeDigit(scnr) { + return takeChar(scnr, isDigit); + } + function isHexDigit(ch) { + const cc = ch.charCodeAt(0); + return ((cc >= 48 && cc <= 57) || // 0-9 + (cc >= 65 && cc <= 70) || // A-F + (cc >= 97 && cc <= 102)); // a-f + } + function takeHexDigit(scnr) { + return takeChar(scnr, isHexDigit); + } + function getDigits(scnr) { + let ch = ''; + let num = ''; + while ((ch = takeDigit(scnr))) { + num += ch; + } + return num; + } + function readModulo(scnr) { + skipSpaces(scnr); + const ch = scnr.currentChar(); + if (ch !== "%" /* TokenChars.Modulo */) { + emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch); + } + scnr.next(); + return "%" /* TokenChars.Modulo */; + } + function readText(scnr) { + let buf = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "}" /* TokenChars.BraceRight */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + !ch) { + break; + } + else if (ch === "%" /* TokenChars.Modulo */) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else { + break; + } + } + else if (ch === CHAR_SP || ch === CHAR_LF) { + if (isTextStart(scnr)) { + buf += ch; + scnr.next(); + } + else if (isPluralStart(scnr)) { + break; + } + else { + buf += ch; + scnr.next(); + } + } + else { + buf += ch; + scnr.next(); + } + } + return buf; + } + function readNamedIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let name = ''; + while ((ch = takeNamedIdentifierChar(scnr))) { + name += ch; + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return name; + } + function readListIdentifier(scnr) { + skipSpaces(scnr); + let value = ''; + if (scnr.currentChar() === '-') { + scnr.next(); + value += `-${getDigits(scnr)}`; + } + else { + value += getDigits(scnr); + } + if (scnr.currentChar() === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + return value; + } + function isLiteral(ch) { + return ch !== LITERAL_DELIMITER && ch !== CHAR_LF; + } + function readLiteral(scnr) { + skipSpaces(scnr); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + let ch = ''; + let literal = ''; + while ((ch = takeChar(scnr, isLiteral))) { + if (ch === '\\') { + literal += readEscapeSequence(scnr); + } + else { + literal += ch; + } + } + const current = scnr.currentChar(); + if (current === CHAR_LF || current === EOF) { + emitError(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, currentPosition(), 0); + // TODO: Is it correct really? + if (current === CHAR_LF) { + scnr.next(); + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + } + return literal; + } + // eslint-disable-next-line no-useless-escape + eat(scnr, `\'`); + return literal; + } + function readEscapeSequence(scnr) { + const ch = scnr.currentChar(); + switch (ch) { + case '\\': + case `\'`: // eslint-disable-line no-useless-escape + scnr.next(); + return `\\${ch}`; + case 'u': + return readUnicodeEscapeSequence(scnr, ch, 4); + case 'U': + return readUnicodeEscapeSequence(scnr, ch, 6); + default: + emitError(CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, currentPosition(), 0, ch); + return ''; + } + } + function readUnicodeEscapeSequence(scnr, unicode, digits) { + eat(scnr, unicode); + let sequence = ''; + for (let i = 0; i < digits; i++) { + const ch = takeHexDigit(scnr); + if (!ch) { + emitError(CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`); + break; + } + sequence += ch; + } + return `\\${unicode}${sequence}`; + } + function isInvalidIdentifier(ch) { + return (ch !== "{" /* TokenChars.BraceLeft */ && + ch !== "}" /* TokenChars.BraceRight */ && + ch !== CHAR_SP && + ch !== CHAR_LF); + } + function readInvalidIdentifier(scnr) { + skipSpaces(scnr); + let ch = ''; + let identifiers = ''; + while ((ch = takeChar(scnr, isInvalidIdentifier))) { + identifiers += ch; + } + return identifiers; + } + function readLinkedModifier(scnr) { + let ch = ''; + let name = ''; + while ((ch = takeIdentifierChar(scnr))) { + name += ch; + } + return name; + } + function readLinkedRefer(scnr) { + const fn = (buf) => { + const ch = scnr.currentChar(); + if (ch === "{" /* TokenChars.BraceLeft */ || + ch === "%" /* TokenChars.Modulo */ || + ch === "@" /* TokenChars.LinkedAlias */ || + ch === "|" /* TokenChars.Pipe */ || + ch === "(" /* TokenChars.ParenLeft */ || + ch === ")" /* TokenChars.ParenRight */ || + !ch) { + return buf; + } + else if (ch === CHAR_SP) { + return buf; + } + else if (ch === CHAR_LF || ch === DOT) { + buf += ch; + scnr.next(); + return fn(buf); + } + else { + buf += ch; + scnr.next(); + return fn(buf); + } + }; + return fn(''); + } + function readPlural(scnr) { + skipSpaces(scnr); + const plural = eat(scnr, "|" /* TokenChars.Pipe */); + skipSpaces(scnr); + return plural; + } + // TODO: We need refactoring of token parsing ... + function readTokenInPlaceholder(scnr, context) { + let token = null; + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + if (context.braceNest >= 1) { + emitError(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 2 /* TokenTypes.BraceLeft */, "{" /* TokenChars.BraceLeft */); + skipSpaces(scnr); + context.braceNest++; + return token; + case "}" /* TokenChars.BraceRight */: + if (context.braceNest > 0 && + context.currentType === 2 /* TokenTypes.BraceLeft */) { + emitError(CompileErrorCodes.EMPTY_PLACEHOLDER, currentPosition(), 0); + } + scnr.next(); + token = getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + context.braceNest--; + context.braceNest > 0 && skipSpaces(scnr); + if (context.inLinked && context.braceNest === 0) { + context.inLinked = false; + } + return token; + case "@" /* TokenChars.LinkedAlias */: + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = readTokenInLinked(scnr, context) || getEndToken(context); + context.braceNest = 0; + return token; + default: { + let validNamedIdentifier = true; + let validListIdentifier = true; + let validLiteral = true; + if (isPluralStart(scnr)) { + if (context.braceNest > 0) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + } + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (context.braceNest > 0 && + (context.currentType === 5 /* TokenTypes.Named */ || + context.currentType === 6 /* TokenTypes.List */ || + context.currentType === 7 /* TokenTypes.Literal */)) { + emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0); + context.braceNest = 0; + return readToken(scnr, context); + } + if ((validNamedIdentifier = isNamedIdentifierStart(scnr, context))) { + token = getToken(context, 5 /* TokenTypes.Named */, readNamedIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validListIdentifier = isListIdentifierStart(scnr, context))) { + token = getToken(context, 6 /* TokenTypes.List */, readListIdentifier(scnr)); + skipSpaces(scnr); + return token; + } + if ((validLiteral = isLiteralStart(scnr, context))) { + token = getToken(context, 7 /* TokenTypes.Literal */, readLiteral(scnr)); + skipSpaces(scnr); + return token; + } + if (!validNamedIdentifier && !validListIdentifier && !validLiteral) { + // TODO: we should be re-designed invalid cases, when we will extend message syntax near the future ... + token = getToken(context, 13 /* TokenTypes.InvalidPlace */, readInvalidIdentifier(scnr)); + emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value); + skipSpaces(scnr); + return token; + } + break; + } + } + return token; + } + // TODO: We need refactoring of token parsing ... + function readTokenInLinked(scnr, context) { + const { currentType } = context; + let token = null; + const ch = scnr.currentChar(); + if ((currentType === 8 /* TokenTypes.LinkedAlias */ || + currentType === 9 /* TokenTypes.LinkedDot */ || + currentType === 12 /* TokenTypes.LinkedModifier */ || + currentType === 10 /* TokenTypes.LinkedDelimiter */) && + (ch === CHAR_LF || ch === CHAR_SP)) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + switch (ch) { + case "@" /* TokenChars.LinkedAlias */: + scnr.next(); + token = getToken(context, 8 /* TokenTypes.LinkedAlias */, "@" /* TokenChars.LinkedAlias */); + context.inLinked = true; + return token; + case "." /* TokenChars.LinkedDot */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 9 /* TokenTypes.LinkedDot */, "." /* TokenChars.LinkedDot */); + case ":" /* TokenChars.LinkedDelimiter */: + skipSpaces(scnr); + scnr.next(); + return getToken(context, 10 /* TokenTypes.LinkedDelimiter */, ":" /* TokenChars.LinkedDelimiter */); + default: + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + if (isLinkedDotStart(scnr, context) || + isLinkedDelimiterStart(scnr, context)) { + skipSpaces(scnr); + return readTokenInLinked(scnr, context); + } + if (isLinkedModifierStart(scnr, context)) { + skipSpaces(scnr); + return getToken(context, 12 /* TokenTypes.LinkedModifier */, readLinkedModifier(scnr)); + } + if (isLinkedReferStart(scnr, context)) { + skipSpaces(scnr); + if (ch === "{" /* TokenChars.BraceLeft */) { + // scan the placeholder + return readTokenInPlaceholder(scnr, context) || token; + } + else { + return getToken(context, 11 /* TokenTypes.LinkedKey */, readLinkedRefer(scnr)); + } + } + if (currentType === 8 /* TokenTypes.LinkedAlias */) { + emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0); + } + context.braceNest = 0; + context.inLinked = false; + return readToken(scnr, context); + } + } + // TODO: We need refactoring of token parsing ... + function readToken(scnr, context) { + let token = { type: 14 /* TokenTypes.EOF */ }; + if (context.braceNest > 0) { + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + } + if (context.inLinked) { + return readTokenInLinked(scnr, context) || getEndToken(context); + } + const ch = scnr.currentChar(); + switch (ch) { + case "{" /* TokenChars.BraceLeft */: + return readTokenInPlaceholder(scnr, context) || getEndToken(context); + case "}" /* TokenChars.BraceRight */: + emitError(CompileErrorCodes.UNBALANCED_CLOSING_BRACE, currentPosition(), 0); + scnr.next(); + return getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */); + case "@" /* TokenChars.LinkedAlias */: + return readTokenInLinked(scnr, context) || getEndToken(context); + default: { + if (isPluralStart(scnr)) { + token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr)); + // reset + context.braceNest = 0; + context.inLinked = false; + return token; + } + const { isModulo, hasSpace } = detectModuloStart(scnr); + if (isModulo) { + return hasSpace + ? getToken(context, 0 /* TokenTypes.Text */, readText(scnr)) + : getToken(context, 4 /* TokenTypes.Modulo */, readModulo(scnr)); + } + if (isTextStart(scnr)) { + return getToken(context, 0 /* TokenTypes.Text */, readText(scnr)); + } + break; + } + } + return token; + } + function nextToken() { + const { currentType, offset, startLoc, endLoc } = _context; + _context.lastType = currentType; + _context.lastOffset = offset; + _context.lastStartLoc = startLoc; + _context.lastEndLoc = endLoc; + _context.offset = currentOffset(); + _context.startLoc = currentPosition(); + if (_scnr.currentChar() === EOF) { + return getToken(_context, 14 /* TokenTypes.EOF */); + } + return readToken(_scnr, _context); + } + return { + nextToken, + currentOffset, + currentPosition, + context + }; + } + + const ERROR_DOMAIN$2 = 'parser'; + // Backslash backslash, backslash quote, uHHHH, UHHHHHH. + const KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g; + function fromEscapeSequence(match, codePoint4, codePoint6) { + switch (match) { + case `\\\\`: + return `\\`; + // eslint-disable-next-line no-useless-escape + case `\\\'`: + // eslint-disable-next-line no-useless-escape + return `\'`; + default: { + const codePoint = parseInt(codePoint4 || codePoint6, 16); + if (codePoint <= 0xd7ff || codePoint >= 0xe000) { + return String.fromCodePoint(codePoint); + } + // invalid ... + // Replace them with U+FFFD REPLACEMENT CHARACTER. + return '�'; + } + } + } + function createParser(options = {}) { + const location = options.location !== false; + const { onError, onWarn } = options; + function emitError(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onError) { + const loc = location ? createLocation(start, end) : null; + const err = createCompileError(code, loc, { + domain: ERROR_DOMAIN$2, + args + }); + onError(err); + } + } + function emitWarn(tokenzer, code, start, offset, ...args) { + const end = tokenzer.currentPosition(); + end.offset += offset; + end.column += offset; + if (onWarn) { + const loc = location ? createLocation(start, end) : null; + onWarn(createCompileWarn(code, loc, args)); + } + } + function startNode(type, offset, loc) { + const node = { type }; + if (location) { + node.start = offset; + node.end = offset; + node.loc = { start: loc, end: loc }; + } + return node; + } + function endNode(node, offset, pos, type) { + if (type) { + node.type = type; + } + if (location) { + node.end = offset; + if (node.loc) { + node.loc.end = pos; + } + } + } + function parseText(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(3 /* NodeTypes.Text */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseList(tokenizer, index) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(5 /* NodeTypes.List */, offset, loc); + node.index = parseInt(index, 10); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseNamed(tokenizer, key, modulo) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(4 /* NodeTypes.Named */, offset, loc); + node.key = key; + if (modulo === true) { + node.modulo = true; + } + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLiteral(tokenizer, value) { + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc + const node = startNode(9 /* NodeTypes.Literal */, offset, loc); + node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence); + tokenizer.nextToken(); // skip brach right + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinkedModifier(tokenizer) { + const token = tokenizer.nextToken(); + const context = tokenizer.context(); + const { lastOffset: offset, lastStartLoc: loc } = context; // get linked dot loc + const node = startNode(8 /* NodeTypes.LinkedModifier */, offset, loc); + if (token.type !== 12 /* TokenTypes.LinkedModifier */) { + // empty modifier + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0); + node.value = ''; + endNode(node, offset, loc); + return { + nextConsumeToken: token, + node + }; + } + // check token + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.value = token.value || ''; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node + }; + } + function parseLinkedKey(tokenizer, value) { + const context = tokenizer.context(); + const node = startNode(7 /* NodeTypes.LinkedKey */, context.offset, context.startLoc); + node.value = value; + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseLinked(tokenizer) { + const context = tokenizer.context(); + const linkedNode = startNode(6 /* NodeTypes.Linked */, context.offset, context.startLoc); + let token = tokenizer.nextToken(); + if (token.type === 9 /* TokenTypes.LinkedDot */) { + const parsed = parseLinkedModifier(tokenizer); + linkedNode.modifier = parsed.node; + token = parsed.nextConsumeToken || tokenizer.nextToken(); + } + // asset check token + if (token.type !== 10 /* TokenTypes.LinkedDelimiter */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + token = tokenizer.nextToken(); + // skip brace left + if (token.type === 2 /* TokenTypes.BraceLeft */) { + token = tokenizer.nextToken(); + } + switch (token.type) { + case 11 /* TokenTypes.LinkedKey */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseNamed(tokenizer, token.value || ''); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseList(tokenizer, token.value || ''); + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + linkedNode.key = parseLiteral(tokenizer, token.value || ''); + break; + default: { + // empty key + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0); + const nextContext = tokenizer.context(); + const emptyLinkedKeyNode = startNode(7 /* NodeTypes.LinkedKey */, nextContext.offset, nextContext.startLoc); + emptyLinkedKeyNode.value = ''; + endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc); + linkedNode.key = emptyLinkedKeyNode; + endNode(linkedNode, nextContext.offset, nextContext.startLoc); + return { + nextConsumeToken: token, + node: linkedNode + }; + } + } + endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition()); + return { + node: linkedNode + }; + } + function parseMessage(tokenizer) { + const context = tokenizer.context(); + const startOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? tokenizer.currentOffset() + : context.offset; + const startLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.endLoc + : context.startLoc; + const node = startNode(2 /* NodeTypes.Message */, startOffset, startLoc); + node.items = []; + let nextToken = null; + let modulo = null; + do { + const token = nextToken || tokenizer.nextToken(); + nextToken = null; + switch (token.type) { + case 0 /* TokenTypes.Text */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseText(tokenizer, token.value || '')); + break; + case 6 /* TokenTypes.List */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseList(tokenizer, token.value || '')); + break; + case 4 /* TokenTypes.Modulo */: + modulo = true; + break; + case 5 /* TokenTypes.Named */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseNamed(tokenizer, token.value || '', !!modulo)); + if (modulo) { + emitWarn(tokenizer, CompileWarnCodes.USE_MODULO_SYNTAX, context.lastStartLoc, 0, getTokenCaption(token)); + modulo = null; + } + break; + case 7 /* TokenTypes.Literal */: + if (token.value == null) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token)); + } + node.items.push(parseLiteral(tokenizer, token.value || '')); + break; + case 8 /* TokenTypes.LinkedAlias */: { + const parsed = parseLinked(tokenizer); + node.items.push(parsed.node); + nextToken = parsed.nextConsumeToken || null; + break; + } + } + } while (context.currentType !== 14 /* TokenTypes.EOF */ && + context.currentType !== 1 /* TokenTypes.Pipe */); + // adjust message node loc + const endOffset = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastOffset + : tokenizer.currentOffset(); + const endLoc = context.currentType === 1 /* TokenTypes.Pipe */ + ? context.lastEndLoc + : tokenizer.currentPosition(); + endNode(node, endOffset, endLoc); + return node; + } + function parsePlural(tokenizer, offset, loc, msgNode) { + const context = tokenizer.context(); + let hasEmptyMessage = msgNode.items.length === 0; + const node = startNode(1 /* NodeTypes.Plural */, offset, loc); + node.cases = []; + node.cases.push(msgNode); + do { + const msg = parseMessage(tokenizer); + if (!hasEmptyMessage) { + hasEmptyMessage = msg.items.length === 0; + } + node.cases.push(msg); + } while (context.currentType !== 14 /* TokenTypes.EOF */); + if (hasEmptyMessage) { + emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + function parseResource(tokenizer) { + const context = tokenizer.context(); + const { offset, startLoc } = context; + const msgNode = parseMessage(tokenizer); + if (context.currentType === 14 /* TokenTypes.EOF */) { + return msgNode; + } + else { + return parsePlural(tokenizer, offset, startLoc, msgNode); + } + } + function parse(source) { + const tokenizer = createTokenizer(source, assign({}, options)); + const context = tokenizer.context(); + const node = startNode(0 /* NodeTypes.Resource */, context.offset, context.startLoc); + if (location && node.loc) { + node.loc.source = source; + } + node.body = parseResource(tokenizer); + if (options.onCacheKey) { + node.cacheKey = options.onCacheKey(source); + } + // assert whether achieved to EOF + if (context.currentType !== 14 /* TokenTypes.EOF */) { + emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || ''); + } + endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); + return node; + } + return { parse }; + } + function getTokenCaption(token) { + if (token.type === 14 /* TokenTypes.EOF */) { + return 'EOF'; + } + const name = (token.value || '').replace(/\r?\n/gu, '\\n'); + return name.length > 10 ? name.slice(0, 9) + '…' : name; + } + + function createTransformer(ast, options = {} // eslint-disable-line + ) { + const _context = { + ast, + helpers: new Set() + }; + const context = () => _context; + const helper = (name) => { + _context.helpers.add(name); + return name; + }; + return { context, helper }; + } + function traverseNodes(nodes, transformer) { + for (let i = 0; i < nodes.length; i++) { + traverseNode(nodes[i], transformer); + } + } + function traverseNode(node, transformer) { + // TODO: if we need pre-hook of transform, should be implemented to here + switch (node.type) { + case 1 /* NodeTypes.Plural */: + traverseNodes(node.cases, transformer); + transformer.helper("plural" /* HelperNameMap.PLURAL */); + break; + case 2 /* NodeTypes.Message */: + traverseNodes(node.items, transformer); + break; + case 6 /* NodeTypes.Linked */: { + const linked = node; + traverseNode(linked.key, transformer); + transformer.helper("linked" /* HelperNameMap.LINKED */); + transformer.helper("type" /* HelperNameMap.TYPE */); + break; + } + case 5 /* NodeTypes.List */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("list" /* HelperNameMap.LIST */); + break; + case 4 /* NodeTypes.Named */: + transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */); + transformer.helper("named" /* HelperNameMap.NAMED */); + break; + } + // TODO: if we need post-hook of transform, should be implemented to here + } + // transform AST + function transform(ast, options = {} // eslint-disable-line + ) { + const transformer = createTransformer(ast); + transformer.helper("normalize" /* HelperNameMap.NORMALIZE */); + // traverse + ast.body && traverseNode(ast.body, transformer); + // set meta information + const context = transformer.context(); + ast.helpers = Array.from(context.helpers); + } + + function optimize(ast) { + const body = ast.body; + if (body.type === 2 /* NodeTypes.Message */) { + optimizeMessageNode(body); + } + else { + body.cases.forEach(c => optimizeMessageNode(c)); + } + return ast; + } + function optimizeMessageNode(message) { + if (message.items.length === 1) { + const item = message.items[0]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + message.static = item.value; + delete item.value; // optimization for size + } + } + else { + const values = []; + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (!(item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */)) { + break; + } + if (item.value == null) { + break; + } + values.push(item.value); + } + if (values.length === message.items.length) { + message.static = join(values); + for (let i = 0; i < message.items.length; i++) { + const item = message.items[i]; + if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) { + delete item.value; // optimization for size + } + } + } + } + } + + const ERROR_DOMAIN$1 = 'minifier'; + /* eslint-disable @typescript-eslint/no-explicit-any */ + function minify(node) { + node.t = node.type; + switch (node.type) { + case 0 /* NodeTypes.Resource */: { + const resource = node; + minify(resource.body); + resource.b = resource.body; + delete resource.body; + break; + } + case 1 /* NodeTypes.Plural */: { + const plural = node; + const cases = plural.cases; + for (let i = 0; i < cases.length; i++) { + minify(cases[i]); + } + plural.c = cases; + delete plural.cases; + break; + } + case 2 /* NodeTypes.Message */: { + const message = node; + const items = message.items; + for (let i = 0; i < items.length; i++) { + minify(items[i]); + } + message.i = items; + delete message.items; + if (message.static) { + message.s = message.static; + delete message.static; + } + break; + } + case 3 /* NodeTypes.Text */: + case 9 /* NodeTypes.Literal */: + case 8 /* NodeTypes.LinkedModifier */: + case 7 /* NodeTypes.LinkedKey */: { + const valueNode = node; + if (valueNode.value) { + valueNode.v = valueNode.value; + delete valueNode.value; + } + break; + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + minify(linked.key); + linked.k = linked.key; + delete linked.key; + if (linked.modifier) { + minify(linked.modifier); + linked.m = linked.modifier; + delete linked.modifier; + } + break; + } + case 5 /* NodeTypes.List */: { + const list = node; + list.i = list.index; + delete list.index; + break; + } + case 4 /* NodeTypes.Named */: { + const named = node; + named.k = named.key; + delete named.key; + break; + } + default: + { + throw createCompileError(CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE, null, { + domain: ERROR_DOMAIN$1, + args: [node.type] + }); + } + } + delete node.type; + } + /* eslint-enable @typescript-eslint/no-explicit-any */ + + // eslint-disable-next-line @typescript-eslint/triple-slash-reference + /// + const ERROR_DOMAIN = 'parser'; + function createCodeGenerator(ast, options) { + const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options; + const location = options.location !== false; + const _context = { + filename, + code: '', + column: 1, + line: 1, + offset: 0, + map: undefined, + breakLineCode, + needIndent: _needIndent, + indentLevel: 0 + }; + if (location && ast.loc) { + _context.source = ast.loc.source; + } + const context = () => _context; + function push(code, node) { + _context.code += code; + } + function _newline(n, withBreakLine = true) { + const _breakLineCode = withBreakLine ? breakLineCode : ''; + push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode); + } + function indent(withNewLine = true) { + const level = ++_context.indentLevel; + withNewLine && _newline(level); + } + function deindent(withNewLine = true) { + const level = --_context.indentLevel; + withNewLine && _newline(level); + } + function newline() { + _newline(_context.indentLevel); + } + const helper = (key) => `_${key}`; + const needIndent = () => _context.needIndent; + return { + context, + push, + indent, + deindent, + newline, + helper, + needIndent + }; + } + function generateLinkedNode(generator, node) { + const { helper } = generator; + generator.push(`${helper("linked" /* HelperNameMap.LINKED */)}(`); + generateNode(generator, node.key); + if (node.modifier) { + generator.push(`, `); + generateNode(generator, node.modifier); + generator.push(`, _type`); + } + else { + generator.push(`, undefined, _type`); + } + generator.push(`)`); + } + function generateMessageNode(generator, node) { + const { helper, needIndent } = generator; + generator.push(`${helper("normalize" /* HelperNameMap.NORMALIZE */)}([`); + generator.indent(needIndent()); + const length = node.items.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.items[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push('])'); + } + function generatePluralNode(generator, node) { + const { helper, needIndent } = generator; + if (node.cases.length > 1) { + generator.push(`${helper("plural" /* HelperNameMap.PLURAL */)}([`); + generator.indent(needIndent()); + const length = node.cases.length; + for (let i = 0; i < length; i++) { + generateNode(generator, node.cases[i]); + if (i === length - 1) { + break; + } + generator.push(', '); + } + generator.deindent(needIndent()); + generator.push(`])`); + } + } + function generateResource(generator, node) { + if (node.body) { + generateNode(generator, node.body); + } + else { + generator.push('null'); + } + } + function generateNode(generator, node) { + const { helper } = generator; + switch (node.type) { + case 0 /* NodeTypes.Resource */: + generateResource(generator, node); + break; + case 1 /* NodeTypes.Plural */: + generatePluralNode(generator, node); + break; + case 2 /* NodeTypes.Message */: + generateMessageNode(generator, node); + break; + case 6 /* NodeTypes.Linked */: + generateLinkedNode(generator, node); + break; + case 8 /* NodeTypes.LinkedModifier */: + generator.push(JSON.stringify(node.value), node); + break; + case 7 /* NodeTypes.LinkedKey */: + generator.push(JSON.stringify(node.value), node); + break; + case 5 /* NodeTypes.List */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("list" /* HelperNameMap.LIST */)}(${node.index}))`, node); + break; + case 4 /* NodeTypes.Named */: + generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("named" /* HelperNameMap.NAMED */)}(${JSON.stringify(node.key)}))`, node); + break; + case 9 /* NodeTypes.Literal */: + generator.push(JSON.stringify(node.value), node); + break; + case 3 /* NodeTypes.Text */: + generator.push(JSON.stringify(node.value), node); + break; + default: + { + throw createCompileError(CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE, null, { + domain: ERROR_DOMAIN, + args: [node.type] + }); + } + } + } + // generate code from AST + const generate = (ast, options = {} // eslint-disable-line + ) => { + const mode = isString(options.mode) ? options.mode : 'normal'; + const filename = isString(options.filename) + ? options.filename + : 'message.intl'; + const sourceMap = !!options.sourceMap; + // prettier-ignore + const breakLineCode = options.breakLineCode != null + ? options.breakLineCode + : mode === 'arrow' + ? ';' + : '\n'; + const needIndent = options.needIndent ? options.needIndent : mode !== 'arrow'; + const helpers = ast.helpers || []; + const generator = createCodeGenerator(ast, { + mode, + filename, + sourceMap, + breakLineCode, + needIndent + }); + generator.push(mode === 'normal' ? `function __msg__ (ctx) {` : `(ctx) => {`); + generator.indent(needIndent); + if (helpers.length > 0) { + generator.push(`const { ${join(helpers.map(s => `${s}: _${s}`), ', ')} } = ctx`); + generator.newline(); + } + generator.push(`return `); + generateNode(generator, ast); + generator.deindent(needIndent); + generator.push(`}`); + delete ast.helpers; + const { code, map } = generator.context(); + return { + ast, + code, + map: map ? map.toJSON() : undefined // eslint-disable-line @typescript-eslint/no-explicit-any + }; + }; + + function baseCompile$1(source, options = {}) { + const assignedOptions = assign({}, options); + const jit = !!assignedOptions.jit; + const enalbeMinify = !!assignedOptions.minify; + const enambeOptimize = assignedOptions.optimize == null ? true : assignedOptions.optimize; + // parse source codes + const parser = createParser(assignedOptions); + const ast = parser.parse(source); + if (!jit) { + // transform ASTs + transform(ast, assignedOptions); + // generate javascript codes + return generate(ast, assignedOptions); + } + else { + // optimize ASTs + enambeOptimize && optimize(ast); + // minimize ASTs + enalbeMinify && minify(ast); + // In JIT mode, no ast transform, no code generation. + return { ast, code: '' }; + } + } + + function isMessageAST(val) { + return (isObject(val) && + resolveType(val) === 0 && + (hasOwn(val, 'b') || hasOwn(val, 'body'))); + } + const PROPS_BODY = ['b', 'body']; + function resolveBody(node) { + return resolveProps(node, PROPS_BODY); + } + const PROPS_CASES = ['c', 'cases']; + function resolveCases(node) { + return resolveProps(node, PROPS_CASES, []); + } + const PROPS_STATIC = ['s', 'static']; + function resolveStatic(node) { + return resolveProps(node, PROPS_STATIC); + } + const PROPS_ITEMS = ['i', 'items']; + function resolveItems(node) { + return resolveProps(node, PROPS_ITEMS, []); + } + const PROPS_TYPE = ['t', 'type']; + function resolveType(node) { + return resolveProps(node, PROPS_TYPE); + } + const PROPS_VALUE = ['v', 'value']; + function resolveValue$1(node, type) { + const resolved = resolveProps(node, PROPS_VALUE); + if (resolved != null) { + return resolved; + } + else { + throw createUnhandleNodeError(type); + } + } + const PROPS_MODIFIER = ['m', 'modifier']; + function resolveLinkedModifier(node) { + return resolveProps(node, PROPS_MODIFIER); + } + const PROPS_KEY = ['k', 'key']; + function resolveLinkedKey(node) { + const resolved = resolveProps(node, PROPS_KEY); + if (resolved) { + return resolved; + } + else { + throw createUnhandleNodeError(6 /* NodeTypes.Linked */); + } + } + function resolveProps(node, props, defaultValue) { + for (let i = 0; i < props.length; i++) { + const prop = props[i]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (hasOwn(node, prop) && node[prop] != null) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return node[prop]; + } + } + return defaultValue; + } + const AST_NODE_PROPS_KEYS = [ + ...PROPS_BODY, + ...PROPS_CASES, + ...PROPS_STATIC, + ...PROPS_ITEMS, + ...PROPS_KEY, + ...PROPS_MODIFIER, + ...PROPS_VALUE, + ...PROPS_TYPE + ]; + function createUnhandleNodeError(type) { + return new Error(`unhandled node type: ${type}`); + } + + const pathStateMachine = []; + pathStateMachine[0 /* States.BEFORE_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [0 /* States.BEFORE_PATH */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] + }; + pathStateMachine[1 /* States.IN_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] + }; + pathStateMachine[2 /* States.BEFORE_IDENT */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [2 /* States.BEFORE_IDENT */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */] + }; + pathStateMachine[3 /* States.IN_IDENT */] = { + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */, 1 /* Actions.PUSH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */, 1 /* Actions.PUSH */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */, 1 /* Actions.PUSH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */, 1 /* Actions.PUSH */] + }; + pathStateMachine[4 /* States.IN_SUB_PATH */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */], + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [ + 4 /* States.IN_SUB_PATH */, + 2 /* Actions.INC_SUB_PATH_DEPTH */ + ], + ["]" /* PathCharTypes.RIGHT_BRACKET */]: [1 /* States.IN_PATH */, 3 /* Actions.PUSH_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */] + }; + pathStateMachine[5 /* States.IN_SINGLE_QUOTE */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */] + }; + pathStateMachine[6 /* States.IN_DOUBLE_QUOTE */] = { + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */] + }; + /** + * Check if an expression is a literal value. + */ + const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/; + function isLiteral(exp) { + return literalValueRE.test(exp); + } + /** + * Strip quotes from a string + */ + function stripQuotes(str) { + const a = str.charCodeAt(0); + const b = str.charCodeAt(str.length - 1); + return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str; + } + /** + * Determine the type of a character in a keypath. + */ + function getPathCharType(ch) { + if (ch === undefined || ch === null) { + return "o" /* PathCharTypes.END_OF_FAIL */; + } + const code = ch.charCodeAt(0); + switch (code) { + case 0x5b: // [ + case 0x5d: // ] + case 0x2e: // . + case 0x22: // " + case 0x27: // ' + return ch; + case 0x5f: // _ + case 0x24: // $ + case 0x2d: // - + return "i" /* PathCharTypes.IDENT */; + case 0x09: // Tab (HT) + case 0x0a: // Newline (LF) + case 0x0d: // Return (CR) + case 0xa0: // No-break space (NBSP) + case 0xfeff: // Byte Order Mark (BOM) + case 0x2028: // Line Separator (LS) + case 0x2029: // Paragraph Separator (PS) + return "w" /* PathCharTypes.WORKSPACE */; + } + return "i" /* PathCharTypes.IDENT */; + } + /** + * Format a subPath, return its plain form if it is + * a literal string or number. Otherwise prepend the + * dynamic indicator (*). + */ + function formatSubPath(path) { + const trimmed = path.trim(); + // invalid leading 0 + if (path.charAt(0) === '0' && isNaN(parseInt(path))) { + return false; + } + return isLiteral(trimmed) + ? stripQuotes(trimmed) + : "*" /* PathCharTypes.ASTARISK */ + trimmed; + } + /** + * Parse a string path into an array of segments + */ + function parse(path) { + const keys = []; + let index = -1; + let mode = 0 /* States.BEFORE_PATH */; + let subPathDepth = 0; + let c; + let key; // eslint-disable-line + let newChar; + let type; + let transition; + let action; + let typeMap; + const actions = []; + actions[0 /* Actions.APPEND */] = () => { + if (key === undefined) { + key = newChar; + } + else { + key += newChar; + } + }; + actions[1 /* Actions.PUSH */] = () => { + if (key !== undefined) { + keys.push(key); + key = undefined; + } + }; + actions[2 /* Actions.INC_SUB_PATH_DEPTH */] = () => { + actions[0 /* Actions.APPEND */](); + subPathDepth++; + }; + actions[3 /* Actions.PUSH_SUB_PATH */] = () => { + if (subPathDepth > 0) { + subPathDepth--; + mode = 4 /* States.IN_SUB_PATH */; + actions[0 /* Actions.APPEND */](); + } + else { + subPathDepth = 0; + if (key === undefined) { + return false; + } + key = formatSubPath(key); + if (key === false) { + return false; + } + else { + actions[1 /* Actions.PUSH */](); + } + } + }; + function maybeUnescapeQuote() { + const nextChar = path[index + 1]; + if ((mode === 5 /* States.IN_SINGLE_QUOTE */ && + nextChar === "'" /* PathCharTypes.SINGLE_QUOTE */) || + (mode === 6 /* States.IN_DOUBLE_QUOTE */ && + nextChar === "\"" /* PathCharTypes.DOUBLE_QUOTE */)) { + index++; + newChar = '\\' + nextChar; + actions[0 /* Actions.APPEND */](); + return true; + } + } + while (mode !== null) { + index++; + c = path[index]; + if (c === '\\' && maybeUnescapeQuote()) { + continue; + } + type = getPathCharType(c); + typeMap = pathStateMachine[mode]; + transition = typeMap[type] || typeMap["l" /* PathCharTypes.ELSE */] || 8 /* States.ERROR */; + // check parse error + if (transition === 8 /* States.ERROR */) { + return; + } + mode = transition[0]; + if (transition[1] !== undefined) { + action = actions[transition[1]]; + if (action) { + newChar = c; + if (action() === false) { + return; + } + } + } + // check parse finish + if (mode === 7 /* States.AFTER_PATH */) { + return keys; + } + } + } + // path token cache + const cache = new Map(); + /** + * key-value message resolver + * + * @remarks + * Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ + function resolveWithKeyValue(obj, path) { + return isObject(obj) ? obj[path] : null; + } + /** + * message resolver + * + * @remarks + * Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default. + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ + function resolveValue(obj, path) { + // check object + if (!isObject(obj)) { + return null; + } + // parse path + let hit = cache.get(path); + if (!hit) { + hit = parse(path); + if (hit) { + cache.set(path, hit); + } + } + // check hit + if (!hit) { + return null; + } + // resolve path value + const len = hit.length; + let last = obj; + let i = 0; + while (i < len) { + const key = hit[i]; + /** + * NOTE: + * if `key` is intlify message format AST node key and `last` is intlify message format AST, skip it. + * because the AST node is not a key-value structure. + */ + if (AST_NODE_PROPS_KEYS.includes(key) && isMessageAST(last)) { + return null; + } + const val = last[key]; + if (val === undefined) { + return null; + } + if (isFunction(last)) { + return null; + } + last = val; + i++; + } + return last; + } + + const DEFAULT_MODIFIER = (str) => str; + const DEFAULT_MESSAGE = (ctx) => ''; // eslint-disable-line + const DEFAULT_MESSAGE_DATA_TYPE = 'text'; + const DEFAULT_NORMALIZE = (values) => values.length === 0 ? '' : join(values); + const DEFAULT_INTERPOLATE = toDisplayString; + function pluralDefault(choice, choicesLength) { + choice = Math.abs(choice); + if (choicesLength === 2) { + // prettier-ignore + return choice + ? choice > 1 + ? 1 + : 0 + : 1; + } + return choice ? Math.min(choice, 2) : 0; + } + function getPluralIndex(options) { + // prettier-ignore + const index = isNumber(options.pluralIndex) + ? options.pluralIndex + : -1; + // prettier-ignore + return options.named && (isNumber(options.named.count) || isNumber(options.named.n)) + ? isNumber(options.named.count) + ? options.named.count + : isNumber(options.named.n) + ? options.named.n + : index + : index; + } + function normalizeNamed(pluralIndex, props) { + if (!props.count) { + props.count = pluralIndex; + } + if (!props.n) { + props.n = pluralIndex; + } + } + function createMessageContext(options = {}) { + const locale = options.locale; + const pluralIndex = getPluralIndex(options); + const pluralRule = isObject(options.pluralRules) && + isString(locale) && + isFunction(options.pluralRules[locale]) + ? options.pluralRules[locale] + : pluralDefault; + const orgPluralRule = isObject(options.pluralRules) && + isString(locale) && + isFunction(options.pluralRules[locale]) + ? pluralDefault + : undefined; + const plural = (messages) => { + return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)]; + }; + const _list = options.list || []; + const list = (index) => _list[index]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _named = options.named || create(); + isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named); + const named = (key) => _named[key]; + function message(key) { + // prettier-ignore + const msg = isFunction(options.messages) + ? options.messages(key) + : isObject(options.messages) + ? options.messages[key] + : false; + return !msg + ? options.parent + ? options.parent.message(key) // resolve from parent messages + : DEFAULT_MESSAGE + : msg; + } + const _modifier = (name) => options.modifiers + ? options.modifiers[name] + : DEFAULT_MODIFIER; + const normalize = isPlainObject(options.processor) && isFunction(options.processor.normalize) + ? options.processor.normalize + : DEFAULT_NORMALIZE; + const interpolate = isPlainObject(options.processor) && + isFunction(options.processor.interpolate) + ? options.processor.interpolate + : DEFAULT_INTERPOLATE; + const type = isPlainObject(options.processor) && isString(options.processor.type) + ? options.processor.type + : DEFAULT_MESSAGE_DATA_TYPE; + const linked = (key, ...args) => { + const [arg1, arg2] = args; + let type = 'text'; + let modifier = ''; + if (args.length === 1) { + if (isObject(arg1)) { + modifier = arg1.modifier || modifier; + type = arg1.type || type; + } + else if (isString(arg1)) { + modifier = arg1 || modifier; + } + } + else if (args.length === 2) { + if (isString(arg1)) { + modifier = arg1 || modifier; + } + if (isString(arg2)) { + type = arg2 || type; + } + } + const ret = message(key)(ctx); + const msg = + // The message in vnode resolved with linked are returned as an array by processor.nomalize + type === 'vnode' && isArray(ret) && modifier + ? ret[0] + : ret; + return modifier ? _modifier(modifier)(msg, type) : msg; + }; + const ctx = { + ["list" /* HelperNameMap.LIST */]: list, + ["named" /* HelperNameMap.NAMED */]: named, + ["plural" /* HelperNameMap.PLURAL */]: plural, + ["linked" /* HelperNameMap.LINKED */]: linked, + ["message" /* HelperNameMap.MESSAGE */]: message, + ["type" /* HelperNameMap.TYPE */]: type, + ["interpolate" /* HelperNameMap.INTERPOLATE */]: interpolate, + ["normalize" /* HelperNameMap.NORMALIZE */]: normalize, + ["values" /* HelperNameMap.VALUES */]: assign(create(), _list, _named) + }; + return ctx; + } + + let devtools = null; + function setDevToolsHook(hook) { + devtools = hook; + } + function initI18nDevTools(i18n, version, meta) { + // TODO: queue if devtools is undefined + devtools && + devtools.emit("i18n:init" /* IntlifyDevToolsHooks.I18nInit */, { + timestamp: Date.now(), + i18n, + version, + meta + }); + } + const translateDevTools = /* #__PURE__*/ createDevToolsHook("function:translate" /* IntlifyDevToolsHooks.FunctionTranslate */); + function createDevToolsHook(hook) { + return (payloads) => devtools && devtools.emit(hook, payloads); + } + + const code$3 = CompileWarnCodes.__EXTEND_POINT__; + const inc$3 = incrementer(code$3); + const CoreWarnCodes = { + NOT_FOUND_KEY: code$3, // 2 + FALLBACK_TO_TRANSLATE: inc$3(), // 3 + CANNOT_FORMAT_NUMBER: inc$3(), // 4 + FALLBACK_TO_NUMBER_FORMAT: inc$3(), // 5 + CANNOT_FORMAT_DATE: inc$3(), // 6 + FALLBACK_TO_DATE_FORMAT: inc$3(), // 7 + EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc$3(), // 8 + __EXTEND_POINT__: inc$3() // 9 + }; + /** @internal */ + const warnMessages$1 = { + [CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`, + [CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`, + [CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`, + [CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]: `This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future.` + }; + function getWarnMessage$1(code, ...args) { + return format$1(warnMessages$1[code], ...args); + } + + const code$2 = CompileErrorCodes.__EXTEND_POINT__; + const inc$2 = incrementer(code$2); + const CoreErrorCodes = { + INVALID_ARGUMENT: code$2, // 17 + INVALID_DATE_ARGUMENT: inc$2(), // 18 + INVALID_ISO_DATE_ARGUMENT: inc$2(), // 19 + NOT_SUPPORT_NON_STRING_MESSAGE: inc$2(), // 20 + NOT_SUPPORT_LOCALE_PROMISE_VALUE: inc$2(), // 21 + NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: inc$2(), // 22 + NOT_SUPPORT_LOCALE_TYPE: inc$2(), // 23 + __EXTEND_POINT__: inc$2() // 24 + }; + function createCoreError(code) { + return createCompileError(code, null, { messages: errorMessages$1 } ); + } + /** @internal */ + const errorMessages$1 = { + [CoreErrorCodes.INVALID_ARGUMENT]: 'Invalid arguments', + [CoreErrorCodes.INVALID_DATE_ARGUMENT]: 'The date provided is an invalid Date object.' + + 'Make sure your Date represents a valid date.', + [CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: 'The argument provided is not a valid ISO date string', + [CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE]: 'Not support non-string message', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]: 'cannot support promise value', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]: 'cannot support async function', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: 'cannot support locale type' + }; + + /** @internal */ + function getLocale(context, options) { + return options.locale != null + ? resolveLocale(options.locale) + : resolveLocale(context.locale); + } + let _resolveLocale; + /** @internal */ + function resolveLocale(locale) { + if (isString(locale)) { + return locale; + } + else { + if (isFunction(locale)) { + if (locale.resolvedOnce && _resolveLocale != null) { + return _resolveLocale; + } + else if (locale.constructor.name === 'Function') { + const resolve = locale(); + if (isPromise(resolve)) { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE); + } + return (_resolveLocale = resolve); + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION); + } + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE); + } + } + } + /** + * Fallback with simple implemenation + * + * @remarks + * A fallback locale function implemented with a simple fallback algorithm. + * + * Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nGeneral + */ + function fallbackWithSimple(ctx, fallback, start // eslint-disable-line @typescript-eslint/no-unused-vars + ) { + // prettier-ignore + return [...new Set([ + start, + ...(isArray(fallback) + ? fallback + : isObject(fallback) + ? Object.keys(fallback) + : isString(fallback) + ? [fallback] + : [start]) + ])]; + } + /** + * Fallback with locale chain + * + * @remarks + * A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @VueI18nGeneral + */ + function fallbackWithLocaleChain(ctx, fallback, start) { + const startLocale = isString(start) ? start : DEFAULT_LOCALE; + const context = ctx; + if (!context.__localeChainCache) { + context.__localeChainCache = new Map(); + } + let chain = context.__localeChainCache.get(startLocale); + if (!chain) { + chain = []; + // first block defined by start + let block = [start]; + // while any intervening block found + while (isArray(block)) { + block = appendBlockToChain(chain, block, fallback); + } + // prettier-ignore + // last block defined by default + const defaults = isArray(fallback) || !isPlainObject(fallback) + ? fallback + : fallback['default'] + ? fallback['default'] + : null; + // convert defaults to array + block = isString(defaults) ? [defaults] : defaults; + if (isArray(block)) { + appendBlockToChain(chain, block, false); + } + context.__localeChainCache.set(startLocale, chain); + } + return chain; + } + function appendBlockToChain(chain, block, blocks) { + let follow = true; + for (let i = 0; i < block.length && isBoolean(follow); i++) { + const locale = block[i]; + if (isString(locale)) { + follow = appendLocaleToChain(chain, block[i], blocks); + } + } + return follow; + } + function appendLocaleToChain(chain, locale, blocks) { + let follow; + const tokens = locale.split('-'); + do { + const target = tokens.join('-'); + follow = appendItemToChain(chain, target, blocks); + tokens.splice(-1, 1); + } while (tokens.length && follow === true); + return follow; + } + function appendItemToChain(chain, target, blocks) { + let follow = false; + if (!chain.includes(target)) { + follow = true; + if (target) { + follow = target[target.length - 1] !== '!'; + const locale = target.replace(/!/g, ''); + chain.push(locale); + if ((isArray(blocks) || isPlainObject(blocks)) && + blocks[locale] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + follow = blocks[locale]; + } + } + } + return follow; + } + + /* eslint-disable @typescript-eslint/no-explicit-any */ + /** + * Intlify core-base version + * @internal + */ + const VERSION$1 = '9.14.5'; + const NOT_REOSLVED = -1; + const DEFAULT_LOCALE = 'en-US'; + const MISSING_RESOLVE_VALUE = ''; + const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`; + function getDefaultLinkedModifiers() { + return { + upper: (val, type) => { + // prettier-ignore + return type === 'text' && isString(val) + ? val.toUpperCase() + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? val.children.toUpperCase() + : val; + }, + lower: (val, type) => { + // prettier-ignore + return type === 'text' && isString(val) + ? val.toLowerCase() + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? val.children.toLowerCase() + : val; + }, + capitalize: (val, type) => { + // prettier-ignore + return (type === 'text' && isString(val) + ? capitalize(val) + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? capitalize(val.children) + : val); + } + }; + } + let _compiler; + function registerMessageCompiler(compiler) { + _compiler = compiler; + } + let _resolver; + /** + * Register the message resolver + * + * @param resolver - A {@link MessageResolver} function + * + * @VueI18nGeneral + */ + function registerMessageResolver(resolver) { + _resolver = resolver; + } + let _fallbacker; + /** + * Register the locale fallbacker + * + * @param fallbacker - A {@link LocaleFallbacker} function + * + * @VueI18nGeneral + */ + function registerLocaleFallbacker(fallbacker) { + _fallbacker = fallbacker; + } + // Additional Meta for Intlify DevTools + let _additionalMeta = null; + /* #__NO_SIDE_EFFECTS__ */ + const setAdditionalMeta = (meta) => { + _additionalMeta = meta; + }; + /* #__NO_SIDE_EFFECTS__ */ + const getAdditionalMeta = () => _additionalMeta; + let _fallbackContext = null; + const setFallbackContext = (context) => { + _fallbackContext = context; + }; + const getFallbackContext = () => _fallbackContext; + // ID for CoreContext + let _cid = 0; + function createCoreContext(options = {}) { + // setup options + const onWarn = isFunction(options.onWarn) ? options.onWarn : warn; + const version = isString(options.version) ? options.version : VERSION$1; + const locale = isString(options.locale) || isFunction(options.locale) + ? options.locale + : DEFAULT_LOCALE; + const _locale = isFunction(locale) ? DEFAULT_LOCALE : locale; + const fallbackLocale = isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + isString(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale; + const messages = isPlainObject(options.messages) + ? options.messages + : createResources(_locale); + const datetimeFormats = isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : createResources(_locale) + ; + const numberFormats = isPlainObject(options.numberFormats) + ? options.numberFormats + : createResources(_locale) + ; + const modifiers = assign(create(), options.modifiers, getDefaultLinkedModifiers()); + const pluralRules = options.pluralRules || create(); + const missing = isFunction(options.missing) ? options.missing : null; + const missingWarn = isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + const fallbackWarn = isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + const fallbackFormat = !!options.fallbackFormat; + const unresolving = !!options.unresolving; + const postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + const processor = isPlainObject(options.processor) ? options.processor : null; + const warnHtmlMessage = isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const escapeParameter = !!options.escapeParameter; + const messageCompiler = isFunction(options.messageCompiler) + ? options.messageCompiler + : _compiler; + const messageResolver = isFunction(options.messageResolver) + ? options.messageResolver + : _resolver || resolveWithKeyValue; + const localeFallbacker = isFunction(options.localeFallbacker) + ? options.localeFallbacker + : _fallbacker || fallbackWithSimple; + const fallbackContext = isObject(options.fallbackContext) + ? options.fallbackContext + : undefined; + // setup internal options + const internalOptions = options; + const __datetimeFormatters = isObject(internalOptions.__datetimeFormatters) + ? internalOptions.__datetimeFormatters + : new Map() + ; + const __numberFormatters = isObject(internalOptions.__numberFormatters) + ? internalOptions.__numberFormatters + : new Map() + ; + const __meta = isObject(internalOptions.__meta) ? internalOptions.__meta : {}; + _cid++; + const context = { + version, + cid: _cid, + locale, + fallbackLocale, + messages, + modifiers, + pluralRules, + missing, + missingWarn, + fallbackWarn, + fallbackFormat, + unresolving, + postTranslation, + processor, + warnHtmlMessage, + escapeParameter, + messageCompiler, + messageResolver, + localeFallbacker, + fallbackContext, + onWarn, + __meta + }; + { + context.datetimeFormats = datetimeFormats; + context.numberFormats = numberFormats; + context.__datetimeFormatters = __datetimeFormatters; + context.__numberFormatters = __numberFormatters; + } + // for vue-devtools timeline event + { + context.__v_emitter = + internalOptions.__v_emitter != null + ? internalOptions.__v_emitter + : undefined; + } + // NOTE: experimental !! + { + initI18nDevTools(context, version, __meta); + } + return context; + } + const createResources = (locale) => ({ [locale]: create() }); + /** @internal */ + function isTranslateFallbackWarn(fallback, key) { + return fallback instanceof RegExp ? fallback.test(key) : fallback; + } + /** @internal */ + function isTranslateMissingWarn(missing, key) { + return missing instanceof RegExp ? missing.test(key) : missing; + } + /** @internal */ + function handleMissing(context, key, locale, missingWarn, type) { + const { missing, onWarn } = context; + // for vue-devtools timeline event + { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("missing" /* VueDevToolsTimelineEvents.MISSING */, { + locale, + key, + type, + groupId: `${type}:${key}` + }); + } + } + if (missing !== null) { + const ret = missing(context, locale, key, type); + return isString(ret) ? ret : key; + } + else { + if (isTranslateMissingWarn(missingWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.NOT_FOUND_KEY, { key, locale })); + } + return key; + } + } + /** @internal */ + function updateFallbackLocale(ctx, locale, fallback) { + const context = ctx; + context.__localeChainCache = new Map(); + ctx.localeFallbacker(ctx, fallback, locale); + } + /** @internal */ + function isAlmostSameLocale(locale, compareLocale) { + if (locale === compareLocale) + return false; + return locale.split('-')[0] === compareLocale.split('-')[0]; + } + /** @internal */ + function isImplicitFallback(targetLocale, locales) { + const index = locales.indexOf(targetLocale); + if (index === -1) { + return false; + } + for (let i = index + 1; i < locales.length; i++) { + if (isAlmostSameLocale(targetLocale, locales[i])) { + return true; + } + } + return false; + } + /* eslint-enable @typescript-eslint/no-explicit-any */ + + function format(ast) { + const msg = (ctx) => formatParts(ctx, ast); + return msg; + } + function formatParts(ctx, ast) { + const body = resolveBody(ast); + if (body == null) { + throw createUnhandleNodeError(0 /* NodeTypes.Resource */); + } + const type = resolveType(body); + if (type === 1 /* NodeTypes.Plural */) { + const plural = body; + const cases = resolveCases(plural); + return ctx.plural(cases.reduce((messages, c) => [ + ...messages, + formatMessageParts(ctx, c) + ], [])); + } + else { + return formatMessageParts(ctx, body); + } + } + function formatMessageParts(ctx, node) { + const static_ = resolveStatic(node); + if (static_ != null) { + return ctx.type === 'text' + ? static_ + : ctx.normalize([static_]); + } + else { + const messages = resolveItems(node).reduce((acm, c) => [...acm, formatMessagePart(ctx, c)], []); + return ctx.normalize(messages); + } + } + function formatMessagePart(ctx, node) { + const type = resolveType(node); + switch (type) { + case 3 /* NodeTypes.Text */: { + return resolveValue$1(node, type); + } + case 9 /* NodeTypes.Literal */: { + return resolveValue$1(node, type); + } + case 4 /* NodeTypes.Named */: { + const named = node; + if (hasOwn(named, 'k') && named.k) { + return ctx.interpolate(ctx.named(named.k)); + } + if (hasOwn(named, 'key') && named.key) { + return ctx.interpolate(ctx.named(named.key)); + } + throw createUnhandleNodeError(type); + } + case 5 /* NodeTypes.List */: { + const list = node; + if (hasOwn(list, 'i') && isNumber(list.i)) { + return ctx.interpolate(ctx.list(list.i)); + } + if (hasOwn(list, 'index') && isNumber(list.index)) { + return ctx.interpolate(ctx.list(list.index)); + } + throw createUnhandleNodeError(type); + } + case 6 /* NodeTypes.Linked */: { + const linked = node; + const modifier = resolveLinkedModifier(linked); + const key = resolveLinkedKey(linked); + return ctx.linked(formatMessagePart(ctx, key), modifier ? formatMessagePart(ctx, modifier) : undefined, ctx.type); + } + case 7 /* NodeTypes.LinkedKey */: { + return resolveValue$1(node, type); + } + case 8 /* NodeTypes.LinkedModifier */: { + return resolveValue$1(node, type); + } + default: + throw new Error(`unhandled node on format message part: ${type}`); + } + } + + const WARN_MESSAGE = `Detected HTML in '{source}' message. Recommend not using HTML messages to avoid XSS.`; + function checkHtmlMessage(source, warnHtmlMessage) { + if (warnHtmlMessage && detectHtmlTag(source)) { + warn(format$1(WARN_MESSAGE, { source })); + } + } + const defaultOnCacheKey = (message) => message; + let compileCache = create(); + function onCompileWarn(_warn) { + if (_warn.code === CompileWarnCodes.USE_MODULO_SYNTAX) { + warn(`The use of named interpolation with modulo syntax is deprecated. ` + + `It will be removed in v10.\n` + + `reference: https://vue-i18n.intlify.dev/guide/essentials/syntax#rails-i18n-format \n` + + `(message compiler warning message: ${_warn.message})`); + } + } + function baseCompile(message, options = {}) { + // error detecting on compile + let detectError = false; + const onError = options.onError || defaultOnError; + options.onError = (err) => { + detectError = true; + onError(err); + }; + // compile with mesasge-compiler + return { ...baseCompile$1(message, options), detectError }; + } + function compile(message, context) { + // set onWarn + { + context.onWarn = onCompileWarn; + } + if (isString(message)) { + // check HTML message + const warnHtmlMessage = isBoolean(context.warnHtmlMessage) + ? context.warnHtmlMessage + : true; + checkHtmlMessage(message, warnHtmlMessage); + // check caches + const onCacheKey = context.onCacheKey || defaultOnCacheKey; + const cacheKey = onCacheKey(message); + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compile with JIT mode + const { ast, detectError } = baseCompile(message, { + ...context, + location: true, + jit: true + }); + // compose message function from AST + const msg = format(ast); + // if occurred compile error, don't cache + return !detectError + ? (compileCache[cacheKey] = msg) + : msg; + } + else { + if (!isMessageAST(message)) { + warn(`the message that is resolve with key '${context.key}' is not supported for jit compilation`); + return (() => message); + } + // AST case (passed from bundler) + const cacheKey = message.cacheKey; + if (cacheKey) { + const cached = compileCache[cacheKey]; + if (cached) { + return cached; + } + // compose message function from message (AST) + return (compileCache[cacheKey] = + format(message)); + } + else { + return format(message); + } + } + } + + const NOOP_MESSAGE_FUNCTION = () => ''; + const isMessageFunction = (val) => isFunction(val); + // implementation of `translate` function + function translate(context, ...args) { + const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context; + const [key, options] = parseTranslateArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const escapeParameter = isBoolean(options.escapeParameter) + ? options.escapeParameter + : context.escapeParameter; + const resolvedMessage = !!options.resolvedMessage; + // prettier-ignore + const defaultMsgOrKey = isString(options.default) || isBoolean(options.default) // default by function option + ? !isBoolean(options.default) + ? options.default + : (!messageCompiler ? () => key : key) + : fallbackFormat // default by `fallbackFormat` option + ? (!messageCompiler ? () => key : key) + : ''; + const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== ''; + const locale = getLocale(context, options); + // escape params + escapeParameter && escapeParams(options); + // resolve message format + // eslint-disable-next-line prefer-const + let [formatScope, targetLocale, message] = !resolvedMessage + ? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) + : [ + key, + locale, + messages[locale] || create() + ]; + // NOTE: + // Fix to work around `ssrTransfrom` bug in Vite. + // https://github.com/vitejs/vite/issues/4306 + // To get around this, use temporary variables. + // https://github.com/nuxt/framework/issues/1461#issuecomment-954606243 + let format = formatScope; + // if you use default message, set it as message format! + let cacheBaseKey = key; + if (!resolvedMessage && + !(isString(format) || + isMessageAST(format) || + isMessageFunction(format))) { + if (enableDefaultMsg) { + format = defaultMsgOrKey; + cacheBaseKey = format; + } + } + // checking message format and target locale + if (!resolvedMessage && + (!(isString(format) || + isMessageAST(format) || + isMessageFunction(format)) || + !isString(targetLocale))) { + return unresolving ? NOT_REOSLVED : key; + } + // TODO: refactor + if (isString(format) && context.messageCompiler == null) { + warn(`The message format compilation is not supported in this build. ` + + `Because message compiler isn't included. ` + + `You need to pre-compilation all message format. ` + + `So translate function return '${key}'.`); + return key; + } + // setup compile error detecting + let occurred = false; + const onError = () => { + occurred = true; + }; + // compile message format + const msg = !isMessageFunction(format) + ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) + : format; + // if occurred compile error, return the message format + if (occurred) { + return format; + } + // evaluate message with context + const ctxOptions = getMessageContextOptions(context, targetLocale, message, options); + const msgContext = createMessageContext(ctxOptions); + const messaged = evaluateMessage(context, msg, msgContext); + // if use post translation option, proceed it with handler + let ret = postTranslation + ? postTranslation(messaged, key) + : messaged; + // apply HTML sanitization for security + if (escapeParameter && isString(ret)) { + ret = sanitizeTranslatedHtml(ret); + } + // NOTE: experimental !! + { + // prettier-ignore + const payloads = { + timestamp: Date.now(), + key: isString(key) + ? key + : isMessageFunction(format) + ? format.key + : '', + locale: targetLocale || (isMessageFunction(format) + ? format.locale + : ''), + format: isString(format) + ? format + : isMessageFunction(format) + ? format.source + : '', + message: ret + }; + payloads.meta = assign({}, context.__meta, getAdditionalMeta() || {}); + translateDevTools(payloads); + } + return ret; + } + function escapeParams(options) { + if (isArray(options.list)) { + options.list = options.list.map(item => isString(item) ? escapeHtml(item) : item); + } + else if (isObject(options.named)) { + Object.keys(options.named).forEach(key => { + if (isString(options.named[key])) { + options.named[key] = escapeHtml(options.named[key]); + } + }); + } + } + function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) { + const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context; + const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any + let message = create(); + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'translate'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + !isAlmostSameLocale(locale, targetLocale) && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.FALLBACK_TO_TRANSLATE, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + message = + messages[targetLocale] || create(); + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-resolve-start'; + endTag = 'intlify-message-resolve-end'; + mark && mark(startTag); + } + if ((format = resolveValue(message, key)) === null) { + // if null, resolve with object key path + format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any + } + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start && format) { + emitter.emit("message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, { + type: "message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, + key, + message: format, + time: end - start, + groupId: `${type}:${key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message resolve', startTag, endTag); + } + } + if (isString(format) || isMessageAST(format) || isMessageFunction(format)) { + break; + } + if (!isImplicitFallback(targetLocale, locales)) { + const missingRet = handleMissing(context, // eslint-disable-line @typescript-eslint/no-explicit-any + key, targetLocale, missingWarn, type); + if (missingRet !== key) { + format = missingRet; + } + } + from = to; + } + return [format, targetLocale, message]; + } + function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) { + const { messageCompiler, warnHtmlMessage } = context; + if (isMessageFunction(format)) { + const msg = format; + msg.locale = msg.locale || targetLocale; + msg.key = msg.key || key; + return msg; + } + if (messageCompiler == null) { + const msg = (() => format); + msg.locale = targetLocale; + msg.key = key; + return msg; + } + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-compilation-start'; + endTag = 'intlify-message-compilation-end'; + mark && mark(startTag); + } + const msg = messageCompiler(format, getCompileContext(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, onError)); + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, { + type: "message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, + message: format, + time: end - start, + groupId: `${'translate'}:${key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message compilation', startTag, endTag); + } + } + msg.locale = targetLocale; + msg.key = key; + msg.source = format; + return msg; + } + function evaluateMessage(context, msg, msgCtx) { + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-evaluation-start'; + endTag = 'intlify-message-evaluation-end'; + mark && mark(startTag); + } + const messaged = msg(msgCtx); + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, { + type: "message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, + value: messaged, + time: end - start, + groupId: `${'translate'}:${msg.key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message evaluation', startTag, endTag); + } + } + return messaged; + } + /** @internal */ + function parseTranslateArgs(...args) { + const [arg1, arg2, arg3] = args; + const options = create(); + if (!isString(arg1) && + !isNumber(arg1) && + !isMessageFunction(arg1) && + !isMessageAST(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + // prettier-ignore + const key = isNumber(arg1) + ? String(arg1) + : isMessageFunction(arg1) + ? arg1 + : arg1; + if (isNumber(arg2)) { + options.plural = arg2; + } + else if (isString(arg2)) { + options.default = arg2; + } + else if (isPlainObject(arg2) && !isEmptyObject(arg2)) { + options.named = arg2; + } + else if (isArray(arg2)) { + options.list = arg2; + } + if (isNumber(arg3)) { + options.plural = arg3; + } + else if (isString(arg3)) { + options.default = arg3; + } + else if (isPlainObject(arg3)) { + assign(options, arg3); + } + return [key, options]; + } + function getCompileContext(context, locale, key, source, warnHtmlMessage, onError) { + return { + locale, + key, + warnHtmlMessage, + onError: (err) => { + onError && onError(err); + { + const _source = getSourceForCodeFrame(source); + const message = `Message compilation error: ${err.message}`; + const codeFrame = err.location && + _source && + generateCodeFrame(_source, err.location.start.offset, err.location.end.offset); + const emitter = context.__v_emitter; + if (emitter && _source) { + emitter.emit("compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */, { + message: _source, + error: err.message, + start: err.location && err.location.start.offset, + end: err.location && err.location.end.offset, + groupId: `${'translate'}:${key}` + }); + } + console.error(codeFrame ? `${message}\n${codeFrame}` : message); + } + }, + onCacheKey: (source) => generateFormatCacheKey(locale, key, source) + }; + } + function getSourceForCodeFrame(source) { + if (isString(source)) { + return source; + } + else { + if (source.loc && source.loc.source) { + return source.loc.source; + } + } + } + function getMessageContextOptions(context, locale, message, options) { + const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context; + const resolveMessage = (key) => { + let val = resolveValue(message, key); + // fallback to root context + if (val == null && fallbackContext) { + const [, , message] = resolveMessageFormat(fallbackContext, key, locale, fallbackLocale, fallbackWarn, missingWarn); + val = resolveValue(message, key); + } + if (isString(val) || isMessageAST(val)) { + let occurred = false; + const onError = () => { + occurred = true; + }; + const msg = compileMessageFormat(context, key, locale, val, key, onError); + return !occurred + ? msg + : NOOP_MESSAGE_FUNCTION; + } + else if (isMessageFunction(val)) { + return val; + } + else { + // TODO: should be implemented warning message + return NOOP_MESSAGE_FUNCTION; + } + }; + const ctxOptions = { + locale, + modifiers, + pluralRules, + messages: resolveMessage + }; + if (context.processor) { + ctxOptions.processor = context.processor; + } + if (options.list) { + ctxOptions.list = options.list; + } + if (options.named) { + ctxOptions.named = options.named; + } + if (isNumber(options.plural)) { + ctxOptions.pluralIndex = options.plural; + } + return ctxOptions; + } + + const intlDefined = typeof Intl !== 'undefined'; + const Availabilities = { + dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined', + numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined' + }; + + // implementation of `datetime` function + function datetime(context, ...args) { + const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __datetimeFormatters } = context; + if (!Availabilities.dateTimeFormat) { + onWarn(getWarnMessage$1(CoreWarnCodes.CANNOT_FORMAT_DATE)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseDateTimeArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!isString(key) || key === '') { + return new Intl.DateTimeFormat(locale, overrides).format(value); + } + // resolve format + let datetimeFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'datetime format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + datetimeFormat = + datetimeFormats[targetLocale] || {}; + format = datetimeFormat[key]; + if (isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!isPlainObject(format) || !isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __datetimeFormatters.get(id); + if (!formatter) { + formatter = new Intl.DateTimeFormat(targetLocale, assign({}, format, overrides)); + __datetimeFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); + } + /** @internal */ + const DATETIME_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'weekday', + 'era', + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second', + 'timeZoneName', + 'formatMatcher', + 'hour12', + 'timeZone', + 'dateStyle', + 'timeStyle', + 'calendar', + 'dayPeriod', + 'numberingSystem', + 'hourCycle', + 'fractionalSecondDigits' + ]; + /** @internal */ + function parseDateTimeArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = create(); + let overrides = create(); + let value; + if (isString(arg1)) { + // Only allow ISO strings - other date formats are often supported, + // but may cause different results in different browsers. + const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/); + if (!matches) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + // Some browsers can not parse the iso datetime separated by space, + // this is a compromise solution by replace the 'T'/' ' with 'T' + const dateTime = matches[3] + ? matches[3].trim().startsWith('T') + ? `${matches[1].trim()}${matches[3].trim()}` + : `${matches[1].trim()}T${matches[3].trim()}` + : matches[1].trim(); + value = new Date(dateTime); + try { + // This will fail if the date is not valid + value.toISOString(); + } + catch (e) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + } + else if (isDate(arg1)) { + if (isNaN(arg1.getTime())) { + throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT); + } + value = arg1; + } + else if (isNumber(arg1)) { + value = arg1; + } + else { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + if (isString(arg2)) { + options.key = arg2; + } + else if (isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isPlainObject(arg3)) { + overrides = arg3; + } + if (isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; + } + /** @internal */ + function clearDateTimeFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__datetimeFormatters.has(id)) { + continue; + } + context.__datetimeFormatters.delete(id); + } + } + + // implementation of `number` function + function number(context, ...args) { + const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __numberFormatters } = context; + if (!Availabilities.numberFormat) { + onWarn(getWarnMessage$1(CoreWarnCodes.CANNOT_FORMAT_NUMBER)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseNumberArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!isString(key) || key === '') { + return new Intl.NumberFormat(locale, overrides).format(value); + } + // resolve format + let numberFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'number format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + numberFormat = + numberFormats[targetLocale] || {}; + format = numberFormat[key]; + if (isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!isPlainObject(format) || !isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __numberFormatters.get(id); + if (!formatter) { + formatter = new Intl.NumberFormat(targetLocale, assign({}, format, overrides)); + __numberFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); + } + /** @internal */ + const NUMBER_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'style', + 'currency', + 'currencyDisplay', + 'currencySign', + 'useGrouping', + 'minimumIntegerDigits', + 'minimumFractionDigits', + 'maximumFractionDigits', + 'minimumSignificantDigits', + 'maximumSignificantDigits', + 'compactDisplay', + 'notation', + 'signDisplay', + 'unit', + 'unitDisplay', + 'roundingMode', + 'roundingPriority', + 'roundingIncrement', + 'trailingZeroDisplay' + ]; + /** @internal */ + function parseNumberArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = create(); + let overrides = create(); + if (!isNumber(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + const value = arg1; + if (isString(arg2)) { + options.key = arg2; + } + else if (isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isPlainObject(arg3)) { + overrides = arg3; + } + if (isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; + } + /** @internal */ + function clearNumberFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__numberFormatters.has(id)) { + continue; + } + context.__numberFormatters.delete(id); + } + } + + /** + * Vue I18n Version + * + * @remarks + * Semver format. Same format as the package.json `version` field. + * + * @VueI18nGeneral + */ + const VERSION = '9.14.5'; + /** + * This is only called development env + * istanbul-ignore-next + */ + function initDev() { + { + { + console.info(`You are running a development build of vue-i18n.\n` + + `Make sure to use the production build (*.prod.js) when deploying for production.`); + } + } + } + + const code$1 = CoreWarnCodes.__EXTEND_POINT__; + const inc$1 = incrementer(code$1); + const I18nWarnCodes = { + FALLBACK_TO_ROOT: code$1, // 9 + NOT_SUPPORTED_PRESERVE: inc$1(), // 10 + NOT_SUPPORTED_FORMATTER: inc$1(), // 11 + NOT_SUPPORTED_PRESERVE_DIRECTIVE: inc$1(), // 12 + NOT_SUPPORTED_GET_CHOICE_INDEX: inc$1(), // 13 + COMPONENT_NAME_LEGACY_COMPATIBLE: inc$1(), // 14 + NOT_FOUND_PARENT_SCOPE: inc$1(), // 15 + IGNORE_OBJ_FLATTEN: inc$1(), // 16 + NOTICE_DROP_ALLOW_COMPOSITION: inc$1(), // 17 + NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG: inc$1() // 18 + }; + const warnMessages = { + [I18nWarnCodes.FALLBACK_TO_ROOT]: `Fall back to {type} '{key}' with root locale.`, + [I18nWarnCodes.NOT_SUPPORTED_PRESERVE]: `Not supported 'preserve'.`, + [I18nWarnCodes.NOT_SUPPORTED_FORMATTER]: `Not supported 'formatter'.`, + [I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE]: `Not supported 'preserveDirectiveContent'.`, + [I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX]: `Not supported 'getChoiceIndex'.`, + [I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE]: `Component name legacy compatible: '{name}' -> 'i18n'`, + [I18nWarnCodes.NOT_FOUND_PARENT_SCOPE]: `Not found parent scope. use the global scope.`, + [I18nWarnCodes.IGNORE_OBJ_FLATTEN]: `Ignore object flatten: '{key}' key has an string value`, + [I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION]: `'allowComposition' option will be dropped in the next major version. For more information, please see 👉 https://tinyurl.com/2p97mcze`, + [I18nWarnCodes.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG]: `'translateExistCompatible' option will be dropped in the next major version.` + }; + function getWarnMessage(code, ...args) { + return format$1(warnMessages[code], ...args); + } + + const code = CoreErrorCodes.__EXTEND_POINT__; + const inc = incrementer(code); + const I18nErrorCodes = { + // composer module errors + UNEXPECTED_RETURN_TYPE: code, // 24 + // legacy module errors + INVALID_ARGUMENT: inc(), // 25 + // i18n module errors + MUST_BE_CALL_SETUP_TOP: inc(), // 26 + NOT_INSTALLED: inc(), // 27 + NOT_AVAILABLE_IN_LEGACY_MODE: inc(), // 28 + // directive module errors + REQUIRED_VALUE: inc(), // 29 + INVALID_VALUE: inc(), // 30 + // vue-devtools errors + CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN: inc(), // 31 + NOT_INSTALLED_WITH_PROVIDE: inc(), // 32 + // unexpected error + UNEXPECTED_ERROR: inc(), // 33 + // not compatible legacy vue-i18n constructor + NOT_COMPATIBLE_LEGACY_VUE_I18N: inc(), // 34 + // bridge support vue 2.x only + BRIDGE_SUPPORT_VUE_2_ONLY: inc(), // 35 + // need to define `i18n` option in `allowComposition: true` and `useScope: 'local' at `useI18n`` + MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION: inc(), // 36 + // Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly + NOT_AVAILABLE_COMPOSITION_IN_LEGACY: inc(), // 37 + // for enhancement + __EXTEND_POINT__: inc() // 38 + }; + function createI18nError(code, ...args) { + return createCompileError(code, null, { messages: errorMessages, args } ); + } + const errorMessages = { + [I18nErrorCodes.UNEXPECTED_RETURN_TYPE]: 'Unexpected return type in composer', + [I18nErrorCodes.INVALID_ARGUMENT]: 'Invalid argument', + [I18nErrorCodes.MUST_BE_CALL_SETUP_TOP]: 'Must be called at the top of a `setup` function', + [I18nErrorCodes.NOT_INSTALLED]: 'Need to install with `app.use` function', + [I18nErrorCodes.UNEXPECTED_ERROR]: 'Unexpected error', + [I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE]: 'Not available in legacy mode', + [I18nErrorCodes.REQUIRED_VALUE]: `Required in value: {0}`, + [I18nErrorCodes.INVALID_VALUE]: `Invalid value`, + [I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN]: `Cannot setup vue-devtools plugin`, + [I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE]: 'Need to install with `provide` function', + [I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N]: 'Not compatible legacy VueI18n.', + [I18nErrorCodes.BRIDGE_SUPPORT_VUE_2_ONLY]: 'vue-i18n-bridge support Vue 2.x only', + [I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION]: 'Must define ‘i18n’ option or custom block in Composition API with using local scope in Legacy API mode', + [I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY]: 'Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly' + }; + + const TranslateVNodeSymbol = + /* #__PURE__*/ makeSymbol('__translateVNode'); + const DatetimePartsSymbol = /* #__PURE__*/ makeSymbol('__datetimeParts'); + const NumberPartsSymbol = /* #__PURE__*/ makeSymbol('__numberParts'); + const EnableEmitter = /* #__PURE__*/ makeSymbol('__enableEmitter'); + const DisableEmitter = /* #__PURE__*/ makeSymbol('__disableEmitter'); + const SetPluralRulesSymbol = makeSymbol('__setPluralRules'); + const InejctWithOptionSymbol = + /* #__PURE__*/ makeSymbol('__injectWithOption'); + const DisposeSymbol = /* #__PURE__*/ makeSymbol('__dispose'); + const __VUE_I18N_BRIDGE__ = '__VUE_I18N_BRIDGE__'; + + /* eslint-disable @typescript-eslint/no-explicit-any */ + /** + * Transform flat json in obj to normal json in obj + */ + function handleFlatJson(obj) { + // check obj + if (!isObject(obj)) { + return obj; + } + if (isMessageAST(obj)) { + return obj; + } + for (const key in obj) { + // check key + if (!hasOwn(obj, key)) { + continue; + } + // handle for normal json + if (!key.includes('.')) { + // recursive process value if value is also a object + if (isObject(obj[key])) { + handleFlatJson(obj[key]); + } + } + // handle for flat json, transform to normal json + else { + // go to the last object + const subKeys = key.split('.'); + const lastIndex = subKeys.length - 1; + let currentObj = obj; + let hasStringValue = false; + for (let i = 0; i < lastIndex; i++) { + if (subKeys[i] === '__proto__') { + throw new Error(`unsafe key: ${subKeys[i]}`); + } + if (!(subKeys[i] in currentObj)) { + currentObj[subKeys[i]] = create(); + } + if (!isObject(currentObj[subKeys[i]])) { + warn(getWarnMessage(I18nWarnCodes.IGNORE_OBJ_FLATTEN, { + key: subKeys[i] + })); + hasStringValue = true; + break; + } + currentObj = currentObj[subKeys[i]]; + } + // update last object value, delete old property + if (!hasStringValue) { + if (!isMessageAST(currentObj)) { + currentObj[subKeys[lastIndex]] = obj[key]; + delete obj[key]; + } + else { + /** + * NOTE: + * if the last object is a message AST and subKeys[lastIndex] has message AST prop key, ignore to copy and key deletion + */ + if (!AST_NODE_PROPS_KEYS.includes(subKeys[lastIndex])) { + delete obj[key]; + } + } + } + // recursive process value if value is also a object + if (!isMessageAST(currentObj)) { + const target = currentObj[subKeys[lastIndex]]; + if (isObject(target)) { + handleFlatJson(target); + } + } + } + } + return obj; + } + function getLocaleMessages(locale, options) { + const { messages, __i18n, messageResolver, flatJson } = options; + // prettier-ignore + const ret = (isPlainObject(messages) + ? messages + : isArray(__i18n) + ? create() + : { [locale]: create() }); + // merge locale messages of i18n custom block + if (isArray(__i18n)) { + __i18n.forEach(custom => { + if ('locale' in custom && 'resource' in custom) { + const { locale, resource } = custom; + if (locale) { + ret[locale] = ret[locale] || create(); + deepCopy(resource, ret[locale]); + } + else { + deepCopy(resource, ret); + } + } + else { + isString(custom) && deepCopy(JSON.parse(custom), ret); + } + }); + } + // handle messages for flat json + if (messageResolver == null && flatJson) { + for (const key in ret) { + if (hasOwn(ret, key)) { + handleFlatJson(ret[key]); + } + } + } + return ret; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function getComponentOptions(instance) { + return instance.type ; + } + function adjustI18nResources(gl, options, componentOptions // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + let messages = isObject(options.messages) + ? options.messages + : create(); + if ('__i18nGlobal' in componentOptions) { + messages = getLocaleMessages(gl.locale.value, { + messages, + __i18n: componentOptions.__i18nGlobal + }); + } + // merge locale messages + const locales = Object.keys(messages); + if (locales.length) { + locales.forEach(locale => { + gl.mergeLocaleMessage(locale, messages[locale]); + }); + } + { + // merge datetime formats + if (isObject(options.datetimeFormats)) { + const locales = Object.keys(options.datetimeFormats); + if (locales.length) { + locales.forEach(locale => { + gl.mergeDateTimeFormat(locale, options.datetimeFormats[locale]); + }); + } + } + // merge number formats + if (isObject(options.numberFormats)) { + const locales = Object.keys(options.numberFormats); + if (locales.length) { + locales.forEach(locale => { + gl.mergeNumberFormat(locale, options.numberFormats[locale]); + }); + } + } + } + } + function createTextNode(key) { + return vue.createVNode(vue.Text, null, key, 0) + ; + } + /* eslint-enable @typescript-eslint/no-explicit-any */ + + /* eslint-disable @typescript-eslint/no-explicit-any */ + // extend VNode interface + const DEVTOOLS_META = '__INTLIFY_META__'; + const NOOP_RETURN_ARRAY = () => []; + const NOOP_RETURN_FALSE = () => false; + let composerID = 0; + function defineCoreMissingHandler(missing) { + return ((ctx, locale, key, type) => { + return missing(locale, key, vue.getCurrentInstance() || undefined, type); + }); + } + // for Intlify DevTools + /* #__NO_SIDE_EFFECTS__ */ + const getMetaInfo = () => { + const instance = vue.getCurrentInstance(); + let meta = null; // eslint-disable-line @typescript-eslint/no-explicit-any + return instance && (meta = getComponentOptions(instance)[DEVTOOLS_META]) + ? { [DEVTOOLS_META]: meta } // eslint-disable-line @typescript-eslint/no-explicit-any + : null; + }; + /** + * Create composer interface factory + * + * @internal + */ + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + function createComposer(options = {}, VueI18nLegacy) { + const { __root, __injectWithOption } = options; + const _isGlobal = __root === undefined; + const flatJson = options.flatJson; + const _ref = inBrowser ? vue.ref : vue.shallowRef; + const translateExistCompatible = !!options.translateExistCompatible; + { + if (translateExistCompatible && !false) { + warnOnce(getWarnMessage(I18nWarnCodes.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG)); + } + } + let _inheritLocale = isBoolean(options.inheritLocale) + ? options.inheritLocale + : true; + const _locale = _ref( + // prettier-ignore + __root && _inheritLocale + ? __root.locale.value + : isString(options.locale) + ? options.locale + : DEFAULT_LOCALE); + const _fallbackLocale = _ref( + // prettier-ignore + __root && _inheritLocale + ? __root.fallbackLocale.value + : isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale.value); + const _messages = _ref(getLocaleMessages(_locale.value, options)); + // prettier-ignore + const _datetimeFormats = _ref(isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : { [_locale.value]: {} }) + ; + // prettier-ignore + const _numberFormats = _ref(isPlainObject(options.numberFormats) + ? options.numberFormats + : { [_locale.value]: {} }) + ; + // warning suppress options + // prettier-ignore + let _missingWarn = __root + ? __root.missingWarn + : isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + // prettier-ignore + let _fallbackWarn = __root + ? __root.fallbackWarn + : isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + // prettier-ignore + let _fallbackRoot = __root + ? __root.fallbackRoot + : isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + // configure fall back to root + let _fallbackFormat = !!options.fallbackFormat; + // runtime missing + let _missing = isFunction(options.missing) ? options.missing : null; + let _runtimeMissing = isFunction(options.missing) + ? defineCoreMissingHandler(options.missing) + : null; + // postTranslation handler + let _postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + // prettier-ignore + let _warnHtmlMessage = __root + ? __root.warnHtmlMessage + : isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + let _escapeParameter = !!options.escapeParameter; + // custom linked modifiers + // prettier-ignore + const _modifiers = __root + ? __root.modifiers + : isPlainObject(options.modifiers) + ? options.modifiers + : {}; + // pluralRules + let _pluralRules = options.pluralRules || (__root && __root.pluralRules); + // runtime context + // eslint-disable-next-line prefer-const + let _context; + const getCoreContext = () => { + _isGlobal && setFallbackContext(null); + const ctxOptions = { + version: VERSION, + locale: _locale.value, + fallbackLocale: _fallbackLocale.value, + messages: _messages.value, + modifiers: _modifiers, + pluralRules: _pluralRules, + missing: _runtimeMissing === null ? undefined : _runtimeMissing, + missingWarn: _missingWarn, + fallbackWarn: _fallbackWarn, + fallbackFormat: _fallbackFormat, + unresolving: true, + postTranslation: _postTranslation === null ? undefined : _postTranslation, + warnHtmlMessage: _warnHtmlMessage, + escapeParameter: _escapeParameter, + messageResolver: options.messageResolver, + messageCompiler: options.messageCompiler, + __meta: { framework: 'vue' } + }; + { + ctxOptions.datetimeFormats = _datetimeFormats.value; + ctxOptions.numberFormats = _numberFormats.value; + ctxOptions.__datetimeFormatters = isPlainObject(_context) + ? _context.__datetimeFormatters + : undefined; + ctxOptions.__numberFormatters = isPlainObject(_context) + ? _context.__numberFormatters + : undefined; + } + { + ctxOptions.__v_emitter = isPlainObject(_context) + ? _context.__v_emitter + : undefined; + } + const ctx = createCoreContext(ctxOptions); + _isGlobal && setFallbackContext(ctx); + return ctx; + }; + _context = getCoreContext(); + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + // track reactivity + function trackReactivityValues() { + return [ + _locale.value, + _fallbackLocale.value, + _messages.value, + _datetimeFormats.value, + _numberFormats.value + ] + ; + } + // locale + const locale = vue.computed({ + get: () => _locale.value, + set: val => { + _locale.value = val; + _context.locale = _locale.value; + } + }); + // fallbackLocale + const fallbackLocale = vue.computed({ + get: () => _fallbackLocale.value, + set: val => { + _fallbackLocale.value = val; + _context.fallbackLocale = _fallbackLocale.value; + updateFallbackLocale(_context, _locale.value, val); + } + }); + // messages + const messages = vue.computed(() => _messages.value); + // datetimeFormats + const datetimeFormats = /* #__PURE__*/ vue.computed(() => _datetimeFormats.value); + // numberFormats + const numberFormats = /* #__PURE__*/ vue.computed(() => _numberFormats.value); + // getPostTranslationHandler + function getPostTranslationHandler() { + return isFunction(_postTranslation) ? _postTranslation : null; + } + // setPostTranslationHandler + function setPostTranslationHandler(handler) { + _postTranslation = handler; + _context.postTranslation = handler; + } + // getMissingHandler + function getMissingHandler() { + return _missing; + } + // setMissingHandler + function setMissingHandler(handler) { + if (handler !== null) { + _runtimeMissing = defineCoreMissingHandler(handler); + } + _missing = handler; + _context.missing = _runtimeMissing; + } + function isResolvedTranslateMessage(type, arg // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + return type !== 'translate' || !arg.resolvedMessage; + } + const wrapWithDeps = (fn, argumentParser, warnType, fallbackSuccess, fallbackFail, successCondition) => { + trackReactivityValues(); // track reactive dependency + // NOTE: experimental !! + let ret; + try { + if (true || false) { + setAdditionalMeta(getMetaInfo()); + } + if (!_isGlobal) { + _context.fallbackContext = __root + ? getFallbackContext() + : undefined; + } + ret = fn(_context); + } + finally { + if (!_isGlobal) { + _context.fallbackContext = undefined; + } + } + if ((warnType !== 'translate exists' && // for not `te` (e.g `t`) + isNumber(ret) && + ret === NOT_REOSLVED) || + (warnType === 'translate exists' && !ret) // for `te` + ) { + const [key, arg2] = argumentParser(); + if (__root && + isString(key) && + isResolvedTranslateMessage(warnType, arg2)) { + if (_fallbackRoot && + (isTranslateFallbackWarn(_fallbackWarn, key) || + isTranslateMissingWarn(_missingWarn, key))) { + warn(getWarnMessage(I18nWarnCodes.FALLBACK_TO_ROOT, { + key, + type: warnType + })); + } + // for vue-devtools timeline event + { + const { __v_emitter: emitter } = _context; + if (emitter && _fallbackRoot) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type: warnType, + key, + to: 'global', + groupId: `${warnType}:${key}` + }); + } + } + } + return __root && _fallbackRoot + ? fallbackSuccess(__root) + : fallbackFail(key); + } + else if (successCondition(ret)) { + return ret; + } + else { + /* istanbul ignore next */ + throw createI18nError(I18nErrorCodes.UNEXPECTED_RETURN_TYPE); + } + }; + // t + function t(...args) { + return wrapWithDeps(context => Reflect.apply(translate, null, [context, ...args]), () => parseTranslateArgs(...args), 'translate', root => Reflect.apply(root.t, root, [...args]), key => key, val => isString(val)); + } + // rt + function rt(...args) { + const [arg1, arg2, arg3] = args; + if (arg3 && !isObject(arg3)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + return t(...[arg1, arg2, assign({ resolvedMessage: true }, arg3 || {})]); + } + // d + function d(...args) { + return wrapWithDeps(context => Reflect.apply(datetime, null, [context, ...args]), () => parseDateTimeArgs(...args), 'datetime format', root => Reflect.apply(root.d, root, [...args]), () => MISSING_RESOLVE_VALUE, val => isString(val)); + } + // n + function n(...args) { + return wrapWithDeps(context => Reflect.apply(number, null, [context, ...args]), () => parseNumberArgs(...args), 'number format', root => Reflect.apply(root.n, root, [...args]), () => MISSING_RESOLVE_VALUE, val => isString(val)); + } + // for custom processor + function normalize(values) { + return values.map(val => isString(val) || isNumber(val) || isBoolean(val) + ? createTextNode(String(val)) + : val); + } + const interpolate = (val) => val; + const processor = { + normalize, + interpolate, + type: 'vnode' + }; + // translateVNode, using for `i18n-t` component + function translateVNode(...args) { + return wrapWithDeps(context => { + let ret; + const _context = context; + try { + _context.processor = processor; + ret = Reflect.apply(translate, null, [_context, ...args]); + } + finally { + _context.processor = null; + } + return ret; + }, () => parseTranslateArgs(...args), 'translate', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[TranslateVNodeSymbol](...args), key => [createTextNode(key)], val => isArray(val)); + } + // numberParts, using for `i18n-n` component + function numberParts(...args) { + return wrapWithDeps(context => Reflect.apply(number, null, [context, ...args]), () => parseNumberArgs(...args), 'number format', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[NumberPartsSymbol](...args), NOOP_RETURN_ARRAY, val => isString(val) || isArray(val)); + } + // datetimeParts, using for `i18n-d` component + function datetimeParts(...args) { + return wrapWithDeps(context => Reflect.apply(datetime, null, [context, ...args]), () => parseDateTimeArgs(...args), 'datetime format', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[DatetimePartsSymbol](...args), NOOP_RETURN_ARRAY, val => isString(val) || isArray(val)); + } + function setPluralRules(rules) { + _pluralRules = rules; + _context.pluralRules = _pluralRules; + } + // te + function te(key, locale) { + return wrapWithDeps(() => { + if (!key) { + return false; + } + const targetLocale = isString(locale) ? locale : _locale.value; + const message = getLocaleMessage(targetLocale); + const resolved = _context.messageResolver(message, key); + return !translateExistCompatible + ? isMessageAST(resolved) || + isMessageFunction(resolved) || + isString(resolved) + : resolved != null; + }, () => [key], 'translate exists', root => { + return Reflect.apply(root.te, root, [key, locale]); + }, NOOP_RETURN_FALSE, val => isBoolean(val)); + } + function resolveMessages(key) { + let messages = null; + const locales = fallbackWithLocaleChain(_context, _fallbackLocale.value, _locale.value); + for (let i = 0; i < locales.length; i++) { + const targetLocaleMessages = _messages.value[locales[i]] || {}; + const messageValue = _context.messageResolver(targetLocaleMessages, key); + if (messageValue != null) { + messages = messageValue; + break; + } + } + return messages; + } + // tm + function tm(key) { + const messages = resolveMessages(key); + // prettier-ignore + return messages != null + ? messages + : __root + ? __root.tm(key) || {} + : {}; + } + // getLocaleMessage + function getLocaleMessage(locale) { + return (_messages.value[locale] || {}); + } + // setLocaleMessage + function setLocaleMessage(locale, message) { + if (flatJson) { + const _message = { [locale]: message }; + for (const key in _message) { + if (hasOwn(_message, key)) { + handleFlatJson(_message[key]); + } + } + message = _message[locale]; + } + _messages.value[locale] = message; + _context.messages = _messages.value; + } + // mergeLocaleMessage + function mergeLocaleMessage(locale, message) { + _messages.value[locale] = _messages.value[locale] || {}; + const _message = { [locale]: message }; + if (flatJson) { + for (const key in _message) { + if (hasOwn(_message, key)) { + handleFlatJson(_message[key]); + } + } + } + message = _message[locale]; + deepCopy(message, _messages.value[locale]); + _context.messages = _messages.value; + } + // getDateTimeFormat + function getDateTimeFormat(locale) { + return _datetimeFormats.value[locale] || {}; + } + // setDateTimeFormat + function setDateTimeFormat(locale, format) { + _datetimeFormats.value[locale] = format; + _context.datetimeFormats = _datetimeFormats.value; + clearDateTimeFormat(_context, locale, format); + } + // mergeDateTimeFormat + function mergeDateTimeFormat(locale, format) { + _datetimeFormats.value[locale] = assign(_datetimeFormats.value[locale] || {}, format); + _context.datetimeFormats = _datetimeFormats.value; + clearDateTimeFormat(_context, locale, format); + } + // getNumberFormat + function getNumberFormat(locale) { + return _numberFormats.value[locale] || {}; + } + // setNumberFormat + function setNumberFormat(locale, format) { + _numberFormats.value[locale] = format; + _context.numberFormats = _numberFormats.value; + clearNumberFormat(_context, locale, format); + } + // mergeNumberFormat + function mergeNumberFormat(locale, format) { + _numberFormats.value[locale] = assign(_numberFormats.value[locale] || {}, format); + _context.numberFormats = _numberFormats.value; + clearNumberFormat(_context, locale, format); + } + // for debug + composerID++; + // watch root locale & fallbackLocale + if (__root && inBrowser) { + vue.watch(__root.locale, (val) => { + if (_inheritLocale) { + _locale.value = val; + _context.locale = val; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }); + vue.watch(__root.fallbackLocale, (val) => { + if (_inheritLocale) { + _fallbackLocale.value = val; + _context.fallbackLocale = val; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }); + } + // define basic composition API! + const composer = { + id: composerID, + locale, + fallbackLocale, + get inheritLocale() { + return _inheritLocale; + }, + set inheritLocale(val) { + _inheritLocale = val; + if (val && __root) { + _locale.value = __root.locale.value; + _fallbackLocale.value = __root.fallbackLocale.value; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }, + get availableLocales() { + return Object.keys(_messages.value).sort(); + }, + messages, + get modifiers() { + return _modifiers; + }, + get pluralRules() { + return _pluralRules || {}; + }, + get isGlobal() { + return _isGlobal; + }, + get missingWarn() { + return _missingWarn; + }, + set missingWarn(val) { + _missingWarn = val; + _context.missingWarn = _missingWarn; + }, + get fallbackWarn() { + return _fallbackWarn; + }, + set fallbackWarn(val) { + _fallbackWarn = val; + _context.fallbackWarn = _fallbackWarn; + }, + get fallbackRoot() { + return _fallbackRoot; + }, + set fallbackRoot(val) { + _fallbackRoot = val; + }, + get fallbackFormat() { + return _fallbackFormat; + }, + set fallbackFormat(val) { + _fallbackFormat = val; + _context.fallbackFormat = _fallbackFormat; + }, + get warnHtmlMessage() { + return _warnHtmlMessage; + }, + set warnHtmlMessage(val) { + _warnHtmlMessage = val; + _context.warnHtmlMessage = val; + }, + get escapeParameter() { + return _escapeParameter; + }, + set escapeParameter(val) { + _escapeParameter = val; + _context.escapeParameter = val; + }, + t, + getLocaleMessage, + setLocaleMessage, + mergeLocaleMessage, + getPostTranslationHandler, + setPostTranslationHandler, + getMissingHandler, + setMissingHandler, + [SetPluralRulesSymbol]: setPluralRules + }; + { + composer.datetimeFormats = datetimeFormats; + composer.numberFormats = numberFormats; + composer.rt = rt; + composer.te = te; + composer.tm = tm; + composer.d = d; + composer.n = n; + composer.getDateTimeFormat = getDateTimeFormat; + composer.setDateTimeFormat = setDateTimeFormat; + composer.mergeDateTimeFormat = mergeDateTimeFormat; + composer.getNumberFormat = getNumberFormat; + composer.setNumberFormat = setNumberFormat; + composer.mergeNumberFormat = mergeNumberFormat; + composer[InejctWithOptionSymbol] = __injectWithOption; + composer[TranslateVNodeSymbol] = translateVNode; + composer[DatetimePartsSymbol] = datetimeParts; + composer[NumberPartsSymbol] = numberParts; + } + // for vue-devtools timeline event + { + composer[EnableEmitter] = (emitter) => { + _context.__v_emitter = emitter; + }; + composer[DisableEmitter] = () => { + _context.__v_emitter = undefined; + }; + } + return composer; + } + /* eslint-enable @typescript-eslint/no-explicit-any */ + + /* eslint-disable @typescript-eslint/no-explicit-any */ + /** + * Convert to I18n Composer Options from VueI18n Options + * + * @internal + */ + function convertComposerOptions(options) { + const locale = isString(options.locale) ? options.locale : DEFAULT_LOCALE; + const fallbackLocale = isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : locale; + const missing = isFunction(options.missing) ? options.missing : undefined; + const missingWarn = isBoolean(options.silentTranslationWarn) || + isRegExp(options.silentTranslationWarn) + ? !options.silentTranslationWarn + : true; + const fallbackWarn = isBoolean(options.silentFallbackWarn) || + isRegExp(options.silentFallbackWarn) + ? !options.silentFallbackWarn + : true; + const fallbackRoot = isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + const fallbackFormat = !!options.formatFallbackMessages; + const modifiers = isPlainObject(options.modifiers) ? options.modifiers : {}; + const pluralizationRules = options.pluralizationRules; + const postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : undefined; + const warnHtmlMessage = isString(options.warnHtmlInMessage) + ? options.warnHtmlInMessage !== 'off' + : true; + const escapeParameter = !!options.escapeParameterHtml; + const inheritLocale = isBoolean(options.sync) ? options.sync : true; + if (options.formatter) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + } + if (options.preserveDirectiveContent) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + } + let messages = options.messages; + if (isPlainObject(options.sharedMessages)) { + const sharedMessages = options.sharedMessages; + const locales = Object.keys(sharedMessages); + messages = locales.reduce((messages, locale) => { + const message = messages[locale] || (messages[locale] = {}); + assign(message, sharedMessages[locale]); + return messages; + }, (messages || {})); + } + const { __i18n, __root, __injectWithOption } = options; + const datetimeFormats = options.datetimeFormats; + const numberFormats = options.numberFormats; + const flatJson = options.flatJson; + const translateExistCompatible = options + .translateExistCompatible; + return { + locale, + fallbackLocale, + messages, + flatJson, + datetimeFormats, + numberFormats, + missing, + missingWarn, + fallbackWarn, + fallbackRoot, + fallbackFormat, + modifiers, + pluralRules: pluralizationRules, + postTranslation, + warnHtmlMessage, + escapeParameter, + messageResolver: options.messageResolver, + inheritLocale, + translateExistCompatible, + __i18n, + __root, + __injectWithOption + }; + } + /** + * create VueI18n interface factory + * + * @internal + */ + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + function createVueI18n(options = {}, VueI18nLegacy) { + { + const composer = createComposer(convertComposerOptions(options)); + const { __extender } = options; + // defines VueI18n + const vueI18n = { + // id + id: composer.id, + // locale + get locale() { + return composer.locale.value; + }, + set locale(val) { + composer.locale.value = val; + }, + // fallbackLocale + get fallbackLocale() { + return composer.fallbackLocale.value; + }, + set fallbackLocale(val) { + composer.fallbackLocale.value = val; + }, + // messages + get messages() { + return composer.messages.value; + }, + // datetimeFormats + get datetimeFormats() { + return composer.datetimeFormats.value; + }, + // numberFormats + get numberFormats() { + return composer.numberFormats.value; + }, + // availableLocales + get availableLocales() { + return composer.availableLocales; + }, + // formatter + get formatter() { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + // dummy + return { + interpolate() { + return []; + } + }; + }, + set formatter(val) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + }, + // missing + get missing() { + return composer.getMissingHandler(); + }, + set missing(handler) { + composer.setMissingHandler(handler); + }, + // silentTranslationWarn + get silentTranslationWarn() { + return isBoolean(composer.missingWarn) + ? !composer.missingWarn + : composer.missingWarn; + }, + set silentTranslationWarn(val) { + composer.missingWarn = isBoolean(val) ? !val : val; + }, + // silentFallbackWarn + get silentFallbackWarn() { + return isBoolean(composer.fallbackWarn) + ? !composer.fallbackWarn + : composer.fallbackWarn; + }, + set silentFallbackWarn(val) { + composer.fallbackWarn = isBoolean(val) ? !val : val; + }, + // modifiers + get modifiers() { + return composer.modifiers; + }, + // formatFallbackMessages + get formatFallbackMessages() { + return composer.fallbackFormat; + }, + set formatFallbackMessages(val) { + composer.fallbackFormat = val; + }, + // postTranslation + get postTranslation() { + return composer.getPostTranslationHandler(); + }, + set postTranslation(handler) { + composer.setPostTranslationHandler(handler); + }, + // sync + get sync() { + return composer.inheritLocale; + }, + set sync(val) { + composer.inheritLocale = val; + }, + // warnInHtmlMessage + get warnHtmlInMessage() { + return composer.warnHtmlMessage ? 'warn' : 'off'; + }, + set warnHtmlInMessage(val) { + composer.warnHtmlMessage = val !== 'off'; + }, + // escapeParameterHtml + get escapeParameterHtml() { + return composer.escapeParameter; + }, + set escapeParameterHtml(val) { + composer.escapeParameter = val; + }, + // preserveDirectiveContent + get preserveDirectiveContent() { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + return true; + }, + set preserveDirectiveContent(val) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + }, + // pluralizationRules + get pluralizationRules() { + return composer.pluralRules || {}; + }, + // for internal + __composer: composer, + // t + t(...args) { + const [arg1, arg2, arg3] = args; + const options = {}; + let list = null; + let named = null; + if (!isString(arg1)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + const key = arg1; + if (isString(arg2)) { + options.locale = arg2; + } + else if (isArray(arg2)) { + list = arg2; + } + else if (isPlainObject(arg2)) { + named = arg2; + } + if (isArray(arg3)) { + list = arg3; + } + else if (isPlainObject(arg3)) { + named = arg3; + } + // return composer.t(key, (list || named || {}) as any, options) + return Reflect.apply(composer.t, composer, [ + key, + (list || named || {}), + options + ]); + }, + rt(...args) { + return Reflect.apply(composer.rt, composer, [...args]); + }, + // tc + tc(...args) { + const [arg1, arg2, arg3] = args; + const options = { plural: 1 }; + let list = null; + let named = null; + if (!isString(arg1)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + const key = arg1; + if (isString(arg2)) { + options.locale = arg2; + } + else if (isNumber(arg2)) { + options.plural = arg2; + } + else if (isArray(arg2)) { + list = arg2; + } + else if (isPlainObject(arg2)) { + named = arg2; + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isArray(arg3)) { + list = arg3; + } + else if (isPlainObject(arg3)) { + named = arg3; + } + // return composer.t(key, (list || named || {}) as any, options) + return Reflect.apply(composer.t, composer, [ + key, + (list || named || {}), + options + ]); + }, + // te + te(key, locale) { + return composer.te(key, locale); + }, + // tm + tm(key) { + return composer.tm(key); + }, + // getLocaleMessage + getLocaleMessage(locale) { + return composer.getLocaleMessage(locale); + }, + // setLocaleMessage + setLocaleMessage(locale, message) { + composer.setLocaleMessage(locale, message); + }, + // mergeLocaleMessage + mergeLocaleMessage(locale, message) { + composer.mergeLocaleMessage(locale, message); + }, + // d + d(...args) { + return Reflect.apply(composer.d, composer, [...args]); + }, + // getDateTimeFormat + getDateTimeFormat(locale) { + return composer.getDateTimeFormat(locale); + }, + // setDateTimeFormat + setDateTimeFormat(locale, format) { + composer.setDateTimeFormat(locale, format); + }, + // mergeDateTimeFormat + mergeDateTimeFormat(locale, format) { + composer.mergeDateTimeFormat(locale, format); + }, + // n + n(...args) { + return Reflect.apply(composer.n, composer, [...args]); + }, + // getNumberFormat + getNumberFormat(locale) { + return composer.getNumberFormat(locale); + }, + // setNumberFormat + setNumberFormat(locale, format) { + composer.setNumberFormat(locale, format); + }, + // mergeNumberFormat + mergeNumberFormat(locale, format) { + composer.mergeNumberFormat(locale, format); + }, + // getChoiceIndex + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getChoiceIndex(choice, choicesLength) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX)); + return -1; + } + }; + vueI18n.__extender = __extender; + // for vue-devtools timeline event + { + vueI18n.__enableEmitter = (emitter) => { + const __composer = composer; + __composer[EnableEmitter] && __composer[EnableEmitter](emitter); + }; + vueI18n.__disableEmitter = () => { + const __composer = composer; + __composer[DisableEmitter] && __composer[DisableEmitter](); + }; + } + return vueI18n; + } + } + /* eslint-enable @typescript-eslint/no-explicit-any */ + + const baseFormatProps = { + tag: { + type: [String, Object] + }, + locale: { + type: String + }, + scope: { + type: String, + // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050 + validator: (val /* ComponentI18nScope */) => val === 'parent' || val === 'global', + default: 'parent' /* ComponentI18nScope */ + }, + i18n: { + type: Object + } + }; + + function getInterpolateArg( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + { slots }, // SetupContext, + keys) { + if (keys.length === 1 && keys[0] === 'default') { + // default slot with list + const ret = slots.default ? slots.default() : []; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return ret.reduce((slot, current) => { + return [ + ...slot, + // prettier-ignore + ...(current.type === vue.Fragment ? current.children : [current] + ) + ]; + }, []); + } + else { + // named slots + return keys.reduce((arg, key) => { + const slot = slots[key]; + if (slot) { + arg[key] = slot(); + } + return arg; + }, create()); + } + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function getFragmentableTag(tag) { + return vue.Fragment ; + } + + const TranslationImpl = /*#__PURE__*/ vue.defineComponent({ + /* eslint-disable */ + name: 'i18n-t', + props: assign({ + keypath: { + type: String, + required: true + }, + plural: { + type: [Number, String], + // eslint-disable-next-line @typescript-eslint/no-explicit-any + validator: (val) => isNumber(val) || !isNaN(val) + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const { slots, attrs } = context; + // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050 + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return () => { + const keys = Object.keys(slots).filter(key => key !== '_'); + const options = create(); + if (props.locale) { + options.locale = props.locale; + } + if (props.plural !== undefined) { + options.plural = isString(props.plural) ? +props.plural : props.plural; + } + const arg = getInterpolateArg(context, keys); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const children = i18n[TranslateVNodeSymbol](props.keypath, arg, options); + const assignedAttrs = assign(create(), attrs); + const tag = isString(props.tag) || isObject(props.tag) + ? props.tag + : getFragmentableTag(); + return vue.h(tag, assignedAttrs, children); + }; + } + }); + /** + * export the public type for h/tsx inference + * also to avoid inline import() in generated d.ts files + */ + /** + * Translation Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [TranslationProps](component#translationprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Component Interpolation](../guide/advanced/component) + * + * @example + * ```html + *
+ * + * + * {{ $t('tos') }} + * + * + *
+ * ``` + * ```js + * import { createApp } from 'vue' + * import { createI18n } from 'vue-i18n' + * + * const messages = { + * en: { + * tos: 'Term of Service', + * term: 'I accept xxx {0}.' + * }, + * ja: { + * tos: '利用規約', + * term: '私は xxx の{0}に同意します。' + * } + * } + * + * const i18n = createI18n({ + * locale: 'en', + * messages + * }) + * + * const app = createApp({ + * data: { + * url: '/term' + * } + * }).use(i18n).mount('#app') + * ``` + * + * @VueI18nComponent + */ + const Translation = TranslationImpl; + const I18nT = Translation; + + function isVNode(target) { + return isArray(target) && !isString(target[0]); + } + function renderFormatter(props, context, slotKeys, partFormatter) { + const { slots, attrs } = context; + return () => { + const options = { part: true }; + let overrides = create(); + if (props.locale) { + options.locale = props.locale; + } + if (isString(props.format)) { + options.key = props.format; + } + else if (isObject(props.format)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (isString(props.format.key)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + options.key = props.format.key; + } + // Filter out number format options only + overrides = Object.keys(props.format).reduce((options, prop) => { + return slotKeys.includes(prop) + ? assign(create(), options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any + : options; + }, create()); + } + const parts = partFormatter(...[props.value, options, overrides]); + let children = [options.key]; + if (isArray(parts)) { + children = parts.map((part, index) => { + const slot = slots[part.type]; + const node = slot + ? slot({ [part.type]: part.value, index, parts }) + : [part.value]; + if (isVNode(node)) { + node[0].key = `${part.type}-${index}`; + } + return node; + }); + } + else if (isString(parts)) { + children = [parts]; + } + const assignedAttrs = assign(create(), attrs); + const tag = isString(props.tag) || isObject(props.tag) + ? props.tag + : getFragmentableTag(); + return vue.h(tag, assignedAttrs, children); + }; + } + + const NumberFormatImpl = /*#__PURE__*/ vue.defineComponent({ + /* eslint-disable */ + name: 'i18n-n', + props: assign({ + value: { + type: Number, + required: true + }, + format: { + type: [String, Object] + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return renderFormatter(props, context, NUMBER_FORMAT_OPTIONS_KEYS, (...args) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + i18n[NumberPartsSymbol](...args)); + } + }); + /** + * export the public type for h/tsx inference + * also to avoid inline import() in generated d.ts files + */ + /** + * Number Format Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [FormattableProps](component#formattableprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Custom Formatting](../guide/essentials/number#custom-formatting) + * + * @VueI18nDanger + * Not supported IE, due to no support `Intl.NumberFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts) + * + * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-numberformat) + * + * @VueI18nComponent + */ + const NumberFormat = NumberFormatImpl; + const I18nN = NumberFormat; + + const DatetimeFormatImpl = /* #__PURE__*/ vue.defineComponent({ + /* eslint-disable */ + name: 'i18n-d', + props: assign({ + value: { + type: [Number, Date], + required: true + }, + format: { + type: [String, Object] + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return renderFormatter(props, context, DATETIME_FORMAT_OPTIONS_KEYS, (...args) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + i18n[DatetimePartsSymbol](...args)); + } + }); + /** + * Datetime Format Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [FormattableProps](component#formattableprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Custom Formatting](../guide/essentials/datetime#custom-formatting) + * + * @VueI18nDanger + * Not supported IE, due to no support `Intl.DateTimeFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts) + * + * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-datetimeformat) + * + * @VueI18nComponent + */ + const DatetimeFormat = DatetimeFormatImpl; + const I18nD = DatetimeFormat; + + function getComposer$2(i18n, instance) { + const i18nInternal = i18n; + if (i18n.mode === 'composition') { + return (i18nInternal.__getInstance(instance) || i18n.global); + } + else { + const vueI18n = i18nInternal.__getInstance(instance); + return vueI18n != null + ? vueI18n.__composer + : i18n.global.__composer; + } + } + function vTDirective(i18n) { + const _process = (binding) => { + const { instance, modifiers, value } = binding; + /* istanbul ignore if */ + if (!instance || !instance.$) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const composer = getComposer$2(i18n, instance.$); + if (modifiers.preserve) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE)); + } + const parsedValue = parseValue(value); + return [ + Reflect.apply(composer.t, composer, [...makeParams(parsedValue)]), + composer + ]; + }; + const register = (el, binding) => { + const [textContent, composer] = _process(binding); + if (inBrowser && i18n.global === composer) { + // global scope only + el.__i18nWatcher = vue.watch(composer.locale, () => { + binding.instance && binding.instance.$forceUpdate(); + }); + } + el.__composer = composer; + el.textContent = textContent; + }; + const unregister = (el) => { + if (inBrowser && el.__i18nWatcher) { + el.__i18nWatcher(); + el.__i18nWatcher = undefined; + delete el.__i18nWatcher; + } + if (el.__composer) { + el.__composer = undefined; + delete el.__composer; + } + }; + const update = (el, { value }) => { + if (el.__composer) { + const composer = el.__composer; + const parsedValue = parseValue(value); + el.textContent = Reflect.apply(composer.t, composer, [ + ...makeParams(parsedValue) + ]); + } + }; + const getSSRProps = (binding) => { + const [textContent] = _process(binding); + return { textContent }; + }; + return { + created: register, + unmounted: unregister, + beforeUpdate: update, + getSSRProps + }; + } + function parseValue(value) { + if (isString(value)) { + return { path: value }; + } + else if (isPlainObject(value)) { + if (!('path' in value)) { + throw createI18nError(I18nErrorCodes.REQUIRED_VALUE, 'path'); + } + return value; + } + else { + throw createI18nError(I18nErrorCodes.INVALID_VALUE); + } + } + function makeParams(value) { + const { path, locale, args, choice, plural } = value; + const options = {}; + const named = args || {}; + if (isString(locale)) { + options.locale = locale; + } + if (isNumber(choice)) { + options.plural = choice; + } + if (isNumber(plural)) { + options.plural = plural; + } + return [path, named, options]; + } + + function apply(app, i18n, ...options) { + const pluginOptions = isPlainObject(options[0]) + ? options[0] + : {}; + const useI18nComponentName = !!pluginOptions.useI18nComponentName; + const globalInstall = isBoolean(pluginOptions.globalInstall) + ? pluginOptions.globalInstall + : true; + if (globalInstall && useI18nComponentName) { + warn(getWarnMessage(I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE, { + name: Translation.name + })); + } + if (globalInstall) { + [!useI18nComponentName ? Translation.name : 'i18n', 'I18nT'].forEach(name => app.component(name, Translation)); + [NumberFormat.name, 'I18nN'].forEach(name => app.component(name, NumberFormat)); + [DatetimeFormat.name, 'I18nD'].forEach(name => app.component(name, DatetimeFormat)); + } + // install directive + { + app.directive('t', vTDirective(i18n)); + } + } + + var global$1 = (typeof global !== "undefined" ? global : + typeof self !== "undefined" ? self : + typeof window !== "undefined" ? window : {}); + + function getDevtoolsGlobalHook() { + return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__; + } + function getTarget() { + // @ts-ignore + return (typeof navigator !== 'undefined' && typeof window !== 'undefined') + ? window + : typeof global$1 !== 'undefined' + ? global$1 + : {}; + } + const isProxyAvailable = typeof Proxy === 'function'; + + const HOOK_SETUP = 'devtools-plugin:setup'; + const HOOK_PLUGIN_SETTINGS_SET = 'plugin:settings:set'; + + let supported; + let perf; + function isPerformanceSupported() { + var _a; + if (supported !== undefined) { + return supported; + } + if (typeof window !== 'undefined' && window.performance) { + supported = true; + perf = window.performance; + } + else if (typeof global$1 !== 'undefined' && ((_a = global$1.perf_hooks) === null || _a === void 0 ? void 0 : _a.performance)) { + supported = true; + perf = global$1.perf_hooks.performance; + } + else { + supported = false; + } + return supported; + } + function now() { + return isPerformanceSupported() ? perf.now() : Date.now(); + } + + class ApiProxy { + constructor(plugin, hook) { + this.target = null; + this.targetQueue = []; + this.onQueue = []; + this.plugin = plugin; + this.hook = hook; + const defaultSettings = {}; + if (plugin.settings) { + for (const id in plugin.settings) { + const item = plugin.settings[id]; + defaultSettings[id] = item.defaultValue; + } + } + const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin.id}`; + let currentSettings = Object.assign({}, defaultSettings); + try { + const raw = localStorage.getItem(localSettingsSaveId); + const data = JSON.parse(raw); + Object.assign(currentSettings, data); + } + catch (e) { + // noop + } + this.fallbacks = { + getSettings() { + return currentSettings; + }, + setSettings(value) { + try { + localStorage.setItem(localSettingsSaveId, JSON.stringify(value)); + } + catch (e) { + // noop + } + currentSettings = value; + }, + now() { + return now(); + }, + }; + if (hook) { + hook.on(HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => { + if (pluginId === this.plugin.id) { + this.fallbacks.setSettings(value); + } + }); + } + this.proxiedOn = new Proxy({}, { + get: (_target, prop) => { + if (this.target) { + return this.target.on[prop]; + } + else { + return (...args) => { + this.onQueue.push({ + method: prop, + args, + }); + }; + } + }, + }); + this.proxiedTarget = new Proxy({}, { + get: (_target, prop) => { + if (this.target) { + return this.target[prop]; + } + else if (prop === 'on') { + return this.proxiedOn; + } + else if (Object.keys(this.fallbacks).includes(prop)) { + return (...args) => { + this.targetQueue.push({ + method: prop, + args, + resolve: () => { }, + }); + return this.fallbacks[prop](...args); + }; + } + else { + return (...args) => { + return new Promise(resolve => { + this.targetQueue.push({ + method: prop, + args, + resolve, + }); + }); + }; + } + }, + }); + } + async setRealTarget(target) { + this.target = target; + for (const item of this.onQueue) { + this.target.on[item.method](...item.args); + } + for (const item of this.targetQueue) { + item.resolve(await this.target[item.method](...item.args)); + } + } + } + + function setupDevtoolsPlugin(pluginDescriptor, setupFn) { + const descriptor = pluginDescriptor; + const target = getTarget(); + const hook = getDevtoolsGlobalHook(); + const enableProxy = isProxyAvailable && descriptor.enableEarlyProxy; + if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) { + hook.emit(HOOK_SETUP, pluginDescriptor, setupFn); + } + else { + const proxy = enableProxy ? new ApiProxy(descriptor, hook) : null; + const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || []; + list.push({ + pluginDescriptor: descriptor, + setupFn, + proxy, + }); + if (proxy) + setupFn(proxy.proxiedTarget); + } + } + + const VueDevToolsLabels = { + ["vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */]: 'Vue I18n devtools', + ["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */]: 'I18n Resources', + ["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */]: 'Vue I18n' + }; + const VueDevToolsPlaceholders = { + ["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */]: 'Search for scopes ...' + }; + const VueDevToolsTimelineColors = { + ["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */]: 0xffcd19 + }; + + const VUE_I18N_COMPONENT_TYPES = 'vue-i18n: composer properties'; + let devtoolsApi; + async function enableDevTools(app, i18n) { + return new Promise((resolve, reject) => { + try { + setupDevtoolsPlugin({ + id: "vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */, + label: VueDevToolsLabels["vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */], + packageName: 'vue-i18n', + homepage: 'https://vue-i18n.intlify.dev', + logo: 'https://vue-i18n.intlify.dev/vue-i18n-devtools-logo.png', + componentStateTypes: [VUE_I18N_COMPONENT_TYPES], + app: app // eslint-disable-line @typescript-eslint/no-explicit-any + }, api => { + devtoolsApi = api; + api.on.visitComponentTree(({ componentInstance, treeNode }) => { + updateComponentTreeTags(componentInstance, treeNode, i18n); + }); + api.on.inspectComponent(({ componentInstance, instanceData }) => { + if (componentInstance.vnode.el && + componentInstance.vnode.el.__VUE_I18N__ && + instanceData) { + if (i18n.mode === 'legacy') { + // ignore global scope on legacy mode + if (componentInstance.vnode.el.__VUE_I18N__ !== + i18n.global.__composer) { + inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__); + } + } + else { + inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__); + } + } + }); + api.addInspector({ + id: "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */, + label: VueDevToolsLabels["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */], + icon: 'language', + treeFilterPlaceholder: VueDevToolsPlaceholders["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */] + }); + api.on.getInspectorTree(payload => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + registerScope(payload, i18n); + } + }); + const roots = new Map(); + api.on.getInspectorState(async (payload) => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + api.unhighlightElement(); + inspectScope(payload, i18n); + if (payload.nodeId === 'global') { + if (!roots.has(payload.app)) { + const [root] = await api.getComponentInstances(payload.app); + roots.set(payload.app, root); + } + api.highlightElement(roots.get(payload.app)); + } + else { + const instance = getComponentInstance(payload.nodeId, i18n); + instance && api.highlightElement(instance); + } + } + }); + api.on.editInspectorState(payload => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + editScope(payload, i18n); + } + }); + api.addTimelineLayer({ + id: "vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */, + label: VueDevToolsLabels["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */], + color: VueDevToolsTimelineColors["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */] + }); + resolve(true); + }); + } + catch (e) { + console.error(e); + reject(false); + } + }); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function getI18nScopeLable(instance) { + return (instance.type.name || + instance.type.displayName || + instance.type.__file || + 'Anonymous'); + } + function updateComponentTreeTags(instance, // eslint-disable-line @typescript-eslint/no-explicit-any + treeNode, i18n) { + // prettier-ignore + const global = i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + if (instance && instance.vnode.el && instance.vnode.el.__VUE_I18N__) { + // add custom tags local scope only + if (instance.vnode.el.__VUE_I18N__ !== global) { + const tag = { + label: `i18n (${getI18nScopeLable(instance)} Scope)`, + textColor: 0x000000, + backgroundColor: 0xffcd19 + }; + treeNode.tags.push(tag); + } + } + } + function inspectComposer(instanceData, composer) { + const type = VUE_I18N_COMPONENT_TYPES; + instanceData.state.push({ + type, + key: 'locale', + editable: true, + value: composer.locale.value + }); + instanceData.state.push({ + type, + key: 'availableLocales', + editable: false, + value: composer.availableLocales + }); + instanceData.state.push({ + type, + key: 'fallbackLocale', + editable: true, + value: composer.fallbackLocale.value + }); + instanceData.state.push({ + type, + key: 'inheritLocale', + editable: true, + value: composer.inheritLocale + }); + instanceData.state.push({ + type, + key: 'messages', + editable: false, + value: getLocaleMessageValue(composer.messages.value) + }); + { + instanceData.state.push({ + type, + key: 'datetimeFormats', + editable: false, + value: composer.datetimeFormats.value + }); + instanceData.state.push({ + type, + key: 'numberFormats', + editable: false, + value: composer.numberFormats.value + }); + } + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function getLocaleMessageValue(messages) { + const value = {}; + Object.keys(messages).forEach((key) => { + const v = messages[key]; + if (isFunction(v) && 'source' in v) { + value[key] = getMessageFunctionDetails(v); + } + else if (isMessageAST(v) && v.loc && v.loc.source) { + value[key] = v.loc.source; + } + else if (isObject(v)) { + value[key] = getLocaleMessageValue(v); + } + else { + value[key] = v; + } + }); + return value; + } + const ESC = { + '<': '<', + '>': '>', + '"': '"', + '&': '&' + }; + function escape(s) { + return s.replace(/[<>"&]/g, escapeChar); + } + function escapeChar(a) { + return ESC[a] || a; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function getMessageFunctionDetails(func) { + const argString = func.source ? `("${escape(func.source)}")` : `(?)`; + return { + _custom: { + type: 'function', + display: `ƒ ${argString}` + } + }; + } + function registerScope(payload, i18n) { + payload.rootNodes.push({ + id: 'global', + label: 'Global Scope' + }); + // prettier-ignore + const global = i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + for (const [keyInstance, instance] of i18n.__instances) { + // prettier-ignore + const composer = i18n.mode === 'composition' + ? instance + : instance.__composer; + if (global === composer) { + continue; + } + payload.rootNodes.push({ + id: composer.id.toString(), + label: `${getI18nScopeLable(keyInstance)} Scope` + }); + } + } + function getComponentInstance(nodeId, i18n) { + let instance = null; + if (nodeId !== 'global') { + for (const [component, composer] of i18n.__instances.entries()) { + if (composer.id.toString() === nodeId) { + instance = component; + break; + } + } + } + return instance; + } + function getComposer$1(nodeId, i18n) { + if (nodeId === 'global') { + return i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + } + else { + const instance = Array.from(i18n.__instances.values()).find(item => item.id.toString() === nodeId); + if (instance) { + return i18n.mode === 'composition' + ? instance + : instance.__composer; + } + else { + return null; + } + } + } + function inspectScope(payload, i18n + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ) { + const composer = getComposer$1(payload.nodeId, i18n); + if (composer) { + // TODO: + // eslint-disable-next-line @typescript-eslint/no-explicit-any + payload.state = makeScopeInspectState(composer); + } + return null; + } + function makeScopeInspectState(composer) { + const state = {}; + const localeType = 'Locale related info'; + const localeStates = [ + { + type: localeType, + key: 'locale', + editable: true, + value: composer.locale.value + }, + { + type: localeType, + key: 'fallbackLocale', + editable: true, + value: composer.fallbackLocale.value + }, + { + type: localeType, + key: 'availableLocales', + editable: false, + value: composer.availableLocales + }, + { + type: localeType, + key: 'inheritLocale', + editable: true, + value: composer.inheritLocale + } + ]; + state[localeType] = localeStates; + const localeMessagesType = 'Locale messages info'; + const localeMessagesStates = [ + { + type: localeMessagesType, + key: 'messages', + editable: false, + value: getLocaleMessageValue(composer.messages.value) + } + ]; + state[localeMessagesType] = localeMessagesStates; + { + const datetimeFormatsType = 'Datetime formats info'; + const datetimeFormatsStates = [ + { + type: datetimeFormatsType, + key: 'datetimeFormats', + editable: false, + value: composer.datetimeFormats.value + } + ]; + state[datetimeFormatsType] = datetimeFormatsStates; + const numberFormatsType = 'Datetime formats info'; + const numberFormatsStates = [ + { + type: numberFormatsType, + key: 'numberFormats', + editable: false, + value: composer.numberFormats.value + } + ]; + state[numberFormatsType] = numberFormatsStates; + } + return state; + } + function addTimelineEvent(event, payload) { + if (devtoolsApi) { + let groupId; + if (payload && 'groupId' in payload) { + groupId = payload.groupId; + delete payload.groupId; + } + devtoolsApi.addTimelineEvent({ + layerId: "vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */, + event: { + title: event, + groupId, + time: Date.now(), + meta: {}, + data: payload || {}, + logType: event === "compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */ + ? 'error' + : event === "fallback" /* VueDevToolsTimelineEvents.FALBACK */ || + event === "missing" /* VueDevToolsTimelineEvents.MISSING */ + ? 'warning' + : 'default' + } + }); + } + } + function editScope(payload, i18n) { + const composer = getComposer$1(payload.nodeId, i18n); + if (composer) { + const [field] = payload.path; + if (field === 'locale' && isString(payload.state.value)) { + composer.locale.value = payload.state.value; + } + else if (field === 'fallbackLocale' && + (isString(payload.state.value) || + isArray(payload.state.value) || + isObject(payload.state.value))) { + composer.fallbackLocale.value = payload.state.value; + } + else if (field === 'inheritLocale' && isBoolean(payload.state.value)) { + composer.inheritLocale = payload.state.value; + } + } + } + + /** + * Supports compatibility for legacy vue-i18n APIs + * This mixin is used when we use vue-i18n@v9.x or later + */ + function defineMixin(vuei18n, composer, i18n) { + return { + beforeCreate() { + const instance = vue.getCurrentInstance(); + /* istanbul ignore if */ + if (!instance) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const options = this.$options; + if (options.i18n) { + const optionsI18n = options.i18n; + if (options.__i18n) { + optionsI18n.__i18n = options.__i18n; + } + optionsI18n.__root = composer; + if (this === this.$root) { + // merge option and gttach global + this.$i18n = mergeToGlobal(vuei18n, optionsI18n); + } + else { + optionsI18n.__injectWithOption = true; + optionsI18n.__extender = i18n.__vueI18nExtend; + // atttach local VueI18n instance + this.$i18n = createVueI18n(optionsI18n); + // extend VueI18n instance + const _vueI18n = this.$i18n; + if (_vueI18n.__extender) { + _vueI18n.__disposer = _vueI18n.__extender(this.$i18n); + } + } + } + else if (options.__i18n) { + if (this === this.$root) { + // merge option and gttach global + this.$i18n = mergeToGlobal(vuei18n, options); + } + else { + // atttach local VueI18n instance + this.$i18n = createVueI18n({ + __i18n: options.__i18n, + __injectWithOption: true, + __extender: i18n.__vueI18nExtend, + __root: composer + }); + // extend VueI18n instance + const _vueI18n = this.$i18n; + if (_vueI18n.__extender) { + _vueI18n.__disposer = _vueI18n.__extender(this.$i18n); + } + } + } + else { + // attach global VueI18n instance + this.$i18n = vuei18n; + } + if (options.__i18nGlobal) { + adjustI18nResources(composer, options, options); + } + // defines vue-i18n legacy APIs + this.$t = (...args) => this.$i18n.t(...args); + this.$rt = (...args) => this.$i18n.rt(...args); + this.$tc = (...args) => this.$i18n.tc(...args); + this.$te = (key, locale) => this.$i18n.te(key, locale); + this.$d = (...args) => this.$i18n.d(...args); + this.$n = (...args) => this.$i18n.n(...args); + this.$tm = (key) => this.$i18n.tm(key); + i18n.__setInstance(instance, this.$i18n); + }, + mounted() { + /* istanbul ignore if */ + if (this.$el && + this.$i18n) { + const _vueI18n = this.$i18n; + this.$el.__VUE_I18N__ = _vueI18n.__composer; + const emitter = (this.__v_emitter = + createEmitter()); + _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter); + emitter.on('*', addTimelineEvent); + } + }, + unmounted() { + const instance = vue.getCurrentInstance(); + /* istanbul ignore if */ + if (!instance) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const _vueI18n = this.$i18n; + /* istanbul ignore if */ + if (this.$el && + this.$el.__VUE_I18N__) { + if (this.__v_emitter) { + this.__v_emitter.off('*', addTimelineEvent); + delete this.__v_emitter; + } + if (this.$i18n) { + _vueI18n.__disableEmitter && _vueI18n.__disableEmitter(); + delete this.$el.__VUE_I18N__; + } + } + delete this.$t; + delete this.$rt; + delete this.$tc; + delete this.$te; + delete this.$d; + delete this.$n; + delete this.$tm; + if (_vueI18n.__disposer) { + _vueI18n.__disposer(); + delete _vueI18n.__disposer; + delete _vueI18n.__extender; + } + i18n.__deleteInstance(instance); + delete this.$i18n; + } + }; + } + function mergeToGlobal(g, options) { + g.locale = options.locale || g.locale; + g.fallbackLocale = options.fallbackLocale || g.fallbackLocale; + g.missing = options.missing || g.missing; + g.silentTranslationWarn = + options.silentTranslationWarn || g.silentFallbackWarn; + g.silentFallbackWarn = options.silentFallbackWarn || g.silentFallbackWarn; + g.formatFallbackMessages = + options.formatFallbackMessages || g.formatFallbackMessages; + g.postTranslation = options.postTranslation || g.postTranslation; + g.warnHtmlInMessage = options.warnHtmlInMessage || g.warnHtmlInMessage; + g.escapeParameterHtml = options.escapeParameterHtml || g.escapeParameterHtml; + g.sync = options.sync || g.sync; + g.__composer[SetPluralRulesSymbol](options.pluralizationRules || g.pluralizationRules); + const messages = getLocaleMessages(g.locale, { + messages: options.messages, + __i18n: options.__i18n + }); + Object.keys(messages).forEach(locale => g.mergeLocaleMessage(locale, messages[locale])); + if (options.datetimeFormats) { + Object.keys(options.datetimeFormats).forEach(locale => g.mergeDateTimeFormat(locale, options.datetimeFormats[locale])); + } + if (options.numberFormats) { + Object.keys(options.numberFormats).forEach(locale => g.mergeNumberFormat(locale, options.numberFormats[locale])); + } + return g; + } + + /** + * Injection key for {@link useI18n} + * + * @remarks + * The global injection key for I18n instances with `useI18n`. this injection key is used in Web Components. + * Specify the i18n instance created by {@link createI18n} together with `provide` function. + * + * @VueI18nGeneral + */ + const I18nInjectionKey = + /* #__PURE__*/ makeSymbol('global-vue-i18n'); + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + function createI18n(options = {}, VueI18nLegacy) { + // prettier-ignore + const __legacyMode = isBoolean(options.legacy) + ? options.legacy + : true; + // prettier-ignore + const __globalInjection = isBoolean(options.globalInjection) + ? options.globalInjection + : true; + // prettier-ignore + const __allowComposition = __legacyMode + ? !!options.allowComposition + : true; + const __instances = new Map(); + const [globalScope, __global] = createGlobal(options, __legacyMode); + const symbol = /* #__PURE__*/ makeSymbol('vue-i18n' ); + { + if (__legacyMode && __allowComposition && !false) { + warn(getWarnMessage(I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION)); + } + } + function __getInstance(component) { + return __instances.get(component) || null; + } + function __setInstance(component, instance) { + __instances.set(component, instance); + } + function __deleteInstance(component) { + __instances.delete(component); + } + { + const i18n = { + // mode + get mode() { + return __legacyMode + ? 'legacy' + : 'composition'; + }, + // allowComposition + get allowComposition() { + return __allowComposition; + }, + // install plugin + async install(app, ...options) { + { + app.__VUE_I18N__ = i18n; + } + // setup global provider + app.__VUE_I18N_SYMBOL__ = symbol; + app.provide(app.__VUE_I18N_SYMBOL__, i18n); + // set composer & vuei18n extend hook options from plugin options + if (isPlainObject(options[0])) { + const opts = options[0]; + i18n.__composerExtend = + opts.__composerExtend; + i18n.__vueI18nExtend = + opts.__vueI18nExtend; + } + // global method and properties injection for Composition API + let globalReleaseHandler = null; + if (!__legacyMode && __globalInjection) { + globalReleaseHandler = injectGlobalFields(app, i18n.global); + } + // install built-in components and directive + { + apply(app, i18n, ...options); + } + // setup mixin for Legacy API + if (__legacyMode) { + app.mixin(defineMixin(__global, __global.__composer, i18n)); + } + // release global scope + const unmountApp = app.unmount; + app.unmount = () => { + globalReleaseHandler && globalReleaseHandler(); + i18n.dispose(); + unmountApp(); + }; + // setup vue-devtools plugin + { + const ret = await enableDevTools(app, i18n); + if (!ret) { + throw createI18nError(I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN); + } + const emitter = createEmitter(); + if (__legacyMode) { + const _vueI18n = __global; + _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter); + } + else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = __global; + _composer[EnableEmitter] && _composer[EnableEmitter](emitter); + } + emitter.on('*', addTimelineEvent); + } + }, + // global accessor + get global() { + return __global; + }, + dispose() { + globalScope.stop(); + }, + // @internal + __instances, + // @internal + __getInstance, + // @internal + __setInstance, + // @internal + __deleteInstance + }; + return i18n; + } + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + function useI18n(options = {}) { + const instance = vue.getCurrentInstance(); + if (instance == null) { + throw createI18nError(I18nErrorCodes.MUST_BE_CALL_SETUP_TOP); + } + if (!instance.isCE && + instance.appContext.app != null && + !instance.appContext.app.__VUE_I18N_SYMBOL__) { + throw createI18nError(I18nErrorCodes.NOT_INSTALLED); + } + const i18n = getI18nInstance(instance); + const gl = getGlobalComposer(i18n); + const componentOptions = getComponentOptions(instance); + const scope = getScope(options, componentOptions); + { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (i18n.mode === 'legacy' && !options.__useComponent) { + if (!i18n.allowComposition) { + throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE); + } + return useI18nForLegacy(instance, scope, gl, options); + } + } + if (scope === 'global') { + adjustI18nResources(gl, options, componentOptions); + return gl; + } + if (scope === 'parent') { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let composer = getComposer(i18n, instance, options.__useComponent); + if (composer == null) { + { + warn(getWarnMessage(I18nWarnCodes.NOT_FOUND_PARENT_SCOPE)); + } + composer = gl; + } + return composer; + } + const i18nInternal = i18n; + let composer = i18nInternal.__getInstance(instance); + if (composer == null) { + const composerOptions = assign({}, options); + if ('__i18n' in componentOptions) { + composerOptions.__i18n = componentOptions.__i18n; + } + if (gl) { + composerOptions.__root = gl; + } + composer = createComposer(composerOptions); + if (i18nInternal.__composerExtend) { + composer[DisposeSymbol] = + i18nInternal.__composerExtend(composer); + } + setupLifeCycle(i18nInternal, instance, composer); + i18nInternal.__setInstance(instance, composer); + } + return composer; + } + /** + * Cast to VueI18n legacy compatible type + * + * @remarks + * This API is provided only with [vue-i18n-bridge](https://vue-i18n.intlify.dev/guide/migration/ways.html#what-is-vue-i18n-bridge). + * + * The purpose of this function is to convert an {@link I18n} instance created with {@link createI18n | createI18n(legacy: true)} into a `vue-i18n@v8.x` compatible instance of `new VueI18n` in a TypeScript environment. + * + * @param i18n - An instance of {@link I18n} + * @returns A i18n instance which is casted to {@link VueI18n} type + * + * @VueI18nTip + * :new: provided by **vue-i18n-bridge only** + * + * @VueI18nGeneral + */ + /* #__NO_SIDE_EFFECTS__ */ + const castToVueI18n = (i18n + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ) => { + if (!(__VUE_I18N_BRIDGE__ in i18n)) { + throw createI18nError(I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N); + } + return i18n; + }; + function createGlobal(options, legacyMode, VueI18nLegacy // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + const scope = vue.effectScope(); + { + const obj = legacyMode + ? scope.run(() => createVueI18n(options)) + : scope.run(() => createComposer(options)); + if (obj == null) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + return [scope, obj]; + } + } + function getI18nInstance(instance) { + { + const i18n = vue.inject(!instance.isCE + ? instance.appContext.app.__VUE_I18N_SYMBOL__ + : I18nInjectionKey); + /* istanbul ignore if */ + if (!i18n) { + throw createI18nError(!instance.isCE + ? I18nErrorCodes.UNEXPECTED_ERROR + : I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE); + } + return i18n; + } + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function getScope(options, componentOptions) { + // prettier-ignore + return isEmptyObject(options) + ? ('__i18n' in componentOptions) + ? 'local' + : 'global' + : !options.useScope + ? 'local' + : options.useScope; + } + function getGlobalComposer(i18n) { + // prettier-ignore + return i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer + ; + } + function getComposer(i18n, target, useComponent = false) { + let composer = null; + const root = target.root; + let current = getParentComponentInstance(target, useComponent); + while (current != null) { + const i18nInternal = i18n; + if (i18n.mode === 'composition') { + composer = i18nInternal.__getInstance(current); + } + else { + { + const vueI18n = i18nInternal.__getInstance(current); + if (vueI18n != null) { + composer = vueI18n + .__composer; + if (useComponent && + composer && + !composer[InejctWithOptionSymbol] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + composer = null; + } + } + } + } + if (composer != null) { + break; + } + if (root === current) { + break; + } + current = current.parent; + } + return composer; + } + function getParentComponentInstance(target, useComponent = false) { + if (target == null) { + return null; + } + { + // if `useComponent: true` will be specified, we get lexical scope owner instance for use-case slots + return !useComponent + ? target.parent + : target.vnode.ctx || target.parent; // eslint-disable-line @typescript-eslint/no-explicit-any + } + } + function setupLifeCycle(i18n, target, composer) { + let emitter = null; + { + vue.onMounted(() => { + // inject composer instance to DOM for intlify-devtools + if (target.vnode.el) { + target.vnode.el.__VUE_I18N__ = composer; + emitter = createEmitter(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = composer; + _composer[EnableEmitter] && _composer[EnableEmitter](emitter); + emitter.on('*', addTimelineEvent); + } + }, target); + vue.onUnmounted(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = composer; + // remove composer instance from DOM for intlify-devtools + if (target.vnode.el && + target.vnode.el.__VUE_I18N__) { + emitter && emitter.off('*', addTimelineEvent); + _composer[DisableEmitter] && _composer[DisableEmitter](); + delete target.vnode.el.__VUE_I18N__; + } + i18n.__deleteInstance(target); + // dispose extended resources + const dispose = _composer[DisposeSymbol]; + if (dispose) { + dispose(); + delete _composer[DisposeSymbol]; + } + }, target); + } + } + function useI18nForLegacy(instance, scope, root, options = {} // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + const isLocalScope = scope === 'local'; + const _composer = vue.shallowRef(null); + if (isLocalScope && + instance.proxy && + !(instance.proxy.$options.i18n || instance.proxy.$options.__i18n)) { + throw createI18nError(I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION); + } + const _inheritLocale = isBoolean(options.inheritLocale) + ? options.inheritLocale + : !isString(options.locale); + const _locale = vue.ref( + // prettier-ignore + !isLocalScope || _inheritLocale + ? root.locale.value + : isString(options.locale) + ? options.locale + : DEFAULT_LOCALE); + const _fallbackLocale = vue.ref( + // prettier-ignore + !isLocalScope || _inheritLocale + ? root.fallbackLocale.value + : isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale.value); + const _messages = vue.ref(getLocaleMessages(_locale.value, options)); + // prettier-ignore + const _datetimeFormats = vue.ref(isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : { [_locale.value]: {} }); + // prettier-ignore + const _numberFormats = vue.ref(isPlainObject(options.numberFormats) + ? options.numberFormats + : { [_locale.value]: {} }); + // prettier-ignore + const _missingWarn = isLocalScope + ? root.missingWarn + : isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + // prettier-ignore + const _fallbackWarn = isLocalScope + ? root.fallbackWarn + : isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + // prettier-ignore + const _fallbackRoot = isLocalScope + ? root.fallbackRoot + : isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + // configure fall back to root + const _fallbackFormat = !!options.fallbackFormat; + // runtime missing + const _missing = isFunction(options.missing) ? options.missing : null; + // postTranslation handler + const _postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + // prettier-ignore + const _warnHtmlMessage = isLocalScope + ? root.warnHtmlMessage + : isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const _escapeParameter = !!options.escapeParameter; + // prettier-ignore + const _modifiers = isLocalScope + ? root.modifiers + : isPlainObject(options.modifiers) + ? options.modifiers + : {}; + // pluralRules + const _pluralRules = options.pluralRules || (isLocalScope && root.pluralRules); + // track reactivity + function trackReactivityValues() { + return [ + _locale.value, + _fallbackLocale.value, + _messages.value, + _datetimeFormats.value, + _numberFormats.value + ]; + } + // locale + const locale = vue.computed({ + get: () => { + return _composer.value ? _composer.value.locale.value : _locale.value; + }, + set: val => { + if (_composer.value) { + _composer.value.locale.value = val; + } + _locale.value = val; + } + }); + // fallbackLocale + const fallbackLocale = vue.computed({ + get: () => { + return _composer.value + ? _composer.value.fallbackLocale.value + : _fallbackLocale.value; + }, + set: val => { + if (_composer.value) { + _composer.value.fallbackLocale.value = val; + } + _fallbackLocale.value = val; + } + }); + // messages + const messages = vue.computed(() => { + if (_composer.value) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return _composer.value.messages.value; + } + else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return _messages.value; + } + }); + const datetimeFormats = vue.computed(() => _datetimeFormats.value); + const numberFormats = vue.computed(() => _numberFormats.value); + function getPostTranslationHandler() { + return _composer.value + ? _composer.value.getPostTranslationHandler() + : _postTranslation; + } + function setPostTranslationHandler(handler) { + if (_composer.value) { + _composer.value.setPostTranslationHandler(handler); + } + } + function getMissingHandler() { + return _composer.value ? _composer.value.getMissingHandler() : _missing; + } + function setMissingHandler(handler) { + if (_composer.value) { + _composer.value.setMissingHandler(handler); + } + } + function warpWithDeps(fn) { + trackReactivityValues(); + return fn(); + } + function t(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.t, null, [...args])) + : warpWithDeps(() => ''); + } + function rt(...args) { + return _composer.value + ? Reflect.apply(_composer.value.rt, null, [...args]) + : ''; + } + function d(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.d, null, [...args])) + : warpWithDeps(() => ''); + } + function n(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.n, null, [...args])) + : warpWithDeps(() => ''); + } + function tm(key) { + return _composer.value ? _composer.value.tm(key) : {}; + } + function te(key, locale) { + return _composer.value ? _composer.value.te(key, locale) : false; + } + function getLocaleMessage(locale) { + return _composer.value ? _composer.value.getLocaleMessage(locale) : {}; + } + function setLocaleMessage(locale, message) { + if (_composer.value) { + _composer.value.setLocaleMessage(locale, message); + _messages.value[locale] = message; + } + } + function mergeLocaleMessage(locale, message) { + if (_composer.value) { + _composer.value.mergeLocaleMessage(locale, message); + } + } + function getDateTimeFormat(locale) { + return _composer.value ? _composer.value.getDateTimeFormat(locale) : {}; + } + function setDateTimeFormat(locale, format) { + if (_composer.value) { + _composer.value.setDateTimeFormat(locale, format); + _datetimeFormats.value[locale] = format; + } + } + function mergeDateTimeFormat(locale, format) { + if (_composer.value) { + _composer.value.mergeDateTimeFormat(locale, format); + } + } + function getNumberFormat(locale) { + return _composer.value ? _composer.value.getNumberFormat(locale) : {}; + } + function setNumberFormat(locale, format) { + if (_composer.value) { + _composer.value.setNumberFormat(locale, format); + _numberFormats.value[locale] = format; + } + } + function mergeNumberFormat(locale, format) { + if (_composer.value) { + _composer.value.mergeNumberFormat(locale, format); + } + } + const wrapper = { + get id() { + return _composer.value ? _composer.value.id : -1; + }, + locale, + fallbackLocale, + messages, + datetimeFormats, + numberFormats, + get inheritLocale() { + return _composer.value ? _composer.value.inheritLocale : _inheritLocale; + }, + set inheritLocale(val) { + if (_composer.value) { + _composer.value.inheritLocale = val; + } + }, + get availableLocales() { + return _composer.value + ? _composer.value.availableLocales + : Object.keys(_messages.value); + }, + get modifiers() { + return (_composer.value ? _composer.value.modifiers : _modifiers); + }, + get pluralRules() { + return (_composer.value ? _composer.value.pluralRules : _pluralRules); + }, + get isGlobal() { + return _composer.value ? _composer.value.isGlobal : false; + }, + get missingWarn() { + return _composer.value ? _composer.value.missingWarn : _missingWarn; + }, + set missingWarn(val) { + if (_composer.value) { + _composer.value.missingWarn = val; + } + }, + get fallbackWarn() { + return _composer.value ? _composer.value.fallbackWarn : _fallbackWarn; + }, + set fallbackWarn(val) { + if (_composer.value) { + _composer.value.missingWarn = val; + } + }, + get fallbackRoot() { + return _composer.value ? _composer.value.fallbackRoot : _fallbackRoot; + }, + set fallbackRoot(val) { + if (_composer.value) { + _composer.value.fallbackRoot = val; + } + }, + get fallbackFormat() { + return _composer.value ? _composer.value.fallbackFormat : _fallbackFormat; + }, + set fallbackFormat(val) { + if (_composer.value) { + _composer.value.fallbackFormat = val; + } + }, + get warnHtmlMessage() { + return _composer.value + ? _composer.value.warnHtmlMessage + : _warnHtmlMessage; + }, + set warnHtmlMessage(val) { + if (_composer.value) { + _composer.value.warnHtmlMessage = val; + } + }, + get escapeParameter() { + return _composer.value + ? _composer.value.escapeParameter + : _escapeParameter; + }, + set escapeParameter(val) { + if (_composer.value) { + _composer.value.escapeParameter = val; + } + }, + t, + getPostTranslationHandler, + setPostTranslationHandler, + getMissingHandler, + setMissingHandler, + rt, + d, + n, + tm, + te, + getLocaleMessage, + setLocaleMessage, + mergeLocaleMessage, + getDateTimeFormat, + setDateTimeFormat, + mergeDateTimeFormat, + getNumberFormat, + setNumberFormat, + mergeNumberFormat + }; + function sync(composer) { + composer.locale.value = _locale.value; + composer.fallbackLocale.value = _fallbackLocale.value; + Object.keys(_messages.value).forEach(locale => { + composer.mergeLocaleMessage(locale, _messages.value[locale]); + }); + Object.keys(_datetimeFormats.value).forEach(locale => { + composer.mergeDateTimeFormat(locale, _datetimeFormats.value[locale]); + }); + Object.keys(_numberFormats.value).forEach(locale => { + composer.mergeNumberFormat(locale, _numberFormats.value[locale]); + }); + composer.escapeParameter = _escapeParameter; + composer.fallbackFormat = _fallbackFormat; + composer.fallbackRoot = _fallbackRoot; + composer.fallbackWarn = _fallbackWarn; + composer.missingWarn = _missingWarn; + composer.warnHtmlMessage = _warnHtmlMessage; + } + vue.onBeforeMount(() => { + if (instance.proxy == null || instance.proxy.$i18n == null) { + throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const composer = (_composer.value = instance.proxy.$i18n + .__composer); + if (scope === 'global') { + _locale.value = composer.locale.value; + _fallbackLocale.value = composer.fallbackLocale.value; + _messages.value = composer.messages.value; + _datetimeFormats.value = composer.datetimeFormats.value; + _numberFormats.value = composer.numberFormats.value; + } + else if (isLocalScope) { + sync(composer); + } + }); + return wrapper; + } + const globalExportProps = [ + 'locale', + 'fallbackLocale', + 'availableLocales' + ]; + const globalExportMethods = ['t', 'rt', 'd', 'n', 'tm', 'te'] + ; + function injectGlobalFields(app, composer) { + const i18n = Object.create(null); + globalExportProps.forEach(prop => { + const desc = Object.getOwnPropertyDescriptor(composer, prop); + if (!desc) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const wrap = vue.isRef(desc.value) // check computed props + ? { + get() { + return desc.value.value; + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + set(val) { + desc.value.value = val; + } + } + : { + get() { + return desc.get && desc.get(); + } + }; + Object.defineProperty(i18n, prop, wrap); + }); + app.config.globalProperties.$i18n = i18n; + globalExportMethods.forEach(method => { + const desc = Object.getOwnPropertyDescriptor(composer, method); + if (!desc || !desc.value) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + Object.defineProperty(app.config.globalProperties, `$${method}`, desc); + }); + const dispose = () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete app.config.globalProperties.$i18n; + globalExportMethods.forEach(method => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete app.config.globalProperties[`$${method}`]; + }); + }; + return dispose; + } + + // register message compiler at vue-i18n + { + registerMessageCompiler(compile); + } + // register message resolver at vue-i18n + registerMessageResolver(resolveValue); + // register fallback locale at vue-i18n + registerLocaleFallbacker(fallbackWithLocaleChain); + // NOTE: experimental !! + { + const target = getGlobalThis(); + target.__INTLIFY__ = true; + setDevToolsHook(target.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__); + } + { + initDev(); + } + + exports.DatetimeFormat = DatetimeFormat; + exports.I18nD = I18nD; + exports.I18nInjectionKey = I18nInjectionKey; + exports.I18nN = I18nN; + exports.I18nT = I18nT; + exports.NumberFormat = NumberFormat; + exports.Translation = Translation; + exports.VERSION = VERSION; + exports.castToVueI18n = castToVueI18n; + exports.createI18n = createI18n; + exports.useI18n = useI18n; + exports.vTDirective = vTDirective; + + return exports; + +})({}, Vue); diff --git a/node_modules/vue-i18n/dist/vue-i18n.global.prod.js b/node_modules/vue-i18n/dist/vue-i18n.global.prod.js new file mode 100644 index 0000000..7772e45 --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.global.prod.js @@ -0,0 +1,6 @@ +/*! + * vue-i18n v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +var VueI18n=function(e,t){"use strict";function n(e,t){"undefined"!=typeof console&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}const r="undefined"!=typeof window,a=(e,t=!1)=>t?Symbol.for(e):Symbol(e),o=(e,t,n)=>l({l:e,k:t,s:n}),l=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),s=e=>"number"==typeof e&&isFinite(e),c=e=>"[object Date]"===y(e),u=e=>"[object RegExp]"===y(e),i=e=>I(e)&&0===Object.keys(e).length,f=Object.assign,m=Object.create,_=(e=null)=>m(e);function p(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/").replace(/=/g,"=")}function d(e){return e.replace(/&(?![a-zA-Z0-9#]{2,6};)/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")}const g=Object.prototype.hasOwnProperty;function E(e,t){return g.call(e,t)}const b=Array.isArray,v=e=>"function"==typeof e,k=e=>"string"==typeof e,h=e=>"boolean"==typeof e,L=e=>null!==e&&"object"==typeof e,N=e=>L(e)&&v(e.then)&&v(e.catch),T=Object.prototype.toString,y=e=>T.call(e),I=e=>{if(!L(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t.constructor===Object};function O(e,t=""){return e.reduce(((e,n,r)=>0===r?e+n:e+t+n),"")}function C(e){let t=e;return()=>++t}const P=e=>!L(e)||b(e);function A(e,t){if(P(e)||P(t))throw new Error("Invalid value");const n=[{src:e,des:t}];for(;n.length;){const{src:e,des:t}=n.pop();Object.keys(e).forEach((r=>{"__proto__"!==r&&(L(e[r])&&!L(t[r])&&(t[r]=Array.isArray(e[r])?[]:_()),P(t[r])||P(e[r])?t[r]=e[r]:n.push({src:e[r],des:t[r]}))}))}}function R(e,t,n){const r={start:e,end:t};return null!=n&&(r.source=n),r}const F={USE_MODULO_SYNTAX:1,__EXTEND_POINT__:2};const S={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16,__EXTEND_POINT__:17};function D(e,t,n={}){const{domain:r,messages:a,args:o}=n,l=new SyntaxError(String(e));return l.code=e,t&&(l.location=t),l.domain=r,l}function M(e){throw e}const w=" ",x="\r",W="\n",U=String.fromCharCode(8232),$=String.fromCharCode(8233);function H(e){const t=e;let n=0,r=1,a=1,o=0;const l=e=>t[e]===x&&t[e+1]===W,s=e=>t[e]===$,c=e=>t[e]===U,u=e=>l(e)||(e=>t[e]===W)(e)||s(e)||c(e),i=e=>l(e)||s(e)||c(e)?W:t[e];function f(){return o=0,u(n)&&(r++,a=0),l(n)&&n++,n++,a++,t[n]}return{index:()=>n,line:()=>r,column:()=>a,peekOffset:()=>o,charAt:i,currentChar:()=>i(n),currentPeek:()=>i(n+o),next:f,peek:function(){return l(n+o)&&o++,o++,t[n+o]},reset:function(){n=0,r=1,a=1,o=0},resetPeek:function(e=0){o=e},skipToPeek:function(){const e=n+o;for(;e!==n;)f();o=0}}}const j=void 0,V="'";function X(e,t={}){const n=!1!==t.location,r=H(e),a=()=>r.index(),o=()=>{return e=r.line(),t=r.column(),n=r.index(),{line:e,column:t,offset:n};var e,t,n},l=o(),s=a(),c={currentType:14,offset:s,startLoc:l,endLoc:l,lastType:14,lastOffset:s,lastStartLoc:l,lastEndLoc:l,braceNest:0,inLinked:!1,text:""},u=()=>c,{onError:i}=t;function f(e,t,r){e.endLoc=o(),e.currentType=t;const a={type:t};return n&&(a.loc=R(e.startLoc,e.endLoc)),null!=r&&(a.value=r),a}const m=e=>f(e,14);function _(e,t){return e.currentChar()===t?(e.next(),t):(S.EXPECTED_TOKEN,o(),"")}function p(e){let t="";for(;e.currentPeek()===w||e.currentPeek()===W;)t+=e.currentPeek(),e.peek();return t}function d(e){const t=p(e);return e.skipToPeek(),t}function g(e){if(e===j)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function E(e,t){const{currentType:n}=t;if(2!==n)return!1;p(e);const r=function(e){if(e===j)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function b(e){p(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function v(e,t=!0){const n=(t=!1,r="",a=!1)=>{const o=e.currentPeek();return"{"===o?"%"!==r&&t:"@"!==o&&o?"%"===o?(e.peek(),n(t,"%",!0)):"|"===o?!("%"!==r&&!a)||!(r===w||r===W):o===w?(e.peek(),n(!0,w,a)):o!==W||(e.peek(),n(!0,W,a)):"%"===r||t},r=n();return t&&e.resetPeek(),r}function k(e,t){const n=e.currentChar();return n===j?j:t(n)?(e.next(),n):null}function h(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t}function L(e){return k(e,h)}function N(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t||45===t}function T(e){return k(e,N)}function y(e){const t=e.charCodeAt(0);return t>=48&&t<=57}function I(e){return k(e,y)}function O(e){const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function C(e){return k(e,O)}function P(e){let t="",n="";for(;t=I(e);)n+=t;return n}function A(e){let t="";for(;;){const n=e.currentChar();if("{"===n||"}"===n||"@"===n||"|"===n||!n)break;if("%"===n){if(!v(e))break;t+=n,e.next()}else if(n===w||n===W)if(v(e))t+=n,e.next();else{if(b(e))break;t+=n,e.next()}else t+=n,e.next()}return t}function F(e){return e!==V&&e!==W}function D(e){const t=e.currentChar();switch(t){case"\\":case"'":return e.next(),`\\${t}`;case"u":return M(e,t,4);case"U":return M(e,t,6);default:return S.UNKNOWN_ESCAPE_SEQUENCE,o(),""}}function M(e,t,n){_(e,t);let r="";for(let a=0;a=1&&(S.NOT_ALLOW_NEST_PLACEHOLDER,o()),e.next(),n=f(t,2,"{"),d(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&(S.EMPTY_PLACEHOLDER,o()),e.next(),n=f(t,3,"}"),t.braceNest--,t.braceNest>0&&d(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),n;case"@":return t.braceNest>0&&(S.UNTERMINATED_CLOSING_BRACE,o()),n=X(e,t)||m(t),t.braceNest=0,n;default:{let r=!0,a=!0,l=!0;if(b(e))return t.braceNest>0&&(S.UNTERMINATED_CLOSING_BRACE,o()),n=f(t,1,U(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(5===t.currentType||6===t.currentType||7===t.currentType))return S.UNTERMINATED_CLOSING_BRACE,o(),t.braceNest=0,G(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;p(e);const r=g(e.currentPeek());return e.resetPeek(),r}(e,t))return n=f(t,5,function(e){d(e);let t="",n="";for(;t=T(e);)n+=t;return e.currentChar()===j&&(S.UNTERMINATED_CLOSING_BRACE,o()),n}(e)),d(e),n;if(a=E(e,t))return n=f(t,6,function(e){d(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${P(e)}`):t+=P(e),e.currentChar()===j&&(S.UNTERMINATED_CLOSING_BRACE,o()),t}(e)),d(e),n;if(l=function(e,t){const{currentType:n}=t;if(2!==n)return!1;p(e);const r=e.currentPeek()===V;return e.resetPeek(),r}(e,t))return n=f(t,7,function(e){d(e),_(e,"'");let t="",n="";for(;t=k(e,F);)n+="\\"===t?D(e):t;const r=e.currentChar();return r===W||r===j?(S.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,o(),r===W&&(e.next(),_(e,"'")),n):(_(e,"'"),n)}(e)),d(e),n;if(!r&&!a&&!l)return n=f(t,13,function(e){d(e);let t="",n="";for(;t=k(e,x);)n+=t;return n}(e)),S.INVALID_TOKEN_IN_PLACEHOLDER,o(),n.value,d(e),n;break}}return n}function X(e,t){const{currentType:n}=t;let r=null;const a=e.currentChar();switch(8!==n&&9!==n&&12!==n&&10!==n||a!==W&&a!==w||(S.INVALID_LINKED_FORMAT,o()),a){case"@":return e.next(),r=f(t,8,"@"),t.inLinked=!0,r;case".":return d(e),e.next(),f(t,9,".");case":":return d(e),e.next(),f(t,10,":");default:return b(e)?(r=f(t,1,U(e)),t.braceNest=0,t.inLinked=!1,r):function(e,t){const{currentType:n}=t;if(8!==n)return!1;p(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,t)||function(e,t){const{currentType:n}=t;if(8!==n&&12!==n)return!1;p(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,t)?(d(e),X(e,t)):function(e,t){const{currentType:n}=t;if(9!==n)return!1;p(e);const r=g(e.currentPeek());return e.resetPeek(),r}(e,t)?(d(e),f(t,12,function(e){let t="",n="";for(;t=L(e);)n+=t;return n}(e))):function(e,t){const{currentType:n}=t;if(10!==n)return!1;const r=()=>{const t=e.currentPeek();return"{"===t?g(e.peek()):!("@"===t||"%"===t||"|"===t||":"===t||"."===t||t===w||!t)&&(t===W?(e.peek(),r()):v(e,!1))},a=r();return e.resetPeek(),a}(e,t)?(d(e),"{"===a?$(e,t)||r:f(t,11,function(e){const t=n=>{const r=e.currentChar();return"{"!==r&&"%"!==r&&"@"!==r&&"|"!==r&&"("!==r&&")"!==r&&r?r===w?n:(n+=r,e.next(),t(n)):n};return t("")}(e))):(8===n&&(S.INVALID_LINKED_FORMAT,o()),t.braceNest=0,t.inLinked=!1,G(e,t))}}function G(e,t){let n={type:14};if(t.braceNest>0)return $(e,t)||m(t);if(t.inLinked)return X(e,t)||m(t);switch(e.currentChar()){case"{":return $(e,t)||m(t);case"}":return S.UNBALANCED_CLOSING_BRACE,o(),e.next(),f(t,3,"}");case"@":return X(e,t)||m(t);default:{if(b(e))return n=f(t,1,U(e)),t.braceNest=0,t.inLinked=!1,n;const{isModulo:r,hasSpace:a}=function(e){const t=p(e),n="%"===e.currentPeek()&&"{"===e.peek();return e.resetPeek(),{isModulo:n,hasSpace:t.length>0}}(e);if(r)return a?f(t,0,A(e)):f(t,4,function(e){d(e);const t=e.currentChar();return"%"!==t&&(S.EXPECTED_TOKEN,o()),e.next(),"%"}(e));if(v(e))return f(t,0,A(e));break}}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:l}=c;return c.lastType=e,c.lastOffset=t,c.lastStartLoc=n,c.lastEndLoc=l,c.offset=a(),c.startLoc=o(),r.currentChar()===j?f(c,14):G(r,c)},currentOffset:a,currentPosition:o,context:u}}const G=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function Y(e,t,n){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const e=parseInt(t||n,16);return e<=55295||e>=57344?String.fromCodePoint(e):"�"}}}function B(e={}){const t=!1!==e.location,{onError:n,onWarn:r}=e;function a(e,n,r){const a={type:e};return t&&(a.start=n,a.end=n,a.loc={start:r,end:r}),a}function o(e,n,r,a){a&&(e.type=a),t&&(e.end=n,e.loc&&(e.loc.end=r))}function l(e,t){const n=e.context(),r=a(3,n.offset,n.startLoc);return r.value=t,o(r,e.currentOffset(),e.currentPosition()),r}function s(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:l}=n,s=a(5,r,l);return s.index=parseInt(t,10),e.nextToken(),o(s,e.currentOffset(),e.currentPosition()),s}function c(e,t,n){const r=e.context(),{lastOffset:l,lastStartLoc:s}=r,c=a(4,l,s);return c.key=t,!0===n&&(c.modulo=!0),e.nextToken(),o(c,e.currentOffset(),e.currentPosition()),c}function u(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:l}=n,s=a(9,r,l);return s.value=t.replace(G,Y),e.nextToken(),o(s,e.currentOffset(),e.currentPosition()),s}function i(e){const t=e.context(),n=a(6,t.offset,t.startLoc);let r=e.nextToken();if(9===r.type){const t=function(e){const t=e.nextToken(),n=e.context(),{lastOffset:r,lastStartLoc:l}=n,s=a(8,r,l);return 12!==t.type?(S.UNEXPECTED_EMPTY_LINKED_MODIFIER,n.lastStartLoc,s.value="",o(s,r,l),{nextConsumeToken:t,node:s}):(null==t.value&&(S.UNEXPECTED_LEXICAL_ANALYSIS,n.lastStartLoc,K(t)),s.value=t.value||"",o(s,e.currentOffset(),e.currentPosition()),{node:s})}(e);n.modifier=t.node,r=t.nextConsumeToken||e.nextToken()}switch(10!==r.type&&(S.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,K(r)),r=e.nextToken(),2===r.type&&(r=e.nextToken()),r.type){case 11:null==r.value&&(S.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,K(r)),n.key=function(e,t){const n=e.context(),r=a(7,n.offset,n.startLoc);return r.value=t,o(r,e.currentOffset(),e.currentPosition()),r}(e,r.value||"");break;case 5:null==r.value&&(S.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,K(r)),n.key=c(e,r.value||"");break;case 6:null==r.value&&(S.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,K(r)),n.key=s(e,r.value||"");break;case 7:null==r.value&&(S.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,K(r)),n.key=u(e,r.value||"");break;default:{S.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const l=e.context(),s=a(7,l.offset,l.startLoc);return s.value="",o(s,l.offset,l.startLoc),n.key=s,o(n,l.offset,l.startLoc),{nextConsumeToken:r,node:n}}}return o(n,e.currentOffset(),e.currentPosition()),{node:n}}function m(e){const t=e.context(),n=a(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let r=null,f=null;do{const a=r||e.nextToken();switch(r=null,a.type){case 0:null==a.value&&(S.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,K(a)),n.items.push(l(e,a.value||""));break;case 6:null==a.value&&(S.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,K(a)),n.items.push(s(e,a.value||""));break;case 4:f=!0;break;case 5:null==a.value&&(S.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,K(a)),n.items.push(c(e,a.value||"",!!f)),f&&(F.USE_MODULO_SYNTAX,t.lastStartLoc,K(a),f=null);break;case 7:null==a.value&&(S.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,K(a)),n.items.push(u(e,a.value||""));break;case 8:{const t=i(e);n.items.push(t.node),r=t.nextConsumeToken||null;break}}}while(14!==t.currentType&&1!==t.currentType);return o(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function _(e){const t=e.context(),{offset:n,startLoc:r}=t,l=m(e);return 14===t.currentType?l:function(e,t,n,r){const l=e.context();let s=0===r.items.length;const c=a(1,t,n);c.cases=[],c.cases.push(r);do{const t=m(e);s||(s=0===t.items.length),c.cases.push(t)}while(14!==l.currentType);return o(c,e.currentOffset(),e.currentPosition()),c}(e,n,r,l)}return{parse:function(n){const r=X(n,f({},e)),l=r.context(),s=a(0,l.offset,l.startLoc);return t&&s.loc&&(s.loc.source=n),s.body=_(r),e.onCacheKey&&(s.cacheKey=e.onCacheKey(n)),14!==l.currentType&&(S.UNEXPECTED_LEXICAL_ANALYSIS,l.lastStartLoc,n[l.offset]),o(s,r.currentOffset(),r.currentPosition()),s}}}function K(e){if(14===e.type)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function z(e,t){for(let n=0;nn,helper:e=>(n.helpers.add(e),e)}}(e);n.helper("normalize"),e.body&&J(e.body,n);const r=n.context();e.helpers=Array.from(r.helpers)}function q(e){if(1===e.items.length){const t=e.items[0];3!==t.type&&9!==t.type||(e.static=t.value,delete t.value)}else{const t=[];for(let n=0;n1){e.push(`${n("plural")}([`),e.indent(r());const a=t.cases.length;for(let n=0;n{const n=k(t.mode)?t.mode:"normal",r=k(t.filename)?t.filename:"message.intl",a=!!t.sourceMap,o=null!=t.breakLineCode?t.breakLineCode:"arrow"===n?";":"\n",l=t.needIndent?t.needIndent:"arrow"!==n,s=e.helpers||[],c=function(e,t){const{sourceMap:n,filename:r,breakLineCode:a,needIndent:o}=t,l=!1!==t.location,s={filename:r,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:a,needIndent:o,indentLevel:0};function c(e,t){s.code+=e}function u(e,t=!0){const n=t?a:"";c(o?n+" ".repeat(e):n)}return l&&e.loc&&(s.source=e.loc.source),{context:()=>s,push:c,indent:function(e=!0){const t=++s.indentLevel;e&&u(t)},deindent:function(e=!0){const t=--s.indentLevel;e&&u(t)},newline:function(){u(s.indentLevel)},helper:e=>`_${e}`,needIndent:()=>s.needIndent}}(e,{mode:n,filename:r,sourceMap:a,breakLineCode:o,needIndent:l});c.push("normal"===n?"function __msg__ (ctx) {":"(ctx) => {"),c.indent(l),s.length>0&&(c.push(`const { ${O(s.map((e=>`${e}: _${e}`)),", ")} } = ctx`),c.newline()),c.push("return "),ee(c,e),c.deindent(l),c.push("}"),delete e.helpers;const{code:u,map:i}=c.context();return{ast:e,code:u,map:i?i.toJSON():void 0}};function ne(e,t={}){const n=f({},t),r=!!n.jit,a=!!n.minify,o=null==n.optimize||n.optimize,l=B(n).parse(e);return r?(o&&function(e){const t=e.body;2===t.type?q(t):t.cases.forEach((e=>q(e)))}(l),a&&Z(l),{ast:l,code:""}):(Q(l,n),te(l,n))}function re(e){return L(e)&&0===ue(e)&&(E(e,"b")||E(e,"body"))}const ae=["b","body"];const oe=["c","cases"];const le=["s","static"];const se=["i","items"];const ce=["t","type"];function ue(e){return pe(e,ce)}const ie=["v","value"];function fe(e,t){const n=pe(e,ie);if(null!=n)return n;throw ge(t)}const me=["m","modifier"];const _e=["k","key"];function pe(e,t,n){for(let r=0;re,Te=e=>"",ye="text",Ie=e=>0===e.length?"":O(e),Oe=e=>null==e?"":b(e)||I(e)&&e.toString===T?JSON.stringify(e,null,2):String(e);function Ce(e,t){return e=Math.abs(e),2===t?e?e>1?1:0:1:e?Math.min(e,2):0}function Pe(e={}){const t=e.locale,n=function(e){const t=s(e.pluralIndex)?e.pluralIndex:-1;return e.named&&(s(e.named.count)||s(e.named.n))?s(e.named.count)?e.named.count:s(e.named.n)?e.named.n:t:t}(e),r=L(e.pluralRules)&&k(t)&&v(e.pluralRules[t])?e.pluralRules[t]:Ce,a=L(e.pluralRules)&&k(t)&&v(e.pluralRules[t])?Ce:void 0,o=e.list||[],l=e.named||_();s(e.pluralIndex)&&function(e,t){t.count||(t.count=e),t.n||(t.n=e)}(n,l);function c(t){const n=v(e.messages)?e.messages(t):!!L(e.messages)&&e.messages[t];return n||(e.parent?e.parent.message(t):Te)}const u=I(e.processor)&&v(e.processor.normalize)?e.processor.normalize:Ie,i=I(e.processor)&&v(e.processor.interpolate)?e.processor.interpolate:Oe,m={list:e=>o[e],named:e=>l[e],plural:e=>e[r(n,e.length,a)],linked:(t,...n)=>{const[r,a]=n;let o="text",l="";1===n.length?L(r)?(l=r.modifier||l,o=r.type||o):k(r)&&(l=r||l):2===n.length&&(k(r)&&(l=r||l),k(a)&&(o=a||o));const s=c(t)(m),u="vnode"===o&&b(s)&&l?s[0]:s;return l?(i=l,e.modifiers?e.modifiers[i]:Ne)(u,o):u;var i},message:c,type:I(e.processor)&&k(e.processor.type)?e.processor.type:ye,interpolate:i,normalize:u,values:f(_(),o,l)};return m}const Ae=S.__EXTEND_POINT__,Re=C(Ae),Fe={INVALID_ARGUMENT:Ae,INVALID_DATE_ARGUMENT:Re(),INVALID_ISO_DATE_ARGUMENT:Re(),NOT_SUPPORT_NON_STRING_MESSAGE:Re(),NOT_SUPPORT_LOCALE_PROMISE_VALUE:Re(),NOT_SUPPORT_LOCALE_ASYNC_FUNCTION:Re(),NOT_SUPPORT_LOCALE_TYPE:Re(),__EXTEND_POINT__:Re()};function Se(e,t){return null!=t.locale?Me(t.locale):Me(e.locale)}let De;function Me(e){if(k(e))return e;if(v(e)){if(e.resolvedOnce&&null!=De)return De;if("Function"===e.constructor.name){const t=e();if(N(t))throw Error(Fe.NOT_SUPPORT_LOCALE_PROMISE_VALUE);return De=t}throw Error(Fe.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION)}throw Error(Fe.NOT_SUPPORT_LOCALE_TYPE)}function we(e,t,n){return[...new Set([n,...b(t)?t:L(t)?Object.keys(t):k(t)?[t]:[n]])]}function xe(e,t,n){const r=k(n)?n:Ve,a=e;a.__localeChainCache||(a.__localeChainCache=new Map);let o=a.__localeChainCache.get(r);if(!o){o=[];let e=[n];for(;b(e);)e=We(o,e,t);const l=b(t)||!I(t)?t:t.default?t.default:null;e=k(l)?[l]:l,b(e)&&We(o,e,!1),a.__localeChainCache.set(r,o)}return o}function We(e,t,n){let r=!0;for(let a=0;a`${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;let Ye,Be,Ke;let ze=null;const Je=e=>{ze=e},Qe=()=>ze;let qe=0;function Ze(e={}){const t=v(e.onWarn)?e.onWarn:n,r=k(e.version)?e.version:He,a=k(e.locale)||v(e.locale)?e.locale:Ve,o=v(a)?Ve:a,l=b(e.fallbackLocale)||I(e.fallbackLocale)||k(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:o,s=I(e.messages)?e.messages:et(o),c=I(e.datetimeFormats)?e.datetimeFormats:et(o),i=I(e.numberFormats)?e.numberFormats:et(o),m=f(_(),e.modifiers,{upper:(e,t)=>"text"===t&&k(e)?e.toUpperCase():"vnode"===t&&L(e)&&"__v_isVNode"in e?e.children.toUpperCase():e,lower:(e,t)=>"text"===t&&k(e)?e.toLowerCase():"vnode"===t&&L(e)&&"__v_isVNode"in e?e.children.toLowerCase():e,capitalize:(e,t)=>"text"===t&&k(e)?Ge(e):"vnode"===t&&L(e)&&"__v_isVNode"in e?Ge(e.children):e}),p=e.pluralRules||_(),d=v(e.missing)?e.missing:null,g=!h(e.missingWarn)&&!u(e.missingWarn)||e.missingWarn,E=!h(e.fallbackWarn)&&!u(e.fallbackWarn)||e.fallbackWarn,N=!!e.fallbackFormat,T=!!e.unresolving,y=v(e.postTranslation)?e.postTranslation:null,O=I(e.processor)?e.processor:null,C=!h(e.warnHtmlMessage)||e.warnHtmlMessage,P=!!e.escapeParameter,A=v(e.messageCompiler)?e.messageCompiler:Ye,R=v(e.messageResolver)?e.messageResolver:Be||Le,F=v(e.localeFallbacker)?e.localeFallbacker:Ke||we,S=L(e.fallbackContext)?e.fallbackContext:void 0,D=e,M=L(D.__datetimeFormatters)?D.__datetimeFormatters:new Map,w=L(D.__numberFormatters)?D.__numberFormatters:new Map,x=L(D.__meta)?D.__meta:{};qe++;const W={version:r,cid:qe,locale:a,fallbackLocale:l,messages:s,modifiers:m,pluralRules:p,missing:d,missingWarn:g,fallbackWarn:E,fallbackFormat:N,unresolving:T,postTranslation:y,processor:O,warnHtmlMessage:C,escapeParameter:P,messageCompiler:A,messageResolver:R,localeFallbacker:F,fallbackContext:S,onWarn:t,__meta:x};return W.datetimeFormats=c,W.numberFormats=i,W.__datetimeFormatters=M,W.__numberFormatters=w,W}const et=e=>({[e]:_()});function tt(e,t,n,r,a){const{missing:o,onWarn:l}=e;if(null!==o){const r=o(e,n,t,a);return k(r)?r:t}return t}function nt(e,t,n){e.__localeChainCache=new Map,e.localeFallbacker(e,n,t)}function rt(e,t){const n=t.indexOf(e);if(-1===n)return!1;for(let o=n+1;ofunction(e,t){const n=(r=t,pe(r,ae));var r;if(null==n)throw ge(0);if(1===ue(n)){const t=function(e){return pe(e,oe,[])}(n);return e.plural(t.reduce(((t,n)=>[...t,ot(e,n)]),[]))}return ot(e,n)}(t,e)}function ot(e,t){const n=function(e){return pe(e,le)}(t);if(null!=n)return"text"===e.type?n:e.normalize([n]);{const n=function(e){return pe(e,se,[])}(t).reduce(((t,n)=>[...t,lt(e,n)]),[]);return e.normalize(n)}}function lt(e,t){const n=ue(t);switch(n){case 3:case 9:case 7:case 8:return fe(t,n);case 4:{const r=t;if(E(r,"k")&&r.k)return e.interpolate(e.named(r.k));if(E(r,"key")&&r.key)return e.interpolate(e.named(r.key));throw ge(n)}case 5:{const r=t;if(E(r,"i")&&s(r.i))return e.interpolate(e.list(r.i));if(E(r,"index")&&s(r.index))return e.interpolate(e.list(r.index));throw ge(n)}case 6:{const n=t,r=function(e){return pe(e,me)}(n),a=function(e){const t=pe(e,_e);if(t)return t;throw ge(6)}(n);return e.linked(lt(e,a),r?lt(e,r):void 0,e.type)}default:throw new Error(`unhandled node on format message part: ${n}`)}}const st=e=>e;let ct=_();const ut=()=>"",it=e=>v(e);function ft(e,...t){const{fallbackFormat:n,postTranslation:r,unresolving:a,messageCompiler:o,fallbackLocale:l,messages:c}=e,[u,i]=pt(...t),f=h(i.missingWarn)?i.missingWarn:e.missingWarn,m=h(i.fallbackWarn)?i.fallbackWarn:e.fallbackWarn,g=h(i.escapeParameter)?i.escapeParameter:e.escapeParameter,E=!!i.resolvedMessage,v=k(i.default)||h(i.default)?h(i.default)?o?u:()=>u:i.default:n?o?u:()=>u:"",N=n||""!==v,T=Se(e,i);g&&function(e){b(e.list)?e.list=e.list.map((e=>k(e)?p(e):e)):L(e.named)&&Object.keys(e.named).forEach((t=>{k(e.named[t])&&(e.named[t]=p(e.named[t]))}))}(i);let[y,I,O]=E?[u,T,c[T]||_()]:mt(e,u,T,l,m,f),C=y,P=u;if(E||k(C)||re(C)||it(C)||N&&(C=v,P=C),!(E||(k(C)||re(C)||it(C))&&k(I)))return a?je:u;let A=!1;const R=it(C)?C:_t(e,u,I,C,P,(()=>{A=!0}));if(A)return C;const F=function(e,t,n,r){const{modifiers:a,pluralRules:o,messageResolver:l,fallbackLocale:c,fallbackWarn:u,missingWarn:i,fallbackContext:f}=e,m=r=>{let a=l(n,r);if(null==a&&f){const[,,e]=mt(f,r,t,c,u,i);a=l(e,r)}if(k(a)||re(a)){let n=!1;const o=_t(e,r,t,a,r,(()=>{n=!0}));return n?ut:o}return it(a)?a:ut},_={locale:t,modifiers:a,pluralRules:o,messages:m};e.processor&&(_.processor=e.processor);r.list&&(_.list=r.list);r.named&&(_.named=r.named);s(r.plural)&&(_.pluralIndex=r.plural);return _}(e,I,O,i),S=function(e,t,n){const r=t(n);return r}(0,R,Pe(F));let D=r?r(S,u):S;var M;return g&&k(D)&&(M=(M=(M=D).replace(/(\w+)\s*=\s*"([^"]*)"/g,((e,t,n)=>`${t}="${d(n)}"`))).replace(/(\w+)\s*=\s*'([^']*)'/g,((e,t,n)=>`${t}='${d(n)}'`)),/\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi.test(M)&&(M=M.replace(/(\s+)(on)(\w+\s*=)/gi,"$1on$3")),[/(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi,/(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi].forEach((e=>{M=M.replace(e,"$1javascript:")})),D=M),D}function mt(e,t,n,r,a,o){const{messages:l,onWarn:s,messageResolver:c,localeFallbacker:u}=e,i=u(e,r,n);let f,m=_(),p=null;for(let d=0;dr;return e.locale=n,e.key=t,e}const u=s(r,function(e,t,n,r,a,l){return{locale:t,key:n,warnHtmlMessage:a,onError:e=>{throw l&&l(e),e},onCacheKey:e=>o(t,n,e)}}(0,n,a,0,c,l));return u.locale=n,u.key=t,u.source=r,u}function pt(...e){const[t,n,r]=e,a=_();if(!(k(t)||s(t)||it(t)||re(t)))throw Error(Fe.INVALID_ARGUMENT);const o=s(t)?String(t):(it(t),t);return s(n)?a.plural=n:k(n)?a.default=n:I(n)&&!i(n)?a.named=n:b(n)&&(a.list=n),s(r)?a.plural=r:k(r)?a.default=r:I(r)&&f(a,r),[o,a]}function dt(e,...t){const{datetimeFormats:n,unresolving:r,fallbackLocale:a,onWarn:o,localeFallbacker:l}=e,{__datetimeFormatters:s}=e,[c,u,m,_]=Et(...t);h(m.missingWarn)?m.missingWarn:e.missingWarn;h(m.fallbackWarn)?m.fallbackWarn:e.fallbackWarn;const p=!!m.part,d=Se(e,m),g=l(e,a,d);if(!k(c)||""===c)return new Intl.DateTimeFormat(d,_).format(u);let E,b={},v=null;for(let i=0;i{gt.includes(e)?u[e]=n[e]:o[e]=n[e]})),k(r)?o.locale=r:I(r)&&(u=r),I(a)&&(u=a),[o.key||"",l,o,u]}function bt(e,t,n){const r=e;for(const a in n){const e=`${t}__${a}`;r.__datetimeFormatters.has(e)&&r.__datetimeFormatters.delete(e)}}function vt(e,...t){const{numberFormats:n,unresolving:r,fallbackLocale:a,onWarn:o,localeFallbacker:l}=e,{__numberFormatters:s}=e,[c,u,m,_]=ht(...t);h(m.missingWarn)?m.missingWarn:e.missingWarn;h(m.fallbackWarn)?m.fallbackWarn:e.fallbackWarn;const p=!!m.part,d=Se(e,m),g=l(e,a,d);if(!k(c)||""===c)return new Intl.NumberFormat(d,_).format(u);let E,b={},v=null;for(let i=0;i{kt.includes(e)?l[e]=n[e]:o[e]=n[e]})),k(r)?o.locale=r:I(r)&&(l=r),I(a)&&(l=a),[o.key||"",c,o,l]}function Lt(e,t,n){const r=e;for(const a in n){const e=`${t}__${a}`;r.__numberFormatters.has(e)&&r.__numberFormatters.delete(e)}}const Nt="9.14.5",Tt=Fe.__EXTEND_POINT__,yt=C(Tt),It={UNEXPECTED_RETURN_TYPE:Tt,INVALID_ARGUMENT:yt(),MUST_BE_CALL_SETUP_TOP:yt(),NOT_INSTALLED:yt(),NOT_AVAILABLE_IN_LEGACY_MODE:yt(),REQUIRED_VALUE:yt(),INVALID_VALUE:yt(),CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN:yt(),NOT_INSTALLED_WITH_PROVIDE:yt(),UNEXPECTED_ERROR:yt(),NOT_COMPATIBLE_LEGACY_VUE_I18N:yt(),BRIDGE_SUPPORT_VUE_2_ONLY:yt(),MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION:yt(),NOT_AVAILABLE_COMPOSITION_IN_LEGACY:yt(),__EXTEND_POINT__:yt()};const Ot=a("__translateVNode"),Ct=a("__datetimeParts"),Pt=a("__numberParts"),At=a("__setPluralRules"),Rt=a("__injectWithOption"),Ft=a("__dispose");function St(e){if(!L(e))return e;if(re(e))return e;for(const t in e)if(E(e,t))if(t.includes(".")){const n=t.split("."),r=n.length-1;let a=e,o=!1;for(let e=0;e{if("locale"in e&&"resource"in e){const{locale:t,resource:n}=e;t?(l[t]=l[t]||_(),A(n,l[t])):A(n,l)}else k(e)&&A(JSON.parse(e),l)})),null==a&&o)for(const s in l)E(l,s)&&St(l[s]);return l}function Mt(e){return e.type}function wt(e,t,n){let r=L(t.messages)?t.messages:_();"__i18nGlobal"in n&&(r=Dt(e.locale.value,{messages:r,__i18n:n.__i18nGlobal}));const a=Object.keys(r);if(a.length&&a.forEach((t=>{e.mergeLocaleMessage(t,r[t])})),L(t.datetimeFormats)){const n=Object.keys(t.datetimeFormats);n.length&&n.forEach((n=>{e.mergeDateTimeFormat(n,t.datetimeFormats[n])}))}if(L(t.numberFormats)){const n=Object.keys(t.numberFormats);n.length&&n.forEach((n=>{e.mergeNumberFormat(n,t.numberFormats[n])}))}}function xt(e){return t.createVNode(t.Text,null,e,0)}const Wt=()=>[],Ut=()=>!1;let $t=0;function Ht(e){return(n,r,a,o)=>e(r,a,t.getCurrentInstance()||void 0,o)}function jt(e={},n){const{__root:a,__injectWithOption:o}=e,l=void 0===a,c=e.flatJson,i=r?t.ref:t.shallowRef,m=!!e.translateExistCompatible;let _=!h(e.inheritLocale)||e.inheritLocale;const p=i(a&&_?a.locale.value:k(e.locale)?e.locale:Ve),d=i(a&&_?a.fallbackLocale.value:k(e.fallbackLocale)||b(e.fallbackLocale)||I(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:p.value),g=i(Dt(p.value,e)),N=i(I(e.datetimeFormats)?e.datetimeFormats:{[p.value]:{}}),T=i(I(e.numberFormats)?e.numberFormats:{[p.value]:{}});let y=a?a.missingWarn:!h(e.missingWarn)&&!u(e.missingWarn)||e.missingWarn,O=a?a.fallbackWarn:!h(e.fallbackWarn)&&!u(e.fallbackWarn)||e.fallbackWarn,C=a?a.fallbackRoot:!h(e.fallbackRoot)||e.fallbackRoot,P=!!e.fallbackFormat,R=v(e.missing)?e.missing:null,F=v(e.missing)?Ht(e.missing):null,S=v(e.postTranslation)?e.postTranslation:null,D=a?a.warnHtmlMessage:!h(e.warnHtmlMessage)||e.warnHtmlMessage,M=!!e.escapeParameter;const w=a?a.modifiers:I(e.modifiers)?e.modifiers:{};let x,W=e.pluralRules||a&&a.pluralRules;x=(()=>{l&&Je(null);const t={version:Nt,locale:p.value,fallbackLocale:d.value,messages:g.value,modifiers:w,pluralRules:W,missing:null===F?void 0:F,missingWarn:y,fallbackWarn:O,fallbackFormat:P,unresolving:!0,postTranslation:null===S?void 0:S,warnHtmlMessage:D,escapeParameter:M,messageResolver:e.messageResolver,messageCompiler:e.messageCompiler,__meta:{framework:"vue"}};t.datetimeFormats=N.value,t.numberFormats=T.value,t.__datetimeFormatters=I(x)?x.__datetimeFormatters:void 0,t.__numberFormatters=I(x)?x.__numberFormatters:void 0;const n=Ze(t);return l&&Je(n),n})(),nt(x,p.value,d.value);const U=t.computed({get:()=>p.value,set:e=>{p.value=e,x.locale=p.value}}),$=t.computed({get:()=>d.value,set:e=>{d.value=e,x.fallbackLocale=d.value,nt(x,p.value,e)}}),H=t.computed((()=>g.value)),j=t.computed((()=>N.value)),V=t.computed((()=>T.value));const X=(e,t,n,r,o,c)=>{let u;p.value,d.value,g.value,N.value,T.value;try{0,l||(x.fallbackContext=a?Qe():void 0),u=e(x)}finally{l||(x.fallbackContext=void 0)}if("translate exists"!==n&&s(u)&&u===je||"translate exists"===n&&!u){const[e,n]=t();return a&&C?r(a):o(e)}if(c(u))return u;throw Error(It.UNEXPECTED_RETURN_TYPE)};function G(...e){return X((t=>Reflect.apply(ft,null,[t,...e])),(()=>pt(...e)),"translate",(t=>Reflect.apply(t.t,t,[...e])),(e=>e),(e=>k(e)))}const Y={normalize:function(e){return e.map((e=>k(e)||s(e)||h(e)?xt(String(e)):e))},interpolate:e=>e,type:"vnode"};function B(e){return g.value[e]||{}}$t++,a&&r&&(t.watch(a.locale,(e=>{_&&(p.value=e,x.locale=e,nt(x,p.value,d.value))})),t.watch(a.fallbackLocale,(e=>{_&&(d.value=e,x.fallbackLocale=e,nt(x,p.value,d.value))})));const K={id:$t,locale:U,fallbackLocale:$,get inheritLocale(){return _},set inheritLocale(e){_=e,e&&a&&(p.value=a.locale.value,d.value=a.fallbackLocale.value,nt(x,p.value,d.value))},get availableLocales(){return Object.keys(g.value).sort()},messages:H,get modifiers(){return w},get pluralRules(){return W||{}},get isGlobal(){return l},get missingWarn(){return y},set missingWarn(e){y=e,x.missingWarn=y},get fallbackWarn(){return O},set fallbackWarn(e){O=e,x.fallbackWarn=O},get fallbackRoot(){return C},set fallbackRoot(e){C=e},get fallbackFormat(){return P},set fallbackFormat(e){P=e,x.fallbackFormat=P},get warnHtmlMessage(){return D},set warnHtmlMessage(e){D=e,x.warnHtmlMessage=e},get escapeParameter(){return M},set escapeParameter(e){M=e,x.escapeParameter=e},t:G,getLocaleMessage:B,setLocaleMessage:function(e,t){if(c){const n={[e]:t};for(const e in n)E(n,e)&&St(n[e]);t=n[e]}g.value[e]=t,x.messages=g.value},mergeLocaleMessage:function(e,t){g.value[e]=g.value[e]||{};const n={[e]:t};if(c)for(const r in n)E(n,r)&&St(n[r]);A(t=n[e],g.value[e]),x.messages=g.value},getPostTranslationHandler:function(){return v(S)?S:null},setPostTranslationHandler:function(e){S=e,x.postTranslation=e},getMissingHandler:function(){return R},setMissingHandler:function(e){null!==e&&(F=Ht(e)),R=e,x.missing=F},[At]:function(e){W=e,x.pluralRules=W}};return K.datetimeFormats=j,K.numberFormats=V,K.rt=function(...e){const[t,n,r]=e;if(r&&!L(r))throw Error(It.INVALID_ARGUMENT);return G(t,n,f({resolvedMessage:!0},r||{}))},K.te=function(e,t){return X((()=>{if(!e)return!1;const n=B(k(t)?t:p.value),r=x.messageResolver(n,e);return m?null!=r:re(r)||it(r)||k(r)}),(()=>[e]),"translate exists",(n=>Reflect.apply(n.te,n,[e,t])),Ut,(e=>h(e)))},K.tm=function(e){const t=function(e){let t=null;const n=xe(x,d.value,p.value);for(let r=0;rReflect.apply(dt,null,[t,...e])),(()=>Et(...e)),"datetime format",(t=>Reflect.apply(t.d,t,[...e])),(()=>Xe),(e=>k(e)))},K.n=function(...e){return X((t=>Reflect.apply(vt,null,[t,...e])),(()=>ht(...e)),"number format",(t=>Reflect.apply(t.n,t,[...e])),(()=>Xe),(e=>k(e)))},K.getDateTimeFormat=function(e){return N.value[e]||{}},K.setDateTimeFormat=function(e,t){N.value[e]=t,x.datetimeFormats=N.value,bt(x,e,t)},K.mergeDateTimeFormat=function(e,t){N.value[e]=f(N.value[e]||{},t),x.datetimeFormats=N.value,bt(x,e,t)},K.getNumberFormat=function(e){return T.value[e]||{}},K.setNumberFormat=function(e,t){T.value[e]=t,x.numberFormats=T.value,Lt(x,e,t)},K.mergeNumberFormat=function(e,t){T.value[e]=f(T.value[e]||{},t),x.numberFormats=T.value,Lt(x,e,t)},K[Rt]=o,K[Ot]=function(...e){return X((t=>{let n;const r=t;try{r.processor=Y,n=Reflect.apply(ft,null,[r,...e])}finally{r.processor=null}return n}),(()=>pt(...e)),"translate",(t=>t[Ot](...e)),(e=>[xt(e)]),(e=>b(e)))},K[Ct]=function(...e){return X((t=>Reflect.apply(dt,null,[t,...e])),(()=>Et(...e)),"datetime format",(t=>t[Ct](...e)),Wt,(e=>k(e)||b(e)))},K[Pt]=function(...e){return X((t=>Reflect.apply(vt,null,[t,...e])),(()=>ht(...e)),"number format",(t=>t[Pt](...e)),Wt,(e=>k(e)||b(e)))},K}function Vt(e={},t){{const t=jt(function(e){const t=k(e.locale)?e.locale:Ve,n=k(e.fallbackLocale)||b(e.fallbackLocale)||I(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:t,r=v(e.missing)?e.missing:void 0,a=!h(e.silentTranslationWarn)&&!u(e.silentTranslationWarn)||!e.silentTranslationWarn,o=!h(e.silentFallbackWarn)&&!u(e.silentFallbackWarn)||!e.silentFallbackWarn,l=!h(e.fallbackRoot)||e.fallbackRoot,s=!!e.formatFallbackMessages,c=I(e.modifiers)?e.modifiers:{},i=e.pluralizationRules,m=v(e.postTranslation)?e.postTranslation:void 0,_=!k(e.warnHtmlInMessage)||"off"!==e.warnHtmlInMessage,p=!!e.escapeParameterHtml,d=!h(e.sync)||e.sync;let g=e.messages;if(I(e.sharedMessages)){const t=e.sharedMessages;g=Object.keys(t).reduce(((e,n)=>{const r=e[n]||(e[n]={});return f(r,t[n]),e}),g||{})}const{__i18n:E,__root:L,__injectWithOption:N}=e,T=e.datetimeFormats,y=e.numberFormats,O=e.flatJson,C=e.translateExistCompatible;return{locale:t,fallbackLocale:n,messages:g,flatJson:O,datetimeFormats:T,numberFormats:y,missing:r,missingWarn:a,fallbackWarn:o,fallbackRoot:l,fallbackFormat:s,modifiers:c,pluralRules:i,postTranslation:m,warnHtmlMessage:_,escapeParameter:p,messageResolver:e.messageResolver,inheritLocale:d,translateExistCompatible:C,__i18n:E,__root:L,__injectWithOption:N}}(e)),{__extender:n}=e,r={id:t.id,get locale(){return t.locale.value},set locale(e){t.locale.value=e},get fallbackLocale(){return t.fallbackLocale.value},set fallbackLocale(e){t.fallbackLocale.value=e},get messages(){return t.messages.value},get datetimeFormats(){return t.datetimeFormats.value},get numberFormats(){return t.numberFormats.value},get availableLocales(){return t.availableLocales},get formatter(){return{interpolate:()=>[]}},set formatter(e){},get missing(){return t.getMissingHandler()},set missing(e){t.setMissingHandler(e)},get silentTranslationWarn(){return h(t.missingWarn)?!t.missingWarn:t.missingWarn},set silentTranslationWarn(e){t.missingWarn=h(e)?!e:e},get silentFallbackWarn(){return h(t.fallbackWarn)?!t.fallbackWarn:t.fallbackWarn},set silentFallbackWarn(e){t.fallbackWarn=h(e)?!e:e},get modifiers(){return t.modifiers},get formatFallbackMessages(){return t.fallbackFormat},set formatFallbackMessages(e){t.fallbackFormat=e},get postTranslation(){return t.getPostTranslationHandler()},set postTranslation(e){t.setPostTranslationHandler(e)},get sync(){return t.inheritLocale},set sync(e){t.inheritLocale=e},get warnHtmlInMessage(){return t.warnHtmlMessage?"warn":"off"},set warnHtmlInMessage(e){t.warnHtmlMessage="off"!==e},get escapeParameterHtml(){return t.escapeParameter},set escapeParameterHtml(e){t.escapeParameter=e},get preserveDirectiveContent(){return!0},set preserveDirectiveContent(e){},get pluralizationRules(){return t.pluralRules||{}},__composer:t,t(...e){const[n,r,a]=e,o={};let l=null,s=null;if(!k(n))throw Error(It.INVALID_ARGUMENT);const c=n;return k(r)?o.locale=r:b(r)?l=r:I(r)&&(s=r),b(a)?l=a:I(a)&&(s=a),Reflect.apply(t.t,t,[c,l||s||{},o])},rt:(...e)=>Reflect.apply(t.rt,t,[...e]),tc(...e){const[n,r,a]=e,o={plural:1};let l=null,c=null;if(!k(n))throw Error(It.INVALID_ARGUMENT);const u=n;return k(r)?o.locale=r:s(r)?o.plural=r:b(r)?l=r:I(r)&&(c=r),k(a)?o.locale=a:b(a)?l=a:I(a)&&(c=a),Reflect.apply(t.t,t,[u,l||c||{},o])},te:(e,n)=>t.te(e,n),tm:e=>t.tm(e),getLocaleMessage:e=>t.getLocaleMessage(e),setLocaleMessage(e,n){t.setLocaleMessage(e,n)},mergeLocaleMessage(e,n){t.mergeLocaleMessage(e,n)},d:(...e)=>Reflect.apply(t.d,t,[...e]),getDateTimeFormat:e=>t.getDateTimeFormat(e),setDateTimeFormat(e,n){t.setDateTimeFormat(e,n)},mergeDateTimeFormat(e,n){t.mergeDateTimeFormat(e,n)},n:(...e)=>Reflect.apply(t.n,t,[...e]),getNumberFormat:e=>t.getNumberFormat(e),setNumberFormat(e,n){t.setNumberFormat(e,n)},mergeNumberFormat(e,n){t.mergeNumberFormat(e,n)},getChoiceIndex:(e,t)=>-1};return r.__extender=n,r}}const Xt={tag:{type:[String,Object]},locale:{type:String},scope:{type:String,validator:e=>"parent"===e||"global"===e,default:"parent"},i18n:{type:Object}};function Gt(e){return t.Fragment}const Yt=t.defineComponent({name:"i18n-t",props:f({keypath:{type:String,required:!0},plural:{type:[Number,String],validator:e=>s(e)||!isNaN(e)}},Xt),setup(e,n){const{slots:r,attrs:a}=n,o=e.i18n||an({useScope:e.scope,__useComponent:!0});return()=>{const l=Object.keys(r).filter((e=>"_"!==e)),s=_();e.locale&&(s.locale=e.locale),void 0!==e.plural&&(s.plural=k(e.plural)?+e.plural:e.plural);const c=function({slots:e},n){if(1===n.length&&"default"===n[0])return(e.default?e.default():[]).reduce(((e,n)=>[...e,...n.type===t.Fragment?n.children:[n]]),[]);return n.reduce(((t,n)=>{const r=e[n];return r&&(t[n]=r()),t}),_())}(n,l),u=o[Ot](e.keypath,c,s),i=f(_(),a),m=k(e.tag)||L(e.tag)?e.tag:Gt();return t.h(m,i,u)}}}),Bt=Yt;function Kt(e,n,r,a){const{slots:o,attrs:l}=n;return()=>{const n={part:!0};let s=_();e.locale&&(n.locale=e.locale),k(e.format)?n.key=e.format:L(e.format)&&(k(e.format.key)&&(n.key=e.format.key),s=Object.keys(e.format).reduce(((t,n)=>r.includes(n)?f(_(),t,{[n]:e.format[n]}):t),_()));const c=a(e.value,n,s);let u=[n.key];b(c)?u=c.map(((e,t)=>{const n=o[e.type],r=n?n({[e.type]:e.value,index:t,parts:c}):[e.value];var a;return b(a=r)&&!k(a[0])&&(r[0].key=`${e.type}-${t}`),r})):k(c)&&(u=[c]);const i=f(_(),l),m=k(e.tag)||L(e.tag)?e.tag:Gt();return t.h(m,i,u)}}const zt=t.defineComponent({name:"i18n-n",props:f({value:{type:Number,required:!0},format:{type:[String,Object]}},Xt),setup(e,t){const n=e.i18n||an({useScope:e.scope,__useComponent:!0});return Kt(e,t,kt,((...e)=>n[Pt](...e)))}}),Jt=zt,Qt=t.defineComponent({name:"i18n-d",props:f({value:{type:[Number,Date],required:!0},format:{type:[String,Object]}},Xt),setup(e,t){const n=e.i18n||an({useScope:e.scope,__useComponent:!0});return Kt(e,t,gt,((...e)=>n[Ct](...e)))}}),qt=Qt;function Zt(e){const n=t=>{const{instance:n,modifiers:r,value:a}=t;if(!n||!n.$)throw Error(It.UNEXPECTED_ERROR);const o=function(e,t){const n=e;if("composition"===e.mode)return n.__getInstance(t)||e.global;{const r=n.__getInstance(t);return null!=r?r.__composer:e.global.__composer}}(e,n.$),l=en(a);return[Reflect.apply(o.t,o,[...tn(l)]),o]};return{created:(a,o)=>{const[l,s]=n(o);r&&e.global===s&&(a.__i18nWatcher=t.watch(s.locale,(()=>{o.instance&&o.instance.$forceUpdate()}))),a.__composer=s,a.textContent=l},unmounted:e=>{r&&e.__i18nWatcher&&(e.__i18nWatcher(),e.__i18nWatcher=void 0,delete e.__i18nWatcher),e.__composer&&(e.__composer=void 0,delete e.__composer)},beforeUpdate:(e,{value:t})=>{if(e.__composer){const n=e.__composer,r=en(t);e.textContent=Reflect.apply(n.t,n,[...tn(r)])}},getSSRProps:e=>{const[t]=n(e);return{textContent:t}}}}function en(e){if(k(e))return{path:e};if(I(e)){if(!("path"in e))throw Error(It.REQUIRED_VALUE,"path");return e}throw Error(It.INVALID_VALUE)}function tn(e){const{path:t,locale:n,args:r,choice:a,plural:o}=e,l={},c=r||{};return k(n)&&(l.locale=n),s(a)&&(l.plural=a),s(o)&&(l.plural=o),[t,c,l]}function nn(e,t){e.locale=t.locale||e.locale,e.fallbackLocale=t.fallbackLocale||e.fallbackLocale,e.missing=t.missing||e.missing,e.silentTranslationWarn=t.silentTranslationWarn||e.silentFallbackWarn,e.silentFallbackWarn=t.silentFallbackWarn||e.silentFallbackWarn,e.formatFallbackMessages=t.formatFallbackMessages||e.formatFallbackMessages,e.postTranslation=t.postTranslation||e.postTranslation,e.warnHtmlInMessage=t.warnHtmlInMessage||e.warnHtmlInMessage,e.escapeParameterHtml=t.escapeParameterHtml||e.escapeParameterHtml,e.sync=t.sync||e.sync,e.__composer[At](t.pluralizationRules||e.pluralizationRules);const n=Dt(e.locale,{messages:t.messages,__i18n:t.__i18n});return Object.keys(n).forEach((t=>e.mergeLocaleMessage(t,n[t]))),t.datetimeFormats&&Object.keys(t.datetimeFormats).forEach((n=>e.mergeDateTimeFormat(n,t.datetimeFormats[n]))),t.numberFormats&&Object.keys(t.numberFormats).forEach((n=>e.mergeNumberFormat(n,t.numberFormats[n]))),e}const rn=a("global-vue-i18n");function an(e={}){const n=t.getCurrentInstance();if(null==n)throw Error(It.MUST_BE_CALL_SETUP_TOP);if(!n.isCE&&null!=n.appContext.app&&!n.appContext.app.__VUE_I18N_SYMBOL__)throw Error(It.NOT_INSTALLED);const r=function(e){{const n=t.inject(e.isCE?rn:e.appContext.app.__VUE_I18N_SYMBOL__);if(!n)throw function(e,...t){return D(e,null,void 0)}(e.isCE?It.NOT_INSTALLED_WITH_PROVIDE:It.UNEXPECTED_ERROR);return n}}(n),a=function(e){return"composition"===e.mode?e.global:e.global.__composer}(r),o=Mt(n),l=function(e,t){return i(e)?"__i18n"in t?"local":"global":e.useScope?e.useScope:"local"}(e,o);if("legacy"===r.mode&&!e.__useComponent){if(!r.allowComposition)throw Error(It.NOT_AVAILABLE_IN_LEGACY_MODE);return function(e,n,r,a={}){const o="local"===n,l=t.shallowRef(null);if(o&&e.proxy&&!e.proxy.$options.i18n&&!e.proxy.$options.__i18n)throw Error(It.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION);const s=h(a.inheritLocale)?a.inheritLocale:!k(a.locale),c=t.ref(!o||s?r.locale.value:k(a.locale)?a.locale:Ve),i=t.ref(!o||s?r.fallbackLocale.value:k(a.fallbackLocale)||b(a.fallbackLocale)||I(a.fallbackLocale)||!1===a.fallbackLocale?a.fallbackLocale:c.value),f=t.ref(Dt(c.value,a)),m=t.ref(I(a.datetimeFormats)?a.datetimeFormats:{[c.value]:{}}),_=t.ref(I(a.numberFormats)?a.numberFormats:{[c.value]:{}}),p=o?r.missingWarn:!h(a.missingWarn)&&!u(a.missingWarn)||a.missingWarn,d=o?r.fallbackWarn:!h(a.fallbackWarn)&&!u(a.fallbackWarn)||a.fallbackWarn,g=o?r.fallbackRoot:!h(a.fallbackRoot)||a.fallbackRoot,E=!!a.fallbackFormat,L=v(a.missing)?a.missing:null,N=v(a.postTranslation)?a.postTranslation:null,T=o?r.warnHtmlMessage:!h(a.warnHtmlMessage)||a.warnHtmlMessage,y=!!a.escapeParameter,O=o?r.modifiers:I(a.modifiers)?a.modifiers:{},C=a.pluralRules||o&&r.pluralRules;function P(){return[c.value,i.value,f.value,m.value,_.value]}const A=t.computed({get:()=>l.value?l.value.locale.value:c.value,set:e=>{l.value&&(l.value.locale.value=e),c.value=e}}),R=t.computed({get:()=>l.value?l.value.fallbackLocale.value:i.value,set:e=>{l.value&&(l.value.fallbackLocale.value=e),i.value=e}}),F=t.computed((()=>l.value?l.value.messages.value:f.value)),S=t.computed((()=>m.value)),D=t.computed((()=>_.value));function M(){return l.value?l.value.getPostTranslationHandler():N}function w(e){l.value&&l.value.setPostTranslationHandler(e)}function x(){return l.value?l.value.getMissingHandler():L}function W(e){l.value&&l.value.setMissingHandler(e)}function U(e){return P(),e()}function $(...e){return l.value?U((()=>Reflect.apply(l.value.t,null,[...e]))):U((()=>""))}function H(...e){return l.value?Reflect.apply(l.value.rt,null,[...e]):""}function j(...e){return l.value?U((()=>Reflect.apply(l.value.d,null,[...e]))):U((()=>""))}function V(...e){return l.value?U((()=>Reflect.apply(l.value.n,null,[...e]))):U((()=>""))}function X(e){return l.value?l.value.tm(e):{}}function G(e,t){return!!l.value&&l.value.te(e,t)}function Y(e){return l.value?l.value.getLocaleMessage(e):{}}function B(e,t){l.value&&(l.value.setLocaleMessage(e,t),f.value[e]=t)}function K(e,t){l.value&&l.value.mergeLocaleMessage(e,t)}function z(e){return l.value?l.value.getDateTimeFormat(e):{}}function J(e,t){l.value&&(l.value.setDateTimeFormat(e,t),m.value[e]=t)}function Q(e,t){l.value&&l.value.mergeDateTimeFormat(e,t)}function q(e){return l.value?l.value.getNumberFormat(e):{}}function Z(e,t){l.value&&(l.value.setNumberFormat(e,t),_.value[e]=t)}function ee(e,t){l.value&&l.value.mergeNumberFormat(e,t)}const te={get id(){return l.value?l.value.id:-1},locale:A,fallbackLocale:R,messages:F,datetimeFormats:S,numberFormats:D,get inheritLocale(){return l.value?l.value.inheritLocale:s},set inheritLocale(e){l.value&&(l.value.inheritLocale=e)},get availableLocales(){return l.value?l.value.availableLocales:Object.keys(f.value)},get modifiers(){return l.value?l.value.modifiers:O},get pluralRules(){return l.value?l.value.pluralRules:C},get isGlobal(){return!!l.value&&l.value.isGlobal},get missingWarn(){return l.value?l.value.missingWarn:p},set missingWarn(e){l.value&&(l.value.missingWarn=e)},get fallbackWarn(){return l.value?l.value.fallbackWarn:d},set fallbackWarn(e){l.value&&(l.value.missingWarn=e)},get fallbackRoot(){return l.value?l.value.fallbackRoot:g},set fallbackRoot(e){l.value&&(l.value.fallbackRoot=e)},get fallbackFormat(){return l.value?l.value.fallbackFormat:E},set fallbackFormat(e){l.value&&(l.value.fallbackFormat=e)},get warnHtmlMessage(){return l.value?l.value.warnHtmlMessage:T},set warnHtmlMessage(e){l.value&&(l.value.warnHtmlMessage=e)},get escapeParameter(){return l.value?l.value.escapeParameter:y},set escapeParameter(e){l.value&&(l.value.escapeParameter=e)},t:$,getPostTranslationHandler:M,setPostTranslationHandler:w,getMissingHandler:x,setMissingHandler:W,rt:H,d:j,n:V,tm:X,te:G,getLocaleMessage:Y,setLocaleMessage:B,mergeLocaleMessage:K,getDateTimeFormat:z,setDateTimeFormat:J,mergeDateTimeFormat:Q,getNumberFormat:q,setNumberFormat:Z,mergeNumberFormat:ee};function ne(e){e.locale.value=c.value,e.fallbackLocale.value=i.value,Object.keys(f.value).forEach((t=>{e.mergeLocaleMessage(t,f.value[t])})),Object.keys(m.value).forEach((t=>{e.mergeDateTimeFormat(t,m.value[t])})),Object.keys(_.value).forEach((t=>{e.mergeNumberFormat(t,_.value[t])})),e.escapeParameter=y,e.fallbackFormat=E,e.fallbackRoot=g,e.fallbackWarn=d,e.missingWarn=p,e.warnHtmlMessage=T}return t.onBeforeMount((()=>{if(null==e.proxy||null==e.proxy.$i18n)throw Error(It.NOT_AVAILABLE_COMPOSITION_IN_LEGACY);const t=l.value=e.proxy.$i18n.__composer;"global"===n?(c.value=t.locale.value,i.value=t.fallbackLocale.value,f.value=t.messages.value,m.value=t.datetimeFormats.value,_.value=t.numberFormats.value):o&&ne(t)})),te}(n,l,a,e)}if("global"===l)return wt(a,e,o),a;if("parent"===l){let t=function(e,t,n=!1){let r=null;const a=t.root;let o=function(e,t=!1){if(null==e)return null;return t&&e.vnode.ctx||e.parent}(t,n);for(;null!=o;){const t=e;if("composition"===e.mode)r=t.__getInstance(o);else{const e=t.__getInstance(o);null!=e&&(r=e.__composer,n&&r&&!r[Rt]&&(r=null))}if(null!=r)break;if(a===o)break;o=o.parent}return r}(r,n,e.__useComponent);return null==t&&(t=a),t}const s=r;let c=s.__getInstance(n);if(null==c){const r=f({},e);"__i18n"in o&&(r.__i18n=o.__i18n),a&&(r.__root=a),c=jt(r),s.__composerExtend&&(c[Ft]=s.__composerExtend(c)),function(e,n,r){t.onMounted((()=>{}),n),t.onUnmounted((()=>{const t=r;e.__deleteInstance(n);const a=t[Ft];a&&(a(),delete t[Ft])}),n)}(s,n,c),s.__setInstance(n,c)}return c}const on=["locale","fallbackLocale","availableLocales"],ln=["t","rt","d","n","tm","te"];return Ye=function(e,t){if(k(e)){!h(t.warnHtmlMessage)||t.warnHtmlMessage;const n=(t.onCacheKey||st)(e),r=ct[n];if(r)return r;const{ast:a,detectError:o}=function(e,t={}){let n=!1;const r=t.onError||M;return t.onError=e=>{n=!0,r(e)},{...ne(e,t),detectError:n}}(e,{...t,location:!1,jit:!0}),l=at(a);return o?l:ct[n]=l}{const t=e.cacheKey;return t?ct[t]||(ct[t]=at(e)):at(e)}},Be=function(e,t){if(!L(e))return null;let n=he.get(t);if(n||(n=function(e){const t=[];let n,r,a,o,l,s,c,u=-1,i=0,f=0;const m=[];function _(){const t=e[u+1];if(5===i&&"'"===t||6===i&&'"'===t)return u++,a="\\"+t,m[0](),!0}for(m[0]=()=>{void 0===r?r=a:r+=a},m[1]=()=>{void 0!==r&&(t.push(r),r=void 0)},m[2]=()=>{m[0](),f++},m[3]=()=>{if(f>0)f--,i=4,m[0]();else{if(f=0,void 0===r)return!1;if(r=ke(r),!1===r)return!1;m[1]()}};null!==i;)if(u++,n=e[u],"\\"!==n||!_()){if(o=ve(n),c=Ee[i],l=c[o]||c.l||8,8===l)return;if(i=l[0],void 0!==l[1]&&(s=m[l[1]],s&&(a=n,!1===s())))return;if(7===i)return t}}(t),n&&he.set(t,n)),!n)return null;const r=n.length;let a=e,o=0;for(;o{if(!("__VUE_I18N_BRIDGE__"in e))throw Error(It.NOT_COMPATIBLE_LEGACY_VUE_I18N);return e},e.createI18n=function(e={},n){const r=!h(e.legacy)||e.legacy,o=!h(e.globalInjection)||e.globalInjection,l=!r||!!e.allowComposition,s=new Map,[c,u]=function(e,n,r){const a=t.effectScope();{const t=n?a.run((()=>Vt(e))):a.run((()=>jt(e)));if(null==t)throw Error(It.UNEXPECTED_ERROR);return[a,t]}}(e,r),i=a("");{const e={get mode(){return r?"legacy":"composition"},get allowComposition(){return l},async install(n,...a){if(n.__VUE_I18N_SYMBOL__=i,n.provide(n.__VUE_I18N_SYMBOL__,e),I(a[0])){const t=a[0];e.__composerExtend=t.__composerExtend,e.__vueI18nExtend=t.__vueI18nExtend}let l=null;!r&&o&&(l=function(e,n){const r=Object.create(null);on.forEach((e=>{const a=Object.getOwnPropertyDescriptor(n,e);if(!a)throw Error(It.UNEXPECTED_ERROR);const o=t.isRef(a.value)?{get:()=>a.value.value,set(e){a.value.value=e}}:{get:()=>a.get&&a.get()};Object.defineProperty(r,e,o)})),e.config.globalProperties.$i18n=r,ln.forEach((t=>{const r=Object.getOwnPropertyDescriptor(n,t);if(!r||!r.value)throw Error(It.UNEXPECTED_ERROR);Object.defineProperty(e.config.globalProperties,`$${t}`,r)}));const a=()=>{delete e.config.globalProperties.$i18n,ln.forEach((t=>{delete e.config.globalProperties[`$${t}`]}))};return a}(n,e.global)),function(e,t,...n){const r=I(n[0])?n[0]:{},a=!!r.useI18nComponentName;(!h(r.globalInstall)||r.globalInstall)&&([a?"i18n":Yt.name,"I18nT"].forEach((t=>e.component(t,Yt))),[zt.name,"I18nN"].forEach((t=>e.component(t,zt))),[Qt.name,"I18nD"].forEach((t=>e.component(t,Qt)))),e.directive("t",Zt(t))}(n,e,...a),r&&n.mixin(function(e,n,r){return{beforeCreate(){const a=t.getCurrentInstance();if(!a)throw Error(It.UNEXPECTED_ERROR);const o=this.$options;if(o.i18n){const t=o.i18n;if(o.__i18n&&(t.__i18n=o.__i18n),t.__root=n,this===this.$root)this.$i18n=nn(e,t);else{t.__injectWithOption=!0,t.__extender=r.__vueI18nExtend,this.$i18n=Vt(t);const e=this.$i18n;e.__extender&&(e.__disposer=e.__extender(this.$i18n))}}else if(o.__i18n)if(this===this.$root)this.$i18n=nn(e,o);else{this.$i18n=Vt({__i18n:o.__i18n,__injectWithOption:!0,__extender:r.__vueI18nExtend,__root:n});const e=this.$i18n;e.__extender&&(e.__disposer=e.__extender(this.$i18n))}else this.$i18n=e;o.__i18nGlobal&&wt(n,o,o),this.$t=(...e)=>this.$i18n.t(...e),this.$rt=(...e)=>this.$i18n.rt(...e),this.$tc=(...e)=>this.$i18n.tc(...e),this.$te=(e,t)=>this.$i18n.te(e,t),this.$d=(...e)=>this.$i18n.d(...e),this.$n=(...e)=>this.$i18n.n(...e),this.$tm=e=>this.$i18n.tm(e),r.__setInstance(a,this.$i18n)},mounted(){},unmounted(){const e=t.getCurrentInstance();if(!e)throw Error(It.UNEXPECTED_ERROR);const n=this.$i18n;delete this.$t,delete this.$rt,delete this.$tc,delete this.$te,delete this.$d,delete this.$n,delete this.$tm,n.__disposer&&(n.__disposer(),delete n.__disposer,delete n.__extender),r.__deleteInstance(e),delete this.$i18n}}}(u,u.__composer,e));const s=n.unmount;n.unmount=()=>{l&&l(),e.dispose(),s()}},get global(){return u},dispose(){c.stop()},__instances:s,__getInstance:function(e){return s.get(e)||null},__setInstance:function(e,t){s.set(e,t)},__deleteInstance:function(e){s.delete(e)}};return e}},e.useI18n=an,e.vTDirective=Zt,e}({},Vue); diff --git a/node_modules/vue-i18n/dist/vue-i18n.mjs b/node_modules/vue-i18n/dist/vue-i18n.mjs new file mode 100644 index 0000000..6678812 --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.mjs @@ -0,0 +1,2982 @@ +/*! + * vue-i18n v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +import { getGlobalThis, incrementer, format, makeSymbol, isPlainObject, isArray, create, deepCopy, isString, hasOwn, isObject, warn, warnOnce, isBoolean, isRegExp, isFunction, inBrowser, assign, isNumber, createEmitter, isEmptyObject } from '@intlify/shared'; +import { CoreWarnCodes, CoreErrorCodes, createCompileError, isMessageAST, AST_NODE_PROPS_KEYS, DEFAULT_LOCALE, updateFallbackLocale, setFallbackContext, createCoreContext, clearDateTimeFormat, clearNumberFormat, setAdditionalMeta, getFallbackContext, NOT_REOSLVED, isTranslateFallbackWarn, isTranslateMissingWarn, parseTranslateArgs, translate, MISSING_RESOLVE_VALUE, parseDateTimeArgs, datetime, parseNumberArgs, number, isMessageFunction, fallbackWithLocaleChain, NUMBER_FORMAT_OPTIONS_KEYS, DATETIME_FORMAT_OPTIONS_KEYS, registerMessageCompiler, compile, compileToFunction, registerMessageResolver, resolveValue, registerLocaleFallbacker, setDevToolsHook } from '@intlify/core-base'; +import { createVNode, Text, computed, watch, getCurrentInstance, ref, shallowRef, Fragment, defineComponent, h, effectScope, inject, onMounted, onUnmounted, onBeforeMount, isRef } from 'vue'; +import { setupDevtoolsPlugin } from '@vue/devtools-api'; + +/** + * Vue I18n Version + * + * @remarks + * Semver format. Same format as the package.json `version` field. + * + * @VueI18nGeneral + */ +const VERSION = '9.14.5'; +/** + * This is only called in esm-bundler builds. + * istanbul-ignore-next + */ +function initFeatureFlags() { + if (typeof __VUE_I18N_FULL_INSTALL__ !== 'boolean') { + getGlobalThis().__VUE_I18N_FULL_INSTALL__ = true; + } + if (typeof __VUE_I18N_LEGACY_API__ !== 'boolean') { + getGlobalThis().__VUE_I18N_LEGACY_API__ = true; + } + if (typeof __INTLIFY_JIT_COMPILATION__ !== 'boolean') { + getGlobalThis().__INTLIFY_JIT_COMPILATION__ = false; + } + if (typeof __INTLIFY_DROP_MESSAGE_COMPILER__ !== 'boolean') { + getGlobalThis().__INTLIFY_DROP_MESSAGE_COMPILER__ = false; + } + if (typeof __INTLIFY_PROD_DEVTOOLS__ !== 'boolean') { + getGlobalThis().__INTLIFY_PROD_DEVTOOLS__ = false; + } +} + +const code$1 = CoreWarnCodes.__EXTEND_POINT__; +const inc$1 = incrementer(code$1); +const I18nWarnCodes = { + FALLBACK_TO_ROOT: code$1, // 9 + NOT_SUPPORTED_PRESERVE: inc$1(), // 10 + NOT_SUPPORTED_FORMATTER: inc$1(), // 11 + NOT_SUPPORTED_PRESERVE_DIRECTIVE: inc$1(), // 12 + NOT_SUPPORTED_GET_CHOICE_INDEX: inc$1(), // 13 + COMPONENT_NAME_LEGACY_COMPATIBLE: inc$1(), // 14 + NOT_FOUND_PARENT_SCOPE: inc$1(), // 15 + IGNORE_OBJ_FLATTEN: inc$1(), // 16 + NOTICE_DROP_ALLOW_COMPOSITION: inc$1(), // 17 + NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG: inc$1() // 18 +}; +const warnMessages = { + [I18nWarnCodes.FALLBACK_TO_ROOT]: `Fall back to {type} '{key}' with root locale.`, + [I18nWarnCodes.NOT_SUPPORTED_PRESERVE]: `Not supported 'preserve'.`, + [I18nWarnCodes.NOT_SUPPORTED_FORMATTER]: `Not supported 'formatter'.`, + [I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE]: `Not supported 'preserveDirectiveContent'.`, + [I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX]: `Not supported 'getChoiceIndex'.`, + [I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE]: `Component name legacy compatible: '{name}' -> 'i18n'`, + [I18nWarnCodes.NOT_FOUND_PARENT_SCOPE]: `Not found parent scope. use the global scope.`, + [I18nWarnCodes.IGNORE_OBJ_FLATTEN]: `Ignore object flatten: '{key}' key has an string value`, + [I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION]: `'allowComposition' option will be dropped in the next major version. For more information, please see 👉 https://tinyurl.com/2p97mcze`, + [I18nWarnCodes.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG]: `'translateExistCompatible' option will be dropped in the next major version.` +}; +function getWarnMessage(code, ...args) { + return format(warnMessages[code], ...args); +} + +const code = CoreErrorCodes.__EXTEND_POINT__; +const inc = incrementer(code); +const I18nErrorCodes = { + // composer module errors + UNEXPECTED_RETURN_TYPE: code, // 24 + // legacy module errors + INVALID_ARGUMENT: inc(), // 25 + // i18n module errors + MUST_BE_CALL_SETUP_TOP: inc(), // 26 + NOT_INSTALLED: inc(), // 27 + NOT_AVAILABLE_IN_LEGACY_MODE: inc(), // 28 + // directive module errors + REQUIRED_VALUE: inc(), // 29 + INVALID_VALUE: inc(), // 30 + // vue-devtools errors + CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN: inc(), // 31 + NOT_INSTALLED_WITH_PROVIDE: inc(), // 32 + // unexpected error + UNEXPECTED_ERROR: inc(), // 33 + // not compatible legacy vue-i18n constructor + NOT_COMPATIBLE_LEGACY_VUE_I18N: inc(), // 34 + // bridge support vue 2.x only + BRIDGE_SUPPORT_VUE_2_ONLY: inc(), // 35 + // need to define `i18n` option in `allowComposition: true` and `useScope: 'local' at `useI18n`` + MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION: inc(), // 36 + // Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly + NOT_AVAILABLE_COMPOSITION_IN_LEGACY: inc(), // 37 + // for enhancement + __EXTEND_POINT__: inc() // 38 +}; +function createI18nError(code, ...args) { + return createCompileError(code, null, (process.env.NODE_ENV !== 'production') ? { messages: errorMessages, args } : undefined); +} +const errorMessages = { + [I18nErrorCodes.UNEXPECTED_RETURN_TYPE]: 'Unexpected return type in composer', + [I18nErrorCodes.INVALID_ARGUMENT]: 'Invalid argument', + [I18nErrorCodes.MUST_BE_CALL_SETUP_TOP]: 'Must be called at the top of a `setup` function', + [I18nErrorCodes.NOT_INSTALLED]: 'Need to install with `app.use` function', + [I18nErrorCodes.UNEXPECTED_ERROR]: 'Unexpected error', + [I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE]: 'Not available in legacy mode', + [I18nErrorCodes.REQUIRED_VALUE]: `Required in value: {0}`, + [I18nErrorCodes.INVALID_VALUE]: `Invalid value`, + [I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN]: `Cannot setup vue-devtools plugin`, + [I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE]: 'Need to install with `provide` function', + [I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N]: 'Not compatible legacy VueI18n.', + [I18nErrorCodes.BRIDGE_SUPPORT_VUE_2_ONLY]: 'vue-i18n-bridge support Vue 2.x only', + [I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION]: 'Must define ‘i18n’ option or custom block in Composition API with using local scope in Legacy API mode', + [I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY]: 'Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly' +}; + +const TranslateVNodeSymbol = +/* #__PURE__*/ makeSymbol('__translateVNode'); +const DatetimePartsSymbol = /* #__PURE__*/ makeSymbol('__datetimeParts'); +const NumberPartsSymbol = /* #__PURE__*/ makeSymbol('__numberParts'); +const EnableEmitter = /* #__PURE__*/ makeSymbol('__enableEmitter'); +const DisableEmitter = /* #__PURE__*/ makeSymbol('__disableEmitter'); +const SetPluralRulesSymbol = makeSymbol('__setPluralRules'); +makeSymbol('__intlifyMeta'); +const InejctWithOptionSymbol = +/* #__PURE__*/ makeSymbol('__injectWithOption'); +const DisposeSymbol = /* #__PURE__*/ makeSymbol('__dispose'); +const __VUE_I18N_BRIDGE__ = '__VUE_I18N_BRIDGE__'; + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Transform flat json in obj to normal json in obj + */ +function handleFlatJson(obj) { + // check obj + if (!isObject(obj)) { + return obj; + } + if (isMessageAST(obj)) { + return obj; + } + for (const key in obj) { + // check key + if (!hasOwn(obj, key)) { + continue; + } + // handle for normal json + if (!key.includes('.')) { + // recursive process value if value is also a object + if (isObject(obj[key])) { + handleFlatJson(obj[key]); + } + } + // handle for flat json, transform to normal json + else { + // go to the last object + const subKeys = key.split('.'); + const lastIndex = subKeys.length - 1; + let currentObj = obj; + let hasStringValue = false; + for (let i = 0; i < lastIndex; i++) { + if (subKeys[i] === '__proto__') { + throw new Error(`unsafe key: ${subKeys[i]}`); + } + if (!(subKeys[i] in currentObj)) { + currentObj[subKeys[i]] = create(); + } + if (!isObject(currentObj[subKeys[i]])) { + (process.env.NODE_ENV !== 'production') && + warn(getWarnMessage(I18nWarnCodes.IGNORE_OBJ_FLATTEN, { + key: subKeys[i] + })); + hasStringValue = true; + break; + } + currentObj = currentObj[subKeys[i]]; + } + // update last object value, delete old property + if (!hasStringValue) { + if (!isMessageAST(currentObj)) { + currentObj[subKeys[lastIndex]] = obj[key]; + delete obj[key]; + } + else { + /** + * NOTE: + * if the last object is a message AST and subKeys[lastIndex] has message AST prop key, ignore to copy and key deletion + */ + if (!AST_NODE_PROPS_KEYS.includes(subKeys[lastIndex])) { + delete obj[key]; + } + } + } + // recursive process value if value is also a object + if (!isMessageAST(currentObj)) { + const target = currentObj[subKeys[lastIndex]]; + if (isObject(target)) { + handleFlatJson(target); + } + } + } + } + return obj; +} +function getLocaleMessages(locale, options) { + const { messages, __i18n, messageResolver, flatJson } = options; + // prettier-ignore + const ret = (isPlainObject(messages) + ? messages + : isArray(__i18n) + ? create() + : { [locale]: create() }); + // merge locale messages of i18n custom block + if (isArray(__i18n)) { + __i18n.forEach(custom => { + if ('locale' in custom && 'resource' in custom) { + const { locale, resource } = custom; + if (locale) { + ret[locale] = ret[locale] || create(); + deepCopy(resource, ret[locale]); + } + else { + deepCopy(resource, ret); + } + } + else { + isString(custom) && deepCopy(JSON.parse(custom), ret); + } + }); + } + // handle messages for flat json + if (messageResolver == null && flatJson) { + for (const key in ret) { + if (hasOwn(ret, key)) { + handleFlatJson(ret[key]); + } + } + } + return ret; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getComponentOptions(instance) { + return instance.type ; +} +function adjustI18nResources(gl, options, componentOptions // eslint-disable-line @typescript-eslint/no-explicit-any +) { + let messages = isObject(options.messages) + ? options.messages + : create(); + if ('__i18nGlobal' in componentOptions) { + messages = getLocaleMessages(gl.locale.value, { + messages, + __i18n: componentOptions.__i18nGlobal + }); + } + // merge locale messages + const locales = Object.keys(messages); + if (locales.length) { + locales.forEach(locale => { + gl.mergeLocaleMessage(locale, messages[locale]); + }); + } + { + // merge datetime formats + if (isObject(options.datetimeFormats)) { + const locales = Object.keys(options.datetimeFormats); + if (locales.length) { + locales.forEach(locale => { + gl.mergeDateTimeFormat(locale, options.datetimeFormats[locale]); + }); + } + } + // merge number formats + if (isObject(options.numberFormats)) { + const locales = Object.keys(options.numberFormats); + if (locales.length) { + locales.forEach(locale => { + gl.mergeNumberFormat(locale, options.numberFormats[locale]); + }); + } + } + } +} +function createTextNode(key) { + return createVNode(Text, null, key, 0) + ; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +/* eslint-disable @typescript-eslint/no-explicit-any */ +// extend VNode interface +const DEVTOOLS_META = '__INTLIFY_META__'; +const NOOP_RETURN_ARRAY = () => []; +const NOOP_RETURN_FALSE = () => false; +let composerID = 0; +function defineCoreMissingHandler(missing) { + return ((ctx, locale, key, type) => { + return missing(locale, key, getCurrentInstance() || undefined, type); + }); +} +// for Intlify DevTools +/* #__NO_SIDE_EFFECTS__ */ +const getMetaInfo = () => { + const instance = getCurrentInstance(); + let meta = null; // eslint-disable-line @typescript-eslint/no-explicit-any + return instance && (meta = getComponentOptions(instance)[DEVTOOLS_META]) + ? { [DEVTOOLS_META]: meta } // eslint-disable-line @typescript-eslint/no-explicit-any + : null; +}; +/** + * Create composer interface factory + * + * @internal + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function createComposer(options = {}, VueI18nLegacy) { + const { __root, __injectWithOption } = options; + const _isGlobal = __root === undefined; + const flatJson = options.flatJson; + const _ref = inBrowser ? ref : shallowRef; + const translateExistCompatible = !!options.translateExistCompatible; + if ((process.env.NODE_ENV !== 'production')) { + if (translateExistCompatible && !false) { + warnOnce(getWarnMessage(I18nWarnCodes.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG)); + } + } + let _inheritLocale = isBoolean(options.inheritLocale) + ? options.inheritLocale + : true; + const _locale = _ref( + // prettier-ignore + __root && _inheritLocale + ? __root.locale.value + : isString(options.locale) + ? options.locale + : DEFAULT_LOCALE); + const _fallbackLocale = _ref( + // prettier-ignore + __root && _inheritLocale + ? __root.fallbackLocale.value + : isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale.value); + const _messages = _ref(getLocaleMessages(_locale.value, options)); + // prettier-ignore + const _datetimeFormats = _ref(isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : { [_locale.value]: {} }) + ; + // prettier-ignore + const _numberFormats = _ref(isPlainObject(options.numberFormats) + ? options.numberFormats + : { [_locale.value]: {} }) + ; + // warning suppress options + // prettier-ignore + let _missingWarn = __root + ? __root.missingWarn + : isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + // prettier-ignore + let _fallbackWarn = __root + ? __root.fallbackWarn + : isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + // prettier-ignore + let _fallbackRoot = __root + ? __root.fallbackRoot + : isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + // configure fall back to root + let _fallbackFormat = !!options.fallbackFormat; + // runtime missing + let _missing = isFunction(options.missing) ? options.missing : null; + let _runtimeMissing = isFunction(options.missing) + ? defineCoreMissingHandler(options.missing) + : null; + // postTranslation handler + let _postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + // prettier-ignore + let _warnHtmlMessage = __root + ? __root.warnHtmlMessage + : isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + let _escapeParameter = !!options.escapeParameter; + // custom linked modifiers + // prettier-ignore + const _modifiers = __root + ? __root.modifiers + : isPlainObject(options.modifiers) + ? options.modifiers + : {}; + // pluralRules + let _pluralRules = options.pluralRules || (__root && __root.pluralRules); + // runtime context + // eslint-disable-next-line prefer-const + let _context; + const getCoreContext = () => { + _isGlobal && setFallbackContext(null); + const ctxOptions = { + version: VERSION, + locale: _locale.value, + fallbackLocale: _fallbackLocale.value, + messages: _messages.value, + modifiers: _modifiers, + pluralRules: _pluralRules, + missing: _runtimeMissing === null ? undefined : _runtimeMissing, + missingWarn: _missingWarn, + fallbackWarn: _fallbackWarn, + fallbackFormat: _fallbackFormat, + unresolving: true, + postTranslation: _postTranslation === null ? undefined : _postTranslation, + warnHtmlMessage: _warnHtmlMessage, + escapeParameter: _escapeParameter, + messageResolver: options.messageResolver, + messageCompiler: options.messageCompiler, + __meta: { framework: 'vue' } + }; + { + ctxOptions.datetimeFormats = _datetimeFormats.value; + ctxOptions.numberFormats = _numberFormats.value; + ctxOptions.__datetimeFormatters = isPlainObject(_context) + ? _context.__datetimeFormatters + : undefined; + ctxOptions.__numberFormatters = isPlainObject(_context) + ? _context.__numberFormatters + : undefined; + } + if ((process.env.NODE_ENV !== 'production')) { + ctxOptions.__v_emitter = isPlainObject(_context) + ? _context.__v_emitter + : undefined; + } + const ctx = createCoreContext(ctxOptions); + _isGlobal && setFallbackContext(ctx); + return ctx; + }; + _context = getCoreContext(); + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + // track reactivity + function trackReactivityValues() { + return [ + _locale.value, + _fallbackLocale.value, + _messages.value, + _datetimeFormats.value, + _numberFormats.value + ] + ; + } + // locale + const locale = computed({ + get: () => _locale.value, + set: val => { + _locale.value = val; + _context.locale = _locale.value; + } + }); + // fallbackLocale + const fallbackLocale = computed({ + get: () => _fallbackLocale.value, + set: val => { + _fallbackLocale.value = val; + _context.fallbackLocale = _fallbackLocale.value; + updateFallbackLocale(_context, _locale.value, val); + } + }); + // messages + const messages = computed(() => _messages.value); + // datetimeFormats + const datetimeFormats = /* #__PURE__*/ computed(() => _datetimeFormats.value); + // numberFormats + const numberFormats = /* #__PURE__*/ computed(() => _numberFormats.value); + // getPostTranslationHandler + function getPostTranslationHandler() { + return isFunction(_postTranslation) ? _postTranslation : null; + } + // setPostTranslationHandler + function setPostTranslationHandler(handler) { + _postTranslation = handler; + _context.postTranslation = handler; + } + // getMissingHandler + function getMissingHandler() { + return _missing; + } + // setMissingHandler + function setMissingHandler(handler) { + if (handler !== null) { + _runtimeMissing = defineCoreMissingHandler(handler); + } + _missing = handler; + _context.missing = _runtimeMissing; + } + function isResolvedTranslateMessage(type, arg // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + return type !== 'translate' || !arg.resolvedMessage; + } + const wrapWithDeps = (fn, argumentParser, warnType, fallbackSuccess, fallbackFail, successCondition) => { + trackReactivityValues(); // track reactive dependency + // NOTE: experimental !! + let ret; + try { + if ((process.env.NODE_ENV !== 'production') || __INTLIFY_PROD_DEVTOOLS__) { + setAdditionalMeta(getMetaInfo()); + } + if (!_isGlobal) { + _context.fallbackContext = __root + ? getFallbackContext() + : undefined; + } + ret = fn(_context); + } + finally { + if ((process.env.NODE_ENV !== 'production') || __INTLIFY_PROD_DEVTOOLS__) { + setAdditionalMeta(null); + } + if (!_isGlobal) { + _context.fallbackContext = undefined; + } + } + if ((warnType !== 'translate exists' && // for not `te` (e.g `t`) + isNumber(ret) && + ret === NOT_REOSLVED) || + (warnType === 'translate exists' && !ret) // for `te` + ) { + const [key, arg2] = argumentParser(); + if ((process.env.NODE_ENV !== 'production') && + __root && + isString(key) && + isResolvedTranslateMessage(warnType, arg2)) { + if (_fallbackRoot && + (isTranslateFallbackWarn(_fallbackWarn, key) || + isTranslateMissingWarn(_missingWarn, key))) { + warn(getWarnMessage(I18nWarnCodes.FALLBACK_TO_ROOT, { + key, + type: warnType + })); + } + // for vue-devtools timeline event + if ((process.env.NODE_ENV !== 'production')) { + const { __v_emitter: emitter } = _context; + if (emitter && _fallbackRoot) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type: warnType, + key, + to: 'global', + groupId: `${warnType}:${key}` + }); + } + } + } + return __root && _fallbackRoot + ? fallbackSuccess(__root) + : fallbackFail(key); + } + else if (successCondition(ret)) { + return ret; + } + else { + /* istanbul ignore next */ + throw createI18nError(I18nErrorCodes.UNEXPECTED_RETURN_TYPE); + } + }; + // t + function t(...args) { + return wrapWithDeps(context => Reflect.apply(translate, null, [context, ...args]), () => parseTranslateArgs(...args), 'translate', root => Reflect.apply(root.t, root, [...args]), key => key, val => isString(val)); + } + // rt + function rt(...args) { + const [arg1, arg2, arg3] = args; + if (arg3 && !isObject(arg3)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + return t(...[arg1, arg2, assign({ resolvedMessage: true }, arg3 || {})]); + } + // d + function d(...args) { + return wrapWithDeps(context => Reflect.apply(datetime, null, [context, ...args]), () => parseDateTimeArgs(...args), 'datetime format', root => Reflect.apply(root.d, root, [...args]), () => MISSING_RESOLVE_VALUE, val => isString(val)); + } + // n + function n(...args) { + return wrapWithDeps(context => Reflect.apply(number, null, [context, ...args]), () => parseNumberArgs(...args), 'number format', root => Reflect.apply(root.n, root, [...args]), () => MISSING_RESOLVE_VALUE, val => isString(val)); + } + // for custom processor + function normalize(values) { + return values.map(val => isString(val) || isNumber(val) || isBoolean(val) + ? createTextNode(String(val)) + : val); + } + const interpolate = (val) => val; + const processor = { + normalize, + interpolate, + type: 'vnode' + }; + // translateVNode, using for `i18n-t` component + function translateVNode(...args) { + return wrapWithDeps(context => { + let ret; + const _context = context; + try { + _context.processor = processor; + ret = Reflect.apply(translate, null, [_context, ...args]); + } + finally { + _context.processor = null; + } + return ret; + }, () => parseTranslateArgs(...args), 'translate', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[TranslateVNodeSymbol](...args), key => [createTextNode(key)], val => isArray(val)); + } + // numberParts, using for `i18n-n` component + function numberParts(...args) { + return wrapWithDeps(context => Reflect.apply(number, null, [context, ...args]), () => parseNumberArgs(...args), 'number format', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[NumberPartsSymbol](...args), NOOP_RETURN_ARRAY, val => isString(val) || isArray(val)); + } + // datetimeParts, using for `i18n-d` component + function datetimeParts(...args) { + return wrapWithDeps(context => Reflect.apply(datetime, null, [context, ...args]), () => parseDateTimeArgs(...args), 'datetime format', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[DatetimePartsSymbol](...args), NOOP_RETURN_ARRAY, val => isString(val) || isArray(val)); + } + function setPluralRules(rules) { + _pluralRules = rules; + _context.pluralRules = _pluralRules; + } + // te + function te(key, locale) { + return wrapWithDeps(() => { + if (!key) { + return false; + } + const targetLocale = isString(locale) ? locale : _locale.value; + const message = getLocaleMessage(targetLocale); + const resolved = _context.messageResolver(message, key); + return !translateExistCompatible + ? isMessageAST(resolved) || + isMessageFunction(resolved) || + isString(resolved) + : resolved != null; + }, () => [key], 'translate exists', root => { + return Reflect.apply(root.te, root, [key, locale]); + }, NOOP_RETURN_FALSE, val => isBoolean(val)); + } + function resolveMessages(key) { + let messages = null; + const locales = fallbackWithLocaleChain(_context, _fallbackLocale.value, _locale.value); + for (let i = 0; i < locales.length; i++) { + const targetLocaleMessages = _messages.value[locales[i]] || {}; + const messageValue = _context.messageResolver(targetLocaleMessages, key); + if (messageValue != null) { + messages = messageValue; + break; + } + } + return messages; + } + // tm + function tm(key) { + const messages = resolveMessages(key); + // prettier-ignore + return messages != null + ? messages + : __root + ? __root.tm(key) || {} + : {}; + } + // getLocaleMessage + function getLocaleMessage(locale) { + return (_messages.value[locale] || {}); + } + // setLocaleMessage + function setLocaleMessage(locale, message) { + if (flatJson) { + const _message = { [locale]: message }; + for (const key in _message) { + if (hasOwn(_message, key)) { + handleFlatJson(_message[key]); + } + } + message = _message[locale]; + } + _messages.value[locale] = message; + _context.messages = _messages.value; + } + // mergeLocaleMessage + function mergeLocaleMessage(locale, message) { + _messages.value[locale] = _messages.value[locale] || {}; + const _message = { [locale]: message }; + if (flatJson) { + for (const key in _message) { + if (hasOwn(_message, key)) { + handleFlatJson(_message[key]); + } + } + } + message = _message[locale]; + deepCopy(message, _messages.value[locale]); + _context.messages = _messages.value; + } + // getDateTimeFormat + function getDateTimeFormat(locale) { + return _datetimeFormats.value[locale] || {}; + } + // setDateTimeFormat + function setDateTimeFormat(locale, format) { + _datetimeFormats.value[locale] = format; + _context.datetimeFormats = _datetimeFormats.value; + clearDateTimeFormat(_context, locale, format); + } + // mergeDateTimeFormat + function mergeDateTimeFormat(locale, format) { + _datetimeFormats.value[locale] = assign(_datetimeFormats.value[locale] || {}, format); + _context.datetimeFormats = _datetimeFormats.value; + clearDateTimeFormat(_context, locale, format); + } + // getNumberFormat + function getNumberFormat(locale) { + return _numberFormats.value[locale] || {}; + } + // setNumberFormat + function setNumberFormat(locale, format) { + _numberFormats.value[locale] = format; + _context.numberFormats = _numberFormats.value; + clearNumberFormat(_context, locale, format); + } + // mergeNumberFormat + function mergeNumberFormat(locale, format) { + _numberFormats.value[locale] = assign(_numberFormats.value[locale] || {}, format); + _context.numberFormats = _numberFormats.value; + clearNumberFormat(_context, locale, format); + } + // for debug + composerID++; + // watch root locale & fallbackLocale + if (__root && inBrowser) { + watch(__root.locale, (val) => { + if (_inheritLocale) { + _locale.value = val; + _context.locale = val; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }); + watch(__root.fallbackLocale, (val) => { + if (_inheritLocale) { + _fallbackLocale.value = val; + _context.fallbackLocale = val; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }); + } + // define basic composition API! + const composer = { + id: composerID, + locale, + fallbackLocale, + get inheritLocale() { + return _inheritLocale; + }, + set inheritLocale(val) { + _inheritLocale = val; + if (val && __root) { + _locale.value = __root.locale.value; + _fallbackLocale.value = __root.fallbackLocale.value; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }, + get availableLocales() { + return Object.keys(_messages.value).sort(); + }, + messages, + get modifiers() { + return _modifiers; + }, + get pluralRules() { + return _pluralRules || {}; + }, + get isGlobal() { + return _isGlobal; + }, + get missingWarn() { + return _missingWarn; + }, + set missingWarn(val) { + _missingWarn = val; + _context.missingWarn = _missingWarn; + }, + get fallbackWarn() { + return _fallbackWarn; + }, + set fallbackWarn(val) { + _fallbackWarn = val; + _context.fallbackWarn = _fallbackWarn; + }, + get fallbackRoot() { + return _fallbackRoot; + }, + set fallbackRoot(val) { + _fallbackRoot = val; + }, + get fallbackFormat() { + return _fallbackFormat; + }, + set fallbackFormat(val) { + _fallbackFormat = val; + _context.fallbackFormat = _fallbackFormat; + }, + get warnHtmlMessage() { + return _warnHtmlMessage; + }, + set warnHtmlMessage(val) { + _warnHtmlMessage = val; + _context.warnHtmlMessage = val; + }, + get escapeParameter() { + return _escapeParameter; + }, + set escapeParameter(val) { + _escapeParameter = val; + _context.escapeParameter = val; + }, + t, + getLocaleMessage, + setLocaleMessage, + mergeLocaleMessage, + getPostTranslationHandler, + setPostTranslationHandler, + getMissingHandler, + setMissingHandler, + [SetPluralRulesSymbol]: setPluralRules + }; + { + composer.datetimeFormats = datetimeFormats; + composer.numberFormats = numberFormats; + composer.rt = rt; + composer.te = te; + composer.tm = tm; + composer.d = d; + composer.n = n; + composer.getDateTimeFormat = getDateTimeFormat; + composer.setDateTimeFormat = setDateTimeFormat; + composer.mergeDateTimeFormat = mergeDateTimeFormat; + composer.getNumberFormat = getNumberFormat; + composer.setNumberFormat = setNumberFormat; + composer.mergeNumberFormat = mergeNumberFormat; + composer[InejctWithOptionSymbol] = __injectWithOption; + composer[TranslateVNodeSymbol] = translateVNode; + composer[DatetimePartsSymbol] = datetimeParts; + composer[NumberPartsSymbol] = numberParts; + } + // for vue-devtools timeline event + if ((process.env.NODE_ENV !== 'production')) { + composer[EnableEmitter] = (emitter) => { + _context.__v_emitter = emitter; + }; + composer[DisableEmitter] = () => { + _context.__v_emitter = undefined; + }; + } + return composer; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Convert to I18n Composer Options from VueI18n Options + * + * @internal + */ +function convertComposerOptions(options) { + const locale = isString(options.locale) ? options.locale : DEFAULT_LOCALE; + const fallbackLocale = isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : locale; + const missing = isFunction(options.missing) ? options.missing : undefined; + const missingWarn = isBoolean(options.silentTranslationWarn) || + isRegExp(options.silentTranslationWarn) + ? !options.silentTranslationWarn + : true; + const fallbackWarn = isBoolean(options.silentFallbackWarn) || + isRegExp(options.silentFallbackWarn) + ? !options.silentFallbackWarn + : true; + const fallbackRoot = isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + const fallbackFormat = !!options.formatFallbackMessages; + const modifiers = isPlainObject(options.modifiers) ? options.modifiers : {}; + const pluralizationRules = options.pluralizationRules; + const postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : undefined; + const warnHtmlMessage = isString(options.warnHtmlInMessage) + ? options.warnHtmlInMessage !== 'off' + : true; + const escapeParameter = !!options.escapeParameterHtml; + const inheritLocale = isBoolean(options.sync) ? options.sync : true; + if ((process.env.NODE_ENV !== 'production') && options.formatter) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + } + if ((process.env.NODE_ENV !== 'production') && options.preserveDirectiveContent) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + } + let messages = options.messages; + if (isPlainObject(options.sharedMessages)) { + const sharedMessages = options.sharedMessages; + const locales = Object.keys(sharedMessages); + messages = locales.reduce((messages, locale) => { + const message = messages[locale] || (messages[locale] = {}); + assign(message, sharedMessages[locale]); + return messages; + }, (messages || {})); + } + const { __i18n, __root, __injectWithOption } = options; + const datetimeFormats = options.datetimeFormats; + const numberFormats = options.numberFormats; + const flatJson = options.flatJson; + const translateExistCompatible = options + .translateExistCompatible; + return { + locale, + fallbackLocale, + messages, + flatJson, + datetimeFormats, + numberFormats, + missing, + missingWarn, + fallbackWarn, + fallbackRoot, + fallbackFormat, + modifiers, + pluralRules: pluralizationRules, + postTranslation, + warnHtmlMessage, + escapeParameter, + messageResolver: options.messageResolver, + inheritLocale, + translateExistCompatible, + __i18n, + __root, + __injectWithOption + }; +} +/** + * create VueI18n interface factory + * + * @internal + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function createVueI18n(options = {}, VueI18nLegacy) { + { + const composer = createComposer(convertComposerOptions(options)); + const { __extender } = options; + // defines VueI18n + const vueI18n = { + // id + id: composer.id, + // locale + get locale() { + return composer.locale.value; + }, + set locale(val) { + composer.locale.value = val; + }, + // fallbackLocale + get fallbackLocale() { + return composer.fallbackLocale.value; + }, + set fallbackLocale(val) { + composer.fallbackLocale.value = val; + }, + // messages + get messages() { + return composer.messages.value; + }, + // datetimeFormats + get datetimeFormats() { + return composer.datetimeFormats.value; + }, + // numberFormats + get numberFormats() { + return composer.numberFormats.value; + }, + // availableLocales + get availableLocales() { + return composer.availableLocales; + }, + // formatter + get formatter() { + (process.env.NODE_ENV !== 'production') && warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + // dummy + return { + interpolate() { + return []; + } + }; + }, + set formatter(val) { + (process.env.NODE_ENV !== 'production') && warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + }, + // missing + get missing() { + return composer.getMissingHandler(); + }, + set missing(handler) { + composer.setMissingHandler(handler); + }, + // silentTranslationWarn + get silentTranslationWarn() { + return isBoolean(composer.missingWarn) + ? !composer.missingWarn + : composer.missingWarn; + }, + set silentTranslationWarn(val) { + composer.missingWarn = isBoolean(val) ? !val : val; + }, + // silentFallbackWarn + get silentFallbackWarn() { + return isBoolean(composer.fallbackWarn) + ? !composer.fallbackWarn + : composer.fallbackWarn; + }, + set silentFallbackWarn(val) { + composer.fallbackWarn = isBoolean(val) ? !val : val; + }, + // modifiers + get modifiers() { + return composer.modifiers; + }, + // formatFallbackMessages + get formatFallbackMessages() { + return composer.fallbackFormat; + }, + set formatFallbackMessages(val) { + composer.fallbackFormat = val; + }, + // postTranslation + get postTranslation() { + return composer.getPostTranslationHandler(); + }, + set postTranslation(handler) { + composer.setPostTranslationHandler(handler); + }, + // sync + get sync() { + return composer.inheritLocale; + }, + set sync(val) { + composer.inheritLocale = val; + }, + // warnInHtmlMessage + get warnHtmlInMessage() { + return composer.warnHtmlMessage ? 'warn' : 'off'; + }, + set warnHtmlInMessage(val) { + composer.warnHtmlMessage = val !== 'off'; + }, + // escapeParameterHtml + get escapeParameterHtml() { + return composer.escapeParameter; + }, + set escapeParameterHtml(val) { + composer.escapeParameter = val; + }, + // preserveDirectiveContent + get preserveDirectiveContent() { + (process.env.NODE_ENV !== 'production') && + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + return true; + }, + set preserveDirectiveContent(val) { + (process.env.NODE_ENV !== 'production') && + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + }, + // pluralizationRules + get pluralizationRules() { + return composer.pluralRules || {}; + }, + // for internal + __composer: composer, + // t + t(...args) { + const [arg1, arg2, arg3] = args; + const options = {}; + let list = null; + let named = null; + if (!isString(arg1)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + const key = arg1; + if (isString(arg2)) { + options.locale = arg2; + } + else if (isArray(arg2)) { + list = arg2; + } + else if (isPlainObject(arg2)) { + named = arg2; + } + if (isArray(arg3)) { + list = arg3; + } + else if (isPlainObject(arg3)) { + named = arg3; + } + // return composer.t(key, (list || named || {}) as any, options) + return Reflect.apply(composer.t, composer, [ + key, + (list || named || {}), + options + ]); + }, + rt(...args) { + return Reflect.apply(composer.rt, composer, [...args]); + }, + // tc + tc(...args) { + const [arg1, arg2, arg3] = args; + const options = { plural: 1 }; + let list = null; + let named = null; + if (!isString(arg1)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + const key = arg1; + if (isString(arg2)) { + options.locale = arg2; + } + else if (isNumber(arg2)) { + options.plural = arg2; + } + else if (isArray(arg2)) { + list = arg2; + } + else if (isPlainObject(arg2)) { + named = arg2; + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isArray(arg3)) { + list = arg3; + } + else if (isPlainObject(arg3)) { + named = arg3; + } + // return composer.t(key, (list || named || {}) as any, options) + return Reflect.apply(composer.t, composer, [ + key, + (list || named || {}), + options + ]); + }, + // te + te(key, locale) { + return composer.te(key, locale); + }, + // tm + tm(key) { + return composer.tm(key); + }, + // getLocaleMessage + getLocaleMessage(locale) { + return composer.getLocaleMessage(locale); + }, + // setLocaleMessage + setLocaleMessage(locale, message) { + composer.setLocaleMessage(locale, message); + }, + // mergeLocaleMessage + mergeLocaleMessage(locale, message) { + composer.mergeLocaleMessage(locale, message); + }, + // d + d(...args) { + return Reflect.apply(composer.d, composer, [...args]); + }, + // getDateTimeFormat + getDateTimeFormat(locale) { + return composer.getDateTimeFormat(locale); + }, + // setDateTimeFormat + setDateTimeFormat(locale, format) { + composer.setDateTimeFormat(locale, format); + }, + // mergeDateTimeFormat + mergeDateTimeFormat(locale, format) { + composer.mergeDateTimeFormat(locale, format); + }, + // n + n(...args) { + return Reflect.apply(composer.n, composer, [...args]); + }, + // getNumberFormat + getNumberFormat(locale) { + return composer.getNumberFormat(locale); + }, + // setNumberFormat + setNumberFormat(locale, format) { + composer.setNumberFormat(locale, format); + }, + // mergeNumberFormat + mergeNumberFormat(locale, format) { + composer.mergeNumberFormat(locale, format); + }, + // getChoiceIndex + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getChoiceIndex(choice, choicesLength) { + (process.env.NODE_ENV !== 'production') && + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX)); + return -1; + } + }; + vueI18n.__extender = __extender; + // for vue-devtools timeline event + if ((process.env.NODE_ENV !== 'production')) { + vueI18n.__enableEmitter = (emitter) => { + const __composer = composer; + __composer[EnableEmitter] && __composer[EnableEmitter](emitter); + }; + vueI18n.__disableEmitter = () => { + const __composer = composer; + __composer[DisableEmitter] && __composer[DisableEmitter](); + }; + } + return vueI18n; + } +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +const baseFormatProps = { + tag: { + type: [String, Object] + }, + locale: { + type: String + }, + scope: { + type: String, + // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050 + validator: (val /* ComponentI18nScope */) => val === 'parent' || val === 'global', + default: 'parent' /* ComponentI18nScope */ + }, + i18n: { + type: Object + } +}; + +function getInterpolateArg( +// eslint-disable-next-line @typescript-eslint/no-explicit-any +{ slots }, // SetupContext, +keys) { + if (keys.length === 1 && keys[0] === 'default') { + // default slot with list + const ret = slots.default ? slots.default() : []; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return ret.reduce((slot, current) => { + return [ + ...slot, + // prettier-ignore + ...(current.type === Fragment ? current.children : [current] + ) + ]; + }, []); + } + else { + // named slots + return keys.reduce((arg, key) => { + const slot = slots[key]; + if (slot) { + arg[key] = slot(); + } + return arg; + }, create()); + } +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getFragmentableTag(tag) { + return Fragment ; +} + +const TranslationImpl = /*#__PURE__*/ defineComponent({ + /* eslint-disable */ + name: 'i18n-t', + props: assign({ + keypath: { + type: String, + required: true + }, + plural: { + type: [Number, String], + // eslint-disable-next-line @typescript-eslint/no-explicit-any + validator: (val) => isNumber(val) || !isNaN(val) + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const { slots, attrs } = context; + // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050 + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return () => { + const keys = Object.keys(slots).filter(key => key !== '_'); + const options = create(); + if (props.locale) { + options.locale = props.locale; + } + if (props.plural !== undefined) { + options.plural = isString(props.plural) ? +props.plural : props.plural; + } + const arg = getInterpolateArg(context, keys); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const children = i18n[TranslateVNodeSymbol](props.keypath, arg, options); + const assignedAttrs = assign(create(), attrs); + const tag = isString(props.tag) || isObject(props.tag) + ? props.tag + : getFragmentableTag(); + return h(tag, assignedAttrs, children); + }; + } +}); +/** + * export the public type for h/tsx inference + * also to avoid inline import() in generated d.ts files + */ +/** + * Translation Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [TranslationProps](component#translationprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Component Interpolation](../guide/advanced/component) + * + * @example + * ```html + *
+ * + * + * {{ $t('tos') }} + * + * + *
+ * ``` + * ```js + * import { createApp } from 'vue' + * import { createI18n } from 'vue-i18n' + * + * const messages = { + * en: { + * tos: 'Term of Service', + * term: 'I accept xxx {0}.' + * }, + * ja: { + * tos: '利用規約', + * term: '私は xxx の{0}に同意します。' + * } + * } + * + * const i18n = createI18n({ + * locale: 'en', + * messages + * }) + * + * const app = createApp({ + * data: { + * url: '/term' + * } + * }).use(i18n).mount('#app') + * ``` + * + * @VueI18nComponent + */ +const Translation = TranslationImpl; +const I18nT = Translation; + +function isVNode(target) { + return isArray(target) && !isString(target[0]); +} +function renderFormatter(props, context, slotKeys, partFormatter) { + const { slots, attrs } = context; + return () => { + const options = { part: true }; + let overrides = create(); + if (props.locale) { + options.locale = props.locale; + } + if (isString(props.format)) { + options.key = props.format; + } + else if (isObject(props.format)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (isString(props.format.key)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + options.key = props.format.key; + } + // Filter out number format options only + overrides = Object.keys(props.format).reduce((options, prop) => { + return slotKeys.includes(prop) + ? assign(create(), options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any + : options; + }, create()); + } + const parts = partFormatter(...[props.value, options, overrides]); + let children = [options.key]; + if (isArray(parts)) { + children = parts.map((part, index) => { + const slot = slots[part.type]; + const node = slot + ? slot({ [part.type]: part.value, index, parts }) + : [part.value]; + if (isVNode(node)) { + node[0].key = `${part.type}-${index}`; + } + return node; + }); + } + else if (isString(parts)) { + children = [parts]; + } + const assignedAttrs = assign(create(), attrs); + const tag = isString(props.tag) || isObject(props.tag) + ? props.tag + : getFragmentableTag(); + return h(tag, assignedAttrs, children); + }; +} + +const NumberFormatImpl = /*#__PURE__*/ defineComponent({ + /* eslint-disable */ + name: 'i18n-n', + props: assign({ + value: { + type: Number, + required: true + }, + format: { + type: [String, Object] + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return renderFormatter(props, context, NUMBER_FORMAT_OPTIONS_KEYS, (...args) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + i18n[NumberPartsSymbol](...args)); + } +}); +/** + * export the public type for h/tsx inference + * also to avoid inline import() in generated d.ts files + */ +/** + * Number Format Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [FormattableProps](component#formattableprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Custom Formatting](../guide/essentials/number#custom-formatting) + * + * @VueI18nDanger + * Not supported IE, due to no support `Intl.NumberFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts) + * + * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-numberformat) + * + * @VueI18nComponent + */ +const NumberFormat = NumberFormatImpl; +const I18nN = NumberFormat; + +const DatetimeFormatImpl = /* #__PURE__*/ defineComponent({ + /* eslint-disable */ + name: 'i18n-d', + props: assign({ + value: { + type: [Number, Date], + required: true + }, + format: { + type: [String, Object] + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return renderFormatter(props, context, DATETIME_FORMAT_OPTIONS_KEYS, (...args) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + i18n[DatetimePartsSymbol](...args)); + } +}); +/** + * Datetime Format Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [FormattableProps](component#formattableprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Custom Formatting](../guide/essentials/datetime#custom-formatting) + * + * @VueI18nDanger + * Not supported IE, due to no support `Intl.DateTimeFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts) + * + * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-datetimeformat) + * + * @VueI18nComponent + */ +const DatetimeFormat = DatetimeFormatImpl; +const I18nD = DatetimeFormat; + +function getComposer$2(i18n, instance) { + const i18nInternal = i18n; + if (i18n.mode === 'composition') { + return (i18nInternal.__getInstance(instance) || i18n.global); + } + else { + const vueI18n = i18nInternal.__getInstance(instance); + return vueI18n != null + ? vueI18n.__composer + : i18n.global.__composer; + } +} +function vTDirective(i18n) { + const _process = (binding) => { + const { instance, modifiers, value } = binding; + /* istanbul ignore if */ + if (!instance || !instance.$) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const composer = getComposer$2(i18n, instance.$); + if ((process.env.NODE_ENV !== 'production') && modifiers.preserve) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE)); + } + const parsedValue = parseValue(value); + return [ + Reflect.apply(composer.t, composer, [...makeParams(parsedValue)]), + composer + ]; + }; + const register = (el, binding) => { + const [textContent, composer] = _process(binding); + if (inBrowser && i18n.global === composer) { + // global scope only + el.__i18nWatcher = watch(composer.locale, () => { + binding.instance && binding.instance.$forceUpdate(); + }); + } + el.__composer = composer; + el.textContent = textContent; + }; + const unregister = (el) => { + if (inBrowser && el.__i18nWatcher) { + el.__i18nWatcher(); + el.__i18nWatcher = undefined; + delete el.__i18nWatcher; + } + if (el.__composer) { + el.__composer = undefined; + delete el.__composer; + } + }; + const update = (el, { value }) => { + if (el.__composer) { + const composer = el.__composer; + const parsedValue = parseValue(value); + el.textContent = Reflect.apply(composer.t, composer, [ + ...makeParams(parsedValue) + ]); + } + }; + const getSSRProps = (binding) => { + const [textContent] = _process(binding); + return { textContent }; + }; + return { + created: register, + unmounted: unregister, + beforeUpdate: update, + getSSRProps + }; +} +function parseValue(value) { + if (isString(value)) { + return { path: value }; + } + else if (isPlainObject(value)) { + if (!('path' in value)) { + throw createI18nError(I18nErrorCodes.REQUIRED_VALUE, 'path'); + } + return value; + } + else { + throw createI18nError(I18nErrorCodes.INVALID_VALUE); + } +} +function makeParams(value) { + const { path, locale, args, choice, plural } = value; + const options = {}; + const named = args || {}; + if (isString(locale)) { + options.locale = locale; + } + if (isNumber(choice)) { + options.plural = choice; + } + if (isNumber(plural)) { + options.plural = plural; + } + return [path, named, options]; +} + +function apply(app, i18n, ...options) { + const pluginOptions = isPlainObject(options[0]) + ? options[0] + : {}; + const useI18nComponentName = !!pluginOptions.useI18nComponentName; + const globalInstall = isBoolean(pluginOptions.globalInstall) + ? pluginOptions.globalInstall + : true; + if ((process.env.NODE_ENV !== 'production') && globalInstall && useI18nComponentName) { + warn(getWarnMessage(I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE, { + name: Translation.name + })); + } + if (globalInstall) { + [!useI18nComponentName ? Translation.name : 'i18n', 'I18nT'].forEach(name => app.component(name, Translation)); + [NumberFormat.name, 'I18nN'].forEach(name => app.component(name, NumberFormat)); + [DatetimeFormat.name, 'I18nD'].forEach(name => app.component(name, DatetimeFormat)); + } + // install directive + { + app.directive('t', vTDirective(i18n)); + } +} + +const VueDevToolsLabels = { + ["vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */]: 'Vue I18n devtools', + ["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */]: 'I18n Resources', + ["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */]: 'Vue I18n' +}; +const VueDevToolsPlaceholders = { + ["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */]: 'Search for scopes ...' +}; +const VueDevToolsTimelineColors = { + ["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */]: 0xffcd19 +}; + +const VUE_I18N_COMPONENT_TYPES = 'vue-i18n: composer properties'; +let devtoolsApi; +async function enableDevTools(app, i18n) { + return new Promise((resolve, reject) => { + try { + setupDevtoolsPlugin({ + id: "vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */, + label: VueDevToolsLabels["vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */], + packageName: 'vue-i18n', + homepage: 'https://vue-i18n.intlify.dev', + logo: 'https://vue-i18n.intlify.dev/vue-i18n-devtools-logo.png', + componentStateTypes: [VUE_I18N_COMPONENT_TYPES], + app: app // eslint-disable-line @typescript-eslint/no-explicit-any + }, api => { + devtoolsApi = api; + api.on.visitComponentTree(({ componentInstance, treeNode }) => { + updateComponentTreeTags(componentInstance, treeNode, i18n); + }); + api.on.inspectComponent(({ componentInstance, instanceData }) => { + if (componentInstance.vnode.el && + componentInstance.vnode.el.__VUE_I18N__ && + instanceData) { + if (i18n.mode === 'legacy') { + // ignore global scope on legacy mode + if (componentInstance.vnode.el.__VUE_I18N__ !== + i18n.global.__composer) { + inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__); + } + } + else { + inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__); + } + } + }); + api.addInspector({ + id: "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */, + label: VueDevToolsLabels["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */], + icon: 'language', + treeFilterPlaceholder: VueDevToolsPlaceholders["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */] + }); + api.on.getInspectorTree(payload => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + registerScope(payload, i18n); + } + }); + const roots = new Map(); + api.on.getInspectorState(async (payload) => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + api.unhighlightElement(); + inspectScope(payload, i18n); + if (payload.nodeId === 'global') { + if (!roots.has(payload.app)) { + const [root] = await api.getComponentInstances(payload.app); + roots.set(payload.app, root); + } + api.highlightElement(roots.get(payload.app)); + } + else { + const instance = getComponentInstance(payload.nodeId, i18n); + instance && api.highlightElement(instance); + } + } + }); + api.on.editInspectorState(payload => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + editScope(payload, i18n); + } + }); + api.addTimelineLayer({ + id: "vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */, + label: VueDevToolsLabels["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */], + color: VueDevToolsTimelineColors["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */] + }); + resolve(true); + }); + } + catch (e) { + console.error(e); + reject(false); + } + }); +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getI18nScopeLable(instance) { + return (instance.type.name || + instance.type.displayName || + instance.type.__file || + 'Anonymous'); +} +function updateComponentTreeTags(instance, // eslint-disable-line @typescript-eslint/no-explicit-any +treeNode, i18n) { + // prettier-ignore + const global = i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + if (instance && instance.vnode.el && instance.vnode.el.__VUE_I18N__) { + // add custom tags local scope only + if (instance.vnode.el.__VUE_I18N__ !== global) { + const tag = { + label: `i18n (${getI18nScopeLable(instance)} Scope)`, + textColor: 0x000000, + backgroundColor: 0xffcd19 + }; + treeNode.tags.push(tag); + } + } +} +function inspectComposer(instanceData, composer) { + const type = VUE_I18N_COMPONENT_TYPES; + instanceData.state.push({ + type, + key: 'locale', + editable: true, + value: composer.locale.value + }); + instanceData.state.push({ + type, + key: 'availableLocales', + editable: false, + value: composer.availableLocales + }); + instanceData.state.push({ + type, + key: 'fallbackLocale', + editable: true, + value: composer.fallbackLocale.value + }); + instanceData.state.push({ + type, + key: 'inheritLocale', + editable: true, + value: composer.inheritLocale + }); + instanceData.state.push({ + type, + key: 'messages', + editable: false, + value: getLocaleMessageValue(composer.messages.value) + }); + { + instanceData.state.push({ + type, + key: 'datetimeFormats', + editable: false, + value: composer.datetimeFormats.value + }); + instanceData.state.push({ + type, + key: 'numberFormats', + editable: false, + value: composer.numberFormats.value + }); + } +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getLocaleMessageValue(messages) { + const value = {}; + Object.keys(messages).forEach((key) => { + const v = messages[key]; + if (isFunction(v) && 'source' in v) { + value[key] = getMessageFunctionDetails(v); + } + else if (isMessageAST(v) && v.loc && v.loc.source) { + value[key] = v.loc.source; + } + else if (isObject(v)) { + value[key] = getLocaleMessageValue(v); + } + else { + value[key] = v; + } + }); + return value; +} +const ESC = { + '<': '<', + '>': '>', + '"': '"', + '&': '&' +}; +function escape(s) { + return s.replace(/[<>"&]/g, escapeChar); +} +function escapeChar(a) { + return ESC[a] || a; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getMessageFunctionDetails(func) { + const argString = func.source ? `("${escape(func.source)}")` : `(?)`; + return { + _custom: { + type: 'function', + display: `ƒ ${argString}` + } + }; +} +function registerScope(payload, i18n) { + payload.rootNodes.push({ + id: 'global', + label: 'Global Scope' + }); + // prettier-ignore + const global = i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + for (const [keyInstance, instance] of i18n.__instances) { + // prettier-ignore + const composer = i18n.mode === 'composition' + ? instance + : instance.__composer; + if (global === composer) { + continue; + } + payload.rootNodes.push({ + id: composer.id.toString(), + label: `${getI18nScopeLable(keyInstance)} Scope` + }); + } +} +function getComponentInstance(nodeId, i18n) { + let instance = null; + if (nodeId !== 'global') { + for (const [component, composer] of i18n.__instances.entries()) { + if (composer.id.toString() === nodeId) { + instance = component; + break; + } + } + } + return instance; +} +function getComposer$1(nodeId, i18n) { + if (nodeId === 'global') { + return i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + } + else { + const instance = Array.from(i18n.__instances.values()).find(item => item.id.toString() === nodeId); + if (instance) { + return i18n.mode === 'composition' + ? instance + : instance.__composer; + } + else { + return null; + } + } +} +function inspectScope(payload, i18n +// eslint-disable-next-line @typescript-eslint/no-explicit-any +) { + const composer = getComposer$1(payload.nodeId, i18n); + if (composer) { + // TODO: + // eslint-disable-next-line @typescript-eslint/no-explicit-any + payload.state = makeScopeInspectState(composer); + } + return null; +} +function makeScopeInspectState(composer) { + const state = {}; + const localeType = 'Locale related info'; + const localeStates = [ + { + type: localeType, + key: 'locale', + editable: true, + value: composer.locale.value + }, + { + type: localeType, + key: 'fallbackLocale', + editable: true, + value: composer.fallbackLocale.value + }, + { + type: localeType, + key: 'availableLocales', + editable: false, + value: composer.availableLocales + }, + { + type: localeType, + key: 'inheritLocale', + editable: true, + value: composer.inheritLocale + } + ]; + state[localeType] = localeStates; + const localeMessagesType = 'Locale messages info'; + const localeMessagesStates = [ + { + type: localeMessagesType, + key: 'messages', + editable: false, + value: getLocaleMessageValue(composer.messages.value) + } + ]; + state[localeMessagesType] = localeMessagesStates; + { + const datetimeFormatsType = 'Datetime formats info'; + const datetimeFormatsStates = [ + { + type: datetimeFormatsType, + key: 'datetimeFormats', + editable: false, + value: composer.datetimeFormats.value + } + ]; + state[datetimeFormatsType] = datetimeFormatsStates; + const numberFormatsType = 'Datetime formats info'; + const numberFormatsStates = [ + { + type: numberFormatsType, + key: 'numberFormats', + editable: false, + value: composer.numberFormats.value + } + ]; + state[numberFormatsType] = numberFormatsStates; + } + return state; +} +function addTimelineEvent(event, payload) { + if (devtoolsApi) { + let groupId; + if (payload && 'groupId' in payload) { + groupId = payload.groupId; + delete payload.groupId; + } + devtoolsApi.addTimelineEvent({ + layerId: "vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */, + event: { + title: event, + groupId, + time: Date.now(), + meta: {}, + data: payload || {}, + logType: event === "compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */ + ? 'error' + : event === "fallback" /* VueDevToolsTimelineEvents.FALBACK */ || + event === "missing" /* VueDevToolsTimelineEvents.MISSING */ + ? 'warning' + : 'default' + } + }); + } +} +function editScope(payload, i18n) { + const composer = getComposer$1(payload.nodeId, i18n); + if (composer) { + const [field] = payload.path; + if (field === 'locale' && isString(payload.state.value)) { + composer.locale.value = payload.state.value; + } + else if (field === 'fallbackLocale' && + (isString(payload.state.value) || + isArray(payload.state.value) || + isObject(payload.state.value))) { + composer.fallbackLocale.value = payload.state.value; + } + else if (field === 'inheritLocale' && isBoolean(payload.state.value)) { + composer.inheritLocale = payload.state.value; + } + } +} + +/** + * Supports compatibility for legacy vue-i18n APIs + * This mixin is used when we use vue-i18n@v9.x or later + */ +function defineMixin(vuei18n, composer, i18n) { + return { + beforeCreate() { + const instance = getCurrentInstance(); + /* istanbul ignore if */ + if (!instance) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const options = this.$options; + if (options.i18n) { + const optionsI18n = options.i18n; + if (options.__i18n) { + optionsI18n.__i18n = options.__i18n; + } + optionsI18n.__root = composer; + if (this === this.$root) { + // merge option and gttach global + this.$i18n = mergeToGlobal(vuei18n, optionsI18n); + } + else { + optionsI18n.__injectWithOption = true; + optionsI18n.__extender = i18n.__vueI18nExtend; + // atttach local VueI18n instance + this.$i18n = createVueI18n(optionsI18n); + // extend VueI18n instance + const _vueI18n = this.$i18n; + if (_vueI18n.__extender) { + _vueI18n.__disposer = _vueI18n.__extender(this.$i18n); + } + } + } + else if (options.__i18n) { + if (this === this.$root) { + // merge option and gttach global + this.$i18n = mergeToGlobal(vuei18n, options); + } + else { + // atttach local VueI18n instance + this.$i18n = createVueI18n({ + __i18n: options.__i18n, + __injectWithOption: true, + __extender: i18n.__vueI18nExtend, + __root: composer + }); + // extend VueI18n instance + const _vueI18n = this.$i18n; + if (_vueI18n.__extender) { + _vueI18n.__disposer = _vueI18n.__extender(this.$i18n); + } + } + } + else { + // attach global VueI18n instance + this.$i18n = vuei18n; + } + if (options.__i18nGlobal) { + adjustI18nResources(composer, options, options); + } + // defines vue-i18n legacy APIs + this.$t = (...args) => this.$i18n.t(...args); + this.$rt = (...args) => this.$i18n.rt(...args); + this.$tc = (...args) => this.$i18n.tc(...args); + this.$te = (key, locale) => this.$i18n.te(key, locale); + this.$d = (...args) => this.$i18n.d(...args); + this.$n = (...args) => this.$i18n.n(...args); + this.$tm = (key) => this.$i18n.tm(key); + i18n.__setInstance(instance, this.$i18n); + }, + mounted() { + /* istanbul ignore if */ + if (((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) && + !false && + this.$el && + this.$i18n) { + const _vueI18n = this.$i18n; + this.$el.__VUE_I18N__ = _vueI18n.__composer; + const emitter = (this.__v_emitter = + createEmitter()); + _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter); + emitter.on('*', addTimelineEvent); + } + }, + unmounted() { + const instance = getCurrentInstance(); + /* istanbul ignore if */ + if (!instance) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const _vueI18n = this.$i18n; + /* istanbul ignore if */ + if (((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) && + !false && + this.$el && + this.$el.__VUE_I18N__) { + if (this.__v_emitter) { + this.__v_emitter.off('*', addTimelineEvent); + delete this.__v_emitter; + } + if (this.$i18n) { + _vueI18n.__disableEmitter && _vueI18n.__disableEmitter(); + delete this.$el.__VUE_I18N__; + } + } + delete this.$t; + delete this.$rt; + delete this.$tc; + delete this.$te; + delete this.$d; + delete this.$n; + delete this.$tm; + if (_vueI18n.__disposer) { + _vueI18n.__disposer(); + delete _vueI18n.__disposer; + delete _vueI18n.__extender; + } + i18n.__deleteInstance(instance); + delete this.$i18n; + } + }; +} +function mergeToGlobal(g, options) { + g.locale = options.locale || g.locale; + g.fallbackLocale = options.fallbackLocale || g.fallbackLocale; + g.missing = options.missing || g.missing; + g.silentTranslationWarn = + options.silentTranslationWarn || g.silentFallbackWarn; + g.silentFallbackWarn = options.silentFallbackWarn || g.silentFallbackWarn; + g.formatFallbackMessages = + options.formatFallbackMessages || g.formatFallbackMessages; + g.postTranslation = options.postTranslation || g.postTranslation; + g.warnHtmlInMessage = options.warnHtmlInMessage || g.warnHtmlInMessage; + g.escapeParameterHtml = options.escapeParameterHtml || g.escapeParameterHtml; + g.sync = options.sync || g.sync; + g.__composer[SetPluralRulesSymbol](options.pluralizationRules || g.pluralizationRules); + const messages = getLocaleMessages(g.locale, { + messages: options.messages, + __i18n: options.__i18n + }); + Object.keys(messages).forEach(locale => g.mergeLocaleMessage(locale, messages[locale])); + if (options.datetimeFormats) { + Object.keys(options.datetimeFormats).forEach(locale => g.mergeDateTimeFormat(locale, options.datetimeFormats[locale])); + } + if (options.numberFormats) { + Object.keys(options.numberFormats).forEach(locale => g.mergeNumberFormat(locale, options.numberFormats[locale])); + } + return g; +} + +/** + * Injection key for {@link useI18n} + * + * @remarks + * The global injection key for I18n instances with `useI18n`. this injection key is used in Web Components. + * Specify the i18n instance created by {@link createI18n} together with `provide` function. + * + * @VueI18nGeneral + */ +const I18nInjectionKey = +/* #__PURE__*/ makeSymbol('global-vue-i18n'); +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types +function createI18n(options = {}, VueI18nLegacy) { + // prettier-ignore + const __legacyMode = __VUE_I18N_LEGACY_API__ && isBoolean(options.legacy) + ? options.legacy + : __VUE_I18N_LEGACY_API__; + // prettier-ignore + const __globalInjection = isBoolean(options.globalInjection) + ? options.globalInjection + : true; + // prettier-ignore + const __allowComposition = __VUE_I18N_LEGACY_API__ && __legacyMode + ? !!options.allowComposition + : true; + const __instances = new Map(); + const [globalScope, __global] = createGlobal(options, __legacyMode); + const symbol = /* #__PURE__*/ makeSymbol((process.env.NODE_ENV !== 'production') ? 'vue-i18n' : ''); + if ((process.env.NODE_ENV !== 'production')) { + if (__legacyMode && __allowComposition && !false) { + warn(getWarnMessage(I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION)); + } + } + function __getInstance(component) { + return __instances.get(component) || null; + } + function __setInstance(component, instance) { + __instances.set(component, instance); + } + function __deleteInstance(component) { + __instances.delete(component); + } + { + const i18n = { + // mode + get mode() { + return __VUE_I18N_LEGACY_API__ && __legacyMode + ? 'legacy' + : 'composition'; + }, + // allowComposition + get allowComposition() { + return __allowComposition; + }, + // install plugin + async install(app, ...options) { + if (((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) && + !false) { + app.__VUE_I18N__ = i18n; + } + // setup global provider + app.__VUE_I18N_SYMBOL__ = symbol; + app.provide(app.__VUE_I18N_SYMBOL__, i18n); + // set composer & vuei18n extend hook options from plugin options + if (isPlainObject(options[0])) { + const opts = options[0]; + i18n.__composerExtend = + opts.__composerExtend; + i18n.__vueI18nExtend = + opts.__vueI18nExtend; + } + // global method and properties injection for Composition API + let globalReleaseHandler = null; + if (!__legacyMode && __globalInjection) { + globalReleaseHandler = injectGlobalFields(app, i18n.global); + } + // install built-in components and directive + if (__VUE_I18N_FULL_INSTALL__) { + apply(app, i18n, ...options); + } + // setup mixin for Legacy API + if (__VUE_I18N_LEGACY_API__ && __legacyMode) { + app.mixin(defineMixin(__global, __global.__composer, i18n)); + } + // release global scope + const unmountApp = app.unmount; + app.unmount = () => { + globalReleaseHandler && globalReleaseHandler(); + i18n.dispose(); + unmountApp(); + }; + // setup vue-devtools plugin + if (((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) && !false) { + const ret = await enableDevTools(app, i18n); + if (!ret) { + throw createI18nError(I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN); + } + const emitter = createEmitter(); + if (__legacyMode) { + const _vueI18n = __global; + _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter); + } + else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = __global; + _composer[EnableEmitter] && _composer[EnableEmitter](emitter); + } + emitter.on('*', addTimelineEvent); + } + }, + // global accessor + get global() { + return __global; + }, + dispose() { + globalScope.stop(); + }, + // @internal + __instances, + // @internal + __getInstance, + // @internal + __setInstance, + // @internal + __deleteInstance + }; + return i18n; + } +} +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function useI18n(options = {}) { + const instance = getCurrentInstance(); + if (instance == null) { + throw createI18nError(I18nErrorCodes.MUST_BE_CALL_SETUP_TOP); + } + if (!instance.isCE && + instance.appContext.app != null && + !instance.appContext.app.__VUE_I18N_SYMBOL__) { + throw createI18nError(I18nErrorCodes.NOT_INSTALLED); + } + const i18n = getI18nInstance(instance); + const gl = getGlobalComposer(i18n); + const componentOptions = getComponentOptions(instance); + const scope = getScope(options, componentOptions); + if (__VUE_I18N_LEGACY_API__) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (i18n.mode === 'legacy' && !options.__useComponent) { + if (!i18n.allowComposition) { + throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE); + } + return useI18nForLegacy(instance, scope, gl, options); + } + } + if (scope === 'global') { + adjustI18nResources(gl, options, componentOptions); + return gl; + } + if (scope === 'parent') { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let composer = getComposer(i18n, instance, options.__useComponent); + if (composer == null) { + if ((process.env.NODE_ENV !== 'production')) { + warn(getWarnMessage(I18nWarnCodes.NOT_FOUND_PARENT_SCOPE)); + } + composer = gl; + } + return composer; + } + const i18nInternal = i18n; + let composer = i18nInternal.__getInstance(instance); + if (composer == null) { + const composerOptions = assign({}, options); + if ('__i18n' in componentOptions) { + composerOptions.__i18n = componentOptions.__i18n; + } + if (gl) { + composerOptions.__root = gl; + } + composer = createComposer(composerOptions); + if (i18nInternal.__composerExtend) { + composer[DisposeSymbol] = + i18nInternal.__composerExtend(composer); + } + setupLifeCycle(i18nInternal, instance, composer); + i18nInternal.__setInstance(instance, composer); + } + return composer; +} +/** + * Cast to VueI18n legacy compatible type + * + * @remarks + * This API is provided only with [vue-i18n-bridge](https://vue-i18n.intlify.dev/guide/migration/ways.html#what-is-vue-i18n-bridge). + * + * The purpose of this function is to convert an {@link I18n} instance created with {@link createI18n | createI18n(legacy: true)} into a `vue-i18n@v8.x` compatible instance of `new VueI18n` in a TypeScript environment. + * + * @param i18n - An instance of {@link I18n} + * @returns A i18n instance which is casted to {@link VueI18n} type + * + * @VueI18nTip + * :new: provided by **vue-i18n-bridge only** + * + * @VueI18nGeneral + */ +/* #__NO_SIDE_EFFECTS__ */ +const castToVueI18n = (i18n +// eslint-disable-next-line @typescript-eslint/no-explicit-any +) => { + if (!(__VUE_I18N_BRIDGE__ in i18n)) { + throw createI18nError(I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N); + } + return i18n; +}; +function createGlobal(options, legacyMode, VueI18nLegacy // eslint-disable-line @typescript-eslint/no-explicit-any +) { + const scope = effectScope(); + { + const obj = __VUE_I18N_LEGACY_API__ && legacyMode + ? scope.run(() => createVueI18n(options)) + : scope.run(() => createComposer(options)); + if (obj == null) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + return [scope, obj]; + } +} +function getI18nInstance(instance) { + { + const i18n = inject(!instance.isCE + ? instance.appContext.app.__VUE_I18N_SYMBOL__ + : I18nInjectionKey); + /* istanbul ignore if */ + if (!i18n) { + throw createI18nError(!instance.isCE + ? I18nErrorCodes.UNEXPECTED_ERROR + : I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE); + } + return i18n; + } +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getScope(options, componentOptions) { + // prettier-ignore + return isEmptyObject(options) + ? ('__i18n' in componentOptions) + ? 'local' + : 'global' + : !options.useScope + ? 'local' + : options.useScope; +} +function getGlobalComposer(i18n) { + // prettier-ignore + return i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer + ; +} +function getComposer(i18n, target, useComponent = false) { + let composer = null; + const root = target.root; + let current = getParentComponentInstance(target, useComponent); + while (current != null) { + const i18nInternal = i18n; + if (i18n.mode === 'composition') { + composer = i18nInternal.__getInstance(current); + } + else { + if (__VUE_I18N_LEGACY_API__) { + const vueI18n = i18nInternal.__getInstance(current); + if (vueI18n != null) { + composer = vueI18n + .__composer; + if (useComponent && + composer && + !composer[InejctWithOptionSymbol] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + composer = null; + } + } + } + } + if (composer != null) { + break; + } + if (root === current) { + break; + } + current = current.parent; + } + return composer; +} +function getParentComponentInstance(target, useComponent = false) { + if (target == null) { + return null; + } + { + // if `useComponent: true` will be specified, we get lexical scope owner instance for use-case slots + return !useComponent + ? target.parent + : target.vnode.ctx || target.parent; // eslint-disable-line @typescript-eslint/no-explicit-any + } +} +function setupLifeCycle(i18n, target, composer) { + let emitter = null; + { + onMounted(() => { + // inject composer instance to DOM for intlify-devtools + if (((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) && + !false && + target.vnode.el) { + target.vnode.el.__VUE_I18N__ = composer; + emitter = createEmitter(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = composer; + _composer[EnableEmitter] && _composer[EnableEmitter](emitter); + emitter.on('*', addTimelineEvent); + } + }, target); + onUnmounted(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = composer; + // remove composer instance from DOM for intlify-devtools + if (((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) && + !false && + target.vnode.el && + target.vnode.el.__VUE_I18N__) { + emitter && emitter.off('*', addTimelineEvent); + _composer[DisableEmitter] && _composer[DisableEmitter](); + delete target.vnode.el.__VUE_I18N__; + } + i18n.__deleteInstance(target); + // dispose extended resources + const dispose = _composer[DisposeSymbol]; + if (dispose) { + dispose(); + delete _composer[DisposeSymbol]; + } + }, target); + } +} +function useI18nForLegacy(instance, scope, root, options = {} // eslint-disable-line @typescript-eslint/no-explicit-any +) { + const isLocalScope = scope === 'local'; + const _composer = shallowRef(null); + if (isLocalScope && + instance.proxy && + !(instance.proxy.$options.i18n || instance.proxy.$options.__i18n)) { + throw createI18nError(I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION); + } + const _inheritLocale = isBoolean(options.inheritLocale) + ? options.inheritLocale + : !isString(options.locale); + const _locale = ref( + // prettier-ignore + !isLocalScope || _inheritLocale + ? root.locale.value + : isString(options.locale) + ? options.locale + : DEFAULT_LOCALE); + const _fallbackLocale = ref( + // prettier-ignore + !isLocalScope || _inheritLocale + ? root.fallbackLocale.value + : isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale.value); + const _messages = ref(getLocaleMessages(_locale.value, options)); + // prettier-ignore + const _datetimeFormats = ref(isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : { [_locale.value]: {} }); + // prettier-ignore + const _numberFormats = ref(isPlainObject(options.numberFormats) + ? options.numberFormats + : { [_locale.value]: {} }); + // prettier-ignore + const _missingWarn = isLocalScope + ? root.missingWarn + : isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + // prettier-ignore + const _fallbackWarn = isLocalScope + ? root.fallbackWarn + : isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + // prettier-ignore + const _fallbackRoot = isLocalScope + ? root.fallbackRoot + : isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + // configure fall back to root + const _fallbackFormat = !!options.fallbackFormat; + // runtime missing + const _missing = isFunction(options.missing) ? options.missing : null; + // postTranslation handler + const _postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + // prettier-ignore + const _warnHtmlMessage = isLocalScope + ? root.warnHtmlMessage + : isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const _escapeParameter = !!options.escapeParameter; + // prettier-ignore + const _modifiers = isLocalScope + ? root.modifiers + : isPlainObject(options.modifiers) + ? options.modifiers + : {}; + // pluralRules + const _pluralRules = options.pluralRules || (isLocalScope && root.pluralRules); + // track reactivity + function trackReactivityValues() { + return [ + _locale.value, + _fallbackLocale.value, + _messages.value, + _datetimeFormats.value, + _numberFormats.value + ]; + } + // locale + const locale = computed({ + get: () => { + return _composer.value ? _composer.value.locale.value : _locale.value; + }, + set: val => { + if (_composer.value) { + _composer.value.locale.value = val; + } + _locale.value = val; + } + }); + // fallbackLocale + const fallbackLocale = computed({ + get: () => { + return _composer.value + ? _composer.value.fallbackLocale.value + : _fallbackLocale.value; + }, + set: val => { + if (_composer.value) { + _composer.value.fallbackLocale.value = val; + } + _fallbackLocale.value = val; + } + }); + // messages + const messages = computed(() => { + if (_composer.value) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return _composer.value.messages.value; + } + else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return _messages.value; + } + }); + const datetimeFormats = computed(() => _datetimeFormats.value); + const numberFormats = computed(() => _numberFormats.value); + function getPostTranslationHandler() { + return _composer.value + ? _composer.value.getPostTranslationHandler() + : _postTranslation; + } + function setPostTranslationHandler(handler) { + if (_composer.value) { + _composer.value.setPostTranslationHandler(handler); + } + } + function getMissingHandler() { + return _composer.value ? _composer.value.getMissingHandler() : _missing; + } + function setMissingHandler(handler) { + if (_composer.value) { + _composer.value.setMissingHandler(handler); + } + } + function warpWithDeps(fn) { + trackReactivityValues(); + return fn(); + } + function t(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.t, null, [...args])) + : warpWithDeps(() => ''); + } + function rt(...args) { + return _composer.value + ? Reflect.apply(_composer.value.rt, null, [...args]) + : ''; + } + function d(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.d, null, [...args])) + : warpWithDeps(() => ''); + } + function n(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.n, null, [...args])) + : warpWithDeps(() => ''); + } + function tm(key) { + return _composer.value ? _composer.value.tm(key) : {}; + } + function te(key, locale) { + return _composer.value ? _composer.value.te(key, locale) : false; + } + function getLocaleMessage(locale) { + return _composer.value ? _composer.value.getLocaleMessage(locale) : {}; + } + function setLocaleMessage(locale, message) { + if (_composer.value) { + _composer.value.setLocaleMessage(locale, message); + _messages.value[locale] = message; + } + } + function mergeLocaleMessage(locale, message) { + if (_composer.value) { + _composer.value.mergeLocaleMessage(locale, message); + } + } + function getDateTimeFormat(locale) { + return _composer.value ? _composer.value.getDateTimeFormat(locale) : {}; + } + function setDateTimeFormat(locale, format) { + if (_composer.value) { + _composer.value.setDateTimeFormat(locale, format); + _datetimeFormats.value[locale] = format; + } + } + function mergeDateTimeFormat(locale, format) { + if (_composer.value) { + _composer.value.mergeDateTimeFormat(locale, format); + } + } + function getNumberFormat(locale) { + return _composer.value ? _composer.value.getNumberFormat(locale) : {}; + } + function setNumberFormat(locale, format) { + if (_composer.value) { + _composer.value.setNumberFormat(locale, format); + _numberFormats.value[locale] = format; + } + } + function mergeNumberFormat(locale, format) { + if (_composer.value) { + _composer.value.mergeNumberFormat(locale, format); + } + } + const wrapper = { + get id() { + return _composer.value ? _composer.value.id : -1; + }, + locale, + fallbackLocale, + messages, + datetimeFormats, + numberFormats, + get inheritLocale() { + return _composer.value ? _composer.value.inheritLocale : _inheritLocale; + }, + set inheritLocale(val) { + if (_composer.value) { + _composer.value.inheritLocale = val; + } + }, + get availableLocales() { + return _composer.value + ? _composer.value.availableLocales + : Object.keys(_messages.value); + }, + get modifiers() { + return (_composer.value ? _composer.value.modifiers : _modifiers); + }, + get pluralRules() { + return (_composer.value ? _composer.value.pluralRules : _pluralRules); + }, + get isGlobal() { + return _composer.value ? _composer.value.isGlobal : false; + }, + get missingWarn() { + return _composer.value ? _composer.value.missingWarn : _missingWarn; + }, + set missingWarn(val) { + if (_composer.value) { + _composer.value.missingWarn = val; + } + }, + get fallbackWarn() { + return _composer.value ? _composer.value.fallbackWarn : _fallbackWarn; + }, + set fallbackWarn(val) { + if (_composer.value) { + _composer.value.missingWarn = val; + } + }, + get fallbackRoot() { + return _composer.value ? _composer.value.fallbackRoot : _fallbackRoot; + }, + set fallbackRoot(val) { + if (_composer.value) { + _composer.value.fallbackRoot = val; + } + }, + get fallbackFormat() { + return _composer.value ? _composer.value.fallbackFormat : _fallbackFormat; + }, + set fallbackFormat(val) { + if (_composer.value) { + _composer.value.fallbackFormat = val; + } + }, + get warnHtmlMessage() { + return _composer.value + ? _composer.value.warnHtmlMessage + : _warnHtmlMessage; + }, + set warnHtmlMessage(val) { + if (_composer.value) { + _composer.value.warnHtmlMessage = val; + } + }, + get escapeParameter() { + return _composer.value + ? _composer.value.escapeParameter + : _escapeParameter; + }, + set escapeParameter(val) { + if (_composer.value) { + _composer.value.escapeParameter = val; + } + }, + t, + getPostTranslationHandler, + setPostTranslationHandler, + getMissingHandler, + setMissingHandler, + rt, + d, + n, + tm, + te, + getLocaleMessage, + setLocaleMessage, + mergeLocaleMessage, + getDateTimeFormat, + setDateTimeFormat, + mergeDateTimeFormat, + getNumberFormat, + setNumberFormat, + mergeNumberFormat + }; + function sync(composer) { + composer.locale.value = _locale.value; + composer.fallbackLocale.value = _fallbackLocale.value; + Object.keys(_messages.value).forEach(locale => { + composer.mergeLocaleMessage(locale, _messages.value[locale]); + }); + Object.keys(_datetimeFormats.value).forEach(locale => { + composer.mergeDateTimeFormat(locale, _datetimeFormats.value[locale]); + }); + Object.keys(_numberFormats.value).forEach(locale => { + composer.mergeNumberFormat(locale, _numberFormats.value[locale]); + }); + composer.escapeParameter = _escapeParameter; + composer.fallbackFormat = _fallbackFormat; + composer.fallbackRoot = _fallbackRoot; + composer.fallbackWarn = _fallbackWarn; + composer.missingWarn = _missingWarn; + composer.warnHtmlMessage = _warnHtmlMessage; + } + onBeforeMount(() => { + if (instance.proxy == null || instance.proxy.$i18n == null) { + throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const composer = (_composer.value = instance.proxy.$i18n + .__composer); + if (scope === 'global') { + _locale.value = composer.locale.value; + _fallbackLocale.value = composer.fallbackLocale.value; + _messages.value = composer.messages.value; + _datetimeFormats.value = composer.datetimeFormats.value; + _numberFormats.value = composer.numberFormats.value; + } + else if (isLocalScope) { + sync(composer); + } + }); + return wrapper; +} +const globalExportProps = [ + 'locale', + 'fallbackLocale', + 'availableLocales' +]; +const globalExportMethods = ['t', 'rt', 'd', 'n', 'tm', 'te'] + ; +function injectGlobalFields(app, composer) { + const i18n = Object.create(null); + globalExportProps.forEach(prop => { + const desc = Object.getOwnPropertyDescriptor(composer, prop); + if (!desc) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const wrap = isRef(desc.value) // check computed props + ? { + get() { + return desc.value.value; + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + set(val) { + desc.value.value = val; + } + } + : { + get() { + return desc.get && desc.get(); + } + }; + Object.defineProperty(i18n, prop, wrap); + }); + app.config.globalProperties.$i18n = i18n; + globalExportMethods.forEach(method => { + const desc = Object.getOwnPropertyDescriptor(composer, method); + if (!desc || !desc.value) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + Object.defineProperty(app.config.globalProperties, `$${method}`, desc); + }); + const dispose = () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete app.config.globalProperties.$i18n; + globalExportMethods.forEach(method => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete app.config.globalProperties[`$${method}`]; + }); + }; + return dispose; +} + +{ + initFeatureFlags(); +} +// register message compiler at vue-i18n +if (__INTLIFY_JIT_COMPILATION__) { + registerMessageCompiler(compile); +} +else { + registerMessageCompiler(compileToFunction); +} +// register message resolver at vue-i18n +registerMessageResolver(resolveValue); +// register fallback locale at vue-i18n +registerLocaleFallbacker(fallbackWithLocaleChain); +// NOTE: experimental !! +if ((process.env.NODE_ENV !== 'production') || __INTLIFY_PROD_DEVTOOLS__) { + const target = getGlobalThis(); + target.__INTLIFY__ = true; + setDevToolsHook(target.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__); +} +if ((process.env.NODE_ENV !== 'production')) ; + +export { DatetimeFormat, I18nD, I18nInjectionKey, I18nN, I18nT, NumberFormat, Translation, VERSION, castToVueI18n, createI18n, useI18n, vTDirective }; diff --git a/node_modules/vue-i18n/dist/vue-i18n.node.mjs b/node_modules/vue-i18n/dist/vue-i18n.node.mjs new file mode 100644 index 0000000..0459461 --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.node.mjs @@ -0,0 +1,2 @@ +global.__VUE_PROD_DEVTOOLS__ = false; +export * from '../dist/vue-i18n.mjs' \ No newline at end of file diff --git a/node_modules/vue-i18n/dist/vue-i18n.prod.cjs b/node_modules/vue-i18n/dist/vue-i18n.prod.cjs new file mode 100644 index 0000000..68e555e --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.prod.cjs @@ -0,0 +1,2362 @@ +/*! + * vue-i18n v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +'use strict'; + +var coreBase = require('@intlify/core-base'); +var vue = require('vue'); +var shared = require('@intlify/shared'); + +/** + * Vue I18n Version + * + * @remarks + * Semver format. Same format as the package.json `version` field. + * + * @VueI18nGeneral + */ +const VERSION = '9.14.5'; + +const code = coreBase.CoreErrorCodes.__EXTEND_POINT__; +const inc = shared.incrementer(code); +const I18nErrorCodes = { + // composer module errors + UNEXPECTED_RETURN_TYPE: code, // 24 + // legacy module errors + INVALID_ARGUMENT: inc(), // 25 + // i18n module errors + MUST_BE_CALL_SETUP_TOP: inc(), // 26 + NOT_INSTALLED: inc(), // 27 + NOT_AVAILABLE_IN_LEGACY_MODE: inc(), // 28 + // directive module errors + REQUIRED_VALUE: inc(), // 29 + INVALID_VALUE: inc(), // 30 + // vue-devtools errors + CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN: inc(), // 31 + NOT_INSTALLED_WITH_PROVIDE: inc(), // 32 + // unexpected error + UNEXPECTED_ERROR: inc(), // 33 + // not compatible legacy vue-i18n constructor + NOT_COMPATIBLE_LEGACY_VUE_I18N: inc(), // 34 + // bridge support vue 2.x only + BRIDGE_SUPPORT_VUE_2_ONLY: inc(), // 35 + // need to define `i18n` option in `allowComposition: true` and `useScope: 'local' at `useI18n`` + MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION: inc(), // 36 + // Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly + NOT_AVAILABLE_COMPOSITION_IN_LEGACY: inc(), // 37 + // for enhancement + __EXTEND_POINT__: inc() // 38 +}; +function createI18nError(code, ...args) { + return coreBase.createCompileError(code, null, undefined); +} + +const TranslateVNodeSymbol = +/* #__PURE__*/ shared.makeSymbol('__translateVNode'); +const DatetimePartsSymbol = /* #__PURE__*/ shared.makeSymbol('__datetimeParts'); +const NumberPartsSymbol = /* #__PURE__*/ shared.makeSymbol('__numberParts'); +const SetPluralRulesSymbol = shared.makeSymbol('__setPluralRules'); +shared.makeSymbol('__intlifyMeta'); +const InejctWithOptionSymbol = +/* #__PURE__*/ shared.makeSymbol('__injectWithOption'); +const DisposeSymbol = /* #__PURE__*/ shared.makeSymbol('__dispose'); +const __VUE_I18N_BRIDGE__ = '__VUE_I18N_BRIDGE__'; + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Transform flat json in obj to normal json in obj + */ +function handleFlatJson(obj) { + // check obj + if (!shared.isObject(obj)) { + return obj; + } + if (coreBase.isMessageAST(obj)) { + return obj; + } + for (const key in obj) { + // check key + if (!shared.hasOwn(obj, key)) { + continue; + } + // handle for normal json + if (!key.includes('.')) { + // recursive process value if value is also a object + if (shared.isObject(obj[key])) { + handleFlatJson(obj[key]); + } + } + // handle for flat json, transform to normal json + else { + // go to the last object + const subKeys = key.split('.'); + const lastIndex = subKeys.length - 1; + let currentObj = obj; + let hasStringValue = false; + for (let i = 0; i < lastIndex; i++) { + if (subKeys[i] === '__proto__') { + throw new Error(`unsafe key: ${subKeys[i]}`); + } + if (!(subKeys[i] in currentObj)) { + currentObj[subKeys[i]] = shared.create(); + } + if (!shared.isObject(currentObj[subKeys[i]])) { + hasStringValue = true; + break; + } + currentObj = currentObj[subKeys[i]]; + } + // update last object value, delete old property + if (!hasStringValue) { + if (!coreBase.isMessageAST(currentObj)) { + currentObj[subKeys[lastIndex]] = obj[key]; + delete obj[key]; + } + else { + /** + * NOTE: + * if the last object is a message AST and subKeys[lastIndex] has message AST prop key, ignore to copy and key deletion + */ + if (!coreBase.AST_NODE_PROPS_KEYS.includes(subKeys[lastIndex])) { + delete obj[key]; + } + } + } + // recursive process value if value is also a object + if (!coreBase.isMessageAST(currentObj)) { + const target = currentObj[subKeys[lastIndex]]; + if (shared.isObject(target)) { + handleFlatJson(target); + } + } + } + } + return obj; +} +function getLocaleMessages(locale, options) { + const { messages, __i18n, messageResolver, flatJson } = options; + // prettier-ignore + const ret = (shared.isPlainObject(messages) + ? messages + : shared.isArray(__i18n) + ? shared.create() + : { [locale]: shared.create() }); + // merge locale messages of i18n custom block + if (shared.isArray(__i18n)) { + __i18n.forEach(custom => { + if ('locale' in custom && 'resource' in custom) { + const { locale, resource } = custom; + if (locale) { + ret[locale] = ret[locale] || shared.create(); + shared.deepCopy(resource, ret[locale]); + } + else { + shared.deepCopy(resource, ret); + } + } + else { + shared.isString(custom) && shared.deepCopy(JSON.parse(custom), ret); + } + }); + } + // handle messages for flat json + if (messageResolver == null && flatJson) { + for (const key in ret) { + if (shared.hasOwn(ret, key)) { + handleFlatJson(ret[key]); + } + } + } + return ret; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getComponentOptions(instance) { + return instance.type ; +} +function adjustI18nResources(gl, options, componentOptions // eslint-disable-line @typescript-eslint/no-explicit-any +) { + let messages = shared.isObject(options.messages) + ? options.messages + : shared.create(); + if ('__i18nGlobal' in componentOptions) { + messages = getLocaleMessages(gl.locale.value, { + messages, + __i18n: componentOptions.__i18nGlobal + }); + } + // merge locale messages + const locales = Object.keys(messages); + if (locales.length) { + locales.forEach(locale => { + gl.mergeLocaleMessage(locale, messages[locale]); + }); + } + { + // merge datetime formats + if (shared.isObject(options.datetimeFormats)) { + const locales = Object.keys(options.datetimeFormats); + if (locales.length) { + locales.forEach(locale => { + gl.mergeDateTimeFormat(locale, options.datetimeFormats[locale]); + }); + } + } + // merge number formats + if (shared.isObject(options.numberFormats)) { + const locales = Object.keys(options.numberFormats); + if (locales.length) { + locales.forEach(locale => { + gl.mergeNumberFormat(locale, options.numberFormats[locale]); + }); + } + } + } +} +function createTextNode(key) { + return vue.createVNode(vue.Text, null, key, 0) + ; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +/* eslint-disable @typescript-eslint/no-explicit-any */ +// extend VNode interface +const DEVTOOLS_META = '__INTLIFY_META__'; +const NOOP_RETURN_ARRAY = () => []; +const NOOP_RETURN_FALSE = () => false; +let composerID = 0; +function defineCoreMissingHandler(missing) { + return ((ctx, locale, key, type) => { + return missing(locale, key, vue.getCurrentInstance() || undefined, type); + }); +} +// for Intlify DevTools +/* #__NO_SIDE_EFFECTS__ */ +const getMetaInfo = () => { + const instance = vue.getCurrentInstance(); + let meta = null; // eslint-disable-line @typescript-eslint/no-explicit-any + return instance && (meta = getComponentOptions(instance)[DEVTOOLS_META]) + ? { [DEVTOOLS_META]: meta } // eslint-disable-line @typescript-eslint/no-explicit-any + : null; +}; +/** + * Create composer interface factory + * + * @internal + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function createComposer(options = {}, VueI18nLegacy) { + const { __root, __injectWithOption } = options; + const _isGlobal = __root === undefined; + const flatJson = options.flatJson; + const _ref = shared.inBrowser ? vue.ref : vue.shallowRef; + const translateExistCompatible = !!options.translateExistCompatible; + let _inheritLocale = shared.isBoolean(options.inheritLocale) + ? options.inheritLocale + : true; + const _locale = _ref( + // prettier-ignore + __root && _inheritLocale + ? __root.locale.value + : shared.isString(options.locale) + ? options.locale + : coreBase.DEFAULT_LOCALE); + const _fallbackLocale = _ref( + // prettier-ignore + __root && _inheritLocale + ? __root.fallbackLocale.value + : shared.isString(options.fallbackLocale) || + shared.isArray(options.fallbackLocale) || + shared.isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale.value); + const _messages = _ref(getLocaleMessages(_locale.value, options)); + // prettier-ignore + const _datetimeFormats = _ref(shared.isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : { [_locale.value]: {} }) + ; + // prettier-ignore + const _numberFormats = _ref(shared.isPlainObject(options.numberFormats) + ? options.numberFormats + : { [_locale.value]: {} }) + ; + // warning suppress options + // prettier-ignore + let _missingWarn = __root + ? __root.missingWarn + : shared.isBoolean(options.missingWarn) || shared.isRegExp(options.missingWarn) + ? options.missingWarn + : true; + // prettier-ignore + let _fallbackWarn = __root + ? __root.fallbackWarn + : shared.isBoolean(options.fallbackWarn) || shared.isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + // prettier-ignore + let _fallbackRoot = __root + ? __root.fallbackRoot + : shared.isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + // configure fall back to root + let _fallbackFormat = !!options.fallbackFormat; + // runtime missing + let _missing = shared.isFunction(options.missing) ? options.missing : null; + let _runtimeMissing = shared.isFunction(options.missing) + ? defineCoreMissingHandler(options.missing) + : null; + // postTranslation handler + let _postTranslation = shared.isFunction(options.postTranslation) + ? options.postTranslation + : null; + // prettier-ignore + let _warnHtmlMessage = __root + ? __root.warnHtmlMessage + : shared.isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + let _escapeParameter = !!options.escapeParameter; + // custom linked modifiers + // prettier-ignore + const _modifiers = __root + ? __root.modifiers + : shared.isPlainObject(options.modifiers) + ? options.modifiers + : {}; + // pluralRules + let _pluralRules = options.pluralRules || (__root && __root.pluralRules); + // runtime context + // eslint-disable-next-line prefer-const + let _context; + const getCoreContext = () => { + _isGlobal && coreBase.setFallbackContext(null); + const ctxOptions = { + version: VERSION, + locale: _locale.value, + fallbackLocale: _fallbackLocale.value, + messages: _messages.value, + modifiers: _modifiers, + pluralRules: _pluralRules, + missing: _runtimeMissing === null ? undefined : _runtimeMissing, + missingWarn: _missingWarn, + fallbackWarn: _fallbackWarn, + fallbackFormat: _fallbackFormat, + unresolving: true, + postTranslation: _postTranslation === null ? undefined : _postTranslation, + warnHtmlMessage: _warnHtmlMessage, + escapeParameter: _escapeParameter, + messageResolver: options.messageResolver, + messageCompiler: options.messageCompiler, + __meta: { framework: 'vue' } + }; + { + ctxOptions.datetimeFormats = _datetimeFormats.value; + ctxOptions.numberFormats = _numberFormats.value; + ctxOptions.__datetimeFormatters = shared.isPlainObject(_context) + ? _context.__datetimeFormatters + : undefined; + ctxOptions.__numberFormatters = shared.isPlainObject(_context) + ? _context.__numberFormatters + : undefined; + } + const ctx = coreBase.createCoreContext(ctxOptions); + _isGlobal && coreBase.setFallbackContext(ctx); + return ctx; + }; + _context = getCoreContext(); + coreBase.updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + // track reactivity + function trackReactivityValues() { + return [ + _locale.value, + _fallbackLocale.value, + _messages.value, + _datetimeFormats.value, + _numberFormats.value + ] + ; + } + // locale + const locale = vue.computed({ + get: () => _locale.value, + set: val => { + _locale.value = val; + _context.locale = _locale.value; + } + }); + // fallbackLocale + const fallbackLocale = vue.computed({ + get: () => _fallbackLocale.value, + set: val => { + _fallbackLocale.value = val; + _context.fallbackLocale = _fallbackLocale.value; + coreBase.updateFallbackLocale(_context, _locale.value, val); + } + }); + // messages + const messages = vue.computed(() => _messages.value); + // datetimeFormats + const datetimeFormats = /* #__PURE__*/ vue.computed(() => _datetimeFormats.value); + // numberFormats + const numberFormats = /* #__PURE__*/ vue.computed(() => _numberFormats.value); + // getPostTranslationHandler + function getPostTranslationHandler() { + return shared.isFunction(_postTranslation) ? _postTranslation : null; + } + // setPostTranslationHandler + function setPostTranslationHandler(handler) { + _postTranslation = handler; + _context.postTranslation = handler; + } + // getMissingHandler + function getMissingHandler() { + return _missing; + } + // setMissingHandler + function setMissingHandler(handler) { + if (handler !== null) { + _runtimeMissing = defineCoreMissingHandler(handler); + } + _missing = handler; + _context.missing = _runtimeMissing; + } + const wrapWithDeps = (fn, argumentParser, warnType, fallbackSuccess, fallbackFail, successCondition) => { + trackReactivityValues(); // track reactive dependency + // NOTE: experimental !! + let ret; + try { + if (false || false) ; + if (!_isGlobal) { + _context.fallbackContext = __root + ? coreBase.getFallbackContext() + : undefined; + } + ret = fn(_context); + } + finally { + if (!_isGlobal) { + _context.fallbackContext = undefined; + } + } + if ((warnType !== 'translate exists' && // for not `te` (e.g `t`) + shared.isNumber(ret) && + ret === coreBase.NOT_REOSLVED) || + (warnType === 'translate exists' && !ret) // for `te` + ) { + const [key, arg2] = argumentParser(); + return __root && _fallbackRoot + ? fallbackSuccess(__root) + : fallbackFail(key); + } + else if (successCondition(ret)) { + return ret; + } + else { + /* istanbul ignore next */ + throw createI18nError(I18nErrorCodes.UNEXPECTED_RETURN_TYPE); + } + }; + // t + function t(...args) { + return wrapWithDeps(context => Reflect.apply(coreBase.translate, null, [context, ...args]), () => coreBase.parseTranslateArgs(...args), 'translate', root => Reflect.apply(root.t, root, [...args]), key => key, val => shared.isString(val)); + } + // rt + function rt(...args) { + const [arg1, arg2, arg3] = args; + if (arg3 && !shared.isObject(arg3)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + return t(...[arg1, arg2, shared.assign({ resolvedMessage: true }, arg3 || {})]); + } + // d + function d(...args) { + return wrapWithDeps(context => Reflect.apply(coreBase.datetime, null, [context, ...args]), () => coreBase.parseDateTimeArgs(...args), 'datetime format', root => Reflect.apply(root.d, root, [...args]), () => coreBase.MISSING_RESOLVE_VALUE, val => shared.isString(val)); + } + // n + function n(...args) { + return wrapWithDeps(context => Reflect.apply(coreBase.number, null, [context, ...args]), () => coreBase.parseNumberArgs(...args), 'number format', root => Reflect.apply(root.n, root, [...args]), () => coreBase.MISSING_RESOLVE_VALUE, val => shared.isString(val)); + } + // for custom processor + function normalize(values) { + return values.map(val => shared.isString(val) || shared.isNumber(val) || shared.isBoolean(val) + ? createTextNode(String(val)) + : val); + } + const interpolate = (val) => val; + const processor = { + normalize, + interpolate, + type: 'vnode' + }; + // translateVNode, using for `i18n-t` component + function translateVNode(...args) { + return wrapWithDeps(context => { + let ret; + const _context = context; + try { + _context.processor = processor; + ret = Reflect.apply(coreBase.translate, null, [_context, ...args]); + } + finally { + _context.processor = null; + } + return ret; + }, () => coreBase.parseTranslateArgs(...args), 'translate', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[TranslateVNodeSymbol](...args), key => [createTextNode(key)], val => shared.isArray(val)); + } + // numberParts, using for `i18n-n` component + function numberParts(...args) { + return wrapWithDeps(context => Reflect.apply(coreBase.number, null, [context, ...args]), () => coreBase.parseNumberArgs(...args), 'number format', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[NumberPartsSymbol](...args), NOOP_RETURN_ARRAY, val => shared.isString(val) || shared.isArray(val)); + } + // datetimeParts, using for `i18n-d` component + function datetimeParts(...args) { + return wrapWithDeps(context => Reflect.apply(coreBase.datetime, null, [context, ...args]), () => coreBase.parseDateTimeArgs(...args), 'datetime format', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[DatetimePartsSymbol](...args), NOOP_RETURN_ARRAY, val => shared.isString(val) || shared.isArray(val)); + } + function setPluralRules(rules) { + _pluralRules = rules; + _context.pluralRules = _pluralRules; + } + // te + function te(key, locale) { + return wrapWithDeps(() => { + if (!key) { + return false; + } + const targetLocale = shared.isString(locale) ? locale : _locale.value; + const message = getLocaleMessage(targetLocale); + const resolved = _context.messageResolver(message, key); + return !translateExistCompatible + ? coreBase.isMessageAST(resolved) || + coreBase.isMessageFunction(resolved) || + shared.isString(resolved) + : resolved != null; + }, () => [key], 'translate exists', root => { + return Reflect.apply(root.te, root, [key, locale]); + }, NOOP_RETURN_FALSE, val => shared.isBoolean(val)); + } + function resolveMessages(key) { + let messages = null; + const locales = coreBase.fallbackWithLocaleChain(_context, _fallbackLocale.value, _locale.value); + for (let i = 0; i < locales.length; i++) { + const targetLocaleMessages = _messages.value[locales[i]] || {}; + const messageValue = _context.messageResolver(targetLocaleMessages, key); + if (messageValue != null) { + messages = messageValue; + break; + } + } + return messages; + } + // tm + function tm(key) { + const messages = resolveMessages(key); + // prettier-ignore + return messages != null + ? messages + : __root + ? __root.tm(key) || {} + : {}; + } + // getLocaleMessage + function getLocaleMessage(locale) { + return (_messages.value[locale] || {}); + } + // setLocaleMessage + function setLocaleMessage(locale, message) { + if (flatJson) { + const _message = { [locale]: message }; + for (const key in _message) { + if (shared.hasOwn(_message, key)) { + handleFlatJson(_message[key]); + } + } + message = _message[locale]; + } + _messages.value[locale] = message; + _context.messages = _messages.value; + } + // mergeLocaleMessage + function mergeLocaleMessage(locale, message) { + _messages.value[locale] = _messages.value[locale] || {}; + const _message = { [locale]: message }; + if (flatJson) { + for (const key in _message) { + if (shared.hasOwn(_message, key)) { + handleFlatJson(_message[key]); + } + } + } + message = _message[locale]; + shared.deepCopy(message, _messages.value[locale]); + _context.messages = _messages.value; + } + // getDateTimeFormat + function getDateTimeFormat(locale) { + return _datetimeFormats.value[locale] || {}; + } + // setDateTimeFormat + function setDateTimeFormat(locale, format) { + _datetimeFormats.value[locale] = format; + _context.datetimeFormats = _datetimeFormats.value; + coreBase.clearDateTimeFormat(_context, locale, format); + } + // mergeDateTimeFormat + function mergeDateTimeFormat(locale, format) { + _datetimeFormats.value[locale] = shared.assign(_datetimeFormats.value[locale] || {}, format); + _context.datetimeFormats = _datetimeFormats.value; + coreBase.clearDateTimeFormat(_context, locale, format); + } + // getNumberFormat + function getNumberFormat(locale) { + return _numberFormats.value[locale] || {}; + } + // setNumberFormat + function setNumberFormat(locale, format) { + _numberFormats.value[locale] = format; + _context.numberFormats = _numberFormats.value; + coreBase.clearNumberFormat(_context, locale, format); + } + // mergeNumberFormat + function mergeNumberFormat(locale, format) { + _numberFormats.value[locale] = shared.assign(_numberFormats.value[locale] || {}, format); + _context.numberFormats = _numberFormats.value; + coreBase.clearNumberFormat(_context, locale, format); + } + // for debug + composerID++; + // watch root locale & fallbackLocale + if (__root && shared.inBrowser) { + vue.watch(__root.locale, (val) => { + if (_inheritLocale) { + _locale.value = val; + _context.locale = val; + coreBase.updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }); + vue.watch(__root.fallbackLocale, (val) => { + if (_inheritLocale) { + _fallbackLocale.value = val; + _context.fallbackLocale = val; + coreBase.updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }); + } + // define basic composition API! + const composer = { + id: composerID, + locale, + fallbackLocale, + get inheritLocale() { + return _inheritLocale; + }, + set inheritLocale(val) { + _inheritLocale = val; + if (val && __root) { + _locale.value = __root.locale.value; + _fallbackLocale.value = __root.fallbackLocale.value; + coreBase.updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }, + get availableLocales() { + return Object.keys(_messages.value).sort(); + }, + messages, + get modifiers() { + return _modifiers; + }, + get pluralRules() { + return _pluralRules || {}; + }, + get isGlobal() { + return _isGlobal; + }, + get missingWarn() { + return _missingWarn; + }, + set missingWarn(val) { + _missingWarn = val; + _context.missingWarn = _missingWarn; + }, + get fallbackWarn() { + return _fallbackWarn; + }, + set fallbackWarn(val) { + _fallbackWarn = val; + _context.fallbackWarn = _fallbackWarn; + }, + get fallbackRoot() { + return _fallbackRoot; + }, + set fallbackRoot(val) { + _fallbackRoot = val; + }, + get fallbackFormat() { + return _fallbackFormat; + }, + set fallbackFormat(val) { + _fallbackFormat = val; + _context.fallbackFormat = _fallbackFormat; + }, + get warnHtmlMessage() { + return _warnHtmlMessage; + }, + set warnHtmlMessage(val) { + _warnHtmlMessage = val; + _context.warnHtmlMessage = val; + }, + get escapeParameter() { + return _escapeParameter; + }, + set escapeParameter(val) { + _escapeParameter = val; + _context.escapeParameter = val; + }, + t, + getLocaleMessage, + setLocaleMessage, + mergeLocaleMessage, + getPostTranslationHandler, + setPostTranslationHandler, + getMissingHandler, + setMissingHandler, + [SetPluralRulesSymbol]: setPluralRules + }; + { + composer.datetimeFormats = datetimeFormats; + composer.numberFormats = numberFormats; + composer.rt = rt; + composer.te = te; + composer.tm = tm; + composer.d = d; + composer.n = n; + composer.getDateTimeFormat = getDateTimeFormat; + composer.setDateTimeFormat = setDateTimeFormat; + composer.mergeDateTimeFormat = mergeDateTimeFormat; + composer.getNumberFormat = getNumberFormat; + composer.setNumberFormat = setNumberFormat; + composer.mergeNumberFormat = mergeNumberFormat; + composer[InejctWithOptionSymbol] = __injectWithOption; + composer[TranslateVNodeSymbol] = translateVNode; + composer[DatetimePartsSymbol] = datetimeParts; + composer[NumberPartsSymbol] = numberParts; + } + return composer; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Convert to I18n Composer Options from VueI18n Options + * + * @internal + */ +function convertComposerOptions(options) { + const locale = shared.isString(options.locale) ? options.locale : coreBase.DEFAULT_LOCALE; + const fallbackLocale = shared.isString(options.fallbackLocale) || + shared.isArray(options.fallbackLocale) || + shared.isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : locale; + const missing = shared.isFunction(options.missing) ? options.missing : undefined; + const missingWarn = shared.isBoolean(options.silentTranslationWarn) || + shared.isRegExp(options.silentTranslationWarn) + ? !options.silentTranslationWarn + : true; + const fallbackWarn = shared.isBoolean(options.silentFallbackWarn) || + shared.isRegExp(options.silentFallbackWarn) + ? !options.silentFallbackWarn + : true; + const fallbackRoot = shared.isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + const fallbackFormat = !!options.formatFallbackMessages; + const modifiers = shared.isPlainObject(options.modifiers) ? options.modifiers : {}; + const pluralizationRules = options.pluralizationRules; + const postTranslation = shared.isFunction(options.postTranslation) + ? options.postTranslation + : undefined; + const warnHtmlMessage = shared.isString(options.warnHtmlInMessage) + ? options.warnHtmlInMessage !== 'off' + : true; + const escapeParameter = !!options.escapeParameterHtml; + const inheritLocale = shared.isBoolean(options.sync) ? options.sync : true; + let messages = options.messages; + if (shared.isPlainObject(options.sharedMessages)) { + const sharedMessages = options.sharedMessages; + const locales = Object.keys(sharedMessages); + messages = locales.reduce((messages, locale) => { + const message = messages[locale] || (messages[locale] = {}); + shared.assign(message, sharedMessages[locale]); + return messages; + }, (messages || {})); + } + const { __i18n, __root, __injectWithOption } = options; + const datetimeFormats = options.datetimeFormats; + const numberFormats = options.numberFormats; + const flatJson = options.flatJson; + const translateExistCompatible = options + .translateExistCompatible; + return { + locale, + fallbackLocale, + messages, + flatJson, + datetimeFormats, + numberFormats, + missing, + missingWarn, + fallbackWarn, + fallbackRoot, + fallbackFormat, + modifiers, + pluralRules: pluralizationRules, + postTranslation, + warnHtmlMessage, + escapeParameter, + messageResolver: options.messageResolver, + inheritLocale, + translateExistCompatible, + __i18n, + __root, + __injectWithOption + }; +} +/** + * create VueI18n interface factory + * + * @internal + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function createVueI18n(options = {}, VueI18nLegacy) { + { + const composer = createComposer(convertComposerOptions(options)); + const { __extender } = options; + // defines VueI18n + const vueI18n = { + // id + id: composer.id, + // locale + get locale() { + return composer.locale.value; + }, + set locale(val) { + composer.locale.value = val; + }, + // fallbackLocale + get fallbackLocale() { + return composer.fallbackLocale.value; + }, + set fallbackLocale(val) { + composer.fallbackLocale.value = val; + }, + // messages + get messages() { + return composer.messages.value; + }, + // datetimeFormats + get datetimeFormats() { + return composer.datetimeFormats.value; + }, + // numberFormats + get numberFormats() { + return composer.numberFormats.value; + }, + // availableLocales + get availableLocales() { + return composer.availableLocales; + }, + // formatter + get formatter() { + // dummy + return { + interpolate() { + return []; + } + }; + }, + set formatter(val) { + }, + // missing + get missing() { + return composer.getMissingHandler(); + }, + set missing(handler) { + composer.setMissingHandler(handler); + }, + // silentTranslationWarn + get silentTranslationWarn() { + return shared.isBoolean(composer.missingWarn) + ? !composer.missingWarn + : composer.missingWarn; + }, + set silentTranslationWarn(val) { + composer.missingWarn = shared.isBoolean(val) ? !val : val; + }, + // silentFallbackWarn + get silentFallbackWarn() { + return shared.isBoolean(composer.fallbackWarn) + ? !composer.fallbackWarn + : composer.fallbackWarn; + }, + set silentFallbackWarn(val) { + composer.fallbackWarn = shared.isBoolean(val) ? !val : val; + }, + // modifiers + get modifiers() { + return composer.modifiers; + }, + // formatFallbackMessages + get formatFallbackMessages() { + return composer.fallbackFormat; + }, + set formatFallbackMessages(val) { + composer.fallbackFormat = val; + }, + // postTranslation + get postTranslation() { + return composer.getPostTranslationHandler(); + }, + set postTranslation(handler) { + composer.setPostTranslationHandler(handler); + }, + // sync + get sync() { + return composer.inheritLocale; + }, + set sync(val) { + composer.inheritLocale = val; + }, + // warnInHtmlMessage + get warnHtmlInMessage() { + return composer.warnHtmlMessage ? 'warn' : 'off'; + }, + set warnHtmlInMessage(val) { + composer.warnHtmlMessage = val !== 'off'; + }, + // escapeParameterHtml + get escapeParameterHtml() { + return composer.escapeParameter; + }, + set escapeParameterHtml(val) { + composer.escapeParameter = val; + }, + // preserveDirectiveContent + get preserveDirectiveContent() { + return true; + }, + set preserveDirectiveContent(val) { + }, + // pluralizationRules + get pluralizationRules() { + return composer.pluralRules || {}; + }, + // for internal + __composer: composer, + // t + t(...args) { + const [arg1, arg2, arg3] = args; + const options = {}; + let list = null; + let named = null; + if (!shared.isString(arg1)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + const key = arg1; + if (shared.isString(arg2)) { + options.locale = arg2; + } + else if (shared.isArray(arg2)) { + list = arg2; + } + else if (shared.isPlainObject(arg2)) { + named = arg2; + } + if (shared.isArray(arg3)) { + list = arg3; + } + else if (shared.isPlainObject(arg3)) { + named = arg3; + } + // return composer.t(key, (list || named || {}) as any, options) + return Reflect.apply(composer.t, composer, [ + key, + (list || named || {}), + options + ]); + }, + rt(...args) { + return Reflect.apply(composer.rt, composer, [...args]); + }, + // tc + tc(...args) { + const [arg1, arg2, arg3] = args; + const options = { plural: 1 }; + let list = null; + let named = null; + if (!shared.isString(arg1)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + const key = arg1; + if (shared.isString(arg2)) { + options.locale = arg2; + } + else if (shared.isNumber(arg2)) { + options.plural = arg2; + } + else if (shared.isArray(arg2)) { + list = arg2; + } + else if (shared.isPlainObject(arg2)) { + named = arg2; + } + if (shared.isString(arg3)) { + options.locale = arg3; + } + else if (shared.isArray(arg3)) { + list = arg3; + } + else if (shared.isPlainObject(arg3)) { + named = arg3; + } + // return composer.t(key, (list || named || {}) as any, options) + return Reflect.apply(composer.t, composer, [ + key, + (list || named || {}), + options + ]); + }, + // te + te(key, locale) { + return composer.te(key, locale); + }, + // tm + tm(key) { + return composer.tm(key); + }, + // getLocaleMessage + getLocaleMessage(locale) { + return composer.getLocaleMessage(locale); + }, + // setLocaleMessage + setLocaleMessage(locale, message) { + composer.setLocaleMessage(locale, message); + }, + // mergeLocaleMessage + mergeLocaleMessage(locale, message) { + composer.mergeLocaleMessage(locale, message); + }, + // d + d(...args) { + return Reflect.apply(composer.d, composer, [...args]); + }, + // getDateTimeFormat + getDateTimeFormat(locale) { + return composer.getDateTimeFormat(locale); + }, + // setDateTimeFormat + setDateTimeFormat(locale, format) { + composer.setDateTimeFormat(locale, format); + }, + // mergeDateTimeFormat + mergeDateTimeFormat(locale, format) { + composer.mergeDateTimeFormat(locale, format); + }, + // n + n(...args) { + return Reflect.apply(composer.n, composer, [...args]); + }, + // getNumberFormat + getNumberFormat(locale) { + return composer.getNumberFormat(locale); + }, + // setNumberFormat + setNumberFormat(locale, format) { + composer.setNumberFormat(locale, format); + }, + // mergeNumberFormat + mergeNumberFormat(locale, format) { + composer.mergeNumberFormat(locale, format); + }, + // getChoiceIndex + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getChoiceIndex(choice, choicesLength) { + return -1; + } + }; + vueI18n.__extender = __extender; + return vueI18n; + } +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +const baseFormatProps = { + tag: { + type: [String, Object] + }, + locale: { + type: String + }, + scope: { + type: String, + // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050 + validator: (val /* ComponentI18nScope */) => val === 'parent' || val === 'global', + default: 'parent' /* ComponentI18nScope */ + }, + i18n: { + type: Object + } +}; + +function getInterpolateArg( +// eslint-disable-next-line @typescript-eslint/no-explicit-any +{ slots }, // SetupContext, +keys) { + if (keys.length === 1 && keys[0] === 'default') { + // default slot with list + const ret = slots.default ? slots.default() : []; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return ret.reduce((slot, current) => { + return [ + ...slot, + // prettier-ignore + ...(current.type === vue.Fragment ? current.children : [current] + ) + ]; + }, []); + } + else { + // named slots + return keys.reduce((arg, key) => { + const slot = slots[key]; + if (slot) { + arg[key] = slot(); + } + return arg; + }, shared.create()); + } +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getFragmentableTag(tag) { + return vue.Fragment ; +} + +const TranslationImpl = /*#__PURE__*/ vue.defineComponent({ + /* eslint-disable */ + name: 'i18n-t', + props: shared.assign({ + keypath: { + type: String, + required: true + }, + plural: { + type: [Number, String], + // eslint-disable-next-line @typescript-eslint/no-explicit-any + validator: (val) => shared.isNumber(val) || !isNaN(val) + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const { slots, attrs } = context; + // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050 + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return () => { + const keys = Object.keys(slots).filter(key => key !== '_'); + const options = shared.create(); + if (props.locale) { + options.locale = props.locale; + } + if (props.plural !== undefined) { + options.plural = shared.isString(props.plural) ? +props.plural : props.plural; + } + const arg = getInterpolateArg(context, keys); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const children = i18n[TranslateVNodeSymbol](props.keypath, arg, options); + const assignedAttrs = shared.assign(shared.create(), attrs); + const tag = shared.isString(props.tag) || shared.isObject(props.tag) + ? props.tag + : getFragmentableTag(); + return vue.h(tag, assignedAttrs, children); + }; + } +}); +/** + * export the public type for h/tsx inference + * also to avoid inline import() in generated d.ts files + */ +/** + * Translation Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [TranslationProps](component#translationprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Component Interpolation](../guide/advanced/component) + * + * @example + * ```html + *
+ * + * + * {{ $t('tos') }} + * + * + *
+ * ``` + * ```js + * import { createApp } from 'vue' + * import { createI18n } from 'vue-i18n' + * + * const messages = { + * en: { + * tos: 'Term of Service', + * term: 'I accept xxx {0}.' + * }, + * ja: { + * tos: '利用規約', + * term: '私は xxx の{0}に同意します。' + * } + * } + * + * const i18n = createI18n({ + * locale: 'en', + * messages + * }) + * + * const app = createApp({ + * data: { + * url: '/term' + * } + * }).use(i18n).mount('#app') + * ``` + * + * @VueI18nComponent + */ +const Translation = TranslationImpl; +const I18nT = Translation; + +function isVNode(target) { + return shared.isArray(target) && !shared.isString(target[0]); +} +function renderFormatter(props, context, slotKeys, partFormatter) { + const { slots, attrs } = context; + return () => { + const options = { part: true }; + let overrides = shared.create(); + if (props.locale) { + options.locale = props.locale; + } + if (shared.isString(props.format)) { + options.key = props.format; + } + else if (shared.isObject(props.format)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (shared.isString(props.format.key)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + options.key = props.format.key; + } + // Filter out number format options only + overrides = Object.keys(props.format).reduce((options, prop) => { + return slotKeys.includes(prop) + ? shared.assign(shared.create(), options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any + : options; + }, shared.create()); + } + const parts = partFormatter(...[props.value, options, overrides]); + let children = [options.key]; + if (shared.isArray(parts)) { + children = parts.map((part, index) => { + const slot = slots[part.type]; + const node = slot + ? slot({ [part.type]: part.value, index, parts }) + : [part.value]; + if (isVNode(node)) { + node[0].key = `${part.type}-${index}`; + } + return node; + }); + } + else if (shared.isString(parts)) { + children = [parts]; + } + const assignedAttrs = shared.assign(shared.create(), attrs); + const tag = shared.isString(props.tag) || shared.isObject(props.tag) + ? props.tag + : getFragmentableTag(); + return vue.h(tag, assignedAttrs, children); + }; +} + +const NumberFormatImpl = /*#__PURE__*/ vue.defineComponent({ + /* eslint-disable */ + name: 'i18n-n', + props: shared.assign({ + value: { + type: Number, + required: true + }, + format: { + type: [String, Object] + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return renderFormatter(props, context, coreBase.NUMBER_FORMAT_OPTIONS_KEYS, (...args) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + i18n[NumberPartsSymbol](...args)); + } +}); +/** + * export the public type for h/tsx inference + * also to avoid inline import() in generated d.ts files + */ +/** + * Number Format Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [FormattableProps](component#formattableprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Custom Formatting](../guide/essentials/number#custom-formatting) + * + * @VueI18nDanger + * Not supported IE, due to no support `Intl.NumberFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts) + * + * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-numberformat) + * + * @VueI18nComponent + */ +const NumberFormat = NumberFormatImpl; +const I18nN = NumberFormat; + +const DatetimeFormatImpl = /* #__PURE__*/ vue.defineComponent({ + /* eslint-disable */ + name: 'i18n-d', + props: shared.assign({ + value: { + type: [Number, Date], + required: true + }, + format: { + type: [String, Object] + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return renderFormatter(props, context, coreBase.DATETIME_FORMAT_OPTIONS_KEYS, (...args) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + i18n[DatetimePartsSymbol](...args)); + } +}); +/** + * Datetime Format Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [FormattableProps](component#formattableprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Custom Formatting](../guide/essentials/datetime#custom-formatting) + * + * @VueI18nDanger + * Not supported IE, due to no support `Intl.DateTimeFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts) + * + * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-datetimeformat) + * + * @VueI18nComponent + */ +const DatetimeFormat = DatetimeFormatImpl; +const I18nD = DatetimeFormat; + +function getComposer$1(i18n, instance) { + const i18nInternal = i18n; + if (i18n.mode === 'composition') { + return (i18nInternal.__getInstance(instance) || i18n.global); + } + else { + const vueI18n = i18nInternal.__getInstance(instance); + return vueI18n != null + ? vueI18n.__composer + : i18n.global.__composer; + } +} +function vTDirective(i18n) { + const _process = (binding) => { + const { instance, modifiers, value } = binding; + /* istanbul ignore if */ + if (!instance || !instance.$) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const composer = getComposer$1(i18n, instance.$); + const parsedValue = parseValue(value); + return [ + Reflect.apply(composer.t, composer, [...makeParams(parsedValue)]), + composer + ]; + }; + const register = (el, binding) => { + const [textContent, composer] = _process(binding); + if (shared.inBrowser && i18n.global === composer) { + // global scope only + el.__i18nWatcher = vue.watch(composer.locale, () => { + binding.instance && binding.instance.$forceUpdate(); + }); + } + el.__composer = composer; + el.textContent = textContent; + }; + const unregister = (el) => { + if (shared.inBrowser && el.__i18nWatcher) { + el.__i18nWatcher(); + el.__i18nWatcher = undefined; + delete el.__i18nWatcher; + } + if (el.__composer) { + el.__composer = undefined; + delete el.__composer; + } + }; + const update = (el, { value }) => { + if (el.__composer) { + const composer = el.__composer; + const parsedValue = parseValue(value); + el.textContent = Reflect.apply(composer.t, composer, [ + ...makeParams(parsedValue) + ]); + } + }; + const getSSRProps = (binding) => { + const [textContent] = _process(binding); + return { textContent }; + }; + return { + created: register, + unmounted: unregister, + beforeUpdate: update, + getSSRProps + }; +} +function parseValue(value) { + if (shared.isString(value)) { + return { path: value }; + } + else if (shared.isPlainObject(value)) { + if (!('path' in value)) { + throw createI18nError(I18nErrorCodes.REQUIRED_VALUE, 'path'); + } + return value; + } + else { + throw createI18nError(I18nErrorCodes.INVALID_VALUE); + } +} +function makeParams(value) { + const { path, locale, args, choice, plural } = value; + const options = {}; + const named = args || {}; + if (shared.isString(locale)) { + options.locale = locale; + } + if (shared.isNumber(choice)) { + options.plural = choice; + } + if (shared.isNumber(plural)) { + options.plural = plural; + } + return [path, named, options]; +} + +function apply(app, i18n, ...options) { + const pluginOptions = shared.isPlainObject(options[0]) + ? options[0] + : {}; + const useI18nComponentName = !!pluginOptions.useI18nComponentName; + const globalInstall = shared.isBoolean(pluginOptions.globalInstall) + ? pluginOptions.globalInstall + : true; + if (globalInstall) { + [!useI18nComponentName ? Translation.name : 'i18n', 'I18nT'].forEach(name => app.component(name, Translation)); + [NumberFormat.name, 'I18nN'].forEach(name => app.component(name, NumberFormat)); + [DatetimeFormat.name, 'I18nD'].forEach(name => app.component(name, DatetimeFormat)); + } + // install directive + { + app.directive('t', vTDirective(i18n)); + } +} + +/** + * Supports compatibility for legacy vue-i18n APIs + * This mixin is used when we use vue-i18n@v9.x or later + */ +function defineMixin(vuei18n, composer, i18n) { + return { + beforeCreate() { + const instance = vue.getCurrentInstance(); + /* istanbul ignore if */ + if (!instance) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const options = this.$options; + if (options.i18n) { + const optionsI18n = options.i18n; + if (options.__i18n) { + optionsI18n.__i18n = options.__i18n; + } + optionsI18n.__root = composer; + if (this === this.$root) { + // merge option and gttach global + this.$i18n = mergeToGlobal(vuei18n, optionsI18n); + } + else { + optionsI18n.__injectWithOption = true; + optionsI18n.__extender = i18n.__vueI18nExtend; + // atttach local VueI18n instance + this.$i18n = createVueI18n(optionsI18n); + // extend VueI18n instance + const _vueI18n = this.$i18n; + if (_vueI18n.__extender) { + _vueI18n.__disposer = _vueI18n.__extender(this.$i18n); + } + } + } + else if (options.__i18n) { + if (this === this.$root) { + // merge option and gttach global + this.$i18n = mergeToGlobal(vuei18n, options); + } + else { + // atttach local VueI18n instance + this.$i18n = createVueI18n({ + __i18n: options.__i18n, + __injectWithOption: true, + __extender: i18n.__vueI18nExtend, + __root: composer + }); + // extend VueI18n instance + const _vueI18n = this.$i18n; + if (_vueI18n.__extender) { + _vueI18n.__disposer = _vueI18n.__extender(this.$i18n); + } + } + } + else { + // attach global VueI18n instance + this.$i18n = vuei18n; + } + if (options.__i18nGlobal) { + adjustI18nResources(composer, options, options); + } + // defines vue-i18n legacy APIs + this.$t = (...args) => this.$i18n.t(...args); + this.$rt = (...args) => this.$i18n.rt(...args); + this.$tc = (...args) => this.$i18n.tc(...args); + this.$te = (key, locale) => this.$i18n.te(key, locale); + this.$d = (...args) => this.$i18n.d(...args); + this.$n = (...args) => this.$i18n.n(...args); + this.$tm = (key) => this.$i18n.tm(key); + i18n.__setInstance(instance, this.$i18n); + }, + mounted() { + }, + unmounted() { + const instance = vue.getCurrentInstance(); + /* istanbul ignore if */ + if (!instance) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const _vueI18n = this.$i18n; + delete this.$t; + delete this.$rt; + delete this.$tc; + delete this.$te; + delete this.$d; + delete this.$n; + delete this.$tm; + if (_vueI18n.__disposer) { + _vueI18n.__disposer(); + delete _vueI18n.__disposer; + delete _vueI18n.__extender; + } + i18n.__deleteInstance(instance); + delete this.$i18n; + } + }; +} +function mergeToGlobal(g, options) { + g.locale = options.locale || g.locale; + g.fallbackLocale = options.fallbackLocale || g.fallbackLocale; + g.missing = options.missing || g.missing; + g.silentTranslationWarn = + options.silentTranslationWarn || g.silentFallbackWarn; + g.silentFallbackWarn = options.silentFallbackWarn || g.silentFallbackWarn; + g.formatFallbackMessages = + options.formatFallbackMessages || g.formatFallbackMessages; + g.postTranslation = options.postTranslation || g.postTranslation; + g.warnHtmlInMessage = options.warnHtmlInMessage || g.warnHtmlInMessage; + g.escapeParameterHtml = options.escapeParameterHtml || g.escapeParameterHtml; + g.sync = options.sync || g.sync; + g.__composer[SetPluralRulesSymbol](options.pluralizationRules || g.pluralizationRules); + const messages = getLocaleMessages(g.locale, { + messages: options.messages, + __i18n: options.__i18n + }); + Object.keys(messages).forEach(locale => g.mergeLocaleMessage(locale, messages[locale])); + if (options.datetimeFormats) { + Object.keys(options.datetimeFormats).forEach(locale => g.mergeDateTimeFormat(locale, options.datetimeFormats[locale])); + } + if (options.numberFormats) { + Object.keys(options.numberFormats).forEach(locale => g.mergeNumberFormat(locale, options.numberFormats[locale])); + } + return g; +} + +/** + * Injection key for {@link useI18n} + * + * @remarks + * The global injection key for I18n instances with `useI18n`. this injection key is used in Web Components. + * Specify the i18n instance created by {@link createI18n} together with `provide` function. + * + * @VueI18nGeneral + */ +const I18nInjectionKey = +/* #__PURE__*/ shared.makeSymbol('global-vue-i18n'); +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types +function createI18n(options = {}, VueI18nLegacy) { + // prettier-ignore + const __legacyMode = shared.isBoolean(options.legacy) + ? options.legacy + : true; + // prettier-ignore + const __globalInjection = shared.isBoolean(options.globalInjection) + ? options.globalInjection + : true; + // prettier-ignore + const __allowComposition = __legacyMode + ? !!options.allowComposition + : true; + const __instances = new Map(); + const [globalScope, __global] = createGlobal(options, __legacyMode); + const symbol = /* #__PURE__*/ shared.makeSymbol(''); + function __getInstance(component) { + return __instances.get(component) || null; + } + function __setInstance(component, instance) { + __instances.set(component, instance); + } + function __deleteInstance(component) { + __instances.delete(component); + } + { + const i18n = { + // mode + get mode() { + return __legacyMode + ? 'legacy' + : 'composition'; + }, + // allowComposition + get allowComposition() { + return __allowComposition; + }, + // install plugin + async install(app, ...options) { + // setup global provider + app.__VUE_I18N_SYMBOL__ = symbol; + app.provide(app.__VUE_I18N_SYMBOL__, i18n); + // set composer & vuei18n extend hook options from plugin options + if (shared.isPlainObject(options[0])) { + const opts = options[0]; + i18n.__composerExtend = + opts.__composerExtend; + i18n.__vueI18nExtend = + opts.__vueI18nExtend; + } + // global method and properties injection for Composition API + let globalReleaseHandler = null; + if (!__legacyMode && __globalInjection) { + globalReleaseHandler = injectGlobalFields(app, i18n.global); + } + // install built-in components and directive + { + apply(app, i18n, ...options); + } + // setup mixin for Legacy API + if (__legacyMode) { + app.mixin(defineMixin(__global, __global.__composer, i18n)); + } + // release global scope + const unmountApp = app.unmount; + app.unmount = () => { + globalReleaseHandler && globalReleaseHandler(); + i18n.dispose(); + unmountApp(); + }; + }, + // global accessor + get global() { + return __global; + }, + dispose() { + globalScope.stop(); + }, + // @internal + __instances, + // @internal + __getInstance, + // @internal + __setInstance, + // @internal + __deleteInstance + }; + return i18n; + } +} +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function useI18n(options = {}) { + const instance = vue.getCurrentInstance(); + if (instance == null) { + throw createI18nError(I18nErrorCodes.MUST_BE_CALL_SETUP_TOP); + } + if (!instance.isCE && + instance.appContext.app != null && + !instance.appContext.app.__VUE_I18N_SYMBOL__) { + throw createI18nError(I18nErrorCodes.NOT_INSTALLED); + } + const i18n = getI18nInstance(instance); + const gl = getGlobalComposer(i18n); + const componentOptions = getComponentOptions(instance); + const scope = getScope(options, componentOptions); + { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (i18n.mode === 'legacy' && !options.__useComponent) { + if (!i18n.allowComposition) { + throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE); + } + return useI18nForLegacy(instance, scope, gl, options); + } + } + if (scope === 'global') { + adjustI18nResources(gl, options, componentOptions); + return gl; + } + if (scope === 'parent') { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let composer = getComposer(i18n, instance, options.__useComponent); + if (composer == null) { + composer = gl; + } + return composer; + } + const i18nInternal = i18n; + let composer = i18nInternal.__getInstance(instance); + if (composer == null) { + const composerOptions = shared.assign({}, options); + if ('__i18n' in componentOptions) { + composerOptions.__i18n = componentOptions.__i18n; + } + if (gl) { + composerOptions.__root = gl; + } + composer = createComposer(composerOptions); + if (i18nInternal.__composerExtend) { + composer[DisposeSymbol] = + i18nInternal.__composerExtend(composer); + } + setupLifeCycle(i18nInternal, instance, composer); + i18nInternal.__setInstance(instance, composer); + } + return composer; +} +/** + * Cast to VueI18n legacy compatible type + * + * @remarks + * This API is provided only with [vue-i18n-bridge](https://vue-i18n.intlify.dev/guide/migration/ways.html#what-is-vue-i18n-bridge). + * + * The purpose of this function is to convert an {@link I18n} instance created with {@link createI18n | createI18n(legacy: true)} into a `vue-i18n@v8.x` compatible instance of `new VueI18n` in a TypeScript environment. + * + * @param i18n - An instance of {@link I18n} + * @returns A i18n instance which is casted to {@link VueI18n} type + * + * @VueI18nTip + * :new: provided by **vue-i18n-bridge only** + * + * @VueI18nGeneral + */ +/* #__NO_SIDE_EFFECTS__ */ +const castToVueI18n = (i18n +// eslint-disable-next-line @typescript-eslint/no-explicit-any +) => { + if (!(__VUE_I18N_BRIDGE__ in i18n)) { + throw createI18nError(I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N); + } + return i18n; +}; +function createGlobal(options, legacyMode, VueI18nLegacy // eslint-disable-line @typescript-eslint/no-explicit-any +) { + const scope = vue.effectScope(); + { + const obj = legacyMode + ? scope.run(() => createVueI18n(options)) + : scope.run(() => createComposer(options)); + if (obj == null) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + return [scope, obj]; + } +} +function getI18nInstance(instance) { + { + const i18n = vue.inject(!instance.isCE + ? instance.appContext.app.__VUE_I18N_SYMBOL__ + : I18nInjectionKey); + /* istanbul ignore if */ + if (!i18n) { + throw createI18nError(!instance.isCE + ? I18nErrorCodes.UNEXPECTED_ERROR + : I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE); + } + return i18n; + } +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getScope(options, componentOptions) { + // prettier-ignore + return shared.isEmptyObject(options) + ? ('__i18n' in componentOptions) + ? 'local' + : 'global' + : !options.useScope + ? 'local' + : options.useScope; +} +function getGlobalComposer(i18n) { + // prettier-ignore + return i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer + ; +} +function getComposer(i18n, target, useComponent = false) { + let composer = null; + const root = target.root; + let current = getParentComponentInstance(target, useComponent); + while (current != null) { + const i18nInternal = i18n; + if (i18n.mode === 'composition') { + composer = i18nInternal.__getInstance(current); + } + else { + { + const vueI18n = i18nInternal.__getInstance(current); + if (vueI18n != null) { + composer = vueI18n + .__composer; + if (useComponent && + composer && + !composer[InejctWithOptionSymbol] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + composer = null; + } + } + } + } + if (composer != null) { + break; + } + if (root === current) { + break; + } + current = current.parent; + } + return composer; +} +function getParentComponentInstance(target, useComponent = false) { + if (target == null) { + return null; + } + { + // if `useComponent: true` will be specified, we get lexical scope owner instance for use-case slots + return !useComponent + ? target.parent + : target.vnode.ctx || target.parent; // eslint-disable-line @typescript-eslint/no-explicit-any + } +} +function setupLifeCycle(i18n, target, composer) { + { + vue.onMounted(() => { + }, target); + vue.onUnmounted(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = composer; + i18n.__deleteInstance(target); + // dispose extended resources + const dispose = _composer[DisposeSymbol]; + if (dispose) { + dispose(); + delete _composer[DisposeSymbol]; + } + }, target); + } +} +function useI18nForLegacy(instance, scope, root, options = {} // eslint-disable-line @typescript-eslint/no-explicit-any +) { + const isLocalScope = scope === 'local'; + const _composer = vue.shallowRef(null); + if (isLocalScope && + instance.proxy && + !(instance.proxy.$options.i18n || instance.proxy.$options.__i18n)) { + throw createI18nError(I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION); + } + const _inheritLocale = shared.isBoolean(options.inheritLocale) + ? options.inheritLocale + : !shared.isString(options.locale); + const _locale = vue.ref( + // prettier-ignore + !isLocalScope || _inheritLocale + ? root.locale.value + : shared.isString(options.locale) + ? options.locale + : coreBase.DEFAULT_LOCALE); + const _fallbackLocale = vue.ref( + // prettier-ignore + !isLocalScope || _inheritLocale + ? root.fallbackLocale.value + : shared.isString(options.fallbackLocale) || + shared.isArray(options.fallbackLocale) || + shared.isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale.value); + const _messages = vue.ref(getLocaleMessages(_locale.value, options)); + // prettier-ignore + const _datetimeFormats = vue.ref(shared.isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : { [_locale.value]: {} }); + // prettier-ignore + const _numberFormats = vue.ref(shared.isPlainObject(options.numberFormats) + ? options.numberFormats + : { [_locale.value]: {} }); + // prettier-ignore + const _missingWarn = isLocalScope + ? root.missingWarn + : shared.isBoolean(options.missingWarn) || shared.isRegExp(options.missingWarn) + ? options.missingWarn + : true; + // prettier-ignore + const _fallbackWarn = isLocalScope + ? root.fallbackWarn + : shared.isBoolean(options.fallbackWarn) || shared.isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + // prettier-ignore + const _fallbackRoot = isLocalScope + ? root.fallbackRoot + : shared.isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + // configure fall back to root + const _fallbackFormat = !!options.fallbackFormat; + // runtime missing + const _missing = shared.isFunction(options.missing) ? options.missing : null; + // postTranslation handler + const _postTranslation = shared.isFunction(options.postTranslation) + ? options.postTranslation + : null; + // prettier-ignore + const _warnHtmlMessage = isLocalScope + ? root.warnHtmlMessage + : shared.isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const _escapeParameter = !!options.escapeParameter; + // prettier-ignore + const _modifiers = isLocalScope + ? root.modifiers + : shared.isPlainObject(options.modifiers) + ? options.modifiers + : {}; + // pluralRules + const _pluralRules = options.pluralRules || (isLocalScope && root.pluralRules); + // track reactivity + function trackReactivityValues() { + return [ + _locale.value, + _fallbackLocale.value, + _messages.value, + _datetimeFormats.value, + _numberFormats.value + ]; + } + // locale + const locale = vue.computed({ + get: () => { + return _composer.value ? _composer.value.locale.value : _locale.value; + }, + set: val => { + if (_composer.value) { + _composer.value.locale.value = val; + } + _locale.value = val; + } + }); + // fallbackLocale + const fallbackLocale = vue.computed({ + get: () => { + return _composer.value + ? _composer.value.fallbackLocale.value + : _fallbackLocale.value; + }, + set: val => { + if (_composer.value) { + _composer.value.fallbackLocale.value = val; + } + _fallbackLocale.value = val; + } + }); + // messages + const messages = vue.computed(() => { + if (_composer.value) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return _composer.value.messages.value; + } + else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return _messages.value; + } + }); + const datetimeFormats = vue.computed(() => _datetimeFormats.value); + const numberFormats = vue.computed(() => _numberFormats.value); + function getPostTranslationHandler() { + return _composer.value + ? _composer.value.getPostTranslationHandler() + : _postTranslation; + } + function setPostTranslationHandler(handler) { + if (_composer.value) { + _composer.value.setPostTranslationHandler(handler); + } + } + function getMissingHandler() { + return _composer.value ? _composer.value.getMissingHandler() : _missing; + } + function setMissingHandler(handler) { + if (_composer.value) { + _composer.value.setMissingHandler(handler); + } + } + function warpWithDeps(fn) { + trackReactivityValues(); + return fn(); + } + function t(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.t, null, [...args])) + : warpWithDeps(() => ''); + } + function rt(...args) { + return _composer.value + ? Reflect.apply(_composer.value.rt, null, [...args]) + : ''; + } + function d(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.d, null, [...args])) + : warpWithDeps(() => ''); + } + function n(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.n, null, [...args])) + : warpWithDeps(() => ''); + } + function tm(key) { + return _composer.value ? _composer.value.tm(key) : {}; + } + function te(key, locale) { + return _composer.value ? _composer.value.te(key, locale) : false; + } + function getLocaleMessage(locale) { + return _composer.value ? _composer.value.getLocaleMessage(locale) : {}; + } + function setLocaleMessage(locale, message) { + if (_composer.value) { + _composer.value.setLocaleMessage(locale, message); + _messages.value[locale] = message; + } + } + function mergeLocaleMessage(locale, message) { + if (_composer.value) { + _composer.value.mergeLocaleMessage(locale, message); + } + } + function getDateTimeFormat(locale) { + return _composer.value ? _composer.value.getDateTimeFormat(locale) : {}; + } + function setDateTimeFormat(locale, format) { + if (_composer.value) { + _composer.value.setDateTimeFormat(locale, format); + _datetimeFormats.value[locale] = format; + } + } + function mergeDateTimeFormat(locale, format) { + if (_composer.value) { + _composer.value.mergeDateTimeFormat(locale, format); + } + } + function getNumberFormat(locale) { + return _composer.value ? _composer.value.getNumberFormat(locale) : {}; + } + function setNumberFormat(locale, format) { + if (_composer.value) { + _composer.value.setNumberFormat(locale, format); + _numberFormats.value[locale] = format; + } + } + function mergeNumberFormat(locale, format) { + if (_composer.value) { + _composer.value.mergeNumberFormat(locale, format); + } + } + const wrapper = { + get id() { + return _composer.value ? _composer.value.id : -1; + }, + locale, + fallbackLocale, + messages, + datetimeFormats, + numberFormats, + get inheritLocale() { + return _composer.value ? _composer.value.inheritLocale : _inheritLocale; + }, + set inheritLocale(val) { + if (_composer.value) { + _composer.value.inheritLocale = val; + } + }, + get availableLocales() { + return _composer.value + ? _composer.value.availableLocales + : Object.keys(_messages.value); + }, + get modifiers() { + return (_composer.value ? _composer.value.modifiers : _modifiers); + }, + get pluralRules() { + return (_composer.value ? _composer.value.pluralRules : _pluralRules); + }, + get isGlobal() { + return _composer.value ? _composer.value.isGlobal : false; + }, + get missingWarn() { + return _composer.value ? _composer.value.missingWarn : _missingWarn; + }, + set missingWarn(val) { + if (_composer.value) { + _composer.value.missingWarn = val; + } + }, + get fallbackWarn() { + return _composer.value ? _composer.value.fallbackWarn : _fallbackWarn; + }, + set fallbackWarn(val) { + if (_composer.value) { + _composer.value.missingWarn = val; + } + }, + get fallbackRoot() { + return _composer.value ? _composer.value.fallbackRoot : _fallbackRoot; + }, + set fallbackRoot(val) { + if (_composer.value) { + _composer.value.fallbackRoot = val; + } + }, + get fallbackFormat() { + return _composer.value ? _composer.value.fallbackFormat : _fallbackFormat; + }, + set fallbackFormat(val) { + if (_composer.value) { + _composer.value.fallbackFormat = val; + } + }, + get warnHtmlMessage() { + return _composer.value + ? _composer.value.warnHtmlMessage + : _warnHtmlMessage; + }, + set warnHtmlMessage(val) { + if (_composer.value) { + _composer.value.warnHtmlMessage = val; + } + }, + get escapeParameter() { + return _composer.value + ? _composer.value.escapeParameter + : _escapeParameter; + }, + set escapeParameter(val) { + if (_composer.value) { + _composer.value.escapeParameter = val; + } + }, + t, + getPostTranslationHandler, + setPostTranslationHandler, + getMissingHandler, + setMissingHandler, + rt, + d, + n, + tm, + te, + getLocaleMessage, + setLocaleMessage, + mergeLocaleMessage, + getDateTimeFormat, + setDateTimeFormat, + mergeDateTimeFormat, + getNumberFormat, + setNumberFormat, + mergeNumberFormat + }; + function sync(composer) { + composer.locale.value = _locale.value; + composer.fallbackLocale.value = _fallbackLocale.value; + Object.keys(_messages.value).forEach(locale => { + composer.mergeLocaleMessage(locale, _messages.value[locale]); + }); + Object.keys(_datetimeFormats.value).forEach(locale => { + composer.mergeDateTimeFormat(locale, _datetimeFormats.value[locale]); + }); + Object.keys(_numberFormats.value).forEach(locale => { + composer.mergeNumberFormat(locale, _numberFormats.value[locale]); + }); + composer.escapeParameter = _escapeParameter; + composer.fallbackFormat = _fallbackFormat; + composer.fallbackRoot = _fallbackRoot; + composer.fallbackWarn = _fallbackWarn; + composer.missingWarn = _missingWarn; + composer.warnHtmlMessage = _warnHtmlMessage; + } + vue.onBeforeMount(() => { + if (instance.proxy == null || instance.proxy.$i18n == null) { + throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const composer = (_composer.value = instance.proxy.$i18n + .__composer); + if (scope === 'global') { + _locale.value = composer.locale.value; + _fallbackLocale.value = composer.fallbackLocale.value; + _messages.value = composer.messages.value; + _datetimeFormats.value = composer.datetimeFormats.value; + _numberFormats.value = composer.numberFormats.value; + } + else if (isLocalScope) { + sync(composer); + } + }); + return wrapper; +} +const globalExportProps = [ + 'locale', + 'fallbackLocale', + 'availableLocales' +]; +const globalExportMethods = ['t', 'rt', 'd', 'n', 'tm', 'te'] + ; +function injectGlobalFields(app, composer) { + const i18n = Object.create(null); + globalExportProps.forEach(prop => { + const desc = Object.getOwnPropertyDescriptor(composer, prop); + if (!desc) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const wrap = vue.isRef(desc.value) // check computed props + ? { + get() { + return desc.value.value; + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + set(val) { + desc.value.value = val; + } + } + : { + get() { + return desc.get && desc.get(); + } + }; + Object.defineProperty(i18n, prop, wrap); + }); + app.config.globalProperties.$i18n = i18n; + globalExportMethods.forEach(method => { + const desc = Object.getOwnPropertyDescriptor(composer, method); + if (!desc || !desc.value) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + Object.defineProperty(app.config.globalProperties, `$${method}`, desc); + }); + const dispose = () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete app.config.globalProperties.$i18n; + globalExportMethods.forEach(method => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete app.config.globalProperties[`$${method}`]; + }); + }; + return dispose; +} + +// register message compiler at vue-i18n +{ + coreBase.registerMessageCompiler(coreBase.compile); +} +// register message resolver at vue-i18n +coreBase.registerMessageResolver(coreBase.resolveValue); +// register fallback locale at vue-i18n +coreBase.registerLocaleFallbacker(coreBase.fallbackWithLocaleChain); + +exports.DatetimeFormat = DatetimeFormat; +exports.I18nD = I18nD; +exports.I18nInjectionKey = I18nInjectionKey; +exports.I18nN = I18nN; +exports.I18nT = I18nT; +exports.NumberFormat = NumberFormat; +exports.Translation = Translation; +exports.VERSION = VERSION; +exports.castToVueI18n = castToVueI18n; +exports.createI18n = createI18n; +exports.useI18n = useI18n; +exports.vTDirective = vTDirective; diff --git a/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-browser.js b/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-browser.js new file mode 100644 index 0000000..4af641b --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-browser.js @@ -0,0 +1,5121 @@ +/*! + * vue-i18n v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +import { createVNode, Text, computed, watch, getCurrentInstance, ref, shallowRef, Fragment, defineComponent, h, effectScope, inject, onMounted, onUnmounted, onBeforeMount, isRef } from 'vue'; + +function warn(msg, err) { + if (typeof console !== 'undefined') { + console.warn(`[intlify] ` + msg); + /* istanbul ignore if */ + if (err) { + console.warn(err.stack); + } + } +} +const hasWarned = {}; +function warnOnce(msg) { + if (!hasWarned[msg]) { + hasWarned[msg] = true; + warn(msg); + } +} + +/** + * Original Utilities + * written by kazuya kawaguchi + */ +const inBrowser = typeof window !== 'undefined'; +let mark; +let measure; +{ + const perf = inBrowser && window.performance; + if (perf && + perf.mark && + perf.measure && + perf.clearMarks && + // @ts-ignore browser compat + perf.clearMeasures) { + mark = (tag) => { + perf.mark(tag); + }; + measure = (name, startTag, endTag) => { + perf.measure(name, startTag, endTag); + perf.clearMarks(startTag); + perf.clearMarks(endTag); + }; + } +} +const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g; +/* eslint-disable */ +function format(message, ...args) { + if (args.length === 1 && isObject(args[0])) { + args = args[0]; + } + if (!args || !args.hasOwnProperty) { + args = {}; + } + return message.replace(RE_ARGS, (match, identifier) => { + return args.hasOwnProperty(identifier) ? args[identifier] : ''; + }); +} +const makeSymbol = (name, shareable = false) => !shareable ? Symbol(name) : Symbol.for(name); +const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({ l: locale, k: key, s: source }); +const friendlyJSONstringify = (json) => JSON.stringify(json) + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029') + .replace(/\u0027/g, '\\u0027'); +const isNumber = (val) => typeof val === 'number' && isFinite(val); +const isDate = (val) => toTypeString(val) === '[object Date]'; +const isRegExp = (val) => toTypeString(val) === '[object RegExp]'; +const isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0; +const assign = Object.assign; +const _create = Object.create; +const create = (obj = null) => _create(obj); +let _globalThis; +const getGlobalThis = () => { + // prettier-ignore + return (_globalThis || + (_globalThis = + typeof globalThis !== 'undefined' + ? globalThis + : typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : create())); +}; +function escapeHtml(rawText) { + return rawText + .replace(/&/g, '&') // escape `&` first to avoid double escaping + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/\//g, '/') // escape `/` to prevent closing tags or JavaScript URLs + .replace(/=/g, '='); // escape `=` to prevent attribute injection +} +function escapeAttributeValue(value) { + return value + .replace(/&(?![a-zA-Z0-9#]{2,6};)/g, '&') // escape unescaped `&` + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(//g, '>'); +} +function sanitizeTranslatedHtml(html) { + // Escape dangerous characters in attribute values + // Process attributes with double quotes + html = html.replace(/(\w+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${escapeAttributeValue(attrValue)}"`); + // Process attributes with single quotes + html = html.replace(/(\w+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${escapeAttributeValue(attrValue)}'`); + // Detect and neutralize event handler attributes + const eventHandlerPattern = /\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi; + if (eventHandlerPattern.test(html)) { + { + warn('Potentially dangerous event handlers detected in translation. ' + + 'Consider removing onclick, onerror, etc. from your translation messages.'); + } + // Neutralize event handler attributes by escaping 'on' + html = html.replace(/(\s+)(on)(\w+\s*=)/gi, '$1on$3'); + } + // Disable javascript: URLs in various contexts + const javascriptUrlPattern = [ + // In href, src, action, formaction attributes + /(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi, + // In style attributes within url() + /(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi + ]; + javascriptUrlPattern.forEach(pattern => { + html = html.replace(pattern, '$1javascript:'); + }); + return html; +} +const hasOwnProperty = Object.prototype.hasOwnProperty; +function hasOwn(obj, key) { + return hasOwnProperty.call(obj, key); +} +/* eslint-enable */ +/** + * Useful Utilities By Evan you + * Modified by kazuya kawaguchi + * MIT License + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts + */ +const isArray = Array.isArray; +const isFunction = (val) => typeof val === 'function'; +const isString = (val) => typeof val === 'string'; +const isBoolean = (val) => typeof val === 'boolean'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isObject = (val) => val !== null && typeof val === 'object'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const isPromise = (val) => { + return isObject(val) && isFunction(val.then) && isFunction(val.catch); +}; +const objectToString = Object.prototype.toString; +const toTypeString = (value) => objectToString.call(value); +const isPlainObject = (val) => { + if (!isObject(val)) + return false; + const proto = Object.getPrototypeOf(val); + return proto === null || proto.constructor === Object; +}; +// for converting list and named values to displayed strings. +const toDisplayString = (val) => { + return val == null + ? '' + : isArray(val) || (isPlainObject(val) && val.toString === objectToString) + ? JSON.stringify(val, null, 2) + : String(val); +}; +function join(items, separator = '') { + return items.reduce((str, item, index) => (index === 0 ? str + item : str + separator + item), ''); +} +const RANGE = 2; +function generateCodeFrame(source, start = 0, end = source.length) { + const lines = source.split(/\r?\n/); + let count = 0; + const res = []; + for (let i = 0; i < lines.length; i++) { + count += lines[i].length + 1; + if (count >= start) { + for (let j = i - RANGE; j <= i + RANGE || end > count; j++) { + if (j < 0 || j >= lines.length) + continue; + const line = j + 1; + res.push(`${line}${' '.repeat(3 - String(line).length)}| ${lines[j]}`); + const lineLength = lines[j].length; + if (j === i) { + // push underline + const pad = start - (count - lineLength) + 1; + const length = Math.max(1, end > count ? lineLength - pad : end - start); + res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length)); + } + else if (j > i) { + if (end > count) { + const length = Math.max(Math.min(end - count, lineLength), 1); + res.push(` | ` + '^'.repeat(length)); + } + count += lineLength + 1; + } + } + break; + } + } + return res.join('\n'); +} +function incrementer(code) { + let current = code; + return () => ++current; +} + +/** + * Event emitter, forked from the below: + * - original repository url: https://github.com/developit/mitt + * - code url: https://github.com/developit/mitt/blob/master/src/index.ts + * - author: Jason Miller (https://github.com/developit) + * - license: MIT + */ +/** + * Create a event emitter + * + * @returns An event emitter + */ +function createEmitter() { + const events = new Map(); + const emitter = { + events, + on(event, handler) { + const handlers = events.get(event); + const added = handlers && handlers.push(handler); + if (!added) { + events.set(event, [handler]); + } + }, + off(event, handler) { + const handlers = events.get(event); + if (handlers) { + handlers.splice(handlers.indexOf(handler) >>> 0, 1); + } + }, + emit(event, payload) { + (events.get(event) || []) + .slice() + .map(handler => handler(payload)); + (events.get('*') || []) + .slice() + .map(handler => handler(event, payload)); + } + }; + return emitter; +} + +const isNotObjectOrIsArray = (val) => !isObject(val) || isArray(val); +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types +function deepCopy(src, des) { + // src and des should both be objects, and none of them can be a array + if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des)) { + throw new Error('Invalid value'); + } + const stack = [{ src, des }]; + while (stack.length) { + const { src, des } = stack.pop(); + // using `Object.keys` which skips prototype properties + Object.keys(src).forEach(key => { + if (key === '__proto__') { + return; + } + // if src[key] is an object/array, set des[key] + // to empty object/array to prevent setting by reference + if (isObject(src[key]) && !isObject(des[key])) { + des[key] = Array.isArray(src[key]) ? [] : create(); + } + if (isNotObjectOrIsArray(des[key]) || isNotObjectOrIsArray(src[key])) { + // replace with src[key] when: + // src[key] or des[key] is not an object, or + // src[key] or des[key] is an array + des[key] = src[key]; + } + else { + // src[key] and des[key] are both objects, merge them + stack.push({ src: src[key], des: des[key] }); + } + }); + } +} + +const CompileWarnCodes = { + USE_MODULO_SYNTAX: 1, + __EXTEND_POINT__: 2 +}; + +const CompileErrorCodes = { + // tokenizer error codes + EXPECTED_TOKEN: 1, + INVALID_TOKEN_IN_PLACEHOLDER: 2, + UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3, + UNKNOWN_ESCAPE_SEQUENCE: 4, + INVALID_UNICODE_ESCAPE_SEQUENCE: 5, + UNBALANCED_CLOSING_BRACE: 6, + UNTERMINATED_CLOSING_BRACE: 7, + EMPTY_PLACEHOLDER: 8, + NOT_ALLOW_NEST_PLACEHOLDER: 9, + INVALID_LINKED_FORMAT: 10, + // parser error codes + MUST_HAVE_MESSAGES_IN_PLURAL: 11, + UNEXPECTED_EMPTY_LINKED_MODIFIER: 12, + UNEXPECTED_EMPTY_LINKED_KEY: 13, + UNEXPECTED_LEXICAL_ANALYSIS: 14, + // generator error codes + UNHANDLED_CODEGEN_NODE_TYPE: 15, + // minifier error codes + UNHANDLED_MINIFIER_NODE_TYPE: 16, + // Special value for higher-order compilers to pick up the last code + // to avoid collision of error codes. This should always be kept as the last + // item. + __EXTEND_POINT__: 17 +}; +/** @internal */ +const errorMessages$2 = { + // tokenizer error messages + [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`, + [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`, + [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`, + [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`, + [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`, + [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`, + [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`, + [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`, + [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`, + [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`, + // parser error messages + [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`, + [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`, + // generator error messages + [CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`, + // minimizer error messages + [CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'` +}; +function createCompileError(code, loc, options = {}) { + const { domain, messages, args } = options; + const msg = format((messages || errorMessages$2)[code] || '', ...(args || [])) + ; + const error = new SyntaxError(String(msg)); + error.code = code; + if (loc) { + error.location = loc; + } + error.domain = domain; + return error; +} + +function isMessageAST(val) { + return (isObject(val) && + resolveType(val) === 0 && + (hasOwn(val, 'b') || hasOwn(val, 'body'))); +} +const PROPS_BODY = ['b', 'body']; +const PROPS_CASES = ['c', 'cases']; +const PROPS_STATIC = ['s', 'static']; +const PROPS_ITEMS = ['i', 'items']; +const PROPS_TYPE = ['t', 'type']; +function resolveType(node) { + return resolveProps(node, PROPS_TYPE); +} +const PROPS_VALUE = ['v', 'value']; +const PROPS_MODIFIER = ['m', 'modifier']; +const PROPS_KEY = ['k', 'key']; +function resolveProps(node, props, defaultValue) { + for (let i = 0; i < props.length; i++) { + const prop = props[i]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (hasOwn(node, prop) && node[prop] != null) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return node[prop]; + } + } + return defaultValue; +} +const AST_NODE_PROPS_KEYS = [ + ...PROPS_BODY, + ...PROPS_CASES, + ...PROPS_STATIC, + ...PROPS_ITEMS, + ...PROPS_KEY, + ...PROPS_MODIFIER, + ...PROPS_VALUE, + ...PROPS_TYPE +]; + +const pathStateMachine = []; +pathStateMachine[0 /* States.BEFORE_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [0 /* States.BEFORE_PATH */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] +}; +pathStateMachine[1 /* States.IN_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] +}; +pathStateMachine[2 /* States.BEFORE_IDENT */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [2 /* States.BEFORE_IDENT */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */] +}; +pathStateMachine[3 /* States.IN_IDENT */] = { + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */, 1 /* Actions.PUSH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */, 1 /* Actions.PUSH */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */, 1 /* Actions.PUSH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */, 1 /* Actions.PUSH */] +}; +pathStateMachine[4 /* States.IN_SUB_PATH */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */], + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [ + 4 /* States.IN_SUB_PATH */, + 2 /* Actions.INC_SUB_PATH_DEPTH */ + ], + ["]" /* PathCharTypes.RIGHT_BRACKET */]: [1 /* States.IN_PATH */, 3 /* Actions.PUSH_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */] +}; +pathStateMachine[5 /* States.IN_SINGLE_QUOTE */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */] +}; +pathStateMachine[6 /* States.IN_DOUBLE_QUOTE */] = { + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */] +}; +/** + * Check if an expression is a literal value. + */ +const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/; +function isLiteral(exp) { + return literalValueRE.test(exp); +} +/** + * Strip quotes from a string + */ +function stripQuotes(str) { + const a = str.charCodeAt(0); + const b = str.charCodeAt(str.length - 1); + return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str; +} +/** + * Determine the type of a character in a keypath. + */ +function getPathCharType(ch) { + if (ch === undefined || ch === null) { + return "o" /* PathCharTypes.END_OF_FAIL */; + } + const code = ch.charCodeAt(0); + switch (code) { + case 0x5b: // [ + case 0x5d: // ] + case 0x2e: // . + case 0x22: // " + case 0x27: // ' + return ch; + case 0x5f: // _ + case 0x24: // $ + case 0x2d: // - + return "i" /* PathCharTypes.IDENT */; + case 0x09: // Tab (HT) + case 0x0a: // Newline (LF) + case 0x0d: // Return (CR) + case 0xa0: // No-break space (NBSP) + case 0xfeff: // Byte Order Mark (BOM) + case 0x2028: // Line Separator (LS) + case 0x2029: // Paragraph Separator (PS) + return "w" /* PathCharTypes.WORKSPACE */; + } + return "i" /* PathCharTypes.IDENT */; +} +/** + * Format a subPath, return its plain form if it is + * a literal string or number. Otherwise prepend the + * dynamic indicator (*). + */ +function formatSubPath(path) { + const trimmed = path.trim(); + // invalid leading 0 + if (path.charAt(0) === '0' && isNaN(parseInt(path))) { + return false; + } + return isLiteral(trimmed) + ? stripQuotes(trimmed) + : "*" /* PathCharTypes.ASTARISK */ + trimmed; +} +/** + * Parse a string path into an array of segments + */ +function parse(path) { + const keys = []; + let index = -1; + let mode = 0 /* States.BEFORE_PATH */; + let subPathDepth = 0; + let c; + let key; // eslint-disable-line + let newChar; + let type; + let transition; + let action; + let typeMap; + const actions = []; + actions[0 /* Actions.APPEND */] = () => { + if (key === undefined) { + key = newChar; + } + else { + key += newChar; + } + }; + actions[1 /* Actions.PUSH */] = () => { + if (key !== undefined) { + keys.push(key); + key = undefined; + } + }; + actions[2 /* Actions.INC_SUB_PATH_DEPTH */] = () => { + actions[0 /* Actions.APPEND */](); + subPathDepth++; + }; + actions[3 /* Actions.PUSH_SUB_PATH */] = () => { + if (subPathDepth > 0) { + subPathDepth--; + mode = 4 /* States.IN_SUB_PATH */; + actions[0 /* Actions.APPEND */](); + } + else { + subPathDepth = 0; + if (key === undefined) { + return false; + } + key = formatSubPath(key); + if (key === false) { + return false; + } + else { + actions[1 /* Actions.PUSH */](); + } + } + }; + function maybeUnescapeQuote() { + const nextChar = path[index + 1]; + if ((mode === 5 /* States.IN_SINGLE_QUOTE */ && + nextChar === "'" /* PathCharTypes.SINGLE_QUOTE */) || + (mode === 6 /* States.IN_DOUBLE_QUOTE */ && + nextChar === "\"" /* PathCharTypes.DOUBLE_QUOTE */)) { + index++; + newChar = '\\' + nextChar; + actions[0 /* Actions.APPEND */](); + return true; + } + } + while (mode !== null) { + index++; + c = path[index]; + if (c === '\\' && maybeUnescapeQuote()) { + continue; + } + type = getPathCharType(c); + typeMap = pathStateMachine[mode]; + transition = typeMap[type] || typeMap["l" /* PathCharTypes.ELSE */] || 8 /* States.ERROR */; + // check parse error + if (transition === 8 /* States.ERROR */) { + return; + } + mode = transition[0]; + if (transition[1] !== undefined) { + action = actions[transition[1]]; + if (action) { + newChar = c; + if (action() === false) { + return; + } + } + } + // check parse finish + if (mode === 7 /* States.AFTER_PATH */) { + return keys; + } + } +} +// path token cache +const cache = new Map(); +/** + * key-value message resolver + * + * @remarks + * Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ +function resolveWithKeyValue(obj, path) { + return isObject(obj) ? obj[path] : null; +} +/** + * message resolver + * + * @remarks + * Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default. + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ +function resolveValue(obj, path) { + // check object + if (!isObject(obj)) { + return null; + } + // parse path + let hit = cache.get(path); + if (!hit) { + hit = parse(path); + if (hit) { + cache.set(path, hit); + } + } + // check hit + if (!hit) { + return null; + } + // resolve path value + const len = hit.length; + let last = obj; + let i = 0; + while (i < len) { + const key = hit[i]; + /** + * NOTE: + * if `key` is intlify message format AST node key and `last` is intlify message format AST, skip it. + * because the AST node is not a key-value structure. + */ + if (AST_NODE_PROPS_KEYS.includes(key) && isMessageAST(last)) { + return null; + } + const val = last[key]; + if (val === undefined) { + return null; + } + if (isFunction(last)) { + return null; + } + last = val; + i++; + } + return last; +} + +const DEFAULT_MODIFIER = (str) => str; +const DEFAULT_MESSAGE = (ctx) => ''; // eslint-disable-line +const DEFAULT_MESSAGE_DATA_TYPE = 'text'; +const DEFAULT_NORMALIZE = (values) => values.length === 0 ? '' : join(values); +const DEFAULT_INTERPOLATE = toDisplayString; +function pluralDefault(choice, choicesLength) { + choice = Math.abs(choice); + if (choicesLength === 2) { + // prettier-ignore + return choice + ? choice > 1 + ? 1 + : 0 + : 1; + } + return choice ? Math.min(choice, 2) : 0; +} +function getPluralIndex(options) { + // prettier-ignore + const index = isNumber(options.pluralIndex) + ? options.pluralIndex + : -1; + // prettier-ignore + return options.named && (isNumber(options.named.count) || isNumber(options.named.n)) + ? isNumber(options.named.count) + ? options.named.count + : isNumber(options.named.n) + ? options.named.n + : index + : index; +} +function normalizeNamed(pluralIndex, props) { + if (!props.count) { + props.count = pluralIndex; + } + if (!props.n) { + props.n = pluralIndex; + } +} +function createMessageContext(options = {}) { + const locale = options.locale; + const pluralIndex = getPluralIndex(options); + const pluralRule = isObject(options.pluralRules) && + isString(locale) && + isFunction(options.pluralRules[locale]) + ? options.pluralRules[locale] + : pluralDefault; + const orgPluralRule = isObject(options.pluralRules) && + isString(locale) && + isFunction(options.pluralRules[locale]) + ? pluralDefault + : undefined; + const plural = (messages) => { + return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)]; + }; + const _list = options.list || []; + const list = (index) => _list[index]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _named = options.named || create(); + isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named); + const named = (key) => _named[key]; + function message(key) { + // prettier-ignore + const msg = isFunction(options.messages) + ? options.messages(key) + : isObject(options.messages) + ? options.messages[key] + : false; + return !msg + ? options.parent + ? options.parent.message(key) // resolve from parent messages + : DEFAULT_MESSAGE + : msg; + } + const _modifier = (name) => options.modifiers + ? options.modifiers[name] + : DEFAULT_MODIFIER; + const normalize = isPlainObject(options.processor) && isFunction(options.processor.normalize) + ? options.processor.normalize + : DEFAULT_NORMALIZE; + const interpolate = isPlainObject(options.processor) && + isFunction(options.processor.interpolate) + ? options.processor.interpolate + : DEFAULT_INTERPOLATE; + const type = isPlainObject(options.processor) && isString(options.processor.type) + ? options.processor.type + : DEFAULT_MESSAGE_DATA_TYPE; + const linked = (key, ...args) => { + const [arg1, arg2] = args; + let type = 'text'; + let modifier = ''; + if (args.length === 1) { + if (isObject(arg1)) { + modifier = arg1.modifier || modifier; + type = arg1.type || type; + } + else if (isString(arg1)) { + modifier = arg1 || modifier; + } + } + else if (args.length === 2) { + if (isString(arg1)) { + modifier = arg1 || modifier; + } + if (isString(arg2)) { + type = arg2 || type; + } + } + const ret = message(key)(ctx); + const msg = + // The message in vnode resolved with linked are returned as an array by processor.nomalize + type === 'vnode' && isArray(ret) && modifier + ? ret[0] + : ret; + return modifier ? _modifier(modifier)(msg, type) : msg; + }; + const ctx = { + ["list" /* HelperNameMap.LIST */]: list, + ["named" /* HelperNameMap.NAMED */]: named, + ["plural" /* HelperNameMap.PLURAL */]: plural, + ["linked" /* HelperNameMap.LINKED */]: linked, + ["message" /* HelperNameMap.MESSAGE */]: message, + ["type" /* HelperNameMap.TYPE */]: type, + ["interpolate" /* HelperNameMap.INTERPOLATE */]: interpolate, + ["normalize" /* HelperNameMap.NORMALIZE */]: normalize, + ["values" /* HelperNameMap.VALUES */]: assign(create(), _list, _named) + }; + return ctx; +} + +let devtools = null; +function setDevToolsHook(hook) { + devtools = hook; +} +function initI18nDevTools(i18n, version, meta) { + // TODO: queue if devtools is undefined + devtools && + devtools.emit("i18n:init" /* IntlifyDevToolsHooks.I18nInit */, { + timestamp: Date.now(), + i18n, + version, + meta + }); +} +const translateDevTools = /* #__PURE__*/ createDevToolsHook("function:translate" /* IntlifyDevToolsHooks.FunctionTranslate */); +function createDevToolsHook(hook) { + return (payloads) => devtools && devtools.emit(hook, payloads); +} + +const code$3 = CompileWarnCodes.__EXTEND_POINT__; +const inc$3 = incrementer(code$3); +const CoreWarnCodes = { + NOT_FOUND_KEY: code$3, // 2 + FALLBACK_TO_TRANSLATE: inc$3(), // 3 + CANNOT_FORMAT_NUMBER: inc$3(), // 4 + FALLBACK_TO_NUMBER_FORMAT: inc$3(), // 5 + CANNOT_FORMAT_DATE: inc$3(), // 6 + FALLBACK_TO_DATE_FORMAT: inc$3(), // 7 + EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc$3(), // 8 + __EXTEND_POINT__: inc$3() // 9 +}; +/** @internal */ +const warnMessages$1 = { + [CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`, + [CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`, + [CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`, + [CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]: `This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future.` +}; +function getWarnMessage$1(code, ...args) { + return format(warnMessages$1[code], ...args); +} + +const code$2 = CompileErrorCodes.__EXTEND_POINT__; +const inc$2 = incrementer(code$2); +const CoreErrorCodes = { + INVALID_ARGUMENT: code$2, // 17 + INVALID_DATE_ARGUMENT: inc$2(), // 18 + INVALID_ISO_DATE_ARGUMENT: inc$2(), // 19 + NOT_SUPPORT_NON_STRING_MESSAGE: inc$2(), // 20 + NOT_SUPPORT_LOCALE_PROMISE_VALUE: inc$2(), // 21 + NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: inc$2(), // 22 + NOT_SUPPORT_LOCALE_TYPE: inc$2(), // 23 + __EXTEND_POINT__: inc$2() // 24 +}; +function createCoreError(code) { + return createCompileError(code, null, { messages: errorMessages$1 } ); +} +/** @internal */ +const errorMessages$1 = { + [CoreErrorCodes.INVALID_ARGUMENT]: 'Invalid arguments', + [CoreErrorCodes.INVALID_DATE_ARGUMENT]: 'The date provided is an invalid Date object.' + + 'Make sure your Date represents a valid date.', + [CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: 'The argument provided is not a valid ISO date string', + [CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE]: 'Not support non-string message', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]: 'cannot support promise value', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]: 'cannot support async function', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: 'cannot support locale type' +}; + +/** @internal */ +function getLocale(context, options) { + return options.locale != null + ? resolveLocale(options.locale) + : resolveLocale(context.locale); +} +let _resolveLocale; +/** @internal */ +function resolveLocale(locale) { + if (isString(locale)) { + return locale; + } + else { + if (isFunction(locale)) { + if (locale.resolvedOnce && _resolveLocale != null) { + return _resolveLocale; + } + else if (locale.constructor.name === 'Function') { + const resolve = locale(); + if (isPromise(resolve)) { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE); + } + return (_resolveLocale = resolve); + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION); + } + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE); + } + } +} +/** + * Fallback with simple implemenation + * + * @remarks + * A fallback locale function implemented with a simple fallback algorithm. + * + * Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nGeneral + */ +function fallbackWithSimple(ctx, fallback, start // eslint-disable-line @typescript-eslint/no-unused-vars +) { + // prettier-ignore + return [...new Set([ + start, + ...(isArray(fallback) + ? fallback + : isObject(fallback) + ? Object.keys(fallback) + : isString(fallback) + ? [fallback] + : [start]) + ])]; +} +/** + * Fallback with locale chain + * + * @remarks + * A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @VueI18nGeneral + */ +function fallbackWithLocaleChain(ctx, fallback, start) { + const startLocale = isString(start) ? start : DEFAULT_LOCALE; + const context = ctx; + if (!context.__localeChainCache) { + context.__localeChainCache = new Map(); + } + let chain = context.__localeChainCache.get(startLocale); + if (!chain) { + chain = []; + // first block defined by start + let block = [start]; + // while any intervening block found + while (isArray(block)) { + block = appendBlockToChain(chain, block, fallback); + } + // prettier-ignore + // last block defined by default + const defaults = isArray(fallback) || !isPlainObject(fallback) + ? fallback + : fallback['default'] + ? fallback['default'] + : null; + // convert defaults to array + block = isString(defaults) ? [defaults] : defaults; + if (isArray(block)) { + appendBlockToChain(chain, block, false); + } + context.__localeChainCache.set(startLocale, chain); + } + return chain; +} +function appendBlockToChain(chain, block, blocks) { + let follow = true; + for (let i = 0; i < block.length && isBoolean(follow); i++) { + const locale = block[i]; + if (isString(locale)) { + follow = appendLocaleToChain(chain, block[i], blocks); + } + } + return follow; +} +function appendLocaleToChain(chain, locale, blocks) { + let follow; + const tokens = locale.split('-'); + do { + const target = tokens.join('-'); + follow = appendItemToChain(chain, target, blocks); + tokens.splice(-1, 1); + } while (tokens.length && follow === true); + return follow; +} +function appendItemToChain(chain, target, blocks) { + let follow = false; + if (!chain.includes(target)) { + follow = true; + if (target) { + follow = target[target.length - 1] !== '!'; + const locale = target.replace(/!/g, ''); + chain.push(locale); + if ((isArray(blocks) || isPlainObject(blocks)) && + blocks[locale] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + follow = blocks[locale]; + } + } + } + return follow; +} + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Intlify core-base version + * @internal + */ +const VERSION$1 = '9.14.5'; +const NOT_REOSLVED = -1; +const DEFAULT_LOCALE = 'en-US'; +const MISSING_RESOLVE_VALUE = ''; +const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`; +function getDefaultLinkedModifiers() { + return { + upper: (val, type) => { + // prettier-ignore + return type === 'text' && isString(val) + ? val.toUpperCase() + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? val.children.toUpperCase() + : val; + }, + lower: (val, type) => { + // prettier-ignore + return type === 'text' && isString(val) + ? val.toLowerCase() + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? val.children.toLowerCase() + : val; + }, + capitalize: (val, type) => { + // prettier-ignore + return (type === 'text' && isString(val) + ? capitalize(val) + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? capitalize(val.children) + : val); + } + }; +} +let _compiler; +let _resolver; +/** + * Register the message resolver + * + * @param resolver - A {@link MessageResolver} function + * + * @VueI18nGeneral + */ +function registerMessageResolver(resolver) { + _resolver = resolver; +} +let _fallbacker; +/** + * Register the locale fallbacker + * + * @param fallbacker - A {@link LocaleFallbacker} function + * + * @VueI18nGeneral + */ +function registerLocaleFallbacker(fallbacker) { + _fallbacker = fallbacker; +} +// Additional Meta for Intlify DevTools +let _additionalMeta = null; +/* #__NO_SIDE_EFFECTS__ */ +const setAdditionalMeta = (meta) => { + _additionalMeta = meta; +}; +/* #__NO_SIDE_EFFECTS__ */ +const getAdditionalMeta = () => _additionalMeta; +let _fallbackContext = null; +const setFallbackContext = (context) => { + _fallbackContext = context; +}; +const getFallbackContext = () => _fallbackContext; +// ID for CoreContext +let _cid = 0; +function createCoreContext(options = {}) { + // setup options + const onWarn = isFunction(options.onWarn) ? options.onWarn : warn; + const version = isString(options.version) ? options.version : VERSION$1; + const locale = isString(options.locale) || isFunction(options.locale) + ? options.locale + : DEFAULT_LOCALE; + const _locale = isFunction(locale) ? DEFAULT_LOCALE : locale; + const fallbackLocale = isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + isString(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale; + const messages = isPlainObject(options.messages) + ? options.messages + : createResources(_locale); + const datetimeFormats = isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : createResources(_locale) + ; + const numberFormats = isPlainObject(options.numberFormats) + ? options.numberFormats + : createResources(_locale) + ; + const modifiers = assign(create(), options.modifiers, getDefaultLinkedModifiers()); + const pluralRules = options.pluralRules || create(); + const missing = isFunction(options.missing) ? options.missing : null; + const missingWarn = isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + const fallbackWarn = isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + const fallbackFormat = !!options.fallbackFormat; + const unresolving = !!options.unresolving; + const postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + const processor = isPlainObject(options.processor) ? options.processor : null; + const warnHtmlMessage = isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const escapeParameter = !!options.escapeParameter; + const messageCompiler = isFunction(options.messageCompiler) + ? options.messageCompiler + : _compiler; + if (isFunction(options.messageCompiler)) { + warnOnce(getWarnMessage$1(CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER)); + } + const messageResolver = isFunction(options.messageResolver) + ? options.messageResolver + : _resolver || resolveWithKeyValue; + const localeFallbacker = isFunction(options.localeFallbacker) + ? options.localeFallbacker + : _fallbacker || fallbackWithSimple; + const fallbackContext = isObject(options.fallbackContext) + ? options.fallbackContext + : undefined; + // setup internal options + const internalOptions = options; + const __datetimeFormatters = isObject(internalOptions.__datetimeFormatters) + ? internalOptions.__datetimeFormatters + : new Map() + ; + const __numberFormatters = isObject(internalOptions.__numberFormatters) + ? internalOptions.__numberFormatters + : new Map() + ; + const __meta = isObject(internalOptions.__meta) ? internalOptions.__meta : {}; + _cid++; + const context = { + version, + cid: _cid, + locale, + fallbackLocale, + messages, + modifiers, + pluralRules, + missing, + missingWarn, + fallbackWarn, + fallbackFormat, + unresolving, + postTranslation, + processor, + warnHtmlMessage, + escapeParameter, + messageCompiler, + messageResolver, + localeFallbacker, + fallbackContext, + onWarn, + __meta + }; + { + context.datetimeFormats = datetimeFormats; + context.numberFormats = numberFormats; + context.__datetimeFormatters = __datetimeFormatters; + context.__numberFormatters = __numberFormatters; + } + // for vue-devtools timeline event + { + context.__v_emitter = + internalOptions.__v_emitter != null + ? internalOptions.__v_emitter + : undefined; + } + // NOTE: experimental !! + { + initI18nDevTools(context, version, __meta); + } + return context; +} +const createResources = (locale) => ({ [locale]: create() }); +/** @internal */ +function isTranslateFallbackWarn(fallback, key) { + return fallback instanceof RegExp ? fallback.test(key) : fallback; +} +/** @internal */ +function isTranslateMissingWarn(missing, key) { + return missing instanceof RegExp ? missing.test(key) : missing; +} +/** @internal */ +function handleMissing(context, key, locale, missingWarn, type) { + const { missing, onWarn } = context; + // for vue-devtools timeline event + { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("missing" /* VueDevToolsTimelineEvents.MISSING */, { + locale, + key, + type, + groupId: `${type}:${key}` + }); + } + } + if (missing !== null) { + const ret = missing(context, locale, key, type); + return isString(ret) ? ret : key; + } + else { + if (isTranslateMissingWarn(missingWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.NOT_FOUND_KEY, { key, locale })); + } + return key; + } +} +/** @internal */ +function updateFallbackLocale(ctx, locale, fallback) { + const context = ctx; + context.__localeChainCache = new Map(); + ctx.localeFallbacker(ctx, fallback, locale); +} +/** @internal */ +function isAlmostSameLocale(locale, compareLocale) { + if (locale === compareLocale) + return false; + return locale.split('-')[0] === compareLocale.split('-')[0]; +} +/** @internal */ +function isImplicitFallback(targetLocale, locales) { + const index = locales.indexOf(targetLocale); + if (index === -1) { + return false; + } + for (let i = index + 1; i < locales.length; i++) { + if (isAlmostSameLocale(targetLocale, locales[i])) { + return true; + } + } + return false; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +const NOOP_MESSAGE_FUNCTION = () => ''; +const isMessageFunction = (val) => isFunction(val); +// implementation of `translate` function +function translate(context, ...args) { + const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context; + const [key, options] = parseTranslateArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const escapeParameter = isBoolean(options.escapeParameter) + ? options.escapeParameter + : context.escapeParameter; + const resolvedMessage = !!options.resolvedMessage; + // prettier-ignore + const defaultMsgOrKey = isString(options.default) || isBoolean(options.default) // default by function option + ? !isBoolean(options.default) + ? options.default + : (!messageCompiler ? () => key : key) + : fallbackFormat // default by `fallbackFormat` option + ? (!messageCompiler ? () => key : key) + : ''; + const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== ''; + const locale = getLocale(context, options); + // escape params + escapeParameter && escapeParams(options); + // resolve message format + // eslint-disable-next-line prefer-const + let [formatScope, targetLocale, message] = !resolvedMessage + ? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) + : [ + key, + locale, + messages[locale] || create() + ]; + // NOTE: + // Fix to work around `ssrTransfrom` bug in Vite. + // https://github.com/vitejs/vite/issues/4306 + // To get around this, use temporary variables. + // https://github.com/nuxt/framework/issues/1461#issuecomment-954606243 + let format = formatScope; + // if you use default message, set it as message format! + let cacheBaseKey = key; + if (!resolvedMessage && + !(isString(format) || + isMessageAST(format) || + isMessageFunction(format))) { + if (enableDefaultMsg) { + format = defaultMsgOrKey; + cacheBaseKey = format; + } + } + // checking message format and target locale + if (!resolvedMessage && + (!(isString(format) || + isMessageAST(format) || + isMessageFunction(format)) || + !isString(targetLocale))) { + return unresolving ? NOT_REOSLVED : key; + } + // TODO: refactor + if (isString(format) && context.messageCompiler == null) { + warn(`The message format compilation is not supported in this build. ` + + `Because message compiler isn't included. ` + + `You need to pre-compilation all message format. ` + + `So translate function return '${key}'.`); + return key; + } + // setup compile error detecting + let occurred = false; + const onError = () => { + occurred = true; + }; + // compile message format + const msg = !isMessageFunction(format) + ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) + : format; + // if occurred compile error, return the message format + if (occurred) { + return format; + } + // evaluate message with context + const ctxOptions = getMessageContextOptions(context, targetLocale, message, options); + const msgContext = createMessageContext(ctxOptions); + const messaged = evaluateMessage(context, msg, msgContext); + // if use post translation option, proceed it with handler + let ret = postTranslation + ? postTranslation(messaged, key) + : messaged; + // apply HTML sanitization for security + if (escapeParameter && isString(ret)) { + ret = sanitizeTranslatedHtml(ret); + } + // NOTE: experimental !! + { + // prettier-ignore + const payloads = { + timestamp: Date.now(), + key: isString(key) + ? key + : isMessageFunction(format) + ? format.key + : '', + locale: targetLocale || (isMessageFunction(format) + ? format.locale + : ''), + format: isString(format) + ? format + : isMessageFunction(format) + ? format.source + : '', + message: ret + }; + payloads.meta = assign({}, context.__meta, getAdditionalMeta() || {}); + translateDevTools(payloads); + } + return ret; +} +function escapeParams(options) { + if (isArray(options.list)) { + options.list = options.list.map(item => isString(item) ? escapeHtml(item) : item); + } + else if (isObject(options.named)) { + Object.keys(options.named).forEach(key => { + if (isString(options.named[key])) { + options.named[key] = escapeHtml(options.named[key]); + } + }); + } +} +function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) { + const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context; + const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any + let message = create(); + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'translate'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + !isAlmostSameLocale(locale, targetLocale) && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.FALLBACK_TO_TRANSLATE, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + message = + messages[targetLocale] || create(); + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-resolve-start'; + endTag = 'intlify-message-resolve-end'; + mark && mark(startTag); + } + if ((format = resolveValue(message, key)) === null) { + // if null, resolve with object key path + format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any + } + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start && format) { + emitter.emit("message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, { + type: "message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, + key, + message: format, + time: end - start, + groupId: `${type}:${key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message resolve', startTag, endTag); + } + } + if (isString(format) || isMessageAST(format) || isMessageFunction(format)) { + break; + } + if (!isImplicitFallback(targetLocale, locales)) { + const missingRet = handleMissing(context, // eslint-disable-line @typescript-eslint/no-explicit-any + key, targetLocale, missingWarn, type); + if (missingRet !== key) { + format = missingRet; + } + } + from = to; + } + return [format, targetLocale, message]; +} +function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) { + const { messageCompiler, warnHtmlMessage } = context; + if (isMessageFunction(format)) { + const msg = format; + msg.locale = msg.locale || targetLocale; + msg.key = msg.key || key; + return msg; + } + if (messageCompiler == null) { + const msg = (() => format); + msg.locale = targetLocale; + msg.key = key; + return msg; + } + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-compilation-start'; + endTag = 'intlify-message-compilation-end'; + mark && mark(startTag); + } + const msg = messageCompiler(format, getCompileContext(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, onError)); + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, { + type: "message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, + message: format, + time: end - start, + groupId: `${'translate'}:${key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message compilation', startTag, endTag); + } + } + msg.locale = targetLocale; + msg.key = key; + msg.source = format; + return msg; +} +function evaluateMessage(context, msg, msgCtx) { + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-evaluation-start'; + endTag = 'intlify-message-evaluation-end'; + mark && mark(startTag); + } + const messaged = msg(msgCtx); + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, { + type: "message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, + value: messaged, + time: end - start, + groupId: `${'translate'}:${msg.key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message evaluation', startTag, endTag); + } + } + return messaged; +} +/** @internal */ +function parseTranslateArgs(...args) { + const [arg1, arg2, arg3] = args; + const options = create(); + if (!isString(arg1) && + !isNumber(arg1) && + !isMessageFunction(arg1) && + !isMessageAST(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + // prettier-ignore + const key = isNumber(arg1) + ? String(arg1) + : isMessageFunction(arg1) + ? arg1 + : arg1; + if (isNumber(arg2)) { + options.plural = arg2; + } + else if (isString(arg2)) { + options.default = arg2; + } + else if (isPlainObject(arg2) && !isEmptyObject(arg2)) { + options.named = arg2; + } + else if (isArray(arg2)) { + options.list = arg2; + } + if (isNumber(arg3)) { + options.plural = arg3; + } + else if (isString(arg3)) { + options.default = arg3; + } + else if (isPlainObject(arg3)) { + assign(options, arg3); + } + return [key, options]; +} +function getCompileContext(context, locale, key, source, warnHtmlMessage, onError) { + return { + locale, + key, + warnHtmlMessage, + onError: (err) => { + onError && onError(err); + { + const _source = getSourceForCodeFrame(source); + const message = `Message compilation error: ${err.message}`; + const codeFrame = err.location && + _source && + generateCodeFrame(_source, err.location.start.offset, err.location.end.offset); + const emitter = context.__v_emitter; + if (emitter && _source) { + emitter.emit("compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */, { + message: _source, + error: err.message, + start: err.location && err.location.start.offset, + end: err.location && err.location.end.offset, + groupId: `${'translate'}:${key}` + }); + } + console.error(codeFrame ? `${message}\n${codeFrame}` : message); + } + }, + onCacheKey: (source) => generateFormatCacheKey(locale, key, source) + }; +} +function getSourceForCodeFrame(source) { + if (isString(source)) { + return source; + } + else { + if (source.loc && source.loc.source) { + return source.loc.source; + } + } +} +function getMessageContextOptions(context, locale, message, options) { + const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context; + const resolveMessage = (key) => { + let val = resolveValue(message, key); + // fallback to root context + if (val == null && fallbackContext) { + const [, , message] = resolveMessageFormat(fallbackContext, key, locale, fallbackLocale, fallbackWarn, missingWarn); + val = resolveValue(message, key); + } + if (isString(val) || isMessageAST(val)) { + let occurred = false; + const onError = () => { + occurred = true; + }; + const msg = compileMessageFormat(context, key, locale, val, key, onError); + return !occurred + ? msg + : NOOP_MESSAGE_FUNCTION; + } + else if (isMessageFunction(val)) { + return val; + } + else { + // TODO: should be implemented warning message + return NOOP_MESSAGE_FUNCTION; + } + }; + const ctxOptions = { + locale, + modifiers, + pluralRules, + messages: resolveMessage + }; + if (context.processor) { + ctxOptions.processor = context.processor; + } + if (options.list) { + ctxOptions.list = options.list; + } + if (options.named) { + ctxOptions.named = options.named; + } + if (isNumber(options.plural)) { + ctxOptions.pluralIndex = options.plural; + } + return ctxOptions; +} + +const intlDefined = typeof Intl !== 'undefined'; +const Availabilities = { + dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined', + numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined' +}; + +// implementation of `datetime` function +function datetime(context, ...args) { + const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __datetimeFormatters } = context; + if (!Availabilities.dateTimeFormat) { + onWarn(getWarnMessage$1(CoreWarnCodes.CANNOT_FORMAT_DATE)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseDateTimeArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!isString(key) || key === '') { + return new Intl.DateTimeFormat(locale, overrides).format(value); + } + // resolve format + let datetimeFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'datetime format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + datetimeFormat = + datetimeFormats[targetLocale] || {}; + format = datetimeFormat[key]; + if (isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!isPlainObject(format) || !isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __datetimeFormatters.get(id); + if (!formatter) { + formatter = new Intl.DateTimeFormat(targetLocale, assign({}, format, overrides)); + __datetimeFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); +} +/** @internal */ +const DATETIME_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'weekday', + 'era', + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second', + 'timeZoneName', + 'formatMatcher', + 'hour12', + 'timeZone', + 'dateStyle', + 'timeStyle', + 'calendar', + 'dayPeriod', + 'numberingSystem', + 'hourCycle', + 'fractionalSecondDigits' +]; +/** @internal */ +function parseDateTimeArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = create(); + let overrides = create(); + let value; + if (isString(arg1)) { + // Only allow ISO strings - other date formats are often supported, + // but may cause different results in different browsers. + const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/); + if (!matches) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + // Some browsers can not parse the iso datetime separated by space, + // this is a compromise solution by replace the 'T'/' ' with 'T' + const dateTime = matches[3] + ? matches[3].trim().startsWith('T') + ? `${matches[1].trim()}${matches[3].trim()}` + : `${matches[1].trim()}T${matches[3].trim()}` + : matches[1].trim(); + value = new Date(dateTime); + try { + // This will fail if the date is not valid + value.toISOString(); + } + catch (e) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + } + else if (isDate(arg1)) { + if (isNaN(arg1.getTime())) { + throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT); + } + value = arg1; + } + else if (isNumber(arg1)) { + value = arg1; + } + else { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + if (isString(arg2)) { + options.key = arg2; + } + else if (isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isPlainObject(arg3)) { + overrides = arg3; + } + if (isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; +} +/** @internal */ +function clearDateTimeFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__datetimeFormatters.has(id)) { + continue; + } + context.__datetimeFormatters.delete(id); + } +} + +// implementation of `number` function +function number(context, ...args) { + const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __numberFormatters } = context; + if (!Availabilities.numberFormat) { + onWarn(getWarnMessage$1(CoreWarnCodes.CANNOT_FORMAT_NUMBER)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseNumberArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!isString(key) || key === '') { + return new Intl.NumberFormat(locale, overrides).format(value); + } + // resolve format + let numberFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'number format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + numberFormat = + numberFormats[targetLocale] || {}; + format = numberFormat[key]; + if (isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!isPlainObject(format) || !isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __numberFormatters.get(id); + if (!formatter) { + formatter = new Intl.NumberFormat(targetLocale, assign({}, format, overrides)); + __numberFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); +} +/** @internal */ +const NUMBER_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'style', + 'currency', + 'currencyDisplay', + 'currencySign', + 'useGrouping', + 'minimumIntegerDigits', + 'minimumFractionDigits', + 'maximumFractionDigits', + 'minimumSignificantDigits', + 'maximumSignificantDigits', + 'compactDisplay', + 'notation', + 'signDisplay', + 'unit', + 'unitDisplay', + 'roundingMode', + 'roundingPriority', + 'roundingIncrement', + 'trailingZeroDisplay' +]; +/** @internal */ +function parseNumberArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = create(); + let overrides = create(); + if (!isNumber(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + const value = arg1; + if (isString(arg2)) { + options.key = arg2; + } + else if (isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isPlainObject(arg3)) { + overrides = arg3; + } + if (isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; +} +/** @internal */ +function clearNumberFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__numberFormatters.has(id)) { + continue; + } + context.__numberFormatters.delete(id); + } +} + +/** + * Vue I18n Version + * + * @remarks + * Semver format. Same format as the package.json `version` field. + * + * @VueI18nGeneral + */ +const VERSION = '9.14.5'; +/** + * This is only called development env + * istanbul-ignore-next + */ +function initDev() { + { + { + console.info(`You are running a development build of vue-i18n.\n` + + `Make sure to use the production build (*.prod.js) when deploying for production.`); + } + } +} + +const code$1 = CoreWarnCodes.__EXTEND_POINT__; +const inc$1 = incrementer(code$1); +const I18nWarnCodes = { + FALLBACK_TO_ROOT: code$1, // 9 + NOT_SUPPORTED_PRESERVE: inc$1(), // 10 + NOT_SUPPORTED_FORMATTER: inc$1(), // 11 + NOT_SUPPORTED_PRESERVE_DIRECTIVE: inc$1(), // 12 + NOT_SUPPORTED_GET_CHOICE_INDEX: inc$1(), // 13 + COMPONENT_NAME_LEGACY_COMPATIBLE: inc$1(), // 14 + NOT_FOUND_PARENT_SCOPE: inc$1(), // 15 + IGNORE_OBJ_FLATTEN: inc$1(), // 16 + NOTICE_DROP_ALLOW_COMPOSITION: inc$1(), // 17 + NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG: inc$1() // 18 +}; +const warnMessages = { + [I18nWarnCodes.FALLBACK_TO_ROOT]: `Fall back to {type} '{key}' with root locale.`, + [I18nWarnCodes.NOT_SUPPORTED_PRESERVE]: `Not supported 'preserve'.`, + [I18nWarnCodes.NOT_SUPPORTED_FORMATTER]: `Not supported 'formatter'.`, + [I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE]: `Not supported 'preserveDirectiveContent'.`, + [I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX]: `Not supported 'getChoiceIndex'.`, + [I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE]: `Component name legacy compatible: '{name}' -> 'i18n'`, + [I18nWarnCodes.NOT_FOUND_PARENT_SCOPE]: `Not found parent scope. use the global scope.`, + [I18nWarnCodes.IGNORE_OBJ_FLATTEN]: `Ignore object flatten: '{key}' key has an string value`, + [I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION]: `'allowComposition' option will be dropped in the next major version. For more information, please see 👉 https://tinyurl.com/2p97mcze`, + [I18nWarnCodes.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG]: `'translateExistCompatible' option will be dropped in the next major version.` +}; +function getWarnMessage(code, ...args) { + return format(warnMessages[code], ...args); +} + +const code = CoreErrorCodes.__EXTEND_POINT__; +const inc = incrementer(code); +const I18nErrorCodes = { + // composer module errors + UNEXPECTED_RETURN_TYPE: code, // 24 + // legacy module errors + INVALID_ARGUMENT: inc(), // 25 + // i18n module errors + MUST_BE_CALL_SETUP_TOP: inc(), // 26 + NOT_INSTALLED: inc(), // 27 + NOT_AVAILABLE_IN_LEGACY_MODE: inc(), // 28 + // directive module errors + REQUIRED_VALUE: inc(), // 29 + INVALID_VALUE: inc(), // 30 + // vue-devtools errors + CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN: inc(), // 31 + NOT_INSTALLED_WITH_PROVIDE: inc(), // 32 + // unexpected error + UNEXPECTED_ERROR: inc(), // 33 + // not compatible legacy vue-i18n constructor + NOT_COMPATIBLE_LEGACY_VUE_I18N: inc(), // 34 + // bridge support vue 2.x only + BRIDGE_SUPPORT_VUE_2_ONLY: inc(), // 35 + // need to define `i18n` option in `allowComposition: true` and `useScope: 'local' at `useI18n`` + MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION: inc(), // 36 + // Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly + NOT_AVAILABLE_COMPOSITION_IN_LEGACY: inc(), // 37 + // for enhancement + __EXTEND_POINT__: inc() // 38 +}; +function createI18nError(code, ...args) { + return createCompileError(code, null, { messages: errorMessages, args } ); +} +const errorMessages = { + [I18nErrorCodes.UNEXPECTED_RETURN_TYPE]: 'Unexpected return type in composer', + [I18nErrorCodes.INVALID_ARGUMENT]: 'Invalid argument', + [I18nErrorCodes.MUST_BE_CALL_SETUP_TOP]: 'Must be called at the top of a `setup` function', + [I18nErrorCodes.NOT_INSTALLED]: 'Need to install with `app.use` function', + [I18nErrorCodes.UNEXPECTED_ERROR]: 'Unexpected error', + [I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE]: 'Not available in legacy mode', + [I18nErrorCodes.REQUIRED_VALUE]: `Required in value: {0}`, + [I18nErrorCodes.INVALID_VALUE]: `Invalid value`, + [I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN]: `Cannot setup vue-devtools plugin`, + [I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE]: 'Need to install with `provide` function', + [I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N]: 'Not compatible legacy VueI18n.', + [I18nErrorCodes.BRIDGE_SUPPORT_VUE_2_ONLY]: 'vue-i18n-bridge support Vue 2.x only', + [I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION]: 'Must define ‘i18n’ option or custom block in Composition API with using local scope in Legacy API mode', + [I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY]: 'Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly' +}; + +const TranslateVNodeSymbol = +/* #__PURE__*/ makeSymbol('__translateVNode'); +const DatetimePartsSymbol = /* #__PURE__*/ makeSymbol('__datetimeParts'); +const NumberPartsSymbol = /* #__PURE__*/ makeSymbol('__numberParts'); +const EnableEmitter = /* #__PURE__*/ makeSymbol('__enableEmitter'); +const DisableEmitter = /* #__PURE__*/ makeSymbol('__disableEmitter'); +const SetPluralRulesSymbol = makeSymbol('__setPluralRules'); +const InejctWithOptionSymbol = +/* #__PURE__*/ makeSymbol('__injectWithOption'); +const DisposeSymbol = /* #__PURE__*/ makeSymbol('__dispose'); +const __VUE_I18N_BRIDGE__ = '__VUE_I18N_BRIDGE__'; + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Transform flat json in obj to normal json in obj + */ +function handleFlatJson(obj) { + // check obj + if (!isObject(obj)) { + return obj; + } + if (isMessageAST(obj)) { + return obj; + } + for (const key in obj) { + // check key + if (!hasOwn(obj, key)) { + continue; + } + // handle for normal json + if (!key.includes('.')) { + // recursive process value if value is also a object + if (isObject(obj[key])) { + handleFlatJson(obj[key]); + } + } + // handle for flat json, transform to normal json + else { + // go to the last object + const subKeys = key.split('.'); + const lastIndex = subKeys.length - 1; + let currentObj = obj; + let hasStringValue = false; + for (let i = 0; i < lastIndex; i++) { + if (subKeys[i] === '__proto__') { + throw new Error(`unsafe key: ${subKeys[i]}`); + } + if (!(subKeys[i] in currentObj)) { + currentObj[subKeys[i]] = create(); + } + if (!isObject(currentObj[subKeys[i]])) { + warn(getWarnMessage(I18nWarnCodes.IGNORE_OBJ_FLATTEN, { + key: subKeys[i] + })); + hasStringValue = true; + break; + } + currentObj = currentObj[subKeys[i]]; + } + // update last object value, delete old property + if (!hasStringValue) { + if (!isMessageAST(currentObj)) { + currentObj[subKeys[lastIndex]] = obj[key]; + delete obj[key]; + } + else { + /** + * NOTE: + * if the last object is a message AST and subKeys[lastIndex] has message AST prop key, ignore to copy and key deletion + */ + if (!AST_NODE_PROPS_KEYS.includes(subKeys[lastIndex])) { + delete obj[key]; + } + } + } + // recursive process value if value is also a object + if (!isMessageAST(currentObj)) { + const target = currentObj[subKeys[lastIndex]]; + if (isObject(target)) { + handleFlatJson(target); + } + } + } + } + return obj; +} +function getLocaleMessages(locale, options) { + const { messages, __i18n, messageResolver, flatJson } = options; + // prettier-ignore + const ret = (isPlainObject(messages) + ? messages + : isArray(__i18n) + ? create() + : { [locale]: create() }); + // merge locale messages of i18n custom block + if (isArray(__i18n)) { + __i18n.forEach(custom => { + if ('locale' in custom && 'resource' in custom) { + const { locale, resource } = custom; + if (locale) { + ret[locale] = ret[locale] || create(); + deepCopy(resource, ret[locale]); + } + else { + deepCopy(resource, ret); + } + } + else { + isString(custom) && deepCopy(JSON.parse(custom), ret); + } + }); + } + // handle messages for flat json + if (messageResolver == null && flatJson) { + for (const key in ret) { + if (hasOwn(ret, key)) { + handleFlatJson(ret[key]); + } + } + } + return ret; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getComponentOptions(instance) { + return instance.type ; +} +function adjustI18nResources(gl, options, componentOptions // eslint-disable-line @typescript-eslint/no-explicit-any +) { + let messages = isObject(options.messages) + ? options.messages + : create(); + if ('__i18nGlobal' in componentOptions) { + messages = getLocaleMessages(gl.locale.value, { + messages, + __i18n: componentOptions.__i18nGlobal + }); + } + // merge locale messages + const locales = Object.keys(messages); + if (locales.length) { + locales.forEach(locale => { + gl.mergeLocaleMessage(locale, messages[locale]); + }); + } + { + // merge datetime formats + if (isObject(options.datetimeFormats)) { + const locales = Object.keys(options.datetimeFormats); + if (locales.length) { + locales.forEach(locale => { + gl.mergeDateTimeFormat(locale, options.datetimeFormats[locale]); + }); + } + } + // merge number formats + if (isObject(options.numberFormats)) { + const locales = Object.keys(options.numberFormats); + if (locales.length) { + locales.forEach(locale => { + gl.mergeNumberFormat(locale, options.numberFormats[locale]); + }); + } + } + } +} +function createTextNode(key) { + return createVNode(Text, null, key, 0) + ; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +/* eslint-disable @typescript-eslint/no-explicit-any */ +// extend VNode interface +const DEVTOOLS_META = '__INTLIFY_META__'; +const NOOP_RETURN_ARRAY = () => []; +const NOOP_RETURN_FALSE = () => false; +let composerID = 0; +function defineCoreMissingHandler(missing) { + return ((ctx, locale, key, type) => { + return missing(locale, key, getCurrentInstance() || undefined, type); + }); +} +// for Intlify DevTools +/* #__NO_SIDE_EFFECTS__ */ +const getMetaInfo = () => { + const instance = getCurrentInstance(); + let meta = null; // eslint-disable-line @typescript-eslint/no-explicit-any + return instance && (meta = getComponentOptions(instance)[DEVTOOLS_META]) + ? { [DEVTOOLS_META]: meta } // eslint-disable-line @typescript-eslint/no-explicit-any + : null; +}; +/** + * Create composer interface factory + * + * @internal + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function createComposer(options = {}, VueI18nLegacy) { + const { __root, __injectWithOption } = options; + const _isGlobal = __root === undefined; + const flatJson = options.flatJson; + const _ref = inBrowser ? ref : shallowRef; + const translateExistCompatible = !!options.translateExistCompatible; + { + if (translateExistCompatible && !false) { + warnOnce(getWarnMessage(I18nWarnCodes.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG)); + } + } + let _inheritLocale = isBoolean(options.inheritLocale) + ? options.inheritLocale + : true; + const _locale = _ref( + // prettier-ignore + __root && _inheritLocale + ? __root.locale.value + : isString(options.locale) + ? options.locale + : DEFAULT_LOCALE); + const _fallbackLocale = _ref( + // prettier-ignore + __root && _inheritLocale + ? __root.fallbackLocale.value + : isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale.value); + const _messages = _ref(getLocaleMessages(_locale.value, options)); + // prettier-ignore + const _datetimeFormats = _ref(isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : { [_locale.value]: {} }) + ; + // prettier-ignore + const _numberFormats = _ref(isPlainObject(options.numberFormats) + ? options.numberFormats + : { [_locale.value]: {} }) + ; + // warning suppress options + // prettier-ignore + let _missingWarn = __root + ? __root.missingWarn + : isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + // prettier-ignore + let _fallbackWarn = __root + ? __root.fallbackWarn + : isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + // prettier-ignore + let _fallbackRoot = __root + ? __root.fallbackRoot + : isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + // configure fall back to root + let _fallbackFormat = !!options.fallbackFormat; + // runtime missing + let _missing = isFunction(options.missing) ? options.missing : null; + let _runtimeMissing = isFunction(options.missing) + ? defineCoreMissingHandler(options.missing) + : null; + // postTranslation handler + let _postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + // prettier-ignore + let _warnHtmlMessage = __root + ? __root.warnHtmlMessage + : isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + let _escapeParameter = !!options.escapeParameter; + // custom linked modifiers + // prettier-ignore + const _modifiers = __root + ? __root.modifiers + : isPlainObject(options.modifiers) + ? options.modifiers + : {}; + // pluralRules + let _pluralRules = options.pluralRules || (__root && __root.pluralRules); + // runtime context + // eslint-disable-next-line prefer-const + let _context; + const getCoreContext = () => { + _isGlobal && setFallbackContext(null); + const ctxOptions = { + version: VERSION, + locale: _locale.value, + fallbackLocale: _fallbackLocale.value, + messages: _messages.value, + modifiers: _modifiers, + pluralRules: _pluralRules, + missing: _runtimeMissing === null ? undefined : _runtimeMissing, + missingWarn: _missingWarn, + fallbackWarn: _fallbackWarn, + fallbackFormat: _fallbackFormat, + unresolving: true, + postTranslation: _postTranslation === null ? undefined : _postTranslation, + warnHtmlMessage: _warnHtmlMessage, + escapeParameter: _escapeParameter, + messageResolver: options.messageResolver, + messageCompiler: options.messageCompiler, + __meta: { framework: 'vue' } + }; + { + ctxOptions.datetimeFormats = _datetimeFormats.value; + ctxOptions.numberFormats = _numberFormats.value; + ctxOptions.__datetimeFormatters = isPlainObject(_context) + ? _context.__datetimeFormatters + : undefined; + ctxOptions.__numberFormatters = isPlainObject(_context) + ? _context.__numberFormatters + : undefined; + } + { + ctxOptions.__v_emitter = isPlainObject(_context) + ? _context.__v_emitter + : undefined; + } + const ctx = createCoreContext(ctxOptions); + _isGlobal && setFallbackContext(ctx); + return ctx; + }; + _context = getCoreContext(); + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + // track reactivity + function trackReactivityValues() { + return [ + _locale.value, + _fallbackLocale.value, + _messages.value, + _datetimeFormats.value, + _numberFormats.value + ] + ; + } + // locale + const locale = computed({ + get: () => _locale.value, + set: val => { + _locale.value = val; + _context.locale = _locale.value; + } + }); + // fallbackLocale + const fallbackLocale = computed({ + get: () => _fallbackLocale.value, + set: val => { + _fallbackLocale.value = val; + _context.fallbackLocale = _fallbackLocale.value; + updateFallbackLocale(_context, _locale.value, val); + } + }); + // messages + const messages = computed(() => _messages.value); + // datetimeFormats + const datetimeFormats = /* #__PURE__*/ computed(() => _datetimeFormats.value); + // numberFormats + const numberFormats = /* #__PURE__*/ computed(() => _numberFormats.value); + // getPostTranslationHandler + function getPostTranslationHandler() { + return isFunction(_postTranslation) ? _postTranslation : null; + } + // setPostTranslationHandler + function setPostTranslationHandler(handler) { + _postTranslation = handler; + _context.postTranslation = handler; + } + // getMissingHandler + function getMissingHandler() { + return _missing; + } + // setMissingHandler + function setMissingHandler(handler) { + if (handler !== null) { + _runtimeMissing = defineCoreMissingHandler(handler); + } + _missing = handler; + _context.missing = _runtimeMissing; + } + function isResolvedTranslateMessage(type, arg // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + return type !== 'translate' || !arg.resolvedMessage; + } + const wrapWithDeps = (fn, argumentParser, warnType, fallbackSuccess, fallbackFail, successCondition) => { + trackReactivityValues(); // track reactive dependency + // NOTE: experimental !! + let ret; + try { + if (true || false) { + setAdditionalMeta(getMetaInfo()); + } + if (!_isGlobal) { + _context.fallbackContext = __root + ? getFallbackContext() + : undefined; + } + ret = fn(_context); + } + finally { + if (!_isGlobal) { + _context.fallbackContext = undefined; + } + } + if ((warnType !== 'translate exists' && // for not `te` (e.g `t`) + isNumber(ret) && + ret === NOT_REOSLVED) || + (warnType === 'translate exists' && !ret) // for `te` + ) { + const [key, arg2] = argumentParser(); + if (__root && + isString(key) && + isResolvedTranslateMessage(warnType, arg2)) { + if (_fallbackRoot && + (isTranslateFallbackWarn(_fallbackWarn, key) || + isTranslateMissingWarn(_missingWarn, key))) { + warn(getWarnMessage(I18nWarnCodes.FALLBACK_TO_ROOT, { + key, + type: warnType + })); + } + // for vue-devtools timeline event + { + const { __v_emitter: emitter } = _context; + if (emitter && _fallbackRoot) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type: warnType, + key, + to: 'global', + groupId: `${warnType}:${key}` + }); + } + } + } + return __root && _fallbackRoot + ? fallbackSuccess(__root) + : fallbackFail(key); + } + else if (successCondition(ret)) { + return ret; + } + else { + /* istanbul ignore next */ + throw createI18nError(I18nErrorCodes.UNEXPECTED_RETURN_TYPE); + } + }; + // t + function t(...args) { + return wrapWithDeps(context => Reflect.apply(translate, null, [context, ...args]), () => parseTranslateArgs(...args), 'translate', root => Reflect.apply(root.t, root, [...args]), key => key, val => isString(val)); + } + // rt + function rt(...args) { + const [arg1, arg2, arg3] = args; + if (arg3 && !isObject(arg3)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + return t(...[arg1, arg2, assign({ resolvedMessage: true }, arg3 || {})]); + } + // d + function d(...args) { + return wrapWithDeps(context => Reflect.apply(datetime, null, [context, ...args]), () => parseDateTimeArgs(...args), 'datetime format', root => Reflect.apply(root.d, root, [...args]), () => MISSING_RESOLVE_VALUE, val => isString(val)); + } + // n + function n(...args) { + return wrapWithDeps(context => Reflect.apply(number, null, [context, ...args]), () => parseNumberArgs(...args), 'number format', root => Reflect.apply(root.n, root, [...args]), () => MISSING_RESOLVE_VALUE, val => isString(val)); + } + // for custom processor + function normalize(values) { + return values.map(val => isString(val) || isNumber(val) || isBoolean(val) + ? createTextNode(String(val)) + : val); + } + const interpolate = (val) => val; + const processor = { + normalize, + interpolate, + type: 'vnode' + }; + // translateVNode, using for `i18n-t` component + function translateVNode(...args) { + return wrapWithDeps(context => { + let ret; + const _context = context; + try { + _context.processor = processor; + ret = Reflect.apply(translate, null, [_context, ...args]); + } + finally { + _context.processor = null; + } + return ret; + }, () => parseTranslateArgs(...args), 'translate', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[TranslateVNodeSymbol](...args), key => [createTextNode(key)], val => isArray(val)); + } + // numberParts, using for `i18n-n` component + function numberParts(...args) { + return wrapWithDeps(context => Reflect.apply(number, null, [context, ...args]), () => parseNumberArgs(...args), 'number format', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[NumberPartsSymbol](...args), NOOP_RETURN_ARRAY, val => isString(val) || isArray(val)); + } + // datetimeParts, using for `i18n-d` component + function datetimeParts(...args) { + return wrapWithDeps(context => Reflect.apply(datetime, null, [context, ...args]), () => parseDateTimeArgs(...args), 'datetime format', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[DatetimePartsSymbol](...args), NOOP_RETURN_ARRAY, val => isString(val) || isArray(val)); + } + function setPluralRules(rules) { + _pluralRules = rules; + _context.pluralRules = _pluralRules; + } + // te + function te(key, locale) { + return wrapWithDeps(() => { + if (!key) { + return false; + } + const targetLocale = isString(locale) ? locale : _locale.value; + const message = getLocaleMessage(targetLocale); + const resolved = _context.messageResolver(message, key); + return !translateExistCompatible + ? isMessageAST(resolved) || + isMessageFunction(resolved) || + isString(resolved) + : resolved != null; + }, () => [key], 'translate exists', root => { + return Reflect.apply(root.te, root, [key, locale]); + }, NOOP_RETURN_FALSE, val => isBoolean(val)); + } + function resolveMessages(key) { + let messages = null; + const locales = fallbackWithLocaleChain(_context, _fallbackLocale.value, _locale.value); + for (let i = 0; i < locales.length; i++) { + const targetLocaleMessages = _messages.value[locales[i]] || {}; + const messageValue = _context.messageResolver(targetLocaleMessages, key); + if (messageValue != null) { + messages = messageValue; + break; + } + } + return messages; + } + // tm + function tm(key) { + const messages = resolveMessages(key); + // prettier-ignore + return messages != null + ? messages + : __root + ? __root.tm(key) || {} + : {}; + } + // getLocaleMessage + function getLocaleMessage(locale) { + return (_messages.value[locale] || {}); + } + // setLocaleMessage + function setLocaleMessage(locale, message) { + if (flatJson) { + const _message = { [locale]: message }; + for (const key in _message) { + if (hasOwn(_message, key)) { + handleFlatJson(_message[key]); + } + } + message = _message[locale]; + } + _messages.value[locale] = message; + _context.messages = _messages.value; + } + // mergeLocaleMessage + function mergeLocaleMessage(locale, message) { + _messages.value[locale] = _messages.value[locale] || {}; + const _message = { [locale]: message }; + if (flatJson) { + for (const key in _message) { + if (hasOwn(_message, key)) { + handleFlatJson(_message[key]); + } + } + } + message = _message[locale]; + deepCopy(message, _messages.value[locale]); + _context.messages = _messages.value; + } + // getDateTimeFormat + function getDateTimeFormat(locale) { + return _datetimeFormats.value[locale] || {}; + } + // setDateTimeFormat + function setDateTimeFormat(locale, format) { + _datetimeFormats.value[locale] = format; + _context.datetimeFormats = _datetimeFormats.value; + clearDateTimeFormat(_context, locale, format); + } + // mergeDateTimeFormat + function mergeDateTimeFormat(locale, format) { + _datetimeFormats.value[locale] = assign(_datetimeFormats.value[locale] || {}, format); + _context.datetimeFormats = _datetimeFormats.value; + clearDateTimeFormat(_context, locale, format); + } + // getNumberFormat + function getNumberFormat(locale) { + return _numberFormats.value[locale] || {}; + } + // setNumberFormat + function setNumberFormat(locale, format) { + _numberFormats.value[locale] = format; + _context.numberFormats = _numberFormats.value; + clearNumberFormat(_context, locale, format); + } + // mergeNumberFormat + function mergeNumberFormat(locale, format) { + _numberFormats.value[locale] = assign(_numberFormats.value[locale] || {}, format); + _context.numberFormats = _numberFormats.value; + clearNumberFormat(_context, locale, format); + } + // for debug + composerID++; + // watch root locale & fallbackLocale + if (__root && inBrowser) { + watch(__root.locale, (val) => { + if (_inheritLocale) { + _locale.value = val; + _context.locale = val; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }); + watch(__root.fallbackLocale, (val) => { + if (_inheritLocale) { + _fallbackLocale.value = val; + _context.fallbackLocale = val; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }); + } + // define basic composition API! + const composer = { + id: composerID, + locale, + fallbackLocale, + get inheritLocale() { + return _inheritLocale; + }, + set inheritLocale(val) { + _inheritLocale = val; + if (val && __root) { + _locale.value = __root.locale.value; + _fallbackLocale.value = __root.fallbackLocale.value; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }, + get availableLocales() { + return Object.keys(_messages.value).sort(); + }, + messages, + get modifiers() { + return _modifiers; + }, + get pluralRules() { + return _pluralRules || {}; + }, + get isGlobal() { + return _isGlobal; + }, + get missingWarn() { + return _missingWarn; + }, + set missingWarn(val) { + _missingWarn = val; + _context.missingWarn = _missingWarn; + }, + get fallbackWarn() { + return _fallbackWarn; + }, + set fallbackWarn(val) { + _fallbackWarn = val; + _context.fallbackWarn = _fallbackWarn; + }, + get fallbackRoot() { + return _fallbackRoot; + }, + set fallbackRoot(val) { + _fallbackRoot = val; + }, + get fallbackFormat() { + return _fallbackFormat; + }, + set fallbackFormat(val) { + _fallbackFormat = val; + _context.fallbackFormat = _fallbackFormat; + }, + get warnHtmlMessage() { + return _warnHtmlMessage; + }, + set warnHtmlMessage(val) { + _warnHtmlMessage = val; + _context.warnHtmlMessage = val; + }, + get escapeParameter() { + return _escapeParameter; + }, + set escapeParameter(val) { + _escapeParameter = val; + _context.escapeParameter = val; + }, + t, + getLocaleMessage, + setLocaleMessage, + mergeLocaleMessage, + getPostTranslationHandler, + setPostTranslationHandler, + getMissingHandler, + setMissingHandler, + [SetPluralRulesSymbol]: setPluralRules + }; + { + composer.datetimeFormats = datetimeFormats; + composer.numberFormats = numberFormats; + composer.rt = rt; + composer.te = te; + composer.tm = tm; + composer.d = d; + composer.n = n; + composer.getDateTimeFormat = getDateTimeFormat; + composer.setDateTimeFormat = setDateTimeFormat; + composer.mergeDateTimeFormat = mergeDateTimeFormat; + composer.getNumberFormat = getNumberFormat; + composer.setNumberFormat = setNumberFormat; + composer.mergeNumberFormat = mergeNumberFormat; + composer[InejctWithOptionSymbol] = __injectWithOption; + composer[TranslateVNodeSymbol] = translateVNode; + composer[DatetimePartsSymbol] = datetimeParts; + composer[NumberPartsSymbol] = numberParts; + } + // for vue-devtools timeline event + { + composer[EnableEmitter] = (emitter) => { + _context.__v_emitter = emitter; + }; + composer[DisableEmitter] = () => { + _context.__v_emitter = undefined; + }; + } + return composer; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Convert to I18n Composer Options from VueI18n Options + * + * @internal + */ +function convertComposerOptions(options) { + const locale = isString(options.locale) ? options.locale : DEFAULT_LOCALE; + const fallbackLocale = isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : locale; + const missing = isFunction(options.missing) ? options.missing : undefined; + const missingWarn = isBoolean(options.silentTranslationWarn) || + isRegExp(options.silentTranslationWarn) + ? !options.silentTranslationWarn + : true; + const fallbackWarn = isBoolean(options.silentFallbackWarn) || + isRegExp(options.silentFallbackWarn) + ? !options.silentFallbackWarn + : true; + const fallbackRoot = isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + const fallbackFormat = !!options.formatFallbackMessages; + const modifiers = isPlainObject(options.modifiers) ? options.modifiers : {}; + const pluralizationRules = options.pluralizationRules; + const postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : undefined; + const warnHtmlMessage = isString(options.warnHtmlInMessage) + ? options.warnHtmlInMessage !== 'off' + : true; + const escapeParameter = !!options.escapeParameterHtml; + const inheritLocale = isBoolean(options.sync) ? options.sync : true; + if (options.formatter) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + } + if (options.preserveDirectiveContent) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + } + let messages = options.messages; + if (isPlainObject(options.sharedMessages)) { + const sharedMessages = options.sharedMessages; + const locales = Object.keys(sharedMessages); + messages = locales.reduce((messages, locale) => { + const message = messages[locale] || (messages[locale] = {}); + assign(message, sharedMessages[locale]); + return messages; + }, (messages || {})); + } + const { __i18n, __root, __injectWithOption } = options; + const datetimeFormats = options.datetimeFormats; + const numberFormats = options.numberFormats; + const flatJson = options.flatJson; + const translateExistCompatible = options + .translateExistCompatible; + return { + locale, + fallbackLocale, + messages, + flatJson, + datetimeFormats, + numberFormats, + missing, + missingWarn, + fallbackWarn, + fallbackRoot, + fallbackFormat, + modifiers, + pluralRules: pluralizationRules, + postTranslation, + warnHtmlMessage, + escapeParameter, + messageResolver: options.messageResolver, + inheritLocale, + translateExistCompatible, + __i18n, + __root, + __injectWithOption + }; +} +/** + * create VueI18n interface factory + * + * @internal + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function createVueI18n(options = {}, VueI18nLegacy) { + { + const composer = createComposer(convertComposerOptions(options)); + const { __extender } = options; + // defines VueI18n + const vueI18n = { + // id + id: composer.id, + // locale + get locale() { + return composer.locale.value; + }, + set locale(val) { + composer.locale.value = val; + }, + // fallbackLocale + get fallbackLocale() { + return composer.fallbackLocale.value; + }, + set fallbackLocale(val) { + composer.fallbackLocale.value = val; + }, + // messages + get messages() { + return composer.messages.value; + }, + // datetimeFormats + get datetimeFormats() { + return composer.datetimeFormats.value; + }, + // numberFormats + get numberFormats() { + return composer.numberFormats.value; + }, + // availableLocales + get availableLocales() { + return composer.availableLocales; + }, + // formatter + get formatter() { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + // dummy + return { + interpolate() { + return []; + } + }; + }, + set formatter(val) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + }, + // missing + get missing() { + return composer.getMissingHandler(); + }, + set missing(handler) { + composer.setMissingHandler(handler); + }, + // silentTranslationWarn + get silentTranslationWarn() { + return isBoolean(composer.missingWarn) + ? !composer.missingWarn + : composer.missingWarn; + }, + set silentTranslationWarn(val) { + composer.missingWarn = isBoolean(val) ? !val : val; + }, + // silentFallbackWarn + get silentFallbackWarn() { + return isBoolean(composer.fallbackWarn) + ? !composer.fallbackWarn + : composer.fallbackWarn; + }, + set silentFallbackWarn(val) { + composer.fallbackWarn = isBoolean(val) ? !val : val; + }, + // modifiers + get modifiers() { + return composer.modifiers; + }, + // formatFallbackMessages + get formatFallbackMessages() { + return composer.fallbackFormat; + }, + set formatFallbackMessages(val) { + composer.fallbackFormat = val; + }, + // postTranslation + get postTranslation() { + return composer.getPostTranslationHandler(); + }, + set postTranslation(handler) { + composer.setPostTranslationHandler(handler); + }, + // sync + get sync() { + return composer.inheritLocale; + }, + set sync(val) { + composer.inheritLocale = val; + }, + // warnInHtmlMessage + get warnHtmlInMessage() { + return composer.warnHtmlMessage ? 'warn' : 'off'; + }, + set warnHtmlInMessage(val) { + composer.warnHtmlMessage = val !== 'off'; + }, + // escapeParameterHtml + get escapeParameterHtml() { + return composer.escapeParameter; + }, + set escapeParameterHtml(val) { + composer.escapeParameter = val; + }, + // preserveDirectiveContent + get preserveDirectiveContent() { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + return true; + }, + set preserveDirectiveContent(val) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + }, + // pluralizationRules + get pluralizationRules() { + return composer.pluralRules || {}; + }, + // for internal + __composer: composer, + // t + t(...args) { + const [arg1, arg2, arg3] = args; + const options = {}; + let list = null; + let named = null; + if (!isString(arg1)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + const key = arg1; + if (isString(arg2)) { + options.locale = arg2; + } + else if (isArray(arg2)) { + list = arg2; + } + else if (isPlainObject(arg2)) { + named = arg2; + } + if (isArray(arg3)) { + list = arg3; + } + else if (isPlainObject(arg3)) { + named = arg3; + } + // return composer.t(key, (list || named || {}) as any, options) + return Reflect.apply(composer.t, composer, [ + key, + (list || named || {}), + options + ]); + }, + rt(...args) { + return Reflect.apply(composer.rt, composer, [...args]); + }, + // tc + tc(...args) { + const [arg1, arg2, arg3] = args; + const options = { plural: 1 }; + let list = null; + let named = null; + if (!isString(arg1)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + const key = arg1; + if (isString(arg2)) { + options.locale = arg2; + } + else if (isNumber(arg2)) { + options.plural = arg2; + } + else if (isArray(arg2)) { + list = arg2; + } + else if (isPlainObject(arg2)) { + named = arg2; + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isArray(arg3)) { + list = arg3; + } + else if (isPlainObject(arg3)) { + named = arg3; + } + // return composer.t(key, (list || named || {}) as any, options) + return Reflect.apply(composer.t, composer, [ + key, + (list || named || {}), + options + ]); + }, + // te + te(key, locale) { + return composer.te(key, locale); + }, + // tm + tm(key) { + return composer.tm(key); + }, + // getLocaleMessage + getLocaleMessage(locale) { + return composer.getLocaleMessage(locale); + }, + // setLocaleMessage + setLocaleMessage(locale, message) { + composer.setLocaleMessage(locale, message); + }, + // mergeLocaleMessage + mergeLocaleMessage(locale, message) { + composer.mergeLocaleMessage(locale, message); + }, + // d + d(...args) { + return Reflect.apply(composer.d, composer, [...args]); + }, + // getDateTimeFormat + getDateTimeFormat(locale) { + return composer.getDateTimeFormat(locale); + }, + // setDateTimeFormat + setDateTimeFormat(locale, format) { + composer.setDateTimeFormat(locale, format); + }, + // mergeDateTimeFormat + mergeDateTimeFormat(locale, format) { + composer.mergeDateTimeFormat(locale, format); + }, + // n + n(...args) { + return Reflect.apply(composer.n, composer, [...args]); + }, + // getNumberFormat + getNumberFormat(locale) { + return composer.getNumberFormat(locale); + }, + // setNumberFormat + setNumberFormat(locale, format) { + composer.setNumberFormat(locale, format); + }, + // mergeNumberFormat + mergeNumberFormat(locale, format) { + composer.mergeNumberFormat(locale, format); + }, + // getChoiceIndex + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getChoiceIndex(choice, choicesLength) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX)); + return -1; + } + }; + vueI18n.__extender = __extender; + // for vue-devtools timeline event + { + vueI18n.__enableEmitter = (emitter) => { + const __composer = composer; + __composer[EnableEmitter] && __composer[EnableEmitter](emitter); + }; + vueI18n.__disableEmitter = () => { + const __composer = composer; + __composer[DisableEmitter] && __composer[DisableEmitter](); + }; + } + return vueI18n; + } +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +const baseFormatProps = { + tag: { + type: [String, Object] + }, + locale: { + type: String + }, + scope: { + type: String, + // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050 + validator: (val /* ComponentI18nScope */) => val === 'parent' || val === 'global', + default: 'parent' /* ComponentI18nScope */ + }, + i18n: { + type: Object + } +}; + +function getInterpolateArg( +// eslint-disable-next-line @typescript-eslint/no-explicit-any +{ slots }, // SetupContext, +keys) { + if (keys.length === 1 && keys[0] === 'default') { + // default slot with list + const ret = slots.default ? slots.default() : []; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return ret.reduce((slot, current) => { + return [ + ...slot, + // prettier-ignore + ...(current.type === Fragment ? current.children : [current] + ) + ]; + }, []); + } + else { + // named slots + return keys.reduce((arg, key) => { + const slot = slots[key]; + if (slot) { + arg[key] = slot(); + } + return arg; + }, create()); + } +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getFragmentableTag(tag) { + return Fragment ; +} + +const TranslationImpl = /*#__PURE__*/ defineComponent({ + /* eslint-disable */ + name: 'i18n-t', + props: assign({ + keypath: { + type: String, + required: true + }, + plural: { + type: [Number, String], + // eslint-disable-next-line @typescript-eslint/no-explicit-any + validator: (val) => isNumber(val) || !isNaN(val) + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const { slots, attrs } = context; + // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050 + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return () => { + const keys = Object.keys(slots).filter(key => key !== '_'); + const options = create(); + if (props.locale) { + options.locale = props.locale; + } + if (props.plural !== undefined) { + options.plural = isString(props.plural) ? +props.plural : props.plural; + } + const arg = getInterpolateArg(context, keys); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const children = i18n[TranslateVNodeSymbol](props.keypath, arg, options); + const assignedAttrs = assign(create(), attrs); + const tag = isString(props.tag) || isObject(props.tag) + ? props.tag + : getFragmentableTag(); + return h(tag, assignedAttrs, children); + }; + } +}); +/** + * export the public type for h/tsx inference + * also to avoid inline import() in generated d.ts files + */ +/** + * Translation Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [TranslationProps](component#translationprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Component Interpolation](../guide/advanced/component) + * + * @example + * ```html + *
+ * + * + * {{ $t('tos') }} + * + * + *
+ * ``` + * ```js + * import { createApp } from 'vue' + * import { createI18n } from 'vue-i18n' + * + * const messages = { + * en: { + * tos: 'Term of Service', + * term: 'I accept xxx {0}.' + * }, + * ja: { + * tos: '利用規約', + * term: '私は xxx の{0}に同意します。' + * } + * } + * + * const i18n = createI18n({ + * locale: 'en', + * messages + * }) + * + * const app = createApp({ + * data: { + * url: '/term' + * } + * }).use(i18n).mount('#app') + * ``` + * + * @VueI18nComponent + */ +const Translation = TranslationImpl; +const I18nT = Translation; + +function isVNode(target) { + return isArray(target) && !isString(target[0]); +} +function renderFormatter(props, context, slotKeys, partFormatter) { + const { slots, attrs } = context; + return () => { + const options = { part: true }; + let overrides = create(); + if (props.locale) { + options.locale = props.locale; + } + if (isString(props.format)) { + options.key = props.format; + } + else if (isObject(props.format)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (isString(props.format.key)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + options.key = props.format.key; + } + // Filter out number format options only + overrides = Object.keys(props.format).reduce((options, prop) => { + return slotKeys.includes(prop) + ? assign(create(), options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any + : options; + }, create()); + } + const parts = partFormatter(...[props.value, options, overrides]); + let children = [options.key]; + if (isArray(parts)) { + children = parts.map((part, index) => { + const slot = slots[part.type]; + const node = slot + ? slot({ [part.type]: part.value, index, parts }) + : [part.value]; + if (isVNode(node)) { + node[0].key = `${part.type}-${index}`; + } + return node; + }); + } + else if (isString(parts)) { + children = [parts]; + } + const assignedAttrs = assign(create(), attrs); + const tag = isString(props.tag) || isObject(props.tag) + ? props.tag + : getFragmentableTag(); + return h(tag, assignedAttrs, children); + }; +} + +const NumberFormatImpl = /*#__PURE__*/ defineComponent({ + /* eslint-disable */ + name: 'i18n-n', + props: assign({ + value: { + type: Number, + required: true + }, + format: { + type: [String, Object] + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return renderFormatter(props, context, NUMBER_FORMAT_OPTIONS_KEYS, (...args) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + i18n[NumberPartsSymbol](...args)); + } +}); +/** + * export the public type for h/tsx inference + * also to avoid inline import() in generated d.ts files + */ +/** + * Number Format Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [FormattableProps](component#formattableprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Custom Formatting](../guide/essentials/number#custom-formatting) + * + * @VueI18nDanger + * Not supported IE, due to no support `Intl.NumberFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts) + * + * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-numberformat) + * + * @VueI18nComponent + */ +const NumberFormat = NumberFormatImpl; +const I18nN = NumberFormat; + +const DatetimeFormatImpl = /* #__PURE__*/ defineComponent({ + /* eslint-disable */ + name: 'i18n-d', + props: assign({ + value: { + type: [Number, Date], + required: true + }, + format: { + type: [String, Object] + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return renderFormatter(props, context, DATETIME_FORMAT_OPTIONS_KEYS, (...args) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + i18n[DatetimePartsSymbol](...args)); + } +}); +/** + * Datetime Format Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [FormattableProps](component#formattableprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Custom Formatting](../guide/essentials/datetime#custom-formatting) + * + * @VueI18nDanger + * Not supported IE, due to no support `Intl.DateTimeFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts) + * + * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-datetimeformat) + * + * @VueI18nComponent + */ +const DatetimeFormat = DatetimeFormatImpl; +const I18nD = DatetimeFormat; + +function getComposer$2(i18n, instance) { + const i18nInternal = i18n; + if (i18n.mode === 'composition') { + return (i18nInternal.__getInstance(instance) || i18n.global); + } + else { + const vueI18n = i18nInternal.__getInstance(instance); + return vueI18n != null + ? vueI18n.__composer + : i18n.global.__composer; + } +} +function vTDirective(i18n) { + const _process = (binding) => { + const { instance, modifiers, value } = binding; + /* istanbul ignore if */ + if (!instance || !instance.$) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const composer = getComposer$2(i18n, instance.$); + if (modifiers.preserve) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE)); + } + const parsedValue = parseValue(value); + return [ + Reflect.apply(composer.t, composer, [...makeParams(parsedValue)]), + composer + ]; + }; + const register = (el, binding) => { + const [textContent, composer] = _process(binding); + if (inBrowser && i18n.global === composer) { + // global scope only + el.__i18nWatcher = watch(composer.locale, () => { + binding.instance && binding.instance.$forceUpdate(); + }); + } + el.__composer = composer; + el.textContent = textContent; + }; + const unregister = (el) => { + if (inBrowser && el.__i18nWatcher) { + el.__i18nWatcher(); + el.__i18nWatcher = undefined; + delete el.__i18nWatcher; + } + if (el.__composer) { + el.__composer = undefined; + delete el.__composer; + } + }; + const update = (el, { value }) => { + if (el.__composer) { + const composer = el.__composer; + const parsedValue = parseValue(value); + el.textContent = Reflect.apply(composer.t, composer, [ + ...makeParams(parsedValue) + ]); + } + }; + const getSSRProps = (binding) => { + const [textContent] = _process(binding); + return { textContent }; + }; + return { + created: register, + unmounted: unregister, + beforeUpdate: update, + getSSRProps + }; +} +function parseValue(value) { + if (isString(value)) { + return { path: value }; + } + else if (isPlainObject(value)) { + if (!('path' in value)) { + throw createI18nError(I18nErrorCodes.REQUIRED_VALUE, 'path'); + } + return value; + } + else { + throw createI18nError(I18nErrorCodes.INVALID_VALUE); + } +} +function makeParams(value) { + const { path, locale, args, choice, plural } = value; + const options = {}; + const named = args || {}; + if (isString(locale)) { + options.locale = locale; + } + if (isNumber(choice)) { + options.plural = choice; + } + if (isNumber(plural)) { + options.plural = plural; + } + return [path, named, options]; +} + +function apply(app, i18n, ...options) { + const pluginOptions = isPlainObject(options[0]) + ? options[0] + : {}; + const useI18nComponentName = !!pluginOptions.useI18nComponentName; + const globalInstall = isBoolean(pluginOptions.globalInstall) + ? pluginOptions.globalInstall + : true; + if (globalInstall && useI18nComponentName) { + warn(getWarnMessage(I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE, { + name: Translation.name + })); + } + if (globalInstall) { + [!useI18nComponentName ? Translation.name : 'i18n', 'I18nT'].forEach(name => app.component(name, Translation)); + [NumberFormat.name, 'I18nN'].forEach(name => app.component(name, NumberFormat)); + [DatetimeFormat.name, 'I18nD'].forEach(name => app.component(name, DatetimeFormat)); + } + // install directive + { + app.directive('t', vTDirective(i18n)); + } +} + +var global$1 = (typeof global !== "undefined" ? global : + typeof self !== "undefined" ? self : + typeof window !== "undefined" ? window : {}); + +function getDevtoolsGlobalHook() { + return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__; +} +function getTarget() { + // @ts-ignore + return (typeof navigator !== 'undefined' && typeof window !== 'undefined') + ? window + : typeof global$1 !== 'undefined' + ? global$1 + : {}; +} +const isProxyAvailable = typeof Proxy === 'function'; + +const HOOK_SETUP = 'devtools-plugin:setup'; +const HOOK_PLUGIN_SETTINGS_SET = 'plugin:settings:set'; + +let supported; +let perf; +function isPerformanceSupported() { + var _a; + if (supported !== undefined) { + return supported; + } + if (typeof window !== 'undefined' && window.performance) { + supported = true; + perf = window.performance; + } + else if (typeof global$1 !== 'undefined' && ((_a = global$1.perf_hooks) === null || _a === void 0 ? void 0 : _a.performance)) { + supported = true; + perf = global$1.perf_hooks.performance; + } + else { + supported = false; + } + return supported; +} +function now() { + return isPerformanceSupported() ? perf.now() : Date.now(); +} + +class ApiProxy { + constructor(plugin, hook) { + this.target = null; + this.targetQueue = []; + this.onQueue = []; + this.plugin = plugin; + this.hook = hook; + const defaultSettings = {}; + if (plugin.settings) { + for (const id in plugin.settings) { + const item = plugin.settings[id]; + defaultSettings[id] = item.defaultValue; + } + } + const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin.id}`; + let currentSettings = Object.assign({}, defaultSettings); + try { + const raw = localStorage.getItem(localSettingsSaveId); + const data = JSON.parse(raw); + Object.assign(currentSettings, data); + } + catch (e) { + // noop + } + this.fallbacks = { + getSettings() { + return currentSettings; + }, + setSettings(value) { + try { + localStorage.setItem(localSettingsSaveId, JSON.stringify(value)); + } + catch (e) { + // noop + } + currentSettings = value; + }, + now() { + return now(); + }, + }; + if (hook) { + hook.on(HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => { + if (pluginId === this.plugin.id) { + this.fallbacks.setSettings(value); + } + }); + } + this.proxiedOn = new Proxy({}, { + get: (_target, prop) => { + if (this.target) { + return this.target.on[prop]; + } + else { + return (...args) => { + this.onQueue.push({ + method: prop, + args, + }); + }; + } + }, + }); + this.proxiedTarget = new Proxy({}, { + get: (_target, prop) => { + if (this.target) { + return this.target[prop]; + } + else if (prop === 'on') { + return this.proxiedOn; + } + else if (Object.keys(this.fallbacks).includes(prop)) { + return (...args) => { + this.targetQueue.push({ + method: prop, + args, + resolve: () => { }, + }); + return this.fallbacks[prop](...args); + }; + } + else { + return (...args) => { + return new Promise(resolve => { + this.targetQueue.push({ + method: prop, + args, + resolve, + }); + }); + }; + } + }, + }); + } + async setRealTarget(target) { + this.target = target; + for (const item of this.onQueue) { + this.target.on[item.method](...item.args); + } + for (const item of this.targetQueue) { + item.resolve(await this.target[item.method](...item.args)); + } + } +} + +function setupDevtoolsPlugin(pluginDescriptor, setupFn) { + const descriptor = pluginDescriptor; + const target = getTarget(); + const hook = getDevtoolsGlobalHook(); + const enableProxy = isProxyAvailable && descriptor.enableEarlyProxy; + if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) { + hook.emit(HOOK_SETUP, pluginDescriptor, setupFn); + } + else { + const proxy = enableProxy ? new ApiProxy(descriptor, hook) : null; + const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || []; + list.push({ + pluginDescriptor: descriptor, + setupFn, + proxy, + }); + if (proxy) + setupFn(proxy.proxiedTarget); + } +} + +const VueDevToolsLabels = { + ["vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */]: 'Vue I18n devtools', + ["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */]: 'I18n Resources', + ["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */]: 'Vue I18n' +}; +const VueDevToolsPlaceholders = { + ["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */]: 'Search for scopes ...' +}; +const VueDevToolsTimelineColors = { + ["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */]: 0xffcd19 +}; + +const VUE_I18N_COMPONENT_TYPES = 'vue-i18n: composer properties'; +let devtoolsApi; +async function enableDevTools(app, i18n) { + return new Promise((resolve, reject) => { + try { + setupDevtoolsPlugin({ + id: "vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */, + label: VueDevToolsLabels["vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */], + packageName: 'vue-i18n', + homepage: 'https://vue-i18n.intlify.dev', + logo: 'https://vue-i18n.intlify.dev/vue-i18n-devtools-logo.png', + componentStateTypes: [VUE_I18N_COMPONENT_TYPES], + app: app // eslint-disable-line @typescript-eslint/no-explicit-any + }, api => { + devtoolsApi = api; + api.on.visitComponentTree(({ componentInstance, treeNode }) => { + updateComponentTreeTags(componentInstance, treeNode, i18n); + }); + api.on.inspectComponent(({ componentInstance, instanceData }) => { + if (componentInstance.vnode.el && + componentInstance.vnode.el.__VUE_I18N__ && + instanceData) { + if (i18n.mode === 'legacy') { + // ignore global scope on legacy mode + if (componentInstance.vnode.el.__VUE_I18N__ !== + i18n.global.__composer) { + inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__); + } + } + else { + inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__); + } + } + }); + api.addInspector({ + id: "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */, + label: VueDevToolsLabels["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */], + icon: 'language', + treeFilterPlaceholder: VueDevToolsPlaceholders["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */] + }); + api.on.getInspectorTree(payload => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + registerScope(payload, i18n); + } + }); + const roots = new Map(); + api.on.getInspectorState(async (payload) => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + api.unhighlightElement(); + inspectScope(payload, i18n); + if (payload.nodeId === 'global') { + if (!roots.has(payload.app)) { + const [root] = await api.getComponentInstances(payload.app); + roots.set(payload.app, root); + } + api.highlightElement(roots.get(payload.app)); + } + else { + const instance = getComponentInstance(payload.nodeId, i18n); + instance && api.highlightElement(instance); + } + } + }); + api.on.editInspectorState(payload => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + editScope(payload, i18n); + } + }); + api.addTimelineLayer({ + id: "vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */, + label: VueDevToolsLabels["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */], + color: VueDevToolsTimelineColors["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */] + }); + resolve(true); + }); + } + catch (e) { + console.error(e); + reject(false); + } + }); +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getI18nScopeLable(instance) { + return (instance.type.name || + instance.type.displayName || + instance.type.__file || + 'Anonymous'); +} +function updateComponentTreeTags(instance, // eslint-disable-line @typescript-eslint/no-explicit-any +treeNode, i18n) { + // prettier-ignore + const global = i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + if (instance && instance.vnode.el && instance.vnode.el.__VUE_I18N__) { + // add custom tags local scope only + if (instance.vnode.el.__VUE_I18N__ !== global) { + const tag = { + label: `i18n (${getI18nScopeLable(instance)} Scope)`, + textColor: 0x000000, + backgroundColor: 0xffcd19 + }; + treeNode.tags.push(tag); + } + } +} +function inspectComposer(instanceData, composer) { + const type = VUE_I18N_COMPONENT_TYPES; + instanceData.state.push({ + type, + key: 'locale', + editable: true, + value: composer.locale.value + }); + instanceData.state.push({ + type, + key: 'availableLocales', + editable: false, + value: composer.availableLocales + }); + instanceData.state.push({ + type, + key: 'fallbackLocale', + editable: true, + value: composer.fallbackLocale.value + }); + instanceData.state.push({ + type, + key: 'inheritLocale', + editable: true, + value: composer.inheritLocale + }); + instanceData.state.push({ + type, + key: 'messages', + editable: false, + value: getLocaleMessageValue(composer.messages.value) + }); + { + instanceData.state.push({ + type, + key: 'datetimeFormats', + editable: false, + value: composer.datetimeFormats.value + }); + instanceData.state.push({ + type, + key: 'numberFormats', + editable: false, + value: composer.numberFormats.value + }); + } +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getLocaleMessageValue(messages) { + const value = {}; + Object.keys(messages).forEach((key) => { + const v = messages[key]; + if (isFunction(v) && 'source' in v) { + value[key] = getMessageFunctionDetails(v); + } + else if (isMessageAST(v) && v.loc && v.loc.source) { + value[key] = v.loc.source; + } + else if (isObject(v)) { + value[key] = getLocaleMessageValue(v); + } + else { + value[key] = v; + } + }); + return value; +} +const ESC = { + '<': '<', + '>': '>', + '"': '"', + '&': '&' +}; +function escape(s) { + return s.replace(/[<>"&]/g, escapeChar); +} +function escapeChar(a) { + return ESC[a] || a; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getMessageFunctionDetails(func) { + const argString = func.source ? `("${escape(func.source)}")` : `(?)`; + return { + _custom: { + type: 'function', + display: `ƒ ${argString}` + } + }; +} +function registerScope(payload, i18n) { + payload.rootNodes.push({ + id: 'global', + label: 'Global Scope' + }); + // prettier-ignore + const global = i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + for (const [keyInstance, instance] of i18n.__instances) { + // prettier-ignore + const composer = i18n.mode === 'composition' + ? instance + : instance.__composer; + if (global === composer) { + continue; + } + payload.rootNodes.push({ + id: composer.id.toString(), + label: `${getI18nScopeLable(keyInstance)} Scope` + }); + } +} +function getComponentInstance(nodeId, i18n) { + let instance = null; + if (nodeId !== 'global') { + for (const [component, composer] of i18n.__instances.entries()) { + if (composer.id.toString() === nodeId) { + instance = component; + break; + } + } + } + return instance; +} +function getComposer$1(nodeId, i18n) { + if (nodeId === 'global') { + return i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + } + else { + const instance = Array.from(i18n.__instances.values()).find(item => item.id.toString() === nodeId); + if (instance) { + return i18n.mode === 'composition' + ? instance + : instance.__composer; + } + else { + return null; + } + } +} +function inspectScope(payload, i18n +// eslint-disable-next-line @typescript-eslint/no-explicit-any +) { + const composer = getComposer$1(payload.nodeId, i18n); + if (composer) { + // TODO: + // eslint-disable-next-line @typescript-eslint/no-explicit-any + payload.state = makeScopeInspectState(composer); + } + return null; +} +function makeScopeInspectState(composer) { + const state = {}; + const localeType = 'Locale related info'; + const localeStates = [ + { + type: localeType, + key: 'locale', + editable: true, + value: composer.locale.value + }, + { + type: localeType, + key: 'fallbackLocale', + editable: true, + value: composer.fallbackLocale.value + }, + { + type: localeType, + key: 'availableLocales', + editable: false, + value: composer.availableLocales + }, + { + type: localeType, + key: 'inheritLocale', + editable: true, + value: composer.inheritLocale + } + ]; + state[localeType] = localeStates; + const localeMessagesType = 'Locale messages info'; + const localeMessagesStates = [ + { + type: localeMessagesType, + key: 'messages', + editable: false, + value: getLocaleMessageValue(composer.messages.value) + } + ]; + state[localeMessagesType] = localeMessagesStates; + { + const datetimeFormatsType = 'Datetime formats info'; + const datetimeFormatsStates = [ + { + type: datetimeFormatsType, + key: 'datetimeFormats', + editable: false, + value: composer.datetimeFormats.value + } + ]; + state[datetimeFormatsType] = datetimeFormatsStates; + const numberFormatsType = 'Datetime formats info'; + const numberFormatsStates = [ + { + type: numberFormatsType, + key: 'numberFormats', + editable: false, + value: composer.numberFormats.value + } + ]; + state[numberFormatsType] = numberFormatsStates; + } + return state; +} +function addTimelineEvent(event, payload) { + if (devtoolsApi) { + let groupId; + if (payload && 'groupId' in payload) { + groupId = payload.groupId; + delete payload.groupId; + } + devtoolsApi.addTimelineEvent({ + layerId: "vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */, + event: { + title: event, + groupId, + time: Date.now(), + meta: {}, + data: payload || {}, + logType: event === "compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */ + ? 'error' + : event === "fallback" /* VueDevToolsTimelineEvents.FALBACK */ || + event === "missing" /* VueDevToolsTimelineEvents.MISSING */ + ? 'warning' + : 'default' + } + }); + } +} +function editScope(payload, i18n) { + const composer = getComposer$1(payload.nodeId, i18n); + if (composer) { + const [field] = payload.path; + if (field === 'locale' && isString(payload.state.value)) { + composer.locale.value = payload.state.value; + } + else if (field === 'fallbackLocale' && + (isString(payload.state.value) || + isArray(payload.state.value) || + isObject(payload.state.value))) { + composer.fallbackLocale.value = payload.state.value; + } + else if (field === 'inheritLocale' && isBoolean(payload.state.value)) { + composer.inheritLocale = payload.state.value; + } + } +} + +/** + * Supports compatibility for legacy vue-i18n APIs + * This mixin is used when we use vue-i18n@v9.x or later + */ +function defineMixin(vuei18n, composer, i18n) { + return { + beforeCreate() { + const instance = getCurrentInstance(); + /* istanbul ignore if */ + if (!instance) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const options = this.$options; + if (options.i18n) { + const optionsI18n = options.i18n; + if (options.__i18n) { + optionsI18n.__i18n = options.__i18n; + } + optionsI18n.__root = composer; + if (this === this.$root) { + // merge option and gttach global + this.$i18n = mergeToGlobal(vuei18n, optionsI18n); + } + else { + optionsI18n.__injectWithOption = true; + optionsI18n.__extender = i18n.__vueI18nExtend; + // atttach local VueI18n instance + this.$i18n = createVueI18n(optionsI18n); + // extend VueI18n instance + const _vueI18n = this.$i18n; + if (_vueI18n.__extender) { + _vueI18n.__disposer = _vueI18n.__extender(this.$i18n); + } + } + } + else if (options.__i18n) { + if (this === this.$root) { + // merge option and gttach global + this.$i18n = mergeToGlobal(vuei18n, options); + } + else { + // atttach local VueI18n instance + this.$i18n = createVueI18n({ + __i18n: options.__i18n, + __injectWithOption: true, + __extender: i18n.__vueI18nExtend, + __root: composer + }); + // extend VueI18n instance + const _vueI18n = this.$i18n; + if (_vueI18n.__extender) { + _vueI18n.__disposer = _vueI18n.__extender(this.$i18n); + } + } + } + else { + // attach global VueI18n instance + this.$i18n = vuei18n; + } + if (options.__i18nGlobal) { + adjustI18nResources(composer, options, options); + } + // defines vue-i18n legacy APIs + this.$t = (...args) => this.$i18n.t(...args); + this.$rt = (...args) => this.$i18n.rt(...args); + this.$tc = (...args) => this.$i18n.tc(...args); + this.$te = (key, locale) => this.$i18n.te(key, locale); + this.$d = (...args) => this.$i18n.d(...args); + this.$n = (...args) => this.$i18n.n(...args); + this.$tm = (key) => this.$i18n.tm(key); + i18n.__setInstance(instance, this.$i18n); + }, + mounted() { + /* istanbul ignore if */ + if (this.$el && + this.$i18n) { + const _vueI18n = this.$i18n; + this.$el.__VUE_I18N__ = _vueI18n.__composer; + const emitter = (this.__v_emitter = + createEmitter()); + _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter); + emitter.on('*', addTimelineEvent); + } + }, + unmounted() { + const instance = getCurrentInstance(); + /* istanbul ignore if */ + if (!instance) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const _vueI18n = this.$i18n; + /* istanbul ignore if */ + if (this.$el && + this.$el.__VUE_I18N__) { + if (this.__v_emitter) { + this.__v_emitter.off('*', addTimelineEvent); + delete this.__v_emitter; + } + if (this.$i18n) { + _vueI18n.__disableEmitter && _vueI18n.__disableEmitter(); + delete this.$el.__VUE_I18N__; + } + } + delete this.$t; + delete this.$rt; + delete this.$tc; + delete this.$te; + delete this.$d; + delete this.$n; + delete this.$tm; + if (_vueI18n.__disposer) { + _vueI18n.__disposer(); + delete _vueI18n.__disposer; + delete _vueI18n.__extender; + } + i18n.__deleteInstance(instance); + delete this.$i18n; + } + }; +} +function mergeToGlobal(g, options) { + g.locale = options.locale || g.locale; + g.fallbackLocale = options.fallbackLocale || g.fallbackLocale; + g.missing = options.missing || g.missing; + g.silentTranslationWarn = + options.silentTranslationWarn || g.silentFallbackWarn; + g.silentFallbackWarn = options.silentFallbackWarn || g.silentFallbackWarn; + g.formatFallbackMessages = + options.formatFallbackMessages || g.formatFallbackMessages; + g.postTranslation = options.postTranslation || g.postTranslation; + g.warnHtmlInMessage = options.warnHtmlInMessage || g.warnHtmlInMessage; + g.escapeParameterHtml = options.escapeParameterHtml || g.escapeParameterHtml; + g.sync = options.sync || g.sync; + g.__composer[SetPluralRulesSymbol](options.pluralizationRules || g.pluralizationRules); + const messages = getLocaleMessages(g.locale, { + messages: options.messages, + __i18n: options.__i18n + }); + Object.keys(messages).forEach(locale => g.mergeLocaleMessage(locale, messages[locale])); + if (options.datetimeFormats) { + Object.keys(options.datetimeFormats).forEach(locale => g.mergeDateTimeFormat(locale, options.datetimeFormats[locale])); + } + if (options.numberFormats) { + Object.keys(options.numberFormats).forEach(locale => g.mergeNumberFormat(locale, options.numberFormats[locale])); + } + return g; +} + +/** + * Injection key for {@link useI18n} + * + * @remarks + * The global injection key for I18n instances with `useI18n`. this injection key is used in Web Components. + * Specify the i18n instance created by {@link createI18n} together with `provide` function. + * + * @VueI18nGeneral + */ +const I18nInjectionKey = +/* #__PURE__*/ makeSymbol('global-vue-i18n'); +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types +function createI18n(options = {}, VueI18nLegacy) { + // prettier-ignore + const __legacyMode = isBoolean(options.legacy) + ? options.legacy + : true; + // prettier-ignore + const __globalInjection = isBoolean(options.globalInjection) + ? options.globalInjection + : true; + // prettier-ignore + const __allowComposition = __legacyMode + ? !!options.allowComposition + : true; + const __instances = new Map(); + const [globalScope, __global] = createGlobal(options, __legacyMode); + const symbol = /* #__PURE__*/ makeSymbol('vue-i18n' ); + { + if (__legacyMode && __allowComposition && !false) { + warn(getWarnMessage(I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION)); + } + } + function __getInstance(component) { + return __instances.get(component) || null; + } + function __setInstance(component, instance) { + __instances.set(component, instance); + } + function __deleteInstance(component) { + __instances.delete(component); + } + { + const i18n = { + // mode + get mode() { + return __legacyMode + ? 'legacy' + : 'composition'; + }, + // allowComposition + get allowComposition() { + return __allowComposition; + }, + // install plugin + async install(app, ...options) { + { + app.__VUE_I18N__ = i18n; + } + // setup global provider + app.__VUE_I18N_SYMBOL__ = symbol; + app.provide(app.__VUE_I18N_SYMBOL__, i18n); + // set composer & vuei18n extend hook options from plugin options + if (isPlainObject(options[0])) { + const opts = options[0]; + i18n.__composerExtend = + opts.__composerExtend; + i18n.__vueI18nExtend = + opts.__vueI18nExtend; + } + // global method and properties injection for Composition API + let globalReleaseHandler = null; + if (!__legacyMode && __globalInjection) { + globalReleaseHandler = injectGlobalFields(app, i18n.global); + } + // install built-in components and directive + { + apply(app, i18n, ...options); + } + // setup mixin for Legacy API + if (__legacyMode) { + app.mixin(defineMixin(__global, __global.__composer, i18n)); + } + // release global scope + const unmountApp = app.unmount; + app.unmount = () => { + globalReleaseHandler && globalReleaseHandler(); + i18n.dispose(); + unmountApp(); + }; + // setup vue-devtools plugin + { + const ret = await enableDevTools(app, i18n); + if (!ret) { + throw createI18nError(I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN); + } + const emitter = createEmitter(); + if (__legacyMode) { + const _vueI18n = __global; + _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter); + } + else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = __global; + _composer[EnableEmitter] && _composer[EnableEmitter](emitter); + } + emitter.on('*', addTimelineEvent); + } + }, + // global accessor + get global() { + return __global; + }, + dispose() { + globalScope.stop(); + }, + // @internal + __instances, + // @internal + __getInstance, + // @internal + __setInstance, + // @internal + __deleteInstance + }; + return i18n; + } +} +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function useI18n(options = {}) { + const instance = getCurrentInstance(); + if (instance == null) { + throw createI18nError(I18nErrorCodes.MUST_BE_CALL_SETUP_TOP); + } + if (!instance.isCE && + instance.appContext.app != null && + !instance.appContext.app.__VUE_I18N_SYMBOL__) { + throw createI18nError(I18nErrorCodes.NOT_INSTALLED); + } + const i18n = getI18nInstance(instance); + const gl = getGlobalComposer(i18n); + const componentOptions = getComponentOptions(instance); + const scope = getScope(options, componentOptions); + { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (i18n.mode === 'legacy' && !options.__useComponent) { + if (!i18n.allowComposition) { + throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE); + } + return useI18nForLegacy(instance, scope, gl, options); + } + } + if (scope === 'global') { + adjustI18nResources(gl, options, componentOptions); + return gl; + } + if (scope === 'parent') { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let composer = getComposer(i18n, instance, options.__useComponent); + if (composer == null) { + { + warn(getWarnMessage(I18nWarnCodes.NOT_FOUND_PARENT_SCOPE)); + } + composer = gl; + } + return composer; + } + const i18nInternal = i18n; + let composer = i18nInternal.__getInstance(instance); + if (composer == null) { + const composerOptions = assign({}, options); + if ('__i18n' in componentOptions) { + composerOptions.__i18n = componentOptions.__i18n; + } + if (gl) { + composerOptions.__root = gl; + } + composer = createComposer(composerOptions); + if (i18nInternal.__composerExtend) { + composer[DisposeSymbol] = + i18nInternal.__composerExtend(composer); + } + setupLifeCycle(i18nInternal, instance, composer); + i18nInternal.__setInstance(instance, composer); + } + return composer; +} +/** + * Cast to VueI18n legacy compatible type + * + * @remarks + * This API is provided only with [vue-i18n-bridge](https://vue-i18n.intlify.dev/guide/migration/ways.html#what-is-vue-i18n-bridge). + * + * The purpose of this function is to convert an {@link I18n} instance created with {@link createI18n | createI18n(legacy: true)} into a `vue-i18n@v8.x` compatible instance of `new VueI18n` in a TypeScript environment. + * + * @param i18n - An instance of {@link I18n} + * @returns A i18n instance which is casted to {@link VueI18n} type + * + * @VueI18nTip + * :new: provided by **vue-i18n-bridge only** + * + * @VueI18nGeneral + */ +/* #__NO_SIDE_EFFECTS__ */ +const castToVueI18n = (i18n +// eslint-disable-next-line @typescript-eslint/no-explicit-any +) => { + if (!(__VUE_I18N_BRIDGE__ in i18n)) { + throw createI18nError(I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N); + } + return i18n; +}; +function createGlobal(options, legacyMode, VueI18nLegacy // eslint-disable-line @typescript-eslint/no-explicit-any +) { + const scope = effectScope(); + { + const obj = legacyMode + ? scope.run(() => createVueI18n(options)) + : scope.run(() => createComposer(options)); + if (obj == null) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + return [scope, obj]; + } +} +function getI18nInstance(instance) { + { + const i18n = inject(!instance.isCE + ? instance.appContext.app.__VUE_I18N_SYMBOL__ + : I18nInjectionKey); + /* istanbul ignore if */ + if (!i18n) { + throw createI18nError(!instance.isCE + ? I18nErrorCodes.UNEXPECTED_ERROR + : I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE); + } + return i18n; + } +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getScope(options, componentOptions) { + // prettier-ignore + return isEmptyObject(options) + ? ('__i18n' in componentOptions) + ? 'local' + : 'global' + : !options.useScope + ? 'local' + : options.useScope; +} +function getGlobalComposer(i18n) { + // prettier-ignore + return i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer + ; +} +function getComposer(i18n, target, useComponent = false) { + let composer = null; + const root = target.root; + let current = getParentComponentInstance(target, useComponent); + while (current != null) { + const i18nInternal = i18n; + if (i18n.mode === 'composition') { + composer = i18nInternal.__getInstance(current); + } + else { + { + const vueI18n = i18nInternal.__getInstance(current); + if (vueI18n != null) { + composer = vueI18n + .__composer; + if (useComponent && + composer && + !composer[InejctWithOptionSymbol] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + composer = null; + } + } + } + } + if (composer != null) { + break; + } + if (root === current) { + break; + } + current = current.parent; + } + return composer; +} +function getParentComponentInstance(target, useComponent = false) { + if (target == null) { + return null; + } + { + // if `useComponent: true` will be specified, we get lexical scope owner instance for use-case slots + return !useComponent + ? target.parent + : target.vnode.ctx || target.parent; // eslint-disable-line @typescript-eslint/no-explicit-any + } +} +function setupLifeCycle(i18n, target, composer) { + let emitter = null; + { + onMounted(() => { + // inject composer instance to DOM for intlify-devtools + if (target.vnode.el) { + target.vnode.el.__VUE_I18N__ = composer; + emitter = createEmitter(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = composer; + _composer[EnableEmitter] && _composer[EnableEmitter](emitter); + emitter.on('*', addTimelineEvent); + } + }, target); + onUnmounted(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = composer; + // remove composer instance from DOM for intlify-devtools + if (target.vnode.el && + target.vnode.el.__VUE_I18N__) { + emitter && emitter.off('*', addTimelineEvent); + _composer[DisableEmitter] && _composer[DisableEmitter](); + delete target.vnode.el.__VUE_I18N__; + } + i18n.__deleteInstance(target); + // dispose extended resources + const dispose = _composer[DisposeSymbol]; + if (dispose) { + dispose(); + delete _composer[DisposeSymbol]; + } + }, target); + } +} +function useI18nForLegacy(instance, scope, root, options = {} // eslint-disable-line @typescript-eslint/no-explicit-any +) { + const isLocalScope = scope === 'local'; + const _composer = shallowRef(null); + if (isLocalScope && + instance.proxy && + !(instance.proxy.$options.i18n || instance.proxy.$options.__i18n)) { + throw createI18nError(I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION); + } + const _inheritLocale = isBoolean(options.inheritLocale) + ? options.inheritLocale + : !isString(options.locale); + const _locale = ref( + // prettier-ignore + !isLocalScope || _inheritLocale + ? root.locale.value + : isString(options.locale) + ? options.locale + : DEFAULT_LOCALE); + const _fallbackLocale = ref( + // prettier-ignore + !isLocalScope || _inheritLocale + ? root.fallbackLocale.value + : isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale.value); + const _messages = ref(getLocaleMessages(_locale.value, options)); + // prettier-ignore + const _datetimeFormats = ref(isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : { [_locale.value]: {} }); + // prettier-ignore + const _numberFormats = ref(isPlainObject(options.numberFormats) + ? options.numberFormats + : { [_locale.value]: {} }); + // prettier-ignore + const _missingWarn = isLocalScope + ? root.missingWarn + : isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + // prettier-ignore + const _fallbackWarn = isLocalScope + ? root.fallbackWarn + : isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + // prettier-ignore + const _fallbackRoot = isLocalScope + ? root.fallbackRoot + : isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + // configure fall back to root + const _fallbackFormat = !!options.fallbackFormat; + // runtime missing + const _missing = isFunction(options.missing) ? options.missing : null; + // postTranslation handler + const _postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + // prettier-ignore + const _warnHtmlMessage = isLocalScope + ? root.warnHtmlMessage + : isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const _escapeParameter = !!options.escapeParameter; + // prettier-ignore + const _modifiers = isLocalScope + ? root.modifiers + : isPlainObject(options.modifiers) + ? options.modifiers + : {}; + // pluralRules + const _pluralRules = options.pluralRules || (isLocalScope && root.pluralRules); + // track reactivity + function trackReactivityValues() { + return [ + _locale.value, + _fallbackLocale.value, + _messages.value, + _datetimeFormats.value, + _numberFormats.value + ]; + } + // locale + const locale = computed({ + get: () => { + return _composer.value ? _composer.value.locale.value : _locale.value; + }, + set: val => { + if (_composer.value) { + _composer.value.locale.value = val; + } + _locale.value = val; + } + }); + // fallbackLocale + const fallbackLocale = computed({ + get: () => { + return _composer.value + ? _composer.value.fallbackLocale.value + : _fallbackLocale.value; + }, + set: val => { + if (_composer.value) { + _composer.value.fallbackLocale.value = val; + } + _fallbackLocale.value = val; + } + }); + // messages + const messages = computed(() => { + if (_composer.value) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return _composer.value.messages.value; + } + else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return _messages.value; + } + }); + const datetimeFormats = computed(() => _datetimeFormats.value); + const numberFormats = computed(() => _numberFormats.value); + function getPostTranslationHandler() { + return _composer.value + ? _composer.value.getPostTranslationHandler() + : _postTranslation; + } + function setPostTranslationHandler(handler) { + if (_composer.value) { + _composer.value.setPostTranslationHandler(handler); + } + } + function getMissingHandler() { + return _composer.value ? _composer.value.getMissingHandler() : _missing; + } + function setMissingHandler(handler) { + if (_composer.value) { + _composer.value.setMissingHandler(handler); + } + } + function warpWithDeps(fn) { + trackReactivityValues(); + return fn(); + } + function t(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.t, null, [...args])) + : warpWithDeps(() => ''); + } + function rt(...args) { + return _composer.value + ? Reflect.apply(_composer.value.rt, null, [...args]) + : ''; + } + function d(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.d, null, [...args])) + : warpWithDeps(() => ''); + } + function n(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.n, null, [...args])) + : warpWithDeps(() => ''); + } + function tm(key) { + return _composer.value ? _composer.value.tm(key) : {}; + } + function te(key, locale) { + return _composer.value ? _composer.value.te(key, locale) : false; + } + function getLocaleMessage(locale) { + return _composer.value ? _composer.value.getLocaleMessage(locale) : {}; + } + function setLocaleMessage(locale, message) { + if (_composer.value) { + _composer.value.setLocaleMessage(locale, message); + _messages.value[locale] = message; + } + } + function mergeLocaleMessage(locale, message) { + if (_composer.value) { + _composer.value.mergeLocaleMessage(locale, message); + } + } + function getDateTimeFormat(locale) { + return _composer.value ? _composer.value.getDateTimeFormat(locale) : {}; + } + function setDateTimeFormat(locale, format) { + if (_composer.value) { + _composer.value.setDateTimeFormat(locale, format); + _datetimeFormats.value[locale] = format; + } + } + function mergeDateTimeFormat(locale, format) { + if (_composer.value) { + _composer.value.mergeDateTimeFormat(locale, format); + } + } + function getNumberFormat(locale) { + return _composer.value ? _composer.value.getNumberFormat(locale) : {}; + } + function setNumberFormat(locale, format) { + if (_composer.value) { + _composer.value.setNumberFormat(locale, format); + _numberFormats.value[locale] = format; + } + } + function mergeNumberFormat(locale, format) { + if (_composer.value) { + _composer.value.mergeNumberFormat(locale, format); + } + } + const wrapper = { + get id() { + return _composer.value ? _composer.value.id : -1; + }, + locale, + fallbackLocale, + messages, + datetimeFormats, + numberFormats, + get inheritLocale() { + return _composer.value ? _composer.value.inheritLocale : _inheritLocale; + }, + set inheritLocale(val) { + if (_composer.value) { + _composer.value.inheritLocale = val; + } + }, + get availableLocales() { + return _composer.value + ? _composer.value.availableLocales + : Object.keys(_messages.value); + }, + get modifiers() { + return (_composer.value ? _composer.value.modifiers : _modifiers); + }, + get pluralRules() { + return (_composer.value ? _composer.value.pluralRules : _pluralRules); + }, + get isGlobal() { + return _composer.value ? _composer.value.isGlobal : false; + }, + get missingWarn() { + return _composer.value ? _composer.value.missingWarn : _missingWarn; + }, + set missingWarn(val) { + if (_composer.value) { + _composer.value.missingWarn = val; + } + }, + get fallbackWarn() { + return _composer.value ? _composer.value.fallbackWarn : _fallbackWarn; + }, + set fallbackWarn(val) { + if (_composer.value) { + _composer.value.missingWarn = val; + } + }, + get fallbackRoot() { + return _composer.value ? _composer.value.fallbackRoot : _fallbackRoot; + }, + set fallbackRoot(val) { + if (_composer.value) { + _composer.value.fallbackRoot = val; + } + }, + get fallbackFormat() { + return _composer.value ? _composer.value.fallbackFormat : _fallbackFormat; + }, + set fallbackFormat(val) { + if (_composer.value) { + _composer.value.fallbackFormat = val; + } + }, + get warnHtmlMessage() { + return _composer.value + ? _composer.value.warnHtmlMessage + : _warnHtmlMessage; + }, + set warnHtmlMessage(val) { + if (_composer.value) { + _composer.value.warnHtmlMessage = val; + } + }, + get escapeParameter() { + return _composer.value + ? _composer.value.escapeParameter + : _escapeParameter; + }, + set escapeParameter(val) { + if (_composer.value) { + _composer.value.escapeParameter = val; + } + }, + t, + getPostTranslationHandler, + setPostTranslationHandler, + getMissingHandler, + setMissingHandler, + rt, + d, + n, + tm, + te, + getLocaleMessage, + setLocaleMessage, + mergeLocaleMessage, + getDateTimeFormat, + setDateTimeFormat, + mergeDateTimeFormat, + getNumberFormat, + setNumberFormat, + mergeNumberFormat + }; + function sync(composer) { + composer.locale.value = _locale.value; + composer.fallbackLocale.value = _fallbackLocale.value; + Object.keys(_messages.value).forEach(locale => { + composer.mergeLocaleMessage(locale, _messages.value[locale]); + }); + Object.keys(_datetimeFormats.value).forEach(locale => { + composer.mergeDateTimeFormat(locale, _datetimeFormats.value[locale]); + }); + Object.keys(_numberFormats.value).forEach(locale => { + composer.mergeNumberFormat(locale, _numberFormats.value[locale]); + }); + composer.escapeParameter = _escapeParameter; + composer.fallbackFormat = _fallbackFormat; + composer.fallbackRoot = _fallbackRoot; + composer.fallbackWarn = _fallbackWarn; + composer.missingWarn = _missingWarn; + composer.warnHtmlMessage = _warnHtmlMessage; + } + onBeforeMount(() => { + if (instance.proxy == null || instance.proxy.$i18n == null) { + throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const composer = (_composer.value = instance.proxy.$i18n + .__composer); + if (scope === 'global') { + _locale.value = composer.locale.value; + _fallbackLocale.value = composer.fallbackLocale.value; + _messages.value = composer.messages.value; + _datetimeFormats.value = composer.datetimeFormats.value; + _numberFormats.value = composer.numberFormats.value; + } + else if (isLocalScope) { + sync(composer); + } + }); + return wrapper; +} +const globalExportProps = [ + 'locale', + 'fallbackLocale', + 'availableLocales' +]; +const globalExportMethods = ['t', 'rt', 'd', 'n', 'tm', 'te'] + ; +function injectGlobalFields(app, composer) { + const i18n = Object.create(null); + globalExportProps.forEach(prop => { + const desc = Object.getOwnPropertyDescriptor(composer, prop); + if (!desc) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const wrap = isRef(desc.value) // check computed props + ? { + get() { + return desc.value.value; + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + set(val) { + desc.value.value = val; + } + } + : { + get() { + return desc.get && desc.get(); + } + }; + Object.defineProperty(i18n, prop, wrap); + }); + app.config.globalProperties.$i18n = i18n; + globalExportMethods.forEach(method => { + const desc = Object.getOwnPropertyDescriptor(composer, method); + if (!desc || !desc.value) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + Object.defineProperty(app.config.globalProperties, `$${method}`, desc); + }); + const dispose = () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete app.config.globalProperties.$i18n; + globalExportMethods.forEach(method => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete app.config.globalProperties[`$${method}`]; + }); + }; + return dispose; +} + +// register message resolver at vue-i18n +registerMessageResolver(resolveValue); +// register fallback locale at vue-i18n +registerLocaleFallbacker(fallbackWithLocaleChain); +// NOTE: experimental !! +{ + const target = getGlobalThis(); + target.__INTLIFY__ = true; + setDevToolsHook(target.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__); +} +{ + initDev(); +} + +export { DatetimeFormat, I18nD, I18nInjectionKey, I18nN, I18nT, NumberFormat, Translation, VERSION, castToVueI18n, createI18n, useI18n, vTDirective }; diff --git a/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-browser.prod.js b/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-browser.prod.js new file mode 100644 index 0000000..e777fd9 --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-browser.prod.js @@ -0,0 +1,6 @@ +/*! + * vue-i18n v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +import{createVNode,Text,computed,watch,getCurrentInstance,ref,shallowRef,Fragment,defineComponent,h,effectScope,inject,onMounted,onUnmounted,onBeforeMount,isRef}from"vue";function warn(e,t){"undefined"!=typeof console&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}const inBrowser="undefined"!=typeof window,makeSymbol=(e,t=!1)=>t?Symbol.for(e):Symbol(e),generateFormatCacheKey=(e,t,a)=>friendlyJSONstringify({l:e,k:t,s:a}),friendlyJSONstringify=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),isNumber=e=>"number"==typeof e&&isFinite(e),isDate=e=>"[object Date]"===toTypeString(e),isRegExp=e=>"[object RegExp]"===toTypeString(e),isEmptyObject=e=>isPlainObject(e)&&0===Object.keys(e).length,assign=Object.assign,_create=Object.create,create=(e=null)=>_create(e);function escapeHtml(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/").replace(/=/g,"=")}function escapeAttributeValue(e){return e.replace(/&(?![a-zA-Z0-9#]{2,6};)/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")}function sanitizeTranslatedHtml(e){e=(e=e.replace(/(\w+)\s*=\s*"([^"]*)"/g,((e,t,a)=>`${t}="${escapeAttributeValue(a)}"`))).replace(/(\w+)\s*=\s*'([^']*)'/g,((e,t,a)=>`${t}='${escapeAttributeValue(a)}'`));/\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi.test(e)&&(e=e.replace(/(\s+)(on)(\w+\s*=)/gi,"$1on$3"));return[/(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi,/(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi].forEach((t=>{e=e.replace(t,"$1javascript:")})),e}const hasOwnProperty=Object.prototype.hasOwnProperty;function hasOwn(e,t){return hasOwnProperty.call(e,t)}const isArray=Array.isArray,isFunction=e=>"function"==typeof e,isString=e=>"string"==typeof e,isBoolean=e=>"boolean"==typeof e,isObject=e=>null!==e&&"object"==typeof e,isPromise=e=>isObject(e)&&isFunction(e.then)&&isFunction(e.catch),objectToString=Object.prototype.toString,toTypeString=e=>objectToString.call(e),isPlainObject=e=>{if(!isObject(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t.constructor===Object},toDisplayString=e=>null==e?"":isArray(e)||isPlainObject(e)&&e.toString===objectToString?JSON.stringify(e,null,2):String(e);function join(e,t=""){return e.reduce(((e,a,r)=>0===r?e+a:e+t+a),"")}function incrementer(e){let t=e;return()=>++t}const isNotObjectOrIsArray=e=>!isObject(e)||isArray(e);function deepCopy(e,t){if(isNotObjectOrIsArray(e)||isNotObjectOrIsArray(t))throw new Error("Invalid value");const a=[{src:e,des:t}];for(;a.length;){const{src:e,des:t}=a.pop();Object.keys(e).forEach((r=>{"__proto__"!==r&&(isObject(e[r])&&!isObject(t[r])&&(t[r]=Array.isArray(e[r])?[]:create()),isNotObjectOrIsArray(t[r])||isNotObjectOrIsArray(e[r])?t[r]=e[r]:a.push({src:e[r],des:t[r]}))}))}}const CompileErrorCodes={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16,__EXTEND_POINT__:17};function createCompileError(e,t,a={}){const{domain:r,messages:n,args:s}=a,l=new SyntaxError(String(e));return l.code=e,t&&(l.location=t),l.domain=r,l}function isMessageAST(e){return isObject(e)&&0===resolveType(e)&&(hasOwn(e,"b")||hasOwn(e,"body"))}const PROPS_BODY=["b","body"],PROPS_CASES=["c","cases"],PROPS_STATIC=["s","static"],PROPS_ITEMS=["i","items"],PROPS_TYPE=["t","type"];function resolveType(e){return resolveProps(e,PROPS_TYPE)}const PROPS_VALUE=["v","value"],PROPS_MODIFIER=["m","modifier"],PROPS_KEY=["k","key"];function resolveProps(e,t,a){for(let r=0;r{void 0===r?r=n:r+=n},g[1]=()=>{void 0!==r&&(t.push(r),r=void 0)},g[2]=()=>{g[0](),m++},g[3]=()=>{if(m>0)m--,u=4,g[0]();else{if(m=0,void 0===r)return!1;if(r=formatSubPath(r),!1===r)return!1;g[1]()}};null!==u;)if(c++,a=e[c],"\\"!==a||!_()){if(s=getPathCharType(a),i=pathStateMachine[u],l=i[s]||i.l||8,8===l)return;if(u=l[0],void 0!==l[1]&&(o=g[l[1]],o&&(n=a,!1===o())))return;if(7===u)return t}}const cache=new Map;function resolveWithKeyValue(e,t){return isObject(e)?e[t]:null}function resolveValue(e,t){if(!isObject(e))return null;let a=cache.get(t);if(a||(a=parse(t),a&&cache.set(t,a)),!a)return null;const r=a.length;let n=e,s=0;for(;se,DEFAULT_MESSAGE=e=>"",DEFAULT_MESSAGE_DATA_TYPE="text",DEFAULT_NORMALIZE=e=>0===e.length?"":join(e),DEFAULT_INTERPOLATE=toDisplayString;function pluralDefault(e,t){return e=Math.abs(e),2===t?e?e>1?1:0:1:e?Math.min(e,2):0}function getPluralIndex(e){const t=isNumber(e.pluralIndex)?e.pluralIndex:-1;return e.named&&(isNumber(e.named.count)||isNumber(e.named.n))?isNumber(e.named.count)?e.named.count:isNumber(e.named.n)?e.named.n:t:t}function normalizeNamed(e,t){t.count||(t.count=e),t.n||(t.n=e)}function createMessageContext(e={}){const t=e.locale,a=getPluralIndex(e),r=isObject(e.pluralRules)&&isString(t)&&isFunction(e.pluralRules[t])?e.pluralRules[t]:pluralDefault,n=isObject(e.pluralRules)&&isString(t)&&isFunction(e.pluralRules[t])?pluralDefault:void 0,s=e.list||[],l=e.named||create();isNumber(e.pluralIndex)&&normalizeNamed(a,l);function o(t){const a=isFunction(e.messages)?e.messages(t):!!isObject(e.messages)&&e.messages[t];return a||(e.parent?e.parent.message(t):DEFAULT_MESSAGE)}const i=isPlainObject(e.processor)&&isFunction(e.processor.normalize)?e.processor.normalize:DEFAULT_NORMALIZE,c=isPlainObject(e.processor)&&isFunction(e.processor.interpolate)?e.processor.interpolate:DEFAULT_INTERPOLATE,u={list:e=>s[e],named:e=>l[e],plural:e=>e[r(a,e.length,n)],linked:(t,...a)=>{const[r,n]=a;let s="text",l="";1===a.length?isObject(r)?(l=r.modifier||l,s=r.type||s):isString(r)&&(l=r||l):2===a.length&&(isString(r)&&(l=r||l),isString(n)&&(s=n||s));const i=o(t)(u),c="vnode"===s&&isArray(i)&&l?i[0]:i;return l?(m=l,e.modifiers?e.modifiers[m]:DEFAULT_MODIFIER)(c,s):c;var m},message:o,type:isPlainObject(e.processor)&&isString(e.processor.type)?e.processor.type:DEFAULT_MESSAGE_DATA_TYPE,interpolate:c,normalize:i,values:assign(create(),s,l)};return u}const code$1=CompileErrorCodes.__EXTEND_POINT__,inc$1=incrementer(code$1),CoreErrorCodes={INVALID_ARGUMENT:code$1,INVALID_DATE_ARGUMENT:inc$1(),INVALID_ISO_DATE_ARGUMENT:inc$1(),NOT_SUPPORT_NON_STRING_MESSAGE:inc$1(),NOT_SUPPORT_LOCALE_PROMISE_VALUE:inc$1(),NOT_SUPPORT_LOCALE_ASYNC_FUNCTION:inc$1(),NOT_SUPPORT_LOCALE_TYPE:inc$1(),__EXTEND_POINT__:inc$1()};function getLocale(e,t){return null!=t.locale?resolveLocale(t.locale):resolveLocale(e.locale)}let _resolveLocale;function resolveLocale(e){if(isString(e))return e;if(isFunction(e)){if(e.resolvedOnce&&null!=_resolveLocale)return _resolveLocale;if("Function"===e.constructor.name){const t=e();if(isPromise(t))throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE);return _resolveLocale=t}throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION)}throw Error(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE)}function fallbackWithSimple(e,t,a){return[...new Set([a,...isArray(t)?t:isObject(t)?Object.keys(t):isString(t)?[t]:[a]])]}function fallbackWithLocaleChain(e,t,a){const r=isString(a)?a:DEFAULT_LOCALE,n=e;n.__localeChainCache||(n.__localeChainCache=new Map);let s=n.__localeChainCache.get(r);if(!s){s=[];let e=[a];for(;isArray(e);)e=appendBlockToChain(s,e,t);const l=isArray(t)||!isPlainObject(t)?t:t.default?t.default:null;e=isString(l)?[l]:l,isArray(e)&&appendBlockToChain(s,e,!1),n.__localeChainCache.set(r,s)}return s}function appendBlockToChain(e,t,a){let r=!0;for(let n=0;n`${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;function getDefaultLinkedModifiers(){return{upper:(e,t)=>"text"===t&&isString(e)?e.toUpperCase():"vnode"===t&&isObject(e)&&"__v_isVNode"in e?e.children.toUpperCase():e,lower:(e,t)=>"text"===t&&isString(e)?e.toLowerCase():"vnode"===t&&isObject(e)&&"__v_isVNode"in e?e.children.toLowerCase():e,capitalize:(e,t)=>"text"===t&&isString(e)?capitalize(e):"vnode"===t&&isObject(e)&&"__v_isVNode"in e?capitalize(e.children):e}}let _compiler,_resolver,_fallbacker;function registerMessageResolver(e){_resolver=e}function registerLocaleFallbacker(e){_fallbacker=e}const setAdditionalMeta=e=>{};let _fallbackContext=null;const setFallbackContext=e=>{_fallbackContext=e},getFallbackContext=()=>_fallbackContext;let _cid=0;function createCoreContext(e={}){const t=isFunction(e.onWarn)?e.onWarn:warn,a=isString(e.version)?e.version:VERSION$1,r=isString(e.locale)||isFunction(e.locale)?e.locale:DEFAULT_LOCALE,n=isFunction(r)?DEFAULT_LOCALE:r,s=isArray(e.fallbackLocale)||isPlainObject(e.fallbackLocale)||isString(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:n,l=isPlainObject(e.messages)?e.messages:createResources(n),o=isPlainObject(e.datetimeFormats)?e.datetimeFormats:createResources(n),i=isPlainObject(e.numberFormats)?e.numberFormats:createResources(n),c=assign(create(),e.modifiers,getDefaultLinkedModifiers()),u=e.pluralRules||create(),m=isFunction(e.missing)?e.missing:null,g=!isBoolean(e.missingWarn)&&!isRegExp(e.missingWarn)||e.missingWarn,_=!isBoolean(e.fallbackWarn)&&!isRegExp(e.fallbackWarn)||e.fallbackWarn,f=!!e.fallbackFormat,p=!!e.unresolving,b=isFunction(e.postTranslation)?e.postTranslation:null,E=isPlainObject(e.processor)?e.processor:null,d=!isBoolean(e.warnHtmlMessage)||e.warnHtmlMessage,O=!!e.escapeParameter,v=isFunction(e.messageCompiler)?e.messageCompiler:_compiler,T=isFunction(e.messageResolver)?e.messageResolver:_resolver||resolveWithKeyValue,S=isFunction(e.localeFallbacker)?e.localeFallbacker:_fallbacker||fallbackWithSimple,N=isObject(e.fallbackContext)?e.fallbackContext:void 0,I=e,F=isObject(I.__datetimeFormatters)?I.__datetimeFormatters:new Map,L=isObject(I.__numberFormatters)?I.__numberFormatters:new Map,h=isObject(I.__meta)?I.__meta:{};_cid++;const P={version:a,cid:_cid,locale:r,fallbackLocale:s,messages:l,modifiers:c,pluralRules:u,missing:m,missingWarn:g,fallbackWarn:_,fallbackFormat:f,unresolving:p,postTranslation:b,processor:E,warnHtmlMessage:d,escapeParameter:O,messageCompiler:v,messageResolver:T,localeFallbacker:S,fallbackContext:N,onWarn:t,__meta:h};return P.datetimeFormats=o,P.numberFormats=i,P.__datetimeFormatters=F,P.__numberFormatters=L,P}const createResources=e=>({[e]:create()});function handleMissing(e,t,a,r,n){const{missing:s,onWarn:l}=e;if(null!==s){const r=s(e,a,t,n);return isString(r)?r:t}return t}function updateFallbackLocale(e,t,a){e.__localeChainCache=new Map,e.localeFallbacker(e,a,t)}function isAlmostSameLocale(e,t){return e!==t&&e.split("-")[0]===t.split("-")[0]}function isImplicitFallback(e,t){const a=t.indexOf(e);if(-1===a)return!1;for(let r=a+1;r"",isMessageFunction=e=>isFunction(e);function translate(e,...t){const{fallbackFormat:a,postTranslation:r,unresolving:n,messageCompiler:s,fallbackLocale:l,messages:o}=e,[i,c]=parseTranslateArgs(...t),u=isBoolean(c.missingWarn)?c.missingWarn:e.missingWarn,m=isBoolean(c.fallbackWarn)?c.fallbackWarn:e.fallbackWarn,g=isBoolean(c.escapeParameter)?c.escapeParameter:e.escapeParameter,_=!!c.resolvedMessage,f=isString(c.default)||isBoolean(c.default)?isBoolean(c.default)?s?i:()=>i:c.default:a?s?i:()=>i:"",p=a||""!==f,b=getLocale(e,c);g&&escapeParams(c);let[E,d,O]=_?[i,b,o[b]||create()]:resolveMessageFormat(e,i,b,l,m,u),v=E,T=i;if(_||isString(v)||isMessageAST(v)||isMessageFunction(v)||p&&(v=f,T=v),!(_||(isString(v)||isMessageAST(v)||isMessageFunction(v))&&isString(d)))return n?NOT_REOSLVED:i;let S=!1;const N=isMessageFunction(v)?v:compileMessageFormat(e,i,d,v,T,(()=>{S=!0}));if(S)return v;const I=evaluateMessage(e,N,createMessageContext(getMessageContextOptions(e,d,O,c)));let F=r?r(I,i):I;return g&&isString(F)&&(F=sanitizeTranslatedHtml(F)),F}function escapeParams(e){isArray(e.list)?e.list=e.list.map((e=>isString(e)?escapeHtml(e):e)):isObject(e.named)&&Object.keys(e.named).forEach((t=>{isString(e.named[t])&&(e.named[t]=escapeHtml(e.named[t]))}))}function resolveMessageFormat(e,t,a,r,n,s){const{messages:l,onWarn:o,messageResolver:i,localeFallbacker:c}=e,u=c(e,r,a);let m,g=create(),_=null;for(let f=0;fr;return e.locale=a,e.key=t,e}const i=l(r,getCompileContext(e,a,n,r,o,s));return i.locale=a,i.key=t,i.source=r,i}function evaluateMessage(e,t,a){return t(a)}function parseTranslateArgs(...e){const[t,a,r]=e,n=create();if(!(isString(t)||isNumber(t)||isMessageFunction(t)||isMessageAST(t)))throw Error(CoreErrorCodes.INVALID_ARGUMENT);const s=isNumber(t)?String(t):(isMessageFunction(t),t);return isNumber(a)?n.plural=a:isString(a)?n.default=a:isPlainObject(a)&&!isEmptyObject(a)?n.named=a:isArray(a)&&(n.list=a),isNumber(r)?n.plural=r:isString(r)?n.default=r:isPlainObject(r)&&assign(n,r),[s,n]}function getCompileContext(e,t,a,r,n,s){return{locale:t,key:a,warnHtmlMessage:n,onError:e=>{throw s&&s(e),e},onCacheKey:e=>generateFormatCacheKey(t,a,e)}}function getMessageContextOptions(e,t,a,r){const{modifiers:n,pluralRules:s,messageResolver:l,fallbackLocale:o,fallbackWarn:i,missingWarn:c,fallbackContext:u}=e,m={locale:t,modifiers:n,pluralRules:s,messages:r=>{let n=l(a,r);if(null==n&&u){const[,,e]=resolveMessageFormat(u,r,t,o,i,c);n=l(e,r)}if(isString(n)||isMessageAST(n)){let a=!1;const s=compileMessageFormat(e,r,t,n,r,(()=>{a=!0}));return a?NOOP_MESSAGE_FUNCTION:s}return isMessageFunction(n)?n:NOOP_MESSAGE_FUNCTION}};return e.processor&&(m.processor=e.processor),r.list&&(m.list=r.list),r.named&&(m.named=r.named),isNumber(r.plural)&&(m.pluralIndex=r.plural),m}function datetime(e,...t){const{datetimeFormats:a,unresolving:r,fallbackLocale:n,onWarn:s,localeFallbacker:l}=e,{__datetimeFormatters:o}=e,[i,c,u,m]=parseDateTimeArgs(...t),g=isBoolean(u.missingWarn)?u.missingWarn:e.missingWarn;isBoolean(u.fallbackWarn)?u.fallbackWarn:e.fallbackWarn;const _=!!u.part,f=getLocale(e,u),p=l(e,n,f);if(!isString(i)||""===i)return new Intl.DateTimeFormat(f,m).format(c);let b,E={},d=null;for(let T=0;T{DATETIME_FORMAT_OPTIONS_KEYS.includes(e)?o[e]=a[e]:s[e]=a[e]})),isString(r)?s.locale=r:isPlainObject(r)&&(o=r),isPlainObject(n)&&(o=n),[s.key||"",l,s,o]}function clearDateTimeFormat(e,t,a){const r=e;for(const n in a){const e=`${t}__${n}`;r.__datetimeFormatters.has(e)&&r.__datetimeFormatters.delete(e)}}function number(e,...t){const{numberFormats:a,unresolving:r,fallbackLocale:n,onWarn:s,localeFallbacker:l}=e,{__numberFormatters:o}=e,[i,c,u,m]=parseNumberArgs(...t),g=isBoolean(u.missingWarn)?u.missingWarn:e.missingWarn;isBoolean(u.fallbackWarn)?u.fallbackWarn:e.fallbackWarn;const _=!!u.part,f=getLocale(e,u),p=l(e,n,f);if(!isString(i)||""===i)return new Intl.NumberFormat(f,m).format(c);let b,E={},d=null;for(let T=0;T{NUMBER_FORMAT_OPTIONS_KEYS.includes(e)?l[e]=a[e]:s[e]=a[e]})),isString(r)?s.locale=r:isPlainObject(r)&&(l=r),isPlainObject(n)&&(l=n),[s.key||"",o,s,l]}function clearNumberFormat(e,t,a){const r=e;for(const n in a){const e=`${t}__${n}`;r.__numberFormatters.has(e)&&r.__numberFormatters.delete(e)}}const VERSION="9.14.5",code=CoreErrorCodes.__EXTEND_POINT__,inc=incrementer(code),I18nErrorCodes={UNEXPECTED_RETURN_TYPE:code,INVALID_ARGUMENT:inc(),MUST_BE_CALL_SETUP_TOP:inc(),NOT_INSTALLED:inc(),NOT_AVAILABLE_IN_LEGACY_MODE:inc(),REQUIRED_VALUE:inc(),INVALID_VALUE:inc(),CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN:inc(),NOT_INSTALLED_WITH_PROVIDE:inc(),UNEXPECTED_ERROR:inc(),NOT_COMPATIBLE_LEGACY_VUE_I18N:inc(),BRIDGE_SUPPORT_VUE_2_ONLY:inc(),MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION:inc(),NOT_AVAILABLE_COMPOSITION_IN_LEGACY:inc(),__EXTEND_POINT__:inc()};function createI18nError(e,...t){return createCompileError(e,null,void 0)}const TranslateVNodeSymbol=makeSymbol("__translateVNode"),DatetimePartsSymbol=makeSymbol("__datetimeParts"),NumberPartsSymbol=makeSymbol("__numberParts"),SetPluralRulesSymbol=makeSymbol("__setPluralRules"),InejctWithOptionSymbol=makeSymbol("__injectWithOption"),DisposeSymbol=makeSymbol("__dispose"),__VUE_I18N_BRIDGE__="__VUE_I18N_BRIDGE__";function handleFlatJson(e){if(!isObject(e))return e;if(isMessageAST(e))return e;for(const t in e)if(hasOwn(e,t))if(t.includes(".")){const a=t.split("."),r=a.length-1;let n=e,s=!1;for(let e=0;e{if("locale"in e&&"resource"in e){const{locale:t,resource:a}=e;t?(l[t]=l[t]||create(),deepCopy(a,l[t])):deepCopy(a,l)}else isString(e)&&deepCopy(JSON.parse(e),l)})),null==n&&s)for(const o in l)hasOwn(l,o)&&handleFlatJson(l[o]);return l}function getComponentOptions(e){return e.type}function adjustI18nResources(e,t,a){let r=isObject(t.messages)?t.messages:create();"__i18nGlobal"in a&&(r=getLocaleMessages(e.locale.value,{messages:r,__i18n:a.__i18nGlobal}));const n=Object.keys(r);if(n.length&&n.forEach((t=>{e.mergeLocaleMessage(t,r[t])})),isObject(t.datetimeFormats)){const a=Object.keys(t.datetimeFormats);a.length&&a.forEach((a=>{e.mergeDateTimeFormat(a,t.datetimeFormats[a])}))}if(isObject(t.numberFormats)){const a=Object.keys(t.numberFormats);a.length&&a.forEach((a=>{e.mergeNumberFormat(a,t.numberFormats[a])}))}}function createTextNode(e){return createVNode(Text,null,e,0)}const DEVTOOLS_META="__INTLIFY_META__",NOOP_RETURN_ARRAY=()=>[],NOOP_RETURN_FALSE=()=>!1;let composerID=0;function defineCoreMissingHandler(e){return(t,a,r,n)=>e(a,r,getCurrentInstance()||void 0,n)}const getMetaInfo=()=>{const e=getCurrentInstance();let t=null;return e&&(t=getComponentOptions(e)[DEVTOOLS_META])?{[DEVTOOLS_META]:t}:null};function createComposer(e={},t){const{__root:a,__injectWithOption:r}=e,n=void 0===a,s=e.flatJson,l=inBrowser?ref:shallowRef,o=!!e.translateExistCompatible;let i=!isBoolean(e.inheritLocale)||e.inheritLocale;const c=l(a&&i?a.locale.value:isString(e.locale)?e.locale:DEFAULT_LOCALE),u=l(a&&i?a.fallbackLocale.value:isString(e.fallbackLocale)||isArray(e.fallbackLocale)||isPlainObject(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:c.value),m=l(getLocaleMessages(c.value,e)),g=l(isPlainObject(e.datetimeFormats)?e.datetimeFormats:{[c.value]:{}}),_=l(isPlainObject(e.numberFormats)?e.numberFormats:{[c.value]:{}});let f=a?a.missingWarn:!isBoolean(e.missingWarn)&&!isRegExp(e.missingWarn)||e.missingWarn,p=a?a.fallbackWarn:!isBoolean(e.fallbackWarn)&&!isRegExp(e.fallbackWarn)||e.fallbackWarn,b=a?a.fallbackRoot:!isBoolean(e.fallbackRoot)||e.fallbackRoot,E=!!e.fallbackFormat,d=isFunction(e.missing)?e.missing:null,O=isFunction(e.missing)?defineCoreMissingHandler(e.missing):null,v=isFunction(e.postTranslation)?e.postTranslation:null,T=a?a.warnHtmlMessage:!isBoolean(e.warnHtmlMessage)||e.warnHtmlMessage,S=!!e.escapeParameter;const N=a?a.modifiers:isPlainObject(e.modifiers)?e.modifiers:{};let I,F=e.pluralRules||a&&a.pluralRules;I=(()=>{n&&setFallbackContext(null);const t={version:VERSION,locale:c.value,fallbackLocale:u.value,messages:m.value,modifiers:N,pluralRules:F,missing:null===O?void 0:O,missingWarn:f,fallbackWarn:p,fallbackFormat:E,unresolving:!0,postTranslation:null===v?void 0:v,warnHtmlMessage:T,escapeParameter:S,messageResolver:e.messageResolver,messageCompiler:e.messageCompiler,__meta:{framework:"vue"}};t.datetimeFormats=g.value,t.numberFormats=_.value,t.__datetimeFormatters=isPlainObject(I)?I.__datetimeFormatters:void 0,t.__numberFormatters=isPlainObject(I)?I.__numberFormatters:void 0;const a=createCoreContext(t);return n&&setFallbackContext(a),a})(),updateFallbackLocale(I,c.value,u.value);const L=computed({get:()=>c.value,set:e=>{c.value=e,I.locale=c.value}}),h=computed({get:()=>u.value,set:e=>{u.value=e,I.fallbackLocale=u.value,updateFallbackLocale(I,c.value,e)}}),P=computed((()=>m.value)),y=computed((()=>g.value)),C=computed((()=>_.value));const A=(e,t,r,s,l,o)=>{let i;c.value,u.value,m.value,g.value,_.value;try{0,n||(I.fallbackContext=a?getFallbackContext():void 0),i=e(I)}finally{n||(I.fallbackContext=void 0)}if("translate exists"!==r&&isNumber(i)&&i===NOT_REOSLVED||"translate exists"===r&&!i){const[e,r]=t();return a&&b?s(a):l(e)}if(o(i))return i;throw Error(I18nErrorCodes.UNEXPECTED_RETURN_TYPE)};function R(...e){return A((t=>Reflect.apply(translate,null,[t,...e])),(()=>parseTranslateArgs(...e)),"translate",(t=>Reflect.apply(t.t,t,[...e])),(e=>e),(e=>isString(e)))}const k={normalize:function(e){return e.map((e=>isString(e)||isNumber(e)||isBoolean(e)?createTextNode(String(e)):e))},interpolate:e=>e,type:"vnode"};function M(e){return m.value[e]||{}}composerID++,a&&inBrowser&&(watch(a.locale,(e=>{i&&(c.value=e,I.locale=e,updateFallbackLocale(I,c.value,u.value))})),watch(a.fallbackLocale,(e=>{i&&(u.value=e,I.fallbackLocale=e,updateFallbackLocale(I,c.value,u.value))})));const D={id:composerID,locale:L,fallbackLocale:h,get inheritLocale(){return i},set inheritLocale(e){i=e,e&&a&&(c.value=a.locale.value,u.value=a.fallbackLocale.value,updateFallbackLocale(I,c.value,u.value))},get availableLocales(){return Object.keys(m.value).sort()},messages:P,get modifiers(){return N},get pluralRules(){return F||{}},get isGlobal(){return n},get missingWarn(){return f},set missingWarn(e){f=e,I.missingWarn=f},get fallbackWarn(){return p},set fallbackWarn(e){p=e,I.fallbackWarn=p},get fallbackRoot(){return b},set fallbackRoot(e){b=e},get fallbackFormat(){return E},set fallbackFormat(e){E=e,I.fallbackFormat=E},get warnHtmlMessage(){return T},set warnHtmlMessage(e){T=e,I.warnHtmlMessage=e},get escapeParameter(){return S},set escapeParameter(e){S=e,I.escapeParameter=e},t:R,getLocaleMessage:M,setLocaleMessage:function(e,t){if(s){const a={[e]:t};for(const e in a)hasOwn(a,e)&&handleFlatJson(a[e]);t=a[e]}m.value[e]=t,I.messages=m.value},mergeLocaleMessage:function(e,t){m.value[e]=m.value[e]||{};const a={[e]:t};if(s)for(const r in a)hasOwn(a,r)&&handleFlatJson(a[r]);deepCopy(t=a[e],m.value[e]),I.messages=m.value},getPostTranslationHandler:function(){return isFunction(v)?v:null},setPostTranslationHandler:function(e){v=e,I.postTranslation=e},getMissingHandler:function(){return d},setMissingHandler:function(e){null!==e&&(O=defineCoreMissingHandler(e)),d=e,I.missing=O},[SetPluralRulesSymbol]:function(e){F=e,I.pluralRules=F}};return D.datetimeFormats=y,D.numberFormats=C,D.rt=function(...e){const[t,a,r]=e;if(r&&!isObject(r))throw Error(I18nErrorCodes.INVALID_ARGUMENT);return R(t,a,assign({resolvedMessage:!0},r||{}))},D.te=function(e,t){return A((()=>{if(!e)return!1;const a=M(isString(t)?t:c.value),r=I.messageResolver(a,e);return o?null!=r:isMessageAST(r)||isMessageFunction(r)||isString(r)}),(()=>[e]),"translate exists",(a=>Reflect.apply(a.te,a,[e,t])),NOOP_RETURN_FALSE,(e=>isBoolean(e)))},D.tm=function(e){const t=function(e){let t=null;const a=fallbackWithLocaleChain(I,u.value,c.value);for(let r=0;rReflect.apply(datetime,null,[t,...e])),(()=>parseDateTimeArgs(...e)),"datetime format",(t=>Reflect.apply(t.d,t,[...e])),(()=>MISSING_RESOLVE_VALUE),(e=>isString(e)))},D.n=function(...e){return A((t=>Reflect.apply(number,null,[t,...e])),(()=>parseNumberArgs(...e)),"number format",(t=>Reflect.apply(t.n,t,[...e])),(()=>MISSING_RESOLVE_VALUE),(e=>isString(e)))},D.getDateTimeFormat=function(e){return g.value[e]||{}},D.setDateTimeFormat=function(e,t){g.value[e]=t,I.datetimeFormats=g.value,clearDateTimeFormat(I,e,t)},D.mergeDateTimeFormat=function(e,t){g.value[e]=assign(g.value[e]||{},t),I.datetimeFormats=g.value,clearDateTimeFormat(I,e,t)},D.getNumberFormat=function(e){return _.value[e]||{}},D.setNumberFormat=function(e,t){_.value[e]=t,I.numberFormats=_.value,clearNumberFormat(I,e,t)},D.mergeNumberFormat=function(e,t){_.value[e]=assign(_.value[e]||{},t),I.numberFormats=_.value,clearNumberFormat(I,e,t)},D[InejctWithOptionSymbol]=r,D[TranslateVNodeSymbol]=function(...e){return A((t=>{let a;const r=t;try{r.processor=k,a=Reflect.apply(translate,null,[r,...e])}finally{r.processor=null}return a}),(()=>parseTranslateArgs(...e)),"translate",(t=>t[TranslateVNodeSymbol](...e)),(e=>[createTextNode(e)]),(e=>isArray(e)))},D[DatetimePartsSymbol]=function(...e){return A((t=>Reflect.apply(datetime,null,[t,...e])),(()=>parseDateTimeArgs(...e)),"datetime format",(t=>t[DatetimePartsSymbol](...e)),NOOP_RETURN_ARRAY,(e=>isString(e)||isArray(e)))},D[NumberPartsSymbol]=function(...e){return A((t=>Reflect.apply(number,null,[t,...e])),(()=>parseNumberArgs(...e)),"number format",(t=>t[NumberPartsSymbol](...e)),NOOP_RETURN_ARRAY,(e=>isString(e)||isArray(e)))},D}function convertComposerOptions(e){const t=isString(e.locale)?e.locale:DEFAULT_LOCALE,a=isString(e.fallbackLocale)||isArray(e.fallbackLocale)||isPlainObject(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:t,r=isFunction(e.missing)?e.missing:void 0,n=!isBoolean(e.silentTranslationWarn)&&!isRegExp(e.silentTranslationWarn)||!e.silentTranslationWarn,s=!isBoolean(e.silentFallbackWarn)&&!isRegExp(e.silentFallbackWarn)||!e.silentFallbackWarn,l=!isBoolean(e.fallbackRoot)||e.fallbackRoot,o=!!e.formatFallbackMessages,i=isPlainObject(e.modifiers)?e.modifiers:{},c=e.pluralizationRules,u=isFunction(e.postTranslation)?e.postTranslation:void 0,m=!isString(e.warnHtmlInMessage)||"off"!==e.warnHtmlInMessage,g=!!e.escapeParameterHtml,_=!isBoolean(e.sync)||e.sync;let f=e.messages;if(isPlainObject(e.sharedMessages)){const t=e.sharedMessages;f=Object.keys(t).reduce(((e,a)=>{const r=e[a]||(e[a]={});return assign(r,t[a]),e}),f||{})}const{__i18n:p,__root:b,__injectWithOption:E}=e,d=e.datetimeFormats,O=e.numberFormats,v=e.flatJson,T=e.translateExistCompatible;return{locale:t,fallbackLocale:a,messages:f,flatJson:v,datetimeFormats:d,numberFormats:O,missing:r,missingWarn:n,fallbackWarn:s,fallbackRoot:l,fallbackFormat:o,modifiers:i,pluralRules:c,postTranslation:u,warnHtmlMessage:m,escapeParameter:g,messageResolver:e.messageResolver,inheritLocale:_,translateExistCompatible:T,__i18n:p,__root:b,__injectWithOption:E}}function createVueI18n(e={},t){{const t=createComposer(convertComposerOptions(e)),{__extender:a}=e,r={id:t.id,get locale(){return t.locale.value},set locale(e){t.locale.value=e},get fallbackLocale(){return t.fallbackLocale.value},set fallbackLocale(e){t.fallbackLocale.value=e},get messages(){return t.messages.value},get datetimeFormats(){return t.datetimeFormats.value},get numberFormats(){return t.numberFormats.value},get availableLocales(){return t.availableLocales},get formatter(){return{interpolate:()=>[]}},set formatter(e){},get missing(){return t.getMissingHandler()},set missing(e){t.setMissingHandler(e)},get silentTranslationWarn(){return isBoolean(t.missingWarn)?!t.missingWarn:t.missingWarn},set silentTranslationWarn(e){t.missingWarn=isBoolean(e)?!e:e},get silentFallbackWarn(){return isBoolean(t.fallbackWarn)?!t.fallbackWarn:t.fallbackWarn},set silentFallbackWarn(e){t.fallbackWarn=isBoolean(e)?!e:e},get modifiers(){return t.modifiers},get formatFallbackMessages(){return t.fallbackFormat},set formatFallbackMessages(e){t.fallbackFormat=e},get postTranslation(){return t.getPostTranslationHandler()},set postTranslation(e){t.setPostTranslationHandler(e)},get sync(){return t.inheritLocale},set sync(e){t.inheritLocale=e},get warnHtmlInMessage(){return t.warnHtmlMessage?"warn":"off"},set warnHtmlInMessage(e){t.warnHtmlMessage="off"!==e},get escapeParameterHtml(){return t.escapeParameter},set escapeParameterHtml(e){t.escapeParameter=e},get preserveDirectiveContent(){return!0},set preserveDirectiveContent(e){},get pluralizationRules(){return t.pluralRules||{}},__composer:t,t(...e){const[a,r,n]=e,s={};let l=null,o=null;if(!isString(a))throw Error(I18nErrorCodes.INVALID_ARGUMENT);const i=a;return isString(r)?s.locale=r:isArray(r)?l=r:isPlainObject(r)&&(o=r),isArray(n)?l=n:isPlainObject(n)&&(o=n),Reflect.apply(t.t,t,[i,l||o||{},s])},rt:(...e)=>Reflect.apply(t.rt,t,[...e]),tc(...e){const[a,r,n]=e,s={plural:1};let l=null,o=null;if(!isString(a))throw Error(I18nErrorCodes.INVALID_ARGUMENT);const i=a;return isString(r)?s.locale=r:isNumber(r)?s.plural=r:isArray(r)?l=r:isPlainObject(r)&&(o=r),isString(n)?s.locale=n:isArray(n)?l=n:isPlainObject(n)&&(o=n),Reflect.apply(t.t,t,[i,l||o||{},s])},te:(e,a)=>t.te(e,a),tm:e=>t.tm(e),getLocaleMessage:e=>t.getLocaleMessage(e),setLocaleMessage(e,a){t.setLocaleMessage(e,a)},mergeLocaleMessage(e,a){t.mergeLocaleMessage(e,a)},d:(...e)=>Reflect.apply(t.d,t,[...e]),getDateTimeFormat:e=>t.getDateTimeFormat(e),setDateTimeFormat(e,a){t.setDateTimeFormat(e,a)},mergeDateTimeFormat(e,a){t.mergeDateTimeFormat(e,a)},n:(...e)=>Reflect.apply(t.n,t,[...e]),getNumberFormat:e=>t.getNumberFormat(e),setNumberFormat(e,a){t.setNumberFormat(e,a)},mergeNumberFormat(e,a){t.mergeNumberFormat(e,a)},getChoiceIndex:(e,t)=>-1};return r.__extender=a,r}}const baseFormatProps={tag:{type:[String,Object]},locale:{type:String},scope:{type:String,validator:e=>"parent"===e||"global"===e,default:"parent"},i18n:{type:Object}};function getInterpolateArg({slots:e},t){if(1===t.length&&"default"===t[0]){return(e.default?e.default():[]).reduce(((e,t)=>[...e,...t.type===Fragment?t.children:[t]]),[])}return t.reduce(((t,a)=>{const r=e[a];return r&&(t[a]=r()),t}),create())}function getFragmentableTag(e){return Fragment}const TranslationImpl=defineComponent({name:"i18n-t",props:assign({keypath:{type:String,required:!0},plural:{type:[Number,String],validator:e=>isNumber(e)||!isNaN(e)}},baseFormatProps),setup(e,t){const{slots:a,attrs:r}=t,n=e.i18n||useI18n({useScope:e.scope,__useComponent:!0});return()=>{const s=Object.keys(a).filter((e=>"_"!==e)),l=create();e.locale&&(l.locale=e.locale),void 0!==e.plural&&(l.plural=isString(e.plural)?+e.plural:e.plural);const o=getInterpolateArg(t,s),i=n[TranslateVNodeSymbol](e.keypath,o,l),c=assign(create(),r),u=isString(e.tag)||isObject(e.tag)?e.tag:getFragmentableTag();return h(u,c,i)}}}),Translation=TranslationImpl,I18nT=Translation;function isVNode(e){return isArray(e)&&!isString(e[0])}function renderFormatter(e,t,a,r){const{slots:n,attrs:s}=t;return()=>{const t={part:!0};let l=create();e.locale&&(t.locale=e.locale),isString(e.format)?t.key=e.format:isObject(e.format)&&(isString(e.format.key)&&(t.key=e.format.key),l=Object.keys(e.format).reduce(((t,r)=>a.includes(r)?assign(create(),t,{[r]:e.format[r]}):t),create()));const o=r(e.value,t,l);let i=[t.key];isArray(o)?i=o.map(((e,t)=>{const a=n[e.type],r=a?a({[e.type]:e.value,index:t,parts:o}):[e.value];return isVNode(r)&&(r[0].key=`${e.type}-${t}`),r})):isString(o)&&(i=[o]);const c=assign(create(),s),u=isString(e.tag)||isObject(e.tag)?e.tag:getFragmentableTag();return h(u,c,i)}}const NumberFormatImpl=defineComponent({name:"i18n-n",props:assign({value:{type:Number,required:!0},format:{type:[String,Object]}},baseFormatProps),setup(e,t){const a=e.i18n||useI18n({useScope:e.scope,__useComponent:!0});return renderFormatter(e,t,NUMBER_FORMAT_OPTIONS_KEYS,((...e)=>a[NumberPartsSymbol](...e)))}}),NumberFormat=NumberFormatImpl,I18nN=NumberFormat,DatetimeFormatImpl=defineComponent({name:"i18n-d",props:assign({value:{type:[Number,Date],required:!0},format:{type:[String,Object]}},baseFormatProps),setup(e,t){const a=e.i18n||useI18n({useScope:e.scope,__useComponent:!0});return renderFormatter(e,t,DATETIME_FORMAT_OPTIONS_KEYS,((...e)=>a[DatetimePartsSymbol](...e)))}}),DatetimeFormat=DatetimeFormatImpl,I18nD=DatetimeFormat;function getComposer$1(e,t){const a=e;if("composition"===e.mode)return a.__getInstance(t)||e.global;{const r=a.__getInstance(t);return null!=r?r.__composer:e.global.__composer}}function vTDirective(e){const t=t=>{const{instance:a,modifiers:r,value:n}=t;if(!a||!a.$)throw Error(I18nErrorCodes.UNEXPECTED_ERROR);const s=getComposer$1(e,a.$),l=parseValue(n);return[Reflect.apply(s.t,s,[...makeParams(l)]),s]};return{created:(a,r)=>{const[n,s]=t(r);inBrowser&&e.global===s&&(a.__i18nWatcher=watch(s.locale,(()=>{r.instance&&r.instance.$forceUpdate()}))),a.__composer=s,a.textContent=n},unmounted:e=>{inBrowser&&e.__i18nWatcher&&(e.__i18nWatcher(),e.__i18nWatcher=void 0,delete e.__i18nWatcher),e.__composer&&(e.__composer=void 0,delete e.__composer)},beforeUpdate:(e,{value:t})=>{if(e.__composer){const a=e.__composer,r=parseValue(t);e.textContent=Reflect.apply(a.t,a,[...makeParams(r)])}},getSSRProps:e=>{const[a]=t(e);return{textContent:a}}}}function parseValue(e){if(isString(e))return{path:e};if(isPlainObject(e)){if(!("path"in e))throw Error(I18nErrorCodes.REQUIRED_VALUE,"path");return e}throw Error(I18nErrorCodes.INVALID_VALUE)}function makeParams(e){const{path:t,locale:a,args:r,choice:n,plural:s}=e,l={},o=r||{};return isString(a)&&(l.locale=a),isNumber(n)&&(l.plural=n),isNumber(s)&&(l.plural=s),[t,o,l]}function apply(e,t,...a){const r=isPlainObject(a[0])?a[0]:{},n=!!r.useI18nComponentName;(!isBoolean(r.globalInstall)||r.globalInstall)&&([n?"i18n":Translation.name,"I18nT"].forEach((t=>e.component(t,Translation))),[NumberFormat.name,"I18nN"].forEach((t=>e.component(t,NumberFormat))),[DatetimeFormat.name,"I18nD"].forEach((t=>e.component(t,DatetimeFormat)))),e.directive("t",vTDirective(t))}function defineMixin(e,t,a){return{beforeCreate(){const r=getCurrentInstance();if(!r)throw Error(I18nErrorCodes.UNEXPECTED_ERROR);const n=this.$options;if(n.i18n){const r=n.i18n;if(n.__i18n&&(r.__i18n=n.__i18n),r.__root=t,this===this.$root)this.$i18n=mergeToGlobal(e,r);else{r.__injectWithOption=!0,r.__extender=a.__vueI18nExtend,this.$i18n=createVueI18n(r);const e=this.$i18n;e.__extender&&(e.__disposer=e.__extender(this.$i18n))}}else if(n.__i18n)if(this===this.$root)this.$i18n=mergeToGlobal(e,n);else{this.$i18n=createVueI18n({__i18n:n.__i18n,__injectWithOption:!0,__extender:a.__vueI18nExtend,__root:t});const e=this.$i18n;e.__extender&&(e.__disposer=e.__extender(this.$i18n))}else this.$i18n=e;n.__i18nGlobal&&adjustI18nResources(t,n,n),this.$t=(...e)=>this.$i18n.t(...e),this.$rt=(...e)=>this.$i18n.rt(...e),this.$tc=(...e)=>this.$i18n.tc(...e),this.$te=(e,t)=>this.$i18n.te(e,t),this.$d=(...e)=>this.$i18n.d(...e),this.$n=(...e)=>this.$i18n.n(...e),this.$tm=e=>this.$i18n.tm(e),a.__setInstance(r,this.$i18n)},mounted(){},unmounted(){const e=getCurrentInstance();if(!e)throw Error(I18nErrorCodes.UNEXPECTED_ERROR);const t=this.$i18n;delete this.$t,delete this.$rt,delete this.$tc,delete this.$te,delete this.$d,delete this.$n,delete this.$tm,t.__disposer&&(t.__disposer(),delete t.__disposer,delete t.__extender),a.__deleteInstance(e),delete this.$i18n}}}function mergeToGlobal(e,t){e.locale=t.locale||e.locale,e.fallbackLocale=t.fallbackLocale||e.fallbackLocale,e.missing=t.missing||e.missing,e.silentTranslationWarn=t.silentTranslationWarn||e.silentFallbackWarn,e.silentFallbackWarn=t.silentFallbackWarn||e.silentFallbackWarn,e.formatFallbackMessages=t.formatFallbackMessages||e.formatFallbackMessages,e.postTranslation=t.postTranslation||e.postTranslation,e.warnHtmlInMessage=t.warnHtmlInMessage||e.warnHtmlInMessage,e.escapeParameterHtml=t.escapeParameterHtml||e.escapeParameterHtml,e.sync=t.sync||e.sync,e.__composer[SetPluralRulesSymbol](t.pluralizationRules||e.pluralizationRules);const a=getLocaleMessages(e.locale,{messages:t.messages,__i18n:t.__i18n});return Object.keys(a).forEach((t=>e.mergeLocaleMessage(t,a[t]))),t.datetimeFormats&&Object.keys(t.datetimeFormats).forEach((a=>e.mergeDateTimeFormat(a,t.datetimeFormats[a]))),t.numberFormats&&Object.keys(t.numberFormats).forEach((a=>e.mergeNumberFormat(a,t.numberFormats[a]))),e}const I18nInjectionKey=makeSymbol("global-vue-i18n");function createI18n(e={},t){const a=!isBoolean(e.legacy)||e.legacy,r=!isBoolean(e.globalInjection)||e.globalInjection,n=!a||!!e.allowComposition,s=new Map,[l,o]=createGlobal(e,a),i=makeSymbol("");{const e={get mode(){return a?"legacy":"composition"},get allowComposition(){return n},async install(t,...n){if(t.__VUE_I18N_SYMBOL__=i,t.provide(t.__VUE_I18N_SYMBOL__,e),isPlainObject(n[0])){const t=n[0];e.__composerExtend=t.__composerExtend,e.__vueI18nExtend=t.__vueI18nExtend}let s=null;!a&&r&&(s=injectGlobalFields(t,e.global)),apply(t,e,...n),a&&t.mixin(defineMixin(o,o.__composer,e));const l=t.unmount;t.unmount=()=>{s&&s(),e.dispose(),l()}},get global(){return o},dispose(){l.stop()},__instances:s,__getInstance:function(e){return s.get(e)||null},__setInstance:function(e,t){s.set(e,t)},__deleteInstance:function(e){s.delete(e)}};return e}}function useI18n(e={}){const t=getCurrentInstance();if(null==t)throw Error(I18nErrorCodes.MUST_BE_CALL_SETUP_TOP);if(!t.isCE&&null!=t.appContext.app&&!t.appContext.app.__VUE_I18N_SYMBOL__)throw Error(I18nErrorCodes.NOT_INSTALLED);const a=getI18nInstance(t),r=getGlobalComposer(a),n=getComponentOptions(t),s=getScope(e,n);if("legacy"===a.mode&&!e.__useComponent){if(!a.allowComposition)throw Error(I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE);return useI18nForLegacy(t,s,r,e)}if("global"===s)return adjustI18nResources(r,e,n),r;if("parent"===s){let n=getComposer(a,t,e.__useComponent);return null==n&&(n=r),n}const l=a;let o=l.__getInstance(t);if(null==o){const a=assign({},e);"__i18n"in n&&(a.__i18n=n.__i18n),r&&(a.__root=r),o=createComposer(a),l.__composerExtend&&(o[DisposeSymbol]=l.__composerExtend(o)),setupLifeCycle(l,t,o),l.__setInstance(t,o)}return o}const castToVueI18n=e=>{if(!(__VUE_I18N_BRIDGE__ in e))throw Error(I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N);return e};function createGlobal(e,t,a){const r=effectScope();{const a=t?r.run((()=>createVueI18n(e))):r.run((()=>createComposer(e)));if(null==a)throw Error(I18nErrorCodes.UNEXPECTED_ERROR);return[r,a]}}function getI18nInstance(e){{const t=inject(e.isCE?I18nInjectionKey:e.appContext.app.__VUE_I18N_SYMBOL__);if(!t)throw createI18nError(e.isCE?I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE:I18nErrorCodes.UNEXPECTED_ERROR);return t}}function getScope(e,t){return isEmptyObject(e)?"__i18n"in t?"local":"global":e.useScope?e.useScope:"local"}function getGlobalComposer(e){return"composition"===e.mode?e.global:e.global.__composer}function getComposer(e,t,a=!1){let r=null;const n=t.root;let s=getParentComponentInstance(t,a);for(;null!=s;){const t=e;if("composition"===e.mode)r=t.__getInstance(s);else{const e=t.__getInstance(s);null!=e&&(r=e.__composer,a&&r&&!r[InejctWithOptionSymbol]&&(r=null))}if(null!=r)break;if(n===s)break;s=s.parent}return r}function getParentComponentInstance(e,t=!1){return null==e?null:t&&e.vnode.ctx||e.parent}function setupLifeCycle(e,t,a){onMounted((()=>{}),t),onUnmounted((()=>{const r=a;e.__deleteInstance(t);const n=r[DisposeSymbol];n&&(n(),delete r[DisposeSymbol])}),t)}function useI18nForLegacy(e,t,a,r={}){const n="local"===t,s=shallowRef(null);if(n&&e.proxy&&!e.proxy.$options.i18n&&!e.proxy.$options.__i18n)throw Error(I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION);const l=isBoolean(r.inheritLocale)?r.inheritLocale:!isString(r.locale),o=ref(!n||l?a.locale.value:isString(r.locale)?r.locale:DEFAULT_LOCALE),i=ref(!n||l?a.fallbackLocale.value:isString(r.fallbackLocale)||isArray(r.fallbackLocale)||isPlainObject(r.fallbackLocale)||!1===r.fallbackLocale?r.fallbackLocale:o.value),c=ref(getLocaleMessages(o.value,r)),u=ref(isPlainObject(r.datetimeFormats)?r.datetimeFormats:{[o.value]:{}}),m=ref(isPlainObject(r.numberFormats)?r.numberFormats:{[o.value]:{}}),g=n?a.missingWarn:!isBoolean(r.missingWarn)&&!isRegExp(r.missingWarn)||r.missingWarn,_=n?a.fallbackWarn:!isBoolean(r.fallbackWarn)&&!isRegExp(r.fallbackWarn)||r.fallbackWarn,f=n?a.fallbackRoot:!isBoolean(r.fallbackRoot)||r.fallbackRoot,p=!!r.fallbackFormat,b=isFunction(r.missing)?r.missing:null,E=isFunction(r.postTranslation)?r.postTranslation:null,d=n?a.warnHtmlMessage:!isBoolean(r.warnHtmlMessage)||r.warnHtmlMessage,O=!!r.escapeParameter,v=n?a.modifiers:isPlainObject(r.modifiers)?r.modifiers:{},T=r.pluralRules||n&&a.pluralRules;function S(e){return o.value,i.value,c.value,u.value,m.value,e()}const N={get id(){return s.value?s.value.id:-1},locale:computed({get:()=>s.value?s.value.locale.value:o.value,set:e=>{s.value&&(s.value.locale.value=e),o.value=e}}),fallbackLocale:computed({get:()=>s.value?s.value.fallbackLocale.value:i.value,set:e=>{s.value&&(s.value.fallbackLocale.value=e),i.value=e}}),messages:computed((()=>s.value?s.value.messages.value:c.value)),datetimeFormats:computed((()=>u.value)),numberFormats:computed((()=>m.value)),get inheritLocale(){return s.value?s.value.inheritLocale:l},set inheritLocale(e){s.value&&(s.value.inheritLocale=e)},get availableLocales(){return s.value?s.value.availableLocales:Object.keys(c.value)},get modifiers(){return s.value?s.value.modifiers:v},get pluralRules(){return s.value?s.value.pluralRules:T},get isGlobal(){return!!s.value&&s.value.isGlobal},get missingWarn(){return s.value?s.value.missingWarn:g},set missingWarn(e){s.value&&(s.value.missingWarn=e)},get fallbackWarn(){return s.value?s.value.fallbackWarn:_},set fallbackWarn(e){s.value&&(s.value.missingWarn=e)},get fallbackRoot(){return s.value?s.value.fallbackRoot:f},set fallbackRoot(e){s.value&&(s.value.fallbackRoot=e)},get fallbackFormat(){return s.value?s.value.fallbackFormat:p},set fallbackFormat(e){s.value&&(s.value.fallbackFormat=e)},get warnHtmlMessage(){return s.value?s.value.warnHtmlMessage:d},set warnHtmlMessage(e){s.value&&(s.value.warnHtmlMessage=e)},get escapeParameter(){return s.value?s.value.escapeParameter:O},set escapeParameter(e){s.value&&(s.value.escapeParameter=e)},t:function(...e){return s.value?S((()=>Reflect.apply(s.value.t,null,[...e]))):S((()=>""))},getPostTranslationHandler:function(){return s.value?s.value.getPostTranslationHandler():E},setPostTranslationHandler:function(e){s.value&&s.value.setPostTranslationHandler(e)},getMissingHandler:function(){return s.value?s.value.getMissingHandler():b},setMissingHandler:function(e){s.value&&s.value.setMissingHandler(e)},rt:function(...e){return s.value?Reflect.apply(s.value.rt,null,[...e]):""},d:function(...e){return s.value?S((()=>Reflect.apply(s.value.d,null,[...e]))):S((()=>""))},n:function(...e){return s.value?S((()=>Reflect.apply(s.value.n,null,[...e]))):S((()=>""))},tm:function(e){return s.value?s.value.tm(e):{}},te:function(e,t){return!!s.value&&s.value.te(e,t)},getLocaleMessage:function(e){return s.value?s.value.getLocaleMessage(e):{}},setLocaleMessage:function(e,t){s.value&&(s.value.setLocaleMessage(e,t),c.value[e]=t)},mergeLocaleMessage:function(e,t){s.value&&s.value.mergeLocaleMessage(e,t)},getDateTimeFormat:function(e){return s.value?s.value.getDateTimeFormat(e):{}},setDateTimeFormat:function(e,t){s.value&&(s.value.setDateTimeFormat(e,t),u.value[e]=t)},mergeDateTimeFormat:function(e,t){s.value&&s.value.mergeDateTimeFormat(e,t)},getNumberFormat:function(e){return s.value?s.value.getNumberFormat(e):{}},setNumberFormat:function(e,t){s.value&&(s.value.setNumberFormat(e,t),m.value[e]=t)},mergeNumberFormat:function(e,t){s.value&&s.value.mergeNumberFormat(e,t)}};return onBeforeMount((()=>{if(null==e.proxy||null==e.proxy.$i18n)throw Error(I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY);const a=s.value=e.proxy.$i18n.__composer;"global"===t?(o.value=a.locale.value,i.value=a.fallbackLocale.value,c.value=a.messages.value,u.value=a.datetimeFormats.value,m.value=a.numberFormats.value):n&&function(e){e.locale.value=o.value,e.fallbackLocale.value=i.value,Object.keys(c.value).forEach((t=>{e.mergeLocaleMessage(t,c.value[t])})),Object.keys(u.value).forEach((t=>{e.mergeDateTimeFormat(t,u.value[t])})),Object.keys(m.value).forEach((t=>{e.mergeNumberFormat(t,m.value[t])})),e.escapeParameter=O,e.fallbackFormat=p,e.fallbackRoot=f,e.fallbackWarn=_,e.missingWarn=g,e.warnHtmlMessage=d}(a)})),N}const globalExportProps=["locale","fallbackLocale","availableLocales"],globalExportMethods=["t","rt","d","n","tm","te"];function injectGlobalFields(e,t){const a=Object.create(null);globalExportProps.forEach((e=>{const r=Object.getOwnPropertyDescriptor(t,e);if(!r)throw Error(I18nErrorCodes.UNEXPECTED_ERROR);const n=isRef(r.value)?{get:()=>r.value.value,set(e){r.value.value=e}}:{get:()=>r.get&&r.get()};Object.defineProperty(a,e,n)})),e.config.globalProperties.$i18n=a,globalExportMethods.forEach((a=>{const r=Object.getOwnPropertyDescriptor(t,a);if(!r||!r.value)throw Error(I18nErrorCodes.UNEXPECTED_ERROR);Object.defineProperty(e.config.globalProperties,`$${a}`,r)}));return()=>{delete e.config.globalProperties.$i18n,globalExportMethods.forEach((t=>{delete e.config.globalProperties[`$${t}`]}))}}registerMessageResolver(resolveValue),registerLocaleFallbacker(fallbackWithLocaleChain);export{DatetimeFormat,I18nD,I18nInjectionKey,I18nN,I18nT,NumberFormat,Translation,VERSION,castToVueI18n,createI18n,useI18n,vTDirective}; diff --git a/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-bundler.js b/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-bundler.js new file mode 100644 index 0000000..195ef35 --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-bundler.js @@ -0,0 +1 @@ +export * from '../dist/vue-i18n.runtime.mjs' \ No newline at end of file diff --git a/node_modules/vue-i18n/dist/vue-i18n.runtime.global.js b/node_modules/vue-i18n/dist/vue-i18n.runtime.global.js new file mode 100644 index 0000000..734d3ba --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.runtime.global.js @@ -0,0 +1,5134 @@ +/*! + * vue-i18n v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +var VueI18n = (function (exports, vue) { + 'use strict'; + + function warn(msg, err) { + if (typeof console !== 'undefined') { + console.warn(`[intlify] ` + msg); + /* istanbul ignore if */ + if (err) { + console.warn(err.stack); + } + } + } + const hasWarned = {}; + function warnOnce(msg) { + if (!hasWarned[msg]) { + hasWarned[msg] = true; + warn(msg); + } + } + + /** + * Original Utilities + * written by kazuya kawaguchi + */ + const inBrowser = typeof window !== 'undefined'; + let mark; + let measure; + { + const perf = inBrowser && window.performance; + if (perf && + perf.mark && + perf.measure && + perf.clearMarks && + // @ts-ignore browser compat + perf.clearMeasures) { + mark = (tag) => { + perf.mark(tag); + }; + measure = (name, startTag, endTag) => { + perf.measure(name, startTag, endTag); + perf.clearMarks(startTag); + perf.clearMarks(endTag); + }; + } + } + const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g; + /* eslint-disable */ + function format(message, ...args) { + if (args.length === 1 && isObject(args[0])) { + args = args[0]; + } + if (!args || !args.hasOwnProperty) { + args = {}; + } + return message.replace(RE_ARGS, (match, identifier) => { + return args.hasOwnProperty(identifier) ? args[identifier] : ''; + }); + } + const makeSymbol = (name, shareable = false) => !shareable ? Symbol(name) : Symbol.for(name); + const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({ l: locale, k: key, s: source }); + const friendlyJSONstringify = (json) => JSON.stringify(json) + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029') + .replace(/\u0027/g, '\\u0027'); + const isNumber = (val) => typeof val === 'number' && isFinite(val); + const isDate = (val) => toTypeString(val) === '[object Date]'; + const isRegExp = (val) => toTypeString(val) === '[object RegExp]'; + const isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0; + const assign = Object.assign; + const _create = Object.create; + const create = (obj = null) => _create(obj); + let _globalThis; + const getGlobalThis = () => { + // prettier-ignore + return (_globalThis || + (_globalThis = + typeof globalThis !== 'undefined' + ? globalThis + : typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : create())); + }; + function escapeHtml(rawText) { + return rawText + .replace(/&/g, '&') // escape `&` first to avoid double escaping + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/\//g, '/') // escape `/` to prevent closing tags or JavaScript URLs + .replace(/=/g, '='); // escape `=` to prevent attribute injection + } + function escapeAttributeValue(value) { + return value + .replace(/&(?![a-zA-Z0-9#]{2,6};)/g, '&') // escape unescaped `&` + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(//g, '>'); + } + function sanitizeTranslatedHtml(html) { + // Escape dangerous characters in attribute values + // Process attributes with double quotes + html = html.replace(/(\w+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${escapeAttributeValue(attrValue)}"`); + // Process attributes with single quotes + html = html.replace(/(\w+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${escapeAttributeValue(attrValue)}'`); + // Detect and neutralize event handler attributes + const eventHandlerPattern = /\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi; + if (eventHandlerPattern.test(html)) { + { + warn('Potentially dangerous event handlers detected in translation. ' + + 'Consider removing onclick, onerror, etc. from your translation messages.'); + } + // Neutralize event handler attributes by escaping 'on' + html = html.replace(/(\s+)(on)(\w+\s*=)/gi, '$1on$3'); + } + // Disable javascript: URLs in various contexts + const javascriptUrlPattern = [ + // In href, src, action, formaction attributes + /(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi, + // In style attributes within url() + /(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi + ]; + javascriptUrlPattern.forEach(pattern => { + html = html.replace(pattern, '$1javascript:'); + }); + return html; + } + const hasOwnProperty = Object.prototype.hasOwnProperty; + function hasOwn(obj, key) { + return hasOwnProperty.call(obj, key); + } + /* eslint-enable */ + /** + * Useful Utilities By Evan you + * Modified by kazuya kawaguchi + * MIT License + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts + * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts + */ + const isArray = Array.isArray; + const isFunction = (val) => typeof val === 'function'; + const isString = (val) => typeof val === 'string'; + const isBoolean = (val) => typeof val === 'boolean'; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const isObject = (val) => val !== null && typeof val === 'object'; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const isPromise = (val) => { + return isObject(val) && isFunction(val.then) && isFunction(val.catch); + }; + const objectToString = Object.prototype.toString; + const toTypeString = (value) => objectToString.call(value); + const isPlainObject = (val) => { + if (!isObject(val)) + return false; + const proto = Object.getPrototypeOf(val); + return proto === null || proto.constructor === Object; + }; + // for converting list and named values to displayed strings. + const toDisplayString = (val) => { + return val == null + ? '' + : isArray(val) || (isPlainObject(val) && val.toString === objectToString) + ? JSON.stringify(val, null, 2) + : String(val); + }; + function join(items, separator = '') { + return items.reduce((str, item, index) => (index === 0 ? str + item : str + separator + item), ''); + } + const RANGE = 2; + function generateCodeFrame(source, start = 0, end = source.length) { + const lines = source.split(/\r?\n/); + let count = 0; + const res = []; + for (let i = 0; i < lines.length; i++) { + count += lines[i].length + 1; + if (count >= start) { + for (let j = i - RANGE; j <= i + RANGE || end > count; j++) { + if (j < 0 || j >= lines.length) + continue; + const line = j + 1; + res.push(`${line}${' '.repeat(3 - String(line).length)}| ${lines[j]}`); + const lineLength = lines[j].length; + if (j === i) { + // push underline + const pad = start - (count - lineLength) + 1; + const length = Math.max(1, end > count ? lineLength - pad : end - start); + res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length)); + } + else if (j > i) { + if (end > count) { + const length = Math.max(Math.min(end - count, lineLength), 1); + res.push(` | ` + '^'.repeat(length)); + } + count += lineLength + 1; + } + } + break; + } + } + return res.join('\n'); + } + function incrementer(code) { + let current = code; + return () => ++current; + } + + /** + * Event emitter, forked from the below: + * - original repository url: https://github.com/developit/mitt + * - code url: https://github.com/developit/mitt/blob/master/src/index.ts + * - author: Jason Miller (https://github.com/developit) + * - license: MIT + */ + /** + * Create a event emitter + * + * @returns An event emitter + */ + function createEmitter() { + const events = new Map(); + const emitter = { + events, + on(event, handler) { + const handlers = events.get(event); + const added = handlers && handlers.push(handler); + if (!added) { + events.set(event, [handler]); + } + }, + off(event, handler) { + const handlers = events.get(event); + if (handlers) { + handlers.splice(handlers.indexOf(handler) >>> 0, 1); + } + }, + emit(event, payload) { + (events.get(event) || []) + .slice() + .map(handler => handler(payload)); + (events.get('*') || []) + .slice() + .map(handler => handler(event, payload)); + } + }; + return emitter; + } + + const isNotObjectOrIsArray = (val) => !isObject(val) || isArray(val); + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + function deepCopy(src, des) { + // src and des should both be objects, and none of them can be a array + if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des)) { + throw new Error('Invalid value'); + } + const stack = [{ src, des }]; + while (stack.length) { + const { src, des } = stack.pop(); + // using `Object.keys` which skips prototype properties + Object.keys(src).forEach(key => { + if (key === '__proto__') { + return; + } + // if src[key] is an object/array, set des[key] + // to empty object/array to prevent setting by reference + if (isObject(src[key]) && !isObject(des[key])) { + des[key] = Array.isArray(src[key]) ? [] : create(); + } + if (isNotObjectOrIsArray(des[key]) || isNotObjectOrIsArray(src[key])) { + // replace with src[key] when: + // src[key] or des[key] is not an object, or + // src[key] or des[key] is an array + des[key] = src[key]; + } + else { + // src[key] and des[key] are both objects, merge them + stack.push({ src: src[key], des: des[key] }); + } + }); + } + } + + const CompileWarnCodes = { + USE_MODULO_SYNTAX: 1, + __EXTEND_POINT__: 2 + }; + + const CompileErrorCodes = { + // tokenizer error codes + EXPECTED_TOKEN: 1, + INVALID_TOKEN_IN_PLACEHOLDER: 2, + UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3, + UNKNOWN_ESCAPE_SEQUENCE: 4, + INVALID_UNICODE_ESCAPE_SEQUENCE: 5, + UNBALANCED_CLOSING_BRACE: 6, + UNTERMINATED_CLOSING_BRACE: 7, + EMPTY_PLACEHOLDER: 8, + NOT_ALLOW_NEST_PLACEHOLDER: 9, + INVALID_LINKED_FORMAT: 10, + // parser error codes + MUST_HAVE_MESSAGES_IN_PLURAL: 11, + UNEXPECTED_EMPTY_LINKED_MODIFIER: 12, + UNEXPECTED_EMPTY_LINKED_KEY: 13, + UNEXPECTED_LEXICAL_ANALYSIS: 14, + // generator error codes + UNHANDLED_CODEGEN_NODE_TYPE: 15, + // minifier error codes + UNHANDLED_MINIFIER_NODE_TYPE: 16, + // Special value for higher-order compilers to pick up the last code + // to avoid collision of error codes. This should always be kept as the last + // item. + __EXTEND_POINT__: 17 + }; + /** @internal */ + const errorMessages$2 = { + // tokenizer error messages + [CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`, + [CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`, + [CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`, + [CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`, + [CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`, + [CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`, + [CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`, + [CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`, + [CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`, + [CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`, + // parser error messages + [CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`, + [CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`, + [CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`, + // generator error messages + [CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`, + // minimizer error messages + [CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'` + }; + function createCompileError(code, loc, options = {}) { + const { domain, messages, args } = options; + const msg = format((messages || errorMessages$2)[code] || '', ...(args || [])) + ; + const error = new SyntaxError(String(msg)); + error.code = code; + if (loc) { + error.location = loc; + } + error.domain = domain; + return error; + } + + function isMessageAST(val) { + return (isObject(val) && + resolveType(val) === 0 && + (hasOwn(val, 'b') || hasOwn(val, 'body'))); + } + const PROPS_BODY = ['b', 'body']; + const PROPS_CASES = ['c', 'cases']; + const PROPS_STATIC = ['s', 'static']; + const PROPS_ITEMS = ['i', 'items']; + const PROPS_TYPE = ['t', 'type']; + function resolveType(node) { + return resolveProps(node, PROPS_TYPE); + } + const PROPS_VALUE = ['v', 'value']; + const PROPS_MODIFIER = ['m', 'modifier']; + const PROPS_KEY = ['k', 'key']; + function resolveProps(node, props, defaultValue) { + for (let i = 0; i < props.length; i++) { + const prop = props[i]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (hasOwn(node, prop) && node[prop] != null) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return node[prop]; + } + } + return defaultValue; + } + const AST_NODE_PROPS_KEYS = [ + ...PROPS_BODY, + ...PROPS_CASES, + ...PROPS_STATIC, + ...PROPS_ITEMS, + ...PROPS_KEY, + ...PROPS_MODIFIER, + ...PROPS_VALUE, + ...PROPS_TYPE + ]; + + const pathStateMachine = []; + pathStateMachine[0 /* States.BEFORE_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [0 /* States.BEFORE_PATH */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] + }; + pathStateMachine[1 /* States.IN_PATH */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */] + }; + pathStateMachine[2 /* States.BEFORE_IDENT */] = { + ["w" /* PathCharTypes.WORKSPACE */]: [2 /* States.BEFORE_IDENT */], + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */] + }; + pathStateMachine[3 /* States.IN_IDENT */] = { + ["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */], + ["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */, 1 /* Actions.PUSH */], + ["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */, 1 /* Actions.PUSH */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */, 1 /* Actions.PUSH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */, 1 /* Actions.PUSH */] + }; + pathStateMachine[4 /* States.IN_SUB_PATH */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */], + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */], + ["[" /* PathCharTypes.LEFT_BRACKET */]: [ + 4 /* States.IN_SUB_PATH */, + 2 /* Actions.INC_SUB_PATH_DEPTH */ + ], + ["]" /* PathCharTypes.RIGHT_BRACKET */]: [1 /* States.IN_PATH */, 3 /* Actions.PUSH_SUB_PATH */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */] + }; + pathStateMachine[5 /* States.IN_SINGLE_QUOTE */] = { + ["'" /* PathCharTypes.SINGLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */] + }; + pathStateMachine[6 /* States.IN_DOUBLE_QUOTE */] = { + ["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */], + ["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */, + ["l" /* PathCharTypes.ELSE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */] + }; + /** + * Check if an expression is a literal value. + */ + const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/; + function isLiteral(exp) { + return literalValueRE.test(exp); + } + /** + * Strip quotes from a string + */ + function stripQuotes(str) { + const a = str.charCodeAt(0); + const b = str.charCodeAt(str.length - 1); + return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str; + } + /** + * Determine the type of a character in a keypath. + */ + function getPathCharType(ch) { + if (ch === undefined || ch === null) { + return "o" /* PathCharTypes.END_OF_FAIL */; + } + const code = ch.charCodeAt(0); + switch (code) { + case 0x5b: // [ + case 0x5d: // ] + case 0x2e: // . + case 0x22: // " + case 0x27: // ' + return ch; + case 0x5f: // _ + case 0x24: // $ + case 0x2d: // - + return "i" /* PathCharTypes.IDENT */; + case 0x09: // Tab (HT) + case 0x0a: // Newline (LF) + case 0x0d: // Return (CR) + case 0xa0: // No-break space (NBSP) + case 0xfeff: // Byte Order Mark (BOM) + case 0x2028: // Line Separator (LS) + case 0x2029: // Paragraph Separator (PS) + return "w" /* PathCharTypes.WORKSPACE */; + } + return "i" /* PathCharTypes.IDENT */; + } + /** + * Format a subPath, return its plain form if it is + * a literal string or number. Otherwise prepend the + * dynamic indicator (*). + */ + function formatSubPath(path) { + const trimmed = path.trim(); + // invalid leading 0 + if (path.charAt(0) === '0' && isNaN(parseInt(path))) { + return false; + } + return isLiteral(trimmed) + ? stripQuotes(trimmed) + : "*" /* PathCharTypes.ASTARISK */ + trimmed; + } + /** + * Parse a string path into an array of segments + */ + function parse(path) { + const keys = []; + let index = -1; + let mode = 0 /* States.BEFORE_PATH */; + let subPathDepth = 0; + let c; + let key; // eslint-disable-line + let newChar; + let type; + let transition; + let action; + let typeMap; + const actions = []; + actions[0 /* Actions.APPEND */] = () => { + if (key === undefined) { + key = newChar; + } + else { + key += newChar; + } + }; + actions[1 /* Actions.PUSH */] = () => { + if (key !== undefined) { + keys.push(key); + key = undefined; + } + }; + actions[2 /* Actions.INC_SUB_PATH_DEPTH */] = () => { + actions[0 /* Actions.APPEND */](); + subPathDepth++; + }; + actions[3 /* Actions.PUSH_SUB_PATH */] = () => { + if (subPathDepth > 0) { + subPathDepth--; + mode = 4 /* States.IN_SUB_PATH */; + actions[0 /* Actions.APPEND */](); + } + else { + subPathDepth = 0; + if (key === undefined) { + return false; + } + key = formatSubPath(key); + if (key === false) { + return false; + } + else { + actions[1 /* Actions.PUSH */](); + } + } + }; + function maybeUnescapeQuote() { + const nextChar = path[index + 1]; + if ((mode === 5 /* States.IN_SINGLE_QUOTE */ && + nextChar === "'" /* PathCharTypes.SINGLE_QUOTE */) || + (mode === 6 /* States.IN_DOUBLE_QUOTE */ && + nextChar === "\"" /* PathCharTypes.DOUBLE_QUOTE */)) { + index++; + newChar = '\\' + nextChar; + actions[0 /* Actions.APPEND */](); + return true; + } + } + while (mode !== null) { + index++; + c = path[index]; + if (c === '\\' && maybeUnescapeQuote()) { + continue; + } + type = getPathCharType(c); + typeMap = pathStateMachine[mode]; + transition = typeMap[type] || typeMap["l" /* PathCharTypes.ELSE */] || 8 /* States.ERROR */; + // check parse error + if (transition === 8 /* States.ERROR */) { + return; + } + mode = transition[0]; + if (transition[1] !== undefined) { + action = actions[transition[1]]; + if (action) { + newChar = c; + if (action() === false) { + return; + } + } + } + // check parse finish + if (mode === 7 /* States.AFTER_PATH */) { + return keys; + } + } + } + // path token cache + const cache = new Map(); + /** + * key-value message resolver + * + * @remarks + * Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ + function resolveWithKeyValue(obj, path) { + return isObject(obj) ? obj[path] : null; + } + /** + * message resolver + * + * @remarks + * Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default. + * + * @param obj - A target object to be resolved with path + * @param path - A {@link Path | path} to resolve the value of message + * + * @returns A resolved {@link PathValue | path value} + * + * @VueI18nGeneral + */ + function resolveValue(obj, path) { + // check object + if (!isObject(obj)) { + return null; + } + // parse path + let hit = cache.get(path); + if (!hit) { + hit = parse(path); + if (hit) { + cache.set(path, hit); + } + } + // check hit + if (!hit) { + return null; + } + // resolve path value + const len = hit.length; + let last = obj; + let i = 0; + while (i < len) { + const key = hit[i]; + /** + * NOTE: + * if `key` is intlify message format AST node key and `last` is intlify message format AST, skip it. + * because the AST node is not a key-value structure. + */ + if (AST_NODE_PROPS_KEYS.includes(key) && isMessageAST(last)) { + return null; + } + const val = last[key]; + if (val === undefined) { + return null; + } + if (isFunction(last)) { + return null; + } + last = val; + i++; + } + return last; + } + + const DEFAULT_MODIFIER = (str) => str; + const DEFAULT_MESSAGE = (ctx) => ''; // eslint-disable-line + const DEFAULT_MESSAGE_DATA_TYPE = 'text'; + const DEFAULT_NORMALIZE = (values) => values.length === 0 ? '' : join(values); + const DEFAULT_INTERPOLATE = toDisplayString; + function pluralDefault(choice, choicesLength) { + choice = Math.abs(choice); + if (choicesLength === 2) { + // prettier-ignore + return choice + ? choice > 1 + ? 1 + : 0 + : 1; + } + return choice ? Math.min(choice, 2) : 0; + } + function getPluralIndex(options) { + // prettier-ignore + const index = isNumber(options.pluralIndex) + ? options.pluralIndex + : -1; + // prettier-ignore + return options.named && (isNumber(options.named.count) || isNumber(options.named.n)) + ? isNumber(options.named.count) + ? options.named.count + : isNumber(options.named.n) + ? options.named.n + : index + : index; + } + function normalizeNamed(pluralIndex, props) { + if (!props.count) { + props.count = pluralIndex; + } + if (!props.n) { + props.n = pluralIndex; + } + } + function createMessageContext(options = {}) { + const locale = options.locale; + const pluralIndex = getPluralIndex(options); + const pluralRule = isObject(options.pluralRules) && + isString(locale) && + isFunction(options.pluralRules[locale]) + ? options.pluralRules[locale] + : pluralDefault; + const orgPluralRule = isObject(options.pluralRules) && + isString(locale) && + isFunction(options.pluralRules[locale]) + ? pluralDefault + : undefined; + const plural = (messages) => { + return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)]; + }; + const _list = options.list || []; + const list = (index) => _list[index]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _named = options.named || create(); + isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named); + const named = (key) => _named[key]; + function message(key) { + // prettier-ignore + const msg = isFunction(options.messages) + ? options.messages(key) + : isObject(options.messages) + ? options.messages[key] + : false; + return !msg + ? options.parent + ? options.parent.message(key) // resolve from parent messages + : DEFAULT_MESSAGE + : msg; + } + const _modifier = (name) => options.modifiers + ? options.modifiers[name] + : DEFAULT_MODIFIER; + const normalize = isPlainObject(options.processor) && isFunction(options.processor.normalize) + ? options.processor.normalize + : DEFAULT_NORMALIZE; + const interpolate = isPlainObject(options.processor) && + isFunction(options.processor.interpolate) + ? options.processor.interpolate + : DEFAULT_INTERPOLATE; + const type = isPlainObject(options.processor) && isString(options.processor.type) + ? options.processor.type + : DEFAULT_MESSAGE_DATA_TYPE; + const linked = (key, ...args) => { + const [arg1, arg2] = args; + let type = 'text'; + let modifier = ''; + if (args.length === 1) { + if (isObject(arg1)) { + modifier = arg1.modifier || modifier; + type = arg1.type || type; + } + else if (isString(arg1)) { + modifier = arg1 || modifier; + } + } + else if (args.length === 2) { + if (isString(arg1)) { + modifier = arg1 || modifier; + } + if (isString(arg2)) { + type = arg2 || type; + } + } + const ret = message(key)(ctx); + const msg = + // The message in vnode resolved with linked are returned as an array by processor.nomalize + type === 'vnode' && isArray(ret) && modifier + ? ret[0] + : ret; + return modifier ? _modifier(modifier)(msg, type) : msg; + }; + const ctx = { + ["list" /* HelperNameMap.LIST */]: list, + ["named" /* HelperNameMap.NAMED */]: named, + ["plural" /* HelperNameMap.PLURAL */]: plural, + ["linked" /* HelperNameMap.LINKED */]: linked, + ["message" /* HelperNameMap.MESSAGE */]: message, + ["type" /* HelperNameMap.TYPE */]: type, + ["interpolate" /* HelperNameMap.INTERPOLATE */]: interpolate, + ["normalize" /* HelperNameMap.NORMALIZE */]: normalize, + ["values" /* HelperNameMap.VALUES */]: assign(create(), _list, _named) + }; + return ctx; + } + + let devtools = null; + function setDevToolsHook(hook) { + devtools = hook; + } + function initI18nDevTools(i18n, version, meta) { + // TODO: queue if devtools is undefined + devtools && + devtools.emit("i18n:init" /* IntlifyDevToolsHooks.I18nInit */, { + timestamp: Date.now(), + i18n, + version, + meta + }); + } + const translateDevTools = /* #__PURE__*/ createDevToolsHook("function:translate" /* IntlifyDevToolsHooks.FunctionTranslate */); + function createDevToolsHook(hook) { + return (payloads) => devtools && devtools.emit(hook, payloads); + } + + const code$3 = CompileWarnCodes.__EXTEND_POINT__; + const inc$3 = incrementer(code$3); + const CoreWarnCodes = { + NOT_FOUND_KEY: code$3, // 2 + FALLBACK_TO_TRANSLATE: inc$3(), // 3 + CANNOT_FORMAT_NUMBER: inc$3(), // 4 + FALLBACK_TO_NUMBER_FORMAT: inc$3(), // 5 + CANNOT_FORMAT_DATE: inc$3(), // 6 + FALLBACK_TO_DATE_FORMAT: inc$3(), // 7 + EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc$3(), // 8 + __EXTEND_POINT__: inc$3() // 9 + }; + /** @internal */ + const warnMessages$1 = { + [CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`, + [CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`, + [CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`, + [CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`, + [CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]: `This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future.` + }; + function getWarnMessage$1(code, ...args) { + return format(warnMessages$1[code], ...args); + } + + const code$2 = CompileErrorCodes.__EXTEND_POINT__; + const inc$2 = incrementer(code$2); + const CoreErrorCodes = { + INVALID_ARGUMENT: code$2, // 17 + INVALID_DATE_ARGUMENT: inc$2(), // 18 + INVALID_ISO_DATE_ARGUMENT: inc$2(), // 19 + NOT_SUPPORT_NON_STRING_MESSAGE: inc$2(), // 20 + NOT_SUPPORT_LOCALE_PROMISE_VALUE: inc$2(), // 21 + NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: inc$2(), // 22 + NOT_SUPPORT_LOCALE_TYPE: inc$2(), // 23 + __EXTEND_POINT__: inc$2() // 24 + }; + function createCoreError(code) { + return createCompileError(code, null, { messages: errorMessages$1 } ); + } + /** @internal */ + const errorMessages$1 = { + [CoreErrorCodes.INVALID_ARGUMENT]: 'Invalid arguments', + [CoreErrorCodes.INVALID_DATE_ARGUMENT]: 'The date provided is an invalid Date object.' + + 'Make sure your Date represents a valid date.', + [CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: 'The argument provided is not a valid ISO date string', + [CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE]: 'Not support non-string message', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]: 'cannot support promise value', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]: 'cannot support async function', + [CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: 'cannot support locale type' + }; + + /** @internal */ + function getLocale(context, options) { + return options.locale != null + ? resolveLocale(options.locale) + : resolveLocale(context.locale); + } + let _resolveLocale; + /** @internal */ + function resolveLocale(locale) { + if (isString(locale)) { + return locale; + } + else { + if (isFunction(locale)) { + if (locale.resolvedOnce && _resolveLocale != null) { + return _resolveLocale; + } + else if (locale.constructor.name === 'Function') { + const resolve = locale(); + if (isPromise(resolve)) { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE); + } + return (_resolveLocale = resolve); + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION); + } + } + else { + throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE); + } + } + } + /** + * Fallback with simple implemenation + * + * @remarks + * A fallback locale function implemented with a simple fallback algorithm. + * + * Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nGeneral + */ + function fallbackWithSimple(ctx, fallback, start // eslint-disable-line @typescript-eslint/no-unused-vars + ) { + // prettier-ignore + return [...new Set([ + start, + ...(isArray(fallback) + ? fallback + : isObject(fallback) + ? Object.keys(fallback) + : isString(fallback) + ? [fallback] + : [start]) + ])]; + } + /** + * Fallback with locale chain + * + * @remarks + * A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default. + * + * @param ctx - A {@link CoreContext | context} + * @param fallback - A {@link FallbackLocale | fallback locale} + * @param start - A starting {@link Locale | locale} + * + * @returns Fallback locales + * + * @VueI18nSee [Fallbacking](../guide/essentials/fallback) + * + * @VueI18nGeneral + */ + function fallbackWithLocaleChain(ctx, fallback, start) { + const startLocale = isString(start) ? start : DEFAULT_LOCALE; + const context = ctx; + if (!context.__localeChainCache) { + context.__localeChainCache = new Map(); + } + let chain = context.__localeChainCache.get(startLocale); + if (!chain) { + chain = []; + // first block defined by start + let block = [start]; + // while any intervening block found + while (isArray(block)) { + block = appendBlockToChain(chain, block, fallback); + } + // prettier-ignore + // last block defined by default + const defaults = isArray(fallback) || !isPlainObject(fallback) + ? fallback + : fallback['default'] + ? fallback['default'] + : null; + // convert defaults to array + block = isString(defaults) ? [defaults] : defaults; + if (isArray(block)) { + appendBlockToChain(chain, block, false); + } + context.__localeChainCache.set(startLocale, chain); + } + return chain; + } + function appendBlockToChain(chain, block, blocks) { + let follow = true; + for (let i = 0; i < block.length && isBoolean(follow); i++) { + const locale = block[i]; + if (isString(locale)) { + follow = appendLocaleToChain(chain, block[i], blocks); + } + } + return follow; + } + function appendLocaleToChain(chain, locale, blocks) { + let follow; + const tokens = locale.split('-'); + do { + const target = tokens.join('-'); + follow = appendItemToChain(chain, target, blocks); + tokens.splice(-1, 1); + } while (tokens.length && follow === true); + return follow; + } + function appendItemToChain(chain, target, blocks) { + let follow = false; + if (!chain.includes(target)) { + follow = true; + if (target) { + follow = target[target.length - 1] !== '!'; + const locale = target.replace(/!/g, ''); + chain.push(locale); + if ((isArray(blocks) || isPlainObject(blocks)) && + blocks[locale] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + follow = blocks[locale]; + } + } + } + return follow; + } + + /* eslint-disable @typescript-eslint/no-explicit-any */ + /** + * Intlify core-base version + * @internal + */ + const VERSION$1 = '9.14.5'; + const NOT_REOSLVED = -1; + const DEFAULT_LOCALE = 'en-US'; + const MISSING_RESOLVE_VALUE = ''; + const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`; + function getDefaultLinkedModifiers() { + return { + upper: (val, type) => { + // prettier-ignore + return type === 'text' && isString(val) + ? val.toUpperCase() + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? val.children.toUpperCase() + : val; + }, + lower: (val, type) => { + // prettier-ignore + return type === 'text' && isString(val) + ? val.toLowerCase() + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? val.children.toLowerCase() + : val; + }, + capitalize: (val, type) => { + // prettier-ignore + return (type === 'text' && isString(val) + ? capitalize(val) + : type === 'vnode' && isObject(val) && '__v_isVNode' in val + ? capitalize(val.children) + : val); + } + }; + } + let _compiler; + let _resolver; + /** + * Register the message resolver + * + * @param resolver - A {@link MessageResolver} function + * + * @VueI18nGeneral + */ + function registerMessageResolver(resolver) { + _resolver = resolver; + } + let _fallbacker; + /** + * Register the locale fallbacker + * + * @param fallbacker - A {@link LocaleFallbacker} function + * + * @VueI18nGeneral + */ + function registerLocaleFallbacker(fallbacker) { + _fallbacker = fallbacker; + } + // Additional Meta for Intlify DevTools + let _additionalMeta = null; + /* #__NO_SIDE_EFFECTS__ */ + const setAdditionalMeta = (meta) => { + _additionalMeta = meta; + }; + /* #__NO_SIDE_EFFECTS__ */ + const getAdditionalMeta = () => _additionalMeta; + let _fallbackContext = null; + const setFallbackContext = (context) => { + _fallbackContext = context; + }; + const getFallbackContext = () => _fallbackContext; + // ID for CoreContext + let _cid = 0; + function createCoreContext(options = {}) { + // setup options + const onWarn = isFunction(options.onWarn) ? options.onWarn : warn; + const version = isString(options.version) ? options.version : VERSION$1; + const locale = isString(options.locale) || isFunction(options.locale) + ? options.locale + : DEFAULT_LOCALE; + const _locale = isFunction(locale) ? DEFAULT_LOCALE : locale; + const fallbackLocale = isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + isString(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale; + const messages = isPlainObject(options.messages) + ? options.messages + : createResources(_locale); + const datetimeFormats = isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : createResources(_locale) + ; + const numberFormats = isPlainObject(options.numberFormats) + ? options.numberFormats + : createResources(_locale) + ; + const modifiers = assign(create(), options.modifiers, getDefaultLinkedModifiers()); + const pluralRules = options.pluralRules || create(); + const missing = isFunction(options.missing) ? options.missing : null; + const missingWarn = isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + const fallbackWarn = isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + const fallbackFormat = !!options.fallbackFormat; + const unresolving = !!options.unresolving; + const postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + const processor = isPlainObject(options.processor) ? options.processor : null; + const warnHtmlMessage = isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const escapeParameter = !!options.escapeParameter; + const messageCompiler = isFunction(options.messageCompiler) + ? options.messageCompiler + : _compiler; + const messageResolver = isFunction(options.messageResolver) + ? options.messageResolver + : _resolver || resolveWithKeyValue; + const localeFallbacker = isFunction(options.localeFallbacker) + ? options.localeFallbacker + : _fallbacker || fallbackWithSimple; + const fallbackContext = isObject(options.fallbackContext) + ? options.fallbackContext + : undefined; + // setup internal options + const internalOptions = options; + const __datetimeFormatters = isObject(internalOptions.__datetimeFormatters) + ? internalOptions.__datetimeFormatters + : new Map() + ; + const __numberFormatters = isObject(internalOptions.__numberFormatters) + ? internalOptions.__numberFormatters + : new Map() + ; + const __meta = isObject(internalOptions.__meta) ? internalOptions.__meta : {}; + _cid++; + const context = { + version, + cid: _cid, + locale, + fallbackLocale, + messages, + modifiers, + pluralRules, + missing, + missingWarn, + fallbackWarn, + fallbackFormat, + unresolving, + postTranslation, + processor, + warnHtmlMessage, + escapeParameter, + messageCompiler, + messageResolver, + localeFallbacker, + fallbackContext, + onWarn, + __meta + }; + { + context.datetimeFormats = datetimeFormats; + context.numberFormats = numberFormats; + context.__datetimeFormatters = __datetimeFormatters; + context.__numberFormatters = __numberFormatters; + } + // for vue-devtools timeline event + { + context.__v_emitter = + internalOptions.__v_emitter != null + ? internalOptions.__v_emitter + : undefined; + } + // NOTE: experimental !! + { + initI18nDevTools(context, version, __meta); + } + return context; + } + const createResources = (locale) => ({ [locale]: create() }); + /** @internal */ + function isTranslateFallbackWarn(fallback, key) { + return fallback instanceof RegExp ? fallback.test(key) : fallback; + } + /** @internal */ + function isTranslateMissingWarn(missing, key) { + return missing instanceof RegExp ? missing.test(key) : missing; + } + /** @internal */ + function handleMissing(context, key, locale, missingWarn, type) { + const { missing, onWarn } = context; + // for vue-devtools timeline event + { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("missing" /* VueDevToolsTimelineEvents.MISSING */, { + locale, + key, + type, + groupId: `${type}:${key}` + }); + } + } + if (missing !== null) { + const ret = missing(context, locale, key, type); + return isString(ret) ? ret : key; + } + else { + if (isTranslateMissingWarn(missingWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.NOT_FOUND_KEY, { key, locale })); + } + return key; + } + } + /** @internal */ + function updateFallbackLocale(ctx, locale, fallback) { + const context = ctx; + context.__localeChainCache = new Map(); + ctx.localeFallbacker(ctx, fallback, locale); + } + /** @internal */ + function isAlmostSameLocale(locale, compareLocale) { + if (locale === compareLocale) + return false; + return locale.split('-')[0] === compareLocale.split('-')[0]; + } + /** @internal */ + function isImplicitFallback(targetLocale, locales) { + const index = locales.indexOf(targetLocale); + if (index === -1) { + return false; + } + for (let i = index + 1; i < locales.length; i++) { + if (isAlmostSameLocale(targetLocale, locales[i])) { + return true; + } + } + return false; + } + /* eslint-enable @typescript-eslint/no-explicit-any */ + + const NOOP_MESSAGE_FUNCTION = () => ''; + const isMessageFunction = (val) => isFunction(val); + // implementation of `translate` function + function translate(context, ...args) { + const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context; + const [key, options] = parseTranslateArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const escapeParameter = isBoolean(options.escapeParameter) + ? options.escapeParameter + : context.escapeParameter; + const resolvedMessage = !!options.resolvedMessage; + // prettier-ignore + const defaultMsgOrKey = isString(options.default) || isBoolean(options.default) // default by function option + ? !isBoolean(options.default) + ? options.default + : (!messageCompiler ? () => key : key) + : fallbackFormat // default by `fallbackFormat` option + ? (!messageCompiler ? () => key : key) + : ''; + const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== ''; + const locale = getLocale(context, options); + // escape params + escapeParameter && escapeParams(options); + // resolve message format + // eslint-disable-next-line prefer-const + let [formatScope, targetLocale, message] = !resolvedMessage + ? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) + : [ + key, + locale, + messages[locale] || create() + ]; + // NOTE: + // Fix to work around `ssrTransfrom` bug in Vite. + // https://github.com/vitejs/vite/issues/4306 + // To get around this, use temporary variables. + // https://github.com/nuxt/framework/issues/1461#issuecomment-954606243 + let format = formatScope; + // if you use default message, set it as message format! + let cacheBaseKey = key; + if (!resolvedMessage && + !(isString(format) || + isMessageAST(format) || + isMessageFunction(format))) { + if (enableDefaultMsg) { + format = defaultMsgOrKey; + cacheBaseKey = format; + } + } + // checking message format and target locale + if (!resolvedMessage && + (!(isString(format) || + isMessageAST(format) || + isMessageFunction(format)) || + !isString(targetLocale))) { + return unresolving ? NOT_REOSLVED : key; + } + // TODO: refactor + if (isString(format) && context.messageCompiler == null) { + warn(`The message format compilation is not supported in this build. ` + + `Because message compiler isn't included. ` + + `You need to pre-compilation all message format. ` + + `So translate function return '${key}'.`); + return key; + } + // setup compile error detecting + let occurred = false; + const onError = () => { + occurred = true; + }; + // compile message format + const msg = !isMessageFunction(format) + ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) + : format; + // if occurred compile error, return the message format + if (occurred) { + return format; + } + // evaluate message with context + const ctxOptions = getMessageContextOptions(context, targetLocale, message, options); + const msgContext = createMessageContext(ctxOptions); + const messaged = evaluateMessage(context, msg, msgContext); + // if use post translation option, proceed it with handler + let ret = postTranslation + ? postTranslation(messaged, key) + : messaged; + // apply HTML sanitization for security + if (escapeParameter && isString(ret)) { + ret = sanitizeTranslatedHtml(ret); + } + // NOTE: experimental !! + { + // prettier-ignore + const payloads = { + timestamp: Date.now(), + key: isString(key) + ? key + : isMessageFunction(format) + ? format.key + : '', + locale: targetLocale || (isMessageFunction(format) + ? format.locale + : ''), + format: isString(format) + ? format + : isMessageFunction(format) + ? format.source + : '', + message: ret + }; + payloads.meta = assign({}, context.__meta, getAdditionalMeta() || {}); + translateDevTools(payloads); + } + return ret; + } + function escapeParams(options) { + if (isArray(options.list)) { + options.list = options.list.map(item => isString(item) ? escapeHtml(item) : item); + } + else if (isObject(options.named)) { + Object.keys(options.named).forEach(key => { + if (isString(options.named[key])) { + options.named[key] = escapeHtml(options.named[key]); + } + }); + } + } + function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) { + const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context; + const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any + let message = create(); + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'translate'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + !isAlmostSameLocale(locale, targetLocale) && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.FALLBACK_TO_TRANSLATE, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + message = + messages[targetLocale] || create(); + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-resolve-start'; + endTag = 'intlify-message-resolve-end'; + mark && mark(startTag); + } + if ((format = resolveValue(message, key)) === null) { + // if null, resolve with object key path + format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any + } + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start && format) { + emitter.emit("message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, { + type: "message-resolve" /* VueDevToolsTimelineEvents.MESSAGE_RESOLVE */, + key, + message: format, + time: end - start, + groupId: `${type}:${key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message resolve', startTag, endTag); + } + } + if (isString(format) || isMessageAST(format) || isMessageFunction(format)) { + break; + } + if (!isImplicitFallback(targetLocale, locales)) { + const missingRet = handleMissing(context, // eslint-disable-line @typescript-eslint/no-explicit-any + key, targetLocale, missingWarn, type); + if (missingRet !== key) { + format = missingRet; + } + } + from = to; + } + return [format, targetLocale, message]; + } + function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) { + const { messageCompiler, warnHtmlMessage } = context; + if (isMessageFunction(format)) { + const msg = format; + msg.locale = msg.locale || targetLocale; + msg.key = msg.key || key; + return msg; + } + if (messageCompiler == null) { + const msg = (() => format); + msg.locale = targetLocale; + msg.key = key; + return msg; + } + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-compilation-start'; + endTag = 'intlify-message-compilation-end'; + mark && mark(startTag); + } + const msg = messageCompiler(format, getCompileContext(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, onError)); + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, { + type: "message-compilation" /* VueDevToolsTimelineEvents.MESSAGE_COMPILATION */, + message: format, + time: end - start, + groupId: `${'translate'}:${key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message compilation', startTag, endTag); + } + } + msg.locale = targetLocale; + msg.key = key; + msg.source = format; + return msg; + } + function evaluateMessage(context, msg, msgCtx) { + // for vue-devtools timeline event + let start = null; + let startTag; + let endTag; + if (inBrowser) { + start = window.performance.now(); + startTag = 'intlify-message-evaluation-start'; + endTag = 'intlify-message-evaluation-end'; + mark && mark(startTag); + } + const messaged = msg(msgCtx); + // for vue-devtools timeline event + if (inBrowser) { + const end = window.performance.now(); + const emitter = context.__v_emitter; + if (emitter && start) { + emitter.emit("message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, { + type: "message-evaluation" /* VueDevToolsTimelineEvents.MESSAGE_EVALUATION */, + value: messaged, + time: end - start, + groupId: `${'translate'}:${msg.key}` + }); + } + if (startTag && endTag && mark && measure) { + mark(endTag); + measure('intlify message evaluation', startTag, endTag); + } + } + return messaged; + } + /** @internal */ + function parseTranslateArgs(...args) { + const [arg1, arg2, arg3] = args; + const options = create(); + if (!isString(arg1) && + !isNumber(arg1) && + !isMessageFunction(arg1) && + !isMessageAST(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + // prettier-ignore + const key = isNumber(arg1) + ? String(arg1) + : isMessageFunction(arg1) + ? arg1 + : arg1; + if (isNumber(arg2)) { + options.plural = arg2; + } + else if (isString(arg2)) { + options.default = arg2; + } + else if (isPlainObject(arg2) && !isEmptyObject(arg2)) { + options.named = arg2; + } + else if (isArray(arg2)) { + options.list = arg2; + } + if (isNumber(arg3)) { + options.plural = arg3; + } + else if (isString(arg3)) { + options.default = arg3; + } + else if (isPlainObject(arg3)) { + assign(options, arg3); + } + return [key, options]; + } + function getCompileContext(context, locale, key, source, warnHtmlMessage, onError) { + return { + locale, + key, + warnHtmlMessage, + onError: (err) => { + onError && onError(err); + { + const _source = getSourceForCodeFrame(source); + const message = `Message compilation error: ${err.message}`; + const codeFrame = err.location && + _source && + generateCodeFrame(_source, err.location.start.offset, err.location.end.offset); + const emitter = context.__v_emitter; + if (emitter && _source) { + emitter.emit("compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */, { + message: _source, + error: err.message, + start: err.location && err.location.start.offset, + end: err.location && err.location.end.offset, + groupId: `${'translate'}:${key}` + }); + } + console.error(codeFrame ? `${message}\n${codeFrame}` : message); + } + }, + onCacheKey: (source) => generateFormatCacheKey(locale, key, source) + }; + } + function getSourceForCodeFrame(source) { + if (isString(source)) { + return source; + } + else { + if (source.loc && source.loc.source) { + return source.loc.source; + } + } + } + function getMessageContextOptions(context, locale, message, options) { + const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context; + const resolveMessage = (key) => { + let val = resolveValue(message, key); + // fallback to root context + if (val == null && fallbackContext) { + const [, , message] = resolveMessageFormat(fallbackContext, key, locale, fallbackLocale, fallbackWarn, missingWarn); + val = resolveValue(message, key); + } + if (isString(val) || isMessageAST(val)) { + let occurred = false; + const onError = () => { + occurred = true; + }; + const msg = compileMessageFormat(context, key, locale, val, key, onError); + return !occurred + ? msg + : NOOP_MESSAGE_FUNCTION; + } + else if (isMessageFunction(val)) { + return val; + } + else { + // TODO: should be implemented warning message + return NOOP_MESSAGE_FUNCTION; + } + }; + const ctxOptions = { + locale, + modifiers, + pluralRules, + messages: resolveMessage + }; + if (context.processor) { + ctxOptions.processor = context.processor; + } + if (options.list) { + ctxOptions.list = options.list; + } + if (options.named) { + ctxOptions.named = options.named; + } + if (isNumber(options.plural)) { + ctxOptions.pluralIndex = options.plural; + } + return ctxOptions; + } + + const intlDefined = typeof Intl !== 'undefined'; + const Availabilities = { + dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined', + numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined' + }; + + // implementation of `datetime` function + function datetime(context, ...args) { + const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __datetimeFormatters } = context; + if (!Availabilities.dateTimeFormat) { + onWarn(getWarnMessage$1(CoreWarnCodes.CANNOT_FORMAT_DATE)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseDateTimeArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!isString(key) || key === '') { + return new Intl.DateTimeFormat(locale, overrides).format(value); + } + // resolve format + let datetimeFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'datetime format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + datetimeFormat = + datetimeFormats[targetLocale] || {}; + format = datetimeFormat[key]; + if (isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!isPlainObject(format) || !isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __datetimeFormatters.get(id); + if (!formatter) { + formatter = new Intl.DateTimeFormat(targetLocale, assign({}, format, overrides)); + __datetimeFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); + } + /** @internal */ + const DATETIME_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'weekday', + 'era', + 'year', + 'month', + 'day', + 'hour', + 'minute', + 'second', + 'timeZoneName', + 'formatMatcher', + 'hour12', + 'timeZone', + 'dateStyle', + 'timeStyle', + 'calendar', + 'dayPeriod', + 'numberingSystem', + 'hourCycle', + 'fractionalSecondDigits' + ]; + /** @internal */ + function parseDateTimeArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = create(); + let overrides = create(); + let value; + if (isString(arg1)) { + // Only allow ISO strings - other date formats are often supported, + // but may cause different results in different browsers. + const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/); + if (!matches) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + // Some browsers can not parse the iso datetime separated by space, + // this is a compromise solution by replace the 'T'/' ' with 'T' + const dateTime = matches[3] + ? matches[3].trim().startsWith('T') + ? `${matches[1].trim()}${matches[3].trim()}` + : `${matches[1].trim()}T${matches[3].trim()}` + : matches[1].trim(); + value = new Date(dateTime); + try { + // This will fail if the date is not valid + value.toISOString(); + } + catch (e) { + throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT); + } + } + else if (isDate(arg1)) { + if (isNaN(arg1.getTime())) { + throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT); + } + value = arg1; + } + else if (isNumber(arg1)) { + value = arg1; + } + else { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + if (isString(arg2)) { + options.key = arg2; + } + else if (isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isPlainObject(arg3)) { + overrides = arg3; + } + if (isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; + } + /** @internal */ + function clearDateTimeFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__datetimeFormatters.has(id)) { + continue; + } + context.__datetimeFormatters.delete(id); + } + } + + // implementation of `number` function + function number(context, ...args) { + const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context; + const { __numberFormatters } = context; + if (!Availabilities.numberFormat) { + onWarn(getWarnMessage$1(CoreWarnCodes.CANNOT_FORMAT_NUMBER)); + return MISSING_RESOLVE_VALUE; + } + const [key, value, options, overrides] = parseNumberArgs(...args); + const missingWarn = isBoolean(options.missingWarn) + ? options.missingWarn + : context.missingWarn; + const fallbackWarn = isBoolean(options.fallbackWarn) + ? options.fallbackWarn + : context.fallbackWarn; + const part = !!options.part; + const locale = getLocale(context, options); + const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any + fallbackLocale, locale); + if (!isString(key) || key === '') { + return new Intl.NumberFormat(locale, overrides).format(value); + } + // resolve format + let numberFormat = {}; + let targetLocale; + let format = null; + let from = locale; + let to = null; + const type = 'number format'; + for (let i = 0; i < locales.length; i++) { + targetLocale = to = locales[i]; + if (locale !== targetLocale && + isTranslateFallbackWarn(fallbackWarn, key)) { + onWarn(getWarnMessage$1(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, { + key, + target: targetLocale + })); + } + // for vue-devtools timeline event + if (locale !== targetLocale) { + const emitter = context.__v_emitter; + if (emitter) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type, + key, + from, + to, + groupId: `${type}:${key}` + }); + } + } + numberFormat = + numberFormats[targetLocale] || {}; + format = numberFormat[key]; + if (isPlainObject(format)) + break; + handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any + from = to; + } + // checking format and target locale + if (!isPlainObject(format) || !isString(targetLocale)) { + return unresolving ? NOT_REOSLVED : key; + } + let id = `${targetLocale}__${key}`; + if (!isEmptyObject(overrides)) { + id = `${id}__${JSON.stringify(overrides)}`; + } + let formatter = __numberFormatters.get(id); + if (!formatter) { + formatter = new Intl.NumberFormat(targetLocale, assign({}, format, overrides)); + __numberFormatters.set(id, formatter); + } + return !part ? formatter.format(value) : formatter.formatToParts(value); + } + /** @internal */ + const NUMBER_FORMAT_OPTIONS_KEYS = [ + 'localeMatcher', + 'style', + 'currency', + 'currencyDisplay', + 'currencySign', + 'useGrouping', + 'minimumIntegerDigits', + 'minimumFractionDigits', + 'maximumFractionDigits', + 'minimumSignificantDigits', + 'maximumSignificantDigits', + 'compactDisplay', + 'notation', + 'signDisplay', + 'unit', + 'unitDisplay', + 'roundingMode', + 'roundingPriority', + 'roundingIncrement', + 'trailingZeroDisplay' + ]; + /** @internal */ + function parseNumberArgs(...args) { + const [arg1, arg2, arg3, arg4] = args; + const options = create(); + let overrides = create(); + if (!isNumber(arg1)) { + throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT); + } + const value = arg1; + if (isString(arg2)) { + options.key = arg2; + } + else if (isPlainObject(arg2)) { + Object.keys(arg2).forEach(key => { + if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) { + overrides[key] = arg2[key]; + } + else { + options[key] = arg2[key]; + } + }); + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isPlainObject(arg3)) { + overrides = arg3; + } + if (isPlainObject(arg4)) { + overrides = arg4; + } + return [options.key || '', value, options, overrides]; + } + /** @internal */ + function clearNumberFormat(ctx, locale, format) { + const context = ctx; + for (const key in format) { + const id = `${locale}__${key}`; + if (!context.__numberFormatters.has(id)) { + continue; + } + context.__numberFormatters.delete(id); + } + } + + /** + * Vue I18n Version + * + * @remarks + * Semver format. Same format as the package.json `version` field. + * + * @VueI18nGeneral + */ + const VERSION = '9.14.5'; + /** + * This is only called development env + * istanbul-ignore-next + */ + function initDev() { + { + { + console.info(`You are running a development build of vue-i18n.\n` + + `Make sure to use the production build (*.prod.js) when deploying for production.`); + } + } + } + + const code$1 = CoreWarnCodes.__EXTEND_POINT__; + const inc$1 = incrementer(code$1); + const I18nWarnCodes = { + FALLBACK_TO_ROOT: code$1, // 9 + NOT_SUPPORTED_PRESERVE: inc$1(), // 10 + NOT_SUPPORTED_FORMATTER: inc$1(), // 11 + NOT_SUPPORTED_PRESERVE_DIRECTIVE: inc$1(), // 12 + NOT_SUPPORTED_GET_CHOICE_INDEX: inc$1(), // 13 + COMPONENT_NAME_LEGACY_COMPATIBLE: inc$1(), // 14 + NOT_FOUND_PARENT_SCOPE: inc$1(), // 15 + IGNORE_OBJ_FLATTEN: inc$1(), // 16 + NOTICE_DROP_ALLOW_COMPOSITION: inc$1(), // 17 + NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG: inc$1() // 18 + }; + const warnMessages = { + [I18nWarnCodes.FALLBACK_TO_ROOT]: `Fall back to {type} '{key}' with root locale.`, + [I18nWarnCodes.NOT_SUPPORTED_PRESERVE]: `Not supported 'preserve'.`, + [I18nWarnCodes.NOT_SUPPORTED_FORMATTER]: `Not supported 'formatter'.`, + [I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE]: `Not supported 'preserveDirectiveContent'.`, + [I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX]: `Not supported 'getChoiceIndex'.`, + [I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE]: `Component name legacy compatible: '{name}' -> 'i18n'`, + [I18nWarnCodes.NOT_FOUND_PARENT_SCOPE]: `Not found parent scope. use the global scope.`, + [I18nWarnCodes.IGNORE_OBJ_FLATTEN]: `Ignore object flatten: '{key}' key has an string value`, + [I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION]: `'allowComposition' option will be dropped in the next major version. For more information, please see 👉 https://tinyurl.com/2p97mcze`, + [I18nWarnCodes.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG]: `'translateExistCompatible' option will be dropped in the next major version.` + }; + function getWarnMessage(code, ...args) { + return format(warnMessages[code], ...args); + } + + const code = CoreErrorCodes.__EXTEND_POINT__; + const inc = incrementer(code); + const I18nErrorCodes = { + // composer module errors + UNEXPECTED_RETURN_TYPE: code, // 24 + // legacy module errors + INVALID_ARGUMENT: inc(), // 25 + // i18n module errors + MUST_BE_CALL_SETUP_TOP: inc(), // 26 + NOT_INSTALLED: inc(), // 27 + NOT_AVAILABLE_IN_LEGACY_MODE: inc(), // 28 + // directive module errors + REQUIRED_VALUE: inc(), // 29 + INVALID_VALUE: inc(), // 30 + // vue-devtools errors + CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN: inc(), // 31 + NOT_INSTALLED_WITH_PROVIDE: inc(), // 32 + // unexpected error + UNEXPECTED_ERROR: inc(), // 33 + // not compatible legacy vue-i18n constructor + NOT_COMPATIBLE_LEGACY_VUE_I18N: inc(), // 34 + // bridge support vue 2.x only + BRIDGE_SUPPORT_VUE_2_ONLY: inc(), // 35 + // need to define `i18n` option in `allowComposition: true` and `useScope: 'local' at `useI18n`` + MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION: inc(), // 36 + // Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly + NOT_AVAILABLE_COMPOSITION_IN_LEGACY: inc(), // 37 + // for enhancement + __EXTEND_POINT__: inc() // 38 + }; + function createI18nError(code, ...args) { + return createCompileError(code, null, { messages: errorMessages, args } ); + } + const errorMessages = { + [I18nErrorCodes.UNEXPECTED_RETURN_TYPE]: 'Unexpected return type in composer', + [I18nErrorCodes.INVALID_ARGUMENT]: 'Invalid argument', + [I18nErrorCodes.MUST_BE_CALL_SETUP_TOP]: 'Must be called at the top of a `setup` function', + [I18nErrorCodes.NOT_INSTALLED]: 'Need to install with `app.use` function', + [I18nErrorCodes.UNEXPECTED_ERROR]: 'Unexpected error', + [I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE]: 'Not available in legacy mode', + [I18nErrorCodes.REQUIRED_VALUE]: `Required in value: {0}`, + [I18nErrorCodes.INVALID_VALUE]: `Invalid value`, + [I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN]: `Cannot setup vue-devtools plugin`, + [I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE]: 'Need to install with `provide` function', + [I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N]: 'Not compatible legacy VueI18n.', + [I18nErrorCodes.BRIDGE_SUPPORT_VUE_2_ONLY]: 'vue-i18n-bridge support Vue 2.x only', + [I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION]: 'Must define ‘i18n’ option or custom block in Composition API with using local scope in Legacy API mode', + [I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY]: 'Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly' + }; + + const TranslateVNodeSymbol = + /* #__PURE__*/ makeSymbol('__translateVNode'); + const DatetimePartsSymbol = /* #__PURE__*/ makeSymbol('__datetimeParts'); + const NumberPartsSymbol = /* #__PURE__*/ makeSymbol('__numberParts'); + const EnableEmitter = /* #__PURE__*/ makeSymbol('__enableEmitter'); + const DisableEmitter = /* #__PURE__*/ makeSymbol('__disableEmitter'); + const SetPluralRulesSymbol = makeSymbol('__setPluralRules'); + const InejctWithOptionSymbol = + /* #__PURE__*/ makeSymbol('__injectWithOption'); + const DisposeSymbol = /* #__PURE__*/ makeSymbol('__dispose'); + const __VUE_I18N_BRIDGE__ = '__VUE_I18N_BRIDGE__'; + + /* eslint-disable @typescript-eslint/no-explicit-any */ + /** + * Transform flat json in obj to normal json in obj + */ + function handleFlatJson(obj) { + // check obj + if (!isObject(obj)) { + return obj; + } + if (isMessageAST(obj)) { + return obj; + } + for (const key in obj) { + // check key + if (!hasOwn(obj, key)) { + continue; + } + // handle for normal json + if (!key.includes('.')) { + // recursive process value if value is also a object + if (isObject(obj[key])) { + handleFlatJson(obj[key]); + } + } + // handle for flat json, transform to normal json + else { + // go to the last object + const subKeys = key.split('.'); + const lastIndex = subKeys.length - 1; + let currentObj = obj; + let hasStringValue = false; + for (let i = 0; i < lastIndex; i++) { + if (subKeys[i] === '__proto__') { + throw new Error(`unsafe key: ${subKeys[i]}`); + } + if (!(subKeys[i] in currentObj)) { + currentObj[subKeys[i]] = create(); + } + if (!isObject(currentObj[subKeys[i]])) { + warn(getWarnMessage(I18nWarnCodes.IGNORE_OBJ_FLATTEN, { + key: subKeys[i] + })); + hasStringValue = true; + break; + } + currentObj = currentObj[subKeys[i]]; + } + // update last object value, delete old property + if (!hasStringValue) { + if (!isMessageAST(currentObj)) { + currentObj[subKeys[lastIndex]] = obj[key]; + delete obj[key]; + } + else { + /** + * NOTE: + * if the last object is a message AST and subKeys[lastIndex] has message AST prop key, ignore to copy and key deletion + */ + if (!AST_NODE_PROPS_KEYS.includes(subKeys[lastIndex])) { + delete obj[key]; + } + } + } + // recursive process value if value is also a object + if (!isMessageAST(currentObj)) { + const target = currentObj[subKeys[lastIndex]]; + if (isObject(target)) { + handleFlatJson(target); + } + } + } + } + return obj; + } + function getLocaleMessages(locale, options) { + const { messages, __i18n, messageResolver, flatJson } = options; + // prettier-ignore + const ret = (isPlainObject(messages) + ? messages + : isArray(__i18n) + ? create() + : { [locale]: create() }); + // merge locale messages of i18n custom block + if (isArray(__i18n)) { + __i18n.forEach(custom => { + if ('locale' in custom && 'resource' in custom) { + const { locale, resource } = custom; + if (locale) { + ret[locale] = ret[locale] || create(); + deepCopy(resource, ret[locale]); + } + else { + deepCopy(resource, ret); + } + } + else { + isString(custom) && deepCopy(JSON.parse(custom), ret); + } + }); + } + // handle messages for flat json + if (messageResolver == null && flatJson) { + for (const key in ret) { + if (hasOwn(ret, key)) { + handleFlatJson(ret[key]); + } + } + } + return ret; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function getComponentOptions(instance) { + return instance.type ; + } + function adjustI18nResources(gl, options, componentOptions // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + let messages = isObject(options.messages) + ? options.messages + : create(); + if ('__i18nGlobal' in componentOptions) { + messages = getLocaleMessages(gl.locale.value, { + messages, + __i18n: componentOptions.__i18nGlobal + }); + } + // merge locale messages + const locales = Object.keys(messages); + if (locales.length) { + locales.forEach(locale => { + gl.mergeLocaleMessage(locale, messages[locale]); + }); + } + { + // merge datetime formats + if (isObject(options.datetimeFormats)) { + const locales = Object.keys(options.datetimeFormats); + if (locales.length) { + locales.forEach(locale => { + gl.mergeDateTimeFormat(locale, options.datetimeFormats[locale]); + }); + } + } + // merge number formats + if (isObject(options.numberFormats)) { + const locales = Object.keys(options.numberFormats); + if (locales.length) { + locales.forEach(locale => { + gl.mergeNumberFormat(locale, options.numberFormats[locale]); + }); + } + } + } + } + function createTextNode(key) { + return vue.createVNode(vue.Text, null, key, 0) + ; + } + /* eslint-enable @typescript-eslint/no-explicit-any */ + + /* eslint-disable @typescript-eslint/no-explicit-any */ + // extend VNode interface + const DEVTOOLS_META = '__INTLIFY_META__'; + const NOOP_RETURN_ARRAY = () => []; + const NOOP_RETURN_FALSE = () => false; + let composerID = 0; + function defineCoreMissingHandler(missing) { + return ((ctx, locale, key, type) => { + return missing(locale, key, vue.getCurrentInstance() || undefined, type); + }); + } + // for Intlify DevTools + /* #__NO_SIDE_EFFECTS__ */ + const getMetaInfo = () => { + const instance = vue.getCurrentInstance(); + let meta = null; // eslint-disable-line @typescript-eslint/no-explicit-any + return instance && (meta = getComponentOptions(instance)[DEVTOOLS_META]) + ? { [DEVTOOLS_META]: meta } // eslint-disable-line @typescript-eslint/no-explicit-any + : null; + }; + /** + * Create composer interface factory + * + * @internal + */ + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + function createComposer(options = {}, VueI18nLegacy) { + const { __root, __injectWithOption } = options; + const _isGlobal = __root === undefined; + const flatJson = options.flatJson; + const _ref = inBrowser ? vue.ref : vue.shallowRef; + const translateExistCompatible = !!options.translateExistCompatible; + { + if (translateExistCompatible && !false) { + warnOnce(getWarnMessage(I18nWarnCodes.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG)); + } + } + let _inheritLocale = isBoolean(options.inheritLocale) + ? options.inheritLocale + : true; + const _locale = _ref( + // prettier-ignore + __root && _inheritLocale + ? __root.locale.value + : isString(options.locale) + ? options.locale + : DEFAULT_LOCALE); + const _fallbackLocale = _ref( + // prettier-ignore + __root && _inheritLocale + ? __root.fallbackLocale.value + : isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale.value); + const _messages = _ref(getLocaleMessages(_locale.value, options)); + // prettier-ignore + const _datetimeFormats = _ref(isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : { [_locale.value]: {} }) + ; + // prettier-ignore + const _numberFormats = _ref(isPlainObject(options.numberFormats) + ? options.numberFormats + : { [_locale.value]: {} }) + ; + // warning suppress options + // prettier-ignore + let _missingWarn = __root + ? __root.missingWarn + : isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + // prettier-ignore + let _fallbackWarn = __root + ? __root.fallbackWarn + : isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + // prettier-ignore + let _fallbackRoot = __root + ? __root.fallbackRoot + : isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + // configure fall back to root + let _fallbackFormat = !!options.fallbackFormat; + // runtime missing + let _missing = isFunction(options.missing) ? options.missing : null; + let _runtimeMissing = isFunction(options.missing) + ? defineCoreMissingHandler(options.missing) + : null; + // postTranslation handler + let _postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + // prettier-ignore + let _warnHtmlMessage = __root + ? __root.warnHtmlMessage + : isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + let _escapeParameter = !!options.escapeParameter; + // custom linked modifiers + // prettier-ignore + const _modifiers = __root + ? __root.modifiers + : isPlainObject(options.modifiers) + ? options.modifiers + : {}; + // pluralRules + let _pluralRules = options.pluralRules || (__root && __root.pluralRules); + // runtime context + // eslint-disable-next-line prefer-const + let _context; + const getCoreContext = () => { + _isGlobal && setFallbackContext(null); + const ctxOptions = { + version: VERSION, + locale: _locale.value, + fallbackLocale: _fallbackLocale.value, + messages: _messages.value, + modifiers: _modifiers, + pluralRules: _pluralRules, + missing: _runtimeMissing === null ? undefined : _runtimeMissing, + missingWarn: _missingWarn, + fallbackWarn: _fallbackWarn, + fallbackFormat: _fallbackFormat, + unresolving: true, + postTranslation: _postTranslation === null ? undefined : _postTranslation, + warnHtmlMessage: _warnHtmlMessage, + escapeParameter: _escapeParameter, + messageResolver: options.messageResolver, + messageCompiler: options.messageCompiler, + __meta: { framework: 'vue' } + }; + { + ctxOptions.datetimeFormats = _datetimeFormats.value; + ctxOptions.numberFormats = _numberFormats.value; + ctxOptions.__datetimeFormatters = isPlainObject(_context) + ? _context.__datetimeFormatters + : undefined; + ctxOptions.__numberFormatters = isPlainObject(_context) + ? _context.__numberFormatters + : undefined; + } + { + ctxOptions.__v_emitter = isPlainObject(_context) + ? _context.__v_emitter + : undefined; + } + const ctx = createCoreContext(ctxOptions); + _isGlobal && setFallbackContext(ctx); + return ctx; + }; + _context = getCoreContext(); + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + // track reactivity + function trackReactivityValues() { + return [ + _locale.value, + _fallbackLocale.value, + _messages.value, + _datetimeFormats.value, + _numberFormats.value + ] + ; + } + // locale + const locale = vue.computed({ + get: () => _locale.value, + set: val => { + _locale.value = val; + _context.locale = _locale.value; + } + }); + // fallbackLocale + const fallbackLocale = vue.computed({ + get: () => _fallbackLocale.value, + set: val => { + _fallbackLocale.value = val; + _context.fallbackLocale = _fallbackLocale.value; + updateFallbackLocale(_context, _locale.value, val); + } + }); + // messages + const messages = vue.computed(() => _messages.value); + // datetimeFormats + const datetimeFormats = /* #__PURE__*/ vue.computed(() => _datetimeFormats.value); + // numberFormats + const numberFormats = /* #__PURE__*/ vue.computed(() => _numberFormats.value); + // getPostTranslationHandler + function getPostTranslationHandler() { + return isFunction(_postTranslation) ? _postTranslation : null; + } + // setPostTranslationHandler + function setPostTranslationHandler(handler) { + _postTranslation = handler; + _context.postTranslation = handler; + } + // getMissingHandler + function getMissingHandler() { + return _missing; + } + // setMissingHandler + function setMissingHandler(handler) { + if (handler !== null) { + _runtimeMissing = defineCoreMissingHandler(handler); + } + _missing = handler; + _context.missing = _runtimeMissing; + } + function isResolvedTranslateMessage(type, arg // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + return type !== 'translate' || !arg.resolvedMessage; + } + const wrapWithDeps = (fn, argumentParser, warnType, fallbackSuccess, fallbackFail, successCondition) => { + trackReactivityValues(); // track reactive dependency + // NOTE: experimental !! + let ret; + try { + if (true || false) { + setAdditionalMeta(getMetaInfo()); + } + if (!_isGlobal) { + _context.fallbackContext = __root + ? getFallbackContext() + : undefined; + } + ret = fn(_context); + } + finally { + if (!_isGlobal) { + _context.fallbackContext = undefined; + } + } + if ((warnType !== 'translate exists' && // for not `te` (e.g `t`) + isNumber(ret) && + ret === NOT_REOSLVED) || + (warnType === 'translate exists' && !ret) // for `te` + ) { + const [key, arg2] = argumentParser(); + if (__root && + isString(key) && + isResolvedTranslateMessage(warnType, arg2)) { + if (_fallbackRoot && + (isTranslateFallbackWarn(_fallbackWarn, key) || + isTranslateMissingWarn(_missingWarn, key))) { + warn(getWarnMessage(I18nWarnCodes.FALLBACK_TO_ROOT, { + key, + type: warnType + })); + } + // for vue-devtools timeline event + { + const { __v_emitter: emitter } = _context; + if (emitter && _fallbackRoot) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type: warnType, + key, + to: 'global', + groupId: `${warnType}:${key}` + }); + } + } + } + return __root && _fallbackRoot + ? fallbackSuccess(__root) + : fallbackFail(key); + } + else if (successCondition(ret)) { + return ret; + } + else { + /* istanbul ignore next */ + throw createI18nError(I18nErrorCodes.UNEXPECTED_RETURN_TYPE); + } + }; + // t + function t(...args) { + return wrapWithDeps(context => Reflect.apply(translate, null, [context, ...args]), () => parseTranslateArgs(...args), 'translate', root => Reflect.apply(root.t, root, [...args]), key => key, val => isString(val)); + } + // rt + function rt(...args) { + const [arg1, arg2, arg3] = args; + if (arg3 && !isObject(arg3)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + return t(...[arg1, arg2, assign({ resolvedMessage: true }, arg3 || {})]); + } + // d + function d(...args) { + return wrapWithDeps(context => Reflect.apply(datetime, null, [context, ...args]), () => parseDateTimeArgs(...args), 'datetime format', root => Reflect.apply(root.d, root, [...args]), () => MISSING_RESOLVE_VALUE, val => isString(val)); + } + // n + function n(...args) { + return wrapWithDeps(context => Reflect.apply(number, null, [context, ...args]), () => parseNumberArgs(...args), 'number format', root => Reflect.apply(root.n, root, [...args]), () => MISSING_RESOLVE_VALUE, val => isString(val)); + } + // for custom processor + function normalize(values) { + return values.map(val => isString(val) || isNumber(val) || isBoolean(val) + ? createTextNode(String(val)) + : val); + } + const interpolate = (val) => val; + const processor = { + normalize, + interpolate, + type: 'vnode' + }; + // translateVNode, using for `i18n-t` component + function translateVNode(...args) { + return wrapWithDeps(context => { + let ret; + const _context = context; + try { + _context.processor = processor; + ret = Reflect.apply(translate, null, [_context, ...args]); + } + finally { + _context.processor = null; + } + return ret; + }, () => parseTranslateArgs(...args), 'translate', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[TranslateVNodeSymbol](...args), key => [createTextNode(key)], val => isArray(val)); + } + // numberParts, using for `i18n-n` component + function numberParts(...args) { + return wrapWithDeps(context => Reflect.apply(number, null, [context, ...args]), () => parseNumberArgs(...args), 'number format', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[NumberPartsSymbol](...args), NOOP_RETURN_ARRAY, val => isString(val) || isArray(val)); + } + // datetimeParts, using for `i18n-d` component + function datetimeParts(...args) { + return wrapWithDeps(context => Reflect.apply(datetime, null, [context, ...args]), () => parseDateTimeArgs(...args), 'datetime format', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[DatetimePartsSymbol](...args), NOOP_RETURN_ARRAY, val => isString(val) || isArray(val)); + } + function setPluralRules(rules) { + _pluralRules = rules; + _context.pluralRules = _pluralRules; + } + // te + function te(key, locale) { + return wrapWithDeps(() => { + if (!key) { + return false; + } + const targetLocale = isString(locale) ? locale : _locale.value; + const message = getLocaleMessage(targetLocale); + const resolved = _context.messageResolver(message, key); + return !translateExistCompatible + ? isMessageAST(resolved) || + isMessageFunction(resolved) || + isString(resolved) + : resolved != null; + }, () => [key], 'translate exists', root => { + return Reflect.apply(root.te, root, [key, locale]); + }, NOOP_RETURN_FALSE, val => isBoolean(val)); + } + function resolveMessages(key) { + let messages = null; + const locales = fallbackWithLocaleChain(_context, _fallbackLocale.value, _locale.value); + for (let i = 0; i < locales.length; i++) { + const targetLocaleMessages = _messages.value[locales[i]] || {}; + const messageValue = _context.messageResolver(targetLocaleMessages, key); + if (messageValue != null) { + messages = messageValue; + break; + } + } + return messages; + } + // tm + function tm(key) { + const messages = resolveMessages(key); + // prettier-ignore + return messages != null + ? messages + : __root + ? __root.tm(key) || {} + : {}; + } + // getLocaleMessage + function getLocaleMessage(locale) { + return (_messages.value[locale] || {}); + } + // setLocaleMessage + function setLocaleMessage(locale, message) { + if (flatJson) { + const _message = { [locale]: message }; + for (const key in _message) { + if (hasOwn(_message, key)) { + handleFlatJson(_message[key]); + } + } + message = _message[locale]; + } + _messages.value[locale] = message; + _context.messages = _messages.value; + } + // mergeLocaleMessage + function mergeLocaleMessage(locale, message) { + _messages.value[locale] = _messages.value[locale] || {}; + const _message = { [locale]: message }; + if (flatJson) { + for (const key in _message) { + if (hasOwn(_message, key)) { + handleFlatJson(_message[key]); + } + } + } + message = _message[locale]; + deepCopy(message, _messages.value[locale]); + _context.messages = _messages.value; + } + // getDateTimeFormat + function getDateTimeFormat(locale) { + return _datetimeFormats.value[locale] || {}; + } + // setDateTimeFormat + function setDateTimeFormat(locale, format) { + _datetimeFormats.value[locale] = format; + _context.datetimeFormats = _datetimeFormats.value; + clearDateTimeFormat(_context, locale, format); + } + // mergeDateTimeFormat + function mergeDateTimeFormat(locale, format) { + _datetimeFormats.value[locale] = assign(_datetimeFormats.value[locale] || {}, format); + _context.datetimeFormats = _datetimeFormats.value; + clearDateTimeFormat(_context, locale, format); + } + // getNumberFormat + function getNumberFormat(locale) { + return _numberFormats.value[locale] || {}; + } + // setNumberFormat + function setNumberFormat(locale, format) { + _numberFormats.value[locale] = format; + _context.numberFormats = _numberFormats.value; + clearNumberFormat(_context, locale, format); + } + // mergeNumberFormat + function mergeNumberFormat(locale, format) { + _numberFormats.value[locale] = assign(_numberFormats.value[locale] || {}, format); + _context.numberFormats = _numberFormats.value; + clearNumberFormat(_context, locale, format); + } + // for debug + composerID++; + // watch root locale & fallbackLocale + if (__root && inBrowser) { + vue.watch(__root.locale, (val) => { + if (_inheritLocale) { + _locale.value = val; + _context.locale = val; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }); + vue.watch(__root.fallbackLocale, (val) => { + if (_inheritLocale) { + _fallbackLocale.value = val; + _context.fallbackLocale = val; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }); + } + // define basic composition API! + const composer = { + id: composerID, + locale, + fallbackLocale, + get inheritLocale() { + return _inheritLocale; + }, + set inheritLocale(val) { + _inheritLocale = val; + if (val && __root) { + _locale.value = __root.locale.value; + _fallbackLocale.value = __root.fallbackLocale.value; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }, + get availableLocales() { + return Object.keys(_messages.value).sort(); + }, + messages, + get modifiers() { + return _modifiers; + }, + get pluralRules() { + return _pluralRules || {}; + }, + get isGlobal() { + return _isGlobal; + }, + get missingWarn() { + return _missingWarn; + }, + set missingWarn(val) { + _missingWarn = val; + _context.missingWarn = _missingWarn; + }, + get fallbackWarn() { + return _fallbackWarn; + }, + set fallbackWarn(val) { + _fallbackWarn = val; + _context.fallbackWarn = _fallbackWarn; + }, + get fallbackRoot() { + return _fallbackRoot; + }, + set fallbackRoot(val) { + _fallbackRoot = val; + }, + get fallbackFormat() { + return _fallbackFormat; + }, + set fallbackFormat(val) { + _fallbackFormat = val; + _context.fallbackFormat = _fallbackFormat; + }, + get warnHtmlMessage() { + return _warnHtmlMessage; + }, + set warnHtmlMessage(val) { + _warnHtmlMessage = val; + _context.warnHtmlMessage = val; + }, + get escapeParameter() { + return _escapeParameter; + }, + set escapeParameter(val) { + _escapeParameter = val; + _context.escapeParameter = val; + }, + t, + getLocaleMessage, + setLocaleMessage, + mergeLocaleMessage, + getPostTranslationHandler, + setPostTranslationHandler, + getMissingHandler, + setMissingHandler, + [SetPluralRulesSymbol]: setPluralRules + }; + { + composer.datetimeFormats = datetimeFormats; + composer.numberFormats = numberFormats; + composer.rt = rt; + composer.te = te; + composer.tm = tm; + composer.d = d; + composer.n = n; + composer.getDateTimeFormat = getDateTimeFormat; + composer.setDateTimeFormat = setDateTimeFormat; + composer.mergeDateTimeFormat = mergeDateTimeFormat; + composer.getNumberFormat = getNumberFormat; + composer.setNumberFormat = setNumberFormat; + composer.mergeNumberFormat = mergeNumberFormat; + composer[InejctWithOptionSymbol] = __injectWithOption; + composer[TranslateVNodeSymbol] = translateVNode; + composer[DatetimePartsSymbol] = datetimeParts; + composer[NumberPartsSymbol] = numberParts; + } + // for vue-devtools timeline event + { + composer[EnableEmitter] = (emitter) => { + _context.__v_emitter = emitter; + }; + composer[DisableEmitter] = () => { + _context.__v_emitter = undefined; + }; + } + return composer; + } + /* eslint-enable @typescript-eslint/no-explicit-any */ + + /* eslint-disable @typescript-eslint/no-explicit-any */ + /** + * Convert to I18n Composer Options from VueI18n Options + * + * @internal + */ + function convertComposerOptions(options) { + const locale = isString(options.locale) ? options.locale : DEFAULT_LOCALE; + const fallbackLocale = isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : locale; + const missing = isFunction(options.missing) ? options.missing : undefined; + const missingWarn = isBoolean(options.silentTranslationWarn) || + isRegExp(options.silentTranslationWarn) + ? !options.silentTranslationWarn + : true; + const fallbackWarn = isBoolean(options.silentFallbackWarn) || + isRegExp(options.silentFallbackWarn) + ? !options.silentFallbackWarn + : true; + const fallbackRoot = isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + const fallbackFormat = !!options.formatFallbackMessages; + const modifiers = isPlainObject(options.modifiers) ? options.modifiers : {}; + const pluralizationRules = options.pluralizationRules; + const postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : undefined; + const warnHtmlMessage = isString(options.warnHtmlInMessage) + ? options.warnHtmlInMessage !== 'off' + : true; + const escapeParameter = !!options.escapeParameterHtml; + const inheritLocale = isBoolean(options.sync) ? options.sync : true; + if (options.formatter) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + } + if (options.preserveDirectiveContent) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + } + let messages = options.messages; + if (isPlainObject(options.sharedMessages)) { + const sharedMessages = options.sharedMessages; + const locales = Object.keys(sharedMessages); + messages = locales.reduce((messages, locale) => { + const message = messages[locale] || (messages[locale] = {}); + assign(message, sharedMessages[locale]); + return messages; + }, (messages || {})); + } + const { __i18n, __root, __injectWithOption } = options; + const datetimeFormats = options.datetimeFormats; + const numberFormats = options.numberFormats; + const flatJson = options.flatJson; + const translateExistCompatible = options + .translateExistCompatible; + return { + locale, + fallbackLocale, + messages, + flatJson, + datetimeFormats, + numberFormats, + missing, + missingWarn, + fallbackWarn, + fallbackRoot, + fallbackFormat, + modifiers, + pluralRules: pluralizationRules, + postTranslation, + warnHtmlMessage, + escapeParameter, + messageResolver: options.messageResolver, + inheritLocale, + translateExistCompatible, + __i18n, + __root, + __injectWithOption + }; + } + /** + * create VueI18n interface factory + * + * @internal + */ + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + function createVueI18n(options = {}, VueI18nLegacy) { + { + const composer = createComposer(convertComposerOptions(options)); + const { __extender } = options; + // defines VueI18n + const vueI18n = { + // id + id: composer.id, + // locale + get locale() { + return composer.locale.value; + }, + set locale(val) { + composer.locale.value = val; + }, + // fallbackLocale + get fallbackLocale() { + return composer.fallbackLocale.value; + }, + set fallbackLocale(val) { + composer.fallbackLocale.value = val; + }, + // messages + get messages() { + return composer.messages.value; + }, + // datetimeFormats + get datetimeFormats() { + return composer.datetimeFormats.value; + }, + // numberFormats + get numberFormats() { + return composer.numberFormats.value; + }, + // availableLocales + get availableLocales() { + return composer.availableLocales; + }, + // formatter + get formatter() { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + // dummy + return { + interpolate() { + return []; + } + }; + }, + set formatter(val) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + }, + // missing + get missing() { + return composer.getMissingHandler(); + }, + set missing(handler) { + composer.setMissingHandler(handler); + }, + // silentTranslationWarn + get silentTranslationWarn() { + return isBoolean(composer.missingWarn) + ? !composer.missingWarn + : composer.missingWarn; + }, + set silentTranslationWarn(val) { + composer.missingWarn = isBoolean(val) ? !val : val; + }, + // silentFallbackWarn + get silentFallbackWarn() { + return isBoolean(composer.fallbackWarn) + ? !composer.fallbackWarn + : composer.fallbackWarn; + }, + set silentFallbackWarn(val) { + composer.fallbackWarn = isBoolean(val) ? !val : val; + }, + // modifiers + get modifiers() { + return composer.modifiers; + }, + // formatFallbackMessages + get formatFallbackMessages() { + return composer.fallbackFormat; + }, + set formatFallbackMessages(val) { + composer.fallbackFormat = val; + }, + // postTranslation + get postTranslation() { + return composer.getPostTranslationHandler(); + }, + set postTranslation(handler) { + composer.setPostTranslationHandler(handler); + }, + // sync + get sync() { + return composer.inheritLocale; + }, + set sync(val) { + composer.inheritLocale = val; + }, + // warnInHtmlMessage + get warnHtmlInMessage() { + return composer.warnHtmlMessage ? 'warn' : 'off'; + }, + set warnHtmlInMessage(val) { + composer.warnHtmlMessage = val !== 'off'; + }, + // escapeParameterHtml + get escapeParameterHtml() { + return composer.escapeParameter; + }, + set escapeParameterHtml(val) { + composer.escapeParameter = val; + }, + // preserveDirectiveContent + get preserveDirectiveContent() { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + return true; + }, + set preserveDirectiveContent(val) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + }, + // pluralizationRules + get pluralizationRules() { + return composer.pluralRules || {}; + }, + // for internal + __composer: composer, + // t + t(...args) { + const [arg1, arg2, arg3] = args; + const options = {}; + let list = null; + let named = null; + if (!isString(arg1)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + const key = arg1; + if (isString(arg2)) { + options.locale = arg2; + } + else if (isArray(arg2)) { + list = arg2; + } + else if (isPlainObject(arg2)) { + named = arg2; + } + if (isArray(arg3)) { + list = arg3; + } + else if (isPlainObject(arg3)) { + named = arg3; + } + // return composer.t(key, (list || named || {}) as any, options) + return Reflect.apply(composer.t, composer, [ + key, + (list || named || {}), + options + ]); + }, + rt(...args) { + return Reflect.apply(composer.rt, composer, [...args]); + }, + // tc + tc(...args) { + const [arg1, arg2, arg3] = args; + const options = { plural: 1 }; + let list = null; + let named = null; + if (!isString(arg1)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + const key = arg1; + if (isString(arg2)) { + options.locale = arg2; + } + else if (isNumber(arg2)) { + options.plural = arg2; + } + else if (isArray(arg2)) { + list = arg2; + } + else if (isPlainObject(arg2)) { + named = arg2; + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isArray(arg3)) { + list = arg3; + } + else if (isPlainObject(arg3)) { + named = arg3; + } + // return composer.t(key, (list || named || {}) as any, options) + return Reflect.apply(composer.t, composer, [ + key, + (list || named || {}), + options + ]); + }, + // te + te(key, locale) { + return composer.te(key, locale); + }, + // tm + tm(key) { + return composer.tm(key); + }, + // getLocaleMessage + getLocaleMessage(locale) { + return composer.getLocaleMessage(locale); + }, + // setLocaleMessage + setLocaleMessage(locale, message) { + composer.setLocaleMessage(locale, message); + }, + // mergeLocaleMessage + mergeLocaleMessage(locale, message) { + composer.mergeLocaleMessage(locale, message); + }, + // d + d(...args) { + return Reflect.apply(composer.d, composer, [...args]); + }, + // getDateTimeFormat + getDateTimeFormat(locale) { + return composer.getDateTimeFormat(locale); + }, + // setDateTimeFormat + setDateTimeFormat(locale, format) { + composer.setDateTimeFormat(locale, format); + }, + // mergeDateTimeFormat + mergeDateTimeFormat(locale, format) { + composer.mergeDateTimeFormat(locale, format); + }, + // n + n(...args) { + return Reflect.apply(composer.n, composer, [...args]); + }, + // getNumberFormat + getNumberFormat(locale) { + return composer.getNumberFormat(locale); + }, + // setNumberFormat + setNumberFormat(locale, format) { + composer.setNumberFormat(locale, format); + }, + // mergeNumberFormat + mergeNumberFormat(locale, format) { + composer.mergeNumberFormat(locale, format); + }, + // getChoiceIndex + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getChoiceIndex(choice, choicesLength) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX)); + return -1; + } + }; + vueI18n.__extender = __extender; + // for vue-devtools timeline event + { + vueI18n.__enableEmitter = (emitter) => { + const __composer = composer; + __composer[EnableEmitter] && __composer[EnableEmitter](emitter); + }; + vueI18n.__disableEmitter = () => { + const __composer = composer; + __composer[DisableEmitter] && __composer[DisableEmitter](); + }; + } + return vueI18n; + } + } + /* eslint-enable @typescript-eslint/no-explicit-any */ + + const baseFormatProps = { + tag: { + type: [String, Object] + }, + locale: { + type: String + }, + scope: { + type: String, + // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050 + validator: (val /* ComponentI18nScope */) => val === 'parent' || val === 'global', + default: 'parent' /* ComponentI18nScope */ + }, + i18n: { + type: Object + } + }; + + function getInterpolateArg( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + { slots }, // SetupContext, + keys) { + if (keys.length === 1 && keys[0] === 'default') { + // default slot with list + const ret = slots.default ? slots.default() : []; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return ret.reduce((slot, current) => { + return [ + ...slot, + // prettier-ignore + ...(current.type === vue.Fragment ? current.children : [current] + ) + ]; + }, []); + } + else { + // named slots + return keys.reduce((arg, key) => { + const slot = slots[key]; + if (slot) { + arg[key] = slot(); + } + return arg; + }, create()); + } + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function getFragmentableTag(tag) { + return vue.Fragment ; + } + + const TranslationImpl = /*#__PURE__*/ vue.defineComponent({ + /* eslint-disable */ + name: 'i18n-t', + props: assign({ + keypath: { + type: String, + required: true + }, + plural: { + type: [Number, String], + // eslint-disable-next-line @typescript-eslint/no-explicit-any + validator: (val) => isNumber(val) || !isNaN(val) + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const { slots, attrs } = context; + // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050 + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return () => { + const keys = Object.keys(slots).filter(key => key !== '_'); + const options = create(); + if (props.locale) { + options.locale = props.locale; + } + if (props.plural !== undefined) { + options.plural = isString(props.plural) ? +props.plural : props.plural; + } + const arg = getInterpolateArg(context, keys); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const children = i18n[TranslateVNodeSymbol](props.keypath, arg, options); + const assignedAttrs = assign(create(), attrs); + const tag = isString(props.tag) || isObject(props.tag) + ? props.tag + : getFragmentableTag(); + return vue.h(tag, assignedAttrs, children); + }; + } + }); + /** + * export the public type for h/tsx inference + * also to avoid inline import() in generated d.ts files + */ + /** + * Translation Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [TranslationProps](component#translationprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Component Interpolation](../guide/advanced/component) + * + * @example + * ```html + *
+ * + * + * {{ $t('tos') }} + * + * + *
+ * ``` + * ```js + * import { createApp } from 'vue' + * import { createI18n } from 'vue-i18n' + * + * const messages = { + * en: { + * tos: 'Term of Service', + * term: 'I accept xxx {0}.' + * }, + * ja: { + * tos: '利用規約', + * term: '私は xxx の{0}に同意します。' + * } + * } + * + * const i18n = createI18n({ + * locale: 'en', + * messages + * }) + * + * const app = createApp({ + * data: { + * url: '/term' + * } + * }).use(i18n).mount('#app') + * ``` + * + * @VueI18nComponent + */ + const Translation = TranslationImpl; + const I18nT = Translation; + + function isVNode(target) { + return isArray(target) && !isString(target[0]); + } + function renderFormatter(props, context, slotKeys, partFormatter) { + const { slots, attrs } = context; + return () => { + const options = { part: true }; + let overrides = create(); + if (props.locale) { + options.locale = props.locale; + } + if (isString(props.format)) { + options.key = props.format; + } + else if (isObject(props.format)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (isString(props.format.key)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + options.key = props.format.key; + } + // Filter out number format options only + overrides = Object.keys(props.format).reduce((options, prop) => { + return slotKeys.includes(prop) + ? assign(create(), options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any + : options; + }, create()); + } + const parts = partFormatter(...[props.value, options, overrides]); + let children = [options.key]; + if (isArray(parts)) { + children = parts.map((part, index) => { + const slot = slots[part.type]; + const node = slot + ? slot({ [part.type]: part.value, index, parts }) + : [part.value]; + if (isVNode(node)) { + node[0].key = `${part.type}-${index}`; + } + return node; + }); + } + else if (isString(parts)) { + children = [parts]; + } + const assignedAttrs = assign(create(), attrs); + const tag = isString(props.tag) || isObject(props.tag) + ? props.tag + : getFragmentableTag(); + return vue.h(tag, assignedAttrs, children); + }; + } + + const NumberFormatImpl = /*#__PURE__*/ vue.defineComponent({ + /* eslint-disable */ + name: 'i18n-n', + props: assign({ + value: { + type: Number, + required: true + }, + format: { + type: [String, Object] + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return renderFormatter(props, context, NUMBER_FORMAT_OPTIONS_KEYS, (...args) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + i18n[NumberPartsSymbol](...args)); + } + }); + /** + * export the public type for h/tsx inference + * also to avoid inline import() in generated d.ts files + */ + /** + * Number Format Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [FormattableProps](component#formattableprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Custom Formatting](../guide/essentials/number#custom-formatting) + * + * @VueI18nDanger + * Not supported IE, due to no support `Intl.NumberFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts) + * + * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-numberformat) + * + * @VueI18nComponent + */ + const NumberFormat = NumberFormatImpl; + const I18nN = NumberFormat; + + const DatetimeFormatImpl = /* #__PURE__*/ vue.defineComponent({ + /* eslint-disable */ + name: 'i18n-d', + props: assign({ + value: { + type: [Number, Date], + required: true + }, + format: { + type: [String, Object] + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return renderFormatter(props, context, DATETIME_FORMAT_OPTIONS_KEYS, (...args) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + i18n[DatetimePartsSymbol](...args)); + } + }); + /** + * Datetime Format Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [FormattableProps](component#formattableprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Custom Formatting](../guide/essentials/datetime#custom-formatting) + * + * @VueI18nDanger + * Not supported IE, due to no support `Intl.DateTimeFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts) + * + * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-datetimeformat) + * + * @VueI18nComponent + */ + const DatetimeFormat = DatetimeFormatImpl; + const I18nD = DatetimeFormat; + + function getComposer$2(i18n, instance) { + const i18nInternal = i18n; + if (i18n.mode === 'composition') { + return (i18nInternal.__getInstance(instance) || i18n.global); + } + else { + const vueI18n = i18nInternal.__getInstance(instance); + return vueI18n != null + ? vueI18n.__composer + : i18n.global.__composer; + } + } + function vTDirective(i18n) { + const _process = (binding) => { + const { instance, modifiers, value } = binding; + /* istanbul ignore if */ + if (!instance || !instance.$) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const composer = getComposer$2(i18n, instance.$); + if (modifiers.preserve) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE)); + } + const parsedValue = parseValue(value); + return [ + Reflect.apply(composer.t, composer, [...makeParams(parsedValue)]), + composer + ]; + }; + const register = (el, binding) => { + const [textContent, composer] = _process(binding); + if (inBrowser && i18n.global === composer) { + // global scope only + el.__i18nWatcher = vue.watch(composer.locale, () => { + binding.instance && binding.instance.$forceUpdate(); + }); + } + el.__composer = composer; + el.textContent = textContent; + }; + const unregister = (el) => { + if (inBrowser && el.__i18nWatcher) { + el.__i18nWatcher(); + el.__i18nWatcher = undefined; + delete el.__i18nWatcher; + } + if (el.__composer) { + el.__composer = undefined; + delete el.__composer; + } + }; + const update = (el, { value }) => { + if (el.__composer) { + const composer = el.__composer; + const parsedValue = parseValue(value); + el.textContent = Reflect.apply(composer.t, composer, [ + ...makeParams(parsedValue) + ]); + } + }; + const getSSRProps = (binding) => { + const [textContent] = _process(binding); + return { textContent }; + }; + return { + created: register, + unmounted: unregister, + beforeUpdate: update, + getSSRProps + }; + } + function parseValue(value) { + if (isString(value)) { + return { path: value }; + } + else if (isPlainObject(value)) { + if (!('path' in value)) { + throw createI18nError(I18nErrorCodes.REQUIRED_VALUE, 'path'); + } + return value; + } + else { + throw createI18nError(I18nErrorCodes.INVALID_VALUE); + } + } + function makeParams(value) { + const { path, locale, args, choice, plural } = value; + const options = {}; + const named = args || {}; + if (isString(locale)) { + options.locale = locale; + } + if (isNumber(choice)) { + options.plural = choice; + } + if (isNumber(plural)) { + options.plural = plural; + } + return [path, named, options]; + } + + function apply(app, i18n, ...options) { + const pluginOptions = isPlainObject(options[0]) + ? options[0] + : {}; + const useI18nComponentName = !!pluginOptions.useI18nComponentName; + const globalInstall = isBoolean(pluginOptions.globalInstall) + ? pluginOptions.globalInstall + : true; + if (globalInstall && useI18nComponentName) { + warn(getWarnMessage(I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE, { + name: Translation.name + })); + } + if (globalInstall) { + [!useI18nComponentName ? Translation.name : 'i18n', 'I18nT'].forEach(name => app.component(name, Translation)); + [NumberFormat.name, 'I18nN'].forEach(name => app.component(name, NumberFormat)); + [DatetimeFormat.name, 'I18nD'].forEach(name => app.component(name, DatetimeFormat)); + } + // install directive + { + app.directive('t', vTDirective(i18n)); + } + } + + var global$1 = (typeof global !== "undefined" ? global : + typeof self !== "undefined" ? self : + typeof window !== "undefined" ? window : {}); + + function getDevtoolsGlobalHook() { + return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__; + } + function getTarget() { + // @ts-ignore + return (typeof navigator !== 'undefined' && typeof window !== 'undefined') + ? window + : typeof global$1 !== 'undefined' + ? global$1 + : {}; + } + const isProxyAvailable = typeof Proxy === 'function'; + + const HOOK_SETUP = 'devtools-plugin:setup'; + const HOOK_PLUGIN_SETTINGS_SET = 'plugin:settings:set'; + + let supported; + let perf; + function isPerformanceSupported() { + var _a; + if (supported !== undefined) { + return supported; + } + if (typeof window !== 'undefined' && window.performance) { + supported = true; + perf = window.performance; + } + else if (typeof global$1 !== 'undefined' && ((_a = global$1.perf_hooks) === null || _a === void 0 ? void 0 : _a.performance)) { + supported = true; + perf = global$1.perf_hooks.performance; + } + else { + supported = false; + } + return supported; + } + function now() { + return isPerformanceSupported() ? perf.now() : Date.now(); + } + + class ApiProxy { + constructor(plugin, hook) { + this.target = null; + this.targetQueue = []; + this.onQueue = []; + this.plugin = plugin; + this.hook = hook; + const defaultSettings = {}; + if (plugin.settings) { + for (const id in plugin.settings) { + const item = plugin.settings[id]; + defaultSettings[id] = item.defaultValue; + } + } + const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin.id}`; + let currentSettings = Object.assign({}, defaultSettings); + try { + const raw = localStorage.getItem(localSettingsSaveId); + const data = JSON.parse(raw); + Object.assign(currentSettings, data); + } + catch (e) { + // noop + } + this.fallbacks = { + getSettings() { + return currentSettings; + }, + setSettings(value) { + try { + localStorage.setItem(localSettingsSaveId, JSON.stringify(value)); + } + catch (e) { + // noop + } + currentSettings = value; + }, + now() { + return now(); + }, + }; + if (hook) { + hook.on(HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => { + if (pluginId === this.plugin.id) { + this.fallbacks.setSettings(value); + } + }); + } + this.proxiedOn = new Proxy({}, { + get: (_target, prop) => { + if (this.target) { + return this.target.on[prop]; + } + else { + return (...args) => { + this.onQueue.push({ + method: prop, + args, + }); + }; + } + }, + }); + this.proxiedTarget = new Proxy({}, { + get: (_target, prop) => { + if (this.target) { + return this.target[prop]; + } + else if (prop === 'on') { + return this.proxiedOn; + } + else if (Object.keys(this.fallbacks).includes(prop)) { + return (...args) => { + this.targetQueue.push({ + method: prop, + args, + resolve: () => { }, + }); + return this.fallbacks[prop](...args); + }; + } + else { + return (...args) => { + return new Promise(resolve => { + this.targetQueue.push({ + method: prop, + args, + resolve, + }); + }); + }; + } + }, + }); + } + async setRealTarget(target) { + this.target = target; + for (const item of this.onQueue) { + this.target.on[item.method](...item.args); + } + for (const item of this.targetQueue) { + item.resolve(await this.target[item.method](...item.args)); + } + } + } + + function setupDevtoolsPlugin(pluginDescriptor, setupFn) { + const descriptor = pluginDescriptor; + const target = getTarget(); + const hook = getDevtoolsGlobalHook(); + const enableProxy = isProxyAvailable && descriptor.enableEarlyProxy; + if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) { + hook.emit(HOOK_SETUP, pluginDescriptor, setupFn); + } + else { + const proxy = enableProxy ? new ApiProxy(descriptor, hook) : null; + const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || []; + list.push({ + pluginDescriptor: descriptor, + setupFn, + proxy, + }); + if (proxy) + setupFn(proxy.proxiedTarget); + } + } + + const VueDevToolsLabels = { + ["vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */]: 'Vue I18n devtools', + ["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */]: 'I18n Resources', + ["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */]: 'Vue I18n' + }; + const VueDevToolsPlaceholders = { + ["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */]: 'Search for scopes ...' + }; + const VueDevToolsTimelineColors = { + ["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */]: 0xffcd19 + }; + + const VUE_I18N_COMPONENT_TYPES = 'vue-i18n: composer properties'; + let devtoolsApi; + async function enableDevTools(app, i18n) { + return new Promise((resolve, reject) => { + try { + setupDevtoolsPlugin({ + id: "vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */, + label: VueDevToolsLabels["vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */], + packageName: 'vue-i18n', + homepage: 'https://vue-i18n.intlify.dev', + logo: 'https://vue-i18n.intlify.dev/vue-i18n-devtools-logo.png', + componentStateTypes: [VUE_I18N_COMPONENT_TYPES], + app: app // eslint-disable-line @typescript-eslint/no-explicit-any + }, api => { + devtoolsApi = api; + api.on.visitComponentTree(({ componentInstance, treeNode }) => { + updateComponentTreeTags(componentInstance, treeNode, i18n); + }); + api.on.inspectComponent(({ componentInstance, instanceData }) => { + if (componentInstance.vnode.el && + componentInstance.vnode.el.__VUE_I18N__ && + instanceData) { + if (i18n.mode === 'legacy') { + // ignore global scope on legacy mode + if (componentInstance.vnode.el.__VUE_I18N__ !== + i18n.global.__composer) { + inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__); + } + } + else { + inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__); + } + } + }); + api.addInspector({ + id: "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */, + label: VueDevToolsLabels["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */], + icon: 'language', + treeFilterPlaceholder: VueDevToolsPlaceholders["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */] + }); + api.on.getInspectorTree(payload => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + registerScope(payload, i18n); + } + }); + const roots = new Map(); + api.on.getInspectorState(async (payload) => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + api.unhighlightElement(); + inspectScope(payload, i18n); + if (payload.nodeId === 'global') { + if (!roots.has(payload.app)) { + const [root] = await api.getComponentInstances(payload.app); + roots.set(payload.app, root); + } + api.highlightElement(roots.get(payload.app)); + } + else { + const instance = getComponentInstance(payload.nodeId, i18n); + instance && api.highlightElement(instance); + } + } + }); + api.on.editInspectorState(payload => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + editScope(payload, i18n); + } + }); + api.addTimelineLayer({ + id: "vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */, + label: VueDevToolsLabels["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */], + color: VueDevToolsTimelineColors["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */] + }); + resolve(true); + }); + } + catch (e) { + console.error(e); + reject(false); + } + }); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function getI18nScopeLable(instance) { + return (instance.type.name || + instance.type.displayName || + instance.type.__file || + 'Anonymous'); + } + function updateComponentTreeTags(instance, // eslint-disable-line @typescript-eslint/no-explicit-any + treeNode, i18n) { + // prettier-ignore + const global = i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + if (instance && instance.vnode.el && instance.vnode.el.__VUE_I18N__) { + // add custom tags local scope only + if (instance.vnode.el.__VUE_I18N__ !== global) { + const tag = { + label: `i18n (${getI18nScopeLable(instance)} Scope)`, + textColor: 0x000000, + backgroundColor: 0xffcd19 + }; + treeNode.tags.push(tag); + } + } + } + function inspectComposer(instanceData, composer) { + const type = VUE_I18N_COMPONENT_TYPES; + instanceData.state.push({ + type, + key: 'locale', + editable: true, + value: composer.locale.value + }); + instanceData.state.push({ + type, + key: 'availableLocales', + editable: false, + value: composer.availableLocales + }); + instanceData.state.push({ + type, + key: 'fallbackLocale', + editable: true, + value: composer.fallbackLocale.value + }); + instanceData.state.push({ + type, + key: 'inheritLocale', + editable: true, + value: composer.inheritLocale + }); + instanceData.state.push({ + type, + key: 'messages', + editable: false, + value: getLocaleMessageValue(composer.messages.value) + }); + { + instanceData.state.push({ + type, + key: 'datetimeFormats', + editable: false, + value: composer.datetimeFormats.value + }); + instanceData.state.push({ + type, + key: 'numberFormats', + editable: false, + value: composer.numberFormats.value + }); + } + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function getLocaleMessageValue(messages) { + const value = {}; + Object.keys(messages).forEach((key) => { + const v = messages[key]; + if (isFunction(v) && 'source' in v) { + value[key] = getMessageFunctionDetails(v); + } + else if (isMessageAST(v) && v.loc && v.loc.source) { + value[key] = v.loc.source; + } + else if (isObject(v)) { + value[key] = getLocaleMessageValue(v); + } + else { + value[key] = v; + } + }); + return value; + } + const ESC = { + '<': '<', + '>': '>', + '"': '"', + '&': '&' + }; + function escape(s) { + return s.replace(/[<>"&]/g, escapeChar); + } + function escapeChar(a) { + return ESC[a] || a; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function getMessageFunctionDetails(func) { + const argString = func.source ? `("${escape(func.source)}")` : `(?)`; + return { + _custom: { + type: 'function', + display: `ƒ ${argString}` + } + }; + } + function registerScope(payload, i18n) { + payload.rootNodes.push({ + id: 'global', + label: 'Global Scope' + }); + // prettier-ignore + const global = i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + for (const [keyInstance, instance] of i18n.__instances) { + // prettier-ignore + const composer = i18n.mode === 'composition' + ? instance + : instance.__composer; + if (global === composer) { + continue; + } + payload.rootNodes.push({ + id: composer.id.toString(), + label: `${getI18nScopeLable(keyInstance)} Scope` + }); + } + } + function getComponentInstance(nodeId, i18n) { + let instance = null; + if (nodeId !== 'global') { + for (const [component, composer] of i18n.__instances.entries()) { + if (composer.id.toString() === nodeId) { + instance = component; + break; + } + } + } + return instance; + } + function getComposer$1(nodeId, i18n) { + if (nodeId === 'global') { + return i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + } + else { + const instance = Array.from(i18n.__instances.values()).find(item => item.id.toString() === nodeId); + if (instance) { + return i18n.mode === 'composition' + ? instance + : instance.__composer; + } + else { + return null; + } + } + } + function inspectScope(payload, i18n + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ) { + const composer = getComposer$1(payload.nodeId, i18n); + if (composer) { + // TODO: + // eslint-disable-next-line @typescript-eslint/no-explicit-any + payload.state = makeScopeInspectState(composer); + } + return null; + } + function makeScopeInspectState(composer) { + const state = {}; + const localeType = 'Locale related info'; + const localeStates = [ + { + type: localeType, + key: 'locale', + editable: true, + value: composer.locale.value + }, + { + type: localeType, + key: 'fallbackLocale', + editable: true, + value: composer.fallbackLocale.value + }, + { + type: localeType, + key: 'availableLocales', + editable: false, + value: composer.availableLocales + }, + { + type: localeType, + key: 'inheritLocale', + editable: true, + value: composer.inheritLocale + } + ]; + state[localeType] = localeStates; + const localeMessagesType = 'Locale messages info'; + const localeMessagesStates = [ + { + type: localeMessagesType, + key: 'messages', + editable: false, + value: getLocaleMessageValue(composer.messages.value) + } + ]; + state[localeMessagesType] = localeMessagesStates; + { + const datetimeFormatsType = 'Datetime formats info'; + const datetimeFormatsStates = [ + { + type: datetimeFormatsType, + key: 'datetimeFormats', + editable: false, + value: composer.datetimeFormats.value + } + ]; + state[datetimeFormatsType] = datetimeFormatsStates; + const numberFormatsType = 'Datetime formats info'; + const numberFormatsStates = [ + { + type: numberFormatsType, + key: 'numberFormats', + editable: false, + value: composer.numberFormats.value + } + ]; + state[numberFormatsType] = numberFormatsStates; + } + return state; + } + function addTimelineEvent(event, payload) { + if (devtoolsApi) { + let groupId; + if (payload && 'groupId' in payload) { + groupId = payload.groupId; + delete payload.groupId; + } + devtoolsApi.addTimelineEvent({ + layerId: "vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */, + event: { + title: event, + groupId, + time: Date.now(), + meta: {}, + data: payload || {}, + logType: event === "compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */ + ? 'error' + : event === "fallback" /* VueDevToolsTimelineEvents.FALBACK */ || + event === "missing" /* VueDevToolsTimelineEvents.MISSING */ + ? 'warning' + : 'default' + } + }); + } + } + function editScope(payload, i18n) { + const composer = getComposer$1(payload.nodeId, i18n); + if (composer) { + const [field] = payload.path; + if (field === 'locale' && isString(payload.state.value)) { + composer.locale.value = payload.state.value; + } + else if (field === 'fallbackLocale' && + (isString(payload.state.value) || + isArray(payload.state.value) || + isObject(payload.state.value))) { + composer.fallbackLocale.value = payload.state.value; + } + else if (field === 'inheritLocale' && isBoolean(payload.state.value)) { + composer.inheritLocale = payload.state.value; + } + } + } + + /** + * Supports compatibility for legacy vue-i18n APIs + * This mixin is used when we use vue-i18n@v9.x or later + */ + function defineMixin(vuei18n, composer, i18n) { + return { + beforeCreate() { + const instance = vue.getCurrentInstance(); + /* istanbul ignore if */ + if (!instance) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const options = this.$options; + if (options.i18n) { + const optionsI18n = options.i18n; + if (options.__i18n) { + optionsI18n.__i18n = options.__i18n; + } + optionsI18n.__root = composer; + if (this === this.$root) { + // merge option and gttach global + this.$i18n = mergeToGlobal(vuei18n, optionsI18n); + } + else { + optionsI18n.__injectWithOption = true; + optionsI18n.__extender = i18n.__vueI18nExtend; + // atttach local VueI18n instance + this.$i18n = createVueI18n(optionsI18n); + // extend VueI18n instance + const _vueI18n = this.$i18n; + if (_vueI18n.__extender) { + _vueI18n.__disposer = _vueI18n.__extender(this.$i18n); + } + } + } + else if (options.__i18n) { + if (this === this.$root) { + // merge option and gttach global + this.$i18n = mergeToGlobal(vuei18n, options); + } + else { + // atttach local VueI18n instance + this.$i18n = createVueI18n({ + __i18n: options.__i18n, + __injectWithOption: true, + __extender: i18n.__vueI18nExtend, + __root: composer + }); + // extend VueI18n instance + const _vueI18n = this.$i18n; + if (_vueI18n.__extender) { + _vueI18n.__disposer = _vueI18n.__extender(this.$i18n); + } + } + } + else { + // attach global VueI18n instance + this.$i18n = vuei18n; + } + if (options.__i18nGlobal) { + adjustI18nResources(composer, options, options); + } + // defines vue-i18n legacy APIs + this.$t = (...args) => this.$i18n.t(...args); + this.$rt = (...args) => this.$i18n.rt(...args); + this.$tc = (...args) => this.$i18n.tc(...args); + this.$te = (key, locale) => this.$i18n.te(key, locale); + this.$d = (...args) => this.$i18n.d(...args); + this.$n = (...args) => this.$i18n.n(...args); + this.$tm = (key) => this.$i18n.tm(key); + i18n.__setInstance(instance, this.$i18n); + }, + mounted() { + /* istanbul ignore if */ + if (this.$el && + this.$i18n) { + const _vueI18n = this.$i18n; + this.$el.__VUE_I18N__ = _vueI18n.__composer; + const emitter = (this.__v_emitter = + createEmitter()); + _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter); + emitter.on('*', addTimelineEvent); + } + }, + unmounted() { + const instance = vue.getCurrentInstance(); + /* istanbul ignore if */ + if (!instance) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const _vueI18n = this.$i18n; + /* istanbul ignore if */ + if (this.$el && + this.$el.__VUE_I18N__) { + if (this.__v_emitter) { + this.__v_emitter.off('*', addTimelineEvent); + delete this.__v_emitter; + } + if (this.$i18n) { + _vueI18n.__disableEmitter && _vueI18n.__disableEmitter(); + delete this.$el.__VUE_I18N__; + } + } + delete this.$t; + delete this.$rt; + delete this.$tc; + delete this.$te; + delete this.$d; + delete this.$n; + delete this.$tm; + if (_vueI18n.__disposer) { + _vueI18n.__disposer(); + delete _vueI18n.__disposer; + delete _vueI18n.__extender; + } + i18n.__deleteInstance(instance); + delete this.$i18n; + } + }; + } + function mergeToGlobal(g, options) { + g.locale = options.locale || g.locale; + g.fallbackLocale = options.fallbackLocale || g.fallbackLocale; + g.missing = options.missing || g.missing; + g.silentTranslationWarn = + options.silentTranslationWarn || g.silentFallbackWarn; + g.silentFallbackWarn = options.silentFallbackWarn || g.silentFallbackWarn; + g.formatFallbackMessages = + options.formatFallbackMessages || g.formatFallbackMessages; + g.postTranslation = options.postTranslation || g.postTranslation; + g.warnHtmlInMessage = options.warnHtmlInMessage || g.warnHtmlInMessage; + g.escapeParameterHtml = options.escapeParameterHtml || g.escapeParameterHtml; + g.sync = options.sync || g.sync; + g.__composer[SetPluralRulesSymbol](options.pluralizationRules || g.pluralizationRules); + const messages = getLocaleMessages(g.locale, { + messages: options.messages, + __i18n: options.__i18n + }); + Object.keys(messages).forEach(locale => g.mergeLocaleMessage(locale, messages[locale])); + if (options.datetimeFormats) { + Object.keys(options.datetimeFormats).forEach(locale => g.mergeDateTimeFormat(locale, options.datetimeFormats[locale])); + } + if (options.numberFormats) { + Object.keys(options.numberFormats).forEach(locale => g.mergeNumberFormat(locale, options.numberFormats[locale])); + } + return g; + } + + /** + * Injection key for {@link useI18n} + * + * @remarks + * The global injection key for I18n instances with `useI18n`. this injection key is used in Web Components. + * Specify the i18n instance created by {@link createI18n} together with `provide` function. + * + * @VueI18nGeneral + */ + const I18nInjectionKey = + /* #__PURE__*/ makeSymbol('global-vue-i18n'); + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + function createI18n(options = {}, VueI18nLegacy) { + // prettier-ignore + const __legacyMode = isBoolean(options.legacy) + ? options.legacy + : true; + // prettier-ignore + const __globalInjection = isBoolean(options.globalInjection) + ? options.globalInjection + : true; + // prettier-ignore + const __allowComposition = __legacyMode + ? !!options.allowComposition + : true; + const __instances = new Map(); + const [globalScope, __global] = createGlobal(options, __legacyMode); + const symbol = /* #__PURE__*/ makeSymbol('vue-i18n' ); + { + if (__legacyMode && __allowComposition && !false) { + warn(getWarnMessage(I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION)); + } + } + function __getInstance(component) { + return __instances.get(component) || null; + } + function __setInstance(component, instance) { + __instances.set(component, instance); + } + function __deleteInstance(component) { + __instances.delete(component); + } + { + const i18n = { + // mode + get mode() { + return __legacyMode + ? 'legacy' + : 'composition'; + }, + // allowComposition + get allowComposition() { + return __allowComposition; + }, + // install plugin + async install(app, ...options) { + { + app.__VUE_I18N__ = i18n; + } + // setup global provider + app.__VUE_I18N_SYMBOL__ = symbol; + app.provide(app.__VUE_I18N_SYMBOL__, i18n); + // set composer & vuei18n extend hook options from plugin options + if (isPlainObject(options[0])) { + const opts = options[0]; + i18n.__composerExtend = + opts.__composerExtend; + i18n.__vueI18nExtend = + opts.__vueI18nExtend; + } + // global method and properties injection for Composition API + let globalReleaseHandler = null; + if (!__legacyMode && __globalInjection) { + globalReleaseHandler = injectGlobalFields(app, i18n.global); + } + // install built-in components and directive + { + apply(app, i18n, ...options); + } + // setup mixin for Legacy API + if (__legacyMode) { + app.mixin(defineMixin(__global, __global.__composer, i18n)); + } + // release global scope + const unmountApp = app.unmount; + app.unmount = () => { + globalReleaseHandler && globalReleaseHandler(); + i18n.dispose(); + unmountApp(); + }; + // setup vue-devtools plugin + { + const ret = await enableDevTools(app, i18n); + if (!ret) { + throw createI18nError(I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN); + } + const emitter = createEmitter(); + if (__legacyMode) { + const _vueI18n = __global; + _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter); + } + else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = __global; + _composer[EnableEmitter] && _composer[EnableEmitter](emitter); + } + emitter.on('*', addTimelineEvent); + } + }, + // global accessor + get global() { + return __global; + }, + dispose() { + globalScope.stop(); + }, + // @internal + __instances, + // @internal + __getInstance, + // @internal + __setInstance, + // @internal + __deleteInstance + }; + return i18n; + } + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + function useI18n(options = {}) { + const instance = vue.getCurrentInstance(); + if (instance == null) { + throw createI18nError(I18nErrorCodes.MUST_BE_CALL_SETUP_TOP); + } + if (!instance.isCE && + instance.appContext.app != null && + !instance.appContext.app.__VUE_I18N_SYMBOL__) { + throw createI18nError(I18nErrorCodes.NOT_INSTALLED); + } + const i18n = getI18nInstance(instance); + const gl = getGlobalComposer(i18n); + const componentOptions = getComponentOptions(instance); + const scope = getScope(options, componentOptions); + { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (i18n.mode === 'legacy' && !options.__useComponent) { + if (!i18n.allowComposition) { + throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE); + } + return useI18nForLegacy(instance, scope, gl, options); + } + } + if (scope === 'global') { + adjustI18nResources(gl, options, componentOptions); + return gl; + } + if (scope === 'parent') { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let composer = getComposer(i18n, instance, options.__useComponent); + if (composer == null) { + { + warn(getWarnMessage(I18nWarnCodes.NOT_FOUND_PARENT_SCOPE)); + } + composer = gl; + } + return composer; + } + const i18nInternal = i18n; + let composer = i18nInternal.__getInstance(instance); + if (composer == null) { + const composerOptions = assign({}, options); + if ('__i18n' in componentOptions) { + composerOptions.__i18n = componentOptions.__i18n; + } + if (gl) { + composerOptions.__root = gl; + } + composer = createComposer(composerOptions); + if (i18nInternal.__composerExtend) { + composer[DisposeSymbol] = + i18nInternal.__composerExtend(composer); + } + setupLifeCycle(i18nInternal, instance, composer); + i18nInternal.__setInstance(instance, composer); + } + return composer; + } + /** + * Cast to VueI18n legacy compatible type + * + * @remarks + * This API is provided only with [vue-i18n-bridge](https://vue-i18n.intlify.dev/guide/migration/ways.html#what-is-vue-i18n-bridge). + * + * The purpose of this function is to convert an {@link I18n} instance created with {@link createI18n | createI18n(legacy: true)} into a `vue-i18n@v8.x` compatible instance of `new VueI18n` in a TypeScript environment. + * + * @param i18n - An instance of {@link I18n} + * @returns A i18n instance which is casted to {@link VueI18n} type + * + * @VueI18nTip + * :new: provided by **vue-i18n-bridge only** + * + * @VueI18nGeneral + */ + /* #__NO_SIDE_EFFECTS__ */ + const castToVueI18n = (i18n + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ) => { + if (!(__VUE_I18N_BRIDGE__ in i18n)) { + throw createI18nError(I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N); + } + return i18n; + }; + function createGlobal(options, legacyMode, VueI18nLegacy // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + const scope = vue.effectScope(); + { + const obj = legacyMode + ? scope.run(() => createVueI18n(options)) + : scope.run(() => createComposer(options)); + if (obj == null) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + return [scope, obj]; + } + } + function getI18nInstance(instance) { + { + const i18n = vue.inject(!instance.isCE + ? instance.appContext.app.__VUE_I18N_SYMBOL__ + : I18nInjectionKey); + /* istanbul ignore if */ + if (!i18n) { + throw createI18nError(!instance.isCE + ? I18nErrorCodes.UNEXPECTED_ERROR + : I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE); + } + return i18n; + } + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function getScope(options, componentOptions) { + // prettier-ignore + return isEmptyObject(options) + ? ('__i18n' in componentOptions) + ? 'local' + : 'global' + : !options.useScope + ? 'local' + : options.useScope; + } + function getGlobalComposer(i18n) { + // prettier-ignore + return i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer + ; + } + function getComposer(i18n, target, useComponent = false) { + let composer = null; + const root = target.root; + let current = getParentComponentInstance(target, useComponent); + while (current != null) { + const i18nInternal = i18n; + if (i18n.mode === 'composition') { + composer = i18nInternal.__getInstance(current); + } + else { + { + const vueI18n = i18nInternal.__getInstance(current); + if (vueI18n != null) { + composer = vueI18n + .__composer; + if (useComponent && + composer && + !composer[InejctWithOptionSymbol] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + composer = null; + } + } + } + } + if (composer != null) { + break; + } + if (root === current) { + break; + } + current = current.parent; + } + return composer; + } + function getParentComponentInstance(target, useComponent = false) { + if (target == null) { + return null; + } + { + // if `useComponent: true` will be specified, we get lexical scope owner instance for use-case slots + return !useComponent + ? target.parent + : target.vnode.ctx || target.parent; // eslint-disable-line @typescript-eslint/no-explicit-any + } + } + function setupLifeCycle(i18n, target, composer) { + let emitter = null; + { + vue.onMounted(() => { + // inject composer instance to DOM for intlify-devtools + if (target.vnode.el) { + target.vnode.el.__VUE_I18N__ = composer; + emitter = createEmitter(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = composer; + _composer[EnableEmitter] && _composer[EnableEmitter](emitter); + emitter.on('*', addTimelineEvent); + } + }, target); + vue.onUnmounted(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = composer; + // remove composer instance from DOM for intlify-devtools + if (target.vnode.el && + target.vnode.el.__VUE_I18N__) { + emitter && emitter.off('*', addTimelineEvent); + _composer[DisableEmitter] && _composer[DisableEmitter](); + delete target.vnode.el.__VUE_I18N__; + } + i18n.__deleteInstance(target); + // dispose extended resources + const dispose = _composer[DisposeSymbol]; + if (dispose) { + dispose(); + delete _composer[DisposeSymbol]; + } + }, target); + } + } + function useI18nForLegacy(instance, scope, root, options = {} // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + const isLocalScope = scope === 'local'; + const _composer = vue.shallowRef(null); + if (isLocalScope && + instance.proxy && + !(instance.proxy.$options.i18n || instance.proxy.$options.__i18n)) { + throw createI18nError(I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION); + } + const _inheritLocale = isBoolean(options.inheritLocale) + ? options.inheritLocale + : !isString(options.locale); + const _locale = vue.ref( + // prettier-ignore + !isLocalScope || _inheritLocale + ? root.locale.value + : isString(options.locale) + ? options.locale + : DEFAULT_LOCALE); + const _fallbackLocale = vue.ref( + // prettier-ignore + !isLocalScope || _inheritLocale + ? root.fallbackLocale.value + : isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale.value); + const _messages = vue.ref(getLocaleMessages(_locale.value, options)); + // prettier-ignore + const _datetimeFormats = vue.ref(isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : { [_locale.value]: {} }); + // prettier-ignore + const _numberFormats = vue.ref(isPlainObject(options.numberFormats) + ? options.numberFormats + : { [_locale.value]: {} }); + // prettier-ignore + const _missingWarn = isLocalScope + ? root.missingWarn + : isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + // prettier-ignore + const _fallbackWarn = isLocalScope + ? root.fallbackWarn + : isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + // prettier-ignore + const _fallbackRoot = isLocalScope + ? root.fallbackRoot + : isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + // configure fall back to root + const _fallbackFormat = !!options.fallbackFormat; + // runtime missing + const _missing = isFunction(options.missing) ? options.missing : null; + // postTranslation handler + const _postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + // prettier-ignore + const _warnHtmlMessage = isLocalScope + ? root.warnHtmlMessage + : isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const _escapeParameter = !!options.escapeParameter; + // prettier-ignore + const _modifiers = isLocalScope + ? root.modifiers + : isPlainObject(options.modifiers) + ? options.modifiers + : {}; + // pluralRules + const _pluralRules = options.pluralRules || (isLocalScope && root.pluralRules); + // track reactivity + function trackReactivityValues() { + return [ + _locale.value, + _fallbackLocale.value, + _messages.value, + _datetimeFormats.value, + _numberFormats.value + ]; + } + // locale + const locale = vue.computed({ + get: () => { + return _composer.value ? _composer.value.locale.value : _locale.value; + }, + set: val => { + if (_composer.value) { + _composer.value.locale.value = val; + } + _locale.value = val; + } + }); + // fallbackLocale + const fallbackLocale = vue.computed({ + get: () => { + return _composer.value + ? _composer.value.fallbackLocale.value + : _fallbackLocale.value; + }, + set: val => { + if (_composer.value) { + _composer.value.fallbackLocale.value = val; + } + _fallbackLocale.value = val; + } + }); + // messages + const messages = vue.computed(() => { + if (_composer.value) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return _composer.value.messages.value; + } + else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return _messages.value; + } + }); + const datetimeFormats = vue.computed(() => _datetimeFormats.value); + const numberFormats = vue.computed(() => _numberFormats.value); + function getPostTranslationHandler() { + return _composer.value + ? _composer.value.getPostTranslationHandler() + : _postTranslation; + } + function setPostTranslationHandler(handler) { + if (_composer.value) { + _composer.value.setPostTranslationHandler(handler); + } + } + function getMissingHandler() { + return _composer.value ? _composer.value.getMissingHandler() : _missing; + } + function setMissingHandler(handler) { + if (_composer.value) { + _composer.value.setMissingHandler(handler); + } + } + function warpWithDeps(fn) { + trackReactivityValues(); + return fn(); + } + function t(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.t, null, [...args])) + : warpWithDeps(() => ''); + } + function rt(...args) { + return _composer.value + ? Reflect.apply(_composer.value.rt, null, [...args]) + : ''; + } + function d(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.d, null, [...args])) + : warpWithDeps(() => ''); + } + function n(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.n, null, [...args])) + : warpWithDeps(() => ''); + } + function tm(key) { + return _composer.value ? _composer.value.tm(key) : {}; + } + function te(key, locale) { + return _composer.value ? _composer.value.te(key, locale) : false; + } + function getLocaleMessage(locale) { + return _composer.value ? _composer.value.getLocaleMessage(locale) : {}; + } + function setLocaleMessage(locale, message) { + if (_composer.value) { + _composer.value.setLocaleMessage(locale, message); + _messages.value[locale] = message; + } + } + function mergeLocaleMessage(locale, message) { + if (_composer.value) { + _composer.value.mergeLocaleMessage(locale, message); + } + } + function getDateTimeFormat(locale) { + return _composer.value ? _composer.value.getDateTimeFormat(locale) : {}; + } + function setDateTimeFormat(locale, format) { + if (_composer.value) { + _composer.value.setDateTimeFormat(locale, format); + _datetimeFormats.value[locale] = format; + } + } + function mergeDateTimeFormat(locale, format) { + if (_composer.value) { + _composer.value.mergeDateTimeFormat(locale, format); + } + } + function getNumberFormat(locale) { + return _composer.value ? _composer.value.getNumberFormat(locale) : {}; + } + function setNumberFormat(locale, format) { + if (_composer.value) { + _composer.value.setNumberFormat(locale, format); + _numberFormats.value[locale] = format; + } + } + function mergeNumberFormat(locale, format) { + if (_composer.value) { + _composer.value.mergeNumberFormat(locale, format); + } + } + const wrapper = { + get id() { + return _composer.value ? _composer.value.id : -1; + }, + locale, + fallbackLocale, + messages, + datetimeFormats, + numberFormats, + get inheritLocale() { + return _composer.value ? _composer.value.inheritLocale : _inheritLocale; + }, + set inheritLocale(val) { + if (_composer.value) { + _composer.value.inheritLocale = val; + } + }, + get availableLocales() { + return _composer.value + ? _composer.value.availableLocales + : Object.keys(_messages.value); + }, + get modifiers() { + return (_composer.value ? _composer.value.modifiers : _modifiers); + }, + get pluralRules() { + return (_composer.value ? _composer.value.pluralRules : _pluralRules); + }, + get isGlobal() { + return _composer.value ? _composer.value.isGlobal : false; + }, + get missingWarn() { + return _composer.value ? _composer.value.missingWarn : _missingWarn; + }, + set missingWarn(val) { + if (_composer.value) { + _composer.value.missingWarn = val; + } + }, + get fallbackWarn() { + return _composer.value ? _composer.value.fallbackWarn : _fallbackWarn; + }, + set fallbackWarn(val) { + if (_composer.value) { + _composer.value.missingWarn = val; + } + }, + get fallbackRoot() { + return _composer.value ? _composer.value.fallbackRoot : _fallbackRoot; + }, + set fallbackRoot(val) { + if (_composer.value) { + _composer.value.fallbackRoot = val; + } + }, + get fallbackFormat() { + return _composer.value ? _composer.value.fallbackFormat : _fallbackFormat; + }, + set fallbackFormat(val) { + if (_composer.value) { + _composer.value.fallbackFormat = val; + } + }, + get warnHtmlMessage() { + return _composer.value + ? _composer.value.warnHtmlMessage + : _warnHtmlMessage; + }, + set warnHtmlMessage(val) { + if (_composer.value) { + _composer.value.warnHtmlMessage = val; + } + }, + get escapeParameter() { + return _composer.value + ? _composer.value.escapeParameter + : _escapeParameter; + }, + set escapeParameter(val) { + if (_composer.value) { + _composer.value.escapeParameter = val; + } + }, + t, + getPostTranslationHandler, + setPostTranslationHandler, + getMissingHandler, + setMissingHandler, + rt, + d, + n, + tm, + te, + getLocaleMessage, + setLocaleMessage, + mergeLocaleMessage, + getDateTimeFormat, + setDateTimeFormat, + mergeDateTimeFormat, + getNumberFormat, + setNumberFormat, + mergeNumberFormat + }; + function sync(composer) { + composer.locale.value = _locale.value; + composer.fallbackLocale.value = _fallbackLocale.value; + Object.keys(_messages.value).forEach(locale => { + composer.mergeLocaleMessage(locale, _messages.value[locale]); + }); + Object.keys(_datetimeFormats.value).forEach(locale => { + composer.mergeDateTimeFormat(locale, _datetimeFormats.value[locale]); + }); + Object.keys(_numberFormats.value).forEach(locale => { + composer.mergeNumberFormat(locale, _numberFormats.value[locale]); + }); + composer.escapeParameter = _escapeParameter; + composer.fallbackFormat = _fallbackFormat; + composer.fallbackRoot = _fallbackRoot; + composer.fallbackWarn = _fallbackWarn; + composer.missingWarn = _missingWarn; + composer.warnHtmlMessage = _warnHtmlMessage; + } + vue.onBeforeMount(() => { + if (instance.proxy == null || instance.proxy.$i18n == null) { + throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const composer = (_composer.value = instance.proxy.$i18n + .__composer); + if (scope === 'global') { + _locale.value = composer.locale.value; + _fallbackLocale.value = composer.fallbackLocale.value; + _messages.value = composer.messages.value; + _datetimeFormats.value = composer.datetimeFormats.value; + _numberFormats.value = composer.numberFormats.value; + } + else if (isLocalScope) { + sync(composer); + } + }); + return wrapper; + } + const globalExportProps = [ + 'locale', + 'fallbackLocale', + 'availableLocales' + ]; + const globalExportMethods = ['t', 'rt', 'd', 'n', 'tm', 'te'] + ; + function injectGlobalFields(app, composer) { + const i18n = Object.create(null); + globalExportProps.forEach(prop => { + const desc = Object.getOwnPropertyDescriptor(composer, prop); + if (!desc) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const wrap = vue.isRef(desc.value) // check computed props + ? { + get() { + return desc.value.value; + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + set(val) { + desc.value.value = val; + } + } + : { + get() { + return desc.get && desc.get(); + } + }; + Object.defineProperty(i18n, prop, wrap); + }); + app.config.globalProperties.$i18n = i18n; + globalExportMethods.forEach(method => { + const desc = Object.getOwnPropertyDescriptor(composer, method); + if (!desc || !desc.value) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + Object.defineProperty(app.config.globalProperties, `$${method}`, desc); + }); + const dispose = () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete app.config.globalProperties.$i18n; + globalExportMethods.forEach(method => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete app.config.globalProperties[`$${method}`]; + }); + }; + return dispose; + } + + // register message resolver at vue-i18n + registerMessageResolver(resolveValue); + // register fallback locale at vue-i18n + registerLocaleFallbacker(fallbackWithLocaleChain); + // NOTE: experimental !! + { + const target = getGlobalThis(); + target.__INTLIFY__ = true; + setDevToolsHook(target.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__); + } + { + initDev(); + } + + exports.DatetimeFormat = DatetimeFormat; + exports.I18nD = I18nD; + exports.I18nInjectionKey = I18nInjectionKey; + exports.I18nN = I18nN; + exports.I18nT = I18nT; + exports.NumberFormat = NumberFormat; + exports.Translation = Translation; + exports.VERSION = VERSION; + exports.castToVueI18n = castToVueI18n; + exports.createI18n = createI18n; + exports.useI18n = useI18n; + exports.vTDirective = vTDirective; + + return exports; + +})({}, Vue); diff --git a/node_modules/vue-i18n/dist/vue-i18n.runtime.global.prod.js b/node_modules/vue-i18n/dist/vue-i18n.runtime.global.prod.js new file mode 100644 index 0000000..ed48fc7 --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.runtime.global.prod.js @@ -0,0 +1,6 @@ +/*! + * vue-i18n v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +var VueI18n=function(e,t){"use strict";function a(e,t){"undefined"!=typeof console&&(console.warn("[intlify] "+e),t&&console.warn(t.stack))}const n="undefined"!=typeof window,r=(e,t=!1)=>t?Symbol.for(e):Symbol(e),l=(e,t,a)=>o({l:e,k:t,s:a}),o=e=>JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),s=e=>"number"==typeof e&&isFinite(e),i=e=>"[object Date]"===y(e),c=e=>"[object RegExp]"===y(e),u=e=>N(e)&&0===Object.keys(e).length,m=Object.assign,f=Object.create,_=(e=null)=>f(e);function g(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/").replace(/=/g,"=")}function p(e){return e.replace(/&(?![a-zA-Z0-9#]{2,6};)/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")}const v=Object.prototype.hasOwnProperty;function d(e,t){return v.call(e,t)}const b=Array.isArray,E=e=>"function"==typeof e,h=e=>"string"==typeof e,k=e=>"boolean"==typeof e,L=e=>null!==e&&"object"==typeof e,T=e=>L(e)&&E(e.then)&&E(e.catch),F=Object.prototype.toString,y=e=>F.call(e),N=e=>{if(!L(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t.constructor===Object};function I(e){let t=e;return()=>++t}const R=e=>!L(e)||b(e);function O(e,t){if(R(e)||R(t))throw new Error("Invalid value");const a=[{src:e,des:t}];for(;a.length;){const{src:e,des:t}=a.pop();Object.keys(e).forEach((n=>{"__proto__"!==n&&(L(e[n])&&!L(t[n])&&(t[n]=Array.isArray(e[n])?[]:_()),R(t[n])||R(e[n])?t[n]=e[n]:a.push({src:e[n],des:t[n]}))}))}}function M(e,t,a={}){const{domain:n,messages:r,args:l}=a,o=new SyntaxError(String(e));return o.code=e,t&&(o.location=t),o.domain=n,o}function W(e){return L(e)&&0===function(e,t,a){for(let n=0;ne,H=e=>"",j="text",V=e=>0===e.length?"":function(e,t=""){return e.reduce(((e,a,n)=>0===n?e+a:e+t+a),"")}(e),G=e=>null==e?"":b(e)||N(e)&&e.toString===F?JSON.stringify(e,null,2):String(e);function Y(e,t){return e=Math.abs(e),2===t?e?e>1?1:0:1:e?Math.min(e,2):0}function B(e={}){const t=e.locale,a=function(e){const t=s(e.pluralIndex)?e.pluralIndex:-1;return e.named&&(s(e.named.count)||s(e.named.n))?s(e.named.count)?e.named.count:s(e.named.n)?e.named.n:t:t}(e),n=L(e.pluralRules)&&h(t)&&E(e.pluralRules[t])?e.pluralRules[t]:Y,r=L(e.pluralRules)&&h(t)&&E(e.pluralRules[t])?Y:void 0,l=e.list||[],o=e.named||_();s(e.pluralIndex)&&function(e,t){t.count||(t.count=e),t.n||(t.n=e)}(a,o);function i(t){const a=E(e.messages)?e.messages(t):!!L(e.messages)&&e.messages[t];return a||(e.parent?e.parent.message(t):H)}const c=N(e.processor)&&E(e.processor.normalize)?e.processor.normalize:V,u=N(e.processor)&&E(e.processor.interpolate)?e.processor.interpolate:G,f={list:e=>l[e],named:e=>o[e],plural:e=>e[n(a,e.length,r)],linked:(t,...a)=>{const[n,r]=a;let l="text",o="";1===a.length?L(n)?(o=n.modifier||o,l=n.type||l):h(n)&&(o=n||o):2===a.length&&(h(n)&&(o=n||o),h(r)&&(l=r||l));const s=i(t)(f),c="vnode"===l&&b(s)&&o?s[0]:s;return o?(u=o,e.modifiers?e.modifiers[u]:x)(c,l):c;var u},message:i,type:N(e.processor)&&h(e.processor.type)?e.processor.type:j,interpolate:u,normalize:c,values:m(_(),l,o)};return f}const X=I(17),z={INVALID_ARGUMENT:17,INVALID_DATE_ARGUMENT:X(),INVALID_ISO_DATE_ARGUMENT:X(),NOT_SUPPORT_NON_STRING_MESSAGE:X(),NOT_SUPPORT_LOCALE_PROMISE_VALUE:X(),NOT_SUPPORT_LOCALE_ASYNC_FUNCTION:X(),NOT_SUPPORT_LOCALE_TYPE:X(),__EXTEND_POINT__:X()};function J(e,t){return null!=t.locale?Z(t.locale):Z(e.locale)}let q;function Z(e){if(h(e))return e;if(E(e)){if(e.resolvedOnce&&null!=q)return q;if("Function"===e.constructor.name){const t=e();if(T(t))throw Error(z.NOT_SUPPORT_LOCALE_PROMISE_VALUE);return q=t}throw Error(z.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION)}throw Error(z.NOT_SUPPORT_LOCALE_TYPE)}function K(e,t,a){return[...new Set([a,...b(t)?t:L(t)?Object.keys(t):h(t)?[t]:[a]])]}function Q(e,t,a){const n=h(a)?a:le,r=e;r.__localeChainCache||(r.__localeChainCache=new Map);let l=r.__localeChainCache.get(n);if(!l){l=[];let e=[a];for(;b(e);)e=ee(l,e,t);const o=b(t)||!N(t)?t:t.default?t.default:null;e=h(o)?[o]:o,b(e)&&ee(l,e,!1),r.__localeChainCache.set(n,l)}return l}function ee(e,t,a){let n=!0;for(let r=0;r`${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;let ie,ce,ue;let me=null;const fe=e=>{me=e},_e=()=>me;let ge=0;function pe(e={}){const t=E(e.onWarn)?e.onWarn:a,n=h(e.version)?e.version:ne,r=h(e.locale)||E(e.locale)?e.locale:le,l=E(r)?le:r,o=b(e.fallbackLocale)||N(e.fallbackLocale)||h(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:l,s=N(e.messages)?e.messages:ve(l),i=N(e.datetimeFormats)?e.datetimeFormats:ve(l),u=N(e.numberFormats)?e.numberFormats:ve(l),f=m(_(),e.modifiers,{upper:(e,t)=>"text"===t&&h(e)?e.toUpperCase():"vnode"===t&&L(e)&&"__v_isVNode"in e?e.children.toUpperCase():e,lower:(e,t)=>"text"===t&&h(e)?e.toLowerCase():"vnode"===t&&L(e)&&"__v_isVNode"in e?e.children.toLowerCase():e,capitalize:(e,t)=>"text"===t&&h(e)?se(e):"vnode"===t&&L(e)&&"__v_isVNode"in e?se(e.children):e}),g=e.pluralRules||_(),p=E(e.missing)?e.missing:null,v=!k(e.missingWarn)&&!c(e.missingWarn)||e.missingWarn,d=!k(e.fallbackWarn)&&!c(e.fallbackWarn)||e.fallbackWarn,T=!!e.fallbackFormat,F=!!e.unresolving,y=E(e.postTranslation)?e.postTranslation:null,I=N(e.processor)?e.processor:null,R=!k(e.warnHtmlMessage)||e.warnHtmlMessage,O=!!e.escapeParameter,M=E(e.messageCompiler)?e.messageCompiler:ie,W=E(e.messageResolver)?e.messageResolver:ce||U,w=E(e.localeFallbacker)?e.localeFallbacker:ue||K,P=L(e.fallbackContext)?e.fallbackContext:void 0,C=e,D=L(C.__datetimeFormatters)?C.__datetimeFormatters:new Map,A=L(C.__numberFormatters)?C.__numberFormatters:new Map,S=L(C.__meta)?C.__meta:{};ge++;const $={version:n,cid:ge,locale:r,fallbackLocale:o,messages:s,modifiers:f,pluralRules:g,missing:p,missingWarn:v,fallbackWarn:d,fallbackFormat:T,unresolving:F,postTranslation:y,processor:I,warnHtmlMessage:R,escapeParameter:O,messageCompiler:M,messageResolver:W,localeFallbacker:w,fallbackContext:P,onWarn:t,__meta:S};return $.datetimeFormats=i,$.numberFormats=u,$.__datetimeFormatters=D,$.__numberFormatters=A,$}const ve=e=>({[e]:_()});function de(e,t,a,n,r){const{missing:l,onWarn:o}=e;if(null!==l){const n=l(e,a,t,r);return h(n)?n:t}return t}function be(e,t,a){e.__localeChainCache=new Map,e.localeFallbacker(e,a,t)}function Ee(e,t){const a=t.indexOf(e);if(-1===a)return!1;for(let l=a+1;l"",ke=e=>E(e);function Le(e,...t){const{fallbackFormat:a,postTranslation:n,unresolving:r,messageCompiler:l,fallbackLocale:o,messages:i}=e,[c,u]=ye(...t),m=k(u.missingWarn)?u.missingWarn:e.missingWarn,f=k(u.fallbackWarn)?u.fallbackWarn:e.fallbackWarn,v=k(u.escapeParameter)?u.escapeParameter:e.escapeParameter,d=!!u.resolvedMessage,E=h(u.default)||k(u.default)?k(u.default)?l?c:()=>c:u.default:a?l?c:()=>c:"",T=a||""!==E,F=J(e,u);v&&function(e){b(e.list)?e.list=e.list.map((e=>h(e)?g(e):e)):L(e.named)&&Object.keys(e.named).forEach((t=>{h(e.named[t])&&(e.named[t]=g(e.named[t]))}))}(u);let[y,N,I]=d?[c,F,i[F]||_()]:Te(e,c,F,o,f,m),R=y,O=c;if(d||h(R)||W(R)||ke(R)||T&&(R=E,O=R),!(d||(h(R)||W(R)||ke(R))&&h(N)))return r?re:c;let M=!1;const w=ke(R)?R:Fe(e,c,N,R,O,(()=>{M=!0}));if(M)return R;const P=function(e,t,a,n){const{modifiers:r,pluralRules:l,messageResolver:o,fallbackLocale:i,fallbackWarn:c,missingWarn:u,fallbackContext:m}=e,f=n=>{let r=o(a,n);if(null==r&&m){const[,,e]=Te(m,n,t,i,c,u);r=o(e,n)}if(h(r)||W(r)){let a=!1;const l=Fe(e,n,t,r,n,(()=>{a=!0}));return a?he:l}return ke(r)?r:he},_={locale:t,modifiers:r,pluralRules:l,messages:f};e.processor&&(_.processor=e.processor);n.list&&(_.list=n.list);n.named&&(_.named=n.named);s(n.plural)&&(_.pluralIndex=n.plural);return _}(e,N,I,u),C=function(e,t,a){const n=t(a);return n}(0,w,B(P));let D=n?n(C,c):C;var A;return v&&h(D)&&(A=(A=(A=D).replace(/(\w+)\s*=\s*"([^"]*)"/g,((e,t,a)=>`${t}="${p(a)}"`))).replace(/(\w+)\s*=\s*'([^']*)'/g,((e,t,a)=>`${t}='${p(a)}'`)),/\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi.test(A)&&(A=A.replace(/(\s+)(on)(\w+\s*=)/gi,"$1on$3")),[/(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi,/(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi].forEach((e=>{A=A.replace(e,"$1javascript:")})),D=A),D}function Te(e,t,a,n,r,l){const{messages:o,onWarn:s,messageResolver:i,localeFallbacker:c}=e,u=c(e,n,a);let m,f=_(),g=null;for(let p=0;pn;return e.locale=a,e.key=t,e}const c=s(n,function(e,t,a,n,r,o){return{locale:t,key:a,warnHtmlMessage:r,onError:e=>{throw o&&o(e),e},onCacheKey:e=>l(t,a,e)}}(0,a,r,0,i,o));return c.locale=a,c.key=t,c.source=n,c}function ye(...e){const[t,a,n]=e,r=_();if(!(h(t)||s(t)||ke(t)||W(t)))throw Error(z.INVALID_ARGUMENT);const l=s(t)?String(t):(ke(t),t);return s(a)?r.plural=a:h(a)?r.default=a:N(a)&&!u(a)?r.named=a:b(a)&&(r.list=a),s(n)?r.plural=n:h(n)?r.default=n:N(n)&&m(r,n),[l,r]}function Ne(e,...t){const{datetimeFormats:a,unresolving:n,fallbackLocale:r,onWarn:l,localeFallbacker:o}=e,{__datetimeFormatters:s}=e,[i,c,f,_]=Re(...t);k(f.missingWarn)?f.missingWarn:e.missingWarn;k(f.fallbackWarn)?f.fallbackWarn:e.fallbackWarn;const g=!!f.part,p=J(e,f),v=o(e,r,p);if(!h(i)||""===i)return new Intl.DateTimeFormat(p,_).format(c);let d,b={},E=null;for(let u=0;u{Ie.includes(e)?c[e]=a[e]:l[e]=a[e]})),h(n)?l.locale=n:N(n)&&(c=n),N(r)&&(c=r),[l.key||"",o,l,c]}function Oe(e,t,a){const n=e;for(const r in a){const e=`${t}__${r}`;n.__datetimeFormatters.has(e)&&n.__datetimeFormatters.delete(e)}}function Me(e,...t){const{numberFormats:a,unresolving:n,fallbackLocale:r,onWarn:l,localeFallbacker:o}=e,{__numberFormatters:s}=e,[i,c,f,_]=we(...t);k(f.missingWarn)?f.missingWarn:e.missingWarn;k(f.fallbackWarn)?f.fallbackWarn:e.fallbackWarn;const g=!!f.part,p=J(e,f),v=o(e,r,p);if(!h(i)||""===i)return new Intl.NumberFormat(p,_).format(c);let d,b={},E=null;for(let u=0;u{We.includes(e)?o[e]=a[e]:l[e]=a[e]})),h(n)?l.locale=n:N(n)&&(o=n),N(r)&&(o=r),[l.key||"",i,l,o]}function Pe(e,t,a){const n=e;for(const r in a){const e=`${t}__${r}`;n.__numberFormatters.has(e)&&n.__numberFormatters.delete(e)}}const Ce="9.14.5",De=z.__EXTEND_POINT__,Ae=I(De),Se={UNEXPECTED_RETURN_TYPE:De,INVALID_ARGUMENT:Ae(),MUST_BE_CALL_SETUP_TOP:Ae(),NOT_INSTALLED:Ae(),NOT_AVAILABLE_IN_LEGACY_MODE:Ae(),REQUIRED_VALUE:Ae(),INVALID_VALUE:Ae(),CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN:Ae(),NOT_INSTALLED_WITH_PROVIDE:Ae(),UNEXPECTED_ERROR:Ae(),NOT_COMPATIBLE_LEGACY_VUE_I18N:Ae(),BRIDGE_SUPPORT_VUE_2_ONLY:Ae(),MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION:Ae(),NOT_AVAILABLE_COMPOSITION_IN_LEGACY:Ae(),__EXTEND_POINT__:Ae()};const $e=r("__translateVNode"),Ue=r("__datetimeParts"),xe=r("__numberParts"),He=r("__setPluralRules"),je=r("__injectWithOption"),Ve=r("__dispose");function Ge(e){if(!L(e))return e;if(W(e))return e;for(const t in e)if(d(e,t))if(t.includes(".")){const a=t.split("."),n=a.length-1;let r=e,l=!1;for(let e=0;e{if("locale"in e&&"resource"in e){const{locale:t,resource:a}=e;t?(o[t]=o[t]||_(),O(a,o[t])):O(a,o)}else h(e)&&O(JSON.parse(e),o)})),null==r&&l)for(const s in o)d(o,s)&&Ge(o[s]);return o}function Be(e){return e.type}function Xe(e,t,a){let n=L(t.messages)?t.messages:_();"__i18nGlobal"in a&&(n=Ye(e.locale.value,{messages:n,__i18n:a.__i18nGlobal}));const r=Object.keys(n);if(r.length&&r.forEach((t=>{e.mergeLocaleMessage(t,n[t])})),L(t.datetimeFormats)){const a=Object.keys(t.datetimeFormats);a.length&&a.forEach((a=>{e.mergeDateTimeFormat(a,t.datetimeFormats[a])}))}if(L(t.numberFormats)){const a=Object.keys(t.numberFormats);a.length&&a.forEach((a=>{e.mergeNumberFormat(a,t.numberFormats[a])}))}}function ze(e){return t.createVNode(t.Text,null,e,0)}const Je=()=>[],qe=()=>!1;let Ze=0;function Ke(e){return(a,n,r,l)=>e(n,r,t.getCurrentInstance()||void 0,l)}function Qe(e={},a){const{__root:r,__injectWithOption:l}=e,o=void 0===r,i=e.flatJson,u=n?t.ref:t.shallowRef,f=!!e.translateExistCompatible;let _=!k(e.inheritLocale)||e.inheritLocale;const g=u(r&&_?r.locale.value:h(e.locale)?e.locale:le),p=u(r&&_?r.fallbackLocale.value:h(e.fallbackLocale)||b(e.fallbackLocale)||N(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:g.value),v=u(Ye(g.value,e)),T=u(N(e.datetimeFormats)?e.datetimeFormats:{[g.value]:{}}),F=u(N(e.numberFormats)?e.numberFormats:{[g.value]:{}});let y=r?r.missingWarn:!k(e.missingWarn)&&!c(e.missingWarn)||e.missingWarn,I=r?r.fallbackWarn:!k(e.fallbackWarn)&&!c(e.fallbackWarn)||e.fallbackWarn,R=r?r.fallbackRoot:!k(e.fallbackRoot)||e.fallbackRoot,M=!!e.fallbackFormat,w=E(e.missing)?e.missing:null,P=E(e.missing)?Ke(e.missing):null,C=E(e.postTranslation)?e.postTranslation:null,D=r?r.warnHtmlMessage:!k(e.warnHtmlMessage)||e.warnHtmlMessage,A=!!e.escapeParameter;const S=r?r.modifiers:N(e.modifiers)?e.modifiers:{};let $,U=e.pluralRules||r&&r.pluralRules;$=(()=>{o&&fe(null);const t={version:Ce,locale:g.value,fallbackLocale:p.value,messages:v.value,modifiers:S,pluralRules:U,missing:null===P?void 0:P,missingWarn:y,fallbackWarn:I,fallbackFormat:M,unresolving:!0,postTranslation:null===C?void 0:C,warnHtmlMessage:D,escapeParameter:A,messageResolver:e.messageResolver,messageCompiler:e.messageCompiler,__meta:{framework:"vue"}};t.datetimeFormats=T.value,t.numberFormats=F.value,t.__datetimeFormatters=N($)?$.__datetimeFormatters:void 0,t.__numberFormatters=N($)?$.__numberFormatters:void 0;const a=pe(t);return o&&fe(a),a})(),be($,g.value,p.value);const x=t.computed({get:()=>g.value,set:e=>{g.value=e,$.locale=g.value}}),H=t.computed({get:()=>p.value,set:e=>{p.value=e,$.fallbackLocale=p.value,be($,g.value,e)}}),j=t.computed((()=>v.value)),V=t.computed((()=>T.value)),G=t.computed((()=>F.value));const Y=(e,t,a,n,l,i)=>{let c;g.value,p.value,v.value,T.value,F.value;try{0,o||($.fallbackContext=r?_e():void 0),c=e($)}finally{o||($.fallbackContext=void 0)}if("translate exists"!==a&&s(c)&&c===re||"translate exists"===a&&!c){const[e,a]=t();return r&&R?n(r):l(e)}if(i(c))return c;throw Error(Se.UNEXPECTED_RETURN_TYPE)};function B(...e){return Y((t=>Reflect.apply(Le,null,[t,...e])),(()=>ye(...e)),"translate",(t=>Reflect.apply(t.t,t,[...e])),(e=>e),(e=>h(e)))}const X={normalize:function(e){return e.map((e=>h(e)||s(e)||k(e)?ze(String(e)):e))},interpolate:e=>e,type:"vnode"};function z(e){return v.value[e]||{}}Ze++,r&&n&&(t.watch(r.locale,(e=>{_&&(g.value=e,$.locale=e,be($,g.value,p.value))})),t.watch(r.fallbackLocale,(e=>{_&&(p.value=e,$.fallbackLocale=e,be($,g.value,p.value))})));const J={id:Ze,locale:x,fallbackLocale:H,get inheritLocale(){return _},set inheritLocale(e){_=e,e&&r&&(g.value=r.locale.value,p.value=r.fallbackLocale.value,be($,g.value,p.value))},get availableLocales(){return Object.keys(v.value).sort()},messages:j,get modifiers(){return S},get pluralRules(){return U||{}},get isGlobal(){return o},get missingWarn(){return y},set missingWarn(e){y=e,$.missingWarn=y},get fallbackWarn(){return I},set fallbackWarn(e){I=e,$.fallbackWarn=I},get fallbackRoot(){return R},set fallbackRoot(e){R=e},get fallbackFormat(){return M},set fallbackFormat(e){M=e,$.fallbackFormat=M},get warnHtmlMessage(){return D},set warnHtmlMessage(e){D=e,$.warnHtmlMessage=e},get escapeParameter(){return A},set escapeParameter(e){A=e,$.escapeParameter=e},t:B,getLocaleMessage:z,setLocaleMessage:function(e,t){if(i){const a={[e]:t};for(const e in a)d(a,e)&&Ge(a[e]);t=a[e]}v.value[e]=t,$.messages=v.value},mergeLocaleMessage:function(e,t){v.value[e]=v.value[e]||{};const a={[e]:t};if(i)for(const n in a)d(a,n)&&Ge(a[n]);O(t=a[e],v.value[e]),$.messages=v.value},getPostTranslationHandler:function(){return E(C)?C:null},setPostTranslationHandler:function(e){C=e,$.postTranslation=e},getMissingHandler:function(){return w},setMissingHandler:function(e){null!==e&&(P=Ke(e)),w=e,$.missing=P},[He]:function(e){U=e,$.pluralRules=U}};return J.datetimeFormats=V,J.numberFormats=G,J.rt=function(...e){const[t,a,n]=e;if(n&&!L(n))throw Error(Se.INVALID_ARGUMENT);return B(t,a,m({resolvedMessage:!0},n||{}))},J.te=function(e,t){return Y((()=>{if(!e)return!1;const a=z(h(t)?t:g.value),n=$.messageResolver(a,e);return f?null!=n:W(n)||ke(n)||h(n)}),(()=>[e]),"translate exists",(a=>Reflect.apply(a.te,a,[e,t])),qe,(e=>k(e)))},J.tm=function(e){const t=function(e){let t=null;const a=Q($,p.value,g.value);for(let n=0;nReflect.apply(Ne,null,[t,...e])),(()=>Re(...e)),"datetime format",(t=>Reflect.apply(t.d,t,[...e])),(()=>oe),(e=>h(e)))},J.n=function(...e){return Y((t=>Reflect.apply(Me,null,[t,...e])),(()=>we(...e)),"number format",(t=>Reflect.apply(t.n,t,[...e])),(()=>oe),(e=>h(e)))},J.getDateTimeFormat=function(e){return T.value[e]||{}},J.setDateTimeFormat=function(e,t){T.value[e]=t,$.datetimeFormats=T.value,Oe($,e,t)},J.mergeDateTimeFormat=function(e,t){T.value[e]=m(T.value[e]||{},t),$.datetimeFormats=T.value,Oe($,e,t)},J.getNumberFormat=function(e){return F.value[e]||{}},J.setNumberFormat=function(e,t){F.value[e]=t,$.numberFormats=F.value,Pe($,e,t)},J.mergeNumberFormat=function(e,t){F.value[e]=m(F.value[e]||{},t),$.numberFormats=F.value,Pe($,e,t)},J[je]=l,J[$e]=function(...e){return Y((t=>{let a;const n=t;try{n.processor=X,a=Reflect.apply(Le,null,[n,...e])}finally{n.processor=null}return a}),(()=>ye(...e)),"translate",(t=>t[$e](...e)),(e=>[ze(e)]),(e=>b(e)))},J[Ue]=function(...e){return Y((t=>Reflect.apply(Ne,null,[t,...e])),(()=>Re(...e)),"datetime format",(t=>t[Ue](...e)),Je,(e=>h(e)||b(e)))},J[xe]=function(...e){return Y((t=>Reflect.apply(Me,null,[t,...e])),(()=>we(...e)),"number format",(t=>t[xe](...e)),Je,(e=>h(e)||b(e)))},J}function et(e={},t){{const t=Qe(function(e){const t=h(e.locale)?e.locale:le,a=h(e.fallbackLocale)||b(e.fallbackLocale)||N(e.fallbackLocale)||!1===e.fallbackLocale?e.fallbackLocale:t,n=E(e.missing)?e.missing:void 0,r=!k(e.silentTranslationWarn)&&!c(e.silentTranslationWarn)||!e.silentTranslationWarn,l=!k(e.silentFallbackWarn)&&!c(e.silentFallbackWarn)||!e.silentFallbackWarn,o=!k(e.fallbackRoot)||e.fallbackRoot,s=!!e.formatFallbackMessages,i=N(e.modifiers)?e.modifiers:{},u=e.pluralizationRules,f=E(e.postTranslation)?e.postTranslation:void 0,_=!h(e.warnHtmlInMessage)||"off"!==e.warnHtmlInMessage,g=!!e.escapeParameterHtml,p=!k(e.sync)||e.sync;let v=e.messages;if(N(e.sharedMessages)){const t=e.sharedMessages;v=Object.keys(t).reduce(((e,a)=>{const n=e[a]||(e[a]={});return m(n,t[a]),e}),v||{})}const{__i18n:d,__root:L,__injectWithOption:T}=e,F=e.datetimeFormats,y=e.numberFormats,I=e.flatJson,R=e.translateExistCompatible;return{locale:t,fallbackLocale:a,messages:v,flatJson:I,datetimeFormats:F,numberFormats:y,missing:n,missingWarn:r,fallbackWarn:l,fallbackRoot:o,fallbackFormat:s,modifiers:i,pluralRules:u,postTranslation:f,warnHtmlMessage:_,escapeParameter:g,messageResolver:e.messageResolver,inheritLocale:p,translateExistCompatible:R,__i18n:d,__root:L,__injectWithOption:T}}(e)),{__extender:a}=e,n={id:t.id,get locale(){return t.locale.value},set locale(e){t.locale.value=e},get fallbackLocale(){return t.fallbackLocale.value},set fallbackLocale(e){t.fallbackLocale.value=e},get messages(){return t.messages.value},get datetimeFormats(){return t.datetimeFormats.value},get numberFormats(){return t.numberFormats.value},get availableLocales(){return t.availableLocales},get formatter(){return{interpolate:()=>[]}},set formatter(e){},get missing(){return t.getMissingHandler()},set missing(e){t.setMissingHandler(e)},get silentTranslationWarn(){return k(t.missingWarn)?!t.missingWarn:t.missingWarn},set silentTranslationWarn(e){t.missingWarn=k(e)?!e:e},get silentFallbackWarn(){return k(t.fallbackWarn)?!t.fallbackWarn:t.fallbackWarn},set silentFallbackWarn(e){t.fallbackWarn=k(e)?!e:e},get modifiers(){return t.modifiers},get formatFallbackMessages(){return t.fallbackFormat},set formatFallbackMessages(e){t.fallbackFormat=e},get postTranslation(){return t.getPostTranslationHandler()},set postTranslation(e){t.setPostTranslationHandler(e)},get sync(){return t.inheritLocale},set sync(e){t.inheritLocale=e},get warnHtmlInMessage(){return t.warnHtmlMessage?"warn":"off"},set warnHtmlInMessage(e){t.warnHtmlMessage="off"!==e},get escapeParameterHtml(){return t.escapeParameter},set escapeParameterHtml(e){t.escapeParameter=e},get preserveDirectiveContent(){return!0},set preserveDirectiveContent(e){},get pluralizationRules(){return t.pluralRules||{}},__composer:t,t(...e){const[a,n,r]=e,l={};let o=null,s=null;if(!h(a))throw Error(Se.INVALID_ARGUMENT);const i=a;return h(n)?l.locale=n:b(n)?o=n:N(n)&&(s=n),b(r)?o=r:N(r)&&(s=r),Reflect.apply(t.t,t,[i,o||s||{},l])},rt:(...e)=>Reflect.apply(t.rt,t,[...e]),tc(...e){const[a,n,r]=e,l={plural:1};let o=null,i=null;if(!h(a))throw Error(Se.INVALID_ARGUMENT);const c=a;return h(n)?l.locale=n:s(n)?l.plural=n:b(n)?o=n:N(n)&&(i=n),h(r)?l.locale=r:b(r)?o=r:N(r)&&(i=r),Reflect.apply(t.t,t,[c,o||i||{},l])},te:(e,a)=>t.te(e,a),tm:e=>t.tm(e),getLocaleMessage:e=>t.getLocaleMessage(e),setLocaleMessage(e,a){t.setLocaleMessage(e,a)},mergeLocaleMessage(e,a){t.mergeLocaleMessage(e,a)},d:(...e)=>Reflect.apply(t.d,t,[...e]),getDateTimeFormat:e=>t.getDateTimeFormat(e),setDateTimeFormat(e,a){t.setDateTimeFormat(e,a)},mergeDateTimeFormat(e,a){t.mergeDateTimeFormat(e,a)},n:(...e)=>Reflect.apply(t.n,t,[...e]),getNumberFormat:e=>t.getNumberFormat(e),setNumberFormat(e,a){t.setNumberFormat(e,a)},mergeNumberFormat(e,a){t.mergeNumberFormat(e,a)},getChoiceIndex:(e,t)=>-1};return n.__extender=a,n}}const tt={tag:{type:[String,Object]},locale:{type:String},scope:{type:String,validator:e=>"parent"===e||"global"===e,default:"parent"},i18n:{type:Object}};function at(e){return t.Fragment}const nt=t.defineComponent({name:"i18n-t",props:m({keypath:{type:String,required:!0},plural:{type:[Number,String],validator:e=>s(e)||!isNaN(e)}},tt),setup(e,a){const{slots:n,attrs:r}=a,l=e.i18n||pt({useScope:e.scope,__useComponent:!0});return()=>{const o=Object.keys(n).filter((e=>"_"!==e)),s=_();e.locale&&(s.locale=e.locale),void 0!==e.plural&&(s.plural=h(e.plural)?+e.plural:e.plural);const i=function({slots:e},a){if(1===a.length&&"default"===a[0])return(e.default?e.default():[]).reduce(((e,a)=>[...e,...a.type===t.Fragment?a.children:[a]]),[]);return a.reduce(((t,a)=>{const n=e[a];return n&&(t[a]=n()),t}),_())}(a,o),c=l[$e](e.keypath,i,s),u=m(_(),r),f=h(e.tag)||L(e.tag)?e.tag:at();return t.h(f,u,c)}}}),rt=nt;function lt(e,a,n,r){const{slots:l,attrs:o}=a;return()=>{const a={part:!0};let s=_();e.locale&&(a.locale=e.locale),h(e.format)?a.key=e.format:L(e.format)&&(h(e.format.key)&&(a.key=e.format.key),s=Object.keys(e.format).reduce(((t,a)=>n.includes(a)?m(_(),t,{[a]:e.format[a]}):t),_()));const i=r(e.value,a,s);let c=[a.key];b(i)?c=i.map(((e,t)=>{const a=l[e.type],n=a?a({[e.type]:e.value,index:t,parts:i}):[e.value];var r;return b(r=n)&&!h(r[0])&&(n[0].key=`${e.type}-${t}`),n})):h(i)&&(c=[i]);const u=m(_(),o),f=h(e.tag)||L(e.tag)?e.tag:at();return t.h(f,u,c)}}const ot=t.defineComponent({name:"i18n-n",props:m({value:{type:Number,required:!0},format:{type:[String,Object]}},tt),setup(e,t){const a=e.i18n||pt({useScope:e.scope,__useComponent:!0});return lt(e,t,We,((...e)=>a[xe](...e)))}}),st=ot,it=t.defineComponent({name:"i18n-d",props:m({value:{type:[Number,Date],required:!0},format:{type:[String,Object]}},tt),setup(e,t){const a=e.i18n||pt({useScope:e.scope,__useComponent:!0});return lt(e,t,Ie,((...e)=>a[Ue](...e)))}}),ct=it;function ut(e){const a=t=>{const{instance:a,modifiers:n,value:r}=t;if(!a||!a.$)throw Error(Se.UNEXPECTED_ERROR);const l=function(e,t){const a=e;if("composition"===e.mode)return a.__getInstance(t)||e.global;{const n=a.__getInstance(t);return null!=n?n.__composer:e.global.__composer}}(e,a.$),o=mt(r);return[Reflect.apply(l.t,l,[...ft(o)]),l]};return{created:(r,l)=>{const[o,s]=a(l);n&&e.global===s&&(r.__i18nWatcher=t.watch(s.locale,(()=>{l.instance&&l.instance.$forceUpdate()}))),r.__composer=s,r.textContent=o},unmounted:e=>{n&&e.__i18nWatcher&&(e.__i18nWatcher(),e.__i18nWatcher=void 0,delete e.__i18nWatcher),e.__composer&&(e.__composer=void 0,delete e.__composer)},beforeUpdate:(e,{value:t})=>{if(e.__composer){const a=e.__composer,n=mt(t);e.textContent=Reflect.apply(a.t,a,[...ft(n)])}},getSSRProps:e=>{const[t]=a(e);return{textContent:t}}}}function mt(e){if(h(e))return{path:e};if(N(e)){if(!("path"in e))throw Error(Se.REQUIRED_VALUE,"path");return e}throw Error(Se.INVALID_VALUE)}function ft(e){const{path:t,locale:a,args:n,choice:r,plural:l}=e,o={},i=n||{};return h(a)&&(o.locale=a),s(r)&&(o.plural=r),s(l)&&(o.plural=l),[t,i,o]}function _t(e,t){e.locale=t.locale||e.locale,e.fallbackLocale=t.fallbackLocale||e.fallbackLocale,e.missing=t.missing||e.missing,e.silentTranslationWarn=t.silentTranslationWarn||e.silentFallbackWarn,e.silentFallbackWarn=t.silentFallbackWarn||e.silentFallbackWarn,e.formatFallbackMessages=t.formatFallbackMessages||e.formatFallbackMessages,e.postTranslation=t.postTranslation||e.postTranslation,e.warnHtmlInMessage=t.warnHtmlInMessage||e.warnHtmlInMessage,e.escapeParameterHtml=t.escapeParameterHtml||e.escapeParameterHtml,e.sync=t.sync||e.sync,e.__composer[He](t.pluralizationRules||e.pluralizationRules);const a=Ye(e.locale,{messages:t.messages,__i18n:t.__i18n});return Object.keys(a).forEach((t=>e.mergeLocaleMessage(t,a[t]))),t.datetimeFormats&&Object.keys(t.datetimeFormats).forEach((a=>e.mergeDateTimeFormat(a,t.datetimeFormats[a]))),t.numberFormats&&Object.keys(t.numberFormats).forEach((a=>e.mergeNumberFormat(a,t.numberFormats[a]))),e}const gt=r("global-vue-i18n");function pt(e={}){const a=t.getCurrentInstance();if(null==a)throw Error(Se.MUST_BE_CALL_SETUP_TOP);if(!a.isCE&&null!=a.appContext.app&&!a.appContext.app.__VUE_I18N_SYMBOL__)throw Error(Se.NOT_INSTALLED);const n=function(e){{const a=t.inject(e.isCE?gt:e.appContext.app.__VUE_I18N_SYMBOL__);if(!a)throw function(e,...t){return M(e,null,void 0)}(e.isCE?Se.NOT_INSTALLED_WITH_PROVIDE:Se.UNEXPECTED_ERROR);return a}}(a),r=function(e){return"composition"===e.mode?e.global:e.global.__composer}(n),l=Be(a),o=function(e,t){return u(e)?"__i18n"in t?"local":"global":e.useScope?e.useScope:"local"}(e,l);if("legacy"===n.mode&&!e.__useComponent){if(!n.allowComposition)throw Error(Se.NOT_AVAILABLE_IN_LEGACY_MODE);return function(e,a,n,r={}){const l="local"===a,o=t.shallowRef(null);if(l&&e.proxy&&!e.proxy.$options.i18n&&!e.proxy.$options.__i18n)throw Error(Se.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION);const s=k(r.inheritLocale)?r.inheritLocale:!h(r.locale),i=t.ref(!l||s?n.locale.value:h(r.locale)?r.locale:le),u=t.ref(!l||s?n.fallbackLocale.value:h(r.fallbackLocale)||b(r.fallbackLocale)||N(r.fallbackLocale)||!1===r.fallbackLocale?r.fallbackLocale:i.value),m=t.ref(Ye(i.value,r)),f=t.ref(N(r.datetimeFormats)?r.datetimeFormats:{[i.value]:{}}),_=t.ref(N(r.numberFormats)?r.numberFormats:{[i.value]:{}}),g=l?n.missingWarn:!k(r.missingWarn)&&!c(r.missingWarn)||r.missingWarn,p=l?n.fallbackWarn:!k(r.fallbackWarn)&&!c(r.fallbackWarn)||r.fallbackWarn,v=l?n.fallbackRoot:!k(r.fallbackRoot)||r.fallbackRoot,d=!!r.fallbackFormat,L=E(r.missing)?r.missing:null,T=E(r.postTranslation)?r.postTranslation:null,F=l?n.warnHtmlMessage:!k(r.warnHtmlMessage)||r.warnHtmlMessage,y=!!r.escapeParameter,I=l?n.modifiers:N(r.modifiers)?r.modifiers:{},R=r.pluralRules||l&&n.pluralRules;function O(){return[i.value,u.value,m.value,f.value,_.value]}const M=t.computed({get:()=>o.value?o.value.locale.value:i.value,set:e=>{o.value&&(o.value.locale.value=e),i.value=e}}),W=t.computed({get:()=>o.value?o.value.fallbackLocale.value:u.value,set:e=>{o.value&&(o.value.fallbackLocale.value=e),u.value=e}}),w=t.computed((()=>o.value?o.value.messages.value:m.value)),P=t.computed((()=>f.value)),C=t.computed((()=>_.value));function D(){return o.value?o.value.getPostTranslationHandler():T}function A(e){o.value&&o.value.setPostTranslationHandler(e)}function S(){return o.value?o.value.getMissingHandler():L}function $(e){o.value&&o.value.setMissingHandler(e)}function U(e){return O(),e()}function x(...e){return o.value?U((()=>Reflect.apply(o.value.t,null,[...e]))):U((()=>""))}function H(...e){return o.value?Reflect.apply(o.value.rt,null,[...e]):""}function j(...e){return o.value?U((()=>Reflect.apply(o.value.d,null,[...e]))):U((()=>""))}function V(...e){return o.value?U((()=>Reflect.apply(o.value.n,null,[...e]))):U((()=>""))}function G(e){return o.value?o.value.tm(e):{}}function Y(e,t){return!!o.value&&o.value.te(e,t)}function B(e){return o.value?o.value.getLocaleMessage(e):{}}function X(e,t){o.value&&(o.value.setLocaleMessage(e,t),m.value[e]=t)}function z(e,t){o.value&&o.value.mergeLocaleMessage(e,t)}function J(e){return o.value?o.value.getDateTimeFormat(e):{}}function q(e,t){o.value&&(o.value.setDateTimeFormat(e,t),f.value[e]=t)}function Z(e,t){o.value&&o.value.mergeDateTimeFormat(e,t)}function K(e){return o.value?o.value.getNumberFormat(e):{}}function Q(e,t){o.value&&(o.value.setNumberFormat(e,t),_.value[e]=t)}function ee(e,t){o.value&&o.value.mergeNumberFormat(e,t)}const te={get id(){return o.value?o.value.id:-1},locale:M,fallbackLocale:W,messages:w,datetimeFormats:P,numberFormats:C,get inheritLocale(){return o.value?o.value.inheritLocale:s},set inheritLocale(e){o.value&&(o.value.inheritLocale=e)},get availableLocales(){return o.value?o.value.availableLocales:Object.keys(m.value)},get modifiers(){return o.value?o.value.modifiers:I},get pluralRules(){return o.value?o.value.pluralRules:R},get isGlobal(){return!!o.value&&o.value.isGlobal},get missingWarn(){return o.value?o.value.missingWarn:g},set missingWarn(e){o.value&&(o.value.missingWarn=e)},get fallbackWarn(){return o.value?o.value.fallbackWarn:p},set fallbackWarn(e){o.value&&(o.value.missingWarn=e)},get fallbackRoot(){return o.value?o.value.fallbackRoot:v},set fallbackRoot(e){o.value&&(o.value.fallbackRoot=e)},get fallbackFormat(){return o.value?o.value.fallbackFormat:d},set fallbackFormat(e){o.value&&(o.value.fallbackFormat=e)},get warnHtmlMessage(){return o.value?o.value.warnHtmlMessage:F},set warnHtmlMessage(e){o.value&&(o.value.warnHtmlMessage=e)},get escapeParameter(){return o.value?o.value.escapeParameter:y},set escapeParameter(e){o.value&&(o.value.escapeParameter=e)},t:x,getPostTranslationHandler:D,setPostTranslationHandler:A,getMissingHandler:S,setMissingHandler:$,rt:H,d:j,n:V,tm:G,te:Y,getLocaleMessage:B,setLocaleMessage:X,mergeLocaleMessage:z,getDateTimeFormat:J,setDateTimeFormat:q,mergeDateTimeFormat:Z,getNumberFormat:K,setNumberFormat:Q,mergeNumberFormat:ee};function ae(e){e.locale.value=i.value,e.fallbackLocale.value=u.value,Object.keys(m.value).forEach((t=>{e.mergeLocaleMessage(t,m.value[t])})),Object.keys(f.value).forEach((t=>{e.mergeDateTimeFormat(t,f.value[t])})),Object.keys(_.value).forEach((t=>{e.mergeNumberFormat(t,_.value[t])})),e.escapeParameter=y,e.fallbackFormat=d,e.fallbackRoot=v,e.fallbackWarn=p,e.missingWarn=g,e.warnHtmlMessage=F}return t.onBeforeMount((()=>{if(null==e.proxy||null==e.proxy.$i18n)throw Error(Se.NOT_AVAILABLE_COMPOSITION_IN_LEGACY);const t=o.value=e.proxy.$i18n.__composer;"global"===a?(i.value=t.locale.value,u.value=t.fallbackLocale.value,m.value=t.messages.value,f.value=t.datetimeFormats.value,_.value=t.numberFormats.value):l&&ae(t)})),te}(a,o,r,e)}if("global"===o)return Xe(r,e,l),r;if("parent"===o){let t=function(e,t,a=!1){let n=null;const r=t.root;let l=function(e,t=!1){if(null==e)return null;return t&&e.vnode.ctx||e.parent}(t,a);for(;null!=l;){const t=e;if("composition"===e.mode)n=t.__getInstance(l);else{const e=t.__getInstance(l);null!=e&&(n=e.__composer,a&&n&&!n[je]&&(n=null))}if(null!=n)break;if(r===l)break;l=l.parent}return n}(n,a,e.__useComponent);return null==t&&(t=r),t}const s=n;let i=s.__getInstance(a);if(null==i){const n=m({},e);"__i18n"in l&&(n.__i18n=l.__i18n),r&&(n.__root=r),i=Qe(n),s.__composerExtend&&(i[Ve]=s.__composerExtend(i)),function(e,a,n){t.onMounted((()=>{}),a),t.onUnmounted((()=>{const t=n;e.__deleteInstance(a);const r=t[Ve];r&&(r(),delete t[Ve])}),a)}(s,a,i),s.__setInstance(a,i)}return i}const vt=["locale","fallbackLocale","availableLocales"],dt=["t","rt","d","n","tm","te"];return ce=function(e,t){if(!L(e))return null;let a=$.get(t);if(a||(a=function(e){const t=[];let a,n,r,l,o,s,i,c=-1,u=0,m=0;const f=[];function _(){const t=e[c+1];if(5===u&&"'"===t||6===u&&'"'===t)return c++,r="\\"+t,f[0](),!0}for(f[0]=()=>{void 0===n?n=r:n+=r},f[1]=()=>{void 0!==n&&(t.push(n),n=void 0)},f[2]=()=>{f[0](),m++},f[3]=()=>{if(m>0)m--,u=4,f[0]();else{if(m=0,void 0===n)return!1;if(n=S(n),!1===n)return!1;f[1]()}};null!==u;)if(c++,a=e[c],"\\"!==a||!_()){if(l=A(a),i=C[u],o=i[l]||i.l||8,8===o)return;if(u=o[0],void 0!==o[1]&&(s=f[o[1]],s&&(r=a,!1===s())))return;if(7===u)return t}}(t),a&&$.set(t,a)),!a)return null;const n=a.length;let r=e,l=0;for(;l{if(!("__VUE_I18N_BRIDGE__"in e))throw Error(Se.NOT_COMPATIBLE_LEGACY_VUE_I18N);return e},e.createI18n=function(e={},a){const n=!k(e.legacy)||e.legacy,l=!k(e.globalInjection)||e.globalInjection,o=!n||!!e.allowComposition,s=new Map,[i,c]=function(e,a,n){const r=t.effectScope();{const t=a?r.run((()=>et(e))):r.run((()=>Qe(e)));if(null==t)throw Error(Se.UNEXPECTED_ERROR);return[r,t]}}(e,n),u=r("");{const e={get mode(){return n?"legacy":"composition"},get allowComposition(){return o},async install(a,...r){if(a.__VUE_I18N_SYMBOL__=u,a.provide(a.__VUE_I18N_SYMBOL__,e),N(r[0])){const t=r[0];e.__composerExtend=t.__composerExtend,e.__vueI18nExtend=t.__vueI18nExtend}let o=null;!n&&l&&(o=function(e,a){const n=Object.create(null);vt.forEach((e=>{const r=Object.getOwnPropertyDescriptor(a,e);if(!r)throw Error(Se.UNEXPECTED_ERROR);const l=t.isRef(r.value)?{get:()=>r.value.value,set(e){r.value.value=e}}:{get:()=>r.get&&r.get()};Object.defineProperty(n,e,l)})),e.config.globalProperties.$i18n=n,dt.forEach((t=>{const n=Object.getOwnPropertyDescriptor(a,t);if(!n||!n.value)throw Error(Se.UNEXPECTED_ERROR);Object.defineProperty(e.config.globalProperties,`$${t}`,n)}));const r=()=>{delete e.config.globalProperties.$i18n,dt.forEach((t=>{delete e.config.globalProperties[`$${t}`]}))};return r}(a,e.global)),function(e,t,...a){const n=N(a[0])?a[0]:{},r=!!n.useI18nComponentName;(!k(n.globalInstall)||n.globalInstall)&&([r?"i18n":nt.name,"I18nT"].forEach((t=>e.component(t,nt))),[ot.name,"I18nN"].forEach((t=>e.component(t,ot))),[it.name,"I18nD"].forEach((t=>e.component(t,it)))),e.directive("t",ut(t))}(a,e,...r),n&&a.mixin(function(e,a,n){return{beforeCreate(){const r=t.getCurrentInstance();if(!r)throw Error(Se.UNEXPECTED_ERROR);const l=this.$options;if(l.i18n){const t=l.i18n;if(l.__i18n&&(t.__i18n=l.__i18n),t.__root=a,this===this.$root)this.$i18n=_t(e,t);else{t.__injectWithOption=!0,t.__extender=n.__vueI18nExtend,this.$i18n=et(t);const e=this.$i18n;e.__extender&&(e.__disposer=e.__extender(this.$i18n))}}else if(l.__i18n)if(this===this.$root)this.$i18n=_t(e,l);else{this.$i18n=et({__i18n:l.__i18n,__injectWithOption:!0,__extender:n.__vueI18nExtend,__root:a});const e=this.$i18n;e.__extender&&(e.__disposer=e.__extender(this.$i18n))}else this.$i18n=e;l.__i18nGlobal&&Xe(a,l,l),this.$t=(...e)=>this.$i18n.t(...e),this.$rt=(...e)=>this.$i18n.rt(...e),this.$tc=(...e)=>this.$i18n.tc(...e),this.$te=(e,t)=>this.$i18n.te(e,t),this.$d=(...e)=>this.$i18n.d(...e),this.$n=(...e)=>this.$i18n.n(...e),this.$tm=e=>this.$i18n.tm(e),n.__setInstance(r,this.$i18n)},mounted(){},unmounted(){const e=t.getCurrentInstance();if(!e)throw Error(Se.UNEXPECTED_ERROR);const a=this.$i18n;delete this.$t,delete this.$rt,delete this.$tc,delete this.$te,delete this.$d,delete this.$n,delete this.$tm,a.__disposer&&(a.__disposer(),delete a.__disposer,delete a.__extender),n.__deleteInstance(e),delete this.$i18n}}}(c,c.__composer,e));const s=a.unmount;a.unmount=()=>{o&&o(),e.dispose(),s()}},get global(){return c},dispose(){i.stop()},__instances:s,__getInstance:function(e){return s.get(e)||null},__setInstance:function(e,t){s.set(e,t)},__deleteInstance:function(e){s.delete(e)}};return e}},e.useI18n=pt,e.vTDirective=ut,e}({},Vue); diff --git a/node_modules/vue-i18n/dist/vue-i18n.runtime.mjs b/node_modules/vue-i18n/dist/vue-i18n.runtime.mjs new file mode 100644 index 0000000..8e1c6ce --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.runtime.mjs @@ -0,0 +1,2979 @@ +/*! + * vue-i18n v9.14.5 + * (c) 2025 kazuya kawaguchi + * Released under the MIT License. + */ +import { getGlobalThis, incrementer, format, makeSymbol, isPlainObject, isArray, create, deepCopy, isString, hasOwn, isObject, warn, warnOnce, isBoolean, isRegExp, isFunction, inBrowser, assign, isNumber, createEmitter, isEmptyObject } from '@intlify/shared'; +import { CoreWarnCodes, CoreErrorCodes, createCompileError, isMessageAST, AST_NODE_PROPS_KEYS, DEFAULT_LOCALE, updateFallbackLocale, setFallbackContext, createCoreContext, clearDateTimeFormat, clearNumberFormat, setAdditionalMeta, getFallbackContext, NOT_REOSLVED, isTranslateFallbackWarn, isTranslateMissingWarn, parseTranslateArgs, translate, MISSING_RESOLVE_VALUE, parseDateTimeArgs, datetime, parseNumberArgs, number, isMessageFunction, fallbackWithLocaleChain, NUMBER_FORMAT_OPTIONS_KEYS, DATETIME_FORMAT_OPTIONS_KEYS, registerMessageCompiler, compile, registerMessageResolver, resolveValue, registerLocaleFallbacker, setDevToolsHook } from '@intlify/core-base'; +import { createVNode, Text, computed, watch, getCurrentInstance, ref, shallowRef, Fragment, defineComponent, h, effectScope, inject, onMounted, onUnmounted, onBeforeMount, isRef } from 'vue'; +import { setupDevtoolsPlugin } from '@vue/devtools-api'; + +/** + * Vue I18n Version + * + * @remarks + * Semver format. Same format as the package.json `version` field. + * + * @VueI18nGeneral + */ +const VERSION = '9.14.5'; +/** + * This is only called in esm-bundler builds. + * istanbul-ignore-next + */ +function initFeatureFlags() { + if (typeof __VUE_I18N_FULL_INSTALL__ !== 'boolean') { + getGlobalThis().__VUE_I18N_FULL_INSTALL__ = true; + } + if (typeof __VUE_I18N_LEGACY_API__ !== 'boolean') { + getGlobalThis().__VUE_I18N_LEGACY_API__ = true; + } + if (typeof __INTLIFY_JIT_COMPILATION__ !== 'boolean') { + getGlobalThis().__INTLIFY_JIT_COMPILATION__ = false; + } + if (typeof __INTLIFY_DROP_MESSAGE_COMPILER__ !== 'boolean') { + getGlobalThis().__INTLIFY_DROP_MESSAGE_COMPILER__ = false; + } + if (typeof __INTLIFY_PROD_DEVTOOLS__ !== 'boolean') { + getGlobalThis().__INTLIFY_PROD_DEVTOOLS__ = false; + } +} + +const code$1 = CoreWarnCodes.__EXTEND_POINT__; +const inc$1 = incrementer(code$1); +const I18nWarnCodes = { + FALLBACK_TO_ROOT: code$1, // 9 + NOT_SUPPORTED_PRESERVE: inc$1(), // 10 + NOT_SUPPORTED_FORMATTER: inc$1(), // 11 + NOT_SUPPORTED_PRESERVE_DIRECTIVE: inc$1(), // 12 + NOT_SUPPORTED_GET_CHOICE_INDEX: inc$1(), // 13 + COMPONENT_NAME_LEGACY_COMPATIBLE: inc$1(), // 14 + NOT_FOUND_PARENT_SCOPE: inc$1(), // 15 + IGNORE_OBJ_FLATTEN: inc$1(), // 16 + NOTICE_DROP_ALLOW_COMPOSITION: inc$1(), // 17 + NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG: inc$1() // 18 +}; +const warnMessages = { + [I18nWarnCodes.FALLBACK_TO_ROOT]: `Fall back to {type} '{key}' with root locale.`, + [I18nWarnCodes.NOT_SUPPORTED_PRESERVE]: `Not supported 'preserve'.`, + [I18nWarnCodes.NOT_SUPPORTED_FORMATTER]: `Not supported 'formatter'.`, + [I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE]: `Not supported 'preserveDirectiveContent'.`, + [I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX]: `Not supported 'getChoiceIndex'.`, + [I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE]: `Component name legacy compatible: '{name}' -> 'i18n'`, + [I18nWarnCodes.NOT_FOUND_PARENT_SCOPE]: `Not found parent scope. use the global scope.`, + [I18nWarnCodes.IGNORE_OBJ_FLATTEN]: `Ignore object flatten: '{key}' key has an string value`, + [I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION]: `'allowComposition' option will be dropped in the next major version. For more information, please see 👉 https://tinyurl.com/2p97mcze`, + [I18nWarnCodes.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG]: `'translateExistCompatible' option will be dropped in the next major version.` +}; +function getWarnMessage(code, ...args) { + return format(warnMessages[code], ...args); +} + +const code = CoreErrorCodes.__EXTEND_POINT__; +const inc = incrementer(code); +const I18nErrorCodes = { + // composer module errors + UNEXPECTED_RETURN_TYPE: code, // 24 + // legacy module errors + INVALID_ARGUMENT: inc(), // 25 + // i18n module errors + MUST_BE_CALL_SETUP_TOP: inc(), // 26 + NOT_INSTALLED: inc(), // 27 + NOT_AVAILABLE_IN_LEGACY_MODE: inc(), // 28 + // directive module errors + REQUIRED_VALUE: inc(), // 29 + INVALID_VALUE: inc(), // 30 + // vue-devtools errors + CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN: inc(), // 31 + NOT_INSTALLED_WITH_PROVIDE: inc(), // 32 + // unexpected error + UNEXPECTED_ERROR: inc(), // 33 + // not compatible legacy vue-i18n constructor + NOT_COMPATIBLE_LEGACY_VUE_I18N: inc(), // 34 + // bridge support vue 2.x only + BRIDGE_SUPPORT_VUE_2_ONLY: inc(), // 35 + // need to define `i18n` option in `allowComposition: true` and `useScope: 'local' at `useI18n`` + MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION: inc(), // 36 + // Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly + NOT_AVAILABLE_COMPOSITION_IN_LEGACY: inc(), // 37 + // for enhancement + __EXTEND_POINT__: inc() // 38 +}; +function createI18nError(code, ...args) { + return createCompileError(code, null, (process.env.NODE_ENV !== 'production') ? { messages: errorMessages, args } : undefined); +} +const errorMessages = { + [I18nErrorCodes.UNEXPECTED_RETURN_TYPE]: 'Unexpected return type in composer', + [I18nErrorCodes.INVALID_ARGUMENT]: 'Invalid argument', + [I18nErrorCodes.MUST_BE_CALL_SETUP_TOP]: 'Must be called at the top of a `setup` function', + [I18nErrorCodes.NOT_INSTALLED]: 'Need to install with `app.use` function', + [I18nErrorCodes.UNEXPECTED_ERROR]: 'Unexpected error', + [I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE]: 'Not available in legacy mode', + [I18nErrorCodes.REQUIRED_VALUE]: `Required in value: {0}`, + [I18nErrorCodes.INVALID_VALUE]: `Invalid value`, + [I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN]: `Cannot setup vue-devtools plugin`, + [I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE]: 'Need to install with `provide` function', + [I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N]: 'Not compatible legacy VueI18n.', + [I18nErrorCodes.BRIDGE_SUPPORT_VUE_2_ONLY]: 'vue-i18n-bridge support Vue 2.x only', + [I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION]: 'Must define ‘i18n’ option or custom block in Composition API with using local scope in Legacy API mode', + [I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY]: 'Not available Compostion API in Legacy API mode. Please make sure that the legacy API mode is working properly' +}; + +const TranslateVNodeSymbol = +/* #__PURE__*/ makeSymbol('__translateVNode'); +const DatetimePartsSymbol = /* #__PURE__*/ makeSymbol('__datetimeParts'); +const NumberPartsSymbol = /* #__PURE__*/ makeSymbol('__numberParts'); +const EnableEmitter = /* #__PURE__*/ makeSymbol('__enableEmitter'); +const DisableEmitter = /* #__PURE__*/ makeSymbol('__disableEmitter'); +const SetPluralRulesSymbol = makeSymbol('__setPluralRules'); +makeSymbol('__intlifyMeta'); +const InejctWithOptionSymbol = +/* #__PURE__*/ makeSymbol('__injectWithOption'); +const DisposeSymbol = /* #__PURE__*/ makeSymbol('__dispose'); +const __VUE_I18N_BRIDGE__ = '__VUE_I18N_BRIDGE__'; + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Transform flat json in obj to normal json in obj + */ +function handleFlatJson(obj) { + // check obj + if (!isObject(obj)) { + return obj; + } + if (isMessageAST(obj)) { + return obj; + } + for (const key in obj) { + // check key + if (!hasOwn(obj, key)) { + continue; + } + // handle for normal json + if (!key.includes('.')) { + // recursive process value if value is also a object + if (isObject(obj[key])) { + handleFlatJson(obj[key]); + } + } + // handle for flat json, transform to normal json + else { + // go to the last object + const subKeys = key.split('.'); + const lastIndex = subKeys.length - 1; + let currentObj = obj; + let hasStringValue = false; + for (let i = 0; i < lastIndex; i++) { + if (subKeys[i] === '__proto__') { + throw new Error(`unsafe key: ${subKeys[i]}`); + } + if (!(subKeys[i] in currentObj)) { + currentObj[subKeys[i]] = create(); + } + if (!isObject(currentObj[subKeys[i]])) { + (process.env.NODE_ENV !== 'production') && + warn(getWarnMessage(I18nWarnCodes.IGNORE_OBJ_FLATTEN, { + key: subKeys[i] + })); + hasStringValue = true; + break; + } + currentObj = currentObj[subKeys[i]]; + } + // update last object value, delete old property + if (!hasStringValue) { + if (!isMessageAST(currentObj)) { + currentObj[subKeys[lastIndex]] = obj[key]; + delete obj[key]; + } + else { + /** + * NOTE: + * if the last object is a message AST and subKeys[lastIndex] has message AST prop key, ignore to copy and key deletion + */ + if (!AST_NODE_PROPS_KEYS.includes(subKeys[lastIndex])) { + delete obj[key]; + } + } + } + // recursive process value if value is also a object + if (!isMessageAST(currentObj)) { + const target = currentObj[subKeys[lastIndex]]; + if (isObject(target)) { + handleFlatJson(target); + } + } + } + } + return obj; +} +function getLocaleMessages(locale, options) { + const { messages, __i18n, messageResolver, flatJson } = options; + // prettier-ignore + const ret = (isPlainObject(messages) + ? messages + : isArray(__i18n) + ? create() + : { [locale]: create() }); + // merge locale messages of i18n custom block + if (isArray(__i18n)) { + __i18n.forEach(custom => { + if ('locale' in custom && 'resource' in custom) { + const { locale, resource } = custom; + if (locale) { + ret[locale] = ret[locale] || create(); + deepCopy(resource, ret[locale]); + } + else { + deepCopy(resource, ret); + } + } + else { + isString(custom) && deepCopy(JSON.parse(custom), ret); + } + }); + } + // handle messages for flat json + if (messageResolver == null && flatJson) { + for (const key in ret) { + if (hasOwn(ret, key)) { + handleFlatJson(ret[key]); + } + } + } + return ret; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getComponentOptions(instance) { + return instance.type ; +} +function adjustI18nResources(gl, options, componentOptions // eslint-disable-line @typescript-eslint/no-explicit-any +) { + let messages = isObject(options.messages) + ? options.messages + : create(); + if ('__i18nGlobal' in componentOptions) { + messages = getLocaleMessages(gl.locale.value, { + messages, + __i18n: componentOptions.__i18nGlobal + }); + } + // merge locale messages + const locales = Object.keys(messages); + if (locales.length) { + locales.forEach(locale => { + gl.mergeLocaleMessage(locale, messages[locale]); + }); + } + { + // merge datetime formats + if (isObject(options.datetimeFormats)) { + const locales = Object.keys(options.datetimeFormats); + if (locales.length) { + locales.forEach(locale => { + gl.mergeDateTimeFormat(locale, options.datetimeFormats[locale]); + }); + } + } + // merge number formats + if (isObject(options.numberFormats)) { + const locales = Object.keys(options.numberFormats); + if (locales.length) { + locales.forEach(locale => { + gl.mergeNumberFormat(locale, options.numberFormats[locale]); + }); + } + } + } +} +function createTextNode(key) { + return createVNode(Text, null, key, 0) + ; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +/* eslint-disable @typescript-eslint/no-explicit-any */ +// extend VNode interface +const DEVTOOLS_META = '__INTLIFY_META__'; +const NOOP_RETURN_ARRAY = () => []; +const NOOP_RETURN_FALSE = () => false; +let composerID = 0; +function defineCoreMissingHandler(missing) { + return ((ctx, locale, key, type) => { + return missing(locale, key, getCurrentInstance() || undefined, type); + }); +} +// for Intlify DevTools +/* #__NO_SIDE_EFFECTS__ */ +const getMetaInfo = () => { + const instance = getCurrentInstance(); + let meta = null; // eslint-disable-line @typescript-eslint/no-explicit-any + return instance && (meta = getComponentOptions(instance)[DEVTOOLS_META]) + ? { [DEVTOOLS_META]: meta } // eslint-disable-line @typescript-eslint/no-explicit-any + : null; +}; +/** + * Create composer interface factory + * + * @internal + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function createComposer(options = {}, VueI18nLegacy) { + const { __root, __injectWithOption } = options; + const _isGlobal = __root === undefined; + const flatJson = options.flatJson; + const _ref = inBrowser ? ref : shallowRef; + const translateExistCompatible = !!options.translateExistCompatible; + if ((process.env.NODE_ENV !== 'production')) { + if (translateExistCompatible && !false) { + warnOnce(getWarnMessage(I18nWarnCodes.NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG)); + } + } + let _inheritLocale = isBoolean(options.inheritLocale) + ? options.inheritLocale + : true; + const _locale = _ref( + // prettier-ignore + __root && _inheritLocale + ? __root.locale.value + : isString(options.locale) + ? options.locale + : DEFAULT_LOCALE); + const _fallbackLocale = _ref( + // prettier-ignore + __root && _inheritLocale + ? __root.fallbackLocale.value + : isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale.value); + const _messages = _ref(getLocaleMessages(_locale.value, options)); + // prettier-ignore + const _datetimeFormats = _ref(isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : { [_locale.value]: {} }) + ; + // prettier-ignore + const _numberFormats = _ref(isPlainObject(options.numberFormats) + ? options.numberFormats + : { [_locale.value]: {} }) + ; + // warning suppress options + // prettier-ignore + let _missingWarn = __root + ? __root.missingWarn + : isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + // prettier-ignore + let _fallbackWarn = __root + ? __root.fallbackWarn + : isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + // prettier-ignore + let _fallbackRoot = __root + ? __root.fallbackRoot + : isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + // configure fall back to root + let _fallbackFormat = !!options.fallbackFormat; + // runtime missing + let _missing = isFunction(options.missing) ? options.missing : null; + let _runtimeMissing = isFunction(options.missing) + ? defineCoreMissingHandler(options.missing) + : null; + // postTranslation handler + let _postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + // prettier-ignore + let _warnHtmlMessage = __root + ? __root.warnHtmlMessage + : isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + let _escapeParameter = !!options.escapeParameter; + // custom linked modifiers + // prettier-ignore + const _modifiers = __root + ? __root.modifiers + : isPlainObject(options.modifiers) + ? options.modifiers + : {}; + // pluralRules + let _pluralRules = options.pluralRules || (__root && __root.pluralRules); + // runtime context + // eslint-disable-next-line prefer-const + let _context; + const getCoreContext = () => { + _isGlobal && setFallbackContext(null); + const ctxOptions = { + version: VERSION, + locale: _locale.value, + fallbackLocale: _fallbackLocale.value, + messages: _messages.value, + modifiers: _modifiers, + pluralRules: _pluralRules, + missing: _runtimeMissing === null ? undefined : _runtimeMissing, + missingWarn: _missingWarn, + fallbackWarn: _fallbackWarn, + fallbackFormat: _fallbackFormat, + unresolving: true, + postTranslation: _postTranslation === null ? undefined : _postTranslation, + warnHtmlMessage: _warnHtmlMessage, + escapeParameter: _escapeParameter, + messageResolver: options.messageResolver, + messageCompiler: options.messageCompiler, + __meta: { framework: 'vue' } + }; + { + ctxOptions.datetimeFormats = _datetimeFormats.value; + ctxOptions.numberFormats = _numberFormats.value; + ctxOptions.__datetimeFormatters = isPlainObject(_context) + ? _context.__datetimeFormatters + : undefined; + ctxOptions.__numberFormatters = isPlainObject(_context) + ? _context.__numberFormatters + : undefined; + } + if ((process.env.NODE_ENV !== 'production')) { + ctxOptions.__v_emitter = isPlainObject(_context) + ? _context.__v_emitter + : undefined; + } + const ctx = createCoreContext(ctxOptions); + _isGlobal && setFallbackContext(ctx); + return ctx; + }; + _context = getCoreContext(); + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + // track reactivity + function trackReactivityValues() { + return [ + _locale.value, + _fallbackLocale.value, + _messages.value, + _datetimeFormats.value, + _numberFormats.value + ] + ; + } + // locale + const locale = computed({ + get: () => _locale.value, + set: val => { + _locale.value = val; + _context.locale = _locale.value; + } + }); + // fallbackLocale + const fallbackLocale = computed({ + get: () => _fallbackLocale.value, + set: val => { + _fallbackLocale.value = val; + _context.fallbackLocale = _fallbackLocale.value; + updateFallbackLocale(_context, _locale.value, val); + } + }); + // messages + const messages = computed(() => _messages.value); + // datetimeFormats + const datetimeFormats = /* #__PURE__*/ computed(() => _datetimeFormats.value); + // numberFormats + const numberFormats = /* #__PURE__*/ computed(() => _numberFormats.value); + // getPostTranslationHandler + function getPostTranslationHandler() { + return isFunction(_postTranslation) ? _postTranslation : null; + } + // setPostTranslationHandler + function setPostTranslationHandler(handler) { + _postTranslation = handler; + _context.postTranslation = handler; + } + // getMissingHandler + function getMissingHandler() { + return _missing; + } + // setMissingHandler + function setMissingHandler(handler) { + if (handler !== null) { + _runtimeMissing = defineCoreMissingHandler(handler); + } + _missing = handler; + _context.missing = _runtimeMissing; + } + function isResolvedTranslateMessage(type, arg // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + return type !== 'translate' || !arg.resolvedMessage; + } + const wrapWithDeps = (fn, argumentParser, warnType, fallbackSuccess, fallbackFail, successCondition) => { + trackReactivityValues(); // track reactive dependency + // NOTE: experimental !! + let ret; + try { + if ((process.env.NODE_ENV !== 'production') || __INTLIFY_PROD_DEVTOOLS__) { + setAdditionalMeta(getMetaInfo()); + } + if (!_isGlobal) { + _context.fallbackContext = __root + ? getFallbackContext() + : undefined; + } + ret = fn(_context); + } + finally { + if ((process.env.NODE_ENV !== 'production') || __INTLIFY_PROD_DEVTOOLS__) { + setAdditionalMeta(null); + } + if (!_isGlobal) { + _context.fallbackContext = undefined; + } + } + if ((warnType !== 'translate exists' && // for not `te` (e.g `t`) + isNumber(ret) && + ret === NOT_REOSLVED) || + (warnType === 'translate exists' && !ret) // for `te` + ) { + const [key, arg2] = argumentParser(); + if ((process.env.NODE_ENV !== 'production') && + __root && + isString(key) && + isResolvedTranslateMessage(warnType, arg2)) { + if (_fallbackRoot && + (isTranslateFallbackWarn(_fallbackWarn, key) || + isTranslateMissingWarn(_missingWarn, key))) { + warn(getWarnMessage(I18nWarnCodes.FALLBACK_TO_ROOT, { + key, + type: warnType + })); + } + // for vue-devtools timeline event + if ((process.env.NODE_ENV !== 'production')) { + const { __v_emitter: emitter } = _context; + if (emitter && _fallbackRoot) { + emitter.emit("fallback" /* VueDevToolsTimelineEvents.FALBACK */, { + type: warnType, + key, + to: 'global', + groupId: `${warnType}:${key}` + }); + } + } + } + return __root && _fallbackRoot + ? fallbackSuccess(__root) + : fallbackFail(key); + } + else if (successCondition(ret)) { + return ret; + } + else { + /* istanbul ignore next */ + throw createI18nError(I18nErrorCodes.UNEXPECTED_RETURN_TYPE); + } + }; + // t + function t(...args) { + return wrapWithDeps(context => Reflect.apply(translate, null, [context, ...args]), () => parseTranslateArgs(...args), 'translate', root => Reflect.apply(root.t, root, [...args]), key => key, val => isString(val)); + } + // rt + function rt(...args) { + const [arg1, arg2, arg3] = args; + if (arg3 && !isObject(arg3)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + return t(...[arg1, arg2, assign({ resolvedMessage: true }, arg3 || {})]); + } + // d + function d(...args) { + return wrapWithDeps(context => Reflect.apply(datetime, null, [context, ...args]), () => parseDateTimeArgs(...args), 'datetime format', root => Reflect.apply(root.d, root, [...args]), () => MISSING_RESOLVE_VALUE, val => isString(val)); + } + // n + function n(...args) { + return wrapWithDeps(context => Reflect.apply(number, null, [context, ...args]), () => parseNumberArgs(...args), 'number format', root => Reflect.apply(root.n, root, [...args]), () => MISSING_RESOLVE_VALUE, val => isString(val)); + } + // for custom processor + function normalize(values) { + return values.map(val => isString(val) || isNumber(val) || isBoolean(val) + ? createTextNode(String(val)) + : val); + } + const interpolate = (val) => val; + const processor = { + normalize, + interpolate, + type: 'vnode' + }; + // translateVNode, using for `i18n-t` component + function translateVNode(...args) { + return wrapWithDeps(context => { + let ret; + const _context = context; + try { + _context.processor = processor; + ret = Reflect.apply(translate, null, [_context, ...args]); + } + finally { + _context.processor = null; + } + return ret; + }, () => parseTranslateArgs(...args), 'translate', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[TranslateVNodeSymbol](...args), key => [createTextNode(key)], val => isArray(val)); + } + // numberParts, using for `i18n-n` component + function numberParts(...args) { + return wrapWithDeps(context => Reflect.apply(number, null, [context, ...args]), () => parseNumberArgs(...args), 'number format', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[NumberPartsSymbol](...args), NOOP_RETURN_ARRAY, val => isString(val) || isArray(val)); + } + // datetimeParts, using for `i18n-d` component + function datetimeParts(...args) { + return wrapWithDeps(context => Reflect.apply(datetime, null, [context, ...args]), () => parseDateTimeArgs(...args), 'datetime format', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + root => root[DatetimePartsSymbol](...args), NOOP_RETURN_ARRAY, val => isString(val) || isArray(val)); + } + function setPluralRules(rules) { + _pluralRules = rules; + _context.pluralRules = _pluralRules; + } + // te + function te(key, locale) { + return wrapWithDeps(() => { + if (!key) { + return false; + } + const targetLocale = isString(locale) ? locale : _locale.value; + const message = getLocaleMessage(targetLocale); + const resolved = _context.messageResolver(message, key); + return !translateExistCompatible + ? isMessageAST(resolved) || + isMessageFunction(resolved) || + isString(resolved) + : resolved != null; + }, () => [key], 'translate exists', root => { + return Reflect.apply(root.te, root, [key, locale]); + }, NOOP_RETURN_FALSE, val => isBoolean(val)); + } + function resolveMessages(key) { + let messages = null; + const locales = fallbackWithLocaleChain(_context, _fallbackLocale.value, _locale.value); + for (let i = 0; i < locales.length; i++) { + const targetLocaleMessages = _messages.value[locales[i]] || {}; + const messageValue = _context.messageResolver(targetLocaleMessages, key); + if (messageValue != null) { + messages = messageValue; + break; + } + } + return messages; + } + // tm + function tm(key) { + const messages = resolveMessages(key); + // prettier-ignore + return messages != null + ? messages + : __root + ? __root.tm(key) || {} + : {}; + } + // getLocaleMessage + function getLocaleMessage(locale) { + return (_messages.value[locale] || {}); + } + // setLocaleMessage + function setLocaleMessage(locale, message) { + if (flatJson) { + const _message = { [locale]: message }; + for (const key in _message) { + if (hasOwn(_message, key)) { + handleFlatJson(_message[key]); + } + } + message = _message[locale]; + } + _messages.value[locale] = message; + _context.messages = _messages.value; + } + // mergeLocaleMessage + function mergeLocaleMessage(locale, message) { + _messages.value[locale] = _messages.value[locale] || {}; + const _message = { [locale]: message }; + if (flatJson) { + for (const key in _message) { + if (hasOwn(_message, key)) { + handleFlatJson(_message[key]); + } + } + } + message = _message[locale]; + deepCopy(message, _messages.value[locale]); + _context.messages = _messages.value; + } + // getDateTimeFormat + function getDateTimeFormat(locale) { + return _datetimeFormats.value[locale] || {}; + } + // setDateTimeFormat + function setDateTimeFormat(locale, format) { + _datetimeFormats.value[locale] = format; + _context.datetimeFormats = _datetimeFormats.value; + clearDateTimeFormat(_context, locale, format); + } + // mergeDateTimeFormat + function mergeDateTimeFormat(locale, format) { + _datetimeFormats.value[locale] = assign(_datetimeFormats.value[locale] || {}, format); + _context.datetimeFormats = _datetimeFormats.value; + clearDateTimeFormat(_context, locale, format); + } + // getNumberFormat + function getNumberFormat(locale) { + return _numberFormats.value[locale] || {}; + } + // setNumberFormat + function setNumberFormat(locale, format) { + _numberFormats.value[locale] = format; + _context.numberFormats = _numberFormats.value; + clearNumberFormat(_context, locale, format); + } + // mergeNumberFormat + function mergeNumberFormat(locale, format) { + _numberFormats.value[locale] = assign(_numberFormats.value[locale] || {}, format); + _context.numberFormats = _numberFormats.value; + clearNumberFormat(_context, locale, format); + } + // for debug + composerID++; + // watch root locale & fallbackLocale + if (__root && inBrowser) { + watch(__root.locale, (val) => { + if (_inheritLocale) { + _locale.value = val; + _context.locale = val; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }); + watch(__root.fallbackLocale, (val) => { + if (_inheritLocale) { + _fallbackLocale.value = val; + _context.fallbackLocale = val; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }); + } + // define basic composition API! + const composer = { + id: composerID, + locale, + fallbackLocale, + get inheritLocale() { + return _inheritLocale; + }, + set inheritLocale(val) { + _inheritLocale = val; + if (val && __root) { + _locale.value = __root.locale.value; + _fallbackLocale.value = __root.fallbackLocale.value; + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value); + } + }, + get availableLocales() { + return Object.keys(_messages.value).sort(); + }, + messages, + get modifiers() { + return _modifiers; + }, + get pluralRules() { + return _pluralRules || {}; + }, + get isGlobal() { + return _isGlobal; + }, + get missingWarn() { + return _missingWarn; + }, + set missingWarn(val) { + _missingWarn = val; + _context.missingWarn = _missingWarn; + }, + get fallbackWarn() { + return _fallbackWarn; + }, + set fallbackWarn(val) { + _fallbackWarn = val; + _context.fallbackWarn = _fallbackWarn; + }, + get fallbackRoot() { + return _fallbackRoot; + }, + set fallbackRoot(val) { + _fallbackRoot = val; + }, + get fallbackFormat() { + return _fallbackFormat; + }, + set fallbackFormat(val) { + _fallbackFormat = val; + _context.fallbackFormat = _fallbackFormat; + }, + get warnHtmlMessage() { + return _warnHtmlMessage; + }, + set warnHtmlMessage(val) { + _warnHtmlMessage = val; + _context.warnHtmlMessage = val; + }, + get escapeParameter() { + return _escapeParameter; + }, + set escapeParameter(val) { + _escapeParameter = val; + _context.escapeParameter = val; + }, + t, + getLocaleMessage, + setLocaleMessage, + mergeLocaleMessage, + getPostTranslationHandler, + setPostTranslationHandler, + getMissingHandler, + setMissingHandler, + [SetPluralRulesSymbol]: setPluralRules + }; + { + composer.datetimeFormats = datetimeFormats; + composer.numberFormats = numberFormats; + composer.rt = rt; + composer.te = te; + composer.tm = tm; + composer.d = d; + composer.n = n; + composer.getDateTimeFormat = getDateTimeFormat; + composer.setDateTimeFormat = setDateTimeFormat; + composer.mergeDateTimeFormat = mergeDateTimeFormat; + composer.getNumberFormat = getNumberFormat; + composer.setNumberFormat = setNumberFormat; + composer.mergeNumberFormat = mergeNumberFormat; + composer[InejctWithOptionSymbol] = __injectWithOption; + composer[TranslateVNodeSymbol] = translateVNode; + composer[DatetimePartsSymbol] = datetimeParts; + composer[NumberPartsSymbol] = numberParts; + } + // for vue-devtools timeline event + if ((process.env.NODE_ENV !== 'production')) { + composer[EnableEmitter] = (emitter) => { + _context.__v_emitter = emitter; + }; + composer[DisableEmitter] = () => { + _context.__v_emitter = undefined; + }; + } + return composer; +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Convert to I18n Composer Options from VueI18n Options + * + * @internal + */ +function convertComposerOptions(options) { + const locale = isString(options.locale) ? options.locale : DEFAULT_LOCALE; + const fallbackLocale = isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : locale; + const missing = isFunction(options.missing) ? options.missing : undefined; + const missingWarn = isBoolean(options.silentTranslationWarn) || + isRegExp(options.silentTranslationWarn) + ? !options.silentTranslationWarn + : true; + const fallbackWarn = isBoolean(options.silentFallbackWarn) || + isRegExp(options.silentFallbackWarn) + ? !options.silentFallbackWarn + : true; + const fallbackRoot = isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + const fallbackFormat = !!options.formatFallbackMessages; + const modifiers = isPlainObject(options.modifiers) ? options.modifiers : {}; + const pluralizationRules = options.pluralizationRules; + const postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : undefined; + const warnHtmlMessage = isString(options.warnHtmlInMessage) + ? options.warnHtmlInMessage !== 'off' + : true; + const escapeParameter = !!options.escapeParameterHtml; + const inheritLocale = isBoolean(options.sync) ? options.sync : true; + if ((process.env.NODE_ENV !== 'production') && options.formatter) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + } + if ((process.env.NODE_ENV !== 'production') && options.preserveDirectiveContent) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + } + let messages = options.messages; + if (isPlainObject(options.sharedMessages)) { + const sharedMessages = options.sharedMessages; + const locales = Object.keys(sharedMessages); + messages = locales.reduce((messages, locale) => { + const message = messages[locale] || (messages[locale] = {}); + assign(message, sharedMessages[locale]); + return messages; + }, (messages || {})); + } + const { __i18n, __root, __injectWithOption } = options; + const datetimeFormats = options.datetimeFormats; + const numberFormats = options.numberFormats; + const flatJson = options.flatJson; + const translateExistCompatible = options + .translateExistCompatible; + return { + locale, + fallbackLocale, + messages, + flatJson, + datetimeFormats, + numberFormats, + missing, + missingWarn, + fallbackWarn, + fallbackRoot, + fallbackFormat, + modifiers, + pluralRules: pluralizationRules, + postTranslation, + warnHtmlMessage, + escapeParameter, + messageResolver: options.messageResolver, + inheritLocale, + translateExistCompatible, + __i18n, + __root, + __injectWithOption + }; +} +/** + * create VueI18n interface factory + * + * @internal + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function createVueI18n(options = {}, VueI18nLegacy) { + { + const composer = createComposer(convertComposerOptions(options)); + const { __extender } = options; + // defines VueI18n + const vueI18n = { + // id + id: composer.id, + // locale + get locale() { + return composer.locale.value; + }, + set locale(val) { + composer.locale.value = val; + }, + // fallbackLocale + get fallbackLocale() { + return composer.fallbackLocale.value; + }, + set fallbackLocale(val) { + composer.fallbackLocale.value = val; + }, + // messages + get messages() { + return composer.messages.value; + }, + // datetimeFormats + get datetimeFormats() { + return composer.datetimeFormats.value; + }, + // numberFormats + get numberFormats() { + return composer.numberFormats.value; + }, + // availableLocales + get availableLocales() { + return composer.availableLocales; + }, + // formatter + get formatter() { + (process.env.NODE_ENV !== 'production') && warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + // dummy + return { + interpolate() { + return []; + } + }; + }, + set formatter(val) { + (process.env.NODE_ENV !== 'production') && warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER)); + }, + // missing + get missing() { + return composer.getMissingHandler(); + }, + set missing(handler) { + composer.setMissingHandler(handler); + }, + // silentTranslationWarn + get silentTranslationWarn() { + return isBoolean(composer.missingWarn) + ? !composer.missingWarn + : composer.missingWarn; + }, + set silentTranslationWarn(val) { + composer.missingWarn = isBoolean(val) ? !val : val; + }, + // silentFallbackWarn + get silentFallbackWarn() { + return isBoolean(composer.fallbackWarn) + ? !composer.fallbackWarn + : composer.fallbackWarn; + }, + set silentFallbackWarn(val) { + composer.fallbackWarn = isBoolean(val) ? !val : val; + }, + // modifiers + get modifiers() { + return composer.modifiers; + }, + // formatFallbackMessages + get formatFallbackMessages() { + return composer.fallbackFormat; + }, + set formatFallbackMessages(val) { + composer.fallbackFormat = val; + }, + // postTranslation + get postTranslation() { + return composer.getPostTranslationHandler(); + }, + set postTranslation(handler) { + composer.setPostTranslationHandler(handler); + }, + // sync + get sync() { + return composer.inheritLocale; + }, + set sync(val) { + composer.inheritLocale = val; + }, + // warnInHtmlMessage + get warnHtmlInMessage() { + return composer.warnHtmlMessage ? 'warn' : 'off'; + }, + set warnHtmlInMessage(val) { + composer.warnHtmlMessage = val !== 'off'; + }, + // escapeParameterHtml + get escapeParameterHtml() { + return composer.escapeParameter; + }, + set escapeParameterHtml(val) { + composer.escapeParameter = val; + }, + // preserveDirectiveContent + get preserveDirectiveContent() { + (process.env.NODE_ENV !== 'production') && + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + return true; + }, + set preserveDirectiveContent(val) { + (process.env.NODE_ENV !== 'production') && + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE)); + }, + // pluralizationRules + get pluralizationRules() { + return composer.pluralRules || {}; + }, + // for internal + __composer: composer, + // t + t(...args) { + const [arg1, arg2, arg3] = args; + const options = {}; + let list = null; + let named = null; + if (!isString(arg1)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + const key = arg1; + if (isString(arg2)) { + options.locale = arg2; + } + else if (isArray(arg2)) { + list = arg2; + } + else if (isPlainObject(arg2)) { + named = arg2; + } + if (isArray(arg3)) { + list = arg3; + } + else if (isPlainObject(arg3)) { + named = arg3; + } + // return composer.t(key, (list || named || {}) as any, options) + return Reflect.apply(composer.t, composer, [ + key, + (list || named || {}), + options + ]); + }, + rt(...args) { + return Reflect.apply(composer.rt, composer, [...args]); + }, + // tc + tc(...args) { + const [arg1, arg2, arg3] = args; + const options = { plural: 1 }; + let list = null; + let named = null; + if (!isString(arg1)) { + throw createI18nError(I18nErrorCodes.INVALID_ARGUMENT); + } + const key = arg1; + if (isString(arg2)) { + options.locale = arg2; + } + else if (isNumber(arg2)) { + options.plural = arg2; + } + else if (isArray(arg2)) { + list = arg2; + } + else if (isPlainObject(arg2)) { + named = arg2; + } + if (isString(arg3)) { + options.locale = arg3; + } + else if (isArray(arg3)) { + list = arg3; + } + else if (isPlainObject(arg3)) { + named = arg3; + } + // return composer.t(key, (list || named || {}) as any, options) + return Reflect.apply(composer.t, composer, [ + key, + (list || named || {}), + options + ]); + }, + // te + te(key, locale) { + return composer.te(key, locale); + }, + // tm + tm(key) { + return composer.tm(key); + }, + // getLocaleMessage + getLocaleMessage(locale) { + return composer.getLocaleMessage(locale); + }, + // setLocaleMessage + setLocaleMessage(locale, message) { + composer.setLocaleMessage(locale, message); + }, + // mergeLocaleMessage + mergeLocaleMessage(locale, message) { + composer.mergeLocaleMessage(locale, message); + }, + // d + d(...args) { + return Reflect.apply(composer.d, composer, [...args]); + }, + // getDateTimeFormat + getDateTimeFormat(locale) { + return composer.getDateTimeFormat(locale); + }, + // setDateTimeFormat + setDateTimeFormat(locale, format) { + composer.setDateTimeFormat(locale, format); + }, + // mergeDateTimeFormat + mergeDateTimeFormat(locale, format) { + composer.mergeDateTimeFormat(locale, format); + }, + // n + n(...args) { + return Reflect.apply(composer.n, composer, [...args]); + }, + // getNumberFormat + getNumberFormat(locale) { + return composer.getNumberFormat(locale); + }, + // setNumberFormat + setNumberFormat(locale, format) { + composer.setNumberFormat(locale, format); + }, + // mergeNumberFormat + mergeNumberFormat(locale, format) { + composer.mergeNumberFormat(locale, format); + }, + // getChoiceIndex + // eslint-disable-next-line @typescript-eslint/no-unused-vars + getChoiceIndex(choice, choicesLength) { + (process.env.NODE_ENV !== 'production') && + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX)); + return -1; + } + }; + vueI18n.__extender = __extender; + // for vue-devtools timeline event + if ((process.env.NODE_ENV !== 'production')) { + vueI18n.__enableEmitter = (emitter) => { + const __composer = composer; + __composer[EnableEmitter] && __composer[EnableEmitter](emitter); + }; + vueI18n.__disableEmitter = () => { + const __composer = composer; + __composer[DisableEmitter] && __composer[DisableEmitter](); + }; + } + return vueI18n; + } +} +/* eslint-enable @typescript-eslint/no-explicit-any */ + +const baseFormatProps = { + tag: { + type: [String, Object] + }, + locale: { + type: String + }, + scope: { + type: String, + // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050 + validator: (val /* ComponentI18nScope */) => val === 'parent' || val === 'global', + default: 'parent' /* ComponentI18nScope */ + }, + i18n: { + type: Object + } +}; + +function getInterpolateArg( +// eslint-disable-next-line @typescript-eslint/no-explicit-any +{ slots }, // SetupContext, +keys) { + if (keys.length === 1 && keys[0] === 'default') { + // default slot with list + const ret = slots.default ? slots.default() : []; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return ret.reduce((slot, current) => { + return [ + ...slot, + // prettier-ignore + ...(current.type === Fragment ? current.children : [current] + ) + ]; + }, []); + } + else { + // named slots + return keys.reduce((arg, key) => { + const slot = slots[key]; + if (slot) { + arg[key] = slot(); + } + return arg; + }, create()); + } +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getFragmentableTag(tag) { + return Fragment ; +} + +const TranslationImpl = /*#__PURE__*/ defineComponent({ + /* eslint-disable */ + name: 'i18n-t', + props: assign({ + keypath: { + type: String, + required: true + }, + plural: { + type: [Number, String], + // eslint-disable-next-line @typescript-eslint/no-explicit-any + validator: (val) => isNumber(val) || !isNaN(val) + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const { slots, attrs } = context; + // NOTE: avoid https://github.com/microsoft/rushstack/issues/1050 + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return () => { + const keys = Object.keys(slots).filter(key => key !== '_'); + const options = create(); + if (props.locale) { + options.locale = props.locale; + } + if (props.plural !== undefined) { + options.plural = isString(props.plural) ? +props.plural : props.plural; + } + const arg = getInterpolateArg(context, keys); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const children = i18n[TranslateVNodeSymbol](props.keypath, arg, options); + const assignedAttrs = assign(create(), attrs); + const tag = isString(props.tag) || isObject(props.tag) + ? props.tag + : getFragmentableTag(); + return h(tag, assignedAttrs, children); + }; + } +}); +/** + * export the public type for h/tsx inference + * also to avoid inline import() in generated d.ts files + */ +/** + * Translation Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [TranslationProps](component#translationprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Component Interpolation](../guide/advanced/component) + * + * @example + * ```html + *
+ * + * + * {{ $t('tos') }} + * + * + *
+ * ``` + * ```js + * import { createApp } from 'vue' + * import { createI18n } from 'vue-i18n' + * + * const messages = { + * en: { + * tos: 'Term of Service', + * term: 'I accept xxx {0}.' + * }, + * ja: { + * tos: '利用規約', + * term: '私は xxx の{0}に同意します。' + * } + * } + * + * const i18n = createI18n({ + * locale: 'en', + * messages + * }) + * + * const app = createApp({ + * data: { + * url: '/term' + * } + * }).use(i18n).mount('#app') + * ``` + * + * @VueI18nComponent + */ +const Translation = TranslationImpl; +const I18nT = Translation; + +function isVNode(target) { + return isArray(target) && !isString(target[0]); +} +function renderFormatter(props, context, slotKeys, partFormatter) { + const { slots, attrs } = context; + return () => { + const options = { part: true }; + let overrides = create(); + if (props.locale) { + options.locale = props.locale; + } + if (isString(props.format)) { + options.key = props.format; + } + else if (isObject(props.format)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (isString(props.format.key)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + options.key = props.format.key; + } + // Filter out number format options only + overrides = Object.keys(props.format).reduce((options, prop) => { + return slotKeys.includes(prop) + ? assign(create(), options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any + : options; + }, create()); + } + const parts = partFormatter(...[props.value, options, overrides]); + let children = [options.key]; + if (isArray(parts)) { + children = parts.map((part, index) => { + const slot = slots[part.type]; + const node = slot + ? slot({ [part.type]: part.value, index, parts }) + : [part.value]; + if (isVNode(node)) { + node[0].key = `${part.type}-${index}`; + } + return node; + }); + } + else if (isString(parts)) { + children = [parts]; + } + const assignedAttrs = assign(create(), attrs); + const tag = isString(props.tag) || isObject(props.tag) + ? props.tag + : getFragmentableTag(); + return h(tag, assignedAttrs, children); + }; +} + +const NumberFormatImpl = /*#__PURE__*/ defineComponent({ + /* eslint-disable */ + name: 'i18n-n', + props: assign({ + value: { + type: Number, + required: true + }, + format: { + type: [String, Object] + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return renderFormatter(props, context, NUMBER_FORMAT_OPTIONS_KEYS, (...args) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + i18n[NumberPartsSymbol](...args)); + } +}); +/** + * export the public type for h/tsx inference + * also to avoid inline import() in generated d.ts files + */ +/** + * Number Format Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [FormattableProps](component#formattableprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Custom Formatting](../guide/essentials/number#custom-formatting) + * + * @VueI18nDanger + * Not supported IE, due to no support `Intl.NumberFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts) + * + * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-numberformat) + * + * @VueI18nComponent + */ +const NumberFormat = NumberFormatImpl; +const I18nN = NumberFormat; + +const DatetimeFormatImpl = /* #__PURE__*/ defineComponent({ + /* eslint-disable */ + name: 'i18n-d', + props: assign({ + value: { + type: [Number, Date], + required: true + }, + format: { + type: [String, Object] + } + }, baseFormatProps), + /* eslint-enable */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + setup(props, context) { + const i18n = props.i18n || + useI18n({ + useScope: props.scope, + __useComponent: true + }); + return renderFormatter(props, context, DATETIME_FORMAT_OPTIONS_KEYS, (...args) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + i18n[DatetimePartsSymbol](...args)); + } +}); +/** + * Datetime Format Component + * + * @remarks + * See the following items for property about details + * + * @VueI18nSee [FormattableProps](component#formattableprops) + * @VueI18nSee [BaseFormatProps](component#baseformatprops) + * @VueI18nSee [Custom Formatting](../guide/essentials/datetime#custom-formatting) + * + * @VueI18nDanger + * Not supported IE, due to no support `Intl.DateTimeFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts) + * + * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-datetimeformat) + * + * @VueI18nComponent + */ +const DatetimeFormat = DatetimeFormatImpl; +const I18nD = DatetimeFormat; + +function getComposer$2(i18n, instance) { + const i18nInternal = i18n; + if (i18n.mode === 'composition') { + return (i18nInternal.__getInstance(instance) || i18n.global); + } + else { + const vueI18n = i18nInternal.__getInstance(instance); + return vueI18n != null + ? vueI18n.__composer + : i18n.global.__composer; + } +} +function vTDirective(i18n) { + const _process = (binding) => { + const { instance, modifiers, value } = binding; + /* istanbul ignore if */ + if (!instance || !instance.$) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const composer = getComposer$2(i18n, instance.$); + if ((process.env.NODE_ENV !== 'production') && modifiers.preserve) { + warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE)); + } + const parsedValue = parseValue(value); + return [ + Reflect.apply(composer.t, composer, [...makeParams(parsedValue)]), + composer + ]; + }; + const register = (el, binding) => { + const [textContent, composer] = _process(binding); + if (inBrowser && i18n.global === composer) { + // global scope only + el.__i18nWatcher = watch(composer.locale, () => { + binding.instance && binding.instance.$forceUpdate(); + }); + } + el.__composer = composer; + el.textContent = textContent; + }; + const unregister = (el) => { + if (inBrowser && el.__i18nWatcher) { + el.__i18nWatcher(); + el.__i18nWatcher = undefined; + delete el.__i18nWatcher; + } + if (el.__composer) { + el.__composer = undefined; + delete el.__composer; + } + }; + const update = (el, { value }) => { + if (el.__composer) { + const composer = el.__composer; + const parsedValue = parseValue(value); + el.textContent = Reflect.apply(composer.t, composer, [ + ...makeParams(parsedValue) + ]); + } + }; + const getSSRProps = (binding) => { + const [textContent] = _process(binding); + return { textContent }; + }; + return { + created: register, + unmounted: unregister, + beforeUpdate: update, + getSSRProps + }; +} +function parseValue(value) { + if (isString(value)) { + return { path: value }; + } + else if (isPlainObject(value)) { + if (!('path' in value)) { + throw createI18nError(I18nErrorCodes.REQUIRED_VALUE, 'path'); + } + return value; + } + else { + throw createI18nError(I18nErrorCodes.INVALID_VALUE); + } +} +function makeParams(value) { + const { path, locale, args, choice, plural } = value; + const options = {}; + const named = args || {}; + if (isString(locale)) { + options.locale = locale; + } + if (isNumber(choice)) { + options.plural = choice; + } + if (isNumber(plural)) { + options.plural = plural; + } + return [path, named, options]; +} + +function apply(app, i18n, ...options) { + const pluginOptions = isPlainObject(options[0]) + ? options[0] + : {}; + const useI18nComponentName = !!pluginOptions.useI18nComponentName; + const globalInstall = isBoolean(pluginOptions.globalInstall) + ? pluginOptions.globalInstall + : true; + if ((process.env.NODE_ENV !== 'production') && globalInstall && useI18nComponentName) { + warn(getWarnMessage(I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE, { + name: Translation.name + })); + } + if (globalInstall) { + [!useI18nComponentName ? Translation.name : 'i18n', 'I18nT'].forEach(name => app.component(name, Translation)); + [NumberFormat.name, 'I18nN'].forEach(name => app.component(name, NumberFormat)); + [DatetimeFormat.name, 'I18nD'].forEach(name => app.component(name, DatetimeFormat)); + } + // install directive + { + app.directive('t', vTDirective(i18n)); + } +} + +const VueDevToolsLabels = { + ["vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */]: 'Vue I18n devtools', + ["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */]: 'I18n Resources', + ["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */]: 'Vue I18n' +}; +const VueDevToolsPlaceholders = { + ["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */]: 'Search for scopes ...' +}; +const VueDevToolsTimelineColors = { + ["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */]: 0xffcd19 +}; + +const VUE_I18N_COMPONENT_TYPES = 'vue-i18n: composer properties'; +let devtoolsApi; +async function enableDevTools(app, i18n) { + return new Promise((resolve, reject) => { + try { + setupDevtoolsPlugin({ + id: "vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */, + label: VueDevToolsLabels["vue-devtools-plugin-vue-i18n" /* VueDevToolsIDs.PLUGIN */], + packageName: 'vue-i18n', + homepage: 'https://vue-i18n.intlify.dev', + logo: 'https://vue-i18n.intlify.dev/vue-i18n-devtools-logo.png', + componentStateTypes: [VUE_I18N_COMPONENT_TYPES], + app: app // eslint-disable-line @typescript-eslint/no-explicit-any + }, api => { + devtoolsApi = api; + api.on.visitComponentTree(({ componentInstance, treeNode }) => { + updateComponentTreeTags(componentInstance, treeNode, i18n); + }); + api.on.inspectComponent(({ componentInstance, instanceData }) => { + if (componentInstance.vnode.el && + componentInstance.vnode.el.__VUE_I18N__ && + instanceData) { + if (i18n.mode === 'legacy') { + // ignore global scope on legacy mode + if (componentInstance.vnode.el.__VUE_I18N__ !== + i18n.global.__composer) { + inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__); + } + } + else { + inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__); + } + } + }); + api.addInspector({ + id: "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */, + label: VueDevToolsLabels["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */], + icon: 'language', + treeFilterPlaceholder: VueDevToolsPlaceholders["vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */] + }); + api.on.getInspectorTree(payload => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + registerScope(payload, i18n); + } + }); + const roots = new Map(); + api.on.getInspectorState(async (payload) => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + api.unhighlightElement(); + inspectScope(payload, i18n); + if (payload.nodeId === 'global') { + if (!roots.has(payload.app)) { + const [root] = await api.getComponentInstances(payload.app); + roots.set(payload.app, root); + } + api.highlightElement(roots.get(payload.app)); + } + else { + const instance = getComponentInstance(payload.nodeId, i18n); + instance && api.highlightElement(instance); + } + } + }); + api.on.editInspectorState(payload => { + if (payload.app === app && + payload.inspectorId === "vue-i18n-resource-inspector" /* VueDevToolsIDs.CUSTOM_INSPECTOR */) { + editScope(payload, i18n); + } + }); + api.addTimelineLayer({ + id: "vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */, + label: VueDevToolsLabels["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */], + color: VueDevToolsTimelineColors["vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */] + }); + resolve(true); + }); + } + catch (e) { + console.error(e); + reject(false); + } + }); +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getI18nScopeLable(instance) { + return (instance.type.name || + instance.type.displayName || + instance.type.__file || + 'Anonymous'); +} +function updateComponentTreeTags(instance, // eslint-disable-line @typescript-eslint/no-explicit-any +treeNode, i18n) { + // prettier-ignore + const global = i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + if (instance && instance.vnode.el && instance.vnode.el.__VUE_I18N__) { + // add custom tags local scope only + if (instance.vnode.el.__VUE_I18N__ !== global) { + const tag = { + label: `i18n (${getI18nScopeLable(instance)} Scope)`, + textColor: 0x000000, + backgroundColor: 0xffcd19 + }; + treeNode.tags.push(tag); + } + } +} +function inspectComposer(instanceData, composer) { + const type = VUE_I18N_COMPONENT_TYPES; + instanceData.state.push({ + type, + key: 'locale', + editable: true, + value: composer.locale.value + }); + instanceData.state.push({ + type, + key: 'availableLocales', + editable: false, + value: composer.availableLocales + }); + instanceData.state.push({ + type, + key: 'fallbackLocale', + editable: true, + value: composer.fallbackLocale.value + }); + instanceData.state.push({ + type, + key: 'inheritLocale', + editable: true, + value: composer.inheritLocale + }); + instanceData.state.push({ + type, + key: 'messages', + editable: false, + value: getLocaleMessageValue(composer.messages.value) + }); + { + instanceData.state.push({ + type, + key: 'datetimeFormats', + editable: false, + value: composer.datetimeFormats.value + }); + instanceData.state.push({ + type, + key: 'numberFormats', + editable: false, + value: composer.numberFormats.value + }); + } +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getLocaleMessageValue(messages) { + const value = {}; + Object.keys(messages).forEach((key) => { + const v = messages[key]; + if (isFunction(v) && 'source' in v) { + value[key] = getMessageFunctionDetails(v); + } + else if (isMessageAST(v) && v.loc && v.loc.source) { + value[key] = v.loc.source; + } + else if (isObject(v)) { + value[key] = getLocaleMessageValue(v); + } + else { + value[key] = v; + } + }); + return value; +} +const ESC = { + '<': '<', + '>': '>', + '"': '"', + '&': '&' +}; +function escape(s) { + return s.replace(/[<>"&]/g, escapeChar); +} +function escapeChar(a) { + return ESC[a] || a; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getMessageFunctionDetails(func) { + const argString = func.source ? `("${escape(func.source)}")` : `(?)`; + return { + _custom: { + type: 'function', + display: `ƒ ${argString}` + } + }; +} +function registerScope(payload, i18n) { + payload.rootNodes.push({ + id: 'global', + label: 'Global Scope' + }); + // prettier-ignore + const global = i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + for (const [keyInstance, instance] of i18n.__instances) { + // prettier-ignore + const composer = i18n.mode === 'composition' + ? instance + : instance.__composer; + if (global === composer) { + continue; + } + payload.rootNodes.push({ + id: composer.id.toString(), + label: `${getI18nScopeLable(keyInstance)} Scope` + }); + } +} +function getComponentInstance(nodeId, i18n) { + let instance = null; + if (nodeId !== 'global') { + for (const [component, composer] of i18n.__instances.entries()) { + if (composer.id.toString() === nodeId) { + instance = component; + break; + } + } + } + return instance; +} +function getComposer$1(nodeId, i18n) { + if (nodeId === 'global') { + return i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer; + } + else { + const instance = Array.from(i18n.__instances.values()).find(item => item.id.toString() === nodeId); + if (instance) { + return i18n.mode === 'composition' + ? instance + : instance.__composer; + } + else { + return null; + } + } +} +function inspectScope(payload, i18n +// eslint-disable-next-line @typescript-eslint/no-explicit-any +) { + const composer = getComposer$1(payload.nodeId, i18n); + if (composer) { + // TODO: + // eslint-disable-next-line @typescript-eslint/no-explicit-any + payload.state = makeScopeInspectState(composer); + } + return null; +} +function makeScopeInspectState(composer) { + const state = {}; + const localeType = 'Locale related info'; + const localeStates = [ + { + type: localeType, + key: 'locale', + editable: true, + value: composer.locale.value + }, + { + type: localeType, + key: 'fallbackLocale', + editable: true, + value: composer.fallbackLocale.value + }, + { + type: localeType, + key: 'availableLocales', + editable: false, + value: composer.availableLocales + }, + { + type: localeType, + key: 'inheritLocale', + editable: true, + value: composer.inheritLocale + } + ]; + state[localeType] = localeStates; + const localeMessagesType = 'Locale messages info'; + const localeMessagesStates = [ + { + type: localeMessagesType, + key: 'messages', + editable: false, + value: getLocaleMessageValue(composer.messages.value) + } + ]; + state[localeMessagesType] = localeMessagesStates; + { + const datetimeFormatsType = 'Datetime formats info'; + const datetimeFormatsStates = [ + { + type: datetimeFormatsType, + key: 'datetimeFormats', + editable: false, + value: composer.datetimeFormats.value + } + ]; + state[datetimeFormatsType] = datetimeFormatsStates; + const numberFormatsType = 'Datetime formats info'; + const numberFormatsStates = [ + { + type: numberFormatsType, + key: 'numberFormats', + editable: false, + value: composer.numberFormats.value + } + ]; + state[numberFormatsType] = numberFormatsStates; + } + return state; +} +function addTimelineEvent(event, payload) { + if (devtoolsApi) { + let groupId; + if (payload && 'groupId' in payload) { + groupId = payload.groupId; + delete payload.groupId; + } + devtoolsApi.addTimelineEvent({ + layerId: "vue-i18n-timeline" /* VueDevToolsIDs.TIMELINE */, + event: { + title: event, + groupId, + time: Date.now(), + meta: {}, + data: payload || {}, + logType: event === "compile-error" /* VueDevToolsTimelineEvents.COMPILE_ERROR */ + ? 'error' + : event === "fallback" /* VueDevToolsTimelineEvents.FALBACK */ || + event === "missing" /* VueDevToolsTimelineEvents.MISSING */ + ? 'warning' + : 'default' + } + }); + } +} +function editScope(payload, i18n) { + const composer = getComposer$1(payload.nodeId, i18n); + if (composer) { + const [field] = payload.path; + if (field === 'locale' && isString(payload.state.value)) { + composer.locale.value = payload.state.value; + } + else if (field === 'fallbackLocale' && + (isString(payload.state.value) || + isArray(payload.state.value) || + isObject(payload.state.value))) { + composer.fallbackLocale.value = payload.state.value; + } + else if (field === 'inheritLocale' && isBoolean(payload.state.value)) { + composer.inheritLocale = payload.state.value; + } + } +} + +/** + * Supports compatibility for legacy vue-i18n APIs + * This mixin is used when we use vue-i18n@v9.x or later + */ +function defineMixin(vuei18n, composer, i18n) { + return { + beforeCreate() { + const instance = getCurrentInstance(); + /* istanbul ignore if */ + if (!instance) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const options = this.$options; + if (options.i18n) { + const optionsI18n = options.i18n; + if (options.__i18n) { + optionsI18n.__i18n = options.__i18n; + } + optionsI18n.__root = composer; + if (this === this.$root) { + // merge option and gttach global + this.$i18n = mergeToGlobal(vuei18n, optionsI18n); + } + else { + optionsI18n.__injectWithOption = true; + optionsI18n.__extender = i18n.__vueI18nExtend; + // atttach local VueI18n instance + this.$i18n = createVueI18n(optionsI18n); + // extend VueI18n instance + const _vueI18n = this.$i18n; + if (_vueI18n.__extender) { + _vueI18n.__disposer = _vueI18n.__extender(this.$i18n); + } + } + } + else if (options.__i18n) { + if (this === this.$root) { + // merge option and gttach global + this.$i18n = mergeToGlobal(vuei18n, options); + } + else { + // atttach local VueI18n instance + this.$i18n = createVueI18n({ + __i18n: options.__i18n, + __injectWithOption: true, + __extender: i18n.__vueI18nExtend, + __root: composer + }); + // extend VueI18n instance + const _vueI18n = this.$i18n; + if (_vueI18n.__extender) { + _vueI18n.__disposer = _vueI18n.__extender(this.$i18n); + } + } + } + else { + // attach global VueI18n instance + this.$i18n = vuei18n; + } + if (options.__i18nGlobal) { + adjustI18nResources(composer, options, options); + } + // defines vue-i18n legacy APIs + this.$t = (...args) => this.$i18n.t(...args); + this.$rt = (...args) => this.$i18n.rt(...args); + this.$tc = (...args) => this.$i18n.tc(...args); + this.$te = (key, locale) => this.$i18n.te(key, locale); + this.$d = (...args) => this.$i18n.d(...args); + this.$n = (...args) => this.$i18n.n(...args); + this.$tm = (key) => this.$i18n.tm(key); + i18n.__setInstance(instance, this.$i18n); + }, + mounted() { + /* istanbul ignore if */ + if (((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) && + !false && + this.$el && + this.$i18n) { + const _vueI18n = this.$i18n; + this.$el.__VUE_I18N__ = _vueI18n.__composer; + const emitter = (this.__v_emitter = + createEmitter()); + _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter); + emitter.on('*', addTimelineEvent); + } + }, + unmounted() { + const instance = getCurrentInstance(); + /* istanbul ignore if */ + if (!instance) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const _vueI18n = this.$i18n; + /* istanbul ignore if */ + if (((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) && + !false && + this.$el && + this.$el.__VUE_I18N__) { + if (this.__v_emitter) { + this.__v_emitter.off('*', addTimelineEvent); + delete this.__v_emitter; + } + if (this.$i18n) { + _vueI18n.__disableEmitter && _vueI18n.__disableEmitter(); + delete this.$el.__VUE_I18N__; + } + } + delete this.$t; + delete this.$rt; + delete this.$tc; + delete this.$te; + delete this.$d; + delete this.$n; + delete this.$tm; + if (_vueI18n.__disposer) { + _vueI18n.__disposer(); + delete _vueI18n.__disposer; + delete _vueI18n.__extender; + } + i18n.__deleteInstance(instance); + delete this.$i18n; + } + }; +} +function mergeToGlobal(g, options) { + g.locale = options.locale || g.locale; + g.fallbackLocale = options.fallbackLocale || g.fallbackLocale; + g.missing = options.missing || g.missing; + g.silentTranslationWarn = + options.silentTranslationWarn || g.silentFallbackWarn; + g.silentFallbackWarn = options.silentFallbackWarn || g.silentFallbackWarn; + g.formatFallbackMessages = + options.formatFallbackMessages || g.formatFallbackMessages; + g.postTranslation = options.postTranslation || g.postTranslation; + g.warnHtmlInMessage = options.warnHtmlInMessage || g.warnHtmlInMessage; + g.escapeParameterHtml = options.escapeParameterHtml || g.escapeParameterHtml; + g.sync = options.sync || g.sync; + g.__composer[SetPluralRulesSymbol](options.pluralizationRules || g.pluralizationRules); + const messages = getLocaleMessages(g.locale, { + messages: options.messages, + __i18n: options.__i18n + }); + Object.keys(messages).forEach(locale => g.mergeLocaleMessage(locale, messages[locale])); + if (options.datetimeFormats) { + Object.keys(options.datetimeFormats).forEach(locale => g.mergeDateTimeFormat(locale, options.datetimeFormats[locale])); + } + if (options.numberFormats) { + Object.keys(options.numberFormats).forEach(locale => g.mergeNumberFormat(locale, options.numberFormats[locale])); + } + return g; +} + +/** + * Injection key for {@link useI18n} + * + * @remarks + * The global injection key for I18n instances with `useI18n`. this injection key is used in Web Components. + * Specify the i18n instance created by {@link createI18n} together with `provide` function. + * + * @VueI18nGeneral + */ +const I18nInjectionKey = +/* #__PURE__*/ makeSymbol('global-vue-i18n'); +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types +function createI18n(options = {}, VueI18nLegacy) { + // prettier-ignore + const __legacyMode = __VUE_I18N_LEGACY_API__ && isBoolean(options.legacy) + ? options.legacy + : __VUE_I18N_LEGACY_API__; + // prettier-ignore + const __globalInjection = isBoolean(options.globalInjection) + ? options.globalInjection + : true; + // prettier-ignore + const __allowComposition = __VUE_I18N_LEGACY_API__ && __legacyMode + ? !!options.allowComposition + : true; + const __instances = new Map(); + const [globalScope, __global] = createGlobal(options, __legacyMode); + const symbol = /* #__PURE__*/ makeSymbol((process.env.NODE_ENV !== 'production') ? 'vue-i18n' : ''); + if ((process.env.NODE_ENV !== 'production')) { + if (__legacyMode && __allowComposition && !false) { + warn(getWarnMessage(I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION)); + } + } + function __getInstance(component) { + return __instances.get(component) || null; + } + function __setInstance(component, instance) { + __instances.set(component, instance); + } + function __deleteInstance(component) { + __instances.delete(component); + } + { + const i18n = { + // mode + get mode() { + return __VUE_I18N_LEGACY_API__ && __legacyMode + ? 'legacy' + : 'composition'; + }, + // allowComposition + get allowComposition() { + return __allowComposition; + }, + // install plugin + async install(app, ...options) { + if (((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) && + !false) { + app.__VUE_I18N__ = i18n; + } + // setup global provider + app.__VUE_I18N_SYMBOL__ = symbol; + app.provide(app.__VUE_I18N_SYMBOL__, i18n); + // set composer & vuei18n extend hook options from plugin options + if (isPlainObject(options[0])) { + const opts = options[0]; + i18n.__composerExtend = + opts.__composerExtend; + i18n.__vueI18nExtend = + opts.__vueI18nExtend; + } + // global method and properties injection for Composition API + let globalReleaseHandler = null; + if (!__legacyMode && __globalInjection) { + globalReleaseHandler = injectGlobalFields(app, i18n.global); + } + // install built-in components and directive + if (__VUE_I18N_FULL_INSTALL__) { + apply(app, i18n, ...options); + } + // setup mixin for Legacy API + if (__VUE_I18N_LEGACY_API__ && __legacyMode) { + app.mixin(defineMixin(__global, __global.__composer, i18n)); + } + // release global scope + const unmountApp = app.unmount; + app.unmount = () => { + globalReleaseHandler && globalReleaseHandler(); + i18n.dispose(); + unmountApp(); + }; + // setup vue-devtools plugin + if (((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) && !false) { + const ret = await enableDevTools(app, i18n); + if (!ret) { + throw createI18nError(I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN); + } + const emitter = createEmitter(); + if (__legacyMode) { + const _vueI18n = __global; + _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter); + } + else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = __global; + _composer[EnableEmitter] && _composer[EnableEmitter](emitter); + } + emitter.on('*', addTimelineEvent); + } + }, + // global accessor + get global() { + return __global; + }, + dispose() { + globalScope.stop(); + }, + // @internal + __instances, + // @internal + __getInstance, + // @internal + __setInstance, + // @internal + __deleteInstance + }; + return i18n; + } +} +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +function useI18n(options = {}) { + const instance = getCurrentInstance(); + if (instance == null) { + throw createI18nError(I18nErrorCodes.MUST_BE_CALL_SETUP_TOP); + } + if (!instance.isCE && + instance.appContext.app != null && + !instance.appContext.app.__VUE_I18N_SYMBOL__) { + throw createI18nError(I18nErrorCodes.NOT_INSTALLED); + } + const i18n = getI18nInstance(instance); + const gl = getGlobalComposer(i18n); + const componentOptions = getComponentOptions(instance); + const scope = getScope(options, componentOptions); + if (__VUE_I18N_LEGACY_API__) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (i18n.mode === 'legacy' && !options.__useComponent) { + if (!i18n.allowComposition) { + throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE); + } + return useI18nForLegacy(instance, scope, gl, options); + } + } + if (scope === 'global') { + adjustI18nResources(gl, options, componentOptions); + return gl; + } + if (scope === 'parent') { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let composer = getComposer(i18n, instance, options.__useComponent); + if (composer == null) { + if ((process.env.NODE_ENV !== 'production')) { + warn(getWarnMessage(I18nWarnCodes.NOT_FOUND_PARENT_SCOPE)); + } + composer = gl; + } + return composer; + } + const i18nInternal = i18n; + let composer = i18nInternal.__getInstance(instance); + if (composer == null) { + const composerOptions = assign({}, options); + if ('__i18n' in componentOptions) { + composerOptions.__i18n = componentOptions.__i18n; + } + if (gl) { + composerOptions.__root = gl; + } + composer = createComposer(composerOptions); + if (i18nInternal.__composerExtend) { + composer[DisposeSymbol] = + i18nInternal.__composerExtend(composer); + } + setupLifeCycle(i18nInternal, instance, composer); + i18nInternal.__setInstance(instance, composer); + } + return composer; +} +/** + * Cast to VueI18n legacy compatible type + * + * @remarks + * This API is provided only with [vue-i18n-bridge](https://vue-i18n.intlify.dev/guide/migration/ways.html#what-is-vue-i18n-bridge). + * + * The purpose of this function is to convert an {@link I18n} instance created with {@link createI18n | createI18n(legacy: true)} into a `vue-i18n@v8.x` compatible instance of `new VueI18n` in a TypeScript environment. + * + * @param i18n - An instance of {@link I18n} + * @returns A i18n instance which is casted to {@link VueI18n} type + * + * @VueI18nTip + * :new: provided by **vue-i18n-bridge only** + * + * @VueI18nGeneral + */ +/* #__NO_SIDE_EFFECTS__ */ +const castToVueI18n = (i18n +// eslint-disable-next-line @typescript-eslint/no-explicit-any +) => { + if (!(__VUE_I18N_BRIDGE__ in i18n)) { + throw createI18nError(I18nErrorCodes.NOT_COMPATIBLE_LEGACY_VUE_I18N); + } + return i18n; +}; +function createGlobal(options, legacyMode, VueI18nLegacy // eslint-disable-line @typescript-eslint/no-explicit-any +) { + const scope = effectScope(); + { + const obj = __VUE_I18N_LEGACY_API__ && legacyMode + ? scope.run(() => createVueI18n(options)) + : scope.run(() => createComposer(options)); + if (obj == null) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + return [scope, obj]; + } +} +function getI18nInstance(instance) { + { + const i18n = inject(!instance.isCE + ? instance.appContext.app.__VUE_I18N_SYMBOL__ + : I18nInjectionKey); + /* istanbul ignore if */ + if (!i18n) { + throw createI18nError(!instance.isCE + ? I18nErrorCodes.UNEXPECTED_ERROR + : I18nErrorCodes.NOT_INSTALLED_WITH_PROVIDE); + } + return i18n; + } +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getScope(options, componentOptions) { + // prettier-ignore + return isEmptyObject(options) + ? ('__i18n' in componentOptions) + ? 'local' + : 'global' + : !options.useScope + ? 'local' + : options.useScope; +} +function getGlobalComposer(i18n) { + // prettier-ignore + return i18n.mode === 'composition' + ? i18n.global + : i18n.global.__composer + ; +} +function getComposer(i18n, target, useComponent = false) { + let composer = null; + const root = target.root; + let current = getParentComponentInstance(target, useComponent); + while (current != null) { + const i18nInternal = i18n; + if (i18n.mode === 'composition') { + composer = i18nInternal.__getInstance(current); + } + else { + if (__VUE_I18N_LEGACY_API__) { + const vueI18n = i18nInternal.__getInstance(current); + if (vueI18n != null) { + composer = vueI18n + .__composer; + if (useComponent && + composer && + !composer[InejctWithOptionSymbol] // eslint-disable-line @typescript-eslint/no-explicit-any + ) { + composer = null; + } + } + } + } + if (composer != null) { + break; + } + if (root === current) { + break; + } + current = current.parent; + } + return composer; +} +function getParentComponentInstance(target, useComponent = false) { + if (target == null) { + return null; + } + { + // if `useComponent: true` will be specified, we get lexical scope owner instance for use-case slots + return !useComponent + ? target.parent + : target.vnode.ctx || target.parent; // eslint-disable-line @typescript-eslint/no-explicit-any + } +} +function setupLifeCycle(i18n, target, composer) { + let emitter = null; + { + onMounted(() => { + // inject composer instance to DOM for intlify-devtools + if (((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) && + !false && + target.vnode.el) { + target.vnode.el.__VUE_I18N__ = composer; + emitter = createEmitter(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = composer; + _composer[EnableEmitter] && _composer[EnableEmitter](emitter); + emitter.on('*', addTimelineEvent); + } + }, target); + onUnmounted(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const _composer = composer; + // remove composer instance from DOM for intlify-devtools + if (((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) && + !false && + target.vnode.el && + target.vnode.el.__VUE_I18N__) { + emitter && emitter.off('*', addTimelineEvent); + _composer[DisableEmitter] && _composer[DisableEmitter](); + delete target.vnode.el.__VUE_I18N__; + } + i18n.__deleteInstance(target); + // dispose extended resources + const dispose = _composer[DisposeSymbol]; + if (dispose) { + dispose(); + delete _composer[DisposeSymbol]; + } + }, target); + } +} +function useI18nForLegacy(instance, scope, root, options = {} // eslint-disable-line @typescript-eslint/no-explicit-any +) { + const isLocalScope = scope === 'local'; + const _composer = shallowRef(null); + if (isLocalScope && + instance.proxy && + !(instance.proxy.$options.i18n || instance.proxy.$options.__i18n)) { + throw createI18nError(I18nErrorCodes.MUST_DEFINE_I18N_OPTION_IN_ALLOW_COMPOSITION); + } + const _inheritLocale = isBoolean(options.inheritLocale) + ? options.inheritLocale + : !isString(options.locale); + const _locale = ref( + // prettier-ignore + !isLocalScope || _inheritLocale + ? root.locale.value + : isString(options.locale) + ? options.locale + : DEFAULT_LOCALE); + const _fallbackLocale = ref( + // prettier-ignore + !isLocalScope || _inheritLocale + ? root.fallbackLocale.value + : isString(options.fallbackLocale) || + isArray(options.fallbackLocale) || + isPlainObject(options.fallbackLocale) || + options.fallbackLocale === false + ? options.fallbackLocale + : _locale.value); + const _messages = ref(getLocaleMessages(_locale.value, options)); + // prettier-ignore + const _datetimeFormats = ref(isPlainObject(options.datetimeFormats) + ? options.datetimeFormats + : { [_locale.value]: {} }); + // prettier-ignore + const _numberFormats = ref(isPlainObject(options.numberFormats) + ? options.numberFormats + : { [_locale.value]: {} }); + // prettier-ignore + const _missingWarn = isLocalScope + ? root.missingWarn + : isBoolean(options.missingWarn) || isRegExp(options.missingWarn) + ? options.missingWarn + : true; + // prettier-ignore + const _fallbackWarn = isLocalScope + ? root.fallbackWarn + : isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) + ? options.fallbackWarn + : true; + // prettier-ignore + const _fallbackRoot = isLocalScope + ? root.fallbackRoot + : isBoolean(options.fallbackRoot) + ? options.fallbackRoot + : true; + // configure fall back to root + const _fallbackFormat = !!options.fallbackFormat; + // runtime missing + const _missing = isFunction(options.missing) ? options.missing : null; + // postTranslation handler + const _postTranslation = isFunction(options.postTranslation) + ? options.postTranslation + : null; + // prettier-ignore + const _warnHtmlMessage = isLocalScope + ? root.warnHtmlMessage + : isBoolean(options.warnHtmlMessage) + ? options.warnHtmlMessage + : true; + const _escapeParameter = !!options.escapeParameter; + // prettier-ignore + const _modifiers = isLocalScope + ? root.modifiers + : isPlainObject(options.modifiers) + ? options.modifiers + : {}; + // pluralRules + const _pluralRules = options.pluralRules || (isLocalScope && root.pluralRules); + // track reactivity + function trackReactivityValues() { + return [ + _locale.value, + _fallbackLocale.value, + _messages.value, + _datetimeFormats.value, + _numberFormats.value + ]; + } + // locale + const locale = computed({ + get: () => { + return _composer.value ? _composer.value.locale.value : _locale.value; + }, + set: val => { + if (_composer.value) { + _composer.value.locale.value = val; + } + _locale.value = val; + } + }); + // fallbackLocale + const fallbackLocale = computed({ + get: () => { + return _composer.value + ? _composer.value.fallbackLocale.value + : _fallbackLocale.value; + }, + set: val => { + if (_composer.value) { + _composer.value.fallbackLocale.value = val; + } + _fallbackLocale.value = val; + } + }); + // messages + const messages = computed(() => { + if (_composer.value) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return _composer.value.messages.value; + } + else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return _messages.value; + } + }); + const datetimeFormats = computed(() => _datetimeFormats.value); + const numberFormats = computed(() => _numberFormats.value); + function getPostTranslationHandler() { + return _composer.value + ? _composer.value.getPostTranslationHandler() + : _postTranslation; + } + function setPostTranslationHandler(handler) { + if (_composer.value) { + _composer.value.setPostTranslationHandler(handler); + } + } + function getMissingHandler() { + return _composer.value ? _composer.value.getMissingHandler() : _missing; + } + function setMissingHandler(handler) { + if (_composer.value) { + _composer.value.setMissingHandler(handler); + } + } + function warpWithDeps(fn) { + trackReactivityValues(); + return fn(); + } + function t(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.t, null, [...args])) + : warpWithDeps(() => ''); + } + function rt(...args) { + return _composer.value + ? Reflect.apply(_composer.value.rt, null, [...args]) + : ''; + } + function d(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.d, null, [...args])) + : warpWithDeps(() => ''); + } + function n(...args) { + return _composer.value + ? warpWithDeps(() => Reflect.apply(_composer.value.n, null, [...args])) + : warpWithDeps(() => ''); + } + function tm(key) { + return _composer.value ? _composer.value.tm(key) : {}; + } + function te(key, locale) { + return _composer.value ? _composer.value.te(key, locale) : false; + } + function getLocaleMessage(locale) { + return _composer.value ? _composer.value.getLocaleMessage(locale) : {}; + } + function setLocaleMessage(locale, message) { + if (_composer.value) { + _composer.value.setLocaleMessage(locale, message); + _messages.value[locale] = message; + } + } + function mergeLocaleMessage(locale, message) { + if (_composer.value) { + _composer.value.mergeLocaleMessage(locale, message); + } + } + function getDateTimeFormat(locale) { + return _composer.value ? _composer.value.getDateTimeFormat(locale) : {}; + } + function setDateTimeFormat(locale, format) { + if (_composer.value) { + _composer.value.setDateTimeFormat(locale, format); + _datetimeFormats.value[locale] = format; + } + } + function mergeDateTimeFormat(locale, format) { + if (_composer.value) { + _composer.value.mergeDateTimeFormat(locale, format); + } + } + function getNumberFormat(locale) { + return _composer.value ? _composer.value.getNumberFormat(locale) : {}; + } + function setNumberFormat(locale, format) { + if (_composer.value) { + _composer.value.setNumberFormat(locale, format); + _numberFormats.value[locale] = format; + } + } + function mergeNumberFormat(locale, format) { + if (_composer.value) { + _composer.value.mergeNumberFormat(locale, format); + } + } + const wrapper = { + get id() { + return _composer.value ? _composer.value.id : -1; + }, + locale, + fallbackLocale, + messages, + datetimeFormats, + numberFormats, + get inheritLocale() { + return _composer.value ? _composer.value.inheritLocale : _inheritLocale; + }, + set inheritLocale(val) { + if (_composer.value) { + _composer.value.inheritLocale = val; + } + }, + get availableLocales() { + return _composer.value + ? _composer.value.availableLocales + : Object.keys(_messages.value); + }, + get modifiers() { + return (_composer.value ? _composer.value.modifiers : _modifiers); + }, + get pluralRules() { + return (_composer.value ? _composer.value.pluralRules : _pluralRules); + }, + get isGlobal() { + return _composer.value ? _composer.value.isGlobal : false; + }, + get missingWarn() { + return _composer.value ? _composer.value.missingWarn : _missingWarn; + }, + set missingWarn(val) { + if (_composer.value) { + _composer.value.missingWarn = val; + } + }, + get fallbackWarn() { + return _composer.value ? _composer.value.fallbackWarn : _fallbackWarn; + }, + set fallbackWarn(val) { + if (_composer.value) { + _composer.value.missingWarn = val; + } + }, + get fallbackRoot() { + return _composer.value ? _composer.value.fallbackRoot : _fallbackRoot; + }, + set fallbackRoot(val) { + if (_composer.value) { + _composer.value.fallbackRoot = val; + } + }, + get fallbackFormat() { + return _composer.value ? _composer.value.fallbackFormat : _fallbackFormat; + }, + set fallbackFormat(val) { + if (_composer.value) { + _composer.value.fallbackFormat = val; + } + }, + get warnHtmlMessage() { + return _composer.value + ? _composer.value.warnHtmlMessage + : _warnHtmlMessage; + }, + set warnHtmlMessage(val) { + if (_composer.value) { + _composer.value.warnHtmlMessage = val; + } + }, + get escapeParameter() { + return _composer.value + ? _composer.value.escapeParameter + : _escapeParameter; + }, + set escapeParameter(val) { + if (_composer.value) { + _composer.value.escapeParameter = val; + } + }, + t, + getPostTranslationHandler, + setPostTranslationHandler, + getMissingHandler, + setMissingHandler, + rt, + d, + n, + tm, + te, + getLocaleMessage, + setLocaleMessage, + mergeLocaleMessage, + getDateTimeFormat, + setDateTimeFormat, + mergeDateTimeFormat, + getNumberFormat, + setNumberFormat, + mergeNumberFormat + }; + function sync(composer) { + composer.locale.value = _locale.value; + composer.fallbackLocale.value = _fallbackLocale.value; + Object.keys(_messages.value).forEach(locale => { + composer.mergeLocaleMessage(locale, _messages.value[locale]); + }); + Object.keys(_datetimeFormats.value).forEach(locale => { + composer.mergeDateTimeFormat(locale, _datetimeFormats.value[locale]); + }); + Object.keys(_numberFormats.value).forEach(locale => { + composer.mergeNumberFormat(locale, _numberFormats.value[locale]); + }); + composer.escapeParameter = _escapeParameter; + composer.fallbackFormat = _fallbackFormat; + composer.fallbackRoot = _fallbackRoot; + composer.fallbackWarn = _fallbackWarn; + composer.missingWarn = _missingWarn; + composer.warnHtmlMessage = _warnHtmlMessage; + } + onBeforeMount(() => { + if (instance.proxy == null || instance.proxy.$i18n == null) { + throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_COMPOSITION_IN_LEGACY); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const composer = (_composer.value = instance.proxy.$i18n + .__composer); + if (scope === 'global') { + _locale.value = composer.locale.value; + _fallbackLocale.value = composer.fallbackLocale.value; + _messages.value = composer.messages.value; + _datetimeFormats.value = composer.datetimeFormats.value; + _numberFormats.value = composer.numberFormats.value; + } + else if (isLocalScope) { + sync(composer); + } + }); + return wrapper; +} +const globalExportProps = [ + 'locale', + 'fallbackLocale', + 'availableLocales' +]; +const globalExportMethods = ['t', 'rt', 'd', 'n', 'tm', 'te'] + ; +function injectGlobalFields(app, composer) { + const i18n = Object.create(null); + globalExportProps.forEach(prop => { + const desc = Object.getOwnPropertyDescriptor(composer, prop); + if (!desc) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + const wrap = isRef(desc.value) // check computed props + ? { + get() { + return desc.value.value; + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + set(val) { + desc.value.value = val; + } + } + : { + get() { + return desc.get && desc.get(); + } + }; + Object.defineProperty(i18n, prop, wrap); + }); + app.config.globalProperties.$i18n = i18n; + globalExportMethods.forEach(method => { + const desc = Object.getOwnPropertyDescriptor(composer, method); + if (!desc || !desc.value) { + throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR); + } + Object.defineProperty(app.config.globalProperties, `$${method}`, desc); + }); + const dispose = () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete app.config.globalProperties.$i18n; + globalExportMethods.forEach(method => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete app.config.globalProperties[`$${method}`]; + }); + }; + return dispose; +} + +{ + initFeatureFlags(); +} +// register message compiler for jit compilation +if (__INTLIFY_JIT_COMPILATION__) { + registerMessageCompiler(compile); +} +// register message resolver at vue-i18n +registerMessageResolver(resolveValue); +// register fallback locale at vue-i18n +registerLocaleFallbacker(fallbackWithLocaleChain); +// NOTE: experimental !! +if ((process.env.NODE_ENV !== 'production') || __INTLIFY_PROD_DEVTOOLS__) { + const target = getGlobalThis(); + target.__INTLIFY__ = true; + setDevToolsHook(target.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__); +} +if ((process.env.NODE_ENV !== 'production')) ; + +export { DatetimeFormat, I18nD, I18nInjectionKey, I18nN, I18nT, NumberFormat, Translation, VERSION, castToVueI18n, createI18n, useI18n, vTDirective }; diff --git a/node_modules/vue-i18n/dist/vue-i18n.runtime.node.mjs b/node_modules/vue-i18n/dist/vue-i18n.runtime.node.mjs new file mode 100644 index 0000000..25bb6a5 --- /dev/null +++ b/node_modules/vue-i18n/dist/vue-i18n.runtime.node.mjs @@ -0,0 +1,2 @@ +global.__VUE_PROD_DEVTOOLS__ = false; +export * from '../dist/vue-i18n.runtime.mjs' \ No newline at end of file diff --git a/node_modules/vue-i18n/index.js b/node_modules/vue-i18n/index.js new file mode 100644 index 0000000..607e38d --- /dev/null +++ b/node_modules/vue-i18n/index.js @@ -0,0 +1,7 @@ +'use strict' + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./dist/vue-i18n.prod.cjs') +} else { + module.exports = require('./dist/vue-i18n.cjs') +} diff --git a/node_modules/vue-i18n/package.json b/node_modules/vue-i18n/package.json new file mode 100644 index 0000000..6f60506 --- /dev/null +++ b/node_modules/vue-i18n/package.json @@ -0,0 +1,91 @@ +{ + "name": "vue-i18n", + "version": "9.14.5", + "description": "Internationalization plugin for Vue.js", + "keywords": [ + "i18n", + "internationalization", + "intlify", + "plugin", + "vue", + "vue.js" + ], + "license": "MIT", + "author": { + "name": "kazuya kawaguchi", + "email": "kawakazu80@gmail.com" + }, + "homepage": "https://github.com/intlify/vue-i18n/tree/master/packages/vue-i18n#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/intlify/vue-i18n.git", + "directory": "packages/vue-i18n" + }, + "bugs": { + "url": "https://github.com/intlify/vue-i18n/issues" + }, + "files": [ + "index.js", + "dist", + "vetur" + ], + "main": "index.js", + "module": "dist/vue-i18n.mjs", + "unpkg": "dist/vue-i18n.global.js", + "jsdelivr": "dist/vue-i18n.global.js", + "types": "dist/vue-i18n.d.ts", + "dependencies": { + "@vue/devtools-api": "^6.5.0", + "@intlify/core-base": "9.14.5", + "@intlify/shared": "9.14.5" + }, + "devDependencies": { + "@intlify/devtools-if": "9.14.5", + "@intlify/vue-devtools": "9.14.5" + }, + "peerDependencies": { + "vue": "^3.0.0" + }, + "engines": { + "node": ">= 16" + }, + "buildOptions": { + "name": "VueI18n", + "formats": [ + "mjs", + "mjs-runtime", + "browser", + "browser-runtime", + "cjs", + "global", + "global-runtime" + ] + }, + "exports": { + ".": { + "types": "./dist/vue-i18n.d.ts", + "import": "./dist/vue-i18n.mjs", + "browser": "./dist/vue-i18n.esm-browser.js", + "node": { + "import": { + "production": "./dist/vue-i18n.node.mjs", + "development": "./dist/vue-i18n.mjs", + "default": "./dist/vue-i18n.mjs" + }, + "require": { + "production": "./dist/vue-i18n.prod.cjs", + "development": "./dist/vue-i18n.cjs", + "default": "./index.js" + } + } + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" + }, + "funding": "https://github.com/sponsors/kazupon", + "sideEffects": false, + "vetur": { + "tags": "vetur/tags.json", + "attributes": "vetur/attributes.json" + } +} \ No newline at end of file diff --git a/node_modules/vue-i18n/vetur/attributes.json b/node_modules/vue-i18n/vetur/attributes.json new file mode 100644 index 0000000..54184ae --- /dev/null +++ b/node_modules/vue-i18n/vetur/attributes.json @@ -0,0 +1,62 @@ +{ + "i18n-t/keypath": { + "description": "[required]\nThe locale message key can be specified prop", + "type": "string" + }, + "i18n-t/plural": { + "description": "[optional]\nThe Plural Choosing the message number prop", + "type": "number|string" + }, + "i18n-t/locale": { + "description": "[optional]\nThe locale to be used for the component", + "type": "string" + }, + "i18n-t/scope": { + "description": "[optional]\tThe scope to be used in the target component.\nYou can specify either `global` or `parent`", + "type": "string" + }, + "i18n-t/tag": { + "description": "[optional]\nUsed to wrap the content that is distribute in the slot.\nIf omitted, the slot content is treated as Fragments", + "type": "string|object" + }, + "i18n-d/value": { + "description": "[required]\nThe value specified for the target component", + "type": "number|date" + }, + "i18n-d/format": { + "description": "[optional]\nThe format to use in the target component", + "type": "string|object" + }, + "i18n-d/locale": { + "description": "[optional]\nThe locale to be used for the component", + "type": "string" + }, + "i18n-d/scope": { + "description": "[optional]\tThe scope to be used in the target component.\nYou can specify either `global` or `parent`", + "type": "string" + }, + "i18n-d/tag": { + "description": "[optional]\nUsed to wrap the content that is distribute in the slot.\nIf omitted, the slot content is treated as Fragments", + "type": "string|object" + }, + "i18n-n/value": { + "description": "[required]\nThe value specified for the target component", + "type": "number" + }, + "i18n-n/format": { + "description": "[optional]\nThe format to use in the target component", + "type": "string|object" + }, + "i18n-n/locale": { + "description": "[optional]\nThe locale to be used for the component", + "type": "string" + }, + "i18n-n/scope": { + "description": "[optional]\tThe scope to be used in the target component.\nYou can specify either `global` or `parent`", + "type": "string" + }, + "i18n-n/tag": { + "description": "[optional]\nUsed to wrap the content that is distribute in the slot.\nIf omitted, the slot content is treated as Fragments", + "type": "string|object" + } +} diff --git a/node_modules/vue-i18n/vetur/tags.json b/node_modules/vue-i18n/vetur/tags.json new file mode 100644 index 0000000..24e16fc --- /dev/null +++ b/node_modules/vue-i18n/vetur/tags.json @@ -0,0 +1,14 @@ +{ + "i18n-t": { + "attributes": ["keypath", "locale", "tag", "plural", "scope"], + "description": "This is Translation component that can be used when HTML interpolation is needed.\n\nhttps://vue-i18n.intlify.dev/guide/advanced/component.html#basic-usage" + }, + "i18n-d": { + "attributes": ["value", "format", "locale", "tag", "scope"], + "description": "This is Datetime Format component provides a way to use HTML interpolation in pair with number formatting.\n\nhttps://vue-i18n.intlify.dev/guide/essentials/datetime.html#custom-formatting" + }, + "i18n-n": { + "attributes": ["value", "format", "locale", "tag", "scope"], + "description": "This is Number Format component provides a way to use HTML interpolation in pair with number formatting.\n\nhttps://vue-i18n.intlify.dev/guide/essentials/number.html#custom-formatting" + } +} diff --git a/package-lock.json b/package-lock.json index 89dee23..939331a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@vueuse/core": "^10.7.0", "pinia": "^2.1.0", "vue": "^3.4.0", + "vue-i18n": "^9.14.5", "vue-router": "^4.3.0" }, "devDependencies": { @@ -473,6 +474,50 @@ "node": ">=12" } }, + "node_modules/@intlify/core-base": { + "version": "9.14.5", + "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.14.5.tgz", + "integrity": "sha512-5ah5FqZG4pOoHjkvs8mjtv+gPKYU0zCISaYNjBNNqYiaITxW8ZtVih3GS/oTOqN8d9/mDLyrjD46GBApNxmlsA==", + "license": "MIT", + "dependencies": { + "@intlify/message-compiler": "9.14.5", + "@intlify/shared": "9.14.5" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@intlify/message-compiler": { + "version": "9.14.5", + "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.14.5.tgz", + "integrity": "sha512-IHzgEu61/YIpQV5Pc3aRWScDcnFKWvQA9kigcINcCBXN8mbW+vk9SK+lDxA6STzKQsVJxUPg9ACC52pKKo3SVQ==", + "license": "MIT", + "dependencies": { + "@intlify/shared": "9.14.5", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@intlify/shared": { + "version": "9.14.5", + "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-9.14.5.tgz", + "integrity": "sha512-9gB+E53BYuAEMhbCAxVgG38EZrk59sxBtv3jSizNL2hEWlgjBjAw1AwpLHtNaeda12pe6W20OGEa0TwuMSRbyQ==", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.13", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", @@ -2551,6 +2596,27 @@ } } }, + "node_modules/vue-i18n": { + "version": "9.14.5", + "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.14.5.tgz", + "integrity": "sha512-0jQ9Em3ymWngyiIkj0+c/k7WgaPO+TNzjKSNq9BvBQaKJECqn9cd9fL4tkDhB5G1QBskGl9YxxbDAhgbFtpe2g==", + "deprecated": "v9 and v10 no longer supported. please migrate to v11. about maintenance status, see https://vue-i18n.intlify.dev/guide/maintenance.html", + "license": "MIT", + "dependencies": { + "@intlify/core-base": "9.14.5", + "@intlify/shared": "9.14.5", + "@vue/devtools-api": "^6.5.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + }, + "peerDependencies": { + "vue": "^3.0.0" + } + }, "node_modules/vue-router": { "version": "4.6.4", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.6.4.tgz", diff --git a/package.json b/package.json index 92c2bc6..168354a 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@vueuse/core": "^10.7.0", "pinia": "^2.1.0", "vue": "^3.4.0", + "vue-i18n": "^9.14.5", "vue-router": "^4.3.0" }, "devDependencies": { diff --git a/src/components/LanguageSwitcher.vue b/src/components/LanguageSwitcher.vue new file mode 100644 index 0000000..5edb2f9 --- /dev/null +++ b/src/components/LanguageSwitcher.vue @@ -0,0 +1,91 @@ + + + diff --git a/src/components/layout/AppHeader.vue b/src/components/layout/AppHeader.vue index 9c6d374..49410d5 100644 --- a/src/components/layout/AppHeader.vue +++ b/src/components/layout/AppHeader.vue @@ -1,12 +1,15 @@