yamchart 0.8.2 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/{advisor-3V6WKALO.js → advisor-CSVLJFOG.js} +10 -10
  2. package/dist/{chunk-77CBXDCO.js → chunk-5N3FYFBV.js} +72 -1
  3. package/dist/chunk-5N3FYFBV.js.map +1 -0
  4. package/dist/{chunk-T76DI6OA.js → chunk-QLBCPJDL.js} +4 -4
  5. package/dist/{chunk-KP4CYPBL.js → chunk-RYTMXP2R.js} +49 -7
  6. package/dist/chunk-RYTMXP2R.js.map +1 -0
  7. package/dist/{chunk-HRF7QVK5.js → chunk-VTLZAE3C.js} +2 -2
  8. package/dist/{chunk-GX2PNKES.js → chunk-VXDZEBAN.js} +21 -7
  9. package/dist/chunk-VXDZEBAN.js.map +1 -0
  10. package/dist/{connection-utils-MI7RM5BP.js → connection-utils-2SZAG2QM.js} +4 -4
  11. package/dist/{describe-46XBIND7.js → describe-ELE7CAVA.js} +5 -5
  12. package/dist/{dev-IMKOBPDZ.js → dev-AWJ7TF6G.js} +49 -18
  13. package/dist/dev-AWJ7TF6G.js.map +1 -0
  14. package/dist/dist-2OQOI2PU.js +54 -0
  15. package/dist/{dist-ONU5AKOH.js → dist-E2PVGIPT.js} +4 -2
  16. package/dist/{dist-25RTZO4E.js → dist-GVNWQXFR.js} +2 -2
  17. package/dist/index.js +34 -25
  18. package/dist/index.js.map +1 -1
  19. package/dist/{init-UYQE5DPU.js → init-GVBYCLJT.js} +14 -1
  20. package/dist/init-GVBYCLJT.js.map +1 -0
  21. package/dist/public/assets/{EventManagement-DSew47oL.js → EventManagement-DmRy5bu3.js} +1 -1
  22. package/dist/public/assets/{LoginPage-BwFMXS0X.js → LoginPage-B2bo8Eck.js} +1 -1
  23. package/dist/public/assets/{PublicViewer-70ErTigq.js → PublicViewer-B_3K2MkZ.js} +1 -1
  24. package/dist/public/assets/{SetupWizard-CR7XCMkq.js → SetupWizard-utnbmxeP.js} +1 -1
  25. package/dist/public/assets/{ShareManagement-B2ZU0Fdy.js → ShareManagement-6iYAjCrr.js} +1 -1
  26. package/dist/public/assets/{UserManagement-CHRB-6uy.js → UserManagement-DAOq9eUf.js} +1 -1
  27. package/dist/public/assets/{index-DcNtdUoV.js → index-BbSrYtxR.js} +3 -3
  28. package/dist/public/assets/{index.es-BC82iFuu.js → index.es-C-5Ej3mu.js} +1 -1
  29. package/dist/public/assets/{jspdf.es.min-DojRcwGj.js → jspdf.es.min-B-lLjljE.js} +3 -3
  30. package/dist/public/index.html +1 -1
  31. package/dist/{query-Q3B4TQTZ.js → query-P4TSQES4.js} +4 -4
  32. package/dist/{sample-PEHRM3TN.js → sample-3VDU6ZAV.js} +4 -4
  33. package/dist/{search-NBJHS4TZ.js → search-L5QA64T7.js} +5 -5
  34. package/dist/{source-resolver-2DIK3MK4.js → source-resolver-TTHGNPBK.js} +5 -5
  35. package/dist/source-resolver-TTHGNPBK.js.map +1 -0
  36. package/dist/{sync-warehouse-UGTZCZ7J.js → sync-warehouse-KGT6XSXI.js} +9 -9
  37. package/dist/{tables-ZERITKTS.js → tables-IG4RYPCG.js} +5 -5
  38. package/dist/templates/default/docs/yamchart-reference.md +50 -4
  39. package/dist/templates/default/yamchart.yaml +10 -0
  40. package/dist/templates/empty/yamchart.yaml +10 -0
  41. package/dist/{test-ME2Q6CSR.js → test-SN75DCIN.js} +4 -4
  42. package/package.json +4 -4
  43. package/dist/chunk-77CBXDCO.js.map +0 -1
  44. package/dist/chunk-GX2PNKES.js.map +0 -1
  45. package/dist/chunk-KP4CYPBL.js.map +0 -1
  46. package/dist/dev-IMKOBPDZ.js.map +0 -1
  47. package/dist/init-UYQE5DPU.js.map +0 -1
  48. /package/dist/{advisor-3V6WKALO.js.map → advisor-CSVLJFOG.js.map} +0 -0
  49. /package/dist/{chunk-T76DI6OA.js.map → chunk-QLBCPJDL.js.map} +0 -0
  50. /package/dist/{chunk-HRF7QVK5.js.map → chunk-VTLZAE3C.js.map} +0 -0
  51. /package/dist/{connection-utils-MI7RM5BP.js.map → connection-utils-2SZAG2QM.js.map} +0 -0
  52. /package/dist/{describe-46XBIND7.js.map → describe-ELE7CAVA.js.map} +0 -0
  53. /package/dist/{dist-ONU5AKOH.js.map → dist-2OQOI2PU.js.map} +0 -0
  54. /package/dist/{source-resolver-2DIK3MK4.js.map → dist-E2PVGIPT.js.map} +0 -0
  55. /package/dist/{dist-25RTZO4E.js.map → dist-GVNWQXFR.js.map} +0 -0
  56. /package/dist/{query-Q3B4TQTZ.js.map → query-P4TSQES4.js.map} +0 -0
  57. /package/dist/{sample-PEHRM3TN.js.map → sample-3VDU6ZAV.js.map} +0 -0
  58. /package/dist/{search-NBJHS4TZ.js.map → search-L5QA64T7.js.map} +0 -0
  59. /package/dist/{sync-warehouse-UGTZCZ7J.js.map → sync-warehouse-KGT6XSXI.js.map} +0 -0
  60. /package/dist/{tables-ZERITKTS.js.map → tables-IG4RYPCG.js.map} +0 -0
  61. /package/dist/{test-ME2Q6CSR.js.map → test-SN75DCIN.js.map} +0 -0
