ocean-brain 0.10.0 → 0.11.0

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 (80) hide show
  1. package/dist/mcp.js +58 -32
  2. package/package.json +2 -2
  3. package/server/client/dist/assets/{ArrowRight.es-Bm-ZXpEC.js → ArrowRight.es-BEhnlwfe.js} +1 -1
  4. package/server/client/dist/assets/AuxiliaryPanelHeader-B1k7pZpn.js +1 -0
  5. package/server/client/dist/assets/Calendar-D7QJsAlg.js +25 -0
  6. package/server/client/dist/assets/{Callout-CviyPHKO.js → Callout-BTd1BYtV.js} +1 -1
  7. package/server/client/dist/assets/{Copy.es-BPreRnP9.js → Copy.es-BoLjilxv.js} +1 -1
  8. package/server/client/dist/assets/File.es-Ct7fscBg.js +1 -0
  9. package/server/client/dist/assets/{Graph-yPE3ljW0.js → Graph-DYUb7gQb.js} +1 -1
  10. package/server/client/dist/assets/{Graph-vXQQ0a-Q.js → Graph-LY_IgMYy.js} +1 -1
  11. package/server/client/dist/assets/{Image.es-DnR3qc_c.js → Image.es-OYyN3BYt.js} +1 -1
  12. package/server/client/dist/assets/Note-DsMhwrHw.js +25 -0
  13. package/server/client/dist/assets/NotePropertiesPanel-aCKXAe5F.js +2 -0
  14. package/server/client/dist/assets/{PencilLine.es-B9V6u64t.js → PencilLine.es-0JpEgxFY.js} +1 -1
  15. package/server/client/dist/assets/{Plus.es-CRRp2u5J.js → Plus.es-DRfLW_bI.js} +1 -1
  16. package/server/client/dist/assets/{Reminders-BOtfNeYD.js → Reminders-COr1OHvF.js} +1 -1
  17. package/server/client/dist/assets/Search-Ctkx0BQk.js +31 -0
  18. package/server/client/dist/assets/{SurfaceCard-GMt5xM7v.js → SurfaceCard-t7pdfhEe.js} +1 -1
  19. package/server/client/dist/assets/Tag-BjxtrIQW.js +1 -0
  20. package/server/client/dist/assets/TagNotes-DV_fdRbg.js +1 -0
  21. package/server/client/dist/assets/{Trash.es-svHOb5LN.js → Trash.es-Bo1VyK9Q.js} +1 -1
  22. package/server/client/dist/assets/ViewChip-DlCkL4z4.js +1 -0
  23. package/server/client/dist/assets/ViewNotes-wWWeFJyU.js +1 -0
  24. package/server/client/dist/assets/ViewSectionDialog-DhH8harC.js +102 -0
  25. package/server/client/dist/assets/Views-CWE99SnI.js +1 -0
  26. package/server/client/dist/assets/app-B9WZRrAH.css +1 -0
  27. package/server/client/dist/assets/app-BpSMjzET.js +26 -0
  28. package/server/client/dist/assets/{image.api-QmHYjp3z.js → image.api-CyQisInP.js} +1 -1
  29. package/server/client/dist/assets/index-B-E1Ilh9.js +1 -0
  30. package/server/client/dist/assets/manage-image-azmo5iVw.js +1 -0
  31. package/server/client/dist/assets/manage-image-detail-BF-uSqb_.js +1 -0
  32. package/server/client/dist/assets/{mcp-uFZkdhCi.js → mcp-CCaFd0zm.js} +1 -1
  33. package/server/client/dist/assets/mcp-admin-adapter-PMmgPupc.js +1 -0
  34. package/server/client/dist/assets/{note-ui-CxK8ymUc.js → note-ui-CtijppHK.js} +1 -1
  35. package/server/client/dist/assets/{note.api-BQovzEzd.js → note.api-D3oJmG3q.js} +2 -2
  36. package/server/client/dist/assets/{placeholder-D3b8lZGE.js → placeholder-AusSo8p9.js} +2 -2
  37. package/server/client/dist/assets/{properties-M-yWq1D7.js → properties-BrNJLkxR.js} +1 -1
  38. package/server/client/dist/assets/route-preload.js +2 -2
  39. package/server/client/dist/assets/search-D-xKTPdO.js +1 -0
  40. package/server/client/dist/assets/search-admin-adapter-CJnJmL6w.js +1 -0
  41. package/server/client/dist/assets/{tag.api-DUfjr8bg.js → tag.api-DNSQpqwk.js} +1 -1
  42. package/server/client/dist/assets/{time-CfAYZipR.js → time-D5LRMumI.js} +3 -3
  43. package/server/client/dist/assets/trash-D4-9sv8q.js +1 -0
  44. package/server/client/dist/assets/{useReminderMutate--omDLmBV.js → useReminderMutate-BrGO9M0o.js} +1 -1
  45. package/server/client/dist/index.html +5 -5
  46. package/server/dist/features/note/graphql/note.field.resolver.js +2 -0
  47. package/server/dist/features/note/graphql/note.mutation.resolver.js +19 -14
  48. package/server/dist/features/note/graphql/note.query.resolver.js +15 -5
  49. package/server/dist/features/note/graphql/note.type-defs.js +1 -0
  50. package/server/dist/features/note/services/authoring.js +15 -10
  51. package/server/dist/features/note/services/note-reference-index.js +98 -0
  52. package/server/dist/features/note/services/search.js +5 -0
  53. package/server/dist/features/note/services/snapshot.js +4 -0
  54. package/server/dist/features/note/services/trash.js +2 -0
  55. package/server/dist/features/note/services/write.js +10 -3
  56. package/server/dist/features/search/graphql/resolver.js +13 -1
  57. package/server/dist/features/search/graphql/type-defs.js +7 -0
  58. package/server/dist/features/search/hybrid-ranking.js +4 -2
  59. package/server/dist/features/search/hybrid-search.js +4 -2
  60. package/server/dist/features/search/related-notes.js +186 -0
  61. package/server/dist/main.js +10 -3
  62. package/server/prisma/migrations/20260728090000_0019_note_reference_index/migration.sql +15 -0
  63. package/server/prisma/schema.prisma +16 -0
  64. package/server/client/dist/assets/Calendar-BsNs3NzO.js +0 -25
  65. package/server/client/dist/assets/Note-CmreVzvQ.js +0 -25
  66. package/server/client/dist/assets/NotePropertiesPanel-DXYgE8h2.js +0 -2
  67. package/server/client/dist/assets/Search-C-FB3pKf.js +0 -1
  68. package/server/client/dist/assets/Tag-lBxDRE77.js +0 -1
  69. package/server/client/dist/assets/TagNotes-Bgorp_rC.js +0 -1
  70. package/server/client/dist/assets/ViewNotes-C7d10VFf.js +0 -1
  71. package/server/client/dist/assets/ViewSectionDialog-Bhw-ILop.js +0 -102
  72. package/server/client/dist/assets/Views-C7V3saUo.js +0 -1
  73. package/server/client/dist/assets/app-DQBV36r_.js +0 -50
  74. package/server/client/dist/assets/app-ZgwR5t_I.css +0 -1
  75. package/server/client/dist/assets/index-CaF9d-zG.js +0 -1
  76. package/server/client/dist/assets/manage-image-DCDF8AM9.js +0 -1
  77. package/server/client/dist/assets/manage-image-detail-e0ViRAj-.js +0 -1
  78. package/server/client/dist/assets/mcp-admin-adapter-D39G3udJ.js +0 -1
  79. package/server/client/dist/assets/search-DFnzZKLd.js +0 -1
  80. package/server/client/dist/assets/trash-CClKfP1x.js +0 -1
