@nice2dev/ui 1.0.28 → 1.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/NiceAssessment.doc-BB1rXcVx.cjs +1 -0
  3. package/dist/NiceAssessment.doc-C3QQawiZ.js +23 -0
  4. package/dist/NiceBackupStatusBadge.doc-Bx2bFmBQ.cjs +1 -0
  5. package/dist/NiceBackupStatusBadge.doc-CdDxIQ-M.js +25 -0
  6. package/dist/NiceConfirmDialog-BiTJVR4-.js +81 -0
  7. package/dist/NiceConfirmDialog-Bjw_rN4o.cjs +1 -0
  8. package/dist/NiceConfirmDialog-DPfYwO2B.js +81 -0
  9. package/dist/NiceConfirmDialog-Dyh42OiK.cjs +1 -0
  10. package/dist/NiceErrorBoundary-1H751jK7.cjs +1 -0
  11. package/dist/NiceErrorBoundary-B-txoU3Y.js +709 -0
  12. package/dist/NiceErrorBoundary-BHCKA1h8.cjs +1 -0
  13. package/dist/NiceErrorBoundary-CBxXcleR.js +695 -0
  14. package/dist/NiceExam.doc-BpTJpwGb.js +23 -0
  15. package/dist/NiceExam.doc-Br8pEbQb.cjs +1 -0
  16. package/dist/NiceForm-C8yEx3VV.cjs +382 -0
  17. package/dist/NiceForm-Ci3XG7s7.js +5000 -0
  18. package/dist/NiceForm-DGUTmaZT.js +5014 -0
  19. package/dist/NiceForm-DmU-gmyv.cjs +382 -0
  20. package/dist/NiceModal-BClAtR5T.js +95 -0
  21. package/dist/NiceModal-Crbhc7GB.cjs +1 -0
  22. package/dist/NiceModal-XvEKVVLa.js +95 -0
  23. package/dist/NiceModal-iKwtagFB.cjs +1 -0
  24. package/dist/NiceModuleLifecyclePanel-BO8Hw_W9.js +7619 -0
  25. package/dist/NiceModuleLifecyclePanel-Ch7HRRoy.cjs +1 -0
  26. package/dist/NiceModuleLifecyclePanel-D3k8kAey.js +7582 -0
  27. package/dist/NiceModuleLifecyclePanel-MAyTh_s5.cjs +1 -0
  28. package/dist/NicePagination-BVo-4KAD.js +172 -0
  29. package/dist/NicePagination-CaohvQsY.cjs +1 -0
  30. package/dist/NicePagination-DUnMbROj.cjs +1 -0
  31. package/dist/NicePagination-DyC6dQ7_.js +171 -0
  32. package/dist/NicePinCodeInput-C43eB9h4.js +13102 -0
  33. package/dist/NicePinCodeInput-DsyLuc0b.cjs +696 -0
  34. package/dist/NicePinCodeInput-nuRCN-9R.js +13223 -0
  35. package/dist/NicePinCodeInput-p5IFVwfY.cjs +696 -0
  36. package/dist/NicePoll.doc-DCiXvOb0.js +23 -0
  37. package/dist/NicePoll.doc-IOgqVPhc.cjs +1 -0
  38. package/dist/NicePollLive.doc-CdUyiCyf.js +23 -0
  39. package/dist/NicePollLive.doc-xBMqHeyt.cjs +1 -0
  40. package/dist/NiceQuiz.doc-BhAeGrcP.cjs +1 -0
  41. package/dist/NiceQuiz.doc-BiZq8X1P.js +23 -0
  42. package/dist/NiceSavedQueryPanel-BBFV4qiF.js +6969 -0
  43. package/dist/NiceSavedQueryPanel-CsiVNkCT.cjs +596 -0
  44. package/dist/NiceSavedQueryPanel-DV4a4axz.cjs +596 -0
  45. package/dist/NiceSavedQueryPanel-Dgbn1ExK.js +6893 -0
  46. package/dist/NiceSurvey.doc-9UorYdXy.cjs +1 -0
  47. package/dist/NiceSurvey.doc-CPF1ZEHo.js +23 -0
  48. package/dist/NiceWindow-BehN3PKk.js +1592 -0
  49. package/dist/NiceWindow-Cm9E6EAi.cjs +1 -0
  50. package/dist/NiceWindow-Dqu9ik8A.cjs +1 -0
  51. package/dist/NiceWindow-FMrVS7zo.js +1603 -0
  52. package/dist/charts-B90sSFeJ.cjs +761 -0
  53. package/dist/charts-CJruxLRY.js +4657 -0
  54. package/dist/charts-D8oj6Nf5.cjs +761 -0
  55. package/dist/charts-DaLf19vS.js +4671 -0
  56. package/dist/charts.cjs +1 -1
  57. package/dist/charts.mjs +1 -1
  58. package/dist/core-BIdbG6p3.js +27212 -0
  59. package/dist/core-BUTtIHg0.js +27766 -0
  60. package/dist/core-CESNSRyS.cjs +122 -0
  61. package/dist/core-bzK0ZnUp.cjs +122 -0
  62. package/dist/data-branching-ByQdcjKO.cjs +1 -0
  63. package/dist/data-branching-BzRFsCJu.js +6133 -0
  64. package/dist/data-branching-DahoQa4M.cjs +1 -0
  65. package/dist/data-branching-psTzlcrT.js +6255 -0
  66. package/dist/data-branching.cjs +1 -1
  67. package/dist/data-branching.mjs +1 -1
  68. package/dist/data.cjs +1 -1
  69. package/dist/data.mjs +1 -1
  70. package/dist/devops-C9gdQxuU.cjs +17 -0
  71. package/dist/devops-CaO_4qGz.js +7684 -0
  72. package/dist/devops-D7bQ3rE4.cjs +17 -0
  73. package/dist/devops-jCmpD6O-.js +8165 -0
  74. package/dist/devops.cjs +1 -1
  75. package/dist/devops.mjs +3 -3
  76. package/dist/editors.cjs +1 -1
  77. package/dist/editors.d.ts +4 -0
  78. package/dist/editors.mjs +3 -3
  79. package/dist/feedback.cjs +1 -1
  80. package/dist/feedback.mjs +3 -3
  81. package/dist/index-BK_Uwmz0.js +67774 -0
  82. package/dist/index-BpixglWg.js +69337 -0
  83. package/dist/index-CTbp81RF.cjs +5517 -0
  84. package/dist/index-DLR-aWZR.cjs +5506 -0
  85. package/dist/index.cjs +1 -1
  86. package/dist/index.css +1 -1
  87. package/dist/index.d.ts +796 -545
  88. package/dist/index.mjs +992 -979
  89. package/dist/lazy.cjs +1 -1
  90. package/dist/lazy.mjs +24 -24
  91. package/dist/navigation.cjs +1 -1
  92. package/dist/navigation.mjs +146 -146
  93. package/dist/no-code-B0mG7OQc.cjs +332 -0
  94. package/dist/no-code-BHo5WrXr.js +7425 -0
  95. package/dist/no-code-CikRvKeJ.js +7133 -0
  96. package/dist/no-code-DyA_1_Th.cjs +332 -0
  97. package/dist/no-code.cjs +1 -1
  98. package/dist/no-code.mjs +1 -1
  99. package/dist/overlays.cjs +1 -1
  100. package/dist/overlays.d.ts +4 -0
  101. package/dist/overlays.mjs +66 -66
  102. package/dist/pickerCommons-BEc3pZ_s.js +2044 -0
  103. package/dist/pickerCommons-CqhXp4QL.js +2043 -0
  104. package/dist/pickerCommons-CrITwM88.cjs +1 -0
  105. package/dist/pickerCommons-OsYJhnFE.cjs +1 -0
  106. package/dist/style.css +1 -1
  107. package/package.json +3 -3
