@nice2dev/ui 1.0.8 → 1.0.11
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/dist/NiceErrorBoundary-B5nF-OVn.cjs +1 -0
- package/dist/NiceErrorBoundary-BZEHCXNM.cjs +1 -0
- package/dist/NiceErrorBoundary-D6jw6wwD.js +762 -0
- package/dist/NiceErrorBoundary-D75yr_WE.js +762 -0
- package/dist/NiceForm-BgR-m8T9.cjs +382 -0
- package/dist/NiceForm-CKoJA6NG.js +5131 -0
- package/dist/NiceForm-D7xnpnRJ.cjs +382 -0
- package/dist/NiceForm-DYKciCeR.js +5131 -0
- package/dist/NiceForm.css +1 -0
- package/dist/NiceModal-1QX7NhyH.js +95 -0
- package/dist/NiceModal-Br3J9jOV.cjs +1 -0
- package/dist/NiceModal-CAwsKVQ2.cjs +1 -0
- package/dist/NiceModal-DVAsBzHP.js +95 -0
- package/dist/NiceModuleLifecyclePanel-C9xMSjOF.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-CMrPbSw9.js +5249 -0
- package/dist/NiceModuleLifecyclePanel-D3azLDdj.js +5249 -0
- package/dist/NiceModuleLifecyclePanel-DEfAIhFf.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -0
- package/dist/NicePagination-CbB5P1N_.js +171 -0
- package/dist/NicePagination-DbE-uOkl.js +171 -0
- package/dist/NicePagination-DlealakT.cjs +1 -0
- package/dist/NicePagination-UGjzvRUS.cjs +1 -0
- package/dist/NicePinCodeInput-B8cI8zu8.js +11830 -0
- package/dist/NicePinCodeInput-BmRO9HSQ.js +11830 -0
- package/dist/NicePinCodeInput-D91uvVsF.cjs +419 -0
- package/dist/NicePinCodeInput-SGQaHvpE.cjs +419 -0
- package/dist/NicePinCodeInput.css +1 -1
- package/dist/NiceSavedQueryPanel-7nZe46t8.cjs +596 -0
- package/dist/NiceSavedQueryPanel-BSGzs7Oc.js +6449 -0
- package/dist/NiceSavedQueryPanel-CZ5bYOe_.js +6449 -0
- package/dist/NiceSavedQueryPanel-Ce2s060j.cjs +596 -0
- package/dist/NiceTabs-BeaxZzAO.js +1636 -0
- package/dist/NiceTabs-DcbYFIWR.cjs +1 -0
- package/dist/NiceTabs-DvOmxKyQ.cjs +1 -0
- package/dist/NiceTabs-DzLHzwuA.js +1636 -0
- package/dist/NiceWindow-Bga9fOkg.js +1409 -0
- package/dist/NiceWindow-CVgkxcCz.cjs +1 -0
- package/dist/NiceWindow-CxWTj5xH.cjs +1 -0
- package/dist/NiceWindow-DeC83yfE.js +1409 -0
- package/dist/charts-BAS21jkC.js +4621 -0
- package/dist/charts-BcvKWYUl.cjs +759 -0
- package/dist/charts-DShUbWrP.cjs +759 -0
- package/dist/charts-DZvmvfhM.js +4621 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +42 -45
- package/dist/charts.mjs +1 -1
- package/dist/core-B4b1BmHt.js +22177 -0
- package/dist/core-C2ZmWe_u.cjs +96 -0
- package/dist/core-CjmLbclt.cjs +96 -0
- package/dist/core-Da43q-pO.js +22094 -0
- package/dist/data-branching-CJlrg8qf.cjs +1 -0
- package/dist/data-branching-DCUwI53s.js +6121 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.d.ts +1 -38
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +206 -192
- package/dist/data.mjs +1 -1
- package/dist/devops-CXynFG3X.cjs +17 -0
- package/dist/devops-D0TfzV5B.js +7660 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.d.ts +1 -38
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +311 -393
- package/dist/editors.mjs +61 -64
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.d.ts +3 -44
- package/dist/feedback.mjs +11 -10
- package/dist/index-B8wxZ8Ps.cjs +5192 -0
- package/dist/index-DlHlXz8e.js +57319 -0
- package/dist/index-Dx726U90.cjs +5192 -0
- package/dist/index-pAuGTbuB.js +57319 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2249 -11141
- package/dist/index.mjs +880 -1018
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +7 -39
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +151 -216
- package/dist/navigation.mjs +52 -46
- package/dist/no-code-B5bzduNP.cjs +332 -0
- package/dist/no-code-D8RJ7lx0.js +7064 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.d.ts +1 -38
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +13 -45
- package/dist/overlays.mjs +243 -233
- package/package.json +5 -3
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),ne=require("./core-CjmLbclt.cjs"),t=require("react"),yt=require("./NiceForm-BgR-m8T9.cjs"),ue=require("./NiceTabs-DcbYFIWR.cjs");function bt(n,i,o){return Math.max(i,Math.min(o,n))}function Pt({h:n,s:i,v:o}){n=(n%360+360)%360;const r=o*i,d=r*(1-Math.abs(n/60%2-1)),h=o-r;let N=0,k=0,D=0;return n<60?(N=r,k=d):n<120?(N=d,k=r):n<180?(k=r,D=d):n<240?(k=d,D=r):n<300?(N=d,D=r):(N=r,D=d),{r:Math.round((N+h)*255),g:Math.round((k+h)*255),b:Math.round((D+h)*255)}}function ut({r:n,g:i,b:o}){n/=255,i/=255,o/=255;const r=Math.max(n,i,o),d=Math.min(n,i,o),h=r-d;let N=0;return h!==0&&(r===n?N=(i-o)/h%6:r===i?N=(o-n)/h+2:N=(n-i)/h+4,N=(N*60+360)%360),{h:N,s:r===0?0:h/r,v:r}}function Bt({r:n,g:i,b:o}){n/=255,i/=255,o/=255;const r=Math.max(n,i,o),d=Math.min(n,i,o),h=(r+d)/2;if(r===d)return{h:0,s:0,l:h};const N=r-d,k=h>.5?N/(2-r-d):N/(r+d);let D=0;return r===n?D=((i-o)/N+(i<o?6:0))/6:r===i?D=((o-n)/N+2)/6:D=((n-i)/N+4)/6,{h:D*360,s:k,l:h}}function We(n){const i=n.replace("#",""),o=i.length===3?i[0]+i[0]+i[1]+i[1]+i[2]+i[2]:i,r=parseInt(o,16);return{r:r>>16&255,g:r>>8&255,b:r&255}}function Ft({r:n,g:i,b:o}){return"#"+[n,i,o].map(r=>r.toString(16).padStart(2,"0")).join("")}function Ne(n){return Ft(Pt(n))}function Fe(n){return ut(We(n))}function Ht(n,i){const o=[];for(let r=0;r<i;r++){const d=i<=1?.5:r/(i-1),h=bt(n.s*(.3+d*.7),0,1),N=bt(n.v*(1.2-d*.7),0,1);o.push(Ne({h:n.h,s:h,v:N}))}return o}function pt(n,i){if(n==="custom")return[0];const o=i??30;switch(n){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-o,180+o];case"analogous":return[0,-o,o];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270]}}function Oe(n,i,o){return pt(i,o).map(r=>((n+r)%360+360)%360)}function xt({r:n,g:i,b:o}){const[r,d,h]=[n,i,o].map(N=>{const k=N/255;return k<=.03928?k/12.92:Math.pow((k+.055)/1.055,2.4)});return .2126*r+.7152*d+.0722*h}function Ue(n,i){const o=xt(We(n)),r=xt(We(i)),d=Math.max(o,r),h=Math.min(o,r);return(d+.05)/(h+.05)}function Xe(n){return n>=7?"AAA":n>=4.5?"AA":n>=3?"AA-lg":"Fail"}const Ot={"lightest-pastel":{sRange:[.1,.25],vRange:[.92,1]},"bright-pastel":{sRange:[.25,.45],vRange:[.9,1]},shiny:{sRange:[.7,.95],vRange:[.9,1]},pastel:{sRange:[.3,.55],vRange:[.75,.92]},full:{sRange:[.75,1],vRange:[.75,1]},dark:{sRange:[.6,.9],vRange:[.3,.55]},deep:{sRange:[.85,1],vRange:[.45,.65]},muted:{sRange:[.15,.35],vRange:[.5,.7]},earth:{sRange:[.3,.6],vRange:[.4,.65]}};function Ve(n,i){const o=Ot[i];return n.map(r=>{const d=(o.sRange[0]+o.sRange[1])/2,h=(o.vRange[0]+o.vRange[1])/2;return Ne({h:r,s:d,v:h})})}function En(){return Math.floor(Math.random()*360)}function Wt(n,i,o){const r=En(),d=Oe(r,n,o),h=[];for(let N=0;N<i;N++){const k=d[N%d.length],D=.55+Math.random()*.4,z=.5+Math.random()*.45;h.push(Ne({h:k+(Math.random()-.5)*8,s:D,v:z}))}return h}const Tn=({hues:n,baseHue:i,onBaseHueChange:o,mode:r,distance:d,disabled:h})=>{const V=t.useCallback(B=>{if(h)return;const C=B.currentTarget.getBoundingClientRect(),_=B.clientX-C.left-120,w=B.clientY-C.top-120,M=(Math.atan2(w,_)*180/Math.PI+360)%360;o(Math.round(M))},[120,120,h,o]),j=[];for(let B=0;B<360;B+=2){const $=(B-1)*Math.PI/180,C=(B+1)*Math.PI/180,_=Ne({h:B,s:1,v:1});j.push(e.jsx("path",{d:`M${120+55*Math.cos($)},${120+55*Math.sin($)} L${120+110*Math.cos($)},${120+110*Math.sin($)} A110,110 0 0,1 ${120+110*Math.cos(C)},${120+110*Math.sin(C)} L${120+55*Math.cos(C)},${120+55*Math.sin(C)} A55,55 0 0,0 ${120+55*Math.cos($)},${120+55*Math.sin($)} Z`,fill:_},B))}const Y=`wheel-center-${r}`,K=n.map((B,$)=>{const _=B*Math.PI/180;return e.jsx("circle",{cx:120+82.5*Math.cos(_),cy:120+82.5*Math.sin(_),r:$===0?8:6,fill:Ne({h:B,s:.85,v:.9}),stroke:$===0?"var(--bg-primary, #fff)":"var(--border-color, #ccc)",strokeWidth:$===0?3:2},$)});let te=null;if(r==="analogous"||r==="split-complementary"){const C=pt(r,d).slice(1).map((_,w)=>{const M=(i+_)*Math.PI/180;return e.jsx("line",{x1:120,y1:120,x2:120+82.5*Math.cos(M),y2:120+82.5*Math.sin(M),stroke:"rgba(255,255,255,0.3)",strokeWidth:1,strokeDasharray:"3,3"},`dline-${w}`)});te=e.jsx(e.Fragment,{children:C})}return e.jsxs("svg",{className:"nice-palette__wheel",viewBox:"0 0 240 240",width:240,height:240,onClick:V,style:{cursor:h?"default":"crosshair"},children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:Y,children:[e.jsx("stop",{offset:"0%",stopColor:"#fff"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})}),j,e.jsx("circle",{cx:120,cy:120,r:53,fill:Ne({h:i,s:.6,v:.85})}),e.jsx("circle",{cx:120,cy:120,r:53,fill:`url(#${Y})`,opacity:.4}),te,K]})},Rn=({colors:n})=>{if(n.length<2)return null;const i=[];for(let o=0;o<n.length;o++){const r=Ue(n[o],"var(--bg-primary, #ffffff)"),d=Ue(n[o],"var(--text-primary, #000000)");i.push({a:n[o],b:"var(--bg-primary, #ffffff)",ratio:r,level:Xe(r)}),i.push({a:n[o],b:"var(--text-primary, #000000)",ratio:d,level:Xe(d)});for(let h=o+1;h<n.length;h++){const N=Ue(n[o],n[h]);i.push({a:n[o],b:n[h],ratio:N,level:Xe(N)})}}return e.jsxs("div",{className:"nice-palette__contrast",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Contrast Analysis (WCAG 2.1)"}),e.jsx("div",{className:"nice-palette__contrast-grid",children:i.map((o,r)=>e.jsxs("div",{className:"nice-palette__contrast-pair",children:[e.jsxs("div",{className:"nice-palette__contrast-swatches",children:[e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:o.a}}),e.jsx("span",{className:"nice-palette__contrast-vs",children:"vs"}),e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:o.b}})]}),e.jsxs("span",{className:"nice-palette__contrast-ratio",children:[o.ratio.toFixed(1),":1"]}),e.jsx("span",{className:`nice-palette__contrast-level nice-palette__contrast-level--${o.level.toLowerCase().replace("-","")}`,children:o.level})]},r))})]})},In=({hex:n})=>{const i=We(n),o=Bt(i),r=ut(i);return e.jsxs("div",{className:"nice-palette__color-info",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"HEX"})," ",n.toUpperCase()]}),e.jsxs("div",{children:[e.jsx("strong",{children:"RGB"})," ",i.r,", ",i.g,", ",i.b]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSL"})," ",Math.round(o.h),"°, ",Math.round(o.s*100),"%,"," ",Math.round(o.l*100),"%"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSV"})," ",Math.round(r.h),"°, ",Math.round(r.s*100),"%,"," ",Math.round(r.v*100),"%"]})]})},jt={monochromatic:"Monochromatic",complementary:"Complementary","split-complementary":"Split-Complementary",analogous:"Analogous",triadic:"Triadic",tetradic:"Tetradic (Rectangle)",square:"Square",custom:"Custom"},An={"lightest-pastel":"Lightest Pastel","bright-pastel":"Bright Pastel",shiny:"Shiny",pastel:"Pastel",full:"Full Colors",dark:"Dark",deep:"Deep Colors",muted:"Muted",earth:"Earth Tones"},Dn=["monochromatic","complementary","split-complementary","analogous","triadic","tetradic","square","custom"],Ln=["lightest-pastel","bright-pastel","shiny","pastel","full","dark","deep","muted","earth"],Kt=t.forwardRef(({id:n,className:i,style:o,accessMode:r,value:d,onChange:h,minColors:N=1,maxColors:k=8,harmonyMode:D,onHarmonyModeChange:z,distance:X,onDistanceChange:V,preset:j,onPresetChange:Y,showWheel:K=!0,showContrast:te=!0,showInfo:B=!0,showPresets:$=!0,presets:C=[],showVariations:_=!0,showRandom:w=!0,variationCount:M=5,label:U,disabled:b},g)=>{const x=ne.Ns(r,n);if(x==="hidden")return null;(x==="disabled"||x==="readOnly")&&(b=!0);const T=ne.cs(n),[P,R]=t.useState("analogous"),[v,u]=t.useState(30),[S,f]=t.useState(""),[c,s]=t.useState(0),m=D??P,a=X??v,p=j??S,E=t.useCallback(W=>{R(W),z?.(W)},[z]),I=t.useCallback(W=>{u(W),V?.(W)},[V]),ee=t.useCallback(W=>{f(W),W&&Y?.(W)},[Y]),L=t.useMemo(()=>["var(--color-primary, #3b82f6)","var(--color-error, #ef4444)","var(--color-success, #22c55e)"],[]),oe=d&&d.length>0?d:L,q=oe[0],J=t.useMemo(()=>Fe(q),[q]),ie=t.useMemo(()=>Oe(J.h,m,a),[J.h,m,a]),se=t.useCallback((W,F,Q,ae)=>{const ye=Oe(W,F,Q);let ge;for(ae&&Ot[ae]?ge=Ve(ye,ae):ge=ye.map(fe=>Ne({h:fe,s:J.s||.7,v:J.v||.85}));ge.length<N;)ge.push(ge[ge.length-1]||"#888888");ge.length>k&&(ge=ge.slice(0,k)),h?.(ge)},[J.s,J.v,N,k,h]),me=t.useCallback(W=>{if(!b){if(m==="custom"){const F=Ne({h:W,s:J.s||.7,v:J.v||.85}),Q=[...oe];Q[c]=F,h?.(Q);return}se(W,m,a,p)}},[b,m,a,p,se,J.s,J.v,oe,c,h]),pe=t.useCallback(W=>{b||(E(W),W!=="custom"&&se(J.h,W,a,p))},[b,J.h,a,p,E,se]),xe=t.useCallback(W=>{b||(I(W),se(J.h,m,W,p))},[b,J.h,m,p,I,se]),_e=t.useCallback(W=>{if(b)return;ee(W);const F=Oe(J.h,m,a),Q=Ve(F,W);h?.(Q.slice(0,k))},[b,J.h,m,a,k,ee,h]),le=t.useCallback((W,F)=>{if(b)return;const Q=[...oe];Q[W]=F,h?.(Q)},[b,oe,h]),de=t.useCallback(()=>{if(b||oe.length>=k)return;const W=Fe(oe[oe.length-1]),F=Ne({h:(W.h+30)%360,s:W.s,v:W.v});h?.([...oe,F])},[b,oe,k,h]),he=t.useCallback(W=>{if(b||oe.length<=N)return;const F=oe.filter((Q,ae)=>ae!==W);h?.(F),c>=F.length&&s(Math.max(0,F.length-1))},[b,oe,N,h,c]),re=t.useCallback(()=>{if(b)return;const W=Math.max(N,Math.min(k,pt(m).length)),F=Wt(m,W,a);h?.(F)},[b,N,k,m,a,h]),A=t.useMemo(()=>{if(!_)return[];const W=oe[c]||oe[0];return Ht(Fe(W),M)},[_,oe,c,M]),y=oe[c]||oe[0],Z=t.useMemo(()=>{const W=Fe(y);return Ne({h:(W.h+180)%360,s:W.s,v:W.v})},[y]);return e.jsxs("div",{ref:g,id:T,className:`nice-palette ${b?"nice-palette--disabled":""} ${i||""}`,style:o,children:[U&&e.jsx("div",{className:"nice-palette__label",children:U}),e.jsx("div",{className:"nice-palette__modes",children:Dn.map(W=>e.jsx("button",{type:"button",className:`nice-palette__mode-btn ${m===W?"nice-palette__mode-btn--active":""}`,onClick:()=>pe(W),disabled:b,title:jt[W],children:jt[W]},W))}),e.jsxs("div",{className:"nice-palette__main",children:[K&&e.jsxs("div",{className:"nice-palette__wheel-container",children:[e.jsx(Tn,{hues:ie,baseHue:J.h,onBaseHueChange:me,mode:m,distance:a,disabled:b}),(m==="analogous"||m==="split-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsxs("label",{children:["Distance: ",a,"°"]}),e.jsx("input",{type:"range",min:10,max:90,value:a,onChange:W=>xe(Number(W.target.value)),disabled:b,className:"nice-palette__distance-slider"})]})]}),e.jsxs("div",{className:"nice-palette__strips",children:[e.jsxs("div",{className:"nice-palette__swatches",children:[oe.map((W,F)=>e.jsxs("div",{className:`nice-palette__swatch-wrapper ${c===F?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>s(F),children:[e.jsx("div",{className:"nice-palette__swatch",style:{background:W},children:oe.length>N&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:Q=>{Q.stopPropagation(),he(F)},disabled:b,"aria-label":"Remove color",children:"×"})}),e.jsx("input",{type:"text",className:"nice-palette__hex-input",value:W.toUpperCase(),maxLength:7,disabled:b,onChange:Q=>le(F,Q.target.value)})]},F)),oe.length<k&&e.jsx("button",{type:"button",className:"nice-palette__add-btn",onClick:de,disabled:b,title:"Add color",children:"+"})]}),e.jsxs("div",{className:"nice-palette__complementary",children:[e.jsx("span",{className:"nice-palette__section-tag",children:"Complementary"}),e.jsx("div",{className:"nice-palette__swatch nice-palette__swatch--sm",style:{background:Z},title:Z.toUpperCase()}),e.jsx("span",{className:"nice-palette__hex-label",children:Z.toUpperCase()})]}),_&&A.length>0&&e.jsxs("div",{className:"nice-palette__variations",children:[e.jsx("span",{className:"nice-palette__section-tag",children:"Tints & Shades"}),e.jsx("div",{className:"nice-palette__variation-strip",children:A.map((W,F)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:W},title:W.toUpperCase(),onClick:()=>{b||le(c,W)},role:"button",tabIndex:0},F))})]}),w&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:re,disabled:b,title:"Random palette","aria-label":"Random palette",children:"🎲 Random Palette"})]})]}),$&&C.length>0&&e.jsxs("div",{className:"nice-palette__presets",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Style Presets"}),e.jsx("div",{className:"nice-palette__preset-grid",children:C.map(W=>{const F=Ve(ie,W);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${p===W?"nice-palette__preset-card--active":""}`,onClick:()=>_e(W),disabled:b,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:F.map((Q,ae)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:Q}},ae))}),e.jsx("span",{className:"nice-palette__preset-label",children:An[W]})]},W)})})]}),B&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Selected Color Info"}),e.jsx(In,{hex:y})]}),te&&e.jsxs("details",{className:"nice-palette__contrast-popup",style:{marginTop:8},children:[e.jsx("summary",{style:{cursor:"pointer",padding:"6px 10px",background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border-color)",borderRadius:4,display:"inline-block",fontSize:12,userSelect:"none"},children:"Contrast Analysis (WCAG 2.1)"}),e.jsx("div",{style:{marginTop:8},children:e.jsx(Rn,{colors:oe})})]})]})});Kt.displayName="NiceColorPalette";function ct(){return{type:"linear",angle:90,stops:[{color:"#3b82f6",position:0},{color:"#8b5cf6",position:100}]}}function lt(n){const i=n.stops.slice().sort((r,d)=>r.position-d.position).map(r=>`${r.color} ${r.position}%`).join(", "),o=n.repeating?"repeating-":"";switch(n.type){case"linear":return`${o}linear-gradient(${n.angle}deg, ${i})`;case"radial":{const r=n.shape||"ellipse",d=n.size||"farthest-corner",h=n.positionX??50,N=n.positionY??50;return`${o}radial-gradient(${r} ${d} at ${h}% ${N}%, ${i})`}case"conic":{const r=n.angle??0,d=n.positionX??50,h=n.positionY??50;return`${o}conic-gradient(from ${r}deg at ${d}% ${h}%, ${i})`}}}function Yt(n){const i=n.trim(),o=i.startsWith("repeating-");if(i.includes("linear-gradient")){const r=i.match(/linear-gradient\((.+)\)/)?.[1];if(!r)return null;const d=r.split(",").map(z=>z.trim());let h=90,N=0;const k=d[0].match(/^(\d+)deg$/);k&&(h=parseInt(k[1]),N=1);const D=ot(d.slice(N));return{type:"linear",angle:h,repeating:o,stops:D}}if(i.includes("radial-gradient")){const r=i.match(/radial-gradient\((.+)\)/)?.[1];if(!r)return null;const d=r.split(",").map(N=>N.trim()),h=ot(d.filter(N=>N.includes("#")||N.includes("rgb")));return{type:"radial",angle:0,repeating:o,stops:h.length>=2?h:ct().stops}}if(i.includes("conic-gradient")){const r=i.match(/conic-gradient\((.+)\)/)?.[1];if(!r)return null;const d=r.split(",").map(N=>N.trim()),h=ot(d.filter(N=>N.includes("#")||N.includes("rgb")));return{type:"conic",angle:0,repeating:o,stops:h.length>=2?h:ct().stops}}return null}function ot(n){return n.map((i,o,r)=>{const d=i.match(/^(#[0-9a-fA-F]{3,8}|rgba?\([^)]+\))\s*(\d+%?)?$/);if(d){const h=d[2]?parseFloat(d[2]):o/Math.max(1,r.length-1)*100;return{color:d[1],position:h}}return{color:i,position:o/Math.max(1,r.length-1)*100}})}function zn(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function Pn(n=2){const i=["linear","radial","conic"],o=i[Math.floor(Math.random()*i.length)],r=[];for(let d=0;d<n;d++)r.push({color:zn(),position:Math.round(d/(n-1)*100)});return{type:o,angle:Math.floor(Math.random()*360),stops:r,shape:o==="radial"?Math.random()>.5?"circle":"ellipse":void 0,positionX:o!=="linear"?Math.round(Math.random()*100):void 0,positionY:o!=="linear"?Math.round(Math.random()*100):void 0}}const Ut=[{name:"Sunset",value:{type:"linear",angle:135,stops:[{color:"#ff6b6b",position:0},{color:"#feca57",position:100}]}},{name:"Ocean",value:{type:"linear",angle:180,stops:[{color:"#667eea",position:0},{color:"#764ba2",position:100}]}},{name:"Forest",value:{type:"linear",angle:120,stops:[{color:"#11998e",position:0},{color:"#38ef7d",position:100}]}},{name:"Fire",value:{type:"linear",angle:90,stops:[{color:"#f12711",position:0},{color:"#f5af19",position:100}]}},{name:"Aurora",value:{type:"linear",angle:135,stops:[{color:"#a18cd1",position:0},{color:"#fbc2eb",position:50},{color:"#a6c1ee",position:100}]}},{name:"Midnight",value:{type:"linear",angle:180,stops:[{color:"#0f0c29",position:0},{color:"#302b63",position:50},{color:"#24243e",position:100}]}},{name:"Candy",value:{type:"linear",angle:45,stops:[{color:"#fc5c7d",position:0},{color:"#6a82fb",position:100}]}},{name:"Radial Glow",value:{type:"radial",angle:0,shape:"circle",stops:[{color:"#ffecd2",position:0},{color:"#fcb69f",position:100}],positionX:50,positionY:50}},{name:"Rainbow",value:{type:"conic",angle:0,stops:[{color:"#ff0000",position:0},{color:"#ff8800",position:17},{color:"#ffff00",position:33},{color:"#00ff00",position:50},{color:"#0088ff",position:67},{color:"#8800ff",position:83},{color:"#ff0000",position:100}],positionX:50,positionY:50}}],Xt=t.forwardRef(({id:n,className:i,style:o,accessMode:r,value:d,onChange:h,showCssOutput:N=!0,showPresets:k=!0,showEditor:D=!0,showRandom:z=!0,maxStops:X=10,label:V,disabled:j,width:Y},K)=>{const te=ne.Ns(r,n);if(te==="hidden")return null;(te==="disabled"||te==="readOnly")&&(j=!0);const B=ne.cs(n),$=d??ct(),C=t.useMemo(()=>lt($),[$]),[_,w]=t.useState(0),[M,U]=t.useState(""),b=t.useRef(null),g=t.useCallback(a=>{h?.(a)},[h]),x=t.useCallback(a=>{j||g({...$,type:a})},[j,$,g]),T=t.useCallback(a=>{j||g({...$,angle:a})},[j,$,g]),P=t.useCallback(a=>{j||g({...$,repeating:a})},[j,$,g]),R=t.useCallback(a=>{j||g({...$,shape:a})},[j,$,g]),v=t.useCallback((a,p)=>{if(j)return;const E=$.stops.map((I,ee)=>ee===a?{...I,...p}:I);g({...$,stops:E})},[j,$,g]),u=t.useCallback(()=>{if(j||$.stops.length>=X)return;const a=$.stops.slice().sort((L,oe)=>L.position-oe.position);let p=0,E=a[0];for(let L=0;L<a.length-1;L++){const oe=a[L+1].position-a[L].position;oe>p&&(p=oe,E=a[L])}const I=Math.round(E.position+p/2),ee="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");g({...$,stops:[...$.stops,{color:ee,position:I}]})},[j,$,X,g]),S=t.useCallback(a=>{if(j||$.stops.length<=2)return;const p=$.stops.filter((E,I)=>I!==a);g({...$,stops:p}),_>=p.length&&w(p.length-1)},[j,$,_,g]),f=t.useCallback(()=>{if(j)return;const a=2+Math.floor(Math.random()*3);g(Pn(a))},[j,g]),c=t.useCallback(()=>{if(j||!M.trim())return;const a=Yt(M);a&&g(a)},[j,M,g]),s=t.useCallback(a=>{if(j||!b.current||$.stops.length>=X)return;const p=b.current.getBoundingClientRect(),E=Math.round((a.clientX-p.left)/p.width*100),I="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),ee=[...$.stops,{color:I,position:E}];g({...$,stops:ee}),w(ee.length-1)},[j,$,X,g]),m=t.useMemo(()=>$.stops.slice().sort((a,p)=>a.position-p.position),[$.stops]);return e.jsxs("div",{ref:K,id:B,className:`nice-gradient ${j?"nice-gradient--disabled":""} ${i||""}`,style:{width:Y!=null?typeof Y=="number"?`${Y}px`:Y:320,boxSizing:"border-box",...o},children:[V&&e.jsx("div",{className:"nice-gradient__label",children:V}),e.jsx("div",{className:"nice-gradient__preview",style:{background:C}}),D&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(a=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${$.type===a?"nice-gradient__type-btn--active":""}`,onClick:()=>x(a),disabled:j,children:a.charAt(0).toUpperCase()+a.slice(1)},a)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:$.repeating??!1,onChange:a=>P(a.target.checked),disabled:j}),"Repeating"]})]}),e.jsxs("div",{className:"nice-gradient__controls",children:[$.type==="linear"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Angle: ",$.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:$.angle,onChange:a=>T(Number(a.target.value)),disabled:j,className:"nice-gradient__slider"}),e.jsx("div",{className:"nice-gradient__angle-presets",children:[0,45,90,135,180,225,270,315].map(a=>e.jsx("button",{type:"button",className:`nice-gradient__angle-btn ${$.angle===a?"nice-gradient__angle-btn--active":""}`,onClick:()=>T(a),disabled:j,title:`${a}°`,children:e.jsx("span",{style:{transform:`rotate(${a}deg)`,display:"inline-block"},children:"→"})},a))})]}),$.type==="radial"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:"Shape:"}),e.jsx("div",{className:"nice-gradient__shape-btns",children:["circle","ellipse"].map(a=>e.jsx("button",{type:"button",className:`nice-gradient__shape-btn ${($.shape||"ellipse")===a?"nice-gradient__shape-btn--active":""}`,onClick:()=>R(a),disabled:j,children:a},a))})]}),($.type==="radial"||$.type==="conic")&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Center: ",$.positionX??50,"%, ",$.positionY??50,"%"]}),e.jsxs("div",{className:"nice-gradient__center-inputs",children:[e.jsx("input",{type:"range",min:0,max:100,value:$.positionX??50,onChange:a=>g({...$,positionX:Number(a.target.value)}),disabled:j,className:"nice-gradient__slider"}),e.jsx("input",{type:"range",min:0,max:100,value:$.positionY??50,onChange:a=>g({...$,positionY:Number(a.target.value)}),disabled:j,className:"nice-gradient__slider"})]})]}),$.type==="conic"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Start angle: ",$.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:$.angle,onChange:a=>T(Number(a.target.value)),disabled:j,className:"nice-gradient__slider"})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{ref:b,className:"nice-gradient__bar",style:{background:C},onClick:s,children:$.stops.map((a,p)=>e.jsx("div",{className:`nice-gradient__stop-marker ${_===p?"nice-gradient__stop-marker--active":""}`,style:{left:`${a.position}%`},onClick:E=>{E.stopPropagation(),w(p)},title:`${a.color} @ ${a.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:a.color}})},p))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:u,disabled:j||$.stops.length>=X,title:"Add stop",children:"+"})]}),e.jsx("div",{className:"nice-gradient__stop-editor",children:e.jsx("div",{className:"nice-gradient__stop-list",children:m.map((a,p)=>{const E=$.stops.indexOf(a);return e.jsxs("div",{className:`nice-gradient__stop-row ${_===E?"nice-gradient__stop-row--active":""}`,onClick:()=>w(E),children:[e.jsx("input",{type:"color",value:a.color,onChange:I=>v(E,{color:I.target.value}),disabled:j,className:"nice-gradient__stop-color"}),e.jsx("input",{type:"text",value:a.color.toUpperCase(),maxLength:7,onChange:I=>v(E,{color:I.target.value}),disabled:j,className:"nice-gradient__stop-hex"}),e.jsx("input",{type:"number",min:0,max:100,value:a.position,onChange:I=>v(E,{position:Number(I.target.value)}),disabled:j,className:"nice-gradient__stop-pos"}),e.jsx("span",{className:"nice-gradient__stop-pct",children:"%"}),$.stops.length>2&&e.jsx("button",{type:"button",className:"nice-gradient__stop-del",onClick:()=>S(E),disabled:j,"aria-label":"Remove stop",children:"×"})]},E)})})})]}),z&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-gradient__random-btn",onClick:f,disabled:j,title:"Random gradient","aria-label":"Random gradient",children:"🎲 Random Gradient"}),k&&e.jsxs("div",{className:"nice-gradient__presets",children:[e.jsx("div",{className:"nice-gradient__section-title",children:"Presets"}),e.jsx("div",{className:"nice-gradient__preset-grid",children:Ut.map((a,p)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{j||g(a.value)},disabled:j,title:a.name,children:[e.jsx("div",{className:"nice-gradient__preset-preview",style:{background:lt(a.value)}}),e.jsx("span",{className:"nice-gradient__preset-name",children:a.name})]},p))})]}),N&&e.jsxs("div",{className:"nice-gradient__css",children:[e.jsx("div",{className:"nice-gradient__section-title",children:"CSS Output"}),e.jsxs("div",{className:"nice-gradient__css-output",children:[e.jsx("code",{children:`background: ${C};`}),e.jsx("button",{type:"button",className:"nice-gradient__copy-btn",onClick:()=>navigator.clipboard?.writeText(`background: ${C};`),title:"Copy CSS",children:"📋"})]}),e.jsxs("div",{className:"nice-gradient__css-import",children:[e.jsx("input",{type:"text",className:"nice-gradient__css-input",placeholder:"Paste CSS gradient to import...",value:M,onChange:a=>U(a.target.value),disabled:j}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:c,disabled:j,children:"Import"})]})]})]})});Xt.displayName="NiceGradientPicker";const Bn=({options:n,value:i,onChange:o,searchable:r=!0,clearable:d,loading:h,placeholder:N,label:k,error:D,helperText:z,required:X,disabled:V,size:j="md",id:Y,className:K,style:te,data:B,columns:$,valueField:C="id",displayField:_,dropdownWidth:w,controlWidth:M})=>{const U=ne.cs(Y),{t:b}=ne.Wo(),[g,x]=t.useState(!1),[T,P]=t.useState(""),R=t.useRef(null);ne.ds(R,()=>x(!1));const v=!!(B&&$&&$.length>0),u=_??($&&$[0]?.key),S=t.useMemo(()=>!v||!B?[]:B.map(a=>({value:String(a[C]??""),label:u?String(a[u]??""):""})),[v,B,C,u]),f=v?S:n??[],c=f.find(a=>String(a.value)===i),s=t.useMemo(()=>{if(!v||!B)return[];if(!T)return B;const a=T.toLowerCase();return B.filter(p=>$.some(E=>String(p[E.key]??"").toLowerCase().includes(a)))},[v,B,$,T]),m=t.useMemo(()=>{if(v||!T)return f;const a=T.toLowerCase();return f.filter(p=>p.label.toLowerCase().includes(a))},[f,T,v]);return e.jsxs("div",{className:`nice-field nice-field--${j} ${D?"nice-field--error":""} ${K||""}`,style:{width:M!=null?typeof M=="number"?`${M}px`:M:"fit-content",...te},ref:R,children:[k&&e.jsxs("label",{className:"nice-field__label",htmlFor:U,children:[k,X&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{className:"nice-field__input-wrap",style:{position:"relative"},children:[e.jsxs("button",{type:"button",id:U,className:"nice-select__trigger",onClick:()=>!V&&x(!g),disabled:V,children:[e.jsx("span",{children:c?.label||N||b("controls.select","Select...")}),e.jsx("span",{className:"nice-select__arrow",children:"▾"})]}),d&&i&&!V&&e.jsx("button",{type:"button",className:"nice-field__clear",onClick:()=>o(""),"aria-label":b("controls.clear","Clear"),children:"✕"}),g&&e.jsxs("div",{className:"nice-dropdown nice-lookup__dropdown",style:{position:"absolute",top:"100%",left:0,zIndex:50,marginTop:4,background:"var(--bg-primary)",border:"1px solid var(--border-color)",borderRadius:"var(--nice-radius-md)",boxShadow:"0 4px 16px rgba(0,0,0,0.15)",minWidth:"100%",width:w!=null?typeof w=="number"?`${w}px`:w:v?"max-content":"100%"},children:[r&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:T,onChange:a=>P(a.target.value),placeholder:b("controls.search","Search..."),autoFocus:!0,style:{width:"100%",padding:"4px 8px",border:"1px solid var(--border-color)",borderRadius:4,background:"var(--bg-primary)",color:"var(--text-primary)"}})}),v?e.jsxs("table",{className:"nice-lookup__grid",role:"listbox",style:{width:"100%",borderCollapse:"collapse",color:"var(--text-primary)"},children:[e.jsx("thead",{children:e.jsx("tr",{children:$.map(a=>e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontSize:12,fontWeight:600,color:"var(--text-secondary)",background:"var(--bg-secondary)",borderBottom:"1px solid var(--border-color)",width:a.width!=null?typeof a.width=="number"?`${a.width}px`:a.width:void 0},children:a.header},a.key))})}),e.jsx("tbody",{children:s.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:$.length,style:{padding:12,textAlign:"center",color:"var(--text-muted)"},children:b("controls.noResults","No results")})}):s.map(a=>{const p=String(a[C]??""),E=p===i;return e.jsx("tr",{role:"option","aria-selected":E,onClick:()=>{o(p),x(!1),P("")},style:{cursor:"pointer",background:E?"var(--hover-bg)":"transparent"},onMouseEnter:I=>{E||(I.currentTarget.style.background="var(--hover-bg)")},onMouseLeave:I=>{E||(I.currentTarget.style.background="transparent")},children:$.map(I=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--border-color)"},children:String(a[I.key]??"")},I.key))},p)})})]}):e.jsx("ul",{className:"nice-dropdown__list",role:"listbox",style:{listStyle:"none",margin:0,padding:4,maxHeight:240,overflowY:"auto"},children:m.length===0?e.jsx("li",{className:"nice-dropdown__empty",style:{padding:8,color:"var(--text-muted)"},children:b("controls.noResults","No results")}):m.map(a=>e.jsx("li",{role:"option",className:`nice-dropdown__option ${String(a.value)===i?"nice-dropdown__option--selected":""}`,onClick:()=>{o(String(a.value)),x(!1),P("")},"aria-selected":String(a.value)===i,children:a.label},String(a.value)))})]})]}),D&&e.jsx("div",{className:"nice-field__error",children:D}),z&&!D&&e.jsx("div",{className:"nice-field__hint",children:z})]})},Fn=["Su","Mo","Tu","We","Th","Fr","Sa"];function Hn(n,i){return new Date(n,i+1,0).getDate()}function On(n,i){return new Date(n,i,1).getDay()}function _t(n,i,o){return`${n}-${String(i+1).padStart(2,"0")}-${String(o).padStart(2,"0")}`}function Wn(n){const i=new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()));i.setUTCDate(i.getUTCDate()+4-(i.getUTCDay()||7));const o=new Date(Date.UTC(i.getUTCFullYear(),0,1));return Math.ceil(((i.getTime()-o.getTime())/864e5+1)/7)}const vt=["January","February","March","April","May","June","July","August","September","October","November","December"],Vt=({value:n,onChange:i,min:o,max:r,disabledDates:d=[],firstDayOfWeek:h=1,size:N="md",showWeekNumbers:k,onMonthChange:D,className:z,style:X,accessMode:V,id:j,multiple:Y,selectedDates:K=[],onSelectedDatesChange:te,renderDay:B,showKeyboardHints:$,persistPreferences:C=!1,fullWidth:_=!1,cookies:w=!1,localStorage:M=!0,sessionStorage:U=!1,storageMode:b,storageKey:g})=>{const x=ne.Ns(V,j);if(x==="hidden")return null;const T=x==="disabled"||x==="readOnly",{t:P}=ne.Wo(),R=new Date,v=n?new Date(n):R,u=ne.useStorageAdapter(g??"nice-calendar"),S=t.useMemo(()=>C?u.get("prefs")??{}:{},[C,u]),f=S.firstDayOfWeek??h,[c,s]=t.useState(S.lastViewYear??v.getFullYear()),[m,a]=t.useState(S.lastViewMonth??v.getMonth()),[p,E]=t.useState(S.preferredView??"days"),I=t.useCallback(F=>{if(!C)return;const Q=u.get("prefs")??{};u.set("prefs",{...Q,...F})},[C,u]),ee=t.useCallback(F=>{E(F),I({preferredView:F})},[I]),L=t.useCallback((F,Q)=>{I({lastViewYear:F,lastViewMonth:Q})},[I]),oe=t.useMemo(()=>[ne.Ws.moveUp,ne.Ws.moveDown,ne.Ws.moveLeft,ne.Ws.moveRight,{key:"Enter",description:P("shortcuts.selectDate","Select date")},ne.Ws.pageUp,ne.Ws.pageDown],[P]),q=t.useMemo(()=>Hn(c,m),[c,m]),J=t.useMemo(()=>(On(c,m)-f+7)%7,[c,m,f]),ie=t.useMemo(()=>{const F=[...Fn];for(let Q=0;Q<f;Q++)F.push(F.shift());return F},[f]),se=t.useCallback(F=>o&&F<o||r&&F>r?!0:d.includes(F),[o,r,d]),me=t.useCallback(F=>{if(p==="years"){s(ye=>ye+F*10);return}if(p==="months"){s(ye=>ye+F);return}let Q=m+F,ae=c;Q<0&&(Q=11,ae--),Q>11&&(Q=0,ae++),a(Q),s(ae),L(ae,Q),D?.(ae,Q)},[m,c,D,p,L]),pe=_t(R.getFullYear(),R.getMonth(),R.getDate()),xe=t.useCallback(F=>Y?K.includes(F):F===n,[Y,K,n]),_e=t.useCallback(F=>{if(!T){if(Y){const Q=K.includes(F)?K.filter(ae=>ae!==F):[...K,F];te?.(Q)}i?.(F)}},[Y,K,i,te]),le=t.useCallback(()=>{p==="days"?ee("months"):p==="months"&&ee("years")},[p,ee]),de=t.useCallback(F=>{a(F),ee("days"),L(c,F),D?.(c,F)},[c,D,ee,L]),he=t.useCallback(F=>{s(F),ee("months")},[ee]),re=p==="years"?`${c-c%10} – ${c-c%10+9}`:p==="months"?`${c}`:`${vt[m]} ${c}`,A=p==="years"?"decade":p==="months"?"year":"month",y=[];for(let F=0;F<J;F++)y.push(null);for(let F=1;F<=q;F++)y.push(F);for(;y.length%7!==0;)y.push(null);const Z=[];for(let F=0;F<y.length;F+=7)Z.push(y.slice(F,F+7));const W=c-c%10;return e.jsxs("div",{className:`nice-calendar nice-calendar--${N}${_?" nice-calendar--full-width":""} ${z||""}`,style:X,children:[e.jsxs("div",{className:"nice-calendar__header",children:[e.jsx("button",{type:"button",className:"nice-calendar__nav",onClick:()=>me(-1),"aria-label":`Previous ${A}`,children:"‹"}),e.jsx("button",{type:"button",className:"nice-calendar__title",onClick:le,"aria-label":p==="days"?"Show month picker":p==="months"?"Show year picker":void 0,disabled:p==="years",children:re}),e.jsx("button",{type:"button",className:"nice-calendar__nav",onClick:()=>me(1),"aria-label":`Next ${A}`,children:"›"}),$&&e.jsx(ne.Hr,{shortcuts:oe,size:"sm"})]}),p==="days"&&e.jsxs("table",{className:"nice-calendar__grid",role:"grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[k&&e.jsx("th",{className:"nice-calendar__wk",children:"W"}),ie.map(F=>e.jsx("th",{children:F},F))]})}),e.jsx("tbody",{children:Z.map((F,Q)=>e.jsxs("tr",{children:[k&&e.jsx("td",{className:"nice-calendar__wk",children:F.find(ae=>ae!=null)?Wn(new Date(c,m,F.find(ae=>ae!=null))):""}),F.map((ae,ye)=>{if(ae==null)return e.jsx("td",{className:"nice-calendar__empty-cell"},ye);const ge=_t(c,m,ae),fe=se(ge),ke=xe(ge),Ie=ge===pe;return e.jsx("td",{className:`nice-calendar__day${ke?" nice-calendar__day--selected":""}${Ie?" nice-calendar__day--today":""}${fe?" nice-calendar__day--disabled":""}`,onClick:()=>!fe&&_e(ge),role:"gridcell","aria-selected":ke,"aria-disabled":fe,children:B?B(ge,ae):ae},ye)})]},Q))})]}),p==="months"&&e.jsx("div",{className:"nice-calendar__picker-grid",children:vt.map((F,Q)=>e.jsx("button",{type:"button",className:`nice-calendar__picker-cell${Q===m&&c===v.getFullYear()?" nice-calendar__picker-cell--selected":""}`,onClick:()=>de(Q),children:F.slice(0,3)},Q))}),p==="years"&&e.jsx("div",{className:"nice-calendar__picker-grid",children:Array.from({length:12},(F,Q)=>W-1+Q).map(F=>e.jsx("button",{type:"button",className:`nice-calendar__picker-cell${F===c?" nice-calendar__picker-cell--selected":""}${F<W||F>W+9?" nice-calendar__picker-cell--other":""}`,onClick:()=>he(F),children:F},F))})]})};Vt.displayName="NiceCalendar";const Kn=({startDate:n,endDate:i,onStartChange:o,onEndChange:r,min:d,max:h,clearable:N,startPlaceholder:k,endPlaceholder:D,startLabel:z,endLabel:X,layout:V="horizontal",separator:j="–",gap:Y=12,fullWidth:K=!1,label:te,error:B,helperText:$,required:C,disabled:_,size:w="md",id:M,className:U,style:b,accessMode:g,showKeyboardHints:x,labelPlacement:T,errorPlacement:P,labelWidth:R,controlWidth:v,loading:u})=>{const S=ne.Ns(g,M),f=ne.cs(M),{t:c}=ne.Wo(),s=S==="disabled"||S==="readOnly"||!!_,m=t.useMemo(()=>[{key:"Tab",description:c("shortcuts.switchField","Switch between start/end")},ne.Ws.cancel],[c]);if(S==="hidden")return null;const a=E=>{o(E),E&&i&&E>i&&r(E)},p=V==="horizontal";return e.jsxs("div",{className:`nice-field nice-field--${w} nice-daterange nice-daterange--${V} ${T==="left"?"nice-field--label-left":""} ${B?"nice-field--error":""} ${u?"nice-field--loading":""} ${U||""}`,style:{...b,...R!=null&&{"--nice-field-label-width":typeof R=="number"?`${R}px`:R},...v!=null&&{"--nice-field-control-width":typeof v=="number"?`${v}px`:v}},"aria-busy":u||void 0,children:[te&&e.jsxs("label",{className:"nice-field__label",htmlFor:f,children:[te,C&&e.jsx("span",{className:"nice-field__required",children:"*"}),x&&e.jsx(ne.Hr,{shortcuts:m,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-daterange__row",style:{display:"flex",flexDirection:p?"row":"column",alignItems:p?"flex-end":"stretch",gap:Y,flexWrap:"wrap"},children:[e.jsx("div",{style:{flex:K?"1 1 0":void 0,minWidth:0},children:e.jsx(yt.NiceDatePicker,{id:f,label:z,value:n,onChange:a,min:d,max:i||h,placeholder:k||c("controls.startDate","Start date"),disabled:s,size:w,clearable:N,labelPlacement:T,labelWidth:R})}),p&&j!==""&&j!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--text-secondary, #666)"},"aria-hidden":"true",children:j}),e.jsx("div",{style:{flex:K?"1 1 0":void 0,minWidth:0},children:e.jsx(yt.NiceDatePicker,{label:X,value:i,onChange:r,min:n||d,max:h,placeholder:D||c("controls.endDate","End date"),disabled:s,size:w,clearable:N,labelPlacement:T,labelWidth:R})})]}),u&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),P==="right"&&B&&e.jsx("div",{className:"nice-field__error",role:"alert",children:B}),P==="right"&&!B&&$&&e.jsx("div",{className:"nice-field__helper",children:$})]}),P!=="right"&&B&&e.jsx("div",{className:"nice-field__error",children:B}),P!=="right"&&!B&&$&&e.jsx("div",{className:"nice-field__hint",children:$})]})},Yn=({min:n=0,max:i=100,step:o=1,startValue:r,endValue:d,onChange:h,showLabels:N=!0,formatLabel:k,valuePlacement:D="none",label:z,error:X,helperText:V,required:j,disabled:Y,readOnly:K,loading:te,size:B="md",id:$,className:C,style:_,accessMode:w,showKeyboardHints:M,labelPlacement:U,errorPlacement:b,labelWidth:g,controlWidth:x})=>{const T=ne.Ns(w,$);if(T==="hidden")return null;(T==="disabled"||T==="readOnly")&&(Y=!0);const{t:P}=ne.Wo(),R=ne.cs($),v=t.useRef(null),u=t.useMemo(()=>[ne.Ws.increment,ne.Ws.decrement,ne.Ws.first,ne.Ws.last,{key:"Tab",description:P("shortcuts.switchThumb","Switch thumb")}],[P]),S=m=>(m-n)/(i-n)*100,f=m=>k?k(m):String(m),c=m=>{const a=Math.round(m/o)*o;return Math.max(n,Math.min(i,a))},s=t.useCallback((m,a)=>{m.preventDefault();const p=v.current;if(!p||Y)return;const E=ee=>{const L=p.getBoundingClientRect(),oe=Math.max(0,Math.min(1,(ee.clientX-L.left)/L.width)),q=c(n+oe*(i-n));a==="start"?h(Math.min(q,d),d):h(r,Math.max(q,r))},I=()=>{document.removeEventListener("pointermove",E),document.removeEventListener("pointerup",I)};document.addEventListener("pointermove",E),document.addEventListener("pointerup",I)},[n,i,o,r,d,h,Y]);return e.jsxs("div",{className:`nice-field nice-field--${B} nice-field--rangeslider ${U==="left"?"nice-field--label-left":""} ${b==="right"?"nice-field--error-right":""} ${X?"nice-field--error":""} ${te?"nice-field--loading":""} ${C||""}`,style:{..._,...g!=null&&{"--nice-field-label-width":typeof g=="number"?`${g}px`:g},...x!=null&&{"--nice-field-control-width":typeof x=="number"?`${x}px`:x}},"aria-busy":te||void 0,children:[z&&e.jsxs("label",{className:"nice-field__label nice-field__label--with-value",htmlFor:R,children:[e.jsxs("span",{className:"nice-field__label-text",children:[z,j&&e.jsx("span",{className:"nice-field__required",children:"*"}),M&&e.jsx(ne.Hr,{shortcuts:u,size:"sm"})]}),D==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[f(r)," – ",f(d)]})]}),e.jsxs("div",{className:"nice-field__control",children:[D==="right"&&!z&&e.jsxs("span",{className:"nice-range-slider__value",children:[f(r)," – ",f(d)]}),e.jsxs("div",{className:"nice-range-slider__stack",children:[e.jsxs("div",{className:`nice-range-slider ${N?"nice-range-slider--with-labels":""} ${z?"nice-range-slider--has-field-label":""}`,ref:v,children:[e.jsx("div",{className:"nice-range-slider__track",children:e.jsx("div",{className:"nice-range-slider__fill",style:{left:`${S(r)}%`,width:`${S(d)-S(r)}%`}})}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${S(r)}%`},onPointerDown:m=>K?void 0:s(m,"start"),role:"slider","aria-valuemin":n,"aria-valuemax":d,"aria-valuenow":r,tabIndex:Y?-1:0,id:R}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${S(d)}%`},onPointerDown:m=>K?void 0:s(m,"end"),role:"slider","aria-valuemin":r,"aria-valuemax":i,"aria-valuenow":d,tabIndex:Y?-1:0})]}),N&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${S(r)}%`},children:f(r)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${S(d)}%`},children:f(d)})]}),D==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[f(r)," – ",f(d)]})]}),te&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),b==="right"&&X&&e.jsx("div",{className:"nice-field__error",role:"alert",children:X}),b==="right"&&!X&&V&&e.jsx("div",{className:"nice-field__helper",children:V})]}),b!=="right"&&X&&e.jsx("div",{className:"nice-field__error",role:"alert",children:X}),b!=="right"&&!X&&V&&e.jsx("div",{className:"nice-field__helper",children:V})]})},Un=({displayValue:n,placeholder:i,clearable:o,children:r,onClear:d,open:h,onOpenChange:N,dropdownWidth:k,label:D,error:z,helperText:X,required:V,disabled:j,size:Y="md",id:K,className:te,style:B,accessMode:$,showKeyboardHints:C,displayStyle:_})=>{ne.Ui("input",_),ne.Gi("input",_);const w=ne.Ns($,K);if(w==="hidden")return null;(w==="disabled"||w==="readOnly")&&(j=!0);const M=ne.cs(K),{t:U}=ne.Wo(),[b,g]=t.useState(!1),x=t.useRef(null),T=h??b,P=t.useMemo(()=>[{key:"Enter",description:U("shortcuts.openDropdown","Open dropdown")},ne.Ws.cancel],[U]),R=v=>{N?N(v):g(v)};return ne.ds(x,()=>R(!1)),e.jsxs("div",{className:`nice-field nice-field--${Y} ${z?"nice-field--error":""} ${te||""}`,style:B,ref:x,children:[D&&e.jsxs("label",{className:"nice-field__label",htmlFor:M,children:[D,V&&e.jsx("span",{className:"nice-field__required",children:"*"}),C&&e.jsx(ne.Hr,{shortcuts:P,size:"sm"})]}),e.jsxs("div",{className:"nice-field__input-wrap",children:[e.jsxs("button",{type:"button",id:M,className:"nice-select__trigger",onClick:()=>!j&&R(!T),disabled:j,children:[e.jsx("span",{children:n||i||U("controls.select","Select...")}),e.jsx("span",{className:"nice-select__arrow",children:"▾"})]}),o&&n&&!j&&e.jsx("button",{type:"button",className:"nice-field__clear",onClick:()=>d?.(),"aria-label":U("controls.clear","Clear"),children:"✕"})]}),T&&e.jsx("div",{className:"nice-dropdown",style:{width:k},children:r}),z&&e.jsx("div",{className:"nice-field__error",children:z}),X&&!z&&e.jsx("div",{className:"nice-field__hint",children:X})]})};function kt(n){const i=n.trim().toLowerCase();return i.startsWith("http://")||i.startsWith("https://")||i.startsWith("/")||i.startsWith("./")||i.startsWith("../")?!0:!(i.startsWith("javascript:")||i.startsWith("vbscript:")||i.startsWith("data:text"))}const Xn=["bold","italic","underline","strikethrough","h1","h2","h3","ul","ol","blockquote","hr","link","unlink","image","table","code","alignLeft","alignCenter","alignRight","fontSize","fontColor","undo","redo","clear","findReplace","emoji","source","fullscreen","markdown"],je=({d:n,viewBox:i="0 0 24 24"})=>e.jsx("svg",{width:"16",height:"16",viewBox:i,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:n})}),Vn={bold:e.jsx("strong",{style:{fontFamily:"serif"},children:"B"}),italic:e.jsx("em",{style:{fontFamily:"serif"},children:"I"}),underline:e.jsx("span",{style:{textDecoration:"underline"},children:"U"}),strikethrough:e.jsx("span",{style:{textDecoration:"line-through"},children:"S"}),h1:"H1",h2:"H2",h3:"H3",ul:e.jsx(je,{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"}),ol:e.jsx(je,{d:"M10 6h11M10 12h11M10 18h11M4 6h1v4M4 10h2M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"}),link:e.jsx(je,{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"}),unlink:e.jsx(je,{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07L11 5.78M3 3l18 18M9 15l3-3M14 11l3 3M14 21l-1.72-1.72a5 5 0 0 1-7.07-7.07L7 10.49"}),undo:e.jsx(je,{d:"M3 7v6h6M3 13a9 9 0 1 0 3-7.7L3 13"}),redo:e.jsx(je,{d:"M21 7v6h-6M21 13a9 9 0 1 1-3-7.7L21 13"}),clear:e.jsx(je,{d:"M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),table:e.jsx(je,{d:"M3 3h18v18H3zM3 9h18M3 15h18M9 3v18M15 3v18"}),image:e.jsx(je,{d:"M3 3h18v18H3zM3 16l5-5 4 4 3-3 6 6M9 9a2 2 0 1 1-4 0 2 2 0 0 1 4 0z"}),code:e.jsx(je,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),markdown:"MD",blockquote:e.jsx(je,{d:"M3 21c3-3 3-9 0-12M21 21c-3-3-3-9 0-12M9 7h6v6H9zM15 7h6v6h-6z"}),hr:e.jsx(je,{d:"M5 12h14"}),subscript:"X₂",superscript:"X²",indent:e.jsx(je,{d:"M3 8l4 4-4 4M7 6h14M7 12h14M3 18h18"}),outdent:e.jsx(je,{d:"M7 8l-4 4 4 4M21 6H3M21 12H7M21 18H3"}),alignLeft:e.jsx(je,{d:"M3 6h18M3 12h12M3 18h18"}),alignCenter:e.jsx(je,{d:"M3 6h18M6 12h12M3 18h18"}),alignRight:e.jsx(je,{d:"M3 6h18M9 12h12M3 18h18"}),alignJustify:e.jsx(je,{d:"M3 6h18M3 12h18M3 18h18"}),fullscreen:e.jsx(je,{d:"M3 9V3h6M21 9V3h-6M3 15v6h6M21 15v6h-6"}),removeFormat:e.jsx(je,{d:"M4 7V4h16v3M5 20h6M13 4 8 20"}),print:e.jsx(je,{d:"M6 9V2h12v7M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2M6 14h12v8H6z"}),source:e.jsx(je,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),emoji:e.jsx(je,{d:"M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zM8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01"}),findReplace:e.jsx(je,{d:"M11 19a8 8 0 1 1 0-16 8 8 0 0 1 0 16zM21 21l-4.35-4.35"}),fontSize:e.jsx(je,{d:"M4 7V4h16v3M9 20h6M12 4v16"}),fontColor:e.jsx(je,{d:"M4 21h16M5 17l7-12 7 12M8 13h8"})},qn=[{value:"1",label:"8pt"},{value:"2",label:"10pt"},{value:"3",label:"12pt"},{value:"4",label:"14pt"},{value:"5",label:"18pt"},{value:"6",label:"24pt"},{value:"7",label:"36pt"}],Gn=[{label:"Faces",emojis:["??","??","??","??","??","??","??","??","??","??","??","??"]},{label:"Hands",emojis:["??","??","??","??","??","??","??","??","??","??"]},{label:"Symbols",emojis:["??","?","??","?","?","?","??","??","??","??","??","??"]},{label:"Arrows",emojis:["??","??","??","??","??","??","??","??","??","?"]}];function Qn(n){let i=n;return i=i.replace(/<h1[^>]*>(.*?)<\/h1>/gi,`# $1
|
|
2
|
+
`),i=i.replace(/<h2[^>]*>(.*?)<\/h2>/gi,`## $1
|
|
3
|
+
`),i=i.replace(/<h3[^>]*>(.*?)<\/h3>/gi,`### $1
|
|
4
|
+
`),i=i.replace(/<strong[^>]*>(.*?)<\/strong>/gi,"**$1**"),i=i.replace(/<b[^>]*>(.*?)<\/b>/gi,"**$1**"),i=i.replace(/<em[^>]*>(.*?)<\/em>/gi,"*$1*"),i=i.replace(/<i[^>]*>(.*?)<\/i>/gi,"*$1*"),i=i.replace(/<code[^>]*>(.*?)<\/code>/gi,"`$1`"),i=i.replace(/<pre[^>]*>(.*?)<\/pre>/gis,"```\n$1\n```\n"),i=i.replace(/<br\s*\/?>/gi,`
|
|
5
|
+
`),i=i.replace(/<li[^>]*>(.*?)<\/li>/gi,`- $1
|
|
6
|
+
`),i=i.replace(/<\/?(?:ul|ol|p|div)[^>]*>/gi,`
|
|
7
|
+
`),i=i.replace(/<[^>]+>/g,""),i=i.replace(/\n{3,}/g,`
|
|
8
|
+
|
|
9
|
+
`),i.trim()}function Zn(n){let i=n;return i=i.replace(/^### (.+)$/gm,"<h3>$1</h3>"),i=i.replace(/^## (.+)$/gm,"<h2>$1</h2>"),i=i.replace(/^# (.+)$/gm,"<h1>$1</h1>"),i=i.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),i=i.replace(/\*(.+?)\*/g,"<em>$1</em>"),i=i.replace(/`([^`]+)`/g,"<code>$1</code>"),i=i.replace(/```\n?([\s\S]*?)\n?```/g,"<pre>$1</pre>"),i=i.replace(/^- (.+)$/gm,"<li>$1</li>"),i=i.replace(/(<li>.*<\/li>)/gs,"<ul>$1</ul>"),i=i.replace(/\n/g,"<br>"),i}const ht=({value:n,onChange:i,placeholder:o,height:r=200,toolbar:d=Xn,readOnly:h,onImageUpload:N,mentionTrigger:k,mentionSuggestions:D,onMentionSearch:z,onFileDrop:X,pasteCleanup:V=!0,maxLength:j=0,showWordCount:Y=!1,templates:K,label:te,error:B,helperText:$,required:C,disabled:_,size:w="md",id:M,className:U,style:b,accessMode:g})=>{const x=ne.Ns(g,M);if(x==="hidden")return null;x==="disabled"&&(_=!0),x==="readOnly"&&(h=!0);const T=ne.cs(M),P=t.useRef(null),R=t.useRef(null),v=t.useRef(null),[u,S]=t.useState(!1),[f,c]=t.useState(""),[s,m]=t.useState(!1),[a,p]=t.useState(""),[E,I]=t.useState(!1),[ee,L]=t.useState(""),[oe,q]=t.useState(0),[J,ie]=t.useState(!1),[se,me]=t.useState("#000000"),[pe,xe]=t.useState("#ffff00"),[_e,le]=t.useState(0),[de,he]=t.useState(0),[re,A]=t.useState(!1),[y,Z]=t.useState(""),[W,F]=t.useState(""),[Q,ae]=t.useState(!1),[ye,ge]=t.useState(!1),fe=t.useCallback((G,l)=>{if(h||_)return;const H=P.current;if(H){if(G==="markdown"){if(!u)c(Qn(n)),S(!0),m(!1);else{const O=Zn(f);i(O),S(!1)}return}if(G==="source"){s?(i(a),m(!1)):(p(n),m(!0),S(!1));return}if(G==="fullscreen"){ie(O=>!O);return}if(G==="emoji"){ae(O=>!O);return}if(G==="findReplace"){A(O=>!O);return}if(G==="image"){if(N)R.current?.click();else{const O=prompt("Image URL:");O&&kt(O)&&(H.focus(),document.execCommand("insertImage",!1,O),i(ne.es(H.innerHTML)))}return}switch(H.focus(),G){case"bold":document.execCommand("bold");break;case"italic":document.execCommand("italic");break;case"underline":document.execCommand("underline");break;case"strikethrough":document.execCommand("strikeThrough");break;case"h1":document.execCommand("formatBlock",!1,"h1");break;case"h2":document.execCommand("formatBlock",!1,"h2");break;case"h3":document.execCommand("formatBlock",!1,"h3");break;case"ul":document.execCommand("insertUnorderedList");break;case"ol":document.execCommand("insertOrderedList");break;case"blockquote":document.execCommand("formatBlock",!1,"blockquote");break;case"hr":document.execCommand("insertHorizontalRule");break;case"subscript":document.execCommand("subscript");break;case"superscript":document.execCommand("superscript");break;case"indent":document.execCommand("indent");break;case"outdent":document.execCommand("outdent");break;case"alignLeft":document.execCommand("justifyLeft");break;case"alignCenter":document.execCommand("justifyCenter");break;case"alignRight":document.execCommand("justifyRight");break;case"alignJustify":document.execCommand("justifyFull");break;case"removeFormat":document.execCommand("removeFormat");break;case"print":window.print();return;case"link":{const O=prompt("URL:");O&&kt(O)&&document.execCommand("createLink",!1,O);break}case"unlink":document.execCommand("unlink");break;case"undo":document.execCommand("undo");break;case"redo":document.execCommand("redo");break;case"clear":document.execCommand("removeFormat");break;case"fontSize":{l&&document.execCommand("fontSize",!1,l);break}case"fontColor":{l&&document.execCommand("foreColor",!1,l);break}case"bgColor":{l&&document.execCommand("hiliteColor",!1,l);break}case"table":{document.execCommand("insertHTML",!1,'<table class="nice-htmleditor__table"><thead><tr><th>Header 1</th><th>Header 2</th><th>Header 3</th></tr></thead><tbody><tr><td> </td><td> </td><td> </td></tr><tr><td> </td><td> </td><td> </td></tr></tbody></table><p> </p>');break}case"code":{const ce=window.getSelection()?.toString()||"";ce.includes(`
|
|
10
|
+
`)||ce.length>60?document.execCommand("insertHTML",!1,`<pre class="nice-htmleditor__code-block">${ce||"// code"}</pre>`):document.execCommand("insertHTML",!1,`<code>${ce||"code"}</code>`);break}}i(ne.es(H.innerHTML)),le(H.textContent?.length??0)}},[i,h,_,u,f,n,N,s,a]),ke=t.useCallback(async G=>{const l=G.target.files?.[0];if(!l||!N)return;const H=await N(l),O=P.current;O&&H&&(O.focus(),document.execCommand("insertImage",!1,H),i(O.innerHTML)),G.target.value=""},[N,i]),Ie=t.useCallback(()=>{const G=P.current;if(!G)return;const l=G.textContent?.length??0;if(j>0&&l>j&&(G.textContent=(G.textContent??"").slice(0,j)),le(l),he((G.textContent??"").trim().split(/\s+/).filter(Boolean).length),i(G.innerHTML),k){const H=window.getSelection();if(H&&H.rangeCount>0){const O=H.getRangeAt(0),ce=O.startContainer;if(ce.nodeType===Node.TEXT_NODE){const be=ce.textContent||"",we=O.startOffset,Se=be.slice(0,we),$e=Se.lastIndexOf(k);if($e>=0&&($e===0||/\s/.test(Se[$e-1]))){const Le=Se.slice($e+k.length);if(!/\s/.test(Le)){I(!0),L(Le),q(0),z?.(Le);return}}}}I(!1)}},[i,k,z]),Me=D?.filter(G=>G.label.toLowerCase().includes(ee.toLowerCase())).slice(0,8)??[],Ae=t.useCallback(G=>{const l=P.current;if(!l)return;const H=window.getSelection();if(!H||H.rangeCount===0)return;const O=H.getRangeAt(0),ce=O.startContainer;if(ce.nodeType===Node.TEXT_NODE&&k){const be=ce.textContent||"",we=O.startOffset,$e=be.slice(0,we).lastIndexOf(k);if($e>=0){const Le=be.slice(0,$e),Sn=be.slice(we),Mn=`<span class="nice-htmleditor__mention" data-mention="${G.key}" contenteditable="false">${k}${G.label}</span> `;ce.textContent=Le;const it=document.createRange();it.setStartAfter(ce),it.collapse(!0);const $n=it.createContextualFragment(Mn+Sn);ce.parentNode?.insertBefore($n,ce.nextSibling),H.collapseToEnd(),i(l.innerHTML)}}I(!1)},[k,i]),Qe=t.useCallback(G=>{if(E&&Me.length>0){G.key==="ArrowDown"?(G.preventDefault(),q(l=>Math.min(l+1,Me.length-1))):G.key==="ArrowUp"?(G.preventDefault(),q(l=>Math.max(l-1,0))):G.key==="Enter"?(G.preventDefault(),Ae(Me[oe])):G.key==="Escape"&&I(!1);return}(G.ctrlKey||G.metaKey)&&G.key==="b"?(G.preventDefault(),fe("bold")):(G.ctrlKey||G.metaKey)&&G.key==="i"?(G.preventDefault(),fe("italic")):(G.ctrlKey||G.metaKey)&&G.key==="u"?(G.preventDefault(),fe("underline")):(G.ctrlKey||G.metaKey)&&G.key==="f"?(G.preventDefault(),A(l=>!l)):(G.ctrlKey||G.metaKey)&&G.key==="z"&&!G.shiftKey?(G.preventDefault(),fe("undo")):(G.ctrlKey||G.metaKey)&&(G.key==="y"||G.key==="z"&&G.shiftKey)&&(G.preventDefault(),fe("redo"))},[E,Me,oe,Ae,fe]),Ze=t.useCallback(G=>{if(!V)return;G.preventDefault();const l=G.clipboardData.getData("text/html"),H=G.clipboardData.getData("text/plain");if(l){const ce=l.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<script[\s\S]*?<\/script>/gi,"").replace(/class="[^"]*"/gi,"").replace(/style="[^"]*"/gi,"").replace(/<o:[^>]*>[\s\S]*?<\/o:[^>]*>/gi,"").replace(/<!--[\s\S]*?-->/g,"").replace(/<\/?(?:xml|meta|link|font|span)[^>]*>/gi,"");document.execCommand("insertHTML",!1,ce)}else H&&document.execCommand("insertText",!1,H);const O=P.current;O&&(i(O.innerHTML),le(O.textContent?.length??0))},[V,i]),Je=t.useCallback(async G=>{if(!X)return;G.preventDefault();const l=Array.from(G.dataTransfer.files);if(l.length===0)return;const H=await X(l),O=P.current;if(O){O.focus();for(const ce of H)if(/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(ce)||ce.startsWith("data:image/"))document.execCommand("insertImage",!1,ce);else{const we=`<a href="${ce}">${ce.split("/").pop()??ce}</a>`;document.execCommand("insertHTML",!1,we)}i(O.innerHTML)}},[X,i]),et=t.useCallback(G=>{X&&G.preventDefault()},[X]),De=t.useCallback(G=>{const l=P.current;if(!l||!y)return;const H=l.textContent??"",O=y.toLowerCase(),ce=H.toLowerCase();(G===1?ce.indexOf(O):ce.lastIndexOf(O))!==-1&&(l.focus(),window.find?.(y))},[y]),tt=t.useCallback(()=>{const G=P.current;!G||!y||(G.innerHTML=G.innerHTML.split(y).join(W),i(G.innerHTML))},[y,W,i]),nt=t.useCallback(()=>{if(!y)return;const G=n.split(y).join(W);i(G);const l=P.current;l&&(l.innerHTML=G)},[y,W,n,i]),Ee=t.useCallback(G=>{const l=P.current;l&&(l.focus(),document.execCommand("insertText",!1,G),i(l.innerHTML),ae(!1))},[i]),ve=t.useCallback(G=>{const l=P.current;l&&(l.focus(),document.execCommand("insertHTML",!1,G),i(l.innerHTML),ge(!1))},[i]),Ce=t.useCallback(G=>{const l=_||h;if(G==="fontSize")return e.jsx(ue.NiceSelect,{size:"sm",value:"",onChange:O=>fe("fontSize",String(O)),disabled:l,placeholder:"Size",options:qn.map(O=>({value:O.value,label:O.label})),style:{minWidth:70,maxWidth:80}},G);if(G==="fontColor")return e.jsx(ue.NiceColorPicker,{value:se,onChange:O=>{me(O),fe("fontColor",O)},disabled:l,size:"sm",label:"",title:"Text color"},G);if(G==="bgColor")return e.jsx(ue.NiceColorPicker,{value:pe,onChange:O=>{xe(O),fe("bgColor",O)},disabled:l,size:"sm",label:"",title:"Highlight color"},G);const H=G==="markdown"&&u||G==="fullscreen"&&J||G==="source"&&s||G==="findReplace"&&re||G==="emoji"&&Q;return e.jsx(ue.NiceButton,{size:"sm",variant:H?"primary":"ghost",onClick:()=>fe(G),title:G,disabled:l,children:Vn[G]||G},G)},[_,h,fe,u,J,se,pe,s,re,Q]);return e.jsxs("div",{className:`nice-field nice-field--${w} ${B?"nice-field--error":""} ${U||""}`,style:b,children:[te&&e.jsxs("label",{className:"nice-field__label",htmlFor:T,children:[te,C&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{ref:v,className:`nice-htmleditor${J?" nice-htmleditor--fullscreen":""}`,children:[e.jsxs("div",{className:"nice-htmleditor__toolbar",style:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[d.map(Ce),K&&K.length>0&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(ue.NiceButton,{size:"sm",variant:ye?"primary":"ghost",onClick:()=>ge(G=>!G),title:"Insert template",children:"??"}),ye&&e.jsx("ul",{style:{position:"absolute",top:"100%",right:0,zIndex:200,background:"var(--bg-primary, #fff)",border:"1px solid var(--border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px rgba(0,0,0,.12)",listStyle:"none",margin:0,padding:4,minWidth:160,maxHeight:200,overflow:"auto"},children:K.map((G,l)=>e.jsx("li",{style:{padding:"6px 10px",cursor:"pointer",borderRadius:4},onMouseDown:H=>{H.preventDefault(),ve(G.html)},children:G.label},l))})]})]}),re&&e.jsxs("div",{className:"nice-htmleditor__find-bar",style:{display:"flex",gap:4,alignItems:"center",padding:"4px 8px",background:"var(--bg-secondary, #f8f9fa)",borderBottom:"1px solid var(--border-color, #ddd)",fontSize:"0.875em"},children:[e.jsx("input",{type:"text",placeholder:"Find...",value:y,onChange:G=>Z(G.target.value),style:{flex:1,maxWidth:180,padding:"2px 6px",border:"1px solid var(--border-color, #ccc)",borderRadius:4,background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)"}}),e.jsx("input",{type:"text",placeholder:"Replace...",value:W,onChange:G=>F(G.target.value),style:{flex:1,maxWidth:180,padding:"2px 6px",border:"1px solid var(--border-color, #ccc)",borderRadius:4,background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)"}}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:()=>De(1),title:"Find next",children:"?"}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:()=>De(-1),title:"Find previous",children:"?"}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:tt,disabled:_||h,children:"Replace"}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:nt,disabled:_||h,children:"All"}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:()=>A(!1),children:"?"})]}),Q&&e.jsx("div",{className:"nice-htmleditor__emoji-picker",style:{padding:8,background:"var(--bg-primary, #fff)",borderBottom:"1px solid var(--border-color, #ddd)",maxHeight:180,overflowY:"auto"},children:Gn.map(G=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"0.7em",fontWeight:600,color:"var(--text-muted, #999)",padding:"4px 0"},children:G.label}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:2},children:G.emojis.map(l=>e.jsx("span",{style:{cursor:"pointer",fontSize:"1.2em",padding:2,borderRadius:4},onClick:()=>Ee(l),title:l,children:l},l))})]},G.label))}),e.jsx("input",{ref:R,type:"file",accept:"image/*",style:{display:"none"},onChange:ke}),s?e.jsx("textarea",{className:"nice-htmleditor__source",value:a,onChange:G=>p(G.target.value),style:{minHeight:r,width:"100%",fontFamily:"monospace",resize:"vertical",whiteSpace:"pre",fontSize:"0.85em",background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:_||h}):u?e.jsx("textarea",{className:"nice-htmleditor__markdown",value:f,onChange:G=>c(G.target.value),style:{minHeight:r,width:"100%",fontFamily:"monospace",resize:"vertical",background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:_||h}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:P,id:T,className:"nice-htmleditor__content",contentEditable:!_&&!h,dangerouslySetInnerHTML:{__html:n},onInput:Ie,onKeyDown:Qe,onPaste:Ze,onDrop:Je,onDragOver:et,style:{minHeight:r},"data-placeholder":o,role:"textbox","aria-multiline":"true",suppressContentEditableWarning:!0}),E&&Me.length>0&&e.jsx("ul",{className:"nice-htmleditor__mention-list",children:Me.map((G,l)=>e.jsx("li",{className:`nice-htmleditor__mention-item ${l===oe?"nice-htmleditor__mention-item--active":""}`,onMouseDown:H=>{H.preventDefault(),Ae(G)},children:G.label},G.key))})]}),e.jsxs("div",{className:"nice-htmleditor__statusbar",style:{display:"flex",gap:12,padding:"2px 8px",fontSize:"0.75em",color:"var(--text-muted, #666)",borderTop:"1px solid var(--border-color, #eee)"},children:[j>0&&e.jsxs("span",{children:[_e," / ",j]}),Y&&e.jsxs("span",{children:[de," words"]}),Y&&e.jsxs("span",{children:[_e," chars"]}),s&&e.jsx("span",{style:{fontWeight:600},children:"HTML Source"}),u&&e.jsx("span",{style:{fontWeight:600},children:"Markdown"})]})]}),B&&e.jsx("div",{className:"nice-field__error",children:B}),$&&!B&&e.jsx("div",{className:"nice-field__hint",children:$})]})},Jn=Object.freeze(Object.defineProperty({__proto__:null,NiceHtmlEditor:ht},Symbol.toStringTag,{value:"Module"})),ei=[{code:"en",label:"English"},{code:"es",label:"Spanish"},{code:"fr",label:"French"},{code:"de",label:"German"},{code:"it",label:"Italian"},{code:"pt",label:"Portuguese"},{code:"pl",label:"Polish"},{code:"ru",label:"Russian"},{code:"zh",label:"Chinese"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"ar",label:"Arabic"}],ti=[{style:"professional",label:"Professional"},{style:"casual",label:"Casual"},{style:"formal",label:"Formal"},{style:"concise",label:"Concise"}],ni=t.forwardRef(function(i,o){const{enableAI:r=!0,aiModel:d,enableImprove:h=!0,enableTranslate:N=!0,enableGenerate:k=!0,toolbar:D,languages:z=ei,textStyles:X=ti,onImprove:V,onTranslate:j,onGenerate:Y,showAIToolbar:K=!0,value:te,onChange:B,...$}=i,C=t.useRef(null),[_,w]=t.useState(!1),[M,U]=t.useState(!1),[b,g]=t.useState(!1),[x,T]=t.useState(""),[P,R]=t.useState(""),[v,u]=t.useState("professional"),[S,f]=t.useState(""),[c,s]=t.useState(z[0]?.code||"en"),[m,a]=t.useState(""),[p,E]=t.useState(""),{t:I}=ne.Wo(),ee=ne.ie(),{improveText:L,translate:oe,generateHtml:q,isLoading:J}=ne.ul(),ie=r&&ee.isConfigured,se=t.useCallback(()=>{const re=window.getSelection();return re&&re.toString().trim()?re.toString():""},[]),me=t.useCallback(re=>{const A=window.getSelection();if(A&&A.rangeCount>0){const y=A.getRangeAt(0);y.deleteContents();const Z=document.createElement("div");Z.innerHTML=re;const W=document.createDocumentFragment();for(;Z.firstChild;)W.appendChild(Z.firstChild);if(y.insertNode(W),C.current){const F=C.current.innerHTML;B(F)}}},[B]),pe=t.useCallback(async(re="professional")=>{if(!ie||!h)return"";const A=se();if(!A)return"";T(A),u(re),w(!0),R("");try{const y=await L(A,re);return R(y),V?.(A,y,re),y}catch{return R(I("htmlEditorAI.improveFailed","Failed to improve text")),""}},[ie,h,se,L,V,I]),xe=t.useCallback(async re=>{if(!ie||!N)return"";const A=se();if(!A)return"";T(A),s(re),U(!0),f("");try{const y=z.find(W=>W.code===re)?.label||re,Z=await oe(A,y);return f(Z),j?.(A,Z,re),Z}catch{return f(I("htmlEditorAI.translateFailed","Failed to translate text")),""}},[ie,N,se,oe,z,j,I]),_e=t.useCallback(async re=>{if(!ie||!k||!re.trim())return"";a(re),E("");try{const A=await q(re);return E(A),Y?.(re,A),A}catch{return E(I("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[ie,k,q,Y,I]),le=t.useCallback(()=>{P&&me(P),w(!1),R("")},[P,me]),de=t.useCallback(()=>{S&&me(S),U(!1),f("")},[S,me]),he=t.useCallback(()=>{if(p&&C.current){document.execCommand("insertHTML",!1,p);const re=C.current.innerHTML;B(re)}g(!1),E(""),a("")},[p,B]);return t.useImperativeHandle(o,()=>({getEditor:()=>C.current,focus:()=>C.current?.focus(),getValue:()=>C.current?.innerHTML||"",setValue:re=>{C.current&&(C.current.innerHTML=re,B(re))},getSelection:se,insertHtml:re=>{document.execCommand("insertHTML",!1,re),C.current&&B(C.current.innerHTML)},improveSelection:pe,translateSelection:xe,generateHtml:_e})),t.useCallback(re=>{C.current=re},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":i["data-testid"],children:[K&&ie&&e.jsxs("div",{className:"nice-html-editor-ai__toolbar",children:[e.jsxs("div",{className:"nice-html-editor-ai__toolbar-left",children:[e.jsx("span",{className:"nice-html-editor-ai__badge",children:"AI"}),J&&e.jsx("span",{className:"nice-html-editor-ai__loading",children:I("htmlEditorAI.processing","Processing...")})]}),e.jsxs("div",{className:"nice-html-editor-ai__toolbar-right",children:[h&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>pe(),disabled:J,title:I("htmlEditorAI.improveText","Improve selected text"),children:["✨ ",I("htmlEditorAI.improve","Improve")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu",children:X.map(({style:re,label:A})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>pe(re),children:A},re))})]}),N&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:J,title:I("htmlEditorAI.translateText","Translate selected text"),children:["🌐 ",I("htmlEditorAI.translate","Translate")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu nice-html-editor-ai__dropdown-menu--languages",children:z.map(({code:re,label:A})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>xe(re),children:A},re))})]}),k&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>g(!0),disabled:J,title:I("htmlEditorAI.generateHtml","Generate HTML from description"),children:["⚡ ",I("htmlEditorAI.generate","Generate")]})]})]}),e.jsx("div",{className:"nice-html-editor-ai__editor-wrapper",children:e.jsx(ht,{value:te,onChange:B,toolbar:D,...$})}),_&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:["✨ ",I("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:X.map(({style:re,label:A})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${v===re?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{u(re),pe(re)},children:A},re))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>w(!1),children:"✕"})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:J?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:I("htmlEditorAI.improving","Improving text...")}):e.jsxs("div",{className:"nice-html-editor-ai__comparison",children:[e.jsxs("div",{className:"nice-html-editor-ai__text-block",children:[e.jsx("h5",{children:I("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:x})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--improved",children:[e.jsx("h5",{children:I("htmlEditorAI.improved","Improved")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:P})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:le,disabled:!P||J,children:["✓ ",I("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{w(!1),R("")},children:I("htmlEditorAI.cancel","Cancel")})]})]}),M&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:["🌐 ",I("htmlEditorAI.translateText","Translate Text")]}),e.jsx("div",{className:"nice-html-editor-ai__language-selector",children:e.jsx("select",{value:c,onChange:re=>{s(re.target.value),xe(re.target.value)},className:"nice-html-editor-ai__language-select",children:z.map(({code:re,label:A})=>e.jsx("option",{value:re,children:A},re))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>U(!1),children:"✕"})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:J?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:I("htmlEditorAI.translating","Translating...")}):e.jsxs("div",{className:"nice-html-editor-ai__comparison",children:[e.jsxs("div",{className:"nice-html-editor-ai__text-block",children:[e.jsx("h5",{children:I("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:x})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--translated",children:[e.jsx("h5",{children:z.find(re=>re.code===c)?.label||c}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:S})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:de,disabled:!S||J,children:["✓ ",I("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{U(!1),f("")},children:I("htmlEditorAI.cancel","Cancel")})]})]}),b&&e.jsxs("div",{className:"nice-html-editor-ai__panel nice-html-editor-ai__panel--generate",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:["⚡ ",I("htmlEditorAI.generateHtml","Generate HTML")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>{g(!1),E(""),a("")},children:"✕"})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-body",children:[e.jsxs("div",{className:"nice-html-editor-ai__generate-input",children:[e.jsx("textarea",{placeholder:I("htmlEditorAI.generatePlaceholder",'Describe what you want to create (e.g., "A pricing table with 3 tiers", "A contact form with name, email, and message")'),value:m,onChange:re=>a(re.target.value),className:"nice-html-editor-ai__generate-textarea",rows:3}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__generate-btn",onClick:()=>_e(m),disabled:J||!m.trim(),children:J?I("htmlEditorAI.generating","Generating..."):I("htmlEditorAI.generate","Generate")})]}),p&&e.jsxs("div",{className:"nice-html-editor-ai__generate-result",children:[e.jsx("h5",{children:I("htmlEditorAI.preview","Preview")}),e.jsx("div",{className:"nice-html-editor-ai__preview",dangerouslySetInnerHTML:{__html:p}}),e.jsx("h5",{children:I("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:p})]})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:he,disabled:!p||J,children:["✓ ",I("htmlEditorAI.insert","Insert")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{g(!1),E(""),a("")},children:I("htmlEditorAI.cancel","Cancel")})]})]})]})}),qt=t.forwardRef(({length:n=6,value:i="",onChange:o,masked:r=!1,onComplete:d,label:h,helperText:N,error:k,required:D,disabled:z,readOnly:X,size:V="md",name:j,id:Y,className:K,style:te,autoFocus:B,labelPlacement:$,errorPlacement:C,labelWidth:_,controlWidth:w,loading:M,cellWidth:U,...b},g)=>{const x=ne.cs(Y),T=t.useRef([]),P=i.padEnd(n,"").slice(0,n).split(""),R=t.useCallback(c=>{const s=Math.max(0,Math.min(n-1,c));T.current[s]?.focus()},[n]),v=t.useCallback(c=>{const s=c.join("");o?.(s),s.length===n&&s.indexOf("")===-1&&/^\d+$/.test(s)&&d?.(s)},[o,d,n]),u=t.useCallback((c,s)=>{const a=s.target.value.replace(/\D/g,"").slice(-1);if(!a)return;const p=[...P];p[c]=a,v(p),R(c+1)},[P,v,R]),S=t.useCallback((c,s)=>{if(s.key==="Backspace"){s.preventDefault();const m=[...P];P[c]?(m[c]="",v(m)):c>0&&(m[c-1]="",v(m),R(c-1))}else s.key==="ArrowLeft"?(s.preventDefault(),R(c-1)):s.key==="ArrowRight"&&(s.preventDefault(),R(c+1))},[P,v,R]),f=t.useCallback(c=>{c.preventDefault();const s=c.clipboardData.getData("text").replace(/\D/g,"").slice(0,n);if(!s)return;const m=s.padEnd(n,"").slice(0,n).split("");for(let a=s.length;a<n;a++)m[a]=P[a]||"";v(m),R(Math.min(s.length,n-1))},[n,P,v,R]);return e.jsxs("div",{className:`nice-field nice-field--${V} nice-field--otp${$?` nice-field--label-${$}`:""}${C==="right"?" nice-field--error-right":""} ${M?"nice-field--loading":""} ${K||""}`,style:{...te,..._!=null&&{"--nice-field-label-width":typeof _=="number"?`${_}px`:_},...w!=null&&{"--nice-field-control-width":typeof w=="number"?`${w}px`:w},...U!=null&&{"--nice-otp-cell-width":typeof U=="number"?`${U}px`:U}},"aria-busy":M||void 0,...b,children:[h&&e.jsx("label",{htmlFor:`${x}-0`,className:`nice-field__label ${D?"nice-field__label--required":""}`,children:h}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:g,className:`nice-otp nice-otp--${V} ${k?"nice-otp--error":""} ${z?"nice-otp--disabled":""}`,onPaste:f,children:[Array.from({length:n},(c,s)=>e.jsx("input",{ref:m=>{T.current[s]=m},id:s===0?`${x}-0`:void 0,className:"nice-otp__digit",type:r?"password":"text",inputMode:"numeric",maxLength:2,value:P[s]||"",disabled:z,readOnly:X,autoFocus:B&&s===0,"aria-invalid":!!k,"aria-label":`${s+1}`,onChange:m=>u(s,m),onKeyDown:m=>S(s,m),onFocus:m=>m.target.select()},s)),j&&e.jsx("input",{type:"hidden",name:j,value:i})]}),C==="right"&&k&&e.jsx("div",{id:`${x}-error`,className:"nice-field__error",role:"alert",children:k}),C==="right"&&!k&&N&&e.jsx("div",{id:`${x}-helper`,className:"nice-field__helper",children:N}),M&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),C!=="right"&&k&&e.jsx("div",{id:`${x}-error`,className:"nice-field__error",role:"alert",children:k}),C!=="right"&&!k&&N&&e.jsx("div",{id:`${x}-helper`,className:"nice-field__helper",children:N})]})});qt.displayName="NiceInputOtp";const ii={xxs:36,xs:48,sm:64,md:80,lg:100,xl:128,xxl:160},Ke=6,He=135,Gt=405,ze=Gt-He;function dt(n,i,o,r){const d=(r-90)*(Math.PI/180);return{x:n+o*Math.cos(d),y:i+o*Math.sin(d)}}function wt(n,i,o,r,d){const h=dt(n,i,o,r),N=dt(n,i,o,d),k=d-r>180?1:0;return`M ${h.x} ${h.y} A ${o} ${o} 0 ${k} 1 ${N.x} ${N.y}`}const Qt=t.forwardRef(({value:n=0,onChange:i,min:o=0,max:r=100,step:d=1,showValue:h=!0,valueTemplate:N="{value}",label:k,helperText:D,error:z,required:X,disabled:V,readOnly:j,size:Y="md",name:K,id:te,className:B,style:$,labelPlacement:C="top",errorPlacement:_,labelWidth:w,controlWidth:M,loading:U,isLabelCentered:b=!0,...g},x)=>{const T=ne.cs(te),P=t.useRef(!1),R=t.useRef(null),v=typeof Y=="number"?Y:ii[Y],u=v/2,S=v/2,f=(v-Ke*2)/2,c=r>o?(n-o)/(r-o):0,s=He+c*ze,m=t.useCallback(ee=>{let L=ee-He;L<0&&(L+=360),L>ze&&(L=L-ze<360-L?ze:0);const oe=Math.max(0,Math.min(1,L/ze)),q=o+oe*(r-o),J=Math.round(q/d)*d;return Math.max(o,Math.min(r,J))},[o,r,d]),a=t.useCallback(ee=>{if(V||j)return;const L=R.current;if(!L)return;const oe=L.getBoundingClientRect(),q=ee.clientX-oe.left-oe.width/2,J=ee.clientY-oe.top-oe.height/2;let ie=Math.atan2(q,-J)*(180/Math.PI);ie<0&&(ie+=360);const se=m(ie);i?.(se)},[m,V,j,i]);t.useEffect(()=>{const ee=oe=>{P.current&&a(oe)},L=()=>{P.current=!1};return window.addEventListener("pointermove",ee),window.addEventListener("pointerup",L),()=>{window.removeEventListener("pointermove",ee),window.removeEventListener("pointerup",L)}},[a]);const p=t.useCallback(ee=>{if(V||j)return;let L=n;ee.key==="ArrowUp"||ee.key==="ArrowRight"?(ee.preventDefault(),L=Math.min(r,n+d)):(ee.key==="ArrowDown"||ee.key==="ArrowLeft")&&(ee.preventDefault(),L=Math.max(o,n-d)),L!==n&&i?.(L)},[n,i,o,r,d,V,j]),E=N.replace("{value}",String(n)),I=dt(u,S,f,s);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${_||"bottom"} nice-field--${typeof Y=="string"?Y:"md"} ${U?"nice-field--loading":""} ${B||""}`,style:{...$,...w!=null&&{"--nice-field-label-width":typeof w=="number"?`${w}px`:w},...M!=null&&{"--nice-field-control-width":typeof M=="number"?`${M}px`:M}},"aria-busy":U||void 0,...g,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${C} ${b?"nice-knob-field--label-centered":""}`,children:[k&&e.jsx("label",{htmlFor:T,className:`nice-field__label ${X?"nice-field__label--required":""}`,children:k}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:ee=>{R.current=ee,typeof x=="function"?x(ee):x&&(x.current=ee)},className:`nice-knob nice-knob--${Y} ${V?"nice-knob--disabled":""} ${z?"nice-knob--error":""}`,role:"slider",id:T,tabIndex:V?-1:0,"aria-valuenow":n,"aria-valuemin":o,"aria-valuemax":r,"aria-disabled":V,"aria-invalid":!!z,onPointerDown:ee=>{V||j||(P.current=!0,a(ee))},onKeyDown:p,children:[e.jsxs("svg",{width:v,height:v,viewBox:`0 0 ${v} ${v}`,children:[e.jsx("path",{d:wt(u,S,f,He,Gt),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:Ke,strokeLinecap:"round"}),c>0&&e.jsx("path",{d:wt(u,S,f,He,s),fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:Ke,strokeLinecap:"round"}),e.jsx("circle",{cx:I.x,cy:I.y,r:Ke,fill:"var(--nice-primary, #3b82f6)"})]}),h&&e.jsx("span",{className:"nice-knob__value",children:E}),K&&e.jsx("input",{type:"hidden",name:K,value:n}),U&&e.jsx("span",{className:"nice-knob__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})})]}),z&&e.jsx("div",{className:"nice-field__error",role:"alert",children:z}),!z&&D&&e.jsx("div",{className:"nice-field__helper",children:D})]})});Qt.displayName="NiceKnob";const Zt=t.forwardRef(({value:n="",onChange:i,suggestions:o=[],onSearch:r,trigger:d="@",renderSuggestion:h,placeholder:N,rows:k=3,label:D,helperText:z,error:X,required:V,disabled:j,readOnly:Y,size:K="md",name:te,id:B,className:$,style:C,..._},w)=>{const M=ne.cs(B),[U,b]=t.useState(!1),[g,x]=t.useState(""),[T,P]=t.useState(0),[R,v]=t.useState({top:0,left:0}),u=t.useRef(null),S=t.useRef(-1),c=o.map(E=>typeof E=="string"?{key:E,label:E}:E).filter(E=>E.label.toLowerCase().includes(g.toLowerCase())),s=t.useCallback(()=>{b(!1),x(""),P(0),S.current=-1},[]),m=t.useCallback(E=>{const I=u.current;if(!I||S.current<0)return;const ee=n.slice(0,S.current),L=n.slice(I.selectionStart),oe=`${d}${E.label} `,q=ee+oe+L;i?.(q),s(),requestAnimationFrame(()=>{const J=ee.length+oe.length;I.setSelectionRange(J,J),I.focus()})},[n,i,d,s]),a=t.useCallback(E=>{const I=E.target.value;i?.(I);const ee=E.target.selectionStart,L=I.slice(0,ee),oe=L.lastIndexOf(d);if(oe>=0){const q=oe>0?L[oe-1]:" ",J=L.slice(oe+d.length);if(/\s/.test(q)&&!/\s/.test(J)){S.current=oe;const ie=J;x(ie),b(!0),P(0),r?.(ie);const se=E.target,me=se.getBoundingClientRect(),pe=parseInt(getComputedStyle(se).lineHeight)||20,xe=L.split(`
|
|
11
|
+
`);v({top:me.top+xe.length*pe+4-se.scrollTop,left:me.left+8});return}}s()},[i,d,r,s]),p=t.useCallback(E=>{!U||c.length===0||(E.key==="ArrowDown"?(E.preventDefault(),P(I=>(I+1)%c.length)):E.key==="ArrowUp"?(E.preventDefault(),P(I=>(I-1+c.length)%c.length)):E.key==="Enter"?(E.preventDefault(),c[T]&&m(c[T])):E.key==="Escape"&&s())},[U,c,T,m,s]);return t.useEffect(()=>{if(!U)return;const E=I=>{const ee=u.current;ee&&!ee.contains(I.target)&&s()};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[U,s]),e.jsxs("div",{className:`nice-field ${$||""}`,style:C,..._,children:[D&&e.jsx("label",{htmlFor:M,className:`nice-field__label ${V?"nice-field__label--required":""}`,children:D}),e.jsxs("div",{className:`nice-mention nice-mention--${K} ${X?"nice-mention--error":""} ${j?"nice-mention--disabled":""}`,children:[e.jsx("textarea",{ref:E=>{u.current=E,typeof w=="function"?w(E):w&&(w.current=E)},id:M,name:te,className:"nice-mention__input",value:n,onChange:a,onKeyDown:p,placeholder:N,rows:k,disabled:j,readOnly:Y,"aria-invalid":!!X,"aria-describedby":X?`${M}-error`:z?`${M}-helper`:void 0,"aria-autocomplete":"list","aria-expanded":U}),U&&c.length>0&&e.jsx("ul",{className:"nice-mention__suggestions",role:"listbox",style:{position:"fixed",top:R.top,left:R.left},children:c.map((E,I)=>e.jsx("li",{role:"option","aria-selected":I===T,className:`nice-mention__suggestion ${I===T?"nice-mention__suggestion--active":""}`,onMouseDown:ee=>{ee.preventDefault(),m(E)},onMouseEnter:()=>P(I),children:h?h(E):e.jsxs(e.Fragment,{children:[E.icon&&e.jsx("span",{className:"nice-mention__suggestion-icon",children:E.icon}),e.jsx("span",{children:E.label})]})},E.key))})]}),X&&e.jsx("div",{id:`${M}-error`,className:"nice-field__error",role:"alert",children:X}),!X&&z&&e.jsx("div",{id:`${M}-helper`,className:"nice-field__helper",children:z})]})});Zt.displayName="NiceMention";function oi(n){const i=[],o=r=>{for(const d of r)i.push(d),d.children&&o(d.children)};return o(n),i}function Jt(n,i){const o=i.toLowerCase();return n.reduce((r,d)=>{const h=d.children?Jt(d.children,i):[];return(d.label.toLowerCase().includes(o)||h.length>0)&&r.push({...d,children:h.length>0?h:d.children}),r},[])}const en=({node:n,level:i,selectedKeys:o,expandedKeys:r,onToggleExpand:d,onSelect:h,selectableLeafsOnly:N})=>{const k=n.children&&n.children.length>0,D=r.has(n.key),z=o.has(n.key),X=!k,V=!n.disabled&&(!N||X);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`nice-tree-select__node ${z?"nice-tree-select__node--selected":""} ${n.disabled?"nice-tree-select__node--disabled":""}`,style:{paddingLeft:i*16+8},onClick:()=>V&&h(n.key),role:"treeitem","aria-selected":z,"aria-expanded":k?D:void 0,"aria-disabled":n.disabled,children:[k?e.jsx("button",{type:"button",className:"nice-tree-select__toggle",onClick:j=>{j.stopPropagation(),d(n.key)},"aria-label":"Toggle",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",style:{transform:D?"rotate(90deg)":"none",transition:"transform 0.15s"},children:e.jsx("path",{d:"M4.5 2l4 4-4 4"})})}):e.jsx("span",{style:{width:12,display:"inline-block"}}),(n.icon==null,null),e.jsx("span",{className:"nice-tree-select__node-label",children:n.label})]}),k&&D&&n.children.map(j=>e.jsx(en,{node:j,level:i+1,selectedKeys:o,expandedKeys:r,onToggleExpand:d,onSelect:h,selectableLeafsOnly:N},j.key))]})},tn=t.forwardRef(({nodes:n,value:i,onChange:o,multiple:r=!1,searchable:d=!1,placeholder:h,selectableLeafsOnly:N=!1,clearable:k=!1,label:D,helperText:z,error:X,required:V,disabled:j,readOnly:Y,size:K="md",name:te,id:B,className:$,style:C,controlWidth:_,...w},M)=>{const{t:U}=ne.Wo(),b=ne.cs(B),[g,x]=t.useState(!1),[T,P]=t.useState(""),[R,v]=t.useState(new Set),u=t.useRef(null);ne.ds(u,()=>x(!1));const S=t.useMemo(()=>i==null?new Set:new Set(Array.isArray(i)?i:[i]),[i]),f=t.useMemo(()=>T?Jt(n,T):n,[n,T]),c=t.useMemo(()=>{const p=oi(n);return Array.from(S).map(E=>p.find(I=>I.key===E)?.label).filter(Boolean)},[S,n]),s=t.useCallback(p=>{v(E=>{const I=new Set(E);return I.has(p)?I.delete(p):I.add(p),I})},[]),m=t.useCallback(p=>{if(r){const E=new Set(S);E.has(p)?E.delete(p):E.add(p),o?.(Array.from(E))}else o?.(p),x(!1)},[r,S,o]),a=t.useCallback(p=>{p.stopPropagation(),o?.(r?[]:"")},[o,r]);return e.jsxs("div",{className:`nice-field nice-field--${K} ${$||""}`,style:{width:"fit-content",maxWidth:"100%",...C},...w,children:[D&&e.jsx("label",{htmlFor:b,className:`nice-field__label ${V?"nice-field__label--required":""}`,children:D}),e.jsxs("div",{ref:u,className:"nice-tree-select",style:{position:"relative",width:_!=null?typeof _=="number"?`${_}px`:_:240},children:[e.jsxs("div",{ref:M,id:b,className:`nice-input nice-input--${K} ${X?"nice-input--error":""} ${j?"nice-input--disabled":""} ${Y?"nice-input--readonly":""}`,role:"combobox","aria-expanded":g,"aria-haspopup":"tree","aria-invalid":!!X,tabIndex:j?-1:0,onClick:()=>!j&&!Y&&x(!g),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),!j&&!Y&&x(!g))},children:[e.jsx("span",{className:"nice-tree-select__display",children:c.length>0?c.join(", "):e.jsx("span",{className:"nice-tree-select__placeholder",children:h??U("controls.select","Select...")})}),k&&S.size>0&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:a,"aria-label":U("controls.clear","Clear"),children:"✕"}),e.jsx("svg",{className:"nice-tree-select__arrow",width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",style:{transform:g?"rotate(180deg)":"none",transition:"transform 0.15s"},children:e.jsx("path",{d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"})})]}),g&&e.jsxs("div",{className:"nice-tree-select__dropdown",role:"tree",children:[d&&e.jsx("div",{className:"nice-tree-select__search",children:e.jsx("input",{className:"nice-input__native",type:"text",placeholder:U("controls.search","Search..."),value:T,onChange:p=>P(p.target.value),autoFocus:!0,onClick:p=>p.stopPropagation()})}),e.jsx("div",{className:"nice-tree-select__list",children:f.length===0?e.jsx("div",{className:"nice-tree-select__empty",children:U("controls.noResults","No results")}):f.map(p=>e.jsx(en,{node:p,level:0,selectedKeys:S,expandedKeys:R,onToggleExpand:s,onSelect:m,selectableLeafsOnly:N},p.key))})]})]}),te&&e.jsx("input",{type:"hidden",name:te,value:Array.isArray(i)?i.join(","):i??""}),X&&e.jsx("div",{id:`${b}-error`,className:"nice-field__error",role:"alert",children:X}),!X&&z&&e.jsx("div",{id:`${b}-helper`,className:"nice-field__helper",children:z})]})});tn.displayName="NiceTreeSelect";function Pe(n,i){return String(n[i])}const nn=t.forwardRef(({source:n,target:i,onChange:o,keyField:r="id",labelField:d="label",renderItem:h,filterable:N=!1,sourceHeader:k,targetHeader:D,disabled:z=!1,size:X="md",className:V,style:j,id:Y,...K},te)=>{const{t:B}=ne.Wo(),[$,C]=t.useState(new Set),[_,w]=t.useState(new Set),[M,U]=t.useState(""),[b,g]=t.useState(""),x=t.useCallback((f,c,s)=>{c(m=>{const a=new Set(m);return a.has(s)?a.delete(s):a.add(s),a})},[]),T=t.useCallback(()=>{const f=n.filter(s=>$.has(Pe(s,r))),c=n.filter(s=>!$.has(Pe(s,r)));o(c,[...i,...f]),C(new Set)},[n,i,$,r,o]),P=t.useCallback(()=>{const f=i.filter(s=>_.has(Pe(s,r))),c=i.filter(s=>!_.has(Pe(s,r)));o([...n,...f],c),w(new Set)},[n,i,_,r,o]),R=t.useCallback(()=>{o([],[...i,...n]),C(new Set)},[n,i,o]),v=t.useCallback(()=>{o([...n,...i],[]),w(new Set)},[n,i,o]),u=(f,c)=>{if(!c)return f;const s=c.toLowerCase();return f.filter(m=>String(m[d]).toLowerCase().includes(s))},S=(f,c,s,m,a,p)=>{const E=u(f,m);return e.jsxs("div",{className:"nice-picklist__panel",children:[p&&e.jsx("div",{className:"nice-picklist__header",children:p}),N&&e.jsx("div",{className:"nice-picklist__filter",children:e.jsx("input",{className:"nice-input__native",type:"text",placeholder:B("controls.search","Search..."),value:m,onChange:I=>a(I.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true",children:[E.map(I=>{const ee=Pe(I,r),L=c.has(ee);return e.jsx("div",{className:`nice-picklist__item ${L?"nice-picklist__item--selected":""}`,role:"option","aria-selected":L,onClick:()=>!z&&x(c,s,ee),children:h?h(I):String(I[d])},ee)}),E.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:B("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:te,id:Y,className:`nice-picklist nice-picklist--${X} ${z?"nice-picklist--disabled":""} ${V||""}`,style:j,...K,children:[S(n,$,C,M,U,k??B("picklist.source","Available")),e.jsxs("div",{className:"nice-picklist__controls",children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:z||$.size===0,onClick:T,"aria-label":B("picklist.moveRight","Move right"),children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"})})}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:z||n.length===0,onClick:R,"aria-label":B("picklist.moveAllRight","Move all right"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{d:"M4.293 14.707a1 1 0 010-1.414L7.586 10 4.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"}),e.jsx("path",{d:"M10.293 14.707a1 1 0 010-1.414L13.586 10 10.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"})]})}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:z||_.size===0,onClick:P,"aria-label":B("picklist.moveLeft","Move left"),children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"})})}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:z||i.length===0,onClick:v,"aria-label":B("picklist.moveAllLeft","Move all left"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{d:"M15.707 5.293a1 1 0 010 1.414L12.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"}),e.jsx("path",{d:"M9.707 5.293a1 1 0 010 1.414L6.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"})]})})]}),S(i,_,w,b,g,D??B("picklist.target","Selected"))]})});nn.displayName="NicePickList";let Te=null,Be=null;const ai="0.45.0",Ge=`https://cdn.jsdelivr.net/npm/monaco-editor@${ai}/min/vs`,Nt=15e3;function Ct(){const n=window;if(n.MonacoEnvironment?.getWorkerUrl)return;const i=`self.MonacoEnvironment={baseUrl:'${Ge}/'};importScripts('${Ge}/base/worker/workerMain.js');`,o=URL.createObjectURL(new Blob([i],{type:"text/javascript"}));n.MonacoEnvironment={getWorkerUrl:()=>o}}function Re(n){if(n!=="auto")return n;if(typeof document>"u")return"vs";const i=document.documentElement.dataset.theme;return i==="dark"?"vs-dark":i==="light"?"vs":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"vs-dark":"vs"}function on(){return Be?Promise.resolve(Be):Te||(Te=new Promise((n,i)=>{if(window.monaco){Ct(),Be=window.monaco,n(Be);return}let o=!1;const r=window.setTimeout(()=>{o||(o=!0,Te=null,i(new Error(`Monaco editor failed to load within ${Nt}ms`)))},Nt),d=document.createElement("script");d.src=`${Ge}/loader.min.js`,d.async=!0,d.onload=()=>{const h=window.require;h.config({paths:{vs:Ge}}),Ct(),h(["vs/editor/editor.main"],N=>{o||(o=!0,window.clearTimeout(r),Be=N,n(N))})},d.onerror=()=>{o||(o=!0,window.clearTimeout(r),Te=null,i(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(d)}),Te)}const gt=t.forwardRef(function(i,o){const{value:r,onChange:d,language:h="plaintext",theme:N="auto",options:k={},height:D=400,width:z="100%",markers:X=[],decorations:V=[],completionProvider:j,onMount:Y,onCursorPositionChange:K,onSelectionChange:te,onSave:B,loading:$,disabled:C=!1,showToolbar:_=!1,showStatusBar:w=!1,editorSize:M="standard",className:U,"data-testid":b}=i,g=t.useRef(null),x=t.useRef(null),T=t.useRef(null),P=t.useRef([]),R=t.useRef(null),[v,u]=t.useState(!0),[S,f]=t.useState(null),[c,s]=t.useState({lineNumber:1,column:1}),[m,a]=t.useState(""),[p,E]=t.useState(k.wordWrap==="on"),I=t.useMemo(()=>({automaticLayout:!0,readOnly:C||k.readOnly,minimap:{enabled:k.minimap??!0},lineNumbers:k.lineNumbers??"on",wordWrap:k.wordWrap??"off",tabSize:k.tabSize??2,insertSpaces:k.insertSpaces??!0,fontSize:k.fontSize??14,fontFamily:k.fontFamily??"'Fira Code', 'Consolas', 'Monaco', monospace",fontLigatures:k.fontLigatures??!0,cursorStyle:k.cursorStyle??"line",cursorBlinking:k.cursorBlinking??"blink",autoClosingBrackets:k.autoClosingBrackets??"languageDefined",autoClosingQuotes:k.autoClosingQuotes??"languageDefined",formatOnPaste:k.formatOnPaste??!1,formatOnType:k.formatOnType??!1,renderWhitespace:k.renderWhitespace??"selection",renderControlCharacters:k.renderControlCharacters??!1,scrollBeyondLastLine:k.scrollBeyondLastLine??!0,smoothScrolling:k.smoothScrolling??!0,folding:k.folding??!0,showFoldingControls:k.showFoldingControls??"mouseover","bracketPairColorization.enabled":k.bracketPairColorization??!0,guides:k.guides??{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:k.stickyScroll??!1},quickSuggestions:k.quickSuggestions??!0,suggestOnTriggerCharacters:k.suggestOnTriggerCharacters??!0,acceptSuggestionOnEnter:k.acceptSuggestionOnEnter??"on",inlayHints:{enabled:k.inlayHints?"on":"off"}}),[k,C]);t.useEffect(()=>{if(!g.current)return;let q=!0;return on().then(J=>{if(!q||!g.current)return;T.current=J;const ie=J.editor.create(g.current,{value:r,language:h,theme:Re(N),...I});x.current=ie,u(!1),ie.onDidChangeModelContent(()=>{const se=ie.getValue();d?.(se)}),ie.onDidChangeCursorPosition(se=>{s({lineNumber:se.position.lineNumber,column:se.position.column}),K?.({lineNumber:se.position.lineNumber,column:se.position.column})}),ie.onDidChangeCursorSelection(se=>{const me=se.selection,pe=ie.getModel()?.getValueInRange(me)??"";a(pe),te?.({startLineNumber:me.startLineNumber,startColumn:me.startColumn,endLineNumber:me.endLineNumber,endColumn:me.endColumn})}),ie.addCommand(J.KeyMod.CtrlCmd|J.KeyCode.KeyS,()=>{B?.(ie.getValue())}),Y?.(ie,J)}).catch(J=>{q&&(f(J.message??"Failed to load editor"),u(!1))}),()=>{q=!1,x.current?.dispose(),R.current?.dispose()}},[]),t.useEffect(()=>{const q=x.current;if(q&&r!==q.getValue()){const J=q.getPosition();q.setValue(r),J&&q.setPosition(J)}},[r]),t.useEffect(()=>{const q=x.current,J=T.current;if(q&&J){const ie=q.getModel();ie&&J.editor.setModelLanguage(ie,h)}},[h]),t.useEffect(()=>{const q=T.current;if(!q||(q.editor.setTheme(Re(N)),N!=="auto"||typeof document>"u"))return;const J=()=>{T.current?.editor.setTheme(Re("auto"))},ie=new MutationObserver(J);ie.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const se=window.matchMedia?.("(prefers-color-scheme: dark)");return se?.addEventListener?.("change",J),()=>{ie.disconnect(),se?.removeEventListener?.("change",J)}},[N]),t.useEffect(()=>{const q=x.current;q&&q.updateOptions(I)},[I]),t.useEffect(()=>{const q=x.current,J=T.current;if(q&&J){const ie=q.getModel();if(ie){const se=X.map(me=>({startLineNumber:me.startLineNumber,startColumn:me.startColumn,endLineNumber:me.endLineNumber,endColumn:me.endColumn,message:me.message,severity:me.severity}));J.editor.setModelMarkers(ie,"owner",se)}}},[X]),t.useEffect(()=>{const q=x.current;if(q&&V.length>0){const J=V.map(ie=>({range:{startLineNumber:ie.range.startLineNumber,startColumn:ie.range.startColumn,endLineNumber:ie.range.endLineNumber,endColumn:ie.range.endColumn},options:{className:ie.className,glyphMarginClassName:ie.glyphMarginClassName,hoverMessage:ie.hoverMessage?{value:ie.hoverMessage}:void 0,isWholeLine:ie.isWholeLine}}));P.current=q.deltaDecorations(P.current,J)}},[V]),t.useEffect(()=>{const q=T.current;if(!q||!j)return;R.current?.dispose();const J={text:0,method:1,function:2,constructor:3,field:4,variable:5,class:6,interface:7,module:8,property:9,keyword:13,snippet:14,color:15,file:16,reference:17,folder:18};return R.current=q.languages.registerCompletionItemProvider(h,{provideCompletionItems:async(ie,se)=>({suggestions:(await j(ie,se)).map(pe=>({label:pe.label,kind:J[pe.kind]??0,insertText:pe.insertText,insertTextRules:pe.insertTextRules==="insertAsSnippet"?4:void 0,documentation:pe.documentation,detail:pe.detail,range:{startLineNumber:se.lineNumber,startColumn:se.column,endLineNumber:se.lineNumber,endColumn:se.column}}))})}),()=>{R.current?.dispose()}},[h,j]),t.useImperativeHandle(o,()=>({getEditor:()=>x.current,getMonaco:()=>T.current,focus:()=>x.current?.focus(),getValue:()=>x.current?.getValue()??"",setValue:q=>x.current?.setValue(q),getSelection:()=>{const q=x.current;if(!q)return"";const J=q.getSelection();return J?q.getModel()?.getValueInRange(J)??"":""},insertText:q=>{const J=x.current;if(!J)return;const ie=J.getSelection();ie&&J.executeEdits("",[{range:ie,text:q}])},formatDocument:()=>{x.current?.getAction("editor.action.formatDocument")?.run()},goToLine:(q,J=1)=>{const ie=x.current;ie&&(ie.setPosition({lineNumber:q,column:J}),ie.revealLineInCenter(q),ie.focus())},findReplace:()=>{x.current?.getAction("editor.action.startFindReplaceAction")?.run()},undo:()=>{x.current?.trigger("keyboard","undo",null)},redo:()=>{x.current?.trigger("keyboard","redo",null)},getCursorPosition:()=>{const q=x.current?.getPosition();return{lineNumber:q?.lineNumber??1,column:q?.column??1}},setMarkers:q=>{const J=x.current,ie=T.current;if(J&&ie){const se=J.getModel();if(se){const me=q.map(pe=>({startLineNumber:pe.startLineNumber,startColumn:pe.startColumn,endLineNumber:pe.endLineNumber,endColumn:pe.endColumn,message:pe.message,severity:pe.severity}));ie.editor.setModelMarkers(se,"owner",me)}}}}),[]);const ee=t.useMemo(()=>({format:()=>x.current?.getAction("editor.action.formatDocument")?.run(),undo:()=>x.current?.trigger("keyboard","undo",null),redo:()=>x.current?.trigger("keyboard","redo",null),find:()=>x.current?.getAction("editor.action.startFindReplaceAction")?.run(),toggleWordWrap:()=>{const q=!p;E(q),x.current?.updateOptions({wordWrap:q?"on":"off"})},toggleMinimap:()=>{const q=x.current?.getOption?.(T.current?.editor?.EditorOption?.minimap);x.current?.updateOptions({minimap:{enabled:!q?.enabled}})},foldAll:()=>x.current?.getAction("editor.foldAll")?.run(),unfoldAll:()=>x.current?.getAction("editor.unfoldAll")?.run()}),[p]),L=r.split(`
|
|
12
|
+
`).length,oe=r.length;return e.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${M} ${U??""}`,style:{height:D,width:z,display:"flex",flexDirection:"column",position:"relative"},"data-testid":b,children:[S&&e.jsxs("div",{className:"nice-code-editor__error",style:{position:"absolute",inset:0,zIndex:2,background:"var(--nice-bg-primary, #fff)"},children:[e.jsxs("span",{children:["⚠️ ",S]}),e.jsx("textarea",{value:r,onChange:q=>d?.(q.target.value),readOnly:C||k.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),v&&!S&&e.jsx("div",{className:"nice-code-editor__loader-overlay",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)"},children:$??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading editor..."})}),_&&e.jsxs("div",{className:"nice-code-editor__toolbar",children:[e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:ee.undo,title:"Undo (Ctrl+Z)",children:"↶"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:ee.redo,title:"Redo (Ctrl+Y)",children:"↷"}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:ee.format,title:"Format (Shift+Alt+F)",children:"⎘"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:ee.find,title:"Find & Replace (Ctrl+H)",children:"🔍"}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:`nice-code-editor__toolbar-btn${p?" nice-code-editor__toolbar-btn--active":""}`,onClick:ee.toggleWordWrap,title:"Toggle Word Wrap",children:"↩"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:ee.toggleMinimap,title:"Toggle Minimap",children:"▥"}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:ee.foldAll,title:"Fold All",children:"⊟"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:ee.unfoldAll,title:"Unfold All",children:"⊞"})]}),e.jsx("div",{ref:g,className:"nice-code-editor",style:{flex:1,minHeight:0}}),w&&e.jsxs("div",{className:"nice-code-editor__statusbar",children:[e.jsxs("span",{children:["Ln ",c.lineNumber,", Col ",c.column]}),m.length>0&&e.jsxs("span",{children:["(",m.length," selected)"]}),e.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),e.jsxs("span",{children:[L," lines · ",oe," chars"]}),e.jsx("span",{className:"nice-code-editor__statusbar-lang",children:h}),X.length>0&&e.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:["⚠ ",X.length]})]})]})});function an(n){const{original:i,modified:o,language:r="plaintext",theme:d="auto",height:h=400,width:N="100%",inline:k=!1,renderSideBySide:D=!0,originalEditable:z=!1,modifiedEditable:X=!1,onOriginalChange:V,onModifiedChange:j,loading:Y,className:K,"data-testid":te}=n,B=t.useRef(null),$=t.useRef(null),C=t.useRef(null),[_,w]=t.useState(!0),[M,U]=t.useState(null);return t.useEffect(()=>{if(!B.current)return;let b=!0;return on().then(g=>{if(!b||!B.current)return;C.current=g;const x=g.editor.createModel(i,r),T=g.editor.createModel(o,r),P=g.editor.createDiffEditor(B.current,{automaticLayout:!0,theme:Re(d),renderSideBySide:!k&&D,originalEditable:z,readOnly:!X});P.setModel({original:x,modified:T}),$.current=P,w(!1),z&&x.onDidChangeContent(()=>{V?.(x.getValue())}),X&&T.onDidChangeContent(()=>{j?.(T.getValue())})}).catch(g=>{b&&(U(g.message??"Failed to load diff editor"),w(!1))}),()=>{b=!1,$.current?.dispose()}},[]),t.useEffect(()=>{const b=$.current;if(!b)return;const g=b.getModel();g&&(g.original.getValue()!==i&&g.original.setValue(i),g.modified.getValue()!==o&&g.modified.setValue(o))},[i,o]),t.useEffect(()=>{const b=C.current;if(!b||(b.editor.setTheme(Re(d)),d!=="auto"||typeof document>"u"))return;const g=()=>{C.current?.editor.setTheme(Re("auto"))},x=new MutationObserver(g);x.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const T=window.matchMedia?.("(prefers-color-scheme: dark)");return T?.addEventListener?.("change",g),()=>{x.disconnect(),T?.removeEventListener?.("change",g)}},[d,_]),M?e.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${K??""}`,style:{height:h,width:N},"data-testid":te,children:e.jsx("div",{className:"nice-code-editor__error",children:e.jsxs("span",{children:["⚠️ ",M]})})}):e.jsxs("div",{className:`nice-code-diff-editor ${K??""}`,style:{height:h,width:N,position:"relative"},"data-testid":te,children:[e.jsx("div",{ref:B,style:{position:"absolute",inset:0}}),_&&e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)",zIndex:2},children:Y??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading diff editor..."})})]})}const si="1.29.0",St=`https://cdn.jsdelivr.net/npm/prismjs@${si}`;let at=null;const mt={javascript:"javascript",typescript:"typescript",json:"json",html:"markup",css:"css",scss:"scss",less:"less",markdown:"markdown",xml:"markup",yaml:"yaml",sql:"sql",python:"python",csharp:"csharp",java:"java",cpp:"cpp",c:"c",go:"go",rust:"rust",php:"php",ruby:"ruby",shell:"bash",powershell:"powershell",plaintext:"plain"};function Mt(n){return new Promise((i,o)=>{if(document.querySelector(`script[data-prism-src="${n}"]`)){i();return}const r=document.createElement("script");r.src=n,r.async=!0,r.dataset.prismSrc=n,r.onload=()=>i(),r.onerror=()=>o(new Error(`Failed to load ${n}`)),document.head.appendChild(r)})}function ri(n){if(typeof window>"u")return Promise.resolve(null);const i=window,o=mt[n]??"plain",r=async()=>{if(o!=="plain"&&!i.Prism?.languages?.[o])try{await Mt(`${St}/components/prism-${o}.min.js`)}catch{}};return i.Prism?r().then(()=>i.Prism):(at||(at=(async()=>(window.Prism={manual:!0},await Mt(`${St}/prism.min.js`),window.Prism))()),at.then(async()=>(await r(),window.Prism)))}function st(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function sn(n){const{value:i,onChange:o,language:r="plaintext",height:d=300,width:h="100%",readOnly:N=!1,tabSize:k=2,lineNumbers:D=!0,placeholder:z,theme:X="auto",className:V,"data-testid":j}=n,Y=t.useRef(null),K=t.useRef(null),[te,B]=t.useState(()=>st(i)),[$,C]=t.useState("light");t.useEffect(()=>{const g=()=>{if(X!=="auto")return X;if(typeof document>"u")return"light";const R=document.documentElement.dataset.theme;return R==="dark"?"dark":R==="light"?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};if(C(g()),X!=="auto"||typeof document>"u")return;const x=()=>C(g()),T=new MutationObserver(x);T.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const P=window.matchMedia?.("(prefers-color-scheme: dark)");return P?.addEventListener?.("change",x),()=>{T.disconnect(),P?.removeEventListener?.("change",x)}},[X]),t.useEffect(()=>{let g=!0;return ri(r).then(x=>{if(!g)return;const T=mt[r]??"plain";if(x?.languages?.[T])try{const P=x.highlight(i,x.languages[T],T);B(P);return}catch{}B(st(i))}).catch(()=>{g&&B(st(i))}),()=>{g=!1}},[i,r]);const _=t.useCallback(()=>{!K.current||!Y.current||(K.current.scrollTop=Y.current.scrollTop,K.current.scrollLeft=Y.current.scrollLeft)},[]),w=t.useCallback(g=>{if(g.key==="Tab"){g.preventDefault();const x=g.currentTarget,T=x.selectionStart,P=x.selectionEnd,R=" ".repeat(k);if(g.shiftKey){const S=i.substring(0,T).lastIndexOf(`
|
|
13
|
+
`)+1;if((i.substring(S,T).match(/^(\s*)/)?.[1]??"").length>=k){const c=i.substring(0,S)+i.substring(S+k);o?.(c),setTimeout(()=>{x.selectionStart=x.selectionEnd=T-k},0)}}else{const v=i.substring(0,T)+R+i.substring(P);o?.(v),setTimeout(()=>{x.selectionStart=x.selectionEnd=T+k},0)}}},[i,o,k]),U=i.split(`
|
|
14
|
+
`).length,b=mt[r]??"plain";return e.jsxs("div",{className:`nice-simple-code-editor nice-simple-code-editor--${$} ${V??""}`,style:{height:d,width:h},"data-testid":j,"data-language":r,"data-theme":$,children:[D&&e.jsx("div",{className:"nice-simple-code-editor__line-numbers",children:Array.from({length:U},(g,x)=>e.jsx("div",{className:"nice-simple-code-editor__line-number",children:x+1},x))}),e.jsxs("div",{className:"nice-simple-code-editor__editor-area",children:[e.jsx("pre",{ref:K,"aria-hidden":"true",className:`nice-simple-code-editor__highlight language-${b}`,children:e.jsx("code",{className:`language-${b}`,dangerouslySetInnerHTML:{__html:te+(i.endsWith(`
|
|
15
|
+
`)?`
|
|
16
|
+
`:"")}})}),e.jsx("textarea",{ref:Y,className:"nice-simple-code-editor__textarea",value:i,onChange:g=>o?.(g.target.value),onKeyDown:w,onScroll:_,readOnly:N,placeholder:z,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"})]})]})}const $t="nice-code-editor-styles";if(typeof document<"u"&&!document.getElementById($t)){const n=document.createElement("style");n.id=$t,n.textContent=`
|
|
17
|
+
.nice-code-editor,
|
|
18
|
+
.nice-code-diff-editor {
|
|
19
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
20
|
+
border-radius: 4px;
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.nice-code-editor--loading,
|
|
25
|
+
.nice-code-editor--error,
|
|
26
|
+
.nice-code-diff-editor--loading {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.nice-code-editor__loader {
|
|
34
|
+
color: var(--nice-text-secondary, #666);
|
|
35
|
+
font-size: 14px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.nice-code-editor__error {
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
width: 100%;
|
|
42
|
+
height: 100%;
|
|
43
|
+
padding: 8px;
|
|
44
|
+
gap: 8px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.nice-code-editor__error span {
|
|
48
|
+
color: var(--nice-error, #d32f2f);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Simple code editor */
|
|
52
|
+
.nice-simple-code-editor {
|
|
53
|
+
display: flex;
|
|
54
|
+
border: 1px solid var(--border-color, var(--nice-border, #e0e0e0));
|
|
55
|
+
border-radius: 4px;
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
58
|
+
font-size: 14px;
|
|
59
|
+
line-height: 1.5;
|
|
60
|
+
background: var(--bg-primary, var(--nice-bg-surface, #fff));
|
|
61
|
+
color: var(--text-primary, var(--nice-text-primary, #333));
|
|
62
|
+
}
|
|
63
|
+
.nice-simple-code-editor--dark {
|
|
64
|
+
background: #1e1e1e;
|
|
65
|
+
color: #d4d4d4;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.nice-simple-code-editor__line-numbers {
|
|
69
|
+
padding: 8px 0;
|
|
70
|
+
background: var(--bg-secondary, var(--nice-bg-muted, #f5f5f5));
|
|
71
|
+
border-right: 1px solid var(--border-color, var(--nice-border, #e0e0e0));
|
|
72
|
+
user-select: none;
|
|
73
|
+
text-align: right;
|
|
74
|
+
color: var(--text-secondary, var(--nice-text-secondary, #999));
|
|
75
|
+
overflow: hidden;
|
|
76
|
+
}
|
|
77
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__line-numbers {
|
|
78
|
+
background: #252526;
|
|
79
|
+
border-right-color: #3c3c3c;
|
|
80
|
+
color: #858585;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.nice-simple-code-editor__line-number {
|
|
84
|
+
padding: 0 12px;
|
|
85
|
+
min-width: 40px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.nice-simple-code-editor__editor-area {
|
|
89
|
+
position: relative;
|
|
90
|
+
flex: 1;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.nice-simple-code-editor__highlight,
|
|
95
|
+
.nice-simple-code-editor__textarea {
|
|
96
|
+
position: absolute;
|
|
97
|
+
inset: 0;
|
|
98
|
+
margin: 0;
|
|
99
|
+
padding: 8px 12px;
|
|
100
|
+
border: 0;
|
|
101
|
+
font: inherit;
|
|
102
|
+
line-height: inherit;
|
|
103
|
+
white-space: pre;
|
|
104
|
+
overflow: auto;
|
|
105
|
+
tab-size: 2;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.nice-simple-code-editor__highlight {
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
background: transparent;
|
|
111
|
+
color: inherit;
|
|
112
|
+
}
|
|
113
|
+
.nice-simple-code-editor__highlight code {
|
|
114
|
+
font: inherit;
|
|
115
|
+
background: transparent;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.nice-simple-code-editor__textarea {
|
|
119
|
+
background: transparent;
|
|
120
|
+
color: transparent;
|
|
121
|
+
caret-color: var(--text-primary, var(--nice-text-primary, #333));
|
|
122
|
+
resize: none;
|
|
123
|
+
outline: none;
|
|
124
|
+
-webkit-text-fill-color: transparent;
|
|
125
|
+
}
|
|
126
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__textarea {
|
|
127
|
+
caret-color: #d4d4d4;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.nice-simple-code-editor__textarea::placeholder {
|
|
131
|
+
color: var(--text-secondary, var(--nice-text-secondary, #999));
|
|
132
|
+
-webkit-text-fill-color: var(--text-secondary, var(--nice-text-secondary, #999));
|
|
133
|
+
}
|
|
134
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__textarea::placeholder {
|
|
135
|
+
color: #858585;
|
|
136
|
+
-webkit-text-fill-color: #858585;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* Prism token colors — light */
|
|
140
|
+
.nice-simple-code-editor .token.comment,
|
|
141
|
+
.nice-simple-code-editor .token.prolog,
|
|
142
|
+
.nice-simple-code-editor .token.doctype,
|
|
143
|
+
.nice-simple-code-editor .token.cdata { color: #6a737d; font-style: italic; }
|
|
144
|
+
.nice-simple-code-editor .token.punctuation { color: #586069; }
|
|
145
|
+
.nice-simple-code-editor .token.property,
|
|
146
|
+
.nice-simple-code-editor .token.tag,
|
|
147
|
+
.nice-simple-code-editor .token.boolean,
|
|
148
|
+
.nice-simple-code-editor .token.number,
|
|
149
|
+
.nice-simple-code-editor .token.constant,
|
|
150
|
+
.nice-simple-code-editor .token.symbol,
|
|
151
|
+
.nice-simple-code-editor .token.deleted { color: #005cc5; }
|
|
152
|
+
.nice-simple-code-editor .token.selector,
|
|
153
|
+
.nice-simple-code-editor .token.attr-name,
|
|
154
|
+
.nice-simple-code-editor .token.string,
|
|
155
|
+
.nice-simple-code-editor .token.char,
|
|
156
|
+
.nice-simple-code-editor .token.builtin,
|
|
157
|
+
.nice-simple-code-editor .token.inserted { color: #032f62; }
|
|
158
|
+
.nice-simple-code-editor .token.operator,
|
|
159
|
+
.nice-simple-code-editor .token.entity,
|
|
160
|
+
.nice-simple-code-editor .token.url,
|
|
161
|
+
.nice-simple-code-editor .token.variable { color: #d73a49; }
|
|
162
|
+
.nice-simple-code-editor .token.atrule,
|
|
163
|
+
.nice-simple-code-editor .token.attr-value,
|
|
164
|
+
.nice-simple-code-editor .token.keyword { color: #d73a49; font-weight: 600; }
|
|
165
|
+
.nice-simple-code-editor .token.function,
|
|
166
|
+
.nice-simple-code-editor .token.class-name { color: #6f42c1; }
|
|
167
|
+
.nice-simple-code-editor .token.regex,
|
|
168
|
+
.nice-simple-code-editor .token.important { color: #e36209; }
|
|
169
|
+
|
|
170
|
+
/* Prism token colors — dark */
|
|
171
|
+
.nice-simple-code-editor--dark .token.comment,
|
|
172
|
+
.nice-simple-code-editor--dark .token.prolog,
|
|
173
|
+
.nice-simple-code-editor--dark .token.doctype,
|
|
174
|
+
.nice-simple-code-editor--dark .token.cdata { color: #6a9955; font-style: italic; }
|
|
175
|
+
.nice-simple-code-editor--dark .token.punctuation { color: #d4d4d4; }
|
|
176
|
+
.nice-simple-code-editor--dark .token.property,
|
|
177
|
+
.nice-simple-code-editor--dark .token.tag,
|
|
178
|
+
.nice-simple-code-editor--dark .token.boolean,
|
|
179
|
+
.nice-simple-code-editor--dark .token.number,
|
|
180
|
+
.nice-simple-code-editor--dark .token.constant,
|
|
181
|
+
.nice-simple-code-editor--dark .token.symbol,
|
|
182
|
+
.nice-simple-code-editor--dark .token.deleted { color: #b5cea8; }
|
|
183
|
+
.nice-simple-code-editor--dark .token.selector,
|
|
184
|
+
.nice-simple-code-editor--dark .token.attr-name,
|
|
185
|
+
.nice-simple-code-editor--dark .token.string,
|
|
186
|
+
.nice-simple-code-editor--dark .token.char,
|
|
187
|
+
.nice-simple-code-editor--dark .token.builtin,
|
|
188
|
+
.nice-simple-code-editor--dark .token.inserted { color: #ce9178; }
|
|
189
|
+
.nice-simple-code-editor--dark .token.operator,
|
|
190
|
+
.nice-simple-code-editor--dark .token.entity,
|
|
191
|
+
.nice-simple-code-editor--dark .token.url,
|
|
192
|
+
.nice-simple-code-editor--dark .token.variable { color: #569cd6; }
|
|
193
|
+
.nice-simple-code-editor--dark .token.atrule,
|
|
194
|
+
.nice-simple-code-editor--dark .token.attr-value,
|
|
195
|
+
.nice-simple-code-editor--dark .token.keyword { color: #c586c0; font-weight: 600; }
|
|
196
|
+
.nice-simple-code-editor--dark .token.function,
|
|
197
|
+
.nice-simple-code-editor--dark .token.class-name { color: #dcdcaa; }
|
|
198
|
+
.nice-simple-code-editor--dark .token.regex,
|
|
199
|
+
.nice-simple-code-editor--dark .token.important { color: #d7ba7d; }
|
|
200
|
+
|
|
201
|
+
/* Toolbar */
|
|
202
|
+
.nice-code-editor-wrap {
|
|
203
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
204
|
+
border-radius: 4px;
|
|
205
|
+
overflow: hidden;
|
|
206
|
+
}
|
|
207
|
+
.nice-code-editor-wrap .nice-code-editor {
|
|
208
|
+
border: none;
|
|
209
|
+
border-radius: 0;
|
|
210
|
+
}
|
|
211
|
+
.nice-code-editor__toolbar {
|
|
212
|
+
display: flex;
|
|
213
|
+
align-items: center;
|
|
214
|
+
gap: 2px;
|
|
215
|
+
padding: 3px 6px;
|
|
216
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
217
|
+
border-bottom: 1px solid var(--nice-border, #e0e0e0);
|
|
218
|
+
}
|
|
219
|
+
.nice-code-editor__toolbar-btn {
|
|
220
|
+
display: inline-flex;
|
|
221
|
+
align-items: center;
|
|
222
|
+
justify-content: center;
|
|
223
|
+
width: 26px;
|
|
224
|
+
height: 26px;
|
|
225
|
+
border: none;
|
|
226
|
+
border-radius: 3px;
|
|
227
|
+
background: transparent;
|
|
228
|
+
color: var(--nice-text-secondary, #666);
|
|
229
|
+
cursor: pointer;
|
|
230
|
+
font-size: 14px;
|
|
231
|
+
transition: background 0.15s, color 0.15s;
|
|
232
|
+
}
|
|
233
|
+
.nice-code-editor__toolbar-btn:hover {
|
|
234
|
+
background: var(--nice-hover, #e0e0e0);
|
|
235
|
+
color: var(--nice-text-primary, #333);
|
|
236
|
+
}
|
|
237
|
+
.nice-code-editor__toolbar-btn--active {
|
|
238
|
+
background: var(--nice-accent, #1976d2);
|
|
239
|
+
color: #fff;
|
|
240
|
+
}
|
|
241
|
+
.nice-code-editor__toolbar-sep {
|
|
242
|
+
width: 1px;
|
|
243
|
+
height: 18px;
|
|
244
|
+
background: var(--nice-border, #e0e0e0);
|
|
245
|
+
margin: 0 4px;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* Status bar */
|
|
249
|
+
.nice-code-editor__statusbar {
|
|
250
|
+
display: flex;
|
|
251
|
+
align-items: center;
|
|
252
|
+
gap: 12px;
|
|
253
|
+
padding: 2px 10px;
|
|
254
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
255
|
+
border-top: 1px solid var(--nice-border, #e0e0e0);
|
|
256
|
+
font-size: 12px;
|
|
257
|
+
color: var(--nice-text-secondary, #666);
|
|
258
|
+
user-select: none;
|
|
259
|
+
}
|
|
260
|
+
.nice-code-editor__statusbar-spacer { flex: 1; }
|
|
261
|
+
.nice-code-editor__statusbar-lang {
|
|
262
|
+
text-transform: uppercase;
|
|
263
|
+
font-weight: 600;
|
|
264
|
+
font-size: 11px;
|
|
265
|
+
}
|
|
266
|
+
.nice-code-editor__statusbar-markers {
|
|
267
|
+
color: var(--nice-warning, #f39c12);
|
|
268
|
+
font-weight: 600;
|
|
269
|
+
}
|
|
270
|
+
`,document.head.appendChild(n)}const ci=Object.freeze(Object.defineProperty({__proto__:null,NiceCodeDiffEditor:an,NiceCodeEditor:gt,NiceSimpleCodeEditor:sn},Symbol.toStringTag,{value:"Module"})),li=t.forwardRef(function(i,o){const{enableAI:r=!0,aiModel:d,enableInlineCompletion:h=!0,completionDelay:N=500,enableExplain:k=!0,enableRefactor:D=!0,enableGenerate:z=!0,systemPrompt:X,onExplain:V,onRefactor:j,showAIToolbar:Y=!0,aiShortcutKey:K="Ctrl",language:te="plaintext",value:B,onChange:$,...C}=i,_=t.useRef(null),[w,M]=t.useState(null),[U,b]=t.useState(!1),[g,x]=t.useState(""),[T,P]=t.useState(!1),[R,v]=t.useState(""),[u,S]=t.useState(""),[f,c]=t.useState(""),s=t.useRef(),{t:m}=ne.Wo(),a=ne.ie(),{complete:p,explain:E,refactor:I,generateFromComment:ee,isLoading:L}=ne.cl({language:te,model:d}),oe=r&&a.isConfigured,q=t.useCallback(async()=>{if(!oe||!h||!_.current||!_.current.getEditor())return;const de=_.current.getCursorPosition(),re=_.current.getValue().split(`
|
|
271
|
+
`),A=re.slice(0,de.lineNumber-1),y=re[de.lineNumber-1]||"",Z=[...A,y.slice(0,de.column-1)].join(`
|
|
272
|
+
`),W=[y.slice(de.column-1),...re.slice(de.lineNumber)].join(`
|
|
273
|
+
`);try{const F=await p(Z,W);F&&M({lineNumber:de.lineNumber,column:de.column,text:F})}catch{}},[oe,h,p]),J=t.useCallback(async()=>{if(!oe||!k||!_.current)return"";const le=_.current.getSelection();if(!le)return"";c(le),b(!0),x("");try{const de=await E(le);return x(de),V?.(le,de),de}catch{return x(m("codeEditorAI.explanationFailed","Failed to explain code")),""}},[oe,k,E,V,m]),ie=t.useCallback(async le=>{if(!oe||!D||!_.current)return"";const de=_.current.getSelection();if(!de)return"";try{const he=await I(de,le);return S(he),j?.(de,he),he}catch{return""}},[oe,D,I,j]),se=t.useCallback(async()=>{if(!oe||!z||!_.current)return;const le=_.current.getCursorPosition(),he=_.current.getValue().split(`
|
|
274
|
+
`);let re="";for(let A=le.lineNumber-1;A>=0&&A>=le.lineNumber-3;A--){const y=he[A]?.trim()||"";if(y.startsWith("//")||y.startsWith("#")||y.startsWith("/*")||y.startsWith("*")){re=y.replace(/^\/\/\s*|^#\s*|^\/\*\s*|\*\/\s*$|^\*\s*/g,"").trim();break}}if(re)try{const A=await ee(re);A&&_.current&&_.current.insertText(`
|
|
275
|
+
`+A)}catch{}},[oe,z,ee]),me=t.useCallback(()=>{!w||!_.current||(_.current.insertText(w.text),M(null))},[w]),pe=t.useCallback(()=>{M(null)},[]),xe=t.useCallback(le=>{i.onCursorPositionChange?.(le),!(!oe||!h)&&(s.current&&clearTimeout(s.current),M(null),s.current=setTimeout(()=>{q()},N))},[i.onCursorPositionChange,oe,h,N,q]);t.useEffect(()=>{if(!_.current?.getEditor()||!oe)return;const de=he=>{if(K==="Ctrl"&&he.ctrlKey||K==="Alt"&&he.altKey||K==="Meta"&&he.metaKey){if(he.key===" "&&h&&(he.preventDefault(),q()),he.key==="e"&&k&&(he.preventDefault(),J()),he.key==="r"&&D){he.preventDefault();const A=_.current?.getSelection();A&&(c(A),P(!0))}he.key==="g"&&z&&(he.preventDefault(),se())}he.key==="Tab"&&w&&(he.preventDefault(),me()),he.key==="Escape"&&w&&pe()};return window.addEventListener("keydown",de),()=>window.removeEventListener("keydown",de)},[oe,K,h,k,D,z,q,J,se,w,me,pe]),t.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const _e=t.useCallback(()=>{if(!u||!_.current)return;const le=_.current.getEditor();if(le?.executeEdits&&le?.getSelection){const de=le.getSelection();le.executeEdits("ai-refactor",[{range:de,text:u}])}P(!1),S(""),v("")},[u]);return t.useImperativeHandle(o,()=>({..._.current,getEditor:()=>_.current?.getEditor(),getMonaco:()=>_.current?.getMonaco(),focus:()=>_.current?.focus(),getValue:()=>_.current?.getValue()||"",setValue:le=>_.current?.setValue(le),getSelection:()=>_.current?.getSelection()||"",insertText:le=>_.current?.insertText(le),formatDocument:()=>_.current?.formatDocument(),goToLine:(le,de)=>_.current?.goToLine(le,de),findReplace:()=>_.current?.findReplace(),undo:()=>_.current?.undo(),redo:()=>_.current?.redo(),getCursorPosition:()=>_.current?.getCursorPosition()||{lineNumber:1,column:1},setMarkers:le=>_.current?.setMarkers(le),triggerCompletion:q,explainSelection:J,refactorSelection:ie,generateFromComment:se,acceptCompletion:me,dismissCompletion:pe})),e.jsxs("div",{className:"nice-code-editor-ai","data-testid":i["data-testid"],children:[Y&&oe&&e.jsxs("div",{className:"nice-code-editor-ai__toolbar",children:[e.jsxs("div",{className:"nice-code-editor-ai__toolbar-left",children:[e.jsx("span",{className:"nice-code-editor-ai__toolbar-badge",children:"AI"}),L&&e.jsx("span",{className:"nice-code-editor-ai__loading",children:m("codeEditorAI.loading","Thinking...")})]}),e.jsxs("div",{className:"nice-code-editor-ai__toolbar-right",children:[h&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>q(),disabled:L,title:`${m("codeEditorAI.complete","Complete")} (${K}+Space)`,children:["💡 ",m("codeEditorAI.complete","Complete")]}),k&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>J(),disabled:L,title:`${m("codeEditorAI.explain","Explain")} (${K}+E)`,children:["📖 ",m("codeEditorAI.explain","Explain")]}),D&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>{const le=_.current?.getSelection();le&&(c(le),P(!0))},disabled:L,title:`${m("codeEditorAI.refactor","Refactor")} (${K}+R)`,children:["🔧 ",m("codeEditorAI.refactor","Refactor")]}),z&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>se(),disabled:L,title:`${m("codeEditorAI.generate","Generate")} (${K}+G)`,children:["⚡ ",m("codeEditorAI.generate","Generate")]})]})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx(gt,{ref:_,value:B,onChange:$,language:te,onCursorPositionChange:xe,...C}),w&&e.jsxs("div",{className:"nice-code-editor-ai__ghost-text",style:{top:`calc(${(w.lineNumber-1)*19}px + 4px)`,left:`calc(${(w.column-1)*7.8}px + 60px)`},children:[e.jsx("span",{className:"nice-code-editor-ai__ghost-text-content",children:w.text}),e.jsxs("span",{className:"nice-code-editor-ai__ghost-text-hint",children:["Tab ",m("codeEditorAI.toAccept","to accept")]})]})]}),U&&e.jsxs("div",{className:"nice-code-editor-ai__panel nice-code-editor-ai__panel--explain",children:[e.jsxs("div",{className:"nice-code-editor-ai__panel-header",children:[e.jsxs("h4",{children:["📖 ",m("codeEditorAI.explanation","Explanation")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>b(!1),children:"✕"})]}),e.jsx("div",{className:"nice-code-editor-ai__panel-body",children:L?e.jsx("div",{className:"nice-code-editor-ai__panel-loading",children:m("codeEditorAI.analyzing","Analyzing code...")}):e.jsxs("div",{className:"nice-code-editor-ai__explanation",children:[e.jsx("pre",{className:"nice-code-editor-ai__code-preview",children:f}),e.jsx("div",{className:"nice-code-editor-ai__explanation-text",children:g||m("codeEditorAI.noExplanation","Select code and click Explain")})]})})]}),T&&e.jsxs("div",{className:"nice-code-editor-ai__panel nice-code-editor-ai__panel--refactor",children:[e.jsxs("div",{className:"nice-code-editor-ai__panel-header",children:[e.jsxs("h4",{children:["🔧 ",m("codeEditorAI.refactorCode","Refactor Code")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>{P(!1),S(""),v("")},children:"✕"})]}),e.jsxs("div",{className:"nice-code-editor-ai__panel-body",children:[e.jsx("pre",{className:"nice-code-editor-ai__code-preview",children:f}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-input",children:[e.jsx("input",{type:"text",placeholder:m("codeEditorAI.refactorInstruction",'Describe how to refactor (e.g., "extract function", "add error handling")'),value:R,onChange:le=>v(le.target.value),onKeyDown:le=>{le.key==="Enter"&&R&&ie(R)}}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactor-btn",onClick:()=>ie(R),disabled:L||!R,children:L?m("codeEditorAI.refactoring","Refactoring..."):m("codeEditorAI.refactor","Refactor")})]}),u&&e.jsxs("div",{className:"nice-code-editor-ai__refactor-result",children:[e.jsx("h5",{children:m("codeEditorAI.refactoredCode","Refactored Code")}),e.jsx("pre",{className:"nice-code-editor-ai__code-preview nice-code-editor-ai__code-preview--result",children:u}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-actions",children:[e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-apply",onClick:_e,children:["✓ ",m("codeEditorAI.apply","Apply")]}),e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-discard",onClick:()=>{S(""),v("")},children:["✕ ",m("codeEditorAI.discard","Discard")]})]})]})]})]})]})});function Et(n,i){const o=i.getBoundingClientRect();let r,d,h;if("touches"in n){const N=n.touches[0];r=N.clientX-o.left,d=N.clientY-o.top,h=N.force}else"pressure"in n?(r=n.clientX-o.left,d=n.clientY-o.top,h=n.pressure):(r=n.clientX-o.left,d=n.clientY-o.top);return{x:r,y:d,time:Date.now(),pressure:h!==void 0?h:.5}}function Tt(n,i,o,r,d){if(!i)return(o+r)/2;const h=Math.sqrt(Math.pow(n.x-i.x,2)+Math.pow(n.y-i.y,2))/Math.max(1,n.time-i.time),N=Math.min(h/5,1),k=r-N*(r-o),D=n.pressure??.5,z=o+D*(r-o);return k*.7+z*.3}function Rt(n,i,o,r){n.beginPath(),n.moveTo(i.x,i.y),n.lineTo(o.x,o.y),n.lineWidth=r,n.lineCap="round",n.lineJoin="round",n.stroke()}const di=t.forwardRef(function(i,o){const{value:r,onChange:d,width:h="100%",height:N=200,penColor:k="var(--text-primary, #000000)",penWidth:D=2,minWidth:z=.5,maxWidth:X=4,backgroundColor:V="var(--bg-primary, #ffffff)",placeholder:j="Sign here",showClearButton:Y=!0,showUndoButton:K=!0,showColorPicker:te=!1,showSizeSlider:B=!1,velocityFilterWeight:$=.7,throttle:C=16,disabled:_=!1,readOnly:w=!1,displayMode:M=!1,onBegin:U,onEnd:b,className:g,"data-testid":x}=i,T=w||M,P=M?!1:Y,R=M?!1:K,v=M?!1:te,u=M?!1:B,S=t.useRef(null),[f,c]=t.useState(r?.strokes??[]),[s,m]=t.useState([]),[a,p]=t.useState(!1),[E,I]=t.useState(k),[ee,L]=t.useState(D),oe=t.useRef(null),q=t.useRef(0),J=f.length===0&&s.length===0;t.useEffect(()=>{const A=S.current;if(!A)return;const y=A.getContext("2d");if(!y)return;const Z=A.getBoundingClientRect(),W=window.devicePixelRatio||1;A.width=Z.width*W,A.height=Z.height*W,y.scale(W,W),ie()},[h,N]);const ie=t.useCallback(()=>{const A=S.current;if(!A)return;const y=A.getContext("2d");if(!y)return;const Z=A.getBoundingClientRect();y.fillStyle=V,y.fillRect(0,0,Z.width,Z.height),f.forEach(W=>{if(y.strokeStyle=W.color,!(W.points.length<2))for(let F=1;F<W.points.length;F++){const Q=W.points[F-1],ae=W.points[F],ye=Tt(ae,Q,z,X);Rt(y,Q,ae,ye)}})},[f,V,z,X,$]);t.useEffect(()=>{ie()},[ie]),t.useEffect(()=>{r?.strokes&&c(r.strokes)},[r]),t.useEffect(()=>{const A=S.current;if(A)if(f.length===0)d?.(null);else{const y=A.getBoundingClientRect();d?.({strokes:f,width:y.width,height:y.height,timestamp:Date.now()})}},[f,d]);const se=t.useCallback(A=>{if(_||T)return;const y=S.current;if(!y)return;y.setPointerCapture(A.pointerId);const Z=Et(A.nativeEvent,y);p(!0),m([Z]),oe.current=Z,q.current=Z.time,U?.()},[_,T,U]),me=t.useCallback(A=>{if(!a||_||T)return;const y=S.current;if(!y)return;const Z=y.getContext("2d");if(!Z)return;const W=Date.now();if(W-q.current<C)return;const F=Et(A.nativeEvent,y),Q=oe.current;if(Q){Z.strokeStyle=E;const ae=Tt(F,Q,z,X);Rt(Z,Q,F,ae)}m(ae=>[...ae,F]),oe.current=F,q.current=W},[a,_,T,E,z,X,$,C]),pe=t.useCallback(A=>{if(!a)return;const y=S.current;if(y&&y.releasePointerCapture(A.pointerId),s.length>0){const Z={points:s,color:E,width:ee};c(W=>[...W,Z])}p(!1),m([]),oe.current=null,b?.()},[a,s,E,ee,b]),xe=t.useCallback(()=>{c([]),m([]),ie()},[ie]),_e=t.useCallback(()=>{c(A=>A.slice(0,-1))},[]),le=t.useCallback((A="png",y=.92)=>{const Z=S.current;if(!Z)return"";const W=A==="jpeg"?"image/jpeg":"image/png";return Z.toDataURL(W,y)},[]),de=t.useCallback(async(A="png",y=.92)=>{const Z=S.current;return Z?new Promise(W=>{const F=A==="jpeg"?"image/jpeg":"image/png";Z.toBlob(Q=>W(Q),F,y)}):null},[]),he=t.useCallback(()=>{const A=S.current;if(!A)return"";const y=A.getBoundingClientRect(),Z=f.map(W=>W.points.length<2?"":`<path d="${W.points.reduce((Q,ae,ye)=>ye===0?`M ${ae.x} ${ae.y}`:`${Q} L ${ae.x} ${ae.y}`,"")}" stroke="${W.color}" stroke-width="${W.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`).join(`
|
|
276
|
+
`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${y.width}" height="${y.height}" viewBox="0 0 ${A.width} ${A.height}">
|
|
277
|
+
<rect width="100%" height="100%" fill="${V}"/>
|
|
278
|
+
${Z}
|
|
279
|
+
</svg>`},[f,V]);t.useImperativeHandle(o,()=>({clear:xe,undo:_e,isEmpty:()=>f.length===0,getData:()=>{const A=S.current;if(!A||f.length===0)return null;const y=A.getBoundingClientRect();return{strokes:f,width:y.width,height:y.height,timestamp:Date.now()}},setData:A=>{c(A.strokes)},toDataURL:le,toBlob:de,toSVG:he,getCanvas:()=>S.current}),[f,xe,_e,le,de,he]),t.useEffect(()=>{const A=S.current;if(!A)return;const y=Z=>{a&&Z.preventDefault()};return A.addEventListener("touchmove",y,{passive:!1}),()=>A.removeEventListener("touchmove",y)},[a]);const re=P||R||v||u;return e.jsxs("div",{className:`nice-signature ${_?"nice-signature--disabled":""} ${T?"nice-signature--readonly":""} ${g??""}`,style:{width:h},"data-testid":x,children:[re&&e.jsxs("div",{className:"nice-signature__toolbar",children:[v&&e.jsx("div",{className:"nice-signature__color-picker",children:e.jsx("input",{type:"color",value:E,onChange:A=>I(A.target.value),disabled:_||T,title:"Pen color"})}),u&&e.jsx("div",{className:"nice-signature__size-slider",children:e.jsx("input",{type:"range",min:z,max:X,step:.5,value:ee,onChange:A=>L(parseFloat(A.target.value)),disabled:_||T,title:"Pen size"})}),e.jsxs("div",{className:"nice-signature__actions",children:[R&&e.jsx("button",{type:"button",onClick:_e,disabled:_||T||f.length===0,className:"nice-signature__btn",title:"Undo",children:"↩️"}),P&&e.jsx("button",{type:"button",onClick:xe,disabled:_||T||J,className:"nice-signature__btn",title:"Clear",children:"🗑️"})]})]}),e.jsxs("div",{className:"nice-signature__canvas-wrapper",style:{height:N},children:[e.jsx("canvas",{ref:S,className:"nice-signature__canvas",style:{width:"100%",height:"100%",cursor:_||T?"not-allowed":"crosshair",touchAction:"none"},onPointerDown:se,onPointerMove:me,onPointerUp:pe,onPointerLeave:pe}),J&&!a&&j&&e.jsx("div",{className:"nice-signature__placeholder",children:j}),e.jsx("div",{className:"nice-signature__line"})]})]})}),It="nice-signature-styles";if(typeof document<"u"&&!document.getElementById(It)){const n=document.createElement("style");n.id=It,n.textContent=`
|
|
280
|
+
.nice-signature {
|
|
281
|
+
display: flex;
|
|
282
|
+
flex-direction: column;
|
|
283
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
284
|
+
border-radius: 4px;
|
|
285
|
+
overflow: hidden;
|
|
286
|
+
background: var(--nice-bg-surface, #fff);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.nice-signature--disabled {
|
|
290
|
+
opacity: 0.6;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.nice-signature__toolbar {
|
|
294
|
+
display: flex;
|
|
295
|
+
align-items: center;
|
|
296
|
+
gap: 8px;
|
|
297
|
+
padding: 8px;
|
|
298
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
299
|
+
border-bottom: 1px solid var(--nice-border, #e0e0e0);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.nice-signature__color-picker input {
|
|
303
|
+
width: 32px;
|
|
304
|
+
height: 32px;
|
|
305
|
+
padding: 2px;
|
|
306
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
307
|
+
border-radius: 4px;
|
|
308
|
+
cursor: pointer;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.nice-signature__size-slider {
|
|
312
|
+
flex: 1;
|
|
313
|
+
max-width: 120px;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.nice-signature__size-slider input {
|
|
317
|
+
width: 100%;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.nice-signature__actions {
|
|
321
|
+
display: flex;
|
|
322
|
+
gap: 4px;
|
|
323
|
+
margin-left: auto;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.nice-signature__btn {
|
|
327
|
+
padding: 6px 10px;
|
|
328
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
329
|
+
border-radius: 4px;
|
|
330
|
+
background: var(--nice-bg-surface, #fff);
|
|
331
|
+
cursor: pointer;
|
|
332
|
+
font-size: 14px;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.nice-signature__btn:hover:not(:disabled) {
|
|
336
|
+
background: var(--nice-bg-hover, #f0f0f0);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.nice-signature__btn:disabled {
|
|
340
|
+
opacity: 0.4;
|
|
341
|
+
cursor: not-allowed;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.nice-signature__canvas-wrapper {
|
|
345
|
+
position: relative;
|
|
346
|
+
background: #fff;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.nice-signature__canvas {
|
|
350
|
+
display: block;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.nice-signature__placeholder {
|
|
354
|
+
position: absolute;
|
|
355
|
+
top: 50%;
|
|
356
|
+
left: 50%;
|
|
357
|
+
transform: translate(-50%, -50%);
|
|
358
|
+
color: var(--nice-text-secondary, #999);
|
|
359
|
+
font-size: 14px;
|
|
360
|
+
pointer-events: none;
|
|
361
|
+
user-select: none;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.nice-signature__line {
|
|
365
|
+
position: absolute;
|
|
366
|
+
bottom: 30px;
|
|
367
|
+
left: 20px;
|
|
368
|
+
right: 20px;
|
|
369
|
+
height: 1px;
|
|
370
|
+
background: var(--nice-border, #ccc);
|
|
371
|
+
pointer-events: none;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/* Display component */
|
|
375
|
+
.nice-signature-display {
|
|
376
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
377
|
+
border-radius: 4px;
|
|
378
|
+
overflow: hidden;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.nice-signature-display__canvas-wrapper {
|
|
382
|
+
position: relative;
|
|
383
|
+
background: #fff;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.nice-signature-display__canvas {
|
|
387
|
+
display: block;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.nice-signature-display__placeholder {
|
|
391
|
+
position: absolute;
|
|
392
|
+
top: 50%;
|
|
393
|
+
left: 50%;
|
|
394
|
+
transform: translate(-50%, -50%);
|
|
395
|
+
color: var(--nice-text-secondary, #999);
|
|
396
|
+
font-size: 14px;
|
|
397
|
+
}
|
|
398
|
+
`,document.head.appendChild(n)}const mi={recent:"🕒",smileys:"😀",people:"👋",animals:"🐱",food:"🍕",travel:"✈️",activities:"⚽",objects:"💡",symbols:"❤️",flags:"🏳️"},At={recent:"Recently Used",smileys:"Smileys & Emotion",people:"People & Body",animals:"Animals & Nature",food:"Food & Drink",travel:"Travel & Places",activities:"Activities",objects:"Objects",symbols:"Symbols",flags:"Flags"},rt=["","🏻","🏼","🏽","🏾","🏿"],qe=[{emoji:"😀",name:"grinning face",category:"smileys",keywords:["happy","smile"]},{emoji:"😃",name:"grinning face with big eyes",category:"smileys"},{emoji:"😄",name:"grinning face with smiling eyes",category:"smileys"},{emoji:"😁",name:"beaming face",category:"smileys"},{emoji:"😅",name:"grinning face with sweat",category:"smileys"},{emoji:"🤣",name:"rolling on the floor laughing",category:"smileys",keywords:["rofl"]},{emoji:"😂",name:"face with tears of joy",category:"smileys",keywords:["lol","laugh"]},{emoji:"🙂",name:"slightly smiling face",category:"smileys"},{emoji:"😉",name:"winking face",category:"smileys",keywords:["wink"]},{emoji:"😊",name:"smiling face with smiling eyes",category:"smileys"},{emoji:"😇",name:"smiling face with halo",category:"smileys",keywords:["angel"]},{emoji:"🥰",name:"smiling face with hearts",category:"smileys",keywords:["love"]},{emoji:"😍",name:"smiling face with heart-eyes",category:"smileys"},{emoji:"🤩",name:"star-struck",category:"smileys",keywords:["wow"]},{emoji:"😘",name:"face blowing a kiss",category:"smileys",keywords:["kiss"]},{emoji:"😗",name:"kissing face",category:"smileys"},{emoji:"😚",name:"kissing face with closed eyes",category:"smileys"},{emoji:"😋",name:"face savoring food",category:"smileys",keywords:["yum"]},{emoji:"😛",name:"face with tongue",category:"smileys"},{emoji:"😜",name:"winking face with tongue",category:"smileys"},{emoji:"🤪",name:"zany face",category:"smileys",keywords:["crazy"]},{emoji:"😝",name:"squinting face with tongue",category:"smileys"},{emoji:"🤑",name:"money-mouth face",category:"smileys"},{emoji:"🤗",name:"hugging face",category:"smileys",keywords:["hug"]},{emoji:"🤭",name:"face with hand over mouth",category:"smileys"},{emoji:"🤫",name:"shushing face",category:"smileys",keywords:["quiet"]},{emoji:"🤔",name:"thinking face",category:"smileys",keywords:["think","hmm"]},{emoji:"🤐",name:"zipper-mouth face",category:"smileys"},{emoji:"🤨",name:"face with raised eyebrow",category:"smileys"},{emoji:"😐",name:"neutral face",category:"smileys"},{emoji:"😑",name:"expressionless face",category:"smileys"},{emoji:"😶",name:"face without mouth",category:"smileys"},{emoji:"😏",name:"smirking face",category:"smileys",keywords:["smirk"]},{emoji:"😒",name:"unamused face",category:"smileys"},{emoji:"🙄",name:"face with rolling eyes",category:"smileys"},{emoji:"😬",name:"grimacing face",category:"smileys"},{emoji:"😮💨",name:"face exhaling",category:"smileys"},{emoji:"🤥",name:"lying face",category:"smileys"},{emoji:"😌",name:"relieved face",category:"smileys"},{emoji:"😔",name:"pensive face",category:"smileys",keywords:["sad"]},{emoji:"😪",name:"sleepy face",category:"smileys"},{emoji:"🤤",name:"drooling face",category:"smileys"},{emoji:"😴",name:"sleeping face",category:"smileys",keywords:["sleep","zzz"]},{emoji:"😷",name:"face with medical mask",category:"smileys",keywords:["sick"]},{emoji:"🤒",name:"face with thermometer",category:"smileys"},{emoji:"🤕",name:"face with head-bandage",category:"smileys"},{emoji:"🤢",name:"nauseated face",category:"smileys"},{emoji:"🤮",name:"face vomiting",category:"smileys"},{emoji:"🤧",name:"sneezing face",category:"smileys"},{emoji:"🥵",name:"hot face",category:"smileys"},{emoji:"🥶",name:"cold face",category:"smileys"},{emoji:"🥴",name:"woozy face",category:"smileys",keywords:["drunk"]},{emoji:"😵",name:"face with crossed-out eyes",category:"smileys"},{emoji:"🤯",name:"exploding head",category:"smileys",keywords:["mind blown"]},{emoji:"🤠",name:"cowboy hat face",category:"smileys"},{emoji:"🥳",name:"partying face",category:"smileys",keywords:["party"]},{emoji:"🥸",name:"disguised face",category:"smileys"},{emoji:"😎",name:"smiling face with sunglasses",category:"smileys",keywords:["cool"]},{emoji:"🤓",name:"nerd face",category:"smileys",keywords:["nerd"]},{emoji:"🧐",name:"face with monocle",category:"smileys"},{emoji:"😕",name:"confused face",category:"smileys"},{emoji:"😟",name:"worried face",category:"smileys"},{emoji:"🙁",name:"slightly frowning face",category:"smileys"},{emoji:"☹️",name:"frowning face",category:"smileys"},{emoji:"😮",name:"face with open mouth",category:"smileys",keywords:["surprised"]},{emoji:"😯",name:"hushed face",category:"smileys"},{emoji:"😲",name:"astonished face",category:"smileys"},{emoji:"😳",name:"flushed face",category:"smileys"},{emoji:"🥺",name:"pleading face",category:"smileys"},{emoji:"😦",name:"frowning face with open mouth",category:"smileys"},{emoji:"😧",name:"anguished face",category:"smileys"},{emoji:"😨",name:"fearful face",category:"smileys"},{emoji:"😰",name:"anxious face with sweat",category:"smileys"},{emoji:"😥",name:"sad but relieved face",category:"smileys"},{emoji:"😢",name:"crying face",category:"smileys",keywords:["cry"]},{emoji:"😭",name:"loudly crying face",category:"smileys",keywords:["sob"]},{emoji:"😱",name:"face screaming in fear",category:"smileys",keywords:["scream"]},{emoji:"😖",name:"confounded face",category:"smileys"},{emoji:"😣",name:"persevering face",category:"smileys"},{emoji:"😞",name:"disappointed face",category:"smileys"},{emoji:"😓",name:"downcast face with sweat",category:"smileys"},{emoji:"😩",name:"weary face",category:"smileys"},{emoji:"😫",name:"tired face",category:"smileys"},{emoji:"🥱",name:"yawning face",category:"smileys"},{emoji:"😤",name:"face with steam from nose",category:"smileys",keywords:["angry"]},{emoji:"😡",name:"pouting face",category:"smileys",keywords:["rage"]},{emoji:"😠",name:"angry face",category:"smileys"},{emoji:"🤬",name:"face with symbols on mouth",category:"smileys",keywords:["swear"]},{emoji:"😈",name:"smiling face with horns",category:"smileys",keywords:["devil"]},{emoji:"👿",name:"angry face with horns",category:"smileys"},{emoji:"💀",name:"skull",category:"smileys",keywords:["dead"]},{emoji:"☠️",name:"skull and crossbones",category:"smileys"},{emoji:"💩",name:"pile of poo",category:"smileys",keywords:["poop"]},{emoji:"🤡",name:"clown face",category:"smileys"},{emoji:"👹",name:"ogre",category:"smileys"},{emoji:"👺",name:"goblin",category:"smileys"},{emoji:"👻",name:"ghost",category:"smileys"},{emoji:"👽",name:"alien",category:"smileys"},{emoji:"👾",name:"alien monster",category:"smileys"},{emoji:"🤖",name:"robot",category:"smileys"},{emoji:"👋",name:"waving hand",category:"people",skinTones:!0,keywords:["wave","hi"]},{emoji:"🤚",name:"raised back of hand",category:"people",skinTones:!0},{emoji:"🖐️",name:"hand with fingers splayed",category:"people",skinTones:!0},{emoji:"✋",name:"raised hand",category:"people",skinTones:!0},{emoji:"🖖",name:"vulcan salute",category:"people",skinTones:!0},{emoji:"👌",name:"ok hand",category:"people",skinTones:!0,keywords:["ok","perfect"]},{emoji:"🤌",name:"pinched fingers",category:"people",skinTones:!0},{emoji:"🤏",name:"pinching hand",category:"people",skinTones:!0},{emoji:"✌️",name:"victory hand",category:"people",skinTones:!0,keywords:["peace"]},{emoji:"🤞",name:"crossed fingers",category:"people",skinTones:!0},{emoji:"🤟",name:"love-you gesture",category:"people",skinTones:!0},{emoji:"🤘",name:"sign of the horns",category:"people",skinTones:!0,keywords:["rock"]},{emoji:"🤙",name:"call me hand",category:"people",skinTones:!0},{emoji:"👈",name:"backhand index pointing left",category:"people",skinTones:!0},{emoji:"👉",name:"backhand index pointing right",category:"people",skinTones:!0},{emoji:"👆",name:"backhand index pointing up",category:"people",skinTones:!0},{emoji:"🖕",name:"middle finger",category:"people",skinTones:!0},{emoji:"👇",name:"backhand index pointing down",category:"people",skinTones:!0},{emoji:"☝️",name:"index pointing up",category:"people",skinTones:!0},{emoji:"👍",name:"thumbs up",category:"people",skinTones:!0,keywords:["like","good"]},{emoji:"👎",name:"thumbs down",category:"people",skinTones:!0,keywords:["dislike","bad"]},{emoji:"✊",name:"raised fist",category:"people",skinTones:!0},{emoji:"👊",name:"oncoming fist",category:"people",skinTones:!0},{emoji:"🤛",name:"left-facing fist",category:"people",skinTones:!0},{emoji:"🤜",name:"right-facing fist",category:"people",skinTones:!0},{emoji:"👏",name:"clapping hands",category:"people",skinTones:!0,keywords:["clap","applause"]},{emoji:"🙌",name:"raising hands",category:"people",skinTones:!0},{emoji:"👐",name:"open hands",category:"people",skinTones:!0},{emoji:"🤲",name:"palms up together",category:"people",skinTones:!0},{emoji:"🤝",name:"handshake",category:"people",skinTones:!0},{emoji:"🙏",name:"folded hands",category:"people",skinTones:!0,keywords:["pray","please"]},{emoji:"✍️",name:"writing hand",category:"people",skinTones:!0},{emoji:"💪",name:"flexed biceps",category:"people",skinTones:!0,keywords:["strong","muscle"]},{emoji:"🐶",name:"dog face",category:"animals",keywords:["dog"]},{emoji:"🐱",name:"cat face",category:"animals",keywords:["cat"]},{emoji:"🐭",name:"mouse face",category:"animals"},{emoji:"🐹",name:"hamster",category:"animals"},{emoji:"🐰",name:"rabbit face",category:"animals"},{emoji:"🦊",name:"fox",category:"animals"},{emoji:"🐻",name:"bear",category:"animals"},{emoji:"🐼",name:"panda",category:"animals"},{emoji:"🐨",name:"koala",category:"animals"},{emoji:"🐯",name:"tiger face",category:"animals"},{emoji:"🦁",name:"lion",category:"animals"},{emoji:"🐮",name:"cow face",category:"animals"},{emoji:"🐷",name:"pig face",category:"animals",keywords:["pig"]},{emoji:"🐸",name:"frog",category:"animals"},{emoji:"🐵",name:"monkey face",category:"animals"},{emoji:"🙈",name:"see-no-evil monkey",category:"animals"},{emoji:"🙉",name:"hear-no-evil monkey",category:"animals"},{emoji:"🙊",name:"speak-no-evil monkey",category:"animals"},{emoji:"🐔",name:"chicken",category:"animals"},{emoji:"🐧",name:"penguin",category:"animals"},{emoji:"🐦",name:"bird",category:"animals"},{emoji:"🐤",name:"baby chick",category:"animals"},{emoji:"🦆",name:"duck",category:"animals"},{emoji:"🦅",name:"eagle",category:"animals"},{emoji:"🦉",name:"owl",category:"animals"},{emoji:"🦇",name:"bat",category:"animals"},{emoji:"🐺",name:"wolf",category:"animals"},{emoji:"🐗",name:"boar",category:"animals"},{emoji:"🐴",name:"horse face",category:"animals"},{emoji:"🦄",name:"unicorn",category:"animals"},{emoji:"🐝",name:"honeybee",category:"animals",keywords:["bee"]},{emoji:"🐛",name:"bug",category:"animals"},{emoji:"🦋",name:"butterfly",category:"animals"},{emoji:"🐌",name:"snail",category:"animals"},{emoji:"🐙",name:"octopus",category:"animals"},{emoji:"🐬",name:"dolphin",category:"animals"},{emoji:"🐳",name:"spouting whale",category:"animals",keywords:["whale"]},{emoji:"🦈",name:"shark",category:"animals"},{emoji:"🐊",name:"crocodile",category:"animals"},{emoji:"🐢",name:"turtle",category:"animals"},{emoji:"🐍",name:"snake",category:"animals"},{emoji:"🦎",name:"lizard",category:"animals"},{emoji:"🐲",name:"dragon face",category:"animals",keywords:["dragon"]},{emoji:"🌸",name:"cherry blossom",category:"animals",keywords:["flower"]},{emoji:"🌹",name:"rose",category:"animals"},{emoji:"🌻",name:"sunflower",category:"animals"},{emoji:"🌺",name:"hibiscus",category:"animals"},{emoji:"🌷",name:"tulip",category:"animals"},{emoji:"🌲",name:"evergreen tree",category:"animals",keywords:["tree"]},{emoji:"🌳",name:"deciduous tree",category:"animals"},{emoji:"🌴",name:"palm tree",category:"animals"},{emoji:"🌵",name:"cactus",category:"animals"},{emoji:"🍀",name:"four leaf clover",category:"animals",keywords:["lucky"]},{emoji:"🍎",name:"red apple",category:"food",keywords:["apple"]},{emoji:"🍊",name:"tangerine",category:"food",keywords:["orange"]},{emoji:"🍋",name:"lemon",category:"food"},{emoji:"🍌",name:"banana",category:"food"},{emoji:"🍉",name:"watermelon",category:"food"},{emoji:"🍇",name:"grapes",category:"food"},{emoji:"🍓",name:"strawberry",category:"food"},{emoji:"🍒",name:"cherries",category:"food"},{emoji:"🍑",name:"peach",category:"food"},{emoji:"🥭",name:"mango",category:"food"},{emoji:"🍍",name:"pineapple",category:"food"},{emoji:"🥝",name:"kiwi fruit",category:"food"},{emoji:"🍅",name:"tomato",category:"food"},{emoji:"🥑",name:"avocado",category:"food"},{emoji:"🥦",name:"broccoli",category:"food"},{emoji:"🥬",name:"leafy green",category:"food"},{emoji:"🥒",name:"cucumber",category:"food"},{emoji:"🌽",name:"ear of corn",category:"food",keywords:["corn"]},{emoji:"🥕",name:"carrot",category:"food"},{emoji:"🧄",name:"garlic",category:"food"},{emoji:"🧅",name:"onion",category:"food"},{emoji:"🥔",name:"potato",category:"food"},{emoji:"🍞",name:"bread",category:"food"},{emoji:"🥐",name:"croissant",category:"food"},{emoji:"🥖",name:"baguette bread",category:"food"},{emoji:"🧀",name:"cheese wedge",category:"food",keywords:["cheese"]},{emoji:"🥚",name:"egg",category:"food"},{emoji:"🍳",name:"cooking",category:"food",keywords:["egg","breakfast"]},{emoji:"🥓",name:"bacon",category:"food"},{emoji:"🥩",name:"cut of meat",category:"food",keywords:["steak"]},{emoji:"🍗",name:"poultry leg",category:"food",keywords:["chicken"]},{emoji:"🍖",name:"meat on bone",category:"food"},{emoji:"🌭",name:"hot dog",category:"food"},{emoji:"🍔",name:"hamburger",category:"food",keywords:["burger"]},{emoji:"🍟",name:"french fries",category:"food",keywords:["fries"]},{emoji:"🍕",name:"pizza",category:"food"},{emoji:"🥪",name:"sandwich",category:"food"},{emoji:"🌮",name:"taco",category:"food"},{emoji:"🌯",name:"burrito",category:"food"},{emoji:"🥗",name:"green salad",category:"food",keywords:["salad"]},{emoji:"🍝",name:"spaghetti",category:"food",keywords:["pasta"]},{emoji:"🍜",name:"steaming bowl",category:"food",keywords:["ramen","noodles"]},{emoji:"🍲",name:"pot of food",category:"food",keywords:["stew"]},{emoji:"🍣",name:"sushi",category:"food"},{emoji:"🍱",name:"bento box",category:"food"},{emoji:"🥟",name:"dumpling",category:"food"},{emoji:"🍩",name:"doughnut",category:"food",keywords:["donut"]},{emoji:"🍪",name:"cookie",category:"food"},{emoji:"🎂",name:"birthday cake",category:"food",keywords:["cake","birthday"]},{emoji:"🍰",name:"shortcake",category:"food",keywords:["cake"]},{emoji:"🧁",name:"cupcake",category:"food"},{emoji:"🍫",name:"chocolate bar",category:"food",keywords:["chocolate"]},{emoji:"🍬",name:"candy",category:"food"},{emoji:"🍭",name:"lollipop",category:"food"},{emoji:"🍦",name:"soft ice cream",category:"food",keywords:["ice cream"]},{emoji:"☕",name:"hot beverage",category:"food",keywords:["coffee","tea"]},{emoji:"🍵",name:"teacup without handle",category:"food",keywords:["tea"]},{emoji:"🥤",name:"cup with straw",category:"food"},{emoji:"🍺",name:"beer mug",category:"food",keywords:["beer"]},{emoji:"🍻",name:"clinking beer mugs",category:"food",keywords:["cheers"]},{emoji:"🥂",name:"clinking glasses",category:"food",keywords:["champagne","toast"]},{emoji:"🍷",name:"wine glass",category:"food",keywords:["wine"]},{emoji:"🍸",name:"cocktail glass",category:"food",keywords:["martini"]},{emoji:"🚗",name:"automobile",category:"travel",keywords:["car"]},{emoji:"🚕",name:"taxi",category:"travel"},{emoji:"🚌",name:"bus",category:"travel"},{emoji:"🚎",name:"trolleybus",category:"travel"},{emoji:"🏎️",name:"racing car",category:"travel"},{emoji:"🚓",name:"police car",category:"travel"},{emoji:"🚑",name:"ambulance",category:"travel"},{emoji:"🚒",name:"fire engine",category:"travel"},{emoji:"🚐",name:"minibus",category:"travel"},{emoji:"🛻",name:"pickup truck",category:"travel"},{emoji:"🚚",name:"delivery truck",category:"travel",keywords:["truck"]},{emoji:"🚲",name:"bicycle",category:"travel",keywords:["bike"]},{emoji:"🛵",name:"motor scooter",category:"travel"},{emoji:"🏍️",name:"motorcycle",category:"travel"},{emoji:"✈️",name:"airplane",category:"travel",keywords:["plane"]},{emoji:"🚀",name:"rocket",category:"travel"},{emoji:"🚁",name:"helicopter",category:"travel"},{emoji:"🛶",name:"canoe",category:"travel"},{emoji:"⛵",name:"sailboat",category:"travel",keywords:["boat"]},{emoji:"🚢",name:"ship",category:"travel"},{emoji:"🚆",name:"train",category:"travel"},{emoji:"🚇",name:"metro",category:"travel",keywords:["subway"]},{emoji:"🏠",name:"house",category:"travel",keywords:["home"]},{emoji:"🏡",name:"house with garden",category:"travel"},{emoji:"🏢",name:"office building",category:"travel",keywords:["office"]},{emoji:"🏣",name:"Japanese post office",category:"travel"},{emoji:"🏥",name:"hospital",category:"travel"},{emoji:"🏦",name:"bank",category:"travel"},{emoji:"🏨",name:"hotel",category:"travel"},{emoji:"🏪",name:"convenience store",category:"travel",keywords:["store"]},{emoji:"🏫",name:"school",category:"travel"},{emoji:"🏭",name:"factory",category:"travel"},{emoji:"🏰",name:"castle",category:"travel"},{emoji:"⛪",name:"church",category:"travel"},{emoji:"🕌",name:"mosque",category:"travel"},{emoji:"🗼",name:"Tokyo tower",category:"travel"},{emoji:"🗽",name:"Statue of Liberty",category:"travel"},{emoji:"🌁",name:"foggy",category:"travel"},{emoji:"🌃",name:"night with stars",category:"travel"},{emoji:"🌄",name:"sunrise over mountains",category:"travel"},{emoji:"🌅",name:"sunrise",category:"travel"},{emoji:"🌆",name:"cityscape at dusk",category:"travel"},{emoji:"🌇",name:"sunset",category:"travel"},{emoji:"🌉",name:"bridge at night",category:"travel"},{emoji:"⛰️",name:"mountain",category:"travel"},{emoji:"🏔️",name:"snow-capped mountain",category:"travel"},{emoji:"🗻",name:"mount fuji",category:"travel"},{emoji:"🏝️",name:"desert island",category:"travel",keywords:["island"]},{emoji:"🏖️",name:"beach with umbrella",category:"travel",keywords:["beach"]},{emoji:"🌋",name:"volcano",category:"travel"},{emoji:"🌍",name:"globe Europe-Africa",category:"travel",keywords:["earth","world"]},{emoji:"🌎",name:"globe Americas",category:"travel"},{emoji:"🌏",name:"globe Asia-Australia",category:"travel"},{emoji:"🌕",name:"full moon",category:"travel",keywords:["moon"]},{emoji:"🌙",name:"crescent moon",category:"travel"},{emoji:"⭐",name:"star",category:"travel"},{emoji:"🌟",name:"glowing star",category:"travel"},{emoji:"☀️",name:"sun",category:"travel"},{emoji:"🌤️",name:"sun behind small cloud",category:"travel"},{emoji:"⛅",name:"sun behind cloud",category:"travel"},{emoji:"🌧️",name:"cloud with rain",category:"travel",keywords:["rain"]},{emoji:"⛈️",name:"cloud with lightning and rain",category:"travel",keywords:["storm"]},{emoji:"🌨️",name:"cloud with snow",category:"travel",keywords:["snow"]},{emoji:"🌈",name:"rainbow",category:"travel"},{emoji:"⚽",name:"soccer ball",category:"activities",keywords:["football","soccer"]},{emoji:"🏀",name:"basketball",category:"activities"},{emoji:"🏈",name:"american football",category:"activities"},{emoji:"⚾",name:"baseball",category:"activities"},{emoji:"🥎",name:"softball",category:"activities"},{emoji:"🎾",name:"tennis",category:"activities"},{emoji:"🏐",name:"volleyball",category:"activities"},{emoji:"🏉",name:"rugby football",category:"activities"},{emoji:"🥏",name:"flying disc",category:"activities",keywords:["frisbee"]},{emoji:"🎱",name:"pool 8 ball",category:"activities",keywords:["billiards"]},{emoji:"🪀",name:"yo-yo",category:"activities"},{emoji:"🏓",name:"ping pong",category:"activities"},{emoji:"🏸",name:"badminton",category:"activities"},{emoji:"🏒",name:"ice hockey",category:"activities"},{emoji:"🥅",name:"goal net",category:"activities"},{emoji:"⛳",name:"flag in hole",category:"activities",keywords:["golf"]},{emoji:"🏹",name:"bow and arrow",category:"activities",keywords:["archery"]},{emoji:"🎣",name:"fishing pole",category:"activities",keywords:["fishing"]},{emoji:"🥊",name:"boxing glove",category:"activities",keywords:["boxing"]},{emoji:"🥋",name:"martial arts uniform",category:"activities"},{emoji:"🎽",name:"running shirt",category:"activities"},{emoji:"🛹",name:"skateboard",category:"activities"},{emoji:"🛷",name:"sled",category:"activities"},{emoji:"⛸️",name:"ice skate",category:"activities"},{emoji:"🥌",name:"curling stone",category:"activities"},{emoji:"🎿",name:"skis",category:"activities",keywords:["skiing"]},{emoji:"🏂",name:"snowboarder",category:"activities",keywords:["snowboard"]},{emoji:"🏋️",name:"person lifting weights",category:"activities",keywords:["gym"]},{emoji:"🤸",name:"person cartwheeling",category:"activities"},{emoji:"🤺",name:"person fencing",category:"activities"},{emoji:"🏊",name:"person swimming",category:"activities",keywords:["swim"]},{emoji:"🚴",name:"person biking",category:"activities",keywords:["cycling"]},{emoji:"🧘",name:"person in lotus position",category:"activities",keywords:["yoga","meditation"]},{emoji:"🏆",name:"trophy",category:"activities",keywords:["winner","champion"]},{emoji:"🥇",name:"gold medal",category:"activities",keywords:["first"]},{emoji:"🥈",name:"silver medal",category:"activities",keywords:["second"]},{emoji:"🥉",name:"bronze medal",category:"activities",keywords:["third"]},{emoji:"🎮",name:"video game",category:"activities",keywords:["game","gaming"]},{emoji:"🕹️",name:"joystick",category:"activities"},{emoji:"🎲",name:"game die",category:"activities",keywords:["dice"]},{emoji:"🧩",name:"puzzle piece",category:"activities",keywords:["puzzle"]},{emoji:"♟️",name:"chess pawn",category:"activities",keywords:["chess"]},{emoji:"🎯",name:"direct hit",category:"activities",keywords:["dart","target"]},{emoji:"🎰",name:"slot machine",category:"activities"},{emoji:"🎭",name:"performing arts",category:"activities",keywords:["theater","drama"]},{emoji:"🎨",name:"artist palette",category:"activities",keywords:["art","paint"]},{emoji:"🎬",name:"clapper board",category:"activities",keywords:["movie","film"]},{emoji:"🎤",name:"microphone",category:"activities",keywords:["karaoke","sing"]},{emoji:"🎧",name:"headphone",category:"activities",keywords:["music"]},{emoji:"🎼",name:"musical score",category:"activities"},{emoji:"🎹",name:"musical keyboard",category:"activities",keywords:["piano"]},{emoji:"🎷",name:"saxophone",category:"activities"},{emoji:"🎸",name:"guitar",category:"activities"},{emoji:"🎻",name:"violin",category:"activities"},{emoji:"🪘",name:"long drum",category:"activities"},{emoji:"🥁",name:"drum",category:"activities"},{emoji:"⌚",name:"watch",category:"objects"},{emoji:"📱",name:"mobile phone",category:"objects",keywords:["phone","smartphone"]},{emoji:"📲",name:"mobile phone with arrow",category:"objects"},{emoji:"💻",name:"laptop",category:"objects",keywords:["computer"]},{emoji:"🖥️",name:"desktop computer",category:"objects"},{emoji:"🖨️",name:"printer",category:"objects"},{emoji:"⌨️",name:"keyboard",category:"objects"},{emoji:"🖱️",name:"computer mouse",category:"objects"},{emoji:"💾",name:"floppy disk",category:"objects"},{emoji:"💿",name:"optical disk",category:"objects",keywords:["cd"]},{emoji:"📀",name:"dvd",category:"objects"},{emoji:"📷",name:"camera",category:"objects"},{emoji:"📹",name:"video camera",category:"objects"},{emoji:"🎥",name:"movie camera",category:"objects"},{emoji:"📺",name:"television",category:"objects",keywords:["tv"]},{emoji:"📻",name:"radio",category:"objects"},{emoji:"🎙️",name:"studio microphone",category:"objects"},{emoji:"⏰",name:"alarm clock",category:"objects",keywords:["clock"]},{emoji:"⏳",name:"hourglass not done",category:"objects"},{emoji:"⌛",name:"hourglass done",category:"objects"},{emoji:"📡",name:"satellite antenna",category:"objects"},{emoji:"🔋",name:"battery",category:"objects"},{emoji:"🔌",name:"electric plug",category:"objects"},{emoji:"💡",name:"light bulb",category:"objects",keywords:["idea"]},{emoji:"🔦",name:"flashlight",category:"objects"},{emoji:"🕯️",name:"candle",category:"objects"},{emoji:"🧯",name:"fire extinguisher",category:"objects"},{emoji:"🛢️",name:"oil drum",category:"objects"},{emoji:"💸",name:"money with wings",category:"objects"},{emoji:"💵",name:"dollar banknote",category:"objects",keywords:["money"]},{emoji:"💳",name:"credit card",category:"objects"},{emoji:"💰",name:"money bag",category:"objects"},{emoji:"🧲",name:"magnet",category:"objects"},{emoji:"🔧",name:"wrench",category:"objects"},{emoji:"🔨",name:"hammer",category:"objects"},{emoji:"🛠️",name:"hammer and wrench",category:"objects",keywords:["tools"]},{emoji:"⚙️",name:"gear",category:"objects",keywords:["settings"]},{emoji:"🔩",name:"nut and bolt",category:"objects"},{emoji:"🔑",name:"key",category:"objects"},{emoji:"🗝️",name:"old key",category:"objects"},{emoji:"🔒",name:"locked",category:"objects",keywords:["lock"]},{emoji:"🔓",name:"unlocked",category:"objects"},{emoji:"📦",name:"package",category:"objects",keywords:["box"]},{emoji:"📫",name:"closed mailbox with raised flag",category:"objects",keywords:["mail"]},{emoji:"📝",name:"memo",category:"objects",keywords:["note"]},{emoji:"📄",name:"page facing up",category:"objects",keywords:["document"]},{emoji:"📁",name:"file folder",category:"objects",keywords:["folder"]},{emoji:"📂",name:"open file folder",category:"objects"},{emoji:"📅",name:"calendar",category:"objects"},{emoji:"📆",name:"tear-off calendar",category:"objects"},{emoji:"📌",name:"pushpin",category:"objects",keywords:["pin"]},{emoji:"📎",name:"paperclip",category:"objects"},{emoji:"✂️",name:"scissors",category:"objects"},{emoji:"📏",name:"straight ruler",category:"objects"},{emoji:"✏️",name:"pencil",category:"objects"},{emoji:"🖊️",name:"pen",category:"objects"},{emoji:"🖍️",name:"crayon",category:"objects"},{emoji:"📚",name:"books",category:"objects",keywords:["book","library"]},{emoji:"📖",name:"open book",category:"objects"},{emoji:"🔗",name:"link",category:"objects"},{emoji:"💊",name:"pill",category:"objects",keywords:["medicine"]},{emoji:"💉",name:"syringe",category:"objects"},{emoji:"🩹",name:"adhesive bandage",category:"objects"},{emoji:"🧪",name:"test tube",category:"objects"},{emoji:"🔬",name:"microscope",category:"objects"},{emoji:"🔭",name:"telescope",category:"objects"},{emoji:"🧬",name:"dna",category:"objects"},{emoji:"🗑️",name:"wastebasket",category:"objects",keywords:["trash","delete"]},{emoji:"🚿",name:"shower",category:"objects"},{emoji:"🛁",name:"bathtub",category:"objects"},{emoji:"🧹",name:"broom",category:"objects"},{emoji:"🧺",name:"basket",category:"objects"},{emoji:"🧻",name:"roll of paper",category:"objects"},{emoji:"🧼",name:"soap",category:"objects"},{emoji:"🪥",name:"toothbrush",category:"objects"},{emoji:"🛒",name:"shopping cart",category:"objects"},{emoji:"🎁",name:"wrapped gift",category:"objects",keywords:["gift","present"]},{emoji:"🎀",name:"ribbon",category:"objects"},{emoji:"🎈",name:"balloon",category:"objects"},{emoji:"🎉",name:"party popper",category:"objects",keywords:["party","celebration"]},{emoji:"🎊",name:"confetti ball",category:"objects"},{emoji:"❤️",name:"red heart",category:"symbols",keywords:["love","heart"]},{emoji:"🧡",name:"orange heart",category:"symbols"},{emoji:"💛",name:"yellow heart",category:"symbols"},{emoji:"💚",name:"green heart",category:"symbols"},{emoji:"💙",name:"blue heart",category:"symbols"},{emoji:"💜",name:"purple heart",category:"symbols"},{emoji:"🖤",name:"black heart",category:"symbols"},{emoji:"🤍",name:"white heart",category:"symbols"},{emoji:"🤎",name:"brown heart",category:"symbols"},{emoji:"💔",name:"broken heart",category:"symbols"},{emoji:"💕",name:"two hearts",category:"symbols"},{emoji:"💖",name:"sparkling heart",category:"symbols"},{emoji:"💗",name:"growing heart",category:"symbols"},{emoji:"💘",name:"heart with arrow",category:"symbols"},{emoji:"💝",name:"heart with ribbon",category:"symbols"},{emoji:"💞",name:"revolving hearts",category:"symbols"},{emoji:"💯",name:"hundred points",category:"symbols",keywords:["100","perfect"]},{emoji:"💢",name:"anger symbol",category:"symbols"},{emoji:"💥",name:"collision",category:"symbols",keywords:["boom","explosion"]},{emoji:"💫",name:"dizzy",category:"symbols"},{emoji:"💦",name:"sweat droplets",category:"symbols"},{emoji:"💨",name:"dashing away",category:"symbols"},{emoji:"🕳️",name:"hole",category:"symbols"},{emoji:"💬",name:"speech balloon",category:"symbols",keywords:["comment","chat"]},{emoji:"👁️🗨️",name:"eye in speech bubble",category:"symbols"},{emoji:"🗨️",name:"left speech bubble",category:"symbols"},{emoji:"🗯️",name:"right anger bubble",category:"symbols"},{emoji:"💭",name:"thought balloon",category:"symbols"},{emoji:"💤",name:"zzz",category:"symbols",keywords:["sleep"]},{emoji:"🔔",name:"bell",category:"symbols",keywords:["notification"]},{emoji:"🔕",name:"bell with slash",category:"symbols",keywords:["mute"]},{emoji:"🎵",name:"musical note",category:"symbols",keywords:["music"]},{emoji:"🎶",name:"musical notes",category:"symbols"},{emoji:"➕",name:"plus",category:"symbols",keywords:["add"]},{emoji:"➖",name:"minus",category:"symbols"},{emoji:"➗",name:"divide",category:"symbols"},{emoji:"✖️",name:"multiply",category:"symbols"},{emoji:"♾️",name:"infinity",category:"symbols"},{emoji:"💲",name:"heavy dollar sign",category:"symbols",keywords:["money"]},{emoji:"🔴",name:"red circle",category:"symbols"},{emoji:"🟠",name:"orange circle",category:"symbols"},{emoji:"🟡",name:"yellow circle",category:"symbols"},{emoji:"🟢",name:"green circle",category:"symbols"},{emoji:"🔵",name:"blue circle",category:"symbols"},{emoji:"🟣",name:"purple circle",category:"symbols"},{emoji:"⚫",name:"black circle",category:"symbols"},{emoji:"⚪",name:"white circle",category:"symbols"},{emoji:"🟤",name:"brown circle",category:"symbols"},{emoji:"🔺",name:"red triangle pointed up",category:"symbols"},{emoji:"🔻",name:"red triangle pointed down",category:"symbols"},{emoji:"🔷",name:"large blue diamond",category:"symbols"},{emoji:"🔶",name:"large orange diamond",category:"symbols"},{emoji:"✅",name:"check mark button",category:"symbols",keywords:["done","yes"]},{emoji:"❌",name:"cross mark",category:"symbols",keywords:["no","wrong"]},{emoji:"❎",name:"cross mark button",category:"symbols"},{emoji:"✔️",name:"check mark",category:"symbols"},{emoji:"⭕",name:"hollow red circle",category:"symbols"},{emoji:"❗",name:"exclamation mark",category:"symbols",keywords:["warning"]},{emoji:"❓",name:"question mark",category:"symbols"},{emoji:"❕",name:"white exclamation mark",category:"symbols"},{emoji:"❔",name:"white question mark",category:"symbols"},{emoji:"⚠️",name:"warning",category:"symbols"},{emoji:"🚫",name:"prohibited",category:"symbols",keywords:["no","forbidden"]},{emoji:"🔞",name:"no one under eighteen",category:"symbols"},{emoji:"⛔",name:"no entry",category:"symbols",keywords:["stop"]},{emoji:"🔙",name:"back arrow",category:"symbols"},{emoji:"🔚",name:"end arrow",category:"symbols"},{emoji:"🔛",name:"on! arrow",category:"symbols"},{emoji:"🔜",name:"soon arrow",category:"symbols"},{emoji:"🔝",name:"top arrow",category:"symbols"},{emoji:"🔃",name:"clockwise vertical arrows",category:"symbols",keywords:["refresh"]},{emoji:"🔄",name:"counterclockwise arrows button",category:"symbols",keywords:["sync"]},{emoji:"🔁",name:"repeat button",category:"symbols"},{emoji:"🔀",name:"shuffle tracks button",category:"symbols"},{emoji:"▶️",name:"play button",category:"symbols"},{emoji:"⏸️",name:"pause button",category:"symbols"},{emoji:"⏹️",name:"stop button",category:"symbols"},{emoji:"⏺️",name:"record button",category:"symbols"},{emoji:"⏭️",name:"next track button",category:"symbols"},{emoji:"⏮️",name:"last track button",category:"symbols"},{emoji:"⏩",name:"fast-forward button",category:"symbols"},{emoji:"⏪",name:"fast reverse button",category:"symbols"},{emoji:"🔼",name:"upwards button",category:"symbols"},{emoji:"🔽",name:"downwards button",category:"symbols"},{emoji:"⬆️",name:"up arrow",category:"symbols"},{emoji:"⬇️",name:"down arrow",category:"symbols"},{emoji:"⬅️",name:"left arrow",category:"symbols"},{emoji:"➡️",name:"right arrow",category:"symbols"},{emoji:"↗️",name:"up-right arrow",category:"symbols"},{emoji:"↘️",name:"down-right arrow",category:"symbols"},{emoji:"↙️",name:"down-left arrow",category:"symbols"},{emoji:"↖️",name:"up-left arrow",category:"symbols"},{emoji:"↕️",name:"up-down arrow",category:"symbols"},{emoji:"↔️",name:"left-right arrow",category:"symbols"},{emoji:"🔀",name:"shuffle",category:"symbols"},{emoji:"ℹ️",name:"information",category:"symbols",keywords:["info"]},{emoji:"🆕",name:"new button",category:"symbols",keywords:["new"]},{emoji:"🆗",name:"ok button",category:"symbols",keywords:["ok"]},{emoji:"🆙",name:"up! button",category:"symbols"},{emoji:"🆒",name:"cool button",category:"symbols",keywords:["cool"]},{emoji:"🆓",name:"free button",category:"symbols",keywords:["free"]},{emoji:"🔟",name:"keycap: 10",category:"symbols"},{emoji:"#️⃣",name:"keycap: #",category:"symbols"},{emoji:"*️⃣",name:"keycap: *",category:"symbols"},{emoji:"0️⃣",name:"keycap: 0",category:"symbols"},{emoji:"1️⃣",name:"keycap: 1",category:"symbols"},{emoji:"2️⃣",name:"keycap: 2",category:"symbols"},{emoji:"3️⃣",name:"keycap: 3",category:"symbols"},{emoji:"4️⃣",name:"keycap: 4",category:"symbols"},{emoji:"5️⃣",name:"keycap: 5",category:"symbols"},{emoji:"6️⃣",name:"keycap: 6",category:"symbols"},{emoji:"7️⃣",name:"keycap: 7",category:"symbols"},{emoji:"8️⃣",name:"keycap: 8",category:"symbols"},{emoji:"9️⃣",name:"keycap: 9",category:"symbols"},{emoji:"©️",name:"copyright",category:"symbols"},{emoji:"®️",name:"registered",category:"symbols"},{emoji:"™️",name:"trade mark",category:"symbols"},{emoji:"🏳️",name:"white flag",category:"flags"},{emoji:"🏴",name:"black flag",category:"flags"},{emoji:"🏁",name:"chequered flag",category:"flags",keywords:["finish","racing"]},{emoji:"🚩",name:"triangular flag",category:"flags"},{emoji:"🏳️🌈",name:"rainbow flag",category:"flags",keywords:["pride"]},{emoji:"🏳️⚧️",name:"transgender flag",category:"flags"},{emoji:"🇺🇸",name:"flag: United States",category:"flags",keywords:["usa","america"]},{emoji:"🇬🇧",name:"flag: United Kingdom",category:"flags",keywords:["uk","britain"]},{emoji:"🇩🇪",name:"flag: Germany",category:"flags"},{emoji:"🇫🇷",name:"flag: France",category:"flags"},{emoji:"🇵🇱",name:"flag: Poland",category:"flags"},{emoji:"🇪🇸",name:"flag: Spain",category:"flags"},{emoji:"🇮🇹",name:"flag: Italy",category:"flags"},{emoji:"🇯🇵",name:"flag: Japan",category:"flags"},{emoji:"🇨🇳",name:"flag: China",category:"flags"},{emoji:"🇰🇷",name:"flag: South Korea",category:"flags"},{emoji:"🇮🇳",name:"flag: India",category:"flags"},{emoji:"🇧🇷",name:"flag: Brazil",category:"flags"},{emoji:"🇷🇺",name:"flag: Russia",category:"flags"},{emoji:"🇦🇺",name:"flag: Australia",category:"flags"},{emoji:"🇨🇦",name:"flag: Canada",category:"flags"},{emoji:"🇲🇽",name:"flag: Mexico",category:"flags"},{emoji:"🇳🇱",name:"flag: Netherlands",category:"flags"},{emoji:"🇧🇪",name:"flag: Belgium",category:"flags"},{emoji:"🇨🇭",name:"flag: Switzerland",category:"flags"},{emoji:"🇦🇹",name:"flag: Austria",category:"flags"},{emoji:"🇸🇪",name:"flag: Sweden",category:"flags"},{emoji:"🇳🇴",name:"flag: Norway",category:"flags"},{emoji:"🇩🇰",name:"flag: Denmark",category:"flags"},{emoji:"🇫🇮",name:"flag: Finland",category:"flags"},{emoji:"🇵🇹",name:"flag: Portugal",category:"flags"},{emoji:"🇬🇷",name:"flag: Greece",category:"flags"},{emoji:"🇹🇷",name:"flag: Turkey",category:"flags"},{emoji:"🇮🇱",name:"flag: Israel",category:"flags"},{emoji:"🇦🇪",name:"flag: United Arab Emirates",category:"flags"},{emoji:"🇸🇦",name:"flag: Saudi Arabia",category:"flags"},{emoji:"🇿🇦",name:"flag: South Africa",category:"flags"},{emoji:"🇪🇬",name:"flag: Egypt",category:"flags"},{emoji:"🇳🇬",name:"flag: Nigeria",category:"flags"},{emoji:"🇹🇭",name:"flag: Thailand",category:"flags"},{emoji:"🇻🇳",name:"flag: Vietnam",category:"flags"},{emoji:"🇸🇬",name:"flag: Singapore",category:"flags"},{emoji:"🇲🇾",name:"flag: Malaysia",category:"flags"},{emoji:"🇮🇩",name:"flag: Indonesia",category:"flags"},{emoji:"🇵🇭",name:"flag: Philippines",category:"flags"},{emoji:"🇦🇷",name:"flag: Argentina",category:"flags"},{emoji:"🇨🇱",name:"flag: Chile",category:"flags"},{emoji:"🇨🇴",name:"flag: Colombia",category:"flags"},{emoji:"🇺🇦",name:"flag: Ukraine",category:"flags"},{emoji:"🇨🇿",name:"flag: Czech Republic",category:"flags"},{emoji:"🇭🇺",name:"flag: Hungary",category:"flags"},{emoji:"🇷🇴",name:"flag: Romania",category:"flags"},{emoji:"🇮🇪",name:"flag: Ireland",category:"flags"},{emoji:"🇳🇿",name:"flag: New Zealand",category:"flags"}],Dt="nice-emoji-picker-recent",rn=({onSelect:n,showSearch:i=!0,searchPlaceholder:o,showSkinTones:r=!0,defaultSkinTone:d=0,showRecent:h=!0,maxRecent:N=24,recentEmojis:k,onRecentChange:D,categories:z,customEmojis:X=[],columns:V=8,size:j="md",className:Y="",style:K,"data-testid":te="nice-emoji-picker"})=>{const{t:B}=ne.Wo(),[$,C]=t.useState(""),[_,w]=t.useState(h?"recent":"smileys"),[M,U]=t.useState(d),[b,g]=t.useState(!1),x=t.useRef(null),[T,P]=t.useState(()=>{if(typeof window>"u")return[];try{return JSON.parse(localStorage.getItem(Dt)||"[]")}catch{return[]}}),R=k??T,v=z??[...h?["recent"]:[],"smileys","people","animals","food","travel","activities","objects","symbols","flags"],u=t.useMemo(()=>{if(!$)return qe;const a=$.toLowerCase();return qe.filter(p=>p.name.toLowerCase().includes(a)||p.emoji.includes(a)||p.keywords?.some(E=>E.toLowerCase().includes(a)))},[$]),S=t.useMemo(()=>{const a={};for(const p of v)p==="recent"?a[p]=R.map(E=>qe.find(I=>I.emoji===E)).filter(E=>E!==void 0).slice(0,N):a[p]=u.filter(E=>E.category===p);return a},[v,u,R,N]),f=t.useCallback((a,p)=>!p||M===0?a:a.replace(/[\u{1F3FB}-\u{1F3FF}]/gu,"")+rt[M],[M]),c=t.useCallback(a=>{const p=f(a.emoji,a.skinTones),E=[a.emoji,...R.filter(I=>I!==a.emoji)].slice(0,N);if(k===void 0){P(E);try{localStorage.setItem(Dt,JSON.stringify(E))}catch{}}D?.(E),n?.(p,a)},[f,R,N,k,D,n]),s=t.useCallback(a=>{n?.(`:${a.name}:`,a)},[n]);t.useEffect(()=>{if(!b)return;const a=p=>{x.current&&!x.current.contains(p.target)&&g(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[b]);const m=$?u:S[_]||[];return e.jsxs("div",{className:`nice-emoji-picker nice-emoji-picker--${j} ${Y}`,style:K,"data-testid":te,children:[i&&e.jsxs("div",{className:"nice-emoji-picker__search",children:[e.jsx("input",{type:"text",value:$,onChange:a=>C(a.target.value),placeholder:o??B("search","Search emoji..."),className:"nice-emoji-picker__search-input","data-testid":`${te}-search`}),r&&e.jsxs("div",{className:"nice-emoji-picker__skin-tone-wrapper",children:[e.jsxs("button",{ref:x,type:"button",className:"nice-emoji-picker__skin-tone-btn",onClick:()=>g(!b),title:B("skinTone","Skin tone"),children:["✋",rt[M]]}),b&&e.jsx("div",{className:"nice-emoji-picker__skin-tone-menu",children:rt.map((a,p)=>e.jsxs("button",{type:"button",className:`nice-emoji-picker__skin-tone-option ${p===M?"nice-emoji-picker__skin-tone-option--selected":""}`,onClick:()=>{U(p),g(!1)},children:["✋",a]},p))})]})]}),!$&&e.jsx("div",{className:"nice-emoji-picker__categories",role:"tablist",children:v.map(a=>e.jsx("button",{type:"button",className:`nice-emoji-picker__category-btn ${_===a?"nice-emoji-picker__category-btn--selected":""}`,onClick:()=>w(a),title:At[a],role:"tab","aria-selected":_===a,children:mi[a]},a))}),e.jsxs("div",{className:"nice-emoji-picker__grid-container",children:[$?e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:B("searchResults","Search Results")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${V}, 1fr)`},children:u.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:B("noEmojis","No emojis found")}):u.map((a,p)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>c(a),title:a.name,children:f(a.emoji,a.skinTones)},`${a.emoji}-${p}`))})]}):e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:At[_]}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${V}, 1fr)`},children:m.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:_==="recent"?B("noRecent","No recent emojis"):B("noEmojis","No emojis")}):m.map((a,p)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>c(a),title:a.name,children:f(a.emoji,a.skinTones)},`${a.emoji}-${p}`))})]}),X.length>0&&e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:B("custom","Custom")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${V}, 1fr)`},children:X.map(a=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji nice-emoji-picker__emoji--custom",onClick:()=>s(a),title:a.name,children:e.jsx("img",{src:a.url,alt:a.name})},a.id))})]})]})]})};rn.displayName="NiceEmojiPicker";const cn=[{label:"Free",value:"free"},{label:"1:1",value:"1:1",ratio:1},{label:"4:3",value:"4:3",ratio:4/3},{label:"3:4",value:"3:4",ratio:3/4},{label:"16:9",value:"16:9",ratio:16/9},{label:"9:16",value:"9:16",ratio:9/16},{label:"3:2",value:"3:2",ratio:3/2},{label:"2:3",value:"2:3",ratio:2/3}],ln=({src:n,initialCrop:i={x:10,y:10,width:80,height:80},initialRotation:o=0,initialZoom:r=1,aspectRatios:d=cn,defaultAspectRatio:h="free",customAspectRatio:N,showRotation:k=!0,showFlip:D=!0,showZoom:z=!0,minZoom:X=.5,maxZoom:V=3,zoomStep:j=.1,showGrid:Y=!0,overlayColor:K="rgba(0, 0, 0, 0.5)",toolbarPosition:te="bottom",toolbarCollapsible:B=!1,defaultToolbarCollapsed:$=!1,onChange:C,className:_="",style:w,"data-testid":M="nice-crop-editor"})=>{const{t:U}=ne.Wo(),b=t.useRef(null),g=t.useRef(null),[x,T]=t.useState(i),[P,R]=t.useState(o),[v,u]=t.useState(r),[S,f]=t.useState(!1),[c,s]=t.useState(!1),[m,a]=t.useState(h),[p,E]=t.useState($),[I,ee]=t.useState(!1),[L,oe]=t.useState({x:0,y:0,crop:x}),q=m==="custom"?N:d.find(y=>y.value===m)?.ratio;t.useEffect(()=>{C?.({crop:x,rotation:P,flipH:S,flipV:c,zoom:v})},[x,P,S,c,v,C]);const J=t.useCallback((y,Z)=>{if(!q)return y;const W=b.current?.clientWidth??400,F=b.current?.clientHeight??300,Q=y.width/100*W,ae=y.height/100*F,ye=Q/ae;if(Math.abs(ye-q)<.01)return y;if(Z?.includes("e")||Z?.includes("w")){const fe=Q/q/F*100;return{...y,height:Math.min(100-y.y,Math.max(5,fe))}}else if(Z?.includes("n")||Z?.includes("s")){const fe=ae*q/W*100;return{...y,width:Math.min(100-y.x,Math.max(5,fe))}}else{const fe=Q/q/F*100;return{...y,height:Math.min(100-y.y,Math.max(5,fe))}}},[q]),ie=t.useCallback((y,Z)=>{Z===!1||(y.preventDefault(),y.stopPropagation(),ee(Z),!b.current?.getBoundingClientRect())||oe({x:y.clientX,y:y.clientY,crop:{...x}})},[x]),se=t.useCallback(y=>{if(!I||!b.current)return;const Z=b.current.getBoundingClientRect(),W=(y.clientX-L.x)/Z.width*100,F=(y.clientY-L.y)/Z.height*100;let Q={...L.crop};if(I==="crop")Q.x=Math.max(0,Math.min(100-Q.width,L.crop.x+W)),Q.y=Math.max(0,Math.min(100-Q.height,L.crop.y+F));else{switch(I){case"resize-nw":Q.x=Math.max(0,Math.min(L.crop.x+L.crop.width-5,L.crop.x+W)),Q.y=Math.max(0,Math.min(L.crop.y+L.crop.height-5,L.crop.y+F)),Q.width=L.crop.width-(Q.x-L.crop.x),Q.height=L.crop.height-(Q.y-L.crop.y);break;case"resize-ne":Q.y=Math.max(0,Math.min(L.crop.y+L.crop.height-5,L.crop.y+F)),Q.width=Math.max(5,Math.min(100-Q.x,L.crop.width+W)),Q.height=L.crop.height-(Q.y-L.crop.y);break;case"resize-sw":Q.x=Math.max(0,Math.min(L.crop.x+L.crop.width-5,L.crop.x+W)),Q.width=L.crop.width-(Q.x-L.crop.x),Q.height=Math.max(5,Math.min(100-Q.y,L.crop.height+F));break;case"resize-se":Q.width=Math.max(5,Math.min(100-Q.x,L.crop.width+W)),Q.height=Math.max(5,Math.min(100-Q.y,L.crop.height+F));break;case"resize-n":Q.y=Math.max(0,Math.min(L.crop.y+L.crop.height-5,L.crop.y+F)),Q.height=L.crop.height-(Q.y-L.crop.y);break;case"resize-s":Q.height=Math.max(5,Math.min(100-Q.y,L.crop.height+F));break;case"resize-e":Q.width=Math.max(5,Math.min(100-Q.x,L.crop.width+W));break;case"resize-w":Q.x=Math.max(0,Math.min(L.crop.x+L.crop.width-5,L.crop.x+W)),Q.width=L.crop.width-(Q.x-L.crop.x);break}Q=J(Q,I.replace("resize-",""))}T(Q)},[I,L,J]),me=t.useCallback(()=>{ee(!1)},[]);t.useEffect(()=>{if(I)return document.addEventListener("mousemove",se),document.addEventListener("mouseup",me),()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",me)}},[I,se,me]);const pe=t.useCallback(()=>{R(y=>(y-90+360)%360)},[]),xe=t.useCallback(()=>{R(y=>(y+90)%360)},[]),_e=t.useCallback(()=>{f(y=>!y)},[]),le=t.useCallback(()=>{s(y=>!y)},[]),de=t.useCallback(()=>{T(i),R(o),u(r),f(!1),s(!1),a(h)},[i,o,r,h]);t.useEffect(()=>{T(y=>J(y))},[m,J]);const he=`scale(${v}) rotate(${P}deg) scaleX(${S?-1:1}) scaleY(${c?-1:1})`,re=te==="top"?"column-reverse":te==="left"?"row-reverse":te==="right"?"row":"column",A=te==="left"||te==="right";return e.jsxs("div",{className:`nice-crop-editor nice-crop-editor--toolbar-${te} ${_}`,style:{display:"flex",flexDirection:re,gap:12,...w},"data-testid":M,children:[e.jsxs("div",{ref:b,className:"nice-crop-editor__container","data-testid":`${M}-container`,children:[e.jsx("img",{ref:g,src:n,alt:"",className:"nice-crop-editor__image",style:{transform:he},draggable:!1}),e.jsxs("div",{className:"nice-crop-editor__overlay",style:{backgroundColor:K},children:[e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:0,left:0,right:0,height:`${x.y}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{bottom:0,left:0,right:0,height:`${100-x.y-x.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${x.y}%`,left:0,width:`${x.x}%`,height:`${x.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${x.y}%`,right:0,width:`${100-x.x-x.width}%`,height:`${x.height}%`}})]}),e.jsxs("div",{className:"nice-crop-editor__crop-area",style:{left:`${x.x}%`,top:`${x.y}%`,width:`${x.width}%`,height:`${x.height}%`},onMouseDown:y=>ie(y,"crop"),"data-testid":`${M}-crop-area`,children:[Y&&e.jsxs("div",{className:"nice-crop-editor__grid",children:[e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--h1"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--h2"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--v1"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--v2"})]}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--nw",onMouseDown:y=>ie(y,"resize-nw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--ne",onMouseDown:y=>ie(y,"resize-ne")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--sw",onMouseDown:y=>ie(y,"resize-sw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--se",onMouseDown:y=>ie(y,"resize-se")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--n",onMouseDown:y=>ie(y,"resize-n")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--s",onMouseDown:y=>ie(y,"resize-s")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--e",onMouseDown:y=>ie(y,"resize-e")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--w",onMouseDown:y=>ie(y,"resize-w")})]})]}),e.jsxs("div",{className:`nice-crop-editor__controls ${p?"nice-crop-editor__controls--collapsed":""}`,style:{display:"flex",flexDirection:A?"column":"row",flexWrap:A?"nowrap":"wrap",gap:8,alignItems:A?"stretch":"center",flexShrink:0},children:[B&&e.jsx("button",{type:"button",className:"nice-crop-editor__toolbar-toggle","aria-expanded":!p,"aria-label":p?"Show toolbar":"Hide toolbar",onClick:()=>E(y=>!y),style:{alignSelf:"flex-start",background:"var(--bg-secondary)",border:"1px solid var(--border-color)",borderRadius:4,padding:"2px 8px",cursor:"pointer",color:"var(--text-primary)",fontSize:12},children:p?"▸":"▾"}),!p&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsx("label",{className:"nice-crop-editor__label",children:U("aspectRatio","Aspect Ratio")}),e.jsx("div",{className:"nice-crop-editor__aspect-buttons",children:d.map(y=>e.jsx("button",{type:"button",className:`nice-crop-editor__aspect-btn ${m===y.value?"nice-crop-editor__aspect-btn--selected":""}`,onClick:()=>a(y.value),title:y.label,children:y.label},y.value))})]}),z&&e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsxs("label",{className:"nice-crop-editor__label",children:[U("zoom","Zoom"),": ",Math.round(v*100),"%"]}),e.jsx("input",{type:"range",className:"nice-crop-editor__slider",min:X,max:V,step:j,value:v,onChange:y=>u(parseFloat(y.target.value)),"data-testid":`${M}-zoom`})]}),e.jsxs("div",{className:"nice-crop-editor__control-group nice-crop-editor__control-group--row",children:[k&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:pe,title:U("rotateLeft","Rotate Left"),children:"↺"}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:xe,title:U("rotateRight","Rotate Right"),children:"↻"})]}),D&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${S?"nice-crop-editor__btn--active":""}`,onClick:_e,title:U("flipHorizontal","Flip Horizontal"),children:"⇆"}),e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${c?"nice-crop-editor__btn--active":""}`,onClick:le,title:U("flipVertical","Flip Vertical"),children:"⇅"})]}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn nice-crop-editor__btn--reset",onClick:de,title:U("reset","Reset"),children:"⟲"})]})]})]})]})};ln.displayName="NiceCropEditor";const ui={strokeColor:"#ff3333",fillColor:"transparent",strokeWidth:2,opacity:1,fontSize:16,fontFamily:"sans-serif"};function pi(n,i){switch(i.type){case"SET_TOOL":return{...n,activeTool:i.tool,selectedId:null};case"SET_STYLE":return{...n,style:{...n.style,...i.style}};case"ADD_ANNOTATION":return{...n,annotations:[...n.annotations,i.annotation],past:[...n.past,n.annotations],future:[]};case"UPDATE_ANNOTATION":return{...n,annotations:n.annotations.map(o=>o.id===i.id?{...o,...i.updates}:o),past:[...n.past,n.annotations],future:[]};case"DELETE_ANNOTATION":return{...n,annotations:n.annotations.filter(o=>o.id!==i.id),selectedId:n.selectedId===i.id?null:n.selectedId,past:[...n.past,n.annotations],future:[]};case"SELECT":return{...n,selectedId:i.id};case"SET_ANNOTATIONS":return{...n,annotations:i.annotations,past:[],future:[]};case"SET_ZOOM":return{...n,zoom:i.zoom};case"SET_PAN":return{...n,panX:i.panX,panY:i.panY};case"UNDO":{if(n.past.length===0)return n;const o=n.past[n.past.length-1];return{...n,annotations:o,past:n.past.slice(0,-1),future:[n.annotations,...n.future]}}case"REDO":{if(n.future.length===0)return n;const o=n.future[0];return{...n,annotations:o,past:[...n.past,n.annotations],future:n.future.slice(1)}}case"CLEAR":return{...n,annotations:[],selectedId:null,past:[...n.past,n.annotations],future:[]};default:return n}}let hi=0;function gi(){return`ann-${Date.now()}-${hi++}`}function fi(n){const{style:i}=n,o=`stroke="${i.strokeColor}" stroke-width="${i.strokeWidth}" fill="${i.fillColor}" opacity="${i.opacity}"`;switch(n.tool){case"rectangle":return`<rect x="${n.x}" y="${n.y}" width="${n.width}" height="${n.height}" ${o} />`;case"ellipse":{const r=n.x+n.width/2,d=n.y+n.height/2;return`<ellipse cx="${r}" cy="${d}" rx="${n.width/2}" ry="${n.height/2}" ${o} />`}case"arrow":{const r=n,d=Math.atan2(r.endY-r.y,r.endX-r.x),h=12,N=r.endX-h*Math.cos(d-Math.PI/6),k=r.endY-h*Math.sin(d-Math.PI/6),D=r.endX-h*Math.cos(d+Math.PI/6),z=r.endY-h*Math.sin(d+Math.PI/6);return`<line x1="${r.x}" y1="${r.y}" x2="${r.endX}" y2="${r.endY}" ${o} />
|
|
399
|
+
<polygon points="${r.endX},${r.endY} ${N},${k} ${D},${z}" fill="${i.strokeColor}" opacity="${i.opacity}" />`}case"line":{const r=n;return`<line x1="${r.x}" y1="${r.y}" x2="${r.endX}" y2="${r.endY}" ${o} />`}case"text":{const r=n;return`<text x="${r.x}" y="${r.y+(r.style.fontSize??16)}" fill="${i.strokeColor}" font-size="${i.fontSize}" font-family="${i.fontFamily}" opacity="${i.opacity}">${yi(r.text)}</text>`}case"freehand":{const r=n;return r.points.length<2?"":`<path d="${r.points.map((h,N)=>`${N===0?"M":"L"}${h.x},${h.y}`).join(" ")}" ${o} fill="none" />`}case"blur":{const r=n,d=`blur-${r.id}`;return`<defs><filter id="${d}"><feGaussianBlur stdDeviation="${r.intensity??5}" /></filter></defs>
|
|
400
|
+
<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" fill="transparent" stroke="none" filter="url(#${d})" />`}default:return""}}function yi(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const dn=t.forwardRef(({src:n,alt:i="Annotatable image",annotations:o,activeTool:r,defaultStyle:d,onAnnotationsChange:h,className:N,readOnly:k=!1,minZoom:D=.1,maxZoom:z=5},X)=>{const V=t.useRef(null),j=t.useRef(null),Y=t.useRef(null),[K,te]=t.useState(!1),[B,$]=t.useState({width:0,height:0}),[C,_]=t.useReducer(pi,{annotations:o??[],selectedId:null,activeTool:r??"select",style:{...ui,...d},zoom:1,panX:0,panY:0,past:[],future:[]});t.useEffect(()=>{r&&_({type:"SET_TOOL",tool:r})},[r]),t.useEffect(()=>{h?.(C.annotations)},[C.annotations,h]),t.useEffect(()=>{const v=new Image;v.crossOrigin="anonymous",v.onload=()=>{Y.current=v,$({width:v.naturalWidth,height:v.naturalHeight}),te(!0)},v.src=n},[n]);const w=t.useRef({isDrawing:!1,startX:0,startY:0,currentAnnotation:null,freehandPoints:[]}),M=t.useCallback((v,u)=>{const S=V.current;if(!S)return{x:0,y:0};const f=S.getBoundingClientRect();return{x:(v-f.left-C.panX)/C.zoom,y:(u-f.top-C.panY)/C.zoom}},[C.zoom,C.panX,C.panY]),U=t.useCallback(()=>{const v=V.current,u=v?.getContext("2d"),S=Y.current;if(!v||!u||!S||!K)return;v.width=j.current?.clientWidth??S.naturalWidth,v.height=j.current?.clientHeight??S.naturalHeight,u.clearRect(0,0,v.width,v.height),u.save(),u.translate(C.panX,C.panY),u.scale(C.zoom,C.zoom),u.drawImage(S,0,0);for(const c of C.annotations){switch(u.save(),u.globalAlpha=c.style.opacity,u.strokeStyle=c.style.strokeColor,u.fillStyle=c.style.fillColor,u.lineWidth=c.style.strokeWidth,c.tool){case"rectangle":u.strokeRect(c.x,c.y,c.width,c.height),c.style.fillColor!=="transparent"&&u.fillRect(c.x,c.y,c.width,c.height);break;case"ellipse":{u.beginPath(),u.ellipse(c.x+c.width/2,c.y+c.height/2,Math.abs(c.width/2),Math.abs(c.height/2),0,0,Math.PI*2),u.stroke(),c.style.fillColor!=="transparent"&&u.fill();break}case"arrow":{const s=c;u.beginPath(),u.moveTo(s.x,s.y),u.lineTo(s.endX,s.endY),u.stroke();const m=Math.atan2(s.endY-s.y,s.endX-s.x),a=12;u.beginPath(),u.moveTo(s.endX,s.endY),u.lineTo(s.endX-a*Math.cos(m-Math.PI/6),s.endY-a*Math.sin(m-Math.PI/6)),u.lineTo(s.endX-a*Math.cos(m+Math.PI/6),s.endY-a*Math.sin(m+Math.PI/6)),u.closePath(),u.fillStyle=c.style.strokeColor,u.fill();break}case"line":{const s=c;u.beginPath(),u.moveTo(s.x,s.y),u.lineTo(s.endX,s.endY),u.stroke();break}case"text":{const s=c;u.font=`${s.style.fontSize??16}px ${s.style.fontFamily??"sans-serif"}`,u.fillStyle=s.style.strokeColor,u.fillText(s.text,s.x,s.y+(s.style.fontSize??16));break}case"freehand":{const s=c;if(s.points.length<2)break;u.beginPath(),u.moveTo(s.points[0].x,s.points[0].y);for(let m=1;m<s.points.length;m++)u.lineTo(s.points[m].x,s.points[m].y);u.stroke();break}case"blur":{const s=c;u.filter=`blur(${s.intensity??5}px)`,u.drawImage(S,s.x,s.y,s.width,s.height,s.x,s.y,s.width,s.height),u.filter="none";break}}c.id===C.selectedId&&(u.strokeStyle="#4488ff",u.lineWidth=1,u.setLineDash([4,4]),u.strokeRect(c.x-2,c.y-2,c.width+4,c.height+4),u.setLineDash([])),u.restore()}const f=w.current;if(f.isDrawing&&f.currentAnnotation){u.save();const c=f.currentAnnotation;if(u.globalAlpha=c.style.opacity,u.strokeStyle=c.style.strokeColor,u.lineWidth=c.style.strokeWidth,u.setLineDash([6,3]),c.tool==="freehand"){const s=c;if(s.points.length>=2){u.beginPath(),u.moveTo(s.points[0].x,s.points[0].y);for(let m=1;m<s.points.length;m++)u.lineTo(s.points[m].x,s.points[m].y);u.stroke()}}else if(c.tool==="rectangle")u.strokeRect(c.x,c.y,c.width,c.height);else if(c.tool==="ellipse")u.beginPath(),u.ellipse(c.x+c.width/2,c.y+c.height/2,Math.abs(c.width/2),Math.abs(c.height/2),0,0,Math.PI*2),u.stroke();else if(c.tool==="arrow"||c.tool==="line"){const s=c;u.beginPath(),u.moveTo(s.x,s.y),u.lineTo(s.endX,s.endY),u.stroke()}u.restore()}u.restore()},[C,K]);t.useEffect(()=>{U()},[U]);const b=t.useCallback(v=>{if(k)return;const u=M(v.clientX,v.clientY),S=C.activeTool;if(S==="select"){const s=[...C.annotations].reverse().find(m=>m.tool==="freehand"?!1:u.x>=m.x&&u.x<=m.x+m.width&&u.y>=m.y&&u.y<=m.y+m.height);_({type:"SELECT",id:s?.id??null});return}const f=w.current;f.isDrawing=!0,f.startX=u.x,f.startY=u.y;const c={id:gi(),style:{...C.style},x:u.x,y:u.y,width:0,height:0};switch(S){case"rectangle":f.currentAnnotation={...c,tool:"rectangle"};break;case"ellipse":f.currentAnnotation={...c,tool:"ellipse"};break;case"arrow":f.currentAnnotation={...c,tool:"arrow",endX:u.x,endY:u.y};break;case"line":f.currentAnnotation={...c,tool:"line",endX:u.x,endY:u.y};break;case"text":f.currentAnnotation={...c,tool:"text",text:"Text",width:100,height:C.style.fontSize??16};break;case"freehand":f.freehandPoints=[u],f.currentAnnotation={...c,tool:"freehand",points:[u]};break;case"blur":f.currentAnnotation={...c,tool:"blur",intensity:5};break}},[k,M,C.activeTool,C.style,C.annotations]),g=t.useCallback(v=>{const u=w.current;if(!u.isDrawing||!u.currentAnnotation)return;const S=M(v.clientX,v.clientY),f=u.currentAnnotation;if(f.tool==="freehand"){u.freehandPoints.push(S),f.points=[...u.freehandPoints];const c=u.freehandPoints.map(m=>m.x),s=u.freehandPoints.map(m=>m.y);f.x=Math.min(...c),f.y=Math.min(...s),f.width=Math.max(...c)-f.x,f.height=Math.max(...s)-f.y}else if(f.tool==="arrow"||f.tool==="line")f.endX=S.x,f.endY=S.y,f.width=Math.abs(S.x-u.startX),f.height=Math.abs(S.y-u.startY);else{const c=Math.min(u.startX,S.x),s=Math.min(u.startY,S.y);f.x=c,f.y=s,f.width=Math.abs(S.x-u.startX),f.height=Math.abs(S.y-u.startY)}U()},[M,U]),x=t.useCallback(()=>{const v=w.current;if(!v.isDrawing||!v.currentAnnotation)return;const u=v.currentAnnotation;(u.tool==="text"||u.tool==="freehand"||Math.abs(u.width)>2||Math.abs(u.height)>2)&&_({type:"ADD_ANNOTATION",annotation:u}),v.isDrawing=!1,v.currentAnnotation=null,v.freehandPoints=[]},[]),T=t.useCallback(v=>{v.preventDefault();const u=v.deltaY>0?.9:1.1,S=Math.max(D,Math.min(z,C.zoom*u));_({type:"SET_ZOOM",zoom:S})},[C.zoom,D,z]);t.useEffect(()=>{if(k)return;const v=u=>{(u.metaKey||u.ctrlKey)&&u.key==="z"&&!u.shiftKey?(u.preventDefault(),_({type:"UNDO"})):(u.metaKey||u.ctrlKey)&&(u.key==="y"||u.key==="z"&&u.shiftKey)?(u.preventDefault(),_({type:"REDO"})):(u.key==="Delete"||u.key==="Backspace")&&C.selectedId&&_({type:"DELETE_ANNOTATION",id:C.selectedId})};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[k,C.selectedId]),t.useImperativeHandle(X,()=>({exportAsDataURL:async(v="png",u=.92)=>{const S=document.createElement("canvas"),f=Y.current;if(!f)return"";S.width=f.naturalWidth,S.height=f.naturalHeight;const c=S.getContext("2d");c.drawImage(f,0,0);for(const s of C.annotations){if(c.save(),c.globalAlpha=s.style.opacity,c.strokeStyle=s.style.strokeColor,c.fillStyle=s.style.fillColor,c.lineWidth=s.style.strokeWidth,s.tool==="rectangle")c.strokeRect(s.x,s.y,s.width,s.height);else if(s.tool==="ellipse")c.beginPath(),c.ellipse(s.x+s.width/2,s.y+s.height/2,Math.abs(s.width/2),Math.abs(s.height/2),0,0,Math.PI*2),c.stroke();else if(s.tool==="freehand"){const m=s;if(m.points.length>=2){c.beginPath(),c.moveTo(m.points[0].x,m.points[0].y);for(let a=1;a<m.points.length;a++)c.lineTo(m.points[a].x,m.points[a].y);c.stroke()}}else if(s.tool==="text"){const m=s;c.font=`${m.style.fontSize??16}px ${m.style.fontFamily??"sans-serif"}`,c.fillStyle=m.style.strokeColor,c.fillText(m.text,m.x,m.y+(m.style.fontSize??16))}c.restore()}return S.toDataURL(`image/${v}`,u)},exportAnnotations:()=>[...C.annotations],importAnnotations:v=>{_({type:"SET_ANNOTATIONS",annotations:v})},exportAsSVG:()=>{const{width:v,height:u}=B,S=C.annotations.map(fi);return`<svg xmlns="http://www.w3.org/2000/svg" width="${v}" height="${u}" viewBox="0 0 ${v} ${u}">
|
|
401
|
+
${S.join(`
|
|
402
|
+
`)}
|
|
403
|
+
</svg>`},undo:()=>_({type:"UNDO"}),redo:()=>_({type:"REDO"}),setZoom:v=>{_({type:"SET_ZOOM",zoom:Math.max(D,Math.min(z,v))})},fitToScreen:()=>{const v=j.current,u=Y.current;if(!v||!u)return;const S=v.clientWidth/u.naturalWidth,f=v.clientHeight/u.naturalHeight,c=Math.min(S,f,1);_({type:"SET_ZOOM",zoom:c}),_({type:"SET_PAN",panX:0,panY:0})},clear:()=>_({type:"CLEAR"})}),[C.annotations,B,D,z]);const P=t.useCallback(v=>{if(v.touches.length!==1)return;const u=v.touches[0];b({clientX:u.clientX,clientY:u.clientY,preventDefault:()=>{}})},[b]),R=t.useCallback(v=>{if(v.touches.length!==1)return;const u=v.touches[0];g({clientX:u.clientX,clientY:u.clientY})},[g]);return e.jsx("div",{ref:j,className:`nice-image-annotator ${N??""}`,style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"},children:e.jsx("canvas",{ref:V,className:"nice-image-annotator__canvas",style:{cursor:C.activeTool==="select"?"default":"crosshair"},onMouseDown:b,onMouseMove:g,onMouseUp:x,onMouseLeave:x,onWheel:T,onTouchStart:P,onTouchMove:R,onTouchEnd:x,role:"img","aria-label":i})})});dn.displayName="NiceImageAnnotator";function bi(n){let i=n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return i=i.replace(/```(\w*)\n([\s\S]*?)```/g,(o,r,d)=>`<pre><code class="language-${r}">${d.trim()}</code></pre>`),i=i.replace(/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm,(o,r,d,h)=>{const N=r.split("|").filter(D=>D.trim()).map(D=>`<th>${D.trim()}</th>`).join(""),k=h.trim().split(`
|
|
404
|
+
`).map(D=>`<tr>${D.split("|").filter(X=>X.trim()).map(X=>`<td>${X.trim()}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${N}</tr></thead><tbody>${k}</tbody></table>`}),i=i.replace(/^#### (.+)$/gm,"<h4>$1</h4>"),i=i.replace(/^### (.+)$/gm,"<h3>$1</h3>"),i=i.replace(/^## (.+)$/gm,"<h2>$1</h2>"),i=i.replace(/^# (.+)$/gm,"<h1>$1</h1>"),i=i.replace(/^> (.+)$/gm,"<blockquote>$1</blockquote>"),i=i.replace(/^---$/gm,"<hr/>"),i=i.replace(/^- \[x\] (.+)$/gm,'<li class="task done">☑ $1</li>'),i=i.replace(/^- \[ \] (.+)$/gm,'<li class="task">☐ $1</li>'),i=i.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),i=i.replace(/\*(.+?)\*/g,"<em>$1</em>"),i=i.replace(/~~(.+?)~~/g,"<del>$1</del>"),i=i.replace(/`(.+?)`/g,"<code>$1</code>"),i=i.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" style="max-width:100%"/>'),i=i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>'),i=i.replace(/^\- (.+)$/gm,"<li>$1</li>"),i=i.replace(/^\d+\. (.+)$/gm,"<li>$1</li>"),i=i.replace(/\n/g,"<br/>"),i}const xi=[{key:"bold",label:"B",md:"**",tip:"Bold",shortcut:"Ctrl+B",group:"format"},{key:"italic",label:"I",md:"*",tip:"Italic",shortcut:"Ctrl+I",group:"format"},{key:"strike",label:"S̶",md:"~~",tip:"Strikethrough",group:"format"},{key:"code",label:"< >",md:"`",tip:"Inline code",group:"format"},{key:"h1",label:"H1",md:"# ",tip:"Heading 1",group:"heading"},{key:"h2",label:"H2",md:"## ",tip:"Heading 2",group:"heading"},{key:"h3",label:"H3",md:"### ",tip:"Heading 3",group:"heading"},{key:"ul",label:"•",md:"- ",tip:"Unordered list",group:"list"},{key:"ol",label:"1.",md:"1. ",tip:"Ordered list",group:"list"},{key:"task",label:"☑",md:"- [ ] ",tip:"Task list",group:"list"},{key:"quote",label:"❝",md:"> ",tip:"Blockquote",group:"block"},{key:"hr",label:"—",md:`---
|
|
405
|
+
`,tip:"Horizontal rule",group:"block"},{key:"link",label:"🔗",md:"[](url)",tip:"Link",shortcut:"Ctrl+K",group:"insert"},{key:"image",label:"🖼",md:"",tip:"Image",group:"insert"},{key:"table",label:"⊞",md:`| H1 | H2 | H3 |
|
|
406
|
+
| --- | --- | --- |
|
|
407
|
+
| c1 | c2 | c3 |
|
|
408
|
+
`,tip:"Table",group:"insert"},{key:"codeblock",label:"```",md:"```\n",tip:"Code block",group:"insert"}],ji=["format","heading","list","block","insert"],mn=t.forwardRef(({value:n="",onChange:i,preview:o="side",placeholder:r,disabled:d,readOnly:h,size:N="md",editorSize:k="standard",toolbar:D=!0,minHeight:z=200,showWordCount:X=!1,showLineNumbers:V=!1,onExportHtml:j,onImageUpload:Y,className:K,style:te,id:B},$)=>{const C=ne.cs(B),[_,w]=t.useState("edit"),[M,U]=t.useState(!1),b=t.useRef(null),g=t.useMemo(()=>bi(n),[n]),x=t.useMemo(()=>{const f=n.trim()?n.trim().split(/\s+/).length:0,c=n.length,s=n.split(`
|
|
409
|
+
`).length;return{words:f,chars:c,lines:s}},[n]),T=t.useCallback(f=>{const c=b.current;if(!c)return;const s=c.selectionStart,m=c.selectionEnd,a=n.slice(s,m);let p,E;f==="[](url)"?(p=n.slice(0,s)+`[${a||"text"}](url)`+n.slice(m),E=s+1+(a||"text").length+2):f===""?(p=n.slice(0,s)+``+n.slice(m),E=s+2+(a||"alt").length+2):f.endsWith(`
|
|
410
|
+
`)||f.endsWith(" ")?(p=n.slice(0,s)+f+a+n.slice(m),E=s+f.length+a.length):(p=n.slice(0,s)+f+a+f+n.slice(m),E=s+f.length+a.length+f.length),i?.(p),requestAnimationFrame(()=>{c.focus(),c.setSelectionRange(E,E)})},[n,i]),P=t.useCallback(f=>{if((f.ctrlKey||f.metaKey)&&(f.key==="b"?(f.preventDefault(),T("**")):f.key==="i"?(f.preventDefault(),T("*")):f.key==="k"&&(f.preventDefault(),T("[](url)"))),f.key==="Tab"){f.preventDefault();const c=f.currentTarget,s=c.selectionStart,m=c.selectionEnd,a=" ";if(f.shiftKey){const I=n.slice(0,s).lastIndexOf(`
|
|
411
|
+
`)+1;if(n.slice(I,I+a.length)===a){const ee=n.slice(0,I)+n.slice(I+a.length);i?.(ee),requestAnimationFrame(()=>{c.selectionStart=c.selectionEnd=s-a.length})}}else{const p=n.slice(0,s)+a+n.slice(m);i?.(p),requestAnimationFrame(()=>{c.selectionStart=c.selectionEnd=s+a.length})}}},[n,i,T]),R=t.useCallback(async f=>{if(!Y)return;const c=Array.from(f.dataTransfer.files).filter(s=>s.type.startsWith("image/"));if(c.length!==0){f.preventDefault();for(const s of c){const m=await Y(s),a=b.current;if(!a)continue;const p=a.selectionStart,E=`
|
|
412
|
+
`,I=n.slice(0,p)+E+n.slice(p);i?.(I)}}},[n,i,Y]),v=o!=="tab"||_==="edit",u=o==="side"||o==="tab"&&_==="preview"||o===!0,S=`nice-md-editor nice-md-editor--${N} nice-editor--${k} nice-md-editor--preview-${o}${M?" nice-md-editor--fullscreen":""} ${K||""}`;return e.jsxs("div",{ref:$,id:C,className:S,style:te,children:[D&&e.jsxs("div",{className:"nice-md-editor__toolbar",children:[ji.map((f,c)=>e.jsxs(t.Fragment,{children:[c>0&&e.jsx("span",{className:"nice-md-editor__sep"}),xi.filter(s=>s.group===f).map(s=>e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:s.shortcut?`${s.tip} (${s.shortcut})`:s.tip,disabled:d||h,onClick:()=>T(s.md),children:s.label},s.key))]},f)),e.jsx("span",{className:"nice-md-editor__sep"}),e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Fullscreen",onClick:()=>U(!M),children:M?"⊙":"⛶"}),j&&e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Export HTML",onClick:()=>j(g),children:"↗"}),o==="tab"&&e.jsxs("span",{className:"nice-md-editor__tabs",children:[e.jsx("button",{type:"button",className:`nice-md-editor__tab${_==="edit"?" nice-md-editor__tab--active":""}`,onClick:()=>w("edit"),children:"Edit"}),e.jsx("button",{type:"button",className:`nice-md-editor__tab${_==="preview"?" nice-md-editor__tab--active":""}`,onClick:()=>w("preview"),children:"Preview"})]})]}),e.jsxs("div",{className:"nice-md-editor__body",style:{minHeight:z},children:[v&&e.jsxs("div",{className:"nice-md-editor__editor-wrap",children:[V&&e.jsx("div",{className:"nice-md-editor__line-numbers",children:Array.from({length:x.lines},(f,c)=>e.jsx("div",{className:"nice-md-editor__line-no",children:c+1},c))}),e.jsx("textarea",{ref:b,className:"nice-md-editor__textarea",value:n,onChange:f=>i?.(f.target.value),onKeyDown:P,onDrop:R,placeholder:r,disabled:d,readOnly:h,style:{minHeight:z}})]}),u&&e.jsx("div",{className:"nice-md-editor__preview",dangerouslySetInnerHTML:{__html:ne.es(g)},style:{minHeight:z}})]}),X&&e.jsxs("div",{className:"nice-md-editor__statusbar",children:[e.jsxs("span",{children:[x.words," words"]}),e.jsxs("span",{children:[x.chars," chars"]}),e.jsxs("span",{children:[x.lines," lines"]})]})]})});mn.displayName="NiceMarkdownEditor";const Lt={rotation:0,flipH:!1,flipV:!1,brightness:100,contrast:100,saturate:100,blur:0,crop:null,annotations:[]},_i=["crop","rotate","flip","brightness","contrast","saturate","blur","annotate"],un=t.forwardRef(({src:n,size:i="md",editorSize:o="standard",tools:r=_i,showToolbar:d=!0,showZoom:h=!0,maxUndo:N=30,onSave:k,onCancel:D,onChange:z,width:X="100%",height:V=500,className:j,style:Y,id:K,...te},B)=>{const $=ne.cs(K),{t:C}=ne.Wo(),_=t.useRef(null),w=t.useRef(null),[M,U]=t.useState({...Lt}),[b,g]=t.useState(null),[x,T]=t.useState(!1),[P,R]=t.useState(1),[v,u]=t.useState("rect"),[S,f]=t.useState("#ff0000"),[c,s]=t.useState({w:0,h:0}),[m,a]=t.useState([]),[p,E]=t.useState([]),[I,ee]=t.useState(null),[L,oe]=t.useState(null),[q,J]=t.useState(null),ie=t.useCallback(A=>{a(y=>[...y.slice(-(N-1)),A]),E([])},[N]),se=t.useCallback(A=>{U(y=>{ie(y);const Z={...y,...A};return z?.(Z),Z})},[z,ie]),me=t.useCallback(()=>{if(m.length===0)return;const A=m[m.length-1];a(y=>y.slice(0,-1)),E(y=>[...y,M]),U(A),z?.(A)},[m,M,z]),pe=t.useCallback(()=>{if(p.length===0)return;const A=p[p.length-1];E(y=>y.slice(0,-1)),a(y=>[...y,M]),U(A),z?.(A)},[p,M,z]);t.useEffect(()=>{const A=new Image;A.crossOrigin="anonymous",A.onload=()=>{w.current=A,s({w:A.width,h:A.height}),T(!0)},A.src=n},[n]),t.useEffect(()=>{if(!x||!_.current||!w.current)return;const A=_.current,y=A.getContext("2d");if(!y)return;const Z=w.current,W=M.rotation%180!==0,F=W?Z.height:Z.width,Q=W?Z.width:Z.height;A.width=F,A.height=Q,y.clearRect(0,0,F,Q),y.save(),y.filter=`brightness(${M.brightness}%) contrast(${M.contrast}%) saturate(${M.saturate}%) blur(${M.blur}px)`,y.translate(F/2,Q/2),y.rotate(M.rotation*Math.PI/180),y.scale(M.flipH?-1:1,M.flipV?-1:1),y.drawImage(Z,-Z.width/2,-Z.height/2),y.restore(),M.annotations.forEach(ae=>{switch(y.save(),y.strokeStyle=ae.color??"red",y.fillStyle=ae.color??"red",y.lineWidth=ae.strokeWidth??2,y.font=`${ae.fontSize??16}px sans-serif`,ae.type){case"text":y.fillText(ae.text??"",ae.x,ae.y);break;case"rect":y.strokeRect(ae.x,ae.y,ae.width??100,ae.height??50);break;case"circle":{const ye=(ae.width??50)/2,ge=(ae.height??50)/2;y.beginPath(),y.ellipse(ae.x+ye,ae.y+ge,ye,ge,0,0,Math.PI*2),y.stroke();break}case"line":y.beginPath(),y.moveTo(ae.x,ae.y),y.lineTo(ae.x+(ae.width??100),ae.y+(ae.height??0)),y.stroke();break;case"arrow":{const ye=ae.x+(ae.width??100),ge=ae.y+(ae.height??0);y.beginPath(),y.moveTo(ae.x,ae.y),y.lineTo(ye,ge),y.stroke();const fe=Math.atan2(ge-ae.y,ye-ae.x),ke=10;y.beginPath(),y.moveTo(ye,ge),y.lineTo(ye-ke*Math.cos(fe-.4),ge-ke*Math.sin(fe-.4)),y.lineTo(ye-ke*Math.cos(fe+.4),ge-ke*Math.sin(fe+.4)),y.closePath(),y.fill();break}}y.restore()}),L&&(y.save(),y.fillStyle="rgba(0,0,0,0.5)",y.fillRect(0,0,F,Q),y.clearRect(L.x,L.y,L.w,L.h),y.strokeStyle="var(--bg-primary, #fff)",y.lineWidth=2,y.setLineDash([5,5]),y.strokeRect(L.x,L.y,L.w,L.h),y.restore())},[x,M,L]);const xe=t.useCallback(A=>{if(!_.current)return;const y=_.current.getBoundingClientRect(),Z=_.current.width/y.width,W=_.current.height/y.height,F=(A.clientX-y.left)*Z,Q=(A.clientY-y.top)*W;b==="crop"?ee({startX:F,startY:Q}):b==="annotate"&&J({startX:F,startY:Q})},[b]),_e=t.useCallback(A=>{if(!_.current)return;const y=_.current.getBoundingClientRect(),Z=_.current.width/y.width,W=_.current.height/y.height,F=(A.clientX-y.left)*Z,Q=(A.clientY-y.top)*W;I&&oe({x:Math.min(I.startX,F),y:Math.min(I.startY,Q),w:Math.abs(F-I.startX),h:Math.abs(Q-I.startY)})},[I]),le=t.useCallback(A=>{if(I&&L&&L.w>5&&L.h>5&&se({crop:{x:L.x,y:L.y,width:L.w,height:L.h}}),ee(null),q&&_.current){const y=_.current.getBoundingClientRect(),Z=_.current.width/y.width,W=_.current.height/y.height,F=(A.clientX-y.left)*Z,Q=(A.clientY-y.top)*W,ae=F-q.startX,ye=Q-q.startY;if(Math.abs(ae)>3||Math.abs(ye)>3||v==="text"){const ge={type:v,x:q.startX,y:q.startY,width:Math.abs(ae)||100,height:Math.abs(ye)||50,color:S,strokeWidth:2,text:v==="text"?prompt(C("imageEditor.annotationText","Text:"))??"":void 0};se({annotations:[...M.annotations,ge]})}J(null)}},[I,L,q,v,S,M.annotations,se,C]),de=t.useCallback(()=>{if(!M.crop||!_.current)return;const A=_.current,y=A.getContext("2d");if(!y)return;const{x:Z,y:W,width:F,height:Q}=M.crop,ae=y.getImageData(Z,W,F,Q);A.width=F,A.height=Q,y.putImageData(ae,0,0),oe(null),g(null)},[M.crop]),he=t.useCallback(()=>{if(!_.current)return;const A=_.current.toDataURL("image/png");k?.(A,M)},[k,M]),re=t.useCallback(()=>{U({...Lt}),oe(null),g(null)},[]);return t.useMemo(()=>`brightness(${M.brightness}%) contrast(${M.contrast}%) saturate(${M.saturate}%) blur(${M.blur}px)`,[M.brightness,M.contrast,M.saturate,M.blur]),e.jsxs("div",{ref:B,id:$,className:`nice-image-editor nice-image-editor--${i} nice-editor--${o} ${j??""}`,style:{...Y,width:X,height:V},role:"application","aria-label":C("imageEditor.label","Image Editor"),...te,children:[d&&e.jsxs("div",{className:"nice-image-editor__toolbar",role:"toolbar",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:me,disabled:m.length===0,title:C("imageEditor.undo","Undo"),children:"↶"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:pe,disabled:p.length===0,title:C("imageEditor.redo","Redo"),children:"↷"}),e.jsx("span",{className:"nice-image-editor__sep"}),r.includes("rotate")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({rotation:(M.rotation-90+360)%360}),title:C("imageEditor.rotateLeft","Rotate left"),children:"↺"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({rotation:(M.rotation+90)%360}),title:C("imageEditor.rotateRight","Rotate right"),children:"↻"})]}),r.includes("flip")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({flipH:!M.flipH}),title:C("imageEditor.flipH","Flip horizontal"),children:"⇔"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({flipV:!M.flipV}),title:C("imageEditor.flipV","Flip vertical"),children:"⇕"})]}),r.includes("crop")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-image-editor__btn ${b==="crop"?"nice-image-editor__btn--active":""}`,onClick:()=>g(b==="crop"?null:"crop"),title:C("imageEditor.crop","Crop"),children:"⊡"}),b==="crop"&&M.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:de,title:C("imageEditor.applyCrop","Apply crop"),children:"✓"})]}),r.includes("brightness")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[C("imageEditor.brightness","☀"),e.jsx("input",{type:"range",min:0,max:200,value:M.brightness,onChange:A=>se({brightness:Number(A.target.value)}),className:"nice-image-editor__slider",title:C("imageEditor.brightness","Brightness")})]}),r.includes("contrast")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[C("imageEditor.contrast","◑"),e.jsx("input",{type:"range",min:0,max:200,value:M.contrast,onChange:A=>se({contrast:Number(A.target.value)}),className:"nice-image-editor__slider",title:C("imageEditor.contrast","Contrast")})]}),r.includes("saturate")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[C("imageEditor.saturate","🎨"),e.jsx("input",{type:"range",min:0,max:200,value:M.saturate,onChange:A=>se({saturate:Number(A.target.value)}),className:"nice-image-editor__slider",title:C("imageEditor.saturate","Saturation")})]}),r.includes("blur")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[C("imageEditor.blur","⊘"),e.jsx("input",{type:"range",min:0,max:20,step:.5,value:M.blur,onChange:A=>se({blur:Number(A.target.value)}),className:"nice-image-editor__slider",title:C("imageEditor.blur","Blur")})]}),r.includes("annotate")&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:`nice-image-editor__btn ${b==="annotate"?"nice-image-editor__btn--active":""}`,onClick:()=>g(b==="annotate"?null:"annotate"),title:C("imageEditor.annotate","Annotate"),children:"✎"}),b==="annotate"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{className:"nice-image-editor__select",value:v,onChange:A=>u(A.target.value),children:[e.jsx("option",{value:"rect",children:"□ Rect"}),e.jsx("option",{value:"circle",children:"○ Circle"}),e.jsx("option",{value:"line",children:"╱ Line"}),e.jsx("option",{value:"arrow",children:"→ Arrow"}),e.jsx("option",{value:"text",children:"T Text"})]}),e.jsx("input",{type:"color",value:S,onChange:A=>f(A.target.value),className:"nice-image-editor__color",title:C("imageEditor.color","Color")}),M.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({annotations:M.annotations.slice(0,-1)}),title:C("imageEditor.removeLastAnnotation","Remove last"),children:"⌫"})]})]}),e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:re,title:C("imageEditor.reset","Reset"),children:"⟲"}),k&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:he,children:C("imageEditor.save","Save")}),D&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:D,children:C("imageEditor.cancel","Cancel")})]}),e.jsx("div",{className:"nice-image-editor__canvas-wrap",children:e.jsx("canvas",{ref:_,className:"nice-image-editor__canvas",onMouseDown:xe,onMouseMove:_e,onMouseUp:le,style:{cursor:b==="crop"||b==="annotate"?"crosshair":"default",transform:`scale(${P})`,transformOrigin:"center center"}})}),h&&e.jsxs("div",{className:"nice-image-editor__footer",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>R(A=>Math.max(.1,A-.1)),title:"Zoom out",children:"−"}),e.jsxs("span",{style:{fontSize:"0.85em",minWidth:40,textAlign:"center"},children:[Math.round(P*100),"%"]}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>R(A=>Math.min(5,A+.1)),title:"Zoom in",children:"+"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>R(1),title:"Reset zoom",children:"1:1"}),e.jsx("span",{style:{flex:1}}),e.jsxs("span",{style:{fontSize:"0.8em",color:"var(--nice-text-secondary, #666)"},children:[c.w,"×",c.h,"px · ",M.rotation,"°"]})]})]})});un.displayName="NiceImageEditor";const pn=t.forwardRef(({value:n,onChange:i,penColor:o="var(--text-primary, #000)",penWidth:r=2,backgroundColor:d="var(--bg-primary, #fff)",width:h=400,height:N=200,size:k="md",disabled:D=!1,readOnly:z=!1,showClear:X=!0,showUndo:V=!0,label:j,exportFormat:Y="image/png",className:K,style:te,id:B,...$},C)=>{const _=ne.cs(B),{t:w}=ne.Wo(),M=t.useRef(null),[U,b]=t.useState(!1),g=t.useRef([]),x=t.useRef([]),[T,P]=t.useState(!0),R=t.useCallback(()=>{const m=M.current;if(!m)return;const a=m.getContext("2d");if(a){a.fillStyle=d,a.fillRect(0,0,m.width,m.height),a.strokeStyle=o,a.lineWidth=r,a.lineCap="round",a.lineJoin="round";for(const p of g.current)if(!(p.length<2)){a.beginPath(),a.moveTo(p[0].x,p[0].y);for(let E=1;E<p.length;E++)a.lineTo(p[E].x,p[E].y);a.stroke()}}},[d,o,r]);t.useEffect(()=>{if(n&&M.current){const m=new Image;m.onload=()=>{const a=M.current?.getContext("2d");!a||!M.current||(a.fillStyle=d,a.fillRect(0,0,M.current.width,M.current.height),a.drawImage(m,0,0),P(!1))},m.src=n}else n||(g.current=[],P(!0),R())},[n,d,R]),t.useEffect(()=>{const m=M.current;m&&(m.width=h,m.height=N,R())},[h,N,R]);const v=t.useCallback(m=>{const a=M.current,p=a.getBoundingClientRect(),E=a.width/p.width,I=a.height/p.height;if("touches"in m){const ee=m.touches[0];return{x:(ee.clientX-p.left)*E,y:(ee.clientY-p.top)*I}}return{x:(m.clientX-p.left)*E,y:(m.clientY-p.top)*I}},[]),u=t.useCallback(m=>{if(D||z)return;m.preventDefault();const a=v(m);x.current=[a],b(!0)},[D,z,v]),S=t.useCallback(m=>{if(!U)return;m.preventDefault();const a=v(m);x.current.push(a);const p=M.current,E=p?.getContext("2d");if(!E||!p)return;const I=x.current;I.length>=2&&(E.strokeStyle=o,E.lineWidth=r,E.lineCap="round",E.beginPath(),E.moveTo(I[I.length-2].x,I[I.length-2].y),E.lineTo(a.x,a.y),E.stroke())},[U,v,o,r]),f=t.useCallback(()=>{if(U&&(b(!1),x.current.length>0&&(g.current.push([...x.current]),x.current=[],P(!1),M.current))){const m=M.current.toDataURL(Y);i?.(m)}},[U,Y,i]),c=t.useCallback(()=>{g.current=[],x.current=[],P(!0),R(),i?.(null)},[R,i]),s=t.useCallback(()=>{if(g.current.length!==0&&(g.current.pop(),P(g.current.length===0),R(),M.current)){const m=g.current.length>0?M.current.toDataURL(Y):null;i?.(m)}},[R,Y,i]);return e.jsxs("div",{ref:C,id:_,className:`nice-signature nice-signature--${k} ${D?"nice-signature--disabled":""} ${z?"nice-signature--readonly":""} ${K??""}`,style:te,...$,children:[j&&e.jsx("label",{className:"nice-signature__label",children:j}),e.jsx("div",{className:"nice-signature__canvas-wrap",style:{width:h,height:N},children:e.jsx("canvas",{ref:M,className:"nice-signature__canvas",onMouseDown:u,onMouseMove:S,onMouseUp:f,onMouseLeave:f,onTouchStart:u,onTouchMove:S,onTouchEnd:f,style:{touchAction:"none",cursor:D||z?"default":"crosshair"},"aria-label":j??w("signature.label","Signature pad"),role:"img"})}),(X||V)&&!z&&!D&&e.jsxs("div",{className:"nice-signature__actions",children:[V&&e.jsx("button",{type:"button",className:"nice-signature__btn",onClick:s,disabled:T,children:w("signature.undo","Undo")}),X&&e.jsx("button",{type:"button",className:"nice-signature__btn",onClick:c,disabled:T,children:w("signature.clear","Clear")})]})]})});pn.displayName="NiceSignaturePad";let vi=0;function ft(){return`blk-${++vi}-${Date.now().toString(36)}`}function zt(n=""){return{id:ft(),type:"paragraph",content:n}}function ki(n,i=""){const o={id:ft(),type:n,content:i};return n==="heading"&&(o.level=2),n==="list"&&(o.listType="unordered"),n==="callout"&&(o.icon="??"),n==="toggle"&&(o.open=!0),o}const wi=[{type:"paragraph",label:"Text",icon:"�",keywords:"paragraph text"},{type:"heading",label:"Heading",icon:"H",keywords:"heading title"},{type:"list",label:"Bulleted list",icon:"�",keywords:"bullet unordered list"},{type:"list",label:"Numbered list",icon:"1.",keywords:"numbered ordered list"},{type:"list",label:"Checklist",icon:"?",keywords:"check todo list"},{type:"quote",label:"Quote",icon:"?",keywords:"quote blockquote"},{type:"callout",label:"Callout",icon:"??",keywords:"callout info alert"},{type:"toggle",label:"Toggle",icon:"?",keywords:"toggle collapse expand"},{type:"code",label:"Code",icon:"</>",keywords:"code snippet"},{type:"image",label:"Image",icon:"??",keywords:"image photo picture"},{type:"video",label:"Video",icon:"??",keywords:"video embed"},{type:"table",label:"Table",icon:"?",keywords:"table grid"},{type:"divider",label:"Divider",icon:"-",keywords:"divider line separator"},{type:"pageBreak",label:"Page Break",icon:"?",keywords:"page break"}];function Ni(n){const i=[n.align?`text-align:${n.align}`:"",n.color?`color:${n.color}`:"",n.bgColor?`background-color:${n.bgColor}`:"",n.indent?`margin-left:${n.indent*24}px`:""].filter(Boolean).join(";"),o=i?` style="${i}"`:"",r=(d,h)=>{let N=h;return n.bold&&(N=`<strong>${N}</strong>`),n.italic&&(N=`<em>${N}</em>`),n.underline&&(N=`<u>${N}</u>`),n.strikethrough&&(N=`<s>${N}</s>`),`<${d}${o}>${N}</${d}>`};switch(n.type){case"heading":return r(`h${n.level??2}`,n.content);case"paragraph":return r("p",n.content||" ");case"list":{const d=n.listType==="ordered"?"ol":"ul",h=n.content.split(`
|
|
413
|
+
`).map((N,k)=>n.listType==="checklist"?`<li><input type="checkbox" ${n.checked?.[k]??!1?"checked":""} disabled />${N}</li>`:`<li>${N}</li>`).join("");return`<${d}${o}>${h}</${d}>`}case"image":return`<figure${o}><img src="${n.src??""}" alt="${n.alt??""}" /></figure>`;case"video":return`<figure${o}><video src="${n.src??""}" controls></video></figure>`;case"divider":return"<hr />";case"pageBreak":return'<div style="page-break-after:always"></div>';case"code":return`<pre><code class="language-${n.language??""}">${n.content}</code></pre>`;case"quote":return r("blockquote",n.content);case"callout":return`<div class="nice-doc-callout"${o}><span>${n.icon??"??"}</span><div>${n.content}</div></div>`;case"toggle":return`<details${o}><summary>${n.content.split(`
|
|
414
|
+
`)[0]}</summary>${n.content.split(`
|
|
415
|
+
`).slice(1).join("<br>")}</details>`;case"table":return`<table${o}>${n.content}</table>`;case"embed":return`<iframe src="${n.src??""}" style="width:100%;border:none;min-height:300px"></iframe>`;default:return r("p",n.content)}}function Ci(n){let i=0,o=0;for(const r of n){const d=r.content??"";i+=d.length;const h=d.trim().split(/\s+/).filter(Boolean);o+=h.length}return{words:o,chars:i,readingTime:Math.max(1,Math.ceil(o/200))}}const hn=t.forwardRef(({blocks:n,onChange:i,readOnly:o=!1,showToolbar:r=!0,size:d="md",editorSize:h="standard",placeholder:N,onExport:k,onImageUpload:D,maxUndo:z=50,slashCommands:X=!0,showWordCount:V=!1,showToc:j=!1,showFindReplace:Y=!0,className:K,style:te,id:B,...$},C)=>{const _=ne.cs(B),{t:w}=ne.Wo(),[M,U]=t.useState(()=>n??[zt()]),b=n??M,[g,x]=t.useState(0),T=t.useRef(new Map),P=t.useRef(null),[R,v]=t.useState(!1),[u,S]=t.useState(""),[f,c]=t.useState(""),[s,m]=t.useState([]),[a,p]=t.useState(0),[E,I]=t.useState(!1),ee=t.useRef([]),L=t.useRef([]),oe=t.useCallback(l=>{ee.current.push(l.map(H=>({...H,checked:H.checked?[...H.checked]:void 0}))),ee.current.length>z&&ee.current.shift(),L.current=[]},[z]),q=t.useCallback(()=>{if(ee.current.length===0)return;const l=ee.current.pop();L.current.push(b.map(H=>({...H}))),n||U(l),i?.(l)},[b,n,i]),J=t.useCallback(()=>{if(L.current.length===0)return;const l=L.current.pop();ee.current.push(b.map(H=>({...H}))),n||U(l),i?.(l)},[b,n,i]),[ie,se]=t.useState(!1),[me,pe]=t.useState(""),[xe,_e]=t.useState(0),le=t.useMemo(()=>{if(!ie||!X)return[];const l=me.toLowerCase();return wi.filter(H=>H.label.toLowerCase().includes(l)||H.keywords.includes(l))},[ie,me,X]),[de,he]=t.useState(null),[re,A]=t.useState(null),y=t.useCallback(l=>{oe(b);const H=l(b);n||U(H),i?.(H)},[b,n,i,oe]),Z=t.useCallback((l,H)=>{y(O=>O.map((ce,be)=>be===l?{...ce,...H}:ce))},[y]),W=t.useCallback((l,H)=>{const O=H??zt();y(ce=>{const be=[...ce];return be.splice(l+1,0,O),be}),x(l+1)},[y]),F=t.useCallback(l=>{const H={...b[l],id:ft()};W(l,H)},[b,W]),Q=t.useCallback(l=>{b.length<=1||(y(H=>H.filter((O,ce)=>ce!==l)),x(Math.max(0,l-1)))},[b.length,y]),ae=t.useCallback((l,H)=>{const O=l+H;O<0||O>=b.length||(y(ce=>{const be=[...ce];return[be[l],be[O]]=[be[O],be[l]],be}),x(O))},[b.length,y]),ye=t.useCallback((l,H)=>{const O={type:H};H==="heading"&&(O.level=2),H==="list"&&(O.listType="unordered"),H==="callout"&&(O.icon="??"),H==="toggle"&&(O.open=!0),Z(l,O)},[Z]),ge=t.useCallback(l=>{const H=ki(l.type);l.type==="list"&&l.label.includes("Numbered")&&(H.listType="ordered"),l.type==="list"&&l.label.includes("Checklist")&&(H.listType="checklist",H.checked=[]),b[g]?.content===""||b[g]?.content==="/"?y(O=>O.map((ce,be)=>be===g?{...H,id:ce.id}:ce)):W(g,H),se(!1),pe("")},[b,g,y,W]),fe=t.useCallback((l,H)=>{if(o)return;const O=b[H];if(!O?.locked){if((l.ctrlKey||l.metaKey)&&l.key==="z"&&!l.shiftKey){l.preventDefault(),q();return}if((l.ctrlKey||l.metaKey)&&(l.key==="y"||l.key==="z"&&l.shiftKey)){l.preventDefault(),J();return}if((l.ctrlKey||l.metaKey)&&l.key==="d"){l.preventDefault(),F(H);return}if((l.ctrlKey||l.metaKey)&&l.key==="b"){l.preventDefault(),Z(H,{bold:!O?.bold});return}if((l.ctrlKey||l.metaKey)&&l.key==="i"){l.preventDefault(),Z(H,{italic:!O?.italic});return}if((l.ctrlKey||l.metaKey)&&l.key==="u"){l.preventDefault(),Z(H,{underline:!O?.underline});return}if((l.ctrlKey||l.metaKey)&&l.key==="e"){l.preventDefault(),Z(H,{strikethrough:!O?.strikethrough});return}if(l.key==="Tab"&&!l.shiftKey){l.preventDefault(),Z(H,{indent:Math.min((O?.indent??0)+1,4)});return}if(l.key==="Tab"&&l.shiftKey){l.preventDefault(),Z(H,{indent:Math.max((O?.indent??0)-1,0)});return}if((l.ctrlKey||l.metaKey)&&l.key==="f"&&Y){l.preventDefault(),v(ce=>!ce);return}if(ie&&le.length>0){if(l.key==="ArrowDown"){l.preventDefault(),_e(ce=>Math.min(ce+1,le.length-1));return}if(l.key==="ArrowUp"){l.preventDefault(),_e(ce=>Math.max(ce-1,0));return}if(l.key==="Enter"){l.preventDefault(),ge(le[xe]);return}if(l.key==="Escape"){se(!1);return}}l.key==="Enter"&&!l.shiftKey?(l.preventDefault(),W(H)):l.key==="Backspace"&&b[H].content===""&&b.length>1?(l.preventDefault(),Q(H)):l.key==="ArrowUp"&&l.altKey?(l.preventDefault(),ae(H,-1)):l.key==="ArrowDown"&&l.altKey&&(l.preventDefault(),ae(H,1))}},[o,b,W,Q,ae,q,J,F,Z,ie,le,xe,ge,Y]),ke=t.useCallback((l,H)=>{const O=l.target.textContent??"";X&&O.startsWith("/")?(se(!0),pe(O.slice(1)),_e(0)):ie&&se(!1),oe(b);const ce=b.map((be,we)=>we===H?{...be,content:O}:be);n||U(ce),i?.(ce)},[b,n,i,oe,X,ie]),Ie=t.useCallback((l,H)=>{he(H),l.dataTransfer.effectAllowed="move"},[]),Me=t.useCallback((l,H)=>{l.preventDefault(),l.dataTransfer.dropEffect="move",A(H)},[]),Ae=t.useCallback((l,H)=>{if(l.preventDefault(),de===null||de===H){he(null),A(null);return}y(O=>{const ce=[...O],[be]=ce.splice(de,1);return ce.splice(H>de?H-1:H,0,be),ce}),x(H>de?H-1:H),he(null),A(null)},[de,y]);t.useEffect(()=>{if(!R||!u){m([]);return}const l=u.toLowerCase(),H=[];b.forEach((O,ce)=>{const be=(O.content??"").toLowerCase();let we=0;for(;we<be.length;){const Se=be.indexOf(l,we);if(Se===-1)break;H.push({blockIdx:ce,start:Se,end:Se+l.length}),we=Se+1}}),m(H),p(0)},[u,R,b]);const Qe=t.useCallback(()=>{if(s.length===0)return;const l=(a+1)%s.length;p(l),x(s[l].blockIdx)},[s,a]),Ze=t.useCallback(()=>{if(s.length===0)return;const l=(a-1+s.length)%s.length;p(l),x(s[l].blockIdx)},[s,a]),Je=t.useCallback(()=>{if(s.length===0||!u)return;const l=s[a],H=b[l.blockIdx],O=H.content.slice(0,l.start),ce=H.content.slice(l.end);Z(l.blockIdx,{content:O+f+ce})},[s,a,u,f,b,Z]),et=t.useCallback(()=>{if(!u)return;const l=u;y(H=>H.map(O=>({...O,content:O.content.split(l).join(f)})))},[u,f,y]),De=t.useMemo(()=>j?b.map((l,H)=>l.type==="heading"?{idx:H,level:l.level??2,text:l.content}:null).filter(Boolean):[],[b,j]),tt=t.useCallback(async l=>{const H=l.target.files?.[0];if(H){if(D){const O=await D(H);Z(g,{src:O})}l.target.value=""}},[D,g,Z]);t.useEffect(()=>{const l=b[g];if(l){const H=T.current.get(l.id);H&&H.focus()}},[g,b]);const nt=t.useCallback(()=>{const l=b.map(Ni).join(`
|
|
416
|
+
`);k?.(l)},[b,k]),Ee=t.useMemo(()=>V?Ci(b):null,[b,V]),[ve,Ce]=t.useState(null),G=t.useCallback((l,H)=>{o||(l.preventDefault(),Ce({x:l.clientX,y:l.clientY,idx:H}))},[o]);return t.useEffect(()=>{if(!ve)return;const l=()=>Ce(null);return window.addEventListener("click",l),()=>window.removeEventListener("click",l)},[ve]),e.jsxs("div",{ref:C,id:_,className:`nice-doc-editor nice-doc-editor--${d} nice-editor--${h} ${o?"nice-doc-editor--readonly":""} ${K??""}`,style:te,role:"application","aria-label":w("docEditor.label","Document Editor"),...$,children:[r&&!o&&e.jsxs("div",{className:"nice-doc-editor__toolbar",role:"toolbar",style:{display:"flex",flexWrap:"wrap",gap:4,alignItems:"center",padding:"4px 8px"},children:[e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:q,title:w("docEditor.undo","Undo (Ctrl+Z)"),children:"?"}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:J,title:w("docEditor.redo","Redo (Ctrl+Y)"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ue.NiceSelect,{size:"sm",value:b[g]?.type??"paragraph",onChange:l=>ye(g,l),label:"",options:[{value:"paragraph",label:w("docEditor.paragraph","Paragraph")},{value:"heading",label:w("docEditor.heading","Heading")},{value:"list",label:w("docEditor.list","List")},{value:"code",label:w("docEditor.code","Code")},{value:"quote",label:w("docEditor.quote","Quote")},{value:"callout",label:w("docEditor.callout","Callout")},{value:"toggle",label:w("docEditor.toggle","Toggle")},{value:"divider",label:w("docEditor.divider","Divider")},{value:"image",label:w("docEditor.image","Image")},{value:"video",label:w("docEditor.video","Video")},{value:"pageBreak",label:w("docEditor.pageBreak","Page Break")}],style:{minWidth:100}}),b[g]?.type==="heading"&&e.jsx(ue.NiceSelect,{size:"sm",value:String(b[g]?.level??2),onChange:l=>Z(g,{level:Number(l)}),label:"",options:[{value:"1",label:"H1"},{value:"2",label:"H2"},{value:"3",label:"H3"},{value:"4",label:"H4"},{value:"5",label:"H5"},{value:"6",label:"H6"}],style:{minWidth:55}}),b[g]?.type==="list"&&e.jsx(ue.NiceSelect,{size:"sm",value:b[g]?.listType??"unordered",onChange:l=>Z(g,{listType:l}),label:"",options:[{value:"unordered",label:"� Bullets"},{value:"ordered",label:"1. Numbers"},{value:"checklist",label:"? Checklist"}],style:{minWidth:90}}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ue.NiceButton,{size:"sm",variant:b[g]?.bold?"primary":"ghost",onClick:()=>Z(g,{bold:!b[g]?.bold}),title:w("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(ue.NiceButton,{size:"sm",variant:b[g]?.italic?"primary":"ghost",onClick:()=>Z(g,{italic:!b[g]?.italic}),title:w("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(ue.NiceButton,{size:"sm",variant:b[g]?.underline?"primary":"ghost",onClick:()=>Z(g,{underline:!b[g]?.underline}),title:w("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(ue.NiceButton,{size:"sm",variant:b[g]?.strikethrough?"primary":"ghost",onClick:()=>Z(g,{strikethrough:!b[g]?.strikethrough}),title:w("docEditor.strikethrough","Strikethrough (Ctrl+E)"),children:e.jsx("s",{children:"S"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ue.NiceButton,{size:"sm",variant:b[g]?.align==="left"?"primary":"ghost",onClick:()=>Z(g,{align:"left"}),title:w("docEditor.alignLeft","Left"),children:"?"}),e.jsx(ue.NiceButton,{size:"sm",variant:b[g]?.align==="center"?"primary":"ghost",onClick:()=>Z(g,{align:"center"}),title:w("docEditor.alignCenter","Center"),children:"?"}),e.jsx(ue.NiceButton,{size:"sm",variant:b[g]?.align==="right"?"primary":"ghost",onClick:()=>Z(g,{align:"right"}),title:w("docEditor.alignRight","Right"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:()=>Z(g,{indent:Math.min((b[g]?.indent??0)+1,4)}),title:w("docEditor.indent","Indent (Tab)"),children:"??"}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:()=>Z(g,{indent:Math.max((b[g]?.indent??0)-1,0)}),title:w("docEditor.outdent","Outdent (Shift+Tab)"),children:"??"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ue.NiceColorPicker,{size:"sm",label:"",value:b[g]?.color??"var(--text-primary, #000000)",onChange:l=>Z(g,{color:l}),title:"Text color"}),e.jsx(ue.NiceColorPicker,{size:"sm",label:"",value:b[g]?.bgColor??"var(--bg-primary, #ffffff)",onChange:l=>Z(g,{bgColor:l}),title:"Block background"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ue.NiceButton,{size:"sm",variant:b[g]?.locked?"primary":"ghost",onClick:()=>Z(g,{locked:!b[g]?.locked}),title:w("docEditor.lock","Lock/Unlock block"),children:"??"}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:()=>F(g),title:w("docEditor.duplicate","Duplicate (Ctrl+D)"),children:"?"}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:()=>Q(g),title:w("docEditor.delete","Delete block"),children:"??"}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:()=>W(g),title:w("docEditor.addBlock","Add block"),children:"+"}),Y&&e.jsx(ue.NiceButton,{size:"sm",variant:R?"primary":"ghost",onClick:()=>v(l=>!l),title:w("docEditor.find","Find & Replace (Ctrl+F)"),children:"??"}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:()=>I(l=>!l),title:w("docEditor.shortcuts","Keyboard shortcuts"),children:"?"}),k&&e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:nt,children:w("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:P,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:tt}),R&&e.jsxs("div",{className:"nice-doc-editor__find-bar",style:{display:"flex",gap:4,alignItems:"center",padding:"4px 8px",background:"var(--nice-doc-find-bg, #f8f9fa)",borderBottom:"1px solid var(--border-color, #ddd)"},children:[e.jsx(ue.NiceTextInput,{size:"sm",placeholder:w("docEditor.findPlaceholder","Find..."),value:u,onChange:S,style:{flex:1,maxWidth:200}}),e.jsx(ue.NiceTextInput,{size:"sm",placeholder:w("docEditor.replacePlaceholder","Replace..."),value:f,onChange:c,style:{flex:1,maxWidth:200}}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:Ze,title:w("docEditor.findPrev","Previous"),children:"?"}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:Qe,title:w("docEditor.findNext","Next"),children:"?"}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:Je,title:w("docEditor.replaceOne","Replace"),disabled:o,children:w("docEditor.replace","Replace")}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:et,title:w("docEditor.replaceAll","Replace all"),disabled:o,children:w("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--text-muted, #666)"},children:s.length>0?`${a+1}/${s.length}`:"0/0"}),e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:()=>v(!1),children:"?"})]}),E&&e.jsx("div",{className:"nice-doc-editor__shortcuts-overlay",style:{position:"fixed",inset:0,background:"rgba(0,0,0,.4)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>I(!1),children:e.jsxs("div",{style:{background:"var(--bg-primary, #fff)",borderRadius:8,padding:24,maxWidth:420,width:"90%",boxShadow:"0 8px 32px rgba(0,0,0,.2)"},onClick:l=>l.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px"},children:w("docEditor.shortcutsTitle","Keyboard Shortcuts")}),e.jsx("table",{style:{width:"100%",fontSize:"0.875em",borderCollapse:"collapse"},children:e.jsx("tbody",{children:[["Ctrl+B",w("docEditor.bold","Bold")],["Ctrl+I",w("docEditor.italic","Italic")],["Ctrl+U",w("docEditor.underline","Underline")],["Ctrl+E",w("docEditor.strikethrough","Strikethrough")],["Ctrl+D",w("docEditor.duplicate","Duplicate block")],["Ctrl+Z",w("docEditor.undo","Undo")],["Ctrl+Y",w("docEditor.redo","Redo")],["Ctrl+F",w("docEditor.find","Find & Replace")],["Enter",w("docEditor.newBlock","New block")],["Backspace",w("docEditor.deleteEmpty","Delete empty block")],["Alt+?",w("docEditor.moveUp","Move block up")],["Alt+?",w("docEditor.moveDown","Move block down")],["Tab",w("docEditor.indent","Indent")],["Shift+Tab",w("docEditor.outdent","Outdent")],["/",w("docEditor.slashCmd","Slash commands")]].map(([l,H])=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--border-color, #eee)"},children:[e.jsx("td",{style:{padding:"4px 8px",fontFamily:"monospace",fontWeight:600},children:l}),e.jsx("td",{style:{padding:"4px 8px"},children:H})]},l))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:()=>I(!1),children:w("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[j&&De.length>0&&e.jsxs("nav",{className:"nice-doc-editor__toc",style:{width:200,minWidth:160,borderRight:"1px solid var(--border-color, #eee)",padding:"8px 4px",fontSize:"0.8em",overflowY:"auto",maxHeight:500},children:[e.jsx("div",{style:{fontWeight:600,padding:"4px 8px",fontSize:"0.75em",textTransform:"uppercase",color:"var(--text-muted, #999)"},children:w("docEditor.toc","Contents")}),De.map(l=>e.jsx("div",{style:{padding:"3px 8px",paddingLeft:8+(l.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:l.idx===g?"#e8f0fe":void 0},onClick:()=>x(l.idx),title:l.text,children:l.text||w("docEditor.untitled","Untitled")},l.idx))]}),e.jsx("div",{className:"nice-doc-editor__body",style:{flex:1},children:b.map((l,H)=>e.jsxs("div",{className:`nice-doc-editor__block nice-doc-editor__block--${l.type} ${H===g?"nice-doc-editor__block--focused":""} ${re===H?"nice-doc-editor__block--drop-target":""} ${l.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>x(H),onContextMenu:O=>G(O,H),draggable:!o&&!l.locked,onDragStart:O=>Ie(O,H),onDragOver:O=>Me(O,H),onDrop:O=>Ae(O,H),onDragEnd:()=>{he(null),A(null)},style:{opacity:de===H?.4:1,marginLeft:(l.indent??0)*24},children:[!o&&!l.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:w("docEditor.drag","Drag to reorder"),children:"?"}),l.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:"??"}),l.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):l.type==="pageBreak"?e.jsxs("div",{className:"nice-doc-editor__page-break",style:{borderTop:"2px dashed #ccc",textAlign:"center",padding:4,fontSize:"0.75em",color:"var(--text-muted, #999)"},children:["� ",w("docEditor.pageBreak","Page Break")," �"]}):l.type==="image"||l.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:l.src?l.type==="image"?e.jsx("img",{src:l.src,alt:l.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:l.src,controls:!0,className:"nice-doc-editor__video",style:{maxWidth:"100%"}}):!o&&e.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[e.jsx(ue.NiceTextInput,{size:"sm",placeholder:w("docEditor.mediaUrl",l.type==="image"?"Image URL":"Video URL"),value:l.src??"",onChange:O=>Z(H,{src:O})}),D&&e.jsx(ue.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{x(H),P.current?.click()},children:"??"})]})}):l.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:l.bgColor??"#f0f7ff",borderRadius:4,color:l.color},children:[e.jsx("span",{style:{fontSize:"1.2em"},children:l.icon??"??"}),e.jsx("div",{ref:O=>{O&&T.current.set(l.id,O)},className:"nice-doc-editor__content",contentEditable:!o&&!l.locked,suppressContentEditableWarning:!0,onInput:O=>ke(O,H),onFocus:()=>x(H),onKeyDown:O=>fe(O,H),"data-placeholder":w("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true",style:{flex:1,outline:"none"},children:l.content})]}):l.type==="toggle"?e.jsxs("details",{open:l.open,className:"nice-doc-editor__toggle",onToggle:O=>Z(H,{open:O.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:l.content.split(`
|
|
417
|
+
`)[0]||w("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:O=>{O&&T.current.set(l.id,O)},className:"nice-doc-editor__content",contentEditable:!o&&!l.locked,suppressContentEditableWarning:!0,onInput:O=>ke(O,H),onFocus:()=>x(H),onKeyDown:O=>fe(O,H),role:"textbox","aria-multiline":"true",style:{padding:"4px 0"},children:l.content.split(`
|
|
418
|
+
`).slice(1).join(`
|
|
419
|
+
`)})]}):l.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!o&&e.jsx(ue.NiceTextInput,{size:"sm",value:l.language??"",onChange:O=>Z(H,{language:O}),placeholder:"Language",style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:O=>{O&&T.current.set(l.id,O)},className:"nice-doc-editor__content",contentEditable:!o&&!l.locked,suppressContentEditableWarning:!0,onInput:O=>ke(O,H),onFocus:()=>x(H),onKeyDown:O=>fe(O,H),role:"textbox","aria-multiline":"true",style:{fontFamily:"monospace",background:"var(--bg-elevated, #1e1e1e)",color:"var(--text-secondary, #d4d4d4)",padding:12,borderRadius:4,overflow:"auto"},children:l.content})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:O=>{O&&T.current.set(l.id,O)},className:"nice-doc-editor__content",contentEditable:!o&&!l.locked,suppressContentEditableWarning:!0,style:{textAlign:l.align,fontWeight:l.bold?"bold":void 0,fontStyle:l.italic?"italic":void 0,textDecoration:[l.underline?"underline":"",l.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:l.color,backgroundColor:l.bgColor},onInput:O=>ke(O,H),onFocus:()=>x(H),onKeyDown:O=>fe(O,H),"data-placeholder":!l.content&&N?N:void 0,role:"textbox","aria-multiline":"true",children:l.content}),ie&&H===g&&le.length>0&&e.jsx("ul",{className:"nice-doc-editor__slash-menu",style:{position:"absolute",left:0,top:"100%",zIndex:100,background:"var(--bg-primary, #fff)",border:"1px solid var(--border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px rgba(0,0,0,.12)",listStyle:"none",margin:0,padding:4,minWidth:180,maxHeight:240,overflow:"auto"},children:le.map((O,ce)=>e.jsxs("li",{className:ce===xe?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:ce===xe?"#e8f0fe":void 0},onMouseDown:be=>{be.preventDefault(),ge(O)},onMouseEnter:()=>_e(ce),children:[e.jsx("span",{style:{width:24,textAlign:"center"},children:O.icon}),e.jsx("span",{children:O.label})]},`${O.type}-${O.label}`))})]})]},l.id))})]}),ve&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:ve.x,top:ve.y,zIndex:1e3,background:"var(--bg-primary, #fff)",border:"1px solid var(--border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px rgba(0,0,0,.12)",padding:4,minWidth:160},children:[e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{F(ve.idx),Ce(null)},children:"? Duplicate"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{W(ve.idx),Ce(null)},children:"+ Insert below"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{ae(ve.idx,-1),Ce(null)},children:"? Move up"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{ae(ve.idx,1),Ce(null)},children:"? Move down"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{Z(ve.idx,{locked:!b[ve.idx]?.locked}),Ce(null)},children:b[ve.idx]?.locked?"?? Unlock":"?? Lock"}),e.jsx("hr",{style:{margin:"2px 0",border:"none",borderTop:"1px solid var(--border-color, #eee)"}}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer",color:"#d32f2f"},onClick:()=>{Q(ve.idx),Ce(null)},children:"?? Delete"})]}),V&&Ee&&e.jsxs("div",{className:"nice-doc-editor__footer",style:{padding:"4px 12px",fontSize:"0.75em",color:"var(--text-muted, #666)",borderTop:"1px solid var(--border-color, #eee)",display:"flex",gap:16},children:[e.jsxs("span",{children:[Ee.words," ",w("docEditor.words","words")]}),e.jsxs("span",{children:[Ee.chars," ",w("docEditor.chars","characters")]}),e.jsxs("span",{children:[b.length," ",w("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",Ee.readingTime," ",w("docEditor.readingTime","min read")]})]})]})});hn.displayName="NiceDocumentEditor";const Si=["street","streetNumber","apartment","city","postalCode","state","country"],Ye={street:"Street",streetNumber:"Number",apartment:"Apt/Suite",city:"City",postalCode:"Postal Code",state:"State/Province",country:"Country"},gn=t.forwardRef(({label:n,helperText:i,error:o,required:r,disabled:d,readOnly:h,size:N="md",name:k,id:D,className:z,style:X,accessMode:V,value:j={},onChange:Y,fields:K=Si,placeholders:te={},countries:B,layout:$="vertical",countryFirst:C=!1,validatePostalCode:_},w)=>{const M=ne.Ns(V,D);if(M==="hidden")return null;M==="disabled"&&(d=!0),M==="readOnly"&&(h=!0);const{t:U}=ne.Wo(),b=ne.cs(D),g=t.useCallback((R,v)=>{Y?.({...j,[R]:v})},[j,Y]),x=t.useMemo(()=>{if(_&&j.postalCode)return _(j.postalCode,j.country)},[_,j.postalCode,j.country]),T=t.useMemo(()=>C&&K.includes("country")?["country",...K.filter(R=>R!=="country")]:K,[K,C]),P=`nice-address nice-address--${$} nice-size-${N}`;return e.jsxs("div",{ref:w,id:b,className:`${P}${z?` ${z}`:""}${o?" nice-error":""}${d?" nice-disabled":""}`,style:X,role:"group","aria-label":n??U("address","Address"),children:[n&&e.jsxs("label",{className:"nice-address__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-address__fields",children:T.map(R=>R==="country"&&B?e.jsxs("div",{className:`nice-address__field nice-address__field--${R}`,children:[e.jsx("label",{className:"nice-address__field-label",children:U(R,Ye[R])}),e.jsxs("select",{className:"nice-input nice-select",value:j.country??"",onChange:v=>g("country",v.target.value),disabled:d,"aria-label":U(R,Ye[R]),children:[e.jsx("option",{value:"",children:te.country??U("selectCountry","— Select country —")}),B.map(v=>e.jsx("option",{value:v.code,children:v.name},v.code))]})]},R):e.jsxs("div",{className:`nice-address__field nice-address__field--${R}`,children:[e.jsx("label",{className:"nice-address__field-label",children:U(R,Ye[R])}),e.jsx("input",{className:`nice-input${R==="postalCode"&&x?" nice-input--error":""}`,type:"text",name:k?`${k}.${R}`:R,value:j[R]??"",onChange:v=>g(R,v.target.value),placeholder:te[R]??"",disabled:d,readOnly:h,"aria-label":U(R,Ye[R])}),R==="postalCode"&&x&&e.jsx("span",{className:"nice-error-text",children:x})]},R))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});gn.displayName="NiceAddressInput";const Mi=[{code:"PLN",symbol:"zł",name:"Polish Zloty"},{code:"EUR",symbol:"€",name:"Euro"},{code:"USD",symbol:"$",name:"US Dollar"},{code:"GBP",symbol:"£",name:"British Pound"},{code:"CZK",symbol:"Kč",name:"Czech Koruna"},{code:"CHF",symbol:"Fr",name:"Swiss Franc"}],fn=t.forwardRef(({label:n,helperText:i,error:o,required:r,disabled:d,readOnly:h,size:N="md",name:k,id:D,className:z,style:X,accessMode:V,value:j,onChange:Y,onBlur:K,currency:te="PLN",onCurrencyChange:B,currencies:$=Mi,useMinorUnit:C=!1,min:_,max:w,locale:M,placeholder:U,showCurrencySelector:b},g)=>{const x=ne.Ns(V,D);if(x==="hidden")return null;x==="disabled"&&(d=!0),x==="readOnly"&&(h=!0);const{t:T}=ne.Wo(),P=ne.cs(D),R=t.useMemo(()=>$.find(s=>s.code===te)??$[0],[te,$]),v=R?.decimals??2,u=t.useMemo(()=>j==null?"":(C?j/Math.pow(10,v):j).toFixed(v),[j,C,v]),S=t.useCallback(s=>{const m=s.replace(/[^\d.,\-]/g,"").replace(",",".");if(m===""||m==="-"){Y?.(null);return}const a=parseFloat(m);if(isNaN(a))return;const p=C?Math.round(a*Math.pow(10,v)):a;_!=null&&p<_||w!=null&&p>w||Y?.(p)},[Y,C,v,_,w]),f=b??$.length>1,c=t.useMemo(()=>{if(j==null)return"";const s=C?j/Math.pow(10,v):j;try{return new Intl.NumberFormat(M,{style:"currency",currency:R?.code??"USD",minimumFractionDigits:v}).format(s)}catch{return`${s.toFixed(v)} ${R?.code}`}},[j,C,v,M,R]);return e.jsxs("div",{ref:g,id:P,className:`nice-currency nice-size-${N}${z?` ${z}`:""}${o?" nice-error":""}${d?" nice-disabled":""}`,style:X,children:[n&&e.jsxs("label",{className:"nice-currency__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-currency__row",children:[f&&e.jsx("select",{className:"nice-currency__select nice-select",value:te,onChange:s=>B?.(s.target.value),disabled:d,"aria-label":T("currency","Currency"),children:$.map(s=>e.jsxs("option",{value:s.code,children:[s.symbol," ",s.code]},s.code))}),!f&&e.jsx("span",{className:"nice-currency__symbol",children:R?.symbol}),e.jsx("input",{className:"nice-input nice-currency__amount",type:"text",inputMode:"decimal",name:k,value:u,onChange:s=>S(s.target.value),onBlur:K,placeholder:U??`0.${"0".repeat(v)}`,disabled:d,readOnly:h,"aria-label":T("amount","Amount")})]}),c&&j!=null&&e.jsx("span",{className:"nice-currency__formatted",children:c}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});fn.displayName="NiceCurrencyInput";let $i=1;function Ei(n){return{id:`new-${$i++}`,description:"",quantity:1,unitPrice:0,vatRate:n,discount:0,unit:"szt."}}function yn(n){const o=n.quantity*n.unitPrice*(1-(n.discount??0)/100),r=Math.round(o*100)/100,d=Math.round(r*(n.vatRate??0)/100*100)/100;return{...n,netAmount:r,grossAmount:r+d}}function Ti(n){const i=n.map(yn),o=i.reduce((k,D)=>k+(D.netAmount??0),0),r=i.reduce((k,D)=>k+(D.grossAmount??0),0),d=r-o,h=new Map;for(const k of i){const D=k.vatRate??0,z=h.get(D)??{base:0,amount:0};z.base+=k.netAmount??0,z.amount+=(k.grossAmount??0)-(k.netAmount??0),h.set(D,z)}const N=Array.from(h.entries()).map(([k,D])=>({rate:k,base:Math.round(D.base*100)/100,amount:Math.round(D.amount*100)/100}));return{totalNet:Math.round(o*100)/100,totalVat:Math.round(d*100)/100,totalGross:Math.round(r*100)/100,vatBreakdown:N}}const bn=t.forwardRef(({label:n,helperText:i,error:o,required:r,disabled:d,readOnly:h,size:N="md",name:k,id:D,className:z,style:X,accessMode:V,value:j=[],onChange:Y,onTotalsChange:K,currencySymbol:te="zł",defaultVatRate:B=23,vatRates:$=[0,5,8,23],units:C=["szt.","h","kg","m","usł."],showDiscount:_=!0,showUnit:w=!0,showTotals:M=!0,editable:U=!0,maxLines:b},g)=>{const x=ne.Ns(V,D);if(x==="hidden")return null;x==="disabled"&&(d=!0),x==="readOnly"&&(h=!0);const{t:T}=ne.Wo(),P=ne.cs(D),R=t.useMemo(()=>j.map(yn),[j]),v=t.useMemo(()=>Ti(j),[j]);t.useEffect(()=>{K?.(v)},[v,K]);const u=t.useCallback((s,m,a)=>{const p=[...j];p[s]={...p[s],[m]:a},Y?.(p)},[j,Y]),S=t.useCallback(()=>{b&&j.length>=b||Y?.([...j,Ei(B)])},[j,Y,B,b]),f=t.useCallback(s=>{Y?.(j.filter((m,a)=>a!==s))},[j,Y]),c=s=>`${s.toFixed(2)} ${te}`;return e.jsxs("div",{ref:g,id:P,className:`nice-invoice-lines nice-size-${N}${z?` ${z}`:""}${o?" nice-error":""}${d?" nice-disabled":""}`,style:X,children:[n&&e.jsxs("label",{className:"nice-invoice-lines__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("table",{className:"nice-invoice-lines__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"nice-il__th-num",children:"#"}),e.jsx("th",{className:"nice-il__th-desc",children:T("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:T("qty","Qty")}),w&&e.jsx("th",{className:"nice-il__th-unit",children:T("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:T("unitPrice","Unit Price")}),_&&e.jsx("th",{className:"nice-il__th-disc",children:T("discount","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:T("vat","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:T("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:T("gross","Gross")}),U&&!h&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:R.map((s,m)=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-il__cell-num",children:m+1}),e.jsx("td",{className:"nice-il__cell-desc",children:e.jsx("input",{className:"nice-input",type:"text",value:s.description,onChange:a=>u(m,"description",a.target.value),disabled:d,readOnly:h,placeholder:T("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:s.quantity,onChange:a=>u(m,"quantity",parseFloat(a.target.value)||0),disabled:d,readOnly:h,min:0,step:"any"})}),w&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:s.unit??"",onChange:a=>u(m,"unit",a.target.value),disabled:d,children:C.map(a=>e.jsx("option",{value:a,children:a},a))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:s.unitPrice,onChange:a=>u(m,"unitPrice",parseFloat(a.target.value)||0),disabled:d,readOnly:h,min:0,step:"0.01"})}),_&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:s.discount??0,onChange:a=>u(m,"discount",parseFloat(a.target.value)||0),disabled:d,readOnly:h,min:0,max:100})}),e.jsx("td",{className:"nice-il__cell-vat",children:e.jsx("select",{className:"nice-select",value:s.vatRate??0,onChange:a=>u(m,"vatRate",parseInt(a.target.value,10)),disabled:d,children:$.map(a=>e.jsxs("option",{value:a,children:[a,"%"]},a))})}),e.jsx("td",{className:"nice-il__cell-net",children:c(s.netAmount??0)}),e.jsx("td",{className:"nice-il__cell-gross",children:c(s.grossAmount??0)}),U&&!h&&e.jsx("td",{className:"nice-il__cell-actions",children:e.jsx("button",{type:"button",className:"nice-btn nice-btn--icon nice-btn--sm",onClick:()=>f(m),disabled:d,title:T("remove","Remove"),children:"✕"})})]},s.id))})]}),U&&!h&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:S,disabled:d||b!=null&&j.length>=b,children:["+ ",T("addLine","Add line")]}),M&&e.jsxs("div",{className:"nice-invoice-lines__totals",children:[e.jsxs("div",{className:"nice-il__total-row",children:[e.jsxs("span",{children:[T("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:c(v.totalNet)})]}),v.vatBreakdown.map(s=>e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--vat",children:[e.jsxs("span",{children:["VAT ",s.rate,"%:"]}),e.jsx("span",{className:"nice-il__total-value",children:c(s.amount)})]},s.rate)),e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--gross",children:[e.jsxs("span",{children:[T("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:c(v.totalGross)})]})]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});bn.displayName="NiceInvoiceLineEditor";const xn=t.forwardRef(({label:n,helperText:i,error:o,required:r,disabled:d,readOnly:h,size:N="md",name:k,id:D,className:z,style:X,accessMode:V,value:j=[],onChange:Y,contacts:K=[],onSearch:te,searchDelay:B=300,multiple:$=!1,placeholder:C,onContactClick:_,maxSelections:w},M)=>{const U=ne.Ns(V,D);if(U==="hidden")return null;U==="disabled"&&(d=!0),U==="readOnly"&&(h=!0);const{t:b}=ne.Wo(),g=ne.cs(D),[x,T]=t.useState(""),[P,R]=t.useState([]),[v,u]=t.useState(!1),[S,f]=t.useState(!1),c=t.useMemo(()=>{const p=[...K,...P],E=new Map(p.map(I=>[I.id,I]));return j.map(I=>E.get(I)).filter(Boolean)},[j,K,P]),s=t.useCallback(p=>{if(T(p),p.length<1){R([]),u(!1);return}if(te){f(!0);const ee=setTimeout(async()=>{const L=await te(p);R(L),u(!0),f(!1)},B);return()=>clearTimeout(ee)}const E=p.toLowerCase(),I=K.filter(ee=>ee.name.toLowerCase().includes(E)||ee.email?.toLowerCase().includes(E)||ee.phone?.includes(p));R(I),u(!0)},[te,K,B]),m=t.useCallback(p=>{if($)if(j.includes(p.id))Y?.(j.filter(E=>E!==p.id));else{if(w&&j.length>=w)return;Y?.([...j,p.id])}else Y?.([p.id]),u(!1),T("")},[j,Y,$,w]),a=t.useCallback(p=>{Y?.(j.filter(E=>E!==p))},[j,Y]);return e.jsxs("div",{ref:M,id:g,className:`nice-contact-picker nice-size-${N}${z?` ${z}`:""}${o?" nice-error":""}${d?" nice-disabled":""}`,style:X,children:[n&&e.jsxs("label",{className:"nice-contact-picker__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),c.length>0&&e.jsx("div",{className:"nice-contact-picker__chips",children:c.map(p=>e.jsxs("span",{className:"nice-contact-picker__chip",onClick:()=>_?.(p),children:[p.avatarUrl&&e.jsx("img",{src:p.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:p.name}),!h&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:E=>{E.stopPropagation(),a(p.id)},disabled:d,children:"×"})]},p.id))}),!h&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{className:"nice-input",type:"text",value:x,onChange:p=>s(p.target.value),onFocus:()=>x.length>0&&u(!0),onBlur:()=>setTimeout(()=>u(!1),200),placeholder:C??b("searchContacts","Search contacts…"),disabled:d,"aria-label":b("searchContacts","Search contacts")}),S&&e.jsx("span",{className:"nice-contact-picker__spinner",children:"⏳"})]}),v&&P.length>0&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",children:P.map(p=>e.jsxs("div",{className:`nice-contact-picker__option${j.includes(p.id)?" nice-contact-picker__option--selected":""}`,role:"option","aria-selected":j.includes(p.id),onClick:()=>m(p),children:[p.avatarUrl&&e.jsx("img",{src:p.avatarUrl,alt:"",className:"nice-contact-picker__option-avatar"}),e.jsxs("div",{className:"nice-contact-picker__option-info",children:[e.jsx("span",{className:"nice-contact-picker__option-name",children:p.name}),p.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:p.subtitle}),p.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:p.email})]}),p.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:p.type==="person"?"👤":"🏢"})]},p.id))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});xn.displayName="NiceContactPicker";const Ri=["highlight","underline","strikethrough","freehand","text","rect","arrow"],Ii={highlight:"🖍️",underline:"⎁",strikethrough:"S̶",freehand:"✏️",text:"T",rect:"▭",arrow:"→",stamp:"🔏"},jn=t.forwardRef(({label:n,helperText:i,error:o,required:r,disabled:d,readOnly:h,size:N="md",id:k,className:D,style:z,accessMode:X,src:V,annotations:j=[],onAnnotationsChange:Y,activeTool:K,onToolChange:te,currentPage:B=1,onPageChange:$,totalPages:C=1,defaultColor:_="#FFFF00",tools:w=Ri,author:M,zoom:U=1,onZoomChange:b,onAnnotationClick:g,onAnnotationDelete:x},T)=>{const P=ne.Ns(X,k);if(P==="hidden")return null;P==="disabled"&&(d=!0),P==="readOnly"&&(h=!0);const{t:R}=ne.Wo(),v=ne.cs(k),u=j.filter(c=>c.page===B),S=t.useCallback(c=>{te?.(K===c?null:c)},[K,te]),f=t.useCallback(c=>{if(h||!K||K==="freehand")return;const s=c.currentTarget.getBoundingClientRect(),m=(c.clientX-s.left)/s.width,a=(c.clientY-s.top)/s.height,p={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:K,page:B,x:m,y:a,color:_,author:M,createdAt:new Date().toISOString(),text:K==="text"?"":void 0};Y?.([...j,p])},[h,K,B,_,M,j,Y]);return e.jsxs("div",{ref:T,id:v,className:`nice-pdf-annotation nice-size-${N}${D?` ${D}`:""}${o?" nice-error":""}${d?" nice-disabled":""}`,style:z,children:[n&&e.jsxs("div",{className:"nice-pdf-annotation__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),!h&&e.jsxs("div",{className:"nice-pdf-annotation__toolbar",children:[w.map(c=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${K===c?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>S(c),disabled:d,title:R(`pdfTool_${c}`,c),children:Ii[c]},c)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:d,onClick:()=>b?.(Math.max(.25,U-.25)),title:R("zoomOut","Zoom out"),children:"−"}),e.jsxs("span",{className:"nice-pdf-annotation__zoom",children:[Math.round(U*100),"%"]}),e.jsx("button",{type:"button",disabled:d,onClick:()=>b?.(Math.min(4,U+.25)),title:R("zoomIn","Zoom in"),children:"+"})]}),e.jsxs("div",{className:"nice-pdf-annotation__viewport",style:{transform:`scale(${U})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:V,className:"nice-pdf-annotation__frame",title:R("pdfViewer","PDF Viewer")}),e.jsx("div",{className:"nice-pdf-annotation__layer",onClick:f,children:u.map(c=>e.jsxs("div",{className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${c.tool}`,style:{left:`${c.x*100}%`,top:`${c.y*100}%`,backgroundColor:c.color},onClick:s=>{s.stopPropagation(),g?.(c)},title:c.text??c.tool,children:[c.text&&e.jsx("span",{children:c.text}),!h&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:s=>{s.stopPropagation(),x?.(c.id)},children:"×"})]},c.id))})]}),e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:d||B<=1,onClick:()=>$?.(B-1),children:"◀"}),e.jsx("span",{children:R("pageOf","{page} / {total}").replace("{page}",String(B)).replace("{total}",String(C))}),e.jsx("button",{type:"button",disabled:d||B>=C,onClick:()=>$?.(B+1),children:"▶"})]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});jn.displayName="NicePDFAnnotationEditor";const _n=t.forwardRef(({label:n,helperText:i,error:o,disabled:r,readOnly:d,size:h="md",id:N,className:k,style:D,accessMode:z,pages:X,selectedPageId:V,content:j="",contentFormat:Y="html",editing:K=!1,onPageSelect:te,onContentChange:B,onSave:$,onCreatePage:C,onDeletePage:_,onEditToggle:w,onVersionHistory:M,sidebarWidth:U=260,sidebarCollapsed:b=!1,onSidebarToggle:g,searchable:x=!0,onSearch:T},P)=>{const R=ne.Ns(z,N);if(R==="hidden")return null;R==="disabled"&&(r=!0),R==="readOnly"&&(d=!0);const{t:v}=ne.Wo(),u=ne.cs(N),[S,f]=t.useState(""),[c,s]=t.useState(""),[m,a]=t.useState(!1),p=t.useMemo(()=>{const L=oe=>{for(const q of oe){if(q.id===V)return q;if(q.children){const J=L(q.children);if(J)return J}}};return L(X)},[X,V]),E=t.useCallback(L=>{f(L),T?.(L)},[T]),I=t.useCallback(()=>{c.trim()&&(C?.(V??null,c.trim()),s(""),a(!1))},[c,V,C]),ee=(L,oe=0)=>e.jsx("ul",{className:"nice-wiki__tree",style:{paddingLeft:oe>0?16:0},children:L.map(q=>e.jsxs("li",{className:"nice-wiki__tree-item",children:[e.jsxs("div",{className:`nice-wiki__tree-node${q.id===V?" nice-wiki__tree-node--active":""}${q.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>te?.(q),role:"treeitem","aria-selected":q.id===V,children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:q.children?.length?"📁":"📄"}),e.jsx("span",{className:"nice-wiki__tree-title",children:q.title}),q.isDraft&&e.jsx("span",{className:"nice-wiki__tree-draft",children:v("draft","Draft")})]}),q.children&&q.children.length>0&&ee(q.children,oe+1)]},q.id))});return e.jsxs("div",{ref:P,id:u,className:`nice-wiki nice-size-${h}${k?` ${k}`:""}${r?" nice-disabled":""}`,style:D,children:[!b&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:U},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("span",{className:"nice-wiki__sidebar-title",children:n??v("wiki","Wiki")}),g&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-toggle",onClick:()=>g(!0),children:"«"})]}),x&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:S,onChange:L=>E(L.target.value),placeholder:v("searchPages","Search pages…"),disabled:r}),e.jsx("div",{className:"nice-wiki__page-tree",role:"tree",children:ee(X)}),C&&!d&&e.jsx("div",{className:"nice-wiki__sidebar-footer",children:m?e.jsxs("div",{className:"nice-wiki__create-form",children:[e.jsx("input",{type:"text",className:"nice-input",value:c,onChange:L=>s(L.target.value),placeholder:v("pageTitle","Page title"),onKeyDown:L=>L.key==="Enter"&&I(),disabled:r}),e.jsx("button",{type:"button",disabled:r||!c.trim(),onClick:I,children:"✓"}),e.jsx("button",{type:"button",onClick:()=>a(!1),children:"✕"})]}):e.jsxs("button",{type:"button",className:"nice-wiki__add-page",onClick:()=>a(!0),disabled:r,children:["+ ",v("newPage","New page")]})})]}),b&&g&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-expand",onClick:()=>g(!1),children:"»"}),e.jsx("main",{className:"nice-wiki__content",children:p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-wiki__content-header",children:[e.jsx("h1",{className:"nice-wiki__page-title",children:p.title}),e.jsxs("div",{className:"nice-wiki__content-actions",children:[w&&!d&&e.jsx("button",{type:"button",disabled:r,onClick:()=>w(!K),children:K?v("preview","Preview"):v("edit","Edit")}),M&&e.jsx("button",{type:"button",disabled:r,onClick:()=>M(p.id),children:v("history","History")}),_&&!d&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:r,onClick:()=>_(p.id),children:v("delete","Delete")})]})]}),p.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[p.updatedBy&&e.jsxs("span",{children:[v("lastEditedBy","Last edited by")," ",p.updatedBy]}),e.jsx("span",{children:new Date(p.updatedAt).toLocaleDateString()})]}),K?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("textarea",{className:"nice-wiki__editor-textarea",value:j,onChange:L=>B?.(L.target.value),disabled:r}),$&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:r,onClick:()=>$(p.id,j),children:v("save","Save")})]}):e.jsx("div",{className:"nice-wiki__viewer",children:Y==="html"?e.jsx("div",{className:"nice-wiki__html",dangerouslySetInnerHTML:{__html:ne.es(j)}}):e.jsx("pre",{className:"nice-wiki__markdown",children:j})})]}):e.jsx("div",{className:"nice-wiki__empty",children:e.jsx("p",{children:v("selectPage","Select a page from the sidebar or create a new one.")})})}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});_n.displayName="NiceWiki";const Ai=[{code:"PL",label:"Polska",prefix:"PL",pattern:/^\d{10}$/,placeholder:"1234567890"},{code:"DE",label:"Deutschland",prefix:"DE",pattern:/^\d{9}$/,placeholder:"123456789"},{code:"GB",label:"United Kingdom",prefix:"GB",pattern:/^\d{9}(\d{3})?$/,placeholder:"123456789"},{code:"FR",label:"France",prefix:"FR",pattern:/^[A-Z0-9]{2}\d{9}$/,placeholder:"XX123456789"},{code:"CZ",label:"Česko",prefix:"CZ",pattern:/^\d{8,10}$/,placeholder:"12345678"},{code:"SK",label:"Slovensko",prefix:"SK",pattern:/^\d{10}$/,placeholder:"1234567890"},{code:"IT",label:"Italia",prefix:"IT",pattern:/^\d{11}$/,placeholder:"12345678901"},{code:"ES",label:"España",prefix:"ES",pattern:/^[A-Z0-9]\d{7}[A-Z0-9]$/,placeholder:"X1234567X"}],vn=t.forwardRef(({label:n,helperText:i,error:o,required:r,disabled:d,readOnly:h,size:N="md",name:k,id:D,className:z,style:X,accessMode:V,value:j="",onChange:Y,countryCode:K="PL",onCountryChange:te,countries:B=Ai,showCountrySelector:$=!0,autoPrefixVat:C=!0,validationResult:_,onValidateRequest:w,placeholder:M},U)=>{const b=ne.Ns(V,D);if(b==="hidden")return null;b==="disabled"&&(d=!0),b==="readOnly"&&(h=!0);const{t:g}=ne.Wo(),x=ne.cs(D),T=t.useMemo(()=>B.find(S=>S.code===K)??B[0],[B,K]),P=t.useCallback(S=>{let f=S.toUpperCase();return T&&f.startsWith(T.prefix)&&(f=f.slice(T.prefix.length)),T?T.pattern.test(f):f.length>0},[T]),R=t.useCallback(S=>{const f=S.target.value.replace(/\s/g,"");Y?.(f,P(f))},[Y,P]),v=C&&j&&T&&!j.toUpperCase().startsWith(T.prefix)?`${T.prefix}${j}`:j,u=P(j);return e.jsxs("div",{ref:U,id:x,className:`nice-vat-input nice-size-${N}${z?` ${z}`:""}${o||!u&&j.length>0?" nice-error":""}${d?" nice-disabled":""}`,style:X,children:[n&&e.jsxs("label",{className:"nice-vat-input__label",htmlFor:`${x}-input`,children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-vat-input__row",children:[$&&e.jsx("select",{className:"nice-vat-input__country",value:K,onChange:S=>te?.(S.target.value),disabled:d||h,children:B.map(S=>e.jsx("option",{value:S.code,children:S.prefix},S.code))}),e.jsx("input",{id:`${x}-input`,className:"nice-input nice-vat-input__field",type:"text",name:k,value:j,onChange:R,readOnly:h,disabled:d,placeholder:M??T?.placeholder,required:r,"aria-invalid":!u&&j.length>0}),w&&j.length>0&&e.jsx("button",{type:"button",className:"nice-vat-input__verify",disabled:d||!u,onClick:()=>w(C?v:j,K),title:g("verifyVat","Verify VAT number"),children:"🔍"})]}),_&&e.jsxs("div",{className:`nice-vat-input__result nice-vat-input__result--${_.valid?"valid":"invalid"}`,children:[_.valid?"✅":"❌"," ",_.companyName??_.error??(_.valid?g("vatValid","VAT number valid"):g("vatInvalid","VAT number invalid"))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});vn.displayName="NiceVatInput";const Di=[{id:"pl-23",label:"23%",rate:.23,countryCode:"PL",category:"standard",isDefault:!0},{id:"pl-8",label:"8%",rate:.08,countryCode:"PL",category:"reduced"},{id:"pl-5",label:"5%",rate:.05,countryCode:"PL",category:"reduced"},{id:"pl-0",label:"0%",rate:0,countryCode:"PL",category:"zero"},{id:"pl-zw",label:"zw.",rate:0,countryCode:"PL",category:"exempt"},{id:"pl-np",label:"n.p.",rate:0,countryCode:"PL",category:"exempt"}],kn=t.forwardRef(({label:n,helperText:i,error:o,required:r,disabled:d,readOnly:h,size:N="md",name:k,id:D,className:z,style:X,accessMode:V,value:j,onChange:Y,rates:K,countryCode:te,placeholder:B,showPercentage:$=!0},C)=>{const _=ne.Ns(V,D);if(_==="hidden")return null;_==="disabled"&&(d=!0),_==="readOnly"&&(h=!0);const{t:w}=ne.Wo(),M=ne.cs(D),U=t.useMemo(()=>{const g=K??Di;return te?g.filter(x=>!x.countryCode||x.countryCode===te):g},[K,te]),b=t.useCallback(g=>{const x=g.target.value,T=U.find(P=>P.id===x);T&&Y?.(x,T)},[Y,U]);return e.jsxs("div",{ref:C,id:M,className:`nice-tax-rate nice-size-${N}${z?` ${z}`:""}${o?" nice-error":""}${d?" nice-disabled":""}`,style:X,children:[n&&e.jsxs("label",{className:"nice-tax-rate__label",htmlFor:`${M}-select`,children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("select",{id:`${M}-select`,className:"nice-select nice-tax-rate__select",name:k,value:j??"",onChange:b,disabled:d||h,required:r,children:[e.jsx("option",{value:"",disabled:!0,children:B??w("selectRate","Select rate…")}),U.map(g=>e.jsxs("option",{value:g.id,children:[g.label,$&&g.category!=="exempt"?` (${(g.rate*100).toFixed(0)}%)`:""]},g.id))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});kn.displayName="NiceTaxRatePicker";const Li={asset:"var(--nice-color-info, #5bc0de)",liability:"var(--nice-color-warning, #f0ad4e)",equity:"var(--nice-color-success, #5cb85c)",revenue:"var(--nice-color-primary, #337ab7)",expense:"var(--nice-color-error, #d9534f)"},wn=t.forwardRef(({label:n,helperText:i,error:o,required:r,disabled:d,readOnly:h,size:N="md",name:k,id:D,className:z,style:X,accessMode:V,value:j,onChange:Y,accounts:K,treeView:te=!1,placeholder:B,searchable:$=!0,showType:C=!0,onSearch:_},w)=>{const M=ne.Ns(V,D);if(M==="hidden")return null;M==="disabled"&&(d=!0),M==="readOnly"&&(h=!0);const{t:U}=ne.Wo(),b=ne.cs(D),[g,x]=t.useState(""),[T,P]=t.useState(!1),R=t.useMemo(()=>{const c=s=>{for(const m of s){if(m.code===j)return m;if(m.children){const a=c(m.children);if(a)return a}}};return c(K)},[K,j]),v=t.useMemo(()=>{const c=[],s=m=>{for(const a of m)c.push(a),a.children&&s(a.children)};return s(K),c},[K]),u=t.useMemo(()=>{if(!g)return v;const c=g.toLowerCase();return v.filter(s=>s.code.toLowerCase().includes(c)||s.name.toLowerCase().includes(c))},[v,g]),S=t.useCallback(c=>{x(c),_?.(c),P(!0)},[_]),f=t.useCallback(c=>{Y?.(c.code,c),P(!1),x("")},[Y]);return e.jsxs("div",{ref:w,id:b,className:`nice-account-picker nice-size-${N}${z?` ${z}`:""}${o?" nice-error":""}${d?" nice-disabled":""}`,style:X,children:[n&&e.jsxs("label",{className:"nice-account-picker__label",htmlFor:`${b}-input`,children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-account-picker__control",children:$&&!h?e.jsx("input",{id:`${b}-input`,className:"nice-input",type:"text",value:T?g:R?`${R.code} — ${R.name}`:"",onChange:c=>S(c.target.value),onFocus:()=>{x(""),P(!0)},onBlur:()=>setTimeout(()=>P(!1),200),placeholder:B??U("searchAccount","Search account…"),disabled:d,required:r}):e.jsx("div",{className:"nice-account-picker__display",children:R?`${R.code} — ${R.name}`:B??U("selectAccount","Select account…")})}),T&&u.length>0&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",children:u.map(c=>e.jsxs("div",{className:`nice-account-picker__option${c.code===j?" nice-account-picker__option--selected":""}${c.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":c.code===j,onClick:()=>f(c),children:[C&&c.type&&e.jsx("span",{className:"nice-account-picker__type",style:{color:Li[c.type]},title:c.type,children:"●"}),e.jsx("span",{className:"nice-account-picker__code",children:c.code}),e.jsx("span",{className:"nice-account-picker__name",children:c.name})]},c.code))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});wn.displayName="NiceAccountPicker";const Nn=t.forwardRef(({label:n,helperText:i,error:o,required:r,disabled:d,readOnly:h,size:N="md",id:k,className:D,style:z,accessMode:X,mode:V="manual",onScan:j,onModeChange:Y,beepOnScan:K=!0,beepFrequency:te=1800,beepDuration:B=150,placeholder:$,scanHistory:C=[],showHistory:_=!0,maxHistory:w=10,autoFocus:M=!0,onCameraFrame:U},b)=>{const g=ne.Ns(X,k);if(g==="hidden")return null;g==="disabled"&&(d=!0),g==="readOnly"&&(h=!0);const{t:x}=ne.Wo(),T=ne.cs(k),[P,R]=t.useState(""),v=t.useRef(null),u=t.useRef(null),S=t.useCallback(()=>{if(K)try{u.current||(u.current=new AudioContext);const s=u.current,m=s.createOscillator(),a=s.createGain();m.connect(a),a.connect(s.destination),m.frequency.value=te,m.type="square",a.gain.value=.3,m.start(),m.stop(s.currentTime+B/1e3)}catch{}},[K,te,B]),f=t.useCallback(()=>{P.trim()&&(S(),j?.({value:P.trim(),format:"manual",scannedAt:new Date}),R(""),v.current?.focus())},[P,j,S]),c=C.slice(0,w);return e.jsxs("div",{ref:b,id:T,className:`nice-scanner nice-size-${N}${D?` ${D}`:""}${o?" nice-error":""}${d?" nice-disabled":""}`,style:z,children:[n&&e.jsxs("div",{className:"nice-scanner__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-scanner__modes",children:[e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${V==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>Y?.("camera"),disabled:d,children:["📷 ",x("camera","Camera")]}),e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${V==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>Y?.("manual"),disabled:d,children:["⌨️ ",x("manual","Manual")]})]}),V==="camera"&&e.jsx("div",{className:"nice-scanner__camera",children:e.jsx("div",{className:"nice-scanner__viewfinder",children:e.jsxs("div",{className:"nice-scanner__viewfinder-overlay",children:[e.jsx("span",{children:"📷"}),e.jsx("p",{children:x("cameraPlaceholder","Camera preview — connect scanner adapter")})]})})}),V==="manual"&&!h&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:v,className:"nice-input nice-scanner__input",type:"text",value:P,onChange:s=>R(s.target.value),onKeyDown:s=>s.key==="Enter"&&f(),placeholder:$??x("enterCode","Enter or scan code…"),disabled:d,autoFocus:M}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:f,disabled:d||!P.trim(),children:"✓"})]}),_&&c.length>0&&e.jsxs("div",{className:"nice-scanner__history",children:[e.jsx("div",{className:"nice-scanner__history-label",children:x("recentScans","Recent scans")}),c.map((s,m)=>e.jsxs("div",{className:"nice-scanner__history-item",children:[e.jsx("span",{className:"nice-scanner__history-value",children:s.value}),s.format&&e.jsx("span",{className:"nice-scanner__history-format",children:s.format}),e.jsx("span",{className:"nice-scanner__history-time",children:s.scannedAt.toLocaleTimeString()})]},m))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Nn.displayName="NiceScannerControl";const Cn=t.forwardRef(({label:n,helperText:i,error:o,required:r,disabled:d,readOnly:h,size:N="md",id:k,className:D,style:z,accessMode:X,value:V="",onChange:j,onComplete:Y,length:K=4,masked:te=!0,showKeypad:B=!1,autoSubmit:$=!0,shake:C=!1,placeholderChar:_="·"},w)=>{const M=ne.Ns(X,k);if(M==="hidden")return null;M==="disabled"&&(d=!0),M==="readOnly"&&(h=!0);const{t:U}=ne.Wo(),b=ne.cs(k),g=t.useRef([]),[x,T]=t.useState(!1);t.useEffect(()=>{if(C){T(!0);const S=setTimeout(()=>T(!1),500);return()=>clearTimeout(S)}},[C]);const P=V.split("").slice(0,K);for(;P.length<K;)P.push("");const R=t.useCallback((S,f)=>{const c=[...P];c[S]=f;const s=c.join("");j?.(s),f&&S<K-1&&g.current[S+1]?.focus(),$&&s.length===K&&s.indexOf("")===-1&&Y?.(s)},[P,K,j,Y,$]),v=t.useCallback((S,f)=>{S.key==="Backspace"&&!P[f]&&f>0&&(g.current[f-1]?.focus(),R(f-1,"")),S.key==="ArrowLeft"&&f>0&&g.current[f-1]?.focus(),S.key==="ArrowRight"&&f<K-1&&g.current[f+1]?.focus()},[P,K,R]),u=t.useCallback(S=>{if(S==="clear"){j?.(""),g.current[0]?.focus();return}if(S==="backspace"){const f=V.slice(0,-1);j?.(f);const c=Math.max(0,f.length-1);g.current[c]?.focus();return}if(V.length<K){const f=V+S;j?.(f),f.length<K&&g.current[f.length]?.focus(),$&&f.length===K&&Y?.(f)}},[V,K,j,Y,$]);return e.jsxs("div",{ref:w,id:b,className:`nice-pin nice-size-${N}${x?" nice-pin--shake":""}${D?` ${D}`:""}${o?" nice-error":""}${d?" nice-disabled":""}`,style:z,children:[n&&e.jsxs("label",{className:"nice-pin__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-pin__boxes",children:P.map((S,f)=>e.jsx("input",{ref:c=>{g.current[f]=c},className:"nice-pin__box",type:te?"password":"text",inputMode:"numeric",maxLength:1,value:S,onChange:c=>{const s=c.target.value.replace(/\D/g,"");s.length<=1&&R(f,s)},onKeyDown:c=>v(c,f),disabled:d,readOnly:h,placeholder:_,"aria-label":`${U("digit","Digit")} ${f+1}`},f))}),B&&!h&&e.jsx("div",{className:"nice-pin__keypad",children:["1","2","3","4","5","6","7","8","9","clear","0","backspace"].map(S=>e.jsx("button",{type:"button",className:`nice-pin__key${S==="clear"||S==="backspace"?" nice-pin__key--action":""}`,onClick:()=>u(S),disabled:d,children:S==="clear"?"C":S==="backspace"?"⌫":S},S))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Cn.displayName="NicePinCodeInput";exports.DEFAULT_ASPECT_RATIOS=cn;exports.EMOJI_DATA=qe;exports.GRADIENT_PRESETS=Ut;exports.NICE_COLOR_PRESET_KEYS=Ln;exports.NiceAccountPicker=wn;exports.NiceAddressInput=gn;exports.NiceCalendar=Vt;exports.NiceCodeDiffEditor=an;exports.NiceCodeEditor=gt;exports.NiceCodeEditor$1=ci;exports.NiceCodeEditorAI=li;exports.NiceColorPalette=Kt;exports.NiceContactPicker=xn;exports.NiceCropEditor=ln;exports.NiceCurrencyInput=fn;exports.NiceDateRangeBox=Kn;exports.NiceDocumentEditor=hn;exports.NiceDropDownBox=Un;exports.NiceEmojiPicker=rn;exports.NiceGradientPicker=Xt;exports.NiceHtmlEditor=ht;exports.NiceHtmlEditor$1=Jn;exports.NiceHtmlEditorAI=ni;exports.NiceImageAnnotator=dn;exports.NiceImageEditor=un;exports.NiceInputOtp=qt;exports.NiceInvoiceLineEditor=bn;exports.NiceKnob=Qt;exports.NiceLookup=Bn;exports.NiceMarkdownEditor=mn;exports.NiceMention=Zt;exports.NicePDFAnnotationEditor=jn;exports.NicePickList=nn;exports.NicePinCodeInput=Cn;exports.NiceRangeSlider=Yn;exports.NiceScannerControl=Nn;exports.NiceSignature=di;exports.NiceSignaturePad=pn;exports.NiceSimpleCodeEditor=sn;exports.NiceTaxRatePicker=kn;exports.NiceTreeSelect=tn;exports.NiceVatInput=vn;exports.NiceWiki=_n;exports.applyPreset=Ve;exports.contrastRatio=Ue;exports.cssToGradient=Yt;exports.generateHarmony=Oe;exports.generateVariations=Ht;exports.gradientToCss=lt;exports.hexToHsv=Fe;exports.hexToRgb=We;exports.hsvToHex=Ne;exports.hsvToRgb=Pt;exports.randomPalette=Wt;exports.rgbToHex=Ft;exports.rgbToHsl=Bt;exports.rgbToHsv=ut;exports.wcagLevel=Xe;
|