efficient-shell 4.163.0 → 4.164.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.
- package/README.md +44 -4
- package/dist/{Browser-2I27OQFE.js → Browser-AZSXQEJ2.js} +14 -14
- package/dist/Calculator-GRNWTZIZ.js +29 -0
- package/dist/ConfirmDialog-LSFNIGKM.js +1 -0
- package/dist/{CurrencyConverter-4EEIPAVX.js → CurrencyConverter-VT2SZDA3.js} +7 -7
- package/dist/{Documents-24YAA5UU.js → Documents-WIYSUFCQ.js} +12 -12
- package/dist/{Files-BU7FY2VD.js → Files-FAO4MFCO.js} +30 -30
- package/dist/{Notepad-3D4L3K5W.js → Notepad-APW5DX37.js} +11 -11
- package/dist/PdfViewer-3NWOBXPP.js +1 -0
- package/dist/{PomodoroTimer-B4OPUTJL.js → PomodoroTimer-4JBDIQZK.js} +27 -27
- package/dist/{Preview-VZSNH76G.js → Preview-FBVFDTPN.js} +24 -24
- package/dist/Sidebar-KRN5ZV3F.js +44 -0
- package/dist/{Spreadsheet-TAJ24BQS.js → Spreadsheet-IQF6QAWU.js} +12 -12
- package/dist/{Stock-VEPDDIMJ.js → Stock-NIM7MAYG.js} +3 -3
- package/dist/{Weather-KGZF4DDW.js → Weather-RLISJWFA.js} +14 -14
- package/dist/{WorldClock-UGADOCFW.js → WorldClock-G4L5OLOT.js} +6 -6
- package/dist/apps/index.js +1 -1
- package/dist/brand.css +1 -1
- package/dist/{chunk-ZAJPQAGP.js → chunk-37QZZRDT.js} +1 -1
- package/dist/{chunk-PH3PRIFP.js → chunk-4UCRT4ST.js} +5 -5
- package/dist/{chunk-GSBX7KIS.js → chunk-6NG4TM3E.js} +16 -16
- package/dist/{chunk-J5HNLMGZ.js → chunk-6ZUAHFK3.js} +11 -11
- package/dist/{chunk-2FZGALCU.js → chunk-DGWWPVEQ.js} +6 -6
- package/dist/chunk-ELSUXC3N.js +1 -0
- package/dist/chunk-HQREOTKI.js +9 -0
- package/dist/{chunk-FWY5IRGL.js → chunk-I3CQI462.js} +2 -2
- package/dist/{chunk-NLASNJNY.js → chunk-IY4CP2HO.js} +1 -1
- package/dist/{chunk-UMOVLVTC.js → chunk-J5E4VMLJ.js} +1 -1
- package/dist/chunk-L2W5XPZ3.js +1 -0
- package/dist/chunk-LZIS72CF.js +9 -0
- package/dist/{chunk-VWTYRICQ.js → chunk-MHGFTCEA.js} +498 -490
- package/dist/{chunk-E4JWTNG5.js → chunk-NNUE7M5G.js} +12 -12
- package/dist/{chunk-4GOHPACN.js → chunk-RKOTKWWU.js} +1 -1
- package/dist/{chunk-TZ2EFTST.js → chunk-SVJN7WWF.js} +8 -8
- package/dist/{chunk-6A7BN7EN.js → chunk-T7DDT2Z6.js} +3 -3
- package/dist/{chunk-TBM3ZIAN.js → chunk-TJ4YXVQQ.js} +97 -97
- package/dist/{chunk-PX435JG4.js → chunk-U7ZDZXOJ.js} +1 -1
- package/dist/{chunk-MAMJHPFN.js → chunk-XY25UBVS.js} +1 -1
- package/dist/{chunk-IJ3V2YOS.js → chunk-YLJ7AZON.js} +9 -9
- package/dist/chunk-YS57MJFM.js +1 -0
- package/dist/{chunk-WURTAA2S.js → chunk-Z43BI2JI.js} +1 -1
- package/dist/file-intake/index.js +1 -1
- package/dist/{index-JQXMH_km.d.ts → index-CFLEu3eh.d.ts} +135 -12
- package/dist/index.d.ts +11 -4
- package/dist/index.js +99 -99
- package/dist/map/index.js +6 -6
- package/dist/page-tabs/index.js +5 -5
- package/dist/pdf/index.js +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/package.json +1 -1
- package/dist/Calculator-2EB2RAT7.js +0 -29
- package/dist/ConfirmDialog-4LZXI6FM.js +0 -1
- package/dist/PdfViewer-5VBKCPCM.js +0 -1
- package/dist/Sidebar-7AY5WJZC.js +0 -44
- package/dist/chunk-A6O4Y63A.js +0 -1
- package/dist/chunk-L7ZMDZAB.js +0 -9
- package/dist/chunk-OSJ3ADF2.js +0 -1
- package/dist/chunk-QRJ2ERKR.js +0 -9
- package/dist/chunk-YJX2IWHB.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{setPdfPreview as e}from"./chunk-ESL5TDNA.js";import{toast_default as t}from"./chunk-
|
|
1
|
+
import{setPdfPreview as e}from"./chunk-ESL5TDNA.js";import{toast_default as t}from"./chunk-IY4CP2HO.js";import{setSpreadsheetPreview as n}from"./chunk-VTVSMRFX.js";var i="react-os-shell:preview-opened";async function o(o){const{filePath:a,filename:r,kind:c,onStaged:s}=o;try{const o=await fetch(`${("undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000").replace(/\/$/,"")}/api/file?path=${encodeURIComponent(a)}`,{credentials:"include"});if(!o.ok)return t.error(`Download failed (${o.status})`),!1;const d=await o.blob();if("csv"===c){const e=await d.text();n({csv:e,filename:r}),s?.("/spreadsheet")}else{const t=URL.createObjectURL(d);e({url:t,filename:r,kind:c}),s?.("/preview")}return"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(i,{detail:{filePath:a,filename:r,kind:c}})),!0}catch(e){return t.error(e?.message||"Open failed"),!1}}export{i as PREVIEW_OPENED_EVENT,o as openPreviewFile};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{forwardRef as e,useId as r}from"react";import{jsxs as
|
|
2
|
-
return
|
|
3
|
-
/* @__PURE__ */
|
|
4
|
-
/* @__PURE__ */
|
|
5
|
-
/* @__PURE__ */
|
|
1
|
+
import{forwardRef as e,useId as r}from"react";import{jsxs as o,jsx as t}from"react/jsx-runtime";var s="inline-flex items-center justify-center rounded-md font-medium transition-colors rosh-focus-ring focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-60",i={primary:"bg-blue-600 text-white shadow-sm hover:bg-blue-700 focus-visible:ring-[color:var(--rosh-focus-ring-strong)]",secondary:"border border-gray-300 bg-white text-gray-700 shadow-sm hover:bg-gray-50 focus-visible:ring-[color:var(--rosh-focus-ring)]",ghost:"text-gray-700 hover:bg-gray-100 focus-visible:ring-[color:var(--rosh-focus-ring)]","ghost-danger":"text-red-600 hover:bg-red-50 focus-visible:ring-[color:var(--rosh-focus-ring-invalid)]",danger:"bg-red-600 text-white shadow-sm hover:bg-red-700 focus-visible:ring-[color:var(--rosh-focus-ring-invalid-strong)]",link:"text-blue-600 underline-offset-4 hover:underline focus-visible:ring-[color:var(--rosh-focus-ring)]"},a={sm:"gap-1 px-2.5 py-1 text-xs",md:"gap-1.5 px-3 py-1.5 text-sm",lg:"gap-2 px-4 py-2.5 text-sm","touch-sm":"gap-1.5 h-11 px-4 text-base",touch:"gap-2 h-14 px-5 text-base","touch-lg":"gap-2 h-16 px-6 text-lg","touch-xl":"gap-3 h-20 px-8 text-2xl"},l={sm:"gap-1 text-xs",md:"gap-1.5 text-sm",lg:"gap-2 text-sm","touch-sm":"gap-1.5 text-base",touch:"gap-2 text-base","touch-lg":"gap-2 text-lg","touch-xl":"gap-3 text-2xl"},n={sm:"h-6 w-6",md:"h-8 w-8",lg:"h-10 w-10","touch-sm":"h-11 w-11",touch:"h-14 w-14","touch-lg":"h-16 w-16","touch-xl":"h-20 w-20"};function c({variant:e="primary",size:r="md",block:o=!1,className:t=""}={}){const n="link"===e;return[n?"inline-flex items-center font-medium transition-colors rosh-focus-ring focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-60":s,i[e],n?l[r]:a[r],o?"w-full":"",t].filter(Boolean).join(" ")}function g({variant:e="ghost",size:r="md",pressed:o=!1,className:t=""}={}){const a=!o||"ghost"!==e&&"secondary"!==e?i[e]:"bg-blue-50 text-blue-700 hover:bg-blue-100 focus-visible:ring-[color:var(--rosh-focus-ring)]";return[s,a,n[r],"shrink-0 p-0",t].filter(Boolean).join(" ")}function u(){/* @__PURE__ */
|
|
2
|
+
return o("svg",{className:"h-3.5 w-3.5 animate-spin",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[
|
|
3
|
+
/* @__PURE__ */t("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),
|
|
4
|
+
/* @__PURE__ */t("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]})}var d=e(function({variant:e="primary",size:s="md",loading:i=!1,leftIcon:a,rightIcon:l,block:n=!1,disabled:g,type:d="button",children:h,className:x="",disabledReason:b,...m},p){const f=r(),v=g||i,y=v&&null!=b&&""!==b,w=y?f:void 0,N=/* @__PURE__ */o("button",{ref:p,type:d,disabled:v,"aria-busy":i||void 0,"aria-describedby":w,className:c({variant:e,size:s,block:n,className:x}),...m,children:[i?/* @__PURE__ */t(u,{}):a,h,!i&&l]});return y?/* @__PURE__ */o("span",{className:n?"flex w-full flex-col gap-1":"inline-flex flex-col items-start gap-1",children:[N,
|
|
5
|
+
/* @__PURE__ */t("span",{id:w,className:"text-xs text-red-600",children:b})]}):N});export{d as Button_default,c as buttonClasses,g as iconButtonClasses};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import{toast_default as e}from"./chunk-
|
|
1
|
+
import{toast_default as e}from"./chunk-IY4CP2HO.js";import{forwardRef as t,useRef as r,useState as n,useMemo as o,useEffect as i,useImperativeHandle as a}from"react";import{jsx as l,jsxs as s,Fragment as c}from"react/jsx-runtime";var d=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000","#ffffff"],h=[{id:"system",label:"System",css:"-apple-system, system-ui, sans-serif"},{id:"serif",label:"Serif",css:'Georgia, "Times New Roman", serif'},{id:"mono",label:"Mono",css:'ui-monospace, "SF Mono", Menlo, monospace'},{id:"cursive",label:"Cursive",css:'"Brush Script MT", "Comic Sans MS", cursive'}],u=()=>Math.random().toString(36).slice(2,9),p=t(function({src:t,filename:p,onApply:x,onCancel:m},M){const N=r(null),L=r(null),D=r(null),z=r(null),[P,E]=n("select"),[I,$]=n(d[0]),[W,B]=n(4),[S,R]=n(24),[j,A]=n(h[0].id),[T,F]=n(!0),[H,U]=n(!1),[O,Z]=n(!1),[K,V]=n(null),[X,Y]=n(null),[q,G]=n(6),[_,J]=n(12),[Q,ee]=n([]),[te,re]=n(null),[ne,oe]=n(null),[ie,ae]=n(null),[le,se]=n(1),[ce,de]=n(null),[he,ue]=n(null),[pe,ye]=n(null),xe=r(null),[me,ge]=n(!1),we=o(()=>ie?{w:ie.w*le,h:ie.h*le}:null,[ie,le]),fe=we&&ne?we.w/ne.w:1,be=o(()=>Q.find(e=>e.id===te)??null,[Q,te]);i(()=>{"select"===P&&be&&("color"in be&&$(be.color),"stroke"in be&&B(be.stroke),"rect"===be.type&&J(be.radius),"text"===be.type&&(R(be.size),A(be.font),F(be.bold),U(be.italic),Z(be.underline),V(be.borderColor),Y(be.background),G(be.padding)))},[te]),i(()=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>{z.current=r,oe({w:r.naturalWidth,h:r.naturalHeight}),ee([]),re(null)},r.onerror=()=>e.error("Failed to load image"),r.src=t},[t]),i(()=>{if(!ne)return;const e=()=>{const e=N.current;if(!e)return;const t=e.getBoundingClientRect(),r=Math.max(0,t.width-32),n=Math.max(0,t.height-32);if(0===r||0===n)return;const o=ne.w/ne.h;let i=ne.w,a=ne.h;i>r&&(i=r,a=i/o),a>n&&(a=n,i=a*o),ae({w:i,h:a})};e();const t=new ResizeObserver(e);return N.current&&t.observe(N.current),()=>t.disconnect()},[ne]);const ve=o(()=>Q.filter(e=>"mosaic"===e.type),[Q]);i(()=>{const e=z.current,t=L.current;if(!e||!t||!ne)return;t.width=ne.w,t.height=ne.h;const r=t.getContext("2d");r.drawImage(e,0,0);for(const e of ve)C(r,e)},[ne,ve,ie]);const ke=e=>{const t=D.current;if(!t)return{x:0,y:0};const r=t.createSVGPoint();r.x=e.clientX,r.y=e.clientY;const n=t.getScreenCTM();if(!n)return{x:0,y:0};const o=r.matrixTransform(n.inverse());return{x:o.x,y:o.y}},Me=e=>{xe.current=e,ge(!0)};i(()=>{if(!me)return;const e=e=>{const t=xe.current;if(!t)return;const r=ke(e);if("draw"===t.kind)de(f(P,t.start,r,I,W,_));else if("pen"===t.kind){const e=t.points[t.points.length-1];(Math.abs(r.x-e.x)>1||Math.abs(r.y-e.y)>1)&&(t.points.push(r),de({id:"",type:"draw",points:t.points.slice(),color:I,stroke:W}))}else if("crop"===t.kind)ye(k(t.start,r));else if("move"===t.kind){const e=r.x-t.start.x,n=r.y-t.start.y;ee(r=>r.map(r=>r.id===t.id?b(t.original,e,n):r))}else"resize"===t.kind&&ee(e=>e.map(e=>e.id===t.id?function(e,t,r){if("arrow"===e.type)return"start"===t?{...e,x1:r.x,y1:r.y}:"end"===t?{...e,x2:r.x,y2:r.y}:e;if("text"===e.type||"draw"===e.type)return e;const n=e.x,o=e.x+e.w,i=e.y,a=e.y+e.h;let l=n,s=i,c=o,d=a;"nw"===t&&(l=r.x,s=r.y);"ne"===t&&(c=r.x,s=r.y);"se"===t&&(c=r.x,d=r.y);"sw"===t&&(l=r.x,d=r.y);const h=k({x:l,y:s},{x:c,y:d});return{...e,x:h.x,y:h.y,w:h.w,h:h.h}}(t.original,t.corner,r):e))},t=()=>{const e=xe.current;if(xe.current=null,ge(!1),"draw"===e?.kind)de(e=>{if(!e||("arrow"===(t=e).type?Math.abs(t.x2-t.x1)<4&&Math.abs(t.y2-t.y1)<4:"draw"===t.type?t.points.length<2:"w"in t&&"h"in t&&(t.w<4||t.h<4)))return null;var t;const r={...e,id:u()};return ee(e=>[...e,r]),re(r.id),E("select"),null});else if("pen"===e?.kind){if(e.points.length<2)return void de(null);const t={id:u(),type:"draw",points:e.points,color:I,stroke:W};ee(e=>[...e,t]),re(t.id),E("select"),de(null)}};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[me,P,I,W,_]);i(()=>{const e=e=>{if(!document.activeElement||!/^(INPUT|TEXTAREA)$/.test(document.activeElement.tagName))return!e.metaKey&&!e.ctrlKey||"z"!==e.key&&"Z"!==e.key||e.shiftKey?void(te&&("Delete"===e.key||"Backspace"===e.key?(e.preventDefault(),ee(e=>e.filter(e=>e.id!==te)),re(null)):"Escape"===e.key&&re(null))):(e.preventDefault(),ee(e=>e.slice(0,-1)),void re(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[te]);const Ce=e=>{const t=!{bold:T,italic:H,underline:O}[e];"bold"===e&&F(t),"italic"===e&&U(t),"underline"===e&&Z(t),te&&ee(r=>r.map(r=>r.id===te&&"text"===r.type?{...r,[e]:t}:r))},Ne=e=>{V(e),te&&ee(t=>t.map(t=>t.id===te&&"text"===t.type?{...t,borderColor:e}:t))},Le=e=>{Y(e),te&&ee(t=>t.map(t=>t.id===te&&"text"===t.type?{...t,background:e}:t))},De=e=>{if(!he)return;const t=e??he.value;if(!t.trim())return he.editingId&&ee(e=>e.filter(e=>e.id!==he.editingId)),void ue(null);if(he.editingId)ee(e=>e.map(e=>e.id===he.editingId&&"text"===e.type?{...e,text:t}:e));else{const e={id:u(),type:"text",x:he.x,y:he.y,text:t,color:I,size:S,font:j,bold:T,italic:H,underline:O,borderColor:K,background:X,padding:q};ee(t=>[...t,e]),re(e.id),E("select")}ue(null)},ze=async()=>{const e=L.current,t=D.current;if(!e||!t||!ne)return null;const r=document.createElement("canvas");r.width=ne.w,r.height=ne.h;const n=r.getContext("2d");n.drawImage(e,0,0);const o=t.cloneNode(!0);o.querySelectorAll("[data-chrome]").forEach(e=>e.remove());const i=(new XMLSerializer).serializeToString(o),a=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(a),s=new Image;return await new Promise(e=>{s.onload=()=>e(),s.onerror=()=>e(),s.src=l}),n.drawImage(s,0,0,ne.w,ne.h),URL.revokeObjectURL(l),r};a(M,()=>({save:async()=>{const t=await ze();t&&t.toBlob(t=>{if(!t)return void e.error("Failed to export");const r=URL.createObjectURL(t),n=document.createElement("a");n.href=r;const o=p.replace(/\.[^.]+$/,"");n.download=`${o}-annotated.png`,n.click(),URL.revokeObjectURL(r)},"image/png")},copy:async()=>{if(!("clipboard"in navigator)||"undefined"==typeof ClipboardItem)return void e.error("Clipboard images not supported in this browser");const t=await ze();t&&t.toBlob(async t=>{if(t)try{await navigator.clipboard.write([new ClipboardItem({"image/png":t})]),e.success("Copied to clipboard")}catch{e.error("Copy failed (clipboard permission?)")}else e.error("Failed to copy")},"image/png")}}),[ne,p]);const Pe=o(()=>[{id:"select",label:"Select / Move",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 3l7 17 2-7 7-2L5 3z"})})},{id:"draw",label:"Pen / Draw",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487z"})})},{id:"rect",label:"Rectangle",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("rect",{x:"4",y:"6",width:"16",height:"12",rx:"3"})})},{id:"circle",label:"Ellipse",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6"})})},{id:"arrow",label:"Arrow",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 19L19 5m0 0h-7m7 0v7"})})},{id:"mosaic",label:"Mosaic",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z"})})},{id:"text",label:"Text",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M12 6v14M9 20h6"})})},{id:"crop",label:"Crop",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 2v15a1 1 0 001 1h15M2 6h15a1 1 0 011 1v15"})})}],[]),Ee=e=>"p-1.5 rounded transition-colors "+(e?"bg-blue-500 text-white":"text-gray-700 hover:bg-gray-200"),Ie=be?.type??("select"===P?null:P),$e="rect"===Ie||"circle"===Ie||"arrow"===Ie||"draw"===Ie,We="rect"===Ie,Be="text"===Ie;/* @__PURE__ */
|
|
2
2
|
return s("div",{className:"flex flex-col h-full bg-gray-100",children:[
|
|
3
3
|
/* @__PURE__ */s("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-gray-200 bg-white shrink-0 flex-wrap text-[12px]",children:[Pe.map(e=>/* @__PURE__ */l("button",{onClick:()=>{E(e.id),re(null)},title:e.label,className:Ee(P===e.id),children:e.icon},e.id)),
|
|
4
4
|
/* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
5
|
-
/* @__PURE__ */l("div",{className:"flex items-center gap-1",children:d.map(e=>/* @__PURE__ */l("button",{onClick:()=>(e=>{
|
|
5
|
+
/* @__PURE__ */l("div",{className:"flex items-center gap-1",children:d.map(e=>/* @__PURE__ */l("button",{onClick:()=>(e=>{$(e),te&&ee(t=>t.map(t=>t.id!==te||"mosaic"===t.type?t:{...t,color:e}))})(e),title:e,className:"h-5 w-5 rounded-full border "+(I===e?"ring-2 ring-blue-500 ring-offset-1":"border-gray-300"),style:{background:e}},e))}),$e&&/* @__PURE__ */s(c,{children:[
|
|
6
6
|
/* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
7
7
|
/* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
|
|
8
8
|
/* @__PURE__ */l("span",{children:"Weight"}),
|
|
9
|
-
/* @__PURE__ */l("input",{type:"range",min:1,max:20,step:1,value:W,onChange:e=>{return t=Number(e.target.value),
|
|
9
|
+
/* @__PURE__ */l("input",{type:"range",min:1,max:20,step:1,value:W,onChange:e=>{return t=Number(e.target.value),B(t),void(te&&ee(e=>e.map(e=>e.id!==te?e:"rect"===e.type||"circle"===e.type||"arrow"===e.type||"draw"===e.type?{...e,stroke:t}:e)));var t},className:"w-16 accent-blue-500"}),
|
|
10
10
|
/* @__PURE__ */l("span",{className:"tabular-nums w-5 text-right",children:W})]})]}),We&&/* @__PURE__ */s(c,{children:[
|
|
11
11
|
/* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
12
12
|
/* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
|
|
13
13
|
/* @__PURE__ */l("span",{children:"Radius"}),
|
|
14
14
|
/* @__PURE__ */l("input",{type:"range",min:0,max:48,step:1,value:_,onChange:e=>{return t=Number(e.target.value),J(t),void(te&&ee(e=>e.map(e=>e.id===te&&"rect"===e.type?{...e,radius:t}:e)));var t},className:"w-16 accent-blue-500"}),
|
|
15
|
-
/* @__PURE__ */l("span",{className:"tabular-nums w-6 text-right",children:_})]})]}),
|
|
15
|
+
/* @__PURE__ */l("span",{className:"tabular-nums w-6 text-right",children:_})]})]}),Be&&/* @__PURE__ */s(c,{children:[
|
|
16
16
|
/* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
17
|
-
/* @__PURE__ */l("select",{value:
|
|
18
|
-
/* @__PURE__ */l("button",{onClick:()=>
|
|
19
|
-
/* @__PURE__ */l("button",{onClick:()=>
|
|
20
|
-
/* @__PURE__ */l("button",{onClick:()=>
|
|
17
|
+
/* @__PURE__ */l("select",{value:j,onChange:e=>{return t=e.target.value,A(t),void(te&&ee(e=>e.map(e=>e.id===te&&"text"===e.type?{...e,font:t}:e)));var t},className:"text-xs border border-gray-300 rounded px-1 py-0.5 bg-white",children:h.map(e=>/* @__PURE__ */l("option",{value:e.id,children:e.label},e.id))}),
|
|
18
|
+
/* @__PURE__ */l("button",{onClick:()=>Ce("bold"),className:Ee(T),title:"Bold",children:/* @__PURE__ */l("span",{className:"font-bold",children:"B"})}),
|
|
19
|
+
/* @__PURE__ */l("button",{onClick:()=>Ce("italic"),className:Ee(H),title:"Italic",children:/* @__PURE__ */l("span",{className:"italic",children:"I"})}),
|
|
20
|
+
/* @__PURE__ */l("button",{onClick:()=>Ce("underline"),className:Ee(O),title:"Underline",children:/* @__PURE__ */l("span",{className:"underline",children:"U"})}),
|
|
21
21
|
/* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
|
|
22
22
|
/* @__PURE__ */l("span",{children:"Size"}),
|
|
23
|
-
/* @__PURE__ */l("input",{type:"range",min:10,max:96,step:1,value:
|
|
24
|
-
/* @__PURE__ */l("span",{className:"tabular-nums w-7 text-right",children:
|
|
23
|
+
/* @__PURE__ */l("input",{type:"range",min:10,max:96,step:1,value:S,onChange:e=>{return t=Number(e.target.value),R(t),void(te&&ee(e=>e.map(e=>e.id===te&&"text"===e.type?{...e,size:t}:e)));var t},className:"w-16 accent-blue-500"}),
|
|
24
|
+
/* @__PURE__ */l("span",{className:"tabular-nums w-7 text-right",children:S})]}),
|
|
25
25
|
/* @__PURE__ */s("label",{className:"flex items-center gap-1 text-gray-600",children:[
|
|
26
26
|
/* @__PURE__ */l("span",{children:"Border"}),K?/* @__PURE__ */s(c,{children:[
|
|
27
|
-
/* @__PURE__ */l("input",{type:"color",value:K,onChange:e=>
|
|
28
|
-
/* @__PURE__ */l("button",{onClick:()=>
|
|
27
|
+
/* @__PURE__ */l("input",{type:"color",value:K,onChange:e=>Ne(e.target.value),title:"Text-box border color",className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
|
|
28
|
+
/* @__PURE__ */l("button",{onClick:()=>Ne(null),title:"Remove border",className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */l("button",{onClick:()=>Ne(I),title:"Add a border",className:"px-1.5 py-0.5 rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:"Add"})]}),
|
|
29
29
|
/* @__PURE__ */s("label",{className:"flex items-center gap-1 text-gray-600",children:[
|
|
30
30
|
/* @__PURE__ */l("span",{children:"Fill"}),X?/* @__PURE__ */s(c,{children:[
|
|
31
31
|
/* @__PURE__ */l("input",{type:"color",value:X,onChange:e=>Le(e.target.value),title:"Text-box background color",className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
|
|
@@ -42,12 +42,12 @@ return s("div",{className:"flex flex-col h-full bg-gray-100",children:[
|
|
|
42
42
|
/* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
43
43
|
/* @__PURE__ */l("button",{onClick:()=>{ee(e=>e.slice(0,-1)),re(null)},disabled:0===Q.length,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-700",children:"Undo"}),
|
|
44
44
|
/* @__PURE__ */s("div",{className:"ml-auto flex items-center gap-2",children:[pe&&/* @__PURE__ */s(c,{children:[
|
|
45
|
-
/* @__PURE__ */l("button",{onClick:()=>{if(!pe||!z.current||!ne)return;const e=pe,t=document.createElement("canvas");t.width=Math.round(e.w),t.height=Math.round(e.h);const r=t.getContext("2d"),n=document.createElement("canvas");n.width=ne.w,n.height=ne.h;const o=n.getContext("2d");o.drawImage(z.current,0,0);for(const e of ve)
|
|
45
|
+
/* @__PURE__ */l("button",{onClick:()=>{if(!pe||!z.current||!ne)return;const e=pe,t=document.createElement("canvas");t.width=Math.round(e.w),t.height=Math.round(e.h);const r=t.getContext("2d"),n=document.createElement("canvas");n.width=ne.w,n.height=ne.h;const o=n.getContext("2d");o.drawImage(z.current,0,0);for(const e of ve)C(o,e);r.drawImage(n,e.x,e.y,e.w,e.h,0,0,e.w,e.h);const i=new Image;i.onload=()=>{z.current=i,oe({w:i.naturalWidth,h:i.naturalHeight}),ee(t=>t.filter(e=>"mosaic"!==e.type).map(t=>b(t,-e.x,-e.y)).filter(e=>function(e,t,r){const n=v(e);return n.x+n.w>0&&n.y+n.h>0&&n.x<t&&n.y<r}(e,i.naturalWidth,i.naturalHeight))),ye(null)},i.src=t.toDataURL("image/png")},className:"px-2 py-1 rounded bg-blue-500 text-white hover:bg-blue-600",children:"Apply Crop"}),
|
|
46
46
|
/* @__PURE__ */l("button",{onClick:()=>ye(null),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",children:"Cancel"})]}),x&&!pe&&/* @__PURE__ */s(c,{children:[m&&/* @__PURE__ */l("button",{onClick:m,className:"px-3 py-1 rounded hover:bg-gray-200 text-gray-700 text-xs font-medium",children:"Cancel"}),
|
|
47
47
|
/* @__PURE__ */l("button",{onClick:async()=>{const t=await ze();t?t.toBlob(t=>{t?x(t):e.error("Failed to export")},"image/png"):e.error("Failed to export")},className:"px-3 py-1 rounded bg-blue-500 text-white hover:bg-blue-600 text-xs font-medium",children:"Apply"})]})]})]}),
|
|
48
|
-
/* @__PURE__ */l("div",{ref:
|
|
48
|
+
/* @__PURE__ */l("div",{ref:N,className:"flex-1 overflow-auto bg-gray-200 flex items-center justify-center p-4 relative",children:we&&ne&&/* @__PURE__ */s("div",{className:"relative shadow-lg rounded overflow-hidden bg-white shrink-0",style:{width:we.w,height:we.h},children:[
|
|
49
49
|
/* @__PURE__ */l("canvas",{ref:L,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),
|
|
50
|
-
/* @__PURE__ */s("svg",{ref:D,viewBox:`0 0 ${ne.w} ${ne.h}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",touchAction:"none",cursor:"select"===P?"default":"text"===P?"text":"crosshair"},onPointerDown:e=>{if("select"===P)return void re(null);if("text"===P){if(he)return void De();const t=ke(e);return void ue({x:t.x,y:t.y,value:""})}const t=ke(e);if("crop"!==P){if("draw"===P)return Me({kind:"pen",points:[t]}),void de({id:"",type:"draw",points:[t],color
|
|
50
|
+
/* @__PURE__ */s("svg",{ref:D,viewBox:`0 0 ${ne.w} ${ne.h}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",touchAction:"none",cursor:"select"===P?"default":"text"===P?"text":"crosshair"},onPointerDown:e=>{if("select"===P)return void re(null);if("text"===P){if(he)return void De();const t=ke(e);return void ue({x:t.x,y:t.y,value:""})}const t=ke(e);if("crop"!==P){if("draw"===P)return Me({kind:"pen",points:[t]}),void de({id:"",type:"draw",points:[t],color:I,stroke:W});de(f(P,t,t,I,W,_)),Me({kind:"draw",start:t})}else Me({kind:"crop",start:t})},children:[Q.map(e=>/* @__PURE__ */l(y,{anno:e,selected:te===e.id,zoom:le,onPointerDown:t=>((e,t)=>{"select"===P&&(e.stopPropagation(),re(t.id),Me({kind:"move",id:t.id,start:ke(e),original:t}))})(t,e),onDoubleClick:()=>{var t;"text"===(t=e).type&&ue({x:t.x,y:t.y,value:t.text,editingId:t.id})},onHandlePointerDown:(t,r)=>((e,t,r)=>{e.stopPropagation(),Me({kind:"resize",id:t.id,corner:r,start:ke(e),original:t})})(t,e,r)},e.id)),ce&&/* @__PURE__ */l(y,{anno:{...ce,id:"__preview"},preview:!0}),pe&&/* @__PURE__ */l(g,{rect:pe,imageSize:ne})]}),he&&/* @__PURE__ */l(w,{pendingText:he,color:I,size:S,font:h.find(e=>e.id===j)?.css??h[0].css,bold:T,italic:H,underline:O,borderColor:K,background:X,padding:q,scale:fe,onChange:e=>ue({...he,value:e}),onCommit:De,onCancel:()=>ue(null)})]})}),
|
|
51
51
|
/* @__PURE__ */l("div",{className:"px-3 py-1.5 border-t border-gray-200 bg-white text-[11px] text-gray-500 shrink-0",children:"select"===P?te?"Drag to move. Drag a corner to resize. Delete / Backspace removes. Click outside to deselect.":"Tap a shape to select. Double-click text to edit.":"text"===P?"Click to drop a text label.":"crop"===P?"Drag a rectangle to set the crop region.":"draw"===P?"Drag to draw freehand.":"Drag on the image to draw."})]})});function y({anno:e,selected:t,preview:r,zoom:n=1,onPointerDown:o,onDoubleClick:i,onHandlePointerDown:a}){const d=v(e),u=o?{onPointerDown:o,pointerEvents:"all",style:{cursor:"move"}}:{},p=i?{onDoubleClick:i}:{};let y;if("rect"===e.type)y=/* @__PURE__ */l("rect",{x:e.x,y:e.y,width:e.w,height:e.h,rx:e.radius,ry:e.radius,fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...u});else if("circle"===e.type)y=/* @__PURE__ */l("ellipse",{cx:e.x+e.w/2,cy:e.y+e.h/2,rx:e.w/2,ry:e.h/2,fill:"none",stroke:e.color,strokeWidth:e.stroke,...u});else if("arrow"===e.type)y=/* @__PURE__ */l(m,{anno:e,interactive:u});else if("draw"===e.type)y=/* @__PURE__ */l("path",{d:M(e.points),fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...u});else if("mosaic"===e.type)y=/* @__PURE__ */l("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"rgba(0,0,0,0.001)",stroke:t?"#3b82f6":"none",strokeWidth:t?2:0,strokeDasharray:t?"6,4":void 0,...u});else{const t=h.find(t=>t.id===e.font)?.css??h[0].css,r=e.padding??0,n=!!e.borderColor||!!e.background,o=v(e),i=e.borderColor?Math.max(1,Math.round(e.size/12)):0;y=/* @__PURE__ */s("g",{...u,...p,children:[n&&/* @__PURE__ */l("rect",{x:o.x-r,y:o.y-r,width:Math.max(0,o.w)+2*r,height:Math.max(0,o.h)+2*r,rx:Math.min(8,r),ry:Math.min(8,r),fill:e.background??"none",stroke:e.borderColor??"none",strokeWidth:i}),
|
|
52
52
|
/* @__PURE__ */l("text",{x:e.x,y:e.y+e.size,fill:e.color,fontSize:e.size,fontWeight:e.bold?700:400,fontStyle:e.italic?"italic":"normal",textDecoration:e.underline?"underline":void 0,fontFamily:t,style:{userSelect:"none"},children:e.text.split("\n").map((t,r)=>/* @__PURE__ */l("tspan",{x:e.x,dy:0===r?0:1.2*e.size,children:t},r))})]})}/* @__PURE__ */
|
|
53
53
|
return s("g",{children:[y,t&&!r&&/* @__PURE__ */s(c,{children:[
|
|
@@ -66,4 +66,4 @@ return s("g",{...t,children:[
|
|
|
66
66
|
return s("g",{pointerEvents:"none",children:[
|
|
67
67
|
/* @__PURE__ */l("path",{d:`M0,0 H${t.w} V${t.h} H0 Z M${e.x},${e.y} V${e.y+e.h} H${e.x+e.w} V${e.y} Z`,fill:"rgba(0,0,0,0.45)",fillRule:"evenodd"}),
|
|
68
68
|
/* @__PURE__ */l("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"none",stroke:"#fff",strokeWidth:2,strokeDasharray:"8,6"})]})}function w({pendingText:e,color:t,size:n,font:o,bold:a,italic:s,underline:c,borderColor:d,background:h,padding:u,scale:p,onChange:y,onCommit:x,onCancel:m}){const g=r(null);i(()=>{const e=requestAnimationFrame(()=>{g.current?.focus(),g.current?.select?.()});return()=>cancelAnimationFrame(e)},[]);const w=()=>x(g.current?.value),f=d?Math.max(1,Math.round(n/12)):0;/* @__PURE__ */
|
|
69
|
-
return l("div",{style:{position:"absolute",left:e.x*p+"px",top:e.y*p+"px",transform:"translateY(-2px)",zIndex:5},onPointerDown:e=>e.stopPropagation(),children:/* @__PURE__ */l("textarea",{ref:g,value:e.value,onChange:e=>y(e.target.value),onBlur:w,onKeyDown:e=>{"Escape"===e.key?(e.preventDefault(),m()):"Enter"!==e.key||e.shiftKey||(e.preventDefault(),w())},placeholder:"Type then Enter…",rows:1,className:"outline-none resize-none shadow-md",style:{color:t,fontSize:n*p+"px",fontFamily:o,fontWeight:a?700:400,fontStyle:s?"italic":"normal",textDecoration:c?"underline":void 0,minWidth:80,padding:u*p+"px",borderRadius:Math.min(8,u)*p+"px",border:d?`${f*p}px solid ${d}`:"1px dashed #60a5fa",background:h??"rgba(255,255,255,0.95)"}})})}function f(e,t,r,n,o,i){if("rect"===e){const e=k(t,r);return{id:"",type:"rect",x:e.x,y:e.y,w:e.w,h:e.h,color:n,stroke:o,radius:i}}if("circle"===e){const e=k(t,r);return{id:"",type:"circle",x:e.x,y:e.y,w:e.w,h:e.h,color:n,stroke:o}}if("arrow"===e)return{id:"",type:"arrow",x1:t.x,y1:t.y,x2:r.x,y2:r.y,color:n,stroke:o};if("mosaic"===e){const e=k(t,r);return{id:"",type:"mosaic",x:e.x,y:e.y,w:e.w,h:e.h}}return null}function b(e,t,r){return"arrow"===e.type?{...e,x1:e.x1+t,y1:e.y1+r,x2:e.x2+t,y2:e.y2+r}:"draw"===e.type?{...e,points:e.points.map(e=>({x:e.x+t,y:e.y+r}))}:(e.type,{...e,x:e.x+t,y:e.y+r})}function v(e){if("arrow"===e.type){return{x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),w:Math.abs(e.x2-e.x1),h:Math.abs(e.y2-e.y1)}}if("draw"===e.type){if(0===e.points.length)return{x:0,y:0,w:0,h:0};let t=e.points[0].x,r=e.points[0].x,n=e.points[0].y,o=e.points[0].y;for(const i of e.points)i.x<t&&(t=i.x),i.x>r&&(r=i.x),i.y<n&&(n=i.y),i.y>o&&(o=i.y);return{x:t,y:n,w:r-t,h:o-n}}if("text"===e.type){const t=e.text.split("\n"),r=t.reduce((e,t)=>Math.max(e,t.length),0);return{x:e.x,y:e.y,w:r*e.size*.55,h:t.length*e.size*1.2}}return{x:e.x,y:e.y,w:e.w,h:e.h}}function k(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}}function M(e){if(0===e.length)return"";let t=`M ${e[0].x} ${e[0].y}`;for(let r=1;r<e.length;r++)t+=` L ${e[r].x} ${e[r].y}`;return t}function
|
|
69
|
+
return l("div",{style:{position:"absolute",left:e.x*p+"px",top:e.y*p+"px",transform:"translateY(-2px)",zIndex:5},onPointerDown:e=>e.stopPropagation(),children:/* @__PURE__ */l("textarea",{ref:g,value:e.value,onChange:e=>y(e.target.value),onBlur:w,onKeyDown:e=>{"Escape"===e.key?(e.preventDefault(),m()):"Enter"!==e.key||e.shiftKey||(e.preventDefault(),w())},placeholder:"Type then Enter…",rows:1,className:"outline-none resize-none shadow-md",style:{color:t,fontSize:n*p+"px",fontFamily:o,fontWeight:a?700:400,fontStyle:s?"italic":"normal",textDecoration:c?"underline":void 0,minWidth:80,padding:u*p+"px",borderRadius:Math.min(8,u)*p+"px",border:d?`${f*p}px solid ${d}`:"1px dashed #60a5fa",background:h??"rgba(255,255,255,0.95)"}})})}function f(e,t,r,n,o,i){if("rect"===e){const e=k(t,r);return{id:"",type:"rect",x:e.x,y:e.y,w:e.w,h:e.h,color:n,stroke:o,radius:i}}if("circle"===e){const e=k(t,r);return{id:"",type:"circle",x:e.x,y:e.y,w:e.w,h:e.h,color:n,stroke:o}}if("arrow"===e)return{id:"",type:"arrow",x1:t.x,y1:t.y,x2:r.x,y2:r.y,color:n,stroke:o};if("mosaic"===e){const e=k(t,r);return{id:"",type:"mosaic",x:e.x,y:e.y,w:e.w,h:e.h}}return null}function b(e,t,r){return"arrow"===e.type?{...e,x1:e.x1+t,y1:e.y1+r,x2:e.x2+t,y2:e.y2+r}:"draw"===e.type?{...e,points:e.points.map(e=>({x:e.x+t,y:e.y+r}))}:(e.type,{...e,x:e.x+t,y:e.y+r})}function v(e){if("arrow"===e.type){return{x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),w:Math.abs(e.x2-e.x1),h:Math.abs(e.y2-e.y1)}}if("draw"===e.type){if(0===e.points.length)return{x:0,y:0,w:0,h:0};let t=e.points[0].x,r=e.points[0].x,n=e.points[0].y,o=e.points[0].y;for(const i of e.points)i.x<t&&(t=i.x),i.x>r&&(r=i.x),i.y<n&&(n=i.y),i.y>o&&(o=i.y);return{x:t,y:n,w:r-t,h:o-n}}if("text"===e.type){const t=e.text.split("\n"),r=t.reduce((e,t)=>Math.max(e,t.length),0);return{x:e.x,y:e.y,w:r*e.size*.55,h:t.length*e.size*1.2}}return{x:e.x,y:e.y,w:e.w,h:e.h}}function k(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}}function M(e){if(0===e.length)return"";let t=`M ${e[0].x} ${e[0].y}`;for(let r=1;r<e.length;r++)t+=` L ${e[r].x} ${e[r].y}`;return t}function C(e,t){const r=Math.round(Math.max(0,t.x)),n=Math.round(Math.max(0,t.y)),o=Math.round(Math.min(e.canvas.width-r,t.w)),i=Math.round(Math.min(e.canvas.height-n,t.h));if(o<2||i<2)return;const a=e.getImageData(r,n,o,i);for(let e=0;e<i;e+=12)for(let t=0;t<o;t+=12){let r=0,n=0,l=0,s=0,c=0;const d=Math.min(12,o-t),h=Math.min(12,i-e);for(let i=0;i<h;i++)for(let h=0;h<d;h++){const d=4*((e+i)*o+(t+h));r+=a.data[d],n+=a.data[d+1],l+=a.data[d+2],s+=a.data[d+3],c++}r=Math.round(r/c),n=Math.round(n/c),l=Math.round(l/c),s=Math.round(s/c);for(let i=0;i<h;i++)for(let c=0;c<d;c++){const d=4*((e+i)*o+(t+c));a.data[d]=r,a.data[d+1]=n,a.data[d+2]=l,a.data[d+3]=s}}e.putImageData(a,r,n)}export{p as ImageAnnotator_default};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import{toast_default as e}from"./chunk-
|
|
2
|
-
/* @__PURE__ */c("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-gray-200 bg-gray-50 px-3 py-2 text-xs",children:e})}"undefined"==typeof window||s.GlobalWorkerOptions.workerSrc||(s.GlobalWorkerOptions.workerSrc=`https://unpkg.com/pdfjs-dist@${s.version}/build/pdf.worker.min.mjs`);var p={"jbig2.wasm":new URL("pdfjs-dist/wasm/jbig2.wasm",import.meta.url).href,"openjpeg.wasm":new URL("pdfjs-dist/wasm/openjpeg.wasm",import.meta.url).href},f=class{async fetch({kind:e,filename:t}){if("wasmUrl"!==e)throw new Error(`Ensure that the \`${e}\` API parameter is provided.`);const n=p[t];if(!n)throw new Error(`No bundled pdf.js wasm module for "${t}".`);const r=await fetch(n);if(!r.ok)throw new Error(`Unable to load wasm data at: ${n}`);const a=new Uint8Array(await r.arrayBuffer());if(!function(e){return e.length>=4&&0===e[0]&&97===e[1]&&115===e[2]&&109===e[3]}(a))throw u(n,t,a);return a}};function g(e){const t=e||("undefined"!=typeof window?window.__REACT_OS_SHELL_PDF_WASM__:void 0);return"string"==typeof t&&t?{wasmUrl:t.endsWith("/")?t:`${t}/`}:{BinaryDataFactory:f}}var w=[50,75,100,125,150,200,300,400];function v(e,t,n){const r=(t.width-40)/n.width,a="page"===e?Math.min(r,(t.height-40)/n.height):r;return Math.min(Math.max(a,.3),4)}function y({url:n,filename:r,fit:l="width",onDownload:u,onEmail:h,workerSrc:p,wasmUrl:f}){const y=t().pdf,b=a(null),x=a(null),k=a(null),[C,L]=o(null),[N
|
|
1
|
+
import{toast_default as e}from"./chunk-IY4CP2HO.js";import{useShellStrings as t}from"./chunk-YS57MJFM.js";import{createContext as n,useContext as r,useRef as a,useState as o,useEffect as i}from"react";import*as s from"pdfjs-dist";import{createPortal as l}from"react-dom";import{jsx as c,jsxs as d}from"react/jsx-runtime";function u(e,t,n){return new Error(`The response for ${e} is not a WebAssembly module (got ${function(e){if(0===e.length)return"an empty response";const t=Array.from(e.subarray(0,24)).map(e=>e>=32&&e<127?String.fromCharCode(e):".").join("");return`${e.length} bytes starting "${t}"`}(n)}). The bundler did not emit "${t}" as an asset, and the host answered with a fallback page instead of a 404. Serve pdfjs-dist/wasm/ yourself and point window.__REACT_OS_SHELL_PDF_WASM__ at it.`)}var h=n(null);function m({children:e}){const t=r(h);return t?l(e,t):
|
|
2
|
+
/* @__PURE__ */c("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-gray-200 bg-gray-50 px-3 py-2 text-xs",children:e})}"undefined"==typeof window||s.GlobalWorkerOptions.workerSrc||(s.GlobalWorkerOptions.workerSrc=`https://unpkg.com/pdfjs-dist@${s.version}/build/pdf.worker.min.mjs`);var p={"jbig2.wasm":new URL("pdfjs-dist/wasm/jbig2.wasm",import.meta.url).href,"openjpeg.wasm":new URL("pdfjs-dist/wasm/openjpeg.wasm",import.meta.url).href},f=class{async fetch({kind:e,filename:t}){if("wasmUrl"!==e)throw new Error(`Ensure that the \`${e}\` API parameter is provided.`);const n=p[t];if(!n)throw new Error(`No bundled pdf.js wasm module for "${t}".`);const r=await fetch(n);if(!r.ok)throw new Error(`Unable to load wasm data at: ${n}`);const a=new Uint8Array(await r.arrayBuffer());if(!function(e){return e.length>=4&&0===e[0]&&97===e[1]&&115===e[2]&&109===e[3]}(a))throw u(n,t,a);return a}};function g(e){const t=e||("undefined"!=typeof window?window.__REACT_OS_SHELL_PDF_WASM__:void 0);return"string"==typeof t&&t?{wasmUrl:t.endsWith("/")?t:`${t}/`}:{BinaryDataFactory:f}}var w=[50,75,100,125,150,200,300,400];function v(e,t,n){const r=(t.width-40)/n.width,a="page"===e?Math.min(r,(t.height-40)/n.height):r;return Math.min(Math.max(a,.3),4)}function y({url:n,filename:r,fit:l="width",onDownload:u,onEmail:h,workerSrc:p,wasmUrl:f}){const y=t().pdf,b=a(null),x=a(null),k=a(null),[C,L]=o(null),[M,N]=o(1),[j,E]=o(0),[z,A]=o(1),[P,_]=o(!0),[D,S]=o(!0),W=a(y.loadFailed);W.current=y.loadFailed,i(()=>{let t=!1;return S(!0),N(1),p&&(s.GlobalWorkerOptions.workerSrc=p),s.getDocument({url:n,...g(f)}).promise.then(e=>{t||(L(e),E(e.numPages),S(!1))}).catch(()=>{t||(e.error(W.current),S(!1))}),()=>{t=!0}},[n,p,f]),i(()=>{if(!C||!P||!k.current)return;const e=()=>{const e=k.current;e&&C.getPage(M).then(t=>{if(!k.current)return;const n=t.getViewport({scale:1}),r=v(l,{width:e.clientWidth,height:e.clientHeight},{width:n.width,height:n.height});A(e=>Math.abs(e-r)<.005?e:r)})};e();const t=new ResizeObserver(e);return t.observe(k.current),()=>t.disconnect()},[C,M,P,l]),i(()=>{if(!C||!b.current)return;let e=!1,t=null,n=null;return C.getPage(M).then(r=>{if(e||!b.current)return;const a=r.getViewport({scale:z}),o=b.current;o.width=a.width,o.height=a.height,o.style.width=`${a.width}px`,o.style.height=`${a.height}px`;const i=o.getContext("2d");t=r.render({canvas:o,canvasContext:i,viewport:a}),t.promise.catch(()=>{});const l=x.current;l&&(l.replaceChildren(),l.style.setProperty("--total-scale-factor",String(a.scale)),n=new s.TextLayer({textContentSource:r.streamTextContent(),container:l,viewport:a}),n.render().then(()=>{if(e)return;const t=document.createElement("div");t.className="endOfContent",l.append(t)}).catch(()=>{}))}),()=>{e=!0,t?.cancel(),n?.cancel()}},[C,M,z]),i(()=>{const e=()=>x.current?.classList.remove("selecting");return window.addEventListener("pointerup",e),()=>window.removeEventListener("pointerup",e)},[]);const $="page"===l?y.fitPage:y.fitWidth,H="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1";/* @__PURE__ */
|
|
3
3
|
return d("div",{className:"flex flex-col h-full",children:[
|
|
4
4
|
/* @__PURE__ */d(m,{children:[
|
|
5
|
-
/* @__PURE__ */c("button",{type:"button","aria-label":y.previousPage,onClick:()=>
|
|
6
|
-
/* @__PURE__ */c("span",{className:"text-gray-600 font-medium tabular-nums whitespace-nowrap",children:y.pageOf(
|
|
7
|
-
/* @__PURE__ */c("button",{type:"button","aria-label":y.nextPage,onClick:()=>
|
|
5
|
+
/* @__PURE__ */c("button",{type:"button","aria-label":y.previousPage,onClick:()=>N(e=>Math.max(1,e-1)),disabled:M<=1,className:"px-1 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",children:/* @__PURE__ */c("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}),
|
|
6
|
+
/* @__PURE__ */c("span",{className:"text-gray-600 font-medium tabular-nums whitespace-nowrap",children:y.pageOf(M,j)}),
|
|
7
|
+
/* @__PURE__ */c("button",{type:"button","aria-label":y.nextPage,onClick:()=>N(e=>Math.min(j,e+1)),disabled:M>=j,className:"px-1 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",children:/* @__PURE__ */c("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})}),
|
|
8
8
|
/* @__PURE__ */c("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
9
|
-
/* @__PURE__ */c("button",{type:"button","aria-label":y.zoomOut,title:y.zoomOut,onClick:()=>{
|
|
10
|
-
/* @__PURE__ */d("select",{value:
|
|
11
|
-
/* @__PURE__ */c("option",{value:"fit",children:$}),!
|
|
12
|
-
/* @__PURE__ */c("button",{type:"button","aria-label":y.zoomIn,title:y.zoomIn,onClick:()=>{
|
|
13
|
-
/* @__PURE__ */c("button",{type:"button",onClick:()=>
|
|
9
|
+
/* @__PURE__ */c("button",{type:"button","aria-label":y.zoomOut,title:y.zoomOut,onClick:()=>{_(!1),A(e=>Math.max(.3,Math.round(100*(e-.25))/100))},className:H,children:/* @__PURE__ */c("span",{"aria-hidden":"true",children:"−"})}),
|
|
10
|
+
/* @__PURE__ */d("select",{value:P?"fit":w.includes(Math.round(100*z))?Math.round(100*z):"custom",onChange:e=>{const t=e.target.value;"fit"!==t?"custom"!==t&&(_(!1),A(Number(t)/100)):_(!0)},className:"bg-transparent hover:bg-gray-200 rounded px-1 py-1 text-gray-600 tabular-nums cursor-pointer focus:outline-none focus:ring-1 focus:ring-blue-400","aria-label":y.zoom,title:y.zoom,children:[
|
|
11
|
+
/* @__PURE__ */c("option",{value:"fit",children:$}),!P&&!w.includes(Math.round(100*z))&&/* @__PURE__ */d("option",{value:"custom",children:[Math.round(100*z),"%"]}),w.map(e=>/* @__PURE__ */d("option",{value:e,children:[e,"%"]},e))]}),
|
|
12
|
+
/* @__PURE__ */c("button",{type:"button","aria-label":y.zoomIn,title:y.zoomIn,onClick:()=>{_(!1),A(e=>Math.min(4,Math.round(100*(e+.25))/100))},className:H,children:/* @__PURE__ */c("span",{"aria-hidden":"true",children:"+"})}),
|
|
13
|
+
/* @__PURE__ */c("button",{type:"button",onClick:()=>_(!0),"aria-pressed":P,className:H+(P?" bg-gray-200 text-gray-900":""),title:y.fitHint,children:y.fit}),
|
|
14
14
|
/* @__PURE__ */c("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
15
15
|
/* @__PURE__ */d("button",{type:"button",onClick:()=>{if(!C)return;const t=window.open("","_blank");if(!t)return void e.error(y.allowPopups);const n=[];for(let e=1;e<=j;e++)n.push(C.getPage(e).then(e=>{const t=e.getViewport({scale:2}),n=document.createElement("canvas");return n.width=t.width,n.height=t.height,e.render({canvas:n,canvasContext:n.getContext("2d"),viewport:t}).promise.then(()=>n.toDataURL())}));Promise.all(n).then(e=>{var n;t.document.write(`<html><head><title>${n=r,n.replace(/[&<>"]/g,e=>({"&":"&","<":"<",">":">",'"':"""}[e]))}</title><style>@media print{body{margin:0}img{width:100%;page-break-after:always}}</style></head><body>`),t.document.write(e.map(e=>`<img src="${e}"/>`).join("")),t.document.write("</body></html>"),t.document.close(),setTimeout(()=>{t.print(),t.close()},300)})},className:H,children:[
|
|
16
16
|
/* @__PURE__ */c("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.72 13.829c-.24.03-.48.062-.72.096m.72-.096a42.415 42.415 0 0110.56 0m-10.56 0L6.34 18m10.94-4.171c.24.03.48.062.72.096m-.72-.096L17.66 18m0 0l.229 2.523a1.125 1.125 0 01-1.12 1.227H7.231c-.662 0-1.18-.568-1.12-1.227L6.34 18m11.318 0h1.091A2.25 2.25 0 0021 15.75V9.456c0-1.081-.768-2.015-1.837-2.175a48.055 48.055 0 00-1.913-.247M6.34 18H5.25A2.25 2.25 0 013 15.75V9.456c0-1.081.768-2.015 1.837-2.175a48.041 48.041 0 011.913-.247m10.5 0a48.536 48.536 0 00-10.5 0m10.5 0V3.375c0-.621-.504-1.125-1.125-1.125h-8.25c-.621 0-1.125.504-1.125 1.125v3.659M18 10.5h.008v.008H18V10.5zm-3 0h.008v.008H15V10.5z"})}),y.print]}),
|
|
17
17
|
/* @__PURE__ */d("button",{type:"button",onClick:u??(()=>{const e=document.createElement("a");e.href=n,e.download=r,e.click()}),className:H,children:[
|
|
18
18
|
/* @__PURE__ */c("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"})}),y.download]}),h&&/* @__PURE__ */d("button",{type:"button",onClick:h,className:H,children:[
|
|
19
19
|
/* @__PURE__ */c("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),y.email]})]}),
|
|
20
|
-
/* @__PURE__ */c("div",{ref:k,className:"flex-1 overflow-auto bg-gray-100 outline-none",tabIndex:0,onWheel:e=>{if(!C)return;if(e.ctrlKey||e.metaKey)return;const t=k.current;if(!t)return;const n=t.scrollTop<=0,r=t.scrollTop+t.clientHeight>=t.scrollHeight-1;e.deltaY>0&&r&&
|
|
20
|
+
/* @__PURE__ */c("div",{ref:k,className:"flex-1 overflow-auto bg-gray-100 outline-none",tabIndex:0,onWheel:e=>{if(!C)return;if(e.ctrlKey||e.metaKey)return;const t=k.current;if(!t)return;const n=t.scrollTop<=0,r=t.scrollTop+t.clientHeight>=t.scrollHeight-1;e.deltaY>0&&r&&M<j?(e.preventDefault(),N(e=>Math.min(j,e+1)),requestAnimationFrame(()=>{k.current&&(k.current.scrollTop=0)})):e.deltaY<0&&n&&M>1&&(e.preventDefault(),N(e=>Math.max(1,e-1)),requestAnimationFrame(()=>{k.current&&(k.current.scrollTop=k.current.scrollHeight)}))},onKeyDown:e=>{if(!C)return;const t=(document.activeElement?.tagName||"").toLowerCase();"input"===t||"textarea"===t||document.activeElement?.isContentEditable||("PageDown"===e.key||"ArrowRight"===e.key?M<j&&(e.preventDefault(),N(e=>Math.min(j,e+1))):"PageUp"===e.key||"ArrowLeft"===e.key?M>1&&(e.preventDefault(),N(e=>Math.max(1,e-1))):"Home"===e.key?(e.preventDefault(),N(1)):"End"===e.key&&(e.preventDefault(),N(j)))},children:D?/* @__PURE__ */c("div",{className:"flex items-center justify-center h-full text-gray-500 text-sm",role:"status",children:y.loading}):/* @__PURE__ */d("div",{className:"min-h-full flex items-center justify-center p-4",children:[
|
|
21
21
|
/* @__PURE__ */c("style",{children:'\n.preview-pdf-textlayer {\n position: absolute;\n inset: 0;\n overflow: clip;\n line-height: 1;\n text-align: initial;\n text-size-adjust: none;\n forced-color-adjust: none;\n transform-origin: 0 0;\n caret-color: CanvasText;\n --min-font-size: 1;\n --text-scale-factor: calc(var(--total-scale-factor, 1) * var(--min-font-size));\n --min-font-size-inv: calc(1 / var(--min-font-size));\n}\n.preview-pdf-textlayer :is(span, br) {\n color: transparent;\n position: absolute;\n white-space: pre;\n cursor: text;\n transform-origin: 0% 0%;\n}\n.preview-pdf-textlayer > :not(.markedContent),\n.preview-pdf-textlayer .markedContent span:not(.markedContent) {\n z-index: 1;\n --font-height: 0;\n font-size: calc(var(--text-scale-factor) * var(--font-height));\n --scale-x: 1;\n --rotate: 0deg;\n transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));\n}\n.preview-pdf-textlayer .markedContent {\n display: contents;\n}\n.preview-pdf-textlayer span[role="img"] {\n user-select: none;\n cursor: default;\n}\n.preview-pdf-textlayer ::selection {\n background: rgba(0, 80, 255, 0.25);\n}\n.preview-pdf-textlayer br::selection {\n background: transparent;\n}\n.preview-pdf-textlayer .endOfContent {\n display: block;\n position: absolute;\n inset: 100% 0 0;\n z-index: 0;\n cursor: default;\n user-select: none;\n}\n.preview-pdf-textlayer.selecting .endOfContent {\n top: 0;\n}\n'}),
|
|
22
22
|
/* @__PURE__ */d("div",{className:"relative shadow-lg rounded",children:[
|
|
23
23
|
/* @__PURE__ */c("canvas",{ref:b,className:"block rounded"}),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{useCopyText as e,CopyGlyph as t}from"./chunk-6KO2U66R.js";import{PopupMenu as n,PopupMenuItem as r,PopupMenuDivider as l}from"./chunk-
|
|
1
|
+
import{useCopyText as e,CopyGlyph as t}from"./chunk-6KO2U66R.js";import{PopupMenu as n,PopupMenuItem as r,PopupMenuDivider as l}from"./chunk-HQREOTKI.js";import{useShellStrings as i}from"./chunk-YS57MJFM.js";import{useState as a,useEffect as o,Fragment as s}from"react";import{jsxs as c,jsx as d,Fragment as m}from"react/jsx-runtime";var u="outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-500";function p(){/* @__PURE__ */
|
|
2
2
|
return d("svg",{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",className:"size-3.5",children:/* @__PURE__ */d("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})})}function y({text:n,label:r,copiedLabel:l}){const{copied:i,copy:a}=e(n);/* @__PURE__ */
|
|
3
|
-
return d("button",{type:"button",tabIndex:-1,"aria-label":i?l:r,title:i?l:r,onClick:a,className:"flex size-5 shrink-0 items-center justify-center rounded text-gray-400 hover:bg-gray-200 hover:text-gray-700 @max-[10rem]:hidden",children:/* @__PURE__ */d(t,{copied:i,className:"size-3.5"})})}function h({tabs:e,activeKey:t,idFor:h,panelMounted:b,onActivate:f,onClose:g,onCloseMany:x,label:k,className:v,activeClassName:w,end:N,onIconMenu:C,menuItems:$}){const j=i().pageTabs,[z,I]=a(null),M=e.length;o(()=>{if(!t)return;const e=document.getElementById(h(t,"tab"));e?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[h,t,M]);const D=e.some(e=>e.key===t)?t:e[0]?.key,L=t=>{const n=e[(t+e.length)%e.length];n&&document.getElementById(h(n.key,"tab"))?.focus()},
|
|
3
|
+
return d("button",{type:"button",tabIndex:-1,"aria-label":i?l:r,title:i?l:r,onClick:a,className:"flex size-5 shrink-0 items-center justify-center rounded text-gray-400 hover:bg-gray-200 hover:text-gray-700 @max-[10rem]:hidden",children:/* @__PURE__ */d(t,{copied:i,className:"size-3.5"})})}function h({tabs:e,activeKey:t,idFor:h,panelMounted:b,onActivate:f,onClose:g,onCloseMany:x,label:k,className:v,activeClassName:w,end:N,onIconMenu:C,menuItems:$}){const j=i().pageTabs,[z,I]=a(null),M=e.length;o(()=>{if(!t)return;const e=document.getElementById(h(t,"tab"));e?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[h,t,M]);const D=e.some(e=>e.key===t)?t:e[0]?.key,L=t=>{const n=e[(t+e.length)%e.length];n&&document.getElementById(h(n.key,"tab"))?.focus()},_=z?e.find(e=>e.key===z.key):void 0,A=_&&$?$(_.key):[],B=_?e.indexOf(_):-1,E=e=>e.some(e=>!e.pinned),R=e=>()=>{I(null),e()};/* @__PURE__ */
|
|
4
4
|
return c("div",{className:v??"relative flex h-10 shrink-0 items-end gap-3 bg-gray-100 px-3",children:[
|
|
5
5
|
/* @__PURE__ */d("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 bottom-0 h-px bg-gray-200"}),
|
|
6
6
|
/* @__PURE__ */d("div",{role:"tablist","aria-label":k,onKeyDown:t=>{const n=e.findIndex(e=>document.getElementById(h(e.key,"tab"))===t.target);if(!(n<0)){if("ArrowRight"===t.key)L(n+1);else if("ArrowLeft"===t.key)L(n-1);else if("Home"===t.key)L(0);else if("End"===t.key)L(e.length-1);else{if("Delete"!==t.key||e[n].pinned)return;g(e[n].key)}t.preventDefault()}},className:"flex min-w-0 flex-1 items-end overflow-x-auto overflow-y-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:e.map((n,r)=>{const l=n.key===t,i=!!n.dirty,a=n.icon,o=l?w??"z-[1] border-gray-200 bg-gray-50 text-gray-900":"border-transparent text-gray-600 hover:bg-gray-200/70 hover:text-gray-900",m=r>0&&!l&&e[r-1].key!==t,x={type:"button",role:"tab",id:h(n.key,"tab"),"aria-selected":l,"aria-controls":b?.(n.key)?h(n.key,"panel"):void 0,tabIndex:n.key===D?0:-1,title:n.title,onClick:()=>f(n.key)},k={onContextMenu:e=>((e,t)=>{e.preventDefault(),I({x:e.clientX,y:e.clientY,key:t.key})})(e,n),onAuxClick:e=>((e,t)=>{1!==e.button||t.pinned||(e.preventDefault(),g(t.key))})(e,n),onMouseDown:e=>{1===e.button&&e.preventDefault()}},v=a&&
|
|
@@ -12,10 +12,10 @@ return c("div",{className:v??"relative flex h-10 shrink-0 items-end gap-3 bg-gra
|
|
|
12
12
|
/* @__PURE__ */c("button",{...x,className:`flex h-full min-w-0 flex-1 items-center gap-2 rounded-t-md pr-1 text-left ${N?"pl-1.5":"pl-3"} ${u} ${l?N?"":"@max-[5rem]:pl-2.5":"@max-[6.5rem]:pr-3 @max-[6.5rem]:group-hover:pr-1 @max-[4.5rem]:justify-center @max-[4.5rem]:px-0 @max-[4.5rem]:group-hover:pl-1.5"}`,children:[!N&&v,
|
|
13
13
|
/* @__PURE__ */d("span",{className:"min-w-0 flex-1 overflow-hidden whitespace-nowrap [mask-image:linear-gradient(to_right,#000_calc(100%-1rem),transparent)] "+(a?l?"@max-[5rem]:sr-only":"@max-[4.5rem]:sr-only":""),children:n.title})]}),l&&n.copy&&/* @__PURE__ */d(y,{text:n.copy,label:j.copy?.(n.copy)??`Copy ${n.copy}`,copiedLabel:j.copied??"Copied"}),
|
|
14
14
|
/* @__PURE__ */c("span",{className:"mr-1.5 flex size-5 shrink-0 items-center justify-center "+(l?"":"@max-[6.5rem]:hidden @max-[6.5rem]:group-hover:flex"),children:[i&&/* @__PURE__ */d("span",{role:"img","aria-label":j.unsaved,className:"size-2 rounded-full bg-gray-500 group-hover:hidden"}),
|
|
15
|
-
/* @__PURE__ */d("button",{type:"button",tabIndex:-1,"aria-label":j.closeTab?.(n.title)??`${j.close} ${n.title}`,onClick:()=>g(n.key),className:"size-5 items-center justify-center rounded text-gray-400 hover:bg-gray-200 hover:text-gray-700 "+(i?"hidden group-hover:flex":l?"flex":"flex opacity-0 group-hover:opacity-100 focus-visible:opacity-100"),children:/* @__PURE__ */d(p,{})})]})]})]},n.key)})}),N&&/* @__PURE__ */d("div",{className:"flex shrink-0 items-center gap-2 self-center",children:N}),z&&
|
|
15
|
+
/* @__PURE__ */d("button",{type:"button",tabIndex:-1,"aria-label":j.closeTab?.(n.title)??`${j.close} ${n.title}`,onClick:()=>g(n.key),className:"size-5 items-center justify-center rounded text-gray-400 hover:bg-gray-200 hover:text-gray-700 "+(i?"hidden group-hover:flex":l?"flex":"flex opacity-0 group-hover:opacity-100 focus-visible:opacity-100"),children:/* @__PURE__ */d(p,{})})]})]})]},n.key)})}),N&&/* @__PURE__ */d("div",{className:"flex shrink-0 items-center gap-2 self-center",children:N}),z&&_&&/* @__PURE__ */c(n,{portal:!0,style:{left:z.x,top:z.y},onClose:()=>I(null),children:[A.length>0&&/* @__PURE__ */c(m,{children:[A.map((e,t)=>/* @__PURE__ */c(r,{onClick:R(e.onSelect),children:[e.icon,e.label]},t)),
|
|
16
16
|
/* @__PURE__ */d(l,{})]}),
|
|
17
|
-
/* @__PURE__ */d(r,{disabled:
|
|
17
|
+
/* @__PURE__ */d(r,{disabled:_.pinned,onClick:R(()=>g(_.key)),children:j.close}),
|
|
18
18
|
/* @__PURE__ */d(l,{}),
|
|
19
|
-
/* @__PURE__ */d(r,{disabled:!E(e.filter(e=>e.key!==
|
|
20
|
-
/* @__PURE__ */d(r,{disabled:!E(e.slice(
|
|
19
|
+
/* @__PURE__ */d(r,{disabled:!E(e.filter(e=>e.key!==_.key)),onClick:R(()=>x("others",_.key)),children:j.closeOthers}),
|
|
20
|
+
/* @__PURE__ */d(r,{disabled:!E(e.slice(B+1)),onClick:R(()=>x("right",_.key)),children:j.closeRight}),
|
|
21
21
|
/* @__PURE__ */d(r,{disabled:!E(e),onClick:R(()=>x("all",null)),children:j.closeAll})]})]})}export{h as TabStrip};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useEffect as e,useLayoutEffect as n}from"react";var t=/* @__PURE__ */new Set,o=null;var r=/* @__PURE__ */new Map;function i(e,n){return t.add(e),n&&r.set(e,n),function(){if(o||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&d(e)&&(e.preventDefault(),e.stopPropagation())};document.addEventListener("keydown",e,!0),o=()=>document.removeEventListener("keydown",e,!0)}(),()=>{t.delete(e),r.delete(e),0===t.size&&o&&(o(),o=null)}}function d(e){const n=Array.from(t);for(let t=n.length-1;t>=0;t--)try{if(n[t](e))return!0}catch{}return!1}function u(e){if(!e)return!1;for(const[n,o]of r){if(!t.has(n))continue;let r;try{r=o()}catch{r=null}if(r&&r.isConnected&&!r.contains(e))return!0}return!1}var f="react-os-shell:overlay-open";function c(){"undefined"!=typeof window&&window.dispatchEvent(new Event(f))}function a(e){return"undefined"==typeof window?()=>{}:(window.addEventListener(f,e),()=>window.removeEventListener(f,e))}var w={window:50,windowStep:10,menu:400,pinnedWindow:999,overlay:9999,popup:1e4},p="undefined"==typeof document?e:n;function s(e){p(()=>{e&&c()},[e])}export{f as OVERLAY_OPEN_EVENT,w as Z_LAYERS,c as dismissPopups,u as escapeSurfaceAbove,a as onOverlayOpen,i as registerModalEscapeInterceptor,d as runEscapeInterceptors,s as useDismissPopupsOnOpen};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{onOverlayOpen as e,registerModalEscapeInterceptor as t,Z_LAYERS as n}from"./chunk-ELSUXC3N.js";import{rootIsDark as r}from"./chunk-MAIHBBWT.js";import{useHydrated as o,useBrowserLayoutEffect as i}from"./chunk-D65T4H6J.js";import{createContext as a,forwardRef as s,useContext as l,useRef as u,useId as c,useState as d,useEffect as p,useMemo as m,useCallback as h}from"react";import{createPortal as f}from"react-dom";import{jsx as g,jsxs as y,Fragment as b}from"react/jsx-runtime";function x(){try{const e=getComputedStyle(document.documentElement).getPropertyValue("--menu-opacity")?.trim();if(e)return parseFloat(e)}catch{}return.95}var w=r;function v(){try{return document.documentElement.classList.contains("rosh-reduce-transparency")}catch{return!1}}function k(e,t){return`color-mix(in srgb, ${e} ${+(Math.round(255*Math.min(1,Math.max(0,t)))/255*100).toFixed(4)}%, transparent)`}function C(e,t={}){const n=e??x();if(v()&&"light"===t.ink)return{background:"var(--rosh-glass-light-ink-surface)",border:"1px solid var(--rosh-glass-light-ink-solid-border)",boxShadow:"var(--rosh-glass-solid-shadow)"};if(v())return{background:"var(--rosh-glass-surface)",border:"1px solid var(--rosh-glass-solid-border)",boxShadow:"var(--rosh-glass-solid-shadow)"};const r="var(--rosh-glass-surface)",o="var(--rosh-glass-surface-mid)";return w()?{background:`linear-gradient(135deg in srgb, ${k(r,.85*n)} 0%, ${k(o,.75*n)} 50%, ${k(r,.85*n)} 100%)`,backdropFilter:"blur(40px) saturate(1.6)",WebkitBackdropFilter:"blur(40px) saturate(1.6)",border:"1px solid var(--rosh-glass-border)",boxShadow:"var(--rosh-glass-shadow)"}:{background:`linear-gradient(135deg in srgb, ${k(r,.85*n)} 0%, ${k(o,.65*n)} 50%, ${k(r,.75*n)} 100%)`,backdropFilter:"blur(40px) saturate(1.8)",WebkitBackdropFilter:"blur(40px) saturate(1.8)",border:"1px solid var(--rosh-glass-border)",boxShadow:"var(--rosh-glass-shadow)"}}function $(e){return v()?"var(--rosh-glass-surface)":k("var(--rosh-glass-surface)",.85*(e??x()))}var N="border-white/20",L="glass-input-bg",M=/* @__PURE__ */new Set(["text","search","url","tel","email","password","number","date","datetime-local","month","week","time"]),E="data-native-context-menu";function T(e,t){return e&&"function"==typeof e.closest?e.closest(t):null}function B(e){const t=e;if(!t||"function"!=typeof t.closest)return!1;if(T(t,`[${E}]`))return!0;if(T(t,"textarea"))return!0;if(T(t,"img, picture, canvas, video, audio"))return!0;const n=T(t,"input");if(n){const e=(n.type||"text").toLowerCase();if(M.has(e))return!0}const r=T(t,"[contenteditable]");if(r){const e=(r.getAttribute("contenteditable")||"").toLowerCase();if(""===e||"true"===e||"plaintext-only"===e)return!0}return!1}var W=/* @__PURE__ */new Set(["http:","https:","mailto:","tel:","blob:"]);function S(e,t,n){const r=T(e,"a[href]"),o=(t||"").trim(),i=function(e,t){if(e&&"#"!==e)try{const n=new URL(e,t??("undefined"!=typeof document?document.baseURI:void 0));return W.has(n.protocol)?n.href:void 0}catch{return}}(r?.getAttribute("href"),n);return{kind:o?"selection":i?"link":"default",...o?{selectionText:o}:{},...i?{linkUrl:i}:{}}}function A(e){if(e.defaultPrevented)return!0;if(e.shiftKey)return!0;if("touch"===e.pointerType)return!0;return B(("function"==typeof e.composedPath?e.composedPath()[0]:void 0)??e.target)}function F(e,t,n){return e.length===t+1&&e[t].key===n.key?e:[...e.slice(0,t),n]}function P(e,t){const n=Math.max(0,t);return e.length>n?e.slice(0,n):e}function R(e,t,n){if(0===t.length||0===e.length)return[];const r=[e];for(let e=1;e<t.length;e++){const o=r[e-1].find(n=>n.to===t[e].key),i=o?n(o):[];if(0===i.length)break;r.push(i)}return r}function H(e,t,n,r){const o=Math.max(0,r-n),i=Math.min(t,o),a=e-i/2;return a<n?n:a+i>r?Math.max(n,r-i):a}function D(e,t,n,r,o,i=!1,a=8){const s=t+o,l=e-o-n,u=l>=a;return i&&u?{left:l,flipped:!0}:s+n<=r-a?{left:s,flipped:!1}:u?{left:l,flipped:!0}:i?{left:a,flipped:!0}:{left:Math.max(a,r-a-n),flipped:!1}}function I(){try{return getComputedStyle(document.documentElement).getPropertyValue("--menu-density")?.trim()||"normal"}catch{return"normal"}}var j=a(null),z=a(!1);function U({children:r,style:i,className:a="",onClose:s,minWidth:l=180,portal:h=!1}){const y=u(null),b=c(),[x,w]=d([]),v=u();p(()=>()=>clearTimeout(v.current),[]);const k=o(),$=m(()=>{const e=()=>clearTimeout(v.current);return{id:b,depth:0,path:x,open:(t,n)=>{e(),w(e=>F(e,t,n))},scheduleClose:t=>{e(),v.current=setTimeout(()=>w(e=>P(e,t)),200)},closeBelow:t=>{e(),w(e=>P(e,t))},cancelClose:e,closeTree:()=>{e(),w([]),s?.()},root:y}},[b,x,s]);p(()=>{if(!s)return;const n=e=>{e.target.closest("[data-menu-toggle]")||e.target.closest?.(`[data-popup-menu-tree="${b}"]`)||y.current&&!y.current.contains(e.target)&&s()},r=e=>{"Escape"===e.key&&s()};window.addEventListener("pointerdown",n),window.addEventListener("keydown",r);const o=e(s),i=t(()=>!1,()=>y.current);return()=>{window.removeEventListener("pointerdown",n),window.removeEventListener("keydown",r),o(),i()}},[s,b]),p(()=>{const e=y.current;e&&requestAnimationFrame(()=>{const t=e.getBoundingClientRect();if(t.right>window.innerWidth-8){const n=t.right-window.innerWidth+8;e.style.left?e.style.left=parseFloat(e.style.left)-n+"px":e.style.right||(e.style.left=t.left-n+"px")}if(t.left<8&&(e.style.left?e.style.left="8px":e.style.right&&(e.style.right=window.innerWidth-t.width-8+"px")),t.bottom>window.innerHeight-8){const n=t.bottom-window.innerHeight+8;e.style.top?e.style.top=parseFloat(e.style.top)-n+"px":e.style.bottom?e.style.bottom="8px":e.style.top=t.top-n+"px"}t.top<8&&(e.style.top?e.style.top="8px":e.style.bottom&&(e.style.bottom=window.innerHeight-t.height-8+"px"))})});const N=I(),L=/(^|[\s:])!?z-/.test(a),M=/* @__PURE__ */g("div",{ref:y,"data-popup-menu-tree":b,className:`fixed rounded-2xl ${"tight"===N?"py-1":"large"===N?"py-2":"py-1.5"} ${a}`,onContextMenu:e=>{B(e.target)||e.preventDefault()},style:{...L?{}:{zIndex:n.menu},minWidth:l,animation:"popup-in 0.12s ease-out",...C(),...i},children:/* @__PURE__ */g(j.Provider,{value:$,children:r})});return h?k?f(M,document.body):null:M}function q(e,t,n,r=!1){const o=I(),i="tight"===o?"0.25rem":"large"===o?"0.6rem":"max(0.25rem, calc(var(--menu-padding-y, 0.5rem) - 0.1rem))";return{className:`w-full flex items-center gap-2 text-left transition-colors rounded-lg mx-auto\n ${e?"text-red-600 hover:bg-red-50":r?"bg-blue-50 text-blue-700":"text-gray-700 hover:bg-blue-50 hover:text-blue-700"}\n ${t?"opacity-40 cursor-not-allowed":""}\n ${n}`,style:{width:"calc(100% - 8px)",marginLeft:4,marginRight:4,fontSize:"var(--menu-font-size, 14px)",paddingLeft:"var(--menu-padding-x, 1rem)",paddingRight:"var(--menu-padding-x, 1rem)",paddingTop:i,paddingBottom:i}}}var K=s(function({onClick:e,children:t,className:n="",danger:r,disabled:o,role:i,tabIndex:a,id:s,onMouseEnter:u},c){const d=l(j),p=l(z),m=q(r,o,n);/* @__PURE__ */
|
|
2
|
+
return g("button",{ref:c,id:s,role:i??(p?"menuitem":void 0),tabIndex:a,onClick:()=>{e?.(),d&&d.depth>0&&d.closeTree()},onMouseEnter:()=>{d?.scheduleClose(d.depth),u?.()},disabled:o,className:m.className,style:m.style,children:t})}),V=/* @__PURE__ */g("svg",{"aria-hidden":!0,className:"h-3.5 w-3.5 shrink-0 ml-auto text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */g("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})});function J(e){let t=n.menu;for(let n=e;n&&n!==document.body;n=n.parentElement){const e=parseInt(getComputedStyle(n).zIndex,10);Number.isNaN(e)||(t=e)}return t}function O(e){return e?[...e.querySelectorAll("button:not([disabled])")].filter(t=>t.closest("[data-popup-submenu-panel]")===e):[]}function X({label:e,icon:n,children:r,disabled:o,className:a="",minWidth:s=180,maxHeight:d}){const x=l(j),w=c(),v=u(null),k=u(null),$=u(),N=u(!1),L=`${w}-menu`;p(()=>()=>clearTimeout($.current),[]);const M=x?.depth??0,E=x?.path[M],T=!!E&&E.key===w&&!o,W=h(e=>{if(!x||o||!v.current)return;clearTimeout($.current),N.current=e;const t=v.current.getBoundingClientRect(),n=v.current.closest("[data-popup-submenu-panel]")??v.current.closest("[data-popup-menu-tree]"),r=n?.getBoundingClientRect()??t,i=M>0&&(x.path[M-1]?.flipped??!1),a=D(r.left,r.right,s,window.innerWidth,4,i);x.open(M,{key:w,y:t.top,...a})},[x,o,M,w,s]),S=e=>{x?.closeBelow(M),v.current?.focus()};p(()=>{if(T)return t(e=>"Escape"===e.key&&(!(x&&x.path.length>M+1)&&(S(),!0)),()=>k.current)}),i(()=>{if(!T||!E)return;const e=()=>{const e=k.current;if(!e||!v.current)return;const t=v.current.closest("[data-popup-submenu-panel]")??v.current.closest("[data-popup-menu-tree]"),n=t?.getBoundingClientRect()??v.current.getBoundingClientRect(),r=M>0&&(x?.path[M-1]?.flipped??!1),o=e.offsetWidth||s,i=D(n.left,n.right,o,window.innerWidth,4,r,8),a=e.offsetHeight,l=H(v.current.getBoundingClientRect().top+a/2,a,8,window.innerHeight-8);e.style.left=`${i.left}px`,e.style.top=`${l}px`,e.dataset.flipped=String(i.flipped)};e();let t=0;const n=requestAnimationFrame(()=>{t=requestAnimationFrame(e)});return()=>{cancelAnimationFrame(n),cancelAnimationFrame(t)}}),p(()=>{T&&N.current&&(N.current=!1,O(k.current)[0]?.focus())},[T]);const A=m(()=>x&&{...x,depth:M+1},[x,M]);if(!x)throw new Error("PopupSubmenu must be rendered inside a PopupMenu");const F=q(!1,o,a,T),P=I();/* @__PURE__ */
|
|
3
|
+
return y(b,{children:[
|
|
4
|
+
/* @__PURE__ */y("button",{ref:v,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":T,"aria-controls":T?L:void 0,disabled:o,"data-popup-submenu-row":!0,className:F.className,style:F.style,onClick:e=>{const t=0===e.detail;T?t&&O(k.current)[0]?.focus():W(t)},onKeyDown:e=>{"ArrowRight"===e.key&&(e.preventDefault(),e.stopPropagation(),W(!0))},onMouseEnter:()=>{o||(x.cancelClose(),T?x.closeBelow(M+1):(clearTimeout($.current),$.current=setTimeout(()=>W(!1),120)))},onMouseLeave:()=>{clearTimeout($.current),x.scheduleClose(M)},children:[n,
|
|
5
|
+
/* @__PURE__ */g("span",{className:"min-w-0 flex-1 truncate",children:e}),V]}),T&&f(
|
|
6
|
+
/* @__PURE__ */g("div",{ref:k,id:L,role:"menu","data-popup-menu-tree":x.id,"data-popup-submenu-panel":!0,className:"fixed rounded-2xl overflow-x-hidden overflow-y-auto overscroll-contain "+("tight"===P?"py-1":"large"===P?"py-2":"py-1.5"),style:{left:E.left,top:E.y,minWidth:s,maxHeight:void 0===d?"calc(100vh - 16px)":`min(${"number"==typeof d?`${d}px`:d}, calc(100vh - 16px))`,zIndex:J(x.root.current)+M+1,animation:(E.flipped?"popup-submenu-in-left":"popup-submenu-in")+" 0.1s ease-out",...C()},onKeyDown:e=>{if(e.target.closest("[data-popup-submenu-panel]")!==e.currentTarget)return;const t=O(k.current),n=t.indexOf(document.activeElement),r=n=>{e.preventDefault(),e.stopPropagation(),t[(n+t.length)%t.length]?.focus()};"ArrowDown"===e.key?r(n+1):"ArrowUp"===e.key?r(n<0?t.length-1:n-1):"Home"===e.key?r(0):"End"===e.key?r(t.length-1):"ArrowLeft"===e.key&&(e.preventDefault(),e.stopPropagation(),S())},onMouseEnter:()=>{x.cancelClose(),clearTimeout($.current)},onMouseLeave:()=>x.scheduleClose(M+1),onContextMenu:e=>{B(e.target)||e.preventDefault()},children:/* @__PURE__ */g(j.Provider,{value:A,children:r})}),document.body)]})}function G(){const e=I();/* @__PURE__ */
|
|
7
|
+
return g("div",{className:`border-t ${N} ${"tight"===e?"my-0.5":"large"===e?"my-1.5":"my-1"} mx-3`})}function Q({children:e}){const t=I(),n="tight"===t?"0.125rem":"large"===t?"0.375rem":"0.25rem";/* @__PURE__ */
|
|
8
|
+
return g("div",{className:"text-xs font-medium uppercase tracking-wide",style:{color:"var(--ink-muted)",paddingLeft:"var(--menu-padding-x, 1rem)",paddingRight:"var(--menu-padding-x, 1rem)",paddingTop:n,paddingBottom:n},children:e})}function Y({d:e,className:t="h-4 w-4 text-gray-400"}){/* @__PURE__ */
|
|
9
|
+
return g("svg",{className:t,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */g("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e})})}export{N as GLASS_DIVIDER,L as GLASS_INPUT_BG,Y as MenuIcon,z as MenuSemanticsContext,E as NATIVE_MENU_ATTR,U as PopupMenu,G as PopupMenuDivider,K as PopupMenuItem,Q as PopupMenuLabel,X as PopupSubmenu,H as clampMenuTop,P as closeMenuBelow,S as describeContextTarget,$ as glassFill,C as glassStyle,q as itemLook,B as keepsNativeMenu,A as leavesContextMenuAlone,D as menuPanelLeft,F as openMenuLevel,R as resolveMenuLevels};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{toast_default as t}from"./chunk-
|
|
2
|
-
return(new Date).toISOString()}var
|
|
1
|
+
import{toast_default as t}from"./chunk-IY4CP2HO.js";import{useShellPrefs as e}from"./chunk-T7DDT2Z6.js";import{useSyncExternalStore as n,useCallback as o,useMemo as a}from"react";var r=[{id:"bell",label:"Bell",description:"Soft bell with one harmonic"},{id:"chime",label:"Chime",description:"Two-note ascending chime"},{id:"bowl",label:"Singing Bowl",description:"Long-decay meditation tone"},{id:"wind-chimes",label:"Wind Chimes",description:"Four soft tones in succession"},{id:"off",label:"Off (silent)",description:"No sound — only desktop notification"}],i=[{id:"none",label:"None"},{id:"tick-fast",label:"Ticking Fast"},{id:"tick-slow",label:"Ticking Slow"},{id:"rain",label:"Rain"},{id:"fireplace",label:"Fireplace"},{id:"white",label:"White Noise"},{id:"pink",label:"Pink Noise"},{id:"brown",label:"Brown Noise"}],c=()=>`pomodoro-${/* @__PURE__ */(new Date).toISOString().slice(0,10)}`,l={focus:1500,short:300,long:900},s="bell",u=100,d=1,f="none",m=50,h={autoStartBreaks:!1,autoStartPomodoros:!1,longBreakInterval:4},g={running:!1,remaining:l.focus,mode:"focus",total:l.focus,streak:0,count:"undefined"!=typeof localStorage?(()=>{try{return parseInt(localStorage.getItem(c())||"0",10)||0}catch{return 0}})():0},p=null,k=/* @__PURE__ */new Set,w=t=>{g={...g,...t},k.forEach(t=>t())};function M(){return g}function S(t){return k.add(t),()=>{k.delete(t)}}function b(t){l=t,g.running||g.remaining!==g.total||w({remaining:t[g.mode],total:t[g.mode]})}function y(t){s=t}function v(t,e){u=Math.max(0,Math.min(100,Math.round(t))),d=Math.max(1,Math.min(5,Math.round(e)))}function T(t){h={autoStartBreaks:!!t.autoStartBreaks,autoStartPomodoros:!!t.autoStartPomodoros,longBreakInterval:Math.max(1,Math.min(20,Math.round(t.longBreakInterval||4)))}}function A(t,e){f=t,m=Math.max(0,Math.min(100,Math.round(e))),g.running&&"focus"===g.mode?(F(),R()):"none"!==t&&0!==m||F()}function I(){g.running||(w({running:!0}),p=setInterval(C,1e3),"focus"===g.mode&&R())}function x(){(g.running||null!==p)&&(null!==p&&(clearInterval(p),p=null),w({running:!1}),F())}function B(t){x(),w({mode:t,remaining:l[t],total:l[t]})}function C(){g.remaining<=1?function(){null!==p&&(clearInterval(p),p=null);F(),P(s,{volume:u,repeat:d});const e="focus"===g.mode?"Pomodoro complete — time for a break! 🍅":"Break's over — back to work!";if("undefined"!=typeof Notification&&"granted"===Notification.permission)try{new Notification(e)}catch{}try{t.info(e)}catch{}if("focus"===g.mode){const t=g.streak+1,e=g.count+1;(t=>{try{localStorage.setItem(c(),String(t))}catch{}})(e);const n=t%h.longBreakInterval===0?"long":"short";w({running:!1,streak:t,count:e,mode:n,remaining:l[n],total:l[n]}),h.autoStartBreaks&&setTimeout(()=>I(),50)}else w({running:!1,mode:"focus",remaining:l.focus,total:l.focus}),h.autoStartPomodoros&&setTimeout(()=>I(),50)}():w({remaining:g.remaining-1})}function P(t=s,e={}){if("off"===t)return;const n=Math.max(0,Math.min(100,e.volume??100))/100;if(0===n)return;const o=Math.max(1,Math.min(5,e.repeat??1));for(let e=0;e<o;e++)setTimeout(()=>N(t,n),2500*e)}function N(t,e){try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,a=(t,n,a,r=.22,i="sine")=>{const c=o.createOscillator(),l=o.createGain();c.connect(l),l.connect(o.destination),c.type=i,c.frequency.value=t;const s=o.currentTime+n;l.gain.setValueAtTime(0,s),l.gain.linearRampToValueAtTime(r*e,s+.03),l.gain.exponentialRampToValueAtTime(1e-4,s+a),c.start(s),c.stop(s+a)};let r=2;"bell"===t?(a(880,0,1.8),a(1320,0,1.4,.1),r=2):"chime"===t?(a(659.25,0,.7),a(880,.2,1.3),r=2):"bowl"===t?(a(440,0,3.4,.22),a(660,0,3,.08),a(880,.05,2.8,.05),r=4):"wind-chimes"===t&&(a(1175,0,1.1,.16),a(880,.15,1.3,.16),a(1318,.3,1.5,.16),a(1047,.5,1.7,.13),r=3),setTimeout(()=>{try{o.close()}catch{}},1e3*r+500)}catch{}}var D=null,O={none:0,white:.3,pink:.3,brown:.3,"tick-fast":.6,"tick-slow":.6,rain:.4,fireplace:.5};function _(t,e){if("none"===e)return null;const n=t.sampleRate,o="white"===e||"pink"===e||"brown"===e?2:4,a=n*o,r=t.createBuffer(1,a,n),i=r.getChannelData(0);if("white"===e)for(let t=0;t<a;t++)i[t]=.5*(2*Math.random()-1);else if("pink"===e){let t=0,e=0,n=0,o=0,r=0,c=0,l=0;for(let s=0;s<a;s++){const a=2*Math.random()-1;t=.99886*t+.0555179*a,e=.99332*e+.0750759*a,n=.969*n+.153852*a,o=.8665*o+.3104856*a,r=.55*r+.5329522*a,c=-.7616*c-.016898*a,i[s]=.11*(t+e+n+o+r+c+l+.5362*a)*.55,l=.115926*a}}else if("brown"===e){let t=0;for(let e=0;e<a;e++){t=(t+.02*(2*Math.random()-1))/1.02,i[e]=3.5*t*.5}}else if("tick-fast"===e||"tick-slow"===e){const t="tick-fast"===e?.5:1,r=Math.floor(.045*n);for(let e=0;e<o;e+=t){const t=Math.floor(e*n);for(let e=0;e<r&&t+e<a;e++){const o=Math.exp(-e/n*180),a=2*Math.random()-1,r=Math.sin(2*Math.PI*1100*(e/n));i[t+e]+=(.7*a+.25*r)*o*.55}}}else if("rain"===e){let t=0;for(let e=0;e<a;e++){const o=2*Math.random()-1,a=o-.93*t;t=o;const r=.7+.3*Math.sin(e/n*2*Math.PI*.25);i[e]=a*r*.4}}else if("fireplace"===e){let t=0;for(let e=0;e<a;e++){t=(t+.02*(2*Math.random()-1))/1.02,i[e]=1.6*t}let e=.4*Math.random()*n;for(;e<a;){const t=Math.floor((.012+.05*Math.random())*n),o=.35+.45*Math.random(),r=Math.floor(e);for(let e=0;e<t&&r+e<a;e++){const t=Math.exp(-e/n*90);i[r+e]+=(2*Math.random()-1)*t*o}e+=(.08+.62*Math.random())*n}}return r}function R(){if(!D&&"none"!==f&&0!==m)try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;const e=new t,n=_(e,f);if(!n){try{e.close()}catch{}return}const o=e.createBufferSource();o.buffer=n,o.loop=!0;const a=e.createGain();a.gain.value=m/100*O[f],o.connect(a).connect(e.destination),o.start(),D={ctx:e,src:o,gain:a}}catch{}}function F(){if(D){try{D.src.stop()}catch{}try{D.ctx.close()}catch{}D=null}}function G(t,e){if("none"!==t&&0!==e)try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,a=_(o,t);if(!a){try{o.close()}catch{}return}const r=o.createBufferSource();r.buffer=a,r.loop=!0;const i=o.createGain();i.gain.value=e/100*O[t],r.connect(i).connect(o.destination),r.start(),setTimeout(()=>{try{r.stop()}catch{}try{o.close()}catch{}},3e3)}catch{}}var V="pomodoro_tasks",j="pomodoro_tasks_migrated";function W(){return Math.random().toString(36).slice(2,11)}function q(){/* @__PURE__ */
|
|
2
|
+
return(new Date).toISOString()}var E=null,H=[],J=!1,L=null,Y=/* @__PURE__ */new Set;function Z(){for(const t of Y)t()}function $(t){H=t,Z()}function z(){const t=E;return t?L=t.list().then(e=>{E===t&&(H=e,J=!0,Z())}).catch(()=>{E===t&&(J=!0,Z())}).finally(()=>{L=null}):(H=[],J=!0,Z(),Promise.resolve())}function K(t){E=t,H=[],J=!1,t?z():Z()}function Q(t){return Y.add(t),!E||J||L||z(),()=>{Y.delete(t)}}function U(){return H}function X(){const t=function(){const{prefs:t,save:n}=e(),r=a(()=>{const e=t.todo_tasks;return Array.isArray(e)?e:[]},[t.todo_tasks]),i=o(t=>{n({todo_tasks:t})},[n]),c=o(t=>{const e=W(),n=q(),o={done:!1,...t,name:t.name.trim(),id:e,createdAt:n,updatedAt:n};return i([...r,o]),e},[r,i]),l=o((t,e)=>{i(r.map(n=>n.id===t?{...n,...e,id:n.id,updatedAt:q()}:n))},[r,i]),s=o(t=>{i(r.filter(e=>e.id!==t))},[r,i]),u=o(t=>{const e=r.find(e=>e.id===t);e&&l(t,{done:!e.done})},[r,l]);return{tasks:r,addTask:c,updateTask:l,removeTask:s,toggleDone:u,setAllTasks:i}}(),r=n(Q,U,U),i=o(e=>{const n=E;if(!n)return t.addTask(e);const o="tmp-"+W(),a=q(),r={done:!1,...e,name:e.name.trim(),id:o,createdAt:a,updatedAt:a};return $([...H,r]),n.create({...e,name:e.name.trim()}).then(t=>$(H.map(e=>e.id===o?{...r,...t}:e))).catch(()=>$(H.filter(t=>t.id!==o))),o},[t]),c=o((e,n)=>{const o=E;if(!o)return t.updateTask(e,n);$(H.map(t=>t.id===e?{...t,...n,id:e,updatedAt:q()}:t)),o.update(e,n).catch(()=>{z()})},[t]),l=o(e=>{const n=E;if(!n)return t.removeTask(e);const o=H;$(H.filter(t=>t.id!==e)),n.remove(e).catch(()=>$(o))},[t]),s=o(e=>{if(!E)return t.toggleDone(e);const n=H.find(t=>t.id===e);n&&c(e,{done:!n.done})},[t,c]),u=o(e=>{E||t.setAllTasks(e)},[t]);return null===E?t:{tasks:r,addTask:i,updateTask:c,removeTask:l,toggleDone:s,setAllTasks:u}}function tt(t,e){try{if(localStorage.getItem(j))return;const n=localStorage.getItem(V);if(!n)return void localStorage.setItem(j,"1");const o=JSON.parse(n);if(!Array.isArray(o)||0===o.length)return localStorage.removeItem(V),void localStorage.setItem(j,"1");const a=q(),r=o.filter(t=>"string"==typeof t?.name).map(t=>({id:t.id||W(),name:String(t.name),done:!!t.done,estimated:"number"==typeof t.estimated?t.estimated:void 0,completed:"number"==typeof t.completed?t.completed:void 0,createdAt:a,updatedAt:a})),i=new Set(t.map(t=>t.id));e([...r.filter(t=>!i.has(t.id)),...t]),localStorage.removeItem(V),localStorage.setItem(j,"1")}catch{try{localStorage.setItem(j,"1")}catch{}}}export{r as ALARM_OPTIONS,i as FOCUS_SOUND_OPTIONS,M as getPomoSnapshot,tt as migratePomodoroTasksOnce,P as playAlarm,x as pomoPause,I as pomoStart,B as pomoSwitchMode,G as previewFocusSound,y as setPomoAlarm,v as setPomoAlarmConfig,T as setPomoBehaviour,b as setPomoDurations,A as setPomoFocusSound,K as setShellTodoProvider,S as subscribePomo,X as useTodoTasks};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{currentShellStrings as t}from"./chunk-
|
|
1
|
+
import{currentShellStrings as t}from"./chunk-YS57MJFM.js";var e="http://www.w3.org/2000/svg",n={},o=/* @__PURE__ */new Map;function s(t,e){let n=document.getElementById(t);return n||(n=document.createElement("div"),n.id=t,n.className=e,document.body.appendChild(n)),n}var r={success:"M5 13l4 4L19 7",error:"M6 18L18 6M6 6l12 12",warning:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z",info:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",loading:"M12 3a9 9 0 019 9",bell:"M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"};function i(t,n){const o=document.createElementNS(e,"svg");o.setAttribute("class",n),o.setAttribute("fill","none"),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("stroke","currentColor"),o.setAttribute("stroke-width","2");const s=document.createElementNS(e,"path");return s.setAttribute("stroke-linecap","round"),"loading"!==t&&s.setAttribute("stroke-linejoin","round"),s.setAttribute("d",r[t]),o.appendChild(s),o}function a(t,e){const n=document.createElement("div");return n.className=t,void 0!==e&&(n.textContent=e),n}function c(t,e,r){const c={...n,...r},l=c.placement??"top",d=c.sticky??!1,u=`${l}|${t}|${e}`;if(c.dedupe){const t=o.get(u);if(t)return t.restart(),{dismiss:t.dismiss}}"loading"!==t&&!1!==c.sound&&import("./sounds-OMHXVVQ4.js").then(e=>{"success"===t?e.playSuccess():"error"===t?e.playError():e.playNotification()}).catch(()=>{});const m="bottom"===l?s("toast-container-bottom","fixed bottom-4 left-1/2 -translate-x-1/2 z-[9999] flex flex-col-reverse gap-2 items-center pointer-events-none"):s("toast-container","fixed top-4 left-1/2 -translate-x-1/2 z-[9999] flex flex-col gap-2 items-center pointer-events-none"),p="bottom"===l?"translateY(10px)":"translateY(-10px)",f=a("pointer-events-auto cursor-pointer rosh-toast");f.style.opacity="0",f.style.transform=`${p} scale(0.95)`,f.setAttribute("role","error"===t?"alert":"status"),f.setAttribute("aria-atomic","true"),f.appendChild(i(t,`h-4 w-4 rosh-tone-${t}${"loading"===t?" animate-spin":""}`));const h=document.createElement("span");let y;h.textContent=e,f.appendChild(h),m.appendChild(f),requestAnimationFrame(()=>{f.style.opacity="1",f.style.transform="translateY(0) scale(1)"});let v=!1;const g=()=>{v||(v=!0,y&&clearTimeout(y),o.delete(u),f.style.opacity="0",f.style.transform=`${p} scale(0.95)`,setTimeout(()=>f.remove(),300))},b=c.duration??("info"===t?4500:3e3),x=()=>{y&&clearTimeout(y),d||(y=setTimeout(g,b))};return x(),f.addEventListener("mouseenter",()=>{y&&clearTimeout(y)}),f.addEventListener("mouseleave",()=>{v||x()}),f.addEventListener("click",g),o.set(u,{el:f,restart:x,dismiss:g}),{dismiss:g}}var l={success:(t,e)=>c("success",t,e),error:(t,e)=>c("error",t,e),warning:(t,e)=>c("warning",t,e),info:(t,e)=>c("info",t,e),notify:(e,o)=>function(e,o){!1!==(o?.sound??n.sound)&&import("./sounds-OMHXVVQ4.js").then(t=>t.playNotification()).catch(()=>{});const r=s("notif-container","fixed top-4 right-4 z-[9999] flex flex-col gap-3 items-end pointer-events-none"),c=a("pointer-events-auto cursor-pointer rosh-notif");c.style.opacity="0",c.style.transform="translateX(30px) scale(0.95)";const l=a("rosh-notif-badge");l.appendChild(i("bell","h-5 w-5"));const d=a("rosh-notif-body");d.append(a("rosh-notif-title",t().toast.notification),a("notif-msg rosh-notif-msg",e));const u=document.createElement("button");u.className="rosh-notif-close",u.textContent="×",c.append(l,d,u);const m=()=>{c.style.opacity="0",c.style.transform="translateX(30px) scale(0.95)",setTimeout(()=>c.remove(),300)};u.addEventListener("click",t=>{t.stopPropagation(),m()}),c.addEventListener("click",m),r.appendChild(c),requestAnimationFrame(()=>{c.style.opacity="1",c.style.transform="translateX(0) scale(1)"}),setTimeout(m,o?.duration??1e4)}(e,o),promise:(t,e,n)=>{const o=c("loading",e.loading,{...n,sticky:!0});return t.then(t=>{o.dismiss(),c("success","function"==typeof e.success?e.success(t):e.success,n)},t=>{o.dismiss(),c("error","function"==typeof e.error?e.error(t):e.error,n)}),t},configure:t=>{n={...t}}};export{l as toast_default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{useShellStrings as e}from"./chunk-
|
|
1
|
+
import{useShellStrings as e}from"./chunk-YS57MJFM.js";import{Fragment as i}from"react";import{jsx as t,jsxs as a}from"react/jsx-runtime";var n=/* @__PURE__ */t("svg",{className:"h-3.5 w-3.5 shrink-0 text-gray-300",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!0,children:/* @__PURE__ */t("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 0 1 .02-1.06L11.168 10 7.23 6.29a.75.75 0 1 1 1.04-1.08l4.5 4.25a.75.75 0 0 1 0 1.08l-4.5 4.25a.75.75 0 0 1-1.06-.02Z",clipRule:"evenodd"})}),l="inline-flex min-w-0 items-center gap-1 truncate rounded px-1 -mx-1 text-gray-500 transition-colors hover:text-gray-900 hover:underline rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)]";function s({items:s,separator:r,maxItems:c=0,className:m}){const o=e().breadcrumbs;if(0===s.length)return null;const h=r??n,d=[],u=s.length-1;if(c>0&&s.length>c&&c>=2){const e=Math.max(1,c-1);d.push({kind:"item",item:s[0],isLast:!1}),d.push({kind:"ellipsis"});for(let i=s.length-e;i<=u;i++)d.push({kind:"item",item:s[i],isLast:i===u})}else s.forEach((e,i)=>d.push({kind:"item",item:e,isLast:i===u}));/* @__PURE__ */
|
|
2
2
|
return t("nav",{"aria-label":o.label,className:`min-w-0 ${m??""}`,children:/* @__PURE__ */t("ol",{className:"flex items-center gap-1.5 text-sm",children:d.map((e,n)=>/* @__PURE__ */a(i,{children:[n>0&&/* @__PURE__ */t("li",{"aria-hidden":!0,className:"flex items-center",children:h}),
|
|
3
3
|
/* @__PURE__ */t("li",{className:"flex min-w-0 items-center",children:"ellipsis"===e.kind?/* @__PURE__ */t("span",{className:"px-0.5 text-gray-400 select-none","aria-label":o.hidden,children:"…"}):e.isLast||!e.item.href&&!e.item.onClick?/* @__PURE__ */a("span",{"aria-current":e.isLast?"page":void 0,className:"inline-flex min-w-0 items-center gap-1 truncate "+(e.isLast?"font-medium text-gray-900":"text-gray-500"),children:[e.item.icon,
|
|
4
4
|
/* @__PURE__ */t("span",{className:"truncate",children:e.item.label})]}):e.item.href?/* @__PURE__ */a("a",{href:e.item.href,onClick:e.item.onClick,className:l,children:[e.item.icon,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r="4.164.0",a=r;export{a as APP_VERSION,r as VERSION};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{glassStyle as t,glassFill as e}from"./chunk-HQREOTKI.js";import{registerModalEscapeInterceptor as o,escapeSurfaceAbove as r,onOverlayOpen as i,Z_LAYERS as n}from"./chunk-ELSUXC3N.js";import{useShellStrings as a}from"./chunk-YS57MJFM.js";import{useBrowserLayoutEffect as l,useBrowserState as h}from"./chunk-D65T4H6J.js";import{useState as s,useRef as d,useId as c,useEffect as m,isValidElement as u,cloneElement as f,useCallback as g}from"react";import{createPortal as p}from"react-dom";import{jsxs as b,jsx as x,Fragment as w}from"react/jsx-runtime";var v=448,y=240,M=8,N=()=>({left:0,right:window.innerWidth,top:0,bottom:window.innerHeight});function W(t){const e=N(),o=t?.closest?.("[data-modal-panel]");if(!o)return e;const r=o.getBoundingClientRect();return r.width<=0||r.height<=0?e:{left:Math.max(e.left,r.left),right:Math.min(e.right,r.right),top:Math.max(e.top,r.top),bottom:Math.min(e.bottom,r.bottom)}}var z=/* @__PURE__ */new Set(["hidden","clip","auto","scroll"]);var k={top:"bottom",bottom:"top",left:"right",right:"left"},C={top:["right","left"],bottom:["right","left"],left:["top","bottom"],right:["top","bottom"]};function H(t,e,o){return{top:t.top-o-(e.top+8),bottom:e.bottom-8-(t.bottom+o),left:t.left-o-(e.left+8),right:e.right-8-(t.right+o)}}var R=(t,e,o)=>Math.max(e,Math.min(t,o));function E(t,e,o){let r=NaN,i=NaN,n=NaN,a=NaN,l=NaN;const h=()=>{const e=t()?.getBoundingClientRect();if(!e)return!1;const h=o?o():NaN,s=e.left!==r||e.top!==i||e.right!==n||e.bottom!==a||h!==l&&!(Number.isNaN(h)&&Number.isNaN(l));return r=e.left,i=e.top,n=e.right,a=e.bottom,l=h,s};h();const s=()=>{h(),e()};let d=requestAnimationFrame(function t(){h()&&e(),d=requestAnimationFrame(t)});return window.addEventListener("scroll",s,!0),window.addEventListener("resize",s),()=>{cancelAnimationFrame(d),window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",s)}}function T({trigger:t,menu:e,bounds:o,align:r,side:i}){const n=H(t,o,4),a="bottom"===i?"top":"bottom",l=e.height>n[i]&&(e.height<=n[a]||n[a]>n[i])?a:i,h=Math.max(Math.min(e.height,96),n[l]),s=Math.min(e.height,h),d=R("bottom"===l?t.bottom+4:t.top-4-s,o.top+8,o.bottom-8-s),c=Math.max(0,o.right-o.left-16),m=Math.min(e.width,c);return{left:R("start"===r?t.left:t.right-m,o.left+8,o.right-8-m),top:d,side:l,maxHeight:h,maxWidth:c}}function P(t,e,o={}){const{matchTriggerWidth:r=!1,preferredMaxWidth:i=v,preferredMaxHeight:n=y,popupRef:a}=o,[h,d]=s(null);return l(()=>{if(!e)return void d(null);const o=()=>{const e=t.current,o=e?.getBoundingClientRect();if(!o)return;const l=W(e),h=l.bottom-o.bottom-4-8,s=o.top-l.top-4-8,c=h<Math.min(n,160)&&s>h,m=Math.max(96,Math.min(n,c?s:h)),u=Math.max(0,l.right-l.left-16),f={minWidth:o.width,maxWidth:Math.min(i,u),maxHeight:m};if(r){const t=Math.min(o.width,u);f.width=t,f.maxWidth=t,f.left=Math.min(Math.max(l.left+8,o.left),l.right-8-t)}else if(a&&l.right-8-o.left<f.maxWidth&&Math.min(o.right,l.right-8)-l.left-8<f.maxWidth){const t=a.current?.offsetWidth??0,e=t>0?Math.min(t,f.maxWidth):f.maxWidth;f.left=Math.max(l.left+8,Math.min(o.left,l.right-8-e))}else if(l.right-8-o.left<f.maxWidth){const t=Math.min(o.right,l.right-8);f.right=window.innerWidth-t,f.maxWidth=Math.min(f.maxWidth,Math.max(0,t-l.left-8))}else f.left=Math.max(l.left+8,o.left);c?f.bottom=window.innerHeight-o.top+4:f.top=o.bottom+4,d(f)};return o(),E(()=>t.current,o,a?()=>a.current?.offsetWidth??NaN:void 0)},[e,t,r,i,n,a]),h}function B({point:t,menu:e,bounds:o}){const r={left:t.x,right:t.x,top:t.y,bottom:t.y},i=o.right-8-t.x,n=t.x-(o.left+8);return T({trigger:r,menu:e,bounds:o,align:e.width<=i||i>=n?"start":"end",side:"bottom"})}var $={top:"bottom-full left-1/2 -translate-x-1/2 mb-3",bottom:"top-full left-1/2 -translate-x-1/2 mt-3",left:"right-full top-1/2 -translate-y-1/2 mr-3",right:"left-full top-1/2 -translate-y-1/2 ml-3"};function S({content:a,side:h="top",delay:g=200,children:w,className:v="relative inline-flex"}){const[y,M]=s(!1),[T,P]=s(null),B=d(void 0),S=d(null),I=d(null),L=c(),D=d(!1),j=()=>{window.clearTimeout(B.current),D.current||(B.current=window.setTimeout(()=>M(!0),g))},A=()=>{window.clearTimeout(B.current),M(!1)},F=()=>{D.current=!0,A()},K=()=>{D.current=!1,A()};m(()=>()=>window.clearTimeout(B.current),[]),l(()=>{if(!y)return void P(null);const t=()=>{const t=S.current,e=I.current;if(!t||!e)return;const o=W(t),r=Math.max(0,o.right-o.left-16),i=Math.max(0,o.bottom-o.top-16);e.style.maxWidth=`${r}px`,e.style.maxHeight=`${i}px`;const n=e.getBoundingClientRect();if(n.width<=0||n.height<=0)return;const a=t.getBoundingClientRect();if(!function(t){const e=t.getBoundingClientRect();if(e.width<=0&&e.height<=0&&0===e.left&&0===e.top)return null;const o=N(),r={left:Math.max(o.left,e.left),right:Math.min(o.right,e.right),top:Math.max(o.top,e.top),bottom:Math.min(o.bottom,e.bottom)};let i=getComputedStyle(t).position;for(let e=t.parentElement;e&&e!==document.documentElement&&"fixed"!==i;e=e.parentElement){const t=getComputedStyle(e);if("absolute"===i&&"static"===t.position)continue;i=t.position;const o=z.has(t.overflowX),n=z.has(t.overflowY);if(!o&&!n)continue;const a=e.getBoundingClientRect();a.width<=0&&a.height<=0||(o&&(r.left=Math.max(r.left,a.left),r.right=Math.min(r.right,a.right)),n&&(r.top=Math.max(r.top,a.top),r.bottom=Math.min(r.bottom,a.bottom)))}return r.right>=r.left&&r.bottom>=r.top?r:null}(t))return void A();const l=function(t,e,o,r,i){const n=H(t,r,i),a=t=>n[t]-("top"===t||"bottom"===t?e.height:e.width),l=[o,k[o],...C[o]],h=l.find(t=>a(t)>=0)??l.reduce((t,e)=>a(e)>a(t)?e:t),s=(t.left+t.right)/2,d=(t.top+t.bottom)/2;let c,m;switch(h){case"top":c=s-e.width/2,m=t.top-i-e.height;break;case"bottom":c=s-e.width/2,m=t.bottom+i;break;case"left":c=t.left-i-e.width,m=d-e.height/2;break;case"right":c=t.right+i,m=d-e.height/2}return{side:h,left:R(c,r.left+8,r.right-8-e.width),top:R(m,r.top+8,r.bottom-8-e.height)}}(a,n,h,o,12),s=function(t,e,o,r,i){const{side:n,left:a,top:l}=e,h=a+o.width,s=l+o.height;if({top:t.top-s,bottom:l-t.bottom,left:t.left-h,right:a-t.right}[n]<i)return null;const d=(t,e,o)=>o<2*r?e+o/2:Math.max(e+r,Math.min(t,e+o-r)),c=(t.left+t.right)/2,m=(t.top+t.bottom)/2;switch(n){case"top":return{side:n,x:d(c,a,o.width),y:s};case"bottom":return{side:n,x:d(c,a,o.width),y:l};case"left":return{side:n,x:h,y:d(m,l,o.height)};case"right":return{side:n,x:a,y:d(m,l,o.height)}}}(a,l,n,16,6),d={anchor:{left:a.left,top:a.top,width:a.width,height:a.height},left:l.left-a.left,top:l.top-a.top,maxWidth:r,maxHeight:i,side:l.side,arrow:s&&{left:s.x-a.left,top:s.y-a.top}};P(t=>{return t&&(o=d,(e=t).anchor.left===o.anchor.left&&e.anchor.top===o.anchor.top&&e.anchor.width===o.anchor.width&&e.anchor.height===o.anchor.height&&e.left===o.left&&e.top===o.top&&e.maxWidth===o.maxWidth&&e.maxHeight===o.maxHeight&&e.side===o.side&&e.arrow?.left===o.arrow?.left&&e.arrow?.top===o.arrow?.top)?t:d;var e,o})};return t(),E(()=>S.current,t)},[y,h,a]),m(()=>{if(!y)return;const t=o(t=>"Escape"===t.key&&(A(),!r(S.current))),e=i(A);return()=>{t(),e()}},[y]);const X=y?L:void 0,q=u(w)?f(w,{"aria-describedby":[w.props["aria-describedby"],X].filter(Boolean).join(" ")||void 0}):w,J=y?t():void 0,U=y?e():void 0;/* @__PURE__ */
|
|
2
|
+
return b("span",{ref:S,className:v,"aria-describedby":u(w)?void 0:X,onMouseEnter:j,onMouseLeave:K,onFocus:j,onBlur:K,onPointerDown:F,onClick:F,children:[q,y&&p(
|
|
3
|
+
/* @__PURE__ */b("span",{className:"pointer-events-none fixed left-0 top-0",style:{zIndex:n.popup,...T?.anchor},children:[
|
|
4
|
+
/* @__PURE__ */x("span",{ref:I,id:L,role:"tooltip",className:`pointer-events-none absolute z-[300] box-border w-max overflow-hidden whitespace-normal break-words text-start rounded-md px-2 py-1 text-xs text-gray-800 ${T?"":$[h]}`,style:{...J,...T&&{left:T.left,top:T.top,maxWidth:T.maxWidth,maxHeight:T.maxHeight}},children:a}),(!T||T.arrow)&&
|
|
5
|
+
/* @__PURE__ */x("span",{"aria-hidden":"true",className:"rosh-tooltip-arrow","data-side":T?.side??h,style:{background:U,"--rosh-tooltip-edge":J?.border,...T?.arrow&&{left:T.arrow.left,top:T.arrow.top}}})]}),document.body)]})}var I=(t,e,o)=>Math.min(o,Math.max(e,t));function L(t,e,o,r,i){return Math.round(I("left"===o?t+e:t-e,r,i))}function D(t,e,o){let r=null;try{r=window.localStorage.getItem(t)}catch{return null}const i=r?parseInt(r,10):NaN;return Number.isNaN(i)?null:I(i,e,o)}function j({width:t,onResize:e,side:o,min:r,max:i,defaultWidth:n=r,step:h=16,storageKey:s,label:c,hint:u,controls:f,className:p=""}){const b=a().resizeHandle,w=d(null),v=d({onResize:e,min:r,max:i,side:o});v.current={onResize:e,min:r,max:i,side:o},l(()=>{if(!s)return;const o=D(s,r,i);null!==o&&o!==t&&e(o)},[s]),m(()=>{if(!s)return;const e=window.setTimeout(()=>{try{window.localStorage.setItem(s,String(Math.round(t)))}catch{}},200);return()=>window.clearTimeout(e)},[t,s]);const y=g(()=>{w.current=null,document.body.style.removeProperty("cursor"),document.body.style.removeProperty("user-select")},[]);m(()=>y,[y]);const M=t=>{w.current&&(t.currentTarget.hasPointerCapture?.(w.current.pointer)&&t.currentTarget.releasePointerCapture(w.current.pointer),y())},N="left"===o?"right-0":"left-0";/* @__PURE__ */
|
|
6
|
+
return x(S,{content:u??b.hint,side:"left"===o?"right":"left",delay:600,className:`absolute inset-y-0 ${N} z-10 flex w-2 ${p}`.trim(),children:/* @__PURE__ */x("div",{role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":c??b.label,"aria-valuenow":Math.round(t),"aria-valuemin":r,"aria-valuemax":i,"aria-controls":f,"data-resize-handle":o,onPointerDown:e=>{0===e.button&&(e.preventDefault(),w.current={x:e.clientX,width:t,moved:!1,pointer:e.pointerId},e.currentTarget.setPointerCapture?.(e.pointerId),document.body.style.cursor="col-resize",document.body.style.userSelect="none")},onPointerMove:t=>{const e=w.current;if(!e)return;if(0===t.buttons)return void y();const o=t.clientX-e.x;if(!e.moved){if(Math.abs(o)<3)return;e.moved=!0}const{onResize:r,min:i,max:n,side:a}=v.current;r(L(e.width,o,a,i,n))},onPointerUp:M,onPointerCancel:M,onLostPointerCapture:()=>{w.current&&y()},onDoubleClick:()=>e(I(n,r,i)),onKeyDown:a=>{const l="ArrowRight"===a.key?h:"ArrowLeft"===a.key?-h:null,s=null!==l?L(t,l,o,r,i):"Home"===a.key?r:"End"===a.key?i:"Enter"===a.key?I(n,r,i):null;null!==s&&(a.preventDefault(),s!==t&&e(s))},className:"group/resize relative h-full w-full cursor-col-resize touch-none rosh-focus-ring focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[color:var(--rosh-focus-ring-solid)]",children:/* @__PURE__ */x("div",{"aria-hidden":"true",className:`absolute inset-y-0 ${N} w-px bg-transparent transition-colors group-hover/resize:bg-[var(--accent-500,var(--rosh-resize-handle))] group-focus-visible/resize:w-0.5 group-focus-visible/resize:bg-[var(--accent-500,var(--rosh-resize-handle))]`})})})}var A=(t,e,o)=>Math.min(Math.max(t,e),o);function F({sidebar:t,sidebarTop:e,sidebarBottom:o,children:r,side:i="left",storageKey:n,defaultWidth:l=256,minWidth:s=180,maxWidth:d=480,className:c="",sidebarClassName:m=("right"===i?"border-l border-gray-200 bg-gray-50":"border-r border-gray-200 bg-gray-50"),contentClassName:u="bg-white"}){const f="right"===i,g=a().sidebar,[p,v]=h(()=>(n?D(n,s,d):null)??A(l,s,d),A(l,s,d)),y=null!=e||null!=o,M=/* @__PURE__ */b("div",{className:"relative flex h-full shrink-0 flex-col",style:{width:p},children:[
|
|
7
|
+
/* @__PURE__ */b("div",{className:`flex h-full flex-col ${y?"overflow-hidden":"overflow-y-auto"} ${m}`,children:[null!=e&&/* @__PURE__ */x("div",{className:"flex shrink-0 flex-col gap-2 px-2 pt-3 pb-2",children:e}),y?/* @__PURE__ */x("div",{className:"min-h-0 flex-1 overflow-y-auto",children:t}):t,null!=o&&/* @__PURE__ */x("div",{className:"mt-auto flex shrink-0 flex-col gap-2 border-t border-gray-200 px-2 py-3",children:o})]}),
|
|
8
|
+
/* @__PURE__ */x(j,{side:i,width:p,onResize:v,min:s,max:d,defaultWidth:A(l,s,d),storageKey:n,hint:g.resize})]}),N=/* @__PURE__ */x("div",{className:`flex min-w-0 flex-1 flex-col ${u}`,children:r});/* @__PURE__ */
|
|
9
|
+
return x("div",{className:`flex h-full w-full overflow-hidden ${c}`,children:/* @__PURE__ */b(w,f?{children:[N,M]}:{children:[M,N]})})}export{y as MENU_MAX_HEIGHT,v as POPUP_MAX_WIDTH,j as ResizeHandle,F as SidebarLayout,S as Tooltip,M as VIEWPORT_MARGIN,E as followAnchor,B as placeAtPoint,T as placeMenu,W as popupBounds,P as useDropdownPosition};
|