@@ -1 +1 @@
1
- import{j as e,a as p,A as j}from"./index-DcNtdUoV.js";import{a as s}from"./echarts-DtOYsfLX.js";function O(){var A;const[i,N]=s.useState([]),[b,C]=s.useState(!0),[h,v]=s.useState(!1),[x,w]=s.useState(""),[l,g]=s.useState(null),[u,c]=s.useState([]),[m,y]=s.useState(!1),d=async()=>{try{const{users:t}=await p.authListUsers();N(t)}catch{w("Failed to load users")}finally{C(!1)}};s.useEffect(()=>{d()},[]);const a=async(t,r)=>{try{await p.authUpdateUser(t,{role:r}),await d()}catch(o){alert(o instanceof j?o.message:"Failed to update role")}},f=async(t,r)=>{if(confirm(`Delete user "${r}"? This cannot be undone.`))try{await p.authDeleteUser(t),await d()}catch(o){alert(o instanceof j?o.message:"Failed to delete user")}},U=t=>{if(l===t.id)g(null),c([]);else{g(t.id);const r=JSON.parse(t.attributes||"{}");c(Object.entries(r).map(([o,n])=>({key:o,value:n})))}},k=(t,r,o)=>{c(n=>n.map((S,M)=>M===t?{...S,[r]:o}:S))},E=()=>{c(t=>[...t,{key:"",value:""}])},L=t=>{c(r=>r.filter((o,n)=>n!==t))},D=async()=>{if(l){y(!0);try{const t={};for(const{key:r,value:o}of u){const n=r.trim();n&&(t[n]=o)}await p.authUpdateUser(l,{attributes:t}),await d(),c(Object.entries(t).map(([r,o])=>({key:r,value:o})))}catch(t){alert(t instanceof j?t.message:"Failed to save attributes")}finally{y(!1)}}};return b?e.jsx("div",{className:"p-6",style:{color:"var(--yc-color-text-secondary)"},children:"Loading users..."}):e.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-xl font-semibold",style:{color:"var(--yc-color-text)"},children:"User Management"}),e.jsx("button",{onClick:()=>v(!0),className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700",children:"Add User"})]}),x&&e.jsx("div",{className:"text-sm rounded-md px-4 py-3 mb-4",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--yc-color-danger) 30%, transparent)",color:"var(--yc-color-danger)"},children:x}),e.jsx("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:e.jsxs("table",{className:"w-full yc-table",children:[e.jsx("thead",{className:"border-b",style:{backgroundColor:"var(--yc-color-input-bg)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-3 text-right text-xs font-medium w-10",style:{color:"var(--yc-color-text-muted)"},children:"#"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Name"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Email"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Role"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Created"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium uppercase",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y",style:{borderColor:"var(--yc-color-border)"},children:i.map((t,r)=>e.jsxs("tr",{className:"group",children:[e.jsx("td",{className:"px-3 py-3 text-right text-sm yc-row-num w-10",children:r+1}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text)"},children:t.name}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:t.email}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("select",{value:t.role,onChange:o=>a(t.id,o.target.value),className:"text-sm border rounded px-2 py-1",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},children:[e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"viewer",children:"Viewer"})]})}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:new Date(t.created_at).toLocaleDateString()}),e.jsxs("td",{className:"px-4 py-3 text-right space-x-3",children:[e.jsx("button",{onClick:()=>U(t),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-primary)"},children:l===t.id?"Hide Attrs":"Attrs"}),e.jsx("button",{onClick:()=>f(t.id,t.name),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-danger)"},children:"Delete"})]})]},t.id))})]})}),l&&e.jsxs("div",{className:"mt-4 rounded-lg p-4",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium",style:{color:"var(--yc-color-text-secondary)"},children:["Attributes for ",(A=i.find(t=>t.id===l))==null?void 0:A.name]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:E,className:"px-3 py-1 text-xs font-medium rounded hover:opacity-80",style:{color:"var(--yc-color-primary)",border:"1px solid color-mix(in srgb, var(--yc-color-primary) 50%, transparent)"},children:"Add Attribute"}),e.jsx("button",{onClick:D,disabled:m,className:"px-3 py-1 text-xs font-medium text-white bg-blue-600 rounded hover:bg-blue-700 disabled:opacity-50",children:m?"Saving...":"Save"})]})]}),u.length===0?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:'No attributes. Click "Add Attribute" to define key-value pairs for row-level security.'}):e.jsx("div",{className:"space-y-2",children:u.map((t,r)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",placeholder:"Key (e.g. department)",value:t.key,onChange:o=>k(r,"key",o.target.value),className:"flex-1 px-3 py-1.5 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}}),e.jsx("input",{type:"text",placeholder:"Value (e.g. Sales)",value:t.value,onChange:o=>k(r,"value",o.target.value),className:"flex-1 px-3 py-1.5 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}}),e.jsx("button",{onClick:()=>L(r),className:"p-1.5 hover:opacity-80",style:{color:"var(--yc-color-text-muted)"},title:"Remove attribute",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},r))})]}),h&&e.jsx(R,{onClose:()=>v(!1),onCreated:d})]})}function R({onClose:i,onCreated:N}){const[b,C]=s.useState(""),[h,v]=s.useState(""),[x,w]=s.useState(""),[l,g]=s.useState("viewer"),[u,c]=s.useState(""),[m,y]=s.useState(!1),d=async a=>{a.preventDefault(),c(""),y(!0);try{await p.authCreateUser({email:b,name:h,password:x,role:l}),N(),i()}catch(f){c(f instanceof j?f.message:"Failed to create user")}finally{y(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:i,children:e.jsxs("div",{className:"rounded-lg shadow-lg p-6 w-full max-w-md",style:{backgroundColor:"var(--yc-color-surface)"},onClick:a=>a.stopPropagation(),children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",style:{color:"var(--yc-color-text)"},children:"Add User"}),u&&e.jsx("div",{className:"text-sm rounded-md px-4 py-3 mb-4",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--yc-color-danger) 30%, transparent)",color:"var(--yc-color-danger)"},children:u}),e.jsxs("form",{onSubmit:d,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Name"}),e.jsx("input",{type:"text",value:h,onChange:a=>v(a.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Email"}),e.jsx("input",{type:"email",value:b,onChange:a=>C(a.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Temporary Password"}),e.jsx("input",{type:"password",value:x,onChange:a=>w(a.target.value),required:!0,minLength:8,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Role"}),e.jsxs("select",{value:l,onChange:a=>g(a.target.value),className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},children:[e.jsx("option",{value:"viewer",children:"Viewer"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"admin",children:"Admin"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:i,className:"px-4 py-2 text-sm hover:bg-black/5 rounded-md",style:{color:"var(--yc-color-text-secondary)"},children:"Cancel"}),e.jsx("button",{type:"submit",disabled:m,className:"px-4 py-2 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50",children:m?"Creating...":"Create User"})]})]})]})})}export{O as UserManagement};
1
+ import{j as e,a as p,A as j}from"./index-BbSrYtxR.js";import{a as s}from"./echarts-DtOYsfLX.js";function O(){var A;const[i,N]=s.useState([]),[b,C]=s.useState(!0),[h,v]=s.useState(!1),[x,w]=s.useState(""),[l,g]=s.useState(null),[u,c]=s.useState([]),[m,y]=s.useState(!1),d=async()=>{try{const{users:t}=await p.authListUsers();N(t)}catch{w("Failed to load users")}finally{C(!1)}};s.useEffect(()=>{d()},[]);const a=async(t,r)=>{try{await p.authUpdateUser(t,{role:r}),await d()}catch(o){alert(o instanceof j?o.message:"Failed to update role")}},f=async(t,r)=>{if(confirm(`Delete user "${r}"? This cannot be undone.`))try{await p.authDeleteUser(t),await d()}catch(o){alert(o instanceof j?o.message:"Failed to delete user")}},U=t=>{if(l===t.id)g(null),c([]);else{g(t.id);const r=JSON.parse(t.attributes||"{}");c(Object.entries(r).map(([o,n])=>({key:o,value:n})))}},k=(t,r,o)=>{c(n=>n.map((S,M)=>M===t?{...S,[r]:o}:S))},E=()=>{c(t=>[...t,{key:"",value:""}])},L=t=>{c(r=>r.filter((o,n)=>n!==t))},D=async()=>{if(l){y(!0);try{const t={};for(const{key:r,value:o}of u){const n=r.trim();n&&(t[n]=o)}await p.authUpdateUser(l,{attributes:t}),await d(),c(Object.entries(t).map(([r,o])=>({key:r,value:o})))}catch(t){alert(t instanceof j?t.message:"Failed to save attributes")}finally{y(!1)}}};return b?e.jsx("div",{className:"p-6",style:{color:"var(--yc-color-text-secondary)"},children:"Loading users..."}):e.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-xl font-semibold",style:{color:"var(--yc-color-text)"},children:"User Management"}),e.jsx("button",{onClick:()=>v(!0),className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700",children:"Add User"})]}),x&&e.jsx("div",{className:"text-sm rounded-md px-4 py-3 mb-4",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--yc-color-danger) 30%, transparent)",color:"var(--yc-color-danger)"},children:x}),e.jsx("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:e.jsxs("table",{className:"w-full yc-table",children:[e.jsx("thead",{className:"border-b",style:{backgroundColor:"var(--yc-color-input-bg)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-3 text-right text-xs font-medium w-10",style:{color:"var(--yc-color-text-muted)"},children:"#"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Name"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Email"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Role"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Created"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium uppercase",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y",style:{borderColor:"var(--yc-color-border)"},children:i.map((t,r)=>e.jsxs("tr",{className:"group",children:[e.jsx("td",{className:"px-3 py-3 text-right text-sm yc-row-num w-10",children:r+1}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text)"},children:t.name}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:t.email}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("select",{value:t.role,onChange:o=>a(t.id,o.target.value),className:"text-sm border rounded px-2 py-1",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},children:[e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"viewer",children:"Viewer"})]})}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:new Date(t.created_at).toLocaleDateString()}),e.jsxs("td",{className:"px-4 py-3 text-right space-x-3",children:[e.jsx("button",{onClick:()=>U(t),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-primary)"},children:l===t.id?"Hide Attrs":"Attrs"}),e.jsx("button",{onClick:()=>f(t.id,t.name),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-danger)"},children:"Delete"})]})]},t.id))})]})}),l&&e.jsxs("div",{className:"mt-4 rounded-lg p-4",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium",style:{color:"var(--yc-color-text-secondary)"},children:["Attributes for ",(A=i.find(t=>t.id===l))==null?void 0:A.name]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:E,className:"px-3 py-1 text-xs font-medium rounded hover:opacity-80",style:{color:"var(--yc-color-primary)",border:"1px solid color-mix(in srgb, var(--yc-color-primary) 50%, transparent)"},children:"Add Attribute"}),e.jsx("button",{onClick:D,disabled:m,className:"px-3 py-1 text-xs font-medium text-white bg-blue-600 rounded hover:bg-blue-700 disabled:opacity-50",children:m?"Saving...":"Save"})]})]}),u.length===0?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:'No attributes. Click "Add Attribute" to define key-value pairs for row-level security.'}):e.jsx("div",{className:"space-y-2",children:u.map((t,r)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",placeholder:"Key (e.g. department)",value:t.key,onChange:o=>k(r,"key",o.target.value),className:"flex-1 px-3 py-1.5 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}}),e.jsx("input",{type:"text",placeholder:"Value (e.g. Sales)",value:t.value,onChange:o=>k(r,"value",o.target.value),className:"flex-1 px-3 py-1.5 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}}),e.jsx("button",{onClick:()=>L(r),className:"p-1.5 hover:opacity-80",style:{color:"var(--yc-color-text-muted)"},title:"Remove attribute",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},r))})]}),h&&e.jsx(R,{onClose:()=>v(!1),onCreated:d})]})}function R({onClose:i,onCreated:N}){const[b,C]=s.useState(""),[h,v]=s.useState(""),[x,w]=s.useState(""),[l,g]=s.useState("viewer"),[u,c]=s.useState(""),[m,y]=s.useState(!1),d=async a=>{a.preventDefault(),c(""),y(!0);try{await p.authCreateUser({email:b,name:h,password:x,role:l}),N(),i()}catch(f){c(f instanceof j?f.message:"Failed to create user")}finally{y(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:i,children:e.jsxs("div",{className:"rounded-lg shadow-lg p-6 w-full max-w-md",style:{backgroundColor:"var(--yc-color-surface)"},onClick:a=>a.stopPropagation(),children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",style:{color:"var(--yc-color-text)"},children:"Add User"}),u&&e.jsx("div",{className:"text-sm rounded-md px-4 py-3 mb-4",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--yc-color-danger) 30%, transparent)",color:"var(--yc-color-danger)"},children:u}),e.jsxs("form",{onSubmit:d,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Name"}),e.jsx("input",{type:"text",value:h,onChange:a=>v(a.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Email"}),e.jsx("input",{type:"email",value:b,onChange:a=>C(a.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Temporary Password"}),e.jsx("input",{type:"password",value:x,onChange:a=>w(a.target.value),required:!0,minLength:8,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Role"}),e.jsxs("select",{value:l,onChange:a=>g(a.target.value),className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},children:[e.jsx("option",{value:"viewer",children:"Viewer"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"admin",children:"Admin"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:i,className:"px-4 py-2 text-sm hover:bg-black/5 rounded-md",style:{color:"var(--yc-color-text-secondary)"},children:"Cancel"}),e.jsx("button",{type:"submit",disabled:m,className:"px-4 py-2 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50",children:m?"Creating...":"Create User"})]})]})]})})}export{O as UserManagement};
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LoginPage-BwFMXS0X.js","assets/echarts-DtOYsfLX.js","assets/SetupWizard-CR7XCMkq.js","assets/UserManagement-CHRB-6uy.js","assets/ShareManagement-B2ZU0Fdy.js","assets/PublicViewer-70ErTigq.js","assets/EventManagement-DSew47oL.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LoginPage-B2bo8Eck.js","assets/echarts-DtOYsfLX.js","assets/SetupWizard-utnbmxeP.js","assets/UserManagement-DAOq9eUf.js","assets/ShareManagement-6iYAjCrr.js","assets/PublicViewer-B_3K2MkZ.js","assets/EventManagement-DmRy5bu3.js"])))=>i.map(i=>d[i]);
2
2
  var zw=Object.defineProperty;var Lg=e=>{throw TypeError(e)};var Ww=(e,t,n)=>t in e?zw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Fe=(e,t,n)=>Ww(e,typeof t!="symbol"?t+"":t,n),Nh=(e,t,n)=>t.has(e)||Lg("Cannot "+n);var W=(e,t,n)=>(Nh(e,t,"read from private field"),n?n.call(e):t.get(e)),Be=(e,t,n)=>t.has(e)?Lg("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ae=(e,t,n,r)=>(Nh(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),st=(e,t,n)=>(Nh(e,t,"access private method"),n);var Ec=(e,t,n,r)=>({set _(o){Ae(e,t,o,n)},get _(){return W(e,t,r)}});import{r as fa,a as N,R as Me,E as Yw,g as xx}from"./echarts-DtOYsfLX.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();var Dh={exports:{}},fl={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.min.js
@@ -75,7 +75,7 @@ Error generating stack: `+w.message+`
75
75
  border: 2px solid var(--yc-color-primary, #2563eb);
76
76
  }
77
77
  .rdp-day_button:hover { background-color: var(--yc-color-surface-hover, #e5e7eb) !important; }
78
- `;function A3({isOpen:e,onClose:t,events:n,allEvents:r,chartName:o,canEdit:i,eventsVisible:l,onToggleVisible:c,themePalette:d}){const h=Wn(),[p,y]=N.useState(!1),[b,v]=N.useState(""),[D,S]=N.useState(""),[E,T]=N.useState(""),[k,O]=N.useState(""),[I,L]=N.useState(!1),[_,C]=N.useState(""),[A,P]=N.useState(!1),[H,B]=N.useState(!1),z=N.useRef(null),Q=N.useRef(null),q=N.useRef(null),[X,ie]=N.useState(null),[ge,te]=N.useState(null),[de,M]=N.useState(""),V=N.useRef(null),[ae,j]=N.useState(null),[le,pe]=N.useState(null),ye=N.useRef(null),Ne=N.useRef(null),[G,Z]=N.useState(null);N.useEffect(()=>{var oe;p&&((oe=z.current)==null||oe.focus())},[p]),N.useEffect(()=>{var oe;ge&&((oe=V.current)==null||oe.focus())},[ge]),N.useEffect(()=>{if(!A)return;function oe(re){Q.current&&!Q.current.contains(re.target)&&P(!1)}return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[A]),N.useEffect(()=>{if(!H)return;function oe(re){q.current&&!q.current.contains(re.target)&&B(!1)}return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[H]),N.useEffect(()=>{if(ae===null)return;function oe(re){ye.current&&!ye.current.contains(re.target)&&j(null)}return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[ae]),N.useEffect(()=>{if(le===null)return;function oe(re){Ne.current&&!Ne.current.contains(re.target)&&pe(null)}return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[le]);const ue=Ka({mutationFn:oe=>xt.createChartEvent(oe),onSuccess:()=>{h.invalidateQueries({queryKey:["chartEvents"]}),Re()}}),me=Ka({mutationFn:oe=>xt.deleteChartEvent(oe),onSuccess:()=>h.invalidateQueries({queryKey:["chartEvents"]})}),Ce=Ka({mutationFn:({index:oe,event:re})=>xt.updateChartEvent(oe,re),onSuccess:()=>{h.invalidateQueries({queryKey:["chartEvents"]}),ie(null),te(null)}});function Re(){y(!1),v(""),S(""),T(""),O(""),L(!1),C(""),P(!1),B(!1)}function tt(){!D.trim()||!b.trim()||ue.mutate({date:D.trim(),label:b.trim(),...k.trim()?{description:k.trim()}:{},...E.trim()?{color:E.trim()}:{},...I&&_.trim()?{endDate:_.trim()}:{},charts:[o]})}function Ge(oe){return r.findIndex(re=>re.date===oe.date&&re.label===oe.label&&(re.description??"")===(oe.description??"")&&(re.endDate??"")===(oe.endDate??""))}function nt(oe){Z(oe)}function we(){if(!G)return;const oe=Ge(G);oe!==-1&&(me.mutate(oe),Z(null))}function je(oe){if(X===null||!ge)return;const re=Ge(oe);if(re===-1)return;const xe=oe[ge]??"";if(de===xe){ie(null),te(null);return}Ce.mutate({index:re,event:{...oe,[ge]:de}})}return e?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 bg-black/20 z-40",onClick:t}),f.jsxs("div",{className:"fixed top-0 right-0 bottom-0 w-[400px] max-w-[90vw] z-50 flex flex-col shadow-xl border-l",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)"},children:[f.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b flex-shrink-0",style:{borderColor:"var(--yc-color-border)"},children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--yc-color-text)",fontFamily:"var(--yc-font-heading)"},children:"Events"}),n.length>0&&f.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-primary) 15%, transparent)",color:"var(--yc-color-primary)"},children:n.length})]}),f.jsx("button",{onClick:t,className:"p-1.5 rounded hover:bg-black/5 transition-colors",style:{color:"var(--yc-color-text-secondary)"},children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between p-3 rounded",style:{backgroundColor:"var(--yc-color-background)",border:"1px solid var(--yc-color-border)"},children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-sm font-medium",style:{color:"var(--yc-color-text)"},children:"Show on chart"}),f.jsx("div",{className:"text-xs",style:{color:"var(--yc-color-text-secondary)"},children:"Display event markers as dashed lines"})]}),f.jsx("button",{onClick:c,className:"relative w-10 h-5 rounded-full transition-colors flex-shrink-0",style:{backgroundColor:l?"var(--yc-color-primary, #3b82f6)":"var(--yc-color-border)"},children:f.jsx("span",{className:"absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform",style:{left:l?22:2}})})]}),i&&!p&&f.jsxs("button",{onClick:()=>y(!0),className:"w-full flex items-center justify-center gap-2 px-3 py-2 text-sm rounded border border-dashed transition-colors hover:opacity-80",style:{borderColor:"var(--yc-color-border)",color:"var(--yc-color-primary)"},children:[f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add event"]}),p&&f.jsxs("div",{className:"p-3 rounded space-y-2",style:{backgroundColor:"var(--yc-color-background)",border:"1px solid var(--yc-color-border)"},children:[f.jsx("div",{className:"text-xs font-medium mb-2",style:{color:"var(--yc-color-text-secondary)"},children:"New event"}),f.jsxs("div",{className:"relative",children:[f.jsx("button",{onClick:()=>P(!A),className:"w-full px-2 py-1.5 text-sm rounded border text-left",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)",color:D?"var(--yc-color-text)":"var(--yc-color-text-muted)"},children:D||(I?"Start date":"Select date")}),A&&f.jsxs("div",{ref:Q,className:"absolute z-50 rounded-lg shadow-lg p-2 mt-1",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[f.jsx("style",{children:Nc}),f.jsx(Qa,{mode:"single",numberOfMonths:1,selected:D?ws(D,"yyyy-MM-dd",new Date):void 0,onSelect:oe=>{oe&&(S(on(oe,"yyyy-MM-dd")),P(!1))}})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-xs",style:{color:"var(--yc-color-text-muted)"},children:"Multi-day"}),f.jsx("button",{onClick:()=>{L(!I),I&&(C(""),B(!1))},className:"relative w-10 h-5 rounded-full transition-colors flex-shrink-0",style:{backgroundColor:I?"var(--yc-color-primary, #3b82f6)":"var(--yc-color-border)"},children:f.jsx("span",{className:"absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform",style:{left:I?22:2}})})]}),I&&f.jsxs("div",{className:"relative",children:[f.jsx("button",{onClick:()=>B(!H),className:"w-full px-2 py-1.5 text-sm rounded border text-left",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)",color:_?"var(--yc-color-text)":"var(--yc-color-text-muted)"},children:_||"End date"}),H&&f.jsxs("div",{ref:q,className:"absolute z-50 rounded-lg shadow-lg p-2 mt-1",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[f.jsx("style",{children:Nc}),f.jsx(Qa,{mode:"single",numberOfMonths:1,selected:_?ws(_,"yyyy-MM-dd",new Date):void 0,onSelect:oe=>{oe&&(C(on(oe,"yyyy-MM-dd")),B(!1))}})]})]}),f.jsx("input",{ref:z,type:"text",value:b,onChange:oe=>v(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&tt(),oe.key==="Escape"&&Re()},placeholder:"Event label",className:"w-full px-2 py-1.5 text-sm rounded border",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}}),f.jsxs("div",{children:[f.jsx("textarea",{value:k,onChange:oe=>O(oe.target.value),onKeyDown:oe=>{oe.key==="Escape"&&Re()},placeholder:"Description (optional)",rows:2,className:"w-full px-2 py-1.5 text-sm rounded border resize-y",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}}),f.jsxs("div",{className:"text-[10px] mt-0.5",style:{color:"var(--yc-color-text-muted)"},children:["Supports ",f.jsx("a",{href:"https://www.markdownguide.org/basic-syntax/",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--yc-color-primary)",textDecoration:"underline"},children:"Markdown"})]})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-xs mb-1",style:{color:"var(--yc-color-text-muted)"},children:"Color (optional)"}),f.jsx(F0,{value:E,onChange:T,themePalette:d})]}),f.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[f.jsx("button",{onClick:Re,className:"px-2 py-1 text-xs rounded",style:{color:"var(--yc-color-text-muted)"},children:"Cancel"}),f.jsx("button",{onClick:tt,disabled:!D.trim()||!b.trim()||ue.isPending,className:"px-2 py-1 text-xs rounded text-white disabled:opacity-50",style:{backgroundColor:"var(--yc-color-primary, #3b82f6)"},children:ue.isPending?"Saving...":"Save"})]})]}),n.length===0?f.jsxs("div",{className:"text-center py-8",children:[f.jsx("div",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:"No events for this chart"}),f.jsx("div",{className:"text-xs mt-1",style:{color:"var(--yc-color-text-muted)"},children:"Events appear as dashed vertical lines on the chart"})]}):f.jsx("div",{className:"space-y-1",children:n.map((oe,re)=>f.jsxs("div",{className:"group flex items-start gap-3 p-3 rounded transition-colors hover:bg-black/[0.03]",style:{border:"1px solid transparent"},children:[i?f.jsx("div",{className:"flex-shrink-0 mt-0.5",children:f.jsx(F0,{value:oe.color??"",onChange:xe=>{const Oe=Ge(oe);Oe!==-1&&Ce.mutate({index:Oe,event:{...oe,...xe?{color:xe}:{color:void 0}}})},themePalette:d,compact:!0})}):f.jsx("span",{className:"w-3 h-3 rounded-full flex-shrink-0 mt-0.5",style:{backgroundColor:oe.color||"#6366f1"}}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"text-xs relative flex items-center gap-1",style:{color:"var(--yc-color-text-secondary)"},children:[f.jsx("span",{style:{cursor:i?"pointer":"default"},onClick:xe=>{i&&(xe.stopPropagation(),j(ae===re?null:re),pe(null))},children:oe.date}),ae===re&&f.jsxs("div",{ref:ye,className:"absolute z-50 rounded-lg shadow-lg p-2",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:0},children:[f.jsx("style",{children:Nc}),f.jsx(Qa,{mode:"single",numberOfMonths:1,selected:(()=>{try{return ws(oe.date,"yyyy-MM-dd",new Date)}catch{return}})(),defaultMonth:(()=>{try{return ws(oe.date,"yyyy-MM-dd",new Date)}catch{return}})(),onSelect:xe=>{if(!xe)return;const Oe=on(xe,"yyyy-MM-dd");if(j(null),Oe===oe.date)return;const qe=Ge(oe);qe!==-1&&Ce.mutate({index:qe,event:{...oe,date:Oe}})}})]}),oe.endDate&&f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"→"}),f.jsx("span",{style:{cursor:i?"pointer":"default"},onClick:xe=>{i&&(xe.stopPropagation(),pe(le===re?null:re),j(null))},children:oe.endDate}),le===re&&f.jsxs("div",{ref:Ne,className:"absolute z-50 rounded-lg shadow-lg p-2",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:0},children:[f.jsx("style",{children:Nc}),f.jsx(Qa,{mode:"single",numberOfMonths:1,selected:(()=>{try{return ws(oe.endDate,"yyyy-MM-dd",new Date)}catch{return}})(),defaultMonth:(()=>{try{return ws(oe.endDate,"yyyy-MM-dd",new Date)}catch{return}})(),onSelect:xe=>{if(!xe)return;const Oe=on(xe,"yyyy-MM-dd");if(pe(null),Oe===oe.endDate)return;const qe=Ge(oe);qe!==-1&&Ce.mutate({index:qe,event:{...oe,endDate:Oe}})}})]})]})]}),X===re&&ge==="label"?f.jsx("input",{ref:V,type:"text",value:de,onChange:xe=>M(xe.target.value),onBlur:()=>je(oe),onKeyDown:xe=>{xe.key==="Enter"&&je(oe),xe.key==="Escape"&&(ie(null),te(null))},className:"w-full py-0 text-sm font-medium border-0 border-b outline-none",style:{backgroundColor:"transparent",borderColor:"var(--yc-color-primary, #3b82f6)",color:"var(--yc-color-text)",borderBottomWidth:1,borderBottomStyle:"solid"}}):f.jsx("div",{className:"text-sm font-medium truncate",style:{color:"var(--yc-color-text)",cursor:i?"pointer":"default"},onClick:()=>{i&&(ie(re),te("label"),M(oe.label))},children:oe.label}),X===re&&ge==="description"?f.jsx("input",{ref:V,type:"text",value:de,onChange:xe=>M(xe.target.value),onBlur:()=>je(oe),onKeyDown:xe=>{xe.key==="Enter"&&je(oe),xe.key==="Escape"&&(ie(null),te(null))},placeholder:"Add description",className:"w-full py-0 text-xs border-0 border-b outline-none mt-0.5",style:{backgroundColor:"transparent",borderColor:"var(--yc-color-primary, #3b82f6)",color:"var(--yc-color-text)",borderBottomWidth:1,borderBottomStyle:"solid"}}):f.jsx("div",{className:"text-xs truncate mt-0.5",style:{color:oe.description?"var(--yc-color-text-secondary)":"var(--yc-color-text-muted)",cursor:i?"pointer":"default"},onClick:()=>{i&&(ie(re),te("description"),M(oe.description??""))},children:oe.description||(i?"Add description":"")}),oe.charts&&oe.charts.length>0&&f.jsx("div",{className:"text-xs mt-1",style:{color:"var(--yc-color-text-muted)"},children:oe.charts.length===1&&oe.charts[0]===o?"This chart only":`${oe.charts.length} charts`})]}),i&&f.jsx("button",{onClick:()=>nt(oe),className:"opacity-0 group-hover:opacity-100 p-1 rounded hover:bg-black/5 transition-all flex-shrink-0",style:{color:"var(--yc-color-danger, #ef4444)"},title:"Delete event",children:f.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})]},`${oe.date}-${oe.label}-${re}`))})]})]}),f.jsx(O3,{open:G!==null,title:"Delete event",message:`Delete "${G==null?void 0:G.label}"? This cannot be undone.`,onConfirm:we,onCancel:()=>Z(null)})]}):null}async function I3(e,t,n="png"){const{default:r}=await ls(async()=>{const{default:l}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:l}},[]),i=(await r(e,{backgroundColor:"#f9fafb",scale:2,useCORS:!0,logging:!1})).toDataURL(`image/${n}`,n==="jpeg"?.9:void 0);Zc(i,`${t}.${n}`)}async function M3(e,t,n){const[{default:r},{jsPDF:o}]=await Promise.all([ls(()=>import("./html2canvas.esm-QH1iLAAe.js"),[]),ls(()=>import("./jspdf.es.min-DojRcwGj.js").then(I=>I.j),[])]),i=await r(e,{backgroundColor:"#f9fafb",scale:2,useCORS:!0,logging:!1}),l=i.toDataURL("image/png"),c=i.width,d=i.height,p=c/d>1,y=new o({orientation:p?"landscape":"portrait",unit:"mm"}),b=y.internal.pageSize.getWidth(),v=y.internal.pageSize.getHeight();let D=10;n&&(y.setFontSize(16),y.text(n,b/2,D,{align:"center"}),D=20);const S=b-20,E=v-D-10;let T=S,k=d/c*T;k>E&&(k=E,T=c/d*k);const O=(b-T)/2;y.addImage(l,"PNG",O,D,T,k),y.save(`${t}.pdf`)}async function L3(e,t,n){const{jsPDF:r}=await ls(async()=>{const{jsPDF:E}=await import("./jspdf.es.min-DojRcwGj.js").then(T=>T.j);return{jsPDF:E}},[]),o=new Image;o.src=e,await new Promise(E=>{o.onload=E});const l=o.width/o.height>1.2,c=new r({orientation:l?"landscape":"portrait",unit:"mm"}),d=c.internal.pageSize.getWidth(),h=c.internal.pageSize.getHeight();let p=15;n&&(c.setFontSize(14),c.text(n,d/2,10,{align:"center"}));const y=d-20,b=h-p-15;let v=y,D=o.height/o.width*v;D>b&&(D=b,v=o.width/o.height*D);const S=(d-v)/2;c.addImage(e,"PNG",S,p,v,D),c.save(`${t}.pdf`)}function Ed(e,t,n){if(e.length===0)return;const r=t.map(l=>l.name),o=e.map(l=>t.map(c=>{const d=l[c.name];if(d==null)return"";const h=String(d);return h.includes(",")||h.includes('"')||h.includes(`
78
+ `;function A3({isOpen:e,onClose:t,events:n,allEvents:r,chartName:o,canEdit:i,eventsVisible:l,onToggleVisible:c,themePalette:d}){const h=Wn(),[p,y]=N.useState(!1),[b,v]=N.useState(""),[D,S]=N.useState(""),[E,T]=N.useState(""),[k,O]=N.useState(""),[I,L]=N.useState(!1),[_,C]=N.useState(""),[A,P]=N.useState(!1),[H,B]=N.useState(!1),z=N.useRef(null),Q=N.useRef(null),q=N.useRef(null),[X,ie]=N.useState(null),[ge,te]=N.useState(null),[de,M]=N.useState(""),V=N.useRef(null),[ae,j]=N.useState(null),[le,pe]=N.useState(null),ye=N.useRef(null),Ne=N.useRef(null),[G,Z]=N.useState(null);N.useEffect(()=>{var oe;p&&((oe=z.current)==null||oe.focus())},[p]),N.useEffect(()=>{var oe;ge&&((oe=V.current)==null||oe.focus())},[ge]),N.useEffect(()=>{if(!A)return;function oe(re){Q.current&&!Q.current.contains(re.target)&&P(!1)}return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[A]),N.useEffect(()=>{if(!H)return;function oe(re){q.current&&!q.current.contains(re.target)&&B(!1)}return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[H]),N.useEffect(()=>{if(ae===null)return;function oe(re){ye.current&&!ye.current.contains(re.target)&&j(null)}return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[ae]),N.useEffect(()=>{if(le===null)return;function oe(re){Ne.current&&!Ne.current.contains(re.target)&&pe(null)}return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[le]);const ue=Ka({mutationFn:oe=>xt.createChartEvent(oe),onSuccess:()=>{h.invalidateQueries({queryKey:["chartEvents"]}),Re()}}),me=Ka({mutationFn:oe=>xt.deleteChartEvent(oe),onSuccess:()=>h.invalidateQueries({queryKey:["chartEvents"]})}),Ce=Ka({mutationFn:({index:oe,event:re})=>xt.updateChartEvent(oe,re),onSuccess:()=>{h.invalidateQueries({queryKey:["chartEvents"]}),ie(null),te(null)}});function Re(){y(!1),v(""),S(""),T(""),O(""),L(!1),C(""),P(!1),B(!1)}function tt(){!D.trim()||!b.trim()||ue.mutate({date:D.trim(),label:b.trim(),...k.trim()?{description:k.trim()}:{},...E.trim()?{color:E.trim()}:{},...I&&_.trim()?{endDate:_.trim()}:{},charts:[o]})}function Ge(oe){return r.findIndex(re=>re.date===oe.date&&re.label===oe.label&&(re.description??"")===(oe.description??"")&&(re.endDate??"")===(oe.endDate??""))}function nt(oe){Z(oe)}function we(){if(!G)return;const oe=Ge(G);oe!==-1&&(me.mutate(oe),Z(null))}function je(oe){if(X===null||!ge)return;const re=Ge(oe);if(re===-1)return;const xe=oe[ge]??"";if(de===xe){ie(null),te(null);return}Ce.mutate({index:re,event:{...oe,[ge]:de}})}return e?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 bg-black/20 z-40",onClick:t}),f.jsxs("div",{className:"fixed top-0 right-0 bottom-0 w-[400px] max-w-[90vw] z-50 flex flex-col shadow-xl border-l",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)"},children:[f.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b flex-shrink-0",style:{borderColor:"var(--yc-color-border)"},children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--yc-color-text)",fontFamily:"var(--yc-font-heading)"},children:"Events"}),n.length>0&&f.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-primary) 15%, transparent)",color:"var(--yc-color-primary)"},children:n.length})]}),f.jsx("button",{onClick:t,className:"p-1.5 rounded hover:bg-black/5 transition-colors",style:{color:"var(--yc-color-text-secondary)"},children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between p-3 rounded",style:{backgroundColor:"var(--yc-color-background)",border:"1px solid var(--yc-color-border)"},children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-sm font-medium",style:{color:"var(--yc-color-text)"},children:"Show on chart"}),f.jsx("div",{className:"text-xs",style:{color:"var(--yc-color-text-secondary)"},children:"Display event markers as dashed lines"})]}),f.jsx("button",{onClick:c,className:"relative w-10 h-5 rounded-full transition-colors flex-shrink-0",style:{backgroundColor:l?"var(--yc-color-primary, #3b82f6)":"var(--yc-color-border)"},children:f.jsx("span",{className:"absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform",style:{left:l?22:2}})})]}),i&&!p&&f.jsxs("button",{onClick:()=>y(!0),className:"w-full flex items-center justify-center gap-2 px-3 py-2 text-sm rounded border border-dashed transition-colors hover:opacity-80",style:{borderColor:"var(--yc-color-border)",color:"var(--yc-color-primary)"},children:[f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add event"]}),p&&f.jsxs("div",{className:"p-3 rounded space-y-2",style:{backgroundColor:"var(--yc-color-background)",border:"1px solid var(--yc-color-border)"},children:[f.jsx("div",{className:"text-xs font-medium mb-2",style:{color:"var(--yc-color-text-secondary)"},children:"New event"}),f.jsxs("div",{className:"relative",children:[f.jsx("button",{onClick:()=>P(!A),className:"w-full px-2 py-1.5 text-sm rounded border text-left",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)",color:D?"var(--yc-color-text)":"var(--yc-color-text-muted)"},children:D||(I?"Start date":"Select date")}),A&&f.jsxs("div",{ref:Q,className:"absolute z-50 rounded-lg shadow-lg p-2 mt-1",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[f.jsx("style",{children:Nc}),f.jsx(Qa,{mode:"single",numberOfMonths:1,selected:D?ws(D,"yyyy-MM-dd",new Date):void 0,onSelect:oe=>{oe&&(S(on(oe,"yyyy-MM-dd")),P(!1))}})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-xs",style:{color:"var(--yc-color-text-muted)"},children:"Multi-day"}),f.jsx("button",{onClick:()=>{L(!I),I&&(C(""),B(!1))},className:"relative w-10 h-5 rounded-full transition-colors flex-shrink-0",style:{backgroundColor:I?"var(--yc-color-primary, #3b82f6)":"var(--yc-color-border)"},children:f.jsx("span",{className:"absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform",style:{left:I?22:2}})})]}),I&&f.jsxs("div",{className:"relative",children:[f.jsx("button",{onClick:()=>B(!H),className:"w-full px-2 py-1.5 text-sm rounded border text-left",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)",color:_?"var(--yc-color-text)":"var(--yc-color-text-muted)"},children:_||"End date"}),H&&f.jsxs("div",{ref:q,className:"absolute z-50 rounded-lg shadow-lg p-2 mt-1",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[f.jsx("style",{children:Nc}),f.jsx(Qa,{mode:"single",numberOfMonths:1,selected:_?ws(_,"yyyy-MM-dd",new Date):void 0,onSelect:oe=>{oe&&(C(on(oe,"yyyy-MM-dd")),B(!1))}})]})]}),f.jsx("input",{ref:z,type:"text",value:b,onChange:oe=>v(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&tt(),oe.key==="Escape"&&Re()},placeholder:"Event label",className:"w-full px-2 py-1.5 text-sm rounded border",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}}),f.jsxs("div",{children:[f.jsx("textarea",{value:k,onChange:oe=>O(oe.target.value),onKeyDown:oe=>{oe.key==="Escape"&&Re()},placeholder:"Description (optional)",rows:2,className:"w-full px-2 py-1.5 text-sm rounded border resize-y",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}}),f.jsxs("div",{className:"text-[10px] mt-0.5",style:{color:"var(--yc-color-text-muted)"},children:["Supports ",f.jsx("a",{href:"https://www.markdownguide.org/basic-syntax/",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--yc-color-primary)",textDecoration:"underline"},children:"Markdown"})]})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-xs mb-1",style:{color:"var(--yc-color-text-muted)"},children:"Color (optional)"}),f.jsx(F0,{value:E,onChange:T,themePalette:d})]}),f.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[f.jsx("button",{onClick:Re,className:"px-2 py-1 text-xs rounded",style:{color:"var(--yc-color-text-muted)"},children:"Cancel"}),f.jsx("button",{onClick:tt,disabled:!D.trim()||!b.trim()||ue.isPending,className:"px-2 py-1 text-xs rounded text-white disabled:opacity-50",style:{backgroundColor:"var(--yc-color-primary, #3b82f6)"},children:ue.isPending?"Saving...":"Save"})]})]}),n.length===0?f.jsxs("div",{className:"text-center py-8",children:[f.jsx("div",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:"No events for this chart"}),f.jsx("div",{className:"text-xs mt-1",style:{color:"var(--yc-color-text-muted)"},children:"Events appear as dashed vertical lines on the chart"})]}):f.jsx("div",{className:"space-y-1",children:n.map((oe,re)=>f.jsxs("div",{className:"group flex items-start gap-3 p-3 rounded transition-colors hover:bg-black/[0.03]",style:{border:"1px solid transparent"},children:[i?f.jsx("div",{className:"flex-shrink-0 mt-0.5",children:f.jsx(F0,{value:oe.color??"",onChange:xe=>{const Oe=Ge(oe);Oe!==-1&&Ce.mutate({index:Oe,event:{...oe,...xe?{color:xe}:{color:void 0}}})},themePalette:d,compact:!0})}):f.jsx("span",{className:"w-3 h-3 rounded-full flex-shrink-0 mt-0.5",style:{backgroundColor:oe.color||"#6366f1"}}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"text-xs relative flex items-center gap-1",style:{color:"var(--yc-color-text-secondary)"},children:[f.jsx("span",{style:{cursor:i?"pointer":"default"},onClick:xe=>{i&&(xe.stopPropagation(),j(ae===re?null:re),pe(null))},children:oe.date}),ae===re&&f.jsxs("div",{ref:ye,className:"absolute z-50 rounded-lg shadow-lg p-2",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:0},children:[f.jsx("style",{children:Nc}),f.jsx(Qa,{mode:"single",numberOfMonths:1,selected:(()=>{try{return ws(oe.date,"yyyy-MM-dd",new Date)}catch{return}})(),defaultMonth:(()=>{try{return ws(oe.date,"yyyy-MM-dd",new Date)}catch{return}})(),onSelect:xe=>{if(!xe)return;const Oe=on(xe,"yyyy-MM-dd");if(j(null),Oe===oe.date)return;const qe=Ge(oe);qe!==-1&&Ce.mutate({index:qe,event:{...oe,date:Oe}})}})]}),oe.endDate&&f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"→"}),f.jsx("span",{style:{cursor:i?"pointer":"default"},onClick:xe=>{i&&(xe.stopPropagation(),pe(le===re?null:re),j(null))},children:oe.endDate}),le===re&&f.jsxs("div",{ref:Ne,className:"absolute z-50 rounded-lg shadow-lg p-2",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:0},children:[f.jsx("style",{children:Nc}),f.jsx(Qa,{mode:"single",numberOfMonths:1,selected:(()=>{try{return ws(oe.endDate,"yyyy-MM-dd",new Date)}catch{return}})(),defaultMonth:(()=>{try{return ws(oe.endDate,"yyyy-MM-dd",new Date)}catch{return}})(),onSelect:xe=>{if(!xe)return;const Oe=on(xe,"yyyy-MM-dd");if(pe(null),Oe===oe.endDate)return;const qe=Ge(oe);qe!==-1&&Ce.mutate({index:qe,event:{...oe,endDate:Oe}})}})]})]})]}),X===re&&ge==="label"?f.jsx("input",{ref:V,type:"text",value:de,onChange:xe=>M(xe.target.value),onBlur:()=>je(oe),onKeyDown:xe=>{xe.key==="Enter"&&je(oe),xe.key==="Escape"&&(ie(null),te(null))},className:"w-full py-0 text-sm font-medium border-0 border-b outline-none",style:{backgroundColor:"transparent",borderColor:"var(--yc-color-primary, #3b82f6)",color:"var(--yc-color-text)",borderBottomWidth:1,borderBottomStyle:"solid"}}):f.jsx("div",{className:"text-sm font-medium truncate",style:{color:"var(--yc-color-text)",cursor:i?"pointer":"default"},onClick:()=>{i&&(ie(re),te("label"),M(oe.label))},children:oe.label}),X===re&&ge==="description"?f.jsx("input",{ref:V,type:"text",value:de,onChange:xe=>M(xe.target.value),onBlur:()=>je(oe),onKeyDown:xe=>{xe.key==="Enter"&&je(oe),xe.key==="Escape"&&(ie(null),te(null))},placeholder:"Add description",className:"w-full py-0 text-xs border-0 border-b outline-none mt-0.5",style:{backgroundColor:"transparent",borderColor:"var(--yc-color-primary, #3b82f6)",color:"var(--yc-color-text)",borderBottomWidth:1,borderBottomStyle:"solid"}}):f.jsx("div",{className:"text-xs truncate mt-0.5",style:{color:oe.description?"var(--yc-color-text-secondary)":"var(--yc-color-text-muted)",cursor:i?"pointer":"default"},onClick:()=>{i&&(ie(re),te("description"),M(oe.description??""))},children:oe.description||(i?"Add description":"")}),oe.charts&&oe.charts.length>0&&f.jsx("div",{className:"text-xs mt-1",style:{color:"var(--yc-color-text-muted)"},children:oe.charts.length===1&&oe.charts[0]===o?"This chart only":`${oe.charts.length} charts`})]}),i&&f.jsx("button",{onClick:()=>nt(oe),className:"opacity-0 group-hover:opacity-100 p-1 rounded hover:bg-black/5 transition-all flex-shrink-0",style:{color:"var(--yc-color-danger, #ef4444)"},title:"Delete event",children:f.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})]},`${oe.date}-${oe.label}-${re}`))})]})]}),f.jsx(O3,{open:G!==null,title:"Delete event",message:`Delete "${G==null?void 0:G.label}"? This cannot be undone.`,onConfirm:we,onCancel:()=>Z(null)})]}):null}async function I3(e,t,n="png"){const{default:r}=await ls(async()=>{const{default:l}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:l}},[]),i=(await r(e,{backgroundColor:"#f9fafb",scale:2,useCORS:!0,logging:!1})).toDataURL(`image/${n}`,n==="jpeg"?.9:void 0);Zc(i,`${t}.${n}`)}async function M3(e,t,n){const[{default:r},{jsPDF:o}]=await Promise.all([ls(()=>import("./html2canvas.esm-QH1iLAAe.js"),[]),ls(()=>import("./jspdf.es.min-B-lLjljE.js").then(I=>I.j),[])]),i=await r(e,{backgroundColor:"#f9fafb",scale:2,useCORS:!0,logging:!1}),l=i.toDataURL("image/png"),c=i.width,d=i.height,p=c/d>1,y=new o({orientation:p?"landscape":"portrait",unit:"mm"}),b=y.internal.pageSize.getWidth(),v=y.internal.pageSize.getHeight();let D=0;n&&(D=8,y.setFontSize(16),y.text(n,b/2,D,{align:"center"}),D=14);const S=b,E=v-D;let T=S,k=d/c*T;k>E&&(k=E,T=c/d*k);const O=(b-T)/2;y.addImage(l,"PNG",O,D,T,k),y.save(`${t}.pdf`)}async function L3(e,t,n){const{jsPDF:r}=await ls(async()=>{const{jsPDF:E}=await import("./jspdf.es.min-B-lLjljE.js").then(T=>T.j);return{jsPDF:E}},[]),o=new Image;o.src=e,await new Promise(E=>{o.onload=E});const l=o.width/o.height>1.2,c=new r({orientation:l?"landscape":"portrait",unit:"mm"}),d=c.internal.pageSize.getWidth(),h=c.internal.pageSize.getHeight();let p=15;n&&(c.setFontSize(14),c.text(n,d/2,10,{align:"center"}));const y=d-20,b=h-p-15;let v=y,D=o.height/o.width*v;D>b&&(D=b,v=o.width/o.height*D);const S=(d-v)/2;c.addImage(e,"PNG",S,p,v,D),c.save(`${t}.pdf`)}function Ed(e,t,n){if(e.length===0)return;const r=t.map(l=>l.name),o=e.map(l=>t.map(c=>{const d=l[c.name];if(d==null)return"";const h=String(d);return h.includes(",")||h.includes('"')||h.includes(`
79
79
  `)?`"${h.replace(/"/g,'""')}"`:h})),i=[r.join(","),...o.map(l=>l.join(","))].join(`
80
80
  `);F2(i,`${n}.csv`,"text/csv;charset=utf-8;")}function R3(e,t){const n=JSON.stringify(e,null,2);F2(n,`${t}.json`,"application/json;charset=utf-8;")}function Zc(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function F2(e,t,n){const r=new Blob([e],{type:n}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}const $a=50;function B2({data:e,columns:t,drillDownColumns:n,filterDisplay:r,chartName:o}){const[i,l]=N.useState(null),[c,d]=N.useState(0),h=N.useMemo(()=>n&&n.length>0?n.map(k=>({field:k.field,label:k.label??k.field,format:k.format})):t.map(k=>({field:k.name,label:k.name,format:void 0})),[n,t]),p=N.useMemo(()=>{if(!i)return e;const{field:k,direction:O}=i;return[...e].sort((I,L)=>{const _=I[k],C=L[k];if(_==null&&C==null)return 0;if(_==null)return 1;if(C==null)return-1;if(typeof _=="number"&&typeof C=="number")return O==="asc"?_-C:C-_;const A=String(_),P=String(C);return O==="asc"?A.localeCompare(P):P.localeCompare(A)})},[e,i]),y=Math.ceil(p.length/$a),b=p.slice(c*$a,(c+1)*$a),v=c*$a+1,D=Math.min((c+1)*$a,p.length),S=k=>{l(O=>!O||O.field!==k?{field:k,direction:"asc"}:O.direction==="asc"?{field:k,direction:"desc"}:null),d(0)},E=(k,O)=>k==null?"":O&&typeof k=="number"?O.includes("$")?`$${k.toLocaleString()}`:O.includes("%")?`${k.toFixed(1)}%`:k.toLocaleString():String(k),T=k=>!i||i.field!==k?"":i.direction==="asc"?" ↑":" ↓";return f.jsxs("div",{className:"border rounded-lg overflow-hidden",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)"},children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b",style:{borderColor:"var(--yc-color-border)",backgroundColor:"var(--yc-color-input-bg)"},children:[f.jsxs("div",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:["Showing ",p.length," rows filtered by ",r]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>Ed(e,t,`${o}-drill-down`),className:"text-sm px-3 py-1 border rounded hover:bg-black/5 transition-colors",style:{color:"var(--yc-color-text-secondary)",borderColor:"var(--yc-color-border)"},children:"Export CSV"}),f.jsx("button",{onClick:()=>R3(e,`${o}-drill-down`),className:"text-sm px-3 py-1 border rounded hover:bg-black/5 transition-colors",style:{color:"var(--yc-color-text-secondary)",borderColor:"var(--yc-color-border)"},children:"Export JSON"})]})]}),f.jsx("div",{className:"overflow-x-auto",children:f.jsxs("table",{className:"w-full text-sm yc-table",children:[f.jsx("thead",{children:f.jsxs("tr",{className:"border-b",style:{borderColor:"var(--yc-color-border)",backgroundColor:"var(--yc-color-input-bg)"},children:[f.jsx("th",{className:"px-3 py-2 text-right font-medium select-none w-10",style:{color:"var(--yc-color-text-muted)"},children:"#"}),h.map(k=>f.jsxs("th",{className:"px-4 py-2 text-left font-medium cursor-pointer hover:bg-black/5 select-none",style:{color:"var(--yc-color-text)"},onClick:()=>S(k.field),children:[k.label,T(k.field)]},k.field))]})}),f.jsx("tbody",{children:b.map((k,O)=>f.jsxs("tr",{style:{backgroundColor:O%2===0?"var(--yc-color-surface)":"var(--yc-color-input-bg)"},children:[f.jsx("td",{className:"px-3 py-2 text-right yc-row-num w-10",style:{backgroundColor:O%2===0?"var(--yc-color-surface)":"var(--yc-color-input-bg)"},children:c*$a+O+1}),h.map(I=>f.jsx("td",{className:"px-4 py-2",style:{color:"var(--yc-color-text-secondary)"},children:E(k[I.field],I.format)},I.field))]},O))})]})}),y>1&&f.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t",style:{borderColor:"var(--yc-color-border)",backgroundColor:"var(--yc-color-input-bg)"},children:[f.jsxs("div",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:["Showing ",v,"-",D," of ",p.length]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>d(k=>Math.max(0,k-1)),disabled:c===0,className:"text-sm px-3 py-1 border rounded disabled:opacity-50 disabled:cursor-not-allowed hover:bg-black/5 transition-colors",style:{borderColor:"var(--yc-color-border)"},children:"Previous"}),f.jsx("button",{onClick:()=>d(k=>Math.min(y-1,k+1)),disabled:c>=y-1,className:"text-sm px-3 py-1 border rounded disabled:opacity-50 disabled:cursor-not-allowed hover:bg-black/5 transition-colors",style:{borderColor:"var(--yc-color-border)"},children:"Next"})]})]})]})}class Am extends N.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&t.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){return this.state.error?this.props.fallback(this.state.error,()=>this.setState({error:null})):this.props.children}}const Wr=N.forwardRef(function({option:t,height:n=400,loading:r=!1,onEvents:o},i){const l=N.useRef(null),c=N.useRef(null);return N.useImperativeHandle(i,()=>({getDataURL:d=>{var p;const h=(p=l.current)==null?void 0:p.getEchartsInstance();if(h)try{return h.getDataURL({type:d==="png"?"png":"svg",pixelRatio:2,backgroundColor:"#fff"})}catch{return h.getDataURL({type:"svg",pixelRatio:2,backgroundColor:"#fff"})}},getInstance:()=>{var d;return(d=l.current)==null?void 0:d.getEchartsInstance()}})),N.useEffect(()=>{const d=c.current;if(!d)return;let h;const p=new ResizeObserver(()=>{clearTimeout(h),h=setTimeout(()=>{var y,b;(b=(y=l.current)==null?void 0:y.getEchartsInstance())==null||b.resize()},150)});return p.observe(d),()=>{clearTimeout(h),p.disconnect()}},[]),f.jsx("div",{ref:c,style:{height:n,width:"100%"},children:f.jsx(Yw,{ref:l,option:t,notMerge:!0,style:{height:"100%",width:"100%"},showLoading:r,onEvents:o,opts:{renderer:"canvas"}})})});function P3(e,t){return e.length<=t?e:e.slice(0,t)+"..."}function j3(e){return e.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(t,n,r)=>{const i=!r.startsWith("#")?' target="_blank" rel="noopener noreferrer"':"";return`<a href="${r}" style="color: #6366f1; text-decoration: underline;"${i}>${n}</a>`})}function Td(e,t,n){const r=e.filter(o=>{if(o.date===t)return!0;if(o.endDate&&n&&n.length>0){let i=n.indexOf(o.date),l=n.indexOf(o.endDate);const c=n.indexOf(t);if(i===-1&&(i=0),l===-1&&(l=n.length-1),c!==-1)return c>=i&&c<=l}return!1});return r.length===0?"":r.map(o=>{const i=o.color??"#6366f1",l=o.endDate?`${o.date} → ${o.endDate}`:"",c=o.description?P3(o.description,100):"",d=c?`<div style="font-size: 11px; color: #888; margin-top: 2px;">${j3(c)}</div>`:"",h=l?`<div style="font-size: 10px; color: #999; margin-top: 1px;">${l}</div>`:"";return`<div style="margin-top: 6px; padding-top: 6px; border-top: 1px dashed #e5e7eb;"><span style="display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: ${i}; margin-right: 6px;"></span><span style="font-weight: 500;">${o.label}</span>${h}${d}</div>`}).join("")}function wd(e,t,n){let r=e.filter(o=>!o.endDate);if(n&&n.length>0&&(r=r.filter(o=>n.includes(o.date))),r.length!==0)return{silent:!0,symbol:"none",tooltip:{show:!1},data:r.map(o=>{const i=o.color??t;return{xAxis:o.date,label:{formatter:o.label,position:"insideEndTop",fontSize:11,color:i,backgroundColor:"rgba(99, 102, 241, 0.12)",padding:[2,6],borderRadius:3},lineStyle:{type:"dashed",color:i,width:1},emphasis:{disabled:!0}}})}}function Sd(e,t,n){const r=e.filter(l=>l.endDate);if(r.length===0)return[];const o=n==null?void 0:n[0],i=n==null?void 0:n[n.length-1];return r.flatMap(l=>{let c=l.date,d=l.endDate;if(n&&n.length>0&&o&&i){const p=n.indexOf(c),y=n.indexOf(d);p===-1&&(c=o),y===-1&&(d=i);const b=n.indexOf(c),v=n.indexOf(d);if(b>v)return[]}const h=l.color??t;return[[{xAxis:c,itemStyle:{color:h,opacity:.1},label:{show:!0,formatter:l.label,position:"insideTop",fontSize:11,color:h,padding:[2,6]}},{xAxis:d}]]})}const Im="#22c55e",H2="dashed";function F3(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e.toLocaleString()}function U2(e){return e.type==="fixed"}function B3(e){return e.type==="cumulative"}function H3(e){return e.type==="model"}function kd(e,t){const n=[];for(const r of e){const o=r.color??Im,i=r.style??H2;if(U2(r)){const l=F3(r.value);n.push({yAxis:r.value,label:{formatter:r.label?`${r.label}: ${l}`:l,position:"insideEndTop",fontSize:11,color:o,backgroundColor:"rgba(255,255,255,0.85)",padding:[2,6],borderRadius:2},lineStyle:{color:o,type:i,width:2}})}if(B3(r)){const l=r.from?t.indexOf(r.from):0,c=r.by?t.indexOf(r.by):t.length-1,d=Math.max(0,l===-1?0:l),h=c===-1?t.length-1:c;n.push([{coord:[d,0],label:{formatter:r.label??"",position:"insideEndTop",fontSize:11,color:o},lineStyle:{color:o,type:i,width:2}},{coord:[h,r.value]}])}}return n}function Cd(e,t){const n=[];for(const r of e){if(!r.zone)continue;const o=r.color??Im;if(U2(r)){const i=r.value*(1-r.zone.tolerance),l=r.value*(1+r.zone.tolerance);n.push([{yAxis:i,itemStyle:{color:o,opacity:.08}},{yAxis:l}])}}return n}function _d(e,t){const n=[];for(const r of e){if(!H3(r)||!t)continue;const o=r.color??Im,i=r.style??H2,l=t.rows.map(c=>{const d=c[r.source.value_field];return typeof d=="number"?d:parseFloat(String(d))||0});n.push({name:r.label??"Goal",data:l,color:o,lineStyle:{type:i,width:2,color:o},showSymbol:!1,z:5})}return n}const ed="#22c55e",td="#ef4444";function z2(e){return e.type==="fixed"}function W2(e){return e.type==="cumulative"}function U3(e,t){const n=t.find(z2);return n?e>=n.value?ed:td:null}function z3(e,t,n,r){const o=r.find(W2);if(!o||n===0)return null;const i=o.value/n*(t+1);return e>=i?ed:td}function W3(e,t){const n=t.find(z2);if(n)return e.map(o=>({value:o,itemStyle:{color:o>=n.value?ed:td}}));const r=t.find(W2);if(r){const o=e.length;return e.map((i,l)=>{const c=r.value/o*(l+1);return{value:i,itemStyle:{color:i>=c?ed:td}}})}return e}function Y2(e,t){if(e.length===0||t.length===0)return null;const n=e[e.length-1],r=U3(n,t);return r||z3(n,e.length-1,e.length,t)}function Y3(e){return"field"in e}function $3(e){return"columns"in e}function Uh(e){if(e.length===0)return e;const t=e[0].data.length;for(let n=0;n<t;n++){let r=0;for(const o of e)r+=o.data[n]??0;for(const o of e)o.data[n]=r===0?0:(o.data[n]??0)/r*100}return e}function Nd(e,t,n){var o,i;const r=t.stacking?"total":void 0;if(!t.series){const l=((o=t.y)==null?void 0:o.field)??"",c=e.map(h=>{const p=h[l];return typeof p=="number"?p:parseFloat(String(p))||0}),d=[{name:l,data:c,color:yi(0,void 0,n),stack:r}];return t.stacking==="percent"?Uh(d):d}if(Y3(t.series)){const l=t.series.field,c=t.series.colors,d=((i=t.y)==null?void 0:i.field)??"",h=[],p=new Map;e.forEach(b=>{const v=String(b[l]??"");p.has(v)||(h.push(v),p.set(v,[]));const D=b[d];p.get(v).push(typeof D=="number"?D:parseFloat(String(D))||0)});const y=h.map((b,v)=>({name:b,data:p.get(b),color:D3(b,v,c,n),stack:r}));return t.stacking==="percent"?Uh(y):y}if($3(t.series)){const l=t.series.columns.map((c,d)=>{const h=e.map(p=>{const y=p[c.field];return typeof y=="number"?y:parseFloat(String(y))||0});return{name:c.name??c.field,data:h,color:yi(d,c.color,n),opacity:c.opacity,style:c.style,gradient:c.gradient,stack:r,chartType:c.type,yAxisIndex:c.axis==="right"?1:c.axis==="left"?0:void 0}});return t.stacking==="percent"?Uh(l):l}return[]}function nd(e){const t=e.match(/^(\d{4}-\d{2}-\d{2})T00:00:00(?:\.0+)?(?:Z|[+-]00:?00)?$/);return c1(t?t[1]:e)}function q3(e){return e.replace(/'/g,"''").replace(/%Y/g,"yyyy").replace(/%y/g,"yy").replace(/%m/g,"MM").replace(/%b/g,"MMM").replace(/%B/g,"MMMM").replace(/%d/g,"dd").replace(/%H/g,"HH").replace(/%I/g,"hh").replace(/%M/g,"mm").replace(/%S/g,"ss").replace(/%p/g,"a").replace(/%P/g,"a")}function $2(e){const t=Math.floor(e.getMonth()/3)+1,n=e.getFullYear().toString().slice(-2);return`Q${t} '${n}`}function V3(e){if(e.length<2)return"MMM dd, yyyy";const t=e.map(c=>c.getTime()).sort((c,d)=>c-d),n=t[0],r=t[t.length-1],o=(r-n)/(1e3*60*60*24);return o<2?"MMM dd, h:mm a":o<=90||(r-n)/(t.length-1)/(1e3*60*60*24)<28?"MMM dd":o<=730?"MMM yyyy":"yyyy"}function Q3(e){if(e.length<2)return"MMM dd, yyyy";const t=e.map(r=>r.getTime()).sort((r,o)=>r-o),n=(t[t.length-1]-t[0])/((t.length-1)*864e5);return n<1?"MMM dd, yyyy h:mm a":n<28?"MMM dd, yyyy":"MMM yyyy"}function Dd(e,t){const n=new Set,r=e.filter(l=>{const c=l[t.field];return n.has(c)?!1:(n.add(c),!0)});if(t.type!=="temporal")return r.map(l=>String(l[t.field]??""));const o=[];for(const l of r){const c=l[t.field];if(typeof c=="string")try{o.push(nd(c))}catch{}}const i=o.length>0?Q3(o):"MMM dd, yyyy";return r.map(l=>{const c=l[t.field];if(typeof c=="string")try{const d=nd(c);return t.format==="quarter"?$2(d):on(d,i)}catch{return String(c??"")}return String(c??"")})}function Od(e,t){const n=new Set,r=e.filter(o=>{const i=o[t.field];return n.has(i)?!1:(n.add(i),!0)});return Ls(r,t)}function Ls(e,t){let n;if(t.type==="temporal"&&!t.format){const r=[];for(const o of e){const i=o[t.field];if(typeof i=="string")try{r.push(nd(i))}catch{}}r.length>0&&(n=V3(r))}return e.map(r=>{const o=r[t.field];if(t.type==="temporal"&&typeof o=="string")try{const i=nd(o);if(t.format==="quarter")return $2(i);const l=t.format?q3(t.format):n??"MMM yyyy";return on(i,l)}catch{return String(o??"")}return String(o??"")})}function wo(e,t){if(t){if(t.includes("$"))return`$${e.toLocaleString()}`;if(t.includes("%"))return`${e.toFixed(1)}%`}return e.toLocaleString()}function G3(e){const t=e.replace("#","").match(/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function Ad(e,t){if(!t)return null;if(typeof t=="object")return{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:t.from},{offset:1,color:t.to}]};const n=G3(e);return n?{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:`rgba(${n.r}, ${n.g}, ${n.b}, 0.4)`},{offset:1,color:`rgba(${n.r}, ${n.g}, ${n.b}, 0.05)`}]}:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:e},{offset:1,color:"rgba(0,0,0,0)"}]}}function Rs(e){return((e==null?void 0:e.base)??"modern")==="modern"?{smooth:!0,barBorderRadius:[4,4,0,0],pieBorderRadius:4}:{smooth:!1,barBorderRadius:[0,0,0,0],pieBorderRadius:0}}const q2=N.forwardRef(function({data:t,xAxis:n,yAxis:r,chartConfig:o,theme:i,height:l=400,loading:c=!1,onChartClick:d,events:h,goalData:p},y){var B,z,Q,q,X,ie,ge,te;const b=cs(),v=(o==null?void 0:o.series)&&"field"in o.series,D=v?Od(t,n):Ls(t,n),S=n.type==="temporal"?Dd(t,n):D,E=N.useMemo(()=>{if(v){const de=new Set;return t.filter(M=>{const V=M[n.field];return de.has(V)?!1:(de.add(V),!0)}).map(M=>M[n.field])}return t.map(de=>de[n.field])},[t,n.field,v]),T=N.useMemo(()=>{if(d)return{click:de=>{var pe,ye,Ne,G;const M=de;if(M.componentType!=="series")return;const V=M.dataIndex!=null?E[M.dataIndex]:void 0,ae=V!=null?String(V):M.name;if(ae==null||ae==="")return;const j=((ye=(pe=M.event)==null?void 0:pe.event)==null?void 0:ye.clientX)??0,le=((G=(Ne=M.event)==null?void 0:Ne.event)==null?void 0:G.clientY)??0;d(n.field,ae,{x:j,y:le},M.seriesName)}}},[d,n.field,E]);let k,O,I;if(o){const de=Nd(t,{type:o.type,y:r?{field:r.field,type:r.type}:void 0,series:o.series,stacking:o.stacking},i),M=Rs(i);k=de.map(V=>{const ae=Ad(V.color,V.gradient??o.gradient);return{type:"line",name:V.name,data:V.data,smooth:M.smooth,symbol:"circle",symbolSize:6,lineStyle:{width:2,color:V.color,type:V.style==="dashed"?"dashed":V.style==="dotted"?"dotted":"solid"},itemStyle:{color:V.color},areaStyle:ae?{color:ae}:void 0,stack:V.stack,...V.opacity!==void 0?{opacity:V.opacity}:{}}}),de.length>1&&(O={show:((B=o.legend)==null?void 0:B.show)!==!1,...((z=o.legend)==null?void 0:z.position)==="top"?{top:0}:((Q=o.legend)==null?void 0:Q.position)==="left"?{left:0,orient:"vertical"}:((q=o.legend)==null?void 0:q.position)==="right"?{right:0,orient:"vertical"}:{bottom:0},textStyle:{color:b.textColor,fontSize:12}}),(X=o.interactions)!=null&&X.zoom&&(I=[{type:"inside",start:0,end:100},{type:"slider",start:0,end:100,bottom:0}])}else{const de=(r==null?void 0:r.field)??"";k=[{type:"line",data:t.map(V=>{const ae=V[de];return typeof ae=="number"?ae:parseFloat(String(ae))||0}),smooth:Rs(i).smooth,symbol:"circle",symbolSize:6,lineStyle:{width:2,color:"#3B82F6"},itemStyle:{color:"#3B82F6"},areaStyle:{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(59, 130, 246, 0.2)"},{offset:1,color:"rgba(59, 130, 246, 0)"}]}}}]}const L=(o==null?void 0:o.goals)??[];if(L.length>0&&Array.isArray(k)){const de=Y2(((ie=k[0])==null?void 0:ie.data)??[],L);de&&k[0]&&(k[0].lineStyle={...k[0].lineStyle,color:de},k[0].itemStyle={color:de});const M=kd(L,D),V=Cd(L);if(M.length>0&&k[0]){const j=k[0].markLine,le=(j==null?void 0:j.data)??[];k[0].markLine={...j,silent:!0,symbol:"none",data:[...le,...M]}}V.length>0&&k[0]&&(k[0].markArea={silent:!0,data:V});const ae=_d(L,p);for(const j of ae)k.push({type:"line",name:j.name,data:j.data,z:j.z,showSymbol:j.showSymbol,lineStyle:j.lineStyle,itemStyle:{color:j.color}})}const _=N.useMemo(()=>{if(!(h!=null&&h.length))return[];const M=h.flatMap(le=>le.endDate?[le.date,le.endDate]:[le.date]).map(le=>({[n.field]:le})),ae=Ls([...t,...M],n).slice(t.length);let j=0;return h.map(le=>{const pe={...le,date:ae[j++]??le.date};return le.endDate&&(pe.endDate=ae[j++]??le.endDate),pe})},[h,t,n]),C=Array.isArray(k)?k.map(de=>de.name).filter(Boolean):[],A=wd(_,b.textColor,D),P=Sd(_,b.textColor,D);if((A||P.length>0)&&Array.isArray(k)){const de={type:"line",data:((ge=k[0])==null?void 0:ge.data)??[],showSymbol:!1,lineStyle:{opacity:0,width:0},silent:!0,legendHoverLink:!1,tooltip:{show:!1}};A&&(de.markLine=A),P.length>0&&(de.markArea={silent:!0,data:P}),k.push(de)}const H={tooltip:{trigger:"axis",formatter:de=>{const M=de;if(!Array.isArray(M)||M.length===0)return"";let ae=`<div style="padding: 8px;"><div style="font-weight: 600; margin-bottom: 4px;">${S[M[0].dataIndex]??M[0].name}</div>`;for(const j of M)ae+=`<div>${j.marker} ${j.seriesName}: ${wo(j.value,r==null?void 0:r.format)}</div>`;return ae+=Td(_,M[0].name,D),ae+="</div>",ae}},legend:O?{...O,...C.length>0?{data:C}:{}}:void 0,grid:{left:"3%",right:"4%",bottom:"10%",top:"10%",containLabel:!0},xAxis:{type:"category",data:D,name:n.label,nameLocation:"middle",nameGap:30,nameTextStyle:{color:b.textColor,fontSize:12},axisLabel:{color:b.textColor,fontSize:12,hideOverlap:!0},axisLine:{lineStyle:{color:b.borderColor}},axisTick:{show:!1}},yAxis:{type:((te=o==null?void 0:o.y)==null?void 0:te.scale)==="log"?"log":"value",name:r==null?void 0:r.label,nameLocation:"middle",nameGap:80,nameTextStyle:{color:b.textColor,fontSize:12},axisLabel:{color:b.textColor,fontSize:12,formatter:de=>wo(de,r==null?void 0:r.format)},axisLine:{show:!1},splitLine:{lineStyle:{color:b.splitLineColor,type:"dashed"}}},series:k,...I?{dataZoom:I}:{},animation:!0,animationDuration:300};return f.jsx(Wr,{ref:y,option:H,height:l,loading:c,onEvents:T})}),V2=N.forwardRef(function({data:t,xAxis:n,yAxis:r,chartConfig:o,theme:i,height:l=400,loading:c=!1,horizontal:d=!1,onChartClick:h,activeCrossFilter:p,events:y,goalData:b},v){var ge,te,de,M,V,ae,j;const D=cs(),S=(o==null?void 0:o.series)&&"field"in o.series,E=S?Od(t,n):Ls(t,n),T=n.type==="temporal"?Dd(t,n):E,k=(p==null?void 0:p.field)===n.field,O=d||(o==null?void 0:o.orientation)==="horizontal",I=N.useMemo(()=>{if(S){const le=new Set;return t.filter(pe=>{const ye=pe[n.field];return le.has(ye)?!1:(le.add(ye),!0)}).map(pe=>pe[n.field])}return t.map(le=>le[n.field])},[t,n.field,S]),L=N.useMemo(()=>{if(h)return{click:le=>{var ue,me,Ce,Re;const pe=le;if(pe.componentType!=="series")return;const ye=pe.dataIndex!=null?I[pe.dataIndex]:void 0,Ne=ye!=null?String(ye):pe.name;if(Ne==null||Ne==="")return;const G=((me=(ue=pe.event)==null?void 0:ue.event)==null?void 0:me.clientX)??0,Z=((Re=(Ce=pe.event)==null?void 0:Ce.event)==null?void 0:Re.clientY)??0;h(n.field,Ne,{x:G,y:Z},pe.seriesName)}}},[h,n.field,I]),_=(o==null?void 0:o.stacking)==="percent",C=le=>_?`${le.toFixed(1)}%`:wo(le,r==null?void 0:r.format);let A,P=!1;if(o){const le=Nd(t,{type:o.type,y:r?{field:r.field,type:r.type}:void 0,series:o.series,stacking:o.stacking},i),pe=le.length>1,ye=!!o.stacking;P=pe;const Ne=Rs(i);A=le.map(G=>{const Z=Ad(G.color,G.gradient??o.gradient);return{type:"bar",name:G.name,data:k?G.data.map((ue,me)=>({value:ue,itemStyle:{opacity:String(I[me])===(p==null?void 0:p.value)?1:.3}})):G.data,barWidth:pe&&!ye?void 0:"60%",itemStyle:{color:Z??G.color,borderRadius:Ne.barBorderRadius},stack:G.stack,...G.opacity!==void 0?{opacity:G.opacity}:{}}})}else{const le=(r==null?void 0:r.field)??"",pe=t.map(Ne=>{const G=Ne[le];return typeof G=="number"?G:parseFloat(String(G))||0}),ye=Rs(i);A=[{type:"bar",data:k?pe.map((Ne,G)=>({value:Ne,itemStyle:{opacity:String(I[G])===(p==null?void 0:p.value)?1:.3}})):pe,barWidth:"60%",itemStyle:{color:"#3B82F6",borderRadius:ye.barBorderRadius},emphasis:{itemStyle:{color:"#2563EB"}}}]}const H=(o==null?void 0:o.goals)??[];if(H.length>0&&Array.isArray(A)&&!O){if(A[0]){const G=A[0].data.map(ue=>typeof ue=="number"?ue:ue.value),Z=W3(G,H);A[0].data=Z}const le=kd(H,E),pe=Cd(H);le.length>0&&A[0]&&(A[0].markLine={silent:!0,symbol:"none",data:le}),pe.length>0&&A[0]&&(A[0].markArea={silent:!0,data:pe});const ye=_d(H,b);for(const Ne of ye)A.push({type:"line",name:Ne.name,data:Ne.data,z:Ne.z,showSymbol:Ne.showSymbol,lineStyle:Ne.lineStyle,itemStyle:{color:Ne.color}})}const B=N.useMemo(()=>{if(!(y!=null&&y.length))return[];const pe=y.flatMap(Z=>Z.endDate?[Z.date,Z.endDate]:[Z.date]).map(Z=>({[n.field]:Z})),Ne=Ls([...t,...pe],n).slice(t.length);let G=0;return y.map(Z=>{const ue={...Z,date:Ne[G++]??Z.date};return Z.endDate&&(ue.endDate=Ne[G++]??Z.endDate),ue})},[y,t,n]),z=Array.isArray(A)?A.map(le=>le.name).filter(Boolean):[],Q=wd(B,D.textColor,E),q=Sd(B,D.textColor,E);if((Q||q.length>0)&&Array.isArray(A)){const le={type:"line",data:((ge=A[0])==null?void 0:ge.data)??[],showSymbol:!1,lineStyle:{opacity:0,width:0},silent:!0,legendHoverLink:!1,tooltip:{show:!1}};Q&&(le.markLine=Q),q.length>0&&(le.markArea={silent:!0,data:q}),A.push(le)}const ie={tooltip:{trigger:"axis",axisPointer:{type:"shadow"},formatter:le=>{const pe=le;if(!Array.isArray(pe)||pe.length===0)return"";const ye=T[pe[0].dataIndex]??pe[0].name,Ne=Td(B,pe[0].name,E);if(pe.length===1){const Z=pe[0];return`
81
81
  <div style="padding: 8px;">
@@ -184,4 +184,4 @@ ${je}${xe}. `,qe=Ce.substring(0,me)+Oe+Ce.substring(me);d(qe),setTimeout(()=>{ue
184
184
  .yc-edit-grid > .react-grid-item {
185
185
  z-index: 1;
186
186
  }
187
- `}),f.jsxs("div",{ref:b,style:{position:"relative"},children:[v>0&&r&&h==="lg"&&f.jsx(ED,{className:"yc-bg-grid",layout:tT,cols:eT,rowHeight:Ol,width:v,margin:[I,I],useCSSTransforms:!0,compactType:null,isDraggable:!1,isResizable:!1,autoSize:!1,children:vR}),v>0&&f.jsx(TD,{className:r?"layout yc-edit-grid":"layout",layouts:A,breakpoints:mR,cols:pR,rowHeight:Ol,width:v,margin:[I,I],isDraggable:r&&h==="lg",isResizable:r&&h==="lg",onLayoutChange:(q,X)=>{X.lg&&H(X.lg)},onDragStart:()=>{k.current=!0},onResizeStart:()=>{k.current=!0},onDragStop:q=>B([...q]),onResizeStop:q=>B([...q]),compactType:"vertical",autoSize:!0,useCSSTransforms:!0,children:C.map(({id:q,widget:X,rowIndex:ie,widgetIndex:ge})=>f.jsx("div",{className:"h-full",children:f.jsxs(hR,{onRemove:()=>z(ie,ge),widgetType:X.type,isContentEditing:S===q,onDoubleClick:X.type==="text"?()=>E(q):void 0,children:[X.type==="chart"&&X.ref&&f.jsx(_D,{chartRef:X.ref}),X.type==="text"&&f.jsx(fR,{content:X.content||"",onUpdate:te=>Q(ie,ge,te),isContentEditing:S===q,onEditStart:()=>E(q),onEditEnd:()=>E(null),dashboardName:n})]})},q))})]})]})}function TR({isOpen:e,onClose:t,onAdd:n,existingCharts:r}){const{data:o}=ma(),[i,l]=N.useState(""),c=N.useRef(null);if(N.useEffect(()=>{const y=v=>{v.key==="Escape"&&t()},b=v=>{c.current&&!c.current.contains(v.target)&&t()};return e&&(document.addEventListener("keydown",y),document.addEventListener("mousedown",b)),()=>{document.removeEventListener("keydown",y),document.removeEventListener("mousedown",b)}},[e,t]),!e)return null;const h=((o==null?void 0:o.charts)||[]).filter(y=>y.title.toLowerCase().includes(i.toLowerCase())||y.name.toLowerCase().includes(i.toLowerCase())),p=y=>{n({type:"chart",ref:y,cols:6}),t()};return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:f.jsxs("div",{ref:c,className:"rounded-lg shadow-xl w-full max-w-md mx-4",style:{backgroundColor:"var(--yc-color-surface)"},children:[f.jsxs("div",{className:"p-4 border-b",style:{borderColor:"var(--yc-color-border)"},children:[f.jsxs("div",{className:"flex items-center justify-between mb-3",children:[f.jsx("h2",{className:"text-lg font-semibold",style:{color:"var(--yc-color-text)"},children:"Add Chart"}),f.jsx("button",{onClick:t,className:"p-1 hover:opacity-80",style:{color:"var(--yc-color-text-muted)"},children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),f.jsx("input",{type:"text",placeholder:"Search charts...",value:i,onChange:y=>l(y.target.value),className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},autoFocus:!0})]}),f.jsx("div",{className:"max-h-80 overflow-y-auto",children:h.length===0?f.jsx("div",{className:"p-4 text-center text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No charts found"}):f.jsx("div",{className:"p-2",children:h.map(y=>{const b=r.includes(y.name);return f.jsxs("button",{onClick:()=>p(y.name),disabled:b,className:"w-full text-left px-3 py-3 rounded-md hover:bg-black/5 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-between group",children:[f.jsxs("div",{children:[f.jsx("div",{className:"font-medium",style:{color:"var(--yc-color-text)"},children:y.title}),f.jsx("div",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:y.name}),y.description&&f.jsx("div",{className:"text-xs mt-1",style:{color:"var(--yc-color-text-muted)"},children:y.description})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-xs px-2 py-1 rounded",style:{color:"var(--yc-color-text-muted)",backgroundColor:"var(--yc-color-surface-hover)"},children:y.type}),b?f.jsx("span",{className:"text-xs",style:{color:"var(--yc-color-success)"},children:"Added"}):f.jsx("svg",{className:"w-5 h-5 opacity-0 group-hover:opacity-100",style:{color:"var(--yc-color-text-muted)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})]})]},y.name)})})})]})})}function wR(e){const t=Math.floor((Date.now()-e)/1e3);if(t<10)return"just now";if(t<60)return`${t}s ago`;const n=Math.floor(t/60);if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:new Date(e).toLocaleDateString()}function SR({dashboardId:e,title:t,description:n,contentRef:r,activeTab:o}){const{isEditing:i,setIsEditing:l,pendingLayout:c,setPendingLayout:d,setOriginalLayout:h,hasChanges:p,addWidget:y,currentLayout:b,undo:v,redo:D,canUndo:S,canRedo:E}=ki(),T=dm(),k=d_(e),O=f_(),I=_S({queryKey:["chartData"]}),L=Wn(),_=(()=>{const M=L.getQueryCache();let V=0;for(const ae of M.getAll()){const j=ae.queryKey[0];(j==="chartData"||j==="chartWithData")&&ae.state.dataUpdatedAt>V&&(V=ae.state.dataUpdatedAt)}return V>0?V:null})(),[C,A]=N.useState(!1),[P,H]=N.useState(!1),[B,z]=N.useState(!1),[Q,q]=N.useState(!1),X=(b==null?void 0:b.rows.flatMap(M=>M.widgets.filter(V=>V.type==="chart"&&V.ref).map(V=>V.ref)))||[],ie=()=>{O()},ge=async M=>{if(r.current){q(!0),A(!1);try{M==="pdf"?await M3(r.current,`${e}-dashboard`,t):await I3(r.current,`${e}-dashboard`,M)}finally{q(!1)}}},te=async()=>{if(c)try{await k.mutateAsync({layout:c,tab:o}),h(c),d(null),l(!1)}catch(M){console.error("Failed to save:",M)}},de=()=>{d(null),l(!1)};return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"border-b",style:{borderColor:"var(--yc-color-border)",backgroundColor:"var(--yc-color-surface)"},children:[f.jsxs("div",{className:"flex items-center justify-between p-4",children:[f.jsx("div",{children:f.jsx("h1",{className:"text-xl font-semibold",style:{color:"var(--yc-color-text)"},children:t})}),f.jsx("div",{className:"flex items-center gap-2",children:i?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"relative",children:[f.jsxs("button",{onClick:()=>z(!B),className:"flex items-center gap-2 px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 rounded-md hover:bg-blue-100",children:[f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add Widget",f.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),B&&f.jsxs("div",{className:"absolute left-0 top-full mt-1 w-40 rounded-md shadow-lg border z-50 py-1",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)"},children:[f.jsxs("button",{onClick:()=>{z(!1),H(!0)},className:"w-full text-left px-4 py-2 text-sm hover:bg-black/5 flex items-center gap-2",style:{color:"var(--yc-color-text)"},children:[f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),"Chart"]}),f.jsxs("button",{onClick:()=>{z(!1),y({type:"text",content:"",cols:6})},className:"w-full text-left px-4 py-2 text-sm hover:bg-black/5 flex items-center gap-2",style:{color:"var(--yc-color-text)"},children:[f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h7"})}),"Text"]})]})]}),f.jsxs("div",{className:"flex items-center",children:[f.jsx("button",{onClick:v,disabled:!S,className:"p-2 hover:bg-black/5 rounded-md disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--yc-color-text-secondary)"},title:"Undo (Cmd+Z)",children:f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a5 5 0 015 5v2M3 10l4-4m-4 4l4 4"})})}),f.jsx("button",{onClick:D,disabled:!E,className:"p-2 hover:bg-black/5 rounded-md disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--yc-color-text-secondary)"},title:"Redo (Cmd+Shift+Z)",children:f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 10H11a5 5 0 00-5 5v2m15-7l-4-4m4 4l-4 4"})})})]}),f.jsx("div",{className:"w-px h-6 mx-2",style:{backgroundColor:"var(--yc-color-border)"}}),f.jsx("button",{onClick:de,className:"px-4 py-2 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Cancel"}),f.jsx("button",{onClick:te,disabled:!p||k.isPending,className:nr("px-4 py-2 text-sm font-medium rounded-md",p?"bg-blue-600 text-white hover:bg-blue-700":"cursor-not-allowed"),style:p?void 0:{backgroundColor:"var(--yc-color-surface-hover)",color:"var(--yc-color-text-muted)"},children:k.isPending?"Saving...":"Save & Push"})]}):f.jsxs(f.Fragment,{children:[_&&I===0&&f.jsxs("span",{className:"text-xs",style:{color:"var(--yc-color-text-muted)"},title:new Date(_).toLocaleString(),children:["Updated ",wR(_)]}),f.jsx("button",{onClick:ie,disabled:I>0,className:"p-2 hover:bg-black/5 rounded-md disabled:opacity-50",style:{color:"var(--yc-color-text-secondary)"},title:"Refresh all charts",children:f.jsx("svg",{className:nr("w-5 h-5",I>0&&"animate-spin"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),f.jsxs("div",{className:"relative",children:[f.jsx("button",{onClick:()=>A(!C),disabled:Q,className:"p-2 hover:bg-black/5 rounded-md disabled:opacity-50",style:{color:"var(--yc-color-text-secondary)"},title:"Export dashboard",children:Q?f.jsxs("svg",{className:"w-5 h-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[f.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),f.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})})}),C&&f.jsxs("div",{className:"absolute right-0 top-full mt-1 w-40 rounded-md shadow-lg border z-50 py-1",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)"},children:[f.jsxs("button",{onClick:()=>ge("png"),className:"w-full text-left px-4 py-2 text-sm hover:bg-black/5 flex items-center gap-2",style:{color:"var(--yc-color-text)"},children:[f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),"Export PNG"]}),f.jsxs("button",{onClick:()=>ge("jpeg"),className:"w-full text-left px-4 py-2 text-sm hover:bg-black/5 flex items-center gap-2",style:{color:"var(--yc-color-text)"},children:[f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),"Export JPEG"]}),f.jsxs("button",{onClick:()=>ge("pdf"),className:"w-full text-left px-4 py-2 text-sm hover:bg-black/5 flex items-center gap-2",style:{color:"var(--yc-color-text)"},children:[f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),"Export PDF"]})]})]}),T==="lg"?f.jsx("button",{onClick:()=>l(!0),className:"p-2 hover:bg-black/5 rounded-md",style:{color:"var(--yc-color-text-secondary)"},title:"Edit layout",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}):f.jsx("button",{disabled:!0,className:"p-2 rounded-md",style:{opacity:.5,cursor:"not-allowed",color:"var(--yc-color-text-muted)"},title:"Editing requires a desktop browser",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})})]})})]}),n&&f.jsx("p",{className:"px-4 pb-3 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:n})]}),f.jsx(TR,{isOpen:P,onClose:()=>H(!1),onAdd:y,existingCharts:X})]})}function kR({filters:e,isEditing:t,onReorder:n,onRename:r,showCrossFilters:o}){const[i,l]=N.useState(null),[c,d]=N.useState(null),h=Je(I=>I.globalFilters),p=Je(I=>I.resetFilters),y=Je(I=>I.crossFilters),b=Je(I=>I.clearCrossFilter),v=Je(I=>I.clearAllCrossFilters),D=o?Object.values(y):[];if(e.length===0&&D.length===0)return null;const S=e.some(I=>{const L=h[I.name];if(L==null||L===""||Array.isArray(L)&&L.length===0)return!1;const _=I.default??(I.type==="date_range"?"last_30_days":void 0);return JSON.stringify(L)!==JSON.stringify(_)});function E(I,L){l(L),I.dataTransfer.effectAllowed="move"}function T(I,L){I.preventDefault(),I.dataTransfer.dropEffect="move",d(L)}function k(I,L){if(I.preventDefault(),i===null||i===L)return;const _=[...e],C=_.splice(i,1)[0];_.splice(L,0,C),n==null||n(_),l(null),d(null)}function O(){l(null),d(null)}return t?f.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.map((I,L)=>{const _=I.label||ca(I.name),C=i===L?"opacity-50":"";return f.jsxs("div",{draggable:!0,onDragStart:A=>E(A,L),onDragOver:A=>T(A,L),onDrop:A=>k(A,L),onDragEnd:O,className:`flex items-center gap-1.5 border rounded-full px-3 py-1.5 text-sm cursor-grab active:cursor-grabbing transition-colors ${C}`,style:c===L?{borderColor:"var(--yc-color-primary)",backgroundColor:"color-mix(in srgb, var(--yc-color-primary) 10%, transparent)"}:{borderColor:"var(--yc-color-border, #e5e7eb)",backgroundColor:"var(--yc-color-surface)"},children:[f.jsx("svg",{className:"w-2.5 h-2.5 flex-shrink-0",style:{color:"var(--yc-color-text-muted)"},fill:"currentColor",viewBox:"0 0 20 20",children:f.jsx("path",{d:"M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z"})}),f.jsx(CR,{value:_,onChange:A=>r==null?void 0:r(L,A)}),f.jsx("svg",{className:"w-3 h-3 flex-shrink-0",style:{color:"var(--yc-color-text-muted)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]},I.name)})}):f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.map(I=>{const L=I.label||ca(I.name),_=typeof I.default=="string"?I.default:void 0;switch(I.type){case"date_range":return f.jsx(_2,{name:I.name,label:L,defaultValue:_},I.name);case"select":{const C=(I.options||[]).map(A=>typeof A=="string"?{value:A,label:A}:A);return f.jsx(Jc,{name:I.name,label:L,options:C,defaultValue:_},I.name)}case"dynamic_select":return I.source?f.jsx(Jc,{name:I.name,label:L,source:I.source,defaultValue:_},I.name):f.jsxs("div",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:[L,": dynamic_select requires source"]},I.name);case"multi_select":{const C=(I.options||[]).map(A=>typeof A=="string"?{value:A,label:A}:A);return f.jsx(N2,{name:I.name,label:L,options:C,defaultValue:Array.isArray(I.default)?I.default:void 0,source:I.source},I.name)}case"text":return f.jsx(A2,{name:I.name,label:L,defaultValue:_},I.name);case"number":return f.jsx(L2,{name:I.name,label:L,defaultValue:typeof I.default=="number"?I.default:void 0},I.name);case"boolean":return f.jsx(R2,{name:I.name,label:L},I.name);default:return f.jsxs("div",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:[L,": ",I.type," (not supported)"]},I.name)}}),D.length>0&&e.length>0&&f.jsx("div",{className:"w-px h-6 mx-1",style:{backgroundColor:"var(--yc-color-border)"}}),D.map(I=>f.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1.5 text-sm rounded-full",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-primary) 10%, transparent)",color:"var(--yc-color-primary)",border:"1px solid color-mix(in srgb, var(--yc-color-primary) 30%, transparent)"},children:[I.field,": ",H0(I.value),f.jsx("button",{onClick:()=>b(I.field),className:"ml-0.5 hover:opacity-80","aria-label":`Clear ${I.field} filter`,children:f.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",children:f.jsx("path",{d:"M3 3l6 6M9 3l-6 6"})})})]},`cf-${I.field}`)),(S||D.length>0)&&f.jsx("button",{type:"button",onClick:()=>{S&&p(),D.length>0&&v()},className:"text-sm px-2 py-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",style:{color:"var(--yc-color-text-muted)"},children:"Clear all"})]})}function CR({value:e,onChange:t}){const[n,r]=N.useState(!1),[o,i]=N.useState(e);if(!n)return f.jsx("span",{className:"text-sm font-medium cursor-text hover:text-blue-600 hover:underline",style:{color:"var(--yc-color-text)"},onClick:c=>{c.stopPropagation(),r(!0),i(e)},title:"Click to rename",children:e});function l(){o.trim()&&o!==e&&t(o.trim()),r(!1)}return f.jsx("input",{autoFocus:!0,value:o,onChange:c=>i(c.target.value),onBlur:l,onKeyDown:c=>{c.key==="Enter"&&l(),c.key==="Escape"&&r(!1)},className:"text-sm font-medium border border-blue-300 rounded px-1 py-0 outline-none w-32",style:{color:"var(--yc-color-text)",backgroundColor:"var(--yc-color-surface)"},onClick:c=>c.stopPropagation()})}function _R({tabs:e,activeTab:t,onTabChange:n}){const{isEditing:r}=ki();return f.jsx("div",{className:"flex border-b mb-4 mt-2",style:{borderColor:"var(--yc-color-border)"},children:e.map(o=>f.jsx("button",{onClick:()=>n(o.name),disabled:r&&o.name!==t,className:nr("px-4 py-2 text-sm font-medium border-b-2 transition-colors",o.name===t?"border-blue-500 text-blue-600":"border-transparent hover:border-gray-300",r&&o.name!==t&&"opacity-50 cursor-not-allowed hover:border-transparent"),style:o.name!==t?{color:"var(--yc-color-text-secondary)"}:void 0,children:o.label},o.name))})}function NR({dashboardId:e,title:t,description:n,contentRef:r,tabs:o,activeTab:i,onTabChange:l,filters:c}){const{isEditing:d,pendingFilters:h,setPendingFilters:p}=ki(),y=Je(v=>Object.keys(v.crossFilters).length>0);N.useEffect(()=>{d&&!h&&p([...c])},[d]);const b=d&&h?h:c;return f.jsxs(f.Fragment,{children:[f.jsx(SR,{dashboardId:e,title:t,description:n,contentRef:r,activeTab:o?i:void 0}),o&&i&&l&&f.jsx(_R,{tabs:o,activeTab:i,onTabChange:l}),(b.length>0||!d&&y)&&f.jsx("div",{className:"yc-filter-bar sticky top-0 z-10 border-b px-6 py-3",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)"},children:f.jsx(kR,{filters:b,isEditing:d,onReorder:v=>p(v),onRename:(v,D)=>{const S=[...b];S[v]={...S[v],label:D},p(S)},showCrossFilters:!d})})]})}function DR({dashboardId:e,branch:t,initialTab:n}){const{data:r,isLoading:o,error:i}=c_(e,t),l=N.useRef(null),c=Wn(),d=Je(S=>S.globalFilters),[h,p]=N.useState(n||"");N.useEffect(()=>{r&&sessionStorage.setItem("yamchart-last-dashboard",JSON.stringify({name:r.name,title:r.title}))},[r==null?void 0:r.name,r==null?void 0:r.title]),N.useEffect(()=>{if(!(r!=null&&r.tabs))return;const S=r.tabs.map(T=>T.name);if(h&&S.includes(h))return;const E=n&&S.includes(n)?n:S[0];E&&p(E)},[r==null?void 0:r.tabs,n]);const y=Je(S=>S.clearAllCrossFilters),b=N.useCallback(S=>{var T;p(S),y();const E=`#/dashboards/${e}`;if(window.history.replaceState(null,"",`${E}?tab=${encodeURIComponent(S)}`),r!=null&&r.name){const k=pi(Object.fromEntries(Object.entries(d).filter(([I,L])=>L!=null)));xt.warmDashboardCache(r.name,k,S).catch(()=>{});const O=(T=r.tabs)==null?void 0:T.find(I=>I.name===S);if(O)for(const I of O.layout.rows)for(const L of I.widgets)L.type==="chart"&&L.ref&&c.prefetchQuery({queryKey:["chartWithData",L.ref,k],queryFn:()=>xt.queryChart(L.ref,k,{includeConfig:!0}),staleTime:1e3*60*5})}},[e,r==null?void 0:r.name,r==null?void 0:r.tabs,d,c,y]),v=N.useMemo(()=>{if(r){if(r.tabs){const S=r.tabs.find(E=>E.name===h);return S==null?void 0:S.layout}return r.layout}},[r,h]),D=N.useMemo(()=>{if(!r)return[];const S=r.filters||[];if(r.tabs){const E=r.tabs.find(k=>k.name===h),T=(E==null?void 0:E.filters)||[];return[...S,...T]}return S},[r,h]);return o?f.jsx("div",{className:"flex items-center justify-center h-64",children:f.jsx("div",{style:{color:"var(--yc-color-text-secondary)"},children:"Loading dashboard..."})}):i||!r?f.jsx("div",{className:"flex items-center justify-center h-64",children:f.jsxs("div",{style:{color:"var(--yc-color-danger)"},children:["Failed to load dashboard: ",(i==null?void 0:i.message)||"Unknown error"]})}):v?f.jsx(p4,{children:f.jsxs("div",{style:{backgroundColor:"var(--yc-color-background)"},children:[f.jsx(NR,{dashboardId:e,title:r.title,description:r.description,contentRef:l,tabs:r.tabs,activeTab:h,onTabChange:r.tabs?b:void 0,filters:D}),f.jsx("div",{ref:l,className:"p-6",children:f.jsx(ER,{layout:v,dashboardName:r.name})})]})}):f.jsx("div",{className:"flex items-center justify-center h-64",children:f.jsx("div",{style:{color:"var(--yc-color-text-secondary)"},children:"No layout available"})})}const OR=N.lazy(()=>ls(()=>import("./LoginPage-BwFMXS0X.js"),__vite__mapDeps([0,1])).then(e=>({default:e.LoginPage}))),AR=N.lazy(()=>ls(()=>import("./SetupWizard-CR7XCMkq.js"),__vite__mapDeps([2,1])).then(e=>({default:e.SetupWizard}))),IR=N.lazy(()=>ls(()=>import("./UserManagement-CHRB-6uy.js"),__vite__mapDeps([3,1])).then(e=>({default:e.UserManagement}))),MR=N.lazy(()=>ls(()=>import("./ShareManagement-B2ZU0Fdy.js"),__vite__mapDeps([4,1])).then(e=>({default:e.ShareManagement}))),LR=N.lazy(()=>ls(()=>import("./PublicViewer-70ErTigq.js"),__vite__mapDeps([5,1])).then(e=>({default:e.PublicViewer}))),RR=N.lazy(()=>ls(()=>import("./EventManagement-DSew47oL.js"),__vite__mapDeps([6,1])).then(e=>({default:e.EventManagement}))),Hc=()=>f.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:f.jsx("div",{className:"text-gray-500",children:"Loading..."})});function ax(e){const t=e.replace(/^#?/,""),n=t.match(/^\/settings\/(.+)$/);if(n&&n[1])return{type:"settings",name:n[1],params:{}};if(t==="/events")return{type:"events",name:"",params:{}};const[r,o]=t.split("?"),i=r==null?void 0:r.match(/^\/public\/(charts|dashboards)\/(.+)$/);if(i&&i[1]&&i[2]){const y={};if(o)for(const[b,v]of new URLSearchParams(o).entries())y[b]=v;return{type:i[1]==="dashboards"?"public_dashboard":"public_chart",name:decodeURIComponent(i[2]),params:y}}const[l,c]=t.split("?"),d=l==null?void 0:l.match(/^\/(charts)\/(.+)\/detail$/);if(d&&d[2]){const y={};if(c)for(const[b,v]of new URLSearchParams(c).entries())y[b]=v;return{type:"chart_detail",name:decodeURIComponent(d[2]),params:y}}const h=l==null?void 0:l.match(/^\/(dashboards|charts)\/(.+)$/);if(!h||!h[1]||!h[2])return null;const p={};if(c)for(const[y,b]of new URLSearchParams(c).entries())p[y]=b;return{type:h[1]==="dashboards"?"dashboard":"chart",name:decodeURIComponent(h[2]),params:p}}function PR(e,t){return f.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:f.jsxs("div",{className:"text-center max-w-md p-8",children:[f.jsx("div",{className:"w-12 h-12 mx-auto mb-4 rounded-full bg-red-50 flex items-center justify-center",children:f.jsx("svg",{className:"w-6 h-6 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),f.jsx("h1",{className:"text-lg font-semibold text-gray-900",children:"Something went wrong"}),f.jsx("p",{className:"text-sm text-gray-500 mt-2",children:e.message}),f.jsx("button",{onClick:()=>window.location.reload(),className:"mt-4 px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors",children:"Reload page"})]})})}function jR(){m_();const e=So(v=>v.auth),t=So(v=>v.checkAuth);N.useEffect(()=>{t()},[t]);const{data:n,isLoading:r}=ma(),{data:o,isLoading:i}=t2(),l=Je(v=>v.clearAllCrossFilters),[c,d]=N.useState(()=>window.location.hash.replace(/^#/,"")||"");N.useEffect(()=>{const v=()=>{d(window.location.hash.replace(/^#/,"")||""),l()};return window.addEventListener("hashchange",v),()=>window.removeEventListener("hashchange",v)},[l]);const h=N.useCallback(v=>{window.location.hash=v,d(v),l()},[l]);N.useEffect(()=>{r||i||c||(o&&o.length>0&&o[0]?h(`/dashboards/${o[0].name}`):n!=null&&n.charts&&n.charts.length>0&&n.charts[0]&&h(`/charts/${n.charts[0].name}`))},[r,i,o,n,c,h]);const p=ax(c);if(p&&(p.type==="public_chart"||p.type==="public_dashboard"))return f.jsx(N.Suspense,{fallback:f.jsx(Hc,{}),children:f.jsx(LR,{parsed:{type:p.type,name:p.name,params:p.params}})});if(e.status==="loading")return f.jsx(Hc,{});if(e.status==="needs_setup")return f.jsx(N.Suspense,{fallback:f.jsx(Hc,{}),children:f.jsx(AR,{})});if(e.status==="unauthenticated")return f.jsx(N.Suspense,{fallback:f.jsx(Hc,{}),children:f.jsx(OR,{})});if(r||i)return f.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:f.jsx("div",{className:"text-gray-500",children:"Loading..."})});const y=ax(c),b=()=>y?y.type==="settings"&&y.name==="users"?f.jsx(N.Suspense,{fallback:f.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:"Loading..."}),children:f.jsx(IR,{})}):y.type==="settings"&&y.name==="shares"?f.jsx(N.Suspense,{fallback:f.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:"Loading..."}),children:f.jsx(MR,{})}):y.type==="events"?f.jsx(N.Suspense,{fallback:f.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:"Loading..."}),children:f.jsx(RR,{})}):y.type==="dashboard"?f.jsx(DR,{dashboardId:y.name,initialTab:y.params.tab}):y.type==="chart_detail"?f.jsx(h4,{chartName:y.name,params:y.params}):f.jsx(f4,{chartName:y.name,drillParams:y.params}):f.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:"Select a dashboard or chart from the sidebar"});return f.jsx(Am,{fallback:PR,children:f.jsx(k_,{children:f.jsx(R_,{currentPath:c,onNavigate:h,onNavigateToUsers:()=>h("/settings/users"),onNavigateToShares:()=>h("/settings/shares"),children:b()})})})}Xw.createRoot(document.getElementById("root")).render(f.jsx(N.StrictMode,{children:f.jsx(NS,{children:f.jsx(jR,{})})}));export{ou as A,V2 as B,rd as C,B2 as D,F0 as E,P2 as F,nv as G,Z2 as H,q2 as L,B5 as M,G2 as P,T3 as S,B0 as T,tv as W,ls as _,xt as a,jx as b,nr as c,e2 as d,ma as e,Tm as f,Je as g,sv as h,ev as i,f as j,J2 as k,X2 as l,K2 as m,Q2 as n,DR as o,Wn as p,hr as q,Ka as r,ws as s,O3 as t,So as u,Qa as v,on as w};
187
+ `}),f.jsxs("div",{ref:b,style:{position:"relative"},children:[v>0&&r&&h==="lg"&&f.jsx(ED,{className:"yc-bg-grid",layout:tT,cols:eT,rowHeight:Ol,width:v,margin:[I,I],useCSSTransforms:!0,compactType:null,isDraggable:!1,isResizable:!1,autoSize:!1,children:vR}),v>0&&f.jsx(TD,{className:r?"layout yc-edit-grid":"layout",layouts:A,breakpoints:mR,cols:pR,rowHeight:Ol,width:v,margin:[I,I],isDraggable:r&&h==="lg",isResizable:r&&h==="lg",onLayoutChange:(q,X)=>{X.lg&&H(X.lg)},onDragStart:()=>{k.current=!0},onResizeStart:()=>{k.current=!0},onDragStop:q=>B([...q]),onResizeStop:q=>B([...q]),compactType:"vertical",autoSize:!0,useCSSTransforms:!0,children:C.map(({id:q,widget:X,rowIndex:ie,widgetIndex:ge})=>f.jsx("div",{className:"h-full",children:f.jsxs(hR,{onRemove:()=>z(ie,ge),widgetType:X.type,isContentEditing:S===q,onDoubleClick:X.type==="text"?()=>E(q):void 0,children:[X.type==="chart"&&X.ref&&f.jsx(_D,{chartRef:X.ref}),X.type==="text"&&f.jsx(fR,{content:X.content||"",onUpdate:te=>Q(ie,ge,te),isContentEditing:S===q,onEditStart:()=>E(q),onEditEnd:()=>E(null),dashboardName:n})]})},q))})]})]})}function TR({isOpen:e,onClose:t,onAdd:n,existingCharts:r}){const{data:o}=ma(),[i,l]=N.useState(""),c=N.useRef(null);if(N.useEffect(()=>{const y=v=>{v.key==="Escape"&&t()},b=v=>{c.current&&!c.current.contains(v.target)&&t()};return e&&(document.addEventListener("keydown",y),document.addEventListener("mousedown",b)),()=>{document.removeEventListener("keydown",y),document.removeEventListener("mousedown",b)}},[e,t]),!e)return null;const h=((o==null?void 0:o.charts)||[]).filter(y=>y.title.toLowerCase().includes(i.toLowerCase())||y.name.toLowerCase().includes(i.toLowerCase())),p=y=>{n({type:"chart",ref:y,cols:6}),t()};return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:f.jsxs("div",{ref:c,className:"rounded-lg shadow-xl w-full max-w-md mx-4",style:{backgroundColor:"var(--yc-color-surface)"},children:[f.jsxs("div",{className:"p-4 border-b",style:{borderColor:"var(--yc-color-border)"},children:[f.jsxs("div",{className:"flex items-center justify-between mb-3",children:[f.jsx("h2",{className:"text-lg font-semibold",style:{color:"var(--yc-color-text)"},children:"Add Chart"}),f.jsx("button",{onClick:t,className:"p-1 hover:opacity-80",style:{color:"var(--yc-color-text-muted)"},children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),f.jsx("input",{type:"text",placeholder:"Search charts...",value:i,onChange:y=>l(y.target.value),className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},autoFocus:!0})]}),f.jsx("div",{className:"max-h-80 overflow-y-auto",children:h.length===0?f.jsx("div",{className:"p-4 text-center text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No charts found"}):f.jsx("div",{className:"p-2",children:h.map(y=>{const b=r.includes(y.name);return f.jsxs("button",{onClick:()=>p(y.name),disabled:b,className:"w-full text-left px-3 py-3 rounded-md hover:bg-black/5 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-between group",children:[f.jsxs("div",{children:[f.jsx("div",{className:"font-medium",style:{color:"var(--yc-color-text)"},children:y.title}),f.jsx("div",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:y.name}),y.description&&f.jsx("div",{className:"text-xs mt-1",style:{color:"var(--yc-color-text-muted)"},children:y.description})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-xs px-2 py-1 rounded",style:{color:"var(--yc-color-text-muted)",backgroundColor:"var(--yc-color-surface-hover)"},children:y.type}),b?f.jsx("span",{className:"text-xs",style:{color:"var(--yc-color-success)"},children:"Added"}):f.jsx("svg",{className:"w-5 h-5 opacity-0 group-hover:opacity-100",style:{color:"var(--yc-color-text-muted)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})]})]},y.name)})})})]})})}function wR(e){const t=Math.floor((Date.now()-e)/1e3);if(t<10)return"just now";if(t<60)return`${t}s ago`;const n=Math.floor(t/60);if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:new Date(e).toLocaleDateString()}function SR({dashboardId:e,title:t,description:n,contentRef:r,activeTab:o}){const{isEditing:i,setIsEditing:l,pendingLayout:c,setPendingLayout:d,setOriginalLayout:h,hasChanges:p,addWidget:y,currentLayout:b,undo:v,redo:D,canUndo:S,canRedo:E}=ki(),T=dm(),k=d_(e),O=f_(),I=_S({queryKey:["chartData"]}),L=Wn(),_=(()=>{const M=L.getQueryCache();let V=0;for(const ae of M.getAll()){const j=ae.queryKey[0];(j==="chartData"||j==="chartWithData")&&ae.state.dataUpdatedAt>V&&(V=ae.state.dataUpdatedAt)}return V>0?V:null})(),[C,A]=N.useState(!1),[P,H]=N.useState(!1),[B,z]=N.useState(!1),[Q,q]=N.useState(!1),X=(b==null?void 0:b.rows.flatMap(M=>M.widgets.filter(V=>V.type==="chart"&&V.ref).map(V=>V.ref)))||[],ie=()=>{O()},ge=async M=>{if(r.current){q(!0),A(!1);try{M==="pdf"?await M3(r.current,`${e}-dashboard`,t):await I3(r.current,`${e}-dashboard`,M)}finally{q(!1)}}},te=async()=>{if(c)try{await k.mutateAsync({layout:c,tab:o}),h(c),d(null),l(!1)}catch(M){console.error("Failed to save:",M)}},de=()=>{d(null),l(!1)};return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"border-b",style:{borderColor:"var(--yc-color-border)",backgroundColor:"var(--yc-color-surface)"},children:[f.jsxs("div",{className:"flex items-center justify-between p-4",children:[f.jsx("div",{children:f.jsx("h1",{className:"text-xl font-semibold",style:{color:"var(--yc-color-text)"},children:t})}),f.jsx("div",{className:"flex items-center gap-2",children:i?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"relative",children:[f.jsxs("button",{onClick:()=>z(!B),className:"flex items-center gap-2 px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 rounded-md hover:bg-blue-100",children:[f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add Widget",f.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),B&&f.jsxs("div",{className:"absolute left-0 top-full mt-1 w-40 rounded-md shadow-lg border z-50 py-1",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)"},children:[f.jsxs("button",{onClick:()=>{z(!1),H(!0)},className:"w-full text-left px-4 py-2 text-sm hover:bg-black/5 flex items-center gap-2",style:{color:"var(--yc-color-text)"},children:[f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),"Chart"]}),f.jsxs("button",{onClick:()=>{z(!1),y({type:"text",content:"",cols:6})},className:"w-full text-left px-4 py-2 text-sm hover:bg-black/5 flex items-center gap-2",style:{color:"var(--yc-color-text)"},children:[f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h7"})}),"Text"]})]})]}),f.jsxs("div",{className:"flex items-center",children:[f.jsx("button",{onClick:v,disabled:!S,className:"p-2 hover:bg-black/5 rounded-md disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--yc-color-text-secondary)"},title:"Undo (Cmd+Z)",children:f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a5 5 0 015 5v2M3 10l4-4m-4 4l4 4"})})}),f.jsx("button",{onClick:D,disabled:!E,className:"p-2 hover:bg-black/5 rounded-md disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--yc-color-text-secondary)"},title:"Redo (Cmd+Shift+Z)",children:f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 10H11a5 5 0 00-5 5v2m15-7l-4-4m4 4l-4 4"})})})]}),f.jsx("div",{className:"w-px h-6 mx-2",style:{backgroundColor:"var(--yc-color-border)"}}),f.jsx("button",{onClick:de,className:"px-4 py-2 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Cancel"}),f.jsx("button",{onClick:te,disabled:!p||k.isPending,className:nr("px-4 py-2 text-sm font-medium rounded-md",p?"bg-blue-600 text-white hover:bg-blue-700":"cursor-not-allowed"),style:p?void 0:{backgroundColor:"var(--yc-color-surface-hover)",color:"var(--yc-color-text-muted)"},children:k.isPending?"Saving...":"Save & Push"})]}):f.jsxs(f.Fragment,{children:[_&&I===0&&f.jsxs("span",{className:"text-xs",style:{color:"var(--yc-color-text-muted)"},title:new Date(_).toLocaleString(),children:["Updated ",wR(_)]}),f.jsx("button",{onClick:ie,disabled:I>0,className:"p-2 hover:bg-black/5 rounded-md disabled:opacity-50",style:{color:"var(--yc-color-text-secondary)"},title:"Refresh all charts",children:f.jsx("svg",{className:nr("w-5 h-5",I>0&&"animate-spin"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),f.jsxs("div",{className:"relative",children:[f.jsx("button",{onClick:()=>A(!C),disabled:Q,className:"p-2 hover:bg-black/5 rounded-md disabled:opacity-50",style:{color:"var(--yc-color-text-secondary)"},title:"Export dashboard",children:Q?f.jsxs("svg",{className:"w-5 h-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[f.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),f.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})})}),C&&f.jsxs("div",{className:"absolute right-0 top-full mt-1 w-40 rounded-md shadow-lg border z-50 py-1",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)"},children:[f.jsxs("button",{onClick:()=>ge("png"),className:"w-full text-left px-4 py-2 text-sm hover:bg-black/5 flex items-center gap-2",style:{color:"var(--yc-color-text)"},children:[f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),"Export PNG"]}),f.jsxs("button",{onClick:()=>ge("jpeg"),className:"w-full text-left px-4 py-2 text-sm hover:bg-black/5 flex items-center gap-2",style:{color:"var(--yc-color-text)"},children:[f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),"Export JPEG"]}),f.jsxs("button",{onClick:()=>ge("pdf"),className:"w-full text-left px-4 py-2 text-sm hover:bg-black/5 flex items-center gap-2",style:{color:"var(--yc-color-text)"},children:[f.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),"Export PDF"]})]})]}),T==="lg"?f.jsx("button",{onClick:()=>l(!0),className:"p-2 hover:bg-black/5 rounded-md",style:{color:"var(--yc-color-text-secondary)"},title:"Edit layout",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}):f.jsx("button",{disabled:!0,className:"p-2 rounded-md",style:{opacity:.5,cursor:"not-allowed",color:"var(--yc-color-text-muted)"},title:"Editing requires a desktop browser",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})})]})})]}),n&&f.jsx("p",{className:"px-4 pb-3 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:n})]}),f.jsx(TR,{isOpen:P,onClose:()=>H(!1),onAdd:y,existingCharts:X})]})}function kR({filters:e,isEditing:t,onReorder:n,onRename:r,showCrossFilters:o}){const[i,l]=N.useState(null),[c,d]=N.useState(null),h=Je(I=>I.globalFilters),p=Je(I=>I.resetFilters),y=Je(I=>I.crossFilters),b=Je(I=>I.clearCrossFilter),v=Je(I=>I.clearAllCrossFilters),D=o?Object.values(y):[];if(e.length===0&&D.length===0)return null;const S=e.some(I=>{const L=h[I.name];if(L==null||L===""||Array.isArray(L)&&L.length===0)return!1;const _=I.default??(I.type==="date_range"?"last_30_days":void 0);return JSON.stringify(L)!==JSON.stringify(_)});function E(I,L){l(L),I.dataTransfer.effectAllowed="move"}function T(I,L){I.preventDefault(),I.dataTransfer.dropEffect="move",d(L)}function k(I,L){if(I.preventDefault(),i===null||i===L)return;const _=[...e],C=_.splice(i,1)[0];_.splice(L,0,C),n==null||n(_),l(null),d(null)}function O(){l(null),d(null)}return t?f.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.map((I,L)=>{const _=I.label||ca(I.name),C=i===L?"opacity-50":"";return f.jsxs("div",{draggable:!0,onDragStart:A=>E(A,L),onDragOver:A=>T(A,L),onDrop:A=>k(A,L),onDragEnd:O,className:`flex items-center gap-1.5 border rounded-full px-3 py-1.5 text-sm cursor-grab active:cursor-grabbing transition-colors ${C}`,style:c===L?{borderColor:"var(--yc-color-primary)",backgroundColor:"color-mix(in srgb, var(--yc-color-primary) 10%, transparent)"}:{borderColor:"var(--yc-color-border, #e5e7eb)",backgroundColor:"var(--yc-color-surface)"},children:[f.jsx("svg",{className:"w-2.5 h-2.5 flex-shrink-0",style:{color:"var(--yc-color-text-muted)"},fill:"currentColor",viewBox:"0 0 20 20",children:f.jsx("path",{d:"M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z"})}),f.jsx(CR,{value:_,onChange:A=>r==null?void 0:r(L,A)}),f.jsx("svg",{className:"w-3 h-3 flex-shrink-0",style:{color:"var(--yc-color-text-muted)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]},I.name)})}):f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.map(I=>{const L=I.label||ca(I.name),_=typeof I.default=="string"?I.default:void 0;switch(I.type){case"date_range":return f.jsx(_2,{name:I.name,label:L,defaultValue:_},I.name);case"select":{const C=(I.options||[]).map(A=>typeof A=="string"?{value:A,label:A}:A);return f.jsx(Jc,{name:I.name,label:L,options:C,defaultValue:_},I.name)}case"dynamic_select":return I.source?f.jsx(Jc,{name:I.name,label:L,source:I.source,defaultValue:_},I.name):f.jsxs("div",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:[L,": dynamic_select requires source"]},I.name);case"multi_select":{const C=(I.options||[]).map(A=>typeof A=="string"?{value:A,label:A}:A);return f.jsx(N2,{name:I.name,label:L,options:C,defaultValue:Array.isArray(I.default)?I.default:void 0,source:I.source},I.name)}case"text":return f.jsx(A2,{name:I.name,label:L,defaultValue:_},I.name);case"number":return f.jsx(L2,{name:I.name,label:L,defaultValue:typeof I.default=="number"?I.default:void 0},I.name);case"boolean":return f.jsx(R2,{name:I.name,label:L},I.name);default:return f.jsxs("div",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:[L,": ",I.type," (not supported)"]},I.name)}}),D.length>0&&e.length>0&&f.jsx("div",{className:"w-px h-6 mx-1",style:{backgroundColor:"var(--yc-color-border)"}}),D.map(I=>f.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1.5 text-sm rounded-full",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-primary) 10%, transparent)",color:"var(--yc-color-primary)",border:"1px solid color-mix(in srgb, var(--yc-color-primary) 30%, transparent)"},children:[I.field,": ",H0(I.value),f.jsx("button",{onClick:()=>b(I.field),className:"ml-0.5 hover:opacity-80","aria-label":`Clear ${I.field} filter`,children:f.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",children:f.jsx("path",{d:"M3 3l6 6M9 3l-6 6"})})})]},`cf-${I.field}`)),(S||D.length>0)&&f.jsx("button",{type:"button",onClick:()=>{S&&p(),D.length>0&&v()},className:"text-sm px-2 py-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",style:{color:"var(--yc-color-text-muted)"},children:"Clear all"})]})}function CR({value:e,onChange:t}){const[n,r]=N.useState(!1),[o,i]=N.useState(e);if(!n)return f.jsx("span",{className:"text-sm font-medium cursor-text hover:text-blue-600 hover:underline",style:{color:"var(--yc-color-text)"},onClick:c=>{c.stopPropagation(),r(!0),i(e)},title:"Click to rename",children:e});function l(){o.trim()&&o!==e&&t(o.trim()),r(!1)}return f.jsx("input",{autoFocus:!0,value:o,onChange:c=>i(c.target.value),onBlur:l,onKeyDown:c=>{c.key==="Enter"&&l(),c.key==="Escape"&&r(!1)},className:"text-sm font-medium border border-blue-300 rounded px-1 py-0 outline-none w-32",style:{color:"var(--yc-color-text)",backgroundColor:"var(--yc-color-surface)"},onClick:c=>c.stopPropagation()})}function _R({tabs:e,activeTab:t,onTabChange:n}){const{isEditing:r}=ki();return f.jsx("div",{className:"flex border-b mb-4 mt-2",style:{borderColor:"var(--yc-color-border)"},children:e.map(o=>f.jsx("button",{onClick:()=>n(o.name),disabled:r&&o.name!==t,className:nr("px-4 py-2 text-sm font-medium border-b-2 transition-colors",o.name===t?"border-blue-500 text-blue-600":"border-transparent hover:border-gray-300",r&&o.name!==t&&"opacity-50 cursor-not-allowed hover:border-transparent"),style:o.name!==t?{color:"var(--yc-color-text-secondary)"}:void 0,children:o.label},o.name))})}function NR({dashboardId:e,title:t,description:n,contentRef:r,tabs:o,activeTab:i,onTabChange:l,filters:c}){const{isEditing:d,pendingFilters:h,setPendingFilters:p}=ki(),y=Je(v=>Object.keys(v.crossFilters).length>0);N.useEffect(()=>{d&&!h&&p([...c])},[d]);const b=d&&h?h:c;return f.jsxs(f.Fragment,{children:[f.jsx(SR,{dashboardId:e,title:t,description:n,contentRef:r,activeTab:o?i:void 0}),o&&i&&l&&f.jsx(_R,{tabs:o,activeTab:i,onTabChange:l}),(b.length>0||!d&&y)&&f.jsx("div",{className:"yc-filter-bar sticky top-0 z-10 border-b px-6 py-3",style:{backgroundColor:"var(--yc-color-surface)",borderColor:"var(--yc-color-border)"},children:f.jsx(kR,{filters:b,isEditing:d,onReorder:v=>p(v),onRename:(v,D)=>{const S=[...b];S[v]={...S[v],label:D},p(S)},showCrossFilters:!d})})]})}function DR({dashboardId:e,branch:t,initialTab:n}){const{data:r,isLoading:o,error:i}=c_(e,t),l=N.useRef(null),c=Wn(),d=Je(S=>S.globalFilters),[h,p]=N.useState(n||"");N.useEffect(()=>{r&&sessionStorage.setItem("yamchart-last-dashboard",JSON.stringify({name:r.name,title:r.title}))},[r==null?void 0:r.name,r==null?void 0:r.title]),N.useEffect(()=>{if(!(r!=null&&r.tabs))return;const S=r.tabs.map(T=>T.name);if(h&&S.includes(h))return;const E=n&&S.includes(n)?n:S[0];E&&p(E)},[r==null?void 0:r.tabs,n]);const y=Je(S=>S.clearAllCrossFilters),b=N.useCallback(S=>{var T;p(S),y();const E=`#/dashboards/${e}`;if(window.history.replaceState(null,"",`${E}?tab=${encodeURIComponent(S)}`),r!=null&&r.name){const k=pi(Object.fromEntries(Object.entries(d).filter(([I,L])=>L!=null)));xt.warmDashboardCache(r.name,k,S).catch(()=>{});const O=(T=r.tabs)==null?void 0:T.find(I=>I.name===S);if(O)for(const I of O.layout.rows)for(const L of I.widgets)L.type==="chart"&&L.ref&&c.prefetchQuery({queryKey:["chartWithData",L.ref,k],queryFn:()=>xt.queryChart(L.ref,k,{includeConfig:!0}),staleTime:1e3*60*5})}},[e,r==null?void 0:r.name,r==null?void 0:r.tabs,d,c,y]),v=N.useMemo(()=>{if(r){if(r.tabs){const S=r.tabs.find(E=>E.name===h);return S==null?void 0:S.layout}return r.layout}},[r,h]),D=N.useMemo(()=>{if(!r)return[];const S=r.filters||[];if(r.tabs){const E=r.tabs.find(k=>k.name===h),T=(E==null?void 0:E.filters)||[];return[...S,...T]}return S},[r,h]);return o?f.jsx("div",{className:"flex items-center justify-center h-64",children:f.jsx("div",{style:{color:"var(--yc-color-text-secondary)"},children:"Loading dashboard..."})}):i||!r?f.jsx("div",{className:"flex items-center justify-center h-64",children:f.jsxs("div",{style:{color:"var(--yc-color-danger)"},children:["Failed to load dashboard: ",(i==null?void 0:i.message)||"Unknown error"]})}):v?f.jsx(p4,{children:f.jsxs("div",{style:{backgroundColor:"var(--yc-color-background)"},children:[f.jsx(NR,{dashboardId:e,title:r.title,description:r.description,contentRef:l,tabs:r.tabs,activeTab:h,onTabChange:r.tabs?b:void 0,filters:D}),f.jsx("div",{ref:l,className:"p-6",children:f.jsx(ER,{layout:v,dashboardName:r.name})})]})}):f.jsx("div",{className:"flex items-center justify-center h-64",children:f.jsx("div",{style:{color:"var(--yc-color-text-secondary)"},children:"No layout available"})})}const OR=N.lazy(()=>ls(()=>import("./LoginPage-B2bo8Eck.js"),__vite__mapDeps([0,1])).then(e=>({default:e.LoginPage}))),AR=N.lazy(()=>ls(()=>import("./SetupWizard-utnbmxeP.js"),__vite__mapDeps([2,1])).then(e=>({default:e.SetupWizard}))),IR=N.lazy(()=>ls(()=>import("./UserManagement-DAOq9eUf.js"),__vite__mapDeps([3,1])).then(e=>({default:e.UserManagement}))),MR=N.lazy(()=>ls(()=>import("./ShareManagement-6iYAjCrr.js"),__vite__mapDeps([4,1])).then(e=>({default:e.ShareManagement}))),LR=N.lazy(()=>ls(()=>import("./PublicViewer-B_3K2MkZ.js"),__vite__mapDeps([5,1])).then(e=>({default:e.PublicViewer}))),RR=N.lazy(()=>ls(()=>import("./EventManagement-DmRy5bu3.js"),__vite__mapDeps([6,1])).then(e=>({default:e.EventManagement}))),Hc=()=>f.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:f.jsx("div",{className:"text-gray-500",children:"Loading..."})});function ax(e){const t=e.replace(/^#?/,""),n=t.match(/^\/settings\/(.+)$/);if(n&&n[1])return{type:"settings",name:n[1],params:{}};if(t==="/events")return{type:"events",name:"",params:{}};const[r,o]=t.split("?"),i=r==null?void 0:r.match(/^\/public\/(charts|dashboards)\/(.+)$/);if(i&&i[1]&&i[2]){const y={};if(o)for(const[b,v]of new URLSearchParams(o).entries())y[b]=v;return{type:i[1]==="dashboards"?"public_dashboard":"public_chart",name:decodeURIComponent(i[2]),params:y}}const[l,c]=t.split("?"),d=l==null?void 0:l.match(/^\/(charts)\/(.+)\/detail$/);if(d&&d[2]){const y={};if(c)for(const[b,v]of new URLSearchParams(c).entries())y[b]=v;return{type:"chart_detail",name:decodeURIComponent(d[2]),params:y}}const h=l==null?void 0:l.match(/^\/(dashboards|charts)\/(.+)$/);if(!h||!h[1]||!h[2])return null;const p={};if(c)for(const[y,b]of new URLSearchParams(c).entries())p[y]=b;return{type:h[1]==="dashboards"?"dashboard":"chart",name:decodeURIComponent(h[2]),params:p}}function PR(e,t){return f.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:f.jsxs("div",{className:"text-center max-w-md p-8",children:[f.jsx("div",{className:"w-12 h-12 mx-auto mb-4 rounded-full bg-red-50 flex items-center justify-center",children:f.jsx("svg",{className:"w-6 h-6 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),f.jsx("h1",{className:"text-lg font-semibold text-gray-900",children:"Something went wrong"}),f.jsx("p",{className:"text-sm text-gray-500 mt-2",children:e.message}),f.jsx("button",{onClick:()=>window.location.reload(),className:"mt-4 px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors",children:"Reload page"})]})})}function jR(){m_();const e=So(v=>v.auth),t=So(v=>v.checkAuth);N.useEffect(()=>{t()},[t]);const{data:n,isLoading:r}=ma(),{data:o,isLoading:i}=t2(),l=Je(v=>v.resetFilters),[c,d]=N.useState(()=>window.location.hash.replace(/^#/,"")||"");N.useEffect(()=>{const v=()=>{d(window.location.hash.replace(/^#/,"")||""),l()};return window.addEventListener("hashchange",v),()=>window.removeEventListener("hashchange",v)},[l]);const h=N.useCallback(v=>{window.location.hash=v,d(v),l()},[l]);N.useEffect(()=>{r||i||c||(o&&o.length>0&&o[0]?h(`/dashboards/${o[0].name}`):n!=null&&n.charts&&n.charts.length>0&&n.charts[0]&&h(`/charts/${n.charts[0].name}`))},[r,i,o,n,c,h]);const p=ax(c);if(p&&(p.type==="public_chart"||p.type==="public_dashboard"))return f.jsx(N.Suspense,{fallback:f.jsx(Hc,{}),children:f.jsx(LR,{parsed:{type:p.type,name:p.name,params:p.params}})});if(e.status==="loading")return f.jsx(Hc,{});if(e.status==="needs_setup")return f.jsx(N.Suspense,{fallback:f.jsx(Hc,{}),children:f.jsx(AR,{})});if(e.status==="unauthenticated")return f.jsx(N.Suspense,{fallback:f.jsx(Hc,{}),children:f.jsx(OR,{})});if(r||i)return f.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:f.jsx("div",{className:"text-gray-500",children:"Loading..."})});const y=ax(c),b=()=>y?y.type==="settings"&&y.name==="users"?f.jsx(N.Suspense,{fallback:f.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:"Loading..."}),children:f.jsx(IR,{})}):y.type==="settings"&&y.name==="shares"?f.jsx(N.Suspense,{fallback:f.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:"Loading..."}),children:f.jsx(MR,{})}):y.type==="events"?f.jsx(N.Suspense,{fallback:f.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:"Loading..."}),children:f.jsx(RR,{})}):y.type==="dashboard"?f.jsx(DR,{dashboardId:y.name,initialTab:y.params.tab}):y.type==="chart_detail"?f.jsx(h4,{chartName:y.name,params:y.params}):f.jsx(f4,{chartName:y.name,drillParams:y.params}):f.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:"Select a dashboard or chart from the sidebar"});return f.jsx(Am,{fallback:PR,children:f.jsx(k_,{children:f.jsx(R_,{currentPath:c,onNavigate:h,onNavigateToUsers:()=>h("/settings/users"),onNavigateToShares:()=>h("/settings/shares"),children:b()})})})}Xw.createRoot(document.getElementById("root")).render(f.jsx(N.StrictMode,{children:f.jsx(NS,{children:f.jsx(jR,{})})}));export{ou as A,V2 as B,rd as C,B2 as D,F0 as E,P2 as F,nv as G,Z2 as H,q2 as L,B5 as M,G2 as P,T3 as S,B0 as T,tv as W,ls as _,xt as a,jx as b,nr as c,e2 as d,ma as e,Tm as f,Je as g,sv as h,ev as i,f as j,J2 as k,X2 as l,K2 as m,Q2 as n,DR as o,Wn as p,hr as q,Ka as r,ws as s,O3 as t,So as u,Qa as v,on as w};