@@ -0,0 +1,25 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-B14ZAmWA.js","assets/preload-helper-BXl3LOEh.js","assets/floating-ui.react-dom-BWTnA00G.js","assets/transform-BUB79_za.js","assets/katex-DywYRkvg.css"])))=>i.map(i=>d[i]);
2
+ import{r as o,j as a}from"./floating-ui.react-dom-BWTnA00G.js";import{af as jn,A as vt,T as j,i as yt,m as Sn,q as B,M as D,B as k,c as K,G as wt,D as Ct,R as Rn,e as Re,u as Ze,ag as An,ah as En,ai as kn,L as Be,I as Tn,d as Dn,a as Mn,b as Fe,a0 as Pn,s as _n,aj as Ln,$ as Nt,ab as jt,ak as We,al as On,U as Bn,ac as Fn,ad as Hn,am as $n,Q as qe,P as Ge,an as Qe,h as In,l as ie,F as Un}from"./note.api-D3oJmG3q.js";import{M as xe,k as zn,r as Wn,f as St,m as Kn,a as He,b as Vn,d as G,s as Yn,l as Rt,o as Zn,p as At,q as Et,v as qn,w as nt,e as Gn}from"./time-D5LRMumI.js";import{m as Qn,c as Jn,C as rt}from"./Callout-BTd1BYtV.js";import{J as kt,A as Tt,N as Xn}from"./NotePropertiesPanel-aCKXAe5F.js";import{N as Ae,T as er,S as tr}from"./url-9nrbQs7Z.js";import{S as nr}from"./SurfaceCard-t7pdfhEe.js";import{u as rr,R as ar}from"./useReminderMutate-BrGO9M0o.js";import{n as sr}from"./Plus.es-DRfLW_bI.js";import{h as Je,m as or,L as Dt,Z as Mt,M as ir,K as cr,a as lr}from"./note-ui-CtijppHK.js";import{u as dr}from"./image.api-CyQisInP.js";import{L as ur,t as at,q as fr,B as he,G as pr,y as st}from"./note-core-DUTqUh5N.js";import{_ as Ke}from"./preload-helper-BXl3LOEh.js";import{s as mr}from"./Copy.es-BoLjilxv.js";import{m as hr}from"./PencilLine.es-0JpEgxFY.js";import{A as gr,p as xr}from"./AuxiliaryPanelHeader-B1k7pZpn.js";import{f as br,c as vr}from"./tag.api-DNSQpqwk.js";import{cn as ot}from"./note-runtime-zN5ddTba.js";import{s as yr}from"./File.es-Ct7fscBg.js";function wr(e,n){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in e)return e;if(typeof e=="function")return{shouldBlockFn:async()=>await e(),enableBeforeUnload:!0,withResolver:!1};const t=!!(e.condition??!0),s=e.blockerFn;return{shouldBlockFn:async()=>t&&s!==void 0?await s():t,enableBeforeUnload:t,withResolver:s===void 0}}function Cr(e,n){const{shouldBlockFn:t,enableBeforeUnload:s=!0,disabled:r=!1,withResolver:i=!1}=wr(e),l=jn(),{history:c}=l,[f,u]=o.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return o.useEffect(()=>{const p=async g=>{function x(A){const w=l.parseLocation(A),m=l.getMatchedRoutes(w.pathname);return m.foundRoute===void 0?{routeId:"__notFound__",fullPath:w.pathname,pathname:w.pathname,params:m.routeParams,search:l.options.parseSearch(A.search)}:{routeId:m.foundRoute.id,fullPath:m.foundRoute.fullPath,pathname:w.pathname,params:m.routeParams,search:l.options.parseSearch(A.search)}}const d=x(g.currentLocation),h=x(g.nextLocation);if(d.routeId==="__notFound__"&&h.routeId!=="__notFound__")return!1;const y=await t({action:g.action,current:d,next:h});if(!i)return y;if(!y)return!1;const S=await new Promise(A=>{u({status:"blocked",current:d,next:h,action:g.action,proceed:()=>A(!1),reset:()=>A(!0)})});return u({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),S};return r?void 0:c.block({blockerFn:p,enableBeforeUnload:s})},[t,s,r,i,c,l]),f}const Nr=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M248.49,71.51l-32-32a12,12,0,0,0-17,17L211,68h-3c-52,0-64.8,30.71-75.08,55.38-8.82,21.17-15.45,37.05-42.75,40.09a44,44,0,1,0,.28,24.08c43.34-3.87,55.07-32,64.63-54.93C164.9,109,172,92,208,92h3l-11.52,11.51a12,12,0,0,0,17,17l32-32A12,12,0,0,0,248.49,71.51ZM48,196a20,20,0,1,1,20-20A20,20,0,0,1,48,196Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M80,176a32,32,0,1,1-32-32A32,32,0,0,1,80,176Z",opacity:"0.2"}),o.createElement("path",{d:"M245.66,74.34l-32-32a8,8,0,0,0-11.32,11.32L220.69,72H208c-49.33,0-61.05,28.12-71.38,52.92-9.38,22.51-16.92,40.59-49.48,42.84a40,40,0,1,0,.1,16c43.26-2.65,54.34-29.15,64.14-52.69C161.41,107,169.33,88,208,88h12.69l-18.35,18.34a8,8,0,0,0,11.32,11.32l32-32A8,8,0,0,0,245.66,74.34ZM48,200a24,24,0,1,1,24-24A24,24,0,0,1,48,200Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M245.66,85.66l-32,32a8,8,0,0,1-11.32-11.32L220.69,88H208c-38.67,0-46.59,19-56.62,43.08C141.05,155.88,129.33,184,80,184H79a32,32,0,1,1,0-16h1c38.67,0,46.59-19,56.62-43.08C147,100.12,158.67,72,208,72h12.69L202.34,53.66a8,8,0,0,1,11.32-11.32l32,32A8,8,0,0,1,245.66,85.66Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M244.24,75.76l-32-32a6,6,0,0,0-8.48,8.48L225.51,74H208c-48,0-59.44,27.46-69.54,51.69-9.43,22.64-17.66,42.33-53,44.16a38,38,0,1,0,.06,12c43.34-2.06,54.29-28.29,64-51.55C159.44,106.53,168,86,208,86h17.51l-21.75,21.76a6,6,0,1,0,8.48,8.48l32-32A6,6,0,0,0,244.24,75.76ZM48,202a26,26,0,1,1,26-26A26,26,0,0,1,48,202Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M245.66,74.34l-32-32a8,8,0,0,0-11.32,11.32L220.69,72H208c-49.33,0-61.05,28.12-71.38,52.92-9.38,22.51-16.92,40.59-49.48,42.84a40,40,0,1,0,.1,16c43.26-2.65,54.34-29.15,64.14-52.69C161.41,107,169.33,88,208,88h12.69l-18.35,18.34a8,8,0,0,0,11.32,11.32l32-32A8,8,0,0,0,245.66,74.34ZM48,200a24,24,0,1,1,24-24A24,24,0,0,1,48,200Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M242.83,77.17l-32-32a4,4,0,0,0-5.66,5.66L230.34,76H208c-46.67,0-57.84,26.81-67.69,50.46-9.46,22.69-18.4,44.16-56.55,45.48a36,36,0,1,0,0,8c43.49-1.42,54.33-27.39,63.91-50.39C157.45,106.12,166.67,84,208,84h22.34l-25.17,25.17a4,4,0,0,0,5.66,5.66l32-32A4,4,0,0,0,242.83,77.17ZM48,204a28,28,0,1,1,28-28A28,28,0,0,1,48,204Z"}))]]),jr=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M212,40a12,12,0,0,1-12,12H170.71A20,20,0,0,0,151,68.42L142.38,116H184a12,12,0,0,1,0,24H138l-9.44,51.87A44,44,0,0,1,85.29,228H56a12,12,0,0,1,0-24H85.29A20,20,0,0,0,105,187.58L113.62,140H72a12,12,0,0,1,0-24h46l9.44-51.87A44,44,0,0,1,170.71,28H200A12,12,0,0,1,212,40Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M200,40V200a16,16,0,0,1-16,16H56V56A16,16,0,0,1,72,40Z",opacity:"0.2"}),o.createElement("path",{d:"M208,40a8,8,0,0,1-8,8H170.71a24,24,0,0,0-23.62,19.71L137.59,120H184a8,8,0,0,1,0,16H134.68l-10,55.16A40,40,0,0,1,85.29,224H56a8,8,0,0,1,0-16H85.29a24,24,0,0,0,23.62-19.71l9.5-52.29H72a8,8,0,0,1,0-16h49.32l10-55.16A40,40,0,0,1,170.71,32H200A8,8,0,0,1,208,40Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM176,72H159.92a16,16,0,0,0-15.73,13l-6.55,35H168a8,8,0,0,1,0,16H134.64l-7.11,37.9A32,32,0,0,1,96.08,200H80a8,8,0,0,1,0-16H96.08A16,16,0,0,0,111.81,171L118.36,136H88a8,8,0,0,1,0-16h33.36l7.11-37.9A32,32,0,0,1,159.92,56H176a8,8,0,0,1,0,16Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M206,40a6,6,0,0,1-6,6H170.71a26,26,0,0,0-25.58,21.35L135.19,122H184a6,6,0,0,1,0,12H133l-10.33,56.8A38,38,0,0,1,85.29,222H56a6,6,0,0,1,0-12H85.29a26,26,0,0,0,25.58-21.35L120.81,134H72a6,6,0,0,1,0-12h51l10.33-56.8A38,38,0,0,1,170.71,34H200A6,6,0,0,1,206,40Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M208,40a8,8,0,0,1-8,8H170.71a24,24,0,0,0-23.62,19.71L137.59,120H184a8,8,0,0,1,0,16H134.68l-10,55.16A40,40,0,0,1,85.29,224H56a8,8,0,0,1,0-16H85.29a24,24,0,0,0,23.62-19.71l9.5-52.29H72a8,8,0,0,1,0-16h49.32l10-55.16A40,40,0,0,1,170.71,32H200A8,8,0,0,1,208,40Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M204,40a4,4,0,0,1-4,4H170.71a28,28,0,0,0-27.55,23l-10.37,57H184a4,4,0,0,1,0,8H131.34l-10.63,58.44A36,36,0,0,1,85.29,220H56a4,4,0,0,1,0-8H85.29a28,28,0,0,0,27.55-23l10.37-57H72a4,4,0,0,1,0-8h52.66l10.63-58.44A36,36,0,0,1,170.71,36H200A4,4,0,0,1,204,40Z"}))]]),Pt=o.forwardRef((e,n)=>o.createElement(vt,{ref:n,...e,weights:Nr}));Pt.displayName="FlowArrowIcon";const _t=Pt,Lt=o.forwardRef((e,n)=>o.createElement(vt,{ref:n,...e,weights:jr}));Lt.displayName="FunctionIcon";const Ot=Lt;function Sr({title:e,description:n,selected:t=!1,onClick:s,children:r}){return a.jsxs("button",{type:"button","aria-pressed":t,className:`focus-ring-soft flex w-full items-start justify-between gap-3 p-3 text-left transition-colors sm:p-4 ${t?"surface-floating bg-elevated":"rounded-[14px] border border-border-subtle bg-transparent hover:border-border-secondary hover:bg-hover-subtle"}`,onClick:s,children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx(j,{as:"div",variant:"body",weight:"semibold",tone:t?"default":"secondary",children:e}),a.jsx(j,{as:"div",variant:"meta",weight:"medium",tone:t?"secondary":"tertiary",className:"mt-1",children:n})]}),r?a.jsx("div",{className:"shrink-0",children:r}):null]})}const Rr=e=>{const{data:n}=yt({queryKey:B.notes.backReferences(e.noteId),async queryFn(){const t=await Sn(e.noteId);if(t.type==="error")throw t;return t.backReferences}});return e.render(n)},Ar=[{value:"narrow",label:"Narrow",description:"Optimized for reading long-form content"},{value:"wide",label:"Wide",description:"Balanced width suitable for most content"},{value:"full",label:"Full Width",description:"Maximize screen space utilization"}];function Er({isOpen:e,onClose:n,onSave:t,currentLayout:s="wide"}){const[r,i]=o.useState(s);o.useEffect(()=>{e&&i(s)},[e,s]);const l=()=>{t(r),n()};return a.jsxs(D,{isOpen:e,onClose:n,variant:"compact",children:[a.jsx(D.Header,{title:"Layout Settings",onClose:n}),a.jsx(D.Body,{children:a.jsx("div",{className:"flex flex-col gap-3 sm:gap-4",children:a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(j,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Note layout"}),a.jsx("div",{className:"flex flex-col gap-2",children:Ar.map(c=>a.jsx(Sr,{title:c.label,description:c.description,selected:r===c.value,onClick:()=>i(c.value)},c.value))})]})})}),a.jsx(D.Footer,{children:a.jsxs(xe,{children:[a.jsx(k,{variant:"ghost",size:"sm",onClick:n,children:"Cancel"}),a.jsx(k,{variant:"primary",size:"sm",onClick:l,children:"Apply"})]})})]})}const ge=e=>{const n=/^\d+$/.test(e)?Number(e):Date.parse(e);return Number.isFinite(n)?n:null},je=(e,n)=>{const t=ge(e),s=ge(n);return t===null||s===null?e===n?0:null:t===s?0:t<s?-1:1},kr=2200;function Tr({status:e,savedAt:n,savedVersion:t,confirmationRevision:s}){const[r,i]=o.useState(()=>Date.now()),[l,c]=o.useState(!1);o.useEffect(()=>{if(e!=="saved")return;const d=window.setTimeout(()=>i(Date.now()),zn(ge(t),r));return()=>window.clearTimeout(d)},[r,t,e]),o.useEffect(()=>{if(s===0)return;c(!0);const d=window.setTimeout(()=>c(!1),kr);return()=>window.clearTimeout(d)},[s]);const f=e==="saved"&&l,u=e==="pending"?"Saving...":e==="saving"?"Saving now...":e==="error"?"Save failed. Try again.":e==="conflict"?"Save paused: changed elsewhere":`Saved ${Wn(ge(t),r)}`,p=K("inline-flex items-center gap-2 transition-colors",e==="saved"&&!f&&"text-fg-secondary",f&&"text-accent-success",(e==="pending"||e==="saving")&&"text-fg-default",(e==="error"||e==="conflict")&&"text-fg-error"),g=K("save-progress-ring flex h-4 w-4 shrink-0 items-center justify-center rounded-full",(e==="pending"||e==="saving")&&"save-progress-ring-active",e==="saved"&&f&&"save-progress-ring-complete",(e==="error"||e==="conflict")&&"save-progress-ring-error"),x=e==="error"||e==="conflict"?a.jsx(Qn,{className:"h-3.5 w-3.5",weight:"fill"}):a.jsx("span",{className:g,"aria-hidden":!0,children:a.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})});return a.jsxs(j,{as:"span",variant:"label",weight:"medium",className:p,role:"status","aria-live":"polite",title:n,children:[x,u]})}function Dr({title:e,titleRef:n,isPinned:t,createdAt:s,saveStatus:r,savedAt:i,savedVersion:l,saveConfirmationRevision:c,onTitleChange:f,onCopyMarkdown:u,onDownloadDocument:p,onTogglePinned:g,onChangeLayout:x,onCloneNote:d,onRestoreVersion:h,onDelete:y,onSave:N}){return a.jsx("div",{className:"surface-floating sticky top-20 z-[1001] mb-7 px-5 pt-4 pb-3.5",children:a.jsxs("div",{className:"flex flex-col gap-3.5",children:[a.jsxs("div",{className:"flex items-start justify-between gap-5",children:[a.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[a.jsx(j,{as:"div",variant:"micro",weight:"semibold",tracking:"widest",transform:"uppercase",tone:"tertiary",className:"mb-1.5",children:"Thought in progress"}),a.jsx("input",{ref:n,"aria-label":"Note title",placeholder:"Title",className:"text-heading sm:text-display w-full bg-transparent font-semibold leading-[1.25] tracking-[-0.02em] outline-none",type:"text",value:e,onChange:S=>f(S.target.value)})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsx(wt,{button:a.jsx(St,{label:"Note actions",size:"lg"}),items:[{name:"Copy Markdown",onClick:u},{name:"Download document",onClick:p},{type:"separator",key:"export-separator"},{name:t?"Unpin":"Pin",onClick:g},{name:"Change layout",onClick:x},{type:"separator"},{name:"Clone this note",onClick:d},{name:"Restore previous version",onClick:h},{type:"separator"},{name:"Delete",onClick:y}]}),a.jsx(k,{size:"sm",variant:"subtle",isLoading:r==="saving",disabled:r==="conflict",onClick:N,children:"Save"})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-t border-border-subtle/80 pt-3",children:[t&&a.jsxs(j,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center gap-1.5",children:[a.jsx(Kn,{className:"h-3 w-3",weight:"fill"}),"Pinned"]}),t&&a.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),a.jsx(Tr,{status:r,savedAt:i,savedVersion:l,confirmationRevision:c}),a.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),a.jsxs(j,{as:"span",variant:"micro",weight:"medium",tone:"tertiary",children:["Created ",s]})]})]})})}const Mr=/[:{}[\],&*#?|<>=!%@`-]/,Pr="/assets/images/",_r=e=>e.trim().toLowerCase().replace(/\s+/g,"-").replace(/[\\/:*?"<>|]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"untitled-note",Ne=e=>e?Mr.test(e)||/^\s|\s$/.test(e)?JSON.stringify(e):e:'""',Se=e=>{if(!e)return;const n=Number(e);return Number.isFinite(n)?new Date(n).toISOString():e},Xe=()=>typeof window>"u"||!window.location?.origin?"http://localhost":window.location.origin,Ee=(e,n=Xe())=>{try{const t=new URL(e,n);return t.origin===n&&t.pathname.startsWith(Pr)}catch{return!1}},Bt=(e,n=Xe())=>{const t=new URL(e,n);return`${t.pathname}${t.search}`},Ft=e=>e.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase()??"",Lr=e=>e.trim().replace(/[\\/:*?"<>|]/g,"-").split("").map(s=>s.charCodeAt(0)<32?"-":s).join("").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"image",Or=e=>{const n=e.lastIndexOf(".");return n<=0||n===e.length-1?{baseName:e,extension:""}:{baseName:e.slice(0,n),extension:e.slice(n)}},Ht=(e,n,t)=>{const r=new URL(e,Xe()).pathname.split("/").filter(Boolean),i=decodeURIComponent(r[r.length-1]??""),l=`image-${n+1}`,{baseName:c,extension:f}=Or(Lr(i||l));let u=`${c}${f}`,p=2;for(;t.has(u);)u=`${c}-${p}${f}`,p+=1;return t.add(u),`assets/${u}`},Br=(e,n)=>{let t=null;for(let s=n;s<e.length;s+=1){const r=e[s];if(t){r===t&&(t=null);continue}if(r==='"'||r==="'"){t=r;continue}if(r===">")return s}return-1},Fr=(e,n)=>{let t=n;for(;t<e.length;){const s=e.toLowerCase().indexOf("<img",t);if(s===-1)return-1;const r=e[s+4],i=s===0?-1:e.lastIndexOf("<",s-1),l=s===0?-1:e.lastIndexOf(">",s-1);if(i<=l&&(!r||/[\s/>]/.test(r)))return s;t=s+4}return-1},Hr=(e,n,t,s)=>{let r=n;for(;r<t;){for(;r<t&&/[\s/]/.test(e[r]);)r+=1;const i=r;for(;r<t&&/[^\s=/>]/.test(e[r]);)r+=1;const l=e.slice(i,r).toLowerCase();for(;r<t&&/\s/.test(e[r]);)r+=1;if(e[r]!=="=")continue;for(r+=1;r<t&&/\s/.test(e[r]);)r+=1;const c=e[r];if(c==='"'||c==="'"){const u=r+1,p=e.indexOf(c,u);if(p===-1||p>t)return;if(r=p+1,l===s)return{end:p,start:u,value:e.slice(u,p)};continue}const f=r;for(;r<t&&/[^\s>]/.test(e[r]);)r+=1;if(l===s)return{end:r,start:f,value:e.slice(f,r)}}},$t=e=>{const n=[];let t=0;for(;t<e.length;){const s=Fr(e,t);if(s===-1)break;const r=Br(e,s+4);if(r===-1)break;const i=Hr(e,s+4,r,"src");i&&n.push({end:r+1,source:i,start:s}),t=r+1}return n},It=(e,n)=>{let t=e;for(const s of[...n].sort((r,i)=>i.start-r.start))t=`${t.slice(0,s.start)}${s.value}${t.slice(s.end)}`;return t},Ut=(e,n)=>{let t=e;for(const s of[...n].sort((r,i)=>i.start-r.start))t=`${t.slice(0,s.start)}${s.value}${t.slice(s.end)}`;return t},zt=e=>{const n=[];let t=0;for(;t<e.length;){const s=e.indexOf("![",t);if(s===-1)break;let r=s+2,i=1;for(;r<e.length&&i>0&&e[r]!==`
3
+ `;){if(e[r]==="\\"){r+=2;continue}e[r]==="["?i+=1:e[r]==="]"&&(i-=1),r+=1}if(i!==0||e[r]!=="("){t=s+2;continue}const l=r+1;let c=l;for(;c<e.length&&e[c]!==`
4
+ `&&/\s/.test(e[c]);)c+=1;if(c>=e.length||e[c]===`
5
+ `){t=s+2;continue}let f=c,u=c,p=c;if(e[c]==="<"){for(r=c+1;r<e.length&&e[r]!==">"&&e[r]!==`
6
+ `;)r+=e[r]==="\\"?2:1;if(e[r]!==">"){t=s+2;continue}f=r+1,u=c+1,p=r}else{let g=0;for(r=c;r<e.length&&e[r]!==`
7
+ `;){const x=e[r];if(x==="\\"){r+=2;continue}if(/\s/.test(x)&&g===0)break;if(x==="(")g+=1;else if(x===")"){if(g===0)break;g-=1}r+=1}f=r,u=c,p=f}if(p<=u){t=s+2;continue}for(r=f;r<e.length&&e[r]!==`
8
+ `&&/\s/.test(e[r]);)r+=1;if(e[r]==='"'||e[r]==="'"){const g=e[r];for(r+=1;r<e.length&&e[r]!==`
9
+ `;){if(e[r]==="\\"){r+=2;continue}if(e[r]===g){r+=1;break}r+=1}}for(;r<e.length&&e[r]!==`
10
+ `&&/\s/.test(e[r]);)r+=1;if(e[r]!==")"){t=s+2;continue}n.push({end:r+1,source:{end:f,start:l,value:e.slice(u,p)},start:s}),t=r+1}return n},$r=(e,n)=>`${_r(e)}.${n}`,Ir=({id:e,title:n,createdAt:t,updatedAt:s})=>{const r=["---",`title: ${Ne(n)}`,`note_id: ${Ne(e)}`],i=Se(t),l=Se(s);return i&&r.push(`created_at: ${Ne(i)}`),l&&r.push(`updated_at: ${Ne(l)}`),r.push("source: ocean-brain","---"),r.join(`
11
+ `)},Wt=(e,n,t=!1)=>t?`${Ir(n)}
12
+
13
+ ${e}`:e,Kt=(e,n,{includeMetadata:t=!1}={})=>{const s=Wt(e,n,t),r=zt(s).filter(i=>Ee(i.source.value)).map(i=>({end:i.end,start:i.start,value:""}));return Ut(s,r)},Vt=(e,n,{includeMetadata:t=!1}={})=>`${t?`<!--
14
+ source: ocean-brain
15
+ note_id: ${n.id}
16
+ title: ${n.title}
17
+ created_at: ${Se(n.createdAt)??""}
18
+ updated_at: ${Se(n.updatedAt)??""}
19
+ -->
20
+ `:""}${e}`,Ur=(e,n,{includeMetadata:t=!1}={})=>{const s=Vt(e,n,{includeMetadata:t}),r=$t(s).filter(i=>Ee(i.source.value)).map(i=>({end:i.end,start:i.start,value:""}));return It(s,r)},zr=async(e,n,{fetchImpl:t=fetch,includeMetadata:s=!1}={})=>{const r=new kt,i=Vt(e,n,{includeMetadata:s}),l=$t(i),c=[],f=new Set,u=new Map;for(const{source:p}of l){if(!Ee(p.value))continue;const g=Bt(p.value);let x=u.get(g);if(!x){x=Ht(g,u.size,f),u.set(g,x);const d=await t(g,{credentials:"same-origin"});if(!d.ok)throw new Error(`Failed to fetch image asset: ${g}`);if(!Ft(d).startsWith("image/"))throw new Error(`Image asset did not return image content: ${g}`);r.file(x,new Uint8Array(await d.arrayBuffer()))}c.push({end:p.end,start:p.start,value:`./${x}`})}return r.file("note.html",It(i,c)),r.generateAsync({type:"blob"})},Wr=async(e,n,{fetchImpl:t=fetch,includeMetadata:s=!1}={})=>{const r=new kt,i=Wt(e,n,s),l=zt(i),c=[],f=new Set,u=new Map;for(const{source:p}of l){if(!Ee(p.value))continue;const g=Bt(p.value);let x=u.get(g);if(!x){x=Ht(g,u.size,f),u.set(g,x);const d=await t(g,{credentials:"same-origin"});if(!d.ok)throw new Error(`Failed to fetch image asset: ${g}`);if(!Ft(d).startsWith("image/"))throw new Error(`Image asset did not return image content: ${g}`);r.file(x,new Uint8Array(await d.arrayBuffer()))}c.push({end:p.end,start:p.start,value:`./${x}`})}return r.file("note.md",Ut(i,c)),r.generateAsync({type:"blob"})},Kr=(e,n)=>{const t=URL.createObjectURL(e),s=document.createElement("a");s.href=t,s.download=n,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(t)},Yt={html:{extension:"html",getContent:e=>e.getHtml(),createDocumentBlob:(e,n)=>new Blob([Ur(e,n.metadata,{includeMetadata:n.includeMetadata})],{type:"text/html;charset=utf-8"}),createZipBlob:(e,n)=>zr(e,n.metadata,{fetchImpl:n.fetchImpl,includeMetadata:n.includeMetadata})},markdown:{extension:"md",getContent:e=>e.getMarkdown(),createDocumentBlob:(e,n)=>new Blob([Kt(e,n.metadata,{includeMetadata:n.includeMetadata})],{type:"text/markdown;charset=utf-8"}),createZipBlob:(e,n)=>Wr(e,n.metadata,{fetchImpl:n.fetchImpl,includeMetadata:n.includeMetadata})}},Zt=(e,n)=>n?"zip":Yt[e].extension,Vr=async e=>{const n=Yt[e.format],t=n.getContent(e.source);if(t===void 0)return{type:"not-ready",format:e.format};const s=Zt(e.format,e.includeAssets);return{type:"success",blob:e.includeAssets?await n.createZipBlob(t,e):n.createDocumentBlob(t,e),filename:$r(e.metadata.title,s)}},Yr=e=>e==="markdown"?"Markdown is not ready yet.":"HTML is not ready yet.",it=({checked:e,description:n,id:t,label:s,onChange:r})=>{const i=`${t}-label`;return a.jsxs("div",{className:"flex min-h-6 items-center gap-2",children:[a.jsx(Ct,{id:t,size:"sm",checked:e,onChange:l=>r(l.target.checked),"aria-labelledby":i}),a.jsx("label",{id:i,htmlFor:t,className:"min-w-0 cursor-pointer",children:a.jsx(j,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"block",children:s})}),a.jsx(Rn,{content:a.jsx("span",{className:"block max-w-[240px] leading-4",children:n}),side:"top",children:a.jsx("button",{type:"button",className:"focus-ring-soft inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-secondary","aria-label":`${s} help`,children:a.jsx(Jn,{className:"h-3.5 w-3.5"})})})]})};function Zr({isOpen:e,metadata:n,getHtml:t,getMarkdown:s,onClose:r}){const i=Re(),[l,c]=o.useState("html"),[f,u]=o.useState(!0),[p,g]=o.useState(!1),[x,d]=o.useState(!1),h=Zt(l,f),y=async()=>{d(!0);try{const N=await Vr({format:l,includeAssets:f,includeMetadata:p,metadata:n,source:{getHtml:t,getMarkdown:s}});if(N.type==="not-ready"){i(Yr(N.format));return}Kr(N.blob,N.filename),r(),i("Downloaded note.")}catch{i("Failed to download note.")}finally{d(!1)}};return a.jsxs(D,{isOpen:e,onClose:r,variant:"compact",children:[a.jsx(D.Header,{title:"Download document",onClose:r}),a.jsx(D.Body,{children:a.jsxs("div",{className:"flex flex-col gap-5",children:[a.jsxs("div",{className:"flex flex-col gap-3",role:"radiogroup","aria-label":"Format",children:[a.jsx(j,{as:"span",variant:"meta",weight:"bold",tone:"muted",children:"Format"}),a.jsxs("div",{className:"flex flex-wrap gap-4",children:[a.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[a.jsx("input",{type:"radio",name:"note-export-format",value:"html",checked:l==="html",onChange:()=>c("html"),className:"h-4 w-4 accent-cta"}),a.jsx(j,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:".html"})]}),a.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[a.jsx("input",{type:"radio",name:"note-export-format",value:"markdown",checked:l==="markdown",onChange:()=>c("markdown"),className:"h-4 w-4 accent-cta"}),a.jsx(j,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:".md"})]})]})]}),a.jsxs("div",{className:"flex flex-col gap-3",role:"group","aria-label":"Options",children:[a.jsx(j,{as:"span",variant:"meta",weight:"bold",tone:"muted",children:"Options"}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(it,{id:"note-export-include-assets",label:"Include local image assets",checked:f,onChange:u,description:"Bundle uploaded Ocean Brain images with the document. Without assets, local images are omitted."}),a.jsx(it,{id:"note-export-include-metadata",label:"Include metadata",checked:p,onChange:g,description:"Add the note title, note id, timestamps, and Ocean Brain source information."})]})]})]})}),a.jsx(D.Footer,{children:a.jsxs(xe,{children:[a.jsx(k,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),a.jsx(k,{variant:"primary",size:"sm",onClick:y,disabled:x,children:x?"Downloading...":`Download .${h}`})]})})]})}const qt=e=>e==="mcp"?{actor:"An MCP client",place:"through MCP",target:"the MCP update"}:e==="web"?{actor:"Another browser tab",place:"in another tab",target:"the tab update"}:{actor:"Another editor",place:"elsewhere",target:"the outside change"},qr=({isDeleted:e,isConflict:n,source:t})=>{const s=qt(t);return e?`This note was moved to trash ${s.place}`:n?`Save paused: note changed ${s.place}`:`This note changed ${s.place}`},Gr=({isDeleted:e,isConflict:n,hasDraft:t,source:s})=>{const r=qt(s);return e?`${r.actor} moved this note to trash. Open trash to review or restore it.`:n&&t?`Your draft is saved locally. Reload the latest note, overwrite ${r.target}, or clone your draft into a new note.`:n?`The layout change is paused because the note changed ${r.place}. Reload the latest note or overwrite only the layout.`:`${r.actor} changed this note while it was open here. Reload the latest version before continuing.`};function Qr({isOpen:e,isDeleted:n,isConflict:t,hasDraft:s,source:r,isReloading:i,onReload:l,onOverwrite:c,onCloneDraft:f,onOpenTrash:u}){return a.jsxs(D,{isOpen:e,onClose:()=>{},variant:"inspect",children:[a.jsx(D.Header,{title:qr({isDeleted:n,isConflict:t,source:r})}),a.jsx(D.Body,{children:a.jsx(j,{as:"p",variant:"body",tone:"secondary",className:"leading-6",children:Gr({isDeleted:n,isConflict:t,hasDraft:s,source:r})})}),a.jsx(D.Footer,{children:a.jsx(xe,{children:n?a.jsx(k,{type:"button",variant:"primary",size:"sm",onClick:u,children:"Open trash"}):t?a.jsxs(a.Fragment,{children:[a.jsx(k,{type:"button",variant:"subtle",size:"sm",isLoading:i,onClick:l,children:"Reload latest"}),s&&a.jsx(k,{type:"button",variant:"ghost",size:"sm",onClick:f,children:"Clone draft"}),a.jsx(k,{type:"button",variant:"danger",size:"sm",onClick:c,children:"Overwrite"})]}):a.jsx(k,{type:"button",variant:"primary",size:"sm",isLoading:i,onClick:l,children:"Reload latest"})})})]})}function Jr({localDraftCreatedAt:e,hasSaveError:n,onRestoreDraft:t,onDiscardDraft:s,onRetrySave:r,onSaveAsNewNote:i}){return a.jsxs(a.Fragment,{children:[e&&a.jsx(rt,{tone:"danger",className:"mb-6",children:a.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[a.jsxs("span",{children:["A draft from ",e," is saved only in this browser."]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx(k,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:t,children:"Restore draft"}),a.jsx(k,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:s,children:"Discard"})]})]})}),n&&a.jsx(rt,{tone:"danger",className:"mb-6",children:a.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[a.jsx("span",{children:"Save failed. Your latest draft is still available here. Retry before leaving this note."}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx(k,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:r,children:"Retry save"}),a.jsx(k,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:i,children:"Save as new note"})]})]})})]})}const ct=(e,n)=>e||(n==="mobile"?"Mobile browser":n==="mcp"?"MCP":"Web browser");function Xr({isOpen:e,noteId:n,onClose:t,restoreSnapshot:s,onRestored:r}){const i=Re(),l=Ze(),[c,f]=o.useState(null),[u,p]=o.useState("diff"),g=o.useRef(null),x=He({queryKey:B.notes.snapshots(n),queryFn:async()=>{const m=await An(n);if(m.type==="error")throw m;return m.noteSnapshots},enabled:e}),d=Vn({mutationFn:s,onSuccess:async m=>{if(m){if(m.type==="error"){i(m.errors[0].message);return}await Promise.all([l.invalidateQueries({queryKey:B.notes.detail(n),exact:!0}),l.invalidateQueries({queryKey:B.notes.listAll(),exact:!1}),l.invalidateQueries({queryKey:B.notes.tagListAll(),exact:!1}),l.invalidateQueries({queryKey:B.notes.tagNameListAll(),exact:!1}),l.invalidateQueries({queryKey:B.notes.pinned(),exact:!0}),l.invalidateQueries({queryKey:B.notes.backReferencesAll(),exact:!1}),l.invalidateQueries({queryKey:B.notes.graph(),exact:!0}),l.invalidateQueries({queryKey:B.notes.snapshots(n),exact:!1}),l.invalidateQueries({queryKey:B.views.sectionNotesAll(),exact:!1}),l.invalidateQueries({queryKey:B.tags.all(),exact:!1})]),i("Previous version restored."),r?.(m.restoreNoteSnapshot),f(null),t()}}}),h=x.data?.find(m=>m.id===c)??null,y=He({queryKey:[...B.notes.snapshotDetail(c??"pending"),"diff"],queryFn:async()=>{if(!c)throw new Error("SNAPSHOT_NOT_SELECTED");const m=await En(c,"current");if(m.type==="error")throw m;if(!m.noteSnapshotDiff)throw new Error("SNAPSHOT_DIFF_NOT_FOUND");return m.noteSnapshotDiff},enabled:!!c&&u==="diff"}),N=He({queryKey:B.notes.snapshotDetail(c??"pending"),queryFn:async()=>{if(!c)throw new Error("SNAPSHOT_NOT_SELECTED");const m=await kn(c);if(m.type==="error")throw m;if(!m.noteSnapshot)throw new Error("SNAPSHOT_NOT_FOUND");return m.noteSnapshot},enabled:!!c&&u==="content"}),S=N.data?.contentAsMarkdown.trim()??"";o.useEffect(()=>{c&&g.current?.focus()},[c]);const A=(m,v)=>{p(v),f(m)},w=()=>{f(null),p("diff"),t()};return a.jsxs(D,{isOpen:e,onClose:w,variant:"inspect",children:[a.jsx(D.Header,{title:h?u==="diff"?"Snapshot Diff":"Snapshot Content":"Restore Previous Version",onClose:w}),a.jsx(D.Description,{className:"sr-only",children:h?u==="diff"?"Review the markdown diff between this snapshot and the current note.":"Read this snapshot content before restoring it.":"Choose a previous snapshot to restore."}),a.jsx(D.Body,{children:h?a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx(j,{as:"p",variant:"body",weight:"semibold",truncate:!0,children:h.title}),a.jsxs(j,{as:"p",variant:"label",tone:"tertiary",children:["Before"," ",ct(h.meta.label,h.meta.entrypoint)," ","edit - ",G(h.createdAt).format("YYYY-MM-DD HH:mm:ss")]})]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx(k,{variant:u==="diff"?"primary":"subtle",size:"sm",onClick:()=>p("diff"),children:"Show diff"}),a.jsx(k,{variant:u==="content"?"primary":"subtle",size:"sm",onClick:()=>p("content"),children:"View content"})]}),u==="diff"?y.isLoading?a.jsx(j,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Loading snapshot diff..."}):y.isError?a.jsx(j,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Snapshot diff could not be loaded."}):y.data?a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(j,{as:"p",variant:"meta",tone:"secondary",children:"Changes from this snapshot to the current note. Red lines were in the snapshot; green lines are in the current note."}),a.jsx("pre",{className:"max-h-[60vh] overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-0 py-3 text-xs leading-5 text-fg-secondary",children:y.data.diff.markdown.split(`
21
+ `).map((m,v)=>{const T=m.startsWith("+")&&!m.startsWith("+++")?"bg-emerald-500/12 text-emerald-700 dark:text-emerald-200":m.startsWith("-")&&!m.startsWith("---")?"bg-rose-500/12 text-rose-700 dark:text-rose-200":m.startsWith("@@")?"bg-sky-500/12 text-sky-700 dark:text-sky-200":"text-fg-secondary";return a.jsx("span",{className:`block min-w-full whitespace-pre-wrap break-words px-4 ${T}`,children:m||" "},`${v}-${m}`)})})]}):null:N.isLoading?a.jsx(j,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Loading snapshot content..."}):N.isError?a.jsx(j,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Snapshot content could not be loaded."}):S?a.jsx("pre",{className:"max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3 text-sm leading-6 text-fg-secondary",children:S}):a.jsx(j,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"No readable content was found for this snapshot."})]}):a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsx(j,{as:"p",variant:"meta",tone:"secondary",children:"Choose a previous snapshot to restore this note back to that state."}),x.isLoading&&a.jsx(j,{as:"div",variant:"meta",tone:"secondary",children:"Loading previous versions..."}),!x.isLoading&&x.data?.length===0&&a.jsx(j,{as:"div",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"A recovery snapshot appears before the first edit in a session. Up to 10 recent snapshots are kept for 7 days, and identical versions are skipped."}),!x.isLoading&&x.data&&x.data.length>0&&a.jsx("div",{className:"flex flex-col gap-2",children:x.data.map(m=>a.jsx(nr,{padding:"compact",children:a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs(j,{as:"p",variant:"body",weight:"semibold",children:["Before"," ",ct(m.meta.label,m.meta.entrypoint)," ","edit"]}),a.jsx(j,{as:"p",variant:"meta",truncate:!0,tone:"secondary",children:m.title}),a.jsx(j,{as:"p",variant:"label",tone:"tertiary",children:G(m.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),a.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[a.jsx(k,{variant:"subtle",size:"sm",onClick:()=>A(m.id,"diff"),children:"Compare"}),a.jsx(k,{size:"sm",isLoading:d.isPending,onClick:()=>d.mutate(m.id),children:"Restore"})]})]}),m.contentPreview&&a.jsx("div",{className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:a.jsx(j,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-4 whitespace-pre-wrap break-words",children:m.contentPreview})})]})},m.id))})]})}),h&&a.jsx(D.Footer,{children:a.jsxs(xe,{children:[a.jsx(k,{ref:g,variant:"subtle",onClick:()=>{f(null),p("diff")},children:"Back"}),a.jsx(k,{isLoading:d.isPending,onClick:()=>d.mutate(h.id),children:"Restore this version"})]})})]})}const lt={low:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},medium:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},high:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"}};function ea({isOpen:e,onClose:n,onSave:t,reminder:s,mode:r}){const[i,l]=o.useState(new Date),[c,f]=o.useState("medium"),[u,p]=o.useState("");o.useEffect(()=>{e&&r==="edit"&&s?(l(new Date(Number(s.reminderDate))),f(s.priority||"medium"),p(s.content||"")):e&&r==="create"&&(l(new Date),f("medium"),p(""))},[e,r,s]);const g=()=>{t(i,c,u||void 0),n()},x=d=>c===d?lt[d].active:lt[d].inactive;return a.jsxs(D,{isOpen:e,onClose:n,variant:"form",children:[a.jsx(D.Header,{title:r==="create"?"Create Reminder":"Edit Reminder",onClose:n}),a.jsx(D.Body,{children:a.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Be,{children:"Date & Time"}),a.jsx(Tn,{type:"datetime-local",size:"sm",value:G(i).format("YYYY-MM-DDTHH:mm"),onChange:d=>l(new Date(d.target.value))})]}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Be,{children:"Content"}),a.jsx(Dn,{size:"sm",placeholder:"Enter reminder content (optional)",value:u,onChange:d=>p(d.target.value)})]}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Be,{children:"Priority"}),a.jsxs(Mn,{type:"single",variant:"quiet",value:c,onValueChange:d=>d&&f(d),className:"gap-1.5 border-none rounded-[14px] bg-muted/70 p-1 sm:gap-2",children:[a.jsx(Fe,{value:"low",className:`flex-1 rounded-[10px] border ${x("low")}`,children:a.jsx(j,{as:"span",weight:"medium",className:"text-current",children:"Low"})}),a.jsx(Fe,{value:"medium",className:`flex-1 rounded-[10px] border ${x("medium")}`,children:a.jsx(j,{as:"span",weight:"medium",className:"text-current",children:"Medium"})}),a.jsx(Fe,{value:"high",className:`flex-1 rounded-[10px] border ${x("high")}`,children:a.jsx(j,{as:"span",weight:"medium",className:"text-current",children:"High"})})]})]})]})}),a.jsx(D.Footer,{children:a.jsxs(xe,{children:[a.jsx(k,{variant:"ghost",size:"sm",onClick:n,children:"Cancel"}),a.jsx(k,{variant:"primary",size:"sm",onClick:g,children:r==="create"?"Create":"Save"})]})})]})}function ta({noteId:e}){const[n,t]=o.useState(!1),[s,r]=o.useState(!1),[i,l]=o.useState("create"),[c,f]=o.useState(void 0),{onCreate:u,onUpdate:p,onDelete:g}=rr(),x=()=>{l("create"),f(void 0),r(!0)},d=w=>{l("edit"),f(w),r(!0)},h=(w,m,v)=>{i==="create"?u(e,w,m,()=>{r(!1)},v):i==="edit"&&c&&p(c.id,e,{reminderDate:w,priority:m,content:v},()=>{r(!1)})},y=w=>{p(w.id,e,{completed:!w.completed})},N=w=>{const m=G(Number(w)),v=G();return m.isSame(v,"day")?`Today at ${m.format("HH:mm")}`:m.isSame(v.add(1,"day"),"day")?`Tomorrow at ${m.format("HH:mm")}`:m.format("YYYY-MM-DD HH:mm")},S=w=>{const m=G(Number(w)),v=G(),T=m.diff(v,"hour");return T<=6?"high":T<=24?"medium":"low"},A=w=>{const m=G(Number(w)),v=G(),T=m.diff(v,"hour"),H=m.diff(v,"minute")%60;return T<0||H<0?"Overdue":T===0?`${H}m remaining`:`${T}h ${H}m remaining`};return a.jsxs(a.Fragment,{children:[a.jsx(Tt,{title:"Reminders",icon:a.jsx(Yn,{className:"h-3.5 w-3.5"}),action:a.jsxs(a.Fragment,{children:[!n&&a.jsxs(k,{size:"sm",variant:"ghost",onClick:x,children:[a.jsx(sr,{className:"w-3 h-3"}),a.jsx(j,{as:"span",variant:"label",className:"hidden sm:inline",children:"Add"})]}),a.jsxs(k,{type:"button",size:"sm",variant:"ghost","aria-label":n?"Expand reminders":"Collapse reminders","aria-expanded":!n,onClick:()=>t(!n),children:[n?a.jsx(Pn,{className:"h-3.5 w-3.5"}):a.jsx(_n,{className:"h-3.5 w-3.5"}),n?"Expand":"Collapse"]})]}),children:!n&&a.jsx(ar,{noteId:e,searchParams:{offset:0,limit:9999},render:({reminders:w,totalCount:m})=>a.jsx("div",{className:"flex flex-col gap-2",children:w.length===0?a.jsx(j,{as:"p",variant:"meta",tone:"secondary",className:"py-3 text-center",children:m===0?"No reminders yet":"All reminders complete"}):a.jsx("div",{className:"flex flex-col",children:w.map(v=>{const T=v.priority||S(v.reminderDate),H=A(v.reminderDate),M=H==="Overdue";return a.jsxs("div",{className:K("flex items-center gap-2.5 px-2 py-1.5"),children:[a.jsx(Ct,{checked:v.completed,onChange:()=>y(v),size:"sm","aria-label":`Reminder: ${v.content||N(v.reminderDate)}`}),a.jsx(j,{as:"div",variant:"body",weight:"medium",className:K("truncate flex-1 min-w-0",v.completed&&"line-through opacity-40"),children:v.content||N(v.reminderDate)}),a.jsxs("div",{className:K("shrink-0 flex items-center gap-1",v.completed&&"opacity-40"),children:[v.content&&a.jsx(j,{as:"span",variant:"meta",tone:"secondary",children:N(v.reminderDate)}),!v.completed&&a.jsx(j,{as:"span",variant:"label",weight:"medium",tone:M||T==="high"?"error":"tertiary",className:K(v.content&&'before:content-["·"] before:mr-1'),children:H})]}),a.jsx(wt,{button:a.jsx(St,{label:"Reminder actions"}),items:[{name:"Edit",onClick:()=>d(v)},{name:"Delete",onClick:()=>g(v.id,e)}]})]},v.id)})})})})}),a.jsx(ea,{isOpen:s,onClose:()=>r(!1),onSave:h,reminder:c,mode:i})]})}const na=e=>[{title:"Diagram",subtext:"Create a flowchart or diagram with Mermaid syntax",onItemClick:()=>{at(e,{type:"codeBlock",props:{language:"mermaid"}})},aliases:["mermaid","diagram","flowchart","sequence"],group:"Other",icon:a.jsx(_t,{})},{title:"Math Formula",subtext:"Write a formula with KaTeX or LaTeX",onItemClick:()=>{at(e,{type:"codeBlock",props:{language:"math"}})},aliases:["math","formula","equation","katex","latex"],group:"Other",icon:a.jsx(Ot,{})}],ra=({editor:e})=>a.jsx(Je,{triggerCharacter:"/",getItems:async n=>ur([...or(e).filter(t=>t.title!=="Audio"&&t.title!=="Video"&&t.title!=="File"),...na(e),{title:"Table of Contents",subtext:"Insert a table of contents based on headings",onItemClick:()=>{e.insertBlocks([{type:"tableOfContents"}],e.getTextCursorPosition().block,"after")},aliases:["toc","table of contents","contents","outline","index"],group:"Other",icon:a.jsx(Rt,{})}],n)}),aa=(e,n)=>n?e.filter(t=>t.id!==n):e,sa=({currentNoteId:e,onClick:n})=>a.jsx(Je,{triggerCharacter:"[",getItems:async t=>{const s=await Ln({query:t,limit:5});return s.type==="error"?[]:aa(s.allNotes.notes,e).map(i=>({title:i.title,onItemClick:()=>n({type:"reference",props:{id:i.id,title:i.title}})}))}}),Gt=["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/avif"],oa=new Set(Gt),dt="Unsupported image type. Use PNG, JPEG, GIF, WebP, BMP, or AVIF.",ia="Failed to upload image.",ca=e=>oa.has(e);let ut,ft;const la=()=>(ut??=Ke(async()=>{const{default:e}=await import("./mermaid.core-B14ZAmWA.js").then(n=>n.bc);return{default:e}},__vite__mapDeps([0,1,2,3])).then(({default:e})=>e),ut),da=()=>(ft??=Promise.all([Ke(()=>import("./katex-x288kqHd.js"),[]),Ke(()=>Promise.resolve({}),__vite__mapDeps([4]))]).then(([{default:e}])=>e),ft),ua=e=>{const n=e?.trim().toLowerCase();return n==="mermaid"?"mermaid":n==="math"||n==="katex"||n==="latex"?"math":null},fa=e=>`ocean-brain-mermaid-${e.replace(/[^a-zA-Z0-9_-]/g,"")||"diagram"}`,pa=async(e,n,t,s="light")=>{if(e==="mermaid"){const i=await la();i.initialize({securityLevel:"strict",startOnLoad:!1,suppressErrorRendering:!0,theme:s==="dark"?"dark":"default"});const l=await i.render(fa(t),n);return{html:l.svg,bindFunctions:l.bindFunctions}}return{html:(await da()).renderToString(n,{displayMode:!0,output:"htmlAndMathml",strict:"warn",throwOnError:!0,trust:!1})}},ma={floating:"pointer-events-auto inline-flex h-7 cursor-pointer select-none items-center gap-1.5 rounded-[8px] border border-white/10 bg-white/10 px-2.5 text-xs font-medium text-white/60 opacity-75 shadow-[0_8px_18px_-14px_rgba(0,0,0,0.45)] backdrop-blur-sm transition-colors hover:bg-white/20 hover:text-white/90 hover:opacity-100 focus-ring-soft focus:text-white/90 focus:opacity-100",toolbar:"focus-ring-soft inline-flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-[8px] border border-transparent px-2.5 text-xs font-semibold text-fg-secondary outline-none transition-colors hover:border-border-subtle hover:bg-hover-subtle hover:text-fg-default"},ha={idle:"",copied:"text-accent-success hover:text-accent-success focus:text-accent-success",failed:"text-fg-error hover:text-fg-error focus:text-fg-error"},ga={idle:"Copy",copied:"Copied",failed:"Copy failed"},pt=({getText:e,resetDelayMs:n=2e3,variant:t="floating"})=>{const[s,r]=o.useState("idle"),i=o.useRef(null),l=o.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),c=o.useCallback(()=>{l(),i.current=setTimeout(()=>{r("idle"),i.current=null},n)},[l,n]);o.useEffect(()=>l,[l]);const f=g=>{g.stopPropagation()},u=g=>{g.preventDefault(),g.stopPropagation()},p=async g=>{f(g);try{await navigator.clipboard.writeText(e()),r("copied")}catch{r("failed")}c()};return a.jsx("div",{className:K(t==="floating"&&"pointer-events-none absolute right-3 top-2 z-[1]"),contentEditable:!1,onMouseDown:u,children:a.jsxs("button",{type:"button",className:K(ma[t],ha[s]),contentEditable:!1,onClick:p,children:[a.jsx(mr,{className:"h-3.5 w-3.5"}),a.jsx("span",{"aria-live":"polite",children:ga[s]})]})})},xa=({kind:e,source:n})=>{const t=o.useId(),s=o.useRef(null),r=Nt(u=>u.theme),[i,l]=o.useState(()=>typeof IntersectionObserver>"u"),[c,f]=o.useState({status:"idle"});return o.useEffect(()=>{const u=s.current;if(i||!u||typeof IntersectionObserver>"u"){l(!0);return}const p=new IntersectionObserver(([g])=>{g?.isIntersecting&&(l(!0),p.disconnect())},{rootMargin:"240px"});return p.observe(u),()=>p.disconnect()},[i]),o.useEffect(()=>{if(!i)return;let u=!1;return f({status:"loading"}),pa(e,n,t,r).then(p=>{u||f({status:"success",...p})}).catch(()=>{u||f({status:"error"})}),()=>{u=!0}},[e,t,i,n,r]),o.useEffect(()=>{c.status==="success"&&c.bindFunctions&&s.current&&c.bindFunctions(s.current)},[c]),a.jsxs("div",{ref:s,"data-rich-code-preview":!0,className:"min-h-24 w-full overflow-auto bg-surface px-4 py-5 text-fg-default sm:px-6 sm:py-6",contentEditable:!1,"aria-label":e==="mermaid"?"Mermaid diagram preview":"Math formula preview",children:[c.status==="success"&&a.jsx("div",{className:"[&_.katex-display]:m-0 [&_svg]:mx-auto [&_svg]:block [&_svg]:h-auto [&_svg]:max-h-[min(68vh,640px)] [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:c.html}}),(c.status==="idle"||c.status==="loading")&&a.jsx("div",{className:"flex min-h-8 items-center justify-center text-sm text-black/55",children:"Rendering preview…"}),c.status==="error"&&a.jsxs("div",{className:"text-left",children:[a.jsx("p",{className:"mb-3 text-sm text-red-700",children:"Preview could not be rendered. The source is preserved."}),a.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap rounded-[6px] bg-black/5 p-4 text-sm text-black",children:a.jsx("code",{children:n})})]})]})},mt="focus-ring-soft inline-flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-[8px] border px-2.5 text-xs font-semibold outline-none transition-colors",Ve=e=>typeof e=="string"?e:!e||typeof e!="object"?"":"text"in e&&typeof e.text=="string"?e.text:"content"in e?Array.isArray(e.content)?e.content.map(Ve).join(""):Ve(e.content):"",ba=({block:e,contentRef:n})=>{const t=o.useRef(null),s=ua(e.props.language),r=e.content.map(Ve).join(""),[i,l]=o.useState(r),[c,f]=o.useState(r.length===0),u=s!==null&&!c,p=s==="mermaid"?"Diagram":"Math Formula",g=`${p} controls`,x=o.useCallback(h=>{t.current=h,n(h)},[n]);o.useEffect(()=>{const h=t.current;if(!h)return;const y=()=>l(h.textContent??""),N=new MutationObserver(y);return N.observe(h,{characterData:!0,childList:!0,subtree:!0}),()=>N.disconnect()},[]);const d=h=>{h.preventDefault(),h.stopPropagation()};return a.jsxs(a.Fragment,{children:[s&&a.jsxs("div",{role:"toolbar","aria-label":g,"data-rich-code-toolbar":!0,className:"flex min-h-11 w-full flex-wrap items-center justify-between gap-2 border-b border-border-subtle bg-elevated px-3 py-1.5 text-fg-secondary",contentEditable:!1,onMouseDown:d,children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1 text-xs font-semibold text-fg-secondary",children:[s==="mermaid"?a.jsx(_t,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}):a.jsx(Ot,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),a.jsx("span",{className:"truncate",children:p})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("div",{className:"flex items-center gap-0.5 rounded-[10px] border border-border-subtle bg-hover-subtle/55 p-0.5",children:[a.jsxs("button",{type:"button","aria-pressed":c,className:K(mt,c?"border-border-secondary/70 bg-elevated text-fg-default shadow-[0_8px_18px_-16px_rgba(15,18,24,0.28)]":"border-transparent text-fg-secondary hover:bg-hover-subtle hover:text-fg-default"),contentEditable:!1,onClick:h=>{h.stopPropagation(),f(!0)},children:[a.jsx(hr,{className:"h-3.5 w-3.5"}),"Edit"]}),a.jsxs("button",{type:"button","aria-pressed":u,className:K(mt,u?"border-border-secondary/70 bg-elevated text-fg-default shadow-[0_8px_18px_-16px_rgba(15,18,24,0.28)]":"border-transparent text-fg-secondary hover:bg-hover-subtle hover:text-fg-default"),contentEditable:!1,onClick:h=>{h.stopPropagation(),f(!1)},children:[a.jsx(Zn,{className:"h-3.5 w-3.5"}),"Preview"]})]}),a.jsx(pt,{variant:"toolbar",getText:()=>t.current?.textContent?.trimEnd()??""})]})]}),a.jsx("pre",{className:K(u&&"hidden",s&&"bg-[#181b20]"),children:a.jsx("code",{ref:x})}),s&&u&&a.jsx(xa,{kind:s,source:i}),!s&&a.jsx(pt,{getText:()=>t.current?.textContent?.trimEnd()??""})]})},va="focus-ring-soft inline-flex cursor-pointer items-center rounded-[8px] border border-border-subtle bg-[color-mix(in_srgb,var(--elevated)_72%,var(--hover-subtle))] px-2 py-0.5 text-xs font-semibold text-fg-secondary transition-colors hover:border-border-secondary hover:bg-elevated hover:text-fg-default dark:bg-[color-mix(in_srgb,var(--elevated)_82%,var(--hover-subtle))]",ya={type:"reference",propSchema:{id:{default:""},title:{default:"Unknown"}},content:"none"};function wa(e){const n=jt(),t=()=>{e.editor.blur(),n({to:Ae,params:{id:e.inlineContent.props.id}})},s=r=>{r.preventDefault(),r.stopPropagation()};return a.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:va,onMouseDown:s,onClick:r=>{s(r),t()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(s(r),t())},children:a.jsxs("span",{children:["[",e.inlineContent.props.title,"]"]})})}const Ca=Dt(ya,{render:e=>a.jsx(wa,{...e})}),Na=()=>{const e=ir(),[n,t]=o.useState([]),s={1:"pl-3",2:"pl-[26px]",3:"pl-[40px]",4:"pl-[54px]",5:"pl-[68px]",6:"pl-[82px]"};o.useEffect(()=>{const l=()=>{const f=e.document,u=[],p=g=>{for(const x of g){if(x.type==="heading"){const d=x,h=d.props.level||1,y=d.content?.map(N=>N.text||"").join("")||"";y.trim()&&u.push({id:x.id,level:h,text:y})}x.children&&Array.isArray(x.children)&&p(x.children)}};p(f),t(u)};l();const c=e.onChange?.(l);return()=>{c&&c()}},[e]);const r=l=>{e.setTextCursorPosition(l);const c=document.querySelector(`[data-id="${l}"]`);if(c){const f=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1;c.scrollIntoView({behavior:f?"auto":"smooth",block:"center"})}},i=a.jsx(gr,{icon:a.jsx(Rt,{className:"h-3.5 w-3.5"}),title:"Table of Contents",className:"text-fg-tertiary"});return n.length===0?a.jsxs("div",{className:"surface-base w-full p-4",children:[i,a.jsx(j,{as:"p",variant:"meta",tone:"secondary",className:"mt-2",children:"Add headings to your document to generate a table of contents"})]}):a.jsxs("div",{className:"surface-base w-full p-4",children:[a.jsx("div",{className:"mb-2",children:i}),a.jsx("nav",{className:"space-y-0.5",children:n.map(l=>{const c=l.level===1;return a.jsxs("button",{type:"button",onClick:()=>r(l.id),className:K("focus-ring-soft","flex","w-full","items-center","gap-2","rounded-[10px]","px-2.5","py-1.5",s[l.level]??"pl-2.5","text-left","transition-colors","hover:bg-hover-subtle",c?"text-fg-default":"text-fg-secondary"),children:[a.jsxs(j,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"min-w-[1.5rem]",children:["H",l.level]}),a.jsx(j,{as:"span",variant:"body",weight:c?"semibold":"medium",className:"line-clamp-2 text-current",children:l.text})]},l.id)})})]})},ja=Mt({type:"tableOfContents",propSchema:{},content:"none"},{render:()=>a.jsx(Na,{})})(),Sa="focus-ring-soft inline-flex cursor-pointer items-center rounded-[8px] border border-border-subtle bg-emphasis px-2 py-0.5 text-xs font-semibold text-fg-secondary transition-colors hover:border-border-secondary hover:bg-hover-subtle hover:text-fg-default dark:bg-emphasis",Ra={type:"tag",propSchema:{id:{default:""},tag:{default:"@Unknown"}},content:"none"};function Aa(e){const n=jt(),t=()=>{e.editor.blur(),n({to:er,params:{id:e.inlineContent.props.id},search:{page:1}})},s=r=>{r.preventDefault(),r.stopPropagation()};return a.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:Sa,onMouseDown:s,onClick:r=>{s(r),t()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(s(r),t())},children:a.jsx("span",{children:e.inlineContent.props.tag})})}const Ea=Dt(Ra,{render:e=>a.jsx(Aa,{...e})}),ka=e=>e,Ta=e=>e,Da=ka({tag:Ea,reference:Ca}),Ma=Ta({tableOfContents:ja}),ce=he.codeBlock,ht=Mt(ce.config,{meta:ce.implementation.meta,parse:ce.implementation.parse,parseContent:ce.implementation.parseContent,runsBefore:ce.implementation.runsBefore,render:ba})(),Pa={...ht,extensions:ce.extensions,implementation:{...ht.implementation,toExternalHTML:ce.implementation.toExternalHTML}},_a={...he.image,implementation:{...he.image.implementation,meta:{...he.image.implementation.meta,fileBlockAccept:[...Gt]}}},La=fr.create({inlineContentSpecs:{...pr,...Da},blockSpecs:{...he,image:_a,codeBlock:Pa,...Ma}}),Oa=(e,n)=>n.some(t=>t.name===`@${e}`),Ba=({onClick:e})=>a.jsx(Je,{triggerCharacter:"@",getItems:async n=>{const t=await br({query:n,limit:5});if(t.type==="error")return[];const{tags:s}=t.allTags,r=Oa(n,s),i=[{title:"Add a new tag",onItemClick:async()=>{const l=await vr({name:"@"+n});if(l.type==="error")return;const{id:c,name:f}=l.createTag;e({type:"tag",props:{id:c,tag:f}})}}];return s.length===0?i:s.map(l=>({title:l.name,onItemClick:()=>e({type:"tag",props:{id:l.id,tag:l.name}})})).concat(n&&!r?i:[])}}),Fa=/^ {0,3}(`{3,}|~{3,})/,Ha=/<[^<>\n]*>/g,Qt=/~+/g,Jt=/[\p{L}\p{M}\p{N}\p{Sc}%‰.,+\-/:°℃℉µμ·²³^]/u,Ye=new RegExp("^(?:[+-]?\\p{Sc}?|\\p{Sc}[+-]?)\\p{N}","u"),Xt=/&#(?:x[0-9a-f]+|\d+);/giu,$a=new Set(["Files","blocknote/html","vscode-editor-data"]),gt="OBTILDE",xt="",Ia=[/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,/(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/,/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,/(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/,/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,/\n{2} {0,3}-{2,48}\n{2}/,/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,/(?:\n|^)(?!\s)\w[^\n]{0,64}\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/],Ua=e=>e.split(`
22
+ `).some(n=>{const t=n.trim();return t.length>2&&t.startsWith("|")&&t.endsWith("|")}),za=e=>Ia.some(n=>n.test(e))||Ua(e),Wa=e=>e.endsWith(`\r
23
+ `)?{body:e.slice(0,-2),ending:`\r
24
+ `}:e.endsWith(`
25
+ `)||e.endsWith("\r")?{body:e.slice(0,-1),ending:e.slice(-1)}:{body:e,ending:""},en=(e,n,t)=>{let s=n;for(;e[s]===t;)s+=1;return s-n},tn=e=>{const n=e.slice(2,-1),t=n[0]?.toLowerCase()==="x",s=Number.parseInt(t?n.slice(1):n,t?16:10);return!Number.isSafeInteger(s)||s<0||s>1114111?e:String.fromCodePoint(s)},Ka=e=>{const n=e.replace(Xt,tn),t=e.toLowerCase();let s=0,r=`${gt}${s}${xt}`;for(;e.includes(r)||t.includes(encodeURIComponent(r).toLowerCase())||n.includes(r);)s+=1,r=`${gt}${s}${xt}`;return r},Va=(e,n,t)=>t-n>2?!1:nn(e,n)&&Za(e,t),bt=(e,n)=>{let t=n;for(;t>0&&Jt.test(e[t-1]??"");)t-=1;return{start:t,token:e.slice(t,n)}},Ya=(e,n)=>{let t=n;for(;t<e.length&&Jt.test(e[t]??"");)t+=1;return e.slice(n,t)},nn=(e,n)=>{const t=bt(e,n);if(Ye.test(t.token))return!0;if(!t.token)return!1;let s=t.start;for(;s>0&&(e[s-1]===" "||e[s-1]===" ");)s-=1;return s===t.start?!1:Ye.test(bt(e,s).token)},Za=(e,n)=>Ye.test(Ya(e,n)),rn=e=>{const n=[],t=new Set;for(const s of e.matchAll(Qt)){const r=s.index,i=s[0].length,l=r+i;if(i>2)continue;const c=l<e.length&&!/\s/u.test(e[l]??""),f=r>0&&!/\s/u.test(e[r-1]??"");if(Va(e,r,l)){if(f&&t.delete(i))continue;n.push({length:i,start:r});continue}f&&t.delete(i)||c&&nn(e,r)&&t.add(i)}return n},$e=(e,n)=>{let t="",s=0;const r=new Set(rn(e).map(i=>i.start));for(const i of e.matchAll(Qt)){const l=i.index,c=l+i[0].length;t+=e.slice(s,l),t+=r.has(l)?n.repeat(i[0].length):i[0],s=c}return t+e.slice(s)},qa=e=>{const n=e.slice(1,-1),t=/^[a-z][a-z0-9.+-]{1,31}:[^\s<>]*$/i.test(n)||/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(n),s=/^<\/?[a-z][\w:-]*(?:\s[^<>]*)?\/?\s*>$/i.test(e)||/^<![^<>]*>$/.test(e);return t||s},Ga=(e,n)=>{let t="",s=0;for(const r of e.matchAll(Ha)){const i=r.index;t+=$e(e.slice(s,i),n),t+=qa(r[0])?r[0]:$e(r[0],n),s=i+r[0].length}return t+$e(e.slice(s),n)},an=e=>rn(e).length>0,Qa=e=>{if(!an(e))return st(e);const n=Ka(e),t=Ga(e,n),s=encodeURIComponent(n);return st(t).split(n).join("~").split(s).join("~")},Ja=(e,n)=>{let t=0;for(let s=n-1;s>=0&&e[s]==="\\";s-=1)t+=1;return t%2===1},Xa=(e,n,t)=>{let s=n+t;for(;s<e.length;){const r=e.indexOf("`",s);if(r===-1)return null;const i=en(e,r,"`");if(i===t)return r+i;s=r+i}return null},es=(e,n)=>{let t=e.indexOf("`",n);for(;t!==-1;){const s=en(e,t,"`");if(!Ja(e,t)){const r=Xa(e,t,s);if(r!==null)return{start:t,end:r}}t=e.indexOf("`",t+s)}return null},ts=(e,n)=>{let t="",s=0;for(;s<e.length;){const r=es(e,s);if(!r){t+=n(e.slice(s));break}t+=n(e.slice(s,r.start)),t+=e.slice(r.start,r.end),s=r.end}return t},sn=(e,n)=>{let t=null;return e.split(new RegExp("(?<=\\n)")).map(s=>{const{body:r,ending:i}=Wa(s);if(t)return new RegExp(`^ {0,3}${t.marker}{${t.length},} *$`).test(r)&&(t=null),s;const l=r.match(Fa)?.[1];return l?(t={marker:l[0],length:l.length},s):`${ts(r,n)}${i}`}).join("")},ns=(e,n)=>{let t=0;for(let s=n;s<e.length;s+=1){const r=e[s];if(r==="\\"){s+=1;continue}if(r==="("){t+=1;continue}if(r===")"){if(t>0){t-=1;continue}return s}}return null},on=e=>{let n="",t=0;for(;t<e.length;){const s=e.indexOf("](",t);if(s===-1){n+=e.slice(t);break}const r=s+2,i=ns(e,r);if(i===null){n+=e.slice(t);break}n+=e.slice(t,r),n+=e.slice(r,i).split("\\&").join("&"),n+=")",t=i+1}return n},rs=(e,n)=>{const t=e[n-1];if(t!=="*"&&t!=="_")return!1;let s=n-1;for(;s>0&&e[s-1]===t;)s-=1;const r=e.slice(s,n),i=e.lastIndexOf(r,s-1);return i!==-1&&i+r.length<s},as=(e,n)=>{const t=e[n];if(t!=="*"&&t!=="_")return!1;let s=n+1;for(;s<e.length&&e[s]===t;)s+=1;const r=e.slice(n,s),i=e.indexOf(r,s);return i!==-1&&s<i},ss=(e,n,t)=>rs(e,n)||as(e,n+t),os=e=>sn(e,n=>{const t=n.replace(Xt,(s,r,i)=>ss(i,r,s.length)?tn(s):s);return on(t)}),is=e=>sn(e,on),cs=e=>{const n=e.getData("text/plain");n&&(e.setData("text/markdown",n),e.setData("text/plain",os(n)))},ls=({event:e,editor:n,defaultPasteHandler:t})=>{const s=e.clipboardData;if(!s||n.getTextCursorPosition().block.type==="codeBlock")return t();const r=Array.from(s.types);if(r.some(c=>$a.has(c)))return t();const i=r.includes("text/markdown"),l=s.getData(i?"text/markdown":"text/plain");return!l||!an(l)||!i&&r.includes("text/html")&&!za(l)?t():(n.pasteHTML(Qa(l)),!0)},ds=new Set(["tableOfContents"]),us="OCEAN_BRAIN_TAG_",fs="_TOKEN",ps=e=>`${us}${e}${fs}`,ms=e=>!Array.isArray(e)&&e?.type==="tableContent",hs=(e,n)=>Array.isArray(e)?e.map(n):ms(e)?{...e,rows:e.rows?.map(t=>({...t,cells:t.cells?.map(s=>({...s,content:s.content?.map(n)}))}))}:e,cn=(e,n)=>e.filter(t=>!ds.has(t.type)).map(t=>({...t,content:n(t.content),children:t.children?.length?cn(t.children,n):[]}));function gs(e){const n=new Map;let t=0;return{blocks:cn(e,r=>hs(r,i=>{if(i.type==="reference"){const l=String(i.props?.id||""),c=String(i.props?.title||i.props?.id||"");return{type:"text",text:l?`[[${c}]](note:${l})`:`[[${c}]]`,styles:{}}}if(i.type==="tag"){const l=i.props?.tag||"",c=ps(t);return t+=1,n.set(c,l),{type:"text",text:c,styles:{}}}return i})),placeholderToTag:n}}function xs(e,n){let t=e;for(const[s,r]of n.entries())t=t.split(s).join(`[${r}]`);return t}async function bs(e){return new Promise((n,t)=>{const s=new FileReader;s.readAsDataURL(e),s.onload=()=>n(s.result),s.onerror=r=>t(r)})}const vs=o.forwardRef(({content:e,currentNoteId:n,editable:t,onChange:s},r)=>{const{theme:i}=Nt(u=>u),l=Re(),c=cr({schema:La,initialContent:e&&JSON.parse(e)||void 0,pasteHandler:u=>ls(u),uploadFile:async(u,p)=>{const g=()=>{p&&c.getBlock(p)&&c.removeBlocks([p])};if(!ca(u.type))throw g(),l(dt),new Error(dt);try{return await dr({base64:await bs(u)})}catch(x){throw g(),l(ia),x}}},[l]);o.useImperativeHandle(r,()=>({getContent:()=>JSON.stringify(c.document),getMarkdown:()=>{const u=gs(c.document),p=c.blocksToMarkdownLossy(u.blocks);return is(xs(p,u.placeholderToTag))},getHtml:()=>c.blocksToHTMLLossy(c.document)}));const f=u=>{cs(u.clipboardData)};return a.jsxs(lr,{slashMenu:!1,theme:i,editor:c,editable:t,onChange:s,onCopy:f,onCut:f,children:[a.jsx(ra,{editor:c}),a.jsx(sa,{currentNoteId:n,onClick:u=>{c.insertInlineContent([u," "])}}),a.jsx(Ba,{onClick:u=>{c.insertInlineContent([u," "])}})]})}),ys=({event:e,noteId:n,editSessionId:t,loadedUpdatedAt:s,acceptedUpdatedAt:r,hasUnsavedChanges:i})=>{if(e.noteId!==n||e.type==="mcp.note.created")return{type:"ignore"};if(e.source==="web"&&e.editSessionId===t)return{type:"ignore"};if(e.type==="mcp.note.deleted")return{type:"notify",change:{type:"deleted",source:e.source},shouldPauseSave:!1};const l=je(e.updatedAt,s),c=je(e.updatedAt,r);return l!==null&&l<=0||c!==null&&c<=0?{type:"ignore"}:{type:"notify",change:{type:"updated",updatedAt:e.updatedAt,source:e.source},shouldPauseSave:i}},ws=({change:e,isConflict:n,loadedUpdatedAt:t})=>e?!(e.type==="updated"&&!n&&e.updatedAt===t):!1;function Cs({allowNextNavigationRef:e,hasExternalPendingChanges:n,saveStatus:t,flushPendingChanges:s,notify:r}){const i=o.useCallback(async()=>{if(e.current)return e.current=!1,!1;if(t==="conflict")return r("Resolve the note conflict before leaving."),!0;const l=await s();return l==="error"?(r("Save failed. Stay on this note and try again."),!0):l==="conflict"},[e,s,r,t]);Cr({disabled:t==="saved"&&!n,enableBeforeUnload:!1,shouldBlockFn:i})}const et=e=>`ocean-brain.note-draft.${e}`,Ns=e=>{if(typeof window>"u")return null;try{const n=window.localStorage.getItem(et(e));if(!n)return null;const t=JSON.parse(n);return typeof t.title!="string"||typeof t.content!="string"||typeof t.baseUpdatedAt!="string"?null:{title:t.title,content:t.content,baseUpdatedAt:t.baseUpdatedAt,createdAt:typeof t.createdAt=="number"?t.createdAt:Date.now(),...t.layout==="narrow"||t.layout==="wide"||t.layout==="full"?{layout:t.layout}:{}}}catch{return null}},Ie=(e,n)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(et(e),JSON.stringify(n))}catch{}},Ue=e=>{if(!(typeof window>"u"))try{window.localStorage.removeItem(et(e))}catch{}},js=1e3,Ss="NOTE_UPDATE_CONFLICT";function Rs({noteId:e,initialContent:n,initialUpdatedAt:t,editSessionIdRef:s,getContent:r,beforeSave:i,hasExternalPendingChanges:l,serverVersionRef:c,executeWrite:f,onSaved:u,onConflict:p,onError:g}){const x=Ze(),d=o.useRef(null),h=o.useRef(null),y=o.useRef(!1),N=o.useRef(null),S=o.useRef(!1),A=o.useRef(t),w=c??A,m=o.useRef(0),v=o.useRef(!1),T=o.useRef(!0),H=o.useRef(u),M=o.useRef(p),V=o.useRef(g),be=o.useRef(i),X=o.useRef(l),me=o.useRef(f),[re,ee]=o.useState("saved"),[ke,le]=o.useState(null),$=o.useCallback(()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},[]),L=o.useCallback(E=>{T.current&&ee(E)},[]),Te=o.useCallback(E=>{w.current=E},[]),ve=o.useCallback((E,O={})=>({title:E,content:r()??n,createdAt:Date.now(),baseUpdatedAt:w.current,...O.layout?{layout:O.layout}:{}}),[r,n]),de=o.useCallback(()=>{h.current&&Ie(e,h.current)},[e]),ae=o.useCallback(E=>{v.current=!0,L("conflict"),M.current(E??w.current)},[L]),_=o.useCallback(async({ignoreConflict:E=!1,silent:O=!1}={})=>{if(y.current)return S.current=!0,N.current??"idle";const Me=h.current!==null,se=X.current?.()??!1;if(!Me&&!se)return S.current=!1,"idle";const I=m.current;S.current=!1,$(),y.current=!0,O||L("saving");const F=(async()=>{const ue=await be.current?.()??"idle";if(I!==m.current)return"idle";if(ue==="error")return y.current=!1,N.current=null,h.current?L("error"):L("saved"),"error";const P=h.current;if(!P)return y.current=!1,N.current=null,L("saved"),ue;h.current=null;const q=async()=>{if(I!==m.current)return"idle";let W;try{W=await We({id:e,title:P.title,content:P.content,...P.layout?{layout:P.layout}:{},editSessionId:s.current,...E?{force:!0}:{expectedUpdatedAt:w.current}})}catch{W={type:"error",category:"network",errors:[{code:"NETWORK_ERROR",message:"Failed to save note."}]}}if(I!==m.current)return"idle";if(W.type==="error"){y.current=!1,N.current=null,h.current||(h.current=P),de();const U=W.errors[0];if(U.code===Ss&&!E){const oe=U.details?.extensions?.currentUpdatedAt;return v.current=!0,!O&&T.current&&(L("conflict"),M.current(oe??w.current)),"conflict"}return!O&&T.current&&(L("error"),V.current(U.message)),"error"}const we=!O&&T.current,J=B.notes.detail(e);if(await x.cancelQueries({queryKey:J,exact:!0}),I!==m.current)return"idle";y.current=!1,N.current=null,v.current=!1,w.current=W.updateNote.updatedAt,we&&H.current(W.updateNote.updatedAt),x.setQueryData(J,U=>U&&{...U,title:W.updateNote.title,content:P.content,...P.layout?{layout:P.layout}:{},updatedAt:W.updateNote.updatedAt}),At({noteId:e,updatedAt:W.updateNote.updatedAt,editSessionId:s.current});const fe=h.current;return fe?.baseUpdatedAt===P.baseUpdatedAt?(h.current={...fe,baseUpdatedAt:W.updateNote.updatedAt},de()):fe||Ue(e),h.current||Et(x),we&&(h.current?ee("pending"):ee("saved")),"saved"},z=me.current?await me.current(q):await q();return z?z==="saved"&&(h.current||S.current)?_({silent:O}):z:(h.current||(h.current=P),de(),y.current=!1,N.current=null,L("pending"),"idle")})();return N.current=F,F},[$,s,e,de,x,w,L]),te=o.useCallback((E,O={})=>{if(h.current=E,Ie(e,E),v.current){L("conflict");return}if(L("pending"),$(),O.immediate){_();return}d.current=window.setTimeout(()=>{_()},js)},[$,_,e,L]),ne=o.useCallback(E=>{if(h.current=E,Ie(e,E),le(null),E.baseUpdatedAt!==w.current){ae(w.current);return}te(E)},[e,te,ae]),ye=o.useCallback(()=>{m.current+=1,$(),h.current=null,y.current=!1,N.current=null,S.current=!1,v.current=!1,Ue(e),le(null),ee("saved")},[$,e]),De=o.useCallback(()=>{$(),N.current=null,S.current=!1,v.current=!1,L(h.current?"pending":"saved")},[$,L]),Q=o.useCallback(()=>{Ue(e),le(null)},[e]),Z=o.useCallback(()=>h.current,[]),Y=o.useCallback(E=>{$(),ae(E)},[$,ae]);return o.useEffect(()=>{be.current=i,me.current=f,X.current=l,M.current=p,V.current=g,H.current=u},[i,f,l,p,g,u]),o.useEffect(()=>(T.current=!0,()=>{T.current=!1}),[]),o.useEffect(()=>{h.current||y.current||v.current||(w.current=t,ee("saved"))},[t]),o.useEffect(()=>{m.current+=1,h.current=null,y.current=!1,N.current=null,S.current=!1,v.current=!1,w.current=t,le(Ns(e)),ee("saved")},[e]),o.useEffect(()=>{const E=O=>{!h.current&&!y.current&&!v.current&&!X.current?.()||(O.preventDefault(),O.returnValue="")};return window.addEventListener("beforeunload",E),()=>{window.removeEventListener("beforeunload",E)}},[]),o.useEffect(()=>()=>{$(),h.current&&!v.current&&_({silent:!0})},[$,_]),{saveStatus:re,localDraft:ke,serverUpdatedAtRef:w,hasUnsavedChanges:re!=="saved",buildDraft:ve,queueSave:te,flushPendingSave:_,restoreLocalDraft:ne,discardLocalDraft:Q,clearDrafts:ye,resolveConflict:De,pauseForConflict:Y,getPendingDraft:Z,setServerUpdatedAt:Te}}function As(){const e=o.useRef(Promise.resolve()),n=o.useRef(0),t=o.useRef(0),[s,r]=o.useState(!1),i=o.useCallback(u=>{t.current+=1,r(!0);const p=n.current,g=()=>p===n.current?u():void 0,x=e.current.then(g,g);e.current=x.then(()=>{},()=>{});const d=()=>{t.current-=1,t.current===0&&r(!1)};return x.then(d,d),x},[]),l=o.useCallback(()=>{n.current+=1},[]),c=o.useCallback(()=>e.current,[]),f=o.useCallback(()=>t.current>0,[]);return o.useMemo(()=>({execute:i,invalidatePending:l,drain:c,isBusy:s,hasPendingWrites:f}),[c,i,f,l,s])}const Es="NOTE_UPDATE_CONFLICT",ze=e=>{const n=ge(e);return G(n??Number(e)).format("YYYY-MM-DD HH:mm:ss")},ks=e=>e?.extensions?.currentUpdatedAt;function Ts({noteId:e,navigateToNote:n,notify:t}){const s=Ze(),r=o.useRef(null),i=o.useRef(null),[l]=o.useState(ot),c=o.useRef(l),f=o.useRef(null),u=o.useRef(null),p=o.useRef(!1),g=o.useRef(0),x=yt({queryKey:B.notes.detail(e),queryFn:async()=>{const b=await On(e);if(b.type==="error")throw b;return b.note},gcTime:0}),d=x.data,h=x.refetch,y=o.useRef(d.updatedAt),N=o.useRef(d.updatedAt),[S,A]=o.useState(d.title),[w,m]=o.useState(d.pinned),[v,T]=o.useState(d.layout||"wide"),H=o.useRef(v),[M,V]=o.useState(null),[be,X]=o.useState(null),[me,re]=o.useState(0),[ee,ke]=o.useState(()=>ze(d.updatedAt)),[le,$]=o.useState(d.updatedAt),[L,Te]=o.useState(0),[ve,de]=o.useState(!1),ae=o.useRef(!1),{execute:_,invalidatePending:te,drain:ne,isBusy:ye,hasPendingWrites:De}=As(),Q=o.useCallback(b=>{H.current=b,T(b)},[]),Z=o.useCallback((b,C={})=>{y.current=b,N.current=b,ke(ze(b)),$(b),C.confirmSave&&Te(R=>R+1)},[]),Y=o.useCallback(async({updatedAt:b,patch:C,confirmSave:R=!0})=>{const pe=B.notes.detail(e),Le=g.current;return await s.cancelQueries({queryKey:pe,exact:!0}),Le!==g.current?!1:(Z(b,{confirmSave:R}),s.setQueryData(pe,Oe=>Oe&&{...Oe,...C,updatedAt:b}),At({noteId:e,updatedAt:b,editSessionId:c.current}),Et(s),!0)},[Z,e,s]),E=o.useCallback(b=>{ae.current=b,de(b)},[]),O=o.useCallback(()=>f.current?.flushPendingSave({expectedUpdatedAt:y.current})??Promise.resolve("idle"),[]),Me=Rs({noteId:e,initialContent:d.content,initialUpdatedAt:d.updatedAt,editSessionIdRef:c,serverVersionRef:y,executeWrite:_,getContent:()=>r.current?.getContent(),beforeSave:O,hasExternalPendingChanges:()=>ae.current||De(),onSaved:b=>{u.current=null,Z(b,{confirmSave:!0})},onConflict:b=>{V({type:"updated",updatedAt:b,source:"unknown"}),t("This note changed elsewhere. Choose how to resolve the draft.")},onError:t}),{saveStatus:se,localDraft:I,serverUpdatedAtRef:F,hasUnsavedChanges:ue,buildDraft:P,queueSave:q,flushPendingSave:z,restoreLocalDraft:W,discardLocalDraft:we,clearDrafts:J,resolveConflict:fe,pauseForConflict:U,getPendingDraft:oe}=Me,Ce=ue||ve||ye,tt=o.useCallback(async b=>{const C=await z(b);return C==="error"||C==="conflict"||await ne(),C},[ne,z]),dn=o.useCallback(b=>_(async()=>{const C=await Bn({...b,expectedUpdatedAt:y.current});return C.type==="success"&&await Y({updatedAt:C.updateNoteProperties.updatedAt,patch:{properties:C.updateNoteProperties.properties}}),C}),[Y,_]);Cs({allowNextNavigationRef:p,hasExternalPendingChanges:ve||ye,saveStatus:se,flushPendingChanges:tt,notify:t}),o.useEffect(()=>{if(Ce){d.updatedAt!==F.current&&(je(d.updatedAt,F.current)??0)>0&&U(d.updatedAt);return}const b=N.current;if(!(b&&d.updatedAt!==b&&(je(d.updatedAt,b)??0)<0)&&(m(d.pinned),Q(d.layout||"wide"),A(d.title),b!==d.updatedAt)){const C=r.current?.getContent();Z(d.updatedAt),(C===void 0||C!==d.content)&&(X(null),re(R=>R+1))}},[Z,Ce,d.content,d.layout,d.pinned,d.title,d.updatedAt,U,F]),o.useEffect(()=>{M?.type!=="updated"||se==="conflict"||M.updatedAt!==d.updatedAt||(Z(d.updatedAt),V(null))},[Z,M,d.updatedAt,se]),o.useEffect(()=>qn(b=>{const C=ys({event:b,noteId:e,editSessionId:c.current,loadedUpdatedAt:d.updatedAt,acceptedUpdatedAt:F.current,hasUnsavedChanges:Ce});C.type!=="ignore"&&(C.shouldPauseSave&&C.change.type==="updated"&&U(C.change.updatedAt),V(C.change))}),[Ce,d.updatedAt,e,U,F]);const un=o.useCallback(()=>{q(P(S))},[P,q,S]),fn=o.useCallback(b=>{A(b),q(P(b))},[P,q]),pn=o.useCallback(()=>{q(P(S),{immediate:!0})},[P,q,S]),mn=o.useCallback(async b=>{if(ue){Q(b),q(P(S,{layout:b}),{immediate:!0}),t("Layout will be saved with your draft.");return}const C=await z();C==="error"||C==="conflict"||await _(async()=>{const R=await We({id:e,layout:b,editSessionId:c.current,expectedUpdatedAt:F.current});if(R.type==="error"){R.errors[0].code===Es&&(u.current=b,Q(b),U(ks(R.errors[0].details)??F.current)),t(R.errors[0].message);return}await Y({updatedAt:R.updateNote.updatedAt,patch:{layout:b}})&&(u.current=null,Q(b),t("Layout has been updated."))})},[Y,P,_,z,ue,e,t,U,q,F,S]),hn=o.useCallback(async()=>{const b=await z();if(b==="error"||b==="conflict")return;const C=!w;await _(async()=>{const R=await Fn(e,C);if(R.type==="error"){t(R.errors[0].message);return}await Y({updatedAt:R.pinNote.updatedAt,patch:{pinned:C},confirmSave:!1})&&m(C)})},[Y,_,z,w,e,t]),Pe=o.useCallback(()=>({id:e,title:S,createdAt:d.createdAt,updatedAt:F.current||d.updatedAt}),[d.createdAt,d.updatedAt,e,F,S]),gn=o.useCallback(async()=>{const b=r.current?.getMarkdown();if(b===void 0){t("Markdown is not ready yet.");return}try{await navigator.clipboard.writeText(Kt(b,Pe())),t("Copied note as Markdown.")}catch{t("Failed to copy Markdown.")}},[Pe,t]),xn=o.useCallback(async()=>{f.current?.invalidateInFlightSave(),te(),await ne(),g.current+=1;const b=await h();if(b.error||!b.data){t("Failed to reload the latest note state.");return}f.current?.discardPendingChanges(),J(),u.current=null,Z(b.data.updatedAt),A(b.data.title),Q(b.data.layout||"wide"),X(null),re(C=>C+1),V(null)},[J,Z,ne,te,t,h]),bn=o.useCallback(async()=>{if(oe()){u.current=null,V(null),await z({ignoreConflict:!0});return}const C=u.current;if(!C){V(null),await z({ignoreConflict:!0});return}await _(async()=>{const R=await We({id:e,layout:C,editSessionId:c.current,force:!0});if(R.type==="error"){t(R.errors[0].message);return}await Y({updatedAt:R.updateNote.updatedAt,patch:{layout:C}})&&(u.current=null,fe(),V(null),Q(C))})},[Y,_,z,oe,e,t,fe]),vn=o.useCallback(async()=>{const b=oe();if(!b||await O()==="error")return;const R=await Hn({title:nt(b.title||"untitled"),content:nt(b.content),layout:b.layout??v});if(R.type==="error"){t(R.errors[0].message);return}p.current=!0,u.current=null,V(null),J(),Promise.resolve(n(R.createNote.id)).finally(()=>{p.current=!1})},[J,O,oe,v,n,t]),yn=o.useCallback(()=>{I&&(A(I.title),I.layout&&Q(I.layout),X(I.content),re(b=>b+1),W(I))},[I,W]),wn=o.useCallback(()=>{},[]),Cn=o.useCallback(async b=>(f.current?.invalidateInFlightSave(),te(),await ne(),g.current+=1,_(async()=>{const C=await $n(b,F.current);if(C.type==="error")return C;const R=C.restoreNoteSnapshot;return await Y({updatedAt:R.updatedAt,patch:{title:R.title,content:R.content,layout:R.layout,pinned:R.pinned}})&&(c.current=ot(),f.current?.discardPendingChanges(),J(),u.current=null,V(null),A(R.title),Q(R.layout||"wide"),m(R.pinned),X(R.content),re(Le=>Le+1)),C})),[Y,J,ne,_,te]),_e=se==="conflict"&&M?.type==="updated",Nn=_e?oe():null;return{document:{title:S,titleRef:i,isPinned:w,layout:v,getLayout:()=>H.current,properties:d.properties,createdAt:ze(d.createdAt),onTitleChange:fn,onLayoutSave:mn,onTogglePinned:hn},editor:{ref:r,key:`${e}:${me}`,content:be??d.content,getContent:()=>r.current?.getContent()??"",getHtml:()=>r.current?.getHtml(),getMarkdown:()=>r.current?.getMarkdown(),onChange:un},save:{status:se,lastSavedAt:ee,lastSavedVersion:le,confirmationRevision:L,onManualSave:pn,flushPendingChanges:tt},recovery:{localDraftCreatedAt:I?G(I.createdAt).format("YYYY-MM-DD HH:mm:ss"):null,onRestoreLocalDraft:yn,onDiscardLocalDraft:we,onClonePendingDraft:vn},externalChange:{value:M,isConflict:_e,hasConflictDraft:Nn!==null,isBlocking:ws({change:M,isConflict:_e,loadedUpdatedAt:d.updatedAt}),isReloading:x.isRefetching,onReload:xn,onOverwrite:bn},properties:{ref:f,expectedUpdatedAt:F.current,editSessionId:c.current,saveProperties:dn,onPendingChange:E,onSaved:wn},exportDocument:{metadata:Pe(),onCopyMarkdown:gn},snapshots:{restore:Cn}}}const ln=In(Ae),Ds={narrow:"max-w-[640px]",wide:"max-w-[896px]",full:"max-w-full px-4"},Ms=a.jsx(Ge,{title:"Loading note",variant:"none",children:a.jsxs("main",{className:"mx-auto max-w-[896px]",children:[a.jsx(ie,{className:"mb-8",height:123}),a.jsxs("div",{className:"flex flex-col gap-5",children:[a.jsx(ie,{height:135}),a.jsx(ie,{className:"ml-12",height:320}),a.jsx(ie,{height:107}),a.jsx(ie,{height:100})]})]})});function Ps({noteId:e}){return a.jsx(qe,{fallback:a.jsx(ie,{height:107}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading reminder details for this note.",renderError:({error:n,retry:t})=>a.jsx(Qe,{title:"Failed to load reminders",description:"Retry loading reminder details for this note.",error:n,onRetry:t,showBackAction:!1,showHomeAction:!1}),children:a.jsx(ta,{noteId:e})})}function _s({noteId:e}){return a.jsx(qe,{fallback:a.jsx(ie,{height:100}),errorTitle:"Failed to load back references",errorDescription:"Retry loading notes that link back here.",renderError:({error:n,retry:t})=>a.jsx(Qe,{title:"Failed to load back references",description:"Retry loading notes that link back here.",error:n,onRetry:t,showBackAction:!1,showHomeAction:!1}),children:a.jsx(Rr,{noteId:e,render:n=>n?.length?a.jsx(Tt,{icon:a.jsx(xr,{className:"h-3.5 w-3.5"}),title:"Back References",children:a.jsx("ul",{className:"flex flex-col",children:n.map(t=>a.jsx("li",{children:a.jsxs(Un,{to:Ae,params:{id:t.id},className:"flex items-center gap-2 rounded-[10px] px-2.5 py-1.5 text-fg-secondary transition-colors hover:bg-hover-subtle hover:text-fg-default",children:[a.jsx(yr,{className:"h-3.5 w-3.5 shrink-0 text-fg-tertiary"}),a.jsx(j,{as:"span",variant:"body",weight:"medium",className:"text-current",children:t.title})]})},t.id))})}):null})})}function Ls({id:e}){const n=Re(),t=ln.useNavigate(),[s,r]=o.useState(!1),[i,l]=o.useState(!1),[c,f]=o.useState(!1),u=Ts({noteId:e,notify:n,navigateToNote:M=>t({to:Ae,params:{id:M}})}),{onCreate:p,onDelete:g,deleteWarningDialog:x}=Gn(),{document:d,editor:h,save:y,recovery:N,externalChange:S,properties:A,exportDocument:w,snapshots:m}=u,v=()=>t({to:tr,search:{page:1}}),T=async()=>{const M=await y.flushPendingChanges();M==="error"||M==="conflict"||await g(e,v)},H=async()=>{const M=await y.flushPendingChanges();M==="error"||M==="conflict"||await p(d.titleRef.current?.value||"untitled",h.getContent(),d.getLayout())};return a.jsx(Ge,{title:d.title,variant:"none",children:a.jsxs("main",{className:K("mx-auto",Ds[d.layout]),children:[a.jsx(Dr,{title:d.title,titleRef:d.titleRef,isPinned:d.isPinned,createdAt:d.createdAt,saveStatus:y.status,savedAt:y.lastSavedAt,savedVersion:y.lastSavedVersion,saveConfirmationRevision:y.confirmationRevision,onTitleChange:d.onTitleChange,onCopyMarkdown:()=>{w.onCopyMarkdown()},onDownloadDocument:()=>f(!0),onTogglePinned:()=>{d.onTogglePinned()},onChangeLayout:()=>r(!0),onCloneNote:()=>{H()},onRestoreVersion:()=>l(!0),onDelete:()=>{T()},onSave:y.onManualSave}),a.jsx(Jr,{localDraftCreatedAt:N.localDraftCreatedAt,hasSaveError:y.status==="error",onRestoreDraft:N.onRestoreLocalDraft,onDiscardDraft:N.onDiscardLocalDraft,onRetrySave:y.onManualSave,onSaveAsNewNote:()=>{N.onClonePendingDraft()}}),a.jsxs("div",{className:"flex flex-col gap-5",children:[a.jsx(Xn,{ref:A.ref,noteId:e,properties:d.properties,expectedUpdatedAt:A.expectedUpdatedAt,editSessionId:A.editSessionId,disabled:y.status!=="saved",saveProperties:A.saveProperties,onPendingChange:A.onPendingChange,onSaved:A.onSaved}),a.jsx(vs,{ref:h.ref,content:h.content,currentNoteId:e,onChange:h.onChange},h.key),a.jsx(Ps,{noteId:e}),a.jsx(_s,{noteId:e})]}),a.jsx(Er,{isOpen:s,onClose:()=>r(!1),onSave:d.onLayoutSave,currentLayout:d.layout}),a.jsx(Qr,{isOpen:S.isBlocking,isDeleted:S.value?.type==="deleted",isConflict:S.isConflict,hasDraft:S.hasConflictDraft,source:S.value?.source??"unknown",isReloading:S.isReloading,onReload:()=>{S.onReload()},onOverwrite:()=>{S.onOverwrite()},onCloneDraft:()=>{N.onClonePendingDraft()},onOpenTrash:()=>{v()}}),a.jsx(Zr,{isOpen:c,metadata:w.metadata,getHtml:h.getHtml,getMarkdown:h.getMarkdown,onClose:()=>f(!1)}),a.jsx(Xr,{isOpen:i,noteId:e,onClose:()=>l(!1),restoreSnapshot:m.restore}),x]})})}function to(){const{id:e}=ln.useParams();if(!e)throw new Error("Note id is required.");return a.jsx(qe,{fallback:Ms,errorTitle:"Failed to load note",errorDescription:"Retry loading the note editor.",resetKeys:[e],renderError:({error:n,retry:t})=>a.jsx(Ge,{title:"Note",variant:"none",children:a.jsx(Qe,{title:"Failed to load note",description:"Retry loading the note editor.",error:n,onRetry:t})}),children:a.jsx(Ls,{id:e},e)})}export{Ls as NoteContent,to as default};
@@ -0,0 +1,2 @@
1
+ import{j as J,q as zt,g as Kt,r as lt}from"./floating-ui.react-dom-BWTnA00G.js";import{a as Gt,n as qt,j as Yt}from"./time-D5LRMumI.js";import{c as At,u as Vt,q as Nt,U as Xt,T as gt,x as Dt,y as It,I as jt,B as kt,H as Jt,V as $t,W as Qt,X as te,Y as ee,Z as re,_ as ne,F as Ft,e as ie,o as ae}from"./note.api-D3oJmG3q.js";import{A as se,p as oe}from"./AuxiliaryPanelHeader-B1k7pZpn.js";import{a as Pt}from"./url-9nrbQs7Z.js";import{n as Ut}from"./Plus.es-DRfLW_bI.js";function le({title:nt,icon:ft,action:m,titleButtonProps:D,ariaLabel:b,className:o,children:l}){const n=l!=null&&l!==!1,h=m!=null&&m!==!1,v=J.jsx(se,{icon:ft,title:nt,className:"text-fg-tertiary"});return J.jsxs("section",{className:At("surface-base p-4",o),"aria-label":b??nt,children:[J.jsxs("div",{className:At("relative",h&&"pr-44 sm:pr-48",n&&"mb-3"),children:[D?J.jsx("button",{...D,type:"button",className:At("focus-ring-soft -m-1 flex items-center gap-2 rounded-[10px] p-1 text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-default",D.className),children:v}):v,h&&J.jsx("div",{className:"absolute top-1/2 right-0 flex -translate-y-1/2 items-center gap-2",children:m})]}),l]})}function Ct(nt){throw new Error('Could not dynamically require "'+nt+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Rt={exports:{}};var Lt;function ue(){return Lt||(Lt=1,(function(nt,ft){(function(m){nt.exports=m()})(function(){return(function m(D,b,o){function l(v,k){if(!b[v]){if(!D[v]){var _=typeof Ct=="function"&&Ct;if(!k&&_)return _(v,!0);if(n)return n(v,!0);var g=new Error("Cannot find module '"+v+"'");throw g.code="MODULE_NOT_FOUND",g}var i=b[v]={exports:{}};D[v][0].call(i.exports,function(c){var r=D[v][1][c];return l(r||c)},i,i.exports,m,D,b,o)}return b[v].exports}for(var n=typeof Ct=="function"&&Ct,h=0;h<o.length;h++)l(o[h]);return l})({1:[function(m,D,b){var o=m("./utils"),l=m("./support"),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";b.encode=function(h){for(var v,k,_,g,i,c,r,u=[],a=0,d=h.length,w=d,z=o.getTypeOf(h)!=="string";a<h.length;)w=d-a,_=z?(v=h[a++],k=a<d?h[a++]:0,a<d?h[a++]:0):(v=h.charCodeAt(a++),k=a<d?h.charCodeAt(a++):0,a<d?h.charCodeAt(a++):0),g=v>>2,i=(3&v)<<4|k>>4,c=1<w?(15&k)<<2|_>>6:64,r=2<w?63&_:64,u.push(n.charAt(g)+n.charAt(i)+n.charAt(c)+n.charAt(r));return u.join("")},b.decode=function(h){var v,k,_,g,i,c,r=0,u=0,a="data:";if(h.substr(0,a.length)===a)throw new Error("Invalid base64 input, it looks like a data url.");var d,w=3*(h=h.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(h.charAt(h.length-1)===n.charAt(64)&&w--,h.charAt(h.length-2)===n.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(d=l.uint8array?new Uint8Array(0|w):new Array(0|w);r<h.length;)v=n.indexOf(h.charAt(r++))<<2|(g=n.indexOf(h.charAt(r++)))>>4,k=(15&g)<<4|(i=n.indexOf(h.charAt(r++)))>>2,_=(3&i)<<6|(c=n.indexOf(h.charAt(r++))),d[u++]=v,i!==64&&(d[u++]=k),c!==64&&(d[u++]=_);return d}},{"./support":30,"./utils":32}],2:[function(m,D,b){var o=m("./external"),l=m("./stream/DataWorker"),n=m("./stream/Crc32Probe"),h=m("./stream/DataLengthProbe");function v(k,_,g,i,c){this.compressedSize=k,this.uncompressedSize=_,this.crc32=g,this.compression=i,this.compressedContent=c}v.prototype={getContentWorker:function(){var k=new l(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new h("data_length")),_=this;return k.on("end",function(){if(this.streamInfo.data_length!==_.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),k},getCompressedWorker:function(){return new l(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},v.createWorkerFrom=function(k,_,g){return k.pipe(new n).pipe(new h("uncompressedSize")).pipe(_.compressWorker(g)).pipe(new h("compressedSize")).withStreamInfo("compression",_)},D.exports=v},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(m,D,b){var o=m("./stream/GenericWorker");b.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},b.DEFLATE=m("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(m,D,b){var o=m("./utils"),l=(function(){for(var n,h=[],v=0;v<256;v++){n=v;for(var k=0;k<8;k++)n=1&n?3988292384^n>>>1:n>>>1;h[v]=n}return h})();D.exports=function(n,h){return n!==void 0&&n.length?o.getTypeOf(n)!=="string"?(function(v,k,_,g){var i=l,c=g+_;v^=-1;for(var r=g;r<c;r++)v=v>>>8^i[255&(v^k[r])];return-1^v})(0|h,n,n.length,0):(function(v,k,_,g){var i=l,c=g+_;v^=-1;for(var r=g;r<c;r++)v=v>>>8^i[255&(v^k.charCodeAt(r))];return-1^v})(0|h,n,n.length,0):0}},{"./utils":32}],5:[function(m,D,b){b.base64=!1,b.binary=!1,b.dir=!1,b.createFolders=!0,b.date=null,b.compression=null,b.compressionOptions=null,b.comment=null,b.unixPermissions=null,b.dosPermissions=null},{}],6:[function(m,D,b){var o=null;o=typeof Promise<"u"?Promise:m("lie"),D.exports={Promise:o}},{lie:37}],7:[function(m,D,b){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",l=m("pako"),n=m("./utils"),h=m("./stream/GenericWorker"),v=o?"uint8array":"array";function k(_,g){h.call(this,"FlateWorker/"+_),this._pako=null,this._pakoAction=_,this._pakoOptions=g,this.meta={}}b.magic="\b\0",n.inherits(k,h),k.prototype.processChunk=function(_){this.meta=_.meta,this._pako===null&&this._createPako(),this._pako.push(n.transformTo(v,_.data),!1)},k.prototype.flush=function(){h.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},k.prototype.cleanUp=function(){h.prototype.cleanUp.call(this),this._pako=null},k.prototype._createPako=function(){this._pako=new l[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var _=this;this._pako.onData=function(g){_.push({data:g,meta:_.meta})}},b.compressWorker=function(_){return new k("Deflate",_)},b.uncompressWorker=function(){return new k("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(m,D,b){function o(i,c){var r,u="";for(r=0;r<c;r++)u+=String.fromCharCode(255&i),i>>>=8;return u}function l(i,c,r,u,a,d){var w,z,S=i.file,R=i.compression,O=d!==v.utf8encode,U=n.transformTo("string",d(S.name)),I=n.transformTo("string",v.utf8encode(S.name)),W=S.comment,Y=n.transformTo("string",d(W)),p=n.transformTo("string",v.utf8encode(W)),T=I.length!==S.name.length,e=p.length!==W.length,N="",X="",L="",Q=S.dir,Z=S.date,$={crc32:0,compressedSize:0,uncompressedSize:0};c&&!r||($.crc32=i.crc32,$.compressedSize=i.compressedSize,$.uncompressedSize=i.uncompressedSize);var E=0;c&&(E|=8),O||!T&&!e||(E|=2048);var y=0,G=0;Q&&(y|=16),a==="UNIX"?(G=798,y|=(function(F,at){var ut=F;return F||(ut=at?16893:33204),(65535&ut)<<16})(S.unixPermissions,Q)):(G=20,y|=(function(F){return 63&(F||0)})(S.dosPermissions)),w=Z.getUTCHours(),w<<=6,w|=Z.getUTCMinutes(),w<<=5,w|=Z.getUTCSeconds()/2,z=Z.getUTCFullYear()-1980,z<<=4,z|=Z.getUTCMonth()+1,z<<=5,z|=Z.getUTCDate(),T&&(X=o(1,1)+o(k(U),4)+I,N+="up"+o(X.length,2)+X),e&&(L=o(1,1)+o(k(Y),4)+p,N+="uc"+o(L.length,2)+L);var K="";return K+=`
2
+ \0`,K+=o(E,2),K+=R.magic,K+=o(w,2),K+=o(z,2),K+=o($.crc32,4),K+=o($.compressedSize,4),K+=o($.uncompressedSize,4),K+=o(U.length,2),K+=o(N.length,2),{fileRecord:_.LOCAL_FILE_HEADER+K+U+N,dirRecord:_.CENTRAL_FILE_HEADER+o(G,2)+K+o(Y.length,2)+"\0\0\0\0"+o(y,4)+o(u,4)+U+N+Y}}var n=m("../utils"),h=m("../stream/GenericWorker"),v=m("../utf8"),k=m("../crc32"),_=m("../signature");function g(i,c,r,u){h.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=c,this.zipPlatform=r,this.encodeFileName=u,this.streamFiles=i,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}n.inherits(g,h),g.prototype.push=function(i){var c=i.meta.percent||0,r=this.entriesCount,u=this._sources.length;this.accumulate?this.contentBuffer.push(i):(this.bytesWritten+=i.data.length,h.prototype.push.call(this,{data:i.data,meta:{currentFile:this.currentFile,percent:r?(c+100*(r-u-1))/r:100}}))},g.prototype.openedSource=function(i){this.currentSourceOffset=this.bytesWritten,this.currentFile=i.file.name;var c=this.streamFiles&&!i.file.dir;if(c){var r=l(i,c,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(i){this.accumulate=!1;var c=this.streamFiles&&!i.file.dir,r=l(i,c,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),c)this.push({data:(function(u){return _.DATA_DESCRIPTOR+o(u.crc32,4)+o(u.compressedSize,4)+o(u.uncompressedSize,4)})(i),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var i=this.bytesWritten,c=0;c<this.dirRecords.length;c++)this.push({data:this.dirRecords[c],meta:{percent:100}});var r=this.bytesWritten-i,u=(function(a,d,w,z,S){var R=n.transformTo("string",S(z));return _.CENTRAL_DIRECTORY_END+"\0\0\0\0"+o(a,2)+o(a,2)+o(d,4)+o(w,4)+o(R.length,2)+R})(this.dirRecords.length,r,i,this.zipComment,this.encodeFileName);this.push({data:u,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(i){this._sources.push(i);var c=this;return i.on("data",function(r){c.processChunk(r)}),i.on("end",function(){c.closedSource(c.previous.streamInfo),c._sources.length?c.prepareNextSource():c.end()}),i.on("error",function(r){c.error(r)}),this},g.prototype.resume=function(){return!!h.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(i){var c=this._sources;if(!h.prototype.error.call(this,i))return!1;for(var r=0;r<c.length;r++)try{c[r].error(i)}catch{}return!0},g.prototype.lock=function(){h.prototype.lock.call(this);for(var i=this._sources,c=0;c<i.length;c++)i[c].lock()},D.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(m,D,b){var o=m("../compressions"),l=m("./ZipFileWorker");b.generateWorker=function(n,h,v){var k=new l(h.streamFiles,v,h.platform,h.encodeFileName),_=0;try{n.forEach(function(g,i){_++;var c=(function(d,w){var z=d||w,S=o[z];if(!S)throw new Error(z+" is not a valid compression method !");return S})(i.options.compression,h.compression),r=i.options.compressionOptions||h.compressionOptions||{},u=i.dir,a=i.date;i._compressWorker(c,r).withStreamInfo("file",{name:g,dir:u,date:a,comment:i.comment||"",unixPermissions:i.unixPermissions,dosPermissions:i.dosPermissions}).pipe(k)}),k.entriesCount=_}catch(g){k.error(g)}return k}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(m,D,b){function o(){if(!(this instanceof o))return new o;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var l=new o;for(var n in this)typeof this[n]!="function"&&(l[n]=this[n]);return l}}(o.prototype=m("./object")).loadAsync=m("./load"),o.support=m("./support"),o.defaults=m("./defaults"),o.version="3.10.1",o.loadAsync=function(l,n){return new o().loadAsync(l,n)},o.external=m("./external"),D.exports=o},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(m,D,b){var o=m("./utils"),l=m("./external"),n=m("./utf8"),h=m("./zipEntries"),v=m("./stream/Crc32Probe"),k=m("./nodejsUtils");function _(g){return new l.Promise(function(i,c){var r=g.decompressed.getContentWorker().pipe(new v);r.on("error",function(u){c(u)}).on("end",function(){r.streamInfo.crc32!==g.decompressed.crc32?c(new Error("Corrupted zip : CRC32 mismatch")):i()}).resume()})}D.exports=function(g,i){var c=this;return i=o.extend(i||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:n.utf8decode}),k.isNode&&k.isStream(g)?l.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):o.prepareContent("the loaded zip file",g,!0,i.optimizedBinaryString,i.base64).then(function(r){var u=new h(i);return u.load(r),u}).then(function(r){var u=[l.Promise.resolve(r)],a=r.files;if(i.checkCRC32)for(var d=0;d<a.length;d++)u.push(_(a[d]));return l.Promise.all(u)}).then(function(r){for(var u=r.shift(),a=u.files,d=0;d<a.length;d++){var w=a[d],z=w.fileNameStr,S=o.resolve(w.fileNameStr);c.file(S,w.decompressed,{binary:!0,optimizedBinaryString:!0,date:w.date,dir:w.dir,comment:w.fileCommentStr.length?w.fileCommentStr:null,unixPermissions:w.unixPermissions,dosPermissions:w.dosPermissions,createFolders:i.createFolders}),w.dir||(c.file(S).unsafeOriginalName=z)}return u.zipComment.length&&(c.comment=u.zipComment),c})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(m,D,b){var o=m("../utils"),l=m("../stream/GenericWorker");function n(h,v){l.call(this,"Nodejs stream input adapter for "+h),this._upstreamEnded=!1,this._bindStream(v)}o.inherits(n,l),n.prototype._bindStream=function(h){var v=this;(this._stream=h).pause(),h.on("data",function(k){v.push({data:k,meta:{percent:0}})}).on("error",function(k){v.isPaused?this.generatedError=k:v.error(k)}).on("end",function(){v.isPaused?v._upstreamEnded=!0:v.end()})},n.prototype.pause=function(){return!!l.prototype.pause.call(this)&&(this._stream.pause(),!0)},n.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},D.exports=n},{"../stream/GenericWorker":28,"../utils":32}],13:[function(m,D,b){var o=m("readable-stream").Readable;function l(n,h,v){o.call(this,h),this._helper=n;var k=this;n.on("data",function(_,g){k.push(_)||k._helper.pause(),v&&v(g)}).on("error",function(_){k.emit("error",_)}).on("end",function(){k.push(null)})}m("../utils").inherits(l,o),l.prototype._read=function(){this._helper.resume()},D.exports=l},{"../utils":32,"readable-stream":16}],14:[function(m,D,b){D.exports={isNode:typeof Buffer<"u",newBufferFrom:function(o,l){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(o,l);if(typeof o=="number")throw new Error('The "data" argument must not be a number');return new Buffer(o,l)},allocBuffer:function(o){if(Buffer.alloc)return Buffer.alloc(o);var l=new Buffer(o);return l.fill(0),l},isBuffer:function(o){return Buffer.isBuffer(o)},isStream:function(o){return o&&typeof o.on=="function"&&typeof o.pause=="function"&&typeof o.resume=="function"}}},{}],15:[function(m,D,b){function o(S,R,O){var U,I=n.getTypeOf(R),W=n.extend(O||{},k);W.date=W.date||new Date,W.compression!==null&&(W.compression=W.compression.toUpperCase()),typeof W.unixPermissions=="string"&&(W.unixPermissions=parseInt(W.unixPermissions,8)),W.unixPermissions&&16384&W.unixPermissions&&(W.dir=!0),W.dosPermissions&&16&W.dosPermissions&&(W.dir=!0),W.dir&&(S=a(S)),W.createFolders&&(U=u(S))&&d.call(this,U,!0);var Y=I==="string"&&W.binary===!1&&W.base64===!1;O&&O.binary!==void 0||(W.binary=!Y),(R instanceof _&&R.uncompressedSize===0||W.dir||!R||R.length===0)&&(W.base64=!1,W.binary=!0,R="",W.compression="STORE",I="string");var p=null;p=R instanceof _||R instanceof h?R:c.isNode&&c.isStream(R)?new r(S,R):n.prepareContent(S,R,W.binary,W.optimizedBinaryString,W.base64);var T=new g(S,p,W);this.files[S]=T}var l=m("./utf8"),n=m("./utils"),h=m("./stream/GenericWorker"),v=m("./stream/StreamHelper"),k=m("./defaults"),_=m("./compressedObject"),g=m("./zipObject"),i=m("./generate"),c=m("./nodejsUtils"),r=m("./nodejs/NodejsStreamInputAdapter"),u=function(S){S.slice(-1)==="/"&&(S=S.substring(0,S.length-1));var R=S.lastIndexOf("/");return 0<R?S.substring(0,R):""},a=function(S){return S.slice(-1)!=="/"&&(S+="/"),S},d=function(S,R){return R=R!==void 0?R:k.createFolders,S=a(S),this.files[S]||o.call(this,S,null,{dir:!0,createFolders:R}),this.files[S]};function w(S){return Object.prototype.toString.call(S)==="[object RegExp]"}var z={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(S){var R,O,U;for(R in this.files)U=this.files[R],(O=R.slice(this.root.length,R.length))&&R.slice(0,this.root.length)===this.root&&S(O,U)},filter:function(S){var R=[];return this.forEach(function(O,U){S(O,U)&&R.push(U)}),R},file:function(S,R,O){if(arguments.length!==1)return S=this.root+S,o.call(this,S,R,O),this;if(w(S)){var U=S;return this.filter(function(W,Y){return!Y.dir&&U.test(W)})}var I=this.files[this.root+S];return I&&!I.dir?I:null},folder:function(S){if(!S)return this;if(w(S))return this.filter(function(I,W){return W.dir&&S.test(I)});var R=this.root+S,O=d.call(this,R),U=this.clone();return U.root=O.name,U},remove:function(S){S=this.root+S;var R=this.files[S];if(R||(S.slice(-1)!=="/"&&(S+="/"),R=this.files[S]),R&&!R.dir)delete this.files[S];else for(var O=this.filter(function(I,W){return W.name.slice(0,S.length)===S}),U=0;U<O.length;U++)delete this.files[O[U].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(S){var R,O={};try{if((O=n.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:l.utf8encode})).type=O.type.toLowerCase(),O.compression=O.compression.toUpperCase(),O.type==="binarystring"&&(O.type="string"),!O.type)throw new Error("No output type specified.");n.checkSupport(O.type),O.platform!=="darwin"&&O.platform!=="freebsd"&&O.platform!=="linux"&&O.platform!=="sunos"||(O.platform="UNIX"),O.platform==="win32"&&(O.platform="DOS");var U=O.comment||this.comment||"";R=i.generateWorker(this,O,U)}catch(I){(R=new h("error")).error(I)}return new v(R,O.type||"string",O.mimeType)},generateAsync:function(S,R){return this.generateInternalStream(S).accumulate(R)},generateNodeStream:function(S,R){return(S=S||{}).type||(S.type="nodebuffer"),this.generateInternalStream(S).toNodejsStream(R)}};D.exports=z},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(m,D,b){D.exports=m("stream")},{stream:void 0}],17:[function(m,D,b){var o=m("./DataReader");function l(n){o.call(this,n);for(var h=0;h<this.data.length;h++)n[h]=255&n[h]}m("../utils").inherits(l,o),l.prototype.byteAt=function(n){return this.data[this.zero+n]},l.prototype.lastIndexOfSignature=function(n){for(var h=n.charCodeAt(0),v=n.charCodeAt(1),k=n.charCodeAt(2),_=n.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===h&&this.data[g+1]===v&&this.data[g+2]===k&&this.data[g+3]===_)return g-this.zero;return-1},l.prototype.readAndCheckSignature=function(n){var h=n.charCodeAt(0),v=n.charCodeAt(1),k=n.charCodeAt(2),_=n.charCodeAt(3),g=this.readData(4);return h===g[0]&&v===g[1]&&k===g[2]&&_===g[3]},l.prototype.readData=function(n){if(this.checkOffset(n),n===0)return[];var h=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,h},D.exports=l},{"../utils":32,"./DataReader":18}],18:[function(m,D,b){var o=m("../utils");function l(n){this.data=n,this.length=n.length,this.index=0,this.zero=0}l.prototype={checkOffset:function(n){this.checkIndex(this.index+n)},checkIndex:function(n){if(this.length<this.zero+n||n<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+n+"). Corrupted zip ?")},setIndex:function(n){this.checkIndex(n),this.index=n},skip:function(n){this.setIndex(this.index+n)},byteAt:function(){},readInt:function(n){var h,v=0;for(this.checkOffset(n),h=this.index+n-1;h>=this.index;h--)v=(v<<8)+this.byteAt(h);return this.index+=n,v},readString:function(n){return o.transformTo("string",this.readData(n))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var n=this.readInt(4);return new Date(Date.UTC(1980+(n>>25&127),(n>>21&15)-1,n>>16&31,n>>11&31,n>>5&63,(31&n)<<1))}},D.exports=l},{"../utils":32}],19:[function(m,D,b){var o=m("./Uint8ArrayReader");function l(n){o.call(this,n)}m("../utils").inherits(l,o),l.prototype.readData=function(n){this.checkOffset(n);var h=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,h},D.exports=l},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(m,D,b){var o=m("./DataReader");function l(n){o.call(this,n)}m("../utils").inherits(l,o),l.prototype.byteAt=function(n){return this.data.charCodeAt(this.zero+n)},l.prototype.lastIndexOfSignature=function(n){return this.data.lastIndexOf(n)-this.zero},l.prototype.readAndCheckSignature=function(n){return n===this.readData(4)},l.prototype.readData=function(n){this.checkOffset(n);var h=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,h},D.exports=l},{"../utils":32,"./DataReader":18}],21:[function(m,D,b){var o=m("./ArrayReader");function l(n){o.call(this,n)}m("../utils").inherits(l,o),l.prototype.readData=function(n){if(this.checkOffset(n),n===0)return new Uint8Array(0);var h=this.data.subarray(this.zero+this.index,this.zero+this.index+n);return this.index+=n,h},D.exports=l},{"../utils":32,"./ArrayReader":17}],22:[function(m,D,b){var o=m("../utils"),l=m("../support"),n=m("./ArrayReader"),h=m("./StringReader"),v=m("./NodeBufferReader"),k=m("./Uint8ArrayReader");D.exports=function(_){var g=o.getTypeOf(_);return o.checkSupport(g),g!=="string"||l.uint8array?g==="nodebuffer"?new v(_):l.uint8array?new k(o.transformTo("uint8array",_)):new n(o.transformTo("array",_)):new h(_)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(m,D,b){b.LOCAL_FILE_HEADER="PK",b.CENTRAL_FILE_HEADER="PK",b.CENTRAL_DIRECTORY_END="PK",b.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",b.ZIP64_CENTRAL_DIRECTORY_END="PK",b.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(m,D,b){var o=m("./GenericWorker"),l=m("../utils");function n(h){o.call(this,"ConvertWorker to "+h),this.destType=h}l.inherits(n,o),n.prototype.processChunk=function(h){this.push({data:l.transformTo(this.destType,h.data),meta:h.meta})},D.exports=n},{"../utils":32,"./GenericWorker":28}],25:[function(m,D,b){var o=m("./GenericWorker"),l=m("../crc32");function n(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}m("../utils").inherits(n,o),n.prototype.processChunk=function(h){this.streamInfo.crc32=l(h.data,this.streamInfo.crc32||0),this.push(h)},D.exports=n},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(m,D,b){var o=m("../utils"),l=m("./GenericWorker");function n(h){l.call(this,"DataLengthProbe for "+h),this.propName=h,this.withStreamInfo(h,0)}o.inherits(n,l),n.prototype.processChunk=function(h){if(h){var v=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=v+h.data.length}l.prototype.processChunk.call(this,h)},D.exports=n},{"../utils":32,"./GenericWorker":28}],27:[function(m,D,b){var o=m("../utils"),l=m("./GenericWorker");function n(h){l.call(this,"DataWorker");var v=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,h.then(function(k){v.dataIsReady=!0,v.data=k,v.max=k&&k.length||0,v.type=o.getTypeOf(k),v.isPaused||v._tickAndRepeat()},function(k){v.error(k)})}o.inherits(n,l),n.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this.data=null},n.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},n.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},n.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var h=null,v=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":h=this.data.substring(this.index,v);break;case"uint8array":h=this.data.subarray(this.index,v);break;case"array":case"nodebuffer":h=this.data.slice(this.index,v)}return this.index=v,this.push({data:h,meta:{percent:this.max?this.index/this.max*100:0}})},D.exports=n},{"../utils":32,"./GenericWorker":28}],28:[function(m,D,b){function o(l){this.name=l||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(l){this.emit("data",l)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(l){this.emit("error",l)}return!0},error:function(l){return!this.isFinished&&(this.isPaused?this.generatedError=l:(this.isFinished=!0,this.emit("error",l),this.previous&&this.previous.error(l),this.cleanUp()),!0)},on:function(l,n){return this._listeners[l].push(n),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(l,n){if(this._listeners[l])for(var h=0;h<this._listeners[l].length;h++)this._listeners[l][h].call(this,n)},pipe:function(l){return l.registerPrevious(this)},registerPrevious:function(l){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=l.streamInfo,this.mergeStreamInfo(),this.previous=l;var n=this;return l.on("data",function(h){n.processChunk(h)}),l.on("end",function(){n.end()}),l.on("error",function(h){n.error(h)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var l=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),l=!0),this.previous&&this.previous.resume(),!l},flush:function(){},processChunk:function(l){this.push(l)},withStreamInfo:function(l,n){return this.extraStreamInfo[l]=n,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var l in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,l)&&(this.streamInfo[l]=this.extraStreamInfo[l])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var l="Worker "+this.name;return this.previous?this.previous+" -> "+l:l}},D.exports=o},{}],29:[function(m,D,b){var o=m("../utils"),l=m("./ConvertWorker"),n=m("./GenericWorker"),h=m("../base64"),v=m("../support"),k=m("../external"),_=null;if(v.nodestream)try{_=m("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(c,r){return new k.Promise(function(u,a){var d=[],w=c._internalType,z=c._outputType,S=c._mimeType;c.on("data",function(R,O){d.push(R),r&&r(O)}).on("error",function(R){d=[],a(R)}).on("end",function(){try{var R=(function(O,U,I){switch(O){case"blob":return o.newBlob(o.transformTo("arraybuffer",U),I);case"base64":return h.encode(U);default:return o.transformTo(O,U)}})(z,(function(O,U){var I,W=0,Y=null,p=0;for(I=0;I<U.length;I++)p+=U[I].length;switch(O){case"string":return U.join("");case"array":return Array.prototype.concat.apply([],U);case"uint8array":for(Y=new Uint8Array(p),I=0;I<U.length;I++)Y.set(U[I],W),W+=U[I].length;return Y;case"nodebuffer":return Buffer.concat(U);default:throw new Error("concat : unsupported type '"+O+"'")}})(w,d),S);u(R)}catch(O){a(O)}d=[]}).resume()})}function i(c,r,u){var a=r;switch(r){case"blob":case"arraybuffer":a="uint8array";break;case"base64":a="string"}try{this._internalType=a,this._outputType=r,this._mimeType=u,o.checkSupport(a),this._worker=c.pipe(new l(a)),c.lock()}catch(d){this._worker=new n("error"),this._worker.error(d)}}i.prototype={accumulate:function(c){return g(this,c)},on:function(c,r){var u=this;return c==="data"?this._worker.on(c,function(a){r.call(u,a.data,a.meta)}):this._worker.on(c,function(){o.delay(r,arguments,u)}),this},resume:function(){return o.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(c){if(o.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new _(this,{objectMode:this._outputType!=="nodebuffer"},c)}},D.exports=i},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(m,D,b){if(b.base64=!0,b.array=!0,b.string=!0,b.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",b.nodebuffer=typeof Buffer<"u",b.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")b.blob=!1;else{var o=new ArrayBuffer(0);try{b.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var l=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);l.append(o),b.blob=l.getBlob("application/zip").size===0}catch{b.blob=!1}}}try{b.nodestream=!!m("readable-stream").Readable}catch{b.nodestream=!1}},{"readable-stream":16}],31:[function(m,D,b){for(var o=m("./utils"),l=m("./support"),n=m("./nodejsUtils"),h=m("./stream/GenericWorker"),v=new Array(256),k=0;k<256;k++)v[k]=252<=k?6:248<=k?5:240<=k?4:224<=k?3:192<=k?2:1;v[254]=v[254]=1;function _(){h.call(this,"utf-8 decode"),this.leftOver=null}function g(){h.call(this,"utf-8 encode")}b.utf8encode=function(i){return l.nodebuffer?n.newBufferFrom(i,"utf-8"):(function(c){var r,u,a,d,w,z=c.length,S=0;for(d=0;d<z;d++)(64512&(u=c.charCodeAt(d)))==55296&&d+1<z&&(64512&(a=c.charCodeAt(d+1)))==56320&&(u=65536+(u-55296<<10)+(a-56320),d++),S+=u<128?1:u<2048?2:u<65536?3:4;for(r=l.uint8array?new Uint8Array(S):new Array(S),d=w=0;w<S;d++)(64512&(u=c.charCodeAt(d)))==55296&&d+1<z&&(64512&(a=c.charCodeAt(d+1)))==56320&&(u=65536+(u-55296<<10)+(a-56320),d++),u<128?r[w++]=u:(u<2048?r[w++]=192|u>>>6:(u<65536?r[w++]=224|u>>>12:(r[w++]=240|u>>>18,r[w++]=128|u>>>12&63),r[w++]=128|u>>>6&63),r[w++]=128|63&u);return r})(i)},b.utf8decode=function(i){return l.nodebuffer?o.transformTo("nodebuffer",i).toString("utf-8"):(function(c){var r,u,a,d,w=c.length,z=new Array(2*w);for(r=u=0;r<w;)if((a=c[r++])<128)z[u++]=a;else if(4<(d=v[a]))z[u++]=65533,r+=d-1;else{for(a&=d===2?31:d===3?15:7;1<d&&r<w;)a=a<<6|63&c[r++],d--;1<d?z[u++]=65533:a<65536?z[u++]=a:(a-=65536,z[u++]=55296|a>>10&1023,z[u++]=56320|1023&a)}return z.length!==u&&(z.subarray?z=z.subarray(0,u):z.length=u),o.applyFromCharCode(z)})(i=o.transformTo(l.uint8array?"uint8array":"array",i))},o.inherits(_,h),_.prototype.processChunk=function(i){var c=o.transformTo(l.uint8array?"uint8array":"array",i.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var r=c;(c=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),c.set(r,this.leftOver.length)}else c=this.leftOver.concat(c);this.leftOver=null}var u=(function(d,w){var z;for((w=w||d.length)>d.length&&(w=d.length),z=w-1;0<=z&&(192&d[z])==128;)z--;return z<0||z===0?w:z+v[d[z]]>w?z:w})(c),a=c;u!==c.length&&(l.uint8array?(a=c.subarray(0,u),this.leftOver=c.subarray(u,c.length)):(a=c.slice(0,u),this.leftOver=c.slice(u,c.length))),this.push({data:b.utf8decode(a),meta:i.meta})},_.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:b.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},b.Utf8DecodeWorker=_,o.inherits(g,h),g.prototype.processChunk=function(i){this.push({data:b.utf8encode(i.data),meta:i.meta})},b.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(m,D,b){var o=m("./support"),l=m("./base64"),n=m("./nodejsUtils"),h=m("./external");function v(r){return r}function k(r,u){for(var a=0;a<r.length;++a)u[a]=255&r.charCodeAt(a);return u}m("setimmediate"),b.newBlob=function(r,u){b.checkSupport("blob");try{return new Blob([r],{type:u})}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return a.append(r),a.getBlob(u)}catch{throw new Error("Bug : can't construct the Blob.")}}};var _={stringifyByChunk:function(r,u,a){var d=[],w=0,z=r.length;if(z<=a)return String.fromCharCode.apply(null,r);for(;w<z;)u==="array"||u==="nodebuffer"?d.push(String.fromCharCode.apply(null,r.slice(w,Math.min(w+a,z)))):d.push(String.fromCharCode.apply(null,r.subarray(w,Math.min(w+a,z)))),w+=a;return d.join("")},stringifyByChar:function(r){for(var u="",a=0;a<r.length;a++)u+=String.fromCharCode(r[a]);return u},applyCanBeUsed:{uint8array:(function(){try{return o.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return o.nodebuffer&&String.fromCharCode.apply(null,n.allocBuffer(1)).length===1}catch{return!1}})()}};function g(r){var u=65536,a=b.getTypeOf(r),d=!0;if(a==="uint8array"?d=_.applyCanBeUsed.uint8array:a==="nodebuffer"&&(d=_.applyCanBeUsed.nodebuffer),d)for(;1<u;)try{return _.stringifyByChunk(r,a,u)}catch{u=Math.floor(u/2)}return _.stringifyByChar(r)}function i(r,u){for(var a=0;a<r.length;a++)u[a]=r[a];return u}b.applyFromCharCode=g;var c={};c.string={string:v,array:function(r){return k(r,new Array(r.length))},arraybuffer:function(r){return c.string.uint8array(r).buffer},uint8array:function(r){return k(r,new Uint8Array(r.length))},nodebuffer:function(r){return k(r,n.allocBuffer(r.length))}},c.array={string:g,array:v,arraybuffer:function(r){return new Uint8Array(r).buffer},uint8array:function(r){return new Uint8Array(r)},nodebuffer:function(r){return n.newBufferFrom(r)}},c.arraybuffer={string:function(r){return g(new Uint8Array(r))},array:function(r){return i(new Uint8Array(r),new Array(r.byteLength))},arraybuffer:v,uint8array:function(r){return new Uint8Array(r)},nodebuffer:function(r){return n.newBufferFrom(new Uint8Array(r))}},c.uint8array={string:g,array:function(r){return i(r,new Array(r.length))},arraybuffer:function(r){return r.buffer},uint8array:v,nodebuffer:function(r){return n.newBufferFrom(r)}},c.nodebuffer={string:g,array:function(r){return i(r,new Array(r.length))},arraybuffer:function(r){return c.nodebuffer.uint8array(r).buffer},uint8array:function(r){return i(r,new Uint8Array(r.length))},nodebuffer:v},b.transformTo=function(r,u){if(u=u||"",!r)return u;b.checkSupport(r);var a=b.getTypeOf(u);return c[a][r](u)},b.resolve=function(r){for(var u=r.split("/"),a=[],d=0;d<u.length;d++){var w=u[d];w==="."||w===""&&d!==0&&d!==u.length-1||(w===".."?a.pop():a.push(w))}return a.join("/")},b.getTypeOf=function(r){return typeof r=="string"?"string":Object.prototype.toString.call(r)==="[object Array]"?"array":o.nodebuffer&&n.isBuffer(r)?"nodebuffer":o.uint8array&&r instanceof Uint8Array?"uint8array":o.arraybuffer&&r instanceof ArrayBuffer?"arraybuffer":void 0},b.checkSupport=function(r){if(!o[r.toLowerCase()])throw new Error(r+" is not supported by this platform")},b.MAX_VALUE_16BITS=65535,b.MAX_VALUE_32BITS=-1,b.pretty=function(r){var u,a,d="";for(a=0;a<(r||"").length;a++)d+="\\x"+((u=r.charCodeAt(a))<16?"0":"")+u.toString(16).toUpperCase();return d},b.delay=function(r,u,a){setImmediate(function(){r.apply(a||null,u||[])})},b.inherits=function(r,u){function a(){}a.prototype=u.prototype,r.prototype=new a},b.extend=function(){var r,u,a={};for(r=0;r<arguments.length;r++)for(u in arguments[r])Object.prototype.hasOwnProperty.call(arguments[r],u)&&a[u]===void 0&&(a[u]=arguments[r][u]);return a},b.prepareContent=function(r,u,a,d,w){return h.Promise.resolve(u).then(function(z){return o.blob&&(z instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(z))!==-1)&&typeof FileReader<"u"?new h.Promise(function(S,R){var O=new FileReader;O.onload=function(U){S(U.target.result)},O.onerror=function(U){R(U.target.error)},O.readAsArrayBuffer(z)}):z}).then(function(z){var S=b.getTypeOf(z);return S?(S==="arraybuffer"?z=b.transformTo("uint8array",z):S==="string"&&(w?z=l.decode(z):a&&d!==!0&&(z=(function(R){return k(R,o.uint8array?new Uint8Array(R.length):new Array(R.length))})(z))),z):h.Promise.reject(new Error("Can't read the data of '"+r+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(m,D,b){var o=m("./reader/readerFor"),l=m("./utils"),n=m("./signature"),h=m("./zipEntry"),v=m("./support");function k(_){this.files=[],this.loadOptions=_}k.prototype={checkSignature:function(_){if(!this.reader.readAndCheckSignature(_)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+l.pretty(g)+", expected "+l.pretty(_)+")")}},isSignature:function(_,g){var i=this.reader.index;this.reader.setIndex(_);var c=this.reader.readString(4)===g;return this.reader.setIndex(i),c},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var _=this.reader.readData(this.zipCommentLength),g=v.uint8array?"uint8array":"array",i=l.transformTo(g,_);this.zipComment=this.loadOptions.decodeFileName(i)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var _,g,i,c=this.zip64EndOfCentralSize-44;0<c;)_=this.reader.readInt(2),g=this.reader.readInt(4),i=this.reader.readData(g),this.zip64ExtensibleData[_]={id:_,length:g,value:i}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var _,g;for(_=0;_<this.files.length;_++)g=this.files[_],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(n.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var _;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(n.CENTRAL_FILE_HEADER);)(_=new h({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(_);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var _=this.reader.lastIndexOfSignature(n.CENTRAL_DIRECTORY_END);if(_<0)throw this.isSignature(0,n.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(_);var g=_;if(this.checkSignature(n.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===l.MAX_VALUE_16BITS||this.diskWithCentralDirStart===l.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===l.MAX_VALUE_16BITS||this.centralDirRecords===l.MAX_VALUE_16BITS||this.centralDirSize===l.MAX_VALUE_32BITS||this.centralDirOffset===l.MAX_VALUE_32BITS){if(this.zip64=!0,(_=this.reader.lastIndexOfSignature(n.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(_),this.checkSignature(n.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,n.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(n.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(n.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var i=this.centralDirOffset+this.centralDirSize;this.zip64&&(i+=20,i+=12+this.zip64EndOfCentralSize);var c=g-i;if(0<c)this.isSignature(g,n.CENTRAL_FILE_HEADER)||(this.reader.zero=c);else if(c<0)throw new Error("Corrupted zip: missing "+Math.abs(c)+" bytes.")},prepareReader:function(_){this.reader=o(_)},load:function(_){this.prepareReader(_),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},D.exports=k},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(m,D,b){var o=m("./reader/readerFor"),l=m("./utils"),n=m("./compressedObject"),h=m("./crc32"),v=m("./utf8"),k=m("./compressions"),_=m("./support");function g(i,c){this.options=i,this.loadOptions=c}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(i){var c,r;if(i.skip(22),this.fileNameLength=i.readInt(2),r=i.readInt(2),this.fileName=i.readData(this.fileNameLength),i.skip(r),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((c=(function(u){for(var a in k)if(Object.prototype.hasOwnProperty.call(k,a)&&k[a].magic===u)return k[a];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+l.pretty(this.compressionMethod)+" unknown (inner file : "+l.transformTo("string",this.fileName)+")");this.decompressed=new n(this.compressedSize,this.uncompressedSize,this.crc32,c,i.readData(this.compressedSize))},readCentralPart:function(i){this.versionMadeBy=i.readInt(2),i.skip(2),this.bitFlag=i.readInt(2),this.compressionMethod=i.readString(2),this.date=i.readDate(),this.crc32=i.readInt(4),this.compressedSize=i.readInt(4),this.uncompressedSize=i.readInt(4);var c=i.readInt(2);if(this.extraFieldsLength=i.readInt(2),this.fileCommentLength=i.readInt(2),this.diskNumberStart=i.readInt(2),this.internalFileAttributes=i.readInt(2),this.externalFileAttributes=i.readInt(4),this.localHeaderOffset=i.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");i.skip(c),this.readExtraFields(i),this.parseZIP64ExtraField(i),this.fileComment=i.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var i=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),i==0&&(this.dosPermissions=63&this.externalFileAttributes),i==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var i=o(this.extraFields[1].value);this.uncompressedSize===l.MAX_VALUE_32BITS&&(this.uncompressedSize=i.readInt(8)),this.compressedSize===l.MAX_VALUE_32BITS&&(this.compressedSize=i.readInt(8)),this.localHeaderOffset===l.MAX_VALUE_32BITS&&(this.localHeaderOffset=i.readInt(8)),this.diskNumberStart===l.MAX_VALUE_32BITS&&(this.diskNumberStart=i.readInt(4))}},readExtraFields:function(i){var c,r,u,a=i.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});i.index+4<a;)c=i.readInt(2),r=i.readInt(2),u=i.readData(r),this.extraFields[c]={id:c,length:r,value:u};i.setIndex(a)},handleUTF8:function(){var i=_.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=v.utf8decode(this.fileName),this.fileCommentStr=v.utf8decode(this.fileComment);else{var c=this.findExtraFieldUnicodePath();if(c!==null)this.fileNameStr=c;else{var r=l.transformTo(i,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(r)}var u=this.findExtraFieldUnicodeComment();if(u!==null)this.fileCommentStr=u;else{var a=l.transformTo(i,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(a)}}},findExtraFieldUnicodePath:function(){var i=this.extraFields[28789];if(i){var c=o(i.value);return c.readInt(1)!==1||h(this.fileName)!==c.readInt(4)?null:v.utf8decode(c.readData(i.length-5))}return null},findExtraFieldUnicodeComment:function(){var i=this.extraFields[25461];if(i){var c=o(i.value);return c.readInt(1)!==1||h(this.fileComment)!==c.readInt(4)?null:v.utf8decode(c.readData(i.length-5))}return null}},D.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(m,D,b){function o(c,r,u){this.name=c,this.dir=u.dir,this.date=u.date,this.comment=u.comment,this.unixPermissions=u.unixPermissions,this.dosPermissions=u.dosPermissions,this._data=r,this._dataBinary=u.binary,this.options={compression:u.compression,compressionOptions:u.compressionOptions}}var l=m("./stream/StreamHelper"),n=m("./stream/DataWorker"),h=m("./utf8"),v=m("./compressedObject"),k=m("./stream/GenericWorker");o.prototype={internalStream:function(c){var r=null,u="string";try{if(!c)throw new Error("No output type specified.");var a=(u=c.toLowerCase())==="string"||u==="text";u!=="binarystring"&&u!=="text"||(u="string"),r=this._decompressWorker();var d=!this._dataBinary;d&&!a&&(r=r.pipe(new h.Utf8EncodeWorker)),!d&&a&&(r=r.pipe(new h.Utf8DecodeWorker))}catch(w){(r=new k("error")).error(w)}return new l(r,u,"")},async:function(c,r){return this.internalStream(c).accumulate(r)},nodeStream:function(c,r){return this.internalStream(c||"nodebuffer").toNodejsStream(r)},_compressWorker:function(c,r){if(this._data instanceof v&&this._data.compression.magic===c.magic)return this._data.getCompressedWorker();var u=this._decompressWorker();return this._dataBinary||(u=u.pipe(new h.Utf8EncodeWorker)),v.createWorkerFrom(u,c,r)},_decompressWorker:function(){return this._data instanceof v?this._data.getContentWorker():this._data instanceof k?this._data:new n(this._data)}};for(var _=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},i=0;i<_.length;i++)o.prototype[_[i]]=g;D.exports=o},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(m,D,b){(function(o){var l,n,h=o.MutationObserver||o.WebKitMutationObserver;if(h){var v=0,k=new h(c),_=o.document.createTextNode("");k.observe(_,{characterData:!0}),l=function(){_.data=v=++v%2}}else if(o.setImmediate||o.MessageChannel===void 0)l="document"in o&&"onreadystatechange"in o.document.createElement("script")?function(){var r=o.document.createElement("script");r.onreadystatechange=function(){c(),r.onreadystatechange=null,r.parentNode.removeChild(r),r=null},o.document.documentElement.appendChild(r)}:function(){setTimeout(c,0)};else{var g=new o.MessageChannel;g.port1.onmessage=c,l=function(){g.port2.postMessage(0)}}var i=[];function c(){var r,u;n=!0;for(var a=i.length;a;){for(u=i,i=[],r=-1;++r<a;)u[r]();a=i.length}n=!1}D.exports=function(r){i.push(r)!==1||n||l()}}).call(this,typeof zt<"u"?zt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(m,D,b){var o=m("immediate");function l(){}var n={},h=["REJECTED"],v=["FULFILLED"],k=["PENDING"];function _(a){if(typeof a!="function")throw new TypeError("resolver must be a function");this.state=k,this.queue=[],this.outcome=void 0,a!==l&&r(this,a)}function g(a,d,w){this.promise=a,typeof d=="function"&&(this.onFulfilled=d,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function i(a,d,w){o(function(){var z;try{z=d(w)}catch(S){return n.reject(a,S)}z===a?n.reject(a,new TypeError("Cannot resolve promise with itself")):n.resolve(a,z)})}function c(a){var d=a&&a.then;if(a&&(typeof a=="object"||typeof a=="function")&&typeof d=="function")return function(){d.apply(a,arguments)}}function r(a,d){var w=!1;function z(O){w||(w=!0,n.reject(a,O))}function S(O){w||(w=!0,n.resolve(a,O))}var R=u(function(){d(S,z)});R.status==="error"&&z(R.value)}function u(a,d){var w={};try{w.value=a(d),w.status="success"}catch(z){w.status="error",w.value=z}return w}(D.exports=_).prototype.finally=function(a){if(typeof a!="function")return this;var d=this.constructor;return this.then(function(w){return d.resolve(a()).then(function(){return w})},function(w){return d.resolve(a()).then(function(){throw w})})},_.prototype.catch=function(a){return this.then(null,a)},_.prototype.then=function(a,d){if(typeof a!="function"&&this.state===v||typeof d!="function"&&this.state===h)return this;var w=new this.constructor(l);return this.state!==k?i(w,this.state===v?a:d,this.outcome):this.queue.push(new g(w,a,d)),w},g.prototype.callFulfilled=function(a){n.resolve(this.promise,a)},g.prototype.otherCallFulfilled=function(a){i(this.promise,this.onFulfilled,a)},g.prototype.callRejected=function(a){n.reject(this.promise,a)},g.prototype.otherCallRejected=function(a){i(this.promise,this.onRejected,a)},n.resolve=function(a,d){var w=u(c,d);if(w.status==="error")return n.reject(a,w.value);var z=w.value;if(z)r(a,z);else{a.state=v,a.outcome=d;for(var S=-1,R=a.queue.length;++S<R;)a.queue[S].callFulfilled(d)}return a},n.reject=function(a,d){a.state=h,a.outcome=d;for(var w=-1,z=a.queue.length;++w<z;)a.queue[w].callRejected(d);return a},_.resolve=function(a){return a instanceof this?a:n.resolve(new this(l),a)},_.reject=function(a){var d=new this(l);return n.reject(d,a)},_.all=function(a){var d=this;if(Object.prototype.toString.call(a)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=a.length,z=!1;if(!w)return this.resolve([]);for(var S=new Array(w),R=0,O=-1,U=new this(l);++O<w;)I(a[O],O);return U;function I(W,Y){d.resolve(W).then(function(p){S[Y]=p,++R!==w||z||(z=!0,n.resolve(U,S))},function(p){z||(z=!0,n.reject(U,p))})}},_.race=function(a){var d=this;if(Object.prototype.toString.call(a)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=a.length,z=!1;if(!w)return this.resolve([]);for(var S=-1,R=new this(l);++S<w;)O=a[S],d.resolve(O).then(function(U){z||(z=!0,n.resolve(R,U))},function(U){z||(z=!0,n.reject(R,U))});var O;return R}},{immediate:36}],38:[function(m,D,b){var o={};(0,m("./lib/utils/common").assign)(o,m("./lib/deflate"),m("./lib/inflate"),m("./lib/zlib/constants")),D.exports=o},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(m,D,b){var o=m("./zlib/deflate"),l=m("./utils/common"),n=m("./utils/strings"),h=m("./zlib/messages"),v=m("./zlib/zstream"),k=Object.prototype.toString,_=0,g=-1,i=0,c=8;function r(a){if(!(this instanceof r))return new r(a);this.options=l.assign({level:g,method:c,chunkSize:16384,windowBits:15,memLevel:8,strategy:i,to:""},a||{});var d=this.options;d.raw&&0<d.windowBits?d.windowBits=-d.windowBits:d.gzip&&0<d.windowBits&&d.windowBits<16&&(d.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new v,this.strm.avail_out=0;var w=o.deflateInit2(this.strm,d.level,d.method,d.windowBits,d.memLevel,d.strategy);if(w!==_)throw new Error(h[w]);if(d.header&&o.deflateSetHeader(this.strm,d.header),d.dictionary){var z;if(z=typeof d.dictionary=="string"?n.string2buf(d.dictionary):k.call(d.dictionary)==="[object ArrayBuffer]"?new Uint8Array(d.dictionary):d.dictionary,(w=o.deflateSetDictionary(this.strm,z))!==_)throw new Error(h[w]);this._dict_set=!0}}function u(a,d){var w=new r(d);if(w.push(a,!0),w.err)throw w.msg||h[w.err];return w.result}r.prototype.push=function(a,d){var w,z,S=this.strm,R=this.options.chunkSize;if(this.ended)return!1;z=d===~~d?d:d===!0?4:0,typeof a=="string"?S.input=n.string2buf(a):k.call(a)==="[object ArrayBuffer]"?S.input=new Uint8Array(a):S.input=a,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new l.Buf8(R),S.next_out=0,S.avail_out=R),(w=o.deflate(S,z))!==1&&w!==_)return this.onEnd(w),!(this.ended=!0);S.avail_out!==0&&(S.avail_in!==0||z!==4&&z!==2)||(this.options.to==="string"?this.onData(n.buf2binstring(l.shrinkBuf(S.output,S.next_out))):this.onData(l.shrinkBuf(S.output,S.next_out)))}while((0<S.avail_in||S.avail_out===0)&&w!==1);return z===4?(w=o.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===_):z!==2||(this.onEnd(_),!(S.avail_out=0))},r.prototype.onData=function(a){this.chunks.push(a)},r.prototype.onEnd=function(a){a===_&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=l.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},b.Deflate=r,b.deflate=u,b.deflateRaw=function(a,d){return(d=d||{}).raw=!0,u(a,d)},b.gzip=function(a,d){return(d=d||{}).gzip=!0,u(a,d)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(m,D,b){var o=m("./zlib/inflate"),l=m("./utils/common"),n=m("./utils/strings"),h=m("./zlib/constants"),v=m("./zlib/messages"),k=m("./zlib/zstream"),_=m("./zlib/gzheader"),g=Object.prototype.toString;function i(r){if(!(this instanceof i))return new i(r);this.options=l.assign({chunkSize:16384,windowBits:0,to:""},r||{});var u=this.options;u.raw&&0<=u.windowBits&&u.windowBits<16&&(u.windowBits=-u.windowBits,u.windowBits===0&&(u.windowBits=-15)),!(0<=u.windowBits&&u.windowBits<16)||r&&r.windowBits||(u.windowBits+=32),15<u.windowBits&&u.windowBits<48&&(15&u.windowBits)==0&&(u.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var a=o.inflateInit2(this.strm,u.windowBits);if(a!==h.Z_OK)throw new Error(v[a]);this.header=new _,o.inflateGetHeader(this.strm,this.header)}function c(r,u){var a=new i(u);if(a.push(r,!0),a.err)throw a.msg||v[a.err];return a.result}i.prototype.push=function(r,u){var a,d,w,z,S,R,O=this.strm,U=this.options.chunkSize,I=this.options.dictionary,W=!1;if(this.ended)return!1;d=u===~~u?u:u===!0?h.Z_FINISH:h.Z_NO_FLUSH,typeof r=="string"?O.input=n.binstring2buf(r):g.call(r)==="[object ArrayBuffer]"?O.input=new Uint8Array(r):O.input=r,O.next_in=0,O.avail_in=O.input.length;do{if(O.avail_out===0&&(O.output=new l.Buf8(U),O.next_out=0,O.avail_out=U),(a=o.inflate(O,h.Z_NO_FLUSH))===h.Z_NEED_DICT&&I&&(R=typeof I=="string"?n.string2buf(I):g.call(I)==="[object ArrayBuffer]"?new Uint8Array(I):I,a=o.inflateSetDictionary(this.strm,R)),a===h.Z_BUF_ERROR&&W===!0&&(a=h.Z_OK,W=!1),a!==h.Z_STREAM_END&&a!==h.Z_OK)return this.onEnd(a),!(this.ended=!0);O.next_out&&(O.avail_out!==0&&a!==h.Z_STREAM_END&&(O.avail_in!==0||d!==h.Z_FINISH&&d!==h.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=n.utf8border(O.output,O.next_out),z=O.next_out-w,S=n.buf2string(O.output,w),O.next_out=z,O.avail_out=U-z,z&&l.arraySet(O.output,O.output,w,z,0),this.onData(S)):this.onData(l.shrinkBuf(O.output,O.next_out)))),O.avail_in===0&&O.avail_out===0&&(W=!0)}while((0<O.avail_in||O.avail_out===0)&&a!==h.Z_STREAM_END);return a===h.Z_STREAM_END&&(d=h.Z_FINISH),d===h.Z_FINISH?(a=o.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===h.Z_OK):d!==h.Z_SYNC_FLUSH||(this.onEnd(h.Z_OK),!(O.avail_out=0))},i.prototype.onData=function(r){this.chunks.push(r)},i.prototype.onEnd=function(r){r===h.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=l.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg},b.Inflate=i,b.inflate=c,b.inflateRaw=function(r,u){return(u=u||{}).raw=!0,c(r,u)},b.ungzip=c},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(m,D,b){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";b.assign=function(h){for(var v=Array.prototype.slice.call(arguments,1);v.length;){var k=v.shift();if(k){if(typeof k!="object")throw new TypeError(k+"must be non-object");for(var _ in k)k.hasOwnProperty(_)&&(h[_]=k[_])}}return h},b.shrinkBuf=function(h,v){return h.length===v?h:h.subarray?h.subarray(0,v):(h.length=v,h)};var l={arraySet:function(h,v,k,_,g){if(v.subarray&&h.subarray)h.set(v.subarray(k,k+_),g);else for(var i=0;i<_;i++)h[g+i]=v[k+i]},flattenChunks:function(h){var v,k,_,g,i,c;for(v=_=0,k=h.length;v<k;v++)_+=h[v].length;for(c=new Uint8Array(_),v=g=0,k=h.length;v<k;v++)i=h[v],c.set(i,g),g+=i.length;return c}},n={arraySet:function(h,v,k,_,g){for(var i=0;i<_;i++)h[g+i]=v[k+i]},flattenChunks:function(h){return[].concat.apply([],h)}};b.setTyped=function(h){h?(b.Buf8=Uint8Array,b.Buf16=Uint16Array,b.Buf32=Int32Array,b.assign(b,l)):(b.Buf8=Array,b.Buf16=Array,b.Buf32=Array,b.assign(b,n))},b.setTyped(o)},{}],42:[function(m,D,b){var o=m("./common"),l=!0,n=!0;try{String.fromCharCode.apply(null,[0])}catch{l=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{n=!1}for(var h=new o.Buf8(256),v=0;v<256;v++)h[v]=252<=v?6:248<=v?5:240<=v?4:224<=v?3:192<=v?2:1;function k(_,g){if(g<65537&&(_.subarray&&n||!_.subarray&&l))return String.fromCharCode.apply(null,o.shrinkBuf(_,g));for(var i="",c=0;c<g;c++)i+=String.fromCharCode(_[c]);return i}h[254]=h[254]=1,b.string2buf=function(_){var g,i,c,r,u,a=_.length,d=0;for(r=0;r<a;r++)(64512&(i=_.charCodeAt(r)))==55296&&r+1<a&&(64512&(c=_.charCodeAt(r+1)))==56320&&(i=65536+(i-55296<<10)+(c-56320),r++),d+=i<128?1:i<2048?2:i<65536?3:4;for(g=new o.Buf8(d),r=u=0;u<d;r++)(64512&(i=_.charCodeAt(r)))==55296&&r+1<a&&(64512&(c=_.charCodeAt(r+1)))==56320&&(i=65536+(i-55296<<10)+(c-56320),r++),i<128?g[u++]=i:(i<2048?g[u++]=192|i>>>6:(i<65536?g[u++]=224|i>>>12:(g[u++]=240|i>>>18,g[u++]=128|i>>>12&63),g[u++]=128|i>>>6&63),g[u++]=128|63&i);return g},b.buf2binstring=function(_){return k(_,_.length)},b.binstring2buf=function(_){for(var g=new o.Buf8(_.length),i=0,c=g.length;i<c;i++)g[i]=_.charCodeAt(i);return g},b.buf2string=function(_,g){var i,c,r,u,a=g||_.length,d=new Array(2*a);for(i=c=0;i<a;)if((r=_[i++])<128)d[c++]=r;else if(4<(u=h[r]))d[c++]=65533,i+=u-1;else{for(r&=u===2?31:u===3?15:7;1<u&&i<a;)r=r<<6|63&_[i++],u--;1<u?d[c++]=65533:r<65536?d[c++]=r:(r-=65536,d[c++]=55296|r>>10&1023,d[c++]=56320|1023&r)}return k(d,c)},b.utf8border=function(_,g){var i;for((g=g||_.length)>_.length&&(g=_.length),i=g-1;0<=i&&(192&_[i])==128;)i--;return i<0||i===0?g:i+h[_[i]]>g?i:g}},{"./common":41}],43:[function(m,D,b){D.exports=function(o,l,n,h){for(var v=65535&o|0,k=o>>>16&65535|0,_=0;n!==0;){for(n-=_=2e3<n?2e3:n;k=k+(v=v+l[h++]|0)|0,--_;);v%=65521,k%=65521}return v|k<<16|0}},{}],44:[function(m,D,b){D.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(m,D,b){var o=(function(){for(var l,n=[],h=0;h<256;h++){l=h;for(var v=0;v<8;v++)l=1&l?3988292384^l>>>1:l>>>1;n[h]=l}return n})();D.exports=function(l,n,h,v){var k=o,_=v+h;l^=-1;for(var g=v;g<_;g++)l=l>>>8^k[255&(l^n[g])];return-1^l}},{}],46:[function(m,D,b){var o,l=m("../utils/common"),n=m("./trees"),h=m("./adler32"),v=m("./crc32"),k=m("./messages"),_=0,g=4,i=0,c=-2,r=-1,u=4,a=2,d=8,w=9,z=286,S=30,R=19,O=2*z+1,U=15,I=3,W=258,Y=W+I+1,p=42,T=113,e=1,N=2,X=3,L=4;function Q(t,B){return t.msg=k[B],B}function Z(t){return(t<<1)-(4<t?9:0)}function $(t){for(var B=t.length;0<=--B;)t[B]=0}function E(t){var B=t.state,A=B.pending;A>t.avail_out&&(A=t.avail_out),A!==0&&(l.arraySet(t.output,B.pending_buf,B.pending_out,A,t.next_out),t.next_out+=A,B.pending_out+=A,t.total_out+=A,t.avail_out-=A,B.pending-=A,B.pending===0&&(B.pending_out=0))}function y(t,B){n._tr_flush_block(t,0<=t.block_start?t.block_start:-1,t.strstart-t.block_start,B),t.block_start=t.strstart,E(t.strm)}function G(t,B){t.pending_buf[t.pending++]=B}function K(t,B){t.pending_buf[t.pending++]=B>>>8&255,t.pending_buf[t.pending++]=255&B}function F(t,B){var A,f,s=t.max_chain_length,x=t.strstart,j=t.prev_length,P=t.nice_match,C=t.strstart>t.w_size-Y?t.strstart-(t.w_size-Y):0,M=t.window,q=t.w_mask,H=t.prev,V=t.strstart+W,it=M[x+j-1],rt=M[x+j];t.prev_length>=t.good_match&&(s>>=2),P>t.lookahead&&(P=t.lookahead);do if(M[(A=B)+j]===rt&&M[A+j-1]===it&&M[A]===M[x]&&M[++A]===M[x+1]){x+=2,A++;do;while(M[++x]===M[++A]&&M[++x]===M[++A]&&M[++x]===M[++A]&&M[++x]===M[++A]&&M[++x]===M[++A]&&M[++x]===M[++A]&&M[++x]===M[++A]&&M[++x]===M[++A]&&x<V);if(f=W-(V-x),x=V-W,j<f){if(t.match_start=B,P<=(j=f))break;it=M[x+j-1],rt=M[x+j]}}while((B=H[B&q])>C&&--s!=0);return j<=t.lookahead?j:t.lookahead}function at(t){var B,A,f,s,x,j,P,C,M,q,H=t.w_size;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=H+(H-Y)){for(l.arraySet(t.window,t.window,H,H,0),t.match_start-=H,t.strstart-=H,t.block_start-=H,B=A=t.hash_size;f=t.head[--B],t.head[B]=H<=f?f-H:0,--A;);for(B=A=H;f=t.prev[--B],t.prev[B]=H<=f?f-H:0,--A;);s+=H}if(t.strm.avail_in===0)break;if(j=t.strm,P=t.window,C=t.strstart+t.lookahead,M=s,q=void 0,q=j.avail_in,M<q&&(q=M),A=q===0?0:(j.avail_in-=q,l.arraySet(P,j.input,j.next_in,q,C),j.state.wrap===1?j.adler=h(j.adler,P,q,C):j.state.wrap===2&&(j.adler=v(j.adler,P,q,C)),j.next_in+=q,j.total_in+=q,q),t.lookahead+=A,t.lookahead+t.insert>=I)for(x=t.strstart-t.insert,t.ins_h=t.window[x],t.ins_h=(t.ins_h<<t.hash_shift^t.window[x+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[x+I-1])&t.hash_mask,t.prev[x&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=x,x++,t.insert--,!(t.lookahead+t.insert<I)););}while(t.lookahead<Y&&t.strm.avail_in!==0)}function ut(t,B){for(var A,f;;){if(t.lookahead<Y){if(at(t),t.lookahead<Y&&B===_)return e;if(t.lookahead===0)break}if(A=0,t.lookahead>=I&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+I-1])&t.hash_mask,A=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),A!==0&&t.strstart-A<=t.w_size-Y&&(t.match_length=F(t,A)),t.match_length>=I)if(f=n._tr_tally(t,t.strstart-t.match_start,t.match_length-I),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=I){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+I-1])&t.hash_mask,A=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart,--t.match_length!=0;);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else f=n._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(f&&(y(t,!1),t.strm.avail_out===0))return e}return t.insert=t.strstart<I-1?t.strstart:I-1,B===g?(y(t,!0),t.strm.avail_out===0?X:L):t.last_lit&&(y(t,!1),t.strm.avail_out===0)?e:N}function et(t,B){for(var A,f,s;;){if(t.lookahead<Y){if(at(t),t.lookahead<Y&&B===_)return e;if(t.lookahead===0)break}if(A=0,t.lookahead>=I&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+I-1])&t.hash_mask,A=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=I-1,A!==0&&t.prev_length<t.max_lazy_match&&t.strstart-A<=t.w_size-Y&&(t.match_length=F(t,A),t.match_length<=5&&(t.strategy===1||t.match_length===I&&4096<t.strstart-t.match_start)&&(t.match_length=I-1)),t.prev_length>=I&&t.match_length<=t.prev_length){for(s=t.strstart+t.lookahead-I,f=n._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-I),t.lookahead-=t.prev_length-1,t.prev_length-=2;++t.strstart<=s&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+I-1])&t.hash_mask,A=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),--t.prev_length!=0;);if(t.match_available=0,t.match_length=I-1,t.strstart++,f&&(y(t,!1),t.strm.avail_out===0))return e}else if(t.match_available){if((f=n._tr_tally(t,0,t.window[t.strstart-1]))&&y(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return e}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(f=n._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<I-1?t.strstart:I-1,B===g?(y(t,!0),t.strm.avail_out===0?X:L):t.last_lit&&(y(t,!1),t.strm.avail_out===0)?e:N}function tt(t,B,A,f,s){this.good_length=t,this.max_lazy=B,this.nice_length=A,this.max_chain=f,this.func=s}function ht(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=d,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new l.Buf16(2*O),this.dyn_dtree=new l.Buf16(2*(2*S+1)),this.bl_tree=new l.Buf16(2*(2*R+1)),$(this.dyn_ltree),$(this.dyn_dtree),$(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new l.Buf16(U+1),this.heap=new l.Buf16(2*z+1),$(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new l.Buf16(2*z+1),$(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function st(t){var B;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=a,(B=t.state).pending=0,B.pending_out=0,B.wrap<0&&(B.wrap=-B.wrap),B.status=B.wrap?p:T,t.adler=B.wrap===2?0:1,B.last_flush=_,n._tr_init(B),i):Q(t,c)}function pt(t){var B=st(t);return B===i&&(function(A){A.window_size=2*A.w_size,$(A.head),A.max_lazy_match=o[A.level].max_lazy,A.good_match=o[A.level].good_length,A.nice_match=o[A.level].nice_length,A.max_chain_length=o[A.level].max_chain,A.strstart=0,A.block_start=0,A.lookahead=0,A.insert=0,A.match_length=A.prev_length=I-1,A.match_available=0,A.ins_h=0})(t.state),B}function dt(t,B,A,f,s,x){if(!t)return c;var j=1;if(B===r&&(B=6),f<0?(j=0,f=-f):15<f&&(j=2,f-=16),s<1||w<s||A!==d||f<8||15<f||B<0||9<B||x<0||u<x)return Q(t,c);f===8&&(f=9);var P=new ht;return(t.state=P).strm=t,P.wrap=j,P.gzhead=null,P.w_bits=f,P.w_size=1<<P.w_bits,P.w_mask=P.w_size-1,P.hash_bits=s+7,P.hash_size=1<<P.hash_bits,P.hash_mask=P.hash_size-1,P.hash_shift=~~((P.hash_bits+I-1)/I),P.window=new l.Buf8(2*P.w_size),P.head=new l.Buf16(P.hash_size),P.prev=new l.Buf16(P.w_size),P.lit_bufsize=1<<s+6,P.pending_buf_size=4*P.lit_bufsize,P.pending_buf=new l.Buf8(P.pending_buf_size),P.d_buf=1*P.lit_bufsize,P.l_buf=3*P.lit_bufsize,P.level=B,P.strategy=x,P.method=A,pt(t)}o=[new tt(0,0,0,0,function(t,B){var A=65535;for(A>t.pending_buf_size-5&&(A=t.pending_buf_size-5);;){if(t.lookahead<=1){if(at(t),t.lookahead===0&&B===_)return e;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;var f=t.block_start+A;if((t.strstart===0||t.strstart>=f)&&(t.lookahead=t.strstart-f,t.strstart=f,y(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-Y&&(y(t,!1),t.strm.avail_out===0))return e}return t.insert=0,B===g?(y(t,!0),t.strm.avail_out===0?X:L):(t.strstart>t.block_start&&(y(t,!1),t.strm.avail_out),e)}),new tt(4,4,8,4,ut),new tt(4,5,16,8,ut),new tt(4,6,32,32,ut),new tt(4,4,16,16,et),new tt(8,16,32,32,et),new tt(8,16,128,128,et),new tt(8,32,128,256,et),new tt(32,128,258,1024,et),new tt(32,258,258,4096,et)],b.deflateInit=function(t,B){return dt(t,B,d,15,8,0)},b.deflateInit2=dt,b.deflateReset=pt,b.deflateResetKeep=st,b.deflateSetHeader=function(t,B){return t&&t.state?t.state.wrap!==2?c:(t.state.gzhead=B,i):c},b.deflate=function(t,B){var A,f,s,x;if(!t||!t.state||5<B||B<0)return t?Q(t,c):c;if(f=t.state,!t.output||!t.input&&t.avail_in!==0||f.status===666&&B!==g)return Q(t,t.avail_out===0?-5:c);if(f.strm=t,A=f.last_flush,f.last_flush=B,f.status===p)if(f.wrap===2)t.adler=0,G(f,31),G(f,139),G(f,8),f.gzhead?(G(f,(f.gzhead.text?1:0)+(f.gzhead.hcrc?2:0)+(f.gzhead.extra?4:0)+(f.gzhead.name?8:0)+(f.gzhead.comment?16:0)),G(f,255&f.gzhead.time),G(f,f.gzhead.time>>8&255),G(f,f.gzhead.time>>16&255),G(f,f.gzhead.time>>24&255),G(f,f.level===9?2:2<=f.strategy||f.level<2?4:0),G(f,255&f.gzhead.os),f.gzhead.extra&&f.gzhead.extra.length&&(G(f,255&f.gzhead.extra.length),G(f,f.gzhead.extra.length>>8&255)),f.gzhead.hcrc&&(t.adler=v(t.adler,f.pending_buf,f.pending,0)),f.gzindex=0,f.status=69):(G(f,0),G(f,0),G(f,0),G(f,0),G(f,0),G(f,f.level===9?2:2<=f.strategy||f.level<2?4:0),G(f,3),f.status=T);else{var j=d+(f.w_bits-8<<4)<<8;j|=(2<=f.strategy||f.level<2?0:f.level<6?1:f.level===6?2:3)<<6,f.strstart!==0&&(j|=32),j+=31-j%31,f.status=T,K(f,j),f.strstart!==0&&(K(f,t.adler>>>16),K(f,65535&t.adler)),t.adler=1}if(f.status===69)if(f.gzhead.extra){for(s=f.pending;f.gzindex<(65535&f.gzhead.extra.length)&&(f.pending!==f.pending_buf_size||(f.gzhead.hcrc&&f.pending>s&&(t.adler=v(t.adler,f.pending_buf,f.pending-s,s)),E(t),s=f.pending,f.pending!==f.pending_buf_size));)G(f,255&f.gzhead.extra[f.gzindex]),f.gzindex++;f.gzhead.hcrc&&f.pending>s&&(t.adler=v(t.adler,f.pending_buf,f.pending-s,s)),f.gzindex===f.gzhead.extra.length&&(f.gzindex=0,f.status=73)}else f.status=73;if(f.status===73)if(f.gzhead.name){s=f.pending;do{if(f.pending===f.pending_buf_size&&(f.gzhead.hcrc&&f.pending>s&&(t.adler=v(t.adler,f.pending_buf,f.pending-s,s)),E(t),s=f.pending,f.pending===f.pending_buf_size)){x=1;break}x=f.gzindex<f.gzhead.name.length?255&f.gzhead.name.charCodeAt(f.gzindex++):0,G(f,x)}while(x!==0);f.gzhead.hcrc&&f.pending>s&&(t.adler=v(t.adler,f.pending_buf,f.pending-s,s)),x===0&&(f.gzindex=0,f.status=91)}else f.status=91;if(f.status===91)if(f.gzhead.comment){s=f.pending;do{if(f.pending===f.pending_buf_size&&(f.gzhead.hcrc&&f.pending>s&&(t.adler=v(t.adler,f.pending_buf,f.pending-s,s)),E(t),s=f.pending,f.pending===f.pending_buf_size)){x=1;break}x=f.gzindex<f.gzhead.comment.length?255&f.gzhead.comment.charCodeAt(f.gzindex++):0,G(f,x)}while(x!==0);f.gzhead.hcrc&&f.pending>s&&(t.adler=v(t.adler,f.pending_buf,f.pending-s,s)),x===0&&(f.status=103)}else f.status=103;if(f.status===103&&(f.gzhead.hcrc?(f.pending+2>f.pending_buf_size&&E(t),f.pending+2<=f.pending_buf_size&&(G(f,255&t.adler),G(f,t.adler>>8&255),t.adler=0,f.status=T)):f.status=T),f.pending!==0){if(E(t),t.avail_out===0)return f.last_flush=-1,i}else if(t.avail_in===0&&Z(B)<=Z(A)&&B!==g)return Q(t,-5);if(f.status===666&&t.avail_in!==0)return Q(t,-5);if(t.avail_in!==0||f.lookahead!==0||B!==_&&f.status!==666){var P=f.strategy===2?(function(C,M){for(var q;;){if(C.lookahead===0&&(at(C),C.lookahead===0)){if(M===_)return e;break}if(C.match_length=0,q=n._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++,q&&(y(C,!1),C.strm.avail_out===0))return e}return C.insert=0,M===g?(y(C,!0),C.strm.avail_out===0?X:L):C.last_lit&&(y(C,!1),C.strm.avail_out===0)?e:N})(f,B):f.strategy===3?(function(C,M){for(var q,H,V,it,rt=C.window;;){if(C.lookahead<=W){if(at(C),C.lookahead<=W&&M===_)return e;if(C.lookahead===0)break}if(C.match_length=0,C.lookahead>=I&&0<C.strstart&&(H=rt[V=C.strstart-1])===rt[++V]&&H===rt[++V]&&H===rt[++V]){it=C.strstart+W;do;while(H===rt[++V]&&H===rt[++V]&&H===rt[++V]&&H===rt[++V]&&H===rt[++V]&&H===rt[++V]&&H===rt[++V]&&H===rt[++V]&&V<it);C.match_length=W-(it-V),C.match_length>C.lookahead&&(C.match_length=C.lookahead)}if(C.match_length>=I?(q=n._tr_tally(C,1,C.match_length-I),C.lookahead-=C.match_length,C.strstart+=C.match_length,C.match_length=0):(q=n._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++),q&&(y(C,!1),C.strm.avail_out===0))return e}return C.insert=0,M===g?(y(C,!0),C.strm.avail_out===0?X:L):C.last_lit&&(y(C,!1),C.strm.avail_out===0)?e:N})(f,B):o[f.level].func(f,B);if(P!==X&&P!==L||(f.status=666),P===e||P===X)return t.avail_out===0&&(f.last_flush=-1),i;if(P===N&&(B===1?n._tr_align(f):B!==5&&(n._tr_stored_block(f,0,0,!1),B===3&&($(f.head),f.lookahead===0&&(f.strstart=0,f.block_start=0,f.insert=0))),E(t),t.avail_out===0))return f.last_flush=-1,i}return B!==g?i:f.wrap<=0?1:(f.wrap===2?(G(f,255&t.adler),G(f,t.adler>>8&255),G(f,t.adler>>16&255),G(f,t.adler>>24&255),G(f,255&t.total_in),G(f,t.total_in>>8&255),G(f,t.total_in>>16&255),G(f,t.total_in>>24&255)):(K(f,t.adler>>>16),K(f,65535&t.adler)),E(t),0<f.wrap&&(f.wrap=-f.wrap),f.pending!==0?i:1)},b.deflateEnd=function(t){var B;return t&&t.state?(B=t.state.status)!==p&&B!==69&&B!==73&&B!==91&&B!==103&&B!==T&&B!==666?Q(t,c):(t.state=null,B===T?Q(t,-3):i):c},b.deflateSetDictionary=function(t,B){var A,f,s,x,j,P,C,M,q=B.length;if(!t||!t.state||(x=(A=t.state).wrap)===2||x===1&&A.status!==p||A.lookahead)return c;for(x===1&&(t.adler=h(t.adler,B,q,0)),A.wrap=0,q>=A.w_size&&(x===0&&($(A.head),A.strstart=0,A.block_start=0,A.insert=0),M=new l.Buf8(A.w_size),l.arraySet(M,B,q-A.w_size,A.w_size,0),B=M,q=A.w_size),j=t.avail_in,P=t.next_in,C=t.input,t.avail_in=q,t.next_in=0,t.input=B,at(A);A.lookahead>=I;){for(f=A.strstart,s=A.lookahead-(I-1);A.ins_h=(A.ins_h<<A.hash_shift^A.window[f+I-1])&A.hash_mask,A.prev[f&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=f,f++,--s;);A.strstart=f,A.lookahead=I-1,at(A)}return A.strstart+=A.lookahead,A.block_start=A.strstart,A.insert=A.lookahead,A.lookahead=0,A.match_length=A.prev_length=I-1,A.match_available=0,t.next_in=P,t.input=C,t.avail_in=j,A.wrap=x,i},b.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(m,D,b){D.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(m,D,b){D.exports=function(o,l){var n,h,v,k,_,g,i,c,r,u,a,d,w,z,S,R,O,U,I,W,Y,p,T,e,N;n=o.state,h=o.next_in,e=o.input,v=h+(o.avail_in-5),k=o.next_out,N=o.output,_=k-(l-o.avail_out),g=k+(o.avail_out-257),i=n.dmax,c=n.wsize,r=n.whave,u=n.wnext,a=n.window,d=n.hold,w=n.bits,z=n.lencode,S=n.distcode,R=(1<<n.lenbits)-1,O=(1<<n.distbits)-1;t:do{w<15&&(d+=e[h++]<<w,w+=8,d+=e[h++]<<w,w+=8),U=z[d&R];e:for(;;){if(d>>>=I=U>>>24,w-=I,(I=U>>>16&255)===0)N[k++]=65535&U;else{if(!(16&I)){if((64&I)==0){U=z[(65535&U)+(d&(1<<I)-1)];continue e}if(32&I){n.mode=12;break t}o.msg="invalid literal/length code",n.mode=30;break t}W=65535&U,(I&=15)&&(w<I&&(d+=e[h++]<<w,w+=8),W+=d&(1<<I)-1,d>>>=I,w-=I),w<15&&(d+=e[h++]<<w,w+=8,d+=e[h++]<<w,w+=8),U=S[d&O];r:for(;;){if(d>>>=I=U>>>24,w-=I,!(16&(I=U>>>16&255))){if((64&I)==0){U=S[(65535&U)+(d&(1<<I)-1)];continue r}o.msg="invalid distance code",n.mode=30;break t}if(Y=65535&U,w<(I&=15)&&(d+=e[h++]<<w,(w+=8)<I&&(d+=e[h++]<<w,w+=8)),i<(Y+=d&(1<<I)-1)){o.msg="invalid distance too far back",n.mode=30;break t}if(d>>>=I,w-=I,(I=k-_)<Y){if(r<(I=Y-I)&&n.sane){o.msg="invalid distance too far back",n.mode=30;break t}if(T=a,(p=0)===u){if(p+=c-I,I<W){for(W-=I;N[k++]=a[p++],--I;);p=k-Y,T=N}}else if(u<I){if(p+=c+u-I,(I-=u)<W){for(W-=I;N[k++]=a[p++],--I;);if(p=0,u<W){for(W-=I=u;N[k++]=a[p++],--I;);p=k-Y,T=N}}}else if(p+=u-I,I<W){for(W-=I;N[k++]=a[p++],--I;);p=k-Y,T=N}for(;2<W;)N[k++]=T[p++],N[k++]=T[p++],N[k++]=T[p++],W-=3;W&&(N[k++]=T[p++],1<W&&(N[k++]=T[p++]))}else{for(p=k-Y;N[k++]=N[p++],N[k++]=N[p++],N[k++]=N[p++],2<(W-=3););W&&(N[k++]=N[p++],1<W&&(N[k++]=N[p++]))}break}}break}}while(h<v&&k<g);h-=W=w>>3,d&=(1<<(w-=W<<3))-1,o.next_in=h,o.next_out=k,o.avail_in=h<v?v-h+5:5-(h-v),o.avail_out=k<g?g-k+257:257-(k-g),n.hold=d,n.bits=w}},{}],49:[function(m,D,b){var o=m("../utils/common"),l=m("./adler32"),n=m("./crc32"),h=m("./inffast"),v=m("./inftrees"),k=1,_=2,g=0,i=-2,c=1,r=852,u=592;function a(p){return(p>>>24&255)+(p>>>8&65280)+((65280&p)<<8)+((255&p)<<24)}function d(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(p){var T;return p&&p.state?(T=p.state,p.total_in=p.total_out=T.total=0,p.msg="",T.wrap&&(p.adler=1&T.wrap),T.mode=c,T.last=0,T.havedict=0,T.dmax=32768,T.head=null,T.hold=0,T.bits=0,T.lencode=T.lendyn=new o.Buf32(r),T.distcode=T.distdyn=new o.Buf32(u),T.sane=1,T.back=-1,g):i}function z(p){var T;return p&&p.state?((T=p.state).wsize=0,T.whave=0,T.wnext=0,w(p)):i}function S(p,T){var e,N;return p&&p.state?(N=p.state,T<0?(e=0,T=-T):(e=1+(T>>4),T<48&&(T&=15)),T&&(T<8||15<T)?i:(N.window!==null&&N.wbits!==T&&(N.window=null),N.wrap=e,N.wbits=T,z(p))):i}function R(p,T){var e,N;return p?(N=new d,(p.state=N).window=null,(e=S(p,T))!==g&&(p.state=null),e):i}var O,U,I=!0;function W(p){if(I){var T;for(O=new o.Buf32(512),U=new o.Buf32(32),T=0;T<144;)p.lens[T++]=8;for(;T<256;)p.lens[T++]=9;for(;T<280;)p.lens[T++]=7;for(;T<288;)p.lens[T++]=8;for(v(k,p.lens,0,288,O,0,p.work,{bits:9}),T=0;T<32;)p.lens[T++]=5;v(_,p.lens,0,32,U,0,p.work,{bits:5}),I=!1}p.lencode=O,p.lenbits=9,p.distcode=U,p.distbits=5}function Y(p,T,e,N){var X,L=p.state;return L.window===null&&(L.wsize=1<<L.wbits,L.wnext=0,L.whave=0,L.window=new o.Buf8(L.wsize)),N>=L.wsize?(o.arraySet(L.window,T,e-L.wsize,L.wsize,0),L.wnext=0,L.whave=L.wsize):(N<(X=L.wsize-L.wnext)&&(X=N),o.arraySet(L.window,T,e-N,X,L.wnext),(N-=X)?(o.arraySet(L.window,T,e-N,N,0),L.wnext=N,L.whave=L.wsize):(L.wnext+=X,L.wnext===L.wsize&&(L.wnext=0),L.whave<L.wsize&&(L.whave+=X))),0}b.inflateReset=z,b.inflateReset2=S,b.inflateResetKeep=w,b.inflateInit=function(p){return R(p,15)},b.inflateInit2=R,b.inflate=function(p,T){var e,N,X,L,Q,Z,$,E,y,G,K,F,at,ut,et,tt,ht,st,pt,dt,t,B,A,f,s=0,x=new o.Buf8(4),j=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!p||!p.state||!p.output||!p.input&&p.avail_in!==0)return i;(e=p.state).mode===12&&(e.mode=13),Q=p.next_out,X=p.output,$=p.avail_out,L=p.next_in,N=p.input,Z=p.avail_in,E=e.hold,y=e.bits,G=Z,K=$,B=g;t:for(;;)switch(e.mode){case c:if(e.wrap===0){e.mode=13;break}for(;y<16;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}if(2&e.wrap&&E===35615){x[e.check=0]=255&E,x[1]=E>>>8&255,e.check=n(e.check,x,2,0),y=E=0,e.mode=2;break}if(e.flags=0,e.head&&(e.head.done=!1),!(1&e.wrap)||(((255&E)<<8)+(E>>8))%31){p.msg="incorrect header check",e.mode=30;break}if((15&E)!=8){p.msg="unknown compression method",e.mode=30;break}if(y-=4,t=8+(15&(E>>>=4)),e.wbits===0)e.wbits=t;else if(t>e.wbits){p.msg="invalid window size",e.mode=30;break}e.dmax=1<<t,p.adler=e.check=1,e.mode=512&E?10:12,y=E=0;break;case 2:for(;y<16;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}if(e.flags=E,(255&e.flags)!=8){p.msg="unknown compression method",e.mode=30;break}if(57344&e.flags){p.msg="unknown header flags set",e.mode=30;break}e.head&&(e.head.text=E>>8&1),512&e.flags&&(x[0]=255&E,x[1]=E>>>8&255,e.check=n(e.check,x,2,0)),y=E=0,e.mode=3;case 3:for(;y<32;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}e.head&&(e.head.time=E),512&e.flags&&(x[0]=255&E,x[1]=E>>>8&255,x[2]=E>>>16&255,x[3]=E>>>24&255,e.check=n(e.check,x,4,0)),y=E=0,e.mode=4;case 4:for(;y<16;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}e.head&&(e.head.xflags=255&E,e.head.os=E>>8),512&e.flags&&(x[0]=255&E,x[1]=E>>>8&255,e.check=n(e.check,x,2,0)),y=E=0,e.mode=5;case 5:if(1024&e.flags){for(;y<16;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}e.length=E,e.head&&(e.head.extra_len=E),512&e.flags&&(x[0]=255&E,x[1]=E>>>8&255,e.check=n(e.check,x,2,0)),y=E=0}else e.head&&(e.head.extra=null);e.mode=6;case 6:if(1024&e.flags&&(Z<(F=e.length)&&(F=Z),F&&(e.head&&(t=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Array(e.head.extra_len)),o.arraySet(e.head.extra,N,L,F,t)),512&e.flags&&(e.check=n(e.check,N,F,L)),Z-=F,L+=F,e.length-=F),e.length))break t;e.length=0,e.mode=7;case 7:if(2048&e.flags){if(Z===0)break t;for(F=0;t=N[L+F++],e.head&&t&&e.length<65536&&(e.head.name+=String.fromCharCode(t)),t&&F<Z;);if(512&e.flags&&(e.check=n(e.check,N,F,L)),Z-=F,L+=F,t)break t}else e.head&&(e.head.name=null);e.length=0,e.mode=8;case 8:if(4096&e.flags){if(Z===0)break t;for(F=0;t=N[L+F++],e.head&&t&&e.length<65536&&(e.head.comment+=String.fromCharCode(t)),t&&F<Z;);if(512&e.flags&&(e.check=n(e.check,N,F,L)),Z-=F,L+=F,t)break t}else e.head&&(e.head.comment=null);e.mode=9;case 9:if(512&e.flags){for(;y<16;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}if(E!==(65535&e.check)){p.msg="header crc mismatch",e.mode=30;break}y=E=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),p.adler=e.check=0,e.mode=12;break;case 10:for(;y<32;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}p.adler=e.check=a(E),y=E=0,e.mode=11;case 11:if(e.havedict===0)return p.next_out=Q,p.avail_out=$,p.next_in=L,p.avail_in=Z,e.hold=E,e.bits=y,2;p.adler=e.check=1,e.mode=12;case 12:if(T===5||T===6)break t;case 13:if(e.last){E>>>=7&y,y-=7&y,e.mode=27;break}for(;y<3;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}switch(e.last=1&E,y-=1,3&(E>>>=1)){case 0:e.mode=14;break;case 1:if(W(e),e.mode=20,T!==6)break;E>>>=2,y-=2;break t;case 2:e.mode=17;break;case 3:p.msg="invalid block type",e.mode=30}E>>>=2,y-=2;break;case 14:for(E>>>=7&y,y-=7&y;y<32;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}if((65535&E)!=(E>>>16^65535)){p.msg="invalid stored block lengths",e.mode=30;break}if(e.length=65535&E,y=E=0,e.mode=15,T===6)break t;case 15:e.mode=16;case 16:if(F=e.length){if(Z<F&&(F=Z),$<F&&(F=$),F===0)break t;o.arraySet(X,N,L,F,Q),Z-=F,L+=F,$-=F,Q+=F,e.length-=F;break}e.mode=12;break;case 17:for(;y<14;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}if(e.nlen=257+(31&E),E>>>=5,y-=5,e.ndist=1+(31&E),E>>>=5,y-=5,e.ncode=4+(15&E),E>>>=4,y-=4,286<e.nlen||30<e.ndist){p.msg="too many length or distance symbols",e.mode=30;break}e.have=0,e.mode=18;case 18:for(;e.have<e.ncode;){for(;y<3;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}e.lens[j[e.have++]]=7&E,E>>>=3,y-=3}for(;e.have<19;)e.lens[j[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,A={bits:e.lenbits},B=v(0,e.lens,0,19,e.lencode,0,e.work,A),e.lenbits=A.bits,B){p.msg="invalid code lengths set",e.mode=30;break}e.have=0,e.mode=19;case 19:for(;e.have<e.nlen+e.ndist;){for(;tt=(s=e.lencode[E&(1<<e.lenbits)-1])>>>16&255,ht=65535&s,!((et=s>>>24)<=y);){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}if(ht<16)E>>>=et,y-=et,e.lens[e.have++]=ht;else{if(ht===16){for(f=et+2;y<f;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}if(E>>>=et,y-=et,e.have===0){p.msg="invalid bit length repeat",e.mode=30;break}t=e.lens[e.have-1],F=3+(3&E),E>>>=2,y-=2}else if(ht===17){for(f=et+3;y<f;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}y-=et,t=0,F=3+(7&(E>>>=et)),E>>>=3,y-=3}else{for(f=et+7;y<f;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}y-=et,t=0,F=11+(127&(E>>>=et)),E>>>=7,y-=7}if(e.have+F>e.nlen+e.ndist){p.msg="invalid bit length repeat",e.mode=30;break}for(;F--;)e.lens[e.have++]=t}}if(e.mode===30)break;if(e.lens[256]===0){p.msg="invalid code -- missing end-of-block",e.mode=30;break}if(e.lenbits=9,A={bits:e.lenbits},B=v(k,e.lens,0,e.nlen,e.lencode,0,e.work,A),e.lenbits=A.bits,B){p.msg="invalid literal/lengths set",e.mode=30;break}if(e.distbits=6,e.distcode=e.distdyn,A={bits:e.distbits},B=v(_,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,A),e.distbits=A.bits,B){p.msg="invalid distances set",e.mode=30;break}if(e.mode=20,T===6)break t;case 20:e.mode=21;case 21:if(6<=Z&&258<=$){p.next_out=Q,p.avail_out=$,p.next_in=L,p.avail_in=Z,e.hold=E,e.bits=y,h(p,K),Q=p.next_out,X=p.output,$=p.avail_out,L=p.next_in,N=p.input,Z=p.avail_in,E=e.hold,y=e.bits,e.mode===12&&(e.back=-1);break}for(e.back=0;tt=(s=e.lencode[E&(1<<e.lenbits)-1])>>>16&255,ht=65535&s,!((et=s>>>24)<=y);){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}if(tt&&(240&tt)==0){for(st=et,pt=tt,dt=ht;tt=(s=e.lencode[dt+((E&(1<<st+pt)-1)>>st)])>>>16&255,ht=65535&s,!(st+(et=s>>>24)<=y);){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}E>>>=st,y-=st,e.back+=st}if(E>>>=et,y-=et,e.back+=et,e.length=ht,tt===0){e.mode=26;break}if(32&tt){e.back=-1,e.mode=12;break}if(64&tt){p.msg="invalid literal/length code",e.mode=30;break}e.extra=15&tt,e.mode=22;case 22:if(e.extra){for(f=e.extra;y<f;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}e.length+=E&(1<<e.extra)-1,E>>>=e.extra,y-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=23;case 23:for(;tt=(s=e.distcode[E&(1<<e.distbits)-1])>>>16&255,ht=65535&s,!((et=s>>>24)<=y);){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}if((240&tt)==0){for(st=et,pt=tt,dt=ht;tt=(s=e.distcode[dt+((E&(1<<st+pt)-1)>>st)])>>>16&255,ht=65535&s,!(st+(et=s>>>24)<=y);){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}E>>>=st,y-=st,e.back+=st}if(E>>>=et,y-=et,e.back+=et,64&tt){p.msg="invalid distance code",e.mode=30;break}e.offset=ht,e.extra=15&tt,e.mode=24;case 24:if(e.extra){for(f=e.extra;y<f;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}e.offset+=E&(1<<e.extra)-1,E>>>=e.extra,y-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){p.msg="invalid distance too far back",e.mode=30;break}e.mode=25;case 25:if($===0)break t;if(F=K-$,e.offset>F){if((F=e.offset-F)>e.whave&&e.sane){p.msg="invalid distance too far back",e.mode=30;break}at=F>e.wnext?(F-=e.wnext,e.wsize-F):e.wnext-F,F>e.length&&(F=e.length),ut=e.window}else ut=X,at=Q-e.offset,F=e.length;for($<F&&(F=$),$-=F,e.length-=F;X[Q++]=ut[at++],--F;);e.length===0&&(e.mode=21);break;case 26:if($===0)break t;X[Q++]=e.length,$--,e.mode=21;break;case 27:if(e.wrap){for(;y<32;){if(Z===0)break t;Z--,E|=N[L++]<<y,y+=8}if(K-=$,p.total_out+=K,e.total+=K,K&&(p.adler=e.check=e.flags?n(e.check,X,K,Q-K):l(e.check,X,K,Q-K)),K=$,(e.flags?E:a(E))!==e.check){p.msg="incorrect data check",e.mode=30;break}y=E=0}e.mode=28;case 28:if(e.wrap&&e.flags){for(;y<32;){if(Z===0)break t;Z--,E+=N[L++]<<y,y+=8}if(E!==(4294967295&e.total)){p.msg="incorrect length check",e.mode=30;break}y=E=0}e.mode=29;case 29:B=1;break t;case 30:B=-3;break t;case 31:return-4;default:return i}return p.next_out=Q,p.avail_out=$,p.next_in=L,p.avail_in=Z,e.hold=E,e.bits=y,(e.wsize||K!==p.avail_out&&e.mode<30&&(e.mode<27||T!==4))&&Y(p,p.output,p.next_out,K-p.avail_out)?(e.mode=31,-4):(G-=p.avail_in,K-=p.avail_out,p.total_in+=G,p.total_out+=K,e.total+=K,e.wrap&&K&&(p.adler=e.check=e.flags?n(e.check,X,K,p.next_out-K):l(e.check,X,K,p.next_out-K)),p.data_type=e.bits+(e.last?64:0)+(e.mode===12?128:0)+(e.mode===20||e.mode===15?256:0),(G==0&&K===0||T===4)&&B===g&&(B=-5),B)},b.inflateEnd=function(p){if(!p||!p.state)return i;var T=p.state;return T.window&&(T.window=null),p.state=null,g},b.inflateGetHeader=function(p,T){var e;return p&&p.state?(2&(e=p.state).wrap)==0?i:((e.head=T).done=!1,g):i},b.inflateSetDictionary=function(p,T){var e,N=T.length;return p&&p.state?(e=p.state).wrap!==0&&e.mode!==11?i:e.mode===11&&l(1,T,N,0)!==e.check?-3:Y(p,T,N,N)?(e.mode=31,-4):(e.havedict=1,g):i},b.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(m,D,b){var o=m("../utils/common"),l=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],n=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],h=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],v=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];D.exports=function(k,_,g,i,c,r,u,a){var d,w,z,S,R,O,U,I,W,Y=a.bits,p=0,T=0,e=0,N=0,X=0,L=0,Q=0,Z=0,$=0,E=0,y=null,G=0,K=new o.Buf16(16),F=new o.Buf16(16),at=null,ut=0;for(p=0;p<=15;p++)K[p]=0;for(T=0;T<i;T++)K[_[g+T]]++;for(X=Y,N=15;1<=N&&K[N]===0;N--);if(N<X&&(X=N),N===0)return c[r++]=20971520,c[r++]=20971520,a.bits=1,0;for(e=1;e<N&&K[e]===0;e++);for(X<e&&(X=e),p=Z=1;p<=15;p++)if(Z<<=1,(Z-=K[p])<0)return-1;if(0<Z&&(k===0||N!==1))return-1;for(F[1]=0,p=1;p<15;p++)F[p+1]=F[p]+K[p];for(T=0;T<i;T++)_[g+T]!==0&&(u[F[_[g+T]]++]=T);if(O=k===0?(y=at=u,19):k===1?(y=l,G-=257,at=n,ut-=257,256):(y=h,at=v,-1),p=e,R=r,Q=T=E=0,z=-1,S=($=1<<(L=X))-1,k===1&&852<$||k===2&&592<$)return 1;for(;;){for(U=p-Q,W=u[T]<O?(I=0,u[T]):u[T]>O?(I=at[ut+u[T]],y[G+u[T]]):(I=96,0),d=1<<p-Q,e=w=1<<L;c[R+(E>>Q)+(w-=d)]=U<<24|I<<16|W|0,w!==0;);for(d=1<<p-1;E&d;)d>>=1;if(d!==0?(E&=d-1,E+=d):E=0,T++,--K[p]==0){if(p===N)break;p=_[g+u[T]]}if(X<p&&(E&S)!==z){for(Q===0&&(Q=X),R+=e,Z=1<<(L=p-Q);L+Q<N&&!((Z-=K[L+Q])<=0);)L++,Z<<=1;if($+=1<<L,k===1&&852<$||k===2&&592<$)return 1;c[z=E&S]=X<<24|L<<16|R-r|0}}return E!==0&&(c[R+E]=p-Q<<24|64<<16|0),a.bits=X,0}},{"../utils/common":41}],51:[function(m,D,b){D.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(m,D,b){var o=m("../utils/common"),l=0,n=1;function h(s){for(var x=s.length;0<=--x;)s[x]=0}var v=0,k=29,_=256,g=_+1+k,i=30,c=19,r=2*g+1,u=15,a=16,d=7,w=256,z=16,S=17,R=18,O=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],U=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],I=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],W=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Y=new Array(2*(g+2));h(Y);var p=new Array(2*i);h(p);var T=new Array(512);h(T);var e=new Array(256);h(e);var N=new Array(k);h(N);var X,L,Q,Z=new Array(i);function $(s,x,j,P,C){this.static_tree=s,this.extra_bits=x,this.extra_base=j,this.elems=P,this.max_length=C,this.has_stree=s&&s.length}function E(s,x){this.dyn_tree=s,this.max_code=0,this.stat_desc=x}function y(s){return s<256?T[s]:T[256+(s>>>7)]}function G(s,x){s.pending_buf[s.pending++]=255&x,s.pending_buf[s.pending++]=x>>>8&255}function K(s,x,j){s.bi_valid>a-j?(s.bi_buf|=x<<s.bi_valid&65535,G(s,s.bi_buf),s.bi_buf=x>>a-s.bi_valid,s.bi_valid+=j-a):(s.bi_buf|=x<<s.bi_valid&65535,s.bi_valid+=j)}function F(s,x,j){K(s,j[2*x],j[2*x+1])}function at(s,x){for(var j=0;j|=1&s,s>>>=1,j<<=1,0<--x;);return j>>>1}function ut(s,x,j){var P,C,M=new Array(u+1),q=0;for(P=1;P<=u;P++)M[P]=q=q+j[P-1]<<1;for(C=0;C<=x;C++){var H=s[2*C+1];H!==0&&(s[2*C]=at(M[H]++,H))}}function et(s){var x;for(x=0;x<g;x++)s.dyn_ltree[2*x]=0;for(x=0;x<i;x++)s.dyn_dtree[2*x]=0;for(x=0;x<c;x++)s.bl_tree[2*x]=0;s.dyn_ltree[2*w]=1,s.opt_len=s.static_len=0,s.last_lit=s.matches=0}function tt(s){8<s.bi_valid?G(s,s.bi_buf):0<s.bi_valid&&(s.pending_buf[s.pending++]=s.bi_buf),s.bi_buf=0,s.bi_valid=0}function ht(s,x,j,P){var C=2*x,M=2*j;return s[C]<s[M]||s[C]===s[M]&&P[x]<=P[j]}function st(s,x,j){for(var P=s.heap[j],C=j<<1;C<=s.heap_len&&(C<s.heap_len&&ht(x,s.heap[C+1],s.heap[C],s.depth)&&C++,!ht(x,P,s.heap[C],s.depth));)s.heap[j]=s.heap[C],j=C,C<<=1;s.heap[j]=P}function pt(s,x,j){var P,C,M,q,H=0;if(s.last_lit!==0)for(;P=s.pending_buf[s.d_buf+2*H]<<8|s.pending_buf[s.d_buf+2*H+1],C=s.pending_buf[s.l_buf+H],H++,P===0?F(s,C,x):(F(s,(M=e[C])+_+1,x),(q=O[M])!==0&&K(s,C-=N[M],q),F(s,M=y(--P),j),(q=U[M])!==0&&K(s,P-=Z[M],q)),H<s.last_lit;);F(s,w,x)}function dt(s,x){var j,P,C,M=x.dyn_tree,q=x.stat_desc.static_tree,H=x.stat_desc.has_stree,V=x.stat_desc.elems,it=-1;for(s.heap_len=0,s.heap_max=r,j=0;j<V;j++)M[2*j]!==0?(s.heap[++s.heap_len]=it=j,s.depth[j]=0):M[2*j+1]=0;for(;s.heap_len<2;)M[2*(C=s.heap[++s.heap_len]=it<2?++it:0)]=1,s.depth[C]=0,s.opt_len--,H&&(s.static_len-=q[2*C+1]);for(x.max_code=it,j=s.heap_len>>1;1<=j;j--)st(s,M,j);for(C=V;j=s.heap[1],s.heap[1]=s.heap[s.heap_len--],st(s,M,1),P=s.heap[1],s.heap[--s.heap_max]=j,s.heap[--s.heap_max]=P,M[2*C]=M[2*j]+M[2*P],s.depth[C]=(s.depth[j]>=s.depth[P]?s.depth[j]:s.depth[P])+1,M[2*j+1]=M[2*P+1]=C,s.heap[1]=C++,st(s,M,1),2<=s.heap_len;);s.heap[--s.heap_max]=s.heap[1],(function(rt,ct){var yt,mt,bt,ot,xt,Et,_t=ct.dyn_tree,Tt=ct.max_code,Wt=ct.stat_desc.static_tree,Mt=ct.stat_desc.has_stree,Ht=ct.stat_desc.extra_bits,Bt=ct.stat_desc.extra_base,wt=ct.stat_desc.max_length,St=0;for(ot=0;ot<=u;ot++)rt.bl_count[ot]=0;for(_t[2*rt.heap[rt.heap_max]+1]=0,yt=rt.heap_max+1;yt<r;yt++)wt<(ot=_t[2*_t[2*(mt=rt.heap[yt])+1]+1]+1)&&(ot=wt,St++),_t[2*mt+1]=ot,Tt<mt||(rt.bl_count[ot]++,xt=0,Bt<=mt&&(xt=Ht[mt-Bt]),Et=_t[2*mt],rt.opt_len+=Et*(ot+xt),Mt&&(rt.static_len+=Et*(Wt[2*mt+1]+xt)));if(St!==0){do{for(ot=wt-1;rt.bl_count[ot]===0;)ot--;rt.bl_count[ot]--,rt.bl_count[ot+1]+=2,rt.bl_count[wt]--,St-=2}while(0<St);for(ot=wt;ot!==0;ot--)for(mt=rt.bl_count[ot];mt!==0;)Tt<(bt=rt.heap[--yt])||(_t[2*bt+1]!==ot&&(rt.opt_len+=(ot-_t[2*bt+1])*_t[2*bt],_t[2*bt+1]=ot),mt--)}})(s,x),ut(M,it,s.bl_count)}function t(s,x,j){var P,C,M=-1,q=x[1],H=0,V=7,it=4;for(q===0&&(V=138,it=3),x[2*(j+1)+1]=65535,P=0;P<=j;P++)C=q,q=x[2*(P+1)+1],++H<V&&C===q||(H<it?s.bl_tree[2*C]+=H:C!==0?(C!==M&&s.bl_tree[2*C]++,s.bl_tree[2*z]++):H<=10?s.bl_tree[2*S]++:s.bl_tree[2*R]++,M=C,it=(H=0)===q?(V=138,3):C===q?(V=6,3):(V=7,4))}function B(s,x,j){var P,C,M=-1,q=x[1],H=0,V=7,it=4;for(q===0&&(V=138,it=3),P=0;P<=j;P++)if(C=q,q=x[2*(P+1)+1],!(++H<V&&C===q)){if(H<it)for(;F(s,C,s.bl_tree),--H!=0;);else C!==0?(C!==M&&(F(s,C,s.bl_tree),H--),F(s,z,s.bl_tree),K(s,H-3,2)):H<=10?(F(s,S,s.bl_tree),K(s,H-3,3)):(F(s,R,s.bl_tree),K(s,H-11,7));M=C,it=(H=0)===q?(V=138,3):C===q?(V=6,3):(V=7,4)}}h(Z);var A=!1;function f(s,x,j,P){K(s,(v<<1)+(P?1:0),3),(function(C,M,q,H){tt(C),G(C,q),G(C,~q),o.arraySet(C.pending_buf,C.window,M,q,C.pending),C.pending+=q})(s,x,j)}b._tr_init=function(s){A||((function(){var x,j,P,C,M,q=new Array(u+1);for(C=P=0;C<k-1;C++)for(N[C]=P,x=0;x<1<<O[C];x++)e[P++]=C;for(e[P-1]=C,C=M=0;C<16;C++)for(Z[C]=M,x=0;x<1<<U[C];x++)T[M++]=C;for(M>>=7;C<i;C++)for(Z[C]=M<<7,x=0;x<1<<U[C]-7;x++)T[256+M++]=C;for(j=0;j<=u;j++)q[j]=0;for(x=0;x<=143;)Y[2*x+1]=8,x++,q[8]++;for(;x<=255;)Y[2*x+1]=9,x++,q[9]++;for(;x<=279;)Y[2*x+1]=7,x++,q[7]++;for(;x<=287;)Y[2*x+1]=8,x++,q[8]++;for(ut(Y,g+1,q),x=0;x<i;x++)p[2*x+1]=5,p[2*x]=at(x,5);X=new $(Y,O,_+1,g,u),L=new $(p,U,0,i,u),Q=new $(new Array(0),I,0,c,d)})(),A=!0),s.l_desc=new E(s.dyn_ltree,X),s.d_desc=new E(s.dyn_dtree,L),s.bl_desc=new E(s.bl_tree,Q),s.bi_buf=0,s.bi_valid=0,et(s)},b._tr_stored_block=f,b._tr_flush_block=function(s,x,j,P){var C,M,q=0;0<s.level?(s.strm.data_type===2&&(s.strm.data_type=(function(H){var V,it=4093624447;for(V=0;V<=31;V++,it>>>=1)if(1&it&&H.dyn_ltree[2*V]!==0)return l;if(H.dyn_ltree[18]!==0||H.dyn_ltree[20]!==0||H.dyn_ltree[26]!==0)return n;for(V=32;V<_;V++)if(H.dyn_ltree[2*V]!==0)return n;return l})(s)),dt(s,s.l_desc),dt(s,s.d_desc),q=(function(H){var V;for(t(H,H.dyn_ltree,H.l_desc.max_code),t(H,H.dyn_dtree,H.d_desc.max_code),dt(H,H.bl_desc),V=c-1;3<=V&&H.bl_tree[2*W[V]+1]===0;V--);return H.opt_len+=3*(V+1)+5+5+4,V})(s),C=s.opt_len+3+7>>>3,(M=s.static_len+3+7>>>3)<=C&&(C=M)):C=M=j+5,j+4<=C&&x!==-1?f(s,x,j,P):s.strategy===4||M===C?(K(s,2+(P?1:0),3),pt(s,Y,p)):(K(s,4+(P?1:0),3),(function(H,V,it,rt){var ct;for(K(H,V-257,5),K(H,it-1,5),K(H,rt-4,4),ct=0;ct<rt;ct++)K(H,H.bl_tree[2*W[ct]+1],3);B(H,H.dyn_ltree,V-1),B(H,H.dyn_dtree,it-1)})(s,s.l_desc.max_code+1,s.d_desc.max_code+1,q+1),pt(s,s.dyn_ltree,s.dyn_dtree)),et(s),P&&tt(s)},b._tr_tally=function(s,x,j){return s.pending_buf[s.d_buf+2*s.last_lit]=x>>>8&255,s.pending_buf[s.d_buf+2*s.last_lit+1]=255&x,s.pending_buf[s.l_buf+s.last_lit]=255&j,s.last_lit++,x===0?s.dyn_ltree[2*j]++:(s.matches++,x--,s.dyn_ltree[2*(e[j]+_+1)]++,s.dyn_dtree[2*y(x)]++),s.last_lit===s.lit_bufsize-1},b._tr_align=function(s){K(s,2,3),F(s,w,Y),(function(x){x.bi_valid===16?(G(x,x.bi_buf),x.bi_buf=0,x.bi_valid=0):8<=x.bi_valid&&(x.pending_buf[x.pending++]=255&x.bi_buf,x.bi_buf>>=8,x.bi_valid-=8)})(s)}},{"../utils/common":41}],53:[function(m,D,b){D.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(m,D,b){(function(o){(function(l,n){if(!l.setImmediate){var h,v,k,_,g=1,i={},c=!1,r=l.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(l);u=u&&u.setTimeout?u:l,h={}.toString.call(l.process)==="[object process]"?function(z){process.nextTick(function(){d(z)})}:(function(){if(l.postMessage&&!l.importScripts){var z=!0,S=l.onmessage;return l.onmessage=function(){z=!1},l.postMessage("","*"),l.onmessage=S,z}})()?(_="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",w,!1):l.attachEvent("onmessage",w),function(z){l.postMessage(_+z,"*")}):l.MessageChannel?((k=new MessageChannel).port1.onmessage=function(z){d(z.data)},function(z){k.port2.postMessage(z)}):r&&"onreadystatechange"in r.createElement("script")?(v=r.documentElement,function(z){var S=r.createElement("script");S.onreadystatechange=function(){d(z),S.onreadystatechange=null,v.removeChild(S),S=null},v.appendChild(S)}):function(z){setTimeout(d,0,z)},u.setImmediate=function(z){typeof z!="function"&&(z=new Function(""+z));for(var S=new Array(arguments.length-1),R=0;R<S.length;R++)S[R]=arguments[R+1];var O={callback:z,args:S};return i[g]=O,h(g),g++},u.clearImmediate=a}function a(z){delete i[z]}function d(z){if(c)setTimeout(d,0,z);else{var S=i[z];if(S){c=!0;try{(function(R){var O=R.callback,U=R.args;switch(U.length){case 0:O();break;case 1:O(U[0]);break;case 2:O(U[0],U[1]);break;case 3:O(U[0],U[1],U[2]);break;default:O.apply(n,U)}})(S)}finally{a(z),c=!1}}}}function w(z){z.source===l&&typeof z.data=="string"&&z.data.indexOf(_)===0&&d(+z.data.slice(_.length))}})(typeof self>"u"?o===void 0?this:o:self)}).call(this,typeof zt<"u"?zt:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Rt)),Rt.exports}var he=ue();const be=Kt(he),fe=nt=>{const ft=nt.trim();if(!ft)return null;try{const m=new URL(ft);return m.protocol==="http:"||m.protocol==="https:"?m.toString():null}catch{return null}},ce=nt=>({id:nt?.key??"",key:nt?.key??"",name:nt?.name??"",value:nt?.value??"",valueType:nt?.valueType??"text",persistedKey:nt?.key}),de=nt=>{if(Array.isArray(nt))return nt;const ft=nt?.keys;return Array.isArray(ft)?ft:[]},Ot=(nt=[])=>nt.map(ce),Zt=(nt,ft)=>{const m=[],D=new Set(ft);for(const b of nt){const o=b.key.trim();if(!o)continue;const l=b.value.trim(),n=!!b.persistedKey&&(b.valueType==="number"||b.valueType==="date"||b.valueType==="select"||b.valueType==="url");if(!l&&n){D.add(b.persistedKey);continue}!l&&b.valueType!=="text"&&b.valueType!=="boolean"||m.push({key:o,name:b.name.trim()||o,value:b.valueType==="boolean"?l||"false":l,valueType:b.valueType})}return{set:m.sort((b,o)=>b.key.localeCompare(o.key)),deleteKeys:Array.from(D).sort()}},vt=(nt,ft=[])=>JSON.stringify(Zt(nt,ft)),we=lt.forwardRef(function({noteId:ft,properties:m=[],expectedUpdatedAt:D,editSessionId:b,disabled:o,saveProperties:l=Xt,onPendingChange:n,onSaved:h},v){const k=ie(),_=Vt(),[g,i]=lt.useState(()=>Ot(m)),[c,r]=lt.useState([]),[u,a]=lt.useState("idle"),d=lt.useRef(g),w=lt.useRef(c),z=lt.useRef(D),S=lt.useRef(vt(g)),R=lt.useRef(null),O=lt.useRef(!1),U=lt.useRef(null),I=lt.useRef(!1),W=lt.useRef(0),Y=Gt({queryKey:Nt.notes.propertyKeys({limit:50}),queryFn:async()=>{const y=await ae({limit:50});if(y.type==="error")throw y;return y.notePropertyKeys.keys}});lt.useEffect(()=>{const y=Ot(m);i(y),r([]),S.current=vt(y),a("idle")},[m]),lt.useEffect(()=>{d.current=g},[g]),lt.useEffect(()=>{w.current=c},[c]),lt.useEffect(()=>{z.current=D},[D]);const p=de(Y.data),T=p.filter(y=>!g.some(G=>G.key===y.key)),e=p.length>0,N=vt(g,c)!==S.current,X=lt.useCallback(async({ignoreDisabled:y=!1,expectedUpdatedAt:G}={})=>{if(R.current&&(clearTimeout(R.current),R.current=null),U.current){I.current=!0;const tt=await U.current;return tt==="error"?tt:X({ignoreDisabled:y})}const K=vt(d.current,w.current);if(!y&&o||K===S.current)return"idle";const F=Zt(d.current,w.current);if(F.set.length===0&&F.deleteKeys.length===0)return"idle";O.current=!0,I.current=!1,a("saving");const at=W.current,ut=(async()=>{try{const tt=await l({id:ft,set:F.set,deleteKeys:F.deleteKeys,editSessionId:b,expectedUpdatedAt:G??z.current});return!tt||at!==W.current?(a("idle"),"idle"):tt.type==="error"?(a("error"),k(tt.errors[0]?.message??"Failed to save properties."),"error"):(z.current=tt.updateNoteProperties.updatedAt,S.current=vt(Ot(tt.updateNoteProperties.properties??[])),await h(tt.updateNoteProperties),_.invalidateQueries({queryKey:Nt.notes.propertyKeysAll(),exact:!1}),a("saved"),"saved")}catch{return a("error"),k("Failed to save properties."),"error"}finally{O.current=!1}})();U.current=ut;const et=await ut;if(U.current===ut&&(U.current=null),I.current){I.current=!1;const tt=await X({ignoreDisabled:y});return tt==="idle"?et:tt}return et},[o,b,ft,h,_,l,k]);lt.useImperativeHandle(v,()=>({flushPendingSave:({expectedUpdatedAt:y}={})=>X({ignoreDisabled:!0,expectedUpdatedAt:y}),invalidateInFlightSave:()=>{W.current+=1,R.current&&(clearTimeout(R.current),R.current=null)},discardPendingChanges:()=>{W.current+=1,I.current=!1,S.current=vt(d.current,w.current),a("idle"),R.current&&(clearTimeout(R.current),R.current=null)}}),[X]),lt.useEffect(()=>{n?.(N||u==="saving")},[u,N,n]),lt.useEffect(()=>{if(R.current&&clearTimeout(R.current),!(o||vt(g,c)===S.current))return R.current=setTimeout(()=>{X()},500),()=>{R.current&&clearTimeout(R.current)}},[c,o,g,X]);const L=y=>{i(G=>[...G,{id:y.key,key:y.key,name:y.name,value:"",valueType:y.valueType,persistedKey:void 0}]),r(G=>G.filter(K=>K!==y.key))},Q=(y,G)=>{i(K=>K.map(F=>F.id===y?{...F,...G}:F))},Z=y=>{y.persistedKey&&r(G=>[...new Set([...G,y.persistedKey])]),i(G=>G.filter(K=>K.id!==y.id))},$=vt(g,c)!==S.current,E=o||!$&&u==="idle"?null:u==="saving"?"Saving...":u==="error"?"Save failed":$?"Waiting...":"Saved";return J.jsxs(le,{title:"Properties",icon:J.jsx(Yt,{className:"h-3.5 w-3.5"}),ariaLabel:"Note properties",action:J.jsxs(J.Fragment,{children:[E&&J.jsx(gt,{as:"span",variant:"micro",tone:u==="error"?"error":"tertiary",className:"px-1",children:E}),e&&J.jsx(kt,{asChild:!0,size:"sm",variant:"ghost",children:J.jsxs(Ft,{to:Pt,search:{page:1},children:[J.jsx(qt,{className:"h-3 w-3"}),"Manage"]})})]}),children:[g.length===0?J.jsx(gt,{as:"p",variant:"label",tone:"tertiary",className:"px-1 py-2",children:"No properties yet."}):J.jsx("div",{className:"divide-y divide-border-subtle",children:g.map(y=>{const G=`note-property-${y.id}-label`,K=y.valueType==="url"?fe(y.value):null;return J.jsxs("div",{className:"group grid gap-2 py-2 sm:grid-cols-[minmax(0,180px)_minmax(0,1fr)_auto] sm:items-center",children:[J.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1",children:[J.jsx(gt,{id:G,as:"span",variant:"label",tone:"secondary",className:"truncate",children:y.name}),J.jsx(gt,{as:"span",variant:"micro",tone:"tertiary",className:"hidden truncate font-mono sm:inline",children:y.key})]}),y.valueType==="boolean"?J.jsxs(Dt,{size:"sm",variant:"ghost",value:y.value||"false",disabled:o,"aria-labelledby":G,onValueChange:F=>Q(y.id,{value:F}),children:[J.jsx(It,{value:"false",children:"False"}),J.jsx(It,{value:"true",children:"True"})]}):y.valueType==="select"?J.jsx(Dt,{size:"sm",variant:"ghost",value:y.value,placeholder:"Select option",disabled:o,"aria-labelledby":G,onValueChange:F=>Q(y.id,{value:F}),children:(p.find(F=>F.key===y.key)?.options??[]).map(F=>J.jsx(It,{value:F.value,children:F.label},F.id))}):y.valueType==="url"?J.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[J.jsx(jt,{className:"min-w-0",size:"sm",variant:"ghost",type:"url","aria-label":"Property value",placeholder:"https://example.com",value:y.value,disabled:o,onChange:F=>Q(y.id,{value:F.target.value})}),K?J.jsx(kt,{asChild:!0,size:"icon-sm",variant:"ghost","aria-label":`Open ${y.name}`,className:"shrink-0 text-fg-tertiary",children:J.jsx("a",{href:K,target:"_blank",rel:"noopener noreferrer",title:K,children:J.jsx(oe,{className:"h-4 w-4"})})}):null]}):J.jsx(jt,{size:"sm",variant:"ghost",type:y.valueType==="date"?"date":y.valueType==="number"?"number":"text","aria-label":"Property value",placeholder:"Value",value:y.value,disabled:o,onChange:F=>Q(y.id,{value:F.target.value})}),J.jsx(kt,{type:"button",size:"icon-sm",variant:"ghost","aria-label":`Remove ${y.name}`,disabled:o,className:"justify-self-end text-fg-tertiary sm:opacity-0 sm:group-hover:opacity-100 sm:focus-visible:opacity-100",onClick:()=>Z(y),children:J.jsx(Jt,{className:"h-4 w-4"})})]},y.id)})}),J.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:Y.isLoading?J.jsx(kt,{type:"button",size:"sm",variant:"ghost",disabled:!0,children:"Loading properties..."}):T.length>0?J.jsxs($t,{children:[J.jsx(Qt,{asChild:!0,children:J.jsxs(kt,{type:"button",size:"sm",variant:"ghost",disabled:o,children:[J.jsx(Ut,{className:"h-4 w-4"}),"Add property"]})}),J.jsxs(te,{align:"start",sideOffset:6,className:"max-h-80 w-[min(22rem,calc(100vw-2rem))]",style:{overflowY:"auto"},children:[J.jsx(ee,{children:J.jsx(gt,{as:"span",variant:"label",weight:"semibold",children:"Add property"})}),J.jsx(re,{}),T.map(y=>J.jsxs(ne,{className:"flex-col items-start gap-0.5 whitespace-normal",onClick:()=>L(y),children:[J.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-3",children:[J.jsx(gt,{as:"span",variant:"label",weight:"medium",className:"truncate",children:y.name}),J.jsx(gt,{as:"span",variant:"micro",tone:"tertiary",className:"shrink-0 capitalize",children:y.valueType})]}),J.jsx(gt,{as:"span",variant:"micro",tone:"tertiary",className:"font-mono",children:y.key})]},y.key))]})]}):e?J.jsx(gt,{as:"span",variant:"micro",tone:"tertiary",className:"px-1",children:"All shared properties are attached."}):J.jsxs(Ft,{to:Pt,search:{page:1},className:"focus-ring-soft inline-flex items-center gap-2 rounded-[12px] px-2.5 py-1.5 text-sm font-medium text-fg-secondary outline-none hover:bg-hover-subtle hover:text-fg-default",children:[J.jsx(Ut,{className:"h-4 w-4"}),"Create property definition"]})})]})});export{le as A,be as J,we as N};
@@ -1 +1 @@
1
- import{r as e}from"./floating-ui.react-dom-BWTnA00G.js";import{z as n}from"./note.api-BQovzEzd.js";const m=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M230.15,70.54,185.46,25.86a20,20,0,0,0-28.28,0L33.86,149.17A19.86,19.86,0,0,0,28,163.31V208a20,20,0,0,0,20,20H216a12,12,0,0,0,0-24H125L230.15,98.83A20,20,0,0,0,230.15,70.54ZM136,81l11,11L76,163,65,152ZM52,204V173l15.52,15.51h0L83,204Zm52-13L93,180l71-71,11,11Zm88-88L153,64l18.34-18.34,39,39Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M221.66,90.34,192,120,136,64l29.66-29.66a8,8,0,0,1,11.31,0L221.66,79A8,8,0,0,1,221.66,90.34Z",opacity:"0.2"}),e.createElement("path",{d:"M227.32,73.37,182.63,28.69a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H216a8,8,0,0,0,0-16H115.32l112-112A16,16,0,0,0,227.32,73.37ZM79.32,188,164,103.31,180.69,120,96,204.69ZM68,176.69,51.31,160,136,75.31,152.69,92Zm-20,2.62L76.69,208H48Zm144-70.62L147.32,64l24-24L216,84.69Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M227.32,73.37,182.63,28.69a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H216a8,8,0,0,0,0-16H115.32l112-112A16,16,0,0,0,227.32,73.37ZM79.32,188l90.34-90.34,16.69,16.68L96,204.69Zm79-101.66h0L68,176.69,51.31,160l90.35-90.34ZM48,179.31,76.69,208H48Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M225.91,74.79,181.22,30.1a14,14,0,0,0-19.8,0L38.1,153.41a13.94,13.94,0,0,0-4.1,9.9V208a14,14,0,0,0,14,14H216a6,6,0,0,0,0-12H110.49L225.91,94.59A14,14,0,0,0,225.91,74.79ZM76.49,188,164,100.48,183.52,120,96,207.51ZM68,179.52,48.49,160,136,72.49,155.52,92ZM46,208V174.48L81.52,210H48A2,2,0,0,1,46,208ZM217.42,86.1,192,111.52,144.49,64,169.9,38.59a2,2,0,0,1,2.83,0l44.69,44.68A2,2,0,0,1,217.42,86.1Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M227.32,73.37,182.63,28.69a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H216a8,8,0,0,0,0-16H115.32l112-112A16,16,0,0,0,227.32,73.37ZM136,75.31,152.69,92,68,176.69,51.31,160ZM48,208V179.31L76.69,208Zm48-3.31L79.32,188,164,103.31,180.69,120Zm96-96L147.32,64l24-24L216,84.69Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224.49,76.2,179.8,31.51a12,12,0,0,0-17,0L39.51,154.83A12,12,0,0,0,36,163.31V208a12,12,0,0,0,12,12H216a4,4,0,0,0,0-8H105.66L224.49,93.17A12,12,0,0,0,224.49,76.2ZM73.66,188,164,97.66,186.35,120,96,210.34ZM68,182.34,45.66,160,136,69.66,158.35,92ZM44,208V169.66l21.17,21.17h0L86.34,212H48A4,4,0,0,1,44,208ZM218.83,87.51,192,114.34,141.66,64l26.83-26.83a4,4,0,0,1,5.66,0l44.68,44.69A4,4,0,0,1,218.83,87.51Z"}))]]),a=e.forwardRef((t,l)=>e.createElement(n,{ref:l,...t,weights:m}));a.displayName="PencilLineIcon";const L=a;export{L as m};
1
+ import{r as e}from"./floating-ui.react-dom-BWTnA00G.js";import{A as n}from"./note.api-D3oJmG3q.js";const m=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M230.15,70.54,185.46,25.86a20,20,0,0,0-28.28,0L33.86,149.17A19.86,19.86,0,0,0,28,163.31V208a20,20,0,0,0,20,20H216a12,12,0,0,0,0-24H125L230.15,98.83A20,20,0,0,0,230.15,70.54ZM136,81l11,11L76,163,65,152ZM52,204V173l15.52,15.51h0L83,204Zm52-13L93,180l71-71,11,11Zm88-88L153,64l18.34-18.34,39,39Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M221.66,90.34,192,120,136,64l29.66-29.66a8,8,0,0,1,11.31,0L221.66,79A8,8,0,0,1,221.66,90.34Z",opacity:"0.2"}),e.createElement("path",{d:"M227.32,73.37,182.63,28.69a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H216a8,8,0,0,0,0-16H115.32l112-112A16,16,0,0,0,227.32,73.37ZM79.32,188,164,103.31,180.69,120,96,204.69ZM68,176.69,51.31,160,136,75.31,152.69,92Zm-20,2.62L76.69,208H48Zm144-70.62L147.32,64l24-24L216,84.69Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M227.32,73.37,182.63,28.69a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H216a8,8,0,0,0,0-16H115.32l112-112A16,16,0,0,0,227.32,73.37ZM79.32,188l90.34-90.34,16.69,16.68L96,204.69Zm79-101.66h0L68,176.69,51.31,160l90.35-90.34ZM48,179.31,76.69,208H48Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M225.91,74.79,181.22,30.1a14,14,0,0,0-19.8,0L38.1,153.41a13.94,13.94,0,0,0-4.1,9.9V208a14,14,0,0,0,14,14H216a6,6,0,0,0,0-12H110.49L225.91,94.59A14,14,0,0,0,225.91,74.79ZM76.49,188,164,100.48,183.52,120,96,207.51ZM68,179.52,48.49,160,136,72.49,155.52,92ZM46,208V174.48L81.52,210H48A2,2,0,0,1,46,208ZM217.42,86.1,192,111.52,144.49,64,169.9,38.59a2,2,0,0,1,2.83,0l44.69,44.68A2,2,0,0,1,217.42,86.1Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M227.32,73.37,182.63,28.69a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H216a8,8,0,0,0,0-16H115.32l112-112A16,16,0,0,0,227.32,73.37ZM136,75.31,152.69,92,68,176.69,51.31,160ZM48,208V179.31L76.69,208Zm48-3.31L79.32,188,164,103.31,180.69,120Zm96-96L147.32,64l24-24L216,84.69Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224.49,76.2,179.8,31.51a12,12,0,0,0-17,0L39.51,154.83A12,12,0,0,0,36,163.31V208a12,12,0,0,0,12,12H216a4,4,0,0,0,0-8H105.66L224.49,93.17A12,12,0,0,0,224.49,76.2ZM73.66,188,164,97.66,186.35,120,96,210.34ZM68,182.34,45.66,160,136,69.66,158.35,92ZM44,208V169.66l21.17,21.17h0L86.34,212H48A4,4,0,0,1,44,208ZM218.83,87.51,192,114.34,141.66,64l26.83-26.83a4,4,0,0,1,5.66,0l44.68,44.69A4,4,0,0,1,218.83,87.51Z"}))]]),a=e.forwardRef((t,l)=>e.createElement(n,{ref:l,...t,weights:m}));a.displayName="PencilLineIcon";const L=a;export{L as m};
@@ -1 +1 @@
1
- import{r as e}from"./floating-ui.react-dom-BWTnA00G.js";import{z as l}from"./note.api-BQovzEzd.js";const r=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),e.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z"}))]]),a=e.forwardRef((t,n)=>e.createElement(l,{ref:n,...t,weights:r}));a.displayName="PlusIcon";const c=a;export{c as n};
1
+ import{r as e}from"./floating-ui.react-dom-BWTnA00G.js";import{A as l}from"./note.api-D3oJmG3q.js";const r=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),e.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z"}))]]),a=e.forwardRef((t,n)=>e.createElement(l,{ref:n,...t,weights:r}));a.displayName="PlusIcon";const c=a;export{c as n};
@@ -1 +1 @@
1
- import{j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{F as k,T as h,C as H,G as M,Q as E,P as w,E as S,j as C,k as o,f as L}from"./note.api-BQovzEzd.js";import{N as O,R as U}from"./url-9nrbQs7Z.js";import{u as I,R as P}from"./useReminderMutate--omDLmBV.js";import{f as Y,d as u}from"./time-CfAYZipR.js";const g={high:"bg-priority-high",medium:"bg-priority-medium",low:"bg-priority-low"};function B({reminder:t,onUpdate:l,onDelete:f}){const j=y=>{const r=u(Number(y)),m=u();return r.isSame(m,"day")?`Today at ${r.format("HH:mm")}`:r.isSame(m.add(1,"day"),"day")?`Tomorrow at ${r.format("HH:mm")}`:r.format("YYYY-MM-DD HH:mm")},a=y=>{const r=u(Number(y)),m=u(),N=r.diff(m,"hour"),b=r.diff(m,"minute")%60;return N<0||b<0?"Overdue":N===0?`${b}m remaining`:`${N}h ${b}m remaining`},d=a(t.reminderDate)==="Overdue",i=t.priority||"low",s=i==="high"?"High":i==="medium"?"Medium":"Low",p=g[i],c=t.noteId.toString(),n=d?"text-fg-error":"text-fg-tertiary",x=t.content?.trim()||t.note?.title||"Untitled reminder",v=t.note?.title||"Untitled note",T=!!(t.content?.trim()&&t.note?.title),D=a(t.reminderDate),$=j(t.reminderDate);return e.jsxs("div",{className:"surface-base flex flex-col gap-2.5 px-4 py-3 sm:flex-row sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5 sm:items-center",children:[e.jsx(k,{checked:t.completed,onChange:()=>l(t.id,c,{completed:!t.completed}),size:"sm","aria-label":`Reminder: ${x}`}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(h,{as:"p",variant:"body",weight:"semibold",className:t.completed?"truncate line-through opacity-45":"truncate",children:x}),T&&e.jsx(h,{as:"div",variant:"meta",tone:"secondary",className:t.completed?"mt-0.5 truncate opacity-45":"mt-0.5 truncate",children:e.jsx(H,{to:O,params:{id:String(t.note?.id??t.noteId)},className:"transition-colors hover:text-fg-default hover:underline",children:v})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 sm:shrink-0",children:[e.jsx("span",{className:`h-3 w-3 shrink-0 rounded-full border border-border-subtle ${p}`,"aria-label":`${s} priority`,title:`${s} priority`}),e.jsx(h,{as:"span",variant:"meta",weight:"medium",tone:"secondary",className:t.completed?"opacity-45":void 0,children:$}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),e.jsx(h,{as:"span",variant:"label",weight:"medium",className:t.completed?"opacity-45":n,children:D})]}),e.jsx("div",{className:"flex items-center justify-end gap-1.5 sm:shrink-0",children:e.jsx(M,{button:e.jsx(Y,{label:"Reminder actions",iconClassName:"h-5 w-5 text-current"}),items:[{name:"Delete",onClick:()=>f(t.id,c)}]})})]})}const R=L(U),A=[{label:"High",className:g.high},{label:"Medium",className:g.medium},{label:"Low",className:g.low}];function K(){const t=R.useNavigate(),{page:l}=R.useSearch(),{onUpdate:f,onDelete:j}=I(),a=25,d=e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:A.map(({label:i,className:s})=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full border border-border-subtle ${s}`,"aria-hidden":"true"}),e.jsx(h,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:i})]},i))});return e.jsx(E,{fallback:e.jsx(w,{title:"Reminders",heading:e.jsx(o,{width:164,height:24,className:"rounded-full"}),description:e.jsx(o,{width:224,height:16,className:"rounded-full"}),headerRight:d,children:e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"})]})}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading the upcoming reminder list",resetKeys:[l,a],children:e.jsx(P,{searchParams:{offset:(l-1)*a,limit:a},render:({reminders:i,totalCount:s})=>{const p=s>0?`Reminders (${s})`:void 0,c="Review reminders created from notes and mark them complete here";return i.length===0?e.jsx(w,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsx(S,{title:"No upcoming reminders",description:"Add a reminder inside any note to see it here"})}):e.jsx(w,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"flex flex-col gap-2.5",children:i.map(n=>e.jsx(B,{reminder:n,onUpdate:f,onDelete:j},n.id))}),s&&a<s&&e.jsx(C,{page:l,last:Math.ceil(s/a),onChange:n=>{t({search:x=>({...x,page:n})})}})]})})}})})}export{K as default};
1
+ import{j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{D as k,T as h,F as H,G as M,Q as E,P as w,E as S,k as L,l as o,h as O}from"./note.api-D3oJmG3q.js";import{N as C,R as U}from"./url-9nrbQs7Z.js";import{u as I,R as P}from"./useReminderMutate-BrGO9M0o.js";import{f as Y,d as u}from"./time-D5LRMumI.js";const g={high:"bg-priority-high",medium:"bg-priority-medium",low:"bg-priority-low"};function B({reminder:t,onUpdate:l,onDelete:f}){const j=y=>{const r=u(Number(y)),m=u();return r.isSame(m,"day")?`Today at ${r.format("HH:mm")}`:r.isSame(m.add(1,"day"),"day")?`Tomorrow at ${r.format("HH:mm")}`:r.format("YYYY-MM-DD HH:mm")},a=y=>{const r=u(Number(y)),m=u(),N=r.diff(m,"hour"),b=r.diff(m,"minute")%60;return N<0||b<0?"Overdue":N===0?`${b}m remaining`:`${N}h ${b}m remaining`},d=a(t.reminderDate)==="Overdue",i=t.priority||"low",s=i==="high"?"High":i==="medium"?"Medium":"Low",p=g[i],c=t.noteId.toString(),n=d?"text-fg-error":"text-fg-tertiary",x=t.content?.trim()||t.note?.title||"Untitled reminder",v=t.note?.title||"Untitled note",T=!!(t.content?.trim()&&t.note?.title),D=a(t.reminderDate),$=j(t.reminderDate);return e.jsxs("div",{className:"surface-base flex flex-col gap-2.5 px-4 py-3 sm:flex-row sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5 sm:items-center",children:[e.jsx(k,{checked:t.completed,onChange:()=>l(t.id,c,{completed:!t.completed}),size:"sm","aria-label":`Reminder: ${x}`}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(h,{as:"p",variant:"body",weight:"semibold",className:t.completed?"truncate line-through opacity-45":"truncate",children:x}),T&&e.jsx(h,{as:"div",variant:"meta",tone:"secondary",className:t.completed?"mt-0.5 truncate opacity-45":"mt-0.5 truncate",children:e.jsx(H,{to:C,params:{id:String(t.note?.id??t.noteId)},className:"transition-colors hover:text-fg-default hover:underline",children:v})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 sm:shrink-0",children:[e.jsx("span",{className:`h-3 w-3 shrink-0 rounded-full border border-border-subtle ${p}`,"aria-label":`${s} priority`,title:`${s} priority`}),e.jsx(h,{as:"span",variant:"meta",weight:"medium",tone:"secondary",className:t.completed?"opacity-45":void 0,children:$}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),e.jsx(h,{as:"span",variant:"label",weight:"medium",className:t.completed?"opacity-45":n,children:D})]}),e.jsx("div",{className:"flex items-center justify-end gap-1.5 sm:shrink-0",children:e.jsx(M,{button:e.jsx(Y,{label:"Reminder actions",iconClassName:"h-5 w-5 text-current"}),items:[{name:"Delete",onClick:()=>f(t.id,c)}]})})]})}const R=O(U),A=[{label:"High",className:g.high},{label:"Medium",className:g.medium},{label:"Low",className:g.low}];function K(){const t=R.useNavigate(),{page:l}=R.useSearch(),{onUpdate:f,onDelete:j}=I(),a=25,d=e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:A.map(({label:i,className:s})=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full border border-border-subtle ${s}`,"aria-hidden":"true"}),e.jsx(h,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:i})]},i))});return e.jsx(E,{fallback:e.jsx(w,{title:"Reminders",heading:e.jsx(o,{width:164,height:24,className:"rounded-full"}),description:e.jsx(o,{width:224,height:16,className:"rounded-full"}),headerRight:d,children:e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"})]})}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading the upcoming reminder list",resetKeys:[l,a],children:e.jsx(P,{searchParams:{offset:(l-1)*a,limit:a},render:({reminders:i,totalCount:s})=>{const p=s>0?`Reminders (${s})`:void 0,c="Review reminders created from notes and mark them complete here";return i.length===0?e.jsx(w,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsx(S,{title:"No upcoming reminders",description:"Add a reminder inside any note to see it here"})}):e.jsx(w,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"flex flex-col gap-2.5",children:i.map(n=>e.jsx(B,{reminder:n,onUpdate:f,onDelete:j},n.id))}),s&&a<s&&e.jsx(L,{page:l,last:Math.ceil(s/a),onChange:n=>{t({search:x=>({...x,page:n})})}})]})})}})})}export{K as default};