@@ -0,0 +1,696 @@
1
+ "use strict";const e=require("react/jsx-runtime"),v=require("./core-CESNSRyS.cjs"),n=require("react"),ve=require("./pickerCommons-CrITwM88.cjs"),jt=require("./NiceForm-DmU-gmyv.cjs"),Wt=require("./devops-D7bQ3rE4.cjs");function Fn(t,i=30){switch(t){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-i,180+i];case"analogous":return[0,-i,i];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270];case"shade-chain":return[];case"custom":return[0,60,200];default:return[0]}}function vt(t,i={}){const a=i.size??16,o="currentColor",d="currentColor";if(i.rectangle||t==="shade-chain"||t==="monochromatic"){const U=Math.max(3,Math.min(7,i.count??5)),b=a*.1,K=a-b*2,O=Math.max(1.2,a/14),Q=a/2,B=Array.from({length:U},(Y,w)=>{const _=b+K*w/(U-1),H=.25+.75*w/(U-1);return e.jsx("circle",{cx:_,cy:Q,r:O,fill:d,opacity:H},w)});return e.jsxs("svg",{width:a,height:a,viewBox:`0 0 ${a} ${a}`,"aria-hidden":!0,children:[e.jsx("rect",{x:1,y:a/2-a/6,width:a-2,height:a/3,rx:a/6,fill:"none",stroke:o,strokeOpacity:.25}),B]})}const N=i.angles??Fn(t),k=a/2,I=a/2,P=a/2-2,W=Math.max(1.4,a/9);return e.jsxs("svg",{width:a,height:a,viewBox:`0 0 ${a} ${a}`,"aria-hidden":!0,children:[e.jsx("circle",{cx:k,cy:I,r:P,fill:"none",stroke:o,strokeOpacity:.25}),N.map((U,b)=>{const K=(U-90)*Math.PI/180,O=k+P*Math.cos(K),Q=I+P*Math.sin(K);return e.jsx("circle",{cx:O,cy:Q,r:W,fill:d},b)})]})}function _t(t,i,a){return Math.max(i,Math.min(a,t))}function Vt({h:t,s:i,v:a}){t=(t%360+360)%360;const o=a*i,d=o*(1-Math.abs(t/60%2-1)),g=a-o;let N=0,k=0,I=0;return t<60?(N=o,k=d):t<120?(N=d,k=o):t<180?(k=o,I=d):t<240?(k=d,I=o):t<300?(N=d,I=o):(N=o,I=d),{r:Math.round((N+g)*255),g:Math.round((k+g)*255),b:Math.round((I+g)*255)}}function ft({r:t,g:i,b:a}){t/=255,i/=255,a/=255;const o=Math.max(t,i,a),d=Math.min(t,i,a),g=o-d;let N=0;return g!==0&&(o===t?N=(i-a)/g%6:o===i?N=(a-t)/g+2:N=(t-i)/g+4,N=(N*60+360)%360),{h:N,s:o===0?0:g/o,v:o}}function Gt({r:t,g:i,b:a}){t/=255,i/=255,a/=255;const o=Math.max(t,i,a),d=Math.min(t,i,a),g=(o+d)/2;if(o===d)return{h:0,s:0,l:g};const N=o-d,k=g>.5?N/(2-o-d):N/(o+d);let I=0;return o===t?I=((i-a)/N+(i<a?6:0))/6:o===i?I=((a-t)/N+2)/6:I=((t-i)/N+4)/6,{h:I*360,s:k,l:g}}function Je(t){const i=t.replace("#",""),a=i.length===3?i[0]+i[0]+i[1]+i[1]+i[2]+i[2]:i,o=parseInt(a,16);return{r:o>>16&255,g:o>>8&255,b:o&255}}function Xt({r:t,g:i,b:a}){return"#"+[t,i,a].map(o=>o.toString(16).padStart(2,"0")).join("")}function Ee(t){return Xt(Vt(t))}function Ae(t){return ft(Je(t))}function qt(t,i){const a=[];for(let o=0;o<i;o++){const d=i<=1?.5:o/(i-1),g=_t(t.s*(.3+d*.7),0,1),N=_t(t.v*(1.2-d*.7),0,1);a.push(Ee({h:t.h,s:g,v:N}))}return a}function yt(t,i){if(t==="custom"||t==="shade-chain")return[0];const a=i??30;switch(t){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-a,180+a];case"analogous":return[0,-a,a];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270]}return[0]}function qe(t,i,a){return yt(i,a).map(o=>((t+o)%360+360)%360)}function kt(t,i,a=.12){const o=Math.max(2,i),d=(o-1)/2,g=[];for(let N=0;N<o;N++){const k=(N-d)*a,I=Math.max(.05,Math.min(.98,t.v+k)),P=Math.max(.05,Math.min(1,t.s-Math.abs(k)*.25));g.push(Ee({h:t.h,s:P,v:I}))}return g}function wt({r:t,g:i,b:a}){const[o,d,g]=[t,i,a].map(N=>{const k=N/255;return k<=.03928?k/12.92:Math.pow((k+.055)/1.055,2.4)});return .2126*o+.7152*d+.0722*g}function tt(t,i){const a=wt(Je(t)),o=wt(Je(i)),d=Math.max(a,o),g=Math.min(a,o);return(d+.05)/(g+.05)}function nt(t){return t>=7?"AAA":t>=4.5?"AA":t>=3?"AA-lg":"Fail"}const Jt={"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 it(t,i){const a=Jt[i];return t.map(o=>{const d=(a.sRange[0]+a.sRange[1])/2,g=(a.vRange[0]+a.vRange[1])/2;return Ee({h:o,s:d,v:g})})}function Bn(){return Math.floor(Math.random()*360)}function Zt(t,i,a){const o=Bn(),d=qe(o,t,a),g=[];for(let N=0;N<i;N++){const k=d[N%d.length],I=.55+Math.random()*.4,P=.5+Math.random()*.45;g.push(Ee({h:k+(Math.random()-.5)*8,s:I,v:P}))}return g}const Kn=({hues:t,baseHue:i,onBaseHueChange:a,mode:o,distance:d,disabled:g})=>{const U=n.useCallback(B=>{if(g)return;const w=B.currentTarget.getBoundingClientRect(),_=B.clientX-w.left-120,H=B.clientY-w.top-120,j=(Math.atan2(H,_)*180/Math.PI+360)%360;a(Math.round(j))},[120,120,g,a]),b=[];for(let B=0;B<360;B+=2){const Y=(B-1)*Math.PI/180,w=(B+1)*Math.PI/180,_=Ee({h:B,s:1,v:1});b.push(e.jsx("path",{d:`M${120+55*Math.cos(Y)},${120+55*Math.sin(Y)} L${120+110*Math.cos(Y)},${120+110*Math.sin(Y)} A110,110 0 0,1 ${120+110*Math.cos(w)},${120+110*Math.sin(w)} L${120+55*Math.cos(w)},${120+55*Math.sin(w)} A55,55 0 0,0 ${120+55*Math.cos(Y)},${120+55*Math.sin(Y)} Z`,fill:_},B))}const K=`wheel-center-${o}`,O=t.map((B,Y)=>{const _=B*Math.PI/180;return e.jsx("circle",{cx:120+82.5*Math.cos(_),cy:120+82.5*Math.sin(_),r:Y===0?8:6,fill:Ee({h:B,s:.85,v:.9}),stroke:Y===0?"var(--bg-primary, #fff)":"var(--border-color, #ccc)",strokeWidth:Y===0?3:2},Y)});let Q=null;if(o==="analogous"||o==="split-complementary"){const w=yt(o,d).slice(1).map((_,H)=>{const j=(i+_)*Math.PI/180;return e.jsx("line",{x1:120,y1:120,x2:120+82.5*Math.cos(j),y2:120+82.5*Math.sin(j),stroke:"var(--nice-overlay-light-30, rgba(255, 255, 255, 0.3))",strokeWidth:1,strokeDasharray:"3,3"},`dline-${H}`)});Q=e.jsx(e.Fragment,{children:w})}return e.jsxs("svg",{className:"nice-palette__wheel",viewBox:"0 0 240 240",width:240,height:240,onClick:U,style:{cursor:g?"default":"crosshair"},children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:K,children:[e.jsx("stop",{offset:"0%",stopColor:"var(--nice-bg, #fff)"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})}),b,e.jsx("circle",{cx:120,cy:120,r:53,fill:Ee({h:i,s:.6,v:.85})}),e.jsx("circle",{cx:120,cy:120,r:53,fill:`url(#${K})`,opacity:.4}),Q,O]})},Un=({colors:t})=>{if(t.length<2)return null;const i=[];for(let a=0;a<t.length;a++){const o=tt(t[a],"var(--bg-primary, #ffffff)"),d=tt(t[a],"var(--text-primary, #000000)");i.push({a:t[a],b:"var(--bg-primary, #ffffff)",ratio:o,level:nt(o)}),i.push({a:t[a],b:"var(--text-primary, #000000)",ratio:d,level:nt(d)});for(let g=a+1;g<t.length;g++){const N=tt(t[a],t[g]);i.push({a:t[a],b:t[g],ratio:N,level:nt(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((a,o)=>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:a.a}}),e.jsx("span",{className:"nice-palette__contrast-vs",children:"vs"}),e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:a.b}})]}),e.jsxs("span",{className:"nice-palette__contrast-ratio",children:[a.ratio.toFixed(1),":1"]}),e.jsx("span",{className:`nice-palette__contrast-level nice-palette__contrast-level--${a.level.toLowerCase().replace("-","")}`,children:a.level})]},o))})]})},Yn=({hex:t})=>{const i=Je(t),a=Gt(i),o=ft(i);return e.jsxs("div",{className:"nice-palette__color-info",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"HEX"})," ",t.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(a.h),"°, ",Math.round(a.s*100),"%,"," ",Math.round(a.l*100),"%"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSV"})," ",Math.round(o.h),"°, ",Math.round(o.s*100),"%,"," ",Math.round(o.v*100),"%"]})]})},Wn={monochromatic:"Monochromatic",complementary:"Complementary","split-complementary":"Split-Complementary",analogous:"Analogous",triadic:"Triadic",tetradic:"Tetradic (Rectangle)",square:"Square","shade-chain":"Shade chain",custom:"Custom"},Vn={"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"},Gn=["monochromatic","shade-chain","complementary","split-complementary","analogous","triadic","tetradic","square","custom"],Xn=["lightest-pastel","bright-pastel","shiny","pastel","full","dark","deep","muted","earth"],Qt="nice-palette-custom-schemes";function qn(){if(typeof window>"u")return[];try{const t=window.localStorage.getItem(Qt);if(!t)return[];const i=JSON.parse(t);if(Array.isArray(i))return i}catch{}return[]}function Jn(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Qt,JSON.stringify(t))}catch{}}const en=n.forwardRef(({id:t,className:i,style:a,accessMode:o,value:d,onChange:g,minColors:N=1,maxColors:k=8,harmonyMode:I,onHarmonyModeChange:P,distance:W,onDistanceChange:U,preset:b,onPresetChange:K,showWheel:O=!0,showContrast:Q=!0,showInfo:B=!0,showPresets:Y=!0,presets:w=[],showVariations:_=!0,showRandom:H=!0,variationCount:j=5,label:z,disabled:$,colorCount:x,shadeStep:h,onShadeStepChange:M,customSchemes:D,onCustomSchemesChange:S,persistCustomSchemes:y=!0},s)=>{const L=v.$c(o,t),C=L==="hidden";(L==="disabled"||L==="readOnly")&&($=!0);const m=v.hc(t),{t:c}=v.Gt(),[u,p]=n.useState("analogous"),[f,l]=n.useState(30),[E,R]=n.useState(""),[J,A]=n.useState(0),[he,re]=n.useState(.12),[fe,ne]=n.useState(null),[se,de]=n.useState(()=>D??(y?qn():[])),[ue,je]=n.useState(null),te=I??u,ce=W??f,me=b??E,ae=h??he,ee=D??se;n.useEffect(()=>{!D&&y&&Jn(se)},[se,D,y]);const le=n.useCallback(ie=>{de(ie),S?.(ie)},[S]),V=n.useCallback(ie=>{p(ie),P?.(ie)},[P]),F=n.useCallback(ie=>{l(ie),U?.(ie)},[U]),X=n.useCallback(ie=>{R(ie),ie&&K?.(ie)},[K]),Z=n.useMemo(()=>["var(--color-primary, #3b82f6)","var(--color-error, #ef4444)","var(--color-success, #22c55e)"],[]),q=d&&d.length>0?d:Z,be=q[0],ye=n.useMemo(()=>Ae(be),[be]),xe=n.useMemo(()=>qe(ye.h,te,ce),[ye.h,te,ce]),_e=n.useCallback((ie,ge,ke,Me)=>{const r=x??fe??void 0,T=r!==void 0?Math.max(N,Math.min(k,r)):void 0;if(ge==="shade-chain"){const Ne=T??Math.max(N,5),Se=kt({h:ie,s:ye.s||.7,v:ye.v||.6},Ne,ae);g?.(Se);return}let G;const oe=ge==="custom"&&ue?ee.find(Ne=>Ne.id===ue):null;oe&&oe.angles.length>0?G=oe.angles.map(Ne=>((ie+Ne)%360+360)%360):G=qe(ie,ge,ke);let pe;if(Me&&Jt[Me]?pe=it(G,Me):pe=G.map(Ne=>Ee({h:Ne,s:ye.s||.7,v:ye.v||.85})),oe?.lightnessOffsets?.length&&(pe=pe.map((Ne,Se)=>{const Oe=oe.lightnessOffsets?.[Se];if(Oe==null)return Ne;const Te=Ae(Ne);return Ee({h:Te.h,s:Te.s,v:Math.max(.05,Math.min(.98,Te.v+Oe))})})),T!==void 0){for(;pe.length<T;){const Ne=pe[pe.length-1]||"#888888",Se=Ae(Ne);pe.push(Ee({h:(Se.h+18)%360,s:Se.s,v:Se.v}))}pe=pe.slice(0,T)}else{for(;pe.length<N;)pe.push(pe[pe.length-1]||"var(--nice-text-secondary, #888888)");pe.length>k&&(pe=pe.slice(0,k))}g?.(pe)},[ye.s,ye.v,N,k,g,x,fe,ae,ue,ee]),we=n.useCallback(ie=>{if(!$){if(te==="custom"){const ge=Ee({h:ie,s:ye.s||.7,v:ye.v||.85}),ke=[...q];ke[J]=ge,g?.(ke);return}_e(ie,te,ce,me)}},[$,te,ce,me,_e,ye.s,ye.v,q,J,g]),$e=n.useCallback(ie=>{$||(V(ie),ie!=="custom"&&_e(ye.h,ie,ce,me))},[$,ye.h,ce,me,V,_e]),Re=n.useCallback(ie=>{$||(F(ie),_e(ye.h,te,ie,me))},[$,ye.h,te,me,F,_e]),Ie=n.useCallback(ie=>{if($)return;X(ie);const ge=qe(ye.h,te,ce),ke=it(ge,ie);g?.(ke.slice(0,k))},[$,ye.h,te,ce,k,X,g]),ze=n.useCallback((ie,ge)=>{if($)return;const ke=[...q];ke[ie]=ge,g?.(ke)},[$,q,g]),Ke=n.useCallback(()=>{if($||q.length>=k)return;const ie=Ae(q[q.length-1]),ge=Ee({h:(ie.h+30)%360,s:ie.s,v:ie.v});g?.([...q,ge])},[$,q,k,g]),Ue=n.useCallback(ie=>{if($||q.length<=N)return;const ge=q.filter((ke,Me)=>Me!==ie);g?.(ge),J>=ge.length&&A(Math.max(0,ge.length-1))},[$,q,N,g,J]),Ye=n.useCallback(()=>{if($)return;const ie=Math.max(N,Math.min(k,yt(te).length)),ge=Zt(te,ie,ce);g?.(ge)},[$,N,k,te,ce,g]),Le=n.useMemo(()=>{if(!_)return[];const ie=q[J]||q[0];return qt(Ae(ie),j)},[_,q,J,j]),De=q[J]||q[0],Pe=n.useMemo(()=>{const ie=Ae(De);return Ee({h:(ie.h+180)%360,s:ie.s,v:ie.v})},[De]);return C?null:e.jsxs("div",{ref:s,id:m,className:`nice-palette ${$?"nice-palette--disabled":""} ${i||""}`,style:a,children:[z&&e.jsx("div",{className:"nice-palette__label",children:z}),e.jsxs("div",{className:"nice-palette__modes",style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx(ve.NiceSelect,{label:c("colorPalette.harmony","Harmony"),labelPlacement:"left",size:"sm",disabled:$,value:te==="custom"&&ue?`custom:${ue}`:te,onChange:ie=>{const ge=Array.isArray(ie)?ie[0]:ie;if(typeof ge=="string")if(ge.startsWith("custom:")){const ke=ge.slice(7);je(ke),$e("custom")}else je(null),$e(ge)},options:[...Gn.map(ie=>({value:ie,label:Wn[ie]})),...ee.map(ie=>({value:`custom:${ie.id}`,label:ie.name}))],renderOption:(ie,ge)=>{const ke=String(ie.value),Me=ke.startsWith("custom:"),r=Me?ee.find(oe=>oe.id===ke.slice(7)):null,T=r?r.angles:void 0,G=Me?"custom":ke;return e.jsxs("span",{style:{display:"inline-flex",gap:8,alignItems:"center"},children:[e.jsx("span",{style:{width:16,height:16,display:"inline-flex",color:"currentColor"},children:vt(G,{angles:T,size:16,count:x})}),e.jsx("span",{style:{fontWeight:ge?600:400},children:ie.label})]})}}),te==="shade-chain"&&e.jsx(ve.NiceNumberInput,{label:c("colorPalette.step","Step"),labelPlacement:"left",size:"sm",min:.02,max:.5,step:.02,precision:2,value:ae,onChange:ie=>{const ge=typeof ie=="number"?ie:Number(ie);Number.isNaN(ge)||(re(ge),M?.(ge),_e(ye.h,te,ce,me))},showStepper:!0,disabled:$}),e.jsx(ve.NiceNumberInput,{label:c("colorPalette.colors","Colors"),labelPlacement:"left",size:"sm",min:Math.max(2,N),max:Math.min(12,k),step:1,precision:0,value:x??fe??q.length,onChange:ie=>{const ge=typeof ie=="number"?ie:Number(ie);if(!Number.isFinite(ge))return;const ke=Math.max(Math.max(2,N),Math.min(Math.min(12,k),Math.round(ge)));ne(ke),te==="shade-chain"?g?.(kt({h:ye.h,s:ye.s||.7,v:ye.v||.6},ke,ae)):setTimeout(()=>_e(ye.h,te,ce,me),0)},showStepper:!0,disabled:$})]}),e.jsxs("div",{className:"nice-palette__main",children:[O&&e.jsxs("div",{className:"nice-palette__wheel-container",children:[e.jsx(Kn,{hues:xe,baseHue:ye.h,onBaseHueChange:we,mode:te,distance:ce,disabled:$}),(te==="analogous"||te==="split-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsxs("label",{children:["Distance: ",ce,"°"]}),e.jsx("input",{type:"range",min:10,max:90,value:ce,onChange:ie=>Re(Number(ie.target.value)),disabled:$,className:"nice-palette__distance-slider"})]})]}),e.jsxs("div",{className:"nice-palette__strips",children:[e.jsxs("div",{className:"nice-palette__swatches",children:[q.map((ie,ge)=>e.jsxs("div",{className:`nice-palette__swatch-wrapper ${J===ge?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>A(ge),children:[e.jsx("div",{className:"nice-palette__swatch",style:{background:ie},children:q.length>N&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:ke=>{ke.stopPropagation(),Ue(ge)},disabled:$,"aria-label":"Remove color",children:e.jsx(v.oa,{name:"close",size:14})})}),e.jsx("input",{type:"text",className:"nice-palette__hex-input",value:ie.toUpperCase(),maxLength:7,disabled:$,onChange:ke=>ze(ge,ke.target.value)})]},ge)),q.length<k&&e.jsx("button",{type:"button",className:"nice-palette__add-btn",onClick:Ke,disabled:$,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:Pe},title:Pe.toUpperCase()}),e.jsx("span",{className:"nice-palette__hex-label",children:Pe.toUpperCase()})]}),_&&Le.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:Le.map((ie,ge)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:ie},title:ie.toUpperCase(),onClick:()=>{$||ze(J,ie)},role:"button",tabIndex:0},ge))})]}),H&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:Ye,disabled:$,title:"Random palette","aria-label":"Random palette",children:[e.jsx(v.oa,{name:"shuffle",size:14})," Random Palette"]})]})]}),Y&&w.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:w.map(ie=>{const ge=it(xe,ie);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${me===ie?"nice-palette__preset-card--active":""}`,onClick:()=>Ie(ie),disabled:$,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:ge.map((ke,Me)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:ke}},Me))}),e.jsx("span",{className:"nice-palette__preset-label",children:Vn[ie]})]},ie)})})]}),B&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Selected Color Info"}),e.jsx(Yn,{hex:De})]}),e.jsxs("details",{className:"nice-palette__custom-schemes",style:{marginTop:8},children:[e.jsxs("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:["Custom schemes (",ee.length,")"]}),e.jsxs("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:6},children:[ee.length===0&&e.jsx("div",{style:{fontSize:12,color:"var(--text-muted)"},children:c("colorPalette.schemes.empty","Save the current palette as a reusable scheme.")}),ee.map(ie=>e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",fontSize:12},children:[e.jsx("span",{style:{width:16,height:16,display:"inline-flex"},children:vt("custom",{angles:ie.angles,size:16})}),e.jsx("span",{style:{flex:1},children:ie.name}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>{je(ie.id),$e("custom")},disabled:$,children:"Use"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>le(ee.filter(ge=>ge.id!==ie.id)),disabled:$,"aria-label":`Delete ${ie.name}`,children:e.jsx(v.oa,{name:"close",size:14})})]},ie.id)),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:$,onClick:()=>{const ie=typeof window<"u"?window.prompt("Scheme name?",`Scheme ${ee.length+1}`):null;if(!ie)return;const ge=Ae(q[0]).h,ke=q.map(r=>(Ae(r).h-ge+540)%360-180),Me={id:`cs-${Date.now()}`,name:ie,angles:ke};le([...ee,Me])},children:"+ Save current as scheme"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:$||ee.length===0,onClick:()=>{typeof navigator>"u"||navigator.clipboard?.writeText(JSON.stringify(ee,null,2))},children:c("colorPalette.exportJson","Export JSON")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:$,onClick:()=>{if(typeof window>"u")return;const ie=window.prompt("Paste schemes JSON");if(ie)try{const ge=JSON.parse(ie);Array.isArray(ge)&&le(ge)}catch{}},children:c("colorPalette.importJson","Import JSON")})]})]})]}),Q&&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(Un,{colors:q})})]})]})});en.displayName="NiceColorPalette";function ut(){return{type:"linear",angle:90,stops:[{color:"var(--nice-primary, #3b82f6)",position:0},{color:"var(--nice-accent, #8b5cf6)",position:100}]}}function pt(t){const i=t.stops.slice().sort((o,d)=>o.position-d.position).map(o=>`${o.color} ${o.position}%`).join(", "),a=t.repeating?"repeating-":"";switch(t.type){case"linear":return`${a}linear-gradient(${t.angle}deg, ${i})`;case"radial":{const o=t.shape||"ellipse",d=t.size||"farthest-corner",g=t.positionX??50,N=t.positionY??50;return`${a}radial-gradient(${o} ${d} at ${g}% ${N}%, ${i})`}case"conic":{const o=t.angle??0,d=t.positionX??50,g=t.positionY??50;return`${a}conic-gradient(from ${o}deg at ${d}% ${g}%, ${i})`}}}function tn(t){const i=t.trim(),a=i.startsWith("repeating-");if(i.includes("linear-gradient")){const o=i.match(/linear-gradient\((.+)\)/)?.[1];if(!o)return null;const d=o.split(",").map(P=>P.trim());let g=90,N=0;const k=d[0].match(/^(\d+)deg$/);k&&(g=parseInt(k[1]),N=1);const I=ct(d.slice(N));return{type:"linear",angle:g,repeating:a,stops:I}}if(i.includes("radial-gradient")){const o=i.match(/radial-gradient\((.+)\)/)?.[1];if(!o)return null;const d=o.split(",").map(N=>N.trim()),g=ct(d.filter(N=>N.includes("#")||N.includes("rgb")));return{type:"radial",angle:0,repeating:a,stops:g.length>=2?g:ut().stops}}if(i.includes("conic-gradient")){const o=i.match(/conic-gradient\((.+)\)/)?.[1];if(!o)return null;const d=o.split(",").map(N=>N.trim()),g=ct(d.filter(N=>N.includes("#")||N.includes("rgb")));return{type:"conic",angle:0,repeating:a,stops:g.length>=2?g:ut().stops}}return null}function ct(t){return t.map((i,a,o)=>{const d=i.match(/^(#[0-9a-fA-F]{3,8}|rgba?\([^)]+\))\s*(\d+%?)?$/);if(d){const g=d[2]?parseFloat(d[2]):a/Math.max(1,o.length-1)*100;return{color:d[1],position:g}}return{color:i,position:a/Math.max(1,o.length-1)*100}})}function Zn(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function Qn(t=2){const i=["linear","radial","conic"],a=i[Math.floor(Math.random()*i.length)],o=[];for(let d=0;d<t;d++)o.push({color:Zn(),position:Math.round(d/(t-1)*100)});return{type:a,angle:Math.floor(Math.random()*360),stops:o,shape:a==="radial"?Math.random()>.5?"circle":"ellipse":void 0,positionX:a!=="linear"?Math.round(Math.random()*100):void 0,positionY:a!=="linear"?Math.round(Math.random()*100):void 0}}const nn=[{name:"Sunset",value:{type:"linear",angle:135,stops:[{color:"var(--nice-danger, #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:"var(--nice-warning-bg, #ffecd2)",position:0},{color:"#fcb69f",position:100}],positionX:50,positionY:50}},{name:"Rainbow",value:{type:"conic",angle:0,stops:[{color:"var(--nice-danger, #ff0000)",position:0},{color:"#ff8800",position:17},{color:"var(--nice-warning, #ffff00)",position:33},{color:"var(--nice-success, #00ff00)",position:50},{color:"#0088ff",position:67},{color:"#8800ff",position:83},{color:"var(--nice-danger, #ff0000)",position:100}],positionX:50,positionY:50}}],an=n.forwardRef(({id:t,className:i,style:a,accessMode:o,value:d,onChange:g,showCssOutput:N=!0,showPresets:k=!0,showEditor:I=!0,showRandom:P=!0,maxStops:W=10,label:U,disabled:b,width:K},O)=>{const Q=v.$c(o,t),B=Q==="hidden";(Q==="disabled"||Q==="readOnly")&&(b=!0);const Y=v.hc(t),w=d??ut(),_=n.useMemo(()=>pt(w),[w]),[H,j]=n.useState(0),[z,$]=n.useState(""),x=n.useRef(null),h=n.useCallback(f=>{g?.(f)},[g]),M=n.useCallback(f=>{b||h({...w,type:f})},[b,w,h]),D=n.useCallback(f=>{b||h({...w,angle:f})},[b,w,h]),S=n.useCallback(f=>{b||h({...w,repeating:f})},[b,w,h]),y=n.useCallback(f=>{b||h({...w,shape:f})},[b,w,h]),s=n.useCallback((f,l)=>{if(b)return;const E=w.stops.map((R,J)=>J===f?{...R,...l}:R);h({...w,stops:E})},[b,w,h]),L=n.useCallback(()=>{if(b||w.stops.length>=W)return;const f=w.stops.slice().sort((A,he)=>A.position-he.position);let l=0,E=f[0];for(let A=0;A<f.length-1;A++){const he=f[A+1].position-f[A].position;he>l&&(l=he,E=f[A])}const R=Math.round(E.position+l/2),J="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");h({...w,stops:[...w.stops,{color:J,position:R}]})},[b,w,W,h]),C=n.useCallback(f=>{if(b||w.stops.length<=2)return;const l=w.stops.filter((E,R)=>R!==f);h({...w,stops:l}),H>=l.length&&j(l.length-1)},[b,w,H,h]),m=n.useCallback(()=>{if(b)return;const f=2+Math.floor(Math.random()*3);h(Qn(f))},[b,h]),c=n.useCallback(()=>{if(b||!z.trim())return;const f=tn(z);f&&h(f)},[b,z,h]),u=n.useCallback(f=>{if(b||!x.current||w.stops.length>=W)return;const l=x.current.getBoundingClientRect(),E=Math.round((f.clientX-l.left)/l.width*100),R="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),J=[...w.stops,{color:R,position:E}];h({...w,stops:J}),j(J.length-1)},[b,w,W,h]),p=n.useMemo(()=>w.stops.slice().sort((f,l)=>f.position-l.position),[w.stops]);return B?null:e.jsxs("div",{ref:O,id:Y,className:`nice-gradient ${b?"nice-gradient--disabled":""} ${i||""}`,style:{width:K!=null?typeof K=="number"?`${K}px`:K:320,boxSizing:"border-box",...a},children:[U&&e.jsx("div",{className:"nice-gradient__label",children:U}),e.jsx("div",{className:"nice-gradient__preview",style:{background:_}}),I&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(f=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${w.type===f?"nice-gradient__type-btn--active":""}`,onClick:()=>M(f),disabled:b,children:f.charAt(0).toUpperCase()+f.slice(1)},f)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:w.repeating??!1,onChange:f=>S(f.target.checked),disabled:b}),"Repeating"]})]}),e.jsxs("div",{className:"nice-gradient__controls",children:[w.type==="linear"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Angle: ",w.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:w.angle,onChange:f=>D(Number(f.target.value)),disabled:b,className:"nice-gradient__slider"}),e.jsx("div",{className:"nice-gradient__angle-presets",children:[0,45,90,135,180,225,270,315].map(f=>e.jsx("button",{type:"button",className:`nice-gradient__angle-btn ${w.angle===f?"nice-gradient__angle-btn--active":""}`,onClick:()=>D(f),disabled:b,title:`${f}°`,children:e.jsx("span",{style:{transform:`rotate(${f}deg)`,display:"inline-flex"},children:e.jsx(v.oa,{name:"arrow-right",size:14})})},f))})]}),w.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(f=>e.jsx("button",{type:"button",className:`nice-gradient__shape-btn ${(w.shape||"ellipse")===f?"nice-gradient__shape-btn--active":""}`,onClick:()=>y(f),disabled:b,children:f},f))})]}),(w.type==="radial"||w.type==="conic")&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Center: ",w.positionX??50,"%, ",w.positionY??50,"%"]}),e.jsxs("div",{className:"nice-gradient__center-inputs",children:[e.jsx("input",{type:"range",min:0,max:100,value:w.positionX??50,onChange:f=>h({...w,positionX:Number(f.target.value)}),disabled:b,className:"nice-gradient__slider"}),e.jsx("input",{type:"range",min:0,max:100,value:w.positionY??50,onChange:f=>h({...w,positionY:Number(f.target.value)}),disabled:b,className:"nice-gradient__slider"})]})]}),w.type==="conic"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Start angle: ",w.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:w.angle,onChange:f=>D(Number(f.target.value)),disabled:b,className:"nice-gradient__slider"})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{ref:x,className:"nice-gradient__bar",style:{background:_},onClick:u,children:w.stops.map((f,l)=>e.jsx("div",{className:`nice-gradient__stop-marker ${H===l?"nice-gradient__stop-marker--active":""}`,style:{left:`${f.position}%`},onClick:E=>{E.stopPropagation(),j(l)},title:`${f.color} @ ${f.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:f.color}})},l))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:L,disabled:b||w.stops.length>=W,title:"Add stop",children:"+"})]}),e.jsx("div",{className:"nice-gradient__stop-editor",children:e.jsx("div",{className:"nice-gradient__stop-list",children:p.map((f,l)=>{const E=w.stops.indexOf(f);return e.jsxs("div",{className:`nice-gradient__stop-row ${H===E?"nice-gradient__stop-row--active":""}`,onClick:()=>j(E),children:[e.jsx("input",{type:"color",value:f.color,onChange:R=>s(E,{color:R.target.value}),disabled:b,className:"nice-gradient__stop-color"}),e.jsx("input",{type:"text",value:f.color.toUpperCase(),maxLength:7,onChange:R=>s(E,{color:R.target.value}),disabled:b,className:"nice-gradient__stop-hex"}),e.jsx("input",{type:"number",min:0,max:100,value:f.position,onChange:R=>s(E,{position:Number(R.target.value)}),disabled:b,className:"nice-gradient__stop-pos"}),e.jsx("span",{className:"nice-gradient__stop-pct",children:"%"}),w.stops.length>2&&e.jsx("button",{type:"button",className:"nice-gradient__stop-del",onClick:()=>C(E),disabled:b,"aria-label":"Remove stop",children:e.jsx(v.oa,{name:"close",size:14})})]},E)})})})]}),P&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-gradient__random-btn",onClick:m,disabled:b,title:"Random gradient","aria-label":"Random gradient",children:[e.jsx(v.oa,{name:"shuffle",size:14})," 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:nn.map((f,l)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{b||h(f.value)},disabled:b,title:f.name,children:[e.jsx("div",{className:"nice-gradient__preset-preview",style:{background:pt(f.value)}}),e.jsx("span",{className:"nice-gradient__preset-name",children:f.name})]},l))})]}),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: ${_};`}),e.jsx("button",{type:"button",className:"nice-gradient__copy-btn",onClick:()=>navigator.clipboard?.writeText(`background: ${_};`),title:"Copy CSS","aria-label":"Copy CSS",children:e.jsx(v.oa,{name:"clipboard",size:16})})]}),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:z,onChange:f=>$(f.target.value),disabled:b}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:c,disabled:b,children:"Import"})]})]})]})});an.displayName="NiceGradientPicker";const ei=({options:t,value:i,onChange:a,searchable:o=!0,clearable:d,loading:g,placeholder:N,label:k,error:I,helperText:P,required:W,disabled:U,size:b="md",id:K,className:O,style:Q,data:B,columns:Y,valueField:w="id",displayField:_,dropdownWidth:H,controlWidth:j})=>{const z=v.hc(K),{t:$}=v.Gt(),[x,h]=n.useState(!1),[M,D]=n.useState(""),S=n.useRef(null);v.vc(S,()=>h(!1));const y=!!(B&&Y&&Y.length>0),s=_??(Y&&Y[0]?.key),L=n.useMemo(()=>!y||!B?[]:B.map(p=>({value:String(p[w]??""),label:s?String(p[s]??""):""})),[y,B,w,s]),C=y?L:t??[],m=C.find(p=>String(p.value)===i),c=n.useMemo(()=>{if(!y||!B)return[];if(!M)return B;const p=M.toLowerCase();return B.filter(f=>Y.some(l=>String(f[l.key]??"").toLowerCase().includes(p)))},[y,B,Y,M]),u=n.useMemo(()=>{if(y||!M)return C;const p=M.toLowerCase();return C.filter(f=>f.label.toLowerCase().includes(p))},[C,M,y]);return e.jsxs("div",{className:`nice-field nice-field--${b} ${I?"nice-field--error":""} ${O||""}`,style:{width:j!=null?typeof j=="number"?`${j}px`:j:"fit-content",...Q},ref:S,children:[k&&e.jsxs("label",{className:"nice-field__label",htmlFor:z,children:[k,W&&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:z,className:"nice-select__trigger",onClick:()=>!U&&h(!x),disabled:U,children:[e.jsx("span",{children:m?.label||N||$("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[d&&i&&!U&&e.jsx("span",{className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":$("controls.clear","Clear"),onClick:p=>{p.stopPropagation(),a("")},children:e.jsx(v.oa,{name:"close",size:14})}),e.jsx("span",{className:"nice-select__arrow",children:e.jsx(v.oa,{name:"chevron-down",size:16})})]})]}),x&&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 var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",minWidth:"100%",width:H!=null?typeof H=="number"?`${H}px`:H:y?"max-content":"100%"},children:[o&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:M,onChange:p=>D(p.target.value),placeholder:$("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)"}})}),y?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:Y.map(p=>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:p.width!=null?typeof p.width=="number"?`${p.width}px`:p.width:void 0},children:p.header},p.key))})}),e.jsx("tbody",{children:c.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:Y.length,style:{padding:12,textAlign:"center",color:"var(--text-muted)"},children:$("controls.noResults","No results")})}):c.map(p=>{const f=String(p[w]??""),l=f===i;return e.jsx("tr",{role:"option","aria-selected":l,onClick:()=>{a(f),h(!1),D("")},style:{cursor:"pointer",background:l?"var(--hover-bg)":"transparent"},onMouseEnter:E=>{l||(E.currentTarget.style.background="var(--hover-bg)")},onMouseLeave:E=>{l||(E.currentTarget.style.background="transparent")},children:Y.map(E=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--border-color)"},children:String(p[E.key]??"")},E.key))},f)})})]}):e.jsx("ul",{className:"nice-dropdown__list",role:"listbox",style:{listStyle:"none",margin:0,padding:4,maxHeight:240,overflowY:"auto"},children:u.length===0?e.jsx("li",{className:"nice-dropdown__empty",style:{padding:8,color:"var(--text-muted)"},children:$("controls.noResults","No results")}):u.map(p=>e.jsx("li",{role:"option",className:`nice-dropdown__option ${String(p.value)===i?"nice-dropdown__option--selected":""}`,onClick:()=>{a(String(p.value)),h(!1),D("")},"aria-selected":String(p.value)===i,children:p.label},String(p.value)))})]})]}),I&&e.jsx("div",{className:"nice-field__error",children:I}),P&&!I&&e.jsx("div",{className:"nice-field__hint",children:P})]})},ti=["Su","Mo","Tu","We","Th","Fr","Sa"];function ni(t,i){return new Date(t,i+1,0).getDate()}function ii(t,i){return new Date(t,i,1).getDay()}function Nt(t,i,a){return`${t}-${String(i+1).padStart(2,"0")}-${String(a).padStart(2,"0")}`}function ai(t){const i=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()));i.setUTCDate(i.getUTCDate()+4-(i.getUTCDay()||7));const a=new Date(Date.UTC(i.getUTCFullYear(),0,1));return Math.ceil(((i.getTime()-a.getTime())/864e5+1)/7)}const Ct=["January","February","March","April","May","June","July","August","September","October","November","December"],on=({value:t,onChange:i,min:a,max:o,disabledDates:d=[],firstDayOfWeek:g=1,size:N="md",showWeekNumbers:k,onMonthChange:I,className:P,style:W,accessMode:U,id:b,multiple:K,selectedDates:O=[],onSelectedDatesChange:Q,renderDay:B,showKeyboardHints:Y,persistPreferences:w=!1,fullWidth:_=!1,cookies:H=!1,localStorage:j=!0,sessionStorage:z=!1,storageMode:$,storageKey:x})=>{const h=v.$c(U,b),M=h==="hidden",D=h==="disabled"||h==="readOnly",{t:S}=v.Gt(),y=new Date,s=t?new Date(t):y,L=v.useStorageAdapter(x??"nice-calendar"),C=n.useMemo(()=>w?L.get("prefs")??{}:{},[w,L]),m=C.firstDayOfWeek??g,[c,u]=n.useState(C.lastViewYear??s.getFullYear()),[p,f]=n.useState(C.lastViewMonth??s.getMonth()),[l,E]=n.useState(C.preferredView??"days"),R=n.useCallback(Z=>{if(!w)return;const q=L.get("prefs")??{};L.set("prefs",{...q,...Z})},[w,L]),J=n.useCallback(Z=>{E(Z),R({preferredView:Z})},[R]),A=n.useCallback((Z,q)=>{R({lastViewYear:Z,lastViewMonth:q})},[R]),he=n.useMemo(()=>[v.Jc.moveUp,v.Jc.moveDown,v.Jc.moveLeft,v.Jc.moveRight,{key:"Enter",description:S("shortcuts.selectDate","Select date")},v.Jc.pageUp,v.Jc.pageDown],[S]),re=n.useMemo(()=>ni(c,p),[c,p]),fe=n.useMemo(()=>(ii(c,p)-m+7)%7,[c,p,m]),ne=n.useMemo(()=>{const Z=[...ti];for(let q=0;q<m;q++)Z.push(Z.shift());return Z},[m]),se=n.useCallback(Z=>a&&Z<a||o&&Z>o?!0:d.includes(Z),[a,o,d]),de=n.useCallback(Z=>{if(l==="years"){u(ye=>ye+Z*10);return}if(l==="months"){u(ye=>ye+Z);return}let q=p+Z,be=c;q<0&&(q=11,be--),q>11&&(q=0,be++),f(q),u(be),A(be,q),I?.(be,q)},[p,c,I,l,A]),ue=Nt(y.getFullYear(),y.getMonth(),y.getDate()),je=n.useCallback(Z=>K?O.includes(Z):Z===t,[K,O,t]),te=n.useCallback(Z=>{if(!D){if(K){const q=O.includes(Z)?O.filter(be=>be!==Z):[...O,Z];Q?.(q)}i?.(Z)}},[K,O,i,Q]),ce=n.useCallback(()=>{l==="days"?J("months"):l==="months"&&J("years")},[l,J]),me=n.useCallback(Z=>{f(Z),J("days"),A(c,Z),I?.(c,Z)},[c,I,J,A]),ae=n.useCallback(Z=>{u(Z),J("months")},[J]),ee=l==="years"?`${c-c%10} – ${c-c%10+9}`:l==="months"?`${c}`:`${Ct[p]} ${c}`,le=l==="years"?"decade":l==="months"?"year":"month",V=[];for(let Z=0;Z<fe;Z++)V.push(null);for(let Z=1;Z<=re;Z++)V.push(Z);for(;V.length%7!==0;)V.push(null);const F=[];for(let Z=0;Z<V.length;Z+=7)F.push(V.slice(Z,Z+7));const X=c-c%10;return M?null:e.jsxs("div",{className:`nice-calendar nice-calendar--${N}${_?" nice-calendar--full-width":""} ${P||""}`,style:W,children:[e.jsxs("div",{className:"nice-calendar__header",children:[e.jsx("button",{type:"button",className:"nice-calendar__nav",onClick:()=>de(-1),"aria-label":`Previous ${le}`,children:e.jsx(v.oa,{name:"chevron-left",size:16})}),e.jsx("button",{type:"button",className:"nice-calendar__title",onClick:ce,"aria-label":l==="days"?"Show month picker":l==="months"?"Show year picker":void 0,disabled:l==="years",children:ee}),e.jsx("button",{type:"button",className:"nice-calendar__nav",onClick:()=>de(1),"aria-label":`Next ${le}`,children:e.jsx(v.oa,{name:"chevron-right",size:16})}),Y&&e.jsx(v.ha,{shortcuts:he,size:"sm"})]}),l==="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"}),ne.map(Z=>e.jsx("th",{children:Z},Z))]})}),e.jsx("tbody",{children:F.map((Z,q)=>e.jsxs("tr",{children:[k&&e.jsx("td",{className:"nice-calendar__wk",children:Z.find(be=>be!=null)?ai(new Date(c,p,Z.find(be=>be!=null))):""}),Z.map((be,ye)=>{if(be==null)return e.jsx("td",{className:"nice-calendar__empty-cell"},ye);const xe=Nt(c,p,be),_e=se(xe),we=je(xe),$e=xe===ue;return e.jsx("td",{className:`nice-calendar__day${we?" nice-calendar__day--selected":""}${$e?" nice-calendar__day--today":""}${_e?" nice-calendar__day--disabled":""}`,onClick:()=>!_e&&te(xe),role:"gridcell","aria-selected":we,"aria-disabled":_e,children:B?B(xe,be):be},ye)})]},q))})]}),l==="months"&&e.jsx("div",{className:"nice-calendar__picker-grid",children:Ct.map((Z,q)=>e.jsx("button",{type:"button",className:`nice-calendar__picker-cell${q===p&&c===s.getFullYear()?" nice-calendar__picker-cell--selected":""}`,onClick:()=>me(q),children:Z.slice(0,3)},q))}),l==="years"&&e.jsx("div",{className:"nice-calendar__picker-grid",children:Array.from({length:12},(Z,q)=>X-1+q).map(Z=>e.jsx("button",{type:"button",className:`nice-calendar__picker-cell${Z===c?" nice-calendar__picker-cell--selected":""}${Z<X||Z>X+9?" nice-calendar__picker-cell--other":""}`,onClick:()=>ae(Z),children:Z},Z))})]})};on.displayName="NiceCalendar";const oi=({startDate:t,endDate:i,onStartChange:a,onEndChange:o,min:d,max:g,clearable:N,startPlaceholder:k,endPlaceholder:I,startLabel:P,endLabel:W,layout:U="horizontal",separator:b="–",gap:K=12,fullWidth:O=!1,label:Q,error:B,helperText:Y,required:w,disabled:_,size:H="md",id:j,className:z,style:$,accessMode:x,showKeyboardHints:h,labelPlacement:M,errorPlacement:D,labelWidth:S,controlWidth:y,loading:s})=>{const L=v.$c(x,j),C=v.hc(j),{t:m}=v.Gt(),c=L==="disabled"||L==="readOnly"||!!_,u=n.useMemo(()=>[{key:"Tab",description:m("shortcuts.switchField","Switch between start/end")},v.Jc.cancel],[m]);if(L==="hidden")return null;const p=l=>{a(l),l&&i&&l>i&&o(l)},f=U==="horizontal";return e.jsxs("div",{className:`nice-field nice-field--${H} nice-daterange nice-daterange--${U} ${M==="left"?"nice-field--label-left":""} ${B?"nice-field--error":""} ${s?"nice-field--loading":""} ${z||""}`,style:{...$,...S!=null&&{"--nice-field-label-width":typeof S=="number"?`${S}px`:S},...y!=null&&{"--nice-field-control-width":typeof y=="number"?`${y}px`:y}},"aria-busy":s||void 0,children:[Q&&e.jsxs("label",{className:"nice-field__label",htmlFor:C,children:[Q,w&&e.jsx("span",{className:"nice-field__required",children:"*"}),h&&e.jsx(v.ha,{shortcuts:u,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-daterange__row",style:{display:"flex",flexDirection:f?"row":"column",alignItems:f?"flex-end":"stretch",gap:K,flexWrap:"wrap"},children:[e.jsx("div",{style:{flex:O?"1 1 0":void 0,minWidth:0},children:e.jsx(jt.NiceDatePicker,{id:C,label:P,value:t,onChange:p,min:d,max:i||g,placeholder:k||m("controls.startDate","Start date"),disabled:c,size:H,clearable:N,labelPlacement:M,labelWidth:S})}),f&&b!==""&&b!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--text-secondary, #666)"},"aria-hidden":"true",children:b}),e.jsx("div",{style:{flex:O?"1 1 0":void 0,minWidth:0},children:e.jsx(jt.NiceDatePicker,{label:W,value:i,onChange:o,min:t||d,max:g,placeholder:I||m("controls.endDate","End date"),disabled:c,size:H,clearable:N,labelPlacement:M,labelWidth:S})})]}),s&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),D==="right"&&B&&e.jsx("div",{className:"nice-field__error",role:"alert",children:B}),D==="right"&&!B&&Y&&e.jsx("div",{className:"nice-field__helper",children:Y})]}),D!=="right"&&B&&e.jsx("div",{className:"nice-field__error",children:B}),D!=="right"&&!B&&Y&&e.jsx("div",{className:"nice-field__hint",children:Y})]})},ri=({min:t=0,max:i=100,step:a=1,startValue:o,endValue:d,onChange:g,showLabels:N=!0,formatLabel:k,valuePlacement:I="none",label:P,error:W,helperText:U,required:b,disabled:K,readOnly:O,loading:Q,size:B="md",id:Y,className:w,style:_,accessMode:H,showKeyboardHints:j,labelPlacement:z,errorPlacement:$,labelWidth:x,controlWidth:h})=>{const M=v.$c(H,Y),D=M==="hidden";(M==="disabled"||M==="readOnly")&&(K=!0);const{t:S}=v.Gt(),y=v.hc(Y),s=n.useRef(null),L=n.useMemo(()=>[v.Jc.increment,v.Jc.decrement,v.Jc.first,v.Jc.last,{key:"Tab",description:S("shortcuts.switchThumb","Switch thumb")}],[S]),C=p=>(p-t)/(i-t)*100,m=p=>k?k(p):String(p),c=p=>{const f=Math.round(p/a)*a;return Math.max(t,Math.min(i,f))},u=n.useCallback((p,f)=>{p.preventDefault();const l=s.current;if(!l||K)return;const E=J=>{const A=l.getBoundingClientRect(),he=Math.max(0,Math.min(1,(J.clientX-A.left)/A.width)),re=c(t+he*(i-t));f==="start"?g(Math.min(re,d),d):g(o,Math.max(re,o))},R=()=>{document.removeEventListener("pointermove",E),document.removeEventListener("pointerup",R)};document.addEventListener("pointermove",E),document.addEventListener("pointerup",R)},[t,i,a,o,d,g,K]);return D?null:e.jsxs("div",{className:`nice-field nice-field--${B} nice-field--rangeslider ${z==="left"?"nice-field--label-left":""} ${$==="right"?"nice-field--error-right":""} ${W?"nice-field--error":""} ${Q?"nice-field--loading":""} ${w||""}`,style:{..._,...x!=null&&{"--nice-field-label-width":typeof x=="number"?`${x}px`:x},...h!=null&&{"--nice-field-control-width":typeof h=="number"?`${h}px`:h}},"aria-busy":Q||void 0,children:[P&&e.jsxs("label",{className:"nice-field__label nice-field__label--with-value",htmlFor:y,children:[e.jsxs("span",{className:"nice-field__label-text",children:[P,b&&e.jsx("span",{className:"nice-field__required",children:"*"}),j&&e.jsx(v.ha,{shortcuts:L,size:"sm"})]}),I==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[m(o)," – ",m(d)]})]}),e.jsxs("div",{className:"nice-field__control",children:[I==="right"&&!P&&e.jsxs("span",{className:"nice-range-slider__value",children:[m(o)," – ",m(d)]}),e.jsxs("div",{className:"nice-range-slider__stack",children:[e.jsxs("div",{className:`nice-range-slider ${N?"nice-range-slider--with-labels":""} ${P?"nice-range-slider--has-field-label":""}`,ref:s,children:[e.jsx("div",{className:"nice-range-slider__track",children:e.jsx("div",{className:"nice-range-slider__fill",style:{left:`${C(o)}%`,width:`${C(d)-C(o)}%`}})}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${C(o)}%`},onPointerDown:p=>O?void 0:u(p,"start"),role:"slider","aria-valuemin":t,"aria-valuemax":d,"aria-valuenow":o,tabIndex:K?-1:0,id:y}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${C(d)}%`},onPointerDown:p=>O?void 0:u(p,"end"),role:"slider","aria-valuemin":o,"aria-valuemax":i,"aria-valuenow":d,tabIndex:K?-1:0})]}),N&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${C(o)}%`},children:m(o)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${C(d)}%`},children:m(d)})]}),I==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[m(o)," – ",m(d)]})]}),Q&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),$==="right"&&W&&e.jsx("div",{className:"nice-field__error",role:"alert",children:W}),$==="right"&&!W&&U&&e.jsx("div",{className:"nice-field__helper",children:U})]}),$!=="right"&&W&&e.jsx("div",{className:"nice-field__error",role:"alert",children:W}),$!=="right"&&!W&&U&&e.jsx("div",{className:"nice-field__helper",children:U})]})},si=({displayValue:t,placeholder:i,clearable:a,children:o,onClear:d,open:g,onOpenChange:N,dropdownWidth:k,label:I,error:P,helperText:W,required:U,disabled:b,size:K="md",id:O,className:Q,style:B,accessMode:Y,showKeyboardHints:w,displayStyle:_})=>{v.rc("input",_),v.ac("input",_);const H=v.$c(Y,O),j=H==="hidden";(H==="disabled"||H==="readOnly")&&(b=!0);const z=v.hc(O),{t:$}=v.Gt(),[x,h]=n.useState(!1),M=n.useRef(null),D=g??x,S=n.useMemo(()=>[{key:"Enter",description:$("shortcuts.openDropdown","Open dropdown")},v.Jc.cancel],[$]),y=s=>{N?N(s):h(s)};return v.vc(M,()=>y(!1)),j?null:e.jsxs("div",{className:`nice-field nice-field--${K} ${P?"nice-field--error":""} ${Q||""}`,style:B,ref:M,children:[I&&e.jsxs("label",{className:"nice-field__label",htmlFor:z,children:[I,U&&e.jsx("span",{className:"nice-field__required",children:"*"}),w&&e.jsx(v.ha,{shortcuts:S,size:"sm"})]}),e.jsxs("div",{className:"nice-field__input-wrap",children:[e.jsxs("button",{type:"button",id:z,className:"nice-select__trigger",onClick:()=>!b&&y(!D),disabled:b,children:[e.jsx("span",{children:t||i||$("controls.select","Select...")}),e.jsx("span",{className:"nice-select__arrow",children:e.jsx(v.oa,{name:"chevron-down",size:16})})]}),a&&t&&!b&&e.jsx("button",{type:"button",className:"nice-field__clear",onClick:()=>d?.(),"aria-label":$("controls.clear","Clear"),children:e.jsx(v.oa,{name:"close",size:14})})]}),D&&e.jsx("div",{className:"nice-dropdown",style:{width:k},children:o}),P&&e.jsx("div",{className:"nice-field__error",children:P}),W&&!P&&e.jsx("div",{className:"nice-field__hint",children:W})]})};function St(t){const i=t.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 ci=[{target:".nice-htmleditor",titleKey:"tutorial.htmlEditor.intro.title",title:"Rich text editor",contentKey:"tutorial.htmlEditor.intro.content",content:"Format text with the toolbar, insert links, images and tables, and switch to HTML or Markdown source when you need it.",placement:"auto"}],li=["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"],Ce=({d:t,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:t})}),di={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(Ce,{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"}),ol:e.jsx(Ce,{d:"M10 6h11M10 12h11M10 18h11M4 6h1v4M4 10h2M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"}),link:e.jsx(Ce,{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(Ce,{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(Ce,{d:"M3 7v6h6M3 13a9 9 0 1 0 3-7.7L3 13"}),redo:e.jsx(Ce,{d:"M21 7v6h-6M21 13a9 9 0 1 1-3-7.7L21 13"}),clear:e.jsx(Ce,{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(Ce,{d:"M3 3h18v18H3zM3 9h18M3 15h18M9 3v18M15 3v18"}),image:e.jsx(Ce,{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(Ce,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),markdown:"MD",blockquote:e.jsx(Ce,{d:"M3 21c3-3 3-9 0-12M21 21c-3-3-3-9 0-12M9 7h6v6H9zM15 7h6v6h-6z"}),hr:e.jsx(Ce,{d:"M5 12h14"}),subscript:"X₂",superscript:"X²",indent:e.jsx(Ce,{d:"M3 8l4 4-4 4M7 6h14M7 12h14M3 18h18"}),outdent:e.jsx(Ce,{d:"M7 8l-4 4 4 4M21 6H3M21 12H7M21 18H3"}),alignLeft:e.jsx(Ce,{d:"M3 6h18M3 12h12M3 18h18"}),alignCenter:e.jsx(Ce,{d:"M3 6h18M6 12h12M3 18h18"}),alignRight:e.jsx(Ce,{d:"M3 6h18M9 12h12M3 18h18"}),alignJustify:e.jsx(Ce,{d:"M3 6h18M3 12h18M3 18h18"}),fullscreen:e.jsx(Ce,{d:"M3 9V3h6M21 9V3h-6M3 15v6h6M21 15v6h-6"}),removeFormat:e.jsx(Ce,{d:"M4 7V4h16v3M5 20h6M13 4 8 20"}),print:e.jsx(Ce,{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(Ce,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),emoji:e.jsx(Ce,{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(Ce,{d:"M11 19a8 8 0 1 1 0-16 8 8 0 0 1 0 16zM21 21l-4.35-4.35"}),fontSize:e.jsx(Ce,{d:"M4 7V4h16v3M9 20h6M12 4v16"}),fontColor:e.jsx(Ce,{d:"M4 21h16M5 17l7-12 7 12M8 13h8"})},mi=[{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"}],ui=[{label:"Faces",emojis:["??","??","??","??","??","??","??","??","??","??","??","??"]},{label:"Hands",emojis:["??","??","??","??","??","??","??","??","??","??"]},{label:"Symbols",emojis:["??","?","??","?","?","?","??","??","??","??","??","??"]},{label:"Arrows",emojis:["??","??","??","??","??","??","??","??","??","?"]}];function pi(t){let i=t;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 hi(t){let i=t;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 xt=({value:t,onChange:i,placeholder:a,height:o=200,toolbar:d=li,readOnly:g,onImageUpload:N,mentionTrigger:k,mentionSuggestions:I,onMentionSearch:P,onFileDrop:W,pasteCleanup:U=!0,maxLength:b=0,showWordCount:K=!1,templates:O,label:Q,error:B,helperText:Y,required:w,disabled:_,size:H="md",id:j,className:z,style:$,accessMode:x,tutorial:h})=>{const M=v.$c(x,j),D=M==="hidden";M==="disabled"&&(_=!0),M==="readOnly"&&(g=!0);const S=v.hc(j),y=n.useRef(null),s=n.useRef(null),L=n.useRef(null),[C,m]=n.useState(!1),[c,u]=n.useState(""),[p,f]=n.useState(!1),[l,E]=n.useState(""),[R,J]=n.useState(!1),[A,he]=n.useState(""),[re,fe]=n.useState(0),[ne,se]=n.useState(!1),[de,ue]=n.useState("var(--nice-text, #000000)"),[je,te]=n.useState("var(--nice-warning, #ffff00)"),[ce,me]=n.useState(0),[ae,ee]=n.useState(0),[le,V]=n.useState(!1),[F,X]=n.useState(""),[Z,q]=n.useState(""),[be,ye]=n.useState(!1),[xe,_e]=n.useState(!1),we=n.useCallback((r,T)=>{if(g||_)return;const G=y.current;if(G){if(r==="markdown"){if(!C)u(pi(t)),m(!0),f(!1);else{const oe=hi(c);i(oe),m(!1)}return}if(r==="source"){p?(i(l),f(!1)):(E(t),f(!0),m(!1));return}if(r==="fullscreen"){se(oe=>!oe);return}if(r==="emoji"){ye(oe=>!oe);return}if(r==="findReplace"){V(oe=>!oe);return}if(r==="image"){if(N)s.current?.click();else{const oe=prompt("Image URL:");oe&&St(oe)&&(G.focus(),document.execCommand("insertImage",!1,oe),i(v.lc(G.innerHTML)))}return}switch(G.focus(),r){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 oe=prompt("URL:");oe&&St(oe)&&document.execCommand("createLink",!1,oe);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":{T&&document.execCommand("fontSize",!1,T);break}case"fontColor":{T&&document.execCommand("foreColor",!1,T);break}case"bgColor":{T&&document.execCommand("hiliteColor",!1,T);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>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></tbody></table><p>&nbsp;</p>');break}case"code":{const pe=window.getSelection()?.toString()||"";pe.includes(`
10
+ `)||pe.length>60?document.execCommand("insertHTML",!1,`<pre class="nice-htmleditor__code-block">${pe||"// code"}</pre>`):document.execCommand("insertHTML",!1,`<code>${pe||"code"}</code>`);break}}i(v.lc(G.innerHTML)),me(G.textContent?.length??0)}},[i,g,_,C,c,t,N,p,l]),$e=n.useCallback(async r=>{const T=r.target.files?.[0];if(!T||!N)return;const G=await N(T),oe=y.current;oe&&G&&(oe.focus(),document.execCommand("insertImage",!1,G),i(oe.innerHTML)),r.target.value=""},[N,i]),Re=n.useCallback(()=>{const r=y.current;if(!r)return;const T=r.textContent?.length??0;if(b>0&&T>b&&(r.textContent=(r.textContent??"").slice(0,b)),me(T),ee((r.textContent??"").trim().split(/\s+/).filter(Boolean).length),i(r.innerHTML),k){const G=window.getSelection();if(G&&G.rangeCount>0){const oe=G.getRangeAt(0),pe=oe.startContainer;if(pe.nodeType===Node.TEXT_NODE){const Ne=pe.textContent||"",Se=oe.startOffset,Oe=Ne.slice(0,Se),Te=Oe.lastIndexOf(k);if(Te>=0&&(Te===0||/\s/.test(Oe[Te-1]))){const We=Oe.slice(Te+k.length);if(!/\s/.test(We)){J(!0),he(We),fe(0),P?.(We);return}}}}J(!1)}},[i,k,P]),Ie=I?.filter(r=>r.label.toLowerCase().includes(A.toLowerCase())).slice(0,8)??[],ze=n.useCallback(r=>{const T=y.current;if(!T)return;const G=window.getSelection();if(!G||G.rangeCount===0)return;const oe=G.getRangeAt(0),pe=oe.startContainer;if(pe.nodeType===Node.TEXT_NODE&&k){const Ne=pe.textContent||"",Se=oe.startOffset,Te=Ne.slice(0,Se).lastIndexOf(k);if(Te>=0){const We=Ne.slice(0,Te),Pn=Ne.slice(Se),On=`<span class="nice-htmleditor__mention" data-mention="${r.key}" contenteditable="false">${k}${r.label}</span>&nbsp;`;pe.textContent=We;const st=document.createRange();st.setStartAfter(pe),st.collapse(!0);const Hn=st.createContextualFragment(On+Pn);pe.parentNode?.insertBefore(Hn,pe.nextSibling),G.collapseToEnd(),i(T.innerHTML)}}J(!1)},[k,i]),Ke=n.useCallback(r=>{if(R&&Ie.length>0){r.key==="ArrowDown"?(r.preventDefault(),fe(T=>Math.min(T+1,Ie.length-1))):r.key==="ArrowUp"?(r.preventDefault(),fe(T=>Math.max(T-1,0))):r.key==="Enter"?(r.preventDefault(),ze(Ie[re])):r.key==="Escape"&&J(!1);return}(r.ctrlKey||r.metaKey)&&r.key==="b"?(r.preventDefault(),we("bold")):(r.ctrlKey||r.metaKey)&&r.key==="i"?(r.preventDefault(),we("italic")):(r.ctrlKey||r.metaKey)&&r.key==="u"?(r.preventDefault(),we("underline")):(r.ctrlKey||r.metaKey)&&r.key==="f"?(r.preventDefault(),V(T=>!T)):(r.ctrlKey||r.metaKey)&&r.key==="z"&&!r.shiftKey?(r.preventDefault(),we("undo")):(r.ctrlKey||r.metaKey)&&(r.key==="y"||r.key==="z"&&r.shiftKey)&&(r.preventDefault(),we("redo"))},[R,Ie,re,ze,we]),Ue=n.useCallback(r=>{if(!U)return;r.preventDefault();const T=r.clipboardData.getData("text/html"),G=r.clipboardData.getData("text/plain");if(T){const pe=T.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,pe)}else G&&document.execCommand("insertText",!1,G);const oe=y.current;oe&&(i(oe.innerHTML),me(oe.textContent?.length??0))},[U,i]),Ye=n.useCallback(async r=>{if(!W)return;r.preventDefault();const T=Array.from(r.dataTransfer.files);if(T.length===0)return;const G=await W(T),oe=y.current;if(oe){oe.focus();for(const pe of G)if(/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(pe)||pe.startsWith("data:image/"))document.execCommand("insertImage",!1,pe);else{const Se=`<a href="${pe}">${pe.split("/").pop()??pe}</a>`;document.execCommand("insertHTML",!1,Se)}i(oe.innerHTML)}},[W,i]),Le=n.useCallback(r=>{W&&r.preventDefault()},[W]),De=n.useCallback(r=>{const T=y.current;if(!T||!F)return;const G=T.textContent??"",oe=F.toLowerCase(),pe=G.toLowerCase();(r===1?pe.indexOf(oe):pe.lastIndexOf(oe))!==-1&&(T.focus(),window.find?.(F))},[F]),Pe=n.useCallback(()=>{const r=y.current;!r||!F||(r.innerHTML=r.innerHTML.split(F).join(Z),i(r.innerHTML))},[F,Z,i]),ie=n.useCallback(()=>{if(!F)return;const r=t.split(F).join(Z);i(r);const T=y.current;T&&(T.innerHTML=r)},[F,Z,t,i]),ge=n.useCallback(r=>{const T=y.current;T&&(T.focus(),document.execCommand("insertText",!1,r),i(T.innerHTML),ye(!1))},[i]),ke=n.useCallback(r=>{const T=y.current;T&&(T.focus(),document.execCommand("insertHTML",!1,r),i(T.innerHTML),_e(!1))},[i]),Me=n.useCallback(r=>{const T=_||g;if(r==="fontSize")return e.jsx(ve.NiceSelect,{size:"sm",value:"",onChange:oe=>we("fontSize",String(oe)),disabled:T,placeholder:"Size",options:mi.map(oe=>({value:oe.value,label:oe.label})),style:{minWidth:70,maxWidth:80}},r);if(r==="fontColor")return e.jsx(ve.NiceColorPicker,{value:de,onChange:oe=>{ue(oe),we("fontColor",oe)},disabled:T,size:"sm",label:"",title:"Text color"},r);if(r==="bgColor")return e.jsx(ve.NiceColorPicker,{value:je,onChange:oe=>{te(oe),we("bgColor",oe)},disabled:T,size:"sm",label:"",title:"Highlight color"},r);const G=r==="markdown"&&C||r==="fullscreen"&&ne||r==="source"&&p||r==="findReplace"&&le||r==="emoji"&&be;return e.jsx(ve.NiceButton,{size:"sm",variant:G?"primary":"ghost",onClick:()=>we(r),title:r,disabled:T,children:di[r]||r},r)},[_,g,we,C,ne,de,je,p,le,be]);return D?null:e.jsxs("div",{className:`nice-field nice-field--${H} ${B?"nice-field--error":""} ${z||""}`,style:$,children:[Q&&e.jsxs("label",{className:"nice-field__label",htmlFor:S,children:[Q,w&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{ref:L,className:`nice-htmleditor${ne?" nice-htmleditor--fullscreen":""}`,style:{position:"relative"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Yl,{steps:v.Jl(h,ci)})}),e.jsxs("div",{className:"nice-htmleditor__toolbar",style:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[d.map(Me),O&&O.length>0&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(ve.NiceButton,{size:"sm",variant:xe?"primary":"ghost",onClick:()=>_e(r=>!r),title:"Insert template",children:"??"}),xe&&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 var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",listStyle:"none",margin:0,padding:4,minWidth:160,maxHeight:200,overflow:"auto"},children:O.map((r,T)=>e.jsx("li",{style:{padding:"6px 10px",cursor:"pointer",borderRadius:4},onMouseDown:G=>{G.preventDefault(),ke(r.html)},children:r.label},T))})]})]}),le&&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:F,onChange:r=>X(r.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:Z,onChange:r=>q(r.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(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>De(1),title:"Find next",children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>De(-1),title:"Find previous",children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:Pe,disabled:_||g,children:"Replace"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:ie,disabled:_||g,children:"All"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>V(!1),children:"?"})]}),be&&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:ui.map(r=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"0.7em",fontWeight:600,color:"var(--text-muted, #999)",padding:"4px 0"},children:r.label}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:2},children:r.emojis.map(T=>e.jsx("span",{style:{cursor:"pointer",fontSize:"1.2em",padding:2,borderRadius:4},onClick:()=>ge(T),title:T,children:T},T))})]},r.label))}),e.jsx("input",{ref:s,type:"file",accept:"image/*",style:{display:"none"},onChange:$e}),p?e.jsx("textarea",{className:"nice-htmleditor__source",value:l,onChange:r=>E(r.target.value),style:{minHeight:o,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:_||g}):C?e.jsx("textarea",{className:"nice-htmleditor__markdown",value:c,onChange:r=>u(r.target.value),style:{minHeight:o,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:_||g}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:y,id:S,className:"nice-htmleditor__content",contentEditable:!_&&!g,dangerouslySetInnerHTML:{__html:t},onInput:Re,onKeyDown:Ke,onPaste:Ue,onDrop:Ye,onDragOver:Le,style:{minHeight:o},"data-placeholder":a,role:"textbox","aria-multiline":"true",suppressContentEditableWarning:!0}),R&&Ie.length>0&&e.jsx("ul",{className:"nice-htmleditor__mention-list",children:Ie.map((r,T)=>e.jsx("li",{className:`nice-htmleditor__mention-item ${T===re?"nice-htmleditor__mention-item--active":""}`,onMouseDown:G=>{G.preventDefault(),ze(r)},children:r.label},r.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:[b>0&&e.jsxs("span",{children:[ce," / ",b]}),K&&e.jsxs("span",{children:[ae," words"]}),K&&e.jsxs("span",{children:[ce," chars"]}),p&&e.jsx("span",{style:{fontWeight:600},children:"HTML Source"}),C&&e.jsx("span",{style:{fontWeight:600},children:"Markdown"})]})]}),B&&e.jsx("div",{className:"nice-field__error",children:B}),Y&&!B&&e.jsx("div",{className:"nice-field__hint",children:Y})]})},gi=Object.freeze(Object.defineProperty({__proto__:null,NiceHtmlEditor:xt},Symbol.toStringTag,{value:"Module"})),fi=[{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"}],yi=[{style:"professional",label:"Professional"},{style:"casual",label:"Casual"},{style:"formal",label:"Formal"},{style:"concise",label:"Concise"}],xi=n.forwardRef(function(i,a){const{enableAI:o=!0,aiModel:d,enableImprove:g=!0,enableTranslate:N=!0,enableGenerate:k=!0,toolbar:I,languages:P=fi,textStyles:W=yi,onImprove:U,onTranslate:b,onGenerate:K,showAIToolbar:O=!0,value:Q,onChange:B,...Y}=i,w=n.useRef(null),[_,H]=n.useState(!1),[j,z]=n.useState(!1),[$,x]=n.useState(!1),[h,M]=n.useState(""),[D,S]=n.useState(""),[y,s]=n.useState("professional"),[L,C]=n.useState(""),[m,c]=n.useState(P[0]?.code||"en"),[u,p]=n.useState(""),[f,l]=n.useState(""),{t:E}=v.Gt(),R=v.he(),{improveText:J,translate:A,generateHtml:he,isLoading:re}=v.Ad(),fe=o&&R.isConfigured,ne=n.useCallback(()=>{const ae=window.getSelection();return ae&&ae.toString().trim()?ae.toString():""},[]),se=n.useCallback(ae=>{const ee=window.getSelection();if(ee&&ee.rangeCount>0){const le=ee.getRangeAt(0);le.deleteContents();const V=document.createElement("div");V.innerHTML=ae;const F=document.createDocumentFragment();for(;V.firstChild;)F.appendChild(V.firstChild);if(le.insertNode(F),w.current){const X=w.current.innerHTML;B(X)}}},[B]),de=n.useCallback(async(ae="professional")=>{if(!fe||!g)return"";const ee=ne();if(!ee)return"";M(ee),s(ae),H(!0),S("");try{const le=await J(ee,ae);return S(le),U?.(ee,le,ae),le}catch{return S(E("htmlEditorAI.improveFailed","Failed to improve text")),""}},[fe,g,ne,J,U,E]),ue=n.useCallback(async ae=>{if(!fe||!N)return"";const ee=ne();if(!ee)return"";M(ee),c(ae),z(!0),C("");try{const le=P.find(F=>F.code===ae)?.label||ae,V=await A(ee,le);return C(V),b?.(ee,V,ae),V}catch{return C(E("htmlEditorAI.translateFailed","Failed to translate text")),""}},[fe,N,ne,A,P,b,E]),je=n.useCallback(async ae=>{if(!fe||!k||!ae.trim())return"";p(ae),l("");try{const ee=await he(ae);return l(ee),K?.(ae,ee),ee}catch{return l(E("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[fe,k,he,K,E]),te=n.useCallback(()=>{D&&se(D),H(!1),S("")},[D,se]),ce=n.useCallback(()=>{L&&se(L),z(!1),C("")},[L,se]),me=n.useCallback(()=>{if(f&&w.current){document.execCommand("insertHTML",!1,f);const ae=w.current.innerHTML;B(ae)}x(!1),l(""),p("")},[f,B]);return n.useImperativeHandle(a,()=>({getEditor:()=>w.current,focus:()=>w.current?.focus(),getValue:()=>w.current?.innerHTML||"",setValue:ae=>{w.current&&(w.current.innerHTML=ae,B(ae))},getSelection:ne,insertHtml:ae=>{document.execCommand("insertHTML",!1,ae),w.current&&B(w.current.innerHTML)},improveSelection:de,translateSelection:ue,generateHtml:je})),n.useCallback(ae=>{w.current=ae},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":i["data-testid"],children:[O&&fe&&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"}),re&&e.jsx("span",{className:"nice-html-editor-ai__loading",children:E("htmlEditorAI.processing","Processing...")})]}),e.jsxs("div",{className:"nice-html-editor-ai__toolbar-right",children:[g&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>de(),disabled:re,title:E("htmlEditorAI.improveText","Improve selected text"),children:[e.jsx(v.oa,{name:"star",size:14})," ",E("htmlEditorAI.improve","Improve")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu",children:W.map(({style:ae,label:ee})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>de(ae),children:ee},ae))})]}),N&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:re,title:E("htmlEditorAI.translateText","Translate selected text"),children:[e.jsx(v.oa,{name:"globe",size:14})," ",E("htmlEditorAI.translate","Translate")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu nice-html-editor-ai__dropdown-menu--languages",children:P.map(({code:ae,label:ee})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>ue(ae),children:ee},ae))})]}),k&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>x(!0),disabled:re,title:E("htmlEditorAI.generateHtml","Generate HTML from description"),children:[e.jsx(v.oa,{name:"zap",size:14})," ",E("htmlEditorAI.generate","Generate")]})]})]}),e.jsx("div",{className:"nice-html-editor-ai__editor-wrapper",children:e.jsx(xt,{value:Q,onChange:B,toolbar:I,...Y})}),_&&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:[e.jsx(v.oa,{name:"star",size:16})," ",E("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:W.map(({style:ae,label:ee})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${y===ae?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{s(ae),de(ae)},children:ee},ae))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":E("htmlEditorAI.close","Close"),onClick:()=>H(!1),children:e.jsx(v.oa,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:re?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:E("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:E("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:h})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--improved",children:[e.jsx("h5",{children:E("htmlEditorAI.improved","Improved")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:D})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:te,disabled:!D||re,children:[e.jsx(v.oa,{name:"check",size:14})," ",E("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{H(!1),S("")},children:E("htmlEditorAI.cancel","Cancel")})]})]}),j&&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:[e.jsx(v.oa,{name:"globe",size:16})," ",E("htmlEditorAI.translateText","Translate Text")]}),e.jsx("div",{className:"nice-html-editor-ai__language-selector",children:e.jsx("select",{value:m,onChange:ae=>{c(ae.target.value),ue(ae.target.value)},className:"nice-html-editor-ai__language-select",children:P.map(({code:ae,label:ee})=>e.jsx("option",{value:ae,children:ee},ae))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":E("htmlEditorAI.close","Close"),onClick:()=>z(!1),children:e.jsx(v.oa,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:re?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:E("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:E("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:h})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--translated",children:[e.jsx("h5",{children:P.find(ae=>ae.code===m)?.label||m}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:L})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:ce,disabled:!L||re,children:[e.jsx(v.oa,{name:"check",size:14})," ",E("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{z(!1),C("")},children:E("htmlEditorAI.cancel","Cancel")})]})]}),$&&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:[e.jsx(v.oa,{name:"zap",size:16})," ",E("htmlEditorAI.generateHtml","Generate HTML")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":E("htmlEditorAI.close","Close"),onClick:()=>{x(!1),l(""),p("")},children:e.jsx(v.oa,{name:"close",size:14})})]}),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:E("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:u,onChange:ae=>p(ae.target.value),className:"nice-html-editor-ai__generate-textarea",rows:3}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__generate-btn",onClick:()=>je(u),disabled:re||!u.trim(),children:re?E("htmlEditorAI.generating","Generating..."):E("htmlEditorAI.generate","Generate")})]}),f&&e.jsxs("div",{className:"nice-html-editor-ai__generate-result",children:[e.jsx("h5",{children:E("htmlEditorAI.preview","Preview")}),e.jsx("div",{className:"nice-html-editor-ai__preview",dangerouslySetInnerHTML:{__html:f}}),e.jsx("h5",{children:E("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:f})]})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:me,disabled:!f||re,children:[e.jsx(v.oa,{name:"check",size:14})," ",E("htmlEditorAI.insert","Insert")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{x(!1),l(""),p("")},children:E("htmlEditorAI.cancel","Cancel")})]})]})]})}),rn=n.forwardRef(({length:t=6,value:i="",onChange:a,masked:o=!1,onComplete:d,label:g,helperText:N,error:k,required:I,disabled:P,readOnly:W,size:U="md",name:b,id:K,className:O,style:Q,autoFocus:B,labelPlacement:Y,errorPlacement:w,labelWidth:_,controlWidth:H,loading:j,cellWidth:z,...$},x)=>{const h=v.hc(K),M=n.useRef([]),D=i.padEnd(t,"").slice(0,t).split(""),S=n.useCallback(m=>{const c=Math.max(0,Math.min(t-1,m));M.current[c]?.focus()},[t]),y=n.useCallback(m=>{const c=m.join("");a?.(c),c.length===t&&c.indexOf("")===-1&&/^\d+$/.test(c)&&d?.(c)},[a,d,t]),s=n.useCallback((m,c)=>{const p=c.target.value.replace(/\D/g,"").slice(-1);if(!p)return;const f=[...D];f[m]=p,y(f),S(m+1)},[D,y,S]),L=n.useCallback((m,c)=>{if(c.key==="Backspace"){c.preventDefault();const u=[...D];D[m]?(u[m]="",y(u)):m>0&&(u[m-1]="",y(u),S(m-1))}else c.key==="ArrowLeft"?(c.preventDefault(),S(m-1)):c.key==="ArrowRight"&&(c.preventDefault(),S(m+1))},[D,y,S]),C=n.useCallback(m=>{m.preventDefault();const c=m.clipboardData.getData("text").replace(/\D/g,"").slice(0,t);if(!c)return;const u=c.padEnd(t,"").slice(0,t).split("");for(let p=c.length;p<t;p++)u[p]=D[p]||"";y(u),S(Math.min(c.length,t-1))},[t,D,y,S]);return e.jsxs("div",{className:`nice-field nice-field--${U} nice-field--otp${Y?` nice-field--label-${Y}`:""}${w==="right"?" nice-field--error-right":""} ${j?"nice-field--loading":""} ${O||""}`,style:{...Q,..._!=null&&{"--nice-field-label-width":typeof _=="number"?`${_}px`:_},...H!=null&&{"--nice-field-control-width":typeof H=="number"?`${H}px`:H},...z!=null&&{"--nice-otp-cell-width":typeof z=="number"?`${z}px`:z}},"aria-busy":j||void 0,...$,children:[g&&e.jsx("label",{htmlFor:`${h}-0`,className:`nice-field__label ${I?"nice-field__label--required":""}`,children:g}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:x,className:`nice-otp nice-otp--${U} ${k?"nice-otp--error":""} ${P?"nice-otp--disabled":""}`,onPaste:C,children:[Array.from({length:t},(m,c)=>e.jsx("input",{ref:u=>{M.current[c]=u},id:c===0?`${h}-0`:void 0,className:"nice-otp__digit",type:o?"password":"text",inputMode:"numeric",maxLength:2,value:D[c]||"",disabled:P,readOnly:W,autoFocus:B&&c===0,"aria-invalid":!!k,"aria-label":`${c+1}`,onChange:u=>s(c,u),onKeyDown:u=>L(c,u),onFocus:u=>u.target.select()},c)),b&&e.jsx("input",{type:"hidden",name:b,value:i})]}),w==="right"&&k&&e.jsx("div",{id:`${h}-error`,className:"nice-field__error",role:"alert",children:k}),w==="right"&&!k&&N&&e.jsx("div",{id:`${h}-helper`,className:"nice-field__helper",children:N}),j&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),w!=="right"&&k&&e.jsx("div",{id:`${h}-error`,className:"nice-field__error",role:"alert",children:k}),w!=="right"&&!k&&N&&e.jsx("div",{id:`${h}-helper`,className:"nice-field__helper",children:N})]})});rn.displayName="NiceInputOtp";const bi={xxs:36,xs:48,sm:64,md:80,lg:100,xl:128,xxl:160,small:64,medium:80,large:100},Qe=6,Xe=135,sn=405,Ve=sn-Xe;function ht(t,i,a,o){const d=(o-90)*(Math.PI/180);return{x:t+a*Math.cos(d),y:i+a*Math.sin(d)}}function Mt(t,i,a,o,d){const g=ht(t,i,a,o),N=ht(t,i,a,d),k=d-o>180?1:0;return`M ${g.x} ${g.y} A ${a} ${a} 0 ${k} 1 ${N.x} ${N.y}`}const cn=n.forwardRef(({value:t=0,onChange:i,min:a=0,max:o=100,step:d=1,showValue:g=!0,valueTemplate:N="{value}",label:k,helperText:I,error:P,required:W,disabled:U,readOnly:b,size:K="md",name:O,id:Q,className:B,style:Y,labelPlacement:w="top",errorPlacement:_,labelWidth:H,controlWidth:j,loading:z,isLabelCentered:$=!0,...x},h)=>{const M=v.hc(Q),D=n.useRef(!1),S=n.useRef(null),y=typeof K=="number"?K:bi[K],s=y/2,L=y/2,C=(y-Qe*2)/2,m=o>a?(t-a)/(o-a):0,c=Xe+m*Ve,u=n.useCallback(R=>{let J=R-Xe;J<0&&(J+=360),J>Ve&&(J=J-Ve<360-J?Ve:0);const A=Math.max(0,Math.min(1,J/Ve)),he=a+A*(o-a),re=Math.round(he/d)*d;return Math.max(a,Math.min(o,re))},[a,o,d]),p=n.useCallback(R=>{if(U||b)return;const J=S.current;if(!J)return;const A=J.getBoundingClientRect(),he=R.clientX-A.left-A.width/2,re=R.clientY-A.top-A.height/2;let fe=Math.atan2(he,-re)*(180/Math.PI);fe<0&&(fe+=360);const ne=u(fe);i?.(ne)},[u,U,b,i]);n.useEffect(()=>{const R=A=>{D.current&&p(A)},J=()=>{D.current=!1};return window.addEventListener("pointermove",R),window.addEventListener("pointerup",J),()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",J)}},[p]);const f=n.useCallback(R=>{if(U||b)return;let J=t;R.key==="ArrowUp"||R.key==="ArrowRight"?(R.preventDefault(),J=Math.min(o,t+d)):(R.key==="ArrowDown"||R.key==="ArrowLeft")&&(R.preventDefault(),J=Math.max(a,t-d)),J!==t&&i?.(J)},[t,i,a,o,d,U,b]),l=N.replace("{value}",String(t)),E=ht(s,L,C,c);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${_||"bottom"} nice-field--${typeof K=="string"?K:"md"} ${z?"nice-field--loading":""} ${B||""}`,style:{...Y,...H!=null&&{"--nice-field-label-width":typeof H=="number"?`${H}px`:H},...j!=null&&{"--nice-field-control-width":typeof j=="number"?`${j}px`:j}},"aria-busy":z||void 0,...x,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${w} ${$?"nice-knob-field--label-centered":""}`,children:[k&&e.jsx("label",{htmlFor:M,className:`nice-field__label ${W?"nice-field__label--required":""}`,children:k}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:R=>{S.current=R,typeof h=="function"?h(R):h&&(h.current=R)},className:`nice-knob nice-knob--${K} ${U?"nice-knob--disabled":""} ${P?"nice-knob--error":""}`,role:"slider",id:M,tabIndex:U?-1:0,"aria-valuenow":t,"aria-valuemin":a,"aria-valuemax":o,"aria-disabled":U,"aria-invalid":!!P,onPointerDown:R=>{U||b||(D.current=!0,p(R))},onKeyDown:f,children:[e.jsxs("svg",{width:y,height:y,viewBox:`0 0 ${y} ${y}`,children:[e.jsx("path",{d:Mt(s,L,C,Xe,sn),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:Qe,strokeLinecap:"round"}),m>0&&e.jsx("path",{d:Mt(s,L,C,Xe,c),fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:Qe,strokeLinecap:"round"}),e.jsx("circle",{cx:E.x,cy:E.y,r:Qe,fill:"var(--nice-primary, #3b82f6)"})]}),g&&e.jsx("span",{className:"nice-knob__value",children:l}),O&&e.jsx("input",{type:"hidden",name:O,value:t}),z&&e.jsx("span",{className:"nice-knob__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})})]}),P&&e.jsx("div",{className:"nice-field__error",role:"alert",children:P}),!P&&I&&e.jsx("div",{className:"nice-field__helper",children:I})]})});cn.displayName="NiceKnob";const ln=n.forwardRef(({value:t="",onChange:i,suggestions:a=[],onSearch:o,trigger:d="@",renderSuggestion:g,placeholder:N,rows:k=3,label:I,helperText:P,error:W,required:U,disabled:b,readOnly:K,size:O="md",name:Q,id:B,className:Y,style:w,..._},H)=>{const j=v.hc(B),[z,$]=n.useState(!1),[x,h]=n.useState(""),[M,D]=n.useState(0),[S,y]=n.useState({top:0,left:0}),s=n.useRef(null),L=n.useRef(-1),m=a.map(l=>typeof l=="string"?{key:l,label:l}:l).filter(l=>l.label.toLowerCase().includes(x.toLowerCase())),c=n.useCallback(()=>{$(!1),h(""),D(0),L.current=-1},[]),u=n.useCallback(l=>{const E=s.current;if(!E||L.current<0)return;const R=t.slice(0,L.current),J=t.slice(E.selectionStart),A=`${d}${l.label} `,he=R+A+J;i?.(he),c(),requestAnimationFrame(()=>{const re=R.length+A.length;E.setSelectionRange(re,re),E.focus()})},[t,i,d,c]),p=n.useCallback(l=>{const E=l.target.value;i?.(E);const R=l.target.selectionStart,J=E.slice(0,R),A=J.lastIndexOf(d);if(A>=0){const he=A>0?J[A-1]:" ",re=J.slice(A+d.length);if(/\s/.test(he)&&!/\s/.test(re)){L.current=A;const fe=re;h(fe),$(!0),D(0),o?.(fe);const ne=l.target,se=ne.getBoundingClientRect(),de=parseInt(getComputedStyle(ne).lineHeight)||20,ue=J.split(`
11
+ `);y({top:se.top+ue.length*de+4-ne.scrollTop,left:se.left+8});return}}c()},[i,d,o,c]),f=n.useCallback(l=>{!z||m.length===0||(l.key==="ArrowDown"?(l.preventDefault(),D(E=>(E+1)%m.length)):l.key==="ArrowUp"?(l.preventDefault(),D(E=>(E-1+m.length)%m.length)):l.key==="Enter"?(l.preventDefault(),m[M]&&u(m[M])):l.key==="Escape"&&c())},[z,m,M,u,c]);return n.useEffect(()=>{if(!z)return;const l=E=>{const R=s.current;R&&!R.contains(E.target)&&c()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[z,c]),e.jsxs("div",{className:`nice-field ${Y||""}`,style:w,..._,children:[I&&e.jsx("label",{htmlFor:j,className:`nice-field__label ${U?"nice-field__label--required":""}`,children:I}),e.jsxs("div",{className:`nice-mention nice-mention--${O} ${W?"nice-mention--error":""} ${b?"nice-mention--disabled":""}`,children:[e.jsx("textarea",{ref:l=>{s.current=l,typeof H=="function"?H(l):H&&(H.current=l)},id:j,name:Q,className:"nice-mention__input",value:t,onChange:p,onKeyDown:f,placeholder:N,rows:k,disabled:b,readOnly:K,"aria-invalid":!!W,"aria-describedby":W?`${j}-error`:P?`${j}-helper`:void 0,"aria-autocomplete":"list","aria-expanded":z}),z&&m.length>0&&e.jsx("ul",{className:"nice-mention__suggestions",role:"listbox",style:{position:"fixed",top:S.top,left:S.left},children:m.map((l,E)=>e.jsx("li",{role:"option","aria-selected":E===M,className:`nice-mention__suggestion ${E===M?"nice-mention__suggestion--active":""}`,onMouseDown:R=>{R.preventDefault(),u(l)},onMouseEnter:()=>D(E),children:g?g(l):e.jsxs(e.Fragment,{children:[l.icon&&e.jsx("span",{className:"nice-mention__suggestion-icon",children:l.icon}),e.jsx("span",{children:l.label})]})},l.key))})]}),W&&e.jsx("div",{id:`${j}-error`,className:"nice-field__error",role:"alert",children:W}),!W&&P&&e.jsx("div",{id:`${j}-helper`,className:"nice-field__helper",children:P})]})});ln.displayName="NiceMention";function ji(t){const i=[],a=o=>{for(const d of o)i.push(d),d.children&&a(d.children)};return a(t),i}function dn(t,i){const a=i.toLowerCase();return t.reduce((o,d)=>{const g=d.children?dn(d.children,i):[];return(d.label.toLowerCase().includes(a)||g.length>0)&&o.push({...d,children:g.length>0?g:d.children}),o},[])}const mn=({node:t,level:i,selectedKeys:a,expandedKeys:o,onToggleExpand:d,onSelect:g,selectableLeafsOnly:N,maxDepth:k})=>{const I=typeof k=="number"?Math.min(10,Math.max(1,k)):1/0,W=!(i+1>=I)&&t.children&&t.children.length>0,U=o.has(t.key),b=a.has(t.key),K=!W,O=!t.disabled&&(!N||K),Q=Math.min(i+1,10),B={paddingLeft:i*16+8,"--nice-row-bg":`var(--nice-tree-level-${Q}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${Q}-text, inherit)`,"--nice-row-hover-bg":`var(--nice-tree-level-${Q}-hover-bg, var(--bg-secondary, #f3f4f6))`,"--nice-row-active-bg":`var(--nice-tree-level-${Q}-active-bg, var(--nice-primary-tint-10, rgba(59,130,246,0.1)))`};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`nice-tree-select__node ${b?"nice-tree-select__node--selected":""} ${t.disabled?"nice-tree-select__node--disabled":""}`,style:B,"data-nice-depth":Q,onClick:()=>O&&g(t.key),role:"treeitem","aria-selected":b,"aria-expanded":W?U:void 0,"aria-disabled":t.disabled,children:[W?e.jsx("button",{type:"button",className:"nice-tree-select__toggle",onClick:Y=>{Y.stopPropagation(),d(t.key)},"aria-label":"Toggle",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",style:{transform:U?"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"}}),(t.icon==null,null),e.jsx("span",{className:"nice-tree-select__node-label",children:t.label})]}),W&&U&&t.children.map(Y=>e.jsx(mn,{node:Y,level:i+1,selectedKeys:a,expandedKeys:o,onToggleExpand:d,onSelect:g,selectableLeafsOnly:N,maxDepth:k},Y.key))]})},un=n.forwardRef(({nodes:t,value:i,onChange:a,multiple:o=!1,searchable:d=!1,placeholder:g,selectableLeafsOnly:N=!1,clearable:k=!1,maxDepth:I,label:P,helperText:W,error:U,required:b,disabled:K,readOnly:O,size:Q="md",name:B,id:Y,className:w,style:_,controlWidth:H,...j},z)=>{const{t:$}=v.Gt(),x=v.hc(Y),[h,M]=n.useState(!1),[D,S]=n.useState(""),[y,s]=n.useState(new Set),L=n.useRef(null);v.vc(L,()=>M(!1));const C=n.useMemo(()=>i==null?new Set:new Set(Array.isArray(i)?i:[i]),[i]),m=n.useMemo(()=>D?dn(t,D):t,[t,D]),c=n.useMemo(()=>{const l=ji(t);return Array.from(C).map(E=>l.find(R=>R.key===E)?.label).filter(Boolean)},[C,t]),u=n.useCallback(l=>{s(E=>{const R=new Set(E);return R.has(l)?R.delete(l):R.add(l),R})},[]),p=n.useCallback(l=>{if(o){const E=new Set(C);E.has(l)?E.delete(l):E.add(l),a?.(Array.from(E))}else a?.(l),M(!1)},[o,C,a]),f=n.useCallback(l=>{l.stopPropagation(),a?.(o?[]:"")},[a,o]);return e.jsxs("div",{className:`nice-field nice-field--${Q} ${w||""}`,style:{width:"fit-content",maxWidth:"100%",..._},...j,children:[P&&e.jsx("label",{htmlFor:x,className:`nice-field__label ${b?"nice-field__label--required":""}`,children:P}),e.jsxs("div",{ref:L,className:"nice-tree-select",style:{position:"relative",width:H!=null?typeof H=="number"?`${H}px`:H:240},children:[e.jsxs("div",{ref:z,id:x,className:`nice-input nice-input--${Q} ${U?"nice-input--error":""} ${K?"nice-input--disabled":""} ${O?"nice-input--readonly":""}`,role:"combobox","aria-expanded":h,"aria-haspopup":"tree","aria-invalid":!!U,tabIndex:K?-1:0,onClick:()=>!K&&!O&&M(!h),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),!K&&!O&&M(!h))},children:[e.jsx("span",{className:"nice-tree-select__display",children:c.length>0?c.join(", "):e.jsx("span",{className:"nice-tree-select__placeholder",children:g??$("controls.select","Select...")})}),k&&C.size>0&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:f,"aria-label":$("controls.clear","Clear"),children:e.jsx(v.oa,{name:"close",size:14})}),e.jsx("span",{className:"nice-tree-select__arrow",style:{transform:h?"rotate(180deg)":"none",transition:"transform 0.15s"},children:e.jsx(v.oa,{name:"chevron-down",size:14})})]}),h&&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:$("controls.search","Search..."),value:D,onChange:l=>S(l.target.value),autoFocus:!0,onClick:l=>l.stopPropagation()})}),e.jsx("div",{className:"nice-tree-select__list",children:m.length===0?e.jsx("div",{className:"nice-tree-select__empty",children:$("controls.noResults","No results")}):m.map(l=>e.jsx(mn,{node:l,level:0,selectedKeys:C,expandedKeys:y,onToggleExpand:u,onSelect:p,selectableLeafsOnly:N,maxDepth:I},l.key))})]})]}),B&&e.jsx("input",{type:"hidden",name:B,value:Array.isArray(i)?i.join(","):i??""}),U&&e.jsx("div",{id:`${x}-error`,className:"nice-field__error",role:"alert",children:U}),!U&&W&&e.jsx("div",{id:`${x}-helper`,className:"nice-field__helper",children:W})]})});un.displayName="NiceTreeSelect";function He(t,i){return String(t[i])}const pn=n.forwardRef(({source:t,target:i,onChange:a,keyField:o="id",labelField:d="label",renderItem:g,filterable:N=!1,searchable:k,groupBy:I,sortable:P=!1,bulkActions:W=!0,maxRight:U,sourceHeader:b,targetHeader:K,disabled:O=!1,size:Q="md",className:B,style:Y,id:w,..._},H)=>{const{t:j}=v.Gt(),[z,$]=n.useState(new Set),[x,h]=n.useState(new Set),[M,D]=n.useState(""),[S,y]=n.useState(""),s=n.useCallback((l,E,R)=>{E(J=>{const A=new Set(J);return A.has(R)?A.delete(R):A.add(R),A})},[]),L=n.useCallback(()=>{const l=t.filter(A=>z.has(He(A,o))),E=t.filter(A=>!z.has(He(A,o))),R=typeof U=="number"?l.slice(0,Math.max(0,U-i.length)):l,J=l.slice(R.length);a([...E,...J],[...i,...R]),$(new Set)},[t,i,z,o,a,U]),C=n.useCallback(()=>{const l=i.filter(R=>x.has(He(R,o))),E=i.filter(R=>!x.has(He(R,o)));a([...t,...l],E),h(new Set)},[t,i,x,o,a]),m=n.useCallback(()=>{if(typeof U=="number"){const l=Math.max(0,U-i.length),E=t.slice(0,l),R=t.slice(l);a(R,[...i,...E])}else a([],[...i,...t]);$(new Set)},[t,i,a,U]),c=n.useCallback(()=>{a([...t,...i],[]),h(new Set)},[t,i,a]),u=(l,E)=>{if(!E)return l;const R=E.toLowerCase();return l.filter(J=>String(J[d]).toLowerCase().includes(R))},p=W===!1?{moveAll:!1,removeAll:!1}:W===!0||W===void 0?{moveAll:!0,removeAll:!0}:{moveAll:W.moveAll??!0,removeAll:W.removeAll??!0},f=(l,E,R,J,A,he,re)=>{const fe=u(l,J),ne=k===!0||N&&k===void 0?"both":k??!1,se=ne==="both"||ne==="left"&&re==="left"||ne==="right"&&re==="right",de=(()=>{if(!I)return[{label:"",items:fe}];const te=new Map;for(const ce of fe){const me=String(I(ce));let ae=te.get(me);ae||(ae=[],te.set(me,ae)),ae.push(ce)}return[...te.entries()].map(([ce,me])=>({label:ce,items:me}))})(),ue=(te,ce)=>{te.dataTransfer.setData("text/plain",ce),te.dataTransfer.effectAllowed="move"},je=(te,ce)=>{te.preventDefault();const me=te.dataTransfer.getData("text/plain");if(!me||me===ce||re!=="right"||!P)return;const ae=[...i],ee=ae.findIndex(F=>He(F,o)===me),le=ae.findIndex(F=>He(F,o)===ce);if(ee===-1||le===-1)return;const[V]=ae.splice(ee,1);ae.splice(le,0,V),a(t,ae)};return e.jsxs("div",{className:"nice-picklist__panel",children:[he&&e.jsx("div",{className:"nice-picklist__header",children:he}),se&&e.jsx("div",{className:"nice-picklist__filter",children:e.jsx("input",{className:"nice-input__native",type:"text",placeholder:j("controls.search","Search..."),value:J,onChange:te=>A(te.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true",children:[de.map(te=>e.jsxs(n.Fragment,{children:[te.label&&e.jsx("div",{className:"nice-picklist__group-header",role:"presentation",children:te.label}),te.items.map(ce=>{const me=He(ce,o),ae=E.has(me);return e.jsx("div",{className:`nice-picklist__item ${ae?"nice-picklist__item--selected":""}`,role:"option","aria-selected":ae,draggable:P&&re==="right",onDragStart:P&&re==="right"?ee=>ue(ee,me):void 0,onDragOver:P&&re==="right"?ee=>ee.preventDefault():void 0,onDrop:P&&re==="right"?ee=>je(ee,me):void 0,onClick:()=>!O&&s(E,R,me),children:g?g(ce,re):String(ce[d])},me)})]},te.label||"__none__")),fe.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:j("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:H,id:w,className:`nice-picklist nice-picklist--${Q} ${O?"nice-picklist--disabled":""} ${B||""}`,style:Y,..._,children:[f(t,z,$,M,D,b??j("picklist.source","Available"),"left"),e.jsxs("div",{className:"nice-picklist__controls",children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:O||z.size===0,onClick:L,"aria-label":j("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"})})}),p.moveAll&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:O||t.length===0,onClick:m,"aria-label":j("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:O||x.size===0,onClick:C,"aria-label":j("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"})})}),p.removeAll&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:O||i.length===0,onClick:c,"aria-label":j("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"})]})})]}),f(i,x,h,S,y,K??j("picklist.target","Selected"),"right")]})});pn.displayName="NicePickList";const vi=[{target:".nice-code-editor-wrap",titleKey:"tutorial.codeEditor.intro.title",title:"Code editor",contentKey:"tutorial.codeEditor.intro.content",content:"Edit code with syntax highlighting, IntelliSense and the toolbar. Ctrl+S saves; the status bar shows the cursor position and any problems.",placement:"auto"}];let Fe=null,Ge=null;const _i="0.45.0",ot=`https://cdn.jsdelivr.net/npm/monaco-editor@${_i}/min/vs`,$t=15e3;function Et(){const t=window;if(t.MonacoEnvironment?.getWorkerUrl)return;const i=`self.MonacoEnvironment={baseUrl:'${ot}/'};importScripts('${ot}/base/worker/workerMain.js');`,a=URL.createObjectURL(new Blob([i],{type:"text/javascript"}));t.MonacoEnvironment={getWorkerUrl:()=>a}}function Be(t){if(t!=="auto")return t;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 hn(){return Ge?Promise.resolve(Ge):Fe||(Fe=new Promise((t,i)=>{if(window.monaco){Et(),Ge=window.monaco,t(Ge);return}let a=!1;const o=window.setTimeout(()=>{a||(a=!0,Fe=null,i(new Error(`Monaco editor failed to load within ${$t}ms`)))},$t),d=document.createElement("script");d.src=`${ot}/loader.min.js`,d.async=!0,d.onload=()=>{const g=window.require;g.config({paths:{vs:ot}}),Et(),g(["vs/editor/editor.main"],N=>{a||(a=!0,window.clearTimeout(o),Ge=N,t(N))})},d.onerror=()=>{a||(a=!0,window.clearTimeout(o),Fe=null,i(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(d)}),Fe)}const Ze=n.forwardRef(function(i,a){const{value:o,onChange:d,language:g="plaintext",theme:N="auto",options:k={},height:I=400,width:P="100%",markers:W=[],decorations:U=[],completionProvider:b,onMount:K,onCursorPositionChange:O,onSelectionChange:Q,onSave:B,loading:Y,disabled:w=!1,showToolbar:_=!1,showStatusBar:H=!1,editorSize:j="standard",className:z,"data-testid":$,lsp:x,extraLibs:h,tutorial:M}=i,D=n.useRef(null),S=n.useRef(null),y=n.useRef(null),s=n.useRef([]),L=n.useRef(null),[C,m]=n.useState(!0),[c,u]=n.useState(null),[p,f]=n.useState({lineNumber:1,column:1}),[l,E]=n.useState(""),[R,J]=n.useState(k.wordWrap==="on"),A=n.useMemo(()=>({automaticLayout:!0,readOnly:w||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,w]);n.useEffect(()=>{if(!D.current)return;let ne=!0;return hn().then(async se=>{if(!ne||!D.current)return;y.current=se;const de=se.editor.create(D.current,{value:o,language:g,theme:Be(N),...A});if(S.current=de,m(!1),de.onDidChangeModelContent(()=>{const ue=de.getValue();d?.(ue)}),de.onDidChangeCursorPosition(ue=>{f({lineNumber:ue.position.lineNumber,column:ue.position.column}),O?.({lineNumber:ue.position.lineNumber,column:ue.position.column})}),de.onDidChangeCursorSelection(ue=>{const je=ue.selection,te=de.getModel()?.getValueInRange(je)??"";E(te),Q?.({startLineNumber:je.startLineNumber,startColumn:je.startColumn,endLineNumber:je.endLineNumber,endColumn:je.endColumn})}),de.addCommand(se.KeyMod.CtrlCmd|se.KeyCode.KeyS,()=>{B?.(de.getValue())}),x&&typeof window<"u")try{await rt("https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"),await rt("https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js");const ue=window,je=ue.ReconnectingWebSocket,{MonacoLanguageClient:te,CloseAction:ce,ErrorAction:me,createConnection:ae}=ue.monacoLanguageClient||{};if(te&&ae){const ee=x.url,le=x.language,V=new je(ee),F=new ue.VSCodeWebSocketMessageReader(V),X=new ue.VSCodeWebSocketMessageWriter(V),Z=ae(F,X),q=new te({name:"LSP Client",clientOptions:{documentSelector:[le],initializationOptions:x.initOptions,errorHandler:{error:()=>me.Continue,closed:()=>ce.Restart}},connectionProvider:{get:()=>Promise.resolve(Z)}});q.start(),S.current.__lspClient=q}}catch(ue){console.warn("LSP bridge failed to load:",ue)}K?.(de,se)}).catch(se=>{ne&&(u(se.message??"Failed to load editor"),m(!1))}),()=>{if(ne=!1,S.current?.dispose(),L.current?.dispose(),S.current&&S.current.__lspClient)try{S.current.__lspClient.stop()}catch{}}},[x]),n.useEffect(()=>{const ne=S.current;if(ne&&o!==ne.getValue()){const se=ne.getPosition();ne.setValue(o),se&&ne.setPosition(se)}},[o]),n.useEffect(()=>{const ne=S.current,se=y.current;if(ne&&se){const de=ne.getModel();de&&se.editor.setModelLanguage(de,g)}},[g]),n.useEffect(()=>{const ne=y.current;if(!ne||C||!h||h.length===0||g!=="javascript"&&g!=="typescript")return;const se=ne.languages?.typescript;if(!se)return;const de=[];try{h.forEach((ue,je)=>{const te=ue.filePath??`inmemory://model/nice-extralib-${je}.d.ts`,ce=se.typescriptDefaults?.addExtraLib(ue.content,te);ce&&de.push(ce);const me=se.javascriptDefaults?.addExtraLib(ue.content,te);me&&de.push(me)})}catch(ue){console.warn("Failed to register extraLibs:",ue)}return()=>{de.forEach(ue=>{try{ue.dispose()}catch{}})}},[h,g,C]),n.useEffect(()=>{const ne=y.current;if(!ne||(ne.editor.setTheme(Be(N)),N!=="auto"||typeof document>"u"))return;const se=()=>{y.current?.editor.setTheme(Be("auto"))},de=new MutationObserver(se);de.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const ue=window.matchMedia?.("(prefers-color-scheme: dark)");return ue?.addEventListener?.("change",se),()=>{de.disconnect(),ue?.removeEventListener?.("change",se)}},[N]),n.useEffect(()=>{const ne=S.current;ne&&ne.updateOptions(A)},[A]),n.useEffect(()=>{const ne=S.current,se=y.current;if(ne&&se){const de=ne.getModel();if(de){const ue=W.map(je=>({startLineNumber:je.startLineNumber,startColumn:je.startColumn,endLineNumber:je.endLineNumber,endColumn:je.endColumn,message:je.message,severity:je.severity}));se.editor.setModelMarkers(de,"owner",ue)}}},[W]),n.useEffect(()=>{const ne=S.current;if(ne&&U.length>0){const se=U.map(de=>({range:{startLineNumber:de.range.startLineNumber,startColumn:de.range.startColumn,endLineNumber:de.range.endLineNumber,endColumn:de.range.endColumn},options:{className:de.className,glyphMarginClassName:de.glyphMarginClassName,hoverMessage:de.hoverMessage?{value:de.hoverMessage}:void 0,isWholeLine:de.isWholeLine}}));s.current=ne.deltaDecorations(s.current,se)}},[U]),n.useEffect(()=>{const ne=y.current;if(!ne||!b)return;L.current?.dispose();const se={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 L.current=ne.languages.registerCompletionItemProvider(g,{provideCompletionItems:async(de,ue)=>({suggestions:(await b(de,ue)).map(te=>({label:te.label,kind:se[te.kind]??0,insertText:te.insertText,insertTextRules:te.insertTextRules==="insertAsSnippet"?4:void 0,documentation:te.documentation,detail:te.detail,range:{startLineNumber:ue.lineNumber,startColumn:ue.column,endLineNumber:ue.lineNumber,endColumn:ue.column}}))})}),()=>{L.current?.dispose()}},[g,b]),n.useImperativeHandle(a,()=>({getEditor:()=>S.current,getMonaco:()=>y.current,focus:()=>S.current?.focus(),getValue:()=>S.current?.getValue()??"",setValue:ne=>S.current?.setValue(ne),getSelection:()=>{const ne=S.current;if(!ne)return"";const se=ne.getSelection();return se?ne.getModel()?.getValueInRange(se)??"":""},insertText:ne=>{const se=S.current;if(!se)return;const de=se.getSelection();de&&se.executeEdits("",[{range:de,text:ne}])},formatDocument:()=>{S.current?.getAction("editor.action.formatDocument")?.run()},goToLine:(ne,se=1)=>{const de=S.current;de&&(de.setPosition({lineNumber:ne,column:se}),de.revealLineInCenter(ne),de.focus())},findReplace:()=>{S.current?.getAction("editor.action.startFindReplaceAction")?.run()},undo:()=>{S.current?.trigger("keyboard","undo",null)},redo:()=>{S.current?.trigger("keyboard","redo",null)},getCursorPosition:()=>{const ne=S.current?.getPosition();return{lineNumber:ne?.lineNumber??1,column:ne?.column??1}},setMarkers:ne=>{const se=S.current,de=y.current;if(se&&de){const ue=se.getModel();if(ue){const je=ne.map(te=>({startLineNumber:te.startLineNumber,startColumn:te.startColumn,endLineNumber:te.endLineNumber,endColumn:te.endColumn,message:te.message,severity:te.severity}));de.editor.setModelMarkers(ue,"owner",je)}}}}),[]);const he=n.useMemo(()=>({format:()=>S.current?.getAction("editor.action.formatDocument")?.run(),undo:()=>S.current?.trigger("keyboard","undo",null),redo:()=>S.current?.trigger("keyboard","redo",null),find:()=>S.current?.getAction("editor.action.startFindReplaceAction")?.run(),toggleWordWrap:()=>{const ne=!R;J(ne),S.current?.updateOptions({wordWrap:ne?"on":"off"})},toggleMinimap:()=>{const ne=S.current?.getOption?.(y.current?.editor?.EditorOption?.minimap);S.current?.updateOptions({minimap:{enabled:!ne?.enabled}})},foldAll:()=>S.current?.getAction("editor.foldAll")?.run(),unfoldAll:()=>S.current?.getAction("editor.unfoldAll")?.run()}),[R]),re=o.split(`
12
+ `).length,fe=o.length;return e.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${j} ${z??""}`,style:{height:I,width:P,display:"flex",flexDirection:"column",position:"relative"},"data-testid":$,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Yl,{steps:v.Jl(M,vi)})}),c&&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:[e.jsx(v.oa,{name:"warning",size:16})," ",c]}),e.jsx("textarea",{value:o,onChange:ne=>d?.(ne.target.value),readOnly:w||k.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),C&&!c&&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:Y??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:he.undo,title:"Undo (Ctrl+Z)","aria-label":"Undo",children:e.jsx(v.oa,{name:"reply",size:16})}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:he.redo,title:"Redo (Ctrl+Y)","aria-label":"Redo",children:e.jsx(v.oa,{name:"forward",size:16})}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:he.format,title:"Format (Shift+Alt+F)","aria-label":"Format",children:e.jsx(v.oa,{name:"type",size:16})}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:he.find,title:"Find & Replace (Ctrl+H)","aria-label":"Find & Replace",children:e.jsx(v.oa,{name:"search",size:16})}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:`nice-code-editor__toolbar-btn${R?" nice-code-editor__toolbar-btn--active":""}`,onClick:he.toggleWordWrap,title:"Toggle Word Wrap","aria-label":"Toggle Word Wrap",children:e.jsx(v.oa,{name:"align-left",size:16})}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:he.toggleMinimap,title:"Toggle Minimap","aria-label":"Toggle Minimap",children:e.jsx(v.oa,{name:"columns",size:16})}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:he.foldAll,title:"Fold All","aria-label":"Fold All",children:e.jsx(v.oa,{name:"collapse",size:16})}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:he.unfoldAll,title:"Unfold All","aria-label":"Unfold All",children:e.jsx(v.oa,{name:"expand",size:16})})]}),e.jsx("div",{ref:D,className:"nice-code-editor",style:{flex:1,minHeight:0}}),H&&e.jsxs("div",{className:"nice-code-editor__statusbar",children:[e.jsxs("span",{children:["Ln ",p.lineNumber,", Col ",p.column]}),l.length>0&&e.jsxs("span",{children:["(",l.length," selected)"]}),e.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),e.jsxs("span",{children:[re," lines · ",fe," chars"]}),e.jsx("span",{className:"nice-code-editor__statusbar-lang",children:g}),W.length>0&&e.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:[e.jsx(v.oa,{name:"warning",size:14})," ",W.length]})]})]})});function gn(t){const{original:i,modified:a,language:o="plaintext",theme:d="auto",height:g=400,width:N="100%",inline:k=!1,renderSideBySide:I=!0,originalEditable:P=!1,modifiedEditable:W=!1,onOriginalChange:U,onModifiedChange:b,loading:K,className:O,"data-testid":Q}=t,B=n.useRef(null),Y=n.useRef(null),w=n.useRef(null),[_,H]=n.useState(!0),[j,z]=n.useState(null);return n.useEffect(()=>{if(!B.current)return;let $=!0;return hn().then(x=>{if(!$||!B.current)return;w.current=x;const h=x.editor.createModel(i,o),M=x.editor.createModel(a,o),D=x.editor.createDiffEditor(B.current,{automaticLayout:!0,theme:Be(d),renderSideBySide:!k&&I,originalEditable:P,readOnly:!W});D.setModel({original:h,modified:M}),Y.current=D,H(!1),P&&h.onDidChangeContent(()=>{U?.(h.getValue())}),W&&M.onDidChangeContent(()=>{b?.(M.getValue())})}).catch(x=>{$&&(z(x.message??"Failed to load diff editor"),H(!1))}),()=>{$=!1,Y.current?.dispose()}},[]),n.useEffect(()=>{const $=Y.current;if(!$)return;const x=$.getModel();x&&(x.original.getValue()!==i&&x.original.setValue(i),x.modified.getValue()!==a&&x.modified.setValue(a))},[i,a]),n.useEffect(()=>{const $=w.current;if(!$||($.editor.setTheme(Be(d)),d!=="auto"||typeof document>"u"))return;const x=()=>{w.current?.editor.setTheme(Be("auto"))},h=new MutationObserver(x);h.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const M=window.matchMedia?.("(prefers-color-scheme: dark)");return M?.addEventListener?.("change",x),()=>{h.disconnect(),M?.removeEventListener?.("change",x)}},[d,_]),j?e.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${O??""}`,style:{height:g,width:N},"data-testid":Q,children:e.jsx("div",{className:"nice-code-editor__error",children:e.jsxs("span",{children:[e.jsx(v.oa,{name:"warning",size:16})," ",j]})})}):e.jsxs("div",{className:`nice-code-diff-editor ${O??""}`,style:{height:g,width:N,position:"relative"},"data-testid":Q,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:K??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading diff editor..."})})]})}const ki="1.29.0",Tt=`https://cdn.jsdelivr.net/npm/prismjs@${ki}`;let lt=null;const gt={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 rt(t){return new Promise((i,a)=>{if(document.querySelector(`script[data-prism-src="${t}"]`)){i();return}const o=document.createElement("script");o.src=t,o.async=!0,o.dataset.prismSrc=t,o.onload=()=>i(),o.onerror=()=>a(new Error(`Failed to load ${t}`)),document.head.appendChild(o)})}function wi(t){if(typeof window>"u")return Promise.resolve(null);const i=window,a=gt[t]??"plain",o=async()=>{if(a!=="plain"&&!i.Prism?.languages?.[a])try{await rt(`${Tt}/components/prism-${a}.min.js`)}catch{}};return i.Prism?.languages?o().then(()=>i.Prism):(lt||(lt=(async()=>(window.Prism={manual:!0},await rt(`${Tt}/prism.min.js`),window.Prism))()),lt.then(async()=>(await o(),window.Prism)))}function dt(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function fn(t){const{value:i,onChange:a,language:o="plaintext",height:d=300,width:g="100%",readOnly:N=!1,tabSize:k=2,lineNumbers:I=!0,placeholder:P,theme:W="auto",className:U,"data-testid":b}=t,K=n.useRef(null),O=n.useRef(null),[Q,B]=n.useState(()=>dt(i)),[Y,w]=n.useState("light");n.useEffect(()=>{const x=()=>{if(W!=="auto")return W;if(typeof document>"u")return"light";const S=document.documentElement.dataset.theme;return S==="dark"?"dark":S==="light"?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};if(w(x()),W!=="auto"||typeof document>"u")return;const h=()=>w(x()),M=new MutationObserver(h);M.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const D=window.matchMedia?.("(prefers-color-scheme: dark)");return D?.addEventListener?.("change",h),()=>{M.disconnect(),D?.removeEventListener?.("change",h)}},[W]),n.useEffect(()=>{let x=!0;return wi(o).then(h=>{if(!x)return;const M=gt[o]??"plain";if(h?.languages?.[M])try{const D=h.highlight(i,h.languages[M],M);B(D);return}catch{}B(dt(i))}).catch(()=>{x&&B(dt(i))}),()=>{x=!1}},[i,o]);const _=n.useCallback(()=>{!O.current||!K.current||(O.current.scrollTop=K.current.scrollTop,O.current.scrollLeft=K.current.scrollLeft)},[]),H=n.useCallback(x=>{if(x.key==="Tab"){x.preventDefault();const h=x.currentTarget,M=h.selectionStart,D=h.selectionEnd,S=" ".repeat(k);if(x.shiftKey){const L=i.substring(0,M).lastIndexOf(`
13
+ `)+1;if((i.substring(L,M).match(/^(\s*)/)?.[1]??"").length>=k){const m=i.substring(0,L)+i.substring(L+k);a?.(m),setTimeout(()=>{h.selectionStart=h.selectionEnd=M-k},0)}}else{const y=i.substring(0,M)+S+i.substring(D);a?.(y),setTimeout(()=>{h.selectionStart=h.selectionEnd=M+k},0)}}},[i,a,k]),z=i.split(`
14
+ `).length,$=gt[o]??"plain";return e.jsxs("div",{className:`nice-simple-code-editor nice-simple-code-editor--${Y} ${U??""}`,style:{height:d,width:g},"data-testid":b,"data-language":o,"data-theme":Y,children:[I&&e.jsx("div",{className:"nice-simple-code-editor__line-numbers",children:Array.from({length:z},(x,h)=>e.jsx("div",{className:"nice-simple-code-editor__line-number",children:h+1},h))}),e.jsxs("div",{className:"nice-simple-code-editor__editor-area",children:[e.jsx("pre",{ref:O,"aria-hidden":"true",className:`nice-simple-code-editor__highlight language-${$}`,children:e.jsx("code",{className:`language-${$}`,dangerouslySetInnerHTML:{__html:Q+(i.endsWith(`
15
+ `)?`
16
+ `:"")}})}),e.jsx("textarea",{ref:K,className:"nice-simple-code-editor__textarea",value:i,onChange:x=>a?.(x.target.value),onKeyDown:H,onScroll:_,readOnly:N,placeholder:P,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"})]})]})}const Rt="nice-code-editor-styles";if(typeof document<"u"&&!document.getElementById(Rt)){const t=document.createElement("style");t.id=Rt,t.textContent=`
17
+ .nice-code-editor,
18
+ .nice-code-diff-editor {
19
+ border: 1px solid var(--nice-border, #e0e0e0);
20
+ border-radius: var(--nice-radius-sm, 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: var(--nice-space-2, 8px);
44
+ gap: var(--nice-space-2, 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: var(--nice-radius-sm, 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: var(--nice-bg, #1e1e1e);
65
+ color: var(--nice-text, #d4d4d4);
66
+ }
67
+
68
+ .nice-simple-code-editor__line-numbers {
69
+ padding: var(--nice-space-2, 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: var(--nice-bg-secondary, #252526);
79
+ border-right-color: var(--nice-border, #3c3c3c);
80
+ color: var(--nice-text-muted, #858585);
81
+ }
82
+
83
+ .nice-simple-code-editor__line-number {
84
+ padding: 0 var(--nice-space-3, 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: var(--nice-space-2, 8px) var(--nice-space-3, 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: var(--nice-text, #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: var(--nice-text-muted, #858585);
136
+ -webkit-text-fill-color: var(--nice-text-muted, #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: var(--nice-danger, #d73a49); }
162
+ .nice-simple-code-editor .token.atrule,
163
+ .nice-simple-code-editor .token.attr-value,
164
+ .nice-simple-code-editor .token.keyword { color: var(--nice-danger, #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: var(--nice-success, #6a9955); font-style: italic; }
175
+ .nice-simple-code-editor--dark .token.punctuation { color: var(--nice-text, #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: var(--nice-success-light, #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: var(--nice-warning, #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: var(--nice-primary, #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: var(--nice-radius-sm, 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: var(--nice-space-0-5, 2px);
215
+ padding: var(--nice-space-0-75, 3px) var(--nice-space-1-5, 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: var(--nice-radius-sm, 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: var(--nice-bg, #FFF);
240
+ }
241
+ .nice-code-editor__toolbar-sep {
242
+ width: 1px;
243
+ height: 18px;
244
+ background: var(--nice-border, #e0e0e0);
245
+ margin: 0 var(--nice-space-1, 4px);
246
+ }
247
+
248
+ /* Status bar */
249
+ .nice-code-editor__statusbar {
250
+ display: flex;
251
+ align-items: center;
252
+ gap: var(--nice-space-3, 12px);
253
+ padding: var(--nice-space-0-5, 2px) var(--nice-space-2-5, 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(t)}const Ni=Object.freeze(Object.defineProperty({__proto__:null,NiceCodeDiffEditor:gn,NiceCodeEditor:Ze,NiceSimpleCodeEditor:fn},Symbol.toStringTag,{value:"Module"})),Ci=n.forwardRef(function(i,a){const{enableAI:o=!0,aiModel:d,enableInlineCompletion:g=!0,completionDelay:N=500,enableExplain:k=!0,enableRefactor:I=!0,enableGenerate:P=!0,systemPrompt:W,onExplain:U,onRefactor:b,showAIToolbar:K=!0,aiShortcutKey:O="Ctrl",language:Q="plaintext",value:B,onChange:Y,...w}=i,_=n.useRef(null),[H,j]=n.useState(null),[z,$]=n.useState(!1),[x,h]=n.useState(""),[M,D]=n.useState(!1),[S,y]=n.useState(""),[s,L]=n.useState(""),[C,m]=n.useState(""),c=n.useRef(),{t:u}=v.Gt(),p=v.he(),{complete:f,explain:l,refactor:E,generateFromComment:R,isLoading:J}=v.xd({language:Q,model:d}),A=o&&p.isConfigured,he=n.useCallback(async()=>{if(!A||!g||!_.current||!_.current.getEditor())return;const ce=_.current.getCursorPosition(),ae=_.current.getValue().split(`
271
+ `),ee=ae.slice(0,ce.lineNumber-1),le=ae[ce.lineNumber-1]||"",V=[...ee,le.slice(0,ce.column-1)].join(`
272
+ `),F=[le.slice(ce.column-1),...ae.slice(ce.lineNumber)].join(`
273
+ `);try{const X=await f(V,F);X&&j({lineNumber:ce.lineNumber,column:ce.column,text:X})}catch{}},[A,g,f]),re=n.useCallback(async()=>{if(!A||!k||!_.current)return"";const te=_.current.getSelection();if(!te)return"";m(te),$(!0),h("");try{const ce=await l(te);return h(ce),U?.(te,ce),ce}catch{return h(u("codeEditorAI.explanationFailed","Failed to explain code")),""}},[A,k,l,U,u]),fe=n.useCallback(async te=>{if(!A||!I||!_.current)return"";const ce=_.current.getSelection();if(!ce)return"";try{const me=await E(ce,te);return L(me),b?.(ce,me),me}catch{return""}},[A,I,E,b]),ne=n.useCallback(async()=>{if(!A||!P||!_.current)return;const te=_.current.getCursorPosition(),me=_.current.getValue().split(`
274
+ `);let ae="";for(let ee=te.lineNumber-1;ee>=0&&ee>=te.lineNumber-3;ee--){const le=me[ee]?.trim()||"";if(le.startsWith("//")||le.startsWith("#")||le.startsWith("/*")||le.startsWith("*")){ae=le.replace(/^\/\/\s*|^#\s*|^\/\*\s*|\*\/\s*$|^\*\s*/g,"").trim();break}}if(ae)try{const ee=await R(ae);ee&&_.current&&_.current.insertText(`
275
+ `+ee)}catch{}},[A,P,R]),se=n.useCallback(()=>{!H||!_.current||(_.current.insertText(H.text),j(null))},[H]),de=n.useCallback(()=>{j(null)},[]),ue=n.useCallback(te=>{i.onCursorPositionChange?.(te),!(!A||!g)&&(c.current&&clearTimeout(c.current),j(null),c.current=setTimeout(()=>{he()},N))},[i.onCursorPositionChange,A,g,N,he]);n.useEffect(()=>{if(!_.current?.getEditor()||!A)return;const ce=me=>{if(O==="Ctrl"&&me.ctrlKey||O==="Alt"&&me.altKey||O==="Meta"&&me.metaKey){if(me.key===" "&&g&&(me.preventDefault(),he()),me.key==="e"&&k&&(me.preventDefault(),re()),me.key==="r"&&I){me.preventDefault();const ee=_.current?.getSelection();ee&&(m(ee),D(!0))}me.key==="g"&&P&&(me.preventDefault(),ne())}me.key==="Tab"&&H&&(me.preventDefault(),se()),me.key==="Escape"&&H&&de()};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[A,O,g,k,I,P,he,re,ne,H,se,de]),n.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const je=n.useCallback(()=>{if(!s||!_.current)return;const te=_.current.getEditor();if(te?.executeEdits&&te?.getSelection){const ce=te.getSelection();te.executeEdits("ai-refactor",[{range:ce,text:s}])}D(!1),L(""),y("")},[s]);return n.useImperativeHandle(a,()=>({..._.current,getEditor:()=>_.current?.getEditor(),getMonaco:()=>_.current?.getMonaco(),focus:()=>_.current?.focus(),getValue:()=>_.current?.getValue()||"",setValue:te=>_.current?.setValue(te),getSelection:()=>_.current?.getSelection()||"",insertText:te=>_.current?.insertText(te),formatDocument:()=>_.current?.formatDocument(),goToLine:(te,ce)=>_.current?.goToLine(te,ce),findReplace:()=>_.current?.findReplace(),undo:()=>_.current?.undo(),redo:()=>_.current?.redo(),getCursorPosition:()=>_.current?.getCursorPosition()||{lineNumber:1,column:1},setMarkers:te=>_.current?.setMarkers(te),triggerCompletion:he,explainSelection:re,refactorSelection:fe,generateFromComment:ne,acceptCompletion:se,dismissCompletion:de})),e.jsxs("div",{className:"nice-code-editor-ai","data-testid":i["data-testid"],children:[K&&A&&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"}),J&&e.jsx("span",{className:"nice-code-editor-ai__loading",children:u("codeEditorAI.loading","Thinking...")})]}),e.jsxs("div",{className:"nice-code-editor-ai__toolbar-right",children:[g&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>he(),disabled:J,title:`${u("codeEditorAI.complete","Complete")} (${O}+Space)`,children:[e.jsx(v.oa,{name:"lightbulb",size:14})," ",u("codeEditorAI.complete","Complete")]}),k&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>re(),disabled:J,title:`${u("codeEditorAI.explain","Explain")} (${O}+E)`,children:[e.jsx(v.oa,{name:"book",size:14})," ",u("codeEditorAI.explain","Explain")]}),I&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>{const te=_.current?.getSelection();te&&(m(te),D(!0))},disabled:J,title:`${u("codeEditorAI.refactor","Refactor")} (${O}+R)`,children:[e.jsx(v.oa,{name:"settings",size:14})," ",u("codeEditorAI.refactor","Refactor")]}),P&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>ne(),disabled:J,title:`${u("codeEditorAI.generate","Generate")} (${O}+G)`,children:[e.jsx(v.oa,{name:"zap",size:14})," ",u("codeEditorAI.generate","Generate")]})]})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx(Ze,{ref:_,value:B,onChange:Y,language:Q,onCursorPositionChange:ue,...w}),H&&e.jsxs("div",{className:"nice-code-editor-ai__ghost-text",style:{top:`calc(${(H.lineNumber-1)*19}px + 4px)`,left:`calc(${(H.column-1)*7.8}px + 60px)`},children:[e.jsx("span",{className:"nice-code-editor-ai__ghost-text-content",children:H.text}),e.jsxs("span",{className:"nice-code-editor-ai__ghost-text-hint",children:["Tab ",u("codeEditorAI.toAccept","to accept")]})]})]}),z&&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:[e.jsx(v.oa,{name:"book",size:16})," ",u("codeEditorAI.explanation","Explanation")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>$(!1),"aria-label":u("codeEditorAI.close","Close"),children:e.jsx(v.oa,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-code-editor-ai__panel-body",children:J?e.jsx("div",{className:"nice-code-editor-ai__panel-loading",children:u("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:C}),e.jsx("div",{className:"nice-code-editor-ai__explanation-text",children:x||u("codeEditorAI.noExplanation","Select code and click Explain")})]})})]}),M&&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:[e.jsx(v.oa,{name:"settings",size:16})," ",u("codeEditorAI.refactorCode","Refactor Code")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>{D(!1),L(""),y("")},"aria-label":u("codeEditorAI.close","Close"),children:e.jsx(v.oa,{name:"close",size:14})})]}),e.jsxs("div",{className:"nice-code-editor-ai__panel-body",children:[e.jsx("pre",{className:"nice-code-editor-ai__code-preview",children:C}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-input",children:[e.jsx("input",{type:"text",placeholder:u("codeEditorAI.refactorInstruction",'Describe how to refactor (e.g., "extract function", "add error handling")'),value:S,onChange:te=>y(te.target.value),onKeyDown:te=>{te.key==="Enter"&&S&&fe(S)}}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactor-btn",onClick:()=>fe(S),disabled:J||!S,children:J?u("codeEditorAI.refactoring","Refactoring..."):u("codeEditorAI.refactor","Refactor")})]}),s&&e.jsxs("div",{className:"nice-code-editor-ai__refactor-result",children:[e.jsx("h5",{children:u("codeEditorAI.refactoredCode","Refactored Code")}),e.jsx("pre",{className:"nice-code-editor-ai__code-preview nice-code-editor-ai__code-preview--result",children:s}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-actions",children:[e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-apply",onClick:je,children:[e.jsx(v.oa,{name:"check",size:14})," ",u("codeEditorAI.apply","Apply")]}),e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-discard",onClick:()=>{L(""),y("")},children:[e.jsx(v.oa,{name:"close",size:14})," ",u("codeEditorAI.discard","Discard")]})]})]})]})]})]})});function Si(t){const i=t instanceof Date?t:new Date(t),a=(o,d=2)=>String(o).padStart(d,"0");return`${a(i.getHours())}:${a(i.getMinutes())}:${a(i.getSeconds())}.${a(i.getMilliseconds(),3)}`}function Mi(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const yn=n.forwardRef(function(i,a){const{entries:o,maxHeight:d=240,autoScroll:g=!0,showTimestamps:N=!0,levelFilter:k,onClear:I,title:P,emptyText:W="No output",clearLabel:U="Clear",fontFamily:b,className:K,style:O,id:Q,"data-testid":B}=i,Y=n.useRef(null),w=n.useMemo(()=>{if(!k||k.length===0)return o;const j=new Set(k);return o.filter(z=>j.has(z.level??"log"))},[o,k]);n.useEffect(()=>{g&&Y.current&&(Y.current.scrollTop=Y.current.scrollHeight)},[w.length,g]);const _=!!P||!!I,H="nice-log-console"+(K?` ${K}`:"");return e.jsxs("div",{ref:a,id:Q,className:H,style:{...b?{fontFamily:b}:null,...O},"data-testid":B,children:[_&&e.jsxs("div",{className:"nice-log-console__header",children:[e.jsx("span",{className:"nice-log-console__title",children:P}),I&&e.jsx("button",{type:"button",className:"nice-log-console__clear",onClick:I,"aria-label":U,children:U})]}),e.jsx("div",{ref:Y,className:"nice-log-console__body",style:{maxHeight:typeof d=="number"?`${d}px`:d},role:"log","aria-live":"polite","aria-relevant":"additions",children:w.length===0?e.jsx("div",{className:"nice-log-console__empty",children:W}):w.map((j,z)=>{const $=j.level??"log";return e.jsxs("div",{className:`nice-log-console__entry nice-log-console__entry--${$}`,children:[N&&j.timestamp!=null&&e.jsx("span",{className:"nice-log-console__time",children:Si(j.timestamp)}),e.jsx("span",{className:"nice-log-console__level",children:$}),j.source&&e.jsx("span",{className:"nice-log-console__source",children:j.source}),e.jsx("span",{className:"nice-log-console__message",children:j.message}),j.data!==void 0&&e.jsx("pre",{className:"nice-log-console__data",children:Mi(j.data)})]},z)})})]})}),It="nice-log-console-styles";if(typeof document<"u"&&!document.getElementById(It)){const t=document.createElement("style");t.id=It,t.textContent=`
276
+ .nice-log-console {
277
+ display: flex;
278
+ flex-direction: column;
279
+ border: 1px solid var(--nice-border, #e0e0e0);
280
+ border-radius: var(--nice-radius-sm, 4px);
281
+ background: var(--nice-surface, #fff);
282
+ color: var(--nice-text-primary, #1f2937);
283
+ overflow: hidden;
284
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
285
+ font-size: 12px;
286
+ line-height: 1.55;
287
+ }
288
+ .nice-log-console__header {
289
+ display: flex;
290
+ align-items: center;
291
+ justify-content: space-between;
292
+ gap: var(--nice-space-2, 8px);
293
+ padding: var(--nice-space-1, 4px) var(--nice-space-2, 8px);
294
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
295
+ background: var(--nice-bg-secondary, #f5f5f5);
296
+ }
297
+ .nice-log-console__title {
298
+ font-weight: 600;
299
+ font-size: 12px;
300
+ }
301
+ .nice-log-console__clear {
302
+ border: 1px solid var(--nice-border, #e0e0e0);
303
+ background: var(--nice-surface, #fff);
304
+ color: var(--nice-text-secondary, #6b7280);
305
+ border-radius: var(--nice-radius-sm, 4px);
306
+ padding: 2px 8px;
307
+ font: inherit;
308
+ font-size: 11px;
309
+ cursor: pointer;
310
+ }
311
+ .nice-log-console__clear:hover {
312
+ color: var(--nice-text-primary, #1f2937);
313
+ border-color: var(--nice-text-secondary, #9ca3af);
314
+ }
315
+ .nice-log-console__body {
316
+ flex: 1;
317
+ overflow: auto;
318
+ padding: var(--nice-space-2, 8px);
319
+ }
320
+ .nice-log-console__empty {
321
+ color: var(--nice-text-muted, #9ca3af);
322
+ font-style: italic;
323
+ padding: var(--nice-space-2, 8px) 0;
324
+ }
325
+ .nice-log-console__entry {
326
+ display: flex;
327
+ flex-wrap: wrap;
328
+ align-items: baseline;
329
+ gap: var(--nice-space-2, 8px);
330
+ padding: 1px 0;
331
+ white-space: pre-wrap;
332
+ word-break: break-word;
333
+ }
334
+ .nice-log-console__time {
335
+ color: var(--nice-text-muted, #9ca3af);
336
+ flex: 0 0 auto;
337
+ }
338
+ .nice-log-console__level {
339
+ flex: 0 0 auto;
340
+ text-transform: uppercase;
341
+ font-size: 10px;
342
+ font-weight: 700;
343
+ letter-spacing: 0.04em;
344
+ opacity: 0.8;
345
+ min-width: 38px;
346
+ }
347
+ .nice-log-console__source {
348
+ flex: 0 0 auto;
349
+ color: var(--nice-primary, #2563eb);
350
+ }
351
+ .nice-log-console__message {
352
+ flex: 1 1 auto;
353
+ }
354
+ .nice-log-console__data {
355
+ flex: 1 0 100%;
356
+ margin: 2px 0 4px;
357
+ padding: var(--nice-space-1, 4px) var(--nice-space-2, 8px);
358
+ background: var(--nice-bg-secondary, #f5f5f5);
359
+ border-radius: var(--nice-radius-sm, 4px);
360
+ overflow: auto;
361
+ font: inherit;
362
+ }
363
+ .nice-log-console__entry--info .nice-log-console__level { color: var(--nice-primary, #2563eb); }
364
+ .nice-log-console__entry--warn { color: var(--nice-warning-text, #92400e); }
365
+ .nice-log-console__entry--warn .nice-log-console__level { color: var(--nice-warning, #d97706); }
366
+ .nice-log-console__entry--error { color: var(--nice-danger, #dc2626); }
367
+ .nice-log-console__entry--error .nice-log-console__level { color: var(--nice-danger, #dc2626); }
368
+ .nice-log-console__entry--debug { color: var(--nice-text-muted, #9ca3af); }
369
+ .nice-log-console__entry--trace { color: var(--nice-text-disabled, #b8bfc9); }
370
+ .nice-log-console__entry--trace .nice-log-console__level { color: var(--nice-text-disabled, #b8bfc9); }
371
+ `,document.head.appendChild(t)}const $i=[{target:".nice-script-runner",titleKey:"tutorial.scriptRunner.intro.title",title:"Script runner",contentKey:"tutorial.scriptRunner.intro.content",content:"Write a script and sample input, click Run, then inspect the result and captured logs below.",placement:"auto"}];function At(t){if(t===void 0)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function zt(t){const i=t.trim();if(i==="")return{value:void 0,error:null};try{return{value:JSON.parse(i),error:null}}catch(a){return{value:t,error:a instanceof Error?a.message:"Invalid JSON"}}}function Ei(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const Ti=n.forwardRef(function(i,a){const{value:o,onChange:d,language:g="javascript",onRun:N,input:k,onInputChange:I,showInputPanel:P,extraLibs:W,height:U=260,running:b,autoRun:K=!1,autoRunDelay:O=600,layout:Q="vertical",runLabel:B="Run",theme:Y="auto",tutorial:w,className:_,style:H,id:j,"data-testid":z}=i,$=P??k!==void 0,[x,h]=n.useState(()=>At(k)),[M,D]=n.useState(null),[S,y]=n.useState(!1),[s,L]=n.useState(null),C=b??S,m=Y==="light"?"vs":Y==="dark"?"vs-dark":Y;n.useEffect(()=>{h(At(k))},[k]);const c=n.useCallback(async()=>{const E=zt(x),R=typeof performance<"u"?performance.now():Date.now();b===void 0&&y(!0);try{const J=await N(o,E.value),A=J.durationMs??Math.round((typeof performance<"u"?performance.now():Date.now())-R);L({...J,durationMs:A})}catch(J){L({ok:!1,error:J instanceof Error?J.message:String(J),durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-R)})}finally{b===void 0&&y(!1)}},[x,N,o,b]),u=n.useRef(c);u.current=c,n.useEffect(()=>{if(!K)return;const E=setTimeout(()=>{u.current()},O);return()=>clearTimeout(E)},[K,O,o,x]);const p=n.useCallback(E=>{h(E);const R=zt(E);D(R.error),I?.(R.value)},[I]),f=typeof U=="number"?`${U}px`:U,l=`nice-script-runner nice-script-runner--${Q}`+(_?` ${_}`:"");return e.jsxs("div",{ref:a,id:j,className:l,style:H,"data-testid":z,children:[e.jsxs("div",{className:"nice-script-runner__toolbar",children:[e.jsxs("button",{type:"button",className:"nice-script-runner__run",onClick:()=>void c(),disabled:C,children:[C?"…":e.jsx(v.oa,{name:"play",size:14})," ",B]}),s?.durationMs!=null&&e.jsxs("span",{className:"nice-script-runner__status",children:[e.jsx("span",{className:"nice-script-runner__badge nice-script-runner__badge--"+(s.ok?"ok":"error"),children:s.ok?"OK":"Failed"}),e.jsxs("span",{className:"nice-script-runner__duration",children:[s.durationMs," ms"]})]}),w&&e.jsx("span",{style:{marginLeft:"auto"},children:e.jsx(v.Yl,{steps:v.Jl(w,$i)})})]}),e.jsxs("div",{className:"nice-script-runner__panes",children:[e.jsxs("div",{className:"nice-script-runner__editors",children:[e.jsx(Ze,{value:o,onChange:d,language:g,theme:m,height:f,extraLibs:W,options:{minimap:!1}}),$&&e.jsxs("div",{className:"nice-script-runner__input",children:[e.jsxs("div",{className:"nice-script-runner__pane-label",children:["Input (JSON)",M&&e.jsxs("span",{className:"nice-script-runner__input-error",children:[" — ",M]})]}),e.jsx(Ze,{value:x,onChange:p,language:"json",theme:m,height:120,options:{minimap:!1,lineNumbers:"off"}})]})]}),e.jsxs("div",{className:"nice-script-runner__output",children:[s?.error&&e.jsx("div",{className:"nice-script-runner__error",children:s.error}),s&&s.result!==void 0&&e.jsxs("div",{className:"nice-script-runner__result",children:[e.jsx("div",{className:"nice-script-runner__pane-label",children:"Result"}),e.jsx("pre",{className:"nice-script-runner__result-body",children:Ei(s.result)})]}),e.jsx(yn,{title:"Logs",entries:s?.logs??[],maxHeight:160,emptyText:"Run the script to see logs"})]})]})]})}),Dt="nice-script-runner-styles";if(typeof document<"u"&&!document.getElementById(Dt)){const t=document.createElement("style");t.id=Dt,t.textContent=`
372
+ .nice-script-runner {
373
+ display: flex;
374
+ flex-direction: column;
375
+ gap: var(--nice-space-2, 8px);
376
+ border: 1px solid var(--nice-border, #e0e0e0);
377
+ border-radius: var(--nice-radius-md, 6px);
378
+ padding: var(--nice-space-2, 8px);
379
+ background: var(--nice-surface, #fff);
380
+ }
381
+ .nice-script-runner__toolbar {
382
+ display: flex;
383
+ align-items: center;
384
+ gap: var(--nice-space-2, 8px);
385
+ }
386
+ .nice-script-runner__run {
387
+ border: 0;
388
+ background: var(--nice-primary, #2563eb);
389
+ color: var(--nice-text-inverse, #fff);
390
+ border-radius: var(--nice-radius-sm, 4px);
391
+ padding: 6px 14px;
392
+ font: inherit;
393
+ font-weight: 600;
394
+ cursor: pointer;
395
+ }
396
+ .nice-script-runner__run:disabled {
397
+ opacity: 0.6;
398
+ cursor: default;
399
+ }
400
+ .nice-script-runner__status {
401
+ display: inline-flex;
402
+ align-items: center;
403
+ gap: var(--nice-space-2, 8px);
404
+ font-size: 12px;
405
+ }
406
+ .nice-script-runner__badge {
407
+ padding: 1px 8px;
408
+ border-radius: 999px;
409
+ font-size: 11px;
410
+ font-weight: 700;
411
+ }
412
+ .nice-script-runner__badge--ok {
413
+ background: var(--nice-success-bg, #dcfce7);
414
+ color: var(--nice-success-text, #166534);
415
+ }
416
+ .nice-script-runner__badge--error {
417
+ background: var(--nice-danger-bg, #fee2e2);
418
+ color: var(--nice-danger-text, #991b1b);
419
+ }
420
+ .nice-script-runner__duration {
421
+ color: var(--nice-text-muted, #9ca3af);
422
+ }
423
+ .nice-script-runner__panes {
424
+ display: grid;
425
+ gap: var(--nice-space-2, 8px);
426
+ }
427
+ .nice-script-runner--horizontal .nice-script-runner__panes {
428
+ grid-template-columns: 1fr 1fr;
429
+ }
430
+ .nice-script-runner__editors,
431
+ .nice-script-runner__output {
432
+ display: flex;
433
+ flex-direction: column;
434
+ gap: var(--nice-space-2, 8px);
435
+ min-width: 0;
436
+ }
437
+ .nice-script-runner__pane-label {
438
+ font-size: 11px;
439
+ font-weight: 600;
440
+ text-transform: uppercase;
441
+ letter-spacing: 0.04em;
442
+ color: var(--nice-text-secondary, #6b7280);
443
+ }
444
+ .nice-script-runner__input-error {
445
+ color: var(--nice-danger, #dc2626);
446
+ text-transform: none;
447
+ font-weight: 400;
448
+ }
449
+ .nice-script-runner__error {
450
+ padding: var(--nice-space-2, 8px);
451
+ border-radius: var(--nice-radius-sm, 4px);
452
+ background: var(--nice-danger-bg, #fee2e2);
453
+ color: var(--nice-danger-text, #991b1b);
454
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
455
+ font-size: 12px;
456
+ white-space: pre-wrap;
457
+ }
458
+ .nice-script-runner__result-body {
459
+ margin: 4px 0 0;
460
+ padding: var(--nice-space-2, 8px);
461
+ border: 1px solid var(--nice-border, #e0e0e0);
462
+ border-radius: var(--nice-radius-sm, 4px);
463
+ background: var(--nice-bg-secondary, #f9fafb);
464
+ max-height: 200px;
465
+ overflow: auto;
466
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
467
+ font-size: 12px;
468
+ }
469
+ `,document.head.appendChild(t)}const Ri=[{target:".nice-key-value-editor",titleKey:"tutorial.keyValueEditor.intro.title",title:"Key/value editor",contentKey:"tutorial.keyValueEditor.intro.content",content:"Add key/value rows for headers, params, env vars or config; mask secret values, toggle rows on/off, and watch for duplicate keys.",placement:"auto"}],Ii=n.forwardRef(function(i,a){const{value:o,onChange:d,allowSecret:g=!1,allowToggle:N=!1,allowDescription:k=!1,keySuggestions:I,keyPlaceholder:P="Key",valuePlaceholder:W="Value",addLabel:U="Add",readOnly:b=!1,duplicateKeyWarning:K=!0,tutorial:O,className:Q,style:B,id:Y,"data-testid":w}=i,_=n.useMemo(()=>`nice-kv-keys-${Math.random().toString(36).slice(2,9)}`,[]),H=n.useMemo(()=>{const h=new Map,M=new Set;if(K){for(const D of o){const S=D.key.trim();S!==""&&h.set(S,(h.get(S)??0)+1)}h.forEach((D,S)=>{D>1&&M.add(S)})}return M},[o,K]),j=(h,M)=>{d(o.map((D,S)=>S===h?{...D,...M}:D))},z=h=>{d(o.filter((M,D)=>D!==h))},$=()=>{d([...o,{key:"",value:"",type:"text",enabled:!0}])},x="nice-key-value-editor"+(Q?` ${Q}`:"");return e.jsxs("div",{ref:a,id:Y,className:x,style:{position:"relative",...B},"data-testid":w,children:[e.jsx("span",{style:{position:"absolute",top:0,right:0,zIndex:20},children:e.jsx(v.Yl,{steps:v.Jl(O,Ri)})}),I&&I.length>0&&e.jsx("datalist",{id:_,children:I.map(h=>e.jsx("option",{value:h},h))}),e.jsx("div",{className:"nice-key-value-editor__rows",children:o.map((h,M)=>{const D=h.type==="secret",S=h.key.trim()!==""&&H.has(h.key.trim()),y=N&&h.enabled===!1;return e.jsxs("div",{className:"nice-key-value-editor__row"+(y?" nice-key-value-editor__row--disabled":""),children:[N&&e.jsx("input",{type:"checkbox",className:"nice-key-value-editor__toggle",checked:h.enabled!==!1,onChange:s=>j(M,{enabled:s.target.checked}),disabled:b,"aria-label":"Enabled"}),e.jsx("input",{type:"text",className:"nice-key-value-editor__key"+(S?" nice-key-value-editor__key--dup":""),value:h.key,list:I?_:void 0,placeholder:P,onChange:s=>j(M,{key:s.target.value}),readOnly:b,"aria-label":P,title:S?"Duplicate key":void 0}),e.jsx("input",{type:D?"password":"text",className:"nice-key-value-editor__value",value:h.value,placeholder:W,onChange:s=>j(M,{value:s.target.value}),readOnly:b,autoComplete:D?"new-password":"off","aria-label":W}),g&&e.jsx("button",{type:"button",className:"nice-key-value-editor__secret"+(D?" nice-key-value-editor__secret--on":""),onClick:()=>j(M,{type:D?"text":"secret"}),disabled:b,title:D?"Secret (click to reveal as text)":"Mark as secret","aria-pressed":D,"aria-label":"Toggle secret",children:e.jsx(v.oa,{name:"lock",size:16})}),k&&e.jsx("input",{type:"text",className:"nice-key-value-editor__desc",value:h.description??"",placeholder:"Description",onChange:s=>j(M,{description:s.target.value}),readOnly:b,"aria-label":"Description"}),!b&&e.jsx("button",{type:"button",className:"nice-key-value-editor__remove",onClick:()=>z(M),title:"Remove row","aria-label":"Remove row",children:e.jsx(v.oa,{name:"close",size:14})})]},h.id??M)})}),!b&&e.jsxs("button",{type:"button",className:"nice-key-value-editor__add",onClick:$,children:["+ ",U]})]})}),Lt="nice-key-value-editor-styles";if(typeof document<"u"&&!document.getElementById(Lt)){const t=document.createElement("style");t.id=Lt,t.textContent=`
470
+ .nice-key-value-editor {
471
+ display: flex;
472
+ flex-direction: column;
473
+ gap: var(--nice-space-2, 8px);
474
+ }
475
+ .nice-key-value-editor__rows {
476
+ display: flex;
477
+ flex-direction: column;
478
+ gap: var(--nice-space-1, 4px);
479
+ }
480
+ .nice-key-value-editor__row {
481
+ display: flex;
482
+ align-items: center;
483
+ gap: var(--nice-space-1, 4px);
484
+ }
485
+ .nice-key-value-editor__row--disabled {
486
+ opacity: 0.55;
487
+ }
488
+ .nice-key-value-editor__key,
489
+ .nice-key-value-editor__value,
490
+ .nice-key-value-editor__desc {
491
+ flex: 1 1 0;
492
+ min-width: 0;
493
+ padding: 6px 8px;
494
+ border: 1px solid var(--nice-border, #d1d5db);
495
+ border-radius: var(--nice-radius-sm, 4px);
496
+ background: var(--nice-bg, #fff);
497
+ color: var(--nice-text-primary, #1f2937);
498
+ font: inherit;
499
+ font-size: 13px;
500
+ }
501
+ .nice-key-value-editor__key {
502
+ flex-basis: 30%;
503
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
504
+ }
505
+ .nice-key-value-editor__key--dup {
506
+ border-color: var(--nice-danger, #dc2626);
507
+ background: var(--nice-danger-bg, #fee2e2);
508
+ }
509
+ .nice-key-value-editor__key:focus,
510
+ .nice-key-value-editor__value:focus,
511
+ .nice-key-value-editor__desc:focus {
512
+ outline: none;
513
+ border-color: var(--nice-primary, #2563eb);
514
+ }
515
+ .nice-key-value-editor__toggle {
516
+ flex: 0 0 auto;
517
+ }
518
+ .nice-key-value-editor__secret,
519
+ .nice-key-value-editor__remove {
520
+ flex: 0 0 auto;
521
+ border: 1px solid var(--nice-border, #d1d5db);
522
+ background: var(--nice-surface, #fff);
523
+ border-radius: var(--nice-radius-sm, 4px);
524
+ padding: 5px 8px;
525
+ font-size: 13px;
526
+ line-height: 1;
527
+ cursor: pointer;
528
+ }
529
+ .nice-key-value-editor__secret--on {
530
+ border-color: var(--nice-warning, #d97706);
531
+ background: var(--nice-warning-bg, #fef3c7);
532
+ }
533
+ .nice-key-value-editor__remove:hover {
534
+ border-color: var(--nice-danger, #dc2626);
535
+ color: var(--nice-danger, #dc2626);
536
+ }
537
+ .nice-key-value-editor__add {
538
+ align-self: flex-start;
539
+ border: 1px dashed var(--nice-border, #d1d5db);
540
+ background: transparent;
541
+ color: var(--nice-primary, #2563eb);
542
+ border-radius: var(--nice-radius-sm, 4px);
543
+ padding: 5px 12px;
544
+ font: inherit;
545
+ font-size: 13px;
546
+ font-weight: 600;
547
+ cursor: pointer;
548
+ }
549
+ .nice-key-value-editor__add:hover {
550
+ background: var(--nice-bg-secondary, #f5f5f5);
551
+ }
552
+ `,document.head.appendChild(t)}function Pt(t,i){const a=i.getBoundingClientRect();let o,d,g;if("touches"in t){const N=t.touches[0];o=N.clientX-a.left,d=N.clientY-a.top,g=N.force}else"pressure"in t?(o=t.clientX-a.left,d=t.clientY-a.top,g=t.pressure):(o=t.clientX-a.left,d=t.clientY-a.top);return{x:o,y:d,time:Date.now(),pressure:g!==void 0?g:.5}}function Ot(t,i,a,o,d){if(!i)return(a+o)/2;const g=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))/Math.max(1,t.time-i.time),N=Math.min(g/5,1),k=o-N*(o-a),I=t.pressure??.5,P=a+I*(o-a);return k*.7+P*.3}function Ht(t,i,a,o){t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(a.x,a.y),t.lineWidth=o,t.lineCap="round",t.lineJoin="round",t.stroke()}const Ai=n.forwardRef(function(i,a){const{value:o,onChange:d,width:g="100%",height:N=200,penColor:k="var(--text-primary, #000000)",penWidth:I=2,minWidth:P=.5,maxWidth:W=4,backgroundColor:U="var(--bg-primary, #ffffff)",placeholder:b="Sign here",showClearButton:K=!0,showUndoButton:O=!0,showColorPicker:Q=!1,showSizeSlider:B=!1,velocityFilterWeight:Y=.7,throttle:w=16,disabled:_=!1,readOnly:H=!1,displayMode:j=!1,onBegin:z,onEnd:$,className:x,"data-testid":h}=i,M=H||j,D=j?!1:K,S=j?!1:O,y=j?!1:Q,s=j?!1:B,L=n.useRef(null),[C,m]=n.useState(o?.strokes??[]),[c,u]=n.useState([]),[p,f]=n.useState(!1),[l,E]=n.useState(k),[R,J]=n.useState(I),A=n.useRef(null),he=n.useRef(0),re=C.length===0&&c.length===0;n.useEffect(()=>{const ee=L.current;if(!ee)return;const le=ee.getContext("2d");if(!le)return;const V=ee.getBoundingClientRect(),F=window.devicePixelRatio||1;ee.width=V.width*F,ee.height=V.height*F,le.scale(F,F),fe()},[g,N]);const fe=n.useCallback(()=>{const ee=L.current;if(!ee)return;const le=ee.getContext("2d");if(!le)return;const V=ee.getBoundingClientRect();le.fillStyle=U,le.fillRect(0,0,V.width,V.height),C.forEach(F=>{if(le.strokeStyle=F.color,!(F.points.length<2))for(let X=1;X<F.points.length;X++){const Z=F.points[X-1],q=F.points[X],be=Ot(q,Z,P,W);Ht(le,Z,q,be)}})},[C,U,P,W,Y]);n.useEffect(()=>{fe()},[fe]),n.useEffect(()=>{o?.strokes&&m(o.strokes)},[o]),n.useEffect(()=>{const ee=L.current;if(ee)if(C.length===0)d?.(null);else{const le=ee.getBoundingClientRect();d?.({strokes:C,width:le.width,height:le.height,timestamp:Date.now()})}},[C,d]);const ne=n.useCallback(ee=>{if(_||M)return;const le=L.current;if(!le)return;le.setPointerCapture(ee.pointerId);const V=Pt(ee.nativeEvent,le);f(!0),u([V]),A.current=V,he.current=V.time,z?.()},[_,M,z]),se=n.useCallback(ee=>{if(!p||_||M)return;const le=L.current;if(!le)return;const V=le.getContext("2d");if(!V)return;const F=Date.now();if(F-he.current<w)return;const X=Pt(ee.nativeEvent,le),Z=A.current;if(Z){V.strokeStyle=l;const q=Ot(X,Z,P,W);Ht(V,Z,X,q)}u(q=>[...q,X]),A.current=X,he.current=F},[p,_,M,l,P,W,Y,w]),de=n.useCallback(ee=>{if(!p)return;const le=L.current;if(le&&le.releasePointerCapture(ee.pointerId),c.length>0){const V={points:c,color:l,width:R};m(F=>[...F,V])}f(!1),u([]),A.current=null,$?.()},[p,c,l,R,$]),ue=n.useCallback(()=>{m([]),u([]),fe()},[fe]),je=n.useCallback(()=>{m(ee=>ee.slice(0,-1))},[]),te=n.useCallback((ee="png",le=.92)=>{const V=L.current;if(!V)return"";const F=ee==="jpeg"?"image/jpeg":"image/png";return V.toDataURL(F,le)},[]),ce=n.useCallback(async(ee="png",le=.92)=>{const V=L.current;return V?new Promise(F=>{const X=ee==="jpeg"?"image/jpeg":"image/png";V.toBlob(Z=>F(Z),X,le)}):null},[]),me=n.useCallback(()=>{const ee=L.current;if(!ee)return"";const le=ee.getBoundingClientRect(),V=C.map(F=>F.points.length<2?"":`<path d="${F.points.reduce((Z,q,be)=>be===0?`M ${q.x} ${q.y}`:`${Z} L ${q.x} ${q.y}`,"")}" stroke="${F.color}" stroke-width="${F.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`).join(`
553
+ `);return`<svg xmlns="http://www.w3.org/2000/svg" width="${le.width}" height="${le.height}" viewBox="0 0 ${ee.width} ${ee.height}">
554
+ <rect width="100%" height="100%" fill="${U}"/>
555
+ ${V}
556
+ </svg>`},[C,U]);n.useImperativeHandle(a,()=>({clear:ue,undo:je,isEmpty:()=>C.length===0,getData:()=>{const ee=L.current;if(!ee||C.length===0)return null;const le=ee.getBoundingClientRect();return{strokes:C,width:le.width,height:le.height,timestamp:Date.now()}},setData:ee=>{m(ee.strokes)},toDataURL:te,toBlob:ce,toSVG:me,getCanvas:()=>L.current}),[C,ue,je,te,ce,me]),n.useEffect(()=>{const ee=L.current;if(!ee)return;const le=V=>{p&&V.preventDefault()};return ee.addEventListener("touchmove",le,{passive:!1}),()=>ee.removeEventListener("touchmove",le)},[p]);const ae=D||S||y||s;return e.jsxs("div",{className:`nice-signature ${_?"nice-signature--disabled":""} ${M?"nice-signature--readonly":""} ${x??""}`,style:{width:g},"data-testid":h,children:[ae&&e.jsxs("div",{className:"nice-signature__toolbar",children:[y&&e.jsx("div",{className:"nice-signature__color-picker",children:e.jsx("input",{type:"color",value:l,onChange:ee=>E(ee.target.value),disabled:_||M,title:"Pen color"})}),s&&e.jsx("div",{className:"nice-signature__size-slider",children:e.jsx("input",{type:"range",min:P,max:W,step:.5,value:R,onChange:ee=>J(parseFloat(ee.target.value)),disabled:_||M,title:"Pen size"})}),e.jsxs("div",{className:"nice-signature__actions",children:[S&&e.jsx("button",{type:"button",onClick:je,disabled:_||M||C.length===0,className:"nice-signature__btn",title:"Undo","aria-label":"Undo",children:e.jsx(v.oa,{name:"reply",size:16})}),D&&e.jsx("button",{type:"button",onClick:ue,disabled:_||M||re,className:"nice-signature__btn",title:"Clear","aria-label":"Clear",children:e.jsx(v.oa,{name:"trash",size:16})})]})]}),e.jsxs("div",{className:"nice-signature__canvas-wrapper",style:{height:N},children:[e.jsx("canvas",{ref:L,className:"nice-signature__canvas",style:{width:"100%",height:"100%",cursor:_||M?"not-allowed":"crosshair",touchAction:"none"},onPointerDown:ne,onPointerMove:se,onPointerUp:de,onPointerLeave:de}),re&&!p&&b&&e.jsx("div",{className:"nice-signature__placeholder",children:b}),e.jsx("div",{className:"nice-signature__line"})]})]})}),Ft="nice-signature-styles";if(typeof document<"u"&&!document.getElementById(Ft)){const t=document.createElement("style");t.id=Ft,t.textContent=`
557
+ .nice-signature {
558
+ display: flex;
559
+ flex-direction: column;
560
+ border: 1px solid var(--nice-border, #e0e0e0);
561
+ border-radius: var(--nice-radius-sm, 4px);
562
+ overflow: hidden;
563
+ background: var(--nice-bg-surface, #fff);
564
+ }
565
+
566
+ .nice-signature--disabled {
567
+ opacity: 0.6;
568
+ }
569
+
570
+ .nice-signature__toolbar {
571
+ display: flex;
572
+ align-items: center;
573
+ gap: var(--nice-space-2, 8px);
574
+ padding: var(--nice-space-2, 8px);
575
+ background: var(--nice-bg-muted, #f5f5f5);
576
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
577
+ }
578
+
579
+ .nice-signature__color-picker input {
580
+ width: 32px;
581
+ height: 32px;
582
+ padding: var(--nice-space-0-5, 2px);
583
+ border: 1px solid var(--nice-border, #e0e0e0);
584
+ border-radius: var(--nice-radius-sm, 4px);
585
+ cursor: pointer;
586
+ }
587
+
588
+ .nice-signature__size-slider {
589
+ flex: 1;
590
+ max-width: 120px;
591
+ }
592
+
593
+ .nice-signature__size-slider input {
594
+ width: 100%;
595
+ }
596
+
597
+ .nice-signature__actions {
598
+ display: flex;
599
+ gap: var(--nice-space-1, 4px);
600
+ margin-left: auto;
601
+ }
602
+
603
+ .nice-signature__btn {
604
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
605
+ border: 1px solid var(--nice-border, #e0e0e0);
606
+ border-radius: var(--nice-radius-sm, 4px);
607
+ background: var(--nice-bg-surface, #fff);
608
+ cursor: pointer;
609
+ font-size: 14px;
610
+ }
611
+
612
+ .nice-signature__btn:hover:not(:disabled) {
613
+ background: var(--nice-bg-hover, #f0f0f0);
614
+ }
615
+
616
+ .nice-signature__btn:disabled {
617
+ opacity: 0.4;
618
+ cursor: not-allowed;
619
+ }
620
+
621
+ .nice-signature__canvas-wrapper {
622
+ position: relative;
623
+ background: var(--nice-bg, #FFF);
624
+ }
625
+
626
+ .nice-signature__canvas {
627
+ display: block;
628
+ }
629
+
630
+ .nice-signature__placeholder {
631
+ position: absolute;
632
+ top: 50%;
633
+ left: 50%;
634
+ transform: translate(-50%, -50%);
635
+ color: var(--nice-text-secondary, #999);
636
+ font-size: 14px;
637
+ pointer-events: none;
638
+ user-select: none;
639
+ }
640
+
641
+ .nice-signature__line {
642
+ position: absolute;
643
+ bottom: 30px;
644
+ left: 20px;
645
+ right: 20px;
646
+ height: 1px;
647
+ background: var(--nice-border, #ccc);
648
+ pointer-events: none;
649
+ }
650
+
651
+ /* Display component */
652
+ .nice-signature-display {
653
+ border: 1px solid var(--nice-border, #e0e0e0);
654
+ border-radius: var(--nice-radius-sm, 4px);
655
+ overflow: hidden;
656
+ }
657
+
658
+ .nice-signature-display__canvas-wrapper {
659
+ position: relative;
660
+ background: var(--nice-bg, #FFF);
661
+ }
662
+
663
+ .nice-signature-display__canvas {
664
+ display: block;
665
+ }
666
+
667
+ .nice-signature-display__placeholder {
668
+ position: absolute;
669
+ top: 50%;
670
+ left: 50%;
671
+ transform: translate(-50%, -50%);
672
+ color: var(--nice-text-secondary, #999);
673
+ font-size: 14px;
674
+ }
675
+ `,document.head.appendChild(t)}const zi={recent:"🕒",smileys:"😀",people:"👋",animals:"🐱",food:"🍕",travel:"✈️",activities:"⚽",objects:"💡",symbols:"❤️",flags:"🏳️"},Bt={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"},mt=["","🏻","🏼","🏽","🏾","🏿"],at=[{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"}],Kt="nice-emoji-picker-recent",xn=({onSelect:t,showSearch:i=!0,searchPlaceholder:a,showSkinTones:o=!0,defaultSkinTone:d=0,showRecent:g=!0,maxRecent:N=24,recentEmojis:k,onRecentChange:I,categories:P,customEmojis:W=[],columns:U=8,size:b="md",className:K="",style:O,"data-testid":Q="nice-emoji-picker"})=>{const{t:B}=v.Gt(),[Y,w]=n.useState(""),[_,H]=n.useState(g?"recent":"smileys"),[j,z]=n.useState(d),[$,x]=n.useState(!1),h=n.useRef(null),[M,D]=n.useState(()=>{if(typeof window>"u")return[];try{return JSON.parse(localStorage.getItem(Kt)||"[]")}catch{return[]}}),S=k??M,y=P??[...g?["recent"]:[],"smileys","people","animals","food","travel","activities","objects","symbols","flags"],s=n.useMemo(()=>{if(!Y)return at;const p=Y.toLowerCase();return at.filter(f=>f.name.toLowerCase().includes(p)||f.emoji.includes(p)||f.keywords?.some(l=>l.toLowerCase().includes(p)))},[Y]),L=n.useMemo(()=>{const p={};for(const f of y)f==="recent"?p[f]=S.map(l=>at.find(E=>E.emoji===l)).filter(l=>l!==void 0).slice(0,N):p[f]=s.filter(l=>l.category===f);return p},[y,s,S,N]),C=n.useCallback((p,f)=>!f||j===0?p:p.replace(/[\u{1F3FB}-\u{1F3FF}]/gu,"")+mt[j],[j]),m=n.useCallback(p=>{const f=C(p.emoji,p.skinTones),l=[p.emoji,...S.filter(E=>E!==p.emoji)].slice(0,N);if(k===void 0){D(l);try{localStorage.setItem(Kt,JSON.stringify(l))}catch{}}I?.(l),t?.(f,p)},[C,S,N,k,I,t]),c=n.useCallback(p=>{t?.(`:${p.name}:`,p)},[t]);n.useEffect(()=>{if(!$)return;const p=f=>{h.current&&!h.current.contains(f.target)&&x(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[$]);const u=Y?s:L[_]||[];return e.jsxs("div",{className:`nice-emoji-picker nice-emoji-picker--${b} ${K}`,style:O,"data-testid":Q,children:[i&&e.jsxs("div",{className:"nice-emoji-picker__search",children:[e.jsx("input",{type:"text",value:Y,onChange:p=>w(p.target.value),placeholder:a??B("search","Search emoji..."),className:"nice-emoji-picker__search-input","data-testid":`${Q}-search`}),o&&e.jsxs("div",{className:"nice-emoji-picker__skin-tone-wrapper",children:[e.jsxs("button",{ref:h,type:"button",className:"nice-emoji-picker__skin-tone-btn",onClick:()=>x(!$),title:B("skinTone","Skin tone"),children:["✋",mt[j]]}),$&&e.jsx("div",{className:"nice-emoji-picker__skin-tone-menu",children:mt.map((p,f)=>e.jsxs("button",{type:"button",className:`nice-emoji-picker__skin-tone-option ${f===j?"nice-emoji-picker__skin-tone-option--selected":""}`,onClick:()=>{z(f),x(!1)},children:["✋",p]},f))})]})]}),!Y&&e.jsx("div",{className:"nice-emoji-picker__categories",role:"tablist",children:y.map(p=>e.jsx("button",{type:"button",className:`nice-emoji-picker__category-btn ${_===p?"nice-emoji-picker__category-btn--selected":""}`,onClick:()=>H(p),title:Bt[p],role:"tab","aria-selected":_===p,children:zi[p]},p))}),e.jsxs("div",{className:"nice-emoji-picker__grid-container",children:[Y?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(${U}, 1fr)`},children:s.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:B("noEmojis","No emojis found")}):s.map((p,f)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>m(p),title:p.name,children:C(p.emoji,p.skinTones)},`${p.emoji}-${f}`))})]}):e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:Bt[_]}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${U}, 1fr)`},children:u.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:_==="recent"?B("noRecent","No recent emojis"):B("noEmojis","No emojis")}):u.map((p,f)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>m(p),title:p.name,children:C(p.emoji,p.skinTones)},`${p.emoji}-${f}`))})]}),W.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(${U}, 1fr)`},children:W.map(p=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji nice-emoji-picker__emoji--custom",onClick:()=>c(p),title:p.name,children:e.jsx("img",{src:p.url,alt:p.name})},p.id))})]})]})]})};xn.displayName="NiceEmojiPicker";const Di=[{target:".nice-crop-editor",titleKey:"tutorial.cropEditor.intro.title",title:"Crop editor",contentKey:"tutorial.cropEditor.intro.content",content:"Drag the crop box over the image, pick an aspect ratio, rotate, flip or zoom, then use the result.",placement:"auto"}],bn=[{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}],jn=({src:t,initialCrop:i={x:10,y:10,width:80,height:80},initialRotation:a=0,initialZoom:o=1,aspectRatios:d=bn,defaultAspectRatio:g="free",customAspectRatio:N,showRotation:k=!0,showFlip:I=!0,showZoom:P=!0,minZoom:W=.5,maxZoom:U=3,zoomStep:b=.1,showGrid:K=!0,overlayColor:O="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",toolbarPosition:Q="bottom",toolbarCollapsible:B=!1,defaultToolbarCollapsed:Y=!1,onChange:w,tutorial:_,className:H="",style:j,"data-testid":z="nice-crop-editor"})=>{const{t:$}=v.Gt(),x=n.useRef(null),h=n.useRef(null),[M,D]=n.useState(i),[S,y]=n.useState(a),[s,L]=n.useState(o),[C,m]=n.useState(!1),[c,u]=n.useState(!1),[p,f]=n.useState(g),[l,E]=n.useState(Y),[R,J]=n.useState(!1),[A,he]=n.useState({x:0,y:0,crop:M}),re=p==="custom"?N:d.find(V=>V.value===p)?.ratio;n.useEffect(()=>{w?.({crop:M,rotation:S,flipH:C,flipV:c,zoom:s})},[M,S,C,c,s,w]);const fe=n.useCallback((V,F)=>{if(!re)return V;const X=x.current?.clientWidth??400,Z=x.current?.clientHeight??300,q=V.width/100*X,be=V.height/100*Z,ye=q/be;if(Math.abs(ye-re)<.01)return V;if(F?.includes("e")||F?.includes("w")){const _e=q/re/Z*100;return{...V,height:Math.min(100-V.y,Math.max(5,_e))}}else if(F?.includes("n")||F?.includes("s")){const _e=be*re/X*100;return{...V,width:Math.min(100-V.x,Math.max(5,_e))}}else{const _e=q/re/Z*100;return{...V,height:Math.min(100-V.y,Math.max(5,_e))}}},[re]),ne=n.useCallback((V,F)=>{F===!1||(V.preventDefault(),V.stopPropagation(),J(F),!x.current?.getBoundingClientRect())||he({x:V.clientX,y:V.clientY,crop:{...M}})},[M]),se=n.useCallback(V=>{if(!R||!x.current)return;const F=x.current.getBoundingClientRect(),X=(V.clientX-A.x)/F.width*100,Z=(V.clientY-A.y)/F.height*100;let q={...A.crop};if(R==="crop")q.x=Math.max(0,Math.min(100-q.width,A.crop.x+X)),q.y=Math.max(0,Math.min(100-q.height,A.crop.y+Z));else{switch(R){case"resize-nw":q.x=Math.max(0,Math.min(A.crop.x+A.crop.width-5,A.crop.x+X)),q.y=Math.max(0,Math.min(A.crop.y+A.crop.height-5,A.crop.y+Z)),q.width=A.crop.width-(q.x-A.crop.x),q.height=A.crop.height-(q.y-A.crop.y);break;case"resize-ne":q.y=Math.max(0,Math.min(A.crop.y+A.crop.height-5,A.crop.y+Z)),q.width=Math.max(5,Math.min(100-q.x,A.crop.width+X)),q.height=A.crop.height-(q.y-A.crop.y);break;case"resize-sw":q.x=Math.max(0,Math.min(A.crop.x+A.crop.width-5,A.crop.x+X)),q.width=A.crop.width-(q.x-A.crop.x),q.height=Math.max(5,Math.min(100-q.y,A.crop.height+Z));break;case"resize-se":q.width=Math.max(5,Math.min(100-q.x,A.crop.width+X)),q.height=Math.max(5,Math.min(100-q.y,A.crop.height+Z));break;case"resize-n":q.y=Math.max(0,Math.min(A.crop.y+A.crop.height-5,A.crop.y+Z)),q.height=A.crop.height-(q.y-A.crop.y);break;case"resize-s":q.height=Math.max(5,Math.min(100-q.y,A.crop.height+Z));break;case"resize-e":q.width=Math.max(5,Math.min(100-q.x,A.crop.width+X));break;case"resize-w":q.x=Math.max(0,Math.min(A.crop.x+A.crop.width-5,A.crop.x+X)),q.width=A.crop.width-(q.x-A.crop.x);break}q=fe(q,R.replace("resize-",""))}D(q)},[R,A,fe]),de=n.useCallback(()=>{J(!1)},[]);n.useEffect(()=>{if(R)return document.addEventListener("mousemove",se),document.addEventListener("mouseup",de),()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",de)}},[R,se,de]);const ue=n.useCallback(()=>{y(V=>(V-90+360)%360)},[]),je=n.useCallback(()=>{y(V=>(V+90)%360)},[]),te=n.useCallback(()=>{m(V=>!V)},[]),ce=n.useCallback(()=>{u(V=>!V)},[]),me=n.useCallback(()=>{D(i),y(a),L(o),m(!1),u(!1),f(g)},[i,a,o,g]);n.useEffect(()=>{D(V=>fe(V))},[p,fe]);const ae=`scale(${s}) rotate(${S}deg) scaleX(${C?-1:1}) scaleY(${c?-1:1})`,ee=Q==="top"?"column-reverse":Q==="left"?"row-reverse":Q==="right"?"row":"column",le=Q==="left"||Q==="right";return e.jsxs("div",{className:`nice-crop-editor nice-crop-editor--toolbar-${Q} ${H}`,style:{position:"relative",display:"flex",flexDirection:ee,gap:12,...j},"data-testid":z,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Yl,{steps:v.Jl(_,Di)})}),e.jsxs("div",{ref:x,className:"nice-crop-editor__container","data-testid":`${z}-container`,children:[e.jsx("img",{ref:h,src:t,alt:"",className:"nice-crop-editor__image",style:{transform:ae},draggable:!1}),e.jsxs("div",{className:"nice-crop-editor__overlay",style:{backgroundColor:O},children:[e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:0,left:0,right:0,height:`${M.y}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{bottom:0,left:0,right:0,height:`${100-M.y-M.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${M.y}%`,left:0,width:`${M.x}%`,height:`${M.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${M.y}%`,right:0,width:`${100-M.x-M.width}%`,height:`${M.height}%`}})]}),e.jsxs("div",{className:"nice-crop-editor__crop-area",style:{left:`${M.x}%`,top:`${M.y}%`,width:`${M.width}%`,height:`${M.height}%`},onMouseDown:V=>ne(V,"crop"),"data-testid":`${z}-crop-area`,children:[K&&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:V=>ne(V,"resize-nw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--ne",onMouseDown:V=>ne(V,"resize-ne")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--sw",onMouseDown:V=>ne(V,"resize-sw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--se",onMouseDown:V=>ne(V,"resize-se")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--n",onMouseDown:V=>ne(V,"resize-n")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--s",onMouseDown:V=>ne(V,"resize-s")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--e",onMouseDown:V=>ne(V,"resize-e")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--w",onMouseDown:V=>ne(V,"resize-w")})]})]}),e.jsxs("div",{className:`nice-crop-editor__controls ${l?"nice-crop-editor__controls--collapsed":""}`,style:{display:"flex",flexDirection:le?"column":"row",flexWrap:le?"nowrap":"wrap",gap:8,alignItems:le?"stretch":"center",flexShrink:0},children:[B&&e.jsx("button",{type:"button",className:"nice-crop-editor__toolbar-toggle","aria-expanded":!l,"aria-label":l?"Show toolbar":"Hide toolbar",onClick:()=>E(V=>!V),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:e.jsx(v.oa,{name:l?"chevron-right":"chevron-down",size:14})}),!l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsx("label",{className:"nice-crop-editor__label",children:$("aspectRatio","Aspect Ratio")}),e.jsx("div",{className:"nice-crop-editor__aspect-buttons",children:d.map(V=>e.jsx("button",{type:"button",className:`nice-crop-editor__aspect-btn ${p===V.value?"nice-crop-editor__aspect-btn--selected":""}`,onClick:()=>f(V.value),title:V.label,children:V.label},V.value))})]}),P&&e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsxs("label",{className:"nice-crop-editor__label",children:[$("zoom","Zoom"),": ",Math.round(s*100),"%"]}),e.jsx("input",{type:"range",className:"nice-crop-editor__slider",min:W,max:U,step:b,value:s,onChange:V=>L(parseFloat(V.target.value)),"data-testid":`${z}-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:ue,title:$("rotateLeft","Rotate Left"),"aria-label":$("rotateLeft","Rotate Left"),children:e.jsx(v.oa,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:je,title:$("rotateRight","Rotate Right"),"aria-label":$("rotateRight","Rotate Right"),children:e.jsx(v.oa,{name:"forward",size:16})})]}),I&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${C?"nice-crop-editor__btn--active":""}`,onClick:te,title:$("flipHorizontal","Flip Horizontal"),"aria-label":$("flipHorizontal","Flip Horizontal"),children:e.jsx(v.oa,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${c?"nice-crop-editor__btn--active":""}`,onClick:ce,title:$("flipVertical","Flip Vertical"),"aria-label":$("flipVertical","Flip Vertical"),children:e.jsx(v.oa,{name:"shuffle",size:16})})]}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn nice-crop-editor__btn--reset",onClick:me,title:$("reset","Reset"),"aria-label":$("reset","Reset"),children:e.jsx(v.oa,{name:"refresh",size:16})})]})]})]})]})};jn.displayName="NiceCropEditor";const Li={strokeColor:"#ff3333",fillColor:"transparent",strokeWidth:2,opacity:1,fontSize:16,fontFamily:"sans-serif"};function Pi(t,i){switch(i.type){case"SET_TOOL":return{...t,activeTool:i.tool,selectedId:null};case"SET_STYLE":return{...t,style:{...t.style,...i.style}};case"ADD_ANNOTATION":return{...t,annotations:[...t.annotations,i.annotation],past:[...t.past,t.annotations],future:[]};case"UPDATE_ANNOTATION":return{...t,annotations:t.annotations.map(a=>a.id===i.id?{...a,...i.updates}:a),past:[...t.past,t.annotations],future:[]};case"DELETE_ANNOTATION":return{...t,annotations:t.annotations.filter(a=>a.id!==i.id),selectedId:t.selectedId===i.id?null:t.selectedId,past:[...t.past,t.annotations],future:[]};case"SELECT":return{...t,selectedId:i.id};case"SET_ANNOTATIONS":return{...t,annotations:i.annotations,past:[],future:[]};case"SET_ZOOM":return{...t,zoom:i.zoom};case"SET_PAN":return{...t,panX:i.panX,panY:i.panY};case"UNDO":{if(t.past.length===0)return t;const a=t.past[t.past.length-1];return{...t,annotations:a,past:t.past.slice(0,-1),future:[t.annotations,...t.future]}}case"REDO":{if(t.future.length===0)return t;const a=t.future[0];return{...t,annotations:a,past:[...t.past,t.annotations],future:t.future.slice(1)}}case"CLEAR":return{...t,annotations:[],selectedId:null,past:[...t.past,t.annotations],future:[]};default:return t}}let Oi=0;function Hi(){return`ann-${Date.now()}-${Oi++}`}function Fi(t){const{style:i}=t,a=`stroke="${i.strokeColor}" stroke-width="${i.strokeWidth}" fill="${i.fillColor}" opacity="${i.opacity}"`;switch(t.tool){case"rectangle":return`<rect x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" ${a} />`;case"ellipse":{const o=t.x+t.width/2,d=t.y+t.height/2;return`<ellipse cx="${o}" cy="${d}" rx="${t.width/2}" ry="${t.height/2}" ${a} />`}case"arrow":{const o=t,d=Math.atan2(o.endY-o.y,o.endX-o.x),g=12,N=o.endX-g*Math.cos(d-Math.PI/6),k=o.endY-g*Math.sin(d-Math.PI/6),I=o.endX-g*Math.cos(d+Math.PI/6),P=o.endY-g*Math.sin(d+Math.PI/6);return`<line x1="${o.x}" y1="${o.y}" x2="${o.endX}" y2="${o.endY}" ${a} />
676
+ <polygon points="${o.endX},${o.endY} ${N},${k} ${I},${P}" fill="${i.strokeColor}" opacity="${i.opacity}" />`}case"line":{const o=t;return`<line x1="${o.x}" y1="${o.y}" x2="${o.endX}" y2="${o.endY}" ${a} />`}case"text":{const o=t;return`<text x="${o.x}" y="${o.y+(o.style.fontSize??16)}" fill="${i.strokeColor}" font-size="${i.fontSize}" font-family="${i.fontFamily}" opacity="${i.opacity}">${Bi(o.text)}</text>`}case"freehand":{const o=t;return o.points.length<2?"":`<path d="${o.points.map((g,N)=>`${N===0?"M":"L"}${g.x},${g.y}`).join(" ")}" ${a} fill="none" />`}case"blur":{const o=t,d=`blur-${o.id}`;return`<defs><filter id="${d}"><feGaussianBlur stdDeviation="${o.intensity??5}" /></filter></defs>
677
+ <rect x="${o.x}" y="${o.y}" width="${o.width}" height="${o.height}" fill="transparent" stroke="none" filter="url(#${d})" />`}default:return""}}function Bi(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}const vn=n.forwardRef(({src:t,alt:i="Annotatable image",annotations:a,activeTool:o,defaultStyle:d,onAnnotationsChange:g,className:N,readOnly:k=!1,minZoom:I=.1,maxZoom:P=5},W)=>{const U=n.useRef(null),b=n.useRef(null),K=n.useRef(null),[O,Q]=n.useState(!1),[B,Y]=n.useState({width:0,height:0}),[w,_]=n.useReducer(Pi,{annotations:a??[],selectedId:null,activeTool:o??"select",style:{...Li,...d},zoom:1,panX:0,panY:0,past:[],future:[]});n.useEffect(()=>{o&&_({type:"SET_TOOL",tool:o})},[o]),n.useEffect(()=>{g?.(w.annotations)},[w.annotations,g]),n.useEffect(()=>{const y=new Image;y.crossOrigin="anonymous",y.onload=()=>{K.current=y,Y({width:y.naturalWidth,height:y.naturalHeight}),Q(!0)},y.src=t},[t]);const H=n.useRef({isDrawing:!1,startX:0,startY:0,currentAnnotation:null,freehandPoints:[]}),j=n.useCallback((y,s)=>{const L=U.current;if(!L)return{x:0,y:0};const C=L.getBoundingClientRect();return{x:(y-C.left-w.panX)/w.zoom,y:(s-C.top-w.panY)/w.zoom}},[w.zoom,w.panX,w.panY]),z=n.useCallback(()=>{const y=U.current,s=y?.getContext("2d"),L=K.current;if(!y||!s||!L||!O)return;y.width=b.current?.clientWidth??L.naturalWidth,y.height=b.current?.clientHeight??L.naturalHeight,s.clearRect(0,0,y.width,y.height),s.save(),s.translate(w.panX,w.panY),s.scale(w.zoom,w.zoom),s.drawImage(L,0,0);for(const m of w.annotations){switch(s.save(),s.globalAlpha=m.style.opacity,s.strokeStyle=m.style.strokeColor,s.fillStyle=m.style.fillColor,s.lineWidth=m.style.strokeWidth,m.tool){case"rectangle":s.strokeRect(m.x,m.y,m.width,m.height),m.style.fillColor!=="transparent"&&s.fillRect(m.x,m.y,m.width,m.height);break;case"ellipse":{s.beginPath(),s.ellipse(m.x+m.width/2,m.y+m.height/2,Math.abs(m.width/2),Math.abs(m.height/2),0,0,Math.PI*2),s.stroke(),m.style.fillColor!=="transparent"&&s.fill();break}case"arrow":{const c=m;s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(c.endX,c.endY),s.stroke();const u=Math.atan2(c.endY-c.y,c.endX-c.x),p=12;s.beginPath(),s.moveTo(c.endX,c.endY),s.lineTo(c.endX-p*Math.cos(u-Math.PI/6),c.endY-p*Math.sin(u-Math.PI/6)),s.lineTo(c.endX-p*Math.cos(u+Math.PI/6),c.endY-p*Math.sin(u+Math.PI/6)),s.closePath(),s.fillStyle=m.style.strokeColor,s.fill();break}case"line":{const c=m;s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(c.endX,c.endY),s.stroke();break}case"text":{const c=m;s.font=`${c.style.fontSize??16}px ${c.style.fontFamily??"sans-serif"}`,s.fillStyle=c.style.strokeColor,s.fillText(c.text,c.x,c.y+(c.style.fontSize??16));break}case"freehand":{const c=m;if(c.points.length<2)break;s.beginPath(),s.moveTo(c.points[0].x,c.points[0].y);for(let u=1;u<c.points.length;u++)s.lineTo(c.points[u].x,c.points[u].y);s.stroke();break}case"blur":{const c=m;s.filter=`blur(${c.intensity??5}px)`,s.drawImage(L,c.x,c.y,c.width,c.height,c.x,c.y,c.width,c.height),s.filter="none";break}}m.id===w.selectedId&&(s.strokeStyle="#4488ff",s.lineWidth=1,s.setLineDash([4,4]),s.strokeRect(m.x-2,m.y-2,m.width+4,m.height+4),s.setLineDash([])),s.restore()}const C=H.current;if(C.isDrawing&&C.currentAnnotation){s.save();const m=C.currentAnnotation;if(s.globalAlpha=m.style.opacity,s.strokeStyle=m.style.strokeColor,s.lineWidth=m.style.strokeWidth,s.setLineDash([6,3]),m.tool==="freehand"){const c=m;if(c.points.length>=2){s.beginPath(),s.moveTo(c.points[0].x,c.points[0].y);for(let u=1;u<c.points.length;u++)s.lineTo(c.points[u].x,c.points[u].y);s.stroke()}}else if(m.tool==="rectangle")s.strokeRect(m.x,m.y,m.width,m.height);else if(m.tool==="ellipse")s.beginPath(),s.ellipse(m.x+m.width/2,m.y+m.height/2,Math.abs(m.width/2),Math.abs(m.height/2),0,0,Math.PI*2),s.stroke();else if(m.tool==="arrow"||m.tool==="line"){const c=m;s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(c.endX,c.endY),s.stroke()}s.restore()}s.restore()},[w,O]);n.useEffect(()=>{z()},[z]);const $=n.useCallback(y=>{if(k)return;const s=j(y.clientX,y.clientY),L=w.activeTool;if(L==="select"){const c=[...w.annotations].reverse().find(u=>u.tool==="freehand"?!1:s.x>=u.x&&s.x<=u.x+u.width&&s.y>=u.y&&s.y<=u.y+u.height);_({type:"SELECT",id:c?.id??null});return}const C=H.current;C.isDrawing=!0,C.startX=s.x,C.startY=s.y;const m={id:Hi(),style:{...w.style},x:s.x,y:s.y,width:0,height:0};switch(L){case"rectangle":C.currentAnnotation={...m,tool:"rectangle"};break;case"ellipse":C.currentAnnotation={...m,tool:"ellipse"};break;case"arrow":C.currentAnnotation={...m,tool:"arrow",endX:s.x,endY:s.y};break;case"line":C.currentAnnotation={...m,tool:"line",endX:s.x,endY:s.y};break;case"text":C.currentAnnotation={...m,tool:"text",text:"Text",width:100,height:w.style.fontSize??16};break;case"freehand":C.freehandPoints=[s],C.currentAnnotation={...m,tool:"freehand",points:[s]};break;case"blur":C.currentAnnotation={...m,tool:"blur",intensity:5};break}},[k,j,w.activeTool,w.style,w.annotations]),x=n.useCallback(y=>{const s=H.current;if(!s.isDrawing||!s.currentAnnotation)return;const L=j(y.clientX,y.clientY),C=s.currentAnnotation;if(C.tool==="freehand"){s.freehandPoints.push(L),C.points=[...s.freehandPoints];const m=s.freehandPoints.map(u=>u.x),c=s.freehandPoints.map(u=>u.y);C.x=Math.min(...m),C.y=Math.min(...c),C.width=Math.max(...m)-C.x,C.height=Math.max(...c)-C.y}else if(C.tool==="arrow"||C.tool==="line")C.endX=L.x,C.endY=L.y,C.width=Math.abs(L.x-s.startX),C.height=Math.abs(L.y-s.startY);else{const m=Math.min(s.startX,L.x),c=Math.min(s.startY,L.y);C.x=m,C.y=c,C.width=Math.abs(L.x-s.startX),C.height=Math.abs(L.y-s.startY)}z()},[j,z]),h=n.useCallback(()=>{const y=H.current;if(!y.isDrawing||!y.currentAnnotation)return;const s=y.currentAnnotation;(s.tool==="text"||s.tool==="freehand"||Math.abs(s.width)>2||Math.abs(s.height)>2)&&_({type:"ADD_ANNOTATION",annotation:s}),y.isDrawing=!1,y.currentAnnotation=null,y.freehandPoints=[]},[]),M=n.useCallback(y=>{y.preventDefault();const s=y.deltaY>0?.9:1.1,L=Math.max(I,Math.min(P,w.zoom*s));_({type:"SET_ZOOM",zoom:L})},[w.zoom,I,P]);n.useEffect(()=>{if(k)return;const y=s=>{(s.metaKey||s.ctrlKey)&&s.key==="z"&&!s.shiftKey?(s.preventDefault(),_({type:"UNDO"})):(s.metaKey||s.ctrlKey)&&(s.key==="y"||s.key==="z"&&s.shiftKey)?(s.preventDefault(),_({type:"REDO"})):(s.key==="Delete"||s.key==="Backspace")&&w.selectedId&&_({type:"DELETE_ANNOTATION",id:w.selectedId})};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[k,w.selectedId]),n.useImperativeHandle(W,()=>({exportAsDataURL:async(y="png",s=.92)=>{const L=document.createElement("canvas"),C=K.current;if(!C)return"";L.width=C.naturalWidth,L.height=C.naturalHeight;const m=L.getContext("2d");m.drawImage(C,0,0);for(const c of w.annotations){if(m.save(),m.globalAlpha=c.style.opacity,m.strokeStyle=c.style.strokeColor,m.fillStyle=c.style.fillColor,m.lineWidth=c.style.strokeWidth,c.tool==="rectangle")m.strokeRect(c.x,c.y,c.width,c.height);else if(c.tool==="ellipse")m.beginPath(),m.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),m.stroke();else if(c.tool==="freehand"){const u=c;if(u.points.length>=2){m.beginPath(),m.moveTo(u.points[0].x,u.points[0].y);for(let p=1;p<u.points.length;p++)m.lineTo(u.points[p].x,u.points[p].y);m.stroke()}}else if(c.tool==="text"){const u=c;m.font=`${u.style.fontSize??16}px ${u.style.fontFamily??"sans-serif"}`,m.fillStyle=u.style.strokeColor,m.fillText(u.text,u.x,u.y+(u.style.fontSize??16))}m.restore()}return L.toDataURL(`image/${y}`,s)},exportAnnotations:()=>[...w.annotations],importAnnotations:y=>{_({type:"SET_ANNOTATIONS",annotations:y})},exportAsSVG:()=>{const{width:y,height:s}=B,L=w.annotations.map(Fi);return`<svg xmlns="http://www.w3.org/2000/svg" width="${y}" height="${s}" viewBox="0 0 ${y} ${s}">
678
+ ${L.join(`
679
+ `)}
680
+ </svg>`},undo:()=>_({type:"UNDO"}),redo:()=>_({type:"REDO"}),setZoom:y=>{_({type:"SET_ZOOM",zoom:Math.max(I,Math.min(P,y))})},fitToScreen:()=>{const y=b.current,s=K.current;if(!y||!s)return;const L=y.clientWidth/s.naturalWidth,C=y.clientHeight/s.naturalHeight,m=Math.min(L,C,1);_({type:"SET_ZOOM",zoom:m}),_({type:"SET_PAN",panX:0,panY:0})},clear:()=>_({type:"CLEAR"})}),[w.annotations,B,I,P]);const D=n.useCallback(y=>{if(y.touches.length!==1)return;const s=y.touches[0];$({clientX:s.clientX,clientY:s.clientY,preventDefault:()=>{}})},[$]),S=n.useCallback(y=>{if(y.touches.length!==1)return;const s=y.touches[0];x({clientX:s.clientX,clientY:s.clientY})},[x]);return e.jsx("div",{ref:b,className:`nice-image-annotator ${N??""}`,style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"},children:e.jsx("canvas",{ref:U,className:"nice-image-annotator__canvas",style:{cursor:w.activeTool==="select"?"default":"crosshair"},onMouseDown:$,onMouseMove:x,onMouseUp:h,onMouseLeave:h,onWheel:M,onTouchStart:D,onTouchMove:S,onTouchEnd:h,role:"img","aria-label":i})})});vn.displayName="NiceImageAnnotator";const Ki=[{target:".nice-md-editor",titleKey:"tutorial.markdownEditor.intro.title",title:"Markdown editor",contentKey:"tutorial.markdownEditor.intro.content",content:"Write Markdown with the formatting toolbar; toggle the live preview to see the rendered result, and export to HTML.",placement:"auto"}];function Ui(t){let i=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return i=i.replace(/```(\w*)\n([\s\S]*?)```/g,(a,o,d)=>`<pre><code class="language-${o}">${d.trim()}</code></pre>`),i=i.replace(/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm,(a,o,d,g)=>{const N=o.split("|").filter(I=>I.trim()).map(I=>`<th>${I.trim()}</th>`).join(""),k=g.trim().split(`
681
+ `).map(I=>`<tr>${I.split("|").filter(W=>W.trim()).map(W=>`<td>${W.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(/^&gt; (.+)$/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 Yi=[{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",icon:"type",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",icon:"list",md:"- ",tip:"Unordered list",group:"list"},{key:"ol",label:"1.",md:"1. ",tip:"Ordered list",group:"list"},{key:"task",icon:"check-square",md:"- [ ] ",tip:"Task list",group:"list"},{key:"quote",icon:"message",md:"> ",tip:"Blockquote",group:"block"},{key:"hr",icon:"minus",md:`---
682
+ `,tip:"Horizontal rule",group:"block"},{key:"link",icon:"link",md:"[](url)",tip:"Link",shortcut:"Ctrl+K",group:"insert"},{key:"image",icon:"image",md:"![](url)",tip:"Image",group:"insert"},{key:"table",icon:"table",md:`| H1 | H2 | H3 |
683
+ | --- | --- | --- |
684
+ | c1 | c2 | c3 |
685
+ `,tip:"Table",group:"insert"},{key:"codeblock",label:"```",md:"```\n",tip:"Code block",group:"insert"}],Wi=["format","heading","list","block","insert"],_n=n.forwardRef(({value:t="",onChange:i,preview:a="side",placeholder:o,disabled:d,readOnly:g,size:N="md",editorSize:k="standard",toolbar:I=!0,minHeight:P=200,showWordCount:W=!1,showLineNumbers:U=!1,onExportHtml:b,onImageUpload:K,tutorial:O,className:Q,style:B,id:Y},w)=>{const _=v.hc(Y),[H,j]=n.useState("edit"),[z,$]=n.useState(!1),x=n.useRef(null),h=n.useMemo(()=>Ui(t),[t]),M=n.useMemo(()=>{const m=t.trim()?t.trim().split(/\s+/).length:0,c=t.length,u=t.split(`
686
+ `).length;return{words:m,chars:c,lines:u}},[t]),D=n.useCallback(m=>{const c=x.current;if(!c)return;const u=c.selectionStart,p=c.selectionEnd,f=t.slice(u,p);let l,E;m==="[](url)"?(l=t.slice(0,u)+`[${f||"text"}](url)`+t.slice(p),E=u+1+(f||"text").length+2):m==="![](url)"?(l=t.slice(0,u)+`![${f||"alt"}](url)`+t.slice(p),E=u+2+(f||"alt").length+2):m.endsWith(`
687
+ `)||m.endsWith(" ")?(l=t.slice(0,u)+m+f+t.slice(p),E=u+m.length+f.length):(l=t.slice(0,u)+m+f+m+t.slice(p),E=u+m.length+f.length+m.length),i?.(l),requestAnimationFrame(()=>{c.focus(),c.setSelectionRange(E,E)})},[t,i]),S=n.useCallback(m=>{if((m.ctrlKey||m.metaKey)&&(m.key==="b"?(m.preventDefault(),D("**")):m.key==="i"?(m.preventDefault(),D("*")):m.key==="k"&&(m.preventDefault(),D("[](url)"))),m.key==="Tab"){m.preventDefault();const c=m.currentTarget,u=c.selectionStart,p=c.selectionEnd,f=" ";if(m.shiftKey){const R=t.slice(0,u).lastIndexOf(`
688
+ `)+1;if(t.slice(R,R+f.length)===f){const J=t.slice(0,R)+t.slice(R+f.length);i?.(J),requestAnimationFrame(()=>{c.selectionStart=c.selectionEnd=u-f.length})}}else{const l=t.slice(0,u)+f+t.slice(p);i?.(l),requestAnimationFrame(()=>{c.selectionStart=c.selectionEnd=u+f.length})}}},[t,i,D]),y=n.useCallback(async m=>{if(!K)return;const c=Array.from(m.dataTransfer.files).filter(u=>u.type.startsWith("image/"));if(c.length!==0){m.preventDefault();for(const u of c){const p=await K(u),f=x.current;if(!f)continue;const l=f.selectionStart,E=`![${u.name}](${p})
689
+ `,R=t.slice(0,l)+E+t.slice(l);i?.(R)}}},[t,i,K]),s=a!=="tab"||H==="edit",L=a==="side"||a==="tab"&&H==="preview"||a===!0,C=`nice-md-editor nice-md-editor--${N} nice-editor--${k} nice-md-editor--preview-${a}${z?" nice-md-editor--fullscreen":""} ${Q||""}`;return e.jsxs("div",{ref:w,id:_,className:C,style:{position:"relative",...B},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Yl,{steps:v.Jl(O,Ki)})}),I&&e.jsxs("div",{className:"nice-md-editor__toolbar",children:[Wi.map((m,c)=>e.jsxs(n.Fragment,{children:[c>0&&e.jsx("span",{className:"nice-md-editor__sep"}),Yi.filter(u=>u.group===m).map(u=>e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:u.shortcut?`${u.tip} (${u.shortcut})`:u.tip,disabled:d||g,onClick:()=>D(u.md),"aria-label":u.tip,children:u.icon?e.jsx(v.oa,{name:u.icon,size:16}):u.label},u.key))]},m)),e.jsx("span",{className:"nice-md-editor__sep"}),e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Fullscreen","aria-label":"Fullscreen",onClick:()=>$(!z),children:e.jsx(v.oa,{name:z?"collapse":"expand",size:16})}),b&&e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Export HTML","aria-label":"Export HTML",onClick:()=>b(h),children:e.jsx(v.oa,{name:"external-link",size:16})}),a==="tab"&&e.jsxs("span",{className:"nice-md-editor__tabs",children:[e.jsx("button",{type:"button",className:`nice-md-editor__tab${H==="edit"?" nice-md-editor__tab--active":""}`,onClick:()=>j("edit"),children:"Edit"}),e.jsx("button",{type:"button",className:`nice-md-editor__tab${H==="preview"?" nice-md-editor__tab--active":""}`,onClick:()=>j("preview"),children:"Preview"})]})]}),e.jsxs("div",{className:"nice-md-editor__body",style:{minHeight:P},children:[s&&e.jsxs("div",{className:"nice-md-editor__editor-wrap",children:[U&&e.jsx("div",{className:"nice-md-editor__line-numbers",children:Array.from({length:M.lines},(m,c)=>e.jsx("div",{className:"nice-md-editor__line-no",children:c+1},c))}),e.jsx("textarea",{ref:x,className:"nice-md-editor__textarea",value:t,onChange:m=>i?.(m.target.value),onKeyDown:S,onDrop:y,placeholder:o,disabled:d,readOnly:g,style:{minHeight:P}})]}),L&&e.jsx("div",{className:"nice-md-editor__preview",dangerouslySetInnerHTML:{__html:v.lc(h)},style:{minHeight:P}})]}),W&&e.jsxs("div",{className:"nice-md-editor__statusbar",children:[e.jsxs("span",{children:[M.words," words"]}),e.jsxs("span",{children:[M.chars," chars"]}),e.jsxs("span",{children:[M.lines," lines"]})]})]})});_n.displayName="NiceMarkdownEditor";const Vi=[{target:".nice-image-editor",titleKey:"tutorial.imageEditor.intro.title",title:"Image editor",contentKey:"tutorial.imageEditor.intro.content",content:"Use the toolbar to crop, rotate, flip, adjust brightness/contrast and annotate; undo/redo your edits, then save the result.",placement:"auto"}],Ut={rotation:0,flipH:!1,flipV:!1,brightness:100,contrast:100,saturate:100,blur:0,crop:null,annotations:[]},Gi=["crop","rotate","flip","brightness","contrast","saturate","blur","annotate"],kn=n.forwardRef(({src:t,size:i="md",editorSize:a="standard",tools:o=Gi,showToolbar:d=!0,showZoom:g=!0,maxUndo:N=30,onSave:k,onCancel:I,onChange:P,width:W="100%",height:U=500,tutorial:b,className:K,style:O,id:Q,...B},Y)=>{const w=v.hc(Q),{t:_}=v.Gt(),H=n.useRef(null),j=n.useRef(null),[z,$]=n.useState({...Ut}),[x,h]=n.useState(null),[M,D]=n.useState(!1),[S,y]=n.useState(1),[s,L]=n.useState("rect"),[C,m]=n.useState("var(--nice-danger, #ff0000)"),[c,u]=n.useState({w:0,h:0}),[p,f]=n.useState([]),[l,E]=n.useState([]),[R,J]=n.useState(null),[A,he]=n.useState(null),[re,fe]=n.useState(null),ne=n.useCallback(F=>{f(X=>[...X.slice(-(N-1)),F]),E([])},[N]),se=n.useCallback(F=>{$(X=>{ne(X);const Z={...X,...F};return P?.(Z),Z})},[P,ne]),de=n.useCallback(()=>{if(p.length===0)return;const F=p[p.length-1];f(X=>X.slice(0,-1)),E(X=>[...X,z]),$(F),P?.(F)},[p,z,P]),ue=n.useCallback(()=>{if(l.length===0)return;const F=l[l.length-1];E(X=>X.slice(0,-1)),f(X=>[...X,z]),$(F),P?.(F)},[l,z,P]);n.useEffect(()=>{const F=new Image;F.crossOrigin="anonymous",F.onload=()=>{j.current=F,u({w:F.width,h:F.height}),D(!0)},F.src=t},[t]),n.useEffect(()=>{if(!M||!H.current||!j.current)return;const F=H.current,X=F.getContext("2d");if(!X)return;const Z=j.current,q=z.rotation%180!==0,be=q?Z.height:Z.width,ye=q?Z.width:Z.height;F.width=be,F.height=ye,X.clearRect(0,0,be,ye),X.save(),X.filter=`brightness(${z.brightness}%) contrast(${z.contrast}%) saturate(${z.saturate}%) blur(${z.blur}px)`,X.translate(be/2,ye/2),X.rotate(z.rotation*Math.PI/180),X.scale(z.flipH?-1:1,z.flipV?-1:1),X.drawImage(Z,-Z.width/2,-Z.height/2),X.restore(),z.annotations.forEach(xe=>{switch(X.save(),X.strokeStyle=xe.color??"red",X.fillStyle=xe.color??"red",X.lineWidth=xe.strokeWidth??2,X.font=`${xe.fontSize??16}px sans-serif`,xe.type){case"text":X.fillText(xe.text??"",xe.x,xe.y);break;case"rect":X.strokeRect(xe.x,xe.y,xe.width??100,xe.height??50);break;case"circle":{const _e=(xe.width??50)/2,we=(xe.height??50)/2;X.beginPath(),X.ellipse(xe.x+_e,xe.y+we,_e,we,0,0,Math.PI*2),X.stroke();break}case"line":X.beginPath(),X.moveTo(xe.x,xe.y),X.lineTo(xe.x+(xe.width??100),xe.y+(xe.height??0)),X.stroke();break;case"arrow":{const _e=xe.x+(xe.width??100),we=xe.y+(xe.height??0);X.beginPath(),X.moveTo(xe.x,xe.y),X.lineTo(_e,we),X.stroke();const $e=Math.atan2(we-xe.y,_e-xe.x),Re=10;X.beginPath(),X.moveTo(_e,we),X.lineTo(_e-Re*Math.cos($e-.4),we-Re*Math.sin($e-.4)),X.lineTo(_e-Re*Math.cos($e+.4),we-Re*Math.sin($e+.4)),X.closePath(),X.fill();break}}X.restore()}),A&&(X.save(),X.fillStyle="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",X.fillRect(0,0,be,ye),X.clearRect(A.x,A.y,A.w,A.h),X.strokeStyle="var(--bg-primary, #fff)",X.lineWidth=2,X.setLineDash([5,5]),X.strokeRect(A.x,A.y,A.w,A.h),X.restore())},[M,z,A]);const je=n.useCallback(F=>{if(!H.current)return;const X=H.current.getBoundingClientRect(),Z=H.current.width/X.width,q=H.current.height/X.height,be=(F.clientX-X.left)*Z,ye=(F.clientY-X.top)*q;x==="crop"?J({startX:be,startY:ye}):x==="annotate"&&fe({startX:be,startY:ye})},[x]),te=n.useCallback(F=>{if(!H.current)return;const X=H.current.getBoundingClientRect(),Z=H.current.width/X.width,q=H.current.height/X.height,be=(F.clientX-X.left)*Z,ye=(F.clientY-X.top)*q;R&&he({x:Math.min(R.startX,be),y:Math.min(R.startY,ye),w:Math.abs(be-R.startX),h:Math.abs(ye-R.startY)})},[R]),ce=n.useCallback(F=>{if(R&&A&&A.w>5&&A.h>5&&se({crop:{x:A.x,y:A.y,width:A.w,height:A.h}}),J(null),re&&H.current){const X=H.current.getBoundingClientRect(),Z=H.current.width/X.width,q=H.current.height/X.height,be=(F.clientX-X.left)*Z,ye=(F.clientY-X.top)*q,xe=be-re.startX,_e=ye-re.startY;if(Math.abs(xe)>3||Math.abs(_e)>3||s==="text"){const we={type:s,x:re.startX,y:re.startY,width:Math.abs(xe)||100,height:Math.abs(_e)||50,color:C,strokeWidth:2,text:s==="text"?prompt(_("imageEditor.annotationText","Text:"))??"":void 0};se({annotations:[...z.annotations,we]})}fe(null)}},[R,A,re,s,C,z.annotations,se,_]),me=n.useCallback(()=>{if(!z.crop||!H.current)return;const F=H.current,X=F.getContext("2d");if(!X)return;const{x:Z,y:q,width:be,height:ye}=z.crop,xe=X.getImageData(Z,q,be,ye);F.width=be,F.height=ye,X.putImageData(xe,0,0),he(null),h(null)},[z.crop]),ae=n.useCallback(()=>{if(!H.current)return;const F=H.current.toDataURL("image/png");k?.(F,z)},[k,z]),ee=n.useCallback(()=>{$({...Ut}),he(null),h(null)},[]);n.useMemo(()=>`brightness(${z.brightness}%) contrast(${z.contrast}%) saturate(${z.saturate}%) blur(${z.blur}px)`,[z.brightness,z.contrast,z.saturate,z.blur]);const le=d?e.jsxs("div",{className:"nice-image-editor__toolbar",role:"toolbar",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:de,disabled:p.length===0,title:_("imageEditor.undo","Undo"),"aria-label":_("imageEditor.undo","Undo"),children:e.jsx(v.oa,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ue,disabled:l.length===0,title:_("imageEditor.redo","Redo"),"aria-label":_("imageEditor.redo","Redo"),children:e.jsx(v.oa,{name:"forward",size:16})}),e.jsx("span",{className:"nice-image-editor__sep"}),o.includes("rotate")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({rotation:(z.rotation-90+360)%360}),title:_("imageEditor.rotateLeft","Rotate left"),"aria-label":_("imageEditor.rotateLeft","Rotate left"),children:e.jsx(v.oa,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({rotation:(z.rotation+90)%360}),title:_("imageEditor.rotateRight","Rotate right"),"aria-label":_("imageEditor.rotateRight","Rotate right"),children:e.jsx(v.oa,{name:"forward",size:16})})]}),o.includes("flip")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({flipH:!z.flipH}),title:_("imageEditor.flipH","Flip horizontal"),"aria-label":_("imageEditor.flipH","Flip horizontal"),children:e.jsx(v.oa,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({flipV:!z.flipV}),title:_("imageEditor.flipV","Flip vertical"),"aria-label":_("imageEditor.flipV","Flip vertical"),children:e.jsx(v.oa,{name:"shuffle",size:16})})]}),o.includes("crop")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-image-editor__btn ${x==="crop"?"nice-image-editor__btn--active":""}`,onClick:()=>h(x==="crop"?null:"crop"),title:_("imageEditor.crop","Crop"),"aria-label":_("imageEditor.crop","Crop"),children:e.jsx(v.oa,{name:"box",size:16})}),x==="crop"&&z.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:me,title:_("imageEditor.applyCrop","Apply crop"),"aria-label":_("imageEditor.applyCrop","Apply crop"),children:e.jsx(v.oa,{name:"check",size:16})})]}),o.includes("brightness")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:_("imageEditor.brightness","Brightness"),children:[e.jsx(v.oa,{name:"lightbulb",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:z.brightness,onChange:F=>se({brightness:Number(F.target.value)}),className:"nice-image-editor__slider",title:_("imageEditor.brightness","Brightness")})]}),o.includes("contrast")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:_("imageEditor.contrast","Contrast"),children:[e.jsx(v.oa,{name:"circle",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:z.contrast,onChange:F=>se({contrast:Number(F.target.value)}),className:"nice-image-editor__slider",title:_("imageEditor.contrast","Contrast")})]}),o.includes("saturate")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:_("imageEditor.saturate","Saturation"),children:[e.jsx(v.oa,{name:"palette",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:z.saturate,onChange:F=>se({saturate:Number(F.target.value)}),className:"nice-image-editor__slider",title:_("imageEditor.saturate","Saturation")})]}),o.includes("blur")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:_("imageEditor.blur","Blur"),children:[e.jsx(v.oa,{name:"eye-off",size:16}),e.jsx("input",{type:"range",min:0,max:20,step:.5,value:z.blur,onChange:F=>se({blur:Number(F.target.value)}),className:"nice-image-editor__slider",title:_("imageEditor.blur","Blur")})]}),o.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 ${x==="annotate"?"nice-image-editor__btn--active":""}`,onClick:()=>h(x==="annotate"?null:"annotate"),title:_("imageEditor.annotate","Annotate"),"aria-label":_("imageEditor.annotate","Annotate"),children:e.jsx(v.oa,{name:"edit",size:16})}),x==="annotate"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{className:"nice-image-editor__select",value:s,onChange:F=>L(F.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:"Text"})]}),e.jsx("input",{type:"color",value:C,onChange:F=>m(F.target.value),className:"nice-image-editor__color",title:_("imageEditor.color","Color")}),z.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({annotations:z.annotations.slice(0,-1)}),title:_("imageEditor.removeLastAnnotation","Remove last"),"aria-label":_("imageEditor.removeLastAnnotation","Remove last"),children:e.jsx(v.oa,{name:"trash",size:16})})]})]}),e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ee,title:_("imageEditor.reset","Reset"),"aria-label":_("imageEditor.reset","Reset"),children:e.jsx(v.oa,{name:"refresh",size:16})}),k&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:ae,children:_("imageEditor.save","Save")}),I&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:I,children:_("imageEditor.cancel","Cancel")})]}):void 0,V=g?e.jsxs("div",{className:"nice-image-editor__footer",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>y(F=>Math.max(.1,F-.1)),title:"Zoom out","aria-label":"Zoom out",children:e.jsx(v.oa,{name:"minus",size:16})}),e.jsxs("span",{style:{fontSize:"0.85em",minWidth:40,textAlign:"center"},children:[Math.round(S*100),"%"]}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>y(F=>Math.min(5,F+.1)),title:"Zoom in","aria-label":"Zoom in",children:e.jsx(v.oa,{name:"plus",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>y(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 · ",z.rotation,"°"]})]}):void 0;return e.jsx(Wt.NiceAppShell,{ref:Y,flush:!0,id:w,className:`nice-image-editor nice-image-editor--${i} nice-editor--${a} ${K??""}`,style:{...O,width:W,height:U},toolbar:le,statusBar:V,children:e.jsxs("div",{className:"nice-image-editor__canvas-wrap",style:{position:"relative"},role:"application","aria-label":_("imageEditor.label","Image Editor"),...B,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Yl,{steps:v.Jl(b,Vi)})}),e.jsx("canvas",{ref:H,className:"nice-image-editor__canvas",onMouseDown:je,onMouseMove:te,onMouseUp:ce,style:{cursor:x==="crop"||x==="annotate"?"crosshair":"default",transform:`scale(${S})`,transformOrigin:"center center"}})]})})});kn.displayName="NiceImageEditor";const wn=n.forwardRef(({value:t,onChange:i,penColor:a="var(--text-primary, #000)",penWidth:o=2,backgroundColor:d="var(--bg-primary, #fff)",width:g=400,height:N=200,size:k="md",disabled:I=!1,readOnly:P=!1,showClear:W=!0,showUndo:U=!0,label:b,exportFormat:K="image/png",className:O,style:Q,id:B,...Y},w)=>{const _=v.hc(B),{t:H}=v.Gt(),j=n.useRef(null),[z,$]=n.useState(!1),x=n.useRef([]),h=n.useRef([]),[M,D]=n.useState(!0),S=n.useCallback(()=>{const u=j.current;if(!u)return;const p=u.getContext("2d");if(p){p.fillStyle=d,p.fillRect(0,0,u.width,u.height),p.strokeStyle=a,p.lineWidth=o,p.lineCap="round",p.lineJoin="round";for(const f of x.current)if(!(f.length<2)){p.beginPath(),p.moveTo(f[0].x,f[0].y);for(let l=1;l<f.length;l++)p.lineTo(f[l].x,f[l].y);p.stroke()}}},[d,a,o]);n.useEffect(()=>{if(t&&j.current){const u=new Image;u.onload=()=>{const p=j.current?.getContext("2d");!p||!j.current||(p.fillStyle=d,p.fillRect(0,0,j.current.width,j.current.height),p.drawImage(u,0,0),D(!1))},u.src=t}else t||(x.current=[],D(!0),S())},[t,d,S]),n.useEffect(()=>{const u=j.current;u&&(u.width=g,u.height=N,S())},[g,N,S]);const y=n.useCallback(u=>{const p=j.current,f=p.getBoundingClientRect(),l=p.width/f.width,E=p.height/f.height;if("touches"in u){const R=u.touches[0];return{x:(R.clientX-f.left)*l,y:(R.clientY-f.top)*E}}return{x:(u.clientX-f.left)*l,y:(u.clientY-f.top)*E}},[]),s=n.useCallback(u=>{if(I||P)return;u.preventDefault();const p=y(u);h.current=[p],$(!0)},[I,P,y]),L=n.useCallback(u=>{if(!z)return;u.preventDefault();const p=y(u);h.current.push(p);const f=j.current,l=f?.getContext("2d");if(!l||!f)return;const E=h.current;E.length>=2&&(l.strokeStyle=a,l.lineWidth=o,l.lineCap="round",l.beginPath(),l.moveTo(E[E.length-2].x,E[E.length-2].y),l.lineTo(p.x,p.y),l.stroke())},[z,y,a,o]),C=n.useCallback(()=>{if(z&&($(!1),h.current.length>0&&(x.current.push([...h.current]),h.current=[],D(!1),j.current))){const u=j.current.toDataURL(K);i?.(u)}},[z,K,i]),m=n.useCallback(()=>{x.current=[],h.current=[],D(!0),S(),i?.(null)},[S,i]),c=n.useCallback(()=>{if(x.current.length!==0&&(x.current.pop(),D(x.current.length===0),S(),j.current)){const u=x.current.length>0?j.current.toDataURL(K):null;i?.(u)}},[S,K,i]);return e.jsxs("div",{ref:w,id:_,className:`nice-signature nice-signature--${k} ${I?"nice-signature--disabled":""} ${P?"nice-signature--readonly":""} ${O??""}`,style:Q,...Y,children:[b&&e.jsx("label",{className:"nice-signature__label",children:b}),e.jsx("div",{className:"nice-signature__canvas-wrap",style:{width:g,height:N},children:e.jsx("canvas",{ref:j,className:"nice-signature__canvas",onMouseDown:s,onMouseMove:L,onMouseUp:C,onMouseLeave:C,onTouchStart:s,onTouchMove:L,onTouchEnd:C,style:{touchAction:"none",cursor:I||P?"default":"crosshair"},"aria-label":b??H("signature.label","Signature pad"),role:"img"})}),(W||U)&&!P&&!I&&e.jsxs("div",{className:"nice-signature__actions",children:[U&&e.jsx("button",{type:"button",className:"nice-signature__btn",onClick:c,disabled:M,children:H("signature.undo","Undo")}),W&&e.jsx("button",{type:"button",className:"nice-signature__btn",onClick:m,disabled:M,children:H("signature.clear","Clear")})]})]})});wn.displayName="NiceSignaturePad";const Xi=[{target:".nice-doc-editor",titleKey:"tutorial.documentEditor.intro.title",title:"Document editor",contentKey:"tutorial.documentEditor.intro.content",content:"Compose a document from blocks: use the toolbar or slash commands to add headings, lists, media and more, then export to HTML.",placement:"auto"}];let qi=0;function bt(){return`blk-${++qi}-${Date.now().toString(36)}`}function Yt(t=""){return{id:bt(),type:"paragraph",content:t}}function Ji(t,i=""){const a={id:bt(),type:t,content:i};return t==="heading"&&(a.level=2),t==="list"&&(a.listType="unordered"),t==="callout"&&(a.icon="??"),t==="toggle"&&(a.open=!0),a}const Zi=[{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 Qi(t){const i=[t.align?`text-align:${t.align}`:"",t.color?`color:${t.color}`:"",t.bgColor?`background-color:${t.bgColor}`:"",t.indent?`margin-left:${t.indent*24}px`:""].filter(Boolean).join(";"),a=i?` style="${i}"`:"",o=(d,g)=>{let N=g;return t.bold&&(N=`<strong>${N}</strong>`),t.italic&&(N=`<em>${N}</em>`),t.underline&&(N=`<u>${N}</u>`),t.strikethrough&&(N=`<s>${N}</s>`),`<${d}${a}>${N}</${d}>`};switch(t.type){case"heading":return o(`h${t.level??2}`,t.content);case"paragraph":return o("p",t.content||"&nbsp;");case"list":{const d=t.listType==="ordered"?"ol":"ul",g=t.content.split(`
690
+ `).map((N,k)=>t.listType==="checklist"?`<li><input type="checkbox" ${t.checked?.[k]??!1?"checked":""} disabled />${N}</li>`:`<li>${N}</li>`).join("");return`<${d}${a}>${g}</${d}>`}case"image":return`<figure${a}><img src="${t.src??""}" alt="${t.alt??""}" /></figure>`;case"video":return`<figure${a}><video src="${t.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-${t.language??""}">${t.content}</code></pre>`;case"quote":return o("blockquote",t.content);case"callout":return`<div class="nice-doc-callout"${a}><span>${t.icon??"??"}</span><div>${t.content}</div></div>`;case"toggle":return`<details${a}><summary>${t.content.split(`
691
+ `)[0]}</summary>${t.content.split(`
692
+ `).slice(1).join("<br>")}</details>`;case"table":return`<table${a}>${t.content}</table>`;case"embed":return`<iframe src="${t.src??""}" style="width:100%;border:none;min-height:300px"></iframe>`;default:return o("p",t.content)}}function ea(t){let i=0,a=0;for(const o of t){const d=o.content??"";i+=d.length;const g=d.trim().split(/\s+/).filter(Boolean);a+=g.length}return{words:a,chars:i,readingTime:Math.max(1,Math.ceil(a/200))}}const Nn=n.forwardRef(({blocks:t,onChange:i,readOnly:a=!1,showToolbar:o=!0,size:d="md",editorSize:g="standard",placeholder:N,onExport:k,onImageUpload:I,maxUndo:P=50,slashCommands:W=!0,showWordCount:U=!1,showToc:b=!1,showFindReplace:K=!0,tutorial:O,className:Q,style:B,id:Y,...w},_)=>{const H=v.hc(Y),{t:j}=v.Gt(),[z,$]=n.useState(()=>t??[Yt()]),x=t??z,[h,M]=n.useState(0),D=n.useRef(new Map),S=n.useRef(null),[y,s]=n.useState(!1),[L,C]=n.useState(""),[m,c]=n.useState(""),[u,p]=n.useState([]),[f,l]=n.useState(0),[E,R]=n.useState(!1),J=n.useRef([]),A=n.useRef([]),he=n.useCallback(r=>{J.current.push(r.map(T=>({...T,checked:T.checked?[...T.checked]:void 0}))),J.current.length>P&&J.current.shift(),A.current=[]},[P]),re=n.useCallback(()=>{if(J.current.length===0)return;const r=J.current.pop();A.current.push(x.map(T=>({...T}))),t||$(r),i?.(r)},[x,t,i]),fe=n.useCallback(()=>{if(A.current.length===0)return;const r=A.current.pop();J.current.push(x.map(T=>({...T}))),t||$(r),i?.(r)},[x,t,i]),[ne,se]=n.useState(!1),[de,ue]=n.useState(""),[je,te]=n.useState(0),ce=n.useMemo(()=>{if(!ne||!W)return[];const r=de.toLowerCase();return Zi.filter(T=>T.label.toLowerCase().includes(r)||T.keywords.includes(r))},[ne,de,W]),[me,ae]=n.useState(null),[ee,le]=n.useState(null),V=n.useCallback(r=>{he(x);const T=r(x);t||$(T),i?.(T)},[x,t,i,he]),F=n.useCallback((r,T)=>{V(G=>G.map((oe,pe)=>pe===r?{...oe,...T}:oe))},[V]),X=n.useCallback((r,T)=>{const G=T??Yt();V(oe=>{const pe=[...oe];return pe.splice(r+1,0,G),pe}),M(r+1)},[V]),Z=n.useCallback(r=>{const T={...x[r],id:bt()};X(r,T)},[x,X]),q=n.useCallback(r=>{x.length<=1||(V(T=>T.filter((G,oe)=>oe!==r)),M(Math.max(0,r-1)))},[x.length,V]),be=n.useCallback((r,T)=>{const G=r+T;G<0||G>=x.length||(V(oe=>{const pe=[...oe];return[pe[r],pe[G]]=[pe[G],pe[r]],pe}),M(G))},[x.length,V]),ye=n.useCallback((r,T)=>{const G={type:T};T==="heading"&&(G.level=2),T==="list"&&(G.listType="unordered"),T==="callout"&&(G.icon="??"),T==="toggle"&&(G.open=!0),F(r,G)},[F]),xe=n.useCallback(r=>{const T=Ji(r.type);r.type==="list"&&r.label.includes("Numbered")&&(T.listType="ordered"),r.type==="list"&&r.label.includes("Checklist")&&(T.listType="checklist",T.checked=[]),x[h]?.content===""||x[h]?.content==="/"?V(G=>G.map((oe,pe)=>pe===h?{...T,id:oe.id}:oe)):X(h,T),se(!1),ue("")},[x,h,V,X]),_e=n.useCallback((r,T)=>{if(a)return;const G=x[T];if(!G?.locked){if((r.ctrlKey||r.metaKey)&&r.key==="z"&&!r.shiftKey){r.preventDefault(),re();return}if((r.ctrlKey||r.metaKey)&&(r.key==="y"||r.key==="z"&&r.shiftKey)){r.preventDefault(),fe();return}if((r.ctrlKey||r.metaKey)&&r.key==="d"){r.preventDefault(),Z(T);return}if((r.ctrlKey||r.metaKey)&&r.key==="b"){r.preventDefault(),F(T,{bold:!G?.bold});return}if((r.ctrlKey||r.metaKey)&&r.key==="i"){r.preventDefault(),F(T,{italic:!G?.italic});return}if((r.ctrlKey||r.metaKey)&&r.key==="u"){r.preventDefault(),F(T,{underline:!G?.underline});return}if((r.ctrlKey||r.metaKey)&&r.key==="e"){r.preventDefault(),F(T,{strikethrough:!G?.strikethrough});return}if(r.key==="Tab"&&!r.shiftKey){r.preventDefault(),F(T,{indent:Math.min((G?.indent??0)+1,4)});return}if(r.key==="Tab"&&r.shiftKey){r.preventDefault(),F(T,{indent:Math.max((G?.indent??0)-1,0)});return}if((r.ctrlKey||r.metaKey)&&r.key==="f"&&K){r.preventDefault(),s(oe=>!oe);return}if(ne&&ce.length>0){if(r.key==="ArrowDown"){r.preventDefault(),te(oe=>Math.min(oe+1,ce.length-1));return}if(r.key==="ArrowUp"){r.preventDefault(),te(oe=>Math.max(oe-1,0));return}if(r.key==="Enter"){r.preventDefault(),xe(ce[je]);return}if(r.key==="Escape"){se(!1);return}}r.key==="Enter"&&!r.shiftKey?(r.preventDefault(),X(T)):r.key==="Backspace"&&x[T].content===""&&x.length>1?(r.preventDefault(),q(T)):r.key==="ArrowUp"&&r.altKey?(r.preventDefault(),be(T,-1)):r.key==="ArrowDown"&&r.altKey&&(r.preventDefault(),be(T,1))}},[a,x,X,q,be,re,fe,Z,F,ne,ce,je,xe,K]),we=n.useCallback((r,T)=>{const G=r.target.textContent??"";W&&G.startsWith("/")?(se(!0),ue(G.slice(1)),te(0)):ne&&se(!1),he(x);const oe=x.map((pe,Ne)=>Ne===T?{...pe,content:G}:pe);t||$(oe),i?.(oe)},[x,t,i,he,W,ne]),$e=n.useCallback((r,T)=>{ae(T),r.dataTransfer.effectAllowed="move"},[]),Re=n.useCallback((r,T)=>{r.preventDefault(),r.dataTransfer.dropEffect="move",le(T)},[]),Ie=n.useCallback((r,T)=>{if(r.preventDefault(),me===null||me===T){ae(null),le(null);return}V(G=>{const oe=[...G],[pe]=oe.splice(me,1);return oe.splice(T>me?T-1:T,0,pe),oe}),M(T>me?T-1:T),ae(null),le(null)},[me,V]);n.useEffect(()=>{if(!y||!L){p([]);return}const r=L.toLowerCase(),T=[];x.forEach((G,oe)=>{const pe=(G.content??"").toLowerCase();let Ne=0;for(;Ne<pe.length;){const Se=pe.indexOf(r,Ne);if(Se===-1)break;T.push({blockIdx:oe,start:Se,end:Se+r.length}),Ne=Se+1}}),p(T),l(0)},[L,y,x]);const ze=n.useCallback(()=>{if(u.length===0)return;const r=(f+1)%u.length;l(r),M(u[r].blockIdx)},[u,f]),Ke=n.useCallback(()=>{if(u.length===0)return;const r=(f-1+u.length)%u.length;l(r),M(u[r].blockIdx)},[u,f]),Ue=n.useCallback(()=>{if(u.length===0||!L)return;const r=u[f],T=x[r.blockIdx],G=T.content.slice(0,r.start),oe=T.content.slice(r.end);F(r.blockIdx,{content:G+m+oe})},[u,f,L,m,x,F]),Ye=n.useCallback(()=>{if(!L)return;const r=L;V(T=>T.map(G=>({...G,content:G.content.split(r).join(m)})))},[L,m,V]),Le=n.useMemo(()=>b?x.map((r,T)=>r.type==="heading"?{idx:T,level:r.level??2,text:r.content}:null).filter(Boolean):[],[x,b]),De=n.useCallback(async r=>{const T=r.target.files?.[0];if(T){if(I){const G=await I(T);F(h,{src:G})}r.target.value=""}},[I,h,F]);n.useEffect(()=>{const r=x[h];if(r){const T=D.current.get(r.id);T&&T.focus()}},[h,x]);const Pe=n.useCallback(()=>{const r=x.map(Qi).join(`
693
+ `);k?.(r)},[x,k]),ie=n.useMemo(()=>U?ea(x):null,[x,U]),[ge,ke]=n.useState(null),Me=n.useCallback((r,T)=>{a||(r.preventDefault(),ke({x:r.clientX,y:r.clientY,idx:T}))},[a]);return n.useEffect(()=>{if(!ge)return;const r=()=>ke(null);return window.addEventListener("click",r),()=>window.removeEventListener("click",r)},[ge]),e.jsxs("div",{ref:_,id:H,className:`nice-doc-editor nice-doc-editor--${d} nice-editor--${g} ${a?"nice-doc-editor--readonly":""} ${Q??""}`,style:{position:"relative",...B},role:"application","aria-label":j("docEditor.label","Document Editor"),...w,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Yl,{steps:v.Jl(O,Xi)})}),o&&!a&&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(ve.NiceButton,{size:"sm",variant:"ghost",onClick:re,title:j("docEditor.undo","Undo (Ctrl+Z)"),children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:fe,title:j("docEditor.redo","Redo (Ctrl+Y)"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ve.NiceSelect,{size:"sm",value:x[h]?.type??"paragraph",onChange:r=>ye(h,r),label:"",options:[{value:"paragraph",label:j("docEditor.paragraph","Paragraph")},{value:"heading",label:j("docEditor.heading","Heading")},{value:"list",label:j("docEditor.list","List")},{value:"code",label:j("docEditor.code","Code")},{value:"quote",label:j("docEditor.quote","Quote")},{value:"callout",label:j("docEditor.callout","Callout")},{value:"toggle",label:j("docEditor.toggle","Toggle")},{value:"divider",label:j("docEditor.divider","Divider")},{value:"image",label:j("docEditor.image","Image")},{value:"video",label:j("docEditor.video","Video")},{value:"pageBreak",label:j("docEditor.pageBreak","Page Break")}],style:{minWidth:100}}),x[h]?.type==="heading"&&e.jsx(ve.NiceSelect,{size:"sm",value:String(x[h]?.level??2),onChange:r=>F(h,{level:Number(r)}),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}}),x[h]?.type==="list"&&e.jsx(ve.NiceSelect,{size:"sm",value:x[h]?.listType??"unordered",onChange:r=>F(h,{listType:r}),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(ve.NiceButton,{size:"sm",variant:x[h]?.bold?"primary":"ghost",onClick:()=>F(h,{bold:!x[h]?.bold}),title:j("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(ve.NiceButton,{size:"sm",variant:x[h]?.italic?"primary":"ghost",onClick:()=>F(h,{italic:!x[h]?.italic}),title:j("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(ve.NiceButton,{size:"sm",variant:x[h]?.underline?"primary":"ghost",onClick:()=>F(h,{underline:!x[h]?.underline}),title:j("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(ve.NiceButton,{size:"sm",variant:x[h]?.strikethrough?"primary":"ghost",onClick:()=>F(h,{strikethrough:!x[h]?.strikethrough}),title:j("docEditor.strikethrough","Strikethrough (Ctrl+E)"),children:e.jsx("s",{children:"S"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ve.NiceButton,{size:"sm",variant:x[h]?.align==="left"?"primary":"ghost",onClick:()=>F(h,{align:"left"}),title:j("docEditor.alignLeft","Left"),children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:x[h]?.align==="center"?"primary":"ghost",onClick:()=>F(h,{align:"center"}),title:j("docEditor.alignCenter","Center"),children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:x[h]?.align==="right"?"primary":"ghost",onClick:()=>F(h,{align:"right"}),title:j("docEditor.alignRight","Right"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>F(h,{indent:Math.min((x[h]?.indent??0)+1,4)}),title:j("docEditor.indent","Indent (Tab)"),children:"??"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>F(h,{indent:Math.max((x[h]?.indent??0)-1,0)}),title:j("docEditor.outdent","Outdent (Shift+Tab)"),children:"??"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ve.NiceColorPicker,{size:"sm",label:"",value:x[h]?.color??"var(--text-primary, #000000)",onChange:r=>F(h,{color:r}),title:"Text color"}),e.jsx(ve.NiceColorPicker,{size:"sm",label:"",value:x[h]?.bgColor??"var(--bg-primary, #ffffff)",onChange:r=>F(h,{bgColor:r}),title:"Block background"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ve.NiceButton,{size:"sm",variant:x[h]?.locked?"primary":"ghost",onClick:()=>F(h,{locked:!x[h]?.locked}),title:j("docEditor.lock","Lock/Unlock block"),children:"??"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>Z(h),title:j("docEditor.duplicate","Duplicate (Ctrl+D)"),children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>q(h),title:j("docEditor.delete","Delete block"),children:"??"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>X(h),title:j("docEditor.addBlock","Add block"),children:"+"}),K&&e.jsx(ve.NiceButton,{size:"sm",variant:y?"primary":"ghost",onClick:()=>s(r=>!r),title:j("docEditor.find","Find & Replace (Ctrl+F)"),children:"??"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>R(r=>!r),title:j("docEditor.shortcuts","Keyboard shortcuts"),children:"?"}),k&&e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:Pe,children:j("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:S,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:De}),y&&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(ve.NiceTextInput,{size:"sm",placeholder:j("docEditor.findPlaceholder","Find..."),value:L,onChange:C,style:{flex:1,maxWidth:200}}),e.jsx(ve.NiceTextInput,{size:"sm",placeholder:j("docEditor.replacePlaceholder","Replace..."),value:m,onChange:c,style:{flex:1,maxWidth:200}}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:Ke,title:j("docEditor.findPrev","Previous"),children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:ze,title:j("docEditor.findNext","Next"),children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:Ue,title:j("docEditor.replaceOne","Replace"),disabled:a,children:j("docEditor.replace","Replace")}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:Ye,title:j("docEditor.replaceAll","Replace all"),disabled:a,children:j("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--text-muted, #666)"},children:u.length>0?`${f+1}/${u.length}`:"0/0"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"?"})]}),E&&e.jsx("div",{className:"nice-doc-editor__shortcuts-overlay",style:{position:"fixed",inset:0,background:"var(--nice-overlay-40, rgba(0, 0, 0, 0.4))",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>R(!1),children:e.jsxs("div",{style:{background:"var(--bg-primary, #fff)",borderRadius:8,padding:24,maxWidth:420,width:"90%",boxShadow:"0 8px 32px var(--nice-overlay-20, rgba(0, 0, 0, 0.2))"},onClick:r=>r.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px"},children:j("docEditor.shortcutsTitle","Keyboard Shortcuts")}),e.jsx("table",{style:{width:"100%",fontSize:"0.875em",borderCollapse:"collapse"},children:e.jsx("tbody",{children:[["Ctrl+B",j("docEditor.bold","Bold")],["Ctrl+I",j("docEditor.italic","Italic")],["Ctrl+U",j("docEditor.underline","Underline")],["Ctrl+E",j("docEditor.strikethrough","Strikethrough")],["Ctrl+D",j("docEditor.duplicate","Duplicate block")],["Ctrl+Z",j("docEditor.undo","Undo")],["Ctrl+Y",j("docEditor.redo","Redo")],["Ctrl+F",j("docEditor.find","Find & Replace")],["Enter",j("docEditor.newBlock","New block")],["Backspace",j("docEditor.deleteEmpty","Delete empty block")],["Alt+?",j("docEditor.moveUp","Move block up")],["Alt+?",j("docEditor.moveDown","Move block down")],["Tab",j("docEditor.indent","Indent")],["Shift+Tab",j("docEditor.outdent","Outdent")],["/",j("docEditor.slashCmd","Slash commands")]].map(([r,T])=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--border-color, #eee)"},children:[e.jsx("td",{style:{padding:"4px 8px",fontFamily:"monospace",fontWeight:600},children:r}),e.jsx("td",{style:{padding:"4px 8px"},children:T})]},r))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>R(!1),children:j("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[b&&Le.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:j("docEditor.toc","Contents")}),Le.map(r=>e.jsx("div",{style:{padding:"3px 8px",paddingLeft:8+(r.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:r.idx===h?"var(--nice-primary-bg, #e8f0fe)":void 0},onClick:()=>M(r.idx),title:r.text,children:r.text||j("docEditor.untitled","Untitled")},r.idx))]}),e.jsx("div",{className:"nice-doc-editor__body",style:{flex:1},children:x.map((r,T)=>e.jsxs("div",{className:`nice-doc-editor__block nice-doc-editor__block--${r.type} ${T===h?"nice-doc-editor__block--focused":""} ${ee===T?"nice-doc-editor__block--drop-target":""} ${r.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>M(T),onContextMenu:G=>Me(G,T),draggable:!a&&!r.locked,onDragStart:G=>$e(G,T),onDragOver:G=>Re(G,T),onDrop:G=>Ie(G,T),onDragEnd:()=>{ae(null),le(null)},style:{opacity:me===T?.4:1,marginLeft:(r.indent??0)*24},children:[!a&&!r.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:j("docEditor.drag","Drag to reorder"),children:"?"}),r.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:"??"}),r.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):r.type==="pageBreak"?e.jsxs("div",{className:"nice-doc-editor__page-break",style:{borderTop:"2px dashed var(--nice-border, #ccc)",textAlign:"center",padding:4,fontSize:"0.75em",color:"var(--text-muted, #999)"},children:["� ",j("docEditor.pageBreak","Page Break")," �"]}):r.type==="image"||r.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:r.src?r.type==="image"?e.jsx("img",{src:r.src,alt:r.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:r.src,controls:!0,className:"nice-doc-editor__video",style:{maxWidth:"100%"}}):!a&&e.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[e.jsx(ve.NiceTextInput,{size:"sm",placeholder:j("docEditor.mediaUrl",r.type==="image"?"Image URL":"Video URL"),value:r.src??"",onChange:G=>F(T,{src:G})}),I&&e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{M(T),S.current?.click()},children:"??"})]})}):r.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:r.bgColor??"#f0f7ff",borderRadius:4,color:r.color},children:[e.jsx("span",{style:{fontSize:"1.2em"},children:r.icon??"??"}),e.jsx("div",{ref:G=>{G&&D.current.set(r.id,G)},className:"nice-doc-editor__content",contentEditable:!a&&!r.locked,suppressContentEditableWarning:!0,onInput:G=>we(G,T),onFocus:()=>M(T),onKeyDown:G=>_e(G,T),"data-placeholder":j("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true",style:{flex:1,outline:"none"},children:r.content})]}):r.type==="toggle"?e.jsxs("details",{open:r.open,className:"nice-doc-editor__toggle",onToggle:G=>F(T,{open:G.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:r.content.split(`
694
+ `)[0]||j("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:G=>{G&&D.current.set(r.id,G)},className:"nice-doc-editor__content",contentEditable:!a&&!r.locked,suppressContentEditableWarning:!0,onInput:G=>we(G,T),onFocus:()=>M(T),onKeyDown:G=>_e(G,T),role:"textbox","aria-multiline":"true",style:{padding:"4px 0"},children:r.content.split(`
695
+ `).slice(1).join(`
696
+ `)})]}):r.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!a&&e.jsx(ve.NiceTextInput,{size:"sm",value:r.language??"",onChange:G=>F(T,{language:G}),placeholder:"Language",style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:G=>{G&&D.current.set(r.id,G)},className:"nice-doc-editor__content",contentEditable:!a&&!r.locked,suppressContentEditableWarning:!0,onInput:G=>we(G,T),onFocus:()=>M(T),onKeyDown:G=>_e(G,T),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:r.content})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:G=>{G&&D.current.set(r.id,G)},className:"nice-doc-editor__content",contentEditable:!a&&!r.locked,suppressContentEditableWarning:!0,style:{textAlign:r.align,fontWeight:r.bold?"bold":void 0,fontStyle:r.italic?"italic":void 0,textDecoration:[r.underline?"underline":"",r.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:r.color,backgroundColor:r.bgColor},onInput:G=>we(G,T),onFocus:()=>M(T),onKeyDown:G=>_e(G,T),"data-placeholder":!r.content&&N?N:void 0,role:"textbox","aria-multiline":"true",children:r.content}),ne&&T===h&&ce.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 var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",listStyle:"none",margin:0,padding:4,minWidth:180,maxHeight:240,overflow:"auto"},children:ce.map((G,oe)=>e.jsxs("li",{className:oe===je?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:oe===je?"var(--nice-primary-bg, #e8f0fe)":void 0},onMouseDown:pe=>{pe.preventDefault(),xe(G)},onMouseEnter:()=>te(oe),children:[e.jsx("span",{style:{width:24,textAlign:"center"},children:G.icon}),e.jsx("span",{children:G.label})]},`${G.type}-${G.label}`))})]})]},r.id))})]}),ge&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:ge.x,top:ge.y,zIndex:1e3,background:"var(--bg-primary, #fff)",border:"1px solid var(--border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",padding:4,minWidth:160},children:[e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{Z(ge.idx),ke(null)},children:"? Duplicate"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{X(ge.idx),ke(null)},children:"+ Insert below"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{be(ge.idx,-1),ke(null)},children:"? Move up"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{be(ge.idx,1),ke(null)},children:"? Move down"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{F(ge.idx,{locked:!x[ge.idx]?.locked}),ke(null)},children:x[ge.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:"var(--nice-danger-dark, #d32f2f)"},onClick:()=>{q(ge.idx),ke(null)},children:"?? Delete"})]}),U&&ie&&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:[ie.words," ",j("docEditor.words","words")]}),e.jsxs("span",{children:[ie.chars," ",j("docEditor.chars","characters")]}),e.jsxs("span",{children:[x.length," ",j("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",ie.readingTime," ",j("docEditor.readingTime","min read")]})]})]})});Nn.displayName="NiceDocumentEditor";const ta=["street","streetNumber","apartment","city","postalCode","state","country"],et={street:"Street",streetNumber:"Number",apartment:"Apt/Suite",city:"City",postalCode:"Postal Code",state:"State/Province",country:"Country"},Cn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:d,readOnly:g,size:N="md",name:k,id:I,className:P,style:W,accessMode:U,value:b={},onChange:K,fields:O=ta,placeholders:Q={},countries:B,layout:Y="vertical",countryFirst:w=!1,validatePostalCode:_},H)=>{const j=v.$c(U,I),z=j==="hidden";j==="disabled"&&(d=!0),j==="readOnly"&&(g=!0);const{t:$}=v.Gt(),x=v.hc(I),h=n.useCallback((y,s)=>{K?.({...b,[y]:s})},[b,K]),M=n.useMemo(()=>{if(_&&b.postalCode)return _(b.postalCode,b.country)},[_,b.postalCode,b.country]),D=n.useMemo(()=>w&&O.includes("country")?["country",...O.filter(y=>y!=="country")]:O,[O,w]),S=`nice-address nice-address--${Y} nice-size-${N}`;return z?null:e.jsxs("div",{ref:H,id:x,className:`${S}${P?` ${P}`:""}${a?" nice-error":""}${d?" nice-disabled":""}`,style:W,role:"group","aria-label":t??$("address","Address"),children:[t&&e.jsxs("label",{className:"nice-address__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-address__fields",children:D.map(y=>y==="country"&&B?e.jsxs("div",{className:`nice-address__field nice-address__field--${y}`,children:[e.jsx("label",{className:"nice-address__field-label",children:$(y,et[y])}),e.jsxs("select",{className:"nice-input nice-select",value:b.country??"",onChange:s=>h("country",s.target.value),disabled:d,"aria-label":$(y,et[y]),children:[e.jsx("option",{value:"",children:Q.country??$("selectCountry","— Select country —")}),B.map(s=>e.jsx("option",{value:s.code,children:s.name},s.code))]})]},y):e.jsxs("div",{className:`nice-address__field nice-address__field--${y}`,children:[e.jsx("label",{className:"nice-address__field-label",children:$(y,et[y])}),e.jsx("input",{className:`nice-input${y==="postalCode"&&M?" nice-input--error":""}`,type:"text",name:k?`${k}.${y}`:y,value:b[y]??"",onChange:s=>h(y,s.target.value),placeholder:Q[y]??"",disabled:d,readOnly:g,"aria-label":$(y,et[y])}),y==="postalCode"&&M&&e.jsx("span",{className:"nice-error-text",children:M})]},y))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});Cn.displayName="NiceAddressInput";const na=[{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"}],Sn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:d,readOnly:g,size:N="md",name:k,id:I,className:P,style:W,accessMode:U,value:b,onChange:K,onBlur:O,currency:Q="PLN",onCurrencyChange:B,currencies:Y=na,useMinorUnit:w=!1,min:_,max:H,locale:j,placeholder:z,showCurrencySelector:$},x)=>{const h=v.$c(U,I),M=h==="hidden";h==="disabled"&&(d=!0),h==="readOnly"&&(g=!0);const{t:D}=v.Gt(),S=v.hc(I),y=n.useMemo(()=>Y.find(u=>u.code===Q)??Y[0],[Q,Y]),s=y?.decimals??2,L=n.useMemo(()=>b==null?"":(w?b/Math.pow(10,s):b).toFixed(s),[b,w,s]),C=n.useCallback(u=>{const p=u.replace(/[^\d.,\-]/g,"").replace(",",".");if(p===""||p==="-"){K?.(null);return}const f=parseFloat(p);if(isNaN(f))return;const l=w?Math.round(f*Math.pow(10,s)):f;_!=null&&l<_||H!=null&&l>H||K?.(l)},[K,w,s,_,H]),m=$??Y.length>1,c=n.useMemo(()=>{if(b==null)return"";const u=w?b/Math.pow(10,s):b;try{return new Intl.NumberFormat(j,{style:"currency",currency:y?.code??"USD",minimumFractionDigits:s}).format(u)}catch{return`${u.toFixed(s)} ${y?.code}`}},[b,w,s,j,y]);return M?null:e.jsxs("div",{ref:x,id:S,className:`nice-currency nice-size-${N}${P?` ${P}`:""}${a?" nice-error":""}${d?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-currency__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-currency__row",children:[m&&e.jsx("select",{className:"nice-currency__select nice-select",value:Q,onChange:u=>B?.(u.target.value),disabled:d,"aria-label":D("currency","Currency"),children:Y.map(u=>e.jsxs("option",{value:u.code,children:[u.symbol," ",u.code]},u.code))}),!m&&e.jsx("span",{className:"nice-currency__symbol",children:y?.symbol}),e.jsx("input",{className:"nice-input nice-currency__amount",type:"text",inputMode:"decimal",name:k,value:L,onChange:u=>C(u.target.value),onBlur:O,placeholder:z??`0.${"0".repeat(s)}`,disabled:d,readOnly:g,"aria-label":D("amount","Amount")})]}),c&&b!=null&&e.jsx("span",{className:"nice-currency__formatted",children:c}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});Sn.displayName="NiceCurrencyInput";const ia=[{target:".nice-invoice-lines",titleKey:"tutorial.invoiceLineEditor.intro.title",title:"Invoice lines",contentKey:"tutorial.invoiceLineEditor.intro.content",content:"Add line items with quantity, unit price, VAT and discount — net, gross and the VAT breakdown are calculated automatically.",placement:"auto"}];let aa=1;function oa(t){return{id:`new-${aa++}`,description:"",quantity:1,unitPrice:0,vatRate:t,discount:0,unit:"szt."}}function Mn(t){const a=t.quantity*t.unitPrice*(1-(t.discount??0)/100),o=Math.round(a*100)/100,d=Math.round(o*(t.vatRate??0)/100*100)/100;return{...t,netAmount:o,grossAmount:o+d}}function ra(t){const i=t.map(Mn),a=i.reduce((k,I)=>k+(I.netAmount??0),0),o=i.reduce((k,I)=>k+(I.grossAmount??0),0),d=o-a,g=new Map;for(const k of i){const I=k.vatRate??0,P=g.get(I)??{base:0,amount:0};P.base+=k.netAmount??0,P.amount+=(k.grossAmount??0)-(k.netAmount??0),g.set(I,P)}const N=Array.from(g.entries()).map(([k,I])=>({rate:k,base:Math.round(I.base*100)/100,amount:Math.round(I.amount*100)/100}));return{totalNet:Math.round(a*100)/100,totalVat:Math.round(d*100)/100,totalGross:Math.round(o*100)/100,vatBreakdown:N}}const $n=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:d,readOnly:g,size:N="md",name:k,id:I,className:P,style:W,accessMode:U,value:b=[],onChange:K,onTotalsChange:O,currencySymbol:Q="zł",defaultVatRate:B=23,vatRates:Y=[0,5,8,23],units:w=["szt.","h","kg","m","usł."],showDiscount:_=!0,showUnit:H=!0,showTotals:j=!0,editable:z=!0,maxLines:$,tutorial:x},h)=>{const M=v.$c(U,I),D=M==="hidden";M==="disabled"&&(d=!0),M==="readOnly"&&(g=!0);const{t:S}=v.Gt(),y=v.hc(I),s=n.useMemo(()=>b.map(Mn),[b]),L=n.useMemo(()=>ra(b),[b]);n.useEffect(()=>{O?.(L)},[L,O]);const C=n.useCallback((p,f,l)=>{const E=[...b];E[p]={...E[p],[f]:l},K?.(E)},[b,K]),m=n.useCallback(()=>{$&&b.length>=$||K?.([...b,oa(B)])},[b,K,B,$]),c=n.useCallback(p=>{K?.(b.filter((f,l)=>l!==p))},[b,K]),u=p=>`${p.toFixed(2)} ${Q}`;return D?null:e.jsxs("div",{ref:h,id:y,className:`nice-invoice-lines nice-size-${N}${P?` ${P}`:""}${a?" nice-error":""}${d?" nice-disabled":""}`,style:{position:"relative",...W},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Yl,{steps:v.Jl(x,ia)})}),t&&e.jsxs("label",{className:"nice-invoice-lines__label",children:[t,o&&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:S("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:S("qty","Qty")}),H&&e.jsx("th",{className:"nice-il__th-unit",children:S("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:S("unitPrice","Unit Price")}),_&&e.jsx("th",{className:"nice-il__th-disc",children:S("discount","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:S("vat","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:S("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:S("gross","Gross")}),z&&!g&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:s.map((p,f)=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-il__cell-num",children:f+1}),e.jsx("td",{className:"nice-il__cell-desc",children:e.jsx("input",{className:"nice-input",type:"text",value:p.description,onChange:l=>C(f,"description",l.target.value),disabled:d,readOnly:g,placeholder:S("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:p.quantity,onChange:l=>C(f,"quantity",parseFloat(l.target.value)||0),disabled:d,readOnly:g,min:0,step:"any"})}),H&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:p.unit??"",onChange:l=>C(f,"unit",l.target.value),disabled:d,children:w.map(l=>e.jsx("option",{value:l,children:l},l))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:p.unitPrice,onChange:l=>C(f,"unitPrice",parseFloat(l.target.value)||0),disabled:d,readOnly:g,min:0,step:"0.01"})}),_&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:p.discount??0,onChange:l=>C(f,"discount",parseFloat(l.target.value)||0),disabled:d,readOnly:g,min:0,max:100})}),e.jsx("td",{className:"nice-il__cell-vat",children:e.jsx("select",{className:"nice-select",value:p.vatRate??0,onChange:l=>C(f,"vatRate",parseInt(l.target.value,10)),disabled:d,children:Y.map(l=>e.jsxs("option",{value:l,children:[l,"%"]},l))})}),e.jsx("td",{className:"nice-il__cell-net",children:u(p.netAmount??0)}),e.jsx("td",{className:"nice-il__cell-gross",children:u(p.grossAmount??0)}),z&&!g&&e.jsx("td",{className:"nice-il__cell-actions",children:e.jsx("button",{type:"button",className:"nice-btn nice-btn--icon nice-btn--sm",onClick:()=>c(f),disabled:d,title:S("remove","Remove"),"aria-label":S("remove","Remove"),children:e.jsx(v.oa,{name:"close",size:14})})})]},p.id))})]}),z&&!g&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:m,disabled:d||$!=null&&b.length>=$,children:["+ ",S("addLine","Add line")]}),j&&e.jsxs("div",{className:"nice-invoice-lines__totals",children:[e.jsxs("div",{className:"nice-il__total-row",children:[e.jsxs("span",{children:[S("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:u(L.totalNet)})]}),L.vatBreakdown.map(p=>e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--vat",children:[e.jsxs("span",{children:["VAT ",p.rate,"%:"]}),e.jsx("span",{className:"nice-il__total-value",children:u(p.amount)})]},p.rate)),e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--gross",children:[e.jsxs("span",{children:[S("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:u(L.totalGross)})]})]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});$n.displayName="NiceInvoiceLineEditor";const En=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:d,readOnly:g,size:N="md",name:k,id:I,className:P,style:W,accessMode:U,value:b=[],onChange:K,contacts:O=[],onSearch:Q,searchDelay:B=300,multiple:Y=!1,placeholder:w,onContactClick:_,maxSelections:H},j)=>{const z=v.$c(U,I),$=z==="hidden";z==="disabled"&&(d=!0),z==="readOnly"&&(g=!0);const{t:x}=v.Gt(),h=v.hc(I),[M,D]=n.useState(""),[S,y]=n.useState([]),[s,L]=n.useState(!1),[C,m]=n.useState(!1),c=n.useMemo(()=>{const l=[...O,...S],E=new Map(l.map(R=>[R.id,R]));return b.map(R=>E.get(R)).filter(Boolean)},[b,O,S]),u=n.useCallback(l=>{if(D(l),l.length<1){y([]),L(!1);return}if(Q){m(!0);const J=setTimeout(async()=>{const A=await Q(l);y(A),L(!0),m(!1)},B);return()=>clearTimeout(J)}const E=l.toLowerCase(),R=O.filter(J=>J.name.toLowerCase().includes(E)||J.email?.toLowerCase().includes(E)||J.phone?.includes(l));y(R),L(!0)},[Q,O,B]),p=n.useCallback(l=>{if(Y)if(b.includes(l.id))K?.(b.filter(E=>E!==l.id));else{if(H&&b.length>=H)return;K?.([...b,l.id])}else K?.([l.id]),L(!1),D("")},[b,K,Y,H]),f=n.useCallback(l=>{K?.(b.filter(E=>E!==l))},[b,K]);return $?null:e.jsxs("div",{ref:j,id:h,className:`nice-contact-picker nice-size-${N}${P?` ${P}`:""}${a?" nice-error":""}${d?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-contact-picker__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),c.length>0&&e.jsx("div",{className:"nice-contact-picker__chips",children:c.map(l=>e.jsxs("span",{className:"nice-contact-picker__chip",onClick:()=>_?.(l),children:[l.avatarUrl&&e.jsx("img",{src:l.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:l.name}),!g&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:E=>{E.stopPropagation(),f(l.id)},disabled:d,"aria-label":x("controls.remove","Remove"),children:e.jsx(v.oa,{name:"close",size:14})})]},l.id))}),!g&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{className:"nice-input",type:"text",value:M,onChange:l=>u(l.target.value),onFocus:()=>M.length>0&&L(!0),onBlur:()=>setTimeout(()=>L(!1),200),placeholder:w??x("searchContacts","Search contacts…"),disabled:d,"aria-label":x("searchContacts","Search contacts")}),C&&e.jsx("span",{className:"nice-contact-picker__spinner",children:e.jsx(v.oa,{name:"refresh",size:16})})]}),s&&S.length>0&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",children:S.map(l=>e.jsxs("div",{className:`nice-contact-picker__option${b.includes(l.id)?" nice-contact-picker__option--selected":""}`,role:"option","aria-selected":b.includes(l.id),onClick:()=>p(l),children:[l.avatarUrl&&e.jsx("img",{src:l.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:l.name}),l.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:l.subtitle}),l.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:l.email})]}),l.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:e.jsx(v.oa,{name:l.type==="person"?"user":"building",size:16})})]},l.id))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});En.displayName="NiceContactPicker";const sa=[{target:".nice-pdf-annotation",titleKey:"tutorial.pdfAnnotationEditor.intro.title",title:"PDF annotations",contentKey:"tutorial.pdfAnnotationEditor.intro.content",content:"Pick a tool from the toolbar (highlight, underline, freehand, text…), mark up the page, navigate pages and zoom as needed.",placement:"auto"}],ca=["highlight","underline","strikethrough","freehand","text","rect","arrow"],la={highlight:"edit",underline:"type",strikethrough:"type",freehand:"edit",text:"type",rect:"box",arrow:"arrow-right",stamp:"tag"},Tn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:d,readOnly:g,size:N="md",id:k,className:I,style:P,accessMode:W,src:U,annotations:b=[],onAnnotationsChange:K,activeTool:O,onToolChange:Q,currentPage:B=1,onPageChange:Y,totalPages:w=1,defaultColor:_="var(--nice-warning, #ffff00)",tools:H=ca,author:j,zoom:z=1,onZoomChange:$,onAnnotationClick:x,onAnnotationDelete:h,tutorial:M},D)=>{const S=v.$c(W,k),y=S==="hidden";S==="disabled"&&(d=!0),S==="readOnly"&&(g=!0);const{t:s}=v.Gt(),L=v.hc(k),C=b.filter(R=>R.page===B),m=n.useCallback(R=>{Q?.(O===R?null:R)},[O,Q]),c=n.useCallback(R=>{if(g||!O||O==="freehand")return;const J=R.currentTarget.getBoundingClientRect(),A=(R.clientX-J.left)/J.width,he=(R.clientY-J.top)/J.height,re={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:O,page:B,x:A,y:he,color:_,author:j,createdAt:new Date().toISOString(),text:O==="text"?"":void 0};K?.([...b,re])},[g,O,B,_,j,b,K]);if(y)return null;const u=t?e.jsxs("div",{className:"nice-pdf-annotation__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}):void 0,p=g?void 0:e.jsxs("div",{className:"nice-pdf-annotation__toolbar",children:[H.map(R=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${O===R?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>m(R),disabled:d,title:s(`pdfTool_${R}`,R),children:e.jsx(v.oa,{name:la[R],size:16})},R)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:d,onClick:()=>$?.(Math.max(.25,z-.25)),title:s("zoomOut","Zoom out"),"aria-label":s("zoomOut","Zoom out"),children:e.jsx(v.oa,{name:"minus",size:16})}),e.jsxs("span",{className:"nice-pdf-annotation__zoom",children:[Math.round(z*100),"%"]}),e.jsx("button",{type:"button",disabled:d,onClick:()=>$?.(Math.min(4,z+.25)),title:s("zoomIn","Zoom in"),"aria-label":s("zoomIn","Zoom in"),children:e.jsx(v.oa,{name:"plus",size:16})})]}),f=e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:d||B<=1,onClick:()=>Y?.(B-1),"aria-label":s("prevPage","Previous page"),children:e.jsx(v.oa,{name:"chevron-left",size:16})}),e.jsx("span",{children:s("pageOf","{page} / {total}").replace("{page}",String(B)).replace("{total}",String(w))}),e.jsx("button",{type:"button",disabled:d||B>=w,onClick:()=>Y?.(B+1),"aria-label":s("nextPage","Next page"),children:e.jsx(v.oa,{name:"chevron-right",size:16})})]}),E=!!i||!!a&&typeof a=="string"?e.jsxs(e.Fragment,{children:[i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]}):void 0;return e.jsx(Wt.NiceAppShell,{ref:D,flush:!0,id:L,className:`nice-pdf-annotation nice-size-${N}${I?` ${I}`:""}${a?" nice-error":""}${d?" nice-disabled":""}`,style:P,menubar:u,toolbar:p,bottomPanel:f,statusBar:E,children:e.jsxs("div",{style:{position:"relative",height:"100%",overflow:"auto"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Yl,{steps:v.Jl(M,sa)})}),e.jsxs("div",{className:"nice-pdf-annotation__viewport",style:{transform:`scale(${z})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:U,className:"nice-pdf-annotation__frame",title:s("pdfViewer","PDF Viewer")}),e.jsx("div",{className:"nice-pdf-annotation__layer",onClick:c,children:C.map(R=>e.jsxs("div",{className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${R.tool}`,style:{left:`${R.x*100}%`,top:`${R.y*100}%`,backgroundColor:R.color},onClick:J=>{J.stopPropagation(),x?.(R)},title:R.text??R.tool,children:[R.text&&e.jsx("span",{children:R.text}),!g&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:J=>{J.stopPropagation(),h?.(R.id)},"aria-label":s("delete","Delete"),children:e.jsx(v.oa,{name:"close",size:14})})]},R.id))})]})]})})});Tn.displayName="NicePDFAnnotationEditor";const Rn=n.forwardRef(({label:t,helperText:i,error:a,disabled:o,readOnly:d,size:g="md",id:N,className:k,style:I,accessMode:P,pages:W,selectedPageId:U,content:b="",contentFormat:K="html",editing:O=!1,onPageSelect:Q,onContentChange:B,onSave:Y,onCreatePage:w,onDeletePage:_,onEditToggle:H,onVersionHistory:j,sidebarWidth:z=260,sidebarCollapsed:$=!1,onSidebarToggle:x,searchable:h=!0,onSearch:M},D)=>{const S=v.$c(P,N),y=S==="hidden";S==="disabled"&&(o=!0),S==="readOnly"&&(d=!0);const{t:s}=v.Gt(),L=v.hc(N),[C,m]=n.useState(""),[c,u]=n.useState(""),[p,f]=n.useState(!1),l=n.useMemo(()=>{const A=he=>{for(const re of he){if(re.id===U)return re;if(re.children){const fe=A(re.children);if(fe)return fe}}};return A(W)},[W,U]),E=n.useCallback(A=>{m(A),M?.(A)},[M]),R=n.useCallback(()=>{c.trim()&&(w?.(U??null,c.trim()),u(""),f(!1))},[c,U,w]),J=(A,he=0)=>e.jsx("ul",{className:"nice-wiki__tree",style:{paddingLeft:he>0?16:0},children:A.map(re=>e.jsxs("li",{className:"nice-wiki__tree-item",children:[e.jsxs("div",{className:`nice-wiki__tree-node${re.id===U?" nice-wiki__tree-node--active":""}${re.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>Q?.(re),role:"treeitem","aria-selected":re.id===U,children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:e.jsx(v.oa,{name:re.children?.length?"folder":"file",size:14})}),e.jsx("span",{className:"nice-wiki__tree-title",children:re.title}),re.isDraft&&e.jsx("span",{className:"nice-wiki__tree-draft",children:s("draft","Draft")})]}),re.children&&re.children.length>0&&J(re.children,he+1)]},re.id))});return y?null:e.jsxs("div",{ref:D,id:L,className:`nice-wiki nice-size-${g}${k?` ${k}`:""}${o?" nice-disabled":""}`,style:I,children:[!$&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:z},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("span",{className:"nice-wiki__sidebar-title",children:t??s("wiki","Wiki")}),x&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-toggle",onClick:()=>x(!0),"aria-label":s("collapseSidebar","Collapse sidebar"),children:e.jsx(v.oa,{name:"chevron-left",size:16})})]}),h&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:C,onChange:A=>E(A.target.value),placeholder:s("searchPages","Search pages…"),disabled:o}),e.jsx("div",{className:"nice-wiki__page-tree",role:"tree",children:J(W)}),w&&!d&&e.jsx("div",{className:"nice-wiki__sidebar-footer",children:p?e.jsxs("div",{className:"nice-wiki__create-form",children:[e.jsx("input",{type:"text",className:"nice-input",value:c,onChange:A=>u(A.target.value),placeholder:s("pageTitle","Page title"),onKeyDown:A=>A.key==="Enter"&&R(),disabled:o}),e.jsx("button",{type:"button",disabled:o||!c.trim(),onClick:R,"aria-label":s("create","Create"),children:e.jsx(v.oa,{name:"check",size:14})}),e.jsx("button",{type:"button",onClick:()=>f(!1),"aria-label":s("cancel","Cancel"),children:e.jsx(v.oa,{name:"close",size:14})})]}):e.jsxs("button",{type:"button",className:"nice-wiki__add-page",onClick:()=>f(!0),disabled:o,children:[e.jsx(v.oa,{name:"plus",size:14})," ",s("newPage","New page")]})})]}),$&&x&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-expand",onClick:()=>x(!1),"aria-label":s("expandSidebar","Expand sidebar"),children:e.jsx(v.oa,{name:"chevron-right",size:16})}),e.jsx("main",{className:"nice-wiki__content",children:l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-wiki__content-header",children:[e.jsx("h1",{className:"nice-wiki__page-title",children:l.title}),e.jsxs("div",{className:"nice-wiki__content-actions",children:[H&&!d&&e.jsx("button",{type:"button",disabled:o,onClick:()=>H(!O),children:O?s("preview","Preview"):s("edit","Edit")}),j&&e.jsx("button",{type:"button",disabled:o,onClick:()=>j(l.id),children:s("history","History")}),_&&!d&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:o,onClick:()=>_(l.id),children:s("delete","Delete")})]})]}),l.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[l.updatedBy&&e.jsxs("span",{children:[s("lastEditedBy","Last edited by")," ",l.updatedBy]}),e.jsx("span",{children:new Date(l.updatedAt).toLocaleDateString()})]}),O?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("textarea",{className:"nice-wiki__editor-textarea",value:b,onChange:A=>B?.(A.target.value),disabled:o}),Y&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:o,onClick:()=>Y(l.id,b),children:s("save","Save")})]}):e.jsx("div",{className:"nice-wiki__viewer",children:K==="html"?e.jsx("div",{className:"nice-wiki__html",dangerouslySetInnerHTML:{__html:v.lc(b)}}):e.jsx("pre",{className:"nice-wiki__markdown",children:b})})]}):e.jsx("div",{className:"nice-wiki__empty",children:e.jsx("p",{children:s("selectPage","Select a page from the sidebar or create a new one.")})})}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});Rn.displayName="NiceWiki";const da=[{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"}],In=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:d,readOnly:g,size:N="md",name:k,id:I,className:P,style:W,accessMode:U,value:b="",onChange:K,countryCode:O="PL",onCountryChange:Q,countries:B=da,showCountrySelector:Y=!0,autoPrefixVat:w=!0,validationResult:_,onValidateRequest:H,placeholder:j},z)=>{const $=v.$c(U,I),x=$==="hidden";$==="disabled"&&(d=!0),$==="readOnly"&&(g=!0);const{t:h}=v.Gt(),M=v.hc(I),D=n.useMemo(()=>B.find(C=>C.code===O)??B[0],[B,O]),S=n.useCallback(C=>{let m=C.toUpperCase();return D&&m.startsWith(D.prefix)&&(m=m.slice(D.prefix.length)),D?D.pattern.test(m):m.length>0},[D]),y=n.useCallback(C=>{const m=C.target.value.replace(/\s/g,"");K?.(m,S(m))},[K,S]),s=w&&b&&D&&!b.toUpperCase().startsWith(D.prefix)?`${D.prefix}${b}`:b,L=S(b);return x?null:e.jsxs("div",{ref:z,id:M,className:`nice-vat-input nice-size-${N}${P?` ${P}`:""}${a||!L&&b.length>0?" nice-error":""}${d?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-vat-input__label",htmlFor:`${M}-input`,children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-vat-input__row",children:[Y&&e.jsx("select",{className:"nice-vat-input__country",value:O,onChange:C=>Q?.(C.target.value),disabled:d||g,children:B.map(C=>e.jsx("option",{value:C.code,children:C.prefix},C.code))}),e.jsx("input",{id:`${M}-input`,className:"nice-input nice-vat-input__field",type:"text",name:k,value:b,onChange:y,readOnly:g,disabled:d,placeholder:j??D?.placeholder,required:o,"aria-invalid":!L&&b.length>0}),H&&b.length>0&&e.jsx("button",{type:"button",className:"nice-vat-input__verify",disabled:d||!L,onClick:()=>H(w?s:b,O),title:h("verifyVat","Verify VAT number"),"aria-label":h("verifyVat","Verify VAT number"),children:e.jsx(v.oa,{name:"search",size:16})})]}),_&&e.jsxs("div",{className:`nice-vat-input__result nice-vat-input__result--${_.valid?"valid":"invalid"}`,children:[e.jsx(v.oa,{name:_.valid?"check":"close",size:16})," ",_.companyName??_.error??(_.valid?h("vatValid","VAT number valid"):h("vatInvalid","VAT number invalid"))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});In.displayName="NiceVatInput";const ma=[{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"}],An=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:d,readOnly:g,size:N="md",name:k,id:I,className:P,style:W,accessMode:U,value:b,onChange:K,rates:O,countryCode:Q,placeholder:B,showPercentage:Y=!0},w)=>{const _=v.$c(U,I),H=_==="hidden";_==="disabled"&&(d=!0),_==="readOnly"&&(g=!0);const{t:j}=v.Gt(),z=v.hc(I),$=n.useMemo(()=>{const h=O??ma;return Q?h.filter(M=>!M.countryCode||M.countryCode===Q):h},[O,Q]),x=n.useCallback(h=>{const M=h.target.value,D=$.find(S=>S.id===M);D&&K?.(M,D)},[K,$]);return H?null:e.jsxs("div",{ref:w,id:z,className:`nice-tax-rate nice-size-${N}${P?` ${P}`:""}${a?" nice-error":""}${d?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-tax-rate__label",htmlFor:`${z}-select`,children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("select",{id:`${z}-select`,className:"nice-select nice-tax-rate__select",name:k,value:b??"",onChange:x,disabled:d||g,required:o,children:[e.jsx("option",{value:"",disabled:!0,children:B??j("selectRate","Select rate…")}),$.map(h=>e.jsxs("option",{value:h.id,children:[h.label,Y&&h.category!=="exempt"?` (${(h.rate*100).toFixed(0)}%)`:""]},h.id))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});An.displayName="NiceTaxRatePicker";const ua={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)"},zn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:d,readOnly:g,size:N="md",name:k,id:I,className:P,style:W,accessMode:U,value:b,onChange:K,accounts:O,treeView:Q=!1,placeholder:B,searchable:Y=!0,showType:w=!0,onSearch:_},H)=>{const j=v.$c(U,I),z=j==="hidden";j==="disabled"&&(d=!0),j==="readOnly"&&(g=!0);const{t:$}=v.Gt(),x=v.hc(I),[h,M]=n.useState(""),[D,S]=n.useState(!1),y=n.useMemo(()=>{const c=u=>{for(const p of u){if(p.code===b)return p;if(p.children){const f=c(p.children);if(f)return f}}};return c(O)},[O,b]),s=n.useMemo(()=>{const c=[],u=p=>{for(const f of p)c.push(f),f.children&&u(f.children)};return u(O),c},[O]),L=n.useMemo(()=>{if(!h)return s;const c=h.toLowerCase();return s.filter(u=>u.code.toLowerCase().includes(c)||u.name.toLowerCase().includes(c))},[s,h]),C=n.useCallback(c=>{M(c),_?.(c),S(!0)},[_]),m=n.useCallback(c=>{K?.(c.code,c),S(!1),M("")},[K]);return z?null:e.jsxs("div",{ref:H,id:x,className:`nice-account-picker nice-size-${N}${P?` ${P}`:""}${a?" nice-error":""}${d?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-account-picker__label",htmlFor:`${x}-input`,children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-account-picker__control",children:Y&&!g?e.jsx("input",{id:`${x}-input`,className:"nice-input",type:"text",value:D?h:y?`${y.code} — ${y.name}`:"",onChange:c=>C(c.target.value),onFocus:()=>{M(""),S(!0)},onBlur:()=>setTimeout(()=>S(!1),200),placeholder:B??$("searchAccount","Search account…"),disabled:d,required:o}):e.jsx("div",{className:"nice-account-picker__display",children:y?`${y.code} — ${y.name}`:B??$("selectAccount","Select account…")})}),D&&L.length>0&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",children:L.map(c=>e.jsxs("div",{className:`nice-account-picker__option${c.code===b?" nice-account-picker__option--selected":""}${c.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":c.code===b,onClick:()=>m(c),children:[w&&c.type&&e.jsx("span",{className:"nice-account-picker__type",style:{color:ua[c.type]},title:c.type,children:e.jsx(v.oa,{name:"circle",size:10})}),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}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});zn.displayName="NiceAccountPicker";const Dn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:d,readOnly:g,size:N="md",id:k,className:I,style:P,accessMode:W,mode:U="manual",onScan:b,onModeChange:K,beepOnScan:O=!0,beepFrequency:Q=1800,beepDuration:B=150,placeholder:Y,scanHistory:w=[],showHistory:_=!0,maxHistory:H=10,autoFocus:j=!0,onCameraFrame:z},$)=>{const x=v.$c(W,k),h=x==="hidden";x==="disabled"&&(d=!0),x==="readOnly"&&(g=!0);const{t:M}=v.Gt(),D=v.hc(k),[S,y]=n.useState(""),s=n.useRef(null),L=n.useRef(null),C=n.useCallback(()=>{if(O)try{L.current||(L.current=new AudioContext);const u=L.current,p=u.createOscillator(),f=u.createGain();p.connect(f),f.connect(u.destination),p.frequency.value=Q,p.type="square",f.gain.value=.3,p.start(),p.stop(u.currentTime+B/1e3)}catch{}},[O,Q,B]),m=n.useCallback(()=>{S.trim()&&(C(),b?.({value:S.trim(),format:"manual",scannedAt:new Date}),y(""),s.current?.focus())},[S,b,C]),c=w.slice(0,H);return h?null:e.jsxs("div",{ref:$,id:D,className:`nice-scanner nice-size-${N}${I?` ${I}`:""}${a?" nice-error":""}${d?" nice-disabled":""}`,style:P,children:[t&&e.jsxs("div",{className:"nice-scanner__label",children:[t,o&&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${U==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>K?.("camera"),disabled:d,children:[e.jsx(v.oa,{name:"camera",size:16})," ",M("camera","Camera")]}),e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${U==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>K?.("manual"),disabled:d,children:[e.jsx(v.oa,{name:"edit",size:16})," ",M("manual","Manual")]})]}),U==="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(v.oa,{name:"camera",size:32})}),e.jsx("p",{children:M("cameraPlaceholder","Camera preview — connect scanner adapter")})]})})}),U==="manual"&&!g&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:s,className:"nice-input nice-scanner__input",type:"text",value:S,onChange:u=>y(u.target.value),onKeyDown:u=>u.key==="Enter"&&m(),placeholder:Y??M("enterCode","Enter or scan code…"),disabled:d,autoFocus:j}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:m,disabled:d||!S.trim(),"aria-label":M("submit","Submit"),children:e.jsx(v.oa,{name:"check",size:16})})]}),_&&c.length>0&&e.jsxs("div",{className:"nice-scanner__history",children:[e.jsx("div",{className:"nice-scanner__history-label",children:M("recentScans","Recent scans")}),c.map((u,p)=>e.jsxs("div",{className:"nice-scanner__history-item",children:[e.jsx("span",{className:"nice-scanner__history-value",children:u.value}),u.format&&e.jsx("span",{className:"nice-scanner__history-format",children:u.format}),e.jsx("span",{className:"nice-scanner__history-time",children:u.scannedAt.toLocaleTimeString()})]},p))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});Dn.displayName="NiceScannerControl";const Ln=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:d,readOnly:g,size:N="md",id:k,className:I,style:P,accessMode:W,value:U="",onChange:b,onComplete:K,length:O=4,masked:Q=!0,showKeypad:B=!1,autoSubmit:Y=!0,shake:w=!1,placeholderChar:_="·"},H)=>{const j=v.$c(W,k),z=j==="hidden";j==="disabled"&&(d=!0),j==="readOnly"&&(g=!0);const{t:$}=v.Gt(),x=v.hc(k),h=n.useRef([]),[M,D]=n.useState(!1);n.useEffect(()=>{if(w){D(!0);const C=setTimeout(()=>D(!1),500);return()=>clearTimeout(C)}},[w]);const S=U.split("").slice(0,O);for(;S.length<O;)S.push("");const y=n.useCallback((C,m)=>{const c=[...S];c[C]=m;const u=c.join("");b?.(u),m&&C<O-1&&h.current[C+1]?.focus(),Y&&u.length===O&&u.indexOf("")===-1&&K?.(u)},[S,O,b,K,Y]),s=n.useCallback((C,m)=>{C.key==="Backspace"&&!S[m]&&m>0&&(h.current[m-1]?.focus(),y(m-1,"")),C.key==="ArrowLeft"&&m>0&&h.current[m-1]?.focus(),C.key==="ArrowRight"&&m<O-1&&h.current[m+1]?.focus()},[S,O,y]),L=n.useCallback(C=>{if(C==="clear"){b?.(""),h.current[0]?.focus();return}if(C==="backspace"){const m=U.slice(0,-1);b?.(m);const c=Math.max(0,m.length-1);h.current[c]?.focus();return}if(U.length<O){const m=U+C;b?.(m),m.length<O&&h.current[m.length]?.focus(),Y&&m.length===O&&K?.(m)}},[U,O,b,K,Y]);return z?null:e.jsxs("div",{ref:H,id:x,className:`nice-pin nice-size-${N}${M?" nice-pin--shake":""}${I?` ${I}`:""}${a?" nice-error":""}${d?" nice-disabled":""}`,style:P,children:[t&&e.jsxs("label",{className:"nice-pin__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-pin__boxes",children:S.map((C,m)=>e.jsx("input",{ref:c=>{h.current[m]=c},className:"nice-pin__box",type:Q?"password":"text",inputMode:"numeric",maxLength:1,value:C,onChange:c=>{const u=c.target.value.replace(/\D/g,"");u.length<=1&&y(m,u)},onKeyDown:c=>s(c,m),disabled:d,readOnly:g,placeholder:_,"aria-label":`${$("digit","Digit")} ${m+1}`},m))}),B&&!g&&e.jsx("div",{className:"nice-pin__keypad",children:["1","2","3","4","5","6","7","8","9","clear","0","backspace"].map(C=>e.jsx("button",{type:"button",className:`nice-pin__key${C==="clear"||C==="backspace"?" nice-pin__key--action":""}`,onClick:()=>L(C),disabled:d,"aria-label":C==="backspace"?$("backspace","Backspace"):C==="clear"?$("clear","Clear"):void 0,children:C==="clear"?"C":C==="backspace"?e.jsx(v.oa,{name:"arrow-left",size:18}):C},C))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});Ln.displayName="NicePinCodeInput";exports.DEFAULT_ASPECT_RATIOS=bn;exports.EMOJI_DATA=at;exports.GRADIENT_PRESETS=nn;exports.NICE_COLOR_PRESET_KEYS=Xn;exports.NiceAccountPicker=zn;exports.NiceAddressInput=Cn;exports.NiceCalendar=on;exports.NiceCodeDiffEditor=gn;exports.NiceCodeEditor=Ze;exports.NiceCodeEditor$1=Ni;exports.NiceCodeEditorAI=Ci;exports.NiceColorPalette=en;exports.NiceContactPicker=En;exports.NiceCropEditor=jn;exports.NiceCurrencyInput=Sn;exports.NiceDateRangeBox=oi;exports.NiceDocumentEditor=Nn;exports.NiceDropDownBox=si;exports.NiceEmojiPicker=xn;exports.NiceGradientPicker=an;exports.NiceHtmlEditor=xt;exports.NiceHtmlEditor$1=gi;exports.NiceHtmlEditorAI=xi;exports.NiceImageAnnotator=vn;exports.NiceImageEditor=kn;exports.NiceInputOtp=rn;exports.NiceInvoiceLineEditor=$n;exports.NiceKeyValueEditor=Ii;exports.NiceKnob=cn;exports.NiceLogConsole=yn;exports.NiceLookup=ei;exports.NiceMarkdownEditor=_n;exports.NiceMention=ln;exports.NicePDFAnnotationEditor=Tn;exports.NicePickList=pn;exports.NicePinCodeInput=Ln;exports.NiceRangeSlider=ri;exports.NiceScannerControl=Dn;exports.NiceScriptRunner=Ti;exports.NiceSignature=Ai;exports.NiceSignaturePad=wn;exports.NiceSimpleCodeEditor=fn;exports.NiceTaxRatePicker=An;exports.NiceTreeSelect=un;exports.NiceVatInput=In;exports.NiceWiki=Rn;exports.applyPreset=it;exports.contrastRatio=tt;exports.cssToGradient=tn;exports.generateHarmony=qe;exports.generateVariations=qt;exports.gradientToCss=pt;exports.hexToHsv=Ae;exports.hexToRgb=Je;exports.hsvToHex=Ee;exports.hsvToRgb=Vt;exports.randomPalette=Zt;exports.rgbToHex=Xt;exports.rgbToHsl=Gt;exports.rgbToHsv=ft;exports.wcagLevel=nt;